linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	Thorsten Scherer <t.scherer@eckelmann.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>
Subject: Re: [PATCH] gpio: siox: indicate exclusive support of threaded IRQs
Date: Thu, 6 Aug 2020 23:07:09 +0200	[thread overview]
Message-ID: <20200806210709.5etazgtsfgkdnoui@pengutronix.de> (raw)
In-Reply-To: <87eeojh5vh.fsf@nanos.tec.linutronix.de>

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

Hello Thomas,

On Thu, Aug 06, 2020 at 10:33:06PM +0200, Thomas Gleixner wrote:
> Uwe Kleine-König <u.kleine-koenig@pengutronix.de> writes:
> > On Thu, Aug 06, 2020 at 08:50:45PM +0200, Thomas Gleixner wrote:
> >> handle_nested_irq() does not care. It cares about thread context,
> >> external reentrancy protection for the same nested interrupt and that
> >> the nested interrupt has a thread handler.
> >> 
> >> The latter is what goes belly up because w/o that threaded bit set the
> >> GPIO core fails to set nested thread. So if a consumer requests an
> >> interrupt with request_any_context_irq() then that fails to select
> >> thread mode which means the threaded handler is not set causing
> >> handle_nested_irq() to fail.
> >
> > For a caller of request_threaded_irq() that passes a relevant hardirq
> > handler the hardirq handler is never called but request_threaded_irq()
> > doesn't fail. The handler is just replaced by irq_nested_primary_handler
> > in __setup_irq(). Is that a bug? (I didn't test, just read the code, so I
> > might have missed something.)
> 
> Depends on what the threaded handler expects what the primary handler
> has done. It might just work or not :)

So we need something like:

diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 48c38e09c673..31777a0b79df 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -1393,12 +1393,18 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
 			ret = -EINVAL;
 			goto out_mput;
 		}
-		/*
-		 * Replace the primary handler which was provided from
-		 * the driver for non nested interrupt handling by the
-		 * dummy function which warns when called.
-		 */
-		new->handler = irq_nested_primary_handler;
+
+		if (new->handler == NULL) {
+			/* Scream loud if the primary handler gets called */
+			new->handler = irq_nested_primary_handler;
+		} else {
+			/*
+			 * The handler won't be called as the requestor expects,
+			 * so refuse to install the handler
+			 */
+			ret = -EINVAL;
+			goto out_mput;
+		}
 	} else {
 		if (irq_settings_can_thread(desc)) {
 			ret = irq_setup_forced_threading(new);

? Do we need to care for other allowed values of new->handler? Maybe
irq_default_primary_handler?

> > Is this bad enough to justify sending this patch to stable?
> 
> Yes, a Cc: stable and a Fixes: tag is justified.

That would be

Fixes: be8c8facc707 ("gpio: new driver to work with a 8x12 siox")

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

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

  reply	other threads:[~2020-08-06 21:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-04  9:16 [PATCH] gpio: siox: indicate exclusive support of threaded IRQs Ahmad Fatoum
2020-08-05  6:17 ` Uwe Kleine-König
2020-08-06 10:20   ` Thomas Gleixner
2020-08-06 13:32     ` Linus Walleij
2020-08-06 18:50       ` Thomas Gleixner
2020-08-06 19:46         ` Uwe Kleine-König
2020-08-06 20:33           ` Thomas Gleixner
2020-08-06 21:07             ` Uwe Kleine-König [this message]
2020-08-10 13:33               ` Uwe Kleine-König
2020-08-06 15:07     ` Uwe Kleine-König
2020-08-27 22:55 ` Linus Walleij
2020-09-07 15:33   ` Ahmad Fatoum

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=20200806210709.5etazgtsfgkdnoui@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=bgolaszewski@baylibre.com \
    --cc=kernel@pengutronix.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=t.scherer@eckelmann.de \
    --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).