Skip to content

Commit af8f9e8

Browse files
committed
Merge tag 'usb-fixes-v5.10-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/usb into usb-linus
Peter writes: Two bugs for Cadence USB3 gadget driver - TD_SIZE entry at descriptor is error for multiple-trb use case - Possible use uninitialized variables * tag 'usb-fixes-v5.10-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/usb: usb: cdns3: gadget: calculate TD_SIZE based on TD usb: cdns3: gadget: initialize link_trb as NULL
2 parents 09162bc + 40252dd commit af8f9e8

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

drivers/usb/cdns3/gadget.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ static int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep,
11141114
struct cdns3_device *priv_dev = priv_ep->cdns3_dev;
11151115
struct cdns3_request *priv_req;
11161116
struct cdns3_trb *trb;
1117-
struct cdns3_trb *link_trb;
1117+
struct cdns3_trb *link_trb = NULL;
11181118
dma_addr_t trb_dma;
11191119
u32 togle_pcs = 1;
11201120
int sg_iter = 0;
@@ -1193,10 +1193,20 @@ static int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep,
11931193

11941194
/* set incorrect Cycle Bit for first trb*/
11951195
control = priv_ep->pcs ? 0 : TRB_CYCLE;
1196+
trb->length = 0;
1197+
if (priv_dev->dev_ver >= DEV_VER_V2) {
1198+
u16 td_size;
1199+
1200+
td_size = DIV_ROUND_UP(request->length,
1201+
priv_ep->endpoint.maxpacket);
1202+
if (priv_dev->gadget.speed == USB_SPEED_SUPER)
1203+
trb->length = TRB_TDL_SS_SIZE(td_size);
1204+
else
1205+
control |= TRB_TDL_HS_SIZE(td_size);
1206+
}
11961207

11971208
do {
11981209
u32 length;
1199-
u16 td_size = 0;
12001210

12011211
/* fill TRB */
12021212
control |= TRB_TYPE(TRB_NORMAL);
@@ -1208,20 +1218,12 @@ static int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep,
12081218
length = request->length;
12091219
}
12101220

1211-
if (likely(priv_dev->dev_ver >= DEV_VER_V2))
1212-
td_size = DIV_ROUND_UP(length,
1213-
priv_ep->endpoint.maxpacket);
1214-
else if (priv_ep->flags & EP_TDLCHK_EN)
1221+
if (priv_ep->flags & EP_TDLCHK_EN)
12151222
total_tdl += DIV_ROUND_UP(length,
12161223
priv_ep->endpoint.maxpacket);
12171224

1218-
trb->length = cpu_to_le32(TRB_BURST_LEN(priv_ep->trb_burst_size) |
1225+
trb->length |= cpu_to_le32(TRB_BURST_LEN(priv_ep->trb_burst_size) |
12191226
TRB_LEN(length));
1220-
if (priv_dev->gadget.speed == USB_SPEED_SUPER)
1221-
trb->length |= cpu_to_le32(TRB_TDL_SS_SIZE(td_size));
1222-
else
1223-
control |= TRB_TDL_HS_SIZE(td_size);
1224-
12251227
pcs = priv_ep->pcs ? TRB_CYCLE : 0;
12261228

12271229
/*

0 commit comments

Comments
 (0)