ata: libata: add tracepoints for ATA error handling

Add tracepoints for ATA error handling.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
This commit is contained in:
Hannes Reinecke 2021-12-21 08:20:34 +01:00 committed by Damien Le Moal
parent 1fe9fb71b2
commit c318458c93
4 changed files with 67 additions and 30 deletions

View File

@ -533,8 +533,6 @@ void ata_scsi_error(struct Scsi_Host *host)
unsigned long flags; unsigned long flags;
LIST_HEAD(eh_work_q); LIST_HEAD(eh_work_q);
DPRINTK("ENTER\n");
spin_lock_irqsave(host->host_lock, flags); spin_lock_irqsave(host->host_lock, flags);
list_splice_init(&host->eh_cmd_q, &eh_work_q); list_splice_init(&host->eh_cmd_q, &eh_work_q);
spin_unlock_irqrestore(host->host_lock, flags); spin_unlock_irqrestore(host->host_lock, flags);
@ -548,7 +546,6 @@ void ata_scsi_error(struct Scsi_Host *host)
/* finish or retry handled scmd's and clean up */ /* finish or retry handled scmd's and clean up */
WARN_ON(!list_empty(&eh_work_q)); WARN_ON(!list_empty(&eh_work_q));
DPRINTK("EXIT\n");
} }
/** /**
@ -940,7 +937,7 @@ void ata_std_sched_eh(struct ata_port *ap)
ata_eh_set_pending(ap, 1); ata_eh_set_pending(ap, 1);
scsi_schedule_eh(ap->scsi_host); scsi_schedule_eh(ap->scsi_host);
DPRINTK("port EH scheduled\n"); trace_ata_std_sched_eh(ap);
} }
EXPORT_SYMBOL_GPL(ata_std_sched_eh); EXPORT_SYMBOL_GPL(ata_std_sched_eh);
@ -1070,7 +1067,7 @@ static void __ata_port_freeze(struct ata_port *ap)
ap->pflags |= ATA_PFLAG_FROZEN; ap->pflags |= ATA_PFLAG_FROZEN;
DPRINTK("ata%u port frozen\n", ap->print_id); trace_ata_port_freeze(ap);
} }
/** /**
@ -1147,7 +1144,7 @@ void ata_eh_thaw_port(struct ata_port *ap)
spin_unlock_irqrestore(ap->lock, flags); spin_unlock_irqrestore(ap->lock, flags);
DPRINTK("ata%u port thawed\n", ap->print_id); trace_ata_port_thaw(ap);
} }
static void ata_eh_scsidone(struct scsi_cmnd *scmd) static void ata_eh_scsidone(struct scsi_cmnd *scmd)
@ -1287,6 +1284,8 @@ void ata_eh_about_to_do(struct ata_link *link, struct ata_device *dev,
struct ata_eh_context *ehc = &link->eh_context; struct ata_eh_context *ehc = &link->eh_context;
unsigned long flags; unsigned long flags;
trace_ata_eh_about_to_do(link, dev ? dev->devno : 0, action);
spin_lock_irqsave(ap->lock, flags); spin_lock_irqsave(ap->lock, flags);
ata_eh_clear_action(link, dev, ehi, action); ata_eh_clear_action(link, dev, ehi, action);
@ -1317,6 +1316,8 @@ void ata_eh_done(struct ata_link *link, struct ata_device *dev,
{ {
struct ata_eh_context *ehc = &link->eh_context; struct ata_eh_context *ehc = &link->eh_context;
trace_ata_eh_done(link, dev ? dev->devno : 0, action);
ata_eh_clear_action(link, dev, &ehc->i, action); ata_eh_clear_action(link, dev, &ehc->i, action);
} }
@ -1421,8 +1422,6 @@ static void ata_eh_request_sense(struct ata_queued_cmd *qc,
return; return;
} }
DPRINTK("ATA request sense\n");
ata_tf_init(dev, &tf); ata_tf_init(dev, &tf);
tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
tf.flags |= ATA_TFLAG_LBA | ATA_TFLAG_LBA48; tf.flags |= ATA_TFLAG_LBA | ATA_TFLAG_LBA48;
@ -1463,8 +1462,6 @@ unsigned int atapi_eh_request_sense(struct ata_device *dev,
struct ata_port *ap = dev->link->ap; struct ata_port *ap = dev->link->ap;
struct ata_taskfile tf; struct ata_taskfile tf;
DPRINTK("ATAPI request sense\n");
memset(sense_buf, 0, SCSI_SENSE_BUFFERSIZE); memset(sense_buf, 0, SCSI_SENSE_BUFFERSIZE);
/* initialize sense_buf with the error register, /* initialize sense_buf with the error register,
@ -1928,8 +1925,6 @@ static void ata_eh_link_autopsy(struct ata_link *link)
u32 serror; u32 serror;
int rc; int rc;
DPRINTK("ENTER\n");
if (ehc->i.flags & ATA_EHI_NO_AUTOPSY) if (ehc->i.flags & ATA_EHI_NO_AUTOPSY)
return; return;
@ -2036,7 +2031,6 @@ static void ata_eh_link_autopsy(struct ata_link *link)
ehc->i.action |= ata_eh_speed_down(dev, eflags, all_err_mask); ehc->i.action |= ata_eh_speed_down(dev, eflags, all_err_mask);
trace_ata_eh_link_autopsy(dev, ehc->i.action, all_err_mask); trace_ata_eh_link_autopsy(dev, ehc->i.action, all_err_mask);
} }
DPRINTK("EXIT\n");
} }
/** /**
@ -2936,8 +2930,6 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,
unsigned long flags; unsigned long flags;
int rc = 0; int rc = 0;
DPRINTK("ENTER\n");
/* For PATA drive side cable detection to work, IDENTIFY must /* For PATA drive side cable detection to work, IDENTIFY must
* be done backwards such that PDIAG- is released by the slave * be done backwards such that PDIAG- is released by the slave
* device before the master device is identified. * device before the master device is identified.
@ -3051,7 +3043,6 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,
err: err:
*r_failed_dev = dev; *r_failed_dev = dev;
DPRINTK("EXIT rc=%d\n", rc);
return rc; return rc;
} }
@ -3566,8 +3557,6 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
int rc, nr_fails; int rc, nr_fails;
unsigned long flags, deadline; unsigned long flags, deadline;
DPRINTK("ENTER\n");
/* prep for recovery */ /* prep for recovery */
ata_for_each_link(link, ap, EDGE) { ata_for_each_link(link, ap, EDGE) {
struct ata_eh_context *ehc = &link->eh_context; struct ata_eh_context *ehc = &link->eh_context;
@ -3775,7 +3764,6 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
if (rc && r_failed_link) if (rc && r_failed_link)
*r_failed_link = link; *r_failed_link = link;
DPRINTK("EXIT, rc=%d\n", rc);
return rc; return rc;
} }

View File

@ -652,8 +652,6 @@ static int sata_pmp_revalidate(struct ata_device *dev, unsigned int new_class)
u32 *gscr = (void *)ap->sector_buf; u32 *gscr = (void *)ap->sector_buf;
int rc; int rc;
DPRINTK("ENTER\n");
ata_eh_about_to_do(link, NULL, ATA_EH_REVALIDATE); ata_eh_about_to_do(link, NULL, ATA_EH_REVALIDATE);
if (!ata_dev_enabled(dev)) { if (!ata_dev_enabled(dev)) {
@ -686,12 +684,10 @@ static int sata_pmp_revalidate(struct ata_device *dev, unsigned int new_class)
ata_eh_done(link, NULL, ATA_EH_REVALIDATE); ata_eh_done(link, NULL, ATA_EH_REVALIDATE);
DPRINTK("EXIT, rc=0\n");
return 0; return 0;
fail: fail:
ata_dev_err(dev, "PMP revalidation failed (errno=%d)\n", rc); ata_dev_err(dev, "PMP revalidation failed (errno=%d)\n", rc);
DPRINTK("EXIT, rc=%d\n", rc);
return rc; return rc;
} }
@ -759,8 +755,6 @@ static int sata_pmp_eh_recover_pmp(struct ata_port *ap,
int detach = 0, rc = 0; int detach = 0, rc = 0;
int reval_failed = 0; int reval_failed = 0;
DPRINTK("ENTER\n");
if (dev->flags & ATA_DFLAG_DETACH) { if (dev->flags & ATA_DFLAG_DETACH) {
detach = 1; detach = 1;
rc = -ENODEV; rc = -ENODEV;
@ -828,7 +822,6 @@ static int sata_pmp_eh_recover_pmp(struct ata_port *ap,
/* okay, PMP resurrected */ /* okay, PMP resurrected */
ehc->i.flags = 0; ehc->i.flags = 0;
DPRINTK("EXIT, rc=0\n");
return 0; return 0;
fail: fail:
@ -838,7 +831,6 @@ static int sata_pmp_eh_recover_pmp(struct ata_port *ap,
else else
ata_dev_disable(dev); ata_dev_disable(dev);
DPRINTK("EXIT, rc=%d\n", rc);
return rc; return rc;
} }

View File

@ -533,8 +533,6 @@ int sata_link_hardreset(struct ata_link *link, const unsigned long *timing,
u32 scontrol; u32 scontrol;
int rc; int rc;
DPRINTK("ENTER\n");
if (online) if (online)
*online = false; *online = false;
@ -610,7 +608,6 @@ int sata_link_hardreset(struct ata_link *link, const unsigned long *timing,
*online = false; *online = false;
ata_link_err(link, "COMRESET failed (errno=%d)\n", rc); ata_link_err(link, "COMRESET failed (errno=%d)\n", rc);
} }
DPRINTK("EXIT, rc=%d\n", rc);
return rc; return rc;
} }
EXPORT_SYMBOL_GPL(sata_link_hardreset); EXPORT_SYMBOL_GPL(sata_link_hardreset);

View File

@ -490,6 +490,37 @@ TRACE_EVENT(ata_eh_link_autopsy_qc,
__parse_eh_err_mask(__entry->eh_err_mask)) __parse_eh_err_mask(__entry->eh_err_mask))
); );
DECLARE_EVENT_CLASS(ata_eh_action_template,
TP_PROTO(struct ata_link *link, unsigned int devno, unsigned int eh_action),
TP_ARGS(link, devno, eh_action),
TP_STRUCT__entry(
__field( unsigned int, ata_port )
__field( unsigned int, ata_dev )
__field( unsigned int, eh_action )
),
TP_fast_assign(
__entry->ata_port = link->ap->print_id;
__entry->ata_dev = link->pmp + devno;
__entry->eh_action = eh_action;
),
TP_printk("ata_port=%u ata_dev=%u eh_action=%s",
__entry->ata_port, __entry->ata_dev,
__parse_eh_action(__entry->eh_action))
);
DEFINE_EVENT(ata_eh_action_template, ata_eh_about_to_do,
TP_PROTO(struct ata_link *link, unsigned int devno, unsigned int eh_action),
TP_ARGS(link, devno, eh_action));
DEFINE_EVENT(ata_eh_action_template, ata_eh_done,
TP_PROTO(struct ata_link *link, unsigned int devno, unsigned int eh_action),
TP_ARGS(link, devno, eh_action));
DECLARE_EVENT_CLASS(ata_link_reset_begin_template, DECLARE_EVENT_CLASS(ata_link_reset_begin_template,
TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline), TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline),
@ -570,6 +601,35 @@ DEFINE_EVENT(ata_link_reset_end_template, ata_slave_postreset,
TP_PROTO(struct ata_link *link, unsigned int *class, int rc), TP_PROTO(struct ata_link *link, unsigned int *class, int rc),
TP_ARGS(link, class, rc)); TP_ARGS(link, class, rc));
DECLARE_EVENT_CLASS(ata_port_eh_begin_template,
TP_PROTO(struct ata_port *ap),
TP_ARGS(ap),
TP_STRUCT__entry(
__field( unsigned int, ata_port )
),
TP_fast_assign(
__entry->ata_port = ap->print_id;
),
TP_printk("ata_port=%u", __entry->ata_port)
);
DEFINE_EVENT(ata_port_eh_begin_template, ata_std_sched_eh,
TP_PROTO(struct ata_port *ap),
TP_ARGS(ap));
DEFINE_EVENT(ata_port_eh_begin_template, ata_port_freeze,
TP_PROTO(struct ata_port *ap),
TP_ARGS(ap));
DEFINE_EVENT(ata_port_eh_begin_template, ata_port_thaw,
TP_PROTO(struct ata_port *ap),
TP_ARGS(ap));
DECLARE_EVENT_CLASS(ata_sff_hsm_template, DECLARE_EVENT_CLASS(ata_sff_hsm_template,
TP_PROTO(struct ata_queued_cmd *qc, unsigned char status), TP_PROTO(struct ata_queued_cmd *qc, unsigned char status),