public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: ygeorgie@gmail.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] serial: mcf: Don't take spinlocks in already protected functions
Date: Mon, 14 Jun 2010 12:12:25 -0700	[thread overview]
Message-ID: <20100614121225.a03c9203.akpm@linux-foundation.org> (raw)
In-Reply-To: <1276070186-11393-1-git-send-email-ygeorgie@gmail.com>

On Wed,  9 Jun 2010 09:56:26 +0200
ygeorgie@gmail.com wrote:

> From: Yury Georgievskiy <ygeorgie@gmail.com>
> 
> Don't take the port spinlock in uart functions where the serial core
> already takes care of locking/unlocking them.
> 
> The code would actually lock up on architectures where spinlocks are
> implemented.
> 
> Also protect calling mcf_rx_chars/mcf_tx_chars in the
> interrupt handler by the port spinlock and use IRQ_RETVAL
> to return from isr.
> 

Thanks.  Did you runtime test this?

> @@ -368,11 +354,15 @@ static irqreturn_t mcf_interrupt(int irq, void *data)
>  	unsigned int isr;
>  
>  	isr = readb(port->membase + MCFUART_UISR) & pp->imr;
> +
> +	spin_lock(&port->lock);
>  	if (isr & MCFUART_UIR_RXREADY)
>  		mcf_rx_chars(pp);
>  	if (isr & MCFUART_UIR_TXREADY)
>  		mcf_tx_chars(pp);
> -	return IRQ_HANDLED;
> +	spin_unlock(&port->lock);
> +
> +	return IRQ_RETVAL(isr);
>  }

I think this is a little abusive of IRQ_RETVAL.  If there are some bits
set in `isr' other than MCFUART_UIR_RXREADY and MCFUART_UIR_TXREADY, we
claim we handled it, only we didn't.

Probably the code works OK, but it all seems a bit uncomfortable. 
Perhaps make it more explicit?


--- a/drivers/serial/mcf.c~serial-mcf-dont-take-spinlocks-in-already-protected-functions-fix
+++ a/drivers/serial/mcf.c
@@ -352,17 +352,22 @@ static irqreturn_t mcf_interrupt(int irq
 	struct uart_port *port = data;
 	struct mcf_uart *pp = container_of(port, struct mcf_uart, port);
 	unsigned int isr;
+	irqreturn_t ret = IRQ_NONE;
 
 	isr = readb(port->membase + MCFUART_UISR) & pp->imr;
 
 	spin_lock(&port->lock);
-	if (isr & MCFUART_UIR_RXREADY)
+	if (isr & MCFUART_UIR_RXREADY) {
 		mcf_rx_chars(pp);
-	if (isr & MCFUART_UIR_TXREADY)
+		ret = IRQ_HANDLED;
+	}
+	if (isr & MCFUART_UIR_TXREADY) {
 		mcf_tx_chars(pp);
+		ret = IRQ_HANDLED;
+	}
 	spin_unlock(&port->lock);
 
-	return IRQ_RETVAL(isr);
+	return ret;
 }
 
 /****************************************************************************/
_


  reply	other threads:[~2010-06-14 19:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-09  7:56 [PATCH 1/1] serial: mcf: Don't take spinlocks in already protected functions ygeorgie
2010-06-14 19:12 ` Andrew Morton [this message]
2010-06-14 20:20   ` Yury Georgievskiy

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=20100614121225.a03c9203.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ygeorgie@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox