linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Ansuel Smith <ansuelsmth@gmail.com>
Cc: agross@kernel.org, Ajay Kishore <akisho@codeaurora.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	linux-arm-msm@vger.kernel.org, linux-gpio@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pinctrl: qcom: use scm_call to route GPIO irq to Apps
Date: Wed, 25 Mar 2020 17:48:53 -0700	[thread overview]
Message-ID: <20200326004853.GH119913@minitux> (raw)
In-Reply-To: <20200313191513.11365-1-ansuelsmth@gmail.com>

On Fri 13 Mar 12:15 PDT 2020, Ansuel Smith wrote:

> For IPQ806x targets, TZ protects the registers that are used to
> configure the routing of interrupts to a target processor.
> To resolve this, this patch uses scm call to route GPIO interrupts
> to application processor. Also the scm call interface is changed.
> 

Oh no...but this does look pretty reasonable after all, some comments
and suggestions below.

> Signed-off-by: Ajay Kishore <akisho@codeaurora.org>

With this --author should be Ajay.

> Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
> ---
>  drivers/pinctrl/qcom/pinctrl-msm.c | 36 ++++++++++++++++++++++++++----
>  1 file changed, 32 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c
> index 9a8daa256a32..a83cfd1da219 100644
> --- a/drivers/pinctrl/qcom/pinctrl-msm.c
> +++ b/drivers/pinctrl/qcom/pinctrl-msm.c
> @@ -22,6 +22,8 @@
>  #include <linux/reboot.h>
>  #include <linux/pm.h>
>  #include <linux/log2.h>
> +#include <linux/qcom_scm.h>
> +#include <linux/io.h>
>  
>  #include <linux/soc/qcom/irq.h>
>  
> @@ -710,6 +712,9 @@ static void msm_gpio_irq_mask(struct irq_data *d)
>  	const struct msm_pingroup *g;
>  	unsigned long flags;
>  	u32 val;
> +	u32 addr;
> +	int ret;
> +	const __be32 *reg;
>  
>  	if (d->parent_data)
>  		irq_chip_mask_parent(d);
> @@ -863,6 +868,7 @@ static int msm_gpio_irq_set_type(struct irq_data *d, unsigned int type)
>  	const struct msm_pingroup *g;
>  	unsigned long flags;
>  	u32 val;
> +	int ret;
>  
>  	if (d->parent_data)
>  		irq_chip_set_type_parent(d, type);
> @@ -882,11 +888,33 @@ static int msm_gpio_irq_set_type(struct irq_data *d, unsigned int type)
>  	else
>  		clear_bit(d->hwirq, pctrl->dual_edge_irqs);
>  
> +	ret = of_device_is_compatible(pctrl->dev->of_node,
> +					"qcom,ipq8064-pinctrl");

This won't change in runtime, so I would like for you to query this
during probe and then carry the result in msm_pinctrl.

>  	/* Route interrupts to application cpu */
> -	val = msm_readl_intr_target(pctrl, g);
> -	val &= ~(7 << g->intr_target_bit);
> -	val |= g->intr_target_kpss_val << g->intr_target_bit;
> -	msm_writel_intr_target(val, pctrl, g);
> +	if (!ret) {
> +		val = msm_readl_intr_target(pctrl, g);
> +		val &= ~(7 << g->intr_target_bit);
> +		val |= g->intr_target_kpss_val << g->intr_target_bit;
> +		msm_writel_intr_target(val, pctrl, g);
> +	} else {
> +		const __be32 *reg = of_get_property(pctrl->dev->of_node,
> +						    "reg", NULL);

This too will be static, and we already resolve this, properly, with
address translation etc during probe.

So if you do a partial rollback of '4b024225c4a8 ("pinctrl: use
devm_platform_ioremap_resource() to simplify code")' you can stash the
base address of the resource in msm_pinctrl, and then make your change
conditional on this being NULL or not.

> +
> +		if (reg) {
> +			u32 addr = be32_to_cpup(reg) + g->intr_target_reg;
> +
> +			qcom_scm_io_readl(addr, &val);
> +			__iormb();

Why do you need this and below barriers?

> +
> +			val &= ~(7 << g->intr_target_bit);
> +			val |= g->intr_target_kpss_val << g->intr_target_bit;
> +
> +			__iowmb();
> +			ret = qcom_scm_io_writel(addr, val);
> +			if (ret)
> +				pr_err("\n Routing interrupts to Apps proc failed");

You have msm_pinctrl->dev, so use dev_err(). And the \n goes at the end
in Linux - and perhaps make it include d->hwirq to make it a little bit
informative?

Regards,
Bjorn

> +		}
> +	}
>  
>  	/* Update configuration for gpio.
>  	 * RAW_STATUS_EN is left on for all gpio irqs. Due to the
> -- 
> 2.25.0
> 

      parent reply	other threads:[~2020-03-26  0:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-13 19:15 [PATCH] pinctrl: qcom: use scm_call to route GPIO irq to Apps Ansuel Smith
2020-03-25 23:31 ` Linus Walleij
2020-03-26  0:48 ` Bjorn Andersson [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=20200326004853.GH119913@minitux \
    --to=bjorn.andersson@linaro.org \
    --cc=agross@kernel.org \
    --cc=akisho@codeaurora.org \
    --cc=ansuelsmth@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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).