From patchwork Fri Nov 25 22:05:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 9448157 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8C86060235 for ; Fri, 25 Nov 2016 22:15:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BDD0204C0 for ; Fri, 25 Nov 2016 22:15:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6EB822808F; Fri, 25 Nov 2016 22:15:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 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 mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0F20C204C0 for ; Fri, 25 Nov 2016 22:15:35 +0000 (UTC) Received: from localhost ([::1]:48127 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cAOmM-00050X-4S for patchwork-qemu-devel@patchwork.kernel.org; Fri, 25 Nov 2016 17:15:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50724) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cAOdp-0006h5-Jl for qemu-devel@nongnu.org; Fri, 25 Nov 2016 17:06:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cAOdo-0000Pd-P9 for qemu-devel@nongnu.org; Fri, 25 Nov 2016 17:06:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37374) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cAOdo-0000OS-Jf for qemu-devel@nongnu.org; Fri, 25 Nov 2016 17:06:44 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CBC2C8124F for ; Fri, 25 Nov 2016 22:06:43 +0000 (UTC) Received: from localhost (ovpn-116-207.phx2.redhat.com [10.3.116.207]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uAPM6goY026457; Fri, 25 Nov 2016 17:06:43 -0500 From: Eduardo Habkost To: qemu-devel@nongnu.org, Markus Armbruster , Marcel Apfelbaum , "Michael S. Tsirkin" Date: Fri, 25 Nov 2016 20:05:53 -0200 Message-Id: <1480111556-32586-18-git-send-email-ehabkost@redhat.com> In-Reply-To: <1480111556-32586-1-git-send-email-ehabkost@redhat.com> References: <1480111556-32586-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 25 Nov 2016 22:06:43 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v2 17/20] pci: Set device_type on bus classes 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: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The default device_type for for TYPE_PCI_BUS will be INTERFACE_LEGACY_PCI_DEVICE. The device_type for TYPE_PCIE_BUS will be INTERFACE_PCIE_DEVICE. Note that specific bus instances may still override accepted_device_types. See the comments added to the code. Signed-off-by: Eduardo Habkost --- Changes series v1 -> v2: * (new patch added to series) --- hw/pci/pci.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 2fc543c..19dc63a 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -152,7 +152,10 @@ static void pci_bus_class_init(ObjectClass *klass, void *data) k->realize = pci_bus_realize; k->unrealize = pci_bus_unrealize; k->reset = pcibus_reset; - k->device_type = TYPE_PCI_DEVICE; + /* note that TYPE_PCIE_BUS is a TYPE_PCI_BUS subclass, + * but overrides BusClass::device_type to INTERFACE_PCIE_DEVICE + */ + k->device_type = INTERFACE_LEGACY_PCI_DEVICE; pbc->is_root = pcibus_is_root; pbc->bus_num = pcibus_num; @@ -177,8 +180,19 @@ static const TypeInfo legacy_pci_interface_info = { .parent = TYPE_INTERFACE, }; +static void pcie_bus_class_init(ObjectClass *oc, void *opaque) +{ + BusClass *bc = BUS_CLASS(oc); + /* Note that this is the default value for accepted_device_types, + * but specific PCIe bus instances may override it. + * (e.g. q35 root bus accepts both legacy and PCIe devices). + */ + bc->device_type = INTERFACE_PCIE_DEVICE; +} + static const TypeInfo pcie_bus_info = { .name = TYPE_PCIE_BUS, + .class_init = pcie_bus_class_init, .parent = TYPE_PCI_BUS, };