All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: greybus: Fix the irq API abuse
@ 2020-03-06 13:24 Thomas Gleixner
  2020-03-09  8:30 ` Johan Hovold
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Gleixner @ 2020-03-06 13:24 UTC (permalink / raw)
  To: LKML
  Cc: Rui Miguel Silva, Johan Hovold, Alex Elder, Greg Kroah-Hartman,
	greybus-dev

Nothing outside of low level architecture code is supposed to look up
interrupt descriptors and fiddle with them.

Replace the open coded abuse by calling generic_handle_irq().

This still does not explain why and in which context this connection
magic is injecting interrupts in the first place and why this is correct
and safe, but at least the API abuse is gone.

Fixes: 036aad9d0224 ("greybus: gpio: add interrupt handling support")
Fixes: 2611ebef8322 ("greybus: gpio: don't call irq-flow handler directly")
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/staging/greybus/gpio.c |   15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

--- a/drivers/staging/greybus/gpio.c
+++ b/drivers/staging/greybus/gpio.c
@@ -364,8 +364,7 @@ static int gb_gpio_request_handler(struc
 	struct gb_message *request;
 	struct gb_gpio_irq_event_request *event;
 	u8 type = op->type;
-	int irq;
-	struct irq_desc *desc;
+	int irq, ret;
 
 	if (type != GB_GPIO_TYPE_IRQ_EVENT) {
 		dev_err(dev, "unsupported unsolicited request: %u\n", type);
@@ -391,17 +390,15 @@ static int gb_gpio_request_handler(struc
 		dev_err(dev, "failed to find IRQ\n");
 		return -EINVAL;
 	}
-	desc = irq_to_desc(irq);
-	if (!desc) {
-		dev_err(dev, "failed to look up irq\n");
-		return -EINVAL;
-	}
 
 	local_irq_disable();
-	generic_handle_irq_desc(desc);
+	ret = generic_handle_irq(irq);
 	local_irq_enable();
 
-	return 0;
+	if (ret)
+		dev_err(dev, "failed to invoke irq handler\n");
+
+	return ret;
 }
 
 static int gb_gpio_request(struct gpio_chip *chip, unsigned int offset)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] staging: greybus: Fix the irq API abuse
  2020-03-06 13:24 [PATCH] staging: greybus: Fix the irq API abuse Thomas Gleixner
@ 2020-03-09  8:30 ` Johan Hovold
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Hovold @ 2020-03-09  8:30 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, Rui Miguel Silva, Johan Hovold, Alex Elder,
	Greg Kroah-Hartman, greybus-dev

On Fri, Mar 06, 2020 at 02:24:13PM +0100, Thomas Gleixner wrote:
> Nothing outside of low level architecture code is supposed to look up
> interrupt descriptors and fiddle with them.
> 
> Replace the open coded abuse by calling generic_handle_irq().
> 
> This still does not explain why and in which context this connection
> magic is injecting interrupts in the first place and why this is correct
> and safe, but at least the API abuse is gone.

Yeah, there's more to that story. The interrupt-handling was known to
have issues, but I can't seem to find the details right now.

> Fixes: 036aad9d0224 ("greybus: gpio: add interrupt handling support")
> Fixes: 2611ebef8322 ("greybus: gpio: don't call irq-flow handler directly")
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Acked-by: Johan Hovold <johan@kernel.org>

Johan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-09  8:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-06 13:24 [PATCH] staging: greybus: Fix the irq API abuse Thomas Gleixner
2020-03-09  8:30 ` Johan Hovold

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.