From nobody Mon Feb 9 13:49:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496986306659353.67995350795616; Thu, 8 Jun 2017 22:31:46 -0700 (PDT) Received: from localhost ([::1]:52682 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCWP-0008Ih-4i for importer@patchew.org; Fri, 09 Jun 2017 01:31:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46987) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCRw-0003va-Jm for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJCRs-0006bg-I9 for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:08 -0400 Received: from ozlabs.org ([103.22.144.67]:60953) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJCRr-0006aD-DQ; Fri, 09 Jun 2017 01:27:04 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wkW4b455kz9s9Y; Fri, 9 Jun 2017 15:26:55 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1496986015; bh=bSUxJFGxSJ5ELblzatP/D/aSKDCr+fdZxMrNQsIt0ts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ivCAB3bgRXUvcjQj3xehRgP1mh+13Esi6RLtMOTZH7rCgtXpSkltLb/02GfJrEzs6 PeEzx9DqzOqSlpnmM72mnHofcZGHaJoGX/ro4q+GHpBKoZqP0yVUqbd8PVDP5sW7Rs NPoRp0YZS2XEmsXcv6I3ld4OlAhZabRN0o2EU07o= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 9 Jun 2017 15:26:33 +1000 Message-Id: <20170609052652.23200-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170609052652.23200-1-david@gibson.dropbear.id.au> References: <20170609052652.23200-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 01/20] target/ppc: pass const string to kvmppc_is_mem_backend_page_size_ok() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: agraf@suse.de, qemu-devel@nongnu.org, sursingh@redhat.com, mdroth@linux.vnet.ibm.com, Greg Kurz , qemu-ppc@nongnu.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) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz This function has three implementations. Two are stubs that do nothing and the third one only passes the obj_path argument to: Object *object_resolve_path(const char *path, bool *ambiguous); Signed-off-by: Greg Kurz Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Thomas Huth Signed-off-by: David Gibson --- target/ppc/kvm.c | 4 ++-- target/ppc/kvm_ppc.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 51249ce..8881762 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -478,7 +478,7 @@ static void kvm_fixup_page_sizes(PowerPCCPU *cpu) } } =20 -bool kvmppc_is_mem_backend_page_size_ok(char *obj_path) +bool kvmppc_is_mem_backend_page_size_ok(const char *obj_path) { Object *mem_obj =3D object_resolve_path(obj_path, NULL); char *mempath =3D object_property_get_str(mem_obj, "mem-path", NULL); @@ -499,7 +499,7 @@ static inline void kvm_fixup_page_sizes(PowerPCCPU *cpu) { } =20 -bool kvmppc_is_mem_backend_page_size_ok(char *obj_path) +bool kvmppc_is_mem_backend_page_size_ok(const char *obj_path) { return true; } diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h index f48243d..eab7c8f 100644 --- a/target/ppc/kvm_ppc.h +++ b/target/ppc/kvm_ppc.h @@ -64,7 +64,7 @@ int kvmppc_enable_hwrng(void); int kvmppc_put_books_sregs(PowerPCCPU *cpu); PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void); =20 -bool kvmppc_is_mem_backend_page_size_ok(char *obj_path); +bool kvmppc_is_mem_backend_page_size_ok(const char *obj_path); =20 #else =20 @@ -211,7 +211,7 @@ static inline uint64_t kvmppc_rma_size(uint64_t current= _size, return ram_size; } =20 -static inline bool kvmppc_is_mem_backend_page_size_ok(char *obj_path) +static inline bool kvmppc_is_mem_backend_page_size_ok(const char *obj_path) { return true; } --=20 2.9.4 From nobody Mon Feb 9 13:49:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496986135268334.35855318546044; Thu, 8 Jun 2017 22:28:55 -0700 (PDT) Received: from localhost ([::1]:52666 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCTc-0005iI-9G for importer@patchew.org; Fri, 09 Jun 2017 01:28:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46925) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCRt-0003uU-PV for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJCRs-0006bh-I1 for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:05 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:53807) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJCRr-0006aH-K5; Fri, 09 Jun 2017 01:27:04 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wkW4b2k1tz9s74; Fri, 9 Jun 2017 15:26:55 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1496986015; bh=h6O3BKspj0DPNfYLeFDwanhgsUlXKieOL6L27MdwWiM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hwDqHQYuG6XzBqZagzw8i0pS4n4pbq3j4CMhOLLOSA425yc3kDwTWqtOpKe2M1TJr 4d9mTdifETtJzoMmQhD5ciwwe2v3v2ViAW7RN909sGQh8nne2OX9gO0JY9T8+Tp5m8 qcQ8tpY4AioRWcRbUzPNW+9+dSpMS3P0DPNHVBeA= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 9 Jun 2017 15:26:34 +1000 Message-Id: <20170609052652.23200-3-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170609052652.23200-1-david@gibson.dropbear.id.au> References: <20170609052652.23200-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 02/20] target/ppc: fix memory leak in kvmppc_is_mem_backend_page_size_ok() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: agraf@suse.de, qemu-devel@nongnu.org, sursingh@redhat.com, mdroth@linux.vnet.ibm.com, Greg Kurz , qemu-ppc@nongnu.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) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz The string returned by object_property_get_str() is dynamically allocated. Signed-off-by: Greg Kurz Reviewed-by: Thomas Huth Signed-off-by: David Gibson --- target/ppc/kvm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 8881762..f2f7c53 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -486,6 +486,7 @@ bool kvmppc_is_mem_backend_page_size_ok(const char *obj= _path) =20 if (mempath) { pagesize =3D qemu_mempath_getpagesize(mempath); + g_free(mempath); } else { pagesize =3D getpagesize(); } --=20 2.9.4 From nobody Mon Feb 9 13:49:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496986135180586.2067037391138; Thu, 8 Jun 2017 22:28:55 -0700 (PDT) Received: from localhost ([::1]:52667 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCTc-0005jj-NV for importer@patchew.org; Fri, 09 Jun 2017 01:28:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46913) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCRt-0003uN-7e for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJCRs-0006bi-IG for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:05 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:49873) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJCRr-0006aG-Kf; Fri, 09 Jun 2017 01:27:04 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wkW4b5BBwz9s8N; Fri, 9 Jun 2017 15:26:55 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1496986015; bh=F0UBCQmILpad6vT0+MKF6J0XbyvTHcNqTduzuvz9Y+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P1AuOGqeLSxig3kmdhTTbuUjB92Xqu924TCtDBKwlVFjWvFIN5i3no5JLfyKnbK+I yud31sdaJ2RsnXQwbAYVXSX0xc67+rau8YTwNbgQZj7Q1IHw9BAX/+rHlCV9DudOU/ Ph2+KAAhhPxb5q3o1DVBJkM9kLpg/VRrkn47FHf8= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 9 Jun 2017 15:26:35 +1000 Message-Id: <20170609052652.23200-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170609052652.23200-1-david@gibson.dropbear.id.au> References: <20170609052652.23200-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 03/20] spapr: fix memory leak in spapr_memory_pre_plug() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: agraf@suse.de, qemu-devel@nongnu.org, sursingh@redhat.com, mdroth@linux.vnet.ibm.com, Greg Kurz , qemu-ppc@nongnu.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) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz The string returned by object_property_get_str() is dynamically allocated. (Spotted by Coverity, CID 1375942) Signed-off-by: Greg Kurz Signed-off-by: David Gibson --- hw/ppc/spapr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 91b4057..9b7ae28 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2615,8 +2615,11 @@ static void spapr_memory_pre_plug(HotplugHandler *ho= tplug_dev, DeviceState *dev, if (mem_dev && !kvmppc_is_mem_backend_page_size_ok(mem_dev)) { error_setg(errp, "Memory backend has bad page size. " "Use 'memory-backend-file' with correct mem-path."); - return; + goto out; } + +out: + g_free(mem_dev); } =20 struct sPAPRDIMMState { --=20 2.9.4 From nobody Mon Feb 9 13:49:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496986469783910.8375857608985; Thu, 8 Jun 2017 22:34:29 -0700 (PDT) Received: from localhost ([::1]:52692 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCZ2-0002io-3H for importer@patchew.org; Fri, 09 Jun 2017 01:34:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47003) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCRx-0003w0-5Q for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJCRv-0006da-Lk for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:09 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:34139) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJCRv-0006cC-8v; Fri, 09 Jun 2017 01:27:07 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wkW4b6wQhz9sN5; Fri, 9 Jun 2017 15:26:55 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1496986015; bh=pbBVm4E6h9vKto7BGzBFqMquE783fbaKizRXl/cSwNQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CU8SZ0L2nl1Z3a3XiJxUEOEt/HMyQWiQRr/K8dDW/F8VkyNtpxMI0FnpbUhEk5SZl Je57RrKZOhqwJYrF8RbAB90Meky41p1VuuKhTlGGSE2Zi2y1bG/wGxx3FdMhSW4T2k KkM5UWNY7I9i8zKIw1Vzz3qyeT8GJdXm2QlSZvlM= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 9 Jun 2017 15:26:36 +1000 Message-Id: <20170609052652.23200-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170609052652.23200-1-david@gibson.dropbear.id.au> References: <20170609052652.23200-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 04/20] pseries: Correct panic behaviour for pseries machine type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, sursingh@redhat.com, mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-ppc@nongnu.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) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The pseries machine type doesn't usually use the 'pvpanic' device as such, because it has a firmware/hypervisor facility with roughly the same purpose. The 'ibm,os-term' RTAS call notifies the hypervisor that the guest has crashed. Our implementation of this call was sending a GUEST_PANICKED qmp event; however, it was not doing the other usual panic actions, making its behaviour different from pvpanic for no good reason. To correct this, we should call qemu_system_guest_panicked() rather than directly sending the panic event. Signed-off-by: David Gibson Reviewed-by: Thomas Huth --- hw/ppc/spapr_rtas.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index 707c4d4..94a2799 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -293,12 +293,9 @@ static void rtas_ibm_os_term(PowerPCCPU *cpu, target_ulong args, uint32_t nret, target_ulong rets) { - target_ulong ret =3D 0; + qemu_system_guest_panicked(NULL); =20 - qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, false, NULL, - &error_abort); - - rtas_st(rets, 0, ret); + rtas_st(rets, 0, RTAS_OUT_SUCCESS); } =20 static void rtas_set_power_level(PowerPCCPU *cpu, sPAPRMachineState *spapr, --=20 2.9.4 From nobody Mon Feb 9 13:49:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496986467948459.88002024561047; Thu, 8 Jun 2017 22:34:27 -0700 (PDT) Received: from localhost ([::1]:52691 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCZ0-0002gw-GJ for importer@patchew.org; Fri, 09 Jun 2017 01:34:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46979) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCRw-0003vU-GV for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJCRs-0006c0-U5 for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:08 -0400 Received: from ozlabs.org ([103.22.144.67]:36421) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJCRs-0006aE-9w; Fri, 09 Jun 2017 01:27:04 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wkW4b5s8gz9sDB; Fri, 9 Jun 2017 15:26:55 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1496986015; bh=3cmyy5lHOK3l0QRPNlNtYfjCWfvmlNu5Uktgbpoj6Rc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SXZE2bi+E72yulOq+LWWo84m2OP3v5XWoTnUUnCoI6S+8wTV9kL7tl4w1HpZy8ih2 wXLrbpe7mewCDVS/ko5PvufWV1hynmcs2hHL2fgnTeL8MbYcroop38dsjLR6AHAgWG Au2vEI9CMJmzP0sshuisKnRPznT8Ei/w+k7VnExo= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 9 Jun 2017 15:26:37 +1000 Message-Id: <20170609052652.23200-6-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170609052652.23200-1-david@gibson.dropbear.id.au> References: <20170609052652.23200-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 05/20] spapr: Clean up DR entity sense handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, sursingh@redhat.com, mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-ppc@nongnu.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) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" DRC classes have an entity_sense method to determine (in a specific PAPR sense) the presence or absence of a device plugged into a DRC. However, we only have one implementation of the method, which explicitly tests for different DRC types. This changes it to instead have different method implementations for the two cases: "logical" and "physical" DRCs. While we're at it, the entity sense method always returns RTAS_OUT_SUCCESS, and the interesting value is returned via pass-by-reference. Simplify this to directly return the value we care about Signed-off-by: David Gibson Reviewed-by: Michael Roth Acked-by: Michael Roth --- hw/ppc/spapr_drc.c | 72 ++++++++++++++++++++++--------------------= ---- hw/ppc/spapr_pci.c | 6 ++-- hw/ppc/trace-events | 1 - include/hw/ppc/spapr_drc.h | 4 +-- 4 files changed, 40 insertions(+), 43 deletions(-) diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 39e7f30..cabeacf 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -185,39 +185,25 @@ static void set_signalled(sPAPRDRConnector *drc) * based on the current allocation/indicator/power states * for the DR connector. */ -static uint32_t entity_sense(sPAPRDRConnector *drc, sPAPRDREntitySense *st= ate) +static sPAPRDREntitySense physical_entity_sense(sPAPRDRConnector *drc) { - if (drc->dev) { - if (spapr_drc_type(drc) !=3D SPAPR_DR_CONNECTOR_TYPE_PCI && - drc->allocation_state =3D=3D SPAPR_DR_ALLOCATION_STATE_UNUSABL= E) { - /* for logical DR, we return a state of UNUSABLE - * iff the allocation state UNUSABLE. - * Otherwise, report the state as USABLE/PRESENT, - * as we would for PCI. - */ - *state =3D SPAPR_DR_ENTITY_SENSE_UNUSABLE; - } else { - /* this assumes all PCI devices are assigned to - * a 'live insertion' power domain, where QEMU - * manages power state automatically as opposed - * to the guest. present, non-PCI resources are - * unaffected by power state. - */ - *state =3D SPAPR_DR_ENTITY_SENSE_PRESENT; - } + /* this assumes all PCI devices are assigned to a 'live insertion' + * power domain, where QEMU manages power state automatically as + * opposed to the guest. present, non-PCI resources are unaffected + * by power state. + */ + return drc->dev ? SPAPR_DR_ENTITY_SENSE_PRESENT + : SPAPR_DR_ENTITY_SENSE_EMPTY; +} + +static sPAPRDREntitySense logical_entity_sense(sPAPRDRConnector *drc) +{ + if (drc->dev + && (drc->allocation_state !=3D SPAPR_DR_ALLOCATION_STATE_UNUSABLE)= ) { + return SPAPR_DR_ENTITY_SENSE_PRESENT; } else { - if (spapr_drc_type(drc) =3D=3D SPAPR_DR_CONNECTOR_TYPE_PCI) { - /* PCI devices, and only PCI devices, use EMPTY - * in cases where we'd otherwise use UNUSABLE - */ - *state =3D SPAPR_DR_ENTITY_SENSE_EMPTY; - } else { - *state =3D SPAPR_DR_ENTITY_SENSE_UNUSABLE; - } + return SPAPR_DR_ENTITY_SENSE_UNUSABLE; } - - trace_spapr_drc_entity_sense(spapr_drc_index(drc), *state); - return RTAS_OUT_SUCCESS; } =20 static void prop_get_index(Object *obj, Visitor *v, const char *name, @@ -445,7 +431,6 @@ static void reset(DeviceState *d) { sPAPRDRConnector *drc =3D SPAPR_DR_CONNECTOR(d); sPAPRDRConnectorClass *drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); - sPAPRDREntitySense state; =20 trace_spapr_drc_reset(spapr_drc_index(drc)); =20 @@ -477,8 +462,7 @@ static void reset(DeviceState *d) } } =20 - drck->entity_sense(drc, &state); - if (state =3D=3D SPAPR_DR_ENTITY_SENSE_PRESENT) { + if (drck->dr_entity_sense(drc) =3D=3D SPAPR_DR_ENTITY_SENSE_PRESENT) { drck->set_signalled(drc); } } @@ -488,8 +472,7 @@ static bool spapr_drc_needed(void *opaque) sPAPRDRConnector *drc =3D (sPAPRDRConnector *)opaque; sPAPRDRConnectorClass *drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); bool rc =3D false; - sPAPRDREntitySense value; - drck->entity_sense(drc, &value); + sPAPRDREntitySense value =3D drck->dr_entity_sense(drc); =20 /* If no dev is plugged in there is no need to migrate the DRC state */ if (value !=3D SPAPR_DR_ENTITY_SENSE_PRESENT) { @@ -667,7 +650,6 @@ static void spapr_dr_connector_class_init(ObjectClass *= k, void *data) drck->set_indicator_state =3D set_indicator_state; drck->set_allocation_state =3D set_allocation_state; drck->get_name =3D get_name; - drck->entity_sense =3D entity_sense; drck->attach =3D attach; drck->detach =3D detach; drck->release_pending =3D release_pending; @@ -678,6 +660,20 @@ static void spapr_dr_connector_class_init(ObjectClass = *k, void *data) dk->user_creatable =3D false; } =20 +static void spapr_drc_physical_class_init(ObjectClass *k, void *data) +{ + sPAPRDRConnectorClass *drck =3D SPAPR_DR_CONNECTOR_CLASS(k); + + drck->dr_entity_sense =3D physical_entity_sense; +} + +static void spapr_drc_logical_class_init(ObjectClass *k, void *data) +{ + sPAPRDRConnectorClass *drck =3D SPAPR_DR_CONNECTOR_CLASS(k); + + drck->dr_entity_sense =3D logical_entity_sense; +} + static void spapr_drc_cpu_class_init(ObjectClass *k, void *data) { sPAPRDRConnectorClass *drck =3D SPAPR_DR_CONNECTOR_CLASS(k); @@ -716,6 +712,7 @@ static const TypeInfo spapr_drc_physical_info =3D { .name =3D TYPE_SPAPR_DRC_PHYSICAL, .parent =3D TYPE_SPAPR_DR_CONNECTOR, .instance_size =3D sizeof(sPAPRDRConnector), + .class_init =3D spapr_drc_physical_class_init, .abstract =3D true, }; =20 @@ -723,6 +720,7 @@ static const TypeInfo spapr_drc_logical_info =3D { .name =3D TYPE_SPAPR_DRC_LOGICAL, .parent =3D TYPE_SPAPR_DR_CONNECTOR, .instance_size =3D sizeof(sPAPRDRConnector), + .class_init =3D spapr_drc_logical_class_init, .abstract =3D true, }; =20 @@ -1010,7 +1008,7 @@ static void rtas_get_sensor_state(PowerPCCPU *cpu, sP= APRMachineState *spapr, goto out; } drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); - ret =3D drck->entity_sense(drc, &sensor_state); + sensor_state =3D drck->dr_entity_sense(drc); =20 out: rtas_st(rets, 0, ret); diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 0c181bb..5cba8f9 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1481,7 +1481,7 @@ static void spapr_phb_hot_plug_child(HotplugHandler *= plug_handler, func_drc =3D spapr_phb_get_pci_func_drc(phb, pci_bus_num(bus), PCI_DEVFN(slotnr, i)); func_drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(func_drc); - func_drck->entity_sense(func_drc, &state); + state =3D func_drck->dr_entity_sense(func_drc); =20 if (state =3D=3D SPAPR_DR_ENTITY_SENSE_PRESENT) { spapr_hotplug_req_add_by_index(func_drc); @@ -1522,7 +1522,7 @@ static void spapr_phb_hot_unplug_child(HotplugHandler= *plug_handler, func_drc =3D spapr_phb_get_pci_func_drc(phb, pci_bus_num(b= us), PCI_DEVFN(slotnr, i)= ); func_drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(func_drc); - func_drck->entity_sense(func_drc, &state); + state =3D func_drck->dr_entity_sense(func_drc); if (state =3D=3D SPAPR_DR_ENTITY_SENSE_PRESENT && !func_drck->release_pending(func_drc)) { error_setg(errp, @@ -1548,7 +1548,7 @@ static void spapr_phb_hot_unplug_child(HotplugHandler= *plug_handler, func_drc =3D spapr_phb_get_pci_func_drc(phb, pci_bus_num(b= us), PCI_DEVFN(slotnr, i)= ); func_drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(func_drc); - func_drck->entity_sense(func_drc, &state); + state =3D func_drck->dr_entity_sense(func_drc); if (state =3D=3D SPAPR_DR_ENTITY_SENSE_PRESENT) { spapr_hotplug_req_remove_by_index(func_drc); } diff --git a/hw/ppc/trace-events b/hw/ppc/trace-events index 43d265f..4979397 100644 --- a/hw/ppc/trace-events +++ b/hw/ppc/trace-events @@ -44,7 +44,6 @@ spapr_drc_set_allocation_state(uint32_t index, int state)= "drc: 0x%"PRIx32", sta spapr_drc_set_allocation_state_finalizing(uint32_t index) "drc: 0x%"PRIx32 spapr_drc_set_configured(uint32_t index) "drc: 0x%"PRIx32 spapr_drc_set_configured_skipping(uint32_t index) "drc: 0x%"PRIx32", isola= ted device" -spapr_drc_entity_sense(uint32_t index, int state) "drc: 0x%"PRIx32", state= : 0x%x" spapr_drc_attach(uint32_t index) "drc: 0x%"PRIx32 spapr_drc_detach(uint32_t index) "drc: 0x%"PRIx32 spapr_drc_awaiting_isolated(uint32_t index) "drc: 0x%"PRIx32 diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h index c88e1be..f892b94 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -214,6 +214,8 @@ typedef struct sPAPRDRConnectorClass { sPAPRDRConnectorTypeShift typeshift; const char *typename; /* used in device tree, PAPR 13.5.2.6 & C.6.1 */ =20 + sPAPRDREntitySense (*dr_entity_sense)(sPAPRDRConnector *drc); + /* accessors for guest-visible (generally via RTAS) DR state */ uint32_t (*set_isolation_state)(sPAPRDRConnector *drc, sPAPRDRIsolationState state); @@ -223,8 +225,6 @@ typedef struct sPAPRDRConnectorClass { sPAPRDRAllocationState state); const char *(*get_name)(sPAPRDRConnector *drc); =20 - uint32_t (*entity_sense)(sPAPRDRConnector *drc, sPAPRDREntitySense *st= ate); - /* QEMU interfaces for managing hotplug operations */ void (*attach)(sPAPRDRConnector *drc, DeviceState *d, void *fdt, int fdt_start_offset, bool coldplug, Error **errp); --=20 2.9.4 From nobody Mon Feb 9 13:49:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496986284370551.2964409679837; Thu, 8 Jun 2017 22:31:24 -0700 (PDT) Received: from localhost ([::1]:52680 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCW1-00080p-Go for importer@patchew.org; Fri, 09 Jun 2017 01:31:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47000) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCRx-0003vp-0I for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJCRv-0006dS-KB for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:09 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:55473) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJCRv-0006cA-7H; Fri, 09 Jun 2017 01:27:07 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wkW4c2fcYz9sNN; Fri, 9 Jun 2017 15:26:55 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1496986016; bh=z9T9L6pM01GMw5Y6ZHCS8zFc0ZBM5TGXIyGuhTpT014=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M57NDeNVx3p1wzWUbPvxU0y1mS/8gQfjkKux/5mMPujNN3hcZp4UB+2I5xNvPtR53 ygP5MxNEAsOS7mg/PBsX1bbk8j5/EqkPCa4ZuJcUx04Pv0EmM1wlT4Jtf1vYYBSvwd oyjm6NZpY1nbVHXR+bbCIaTzYPKmu2dzQguKjSlw= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 9 Jun 2017 15:26:38 +1000 Message-Id: <20170609052652.23200-7-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170609052652.23200-1-david@gibson.dropbear.id.au> References: <20170609052652.23200-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 06/20] spapr: Don't misuse DR-indicator in spapr_recover_pending_dimm_state() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, sursingh@redhat.com, mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-ppc@nongnu.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) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" With some combinations of migration and hotplug we can lost temporary state indicating how many DRCs (guest side hotplug handles) are still connected to a DIMM object in the process of removal. When we hit that situation spapr_recover_pending_dimm_state() is used to scan more extensively and work out the right number. It does this using drc->indicator state to determine what state of disconnection the DRC is in. However, this is not safe, because the indicator state is guest settable - in fact it's more-or-less a purely guest->host notification mechanism which should have no bearing on the internals of hotplug state management. So, replace the test for this with a test on drc->dev, which is a purely qemu side managed variable, and updated the same BQL critical section as the indicator state. This does introduce an off-by-one change, because the indicator state was updated before the call to spapr_lmb_release() on the current DRC, whereas drc->dev is updated afterwards. That's corrected by always decrementing the nr_lmbs value instead of only doing so in the case where we didn't have to recover information. Signed-off-by: David Gibson Reviewed-by: Michael Roth Acked-by: Michael Roth --- hw/ppc/spapr.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 9b7ae28..b2311dc 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2676,7 +2676,7 @@ static sPAPRDIMMState *spapr_recover_pending_dimm_sta= te(sPAPRMachineState *ms, drc =3D spapr_drc_by_id(TYPE_SPAPR_DRC_LMB, addr / SPAPR_MEMORY_BLOCK_SIZE); g_assert(drc); - if (drc->indicator_state !=3D SPAPR_DR_INDICATOR_STATE_INACTIVE) { + if (drc->dev) { avail_lmbs++; } addr +=3D SPAPR_MEMORY_BLOCK_SIZE; @@ -2700,10 +2700,11 @@ void spapr_lmb_release(DeviceState *dev) * during the unplug process. In this case recover it. */ if (ds =3D=3D NULL) { ds =3D spapr_recover_pending_dimm_state(spapr, PC_DIMM(dev)); - if (ds->nr_lmbs) { - return; - } - } else if (--ds->nr_lmbs) { + /* The DRC being examined by the caller at least must be counted */ + g_assert(ds->nr_lmbs); + } + + if (--ds->nr_lmbs) { return; } =20 --=20 2.9.4 From nobody Mon Feb 9 13:49:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496986445059179.76968523199866; Thu, 8 Jun 2017 22:34:05 -0700 (PDT) Received: from localhost ([::1]:52689 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCYd-0002OU-7p for importer@patchew.org; Fri, 09 Jun 2017 01:34:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47007) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCRx-0003wI-AF for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJCRv-0006dM-Hh for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:09 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:59865) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJCRv-0006c9-5E; Fri, 09 Jun 2017 01:27:07 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wkW4c1GKwz9sDG; Fri, 9 Jun 2017 15:26:55 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1496986016; bh=X+Nj6Ihmx3/7TYtPMm1o06xzYSf1HFtNhbW/mBk5jFE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QoAVAMyGE/PSaumM+eeFn1tFQLV1Wcz643TBjgEceBeKcPyRCYUums8Tj0MN+Wz0Q +7bwpsxkq78Gu8dfgjwj3QvyNPfv+lZMAphHrAcZ3PJzLZrJB0JaOCsQbekgAZP46a M+WKQyyMBej+2fC92zM/ChZBczWEbFdOtD/WWx5E= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 9 Jun 2017 15:26:39 +1000 Message-Id: <20170609052652.23200-8-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170609052652.23200-1-david@gibson.dropbear.id.au> References: <20170609052652.23200-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 07/20] spapr: Clean up RTAS set-indicator X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, sursingh@redhat.com, mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-ppc@nongnu.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) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In theory the RTAS set-indicator call can be used for a number of "indicators" defined by PAPR. In practice the only ones we're ever likely to implement are those used for Dynamic Reconfiguration (i.e. hotplug). Because of this, the current implementation determines the associated DRC object, before dispatching based on the type of indicator. However, this means we also need a check that we're dealing with a DR related indicator at all, which duplicates some of the logic from the switch further down. Even though it means a bit of code duplication, things work out cleaner if we delegate the DRC lookup to the individual indicator type functions - and it also allows some further cleanups. While we're there, remove references to "sensor", a copy/paste artefact from the related, but distinct "get-sensor" call. Signed-off-by: David Gibson Reviewed-by: Michael Roth Acked-by: Michael Roth --- hw/ppc/spapr_drc.c | 84 ++++++++++++++++++++++++++++---------------------= ---- hw/ppc/trace-events | 2 -- 2 files changed, 44 insertions(+), 42 deletions(-) diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index cabeacf..f0cff0b 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -903,74 +903,78 @@ out: * RTAS calls */ =20 -static bool sensor_type_is_dr(uint32_t sensor_type) +static uint32_t rtas_set_isolation_state(uint32_t idx, uint32_t state) { - switch (sensor_type) { - case RTAS_SENSOR_TYPE_ISOLATION_STATE: - case RTAS_SENSOR_TYPE_DR: - case RTAS_SENSOR_TYPE_ALLOCATION_STATE: - return true; + sPAPRDRConnector *drc =3D spapr_drc_by_index(idx); + sPAPRDRConnectorClass *drck; + + if (!drc) { + return RTAS_OUT_PARAM_ERROR; } =20 - return false; + drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); + return drck->set_isolation_state(drc, state); } =20 -static void rtas_set_indicator(PowerPCCPU *cpu, sPAPRMachineState *spapr, - uint32_t token, uint32_t nargs, - target_ulong args, uint32_t nret, - target_ulong rets) +static uint32_t rtas_set_allocation_state(uint32_t idx, uint32_t state) { - uint32_t sensor_type; - uint32_t sensor_index; - uint32_t sensor_state; - uint32_t ret =3D RTAS_OUT_SUCCESS; - sPAPRDRConnector *drc; + sPAPRDRConnector *drc =3D spapr_drc_by_index(idx); sPAPRDRConnectorClass *drck; =20 - if (nargs !=3D 3 || nret !=3D 1) { - ret =3D RTAS_OUT_PARAM_ERROR; - goto out; + if (!drc) { + return RTAS_OUT_PARAM_ERROR; } =20 - sensor_type =3D rtas_ld(args, 0); - sensor_index =3D rtas_ld(args, 1); - sensor_state =3D rtas_ld(args, 2); + drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); + return drck->set_allocation_state(drc, state); +} =20 - if (!sensor_type_is_dr(sensor_type)) { - goto out_unimplemented; - } +static uint32_t rtas_set_indicator_state(uint32_t idx, uint32_t state) +{ + sPAPRDRConnector *drc =3D spapr_drc_by_index(idx); + sPAPRDRConnectorClass *drck; =20 - /* if this is a DR sensor we can assume sensor_index =3D=3D drc_index = */ - drc =3D spapr_drc_by_index(sensor_index); if (!drc) { - trace_spapr_rtas_set_indicator_invalid(sensor_index); + return RTAS_OUT_PARAM_ERROR; + } + + drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); + return drck->set_indicator_state(drc, state); +} + +static void rtas_set_indicator(PowerPCCPU *cpu, sPAPRMachineState *spapr, + uint32_t token, + uint32_t nargs, target_ulong args, + uint32_t nret, target_ulong rets) +{ + uint32_t type, idx, state; + uint32_t ret =3D RTAS_OUT_SUCCESS; + + if (nargs !=3D 3 || nret !=3D 1) { ret =3D RTAS_OUT_PARAM_ERROR; goto out; } - drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); =20 - switch (sensor_type) { + type =3D rtas_ld(args, 0); + idx =3D rtas_ld(args, 1); + state =3D rtas_ld(args, 2); + + switch (type) { case RTAS_SENSOR_TYPE_ISOLATION_STATE: - ret =3D drck->set_isolation_state(drc, sensor_state); + ret =3D rtas_set_isolation_state(idx, state); break; case RTAS_SENSOR_TYPE_DR: - ret =3D drck->set_indicator_state(drc, sensor_state); + ret =3D rtas_set_indicator_state(idx, state); break; case RTAS_SENSOR_TYPE_ALLOCATION_STATE: - ret =3D drck->set_allocation_state(drc, sensor_state); + ret =3D rtas_set_allocation_state(idx, state); break; default: - goto out_unimplemented; + ret =3D RTAS_OUT_NOT_SUPPORTED; } =20 out: rtas_st(rets, 0, ret); - return; - -out_unimplemented: - /* currently only DR-related sensors are implemented */ - trace_spapr_rtas_set_indicator_not_supported(sensor_index, sensor_type= ); - rtas_st(rets, 0, RTAS_OUT_NOT_SUPPORTED); } =20 static void rtas_get_sensor_state(PowerPCCPU *cpu, sPAPRMachineState *spap= r, diff --git a/hw/ppc/trace-events b/hw/ppc/trace-events index 4979397..581fa85 100644 --- a/hw/ppc/trace-events +++ b/hw/ppc/trace-events @@ -60,8 +60,6 @@ spapr_ovec_parse_vector(int vector, int byte, uint16_t ve= c_len, uint8_t entry) " spapr_ovec_populate_dt(int byte, uint16_t vec_len, uint8_t entry) "encodin= g guest vector byte %3d / %3d: 0x%.2x" =20 # hw/ppc/spapr_rtas.c -spapr_rtas_set_indicator_invalid(uint32_t index) "sensor index: 0x%"PRIx32 -spapr_rtas_set_indicator_not_supported(uint32_t index, uint32_t type) "sen= sor index: 0x%"PRIx32", type: %"PRIu32 spapr_rtas_get_sensor_state_not_supported(uint32_t index, uint32_t type) "= sensor index: 0x%"PRIx32", type: %"PRIu32 spapr_rtas_get_sensor_state_invalid(uint32_t index) "sensor index: 0x%"PRI= x32 spapr_rtas_ibm_configure_connector_invalid(uint32_t index) "DRC index: 0x%= "PRIx32 --=20 2.9.4 From nobody Mon Feb 9 13:49:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496986292953995.1057547206265; Thu, 8 Jun 2017 22:31:32 -0700 (PDT) Received: from localhost ([::1]:52681 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCWB-000869-EA for importer@patchew.org; Fri, 09 Jun 2017 01:31:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47043) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCRy-0003x7-2Z for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJCRw-0006dz-1V for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:10 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:53475) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJCRv-0006cF-Ab; Fri, 09 Jun 2017 01:27:07 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wkW4c3MVLz9sNC; Fri, 9 Jun 2017 15:26:55 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1496986016; bh=xRuVok7WnWkET5lx69RibSh77cINYrrSNCkLxKndXjU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XSBfNdzVjNxYndDv+oLcAhIGE3W2SRzjG0q6xE/tVvrAlA4Am/O3g8pPcamkK9tHO i8Ho95bhMu1P5Mj+4QBvQcB7M1U4D/xuyCQEW+iZcGABcJRCq6Cm+XM+m3+Cx6xG7x h8/p649H5JYUOlU9WF4klSRm586FezmcyKEmKxhY= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 9 Jun 2017 15:26:40 +1000 Message-Id: <20170609052652.23200-9-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170609052652.23200-1-david@gibson.dropbear.id.au> References: <20170609052652.23200-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 08/20] spapr: Clean up handling of DR-indicator X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, sursingh@redhat.com, mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-ppc@nongnu.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) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" There are 3 types of "indicator" associated with hotplug in the PAPR spec the "allocation state", "isolation state" and "DR-indicator". The first two are intimately tied to the various state transitions associated with hotplug. The DR-indicator, however, is different and simpler. It's basically just a guest controlled variable which can be used by the guest to flag state or problems associated with a device. The idea is that the hypervisor can use it to present information back on management consoles (on some machines with PowerVM it may even control physical LEDs on the machine case associated with the relevant device). For that reason, there's only ever likely to be a single update implementation so the set_indicator_state method isn't useful. Replace it with a direct function call. While we're there, make some small associated cleanups: * PAPR doesn't use the term "indicator state", just "DR-indicator" and the allocation state and isolation state are also considered "indicators". Rename things to be less confusing * Fold set_indicator_state() and rtas_set_indicator_state() into a single rtas_set_dr_indicator() function. Signed-off-by: David Gibson Reviewed-by: Michael Roth Acked-by: Michael Roth --- hw/ppc/spapr_drc.c | 25 ++++++++----------------- hw/ppc/trace-events | 2 +- include/hw/ppc/spapr_drc.h | 16 ++++++++-------- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index f0cff0b..19e2c0d 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -116,14 +116,6 @@ static uint32_t set_isolation_state(sPAPRDRConnector *= drc, return RTAS_OUT_SUCCESS; } =20 -static uint32_t set_indicator_state(sPAPRDRConnector *drc, - sPAPRDRIndicatorState state) -{ - trace_spapr_drc_set_indicator_state(spapr_drc_index(drc), state); - drc->indicator_state =3D state; - return RTAS_OUT_SUCCESS; -} - static uint32_t set_allocation_state(sPAPRDRConnector *drc, sPAPRDRAllocationState state) { @@ -321,7 +313,7 @@ static void attach(sPAPRDRConnector *drc, DeviceState *= d, void *fdt, if (spapr_drc_type(drc) =3D=3D SPAPR_DR_CONNECTOR_TYPE_PCI) { drc->isolation_state =3D SPAPR_DR_ISOLATION_STATE_UNISOLATED; } - drc->indicator_state =3D SPAPR_DR_INDICATOR_STATE_ACTIVE; + drc->dr_indicator =3D SPAPR_DR_INDICATOR_ACTIVE; =20 drc->dev =3D d; drc->fdt =3D fdt; @@ -394,7 +386,7 @@ static void detach(sPAPRDRConnector *drc, DeviceState *= d, Error **errp) } } =20 - drc->indicator_state =3D SPAPR_DR_INDICATOR_STATE_INACTIVE; + drc->dr_indicator =3D SPAPR_DR_INDICATOR_INACTIVE; =20 /* Calling release callbacks based on spapr_drc_type(drc). */ switch (spapr_drc_type(drc)) { @@ -507,7 +499,7 @@ static const VMStateDescription vmstate_spapr_drc =3D { .fields =3D (VMStateField []) { VMSTATE_UINT32(isolation_state, sPAPRDRConnector), VMSTATE_UINT32(allocation_state, sPAPRDRConnector), - VMSTATE_UINT32(indicator_state, sPAPRDRConnector), + VMSTATE_UINT32(dr_indicator, sPAPRDRConnector), VMSTATE_BOOL(configured, sPAPRDRConnector), VMSTATE_BOOL(awaiting_release, sPAPRDRConnector), VMSTATE_BOOL(awaiting_allocation, sPAPRDRConnector), @@ -647,7 +639,6 @@ static void spapr_dr_connector_class_init(ObjectClass *= k, void *data) dk->realize =3D realize; dk->unrealize =3D unrealize; drck->set_isolation_state =3D set_isolation_state; - drck->set_indicator_state =3D set_indicator_state; drck->set_allocation_state =3D set_allocation_state; drck->get_name =3D get_name; drck->attach =3D attach; @@ -929,17 +920,17 @@ static uint32_t rtas_set_allocation_state(uint32_t id= x, uint32_t state) return drck->set_allocation_state(drc, state); } =20 -static uint32_t rtas_set_indicator_state(uint32_t idx, uint32_t state) +static uint32_t rtas_set_dr_indicator(uint32_t idx, uint32_t state) { sPAPRDRConnector *drc =3D spapr_drc_by_index(idx); - sPAPRDRConnectorClass *drck; =20 if (!drc) { return RTAS_OUT_PARAM_ERROR; } =20 - drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); - return drck->set_indicator_state(drc, state); + trace_spapr_drc_set_dr_indicator(idx, state); + drc->dr_indicator =3D state; + return RTAS_OUT_SUCCESS; } =20 static void rtas_set_indicator(PowerPCCPU *cpu, sPAPRMachineState *spapr, @@ -964,7 +955,7 @@ static void rtas_set_indicator(PowerPCCPU *cpu, sPAPRMa= chineState *spapr, ret =3D rtas_set_isolation_state(idx, state); break; case RTAS_SENSOR_TYPE_DR: - ret =3D rtas_set_indicator_state(idx, state); + ret =3D rtas_set_dr_indicator(idx, state); break; case RTAS_SENSOR_TYPE_ALLOCATION_STATE: ret =3D rtas_set_allocation_state(idx, state); diff --git a/hw/ppc/trace-events b/hw/ppc/trace-events index 581fa85..3e8e3cf 100644 --- a/hw/ppc/trace-events +++ b/hw/ppc/trace-events @@ -39,7 +39,7 @@ spapr_iommu_ddw_reset(uint64_t buid, uint32_t cfgaddr) "b= uid=3D%"PRIx64" addr=3D%"PR spapr_drc_set_isolation_state(uint32_t index, int state) "drc: 0x%"PRIx32"= , state: %"PRIx32 spapr_drc_set_isolation_state_finalizing(uint32_t index) "drc: 0x%"PRIx32 spapr_drc_set_isolation_state_deferring(uint32_t index) "drc: 0x%"PRIx32 -spapr_drc_set_indicator_state(uint32_t index, int state) "drc: 0x%"PRIx32"= , state: 0x%x" +spapr_drc_set_dr_indicator(uint32_t index, int state) "drc: 0x%"PRIx32", s= tate: 0x%x" spapr_drc_set_allocation_state(uint32_t index, int state) "drc: 0x%"PRIx32= ", state: 0x%x" spapr_drc_set_allocation_state_finalizing(uint32_t index) "drc: 0x%"PRIx32 spapr_drc_set_configured(uint32_t index) "drc: 0x%"PRIx32 diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h index f892b94..70db573 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -125,7 +125,7 @@ typedef enum { } sPAPRDRAllocationState; =20 /* - * LED/visual indicator state + * DR-indicator (LED/visual indicator) * * set via set-indicator RTAS calls * as documented by PAPR+ 2.7 13.5.3.4, Table 177, @@ -137,10 +137,10 @@ typedef enum { * action: (currently unused) */ typedef enum { - SPAPR_DR_INDICATOR_STATE_INACTIVE =3D 0, - SPAPR_DR_INDICATOR_STATE_ACTIVE =3D 1, - SPAPR_DR_INDICATOR_STATE_IDENTIFY =3D 2, - SPAPR_DR_INDICATOR_STATE_ACTION =3D 3, + SPAPR_DR_INDICATOR_INACTIVE =3D 0, + SPAPR_DR_INDICATOR_ACTIVE =3D 1, + SPAPR_DR_INDICATOR_IDENTIFY =3D 2, + SPAPR_DR_INDICATOR_ACTION =3D 3, } sPAPRDRIndicatorState; =20 /* @@ -186,10 +186,12 @@ typedef struct sPAPRDRConnector { Object *owner; const char *name; =20 + /* DR-indicator */ + uint32_t dr_indicator; + /* sensor/indicator states */ uint32_t isolation_state; uint32_t allocation_state; - uint32_t indicator_state; =20 /* configure-connector state */ void *fdt; @@ -219,8 +221,6 @@ typedef struct sPAPRDRConnectorClass { /* accessors for guest-visible (generally via RTAS) DR state */ uint32_t (*set_isolation_state)(sPAPRDRConnector *drc, sPAPRDRIsolationState state); - uint32_t (*set_indicator_state)(sPAPRDRConnector *drc, - sPAPRDRIndicatorState state); uint32_t (*set_allocation_state)(sPAPRDRConnector *drc, sPAPRDRAllocationState state); const char *(*get_name)(sPAPRDRConnector *drc); --=20 2.9.4 From nobody Mon Feb 9 13:49:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496986455349843.8935169696587; Thu, 8 Jun 2017 22:34:15 -0700 (PDT) Received: from localhost ([::1]:52690 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCYn-0002WU-Q6 for importer@patchew.org; Fri, 09 Jun 2017 01:34:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47060) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCRy-0003xo-IU for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJCRw-0006dn-20 for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:10 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:52107) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJCRv-0006cE-9S; Fri, 09 Jun 2017 01:27:07 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wkW4c4Fw1z9sNG; Fri, 9 Jun 2017 15:26:55 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1496986016; bh=REeuJ+iQgYyxqhY9PVFVtzb/IWEPfPfLk0Fw61ZK8bE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R/RIpMfc1iIAbyzrv4fgmjxfL4hw8ZDe3PWSFu8O0zgEKAzttOBqFheumfunMyTzv KjhAkVqtmQHbUKZm0O0KMMbmsYSs+QnnqZi4LJpJ2G16LGF3kl+A/YfKyMYx+GxHOA x8eglNJBh4TyA4cIDnNoU0xExsHxMpMrfF7Vp4Gw= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 9 Jun 2017 15:26:41 +1000 Message-Id: <20170609052652.23200-10-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170609052652.23200-1-david@gibson.dropbear.id.au> References: <20170609052652.23200-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 09/20] spapr: Change DRC attach & detach methods to functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, sursingh@redhat.com, mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-ppc@nongnu.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) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" DRC objects have attach & detach methods, but there's only one implementation. Although there are some differences in its behaviour for different DRC types, the overall structure is the same, so while we might want different method implementations for some parts, we're unlikely to want them for the top-level functions. So, replace them with direct function calls. Signed-off-by: David Gibson Reviewed-by: Michael Roth Acked-by: Michael Roth --- hw/ppc/spapr.c | 19 ++++++------------- hw/ppc/spapr_drc.c | 18 ++++++------------ hw/ppc/spapr_pci.c | 9 +++------ include/hw/ppc/spapr_drc.h | 7 ++++--- 4 files changed, 19 insertions(+), 34 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index b2311dc..e340ff3 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2523,7 +2523,6 @@ static void spapr_add_lmbs(DeviceState *dev, uint64_t= addr_start, uint64_t size, Error **errp) { sPAPRDRConnector *drc; - sPAPRDRConnectorClass *drck; uint32_t nr_lmbs =3D size/SPAPR_MEMORY_BLOCK_SIZE; int i, fdt_offset, fdt_size; void *fdt; @@ -2538,10 +2537,10 @@ static void spapr_add_lmbs(DeviceState *dev, uint64= _t addr_start, uint64_t size, fdt_offset =3D spapr_populate_memory_node(fdt, node, addr, SPAPR_MEMORY_BLOCK_SIZE); =20 - drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); - drck->attach(drc, dev, fdt, fdt_offset, !dev->hotplugged, errp); + spapr_drc_attach(drc, dev, fdt, fdt_offset, !dev->hotplugged, errp= ); addr +=3D SPAPR_MEMORY_BLOCK_SIZE; if (!dev->hotplugged) { + sPAPRDRConnectorClass *drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(d= rc); /* guests expect coldplugged LMBs to be pre-allocated */ drck->set_allocation_state(drc, SPAPR_DR_ALLOCATION_STATE_USAB= LE); drck->set_isolation_state(drc, SPAPR_DR_ISOLATION_STATE_UNISOL= ATED); @@ -2554,7 +2553,6 @@ static void spapr_add_lmbs(DeviceState *dev, uint64_t= addr_start, uint64_t size, if (dedicated_hp_event_source) { drc =3D spapr_drc_by_id(TYPE_SPAPR_DRC_LMB, addr_start / SPAPR_MEMORY_BLOCK_SIZE); - drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); spapr_hotplug_req_add_by_count_indexed(SPAPR_DR_CONNECTOR_TYPE= _LMB, nr_lmbs, spapr_drc_index(drc)); @@ -2742,7 +2740,6 @@ static void spapr_memory_unplug_request(HotplugHandle= r *hotplug_dev, uint64_t addr_start, addr; int i; sPAPRDRConnector *drc; - sPAPRDRConnectorClass *drck; sPAPRDIMMState *ds; =20 addr_start =3D object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP, @@ -2762,14 +2759,12 @@ static void spapr_memory_unplug_request(HotplugHand= ler *hotplug_dev, addr / SPAPR_MEMORY_BLOCK_SIZE); g_assert(drc); =20 - drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); - drck->detach(drc, dev, errp); + spapr_drc_detach(drc, dev, errp); addr +=3D SPAPR_MEMORY_BLOCK_SIZE; } =20 drc =3D spapr_drc_by_id(TYPE_SPAPR_DRC_LMB, addr_start / SPAPR_MEMORY_BLOCK_SIZE); - drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); spapr_hotplug_req_remove_by_count_indexed(SPAPR_DR_CONNECTOR_TYPE_LMB, nr_lmbs, spapr_drc_index(drc= )); out: @@ -2824,7 +2819,6 @@ void spapr_core_unplug_request(HotplugHandler *hotplu= g_dev, DeviceState *dev, { int index; sPAPRDRConnector *drc; - sPAPRDRConnectorClass *drck; Error *local_err =3D NULL; CPUCore *cc =3D CPU_CORE(dev); int smt =3D kvmppc_smt_threads(); @@ -2842,8 +2836,7 @@ void spapr_core_unplug_request(HotplugHandler *hotplu= g_dev, DeviceState *dev, drc =3D spapr_drc_by_id(TYPE_SPAPR_DRC_CPU, index * smt); g_assert(drc); =20 - drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); - drck->detach(drc, dev, &local_err); + spapr_drc_detach(drc, dev, &local_err); if (local_err) { error_propagate(errp, local_err); return; @@ -2887,8 +2880,8 @@ static void spapr_core_plug(HotplugHandler *hotplug_d= ev, DeviceState *dev, } =20 if (drc) { - sPAPRDRConnectorClass *drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); - drck->attach(drc, dev, fdt, fdt_offset, !dev->hotplugged, &local_e= rr); + spapr_drc_attach(drc, dev, fdt, fdt_offset, !dev->hotplugged, + &local_err); if (local_err) { g_free(fdt); error_propagate(errp, local_err); diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 19e2c0d..82c0b94 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -49,8 +49,6 @@ uint32_t spapr_drc_index(sPAPRDRConnector *drc) static uint32_t set_isolation_state(sPAPRDRConnector *drc, sPAPRDRIsolationState state) { - sPAPRDRConnectorClass *drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); - trace_spapr_drc_set_isolation_state(spapr_drc_index(drc), state); =20 /* if the guest is configuring a device attached to this DRC, we @@ -105,7 +103,7 @@ static uint32_t set_isolation_state(sPAPRDRConnector *d= rc, uint32_t drc_index =3D spapr_drc_index(drc); if (drc->configured) { trace_spapr_drc_set_isolation_state_finalizing(drc_index); - drck->detach(drc, DEVICE(drc->dev), NULL); + spapr_drc_detach(drc, DEVICE(drc->dev), NULL); } else { trace_spapr_drc_set_isolation_state_deferring(drc_index); } @@ -119,8 +117,6 @@ static uint32_t set_isolation_state(sPAPRDRConnector *d= rc, static uint32_t set_allocation_state(sPAPRDRConnector *drc, sPAPRDRAllocationState state) { - sPAPRDRConnectorClass *drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); - trace_spapr_drc_set_allocation_state(spapr_drc_index(drc), state); =20 if (state =3D=3D SPAPR_DR_ALLOCATION_STATE_USABLE) { @@ -151,7 +147,7 @@ static uint32_t set_allocation_state(sPAPRDRConnector *= drc, drc->allocation_state =3D=3D SPAPR_DR_ALLOCATION_STATE_UNUSABL= E) { uint32_t drc_index =3D spapr_drc_index(drc); trace_spapr_drc_set_allocation_state_finalizing(drc_index); - drck->detach(drc, DEVICE(drc->dev), NULL); + spapr_drc_detach(drc, DEVICE(drc->dev), NULL); } else if (drc->allocation_state =3D=3D SPAPR_DR_ALLOCATION_STATE_= USABLE) { drc->awaiting_allocation =3D false; } @@ -289,8 +285,8 @@ static void prop_get_fdt(Object *obj, Visitor *v, const= char *name, } while (fdt_depth !=3D 0); } =20 -static void attach(sPAPRDRConnector *drc, DeviceState *d, void *fdt, - int fdt_start_offset, bool coldplug, Error **errp) +void spapr_drc_attach(sPAPRDRConnector *drc, DeviceState *d, void *fdt, + int fdt_start_offset, bool coldplug, Error **errp) { trace_spapr_drc_attach(spapr_drc_index(drc)); =20 @@ -341,7 +337,7 @@ static void attach(sPAPRDRConnector *drc, DeviceState *= d, void *fdt, NULL, 0, NULL); } =20 -static void detach(sPAPRDRConnector *drc, DeviceState *d, Error **errp) +void spapr_drc_detach(sPAPRDRConnector *drc, DeviceState *d, Error **errp) { trace_spapr_drc_detach(spapr_drc_index(drc)); =20 @@ -444,7 +440,7 @@ static void reset(DeviceState *d) * force removal if we are */ if (drc->awaiting_release) { - drck->detach(drc, DEVICE(drc->dev), NULL); + spapr_drc_detach(drc, DEVICE(drc->dev), NULL); } =20 /* non-PCI devices may be awaiting a transition to UNUSABLE */ @@ -641,8 +637,6 @@ static void spapr_dr_connector_class_init(ObjectClass *= k, void *data) drck->set_isolation_state =3D set_isolation_state; drck->set_allocation_state =3D set_allocation_state; drck->get_name =3D get_name; - drck->attach =3D attach; - drck->detach =3D detach; drck->release_pending =3D release_pending; drck->set_signalled =3D set_signalled; /* diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 5cba8f9..56cb4b8 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1349,7 +1349,6 @@ static void spapr_phb_add_pci_device(sPAPRDRConnector= *drc, PCIDevice *pdev, Error **errp) { - sPAPRDRConnectorClass *drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); DeviceState *dev =3D DEVICE(pdev); void *fdt =3D NULL; int fdt_start_offset =3D 0, fdt_size; @@ -1361,8 +1360,8 @@ static void spapr_phb_add_pci_device(sPAPRDRConnector= *drc, goto out; } =20 - drck->attach(drc, DEVICE(pdev), - fdt, fdt_start_offset, !dev->hotplugged, errp); + spapr_drc_attach(drc, DEVICE(pdev), + fdt, fdt_start_offset, !dev->hotplugged, errp); out: if (*errp) { g_free(fdt); @@ -1391,9 +1390,7 @@ static void spapr_phb_remove_pci_device(sPAPRDRConnec= tor *drc, PCIDevice *pdev, Error **errp) { - sPAPRDRConnectorClass *drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); - - drck->detach(drc, DEVICE(pdev), errp); + spapr_drc_detach(drc, DEVICE(pdev), errp); } =20 static sPAPRDRConnector *spapr_phb_get_pci_func_drc(sPAPRPHBState *phb, diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h index 70db573..4f82001 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -226,9 +226,6 @@ typedef struct sPAPRDRConnectorClass { const char *(*get_name)(sPAPRDRConnector *drc); =20 /* QEMU interfaces for managing hotplug operations */ - void (*attach)(sPAPRDRConnector *drc, DeviceState *d, void *fdt, - int fdt_start_offset, bool coldplug, Error **errp); - void (*detach)(sPAPRDRConnector *drc, DeviceState *d, Error **errp); bool (*release_pending)(sPAPRDRConnector *drc); void (*set_signalled)(sPAPRDRConnector *drc); } sPAPRDRConnectorClass; @@ -243,4 +240,8 @@ sPAPRDRConnector *spapr_drc_by_id(const char *type, uin= t32_t id); int spapr_drc_populate_dt(void *fdt, int fdt_offset, Object *owner, uint32_t drc_type_mask); =20 +void spapr_drc_attach(sPAPRDRConnector *drc, DeviceState *d, void *fdt, + int fdt_start_offset, bool coldplug, Error **errp); +void spapr_drc_detach(sPAPRDRConnector *drc, DeviceState *d, Error **errp); + #endif /* HW_SPAPR_DRC_H */ --=20 2.9.4 From nobody Mon Feb 9 13:49:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149698630826720.045430238766585; Thu, 8 Jun 2017 22:31:48 -0700 (PDT) Received: from localhost ([::1]:52683 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCWQ-0008KH-HF for importer@patchew.org; Fri, 09 Jun 2017 01:31:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46986) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCRw-0003vZ-JI for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJCRv-0006co-2s for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:08 -0400 Received: from ozlabs.org ([103.22.144.67]:60111) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJCRu-0006c7-NR; Fri, 09 Jun 2017 01:27:07 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wkW4c1yXbz9sND; Fri, 9 Jun 2017 15:26:56 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1496986016; bh=Qs+nVXSTBg66YxlWT3Q5+94GEeX+pKzfZkTjsAuK+0U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=btb5N7oHHXyEc/fBHk8nqr9ImrGABwZhJA9h8WWExrkW51+pzpFvy61S8ifJEz+KT 1Uyjhp9WJcYfDZZBw+amsX2QKwTmhYBSW4NnlJeLLtOPzhgSwBLLzQLA/bC5K0DzEL ZRHlMo6cPPgW/fOM+88Ip2a6CJm/fhYfD3A45Wio= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 9 Jun 2017 15:26:42 +1000 Message-Id: <20170609052652.23200-11-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170609052652.23200-1-david@gibson.dropbear.id.au> References: <20170609052652.23200-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 10/20] spapr: Fold spapr_phb_{add, remove}_pci_device() into their only callers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, sursingh@redhat.com, mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-ppc@nongnu.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) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Both functions are fairly short, and so are their callers. There's no particular logical distinction between them, so fold them together. Signed-off-by: David Gibson Reviewed-by: Michael Roth Acked-by: Michael Roth --- hw/ppc/spapr_pci.c | 63 ++++++++++++++++++++------------------------------= ---- 1 file changed, 23 insertions(+), 40 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 56cb4b8..0b447f2 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1344,30 +1344,6 @@ static int spapr_create_pci_child_dt(sPAPRPHBState *= phb, PCIDevice *dev, return offset; } =20 -static void spapr_phb_add_pci_device(sPAPRDRConnector *drc, - sPAPRPHBState *phb, - PCIDevice *pdev, - Error **errp) -{ - DeviceState *dev =3D DEVICE(pdev); - void *fdt =3D NULL; - int fdt_start_offset =3D 0, fdt_size; - - fdt =3D create_device_tree(&fdt_size); - fdt_start_offset =3D spapr_create_pci_child_dt(phb, pdev, fdt, 0); - if (!fdt_start_offset) { - error_setg(errp, "Failed to create pci child device tree node"); - goto out; - } - - spapr_drc_attach(drc, DEVICE(pdev), - fdt, fdt_start_offset, !dev->hotplugged, errp); -out: - if (*errp) { - g_free(fdt); - } -} - /* Callback to be called during DRC release. */ void spapr_phb_remove_pci_device_cb(DeviceState *dev) { @@ -1385,14 +1361,6 @@ void spapr_phb_remove_pci_device_cb(DeviceState *dev) object_unparent(OBJECT(dev)); } =20 -static void spapr_phb_remove_pci_device(sPAPRDRConnector *drc, - sPAPRPHBState *phb, - PCIDevice *pdev, - Error **errp) -{ - spapr_drc_detach(drc, DEVICE(pdev), errp); -} - static sPAPRDRConnector *spapr_phb_get_pci_func_drc(sPAPRPHBState *phb, uint32_t busnr, int32_t devfn) @@ -1429,6 +1397,8 @@ static void spapr_phb_hot_plug_child(HotplugHandler *= plug_handler, Error *local_err =3D NULL; PCIBus *bus =3D PCI_BUS(qdev_get_parent_bus(DEVICE(pdev))); uint32_t slotnr =3D PCI_SLOT(pdev->devfn); + void *fdt =3D NULL; + int fdt_start_offset, fdt_size; =20 /* if DR is disabled we don't need to do anything in the case of * hotplug or coldplug callbacks @@ -1438,10 +1408,10 @@ static void spapr_phb_hot_plug_child(HotplugHandler= *plug_handler, * we need to let them know it's not enabled */ if (plugged_dev->hotplugged) { - error_setg(errp, QERR_BUS_NO_HOTPLUG, + error_setg(&local_err, QERR_BUS_NO_HOTPLUG, object_get_typename(OBJECT(phb))); } - return; + goto out; } =20 g_assert(drc); @@ -1452,16 +1422,23 @@ static void spapr_phb_hot_plug_child(HotplugHandler= *plug_handler, */ if (plugged_dev->hotplugged && bus->devices[PCI_DEVFN(slotnr, 0)] && PCI_FUNC(pdev->devfn) !=3D 0) { - error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s," + error_setg(&local_err, "PCI: slot %d function 0 already ocuppied b= y %s," " additional functions can no longer be exposed to gues= t.", slotnr, bus->devices[PCI_DEVFN(slotnr, 0)]->name); - return; + goto out; + } + + fdt =3D create_device_tree(&fdt_size); + fdt_start_offset =3D spapr_create_pci_child_dt(phb, pdev, fdt, 0); + if (!fdt_start_offset) { + error_setg(&local_err, "Failed to create pci child device tree nod= e"); + goto out; } =20 - spapr_phb_add_pci_device(drc, phb, pdev, &local_err); + spapr_drc_attach(drc, DEVICE(pdev), fdt, fdt_start_offset, + !plugged_dev->hotplugged, &local_err); if (local_err) { - error_propagate(errp, local_err); - return; + goto out; } =20 /* If this is function 0, signal hotplug for all the device functions. @@ -1485,6 +1462,12 @@ static void spapr_phb_hot_plug_child(HotplugHandler = *plug_handler, } } } + +out: + if (local_err) { + error_propagate(errp, local_err); + g_free(fdt); + } } =20 static void spapr_phb_hot_unplug_child(HotplugHandler *plug_handler, @@ -1531,7 +1514,7 @@ static void spapr_phb_hot_unplug_child(HotplugHandler= *plug_handler, } } =20 - spapr_phb_remove_pci_device(drc, phb, pdev, &local_err); + spapr_drc_detach(drc, DEVICE(pdev), &local_err); if (local_err) { error_propagate(errp, local_err); return; --=20 2.9.4 From nobody Mon Feb 9 13:49:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496987118428812.7431344597862; Thu, 8 Jun 2017 22:45:18 -0700 (PDT) Received: from localhost ([::1]:52760 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCjU-0004xz-Np for importer@patchew.org; Fri, 09 Jun 2017 01:45:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCS1-000449-Uv for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJCRz-0006gf-1x for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:13 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:40231) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJCRy-0006eB-Ae; Fri, 09 Jun 2017 01:27:10 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wkW4d3RbTz9sNs; Fri, 9 Jun 2017 15:26:56 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1496986017; bh=49+uYS2x1yXZgFGUv3pgEIesvtvO3AoPzZSLn6YGLJI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ep2YHrZ6OXXJFm565GcRn3l/1IINFjMfKjGMGiRXNzPHJCbxIjoajfXArUoBgV4gA 1YEw0j7npv6Msp+AWUBgnywF7i2lPQ5uQqXWPuYwC1GuLGvUY+4iohnjdEx9HUFuEJ D8U6cGACNANVEXpjHFJ3gfrF3hsR+HEdcxc1MNms= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 9 Jun 2017 15:26:43 +1000 Message-Id: <20170609052652.23200-12-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170609052652.23200-1-david@gibson.dropbear.id.au> References: <20170609052652.23200-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 11/20] spapr: Rework DRC name handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, sursingh@redhat.com, mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-ppc@nongnu.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) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" DRC objects have a get_name method which returns the DRC name generated when the DRC is created. Replace that with a fixed spapr_drc_name() function which generates the name on the fly from other information. This means: * We get rid of a method with only one implementation, and only local callers * We don't have to carry the name string around for the lifetime of the DRC * We use information added to the class structure to generate the name in standard format, so we don't need an explicit switch on drc type any more We also eliminate the 'name' property; it's basically useless since the only information in it can easily be deduced from other things. Signed-off-by: David Gibson Reviewed-by: Michael Roth Acked-by: Michael Roth --- hw/ppc/spapr_drc.c | 80 +++++++++++++++++-------------------------= ---- include/hw/ppc/spapr_drc.h | 3 +- 2 files changed, 30 insertions(+), 53 deletions(-) diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 82c0b94..15ef67d 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -155,9 +155,32 @@ static uint32_t set_allocation_state(sPAPRDRConnector = *drc, return RTAS_OUT_SUCCESS; } =20 -static const char *get_name(sPAPRDRConnector *drc) +static const char *spapr_drc_name(sPAPRDRConnector *drc) { - return drc->name; + sPAPRDRConnectorClass *drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); + + /* human-readable name for a DRC to encode into the DT + * description. this is mainly only used within a guest in place + * of the unique DRC index. + * + * in the case of VIO/PCI devices, it corresponds to a "location + * code" that maps a logical device/function (DRC index) to a + * physical (or virtual in the case of VIO) location in the system + * by chaining together the "location label" for each + * encapsulating component. + * + * since this is more to do with diagnosing physical hardware + * issues than guest compatibility, we choose location codes/DRC + * names that adhere to the documented format, but avoid encoding + * the entire topology information into the label/code, instead + * just using the location codes based on the labels for the + * endpoints (VIO/PCI adaptor connectors), which is basically just + * "C" followed by an integer ID. + * + * DRC names as documented by PAPR+ v2.7, 13.5.2.4 + * location codes as documented by PAPR+ v2.7, 12.3.1.5 + */ + return g_strdup_printf("%s%d", drck->drc_name_prefix, drc->id); } =20 /* has the guest been notified of device attachment? */ @@ -202,13 +225,6 @@ static void prop_get_index(Object *obj, Visitor *v, co= nst char *name, visit_type_uint32(v, name, &value, errp); } =20 -static char *prop_get_name(Object *obj, Error **errp) -{ - sPAPRDRConnector *drc =3D SPAPR_DR_CONNECTOR(obj); - sPAPRDRConnectorClass *drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); - return g_strdup(drck->get_name(drc)); -} - static void prop_get_fdt(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { @@ -567,45 +583,6 @@ sPAPRDRConnector *spapr_dr_connector_new(Object *owner= , const char *type, object_property_set_bool(OBJECT(drc), true, "realized", NULL); g_free(prop_name); =20 - /* human-readable name for a DRC to encode into the DT - * description. this is mainly only used within a guest in place - * of the unique DRC index. - * - * in the case of VIO/PCI devices, it corresponds to a - * "location code" that maps a logical device/function (DRC index) - * to a physical (or virtual in the case of VIO) location in the - * system by chaining together the "location label" for each - * encapsulating component. - * - * since this is more to do with diagnosing physical hardware - * issues than guest compatibility, we choose location codes/DRC - * names that adhere to the documented format, but avoid encoding - * the entire topology information into the label/code, instead - * just using the location codes based on the labels for the - * endpoints (VIO/PCI adaptor connectors), which is basically - * just "C" followed by an integer ID. - * - * DRC names as documented by PAPR+ v2.7, 13.5.2.4 - * location codes as documented by PAPR+ v2.7, 12.3.1.5 - */ - switch (spapr_drc_type(drc)) { - case SPAPR_DR_CONNECTOR_TYPE_CPU: - drc->name =3D g_strdup_printf("CPU %d", id); - break; - case SPAPR_DR_CONNECTOR_TYPE_PHB: - drc->name =3D g_strdup_printf("PHB %d", id); - break; - case SPAPR_DR_CONNECTOR_TYPE_VIO: - case SPAPR_DR_CONNECTOR_TYPE_PCI: - drc->name =3D g_strdup_printf("C%d", id); - break; - case SPAPR_DR_CONNECTOR_TYPE_LMB: - drc->name =3D g_strdup_printf("LMB %d", id); - break; - default: - g_assert(false); - } - /* PCI slot always start in a USABLE state, and stay there */ if (spapr_drc_type(drc) =3D=3D SPAPR_DR_CONNECTOR_TYPE_PCI) { drc->allocation_state =3D SPAPR_DR_ALLOCATION_STATE_USABLE; @@ -621,7 +598,6 @@ static void spapr_dr_connector_instance_init(Object *ob= j) object_property_add_uint32_ptr(obj, "id", &drc->id, NULL); object_property_add(obj, "index", "uint32", prop_get_index, NULL, NULL, NULL, NULL); - object_property_add_str(obj, "name", prop_get_name, NULL, NULL); object_property_add(obj, "fdt", "struct", prop_get_fdt, NULL, NULL, NULL, NULL); } @@ -636,7 +612,6 @@ static void spapr_dr_connector_class_init(ObjectClass *= k, void *data) dk->unrealize =3D unrealize; drck->set_isolation_state =3D set_isolation_state; drck->set_allocation_state =3D set_allocation_state; - drck->get_name =3D get_name; drck->release_pending =3D release_pending; drck->set_signalled =3D set_signalled; /* @@ -665,6 +640,7 @@ static void spapr_drc_cpu_class_init(ObjectClass *k, vo= id *data) =20 drck->typeshift =3D SPAPR_DR_CONNECTOR_TYPE_SHIFT_CPU; drck->typename =3D "CPU"; + drck->drc_name_prefix =3D "CPU "; } =20 static void spapr_drc_pci_class_init(ObjectClass *k, void *data) @@ -673,6 +649,7 @@ static void spapr_drc_pci_class_init(ObjectClass *k, vo= id *data) =20 drck->typeshift =3D SPAPR_DR_CONNECTOR_TYPE_SHIFT_PCI; drck->typename =3D "28"; + drck->drc_name_prefix =3D "C"; } =20 static void spapr_drc_lmb_class_init(ObjectClass *k, void *data) @@ -681,6 +658,7 @@ static void spapr_drc_lmb_class_init(ObjectClass *k, vo= id *data) =20 drck->typeshift =3D SPAPR_DR_CONNECTOR_TYPE_SHIFT_LMB; drck->typename =3D "MEM"; + drck->drc_name_prefix =3D "LMB "; } =20 static const TypeInfo spapr_dr_connector_info =3D { @@ -829,7 +807,7 @@ int spapr_drc_populate_dt(void *fdt, int fdt_offset, Ob= ject *owner, g_array_append_val(drc_power_domains, drc_power_domain); =20 /* ibm,drc-names */ - drc_names =3D g_string_append(drc_names, drck->get_name(drc)); + drc_names =3D g_string_append(drc_names, spapr_drc_name(drc)); drc_names =3D g_string_insert_len(drc_names, -1, "\0", 1); =20 /* ibm,drc-types */ diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h index 4f82001..c487123 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -184,7 +184,6 @@ typedef struct sPAPRDRConnector { =20 uint32_t id; Object *owner; - const char *name; =20 /* DR-indicator */ uint32_t dr_indicator; @@ -215,6 +214,7 @@ typedef struct sPAPRDRConnectorClass { /*< public >*/ sPAPRDRConnectorTypeShift typeshift; const char *typename; /* used in device tree, PAPR 13.5.2.6 & C.6.1 */ + const char *drc_name_prefix; /* used other places in device tree */ =20 sPAPRDREntitySense (*dr_entity_sense)(sPAPRDRConnector *drc); =20 @@ -223,7 +223,6 @@ typedef struct sPAPRDRConnectorClass { sPAPRDRIsolationState state); uint32_t (*set_allocation_state)(sPAPRDRConnector *drc, sPAPRDRAllocationState state); - const char *(*get_name)(sPAPRDRConnector *drc); =20 /* QEMU interfaces for managing hotplug operations */ bool (*release_pending)(sPAPRDRConnector *drc); --=20 2.9.4 From nobody Mon Feb 9 13:49:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496986158269972.7853142518825; Thu, 8 Jun 2017 22:29:18 -0700 (PDT) Received: from localhost ([::1]:52669 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCU0-0006Cq-Tz for importer@patchew.org; Fri, 09 Jun 2017 01:29:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCRw-0003vX-IG for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJCRv-0006dG-EQ for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:08 -0400 Received: from ozlabs.org ([103.22.144.67]:33837) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJCRv-0006cT-2h; Fri, 09 Jun 2017 01:27:07 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wkW4c5rtFz9sNq; Fri, 9 Jun 2017 15:26:56 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1496986016; bh=M0ma7gogVY6WU+6PhZKi2JDhynALLFC9g7tRy8d0xmM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jRrkcQJ4wZwPmD0nYsFwqR/FDfHM9SQaQgvN9EAu3+tCRoFw6SF379rroEz9l6C8g ogKchdjdFPmrSAkadBJQbzUNMcarz6Bo0wxLxwJaqOwXYvAi7BvrsawyLDBY+tymht R6PzgTeYXhdl/04wYvmv0km/gBWX4aCc0PDR4pbc= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 9 Jun 2017 15:26:44 +1000 Message-Id: <20170609052652.23200-13-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170609052652.23200-1-david@gibson.dropbear.id.au> References: <20170609052652.23200-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 12/20] pnv_core: drop reference on ICPState object during CPU realization X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: agraf@suse.de, qemu-devel@nongnu.org, sursingh@redhat.com, mdroth@linux.vnet.ibm.com, Greg Kurz , qemu-ppc@nongnu.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) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz Similarly to what was done to spapr with commit 249127d0dfeb, this patch ensures that we don't keep an extra reference on the ICPState object. Also since the object was just created and not reparented yet, the call to object_property_add_child() should never fail: let's pass &error_abort to make this clear. Signed-off-by: Greg Kurz Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: David Gibson --- hw/ppc/pnv_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index 1b7ec70..e8a9a94 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -119,7 +119,8 @@ static void pnv_core_realize_child(Object *child, XICSF= abric *xi, Error **errp) Object *obj; =20 obj =3D object_new(TYPE_PNV_ICP); - object_property_add_child(OBJECT(cpu), "icp", obj, NULL); + object_property_add_child(OBJECT(cpu), "icp", obj, &error_abort); + object_unref(obj); object_property_add_const_link(obj, "xics", OBJECT(xi), &error_abort); object_property_set_bool(obj, true, "realized", &local_err); if (local_err) { --=20 2.9.4 From nobody Mon Feb 9 13:49:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496986773809212.1257658556999; Thu, 8 Jun 2017 22:39:33 -0700 (PDT) Received: from localhost ([::1]:52733 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCdu-0007jf-Ew for importer@patchew.org; Fri, 09 Jun 2017 01:39:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCRz-0003zC-Ta for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJCRy-0006fX-AH for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:11 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:54293) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJCRx-0006dX-R5; Fri, 09 Jun 2017 01:27:10 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wkW4c6b73z9sNg; Fri, 9 Jun 2017 15:26:56 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1496986016; bh=ZotHL55TQ5gHJZwiCY7F/WzQArbl1ODOuRebzSHBz0o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fSYn3W5oQvIIkYW7eCnKfQ64MPhYloRodRSYUQL43V3d8ChJZ3wDtETYB1YTsRBBx 9WqgY3tylvagsMH8R5yQw2DC1VKWo79fRISWNdubLjZTa6DOvguL7GlDzKmfAr1ZQu 8PEIyHiV8Le3UILDbUin5w/ZVUDiC3jh73rXK3lE= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 9 Jun 2017 15:26:45 +1000 Message-Id: <20170609052652.23200-14-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170609052652.23200-1-david@gibson.dropbear.id.au> References: <20170609052652.23200-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 Subject: [Qemu-devel] [PULL 13/20] xics: add reset() handler to ICPStateClass X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: agraf@suse.de, qemu-devel@nongnu.org, sursingh@redhat.com, mdroth@linux.vnet.ibm.com, Greg Kurz , qemu-ppc@nongnu.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) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz Taking into account that qemu_set_irq() returns immediatly if its first argument is NULL, icp_kvm_reset() largely duplicates icp_reset(). This patch introduces a reset() handler, so that the common logic can be implemented in icp_reset() only. While there we can also drop icp_kvm_realize() and icp_kvm_unrealize(). This causes icp-kvm to be realized in icp_realize(), which sets icp->xics, but it has no impact. Signed-off-by: Greg Kurz Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: David Gibson --- hw/intc/xics.c | 5 +++++ hw/intc/xics_kvm.c | 27 ++------------------------- include/hw/ppc/xics.h | 1 + 3 files changed, 8 insertions(+), 25 deletions(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index ea35167..ec73f02 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -325,6 +325,7 @@ static const VMStateDescription vmstate_icp_server =3D { static void icp_reset(void *dev) { ICPState *icp =3D ICP(dev); + ICPStateClass *icpc =3D ICP_GET_CLASS(icp); =20 icp->xirr =3D 0; icp->pending_priority =3D 0xff; @@ -332,6 +333,10 @@ static void icp_reset(void *dev) =20 /* Make all outputs are deasserted */ qemu_set_irq(icp->output, 0); + + if (icpc->reset) { + icpc->reset(icp); + } } =20 static void icp_realize(DeviceState *dev, Error **errp) diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c index 14b8f6f..45bf110 100644 --- a/hw/intc/xics_kvm.c +++ b/hw/intc/xics_kvm.c @@ -110,19 +110,8 @@ static int icp_set_kvm_state(ICPState *icp, int versio= n_id) return 0; } =20 -static void icp_kvm_reset(void *dev) +static void icp_kvm_reset(ICPState *icp) { - ICPState *icp =3D ICP(dev); - - icp->xirr =3D 0; - icp->pending_priority =3D 0xff; - icp->mfrr =3D 0xff; - - /* Make all outputs as deasserted only if the CPU thread is in use */ - if (icp->output) { - qemu_set_irq(icp->output, 0); - } - icp_set_kvm_state(icp, 1); } =20 @@ -159,26 +148,14 @@ static void icp_kvm_cpu_setup(ICPState *icp, PowerPCC= PU *cpu) QLIST_INSERT_HEAD(&kvm_enabled_icps, enabled_icp, node); } =20 -static void icp_kvm_realize(DeviceState *dev, Error **errp) -{ - qemu_register_reset(icp_kvm_reset, dev); -} - -static void icp_kvm_unrealize(DeviceState *dev, Error **errp) -{ - qemu_unregister_reset(icp_kvm_reset, dev); -} - static void icp_kvm_class_init(ObjectClass *klass, void *data) { - DeviceClass *dc =3D DEVICE_CLASS(klass); ICPStateClass *icpc =3D ICP_CLASS(klass); =20 - dc->realize =3D icp_kvm_realize; - dc->unrealize =3D icp_kvm_unrealize; icpc->pre_save =3D icp_get_kvm_state; icpc->post_load =3D icp_set_kvm_state; icpc->cpu_setup =3D icp_kvm_cpu_setup; + icpc->reset =3D icp_kvm_reset; } =20 static const TypeInfo icp_kvm_info =3D { diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index a3073f9..40a506e 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -69,6 +69,7 @@ struct ICPStateClass { void (*pre_save)(ICPState *s); int (*post_load)(ICPState *s, int version_id); void (*cpu_setup)(ICPState *icp, PowerPCCPU *cpu); + void (*reset)(ICPState *icp); }; =20 struct ICPState { --=20 2.9.4 From nobody Mon Feb 9 13:49:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496986917070504.7767755186626; Thu, 8 Jun 2017 22:41:57 -0700 (PDT) Received: from localhost ([::1]:52746 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCgF-0001Qb-6c for importer@patchew.org; Fri, 09 Jun 2017 01:41:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47138) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCS0-0003zy-Dj for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJCRy-0006gW-Sx for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:12 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:35677) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJCRy-0006eF-Cl; Fri, 09 Jun 2017 01:27:10 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wkW4d4GPdz9sNb; Fri, 9 Jun 2017 15:26:56 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1496986017; bh=BMxyRMhJcY8i1PvxCx+wqv17vMjz3x0FVI3GNDgmqns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ms5DA/zK91wkNfn6Qd11CSw05nP4wbUvrO5AjfeANynCPqq8hyGBtn4k1DiE46PLx EMVrKIrHLht9BEvYlIXrV78qUx5z7imPI3N8JwgeQIcHPUQhcmXipxpEPABZBGhL/Y eTSZOscwpRmUSXsiLURYOsz6rFppfiMRyGSgBN/U= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 9 Jun 2017 15:26:46 +1000 Message-Id: <20170609052652.23200-15-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170609052652.23200-1-david@gibson.dropbear.id.au> References: <20170609052652.23200-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 14/20] hw/ppc/spapr: Adjust firmware name for PCI bridges X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , qemu-devel@nongnu.org, sursingh@redhat.com, mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-ppc@nongnu.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) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth SLOF uses "pci" as name for PCI bridges nodes in the device tree instead of "pci-bridges", so booting via bootindex from a device behind a PCI bridge currently does not work since QEMU passes the wrong name in the "qemu,boot-list" property. Fix it by changing the name of the PCI bridge nodes to "pci" instead. Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=3D1459170 Signed-off-by: Thomas Huth Signed-off-by: David Gibson --- hw/ppc/spapr.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index e340ff3..01dda9e 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2441,6 +2441,12 @@ static char *spapr_get_fw_dev_path(FWPathProvider *p= , BusState *bus, return g_strdup_printf("disk@%"PRIX64, (uint64_t)id << 32); } =20 + if (g_str_equal("pci-bridge", qdev_fw_name(dev))) { + /* SLOF uses "pci" instead of "pci-bridge" for PCI bridges */ + PCIDevice *pcidev =3D CAST(PCIDevice, dev, TYPE_PCI_DEVICE); + return g_strdup_printf("pci@%x", PCI_SLOT(pcidev->devfn)); + } + return NULL; } =20 --=20 2.9.4 From nobody Mon Feb 9 13:49:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496986621969399.5715312446815; Thu, 8 Jun 2017 22:37:01 -0700 (PDT) Received: from localhost ([::1]:52710 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCbU-0004pK-Fq for importer@patchew.org; Fri, 09 Jun 2017 01:37:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCRz-0003z8-SL for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJCRy-0006gO-QZ for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:11 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:39801) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJCRy-0006ds-9X; Fri, 09 Jun 2017 01:27:10 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wkW4d0d4cz9sNh; Fri, 9 Jun 2017 15:26:56 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1496986017; bh=aliKIps3q59mHhZvthDDuXR27QbroBrM7iL/UE3Nn4A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EcNPiPPH4g4CwjST4aRj0wMet/dmu6c1zAB6b84FBH1kOoGyixNZ1vrdjZtTkaWQ/ T4tAE7p8Kd1LoqC1dB6Ca27xTVCJacP03Rw8bkZShKQVnrUhvtVinMnqz9QiXlu9cG ftX/6bqYDou2wOuS8xcdd17DGeyKtGpzrG3CGC10= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 9 Jun 2017 15:26:47 +1000 Message-Id: <20170609052652.23200-16-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170609052652.23200-1-david@gibson.dropbear.id.au> References: <20170609052652.23200-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 15/20] hw/cpu: core.c can be compiled as common object X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , qemu-devel@nongnu.org, sursingh@redhat.com, mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-ppc@nongnu.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) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth There does not seem to be any target specific code in core.c, so we can put it into "common-obj" instead of "obj" to compile it only once for all targets. Signed-off-by: Thomas Huth Reviewed-by: Juan Quintela Signed-off-by: David Gibson --- hw/cpu/Makefile.objs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/cpu/Makefile.objs b/hw/cpu/Makefile.objs index 942a4bb..cd52d20 100644 --- a/hw/cpu/Makefile.objs +++ b/hw/cpu/Makefile.objs @@ -2,5 +2,4 @@ obj-$(CONFIG_ARM11MPCORE) +=3D arm11mpcore.o obj-$(CONFIG_REALVIEW) +=3D realview_mpcore.o obj-$(CONFIG_A9MPCORE) +=3D a9mpcore.o obj-$(CONFIG_A15MPCORE) +=3D a15mpcore.o -obj-y +=3D core.o - +common-obj-y +=3D core.o --=20 2.9.4 From nobody Mon Feb 9 13:49:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496987082234439.2315153629852; Thu, 8 Jun 2017 22:44:42 -0700 (PDT) Received: from localhost ([::1]:52756 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCiu-00049i-Q1 for importer@patchew.org; Fri, 09 Jun 2017 01:44:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47148) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCS0-000409-Kk for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJCRy-0006g8-PE for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:12 -0400 Received: from ozlabs.org ([103.22.144.67]:56009) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJCRy-0006eR-97; Fri, 09 Jun 2017 01:27:10 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wkW4d5ZVBz9sNn; Fri, 9 Jun 2017 15:26:56 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1496986017; bh=Lur8otyqTg9soYPKyqaI8IqYcLEUTlUzeEiCGznbRaY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cBHDT07+5H3jjuRd0pSm1oD9msa2kfciGjdTcHAcRWWNGQOgPz4sGeNUia1WbpMnl HyU14AyAszPP/Vynk4M/1PhfWISXdoZcAU9k6pzy5sPTW+d+L0Z4XSzWOuZV1ODX81 I76zDmBzU0IA6iBAOXWZFR7R7sO0WcAQ78rxhVus= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 9 Jun 2017 15:26:48 +1000 Message-Id: <20170609052652.23200-17-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170609052652.23200-1-david@gibson.dropbear.id.au> References: <20170609052652.23200-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 16/20] xics: introduce macros for ICP/ICS link properties X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: agraf@suse.de, qemu-devel@nongnu.org, sursingh@redhat.com, mdroth@linux.vnet.ibm.com, Greg Kurz , qemu-ppc@nongnu.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) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz These properties are part of the XICS API. They deserve to appear explicitely in the XICS header file. Signed-off-by: Greg Kurz Signed-off-by: David Gibson --- hw/intc/xics.c | 8 ++++---- hw/ppc/pnv_core.c | 3 ++- hw/ppc/pnv_psi.c | 3 ++- hw/ppc/spapr.c | 3 ++- hw/ppc/spapr_cpu_core.c | 3 ++- include/hw/ppc/xics.h | 4 ++++ 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index ec73f02..aa2c4e7 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -346,9 +346,9 @@ static void icp_realize(DeviceState *dev, Error **errp) Object *obj; Error *err =3D NULL; =20 - obj =3D object_property_get_link(OBJECT(dev), "xics", &err); + obj =3D object_property_get_link(OBJECT(dev), ICP_PROP_XICS, &err); if (!obj) { - error_setg(errp, "%s: required link 'xics' not found: %s", + error_setg(errp, "%s: required link '" ICP_PROP_XICS "' not found:= %s", __func__, error_get_pretty(err)); return; } @@ -654,9 +654,9 @@ static void ics_base_realize(DeviceState *dev, Error **= errp) Object *obj; Error *err =3D NULL; =20 - obj =3D object_property_get_link(OBJECT(dev), "xics", &err); + obj =3D object_property_get_link(OBJECT(dev), ICS_PROP_XICS, &err); if (!obj) { - error_setg(errp, "%s: required link 'xics' not found: %s", + error_setg(errp, "%s: required link '" ICS_PROP_XICS "' not found:= %s", __func__, error_get_pretty(err)); return; } diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index e8a9a94..0b6e729 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -121,7 +121,8 @@ static void pnv_core_realize_child(Object *child, XICSF= abric *xi, Error **errp) obj =3D object_new(TYPE_PNV_ICP); object_property_add_child(OBJECT(cpu), "icp", obj, &error_abort); object_unref(obj); - object_property_add_const_link(obj, "xics", OBJECT(xi), &error_abort); + object_property_add_const_link(obj, ICP_PROP_XICS, OBJECT(xi), + &error_abort); object_property_set_bool(obj, true, "realized", &local_err); if (local_err) { error_propagate(errp, local_err); diff --git a/hw/ppc/pnv_psi.c b/hw/ppc/pnv_psi.c index 2bf5bfe..9876c26 100644 --- a/hw/ppc/pnv_psi.c +++ b/hw/ppc/pnv_psi.c @@ -474,7 +474,8 @@ static void pnv_psi_realize(DeviceState *dev, Error **e= rrp) } =20 /* Create PSI interrupt control source */ - object_property_add_const_link(OBJECT(ics), "xics", obj, &error_abort= ); + object_property_add_const_link(OBJECT(ics), ICS_PROP_XICS, obj, + &error_abort); object_property_set_int(OBJECT(ics), PSI_NUM_INTERRUPTS, "nr-irqs", &e= rr); if (err) { error_propagate(errp, err); diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 01dda9e..b2951d7 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -107,7 +107,8 @@ static ICSState *spapr_ics_create(sPAPRMachineState *sp= apr, =20 obj =3D object_new(type_ics); object_property_add_child(OBJECT(spapr), "ics", obj, &error_abort); - object_property_add_const_link(obj, "xics", OBJECT(spapr), &error_abor= t); + object_property_add_const_link(obj, ICS_PROP_XICS, OBJECT(spapr), + &error_abort); object_property_set_int(obj, nr_irqs, "nr-irqs", &local_err); if (local_err) { goto error; diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 029a141..e81879c 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -145,7 +145,8 @@ static void spapr_cpu_core_realize_child(Object *child,= Error **errp) obj =3D object_new(spapr->icp_type); object_property_add_child(OBJECT(cpu), "icp", obj, &error_abort); object_unref(obj); - object_property_add_const_link(obj, "xics", OBJECT(spapr), &error_abor= t); + object_property_add_const_link(obj, ICP_PROP_XICS, OBJECT(spapr), + &error_abort); object_property_set_bool(obj, true, "realized", &local_err); if (local_err) { goto error; diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index 40a506e..3114532 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -86,6 +86,8 @@ struct ICPState { XICSFabric *xics; }; =20 +#define ICP_PROP_XICS "xics" + struct PnvICPState { ICPState parent_obj; =20 @@ -130,6 +132,8 @@ struct ICSState { XICSFabric *xics; }; =20 +#define ICS_PROP_XICS "xics" + static inline bool ics_valid_irq(ICSState *ics, uint32_t nr) { return (ics->offset !=3D 0) && (nr >=3D ics->offset) --=20 2.9.4 From nobody Mon Feb 9 13:49:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496986949991563.1948753484124; Thu, 8 Jun 2017 22:42:29 -0700 (PDT) Received: from localhost ([::1]:52748 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCgm-0001vL-CX for importer@patchew.org; Fri, 09 Jun 2017 01:42:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47211) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCS1-00043G-NR for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJCRz-0006gp-9H for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:13 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:38907) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJCRy-0006eU-Pk; Fri, 09 Jun 2017 01:27:11 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wkW4d52hLz9sNk; Fri, 9 Jun 2017 15:26:56 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1496986017; bh=/iRNZQtvTyIHgA+tj6QBNR0wAo0jDwEsPDyQSG6FWS8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HEIxjt9sA/kWIe6JzbfMG7nAcUIDcCx+kDcpK8GsiNfoF+6ZRikxeZXIMhA9K5fD1 OUxFjiBSrmfai1klLAZLYLdBmnh4ZNYwJW8P2uP9w9smrvmwu94KNnRNXWNhvb/KtE Wp1+RPm56I4qPrxt09fMaDYQSmKPZohro2i0zcaU= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 9 Jun 2017 15:26:49 +1000 Message-Id: <20170609052652.23200-18-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170609052652.23200-1-david@gibson.dropbear.id.au> References: <20170609052652.23200-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 17/20] xics: pass appropriate types to realize() handlers. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: agraf@suse.de, qemu-devel@nongnu.org, sursingh@redhat.com, mdroth@linux.vnet.ibm.com, Greg Kurz , qemu-ppc@nongnu.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) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz It makes more sense to pass an IPCState * to handlers of ICPStateClass instead of a DeviceState *, if only to benefit from compile time type checking. The same goes with ICSStateClass. While here, we also change the declaration of ICPStateClass in xics.h for consistency. Signed-off-by: Greg Kurz Signed-off-by: David Gibson --- hw/intc/xics.c | 10 ++++------ hw/intc/xics_kvm.c | 6 ++---- hw/intc/xics_pnv.c | 6 +++--- include/hw/ppc/xics.h | 8 ++++---- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index aa2c4e7..f74a96e 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -356,7 +356,7 @@ static void icp_realize(DeviceState *dev, Error **errp) icp->xics =3D XICS_FABRIC(obj); =20 if (icpc->realize) { - icpc->realize(dev, errp); + icpc->realize(icp, errp); } =20 qemu_register_reset(icp_reset, dev); @@ -606,10 +606,8 @@ static void ics_simple_initfn(Object *obj) ics->offset =3D XICS_IRQ_BASE; } =20 -static void ics_simple_realize(DeviceState *dev, Error **errp) +static void ics_simple_realize(ICSState *ics, Error **errp) { - ICSState *ics =3D ICS_SIMPLE(dev); - if (!ics->nr_irqs) { error_setg(errp, "Number of interrupts needs to be greater 0"); return; @@ -617,7 +615,7 @@ static void ics_simple_realize(DeviceState *dev, Error = **errp) ics->irqs =3D g_malloc0(ics->nr_irqs * sizeof(ICSIRQState)); ics->qirqs =3D qemu_allocate_irqs(ics_simple_set_irq, ics, ics->nr_irq= s); =20 - qemu_register_reset(ics_simple_reset, dev); + qemu_register_reset(ics_simple_reset, ics); } =20 static Property ics_simple_properties[] =3D { @@ -664,7 +662,7 @@ static void ics_base_realize(DeviceState *dev, Error **= errp) =20 =20 if (icsc->realize) { - icsc->realize(dev, errp); + icsc->realize(ics, errp); } } =20 diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c index 45bf110..41c5b94 100644 --- a/hw/intc/xics_kvm.c +++ b/hw/intc/xics_kvm.c @@ -328,10 +328,8 @@ static void ics_kvm_reset(void *dev) ics_set_kvm_state(ics, 1); } =20 -static void ics_kvm_realize(DeviceState *dev, Error **errp) +static void ics_kvm_realize(ICSState *ics, Error **errp) { - ICSState *ics =3D ICS_SIMPLE(dev); - if (!ics->nr_irqs) { error_setg(errp, "Number of interrupts needs to be greater 0"); return; @@ -339,7 +337,7 @@ static void ics_kvm_realize(DeviceState *dev, Error **e= rrp) ics->irqs =3D g_malloc0(ics->nr_irqs * sizeof(ICSIRQState)); ics->qirqs =3D qemu_allocate_irqs(ics_kvm_set_irq, ics, ics->nr_irqs); =20 - qemu_register_reset(ics_kvm_reset, dev); + qemu_register_reset(ics_kvm_reset, ics); } =20 static void ics_kvm_class_init(ObjectClass *klass, void *data) diff --git a/hw/intc/xics_pnv.c b/hw/intc/xics_pnv.c index 12ae605..2a955a8 100644 --- a/hw/intc/xics_pnv.c +++ b/hw/intc/xics_pnv.c @@ -159,11 +159,11 @@ static const MemoryRegionOps pnv_icp_ops =3D { }, }; =20 -static void pnv_icp_realize(DeviceState *dev, Error **errp) +static void pnv_icp_realize(ICPState *icp, Error **errp) { - PnvICPState *icp =3D PNV_ICP(dev); + PnvICPState *pnv_icp =3D PNV_ICP(icp); =20 - memory_region_init_io(&icp->mmio, OBJECT(dev), &pnv_icp_ops, + memory_region_init_io(&pnv_icp->mmio, OBJECT(icp), &pnv_icp_ops, icp, "icp-thread", 0x1000); } =20 diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index 3114532..797df82 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -65,9 +65,9 @@ typedef struct XICSFabric XICSFabric; struct ICPStateClass { DeviceClass parent_class; =20 - void (*realize)(DeviceState *dev, Error **errp); - void (*pre_save)(ICPState *s); - int (*post_load)(ICPState *s, int version_id); + void (*realize)(ICPState *icp, Error **errp); + void (*pre_save)(ICPState *icp); + int (*post_load)(ICPState *icp, int version_id); void (*cpu_setup)(ICPState *icp, PowerPCCPU *cpu); void (*reset)(ICPState *icp); }; @@ -113,7 +113,7 @@ struct PnvICPState { struct ICSStateClass { DeviceClass parent_class; =20 - void (*realize)(DeviceState *dev, Error **errp); + void (*realize)(ICSState *s, Error **errp); void (*pre_save)(ICSState *s); int (*post_load)(ICSState *s, int version_id); void (*reject)(ICSState *s, uint32_t irq); --=20 2.9.4 From nobody Mon Feb 9 13:49:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496986806487420.70251832515964; Thu, 8 Jun 2017 22:40:06 -0700 (PDT) Received: from localhost ([::1]:52735 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCeS-0008ER-PP for importer@patchew.org; Fri, 09 Jun 2017 01:40:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47067) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCRy-0003xz-O8 for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJCRw-0006e7-4c for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:10 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:41129) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJCRv-0006cK-CO; Fri, 09 Jun 2017 01:27:07 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wkW4c4yW7z9sNH; Fri, 9 Jun 2017 15:26:56 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1496986016; bh=rOXw5wT2eX06Plo/20mh7uBfW1pum7lpihug3TsmrHs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JKW93I5BfMMZW4VR+sLHxx2gXTdAFiEUXaPHPf5rHVJDDXUZAnL31iYi+W9Eh/iN9 7jyYQ+uOdzpSOKKl4ztN5/IF82oIKQ4DS+ZE0FlgxC6vZQBu3VY3qVeIJndovjTlQJ URpGQRY1CmnIBjaK9lrn7GwoQqtnXzXecPitM1s4= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 9 Jun 2017 15:26:50 +1000 Message-Id: <20170609052652.23200-19-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170609052652.23200-1-david@gibson.dropbear.id.au> References: <20170609052652.23200-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 Subject: [Qemu-devel] [PULL 18/20] xics: setup cpu at realize time X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: agraf@suse.de, qemu-devel@nongnu.org, sursingh@redhat.com, mdroth@linux.vnet.ibm.com, Greg Kurz , qemu-ppc@nongnu.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) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz Until recently, spapr used to allocate ICPState objects for the lifetime of the machine. They would only be associated to vCPUs in xics_cpu_setup() when plugging a CPU core. Now that ICPState objects have the same lifecycle as vCPUs, it is possible to associate them during realization. This patch hence open-codes xics_cpu_setup() in icp_realize(). The vCPU is passed as a property. Note that vCPU now needs to be realized first for the IRQs to be allocated. It also needs to resetted before ICPState realization in order to synchronize with KVM. Since ICPState objects are freed when unrealized, xics_cpu_destroy() isn't needed anymore and can be safely dropped. Signed-off-by: Greg Kurz Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: David Gibson --- hw/intc/xics.c | 76 +++++++++++++++++++++------------------------= ---- hw/ppc/pnv_core.c | 18 ++++++------ hw/ppc/spapr_cpu_core.c | 23 +++++++-------- include/hw/ppc/xics.h | 3 +- 4 files changed, 51 insertions(+), 69 deletions(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index f74a96e..fdbfddf 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -38,50 +38,6 @@ #include "monitor/monitor.h" #include "hw/intc/intc.h" =20 -void xics_cpu_destroy(XICSFabric *xi, PowerPCCPU *cpu) -{ - CPUState *cs =3D CPU(cpu); - ICPState *icp =3D ICP(cpu->intc); - - assert(icp); - assert(cs =3D=3D icp->cs); - - icp->output =3D NULL; - icp->cs =3D NULL; -} - -void xics_cpu_setup(XICSFabric *xi, PowerPCCPU *cpu, ICPState *icp) -{ - CPUState *cs =3D CPU(cpu); - CPUPPCState *env =3D &cpu->env; - ICPStateClass *icpc; - - assert(icp); - - cpu->intc =3D OBJECT(icp); - icp->cs =3D cs; - - icpc =3D ICP_GET_CLASS(icp); - if (icpc->cpu_setup) { - icpc->cpu_setup(icp, cpu); - } - - switch (PPC_INPUT(env)) { - case PPC_FLAGS_INPUT_POWER7: - icp->output =3D env->irq_inputs[POWER7_INPUT_INT]; - break; - - case PPC_FLAGS_INPUT_970: - icp->output =3D env->irq_inputs[PPC970_INPUT_INT]; - break; - - default: - error_report("XICS interrupt controller does not support this CPU " - "bus model"); - abort(); - } -} - void icp_pic_print_info(ICPState *icp, Monitor *mon) { int cpu_index =3D icp->cs ? icp->cs->cpu_index : -1; @@ -343,6 +299,8 @@ static void icp_realize(DeviceState *dev, Error **errp) { ICPState *icp =3D ICP(dev); ICPStateClass *icpc =3D ICP_GET_CLASS(dev); + PowerPCCPU *cpu; + CPUPPCState *env; Object *obj; Error *err =3D NULL; =20 @@ -355,6 +313,36 @@ static void icp_realize(DeviceState *dev, Error **errp) =20 icp->xics =3D XICS_FABRIC(obj); =20 + obj =3D object_property_get_link(OBJECT(dev), ICP_PROP_CPU, &err); + if (!obj) { + error_setg(errp, "%s: required link '" ICP_PROP_CPU "' not found: = %s", + __func__, error_get_pretty(err)); + return; + } + + cpu =3D POWERPC_CPU(obj); + cpu->intc =3D OBJECT(icp); + icp->cs =3D CPU(obj); + + if (icpc->cpu_setup) { + icpc->cpu_setup(icp, cpu); + } + + env =3D &cpu->env; + switch (PPC_INPUT(env)) { + case PPC_FLAGS_INPUT_POWER7: + icp->output =3D env->irq_inputs[POWER7_INPUT_INT]; + break; + + case PPC_FLAGS_INPUT_970: + icp->output =3D env->irq_inputs[PPC970_INPUT_INT]; + break; + + default: + error_setg(errp, "XICS interrupt controller does not support this = CPU bus model"); + return; + } + if (icpc->realize) { icpc->realize(icp, errp); } diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index 0b6e729..c7b00b6 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -118,20 +118,20 @@ static void pnv_core_realize_child(Object *child, XIC= SFabric *xi, Error **errp) PowerPCCPU *cpu =3D POWERPC_CPU(cs); Object *obj; =20 - obj =3D object_new(TYPE_PNV_ICP); - object_property_add_child(OBJECT(cpu), "icp", obj, &error_abort); - object_unref(obj); - object_property_add_const_link(obj, ICP_PROP_XICS, OBJECT(xi), - &error_abort); - object_property_set_bool(obj, true, "realized", &local_err); + object_property_set_bool(child, true, "realized", &local_err); if (local_err) { error_propagate(errp, local_err); return; } =20 - object_property_set_bool(child, true, "realized", &local_err); + obj =3D object_new(TYPE_PNV_ICP); + object_property_add_child(child, "icp", obj, NULL); + object_unref(obj); + object_property_add_const_link(obj, ICP_PROP_XICS, OBJECT(xi), + &error_abort); + object_property_add_const_link(obj, ICP_PROP_CPU, child, &error_abort); + object_property_set_bool(obj, true, "realized", &local_err); if (local_err) { - object_unparent(obj); error_propagate(errp, local_err); return; } @@ -142,8 +142,6 @@ static void pnv_core_realize_child(Object *child, XICSF= abric *xi, Error **errp) error_propagate(errp, local_err); return; } - - xics_cpu_setup(xi, cpu, ICP(obj)); } =20 static void pnv_core_realize(DeviceState *dev, Error **errp) diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index e81879c..9fb896b 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -53,9 +53,6 @@ static void spapr_cpu_reset(void *opaque) =20 static void spapr_cpu_destroy(PowerPCCPU *cpu) { - sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); - - xics_cpu_destroy(XICS_FABRIC(spapr), cpu); qemu_unregister_reset(spapr_cpu_reset, cpu); } =20 @@ -140,29 +137,29 @@ static void spapr_cpu_core_realize_child(Object *chil= d, Error **errp) sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); CPUState *cs =3D CPU(child); PowerPCCPU *cpu =3D POWERPC_CPU(cs); - Object *obj; + Object *obj =3D NULL; =20 - obj =3D object_new(spapr->icp_type); - object_property_add_child(OBJECT(cpu), "icp", obj, &error_abort); - object_unref(obj); - object_property_add_const_link(obj, ICP_PROP_XICS, OBJECT(spapr), - &error_abort); - object_property_set_bool(obj, true, "realized", &local_err); + object_property_set_bool(child, true, "realized", &local_err); if (local_err) { goto error; } =20 - object_property_set_bool(child, true, "realized", &local_err); + spapr_cpu_init(spapr, cpu, &local_err); if (local_err) { goto error; } =20 - spapr_cpu_init(spapr, cpu, &local_err); + obj =3D object_new(spapr->icp_type); + object_property_add_child(child, "icp", obj, &error_abort); + object_unref(obj); + object_property_add_const_link(obj, ICP_PROP_XICS, OBJECT(spapr), + &error_abort); + object_property_add_const_link(obj, ICP_PROP_CPU, child, &error_abort); + object_property_set_bool(obj, true, "realized", &local_err); if (local_err) { goto error; } =20 - xics_cpu_setup(XICS_FABRIC(spapr), cpu, ICP(obj)); return; =20 error: diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index 797df82..37b8fb1 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -87,6 +87,7 @@ struct ICPState { }; =20 #define ICP_PROP_XICS "xics" +#define ICP_PROP_CPU "cpu" =20 struct PnvICPState { ICPState parent_obj; @@ -187,8 +188,6 @@ void spapr_dt_xics(int nr_servers, void *fdt, uint32_t = phandle); =20 qemu_irq xics_get_qirq(XICSFabric *xi, int irq); ICPState *xics_icp_get(XICSFabric *xi, int server); -void xics_cpu_setup(XICSFabric *xi, PowerPCCPU *cpu, ICPState *icp); -void xics_cpu_destroy(XICSFabric *xi, PowerPCCPU *cpu); =20 /* Internal XICS interfaces */ void icp_set_cppr(ICPState *icp, uint8_t cppr); --=20 2.9.4 From nobody Mon Feb 9 13:49:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496986625719789.8387856968632; Thu, 8 Jun 2017 22:37:05 -0700 (PDT) Received: from localhost ([::1]:52712 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCbX-0004rP-SR for importer@patchew.org; Fri, 09 Jun 2017 01:37:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCRz-0003yY-DD for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJCRy-0006fJ-3Z for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:11 -0400 Received: from ozlabs.org ([103.22.144.67]:60293) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJCRx-0006dr-Nh; Fri, 09 Jun 2017 01:27:10 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wkW4d2Jl4z9sNl; Fri, 9 Jun 2017 15:26:56 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1496986017; bh=NqNofQk74n9cS1pLnIvP+pGDLVRROi25YvojawdZFoo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XUf7dI5DLXxXPqG0Cfn3MlljSWSF20n9hMeLb1yxb7wJrcrf9r948kOYSMofjksw3 wp/kV9Pt/AXRDbm7j9yD2OUM3fMey5xPi/wPtVfDqICZLDE4V/6+FzcGRFG75A3NW5 oRWZquhOgpkywIIT9xlQI0nZhUafMVEyF9jy7u0k= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 9 Jun 2017 15:26:51 +1000 Message-Id: <20170609052652.23200-20-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170609052652.23200-1-david@gibson.dropbear.id.au> References: <20170609052652.23200-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 19/20] xics: drop ICPStateClass::cpu_setup() handler X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: agraf@suse.de, qemu-devel@nongnu.org, sursingh@redhat.com, mdroth@linux.vnet.ibm.com, Greg Kurz , qemu-ppc@nongnu.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) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz The cpu_setup() handler is only implemented by xics_kvm, where it really does a typical "realize" job. Moreover, the realize() handler is called shortly after cpu_setup(), on the same path. This patch converts xics_kvm to implement realize() instead of cpu_setup(). Signed-off-by: Greg Kurz Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: David Gibson --- hw/intc/xics.c | 4 ---- hw/intc/xics_kvm.c | 12 ++++++------ include/hw/ppc/xics.h | 1 - 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index fdbfddf..7ccfb53 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -324,10 +324,6 @@ static void icp_realize(DeviceState *dev, Error **errp) cpu->intc =3D OBJECT(icp); icp->cs =3D CPU(obj); =20 - if (icpc->cpu_setup) { - icpc->cpu_setup(icp, cpu); - } - env =3D &cpu->env; switch (PPC_INPUT(env)) { case PPC_FLAGS_INPUT_POWER7: diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c index 41c5b94..3091ad3 100644 --- a/hw/intc/xics_kvm.c +++ b/hw/intc/xics_kvm.c @@ -115,9 +115,9 @@ static void icp_kvm_reset(ICPState *icp) icp_set_kvm_state(icp, 1); } =20 -static void icp_kvm_cpu_setup(ICPState *icp, PowerPCCPU *cpu) +static void icp_kvm_realize(ICPState *icp, Error **errp) { - CPUState *cs =3D CPU(cpu); + CPUState *cs =3D icp->cs; KVMEnabledICP *enabled_icp; unsigned long vcpu_id =3D kvm_arch_vcpu_id(cs); int ret; @@ -139,9 +139,9 @@ static void icp_kvm_cpu_setup(ICPState *icp, PowerPCCPU= *cpu) =20 ret =3D kvm_vcpu_enable_cap(cs, KVM_CAP_IRQ_XICS, 0, kernel_xics_fd, v= cpu_id); if (ret < 0) { - error_report("Unable to connect CPU%ld to kernel XICS: %s", vcpu_i= d, - strerror(errno)); - exit(1); + error_setg(errp, "Unable to connect CPU%ld to kernel XICS: %s", vc= pu_id, + strerror(errno)); + return; } enabled_icp =3D g_malloc(sizeof(*enabled_icp)); enabled_icp->vcpu_id =3D vcpu_id; @@ -154,7 +154,7 @@ static void icp_kvm_class_init(ObjectClass *klass, void= *data) =20 icpc->pre_save =3D icp_get_kvm_state; icpc->post_load =3D icp_set_kvm_state; - icpc->cpu_setup =3D icp_kvm_cpu_setup; + icpc->realize =3D icp_kvm_realize; icpc->reset =3D icp_kvm_reset; } =20 diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index 37b8fb1..28d248a 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -68,7 +68,6 @@ struct ICPStateClass { void (*realize)(ICPState *icp, Error **errp); void (*pre_save)(ICPState *icp); int (*post_load)(ICPState *icp, int version_id); - void (*cpu_setup)(ICPState *icp, PowerPCCPU *cpu); void (*reset)(ICPState *icp); }; =20 --=20 2.9.4 From nobody Mon Feb 9 13:49:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496986604978782.0260868003671; Thu, 8 Jun 2017 22:36:44 -0700 (PDT) Received: from localhost ([::1]:52707 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCbB-0004Z1-FS for importer@patchew.org; Fri, 09 Jun 2017 01:36:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47184) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCS1-00041k-6D for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJCRz-0006gv-9u for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:27:13 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:43889) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJCRy-0006eb-Pu; Fri, 09 Jun 2017 01:27:11 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wkW4d6Hrjz9sNm; Fri, 9 Jun 2017 15:26:56 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1496986017; bh=h5aH1hP7H6oHdDuCVIdIJ3WMIkx1E8klX6WwRMJ5T+Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BaaDpMJU282enY7mKwYg5pyHRYnXcxNJ9wY9TifsAF2ehvWBhy18eyw2XIDU4GSCZ zmOdi7yit+rUMwG9RsYARAkoqAxFuOPNpCbGXac2tAu7ortLFUnLaZebN8nmj4gs6e ZEMek7TwNX0ofGUai6926DojyYNk1Y5NCcFNWaz8= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 9 Jun 2017 15:26:52 +1000 Message-Id: <20170609052652.23200-21-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170609052652.23200-1-david@gibson.dropbear.id.au> References: <20170609052652.23200-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 20/20] Revert "spapr: fix memory hot-unplugging" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , qemu-devel@nongnu.org, sursingh@redhat.com, mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-ppc@nongnu.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) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Laurent Vivier This reverts commit fe6824d12642b005c69123ecf8631f9b13553f8b. Conflicts hw/ppc/spapr_drc.c, because get_index() has been renamed spapr_get_index(). This didn't fix the problem. Once the hotplug has been started some memory is allocated and some structures are allocated. We don't free it when we ignore the unplug, and we can't because they can be in use by the kernel. Signed-off-by: Laurent Vivier Tested-by: Daniel Barboza Signed-off-by: David Gibson --- hw/ppc/spapr_drc.c | 20 +++----------------- include/hw/ppc/spapr_drc.h | 1 - 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 15ef67d..5cb75bb 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -128,17 +128,6 @@ static uint32_t set_allocation_state(sPAPRDRConnector = *drc, if (!drc->dev) { return RTAS_OUT_NO_SUCH_INDICATOR; } - if (drc->awaiting_release && drc->awaiting_allocation) { - /* kernel is acknowledging a previous hotplug event - * while we are already removing it. - * it's safe to ignore awaiting_allocation here since we know = the - * situation is predicated on the guest either already having = done - * so (boot-time hotplug), or never being able to acquire in t= he - * first place (hotplug followed by immediate unplug). - */ - drc->awaiting_allocation_skippable =3D true; - return RTAS_OUT_NO_SUCH_INDICATOR; - } } =20 if (spapr_drc_type(drc) !=3D SPAPR_DR_CONNECTOR_TYPE_PCI) { @@ -391,11 +380,9 @@ void spapr_drc_detach(sPAPRDRConnector *drc, DeviceSta= te *d, Error **errp) } =20 if (drc->awaiting_allocation) { - if (!drc->awaiting_allocation_skippable) { - drc->awaiting_release =3D true; - trace_spapr_drc_awaiting_allocation(spapr_drc_index(drc)); - return; - } + drc->awaiting_release =3D true; + trace_spapr_drc_awaiting_allocation(spapr_drc_index(drc)); + return; } =20 drc->dr_indicator =3D SPAPR_DR_INDICATOR_INACTIVE; @@ -418,7 +405,6 @@ void spapr_drc_detach(sPAPRDRConnector *drc, DeviceStat= e *d, Error **errp) } =20 drc->awaiting_release =3D false; - drc->awaiting_allocation_skippable =3D false; g_free(drc->fdt); drc->fdt =3D NULL; drc->fdt_start_offset =3D 0; diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h index c487123..bc9f988 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -201,7 +201,6 @@ typedef struct sPAPRDRConnector { bool awaiting_release; bool signalled; bool awaiting_allocation; - bool awaiting_allocation_skippable; =20 /* device pointer, via link property */ DeviceState *dev; --=20 2.9.4