diff mbox series

usb: dwc3: qcom: Defer dwc3-qcom probe if dwc3 isn't probed properly

Message ID 1657810516-31143-1-git-send-email-quic_kriskura@quicinc.com
State Superseded
Headers show
Series usb: dwc3: qcom: Defer dwc3-qcom probe if dwc3 isn't probed properly | expand

Commit Message

Krishna Kurapati July 14, 2022, 2:55 p.m. UTC
On SC7180 devices, it is observed that dwc3 probing is deferred
because device_links_check_suppliers() finds that '88e3000.phy'
isn't ready yet.

As a part of its probe call, dwc3-qcom driver checks if dwc3 core
is wakeup capable or not. If the dwc3 core is wakeup capable, driver
configures dwc-qcom's power domain to be always ON. Also it configures
dp/dm interrupts accordingly to support wakeup from system suspend.

More info regarding the same can be found at:
commit d9be8d5c5b03 ("usb: dwc3: qcom: Keep power domain on to retain controller status"
commit 6895ea55c385 ("usb: dwc3: qcom: Configure wakeup interrupts during suspend")

In the event, dwc3 probe gets deferred and is processed after dwc3-qcom
probe, driver ends up reading the wakeup capability of dwc3 core as false
leading to instability in suspend/resume path.

To avoid this scenario, ensure dwc3_probe is successful by checking
if appropriate driver is assigned to it or not after the of_platform_populate
call. If it isn't then defer dwc3-qcom probe as well.

Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>
---
 drivers/usb/dwc3/dwc3-qcom.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Greg KH July 14, 2022, 3:01 p.m. UTC | #1
On Thu, Jul 14, 2022 at 08:25:16PM +0530, Krishna Kurapati wrote:
> On SC7180 devices, it is observed that dwc3 probing is deferred
> because device_links_check_suppliers() finds that '88e3000.phy'
> isn't ready yet.
> 
> As a part of its probe call, dwc3-qcom driver checks if dwc3 core
> is wakeup capable or not. If the dwc3 core is wakeup capable, driver
> configures dwc-qcom's power domain to be always ON. Also it configures
> dp/dm interrupts accordingly to support wakeup from system suspend.
> 
> More info regarding the same can be found at:
> commit d9be8d5c5b03 ("usb: dwc3: qcom: Keep power domain on to retain controller status"
> commit 6895ea55c385 ("usb: dwc3: qcom: Configure wakeup interrupts during suspend")
> 
> In the event, dwc3 probe gets deferred and is processed after dwc3-qcom
> probe, driver ends up reading the wakeup capability of dwc3 core as false
> leading to instability in suspend/resume path.
> 
> To avoid this scenario, ensure dwc3_probe is successful by checking
> if appropriate driver is assigned to it or not after the of_platform_populate
> call. If it isn't then defer dwc3-qcom probe as well.
> 
> Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>
> ---
>  drivers/usb/dwc3/dwc3-qcom.c | 3 +++
>  1 file changed, 3 insertions(+)

I got 2 different copies of this change, what's the difference?

confused,

greg k-h
Krishna Kurapati July 14, 2022, 3:03 p.m. UTC | #2
On 7/14/2022 8:31 PM, Greg Kroah-Hartman wrote:
> On Thu, Jul 14, 2022 at 08:25:16PM +0530, Krishna Kurapati wrote:
>> On SC7180 devices, it is observed that dwc3 probing is deferred
>> because device_links_check_suppliers() finds that '88e3000.phy'
>> isn't ready yet.
>>
>> As a part of its probe call, dwc3-qcom driver checks if dwc3 core
>> is wakeup capable or not. If the dwc3 core is wakeup capable, driver
>> configures dwc-qcom's power domain to be always ON. Also it configures
>> dp/dm interrupts accordingly to support wakeup from system suspend.
>>
>> More info regarding the same can be found at:
>> commit d9be8d5c5b03 ("usb: dwc3: qcom: Keep power domain on to retain controller status"
>> commit 6895ea55c385 ("usb: dwc3: qcom: Configure wakeup interrupts during suspend")
>>
>> In the event, dwc3 probe gets deferred and is processed after dwc3-qcom
>> probe, driver ends up reading the wakeup capability of dwc3 core as false
>> leading to instability in suspend/resume path.
>>
>> To avoid this scenario, ensure dwc3_probe is successful by checking
>> if appropriate driver is assigned to it or not after the of_platform_populate
>> call. If it isn't then defer dwc3-qcom probe as well.
>>
>> Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>
>> ---
>>   drivers/usb/dwc3/dwc3-qcom.c | 3 +++
>>   1 file changed, 3 insertions(+)
> I got 2 different copies of this change, what's the difference?
>
> confused,
>
> greg k-h
Sorry Greg, My bad, I thought the mail sending failed the first time. So 
I sent the same patch second time. Sorry for the confusion.
Regards,
Krishna,
Krishna Kurapati July 14, 2022, 3:09 p.m. UTC | #3
On 7/14/2022 8:32 PM, Greg Kroah-Hartman wrote:
> On Thu, Jul 14, 2022 at 08:25:16PM +0530, Krishna Kurapati wrote:
>> On SC7180 devices, it is observed that dwc3 probing is deferred
>> because device_links_check_suppliers() finds that '88e3000.phy'
>> isn't ready yet.
>>
>> As a part of its probe call, dwc3-qcom driver checks if dwc3 core
>> is wakeup capable or not. If the dwc3 core is wakeup capable, driver
>> configures dwc-qcom's power domain to be always ON. Also it configures
>> dp/dm interrupts accordingly to support wakeup from system suspend.
>>
>> More info regarding the same can be found at:
>> commit d9be8d5c5b03 ("usb: dwc3: qcom: Keep power domain on to retain controller status"
>> commit 6895ea55c385 ("usb: dwc3: qcom: Configure wakeup interrupts during suspend")
>>
>> In the event, dwc3 probe gets deferred and is processed after dwc3-qcom
>> probe, driver ends up reading the wakeup capability of dwc3 core as false
>> leading to instability in suspend/resume path.
>>
>> To avoid this scenario, ensure dwc3_probe is successful by checking
>> if appropriate driver is assigned to it or not after the of_platform_populate
>> call. If it isn't then defer dwc3-qcom probe as well.
>>
>> Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>
>> ---
>>   drivers/usb/dwc3/dwc3-qcom.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
>> index 7703655..096d1414 100644
>> --- a/drivers/usb/dwc3/dwc3-qcom.c
>> +++ b/drivers/usb/dwc3/dwc3-qcom.c
>> @@ -722,6 +722,9 @@ static int dwc3_qcom_of_register_core(struct platform_device *pdev)
>>   		dev_err(dev, "failed to get dwc3 platform device\n");
>>   	}
>>   
>> +	if (!qcom->dwc3->dev.driver)
>> +		return -EPROBE_DEFER;
>> +
> Why not limit this check to a device type like your changelog mentions?
>
> thanks,
>
> greg k-h
Hi Greg,

I wanted to make it common to any device using this driver. Although on 
devices
ike SC7280,this issue is not seen but the code would hold good. Do you 
see any
concerns if we do it this way ?

Thanks,
Krishna,
Krishna Kurapati July 14, 2022, 3:43 p.m. UTC | #4
On 7/14/2022 8:58 PM, Greg Kroah-Hartman wrote:
> On Thu, Jul 14, 2022 at 08:39:31PM +0530, Krishna Kurapati PSSNV wrote:
>> On 7/14/2022 8:32 PM, Greg Kroah-Hartman wrote:
>>> On Thu, Jul 14, 2022 at 08:25:16PM +0530, Krishna Kurapati wrote:
>>>> On SC7180 devices, it is observed that dwc3 probing is deferred
>>>> because device_links_check_suppliers() finds that '88e3000.phy'
>>>> isn't ready yet.
>>>>
>>>> As a part of its probe call, dwc3-qcom driver checks if dwc3 core
>>>> is wakeup capable or not. If the dwc3 core is wakeup capable, driver
>>>> configures dwc-qcom's power domain to be always ON. Also it configures
>>>> dp/dm interrupts accordingly to support wakeup from system suspend.
>>>>
>>>> More info regarding the same can be found at:
>>>> commit d9be8d5c5b03 ("usb: dwc3: qcom: Keep power domain on to retain controller status"
>>>> commit 6895ea55c385 ("usb: dwc3: qcom: Configure wakeup interrupts during suspend")
>>>>
>>>> In the event, dwc3 probe gets deferred and is processed after dwc3-qcom
>>>> probe, driver ends up reading the wakeup capability of dwc3 core as false
>>>> leading to instability in suspend/resume path.
>>>>
>>>> To avoid this scenario, ensure dwc3_probe is successful by checking
>>>> if appropriate driver is assigned to it or not after the of_platform_populate
>>>> call. If it isn't then defer dwc3-qcom probe as well.
>>>>
>>>> Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>
>>>> ---
>>>>    drivers/usb/dwc3/dwc3-qcom.c | 3 +++
>>>>    1 file changed, 3 insertions(+)
>>>>
>>>> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
>>>> index 7703655..096d1414 100644
>>>> --- a/drivers/usb/dwc3/dwc3-qcom.c
>>>> +++ b/drivers/usb/dwc3/dwc3-qcom.c
>>>> @@ -722,6 +722,9 @@ static int dwc3_qcom_of_register_core(struct platform_device *pdev)
>>>>    		dev_err(dev, "failed to get dwc3 platform device\n");
>>>>    	}
>>>> +	if (!qcom->dwc3->dev.driver)
>>>> +		return -EPROBE_DEFER;
>>>> +
>>> Why not limit this check to a device type like your changelog mentions?
>>>
>>> thanks,
>>>
>>> greg k-h
>> Hi Greg,
>>
>> I wanted to make it common to any device using this driver. Although on
>> devices
>> ike SC7280,this issue is not seen but the code would hold good. Do you see
>> any
>> concerns if we do it this way ?
> How many different types of hardware did you test this change on and
> what was the results?
>
> thanks,
>
> greg k-h
Hi Greg,

   I tested only on SC7180 and SC7280 devices. It was working on SC7280, 
(the first run of of_platform_populate made sure dwc3 probe is done).
On SC7180, during the first run of dwc3-qcom probe, we observed dwc3 
probe getting deferred after of_platform_populate.
As you suggested, I can try and check on other devices using this driver 
and confirm if only SC7180 has this issue. 🙂

Thanks,
Krishna,
Matthias Kaehlcke July 14, 2022, 3:56 p.m. UTC | #5
On Thu, Jul 14, 2022 at 08:25:16PM +0530, Krishna Kurapati wrote:
> On SC7180 devices, it is observed that dwc3 probing is deferred
> because device_links_check_suppliers() finds that '88e3000.phy'
> isn't ready yet.
> 
> As a part of its probe call, dwc3-qcom driver checks if dwc3 core
> is wakeup capable or not. If the dwc3 core is wakeup capable, driver
> configures dwc-qcom's power domain to be always ON. Also it configures
> dp/dm interrupts accordingly to support wakeup from system suspend.
> 
> More info regarding the same can be found at:
> commit d9be8d5c5b03 ("usb: dwc3: qcom: Keep power domain on to retain controller status"
> commit 6895ea55c385 ("usb: dwc3: qcom: Configure wakeup interrupts during suspend")
> 
> In the event, dwc3 probe gets deferred and is processed after dwc3-qcom
> probe, driver ends up reading the wakeup capability of dwc3 core as false
> leading to instability in suspend/resume path.
> 
> To avoid this scenario, ensure dwc3_probe is successful by checking
> if appropriate driver is assigned to it or not after the of_platform_populate
> call. If it isn't then defer dwc3-qcom probe as well.
> Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>

Fixes: 649f5c842ba3 ("usb: dwc3: core: Host wake up support from system suspend")

> ---
>  drivers/usb/dwc3/dwc3-qcom.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index 7703655..096d1414 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -722,6 +722,9 @@ static int dwc3_qcom_of_register_core(struct platform_device *pdev)
>  		dev_err(dev, "failed to get dwc3 platform device\n");
>  	}
>  
> +	if (!qcom->dwc3->dev.driver)
> +		return -EPROBE_DEFER;

change this to:

		ret = -EPROBE_DEFER;

to put 'dwc3_np'

> +
>  node_put:
>  	of_node_put(dwc3_np);
>  
> -- 
> 2.7.4
>
Pavan Kondeti July 15, 2022, 9:40 a.m. UTC | #6
On Thu, Jul 14, 2022 at 08:25:16PM +0530, Krishna Kurapati wrote:
> On SC7180 devices, it is observed that dwc3 probing is deferred
> because device_links_check_suppliers() finds that '88e3000.phy'
> isn't ready yet.
> 
> As a part of its probe call, dwc3-qcom driver checks if dwc3 core
> is wakeup capable or not. If the dwc3 core is wakeup capable, driver
> configures dwc-qcom's power domain to be always ON. Also it configures
> dp/dm interrupts accordingly to support wakeup from system suspend.
> 
> More info regarding the same can be found at:
> commit d9be8d5c5b03 ("usb: dwc3: qcom: Keep power domain on to retain controller status"
> commit 6895ea55c385 ("usb: dwc3: qcom: Configure wakeup interrupts during suspend")
> 
> In the event, dwc3 probe gets deferred and is processed after dwc3-qcom
> probe, driver ends up reading the wakeup capability of dwc3 core as false
> leading to instability in suspend/resume path.
> 
> To avoid this scenario, ensure dwc3_probe is successful by checking
> if appropriate driver is assigned to it or not after the of_platform_populate
> call. If it isn't then defer dwc3-qcom probe as well.
> 
> Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>
> ---
>  drivers/usb/dwc3/dwc3-qcom.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index 7703655..096d1414 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -722,6 +722,9 @@ static int dwc3_qcom_of_register_core(struct platform_device *pdev)
>  		dev_err(dev, "failed to get dwc3 platform device\n");
>  	}
>  
> +	if (!qcom->dwc3->dev.driver)
> +		return -EPROBE_DEFER;
> +

you need to drop the dwc3 node reference, so set ret = -EPROBE_DEFER here
instead of returning.

>  node_put:
>  	of_node_put(dwc3_np);
>  
> -- 
> 2.7.4
> 

Thanks,
Pavan
Greg KH July 27, 2022, 9:55 a.m. UTC | #7
On Wed, Jul 27, 2022 at 03:03:01PM +0530, Pratham Pratap wrote:

<snip>

Please note that html email is not allowed on kernel mailing lists and
the messages are thrown away, so no one can see them :(

Please fix your email client so that you can participate in kernel
development.

thanks,

greg k-h
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index 7703655..096d1414 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -722,6 +722,9 @@  static int dwc3_qcom_of_register_core(struct platform_device *pdev)
 		dev_err(dev, "failed to get dwc3 platform device\n");
 	}
 
+	if (!qcom->dwc3->dev.driver)
+		return -EPROBE_DEFER;
+
 node_put:
 	of_node_put(dwc3_np);