Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752004AbdIFG2v (ORCPT ); Wed, 6 Sep 2017 02:28:51 -0400 Received: from mga07.intel.com ([134.134.136.100]:25705 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750786AbdIFG2t (ORCPT ); Wed, 6 Sep 2017 02:28:49 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,482,1498546800"; d="scan'208";a="897500706" Subject: Re: [PATCH v2 1/1] usb:xhci: update condition to select bus->sysdev from parent device To: "Thang Q. Nguyen" References: <1503114220-30971-1-git-send-email-tqnguyen@apm.com> <59AE86FA.5070201@linux.intel.com> Cc: Mathias Nyman , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Tung Nguyen , Phong Vo , Loc Ho , patches , Adam Wallis From: Mathias Nyman Message-ID: <59AF9676.9080904@linux.intel.com> Date: Wed, 6 Sep 2017 09:32:22 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3913 Lines: 89 On 06.09.2017 06:47, Thang Q. Nguyen wrote: > > > On Tue, Sep 5, 2017 at 6:14 PM, Mathias Nyman > wrote: > > On 24.08.2017 05 :53, Thang Q. Nguyen wrote: > > On Sat, Aug 19, 2017 at 10:43 AM, Thang Q. Nguyen > wrote: > > From: "Thang Q. Nguyen" > > > 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 > > Signed-off-by: Thang Q. Nguyen > > --- > 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