2018-08-06 11:38:21

by Anurag Kumar Vulisha

[permalink] [raw]
Subject: [PATCH v2] usb: host: xhci-plat: Iterate over parent nodes for finding quirks

In xhci_plat_probe() both sysdev and pdev->dev are being used
for finding quirks. There are some drivers(like dwc3 host.c)
which adds quirks(like usb3-lpm-capable) into pdev and the logic
present in xhci_plat_probe() checks for quirks in either sysdev
or pdev for finding the quirks. Because of this logic, some of
the quirks are getting missed(usb3-lpm-capable quirk added by dwc3
host.c driver is getting missed).This patch fixes this by iterating
over all the available parents for finding the quirks. In this way
all the quirks which are present in child or parent are correctly
updated.

Signed-off-by: Anurag Kumar Vulisha <[email protected]>
---
Changes in v2:
1. As suggested by Mathias, restoring immod_interval changes to
default
---
drivers/usb/host/xhci-plat.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index c1b22fc..f121238 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -152,7 +152,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
{
const struct xhci_plat_priv *priv_match;
const struct hc_driver *driver;
- struct device *sysdev;
+ struct device *sysdev, *tmpdev;
struct xhci_hcd *xhci;
struct resource *res;
struct usb_hcd *hcd;
@@ -272,20 +272,24 @@ static int xhci_plat_probe(struct platform_device *pdev)
goto disable_clk;
}

- if (device_property_read_bool(sysdev, "usb2-lpm-disable"))
- xhci->quirks |= XHCI_HW_LPM_DISABLE;
-
- if (device_property_read_bool(sysdev, "usb3-lpm-capable"))
- xhci->quirks |= XHCI_LPM_SUPPORT;
-
- if (device_property_read_bool(&pdev->dev, "quirk-broken-port-ped"))
- xhci->quirks |= XHCI_BROKEN_PORT_PED;
-
/* imod_interval is the interrupt moderation value in nanoseconds. */
xhci->imod_interval = 40000;
device_property_read_u32(sysdev, "imod-interval-ns",
&xhci->imod_interval);

+ /* Iterate over all parent nodes for finding quirks */
+ for (tmpdev = &pdev->dev; tmpdev; tmpdev = tmpdev->parent) {
+
+ if (device_property_read_bool(tmpdev, "usb2-lpm-disable"))
+ xhci->quirks |= XHCI_HW_LPM_DISABLE;
+
+ if (device_property_read_bool(tmpdev, "usb3-lpm-capable"))
+ xhci->quirks |= XHCI_LPM_SUPPORT;
+
+ if (device_property_read_bool(tmpdev, "quirk-broken-port-ped"))
+ xhci->quirks |= XHCI_BROKEN_PORT_PED;
+ }
+
hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, "usb-phy", 0);
if (IS_ERR(hcd->usb_phy)) {
ret = PTR_ERR(hcd->usb_phy);
--
2.1.1



2018-08-06 12:16:51

by Mathias Nyman

[permalink] [raw]
Subject: Re: [PATCH v2] usb: host: xhci-plat: Iterate over parent nodes for finding quirks

Hi

On 06.08.2018 14:36, Anurag Kumar Vulisha wrote:
> In xhci_plat_probe() both sysdev and pdev->dev are being used
> for finding quirks. There are some drivers(like dwc3 host.c)
> which adds quirks(like usb3-lpm-capable) into pdev and the logic
> present in xhci_plat_probe() checks for quirks in either sysdev
> or pdev for finding the quirks. Because of this logic, some of
> the quirks are getting missed(usb3-lpm-capable quirk added by dwc3
> host.c driver is getting missed).This patch fixes this by iterating
> over all the available parents for finding the quirks. In this way
> all the quirks which are present in child or parent are correctly
> updated.
>
> Signed-off-by: Anurag Kumar Vulisha <[email protected]>
> ---
> Changes in v2:
> 1. As suggested by Mathias, restoring immod_interval changes to
> default
> ---
> drivers/usb/host/xhci-plat.c | 24 ++++++++++++++----------
> 1 file changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index c1b22fc..f121238 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -152,7 +152,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
> {
> const struct xhci_plat_priv *priv_match;
> const struct hc_driver *driver;
> - struct device *sysdev;
> + struct device *sysdev, *tmpdev;
> struct xhci_hcd *xhci;
> struct resource *res;
> struct usb_hcd *hcd;
> @@ -272,20 +272,24 @@ static int xhci_plat_probe(struct platform_device *pdev)
> goto disable_clk;
> }
>
> - if (device_property_read_bool(sysdev, "usb2-lpm-disable"))
> - xhci->quirks |= XHCI_HW_LPM_DISABLE;
> -
> - if (device_property_read_bool(sysdev, "usb3-lpm-capable"))
> - xhci->quirks |= XHCI_LPM_SUPPORT;
> -
> - if (device_property_read_bool(&pdev->dev, "quirk-broken-port-ped"))
> - xhci->quirks |= XHCI_BROKEN_PORT_PED;
> -
> /* imod_interval is the interrupt moderation value in nanoseconds. */
> xhci->imod_interval = 40000;

xhci->imod_interval = 40000 is now in the correct place

> device_property_read_u32(sysdev, "imod-interval-ns",
> &xhci->imod_interval);

but the device_propery_read_u32() line above can be moved inside loop below.

>
> + /* Iterate over all parent nodes for finding quirks */
> + for (tmpdev = &pdev->dev; tmpdev; tmpdev = tmpdev->parent) {
> +
> + if (device_property_read_bool(tmpdev, "usb2-lpm-disable"))
> + xhci->quirks |= XHCI_HW_LPM_DISABLE;
> +
> + if (device_property_read_bool(tmpdev, "usb3-lpm-capable"))
> + xhci->quirks |= XHCI_LPM_SUPPORT;
> +
> + if (device_property_read_bool(tmpdev, "quirk-broken-port-ped"))
> + xhci->quirks |= XHCI_BROKEN_PORT_PED;
> + }
> +
> hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, "usb-phy", 0);
> if (IS_ERR(hcd->usb_phy)) {
> ret = PTR_ERR(hcd->usb_phy);
>

-Mathias

2018-08-06 13:19:47

by Anurag Kumar Vulisha

[permalink] [raw]
Subject: RE: [PATCH v2] usb: host: xhci-plat: Iterate over parent nodes for finding quirks


>> - if (device_property_read_bool(sysdev, "usb3-lpm-capable"))
>> - xhci->quirks |= XHCI_LPM_SUPPORT;
>> -
>> - if (device_property_read_bool(&pdev->dev, "quirk-broken-port-ped"))
>> - xhci->quirks |= XHCI_BROKEN_PORT_PED;
>> -
>> /* imod_interval is the interrupt moderation value in nanoseconds. */
>> xhci->imod_interval = 40000;
>
>xhci->imod_interval = 40000 is now in the correct place
>
>> device_property_read_u32(sysdev, "imod-interval-ns",
>> &xhci->imod_interval);
>
>but the device_propery_read_u32() line above can be moved inside loop below.
>

Hi Mathias,

Thanks for reviewing the patch. I agree with you, will correct this in v3

Thanks,
Anurag Kumar Vulisha
>>
>> + /* Iterate over all parent nodes for finding quirks */
>> + for (tmpdev = &pdev->dev; tmpdev; tmpdev = tmpdev->parent) {
>> +
>> + if (device_property_read_bool(tmpdev, "usb2-lpm-disable"))
>> + xhci->quirks |= XHCI_HW_LPM_DISABLE;
>> +
>> + if (device_property_read_bool(tmpdev, "usb3-lpm-capable"))
>> + xhci->quirks |= XHCI_LPM_SUPPORT;
>> +
>> + if (device_property_read_bool(tmpdev, "quirk-broken-port-ped"))
>> + xhci->quirks |= XHCI_BROKEN_PORT_PED;
>> + }
>> +
>> hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, "usb-phy", 0);
>> if (IS_ERR(hcd->usb_phy)) {
>> ret = PTR_ERR(hcd->usb_phy);
>>
>
>-Mathias