Skip to contentSkip to conversation

Regression in next with spi return from transfer_one()

DISCUSSION Tony Lindgren 3 participants 6 messages Nov 15, 2018 – Nov 16, 2018 SPI

lore
Share & tools
lore
#0 lore raw

Hi,

Commit 810923f3bf06 ("spi: Deal with slaves that return from transfer_one() unfinished") causes a regression at least on droid 4 with SPI PMIC and regulators on the PMIC. During boot the device just hangs there waiting for rootfs to appear on MMC. Reverting 810923f3bf06 makes things work again.

Any ideas why this might be?

Regards,

Tony

maintainer
#1 lore raw
Quoted 7 lines · Tony Lindgren

Commit 810923f3bf06 ("spi: Deal with slaves that return from transfer_one() unfinished") causes a regression at least on droid 4 with SPI PMIC and regulators on the PMIC. During boot the device just hangs there waiting for rootfs to appear on MMC. Reverting 810923f3bf06 makes things work again.

Any ideas why this might be?

Wow, that's not obvious... as far as I can tell the code in the !slave
case is identical so unless the controller is somehow getting mistakenly
flagged as a slave it looks like it should be something to do with it
being pushed into a function. Could you try logging what the timeout
ends up getting set to?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20181115/dbd71646/attachment.sig>

#2 lore raw
Quoted 8 lines · Mark Brown
Quoted 5 lines · Tony Lindgren

Commit 810923f3bf06 ("spi: Deal with slaves that return from transfer_one() unfinished") causes a regression at least on droid 4 with SPI PMIC and regulators on the PMIC. During boot the device just hangs there waiting for rootfs to appear on MMC. Reverting 810923f3bf06 makes things work again.

Quoted 7 lines
Quoted 1 line

Any ideas why this might be?

Wow, that's not obvious... as far as I can tell the code in the !slave case is identical so unless the controller is somehow getting mistakenly flagged as a slave it looks like it should be something to do with it being pushed into a function. Could you try logging what the timeout ends up getting set to?

It seems to be caused because of the now missing "if (ret > 0) {" line somehow that was there earlier. New code sets ms to 200 it seems, then dmesg shows:

SPI transfer timed out

The old code is not updating ms and it's set to 1.

Regards,

Tony

maintainer
#3 lore raw
Quoted 3 lines · Tony Lindgren

It seems to be caused because of the now missing "if (ret > 0) {" line somehow that was there earlier. New code sets ms to 200 it seems, then dmesg shows:

Doh, of course :( Sorry I missed that.

Quoted 1 line

The old code is not updating ms and it's set to 1.

Right, and not waiting either which should be the issue. Does the following work:

drivers/spi/spi.c +5 -3
index 498d3b9bf3ae..430ad637c643 100644
@@ -1114,9 +1114,11 @@ static int spi_transfer_one_message(struct spi_controller *ctlr,
 				goto out;
 			}
 
-			ret = spi_transfer_wait(ctlr, msg, xfer);
-			if (ret < 0)
-				msg->status = ret;
+			if (ret > 0) {
+				ret = spi_transfer_wait(ctlr, msg, xfer);
+				if (ret < 0)
+					msg->status = ret;
+			}
 		} else {
 			if (xfer->len)
 				dev_err(&msg->spi->dev,

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20181115/213c9a1f/attachment.sig>

author Tested-by
#4 lore raw
Quoted 6 lines · Mark Brown
Quoted 3 lines · Tony Lindgren

It seems to be caused because of the now missing "if (ret > 0) {" line somehow that was there earlier. New code sets ms to 200 it seems, then dmesg shows:

Quoted 6 lines

Doh, of course :( Sorry I missed that.

Quoted 1 line

The old code is not updating ms and it's set to 1.

Right, and not waiting either which should be the issue. Does the following work:

And it's recalculating the timeout every time now too :) Yup that fix works and the problem makes sense now:

Quoted 19 lines
drivers/spi/spi.c +5 -3
index 498d3b9bf3ae..430ad637c643 100644
@@ -1114,9 +1114,11 @@ static int spi_transfer_one_message(struct spi_controller *ctlr,
 				goto out;
 			}
 
-			ret = spi_transfer_wait(ctlr, msg, xfer);
-			if (ret < 0)
-				msg->status = ret;
+			if (ret > 0) {
+				ret = spi_transfer_wait(ctlr, msg, xfer);
+				if (ret < 0)
+					msg->status = ret;
+			}
 		} else {
 			if (xfer->len)
 				dev_err(&msg->spi->dev,
#5 lore raw
Quoted 11 lines · Tony Lindgren
Quoted 10 lines · Mark Brown
Quoted 3 lines · Tony Lindgren

It seems to be caused because of the now missing "if (ret > 0) {" line somehow that was there earlier. New code sets ms to 200 it seems, then dmesg shows:

Doh, of course :( Sorry I missed that.

Quoted 1 line

The old code is not updating ms and it's set to 1.

Quoted 7 lines
Quoted 2 lines

Right, and not waiting either which should be the issue. Does the following work:

And it's recalculating the timeout every time now too :) Yup that fix works and the problem makes sense now:

My bad obviously. Sorry.

I'm grateful that you identified and fixed the problem so quickly.

Thanks,
Lubo

Quoted 24 lines
Quoted 22 lines
drivers/spi/spi.c +5 -3
index 498d3b9bf3ae..430ad637c643 100644
@@ -1114,9 +1114,11 @@ static int spi_transfer_one_message(struct
 spi_controller *ctlr,
 				goto out;
 			}
 
-			ret = spi_transfer_wait(ctlr, msg, xfer);
-			if (ret < 0)
-				msg->status = ret;
+			if (ret > 0) {
+				ret = spi_transfer_wait(ctlr, msg,
 xfer);
+				if (ret < 0)
+					msg->status = ret;
+			}
 		} else {
drivers/spi/spi.c +0 -0
 			if (xfer->len)
 				dev_err(&msg->spi->dev,