All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
To: Hubert Feurstein <h.feurstein-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Nikolaus Voss <n.voss-+umVssTZoCsb1SvskN2V4Q@public.gmane.org>,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org,
	balbi-l0cyMroinI0@public.gmane.org,
	rmallon-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Subject: Re: [PATCH v9 3/4] drivers/i2c/busses/i2c-at91.c: add new driver
Date: Fri, 13 Apr 2012 13:39:41 +0300	[thread overview]
Message-ID: <20120413103937.GH7154@arwen.pp.htv.fi> (raw)
In-Reply-To: <CAFfN3gWCu5RnKb6dK4YMCAhpkfLncYdk1Cwqxb3wxMVznSiSFQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

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

Hi,

On Fri, Apr 13, 2012 at 12:17:59PM +0200, Hubert Feurstein wrote:
> Hi Niko,
> 
> I'm using this driver since a while a now in my system
> (soc:at91sam9m10; kernel:v3.2.14) and it works quite well. But
> occasionally it happens that wrong data is read from my devices. I've
> traced down the issue to the way how you do the interrupt handling. In
> your code you do not consider that both status-flags (TXCOMP and
> RXRDY) may be pending at the same time. So you handle the TXCOMP but
> NOT the RXRDY which will cause a data-loss on the current transfer. As
> a consequence also the next transfer will be corrupt, because you
> start with old data in RHR. So I would suggest the following changes:
> 
> static irqreturn_t atmel_twi_interrupt(int irq, void *dev_id)
> {
> 	struct at91_twi_dev *dev = dev_id;
> 	const unsigned status = at91_twi_read(dev, AT91_TWI_SR);
> 	unsigned irqstatus = status & at91_twi_read(dev, AT91_TWI_IMR);
> 
> 	if (irqstatus & AT91_TWI_RXRDY) {
> 		at91_twi_read_next_byte(dev);
> 		irqstatus &= ~AT91_TWI_RXRDY;
> 	}
> 
> 	if (irqstatus & AT91_TWI_TXRDY) {
> 		at91_twi_write_next_byte(dev);
> 		irqstatus &= ~AT91_TWI_TXRDY;
> 	}
> 
> 	if (irqstatus & AT91_TWI_TXCOMP) {
> 		at91_disable_twi_interrupts(dev);
> 		dev->transfer_status = status;
> 		complete(&dev->cmd_complete);
> 		irqstatus &= ~AT91_TWI_TXCOMP;
> 	}
> 	
> 	if (irqstatus) {
> 		/* There should be no pending interrupt anymore. *)
> 		return IRQ_NONE;
> 	}

Dude, I remember asking the exact same thing when he first posted this
driver. That whole if...else if... else if ... else didn't look right.

Can you send this in patch format Hubert ? Take a look at
Documentation/SumittingPatches if you have never done it before.

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Felipe Balbi <balbi@ti.com>
To: Hubert Feurstein <h.feurstein@gmail.com>
Cc: Nikolaus Voss <n.voss@weinmann.de>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org,
	nicolas.ferre@atmel.com, ben-linux@fluff.org, balbi@ti.com,
	rmallon@gmail.com
Subject: Re: [PATCH v9 3/4] drivers/i2c/busses/i2c-at91.c: add new driver
Date: Fri, 13 Apr 2012 13:39:41 +0300	[thread overview]
Message-ID: <20120413103937.GH7154@arwen.pp.htv.fi> (raw)
In-Reply-To: <CAFfN3gWCu5RnKb6dK4YMCAhpkfLncYdk1Cwqxb3wxMVznSiSFQ@mail.gmail.com>

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

Hi,

On Fri, Apr 13, 2012 at 12:17:59PM +0200, Hubert Feurstein wrote:
> Hi Niko,
> 
> I'm using this driver since a while a now in my system
> (soc:at91sam9m10; kernel:v3.2.14) and it works quite well. But
> occasionally it happens that wrong data is read from my devices. I've
> traced down the issue to the way how you do the interrupt handling. In
> your code you do not consider that both status-flags (TXCOMP and
> RXRDY) may be pending at the same time. So you handle the TXCOMP but
> NOT the RXRDY which will cause a data-loss on the current transfer. As
> a consequence also the next transfer will be corrupt, because you
> start with old data in RHR. So I would suggest the following changes:
> 
> static irqreturn_t atmel_twi_interrupt(int irq, void *dev_id)
> {
> 	struct at91_twi_dev *dev = dev_id;
> 	const unsigned status = at91_twi_read(dev, AT91_TWI_SR);
> 	unsigned irqstatus = status & at91_twi_read(dev, AT91_TWI_IMR);
> 
> 	if (irqstatus & AT91_TWI_RXRDY) {
> 		at91_twi_read_next_byte(dev);
> 		irqstatus &= ~AT91_TWI_RXRDY;
> 	}
> 
> 	if (irqstatus & AT91_TWI_TXRDY) {
> 		at91_twi_write_next_byte(dev);
> 		irqstatus &= ~AT91_TWI_TXRDY;
> 	}
> 
> 	if (irqstatus & AT91_TWI_TXCOMP) {
> 		at91_disable_twi_interrupts(dev);
> 		dev->transfer_status = status;
> 		complete(&dev->cmd_complete);
> 		irqstatus &= ~AT91_TWI_TXCOMP;
> 	}
> 	
> 	if (irqstatus) {
> 		/* There should be no pending interrupt anymore. *)
> 		return IRQ_NONE;
> 	}

Dude, I remember asking the exact same thing when he first posted this
driver. That whole if...else if... else if ... else didn't look right.

Can you send this in patch format Hubert ? Take a look at
Documentation/SumittingPatches if you have never done it before.

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: balbi@ti.com (Felipe Balbi)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v9 3/4] drivers/i2c/busses/i2c-at91.c: add new driver
Date: Fri, 13 Apr 2012 13:39:41 +0300	[thread overview]
Message-ID: <20120413103937.GH7154@arwen.pp.htv.fi> (raw)
In-Reply-To: <CAFfN3gWCu5RnKb6dK4YMCAhpkfLncYdk1Cwqxb3wxMVznSiSFQ@mail.gmail.com>

Hi,

On Fri, Apr 13, 2012 at 12:17:59PM +0200, Hubert Feurstein wrote:
> Hi Niko,
> 
> I'm using this driver since a while a now in my system
> (soc:at91sam9m10; kernel:v3.2.14) and it works quite well. But
> occasionally it happens that wrong data is read from my devices. I've
> traced down the issue to the way how you do the interrupt handling. In
> your code you do not consider that both status-flags (TXCOMP and
> RXRDY) may be pending at the same time. So you handle the TXCOMP but
> NOT the RXRDY which will cause a data-loss on the current transfer. As
> a consequence also the next transfer will be corrupt, because you
> start with old data in RHR. So I would suggest the following changes:
> 
> static irqreturn_t atmel_twi_interrupt(int irq, void *dev_id)
> {
> 	struct at91_twi_dev *dev = dev_id;
> 	const unsigned status = at91_twi_read(dev, AT91_TWI_SR);
> 	unsigned irqstatus = status & at91_twi_read(dev, AT91_TWI_IMR);
> 
> 	if (irqstatus & AT91_TWI_RXRDY) {
> 		at91_twi_read_next_byte(dev);
> 		irqstatus &= ~AT91_TWI_RXRDY;
> 	}
> 
> 	if (irqstatus & AT91_TWI_TXRDY) {
> 		at91_twi_write_next_byte(dev);
> 		irqstatus &= ~AT91_TWI_TXRDY;
> 	}
> 
> 	if (irqstatus & AT91_TWI_TXCOMP) {
> 		at91_disable_twi_interrupts(dev);
> 		dev->transfer_status = status;
> 		complete(&dev->cmd_complete);
> 		irqstatus &= ~AT91_TWI_TXCOMP;
> 	}
> 	
> 	if (irqstatus) {
> 		/* There should be no pending interrupt anymore. *)
> 		return IRQ_NONE;
> 	}

Dude, I remember asking the exact same thing when he first posted this
driver. That whole if...else if... else if ... else didn't look right.

Can you send this in patch format Hubert ? Take a look at
Documentation/SumittingPatches if you have never done it before.

-- 
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120413/dabfb87a/attachment-0001.sig>

  parent reply	other threads:[~2012-04-13 10:39 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-19 15:07 [PATCH v9 0/4] AT91: replace broken TWI driver i2c-at91.c Nikolaus Voss
2012-03-19 15:07 ` Nikolaus Voss
2011-11-08 10:49 ` [PATCH v9 1/4] drivers/i2c/busses/i2c-at91.c: remove broken driver Nikolaus Voss
2011-11-08 10:49   ` Nikolaus Voss
2011-11-08 10:49 ` [PATCH v9 3/4] drivers/i2c/busses/i2c-at91.c: add new driver Nikolaus Voss
2011-11-08 10:49   ` Nikolaus Voss
     [not found]   ` <201203191534.q2JFYl1b012744-vb1CFJ/PVqUnDeILM3HATdG/hX4sBvbD@public.gmane.org>
2012-04-13 10:17     ` Hubert Feurstein
2012-04-13 10:17       ` Hubert Feurstein
2012-04-13 10:17       ` Hubert Feurstein
     [not found]       ` <CAFfN3gWCu5RnKb6dK4YMCAhpkfLncYdk1Cwqxb3wxMVznSiSFQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-04-13 10:39         ` Felipe Balbi [this message]
2012-04-13 10:39           ` Felipe Balbi
2012-04-13 10:39           ` Felipe Balbi
     [not found]           ` <20120413103937.GH7154-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2012-04-13 11:44             ` [PATCH] i2c-at91: fix data-loss issue Hubert Feurstein
2012-04-13 11:44               ` Hubert Feurstein
2012-04-13 11:44               ` Hubert Feurstein
     [not found]               ` <1334317476-10044-1-git-send-email-h.feurstein-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-04-13 22:06                 ` Ryan Mallon
2012-04-13 22:06                   ` Ryan Mallon
2012-04-13 22:06                   ` Ryan Mallon
2012-04-16  7:30               ` Voss, Nikolaus
2012-04-16  7:30                 ` Voss, Nikolaus
2012-04-16  7:30                 ` Voss, Nikolaus
     [not found]                 ` <EF2E73589CA71846A15D0B2CDF79505D0905D5A1AA-qhZVaJ2D3XF9OWT4OSQXE9BPR1lH4CV8@public.gmane.org>
2012-04-16  9:27                   ` Hubert Feurstein
2012-04-16  9:27                     ` Hubert Feurstein
2012-04-16  9:27                     ` Hubert Feurstein
2012-04-18 14:39                 ` Wolfram Sang
2012-04-18 14:39                   ` Wolfram Sang
2012-04-18 14:39                   ` Wolfram Sang
2012-04-21 19:33                   ` Adrian Yanes
2012-04-23  5:39                     ` Voss, Nikolaus
2012-04-23  5:39                       ` Voss, Nikolaus
2012-04-23  5:39                       ` Voss, Nikolaus
2012-04-23  6:24                       ` Adrian Yanes
2012-04-23  6:24                         ` Adrian Yanes
2012-04-23  6:24                         ` Adrian Yanes
2012-04-25  5:26                         ` Adrian Yanes
     [not found] ` <cover.1322479017a.git.n.voss-+umVssTZoCsb1SvskN2V4Q@public.gmane.org>
2011-11-08 11:09   ` [PATCH v9 2/4] Replace clk_lookup.con_id with clk_lookup.dev_id entries for twi clk Nikolaus Voss
2011-11-08 11:09     ` Nikolaus Voss
2011-11-08 11:11 ` [PATCH v9 4/4] G45 TWI: remove open drain setting for twi function gpios Nikolaus Voss
2011-11-08 11:11   ` Nikolaus Voss

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=20120413103937.GH7154@arwen.pp.htv.fi \
    --to=balbi-l0cymroini0@public.gmane.org \
    --cc=ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
    --cc=h.feurstein-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=n.voss-+umVssTZoCsb1SvskN2V4Q@public.gmane.org \
    --cc=nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org \
    --cc=rmallon-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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 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.