Linux USB
 help / color / mirror / Atom feed
From: Peter Chen <peter.chen@nxp.com>
To: Peter Geis <pgwipeout@gmail.com>
Cc: Thierry Reding <treding@nvidia.com>,
	Dmitry Osipenko <digetx@gmail.com>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>
Subject: Re: [PATCH] usb: chipidea: tegra: fix hardlock with invalid dr mode
Date: Fri, 31 Jan 2020 05:27:17 +0000	[thread overview]
Message-ID: <20200131052716.GA30672@b29397-desktop> (raw)
In-Reply-To: <20200127023548.27107-1-pgwipeout@gmail.com>

On 20-01-26 21:35:48, Peter Geis wrote:
> The ci_hdrc_tegra driver does not currently support dual role mode, but
> it does not explicitly prevent its use.
> Certain devices support dual role mode, but not automatic role switch.
> This can cause the device to lock up during initialization of the
> driver.

If the driver only supports peripheral mode, you could set dr_mode as
peripheral-only at glue layer, it would not be override by core.c.
See ci_get_platdata.

But one thing I could not understand, if the driver doesn't support
dual-role, how could you do manual role switch?

> 
> Detect this state by checking for the extcon phandle when dual role mode
> is set to otg.
> If it doesn't exist request the driver to only enable manual role
> switching.
> 
> Fixes: dfebb5f ("usb: chipidea: Add support for Tegra20/30/114/124")
> Signed-off-by: Peter Geis <pgwipeout@gmail.com>
> ---
>  drivers/usb/chipidea/ci_hdrc_tegra.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/usb/chipidea/ci_hdrc_tegra.c b/drivers/usb/chipidea/ci_hdrc_tegra.c
> index 7455df0ede49..2f6f6ce3e8f5 100644
> --- a/drivers/usb/chipidea/ci_hdrc_tegra.c
> +++ b/drivers/usb/chipidea/ci_hdrc_tegra.c
> @@ -89,6 +89,13 @@ static int tegra_udc_probe(struct platform_device *pdev)
>  	udc->data.usb_phy = udc->phy;
>  	udc->data.capoffset = DEF_CAPOFFSET;
>  
> +	/* check the dual mode and warn about bad configurations */
> +	if (usb_get_dr_mode(&pdev->dev) == USB_DR_MODE_OTG &&
> +	   !of_property_read_bool(pdev->dev.of_node, "extcon")) {
> +		dev_warn(&pdev->dev, "no extcon registered, otg unavailable");
> +		udc->data.flags |= CI_HDRC_DUAL_ROLE_NOT_OTG;
> +	}
> +

The CI_HDRC_DUAL_ROLE_NOT_OTG flag may not be suitable here, please see
comments for it.
 
>  	udc->dev = ci_hdrc_add_device(&pdev->dev, pdev->resource,
>  				      pdev->num_resources, &udc->data);
>  	if (IS_ERR(udc->dev)) {
> -- 
> 2.17.1
> 

-- 

Thanks,
Peter Chen

  parent reply	other threads:[~2020-01-31  5:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-27  2:35 [PATCH] usb: chipidea: tegra: fix hardlock with invalid dr mode Peter Geis
2020-01-27  7:17 ` Greg KH
2020-01-27 15:25   ` Peter Geis
2020-01-27 15:38     ` Dmitry Osipenko
2020-01-31  5:27 ` Peter Chen [this message]
2020-01-31 20:43   ` Peter Geis
2020-02-01  6:13     ` Peter Chen
2020-02-03 17:22       ` Peter Geis
2020-02-04  7:44         ` Peter Chen
2020-02-04 14:35           ` Peter Geis
2020-02-05 11:17             ` Peter Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200131052716.GA30672@b29397-desktop \
    --to=peter.chen@nxp.com \
    --cc=digetx@gmail.com \
    --cc=linux-tegra@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=pgwipeout@gmail.com \
    --cc=treding@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox