public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Federico Vaga <federico.vaga@cern.ch>
Cc: Peter Korsgaard <peter@korsgaard.com>,
	linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/5] i2c:ocores: stop transfer on timeout
Date: Fri, 8 Feb 2019 17:58:43 +0100	[thread overview]
Message-ID: <20190208165843.GA1853@lunn.ch> (raw)
In-Reply-To: <20190208161201.7860-2-federico.vaga@cern.ch>

On Fri, Feb 08, 2019 at 05:11:57PM +0100, Federico Vaga wrote:
> Detecting a timeout is ok, but we also need to assert a STOP command on
> the bus in order to prevent it from generating interrupts when there are
> no on going transfers.
> 
> Example: very long transmission.
> 
> 1. ocores_xfer: START a transfer
> 2. ocores_isr : handle byte by byte the transfer
> 3. ocores_xfer: goes in timeout [[bugfix here]]
> 4. ocores_xfer: return to I2C subsystem and to the I2C driver
> 5. I2C driver : it may clean up the i2c_msg memory
> 6. ocores_isr : receives another interrupt (pending bytes to be
>                 transferred) but the i2c_msg memory is invalid now
> 
> So, since the transfer was too long, we have to detect the timeout and
> STOP the transfer.
> 
> Another point is that we have a critical region here. When handling the
> timeout condition we may have a running IRQ handler. For this reason I
> introduce a spinlock.
> 
> In order to make easier to understan locking I have:
> - added a new function to handle timeout
> - modified the current ocores_process() function in order to be protected
>   by the new spinlock
> Like this it is obvious at first sight that this locking serializes
> the execution of ocores_process() and ocores_process_timeout()
> 
> Signed-off-by: Federico Vaga <federico.vaga@cern.ch>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

  reply	other threads:[~2019-02-08 16:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-08 16:11 [PATCH v3 0/5] Federico Vaga
2019-02-08 16:11 ` [PATCH v3 1/5] i2c:ocores: stop transfer on timeout Federico Vaga
2019-02-08 16:58   ` Andrew Lunn [this message]
2019-02-08 16:11 ` [PATCH v3 2/5] i2c:ocores: do not handle IRQ if IF is not set Federico Vaga
2019-02-08 17:00   ` Andrew Lunn
2019-02-08 16:11 ` [PATCH v3 3/5] i2c:ocores: add polling interface Federico Vaga
2019-02-09 21:33   ` Andrew Lunn
2019-02-11  8:20     ` Federico Vaga
2019-02-08 16:12 ` [PATCH v3 4/5] i2c:ocores: add SPDX tag Federico Vaga
2019-02-08 17:01   ` Andrew Lunn
2019-02-08 17:16   ` Peter Rosin
2019-02-08 16:12 ` [PATCH v3 5/5] i2c:ocores: checkpatch fixes Federico Vaga
2019-02-08 17:03   ` Andrew Lunn
2019-02-09 21:41 ` [PATCH v3 0/5] Andrew Lunn

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=20190208165843.GA1853@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=federico.vaga@cern.ch \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter@korsgaard.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