mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: Peter Chen <peter.chen@nxp.com>
Cc: Thierry Reding <thierry.reding@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	Felipe Balbi <balbi@kernel.org>,
	Matt Merhar <mattmerhar@protonmail.com>,
	Nicolas Chauvet <kwizart@gmail.com>,
	Peter Geis <pgwipeout@gmail.com>,
	"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1 5/8] usb: chipidea: tegra: Support host mode
Date: Wed, 16 Dec 2020 12:53:38 +0300	[thread overview]
Message-ID: <78b8b868-fa72-cffa-b3c2-5a73a02d02b0@gmail.com> (raw)
In-Reply-To: <DBBPR04MB79794F5CC440279AF94A48448BC50@DBBPR04MB7979.eurprd04.prod.outlook.com>

16.12.2020 12:32, Peter Chen пишет:
>  
>>>>
>>>>  struct tegra_usb_soc_info {
>>>>  	unsigned long flags;
>>>> +	unsigned int txfifothresh;
>>>> +	enum usb_dr_mode dr_mode;
>>>> +};
>>>> +
>>>> +static const struct tegra_usb_soc_info tegra20_ehci_soc_info = {
>>>> +	.flags = CI_HDRC_REQUIRES_ALIGNED_DMA |
>>>> +		 CI_HDRC_OVERRIDE_PHY_CONTROL,
>>>> +	.dr_mode = USB_DR_MODE_HOST,
>>>> +	.txfifothresh = 10,
>>>> +};
>>>> +
>>>> +static const struct tegra_usb_soc_info tegra30_ehci_soc_info = {
>>>> +	.flags = CI_HDRC_REQUIRES_ALIGNED_DMA |
>>>> +		 CI_HDRC_OVERRIDE_PHY_CONTROL
>>>> +	.dr_mode = USB_DR_MODE_HOST,
>>>> +	.txfifothresh = 16,
>>>>  };
>>>>
>>>>  static const struct tegra_usb_soc_info tegra_udc_soc_info = {
>>>> -	.flags = CI_HDRC_REQUIRES_ALIGNED_DMA,
>>>> +	.flags = CI_HDRC_REQUIRES_ALIGNED_DMA |
>>>> +		 CI_HDRC_OVERRIDE_PHY_CONTROL,
>>>> +	.dr_mode = USB_DR_MODE_UNKNOWN,
>>>>  };
>>>
>>> What's the usage for this dr_mode? Does these three SoCs only supports
>>> single mode, it usually sets dr_mode at board dts file to indicate USB
>>> role for this board.
>>
>> All Tegra SoCs have three USB controllers.  Only one of these three controllers
>> supports peripheral / OTG modes, the other two controllers are fixed to the
>> host mode and device trees do not specify the dr_mode for the host
>> controllers.
>>
>> Hence we need to enforce the dr_mode=host for the host-mode controllers.
>>
>> For UDC the default mode is "unknown" because actual mode comes from a
>> board's device tree.
>>
> 
> You could add dr_mode property at usb node of soc.dtsi to fulfill that.

This will break older DTBs, we can't do this.

...
>>>>  static int ehci_ci_portpower(struct usb_hcd *hcd, int portnum, bool
>>>> enable)  {
>>>>  	struct ehci_hcd *ehci = hcd_to_ehci(hcd); @@ -160,14 +166,14 @@
>>>> static int host_start(struct ci_hdrc *ci)
>>>>  		pinctrl_select_state(ci->platdata->pctl,
>>>>  				     ci->platdata->pins_host);
>>>>
>>>> +	ci->hcd = hcd;
>>>> +
>>>>  	ret = usb_add_hcd(hcd, 0, 0);
>>>>  	if (ret) {
>>>>  		goto disable_reg;
>>>>  	} else {
>>>>  		struct usb_otg *otg = &ci->otg;
>>>>
>>>> -		ci->hcd = hcd;
>>>> -
>>>
>>> Why this changed?
>>
>> The ci->hcd is used by tegra_usb_notify_event() to handle reset event and the
>> reset happens once usb_add_hcd() is invoked.  Hence we need to pre-assign
>> the hcd pointer, otherwise there will be a NULL dereference.
> 
> Get it, please set ci->hcd as NULL at error path.

Ok, thanks.


  reply	other threads:[~2020-12-16  9:54 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-15 20:21 [PATCH v1 0/8] Support Runtime PM and host mode by Tegra ChipIdea USB driver Dmitry Osipenko
2020-12-15 20:21 ` [PATCH v1 1/8] usb: phy: tegra: Add delay after power up Dmitry Osipenko
2020-12-16  8:51   ` Sergei Shtylyov
2020-12-16  9:09     ` Dmitry Osipenko
2020-12-15 20:21 ` [PATCH v1 2/8] usb: phy: tegra: Support waking up from a low power mode Dmitry Osipenko
2020-12-15 20:21 ` [PATCH v1 3/8] usb: chipidea: tegra: Remove MODULE_ALIAS Dmitry Osipenko
2020-12-16 17:58   ` Thierry Reding
2020-12-16 18:06     ` Dmitry Osipenko
2020-12-15 20:21 ` [PATCH v1 4/8] usb: chipidea: tegra: Rename UDC to USB Dmitry Osipenko
2020-12-15 20:21 ` [PATCH v1 5/8] usb: chipidea: tegra: Support host mode Dmitry Osipenko
2020-12-16  6:08   ` Peter Chen
2020-12-16  9:07     ` Dmitry Osipenko
2020-12-16  9:22       ` Dmitry Osipenko
2020-12-16  9:32       ` Peter Chen
2020-12-16  9:53         ` Dmitry Osipenko [this message]
2020-12-16 15:56         ` Dmitry Osipenko
2020-12-15 20:21 ` [PATCH v1 6/8] usb: chipidea: tegra: Support runtime PM Dmitry Osipenko
2020-12-15 20:21 ` [PATCH v1 7/8] usb: host: ehci-tegra: Remove the driver Dmitry Osipenko
2020-12-16 16:45   ` Alan Stern
2020-12-16 17:09     ` Dmitry Osipenko
2020-12-16 17:22       ` Alan Stern
2020-12-16 17:28         ` Dmitry Osipenko
2020-12-15 20:21 ` [PATCH v1 8/8] ARM: tegra_defconfig: Enable USB_CHIPIDEA and remove USB_EHCI_TEGRA Dmitry Osipenko

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=78b8b868-fa72-cffa-b3c2-5a73a02d02b0@gmail.com \
    --to=digetx@gmail.com \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jonathanh@nvidia.com \
    --cc=kwizart@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mattmerhar@protonmail.com \
    --cc=peter.chen@nxp.com \
    --cc=pgwipeout@gmail.com \
    --cc=stern@rowland.harvard.edu \
    --cc=thierry.reding@gmail.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

Powered by JetHome