From nobody Tue Feb 10 01:16:18 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1571916285; cv=none; d=zoho.com; s=zohoarc; b=nwhK7uHFekk1UiTzRCmaU18dp5defsj5WNp+zei3sRR7/YJ/hmwQ81DmzVqDmKyATW1/EwDot6JvPVrfaKMo6aXAs/EyQRzEr73M/9hduhQwK/KlWdhWDlrcEmUwjEcZqStp94nYKZFDSsE7BvSEpabpZA4ihsOq3peyVrvMM48= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571916285; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tkanIxOZCQB+fFmtfxmwX+fA4+zHF/kSyfCnpD1kiBY=; b=YrL0d5eydYNAsuVEBXanNUBEuF5Jr+5NObvGOvF2QQZeEMWBS+SCua8EeYH6DDk+eGRJCMt4hI5FdkTQgCcBRgl8n5qH7JCNDBiWeUqtmQlcaI4fcuntMEJsQx918QeqzP65GUtmhTKH/yYvR0xbiULN9G0ZdQggHqL+7ixTVQE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571916285178764.5961549570635; Thu, 24 Oct 2019 04:24:45 -0700 (PDT) Received: from localhost ([::1]:35088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNYaQ-000458-5T for importer@patchew.org; Thu, 24 Oct 2019 04:35:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36723) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNYKX-0004t2-GO for qemu-devel@nongnu.org; Thu, 24 Oct 2019 04:18:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNYKV-0005Gx-J9 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 04:18:49 -0400 Received: from bilbo.ozlabs.org ([2401:3900:2:1::2]:48817 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNYKV-00059J-4i; Thu, 24 Oct 2019 04:18:47 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 46zKrZ46jRz9sRl; Thu, 24 Oct 2019 19:18:37 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1571905118; bh=LIu/9orQqM+uHUGN1XbfnZlinvHNg01lhAvD+xkXWok=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cQ4J071tEkPoYAN5fDp/RYbQxMy+53cu9miBiB6dxNVMZQQr0V1W2oHKLEclPw8Ru tSd/MJiTwymeqQFGXVB6guFT+P2lv8M/3Yz9keSXxZg3rH2vSpaLpYJGH1d6xyjMUw t9O6exA6HSFTQzTIAtPRwH1IJKrEocziOy4vNelQ= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 15/28] spapr: Remove SpaprIrq::init_kvm hook Date: Thu, 24 Oct 2019 19:18:00 +1100 Message-Id: <20191024081813.2115-16-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191024081813.2115-1-david@gibson.dropbear.id.au> References: <20191024081813.2115-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This hook is a bit odd. The only caller is spapr_irq_init_kvm(), but it explicitly takes an SpaprIrq *, so it's never really called through the current SpaprIrq. Essentially this is just a way of passing through a function pointer so that spapr_irq_init_kvm() can handle some configuration and error handling logic without duplicating it between the xics and xive reset paths. So, make it just take that function pointer. Because of earlier reworks to the KVM connect/disconnect code in the xics and xive backends we can also eliminate some wrapper functions and streamline error handling a bit. Signed-off-by: David Gibson Reviewed-by: Greg Kurz Reviewed-by: C=C3=A9dric Le Goater --- hw/ppc/spapr_irq.c | 74 +++++++++++++------------------------- include/hw/ppc/spapr_irq.h | 1 - 2 files changed, 25 insertions(+), 50 deletions(-) diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index 5c8ffb27da..7cd18e5b15 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -65,33 +65,35 @@ void spapr_irq_msi_free(SpaprMachineState *spapr, int i= rq, uint32_t num) bitmap_clear(spapr->irq_map, irq - SPAPR_IRQ_MSI, num); } =20 -static void spapr_irq_init_kvm(SpaprMachineState *spapr, - SpaprIrq *irq, Error **errp) +static int spapr_irq_init_kvm(int (*fn)(SpaprInterruptController *, Error = **), + SpaprInterruptController *intc, + Error **errp) { - MachineState *machine =3D MACHINE(spapr); + MachineState *machine =3D MACHINE(qdev_get_machine()); Error *local_err =3D NULL; =20 if (kvm_enabled() && machine_kernel_irqchip_allowed(machine)) { - irq->init_kvm(spapr, &local_err); - if (local_err && machine_kernel_irqchip_required(machine)) { - error_prepend(&local_err, - "kernel_irqchip requested but unavailable: "); - error_propagate(errp, local_err); - return; - } + if (fn(intc, &local_err) < 0) { + if (machine_kernel_irqchip_required(machine)) { + error_prepend(&local_err, + "kernel_irqchip requested but unavailable: "= ); + error_propagate(errp, local_err); + return -1; + } =20 - if (!local_err) { - return; + /* + * We failed to initialize the KVM device, fallback to + * emulated mode + */ + error_prepend(&local_err, + "kernel_irqchip allowed but unavailable: "); + error_append_hint(&local_err, + "Falling back to kernel-irqchip=3Doff\n"); + warn_report_err(local_err); } - - /* - * We failed to initialize the KVM device, fallback to - * emulated mode - */ - error_prepend(&local_err, "kernel_irqchip allowed but unavailable:= "); - error_append_hint(&local_err, "Falling back to kernel-irqchip=3Dof= f\n"); - warn_report_err(local_err); } + + return 0; } =20 /* @@ -112,20 +114,7 @@ static int spapr_irq_post_load_xics(SpaprMachineState = *spapr, int version_id) =20 static void spapr_irq_reset_xics(SpaprMachineState *spapr, Error **errp) { - Error *local_err =3D NULL; - - spapr_irq_init_kvm(spapr, &spapr_irq_xics, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } -} - -static void spapr_irq_init_kvm_xics(SpaprMachineState *spapr, Error **errp) -{ - if (kvm_enabled()) { - xics_kvm_connect(SPAPR_INTC(spapr->ics), errp); - } + spapr_irq_init_kvm(xics_kvm_connect, SPAPR_INTC(spapr->ics), errp); } =20 SpaprIrq spapr_irq_xics =3D { @@ -136,7 +125,6 @@ SpaprIrq spapr_irq_xics =3D { =20 .post_load =3D spapr_irq_post_load_xics, .reset =3D spapr_irq_reset_xics, - .init_kvm =3D spapr_irq_init_kvm_xics, }; =20 /* @@ -151,7 +139,6 @@ static int spapr_irq_post_load_xive(SpaprMachineState *= spapr, int version_id) static void spapr_irq_reset_xive(SpaprMachineState *spapr, Error **errp) { CPUState *cs; - Error *local_err =3D NULL; =20 CPU_FOREACH(cs) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); @@ -160,9 +147,8 @@ static void spapr_irq_reset_xive(SpaprMachineState *spa= pr, Error **errp) spapr_xive_set_tctx_os_cam(spapr_cpu_state(cpu)->tctx); } =20 - spapr_irq_init_kvm(spapr, &spapr_irq_xive, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (spapr_irq_init_kvm(kvmppc_xive_connect, + SPAPR_INTC(spapr->xive), errp) < 0) { return; } =20 @@ -170,13 +156,6 @@ static void spapr_irq_reset_xive(SpaprMachineState *sp= apr, Error **errp) spapr_xive_mmio_set_enabled(spapr->xive, true); } =20 -static void spapr_irq_init_kvm_xive(SpaprMachineState *spapr, Error **errp) -{ - if (kvm_enabled()) { - kvmppc_xive_connect(SPAPR_INTC(spapr->xive), errp); - } -} - SpaprIrq spapr_irq_xive =3D { .nr_xirqs =3D SPAPR_NR_XIRQS, .nr_msis =3D SPAPR_NR_MSIS, @@ -185,7 +164,6 @@ SpaprIrq spapr_irq_xive =3D { =20 .post_load =3D spapr_irq_post_load_xive, .reset =3D spapr_irq_reset_xive, - .init_kvm =3D spapr_irq_init_kvm_xive, }; =20 /* @@ -251,7 +229,6 @@ SpaprIrq spapr_irq_dual =3D { =20 .post_load =3D spapr_irq_post_load_dual, .reset =3D spapr_irq_reset_dual, - .init_kvm =3D NULL, /* should not be used */ }; =20 =20 @@ -675,7 +652,6 @@ SpaprIrq spapr_irq_xics_legacy =3D { =20 .post_load =3D spapr_irq_post_load_xics, .reset =3D spapr_irq_reset_xics, - .init_kvm =3D spapr_irq_init_kvm_xics, }; =20 static void spapr_irq_register_types(void) diff --git a/include/hw/ppc/spapr_irq.h b/include/hw/ppc/spapr_irq.h index 0df95e1b5a..06179b271f 100644 --- a/include/hw/ppc/spapr_irq.h +++ b/include/hw/ppc/spapr_irq.h @@ -85,7 +85,6 @@ typedef struct SpaprIrq { =20 int (*post_load)(SpaprMachineState *spapr, int version_id); void (*reset)(SpaprMachineState *spapr, Error **errp); - void (*init_kvm)(SpaprMachineState *spapr, Error **errp); } SpaprIrq; =20 extern SpaprIrq spapr_irq_xics; --=20 2.21.0