aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
authorHuang Ying <ying.huang@intel.com>2011-02-21 00:54:42 -0500
committerLen Brown <len.brown@intel.com>2011-03-21 22:59:08 -0400
commitb64a44146540a4761bb1cf8047fffd9dbf0c3090 (patch)
tree2a6fd718db4c5885eab7b41e1c8139f7b259cf00 /drivers/pci
parent885b976fada5bc6595a9fd3e67e3cb1a3d11f50b (diff)
PCIe, AER, use pre-generated prefix in error information printing
When printing PCIe AER error information, each line is prefixed with PCIe device and driver information. In original implementation, the prefix is generated when each line is printed. In fact, all lines share the same prefix. So this patch pre-generated the prefix, and use that one when each line is printed. In addition to common prefix can be pre-generated, the trailing white spaces in string constants and NULLs in char * array constants can be removed too. These can reduce the object file size further. The size of object file before and after changing is as follow: text data bss dec before: 3038 0 0 3038 after: 2118 0 0 2118 Signed-off-by: Huang Ying <ying.huang@intel.com> CC: Jesse Barnes <jbarnes@virtuousgeek.org> CC: Zhang Yanmin <yanmin.zhang@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/pcie/aer/aerdrv_errprint.c123
1 files changed, 48 insertions, 75 deletions
diff --git a/drivers/pci/pcie/aer/aerdrv_errprint.c b/drivers/pci/pcie/aer/aerdrv_errprint.c
index 9d3e4c8d0184..7a237f67129e 100644
--- a/drivers/pci/pcie/aer/aerdrv_errprint.c
+++ b/drivers/pci/pcie/aer/aerdrv_errprint.c
@@ -57,86 +57,44 @@
57 (e & AER_DATA_LINK_LAYER_ERROR_MASK(t)) ? AER_DATA_LINK_LAYER_ERROR : \ 57 (e & AER_DATA_LINK_LAYER_ERROR_MASK(t)) ? AER_DATA_LINK_LAYER_ERROR : \
58 AER_TRANSACTION_LAYER_ERROR) 58 AER_TRANSACTION_LAYER_ERROR)
59 59
60#define AER_PR(info, pdev, fmt, args...) \
61 printk("%s%s %s: " fmt, (info->severity == AER_CORRECTABLE) ? \
62 KERN_WARNING : KERN_ERR, dev_driver_string(&pdev->dev), \
63 dev_name(&pdev->dev), ## args)
64
65/* 60/*
66 * AER error strings 61 * AER error strings
67 */ 62 */
68static char *aer_error_severity_string[] = { 63static const char *aer_error_severity_string[] = {
69 "Uncorrected (Non-Fatal)", 64 "Uncorrected (Non-Fatal)",
70 "Uncorrected (Fatal)", 65 "Uncorrected (Fatal)",
71 "Corrected" 66 "Corrected"
72}; 67};
73 68
74static char *aer_error_layer[] = { 69static const char *aer_error_layer[] = {
75 "Physical Layer", 70 "Physical Layer",
76 "Data Link Layer", 71 "Data Link Layer",
77 "Transaction Layer" 72 "Transaction Layer"
78}; 73};
79static char *aer_correctable_error_string[] = { 74
80 "Receiver Error ", /* Bit Position 0 */ 75static const char *aer_correctable_error_string[] = {
81 NULL, 76 "Receiver Error", /* Bit Position 0 */
82 NULL,
83 NULL,
84 NULL,
85 NULL,
86 "Bad TLP ", /* Bit Position 6 */
87 "Bad DLLP ", /* Bit Position 7 */
88 "RELAY_NUM Rollover ", /* Bit Position 8 */
89 NULL,
90 NULL,
91 NULL,
92 "Replay Timer Timeout ", /* Bit Position 12 */
93 "Advisory Non-Fatal ", /* Bit Position 13 */
94 NULL,
95 NULL,
96 NULL,
97 NULL,
98 NULL,
99 NULL,
100 NULL,
101 NULL,
102 NULL,
103 NULL,
104 NULL, 77 NULL,
105 NULL, 78 NULL,
106 NULL, 79 NULL,
107 NULL, 80 NULL,
108 NULL, 81 NULL,
82 "Bad TLP", /* Bit Position 6 */
83 "Bad DLLP", /* Bit Position 7 */
84 "RELAY_NUM Rollover", /* Bit Position 8 */
109 NULL, 85 NULL,
110 NULL, 86 NULL,
111 NULL, 87 NULL,
88 "Replay Timer Timeout", /* Bit Position 12 */
89 "Advisory Non-Fatal", /* Bit Position 13 */
112}; 90};
113 91
114static char *aer_uncorrectable_error_string[] = { 92static const char *aer_uncorrectable_error_string[] = {
115 NULL,
116 NULL,
117 NULL,
118 NULL,
119 "Data Link Protocol ", /* Bit Position 4 */
120 NULL,
121 NULL,
122 NULL,
123 NULL,
124 NULL,
125 NULL,
126 NULL,
127 "Poisoned TLP ", /* Bit Position 12 */
128 "Flow Control Protocol ", /* Bit Position 13 */
129 "Completion Timeout ", /* Bit Position 14 */
130 "Completer Abort ", /* Bit Position 15 */
131 "Unexpected Completion ", /* Bit Position 16 */
132 "Receiver Overflow ", /* Bit Position 17 */
133 "Malformed TLP ", /* Bit Position 18 */
134 "ECRC ", /* Bit Position 19 */
135 "Unsupported Request ", /* Bit Position 20 */
136 NULL, 93 NULL,
137 NULL, 94 NULL,
138 NULL, 95 NULL,
139 NULL, 96 NULL,
97 "Data Link Protocol", /* Bit Position 4 */
140 NULL, 98 NULL,
141 NULL, 99 NULL,
142 NULL, 100 NULL,
@@ -144,19 +102,29 @@ static char *aer_uncorrectable_error_string[] = {
144 NULL, 102 NULL,
145 NULL, 103 NULL,
146 NULL, 104 NULL,
105 "Poisoned TLP", /* Bit Position 12 */
106 "Flow Control Protocol", /* Bit Position 13 */
107 "Completion Timeout", /* Bit Position 14 */
108 "Completer Abort", /* Bit Position 15 */
109 "Unexpected Completion", /* Bit Position 16 */
110 "Receiver Overflow", /* Bit Position 17 */
111 "Malformed TLP", /* Bit Position 18 */
112 "ECRC", /* Bit Position 19 */
113 "Unsupported Request", /* Bit Position 20 */
147}; 114};
148 115
149static char *aer_agent_string[] = { 116static const char *aer_agent_string[] = {
150 "Receiver ID", 117 "Receiver ID",
151 "Requester ID", 118 "Requester ID",
152 "Completer ID", 119 "Completer ID",
153 "Transmitter ID" 120 "Transmitter ID"
154}; 121};
155 122
156static void __aer_print_error(struct aer_err_info *info, struct pci_dev *dev) 123static void __aer_print_error(const char *prefix,
124 struct aer_err_info *info)
157{ 125{
158 int i, status; 126 int i, status;
159 char *errmsg = NULL; 127 const char *errmsg = NULL;
160 128
161 status = (info->status & ~info->mask); 129 status = (info->status & ~info->mask);
162 130
@@ -165,15 +133,17 @@ static void __aer_print_error(struct aer_err_info *info, struct pci_dev *dev)
165 continue; 133 continue;
166 134
167 if (info->severity == AER_CORRECTABLE) 135 if (info->severity == AER_CORRECTABLE)
168 errmsg = aer_correctable_error_string[i]; 136 errmsg = i < ARRAY_SIZE(aer_correctable_error_string) ?
137 aer_correctable_error_string[i] : NULL;
169 else 138 else
170 errmsg = aer_uncorrectable_error_string[i]; 139 errmsg = i < ARRAY_SIZE(aer_uncorrectable_error_string) ?
140 aer_uncorrectable_error_string[i] : NULL;
171 141
172 if (errmsg) 142 if (errmsg)
173 AER_PR(info, dev, " [%2d] %s%s\n", i, errmsg, 143 printk("%s"" [%2d] %-22s%s\n", prefix, i, errmsg,
174 info->first_error == i ? " (First)" : ""); 144 info->first_error == i ? " (First)" : "");
175 else 145 else
176 AER_PR(info, dev, " [%2d] Unknown Error Bit%s\n", i, 146 printk("%s"" [%2d] Unknown Error Bit%s\n", prefix, i,
177 info->first_error == i ? " (First)" : ""); 147 info->first_error == i ? " (First)" : "");
178 } 148 }
179} 149}
@@ -181,11 +151,15 @@ static void __aer_print_error(struct aer_err_info *info, struct pci_dev *dev)
181void aer_print_error(struct pci_dev *dev, struct aer_err_info *info) 151void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
182{ 152{
183 int id = ((dev->bus->number << 8) | dev->devfn); 153 int id = ((dev->bus->number << 8) | dev->devfn);
154 char prefix[44];
155
156 snprintf(prefix, sizeof(prefix), "%s%s %s: ",
157 (info->severity == AER_CORRECTABLE) ? KERN_WARNING : KERN_ERR,
158 dev_driver_string(&dev->dev), dev_name(&dev->dev));
184 159
185 if (info->status == 0) { 160 if (info->status == 0) {
186 AER_PR(info, dev, 161 printk("%s""PCIe Bus Error: severity=%s, type=Unaccessible, "
187 "PCIe Bus Error: severity=%s, type=Unaccessible, " 162 "id=%04x(Unregistered Agent ID)\n", prefix,
188 "id=%04x(Unregistered Agent ID)\n",
189 aer_error_severity_string[info->severity], id); 163 aer_error_severity_string[info->severity], id);
190 } else { 164 } else {
191 int layer, agent; 165 int layer, agent;
@@ -193,23 +167,22 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
193 layer = AER_GET_LAYER_ERROR(info->severity, info->status); 167 layer = AER_GET_LAYER_ERROR(info->severity, info->status);
194 agent = AER_GET_AGENT(info->severity, info->status); 168 agent = AER_GET_AGENT(info->severity, info->status);
195 169
196 AER_PR(info, dev, 170 printk("%s""PCIe Bus Error: severity=%s, type=%s, id=%04x(%s)\n",
197 "PCIe Bus Error: severity=%s, type=%s, id=%04x(%s)\n", 171 prefix, aer_error_severity_string[info->severity],
198 aer_error_severity_string[info->severity],
199 aer_error_layer[layer], id, aer_agent_string[agent]); 172 aer_error_layer[layer], id, aer_agent_string[agent]);
200 173
201 AER_PR(info, dev, 174 printk("%s"" device [%04x:%04x] error status/mask=%08x/%08x\n",
202 " device [%04x:%04x] error status/mask=%08x/%08x\n", 175 prefix, dev->vendor, dev->device,
203 dev->vendor, dev->device, info->status, info->mask); 176 info->status, info->mask);
204 177
205 __aer_print_error(info, dev); 178 __aer_print_error(prefix, info);
206 179
207 if (info->tlp_header_valid) { 180 if (info->tlp_header_valid) {
208 unsigned char *tlp = (unsigned char *) &info->tlp; 181 unsigned char *tlp = (unsigned char *) &info->tlp;
209 AER_PR(info, dev, " TLP Header:" 182 printk("%s"" TLP Header:"
210 " %02x%02x%02x%02x %02x%02x%02x%02x" 183 " %02x%02x%02x%02x %02x%02x%02x%02x"
211 " %02x%02x%02x%02x %02x%02x%02x%02x\n", 184 " %02x%02x%02x%02x %02x%02x%02x%02x\n",
212 *(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp, 185 prefix, *(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp,
213 *(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4), 186 *(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4),
214 *(tlp + 11), *(tlp + 10), *(tlp + 9), 187 *(tlp + 11), *(tlp + 10), *(tlp + 9),
215 *(tlp + 8), *(tlp + 15), *(tlp + 14), 188 *(tlp + 8), *(tlp + 15), *(tlp + 14),
@@ -218,8 +191,8 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
218 } 191 }
219 192
220 if (info->id && info->error_dev_num > 1 && info->id == id) 193 if (info->id && info->error_dev_num > 1 && info->id == id)
221 AER_PR(info, dev, 194 printk("%s"" Error of this Agent(%04x) is reported first\n",
222 " Error of this Agent(%04x) is reported first\n", id); 195 prefix, id);
223} 196}
224 197
225void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info) 198void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info)