[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230328212048.rpm4ly265etahwm3@synopsys.com>
Date: Tue, 28 Mar 2023 21:20:50 +0000
From: Thinh Nguyen <Thinh.Nguyen@...opsys.com>
To: Krishna Kurapati <quic_kriskura@...cinc.com>
CC: Thinh Nguyen <Thinh.Nguyen@...opsys.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Alan Stern <stern@...land.harvard.edu>,
Geert Uytterhoeven <geert+renesas@...der.be>,
Colin Ian King <colin.i.king@...il.com>,
Jiantao Zhang <water.zhangjiantao@...wei.com>,
"Rafael J . Wysocki" <rafael@...nel.org>,
"linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"quic_ppratap@...cinc.com" <quic_ppratap@...cinc.com>,
"quic_wcheng@...cinc.com" <quic_wcheng@...cinc.com>,
"quic_jackp@...cinc.com" <quic_jackp@...cinc.com>,
"quic_ugoswami@...cinc.com" <quic_ugoswami@...cinc.com>
Subject: Re: [PATCH v2 1/2] usb: dwc3: gadget: Bail out in pullup if soft
reset timeout happens
Hi,
On Tue, Mar 28, 2023, Krishna Kurapati wrote:
> If the core soft reset timeout happens, avoid setting up event
> buffers and starting gadget as the writes to these registers
> may not reflect when in reset and setting the run stop bit
> can lead the controller to access wrong event buffer address
> resulting in a crash.
>
> Signed-off-by: Krishna Kurapati <quic_kriskura@...cinc.com>
> ---
> drivers/usb/dwc3/gadget.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 3c63fa97a680..f0472801d9a5 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -2620,13 +2620,16 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
> * device-initiated disconnect requires a core soft reset
> * (DCTL.CSftRst) before enabling the run/stop bit.
> */
> - dwc3_core_soft_reset(dwc);
> + ret = dwc3_core_soft_reset(dwc);
> + if (ret)
> + goto done;
>
> dwc3_event_buffers_setup(dwc);
> __dwc3_gadget_start(dwc);
> ret = dwc3_gadget_run_stop(dwc, true, false);
> }
>
> +done:
> pm_runtime_put(dwc->dev);
>
> return ret;
> --
> 2.40.0
>
I think there's one more place that may needs this check. Can you also
add this check in __dwc3_set_mode()?
Thanks,
Thinh
Powered by blists - more mailing lists