Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions
libata-eh.c File Reference
#include <linux/kernel.h>
#include <linux/blkdev.h>
#include <linux/export.h>
#include <linux/pci.h>
#include <scsi/scsi.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_eh.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_dbg.h>
#include "../scsi/scsi_transport_api.h"
#include <linux/libata.h>
#include "libata.h"

Go to the source code of this file.

Data Structures

struct  ata_eh_cmd_timeout_ent
 
struct  speed_down_verdict_arg
 

Macros

#define CMDS(cmds...)   (const u8 []){ cmds, 0 }
 

Enumerations

enum  {
  ATA_EH_SPDN_NCQ_OFF = (1 << 0), ATA_EH_SPDN_SPEED_DOWN = (1 << 1), ATA_EH_SPDN_FALLBACK_TO_PIO = (1 << 2), ATA_EH_SPDN_KEEP_ERRORS = (1 << 3),
  ATA_EFLAG_IS_IO = (1 << 0), ATA_EFLAG_DUBIOUS_XFER = (1 << 1), ATA_EFLAG_OLD_ER = (1 << 31), ATA_ECAT_NONE = 0,
  ATA_ECAT_ATA_BUS = 1, ATA_ECAT_TOUT_HSM = 2, ATA_ECAT_UNK_DEV = 3, ATA_ECAT_DUBIOUS_NONE = 4,
  ATA_ECAT_DUBIOUS_ATA_BUS = 5, ATA_ECAT_DUBIOUS_TOUT_HSM = 6, ATA_ECAT_DUBIOUS_UNK_DEV = 7, ATA_ECAT_NR = 8,
  ATA_EH_CMD_DFL_TIMEOUT = 5000, ATA_EH_RESET_COOL_DOWN = 5000, ATA_EH_PRERESET_TIMEOUT = 10000, ATA_EH_FASTDRAIN_INTERVAL = 3000,
  ATA_EH_UA_TRIES = 5, ATA_EH_PROBE_TRIAL_INTERVAL = 60000, ATA_EH_PROBE_TRIALS = 2
}
 

Functions

void __ata_ehi_push_desc (struct ata_eh_info *ehi, const char *fmt,...)
 
void ata_ehi_push_desc (struct ata_eh_info *ehi, const char *fmt,...)
 
void ata_ehi_clear_desc (struct ata_eh_info *ehi)
 
void ata_port_desc (struct ata_port *ap, const char *fmt,...)
 
unsigned long ata_internal_cmd_timeout (struct ata_device *dev, u8 cmd)
 
void ata_internal_cmd_timed_out (struct ata_device *dev, u8 cmd)
 
int ata_ering_map (struct ata_ering *ering, int(*map_fn)(struct ata_ering_entry *, void *), void *arg)
 
void ata_eh_acquire (struct ata_port *ap)
 
void ata_eh_release (struct ata_port *ap)
 
enum blk_eh_timer_return ata_scsi_timed_out (struct scsi_cmnd *cmd)
 
void ata_scsi_error (struct Scsi_Host *host)
 
void ata_scsi_cmd_error_handler (struct Scsi_Host *host, struct ata_port *ap, struct list_head *eh_work_q)
 
 EXPORT_SYMBOL (ata_scsi_cmd_error_handler)
 
void ata_scsi_port_error_handler (struct Scsi_Host *host, struct ata_port *ap)
 
 EXPORT_SYMBOL_GPL (ata_scsi_port_error_handler)
 
void ata_port_wait_eh (struct ata_port *ap)
 
 EXPORT_SYMBOL_GPL (ata_port_wait_eh)
 
void ata_eh_fastdrain_timerfn (unsigned long arg)
 
void ata_qc_schedule_eh (struct ata_queued_cmd *qc)
 
void ata_std_sched_eh (struct ata_port *ap)
 
 EXPORT_SYMBOL_GPL (ata_std_sched_eh)
 
void ata_std_end_eh (struct ata_port *ap)
 
 EXPORT_SYMBOL (ata_std_end_eh)
 
void ata_port_schedule_eh (struct ata_port *ap)
 
int ata_link_abort (struct ata_link *link)
 
int ata_port_abort (struct ata_port *ap)
 
int ata_port_freeze (struct ata_port *ap)
 
int sata_async_notification (struct ata_port *ap)
 
void ata_eh_freeze_port (struct ata_port *ap)
 
void ata_eh_thaw_port (struct ata_port *ap)
 
void ata_eh_qc_complete (struct ata_queued_cmd *qc)
 
void ata_eh_qc_retry (struct ata_queued_cmd *qc)
 
void ata_dev_disable (struct ata_device *dev)
 
void ata_eh_detach_dev (struct ata_device *dev)
 
void ata_eh_about_to_do (struct ata_link *link, struct ata_device *dev, unsigned int action)
 
void ata_eh_done (struct ata_link *link, struct ata_device *dev, unsigned int action)
 
unsigned int ata_read_log_page (struct ata_device *dev, u8 log, u8 page, void *buf, unsigned int sectors)
 
void ata_eh_analyze_ncq_error (struct ata_link *link)
 
void ata_eh_autopsy (struct ata_port *ap)
 
const charata_get_cmd_descript (u8 command)
 
void ata_eh_report (struct ata_port *ap)
 
int ata_eh_reset (struct ata_link *link, int classify, ata_prereset_fn_t prereset, ata_reset_fn_t softreset, ata_reset_fn_t hardreset, ata_postreset_fn_t postreset)
 
int ata_set_mode (struct ata_link *link, struct ata_device **r_failed_dev)
 
int ata_link_nr_enabled (struct ata_link *link)
 
int ata_eh_recover (struct ata_port *ap, ata_prereset_fn_t prereset, ata_reset_fn_t softreset, ata_reset_fn_t hardreset, ata_postreset_fn_t postreset, struct ata_link **r_failed_link)
 
void ata_eh_finish (struct ata_port *ap)
 
void ata_do_eh (struct ata_port *ap, ata_prereset_fn_t prereset, ata_reset_fn_t softreset, ata_reset_fn_t hardreset, ata_postreset_fn_t postreset)
 
void ata_std_error_handler (struct ata_port *ap)
 

Macro Definition Documentation

#define CMDS (   cmds...)    (const u8 []){ cmds, 0 }

Definition at line 146 of file libata-eh.c.

Enumeration Type Documentation

anonymous enum
Enumerator:
ATA_EH_SPDN_NCQ_OFF 
ATA_EH_SPDN_SPEED_DOWN 
ATA_EH_SPDN_FALLBACK_TO_PIO 
ATA_EH_SPDN_KEEP_ERRORS 
ATA_EFLAG_IS_IO 
ATA_EFLAG_DUBIOUS_XFER 
ATA_EFLAG_OLD_ER 
ATA_ECAT_NONE 
ATA_ECAT_ATA_BUS 
ATA_ECAT_TOUT_HSM 
ATA_ECAT_UNK_DEV 
ATA_ECAT_DUBIOUS_NONE 
ATA_ECAT_DUBIOUS_ATA_BUS 
ATA_ECAT_DUBIOUS_TOUT_HSM 
ATA_ECAT_DUBIOUS_UNK_DEV 
ATA_ECAT_NR 
ATA_EH_CMD_DFL_TIMEOUT 
ATA_EH_RESET_COOL_DOWN 
ATA_EH_PRERESET_TIMEOUT 
ATA_EH_FASTDRAIN_INTERVAL 
ATA_EH_UA_TRIES 
ATA_EH_PROBE_TRIAL_INTERVAL 
ATA_EH_PROBE_TRIALS 

Definition at line 51 of file libata-eh.c.

Function Documentation

void __ata_ehi_push_desc ( struct ata_eh_info ehi,
const char fmt,
  ... 
)

__ata_ehi_push_desc - push error description without adding separator : target EHI : printf format string

Format string according to and append it to ->desc.

LOCKING: spin_lock_irqsave(host lock)

Definition at line 194 of file libata-eh.c.

void ata_dev_disable ( struct ata_device dev)

ata_dev_disable - disable ATA device : ATA device to disable

Disable .

Locking: EH context.

Definition at line 1345 of file libata-eh.c.

void ata_do_eh ( struct ata_port ap,
ata_prereset_fn_t  prereset,
ata_reset_fn_t  softreset,
ata_reset_fn_t  hardreset,
ata_postreset_fn_t  postreset 
)

ata_do_eh - do standard error handling : host port to handle error for

: prereset method (can be NULL) : softreset method (can be NULL) : hardreset method (can be NULL) : postreset method (can be NULL)

Perform standard error handling sequence.

LOCKING: Kernel thread context (may sleep).

Definition at line 3969 of file libata-eh.c.

void ata_eh_about_to_do ( struct ata_link link,
struct ata_device dev,
unsigned int  action 
)

ata_eh_about_to_do - about to perform eh_action target ATA link : target ATA dev for per-dev action (can be NULL) : action about to be performed

Called just before performing EH actions to clear related bits in >eh_info such that eh actions are not unnecessarily repeated.

LOCKING: None.

Definition at line 1411 of file libata-eh.c.

void ata_eh_acquire ( struct ata_port ap)

ata_eh_acquire - acquire EH ownership : ATA port to acquire EH ownership for

Acquire EH ownership for . This is the basic exclusion mechanism for ports sharing a host. Only one port hanging off the same host can claim the ownership of EH.

LOCKING: EH context.

Definition at line 477 of file libata-eh.c.

void ata_eh_analyze_ncq_error ( struct ata_link link)

ata_eh_analyze_ncq_error - analyze NCQ error ATA link to analyze NCQ error for

Read log page 10h, determine the offending qc and acquire error status TF. For NCQ device errors, all LLDDs have to do is setting AC_ERR_DEV in ehi->err_mask. This function takes care of the rest.

LOCKING: Kernel thread context (may sleep).

Definition at line 1727 of file libata-eh.c.

void ata_eh_autopsy ( struct ata_port ap)

ata_eh_autopsy - analyze error and determine recovery action : host port to perform autopsy on

Analyze all links of and determine why they failed and which recovery actions are needed.

LOCKING: Kernel thread context (may sleep).

Definition at line 2236 of file libata-eh.c.

void ata_eh_detach_dev ( struct ata_device dev)

ata_eh_detach_dev - detach ATA device : ATA device to detach

Detach .

LOCKING: None.

Definition at line 1371 of file libata-eh.c.

void ata_eh_done ( struct ata_link link,
struct ata_device dev,
unsigned int  action 
)

ata_eh_done - EH action complete : target ATA port : target ATA dev for per-dev action (can be NULL) : action just completed

Called right after performing EH actions to clear related bits in >eh_context.

LOCKING: None.

Definition at line 1444 of file libata-eh.c.

void ata_eh_fastdrain_timerfn ( unsigned long  arg)

Definition at line 881 of file libata-eh.c.

void ata_eh_finish ( struct ata_port ap)

ata_eh_finish - finish up EH : host port to finish EH for

Recovery is complete. Clean up EH states and retry or finish failed qcs.

LOCKING: None.

Definition at line 3919 of file libata-eh.c.

void ata_eh_freeze_port ( struct ata_port ap)

ata_eh_freeze_port - EH helper to freeze port : ATA port to freeze

Freeze .

LOCKING: None.

Definition at line 1243 of file libata-eh.c.

void ata_eh_qc_complete ( struct ata_queued_cmd qc)

ata_eh_qc_complete - Complete an active ATA command from EH : Command to complete

Indicate to the mid and upper layers that an ATA command has completed. To be used from EH.

Definition at line 1310 of file libata-eh.c.

void ata_eh_qc_retry ( struct ata_queued_cmd qc)

ata_eh_qc_retry - Tell midlayer to retry an ATA command after EH : Command to retry

Indicate to the mid and upper layers that an ATA command should be retried. To be used from EH.

SCSI midlayer limits the number of retries to scmd->allowed. scmd->retries is decremented for commands which get retried due to unrelated failures (qc->err_mask is zero).

Definition at line 1328 of file libata-eh.c.

int ata_eh_recover ( struct ata_port ap,
ata_prereset_fn_t  prereset,
ata_reset_fn_t  softreset,
ata_reset_fn_t  hardreset,
ata_postreset_fn_t  postreset,
struct ata_link **  r_failed_link 
)

ata_eh_recover - recover host port after error : host port to recover : prereset method (can be NULL) : softreset method (can be NULL) : hardreset method (can be NULL) : postreset method (can be NULL) : out parameter for failed link

This is the alpha and omega, eum and yang, heart and soul of libata exception handling. On entry, actions required to recover each link and hotplug requests are recorded in the link's eh_context. This function executes all the operations with appropriate retrials and fallbacks to resurrect failed devices, detach goners and greet newcomers.

LOCKING: Kernel thread context (may sleep).

RETURNS: 0 on success, -errno on failure.

Definition at line 3690 of file libata-eh.c.

void ata_eh_release ( struct ata_port ap)

ata_eh_release - release EH ownership : ATA port to release EH ownership for

Release EH ownership for if the caller. The caller must have acquired EH ownership using ata_eh_acquire() previously.

LOCKING: EH context.

Definition at line 494 of file libata-eh.c.

void ata_eh_report ( struct ata_port ap)

ata_eh_report - report error handling to user : ATA port to report EH about

Report EH to user.

LOCKING: None.

Definition at line 2571 of file libata-eh.c.

int ata_eh_reset ( struct ata_link link,
int  classify,
ata_prereset_fn_t  prereset,
ata_reset_fn_t  softreset,
ata_reset_fn_t  hardreset,
ata_postreset_fn_t  postreset 
)

Definition at line 2603 of file libata-eh.c.

void ata_eh_thaw_port ( struct ata_port ap)

ata_port_thaw_port - EH helper to thaw port : ATA port to thaw

Thaw frozen port .

LOCKING: None.

Definition at line 1264 of file libata-eh.c.

void ata_ehi_clear_desc ( struct ata_eh_info ehi)

ata_ehi_clear_desc - clean error description : target EHI

Clear ->desc.

LOCKING: spin_lock_irqsave(host lock)

Definition at line 235 of file libata-eh.c.

void ata_ehi_push_desc ( struct ata_eh_info ehi,
const char fmt,
  ... 
)

ata_ehi_push_desc - push error description with separator : target EHI : printf format string

Format string according to and append it to ->desc. If ->desc is not empty, ", " is added in-between.

LOCKING: spin_lock_irqsave(host lock)

Definition at line 214 of file libata-eh.c.

int ata_ering_map ( struct ata_ering ering,
int(*)(struct ata_ering_entry *, void *)  map_fn,
void arg 
)

Definition at line 401 of file libata-eh.c.

const char* ata_get_cmd_descript ( u8  command)

ata_get_cmd_descript - get description for ATA command : ATA command code to get description for

Return a textual description of the given command, or NULL if the command is not known.

LOCKING: None

Definition at line 2282 of file libata-eh.c.

void ata_internal_cmd_timed_out ( struct ata_device dev,
u8  cmd 
)

ata_internal_cmd_timed_out - notification for internal command timeout : target device : internal command which timed out

Notify EH that internal command for timed out. This function should be called only for commands whose timeouts are determined using ata_internal_cmd_timeout().

LOCKING: EH context.

Definition at line 362 of file libata-eh.c.

unsigned long ata_internal_cmd_timeout ( struct ata_device dev,
u8  cmd 
)

ata_internal_cmd_timeout - determine timeout for an internal command : target device : internal command to be issued

Determine timeout for internal command for .

LOCKING: EH context.

RETURNS: Determined timeout.

Definition at line 337 of file libata-eh.c.

int ata_link_abort ( struct ata_link link)

ata_link_abort - abort all qc's on the link ATA link to abort qc's for

Abort all active qc's active on schedule EH. LOCKING: spin_lock_irqsave(host lock) RETURNS: Number of aborted qc's.

Definition at line 1083 of file libata-eh.c.

int ata_link_nr_enabled ( struct ata_link link)

Definition at line 3501 of file libata-eh.c.

int ata_port_abort ( struct ata_port ap)

ata_port_abort - abort all qc's on the port : ATA port to abort qc's for

Abort all active qc's of and schedule EH.

LOCKING: spin_lock_irqsave(host_set lock)

RETURNS: Number of aborted qc's.

Definition at line 1100 of file libata-eh.c.

void ata_port_desc ( struct ata_port ap,
const char fmt,
  ... 
)

ata_port_desc - append port description : target ATA port : printf format string

Format string according to and append it to port description. If port description is not empty, " " is added in-between. This function is to be used while initializing ata_host. The description is printed on host registration.

LOCKING: None.

Definition at line 254 of file libata-eh.c.

int ata_port_freeze ( struct ata_port ap)

ata_port_freeze - abort & freeze port : ATA port to freeze

Abort and freeze . The freeze operation must be called first, because some hardware requires special operations before the taskfile registers are accessible.

LOCKING: spin_lock_irqsave(host lock)

RETURNS: Number of aborted commands.

Definition at line 1149 of file libata-eh.c.

void ata_port_schedule_eh ( struct ata_port ap)

ata_port_schedule_eh - schedule error handling without a qc : ATA port to schedule EH for

Schedule error handling for . EH will kick in as soon as all commands are drained.

LOCKING: spin_lock_irqsave(host lock)

Definition at line 1040 of file libata-eh.c.

void ata_port_wait_eh ( struct ata_port ap)

ata_port_wait_eh - Wait for the currently pending EH to complete : Port to wait EH for

Wait until the currently pending EH is complete.

LOCKING: Kernel thread context (may sleep).

Definition at line 842 of file libata-eh.c.

void ata_qc_schedule_eh ( struct ata_queued_cmd qc)

ata_qc_schedule_eh - schedule qc for error handling : command to schedule error handling for

Schedule error handling for . EH will kick in as soon as other commands are drained.

LOCKING: spin_lock_irqsave(host lock)

Definition at line 967 of file libata-eh.c.

unsigned int ata_read_log_page ( struct ata_device dev,
u8  log,
u8  page,
void buf,
unsigned int  sectors 
)

Definition at line 1503 of file libata-eh.c.

void ata_scsi_cmd_error_handler ( struct Scsi_Host host,
struct ata_port ap,
struct list_head eh_work_q 
)

ata_scsi_cmd_error_handler - error callback for a list of commands : scsi host containing the port : ATA port within the host : list of commands to process

process the given list of commands and return those finished to the ap->eh_done_q. This function is the first part of the libata error handler which processes a given list of failed commands.

Definition at line 622 of file libata-eh.c.

void ata_scsi_error ( struct Scsi_Host host)

ata_scsi_error - SCSI layer error handler callback : SCSI host on which error occurred

Handles SCSI-layer-thrown error events.

LOCKING: Inherited from SCSI layer (none, can sleep)

RETURNS: Zero.

Definition at line 588 of file libata-eh.c.

void ata_scsi_port_error_handler ( struct Scsi_Host host,
struct ata_port ap 
)

ata_scsi_port_error_handler - recover the port after the commands : SCSI host containing the port : the ATA port

Handle the recovery of the port after all the commands have been recovered.

Definition at line 718 of file libata-eh.c.

enum blk_eh_timer_return ata_scsi_timed_out ( struct scsi_cmnd cmd)

ata_scsi_timed_out - SCSI layer time out callback : timed out SCSI command

Handles SCSI layer timeout. We race with normal completion of the qc for . If the qc is already gone, we lose and let the scsi command finish (EH_HANDLED). Otherwise, the qc has timed out and EH should be invoked. Prevent ata_qc_complete() from finishing it by setting EH_SCHEDULED and return EH_NOT_HANDLED.

TODO: kill this function once old EH is gone.

LOCKING: Called from timer context

RETURNS: EH_HANDLED or EH_NOT_HANDLED

Definition at line 520 of file libata-eh.c.

int ata_set_mode ( struct ata_link link,
struct ata_device **  r_failed_dev 
)

ata_set_mode - Program timings and issue SET FEATURES - XFER link on which timings will be programmed : out parameter for failed device

Set ATA device disk transfer mode (PIO3, UDMA6, etc.). If ata_set_mode() fails, pointer to the failing device is returned in .

LOCKING: PCI/etc. bus probe sem.

RETURNS: 0 on success, negative errno otherwise

Definition at line 3210 of file libata-eh.c.

void ata_std_end_eh ( struct ata_port ap)

ata_std_end_eh - non-libsas ata_ports complete eh with this common routine : ATA port to end EH for

In the libata object model there is a 1:1 mapping of ata_port to shost, so host fields can be directly manipulated under ap->lock, in the libsas case we need to hold a lock at the ha->level to coordinate these events.

LOCKING: spin_lock_irqsave(host lock)

Definition at line 1021 of file libata-eh.c.

void ata_std_error_handler ( struct ata_port ap)

ata_std_error_handler - standard error handler : host port to handle error for

Standard error handler

LOCKING: Kernel thread context (may sleep).

Definition at line 3998 of file libata-eh.c.

void ata_std_sched_eh ( struct ata_port ap)

ata_std_sched_eh - non-libsas ata_ports issue eh with this common routine : ATA port to schedule EH for

LOCKING: inherited from ata_port_schedule_eh spin_lock_irqsave(host lock)

Definition at line 995 of file libata-eh.c.

EXPORT_SYMBOL ( ata_scsi_cmd_error_handler  )
EXPORT_SYMBOL ( ata_std_end_eh  )
EXPORT_SYMBOL_GPL ( ata_scsi_port_error_handler  )
EXPORT_SYMBOL_GPL ( ata_port_wait_eh  )
EXPORT_SYMBOL_GPL ( ata_std_sched_eh  )
int sata_async_notification ( struct ata_port ap)

sata_async_notification - SATA async notification handler : ATA port where async notification is received

Handler to be called when async notification via SDB FIS is received. This function schedules EH if necessary.

LOCKING: spin_lock_irqsave(host lock)

RETURNS: 1 if EH is scheduled, 0 otherwise.

Definition at line 1174 of file libata-eh.c.