Skip to content

Commit 581d667

Browse files
eenurkkaacassis
authored andcommitted
risc-v/mpfs: usb: don't try nonexistent ep int flags
Currently the irq handler checks many reserved bits, which is a waste of resources: 1. pending_rx_ep bit 0 is reserved (always 0) 2. pending_rx_ep and pending_tx_ep have only bits 1, 2, 3 and 4 defined, no need to scan MPFS_USB_NENDPOINTS (9) bits as the rest are reserved Fix this by checking only the relevant bits. Signed-off-by: Eero Nurkkala <[email protected]> Signed-off-by: Jukka Laitinen <[email protected]>
1 parent 21787b4 commit 581d667

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

arch/risc-v/src/mpfs/mpfs_usb.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3467,7 +3467,7 @@ static int mpfs_usb_interrupt(int irq, void *context, void *arg)
34673467

34683468
if (pending_tx_ep != 0)
34693469
{
3470-
for (i = 1; i < MPFS_USB_NENDPOINTS; i++)
3470+
for (i = 1; i < (MPFS_USB_NENDPOINTS / 2 + 1); i++)
34713471
{
34723472
if ((pending_tx_ep & (1 << i)) != 0)
34733473
{
@@ -3478,20 +3478,27 @@ static int mpfs_usb_interrupt(int irq, void *context, void *arg)
34783478

34793479
if (pending_rx_ep != 0)
34803480
{
3481-
for (i = 0; i < MPFS_USB_NENDPOINTS; i++)
3481+
for (i = 1; i < (MPFS_USB_NENDPOINTS / 2 + 1); i++)
34823482
{
34833483
/* Check if dead connections are back in business */
34843484

34853485
if (g_linkdead)
34863486
{
3487-
/* This releases all, which is a problem if only some
3488-
* endpoints are closed on the remote; whereas some
3489-
* are functioning; for example ACM and mass storage;
3490-
* now the functioning one likely marks the closed ones
3491-
* as no longer dead.
3487+
/* This releases all tx counterparts with linkdead flag
3488+
* set, which is a problem if only some endpoints are
3489+
* closed on the remote; whereas some are functioning;
3490+
* for example ACM and mass storage; now the functioning
3491+
* one likely marks the closed ones as no longer dead.
3492+
* Please note that tx counterparts have MPFS_EPIN_START
3493+
* offset on top of the rx eps.
3494+
*
3495+
* For clarity, the eplist[] is as follows:
3496+
* eplist: 0: ep0,
3497+
* 1-4: ep1rx, ep2rx, ep3rx, ep4rx,
3498+
* 5-8: ep1tx, ep2tx, ep3tx, ep4tx
34923499
*/
34933500

3494-
struct mpfs_ep_s *privep = &priv->eplist[i];
3501+
struct mpfs_ep_s *privep = &priv->eplist[i + MPFS_EPIN_START];
34953502
privep->linkdead = 0;
34963503
}
34973504

0 commit comments

Comments
 (0)