Page MenuHomeFreeBSD

D27615.id80879.diff
No OneTemporary

D27615.id80879.diff

Index: head/sys/dev/pci/pci_iov.c
===================================================================
--- head/sys/dev/pci/pci_iov.c
+++ head/sys/dev/pci/pci_iov.c
@@ -95,6 +95,7 @@
nvlist_t **driver_schema);
static void pci_iov_build_vf_schema(nvlist_t *schema,
nvlist_t **driver_schema);
+static int pci_iov_delete_iov_children(struct pci_devinfo *dinfo);
static nvlist_t *pci_iov_get_pf_subsystem_schema(void);
static nvlist_t *pci_iov_get_vf_subsystem_schema(void);
@@ -191,6 +192,7 @@
{
struct pci_devinfo *dinfo;
struct pcicfg_iov *iov;
+ int error;
mtx_lock(&Giant);
dinfo = device_get_ivars(dev);
@@ -201,11 +203,17 @@
return (0);
}
- if (iov->iov_num_vfs != 0 || iov->iov_flags & IOV_BUSY) {
+ if ((iov->iov_flags & IOV_BUSY) != 0) {
mtx_unlock(&Giant);
return (EBUSY);
}
+ error = pci_iov_delete_iov_children(dinfo);
+ if (error != 0) {
+ mtx_unlock(&Giant);
+ return (error);
+ }
+
dinfo->cfg.iov = NULL;
if (iov->iov_cdev) {
@@ -823,31 +831,20 @@
}
static int
-pci_iov_delete(struct cdev *cdev)
+pci_iov_delete_iov_children(struct pci_devinfo *dinfo)
{
device_t bus, dev, vf, *devlist;
- struct pci_devinfo *dinfo;
struct pcicfg_iov *iov;
int i, error, devcount;
uint32_t iov_ctl;
- mtx_lock(&Giant);
- dinfo = cdev->si_drv1;
+ mtx_assert(&Giant, MA_OWNED);
+
iov = dinfo->cfg.iov;
dev = dinfo->cfg.dev;
bus = device_get_parent(dev);
devlist = NULL;
- if (iov->iov_flags & IOV_BUSY) {
- mtx_unlock(&Giant);
- return (EBUSY);
- }
-
- if (iov->iov_num_vfs == 0) {
- mtx_unlock(&Giant);
- return (ECHILD);
- }
-
iov->iov_flags |= IOV_BUSY;
error = device_get_children(bus, &devlist, &devcount);
@@ -905,6 +902,32 @@
out:
free(devlist, M_TEMP);
iov->iov_flags &= ~IOV_BUSY;
+ return (error);
+}
+
+static int
+pci_iov_delete(struct cdev *cdev)
+{
+ struct pci_devinfo *dinfo;
+ struct pcicfg_iov *iov;
+ int error;
+
+ mtx_lock(&Giant);
+ dinfo = cdev->si_drv1;
+ iov = dinfo->cfg.iov;
+
+ if ((iov->iov_flags & IOV_BUSY) != 0) {
+ error = EBUSY;
+ goto out;
+ }
+ if (iov->iov_num_vfs == 0) {
+ error = ECHILD;
+ goto out;
+ }
+
+ error = pci_iov_delete_iov_children(dinfo);
+
+out:
mtx_unlock(&Giant);
return (error);
}

File Metadata

Mime Type
text/plain
Expires
Mon, Apr 13, 10:47 AM (3 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31406618
Default Alt Text
D27615.id80879.diff (2 KB)

Event Timeline