.. | .. |
---|
13 | 13 | #ifdef DEBUG |
---|
14 | 14 | #include <linux/highmem.h> |
---|
15 | 15 | |
---|
16 | | -void caam_dump_sg(const char *level, const char *prefix_str, int prefix_type, |
---|
| 16 | +void caam_dump_sg(const char *prefix_str, int prefix_type, |
---|
17 | 17 | int rowsize, int groupsize, struct scatterlist *sg, |
---|
18 | 18 | size_t tlen, bool ascii) |
---|
19 | 19 | { |
---|
.. | .. |
---|
35 | 35 | |
---|
36 | 36 | buf = it_page + it->offset; |
---|
37 | 37 | len = min_t(size_t, tlen, it->length); |
---|
38 | | - print_hex_dump(level, prefix_str, prefix_type, rowsize, |
---|
39 | | - groupsize, buf, len, ascii); |
---|
| 38 | + print_hex_dump_debug(prefix_str, prefix_type, rowsize, |
---|
| 39 | + groupsize, buf, len, ascii); |
---|
40 | 40 | tlen -= len; |
---|
41 | 41 | |
---|
42 | 42 | kunmap_atomic(it_page); |
---|
43 | 43 | } |
---|
44 | 44 | } |
---|
45 | 45 | #else |
---|
46 | | -void caam_dump_sg(const char *level, const char *prefix_str, int prefix_type, |
---|
| 46 | +void caam_dump_sg(const char *prefix_str, int prefix_type, |
---|
47 | 47 | int rowsize, int groupsize, struct scatterlist *sg, |
---|
48 | 48 | size_t tlen, bool ascii) |
---|
49 | 49 | {} |
---|
50 | 50 | #endif /* DEBUG */ |
---|
51 | 51 | EXPORT_SYMBOL(caam_dump_sg); |
---|
| 52 | + |
---|
| 53 | +bool caam_little_end; |
---|
| 54 | +EXPORT_SYMBOL(caam_little_end); |
---|
| 55 | + |
---|
| 56 | +bool caam_imx; |
---|
| 57 | +EXPORT_SYMBOL(caam_imx); |
---|
| 58 | + |
---|
| 59 | +size_t caam_ptr_sz; |
---|
| 60 | +EXPORT_SYMBOL(caam_ptr_sz); |
---|
52 | 61 | |
---|
53 | 62 | static const struct { |
---|
54 | 63 | u8 value; |
---|
.. | .. |
---|
108 | 117 | { 0xF1, "3GPP HFN matches or exceeds the Threshold" }, |
---|
109 | 118 | }; |
---|
110 | 119 | |
---|
| 120 | +static const struct { |
---|
| 121 | + u8 value; |
---|
| 122 | + const char *error_text; |
---|
| 123 | +} qi_error_list[] = { |
---|
| 124 | + { 0x00, "No error" }, |
---|
| 125 | + { 0x1F, "Job terminated by FQ or ICID flush" }, |
---|
| 126 | + { 0x20, "FD format error"}, |
---|
| 127 | + { 0x21, "FD command format error"}, |
---|
| 128 | + { 0x23, "FL format error"}, |
---|
| 129 | + { 0x25, "CRJD specified in FD, but not enabled in FLC"}, |
---|
| 130 | + { 0x30, "Max. buffer size too small"}, |
---|
| 131 | + { 0x31, "DHR exceeds max. buffer size (allocate mode, S/G format)"}, |
---|
| 132 | + { 0x32, "SGT exceeds max. buffer size (allocate mode, S/G format"}, |
---|
| 133 | + { 0x33, "Size over/underflow (allocate mode)"}, |
---|
| 134 | + { 0x34, "Size over/underflow (reuse mode)"}, |
---|
| 135 | + { 0x35, "Length exceeds max. short length (allocate mode, S/G/ format)"}, |
---|
| 136 | + { 0x36, "Memory footprint exceeds max. value (allocate mode, S/G/ format)"}, |
---|
| 137 | + { 0x41, "SBC frame format not supported (allocate mode)"}, |
---|
| 138 | + { 0x42, "Pool 0 invalid / pool 1 size < pool 0 size (allocate mode)"}, |
---|
| 139 | + { 0x43, "Annotation output enabled but ASAR = 0 (allocate mode)"}, |
---|
| 140 | + { 0x44, "Unsupported or reserved frame format or SGHR = 1 (reuse mode)"}, |
---|
| 141 | + { 0x45, "DHR correction underflow (reuse mode, single buffer format)"}, |
---|
| 142 | + { 0x46, "Annotation length exceeds offset (reuse mode)"}, |
---|
| 143 | + { 0x48, "Annotation output enabled but ASA limited by ASAR (reuse mode)"}, |
---|
| 144 | + { 0x49, "Data offset correction exceeds input frame data length (reuse mode)"}, |
---|
| 145 | + { 0x4B, "Annotation output enabled but ASA cannot be expanded (frame list)"}, |
---|
| 146 | + { 0x51, "Unsupported IF reuse mode"}, |
---|
| 147 | + { 0x52, "Unsupported FL use mode"}, |
---|
| 148 | + { 0x53, "Unsupported RJD use mode"}, |
---|
| 149 | + { 0x54, "Unsupported inline descriptor use mode"}, |
---|
| 150 | + { 0xC0, "Table buffer pool 0 depletion"}, |
---|
| 151 | + { 0xC1, "Table buffer pool 1 depletion"}, |
---|
| 152 | + { 0xC2, "Data buffer pool 0 depletion, no OF allocated"}, |
---|
| 153 | + { 0xC3, "Data buffer pool 1 depletion, no OF allocated"}, |
---|
| 154 | + { 0xC4, "Data buffer pool 0 depletion, partial OF allocated"}, |
---|
| 155 | + { 0xC5, "Data buffer pool 1 depletion, partial OF allocated"}, |
---|
| 156 | + { 0xD0, "FLC read error"}, |
---|
| 157 | + { 0xD1, "FL read error"}, |
---|
| 158 | + { 0xD2, "FL write error"}, |
---|
| 159 | + { 0xD3, "OF SGT write error"}, |
---|
| 160 | + { 0xD4, "PTA read error"}, |
---|
| 161 | + { 0xD5, "PTA write error"}, |
---|
| 162 | + { 0xD6, "OF SGT F-bit write error"}, |
---|
| 163 | + { 0xD7, "ASA write error"}, |
---|
| 164 | + { 0xE1, "FLC[ICR]=0 ICID error"}, |
---|
| 165 | + { 0xE2, "FLC[ICR]=1 ICID error"}, |
---|
| 166 | + { 0xE4, "source of ICID flush not trusted (BDI = 0)"}, |
---|
| 167 | +}; |
---|
| 168 | + |
---|
111 | 169 | static const char * const cha_id_list[] = { |
---|
112 | 170 | "", |
---|
113 | 171 | "AES", |
---|
.. | .. |
---|
154 | 212 | "Prediction resistance and test request", |
---|
155 | 213 | "Uninstantiate", |
---|
156 | 214 | "Secure key generation", |
---|
| 215 | + "", |
---|
| 216 | + "Hardware error", |
---|
| 217 | + "Continuous check" |
---|
157 | 218 | }; |
---|
158 | 219 | |
---|
159 | | -static void report_ccb_status(struct device *jrdev, const u32 status, |
---|
160 | | - const char *error) |
---|
| 220 | +static int report_ccb_status(struct device *jrdev, const u32 status, |
---|
| 221 | + const char *error) |
---|
161 | 222 | { |
---|
162 | 223 | u8 cha_id = (status & JRSTA_CCBERR_CHAID_MASK) >> |
---|
163 | 224 | JRSTA_CCBERR_CHAID_SHIFT; |
---|
.. | .. |
---|
193 | 254 | * CCB ICV check failures are part of normal operation life; |
---|
194 | 255 | * we leave the upper layers to do what they want with them. |
---|
195 | 256 | */ |
---|
196 | | - if (err_id != JRSTA_CCBERR_ERRID_ICVCHK) |
---|
197 | | - dev_err(jrdev, "%08x: %s: %s %d: %s%s: %s%s\n", |
---|
198 | | - status, error, idx_str, idx, |
---|
199 | | - cha_str, cha_err_code, |
---|
200 | | - err_str, err_err_code); |
---|
| 257 | + if (err_id == JRSTA_CCBERR_ERRID_ICVCHK) |
---|
| 258 | + return -EBADMSG; |
---|
| 259 | + |
---|
| 260 | + dev_err_ratelimited(jrdev, "%08x: %s: %s %d: %s%s: %s%s\n", status, |
---|
| 261 | + error, idx_str, idx, cha_str, cha_err_code, |
---|
| 262 | + err_str, err_err_code); |
---|
| 263 | + |
---|
| 264 | + return -EINVAL; |
---|
201 | 265 | } |
---|
202 | 266 | |
---|
203 | | -static void report_jump_status(struct device *jrdev, const u32 status, |
---|
204 | | - const char *error) |
---|
| 267 | +static int report_jump_status(struct device *jrdev, const u32 status, |
---|
| 268 | + const char *error) |
---|
205 | 269 | { |
---|
206 | 270 | dev_err(jrdev, "%08x: %s: %s() not implemented\n", |
---|
207 | 271 | status, error, __func__); |
---|
| 272 | + |
---|
| 273 | + return -EINVAL; |
---|
208 | 274 | } |
---|
209 | 275 | |
---|
210 | | -static void report_deco_status(struct device *jrdev, const u32 status, |
---|
211 | | - const char *error) |
---|
| 276 | +static int report_deco_status(struct device *jrdev, const u32 status, |
---|
| 277 | + const char *error) |
---|
212 | 278 | { |
---|
213 | 279 | u8 err_id = status & JRSTA_DECOERR_ERROR_MASK; |
---|
214 | 280 | u8 idx = (status & JRSTA_DECOERR_INDEX_MASK) >> |
---|
.. | .. |
---|
234 | 300 | |
---|
235 | 301 | dev_err(jrdev, "%08x: %s: %s %d: %s%s\n", |
---|
236 | 302 | status, error, idx_str, idx, err_str, err_err_code); |
---|
| 303 | + |
---|
| 304 | + return -EINVAL; |
---|
237 | 305 | } |
---|
238 | 306 | |
---|
239 | | -static void report_jr_status(struct device *jrdev, const u32 status, |
---|
240 | | - const char *error) |
---|
| 307 | +static int report_qi_status(struct device *qidev, const u32 status, |
---|
| 308 | + const char *error) |
---|
| 309 | +{ |
---|
| 310 | + u8 err_id = status & JRSTA_QIERR_ERROR_MASK; |
---|
| 311 | + const char *err_str = "unidentified error value 0x"; |
---|
| 312 | + char err_err_code[3] = { 0 }; |
---|
| 313 | + int i; |
---|
| 314 | + |
---|
| 315 | + for (i = 0; i < ARRAY_SIZE(qi_error_list); i++) |
---|
| 316 | + if (qi_error_list[i].value == err_id) |
---|
| 317 | + break; |
---|
| 318 | + |
---|
| 319 | + if (i != ARRAY_SIZE(qi_error_list) && qi_error_list[i].error_text) |
---|
| 320 | + err_str = qi_error_list[i].error_text; |
---|
| 321 | + else |
---|
| 322 | + snprintf(err_err_code, sizeof(err_err_code), "%02x", err_id); |
---|
| 323 | + |
---|
| 324 | + dev_err(qidev, "%08x: %s: %s%s\n", |
---|
| 325 | + status, error, err_str, err_err_code); |
---|
| 326 | + |
---|
| 327 | + return -EINVAL; |
---|
| 328 | +} |
---|
| 329 | + |
---|
| 330 | +static int report_jr_status(struct device *jrdev, const u32 status, |
---|
| 331 | + const char *error) |
---|
241 | 332 | { |
---|
242 | 333 | dev_err(jrdev, "%08x: %s: %s() not implemented\n", |
---|
243 | 334 | status, error, __func__); |
---|
| 335 | + |
---|
| 336 | + return -EINVAL; |
---|
244 | 337 | } |
---|
245 | 338 | |
---|
246 | | -static void report_cond_code_status(struct device *jrdev, const u32 status, |
---|
247 | | - const char *error) |
---|
| 339 | +static int report_cond_code_status(struct device *jrdev, const u32 status, |
---|
| 340 | + const char *error) |
---|
248 | 341 | { |
---|
249 | 342 | dev_err(jrdev, "%08x: %s: %s() not implemented\n", |
---|
250 | 343 | status, error, __func__); |
---|
| 344 | + |
---|
| 345 | + return -EINVAL; |
---|
251 | 346 | } |
---|
252 | 347 | |
---|
253 | | -void caam_jr_strstatus(struct device *jrdev, u32 status) |
---|
| 348 | +int caam_strstatus(struct device *jrdev, u32 status, bool qi_v2) |
---|
254 | 349 | { |
---|
255 | 350 | static const struct stat_src { |
---|
256 | | - void (*report_ssed)(struct device *jrdev, const u32 status, |
---|
257 | | - const char *error); |
---|
| 351 | + int (*report_ssed)(struct device *jrdev, const u32 status, |
---|
| 352 | + const char *error); |
---|
258 | 353 | const char *error; |
---|
259 | 354 | } status_src[16] = { |
---|
260 | 355 | { NULL, "No error" }, |
---|
.. | .. |
---|
262 | 357 | { report_ccb_status, "CCB" }, |
---|
263 | 358 | { report_jump_status, "Jump" }, |
---|
264 | 359 | { report_deco_status, "DECO" }, |
---|
265 | | - { NULL, "Queue Manager Interface" }, |
---|
| 360 | + { report_qi_status, "Queue Manager Interface" }, |
---|
266 | 361 | { report_jr_status, "Job Ring" }, |
---|
267 | 362 | { report_cond_code_status, "Condition Code" }, |
---|
268 | 363 | { NULL, NULL }, |
---|
.. | .. |
---|
282 | 377 | * Otherwise print the error source name. |
---|
283 | 378 | */ |
---|
284 | 379 | if (status_src[ssrc].report_ssed) |
---|
285 | | - status_src[ssrc].report_ssed(jrdev, status, error); |
---|
286 | | - else if (error) |
---|
| 380 | + return status_src[ssrc].report_ssed(jrdev, status, error); |
---|
| 381 | + |
---|
| 382 | + if (error) |
---|
287 | 383 | dev_err(jrdev, "%d: %s\n", ssrc, error); |
---|
288 | 384 | else |
---|
289 | 385 | dev_err(jrdev, "%d: unknown error source\n", ssrc); |
---|
| 386 | + |
---|
| 387 | + return -EINVAL; |
---|
290 | 388 | } |
---|
291 | | -EXPORT_SYMBOL(caam_jr_strstatus); |
---|
| 389 | +EXPORT_SYMBOL(caam_strstatus); |
---|
| 390 | + |
---|
| 391 | +MODULE_LICENSE("GPL"); |
---|
| 392 | +MODULE_DESCRIPTION("FSL CAAM error reporting"); |
---|
| 393 | +MODULE_AUTHOR("Freescale Semiconductor"); |
---|