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

Configure Feed

Select the types of activity you want to include in your feed.

scsi: qla2xxx: Enhance driver tracing with separate tunable and more

Older tracing of driver messages was to:

- log only debug messages to kernel main trace buffer; and

- log only if extended logging bits corresponding to this message is
off

This has been modified and extended as follows:

- Tracing is now controlled via ql2xextended_error_logging_ktrace
module parameter. Bit usages same as ql2xextended_error_logging.

- Tracing uses "qla2xxx" trace instance, unless instance creation have
issues.

- Tracing is enabled (compile time tunable).

- All driver messages, include debug and log messages are now traced in
kernel trace buffer.

Trace messages can be viewed by looking at the qla2xxx instance at:

/sys/kernel/tracing/instances/qla2xxx/trace

Trace tunable that takes the same bit mask as ql2xextended_error_logging
is:

ql2xextended_error_logging_ktrace (default=1)

Link: https://lore.kernel.org/r/20220826102559.17474-6-njavali@marvell.com
Suggested-by: Daniel Wagner <dwagner@suse.de>
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Tested-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Arun Easi <aeasi@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Arun Easi and committed by
Martin K. Petersen
8bfc149b d9ba85ef

+115 -14
+36 -14
drivers/scsi/qla2xxx/qla_dbg.c
··· 2455 2455 /****************************************************************************/ 2456 2456 2457 2457 /* Write the debug message prefix into @pbuf. */ 2458 - static void ql_dbg_prefix(char *pbuf, int pbuf_size, 2458 + static void ql_dbg_prefix(char *pbuf, int pbuf_size, struct pci_dev *pdev, 2459 2459 const scsi_qla_host_t *vha, uint msg_id) 2460 2460 { 2461 2461 if (vha) { ··· 2464 2464 /* <module-name> [<dev-name>]-<msg-id>:<host>: */ 2465 2465 snprintf(pbuf, pbuf_size, "%s [%s]-%04x:%lu: ", QL_MSGHDR, 2466 2466 dev_name(&(pdev->dev)), msg_id, vha->host_no); 2467 + } else if (pdev) { 2468 + snprintf(pbuf, pbuf_size, "%s [%s]-%04x: : ", QL_MSGHDR, 2469 + dev_name(&pdev->dev), msg_id); 2467 2470 } else { 2468 2471 /* <module-name> [<dev-name>]-<msg-id>: : */ 2469 2472 snprintf(pbuf, pbuf_size, "%s [%s]-%04x: : ", QL_MSGHDR, ··· 2494 2491 struct va_format vaf; 2495 2492 char pbuf[64]; 2496 2493 2497 - if (!ql_mask_match(level) && !trace_ql_dbg_log_enabled()) 2494 + ql_ktrace(1, level, pbuf, NULL, vha, id, fmt); 2495 + 2496 + if (!ql_mask_match(level)) 2498 2497 return; 2498 + 2499 + if (!pbuf[0]) /* set by ql_ktrace */ 2500 + ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), NULL, vha, id); 2499 2501 2500 2502 va_start(va, fmt); 2501 2503 2502 2504 vaf.fmt = fmt; 2503 2505 vaf.va = &va; 2504 2506 2505 - ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), vha, id); 2506 - 2507 - if (!ql_mask_match(level)) 2508 - trace_ql_dbg_log(pbuf, &vaf); 2509 - else 2510 - pr_warn("%s%pV", pbuf, &vaf); 2507 + pr_warn("%s%pV", pbuf, &vaf); 2511 2508 2512 2509 va_end(va); 2513 2510 ··· 2536 2533 2537 2534 if (pdev == NULL) 2538 2535 return; 2536 + 2537 + ql_ktrace(1, level, pbuf, pdev, NULL, id, fmt); 2538 + 2539 2539 if (!ql_mask_match(level)) 2540 2540 return; 2541 2541 ··· 2547 2541 vaf.fmt = fmt; 2548 2542 vaf.va = &va; 2549 2543 2550 - ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), NULL, id + ql_dbg_offset); 2544 + if (!pbuf[0]) /* set by ql_ktrace */ 2545 + ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), pdev, NULL, 2546 + id + ql_dbg_offset); 2551 2547 pr_warn("%s%pV", pbuf, &vaf); 2552 2548 2553 2549 va_end(va); ··· 2578 2570 if (level > ql_errlev) 2579 2571 return; 2580 2572 2581 - ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), vha, id); 2573 + ql_ktrace(0, level, pbuf, NULL, vha, id, fmt); 2574 + 2575 + if (!pbuf[0]) /* set by ql_ktrace */ 2576 + ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), NULL, vha, id); 2582 2577 2583 2578 va_start(va, fmt); 2584 2579 ··· 2632 2621 if (level > ql_errlev) 2633 2622 return; 2634 2623 2635 - ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), NULL, id); 2624 + ql_ktrace(0, level, pbuf, pdev, NULL, id, fmt); 2625 + 2626 + if (!pbuf[0]) /* set by ql_ktrace */ 2627 + ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), pdev, NULL, id); 2636 2628 2637 2629 va_start(va, fmt); 2638 2630 ··· 2730 2716 if (level > ql_errlev) 2731 2717 return; 2732 2718 2733 - ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), qpair ? qpair->vha : NULL, id); 2719 + ql_ktrace(0, level, pbuf, NULL, qpair ? qpair->vha : NULL, id, fmt); 2720 + 2721 + if (!pbuf[0]) /* set by ql_ktrace */ 2722 + ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), NULL, 2723 + qpair ? qpair->vha : NULL, id); 2734 2724 2735 2725 va_start(va, fmt); 2736 2726 ··· 2780 2762 struct va_format vaf; 2781 2763 char pbuf[128]; 2782 2764 2765 + ql_ktrace(1, level, pbuf, NULL, qpair ? qpair->vha : NULL, id, fmt); 2766 + 2783 2767 if (!ql_mask_match(level)) 2784 2768 return; 2785 2769 ··· 2790 2770 vaf.fmt = fmt; 2791 2771 vaf.va = &va; 2792 2772 2793 - ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), qpair ? qpair->vha : NULL, 2794 - id + ql_dbg_offset); 2773 + if (!pbuf[0]) /* set by ql_ktrace */ 2774 + ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), NULL, 2775 + qpair ? qpair->vha : NULL, id + ql_dbg_offset); 2776 + 2795 2777 pr_warn("%s%pV", pbuf, &vaf); 2796 2778 2797 2779 va_end(va);
+43
drivers/scsi/qla2xxx/qla_dbg.h
··· 385 385 386 386 return level && ((level & ql2xextended_error_logging) == level); 387 387 } 388 + 389 + static inline int 390 + ql_mask_match_ext(uint level, int *log_tunable) 391 + { 392 + if (*log_tunable == 1) 393 + *log_tunable = QL_DBG_DEFAULT1_MASK; 394 + 395 + return (level & *log_tunable) == level; 396 + } 397 + 398 + /* Assumes local variable pbuf and pbuf_ready present. */ 399 + #define ql_ktrace(dbg_msg, level, pbuf, pdev, vha, id, fmt) do { \ 400 + struct va_format _vaf; \ 401 + va_list _va; \ 402 + u32 dbg_off = dbg_msg ? ql_dbg_offset : 0; \ 403 + \ 404 + pbuf[0] = 0; \ 405 + if (!trace_ql_dbg_log_enabled()) \ 406 + break; \ 407 + \ 408 + if (dbg_msg && !ql_mask_match_ext(level, \ 409 + &ql2xextended_error_logging_ktrace)) \ 410 + break; \ 411 + \ 412 + ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), pdev, vha, id + dbg_off); \ 413 + \ 414 + va_start(_va, fmt); \ 415 + _vaf.fmt = fmt; \ 416 + _vaf.va = &_va; \ 417 + \ 418 + trace_ql_dbg_log(pbuf, &_vaf); \ 419 + \ 420 + va_end(_va); \ 421 + } while (0) 422 + 423 + #define QLA_ENABLE_KERNEL_TRACING 424 + 425 + #ifdef QLA_ENABLE_KERNEL_TRACING 426 + #define QLA_TRACE_ENABLE(_tr) \ 427 + trace_array_set_clr_event(_tr, "qla", NULL, true) 428 + #else /* QLA_ENABLE_KERNEL_TRACING */ 429 + #define QLA_TRACE_ENABLE(_tr) 430 + #endif /* QLA_ENABLE_KERNEL_TRACING */
+1
drivers/scsi/qla2xxx/qla_gbl.h
··· 163 163 extern int ql2xsmartsan; 164 164 extern int ql2xallocfwdump; 165 165 extern int ql2xextended_error_logging; 166 + extern int ql2xextended_error_logging_ktrace; 166 167 extern int ql2xiidmaenable; 167 168 extern int ql2xmqsupport; 168 169 extern int ql2xfwloadbin;
+35
drivers/scsi/qla2xxx/qla_os.c
··· 15 15 #include <linux/blk-mq-pci.h> 16 16 #include <linux/refcount.h> 17 17 #include <linux/crash_dump.h> 18 + #include <linux/trace_events.h> 19 + #include <linux/trace.h> 18 20 19 21 #include <scsi/scsi_tcq.h> 20 22 #include <scsi/scsicam.h> ··· 36 34 * SRB allocation cache 37 35 */ 38 36 struct kmem_cache *srb_cachep; 37 + 38 + struct trace_array *qla_trc_array; 39 39 40 40 int ql2xfulldump_on_mpifail; 41 41 module_param(ql2xfulldump_on_mpifail, int, S_IRUGO | S_IWUSR); ··· 120 116 "debug information (equivalent to old " 121 117 "ql2xextended_error_logging=1).\n" 122 118 "\t\tDo LOGICAL OR of the value to enable more than one level"); 119 + 120 + int ql2xextended_error_logging_ktrace = 1; 121 + module_param(ql2xextended_error_logging_ktrace, int, S_IRUGO|S_IWUSR); 122 + MODULE_PARM_DESC(ql2xextended_error_logging_ktrace, 123 + "Same BIT definiton as ql2xextended_error_logging, but used to control logging to kernel trace buffer (default=1).\n"); 123 124 124 125 int ql2xshiftctondsd = 6; 125 126 module_param(ql2xshiftctondsd, int, S_IRUGO); ··· 2846 2837 spin_lock_irqsave(&vha->work_lock, flags); 2847 2838 clear_bit(IOCB_WORK_ACTIVE, &vha->dpc_flags); 2848 2839 spin_unlock_irqrestore(&vha->work_lock, flags); 2840 + } 2841 + 2842 + static void 2843 + qla_trace_init(void) 2844 + { 2845 + qla_trc_array = trace_array_get_by_name("qla2xxx"); 2846 + if (!qla_trc_array) { 2847 + ql_log(ql_log_fatal, NULL, 0x0001, 2848 + "Unable to create qla2xxx trace instance, instance logging will be disabled.\n"); 2849 + return; 2850 + } 2851 + 2852 + QLA_TRACE_ENABLE(qla_trc_array); 2853 + } 2854 + 2855 + static void 2856 + qla_trace_uninit(void) 2857 + { 2858 + if (!qla_trc_array) 2859 + return; 2860 + trace_array_put(qla_trc_array); 2849 2861 } 2850 2862 2851 2863 /* ··· 8211 8181 BUILD_BUG_ON(sizeof(sw_info_t) != 32); 8212 8182 BUILD_BUG_ON(sizeof(target_id_t) != 2); 8213 8183 8184 + qla_trace_init(); 8185 + 8214 8186 /* Allocate cache for SRBs. */ 8215 8187 srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0, 8216 8188 SLAB_HWCACHE_ALIGN, NULL); ··· 8291 8259 8292 8260 destroy_cache: 8293 8261 kmem_cache_destroy(srb_cachep); 8262 + 8263 + qla_trace_uninit(); 8294 8264 return ret; 8295 8265 } 8296 8266 ··· 8311 8277 fc_release_transport(qla2xxx_transport_template); 8312 8278 qlt_exit(); 8313 8279 kmem_cache_destroy(srb_cachep); 8280 + qla_trace_uninit(); 8314 8281 } 8315 8282 8316 8283 module_init(qla2x00_module_init);