Skip to content

Commit 9057a64

Browse files
committed
Merge tag 'usb-5.19-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB driver fixes from Greg KH: "Here are some small USB driver fixes and new device ids for 5.19-rc3 They include: - new usb-serial driver device ids - usb gadget driver fixes for reported problems - cdnsp driver fix - dwc3 driver fixes for reported problems - dwc3 driver fix for merge problem that I caused in 5.18 - xhci driver fixes - dwc2 memory leak fix All of these have been in linux-next for a while with no reported issues" * tag 'usb-5.19-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: usb: gadget: f_fs: change ep->ep safe in ffs_epfile_io() usb: gadget: f_fs: change ep->status safe in ffs_epfile_io() xhci: Fix null pointer dereference in resume if xhci has only one roothub USB: fixup for merge issue with "usb: dwc3: Don't switch OTG -> peripheral if extcon is present" usb: cdnsp: Fixed setting last_trb incorrectly usb: gadget: u_ether: fix regression in setting fixed MAC address usb: gadget: lpc32xx_udc: Fix refcount leak in lpc32xx_udc_probe usb: dwc2: Fix memory leak in dwc2_hcd_init usb: dwc3: pci: Restore line lost in merge conflict resolution usb: dwc3: gadget: Fix IN endpoint max packet size allocation USB: serial: option: add support for Cinterion MV31 with new baseline USB: serial: io_ti: add Agilent E5805A support
2 parents 4770094 + 0698f02 commit 9057a64

12 files changed

Lines changed: 80 additions & 54 deletions

File tree

drivers/usb/cdns3/cdnsp-ring.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,13 +1941,16 @@ int cdnsp_queue_bulk_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq)
19411941
}
19421942

19431943
if (enqd_len + trb_buff_len >= full_len) {
1944-
if (need_zero_pkt)
1945-
zero_len_trb = !zero_len_trb;
1946-
1947-
field &= ~TRB_CHAIN;
1948-
field |= TRB_IOC;
1949-
more_trbs_coming = false;
1950-
preq->td.last_trb = ring->enqueue;
1944+
if (need_zero_pkt && !zero_len_trb) {
1945+
zero_len_trb = true;
1946+
} else {
1947+
zero_len_trb = false;
1948+
field &= ~TRB_CHAIN;
1949+
field |= TRB_IOC;
1950+
more_trbs_coming = false;
1951+
need_zero_pkt = false;
1952+
preq->td.last_trb = ring->enqueue;
1953+
}
19511954
}
19521955

19531956
/* Only set interrupt on short packet for OUT endpoints. */
@@ -1962,7 +1965,7 @@ int cdnsp_queue_bulk_tx(struct cdnsp_device *pdev, struct cdnsp_request *preq)
19621965
length_field = TRB_LEN(trb_buff_len) | TRB_TD_SIZE(remainder) |
19631966
TRB_INTR_TARGET(0);
19641967

1965-
cdnsp_queue_trb(pdev, ring, more_trbs_coming | zero_len_trb,
1968+
cdnsp_queue_trb(pdev, ring, more_trbs_coming,
19661969
lower_32_bits(send_addr),
19671970
upper_32_bits(send_addr),
19681971
length_field,

drivers/usb/dwc2/hcd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5190,7 +5190,7 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg)
51905190
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
51915191
if (!res) {
51925192
retval = -EINVAL;
5193-
goto error1;
5193+
goto error2;
51945194
}
51955195
hcd->rsrc_start = res->start;
51965196
hcd->rsrc_len = resource_size(res);

drivers/usb/dwc3/core.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,13 +1644,8 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc)
16441644
* This device property is for kernel internal use only and
16451645
* is expected to be set by the glue code.
16461646
*/
1647-
if (device_property_read_string(dev, "linux,extcon-name", &name) == 0) {
1648-
edev = extcon_get_extcon_dev(name);
1649-
if (!edev)
1650-
return ERR_PTR(-EPROBE_DEFER);
1651-
1652-
return edev;
1653-
}
1647+
if (device_property_read_string(dev, "linux,extcon-name", &name) == 0)
1648+
return extcon_get_extcon_dev(name);
16541649

16551650
/*
16561651
* Try to get an extcon device from the USB PHY controller's "port"

drivers/usb/dwc3/dwc3-pci.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ static const struct property_entry dwc3_pci_intel_phy_charger_detect_properties[
127127
PROPERTY_ENTRY_STRING("dr_mode", "peripheral"),
128128
PROPERTY_ENTRY_BOOL("snps,dis_u2_susphy_quirk"),
129129
PROPERTY_ENTRY_BOOL("linux,phy_charger_detect"),
130+
PROPERTY_ENTRY_BOOL("linux,sysdev_is_parent"),
130131
{}
131132
};
132133

drivers/usb/dwc3/gadget.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2976,6 +2976,7 @@ static int dwc3_gadget_init_in_endpoint(struct dwc3_ep *dep)
29762976
struct dwc3 *dwc = dep->dwc;
29772977
u32 mdwidth;
29782978
int size;
2979+
int maxpacket;
29792980

29802981
mdwidth = dwc3_mdwidth(dwc);
29812982

@@ -2988,21 +2989,24 @@ static int dwc3_gadget_init_in_endpoint(struct dwc3_ep *dep)
29882989
else
29892990
size = DWC31_GTXFIFOSIZ_TXFDEP(size);
29902991

2991-
/* FIFO Depth is in MDWDITH bytes. Multiply */
2992-
size *= mdwidth;
2993-
29942992
/*
2995-
* To meet performance requirement, a minimum TxFIFO size of 3x
2996-
* MaxPacketSize is recommended for endpoints that support burst and a
2997-
* minimum TxFIFO size of 2x MaxPacketSize for endpoints that don't
2998-
* support burst. Use those numbers and we can calculate the max packet
2999-
* limit as below.
2993+
* maxpacket size is determined as part of the following, after assuming
2994+
* a mult value of one maxpacket:
2995+
* DWC3 revision 280A and prior:
2996+
* fifo_size = mult * (max_packet / mdwidth) + 1;
2997+
* maxpacket = mdwidth * (fifo_size - 1);
2998+
*
2999+
* DWC3 revision 290A and onwards:
3000+
* fifo_size = mult * ((max_packet + mdwidth)/mdwidth + 1) + 1
3001+
* maxpacket = mdwidth * ((fifo_size - 1) - 1) - mdwidth;
30003002
*/
3001-
if (dwc->maximum_speed >= USB_SPEED_SUPER)
3002-
size /= 3;
3003+
if (DWC3_VER_IS_PRIOR(DWC3, 290A))
3004+
maxpacket = mdwidth * (size - 1);
30033005
else
3004-
size /= 2;
3006+
maxpacket = mdwidth * ((size - 1) - 1) - mdwidth;
30053007

3008+
/* Functionally, space for one max packet is sufficient */
3009+
size = min_t(int, maxpacket, 1024);
30063010
usb_ep_set_maxpacket_limit(&dep->endpoint, size);
30073011

30083012
dep->endpoint.max_streams = 16;

drivers/usb/gadget/function/f_fs.c

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ struct ffs_ep {
122122
struct usb_endpoint_descriptor *descs[3];
123123

124124
u8 num;
125-
126-
int status; /* P: epfile->mutex */
127125
};
128126

129127
struct ffs_epfile {
@@ -227,6 +225,9 @@ struct ffs_io_data {
227225
bool use_sg;
228226

229227
struct ffs_data *ffs;
228+
229+
int status;
230+
struct completion done;
230231
};
231232

232233
struct ffs_desc_helper {
@@ -707,12 +708,15 @@ static const struct file_operations ffs_ep0_operations = {
707708

708709
static void ffs_epfile_io_complete(struct usb_ep *_ep, struct usb_request *req)
709710
{
711+
struct ffs_io_data *io_data = req->context;
712+
710713
ENTER();
711-
if (req->context) {
712-
struct ffs_ep *ep = _ep->driver_data;
713-
ep->status = req->status ? req->status : req->actual;
714-
complete(req->context);
715-
}
714+
if (req->status)
715+
io_data->status = req->status;
716+
else
717+
io_data->status = req->actual;
718+
719+
complete(&io_data->done);
716720
}
717721

718722
static ssize_t ffs_copy_to_iter(void *data, int data_len, struct iov_iter *iter)
@@ -1050,7 +1054,6 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
10501054
WARN(1, "%s: data_len == -EINVAL\n", __func__);
10511055
ret = -EINVAL;
10521056
} else if (!io_data->aio) {
1053-
DECLARE_COMPLETION_ONSTACK(done);
10541057
bool interrupted = false;
10551058

10561059
req = ep->req;
@@ -1066,7 +1069,8 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
10661069

10671070
io_data->buf = data;
10681071

1069-
req->context = &done;
1072+
init_completion(&io_data->done);
1073+
req->context = io_data;
10701074
req->complete = ffs_epfile_io_complete;
10711075

10721076
ret = usb_ep_queue(ep->ep, req, GFP_ATOMIC);
@@ -1075,25 +1079,31 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
10751079

10761080
spin_unlock_irq(&epfile->ffs->eps_lock);
10771081

1078-
if (wait_for_completion_interruptible(&done)) {
1082+
if (wait_for_completion_interruptible(&io_data->done)) {
1083+
spin_lock_irq(&epfile->ffs->eps_lock);
1084+
if (epfile->ep != ep) {
1085+
ret = -ESHUTDOWN;
1086+
goto error_lock;
1087+
}
10791088
/*
10801089
* To avoid race condition with ffs_epfile_io_complete,
10811090
* dequeue the request first then check
10821091
* status. usb_ep_dequeue API should guarantee no race
10831092
* condition with req->complete callback.
10841093
*/
10851094
usb_ep_dequeue(ep->ep, req);
1086-
wait_for_completion(&done);
1087-
interrupted = ep->status < 0;
1095+
spin_unlock_irq(&epfile->ffs->eps_lock);
1096+
wait_for_completion(&io_data->done);
1097+
interrupted = io_data->status < 0;
10881098
}
10891099

10901100
if (interrupted)
10911101
ret = -EINTR;
1092-
else if (io_data->read && ep->status > 0)
1093-
ret = __ffs_epfile_read_data(epfile, data, ep->status,
1102+
else if (io_data->read && io_data->status > 0)
1103+
ret = __ffs_epfile_read_data(epfile, data, io_data->status,
10941104
&io_data->data);
10951105
else
1096-
ret = ep->status;
1106+
ret = io_data->status;
10971107
goto error_mutex;
10981108
} else if (!(req = usb_ep_alloc_request(ep->ep, GFP_ATOMIC))) {
10991109
ret = -ENOMEM;

drivers/usb/gadget/function/u_ether.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,9 +775,13 @@ struct eth_dev *gether_setup_name(struct usb_gadget *g,
775775
dev->qmult = qmult;
776776
snprintf(net->name, sizeof(net->name), "%s%%d", netname);
777777

778-
if (get_ether_addr(dev_addr, addr))
778+
if (get_ether_addr(dev_addr, addr)) {
779+
net->addr_assign_type = NET_ADDR_RANDOM;
779780
dev_warn(&g->dev,
780781
"using random %s ethernet address\n", "self");
782+
} else {
783+
net->addr_assign_type = NET_ADDR_SET;
784+
}
781785
eth_hw_addr_set(net, addr);
782786
if (get_ether_addr(host_addr, dev->host_mac))
783787
dev_warn(&g->dev,
@@ -844,6 +848,10 @@ struct net_device *gether_setup_name_default(const char *netname)
844848

845849
eth_random_addr(dev->dev_mac);
846850
pr_warn("using random %s ethernet address\n", "self");
851+
852+
/* by default we always have a random MAC address */
853+
net->addr_assign_type = NET_ADDR_RANDOM;
854+
847855
eth_random_addr(dev->host_mac);
848856
pr_warn("using random %s ethernet address\n", "host");
849857

@@ -871,7 +879,6 @@ int gether_register_netdev(struct net_device *net)
871879
dev = netdev_priv(net);
872880
g = dev->gadget;
873881

874-
net->addr_assign_type = NET_ADDR_RANDOM;
875882
eth_hw_addr_set(net, dev->dev_mac);
876883

877884
status = register_netdev(net);
@@ -912,6 +919,7 @@ int gether_set_dev_addr(struct net_device *net, const char *dev_addr)
912919
if (get_ether_addr(dev_addr, new_addr))
913920
return -EINVAL;
914921
memcpy(dev->dev_mac, new_addr, ETH_ALEN);
922+
net->addr_assign_type = NET_ADDR_SET;
915923
return 0;
916924
}
917925
EXPORT_SYMBOL_GPL(gether_set_dev_addr);

drivers/usb/gadget/udc/lpc32xx_udc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3016,6 +3016,7 @@ static int lpc32xx_udc_probe(struct platform_device *pdev)
30163016
}
30173017

30183018
udc->isp1301_i2c_client = isp1301_get_client(isp1301_node);
3019+
of_node_put(isp1301_node);
30193020
if (!udc->isp1301_i2c_client) {
30203021
return -EPROBE_DEFER;
30213022
}

drivers/usb/host/xhci.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,6 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
11071107
{
11081108
u32 command, temp = 0;
11091109
struct usb_hcd *hcd = xhci_to_hcd(xhci);
1110-
struct usb_hcd *secondary_hcd;
11111110
int retval = 0;
11121111
bool comp_timer_running = false;
11131112
bool pending_portevent = false;
@@ -1214,23 +1213,19 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
12141213
* first with the primary HCD, and then with the secondary HCD.
12151214
* If we don't do the same, the host will never be started.
12161215
*/
1217-
if (!usb_hcd_is_primary_hcd(hcd))
1218-
secondary_hcd = hcd;
1219-
else
1220-
secondary_hcd = xhci->shared_hcd;
1221-
12221216
xhci_dbg(xhci, "Initialize the xhci_hcd\n");
1223-
retval = xhci_init(hcd->primary_hcd);
1217+
retval = xhci_init(hcd);
12241218
if (retval)
12251219
return retval;
12261220
comp_timer_running = true;
12271221

12281222
xhci_dbg(xhci, "Start the primary HCD\n");
1229-
retval = xhci_run(hcd->primary_hcd);
1230-
if (!retval && secondary_hcd) {
1223+
retval = xhci_run(hcd);
1224+
if (!retval && xhci->shared_hcd) {
12311225
xhci_dbg(xhci, "Start the secondary HCD\n");
1232-
retval = xhci_run(secondary_hcd);
1226+
retval = xhci_run(xhci->shared_hcd);
12331227
}
1228+
12341229
hcd->state = HC_STATE_SUSPENDED;
12351230
if (xhci->shared_hcd)
12361231
xhci->shared_hcd->state = HC_STATE_SUSPENDED;

drivers/usb/serial/io_ti.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ static const struct usb_device_id edgeport_2port_id_table[] = {
166166
{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_8S) },
167167
{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_416) },
168168
{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_416B) },
169+
{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_E5805A) },
169170
{ }
170171
};
171172

@@ -204,6 +205,7 @@ static const struct usb_device_id id_table_combined[] = {
204205
{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_8S) },
205206
{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_416) },
206207
{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_TI_EDGEPORT_416B) },
208+
{ USB_DEVICE(USB_VENDOR_ID_ION, ION_DEVICE_ID_E5805A) },
207209
{ }
208210
};
209211

0 commit comments

Comments
 (0)