All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Maulik Shah <mkshah@codeaurora.org>
Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org, linux-gpio@vger.kernel.org,
	bjorn.andersson@linaro.org, linus.walleij@linaro.org,
	tkjos@google.com, lsrao@codeaurora.org
Subject: Re: [PATCH v2 2/3] irqdomain: Fix irq_domain_trim_hierarchy()
Date: Fri, 20 Aug 2021 16:54:21 +0100	[thread overview]
Message-ID: <87im00qfgy.wl-maz@kernel.org> (raw)
In-Reply-To: <1629373993-13370-3-git-send-email-mkshah@codeaurora.org>

On Thu, 19 Aug 2021 12:53:12 +0100,
Maulik Shah <mkshah@codeaurora.org> wrote:
> 
> Currently tail marker is moving along with parent domain
> irq data. Fix this to initialize only once from where all
> parent domain needs trimming.
> 
> Also correct the valid irq chip check.
> 
> Signed-off-by: Maulik Shah <mkshah@codeaurora.org>
> ---
>  kernel/irq/irqdomain.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
> index 19e83e9..9f6187b 100644
> --- a/kernel/irq/irqdomain.c
> +++ b/kernel/irq/irqdomain.c
> @@ -1235,7 +1235,7 @@ static int irq_domain_trim_hierarchy(unsigned int virq)
>  	 */
>  	for (irqd = irq_data->parent_data; irqd; irq_data = irqd, irqd = irqd->parent_data) {
>  		/* Can't have a valid irqchip after a trim marker */
> -		if (irqd->chip && tail)
> +		if (!IS_ERR(irqd->chip) && tail)
>  			return -EINVAL;
>  
>  		/* Can't have an empty irqchip before a trim marker */
> @@ -1247,7 +1247,8 @@ static int irq_domain_trim_hierarchy(unsigned int virq)
>  			if (PTR_ERR(irqd->chip) != -ENOTCONN)
>  				return -EINVAL;
>  
> -			tail = irq_data;
> +			if (!tail)
> +				tail = irq_data;
>  		}
>  	}

I think you have the wrong end of the stick. 'tail' represent the
*unique* point in the hierarchy where you can have a trim marker:

(1) If there is a valid irqchip after a trim marker, this is wrong
(2) If there is a trim marker after another trim marker, this is wrong
(3) If there is a NULL irqchip before a trim marker, this is wrong
(4) If there is an error that isn't a trim marker, this is wrong

(1) and (2) are captured by:
		if (irqd->chip && tail)
(3) is captured by:
		if (!irqd->chip && !tail)
(4) is captured by:
		if (IS_ERR(irqd->chip)) {
			/* Only -ENOTCONN is a valid trim marker */
			if (PTR_ERR(irqd->chip) != -ENOTCONN)

The expected usage is that:

- there is a single potential trim marker in the hierarchy
- all the irqd->chip pointers below the marker are NULL
- all the irqd->chip before the marker are neither NULL nor an error

I don't see any bug here.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

  reply	other threads:[~2021-08-20 15:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-19 11:53 [PATCH v2 0/3] Start getting rid of the GPIO_NO_WAKE_IRQ Maulik Shah
2021-08-19 11:53 ` [PATCH v2 1/3] irqdomain: Export irq_domain_disconnect_hierarchy() Maulik Shah
2021-08-19 11:53 ` [PATCH v2 2/3] irqdomain: Fix irq_domain_trim_hierarchy() Maulik Shah
2021-08-20 15:54   ` Marc Zyngier [this message]
2021-08-19 11:53 ` [PATCH v2 3/3] irqchip/qcom-pdc: Start getting rid of the GPIO_NO_WAKE_IRQ Maulik Shah
2021-08-20 15:38   ` Marc Zyngier
2021-08-23  7:55     ` Maulik Shah

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=87im00qfgy.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lsrao@codeaurora.org \
    --cc=mkshah@codeaurora.org \
    --cc=tglx@linutronix.de \
    --cc=tkjos@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.