From nobody Thu May 2 04:01:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150539875579229.789066837956966; Thu, 14 Sep 2017 07:19:15 -0700 (PDT) Received: from localhost ([::1]:48069 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsUz5-0008LS-0b for importer@patchew.org; Thu, 14 Sep 2017 10:19:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59555) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsUuj-0004Qn-GD for qemu-devel@nongnu.org; Thu, 14 Sep 2017 10:14:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsUuf-0008UR-IL for qemu-devel@nongnu.org; Thu, 14 Sep 2017 10:14:45 -0400 Received: from 8.mo2.mail-out.ovh.net ([188.165.52.147]:52725) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dsUuf-0008Th-BS for qemu-devel@nongnu.org; Thu, 14 Sep 2017 10:14:41 -0400 Received: from player770.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo2.mail-out.ovh.net (Postfix) with ESMTP id 45F4DAC1E1 for ; Thu, 14 Sep 2017 16:14:39 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player770.ha.ovh.net (Postfix) with ESMTPA id EC4D13C00FC; Thu, 14 Sep 2017 16:14:33 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Thu, 14 Sep 2017 16:14:33 +0200 Message-ID: <150539847337.21523.1659017394355445790.stgit@bahia> In-Reply-To: <150539846159.21523.16161730500010192093.stgit@bahia> References: <150539846159.21523.16161730500010192093.stgit@bahia> User-Agent: StGit/0.17.1-46-g6855-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 10290443677359053301 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelledrgeeigdejiecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 188.165.52.147 Subject: [Qemu-devel] [PATCH v2 1/2] checkpatch: add hwaddr to @typeList X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy , Paolo Bonzini , qemu-ppc@nongnu.org, Michael Roth , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 The script doesn't know about all possible types and learn them as it parses the code. If it reaches a line with a type cast but the type isn't known yet, it is misinterpreted as an identifier. For example the following line: foo =3D (hwaddr) -1; results in the following false-positive to be reported: ERROR: spaces required around that '-' (ctx:VxV) Let's add this standard QEMU type to the list of pre-known types. Signed-off-by: Greg Kurz Reviewed-by: David Gibson --- scripts/checkpatch.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index fa478074b88d..def5bc1cc0e1 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -213,6 +213,7 @@ our @typeList =3D ( qr{${Ident}_handler}, qr{${Ident}_handler_fn}, qr{target_(?:u)?long}, + qr{hwaddr}, ); =20 # This can be modified by sub possible. Since it can be empty, be careful From nobody Thu May 2 04:01:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1505398644951514.6448519771494; Thu, 14 Sep 2017 07:17:24 -0700 (PDT) Received: from localhost ([::1]:48059 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsUxI-0006jt-1M for importer@patchew.org; Thu, 14 Sep 2017 10:17:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59680) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsUus-0004cM-Rm for qemu-devel@nongnu.org; Thu, 14 Sep 2017 10:14:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsUup-00009z-IW for qemu-devel@nongnu.org; Thu, 14 Sep 2017 10:14:54 -0400 Received: from 5.mo2.mail-out.ovh.net ([87.98.181.248]:54263) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dsUup-00009N-91 for qemu-devel@nongnu.org; Thu, 14 Sep 2017 10:14:51 -0400 Received: from player770.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo2.mail-out.ovh.net (Postfix) with ESMTP id 4031BAC1DC for ; Thu, 14 Sep 2017 16:14:50 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player770.ha.ovh.net (Postfix) with ESMTPA id D5B0E3C00CE; Thu, 14 Sep 2017 16:14:44 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Thu, 14 Sep 2017 16:14:44 +0200 Message-ID: <150539848430.21523.2732328570419779115.stgit@bahia> In-Reply-To: <150539846159.21523.16161730500010192093.stgit@bahia> References: <150539846159.21523.16161730500010192093.stgit@bahia> User-Agent: StGit/0.17.1-46-g6855-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 10293539902228961781 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelledrgeeigdejiecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 87.98.181.248 Subject: [Qemu-devel] [PATCH v2 2/2] spapr_pci: make index property mandatory X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy , Paolo Bonzini , qemu-ppc@nongnu.org, Michael Roth , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Creating several PHBs without index property confuses the DRC code and causes issues: - only the first index-less PHB is functional, the other ones will silently ignore hotplugging of PCI devices - QEMU will even terminate if these PHBs have cold-plugged devices qemu-system-ppc64: -device virtio-net,bus=3Dpci2.0: an attached device is still awaiting release This happens because DR connectors for child PCI devices are created with a DRC index that is derived from the PHB's index property. If the PHBs are created without index, then the same value of -1 is used to compute the DRC indexes for both PHBs, hence causing the collision. Also, the index property is used to compute the placement of the PHB's memory regions. It is limited to 31 or 255, depending on the machine type version. This fits well with the requirements of DRC indexes, which need the PHB index to be a 16-bit value. This patch hence makes the index property mandatory. As a consequence, the PHB's memory regions and BUID are now always configured according to the index, and it is no longer possible to set them from the command line. We have to introduce a PHB instance init function to initialize the 64-bit window address to -1 because pseries-2.7 and older machines don't set it. This DOES BREAK backwards compat, but we don't think the non-index PHB feature was used in practice (at least libvirt doesn't) and the simplification is worth it. Signed-off-by: Greg Kurz --- v1->v2: - error out if mem64_win_pciaddr is set but mem64_win_size isn't - set mem64_win_addr to -1 for old configuration with 32-bit window below 2G in spapr_phb_realize() - drop instance init function RFC->v1: - as suggested dy David, updated the changelog to explicitely mention that we intentionally break backwards compat. --- hw/ppc/spapr_pci.c | 53 +++++++++++-------------------------------------= ---- 1 file changed, 11 insertions(+), 42 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index cf54160526fa..024638e18b53 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1523,16 +1523,6 @@ static void spapr_phb_realize(DeviceState *dev, Erro= r **errp) sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); Error *local_err =3D NULL; =20 - if ((sphb->buid !=3D (uint64_t)-1) || (sphb->dma_liobn[0] !=3D (ui= nt32_t)-1) - || (sphb->dma_liobn[1] !=3D (uint32_t)-1 && windows_supported = =3D=3D 2) - || (sphb->mem_win_addr !=3D (hwaddr)-1) - || (sphb->mem64_win_addr !=3D (hwaddr)-1) - || (sphb->io_win_addr !=3D (hwaddr)-1)) { - error_setg(errp, "Either \"index\" or other parameters must" - " be specified for PAPR PHB, not both"); - return; - } - smc->phb_placement(spapr, sphb->index, &sphb->buid, &sphb->io_win_addr, &sphb->mem_win_addr, &sphb->mem64_win_addr, @@ -1541,36 +1531,12 @@ static void spapr_phb_realize(DeviceState *dev, Err= or **errp) error_propagate(errp, local_err); return; } - } - - if (sphb->buid =3D=3D (uint64_t)-1) { - error_setg(errp, "BUID not specified for PHB"); - return; - } - - if ((sphb->dma_liobn[0] =3D=3D (uint32_t)-1) || - ((sphb->dma_liobn[1] =3D=3D (uint32_t)-1) && (windows_supported > = 1))) { - error_setg(errp, "LIOBN(s) not specified for PHB"); - return; - } - - if (sphb->mem_win_addr =3D=3D (hwaddr)-1) { - error_setg(errp, "Memory window address not specified for PHB"); - return; - } - - if (sphb->io_win_addr =3D=3D (hwaddr)-1) { - error_setg(errp, "IO window address not specified for PHB"); + } else { + error_setg(errp, "\"index\" for PAPR PHB is mandatory"); return; } =20 if (sphb->mem64_win_size !=3D 0) { - if (sphb->mem64_win_addr =3D=3D (hwaddr)-1) { - error_setg(errp, - "64-bit memory window address not specified for PHB= "); - return; - } - if (sphb->mem_win_size > SPAPR_PCI_MEM32_WIN_SIZE) { error_setg(errp, "32-bit memory window of size 0x%"HWADDR_PRIx " (max 2 GiB)", sphb->mem_win_size); @@ -1581,6 +1547,9 @@ static void spapr_phb_realize(DeviceState *dev, Error= **errp) /* 64-bit window defaults to identity mapping */ sphb->mem64_win_pciaddr =3D sphb->mem64_win_addr; } + } else if (sphb->mem64_win_pciaddr !=3D (hwaddr) -1) { + error_setg(errp, "64-bit memory window requires \"mem64_win_size\"= "); + return; } else if (sphb->mem_win_size > SPAPR_PCI_MEM32_WIN_SIZE) { /* * For compatibility with old configuration, if no 64-bit MMIO @@ -1594,6 +1563,12 @@ static void spapr_phb_realize(DeviceState *dev, Erro= r **errp) sphb->mem64_win_pciaddr =3D SPAPR_PCI_MEM_WIN_BUS_OFFSET + SPAPR_PCI_MEM32_WIN_SIZE; sphb->mem_win_size =3D SPAPR_PCI_MEM32_WIN_SIZE; + } else { + /* Old configuration with the 32-bit MMIO window <=3D 2GiB don't n= eed a + * 64-bit MMIO window. + */ + sphb->mem64_win_addr =3D (hwaddr) -1; + sphb->mem64_win_pciaddr =3D (hwaddr) -1; } =20 if (spapr_pci_find_phb(spapr, sphb->buid)) { @@ -1789,18 +1764,12 @@ static void spapr_phb_reset(DeviceState *qdev) =20 static Property spapr_phb_properties[] =3D { DEFINE_PROP_UINT32("index", sPAPRPHBState, index, -1), - DEFINE_PROP_UINT64("buid", sPAPRPHBState, buid, -1), - DEFINE_PROP_UINT32("liobn", sPAPRPHBState, dma_liobn[0], -1), - DEFINE_PROP_UINT32("liobn64", sPAPRPHBState, dma_liobn[1], -1), - DEFINE_PROP_UINT64("mem_win_addr", sPAPRPHBState, mem_win_addr, -1), DEFINE_PROP_UINT64("mem_win_size", sPAPRPHBState, mem_win_size, SPAPR_PCI_MEM32_WIN_SIZE), - DEFINE_PROP_UINT64("mem64_win_addr", sPAPRPHBState, mem64_win_addr, -1= ), DEFINE_PROP_UINT64("mem64_win_size", sPAPRPHBState, mem64_win_size, SPAPR_PCI_MEM64_WIN_SIZE), DEFINE_PROP_UINT64("mem64_win_pciaddr", sPAPRPHBState, mem64_win_pciad= dr, -1), - DEFINE_PROP_UINT64("io_win_addr", sPAPRPHBState, io_win_addr, -1), DEFINE_PROP_UINT64("io_win_size", sPAPRPHBState, io_win_size, SPAPR_PCI_IO_WIN_SIZE), DEFINE_PROP_BOOL("dynamic-reconfiguration", sPAPRPHBState, dr_enabled,