All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa@the-dreams.de>
To: Shardar Shariff Md <smohammed@nvidia.com>
Cc: ldewangan@nvidia.com, swarren@wwwdotorg.org,
	thierry.reding@gmail.com, gnurou@gmail.com,
	linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org, jonathanh@nvidia.com
Subject: Re: [PATCH v7 4/4] i2c: tegra: proper handling of error cases
Date: Wed, 11 May 2016 16:47:52 +0200	[thread overview]
Message-ID: <20160511144752.GD1716@katana> (raw)
In-Reply-To: <1461591519-24602-4-git-send-email-smohammed@nvidia.com>

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

On Mon, Apr 25, 2016 at 07:08:39PM +0530, Shardar Shariff Md wrote:
> To summarize the issue observed in error cases:
> 
> SW Flow: For i2c message transfer, packet header and data payload is
> posted and then required error/packet completion interrupts are enabled
> later.
> 
> HW flow: HW process the packet just after packet header is posted, if
> ARB lost/NACK error occurs (SW will not handle immediately when error
> happens as error interrupts are not enabled at this point). HW assumes
> error is acknowledged and clears current data in FIFO, But SW here posts
> the remaining data payload which still stays in FIFO as stale data
> (data without packet header).
> 
> Now once the interrupts are enabled, SW handles ARB lost/NACK error by
> clearing the ARB lost/NACK interrupt. Now HW assumes that SW attended
> the error and will parse/process stale data (data without packet header)
> present in FIFO which causes invalid NACK errors.
> 
> Fix: Enable the error interrupts before posting the packet into FIFO
> which make sure HW to not clear the fifo. Also disable the packet mode
> before acknowledging errors (ARB lost/NACK error) to not process any
> stale data. As error interrupts are enabled before posting the packet
> header use spinlock to avoid preempting.
> 
> Signed-off-by: Shardar Shariff Md <smohammed@nvidia.com>
> 
> ---
> Changes in v2:
> - Align the commit message to 72 characters per line.
> - Removing unnecessary paranthesis.
> - Handle error in isr
> 
> Changes in v3:
> - Printing error if tegra_i2c_disable_packet_mode() fails
>   is already present and handling error is not taken cared
>   in ISR which was done in v2 but keeping return error in
>   *wait_for_config_load() as its used in tegra_i2c_init()
> ---
>  drivers/i2c/busses/i2c-tegra.c | 28 ++++++++++++++++++++++++++--
>  1 file changed, 26 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
> index 8d49995..1181bbf 100644
> --- a/drivers/i2c/busses/i2c-tegra.c
> +++ b/drivers/i2c/busses/i2c-tegra.c
> @@ -194,6 +194,7 @@ struct tegra_i2c_dev {
>  	u16 clk_divisor_non_hs_mode;
>  	bool is_suspended;
>  	bool is_multimaster_mode;
> +	spinlock_t xfer_lock;

This lock needs a description. The sentence from above is a good
template: "As error interrupts are enabled before posting the packet
header use spinlock to avoid preempting.".

Patches 3+4 look good otherwise but need to be rebased on modified
patch 2.

Thanks,

   Wolfram


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2016-05-11 14:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-25 13:38 [PATCH v7 1/4] i2c: tegra: disable clock before returning error Shardar Shariff Md
2016-04-25 13:38 ` Shardar Shariff Md
     [not found] ` <1461591519-24602-1-git-send-email-smohammed-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-04-25 13:38   ` [PATCH v7 2/4] i2c: tegra: calculate timeout for config load when needed Shardar Shariff Md
2016-04-25 13:38     ` Shardar Shariff Md
     [not found]     ` <1461591519-24602-2-git-send-email-smohammed-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-05-11 14:42       ` Wolfram Sang
2016-05-11 14:42         ` Wolfram Sang
2016-04-25 13:38   ` [PATCH v7 4/4] i2c: tegra: proper handling of error cases Shardar Shariff Md
2016-04-25 13:38     ` Shardar Shariff Md
2016-05-11 14:47     ` Wolfram Sang [this message]
2016-04-25 13:54   ` [PATCH v7 1/4] i2c: tegra: disable clock before returning error Wolfram Sang
2016-04-25 13:54     ` Wolfram Sang
2016-04-25 13:38 ` [PATCH v7 3/4] i2c: tegra: add separate function for config_load Shardar Shariff Md
2016-04-25 13:38   ` Shardar Shariff Md
2016-05-11 14:33 ` [PATCH v7 1/4] i2c: tegra: disable clock before returning error Wolfram Sang

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=20160511144752.GD1716@katana \
    --to=wsa@the-dreams.de \
    --cc=gnurou@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=ldewangan@nvidia.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=smohammed@nvidia.com \
    --cc=swarren@wwwdotorg.org \
    --cc=thierry.reding@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 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.