* [PATCH] usb: storage: Increase retries for usb_stor_transport()
@ 2019-10-25 15:56 Robert Karszniewicz
2019-10-25 16:07 ` [PATCH] test: " Robert Karszniewicz
2019-11-04 9:42 ` [PATCH] " Sascha Hauer
0 siblings, 2 replies; 9+ messages in thread
From: Robert Karszniewicz @ 2019-10-25 15:56 UTC (permalink / raw)
To: barebox
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
---
We've had problems writing (and even reading) a 10 MiB file from barebox
to multiple USB flash drives.
The 10 MiB file copy failed with "write: I/O error" almost every time.
Increasing the retry count made 100 MiB file copies succeed every time.
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] test: usb: storage: Increase retries for usb_stor_transport()
2019-10-25 15:56 [PATCH] usb: storage: Increase retries for usb_stor_transport() Robert Karszniewicz
@ 2019-10-25 16:07 ` Robert Karszniewicz
2019-11-04 9:42 ` [PATCH] " Sascha Hauer
1 sibling, 0 replies; 9+ messages in thread
From: Robert Karszniewicz @ 2019-10-25 16:07 UTC (permalink / raw)
To: barebox
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
---
And here is the test for how many retries were required at maximum. In case
anyone wants to try for themselves.
barebox:/ usb && mkdir /mnt/usb && mount /dev/disk0.0 /mnt/usb && echo 'generating 100MiB file' && memcpy -s /dev/prng -d testfile 0x0 0x0 104857600 && echo 'writing file to drive' && cp testfile /mnt/usb/testfile && md5sum testfile /mnt/usb/testfile; ls -l testfile /mnt/usb/testfile
The highest max_retries for our three drives was 4. So 10 should be high enough.
drivers/usb/storage/usb.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 63d624e..90e4492 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -86,9 +86,13 @@ static int usb_stor_transport(struct us_blk_dev *usb_blkdev,
struct us_data *us = usb_blkdev->us;
struct device_d *dev = &us->pusb_dev->dev;
int i, ret;
+ static int max_retries = 0;
-
- for (i = 0; i < retries; i++) {
+ for (i = 0; i <= retries; i++) {
+ if (cmd[0] == SCSI_WRITE10 && i > max_retries) {
+ max_retries = i;
+ printf("max_retries = %d\n", max_retries);
+ }
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 +109,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 +200,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, 100, 0);
}
/***********************************************************************
--
2.7.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] usb: storage: Increase retries for usb_stor_transport()
2019-10-25 15:56 [PATCH] usb: storage: Increase retries for usb_stor_transport() Robert Karszniewicz
2019-10-25 16:07 ` [PATCH] test: " Robert Karszniewicz
@ 2019-11-04 9:42 ` Sascha Hauer
2019-11-04 14:52 ` Robert Karszniewicz
2019-11-04 14:54 ` Marco Felsch
1 sibling, 2 replies; 9+ messages in thread
From: Sascha Hauer @ 2019-11-04 9:42 UTC (permalink / raw)
To: Robert Karszniewicz; +Cc: barebox
On Fri, Oct 25, 2019 at 05:56:08PM +0200, Robert Karszniewicz wrote:
> 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
> ---
> We've had problems writing (and even reading) a 10 MiB file from barebox
> to multiple USB flash drives.
> The 10 MiB file copy failed with "write: I/O error" almost every time.
> Increasing the retry count made 100 MiB file copies succeed every time.
>
Doing this doesn't hurt, so I applied this patch. I wonder though if
there's something else wrong which makes increasing the retry counts
necessary.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] usb: storage: Increase retries for usb_stor_transport()
2019-11-04 9:42 ` [PATCH] " Sascha Hauer
@ 2019-11-04 14:52 ` Robert Karszniewicz
2019-11-04 14:54 ` Marco Felsch
1 sibling, 0 replies; 9+ messages in thread
From: Robert Karszniewicz @ 2019-11-04 14:52 UTC (permalink / raw)
To: barebox
On 11/4/19 10:42 AM, Sascha Hauer wrote:
> On Fri, Oct 25, 2019 at 05:56:08PM +0200, Robert Karszniewicz wrote:
>> 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
>> ---
>> We've had problems writing (and even reading) a 10 MiB file from barebox
>> to multiple USB flash drives.
>> The 10 MiB file copy failed with "write: I/O error" almost every time.
>> Increasing the retry count made 100 MiB file copies succeed every time.
>>
>
> Doing this doesn't hurt, so I applied this patch. I wonder though if
> there's something else wrong which makes increasing the retry counts
> necessary.
>
> Sascha
>
>
Thanks, yes, so I thought, too; it doesn't hurt, so I sent it in.
From when I looked at the problem, it seemed to me that the whole USB
flash drives thing is fickle. I glanced at the USB storage drivers of
Linux and saw that they have a bunch of workarounds and per-device
quirks. So Linux' drivers simply seem more mature and tolerant than
those in barebox.
Robert
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] usb: storage: Increase retries for usb_stor_transport()
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:04 ` [PATCH v2] " Robert Karszniewicz
1 sibling, 2 replies; 9+ messages in thread
From: Marco Felsch @ 2019-11-04 14:54 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox, Robert Karszniewicz
Hi Sascha,
On 19-11-04 10:42, Sascha Hauer wrote:
> On Fri, Oct 25, 2019 at 05:56:08PM +0200, Robert Karszniewicz wrote:
> > 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
> > ---
> > We've had problems writing (and even reading) a 10 MiB file from barebox
> > to multiple USB flash drives.
> > The 10 MiB file copy failed with "write: I/O error" almost every time.
> > Increasing the retry count made 100 MiB file copies succeed every time.
> >
>
> Doing this doesn't hurt, so I applied this patch. I wonder though if
> there's something else wrong which makes increasing the retry counts
> necessary.
>
> Sascha
there is a missing sob is that okay with you? Robert can you add a
signed-off-by line?
Regards,
Marco
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] usb: storage: Increase retries for usb_stor_transport()
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:04 ` [PATCH v2] " Robert Karszniewicz
1 sibling, 1 reply; 9+ messages in thread
From: Robert Karszniewicz @ 2019-11-04 14:59 UTC (permalink / raw)
To: barebox
On 11/4/19 3:54 PM, Marco Felsch wrote:
> Hi Sascha,
>
> On 19-11-04 10:42, Sascha Hauer wrote:
>> On Fri, Oct 25, 2019 at 05:56:08PM +0200, Robert Karszniewicz wrote:
>>> 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
>>> ---
>>> We've had problems writing (and even reading) a 10 MiB file from barebox
>>> to multiple USB flash drives.
>>> The 10 MiB file copy failed with "write: I/O error" almost every time.
>>> Increasing the retry count made 100 MiB file copies succeed every time.
>>>
>>
>> Doing this doesn't hurt, so I applied this patch. I wonder though if
>> there's something else wrong which makes increasing the retry counts
>> necessary.
>>
>> Sascha
>
> there is a missing sob is that okay with you? Robert can you add a
> signed-off-by line?
>
Oops, I'm sorry for that! How do we handle this? Should I just amend and
resubmit the patch?
> Regards,
> Marco
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] usb: storage: Increase retries for usb_stor_transport()
2019-11-04 14:59 ` Robert Karszniewicz
@ 2019-11-04 15:21 ` Marco Felsch
2019-11-04 15:28 ` Robert Karszniewicz
0 siblings, 1 reply; 9+ messages in thread
From: Marco Felsch @ 2019-11-04 15:21 UTC (permalink / raw)
To: Robert Karszniewicz; +Cc: barebox
Hi Robert,
On 19-11-04 15:59, Robert Karszniewicz wrote:
> On 11/4/19 3:54 PM, Marco Felsch wrote:
> > Hi Sascha,
> >
> > On 19-11-04 10:42, Sascha Hauer wrote:
> > > On Fri, Oct 25, 2019 at 05:56:08PM +0200, Robert Karszniewicz wrote:
> > > > 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
> > > > ---
> > > > We've had problems writing (and even reading) a 10 MiB file from barebox
> > > > to multiple USB flash drives.
> > > > The 10 MiB file copy failed with "write: I/O error" almost every time.
> > > > Increasing the retry count made 100 MiB file copies succeed every time.
> > > >
> > >
> > > Doing this doesn't hurt, so I applied this patch. I wonder though if
> > > there's something else wrong which makes increasing the retry counts
> > > necessary.
> > >
> > > Sascha
> >
> > there is a missing sob is that okay with you? Robert can you add a
> > signed-off-by line?
> >
>
> Oops, I'm sorry for that! How do we handle this? Should I just amend and
> resubmit the patch?
Resend as you already did is fine :) else you could reply with your
sob-tag.
Regards,
Marco
> > Regards,
> > Marco
> >
> > _______________________________________________
> > barebox mailing list
> > barebox@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/barebox
> >
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] usb: storage: Increase retries for usb_stor_transport()
2019-11-04 15:21 ` Marco Felsch
@ 2019-11-04 15:28 ` Robert Karszniewicz
0 siblings, 0 replies; 9+ messages in thread
From: Robert Karszniewicz @ 2019-11-04 15:28 UTC (permalink / raw)
To: barebox
On 11/4/19 4:21 PM, Marco Felsch wrote:
> Hi Robert,
>
> On 19-11-04 15:59, Robert Karszniewicz wrote:
>> On 11/4/19 3:54 PM, Marco Felsch wrote:
>>> Hi Sascha,
>>>
>>> On 19-11-04 10:42, Sascha Hauer wrote:
>>>> On Fri, Oct 25, 2019 at 05:56:08PM +0200, Robert Karszniewicz wrote:
>>>>> 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
>>>>> ---
>>>>> We've had problems writing (and even reading) a 10 MiB file from barebox
>>>>> to multiple USB flash drives.
>>>>> The 10 MiB file copy failed with "write: I/O error" almost every time.
>>>>> Increasing the retry count made 100 MiB file copies succeed every time.
>>>>>
>>>>
>>>> Doing this doesn't hurt, so I applied this patch. I wonder though if
>>>> there's something else wrong which makes increasing the retry counts
>>>> necessary.
>>>>
>>>> Sascha
>>>
>>> there is a missing sob is that okay with you? Robert can you add a
>>> signed-off-by line?
>>>
>>
>> Oops, I'm sorry for that! How do we handle this? Should I just amend and
>> resubmit the patch?
>
> Resend as you already did is fine :) else you could reply with your
> sob-tag.
Ok!
>
> Regards,
> Marco
>
>>> Regards,
>>> Marco
>>>
>>> _______________________________________________
>>> barebox mailing list
>>> barebox@lists.infradead.org
>>> http://lists.infradead.org/mailman/listinfo/barebox
>>>
>>
>>
>> _______________________________________________
>> barebox mailing list
>> barebox@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/barebox
>>
>
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2] usb: storage: Increase retries for usb_stor_transport()
2019-11-04 14:54 ` Marco Felsch
2019-11-04 14:59 ` Robert Karszniewicz
@ 2019-11-04 15:04 ` Robert Karszniewicz
1 sibling, 0 replies; 9+ messages in thread
From: Robert Karszniewicz @ 2019-11-04 15:04 UTC (permalink / raw)
To: barebox
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
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2019-11-04 15:28 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-25 15:56 [PATCH] usb: storage: Increase retries for usb_stor_transport() 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 ` [PATCH v2] " Robert Karszniewicz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox