From nobody Fri Apr 26 18:15:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1560318958; cv=none; d=zoho.com; s=zohoarc; b=m0FA0Jgr4IK3hmFwdMg0BtnLjdDjY2T7WhKSnI90ON+zm3KaynapNpd+0gZUbMhCFm3BiwNsUxC5PlNr/xiti/d+CBHy72rTBFzsxdjq4SzhRq/Fbw40rFuJaEKjSBC//KkTrF20MxoitKmGdmt7lxowQGS4AHsK3By4wAePx2I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560318958; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=pmEAEEKfSnyfGQ9MvBwtHVRHzTaMTK6BwAMRTuVStuw=; b=jTaMsKHWyxJrXA3cdkW+ddaS+6WgX3L6IuMZf9rx3tbamfCpVQILASQSi6FAQXK9cZI28OMysDykT5GodfBKIlPoAFYLaz11WGtgHHiBWQX0EyfWe2VKll8t57bnTr0dJyZbAeyEKRGBP7RS35qIIv+UXA6M4DzfKa6cAxaC1V4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560318958569220.67400602424414; Tue, 11 Jun 2019 22:55:58 -0700 (PDT) Received: from localhost ([::1]:56842 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hawEk-0003aL-Ks for importer@patchew.org; Wed, 12 Jun 2019 01:55:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58396) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1haw8j-0004Ow-By for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1haw8i-000710-48 for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:41 -0400 Received: from ozlabs.org ([203.11.71.1]:60519) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1haw8g-0006ze-Rs; Wed, 12 Jun 2019 01:49:40 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 45NwtQ41vPz9s6w; Wed, 12 Jun 2019 15:49:34 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1560318574; bh=Ouz+QarirwIM17ifHbWbbOGb+G6yD8tl0/FYe436hdU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oG3N/8tRf+GT5p3oBxK8qXkna7P0Z8TMCev1QFr5J1Tu+QrCenYPQT/OWMDpQ6bhx 8f4XFNA/fsqEnP3vt0CSmtydbf7SRmjJ+KkHY95jLrCL4/u2Xt7yCgdFA8fkUk4UhF vDvKhLC4FV72D0r6T7O7VXMCtXfC0oIM6DQHpOXE= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 12 Jun 2019 15:49:17 +1000 Message-Id: <20190612054929.21136-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190612054929.21136-1-david@gibson.dropbear.id.au> References: <20190612054929.21136-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] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 01/13] spapr_pci: Improve error message X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, aik@ozlabs.ru, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Greg Kurz Every PHB must have a unique index. This is checked at realize but when a duplicate index is detected, an error message mentioning BUIDs is printed. This doesn't help much, especially since BUID is an internal concept that is no longer exposed to the user. Fix the message to mention the index property instead of BUID. As a bonus print a list of indexes already in use. Signed-off-by: Greg Kurz Message-Id: <155915010892.2061314.10485622810149098411.stgit@bahia.lan> Signed-off-by: David Gibson --- hw/ppc/spapr_pci.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 9cf2c41b8c..483639b107 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1677,7 +1677,14 @@ static void spapr_phb_realize(DeviceState *dev, Erro= r **errp) } =20 if (spapr_pci_find_phb(spapr, sphb->buid)) { - error_setg(errp, "PCI host bridges must have unique BUIDs"); + SpaprPhbState *s; + + error_setg(errp, "PCI host bridges must have unique indexes"); + error_append_hint(errp, "The following indexes are already in use:= "); + QLIST_FOREACH(s, &spapr->phbs, list) { + error_append_hint(errp, " %d", s->index); + } + error_append_hint(errp, "\nTry another value for the index propert= y\n"); return; } =20 --=20 2.21.0 From nobody Fri Apr 26 18:15:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1560318745; cv=none; d=zoho.com; s=zohoarc; b=FHSzgL50LR/FC+z5k3utig6F5tDLL73fmU1xbykSmm7DHUS1MbCuuhj0j4USw5n7kQ85rqXpi5jNAtF8GJjiG6obni3LQ7oH4XaclWxxKEHMHSY5sY/IXm2jDPG2fe9ooK7BnJKwGCtr7ppsDsdoL705lqC9b54tNUAGpsoVxBU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560318745; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=swiDDbo8esrQvngN2M3rwA2ZSzcW7vLIVE5TffeyMMw=; b=D4XCKmZEI6VIwkDlFNGVLnULFEfcmanBKPMTXYAwOZEwLrB/L6oq+0hwt1OfjdOkYc3IQViZFg6Et/qeTFbV9arTAv45j+t30XDhUgg+QudTsbk11ORkmuN/P7OBobjPq+mXM07WBpIHrG5pTFDMlI0lc6Z4BjGseZGNiCaUJU4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156031874392233.48824178361974; Tue, 11 Jun 2019 22:52:23 -0700 (PDT) Received: from localhost ([::1]:56812 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hawBI-0006lb-T2 for importer@patchew.org; Wed, 12 Jun 2019 01:52:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58391) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1haw8j-0004Od-36 for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1haw8h-00070l-Pn for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:41 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:34047) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1haw8g-0006zf-MK; Wed, 12 Jun 2019 01:49:39 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 45NwtQ4zKFz9sBr; Wed, 12 Jun 2019 15:49:34 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1560318574; bh=68ja9D+gsAavD+uwI2kDBEzDvhTjjHe39m37M5/3DuU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MIhTdr6RdAUeIM0HSVZ9yoWdrD3eMUQyOcfZ/ckJmvzcbwUzgb9/6wxqw95vYJOQV E7XQR9Juv3M4aI4uzlbE9zsKTTT2wNVrVbtjg8yNV01awBpZorOWuju8kensrTl6Ph j1Vz/OyGucNg1w6lleAGUyUxVphbsipCWGglodMg= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 12 Jun 2019 15:49:18 +1000 Message-Id: <20190612054929.21136-3-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190612054929.21136-1-david@gibson.dropbear.id.au> References: <20190612054929.21136-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 02/13] target/ppc: Fix lxvw4x, lxvh8x and lxvb16x X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, aik@ozlabs.ru, Mark Cave-Ayland , qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, Anton Blanchard , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Anton Blanchard During the conversion these instructions were incorrectly treated as stores. We need to use set_cpu_vsr* and not get_cpu_vsr*. Fixes: 8b3b2d75c7c0 ("introduce get_cpu_vsr{l,h}() and set_cpu_vsr{l,h}() h= elpers for VSR register access") Signed-off-by: Anton Blanchard Reviewed-by: Mark Cave-Ayland Tested-by: Greg Kurz Reviewed-by: Greg Kurz Message-Id: <20190524065345.25591-1-mark.cave-ayland@ilande.co.uk> Signed-off-by: David Gibson --- target/ppc/translate/vsx-impl.inc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/target/ppc/translate/vsx-impl.inc.c b/target/ppc/translate/vsx= -impl.inc.c index 199d22da97..cdb44b8b70 100644 --- a/target/ppc/translate/vsx-impl.inc.c +++ b/target/ppc/translate/vsx-impl.inc.c @@ -102,8 +102,7 @@ static void gen_lxvw4x(DisasContext *ctx) } xth =3D tcg_temp_new_i64(); xtl =3D tcg_temp_new_i64(); - get_cpu_vsrh(xth, xT(ctx->opcode)); - get_cpu_vsrl(xtl, xT(ctx->opcode)); + gen_set_access_type(ctx, ACCESS_INT); EA =3D tcg_temp_new(); =20 @@ -126,6 +125,8 @@ static void gen_lxvw4x(DisasContext *ctx) tcg_gen_addi_tl(EA, EA, 8); tcg_gen_qemu_ld_i64(xtl, EA, ctx->mem_idx, MO_BEQ); } + set_cpu_vsrh(xT(ctx->opcode), xth); + set_cpu_vsrl(xT(ctx->opcode), xtl); tcg_temp_free(EA); tcg_temp_free_i64(xth); tcg_temp_free_i64(xtl); @@ -185,8 +186,6 @@ static void gen_lxvh8x(DisasContext *ctx) } xth =3D tcg_temp_new_i64(); xtl =3D tcg_temp_new_i64(); - get_cpu_vsrh(xth, xT(ctx->opcode)); - get_cpu_vsrl(xtl, xT(ctx->opcode)); gen_set_access_type(ctx, ACCESS_INT); =20 EA =3D tcg_temp_new(); @@ -197,6 +196,8 @@ static void gen_lxvh8x(DisasContext *ctx) if (ctx->le_mode) { gen_bswap16x8(xth, xtl, xth, xtl); } + set_cpu_vsrh(xT(ctx->opcode), xth); + set_cpu_vsrl(xT(ctx->opcode), xtl); tcg_temp_free(EA); tcg_temp_free_i64(xth); tcg_temp_free_i64(xtl); @@ -214,14 +215,14 @@ static void gen_lxvb16x(DisasContext *ctx) } xth =3D tcg_temp_new_i64(); xtl =3D tcg_temp_new_i64(); - get_cpu_vsrh(xth, xT(ctx->opcode)); - get_cpu_vsrl(xtl, xT(ctx->opcode)); gen_set_access_type(ctx, ACCESS_INT); EA =3D tcg_temp_new(); gen_addr_reg_index(ctx, EA); tcg_gen_qemu_ld_i64(xth, EA, ctx->mem_idx, MO_BEQ); tcg_gen_addi_tl(EA, EA, 8); tcg_gen_qemu_ld_i64(xtl, EA, ctx->mem_idx, MO_BEQ); + set_cpu_vsrh(xT(ctx->opcode), xth); + set_cpu_vsrl(xT(ctx->opcode), xtl); tcg_temp_free(EA); tcg_temp_free_i64(xth); tcg_temp_free_i64(xtl); --=20 2.21.0 From nobody Fri Apr 26 18:15:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1560318737; cv=none; d=zoho.com; s=zohoarc; b=P6UtMLFjPMXg/imdnMNItgpA1MvyYLmcMozI+111mUsr0EfJDre51nx6/nWMi4vbdtwFCe0tV+o25flV4cAKgpDZSgMLEvg1CfdmKuQNtheGbHImpCbLpEFZWJErH2XXAgBgr6NTJO4MUZSgP5WwitbB0M00DSfNw2Xh04JkCgQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560318737; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=1Ieo2Zrx03vfMGJmJk9XUvcN0Xw/tCyIW7ourfw2kpk=; b=EkXzSYZ4L4aMDw0yb8tQcG0DtJcDQnftujEzQTrIMp+qonrHHwnEDZrqGG5mPEKPYKKNEi2ySMLfB/0WCGqL7h+RTw3U3b/euffsDrwKiBSxa15Oqwo/GkouvQXlVLgxqPFM6rY80vl/dP0upFwYNChIrb/GOZI6Ieyb9wRmu68= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560318735797563.249681878553; Tue, 11 Jun 2019 22:52:15 -0700 (PDT) Received: from localhost ([::1]:56810 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hawB9-0006hz-7v for importer@patchew.org; Wed, 12 Jun 2019 01:52:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58386) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1haw8i-0004OP-TR for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1haw8h-00070d-HJ for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:40 -0400 Received: from bilbo.ozlabs.org ([2401:3900:2:1::2]:36969 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1haw8g-0006zh-MQ; Wed, 12 Jun 2019 01:49:39 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 45NwtQ626Nz9sDB; Wed, 12 Jun 2019 15:49:34 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1560318574; bh=vsL1MTcIqQtzX5J9XA5ybbRM13gWkkMbqPYJHP8GFT8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YqhUbCMZHahPs5YVI05TxaJhglxTkClsJ4hYf45s1tEYhMu87B0z2s57fxtww0vbX SfRqNwvfj+IrzY3b7rfzayjLQd94TMlFmrzxxmrnUOv2AzNVkVL+3vig0SYamQBqjx Y2Mf4VhVrApEZj+Au7gVWP+HL60DLypChYQ30iuY= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 12 Jun 2019 15:49:19 +1000 Message-Id: <20190612054929.21136-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190612054929.21136-1-david@gibson.dropbear.id.au> References: <20190612054929.21136-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 03/13] spapr: Clean up device node name generation for PCI devices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, "Michael S . Tsirkin" , aik@ozlabs.ru, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" spapr_populate_pci_child_dt() adds a 'name' property to the device tree node for PCI devices. This is never necessary for a flattened device tree, it is implicit in the name added when the node is constructed. In fact anything we do add to a 'name' property will be overwritten with something derived from the structural name in the guest firmware (but in fact it is exactly the same bytes). So, remove that. In addition, pci_get_node_name() is very simple, so fold it into its (also simple) sole caller spapr_create_pci_child_dt(). While we're there rename pci_find_device_name() to the shorter and more accurate dt_name_from_class(). Signed-off-by: David Gibson Reviewed-by: Greg Kurz Acked-by: Michael S. Tsirkin --- hw/ppc/spapr_pci.c | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 483639b107..e8173d3246 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1173,8 +1173,8 @@ static const PCIClass pci_classes[] =3D { { "data-processing-controller", spc_subclass }, }; =20 -static const char *pci_find_device_name(uint8_t class, uint8_t subclass, - uint8_t iface) +static const char *dt_name_from_class(uint8_t class, uint8_t subclass, + uint8_t iface) { const PCIClass *pclass; const PCISubClass *psubclass; @@ -1216,23 +1216,6 @@ static const char *pci_find_device_name(uint8_t clas= s, uint8_t subclass, return name; } =20 -static gchar *pci_get_node_name(PCIDevice *dev) -{ - int slot =3D PCI_SLOT(dev->devfn); - int func =3D PCI_FUNC(dev->devfn); - uint32_t ccode =3D pci_default_read_config(dev, PCI_CLASS_PROG, 3); - const char *name; - - name =3D pci_find_device_name((ccode >> 16) & 0xff, (ccode >> 8) & 0xf= f, - ccode & 0xff); - - if (func !=3D 0) { - return g_strdup_printf("%s@%x,%x", name, slot, func); - } else { - return g_strdup_printf("%s@%x", name, slot); - } -} - static uint32_t spapr_phb_get_pci_drc_index(SpaprPhbState *phb, PCIDevice *pdev); =20 @@ -1300,11 +1283,6 @@ static void spapr_populate_pci_child_dt(PCIDevice *d= ev, void *fdt, int offset, _FDT(fdt_setprop(fdt, offset, "udf-supported", NULL, 0)); } =20 - _FDT(fdt_setprop_string(fdt, offset, "name", - pci_find_device_name((ccode >> 16) & 0xff, - (ccode >> 8) & 0xff, - ccode & 0xff))); - buf =3D spapr_phb_get_loc_code(sphb, dev); _FDT(fdt_setprop_string(fdt, offset, "ibm,loc-code", buf)); g_free(buf); @@ -1348,10 +1326,23 @@ static int spapr_create_pci_child_dt(SpaprPhbState = *phb, PCIDevice *dev, void *fdt, int node_offset) { int offset; + const gchar *basename; gchar *nodename; + int slot =3D PCI_SLOT(dev->devfn); + int func =3D PCI_FUNC(dev->devfn); + uint32_t ccode =3D pci_default_read_config(dev, PCI_CLASS_PROG, 3); + + basename =3D dt_name_from_class((ccode >> 16) & 0xff, (ccode >> 8) & 0= xff, + ccode & 0xff); + + if (func !=3D 0) { + nodename =3D g_strdup_printf("%s@%x,%x", basename, slot, func); + } else { + nodename =3D g_strdup_printf("%s@%x", basename, slot); + } =20 - nodename =3D pci_get_node_name(dev); _FDT(offset =3D fdt_add_subnode(fdt, node_offset, nodename)); + g_free(nodename); =20 spapr_populate_pci_child_dt(dev, fdt, offset, phb); --=20 2.21.0 From nobody Fri Apr 26 18:15:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1560319393; cv=none; d=zoho.com; s=zohoarc; b=f17S8d+OPTZWFyyIbv69Ed8V56oeHKvnZ3RxUPurMO9+NH+czaN2Mj5tuEyXdAWpKe+cTk5FJrmEilAmyfmGRk8vzS4vhCLSljm9pIonef9p7mkLuICbxo5wOj6oDhclx5k0gDnZCOKHngu0Oan18cycbbPbToczL3hhu/W1mOs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560319393; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=otAQ779+3ncrbRSTgp8ZKLh9urjrWtPugAfY+tAvZ9s=; b=WFxryl+s282BrYJvixivcQJmY2AWdxHVxj/gwWGvBQoQXk/cXTqSyk3063wbTGXRfV/pJIyzd6DSszg9PHpPiU60evx/rC9kTu5MTR0ceYtrrN3qIru73jaXyC/bncpd0BmHbA2I/Z5TTnq0B0O/jq4r5W2c8bzDXFRtgJ/Z0VQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560319393354997.7831911612287; Tue, 11 Jun 2019 23:03:13 -0700 (PDT) Received: from localhost ([::1]:56872 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hawLm-0006xX-0n for importer@patchew.org; Wed, 12 Jun 2019 02:03:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58443) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1haw8l-0004Rq-EW for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1haw8j-00071k-9K for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:43 -0400 Received: from bilbo.ozlabs.org ([203.11.71.1]:36029 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1haw8g-0006zi-ME; Wed, 12 Jun 2019 01:49:41 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 45NwtQ6ggpz9sNC; Wed, 12 Jun 2019 15:49:34 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1560318574; bh=8A/zGEQXWaU06j42fyfoXAwqsbhF/kNZZQ+ztY9cByM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N0jSpMkjtVythpFBKMEHoeGp35vF+84XWT0FMPTrED0YEJdXdRuPEcjYACAFWETlS JHdurTdOKkplODXQN68ELFothcSUgMymMGnMQzjXFn7dnt705iPXrL2pgw/L8HDu/I r3jiYfd8+gXfxzxE9oVGPwKJ1LLJNyG/n7Ziseao= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 12 Jun 2019 15:49:20 +1000 Message-Id: <20190612054929.21136-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190612054929.21136-1-david@gibson.dropbear.id.au> References: <20190612054929.21136-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] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 04/13] spapr: Clean up device tree construction for PCI devices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, "Michael S . Tsirkin" , aik@ozlabs.ru, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" spapr_create_pci_child_dt() is a trivial wrapper around spapr_populate_pci_child_dt(), but is the latter's only caller. So fold them together into spapr_dt_pci_device(), which closer matches our modern naming convention. While there, make a number of cleanups to the function itself. This is mostly using more temporary locals to avoid awkwardly long lines, and in some cases avoiding double reads of PCI config space variables. Signed-off-by: David Gibson Reviewed-by: Greg Kurz Acked-by: Michael S. Tsirkin --- hw/ppc/spapr_pci.c | 119 +++++++++++++++++++++------------------------ 1 file changed, 55 insertions(+), 64 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index e8173d3246..8e10fc6857 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1219,57 +1219,75 @@ static const char *dt_name_from_class(uint8_t class= , uint8_t subclass, static uint32_t spapr_phb_get_pci_drc_index(SpaprPhbState *phb, PCIDevice *pdev); =20 -static void spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int off= set, - SpaprPhbState *sphb) +/* create OF node for pci device and required OF DT properties */ +static int spapr_dt_pci_device(SpaprPhbState *sphb, PCIDevice *dev, + void *fdt, int parent_offset) { + int offset; + const gchar *basename; + gchar *nodename; + int slot =3D PCI_SLOT(dev->devfn); + int func =3D PCI_FUNC(dev->devfn); ResourceProps rp; - bool is_bridge =3D false; - int pci_status; - char *buf =3D NULL; uint32_t drc_index =3D spapr_phb_get_pci_drc_index(sphb, dev); + uint32_t header_type =3D pci_default_read_config(dev, PCI_HEADER_TYPE,= 1); + bool is_bridge =3D (header_type =3D=3D PCI_HEADER_TYPE_BRIDGE); + uint32_t vendor_id =3D pci_default_read_config(dev, PCI_VENDOR_ID, 2); + uint32_t device_id =3D pci_default_read_config(dev, PCI_DEVICE_ID, 2); + uint32_t revision_id =3D pci_default_read_config(dev, PCI_REVISION_ID,= 1); uint32_t ccode =3D pci_default_read_config(dev, PCI_CLASS_PROG, 3); - uint32_t max_msi, max_msix; + uint32_t irq_pin =3D pci_default_read_config(dev, PCI_INTERRUPT_PIN, 1= ); + uint32_t subsystem_id =3D pci_default_read_config(dev, PCI_SUBSYSTEM_I= D, 2); + uint32_t subsystem_vendor_id =3D + pci_default_read_config(dev, PCI_SUBSYSTEM_VENDOR_ID, 2); + uint32_t cache_line_size =3D + pci_default_read_config(dev, PCI_CACHE_LINE_SIZE, 1); + uint32_t pci_status =3D pci_default_read_config(dev, PCI_STATUS, 2); + gchar *loc_code; =20 - if (pci_default_read_config(dev, PCI_HEADER_TYPE, 1) =3D=3D - PCI_HEADER_TYPE_BRIDGE) { - is_bridge =3D true; + basename =3D dt_name_from_class((ccode >> 16) & 0xff, (ccode >> 8) & 0= xff, + ccode & 0xff); + + if (func !=3D 0) { + nodename =3D g_strdup_printf("%s@%x,%x", basename, slot, func); + } else { + nodename =3D g_strdup_printf("%s@%x", basename, slot); } =20 + _FDT(offset =3D fdt_add_subnode(fdt, parent_offset, nodename)); + + g_free(nodename); + /* in accordance with PAPR+ v2.7 13.6.3, Table 181 */ - _FDT(fdt_setprop_cell(fdt, offset, "vendor-id", - pci_default_read_config(dev, PCI_VENDOR_ID, 2))); - _FDT(fdt_setprop_cell(fdt, offset, "device-id", - pci_default_read_config(dev, PCI_DEVICE_ID, 2))); - _FDT(fdt_setprop_cell(fdt, offset, "revision-id", - pci_default_read_config(dev, PCI_REVISION_ID, 1)= )); + _FDT(fdt_setprop_cell(fdt, offset, "vendor-id", vendor_id)); + _FDT(fdt_setprop_cell(fdt, offset, "device-id", device_id)); + _FDT(fdt_setprop_cell(fdt, offset, "revision-id", revision_id)); + _FDT(fdt_setprop_cell(fdt, offset, "class-code", ccode)); - if (pci_default_read_config(dev, PCI_INTERRUPT_PIN, 1)) { - _FDT(fdt_setprop_cell(fdt, offset, "interrupts", - pci_default_read_config(dev, PCI_INTERRUPT_PIN, 1))); + if (irq_pin) { + _FDT(fdt_setprop_cell(fdt, offset, "interrupts", irq_pin)); } =20 if (!is_bridge) { - _FDT(fdt_setprop_cell(fdt, offset, "min-grant", - pci_default_read_config(dev, PCI_MIN_GNT, 1))); - _FDT(fdt_setprop_cell(fdt, offset, "max-latency", - pci_default_read_config(dev, PCI_MAX_LAT, 1))); + uint32_t min_grant =3D pci_default_read_config(dev, PCI_MIN_GNT, 1= ); + uint32_t max_latency =3D pci_default_read_config(dev, PCI_MAX_LAT,= 1); + _FDT(fdt_setprop_cell(fdt, offset, "min-grant", min_grant)); + _FDT(fdt_setprop_cell(fdt, offset, "max-latency", max_latency)); } =20 - if (pci_default_read_config(dev, PCI_SUBSYSTEM_ID, 2)) { - _FDT(fdt_setprop_cell(fdt, offset, "subsystem-id", - pci_default_read_config(dev, PCI_SUBSYSTEM_ID, 2))); + if (subsystem_id) { + _FDT(fdt_setprop_cell(fdt, offset, "subsystem-id", subsystem_id)); } =20 - if (pci_default_read_config(dev, PCI_SUBSYSTEM_VENDOR_ID, 2)) { + if (subsystem_vendor_id) { _FDT(fdt_setprop_cell(fdt, offset, "subsystem-vendor-id", - pci_default_read_config(dev, PCI_SUBSYSTEM_VENDOR_ID, 2))= ); + subsystem_vendor_id)); } =20 - _FDT(fdt_setprop_cell(fdt, offset, "cache-line-size", - pci_default_read_config(dev, PCI_CACHE_LINE_SIZE, 1))); + _FDT(fdt_setprop_cell(fdt, offset, "cache-line-size", cache_line_size)= ); + =20 /* the following fdt cells are masked off the pci status register */ - pci_status =3D pci_default_read_config(dev, PCI_STATUS, 2); _FDT(fdt_setprop_cell(fdt, offset, "devsel-speed", PCI_STATUS_DEVSEL_MASK & pci_status)); =20 @@ -1283,9 +1301,9 @@ static void spapr_populate_pci_child_dt(PCIDevice *de= v, void *fdt, int offset, _FDT(fdt_setprop(fdt, offset, "udf-supported", NULL, 0)); } =20 - buf =3D spapr_phb_get_loc_code(sphb, dev); - _FDT(fdt_setprop_string(fdt, offset, "ibm,loc-code", buf)); - g_free(buf); + loc_code =3D spapr_phb_get_loc_code(sphb, dev); + _FDT(fdt_setprop_string(fdt, offset, "ibm,loc-code", loc_code)); + g_free(loc_code); =20 if (drc_index) { _FDT(fdt_setprop_cell(fdt, offset, "ibm,my-drc-index", drc_index)); @@ -1297,13 +1315,13 @@ static void spapr_populate_pci_child_dt(PCIDevice *= dev, void *fdt, int offset, RESOURCE_CELLS_SIZE)); =20 if (msi_present(dev)) { - max_msi =3D msi_nr_vectors_allocated(dev); + uint32_t max_msi =3D msi_nr_vectors_allocated(dev); if (max_msi) { _FDT(fdt_setprop_cell(fdt, offset, "ibm,req#msi", max_msi)); } } if (msix_present(dev)) { - max_msix =3D dev->msix_entries_nr; + uint32_t max_msix =3D dev->msix_entries_nr; if (max_msix) { _FDT(fdt_setprop_cell(fdt, offset, "ibm,req#msi-x", max_msix)); } @@ -1319,33 +1337,6 @@ static void spapr_populate_pci_child_dt(PCIDevice *d= ev, void *fdt, int offset, } =20 spapr_phb_nvgpu_populate_pcidev_dt(dev, fdt, offset, sphb); -} - -/* create OF node for pci device and required OF DT properties */ -static int spapr_create_pci_child_dt(SpaprPhbState *phb, PCIDevice *dev, - void *fdt, int node_offset) -{ - int offset; - const gchar *basename; - gchar *nodename; - int slot =3D PCI_SLOT(dev->devfn); - int func =3D PCI_FUNC(dev->devfn); - uint32_t ccode =3D pci_default_read_config(dev, PCI_CLASS_PROG, 3); - - basename =3D dt_name_from_class((ccode >> 16) & 0xff, (ccode >> 8) & 0= xff, - ccode & 0xff); - - if (func !=3D 0) { - nodename =3D g_strdup_printf("%s@%x,%x", basename, slot, func); - } else { - nodename =3D g_strdup_printf("%s@%x", basename, slot); - } - - _FDT(offset =3D fdt_add_subnode(fdt, node_offset, nodename)); - - g_free(nodename); - - spapr_populate_pci_child_dt(dev, fdt, offset, phb); =20 return offset; } @@ -1393,7 +1384,7 @@ int spapr_pci_dt_populate(SpaprDrc *drc, SpaprMachine= State *spapr, SpaprPhbState *sphb =3D SPAPR_PCI_HOST_BRIDGE(plug_handler); PCIDevice *pdev =3D PCI_DEVICE(drc->dev); =20 - *fdt_start_offset =3D spapr_create_pci_child_dt(sphb, pdev, fdt, 0); + *fdt_start_offset =3D spapr_dt_pci_device(sphb, pdev, fdt, 0); return 0; } =20 @@ -2080,7 +2071,7 @@ static void spapr_populate_pci_devices_dt(PCIBus *bus= , PCIDevice *pdev, int offset; SpaprFdt s_fdt; =20 - offset =3D spapr_create_pci_child_dt(p->sphb, pdev, p->fdt, p->node_of= f); + offset =3D spapr_dt_pci_device(p->sphb, pdev, p->fdt, p->node_off); if (!offset) { error_report("Failed to create pci child device tree node"); return; --=20 2.21.0 From nobody Fri Apr 26 18:15:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1560319588; cv=none; d=zoho.com; s=zohoarc; b=RormaTffok0KB32g0TspDLbNTf6xkWoboWNzgXfaAv81wxgjlZcNyGahTKceXM4XIQl19JXWjowtbrTWdAHCQwcnqR8dWrsU48Lhb7TELnzpByxeKqYvDczU53P0jfhWxCy5G9P4I/Zd082fRi4wRD/fgKkaBhBR3dPq3eWFLIo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560319588; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=FDMVSAy5FNGSY3zoeHpdj5MoHdNJ7yR+uP3JfZiFeoY=; b=QZtwpIaVihLGjHdazFP1Va/DiYCU14AIe8IQpMPeZsCIWBe7v+I2Lae5r9K2SkiQLTstCsrbjv6K1/gaEu2vUcjNjyZV9rhY4xqqUlEmLM4Rp8X1vaMJE9Iajoa20k7ZCv6dEcxXMEZ05ItZcSV0fRq4TlFvQ90R0Ky5ytjgsN8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560319588764656.3602669021578; Tue, 11 Jun 2019 23:06:28 -0700 (PDT) Received: from localhost ([::1]:56892 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hawOt-0001NR-8r for importer@patchew.org; Wed, 12 Jun 2019 02:06:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58575) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1haw8o-0004Zp-P7 for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1haw8k-00072p-LQ for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:46 -0400 Received: from ozlabs.org ([203.11.71.1]:54437) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1haw8k-00070v-0m; Wed, 12 Jun 2019 01:49:42 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 45NwtR0HDnz9sND; Wed, 12 Jun 2019 15:49:34 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1560318575; bh=5mQj3sa0x70jnY5xmg5WskDu7xryaD4fDO6cG7edD8s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R0nKqTghPz6JQ8Eq2AKLQ8le+MAwhe+WZLTva9eRdKB0Envz/NRr6f0W6POMwaYmf DWoviui49qKpDFOvToSMqj41PItnsJUdJLozQlGBBuhaAaXE8xWIC1dP0cl3+GTxrz nGtI0maUxYwHD9JMBqJ319OrLjYTtnSrttgcTjKg= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 12 Jun 2019 15:49:21 +1000 Message-Id: <20190612054929.21136-6-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190612054929.21136-1-david@gibson.dropbear.id.au> References: <20190612054929.21136-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] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 05/13] spapr: Clean up dt creation for PCI buses X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, "Michael S . Tsirkin" , aik@ozlabs.ru, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Device nodes for PCI bridges (both host and P2P) describe both the bridge device itself and the bus hanging off it, handling of this is a bit of a mess. spapr_dt_pci_device() has a few things it only adds for non-bridges, but always adds #address-cells and #size-cells which should only appear for bridges. But the walking down the subordinate PCI bus is done in one of its callers spapr_populate_pci_devices_dt(). The PHB dt creation in spapr_populate_pci_dt() open codes some similar logic to the bridge case. This patch consolidates things in a bunch of ways: * Bus specific dt info is now created in spapr_dt_pci_bus() used for both P2P bridges and the host bridge. This includes walking subordinate devices * spapr_dt_pci_device() now calls spapr_dt_pci_bus() when called on a P2P bridge * We do detection of bridges with the is_bridge field of the device class, rather than checking PCI config space directly, for consistency with qemu's core PCI code. * Several things are renamed for brevity and clarity Signed-off-by: David Gibson Acked-by: Michael S. Tsirkin --- hw/ppc/spapr.c | 7 +- hw/ppc/spapr_pci.c | 140 +++++++++++++++++++----------------- include/hw/pci-host/spapr.h | 4 +- 3 files changed, 79 insertions(+), 72 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index e2b33e5890..44573adce7 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1309,8 +1309,7 @@ static void *spapr_build_fdt(SpaprMachineState *spapr) } =20 QLIST_FOREACH(phb, &spapr->phbs, list) { - ret =3D spapr_populate_pci_dt(phb, PHANDLE_INTC, fdt, - spapr->irq->nr_msis, NULL); + ret =3D spapr_dt_phb(phb, PHANDLE_INTC, fdt, spapr->irq->nr_msis, = NULL); if (ret < 0) { error_report("couldn't setup PCI devices in fdt"); exit(1); @@ -3917,8 +3916,8 @@ int spapr_phb_dt_populate(SpaprDrc *drc, SpaprMachine= State *spapr, return -1; } =20 - if (spapr_populate_pci_dt(sphb, intc_phandle, fdt, spapr->irq->nr_msis, - fdt_start_offset)) { + if (spapr_dt_phb(sphb, intc_phandle, fdt, spapr->irq->nr_msis, + fdt_start_offset)) { error_setg(errp, "unable to create FDT node for PHB %d", sphb->ind= ex); return -1; } diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 8e10fc6857..dc5e46e6d4 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1219,6 +1219,60 @@ static const char *dt_name_from_class(uint8_t class,= uint8_t subclass, static uint32_t spapr_phb_get_pci_drc_index(SpaprPhbState *phb, PCIDevice *pdev); =20 +typedef struct PciWalkFdt { + void *fdt; + int offset; + SpaprPhbState *sphb; + int err; +} PciWalkFdt; + +static int spapr_dt_pci_device(SpaprPhbState *sphb, PCIDevice *dev, + void *fdt, int parent_offset); + +static void spapr_dt_pci_device_cb(PCIBus *bus, PCIDevice *pdev, + void *opaque) +{ + PciWalkFdt *p =3D opaque; + int err; + + if (p->err) { + /* Something's already broken, don't keep going */ + return; + } + + err =3D spapr_dt_pci_device(p->sphb, pdev, p->fdt, p->offset); + if (err < 0) { + p->err =3D err; + } +} + +/* Augment PCI device node with bridge specific information */ +static int spapr_dt_pci_bus(SpaprPhbState *sphb, PCIBus *bus, + void *fdt, int offset) +{ + PciWalkFdt cbinfo =3D { + .fdt =3D fdt, + .offset =3D offset, + .sphb =3D sphb, + .err =3D 0, + }; + + _FDT(fdt_setprop_cell(fdt, offset, "#address-cells", + RESOURCE_CELLS_ADDRESS)); + _FDT(fdt_setprop_cell(fdt, offset, "#size-cells", + RESOURCE_CELLS_SIZE)); + + if (bus) { + pci_for_each_device_reverse(bus, pci_bus_num(bus), + spapr_dt_pci_device_cb, &cbinfo); + if (cbinfo.err) { + return cbinfo.err; + } + } + + return offset; +} + /* create OF node for pci device and required OF DT properties */ static int spapr_dt_pci_device(SpaprPhbState *sphb, PCIDevice *dev, void *fdt, int parent_offset) @@ -1228,10 +1282,9 @@ static int spapr_dt_pci_device(SpaprPhbState *sphb, = PCIDevice *dev, gchar *nodename; int slot =3D PCI_SLOT(dev->devfn); int func =3D PCI_FUNC(dev->devfn); + PCIDeviceClass *pc =3D PCI_DEVICE_GET_CLASS(dev); ResourceProps rp; uint32_t drc_index =3D spapr_phb_get_pci_drc_index(sphb, dev); - uint32_t header_type =3D pci_default_read_config(dev, PCI_HEADER_TYPE,= 1); - bool is_bridge =3D (header_type =3D=3D PCI_HEADER_TYPE_BRIDGE); uint32_t vendor_id =3D pci_default_read_config(dev, PCI_VENDOR_ID, 2); uint32_t device_id =3D pci_default_read_config(dev, PCI_DEVICE_ID, 2); uint32_t revision_id =3D pci_default_read_config(dev, PCI_REVISION_ID,= 1); @@ -1268,13 +1321,6 @@ static int spapr_dt_pci_device(SpaprPhbState *sphb, = PCIDevice *dev, _FDT(fdt_setprop_cell(fdt, offset, "interrupts", irq_pin)); } =20 - if (!is_bridge) { - uint32_t min_grant =3D pci_default_read_config(dev, PCI_MIN_GNT, 1= ); - uint32_t max_latency =3D pci_default_read_config(dev, PCI_MAX_LAT,= 1); - _FDT(fdt_setprop_cell(fdt, offset, "min-grant", min_grant)); - _FDT(fdt_setprop_cell(fdt, offset, "max-latency", max_latency)); - } - if (subsystem_id) { _FDT(fdt_setprop_cell(fdt, offset, "subsystem-id", subsystem_id)); } @@ -1309,11 +1355,6 @@ static int spapr_dt_pci_device(SpaprPhbState *sphb, = PCIDevice *dev, _FDT(fdt_setprop_cell(fdt, offset, "ibm,my-drc-index", drc_index)); } =20 - _FDT(fdt_setprop_cell(fdt, offset, "#address-cells", - RESOURCE_CELLS_ADDRESS)); - _FDT(fdt_setprop_cell(fdt, offset, "#size-cells", - RESOURCE_CELLS_SIZE)); - if (msi_present(dev)) { uint32_t max_msi =3D msi_nr_vectors_allocated(dev); if (max_msi) { @@ -1338,7 +1379,18 @@ static int spapr_dt_pci_device(SpaprPhbState *sphb, = PCIDevice *dev, =20 spapr_phb_nvgpu_populate_pcidev_dt(dev, fdt, offset, sphb); =20 - return offset; + if (!pc->is_bridge) { + /* Properties only for non-bridges */ + uint32_t min_grant =3D pci_default_read_config(dev, PCI_MIN_GNT, 1= ); + uint32_t max_latency =3D pci_default_read_config(dev, PCI_MAX_LAT,= 1); + _FDT(fdt_setprop_cell(fdt, offset, "min-grant", min_grant)); + _FDT(fdt_setprop_cell(fdt, offset, "max-latency", max_latency)); + return offset; + } else { + PCIBus *sec_bus =3D pci_bridge_get_sec_bus(PCI_BRIDGE(dev)); + + return spapr_dt_pci_bus(sphb, sec_bus, fdt, offset); + } } =20 /* Callback to be called during DRC release. */ @@ -2057,44 +2109,6 @@ static const TypeInfo spapr_phb_info =3D { } }; =20 -typedef struct SpaprFdt { - void *fdt; - int node_off; - SpaprPhbState *sphb; -} SpaprFdt; - -static void spapr_populate_pci_devices_dt(PCIBus *bus, PCIDevice *pdev, - void *opaque) -{ - PCIBus *sec_bus; - SpaprFdt *p =3D opaque; - int offset; - SpaprFdt s_fdt; - - offset =3D spapr_dt_pci_device(p->sphb, pdev, p->fdt, p->node_off); - if (!offset) { - error_report("Failed to create pci child device tree node"); - return; - } - - if ((pci_default_read_config(pdev, PCI_HEADER_TYPE, 1) !=3D - PCI_HEADER_TYPE_BRIDGE)) { - return; - } - - sec_bus =3D pci_bridge_get_sec_bus(PCI_BRIDGE(pdev)); - if (!sec_bus) { - return; - } - - s_fdt.fdt =3D p->fdt; - s_fdt.node_off =3D offset; - s_fdt.sphb =3D p->sphb; - pci_for_each_device_reverse(sec_bus, pci_bus_num(sec_bus), - spapr_populate_pci_devices_dt, - &s_fdt); -} - static void spapr_phb_pci_enumerate_bridge(PCIBus *bus, PCIDevice *pdev, void *opaque) { @@ -2132,8 +2146,8 @@ static void spapr_phb_pci_enumerate(SpaprPhbState *ph= b) =20 } =20 -int spapr_populate_pci_dt(SpaprPhbState *phb, uint32_t intc_phandle, void = *fdt, - uint32_t nr_msis, int *node_offset) +int spapr_dt_phb(SpaprPhbState *phb, uint32_t intc_phandle, void *fdt, + uint32_t nr_msis, int *node_offset) { int bus_off, i, j, ret; uint32_t bus_range[] =3D { cpu_to_be32(0), cpu_to_be32(0xff) }; @@ -2180,8 +2194,6 @@ int spapr_populate_pci_dt(SpaprPhbState *phb, uint32_= t intc_phandle, void *fdt, cpu_to_be32(0x0), cpu_to_be32(phb->numa_node)}; SpaprTceTable *tcet; - PCIBus *bus =3D PCI_HOST_BRIDGE(phb)->bus; - SpaprFdt s_fdt; SpaprDrc *drc; Error *errp =3D NULL; =20 @@ -2194,8 +2206,6 @@ int spapr_populate_pci_dt(SpaprPhbState *phb, uint32_= t intc_phandle, void *fdt, /* Write PHB properties */ _FDT(fdt_setprop_string(fdt, bus_off, "device_type", "pci")); _FDT(fdt_setprop_string(fdt, bus_off, "compatible", "IBM,Logical_PHB")= ); - _FDT(fdt_setprop_cell(fdt, bus_off, "#address-cells", 0x3)); - _FDT(fdt_setprop_cell(fdt, bus_off, "#size-cells", 0x2)); _FDT(fdt_setprop_cell(fdt, bus_off, "#interrupt-cells", 0x1)); _FDT(fdt_setprop(fdt, bus_off, "used-by-rtas", NULL, 0)); _FDT(fdt_setprop(fdt, bus_off, "bus-range", &bus_range, sizeof(bus_ran= ge))); @@ -2260,13 +2270,11 @@ int spapr_populate_pci_dt(SpaprPhbState *phb, uint3= 2_t intc_phandle, void *fdt, spapr_phb_pci_enumerate(phb); _FDT(fdt_setprop_cell(fdt, bus_off, "qemu,phb-enumerated", 0x1)); =20 - /* Populate tree nodes with PCI devices attached */ - s_fdt.fdt =3D fdt; - s_fdt.node_off =3D bus_off; - s_fdt.sphb =3D phb; - pci_for_each_device_reverse(bus, pci_bus_num(bus), - spapr_populate_pci_devices_dt, - &s_fdt); + /* Walk the bridge and subordinate buses */ + ret =3D spapr_dt_pci_bus(phb, PCI_HOST_BRIDGE(phb)->bus, fdt, bus_off); + if (ret < 0) { + return ret; + } =20 ret =3D spapr_drc_populate_dt(fdt, bus_off, OBJECT(phb), SPAPR_DR_CONNECTOR_TYPE_PCI); diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h index 53519c835e..1b61162f91 100644 --- a/include/hw/pci-host/spapr.h +++ b/include/hw/pci-host/spapr.h @@ -131,8 +131,8 @@ static inline qemu_irq spapr_phb_lsi_qirq(struct SpaprP= hbState *phb, int pin) return spapr_qirq(spapr, phb->lsi_table[pin].irq); } =20 -int spapr_populate_pci_dt(SpaprPhbState *phb, uint32_t intc_phandle, void = *fdt, - uint32_t nr_msis, int *node_offset); +int spapr_dt_phb(SpaprPhbState *phb, uint32_t intc_phandle, void *fdt, + uint32_t nr_msis, int *node_offset); =20 void spapr_pci_rtas_init(void); =20 --=20 2.21.0 From nobody Fri Apr 26 18:15:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1560319645; cv=none; d=zoho.com; s=zohoarc; b=Utxv5GeKYRwqHlnGs+pb9QCekWIEMbzg3MUas3mHuLzUzrXJw0nabLAuzglKYhF+R+QN9V6uD8TeqV3iu2O1IYjEyDnTVm5iksIUbfZ880wvs48B/WA1EFmELZ19m0Di1VZK2Y1GofWU2nTdi3KsV8bkw+v+W+TMLsXaYxrMkx8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560319645; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=pgD0hftxscPpconHVj4825/iICJWBoHFEMRUYXaIfGw=; b=fhheSCw5vvVPBm21L/kaVgkT9Gy38cA+2qQIlLBp49ztMSSPbppY0+Ax9s59q1vdq+mAk8XiR2kIOGEUNTQqipW7HR/CPWl+xeyIvTFfD6y1gmVw9Zof6klV3ZHmJkXrWi7bhWJp20TcKA1zEGg0KViwiDOCxgfTkImLy/PkPws= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560319645206617.5848634434388; Tue, 11 Jun 2019 23:07:25 -0700 (PDT) Received: from localhost ([::1]:56896 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hawPq-0002WV-8r for importer@patchew.org; Wed, 12 Jun 2019 02:07:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58534) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1haw8n-0004YE-LS for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1haw8l-00073c-91 for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:45 -0400 Received: from bilbo.ozlabs.org ([2401:3900:2:1::2]:60001 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1haw8k-00071O-I1; Wed, 12 Jun 2019 01:49:43 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 45NwtR4sXfz9sNt; Wed, 12 Jun 2019 15:49:34 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1560318575; bh=ZzXHpk4SPL5Xit/JDm8FZtI1PKJAeduhvqwVZi7MhI0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YzSx0EDTPyTgvLuyGJpHEwTLMAQ5cm3QU1H6RWNv9Wy+Aj8wSNnUisH195ou12BeS 6dzJHIqSdqVeleZ6r0stvWPgpuPEZpL+cq51mN4A9mS0rsgV7EdNpxHQXHwqyL771h 2cAT5yGdEvlzdwCWq0DqcgWNChs8gaXDKOytVcYM= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 12 Jun 2019 15:49:22 +1000 Message-Id: <20190612054929.21136-7-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190612054929.21136-1-david@gibson.dropbear.id.au> References: <20190612054929.21136-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 06/13] spapr: Clean up spapr_drc_populate_dt() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, "Michael S . Tsirkin" , aik@ozlabs.ru, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This makes some minor cleanups to spapr_drc_populate_dt(), renaming it to the shorter and more idiomatic spapr_dt_drc() along the way. Signed-off-by: David Gibson Reviewed-by: Greg Kurz Acked-by: Michael S. Tsirkin --- hw/ppc/spapr.c | 7 +++---- hw/ppc/spapr_drc.c | 13 ++++++------- hw/ppc/spapr_pci.c | 3 +-- include/hw/ppc/spapr_drc.h | 3 +-- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 44573adce7..507fd50dd5 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1320,13 +1320,12 @@ static void *spapr_build_fdt(SpaprMachineState *spa= pr) spapr_populate_cpus_dt_node(fdt, spapr); =20 if (smc->dr_lmb_enabled) { - _FDT(spapr_drc_populate_dt(fdt, 0, NULL, SPAPR_DR_CONNECTOR_TYPE_L= MB)); + _FDT(spapr_dt_drc(fdt, 0, NULL, SPAPR_DR_CONNECTOR_TYPE_LMB)); } =20 if (mc->has_hotpluggable_cpus) { int offset =3D fdt_path_offset(fdt, "/cpus"); - ret =3D spapr_drc_populate_dt(fdt, offset, NULL, - SPAPR_DR_CONNECTOR_TYPE_CPU); + ret =3D spapr_dt_drc(fdt, offset, NULL, SPAPR_DR_CONNECTOR_TYPE_CP= U); if (ret < 0) { error_report("Couldn't set up CPU DR device tree properties"); exit(1); @@ -1363,7 +1362,7 @@ static void *spapr_build_fdt(SpaprMachineState *spapr) } =20 if (smc->dr_phb_enabled) { - ret =3D spapr_drc_populate_dt(fdt, 0, NULL, SPAPR_DR_CONNECTOR_TYP= E_PHB); + ret =3D spapr_dt_drc(fdt, 0, NULL, SPAPR_DR_CONNECTOR_TYPE_PHB); if (ret < 0) { error_report("Couldn't set up PHB DR device tree properties"); exit(1); diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 597f236b9c..bacadfcac5 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -781,7 +781,7 @@ SpaprDrc *spapr_drc_by_id(const char *type, uint32_t id) } =20 /** - * spapr_drc_populate_dt + * spapr_dt_drc * * @fdt: libfdt device tree * @path: path in the DT to generate properties @@ -794,8 +794,7 @@ SpaprDrc *spapr_drc_by_id(const char *type, uint32_t id) * * as documented in PAPR+ v2.1, 13.5.2 */ -int spapr_drc_populate_dt(void *fdt, int fdt_offset, Object *owner, - uint32_t drc_type_mask) +int spapr_dt_drc(void *fdt, int offset, Object *owner, uint32_t drc_type_m= ask) { Object *root_container; ObjectProperty *prop; @@ -873,7 +872,7 @@ int spapr_drc_populate_dt(void *fdt, int fdt_offset, Ob= ject *owner, *(uint32_t *)drc_names->str =3D cpu_to_be32(drc_count); *(uint32_t *)drc_types->str =3D cpu_to_be32(drc_count); =20 - ret =3D fdt_setprop(fdt, fdt_offset, "ibm,drc-indexes", + ret =3D fdt_setprop(fdt, offset, "ibm,drc-indexes", drc_indexes->data, drc_indexes->len * sizeof(uint32_t)); if (ret) { @@ -881,7 +880,7 @@ int spapr_drc_populate_dt(void *fdt, int fdt_offset, Ob= ject *owner, goto out; } =20 - ret =3D fdt_setprop(fdt, fdt_offset, "ibm,drc-power-domains", + ret =3D fdt_setprop(fdt, offset, "ibm,drc-power-domains", drc_power_domains->data, drc_power_domains->len * sizeof(uint32_t)); if (ret) { @@ -889,14 +888,14 @@ int spapr_drc_populate_dt(void *fdt, int fdt_offset, = Object *owner, goto out; } =20 - ret =3D fdt_setprop(fdt, fdt_offset, "ibm,drc-names", + ret =3D fdt_setprop(fdt, offset, "ibm,drc-names", drc_names->str, drc_names->len); if (ret) { error_report("Couldn't finalize ibm,drc-names property"); goto out; } =20 - ret =3D fdt_setprop(fdt, fdt_offset, "ibm,drc-types", + ret =3D fdt_setprop(fdt, offset, "ibm,drc-types", drc_types->str, drc_types->len); if (ret) { error_report("Couldn't finalize ibm,drc-types property"); diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index dc5e46e6d4..546ca29bb7 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -2276,8 +2276,7 @@ int spapr_dt_phb(SpaprPhbState *phb, uint32_t intc_ph= andle, void *fdt, return ret; } =20 - ret =3D spapr_drc_populate_dt(fdt, bus_off, OBJECT(phb), - SPAPR_DR_CONNECTOR_TYPE_PCI); + ret =3D spapr_dt_drc(fdt, bus_off, OBJECT(phb), SPAPR_DR_CONNECTOR_TYP= E_PCI); if (ret) { return ret; } diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h index fad0a887f9..c2c543a591 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -266,8 +266,7 @@ SpaprDrc *spapr_dr_connector_new(Object *owner, const c= har *type, uint32_t id); SpaprDrc *spapr_drc_by_index(uint32_t index); SpaprDrc *spapr_drc_by_id(const char *type, uint32_t id); -int spapr_drc_populate_dt(void *fdt, int fdt_offset, Object *owner, - uint32_t drc_type_mask); +int spapr_dt_drc(void *fdt, int offset, Object *owner, uint32_t drc_type_m= ask); =20 void spapr_drc_attach(SpaprDrc *drc, DeviceState *d, Error **errp); void spapr_drc_detach(SpaprDrc *drc); --=20 2.21.0 From nobody Fri Apr 26 18:15:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1560318890; cv=none; d=zoho.com; s=zohoarc; b=T8QfIym+rCafG6GHdTV2qczwTOnUxkb6tohTJZH961HP3QapZQZxJiI+r9PaiVfbNRwst9QQcfxjKcD7w6u9zmVCRT5OG+uEkLI8cHIhwhoFSJgL8BA0bBJBoasOS4JDTBv2YIf5g+sxjOmXqC3KCtdteXwJpoqvKweHiiY0QmA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560318890; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=jexCQQp8RzxU8yoY0PFpAPxMkmjgqrgQ4f9RgNJselI=; b=XcdmIxEjXiXlvlgS4RbKZcWwyRBxa3XW93izndCDLei9aMpPAKBlTkUiwzLEtNljhVW72t3PlOUeCy1H9TjJEOzduxjVok5a2ze1zh9HzPtK7MZKrC1GK4Vg7lce8mha0i5s1ZZefN31s29Bs5ZwKnZBpPMcj0rjJv4JKmYEhEA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560318890893515.642438979693; Tue, 11 Jun 2019 22:54:50 -0700 (PDT) Received: from localhost ([::1]:56838 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hawDh-00026d-SY for importer@patchew.org; Wed, 12 Jun 2019 01:54:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58546) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1haw8n-0004YL-T4 for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1haw8k-000736-RB for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:45 -0400 Received: from ozlabs.org ([203.11.71.1]:56839) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1haw8k-000715-5N; Wed, 12 Jun 2019 01:49:42 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 45NwtR2rPXz9sNw; Wed, 12 Jun 2019 15:49:34 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1560318575; bh=6hH2cJes8qPN391DBNWvg7VBxZkgMDO5ENeluNAgIRU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eGA3Ljx3g+3Z/EySYpWlmNmW+PGEgDwmHV8h3niIKiynIFGy+pdOQI+A50tQRIhLC sYXPSS/nf4JUapWW1omcJSS/V6chuBBxu6StKXuY8SlJXmTtHlSTabDxCFiGgx5zMc nvZe3k9BEBQuHIOX2iRY4jZaBvZ8qKaA5aEc3QFc= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 12 Jun 2019 15:49:23 +1000 Message-Id: <20190612054929.21136-8-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190612054929.21136-1-david@gibson.dropbear.id.au> References: <20190612054929.21136-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] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 07/13] spapr: Clean up DRC index construction X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, "Michael S . Tsirkin" , aik@ozlabs.ru, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" spapr_pci.c currently has several confusingly similarly named functions for various conversions between representations of DRCs. Make things clearer by renaming things in a more consistent XXX_from_YYY() manner and remove some called-only-once variants in favour of open coding. While we're at it, move this code together in the file to avoid some extra forward references, and split out construction and removal of DRCs for the host bridge into helper functions. Signed-off-by: David Gibson Acked-by: Michael S. Tsirkin --- hw/ppc/spapr_pci.c | 124 +++++++++++++++++++++++++-------------------- 1 file changed, 68 insertions(+), 56 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 546ca29bb7..7352028628 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1216,8 +1216,60 @@ static const char *dt_name_from_class(uint8_t class,= uint8_t subclass, return name; } =20 -static uint32_t spapr_phb_get_pci_drc_index(SpaprPhbState *phb, - PCIDevice *pdev); +/* + * DRC helper functions + */ + +static uint32_t drc_id_from_devfn(SpaprPhbState *phb, + uint32_t busnr, + int32_t devfn) +{ + return (phb->index << 16) | (busnr << 8) | devfn; +} + +static SpaprDrc *drc_from_devfn(SpaprPhbState *phb, + uint32_t busnr, int32_t devfn) +{ + return spapr_drc_by_id(TYPE_SPAPR_DRC_PCI, + drc_id_from_devfn(phb, busnr, devfn)); +} + +static SpaprDrc *drc_from_dev(SpaprPhbState *phb, PCIDevice *dev) +{ + uint32_t busnr =3D pci_bus_num(PCI_BUS(qdev_get_parent_bus(DEVICE(dev)= ))); + return drc_from_devfn(phb, busnr, dev->devfn); +} + +static void add_drcs(SpaprPhbState *phb) +{ + int i; + + if (!phb->dr_enabled) { + return; + } + + for (i =3D 0; i < PCI_SLOT_MAX * PCI_FUNC_MAX; i++) { + spapr_dr_connector_new(OBJECT(phb), TYPE_SPAPR_DRC_PCI, + drc_id_from_devfn(phb, 0, i)); + } +} + +static void remove_drcs(SpaprPhbState *phb) +{ + int i; + + if (!phb->dr_enabled) { + return; + } + + for (i =3D PCI_SLOT_MAX * PCI_FUNC_MAX - 1; i >=3D 0; i--) { + SpaprDrc *drc =3D drc_from_devfn(phb, 0, i); + + if (drc) { + object_unparent(OBJECT(drc)); + } + } +} =20 typedef struct PciWalkFdt { void *fdt; @@ -1284,7 +1336,7 @@ static int spapr_dt_pci_device(SpaprPhbState *sphb, P= CIDevice *dev, int func =3D PCI_FUNC(dev->devfn); PCIDeviceClass *pc =3D PCI_DEVICE_GET_CLASS(dev); ResourceProps rp; - uint32_t drc_index =3D spapr_phb_get_pci_drc_index(sphb, dev); + SpaprDrc *drc =3D drc_from_dev(sphb, dev); uint32_t vendor_id =3D pci_default_read_config(dev, PCI_VENDOR_ID, 2); uint32_t device_id =3D pci_default_read_config(dev, PCI_DEVICE_ID, 2); uint32_t revision_id =3D pci_default_read_config(dev, PCI_REVISION_ID,= 1); @@ -1351,8 +1403,9 @@ static int spapr_dt_pci_device(SpaprPhbState *sphb, P= CIDevice *dev, _FDT(fdt_setprop_string(fdt, offset, "ibm,loc-code", loc_code)); g_free(loc_code); =20 - if (drc_index) { - _FDT(fdt_setprop_cell(fdt, offset, "ibm,my-drc-index", drc_index)); + if (drc) { + _FDT(fdt_setprop_cell(fdt, offset, "ibm,my-drc-index", + spapr_drc_index(drc))); } =20 if (msi_present(dev)) { @@ -1402,33 +1455,6 @@ void spapr_phb_remove_pci_device_cb(DeviceState *dev) object_unparent(OBJECT(dev)); } =20 -static SpaprDrc *spapr_phb_get_pci_func_drc(SpaprPhbState *phb, - uint32_t busnr, - int32_t devfn) -{ - return spapr_drc_by_id(TYPE_SPAPR_DRC_PCI, - (phb->index << 16) | (busnr << 8) | devfn); -} - -static SpaprDrc *spapr_phb_get_pci_drc(SpaprPhbState *phb, - PCIDevice *pdev) -{ - uint32_t busnr =3D pci_bus_num(PCI_BUS(qdev_get_parent_bus(DEVICE(pdev= )))); - return spapr_phb_get_pci_func_drc(phb, busnr, pdev->devfn); -} - -static uint32_t spapr_phb_get_pci_drc_index(SpaprPhbState *phb, - PCIDevice *pdev) -{ - SpaprDrc *drc =3D spapr_phb_get_pci_drc(phb, pdev); - - if (!drc) { - return 0; - } - - return spapr_drc_index(drc); -} - int spapr_pci_dt_populate(SpaprDrc *drc, SpaprMachineState *spapr, void *fdt, int *fdt_start_offset, Error **errp) { @@ -1445,7 +1471,7 @@ static void spapr_pci_plug(HotplugHandler *plug_handl= er, { SpaprPhbState *phb =3D SPAPR_PCI_HOST_BRIDGE(DEVICE(plug_handler)); PCIDevice *pdev =3D PCI_DEVICE(plugged_dev); - SpaprDrc *drc =3D spapr_phb_get_pci_drc(phb, pdev); + SpaprDrc *drc =3D drc_from_dev(phb, pdev); Error *local_err =3D NULL; PCIBus *bus =3D PCI_BUS(qdev_get_parent_bus(DEVICE(pdev))); uint32_t slotnr =3D PCI_SLOT(pdev->devfn); @@ -1496,8 +1522,8 @@ static void spapr_pci_plug(HotplugHandler *plug_handl= er, SpaprDrcClass *func_drck; SpaprDREntitySense state; =20 - func_drc =3D spapr_phb_get_pci_func_drc(phb, pci_bus_num(bus), - PCI_DEVFN(slotnr, i)); + func_drc =3D drc_from_devfn(phb, pci_bus_num(bus), + PCI_DEVFN(slotnr, i)); func_drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(func_drc); state =3D func_drck->dr_entity_sense(func_drc); =20 @@ -1533,7 +1559,7 @@ static void spapr_pci_unplug_request(HotplugHandler *= plug_handler, { SpaprPhbState *phb =3D SPAPR_PCI_HOST_BRIDGE(DEVICE(plug_handler)); PCIDevice *pdev =3D PCI_DEVICE(plugged_dev); - SpaprDrc *drc =3D spapr_phb_get_pci_drc(phb, pdev); + SpaprDrc *drc =3D drc_from_dev(phb, pdev); =20 if (!phb->dr_enabled) { error_setg(errp, QERR_BUS_NO_HOTPLUG, @@ -1555,8 +1581,8 @@ static void spapr_pci_unplug_request(HotplugHandler *= plug_handler, /* ensure any other present functions are pending unplug */ if (PCI_FUNC(pdev->devfn) =3D=3D 0) { for (i =3D 1; i < 8; i++) { - func_drc =3D spapr_phb_get_pci_func_drc(phb, pci_bus_num(b= us), - PCI_DEVFN(slotnr, i)= ); + func_drc =3D drc_from_devfn(phb, pci_bus_num(bus), + PCI_DEVFN(slotnr, i)); func_drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(func_drc); state =3D func_drck->dr_entity_sense(func_drc); if (state =3D=3D SPAPR_DR_ENTITY_SENSE_PRESENT @@ -1577,8 +1603,8 @@ static void spapr_pci_unplug_request(HotplugHandler *= plug_handler, */ if (PCI_FUNC(pdev->devfn) =3D=3D 0) { for (i =3D 7; i >=3D 0; i--) { - func_drc =3D spapr_phb_get_pci_func_drc(phb, pci_bus_num(b= us), - PCI_DEVFN(slotnr, i)= ); + func_drc =3D drc_from_devfn(phb, pci_bus_num(bus), + PCI_DEVFN(slotnr, i)); func_drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(func_drc); state =3D func_drck->dr_entity_sense(func_drc); if (state =3D=3D SPAPR_DR_ENTITY_SENSE_PRESENT) { @@ -1626,16 +1652,7 @@ static void spapr_phb_unrealize(DeviceState *dev, Er= ror **errp) } } =20 - if (sphb->dr_enabled) { - for (i =3D PCI_SLOT_MAX * 8 - 1; i >=3D 0; i--) { - SpaprDrc *drc =3D spapr_drc_by_id(TYPE_SPAPR_DRC_PCI, - (sphb->index << 16) | = i); - - if (drc) { - object_unparent(OBJECT(drc)); - } - } - } + remove_drcs(sphb); =20 for (i =3D PCI_NUM_PINS - 1; i >=3D 0; i--) { if (sphb->lsi_table[i].irq) { @@ -1855,12 +1872,7 @@ static void spapr_phb_realize(DeviceState *dev, Erro= r **errp) } =20 /* allocate connectors for child PCI devices */ - if (sphb->dr_enabled) { - for (i =3D 0; i < PCI_SLOT_MAX * 8; i++) { - spapr_dr_connector_new(OBJECT(phb), TYPE_SPAPR_DRC_PCI, - (sphb->index << 16) | i); - } - } + add_drcs(sphb); =20 /* DMA setup */ for (i =3D 0; i < windows_supported; ++i) { --=20 2.21.0 From nobody Fri Apr 26 18:15:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1560318943; cv=none; d=zoho.com; s=zohoarc; b=XZ0a9fq5ro99bY7F0CvfPXWLAVprHNU3VnYZT+C+JTqodkMES7JxthdZmwnlwK3qoshQ8x4VGlOr3882uuA39+YBUjf6I8anvG/4AC14SJuXkOE8RcLMK3ylzg25AUSt0n5/0arTRU7Vyb7/nhaJkr1xJ37/+h4LEpRaxOv32qw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560318943; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=kbJwL/Et9YC5cBJ03697jtekQfI8qmx0upU8Nd8htVM=; b=nrNkVAX58mNKZb6klTZDkzOinaXRFg8cROlk7MaxqS0EiAdl5nRNW4HGVUjeG7uzcZ+daL1tDEHW6EwE0IscyoSfjQHijtzK+VAlbQUATOdraPeH7aPaY678VBL/OYLGWtzYdJZl6jcIchptMHerjeIagP4Op/7txjGJrgk/qM0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560318943827847.2390092767749; Tue, 11 Jun 2019 22:55:43 -0700 (PDT) Received: from localhost ([::1]:56840 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hawEW-0002pL-Er for importer@patchew.org; Wed, 12 Jun 2019 01:55:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58502) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1haw8n-0004XM-4N for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1haw8k-00073D-SS for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:44 -0400 Received: from ozlabs.org ([203.11.71.1]:60309) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1haw8k-000717-7O; Wed, 12 Jun 2019 01:49:42 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 45NwtR4Cf9z9sPC; Wed, 12 Jun 2019 15:49:34 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1560318575; bh=Eb6H0LTkCVq9ttPuBWVZZEAnmYMnVgLWdK92LYFslA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e1LtqAbaVQtyJaIiHh4l4yhQDSj6KKWxZlf/cwrYEaxOgy4gHi4nAbQt4IQ5wNiY3 RsK0QyXPQVm1YR2f7Fj8wjb6VGoutROPtVXndj+ShxcrTz1LNXYtX3RbWVDFYD1yt8 rrdn4tLB3//gqN0NiSCMdJxrVavpkE+u5quI3HQ0= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 12 Jun 2019 15:49:24 +1000 Message-Id: <20190612054929.21136-9-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190612054929.21136-1-david@gibson.dropbear.id.au> References: <20190612054929.21136-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] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 08/13] spapr: Don't use bus number for building DRC ids X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, "Michael S . Tsirkin" , aik@ozlabs.ru, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" DRC ids are more or less arbitrary, as long as they're consistent. For PCI, we notionally build them from the phb's index along with PCI bus number, slot and function number. Using bus number is broken, however, because it can change if the guest re-enumerates the PCI topology for whatever reason (e.g. due to hotplug of a bridge, which we don't support yet but want to). Fortunately, there's an alternative. Bridges are required to have a unique non-zero "chassis number" that we can use instead. Adjust the code to use that instead. This looks like it would introduce a guest visible breaking change, but in fact it does not because we don't yet ever use non-zero bus numbers. Both chassis and bus number are always 0 for the root bus, so there's no change for the existing cases. Signed-off-by: David Gibson Acked-by: Michael S. Tsirkin --- hw/ppc/spapr_pci.c | 54 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 7352028628..9d99bc0b4c 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1221,23 +1221,40 @@ static const char *dt_name_from_class(uint8_t class= , uint8_t subclass, */ =20 static uint32_t drc_id_from_devfn(SpaprPhbState *phb, - uint32_t busnr, - int32_t devfn) + uint8_t chassis, int32_t devfn) { - return (phb->index << 16) | (busnr << 8) | devfn; + return (phb->index << 16) | (chassis << 8) | devfn; } =20 static SpaprDrc *drc_from_devfn(SpaprPhbState *phb, - uint32_t busnr, int32_t devfn) + uint8_t chassis, int32_t devfn) { return spapr_drc_by_id(TYPE_SPAPR_DRC_PCI, - drc_id_from_devfn(phb, busnr, devfn)); + drc_id_from_devfn(phb, chassis, devfn)); +} + +static uint8_t chassis_from_bus(PCIBus *bus, Error **errp) +{ + if (pci_bus_is_root(bus)) { + return 0; + } else { + PCIDevice *bridge =3D pci_bridge_get_device(bus); + + return object_property_get_uint(OBJECT(bridge), "chassis_nr", errp= ); + } } =20 static SpaprDrc *drc_from_dev(SpaprPhbState *phb, PCIDevice *dev) { - uint32_t busnr =3D pci_bus_num(PCI_BUS(qdev_get_parent_bus(DEVICE(dev)= ))); - return drc_from_devfn(phb, busnr, dev->devfn); + Error *local_err =3D NULL; + uint8_t chassis =3D chassis_from_bus(pci_get_bus(dev), &local_err); + + if (local_err) { + error_report_err(local_err); + return NULL; + } + + return drc_from_devfn(phb, chassis, dev->devfn); } =20 static void add_drcs(SpaprPhbState *phb) @@ -1516,14 +1533,19 @@ static void spapr_pci_plug(HotplugHandler *plug_han= dler, spapr_drc_reset(drc); } else if (PCI_FUNC(pdev->devfn) =3D=3D 0) { int i; + uint8_t chassis =3D chassis_from_bus(pci_get_bus(pdev), &local_err= ); + + if (local_err) { + error_propagate(errp, local_err); + return; + } =20 for (i =3D 0; i < 8; i++) { SpaprDrc *func_drc; SpaprDrcClass *func_drck; SpaprDREntitySense state; =20 - func_drc =3D drc_from_devfn(phb, pci_bus_num(bus), - PCI_DEVFN(slotnr, i)); + func_drc =3D drc_from_devfn(phb, chassis, PCI_DEVFN(slotnr, i)= ); func_drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(func_drc); state =3D func_drck->dr_entity_sense(func_drc); =20 @@ -1571,18 +1593,23 @@ static void spapr_pci_unplug_request(HotplugHandler= *plug_handler, g_assert(drc->dev =3D=3D plugged_dev); =20 if (!spapr_drc_unplug_requested(drc)) { - PCIBus *bus =3D PCI_BUS(qdev_get_parent_bus(DEVICE(pdev))); uint32_t slotnr =3D PCI_SLOT(pdev->devfn); SpaprDrc *func_drc; SpaprDrcClass *func_drck; SpaprDREntitySense state; int i; + Error *local_err =3D NULL; + uint8_t chassis =3D chassis_from_bus(pci_get_bus(pdev), &local_err= ); + + if (local_err) { + error_propagate(errp, local_err); + return; + } =20 /* ensure any other present functions are pending unplug */ if (PCI_FUNC(pdev->devfn) =3D=3D 0) { for (i =3D 1; i < 8; i++) { - func_drc =3D drc_from_devfn(phb, pci_bus_num(bus), - PCI_DEVFN(slotnr, i)); + func_drc =3D drc_from_devfn(phb, chassis, PCI_DEVFN(slotnr= , i)); func_drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(func_drc); state =3D func_drck->dr_entity_sense(func_drc); if (state =3D=3D SPAPR_DR_ENTITY_SENSE_PRESENT @@ -1603,8 +1630,7 @@ static void spapr_pci_unplug_request(HotplugHandler *= plug_handler, */ if (PCI_FUNC(pdev->devfn) =3D=3D 0) { for (i =3D 7; i >=3D 0; i--) { - func_drc =3D drc_from_devfn(phb, pci_bus_num(bus), - PCI_DEVFN(slotnr, i)); + func_drc =3D drc_from_devfn(phb, chassis, PCI_DEVFN(slotnr= , i)); func_drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(func_drc); state =3D func_drck->dr_entity_sense(func_drc); if (state =3D=3D SPAPR_DR_ENTITY_SENSE_PRESENT) { --=20 2.21.0 From nobody Fri Apr 26 18:15:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1560318889; cv=none; d=zoho.com; s=zohoarc; b=jVLeSBD1KQub8gisbW3yi6WyFlxmuA7SuTb051FV9yjbH7DgsHSuzcOg4BCFIlIj0c40uioNPXbJH39jzTVGrxsC6gzD9aKcXsW6rgUpzQvd1rjEHBZpq8xb8G4KKDs6UkY9S6ckSHGl3/SF86rXJgswfgwM13XSgmmLQxSyWOc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560318889; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=sViPYoQ5PiG9kRkEIkY0uffco6+oD7s+FCOfRnBon1Y=; b=L2d2IYq5KU5CiaIKTfa0eJiOzRmGsTAhgljEJzFmFbjTmybFlSsJoNmA0dcO/gWUS/bedTXghnU8dOG6gPPHe7oFACA9YgvBXyObpBocCmW0KyZEGQGszCkro5qaOFv0ygZKWyMKiPCNE6JL6aQ16kjs7IL6XexZvrIric0zUx0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560318889369937.2703036772533; Tue, 11 Jun 2019 22:54:49 -0700 (PDT) Received: from localhost ([::1]:56836 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hawDg-00021u-Dc for importer@patchew.org; Wed, 12 Jun 2019 01:54:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58474) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1haw8m-0004Ux-8q for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1haw8k-00073L-UW for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:44 -0400 Received: from bilbo.ozlabs.org ([2401:3900:2:1::2]:34235 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1haw8k-00071A-GK; Wed, 12 Jun 2019 01:49:42 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 45NwtR2Dcxz9sPG; Wed, 12 Jun 2019 15:49:35 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1560318575; bh=Dc4e87KbcUk5ty+IGSWNE2GcGV1SyAd7CLeN6PnTLas=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G55+4eoy8K+fVQhB3IrHB3OnJWCbU/UZWR2e4HQ1B2BEx58apc/+0/Vc6uNYVAbkq ck5B+WKz053gmvgvvh7ZxLVe/ISCQEVnhAmmJpXKca3wW3GmS4qsSDHn74R7ybXbK3 n2aYgHV86Y4eSUlaHypXvoBJKM/zCRV0Ld6B0m+4= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 12 Jun 2019 15:49:25 +1000 Message-Id: <20190612054929.21136-10-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190612054929.21136-1-david@gibson.dropbear.id.au> References: <20190612054929.21136-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 09/13] spapr: Direct all PCI hotplug to host bridge, rather than P2P bridge X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, "Michael S . Tsirkin" , aik@ozlabs.ru, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" A P2P bridge will attempt to handle the hotplug with SHPC, which doesn't work in the PAPR environment. Instead we want to direct all PCI hotplug actions to the PAPR specific host bridge which will use the PAPR hotplug mechanism. Signed-off-by: David Gibson Acked-by: Michael S. Tsirkin --- hw/ppc/spapr.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 507fd50dd5..6dd8aaac33 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -4094,6 +4094,17 @@ static HotplugHandler *spapr_get_hotplug_handler(Mac= hineState *machine, object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_PCI_HOST_BRIDGE)) { return HOTPLUG_HANDLER(machine); } + if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { + PCIDevice *pcidev =3D PCI_DEVICE(dev); + PCIBus *root =3D pci_device_root_bus(pcidev); + SpaprPhbState *phb =3D + (SpaprPhbState *)object_dynamic_cast(OBJECT(BUS(root)->parent), + TYPE_SPAPR_PCI_HOST_BRIDG= E); + + if (phb) { + return HOTPLUG_HANDLER(phb); + } + } return NULL; } =20 --=20 2.21.0 From nobody Fri Apr 26 18:15:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1560319597; cv=none; d=zoho.com; s=zohoarc; b=MqpVraM1lZt9n9GhWpSK0ETmMFEFVLd+8/pw/o8Ap5GmiouegI/MaaP0iKF3UHenTmzthj2jWoKxxkHNWGWh9f92eT8dPZeJusrVhPOeGYaFKekzV9kdSdiBFu0muE5SBcqE+G83V0TAk61oIBQfgDyS+NzjszANNDJkTy+KX5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560319597; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=0yQ8Y0K3kYdDBw/sJQCnG0oSFqoFyTY5ifWEFsTGvv4=; b=MD+Bvp8/zSg5AP9TteDCZyNheawO8VVonfS4CAYuLQMG03C3KPoqe9j4JwKvejetYf5RE9mr1hOr1uQGeQIKKCVRtM0z1IoAc/mAoNSqCC1g4triectV5SUMcMj6SIU3NtrVoU3MGE2p5HzUkWFl7r8Cqg/AECBJtYNJQJwz/sA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560319597692658.2703137771987; Tue, 11 Jun 2019 23:06:37 -0700 (PDT) Received: from localhost ([::1]:56894 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hawP1-0001ab-Tn for importer@patchew.org; Wed, 12 Jun 2019 02:06:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58566) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1haw8o-0004ZL-I4 for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1haw8l-00073W-3V for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:46 -0400 Received: from bilbo.ozlabs.org ([2401:3900:2:1::2]:53731 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1haw8k-00071C-Ck; Wed, 12 Jun 2019 01:49:43 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 45NwtR3X0zz9sNp; Wed, 12 Jun 2019 15:49:35 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1560318575; bh=kqdUGeH6ieL5NQXTxSXSwkj8DXS2BqmKfoTd/xekpGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z51HDnGygAWnxyhWO58nDPI8t8RCH9VtGHJ4wfrZ+fqly32nbtaKLa/8lHg2sQWLh dBDj+xsgA6fh7QTk0ZfQbia1frPuA16wmWR4gGIkWgIEhiu0HS9ZpAXvO4PvbPZLZ3 upgEf4sSk/qpvJKnQOgCuIftgEZpFyyAwaz9oK7M= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 12 Jun 2019 15:49:26 +1000 Message-Id: <20190612054929.21136-11-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190612054929.21136-1-david@gibson.dropbear.id.au> References: <20190612054929.21136-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 10/13] spapr: Allow hot plug/unplug of PCI bridges and devices under PCI bridges X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, "Michael S . Tsirkin" , aik@ozlabs.ru, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The pseries machine type already allows PCI hotplug and unplug via the PAPR mechanism, but only on the root bus of each PHB. This patch extends this to allow PCI to PCI bridges to be hotplugged, and devices to be hotplugged or unplugged under P2P bridges. For now we disallow hot unplugging P2P bridges. I tried doing that, but haven't managed to get it working, I think due to some guest side problems that need further investigation. To do this we dynamically construct DRCs when bridges are hot (or cold) added, which can in turn be used to hotplug devices under the bridge. Signed-off-by: David Gibson Acked-by: Michael S. Tsirkin --- hw/ppc/spapr_pci.c | 115 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 102 insertions(+), 13 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 9d99bc0b4c..c8d7838385 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1257,30 +1257,53 @@ static SpaprDrc *drc_from_dev(SpaprPhbState *phb, P= CIDevice *dev) return drc_from_devfn(phb, chassis, dev->devfn); } =20 -static void add_drcs(SpaprPhbState *phb) +static void add_drcs(SpaprPhbState *phb, PCIBus *bus, Error **errp) { + Object *owner; int i; + uint8_t chassis; + Error *local_err =3D NULL; =20 if (!phb->dr_enabled) { return; } =20 + chassis =3D chassis_from_bus(bus, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + if (pci_bus_is_root(bus)) { + owner =3D OBJECT(phb); + } else { + owner =3D OBJECT(pci_bridge_get_device(bus)); + } + for (i =3D 0; i < PCI_SLOT_MAX * PCI_FUNC_MAX; i++) { - spapr_dr_connector_new(OBJECT(phb), TYPE_SPAPR_DRC_PCI, - drc_id_from_devfn(phb, 0, i)); + spapr_dr_connector_new(owner, TYPE_SPAPR_DRC_PCI, + drc_id_from_devfn(phb, chassis, i)); } } =20 -static void remove_drcs(SpaprPhbState *phb) +static void remove_drcs(SpaprPhbState *phb, PCIBus *bus, Error **errp) { int i; + uint8_t chassis; + Error *local_err =3D NULL; =20 if (!phb->dr_enabled) { return; } =20 + chassis =3D chassis_from_bus(bus, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + for (i =3D PCI_SLOT_MAX * PCI_FUNC_MAX - 1; i >=3D 0; i--) { - SpaprDrc *drc =3D drc_from_devfn(phb, 0, i); + SpaprDrc *drc =3D drc_from_devfn(phb, chassis, i); =20 if (drc) { object_unparent(OBJECT(drc)); @@ -1325,6 +1348,7 @@ static int spapr_dt_pci_bus(SpaprPhbState *sphb, PCIB= us *bus, .sphb =3D sphb, .err =3D 0, }; + int ret; =20 _FDT(fdt_setprop_cell(fdt, offset, "#address-cells", RESOURCE_CELLS_ADDRESS)); @@ -1339,6 +1363,12 @@ static int spapr_dt_pci_bus(SpaprPhbState *sphb, PCI= Bus *bus, } } =20 + ret =3D spapr_dt_drc(fdt, offset, OBJECT(bus->parent_dev), + SPAPR_DR_CONNECTOR_TYPE_PCI); + if (ret) { + return ret; + } + return offset; } =20 @@ -1483,11 +1513,26 @@ int spapr_pci_dt_populate(SpaprDrc *drc, SpaprMachi= neState *spapr, return 0; } =20 +static void spapr_pci_bridge_plug(SpaprPhbState *phb, + PCIBridge *bridge, + Error **errp) +{ + Error *local_err =3D NULL; + PCIBus *bus =3D pci_bridge_get_sec_bus(bridge); + + add_drcs(phb, bus, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } +} + static void spapr_pci_plug(HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) { SpaprPhbState *phb =3D SPAPR_PCI_HOST_BRIDGE(DEVICE(plug_handler)); PCIDevice *pdev =3D PCI_DEVICE(plugged_dev); + PCIDeviceClass *pc =3D PCI_DEVICE_GET_CLASS(plugged_dev); SpaprDrc *drc =3D drc_from_dev(phb, pdev); Error *local_err =3D NULL; PCIBus *bus =3D PCI_BUS(qdev_get_parent_bus(DEVICE(pdev))); @@ -1509,6 +1554,14 @@ static void spapr_pci_plug(HotplugHandler *plug_hand= ler, =20 g_assert(drc); =20 + if (pc->is_bridge) { + spapr_pci_bridge_plug(phb, PCI_BRIDGE(plugged_dev), &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + } + /* Following the QEMU convention used for PCIe multifunction * hotplug, we do not allow functions to be hotplugged to a * slot that already has function 0 present @@ -1559,9 +1612,26 @@ out: error_propagate(errp, local_err); } =20 +static void spapr_pci_bridge_unplug(SpaprPhbState *phb, + PCIBridge *bridge, + Error **errp) +{ + Error *local_err =3D NULL; + PCIBus *bus =3D pci_bridge_get_sec_bus(bridge); + + remove_drcs(phb, bus, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } +} + static void spapr_pci_unplug(HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) { + PCIDeviceClass *pc =3D PCI_DEVICE_GET_CLASS(plugged_dev); + SpaprPhbState *phb =3D SPAPR_PCI_HOST_BRIDGE(DEVICE(plug_handler)); + /* some version guests do not wait for completion of a device * cleanup (generally done asynchronously by the kernel) before * signaling to QEMU that the device is safe, but instead sleep @@ -1573,6 +1643,16 @@ static void spapr_pci_unplug(HotplugHandler *plug_ha= ndler, * an 'idle' state, as the device cleanup code expects. */ pci_device_reset(PCI_DEVICE(plugged_dev)); + + if (pc->is_bridge) { + Error *local_err =3D NULL; + spapr_pci_bridge_unplug(phb, PCI_BRIDGE(plugged_dev), &local_err); + if (local_err) { + error_propagate(errp, local_err); + } + return; + } + object_property_set_bool(OBJECT(plugged_dev), false, "realized", NULL); } =20 @@ -1593,6 +1673,7 @@ static void spapr_pci_unplug_request(HotplugHandler *= plug_handler, g_assert(drc->dev =3D=3D plugged_dev); =20 if (!spapr_drc_unplug_requested(drc)) { + PCIDeviceClass *pc =3D PCI_DEVICE_GET_CLASS(plugged_dev); uint32_t slotnr =3D PCI_SLOT(pdev->devfn); SpaprDrc *func_drc; SpaprDrcClass *func_drck; @@ -1606,6 +1687,10 @@ static void spapr_pci_unplug_request(HotplugHandler = *plug_handler, return; } =20 + if (pc->is_bridge) { + error_setg(errp, "PCI: Hot unplug of PCI bridges not supported= "); + } + /* ensure any other present functions are pending unplug */ if (PCI_FUNC(pdev->devfn) =3D=3D 0) { for (i =3D 1; i < 8; i++) { @@ -1658,6 +1743,7 @@ static void spapr_phb_unrealize(DeviceState *dev, Err= or **errp) SpaprTceTable *tcet; int i; const unsigned windows_supported =3D spapr_phb_windows_supported(sphb); + Error *local_err =3D NULL; =20 spapr_phb_nvgpu_free(sphb); =20 @@ -1678,7 +1764,11 @@ static void spapr_phb_unrealize(DeviceState *dev, Er= ror **errp) } } =20 - remove_drcs(sphb); + remove_drcs(sphb, phb->bus, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } =20 for (i =3D PCI_NUM_PINS - 1; i >=3D 0; i--) { if (sphb->lsi_table[i].irq) { @@ -1721,6 +1811,7 @@ static void spapr_phb_realize(DeviceState *dev, Error= **errp) uint64_t msi_window_size =3D 4096; SpaprTceTable *tcet; const unsigned windows_supported =3D spapr_phb_windows_supported(sphb); + Error *local_err =3D NULL; =20 if (!spapr) { error_setg(errp, TYPE_SPAPR_PCI_HOST_BRIDGE " needs a pseries mach= ine"); @@ -1873,7 +1964,6 @@ static void spapr_phb_realize(DeviceState *dev, Error= **errp) /* Initialize the LSI table */ for (i =3D 0; i < PCI_NUM_PINS; i++) { uint32_t irq =3D SPAPR_IRQ_PCI_LSI + sphb->index * PCI_NUM_PINS + = i; - Error *local_err =3D NULL; =20 if (smc->legacy_irq_allocation) { irq =3D spapr_irq_findone(spapr, &local_err); @@ -1898,7 +1988,11 @@ static void spapr_phb_realize(DeviceState *dev, Erro= r **errp) } =20 /* allocate connectors for child PCI devices */ - add_drcs(sphb); + add_drcs(sphb, phb->bus, &local_err); + if (local_err) { + error_propagate(errp, local_err); + goto unrealize; + } =20 /* DMA setup */ for (i =3D 0; i < windows_supported; ++i) { @@ -2314,11 +2408,6 @@ int spapr_dt_phb(SpaprPhbState *phb, uint32_t intc_p= handle, void *fdt, return ret; } =20 - ret =3D spapr_dt_drc(fdt, bus_off, OBJECT(phb), SPAPR_DR_CONNECTOR_TYP= E_PCI); - if (ret) { - return ret; - } - spapr_phb_nvgpu_populate_dt(phb, fdt, bus_off, &errp); if (errp) { error_report_err(errp); --=20 2.21.0 From nobody Fri Apr 26 18:15:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1560318750; cv=none; d=zoho.com; s=zohoarc; b=hDDLiScmcWj8hHbkuny5Qbp/sc2DinCRkvFhoBTVW5V2crw37rlvX9OED9wEA1A67W/HR+11DS71Sjb6LWLNGCwYsa5Pl5GGoVma/YrmR/OgQNb/IYD3jeH92YPHuZ4te4KcHldd39iNSj08jmfJM4IKEwT8s501JzVF6wS7ocU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560318750; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=JAKf1TpVtZ3OSjK0YLQUzBxV/UFK+dxjO+Dd7ysae/M=; b=CHtoGxjr227eHAQ6Kk9Mtd/x3x4i/ufkA2i3C44CFCRReWx5UeWoiO8xJHNa2UWzgd30j0ENPrExU7CA1goyegF5r8IdkCdx5EhWf4DbXNnEw/oXhEpl+++Q9igO2QAJIJDN2mf3PGK7kJxEOuHrNPPuUXQgpX+fmp3Zjj+j9Xc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560318750172573.0281841355078; Tue, 11 Jun 2019 22:52:30 -0700 (PDT) Received: from localhost ([::1]:56814 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hawBR-00078K-6F for importer@patchew.org; Wed, 12 Jun 2019 01:52:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58473) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1haw8m-0004Ur-8f for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1haw8k-00072W-En for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:44 -0400 Received: from ozlabs.org ([203.11.71.1]:33539) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1haw8k-00070u-26; Wed, 12 Jun 2019 01:49:42 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 45NwtR1Hlnz9sNT; Wed, 12 Jun 2019 15:49:35 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1560318575; bh=KS3YuiEIOq/GZnRXvIWmLklhlLsIdYGPylfsoDmpdvo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ezP/FgFM07clANxNp9kcWY167jth5oTPP+Qu+oyqCDhoE520KweugtXUgMFp05lRv 1P9BYCayylNXCxwgev9gFFbak8Lzn57ZT6NUtUy5n662Sdy+eUdY2GKhgUYqSFwC2e 6HehvV/SM68lFBU1dia0HzWV9EBYgdmqnDQUjoeg= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 12 Jun 2019 15:49:27 +1000 Message-Id: <20190612054929.21136-12-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190612054929.21136-1-david@gibson.dropbear.id.au> References: <20190612054929.21136-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] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 11/13] target/ppc: Use tcg_gen_gvec_bitsel X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, aik@ozlabs.ru, Richard Henderson , qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Richard Henderson Replace the target-specific implementation of XXSEL. Signed-off-by: Richard Henderson Message-Id: <20190603164927.8336-1-richard.henderson@linaro.org> Signed-off-by: David Gibson --- target/ppc/translate/vsx-impl.inc.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/target/ppc/translate/vsx-impl.inc.c b/target/ppc/translate/vsx= -impl.inc.c index cdb44b8b70..e9b7562f84 100644 --- a/target/ppc/translate/vsx-impl.inc.c +++ b/target/ppc/translate/vsx-impl.inc.c @@ -1339,28 +1339,8 @@ static void glue(gen_, name)(DisasContext *ctx) = \ VSX_XXMRG(xxmrghw, 1) VSX_XXMRG(xxmrglw, 0) =20 -static void xxsel_i64(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b, TCGv_i64 c) -{ - tcg_gen_and_i64(b, b, c); - tcg_gen_andc_i64(a, a, c); - tcg_gen_or_i64(t, a, b); -} - -static void xxsel_vec(unsigned vece, TCGv_vec t, TCGv_vec a, - TCGv_vec b, TCGv_vec c) -{ - tcg_gen_and_vec(vece, b, b, c); - tcg_gen_andc_vec(vece, a, a, c); - tcg_gen_or_vec(vece, t, a, b); -} - static void gen_xxsel(DisasContext *ctx) { - static const GVecGen4 g =3D { - .fni8 =3D xxsel_i64, - .fniv =3D xxsel_vec, - .vece =3D MO_64, - }; int rt =3D xT(ctx->opcode); int ra =3D xA(ctx->opcode); int rb =3D xB(ctx->opcode); @@ -1370,8 +1350,8 @@ static void gen_xxsel(DisasContext *ctx) gen_exception(ctx, POWERPC_EXCP_VSXU); return; } - tcg_gen_gvec_4(vsr_full_offset(rt), vsr_full_offset(ra), - vsr_full_offset(rb), vsr_full_offset(rc), 16, 16, &g); + tcg_gen_gvec_bitsel(MO_64, vsr_full_offset(rt), vsr_full_offset(rc), + vsr_full_offset(rb), vsr_full_offset(ra), 16, 16); } =20 static void gen_xxspltw(DisasContext *ctx) --=20 2.21.0 From nobody Fri Apr 26 18:15:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1560319208; cv=none; d=zoho.com; s=zohoarc; b=TigVJGdAWshkjF2H6ewlBsq/7kBnjjyU9TkDkKAtsKSRVsx/KFGi0fup54K0VPWmL2MA1ShY6rRohPbD/xxyF2saKl+ErfTcWnPb+HZ0i8jeWLD8zFI2yPb4dSRcwitHgAofnDFxw+6bHCs8295HXJVO/cvDpFTq5LRNX41C4L4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560319208; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=mDslacyCcsy7I+8ektmijYlPHKVwOMMvWh9MBts0hUI=; b=asHDyAIykfi3dg/8uT5xTrXJF9PM8RKVMq5vuEpeyE6+lRYcQosKZXwAnzWX4yialAUlP2vbOc9vIh67b0GZ+1yDkQuu1EjehHzXm4TkVvImDDozC4rA0oCOhNZ633TnTubk4xn6RYkfpJCSWRJIUjl+k0zhqhSJblG6iIxgiVc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560319208095176.77327659354216; Tue, 11 Jun 2019 23:00:08 -0700 (PDT) Received: from localhost ([::1]:56868 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hawIm-000651-3T for importer@patchew.org; Wed, 12 Jun 2019 02:00:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58513) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1haw8n-0004Xr-Ce for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1haw8l-000740-Qq for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:45 -0400 Received: from ozlabs.org ([203.11.71.1]:53911) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1haw8l-000721-Du; Wed, 12 Jun 2019 01:49:43 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 45NwtR5PZlz9sNk; Wed, 12 Jun 2019 15:49:35 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1560318575; bh=7/ss7KjQXSPnRKSlVh6aYkEwnLkYZP9whziMKOPd0nE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fk9fuRRoj7HfKsoEwuDDSd+NTxOyRR0cw1QYoeHd+zb96FxKas0OPUXggBbwQ5wWy dqQRL1xvI9Xba/JZVSHJJRRLpuwisonCDlqBNE5u0oaxzfMNGQMuYeFWMw/63JBSHS f8KZgDxwbKh2fW2ki2Ddtybv+iBddYjFHSHGLplg= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 12 Jun 2019 15:49:28 +1000 Message-Id: <20190612054929.21136-13-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190612054929.21136-1-david@gibson.dropbear.id.au> References: <20190612054929.21136-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] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 12/13] ppc/pnv: activate the "dumpdtb" option on the powernv machine X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, aik@ozlabs.ru, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: C=C3=A9dric Le Goater This is a good way to debug the DT creation for current PowerNV machines and new ones to come. Signed-off-by: C=C3=A9dric Le Goater Message-Id: <20190606174732.13051-1-clg@kaod.org> Reviewed-by: Greg Kurz Signed-off-by: David Gibson --- hw/ppc/pnv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 046f0a83c8..ed68924667 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -23,6 +23,7 @@ #include "sysemu/sysemu.h" #include "sysemu/numa.h" #include "sysemu/cpus.h" +#include "sysemu/device_tree.h" #include "hw/hw.h" #include "target/ppc/cpu.h" #include "qemu/log.h" @@ -554,6 +555,7 @@ static void pnv_reset(void) /* Pack resulting tree */ _FDT((fdt_pack(fdt))); =20 + qemu_fdt_dumpdtb(fdt, fdt_totalsize(fdt)); cpu_physical_memory_write(PNV_FDT_ADDR, fdt, fdt_totalsize(fdt)); } =20 --=20 2.21.0 From nobody Fri Apr 26 18:15:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1560319222; cv=none; d=zoho.com; s=zohoarc; b=Cmx/Lb+ZX1DdoA2j6Ki9128kb3R93Rr/74suF3D9GdLg3o44M8gOrJulZ4sJcn7R0WxIZq9f2oWPkv9+upcq39D0baCMoIUZXSPX1BgTIDxrn5lQp7nt0uJAtlXqGZnASh/N3/s63g1nhk9vTn+AYN13C6bY9pTIsbDoMiMoOkE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560319222; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=PKtQ66Im19CdRx5g7RhnHC8sgNg3fT70fVdQgUgDYWE=; b=lYi85O463b0CTG0mOWpBKPuyI6VBnbkyz7rbIDDoz6A+g7BXVhEnVxj9BSm82E/nPTJnb+9KM2uEPF6zwJffpCCTX6BktgXOjSPZ99mgqcGWuuiy4yUxAxoihGSyrqiFQ1FLu04qJVNBce/sSDXP/GYbk/kvLjk1j8nniWp2p8Y= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560319222043589.0409569171607; Tue, 11 Jun 2019 23:00:22 -0700 (PDT) Received: from localhost ([::1]:56870 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hawIw-0006Da-Sc for importer@patchew.org; Wed, 12 Jun 2019 02:00:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58584) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1haw8p-0004a1-4S for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1haw8n-000758-Fh for qemu-devel@nongnu.org; Wed, 12 Jun 2019 01:49:46 -0400 Received: from bilbo.ozlabs.org ([2401:3900:2:1::2]:46167 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1haw8m-00073Q-WF; Wed, 12 Jun 2019 01:49:45 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 45NwtR60Tqz9sPH; Wed, 12 Jun 2019 15:49:35 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1560318575; bh=tyUDdI4e4bCE/oy8otsoOZLgCZX2M2lVZQFcb3wbaG0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LP8aVkvAJvLUWrSFlNtQ6ksimJNKkRnHwnOBTYOUSh3HpxkKXO2KHxnYgYgRYXalY vehJGdI60JE8d6Q8PHz0Et6ZZWKMYugZatlMi0JyiIbDnVJxH1J63VWcTbivwvU0nz 5NZ+1hOvViOc45KyAzbxR0bLzS4bIUgjtjtfROVk= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 12 Jun 2019 15:49:29 +1000 Message-Id: <20190612054929.21136-14-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190612054929.21136-1-david@gibson.dropbear.id.au> References: <20190612054929.21136-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/13] ppc/xive: Make XIVE generate the proper interrupt types X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, aik@ozlabs.ru, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Benjamin Herrenschmidt It should be generic Hypervisor Virtualization interrupts for HV directed rings and traditional External Interrupts for the OS directed ring. Don't generate anything for the user ring as it isn't actually supported. Signed-off-by: Benjamin Herrenschmidt Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: David Gibson Message-Id: <20190606174409.12502-1-clg@kaod.org> Signed-off-by: David Gibson --- hw/intc/xive.c | 22 +++++++++++++++++++--- include/hw/ppc/xive.h | 3 ++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/hw/intc/xive.c b/hw/intc/xive.c index 0c74e47aa4..b2b92a92c8 100644 --- a/hw/intc/xive.c +++ b/hw/intc/xive.c @@ -61,13 +61,28 @@ static uint8_t exception_mask(uint8_t ring) } } =20 +static qemu_irq xive_tctx_output(XiveTCTX *tctx, uint8_t ring) +{ + switch (ring) { + case TM_QW0_USER: + return 0; /* Not supported */ + case TM_QW1_OS: + return tctx->os_output; + case TM_QW2_HV_POOL: + case TM_QW3_HV_PHYS: + return tctx->hv_output; + default: + return 0; + } +} + static uint64_t xive_tctx_accept(XiveTCTX *tctx, uint8_t ring) { uint8_t *regs =3D &tctx->regs[ring]; uint8_t nsr =3D regs[TM_NSR]; uint8_t mask =3D exception_mask(ring); =20 - qemu_irq_lower(tctx->output); + qemu_irq_lower(xive_tctx_output(tctx, ring)); =20 if (regs[TM_NSR] & mask) { uint8_t cppr =3D regs[TM_PIPR]; @@ -100,7 +115,7 @@ static void xive_tctx_notify(XiveTCTX *tctx, uint8_t ri= ng) default: g_assert_not_reached(); } - qemu_irq_raise(tctx->output); + qemu_irq_raise(xive_tctx_output(tctx, ring)); } } =20 @@ -556,7 +571,8 @@ static void xive_tctx_realize(DeviceState *dev, Error *= *errp) env =3D &cpu->env; switch (PPC_INPUT(env)) { case PPC_FLAGS_INPUT_POWER9: - tctx->output =3D env->irq_inputs[POWER9_INPUT_INT]; + tctx->hv_output =3D env->irq_inputs[POWER9_INPUT_HINT]; + tctx->os_output =3D env->irq_inputs[POWER9_INPUT_INT]; break; =20 default: diff --git a/include/hw/ppc/xive.h b/include/hw/ppc/xive.h index d872f96d1a..a6ee7e831d 100644 --- a/include/hw/ppc/xive.h +++ b/include/hw/ppc/xive.h @@ -317,7 +317,8 @@ typedef struct XiveTCTX { DeviceState parent_obj; =20 CPUState *cs; - qemu_irq output; + qemu_irq hv_output; + qemu_irq os_output; =20 uint8_t regs[XIVE_TM_RING_COUNT * XIVE_TM_RING_SIZE]; } XiveTCTX; --=20 2.21.0