libata total system lockup fix
Jeff,
We corresponded about this bugfix ages ago, but I find I'm still patching it into each new kernel.org kernel to keep my system from locking up hard in the libata error handling path.
(error handling is triggered by the KDE/Gnome desktop polling the empty ATAPI drive every second or two, gets an error when no disc inserted, thereby triggering SCSI/libata error paths, which lock system hard once in a few thousand tries -- about once every two hours).
This patch originally came to me from you, and I've now forgotten where you got it from. But it does fix the problem here. I have also circulated this patch among many other users of "ata_piix" on modern laptops, and it seems to cure random lockups for them as well.
This configuration (2.6 kernel, ata_piix driving hard disk and DVD-RW drive in a Centrino laptop) is now very very commonplace, and the lockups are driving users crazy.
Sure would be nice to see it in 2.6.13 or 2.6.14 by default.
Cheers
Signature · 3 lines
Mark Lord Real-Time Remedies Inc. [email protected]
drivers/scsi/libata-core.c +9 -4
@@ -41,6 +41,7 @@#include <scsi/scsi.h> #include "scsi.h" #include "scsi_priv.h" +#include "scsi_logging.h" #include <scsi/scsi_host.h> #include <linux/libata.h> #include <asm/io.h>
@@ -2803,6 +2804,11 @@DPRINTK ("EXIT\n" ); } +void ata_qc_timeout_done (struct scsi_cmnd *scmd) +{ +return ; +} +/** * ata_qc_timeout - Handle timeout of queued command * @qc: Command that timed out
@@ -2835,17 +2841,16 @@struct scsi_cmnd *cmd = qc->scsicmd;if (!scsi_eh_eflags_chk (cmd,SCSI_EH_CANCEL_CMD )) { -/* finish completing original command */ + qc->scsidone = ata_qc_timeout_done; +__ata_qc_complete (qc);atapi_request_sense (ap, dev, cmd); cmd->result = (CHECK_CONDITION <<1 ) | (DID_OK <<16 ); -scsi_finish_command (cmd); - - goto out; } + goto out; }/* hack alert! We cannot use the supplied completion
drivers/scsi/libata-scsi.c +0 -6
@@ -380,12 +380,6 @@ ap = (struct ata_port *) &host->hostdata[0 ]; ap->ops->eng_timeout (ap); -/* TODO: this is per-command; when queueing is supported -* this code will either change or move to a more -* appropriate place -*/ - host->host_failed--; -DPRINTK ("EXIT\n" );return 0 ; }
drivers/scsi/scsi_error.c +36 -3
@@ -1613,6 +1613,40 @@scsi_eh_flush_done_q (&eh_done_q); } +static void scsi_invoke_strategy_handler (struct Scsi_Host *shost) +{ +int rtn; +struct list_head *lh, *lh_sf; +struct scsi_cmnd *scmd; +unsigned long flags; +LIST_HEAD (eh_work_q); +LIST_HEAD (eh_done_q); + + rtn = shost->hostt->eh_strategy_handler (shost); + +spin_lock_irqsave (shost->host_lock, flags); +list_splice_init (&shost->eh_cmd_q, &eh_work_q); +spin_unlock_irqrestore (shost->host_lock, flags); + +SCSI_LOG_ERROR_RECOVERY (1 ,scsi_eh_prt_fail_stats (shost, &eh_work_q)); + +list_for_each_safe (lh, lh_sf, &eh_work_q) { + scmd = list_entry(lh, struct scsi_cmnd, eh_entry); + +if (scsi_eh_eflags_chk (scmd,SCSI_EH_CANCEL_CMD ) || + !SCSI_SENSE_VALID (scmd)) +continue ; + scmd->retries = scmd->allowed; +scsi_eh_finish_cmd (scmd, &eh_done_q); + } + +if (!list_empty (&eh_work_q)) +if (!scsi_eh_abort_cmds (&eh_work_q, &eh_done_q)) +scsi_eh_ready_devs (shost, &eh_work_q, &eh_done_q); + +scsi_eh_flush_done_q (&eh_done_q); +} +/** * scsi_error_handler - Handle errors/timeouts of SCSI cmds. * @data: Host for which we are running.
@@ -1627,7 +1661,6 @@int scsi_error_handler (void *data) {struct Scsi_Host *shost = (struct Scsi_Host *) data; -int rtn;DECLARE_MUTEX_LOCKED (sem);/*
@@ -1683,8 +1716,8 @@* what we need to do to get it up and online again (if we can). * If we fail, we end up taking the thing offline. */ -if (shost->hostt->eh_strategy_handler) - rtn = shost->hostt->eh_strategy_handler (shost); +if (shost->hostt->eh_strategy_handler) +scsi_invoke_strategy_handler (shost);else scsi_unjam_host (shost);
Quoted 19 lines · Mark Lord
Jeff,
We corresponded about this bugfix ages ago, but I find I'm still patching it into each new kernel.org kernel to keep my system from locking up hard in the libata error handling path.
(error handling is triggered by the KDE/Gnome desktop polling the empty ATAPI drive every second or two, gets an error when no disc inserted, thereby triggering SCSI/libata error paths, which lock system hard once in a few thousand tries -- about once every two hours).
This patch originally came to me from you, and I've now forgotten where you got it from. But it does fix the problem here. I have also circulated this patch among many other users of "
ata_piix" on modern laptops, and it seems to cure random lockups for them as well.
Quoted 5 lines
This configuration (2.6 kernel,
ata_piixdriving hard disk and DVD-RW drive in a Centrino laptop) is now very very commonplace, and the lockups are driving users crazy.Sure would be nice to see it in 2.6.13 or 2.6.14 by default.
The problem with this patch is that is causes leaks, and doesn't actually ready the devices because scsi_eh_ready_devs() is never called: scsi_eh_abort_cmds() is guaranteed to fail out every time its called.
So it just trades one set of failures for another. I don't dispute that lockups SUCK but someone (me? noone else is stepping up) needs to look into fixing it.
When I finish up SATA ATAPI today, I'll put this on the short list.
Jeff
Quoted 1 line
The problem with this patch is that is causes leaks, and doesn't actually ready the devices because
scsi_eh_ready_devs()is never called:scsi_eh_abort_cmds()is guaranteed to fail out every time its called.
MMmm.. bummer if that's the case, but it does execute here on my machine about once every two seconds, continuously, for hours on end, and the DVD-RW drive still works when I eventually do place a disc into it later on.
I suppose the bug isn't seen more commonly because libata is the only (?) SCSI LLD that supplies it's own eh strategy function. Or are there other users of that interface now?
I'm off on holiday for the next while, but I'll check in on this again when I get back. Perhaps the originator of this patch could chip in with some of the fixes, if you point out where the "leaks" are.
Quoted 7 lines
Ahha.. here's the header from the original email for this patch
Subject: [PATCH] Fix SATA ATAPI error handling
From: Hannes Reinecke <[email protected]>
Date: Wed, 23 Mar 2005 16:28:16 +0100
To: SCSI Mailing List <[email protected]>
CC: [email protected], Jeff Garzik <[email protected]>, Jens Axboe <[email protected]>, Kurt Garloff <[email protected]>:
Cheers
Quoted 8 lines · Mark Lord
Quoted 1 line
The problem with this patch is that is causes leaks, and doesn't
actually ready the devices because
scsi_eh_ready_devs()is never called:scsi_eh_abort_cmds()is guaranteed to fail out every time its called.MMmm.. bummer if that's the case, but it does execute here on my machine about once every two seconds, continuously, for hours on end, and the DVD-RW drive still works when I eventually do place a disc into it later on.
Quoted 16 lines
I suppose the bug isn't seen more commonly because libata is the only (?) SCSI LLD that supplies it's own eh strategy function. Or are there other users of that interface now?
I'm off on holiday for the next while, but I'll check in on this again when I get back. Perhaps the originator of this patch could chip in with some of the fixes, if you point out where the "leaks" are.
Quoted 7 lines
Ahha.. here's the header from the original email for this patch
Subject: [PATCH] Fix SATA ATAPI error handling
From: Hannes Reinecke <[email protected]>
Date: Wed, 23 Mar 2005 16:28:16 +0100
To: SCSI Mailing List <[email protected]>
CC: [email protected], Jeff Garzik <[email protected]>, Jens Axboe <[email protected]>, Kurt Garloff <[email protected]>:
Hello, Mark Lord.
I think I've hit similar scsi-eh lockup problem during development of
new EH/NCQ helpers. I currently don't remember where it exactly looped, but I recall that scmds jumped back and forth between two lists, one of which being eh_cmd_q which isn't cleared properly by SATA's strategy routine. Anyways, I'm attaching an one liner quick fix, which I'm not sure if it will work or not. Also, I'll post a combined patch of my new EH/NCQ helpers in a separate mail, which, hopefully, should be free of this issue.
Please try out these two and let me know how they go. Here's the one
liner against v2.6.12.
drivers/scsi/libata-scsi.c +1 -0
@@ -385,6 +385,7 @@ int ata_scsi_error(struct Scsi_Host *hos* appropriate place */ host->host_failed--; +INIT_LIST_HEAD (&host->eh_cmd_q);DPRINTK ("EXIT\n" );return 0 ;
Quoted 29 lines · Tejun Heo
Quoted 9 lines · Mark Lord
Quoted 1 line
The problem with this patch is that is causes leaks, and doesn't
actually ready the devices because
scsi_eh_ready_devs()is never called:scsi_eh_abort_cmds()is guaranteed to fail out every time its called.MMmm.. bummer if that's the case, but it does execute here on my machine about once every two seconds, continuously, for hours on end, and the DVD-RW drive still works when I eventually do place a disc into it later on.
Quoted 16 lines
I suppose the bug isn't seen more commonly because libata is the only (?) SCSI LLD that supplies it's own eh strategy function. Or are there other users of that interface now?
I'm off on holiday for the next while, but I'll check in on this again when I get back. Perhaps the originator of this patch could chip in with some of the fixes, if you point out where the "leaks" are.
Quoted 7 lines
Ahha.. here's the header from the original email for this patch
Subject: [PATCH] Fix SATA ATAPI error handling
From: Hannes Reinecke <[email protected]>
Date: Wed, 23 Mar 2005 16:28:16 +0100
To: SCSI Mailing List <[email protected]>
CC: [email protected], Jeff Garzik <[email protected]>, Jens Axboe <[email protected]>, Kurt Garloff <[email protected]>:Hello, Mark Lord.
Quoted 9 lines
I think I've hit similar scsi-eh lockup problem during development of
new EH/NCQ helpers. I currently don't remember where it exactly looped, but I recall that scmds jumped back and forth between two lists, one of which beingeh_cmd_qwhich isn't cleared properly by SATA's strategy routine. Anyways, I'm attaching an one liner quick fix, which I'm not sure if it will work or not. Also, I'll post a combined patch of my new EH/NCQ helpers in a separate mail, which, hopefully, should be free of this issue.
And this is the combined patch against ncq head of libata-dev-2.6
tree. Commit d032ec9048ff82a704b96b93cfd6f2e8e3a06b19.
Only ata_piix, sata_sil and ahci are converted and all other SATA
drivers are broken. So, enable only those three SATA drivers when compiling with this patch.
drivers/scsi/libata-core.c +582 -207
@@ -49,6 +49,10 @@#include "libata.h" +#define ata_for_each_tag (tag, mask) \ + for (tag = find_first_bit(&mask, ATA_MAX_CMDS); tag < ATA_MAX_CMDS; \ + tag = find_next_bit(&mask, ATA_MAX_CMDS, tag + 1)) +static unsigned int ata_busy_sleep (struct ata_port *ap,unsigned long tmout_pat,unsigned long tmout);
@@ -59,7 +63,6 @@ static int fgb(u32 bitmap);static int ata_choose_xfer_mode (struct ata_port *ap,u8 *xfer_mode_out,unsigned int *xfer_shift_out); -static int ata_qc_complete_noop (struct ata_queued_cmd *qc,u8 drv_stat);static void __ata_qc_complete (struct ata_queued_cmd *qc);static unsigned int ata_unique_id =1 ;
@@ -70,6 +73,87 @@ MODULE_DESCRIPTION("Library module for AMODULE_LICENSE ("GPL" );MODULE_VERSION (DRV_VERSION ); +static void ata_qc_complete_noop (struct ata_queued_cmd *qc) +{ +/* noop */ +} + +static void ata_qc_exec_special_timeout (unsigned long data) +{ +struct completion *wait = (void *)data; +complete (wait); +} + +/** +* ata_qc_exec_special - execute libata internal special command +* @qc: Command to execute +* @tmout: timeout in jiffies +* +* Executes libata internal command with timeout. Timeout and +* error conditions are reported via return value. No recovery +* action is taken after a command times out. It's caller's duto +* to clean up after timeout. +* +* Also, note that error condition is checked after the qc is +* completed, meaning that if another command is issued before +* checking the condition, we get the wrong values. As special +* cmds are used only for initialization and recovery, this +* won't cause any problem currently. +* +* LOCKING: +* None. Should be called with kernel context, might sleep. +*/ + +static int ata_qc_exec_special (struct ata_queued_cmd *qc,unsigned long tmout) +{ +struct ata_port *ap = qc->ap; +DECLARE_COMPLETION (wait); +struct timer_list timer; +int rc; + +might_sleep (); + +if (ata_busy_sleep (ap,ATA_TMOUT_SPECIAL_QUICK ,ATA_TMOUT_SPECIAL )) +return -ETIMEDOUT ; + + qc->complete_fn = ata_qc_complete_noop; + qc->waiting = &wait; + +if (tmout) { +init_timer (&timer); + timer.function = ata_qc_exec_special_timeout; + timer.data = (unsigned long )&wait; + timer.expires = jiffies + tmout; +add_timer (&timer); + } + +spin_lock_irq (&ap->host_set->lock); + rc =ata_qc_issue (qc); +spin_unlock_irq (&ap->host_set->lock); + +if (rc) { +if (tmout) +del_timer (&timer); +return -EAGAIN ;/* any better value for issue failure? */ + } + +wait_for_completion (&wait); + +if (tmout && !del_timer (&timer)) { +spin_lock_irq (&ap->host_set->lock); +if (qc->waiting == &wait) { +ata_qc_complete (qc); + rc = -ETIMEDOUT ; + } +spin_unlock_irq (&ap->host_set->lock); + } + +if (rc ==0 && !ata_ok (ata_chk_status (ap))) + rc = -EIO ; + +return rc; +} +/** * ata_tf_load - send taskfile registers to host controller * @ap: Port to which output is sent
@@ -1126,9 +1210,7 @@ static void ata_dev_identify(struct ata_unsigned long xfer_modes;u8 status;unsigned int using_edd; -DECLARE_COMPLETION (wait);struct ata_queued_cmd *qc; -unsigned long flags;int rc;if (!ata_dev_present (dev)) {
@@ -1166,20 +1248,19 @@ retry:DPRINTK ("do ATAPI identify\n" ); } - qc->waiting = &wait; - qc->complete_fn = ata_qc_complete_noop; + rc =ata_qc_exec_special (qc,ATA_TMOUT_IDENTIFY ); -spin_lock_irqsave (&ap->host_set->lock, flags); - rc =ata_qc_issue (qc); -spin_unlock_irqrestore (&ap->host_set->lock, flags); +switch (rc) { +case 0 : +break ; +case -EIO : +/* Device failed the command */ + status =ata_chk_status (ap); -if (rc) - goto err_out; -else -wait_for_completion (&wait); +if (!(status &ATA_ERR )) +/* Weird error condition, give up */ + goto err_out; - status =ata_chk_status (ap); -if (status &ATA_ERR ) {/* * arg! EDD works for all test cases, but seems to return * the ATA signature for some ATAPI devices. Until the
@@ -1202,6 +1283,9 @@ retry: goto retry; } } +/* Fall through */ +default : +/* Issue failed or some other error */ goto err_out; }
@@ -1326,10 +1410,7 @@ int ata_read_log_page(struct ata_port *a char *buffer, unsigned int sectors) {struct ata_device *dev = &ap->device[device]; -DECLARE_COMPLETION (wait);struct ata_queued_cmd *qc; -unsigned long flags; -int rc;assert (dev->class ==ATA_DEV_ATA );
@@ -1347,18 +1428,53 @@ int ata_read_log_page(struct ata_port *a qc->tf.lbal = page; qc->flags |=ATA_QCFLAG_PREEMPT ; - qc->waiting = &wait; - qc->complete_fn = ata_qc_complete_noop; +return ata_qc_exec_special (qc,ATA_TMOUT_READLOG ); +} -spin_lock_irqsave (&ap->host_set->lock, flags); - rc =ata_qc_issue (qc); -spin_unlock_irqrestore (&ap->host_set->lock, flags); +/** +* ata_eh_qc_complete - Complete an ATA command from EH +* @qc: Command to complete +* @drv_stat: ATA Status register contents +* @drv_err: ATA Error register contents +* +* This function is used in EH to complete commands. +* +* HACK ALERT! We cannot use the supplied completion function +* from inside the ->eh_strategy_handler() thread. libata is the +* only user of ->eh_strategy_handler() in any kernel, so the +* default scsi_done() assumes it is not being called from the +* SCSI EH. +* +* LOCKING: +* None. Called from EH. +*/ -if (rc) -return -EIO ; +void ata_eh_qc_complete (struct ata_queued_cmd *qc) +{ +BUG_ON (!(qc->ap->flags &ATA_FLAG_RECOVERY )); -wait_for_completion (&wait); -return 0 ; + qc->scsidone = scsi_finish_command; +__ata_qc_complete (qc); +} + +/** +* ata_eh_qc_retry - Retry an ATA command from EH. +* @qc: Command to complete +* +* This function is used in EH to complete commands. +* +* HACK ALERT! See ata_eh_qc_complete. +* +* LOCKING: +* None. Called from EH. +*/ + +void ata_eh_qc_retry (struct ata_queued_cmd *qc) +{ +BUG_ON (!(qc->ap->flags &ATA_FLAG_RECOVERY )); + + qc->scsidone = (void *)scsi_retry_command; +__ata_qc_complete (qc); }/**
@@ -2133,10 +2249,8 @@ static int ata_choose_xfer_mode(struct astatic void ata_dev_set_xfermode (struct ata_port *ap,struct ata_device *dev) { -DECLARE_COMPLETION (wait);struct ata_queued_cmd *qc;int rc; -unsigned long flags;/* set up set-features taskfile */ DPRINTK ("set features - xfer mode\n" );
@@ -2150,17 +2264,13 @@ static void ata_dev_set_xfermode(struct qc->tf.protocol =ATA_PROT_NODATA ; qc->tf.nsect = dev->xfer_mode; - qc->waiting = &wait; - qc->complete_fn = ata_qc_complete_noop; - -spin_lock_irqsave (&ap->host_set->lock, flags); - rc =ata_qc_issue (qc); -spin_unlock_irqrestore (&ap->host_set->lock, flags); - -if (rc) + rc =ata_qc_exec_special (qc,ATA_TMOUT_SET_XFERMODE ); +if (rc) { +printk (KERN_ERR "ata%u: failed to set xfermode, disabling... " +"(rc=%d stat=0x%x err=0x%x)\n" , + ap->id, rc,ata_chk_status (ap),ata_chk_err (ap));ata_port_disable (ap); -else -wait_for_completion (&wait); + }DPRINTK ("EXIT\n" ); }
@@ -2530,7 +2640,7 @@ static void ata_pio_complete (struct ataata_irq_on (ap); -ata_qc_complete (qc, drv_stat); +ata_qc_complete (qc); }
@@ -2755,7 +2865,10 @@ static void ata_pio_block(struct ata_porata_irq_on (ap); -ata_qc_complete (qc, status); +if (!(status & (ATA_ERR |ATA_DRQ ))) +ata_qc_complete (qc); +else +ata_qc_error (qc);return ; }
@@ -2787,7 +2900,7 @@ static void ata_pio_error(struct ata_porata_irq_on (ap); -ata_qc_complete (qc, drv_stat |ATA_ERR ); +ata_qc_error (qc); }static void ata_pio_task (void *_data)
@@ -2828,9 +2941,7 @@ static void ata_pio_task(void *_data)static void atapi_request_sense (struct ata_port *ap,struct ata_device *dev,struct scsi_cmnd *cmd) { -DECLARE_COMPLETION (wait);struct ata_queued_cmd *qc; -unsigned long flags;int rc;DPRINTK ("ATAPI request sense\n" );
@@ -2855,31 +2966,34 @@ static void atapi_request_sense(struct a qc->tf.lbam = (8 *1024 ) &0xff ; qc->tf.lbah = (8 *1024 ) >>8 ; qc->nbytes =SCSI_SENSE_BUFFERSIZE ; + qc->flags |=ATA_QCFLAG_PREEMPT ; - qc->waiting = &wait; - qc->complete_fn = ata_qc_complete_noop; - -spin_lock_irqsave (&ap->host_set->lock, flags); - rc =ata_qc_issue (qc); -spin_unlock_irqrestore (&ap->host_set->lock, flags); + rc =ata_qc_exec_special (qc,ATA_TMOUT_REQUEST_SENSE ); +if (rc) { +printk (KERN_WARNING "ata%u: failed to read sense data " +"(rc=%d stat=0x%x err=0x%x)\n" , + ap->id, rc,ata_chk_status (ap),ata_chk_err (ap)); +/* +* If this happens, we're returning w/ NULL sense +* data. Upper layer can handle it. +*/ + } -if (rc) -ata_port_disable (ap); -else -wait_for_completion (&wait); + cmd->result =SAM_STAT_CHECK_CONDITION ;DPRINTK ("EXIT\n" ); }/** -* ata_qc_timeout - Handle timeout of queued command -* @qc: Command that timed out +* ata_error_handler - Handle error or timeout of queued command +* @ap: Port on which the command is active * -* Some part of the kernel (currently, only the SCSI layer) -* has noticed that the active command on port @ap has not -* completed after a specified length of time. Handle this -* condition by disabling DMA (if necessary) and completing -* transactions, with error if necessary. +* The driver reported error or some part of the kernel +* (currently, only the SCSI layer) has noticed that the active +* command on port @ap has not completed after a specified length +* of time. Handle this condition by disabling DMA (if +* necessary) and completing transactions, with error if +* necessary. * * This also handles the case of the "lost interrupt", where * for some reason (possibly hardware bug, possibly driver bug)
@@ -2890,102 +3004,65 @@ static void atapi_request_sense(struct a* Inherited from SCSI layer (none, can sleep) */ -static void ata_qc_timeout (struct ata_queued_cmd *qc) +void ata_error_handler (struct ata_port *ap) { -struct ata_port *ap = qc->ap; -struct ata_device *dev = qc->dev; -u8 host_stat =0 , drv_stat; +struct ata_queued_cmd *qc; +u8 host_stat =0 , drv_stat, drv_err;DPRINTK ("ENTER\n" ); -/* FIXME: doesn't this conflict with timeout handling? */ -if (qc->dev->class ==ATA_DEV_ATAPI && qc->scsicmd) { -struct scsi_cmnd *cmd = qc->scsicmd; - -if (!scsi_eh_eflags_chk (cmd,SCSI_EH_CANCEL_CMD )) { - -/* finish completing original command */ -__ata_qc_complete (qc); - -atapi_request_sense (ap, dev, cmd); - - cmd->result = (CHECK_CONDITION <<1 ) | (DID_OK <<16 ); -scsi_finish_command (cmd); - - goto out; - } + qc =ata_qc_from_tag (ap, ap->active_tag); +if (!qc) { +printk (KERN_ERR "ata%u: BUG: timeout without command\n" , + ap->id); + goto out; } -/* hack alert! We cannot use the supplied completion -* function from inside the ->eh_strategy_handler() thread. -* libata is the only user of ->eh_strategy_handler() in -* any kernel, so the default scsi_done() assumes it is -* not being called from the SCSI EH. -*/ - qc->scsidone = scsi_finish_command; - -switch (qc->tf.protocol) { - -case ATA_PROT_DMA : -case ATA_PROT_ATAPI_DMA : - host_stat = ap->ops->bmdma_status (ap); - -/* before we do anything else, clear DMA-Start bit */ - ap->ops->bmdma_stop (ap); - -/* fall through */ - -default : -ata_altstatus (ap); +if (qc->flags &ATA_QCFLAG_ERROR ) { drv_stat =ata_chk_status (ap); + drv_err =ata_chk_err (ap); + }else { +/* +* Okay, command has timed out. Currently all we do +* is stopping the dma engine. Maybe performing +* ->phy_reset is useful to make the device online +* again. However, this was all that the original +* code did, so, for now, leave it as it is. +*/ +switch (qc->tf.protocol) { -/* ack bmdma irq events */ - ap->ops->irq_clear (ap); +case ATA_PROT_DMA : +case ATA_PROT_ATAPI_DMA : + host_stat = ap->ops->bmdma_status (ap); -printk (KERN_ERR "ata%u: command 0x%x timeout, stat 0x%x host_stat 0x%x\n" , - ap->id, qc->tf.command, drv_stat, host_stat); +/* before we do anything else, clear DMA-Start bit */ + ap->ops->bmdma_stop (ap); -/* complete taskfile transaction */ -ata_qc_complete (qc, drv_stat); -break ; - } -out: -DPRINTK ("EXIT\n" ); -} +/* fall through */ -/** -* ata_eng_timeout - Handle timeout of queued command -* @ap: Port on which timed-out command is active -* -* Some part of the kernel (currently, only the SCSI layer) -* has noticed that the active command on port @ap has not -* completed after a specified length of time. Handle this -* condition by disabling DMA (if necessary) and completing -* transactions, with error if necessary. -* -* This also handles the case of the "lost interrupt", where -* for some reason (possibly hardware bug, possibly driver bug) -* an interrupt was not delivered to the driver, even though the -* transaction completed successfully. -* -* LOCKING: -* Inherited from SCSI layer (none, can sleep) -*/ +default : +ata_altstatus (ap); + drv_stat =ata_chk_status (ap); + drv_err =ata_chk_err (ap); -void ata_eng_timeout (struct ata_port *ap) -{ -struct ata_queued_cmd *qc; +/* ack bmdma irq events */ + ap->ops->irq_clear (ap); -DPRINTK ("ENTER\n" ); +printk (KERN_ERR "ata%u: command 0x%x timeout, stat 0x%x host_stat 0x%x\n" , + ap->id, qc->tf.command, drv_stat, host_stat); +break ; + } + } - qc =ata_qc_from_tag (ap, ap->active_tag); -if (!qc) { -printk (KERN_ERR "ata%u: BUG: timeout without command\n" , - ap->id); - goto out; +if (qc->scsicmd) { +if (qc->dev->class ==ATA_DEV_ATA || + !(qc->flags &ATA_QCFLAG_ERROR )) +ata_to_sense_error (qc, drv_stat, drv_err); +else +atapi_request_sense (ap, qc->dev, qc->scsicmd); } -ata_qc_timeout (qc); +ata_eh_qc_complete (qc); out:DPRINTK ("EXIT\n" );
@@ -3049,100 +3126,142 @@ struct ata_queued_cmd *ata_qc_new_init(sreturn qc; } -static int ata_qc_complete_noop (struct ata_queued_cmd *qc,u8 drv_stat) -{ -return 0 ; -} +/** +* ata_qc_free - free unused ata_queued_cmd +* @qc: Command to complete +* +* Designed to free unused ata_queued_cmd object +* in case something prevents using it. +* +* LOCKING: +* spin_lock_irqsave(host_set lock) +* +*/ -static void __ata_qc_complete (struct ata_queued_cmd *qc) +void ata_qc_free (struct ata_queued_cmd *qc) {struct ata_port *ap = qc->ap; -unsigned int tag, do_clear =0 ; +unsigned int tag = qc->tag; + +assert (ata_tag_valid (qc->tag));if (likely (qc->flags &ATA_QCFLAG_ACTIVE )) { -assert (ap->queue_depth); - ap->queue_depth--; +assert (ap->flags &ATA_FLAG_INFLIGHT ); -if (!ap->queue_depth) - ap->flags &= ~ATA_FLAG_NCQ_QUEUED ; +if (ap->active_tag ==ATA_TAG_POISON ) { +assert (ap->sactive & (1 << tag)); + ap->sactive &= ~(1 << tag); +if (!ap->sactive) + ap->flags &= ~ATA_FLAG_INFLIGHT ; + }else { +assert (ap->active_tag == tag && + (qc->flags &ATA_QCFLAG_PREEMPT || !ap->sactive)); + ap->active_tag = ap->preempted_tag; + ap->preempted_tag =ATA_TAG_POISON ; +if (ap->active_tag ==ATA_TAG_POISON && !ap->sactive) + ap->flags &= ~ATA_FLAG_INFLIGHT ; + } } qc->flags =0 ; - tag = qc->tag; -if (likely (ata_tag_valid (tag))) { -if (tag == ap->active_tag) - ap->active_tag =ATA_TAG_POISON ; - qc->tag =ATA_TAG_POISON ; - do_clear =1 ; - } - -if (qc->waiting) { -struct completion *waiting = qc->waiting; - qc->waiting =NULL ; -complete (waiting); - } + qc->tag =ATA_TAG_POISON ; -if (likely (do_clear)) -clear_bit (tag, &ap->qactive); +clear_bit (tag, &ap->qactive);if (ap->cmd_waiters)wake_up (&ap->cmd_wait_queue); } +static void __ata_qc_complete (struct ata_queued_cmd *qc) +{ +struct completion *waiting = qc->waiting; + +assert (qc !=NULL );/* ata_qc_from_tag _might_ return NULL */ +assert (qc->flags &ATA_QCFLAG_ACTIVE ); + +if (likely (qc->flags &ATA_QCFLAG_DMAMAP )) +ata_sg_clean (qc); + +/* call completion callback */ + qc->complete_fn (qc); +/* for special cmd timeout synchronization */ + qc->waiting =NULL ; + +ata_qc_free (qc); + +if (waiting) +complete (waiting); + +VPRINTK ("EXIT\n" ); +} +/** -* ata_qc_free - free unused ata_queued_cmd +* ata_qc_complete - Complete an active ATA command * @qc: Command to complete * -* Designed to free unused ata_queued_cmd object -* in case something prevents using it. +* Indicate to the mid and upper layers that an ATA +* command has completed, with either an ok or not-ok status. * * LOCKING: * spin_lock_irqsave(host_set lock) * */ -void ata_qc_free (struct ata_queued_cmd *qc) +void ata_qc_complete (struct ata_queued_cmd *qc) { -assert (qc !=NULL );/* ata_qc_from_tag _might_ return NULL */ -assert (qc->waiting ==NULL );/* nothing should be waiting */ +if (unlikely ((qc->flags &ATA_QCFLAG_ERROR || + qc->ap->flags &ATA_FLAG_RECOVERY ) && + !(qc->flags &ATA_QCFLAG_PREEMPT ))) { +printk (KERN_WARNING "ata%u: ignoring command completion for " +"tag %u during recovery\n" , qc->ap->id, qc->tag); +return ; + }__ata_qc_complete (qc); }/** -* ata_qc_complete - Complete an active ATA command -* @qc: Command to complete -* @drv_stat: ATA Status register contents +* ata_qc_error - Invoke error handler +* @qc: Command which failed * -* Indicate to the mid and upper layers that an ATA -* command has completed, with either an ok or not-ok status. +* Invoke EH for a failed qc. * * LOCKING: * spin_lock_irqsave(host_set lock) * */ -void ata_qc_complete (struct ata_queued_cmd *qc,u8 drv_stat) +void ata_qc_error (struct ata_queued_cmd *qc) { -int rc; - -assert (qc !=NULL );/* ata_qc_from_tag _might_ return NULL */ -assert (qc->flags &ATA_QCFLAG_ACTIVE ); - -if (likely (qc->flags &ATA_QCFLAG_DMAMAP )) -ata_sg_clean (qc); - -/* call completion callback */ - rc = qc->complete_fn (qc, drv_stat); - -/* if callback indicates not to complete command (non-zero), -* return immediately -*/ -if (unlikely (rc !=0 )) +if (unlikely ((qc->flags &ATA_QCFLAG_ERROR || + qc->ap->flags &ATA_FLAG_RECOVERY ) && + !(qc->flags &ATA_QCFLAG_PREEMPT ))) { +printk (KERN_WARNING "ata%u: ignoring command error for " +"tag %u during recovery\n" , qc->ap->id, qc->tag);return ; + } -__ata_qc_complete (qc); - qc->flags &= ~ATA_QCFLAG_ACTIVE ; +if (qc->scsicmd) { +/* +* SCSI command. Invoke SCSI EH +*/ +printk (KERN_WARNING "ata%u: requesting check condition for " +"failed scmd %p tag %u\n" , + qc->ap->id, qc->scsicmd, qc->tag); -VPRINTK ("EXIT\n" ); + qc->flags |=ATA_QCFLAG_ERROR ; + qc->ap->flags |=ATA_FLAG_ERROR ; + + qc->scsicmd->result =SAM_STAT_CHECK_CONDITION ; + qc->scsidone (qc->scsicmd); + }else { +/* +* libata internal command. No tender and kind error +* handling yet. Just finish'em. +*/ +printk (KERN_WARNING "ata%u: finishing internal command tag %u " +"with error\n" , qc->ap->id, qc->tag); +BUG_ON (qc->flags &ATA_QCFLAG_NCQ ); +ata_qc_complete (qc); + } }static inline int ata_should_dma_map (struct ata_queued_cmd *qc)
@@ -3179,6 +3298,14 @@ static inline int ata_qc_issue_ok(struct {if (qc->flags &ATA_QCFLAG_PREEMPT )return 1 ; + +/* +* If error handling is in progress, only preempt commands are +* allowed. +*/ +if (qc->ap->flags & (ATA_FLAG_ERROR |ATA_FLAG_RECOVERY )) +return 0 ; +/* * if people are already waiting for a queue drain, don't allow a * new 'lucky' queuer to get in there
@@ -3189,7 +3316,7 @@ static inline int ata_qc_issue_ok(struct/* * If nothing is queued, it's always ok to continue. */ -if (!ap->queue_depth) +if (!(ap->flags &ATA_FLAG_INFLIGHT ))return 1 ;/*
@@ -3203,7 +3330,7 @@ static inline int ata_qc_issue_ok(struct* Command is NCQ, allow it to be queued if the commands that are * currently running are also NCQ */ -if (ap->flags &ATA_FLAG_NCQ_QUEUED ) +if (ap->sactive)return 1 ;return 0 ;
@@ -3281,13 +3408,25 @@ int ata_qc_issue(struct ata_queued_cmd * ap->ops->qc_prep (qc); - qc->ap->active_tag = qc->tag; qc->flags |=ATA_QCFLAG_ACTIVE ; -if (qc->flags &ATA_QCFLAG_NCQ ) - ap->flags |=ATA_FLAG_NCQ_QUEUED ; +assert (ap->preempted_tag ==ATA_TAG_POISON ); - ap->queue_depth++; +if (!(qc->flags &ATA_QCFLAG_PREEMPT )) { +assert (ap->active_tag ==ATA_TAG_POISON ); + +if (qc->flags &ATA_QCFLAG_NCQ ) + ap->sactive |=1 << qc->tag; +else { +assert (!ap->sactive); + ap->active_tag = qc->tag; + } + }else { + ap->preempted_tag = ap->active_tag; + ap->active_tag = qc->tag; + } + + ap->flags |=ATA_FLAG_INFLIGHT ; rc = ap->ops->qc_issue (qc);if (rc !=ATA_QC_ISSUE_OK )
@@ -3655,7 +3794,10 @@ inline unsigned int ata_host_intr (struc ap->ops->irq_clear (ap);/* complete taskfile transaction */ -ata_qc_complete (qc, status); +if (!(status & (ATA_ERR |ATA_DRQ ))) +ata_qc_complete (qc); +else +ata_qc_error (qc);break ;default :
@@ -3723,6 +3865,236 @@ irqreturn_t ata_interrupt (int irq, voidreturn IRQ_RETVAL (handled); } +/* +* NCQ helpers +*/ + +/** +* ata_ncq_complete - NCQ driver helper. Complete requests normally. +* @ap: port in question +* +* Complete in-flight commands. One device per port is assumed. +* This functions is meant to be called from specific driver's +* interrupt routine to complete requests normally. On +* invocation, if non-NCQ command was in-flight, it's completed +* normally. If NCQ commands were in-flight, Sactive register is +* read and completed commands are processed. +* +* LOCKING: +* spin_lock_irqsave(host_set lock) +*/ +int ata_ncq_complete (struct ata_port *ap) +{ +int nr_done =0 ; +unsigned long done_mask =0 ; +unsigned tag; + +/* +* ap->active_tag test should come before ap->sactive test to +* complete EH requests. +*/ +if (ap->active_tag !=ATA_TAG_POISON ) + done_mask =1 << ap->active_tag; +else if (ap->sactive) { +unsigned long new_sactive =scr_read (ap,SCR_ACTIVE ); + done_mask = new_sactive ^ ap->sactive; + +if (unlikely (done_mask & new_sactive)) { +printk (KERN_ERR "ata%u: illegal sactive transition (%08lx->%08lx)\n" , + ap->id, ap->sactive, new_sactive); + done_mask &= ~new_sactive; + } + } + +ata_for_each_tag (tag, done_mask) { +struct ata_queued_cmd *qc =ata_qc_from_tag (ap, tag); +assert (qc); +ata_qc_complete (qc); + nr_done++; + } + +return nr_done; +} + +/** +* ata_ncq_error - NCQ driver helper. Abort commands and invoke EH. +* @ap: port in question. +* +* Abort in-flight commands and invoke EH. This function is +* meant to be called from specific driver's interrupt routine to +* indicate error. +* +* LOCKING: +* spin_lock_irqsave(host_set lock) +*/ + +int ata_ncq_error (struct ata_port *ap) +{ +int nr_aborted =0 ; +unsigned long sactive =0 ; +unsigned tag; + +printk (KERN_WARNING "ata%u: aborting commands due to error. " +"active_tag %d, sactive %08lx\n" , + ap->id, + ap->active_tag !=ATA_TAG_POISON ? ap->active_tag :-1 , + ap->sactive); + +/* +* ap->active_tag test should come before ap->sactive test to +* complete EH requests. +*/ +if (ap->active_tag !=ATA_TAG_POISON ) + sactive =1 << ap->active_tag; +else if (ap->sactive) { +/* Complete successful requests before aborting. */ +ata_ncq_complete (ap); +if (!ap->sactive) +printk (KERN_WARNING "ata%u: device reports successful " +"completion of all NCQ commands after error\n" , + ap->id); + sactive = ap->sactive; + } + +ata_for_each_tag (tag, sactive) { +struct ata_queued_cmd *qc =ata_qc_from_tag (ap, tag); +assert (qc); +ata_qc_error (qc); + nr_aborted++; + } + +return nr_aborted; +} + +static inline int ata_read_log_10h (struct ata_port *ap,unsigned *tagp, +u8 *drv_statp,u8 *drv_errp) +{ +char *buffer; +int rc; + + buffer =kmalloc (512 ,GFP_KERNEL ); +if (buffer ==NULL ) { +printk (KERN_ERR "ata%u: unable to allocate memory for error\n" , + ap->id); +return -ENOMEM ; + } + + rc =ata_read_log_page (ap,0 ,READ_LOG_SATA_NCQ_PAGE , buffer,1 ); +if (rc <0 ) { +printk (KERN_ERR "ata%u: failed to read log page 10h (%d)\n" , + ap->id, rc); + goto out; + } + +if (buffer[0 ] &0x80 ) { +printk (KERN_WARNING "ata%u: NQ bit set on log page 10h\n" , + ap->id); + rc = -EIO ; + goto out; + } + + *tagp = buffer[0 ] &0x1f ; + *drv_statp = buffer[2 ] |ATA_ERR ; + *drv_errp = buffer[3 ]; + rc =0 ; + out: +kfree (buffer); +return rc; +} + +/** +* ata_ncq_recover - NCQ driver helper. Recover from error. +* @ap: port in question +* @did_reset: specific driver performed reset. Log page 10h might +* be invalid. +* +* This function is to be called from eng_timeout routine of +* specific drivers. Before calling this function, specific +* drivers are required to +* +* - Clear all in-flight requests. Drivers only have to clear +* low-level state (like stopping DMA engine and clearing +* interrupts). All generic command cancelling are dealt by +* libata-core layer. +* +* - Make the controller ready for new commands. +* +* LOCKING: +* Inherited from SCSI layer (in EH context, can sleep) +*/ +void ata_ncq_recover (struct ata_port *ap,int did_reset) +{ +unsigned ncq_abort_tag =ATA_TAG_POISON ; +u8 stat =0 , err =0 ; +unsigned long sactive; +unsigned tag; + +DPRINTK ("ENTER\n" ); + + stat =ata_chk_status (ap); + err =ata_chk_err (ap); + +/* +* if commands have timed out or DRQ/BSY is set, device needs +* to be reset. +*/ +if (!(ap->flags &ATA_FLAG_ERROR ) || stat & (ATA_BUSY |ATA_DRQ )) { +printk (KERN_WARNING "ata%u: stat=%x, issuing COMRESET\n" , ap->id, stat); + ap->ops->phy_reset (ap); + did_reset =1 ; + } + +if (ap->sactive) { +if (ap->flags &ATA_FLAG_ERROR ) { +u8 tstat, terr; +/* +* Regardless of did_reset, we read log page +* 10h. The drive might need it to restart +* operation. If did_reset, we ignore the +* result. +*/ +if (ata_read_log_10h (ap, &tag, &tstat, &terr) ==0 ) { +printk (KERN_INFO "ata%u: log_ext_10h, tag=%d " +"stat=%02x err=%02x%s\n" , + ap->id, tag, tstat, terr, + did_reset ?" (ignored due to reset)" :"" ); +if (!did_reset) { + ncq_abort_tag = tag; + stat = tstat; + err = terr; + } + }else { +printk (KERN_WARNING "ata%u: resetting...\n" , + ap->id); + ap->ops->phy_reset (ap); + } + } + sactive = ap->sactive; + }else + sactive =1 << ap->active_tag; + +ata_for_each_tag (tag, sactive) { +struct ata_queued_cmd *qc =ata_qc_from_tag (ap, tag); +assert (qc); +if (ncq_abort_tag !=ATA_TAG_POISON && tag != ncq_abort_tag) { +ata_eh_qc_retry (qc); +continue ; + } + +if (qc->scsicmd) { +if (qc->dev->class ==ATA_DEV_ATA || + !(qc->flags &ATA_QCFLAG_ERROR )) +ata_to_sense_error (qc, stat |ATA_ERR , err); +else +atapi_request_sense (ap, qc->dev, qc->scsicmd); + } + +ata_eh_qc_complete (qc); + } + +DPRINTK ("EXIT\n" ); +} +/** * atapi_packet_task - Write CDB bytes to hardware * @_data: Port to which ATAPI device is attached.
@@ -3780,7 +4152,7 @@ static void atapi_packet_task(void *_datreturn ; err_out: -ata_qc_complete (qc,ATA_ERR ); +ata_qc_error (qc); }
@@ -3900,6 +4272,7 @@ static void ata_host_init(struct ata_por ap->ops = ent->port_ops; ap->cbl =ATA_CBL_NONE ; ap->active_tag =ATA_TAG_POISON ; + ap->preempted_tag =ATA_TAG_POISON ;init_waitqueue_head (&ap->cmd_wait_queue); ap->cmd_waiters =0 ; ap->last_ctl =0xFF ;
@@ -4538,7 +4911,7 @@ EXPORT_SYMBOL_GPL(ata_sg_init);EXPORT_SYMBOL_GPL (ata_sg_init_one);EXPORT_SYMBOL_GPL (ata_qc_complete);EXPORT_SYMBOL_GPL (ata_qc_issue_prot); -EXPORT_SYMBOL_GPL (ata_eng_timeout); +EXPORT_SYMBOL_GPL (ata_error_handler);EXPORT_SYMBOL_GPL (ata_tf_load);EXPORT_SYMBOL_GPL (ata_tf_read);EXPORT_SYMBOL_GPL (ata_noop_dev_select);
@@ -4574,10 +4947,12 @@ EXPORT_SYMBOL_GPL(ata_dev_classify);EXPORT_SYMBOL_GPL (ata_dev_id_string);EXPORT_SYMBOL_GPL (ata_scsi_simulate);EXPORT_SYMBOL_GPL (ata_scsi_change_queue_depth); -EXPORT_SYMBOL_GPL (ata_scsi_block_requests); -EXPORT_SYMBOL_GPL (ata_scsi_unblock_requests); -EXPORT_SYMBOL_GPL (ata_scsi_requeue);EXPORT_SYMBOL_GPL (ata_read_log_page); +EXPORT_SYMBOL_GPL (ata_eh_qc_complete); +EXPORT_SYMBOL_GPL (ata_eh_qc_retry); +EXPORT_SYMBOL_GPL (ata_ncq_complete); +EXPORT_SYMBOL_GPL (ata_ncq_error); +EXPORT_SYMBOL_GPL (ata_ncq_recover);#ifdef CONFIG_PCI EXPORT_SYMBOL_GPL (pci_test_config_bits);
include/linux/libata.h +23 -13
@@ -116,25 +116,33 @@ enum {ATA_FLAG_SATA_RESET = (1 <<7 ),/* use COMRESET */ ATA_FLAG_PIO_DMA = (1 <<8 ),/* PIO cmds via DMA */ ATA_FLAG_NCQ = (1 <<9 ),/* Can do NCQ */ -ATA_FLAG_NCQ_QUEUED = (1 <<10 ),/* NCQ commands are queued */ +ATA_FLAG_INFLIGHT = (1 <<10 ),/* Command(s) in flight */ +ATA_FLAG_ERROR = (1 <<11 ),/* Error met and EH scheduled */ +ATA_FLAG_RECOVERY = (1 <<12 ),/* Recovery in progress */ ATA_QCFLAG_ACTIVE = (1 <<1 ),/* cmd not yet ack'd to scsi lyer */ ATA_QCFLAG_SG = (1 <<3 ),/* have s/g table? */ ATA_QCFLAG_SINGLE = (1 <<4 ),/* no s/g, just a single buffer */ ATA_QCFLAG_DMAMAP =ATA_QCFLAG_SG |ATA_QCFLAG_SINGLE ,ATA_QCFLAG_NCQ = (1 <<5 ),/* using NCQ */ -ATA_QCFLAG_PREEMPT = (1 <<6 ),/* for error handling */ +ATA_QCFLAG_ERROR = (1 <<6 ),/* this qc has failed w/ error */ +ATA_QCFLAG_PREEMPT = (1 <<7 ),/* for error handling */ ATA_QC_ISSUE_OK =0 ,ATA_QC_ISSUE_FATAL =-1 ,/* various lengths of time */ -ATA_TMOUT_EDD =5 *HZ ,/* hueristic */ ATA_TMOUT_PIO =30 *HZ ,ATA_TMOUT_BOOT =30 *HZ ,/* hueristic */ ATA_TMOUT_BOOT_QUICK =7 *HZ ,/* hueristic */ ATA_TMOUT_CDB =30 *HZ ,ATA_TMOUT_CDB_QUICK =5 *HZ , +ATA_TMOUT_SPECIAL =30 *HZ , +ATA_TMOUT_SPECIAL_QUICK =5 *HZ , +ATA_TMOUT_IDENTIFY =5 *HZ ,/* hueristic */ +ATA_TMOUT_READLOG =5 *HZ ,/* hueristic */ +ATA_TMOUT_SET_XFERMODE =5 *HZ ,/* hueristic */ +ATA_TMOUT_REQUEST_SENSE =5 *HZ ,/* hueristic */ /* ATA bus states */ BUS_UNKNOWN = 0,
@@ -179,7 +187,7 @@ struct ata_port;struct ata_queued_cmd ;/* typedefs */ -typedef int (*ata_qc_cb_t ) (struct ata_queued_cmd *qc,u8 drv_stat); +typedef void (*ata_qc_cb_t ) (struct ata_queued_cmd *qc);struct ata_ioports {unsigned long cmd_addr;
@@ -315,9 +323,8 @@ struct ata_port {struct ata_device device[ATA_MAX_DEVICES ];struct ata_queued_cmd qcmd[ATA_MAX_CMDS ]; -unsigned long qactive; -unsigned int active_tag; -unsigned int queue_depth; +unsigned long qactive, sactive; +unsigned int active_tag, preempted_tag;wait_queue_head_t cmd_wait_queue;unsigned int cmd_waiters;
@@ -362,7 +369,7 @@ struct ata_port_operations {void (*qc_prep) (struct ata_queued_cmd *qc);int (*qc_issue) (struct ata_queued_cmd *qc); -void (*eng_timeout) (struct ata_port *ap); +void (*error_handler) (struct ata_port *ap);irqreturn_t (*irq_handler)(int ,void *,struct pt_regs *);void (*irq_clear) (struct ata_port *);
@@ -439,8 +446,9 @@ extern void ata_bmdma_start (struct ata_extern void ata_bmdma_stop (struct ata_port *ap);extern u8 ata_bmdma_status (struct ata_port *ap);extern void ata_bmdma_irq_clear (struct ata_port *ap); -extern void ata_qc_complete (struct ata_queued_cmd *qc,u8 drv_stat); -extern void ata_eng_timeout (struct ata_port *ap); +extern void ata_qc_complete (struct ata_queued_cmd *qc); +extern void ata_qc_error (struct ata_queued_cmd *qc); +extern void ata_error_handler (struct ata_port *ap);extern void ata_scsi_simulate (u16 *id,struct scsi_cmnd *cmd,void (*done)(struct scsi_cmnd *)); extern int ata_std_bios_param(struct scsi_device *sdev,
@@ -448,11 +456,13 @@ extern int ata_std_bios_param(struct scs sector_t capacity, int geom[]);extern int ata_scsi_slave_config (struct scsi_device *sdev);extern int ata_scsi_change_queue_depth (struct scsi_device *,int ); -extern void ata_scsi_block_requests (struct ata_port *); -extern void ata_scsi_unblock_requests (struct ata_port *); -extern void ata_scsi_requeue (struct ata_queued_cmd *);extern int ata_read_log_page (struct ata_port *,unsigned int ,char ,char *,unsigned int ); +extern void ata_eh_qc_complete (struct ata_queued_cmd *qc); +extern void ata_eh_qc_retry (struct ata_queued_cmd *qc); +extern int ata_ncq_complete (struct ata_port *ap); +extern int ata_ncq_error (struct ata_port *ap); +extern void ata_ncq_recover (struct ata_port *ap,int did_reset);#ifdef CONFIG_PCI
drivers/scsi/libata-scsi.c +78 -84
271 lines not on this page · raw message
drivers/scsi/ata_piix.c +2 -2
@@ -146,7 +146,7 @@ static struct ata_port_operations piix_p .qc_prep = ata_qc_prep, .qc_issue = ata_qc_issue_prot, - .eng_timeout = ata_eng_timeout, + .error_handler = ata_error_handler, .irq_handler = ata_interrupt, .irq_clear = ata_bmdma_irq_clear,
@@ -174,7 +174,7 @@ static struct ata_port_operations piix_s .qc_prep = ata_qc_prep, .qc_issue = ata_qc_issue_prot, - .eng_timeout = ata_eng_timeout, + .error_handler = ata_error_handler, .irq_handler = ata_interrupt, .irq_clear = ata_bmdma_irq_clear,
drivers/scsi/sata_sil.c +1 -1
@@ -154,7 +154,7 @@ static struct ata_port_operations sil_op .bmdma_status = ata_bmdma_status, .qc_prep = ata_qc_prep, .qc_issue = ata_qc_issue_prot, - .eng_timeout = ata_eng_timeout, + .error_handler = ata_error_handler, .irq_handler = ata_interrupt, .irq_clear = ata_bmdma_irq_clear, .scr_read = sil_scr_read,
drivers/scsi/libata.h +1 -1
@@ -47,7 +47,7 @@ extern void swap_buf_le16(u16 *buf, unsi/* libata-scsi.c */ -extern void ata_to_sense_error (struct ata_queued_cmd *qc,u8 drv_stat); +extern void ata_to_sense_error (struct ata_queued_cmd *qc,u8 drv_stat,u8 drv_err);extern int ata_scsi_error (struct Scsi_Host *host);extern unsigned int ata_scsiop_inq_std (struct ata_scsi_args *args,u8 *rbuf,unsigned int buflen);
drivers/scsi/ahci.c +60 -305
425 lines not on this page · raw message
Quoted 6 lines · Tejun Heo
And this is the combined patch against ncq head of libata-dev-2.6
tree. Commitd032ec9048ff82a704b96b93cfd6f2e8e3a06b19.Only
ata_piix,sata_siland ahci are converted and all other SATA
drivers are broken. So, enable only those three SATA drivers when compiling with this patch.
Overall, the approach of adding a timeout to the 'special' commands is a good, and necessary approach.
Comments follow...
Quoted 69 lines
Index:
work/drivers/scsi/libata-core.c
===================================================================drivers/scsi/libata-core.c +46
-1@@ -49,6 +49,10 @@#include "libata.h" +#define ata_for_each_tag (tag, mask) \ + for (tag = find_first_bit(&mask, ATA_MAX_CMDS); tag < ATA_MAX_CMDS; \ + tag = find_next_bit(&mask, ATA_MAX_CMDS, tag + 1)) +static unsigned int ata_busy_sleep (struct ata_port *ap,unsigned long tmout_pat,unsigned long tmout);@@ -59,7 +63,6 @@ static int fgb(u32 bitmap);static int ata_choose_xfer_mode (struct ata_port *ap,u8 *xfer_mode_out,unsigned int *xfer_shift_out); -static int ata_qc_complete_noop (struct ata_queued_cmd *qc,u8 drv_stat);static void __ata_qc_complete (struct ata_queued_cmd *qc);static unsigned int ata_unique_id =1 ;@@ -70,6 +73,87 @@ MODULE_DESCRIPTION("Library module for AMODULE_LICENSE ("GPL" );MODULE_VERSION (DRV_VERSION ); +static void ata_qc_complete_noop (struct ata_queued_cmd *qc) +{ +/* noop */ +} + +static void ata_qc_exec_special_timeout (unsigned long data) +{ +struct completion *wait = (void *)data; +complete (wait); +} + +/** +* ata_qc_exec_special - execute libata internal special command +* @qc: Command to execute +* @tmout: timeout in jiffies +* +* Executes libata internal command with timeout. Timeout and +* error conditions are reported via return value. No recovery +* action is taken after a command times out. It's caller's duto +* to clean up after timeout. +* +* Also, note that error condition is checked after the qc is +* completed, meaning that if another command is issued before +* checking the condition, we get the wrong values. As special +* cmds are used only for initialization and recovery, this +* won't cause any problem currently. +* +* LOCKING: +* None. Should be called with kernel context, might sleep. +*/ + +static int ata_qc_exec_special (struct ata_queued_cmd *qc,unsigned long tmout) +{ +struct ata_port *ap = qc->ap; +DECLARE_COMPLETION (wait); +struct timer_list timer; +int rc; + +might_sleep (); + +if (ata_busy_sleep (ap,ATA_TMOUT_SPECIAL_QUICK ,ATA_TMOUT_SPECIAL )) +return -ETIMEDOUT ;
drivers/scsi/libata-core.c MODULE_DESCRIPTION("Library module for A · line 127
Quoted 10 lines
drivers/scsi/libata-core.c +10
-0+ + qc->complete_fn = ata_qc_complete_noop; + qc->waiting = &wait; + +if (tmout) { +init_timer (&timer); + timer.function = ata_qc_exec_special_timeout; + timer.data = (unsigned long )&wait; + timer.expires = jiffies + tmout; +add_timer (&timer);
Just use mod_timer(), and combine these last two lines into a single one.
drivers/scsi/libata-core.c MODULE_DESCRIPTION("Library module for A · line 136
Quoted 7 lines
drivers/scsi/libata-core.c +7
-0+spin_lock_irq (&ap->host_set->lock); + rc =ata_qc_issue (qc); +spin_unlock_irq (&ap->host_set->lock); + +if (rc) { +if (tmout) +del_timer (&timer);
Use del_timer_sync() here, and for every case where you are not inside a spinlock.
Quoted 6 lines
drivers/scsi/libata-core.c +6
-0+return -EAGAIN ;/* any better value for issue failure? */ + } + +wait_for_completion (&wait); + +if (tmout && !del_timer (&timer)) {
drivers/scsi/libata-core.c MODULE_DESCRIPTION("Library module for A · line 152
Quoted 10 lines
drivers/scsi/libata-core.c +10
-0+spin_lock_irq (&ap->host_set->lock); +if (qc->waiting == &wait) { +ata_qc_complete (qc); + rc = -ETIMEDOUT ; + } +spin_unlock_irq (&ap->host_set->lock); + } + +if (rc ==0 && !ata_ok (ata_chk_status (ap))) + rc = -EIO ;
General comment on libata: we should move away from using the Status register directly, and more towards an indication that the taskfile described by the queue_cmd is in error. i.e. add an 'error' flag or something like that.
The rest seems fairly sane.
General comment on libata error handling: as soon as SATA ATAPI is complete, we can move libata to using SCSI's fine-grained error handling hooks (eh_{abort,timeout,bus,host}_handler), which will make error handling easier, and avoid the problems that keep cropping up with the ->eh_strategy_handler() approach.
Jeff
Hello, Jeff.
The patch I posted in this thread is just collapsed version of the
following patchset.
http://marc.theaimsgroup.com/?l=linux-ide&m=112074204019013&w=2
Above post has it splitted over 11 patches and has proper explanations.
Quoted 93 lines · Jeff Garzik
Quoted 6 lines · Tejun Heo
And this is the combined patch against ncq head of libata-dev-2.6
tree. Commitd032ec9048ff82a704b96b93cfd6f2e8e3a06b19.Only
ata_piix,sata_siland ahci are converted and all other SATA
drivers are broken. So, enable only those three SATA drivers when compiling with this patch.Overall, the approach of adding a timeout to the 'special' commands is a good, and necessary approach.
Comments follow...
Quoted 78 lines
Index:
work/drivers/scsi/libata-core.c
===================================================================
---work.orig/drivers/scsi/libata-core.c2005-08-05
12:55:08.000000000 +0900
+++work/drivers/scsi/libata-core.c2005-08-05 12:55:50.000000000
+0900drivers/scsi/libata-core.c +4
-0@@ -49,6 +49,10 @@#include "libata.h" +#define ata_for_each_tag (tag, mask) \ + for (tag = find_first_bit(&mask, ATA_MAX_CMDS); tag <ATA_MAX_CMDS ; \ + tag = find_next_bit(&mask, ATA_MAX_CMDS, tag + 1)) + static unsigned int ata_busy_sleep (struct ata_port *ap, unsigned long tmout_pat,unsigned long tmout);drivers/scsi/libata-core.c +47
-1@@ -59,7 +63,6 @@ static int fgb(u32 bitmap);static int ata_choose_xfer_mode (struct ata_port *ap,u8 *xfer_mode_out,unsigned int *xfer_shift_out); -static int ata_qc_complete_noop (struct ata_queued_cmd *qc,u8 drv_stat);static void __ata_qc_complete (struct ata_queued_cmd *qc);static unsigned int ata_unique_id =1 ;@@ -70,6 +73,87 @@ MODULE_DESCRIPTION("Library module for AMODULE_LICENSE ("GPL" );MODULE_VERSION (DRV_VERSION ); +static void ata_qc_complete_noop (struct ata_queued_cmd *qc) +{ +/* noop */ +} + +static void ata_qc_exec_special_timeout (unsigned long data) +{ +struct completion *wait = (void *)data; +complete (wait); +} + +/** +* ata_qc_exec_special - execute libata internal special command +* @qc: Command to execute +* @tmout: timeout in jiffies +* +* Executes libata internal command with timeout. Timeout and +* error conditions are reported via return value. No recovery +* action is taken after a command times out. It's caller's duto +* to clean up after timeout. +* +* Also, note that error condition is checked after the qc is +* completed, meaning that if another command is issued before +* checking the condition, we get the wrong values. As special +* cmds are used only for initialization and recovery, this +* won't cause any problem currently. +* +* LOCKING: +* None. Should be called with kernel context, might sleep. +*/ + +static int ata_qc_exec_special (struct ata_queued_cmd *qc,unsigned long tmout) +{ +struct ata_port *ap = qc->ap; +DECLARE_COMPLETION (wait); +struct timer_list timer; +int rc; + +might_sleep (); + +if (ata_busy_sleep (ap,ATA_TMOUT_SPECIAL_QUICK ,ATA_TMOUT_SPECIAL )) +return -ETIMEDOUT ; + + qc->complete_fn = ata_qc_complete_noop; + qc->waiting = &wait; + +if (tmout) {
Quoted 9 lines
drivers/scsi/libata-core.c MODULE_DESCRIPTION("Library module for A · line 127
Quoted 5 lines
drivers/scsi/libata-core.c +5
-0+init_timer (&timer); + timer.function = ata_qc_exec_special_timeout; + timer.data = (unsigned long )&wait; + timer.expires = jiffies + tmout; +add_timer (&timer);Just use
mod_timer(), and combine these last two lines into a single one.
Sure.
Quoted 10 lines
drivers/scsi/libata-core.c MODULE_DESCRIPTION("Library module for A · line 136
Quoted 8 lines
drivers/scsi/libata-core.c +7
-0+spin_lock_irq (&ap->host_set->lock); + rc =ata_qc_issue (qc); +spin_unlock_irq (&ap->host_set->lock); + +if (rc) { +if (tmout) +del_timer (&timer);
Quoted 2 lines
Use
del_timer_sync()here, and for every case where you are not inside a spinlock.
Oops, right, timer is on stack. Sorry.
Quoted 21 lines
Quoted 7 lines
drivers/scsi/libata-core.c +6
-0+return -EAGAIN ;/* any better value for issue failure? */ + } + +wait_for_completion (&wait); + +if (tmout && !del_timer (&timer)) {drivers/scsi/libata-core.c MODULE_DESCRIPTION("Library module for A · line 152
Quoted 10 lines
drivers/scsi/libata-core.c +10
-0+spin_lock_irq (&ap->host_set->lock); +if (qc->waiting == &wait) { +ata_qc_complete (qc); + rc = -ETIMEDOUT ; + } +spin_unlock_irq (&ap->host_set->lock); + } + +if (rc ==0 && !ata_ok (ata_chk_status (ap))) + rc = -EIO ;General comment on libata: we should move away from using the Status register directly, and more towards an indication that the taskfile described by the
queue_cmdis in error. i.e. add an 'error' flag or something like that.
Quoted 4 lines
The rest seems fairly sane.
General comment on libata error handling: as soon as SATA ATAPI is complete, we can move libata to using SCSI's fine-grained error handling hooks (eh_{abort,timeout,bus,host}_handler), which will make error handling easier, and avoid the problems that keep cropping up with the ->eh_strategy_handler() approach.
I don't think ->eh_strategy_handler approach is troublesome
inherently. We just haven't been doing things required to use it properly. IMHO, it's cleaner for libata to implement separate EH strategy than using SCSI EH. Also, If you're still considering separating out SATA from SCSI, integrating tightly w/ SCSI EH wouldn't be such a good idea.
In new EH, libata error handlers can expect two things...
* _All_ errors are handled in EH thread.
* Once any error has occurred, all normal processing stops until error
condition is cleared by EH.
I think above two assumptions are the basics of IO error handling and
thus can/should be met by any block device infrastructure. This way, individual error_handler implementation is cleaner/simpler, and, when finally migrating, only glueing codes need be modified. If you look at the current implementation, most glueing chores are done inside libata-scsi.c:ata_scsi_error().
So, can you please reconsider new EH? It might have some bugs
currently, but, IMHO, it's heading the right direction. Also, Jens and I hammered new EH w/ various NCQ/ATAPI errors and new EH did quite okay.
Thanks.
Signature · 1 line
tejun
Quoted 4 lines · Tejun Heo
* _All_ errors are handled in EH thread.
* Once any error has occurred, all normal processing stops until error
condition is cleared by EH.
Do you mean "all normal processing" for that channel stops, or *ALL* processing on all libata channels stops?
Obviously the former, I presume.
Cheers
Signature · 3 lines
Mark Lord Real-Time Remedies Inc. [email protected]
Quoted 8 lines · Mark Lord
Quoted 4 lines · Tejun Heo
* _All_ errors are handled in EH thread.
* Once any error has occurred, all normal processing stops until
error condition is cleared by EH.
Quoted 6 lines
Do you mean "all normal processing" for that channel stops, or *ALL* processing on all libata channels stops?
Obviously the former, I presume.
Cheers
Yeah, the former of course. ;-) Error state is indicated by one of
the followings.
* ATA_FLAG_ERROR : one or more errors have occurred and EH is
scheduled to run.
* ATA_FLAG_RECOVERY : EH in progress
When either of above flags is set, only commands w/ ATA_QCFLAG_PREEMPT
flag set gets to run and complete. So, currently, sense requesting and NCQ log page reading are done w/ the flag set.
Signature · 1 line
tejun
Quoted 14 lines · Tejun Heo
Quoted 12 lines · Mark Lord
Quoted 4 lines · Tejun Heo
* _All_ errors are handled in EH thread.
* Once any error has occurred, all normal processing stops until
error condition is cleared by EH.Do you mean "all normal processing" for that channel stops, or *ALL* processing on all libata channels stops?
Quoted 7 lines
Quoted 3 lines
Obviously the former, I presume.
Cheers
Yeah, the former of course. ;-) Error state is indicated by one of
the followings.
^ following ata per-port flags.
Quoted 3 lines
*
ATA_FLAG_ERROR: one or more errors have occurred and EH is
scheduled to run.
^ on the ata port
Quoted 1 line
*
ATA_FLAG_RECOVERY: EH in progress
^ on the ata port
Quoted 3 lines
When either of above flags is set, only commands w/
ATA_QCFLAG_PREEMPT
flag set gets to run and complete. So, currently, sense requesting and
^ on the ata port
Quoted 1 line
NCQ log page reading are done w/ the flag set.
Just to be clearer. ;-)
Signature · 1 line
tejun
Tejun,
I'm back from holiday now, and will try your one-liner in place of the more complex patch I had been using.
(that's what you intended, right?)
Should know within a few hours whether it solves this problem here or not.
cheers
Signature · 3 lines
Mark Lord Real-Time Remedies Inc. [email protected]
Quoted 7 lines · Tejun Heo
Quoted 5 lines · Mark Lord
Quoted 1 line
The problem with this patch is that is causes leaks, and doesn't
actually ready the devices because
scsi_eh_ready_devs()is never called:scsi_eh_abort_cmds()is guaranteed to fail out every time its called.MMmm.. bummer if that's the case, but it does execute here on my machine about once every two seconds, continuously,
...
Quoted 20 lines
Hello, Mark Lord.
I think I've hit similar scsi-eh lockup problem during development of
new EH/NCQ helpers. I currently don't remember where it exactly looped, but I recall that scmds jumped back and forth between two lists, one of which beingeh_cmd_qwhich isn't cleared properly by SATA's strategy routine. Anyways, I'm attaching an one liner quick fix, which I'm not sure if it will work or not. Also, I'll post a combined patch of my new EH/NCQ helpers in a separate mail, which, hopefully, should be free of this issue.Please try out these two and let me know how they go. Here's the one
liner against v2.6.12.drivers/scsi/libata-scsi.c +1
-0@@ -385,6 +385,7 @@ int ata_scsi_error(struct Scsi_Host *hos* appropriate place */ host->host_failed--; +INIT_LIST_HEAD (&host->eh_cmd_q);DPRINTK ("EXIT\n" );return 0 ;
Hi, Mark.
Quoted 7 lines · Mark Lord
Tejun,
I'm back from holiday now, and will try your one-liner in place of the more complex patch I had been using.
(that's what you intended, right?)
Yeap, and if possible, please also try the second large patch. I
wanna make sure it's free of that problem.
Quoted 2 lines
Should know within a few hours whether it solves this problem here or not.
Cool.
Thanks.
Signature · 1 line
tejun
Quoted 2 lines
Quoted 2 lines
I'm back from holiday now, and will try your one-liner in place of the more complex patch I had been using.
Okay, the one-liner eh fix for libata appears to prevent the lockups here, so I will continue using it from now on in place of the earlier more complex patch.
And it looks "obviously correct" too, a Good Thing (tm).
Jeff: This one should go out ASAP.
Tejun: I'm short on time to soak the other larger patch, as the problem occurs only on my primary notebook PC, and I really need it for "real (paid) work" now.
Cheers
--
Mark Lord
drivers/scsi/libata-scsi.c +1 -0
@@ -385,6 +385,7 @@ int ata_scsi_error(struct Scsi_Host *hos* appropriate place */ host->host_failed--; +INIT_LIST_HEAD (&host->eh_cmd_q);DPRINTK ("EXIT\n" );return 0 ;
Jeff Garzik
Applieddrivers/scsi/libata-scsi.c int ata_scsi_error(struct Scsi_Host *hos · line 391
Quoted 11 lines · Tejun Heo
drivers/scsi/libata-scsi.c +1
-0@@ -385,6 +385,7 @@ int ata_scsi_error(struct Scsi_Host *hos* appropriate place */ host->host_failed--; +INIT_LIST_HEAD (&host->eh_cmd_q);DPRINTK ("EXIT\n" );return 0 ;
applied to 2.6.13
After a week of further experience with this patch, I regretfully inform one and all that it does not entirely fix the lockups.
My system has experienced three of them during the past 24 hours.. after many days without.
I'm now reverting to the original "broken" patch that keeps my system alive.
Cheers!
Signature · 3 lines
Mark Lord Real-Time Remedies Inc. [email protected]
Quoted 18 lines · Jeff Garzik
drivers/scsi/libata-scsi.c int ata_scsi_error(struct Scsi_Host *hos · line 391
Quoted 11 lines · Tejun Heo
drivers/scsi/libata-scsi.c +1
-0@@ -385,6 +385,7 @@ int ata_scsi_error(struct Scsi_Host *hos* appropriate place */ host->host_failed--; +INIT_LIST_HEAD (&host->eh_cmd_q);DPRINTK ("EXIT\n" );return 0 ;applied to 2.6.13
Hi, Mark.
Quoted 6 lines · Mark Lord
After a week of further experience with this patch, I regretfully inform one and all that it does not entirely fix the lockups.
My system has experienced three of them during the past 24 hours.. after many days without.
Oh.. crap.
Quoted 4 lines
I'm now reverting to the original "broken" patch that keeps my system alive.
Cheers!
I've been trying to reproduce your lockup here, but haven't succeeded
yet. I'm currently doing multiple "while true; do cat /dev/sr0; done", bonnie, raw random IOs (latter two are to give some randomness to test condition).
I'm also digging code to discover how exactly the lockup loop occurs.
My lockup was between scsi_softirq and scsi_eh_scmd_add (EIP jumped
between the two functions), and I orginally assumed adding eh_entry to corrupt eh_cmd_q screwed local_q iteration in scsi_softirq. And as clearing eh_cmd_q solved my problem, I didn't look into it further.
If possible, can you please hook up your notebook to a serial console
and, when lockup occurs (with or without INIT_LIST_HEAD one liner), dump call trace by ctrl-alt-sysrq-p multiple times (10times across 5secs should do, I think) to verify that we're looking at the same problem? It would be best if I can find a way to reproduce it here, but the busy loop has been running for two hours now and nothing happened. :-(
Thanks.
Signature · 1 line
tejun
Quoted 3 lines · Tejun Heo
I've been trying to reproduce your lockup here, but haven't succeeded
yet. I'm currently doing multiple "while true; do cat/dev/sr0; done", bonnie, raw random IOs (latter two are to give some randomness to test condition).
Gotta trigger the eh code to get lockups, and hard disks are so reliable by themselves that it just ain't gonna happen very often that way.
My notebook has a DVD+-RW/DL drive, which the desktop (KDE) polls every second or so -- generates a libata error every time it does that with no disk in the drive. But hours or days can go by before this produces the race that locks things up (and it NEVER locks up if I keep a disc in the drive).
However, I have had the machine lock up solid during suspend/resume (RAM) at least once in the past couple of days --> perhaps a command timeout on accessing the disk on resume (or suspend?) is aggrievating the situation. No problems with the large "broken" fix,
but the one-liner was just giving me too much grief.
The laptop & I are off for a road trip for the next seven days or so, and it will be in constant daily use for presentations and stuff. So, no risky testing over the next week, sorry.
Cheers!
Quoted 10 lines · Mark Lord
Quoted 3 lines · Tejun Heo
I've been trying to reproduce your lockup here, but haven't succeeded
yet. I'm currently doing multiple "while true; do cat/dev/sr0; done", bonnie, raw random IOs (latter two are to give some randomness to test condition).Gotta trigger the eh code to get lockups, and hard disks are so reliable by themselves that it just ain't gonna happen very often that way.
Yeap, the sr0 is my SATA DVD+-RW/DL drive, and as no media is present,
each cat results in EH handling leading to No medium found error.
Quoted 6 lines
My notebook has a DVD+-RW/DL drive, which the desktop (KDE) polls every second or so -- generates a libata error every time it does that with no disk in the drive. But hours or days can go by before this produces the race that locks things up (and it NEVER locks up if I keep a disc in the drive).
Okay, I'll keep my test running for longer.
Quoted 6 lines
However, I have had the machine lock up solid during suspend/resume (RAM) at least once in the past couple of days --> perhaps a command timeout on accessing the disk on resume (or suspend?) is aggrievating the situation. No problems with the large "broken" fix,
but the one-liner was just giving me too much grief.
Hmmm, if the lockup only occurs w/ suspend/resume w/ one-liner. The
lockup could be a different problem. I'll try to dig deeper.
Quoted 3 lines
The laptop & I are off for a road trip for the next seven days or so, and it will be in constant daily use for presentations and stuff. So, no risky testing over the next week, sorry.
Dang. :-p
Signature · 1 line
tejun
One idea would be to inject more faults into disk (ATA) as opposed to the Optical (ATAPI) drives, and see if doing so in combination with the existing ATAPI poll/fails will trigger things more quickly.
This can be done by using Passthru to issue invalid commands to a drive, which the drive will reject with "Drive Status Errors".
I just tried it now on a whim, using "hdparm -Z /dev/sda", and my system never recovered until I used ctrl-alt-sysreq-b.
Now mind you, "hdparm -Z" sends a Seagate vendor-unique opcode (to my Fujitsu hard drive), and perhaps that maps to something the Fujitsu recognized or choked on.. But one could edit hdparm to send a NOP or something instead.
Cheers
Quoted 5 lines · Mark Lord
However, I have had the machine lock up solid during suspend/resume (RAM) at least once in the past couple of days --> perhaps a command timeout on accessing the disk on resume (or suspend?) is aggrievating the situation. No problems with the large "broken" fix,
but the one-liner was just giving me too much grief.
Metoo (C) ;-)
I had the nerve to open the drive while suspending and had a solid lockup.
Quoted 9 lines · Mark Lord
After a week of further experience with this patch, I regretfully inform one and all that it does not entirely fix the lockups.
My system has experienced three of them during the past 24 hours.. after many days without.
I'm now reverting to the original "broken" patch that keeps my system alive.
What is exactly the "broken" patch and what is "this" patch?
I am using the patch mentioned in your mail (the oneliner) and I've had no lockups whatsoeve.
But that may have to do with me not running progs that keep scanning the cd drive.
Quoted 3 lines · Erik Slagter
Quoted 1 line · Mark Lord
After a week of further experience with this patch,
..
Quoted 1 line
Quoted 1 line
I'm now reverting to the original "broken" patch
..
Quoted 2 lines
What is exactly the "broken" patch and what is "this" patch?
"this" patch refered to the subject of that email, the "one-liner" included therein.
The "broken" patch (which behaves in a very unbroken manner) is in the collection of "essentials" that I maintain for modern laptop users at http://rtr.ca/dell_i9300/kernels/
Cheers
Quoted 8 lines · Mark Lord
Quoted 3 lines · Erik Slagter
Quoted 1 line · Mark Lord
After a week of further experience with this patch,
..
Quoted 1 line
Quoted 1 line
I'm now reverting to the original "broken" patch
..
Quoted 1 line
Quoted 8 lines
Quoted 1 line
What is exactly the "broken" patch and what is "this" patch?
"this" patch refered to the subject of that email, the "one-liner" included therein.
The "broken" patch (which behaves in a very unbroken manner) is in the collection of "essentials" that I maintain for modern laptop users at http://rtr.ca/dell_i9300/kernels/
Quoted 11 lines · Bartlomiej Zolnierkiewicz
Quoted 10 lines · Mark Lord
Quoted 3 lines · Erik Slagter
Quoted 1 line · Mark Lord
After a week of further experience with this patch,
..
Quoted 1 line
Quoted 1 line
I'm now reverting to the original "broken" patch
..
Quoted 2 lines
What is exactly the "broken" patch and what is "this" patch?
Quoted 8 lines
Quoted 6 lines
"this" patch refered to the subject of that email, the "one-liner" included therein.
The "broken" patch (which behaves in a very unbroken manner) is in the collection of "essentials" that I maintain for modern laptop users at http://rtr.ca/dell_i9300/kernels/
BTW it would be nice to keep some comments in the patches (author, description, url etc.)
Cheers,
Bartlomiej
Another data point on the current libata EH:
I have now been running 2.6.13 for a week now
with no crashes attributable to libata.
This is stock 2.6.13, plus:
-- libata passthru patch (needed for laptop-mode, etc..) -- libata atapi DMA patch (needed for modern laptop) -- libata suspend patch (needed for swsusp)
-- Jeff's libata 2.6.13+ updates from LKML (just on principles)
So the system is no longer crashing due to libata EH.
Now to await the day when I no longer have to patch libata at all just to have my laptop work properly.
Cheers
Quoted 1 line · Mark Lord
-- libata atapi DMA patch (needed for modern laptop)
Which patch is this? DMA alignment?
Jeff