From: "Samuel Iglesias Gonsálvez" <siglesias@igalia.com>
To: Federico Vaga <federico.vaga@cern.ch>
Cc: jens.taprogge@taprogge.org, gregkh@linuxfoundation.org,
industrypack-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ipoctal: protect only the real critical section
Date: Thu, 26 Jun 2014 09:52:50 +0200 [thread overview]
Message-ID: <1403769170.4516.5.camel@fourier> (raw)
In-Reply-To: <1403768784-21605-1-git-send-email-federico.vaga@cern.ch>
[-- Attachment #1: Type: text/plain, Size: 2206 bytes --]
On Thu, 2014-06-26 at 09:46 +0200, Federico Vaga wrote:
> In some conditions (echo or particular sequence of special
> characters), on buffer push, the tty layer calls the write operation
> while we are holding the spinlock. This means deadlock within the same
> process on kernels version < 3.12. It seems not a problem on recent
> kernel, but the patch still valid as locking optimization.
>
> The protected variables by the spinlock are: xmit_buf, nb_bytes,
> pointer_read and pointer_write. So, this patch reduces the locked area
> in the IRQ handler only to these variables. Most of the code inside the
> locked area in the IRQ handler is not protected elsewhere; it means
> that it is not protected at all.
>
> Signed-off-by: Federico Vaga <federico.vaga@cern.ch>
> ---
> drivers/ipack/devices/ipoctal.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/ipack/devices/ipoctal.c b/drivers/ipack/devices/ipoctal.c
> index 141094e..69687f1 100644
> --- a/drivers/ipack/devices/ipoctal.c
> +++ b/drivers/ipack/devices/ipoctal.c
> @@ -177,19 +177,20 @@ static void ipoctal_irq_tx(struct ipoctal_channel *channel)
> if (channel->nb_bytes == 0)
> return;
>
> + spin_lock(&channel->lock);
> value = channel->tty_port.xmit_buf[*pointer_write];
> iowrite8(value, &channel->regs->w.thr);
> channel->stats.tx++;
> (*pointer_write)++;
> *pointer_write = *pointer_write % PAGE_SIZE;
> channel->nb_bytes--;
> + spin_unlock(&channel->lock);
> }
>
> static void ipoctal_irq_channel(struct ipoctal_channel *channel)
> {
> u8 isr, sr;
>
> - spin_lock(&channel->lock);
> /* The HW is organized in pair of channels. See which register we need
> * to read from */
> isr = ioread8(&channel->block_regs->r.isr);
> @@ -213,8 +214,6 @@ static void ipoctal_irq_channel(struct ipoctal_channel *channel)
> /* TX of each character */
> if ((isr & channel->isr_tx_rdy_mask) && (sr & SR_TX_READY))
> ipoctal_irq_tx(channel);
> -
> - spin_unlock(&channel->lock);
> }
>
> static irqreturn_t ipoctal_irq_handler(void *arg)
Acked-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Sam
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2014-06-26 8:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-26 7:46 [PATCH] ipoctal: protect only the real critical section Federico Vaga
2014-06-26 7:52 ` Samuel Iglesias Gonsálvez [this message]
2014-07-03 8:55 ` [Industrypack-devel] " Samuel Iglesias Gonsálvez
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=1403769170.4516.5.camel@fourier \
--to=siglesias@igalia.com \
--cc=federico.vaga@cern.ch \
--cc=gregkh@linuxfoundation.org \
--cc=industrypack-devel@lists.sourceforge.net \
--cc=jens.taprogge@taprogge.org \
--cc=linux-kernel@vger.kernel.org \
/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