Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1726635

Re: [PATCH v2 1/1] usb:xhci: update condition to select bus->sysdev from parent device

From Mathias Nyman <mathias.nyman@linux.intel.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2 1/1] usb:xhci: update condition to select bus->sysdev from parent device
Date 2017-09-05 13:20 +0200
Message-ID <umk3E-1YM-9@gated-at.bofh.it> (permalink)
References <ug2VQ-4xH-3@gated-at.bofh.it> <uhQxb-wP-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH v2 1/1] usb:xhci: update condition to select bus->sysdev  from parent device Mathias Nyman <mathias.nyman@linux.intel.com> - 2017-09-05 13:20 +0200
  Re: [PATCH v2 1/1] usb:xhci: update condition to select bus->sysdev  from parent device Mathias Nyman <mathias.nyman@linux.intel.com> - 2017-09-06 08:30 +0200

csiph-web