From patchwork Thu Feb 16 12:25:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 654028 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp321115wrr; Thu, 16 Feb 2023 04:27:29 -0800 (PST) X-Google-Smtp-Source: AK7set9AeYsJC8OioLgJhrLSSAKpkwceUg3VYQSMqgnAEL2nEJegoneTylcU/OXqr4cCTBe0Lgd6 X-Received: by 2002:a05:6214:2504:b0:56e:fe7b:8bcd with SMTP id gf4-20020a056214250400b0056efe7b8bcdmr2281521qvb.37.1676550449694; Thu, 16 Feb 2023 04:27:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676550449; cv=none; d=google.com; s=arc-20160816; b=y3I7CyxPlBrMFCjhZcsTH9mQtCJ0LiDX9wOnkBrKNVcHBL4+FUBUTEJPdTC59V+enB g4hrAOZCeX0JdFa9g9sFFPwsZ9gZxSoe/Zbi6ve1vi5CfFobUqub32uypo3EhE6Lylkh qHjUvRMw7guYPqtZmANaVm9ACqdHJ7jsAYpBt012K9ArMhoI9eVzjVUXIF9KCjlreOOx DEr0J8JFQ1uRn0WJRdbVdJGfXntgnhp4pr9eVKVgW7K5+ERSnVgjpc9guTJ1qAiZHVX8 10Wam3kzTUrvknuYXMFmtD7J3jYEIB4D3sbLha6Wt8RMhc9hCd3ZqaAjV2MCQWsEjHeB gfog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vXaKAK994idnw+4qe0vPaymYezvQPE1zxpNZ2GlwOtY=; b=q7dWJhajEyyHvbn+S6d0ds+V0jWkV2sxlKJNZgEeuQVFuU0vkuoj4oyizavh51Ijls EHXF37zTlEvVUGDF/hxswZDLxgmiDu1/Hl3lQQ483l16l5UXnspxUlUE0EzkUY9axNbD jdJjSqduqIjURw8X9lLEdBmJnkJUN6ZbYarmPyEhsq4LPAvg3G+GjWmvg8oADVO0vi7f nWHFGGF2rAbI4YaBRJCfFUYNuBoAxCVS0tOiIXArWyf69P+h1s7iveeDLA2drxIMirWZ HTiQJPYP1GS9y7q88TfDV1F7CM6foGNkhuWegdwoEEOyap0SzA7vEyEKahkJ5vMp7Scx RuAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TYhiLdvI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v15-20020a05620a0f0f00b0073b7f378bcesi1525821qkl.422.2023.02.16.04.27.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Feb 2023 04:27:29 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TYhiLdvI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSdKm-0002o8-6m; Thu, 16 Feb 2023 07:25:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSdKi-0002jz-MV for qemu-devel@nongnu.org; Thu, 16 Feb 2023 07:25:52 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSdKg-0007yy-CG for qemu-devel@nongnu.org; Thu, 16 Feb 2023 07:25:52 -0500 Received: by mail-wr1-x42b.google.com with SMTP id y1so1692472wru.2 for ; Thu, 16 Feb 2023 04:25:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vXaKAK994idnw+4qe0vPaymYezvQPE1zxpNZ2GlwOtY=; b=TYhiLdvIy3/9XqbcRntWNxRyLPiuO0xeG0JeiBg3qJFr4UXK/4jjCe5YpO1MCqhBAS xN2jBf77sOM5tplhAc4nm8JkJW/XDWCDDIkobOPk+YVb0A1pFPCHx9mDDAhyJHdbFYY0 zrS2PBh2TdDwCBSRqDKlJxA2hnL9EtGY3aGcC9Hk3w8sbiJQUPS1cSs/qZYwt6MWCUYi mkQaM6ALL74/ItMmwtrWiJA/s/a696+u4sSjKtmDFJz4oVt/X+gBLGRn2QULUv8iq9Yk +Lrgm/QJ3IdInzT3ZJoChp2qrBh4niSOcO21EKYL3LAoaUM8Xv5If9Y+3Gxuecwjp1Gb dtNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vXaKAK994idnw+4qe0vPaymYezvQPE1zxpNZ2GlwOtY=; b=BmHiJUUHeUoeFT+roIDhAZcDDGL3JILuFraVRbI7YXu5xvNf3qDGV1xyg4603HMjfo wvI+k2Z2QUodgB/2SBj5gR69x/CYcHS9mNyJgZ9S2U5v4vDVY2w0ruJEERG894UZ9XcS vXBxSlKnr6vOD9nMefHDQ0otPCX0Ec6WJqKw35B8pUIIgVQsH5p91P6JM8tNY9zsnY1F hVwij0W9ljL/GZQpFsl8WgGvMwETSODTeb3E8TTIKZFOO4+MNdyE3HNKtO2Mwme+ihC6 VOryx/cBJVnhfc7R32OdomVTNBWbka0X31Q53B8JayOvJhVIDv/L1sWvwasBApap//Pg aK1g== X-Gm-Message-State: AO0yUKU7SHZ/hE8LQ/olzzC58DCP0C0ogN6eZSXSZ7+qyRTSw64z1AqP OoHfliVJwP5RRBXlhcMLW/SbMgZ2xD3jcgWi X-Received: by 2002:a5d:6a8e:0:b0:2c5:561e:809b with SMTP id s14-20020a5d6a8e000000b002c5561e809bmr3715424wru.66.1676550349391; Thu, 16 Feb 2023 04:25:49 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id g1-20020a5d46c1000000b002c57384dfe0sm1369835wrs.113.2023.02.16.04.25.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 16 Feb 2023 04:25:48 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , qemu-arm@nongnu.org, qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [RFC PATCH 4/5] hw/nmi: Simplify nmi_monitor_handle() and do_nmi() Date: Thu, 16 Feb 2023 13:25:23 +0100 Message-Id: <20230216122524.67212-5-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230216122524.67212-1-philmd@linaro.org> References: <20230216122524.67212-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=philmd@linaro.org; helo=mail-wr1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Since the previous commit, object_child_foreach_recursive()'s handler takes an Error* argument and return a boolean. We can remove these fields from the do_nmi_s structure, which then only contains the 'int cpu_index' field. Directly pass 'cpu_index' as context, removing 'struct do_nmi_s'. Signed-off-by: Philippe Mathieu-Daudé --- RFC: please double-check... hw/core/nmi.c | 41 ++++++----------------------------------- 1 file changed, 6 insertions(+), 35 deletions(-) diff --git a/hw/core/nmi.c b/hw/core/nmi.c index fa74c405f7..f5a6483e89 100644 --- a/hw/core/nmi.c +++ b/hw/core/nmi.c @@ -26,51 +26,22 @@ #include "qemu/module.h" #include "monitor/monitor.h" -struct do_nmi_s { - int cpu_index; - Error *err; - bool handled; -}; - -static void nmi_children(Object *o, struct do_nmi_s *ns); - static bool do_nmi(Object *o, void *opaque, Error **errp) { - struct do_nmi_s *ns = opaque; + int *cpu_index = opaque; NMIState *n = (NMIState *) object_dynamic_cast(o, TYPE_NMI); - if (n) { - NMIClass *nc = NMI_GET_CLASS(n); - - ns->handled = true; - if (!nc->nmi_monitor_handler(n, ns->cpu_index, &ns->err)) { - return false; - } + if (!n) { + error_setg(errp, QERR_UNSUPPORTED); + return false; } - nmi_children(o, ns); - return true; -} - -static void nmi_children(Object *o, struct do_nmi_s *ns) -{ - object_child_foreach(o, do_nmi, ns, NULL); + return NMI_GET_CLASS(n)->nmi_monitor_handler(n, *cpu_index, errp); } void nmi_monitor_handle(int cpu_index, Error **errp) { - struct do_nmi_s ns = { - .cpu_index = cpu_index, - .err = NULL, - .handled = false - }; - - nmi_children(object_get_root(), &ns); - if (ns.handled) { - error_propagate(errp, ns.err); - } else { - error_setg(errp, QERR_UNSUPPORTED); - } + object_child_foreach_recursive(object_get_root(), do_nmi, &cpu_index, errp); } static const TypeInfo nmi_info = {