Skip to content

Commit b62dabf

Browse files
committed
Merge tag 'usb-4.6-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB driver fixes from Greg KH: "Here are some small USB fixes for 4.6-rc4. Mostly xhci fixes for reported issues, a UAS bug that has hit a number of people, including stable tree users, and a few other minor things. All have been in linux-next for a while with no reported issues" * tag 'usb-4.6-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: usb: hcd: out of bounds access in for_each_companion USB: uas: Add a new NO_REPORT_LUNS quirk USB: uas: Limit qdepth at the scsi-host level doc: usb: Fix typo in gadget_multi documentation usb: host: xhci-plat: Make enum xhci_plat_type start at a non zero value xhci: fix 10 second timeout on removal of PCI hotpluggable xhci controllers usb: xhci: fix wild pointers in xhci_mem_cleanup usb: host: xhci-plat: fix cannot work if R-Car Gen2/3 run on above 4GB phys usb: host: xhci: add a new quirk XHCI_NO_64BIT_SUPPORT xhci: resume USB 3 roothub first usb: xhci: applying XHCI_PME_STUCK_QUIRK to Intel BXT B0 host cdc-acm: fix crash if flushed with nothing buffered
2 parents 306a63b + e86103a commit b62dabf

File tree

15 files changed

+94
-13
lines changed

15 files changed

+94
-13
lines changed

Documentation/kernel-parameters.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4077,6 +4077,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
40774077
sector if the number is odd);
40784078
i = IGNORE_DEVICE (don't bind to this
40794079
device);
4080+
j = NO_REPORT_LUNS (don't use report luns
4081+
command, uas only);
40804082
l = NOT_LOCKABLE (don't try to lock and
40814083
unlock ejectable media);
40824084
m = MAX_SECTORS_64 (don't transfer more

Documentation/usb/gadget_multi.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ For the gadget two work under Windows two conditions have to be met:
4343
First of all, Windows need to detect the gadget as an USB composite
4444
gadget which on its own have some conditions[4]. If they are met,
4545
Windows lets USB Generic Parent Driver[5] handle the device which then
46-
tries to much drivers for each individual interface (sort of, don't
46+
tries to match drivers for each individual interface (sort of, don't
4747
get into too many details).
4848

4949
The good news is: you do not have to worry about most of the

drivers/usb/class/cdc-acm.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,11 +744,15 @@ static void acm_tty_flush_chars(struct tty_struct *tty)
744744
int err;
745745
unsigned long flags;
746746

747+
if (!cur) /* nothing to do */
748+
return;
749+
747750
acm->putbuffer = NULL;
748751
err = usb_autopm_get_interface_async(acm->control);
749752
spin_lock_irqsave(&acm->write_lock, flags);
750753
if (err < 0) {
751754
cur->use = 0;
755+
acm->putbuffer = cur;
752756
goto out;
753757
}
754758

drivers/usb/core/hcd-pci.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ static void for_each_companion(struct pci_dev *pdev, struct usb_hcd *hcd,
7373
if (companion->bus != pdev->bus ||
7474
PCI_SLOT(companion->devfn) != slot)
7575
continue;
76+
77+
/*
78+
* Companion device should be either UHCI,OHCI or EHCI host
79+
* controller, otherwise skip.
80+
*/
81+
if (companion->class != CL_UHCI && companion->class != CL_OHCI &&
82+
companion->class != CL_EHCI)
83+
continue;
84+
7685
companion_hcd = pci_get_drvdata(companion);
7786
if (!companion_hcd || !companion_hcd->self.root_hub)
7887
continue;

drivers/usb/host/xhci-mem.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,6 +1861,12 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
18611861
kfree(xhci->rh_bw);
18621862
kfree(xhci->ext_caps);
18631863

1864+
xhci->usb2_ports = NULL;
1865+
xhci->usb3_ports = NULL;
1866+
xhci->port_array = NULL;
1867+
xhci->rh_bw = NULL;
1868+
xhci->ext_caps = NULL;
1869+
18641870
xhci->page_size = 0;
18651871
xhci->page_shift = 0;
18661872
xhci->bus_state[0].bus_suspended = 0;

drivers/usb/host/xhci-pci.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI 0xa12f
4949
#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI 0x9d2f
5050
#define PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI 0x0aa8
51+
#define PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI 0x1aa8
5152

5253
static const char hcd_name[] = "xhci_hcd";
5354

@@ -155,7 +156,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
155156
(pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI ||
156157
pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI ||
157158
pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
158-
pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI)) {
159+
pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI ||
160+
pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI)) {
159161
xhci->quirks |= XHCI_PME_STUCK_QUIRK;
160162
}
161163
if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
@@ -302,6 +304,7 @@ static void xhci_pci_remove(struct pci_dev *dev)
302304
struct xhci_hcd *xhci;
303305

304306
xhci = hcd_to_xhci(pci_get_drvdata(dev));
307+
xhci->xhc_state |= XHCI_STATE_REMOVING;
305308
if (xhci->shared_hcd) {
306309
usb_remove_hcd(xhci->shared_hcd);
307310
usb_put_hcd(xhci->shared_hcd);

drivers/usb/host/xhci-plat.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,25 @@ static const struct xhci_driver_overrides xhci_plat_overrides __initconst = {
3939

4040
static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
4141
{
42+
struct usb_hcd *hcd = xhci_to_hcd(xhci);
43+
4244
/*
4345
* As of now platform drivers don't provide MSI support so we ensure
4446
* here that the generic code does not try to make a pci_dev from our
4547
* dev struct in order to setup MSI
4648
*/
4749
xhci->quirks |= XHCI_PLAT;
50+
51+
/*
52+
* On R-Car Gen2 and Gen3, the AC64 bit (bit 0) of HCCPARAMS1 is set
53+
* to 1. However, these SoCs don't support 64-bit address memory
54+
* pointers. So, this driver clears the AC64 bit of xhci->hcc_params
55+
* to call dma_set_coherent_mask(dev, DMA_BIT_MASK(32)) in
56+
* xhci_gen_setup().
57+
*/
58+
if (xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2) ||
59+
xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_RENESAS_RCAR_GEN3))
60+
xhci->quirks |= XHCI_NO_64BIT_SUPPORT;
4861
}
4962

5063
/* called during probe() after chip reset completes */

drivers/usb/host/xhci-plat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "xhci.h" /* for hcd_to_xhci() */
1515

1616
enum xhci_plat_type {
17-
XHCI_PLAT_TYPE_MARVELL_ARMADA,
17+
XHCI_PLAT_TYPE_MARVELL_ARMADA = 1,
1818
XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2,
1919
XHCI_PLAT_TYPE_RENESAS_RCAR_GEN3,
2020
};

drivers/usb/host/xhci-ring.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4004,7 +4004,8 @@ static int queue_command(struct xhci_hcd *xhci, struct xhci_command *cmd,
40044004
int reserved_trbs = xhci->cmd_ring_reserved_trbs;
40054005
int ret;
40064006

4007-
if (xhci->xhc_state) {
4007+
if ((xhci->xhc_state & XHCI_STATE_DYING) ||
4008+
(xhci->xhc_state & XHCI_STATE_HALTED)) {
40084009
xhci_dbg(xhci, "xHCI dying or halted, can't queue_command\n");
40094010
return -ESHUTDOWN;
40104011
}

drivers/usb/host/xhci.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ static int xhci_start(struct xhci_hcd *xhci)
147147
"waited %u microseconds.\n",
148148
XHCI_MAX_HALT_USEC);
149149
if (!ret)
150-
xhci->xhc_state &= ~(XHCI_STATE_HALTED | XHCI_STATE_DYING);
150+
/* clear state flags. Including dying, halted or removing */
151+
xhci->xhc_state = 0;
151152

152153
return ret;
153154
}
@@ -1108,8 +1109,8 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
11081109
/* Resume root hubs only when have pending events. */
11091110
status = readl(&xhci->op_regs->status);
11101111
if (status & STS_EINT) {
1111-
usb_hcd_resume_root_hub(hcd);
11121112
usb_hcd_resume_root_hub(xhci->shared_hcd);
1113+
usb_hcd_resume_root_hub(hcd);
11131114
}
11141115
}
11151116

@@ -1124,10 +1125,10 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
11241125

11251126
/* Re-enable port polling. */
11261127
xhci_dbg(xhci, "%s: starting port polling.\n", __func__);
1127-
set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
1128-
usb_hcd_poll_rh_status(hcd);
11291128
set_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags);
11301129
usb_hcd_poll_rh_status(xhci->shared_hcd);
1130+
set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
1131+
usb_hcd_poll_rh_status(hcd);
11311132

11321133
return retval;
11331134
}
@@ -2773,7 +2774,8 @@ int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
27732774
if (ret <= 0)
27742775
return ret;
27752776
xhci = hcd_to_xhci(hcd);
2776-
if (xhci->xhc_state & XHCI_STATE_DYING)
2777+
if ((xhci->xhc_state & XHCI_STATE_DYING) ||
2778+
(xhci->xhc_state & XHCI_STATE_REMOVING))
27772779
return -ENODEV;
27782780

27792781
xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
@@ -3820,7 +3822,7 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev,
38203822

38213823
mutex_lock(&xhci->mutex);
38223824

3823-
if (xhci->xhc_state) /* dying or halted */
3825+
if (xhci->xhc_state) /* dying, removing or halted */
38243826
goto out;
38253827

38263828
if (!udev->slot_id) {
@@ -4948,6 +4950,16 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
49484950
return retval;
49494951
xhci_dbg(xhci, "Reset complete\n");
49504952

4953+
/*
4954+
* On some xHCI controllers (e.g. R-Car SoCs), the AC64 bit (bit 0)
4955+
* of HCCPARAMS1 is set to 1. However, the xHCs don't support 64-bit
4956+
* address memory pointers actually. So, this driver clears the AC64
4957+
* bit of xhci->hcc_params to call dma_set_coherent_mask(dev,
4958+
* DMA_BIT_MASK(32)) in this xhci_gen_setup().
4959+
*/
4960+
if (xhci->quirks & XHCI_NO_64BIT_SUPPORT)
4961+
xhci->hcc_params &= ~BIT(0);
4962+
49514963
/* Set dma_mask and coherent_dma_mask to 64-bits,
49524964
* if xHC supports 64-bit addressing */
49534965
if (HCC_64BIT_ADDR(xhci->hcc_params) &&

drivers/usb/host/xhci.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,6 +1605,7 @@ struct xhci_hcd {
16051605
*/
16061606
#define XHCI_STATE_DYING (1 << 0)
16071607
#define XHCI_STATE_HALTED (1 << 1)
1608+
#define XHCI_STATE_REMOVING (1 << 2)
16081609
/* Statistics */
16091610
int error_bitmask;
16101611
unsigned int quirks;
@@ -1641,6 +1642,7 @@ struct xhci_hcd {
16411642
#define XHCI_PME_STUCK_QUIRK (1 << 20)
16421643
#define XHCI_MTK_HOST (1 << 21)
16431644
#define XHCI_SSIC_PORT_UNUSED (1 << 22)
1645+
#define XHCI_NO_64BIT_SUPPORT (1 << 23)
16441646
unsigned int num_active_eps;
16451647
unsigned int limit_active_eps;
16461648
/* There are two roothubs to keep track of bus suspend info for */

drivers/usb/storage/uas.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* USB Attached SCSI
33
* Note that this is not the same as the USB Mass Storage driver
44
*
5-
* Copyright Hans de Goede <hdegoede@redhat.com> for Red Hat, Inc. 2013 - 2014
5+
* Copyright Hans de Goede <hdegoede@redhat.com> for Red Hat, Inc. 2013 - 2016
66
* Copyright Matthew Wilcox for Intel Corp, 2010
77
* Copyright Sarah Sharp for Intel Corp, 2010
88
*
@@ -781,6 +781,17 @@ static int uas_eh_bus_reset_handler(struct scsi_cmnd *cmnd)
781781
return SUCCESS;
782782
}
783783

784+
static int uas_target_alloc(struct scsi_target *starget)
785+
{
786+
struct uas_dev_info *devinfo = (struct uas_dev_info *)
787+
dev_to_shost(starget->dev.parent)->hostdata;
788+
789+
if (devinfo->flags & US_FL_NO_REPORT_LUNS)
790+
starget->no_report_luns = 1;
791+
792+
return 0;
793+
}
794+
784795
static int uas_slave_alloc(struct scsi_device *sdev)
785796
{
786797
struct uas_dev_info *devinfo =
@@ -824,14 +835,14 @@ static int uas_slave_configure(struct scsi_device *sdev)
824835
if (devinfo->flags & US_FL_BROKEN_FUA)
825836
sdev->broken_fua = 1;
826837

827-
scsi_change_queue_depth(sdev, devinfo->qdepth - 2);
828838
return 0;
829839
}
830840

831841
static struct scsi_host_template uas_host_template = {
832842
.module = THIS_MODULE,
833843
.name = "uas",
834844
.queuecommand = uas_queuecommand,
845+
.target_alloc = uas_target_alloc,
835846
.slave_alloc = uas_slave_alloc,
836847
.slave_configure = uas_slave_configure,
837848
.eh_abort_handler = uas_eh_abort_handler,
@@ -956,6 +967,12 @@ static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id)
956967
if (result)
957968
goto set_alt0;
958969

970+
/*
971+
* 1 tag is reserved for untagged commands +
972+
* 1 tag to avoid off by one errors in some bridge firmwares
973+
*/
974+
shost->can_queue = devinfo->qdepth - 2;
975+
959976
usb_set_intfdata(intf, shost);
960977
result = scsi_add_host(shost, &intf->dev);
961978
if (result)

drivers/usb/storage/unusual_uas.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ UNUSUAL_DEV(0x0bc2, 0x3312, 0x0000, 0x9999,
6464
USB_SC_DEVICE, USB_PR_DEVICE, NULL,
6565
US_FL_NO_ATA_1X),
6666

67+
/* Reported-by: David Webb <djw@noc.ac.uk> */
68+
UNUSUAL_DEV(0x0bc2, 0x331a, 0x0000, 0x9999,
69+
"Seagate",
70+
"Expansion Desk",
71+
USB_SC_DEVICE, USB_PR_DEVICE, NULL,
72+
US_FL_NO_REPORT_LUNS),
73+
6774
/* Reported-by: Hans de Goede <hdegoede@redhat.com> */
6875
UNUSUAL_DEV(0x0bc2, 0x3320, 0x0000, 0x9999,
6976
"Seagate",

drivers/usb/storage/usb.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ void usb_stor_adjust_quirks(struct usb_device *udev, unsigned long *fflags)
482482
US_FL_NO_READ_DISC_INFO | US_FL_NO_READ_CAPACITY_16 |
483483
US_FL_INITIAL_READ10 | US_FL_WRITE_CACHE |
484484
US_FL_NO_ATA_1X | US_FL_NO_REPORT_OPCODES |
485-
US_FL_MAX_SECTORS_240);
485+
US_FL_MAX_SECTORS_240 | US_FL_NO_REPORT_LUNS);
486486

487487
p = quirks;
488488
while (*p) {
@@ -532,6 +532,9 @@ void usb_stor_adjust_quirks(struct usb_device *udev, unsigned long *fflags)
532532
case 'i':
533533
f |= US_FL_IGNORE_DEVICE;
534534
break;
535+
case 'j':
536+
f |= US_FL_NO_REPORT_LUNS;
537+
break;
535538
case 'l':
536539
f |= US_FL_NOT_LOCKABLE;
537540
break;

include/linux/usb_usual.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979
/* Cannot handle MI_REPORT_SUPPORTED_OPERATION_CODES */ \
8080
US_FLAG(MAX_SECTORS_240, 0x08000000) \
8181
/* Sets max_sectors to 240 */ \
82+
US_FLAG(NO_REPORT_LUNS, 0x10000000) \
83+
/* Cannot handle REPORT_LUNS */ \
8284

8385
#define US_FLAG(name, value) US_FL_##name = value ,
8486
enum { US_DO_ALL_FLAGS };

0 commit comments

Comments
 (0)