mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Robert Karszniewicz <r.karszniewicz@phytec.de>
To: barebox@lists.infradead.org
Subject: [PATCH v2] usb: storage: Increase retries for usb_stor_transport()
Date: Mon, 4 Nov 2019 16:04:18 +0100	[thread overview]
Message-ID: <1572879858-77435-1-git-send-email-r.karszniewicz@phytec.de> (raw)
In-Reply-To: <20191104145448.7b4g4qmadpyxaygj@pengutronix.de>

This should make writing and reading more reliable.

Also:
- change loop condition to make "retries" semantically correct
- add a debug message in case of fatal failure

Signed-off-by: Robert Karszniewicz <r.karszniewicz@phytec.de>
---
 drivers/usb/storage/usb.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 63d624e..e0ef4f5 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -87,8 +87,7 @@ static int usb_stor_transport(struct us_blk_dev *usb_blkdev,
 	struct device_d *dev = &us->pusb_dev->dev;
 	int i, ret;
 
-
-	for (i = 0; i < retries; i++) {
+	for (i = 0; i <= retries; i++) {
 		dev_dbg(dev, "%s\n", usb_stor_opcode_name(cmd[0]));
 		ret = us->transport(usb_blkdev, cmd, cmdlen, data, datalen);
 		dev_dbg(dev, "%s returns %d\n", usb_stor_opcode_name(cmd[0]),
@@ -105,6 +104,8 @@ static int usb_stor_transport(struct us_blk_dev *usb_blkdev,
 			mdelay(request_sense_delay_ms);
 	}
 
+	dev_dbg(dev, "Retried %s %d times, and failed.\n", usb_stor_opcode_name(cmd[0]), retries);
+
 	return -EIO;
 }
 
@@ -194,7 +195,7 @@ static int usb_stor_io_10(struct us_blk_dev *usb_blkdev, u8 opcode,
 	put_unaligned_be16(blocks, &cmd[7]);
 
 	return usb_stor_transport(usb_blkdev, cmd, sizeof(cmd), data,
-				  blocks * SECTOR_SIZE, 2, 0);
+				  blocks * SECTOR_SIZE, 10, 0);
 }
 
 /***********************************************************************
-- 
2.7.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      parent reply	other threads:[~2019-11-04 15:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-25 15:56 [PATCH] " Robert Karszniewicz
2019-10-25 16:07 ` [PATCH] test: " Robert Karszniewicz
2019-11-04  9:42 ` [PATCH] " Sascha Hauer
2019-11-04 14:52   ` Robert Karszniewicz
2019-11-04 14:54   ` Marco Felsch
2019-11-04 14:59     ` Robert Karszniewicz
2019-11-04 15:21       ` Marco Felsch
2019-11-04 15:28         ` Robert Karszniewicz
2019-11-04 15:04     ` Robert Karszniewicz [this message]

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=1572879858-77435-1-git-send-email-r.karszniewicz@phytec.de \
    --to=r.karszniewicz@phytec.de \
    --cc=barebox@lists.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox