Skip to contentSkip to conversation

xilinx_xiic: Fix fill tx fifo loop

PATCH Superseded Melin Tomas 3 participants 25 messages Jun 25, 2019 – Jun 28, 2019

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 xilinx_xiic: Fix fill tx fifo loop

Comparison should be against the actual message length, not loop index.

len is used for stopping while loop, pos is position in message. stop should be sent when entire message is sent, not when len and pos meet.

---

Changes in v2:
- Added reasoning to commit message

 drivers/i2c/xilinx_xiic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/xilinx_xiic.c +1 -1
index 83114ed510..e4ca0ab936 100644
@@ -149,7 +149,7 @@ static void xiic_fill_tx_fifo(struct xilinx_xiic_priv *priv,
 	while (len--) {
 		u16 data = msg->buf[pos++];
 
-		if (pos == len && nmsgs == 1) {
+		if ((msg->len - pos == 0) && nmsgs == 1) {
 			/* last message in transfer -> STOP */
 			data |= XIIC_TX_DYN_STOP_MASK;
 		}
Signature · 1 line
2.17.2
#1 lore raw

PATCH v2 2/2 xilinx_xiic: Fix transfer initialisation

Prior to starting a new transfer, conditionally wait for bus to not be busy.

Reinitialise controller as otherwise operation is not stable. For reference, see linux kernel commit: 9656eeebf3f1 ("i2c: Revert "i2c: xiic: Do not reset controller before every transfer"")

---
Changes in v2:
- Change variable declaration order
- Change timeout to 3ms

 drivers/i2c/xilinx_xiic.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/i2c/xilinx_xiic.c +9 -0
index e4ca0ab936..83386677d5 100644
@@ -266,8 +266,17 @@ static void xiic_reinit(struct xilinx_xiic_priv *priv)
 
 static int xilinx_xiic_xfer(struct udevice *dev, struct i2c_msg *msg, int nmsgs)
 {
+	struct xilinx_xiic_priv *priv = dev_get_priv(dev);
 	int ret = 0;
 
+	ret = wait_for_bit_8(priv->base + XIIC_SR_REG_OFFSET,
+			     XIIC_SR_BUS_BUSY_MASK, false, 3, true);
+
+	if (ret)
+		return ret;
+
+	xiic_reinit(priv);
+
 	for (; nmsgs > 0; nmsgs--, msg++) {
 		if (msg->flags & I2C_M_RD)
 			ret = xilinx_xiic_read_common(dev, msg, nmsgs);
Signature · 1 line
2.17.2
#2 lore raw

PATCH v2 2/2 xilinx_xiic: Fix transfer initialisation

Quoted 7 lines · Melin Tomas

Prior to starting a new transfer, conditionally wait for bus to not be busy.

Reinitialise controller as otherwise operation is not stable. For reference, see linux kernel commit: 9656eeebf3f1 ("i2c: Revert "i2c: xiic: Do not reset controller before every transfer"")

Quoted 5 lines

---
Changes in v2:
- Change variable declaration order
- Change timeout to 3ms

Why 3mS ?

Signature · 2 lines
Best regards,
Marek Vasut
#3 lore raw

PATCH v2 2/2 xilinx_xiic: Fix transfer initialisation

Quoted 8 lines · Marek Vasut
Quoted 7 lines · Melin Tomas

Prior to starting a new transfer, conditionally wait for bus to not be busy.

Reinitialise controller as otherwise operation is not stable. For reference, see linux kernel commit: 9656eeebf3f1 ("i2c: Revert "i2c: xiic: Do not reset controller before every transfer"")

Quoted 6 lines
Quoted 5 lines

---
Changes in v2:
- Change variable declaration order
- Change timeout to 3ms

Why 3mS ?

That is value used also in kernel driver.

thanks,

Tomas

#4 lore raw

PATCH v2 2/2 xilinx_xiic: Fix transfer initialisation

Quoted 10 lines · Melin Tomas
Quoted 8 lines · Marek Vasut
Quoted 7 lines · Melin Tomas

Prior to starting a new transfer, conditionally wait for bus to not be busy.

Reinitialise controller as otherwise operation is not stable. For reference, see linux kernel commit: 9656eeebf3f1 ("i2c: Revert "i2c: xiic: Do not reset controller before every transfer"")

Quoted 8 lines
Quoted 6 lines
Quoted 5 lines

---
Changes in v2:
- Change variable declaration order
- Change timeout to 3ms

Why 3mS ?

That is value used also in kernel driver.

But why 3mS , why not e.g. 5mS ?

Signature · 2 lines
Best regards,
Marek Vasut
#5 lore raw

PATCH v2 2/2 xilinx_xiic: Fix transfer initialisation

Quoted 11 lines · Marek Vasut
Quoted 10 lines · Melin Tomas
Quoted 8 lines · Marek Vasut
Quoted 7 lines · Melin Tomas

Prior to starting a new transfer, conditionally wait for bus to not be busy.

Reinitialise controller as otherwise operation is not stable. For reference, see linux kernel commit: 9656eeebf3f1 ("i2c: Revert "i2c: xiic: Do not reset controller before every transfer"")

Quoted 8 lines
Quoted 7 lines
Quoted 6 lines
Quoted 5 lines

---
Changes in v2:
- Change variable declaration order
- Change timeout to 3ms

Why 3mS ?

That is value used also in kernel driver.

But why 3mS , why not e.g. 5mS ?

Quoting from comment: "for instance if previous transfer was terminated due to TX error it might be that the bus is on it's way to become available give it at most 3 ms to wake"

thanks,

Tomas

#6 lore raw

PATCH v2 2/2 xilinx_xiic: Fix transfer initialisation

Quoted 18 lines · Melin Tomas
Quoted 16 lines · Marek Vasut
Quoted 15 lines · Melin Tomas
Quoted 13 lines · Marek Vasut
Quoted 12 lines · Melin Tomas

Prior to starting a new transfer, conditionally wait for bus to not be busy.

Reinitialise controller as otherwise operation is not stable. For reference, see linux kernel commit: 9656eeebf3f1 ("i2c: Revert "i2c: xiic: Do not reset controller before every transfer"")

---
Changes in v2:
- Change variable declaration order
- Change timeout to 3ms

Quoted 7 lines
Quoted 3 lines
Quoted 2 lines
Quoted 1 line

Why 3mS ?

That is value used also in kernel driver.

But why 3mS , why not e.g. 5mS ?

Quoting from comment: "for instance if previous transfer was terminated due to TX error it might be that the bus is on it's way to become available give it at most 3 ms to wake"

So where did that 3 mS figure come from ? Is it from a datasheet ? Or the HDL ? Or is that some arbitrary number ?

Signature · 2 lines
Best regards,
Marek Vasut
#7 lore raw

PATCH v2 2/2 xilinx_xiic: Fix transfer initialisation

Quoted 19 lines · Marek Vasut
Quoted 18 lines · Melin Tomas
Quoted 16 lines · Marek Vasut
Quoted 15 lines · Melin Tomas
Quoted 13 lines · Marek Vasut
Quoted 12 lines · Melin Tomas

Prior to starting a new transfer, conditionally wait for bus to not be busy.

Reinitialise controller as otherwise operation is not stable. For reference, see linux kernel commit: 9656eeebf3f1 ("i2c: Revert "i2c: xiic: Do not reset controller before every transfer"")

---
Changes in v2:
- Change variable declaration order
- Change timeout to 3ms

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
Quoted 1 line

Why 3mS ?

That is value used also in kernel driver.

But why 3mS , why not e.g. 5mS ?

Quoting from comment: "for instance if previous transfer was terminated due to TX error it might be that the bus is on it's way to become available give it at most 3 ms to wake"

So where did that 3 mS figure come from ? Is it from a datasheet ? Or the HDL ? Or is that some arbitrary number ?

This driver is based on the kernel driver, and has the same structure as that.

As such, it's probably a good idea to keep the same delay values here as in the original driver unless good reason to use something else.

As what goes for the original reasoning for 3ms, the commit history does not mention that so I cannot comment.

thanks,

Tomas

Quoted 1 line
#8 lore raw

PATCH v2 2/2 xilinx_xiic: Fix transfer initialisation

Quoted 24 lines · Melin Tomas
Quoted 22 lines · Marek Vasut
Quoted 21 lines · Melin Tomas
Quoted 19 lines · Marek Vasut
Quoted 10 lines · Melin Tomas
Quoted 8 lines · Marek Vasut
Quoted 7 lines · Melin Tomas

Prior to starting a new transfer, conditionally wait for bus to not be busy.

Reinitialise controller as otherwise operation is not stable. For reference, see linux kernel commit: 9656eeebf3f1 ("i2c: Revert "i2c: xiic: Do not reset controller before every transfer"")

Quoted 7 lines
Quoted 6 lines
Quoted 5 lines

---
Changes in v2:
- Change variable declaration order
- Change timeout to 3ms

Why 3mS ?

That is value used also in kernel driver.

But why 3mS , why not e.g. 5mS ?

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Quoting from comment: "for instance if previous transfer was terminated due to TX error it might be that the bus is on it's way to become available give it at most 3 ms to wake"

So where did that 3 mS figure come from ? Is it from a datasheet ? Or the HDL ? Or is that some arbitrary number ?

This driver is based on the kernel driver, and has the same structure as that.

So what, Linux kernel has bugs too.

Quoted 5 lines

As such, it's probably a good idea to keep the same delay values here as in the original driver unless good reason to use something else.

As what goes for the original reasoning for 3ms, the commit history does not mention that so I cannot comment.

So would you be so kind and research this ?

Signature · 2 lines
Best regards,
Marek Vasut
#9 lore raw

PATCH v2 2/2 xilinx_xiic: Fix transfer initialisation

Quoted 8 lines · Marek Vasut
Quoted 5 lines · Melin Tomas

As such, it's probably a good idea to keep the same delay values here as in the original driver unless good reason to use something else.

As what goes for the original reasoning for 3ms, the commit history does not mention that so I cannot comment.

So would you be so kind and research this ?

Based on a short study of other i2c bus drivers it seems most have bus busy timeout checks.

The timeout values seems to differ, ranging from milliseconds to seconds.

So probably it's just a number, after all it's just a check to know if we are good to go.

thanks,

Tomas

#10 lore raw

PATCH v2 2/2 xilinx_xiic: Fix transfer initialisation

Quoted 7 lines · Melin Tomas
Quoted 5 lines · Marek Vasut
Quoted 3 lines · Melin Tomas

As such, it's probably a good idea to keep the same delay values here as in the original driver unless good reason to use something else.

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

As what goes for the original reasoning for 3ms, the commit history does not mention that so I cannot comment.

So would you be so kind and research this ?

Based on a short study of other i2c bus drivers it seems most have bus busy timeout checks.

The timeout values seems to differ, ranging from milliseconds to seconds.

Yep

Quoted 2 lines

So probably it's just a number, after all it's just a check to know if we are good to go.

And is the number large enough ?

Signature · 2 lines
Best regards,
Marek Vasut
#11 lore raw

PATCH v2 2/2 xilinx_xiic: Fix transfer initialisation

Quoted 14 lines · Marek Vasut
Quoted 13 lines · Melin Tomas
Quoted 8 lines · Marek Vasut
Quoted 5 lines · Melin Tomas

As such, it's probably a good idea to keep the same delay values here as in the original driver unless good reason to use something else.

As what goes for the original reasoning for 3ms, the commit history does not mention that so I cannot comment.

So would you be so kind and research this ?

Based on a short study of other i2c bus drivers it seems most have bus busy timeout checks.

Quoted 6 lines
Quoted 1 line

The timeout values seems to differ, ranging from milliseconds to seconds.

Yep

Quoted 2 lines

So probably it's just a number, after all it's just a check to know if we are good to go.

And is the number large enough ?

As mentioned, good approach is probably using value known to work instead of

guessing a new number.

thanks,

Tomas

Quoted 1 line
#12 lore raw

PATCH v2 2/2 xilinx_xiic: Fix transfer initialisation

Quoted 19 lines · Melin Tomas
Quoted 17 lines · Marek Vasut
Quoted 7 lines · Melin Tomas
Quoted 5 lines · Marek Vasut
Quoted 3 lines · Melin Tomas

As such, it's probably a good idea to keep the same delay values here as in the original driver unless good reason to use something else.

Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

As what goes for the original reasoning for 3ms, the commit history does not mention that so I cannot comment.

So would you be so kind and research this ?

Based on a short study of other i2c bus drivers it seems most have bus busy timeout checks.

The timeout values seems to differ, ranging from milliseconds to seconds.

Yep

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

So probably it's just a number, after all it's just a check to know if we are good to go.

And is the number large enough ?

As mentioned, good approach is probably using value known to work instead of

guessing a new number.

So why did kernel pick that specific number ? Surely there was some reasoning, they didn't just pull it out of /dev/random .

Signature · 2 lines
Best regards,
Marek Vasut
#13 lore raw

PATCH v2 2/2 xilinx_xiic: Fix transfer initialisation

Quoted 21 lines · Marek Vasut
Quoted 20 lines · Melin Tomas
Quoted 19 lines · Marek Vasut
Quoted 7 lines · Melin Tomas
Quoted 5 lines · Marek Vasut
Quoted 3 lines · Melin Tomas

As such, it's probably a good idea to keep the same delay values here as in the original driver unless good reason to use something else.

Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

As what goes for the original reasoning for 3ms, the commit history does not mention that so I cannot comment.

So would you be so kind and research this ?

Based on a short study of other i2c bus drivers it seems most have bus busy timeout checks.

The timeout values seems to differ, ranging from milliseconds to seconds.

Yep

Quoted 2 lines

So probably it's just a number, after all it's just a check to know if we are good to go.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

And is the number large enough ?

As mentioned, good approach is probably using value known to work instead of

guessing a new number.

So why did kernel pick that specific number ? Surely there was some reasoning, they didn't just pull it out of /dev/random .

Yes, history does not tell.

I do see that this driver uses timeout of 1000ms for bus busy when probing, perhaps you can enlighten how that number was concluded? If that could give some clues about this.

thanks,

Tomas

Quoted 1 line
#14 lore raw

PATCH v2 2/2 xilinx_xiic: Fix transfer initialisation

Quoted 28 lines · Melin Tomas
Quoted 26 lines · Marek Vasut
Quoted 25 lines · Melin Tomas
Quoted 14 lines · Marek Vasut
Quoted 13 lines · Melin Tomas
Quoted 8 lines · Marek Vasut
Quoted 5 lines · Melin Tomas

As such, it's probably a good idea to keep the same delay values here as in the original driver unless good reason to use something else.

As what goes for the original reasoning for 3ms, the commit history does not mention that so I cannot comment.

So would you be so kind and research this ?

Based on a short study of other i2c bus drivers it seems most have bus busy timeout checks.

Quoted 6 lines
Quoted 1 line

The timeout values seems to differ, ranging from milliseconds to seconds.

Yep

Quoted 2 lines

So probably it's just a number, after all it's just a check to know if we are good to go.

And is the number large enough ?

As mentioned, good approach is probably using value known to work instead of

guessing a new number.

Quoted 8 lines
Quoted 2 lines

So why did kernel pick that specific number ? Surely there was some reasoning, they didn't just pull it out of /dev/random .

Yes, history does not tell.

I do see that this driver uses timeout of 1000ms for bus busy when probing, perhaps you can enlighten how that number was concluded? If that could give some clues about this.

I don't know.

You're the patch author, it's your responsibility to know why you're adding/changing the code you're adding/changing.

Signature · 2 lines
Best regards,
Marek Vasut
#15 lore raw

PATCH v2 2/2 xilinx_xiic: Fix transfer initialisation

Quoted 28 lines · Marek Vasut
Quoted 27 lines · Melin Tomas
Quoted 26 lines · Marek Vasut
Quoted 25 lines · Melin Tomas
Quoted 14 lines · Marek Vasut
Quoted 13 lines · Melin Tomas
Quoted 8 lines · Marek Vasut
Quoted 5 lines · Melin Tomas

As such, it's probably a good idea to keep the same delay values here as in the original driver unless good reason to use something else.

As what goes for the original reasoning for 3ms, the commit history does not mention that so I cannot comment.

So would you be so kind and research this ?

Based on a short study of other i2c bus drivers it seems most have bus busy timeout checks.

Quoted 6 lines
Quoted 1 line

The timeout values seems to differ, ranging from milliseconds to seconds.

Yep

Quoted 2 lines

So probably it's just a number, after all it's just a check to know if we are good to go.

And is the number large enough ?

As mentioned, good approach is probably using value known to work instead of

guessing a new number.

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

So why did kernel pick that specific number ? Surely there was some reasoning, they didn't just pull it out of /dev/random .

Yes, history does not tell.

I do see that this driver uses timeout of 1000ms for bus busy when probing, perhaps you can enlighten how that number was concluded? If that could give some clues about this.

I don't know.

But you are author of that line?

Quoted 2 lines

You're the patch author, it's your responsibility to know why you're adding/changing the code you're adding/changing.

yes, and the reasoning is:

* the value has been deemed good in original driver. If it would be bad, probably it would have been changed during course of time

* the value has been tested for this driver as well with success

thanks,

Tomas

#16 lore raw

PATCH v2 2/2 xilinx_xiic: Fix transfer initialisation

Quoted 32 lines · Melin Tomas
Quoted 30 lines · Marek Vasut
Quoted 29 lines · Melin Tomas
Quoted 28 lines · Marek Vasut
Quoted 18 lines · Melin Tomas
Quoted 17 lines · Marek Vasut
Quoted 7 lines · Melin Tomas
Quoted 5 lines · Marek Vasut
Quoted 3 lines · Melin Tomas

As such, it's probably a good idea to keep the same delay values here as in the original driver unless good reason to use something else.

Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

As what goes for the original reasoning for 3ms, the commit history does not mention that so I cannot comment.

So would you be so kind and research this ?

Based on a short study of other i2c bus drivers it seems most have bus busy timeout checks.

The timeout values seems to differ, ranging from milliseconds to seconds.

Yep

Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

So probably it's just a number, after all it's just a check to know if we are good to go.

And is the number large enough ?

As mentioned, good approach is probably using value known to work instead of

guessing a new number.

So why did kernel pick that specific number ? Surely there was some reasoning, they didn't just pull it out of /dev/random .

Quoted 8 lines
Quoted 6 lines
Quoted 5 lines

Yes, history does not tell.

I do see that this driver uses timeout of 1000ms for bus busy when probing, perhaps you can enlighten how that number was concluded? If that could give some clues about this.

I don't know.

But you are author of that line?

+ ret = wait_for_bit_8(priv->base + XIIC_SR_REG_OFFSET,
+ XIIC_SR_BUS_BUSY_MASK, false, 3, true);
+

comes from 2/2 ?

Quoted 9 lines
Quoted 2 lines

You're the patch author, it's your responsibility to know why you're adding/changing the code you're adding/changing.

yes, and the reasoning is:

* the value has been deemed good in original driver. If it would be bad, probably it would have been changed during course of time

* the value has been tested for this driver as well with success

So shouldn't there be some upper bound on the bus busy time , demanded either by the i2c bus spec or the xiic core spec ?

Signature · 2 lines
Best regards,
Marek Vasut
#17 lore raw

PATCH v2 2/2 xilinx_xiic: Fix transfer initialisation

Quoted 43 lines · Marek Vasut
Quoted 38 lines · Melin Tomas
Quoted 28 lines · Marek Vasut
Quoted 27 lines · Melin Tomas
Quoted 26 lines · Marek Vasut
Quoted 25 lines · Melin Tomas
Quoted 14 lines · Marek Vasut
Quoted 13 lines · Melin Tomas
Quoted 8 lines · Marek Vasut
Quoted 5 lines · Melin Tomas

As such, it's probably a good idea to keep the same delay values here as in the original driver unless good reason to use something else.

As what goes for the original reasoning for 3ms, the commit history does not mention that so I cannot comment.

So would you be so kind and research this ?

Based on a short study of other i2c bus drivers it seems most have bus busy timeout checks.

Quoted 6 lines
Quoted 1 line

The timeout values seems to differ, ranging from milliseconds to seconds.

Yep

Quoted 2 lines

So probably it's just a number, after all it's just a check to know if we are good to go.

And is the number large enough ?

As mentioned, good approach is probably using value known to work instead of

guessing a new number.

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

So why did kernel pick that specific number ? Surely there was some reasoning, they didn't just pull it out of /dev/random .

Yes, history does not tell.

I do see that this driver uses timeout of 1000ms for bus busy when probing, perhaps you can enlighten how that number was concluded? If that could give some clues about this.

I don't know.

But you are author of that line?

(quoted diff) +3 -0
+	ret = wait_for_bit_8(priv->base + XIIC_SR_REG_OFFSET,
+			     XIIC_SR_BUS_BUSY_MASK, false, 3, true);
+
Quoted 1 line

comes from 2/2 ?

No, I was referring to the already existing wait_for_bit_8 of bus busy

https://gitlab.denx.de/u-boot/u-boot/blob/master/drivers/i2c/xilinx_xiic.c#L294

Quoted 10 lines
Quoted 8 lines
Quoted 2 lines

You're the patch author, it's your responsibility to know why you're adding/changing the code you're adding/changing.

yes, and the reasoning is:

* the value has been deemed good in original driver. If it would be bad, probably it would have been changed during course of time

* the value has been tested for this driver as well with success

So shouldn't there be some upper bound on the bus busy time , demanded either by the i2c bus spec or the xiic core spec ?

In case some of the devices on the bus misbehaves, bus could potentially stay

busy until device reset or power-cycle.

thanks,

Tomas

#18 lore raw

PATCH v2 2/2 xilinx_xiic: Fix transfer initialisation

Quoted 45 lines · Melin Tomas
Quoted 43 lines · Marek Vasut
Quoted 38 lines · Melin Tomas
Quoted 28 lines · Marek Vasut
Quoted 27 lines · Melin Tomas
Quoted 26 lines · Marek Vasut
Quoted 25 lines · Melin Tomas
Quoted 14 lines · Marek Vasut
Quoted 13 lines · Melin Tomas
Quoted 8 lines · Marek Vasut
Quoted 5 lines · Melin Tomas

As such, it's probably a good idea to keep the same delay values here as in the original driver unless good reason to use something else.

As what goes for the original reasoning for 3ms, the commit history does not mention that so I cannot comment.

So would you be so kind and research this ?

Based on a short study of other i2c bus drivers it seems most have bus busy timeout checks.

Quoted 6 lines
Quoted 1 line

The timeout values seems to differ, ranging from milliseconds to seconds.

Yep

Quoted 2 lines

So probably it's just a number, after all it's just a check to know if we are good to go.

And is the number large enough ?

As mentioned, good approach is probably using value known to work instead of

guessing a new number.

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

So why did kernel pick that specific number ? Surely there was some reasoning, they didn't just pull it out of /dev/random .

Yes, history does not tell.

I do see that this driver uses timeout of 1000ms for bus busy when probing, perhaps you can enlighten how that number was concluded? If that could give some clues about this.

I don't know.

But you are author of that line?

(quoted diff) +3 -0
+	ret = wait_for_bit_8(priv->base + XIIC_SR_REG_OFFSET,
+			     XIIC_SR_BUS_BUSY_MASK, false, 3, true);
+
Quoted 5 lines
Quoted 1 line

comes from 2/2 ?

No, I was referring to the already existing wait_for_bit_8 of bus busy

https://gitlab.denx.de/u-boot/u-boot/blob/master/drivers/i2c/xilinx_xiic.c#L294

Oh, this. When probing, you need to pick some arbitrary amount of time after which you give up and conclude there isn't any device at that address. 1 second should give enough time to even slow devices on slow busses. If some device is too slow or doesn't respond, too bad. That's also why i2c is NOT a bus which could be probed, there are simple devices which do not respond to addressing in any way.

So this probably didn't help you determine why you should wait some time for bus busy when sending messages, since this is unrelated timeout.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

You're the patch author, it's your responsibility to know why you're adding/changing the code you're adding/changing.

yes, and the reasoning is:

* the value has been deemed good in original driver. If it would be bad, probably it would have been changed during course of time

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

* the value has been tested for this driver as well with success

So shouldn't there be some upper bound on the bus busy time , demanded either by the i2c bus spec or the xiic core spec ?

In case some of the devices on the bus misbehaves, bus could potentially stay

busy until device reset or power-cycle.

My concern here would be e.g. EEPROM programming, which is slow, so I wonder whether this timeout is enough. But maybe the xiic datasheet says something about maximum delay , or somehow tells you how to derive the delay from bus clock speed ...

Signature · 2 lines
Best regards,
Marek Vasut
#19 lore raw

PATCH v2 2/2 xilinx_xiic: Fix transfer initialisation

Quoted 69 lines · Marek Vasut
Quoted 40 lines · Melin Tomas
Quoted 39 lines · Marek Vasut
Quoted 38 lines · Melin Tomas
Quoted 28 lines · Marek Vasut
Quoted 27 lines · Melin Tomas
Quoted 26 lines · Marek Vasut
Quoted 25 lines · Melin Tomas
Quoted 14 lines · Marek Vasut
Quoted 13 lines · Melin Tomas
Quoted 8 lines · Marek Vasut
Quoted 5 lines · Melin Tomas

As such, it's probably a good idea to keep the same delay values here as in the original driver unless good reason to use something else.

As what goes for the original reasoning for 3ms, the commit history does not mention that so I cannot comment.

So would you be so kind and research this ?

Based on a short study of other i2c bus drivers it seems most have bus busy timeout checks.

Quoted 6 lines
Quoted 1 line

The timeout values seems to differ, ranging from milliseconds to seconds.

Yep

Quoted 2 lines

So probably it's just a number, after all it's just a check to know if we are good to go.

And is the number large enough ?

As mentioned, good approach is probably using value known to work instead of

guessing a new number.

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

So why did kernel pick that specific number ? Surely there was some reasoning, they didn't just pull it out of /dev/random .

Yes, history does not tell.

I do see that this driver uses timeout of 1000ms for bus busy when probing, perhaps you can enlighten how that number was concluded? If that could give some clues about this.

I don't know.

But you are author of that line?

Quoted 8 lines
Quoted 5 lines
(quoted diff) +3 -0
+	ret = wait_for_bit_8(priv->base + XIIC_SR_REG_OFFSET,
+			     XIIC_SR_BUS_BUSY_MASK, false, 3, true);
+

comes from 2/2 ?

No, I was referring to the already existing wait_for_bit_8 of bus busy

https://gitlab.denx.de/u-boot/u-boot/blob/master/drivers/i2c/xilinx_xiic.c#L294

Oh, this. When probing, you need to pick some arbitrary amount of time after which you give up and conclude there isn't any device at that address. 1 second should give enough time to even slow devices on slow busses. If some device is too slow or doesn't respond, too bad. That's also why i2c is NOT a bus which could be probed, there are simple devices which do not respond to addressing in any way.

So this probably didn't help you determine why you should wait some time for bus busy when sending messages, since this is unrelated timeout.

Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
Quoted 2 lines

You're the patch author, it's your responsibility to know why you're adding/changing the code you're adding/changing.

yes, and the reasoning is:

* the value has been deemed good in original driver. If it would be bad, probably it would have been changed during course of time

* the value has been tested for this driver as well with success

So shouldn't there be some upper bound on the bus busy time , demanded either by the i2c bus spec or the xiic core spec ?

Quoted 8 lines
Quoted 4 lines

In case some of the devices on the bus misbehaves, bus could potentially stay

busy until device reset or power-cycle.

My concern here would be e.g. EEPROM programming, which is slow, so I wonder whether this timeout is enough. But maybe the xiic datasheet says something about maximum delay , or somehow tells you how to derive the delay from bus clock speed ...

Specification only mentions to check bus busy status prior to starting,

no mention about delays AFAIS.

Even with standard low speed 100kHz, 3ms would equal 300 clock

cycles waiting.

Unless you have other suggestion, I suggest proceeding with this delay value,

as explained why in previous messages.

thanks,

Tomas

#20 lore raw

PATCH v2 2/2 xilinx_xiic: Fix transfer initialisation

Quoted 84 lines · Melin Tomas
Quoted 69 lines · Marek Vasut
Quoted 40 lines · Melin Tomas
Quoted 39 lines · Marek Vasut
Quoted 38 lines · Melin Tomas
Quoted 28 lines · Marek Vasut
Quoted 27 lines · Melin Tomas
Quoted 26 lines · Marek Vasut
Quoted 25 lines · Melin Tomas
Quoted 14 lines · Marek Vasut
Quoted 13 lines · Melin Tomas
Quoted 8 lines · Marek Vasut
Quoted 5 lines · Melin Tomas

As such, it's probably a good idea to keep the same delay values here as
in the original driver unless good reason to use something else.

As what goes for the original reasoning for 3ms, the commit history does
not mention that so I cannot comment.

So would you be so kind and research this ?

Based on a short study of other i2c bus drivers it seems most have bus busy timeout checks.

Quoted 6 lines
Quoted 1 line

The timeout values seems to differ, ranging from milliseconds to seconds.

Yep

Quoted 2 lines

So probably it's just a number, after all it's just a check to know if we are good to go.

And is the number large enough ?

As mentioned, good approach is probably using value known to work instead of

guessing a new number.

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

So why did kernel pick that specific number ? Surely there was some reasoning, they didn't just pull it out of /dev/random .

Yes, history does not tell.

I do see that this driver uses timeout of 1000ms for bus busy when probing, perhaps you can enlighten how that number was concluded? If that could give some clues about this.

I don't know.

But you are author of that line?

Quoted 8 lines
Quoted 5 lines
(quoted diff) +3 -0
+	ret = wait_for_bit_8(priv->base + XIIC_SR_REG_OFFSET,
+			     XIIC_SR_BUS_BUSY_MASK, false, 3, true);
+

comes from 2/2 ?

No, I was referring to the already existing wait_for_bit_8 of bus busy

https://gitlab.denx.de/u-boot/u-boot/blob/master/drivers/i2c/xilinx_xiic.c#L294

Oh, this. When probing, you need to pick some arbitrary amount of time after which you give up and conclude there isn't any device at that address. 1 second should give enough time to even slow devices on slow busses. If some device is too slow or doesn't respond, too bad. That's also why i2c is NOT a bus which could be probed, there are simple devices which do not respond to addressing in any way.

So this probably didn't help you determine why you should wait some time for bus busy when sending messages, since this is unrelated timeout.

Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
Quoted 2 lines

You're the patch author, it's your responsibility to know why you're adding/changing the code you're adding/changing.

yes, and the reasoning is:

* the value has been deemed good in original driver. If it would be bad, probably it would have been changed during course of time

* the value has been tested for this driver as well with success

So shouldn't there be some upper bound on the bus busy time , demanded either by the i2c bus spec or the xiic core spec ?

Quoted 8 lines
Quoted 4 lines

In case some of the devices on the bus misbehaves, bus could potentially stay

busy until device reset or power-cycle.

My concern here would be e.g. EEPROM programming, which is slow, so I wonder whether this timeout is enough. But maybe the xiic datasheet says something about maximum delay , or somehow tells you how to derive the delay from bus clock speed ...

Specification only mentions to check bus busy status prior to starting,

no mention about delays AFAIS.

Quoted 8 lines

Even with standard low speed 100kHz, 3ms would equal 300 clock

cycles waiting.

Unless you have other suggestion, I suggest proceeding with this delay value,

as explained why in previous messages.

There was no explanation besides "Linux does it this way, so it must be right", and I don't really like that. But ultimately, this is up to Heiko now.

Signature · 2 lines
Best regards,
Marek Vasut
#21 lore raw

PATCH v2 2/2 xilinx_xiic: Fix transfer initialisation

Hi Marek, Tomas,

Am 27.06.2019 um 13:32 schrieb Marek Vasut:

Quoted 89 lines · Melin Tomas
Quoted 88 lines · Marek Vasut
Quoted 69 lines · Melin Tomas
Quoted 40 lines · Marek Vasut
Quoted 39 lines · Melin Tomas
Quoted 38 lines · Marek Vasut
Quoted 28 lines · Melin Tomas
Quoted 27 lines · Marek Vasut
Quoted 26 lines · Melin Tomas
Quoted 25 lines · Marek Vasut
Quoted 14 lines · Melin Tomas
Quoted 13 lines · Marek Vasut
Quoted 9 lines · Melin Tomas

As such, it's probably a good idea to keep the same delay values here as
in the original driver unless good reason to use something else.

As what goes for the original reasoning for 3ms, the commit history does
not mention that so I cannot comment.
So would you be so kind and research this ?

Based on a short study of other i2c bus drivers it seems most have bus busy timeout checks.

Quoted 6 lines
Quoted 1 line

The timeout values seems to differ, ranging from milliseconds to seconds.

Yep

Quoted 2 lines

So probably it's just a number, after all it's just a check to know if we are good to go.

And is the number large enough ?

As mentioned, good approach is probably using value known to work instead of

guessing a new number.

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

So why did kernel pick that specific number ? Surely there was some reasoning, they didn't just pull it out of /dev/random .

Yes, history does not tell.

I do see that this driver uses timeout of 1000ms for bus busy when probing, perhaps you can enlighten how that number was concluded? If that could give some clues about this.

I don't know.

But you are author of that line?

Quoted 8 lines
Quoted 5 lines
(quoted diff) +3 -0
+	ret = wait_for_bit_8(priv->base + XIIC_SR_REG_OFFSET,
+			     XIIC_SR_BUS_BUSY_MASK, false, 3, true);
+

comes from 2/2 ?

No, I was referring to the already existing wait_for_bit_8 of bus busy

https://gitlab.denx.de/u-boot/u-boot/blob/master/drivers/i2c/xilinx_xiic.c#L294

Oh, this. When probing, you need to pick some arbitrary amount of time after which you give up and conclude there isn't any device at that address. 1 second should give enough time to even slow devices on slow busses. If some device is too slow or doesn't respond, too bad. That's also why i2c is NOT a bus which could be probed, there are simple devices which do not respond to addressing in any way.

So this probably didn't help you determine why you should wait some time for bus busy when sending messages, since this is unrelated timeout.

Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
Quoted 2 lines

You're the patch author, it's your responsibility to know why you're adding/changing the code you're adding/changing.

yes, and the reasoning is:

* the value has been deemed good in original driver. If it would be bad, probably it would have been changed during course of time

* the value has been tested for this driver as well with success

So shouldn't there be some upper bound on the bus busy time , demanded either by the i2c bus spec or the xiic core spec ?

Quoted 8 lines
Quoted 4 lines

In case some of the devices on the bus misbehaves, bus could potentially stay

busy until device reset or power-cycle.

My concern here would be e.g. EEPROM programming, which is slow, so I wonder whether this timeout is enough. But maybe the xiic datasheet says something about maximum delay , or somehow tells you how to derive the delay from bus clock speed ...

Specification only mentions to check bus busy status prior to starting,

no mention about delays AFAIS.

Even with standard low speed 100kHz, 3ms would equal 300 clock

cycles waiting.

Quoted 8 lines
Quoted 4 lines

Unless you have other suggestion, I suggest proceeding with this delay value,

as explained why in previous messages.

There was no explanation besides "Linux does it this way, so it must be right", and I don't really like that. But ultimately, this is up to Heiko now.

May it makes sense to ask Richard or Ben which have the driver and the comment with "3 mS" introduced in linux?

See linux commit:
commit e1d5b6598cdc33257fe68302ae9db81d2f7bb883

Author: Richard Röjfors <[email protected]>
Date:   Thu Feb 11 10:42:00 2010 +0100

i2c: Add support for Xilinx XPS IIC Bus Interface

This patch adds support for the Xilinx XPS IIC Bus Interface.

The driver uses the dynamic mode, supporting to put several I2C messages in the FIFO to reduce the number of interrupts.

It has the same feature as ocores, it can be passed a list of devices that will be added when the bus is probed.

Beside of that, wait_for_bit_8() drops a debug message, if timeout, so that is good ...

Remains the question, what is a good timeout value ?

I tend to say, we could set the timeout higher, as the SR register is polled all millisecond, and if bus is not busy we loose no time.

But the problem remains, what a good timeout is here ...

So may we should add here a printf, if wait_for_bit_8 returns with -ETIMEDOUT, so users may get in panic and report, and we can find a better timeout?

bye,
Heiko

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de
#22 lore raw

PATCH v2 2/2 xilinx_xiic: Fix transfer initialisation

Hi,

+ Richard, Ben

Quoted 141 lines · Heiko Schocher

Hi Marek, Tomas,

Am 27.06.2019 um 13:32 schrieb Marek Vasut:

Quoted 107 lines · Melin Tomas
Quoted 106 lines · Marek Vasut
Quoted 89 lines · Melin Tomas
Quoted 54 lines · Marek Vasut
Quoted 53 lines · Melin Tomas
Quoted 41 lines · Marek Vasut
Quoted 40 lines · Melin Tomas
Quoted 39 lines · Marek Vasut
Quoted 28 lines · Melin Tomas
Quoted 27 lines · Marek Vasut
Quoted 26 lines · Melin Tomas
Quoted 19 lines · Marek Vasut

On 6/26/19 12:39 PM, Melin Tomas wrote:

As such, it's probably a good idea to keep the same
delay values here as
in the original driver unless good reason to use
something else.

As what goes for the original reasoning for 3ms, the
commit history does
not mention that so I cannot comment.
So would you be so kind and research this ?
Based on a short study of other i2c bus drivers it seems
most have bus
busy timeout checks.

The timeout values seems to differ, ranging from
milliseconds to seconds.

Yep

Quoted 3 lines

So probably it's just a number, after all it's just a
check to know if
we are good to go.

And is the number large enough ?

Quoted 8 lines
Quoted 5 lines

As mentioned, good approach is probably using value known to work
instead of

guessing a new number.

So why did kernel pick that specific number ? Surely there was some
reasoning, they didn't just pull it out of /dev/random .

Yes, history does not tell.

Quoted 7 lines
Quoted 6 lines
Quoted 5 lines

I do see that this driver uses timeout of 1000ms for bus busy when
probing, perhaps you can enlighten how that number was concluded? If
that could give some clues about this.

I don't know.

But you are author of that line?

+    ret = wait_for_bit_8(priv->base + XIIC_SR_REG_OFFSET, +                 XIIC_SR_BUS_BUSY_MASK, false, 3, true); +

Quoted 6 lines
Quoted 1 line

comes from 2/2 ?

No, I was referring to the already existing wait_for_bit_8 of bus busy

https://gitlab.denx.de/u-boot/u-boot/blob/master/drivers/i2c/xilinx_xiic.c#L294

Oh, this. When probing, you need to pick some arbitrary amount of time after which you give up and conclude there isn't any device at that address. 1 second should give enough time to even slow devices on slow busses. If some device is too slow or doesn't respond, too bad. That's also why i2c is NOT a bus which could be probed, there are simple devices which do not respond to addressing in any way.

So this probably didn't help you determine why you should wait some time
for bus busy when sending messages, since this is unrelated timeout.

Quoted 17 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

You're the patch author, it's your responsibility to know why you're
adding/changing the code you're adding/changing.

yes, and the reasoning is:

Quoted 8 lines
Quoted 5 lines

* the value has been deemed good in original driver. If it would be bad,
probably it would have been changed during course of time

* the value has been tested for this driver as well with success

So shouldn't there be some upper bound on the bus busy time , demanded
either by the i2c bus spec or the xiic core spec ?

In case some of the devices on the bus misbehaves, bus could potentially
stay

Quoted 6 lines
Quoted 1 line

busy until device reset or power-cycle.

My concern here would be e.g. EEPROM programming, which is slow, so I wonder whether this timeout is enough. But maybe the xiic datasheet says
something about maximum delay , or somehow tells you how to derive the delay from bus clock speed ...

Specification only mentions to check bus busy status prior to starting,

no mention about delays AFAIS.

Even with standard low speed 100kHz, 3ms would equal 300 clock

cycles waiting.

Quoted 8 lines
Quoted 4 lines

Unless you have other suggestion, I suggest proceeding with this delay value,

as explained why in previous messages.

There was no explanation besides "Linux does it this way, so it must be right", and I don't really like that. But ultimately, this is up to Heiko now.

May it makes sense to ask Richard or Ben which have the driver and the comment with "3 mS" introduced in linux?

See linux commit:
commit e1d5b6598cdc33257fe68302ae9db81d2f7bb883
Author: Richard Röjfors <[email protected]> Date:   Thu Feb 11 10:42:00 2010 +0100

    i2c: Add support for Xilinx XPS IIC Bus Interface

    This patch adds support for the Xilinx XPS IIC Bus Interface.

    The driver uses the dynamic mode, supporting to put several I2C messages in the FIFO to reduce the number of interrupts.

    It has the same feature as ocores, it can be passed a list of devices that will be added when the bus is probed.

Quoted 8 lines

Beside of that, wait_for_bit_8() drops a debug message, if timeout, so that is good ...

Remains the question, what is a good timeout value ?

I tend to say, we could set the timeout higher, as the SR register is polled all millisecond, and if bus is not busy we loose no time.

ok, so increase timeout to 1000ms or so?

Quoted 6 lines

But the problem remains, what a good timeout is here ...

So may we should add here a printf, if wait_for_bit_8 returns with -ETIMEDOUT, so users may get in panic and report, and we can find a better timeout?

Sounds ok to me.

So I'll update the patch to

* have longer 1000ms timeout

* print message in case of timeout from bus busy to catch possibly incorrect timeout estimate

Please let me know if this approach does not sound good to any of you.

thanks,

Tomas

#23 lore raw

PATCH v2 2/2 xilinx_xiic: Fix transfer initialisation

Hello Tomas,

Am 28.06.2019 um 10:58 schrieb Melin Tomas:

Quoted 165 lines

Hi,

+ Richard, Ben

Quoted 141 lines · Heiko Schocher

Hi Marek, Tomas,

Am 27.06.2019 um 13:32 schrieb Marek Vasut:

Quoted 107 lines · Melin Tomas
Quoted 106 lines · Marek Vasut
Quoted 89 lines · Melin Tomas
Quoted 54 lines · Marek Vasut
Quoted 53 lines · Melin Tomas
Quoted 41 lines · Marek Vasut
Quoted 40 lines · Melin Tomas
Quoted 39 lines · Marek Vasut
Quoted 28 lines · Melin Tomas
Quoted 27 lines · Marek Vasut
Quoted 26 lines · Melin Tomas

On 6/26/19 1:47 PM, Marek Vasut wrote:

On 6/26/19 12:39 PM, Melin Tomas wrote:

As such, it's probably a good idea to keep the same
delay values here as
in the original driver unless good reason to use
something else.

As what goes for the original reasoning for 3ms, the
commit history does
not mention that so I cannot comment.
So would you be so kind and research this ?
Based on a short study of other i2c bus drivers it seems
most have bus
busy timeout checks.

The timeout values seems to differ, ranging from
milliseconds to seconds.
Yep

So probably it's just a number, after all it's just a
check to know if
we are good to go.
And is the number large enough ?

Quoted 8 lines
Quoted 5 lines

As mentioned, good approach is probably using value known to work
instead of

guessing a new number.

So why did kernel pick that specific number ? Surely there was some
reasoning, they didn't just pull it out of /dev/random .

Yes, history does not tell.

Quoted 7 lines
Quoted 6 lines
Quoted 5 lines

I do see that this driver uses timeout of 1000ms for bus busy when
probing, perhaps you can enlighten how that number was concluded? If
that could give some clues about this.

I don't know.

But you are author of that line?

+    ret = wait_for_bit_8(priv->base + XIIC_SR_REG_OFFSET, +                 XIIC_SR_BUS_BUSY_MASK, false, 3, true); +

Quoted 6 lines
Quoted 1 line

comes from 2/2 ?

No, I was referring to the already existing wait_for_bit_8 of bus busy

https://gitlab.denx.de/u-boot/u-boot/blob/master/drivers/i2c/xilinx_xiic.c#L294

Oh, this. When probing, you need to pick some arbitrary amount of time after which you give up and conclude there isn't any device at that address. 1 second should give enough time to even slow devices on slow busses. If some device is too slow or doesn't respond, too bad. That's also why i2c is NOT a bus which could be probed, there are simple devices which do not respond to addressing in any way.

So this probably didn't help you determine why you should wait some time
for bus busy when sending messages, since this is unrelated timeout.

Quoted 17 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

You're the patch author, it's your responsibility to know why you're
adding/changing the code you're adding/changing.

yes, and the reasoning is:

Quoted 8 lines
Quoted 5 lines

* the value has been deemed good in original driver. If it would be bad,
probably it would have been changed during course of time

* the value has been tested for this driver as well with success

So shouldn't there be some upper bound on the bus busy time , demanded
either by the i2c bus spec or the xiic core spec ?

In case some of the devices on the bus misbehaves, bus could potentially
stay

Quoted 6 lines
Quoted 1 line

busy until device reset or power-cycle.

My concern here would be e.g. EEPROM programming, which is slow, so I wonder whether this timeout is enough. But maybe the xiic datasheet says
something about maximum delay , or somehow tells you how to derive the delay from bus clock speed ...

Specification only mentions to check bus busy status prior to starting,

no mention about delays AFAIS.

Even with standard low speed 100kHz, 3ms would equal 300 clock

cycles waiting.

Quoted 8 lines
Quoted 4 lines

Unless you have other suggestion, I suggest proceeding with this delay value,

as explained why in previous messages.

There was no explanation besides "Linux does it this way, so it must be right", and I don't really like that. But ultimately, this is up to Heiko now.

May it makes sense to ask Richard or Ben which have the driver and the comment with "3 mS" introduced in linux?

See linux commit:
commit e1d5b6598cdc33257fe68302ae9db81d2f7bb883
Author: Richard Röjfors <[email protected]> Date:   Thu Feb 11 10:42:00 2010 +0100

    i2c: Add support for Xilinx XPS IIC Bus Interface

    This patch adds support for the Xilinx XPS IIC Bus Interface.

    The driver uses the dynamic mode, supporting to put several I2C messages in the FIFO to reduce the number of interrupts.

    It has the same feature as ocores, it can be passed a list of devices that will be added when the bus is probed.

Quoted 8 lines

Beside of that, wait_for_bit_8() drops a debug message, if timeout, so that is good ...

Remains the question, what is a good timeout value ?

I tend to say, we could set the timeout higher, as the SR register is polled all millisecond, and if bus is not busy we loose no time.

ok, so increase timeout to 1000ms or so?

Quoted 6 lines

But the problem remains, what a good timeout is here ...

So may we should add here a printf, if wait_for_bit_8 returns with -ETIMEDOUT, so users may get in panic and report, and we can find a better timeout?

Sounds ok to me.

Quoted 8 lines

So I'll update the patch to

* have longer 1000ms timeout

* print message in case of timeout from bus busy to catch possibly incorrect timeout estimate

Please let me know if this approach does not sound good to any of you.

For me it sounds good, many thanks!

bye,
Heiko

Signature · 4 lines
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de
#24 lore raw

PATCH v2 1/2 xilinx_xiic: Fix fill tx fifo loop

In reply to Melin Tomas
Quoted 5 lines · Melin Tomas

Comparison should be against the actual message length, not loop index.

len is used for stopping while loop, pos is position in message. stop should be sent when entire message is sent, not when len and pos meet.

Thanks. Just be careful to clamp the transfer length to 65535 bytes, otherwise you'll hit another overflow.

Quoted 23 lines

---

Changes in v2:
- Added reasoning to commit message

 drivers/i2c/xilinx_xiic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/xilinx_xiic.c +1 -1
index 83114ed510..e4ca0ab936 100644
@@ -149,7 +149,7 @@ static void xiic_fill_tx_fifo(struct xilinx_xiic_priv *priv,
 	while (len--) {
 		u16 data = msg->buf[pos++];
 
-		if (pos == len && nmsgs == 1) {
+		if ((msg->len - pos == 0) && nmsgs == 1) {
 			/* last message in transfer -> STOP */
 			data |= XIIC_TX_DYN_STOP_MASK;
 		}
Signature · 2 lines
Best regards,
Marek Vasut