mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-10-18 07:01:39 +08:00
Update to FreeBSD head 2016-12-10
Git mirror commit 80c55f08a05ab3b26a73b226ccb56adc3122a55c.
This commit is contained in:
@@ -47,7 +47,6 @@
|
||||
#include <sys/callout.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/priv.h>
|
||||
#include <sys/proc.h>
|
||||
|
||||
#include <dev/usb/usb.h>
|
||||
#include <dev/usb/usbdi.h>
|
||||
@@ -341,12 +340,12 @@ usbd_transfer_setup_sub_malloc(struct usb_setup_params *parm,
|
||||
pc->buffer = USB_ADD_BYTES(buf, y * size);
|
||||
pc->page_start = pg;
|
||||
|
||||
mtx_lock(pc->tag_parent->mtx);
|
||||
USB_MTX_LOCK(pc->tag_parent->mtx);
|
||||
if (usb_pc_load_mem(pc, size, 1 /* synchronous */ )) {
|
||||
mtx_unlock(pc->tag_parent->mtx);
|
||||
USB_MTX_UNLOCK(pc->tag_parent->mtx);
|
||||
return (1); /* failure */
|
||||
}
|
||||
mtx_unlock(pc->tag_parent->mtx);
|
||||
USB_MTX_UNLOCK(pc->tag_parent->mtx);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -983,7 +982,7 @@ usbd_transfer_setup(struct usb_device *udev,
|
||||
return (error);
|
||||
|
||||
/* Protect scratch area */
|
||||
do_unlock = usbd_enum_lock(udev);
|
||||
do_unlock = usbd_ctrl_lock(udev);
|
||||
|
||||
refcount = 0;
|
||||
info = NULL;
|
||||
@@ -1304,7 +1303,7 @@ done:
|
||||
error = parm->err;
|
||||
|
||||
if (do_unlock)
|
||||
usbd_enum_unlock(udev);
|
||||
usbd_ctrl_unlock(udev);
|
||||
|
||||
return (error);
|
||||
}
|
||||
@@ -2292,14 +2291,14 @@ usb_callback_proc(struct usb_proc_msg *_pm)
|
||||
* We exploit the fact that the mutex is the same for all
|
||||
* callbacks that will be called from this thread:
|
||||
*/
|
||||
mtx_lock(info->xfer_mtx);
|
||||
USB_MTX_LOCK(info->xfer_mtx);
|
||||
USB_BUS_LOCK(info->bus);
|
||||
|
||||
/* Continue where we lost track */
|
||||
usb_command_wrapper(&info->done_q,
|
||||
info->done_q.curr);
|
||||
|
||||
mtx_unlock(info->xfer_mtx);
|
||||
USB_MTX_UNLOCK(info->xfer_mtx);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
@@ -2352,7 +2351,7 @@ usbd_callback_wrapper(struct usb_xfer_queue *pq)
|
||||
|
||||
USB_BUS_LOCK_ASSERT(info->bus, MA_OWNED);
|
||||
if ((pq->recurse_3 != 0 || mtx_owned(info->xfer_mtx) == 0) &&
|
||||
SCHEDULER_STOPPED() == 0) {
|
||||
USB_IN_POLLING_MODE_FUNC() == 0) {
|
||||
/*
|
||||
* Cases that end up here:
|
||||
*
|
||||
@@ -3333,7 +3332,9 @@ usbd_transfer_poll(struct usb_xfer **ppxfer, uint16_t max)
|
||||
struct usb_xfer_root *xroot;
|
||||
struct usb_device *udev;
|
||||
struct usb_proc_msg *pm;
|
||||
struct usb_bus *bus;
|
||||
uint16_t n;
|
||||
uint16_t drop_bus_spin;
|
||||
uint16_t drop_bus;
|
||||
uint16_t drop_xfer;
|
||||
|
||||
@@ -3348,38 +3349,47 @@ usbd_transfer_poll(struct usb_xfer **ppxfer, uint16_t max)
|
||||
udev = xroot->udev;
|
||||
if (udev == NULL)
|
||||
continue; /* no USB device */
|
||||
if (udev->bus == NULL)
|
||||
bus = udev->bus;
|
||||
if (bus == NULL)
|
||||
continue; /* no BUS structure */
|
||||
if (udev->bus->methods == NULL)
|
||||
if (bus->methods == NULL)
|
||||
continue; /* no BUS methods */
|
||||
if (udev->bus->methods->xfer_poll == NULL)
|
||||
if (bus->methods->xfer_poll == NULL)
|
||||
continue; /* no poll method */
|
||||
|
||||
/* make sure that the BUS mutex is not locked */
|
||||
drop_bus_spin = 0;
|
||||
drop_bus = 0;
|
||||
while (mtx_owned(&xroot->udev->bus->bus_mtx) && !SCHEDULER_STOPPED()) {
|
||||
mtx_unlock(&xroot->udev->bus->bus_mtx);
|
||||
drop_bus++;
|
||||
}
|
||||
|
||||
/* make sure that the transfer mutex is not locked */
|
||||
drop_xfer = 0;
|
||||
while (mtx_owned(xroot->xfer_mtx) && !SCHEDULER_STOPPED()) {
|
||||
mtx_unlock(xroot->xfer_mtx);
|
||||
drop_xfer++;
|
||||
|
||||
if (USB_IN_POLLING_MODE_FUNC() == 0) {
|
||||
/* make sure that the BUS spin mutex is not locked */
|
||||
while (mtx_owned(&bus->bus_spin_lock)) {
|
||||
mtx_unlock_spin(&bus->bus_spin_lock);
|
||||
drop_bus_spin++;
|
||||
}
|
||||
|
||||
/* make sure that the BUS mutex is not locked */
|
||||
while (mtx_owned(&bus->bus_mtx)) {
|
||||
mtx_unlock(&bus->bus_mtx);
|
||||
drop_bus++;
|
||||
}
|
||||
|
||||
/* make sure that the transfer mutex is not locked */
|
||||
while (mtx_owned(xroot->xfer_mtx)) {
|
||||
mtx_unlock(xroot->xfer_mtx);
|
||||
drop_xfer++;
|
||||
}
|
||||
}
|
||||
|
||||
#if USB_HAVE_PER_BUS_PROCESS
|
||||
/* Make sure cv_signal() and cv_broadcast() is not called */
|
||||
USB_BUS_CONTROL_XFER_PROC(udev->bus)->up_msleep = 0;
|
||||
USB_BUS_EXPLORE_PROC(udev->bus)->up_msleep = 0;
|
||||
USB_BUS_GIANT_PROC(udev->bus)->up_msleep = 0;
|
||||
USB_BUS_NON_GIANT_ISOC_PROC(udev->bus)->up_msleep = 0;
|
||||
USB_BUS_NON_GIANT_BULK_PROC(udev->bus)->up_msleep = 0;
|
||||
#endif
|
||||
USB_BUS_CONTROL_XFER_PROC(bus)->up_msleep = 0;
|
||||
USB_BUS_EXPLORE_PROC(bus)->up_msleep = 0;
|
||||
USB_BUS_GIANT_PROC(bus)->up_msleep = 0;
|
||||
USB_BUS_NON_GIANT_ISOC_PROC(bus)->up_msleep = 0;
|
||||
USB_BUS_NON_GIANT_BULK_PROC(bus)->up_msleep = 0;
|
||||
|
||||
/* poll USB hardware */
|
||||
(udev->bus->methods->xfer_poll) (udev->bus);
|
||||
(bus->methods->xfer_poll) (bus);
|
||||
|
||||
USB_BUS_LOCK(xroot->bus);
|
||||
|
||||
@@ -3407,7 +3417,11 @@ usbd_transfer_poll(struct usb_xfer **ppxfer, uint16_t max)
|
||||
|
||||
/* restore BUS mutex */
|
||||
while (drop_bus--)
|
||||
mtx_lock(&xroot->udev->bus->bus_mtx);
|
||||
mtx_lock(&bus->bus_mtx);
|
||||
|
||||
/* restore BUS spin mutex */
|
||||
while (drop_bus_spin--)
|
||||
mtx_lock_spin(&bus->bus_spin_lock);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user