Re: [PATCH] usb: dwc3: debugfs: do not queue work if try to change mode on non-drd

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

 



Jun Li wrote:
>
>> -----Original Message-----
>> From: Thinh Nguyen <Thinh.Nguyen@xxxxxxxxxxxx>
>> Sent: Thursday, July 23, 2020 4:36 AM
>> To: Jun Li <jun.li@xxxxxxx>; balbi@xxxxxxxxxx
>> Cc: gregkh@xxxxxxxxxxxxxxxxxxx; linux-usb@xxxxxxxxxxxxxxx
>> Subject: Re: [PATCH] usb: dwc3: debugfs: do not queue work if try to change mode
>> on non-drd
>>
>> Hi,
>>
>> Li Jun wrote:
>>> Do not try to queue a drd work for change mode if the port is not a
>>> drd, this is to avoid below kernel dump:
>> Are you talking about OTG or DRD? This patch seems to be for OTG. If you need to
>> debug and manually do role switch for DRD from userspace, enable and use role class
>> sysfs attribute.
> There is no problem in normal cases, I triggered this warning
> when try to change the role for a single role port via this debugfs
> file, I think nothing should stop user to use this file for debug
> purpose.

Ok.

>
> There is condition check of USB_DR_MODE_OTG when init drd_work, but
> no this check when queue work, so maybe a better change is to move
> the condition check from __dwc3_set_mode() into dwc3_set_mode()

Yeah, this looks better.

>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 6adaa7d..2fa50ec 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -120,9 +120,6 @@ static void __dwc3_set_mode(struct work_struct *work)
>          unsigned long flags;
>          int ret;
>
> -       if (dwc->dr_mode != USB_DR_MODE_OTG)
> -               return;
> -
>          pm_runtime_get_sync(dwc->dev);
>
>          if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_OTG)
> @@ -205,6 +202,9 @@ void dwc3_set_mode(struct dwc3 *dwc, u32 mode)
>   {
>          unsigned long flags;
>
> +       if (dwc->dr_mode != USB_DR_MODE_OTG)
> +               return;
> +
>          spin_lock_irqsave(&dwc->lock, flags);
>          dwc->desired_dr_role = mode;
>          spin_unlock_irqrestore(&dwc->lock, flags);
>

BR,
Thinh





[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux