Hoist locking giant back up into the ioctl handler
Move the locking back into the ioctl handler. This "fixes" the race where we hve a hot plug event just after the dropping of Giant in pci_find_dbsf, assuming the driver doesn't then call anything that drops and picks up Giant again... It's a little safer since don't think it doesn't, but we lack the tools to know for sure.
This commit is contained in:
parent
57aa9163fd
commit
96b506a57c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=355057
@ -447,8 +447,6 @@ pci_find_dbsf(uint32_t domain, uint8_t bus, uint8_t slot, uint8_t func)
|
||||
{
|
||||
struct pci_devinfo *dinfo = NULL;
|
||||
|
||||
/* Giant because newbus is Giant locked revisit with newbus locking */
|
||||
mtx_lock(&Giant);
|
||||
STAILQ_FOREACH(dinfo, &pci_devq, pci_links) {
|
||||
if ((dinfo->cfg.domain == domain) &&
|
||||
(dinfo->cfg.bus == bus) &&
|
||||
@ -457,7 +455,6 @@ pci_find_dbsf(uint32_t domain, uint8_t bus, uint8_t slot, uint8_t func)
|
||||
break;
|
||||
}
|
||||
}
|
||||
mtx_unlock(&Giant);
|
||||
|
||||
return (dinfo != NULL ? dinfo->cfg.dev : NULL);
|
||||
}
|
||||
|
@ -965,6 +965,9 @@ pci_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *t
|
||||
}
|
||||
|
||||
|
||||
/* Giant because newbus is Giant locked revisit with newbus locking */
|
||||
mtx_lock(&Giant);
|
||||
|
||||
switch (cmd) {
|
||||
case PCIOCGETCONF:
|
||||
#ifdef COMPAT_FREEBSD32
|
||||
@ -1288,8 +1291,10 @@ pci_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *t
|
||||
case PCIOCBARMMAP:
|
||||
pbm = (struct pci_bar_mmap *)data;
|
||||
if ((flag & FWRITE) == 0 &&
|
||||
(pbm->pbm_flags & PCIIO_BAR_MMAP_RW) != 0)
|
||||
return (EPERM);
|
||||
(pbm->pbm_flags & PCIIO_BAR_MMAP_RW) != 0) {
|
||||
error = EPERM;
|
||||
break;
|
||||
}
|
||||
pcidev = pci_find_dbsf(pbm->pbm_sel.pc_domain,
|
||||
pbm->pbm_sel.pc_bus, pbm->pbm_sel.pc_dev,
|
||||
pbm->pbm_sel.pc_func);
|
||||
@ -1301,5 +1306,7 @@ pci_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *t
|
||||
break;
|
||||
}
|
||||
|
||||
mtx_unlock(&Giant);
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user