Skip to contentSkip to conversation

usb: dwc3: Add error logs for unknown endpoint events

PATCH Superseded Roy Luo 2 participants 3 messages May 3, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Roy Luo

author
#0 lore raw

PATCH 1/1 usb: dwc3: Add error logs for unknown endpoint events

In cases where the controller somehow fails to write to event buffer memory (e.g. due to incorrect MMU config), the driver would receive all-zero dwc3 events. However, the abnormal event is silently dropped as a regular ep0out event.
Add error logs when an unknown endpoint event is received to highlight the anamoly.

---
 drivers/usb/dwc3/ep0.c    | 2 ++
 drivers/usb/dwc3/gadget.c | 2 ++
 2 files changed, 4 insertions(+)
drivers/usb/dwc3/ep0.c +2 -0
index 953b752a5052..8c9560a9999e 100644
@@ -1207,5 +1207,7 @@ void dwc3_ep0_interrupt(struct dwc3 *dwc,
 			dep->flags &= ~DWC3_EP_TRANSFER_STARTED;
 		}
 		break;
+	default:
+		dev_err(dwc->dev, "unknown endpoint event %d\n", event->endpoint_event);
 	}
 }
drivers/usb/dwc3/gadget.c +2 -0
index c0ca4d12f95d..054f6f297e17 100644
@@ -3803,6 +3803,8 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc,
 		break;
 	case DWC3_DEPEVT_RXTXFIFOEVT:
 		break;
+	default:
+		dev_err(dwc->dev, "unknown endpoint event %d\n", event->endpoint_event);
 	}
 }
 

base-commit: c8c655c34e33544aec9d64b660872ab33c29b5f1

Signature · 1 line
2.40.1.495.gc816e09b53d-goog
maintainer
#1 lore raw
Quoted 4 lines · Roy Luo

In cases where the controller somehow fails to write to event buffer memory (e.g. due to incorrect MMU config), the driver would receive all-zero dwc3 events. However, the abnormal event is silently dropped as a regular ep0out event.

When it does happen, will these prints flood the dmesg log?

Quoted 2 lines

Add error logs when an unknown endpoint event is received to highlight the anamoly.

anomaly?

Quoted 12 lines
---
 drivers/usb/dwc3/ep0.c    | 2 ++
 drivers/usb/dwc3/gadget.c | 2 ++
 2 files changed, 4 insertions(+)
drivers/usb/dwc3/ep0.c +0 -0
index 953b752a5052..8c9560a9999e 100644

drivers/usb/dwc3/ep0.c void dwc3_ep0_interrupt(struct dwc3 *dwc, · line 1211

Quoted 5 lines
drivers/usb/dwc3/ep0.c +2 -0
@@ -1207,5 +1207,7 @@ void dwc3_ep0_interrupt(struct dwc3 *dwc,
 			dep->flags &= ~DWC3_EP_TRANSFER_STARTED;
 		}
 		break;
+	default:
+		dev_err(dwc->dev, "unknown endpoint event %d\n", event->endpoint_event);

Can we add a break here?

drivers/usb/dwc3/gadget.c static void dwc3_endpoint_interrupt(struct dwc3 *dwc, · line 3807

Quoted 12 lines
drivers/usb/dwc3/ep0.c +0 -0
 	}
 }
drivers/usb/dwc3/gadget.c +2 -0
index c0ca4d12f95d..054f6f297e17 100644
@@ -3803,6 +3803,8 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc,
 		break;
 	case DWC3_DEPEVT_RXTXFIFOEVT:
 		break;
+	default:
+		dev_err(dwc->dev, "unknown endpoint event %d\n", event->endpoint_event);

and here too.

Quoted 8 lines
drivers/usb/dwc3/gadget.c +0 -0
 	}
 }
 

base-commit: c8c655c34e33544aec9d64b660872ab33c29b5f1

Signature · 1 line
2.40.1.495.gc816e09b53d-goog

Thanks,
Thinh

author
#2 lore raw
Quoted 8 lines · Thinh Nguyen
Quoted 4 lines · Roy Luo

In cases where the controller somehow fails to write to event buffer memory (e.g. due to incorrect MMU config), the driver would receive all-zero dwc3 events. However, the abnormal event is silently dropped as a regular ep0out event.

When it does happen, will these prints flood the dmesg log?

When this does happen, the driver cannot do the required actions to move things forward in correspondence to the HW events (e.g. Xfercomplete, reset, connection done, etc.).
Therefore, the controller might throw some events in the beginning but it would cease quickly until the host does a new move that triggers the controller to send new events.

Quoted 5 lines
Quoted 3 lines

Add error logs when an unknown endpoint event is received to highlight the anamoly.

anomaly?

Thanks for catching this typo, will fix it in the next patchset.

Quoted 8 lines
Quoted 8 lines
---
 drivers/usb/dwc3/ep0.c    | 2 ++
 drivers/usb/dwc3/gadget.c | 2 ++
 2 files changed, 4 insertions(+)
Quoted 12 lines

drivers/usb/dwc3/ep0.c void dwc3_ep0_interrupt(struct dwc3 *dwc, · line 1211

Quoted 10 lines
drivers/usb/dwc3/ep0.c +2 -0
index 953b752a5052..8c9560a9999e 100644
@@ -1207,5 +1207,7 @@ void dwc3_ep0_interrupt(struct dwc3 *dwc,
                      dep->flags &= ~DWC3_EP_TRANSFER_STARTED;
              }
              break;
+     default:
+             dev_err(dwc->dev, "unknown endpoint event %d\n", event->endpoint_event);

Can we add a break here?

Sure ,will do it in the next patchset.

Quoted 15 lines

drivers/usb/dwc3/gadget.c static void dwc3_endpoint_interrupt(struct dwc3 *dwc, · line 3807

Quoted 13 lines
drivers/usb/dwc3/ep0.c +0 -0
      }
 }
drivers/usb/dwc3/gadget.c +2 -0
index c0ca4d12f95d..054f6f297e17 100644
@@ -3803,6 +3803,8 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc,
              break;
      case DWC3_DEPEVT_RXTXFIFOEVT:
              break;
+     default:
+             dev_err(dwc->dev, "unknown endpoint event %d\n", event->endpoint_event);

and here too.

Sure ,will do.

Quoted 5 lines
Quoted 5 lines
drivers/usb/dwc3/gadget.c +0 -0
      }
 }
 
Quoted 7 lines
Quoted 4 lines

base-commit: c8c655c34e33544aec9d64b660872ab33c29b5f1 --
2.40.1.495.gc816e09b53d-goog

Thanks,
Thinh

Regards,
Roy Luo