On Thu, Mar 16, 2023 at 12:28:58PM +0530, Udipto Goswami wrote: > When the dwc3 device is runtime suspended, various required clocks would > get disabled and it is not guaranteed that access to any registers would > work. Depending on the SoC glue, a register read could be as benign as > returning 0 or be fatal enough to hang the system. > > In order to prevent such scenarios of fatal errors, bail out of debugfs > function is dwc3 is suspended. > > Signed-off-by: Udipto Goswami <quic_ugoswami@xxxxxxxxxxx> > --- > v3: Replace pr_err to dev_err. > > drivers/usb/dwc3/debugfs.c | 60 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 60 insertions(+) > > diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c > index 850df0e6bcab..4a9d0994f3b4 100644 > --- a/drivers/usb/dwc3/debugfs.c > +++ b/drivers/usb/dwc3/debugfs.c > @@ -544,6 +544,12 @@ static int dwc3_link_state_show(struct seq_file *s, void *unused) > u32 reg; > u8 speed; > > + if (pm_runtime_suspended(dwc->dev)) { > + dev_err(dwc->dev, > + "Invalid operation, DWC3 suspended!"); > + return -EINVAL; > + } What prevents the device from being suspened right after you check this? thanks, greg k-h