hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/crypto/caam/error.c
....@@ -13,7 +13,7 @@
1313 #ifdef DEBUG
1414 #include <linux/highmem.h>
1515
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,
1717 int rowsize, int groupsize, struct scatterlist *sg,
1818 size_t tlen, bool ascii)
1919 {
....@@ -35,20 +35,29 @@
3535
3636 buf = it_page + it->offset;
3737 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);
4040 tlen -= len;
4141
4242 kunmap_atomic(it_page);
4343 }
4444 }
4545 #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,
4747 int rowsize, int groupsize, struct scatterlist *sg,
4848 size_t tlen, bool ascii)
4949 {}
5050 #endif /* DEBUG */
5151 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);
5261
5362 static const struct {
5463 u8 value;
....@@ -108,6 +117,55 @@
108117 { 0xF1, "3GPP HFN matches or exceeds the Threshold" },
109118 };
110119
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
+
111169 static const char * const cha_id_list[] = {
112170 "",
113171 "AES",
....@@ -154,10 +212,13 @@
154212 "Prediction resistance and test request",
155213 "Uninstantiate",
156214 "Secure key generation",
215
+ "",
216
+ "Hardware error",
217
+ "Continuous check"
157218 };
158219
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)
161222 {
162223 u8 cha_id = (status & JRSTA_CCBERR_CHAID_MASK) >>
163224 JRSTA_CCBERR_CHAID_SHIFT;
....@@ -193,22 +254,27 @@
193254 * CCB ICV check failures are part of normal operation life;
194255 * we leave the upper layers to do what they want with them.
195256 */
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;
201265 }
202266
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)
205269 {
206270 dev_err(jrdev, "%08x: %s: %s() not implemented\n",
207271 status, error, __func__);
272
+
273
+ return -EINVAL;
208274 }
209275
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)
212278 {
213279 u8 err_id = status & JRSTA_DECOERR_ERROR_MASK;
214280 u8 idx = (status & JRSTA_DECOERR_INDEX_MASK) >>
....@@ -234,27 +300,56 @@
234300
235301 dev_err(jrdev, "%08x: %s: %s %d: %s%s\n",
236302 status, error, idx_str, idx, err_str, err_err_code);
303
+
304
+ return -EINVAL;
237305 }
238306
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)
241332 {
242333 dev_err(jrdev, "%08x: %s: %s() not implemented\n",
243334 status, error, __func__);
335
+
336
+ return -EINVAL;
244337 }
245338
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)
248341 {
249342 dev_err(jrdev, "%08x: %s: %s() not implemented\n",
250343 status, error, __func__);
344
+
345
+ return -EINVAL;
251346 }
252347
253
-void caam_jr_strstatus(struct device *jrdev, u32 status)
348
+int caam_strstatus(struct device *jrdev, u32 status, bool qi_v2)
254349 {
255350 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);
258353 const char *error;
259354 } status_src[16] = {
260355 { NULL, "No error" },
....@@ -262,7 +357,7 @@
262357 { report_ccb_status, "CCB" },
263358 { report_jump_status, "Jump" },
264359 { report_deco_status, "DECO" },
265
- { NULL, "Queue Manager Interface" },
360
+ { report_qi_status, "Queue Manager Interface" },
266361 { report_jr_status, "Job Ring" },
267362 { report_cond_code_status, "Condition Code" },
268363 { NULL, NULL },
....@@ -282,10 +377,17 @@
282377 * Otherwise print the error source name.
283378 */
284379 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)
287383 dev_err(jrdev, "%d: %s\n", ssrc, error);
288384 else
289385 dev_err(jrdev, "%d: unknown error source\n", ssrc);
386
+
387
+ return -EINVAL;
290388 }
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");