All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Frank Schäfer" <fschaefer.oss@googlemail.com>
To: Mauro Carvalho Chehab <m.chehab@samsung.com>, unlisted-recipients:;
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
	Mauro Carvalho Chehab <mchehab@infradead.org>
Subject: Re: [PATCH v4 18/22] [media] em28xx: don't return -ENODEV for I2C xfer errors
Date: Sun, 05 Jan 2014 21:49:57 +0100	[thread overview]
Message-ID: <52C9C575.5030804@googlemail.com> (raw)
In-Reply-To: <1388832951-11195-19-git-send-email-m.chehab@samsung.com>

Am 04.01.2014 11:55, schrieb Mauro Carvalho Chehab:
> -ENODEV reports a permanent condition where a device is not found,
> and used only during device probing or device removal, as stated
> at  the V4L2 spec:
> 	http://linuxtv.org/downloads/v4l-dvb-apis/gen_errors.html
>
> Except during device detection, this is not the case of I2C
> transfer timeout errors.
>
> So, change them to return -EREMOTEIO instead.
Mauro,

make a step back and think about this again.
What are you doing here ?

You noticed that your HVR-950 device is working unstable for an unknown
reason.
Your specific device seems to be the only one, nobody could reproduce
your issues so far and with the HVR-900 for example (which is nearly
identical) we don't see any errors.

Then you started playing with the em28xx i2c transfer functions and
noticed, that if you repeat the same i2c operations again and again, you
finally have luck and it succeeds.
>From that you draw the conclusion, that i2c status 0x10 can't be a
permanent error and hence 0x10 can't be -ENODEV.
But that's wrong. Your problems could also be caused by
sporadic/temporary circuit failures (such as loose contacts or whatever).
Hardware errors can always happen and they are no reason for not using
-ENODEV.
Whether -ENODEV is the appropriate error code or not depends on the
devices error detection capabilities.

The second assumption you make is that 0x10 means that a timeout occured.
Which timeout are you talking about ?
The only timeout I can think of can happen with devices which use clock
stretching and hold down SCL too long.
In any case you have no evidence for this theory, too.

What we can say for sure ist that 0x10 includes the NACK error case
because this happens when the slave device isn't present / doesn't respond.
But that's all. We have no idea what 0x10 really means in detail.
Maybe it also covers things like clock stretching timeouts or general
SCL and SDA line errors, but we'll never know that without the datasheet.

Interpreting 0x10 as -ENODEV and all other errors as -EIO has been
working fine for ages now.
Changing it based on such fragile theories is no good idea.

NACK from my side.

> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
> ---
>  drivers/media/usb/em28xx/em28xx-i2c.c | 20 +++++++++-----------
>  1 file changed, 9 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/media/usb/em28xx/em28xx-i2c.c b/drivers/media/usb/em28xx/em28xx-i2c.c
> index 8b35aa51b9bb..c3ba8ace5c94 100644
> --- a/drivers/media/usb/em28xx/em28xx-i2c.c
> +++ b/drivers/media/usb/em28xx/em28xx-i2c.c
> @@ -81,7 +81,7 @@ static int em2800_i2c_send_bytes(struct em28xx *dev, u8 addr, u8 *buf, u16 len)
>  			return len;
>  		if (ret == 0x94 + len - 1) {
>  			em28xx_warn("R05 returned 0x%02x: I2C timeout", ret);
> -			return -ENODEV;
> +			return -EREMOTEIO;
>  		}
>  		if (ret < 0) {
>  			em28xx_warn("failed to get i2c transfer status from bridge register (error=%i)\n",
> @@ -125,7 +125,7 @@ static int em2800_i2c_recv_bytes(struct em28xx *dev, u8 addr, u8 *buf, u16 len)
>  			break;
>  		if (ret == 0x94 + len - 1) {
>  			em28xx_warn("R05 returned 0x%02x: I2C timeout", ret);
> -			return -ENODEV;
> +			return -EREMOTEIO;
>  		}
>  		if (ret < 0) {
>  			em28xx_warn("failed to get i2c transfer status from bridge register (error=%i)\n",
> @@ -203,7 +203,7 @@ static int em28xx_i2c_send_bytes(struct em28xx *dev, u16 addr, u8 *buf,
>  		if (ret == 0x10) {
>  			em28xx_warn("I2C transfer timeout on writing to addr 0x%02x",
>  				    addr);
> -			return -ENODEV;
> +			return -EREMOTEIO;
>  		}
>  		if (ret < 0) {
>  			em28xx_warn("failed to get i2c transfer status from bridge register (error=%i)\n",
> @@ -249,7 +249,7 @@ static int em28xx_i2c_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, u16 len)
>  	 * bytes if we are on bus B AND there was no write attempt to the
>  	 * specified slave address before AND no device is present at the
>  	 * requested slave address.
> -	 * Anyway, the next check will fail with -ENODEV in this case, so avoid
> +	 * Anyway, the next check will fail with -EREMOTEIO in this case, so avoid
>  	 * spamming the system log on device probing and do nothing here.
>  	 */
>  
> @@ -264,7 +264,7 @@ static int em28xx_i2c_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, u16 len)
>  	}
>  	if (ret == 0x10) {
>  		em28xx_warn("I2C transfer timeout on read from addr 0x%02x", addr);
> -		return -ENODEV;
> +		return -EREMOTEIO;
>  	}
>  
>  	em28xx_warn("unknown i2c error (status=%i)\n", ret);
> @@ -325,7 +325,7 @@ static int em25xx_bus_B_send_bytes(struct em28xx *dev, u16 addr, u8 *buf,
>  		return len;
>  	else if (ret > 0) {
>  		em28xx_warn("Bus B R08 returned 0x%02x: I2C timeout", ret);
> -		return -ENODEV;
> +		return -EREMOTEIO;
>  	}
>  
>  	return ret;
> @@ -364,8 +364,6 @@ static int em25xx_bus_B_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf,
>  	 * bytes if we are on bus B AND there was no write attempt to the
>  	 * specified slave address before AND no device is present at the
>  	 * requested slave address.
> -	 * Anyway, the next check will fail with -ENODEV in this case, so avoid
> -	 * spamming the system log on device probing and do nothing here.
>  	 */
>  
>  	/* Check success */
> @@ -378,7 +376,7 @@ static int em25xx_bus_B_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf,
>  		return len;
>  	else if (ret > 0) {
>  		em28xx_warn("Bus B R08 returned 0x%02x: I2C timeout", ret);
> -		return -ENODEV;
> +		return -EREMOTEIO;
>  	}
>  
>  	return ret;
> @@ -420,7 +418,7 @@ static inline int i2c_check_for_device(struct em28xx_i2c_bus *i2c_bus, u16 addr)
>  		rc = em2800_i2c_check_for_device(dev, addr);
>  	else if (i2c_bus->algo_type == EM28XX_I2C_ALGO_EM25XX_BUS_B)
>  		rc = em25xx_bus_B_check_for_device(dev, addr);
> -	if (rc == -ENODEV) {
> +	if (rc < 0) {
>  		if (i2c_debug)
>  			printk(" no device\n");
>  	}
> @@ -510,7 +508,7 @@ static int em28xx_i2c_xfer(struct i2c_adapter *i2c_adap,
>  			       addr, msgs[i].len);
>  		if (!msgs[i].len) { /* no len: check only for device presence */
>  			rc = i2c_check_for_device(i2c_bus, addr);
> -			if (rc == -ENODEV) {
> +			if (rc < 0) {
>  				rt_mutex_unlock(&dev->i2c_bus_lock);
>  				return rc;
>  			}


  reply	other threads:[~2014-01-05 20:48 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-04 10:55 [PATCH v4 00/22] em28xx: split analog part into a separate module Mauro Carvalho Chehab
2014-01-04 10:55 ` [PATCH v4 01/22] [media] em28xx: move some video-specific functions to em28xx-video Mauro Carvalho Chehab
2014-01-05 10:11   ` Frank Schäfer
2014-01-05 13:28     ` Mauro Carvalho Chehab
2014-01-04 10:55 ` [PATCH v4 02/22] [media] em28xx: some cosmetic changes Mauro Carvalho Chehab
2014-01-05 10:13   ` Frank Schäfer
2014-01-04 10:55 ` [PATCH v4 03/22] [media] em28xx: move analog-specific init to em28xx-video Mauro Carvalho Chehab
2014-01-05 10:26   ` Frank Schäfer
2014-01-05 14:40     ` Mauro Carvalho Chehab
2014-01-06 21:28       ` Frank Schäfer
2014-01-04 10:55 ` [PATCH v4 04/22] [media] em28xx: make em28xx-video to be a separate module Mauro Carvalho Chehab
2014-01-05 10:47   ` Frank Schäfer
2014-01-05 12:56     ` Mauro Carvalho Chehab
2014-01-05 15:18       ` Mauro Carvalho Chehab
2014-01-06 21:35         ` Frank Schäfer
2014-01-06 17:38       ` Frank Schäfer
2014-01-04 10:55 ` [PATCH v4 05/22] [media] em28xx: initialize analog I2C devices at the right place Mauro Carvalho Chehab
2014-01-05 10:48   ` Frank Schäfer
2014-01-04 10:55 ` [PATCH v4 06/22] [media] em28xx: add warn messages for timeout Mauro Carvalho Chehab
2014-01-05 10:51   ` Frank Schäfer
2014-01-05 13:05     ` Mauro Carvalho Chehab
2014-01-05 13:25     ` Mauro Carvalho Chehab
2014-01-04 10:55 ` [PATCH v4 07/22] [media] em28xx: improve extension information messages Mauro Carvalho Chehab
2014-01-05 10:55   ` Frank Schäfer
2014-01-05 13:08     ` Mauro Carvalho Chehab
2014-01-05 15:31       ` Mauro Carvalho Chehab
2014-01-06 17:44       ` Frank Schäfer
2014-01-06 18:17         ` Mauro Carvalho Chehab
2014-01-04 10:55 ` [PATCH v4 08/22] [media] em28xx: convert i2c wait completion logic to use jiffies Mauro Carvalho Chehab
2014-01-05 11:03   ` Frank Schäfer
2014-01-05 13:10     ` Mauro Carvalho Chehab
2014-01-06 17:48       ` Frank Schäfer
2014-01-04 10:55 ` [PATCH v4 09/22] [media] tvp5150: make read operations atomic Mauro Carvalho Chehab
2014-01-05 11:07   ` Frank Schäfer
2014-01-04 10:55 ` [PATCH v4 10/22] [media] tuner-xc2028: remove unused code Mauro Carvalho Chehab
2014-01-05 11:07   ` Frank Schäfer
2014-01-04 10:55 ` [PATCH v4 11/22] [media] em28xx: check if a device has audio earlier Mauro Carvalho Chehab
2014-01-05 11:12   ` Frank Schäfer
2014-01-05 13:22     ` Mauro Carvalho Chehab
2014-01-04 10:55 ` [PATCH v4 12/22] [media] em28xx: properly implement AC97 wait code Mauro Carvalho Chehab
2014-01-05 11:19   ` Frank Schäfer
2014-01-05 13:20     ` Mauro Carvalho Chehab
2014-01-05 15:44       ` Mauro Carvalho Chehab
2014-01-07 16:50         ` Frank Schäfer
2014-01-04 10:55 ` [PATCH v4 13/22] [media] em28xx: initialize audio latter Mauro Carvalho Chehab
2014-01-05 11:29   ` Frank Schäfer
2014-01-05 13:17     ` Mauro Carvalho Chehab
2014-01-07 17:00       ` Frank Schäfer
2014-01-08 14:29         ` Mauro Carvalho Chehab
2014-01-04 10:55 ` [PATCH v4 14/22] [media] em28xx: unify module version Mauro Carvalho Chehab
2014-01-05 11:33   ` Frank Schäfer
2014-01-04 10:55 ` [PATCH v4 15/22] [media] em28xx: Fix em28xx deplock Mauro Carvalho Chehab
2014-01-05 11:38   ` Frank Schäfer
2014-01-04 10:55 ` [PATCH v4 16/22] [media] em28xx: use a better value for I2C timeouts Mauro Carvalho Chehab
2014-01-05 20:38   ` Frank Schäfer
2014-01-05 20:57     ` Mauro Carvalho Chehab
2014-01-07 17:15       ` Frank Schäfer
2014-01-08 14:39         ` Mauro Carvalho Chehab
2014-01-04 10:55 ` [PATCH v4 17/22] [media] em28xx-i2c: Fix error code for I2C error transfers Mauro Carvalho Chehab
2014-01-05 20:40   ` Frank Schäfer
2014-01-06  9:55     ` Mauro Carvalho Chehab
2014-01-07 17:28       ` Frank Schäfer
2014-01-08 11:55         ` Mauro Carvalho Chehab
2014-01-08 19:37           ` Frank Schäfer
2014-01-04 10:55 ` [PATCH v4 18/22] [media] em28xx: don't return -ENODEV for I2C xfer errors Mauro Carvalho Chehab
2014-01-05 20:49   ` Frank Schäfer [this message]
2014-01-06 10:37     ` Mauro Carvalho Chehab
2014-01-04 10:55 ` [PATCH v4 19/22] [media] em28xx: cleanup I2C debug messages Mauro Carvalho Chehab
2014-01-05 20:54   ` Frank Schäfer
2014-01-04 10:55 ` [PATCH v4 20/22] [media] em28xx: use usb_alloc_coherent() for audio Mauro Carvalho Chehab
2014-01-05 20:57   ` Frank Schäfer
2014-01-04 10:55 ` [PATCH v4 21/22] [media] em28xx-audio: allocate URBs at device driver init Mauro Carvalho Chehab
2014-01-05 21:02   ` Frank Schäfer
2014-01-05 21:25     ` Mauro Carvalho Chehab
2014-01-06 16:25       ` Mauro Carvalho Chehab
2014-01-07 17:03       ` Frank Schäfer
2014-01-08 14:10         ` Mauro Carvalho Chehab
2014-01-08 19:14           ` Frank Schäfer
2014-01-04 10:55 ` [PATCH v4 22/22] [media] em28xx: retry read operation if it fails Mauro Carvalho Chehab
2014-01-05 21:06   ` Frank Schäfer

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=52C9C575.5030804@googlemail.com \
    --to=fschaefer.oss@googlemail.com \
    --cc=linux-media@vger.kernel.org \
    --cc=m.chehab@samsung.com \
    --cc=mchehab@infradead.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.