public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/1] usb:xhci: update condition to select bus->sysdev from parent device
@ 2017-08-19  3:43 Thang Q. Nguyen
  2017-08-24  2:53 ` Thang Q. Nguyen
  0 siblings, 1 reply; 4+ messages in thread
From: Thang Q. Nguyen @ 2017-08-19  3:43 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman, linux-usb, linux-kernel
  Cc: Thang Nguyen, Tung Nguyen, Phong Vo, Loc Ho, patches

From: "Thang Q. Nguyen" <tqnguyen@apm.com>

For commit 4c39d4b949d3 ("usb: xhci: use bus->sysdev for DMA
configuration"), sysdev points to devices known to the system firmware
or hardware for DMA parameters.
However, the parent of the system firmware/hardware device checking
logic does not work in ACPI boot mode. This patch updates the formulation
to check this case in both DT and ACPI.

Signed-off-by: Tung Nguyen <tunguyen@apm.com>
Signed-off-by: Thang Q. Nguyen <tqnguyen@apm.com>
---
Change since v1:
 - Update codes to work with kernel 4.13-rc5
---
 drivers/usb/host/xhci-plat.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index c04144b..1bb9729 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -187,7 +187,10 @@ static int xhci_plat_probe(struct platform_device *pdev)
 	 * 3. xhci_plat is grandchild of a pci device (dwc3-pci)
 	 */
 	sysdev = &pdev->dev;
-	if (sysdev->parent && !sysdev->of_node && sysdev->parent->of_node)
+	if (sysdev->parent && !is_of_node(sysdev->fwnode) &&
+			!is_acpi_device_node(sysdev->fwnode) &&
+			(is_of_node(sysdev->parent->fwnode) ||
+			 is_acpi_device_node(sysdev->parent->fwnode)))
 		sysdev = sysdev->parent;
 #ifdef CONFIG_PCI
 	else if (sysdev->parent && sysdev->parent->parent &&
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/1] usb:xhci: update condition to select bus->sysdev from parent device
  2017-08-19  3:43 [PATCH v2 1/1] usb:xhci: update condition to select bus->sysdev from parent device Thang Q. Nguyen
@ 2017-08-24  2:53 ` Thang Q. Nguyen
  2017-09-05 11:14   ` Mathias Nyman
  0 siblings, 1 reply; 4+ messages in thread
From: Thang Q. Nguyen @ 2017-08-24  2:53 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman, linux-usb, linux-kernel
  Cc: Thang Nguyen, Tung Nguyen, Phong Vo, Loc Ho, patches

On Sat, Aug 19, 2017 at 10:43 AM, Thang Q. Nguyen <tqnguyen@apm.com> wrote:
> From: "Thang Q. Nguyen" <tqnguyen@apm.com>
>
> For commit 4c39d4b949d3 ("usb: xhci: use bus->sysdev for DMA
> configuration"), sysdev points to devices known to the system firmware
> or hardware for DMA parameters.
> However, the parent of the system firmware/hardware device checking
> logic does not work in ACPI boot mode. This patch updates the formulation
> to check this case in both DT and ACPI.
>
> Signed-off-by: Tung Nguyen <tunguyen@apm.com>
> Signed-off-by: Thang Q. Nguyen <tqnguyen@apm.com>
> ---
> Change since v1:
>  - Update codes to work with kernel 4.13-rc5
> ---
>  drivers/usb/host/xhci-plat.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index c04144b..1bb9729 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -187,7 +187,10 @@ static int xhci_plat_probe(struct platform_device *pdev)
>          * 3. xhci_plat is grandchild of a pci device (dwc3-pci)
>          */
>         sysdev = &pdev->dev;
> -       if (sysdev->parent && !sysdev->of_node && sysdev->parent->of_node)
> +       if (sysdev->parent && !is_of_node(sysdev->fwnode) &&
> +                       !is_acpi_device_node(sysdev->fwnode) &&
> +                       (is_of_node(sysdev->parent->fwnode) ||
> +                        is_acpi_device_node(sysdev->parent->fwnode)))
>                 sysdev = sysdev->parent;
>  #ifdef CONFIG_PCI
>         else if (sysdev->parent && sysdev->parent->parent &&
> --
> 1.8.3.1
>
Is there any comment about the patch?
With current kernel (4.13.0-rc6), booting the Linux using ACPI boot,
kernel is crashed right after probing the USB DWC3 driver with the
following messages:

[   10.193176] WARNING: CPU: 0 PID: 1 at
drivers/usb/host/xhci-plat.c:199 xhci_plat_probe+0x2f0/0x700
[   10.193176] WARNING: CPU: 0 PID: 1 at
drivers/usb/host/xhci-plat.c:199 xhci_plat_probe+0x2f0/0x700
[   10.211272] Modules linked in:
[   10.211272] Modules linked in:
[   10.217457] CPU: 0 PID: 1 Comm: swapper/0 Not tainted
4.13.0-rc6-00066-g143c97c #4
[   10.217457] CPU: 0 PID: 1 Comm: swapper/0 Not tainted
4.13.0-rc6-00066-g143c97c #4
[   10.232727] Hardware name: AppliedMicro X-Gene Mustang Board/X-Gene
Mustang Board, BIOS 3.07.09 Feb 28 2017
[   10.232727] Hardware name: AppliedMicro X-Gene Mustang Board/X-Gene
Mustang Board, BIOS 3.07.09 Feb 28 2017
[   10.252464] task: ffff8001f3c78000 task.stack: ffff8001f3c74000
[   10.252464] task: ffff8001f3c78000 task.stack: ffff8001f3c74000
[   10.264383] PC is at xhci_plat_probe+0x2f0/0x700
[   10.264383] PC is at xhci_plat_probe+0x2f0/0x700
[   10.273727] LR is at xhci_plat_probe+0x34/0x700
[   10.273727] LR is at xhci_plat_probe+0x34/0x700
[   10.282906] pc : [<ffff00000874bf00>] lr : [<ffff00000874bc44>]
pstate: 00000145
[   10.282906] pc : [<ffff00000874bf00>] lr : [<ffff00000874bc44>]
pstate: 00000145
[   10.297909] sp : ffff8001f3c77c00
[   10.297909] sp : ffff8001f3c77c00
[   10.304608] x29: ffff8001f3c77c00 x28: 0000000000000000
[   10.304608] x29: ffff8001f3c77c00 x28: 0000000000000000
[   10.315360] x27: ffff000008eac808 x26: ffff000008db0454
[   10.315360] x27: ffff000008eac808 x26: ffff000008db0454
[   10.326113] x25: 000000000000001c x24: 0000000000000000
[   10.326113] x25: 000000000000001c x24: 0000000000000000
[   10.336814] x23: ffff000008fa32d0 x22: ffff8001f2bd1010
[   10.336814] x23: ffff000008fa32d0 x22: ffff8001f2bd1010
[   10.347532] x21: ffff8001f2bd1000 x20: ffff8001f2bd1010
[   10.347532] x21: ffff8001f2bd1000 x20: ffff8001f2bd1010
[   10.358215] x19: 00000000ffffffed x18: 0000000000000000
[   10.358215] x19: 00000000ffffffed x18: 0000000000000000
[   10.368950] x17: 0000000000030004 x16: 0000000000030000
[   10.368950] x17: 0000000000030004 x16: 0000000000030000
[   10.379642] x15: ffff8001f3f50400 x14: 0000000000000004
[   10.379642] x15: ffff8001f3f50400 x14: 0000000000000004
[   10.390403] x13: 0000000000000404 x12: 0000000000030000
[   10.390403] x13: 0000000000000404 x12: 0000000000030000
[   10.401173] x11: 0000000000030004 x10: ffff8001f3f50400
[   10.401173] x11: 0000000000030004 x10: ffff8001f3f50400
[   10.411864] x9 : 0000000000000000 x8 : 000000000000001c
[   10.411864] x9 : 0000000000000000 x8 : 000000000000001c
[   10.422616] x7 : ffff8001f3f50400 x6 : ffff8001f3f50400
[   10.422616] x7 : ffff8001f3f50400 x6 : ffff8001f3f50400
[   10.433360] x5 : 0000000000000000 x4 : 0000000000000000
[   10.433360] x5 : 0000000000000000 x4 : 0000000000000000
[   10.444103] x3 : ffff000008f245b8 x2 : ffff000008f24000
[   10.444103] x3 : ffff000008f245b8 x2 : ffff000008f24000
[   10.454864] x1 : 0000000000000000 x0 : 0000000000000000
[   10.454864] x1 : 0000000000000000 x0 : 0000000000000000
[   10.465600] Call trace:
[   10.465600] Call trace:
[   10.470546] Exception stack(0xffff8001f3c77a30 to 0xffff8001f3c77b60)
[   10.470546] Exception stack(0xffff8001f3c77a30 to 0xffff8001f3c77b60)
[   10.483561] 7a20:
00000000ffffffed 0001000000000000
[   10.483561] 7a20:
00000000ffffffed 0001000000000000
[   10.499386] 7a40: ffff8001f3c77c00 ffff00000874bf00
ffff8001f3c77a80 ffff00000896a3a0
[   10.499386] 7a40: ffff8001f3c77c00 ffff00000874bf00
ffff8001f3c77a80 ffff00000896a3a0
[   10.515312] 7a60: 0000000000000000 ffff8001f4c29758
000000000000000c 0000000000000000
[   10.515312] 7a60: 0000000000000000 ffff8001f4c29758
000000000000000c 0000000000000000
[   10.531110] 7a80: ffff8001f3c77a90 ffff000008964e6c
ffff8001f3c77b20 ffff00000896510c
[   10.531110] 7a80: ffff8001f3c77a90 ffff000008964e6c
ffff8001f3c77b20 ffff00000896510c
[   10.546908] 7aa0: 0000000000000001 ffff8001f4814a90
ffff8001f4814a80 ffff00000903efb0
[   10.546908] 7aa0: 0000000000000001 ffff8001f4814a90
ffff8001f4814a80 ffff00000903efb0
[   10.562714] 7ac0: 00000000014000c0 0000000080000000
0000000000000000 0000000000000000
[   10.562714] 7ac0: 00000000014000c0 0000000080000000
0000000000000000 0000000000000000
[   10.578564] 7ae0: ffff000008f24000 ffff000008f245b8
0000000000000000 0000000000000000
[   10.578564] 7ae0: ffff000008f24000 ffff000008f245b8
0000000000000000 0000000000000000
[   10.594336] 7b00: ffff8001f3f50400 ffff8001f3f50400
000000000000001c 0000000000000000
[   10.594336] 7b00: ffff8001f3f50400 ffff8001f3f50400
000000000000001c 0000000000000000
[   10.610228] 7b20: ffff8001f3f50400 0000000000030004
0000000000030000 0000000000000404
[   10.610228] 7b20: ffff8001f3f50400 0000000000030004
0000000000030000 0000000000000404
[   10.626095] 7b40: 0000000000000004 ffff8001f3f50400
0000000000030000 0000000000030004
[   10.626095] 7b40: 0000000000000004 ffff8001f3f50400
0000000000030000 0000000000030004
[   10.641866] [<ffff00000874bf00>] xhci_plat_probe+0x2f0/0x700
[   10.641866] [<ffff00000874bf00>] xhci_plat_probe+0x2f0/0x700
[   10.653277] [<ffff0000085787f8>] platform_drv_probe+0x58/0xc0
[   10.653277] [<ffff0000085787f8>] platform_drv_probe+0x58/0xc0
[   10.664894] [<ffff000008576a64>] driver_probe_device+0x214/0x2d0
[   10.664894] [<ffff000008576a64>] driver_probe_device+0x214/0x2d0
[   10.676986] [<ffff000008576bcc>] __driver_attach+0xac/0xb0
[   10.676986] [<ffff000008576bcc>] __driver_attach+0xac/0xb0
[   10.688093] [<ffff000008574d08>] bus_for_each_dev+0x60/0xa0
[   10.688093] [<ffff000008574d08>] bus_for_each_dev+0x60/0xa0
[   10.699355] [<ffff000008576380>] driver_attach+0x20/0x28
[   10.699355] [<ffff000008576380>] driver_attach+0x20/0x28
[   10.710073] [<ffff000008575ed0>] bus_add_driver+0x110/0x230
[   10.710073] [<ffff000008575ed0>] bus_add_driver+0x110/0x230
[   10.721447] [<ffff000008577540>] driver_register+0x60/0xf8
[   10.721447] [<ffff000008577540>] driver_register+0x60/0xf8
[   10.732606] [<ffff000008578730>] __platform_driver_register+0x40/0x48
[   10.732606] [<ffff000008578730>] __platform_driver_register+0x40/0x48
[   10.745642] [<ffff000008df43e8>] xhci_plat_init+0x2c/0x34
[   10.745642] [<ffff000008df43e8>] xhci_plat_init+0x2c/0x34
[   10.756610] [<ffff000008083150>] do_one_initcall+0x38/0x120
[   10.756610] [<ffff000008083150>] do_one_initcall+0x38/0x120
[   10.767892] [<ffff000008db0cf4>] kernel_init_freeable+0x188/0x228
[   10.767892] [<ffff000008db0cf4>] kernel_init_freeable+0x188/0x228
[   10.780244] [<ffff000008973258>] kernel_init+0x10/0x100
[   10.780244] [<ffff000008973258>] kernel_init+0x10/0x100
[   10.790805] [<ffff000008082ec0>] ret_from_fork+0x10/0x50
[   10.790805] [<ffff000008082ec0>] ret_from_fork+0x10/0x50
[   10.801532] ---[ end trace 505c859fb1949e61 ]---
[   10.801532] ---[ end trace 505c859fb1949e61 ]---
[   10.810886] ata3: SATA link down (SStatus 0 SControl 4300)
[   10.810886] ata3: SATA link down (SStatus 0 SControl 4300)
[   10.822079] xhci-hcd: probe of xhci-hcd.0.auto failed with error -5
[   10.822079] xhci-hcd: probe of xhci-hcd.0.auto failed with error -5

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/1] usb:xhci: update condition to select bus->sysdev from parent device
  2017-08-24  2:53 ` Thang Q. Nguyen
@ 2017-09-05 11:14   ` Mathias Nyman
       [not found]     ` <CAKrQpSvP9nwCM7C4cxiwbvOqk-s=CxaoOJ8tCaYBCJvZ=rcUrw@mail.gmail.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Mathias Nyman @ 2017-09-05 11:14 UTC (permalink / raw)
  To: Thang Q. Nguyen, Mathias Nyman, Greg Kroah-Hartman, linux-usb,
	linux-kernel
  Cc: Tung Nguyen, Phong Vo, Loc Ho, patches, Adam Wallis

On 24.08.2017 05:53, Thang Q. Nguyen wrote:
> On Sat, Aug 19, 2017 at 10:43 AM, Thang Q. Nguyen <tqnguyen@apm.com> wrote:
>> From: "Thang Q. Nguyen" <tqnguyen@apm.com>
>>
>> For commit 4c39d4b949d3 ("usb: xhci: use bus->sysdev for DMA
>> configuration"), sysdev points to devices known to the system firmware
>> or hardware for DMA parameters.
>> However, the parent of the system firmware/hardware device checking
>> logic does not work in ACPI boot mode. This patch updates the formulation
>> to check this case in both DT and ACPI.
>>
>> Signed-off-by: Tung Nguyen <tunguyen@apm.com>
>> Signed-off-by: Thang Q. Nguyen <tqnguyen@apm.com>
>> ---
>> Change since v1:
>>   - Update codes to work with kernel 4.13-rc5
>> ---
>>   drivers/usb/host/xhci-plat.c | 5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
>> index c04144b..1bb9729 100644
>> --- a/drivers/usb/host/xhci-plat.c
>> +++ b/drivers/usb/host/xhci-plat.c
>> @@ -187,7 +187,10 @@ static int xhci_plat_probe(struct platform_device *pdev)
>>           * 3. xhci_plat is grandchild of a pci device (dwc3-pci)
>>           */
>>          sysdev = &pdev->dev;
>> -       if (sysdev->parent && !sysdev->of_node && sysdev->parent->of_node)
>> +       if (sysdev->parent && !is_of_node(sysdev->fwnode) &&
>> +                       !is_acpi_device_node(sysdev->fwnode) &&
>> +                       (is_of_node(sysdev->parent->fwnode) ||
>> +                        is_acpi_device_node(sysdev->parent->fwnode)))
>>                  sysdev = sysdev->parent;
>>   #ifdef CONFIG_PCI
>>          else if (sysdev->parent && sysdev->parent->parent &&
>> --
>> 1.8.3.1
>>
> Is there any comment about the patch?
> With current kernel (4.13.0-rc6), booting the Linux using ACPI boot,
> kernel is crashed right after probing the USB DWC3 driver with the
> following messages:

That should work, but the if statements are getting quite elaborate.
How about replacing it all with:

-       sysdev = &pdev->dev;
-       if (sysdev->parent && !sysdev->of_node && sysdev->parent->of_node)
-               sysdev = sysdev->parent;
-#ifdef CONFIG_PCI
-       else if (sysdev->parent && sysdev->parent->parent &&
-                sysdev->parent->parent->bus == &pci_bus_type)
-               sysdev = sysdev->parent->parent;
-#endif
+
+       for (sysdev = &pdev->dev; sysdev; sysdev = sysdev->parent) {
+               if (is_of_node(sysdev->fwnode) ||
+                   is_acpi_device_node(sysdev->fwnode))
+                       break;
+       #ifdef CONFIG_PCI
+               else if (sysdev->bus == &pci_bus_type)
+                       break;
+       #endif
+       }
+
+       if (!sysdev)
+               sysdev = &pdev->dev

Does that work for you?

-Mathias

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/1] usb:xhci: update condition to select bus->sysdev from parent device
       [not found]     ` <CAKrQpSvP9nwCM7C4cxiwbvOqk-s=CxaoOJ8tCaYBCJvZ=rcUrw@mail.gmail.com>
@ 2017-09-06  6:32       ` Mathias Nyman
  0 siblings, 0 replies; 4+ messages in thread
From: Mathias Nyman @ 2017-09-06  6:32 UTC (permalink / raw)
  To: Thang Q. Nguyen
  Cc: Mathias Nyman, Greg Kroah-Hartman, linux-usb, linux-kernel,
	Tung Nguyen, Phong Vo, Loc Ho, patches, Adam Wallis

On 06.09.2017 06:47, Thang Q. Nguyen wrote:
>
>
> On Tue, Sep 5, 2017 at 6:14 PM, Mathias Nyman <mathias.nyman@linux.intel.com <mailto:mathias.nyman@linux.intel.com>> wrote:
>
>     On 24.08.2017 05 <tel:24.08.2017%2005>:53, Thang Q. Nguyen wrote:
>
>         On Sat, Aug 19, 2017 at 10:43 AM, Thang Q. Nguyen <tqnguyen@apm.com <mailto:tqnguyen@apm.com>> wrote:
>
>             From: "Thang Q. Nguyen" <tqnguyen@apm.com <mailto:tqnguyen@apm.com>>
>
>             For commit 4c39d4b949d3 ("usb: xhci: use bus->sysdev for DMA
>             configuration"), sysdev points to devices known to the system firmware
>             or hardware for DMA parameters.
>             However, the parent of the system firmware/hardware device checking
>             logic does not work in ACPI boot mode. This patch updates the formulation
>             to check this case in both DT and ACPI.
>
>             Signed-off-by: Tung Nguyen <tunguyen@apm.com <mailto:tunguyen@apm.com>>
>             Signed-off-by: Thang Q. Nguyen <tqnguyen@apm.com <mailto:tqnguyen@apm.com>>
>             ---
>             Change since v1:
>                - Update codes to work with kernel 4.13-rc5
>             ---
>                drivers/usb/host/xhci-plat.c | 5 ++++-
>                1 file changed, 4 insertions(+), 1 deletion(-)
>
>             diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
>             index c04144b..1bb9729 100644
>             --- a/drivers/usb/host/xhci-plat.c
>             +++ b/drivers/usb/host/xhci-plat.c
>             @@ -187,7 +187,10 @@ static int xhci_plat_probe(struct platform_device *pdev)
>                        * 3. xhci_plat is grandchild of a pci device (dwc3-pci)
>                        */
>                       sysdev = &pdev->dev;
>             -       if (sysdev->parent && !sysdev->of_node && sysdev->parent->of_node)
>             +       if (sysdev->parent && !is_of_node(sysdev->fwnode) &&
>             +                       !is_acpi_device_node(sysdev->fwnode) &&
>             +                       (is_of_node(sysdev->parent->fwnode) ||
>             +                        is_acpi_device_node(sysdev->parent->fwnode)))
>                               sysdev = sysdev->parent;
>                #ifdef CONFIG_PCI
>                       else if (sysdev->parent && sysdev->parent->parent &&
>             --
>             1.8.3.1
>
>         Is there any comment about the patch?
>         With current kernel (4.13.0-rc6), booting the Linux using ACPI boot,
>         kernel is crashed right after probing the USB DWC3 driver with the
>         following messages:
>
>
>     That should work, but the if statements are getting quite elaborate.
>     How about replacing it all with:
>
>     -       sysdev = &pdev->dev;
>     -       if (sysdev->parent && !sysdev->of_node && sysdev->parent->of_node)
>     -               sysdev = sysdev->parent;
>     -#ifdef CONFIG_PCI
>     -       else if (sysdev->parent && sysdev->parent->parent &&
>     -                sysdev->parent->parent->bus == &pci_bus_type)
>     -               sysdev = sysdev->parent->parent;
>     -#endif
>     +
>     +       for (sysdev = &pdev->dev; sysdev; sysdev = sysdev->parent) {
>     +               if (is_of_node(sysdev->fwnode) ||
>     +                   is_acpi_device_node(sysdev->fwnode))
>     +                       break;
>     +       #ifdef CONFIG_PCI
>     +               else if (sysdev->bus == &pci_bus_type)
>     +                       break;
>     +       #endif
>     +       }
>     +
>     +       if (!sysdev)
>     +               sysdev = &pdev->dev
>
>     Does that work for you?
>
>     -Mathias
>
> It works for me. I tested the followings:
> - ACPI boot: 808622B7 (DWC3) and PNP0D10 (xhci-platform)
> - DT boot: snps,dwc3 (DWC3) and xhci-platform.
> Will you apply your codes into 4.14 kernel?

I will, thanks for testing

-Mathias

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-09-06  6:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-19  3:43 [PATCH v2 1/1] usb:xhci: update condition to select bus->sysdev from parent device Thang Q. Nguyen
2017-08-24  2:53 ` Thang Q. Nguyen
2017-09-05 11:14   ` Mathias Nyman
     [not found]     ` <CAKrQpSvP9nwCM7C4cxiwbvOqk-s=CxaoOJ8tCaYBCJvZ=rcUrw@mail.gmail.com>
2017-09-06  6:32       ` Mathias Nyman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox