Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ata: libata: add reset tracepoints

To follow the flow of control we should be using tracepoints, as
they will tie in with the actual I/O flow and deliver a better
overview about what it happening.
This patch adds tracepoints for hard reset, soft reset, and postreset
and adds them in the libata-eh control flow.
With that we can drop the reset DPRINTK calls in the various drivers.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>

authored by

Hannes Reinecke and committed by
Damien Le Moal
f8ec26d0 4baa5745

+115 -57
-7
drivers/ata/ahci.c
··· 700 700 bool online; 701 701 int rc; 702 702 703 - DPRINTK("ENTER\n"); 704 - 705 703 hpriv->stop_engine(ap); 706 704 707 705 rc = sata_link_hardreset(link, sata_ehc_deb_timing(&link->eh_context), 708 706 deadline, &online, NULL); 709 707 710 708 hpriv->start_engine(ap); 711 - 712 - DPRINTK("EXIT, rc=%d, class=%u\n", rc, *class); 713 709 714 710 /* vt8251 doesn't clear BSY on signature FIS reception, 715 711 * request follow-up softreset. ··· 786 790 bool online; 787 791 int rc, i; 788 792 789 - DPRINTK("ENTER\n"); 790 - 791 793 hpriv->stop_engine(ap); 792 794 793 795 for (i = 0; i < 2; i++) { ··· 823 829 if (online) 824 830 *class = ahci_dev_classify(ap); 825 831 826 - DPRINTK("EXIT, rc=%d, class=%u\n", rc, *class); 827 832 return rc; 828 833 } 829 834
-4
drivers/ata/ahci_qoriq.c
··· 103 103 int rc; 104 104 bool ls1021a_workaround = (qoriq_priv->type == AHCI_LS1021A); 105 105 106 - DPRINTK("ENTER\n"); 107 - 108 106 hpriv->stop_engine(ap); 109 107 110 108 /* ··· 144 146 145 147 if (online) 146 148 *class = ahci_dev_classify(ap); 147 - 148 - DPRINTK("EXIT, rc=%d, class=%u\n", rc, *class); 149 149 return rc; 150 150 } 151 151
-10
drivers/ata/libahci.c
··· 1415 1415 bool fbs_disabled = false; 1416 1416 int rc; 1417 1417 1418 - DPRINTK("ENTER\n"); 1419 - 1420 1418 /* prepare for SRST (AHCI-1.1 10.4.1) */ 1421 1419 rc = ahci_kick_engine(ap); 1422 1420 if (rc && rc != -EOPNOTSUPP) ··· 1474 1476 if (fbs_disabled) 1475 1477 ahci_enable_fbs(ap); 1476 1478 1477 - DPRINTK("EXIT, class=%u\n", *class); 1478 1479 return 0; 1479 1480 1480 1481 fail: ··· 1494 1497 unsigned long deadline) 1495 1498 { 1496 1499 int pmp = sata_srst_pmp(link); 1497 - 1498 - DPRINTK("ENTER\n"); 1499 1500 1500 1501 return ahci_do_softreset(link, class, pmp, deadline, ahci_check_ready); 1501 1502 } ··· 1523 1528 int pmp = sata_srst_pmp(link); 1524 1529 int rc; 1525 1530 u32 irq_sts; 1526 - 1527 - DPRINTK("ENTER\n"); 1528 1531 1529 1532 rc = ahci_do_softreset(link, class, pmp, deadline, 1530 1533 ahci_bad_pmp_check_ready); ··· 1557 1564 struct ata_taskfile tf; 1558 1565 int rc; 1559 1566 1560 - DPRINTK("ENTER\n"); 1561 - 1562 1567 hpriv->stop_engine(ap); 1563 1568 1564 1569 /* clear D2H reception area to properly wait for D2H FIS */ ··· 1572 1581 if (*online) 1573 1582 *class = ahci_dev_classify(ap); 1574 1583 1575 - DPRINTK("EXIT, rc=%d, class=%u\n", rc, *class); 1576 1584 return rc; 1577 1585 } 1578 1586 EXPORT_SYMBOL_GPL(ahci_do_hardreset);
-4
drivers/ata/libata-core.c
··· 3656 3656 { 3657 3657 u32 serror; 3658 3658 3659 - DPRINTK("ENTER\n"); 3660 - 3661 3659 /* reset complete, clear SError */ 3662 3660 if (!sata_scr_read(link, SCR_ERROR, &serror)) 3663 3661 sata_scr_write(link, SCR_ERROR, serror); 3664 3662 3665 3663 /* print link status */ 3666 3664 sata_print_link_status(link); 3667 - 3668 - DPRINTK("EXIT\n"); 3669 3665 } 3670 3666 EXPORT_SYMBOL_GPL(ata_std_postreset); 3671 3667
+18 -3
drivers/ata/libata-eh.c
··· 2596 2596 2597 2597 /* mark that this EH session started with reset */ 2598 2598 ehc->last_reset = jiffies; 2599 - if (reset == hardreset) 2599 + if (reset == hardreset) { 2600 2600 ehc->i.flags |= ATA_EHI_DID_HARDRESET; 2601 - else 2601 + trace_ata_link_hardreset_begin(link, classes, deadline); 2602 + } else { 2602 2603 ehc->i.flags |= ATA_EHI_DID_SOFTRESET; 2604 + trace_ata_link_softreset_begin(link, classes, deadline); 2605 + } 2603 2606 2604 2607 rc = ata_do_reset(link, reset, classes, deadline, true); 2608 + if (reset == hardreset) 2609 + trace_ata_link_hardreset_end(link, classes, rc); 2610 + else 2611 + trace_ata_link_softreset_end(link, classes, rc); 2605 2612 if (rc && rc != -EAGAIN) { 2606 2613 failed_link = link; 2607 2614 goto fail; ··· 2622 2615 ata_link_info(slave, "hard resetting link\n"); 2623 2616 2624 2617 ata_eh_about_to_do(slave, NULL, ATA_EH_RESET); 2618 + trace_ata_slave_hardreset_begin(slave, classes, 2619 + deadline); 2625 2620 tmp = ata_do_reset(slave, reset, classes, deadline, 2626 2621 false); 2622 + trace_ata_slave_hardreset_end(slave, classes, tmp); 2627 2623 switch (tmp) { 2628 2624 case -EAGAIN: 2629 2625 rc = -EAGAIN; ··· 2654 2644 } 2655 2645 2656 2646 ata_eh_about_to_do(link, NULL, ATA_EH_RESET); 2647 + trace_ata_link_softreset_begin(link, classes, deadline); 2657 2648 rc = ata_do_reset(link, reset, classes, deadline, true); 2649 + trace_ata_link_softreset_end(link, classes, rc); 2658 2650 if (rc) { 2659 2651 failed_link = link; 2660 2652 goto fail; ··· 2710 2698 */ 2711 2699 if (postreset) { 2712 2700 postreset(link, classes); 2713 - if (slave) 2701 + trace_ata_link_postreset(link, classes, rc); 2702 + if (slave) { 2714 2703 postreset(slave, classes); 2704 + trace_ata_slave_postreset(slave, classes, rc); 2705 + } 2715 2706 } 2716 2707 2717 2708 /*
+1 -10
drivers/ata/libata-sff.c
··· 1956 1956 { 1957 1957 struct ata_ioports *ioaddr = &ap->ioaddr; 1958 1958 1959 - DPRINTK("ata%u: bus reset via SRST\n", ap->print_id); 1960 - 1961 1959 if (ap->ioaddr.ctl_addr) { 1962 1960 /* software reset. causes dev0 to be selected */ 1963 1961 iowrite8(ap->ctl, ioaddr->ctl_addr); ··· 1993 1995 int rc; 1994 1996 u8 err; 1995 1997 1996 - DPRINTK("ENTER\n"); 1997 - 1998 1998 /* determine if device 0/1 are present */ 1999 1999 if (ata_devchk(ap, 0)) 2000 2000 devmask |= (1 << 0); ··· 2003 2007 ap->ops->sff_dev_select(ap, 0); 2004 2008 2005 2009 /* issue bus reset */ 2006 - DPRINTK("about to softreset, devmask=%x\n", devmask); 2007 2010 rc = ata_bus_softreset(ap, devmask, deadline); 2008 2011 /* if link is occupied, -ENODEV too is an error */ 2009 2012 if (rc && (rc != -ENODEV || sata_scr_valid(link))) { ··· 2017 2022 classes[1] = ata_sff_dev_classify(&link->device[1], 2018 2023 devmask & (1 << 1), &err); 2019 2024 2020 - DPRINTK("EXIT, classes[0]=%u [1]=%u\n", classes[0], classes[1]); 2021 2025 return 0; 2022 2026 } 2023 2027 EXPORT_SYMBOL_GPL(ata_sff_softreset); ··· 2049 2055 if (online) 2050 2056 *class = ata_sff_dev_classify(link->device, 1, NULL); 2051 2057 2052 - DPRINTK("EXIT, class=%u\n", *class); 2053 2058 return rc; 2054 2059 } 2055 2060 EXPORT_SYMBOL_GPL(sata_sff_hardreset); ··· 2078 2085 ap->ops->sff_dev_select(ap, 0); 2079 2086 2080 2087 /* bail out if no device is present */ 2081 - if (classes[0] == ATA_DEV_NONE && classes[1] == ATA_DEV_NONE) { 2082 - DPRINTK("EXIT, no device\n"); 2088 + if (classes[0] == ATA_DEV_NONE && classes[1] == ATA_DEV_NONE) 2083 2089 return; 2084 - } 2085 2090 2086 2091 /* set up device control */ 2087 2092 if (ap->ops->sff_set_devctl || ap->ioaddr.ctl_addr) {
-2
drivers/ata/pata_octeon_cf.c
··· 440 440 int rc; 441 441 u8 err; 442 442 443 - DPRINTK("about to softreset\n"); 444 443 __raw_writew(ap->ctl, base + 0xe); 445 444 udelay(20); 446 445 __raw_writew(ap->ctl | ATA_SRST, base + 0xe); ··· 454 455 455 456 /* determine by signature whether we have ATA or ATAPI devices */ 456 457 classes[0] = ata_sff_dev_classify(&link->device[0], 1, &err); 457 - DPRINTK("EXIT, classes[0]=%u [1]=%u\n", classes[0], classes[1]); 458 458 return 0; 459 459 } 460 460
-10
drivers/ata/sata_fsl.c
··· 827 827 int i = 0; 828 828 unsigned long start_jiffies; 829 829 830 - DPRINTK("in xx_hardreset\n"); 831 - 832 830 try_offline_again: 833 831 /* 834 832 * Force host controller to go off-line, aborting current operations ··· 941 943 u8 *cfis; 942 944 u32 Serror; 943 945 944 - DPRINTK("in xx_softreset\n"); 945 - 946 946 if (ata_link_offline(link)) { 947 - DPRINTK("PHY reports no device\n"); 948 947 *class = ATA_DEV_NONE; 949 948 return 0; 950 949 } ··· 953 958 * and device presence has been detected, therefore if we have 954 959 * reached here, we can send a command to the target device 955 960 */ 956 - 957 - DPRINTK("Sending SRST/device reset\n"); 958 961 959 962 ata_tf_init(link->device, &tf); 960 963 cfis = (u8 *) &pp->cmdentry->cfis; ··· 1025 1032 */ 1026 1033 iowrite32(0x01, CC + hcr_base); /* We know it will be cmd#0 always */ 1027 1034 1028 - DPRINTK("SATA FSL : Now checking device signature\n"); 1029 - 1030 1035 *class = ATA_DEV_NONE; 1031 1036 1032 1037 /* Verify if SStatus indicates device presence */ ··· 1038 1047 1039 1048 *class = sata_fsl_dev_classify(ap); 1040 1049 1041 - DPRINTK("class = %d\n", *class); 1042 1050 VPRINTK("ccreg = 0x%x\n", ioread32(hcr_base + CC)); 1043 1051 VPRINTK("cereg = 0x%x\n", ioread32(hcr_base + CE)); 1044 1052 }
-4
drivers/ata/sata_rcar.c
··· 323 323 { 324 324 struct ata_ioports *ioaddr = &ap->ioaddr; 325 325 326 - DPRINTK("ata%u: bus reset via SRST\n", ap->print_id); 327 - 328 326 /* software reset. causes dev0 to be selected */ 329 327 iowrite32(ap->ctl, ioaddr->ctl_addr); 330 328 udelay(20); ··· 348 350 devmask |= 1 << 0; 349 351 350 352 /* issue bus reset */ 351 - DPRINTK("about to softreset, devmask=%x\n", devmask); 352 353 rc = sata_rcar_bus_softreset(ap, deadline); 353 354 /* if link is occupied, -ENODEV too is an error */ 354 355 if (rc && (rc != -ENODEV || sata_scr_valid(link))) { ··· 358 361 /* determine by signature whether we have ATA or ATAPI devices */ 359 362 classes[0] = ata_sff_dev_classify(&link->device[0], devmask, &err); 360 363 361 - DPRINTK("classes[0]=%u\n", classes[0]); 362 364 return 0; 363 365 } 364 366
-3
drivers/ata/sata_sil24.c
··· 656 656 const char *reason; 657 657 int rc; 658 658 659 - DPRINTK("ENTER\n"); 660 - 661 659 /* put the port into known state */ 662 660 if (sil24_init_port(ap)) { 663 661 reason = "port not ready"; ··· 680 682 sil24_read_tf(ap, 0, &tf); 681 683 *class = ata_port_classify(ap, &tf); 682 684 683 - DPRINTK("EXIT, class=%u\n", *class); 684 685 return 0; 685 686 686 687 err:
+96
include/trace/events/libata.h
··· 132 132 ata_protocol_name(ATAPI_PROT_PIO), \ 133 133 ata_protocol_name(ATAPI_PROT_DMA)) 134 134 135 + #define ata_class_name(class) { class, #class } 136 + #define show_class_name(val) \ 137 + __print_symbolic(val, \ 138 + ata_class_name(ATA_DEV_UNKNOWN), \ 139 + ata_class_name(ATA_DEV_ATA), \ 140 + ata_class_name(ATA_DEV_ATA_UNSUP), \ 141 + ata_class_name(ATA_DEV_ATAPI), \ 142 + ata_class_name(ATA_DEV_ATAPI_UNSUP), \ 143 + ata_class_name(ATA_DEV_PMP), \ 144 + ata_class_name(ATA_DEV_PMP_UNSUP), \ 145 + ata_class_name(ATA_DEV_SEMB), \ 146 + ata_class_name(ATA_DEV_SEMB_UNSUP), \ 147 + ata_class_name(ATA_DEV_ZAC), \ 148 + ata_class_name(ATA_DEV_ZAC_UNSUP), \ 149 + ata_class_name(ATA_DEV_NONE)) 150 + 135 151 const char *libata_trace_parse_status(struct trace_seq*, unsigned char); 136 152 #define __parse_status(s) libata_trace_parse_status(p, s) 137 153 ··· 344 328 __parse_qc_flags(__entry->qc_flags), 345 329 __parse_eh_err_mask(__entry->eh_err_mask)) 346 330 ); 331 + 332 + DECLARE_EVENT_CLASS(ata_link_reset_begin_template, 333 + 334 + TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline), 335 + 336 + TP_ARGS(link, class, deadline), 337 + 338 + TP_STRUCT__entry( 339 + __field( unsigned int, ata_port ) 340 + __array( unsigned int, class, 2 ) 341 + __field( unsigned long, deadline ) 342 + ), 343 + 344 + TP_fast_assign( 345 + __entry->ata_port = link->ap->print_id; 346 + memcpy(__entry->class, class, 2); 347 + __entry->deadline = deadline; 348 + ), 349 + 350 + TP_printk("ata_port=%u deadline=%lu classes=[%s,%s]", 351 + __entry->ata_port, __entry->deadline, 352 + show_class_name(__entry->class[0]), 353 + show_class_name(__entry->class[1])) 354 + ); 355 + 356 + DEFINE_EVENT(ata_link_reset_begin_template, ata_link_hardreset_begin, 357 + TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline), 358 + TP_ARGS(link, class, deadline)); 359 + 360 + DEFINE_EVENT(ata_link_reset_begin_template, ata_slave_hardreset_begin, 361 + TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline), 362 + TP_ARGS(link, class, deadline)); 363 + 364 + DEFINE_EVENT(ata_link_reset_begin_template, ata_link_softreset_begin, 365 + TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline), 366 + TP_ARGS(link, class, deadline)); 367 + 368 + DECLARE_EVENT_CLASS(ata_link_reset_end_template, 369 + 370 + TP_PROTO(struct ata_link *link, unsigned int *class, int rc), 371 + 372 + TP_ARGS(link, class, rc), 373 + 374 + TP_STRUCT__entry( 375 + __field( unsigned int, ata_port ) 376 + __array( unsigned int, class, 2 ) 377 + __field( int, rc ) 378 + ), 379 + 380 + TP_fast_assign( 381 + __entry->ata_port = link->ap->print_id; 382 + memcpy(__entry->class, class, 2); 383 + __entry->rc = rc; 384 + ), 385 + 386 + TP_printk("ata_port=%u rc=%d class=[%s,%s]", 387 + __entry->ata_port, __entry->rc, 388 + show_class_name(__entry->class[0]), 389 + show_class_name(__entry->class[1])) 390 + ); 391 + 392 + DEFINE_EVENT(ata_link_reset_end_template, ata_link_hardreset_end, 393 + TP_PROTO(struct ata_link *link, unsigned int *class, int rc), 394 + TP_ARGS(link, class, rc)); 395 + 396 + DEFINE_EVENT(ata_link_reset_end_template, ata_slave_hardreset_end, 397 + TP_PROTO(struct ata_link *link, unsigned int *class, int rc), 398 + TP_ARGS(link, class, rc)); 399 + 400 + DEFINE_EVENT(ata_link_reset_end_template, ata_link_softreset_end, 401 + TP_PROTO(struct ata_link *link, unsigned int *class, int rc), 402 + TP_ARGS(link, class, rc)); 403 + 404 + DEFINE_EVENT(ata_link_reset_end_template, ata_link_postreset, 405 + TP_PROTO(struct ata_link *link, unsigned int *class, int rc), 406 + TP_ARGS(link, class, rc)); 407 + 408 + DEFINE_EVENT(ata_link_reset_end_template, ata_slave_postreset, 409 + TP_PROTO(struct ata_link *link, unsigned int *class, int rc), 410 + TP_ARGS(link, class, rc)); 347 411 348 412 #endif /* _TRACE_LIBATA_H */ 349 413