linux-tegra.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Petlozu Pravareshwar <petlozup@nvidia.com>
Cc: jonathanh@nvidia.com, p.zabel@pengutronix.de,
	dmitry.osipenko@collabora.com, ulf.hansson@linaro.org,
	kkartik@nvidia.com, cai.huoqing@linux.dev, spatra@nvidia.com,
	linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org,
	Prathamesh Shete <pshete@nvidia.com>
Subject: Re: [PATCH] soc/tegra: pmc: Process wake events during resume
Date: Wed, 14 Sep 2022 17:25:42 +0200	[thread overview]
Message-ID: <YyHydhlIP4FcP7zj@orome> (raw)
In-Reply-To: <20220914043831.654836-1-petlozup@nvidia.com>

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

On Wed, Sep 14, 2022 at 04:38:31AM +0000, Petlozu Pravareshwar wrote:
> During PMC resume, translate tier2 SC7 wake sources back into
> irqs and do generic_handle_irq() to invoke the interrupt handlers
> for edge triggered wake events such as sw-wake.
> 
> Signed-off-by: Prathamesh Shete <pshete@nvidia.com>
> Signed-off-by: Petlozu Pravareshwar <petlozup@nvidia.com>
> ---
>  drivers/soc/tegra/pmc.c | 44 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 44 insertions(+)
> 
> diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
> index 8c7b46ac6ad6..f275af15f2d0 100644
> --- a/drivers/soc/tegra/pmc.c
> +++ b/drivers/soc/tegra/pmc.c
> @@ -27,6 +27,7 @@
>  #include <linux/iopoll.h>
>  #include <linux/irqdomain.h>
>  #include <linux/irq.h>
> +#include <linux/interrupt.h>

This should be sorted alphabetically.

>  #include <linux/kernel.h>
>  #include <linux/of_address.h>
>  #include <linux/of_clk.h>
> @@ -3181,6 +3182,40 @@ static void wke_clear_wake_status(void)
>  				WAKE_AOWAKE_STATUS_W((i * 32) + wake));
>  	}
>  }
> +
> +/* translate sc7 wake sources back into irqs to catch edge triggered wakeups */
> +static void process_wake_event(int index, u32 status)
> +{
> +	int irq;

Interrupts are usually unsigned int. The index parameter can also be
unsigned int because it will never be negative.

> +	irq_hw_number_t hwirq;
> +	int wake;

Can be unsigned int as well. Also, it's usually best to define variables
of the same time on a single line to make the code a bit shorter.

> +	unsigned long flags;
> +	struct irq_desc *desc;
> +	unsigned long ulong_status = (unsigned long)status;

Why not just make the status parameter an unsigned long to avoid this
clumsy construct?

> +
> +	dev_info(pmc->dev, "Wake[%d:%d]  status=0x%x\n", (index + 1) * 32,
> +		index * 32, status);

At most these should be dev_dbg().

> +	for_each_set_bit(wake, &ulong_status, 32) {
> +		hwirq = wake + 32 * index;
> +
> +#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
> +		irq = irq_find_mapping(pmc->domain, hwirq);

We already use irq_domain_add_hierarchy(), and so the assumption is that
IRQ_DOMAIN_HIERARCHY will always be enabled. You can drop this check. We
may even want to make it explicit by selecting it from SOC_TEGRA_PMC.

> +#else
> +		irq = hwirq;
> +#endif
> +		desc = irq_to_desc(irq);
> +		if (!desc || !desc->action || !desc->action->name) {
> +			dev_info(pmc->dev, "Resume caused by WAKE%d, irq %d\n",
> +				(wake + 32 * index), irq);
> +			continue;
> +		}
> +		dev_info(pmc->dev, "Resume caused by WAKE%d, %s\n",
> +			(wake + 32 * index), desc->action->name);

Same here.

> +		local_irq_save(flags);
> +		generic_handle_irq(irq);
> +		local_irq_restore(flags);
> +	}
> +}
>  #endif /* CONFIG_ARM64 */
>  
>  static int tegra_pmc_suspend(struct device *dev)
> @@ -3219,6 +3254,15 @@ static int tegra_pmc_resume(struct device *dev)
>  	struct tegra_pmc *pmc = dev_get_drvdata(dev);
>  
>  	tegra_pmc_writel(pmc, 0x0, PMC_SCRATCH41);
> +#else /* CONFIG_ARM64 */
> +	int i;

unsigned int, please.

Thierry

> +	u32 status;
> +
> +	for (i = 0; i < WAKE_NR_VECTORS; i++) {
> +		status = readl(pmc->wake + WAKE_AOWAKE_STATUS_R(i));
> +		status = status & readl(pmc->wake + WAKE_AOWAKE_TIER2_ROUTING(i));
> +		process_wake_event(i, status);
> +	}
>  #endif
>  
>  	return 0;
> -- 
> 2.17.1
> 

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

  reply	other threads:[~2022-09-14 15:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-14  4:38 [PATCH] soc/tegra: pmc: Process wake events during resume Petlozu Pravareshwar
2022-09-14 15:25 ` Thierry Reding [this message]
2022-10-02 14:23   ` Petlozu Pravareshwar

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=YyHydhlIP4FcP7zj@orome \
    --to=thierry.reding@gmail.com \
    --cc=cai.huoqing@linux.dev \
    --cc=dmitry.osipenko@collabora.com \
    --cc=jonathanh@nvidia.com \
    --cc=kkartik@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=petlozup@nvidia.com \
    --cc=pshete@nvidia.com \
    --cc=spatra@nvidia.com \
    --cc=ulf.hansson@linaro.org \
    /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;
as well as URLs for NNTP newsgroup(s).