mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-16 19:47:55 +00:00
usb: Change usb_hcd->bandwidth_mutex to a pointer.
Change the bandwith_mutex in struct usb_hcd to a pointer. This will allow the pointer to be shared across usb_hcds for the upcoming work to split the xHCI driver roothub into a USB 2.0/1.1 and a USB 3.0 bus. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
This commit is contained in:
parent
23e0d1066f
commit
d673bfcbff
4 changed files with 26 additions and 17 deletions
|
@ -2191,6 +2191,15 @@ struct usb_hcd *usb_create_hcd (const struct hc_driver *driver,
|
||||||
dev_dbg (dev, "hcd alloc failed\n");
|
dev_dbg (dev, "hcd alloc failed\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
hcd->bandwidth_mutex = kmalloc(sizeof(*hcd->bandwidth_mutex),
|
||||||
|
GFP_KERNEL);
|
||||||
|
if (!hcd->bandwidth_mutex) {
|
||||||
|
kfree(hcd);
|
||||||
|
dev_dbg(dev, "hcd bandwidth mutex alloc failed\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
mutex_init(hcd->bandwidth_mutex);
|
||||||
|
|
||||||
dev_set_drvdata(dev, hcd);
|
dev_set_drvdata(dev, hcd);
|
||||||
kref_init(&hcd->kref);
|
kref_init(&hcd->kref);
|
||||||
|
|
||||||
|
@ -2205,7 +2214,6 @@ struct usb_hcd *usb_create_hcd (const struct hc_driver *driver,
|
||||||
#ifdef CONFIG_USB_SUSPEND
|
#ifdef CONFIG_USB_SUSPEND
|
||||||
INIT_WORK(&hcd->wakeup_work, hcd_resume_work);
|
INIT_WORK(&hcd->wakeup_work, hcd_resume_work);
|
||||||
#endif
|
#endif
|
||||||
mutex_init(&hcd->bandwidth_mutex);
|
|
||||||
|
|
||||||
hcd->driver = driver;
|
hcd->driver = driver;
|
||||||
hcd->product_desc = (driver->product_desc) ? driver->product_desc :
|
hcd->product_desc = (driver->product_desc) ? driver->product_desc :
|
||||||
|
@ -2218,6 +2226,7 @@ static void hcd_release (struct kref *kref)
|
||||||
{
|
{
|
||||||
struct usb_hcd *hcd = container_of (kref, struct usb_hcd, kref);
|
struct usb_hcd *hcd = container_of (kref, struct usb_hcd, kref);
|
||||||
|
|
||||||
|
kfree(hcd->bandwidth_mutex);
|
||||||
kfree(hcd);
|
kfree(hcd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3776,13 +3776,13 @@ static int usb_reset_and_verify_device(struct usb_device *udev)
|
||||||
if (!udev->actconfig)
|
if (!udev->actconfig)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
mutex_lock(&hcd->bandwidth_mutex);
|
mutex_lock(hcd->bandwidth_mutex);
|
||||||
ret = usb_hcd_alloc_bandwidth(udev, udev->actconfig, NULL, NULL);
|
ret = usb_hcd_alloc_bandwidth(udev, udev->actconfig, NULL, NULL);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_warn(&udev->dev,
|
dev_warn(&udev->dev,
|
||||||
"Busted HC? Not enough HCD resources for "
|
"Busted HC? Not enough HCD resources for "
|
||||||
"old configuration.\n");
|
"old configuration.\n");
|
||||||
mutex_unlock(&hcd->bandwidth_mutex);
|
mutex_unlock(hcd->bandwidth_mutex);
|
||||||
goto re_enumerate;
|
goto re_enumerate;
|
||||||
}
|
}
|
||||||
ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
|
ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
|
||||||
|
@ -3793,10 +3793,10 @@ static int usb_reset_and_verify_device(struct usb_device *udev)
|
||||||
dev_err(&udev->dev,
|
dev_err(&udev->dev,
|
||||||
"can't restore configuration #%d (error=%d)\n",
|
"can't restore configuration #%d (error=%d)\n",
|
||||||
udev->actconfig->desc.bConfigurationValue, ret);
|
udev->actconfig->desc.bConfigurationValue, ret);
|
||||||
mutex_unlock(&hcd->bandwidth_mutex);
|
mutex_unlock(hcd->bandwidth_mutex);
|
||||||
goto re_enumerate;
|
goto re_enumerate;
|
||||||
}
|
}
|
||||||
mutex_unlock(&hcd->bandwidth_mutex);
|
mutex_unlock(hcd->bandwidth_mutex);
|
||||||
usb_set_device_state(udev, USB_STATE_CONFIGURED);
|
usb_set_device_state(udev, USB_STATE_CONFIGURED);
|
||||||
|
|
||||||
/* Put interfaces back into the same altsettings as before.
|
/* Put interfaces back into the same altsettings as before.
|
||||||
|
|
|
@ -1284,12 +1284,12 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
|
||||||
/* Make sure we have enough bandwidth for this alternate interface.
|
/* Make sure we have enough bandwidth for this alternate interface.
|
||||||
* Remove the current alt setting and add the new alt setting.
|
* Remove the current alt setting and add the new alt setting.
|
||||||
*/
|
*/
|
||||||
mutex_lock(&hcd->bandwidth_mutex);
|
mutex_lock(hcd->bandwidth_mutex);
|
||||||
ret = usb_hcd_alloc_bandwidth(dev, NULL, iface->cur_altsetting, alt);
|
ret = usb_hcd_alloc_bandwidth(dev, NULL, iface->cur_altsetting, alt);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_info(&dev->dev, "Not enough bandwidth for altsetting %d\n",
|
dev_info(&dev->dev, "Not enough bandwidth for altsetting %d\n",
|
||||||
alternate);
|
alternate);
|
||||||
mutex_unlock(&hcd->bandwidth_mutex);
|
mutex_unlock(hcd->bandwidth_mutex);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1311,10 +1311,10 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
|
||||||
} else if (ret < 0) {
|
} else if (ret < 0) {
|
||||||
/* Re-instate the old alt setting */
|
/* Re-instate the old alt setting */
|
||||||
usb_hcd_alloc_bandwidth(dev, NULL, alt, iface->cur_altsetting);
|
usb_hcd_alloc_bandwidth(dev, NULL, alt, iface->cur_altsetting);
|
||||||
mutex_unlock(&hcd->bandwidth_mutex);
|
mutex_unlock(hcd->bandwidth_mutex);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
mutex_unlock(&hcd->bandwidth_mutex);
|
mutex_unlock(hcd->bandwidth_mutex);
|
||||||
|
|
||||||
/* FIXME drivers shouldn't need to replicate/bugfix the logic here
|
/* FIXME drivers shouldn't need to replicate/bugfix the logic here
|
||||||
* when they implement async or easily-killable versions of this or
|
* when they implement async or easily-killable versions of this or
|
||||||
|
@ -1413,7 +1413,7 @@ int usb_reset_configuration(struct usb_device *dev)
|
||||||
|
|
||||||
config = dev->actconfig;
|
config = dev->actconfig;
|
||||||
retval = 0;
|
retval = 0;
|
||||||
mutex_lock(&hcd->bandwidth_mutex);
|
mutex_lock(hcd->bandwidth_mutex);
|
||||||
/* Make sure we have enough bandwidth for each alternate setting 0 */
|
/* Make sure we have enough bandwidth for each alternate setting 0 */
|
||||||
for (i = 0; i < config->desc.bNumInterfaces; i++) {
|
for (i = 0; i < config->desc.bNumInterfaces; i++) {
|
||||||
struct usb_interface *intf = config->interface[i];
|
struct usb_interface *intf = config->interface[i];
|
||||||
|
@ -1442,7 +1442,7 @@ reset_old_alts:
|
||||||
usb_hcd_alloc_bandwidth(dev, NULL,
|
usb_hcd_alloc_bandwidth(dev, NULL,
|
||||||
alt, intf->cur_altsetting);
|
alt, intf->cur_altsetting);
|
||||||
}
|
}
|
||||||
mutex_unlock(&hcd->bandwidth_mutex);
|
mutex_unlock(hcd->bandwidth_mutex);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
|
retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
|
||||||
|
@ -1451,7 +1451,7 @@ reset_old_alts:
|
||||||
NULL, 0, USB_CTRL_SET_TIMEOUT);
|
NULL, 0, USB_CTRL_SET_TIMEOUT);
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
goto reset_old_alts;
|
goto reset_old_alts;
|
||||||
mutex_unlock(&hcd->bandwidth_mutex);
|
mutex_unlock(hcd->bandwidth_mutex);
|
||||||
|
|
||||||
/* re-init hc/hcd interface/endpoint state */
|
/* re-init hc/hcd interface/endpoint state */
|
||||||
for (i = 0; i < config->desc.bNumInterfaces; i++) {
|
for (i = 0; i < config->desc.bNumInterfaces; i++) {
|
||||||
|
@ -1739,10 +1739,10 @@ free_interfaces:
|
||||||
* host controller will not allow submissions to dropped endpoints. If
|
* host controller will not allow submissions to dropped endpoints. If
|
||||||
* this call fails, the device state is unchanged.
|
* this call fails, the device state is unchanged.
|
||||||
*/
|
*/
|
||||||
mutex_lock(&hcd->bandwidth_mutex);
|
mutex_lock(hcd->bandwidth_mutex);
|
||||||
ret = usb_hcd_alloc_bandwidth(dev, cp, NULL, NULL);
|
ret = usb_hcd_alloc_bandwidth(dev, cp, NULL, NULL);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
mutex_unlock(&hcd->bandwidth_mutex);
|
mutex_unlock(hcd->bandwidth_mutex);
|
||||||
usb_autosuspend_device(dev);
|
usb_autosuspend_device(dev);
|
||||||
goto free_interfaces;
|
goto free_interfaces;
|
||||||
}
|
}
|
||||||
|
@ -1761,11 +1761,11 @@ free_interfaces:
|
||||||
if (!cp) {
|
if (!cp) {
|
||||||
usb_set_device_state(dev, USB_STATE_ADDRESS);
|
usb_set_device_state(dev, USB_STATE_ADDRESS);
|
||||||
usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL);
|
usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL);
|
||||||
mutex_unlock(&hcd->bandwidth_mutex);
|
mutex_unlock(hcd->bandwidth_mutex);
|
||||||
usb_autosuspend_device(dev);
|
usb_autosuspend_device(dev);
|
||||||
goto free_interfaces;
|
goto free_interfaces;
|
||||||
}
|
}
|
||||||
mutex_unlock(&hcd->bandwidth_mutex);
|
mutex_unlock(hcd->bandwidth_mutex);
|
||||||
usb_set_device_state(dev, USB_STATE_CONFIGURED);
|
usb_set_device_state(dev, USB_STATE_CONFIGURED);
|
||||||
|
|
||||||
/* Initialize the new interface structures and the
|
/* Initialize the new interface structures and the
|
||||||
|
|
|
@ -142,7 +142,7 @@ struct usb_hcd {
|
||||||
* bandwidth_mutex should be dropped after a successful control message
|
* bandwidth_mutex should be dropped after a successful control message
|
||||||
* to the device, or resetting the bandwidth after a failed attempt.
|
* to the device, or resetting the bandwidth after a failed attempt.
|
||||||
*/
|
*/
|
||||||
struct mutex bandwidth_mutex;
|
struct mutex *bandwidth_mutex;
|
||||||
|
|
||||||
|
|
||||||
#define HCD_BUFFER_POOLS 4
|
#define HCD_BUFFER_POOLS 4
|
||||||
|
|
Loading…
Add table
Reference in a new issue