Re: [PATCH 3/8] usb: dwc3: core: Skip setting event buffers for host only controllers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 3/13/2023 7:37 AM, Dongliang Mu wrote:
On Sat, Mar 11, 2023 at 12:40 AM Krishna Kurapati
<quic_kriskura@xxxxxxxxxxx> wrote:

On some SoC's like SA8295P where the teritiary controller is host-only
capable, GEVTADDRHI/LO, GEVTSIZ, GEVTCOUNT registers are not accessible.
Trying to setup them up during core_init leads to a crash.

For DRD/Peripheral supported controllers, event buffer setup is done
again in gadget_pullup. Skip setup or cleanup of event buffers if
controller is host-only capable.

Signed-off-by: Krishna Kurapati <quic_kriskura@xxxxxxxxxxx>
---
  drivers/usb/dwc3/core.c | 20 ++++++++++++++------
  1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 076c0f8a4441..1ca9fa40a66e 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -840,7 +840,11 @@ static void dwc3_clk_disable(struct dwc3 *dwc)

  static void dwc3_core_exit(struct dwc3 *dwc)
  {
-       dwc3_event_buffers_cleanup(dwc);
+       unsigned int    hw_mode;
+
+       hw_mode = DWC3_GHWPARAMS0_MODE(dwc->hwparams.hwparams0);
+       if (hw_mode != DWC3_GHWPARAMS0_MODE_HOST)
+               dwc3_event_buffers_cleanup(dwc);

quick question about dwc3_event_buffers_cleanup, there are other
similar sites calling this function.

C symbol: dwc3_event_buffers_cleanup

   File   Function                   Line
0 core.h <global>                   1546 void
dwc3_event_buffers_cleanup(struct dwc3 *dwc);
1 core.c __dwc3_set_mode             152 dwc3_event_buffers_cleanup(dwc);
2 core.c dwc3_event_buffers_cleanup  522 void
dwc3_event_buffers_cleanup(struct dwc3 *dwc)
3 core.c dwc3_core_exit              842 dwc3_event_buffers_cleanup(dwc);
4 core.c dwc3_probe                 1936 dwc3_event_buffers_cleanup(dwc);
5 drd.c  dwc3_otg_update             363 dwc3_event_buffers_cleanup(dwc);
6 drd.c  dwc3_drd_exit               607 dwc3_event_buffers_cleanup(dwc);

For 1, 5, and 6, any need to take care of this situation?

Hi Dongliang,

  Thanks for the review.
In the other places mentioned like set_mode otg_update or drd_exit, cleanup is called if we are in device mode and we want to exit that mode. Since for MP, we have a host only controller those paths won't be accessed I believe.

Regards,
Krishna,

         usb_phy_set_suspend(dwc->usb2_phy, 1);
         usb_phy_set_suspend(dwc->usb3_phy, 1);
@@ -1177,10 +1181,12 @@ static int dwc3_core_init(struct dwc3 *dwc)
         if (ret < 0)
                 goto err3;

-       ret = dwc3_event_buffers_setup(dwc);
-       if (ret) {
-               dev_err(dwc->dev, "failed to setup event buffers\n");
-               goto err4;
+       if (hw_mode != DWC3_GHWPARAMS0_MODE_HOST) {
+               ret = dwc3_event_buffers_setup(dwc);
+               if (ret) {
+                       dev_err(dwc->dev, "failed to setup event buffers\n");
+                       goto err4;
+               }
         }

         /*
@@ -2008,7 +2014,9 @@ static int dwc3_probe(struct platform_device *pdev)

  err5:
         dwc3_debugfs_exit(dwc);
-       dwc3_event_buffers_cleanup(dwc);
+
+       if (hw_mode != DWC3_GHWPARAMS0_MODE_HOST)
+               dwc3_event_buffers_cleanup(dwc);

         usb_phy_set_suspend(dwc->usb2_phy, 1);
         usb_phy_set_suspend(dwc->usb3_phy, 1);
--
2.39.0




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux