From owner-svn-src-all@FreeBSD.ORG Tue Sep 30 16:49:18 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9F9E7BA2; Tue, 30 Sep 2014 16:49:18 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 73DA9831; Tue, 30 Sep 2014 16:49:18 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s8UGnIXS093129; Tue, 30 Sep 2014 16:49:18 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s8UGnIlO093128; Tue, 30 Sep 2014 16:49:18 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201409301649.s8UGnIlO093128@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: Roger Pau Monné Date: Tue, 30 Sep 2014 16:49:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r272311 - head/sys/x86/xen X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Sep 2014 16:49:18 -0000 Author: royger Date: Tue Sep 30 16:49:17 2014 New Revision: 272311 URL: http://svnweb.freebsd.org/changeset/base/272311 Log: xen: add the Xen implementation of pci_child_added method Add the Xen specific implementation of pci_child_added to the Xen PCI bus. This is needed so FreeBSD can register the devices it finds with the hypervisor. Sponsored by: Citrix Systems R&D x86/xen/xen_pci.c: - Add the Xen pci_child_added method. Modified: head/sys/x86/xen/xen_pci.c Modified: head/sys/x86/xen/xen_pci.c ============================================================================== --- head/sys/x86/xen/xen_pci.c Tue Sep 30 16:46:45 2014 (r272310) +++ head/sys/x86/xen/xen_pci.c Tue Sep 30 16:49:17 2014 (r272311) @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include "pcib_if.h" #include "pci_if.h" @@ -49,6 +50,7 @@ static int xen_pci_probe(device_t dev); static void xen_pci_enable_msi_method(device_t dev, device_t child, uint64_t address, uint16_t data); static void xen_pci_disable_msi_method(device_t dev, device_t child); +static void xen_pci_child_added_method(device_t dev, device_t child); static device_method_t xen_pci_methods[] = { /* Device interface */ @@ -57,6 +59,7 @@ static device_method_t xen_pci_methods[] /* PCI interface overwrites */ DEVMETHOD(pci_enable_msi, xen_pci_enable_msi_method), DEVMETHOD(pci_disable_msi, xen_pci_disable_msi_method), + DEVMETHOD(pci_child_added, xen_pci_child_added_method), DEVMETHOD_END }; @@ -106,3 +109,24 @@ xen_pci_disable_msi_method(device_t dev, pci_write_config(child, msi->msi_location + PCIR_MSI_CTRL, msi->msi_ctrl, 2); } + +static void +xen_pci_child_added_method(device_t dev, device_t child) +{ + struct pci_devinfo *dinfo; + struct physdev_pci_device_add add_pci; + int error; + + dinfo = device_get_ivars(child); + KASSERT((dinfo != NULL), + ("xen_pci_add_child_method called with NULL dinfo")); + + bzero(&add_pci, sizeof(add_pci)); + add_pci.seg = dinfo->cfg.domain; + add_pci.bus = dinfo->cfg.bus; + add_pci.devfn = (dinfo->cfg.slot << 3) | dinfo->cfg.func; + error = HYPERVISOR_physdev_op(PHYSDEVOP_pci_device_add, &add_pci); + if (error) + panic("unable to add device bus %u devfn %u error: %d\n", + add_pci.bus, add_pci.devfn, error); +}