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: <20201222092327.jq5b7g4bffeccq3o@pali>
Date:   Tue, 22 Dec 2020 10:23:27 +0100
From:   Pali Rohár <pali@...nel.org>
To:     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>
Subject: Re: [PATCH] usb: host: xhci-plat: fix support for XHCI_SKIP_PHY_INIT
 quirk

On Tuesday 22 December 2020 02:14:45 Peter Chen wrote:
> On 20-12-21 16:09:03, 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.
> > 
> > Fixes: f768e718911e0 ("usb: host: xhci-plat: add priv quirk for skip PHY initialization")
> > Signed-off-by: Pali Rohár <pali@...nel.org>
> > ---
> >  drivers/usb/host/xhci-plat.c | 14 +++++++-------
> >  1 file changed, 7 insertions(+), 7 deletions(-)
> > 
> > diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> > index 4d34f6005381..58704c5b002b 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,6 +323,13 @@ 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) {
> > +		ret = xhci_priv_init_quirk(hcd);
> > +		if (ret)
> > +			goto disable_usb_phy;
> > +	}
> > +
> >  	if (priv && (priv->quirks & XHCI_SKIP_PHY_INIT))
> >  		hcd->skip_phy_initialization = 1;
> >  
> 
> Hi Pali,
> 
> What's problem you have met? In structure xhci_plat_priv, the quirks are
> defined at .quirks entry which is got at below code. .init_quirk is the
> routine if special initializations are needed.

Hello!

I'm talking about .init_quirk. And if XHCI_SKIP_PHY_INIT quirk is set in
this function then has no effect.

I'm working currently on patch for xhci mvebu which conditionally enable
or disable XHCI_SKIP_PHY_INIT quirk (it is going to fix existing
regression since v5.1 kernel) and without this patch XHCI_SKIP_PHY_INIT
quirk from the init_quirk does not work.

> 	if (pdev->dev.of_node)
> 		priv_match = of_device_get_match_data(&pdev->dev);
> 	else
> 		priv_match = dev_get_platdata(&pdev->dev);
> 
> 	if (priv_match) {
> 		priv = hcd_to_xhci_priv(hcd);
> 		/* Just copy data for now */
> 		*priv = *priv_match;
> 	}
> -- 
> 
> Thanks,
> Peter Chen

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ