Gitweb: http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=a0899d4df534d2bcf671b0f647b809842309a9ae Commit: a0899d4df534d2bcf671b0f647b809842309a9ae Parent: b523381e325366cc54a2548df418c2a427b2f2ee Author: Hans de Goede <[EMAIL PROTECTED]> AuthorDate: Sun Jan 20 11:12:26 2008 +0100 Committer: James Bottomley <[EMAIL PROTECTED]> CommitDate: Wed Jan 23 11:29:34 2008 -0600
[SCSI] sd: add fix for devices with last sector access problems This patch adds a new scsi_device flag (last_sector_bug) 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 <[EMAIL PROTECTED]> Signed-off-by: James Bottomley <[EMAIL PROTECTED]> --- drivers/scsi/sd.c | 9 +++++++++ include/scsi/scsi_device.h | 1 + 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 212f6bc..24eba31 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -395,6 +395,15 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq) 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)); diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index e0c645a..3c8f898 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -139,6 +139,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 */ - To unsubscribe from this list: send the line "unsubscribe git-commits-head" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html