linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: "Andreas Färber" <afaerber@suse.de>
Cc: Jason Cooper <jason@lakedaemon.net>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-realtek-soc@lists.infradead.org
Subject: Re: [PATCH v5 3/9] irqchip: rtd1195-mux: Implement irq_get_irqchip_state
Date: Thu, 12 Dec 2019 13:48:41 +0000	[thread overview]
Message-ID: <f756e3ccde3b928ccc75f41f2012895a@www.loen.fr> (raw)
In-Reply-To: <20191121050208.11324-4-afaerber@suse.de>

On 2019-11-21 05:02, Andreas Färber wrote:
> Implement the .irq_get_irqchip_state callback to retrieve pending,
> active and masked interrupt status.
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
>  v5: New
>
>  drivers/irqchip/irq-rtd1195-mux.c | 36 
> ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
>
> diff --git a/drivers/irqchip/irq-rtd1195-mux.c
> b/drivers/irqchip/irq-rtd1195-mux.c
> index 0e86973aafca..2f1bcfd9d5d6 100644
> --- a/drivers/irqchip/irq-rtd1195-mux.c
> +++ b/drivers/irqchip/irq-rtd1195-mux.c
> @@ -7,6 +7,7 @@
>
>  #include <linux/bitops.h>
>  #include <linux/io.h>
> +#include <linux/interrupt.h>
>  #include <linux/irqchip.h>
>  #include <linux/irqchip/chained_irq.h>
>  #include <linux/irqdomain.h>
> @@ -96,10 +97,45 @@ static void rtd1195_mux_unmask_irq(struct 
> irq_data *data)
>  	raw_spin_unlock_irqrestore(&mux->lock, flags);
>  }
>
> +static int rtd1195_mux_get_irqchip_state(struct irq_data *data,
> +	enum irqchip_irq_state which, bool *state)
> +{
> +	struct rtd1195_irq_mux_data *mux = 
> irq_data_get_irq_chip_data(data);
> +	u32 val;
> +
> +	switch (which) {
> +	case IRQCHIP_STATE_PENDING:
> +		/*
> +		 * UMSK_ISR provides the unmasked pending interrupts,
> +		 * except UART and I2C.
> +		 */
> +		val = readl_relaxed(mux->reg_umsk_isr);
> +		*state = !!(val & BIT(data->hwirq));
> +		break;
> +	case IRQCHIP_STATE_ACTIVE:
> +		/*
> +		 * ISR provides the masked pending interrupts,
> +		 * including UART and I2C.
> +		 */
> +		val = readl_relaxed(mux->reg_isr);
> +		*state = !!(val & BIT(data->hwirq));
> +		break;

ACTIVE has a very specific meaning: it indicates that the interrupt is
being handled right now. What this tells you is whether the interrupt
is pending and unmasked, which is an entirely different thing.

This will lead to irq_disable() misbehaving (it will assume that
the interrupt is active while it is only pending).

Given what the HW exposes (or rather, what this driver exposes of the 
HW),
I don't think you can implement this state.

> +	case IRQCHIP_STATE_MASKED:
> +		val = mux->info->isr_to_int_en_mask[data->hwirq];
> +		*state = !(mux->scpu_int_en & val);

Shouldn't you take the corresponding spinlock given that you can
have a pending update in parallel?

         M.

> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	return 0;
> +}
> +
>  static const struct irq_chip rtd1195_mux_irq_chip = {
>  	.irq_ack		= rtd1195_mux_ack_irq,
>  	.irq_mask		= rtd1195_mux_mask_irq,
>  	.irq_unmask		= rtd1195_mux_unmask_irq,
> +	.irq_get_irqchip_state	= rtd1195_mux_get_irqchip_state,
>  };
>
>  static int rtd1195_mux_irq_domain_map(struct irq_domain *d,

-- 
Jazz is not dead. It just smells funny...

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-12-12 13:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-21  5:01 [PATCH v5 0/9] ARM: Realtek RTD1195/RTD1295/RTD1395 IRQ mux Andreas Färber
2019-11-21  5:02 ` [PATCH v5 1/9] dt-bindings: interrupt-controller: Add Realtek RTD1195/RTD1295 mux Andreas Färber
2019-11-21  5:02 ` [PATCH v5 2/9] irqchip: Add Realtek RTD1295 mux driver Andreas Färber
2019-11-21  5:02 ` [PATCH v5 3/9] irqchip: rtd1195-mux: Implement irq_get_irqchip_state Andreas Färber
2019-12-12 13:48   ` Marc Zyngier [this message]
2019-11-21  5:02 ` [PATCH v5 4/9] arm64: dts: realtek: rtd129x: Add irq muxes and UART interrupts Andreas Färber
2019-11-21  5:02 ` [PATCH v5 5/9] irqchip: rtd1195-mux: Add RTD1195 definitions Andreas Färber
2019-11-21  5:02 ` [PATCH v5 6/9] ARM: dts: rtd1195: Add irq muxes and UART interrupts Andreas Färber
2019-11-21  5:02 ` [PATCH v5 7/9] dt-bindings: interrupt-controller: rtd1195-mux: Add RTD1395 Andreas Färber
2019-11-22 23:34   ` Rob Herring
2019-11-21  5:02 ` [PATCH v5 8/9] irqchip: rtd1195-mux: Add RTD1395 definitions Andreas Färber
2019-11-21  5:02 ` [PATCH v5 9/9] arm64: dts: realtek: rtd139x: Add irq muxes and UART interrupts Andreas Färber

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=f756e3ccde3b928ccc75f41f2012895a@www.loen.fr \
    --to=maz@kernel.org \
    --cc=afaerber@suse.de \
    --cc=jason@lakedaemon.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-realtek-soc@lists.infradead.org \
    --cc=tglx@linutronix.de \
    /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).