From 2a3775ef2530ca5108cd55044f6219d55fd11db5 Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Fri, 12 Aug 2005 14:17:50 +0800 Subject: [PATCH] --- yaml --- r: 6043 b: refs/heads/master c: 563a6e1fb0af58433beec1ab418e1fafbd100b56 h: refs/heads/master i: 6041: ebc9331a431c8035e6904f4bae821daec5c14321 6039: 5107929083ec6ae8839c6214b71bd073471820a7 v: v3 --- [refs] | 2 +- trunk/drivers/scsi/libata-core.c | 28 +++++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/[refs] b/[refs] index a472fba9feda..e137a8cf60f0 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 6ae4cfb5711b6f2878c9e384617971d98c34a7f5 +refs/heads/master: 563a6e1fb0af58433beec1ab418e1fafbd100b56 diff --git a/trunk/drivers/scsi/libata-core.c b/trunk/drivers/scsi/libata-core.c index 8f6e536d8924..9add4c521b6b 100644 --- a/trunk/drivers/scsi/libata-core.c +++ b/trunk/drivers/scsi/libata-core.c @@ -2697,10 +2697,33 @@ static void __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes) unsigned char *buf; unsigned int offset, count; - if (qc->curbytes == qc->nbytes - bytes) + if (qc->curbytes + bytes >= qc->nbytes) ap->pio_task_state = PIO_ST_LAST; next_sg: + if (unlikely(qc->cursg >= qc->n_elem)) { + /* + * The end of qc->sg is reached and the device expects + * more data to transfer. In order not to overrun qc->sg + * and fulfill length specified in the byte count register, + * - for read case, discard trailing data from the device + * - for write case, padding zero data to the device + */ + u16 pad_buf[1] = { 0 }; + unsigned int words = bytes >> 1; + unsigned int i; + + if (words) /* warning if bytes > 1 */ + printk(KERN_WARNING "ata%u: %u bytes trailing data\n", + ap->id, bytes); + + for (i = 0; i < words; i++) + ata_data_xfer(ap, (unsigned char*)pad_buf, 2, do_write); + + ap->pio_task_state = PIO_ST_LAST; + return; + } + sg = &qc->sg[qc->cursg]; page = sg->page; @@ -2734,9 +2757,8 @@ static void __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes) kunmap(page); - if (bytes) { + if (bytes) goto next_sg; - } } /**