linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] serial: sh-sci: Do not free irqs that have already been freed
@ 2019-01-28 18:25 Chris Brandt
  2019-01-30 10:04 ` Simon Horman
  2019-02-01 14:18 ` Geert Uytterhoeven
  0 siblings, 2 replies; 3+ messages in thread
From: Chris Brandt @ 2019-01-28 18:25 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-serial, linux-renesas-soc, Chris Brandt

Since IRQs might be muxed on some parts, we need to pay attention when we
are freeing them.
Otherwise we get the ugly WARNING "Trying to free already-free IRQ 20".

Fixes: 628c534ae735 ("serial: sh-sci: Improve support for separate TEI and DRI interrupts")
Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
---
v2:
 * fix bad commit grammer
---
 drivers/tty/serial/sh-sci.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index cb3d5d37674f..060fcd42b6d5 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -1936,7 +1936,7 @@ static int sci_request_irq(struct sci_port *port)
 
 static void sci_free_irq(struct sci_port *port)
 {
-	int i;
+	int i, j;
 
 	/*
 	 * Intentionally in reverse order so we iterate over the muxed
@@ -1952,6 +1952,13 @@ static void sci_free_irq(struct sci_port *port)
 		if (unlikely(irq < 0))
 			continue;
 
+		/* Check if already freed (irq was muxed) */
+		for (j = 0; j < i; j++)
+			if (port->irqs[j] == irq)
+				j = i + 1;
+		if (j > i)
+			continue;
+
 		free_irq(port->irqs[i], port);
 		kfree(port->irqstr[i]);
 
-- 
2.16.1


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

* Re: [PATCH v2] serial: sh-sci: Do not free irqs that have already been freed
  2019-01-28 18:25 [PATCH v2] serial: sh-sci: Do not free irqs that have already been freed Chris Brandt
@ 2019-01-30 10:04 ` Simon Horman
  2019-02-01 14:18 ` Geert Uytterhoeven
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2019-01-30 10:04 UTC (permalink / raw)
  To: Chris Brandt; +Cc: Greg Kroah-Hartman, linux-serial, linux-renesas-soc

On Mon, Jan 28, 2019 at 01:25:56PM -0500, Chris Brandt wrote:
> Since IRQs might be muxed on some parts, we need to pay attention when we
> are freeing them.
> Otherwise we get the ugly WARNING "Trying to free already-free IRQ 20".
> 
> Fixes: 628c534ae735 ("serial: sh-sci: Improve support for separate TEI and DRI interrupts")
> Signed-off-by: Chris Brandt <chris.brandt@renesas.com>

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

> ---
> v2:
>  * fix bad commit grammer

s/grammer/grammar/ :)

> ---
>  drivers/tty/serial/sh-sci.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> index cb3d5d37674f..060fcd42b6d5 100644
> --- a/drivers/tty/serial/sh-sci.c
> +++ b/drivers/tty/serial/sh-sci.c
> @@ -1936,7 +1936,7 @@ static int sci_request_irq(struct sci_port *port)
>  
>  static void sci_free_irq(struct sci_port *port)
>  {
> -	int i;
> +	int i, j;
>  
>  	/*
>  	 * Intentionally in reverse order so we iterate over the muxed
> @@ -1952,6 +1952,13 @@ static void sci_free_irq(struct sci_port *port)
>  		if (unlikely(irq < 0))
>  			continue;
>  
> +		/* Check if already freed (irq was muxed) */
> +		for (j = 0; j < i; j++)
> +			if (port->irqs[j] == irq)
> +				j = i + 1;
> +		if (j > i)
> +			continue;
> +
>  		free_irq(port->irqs[i], port);
>  		kfree(port->irqstr[i]);
>  
> -- 
> 2.16.1
> 

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

* Re: [PATCH v2] serial: sh-sci: Do not free irqs that have already been freed
  2019-01-28 18:25 [PATCH v2] serial: sh-sci: Do not free irqs that have already been freed Chris Brandt
  2019-01-30 10:04 ` Simon Horman
@ 2019-02-01 14:18 ` Geert Uytterhoeven
  1 sibling, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2019-02-01 14:18 UTC (permalink / raw)
  To: Chris Brandt; +Cc: Greg Kroah-Hartman, open list:SERIAL DRIVERS, Linux-Renesas

Hi Chris,

On Mon, Jan 28, 2019 at 7:26 PM Chris Brandt <chris.brandt@renesas.com> wrote:
> Since IRQs might be muxed on some parts, we need to pay attention when we
> are freeing them.
> Otherwise we get the ugly WARNING "Trying to free already-free IRQ 20".
>
> Fixes: 628c534ae735 ("serial: sh-sci: Improve support for separate TEI and DRI interrupts")
> Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
> ---
> v2:

Thanks for the update!

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

> --- a/drivers/tty/serial/sh-sci.c
> +++ b/drivers/tty/serial/sh-sci.c

> @@ -1952,6 +1952,13 @@ static void sci_free_irq(struct sci_port *port)
>                 if (unlikely(irq < 0))
>                         continue;
>
> +               /* Check if already freed (irq was muxed) */
> +               for (j = 0; j < i; j++)
> +                       if (port->irqs[j] == irq)
> +                               j = i + 1;
> +               if (j > i)
> +                       continue;
> +
>                 free_irq(port->irqs[i], port);
>                 kfree(port->irqstr[i]);

I think the error path in sci_request_irq() needs similar handling, also for
SCIx_IRQ_IS_MUXED().

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

end of thread, other threads:[~2019-02-01 14:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-28 18:25 [PATCH v2] serial: sh-sci: Do not free irqs that have already been freed Chris Brandt
2019-01-30 10:04 ` Simon Horman
2019-02-01 14:18 ` Geert Uytterhoeven

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).