* PATCH: scsi-sd-last-sector-bug-flag.patch
@ 2008-01-20 10:12 Hans de Goede
2008-01-20 16:48 ` James Bottomley
2008-01-20 20:55 ` Greg KH
0 siblings, 2 replies; 4+ messages in thread
From: Hans de Goede @ 2008-01-20 10:12 UTC (permalink / raw)
To: James Bottomley
Cc: Matthew Dharm, Guillaume Bedot, Boaz Harrosh, USB Storage list,
USB development list, David Brown, linux-scsi, linux-usb
[-- Attachment #1: Type: text/plain, Size: 357 bytes --]
Hi all,
This patch adds a new scsi_device flag for devices which contain a bug where
the device crashes when the last sector is read in a larger then 1 sector read.
This is for example the case with sdcards in the HP PSC1350 printer cardreader
and in the HP PSC1610 printer cardreader.
Signed-off-by: Hans de Goede <j.w.r.degoede@hhs.nl>
Regards,
Hans
[-- Attachment #2: scsi-sd-last-sector-bug-flag.patch --]
[-- Type: text/x-patch, Size: 1824 bytes --]
This patch adds a new scsi_device flag for devices which contain a bug where
the device crashes when the last sector is read in a larger then 1 sector read.
This is for example the case with sdcards in the HP PSC1350 printer cardreader
and in the HP PSC1610 printer cardreader.
Signed-off-by: Hans de Goede <j.w.r.degoede@hhs.nl>
diff -up vanilla-2.6.24-rc7/include/scsi/scsi_device.h.psc1350 vanilla-2.6.24-rc7/include/scsi/scsi_device.h
--- vanilla-2.6.24-rc7/include/scsi/scsi_device.h.psc1350 2008-01-11 19:40:31.000000000 +0100
+++ vanilla-2.6.24-rc7/include/scsi/scsi_device.h 2008-01-11 19:40:48.000000000 +0100
@@ -142,6 +142,7 @@ struct scsi_device {
unsigned fix_capacity:1; /* READ_CAPACITY is too high by 1 */
unsigned guess_capacity:1; /* READ_CAPACITY might be too high by 1 */
unsigned retry_hwerror:1; /* Retry HARDWARE_ERROR */
+ unsigned last_sector_bug:1; /* Always read last sector in a 1 sector read */
DECLARE_BITMAP(supported_events, SDEV_EVT_MAXBITS); /* supported events */
struct list_head event_list; /* asserted events */
diff -up vanilla-2.6.24-rc7/drivers/scsi/sd.c.psc1350 vanilla-2.6.24-rc7/drivers/scsi/sd.c
--- vanilla-2.6.24-rc7/drivers/scsi/sd.c.psc1350 2008-01-11 19:55:43.000000000 +0100
+++ vanilla-2.6.24-rc7/drivers/scsi/sd.c 2008-01-20 10:49:17.000000000 +0100
@@ -395,6 +395,16 @@ static int sd_prep_fn(struct request_que
goto out;
}
+ /*
+ * Some devices (some sdcards for one) don't like it if the last sector
+ * gets read in a larger then 1 sector read.
+ */
+ if (unlikely(sdp->last_sector_bug &&
+ rq->nr_sectors > sdp->sector_size / 512 &&
+ block + this_count == get_capacity(disk))) {
+ this_count -= sdp->sector_size / 512;
+ }
+
SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt, "block=%llu\n",
(unsigned long long)block));
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH: scsi-sd-last-sector-bug-flag.patch
2008-01-20 10:12 PATCH: scsi-sd-last-sector-bug-flag.patch Hans de Goede
@ 2008-01-20 16:48 ` James Bottomley
2008-01-20 20:55 ` Greg KH
1 sibling, 0 replies; 4+ messages in thread
From: James Bottomley @ 2008-01-20 16:48 UTC (permalink / raw)
To: Hans de Goede
Cc: Matthew Dharm, Guillaume Bedot, Boaz Harrosh, USB Storage list,
USB development list, David Brown, linux-scsi, linux-usb
On Sun, 2008-01-20 at 11:12 +0100, Hans de Goede wrote:
> Hi all,
>
> This patch adds a new scsi_device flag for devices which contain a bug where
> the device crashes when the last sector is read in a larger then 1 sector read.
>
> This is for example the case with sdcards in the HP PSC1350 printer cardreader
> and in the HP PSC1610 printer cardreader.
>
> Signed-off-by: Hans de Goede <j.w.r.degoede@hhs.nl>
This could have done with running through checkpatch.pl:
ERROR: trailing whitespace
#28: FILE: drivers/scsi/sd.c:398:
+^I/* $
ERROR: trailing whitespace
#32: FILE: drivers/scsi/sd.c:402:
+^Iif (unlikely(sdp->last_sector_bug && $
WARNING: braces {} are not necessary for single statement blocks
#32: FILE: drivers/scsi/sd.c:402:
+ if (unlikely(sdp->last_sector_bug &&
+ rq->nr_sectors > sdp->sector_size / 512 &&
+ block + this_count == get_capacity(disk))) {
+ this_count -= sdp->sector_size / 512;
+ }
ERROR: use tabs not spaces
#34: FILE: drivers/scsi/sd.c:404:
+ ^I block + this_count == get_capacity(disk))) {$
WARNING: line over 80 characters
#49: FILE: include/scsi/scsi_device.h:142:
+ unsigned last_sector_bug:1; /* Always read last sector in a
1 sector read */
total: 3 errors, 2 warnings, 23 lines checked
I've fixed all of these up.
James
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH: scsi-sd-last-sector-bug-flag.patch
2008-01-20 10:12 PATCH: scsi-sd-last-sector-bug-flag.patch Hans de Goede
2008-01-20 16:48 ` James Bottomley
@ 2008-01-20 20:55 ` Greg KH
2008-01-20 21:10 ` Hans de Goede
1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2008-01-20 20:55 UTC (permalink / raw)
To: Hans de Goede
Cc: Guillaume Bedot, USB development list, linux-scsi,
USB Storage list, linux-usb, David Brown, James Bottomley,
Boaz Harrosh, Matthew Dharm
On Sun, Jan 20, 2008 at 11:12:26AM +0100, Hans de Goede wrote:
> Hi all,
>
> This patch adds a new scsi_device flag for devices which contain a bug
> where
> the device crashes when the last sector is read in a larger then 1 sector
> read.
>
> This is for example the case with sdcards in the HP PSC1350 printer
> cardreader
> and in the HP PSC1610 printer cardreader.
Wait, we already handle this in the usb-storage driver, why are you
putting this in the scsi core now?
confused,
greg k-h
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH: scsi-sd-last-sector-bug-flag.patch
2008-01-20 20:55 ` Greg KH
@ 2008-01-20 21:10 ` Hans de Goede
0 siblings, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2008-01-20 21:10 UTC (permalink / raw)
To: Greg KH
Cc: Guillaume Bedot, USB development list, linux-scsi,
USB Storage list, linux-usb, David Brown, James Bottomley,
Boaz Harrosh, Matthew Dharm
Greg KH wrote:
> On Sun, Jan 20, 2008 at 11:12:26AM +0100, Hans de Goede wrote:
>> Hi all,
>>
>> This patch adds a new scsi_device flag for devices which contain a bug
>> where
>> the device crashes when the last sector is read in a larger then 1 sector
>> read.
>>
>> This is for example the case with sdcards in the HP PSC1350 printer
>> cardreader
>> and in the HP PSC1610 printer cardreader.
>
> Wait, we already handle this in the usb-storage driver, why are you
> putting this in the scsi core now?
>
No we don't, I've send patches for this to the usb-storage driver but they were
refused as they modified scsi commands in flight, the consensus was that this
should be done in the scsi layer, hence this patch.
> confused,
I've noticed, esp. with regards to your second mail to which I will reply next.
There has been a lot of discussion about this ending in this (perfectly fine)
patch, which is much better then my original hack if I may add that.
Regards,
Hans
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-01-20 21:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-20 10:12 PATCH: scsi-sd-last-sector-bug-flag.patch Hans de Goede
2008-01-20 16:48 ` James Bottomley
2008-01-20 20:55 ` Greg KH
2008-01-20 21:10 ` Hans de Goede
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).