[PATCH] dt-bindings: usb: dwc3: Add usb-psy-name string

2021-03-27 Thread Ray Chi
This commit adds documentation for usb-psy-name string.
The string will use to find the power supply interface.
And then, DWC3 can use the interface to control charing
current with USB state and USB speed.

Signed-off-by: Ray Chi 
---
 Documentation/devicetree/bindings/usb/snps,dwc3.yaml | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/snps,dwc3.yaml 
b/Documentation/devicetree/bindings/usb/snps,dwc3.yaml
index 2247da77eac1..ad62f4552fad 100644
--- a/Documentation/devicetree/bindings/usb/snps,dwc3.yaml
+++ b/Documentation/devicetree/bindings/usb/snps,dwc3.yaml
@@ -301,6 +301,13 @@ properties:
 items:
   enum: [1, 4, 8, 16, 32, 64, 128, 256]
 
+  usb-psy-name:
+description:
+  Contains the name for power supply interface. To follow
+  BC1.2 specification, DWC3 could use power supply interface
+  to control current with corresponding USB state and USB speed.
+minItems: 1
+
 unevaluatedProperties: false
 
 required:
-- 
2.31.0.291.g576ba9dcdaf-goog



[PATCH 2/2] power: supply: Fix build error when CONFIG_POWER_SUPPLY is not enabled.

2021-03-27 Thread Ray Chi
The build error happens when CONFIG_POWER_SUPPLY is not enabled.

h8300-linux-ld: drivers/usb/dwc3/gadget.o: in function `.L59':
>> gadget.c:(.text+0x655): undefined reference to `power_supply_set_property'

Fixes: 99288de36020 ("usb: dwc3: add an alternate path in vbus_draw callback")
Reported-by: kernel test robot 
Signed-off-by: Ray Chi 
---
 include/linux/power_supply.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 81a55e974feb..b495b4374cd0 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -426,9 +426,16 @@ static inline int power_supply_is_system_supplied(void) { 
return -ENOSYS; }
 extern int power_supply_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val);
+#if IS_ENABLED(CONFIG_POWER_SUPPLY)
 extern int power_supply_set_property(struct power_supply *psy,
enum power_supply_property psp,
const union power_supply_propval *val);
+#else
+static inline int power_supply_set_property(struct power_supply *psy,
+   enum power_supply_property psp,
+   const union power_supply_propval *val)
+{ return 0; }
+#endif
 extern int power_supply_property_is_writeable(struct power_supply *psy,
enum power_supply_property psp);
 extern void power_supply_external_power_changed(struct power_supply *psy);
-- 
2.31.0.291.g576ba9dcdaf-goog



[PATCH 1/2] usb: dwc3: gadget: modify the scale in vbus_draw callback

2021-03-27 Thread Ray Chi
Currently, vbus_draw callback used wrong scale for power_supply.
The unit of power supply should be uA.
Therefore, this patch will fix this problem.

Fixes: 99288de36020 ("usb: dwc3: add an alternate path in vbus_draw callback")
Reported-by: Sebastian Reichel 
Signed-off-by: Ray Chi 
---
 drivers/usb/dwc3/gadget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index e1442fc763e1..8a361f07e045 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2536,7 +2536,7 @@ static int dwc3_gadget_vbus_draw(struct usb_gadget *g, 
unsigned int mA)
if (!dwc->usb_psy)
return -EOPNOTSUPP;
 
-   val.intval = mA;
+   val.intval = 1000 * mA;
ret = power_supply_set_property(dwc->usb_psy, 
POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, );
 
return ret;
-- 
2.31.0.291.g576ba9dcdaf-goog



[PATCH 0/2] modify power_supply usage in dwc3

2021-03-27 Thread Ray Chi
Currently, the power_supply usage in dwc3 is wrong.
In addition, there is a build error when CONFIG_POWER_SUPPLY
is not enabled. Therefore, these patches will fix the
problems.

Ray Chi (2):
  usb: dwc3: gadget: modify the scale in vbus_draw callback
  power: supply: Fix build error when CONFIG_POWER_SUPPLY is not
enabled.

 drivers/usb/dwc3/gadget.c| 2 +-
 include/linux/power_supply.h | 7 +++
 2 files changed, 8 insertions(+), 1 deletion(-)

-- 
2.31.0.291.g576ba9dcdaf-goog



[Patch v4] usb: dwc3: add cancelled reasons for dwc3 requests

2021-03-27 Thread Ray Chi
Currently, when dwc3 handles request cancelled, dwc3 just returns
-ECONNRESET for all requests. It will cause USB function drivers
can't know if the requests are cancelled by other reasons.

This patch will replace DWC3_REQUEST_STATUS_CANCELLED with the
reasons below.
  - DWC3_REQUEST_STATUS_DISCONNECTED
  - DWC3_REQUEST_STATUS_DEQUEUED
  - DWC3_REQUEST_STATUS_STALLED

Signed-off-by: Ray Chi 
---
Changelog since v3:
- add error log and pass -ECONNRESET in default case

Changelog since v2:
- modify the changelog 
- remove theree definitions
- replace DWC3_REQUEST_STATUS_CANCELLED with new cancelled reason
- In dwc3_gadget_ep_cleanup_cancelled_requests(), 
  add a switch case to give different error code base on the reason

Changelog since v1:
- Added new parameter to dwc3_gadget_move_cancelled_request()
- Added three definitions for cancelled reasons
- Passed the reason to req->request.status

 drivers/usb/dwc3/core.h   | 12 +++-
 drivers/usb/dwc3/gadget.c | 24 
 drivers/usb/dwc3/gadget.h |  6 --
 3 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 4ca4b4be85e4..51a3eec2428a 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -908,11 +908,13 @@ struct dwc3_request {
unsigned intremaining;
 
unsigned intstatus;
-#define DWC3_REQUEST_STATUS_QUEUED 0
-#define DWC3_REQUEST_STATUS_STARTED1
-#define DWC3_REQUEST_STATUS_CANCELLED  2
-#define DWC3_REQUEST_STATUS_COMPLETED  3
-#define DWC3_REQUEST_STATUS_UNKNOWN-1
+#define DWC3_REQUEST_STATUS_QUEUED 0
+#define DWC3_REQUEST_STATUS_STARTED1
+#define DWC3_REQUEST_STATUS_DISCONNECTED   2
+#define DWC3_REQUEST_STATUS_DEQUEUED   3
+#define DWC3_REQUEST_STATUS_STALLED4
+#define DWC3_REQUEST_STATUS_COMPLETED  5
+#define DWC3_REQUEST_STATUS_UNKNOWN-1
 
u8  epnum;
struct dwc3_trb *trb;
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index e1442fc763e1..492086519539 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1402,7 +1402,7 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep 
*dep)
dwc3_stop_active_transfer(dep, true, true);
 
list_for_each_entry_safe(req, tmp, >started_list, list)
-   dwc3_gadget_move_cancelled_request(req);
+   dwc3_gadget_move_cancelled_request(req, 
DWC3_REQUEST_STATUS_DEQUEUED);
 
/* If ep isn't started, then there's no end transfer pending */
if (!(dep->flags & DWC3_EP_END_TRANSFER_PENDING))
@@ -1729,10 +1729,25 @@ static void 
dwc3_gadget_ep_cleanup_cancelled_requests(struct dwc3_ep *dep)
 {
struct dwc3_request *req;
struct dwc3_request *tmp;
+   struct dwc3 *dwc = dep->dwc;
 
list_for_each_entry_safe(req, tmp, >cancelled_list, list) {
dwc3_gadget_ep_skip_trbs(dep, req);
-   dwc3_gadget_giveback(dep, req, -ECONNRESET);
+   switch (req->status) {
+   case DWC3_REQUEST_STATUS_DISCONNECTED:
+   dwc3_gadget_giveback(dep, req, -ESHUTDOWN);
+   break;
+   case DWC3_REQUEST_STATUS_DEQUEUED:
+   dwc3_gadget_giveback(dep, req, -ECONNRESET);
+   break;
+   case DWC3_REQUEST_STATUS_STALLED:
+   dwc3_gadget_giveback(dep, req, -EPIPE);
+   break;
+   default:
+   dev_err(dwc->dev, "request cancelled with wrong 
reason:%d\n", req->status);
+   dwc3_gadget_giveback(dep, req, -ECONNRESET);
+   break;
+   }
}
 }
 
@@ -1776,7 +1791,8 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
 * cancelled.
 */
list_for_each_entry_safe(r, t, >started_list, list)
-   dwc3_gadget_move_cancelled_request(r);
+   dwc3_gadget_move_cancelled_request(r,
+   DWC3_REQUEST_STATUS_DEQUEUED);
 
dep->flags &= ~DWC3_EP_WAIT_TRANSFER_COMPLETE;
 
@@ -1848,7 +1864,7 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int 
value, int protocol)
dwc3_stop_active_transfer(dep, true, true);
 
list_for_each_entry_safe(req, tmp, >started_list, list)
-   dwc3_gadget_move_cancelled_request(req);
+   dwc3_gadget_move_cancelled_request(req, 
DWC3_REQUEST_STATUS_STALLED);
 
if (dep->flags & DWC3_EP_END_TRANSFER_PENDING) {
dep->flags |= DWC3_EP_

[Patch v3] usb: dwc3: add cancelled reasons for dwc3 requests

2021-03-27 Thread Ray Chi
Currently, when dwc3 handles request cancelled, dwc3 just returns
-ECONNRESET for all requests. It will cause USB function drivers
can't know if the requests are cancelled by other reasons.

This patch will replace DWC3_REQUEST_STATUS_CANCELLED with the
reasons below.
  - DWC3_REQUEST_STATUS_DISCONNECTED
  - DWC3_REQUEST_STATUS_DEQUEUED
  - DWC3_REQUEST_STATUS_STALLED

Signed-off-by: Ray Chi 
---
 drivers/usb/dwc3/core.h   | 12 +++-
 drivers/usb/dwc3/gadget.c | 24 
 drivers/usb/dwc3/gadget.h |  6 --
 3 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 4ca4b4be85e4..51a3eec2428a 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -908,11 +908,13 @@ struct dwc3_request {
unsigned intremaining;
 
unsigned intstatus;
-#define DWC3_REQUEST_STATUS_QUEUED 0
-#define DWC3_REQUEST_STATUS_STARTED1
-#define DWC3_REQUEST_STATUS_CANCELLED  2
-#define DWC3_REQUEST_STATUS_COMPLETED  3
-#define DWC3_REQUEST_STATUS_UNKNOWN-1
+#define DWC3_REQUEST_STATUS_QUEUED 0
+#define DWC3_REQUEST_STATUS_STARTED1
+#define DWC3_REQUEST_STATUS_DISCONNECTED   2
+#define DWC3_REQUEST_STATUS_DEQUEUED   3
+#define DWC3_REQUEST_STATUS_STALLED4
+#define DWC3_REQUEST_STATUS_COMPLETED  5
+#define DWC3_REQUEST_STATUS_UNKNOWN-1
 
u8  epnum;
struct dwc3_trb *trb;
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index e1442fc763e1..492086519539 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1402,7 +1402,7 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep 
*dep)
dwc3_stop_active_transfer(dep, true, true);
 
list_for_each_entry_safe(req, tmp, >started_list, list)
-   dwc3_gadget_move_cancelled_request(req);
+   dwc3_gadget_move_cancelled_request(req, 
DWC3_REQUEST_STATUS_DEQUEUED);
 
/* If ep isn't started, then there's no end transfer pending */
if (!(dep->flags & DWC3_EP_END_TRANSFER_PENDING))
@@ -1729,10 +1729,25 @@ static void 
dwc3_gadget_ep_cleanup_cancelled_requests(struct dwc3_ep *dep)
 {
struct dwc3_request *req;
struct dwc3_request *tmp;
+   struct dwc3 *dwc = dep->dwc;
 
list_for_each_entry_safe(req, tmp, >cancelled_list, list) {
dwc3_gadget_ep_skip_trbs(dep, req);
-   dwc3_gadget_giveback(dep, req, -ECONNRESET);
+   switch (req->status) {
+   case DWC3_REQUEST_STATUS_DISCONNECTED:
+   dwc3_gadget_giveback(dep, req, -ESHUTDOWN);
+   break;
+   case DWC3_REQUEST_STATUS_DEQUEUED:
+   dwc3_gadget_giveback(dep, req, -ECONNRESET);
+   break;
+   case DWC3_REQUEST_STATUS_STALLED:
+   dwc3_gadget_giveback(dep, req, -EPIPE);
+   break;
+   default:
+   dev_err(dwc->dev, "request cancelled with wrong 
reason:%d\n", req->status);
+   dwc3_gadget_giveback(dep, req, -ECONNRESET);
+   break;
+   }
}
 }
 
@@ -1776,7 +1791,8 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
 * cancelled.
 */
list_for_each_entry_safe(r, t, >started_list, list)
-   dwc3_gadget_move_cancelled_request(r);
+   dwc3_gadget_move_cancelled_request(r,
+   DWC3_REQUEST_STATUS_DEQUEUED);
 
dep->flags &= ~DWC3_EP_WAIT_TRANSFER_COMPLETE;
 
@@ -1848,7 +1864,7 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int 
value, int protocol)
dwc3_stop_active_transfer(dep, true, true);
 
list_for_each_entry_safe(req, tmp, >started_list, list)
-   dwc3_gadget_move_cancelled_request(req);
+   dwc3_gadget_move_cancelled_request(req, 
DWC3_REQUEST_STATUS_STALLED);
 
if (dep->flags & DWC3_EP_END_TRANSFER_PENDING) {
dep->flags |= DWC3_EP_PENDING_CLEAR_STALL;
diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h
index 0cd281949970..77df4b6d6c13 100644
--- a/drivers/usb/dwc3/gadget.h
+++ b/drivers/usb/dwc3/gadget.h
@@ -90,15 +90,17 @@ static inline void dwc3_gadget_move_started_request(struct 
dwc3_request *req)
 /**
  * dwc3_gadget_move_cancelled_request - move @req to the cancelled_list
  * @req: the request to be moved
+ * @reason: cancelled reason for the dwc3 request
  *
  * Caller should take care of locking. This function 

[Patch v2] usb: dwc3: add cancelled reasons for dwc3 requests

2021-03-26 Thread Ray Chi
Currently, when dwc3 handles request cancelled, dwc3 just returns
-ECONNRESET for all requests. It will cause USB function drivers
can't know if the requests are cancelled by other reasons.

This patch will replace DWC3_REQUEST_STATUS_CANCELLED with the
reasons below.
  - DWC3_REQUEST_STATUS_DISCONNECTED
  - DWC3_REQUEST_STATUS_DEQUEUED
  - DWC3_REQUEST_STATUS_STALLED

Signed-off-by: Ray Chi 
---
 drivers/usb/dwc3/core.h   | 12 +++-
 drivers/usb/dwc3/gadget.c | 21 +
 drivers/usb/dwc3/gadget.h |  6 --
 3 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 4ca4b4be85e4..51a3eec2428a 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -908,11 +908,13 @@ struct dwc3_request {
unsigned intremaining;
 
unsigned intstatus;
-#define DWC3_REQUEST_STATUS_QUEUED 0
-#define DWC3_REQUEST_STATUS_STARTED1
-#define DWC3_REQUEST_STATUS_CANCELLED  2
-#define DWC3_REQUEST_STATUS_COMPLETED  3
-#define DWC3_REQUEST_STATUS_UNKNOWN-1
+#define DWC3_REQUEST_STATUS_QUEUED 0
+#define DWC3_REQUEST_STATUS_STARTED1
+#define DWC3_REQUEST_STATUS_DISCONNECTED   2
+#define DWC3_REQUEST_STATUS_DEQUEUED   3
+#define DWC3_REQUEST_STATUS_STALLED4
+#define DWC3_REQUEST_STATUS_COMPLETED  5
+#define DWC3_REQUEST_STATUS_UNKNOWN-1
 
u8  epnum;
struct dwc3_trb *trb;
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index e1442fc763e1..b11fd02604bb 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1402,7 +1402,7 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep 
*dep)
dwc3_stop_active_transfer(dep, true, true);
 
list_for_each_entry_safe(req, tmp, >started_list, list)
-   dwc3_gadget_move_cancelled_request(req);
+   dwc3_gadget_move_cancelled_request(req, 
DWC3_REQUEST_STATUS_DEQUEUED);
 
/* If ep isn't started, then there's no end transfer pending */
if (!(dep->flags & DWC3_EP_END_TRANSFER_PENDING))
@@ -1732,7 +1732,19 @@ static void 
dwc3_gadget_ep_cleanup_cancelled_requests(struct dwc3_ep *dep)
 
list_for_each_entry_safe(req, tmp, >cancelled_list, list) {
dwc3_gadget_ep_skip_trbs(dep, req);
-   dwc3_gadget_giveback(dep, req, -ECONNRESET);
+   switch (req->status) {
+   case DWC3_REQUEST_STATUS_DISCONNECTED:
+   dwc3_gadget_giveback(dep, req, -ESHUTDOWN);
+   break;
+   case DWC3_REQUEST_STATUS_DEQUEUED:
+   dwc3_gadget_giveback(dep, req, -ECONNRESET);
+   break;
+   case DWC3_REQUEST_STATUS_STALLED:
+   dwc3_gadget_giveback(dep, req, -EPIPE);
+   break;
+   default:
+   break;
+   }
}
 }
 
@@ -1776,7 +1788,8 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
 * cancelled.
 */
list_for_each_entry_safe(r, t, >started_list, list)
-   dwc3_gadget_move_cancelled_request(r);
+   dwc3_gadget_move_cancelled_request(r,
+   DWC3_REQUEST_STATUS_DEQUEUED);
 
dep->flags &= ~DWC3_EP_WAIT_TRANSFER_COMPLETE;
 
@@ -1848,7 +1861,7 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int 
value, int protocol)
dwc3_stop_active_transfer(dep, true, true);
 
list_for_each_entry_safe(req, tmp, >started_list, list)
-   dwc3_gadget_move_cancelled_request(req);
+   dwc3_gadget_move_cancelled_request(req, 
DWC3_REQUEST_STATUS_STALLED);
 
if (dep->flags & DWC3_EP_END_TRANSFER_PENDING) {
dep->flags |= DWC3_EP_PENDING_CLEAR_STALL;
diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h
index 0cd281949970..77df4b6d6c13 100644
--- a/drivers/usb/dwc3/gadget.h
+++ b/drivers/usb/dwc3/gadget.h
@@ -90,15 +90,17 @@ static inline void dwc3_gadget_move_started_request(struct 
dwc3_request *req)
 /**
  * dwc3_gadget_move_cancelled_request - move @req to the cancelled_list
  * @req: the request to be moved
+ * @reason: cancelled reason for the dwc3 request
  *
  * Caller should take care of locking. This function will move @req from its
  * current list to the endpoint's cancelled_list.
  */
-static inline void dwc3_gadget_move_cancelled_request(struct dwc3_request *req)
+static inline void dwc3_gadget_move_cancelled_request(struct dwc3_request *req,
+   unsigned int reason)
 {
struct dwc3_ep  *dep = req->dep;
 
-   r

[PATCH] usb: dwc3: add cancelled reason for dwc3 requests

2021-03-25 Thread Ray Chi
Currently, when dwc3 handles request cancelled, dwc3 just returns
-ECONNRESET for all requests. It will cause USB class drivers can't
know if the requests are cancelled by other reasons.

This patch will add the reason when the requests are cancelled.

Signed-off-by: Ray Chi 
---
 drivers/usb/dwc3/gadget.c |  6 +++---
 drivers/usb/dwc3/gadget.h | 10 +-
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index e1442fc763e1..cc65fc064078 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1402,7 +1402,7 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep 
*dep)
dwc3_stop_active_transfer(dep, true, true);
 
list_for_each_entry_safe(req, tmp, >started_list, list)
-   dwc3_gadget_move_cancelled_request(req);
+   dwc3_gadget_move_cancelled_request(req, 
DWC3_REQUEST_DEQUEUED);
 
/* If ep isn't started, then there's no end transfer pending */
if (!(dep->flags & DWC3_EP_END_TRANSFER_PENDING))
@@ -1776,7 +1776,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
 * cancelled.
 */
list_for_each_entry_safe(r, t, >started_list, list)
-   dwc3_gadget_move_cancelled_request(r);
+   dwc3_gadget_move_cancelled_request(r, 
DWC3_REQUEST_DEQUEUED);
 
dep->flags &= ~DWC3_EP_WAIT_TRANSFER_COMPLETE;
 
@@ -1848,7 +1848,7 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int 
value, int protocol)
dwc3_stop_active_transfer(dep, true, true);
 
list_for_each_entry_safe(req, tmp, >started_list, list)
-   dwc3_gadget_move_cancelled_request(req);
+   dwc3_gadget_move_cancelled_request(req, 
DWC3_REQUEST_STALL);
 
if (dep->flags & DWC3_EP_END_TRANSFER_PENDING) {
dep->flags |= DWC3_EP_PENDING_CLEAR_STALL;
diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h
index 0cd281949970..a23e85bd3933 100644
--- a/drivers/usb/dwc3/gadget.h
+++ b/drivers/usb/dwc3/gadget.h
@@ -56,6 +56,12 @@ struct dwc3;
 
 /* Frame/Microframe Number Mask */
 #define DWC3_FRNUMBER_MASK 0x3fff
+
+/* Cancel reason for dwc3 request */
+#define DWC3_REQUEST_DEQUEUED  -ECONNRESET  /* Request get dequeued */
+#define DWC3_REQUEST_DISCONNECTED  -ESHUTDOWN   /* Device is 
disconnected/disabled */
+#define DWC3_REQUEST_STALL -EPIPE   /* Bus or protocol error */
+
 /* -- 
*/
 
 #define to_dwc3_request(r) (container_of(r, struct dwc3_request, request))
@@ -90,15 +96,17 @@ static inline void dwc3_gadget_move_started_request(struct 
dwc3_request *req)
 /**
  * dwc3_gadget_move_cancelled_request - move @req to the cancelled_list
  * @req: the request to be moved
+ * @reason: cancelled reason for the dwc3 request
  *
  * Caller should take care of locking. This function will move @req from its
  * current list to the endpoint's cancelled_list.
  */
-static inline void dwc3_gadget_move_cancelled_request(struct dwc3_request *req)
+static inline void dwc3_gadget_move_cancelled_request(struct dwc3_request 
*req, int reason)
 {
struct dwc3_ep  *dep = req->dep;
 
req->status = DWC3_REQUEST_STATUS_CANCELLED;
+   req->request.status = reason;
list_move_tail(>list, >cancelled_list);
 }
 
-- 
2.31.0.291.g576ba9dcdaf-goog



Re: [PATCH] usb: dwc3: fix build error when POWER_SUPPLY is not enabled

2021-03-23 Thread Ray Chi
Hi Greg,

I will upload fixes for power supply usage in dwc3 and dt-binding
documentation for the new device tree this week.

Thanks,
Ray

On Tue, Mar 23, 2021 at 9:47 PM Greg KH  wrote:
>
> On Fri, Mar 12, 2021 at 09:57:56PM +0800, Ray Chi wrote:
> > Hi Sebastian,
> >
> > Sorry for the late reply.
> >
> > On Wed, Mar 10, 2021 at 2:58 AM Sebastian Reichel  wrote:
> > >
> > > Hi,
> > >
> > > On Mon, Mar 08, 2021 at 09:31:46PM +0800, Ray Chi wrote:
> > > > Fix build error when CONFIG_POWER_SUPPLY is not enabled.
> > > >
> > > > The build error occurs in mips (cavium_octeon_defconfig).
> > > >
> > > > mips-linux-gnu-ld: drivers/usb/dwc3/core.o: in function `dwc3_remove':
> > > > drivers/usb/dwc3/core.c:1657: undefined reference to `power_supply_put'
> > > > mips-linux-gnu-ld: drivers/usb/dwc3/core.o: in function 
> > > > `dwc3_get_properties':
> > > > drivers/usb/dwc3/core.c:1270: undefined reference to 
> > > > `power_supply_get_by_name'
> > > > mips-linux-gnu-ld: drivers/usb/dwc3/core.o: in function `dwc3_probe':
> > > > drivers/usb/dwc3/core.c:1632: undefined reference to `power_supply_put'
> > > >
> > > > Fixes: 59fa3def35de ("usb: dwc3: add a power supply for current 
> > > > control")
> > > > Reported-by: Naresh Kamboju 
> > > > Signed-off-by: Ray Chi 
> > > > ---
> > >
> > > While I'm fine with merging this after fixing up the subject, the
> > > original patch for dwc3 [0] looks completly incorrect to me.
> > >
> > > First of all it uses wrong scale (power-supply uses uA, not mA),
> > > so you are charging 1000x slower than expected. Then the patchset
> > > introduces a new DT property to get the power-supply device, but
> > > does not update the DT binding documentation and does not Cc the
> > > DT binding maintainer.
> >
> > Yes, it should use uA and send this information, and I will update a
> > patch to fix it and add the DT binding documentation.
>
> So should I revert what we currently have in my usb-next tree, or do
> you have a fix for this?
>
> thanks,
>
> greg k-h


Re: [PATCH] usb: dwc3: fix build error when POWER_SUPPLY is not enabled

2021-03-15 Thread Ray Chi
Hi,

On Mon, Mar 15, 2021 at 6:35 AM Sebastian Reichel  wrote:
>
> Hi,
>
> On Fri, Mar 12, 2021 at 09:57:56PM +0800, Ray Chi wrote:
> > > While I'm fine with merging this after fixing up the subject, the
> > > original patch for dwc3 [0] looks completly incorrect to me.
> > >
> > > First of all it uses wrong scale (power-supply uses uA, not mA),
> > > so you are charging 1000x slower than expected. Then the patchset
> > > introduces a new DT property to get the power-supply device, but
> > > does not update the DT binding documentation and does not Cc the
> > > DT binding maintainer.
> >
> > Yes, it should use uA and send this information, and I will update a
> > patch to fix it and add the DT binding documentation.
>
> Considering your programming is off by a factor 1000 I wonder how
> this patchset has been tested.

Since our corresponding charging driver also uses mA as the unit, I
don't find this problem.

>
> > > Next the property itself looks not very
> > > smart to me. Usually one would use a device reference, not the
> > > Linux device name.
> > >
> > > Finally all existing devices solve this by registering a usb
> > > notifier from the charger, so why are you going the other way
> > > around? This is going to break once you want to use one of the
> > > existing chargers with dwc3.
> >
> > Only the USB controller will know USB state/speed so that I think
> > it is better to send this information from the USB side. For
> > example: For USB high speed, charging current should be limited to
> > 500 mA in configured state.  For USB super speed, charging current
> > should be limited to 900 mA in configured state.
>
> usb_register_notifier registers a callback to receive information
> from the USB subsystem. Then power-supply drivers can query specific
> info, e.g. call usb_phy_get_charger_current(). This is already being
> done by some power-supply drivers, so using one of those
> power-supply charger drivers in combination with dwc3 will now result
> in potentially racy behaviour as far as I can see.

Since these functions are defined in driver/usb/phy/phy.c, only the
devices which support usb_phy can use them.
If the device supports generic PHY drivers, it needs an additional way
to provide the information.
BTW, when there are two or more ways to provide the information, I
think it is fine to return the result directly if one of the ways is
executed successfully.

>
> > > I suggest to drop/revert the whole patchset.
>
> -- Sebastian


Re: [PATCH] usb: dwc3: fix build error when POWER_SUPPLY is not enabled

2021-03-12 Thread Ray Chi
Hi Sebastian,

Sorry for the late reply.

On Wed, Mar 10, 2021 at 2:58 AM Sebastian Reichel  wrote:
>
> Hi,
>
> On Mon, Mar 08, 2021 at 09:31:46PM +0800, Ray Chi wrote:
> > Fix build error when CONFIG_POWER_SUPPLY is not enabled.
> >
> > The build error occurs in mips (cavium_octeon_defconfig).
> >
> > mips-linux-gnu-ld: drivers/usb/dwc3/core.o: in function `dwc3_remove':
> > drivers/usb/dwc3/core.c:1657: undefined reference to `power_supply_put'
> > mips-linux-gnu-ld: drivers/usb/dwc3/core.o: in function 
> > `dwc3_get_properties':
> > drivers/usb/dwc3/core.c:1270: undefined reference to 
> > `power_supply_get_by_name'
> > mips-linux-gnu-ld: drivers/usb/dwc3/core.o: in function `dwc3_probe':
> > drivers/usb/dwc3/core.c:1632: undefined reference to `power_supply_put'
> >
> > Fixes: 59fa3def35de ("usb: dwc3: add a power supply for current control")
> > Reported-by: Naresh Kamboju 
> > Signed-off-by: Ray Chi 
> > ---
>
> While I'm fine with merging this after fixing up the subject, the
> original patch for dwc3 [0] looks completly incorrect to me.
>
> First of all it uses wrong scale (power-supply uses uA, not mA),
> so you are charging 1000x slower than expected. Then the patchset
> introduces a new DT property to get the power-supply device, but
> does not update the DT binding documentation and does not Cc the
> DT binding maintainer.

Yes, it should use uA and send this information, and I will update a
patch to fix it and add the DT binding documentation.

> Next the property itself looks not very
> smart to me. Usually one would use a device reference, not the
> Linux device name.
>
> Finally all existing devices solve this by registering a usb
> notifier from the charger, so why are you going the other way
> around? This is going to break once you want to use one of the
> existing chargers with dwc3.

Only the USB controller will know USB state/speed so that I think it is
better to send this information from the USB side.
For example:
For USB high speed, charging current should be limited to 500 mA in
configured state.
For USB super speed, charging current should be limited to 900 mA in
configured state.

>
> I suggest to drop/revert the whole patchset.
>
> [0] 
> https://lore.kernel.org/linux-usb/20210222115149.3606776-1-ray...@google.com/
>
> -- Sebastian
>
> >  include/linux/power_supply.h | 6 ++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
> > index 81a55e974feb..6e776be5bfa0 100644
> > --- a/include/linux/power_supply.h
> > +++ b/include/linux/power_supply.h
> > @@ -381,8 +381,14 @@ struct power_supply_battery_info {
> >  extern struct atomic_notifier_head power_supply_notifier;
> >  extern int power_supply_reg_notifier(struct notifier_block *nb);
> >  extern void power_supply_unreg_notifier(struct notifier_block *nb);
> > +#if IS_ENABLED(CONFIG_POWER_SUPPLY)
> >  extern struct power_supply *power_supply_get_by_name(const char *name);
> >  extern void power_supply_put(struct power_supply *psy);
> > +#else
> > +static inline void power_supply_put(struct power_supply *psy) {}
> > +static inline struct power_supply *power_supply_get_by_name(const char 
> > *name)
> > +{ return NULL; }
> > +#endif
> >  #ifdef CONFIG_OF
> >  extern struct power_supply *power_supply_get_by_phandle(struct device_node 
> > *np,
> >   const char *property);
> > --
> > 2.30.1.766.gb4fecdf3b7-goog
> >


[PATCH] usb: dwc3: fix build error when POWER_SUPPLY is not enabled

2021-03-08 Thread Ray Chi
Fix build error when CONFIG_POWER_SUPPLY is not enabled.

The build error occurs in mips (cavium_octeon_defconfig).

mips-linux-gnu-ld: drivers/usb/dwc3/core.o: in function `dwc3_remove':
drivers/usb/dwc3/core.c:1657: undefined reference to `power_supply_put'
mips-linux-gnu-ld: drivers/usb/dwc3/core.o: in function `dwc3_get_properties':
drivers/usb/dwc3/core.c:1270: undefined reference to `power_supply_get_by_name'
mips-linux-gnu-ld: drivers/usb/dwc3/core.o: in function `dwc3_probe':
drivers/usb/dwc3/core.c:1632: undefined reference to `power_supply_put'

Fixes: 59fa3def35de ("usb: dwc3: add a power supply for current control")
Reported-by: Naresh Kamboju 
Signed-off-by: Ray Chi 
---
 include/linux/power_supply.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 81a55e974feb..6e776be5bfa0 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -381,8 +381,14 @@ struct power_supply_battery_info {
 extern struct atomic_notifier_head power_supply_notifier;
 extern int power_supply_reg_notifier(struct notifier_block *nb);
 extern void power_supply_unreg_notifier(struct notifier_block *nb);
+#if IS_ENABLED(CONFIG_POWER_SUPPLY)
 extern struct power_supply *power_supply_get_by_name(const char *name);
 extern void power_supply_put(struct power_supply *psy);
+#else
+static inline void power_supply_put(struct power_supply *psy) {}
+static inline struct power_supply *power_supply_get_by_name(const char *name)
+{ return NULL; }
+#endif
 #ifdef CONFIG_OF
 extern struct power_supply *power_supply_get_by_phandle(struct device_node *np,
const char *property);
-- 
2.30.1.766.gb4fecdf3b7-goog



Re: [PATCH] usb: dwc3: Fix dereferencing of null dwc->usb_psy

2021-03-03 Thread Ray Chi
On Wed, Mar 3, 2021 at 6:00 PM Colin King  wrote:
>
> From: Colin Ian King 
>
> Currently the null check logic on dwc->usb_psy is inverted as it allows
> calls to power_supply_put with a null dwc->usb_psy causing a null
> pointer dereference. Fix this by removing the ! operator.
>
> Addresses-Coverity: ("Dereference after null check")
> Fixes: 59fa3def35de ("usb: dwc3: add a power supply for current control")

Acked-by: Ray Chi 

> Signed-off-by: Colin Ian King 
> ---
>  drivers/usb/dwc3/core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index d15f065849cd..94fdbe502ce9 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -1628,7 +1628,7 @@ static int dwc3_probe(struct platform_device *pdev)
>  assert_reset:
> reset_control_assert(dwc->reset);
>
> -   if (!dwc->usb_psy)
> +   if (dwc->usb_psy)
> power_supply_put(dwc->usb_psy);
>
> return ret;
> @@ -1653,7 +1653,7 @@ static int dwc3_remove(struct platform_device *pdev)
> dwc3_free_event_buffers(dwc);
> dwc3_free_scratch_buffers(dwc);
>
> -   if (!dwc->usb_psy)
> +   if (dwc->usb_psy)
> power_supply_put(dwc->usb_psy);
>
> return 0;
> --
> 2.30.0
>

Thanks for fixing this bug!

Regards,
Ray


[Patch v2] usb: dwc3: document usb_psy in struct dwc3

2021-03-03 Thread Ray Chi
The new struct member was added to struct dwc3, but
a documentation was missing:

drivers/usb/dwc3/core.h:1273: warning: Function parameter or member 'usb_psy' 
not described in 'dwc3'

Signed-off-by: Ray Chi 
Reported-by: Stephen Rothwell 
---
Changelog since v1:
(reported-by Stephen Rothwell )
- added Reported-by line.

 drivers/usb/dwc3/core.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 6708fdf358b3..ce6bd84e2b39 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -988,6 +988,7 @@ struct dwc3_scratchpad_array {
  * @role_sw: usb_role_switch handle
  * @role_switch_default_mode: default operation mode of controller while
  * usb role is USB_ROLE_NONE.
+ * @usb_psy: pointer to power supply interface.
  * @usb2_phy: pointer to USB2 PHY
  * @usb3_phy: pointer to USB3 PHY
  * @usb2_generic_phy: pointer to USB2 PHY
-- 
2.30.1.766.gb4fecdf3b7-goog



[Patch v3] usb: dwc3: document usb_psy in struct dwc3

2021-03-03 Thread Ray Chi
The new struct member was added to struct dwc3, but
a documentation was missing:

drivers/usb/dwc3/core.h:1273: warning: Function parameter or member 'usb_psy' 
not described in 'dwc3'

Reported-by: Stephen Rothwell 
Signed-off-by: Ray Chi 
---
Changelog since v2:
- move Signed-off-by to the bottom

Changelog since v1:
(reported-by Stephen Rothwell )
- added Reported-by line.

 drivers/usb/dwc3/core.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 6708fdf358b3..ce6bd84e2b39 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -988,6 +988,7 @@ struct dwc3_scratchpad_array {
  * @role_sw: usb_role_switch handle
  * @role_switch_default_mode: default operation mode of controller while
  * usb role is USB_ROLE_NONE.
+ * @usb_psy: pointer to power supply interface.
  * @usb2_phy: pointer to USB2 PHY
  * @usb3_phy: pointer to USB3 PHY
  * @usb2_generic_phy: pointer to USB2 PHY
-- 
2.30.1.766.gb4fecdf3b7-goog



[PATCH] usb: dwc3: document usb_psy in struct dwc3

2021-03-03 Thread Ray Chi
The new struct member was added to struct dwc3, but
a documentation was missing:

drivers/usb/dwc3/core.h:1273: warning: Function parameter or member 'usb_psy' 
not described in 'dwc3'

Signed-off-by: Ray Chi 
---
 drivers/usb/dwc3/core.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 6708fdf358b3..ce6bd84e2b39 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -988,6 +988,7 @@ struct dwc3_scratchpad_array {
  * @role_sw: usb_role_switch handle
  * @role_switch_default_mode: default operation mode of controller while
  * usb role is USB_ROLE_NONE.
+ * @usb_psy: pointer to power supply interface.
  * @usb2_phy: pointer to USB2 PHY
  * @usb3_phy: pointer to USB3 PHY
  * @usb2_generic_phy: pointer to USB2 PHY
-- 
2.30.1.766.gb4fecdf3b7-goog



[PATCH 1/2] usb: dwc3: add a power supply for current control

2021-02-22 Thread Ray Chi
Currently, VBUS draw callback does no action when the
generic PHYs are used. This patch adds an additional
path to control charging current through power supply
interface.

Signed-off-by: Ray Chi 
---
 drivers/usb/dwc3/core.c | 15 +++
 drivers/usb/dwc3/core.h |  4 
 2 files changed, 19 insertions(+)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index f2448d0a9d39..d15f065849cd 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1238,6 +1238,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
u8  rx_max_burst_prd;
u8  tx_thr_num_pkt_prd;
u8  tx_max_burst_prd;
+   const char  *usb_psy_name;
+   int ret;
 
/* default to highest possible threshold */
lpm_nyet_threshold = 0xf;
@@ -1263,6 +1265,13 @@ static void dwc3_get_properties(struct dwc3 *dwc)
else
dwc->sysdev = dwc->dev;
 
+   ret = device_property_read_string(dev, "usb-psy-name", _psy_name);
+   if (ret >= 0) {
+   dwc->usb_psy = power_supply_get_by_name(usb_psy_name);
+   if (!dwc->usb_psy)
+   dev_err(dev, "couldn't get usb power supply\n");
+   }
+
dwc->has_lpm_erratum = device_property_read_bool(dev,
"snps,has-lpm-erratum");
device_property_read_u8(dev, "snps,lpm-nyet-threshold",
@@ -1619,6 +1628,9 @@ static int dwc3_probe(struct platform_device *pdev)
 assert_reset:
reset_control_assert(dwc->reset);
 
+   if (!dwc->usb_psy)
+   power_supply_put(dwc->usb_psy);
+
return ret;
 }
 
@@ -1641,6 +1653,9 @@ static int dwc3_remove(struct platform_device *pdev)
dwc3_free_event_buffers(dwc);
dwc3_free_scratch_buffers(dwc);
 
+   if (!dwc->usb_psy)
+   power_supply_put(dwc->usb_psy);
+
return 0;
 }
 
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 052b20d52651..6708fdf358b3 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -30,6 +30,8 @@
 
 #include 
 
+#include 
+
 #define DWC3_MSG_MAX   500
 
 /* Global constants */
@@ -1125,6 +1127,8 @@ struct dwc3 {
struct usb_role_switch  *role_sw;
enum usb_dr_moderole_switch_default_mode;
 
+   struct power_supply *usb_psy;
+
u32 fladj;
u32 irq_gadget;
u32 otg_irq;
-- 
2.30.0.617.g56c4b15f3c-goog



[PATCH 2/2] usb: dwc3: add an alternate path in vbus_draw callback

2021-02-22 Thread Ray Chi
This patch adds an alternate path in vbus_draw callback through
power supply property POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT.

Signed-off-by: Ray Chi 
---
 drivers/usb/dwc3/gadget.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index aebcf8ec0716..47809835e163 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2530,11 +2530,19 @@ static void dwc3_gadget_set_ssp_rate(struct usb_gadget 
*g,
 static int dwc3_gadget_vbus_draw(struct usb_gadget *g, unsigned int mA)
 {
struct dwc3 *dwc = gadget_to_dwc(g);
+   union power_supply_propval  val = {0};
+   int ret;
 
if (dwc->usb2_phy)
return usb_phy_set_power(dwc->usb2_phy, mA);
 
-   return 0;
+   if (!dwc->usb_psy)
+   return -EOPNOTSUPP;
+
+   val.intval = mA;
+   ret = power_supply_set_property(dwc->usb_psy, 
POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, );
+
+   return ret;
 }
 
 static const struct usb_gadget_ops dwc3_gadget_ops = {
-- 
2.30.0.617.g56c4b15f3c-goog



[PATCH 0/2] an additional path to control charging current

2021-02-22 Thread Ray Chi
Currently, VBUS draw callback does no action when the
generic PHYs are used. The patches add an additional path
to control charging current through power supply property
POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT.

Ray Chi (2):
  usb: dwc3: add a power supply for current control
  usb: dwc3: add an alternate path in vbus_draw callback

 drivers/usb/dwc3/core.c   | 15 +++
 drivers/usb/dwc3/core.h   |  4 
 drivers/usb/dwc3/gadget.c | 10 +-
 3 files changed, 28 insertions(+), 1 deletion(-)

-- 
2.30.0.617.g56c4b15f3c-goog



Re: [PATCH] usb: dwc3: add EXPORT_SYMBOL_GPL for role init functions

2021-01-26 Thread Ray Chi
On Tue, Jan 26, 2021 at 6:01 PM Greg KH  wrote:
>
> On Tue, Jan 26, 2021 at 05:49:13PM +0800, Ray Chi wrote:
> > Currently, role init functions are used in dwc3 driver but
> > can't be called from kernel modules.
> >   dwc3_host_init
> >   dwc3_host_exit
> >   dwc3_gadget_init
> >   dwc3_gadget_exit
> >   dwc3_event_buffers_setup
> >   dwc3_event_buffers_cleanup
> >
> > If other kernel modules want to use these functions, it needs
> > EXPORT_SYMBOL_GPL() to get compile pass.
> >
> > Signed-off-by: Ray Chi 
>
> What current kernel configuration fails without this patch applied?  I
> don't see any in-tree users of this as a module that would break, or am
> I missing something?
>
> thanks,
>
> greg k-h

There is no failure for current status. This patch is just used for
any kernel modules
which want to call these functions. I think it is an expandability of
dwc3 core driver.


[PATCH] usb: dwc3: add EXPORT_SYMBOL_GPL for role init functions

2021-01-26 Thread Ray Chi
Currently, role init functions are used in dwc3 driver but
can't be called from kernel modules.
  dwc3_host_init
  dwc3_host_exit
  dwc3_gadget_init
  dwc3_gadget_exit
  dwc3_event_buffers_setup
  dwc3_event_buffers_cleanup

If other kernel modules want to use these functions, it needs
EXPORT_SYMBOL_GPL() to get compile pass.

Signed-off-by: Ray Chi 
---
 drivers/usb/dwc3/core.c   | 2 ++
 drivers/usb/dwc3/gadget.c | 2 ++
 drivers/usb/dwc3/host.c   | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 25c686a752b0..f34a7dd5323e 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -418,6 +418,7 @@ int dwc3_event_buffers_setup(struct dwc3 *dwc)
 
return 0;
 }
+EXPORT_SYMBOL_GPL(dwc3_event_buffers_setup);
 
 void dwc3_event_buffers_cleanup(struct dwc3 *dwc)
 {
@@ -433,6 +434,7 @@ void dwc3_event_buffers_cleanup(struct dwc3 *dwc)
| DWC3_GEVNTSIZ_SIZE(0));
dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0);
 }
+EXPORT_SYMBOL_GPL(dwc3_event_buffers_cleanup);
 
 static int dwc3_alloc_scratch_buffers(struct dwc3 *dwc)
 {
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 80c3ef134e41..43110bfdc440 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -3699,6 +3699,7 @@ int dwc3_gadget_init(struct dwc3 *dwc)
 err0:
return ret;
 }
+EXPORT_SYMBOL_GPL(dwc3_gadget_init);
 
 /* -- 
*/
 
@@ -3712,6 +3713,7 @@ void dwc3_gadget_exit(struct dwc3 *dwc)
dma_free_coherent(dwc->sysdev, sizeof(*dwc->ep0_trb) * 2,
  dwc->ep0_trb, dwc->ep0_trb_addr);
 }
+EXPORT_SYMBOL_GPL(dwc3_gadget_exit);
 
 int dwc3_gadget_suspend(struct dwc3 *dwc)
 {
diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index bef1c1ac2067..30589e313a67 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -126,8 +126,10 @@ int dwc3_host_init(struct dwc3 *dwc)
platform_device_put(xhci);
return ret;
 }
+EXPORT_SYMBOL_GPL(dwc3_host_init);
 
 void dwc3_host_exit(struct dwc3 *dwc)
 {
platform_device_unregister(dwc->xhci);
 }
+EXPORT_SYMBOL_GPL(dwc3_host_exit);
-- 
2.30.0.280.ga3ce27912f-goog