Re: [PATCH] pata_legacy: Restructure and revamp

2007-12-11 Thread Andrew Morton
On Sat, 8 Dec 2007 15:55:06 + Alan Cox <[EMAIL PROTECTED]> wrote:

> Rework the pata_legacy driver to have an internal way to plug multiple legacy 
> interface types
> and designs into the driver. 
> 
> This driver supports
>   - Generic legacy ISA on primary/secondary and tertiary ports
>   - BIOS or jumper configured legacy ports
>   - VLB controllers that snoop the mode set for PIO
>   (Cirrus CLPD7220, Adaptec AIC25VL01)
>   - Promise PDC20230
>   - Holtek 6560A/B
>   - Opti VLB controllers
>   - QDI 6500/6580/6580DP controllers
> 
> The new driver also adds an "all" option so you can load all the PCI drivers 
> you have, decide you have
> a controller that is totally unknown and then load pata_legacy all=1 to grab 
> the primary/secondary ports
> as a last resort fallback.
> 
> TODO:
>   Add ST412 support (needs some kind of geometry hook in libata core code)
>   Winbond W83759A in programmable mode (aka DTC2278)
>   Find more insane VLB controllers to support
> 
> This driver obsoletes pata_qdi, which can go once this is settled in.
> 

Is this patch going to screw my kernel up?

> +static __init void probe_opti_vlb(void)
> +{
> + /* If an OPTI 82C46X is present find out where the channels are */
> + static const char *optis[4] = {
> + "3/463MV", "5MV",
> + "5MVA", "5MVB"
> + };
> + u8 chans = 1;
> + u8 ctrl = (opti_syscfg(0x30) & 0xC0) >> 6;
> +
> + opti82c46x = 3; /* Assume master and slave first */
> + printk(KERN_INFO DRV_NAME ": Opti 82C46%s chipset support.\n",
> + optis[ctrl]);
> + if (ctrl == 3)
> + chans = (opti_syscfg(0x3F) & 0x20) ? 2 : 1;

this could be

if (ctrl == 3 && (opti_syscfg(0x3F) & 0x20))
chans = 2;

if that's any clearer...

-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: sata_mv hotplug flaky?

2007-12-11 Thread Jeff Garzik

Orion Poplawski wrote:
Not sure what the latest status of sata_mv hotplug should be, but it 
seems close.  I'm currently running 2.6.24-0.81.rc4.git7.fc9 with a 
MV88SX5081.  Pulled a couple drives and re-added.  One device got 
re-added, but the other did not.  It seems like I got the system to 
probe and re-add the first drive by doing a "mount -a", but haven't been 
able (no idea how) to re-add the second.




hotplug made great strides with the introduction of the new-EH code, but 
it still needs a bit of work.  Mark Lord was looking into that, so you 
can sure your report has been noted...


Jeff



-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH #upstream-fixes] libata: fix ATAPI draining

2007-12-11 Thread Tejun Heo
With ATAPI transfer chunk size properly programmed, libata PIO HSM
should be able to handle full spurious data chunks.  Also, it's a good
idea to suppress trailing data warning for misc ATAPI commands as
there can be many of them per command - for example, if the chunk size
is 16 and the drive tries to transfer 510 bytes, there can be 31
trailing data messages.

This patch makes the following updates to libata ATAPI PIO HSM
implementation.

* Make it drain full spurious chunks.

* Suppress trailing data warning message for misc commands.

* Put limit on how many bytes can be drained.

* If odd, round up consumed bytes and the number of bytes to be
  drained.  This gets the number of bytes to drain right for drivers
  which do 16bit PIO.

This patch is partial backport of improve-ATAPI-data-xfer patchset
pending for #upstream.

Signed-off-by: Tejun Heo <[EMAIL PROTECTED]>
---
This combined with the previous patch fixes bug 9346.

 drivers/ata/libata-core.c |   87 ++
 include/linux/libata.h|2 +
 2 files changed, 67 insertions(+), 22 deletions(-)

Index: work/drivers/ata/libata-core.c
===
--- work.orig/drivers/ata/libata-core.c
+++ work/drivers/ata/libata-core.c
@@ -64,6 +64,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "libata.h"
 
@@ -4649,6 +4650,43 @@ int ata_check_atapi_dma(struct ata_queue
 }
 
 /**
+ * atapi_qc_may_overflow - Check whether data transfer may overflow
+ * @qc: ATA command in question
+ *
+ * ATAPI commands which transfer variable length data to host
+ * might overflow due to application error or hardare bug.  This
+ * function checks whether overflow should be drained and ignored
+ * for @qc.
+ *
+ * LOCKING:
+ * None.
+ *
+ * RETURNS:
+ * 1 if @qc may overflow; otherwise, 0.
+ */
+static int atapi_qc_may_overflow(struct ata_queued_cmd *qc)
+{
+   if (qc->tf.protocol != ATA_PROT_ATAPI &&
+   qc->tf.protocol != ATA_PROT_ATAPI_DMA)
+   return 0;
+
+   if (qc->tf.flags & ATA_TFLAG_WRITE)
+   return 0;
+
+   switch (qc->cdb[0]) {
+   case READ_10:
+   case READ_12:
+   case WRITE_10:
+   case WRITE_12:
+   case GPCMD_READ_CD:
+   case GPCMD_READ_CD_MSF:
+   return 0;
+   }
+
+   return 1;
+}
+
+/**
  * ata_std_qc_defer - Check whether a qc needs to be deferred
  * @qc: ATA command in question
  *
@@ -5136,23 +5174,19 @@ static void atapi_send_cdb(struct ata_po
  * Inherited from caller.
  *
  */
-
-static void __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes)
+static int __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes)
 {
int do_write = (qc->tf.flags & ATA_TFLAG_WRITE);
-   struct scatterlist *sg = qc->__sg;
-   struct scatterlist *lsg = sg_last(qc->__sg, qc->n_elem);
struct ata_port *ap = qc->ap;
+   struct ata_eh_info *ehi = &qc->dev->link->eh_info;
+   struct scatterlist *sg;
struct page *page;
unsigned char *buf;
unsigned int offset, count;
-   int no_more_sg = 0;
-
-   if (qc->curbytes + bytes >= qc->nbytes)
-   ap->hsm_task_state = HSM_ST_LAST;
 
 next_sg:
-   if (unlikely(no_more_sg)) {
+   sg = qc->cursg;
+   if (unlikely(!sg)) {
/*
 * The end of qc->sg is reached and the device expects
 * more data to transfer. In order not to overrun qc->sg
@@ -5161,21 +5195,28 @@ next_sg:
 *- 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 */
-   ata_dev_printk(qc->dev, KERN_WARNING,
-  "%u bytes trailing data\n", bytes);
+   if (bytes > qc->curbytes - qc->nbytes + ATAPI_MAX_DRAIN) {
+   ata_ehi_push_desc(ehi, "too much trailing data "
+ "buf=%u cur=%u bytes=%u",
+ qc->nbytes, qc->curbytes, bytes);
+   return -1;
+   }
+
+/* overflow is exptected for misc ATAPI commands */
+   if (bytes && !atapi_qc_may_overflow(qc))
+   ata_dev_printk(qc->dev, KERN_WARNING, "ATAPI %u bytes "
+  "trailing data (cdb=%02x nbytes=%u)\n",
+  bytes, qc->cdb[0], qc->nbytes);
 
-   for (i = 0; i < words; i++)
+   for (i = 0; i < (bytes + 1) / 2; i++)
ap->ops->data_xfer(qc->dev, (unsigned char *)pad_buf, 
2, do_write);
 
-   ap->hsm_task_state = HSM_ST_LAST;
-   return;
-   }
+   qc

[PATCH #upstream-fixes] libata: update atapi_eh_request_sense() such that lbam/lbah contains buffer size

2007-12-11 Thread Tejun Heo
While updating lbam/h for ATAPI commands, atapi_eh_request_sense() was
left out.  Update it.

Signed-off-by: Tejun Heo <[EMAIL PROTECTED]>
---
This patch is from improve-ATAPI-data-xfer patchset pending for
#upstream.

 drivers/ata/libata-eh.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: work/drivers/ata/libata-eh.c
===
--- work.orig/drivers/ata/libata-eh.c
+++ work/drivers/ata/libata-eh.c
@@ -1264,8 +1264,8 @@ static unsigned int atapi_eh_request_sen
tf.feature |= ATAPI_PKT_DMA;
} else {
tf.protocol = ATA_PROT_ATAPI;
-   tf.lbam = (8 * 1024) & 0xff;
-   tf.lbah = (8 * 1024) >> 8;
+   tf.lbam = SCSI_SENSE_BUFFERSIZE;
+   tf.lbah = 0;
}
 
return ata_exec_internal(dev, &tf, cdb, DMA_FROM_DEVICE,
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 12/30] blk_end_request: changing ub (take 4)

2007-12-11 Thread Pete Zaitcev
On Tue, 11 Dec 2007 17:46:47 -0500 (EST), Kiyoshi Ueda <[EMAIL PROTECTED]> 
wrote:

>   if (scsi_status == 0) {
> - uptodate = 1;
> + error = 0;
>   } else {
> - uptodate = 0;
> + error = -EIO;
>   rq->errors = scsi_status;
>   }
> - end_that_request_first(rq, uptodate, rq->hard_nr_sectors);
> - end_that_request_last(rq, uptodate);
> + if (__blk_end_request(rq, error, blk_rq_bytes(rq)))
> + BUG();

Acked-by: Pete Zaitcev <[EMAIL PROTECTED]>

I follow the discussion, actually, and wanted to ask someone to look
closer if it's appropriate to use __blk_end_request() here.
My understanding was, blk_end_request() is the same thing, only
takes the queue lock. But then, should I refactor ub so that it
calls __blk_end_request if request function ends with an error
and blk_end_request if the end-of-IO even is processed? If not,
and the above is sufficient, why have blk_end_request at all?

-- Pete
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: PROBLEM: WARNING: at kernel/irq/manage.c:158 enable_irq() during boot

2007-12-11 Thread Tejun Heo
Wojciech Zareba wrote:
> Hello,
> 
> Tejun Heo pisze:
>> (cc'ing Bartlomiej)
>> Hello,
>>
>> [EMAIL PROTECTED] wrote:
>>> Dec  6 11:58:23 titanium kernel: WARNING: at kernel/irq/manage.c:158 
>>> enable_irq()
>>> Dec  6 11:58:23 titanium kernel:  [] enable_irq+0x6e/0xa2
>>> Dec  6 11:58:23 titanium kernel:  [] probe_hwif+0x6d8/0x7c7 
>>> [ide_core]
>>> Dec  6 11:58:23 titanium kernel:  [] 
>>> probe_hwif_init_with_fixup+0xc/0x80 [ide_core]
>>> Dec  6 11:58:23 titanium kernel:  [] elf_core_dump+0x627/0xb60
>>> Dec  6 11:58:23 titanium kernel:  [] 
>>> ide_setup_pci_device+0x6f/0x9c [ide_core]
>>> Dec  6 11:58:23 titanium kernel:  [] pdc202new_init_one+0xf/0x10 
>>> [pdc202xx_new]
>>> Dec  6 11:58:23 titanium kernel:  [] pci_device_probe+0x36/0x55
>>> Dec  6 11:58:23 titanium kernel:  [] 
>>> driver_probe_device+0xc8/0x14b
>>> Dec  6 11:58:23 titanium kernel:  [] __driver_attach+0x52/0x87
>>> Dec  6 11:58:23 titanium kernel:  [] bus_for_each_dev+0x35/0x57
>>> Dec  6 11:58:23 titanium kernel:  [] driver_attach+0x16/0x18
>>> Dec  6 11:58:23 titanium kernel:  [] __driver_attach+0x0/0x87
>>> Dec  6 11:58:23 titanium kernel:  [] bus_add_driver+0x6d/0x153
>>> Dec  6 11:58:23 titanium kernel:  [] 
>>> __pci_register_driver+0x4b/0x77
>>> Dec  6 11:58:23 titanium kernel:  [] sys_init_module+0x1525/0x15fb
>>> Dec  6 11:58:23 titanium kernel:  [] 
>>> ide_config_drive_speed+0x0/0x314 [ide_core]
>>> Dec  6 11:58:23 titanium kernel:  [] syscall_call+0x7/0xb
>>> Dec  6 11:58:23 titanium kernel:  [] 
>>> wireless_nlevent_process+0x15/0x31
>>> Dec  6 11:58:23 titanium kernel:  ===
>> That means IRQ is being enabled more times than it should be.  Can you
>> please give a shot at 2.6.24-rc4 and see whether the problem is still there?
>>
> It seems to be no more of this warning in the 2.6.24-rc4 kernel. But my 
> feeling
> is that overall system performance is much poorer... pity. Maybe I should 
> change
> something in the .config file?

Good, so it's something fixed during 2.6.24 devel cycle.  What do you
mean by 'overall system performance'?  Does IO feel much slower?

-- 
tejun
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [stable] [PATCH -stable] libata: kill spurious NCQ completion detection

2007-12-11 Thread Tejun Heo
Greg KH wrote:
> On Sat, Dec 08, 2007 at 09:25:31AM +0900, Tejun Heo wrote:
>> Spurious NCQ completion detection implemented in ahci was incorrect.
>> On AHCI receving and processing FISes and raising interrupts are not
>> interlocked and spurious interrupts are expected.
>>
>> For example, if an interrupt occurs while interrupt handler is running
>> and the running interrupt handler handles the event the new IRQ
>> indicated, after IRQ handler finishes, it will be executed again
>> because IRQ pending bit is set by the new interrupt but there won't be
>> anything to process.
>>
>> Please read the following message for more information.
>>
>>   http://article.gmane.org/gmane.linux.ide/26012
>>
>> This patch...
> 
> Is this already in Linus's tree?  Is this for 2.6.23-stable, and/or
> older ones too?

Yes, this is in Linus's tree and it's for 2.6.23-stable.  2.6.22 is
affected too so it'll be a good idea to update 2.6.22 too.  Kernels
before 2.6.22 are fine.

Thanks.


-- 
tejun
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 20/30] blk_end_request: changing xsysace (take 4)

2007-12-11 Thread Grant Likely
On 12/11/07, Kiyoshi Ueda <[EMAIL PROTECTED]> wrote:
> This patch converts xsysace to use blk_end_request interfaces.
> Related 'uptodate' arguments are converted to 'error'.
>
> xsysace is a little bit different from "normal" drivers.
> xsysace driver has a state machine in it.
> It calls end_that_request_first() and end_that_request_last()
> from different states. (ACE_FSM_STATE_REQ_TRANSFER and
> ACE_FSM_STATE_REQ_COMPLETE, respectively.)
>
> However, those states are consecutive and without any interruption
> inbetween.
> So we can just follow the standard conversion rule (b) mentioned in
> the patch subject "[PATCH 01/30] blk_end_request: add new request
> completion interface".
>
> Cc: Grant Likely <[EMAIL PROTECTED]>
> Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
> Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>

Acked-by: Grant Likely <[EMAIL PROTECTED]>

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
[EMAIL PROTECTED]
(403) 399-0195
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 29/30] blk_end_request: cleanup 'uptodate' related code (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch converts 'uptodate' arguments of no longer exported
interfaces, end_that_request_first/last, to 'error', and removes
internal conversions for it in blk_end_request interfaces.

Also, this patch removes no longer needed end_io_error().

Cc: Boaz Harrosh <[EMAIL PROTECTED]>
Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 block/ll_rw_blk.c  |   56 +++--
 include/linux/blkdev.h |8 ---
 2 files changed, 9 insertions(+), 55 deletions(-)

Index: 2.6.24-rc4/block/ll_rw_blk.c
===
--- 2.6.24-rc4.orig/block/ll_rw_blk.c
+++ 2.6.24-rc4/block/ll_rw_blk.c
@@ -3413,7 +3413,7 @@ static void blk_recalc_rq_sectors(struct
 /**
  * __end_that_request_first - end I/O on a request
  * @req:  the request being processed
- * @uptodate: 1 for success, 0 for I/O error, < 0 for specific error
+ * @error:0 for success, < 0 for error
  * @nr_bytes: number of bytes to complete
  *
  * Description:
@@ -3424,29 +3424,22 @@ static void blk_recalc_rq_sectors(struct
  * 0 - we are done with this request, call end_that_request_last()
  * 1 - still buffers pending for this request
  **/
-static int __end_that_request_first(struct request *req, int uptodate,
+static int __end_that_request_first(struct request *req, int error,
int nr_bytes)
 {
-   int total_bytes, bio_nbytes, error, next_idx = 0;
+   int total_bytes, bio_nbytes, next_idx = 0;
struct bio *bio;
 
blk_add_trace_rq(req->q, req, BLK_TA_COMPLETE);
 
/*
-* extend uptodate bool to allow < 0 value to be direct io error
-*/
-   error = 0;
-   if (end_io_error(uptodate))
-   error = !uptodate ? -EIO : uptodate;
-
-   /*
 * for a REQ_BLOCK_PC request, we want to carry any eventual
 * sense key with us all the way through
 */
if (!blk_pc_request(req))
req->errors = 0;
 
-   if (!uptodate) {
+   if (error) {
if (blk_fs_request(req) && !(req->cmd_flags & REQ_QUIET))
printk("end_request: I/O error, dev %s, sector %llu\n",
req->rq_disk ? req->rq_disk->disk_name : "?",
@@ -3619,17 +3612,9 @@ EXPORT_SYMBOL(blk_complete_request);
 /*
  * queue lock must be held
  */
-static void end_that_request_last(struct request *req, int uptodate)
+static void end_that_request_last(struct request *req, int error)
 {
struct gendisk *disk = req->rq_disk;
-   int error;
-
-   /*
-* extend uptodate bool to allow < 0 value to be direct io error
-*/
-   error = 0;
-   if (end_io_error(uptodate))
-   error = !uptodate ? -EIO : uptodate;
 
if (unlikely(laptop_mode) && blk_fs_request(req))
laptop_io_completion();
@@ -3754,14 +3739,6 @@ EXPORT_SYMBOL(end_request);
 
 static void complete_request(struct request *rq, int error)
 {
-   /*
-* REMOVEME: This conversion is transitional and will be removed
-*   when old end_that_request_* are unexported.
-*/
-   int uptodate = 1;
-   if (error)
-   uptodate = (error == -EIO) ? 0 : error;
-
if (blk_rq_tagged(rq))
blk_queue_end_tag(rq->q, rq);
 
@@ -3771,7 +3748,7 @@ static void complete_request(struct requ
if (blk_bidi_rq(rq) && !rq->end_io)
__blk_put_request(rq->next_rq->q, rq->next_rq);
 
-   end_that_request_last(rq, uptodate);
+   end_that_request_last(rq, error);
 }
 
 /**
@@ -3798,21 +3775,14 @@ static int blk_end_io(struct request *rq
 {
struct request_queue *q = rq->q;
unsigned long flags = 0UL;
-   /*
-* REMOVEME: This conversion is transitional and will be removed
-*   when old end_that_request_* are unexported.
-*/
-   int uptodate = 1;
-   if (error)
-   uptodate = (error == -EIO) ? 0 : error;
 
if (blk_fs_request(rq) || blk_pc_request(rq)) {
-   if (__end_that_request_first(rq, uptodate, nr_bytes))
+   if (__end_that_request_first(rq, error, nr_bytes))
return 1;
 
/* Bidi request must be completed as a whole */
if (blk_bidi_rq(rq) &&
-   __end_that_request_first(rq->next_rq, uptodate, bidi_bytes))
+   __end_that_request_first(rq->next_rq, error, bidi_bytes))
return 1;
}
 
@@ -3864,16 +3834,8 @@ EXPORT_SYMBOL_GPL(blk_end_request);
  **/
 int __blk_end_request(struct request *rq, int error, int nr_bytes)
 {
-   /*
-* REMOVEME: This conversion is transitional and will be removed
-*   when old end_that_request_* are unexported.
-*/
-   int uptodate = 1;
-   if (error)
-   uptodate

[PATCH 30/30] blk_end_request: cleanup of request completion (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch merges complete_request() into end_that_request_last()
for cleanup.

complete_request() was introduced by earlier part of this patch-set,
not to break the existing users of end_that_request_last().

Since all users are converted to blk_end_request interfaces and
end_that_request_last() is no longer exported, the code can be
merged to end_that_request_last().

Cc: Boaz Harrosh <[EMAIL PROTECTED]>
Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 block/ll_rw_blk.c |   31 ++-
 1 files changed, 14 insertions(+), 17 deletions(-)

Index: 2.6.24-rc4/block/ll_rw_blk.c
===
--- 2.6.24-rc4.orig/block/ll_rw_blk.c
+++ 2.6.24-rc4/block/ll_rw_blk.c
@@ -3616,6 +3616,12 @@ static void end_that_request_last(struct
 {
struct gendisk *disk = req->rq_disk;
 
+   if (blk_rq_tagged(req))
+   blk_queue_end_tag(req->q, req);
+
+   if (blk_queued_rq(req))
+   blkdev_dequeue_request(req);
+
if (unlikely(laptop_mode) && blk_fs_request(req))
laptop_io_completion();
 
@@ -3633,10 +3639,15 @@ static void end_that_request_last(struct
disk_round_stats(disk);
disk->in_flight--;
}
+
if (req->end_io)
req->end_io(req, error);
-   else
+   else {
+   if (blk_bidi_rq(req))
+   __blk_put_request(req->next_rq->q, req->next_rq);
+
__blk_put_request(req->q, req);
+   }
 }
 
 static inline void __end_request(struct request *rq, int uptodate,
@@ -3737,20 +3748,6 @@ void end_request(struct request *req, in
 }
 EXPORT_SYMBOL(end_request);
 
-static void complete_request(struct request *rq, int error)
-{
-   if (blk_rq_tagged(rq))
-   blk_queue_end_tag(rq->q, rq);
-
-   if (blk_queued_rq(rq))
-   blkdev_dequeue_request(rq);
-
-   if (blk_bidi_rq(rq) && !rq->end_io)
-   __blk_put_request(rq->next_rq->q, rq->next_rq);
-
-   end_that_request_last(rq, error);
-}
-
 /**
  * blk_end_io - Generic end_io function to complete a request.
  * @rq:   the request being processed
@@ -3793,7 +3790,7 @@ static int blk_end_io(struct request *rq
add_disk_randomness(rq->rq_disk);
 
spin_lock_irqsave(q->queue_lock, flags);
-   complete_request(rq, error);
+   end_that_request_last(rq, error);
spin_unlock_irqrestore(q->queue_lock, flags);
 
return 0;
@@ -3841,7 +3838,7 @@ int __blk_end_request(struct request *rq
 
add_disk_randomness(rq->rq_disk);
 
-   complete_request(rq, error);
+   end_that_request_last(rq, error);
 
return 0;
 }
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 28/30] blk_end_request: remove/unexport end_that_request_* (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch removes the following functions:
  o end_that_request_first()
  o end_that_request_chunk()
and stops exporting the functions below:
  o end_that_request_last()

Cc: Boaz Harrosh <[EMAIL PROTECTED]>
Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 block/ll_rw_blk.c  |   61 -
 include/linux/blkdev.h |   13 --
 2 files changed, 20 insertions(+), 54 deletions(-)

Index: 2.6.24-rc4/block/ll_rw_blk.c
===
--- 2.6.24-rc4.orig/block/ll_rw_blk.c
+++ 2.6.24-rc4/block/ll_rw_blk.c
@@ -3410,6 +3410,20 @@ static void blk_recalc_rq_sectors(struct
}
 }
 
+/**
+ * __end_that_request_first - end I/O on a request
+ * @req:  the request being processed
+ * @uptodate: 1 for success, 0 for I/O error, < 0 for specific error
+ * @nr_bytes: number of bytes to complete
+ *
+ * Description:
+ * Ends I/O on a number of bytes attached to @req, and sets it up
+ * for the next range of segments (if any) in the cluster.
+ *
+ * Return:
+ * 0 - we are done with this request, call end_that_request_last()
+ * 1 - still buffers pending for this request
+ **/
 static int __end_that_request_first(struct request *req, int uptodate,
int nr_bytes)
 {
@@ -3526,49 +3540,6 @@ static int __end_that_request_first(stru
return 1;
 }
 
-/**
- * end_that_request_first - end I/O on a request
- * @req:  the request being processed
- * @uptodate: 1 for success, 0 for I/O error, < 0 for specific error
- * @nr_sectors: number of sectors to end I/O on
- *
- * Description:
- * Ends I/O on a number of sectors attached to @req, and sets it up
- * for the next range of segments (if any) in the cluster.
- *
- * Return:
- * 0 - we are done with this request, call end_that_request_last()
- * 1 - still buffers pending for this request
- **/
-int end_that_request_first(struct request *req, int uptodate, int nr_sectors)
-{
-   return __end_that_request_first(req, uptodate, nr_sectors << 9);
-}
-
-EXPORT_SYMBOL(end_that_request_first);
-
-/**
- * end_that_request_chunk - end I/O on a request
- * @req:  the request being processed
- * @uptodate: 1 for success, 0 for I/O error, < 0 for specific error
- * @nr_bytes: number of bytes to complete
- *
- * Description:
- * Ends I/O on a number of bytes attached to @req, and sets it up
- * for the next range of segments (if any). Like end_that_request_first(),
- * but deals with bytes instead of sectors.
- *
- * Return:
- * 0 - we are done with this request, call end_that_request_last()
- * 1 - still buffers pending for this request
- **/
-int end_that_request_chunk(struct request *req, int uptodate, int nr_bytes)
-{
-   return __end_that_request_first(req, uptodate, nr_bytes);
-}
-
-EXPORT_SYMBOL(end_that_request_chunk);
-
 /*
  * splice the completion data to a local structure and hand off to
  * process_completion_queue() to complete the requests
@@ -3648,7 +3619,7 @@ EXPORT_SYMBOL(blk_complete_request);
 /*
  * queue lock must be held
  */
-void end_that_request_last(struct request *req, int uptodate)
+static void end_that_request_last(struct request *req, int uptodate)
 {
struct gendisk *disk = req->rq_disk;
int error;
@@ -3683,8 +3654,6 @@ void end_that_request_last(struct reques
__blk_put_request(req->q, req);
 }
 
-EXPORT_SYMBOL(end_that_request_last);
-
 static inline void __end_request(struct request *rq, int uptodate,
 unsigned int nr_bytes)
 {
Index: 2.6.24-rc4/include/linux/blkdev.h
===
--- 2.6.24-rc4.orig/include/linux/blkdev.h
+++ 2.6.24-rc4/include/linux/blkdev.h
@@ -720,21 +720,18 @@ static inline void blk_run_address_space
 }
 
 /*
- * end_request() and friends. Must be called with the request queue spinlock
- * acquired. All functions called within end_request() _must_be_ atomic.
+ * blk_end_request() and friends.
+ * __blk_end_request() and end_request() must be called with
+ * the request queue spinlock acquired.
  *
  * Several drivers define their own end_request and call
- * end_that_request_first() and end_that_request_last()
- * for parts of the original function. This prevents
- * code duplication in drivers.
+ * blk_end_request() for parts of the original function.
+ * This prevents code duplication in drivers.
  */
 extern int blk_end_request(struct request *rq, int error, int nr_bytes);
 extern int __blk_end_request(struct request *rq, int error, int nr_bytes);
 extern int blk_end_bidi_request(struct request *rq, int error, int nr_bytes,
int bidi_bytes);
-extern int end_that_request_first(struct request *, int, int);
-extern int end_that_request_chunk(struct request *, int, int);
-extern void end_that_request_last(struct request *, int);

[PATCH 27/30] blk_end_request: changing scsi (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch converts scsi mid-layer to use blk_end_request interfaces.
Related 'uptodate' arguments are converted to 'error'.

As a result, the interface of internal function, scsi_end_request(),
is changed.

Cc: James Bottomley <[EMAIL PROTECTED]>
Cc: Boaz Harrosh <[EMAIL PROTECTED]>
Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 drivers/scsi/scsi_lib.c |   31 +++
 1 files changed, 11 insertions(+), 20 deletions(-)

Index: 2.6.24-rc4/drivers/scsi/scsi_lib.c
===
--- 2.6.24-rc4.orig/drivers/scsi/scsi_lib.c
+++ 2.6.24-rc4/drivers/scsi/scsi_lib.c
@@ -632,7 +632,7 @@ void scsi_run_host_queues(struct Scsi_Ho
  * of upper level post-processing and scsi_io_completion).
  *
  * Arguments:   cmd - command that is complete.
- *  uptodate - 1 if I/O indicates success, <= 0 for I/O error.
+ *  error- 0 if I/O indicates success, < 0 for I/O error.
  *  bytes- number of bytes of completed I/O
  * requeue  - indicates whether we should requeue leftovers.
  *
@@ -647,26 +647,25 @@ void scsi_run_host_queues(struct Scsi_Ho
  * at some point during this call.
  * Notes:  If cmd was requeued, upon return it will be a stale pointer.
  */
-static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int uptodate,
+static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int error,
  int bytes, int requeue)
 {
struct request_queue *q = cmd->device->request_queue;
struct request *req = cmd->request;
-   unsigned long flags;
 
/*
 * If there are blocks left over at the end, set up the command
 * to queue the remainder of them.
 */
-   if (end_that_request_chunk(req, uptodate, bytes)) {
+   if (blk_end_request(req, error, bytes)) {
int leftover = (req->hard_nr_sectors << 9);
 
if (blk_pc_request(req))
leftover = req->data_len;
 
/* kill remainder if no retrys */
-   if (!uptodate && blk_noretry_request(req))
-   end_that_request_chunk(req, 0, leftover);
+   if (error && blk_noretry_request(req))
+   blk_end_request(req, error, leftover);
else {
if (requeue) {
/*
@@ -681,14 +680,6 @@ static struct scsi_cmnd *scsi_end_reques
}
}
 
-   add_disk_randomness(req->rq_disk);
-
-   spin_lock_irqsave(q->queue_lock, flags);
-   if (blk_rq_tagged(req))
-   blk_queue_end_tag(q, req);
-   end_that_request_last(req, uptodate);
-   spin_unlock_irqrestore(q->queue_lock, flags);
-
/*
 * This will goose the queue request function at the end, so we don't
 * need to worry about launching another command.
@@ -985,7 +976,7 @@ void scsi_io_completion(struct scsi_cmnd
 * are leftovers and there is some kind of error
 * (result != 0), retry the rest.
 */
-   if (scsi_end_request(cmd, 1, good_bytes, result == 0) == NULL)
+   if (scsi_end_request(cmd, 0, good_bytes, result == 0) == NULL)
return;
 
/* good_bytes = 0, or (inclusive) there were leftovers and
@@ -999,7 +990,7 @@ void scsi_io_completion(struct scsi_cmnd
 * and quietly refuse further access.
 */
cmd->device->changed = 1;
-   scsi_end_request(cmd, 0, this_count, 1);
+   scsi_end_request(cmd, -EIO, this_count, 1);
return;
} else {
/* Must have been a power glitch, or a
@@ -1031,7 +1022,7 @@ void scsi_io_completion(struct scsi_cmnd
scsi_requeue_command(q, cmd);
return;
} else {
-   scsi_end_request(cmd, 0, this_count, 1);
+   scsi_end_request(cmd, -EIO, this_count, 1);
return;
}
break;
@@ -1059,7 +1050,7 @@ void scsi_io_completion(struct scsi_cmnd
 "Device not ready",
 &sshdr);
 
-   scsi_end_request(cmd, 0, this_count, 1);
+   scsi_end_request(cmd, -EIO, this_count, 1);
return;
case VOLUME_OVERFLOW:
if (!(req->cmd_flags & REQ_QUIET)) {
@@ -1069,7 +1060,7 @@ void scsi_io_completion(struct scsi_cmnd
scsi_print_sense("", cmd);

Re: [stable] [PATCH -stable] libata: kill spurious NCQ completion detection

2007-12-11 Thread Greg KH
On Sat, Dec 08, 2007 at 09:25:31AM +0900, Tejun Heo wrote:
> Spurious NCQ completion detection implemented in ahci was incorrect.
> On AHCI receving and processing FISes and raising interrupts are not
> interlocked and spurious interrupts are expected.
> 
> For example, if an interrupt occurs while interrupt handler is running
> and the running interrupt handler handles the event the new IRQ
> indicated, after IRQ handler finishes, it will be executed again
> because IRQ pending bit is set by the new interrupt but there won't be
> anything to process.
> 
> Please read the following message for more information.
> 
>   http://article.gmane.org/gmane.linux.ide/26012
> 
> This patch...

Is this already in Linus's tree?  Is this for 2.6.23-stable, and/or
older ones too?

thanks,

greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 26/30] blk_end_request: add bidi completion interface (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch adds a variant of the interface, blk_end_bidi_request(),
which completes a bidi request.

Bidi request must be completed as a whole, both rq and rq->next_rq
at once.  So the interface has 2 arguments for completion size.

As for ->end_io, only rq->end_io is called (rq->next_rq->end_io is not
called).  So if special completion handling is needed, the handler
must be set to rq->end_io.
And the handler must take care of freeing next_rq too, since
the interface doesn't care of it if rq->end_io is not NULL.

Cc: Boaz Harrosh <[EMAIL PROTECTED]>
Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 block/ll_rw_blk.c  |   40 +++-
 include/linux/blkdev.h |2 ++
 2 files changed, 37 insertions(+), 5 deletions(-)

Index: 2.6.24-rc4/block/ll_rw_blk.c
===
--- 2.6.24-rc4.orig/block/ll_rw_blk.c
+++ 2.6.24-rc4/block/ll_rw_blk.c
@@ -3799,6 +3799,9 @@ static void complete_request(struct requ
if (blk_queued_rq(rq))
blkdev_dequeue_request(rq);
 
+   if (blk_bidi_rq(rq) && !rq->end_io)
+   __blk_put_request(rq->next_rq->q, rq->next_rq);
+
end_that_request_last(rq, uptodate);
 }
 
@@ -3806,14 +3809,15 @@ static void complete_request(struct requ
  * blk_end_io - Generic end_io function to complete a request.
  * @rq:   the request being processed
  * @error:0 for success, < 0 for error
- * @nr_bytes: number of bytes to complete
+ * @nr_bytes: number of bytes to complete @rq
+ * @bidi_bytes:   number of bytes to complete @rq->next_rq
  * @drv_callback: function called between completion of bios in the request
  *and completion of the request.
  *If the callback returns non 0, this helper returns without
  *completion of the request.
  *
  * Description:
- * Ends I/O on a number of bytes attached to @rq.
+ * Ends I/O on a number of bytes attached to @rq and @rq->next_rq.
  * If @rq has leftover, sets it up for the next range of segments.
  *
  * Return:
@@ -3821,7 +3825,7 @@ static void complete_request(struct requ
  * 1 - this request is not freed yet, it still has pending buffers.
  **/
 static int blk_end_io(struct request *rq, int error, int nr_bytes,
- int (drv_callback)(struct request *))
+ int bidi_bytes, int (drv_callback)(struct request *))
 {
struct request_queue *q = rq->q;
unsigned long flags = 0UL;
@@ -3836,6 +3840,11 @@ static int blk_end_io(struct request *rq
if (blk_fs_request(rq) || blk_pc_request(rq)) {
if (__end_that_request_first(rq, uptodate, nr_bytes))
return 1;
+
+   /* Bidi request must be completed as a whole */
+   if (blk_bidi_rq(rq) &&
+   __end_that_request_first(rq->next_rq, uptodate, bidi_bytes))
+   return 1;
}
 
/* Special feature for tricky drivers */
@@ -3867,7 +3876,7 @@ static int blk_end_io(struct request *rq
  **/
 int blk_end_request(struct request *rq, int error, int nr_bytes)
 {
-   return blk_end_io(rq, error, nr_bytes, NULL);
+   return blk_end_io(rq, error, nr_bytes, 0, NULL);
 }
 EXPORT_SYMBOL_GPL(blk_end_request);
 
@@ -3908,6 +3917,27 @@ int __blk_end_request(struct request *rq
 EXPORT_SYMBOL_GPL(__blk_end_request);
 
 /**
+ * blk_end_bidi_request - Helper function for drivers to complete bidi request.
+ * @rq: the bidi request being processed
+ * @error:  0 for success, < 0 for error
+ * @nr_bytes:   number of bytes to complete @rq
+ * @bidi_bytes: number of bytes to complete @rq->next_rq
+ *
+ * Description:
+ * Ends I/O on a number of bytes attached to @rq and @rq->next_rq.
+ *
+ * Return:
+ * 0 - we are done with this request
+ * 1 - still buffers pending for this request
+ **/
+int blk_end_bidi_request(struct request *rq, int error, int nr_bytes,
+int bidi_bytes)
+{
+   return blk_end_io(rq, error, nr_bytes, bidi_bytes, NULL);
+}
+EXPORT_SYMBOL_GPL(blk_end_bidi_request);
+
+/**
  * blk_end_request_callback - Special helper function for tricky drivers
  * @rq:   the request being processed
  * @error:0 for success, < 0 for error
@@ -3935,7 +3965,7 @@ EXPORT_SYMBOL_GPL(__blk_end_request);
 int blk_end_request_callback(struct request *rq, int error, int nr_bytes,
 int (drv_callback)(struct request *))
 {
-   return blk_end_io(rq, error, nr_bytes, drv_callback);
+   return blk_end_io(rq, error, nr_bytes, 0, drv_callback);
 }
 EXPORT_SYMBOL_GPL(blk_end_request_callback);
 
Index: 2.6.24-rc4/include/linux/blkdev.h
===
--- 2.6.24-rc4.orig/include/linux/blkdev.h
+++ 2.6.24-rc4/include/linux/blkdev.h
@@ -730,6 +730,8 @@ static inline void 

[PATCH 25/30] blk_end_request: changing ide-cd (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch converts ide-cd (cdrom_newpc_intr()) to use blk_end_request
interfaces.  Related 'uptodate' arguments are converted to 'error'.

In PIO mode, ide-cd (cdrom_newpc_intr()) needs to defer
end_that_request_last() until the device clears DRQ_STAT and raises
an interrupt after end_that_request_first().
So blk_end_request() has to return without completing request
even if no leftover in the request.

ide-cd uses blk_end_request_callback() and a dummy callback function,
which just returns value '1', to tell blk_end_request_callback()
about that.

Cc: Bartlomiej Zolnierkiewicz <[EMAIL PROTECTED]>
Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 drivers/ide/ide-cd.c |   49 +++--
 1 files changed, 35 insertions(+), 14 deletions(-)

Index: 2.6.24-rc4/drivers/ide/ide-cd.c
===
--- 2.6.24-rc4.orig/drivers/ide/ide-cd.c
+++ 2.6.24-rc4/drivers/ide/ide-cd.c
@@ -1650,6 +1650,17 @@ static int cdrom_write_check_ireason(ide
return 1;
 }
 
+/*
+ * Called from blk_end_request_callback() after the data of the request
+ * is completed and before the request is completed.
+ * By returning value '1', blk_end_request_callback() returns immediately
+ * without completing the request.
+ */
+static int cdrom_newpc_intr_dummy_cb(struct request *rq)
+{
+   return 1;
+}
+
 typedef void (xfer_func_t)(ide_drive_t *, void *, u32);
 
 /*
@@ -1688,9 +1699,13 @@ static ide_startstop_t cdrom_newpc_intr(
return ide_error(drive, "dma error", stat);
}
 
-   end_that_request_chunk(rq, 1, rq->data_len);
-   rq->data_len = 0;
-   goto end_request;
+   spin_lock_irqsave(&ide_lock, flags);
+   if (__blk_end_request(rq, 0, rq->data_len))
+   BUG();
+   HWGROUP(drive)->rq = NULL;
+   spin_unlock_irqrestore(&ide_lock, flags);
+
+   return ide_stopped;
}
 
/*
@@ -1708,8 +1723,15 @@ static ide_startstop_t cdrom_newpc_intr(
/*
 * If DRQ is clear, the command has completed.
 */
-   if ((stat & DRQ_STAT) == 0)
-   goto end_request;
+   if ((stat & DRQ_STAT) == 0) {
+   spin_lock_irqsave(&ide_lock, flags);
+   if (__blk_end_request(rq, 0, 0))
+   BUG();
+   HWGROUP(drive)->rq = NULL;
+   spin_unlock_irqrestore(&ide_lock, flags);
+
+   return ide_stopped;
+   }
 
/*
 * check which way to transfer data
@@ -1762,7 +1784,14 @@ static ide_startstop_t cdrom_newpc_intr(
rq->data_len -= blen;
 
if (rq->bio)
-   end_that_request_chunk(rq, 1, blen);
+   /*
+* The request can't be completed until DRQ is cleared.
+* So complete the data, but don't complete the request
+* using the dummy function for the callback feature
+* of blk_end_request_callback().
+*/
+   blk_end_request_callback(rq, 0, blen,
+cdrom_newpc_intr_dummy_cb);
else
rq->data += blen;
}
@@ -1783,14 +1812,6 @@ static ide_startstop_t cdrom_newpc_intr(
 
ide_set_handler(drive, cdrom_newpc_intr, rq->timeout, NULL);
return ide_started;
-
-end_request:
-   spin_lock_irqsave(&ide_lock, flags);
-   blkdev_dequeue_request(rq);
-   end_that_request_last(rq, 1);
-   HWGROUP(drive)->rq = NULL;
-   spin_unlock_irqrestore(&ide_lock, flags);
-   return ide_stopped;
 }
 
 static ide_startstop_t cdrom_write_intr(ide_drive_t *drive)
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 22/30] blk_end_request: changing cpqarray (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch converts cpqarray to use blk_end_request interfaces.
Related 'ok' arguments are converted to 'error'.

cpqarray is a little bit different from "normal" drivers.
cpqarray directly calls bio_endio() and disk_stat_add()
when completing request.  But those can be replaced with
__end_that_request_first().
After the replacement, request completion procedures of
those drivers become like the following:
o end_that_request_first()
o add_disk_randomness()
o end_that_request_last()
This can be converted to __blk_end_request() by following
the rule (b) mentioned in the patch subject
"[PATCH 01/30] blk_end_request: add new request completion interface".

Cc: Mike Miller <[EMAIL PROTECTED]>
Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 drivers/block/cpqarray.c |   36 +++-
 1 files changed, 7 insertions(+), 29 deletions(-)

Index: 2.6.24-rc4/drivers/block/cpqarray.c
===
--- 2.6.24-rc4.orig/drivers/block/cpqarray.c
+++ 2.6.24-rc4/drivers/block/cpqarray.c
@@ -167,7 +167,6 @@ static void start_io(ctlr_info_t *h);
 
 static inline void addQ(cmdlist_t **Qptr, cmdlist_t *c);
 static inline cmdlist_t *removeQ(cmdlist_t **Qptr, cmdlist_t *c);
-static inline void complete_buffers(struct bio *bio, int ok);
 static inline void complete_command(cmdlist_t *cmd, int timeout);
 
 static irqreturn_t do_ida_intr(int irq, void *dev_id);
@@ -980,26 +979,13 @@ static void start_io(ctlr_info_t *h)
}
 }
 
-static inline void complete_buffers(struct bio *bio, int ok)
-{
-   struct bio *xbh;
-
-   while (bio) {
-   xbh = bio->bi_next;
-   bio->bi_next = NULL;
-   
-   bio_endio(bio, ok ? 0 : -EIO);
-
-   bio = xbh;
-   }
-}
 /*
  * Mark all buffers that cmd was responsible for
  */
 static inline void complete_command(cmdlist_t *cmd, int timeout)
 {
struct request *rq = cmd->rq;
-   int ok=1;
+   int error = 0;
int i, ddir;
 
if (cmd->req.hdr.rcode & RCODE_NONFATAL &&
@@ -1011,16 +997,17 @@ static inline void complete_command(cmdl
if (cmd->req.hdr.rcode & RCODE_FATAL) {
printk(KERN_WARNING "Fatal error on ida/c%dd%d\n",
cmd->ctlr, cmd->hdr.unit);
-   ok = 0;
+   error = -EIO;
}
if (cmd->req.hdr.rcode & RCODE_INVREQ) {
printk(KERN_WARNING "Invalid request on 
ida/c%dd%d = (cmd=%x sect=%d cnt=%d sg=%d ret=%x)\n",
cmd->ctlr, cmd->hdr.unit, cmd->req.hdr.cmd,
cmd->req.hdr.blk, cmd->req.hdr.blk_cnt,
cmd->req.hdr.sg_cnt, cmd->req.hdr.rcode);
-   ok = 0; 
+   error = -EIO;
}
-   if (timeout) ok = 0;
+   if (timeout)
+   error = -EIO;
/* unmap the DMA mapping for all the scatter gather elements */
if (cmd->req.hdr.cmd == IDA_READ)
ddir = PCI_DMA_FROMDEVICE;
@@ -1030,18 +1017,9 @@ static inline void complete_command(cmdl
 pci_unmap_page(hba[cmd->ctlr]->pci_dev, cmd->req.sg[i].addr,
cmd->req.sg[i].size, ddir);
 
-   complete_buffers(rq->bio, ok);
-
-   if (blk_fs_request(rq)) {
-   const int rw = rq_data_dir(rq);
-
-   disk_stat_add(rq->rq_disk, sectors[rw], rq->nr_sectors);
-   }
-
-   add_disk_randomness(rq->rq_disk);
-
DBGPX(printk("Done with %p\n", rq););
-   end_that_request_last(rq, ok ? 1 : -EIO);
+   if (__blk_end_request(rq, error, blk_rq_bytes(rq)))
+   BUG();
 }
 
 /*
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 24/30] blk_end_request: add callback feature (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch adds a variant of the interface, blk_end_request_callback(),
which has driver callback feature.

Drivers may need to do special works between end_that_request_first()
and end_that_request_last().
For such drivers, blk_end_request_callback() allows it to pass
a callback function which is called between end_that_request_first()
and end_that_request_last().

This interface is only for fallback of other blk_end_request interfaces.
Drivers should avoid their tricky behaviors and use other interfaces
as much as possible.

Currently, only one driver, ide-cd, needs this interface.
So this interface should/will be removed, after the driver removes
such tricky behaviors.

o ide-cd (cdrom_newpc_intr())
  In PIO mode, cdrom_newpc_intr() needs to defer end_that_request_last()
  until the device clears DRQ_STAT and raises an interrupt after
  end_that_request_first().
  So end_that_request_first() and end_that_request_last() are called
  separately in cdrom_newpc_intr().

  This means blk_end_request_callback() has to return without
  completing request even if no leftover in the request.
  To satisfy the requirement, callback function has return value
  so that drivers can tell blk_end_request_callback() to return
  without completing request.

Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 block/ll_rw_blk.c  |   72 -
 include/linux/blkdev.h |2 +
 2 files changed, 68 insertions(+), 6 deletions(-)

Index: 2.6.24-rc4/block/ll_rw_blk.c
===
--- 2.6.24-rc4.orig/block/ll_rw_blk.c
+++ 2.6.24-rc4/block/ll_rw_blk.c
@@ -3803,10 +3803,14 @@ static void complete_request(struct requ
 }
 
 /**
- * blk_end_request - Helper function for drivers to complete the request.
- * @rq:   the request being processed
- * @error:0 for success, < 0 for error
- * @nr_bytes: number of bytes to complete
+ * blk_end_io - Generic end_io function to complete a request.
+ * @rq:   the request being processed
+ * @error:0 for success, < 0 for error
+ * @nr_bytes: number of bytes to complete
+ * @drv_callback: function called between completion of bios in the request
+ *and completion of the request.
+ *If the callback returns non 0, this helper returns without
+ *completion of the request.
  *
  * Description:
  * Ends I/O on a number of bytes attached to @rq.
@@ -3814,9 +3818,10 @@ static void complete_request(struct requ
  *
  * Return:
  * 0 - we are done with this request
- * 1 - still buffers pending for this request
+ * 1 - this request is not freed yet, it still has pending buffers.
  **/
-int blk_end_request(struct request *rq, int error, int nr_bytes)
+static int blk_end_io(struct request *rq, int error, int nr_bytes,
+ int (drv_callback)(struct request *))
 {
struct request_queue *q = rq->q;
unsigned long flags = 0UL;
@@ -3833,6 +3838,10 @@ int blk_end_request(struct request *rq, 
return 1;
}
 
+   /* Special feature for tricky drivers */
+   if (drv_callback && drv_callback(rq))
+   return 1;
+
add_disk_randomness(rq->rq_disk);
 
spin_lock_irqsave(q->queue_lock, flags);
@@ -3841,6 +3850,25 @@ int blk_end_request(struct request *rq, 
 
return 0;
 }
+
+/**
+ * blk_end_request - Helper function for drivers to complete the request.
+ * @rq:   the request being processed
+ * @error:0 for success, < 0 for error
+ * @nr_bytes: number of bytes to complete
+ *
+ * Description:
+ * Ends I/O on a number of bytes attached to @rq.
+ * If @rq has leftover, sets it up for the next range of segments.
+ *
+ * Return:
+ * 0 - we are done with this request
+ * 1 - still buffers pending for this request
+ **/
+int blk_end_request(struct request *rq, int error, int nr_bytes)
+{
+   return blk_end_io(rq, error, nr_bytes, NULL);
+}
 EXPORT_SYMBOL_GPL(blk_end_request);
 
 /**
@@ -3879,6 +3907,38 @@ int __blk_end_request(struct request *rq
 }
 EXPORT_SYMBOL_GPL(__blk_end_request);
 
+/**
+ * blk_end_request_callback - Special helper function for tricky drivers
+ * @rq:   the request being processed
+ * @error:0 for success, < 0 for error
+ * @nr_bytes: number of bytes to complete
+ * @drv_callback: function called between completion of bios in the request
+ *and completion of the request.
+ *If the callback returns non 0, this helper returns without
+ *completion of the request.
+ *
+ * Description:
+ * Ends I/O on a number of bytes attached to @rq.
+ * If @rq has leftover, sets it up for the next range of segments.
+ *
+ * This special helper function is used only for existing tricky drivers.
+ * (e.g. cdrom_newpc_intr() of ide-cd)
+ * This interface will be removed wh

[PATCH 23/30] blk_end_request: changing ide normal caller (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch converts "normal" parts of ide to use blk_end_request
interfaces.  Related 'uptodate' arguments are converted to 'error'.

The conversion of 'uptodate' to 'error' is done only for the internal
function, __ide_end_request().
ide_end_request() was not changed since it's exported and used
by many ide drivers.


With this patch, blkdev_dequeue_request() in __ide_end_request() is
moved to blk_end_request, since blk_end_request takes care of
dequeueing request like below:

if (!list_empty(&rq->queuelist))
blkdev_dequeue_request(rq);

In the case of ide,
  o 'dequeue' variable of __ide_end_request() is 1 only when the request
is still linked to the queue (i.e. rq->queuelist is not empty)
  o 'dequeue' variable of __ide_end_request() is 0 only when the request
has already been removed from the queue (i.e. rq->queuelist is empty)
So blk_end_request can handle it correctly although ide always run
thought the code above.

Cc: Bartlomiej Zolnierkiewicz <[EMAIL PROTECTED]>
Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 drivers/ide/ide-cd.c |6 +++---
 drivers/ide/ide-io.c |   25 -
 2 files changed, 15 insertions(+), 16 deletions(-)

Index: 2.6.24-rc4/drivers/ide/ide-cd.c
===
--- 2.6.24-rc4.orig/drivers/ide/ide-cd.c
+++ 2.6.24-rc4/drivers/ide/ide-cd.c
@@ -655,9 +655,9 @@ static void cdrom_end_request (ide_drive
BUG();
} else {
spin_lock_irqsave(&ide_lock, flags);
-   end_that_request_chunk(failed, 0,
-   failed->data_len);
-   end_that_request_last(failed, 0);
+   if (__blk_end_request(failed, -EIO,
+ failed->data_len))
+   BUG();
spin_unlock_irqrestore(&ide_lock, flags);
}
} else
Index: 2.6.24-rc4/drivers/ide/ide-io.c
===
--- 2.6.24-rc4.orig/drivers/ide/ide-io.c
+++ 2.6.24-rc4/drivers/ide/ide-io.c
@@ -58,15 +58,19 @@ static int __ide_end_request(ide_drive_t
 int uptodate, unsigned int nr_bytes, int dequeue)
 {
int ret = 1;
+   int error = 0;
+
+   if (uptodate <= 0)
+   error = uptodate ? uptodate : -EIO;
 
/*
 * if failfast is set on a request, override number of sectors and
 * complete the whole request right now
 */
-   if (blk_noretry_request(rq) && end_io_error(uptodate))
+   if (blk_noretry_request(rq) && error)
nr_bytes = rq->hard_nr_sectors << 9;
 
-   if (!blk_fs_request(rq) && end_io_error(uptodate) && !rq->errors)
+   if (!blk_fs_request(rq) && error && !rq->errors)
rq->errors = -EIO;
 
/*
@@ -78,14 +82,9 @@ static int __ide_end_request(ide_drive_t
HWGROUP(drive)->hwif->ide_dma_on(drive);
}
 
-   if (!end_that_request_chunk(rq, uptodate, nr_bytes)) {
-   add_disk_randomness(rq->rq_disk);
-   if (dequeue) {
-   if (!list_empty(&rq->queuelist))
-   blkdev_dequeue_request(rq);
+   if (!__blk_end_request(rq, error, nr_bytes)) {
+   if (dequeue)
HWGROUP(drive)->rq = NULL;
-   }
-   end_that_request_last(rq, uptodate);
ret = 0;
}
 
@@ -292,9 +291,9 @@ static void ide_complete_pm_request (ide
drive->blocked = 0;
blk_start_queue(drive->queue);
}
-   blkdev_dequeue_request(rq);
HWGROUP(drive)->rq = NULL;
-   end_that_request_last(rq, 1);
+   if (__blk_end_request(rq, 0, 0))
+   BUG();
spin_unlock_irqrestore(&ide_lock, flags);
 }
 
@@ -391,10 +390,10 @@ void ide_end_drive_cmd (ide_drive_t *dri
}
 
spin_lock_irqsave(&ide_lock, flags);
-   blkdev_dequeue_request(rq);
HWGROUP(drive)->rq = NULL;
rq->errors = err;
-   end_that_request_last(rq, !rq->errors);
+   if (__blk_end_request(rq, (rq->errors ? -EIO : 0), 0))
+   BUG();
spin_unlock_irqrestore(&ide_lock, flags);
 }
 
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 20/30] blk_end_request: changing xsysace (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch converts xsysace to use blk_end_request interfaces.
Related 'uptodate' arguments are converted to 'error'.

xsysace is a little bit different from "normal" drivers.
xsysace driver has a state machine in it.
It calls end_that_request_first() and end_that_request_last()
from different states. (ACE_FSM_STATE_REQ_TRANSFER and
ACE_FSM_STATE_REQ_COMPLETE, respectively.)

However, those states are consecutive and without any interruption
inbetween.
So we can just follow the standard conversion rule (b) mentioned in
the patch subject "[PATCH 01/30] blk_end_request: add new request
completion interface".

Cc: Grant Likely <[EMAIL PROTECTED]>
Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 drivers/block/xsysace.c |5 +
 1 files changed, 1 insertion(+), 4 deletions(-)

Index: 2.6.24-rc4/drivers/block/xsysace.c
===
--- 2.6.24-rc4.orig/drivers/block/xsysace.c
+++ 2.6.24-rc4/drivers/block/xsysace.c
@@ -703,7 +703,7 @@ static void ace_fsm_dostate(struct ace_d
 
/* bio finished; is there another one? */
i = ace->req->current_nr_sectors;
-   if (end_that_request_first(ace->req, 1, i)) {
+   if (__blk_end_request(ace->req, 0, i)) {
/* dev_dbg(ace->dev, "next block; h=%li c=%i\n",
 *  ace->req->hard_nr_sectors,
 *  ace->req->current_nr_sectors);
@@ -718,9 +718,6 @@ static void ace_fsm_dostate(struct ace_d
break;
 
case ACE_FSM_STATE_REQ_COMPLETE:
-   /* Complete the block request */
-   blkdev_dequeue_request(ace->req);
-   end_that_request_last(ace->req, 1);
ace->req = NULL;
 
/* Finished request; go to idle state */
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 21/30] blk_end_request: changing cciss (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch converts cciss to use blk_end_request interfaces.
Related 'uptodate' arguments are converted to 'error'.

cciss is a little bit different from "normal" drivers.
cciss directly calls bio_endio() and disk_stat_add()
when completing request.  But those can be replaced with
__end_that_request_first().
After the replacement, request completion procedures of
those drivers become like the following:
o end_that_request_first()
o add_disk_randomness()
o end_that_request_last()
This can be converted to blk_end_request() by following
the rule (a) mentioned in the patch subject
"[PATCH 01/30] blk_end_request: add new request completion interface".

Cc: Mike Miller <[EMAIL PROTECTED]>
Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 drivers/block/cciss.c |   25 +++--
 1 files changed, 3 insertions(+), 22 deletions(-)

Index: 2.6.24-rc4/drivers/block/cciss.c
===
--- 2.6.24-rc4.orig/drivers/block/cciss.c
+++ 2.6.24-rc4/drivers/block/cciss.c
@@ -1187,17 +1187,6 @@ static int cciss_ioctl(struct inode *ino
}
 }
 
-static inline void complete_buffers(struct bio *bio, int status)
-{
-   while (bio) {
-   struct bio *xbh = bio->bi_next;
-
-   bio->bi_next = NULL;
-   bio_endio(bio, status ? 0 : -EIO);
-   bio = xbh;
-   }
-}
-
 static void cciss_check_queues(ctlr_info_t *h)
 {
int start_queue = h->next_to_run;
@@ -1263,21 +1252,14 @@ static void cciss_softirq_done(struct re
pci_unmap_page(h->pdev, temp64.val, cmd->SG[i].Len, ddir);
}
 
-   complete_buffers(rq->bio, (rq->errors == 0));
-
-   if (blk_fs_request(rq)) {
-   const int rw = rq_data_dir(rq);
-
-   disk_stat_add(rq->rq_disk, sectors[rw], rq->nr_sectors);
-   }
-
 #ifdef CCISS_DEBUG
printk("Done with %p\n", rq);
 #endif /* CCISS_DEBUG */
 
-   add_disk_randomness(rq->rq_disk);
+   if (blk_end_request(rq, (rq->errors == 0) ? 0 : -EIO, blk_rq_bytes(rq)))
+   BUG();
+
spin_lock_irqsave(&h->lock, flags);
-   end_that_request_last(rq, (rq->errors == 0));
cmd_free(h, cmd, 1);
cciss_check_queues(h);
spin_unlock_irqrestore(&h->lock, flags);
@@ -2544,7 +2526,6 @@ after_error_processing:
}
cmd->rq->data_len = 0;
cmd->rq->completion_data = cmd;
-   blk_add_trace_rq(cmd->rq->q, cmd->rq, BLK_TA_COMPLETE);
blk_complete_request(cmd->rq);
 }
 
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 19/30] blk_end_request: changing ide-scsi (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch converts ide-scsi to use blk_end_request interfaces.
Related 'uptodate' arguments are converted to 'error'.

Cc: Bartlomiej Zolnierkiewicz <[EMAIL PROTECTED]>
Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 drivers/scsi/ide-scsi.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

Index: 2.6.24-rc4/drivers/scsi/ide-scsi.c
===
--- 2.6.24-rc4.orig/drivers/scsi/ide-scsi.c
+++ 2.6.24-rc4/drivers/scsi/ide-scsi.c
@@ -921,8 +921,8 @@ static int idescsi_eh_reset (struct scsi
}
 
/* kill current request */
-   blkdev_dequeue_request(req);
-   end_that_request_last(req, 0);
+   if (__blk_end_request(req, -EIO, 0))
+   BUG();
if (blk_sense_request(req))
kfree(scsi->pc->buffer);
kfree(scsi->pc);
@@ -931,8 +931,8 @@ static int idescsi_eh_reset (struct scsi
 
/* now nuke the drive queue */
while ((req = elv_next_request(drive->queue))) {
-   blkdev_dequeue_request(req);
-   end_that_request_last(req, 0);
+   if (__blk_end_request(req, -EIO, 0))
+   BUG();
}
 
HWGROUP(drive)->rq = NULL;
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 18/30] blk_end_request: changing s390 (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch converts s390 to use blk_end_request interfaces.
Related 'uptodate' arguments are converted to 'error'.

As a result, the interfaces of internal functions below are changed:
  o dasd_end_request
  o tapeblock_end_request

Cc: Martin Schwidefsky <[EMAIL PROTECTED]>
Cc: Heiko Carstens <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 drivers/s390/block/dasd.c  |   19 ++-
 drivers/s390/char/tape_block.c |   13 ++---
 2 files changed, 16 insertions(+), 16 deletions(-)

Index: 2.6.24-rc4/drivers/s390/block/dasd.c
===
--- 2.6.24-rc4.orig/drivers/s390/block/dasd.c
+++ 2.6.24-rc4/drivers/s390/block/dasd.c
@@ -1078,12 +1078,10 @@ dasd_int_handler(struct ccw_device *cdev
  * posts the buffer_cache about a finalized request
  */
 static inline void
-dasd_end_request(struct request *req, int uptodate)
+dasd_end_request(struct request *req, int error)
 {
-   if (end_that_request_first(req, uptodate, req->hard_nr_sectors))
+   if (__blk_end_request(req, error, blk_rq_bytes(req)))
BUG();
-   add_disk_randomness(req->rq_disk);
-   end_that_request_last(req, uptodate);
 }
 
 /*
@@ -1170,13 +1168,16 @@ dasd_end_request_cb(struct dasd_ccw_req 
struct request *req;
struct dasd_device *device;
int status;
+   int error = 0;
 
req = (struct request *) data;
device = cqr->device;
dasd_profile_end(device, cqr, req);
status = cqr->device->discipline->free_cp(cqr,req);
+   if (status <= 0)
+   error = status ? status : -EIO;
spin_lock_irq(&device->request_queue_lock);
-   dasd_end_request(req, status);
+   dasd_end_request(req, error);
spin_unlock_irq(&device->request_queue_lock);
 }
 
@@ -1223,12 +1224,12 @@ __dasd_process_blk_queue(struct dasd_dev
  "Rejecting write request %p",
  req);
blkdev_dequeue_request(req);
-   dasd_end_request(req, 0);
+   dasd_end_request(req, -EIO);
continue;
}
if (device->stopped & DASD_STOPPED_DC_EIO) {
blkdev_dequeue_request(req);
-   dasd_end_request(req, 0);
+   dasd_end_request(req, -EIO);
continue;
}
cqr = device->discipline->build_cp(device, req);
@@ -1253,7 +1254,7 @@ __dasd_process_blk_queue(struct dasd_dev
  "on request %p",
  PTR_ERR(cqr), req);
blkdev_dequeue_request(req);
-   dasd_end_request(req, 0);
+   dasd_end_request(req, -EIO);
continue;
}
cqr->callback = dasd_end_request_cb;
@@ -1821,7 +1822,7 @@ dasd_flush_request_queue(struct dasd_dev
spin_lock_irq(&device->request_queue_lock);
while ((req = elv_next_request(device->request_queue))) {
blkdev_dequeue_request(req);
-   dasd_end_request(req, 0);
+   dasd_end_request(req, -EIO);
}
spin_unlock_irq(&device->request_queue_lock);
 }
Index: 2.6.24-rc4/drivers/s390/char/tape_block.c
===
--- 2.6.24-rc4.orig/drivers/s390/char/tape_block.c
+++ 2.6.24-rc4/drivers/s390/char/tape_block.c
@@ -74,11 +74,10 @@ tapeblock_trigger_requeue(struct tape_de
  * Post finished request.
  */
 static void
-tapeblock_end_request(struct request *req, int uptodate)
+tapeblock_end_request(struct request *req, int error)
 {
-   if (end_that_request_first(req, uptodate, req->hard_nr_sectors))
+   if (__blk_end_request(req, error, blk_rq_bytes(req)))
BUG();
-   end_that_request_last(req, uptodate);
 }
 
 static void
@@ -91,7 +90,7 @@ __tapeblock_end_request(struct tape_requ
 
device = ccw_req->device;
req = (struct request *) data;
-   tapeblock_end_request(req, ccw_req->rc == 0);
+   tapeblock_end_request(req, (ccw_req->rc == 0) ? 0 : -EIO);
if (ccw_req->rc == 0)
/* Update position. */
device->blk_data.block_position =
@@ -119,7 +118,7 @@ tapeblock_start_request(struct tape_devi
ccw_req = device->discipline->bread(device, req);
if (IS_ERR(ccw_req)) {
DBF_EVENT(1, "TBLOCK: bread failed\n");
-   tapeblock_end_request(req, 0);
+   tapeblock_end_request(req, -EIO);
return PTR_ERR(ccw_req);
}
ccw_req->callback = __tapeblock_end_request;
@@ -132,7 +131,7 @@ tapeblock_start_request(struct tape_devi
 * Start/enqueueing failed. N

[PATCH 17/30] blk_end_request: changing mmc (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch converts mmc to use blk_end_request interfaces.
Related 'uptodate' arguments are converted to 'error'.

Cc: Pierre Ossman <[EMAIL PROTECTED]>
Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 drivers/mmc/card/block.c |   24 +---
 drivers/mmc/card/queue.c |4 ++--
 2 files changed, 7 insertions(+), 21 deletions(-)

Index: 2.6.24-rc4/drivers/mmc/card/block.c
===
--- 2.6.24-rc4.orig/drivers/mmc/card/block.c
+++ 2.6.24-rc4/drivers/mmc/card/block.c
@@ -348,15 +348,7 @@ static int mmc_blk_issue_rq(struct mmc_q
 * A block was successfully transferred.
 */
spin_lock_irq(&md->lock);
-   ret = end_that_request_chunk(req, 1, brq.data.bytes_xfered);
-   if (!ret) {
-   /*
-* The whole request completed successfully.
-*/
-   add_disk_randomness(req->rq_disk);
-   blkdev_dequeue_request(req);
-   end_that_request_last(req, 1);
-   }
+   ret = __blk_end_request(req, 0, brq.data.bytes_xfered);
spin_unlock_irq(&md->lock);
} while (ret);
 
@@ -386,27 +378,21 @@ static int mmc_blk_issue_rq(struct mmc_q
else
bytes = blocks << 9;
spin_lock_irq(&md->lock);
-   ret = end_that_request_chunk(req, 1, bytes);
+   ret = __blk_end_request(req, 0, bytes);
spin_unlock_irq(&md->lock);
}
} else if (rq_data_dir(req) != READ &&
   (card->host->caps & MMC_CAP_MULTIWRITE)) {
spin_lock_irq(&md->lock);
-   ret = end_that_request_chunk(req, 1, brq.data.bytes_xfered);
+   ret = __blk_end_request(req, 0, brq.data.bytes_xfered);
spin_unlock_irq(&md->lock);
}
 
mmc_release_host(card->host);
 
spin_lock_irq(&md->lock);
-   while (ret) {
-   ret = end_that_request_chunk(req, 0,
-   req->current_nr_sectors << 9);
-   }
-
-   add_disk_randomness(req->rq_disk);
-   blkdev_dequeue_request(req);
-   end_that_request_last(req, 0);
+   while (ret)
+   ret = __blk_end_request(req, -EIO, blk_rq_cur_bytes(req));
spin_unlock_irq(&md->lock);
 
return 0;
Index: 2.6.24-rc4/drivers/mmc/card/queue.c
===
--- 2.6.24-rc4.orig/drivers/mmc/card/queue.c
+++ 2.6.24-rc4/drivers/mmc/card/queue.c
@@ -94,8 +94,8 @@ static void mmc_request(struct request_q
printk(KERN_ERR "MMC: killing requests for dead queue\n");
while ((req = elv_next_request(q)) != NULL) {
do {
-   ret = end_that_request_chunk(req, 0,
-   req->current_nr_sectors << 9);
+   ret = __blk_end_request(req, -EIO,
+   blk_rq_cur_bytes(req));
} while (ret);
}
return;
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 15/30] blk_end_request: changing viocd (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch converts viocd to use blk_end_request interfaces.
Related 'uptodate' arguments are converted to 'error'.

As a result, the interface of internal function, viocd_end_request(),
is changed.

Cc: Stephen Rothwell <[EMAIL PROTECTED]>
Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 drivers/cdrom/viocd.c |   15 ++-
 1 files changed, 6 insertions(+), 9 deletions(-)

Index: 2.6.24-rc4/drivers/cdrom/viocd.c
===
--- 2.6.24-rc4.orig/drivers/cdrom/viocd.c
+++ 2.6.24-rc4/drivers/cdrom/viocd.c
@@ -289,7 +289,7 @@ static int send_request(struct request *
return 0;
 }
 
-static void viocd_end_request(struct request *req, int uptodate)
+static void viocd_end_request(struct request *req, int error)
 {
int nsectors = req->hard_nr_sectors;
 
@@ -302,11 +302,8 @@ static void viocd_end_request(struct req
if (!nsectors)
nsectors = 1;
 
-   if (end_that_request_first(req, uptodate, nsectors))
+   if (__blk_end_request(req, error, nsectors << 9))
BUG();
-   add_disk_randomness(req->rq_disk);
-   blkdev_dequeue_request(req);
-   end_that_request_last(req, uptodate);
 }
 
 static int rwreq;
@@ -317,11 +314,11 @@ static void do_viocd_request(struct requ
 
while ((rwreq == 0) && ((req = elv_next_request(q)) != NULL)) {
if (!blk_fs_request(req))
-   viocd_end_request(req, 0);
+   viocd_end_request(req, -EIO);
else if (send_request(req) < 0) {
printk(VIOCD_KERN_WARNING
"unable to send message to OS/400!");
-   viocd_end_request(req, 0);
+   viocd_end_request(req, -EIO);
} else
rwreq++;
}
@@ -532,9 +529,9 @@ return_complete:
"with rc %d:0x%04X: %s\n",
req, event->xRc,
bevent->sub_result, err->msg);
-   viocd_end_request(req, 0);
+   viocd_end_request(req, -EIO);
} else
-   viocd_end_request(req, 1);
+   viocd_end_request(req, 0);
 
/* restart handling of incoming requests */
spin_unlock_irqrestore(&viocd_reqlock, flags);
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/30] blk_end_request: changing xen-blkfront (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch converts xen-blkfront to use blk_end_request interfaces.
Related 'uptodate' arguments are converted to 'error'.

Cc: Jeremy Fitzhardinge <[EMAIL PROTECTED]>
Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 drivers/block/xen-blkfront.c |   10 --
 1 files changed, 4 insertions(+), 6 deletions(-)

Index: 2.6.24-rc4/drivers/block/xen-blkfront.c
===
--- 2.6.24-rc4.orig/drivers/block/xen-blkfront.c
+++ 2.6.24-rc4/drivers/block/xen-blkfront.c
@@ -452,7 +452,7 @@ static irqreturn_t blkif_interrupt(int i
RING_IDX i, rp;
unsigned long flags;
struct blkfront_info *info = (struct blkfront_info *)dev_id;
-   int uptodate;
+   int error;
 
spin_lock_irqsave(&blkif_io_lock, flags);
 
@@ -477,13 +477,13 @@ static irqreturn_t blkif_interrupt(int i
 
add_id_to_freelist(info, id);
 
-   uptodate = (bret->status == BLKIF_RSP_OKAY);
+   error = (bret->status == BLKIF_RSP_OKAY) ? 0 : -EIO;
switch (bret->operation) {
case BLKIF_OP_WRITE_BARRIER:
if (unlikely(bret->status == BLKIF_RSP_EOPNOTSUPP)) {
printk(KERN_WARNING "blkfront: %s: write 
barrier op failed\n",
   info->gd->disk_name);
-   uptodate = -EOPNOTSUPP;
+   error = -EOPNOTSUPP;
info->feature_barrier = 0;
xlvbd_barrier(info);
}
@@ -494,10 +494,8 @@ static irqreturn_t blkif_interrupt(int i
dev_dbg(&info->xbdev->dev, "Bad return from 
blkdev data "
"request: %x\n", bret->status);
 
-   ret = end_that_request_first(req, uptodate,
-   req->hard_nr_sectors);
+   ret = __blk_end_request(req, error, blk_rq_bytes(req));
BUG_ON(ret);
-   end_that_request_last(req, uptodate);
break;
default:
BUG();
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 16/30] blk_end_request: changing i2o_block (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch converts i2o_block to use blk_end_request interfaces.
Related 'uptodate' arguments are converted to 'error'.

As a result, the interface of internal function, i2o_block_end_request(),
is changed.

Cc: Markus Lidel <[EMAIL PROTECTED]>
Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 drivers/message/i2o/i2o_block.c |   20 
 1 files changed, 8 insertions(+), 12 deletions(-)

Index: 2.6.24-rc4/drivers/message/i2o/i2o_block.c
===
--- 2.6.24-rc4.orig/drivers/message/i2o/i2o_block.c
+++ 2.6.24-rc4/drivers/message/i2o/i2o_block.c
@@ -412,13 +412,13 @@ static void i2o_block_delayed_request_fn
 /**
  * i2o_block_end_request - Post-processing of completed commands
  * @req: request which should be completed
- * @uptodate: 1 for success, 0 for I/O error, < 0 for specific error
+ * @error: 0 for success, < 0 for error
  * @nr_bytes: number of bytes to complete
  *
  * Mark the request as complete. The lock must not be held when entering.
  *
  */
-static void i2o_block_end_request(struct request *req, int uptodate,
+static void i2o_block_end_request(struct request *req, int error,
  int nr_bytes)
 {
struct i2o_block_request *ireq = req->special;
@@ -426,22 +426,18 @@ static void i2o_block_end_request(struct
struct request_queue *q = req->q;
unsigned long flags;
 
-   if (end_that_request_chunk(req, uptodate, nr_bytes)) {
+   if (blk_end_request(req, error, nr_bytes)) {
int leftover = (req->hard_nr_sectors << KERNEL_SECTOR_SHIFT);
 
if (blk_pc_request(req))
leftover = req->data_len;
 
-   if (end_io_error(uptodate))
-   end_that_request_chunk(req, 0, leftover);
+   if (error)
+   blk_end_request(req, -EIO, leftover);
}
 
-   add_disk_randomness(req->rq_disk);
-
spin_lock_irqsave(q->queue_lock, flags);
 
-   end_that_request_last(req, uptodate);
-
if (likely(dev)) {
dev->open_queue_depth--;
list_del(&ireq->queue);
@@ -468,7 +464,7 @@ static int i2o_block_reply(struct i2o_co
   struct i2o_message *msg)
 {
struct request *req;
-   int uptodate = 1;
+   int error = 0;
 
req = i2o_cntxt_list_get(c, le32_to_cpu(msg->u.s.tcntxt));
if (unlikely(!req)) {
@@ -501,10 +497,10 @@ static int i2o_block_reply(struct i2o_co
 
req->errors++;
 
-   uptodate = 0;
+   error = -EIO;
}
 
-   i2o_block_end_request(req, uptodate, le32_to_cpu(msg->body[1]));
+   i2o_block_end_request(req, error, le32_to_cpu(msg->body[1]));
 
return 1;
 };
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/30] blk_end_request: changing viodasd (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch converts viodasd to use blk_end_request interfaces.
Related 'uptodate' arguments are converted to 'error'.

As a result, the interface of internal function, viodasd_end_request(),
is changed.

Cc: Stephen Rothwell <[EMAIL PROTECTED]>
Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 drivers/block/viodasd.c |   15 ++-
 1 files changed, 6 insertions(+), 9 deletions(-)

Index: 2.6.24-rc4/drivers/block/viodasd.c
===
--- 2.6.24-rc4.orig/drivers/block/viodasd.c
+++ 2.6.24-rc4/drivers/block/viodasd.c
@@ -229,13 +229,10 @@ static struct block_device_operations vi
 /*
  * End a request
  */
-static void viodasd_end_request(struct request *req, int uptodate,
+static void viodasd_end_request(struct request *req, int error,
int num_sectors)
 {
-   if (end_that_request_first(req, uptodate, num_sectors))
-   return;
-   add_disk_randomness(req->rq_disk);
-   end_that_request_last(req, uptodate);
+   __blk_end_request(req, error, num_sectors << 9);
 }
 
 /*
@@ -374,12 +371,12 @@ static void do_viodasd_request(struct re
blkdev_dequeue_request(req);
/* check that request contains a valid command */
if (!blk_fs_request(req)) {
-   viodasd_end_request(req, 0, req->hard_nr_sectors);
+   viodasd_end_request(req, -EIO, req->hard_nr_sectors);
continue;
}
/* Try sending the request */
if (send_request(req) != 0)
-   viodasd_end_request(req, 0, req->hard_nr_sectors);
+   viodasd_end_request(req, -EIO, req->hard_nr_sectors);
}
 }
 
@@ -591,7 +588,7 @@ static int viodasd_handle_read_write(str
num_req_outstanding--;
spin_unlock_irqrestore(&viodasd_spinlock, irq_flags);
 
-   error = event->xRc != HvLpEvent_Rc_Good;
+   error = (event->xRc == HvLpEvent_Rc_Good) ? 0 : -EIO;
if (error) {
const struct vio_error_entry *err;
err = vio_lookup_rc(viodasd_err_table, bevent->sub_result);
@@ -601,7 +598,7 @@ static int viodasd_handle_read_write(str
}
qlock = req->q->queue_lock;
spin_lock_irqsave(qlock, irq_flags);
-   viodasd_end_request(req, !error, num_sect);
+   viodasd_end_request(req, error, num_sect);
spin_unlock_irqrestore(qlock, irq_flags);
 
/* Finally, try to get more requests off of this device's queue */
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/30] blk_end_request: changing sx8 (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch converts sx8 to use blk_end_request interfaces.
Related 'uptodate' and 'is_ok' arguments are converted to 'error'.

As a result, the interfaces of internal functions below are changed.
  o carm_end_request_queued
  o carm_end_rq
  o carm_handle_array_info
  o carm_handle_scan_chan
  o carm_handle_generic
  o carm_handle_rw

The 'is_ok' is set at only one place in carm_handle_resp() below:

int is_ok = (status == RMSG_OK);

And the value is propagated to all functions above, and no modification
in other places.
So the actual conversion of the 'is_ok' is done at only one place above.

Cc: Jeff Garzik <[EMAIL PROTECTED]>
Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 drivers/block/sx8.c |   58 +---
 1 files changed, 28 insertions(+), 30 deletions(-)

Index: 2.6.24-rc4/drivers/block/sx8.c
===
--- 2.6.24-rc4.orig/drivers/block/sx8.c
+++ 2.6.24-rc4/drivers/block/sx8.c
@@ -744,16 +744,14 @@ static unsigned int carm_fill_get_fw_ver
 
 static inline void carm_end_request_queued(struct carm_host *host,
   struct carm_request *crq,
-  int uptodate)
+  int error)
 {
struct request *req = crq->rq;
int rc;
 
-   rc = end_that_request_first(req, uptodate, req->hard_nr_sectors);
+   rc = __blk_end_request(req, error, blk_rq_bytes(req));
assert(rc == 0);
 
-   end_that_request_last(req, uptodate);
-
rc = carm_put_request(host, crq);
assert(rc == 0);
 }
@@ -793,9 +791,9 @@ static inline void carm_round_robin(stru
 }
 
 static inline void carm_end_rq(struct carm_host *host, struct carm_request 
*crq,
-   int is_ok)
+  int error)
 {
-   carm_end_request_queued(host, crq, is_ok);
+   carm_end_request_queued(host, crq, error);
if (max_queue == 1)
carm_round_robin(host);
else if ((host->n_msgs <= CARM_MSG_LOW_WATER) &&
@@ -873,14 +871,14 @@ queue_one_request:
sg = &crq->sg[0];
n_elem = blk_rq_map_sg(q, rq, sg);
if (n_elem <= 0) {
-   carm_end_rq(host, crq, 0);
+   carm_end_rq(host, crq, -EIO);
return; /* request with no s/g entries? */
}
 
/* map scatterlist to PCI bus addresses */
n_elem = pci_map_sg(host->pdev, sg, n_elem, pci_dir);
if (n_elem <= 0) {
-   carm_end_rq(host, crq, 0);
+   carm_end_rq(host, crq, -EIO);
return; /* request with no s/g entries? */
}
crq->n_elem = n_elem;
@@ -941,7 +939,7 @@ queue_one_request:
 
 static void carm_handle_array_info(struct carm_host *host,
   struct carm_request *crq, u8 *mem,
-  int is_ok)
+  int error)
 {
struct carm_port *port;
u8 *msg_data = mem + sizeof(struct carm_array_info);
@@ -952,9 +950,9 @@ static void carm_handle_array_info(struc
 
DPRINTK("ENTER\n");
 
-   carm_end_rq(host, crq, is_ok);
+   carm_end_rq(host, crq, error);
 
-   if (!is_ok)
+   if (error)
goto out;
if (le32_to_cpu(desc->array_status) & ARRAY_NO_EXIST)
goto out;
@@ -1001,7 +999,7 @@ out:
 
 static void carm_handle_scan_chan(struct carm_host *host,
  struct carm_request *crq, u8 *mem,
- int is_ok)
+ int error)
 {
u8 *msg_data = mem + IOC_SCAN_CHAN_OFFSET;
unsigned int i, dev_count = 0;
@@ -1009,9 +1007,9 @@ static void carm_handle_scan_chan(struct
 
DPRINTK("ENTER\n");
 
-   carm_end_rq(host, crq, is_ok);
+   carm_end_rq(host, crq, error);
 
-   if (!is_ok) {
+   if (error) {
new_state = HST_ERROR;
goto out;
}
@@ -1033,23 +1031,23 @@ out:
 }
 
 static void carm_handle_generic(struct carm_host *host,
-   struct carm_request *crq, int is_ok,
+   struct carm_request *crq, int error,
int cur_state, int next_state)
 {
DPRINTK("ENTER\n");
 
-   carm_end_rq(host, crq, is_ok);
+   carm_end_rq(host, crq, error);
 
assert(host->state == cur_state);
-   if (is_ok)
-   host->state = next_state;
-   else
+   if (error)
host->state = HST_ERROR;
+   else
+   host->state = next_state;
schedule_work(&host->fsm_task);
 }
 
 static inline void carm_handle_rw(struct carm_host *host,
- struct carm_request *crq, int is_ok)
+ struct carm_request *c

[PATCH 12/30] blk_end_request: changing ub (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch converts ub to use blk_end_request interfaces.
Related 'uptodate' arguments are converted to 'error'.

Cc: Pete Zaitcev <[EMAIL PROTECTED]>
Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 drivers/block/ub.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

Index: 2.6.24-rc4/drivers/block/ub.c
===
--- 2.6.24-rc4.orig/drivers/block/ub.c
+++ 2.6.24-rc4/drivers/block/ub.c
@@ -808,16 +808,16 @@ static void ub_rw_cmd_done(struct ub_dev
 
 static void ub_end_rq(struct request *rq, unsigned int scsi_status)
 {
-   int uptodate;
+   int error;
 
if (scsi_status == 0) {
-   uptodate = 1;
+   error = 0;
} else {
-   uptodate = 0;
+   error = -EIO;
rq->errors = scsi_status;
}
-   end_that_request_first(rq, uptodate, rq->hard_nr_sectors);
-   end_that_request_last(rq, uptodate);
+   if (__blk_end_request(rq, error, blk_rq_bytes(rq)))
+   BUG();
 }
 
 static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun,
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/30] blk_end_request: changing ps3disk (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch converts ps3disk to use blk_end_request interfaces.
Related 'uptodate' arguments are converted to 'error'.

Cc: Geoff Levand <[EMAIL PROTECTED]>
Cc: Geert Uytterhoeven <[EMAIL PROTECTED]>
Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 drivers/block/ps3disk.c |   12 
 1 files changed, 4 insertions(+), 8 deletions(-)

Index: 2.6.24-rc4/drivers/block/ps3disk.c
===
--- 2.6.24-rc4.orig/drivers/block/ps3disk.c
+++ 2.6.24-rc4/drivers/block/ps3disk.c
@@ -229,7 +229,7 @@ static irqreturn_t ps3disk_interrupt(int
struct ps3_storage_device *dev = data;
struct ps3disk_private *priv;
struct request *req;
-   int res, read, uptodate;
+   int res, read, error;
u64 tag, status;
unsigned long num_sectors;
const char *op;
@@ -270,21 +270,17 @@ static irqreturn_t ps3disk_interrupt(int
if (status) {
dev_dbg(&dev->sbd.core, "%s:%u: %s failed 0x%lx\n", __func__,
__LINE__, op, status);
-   uptodate = 0;
+   error = -EIO;
} else {
dev_dbg(&dev->sbd.core, "%s:%u: %s completed\n", __func__,
__LINE__, op);
-   uptodate = 1;
+   error = 0;
if (read)
ps3disk_scatter_gather(dev, req, 0);
}
 
spin_lock(&priv->lock);
-   if (!end_that_request_first(req, uptodate, num_sectors)) {
-   add_disk_randomness(req->rq_disk);
-   blkdev_dequeue_request(req);
-   end_that_request_last(req, uptodate);
-   }
+   __blk_end_request(req, error, num_sectors << 9);
priv->req = NULL;
ps3disk_do_request(dev, priv->queue);
spin_unlock(&priv->lock);
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/30] blk_end_request: changing sunvdc (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch converts sunvdc to use blk_end_request interfaces.
Related 'uptodate' arguments are converted to 'error'.

As a result, the interface of internal function, vdc_end_request(),
is changed.

Cc: David S. Miller <[EMAIL PROTECTED]>
Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 drivers/block/sunvdc.c |   11 ---
 1 files changed, 4 insertions(+), 7 deletions(-)

Index: 2.6.24-rc4/drivers/block/sunvdc.c
===
--- 2.6.24-rc4.orig/drivers/block/sunvdc.c
+++ 2.6.24-rc4/drivers/block/sunvdc.c
@@ -212,12 +212,9 @@ static void vdc_end_special(struct vdc_p
vdc_finish(&port->vio, -err, WAITING_FOR_GEN_CMD);
 }
 
-static void vdc_end_request(struct request *req, int uptodate, int num_sectors)
+static void vdc_end_request(struct request *req, int error, int num_sectors)
 {
-   if (end_that_request_first(req, uptodate, num_sectors))
-   return;
-   add_disk_randomness(req->rq_disk);
-   end_that_request_last(req, uptodate);
+   __blk_end_request(req, error, num_sectors << 9);
 }
 
 static void vdc_end_one(struct vdc_port *port, struct vio_dring_state *dr,
@@ -242,7 +239,7 @@ static void vdc_end_one(struct vdc_port 
 
rqe->req = NULL;
 
-   vdc_end_request(req, !desc->status, desc->size >> 9);
+   vdc_end_request(req, (desc->status ? -EIO : 0), desc->size >> 9);
 
if (blk_queue_stopped(port->disk->queue))
blk_start_queue(port->disk->queue);
@@ -456,7 +453,7 @@ static void do_vdc_request(struct reques
 
blkdev_dequeue_request(req);
if (__send_request(req) < 0)
-   vdc_end_request(req, 0, req->hard_nr_sectors);
+   vdc_end_request(req, -EIO, req->hard_nr_sectors);
}
 }
 
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/30] blk_end_request: changing nbd (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch converts nbd to use blk_end_request interfaces.
Related 'uptodate' arguments are converted to 'error'.

Cc: Paul Clements <[EMAIL PROTECTED]>
Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 drivers/block/nbd.c |8 +++-
 1 files changed, 3 insertions(+), 5 deletions(-)

Index: 2.6.24-rc4/drivers/block/nbd.c
===
--- 2.6.24-rc4.orig/drivers/block/nbd.c
+++ 2.6.24-rc4/drivers/block/nbd.c
@@ -100,17 +100,15 @@ static const char *nbdcmd_to_ascii(int c
 
 static void nbd_end_request(struct request *req)
 {
-   int uptodate = (req->errors == 0) ? 1 : 0;
+   int error = req->errors ? -EIO : 0;
struct request_queue *q = req->q;
unsigned long flags;
 
dprintk(DBG_BLKDEV, "%s: request %p: %s\n", req->rq_disk->disk_name,
-   req, uptodate? "done": "failed");
+   req, error ? "failed" : "done");
 
spin_lock_irqsave(q->queue_lock, flags);
-   if (!end_that_request_first(req, uptodate, req->nr_sectors)) {
-   end_that_request_last(req, uptodate);
-   }
+   __blk_end_request(req, error, req->nr_sectors << 9);
spin_unlock_irqrestore(q->queue_lock, flags);
 }
 
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/30] blk_end_request: changing DAC960 (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch converts DAC960 to use blk_end_request interfaces.
Related 'UpToDate' arguments are converted to 'Error'.

Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 drivers/block/DAC960.c |   11 ++-
 1 files changed, 2 insertions(+), 9 deletions(-)

Index: 2.6.24-rc4/drivers/block/DAC960.c
===
--- 2.6.24-rc4.orig/drivers/block/DAC960.c
+++ 2.6.24-rc4/drivers/block/DAC960.c
@@ -3455,19 +3455,12 @@ static inline bool DAC960_ProcessComplet
 bool SuccessfulIO)
 {
struct request *Request = Command->Request;
-   int UpToDate;
-
-   UpToDate = 0;
-   if (SuccessfulIO)
-   UpToDate = 1;
+   int Error = SuccessfulIO ? 0 : -EIO;
 
pci_unmap_sg(Command->Controller->PCIDevice, Command->cmd_sglist,
Command->SegmentCount, Command->DmaDirection);
 
-if (!end_that_request_first(Request, UpToDate, Command->BlockCount)) {
-   add_disk_randomness(Request->rq_disk);
-   end_that_request_last(Request, UpToDate);
-
+if (!__blk_end_request(Request, Error, Command->BlockCount << 9)) {
if (Command->Completion) {
complete(Command->Completion);
Command->Completion = NULL;
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/30] blk_end_request: changing um (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch converts um to use blk_end_request interfaces.
Related 'uptodate' arguments are converted to 'error'.

As a result, the interface of internal function, ubd_end_request(),
is changed.

Cc: Jeff Dike <[EMAIL PROTECTED]>
Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 arch/um/drivers/ubd_kern.c |   16 
 1 files changed, 4 insertions(+), 12 deletions(-)

Index: 2.6.24-rc4/arch/um/drivers/ubd_kern.c
===
--- 2.6.24-rc4.orig/arch/um/drivers/ubd_kern.c
+++ 2.6.24-rc4/arch/um/drivers/ubd_kern.c
@@ -475,17 +475,9 @@ static void do_ubd_request(struct reques
 /* Only changed by ubd_init, which is an initcall. */
 int thread_fd = -1;
 
-static void ubd_end_request(struct request *req, int bytes, int uptodate)
+static void ubd_end_request(struct request *req, int bytes, int error)
 {
-   if (!end_that_request_first(req, uptodate, bytes >> 9)) {
-   struct ubd *dev = req->rq_disk->private_data;
-   unsigned long flags;
-
-   add_disk_randomness(req->rq_disk);
-   spin_lock_irqsave(&dev->lock, flags);
-   end_that_request_last(req, uptodate);
-   spin_unlock_irqrestore(&dev->lock, flags);
-   }
+   blk_end_request(req, error, bytes);
 }
 
 /* Callable only from interrupt context - otherwise you need to do
@@ -493,10 +485,10 @@ static void ubd_end_request(struct reque
 static inline void ubd_finish(struct request *req, int bytes)
 {
if(bytes < 0){
-   ubd_end_request(req, 0, 0);
+   ubd_end_request(req, 0, -EIO);
return;
}
-   ubd_end_request(req, bytes, 1);
+   ubd_end_request(req, bytes, 0);
 }
 
 static LIST_HEAD(restart);
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/30] blk_end_request: changing floppy (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch converts floppy to use blk_end_request interfaces.
Related 'uptodate' arguments are converted to 'error'.

As a result, the interface of internal function, floppy_end_request(),
is changed.

Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 drivers/block/floppy.c |   16 +++-
 1 files changed, 7 insertions(+), 9 deletions(-)

Index: 2.6.24-rc4/drivers/block/floppy.c
===
--- 2.6.24-rc4.orig/drivers/block/floppy.c
+++ 2.6.24-rc4/drivers/block/floppy.c
@@ -2287,21 +2287,19 @@ static int do_format(int drive, struct f
  * =
  */
 
-static void floppy_end_request(struct request *req, int uptodate)
+static void floppy_end_request(struct request *req, int error)
 {
unsigned int nr_sectors = current_count_sectors;
+   unsigned int drive = (unsigned int)req->rq_disk->private_data;
 
/* current_count_sectors can be zero if transfer failed */
-   if (!uptodate)
+   if (error)
nr_sectors = req->current_nr_sectors;
-   if (end_that_request_first(req, uptodate, nr_sectors))
+   if (__blk_end_request(req, error, nr_sectors << 9))
return;
-   add_disk_randomness(req->rq_disk);
-   floppy_off((long)req->rq_disk->private_data);
-   blkdev_dequeue_request(req);
-   end_that_request_last(req, uptodate);
 
/* We're done with the request */
+   floppy_off(drive);
current_req = NULL;
 }
 
@@ -2332,7 +2330,7 @@ static void request_done(int uptodate)
 
/* unlock chained buffers */
spin_lock_irqsave(q->queue_lock, flags);
-   floppy_end_request(req, 1);
+   floppy_end_request(req, 0);
spin_unlock_irqrestore(q->queue_lock, flags);
} else {
if (rq_data_dir(req) == WRITE) {
@@ -2346,7 +2344,7 @@ static void request_done(int uptodate)
DRWE->last_error_generation = DRS->generation;
}
spin_lock_irqsave(q->queue_lock, flags);
-   floppy_end_request(req, 0);
+   floppy_end_request(req, -EIO);
spin_unlock_irqrestore(q->queue_lock, flags);
}
 }
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/30] blk_end_request: changing block layer core (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch converts core parts of block layer to use blk_end_request
interfaces.  Related 'uptodate' arguments are converted to 'error'.

'dequeue' argument was originally introduced for end_dequeued_request(),
where no attempt should be made to dequeue the request as it's already
dequeued.
However, it's not necessary as it can be checked with
list_empty(&rq->queuelist).
(Dequeued request has empty list and queued request doesn't.)
And it has been done in blk_end_request interfaces.

As a result of this patch, end_queued_request() and
end_dequeued_request() become identical.  A future patch will merge
and rename them and change users of those functions.

Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 block/ll_rw_blk.c |   35 +++
 1 files changed, 15 insertions(+), 20 deletions(-)

Index: 2.6.24-rc4/block/ll_rw_blk.c
===
--- 2.6.24-rc4.orig/block/ll_rw_blk.c
+++ 2.6.24-rc4/block/ll_rw_blk.c
@@ -347,7 +347,6 @@ unsigned blk_ordered_req_seq(struct requ
 void blk_ordered_complete_seq(struct request_queue *q, unsigned seq, int error)
 {
struct request *rq;
-   int uptodate;
 
if (error && !q->orderr)
q->orderr = error;
@@ -361,15 +360,11 @@ void blk_ordered_complete_seq(struct req
/*
 * Okay, sequence complete.
 */
-   uptodate = 1;
-   if (q->orderr)
-   uptodate = q->orderr;
-
q->ordseq = 0;
rq = q->orig_bar_rq;
 
-   end_that_request_first(rq, uptodate, rq->hard_nr_sectors);
-   end_that_request_last(rq, uptodate);
+   if (__blk_end_request(rq, q->orderr, blk_rq_bytes(rq)))
+   BUG();
 }
 
 static void pre_flush_end_io(struct request *rq, int error)
@@ -486,9 +481,9 @@ int blk_do_ordered(struct request_queue 
 * ORDERED_NONE while this request is on it.
 */
blkdev_dequeue_request(rq);
-   end_that_request_first(rq, -EOPNOTSUPP,
-  rq->hard_nr_sectors);
-   end_that_request_last(rq, -EOPNOTSUPP);
+   if (__blk_end_request(rq, -EOPNOTSUPP,
+ blk_rq_bytes(rq)))
+   BUG();
*rqp = NULL;
return 0;
}
@@ -3691,14 +3686,14 @@ void end_that_request_last(struct reques
 EXPORT_SYMBOL(end_that_request_last);
 
 static inline void __end_request(struct request *rq, int uptodate,
-unsigned int nr_bytes, int dequeue)
+unsigned int nr_bytes)
 {
-   if (!end_that_request_chunk(rq, uptodate, nr_bytes)) {
-   if (dequeue)
-   blkdev_dequeue_request(rq);
-   add_disk_randomness(rq->rq_disk);
-   end_that_request_last(rq, uptodate);
-   }
+   int error = 0;
+
+   if (uptodate <= 0)
+   error = uptodate ? uptodate : -EIO;
+
+   __blk_end_request(rq, error, nr_bytes);
 }
 
 /**
@@ -3741,7 +3736,7 @@ EXPORT_SYMBOL_GPL(blk_rq_cur_bytes);
  **/
 void end_queued_request(struct request *rq, int uptodate)
 {
-   __end_request(rq, uptodate, blk_rq_bytes(rq), 1);
+   __end_request(rq, uptodate, blk_rq_bytes(rq));
 }
 EXPORT_SYMBOL(end_queued_request);
 
@@ -3758,7 +3753,7 @@ EXPORT_SYMBOL(end_queued_request);
  **/
 void end_dequeued_request(struct request *rq, int uptodate)
 {
-   __end_request(rq, uptodate, blk_rq_bytes(rq), 0);
+   __end_request(rq, uptodate, blk_rq_bytes(rq));
 }
 EXPORT_SYMBOL(end_dequeued_request);
 
@@ -3784,7 +3779,7 @@ EXPORT_SYMBOL(end_dequeued_request);
  **/
 void end_request(struct request *req, int uptodate)
 {
-   __end_request(req, uptodate, req->hard_cur_sectors << 9, 1);
+   __end_request(req, uptodate, req->hard_cur_sectors << 9);
 }
 EXPORT_SYMBOL(end_request);
 
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/30] blk_end_request: changing arm (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch converts arm's OMAP mailbox driver to use
blk_end_request interfaces.

If the original code was converted literally, blk_end_request would
be called with '-EIO' because end_that_request_last() were called
with '0' (i.e. failure).
But I think these '0's are bugs in the original code because it's
unlikely that all requests are treated as failure.
(The bugs should have no effect unless these requests have an end_io
 callback.)

So I changed them to pass '0' (i.e. success) to blk_end_request.

Cc: Toshihiro Kobayashi <[EMAIL PROTECTED]>
Cc: Hiroshi DOYU <[EMAIL PROTECTED]>
Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---

 arch/arm/plat-omap/mailbox.c |   16 ++--
 1 files changed, 6 insertions(+), 10 deletions(-)

Index: 2.6.24-rc4/arch/arm/plat-omap/mailbox.c
===
--- 2.6.24-rc4.orig/arch/arm/plat-omap/mailbox.c
+++ 2.6.24-rc4/arch/arm/plat-omap/mailbox.c
@@ -116,8 +116,8 @@ static void mbox_tx_work(struct work_str
}
 
spin_lock(q->queue_lock);
-   blkdev_dequeue_request(rq);
-   end_that_request_last(rq, 0);
+   if (__blk_end_request(rq, 0, 0))
+   BUG();
spin_unlock(q->queue_lock);
}
 }
@@ -149,10 +149,8 @@ static void mbox_rx_work(struct work_str
 
msg = (mbox_msg_t) rq->data;
 
-   spin_lock_irqsave(q->queue_lock, flags);
-   blkdev_dequeue_request(rq);
-   end_that_request_last(rq, 0);
-   spin_unlock_irqrestore(q->queue_lock, flags);
+   if (blk_end_request(rq, 0, 0))
+   BUG();
 
mbox->rxq->callback((void *)msg);
}
@@ -263,10 +261,8 @@ omap_mbox_read(struct device *dev, struc
 
*p = (mbox_msg_t) rq->data;
 
-   spin_lock_irqsave(q->queue_lock, flags);
-   blkdev_dequeue_request(rq);
-   end_that_request_last(rq, 0);
-   spin_unlock_irqrestore(q->queue_lock, flags);
+   if (blk_end_request(rq, 0, 0))
+   BUG();
 
if (unlikely(mbox_seq_test(mbox, *p))) {
pr_info("mbox: Illegal seq bit!(%08x) ignored\n", *p);
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 00/30] blk_end_request: full I/O completion handler (take 4)

2007-12-11 Thread Kiyoshi Ueda
Hi Jens, Boaz,

The following is the updated patch-set for blk_end_request().
I have done some interface/implementation changes based on
feedbacks/discussions since the previous version.
(Although this patch-set was made on top of 2.6.24-rc4, I confirmed
 it can be applied to 2.6.24-rc5, too.  Also, I confirmed it has
 no build error on my IA64 box.)

As for patches without Cc tag, I couldn't find the maintainer
related to the patch.

Patch 27 through patch 30 conflict with Boaz's scsi bidi patch.
If Boaz's patch goes first, I will rebase these 4 patches on top of
Boaz's patch and post them again.


-- Changes from the previous post -
Changes between take3 and take4:
  o Rebased on top of 2.6.24-rc4 + an IDE's patch to remove dead
post_transform_command()
(http://marc.info/?l=linux-kernel&m=119654922030880&w=2)
  o Changed the 'uptodate' argument of blk_end_request interfaces
to 'error'.  Changed all related drivers, too.  (PATCH 01-29)
  o Added blk_queued_rq() macro, which indicates whether the request
is in the block-layer's queue or not  (PATCH 01)
  o Added blk_end_bidi_request() interface for bidi request (PATCH 26)
  o Removed some code duplications of blk_end_request interfaces
using an internal function (blk_end_io())  (PATCH 24 and PATCH 26)
  o Added cleanup of request completion introduced by this
patch-set  (PATCH 30)

Changes between take2 and take3:
  o Rebased on top of 2.6.24-rc3-mm2
  o Added a bidi patch, which changes bidi to use blk_end_request()
(PATCH 27)
  o Dropped blk_rq_size() which was to get size of entire request
because rq_byte_size() has been added to ll_rw_blk.c (PATCH 02)
  o Removed 'dequeue' argument, which was added in 2.6.23-rc7-mm1,
from __end_request() (PATCH 03)
  o Removed lguest patch because lguest has been changed not to use
end_that_request_{chunk/last} directly.

Changes between take1 and take2:
  o Rebased on top of 2.6.23-rc4-mm1
  o Don't pass the lock held information (PATCH 01)
  o Removed sect2byte() macro (PATCH 02)
  o fixed blk_rq_size() and blk_rq_cur_size() for blk_pc_requests (PATCH 02)
  o Separated the patch for changes of end_that_request_* user (PATCH 03-26)
  o Removed the patch which changes the role of rq->end_io()
from this patch-set because some more discussions are needed
about it.
---


Summary of each patch are below:
  01/30: add new request completion interface, blk_end_request (block)
  02/30: add some functions to get the size of request in bytes (block)
  03/30: convert to use blk_end_request (block)
  04/30: convert to use blk_end_request (arm)
  05/30: convert to use blk_end_request (um)
  06/30: convert to use blk_end_request (DAC960)
  07/30: convert to use blk_end_request (floppy)
  08/30: convert to use blk_end_request (nbd)
  09/30: convert to use blk_end_request (ps3disk)
  10/30: convert to use blk_end_request (sunvdc)
  11/30: convert to use blk_end_request (sx8)
  12/30: convert to use blk_end_request (ub)
  13/30: convert to use blk_end_request (viodasd)
  14/30: convert to use blk_end_request (xen-blkfront)
  15/30: convert to use blk_end_request (viocd)
  16/30: convert to use blk_end_request (i2o_block)
  17/30: convert to use blk_end_request (mmc)
  18/30: convert to use blk_end_request (s390)
  19/30: convert to use blk_end_request (ide-scsi)
  20/30: convert to use blk_end_request (xsysace)
  21/30: convert to use blk_end_request (cciss)
  22/30: convert to use blk_end_request (cpqarray)
  23/30: convert to use blk_end_request (normal parts of ide)
  24/30: add a valiant of blk_end_request having callback feature (block)
  25/30: convert to use blk_end_request (ide-cd, cdrom_newpc_intr())
  26/30: add a valiant of blk_end_request for bidi request (block)
  27/30: convert to use blk_end_request (scsi mid-layer)
  28/30: remove/unexport no longer needed end_that_request_* (block)
  29/30: remove no longer needed 'uptodate' related codes (block)
  30/30: cleanup of request completion introduced by this patch-set (block)

I have tested this patch-set on two machines,
IA64+QLA1280+QLA2200 box and x86_64+SATA+IDE-CDROM box.


Below is the explanation about needs and details of this patch-set.

SUMMARY
===
This set of patches changes request completion interface
between device drivers and block layer to 1-step procedure
from current 2-step procedures (i.e. end_that_request_{first/chunk}
and end_that_request_last) so that the block layer can take over
the ownership of the request from device drivers before starting to
complete each chunk of the request.

This patch-set prepares for realizing another patch-set which changes
the role of rq->end_io().  It allows request-based multipath to hook
in before completing each chunk of request, check errors for it and
retry it using another path if error is detected.


BACKGROUND
==
The patch-set which changes the role of

[PATCH 02/30] blk_end_request: add/export functions to get request size (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch adds/exports functions to get the size of request in bytes.
They are useful because blk_end_request interfaces take bytes
as a completed I/O size instead of sectors.

Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 block/ll_rw_blk.c  |   25 ++---
 include/linux/blkdev.h |8 
 2 files changed, 30 insertions(+), 3 deletions(-)

Index: 2.6.24-rc4/include/linux/blkdev.h
===
--- 2.6.24-rc4.orig/include/linux/blkdev.h
+++ 2.6.24-rc4/include/linux/blkdev.h
@@ -739,6 +739,14 @@ extern void end_dequeued_request(struct 
 extern void blk_complete_request(struct request *);
 
 /*
+ * blk_end_request() takes bytes instead of sectors as a complete size.
+ * blk_rq_bytes() returns bytes left to complete in the entire request.
+ * blk_rq_cur_bytes() returns bytes left to complete in the current segment.
+ */
+extern unsigned int blk_rq_bytes(struct request *rq);
+extern unsigned int blk_rq_cur_bytes(struct request *rq);
+
+/*
  * end_that_request_first/chunk() takes an uptodate argument. we account
  * any value <= as an io error. 0 means -EIO for compatability reasons,
  * any other < 0 value is the direct error type. An uptodate value of
Index: 2.6.24-rc4/block/ll_rw_blk.c
===
--- 2.6.24-rc4.orig/block/ll_rw_blk.c
+++ 2.6.24-rc4/block/ll_rw_blk.c
@@ -3701,13 +3701,32 @@ static inline void __end_request(struct 
}
 }
 
-static unsigned int rq_byte_size(struct request *rq)
+/**
+ * blk_rq_bytes - Returns bytes left to complete in the entire request
+ **/
+unsigned int blk_rq_bytes(struct request *rq)
 {
if (blk_fs_request(rq))
return rq->hard_nr_sectors << 9;
 
return rq->data_len;
 }
+EXPORT_SYMBOL_GPL(blk_rq_bytes);
+
+/**
+ * blk_rq_cur_bytes - Returns bytes left to complete in the current segment
+ **/
+unsigned int blk_rq_cur_bytes(struct request *rq)
+{
+   if (blk_fs_request(rq))
+   return rq->current_nr_sectors << 9;
+
+   if (rq->bio)
+   return rq->bio->bi_size;
+
+   return rq->data_len;
+}
+EXPORT_SYMBOL_GPL(blk_rq_cur_bytes);
 
 /**
  * end_queued_request - end all I/O on a queued request
@@ -3722,7 +3741,7 @@ static unsigned int rq_byte_size(struct 
  **/
 void end_queued_request(struct request *rq, int uptodate)
 {
-   __end_request(rq, uptodate, rq_byte_size(rq), 1);
+   __end_request(rq, uptodate, blk_rq_bytes(rq), 1);
 }
 EXPORT_SYMBOL(end_queued_request);
 
@@ -3739,7 +3758,7 @@ EXPORT_SYMBOL(end_queued_request);
  **/
 void end_dequeued_request(struct request *rq, int uptodate)
 {
-   __end_request(rq, uptodate, rq_byte_size(rq), 0);
+   __end_request(rq, uptodate, blk_rq_bytes(rq), 0);
 }
 EXPORT_SYMBOL(end_dequeued_request);
 
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/30] blk_end_request: add new request completion interface (take 4)

2007-12-11 Thread Kiyoshi Ueda
This patch adds 2 new interfaces for request completion:
  o blk_end_request()   : called without queue lock
  o __blk_end_request() : called with queue lock held

blk_end_request takes 'error' as an argument instead of 'uptodate',
which current end_that_request_* take.
The meanings of values are below and the value is used when bio is
completed.
0 : success
  < 0 : error

Some device drivers call some generic functions below between
end_that_request_{first/chunk} and end_that_request_last().
  o add_disk_randomness()
  o blk_queue_end_tag()
  o blkdev_dequeue_request()
These are called in the blk_end_request interfaces as a part of
generic request completion.
So all device drivers become to call above functions.
To decide whether to call blkdev_dequeue_request(), blk_end_request
uses list_empty(&rq->queuelist) (blk_queued_rq() macro is added for it).
So drivers must re-initialize it using list_init() or so before calling
blk_end_request if drivers use it for its specific purpose.
(Currently, there is no driver which completes request without
 re-initializing the queuelist after used it.  So rq->queuelist
 can be used for the purpose above.)

"Normal" drivers can be converted to use blk_end_request()
in a standard way shown below.

 a) end_that_request_{chunk/first}
spin_lock_irqsave()
(add_disk_randomness(), blk_queue_end_tag(), blkdev_dequeue_request())
end_that_request_last()
spin_unlock_irqrestore()
=> blk_end_request()

 b) spin_lock_irqsave()
end_that_request_{chunk/first}
(add_disk_randomness(), blk_queue_end_tag(), blkdev_dequeue_request())
end_that_request_last()
spin_unlock_irqrestore()
=> spin_lock_irqsave()
   __blk_end_request()
   spin_unlock_irqsave()

 c) spin_lock_irqsave()
(add_disk_randomness(), blk_queue_end_tag(), blkdev_dequeue_request())
end_that_request_last()
spin_unlock_irqrestore()
=> blk_end_request()   or   spin_lock_irqsave()
__blk_end_request()
spin_unlock_irqrestore()

Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
---
 block/ll_rw_blk.c  |   96 +
 include/linux/blkdev.h |4 ++
 2 files changed, 100 insertions(+)

Index: 2.6.24-rc4/block/ll_rw_blk.c
===
--- 2.6.24-rc4.orig/block/ll_rw_blk.c
+++ 2.6.24-rc4/block/ll_rw_blk.c
@@ -3769,6 +3769,102 @@ void end_request(struct request *req, in
 }
 EXPORT_SYMBOL(end_request);
 
+static void complete_request(struct request *rq, int error)
+{
+   /*
+* REMOVEME: This conversion is transitional and will be removed
+*   when old end_that_request_* are unexported.
+*/
+   int uptodate = 1;
+   if (error)
+   uptodate = (error == -EIO) ? 0 : error;
+
+   if (blk_rq_tagged(rq))
+   blk_queue_end_tag(rq->q, rq);
+
+   if (blk_queued_rq(rq))
+   blkdev_dequeue_request(rq);
+
+   end_that_request_last(rq, uptodate);
+}
+
+/**
+ * blk_end_request - Helper function for drivers to complete the request.
+ * @rq:   the request being processed
+ * @error:0 for success, < 0 for error
+ * @nr_bytes: number of bytes to complete
+ *
+ * Description:
+ * Ends I/O on a number of bytes attached to @rq.
+ * If @rq has leftover, sets it up for the next range of segments.
+ *
+ * Return:
+ * 0 - we are done with this request
+ * 1 - still buffers pending for this request
+ **/
+int blk_end_request(struct request *rq, int error, int nr_bytes)
+{
+   struct request_queue *q = rq->q;
+   unsigned long flags = 0UL;
+   /*
+* REMOVEME: This conversion is transitional and will be removed
+*   when old end_that_request_* are unexported.
+*/
+   int uptodate = 1;
+   if (error)
+   uptodate = (error == -EIO) ? 0 : error;
+
+   if (blk_fs_request(rq) || blk_pc_request(rq)) {
+   if (__end_that_request_first(rq, uptodate, nr_bytes))
+   return 1;
+   }
+
+   add_disk_randomness(rq->rq_disk);
+
+   spin_lock_irqsave(q->queue_lock, flags);
+   complete_request(rq, error);
+   spin_unlock_irqrestore(q->queue_lock, flags);
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(blk_end_request);
+
+/**
+ * __blk_end_request - Helper function for drivers to complete the request.
+ * @rq:   the request being processed
+ * @error:0 for success, < 0 for error
+ * @nr_bytes: number of bytes to complete
+ *
+ * Description:
+ * Must be called with queue lock held unlike blk_end_request().
+ *
+ * Return:
+ * 0 - we are done with this request
+ * 1 - still buffers pending for this request
+ **/
+int __blk_end_request(struct request *rq, int error, int nr_bytes)
+{
+   /*
+* REMOVEME: This conversion is transitional and will be remov

Re: Iomega ZIP-100 drive unsupported with jmicron JMB361 chip?

2007-12-11 Thread Mark Lord

trash can wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Thanks for the note. Zip drive as only device on the bus did not work
for me. kernel is correctly identifying the Jmicron chip.

..

So have you tried 2.6.24-rc* on that system yet, using only libata ?


Mark Lord wrote:

Mark Lord wrote:

I missed the early part of this thread,
but here is a data point that may or may not be useful.

I have an ASUS mobo here with an onboard JM363 SATA/PATA controller
(verified by looking at the actual chip).

It works fine when in AHCI mode with a PATA ATAPI ZIP100 drive
all by itself.  No other configurations tested.
This is with kernel 2.6.24-rc4-git?.

..

Oh yeah.. that's with libata controlling all drives in the system.

..
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Iomega ZIP-100 drive unsupported with jmicron JMB361 chip?

2007-12-11 Thread trash can
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Thanks for the note. Zip drive as only device on the bus did not work
for me. kernel is correctly identifying the Jmicron chip.

Removed the DVD drive and jumpered the Zip drive to Master. BIOS
set to IDE. Fedora 8 with nash on boot:
Buffer I/O error on dev/sdc locaical block 0

dmesg:
Buffer I/O error on device sdc, logical block 0
sd 4:0:0:0: [sdc] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE,SUGGEST_OK
sd 4:0:0:0: [sdc] Sense Key : Hardware Error [current]
sd 4:0:0:0: [sdc] Add. Sense: Scsi parity error
end_request: I/O error, dev sdc, sector 0
Buffer I/O error on device sdc, logical block 0
sd 4:0:0:0: [sdc] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE,SUGGEST_OK
sd 4:0:0:0: [sdc] Sense Key : Hardware Error [current]
sd 4:0:0:0: [sdc] Add. Sense: Scsi parity error
end_request: I/O error, dev sdc, sector 0
Buffer I/O error on device sdc, logical block 0
Dev sdc: unable to read RDB block 0

udev creates a /dev/sdc only.

With DVD removed and BIOS set to AHCI device changes to sda
Fedora 8: nash:
Buffer I/O error on device sda, logical block 0

dmesg:
Buffer I/O error on device sda, logical block 0
sd 0:0:0:0: [sda] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE,SUGGEST_OK
sd 0:0:0:0: [sda] Sense Key : Hardware Error [current]
sd 0:0:0:0: [sda] Add. Sense: Scsi parity error
end_request: I/O error, dev sda, sector 0
Buffer I/O error on device sda, logical block 0
Dev sda: unable to read RDB block 0


Mark Lord wrote:
> Mark Lord wrote:
>>
>> I missed the early part of this thread,
>> but here is a data point that may or may not be useful.
>>
>> I have an ASUS mobo here with an onboard JM363 SATA/PATA controller
>> (verified by looking at the actual chip).
>>
>> It works fine when in AHCI mode with a PATA ATAPI ZIP100 drive
>> all by itself.  No other configurations tested.
>> This is with kernel 2.6.24-rc4-git?.
> ..
> 
> Oh yeah.. that's with libata controlling all drives in the system.
> 
> This exact same mobo was used for a while with a PATA DVD-RW (no ZIP drive)
> under older kernels using drivers/IDE, but was unreliable in that
> configuration
> (Ubuntu Edgy).   Ditto when the PATA DVD-RW was replaced with a SATA
> DVD-RW.
> 
> -ml
> 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFHXt92z1/aqdDsM3URAvoNAKD4jBHDbhppOx6Fa8URPjbgN+jc9gCdEc6s
HomNnFPdQEDa6m8aJKB+vLM=
=PkYa
-END PGP SIGNATURE-
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 17/21] ide: drop 'initializing' argument from ide_register_hw()

2007-12-11 Thread Sergei Shtylyov

Bartlomiej Zolnierkiewicz wrote:


* Rename init_hwif_data() to ide_init_port_data() and export it.



* For all users of ide_register_hw() with 'initializing' argument set
  hwif->present and hwif->hold are always zero so convert these host
  drivers to use ide_find_port()+ide_init_port_data()+ide_init_port_hw()
  instead (also no need for init_hwif_default() call since the setup
  done by it gets over-ridden by ide_init_port_data() call).


   But init_hwif_default() gets called *after* ide_init_port_data() call, at 
least in ide_register_hw()...



* Drop 'initializing' argument from ide_register_hw().



Signed-off-by: Bartlomiej Zolnierkiewicz <[EMAIL PROTECTED]>



Index: b/drivers/ide/ide.c
===
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -116,7 +116,7 @@ EXPORT_SYMBOL(ide_hwifs);
 /*
  * Do not even *think* about calling this!
  */


   Isn't this comment being obsoleted by the patch?

MBR, Sergei
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] sata_mv: improve warnings about Highpoint RocketRAID 23xx cards

2007-12-11 Thread Mark Lord

Improve the existing boot/load time warnings from sata_mv
for Highpoint RocketRAID 23xx cards, based on new knowledge
about where the BIOS likes to overwrite sectors with metadata.

Harmless to us, but very useful for end users.

Signed-off-by: Mark Lord <[EMAIL PROTECTED]>
---
This should ideally go upstream for 2.6.24.

--- old/drivers/ata/sata_mv.c   2007-12-10 18:14:09.0 -0500
+++ linux/drivers/ata/sata_mv.c 2007-12-11 12:51:51.0 -0500
@@ -2506,11 +2506,31 @@
if (pdev->vendor == PCI_VENDOR_ID_TTI &&
(pdev->device == 0x2300 || pdev->device == 0x2310))
{
-   printk(KERN_WARNING "sata_mv: Highpoint RocketRAID BIOS"
-   " will CORRUPT DATA on attached drives when"
-   " configured as \"Legacy\".  BEWARE!\n");
-   printk(KERN_WARNING "sata_mv: Use BIOS \"JBOD\" volumes"
-   " instead for safety.\n");
+   /*
+* Highpoint RocketRAID PCIe 23xx series cards:
+*
+* Unconfigured drives are treated as "Legacy"
+* by the BIOS, and it overwrites sector 8 with
+* a "Lgcy" metadata block prior to Linux boot.
+*
+* Configured drives (RAID or JBOD) leave sector 8
+* alone, but instead overwrite a high numbered
+* sector for the RAID metadata.  This sector can
+* be determined exactly, by truncating the physical
+* drive capacity to a nice even GB value.
+*
+* RAID metadata is at: (dev->n_sectors & ~0xf)
+*
+* Warn the user, lest they think we're just buggy.
+*/
+   printk(KERN_WARNING DRV_NAME ": Highpoint RocketRAID"
+   " BIOS CORRUPTS DATA on all attached drives,"
+   " regardless of if/how they are configured."
+   " BEWARE!\n");
+   printk(KERN_WARNING DRV_NAME ": For data safety, do not"
+   " use sectors 8-9 on \"Legacy\" drives,"
+   " and avoid the final two gigabytes on"
+   " all RocketRAID BIOS initialized drives.\n");
}
case chip_6042:
hpriv->ops = &mv6xxx_ops;
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: Responding to 2 thread <2.6.23.8 - Hang with sata_mv (7042)...> AND

2007-12-11 Thread Morrison, Tom
Correct, it has a flat memory map 0-0x

I don't make this stuff up and I checked it 3 times 
(with & without this set (#if 0 & #if 1) - just to make 
sure I don't have something else weird going on...

I'll send you privately my sata_mv.c - so you can inspect
that yourself (only custom thing is the EDMA buffers hi/low
buffers are set to point to the physical PCI space which is 
way up in 0xC__ space...

tom


-Original Message-
From: Mark Lord [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, December 11, 2007 12:42 PM
To: Morrison, Tom
Cc: Jeff Garzik; linux-ide@vger.kernel.org; Tejun Heo; [EMAIL PROTECTED]
Subject: Re: Responding to 2 thread <2.6.23.8 - Hang with sata_mv
(7042)...> AND 

Morrison, Tom wrote:
>> 
>> That's a bit strange, actually.. because you said that this system
>>does not have any RAM at any addresses above 0x.
>> The physical RAM in this system is supposedly from 0 - 0x
(4Gbytes).


-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Responding to 2 thread <2.6.23.8 - Hang with sata_mv (7042)...> AND

2007-12-11 Thread Mark Lord

Morrison, Tom wrote:
I am a little confused as to exactly what thread I am to respond to 
and/or what requests...but lets try this and see if I get close?


I have the  below mentioned hardware/configuration (flat 4Gig 
of DDR mem (0x0_000_ to 0x1_000_)...PPC/8548E - 36bit addressing


As can be seen below - Mark has asked me try patching my sata_mv 
(and scsi_lib) with some patches from the second thread in subject:


1) Disable 64bit DMA in sata_mv (equivalent of the CAP_64 for 
   AHCI) and disabling the bounce:


2) Disable queue bounce limit in drivers/scsi/scsi_lib.c

+#if 0
 blk_queue_bounce_limit(q, scsi_calculate_bounce_limit(shost));
+#endif

Mark had already asked me to try #1 a while back - and that didn't work.
So, I tried #2 - and now it doesn't hang for me went writing a large 
File (which was my error condition)...


So, as Linus suggested in his email, it looks like something 
is wrong in the bounce buffering? What - somebody will have

to look into this further...

..

That's a bit strange, actually.. because you said that this system
does not have any RAM at any addresses above 0x.
The physical RAM in this system is supposedly from 0 - 0x (4Gbytes).




-Original Message-
From: Mark Lord [mailto:[EMAIL PROTECTED] 
Sent: Monday, December 10, 2007 11:44 AM

To: Morrison, Tom
Cc: Jeff Garzik; linux-ide@vger.kernel.org; Tejun Heo; [EMAIL PROTECTED]
Subject: Re: Revisiting - 2.6.23.8 - Hang with sata_mv (7042) + Flat
4Gig (no holes) Memory

Morrison, Tom wrote:
..

To re-state the problem

Hardware/Configuration:
   MPC8548E with a 7042 (rev 2 - connected internal via a PEX switch) 
   2.6.23.8 (using PHYS_64BIT & PTE_64BIT - for 36 bit addressing

 & MSI is NOT compiled in)
   Flat 4Gig Memory Map (no holes - 0 - 0x0__ defined -

special

   low reserve memory is also used)

   Local Bus & PCI Express IOMem mapped to unique space in 
		0xC__ with extensions to the ioremap routines 
		to create the appropriate requested physical address...
		This is (and should be) transparent to the requesting 
		function that calls ioremap.


   2 SATA hard drives connected.

To recreate:
   Write a large file (now greater than >310Mbytes) - hangs
   and soft lockup is detected by kernel - no useful info 
   in stack trace...


Of interest:
   a) Replace sata_mv.c - with the 'old' Marvell's reference 
  driver and it works perfectly!!


   b) Also, sata_mv works perfectly in all conditions - if we boot
with 

  less than the ~3750M from the command line (which I note is

~below

  where its PEX IOmemory space is located).

..

Tom:  could you please try and follow the recent thread here (linux-ide)
entitled " Bug: get EXT3-fs error Allocating block in system zone ".

Somebody there has a similar problem on x86-32 with RAM above 4GB
using a standard AHCI SATA controller.

Jens has posted a couple of debugging patches there to try and isolate
things.
(patches attached here for convenience, though you'll have to
modify/hack
 the first one for sata_mv instead of ahci).

-ml

-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Responding to 2 thread <2.6.23.8 - Hang with sata_mv (7042)...> AND

2007-12-11 Thread Morrison, Tom
I am a little confused as to exactly what thread I am to respond to 
and/or what requests...but lets try this and see if I get close?

I have the  below mentioned hardware/configuration (flat 4Gig 
of DDR mem (0x0_000_ to 0x1_000_)...PPC/8548E - 36bit addressing

As can be seen below - Mark has asked me try patching my sata_mv 
(and scsi_lib) with some patches from the second thread in subject:

1) Disable 64bit DMA in sata_mv (equivalent of the CAP_64 for 
   AHCI) and disabling the bounce:

2) Disable queue bounce limit in drivers/scsi/scsi_lib.c

+#if 0
 blk_queue_bounce_limit(q, scsi_calculate_bounce_limit(shost));
+#endif

Mark had already asked me to try #1 a while back - and that didn't work.
So, I tried #2 - and now it doesn't hang for me went writing a large 
File (which was my error condition)...

So, as Linux suggested in his email, it looks like something 
is wrong in the bounce buffering? What - somebody will have
to look into this further...

Is that enough info Mark - let me know what you else you want me 
to try with my setup...

Tom

-Original Message-
From: Mark Lord [mailto:[EMAIL PROTECTED] 
Sent: Monday, December 10, 2007 11:44 AM
To: Morrison, Tom
Cc: Jeff Garzik; linux-ide@vger.kernel.org; Tejun Heo; [EMAIL PROTECTED]
Subject: Re: Revisiting - 2.6.23.8 - Hang with sata_mv (7042) + Flat
4Gig (no holes) Memory

Morrison, Tom wrote:
..
> To re-state the problem
> 
> Hardware/Configuration:
>MPC8548E with a 7042 (rev 2 - connected internal via a PEX switch) 
>2.6.23.8 (using PHYS_64BIT & PTE_64BIT - for 36 bit addressing
>  & MSI is NOT compiled in)
>Flat 4Gig Memory Map (no holes - 0 - 0x0__ defined -
special
>  low reserve memory is also used)
> 
>Local Bus & PCI Express IOMem mapped to unique space in 
>   0xC__ with extensions to the ioremap routines 
>   to create the appropriate requested physical address...
>   This is (and should be) transparent to the requesting 
>   function that calls ioremap.
>   
>2 SATA hard drives connected.
> 
> To recreate:
>Write a large file (now greater than >310Mbytes) - hangs
>and soft lockup is detected by kernel - no useful info 
>in stack trace...
> 
> Of interest:
>a) Replace sata_mv.c - with the 'old' Marvell's reference 
>   driver and it works perfectly!!
> 
>b) Also, sata_mv works perfectly in all conditions - if we boot
with 
>   less than the ~3750M from the command line (which I note is
~below
>   where its PEX IOmemory space is located).
..

Tom:  could you please try and follow the recent thread here (linux-ide)
entitled " Bug: get EXT3-fs error Allocating block in system zone ".

Somebody there has a similar problem on x86-32 with RAM above 4GB
using a standard AHCI SATA controller.

Jens has posted a couple of debugging patches there to try and isolate
things.
(patches attached here for convenience, though you'll have to
modify/hack
 the first one for sata_mv instead of ahci).

-ml

-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Iomega ZIP-100 drive unsupported with jmicron JMB361 chip?

2007-12-11 Thread Mark Lord

Mark Lord wrote:


I missed the early part of this thread,
but here is a data point that may or may not be useful.

I have an ASUS mobo here with an onboard JM363 SATA/PATA controller
(verified by looking at the actual chip).

It works fine when in AHCI mode with a PATA ATAPI ZIP100 drive
all by itself.  No other configurations tested.
This is with kernel 2.6.24-rc4-git?.

..

Oh yeah.. that's with libata controlling all drives in the system.

This exact same mobo was used for a while with a PATA DVD-RW (no ZIP drive)
under older kernels using drivers/IDE, but was unreliable in that configuration
(Ubuntu Edgy).   Ditto when the PATA DVD-RW was replaced with a SATA DVD-RW.

-ml
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Iomega ZIP-100 drive unsupported with jmicron JMB361 chip?

2007-12-11 Thread Mark Lord

trash can wrote:
..

Robert Hancock wrote:

That is rather curious. There's no sign of any libata error handling
going on.. Maybe the drive is actually returning that error code in the
ATAPI CDB, or at least we think it is?

You are sure that this drive still works with older kernels using
drivers/ide, and that the hardware didn't break at some point, I assume?


Thanks for your time. I get a kernel panic with the controller mode in BIOS
set to AHCI with Fedora Core 6. Once returned to IDE (setting used since
computer was built) I booted up. Added information: In Fedora 7 I can not
burn DVDs or CDROM using K3b with the Zip drive connected. Some
preformatting (I assume) is done rendering the CD/DVD useless then got an
I/O error. In Fedora 8 I am able to burn a CDROM using K3b but DVDs behave
as with Fedora 7. All is well when the Zip is totaly removed. This Zip
drive also worked under Microsoft 2000 { which was removed over a year
ago ;-) }. Fedora Core 6, Fedora 7, and Fedora 8 are all installed on
this machine. This drive did not work with a Ubuntu 7.10 Live CD on this
machine. I intend to try this Zip drive on another motherboard with the
above live CD.

...

I missed the early part of this thread,
but here is a data point that may or may not be useful.

I have an ASUS mobo here with an onboard JM363 SATA/PATA controller
(verified by looking at the actual chip).

It works fine when in AHCI mode with a PATA ATAPI ZIP100 drive
all by itself.  No other configurations tested.
This is with kernel 2.6.24-rc4-git?.

Cheers
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Iomega ZIP-100 drive unsupported with jmicron JMB361 chip?

2007-12-11 Thread trash can
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1



Robert Hancock wrote:
> That is rather curious. There's no sign of any libata error handling
> going on.. Maybe the drive is actually returning that error code in the
> ATAPI CDB, or at least we think it is?
> 
> You are sure that this drive still works with older kernels using
> drivers/ide, and that the hardware didn't break at some point, I assume?
> 
Thanks for your time. I get a kernel panic with the controller mode in BIOS
set to AHCI with Fedora Core 6. Once returned to IDE (setting used since
computer was built) I booted up. Added information: In Fedora 7 I can not
burn DVDs or CDROM using K3b with the Zip drive connected. Some
preformatting (I assume) is done rendering the CD/DVD useless then got an
I/O error. In Fedora 8 I am able to burn a CDROM using K3b but DVDs behave
as with Fedora 7. All is well when the Zip is totaly removed. This Zip
drive also worked under Microsoft 2000 { which was removed over a year
ago ;-) }. Fedora Core 6, Fedora 7, and Fedora 8 are all installed on
this machine. This drive did not work with a Ubuntu 7.10 Live CD on this
machine. I intend to try this Zip drive on another motherboard with the
above live CD.

- --RoyBoy626

Fedora Core 6 information (computer booted December 11th with Zip
disk inserted):
# uname -r
2.6.22.5-49.fc6

# blkid
/dev/hdb4: SEC_TYPE="msdos" LABEL="ZIP-100" UUID="-" TYPE="vfat"

from dmesg:
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
JMB361: IDE controller at PCI slot :03:00.1
PCI: Enabling device :03:00.1 ( -> 0001)
ACPI: PCI Interrupt :03:00.1[B] -> GSI 17 (level, low) -> IRQ 17
JMB361: chipset revision 2
JMB361: 100% native mode on irq 17
PCI: Setting latency timer of device :03:00.1 to 64
ide0: BM-DMA at 0xc400-0xc407, BIOS settings: hda:pio, hdb:pio
ide1: BM-DMA at 0xc408-0xc40f, BIOS settings: hdc:pio, hdd:pio
Probing IDE interface ide0...
hda: LITE-ON DVDRW SOHW-1693S, ATAPI CD/DVD-ROM drive
hdb: IOMEGA ZIP 100 ATAPI, ATAPI FLOPPY drive
hda: host side 80-wire cable detection failed, limiting max speed to UDMA33
hda: selected mode 0x42
hdb: selected mode 0x21
ide0 at 0xcc00-0xcc07,0xc882 on irq 17
Probing IDE interface ide1...
Probing IDE interface ide1...
ide-floppy driver 0.99.newide
hdb: 98304kB, 196608 blocks, 512 sector size
hdb: 98304kB, 96/64/32 CHS, 4096 kBps, 512 sector size, 2941 rpm
 hdb: hdb4

Manual mount: mount -t vfat /dev/hdb4 /mnt/zip
/var/log/messages response: Dec 11 10:12:43  kernel:  hdb: hdb4

]# df /mnt/zip
Filesystem   1K-blocks  Used Available Use% Mounted on
/dev/hdb498078 11782 86296  13% /mnt/zip

All is well in Fedora Core 6.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFHXq7dz1/aqdDsM3URAvV0AKDzd4PnK9/Bt7jao0OIsPrIAHxMVACfbzkY
feZlOXUDXZ9bmiArwsp+O78=
=1jws
-END PGP SIGNATURE-
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: PROBLEM: WARNING: at kernel/irq/manage.c:158 enable_irq() during boot

2007-12-11 Thread Wojciech Zareba
Hello,

Tejun Heo pisze:
> (cc'ing Bartlomiej)
> Hello,
> 
> [EMAIL PROTECTED] wrote:
>> Dec  6 11:58:23 titanium kernel: WARNING: at kernel/irq/manage.c:158 
>> enable_irq()
>> Dec  6 11:58:23 titanium kernel:  [] enable_irq+0x6e/0xa2
>> Dec  6 11:58:23 titanium kernel:  [] probe_hwif+0x6d8/0x7c7 
>> [ide_core]
>> Dec  6 11:58:23 titanium kernel:  [] 
>> probe_hwif_init_with_fixup+0xc/0x80 [ide_core]
>> Dec  6 11:58:23 titanium kernel:  [] elf_core_dump+0x627/0xb60
>> Dec  6 11:58:23 titanium kernel:  [] 
>> ide_setup_pci_device+0x6f/0x9c [ide_core]
>> Dec  6 11:58:23 titanium kernel:  [] pdc202new_init_one+0xf/0x10 
>> [pdc202xx_new]
>> Dec  6 11:58:23 titanium kernel:  [] pci_device_probe+0x36/0x55
>> Dec  6 11:58:23 titanium kernel:  [] driver_probe_device+0xc8/0x14b
>> Dec  6 11:58:23 titanium kernel:  [] __driver_attach+0x52/0x87
>> Dec  6 11:58:23 titanium kernel:  [] bus_for_each_dev+0x35/0x57
>> Dec  6 11:58:23 titanium kernel:  [] driver_attach+0x16/0x18
>> Dec  6 11:58:23 titanium kernel:  [] __driver_attach+0x0/0x87
>> Dec  6 11:58:23 titanium kernel:  [] bus_add_driver+0x6d/0x153
>> Dec  6 11:58:23 titanium kernel:  [] 
>> __pci_register_driver+0x4b/0x77
>> Dec  6 11:58:23 titanium kernel:  [] sys_init_module+0x1525/0x15fb
>> Dec  6 11:58:23 titanium kernel:  [] 
>> ide_config_drive_speed+0x0/0x314 [ide_core]
>> Dec  6 11:58:23 titanium kernel:  [] syscall_call+0x7/0xb
>> Dec  6 11:58:23 titanium kernel:  [] 
>> wireless_nlevent_process+0x15/0x31
>> Dec  6 11:58:23 titanium kernel:  ===
> 
> That means IRQ is being enabled more times than it should be.  Can you
> please give a shot at 2.6.24-rc4 and see whether the problem is still there?
> 
It seems to be no more of this warning in the 2.6.24-rc4 kernel. But my feeling
is that overall system performance is much poorer... pity. Maybe I should change
something in the .config file?

Regards
Wojciech

-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: SATA drive keeps hard resetting

2007-12-11 Thread Matí­as Alejandro Torres

Michael Tokarev escribió:


By the way, which drive it is?  If it's Seagate, pull out its
only jumper (factory preset) which limits it to SATAI.

/mjt
Thanks for your reply. It's a Hitachi HDS728080PLA380 80GB SATA drive. 
It's kind of old so it may show the bug you mention. I'll compile the 
kernel with that patch and tell you how it worked.


Matías
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH] sata_nv,adma: fix error when rmmod sata_nv

2007-12-11 Thread Kuan Luo
hi,
The below error happens when i rmmod sata_nv in adma mode on ck804
chipset with 2.6.24 kernel.
I traced the code and found that the driver attempts to write device mem
that has been unmapped.

Only simply removing the code" writew(0, mmio + NV_ADMA_CTL);" in the
nv_adma_port_stop function or remove .port_stop field in nv_adma_ops,
rmmod is ok.

static void nv_adma_port_stop(struct ata_port *ap)
{
struct nv_adma_port_priv *pp = ap->private_data;
void __iomem *mmio = pp->ctl_block;

VPRINTK("ENTER\n");
-   writew(0, mmio + NV_ADMA_CTL);
}

Or
 Place pcim_iomap_regions before ata_pci_prepare_native_host in
nv_init_one function.
This can guarantee that the code "writew(0, mmio + NV_ADMA_CTL) " write
device mem before the device mem is unmapped.

messages:
Dec 19 02:23:24 localhost kernel: ata16.00: disabled
Dec 19 02:23:24 localhost kernel: sd 15:0:0:0: [sda] Synchronizing SCSI
cache
Dec 19 02:23:24 localhost kernel: sd 15:0:0:0: [sda] Result:
hostbyte=0x04 driverbyte=0x00
Dec 19 02:23:24 localhost kernel: sd 15:0:0:0: [sda] Stopping disk
Dec 19 02:23:24 localhost kernel: sd 15:0:0:0: [sda] START_STOP FAILED
Dec 19 02:23:24 localhost kernel: sd 15:0:0:0: [sda] Result:
hostbyte=0x04 driverbyte=0x00
Dec 19 02:23:24 localhost kernel: BUG: unable to handle kernel paging
request at virtual address e881a4c0
Dec 19 02:23:24 localhost kernel: printing eip: e88224e9 *pde = 0180c067
*pte =  
Dec 19 02:23:24 localhost kernel: Oops: 0002 [#1] SMP 
Dec 19 02:23:24 localhost kernel: Modules linked in: sata_nv libata
Dec 19 02:23:24 localhost kernel: 
Dec 19 02:23:24 localhost kernel: Pid: 4915, comm: rmmod Not tainted
(2.6.24-rc1-ge2e031eb #2)
Dec 19 02:23:24 localhost kernel: EIP: 0060:[] EFLAGS:
00210292 CPU: 1
Dec 19 02:23:24 localhost kernel: EIP is at nv_adma_port_stop+0x3d/0x53
[sata_nv]
Dec 19 02:23:24 localhost kernel: EAX: 0015 EBX: e881a480 ECX:
00200046 EDX: 00200046
Dec 19 02:23:24 localhost kernel: ESI: c220b50c EDI: c1979154 EBP:
c197904c ESP: c2429ecc
Dec 19 02:23:24 localhost kernel:  DS: 007b ES: 007b FS: 00d8 GS: 0033
SS: 0068
Dec 19 02:23:24 localhost kernel: Process rmmod (pid: 4915, ti=c2428000
task=c25e5a40 task.ti=c2428000)
Dec 19 02:23:24 localhost kernel: Stack: e8823e1b e881a480 
e884398e c220b500 c18a3ec0 c1979154  
Dec 19 02:23:24 localhost kernel:c02818be c1979154 c197904c
000d c18a3ec0 c18a3a40 c197904c e88259d0 
Dec 19 02:23:24 localhost kernel:e88259d0 c2428000 c0281987
00200286 c197904c c027f8bb c1834600 c197904c 
Dec 19 02:23:24 localhost kernel: Call Trace:
Dec 19 02:23:24 localhost kernel:  []
ata_host_release+0x2f/0x92 [libata]
Dec 19 02:23:24 localhost kernel:  []
release_nodes+0x10f/0x12f
Dec 19 02:23:24 localhost kernel:  []
devres_release_all+0x27/0x2a
Dec 19 02:23:24 localhost kernel:  []
__device_release_driver+0x72/0x88
Dec 19 02:23:24 localhost kernel:  [] driver_detach+0x76/0xb3
Dec 19 02:23:24 localhost kernel:  []
bus_remove_driver+0x63/0x81
Dec 19 02:23:24 localhost kernel:  []
pci_unregister_driver+0xc/0x57
Dec 19 02:23:24 localhost kernel:  []
sys_delete_module+0x197/0x1bd
Dec 19 02:23:24 localhost kernel:  []
do_page_fault+0x202/0x581
Dec 19 02:23:24 localhost kernel:  [] do_munmap+0x193/0x1ac
Dec 19 02:23:24 localhost kernel:  []
sysenter_past_esp+0x5f/0x85
Dec 19 02:23:24 localhost kernel:  ===
Dec 19 02:23:24 localhost kernel: Code: 3e 82 e8 e8 b8 30 90 d7 89 5c 24
04 c7 04 24 0f 3e 82 e8 e8 a8 30 90 d7 8b 5b 10 c7 04 24 1b 3e 82 e8 89
5c 24 04 e8 95 30 90 d7 <66> c7 43 40 00 00 c7 04 24 29 3e 82 e8 e8 83
30 90 d7 5b 58 5b 
Dec 19 02:23:24 localhost kernel: EIP: []
nv_adma_port_stop+0x3d/0x53 [sata_nv] SS:ESP 0068:c2429ecc
---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Recent kernel hosing partition

2007-12-11 Thread For Junk Mail
On Tue, 2007-12-11 at 10:47 +0900, Tejun Heo wrote:
> Hello,
> 
[snip]
> 
> AFAIK, there currently isn't any known problem specific to VIA - Seagate
> combination.  sata_via surely has some issues on error conditions tho.

>From previous incarnations of the via chipset I've had errors on dma,
drive 'ringing' (where access/copying to hdb wakes up hda which says
"What's going on?" and confuses everything) from Seagate drives. One M/B
sat down and refused to work with 2 hard disks on the same ribbon. Maybe
I'm just one disenchanted luser but I had the logs to prove it in the
crashtesting days and they were examined by Mandrake's guys.
> 
> >>> Another issue here is that the old ide driver could get through the
> >>> mess, whereas the newer one cannot. I get "Drive reset: success" and the
> >>> old ide driver recovers, whereas the new one goes out to lunch. The log
> >>> snippets show a 60 seconds gap between errors. That's a 60 second freeze.
> >> Hmmm...
> >>
> >> 1. So, the IDE driver suffers from error conditions too?  Do you have
> >> logs around?
> >>
> 
> I meant the old driver/ide/* drivers.
> 
/checks every distro
YES! I have logs of errors with the old ide driver. When Fedora 7 went
out to lunch, I was embarassed for a kernel for my (previous) fedora 5,
and ended up using e2fsck from a uClibc based experimental distro from
 
http://kevux.org/

It has e2fsck-1.40.2, and some weird alternative log system. I'll send
the appropriate log privately as well as Fedora's log. Logs are dated.
The last errors in Kevux will correspond to a time shortly
after /usr/lib/firefox went missing in Fedora 7, as I went from one to
the other to sort the disk out. Do you understand me? 

I should be very clear. These errors occurred using the old driver on
hda3(sda3) while dealing with errors _caused_ by what you are trying to
investigate. Fedora 7 also had /dev/sda5 mounted as /home, and /dev/sda1
as /boot and not one error occurred on either of those. I checked the
whole disk with e2fsck at some points, and everything was fine.
Filesystems were modified, but nothing came to lost+found, or nothing
was corrupted to my knowledge except on sda3.

What upset me personally, btw, is that nobody in RedHat/Fedora gave an
. When you're finished, Slackware is going in
there :-D

> >> 2. Do you have logs of libata driver goes out to lunch?
> >>
> > Catch 22. Did you see the film? I've only one hard disk. Reset to get
> > out of trouble, so how does it log the disk going out to lunch?. Where
> > would I log it to?
> 
> Ah.. Catch 22 is name of a film.  I knew what it meant but never knew
> where the expression came from.  Anyways, in such cases, log is usually
> collected via serial or net console, usb or other storage if you have
> quasi working userland or digital cameras as a last resort.

Have you a doc on setting up such a log somewhere? I'll set one up. As
long as it doesn't queue in the ide cache. BTW, Catch-22 was also a
book, which I read. It was full of army tales. You didn't miss much,
imho. Knowing what it means is enough.
> 
[snip]
> > Typically, in an 'out to lunch' period, the line beginning 'exception
> > Emask' down as far as 'DPO or FUA' would repeat on stdout. Some disk
> > error would precede it, e.g. '/usr/lib/something.so: no such file or
> > directory'. That file would probably migrate to lost+found on the next
> > e2fsck pass and when I went to check it 2 reboots later it was indeed
> > missing. Then we got to the stage where the
> > entire /usr/lib/firefox/  directory migrated and we departed
> > from reality at that point.
> 
> Ah... I'd really like to see the log.

Sadly, there wasn't one. The box froze in X. I hit Ctrl_Alt_F1. I saw
/usr/lib/firefox-2.0.0.9/firefox-bin: No such file or directory
Followed by the error (Emask ... --> DPO or FUA)
e2fsck found illegal inodes, loose inodes, inodes claimed by 2 programs,
counts all over the place. It restarted itself after stage 2, and I
nearly blew a gasket because stage1 had the badblocks option set :-(. I
saw A, B, & C to some of these 5 stages that I never saw before. I'll
privately send you the /var/log/messages in it's entirety, which is all
the Fedora 7 recorded data. I know linux-ide will bounce it. The _last_
set of errors in the file will be that time
when /usr/lib/firefox-2.0.0.9/ went awol.


Subsequent to that outage I compiled binutils, uClibc, installed linux
headers, and finally crashed out on a repeatable error in compiling gcc
using somebody's scripts in Fedora 7. But I couldn't run X, because
gnome and every X program was borked by this error. I'd get X (the grey
screen) and then things went sadly wrong in gnome.

> 
> > If we can provoke the error, I feel the way to trap it is
> > 1. make intelligent recoverable changes to ide partition /dev/sda3 on
> > firefox files.
> > 2. Directly or indirectly, Mount my 1 gig usb disk on /var/log :-D.
> > Would that get around the Catch-22? I can stick in another (old) disk if
> > needed, but I only have 

Re: SATA drive keeps hard resetting

2007-12-11 Thread Michael Tokarev
Matí­as Alejandro Torres wrote:
> Hi all,
> 
> I have a SATA drive in a motherboard with an ATI SB600 chipset that
> until now worked just fine.
> The disk seems fine but after a while it start making noises (like
> spinning up) and the computer freezes during 2 or 3 seconds. I think my
> SATA drive is broken, or maybe the motherboard. This is what dmesg says:
> 
> [  229.096000] ata4: exception Emask 0x10 SAct 0x0 SErr 0x90200 action 0x6 
> frozen

See http://marc.info/?l=linux-ide&m=119707355016060&w=2
...
> I'm using Ubuntu 7.10 with kernel 2.6.22-14-generic in a dual processor
> computer. Below there's some hardware information. The output of dmesg
> is attached. Thanks!

That patch will not apply cleanly to 2.6.22 - it will show rejects
in libata-core.c.  Those are OK - it's a cleanup of wrongly blacklisted
drives.  The main part - in ahci.c - is the one that's needed.

> [  229.096000] ata4: (irq_stat 0x0040, PHY RDY changed)
> [  229.096000] ata4: hard resetting port
> [  233.40] ata4: SATA link up 1.5 Gbps (SStatus 113 SControl 300)

By the way, which drive it is?  If it's Seagate, pull out its
only jumper (factory preset) which limits it to SATAI.

/mjt
-
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html