From owner-svn-src-head@FreeBSD.ORG Tue Mar 10 23:27:15 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 22C3DB04; Tue, 10 Mar 2015 23:27:15 +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 E87533DA; Tue, 10 Mar 2015 23:27:14 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t2ANREcm010771; Tue, 10 Mar 2015 23:27:14 GMT (envelope-from rstone@FreeBSD.org) Received: (from rstone@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t2ANREmU010768; Tue, 10 Mar 2015 23:27:14 GMT (envelope-from rstone@FreeBSD.org) Message-Id: <201503102327.t2ANREmU010768@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: rstone set sender to rstone@FreeBSD.org using -f From: Ryan Stone Date: Tue, 10 Mar 2015 23:27:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r279868 - in head/sys: dev/pci kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Mar 2015 23:27:15 -0000 Author: rstone Date: Tue Mar 10 23:27:13 2015 New Revision: 279868 URL: https://svnweb.freebsd.org/changeset/base/279868 Log: Fix SR-IOV passthrough devices to allow ppt to attach A late change to the SR-IOV infrastructure broke passthrough of VFs. device_set_devclass() was being used to try to force the ppt driver to attach to the device, but this didn't work because the DF_FIXEDCLASS flag wasn't being set on the device, so the ppt driver probe routine would not match when it returned BUS_NOWILDCARD. Fix this by adding a new device function that both sets the devclass and sets the DF_FIXEDCLASS flag, and use that to force the ppt driver to attach to VFs. Differential Revision: https://reviews.freebsd.org/D2041 Reviewed by: jhb MFC after: 3 weeks Modified: head/sys/dev/pci/pci_iov.c head/sys/kern/subr_bus.c head/sys/sys/bus.h Modified: head/sys/dev/pci/pci_iov.c ============================================================================== --- head/sys/dev/pci/pci_iov.c Tue Mar 10 22:38:10 2015 (r279867) +++ head/sys/dev/pci/pci_iov.c Tue Mar 10 23:27:13 2015 (r279868) @@ -586,7 +586,7 @@ pci_iov_enumerate_vfs(struct pci_devinfo * VFs. */ if (nvlist_get_bool(iov_config, "passthrough")) - device_set_devclass(vf, "ppt"); + device_set_devclass_fixed(vf, "ppt"); vfinfo = device_get_ivars(vf); Modified: head/sys/kern/subr_bus.c ============================================================================== --- head/sys/kern/subr_bus.c Tue Mar 10 22:38:10 2015 (r279867) +++ head/sys/kern/subr_bus.c Tue Mar 10 23:27:13 2015 (r279868) @@ -2683,6 +2683,25 @@ device_set_devclass(device_t dev, const } /** + * @brief Set the devclass of a device and mark the devclass fixed. + * @see device_set_devclass() + */ +int +device_set_devclass_fixed(device_t dev, const char *classname) +{ + int error; + + if (classname == NULL) + return (EINVAL); + + error = device_set_devclass(dev, classname); + if (error) + return (error); + dev->flags |= DF_FIXEDCLASS; + return (0); +} + +/** * @brief Set the driver of a device * * @retval 0 success Modified: head/sys/sys/bus.h ============================================================================== --- head/sys/sys/bus.h Tue Mar 10 22:38:10 2015 (r279867) +++ head/sys/sys/bus.h Tue Mar 10 23:27:13 2015 (r279868) @@ -522,6 +522,7 @@ void device_quiet(device_t dev); void device_set_desc(device_t dev, const char* desc); void device_set_desc_copy(device_t dev, const char* desc); int device_set_devclass(device_t dev, const char *classname); +int device_set_devclass_fixed(device_t dev, const char *classname); int device_set_driver(device_t dev, driver_t *driver); void device_set_flags(device_t dev, u_int32_t flags); void device_set_softc(device_t dev, void *softc);