From patchwork Fri Oct 28 07:56:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 688264 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3t4x1y04pLz9t0H for ; Fri, 28 Oct 2016 18:57:40 +1100 (AEDT) Received: from localhost ([::1]:47316 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c022j-00051Z-7X for incoming@patchwork.ozlabs.org; Fri, 28 Oct 2016 03:57:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54269) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c0221-0004eC-5D for qemu-devel@nongnu.org; Fri, 28 Oct 2016 03:56:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c021x-00072g-5I for qemu-devel@nongnu.org; Fri, 28 Oct 2016 03:56:53 -0400 Received: from ozlabs.ru ([83.169.36.222]:58918) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c021w-00072I-VE; Fri, 28 Oct 2016 03:56:49 -0400 Received: from vpl2.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 22962120A83; Fri, 28 Oct 2016 09:56:43 +0200 (CEST) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Fri, 28 Oct 2016 18:56:40 +1100 Message-Id: <1477641400-23292-1-git-send-email-aik@ozlabs.ru> X-Mailer: git-send-email 2.5.0.rc3 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.169.36.222 Subject: [Qemu-devel] [RFC PATCH qemu] spapr_pci: Create PCI-express root bus by default 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 , Michael Roth , Alex Williamson , qemu-ppc@nongnu.org, Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" At the moment sPAPR PHB creates a root buf of TYPE_PCI_BUS type. This means that vfio-pci devices attached to it (and this is a default behaviour) hide PCIe extended capabilities as the bus does not pass a pci_bus_is_express(pdev->bus) check. This changes adds a default PCI bus type property to sPAPR PHB and uses TYPE_PCIE_BUS if none passed; older machines get TYPE_PCI_BUS for backward compatibility as a bus type is used in the bus name so the root bus name becomes "pcie.0" instead of "pci.0". Signed-off-by: Alexey Kardashevskiy --- What can possibly go wrong with such change of a name? From devices prospective, I cannot see any. libvirt might get upset as "pci.0" will not be available, will it make sense to create pcie.0 as a root bus and always add a PCIe->PCI bridge and name its bus "pci.0"? Or create root bus from TYPE_PCIE_BUS and force name to "pci.0"? pci_register_bus() can do this. --- hw/ppc/spapr.c | 5 +++++ hw/ppc/spapr_pci.c | 5 ++++- include/hw/pci-host/spapr.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 0b3820b..a268511 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2541,6 +2541,11 @@ DEFINE_SPAPR_MACHINE(2_8, "2.8", true); .driver = TYPE_SPAPR_PCI_HOST_BRIDGE, \ .property = "mem64_win_size", \ .value = "0", \ + }, \ + { \ + .driver = TYPE_SPAPR_PCI_HOST_BRIDGE, \ + .property = "root_bus_type", \ + .value = TYPE_PCI_BUS, \ }, static void phb_placement_2_7(sPAPRMachineState *spapr, uint32_t index, diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 7cde30e..2fa1f22 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1434,7 +1434,9 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp) bus = pci_register_bus(dev, NULL, pci_spapr_set_irq, pci_spapr_map_irq, sphb, &sphb->memspace, &sphb->iospace, - PCI_DEVFN(0, 0), PCI_NUM_PINS, TYPE_PCI_BUS); + PCI_DEVFN(0, 0), PCI_NUM_PINS, + sphb->root_bus_type ? sphb->root_bus_type : + TYPE_PCIE_BUS); phb->bus = bus; qbus_set_hotplug_handler(BUS(phb->bus), DEVICE(sphb), NULL); @@ -1590,6 +1592,7 @@ static Property spapr_phb_properties[] = { DEFINE_PROP_UINT64("pgsz", sPAPRPHBState, page_size_mask, (1ULL << 12) | (1ULL << 16)), DEFINE_PROP_UINT32("numa_node", sPAPRPHBState, numa_node, -1), + DEFINE_PROP_STRING("root_bus_type", sPAPRPHBState, root_bus_type), DEFINE_PROP_END_OF_LIST(), }; diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h index b92c1b5..a4ee873 100644 --- a/include/hw/pci-host/spapr.h +++ b/include/hw/pci-host/spapr.h @@ -79,6 +79,7 @@ struct sPAPRPHBState { uint64_t dma64_win_addr; uint32_t numa_node; + char *root_bus_type; }; #define SPAPR_PCI_MEM_WIN_BUS_OFFSET 0x80000000ULL