public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Dmitry Osipenko <digetx@gmail.com>
Cc: Thierry Reding <treding@nvidia.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Mathias Nyman <mathias.nyman@intel.com>,
	JC Kuo <jckuo@nvidia.com>, Nicolas Chauvet <kwizart@gmail.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-tegra@vger.kernel.org
Subject: Re: [PATCH v2] usb: xhci: tegra: Check padctrl interrupt presence in device tree
Date: Thu, 4 Nov 2021 09:29:38 +0100	[thread overview]
Message-ID: <YYOZ8sYB94hZlncn@orome.fritz.box> (raw)
In-Reply-To: <20211102184801.7229-1-digetx@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4894 bytes --]

On Tue, Nov 02, 2021 at 09:48:01PM +0300, Dmitry Osipenko wrote:
> Older device-trees don't specify padctrl interrupt and xhci-tegra driver
> now fails to probe with -EINVAL using those device-trees. Check interrupt
> presence and keep runtime PM disabled if it's missing to fix the trouble.
> 
> Fixes: 971ee247060d ("usb: xhci: tegra: Enable ELPG for runtime/system PM")
> Cc: <stable@vger.kernel.org> # 5.14+
> Tested-by: Nicolas Chauvet <kwizart@gmail.com>
> Reported-by: Nicolas Chauvet <kwizart@gmail.com>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
> 
> Changelog:
> 
> v2: - Use of_irq_parse_one() to check interrupt presence status in device-tree,
>       instead of checking interrupt properties directly.
> 
>     - USB wakeup and runtime PM are kept disabled if interrupt is missing,
>       instead of returning -EOPNOTSUPP from RPM-suspend callback.
> 
>     - Added debug message, telling about the missing interrupt.
> 
>  drivers/usb/host/xhci-tegra.c | 40 ++++++++++++++++++++++++-----------
>  1 file changed, 28 insertions(+), 12 deletions(-)

I like this version much better. Two minor nits:

> 
> diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
> index 1bf494b649bd..0a7ab596be85 100644
> --- a/drivers/usb/host/xhci-tegra.c
> +++ b/drivers/usb/host/xhci-tegra.c
> @@ -1400,6 +1400,7 @@ static void tegra_xusb_deinit_usb_phy(struct tegra_xusb *tegra)
>  
>  static int tegra_xusb_probe(struct platform_device *pdev)
>  {
> +	struct of_phandle_args irq_arg;

Could've been just "args". There's no other "arg" variable here, so no
need for an irq_ prefix to differentiate.

>  	struct tegra_xusb *tegra;
>  	struct device_node *np;
>  	struct resource *regs;
> @@ -1454,10 +1455,16 @@ static int tegra_xusb_probe(struct platform_device *pdev)
>  		goto put_padctl;
>  	}
>  
> -	tegra->padctl_irq = of_irq_get(np, 0);
> -	if (tegra->padctl_irq <= 0) {
> -		err = (tegra->padctl_irq == 0) ? -ENODEV : tegra->padctl_irq;
> -		goto put_padctl;
> +	/* Older device-trees don't have padctrl interrupt */
> +	err = of_irq_parse_one(np, 0, &irq_arg);
> +	if (!err) {
> +		tegra->padctl_irq = of_irq_get(np, 0);
> +		if (tegra->padctl_irq <= 0) {
> +			err = (tegra->padctl_irq == 0) ? -ENODEV : tegra->padctl_irq;
> +			goto put_padctl;
> +		}
> +	} else {
> +		dev_dbg(&pdev->dev, "%pOF doesn't have interrupt\n", np);

This seems a bit vague. I think it'd be better to include information
about the consequence of this interrupt being missing and/or some hint
about what should be done about it. Perhaps something like:

		dev_dbg(&pdev->dev, "%pOF is missing an interrupt, disabling PM support\n", np);

With that fixed:

Acked-by: Thierry Reding <treding@nvidia.com>


I've also run this through our GVS test farm, and didn't spot any
regressions, so:

Tested-by: Thierry Reding <treding@nvidia.com>

Thierry

>  	}
>  
>  	tegra->host_clk = devm_clk_get(&pdev->dev, "xusb_host");
> @@ -1696,11 +1703,15 @@ static int tegra_xusb_probe(struct platform_device *pdev)
>  		goto remove_usb3;
>  	}
>  
> -	err = devm_request_threaded_irq(&pdev->dev, tegra->padctl_irq, NULL, tegra_xusb_padctl_irq,
> -					IRQF_ONESHOT, dev_name(&pdev->dev), tegra);
> -	if (err < 0) {
> -		dev_err(&pdev->dev, "failed to request padctl IRQ: %d\n", err);
> -		goto remove_usb3;
> +	if (tegra->padctl_irq) {
> +		err = devm_request_threaded_irq(&pdev->dev, tegra->padctl_irq,
> +						NULL, tegra_xusb_padctl_irq,
> +						IRQF_ONESHOT, dev_name(&pdev->dev),
> +						tegra);
> +		if (err < 0) {
> +			dev_err(&pdev->dev, "failed to request padctl IRQ: %d\n", err);
> +			goto remove_usb3;
> +		}
>  	}
>  
>  	err = tegra_xusb_enable_firmware_messages(tegra);
> @@ -1718,13 +1729,16 @@ static int tegra_xusb_probe(struct platform_device *pdev)
>  	/* Enable wake for both USB 2.0 and USB 3.0 roothubs */
>  	device_init_wakeup(&tegra->hcd->self.root_hub->dev, true);
>  	device_init_wakeup(&xhci->shared_hcd->self.root_hub->dev, true);
> -	device_init_wakeup(tegra->dev, true);
>  
>  	pm_runtime_use_autosuspend(tegra->dev);
>  	pm_runtime_set_autosuspend_delay(tegra->dev, 2000);
>  	pm_runtime_mark_last_busy(tegra->dev);
>  	pm_runtime_set_active(tegra->dev);
> -	pm_runtime_enable(tegra->dev);
> +
> +	if (tegra->padctl_irq) {
> +		device_init_wakeup(tegra->dev, true);
> +		pm_runtime_enable(tegra->dev);
> +	}
>  
>  	return 0;
>  
> @@ -1772,7 +1786,9 @@ static int tegra_xusb_remove(struct platform_device *pdev)
>  	dma_free_coherent(&pdev->dev, tegra->fw.size, tegra->fw.virt,
>  			  tegra->fw.phys);
>  
> -	pm_runtime_disable(&pdev->dev);
> +	if (tegra->padctl_irq)
> +		pm_runtime_disable(&pdev->dev);
> +
>  	pm_runtime_put(&pdev->dev);
>  
>  	tegra_xusb_powergate_partitions(tegra);
> -- 
> 2.33.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2021-11-04  8:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-02 18:48 [PATCH v2] usb: xhci: tegra: Check padctrl interrupt presence in device tree Dmitry Osipenko
2021-11-04  8:29 ` Thierry Reding [this message]

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=YYOZ8sYB94hZlncn@orome.fritz.box \
    --to=thierry.reding@gmail.com \
    --cc=digetx@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jckuo@nvidia.com \
    --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=mathias.nyman@intel.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