ccp-dev.c (341924049558e5f7c1a148a2c461a417933d35d9) ccp-dev.c (52393d617af7b554f03531e6756facf2ea687d2e)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * AMD Cryptographic Coprocessor (CCP) driver
4 *
5 * Copyright (C) 2013,2017 Advanced Micro Devices, Inc.
6 *
7 * Author: Tom Lendacky <thomas.lendacky@amd.com>
8 * Author: Gary R Hook <gary.hook@amd.com>
1/*
2 * AMD Cryptographic Coprocessor (CCP) driver
3 *
4 * Copyright (C) 2013,2017 Advanced Micro Devices, Inc.
5 *
6 * Author: Tom Lendacky <thomas.lendacky@amd.com>
7 * Author: Gary R Hook <gary.hook@amd.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
9 */
10
11#include <linux/kernel.h>
12#include <linux/kthread.h>
13#include <linux/sched.h>
14#include <linux/interrupt.h>
15#include <linux/spinlock.h>
16#include <linux/spinlock_types.h>

--- 10 unchanged lines hidden (view full) ---

27#include "ccp-dev.h"
28
29struct ccp_tasklet_data {
30 struct completion completion;
31 struct ccp_cmd *cmd;
32};
33
34/* Human-readable error strings */
12 */
13
14#include <linux/kernel.h>
15#include <linux/kthread.h>
16#include <linux/sched.h>
17#include <linux/interrupt.h>
18#include <linux/spinlock.h>
19#include <linux/spinlock_types.h>

--- 10 unchanged lines hidden (view full) ---

30#include "ccp-dev.h"
31
32struct ccp_tasklet_data {
33 struct completion completion;
34 struct ccp_cmd *cmd;
35};
36
37/* Human-readable error strings */
38#define CCP_MAX_ERROR_CODE 64
35static char *ccp_error_codes[] = {
36 "",
39static char *ccp_error_codes[] = {
40 "",
37 "ERR 01: ILLEGAL_ENGINE",
38 "ERR 02: ILLEGAL_KEY_ID",
39 "ERR 03: ILLEGAL_FUNCTION_TYPE",
40 "ERR 04: ILLEGAL_FUNCTION_MODE",
41 "ERR 05: ILLEGAL_FUNCTION_ENCRYPT",
42 "ERR 06: ILLEGAL_FUNCTION_SIZE",
43 "ERR 07: Zlib_MISSING_INIT_EOM",
44 "ERR 08: ILLEGAL_FUNCTION_RSVD",
45 "ERR 09: ILLEGAL_BUFFER_LENGTH",
46 "ERR 10: VLSB_FAULT",
47 "ERR 11: ILLEGAL_MEM_ADDR",
48 "ERR 12: ILLEGAL_MEM_SEL",
49 "ERR 13: ILLEGAL_CONTEXT_ID",
50 "ERR 14: ILLEGAL_KEY_ADDR",
51 "ERR 15: 0xF Reserved",
52 "ERR 16: Zlib_ILLEGAL_MULTI_QUEUE",
53 "ERR 17: Zlib_ILLEGAL_JOBID_CHANGE",
54 "ERR 18: CMD_TIMEOUT",
55 "ERR 19: IDMA0_AXI_SLVERR",
56 "ERR 20: IDMA0_AXI_DECERR",
57 "ERR 21: 0x15 Reserved",
58 "ERR 22: IDMA1_AXI_SLAVE_FAULT",
59 "ERR 23: IDMA1_AIXI_DECERR",
60 "ERR 24: 0x18 Reserved",
61 "ERR 25: ZLIBVHB_AXI_SLVERR",
62 "ERR 26: ZLIBVHB_AXI_DECERR",
63 "ERR 27: 0x1B Reserved",
64 "ERR 27: ZLIB_UNEXPECTED_EOM",
65 "ERR 27: ZLIB_EXTRA_DATA",
66 "ERR 30: ZLIB_BTYPE",
67 "ERR 31: ZLIB_UNDEFINED_SYMBOL",
68 "ERR 32: ZLIB_UNDEFINED_DISTANCE_S",
69 "ERR 33: ZLIB_CODE_LENGTH_SYMBOL",
70 "ERR 34: ZLIB _VHB_ILLEGAL_FETCH",
71 "ERR 35: ZLIB_UNCOMPRESSED_LEN",
72 "ERR 36: ZLIB_LIMIT_REACHED",
73 "ERR 37: ZLIB_CHECKSUM_MISMATCH0",
74 "ERR 38: ODMA0_AXI_SLVERR",
75 "ERR 39: ODMA0_AXI_DECERR",
76 "ERR 40: 0x28 Reserved",
77 "ERR 41: ODMA1_AXI_SLVERR",
78 "ERR 42: ODMA1_AXI_DECERR",
79 "ERR 43: LSB_PARITY_ERR",
41 "ILLEGAL_ENGINE",
42 "ILLEGAL_KEY_ID",
43 "ILLEGAL_FUNCTION_TYPE",
44 "ILLEGAL_FUNCTION_MODE",
45 "ILLEGAL_FUNCTION_ENCRYPT",
46 "ILLEGAL_FUNCTION_SIZE",
47 "Zlib_MISSING_INIT_EOM",
48 "ILLEGAL_FUNCTION_RSVD",
49 "ILLEGAL_BUFFER_LENGTH",
50 "VLSB_FAULT",
51 "ILLEGAL_MEM_ADDR",
52 "ILLEGAL_MEM_SEL",
53 "ILLEGAL_CONTEXT_ID",
54 "ILLEGAL_KEY_ADDR",
55 "0xF Reserved",
56 "Zlib_ILLEGAL_MULTI_QUEUE",
57 "Zlib_ILLEGAL_JOBID_CHANGE",
58 "CMD_TIMEOUT",
59 "IDMA0_AXI_SLVERR",
60 "IDMA0_AXI_DECERR",
61 "0x15 Reserved",
62 "IDMA1_AXI_SLAVE_FAULT",
63 "IDMA1_AIXI_DECERR",
64 "0x18 Reserved",
65 "ZLIBVHB_AXI_SLVERR",
66 "ZLIBVHB_AXI_DECERR",
67 "0x1B Reserved",
68 "ZLIB_UNEXPECTED_EOM",
69 "ZLIB_EXTRA_DATA",
70 "ZLIB_BTYPE",
71 "ZLIB_UNDEFINED_SYMBOL",
72 "ZLIB_UNDEFINED_DISTANCE_S",
73 "ZLIB_CODE_LENGTH_SYMBOL",
74 "ZLIB _VHB_ILLEGAL_FETCH",
75 "ZLIB_UNCOMPRESSED_LEN",
76 "ZLIB_LIMIT_REACHED",
77 "ZLIB_CHECKSUM_MISMATCH0",
78 "ODMA0_AXI_SLVERR",
79 "ODMA0_AXI_DECERR",
80 "0x28 Reserved",
81 "ODMA1_AXI_SLVERR",
82 "ODMA1_AXI_DECERR",
80};
81
83};
84
82void ccp_log_error(struct ccp_device *d, int e)
85void ccp_log_error(struct ccp_device *d, unsigned int e)
83{
86{
84 dev_err(d->dev, "CCP error: %s (0x%x)\n", ccp_error_codes[e], e);
87 if (WARN_ON(e >= CCP_MAX_ERROR_CODE))
88 return;
89
90 if (e < ARRAY_SIZE(ccp_error_codes))
91 dev_err(d->dev, "CCP error %d: %s\n", e, ccp_error_codes[e]);
92 else
93 dev_err(d->dev, "CCP error %d: Unknown Error\n", e);
85}
86
87/* List of CCPs, CCP count, read-write access lock, and access functions
88 *
89 * Lock structure: get ccp_unit_lock for reading whenever we need to
90 * examine the CCP list. While holding it for reading we can acquire
91 * the RR lock to update the round-robin next-CCP pointer. The unit lock
92 * must be acquired before the RR lock.

--- 534 unchanged lines hidden ---
94}
95
96/* List of CCPs, CCP count, read-write access lock, and access functions
97 *
98 * Lock structure: get ccp_unit_lock for reading whenever we need to
99 * examine the CCP list. While holding it for reading we can acquire
100 * the RR lock to update the round-robin next-CCP pointer. The unit lock
101 * must be acquired before the RR lock.

--- 534 unchanged lines hidden ---