Skip to content

Commit a28dde6

Browse files
committed
Merge tag 'for-usb-linus-2012-01-24' of git://git.kernel.org/pub/scm/linux/kernel/git/sarah/xhci into usb-linus
Sarah writes: USB/xhci: Misc fixes for 3.8. Hi Greg, Here's six patches for xHCI and the USB core. There's a couple of patches to fix xHCI 1.0 field formats, some memory leaks, dead ports, and USB 3.0 remote wakeup disabling. All of these are marked for stable. I know I owe you some re-works of failed stable patches from my last patchset round, but I don't think I'm going to get to them before I head off to Linux Conf Australia tomorrow. Sarah Sharp
2 parents 949db15 + 54a3ac0 commit a28dde6

4 files changed

Lines changed: 68 additions & 22 deletions

File tree

‎drivers/usb/core/hub.c‎

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2838,6 +2838,23 @@ void usb_enable_ltm(struct usb_device *udev)
28382838
EXPORT_SYMBOL_GPL(usb_enable_ltm);
28392839

28402840
#ifdef CONFIG_USB_SUSPEND
2841+
/*
2842+
* usb_disable_function_remotewakeup - disable usb3.0
2843+
* device's function remote wakeup
2844+
* @udev: target device
2845+
*
2846+
* Assume there's only one function on the USB 3.0
2847+
* device and disable remote wake for the first
2848+
* interface. FIXME if the interface association
2849+
* descriptor shows there's more than one function.
2850+
*/
2851+
static int usb_disable_function_remotewakeup(struct usb_device *udev)
2852+
{
2853+
return usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
2854+
USB_REQ_CLEAR_FEATURE, USB_RECIP_INTERFACE,
2855+
USB_INTRF_FUNC_SUSPEND, 0, NULL, 0,
2856+
USB_CTRL_SET_TIMEOUT);
2857+
}
28412858

28422859
/*
28432860
* usb_port_suspend - suspend a usb device's upstream port
@@ -2955,12 +2972,19 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
29552972
dev_dbg(hub->intfdev, "can't suspend port %d, status %d\n",
29562973
port1, status);
29572974
/* paranoia: "should not happen" */
2958-
if (udev->do_remote_wakeup)
2959-
(void) usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
2960-
USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE,
2961-
USB_DEVICE_REMOTE_WAKEUP, 0,
2962-
NULL, 0,
2963-
USB_CTRL_SET_TIMEOUT);
2975+
if (udev->do_remote_wakeup) {
2976+
if (!hub_is_superspeed(hub->hdev)) {
2977+
(void) usb_control_msg(udev,
2978+
usb_sndctrlpipe(udev, 0),
2979+
USB_REQ_CLEAR_FEATURE,
2980+
USB_RECIP_DEVICE,
2981+
USB_DEVICE_REMOTE_WAKEUP, 0,
2982+
NULL, 0,
2983+
USB_CTRL_SET_TIMEOUT);
2984+
} else
2985+
(void) usb_disable_function_remotewakeup(udev);
2986+
2987+
}
29642988

29652989
/* Try to enable USB2 hardware LPM again */
29662990
if (udev->usb2_hw_lpm_capable == 1)
@@ -3052,20 +3076,30 @@ static int finish_port_resume(struct usb_device *udev)
30523076
* udev->reset_resume
30533077
*/
30543078
} else if (udev->actconfig && !udev->reset_resume) {
3055-
le16_to_cpus(&devstatus);
3056-
if (devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP)) {
3057-
status = usb_control_msg(udev,
3058-
usb_sndctrlpipe(udev, 0),
3059-
USB_REQ_CLEAR_FEATURE,
3079+
if (!hub_is_superspeed(udev->parent)) {
3080+
le16_to_cpus(&devstatus);
3081+
if (devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP))
3082+
status = usb_control_msg(udev,
3083+
usb_sndctrlpipe(udev, 0),
3084+
USB_REQ_CLEAR_FEATURE,
30603085
USB_RECIP_DEVICE,
3061-
USB_DEVICE_REMOTE_WAKEUP, 0,
3062-
NULL, 0,
3063-
USB_CTRL_SET_TIMEOUT);
3064-
if (status)
3065-
dev_dbg(&udev->dev,
3066-
"disable remote wakeup, status %d\n",
3067-
status);
3086+
USB_DEVICE_REMOTE_WAKEUP, 0,
3087+
NULL, 0,
3088+
USB_CTRL_SET_TIMEOUT);
3089+
} else {
3090+
status = usb_get_status(udev, USB_RECIP_INTERFACE, 0,
3091+
&devstatus);
3092+
le16_to_cpus(&devstatus);
3093+
if (!status && devstatus & (USB_INTRF_STAT_FUNC_RW_CAP
3094+
| USB_INTRF_STAT_FUNC_RW))
3095+
status =
3096+
usb_disable_function_remotewakeup(udev);
30683097
}
3098+
3099+
if (status)
3100+
dev_dbg(&udev->dev,
3101+
"disable remote wakeup, status %d\n",
3102+
status);
30693103
status = 0;
30703104
}
30713105
return status;

‎drivers/usb/host/pci-quirks.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,7 @@ void usb_enable_xhci_ports(struct pci_dev *xhci_pdev)
780780
"defaulting to EHCI.\n");
781781
dev_warn(&xhci_pdev->dev,
782782
"USB 3.0 devices will work at USB 2.0 speeds.\n");
783+
usb_disable_xhci_ports(xhci_pdev);
783784
return;
784785
}
785786

‎drivers/usb/host/xhci-ring.c‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,7 +1698,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
16981698
faked_port_index + 1);
16991699
if (slot_id && xhci->devs[slot_id])
17001700
xhci_ring_device(xhci, slot_id);
1701-
if (bus_state->port_remote_wakeup && (1 << faked_port_index)) {
1701+
if (bus_state->port_remote_wakeup & (1 << faked_port_index)) {
17021702
bus_state->port_remote_wakeup &=
17031703
~(1 << faked_port_index);
17041704
xhci_test_and_clear_bit(xhci, port_array,
@@ -2589,6 +2589,8 @@ static int handle_tx_event(struct xhci_hcd *xhci,
25892589
(trb_comp_code != COMP_STALL &&
25902590
trb_comp_code != COMP_BABBLE))
25912591
xhci_urb_free_priv(xhci, urb_priv);
2592+
else
2593+
kfree(urb_priv);
25922594

25932595
usb_hcd_unlink_urb_from_ep(bus_to_hcd(urb->dev->bus), urb);
25942596
if ((urb->actual_length != urb->transfer_buffer_length &&
@@ -3108,7 +3110,7 @@ static u32 xhci_v1_0_td_remainder(int running_total, int trb_buff_len,
31083110
* running_total.
31093111
*/
31103112
packets_transferred = (running_total + trb_buff_len) /
3111-
usb_endpoint_maxp(&urb->ep->desc);
3113+
GET_MAX_PACKET(usb_endpoint_maxp(&urb->ep->desc));
31123114

31133115
if ((total_packet_count - packets_transferred) > 31)
31143116
return 31 << 17;
@@ -3642,7 +3644,8 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
36423644
td_len = urb->iso_frame_desc[i].length;
36433645
td_remain_len = td_len;
36443646
total_packet_count = DIV_ROUND_UP(td_len,
3645-
usb_endpoint_maxp(&urb->ep->desc));
3647+
GET_MAX_PACKET(
3648+
usb_endpoint_maxp(&urb->ep->desc)));
36463649
/* A zero-length transfer still involves at least one packet. */
36473650
if (total_packet_count == 0)
36483651
total_packet_count++;
@@ -3664,9 +3667,11 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
36643667
td = urb_priv->td[i];
36653668
for (j = 0; j < trbs_per_td; j++) {
36663669
u32 remainder = 0;
3667-
field = TRB_TBC(burst_count) | TRB_TLBPC(residue);
3670+
field = 0;
36683671

36693672
if (first_trb) {
3673+
field = TRB_TBC(burst_count) |
3674+
TRB_TLBPC(residue);
36703675
/* Queue the isoc TRB */
36713676
field |= TRB_TYPE(TRB_ISOC);
36723677
/* Assume URB_ISO_ASAP is set */

‎include/uapi/linux/usb/ch9.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@
152152
#define USB_INTRF_FUNC_SUSPEND_LP (1 << (8 + 0))
153153
#define USB_INTRF_FUNC_SUSPEND_RW (1 << (8 + 1))
154154

155+
/*
156+
* Interface status, Figure 9-5 USB 3.0 spec
157+
*/
158+
#define USB_INTRF_STAT_FUNC_RW_CAP 1
159+
#define USB_INTRF_STAT_FUNC_RW 2
160+
155161
#define USB_ENDPOINT_HALT 0 /* IN/OUT will STALL */
156162

157163
/* Bit array elements as returned by the USB_REQ_GET_STATUS request. */

0 commit comments

Comments
 (0)