ccp-dev-v3.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  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 <[email protected]>
  8. * Author: Gary R Hook <[email protected]>
  9. */
  10. #include <linux/module.h>
  11. #include <linux/kernel.h>
  12. #include <linux/kthread.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/ccp.h>
  15. #include "ccp-dev.h"
  16. static u32 ccp_alloc_ksb(struct ccp_cmd_queue *cmd_q, unsigned int count)
  17. {
  18. int start;
  19. struct ccp_device *ccp = cmd_q->ccp;
  20. for (;;) {
  21. mutex_lock(&ccp->sb_mutex);
  22. start = (u32)bitmap_find_next_zero_area(ccp->sb,
  23. ccp->sb_count,
  24. ccp->sb_start,
  25. count, 0);
  26. if (start <= ccp->sb_count) {
  27. bitmap_set(ccp->sb, start, count);
  28. mutex_unlock(&ccp->sb_mutex);
  29. break;
  30. }
  31. ccp->sb_avail = 0;
  32. mutex_unlock(&ccp->sb_mutex);
  33. /* Wait for KSB entries to become available */
  34. if (wait_event_interruptible(ccp->sb_queue, ccp->sb_avail))
  35. return 0;
  36. }
  37. return KSB_START + start;
  38. }
  39. static void ccp_free_ksb(struct ccp_cmd_queue *cmd_q, unsigned int start,
  40. unsigned int count)
  41. {
  42. struct ccp_device *ccp = cmd_q->ccp;
  43. if (!start)
  44. return;
  45. mutex_lock(&ccp->sb_mutex);
  46. bitmap_clear(ccp->sb, start - KSB_START, count);
  47. ccp->sb_avail = 1;
  48. mutex_unlock(&ccp->sb_mutex);
  49. wake_up_interruptible_all(&ccp->sb_queue);
  50. }
  51. static unsigned int ccp_get_free_slots(struct ccp_cmd_queue *cmd_q)
  52. {
  53. return CMD_Q_DEPTH(ioread32(cmd_q->reg_status));
  54. }
  55. static int ccp_do_cmd(struct ccp_op *op, u32 *cr, unsigned int cr_count)
  56. {
  57. struct ccp_cmd_queue *cmd_q = op->cmd_q;
  58. struct ccp_device *ccp = cmd_q->ccp;
  59. void __iomem *cr_addr;
  60. u32 cr0, cmd;
  61. unsigned int i;
  62. int ret = 0;
  63. /* We could read a status register to see how many free slots
  64. * are actually available, but reading that register resets it
  65. * and you could lose some error information.
  66. */
  67. cmd_q->free_slots--;
  68. cr0 = (cmd_q->id << REQ0_CMD_Q_SHIFT)
  69. | (op->jobid << REQ0_JOBID_SHIFT)
  70. | REQ0_WAIT_FOR_WRITE;
  71. if (op->soc)
  72. cr0 |= REQ0_STOP_ON_COMPLETE
  73. | REQ0_INT_ON_COMPLETE;
  74. if (op->ioc || !cmd_q->free_slots)
  75. cr0 |= REQ0_INT_ON_COMPLETE;
  76. /* Start at CMD_REQ1 */
  77. cr_addr = ccp->io_regs + CMD_REQ0 + CMD_REQ_INCR;
  78. mutex_lock(&ccp->req_mutex);
  79. /* Write CMD_REQ1 through CMD_REQx first */
  80. for (i = 0; i < cr_count; i++, cr_addr += CMD_REQ_INCR)
  81. iowrite32(*(cr + i), cr_addr);
  82. /* Tell the CCP to start */
  83. wmb();
  84. iowrite32(cr0, ccp->io_regs + CMD_REQ0);
  85. mutex_unlock(&ccp->req_mutex);
  86. if (cr0 & REQ0_INT_ON_COMPLETE) {
  87. /* Wait for the job to complete */
  88. ret = wait_event_interruptible(cmd_q->int_queue,
  89. cmd_q->int_rcvd);
  90. if (ret || cmd_q->cmd_error) {
  91. /* On error delete all related jobs from the queue */
  92. cmd = (cmd_q->id << DEL_Q_ID_SHIFT)
  93. | op->jobid;
  94. if (cmd_q->cmd_error)
  95. ccp_log_error(cmd_q->ccp,
  96. cmd_q->cmd_error);
  97. iowrite32(cmd, ccp->io_regs + DEL_CMD_Q_JOB);
  98. if (!ret)
  99. ret = -EIO;
  100. } else if (op->soc) {
  101. /* Delete just head job from the queue on SoC */
  102. cmd = DEL_Q_ACTIVE
  103. | (cmd_q->id << DEL_Q_ID_SHIFT)
  104. | op->jobid;
  105. iowrite32(cmd, ccp->io_regs + DEL_CMD_Q_JOB);
  106. }
  107. cmd_q->free_slots = CMD_Q_DEPTH(cmd_q->q_status);
  108. cmd_q->int_rcvd = 0;
  109. }
  110. return ret;
  111. }
  112. static int ccp_perform_aes(struct ccp_op *op)
  113. {
  114. u32 cr[6];
  115. /* Fill out the register contents for REQ1 through REQ6 */
  116. cr[0] = (CCP_ENGINE_AES << REQ1_ENGINE_SHIFT)
  117. | (op->u.aes.type << REQ1_AES_TYPE_SHIFT)
  118. | (op->u.aes.mode << REQ1_AES_MODE_SHIFT)
  119. | (op->u.aes.action << REQ1_AES_ACTION_SHIFT)
  120. | (op->sb_key << REQ1_KEY_KSB_SHIFT);
  121. cr[1] = op->src.u.dma.length - 1;
  122. cr[2] = ccp_addr_lo(&op->src.u.dma);
  123. cr[3] = (op->sb_ctx << REQ4_KSB_SHIFT)
  124. | (CCP_MEMTYPE_SYSTEM << REQ4_MEMTYPE_SHIFT)
  125. | ccp_addr_hi(&op->src.u.dma);
  126. cr[4] = ccp_addr_lo(&op->dst.u.dma);
  127. cr[5] = (CCP_MEMTYPE_SYSTEM << REQ6_MEMTYPE_SHIFT)
  128. | ccp_addr_hi(&op->dst.u.dma);
  129. if (op->u.aes.mode == CCP_AES_MODE_CFB)
  130. cr[0] |= ((0x7f) << REQ1_AES_CFB_SIZE_SHIFT);
  131. if (op->eom)
  132. cr[0] |= REQ1_EOM;
  133. if (op->init)
  134. cr[0] |= REQ1_INIT;
  135. return ccp_do_cmd(op, cr, ARRAY_SIZE(cr));
  136. }
  137. static int ccp_perform_xts_aes(struct ccp_op *op)
  138. {
  139. u32 cr[6];
  140. /* Fill out the register contents for REQ1 through REQ6 */
  141. cr[0] = (CCP_ENGINE_XTS_AES_128 << REQ1_ENGINE_SHIFT)
  142. | (op->u.xts.action << REQ1_AES_ACTION_SHIFT)
  143. | (op->u.xts.unit_size << REQ1_XTS_AES_SIZE_SHIFT)
  144. | (op->sb_key << REQ1_KEY_KSB_SHIFT);
  145. cr[1] = op->src.u.dma.length - 1;
  146. cr[2] = ccp_addr_lo(&op->src.u.dma);
  147. cr[3] = (op->sb_ctx << REQ4_KSB_SHIFT)
  148. | (CCP_MEMTYPE_SYSTEM << REQ4_MEMTYPE_SHIFT)
  149. | ccp_addr_hi(&op->src.u.dma);
  150. cr[4] = ccp_addr_lo(&op->dst.u.dma);
  151. cr[5] = (CCP_MEMTYPE_SYSTEM << REQ6_MEMTYPE_SHIFT)
  152. | ccp_addr_hi(&op->dst.u.dma);
  153. if (op->eom)
  154. cr[0] |= REQ1_EOM;
  155. if (op->init)
  156. cr[0] |= REQ1_INIT;
  157. return ccp_do_cmd(op, cr, ARRAY_SIZE(cr));
  158. }
  159. static int ccp_perform_sha(struct ccp_op *op)
  160. {
  161. u32 cr[6];
  162. /* Fill out the register contents for REQ1 through REQ6 */
  163. cr[0] = (CCP_ENGINE_SHA << REQ1_ENGINE_SHIFT)
  164. | (op->u.sha.type << REQ1_SHA_TYPE_SHIFT)
  165. | REQ1_INIT;
  166. cr[1] = op->src.u.dma.length - 1;
  167. cr[2] = ccp_addr_lo(&op->src.u.dma);
  168. cr[3] = (op->sb_ctx << REQ4_KSB_SHIFT)
  169. | (CCP_MEMTYPE_SYSTEM << REQ4_MEMTYPE_SHIFT)
  170. | ccp_addr_hi(&op->src.u.dma);
  171. if (op->eom) {
  172. cr[0] |= REQ1_EOM;
  173. cr[4] = lower_32_bits(op->u.sha.msg_bits);
  174. cr[5] = upper_32_bits(op->u.sha.msg_bits);
  175. } else {
  176. cr[4] = 0;
  177. cr[5] = 0;
  178. }
  179. return ccp_do_cmd(op, cr, ARRAY_SIZE(cr));
  180. }
  181. static int ccp_perform_rsa(struct ccp_op *op)
  182. {
  183. u32 cr[6];
  184. /* Fill out the register contents for REQ1 through REQ6 */
  185. cr[0] = (CCP_ENGINE_RSA << REQ1_ENGINE_SHIFT)
  186. | (op->u.rsa.mod_size << REQ1_RSA_MOD_SIZE_SHIFT)
  187. | (op->sb_key << REQ1_KEY_KSB_SHIFT)
  188. | REQ1_EOM;
  189. cr[1] = op->u.rsa.input_len - 1;
  190. cr[2] = ccp_addr_lo(&op->src.u.dma);
  191. cr[3] = (op->sb_ctx << REQ4_KSB_SHIFT)
  192. | (CCP_MEMTYPE_SYSTEM << REQ4_MEMTYPE_SHIFT)
  193. | ccp_addr_hi(&op->src.u.dma);
  194. cr[4] = ccp_addr_lo(&op->dst.u.dma);
  195. cr[5] = (CCP_MEMTYPE_SYSTEM << REQ6_MEMTYPE_SHIFT)
  196. | ccp_addr_hi(&op->dst.u.dma);
  197. return ccp_do_cmd(op, cr, ARRAY_SIZE(cr));
  198. }
  199. static int ccp_perform_passthru(struct ccp_op *op)
  200. {
  201. u32 cr[6];
  202. /* Fill out the register contents for REQ1 through REQ6 */
  203. cr[0] = (CCP_ENGINE_PASSTHRU << REQ1_ENGINE_SHIFT)
  204. | (op->u.passthru.bit_mod << REQ1_PT_BW_SHIFT)
  205. | (op->u.passthru.byte_swap << REQ1_PT_BS_SHIFT);
  206. if (op->src.type == CCP_MEMTYPE_SYSTEM)
  207. cr[1] = op->src.u.dma.length - 1;
  208. else
  209. cr[1] = op->dst.u.dma.length - 1;
  210. if (op->src.type == CCP_MEMTYPE_SYSTEM) {
  211. cr[2] = ccp_addr_lo(&op->src.u.dma);
  212. cr[3] = (CCP_MEMTYPE_SYSTEM << REQ4_MEMTYPE_SHIFT)
  213. | ccp_addr_hi(&op->src.u.dma);
  214. if (op->u.passthru.bit_mod != CCP_PASSTHRU_BITWISE_NOOP)
  215. cr[3] |= (op->sb_key << REQ4_KSB_SHIFT);
  216. } else {
  217. cr[2] = op->src.u.sb * CCP_SB_BYTES;
  218. cr[3] = (CCP_MEMTYPE_SB << REQ4_MEMTYPE_SHIFT);
  219. }
  220. if (op->dst.type == CCP_MEMTYPE_SYSTEM) {
  221. cr[4] = ccp_addr_lo(&op->dst.u.dma);
  222. cr[5] = (CCP_MEMTYPE_SYSTEM << REQ6_MEMTYPE_SHIFT)
  223. | ccp_addr_hi(&op->dst.u.dma);
  224. } else {
  225. cr[4] = op->dst.u.sb * CCP_SB_BYTES;
  226. cr[5] = (CCP_MEMTYPE_SB << REQ6_MEMTYPE_SHIFT);
  227. }
  228. if (op->eom)
  229. cr[0] |= REQ1_EOM;
  230. return ccp_do_cmd(op, cr, ARRAY_SIZE(cr));
  231. }
  232. static int ccp_perform_ecc(struct ccp_op *op)
  233. {
  234. u32 cr[6];
  235. /* Fill out the register contents for REQ1 through REQ6 */
  236. cr[0] = REQ1_ECC_AFFINE_CONVERT
  237. | (CCP_ENGINE_ECC << REQ1_ENGINE_SHIFT)
  238. | (op->u.ecc.function << REQ1_ECC_FUNCTION_SHIFT)
  239. | REQ1_EOM;
  240. cr[1] = op->src.u.dma.length - 1;
  241. cr[2] = ccp_addr_lo(&op->src.u.dma);
  242. cr[3] = (CCP_MEMTYPE_SYSTEM << REQ4_MEMTYPE_SHIFT)
  243. | ccp_addr_hi(&op->src.u.dma);
  244. cr[4] = ccp_addr_lo(&op->dst.u.dma);
  245. cr[5] = (CCP_MEMTYPE_SYSTEM << REQ6_MEMTYPE_SHIFT)
  246. | ccp_addr_hi(&op->dst.u.dma);
  247. return ccp_do_cmd(op, cr, ARRAY_SIZE(cr));
  248. }
  249. static void ccp_disable_queue_interrupts(struct ccp_device *ccp)
  250. {
  251. iowrite32(0x00, ccp->io_regs + IRQ_MASK_REG);
  252. }
  253. static void ccp_enable_queue_interrupts(struct ccp_device *ccp)
  254. {
  255. iowrite32(ccp->qim, ccp->io_regs + IRQ_MASK_REG);
  256. }
  257. static void ccp_irq_bh(unsigned long data)
  258. {
  259. struct ccp_device *ccp = (struct ccp_device *)data;
  260. struct ccp_cmd_queue *cmd_q;
  261. u32 q_int, status;
  262. unsigned int i;
  263. status = ioread32(ccp->io_regs + IRQ_STATUS_REG);
  264. for (i = 0; i < ccp->cmd_q_count; i++) {
  265. cmd_q = &ccp->cmd_q[i];
  266. q_int = status & (cmd_q->int_ok | cmd_q->int_err);
  267. if (q_int) {
  268. cmd_q->int_status = status;
  269. cmd_q->q_status = ioread32(cmd_q->reg_status);
  270. cmd_q->q_int_status = ioread32(cmd_q->reg_int_status);
  271. /* On error, only save the first error value */
  272. if ((q_int & cmd_q->int_err) && !cmd_q->cmd_error)
  273. cmd_q->cmd_error = CMD_Q_ERROR(cmd_q->q_status);
  274. cmd_q->int_rcvd = 1;
  275. /* Acknowledge the interrupt and wake the kthread */
  276. iowrite32(q_int, ccp->io_regs + IRQ_STATUS_REG);
  277. wake_up_interruptible(&cmd_q->int_queue);
  278. }
  279. }
  280. ccp_enable_queue_interrupts(ccp);
  281. }
  282. static irqreturn_t ccp_irq_handler(int irq, void *data)
  283. {
  284. struct ccp_device *ccp = (struct ccp_device *)data;
  285. ccp_disable_queue_interrupts(ccp);
  286. if (ccp->use_tasklet)
  287. tasklet_schedule(&ccp->irq_tasklet);
  288. else
  289. ccp_irq_bh((unsigned long)ccp);
  290. return IRQ_HANDLED;
  291. }
  292. static int ccp_init(struct ccp_device *ccp)
  293. {
  294. struct device *dev = ccp->dev;
  295. struct ccp_cmd_queue *cmd_q;
  296. struct dma_pool *dma_pool;
  297. char dma_pool_name[MAX_DMAPOOL_NAME_LEN];
  298. unsigned int qmr, i;
  299. int ret;
  300. /* Find available queues */
  301. ccp->qim = 0;
  302. qmr = ioread32(ccp->io_regs + Q_MASK_REG);
  303. for (i = 0; (i < MAX_HW_QUEUES) && (ccp->cmd_q_count < ccp->max_q_count); i++) {
  304. if (!(qmr & (1 << i)))
  305. continue;
  306. /* Allocate a dma pool for this queue */
  307. snprintf(dma_pool_name, sizeof(dma_pool_name), "%s_q%d",
  308. ccp->name, i);
  309. dma_pool = dma_pool_create(dma_pool_name, dev,
  310. CCP_DMAPOOL_MAX_SIZE,
  311. CCP_DMAPOOL_ALIGN, 0);
  312. if (!dma_pool) {
  313. dev_err(dev, "unable to allocate dma pool\n");
  314. ret = -ENOMEM;
  315. goto e_pool;
  316. }
  317. cmd_q = &ccp->cmd_q[ccp->cmd_q_count];
  318. ccp->cmd_q_count++;
  319. cmd_q->ccp = ccp;
  320. cmd_q->id = i;
  321. cmd_q->dma_pool = dma_pool;
  322. /* Reserve 2 KSB regions for the queue */
  323. cmd_q->sb_key = KSB_START + ccp->sb_start++;
  324. cmd_q->sb_ctx = KSB_START + ccp->sb_start++;
  325. ccp->sb_count -= 2;
  326. /* Preset some register values and masks that are queue
  327. * number dependent
  328. */
  329. cmd_q->reg_status = ccp->io_regs + CMD_Q_STATUS_BASE +
  330. (CMD_Q_STATUS_INCR * i);
  331. cmd_q->reg_int_status = ccp->io_regs + CMD_Q_INT_STATUS_BASE +
  332. (CMD_Q_STATUS_INCR * i);
  333. cmd_q->int_ok = 1 << (i * 2);
  334. cmd_q->int_err = 1 << ((i * 2) + 1);
  335. cmd_q->free_slots = ccp_get_free_slots(cmd_q);
  336. init_waitqueue_head(&cmd_q->int_queue);
  337. /* Build queue interrupt mask (two interrupts per queue) */
  338. ccp->qim |= cmd_q->int_ok | cmd_q->int_err;
  339. #ifdef CONFIG_ARM64
  340. /* For arm64 set the recommended queue cache settings */
  341. iowrite32(ccp->axcache, ccp->io_regs + CMD_Q_CACHE_BASE +
  342. (CMD_Q_CACHE_INC * i));
  343. #endif
  344. dev_dbg(dev, "queue #%u available\n", i);
  345. }
  346. if (ccp->cmd_q_count == 0) {
  347. dev_notice(dev, "no command queues available\n");
  348. ret = -EIO;
  349. goto e_pool;
  350. }
  351. dev_notice(dev, "%u command queues available\n", ccp->cmd_q_count);
  352. /* Disable and clear interrupts until ready */
  353. ccp_disable_queue_interrupts(ccp);
  354. for (i = 0; i < ccp->cmd_q_count; i++) {
  355. cmd_q = &ccp->cmd_q[i];
  356. ioread32(cmd_q->reg_int_status);
  357. ioread32(cmd_q->reg_status);
  358. }
  359. iowrite32(ccp->qim, ccp->io_regs + IRQ_STATUS_REG);
  360. /* Request an irq */
  361. ret = sp_request_ccp_irq(ccp->sp, ccp_irq_handler, ccp->name, ccp);
  362. if (ret) {
  363. dev_err(dev, "unable to allocate an IRQ\n");
  364. goto e_pool;
  365. }
  366. /* Initialize the ISR tasklet? */
  367. if (ccp->use_tasklet)
  368. tasklet_init(&ccp->irq_tasklet, ccp_irq_bh,
  369. (unsigned long)ccp);
  370. dev_dbg(dev, "Starting threads...\n");
  371. /* Create a kthread for each queue */
  372. for (i = 0; i < ccp->cmd_q_count; i++) {
  373. struct task_struct *kthread;
  374. cmd_q = &ccp->cmd_q[i];
  375. kthread = kthread_run(ccp_cmd_queue_thread, cmd_q,
  376. "%s-q%u", ccp->name, cmd_q->id);
  377. if (IS_ERR(kthread)) {
  378. dev_err(dev, "error creating queue thread (%ld)\n",
  379. PTR_ERR(kthread));
  380. ret = PTR_ERR(kthread);
  381. goto e_kthread;
  382. }
  383. cmd_q->kthread = kthread;
  384. }
  385. dev_dbg(dev, "Enabling interrupts...\n");
  386. /* Enable interrupts */
  387. ccp_enable_queue_interrupts(ccp);
  388. dev_dbg(dev, "Registering device...\n");
  389. ccp_add_device(ccp);
  390. ret = ccp_register_rng(ccp);
  391. if (ret)
  392. goto e_kthread;
  393. /* Register the DMA engine support */
  394. ret = ccp_dmaengine_register(ccp);
  395. if (ret)
  396. goto e_hwrng;
  397. return 0;
  398. e_hwrng:
  399. ccp_unregister_rng(ccp);
  400. e_kthread:
  401. for (i = 0; i < ccp->cmd_q_count; i++)
  402. if (ccp->cmd_q[i].kthread)
  403. kthread_stop(ccp->cmd_q[i].kthread);
  404. sp_free_ccp_irq(ccp->sp, ccp);
  405. e_pool:
  406. for (i = 0; i < ccp->cmd_q_count; i++)
  407. dma_pool_destroy(ccp->cmd_q[i].dma_pool);
  408. return ret;
  409. }
  410. static void ccp_destroy(struct ccp_device *ccp)
  411. {
  412. struct ccp_cmd_queue *cmd_q;
  413. struct ccp_cmd *cmd;
  414. unsigned int i;
  415. /* Unregister the DMA engine */
  416. ccp_dmaengine_unregister(ccp);
  417. /* Unregister the RNG */
  418. ccp_unregister_rng(ccp);
  419. /* Remove this device from the list of available units */
  420. ccp_del_device(ccp);
  421. /* Disable and clear interrupts */
  422. ccp_disable_queue_interrupts(ccp);
  423. for (i = 0; i < ccp->cmd_q_count; i++) {
  424. cmd_q = &ccp->cmd_q[i];
  425. ioread32(cmd_q->reg_int_status);
  426. ioread32(cmd_q->reg_status);
  427. }
  428. iowrite32(ccp->qim, ccp->io_regs + IRQ_STATUS_REG);
  429. /* Stop the queue kthreads */
  430. for (i = 0; i < ccp->cmd_q_count; i++)
  431. if (ccp->cmd_q[i].kthread)
  432. kthread_stop(ccp->cmd_q[i].kthread);
  433. sp_free_ccp_irq(ccp->sp, ccp);
  434. for (i = 0; i < ccp->cmd_q_count; i++)
  435. dma_pool_destroy(ccp->cmd_q[i].dma_pool);
  436. /* Flush the cmd and backlog queue */
  437. while (!list_empty(&ccp->cmd)) {
  438. /* Invoke the callback directly with an error code */
  439. cmd = list_first_entry(&ccp->cmd, struct ccp_cmd, entry);
  440. list_del(&cmd->entry);
  441. cmd->callback(cmd->data, -ENODEV);
  442. }
  443. while (!list_empty(&ccp->backlog)) {
  444. /* Invoke the callback directly with an error code */
  445. cmd = list_first_entry(&ccp->backlog, struct ccp_cmd, entry);
  446. list_del(&cmd->entry);
  447. cmd->callback(cmd->data, -ENODEV);
  448. }
  449. }
  450. static const struct ccp_actions ccp3_actions = {
  451. .aes = ccp_perform_aes,
  452. .xts_aes = ccp_perform_xts_aes,
  453. .des3 = NULL,
  454. .sha = ccp_perform_sha,
  455. .rsa = ccp_perform_rsa,
  456. .passthru = ccp_perform_passthru,
  457. .ecc = ccp_perform_ecc,
  458. .sballoc = ccp_alloc_ksb,
  459. .sbfree = ccp_free_ksb,
  460. .init = ccp_init,
  461. .destroy = ccp_destroy,
  462. .get_free_slots = ccp_get_free_slots,
  463. .irqhandler = ccp_irq_handler,
  464. };
  465. const struct ccp_vdata ccpv3_platform = {
  466. .version = CCP_VERSION(3, 0),
  467. .setup = NULL,
  468. .perform = &ccp3_actions,
  469. .offset = 0,
  470. .rsamax = CCP_RSA_MAX_WIDTH,
  471. };
  472. const struct ccp_vdata ccpv3 = {
  473. .version = CCP_VERSION(3, 0),
  474. .setup = NULL,
  475. .perform = &ccp3_actions,
  476. .offset = 0x20000,
  477. .rsamax = CCP_RSA_MAX_WIDTH,
  478. };