linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Sverdlin, Alexander (Nokia - DE/Ulm)" <alexander.sverdlin@nokia.com>
To: "Adamski,
	Krzysztof (Nokia - PL/Wroclaw)"  <krzysztof.adamski@nokia.com>,
	Wolfram Sang <wsa@the-dreams.de>
Cc: "linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Guenter Roeck <linux@roeck-us.net>,
	Tobias Jordan <Tobias.Jordan@elektrobit.com>,
	Peter Rosin <peda@axentia.se>
Subject: Re: [PATCH 2/3] i2c-axxia: check for error conditions first
Date: Tue, 11 Dec 2018 12:02:32 +0000	[thread overview]
Message-ID: <bb305008-f552-b7d0-49f6-daf76a827e1f@nokia.com> (raw)
In-Reply-To: <d9a8070357973b5078dc897a18f319cba1df5de0.1544453688.git.krzysztof.adamski@nokia.com>

Hi!

On 10/12/2018 16:01, Adamski, Krzysztof (Nokia - PL/Wroclaw) wrote:
> It was observed that when using seqentional mode contrary to the
                                  ^^^^^^^^^^^
> documentation, the SS bit (which is supposed to only be set if
> automatic/sequence command completed normally), is sometimes set
> together with NA (NAK in address phase) causing transfer to falsely be
> considered successful.
> 
> My assumption is that this does not happen during manual mode since the
> controller is stopping its work the moment it sets NA/ND bit in status
> register. This is not the case in Automatic/Sequentional mode where it
                                              ^^^^^^^^^^^^
> is still working to send STOP condition and the actual status we get
> depends on the time when the ISR is run.
> 
> This patch changes the order of checking status bits in ISR - error
> conditions are checked first and only if none of them occurred, the
> transfer may be considered successful. This is required to introduce
> using of sequentional mode in next patch.
           ^^^^^^^^^^^^
sequential

Reviewed-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>

> Signed-off-by: Krzysztof Adamski <krzysztof.adamski@nokia.com>
> ---
>  drivers/i2c/busses/i2c-axxia.c | 32 ++++++++++++++++----------------
>  1 file changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-axxia.c b/drivers/i2c/busses/i2c-axxia.c
> index d37caf694fbf..35258321e81b 100644
> --- a/drivers/i2c/busses/i2c-axxia.c
> +++ b/drivers/i2c/busses/i2c-axxia.c
> @@ -296,22 +296,7 @@ static irqreturn_t axxia_i2c_isr(int irq, void *_dev)
>  			i2c_int_disable(idev, MST_STATUS_TFL);
>  	}
>  
> -	if (status & MST_STATUS_SCC) {
> -		/* Stop completed */
> -		i2c_int_disable(idev, ~MST_STATUS_TSS);
> -		complete(&idev->msg_complete);
> -	} else if (status & MST_STATUS_SNS) {
> -		/* Transfer done */
> -		i2c_int_disable(idev, ~MST_STATUS_TSS);
> -		if (i2c_m_rd(idev->msg) && idev->msg_xfrd < idev->msg->len)
> -			axxia_i2c_empty_rx_fifo(idev);
> -		complete(&idev->msg_complete);
> -	} else if (status & MST_STATUS_TSS) {
> -		/* Transfer timeout */
> -		idev->msg_err = -ETIMEDOUT;
> -		i2c_int_disable(idev, ~MST_STATUS_TSS);
> -		complete(&idev->msg_complete);
> -	} else if (unlikely(status & MST_STATUS_ERR)) {
> +	if (unlikely(status & MST_STATUS_ERR)) {
>  		/* Transfer error */
>  		i2c_int_disable(idev, ~0);
>  		if (status & MST_STATUS_AL)
> @@ -328,6 +313,21 @@ static irqreturn_t axxia_i2c_isr(int irq, void *_dev)
>  			readl(idev->base + MST_TX_BYTES_XFRD),
>  			readl(idev->base + MST_TX_XFER));
>  		complete(&idev->msg_complete);
> +	} else if (status & MST_STATUS_SCC) {
> +		/* Stop completed */
> +		i2c_int_disable(idev, ~MST_STATUS_TSS);
> +		complete(&idev->msg_complete);
> +	} else if (status & MST_STATUS_SNS) {
> +		/* Transfer done */
> +		i2c_int_disable(idev, ~MST_STATUS_TSS);
> +		if (i2c_m_rd(idev->msg) && idev->msg_xfrd < idev->msg->len)
> +			axxia_i2c_empty_rx_fifo(idev);
> +		complete(&idev->msg_complete);
> +	} else if (status & MST_STATUS_TSS) {
> +		/* Transfer timeout */
> +		idev->msg_err = -ETIMEDOUT;
> +		i2c_int_disable(idev, ~MST_STATUS_TSS);
> +		complete(&idev->msg_complete);
>  	}
>  
>  out:
> 

-- 
Best regards,
Alexander Sverdlin.

  reply	other threads:[~2018-12-11 12:05 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-10 15:00 [PATCH 0/3] i2c-axxia: support Sequence command Adamski, Krzysztof (Nokia - PL/Wroclaw)
2018-12-10 15:00 ` [PATCH 1/3] i2c-axxia: dedicated function to set client addr Adamski, Krzysztof (Nokia - PL/Wroclaw)
2018-12-11 12:00   ` Sverdlin, Alexander (Nokia - DE/Ulm)
2018-12-11 20:05   ` Wolfram Sang
2018-12-10 15:01 ` [PATCH 2/3] i2c-axxia: check for error conditions first Adamski, Krzysztof (Nokia - PL/Wroclaw)
2018-12-11 12:02   ` Sverdlin, Alexander (Nokia - DE/Ulm) [this message]
2018-12-11 20:05   ` Wolfram Sang
2018-12-10 15:05 ` [PATCH 3/3] i2c-axxia: support sequence command mode Adamski, Krzysztof (Nokia - PL/Wroclaw)
2018-12-11 12:05   ` Sverdlin, Alexander (Nokia - DE/Ulm)
2018-12-11 20:04   ` Wolfram Sang
2018-12-13 12:09     ` [PATCH v2] i2c: axxia: " Adamski, Krzysztof (Nokia - PL/Wroclaw)
2018-12-13 12:45       ` Sverdlin, Alexander (Nokia - DE/Ulm)
2018-12-17 22:31       ` 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=bb305008-f552-b7d0-49f6-daf76a827e1f@nokia.com \
    --to=alexander.sverdlin@nokia.com \
    --cc=Tobias.Jordan@elektrobit.com \
    --cc=krzysztof.adamski@nokia.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=peda@axentia.se \
    --cc=wsa@the-dreams.de \
    /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;
as well as URLs for NNTP newsgroup(s).