Re: Buffer I/O error after s2ram with usb storage

From: Matthieu CASTET
Date: Fri Aug 29 2014 - 12:11:47 EST


Le Wed, 27 Aug 2014 10:54:53 -0400,
Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> a écrit :

> On Wed, 27 Aug 2014, Matthieu CASTET wrote:
>
> > Ping
> >
> > I have got also a problem with a usb sdcard reader (without power cut
> > during suspend)
>
> > > > The usb storage driver call scsi_report_bus_reset after device reset,
> > > > but because of commit dfcf7775 <4>, we don't ignore unit attention if
> > > > "sshdr.asc == 0x28 && sshdr.ascq == 0x00" ("Not-ready to ready").
> > > >
> > > > If dfcf7775 is reverted there is no more Buffer I/O error.
> > > >
> > > > Is that possible to find a way to restore the behavior before dfcf7775
> > > > commit (no Buffer I/O error after device reset) after a suspend to ram ?
>
> Since that commit was written to fix a problem with certain cdrom
> drives, maybe we would work around the issue by modifying the commit.
> Have it go back to the original behavior if the device isn't a cdrom
> drive.
>
> That's not a complete fix (it won't help when a CD drive is attached
> via USB), but maybe it's better than nothing.
>
Ok,

note to handle all case we need also to filter unit_attention in
scsi_test_unit_ready. Otherwise DISK_EVENT_MEDIA_CHANGE event is set and check_disk_change will invalidate vfs cache.


Matthieu

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 2bc0362..e994061 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2030,8 +2030,12 @@ scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries,
result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, sshdr,
timeout, retries, NULL);
if (sdev->removable && scsi_sense_valid(sshdr) &&
- sshdr->sense_key == UNIT_ATTENTION)
- sdev->changed = 1;
+ sshdr->sense_key == UNIT_ATTENTION) {
+ if (sdev->expecting_cc_ua)
+ sdev->expecting_cc_ua = 0;
+ else
+ sdev->changed = 1;
+ }
} while (scsi_sense_valid(sshdr) &&
sshdr->sense_key == UNIT_ATTENTION && --retries);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/