Skip to content

Commit 4c41a48

Browse files
niklas88Alexander Gordeev
authored andcommitted
s390/pci: Add pci_msg debug view to PCI report
Using the newly introduced debug_dump() mechanism add formatted content of pci_debug_msg_id to the PCI report. The formatting is based on the existing sprintf format but removes caller pointer and area index and adds an column header. This will allow the platform to collect this log data together with hardware errors. This sets the reverse flag such that the newest log entries get added to the PCI report even if not all debug log entries fit. Reviewed-by: Halil Pasic <pasic@linux.ibm.com> Co-developed-by: Halil Pasic <pasic@linux.ibm.com> Signed-off-by: Halil Pasic <pasic@linux.ibm.com> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
1 parent dc18c81 commit 4c41a48

3 files changed

Lines changed: 54 additions & 5 deletions

File tree

arch/s390/include/asm/debug.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ int debug_dflt_header_fn(debug_info_t *id, struct debug_view *view,
8585
int area, debug_entry_t *entry,
8686
char *out_buf, size_t out_buf_size);
8787

88+
#define DEBUG_SPRINTF_MAX_ARGS 10
89+
int debug_sprintf_format_fn(debug_info_t *id, struct debug_view *view,
90+
char *out_buf, size_t out_buf_size,
91+
const char *inbuf);
8892
struct debug_view {
8993
char name[DEBUG_MAX_NAME_LEN];
9094
debug_prolog_proc_t *prolog_proc;

arch/s390/kernel/debug.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ static int debug_input_flush_fn(debug_info_t *id, struct debug_view *view,
9595
static int debug_hex_ascii_format_fn(debug_info_t *id, struct debug_view *view,
9696
char *out_buf, size_t out_buf_size,
9797
const char *in_buf);
98-
static int debug_sprintf_format_fn(debug_info_t *id, struct debug_view *view,
99-
char *out_buf, size_t out_buf_size,
100-
const char *inbuf);
10198
static void debug_areas_swap(debug_info_t *a, debug_info_t *b);
10299
static void debug_events_append(debug_info_t *dest, debug_info_t *src);
103100

@@ -1685,8 +1682,8 @@ EXPORT_SYMBOL(debug_dflt_header_fn);
16851682

16861683
#define DEBUG_SPRINTF_MAX_ARGS 10
16871684

1688-
static int debug_sprintf_format_fn(debug_info_t *id, struct debug_view *view,
1689-
char *out_buf, size_t out_buf_size, const char *inbuf)
1685+
int debug_sprintf_format_fn(debug_info_t *id, struct debug_view *view,
1686+
char *out_buf, size_t out_buf_size, const char *inbuf)
16901687
{
16911688
debug_sprintf_entry_t *curr_event = (debug_sprintf_entry_t *)inbuf;
16921689
int num_longs, num_used_args = 0, i, rc = 0;
@@ -1723,6 +1720,7 @@ static int debug_sprintf_format_fn(debug_info_t *id, struct debug_view *view,
17231720
out:
17241721
return rc;
17251722
}
1723+
EXPORT_SYMBOL(debug_sprintf_format_fn);
17261724

17271725
/*
17281726
* debug_init:

arch/s390/pci/pci_report.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include <linux/pci.h>
1616

1717
#include <asm/sclp.h>
18+
#include <asm/debug.h>
19+
#include <asm/pci_debug.h>
1820

1921
#include "pci_report.h"
2022

@@ -48,6 +50,44 @@ static const char *zpci_state_str(pci_channel_state_t state)
4850
};
4951
}
5052

53+
static int debug_log_header_fn(debug_info_t *id, struct debug_view *view,
54+
int area, debug_entry_t *entry, char *out_buf,
55+
size_t out_buf_size)
56+
{
57+
unsigned long sec, usec;
58+
unsigned int level;
59+
char *except_str;
60+
int rc = 0;
61+
62+
level = entry->level;
63+
sec = entry->clock;
64+
usec = do_div(sec, USEC_PER_SEC);
65+
66+
if (entry->exception)
67+
except_str = "*";
68+
else
69+
except_str = "-";
70+
rc += scnprintf(out_buf, out_buf_size, "%011ld:%06lu %1u %1s %04u ",
71+
sec, usec, level, except_str,
72+
entry->cpu);
73+
return rc;
74+
}
75+
76+
static int debug_prolog_header(debug_info_t *id, struct debug_view *view,
77+
char *out_buf, size_t out_buf_size)
78+
{
79+
return scnprintf(out_buf, out_buf_size, "sec:usec level except cpu msg\n");
80+
}
81+
82+
static struct debug_view debug_log_view = {
83+
"pci_msg_log",
84+
&debug_prolog_header,
85+
&debug_log_header_fn,
86+
&debug_sprintf_format_fn,
87+
NULL,
88+
NULL
89+
};
90+
5191
/**
5292
* zpci_report_status - Report the status of operations on a PCI device
5393
* @zdev: The PCI device for which to report status
@@ -59,6 +99,8 @@ static const char *zpci_state_str(pci_channel_state_t state)
5999
* Event Data mechanism. Besides the operation and status strings the report
60100
* also contains additional information about the device deemed useful for
61101
* debug such as the currently bound device driver, if any, and error state.
102+
* Additionally a string representation of pci_debug_msg_id, or as much as fits,
103+
* is also included.
62104
*
63105
* Return: 0 on success an error code < 0 otherwise.
64106
*/
@@ -92,6 +134,11 @@ int zpci_report_status(struct zpci_dev *zdev, const char *operation, const char
92134
buf += scnprintf(buf, end - buf, "state: %s\n",
93135
(pdev) ? zpci_state_str(pdev->error_state) : "n/a");
94136
buf += scnprintf(buf, end - buf, "driver: %s\n", (driver) ? driver->name : "n/a");
137+
ret = debug_dump(pci_debug_msg_id, &debug_log_view, buf, end - buf, true);
138+
if (ret < 0)
139+
pr_err("Reading PCI debug messages failed with code %d\n", ret);
140+
else
141+
buf += ret;
95142

96143
report->header.version = 1;
97144
report->header.action = SCLP_ERRNOTIFY_AQ_INFO_LOG;

0 commit comments

Comments
 (0)