lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <88b48c61-65e4-cc24-d90d-5fba92f05f27@linux.intel.com>
Date:   Fri, 15 Jan 2021 15:32:30 +0200
From:   Mathias Nyman <mathias.nyman@...ux.intel.com>
To:     Pali Rohár <pali@...nel.org>,
        Peter Chen <peter.chen@....com>
Cc:     Mathias Nyman <mathias.nyman@...el.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Jun Li <jun.li@....com>,
        "linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Yoshihiro Shimoda <yoshihiro.shimoda.uh@...esas.com>
Subject: Re: [PATCH v2] usb: host: xhci-plat: fix support for
 XHCI_SKIP_PHY_INIT quirk

On 14.1.2021 1.20, Pali Rohár wrote:
> On Thursday 24 December 2020 05:59:05 Peter Chen wrote:
>> On 20-12-23 17:18:47, Pali Rohár wrote:
>>> Currently init_quirk callbacks for xhci platform drivers are called
>>> xhci_plat_setup() function which is called after chip reset completes.
>>> It happens in the middle of the usb_add_hcd() function.
>>>
>>> But XHCI_SKIP_PHY_INIT quirk is checked in the xhci_plat_probe() function
>>> prior calling usb_add_hcd() function. Therefore this XHCI_SKIP_PHY_INIT
>>> currently does nothing as prior xhci_plat_setup() it is not set.
>>>
>>> Quirk XHCI_SKIP_PHY_INIT is only setting hcd->skip_phy_initialization value
>>> which really needs to be set prior calling usb_add_hcd() as this function
>>> at its beginning skips PHY init if this member is set.
>>>
>>> This patch fixes implementation of the XHCI_SKIP_PHY_INIT quirk by calling
>>> init_quirk callbacks (via xhci_priv_init_quirk()) prior checking if
>>> XHCI_SKIP_PHY_INIT is set. Also checking if either xhci->quirks or
>>> priv->quirks contains this XHCI_SKIP_PHY_INIT quirk.
>>>
>>> Signed-off-by: Pali Rohár <pali@...nel.org>
>>>
>>> ---
>>> Changes in v2:
>>> * Check also xhci->quirks as xhci_priv_init_quirk() callbacks are setting xhci->quirks
>>> * Tested with "usb: host: xhci: mvebu: make USB 3.0 PHY optional for Armada 3720" patch
>>> * Removed Fixes: line
>>> ---
>>>  drivers/usb/host/xhci-plat.c | 16 ++++++++--------
>>>  1 file changed, 8 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
>>> index 4d34f6005381..0eab7cb5a767 100644
>>> --- a/drivers/usb/host/xhci-plat.c
>>> +++ b/drivers/usb/host/xhci-plat.c
>>> @@ -89,13 +89,6 @@ static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
>>>  /* called during probe() after chip reset completes */
>>>  static int xhci_plat_setup(struct usb_hcd *hcd)
>>>  {
>>> -	int ret;
>>> -
>>> -
>>> -	ret = xhci_priv_init_quirk(hcd);
>>> -	if (ret)
>>> -		return ret;
>>> -
>>>  	return xhci_gen_setup(hcd, xhci_plat_quirks);
>>>  }
>>>  
>>> @@ -330,7 +323,14 @@ static int xhci_plat_probe(struct platform_device *pdev)
>>>  
>>>  	hcd->tpl_support = of_usb_host_tpl_support(sysdev->of_node);
>>>  	xhci->shared_hcd->tpl_support = hcd->tpl_support;
>>> -	if (priv && (priv->quirks & XHCI_SKIP_PHY_INIT))
>>> +
>>> +	if (priv) {
>>> +		ret = xhci_priv_init_quirk(hcd);
>>> +		if (ret)
>>> +			goto disable_usb_phy;
>>> +	}
>>> +
>>> +	if ((xhci->quirks & XHCI_SKIP_PHY_INIT) || (priv && (priv->quirks & XHCI_SKIP_PHY_INIT)))
>>>  		hcd->skip_phy_initialization = 1;
>>
>> I am not sure if others agree with you move the position of
>> xhci_priv_init_quirk, Let's see Mathias opinion.
> 
> Hello! Do you have an opinion how to handle this issue? As currently it
> is needed for another patch which is fixing issue/regression in xhci-mvebu:
> https://lore.kernel.org/linux-usb/20201223162403.10897-1-pali@kernel.org/
> 

I can see the benefit in this. 
In the xhci-plat case usb_create_hcd and usb_add_hcd are separate steps, and
we could both copy the xhci_plat_priv .quirks and run the .init_qurks before
adding the hcd.
I guess the current way is inherited from pci case where the earliest place
to do this after hcd is created is the hcd->driver->reset callback (which is
set to xhci_pci_setup() or xhci_plat_setup()).

xhci-rcar.c is using the .init_quirk to load firmware, we need to check with
them if this change is ok. (added Yoshihiro Shimoda to cc)
Their firmware would be loaded before phy parts are initialized, usb bus
registered, or roothub device allocated.

Thanks
-Mathias

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ