ccp-dev.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * AMD Cryptographic Coprocessor (CCP) driver
  4. *
  5. * Copyright (C) 2013,2019 Advanced Micro Devices, Inc.
  6. *
  7. * Author: Tom Lendacky <thomas.lendacky@amd.com>
  8. * Author: Gary R Hook <gary.hook@amd.com>
  9. */
  10. #include <linux/module.h>
  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>
  17. #include <linux/types.h>
  18. #include <linux/mutex.h>
  19. #include <linux/delay.h>
  20. #include <linux/hw_random.h>
  21. #include <linux/cpu.h>
  22. #include <linux/atomic.h>
  23. #ifdef CONFIG_X86
  24. #include <asm/cpu_device_id.h>
  25. #endif
  26. #include <linux/ccp.h>
  27. #include "ccp-dev.h"
  28. #define MAX_CCPS 32
  29. /* Limit CCP use to a specifed number of queues per device */
  30. static unsigned int nqueues = 0;
  31. module_param(nqueues, uint, 0444);
  32. MODULE_PARM_DESC(nqueues, "Number of queues per CCP (minimum 1; default: all available)");
  33. /* Limit the maximum number of configured CCPs */
  34. static atomic_t dev_count = ATOMIC_INIT(0);
  35. static unsigned int max_devs = MAX_CCPS;
  36. module_param(max_devs, uint, 0444);
  37. MODULE_PARM_DESC(max_devs, "Maximum number of CCPs to enable (default: all; 0 disables all CCPs)");
  38. struct ccp_tasklet_data {
  39. struct completion completion;
  40. struct ccp_cmd *cmd;
  41. };
  42. /* Human-readable error strings */
  43. #define CCP_MAX_ERROR_CODE 64
  44. static char *ccp_error_codes[] = {
  45. "",
  46. "ILLEGAL_ENGINE",
  47. "ILLEGAL_KEY_ID",
  48. "ILLEGAL_FUNCTION_TYPE",
  49. "ILLEGAL_FUNCTION_MODE",
  50. "ILLEGAL_FUNCTION_ENCRYPT",
  51. "ILLEGAL_FUNCTION_SIZE",
  52. "Zlib_MISSING_INIT_EOM",
  53. "ILLEGAL_FUNCTION_RSVD",
  54. "ILLEGAL_BUFFER_LENGTH",
  55. "VLSB_FAULT",
  56. "ILLEGAL_MEM_ADDR",
  57. "ILLEGAL_MEM_SEL",
  58. "ILLEGAL_CONTEXT_ID",
  59. "ILLEGAL_KEY_ADDR",
  60. "0xF Reserved",
  61. "Zlib_ILLEGAL_MULTI_QUEUE",
  62. "Zlib_ILLEGAL_JOBID_CHANGE",
  63. "CMD_TIMEOUT",
  64. "IDMA0_AXI_SLVERR",
  65. "IDMA0_AXI_DECERR",
  66. "0x15 Reserved",
  67. "IDMA1_AXI_SLAVE_FAULT",
  68. "IDMA1_AIXI_DECERR",
  69. "0x18 Reserved",
  70. "ZLIBVHB_AXI_SLVERR",
  71. "ZLIBVHB_AXI_DECERR",
  72. "0x1B Reserved",
  73. "ZLIB_UNEXPECTED_EOM",
  74. "ZLIB_EXTRA_DATA",
  75. "ZLIB_BTYPE",
  76. "ZLIB_UNDEFINED_SYMBOL",
  77. "ZLIB_UNDEFINED_DISTANCE_S",
  78. "ZLIB_CODE_LENGTH_SYMBOL",
  79. "ZLIB _VHB_ILLEGAL_FETCH",
  80. "ZLIB_UNCOMPRESSED_LEN",
  81. "ZLIB_LIMIT_REACHED",
  82. "ZLIB_CHECKSUM_MISMATCH0",
  83. "ODMA0_AXI_SLVERR",
  84. "ODMA0_AXI_DECERR",
  85. "0x28 Reserved",
  86. "ODMA1_AXI_SLVERR",
  87. "ODMA1_AXI_DECERR",
  88. };
  89. void ccp_log_error(struct ccp_device *d, unsigned int e)
  90. {
  91. if (WARN_ON(e >= CCP_MAX_ERROR_CODE))
  92. return;
  93. if (e < ARRAY_SIZE(ccp_error_codes))
  94. dev_err(d->dev, "CCP error %d: %s\n", e, ccp_error_codes[e]);
  95. else
  96. dev_err(d->dev, "CCP error %d: Unknown Error\n", e);
  97. }
  98. /* List of CCPs, CCP count, read-write access lock, and access functions
  99. *
  100. * Lock structure: get ccp_unit_lock for reading whenever we need to
  101. * examine the CCP list. While holding it for reading we can acquire
  102. * the RR lock to update the round-robin next-CCP pointer. The unit lock
  103. * must be acquired before the RR lock.
  104. *
  105. * If the unit-lock is acquired for writing, we have total control over
  106. * the list, so there's no value in getting the RR lock.
  107. */
  108. static DEFINE_RWLOCK(ccp_unit_lock);
  109. static LIST_HEAD(ccp_units);
  110. /* Round-robin counter */
  111. static DEFINE_SPINLOCK(ccp_rr_lock);
  112. static struct ccp_device *ccp_rr;
  113. /**
  114. * ccp_add_device - add a CCP device to the list
  115. *
  116. * @ccp: ccp_device struct pointer
  117. *
  118. * Put this CCP on the unit list, which makes it available
  119. * for use.
  120. *
  121. * Returns zero if a CCP device is present, -ENODEV otherwise.
  122. */
  123. void ccp_add_device(struct ccp_device *ccp)
  124. {
  125. unsigned long flags;
  126. write_lock_irqsave(&ccp_unit_lock, flags);
  127. list_add_tail(&ccp->entry, &ccp_units);
  128. if (!ccp_rr)
  129. /* We already have the list lock (we're first) so this
  130. * pointer can't change on us. Set its initial value.
  131. */
  132. ccp_rr = ccp;
  133. write_unlock_irqrestore(&ccp_unit_lock, flags);
  134. }
  135. /**
  136. * ccp_del_device - remove a CCP device from the list
  137. *
  138. * @ccp: ccp_device struct pointer
  139. *
  140. * Remove this unit from the list of devices. If the next device
  141. * up for use is this one, adjust the pointer. If this is the last
  142. * device, NULL the pointer.
  143. */
  144. void ccp_del_device(struct ccp_device *ccp)
  145. {
  146. unsigned long flags;
  147. write_lock_irqsave(&ccp_unit_lock, flags);
  148. if (ccp_rr == ccp) {
  149. /* ccp_unit_lock is read/write; any read access
  150. * will be suspended while we make changes to the
  151. * list and RR pointer.
  152. */
  153. if (list_is_last(&ccp_rr->entry, &ccp_units))
  154. ccp_rr = list_first_entry(&ccp_units, struct ccp_device,
  155. entry);
  156. else
  157. ccp_rr = list_next_entry(ccp_rr, entry);
  158. }
  159. list_del(&ccp->entry);
  160. if (list_empty(&ccp_units))
  161. ccp_rr = NULL;
  162. write_unlock_irqrestore(&ccp_unit_lock, flags);
  163. }
  164. int ccp_register_rng(struct ccp_device *ccp)
  165. {
  166. int ret = 0;
  167. dev_dbg(ccp->dev, "Registering RNG...\n");
  168. /* Register an RNG */
  169. ccp->hwrng.name = ccp->rngname;
  170. ccp->hwrng.read = ccp_trng_read;
  171. ret = hwrng_register(&ccp->hwrng);
  172. if (ret)
  173. dev_err(ccp->dev, "error registering hwrng (%d)\n", ret);
  174. return ret;
  175. }
  176. void ccp_unregister_rng(struct ccp_device *ccp)
  177. {
  178. if (ccp->hwrng.name)
  179. hwrng_unregister(&ccp->hwrng);
  180. }
  181. static struct ccp_device *ccp_get_device(void)
  182. {
  183. unsigned long flags;
  184. struct ccp_device *dp = NULL;
  185. /* We round-robin through the unit list.
  186. * The (ccp_rr) pointer refers to the next unit to use.
  187. */
  188. read_lock_irqsave(&ccp_unit_lock, flags);
  189. if (!list_empty(&ccp_units)) {
  190. spin_lock(&ccp_rr_lock);
  191. dp = ccp_rr;
  192. if (list_is_last(&ccp_rr->entry, &ccp_units))
  193. ccp_rr = list_first_entry(&ccp_units, struct ccp_device,
  194. entry);
  195. else
  196. ccp_rr = list_next_entry(ccp_rr, entry);
  197. spin_unlock(&ccp_rr_lock);
  198. }
  199. read_unlock_irqrestore(&ccp_unit_lock, flags);
  200. return dp;
  201. }
  202. /**
  203. * ccp_present - check if a CCP device is present
  204. *
  205. * Returns zero if a CCP device is present, -ENODEV otherwise.
  206. */
  207. int ccp_present(void)
  208. {
  209. unsigned long flags;
  210. int ret;
  211. read_lock_irqsave(&ccp_unit_lock, flags);
  212. ret = list_empty(&ccp_units);
  213. read_unlock_irqrestore(&ccp_unit_lock, flags);
  214. return ret ? -ENODEV : 0;
  215. }
  216. EXPORT_SYMBOL_GPL(ccp_present);
  217. /**
  218. * ccp_version - get the version of the CCP device
  219. *
  220. * Returns the version from the first unit on the list;
  221. * otherwise a zero if no CCP device is present
  222. */
  223. unsigned int ccp_version(void)
  224. {
  225. struct ccp_device *dp;
  226. unsigned long flags;
  227. int ret = 0;
  228. read_lock_irqsave(&ccp_unit_lock, flags);
  229. if (!list_empty(&ccp_units)) {
  230. dp = list_first_entry(&ccp_units, struct ccp_device, entry);
  231. ret = dp->vdata->version;
  232. }
  233. read_unlock_irqrestore(&ccp_unit_lock, flags);
  234. return ret;
  235. }
  236. EXPORT_SYMBOL_GPL(ccp_version);
  237. /**
  238. * ccp_enqueue_cmd - queue an operation for processing by the CCP
  239. *
  240. * @cmd: ccp_cmd struct to be processed
  241. *
  242. * Queue a cmd to be processed by the CCP. If queueing the cmd
  243. * would exceed the defined length of the cmd queue the cmd will
  244. * only be queued if the CCP_CMD_MAY_BACKLOG flag is set and will
  245. * result in a return code of -EBUSY.
  246. *
  247. * The callback routine specified in the ccp_cmd struct will be
  248. * called to notify the caller of completion (if the cmd was not
  249. * backlogged) or advancement out of the backlog. If the cmd has
  250. * advanced out of the backlog the "err" value of the callback
  251. * will be -EINPROGRESS. Any other "err" value during callback is
  252. * the result of the operation.
  253. *
  254. * The cmd has been successfully queued if:
  255. * the return code is -EINPROGRESS or
  256. * the return code is -EBUSY and CCP_CMD_MAY_BACKLOG flag is set
  257. */
  258. int ccp_enqueue_cmd(struct ccp_cmd *cmd)
  259. {
  260. struct ccp_device *ccp;
  261. unsigned long flags;
  262. unsigned int i;
  263. int ret;
  264. /* Some commands might need to be sent to a specific device */
  265. ccp = cmd->ccp ? cmd->ccp : ccp_get_device();
  266. if (!ccp)
  267. return -ENODEV;
  268. /* Caller must supply a callback routine */
  269. if (!cmd->callback)
  270. return -EINVAL;
  271. cmd->ccp = ccp;
  272. spin_lock_irqsave(&ccp->cmd_lock, flags);
  273. i = ccp->cmd_q_count;
  274. if (ccp->cmd_count >= MAX_CMD_QLEN) {
  275. if (cmd->flags & CCP_CMD_MAY_BACKLOG) {
  276. ret = -EBUSY;
  277. list_add_tail(&cmd->entry, &ccp->backlog);
  278. } else {
  279. ret = -ENOSPC;
  280. }
  281. } else {
  282. ret = -EINPROGRESS;
  283. ccp->cmd_count++;
  284. list_add_tail(&cmd->entry, &ccp->cmd);
  285. /* Find an idle queue */
  286. if (!ccp->suspending) {
  287. for (i = 0; i < ccp->cmd_q_count; i++) {
  288. if (ccp->cmd_q[i].active)
  289. continue;
  290. break;
  291. }
  292. }
  293. }
  294. spin_unlock_irqrestore(&ccp->cmd_lock, flags);
  295. /* If we found an idle queue, wake it up */
  296. if (i < ccp->cmd_q_count)
  297. wake_up_process(ccp->cmd_q[i].kthread);
  298. return ret;
  299. }
  300. EXPORT_SYMBOL_GPL(ccp_enqueue_cmd);
  301. static void ccp_do_cmd_backlog(struct work_struct *work)
  302. {
  303. struct ccp_cmd *cmd = container_of(work, struct ccp_cmd, work);
  304. struct ccp_device *ccp = cmd->ccp;
  305. unsigned long flags;
  306. unsigned int i;
  307. cmd->callback(cmd->data, -EINPROGRESS);
  308. spin_lock_irqsave(&ccp->cmd_lock, flags);
  309. ccp->cmd_count++;
  310. list_add_tail(&cmd->entry, &ccp->cmd);
  311. /* Find an idle queue */
  312. for (i = 0; i < ccp->cmd_q_count; i++) {
  313. if (ccp->cmd_q[i].active)
  314. continue;
  315. break;
  316. }
  317. spin_unlock_irqrestore(&ccp->cmd_lock, flags);
  318. /* If we found an idle queue, wake it up */
  319. if (i < ccp->cmd_q_count)
  320. wake_up_process(ccp->cmd_q[i].kthread);
  321. }
  322. static struct ccp_cmd *ccp_dequeue_cmd(struct ccp_cmd_queue *cmd_q)
  323. {
  324. struct ccp_device *ccp = cmd_q->ccp;
  325. struct ccp_cmd *cmd = NULL;
  326. struct ccp_cmd *backlog = NULL;
  327. unsigned long flags;
  328. spin_lock_irqsave(&ccp->cmd_lock, flags);
  329. cmd_q->active = 0;
  330. if (ccp->suspending) {
  331. cmd_q->suspended = 1;
  332. spin_unlock_irqrestore(&ccp->cmd_lock, flags);
  333. wake_up_interruptible(&ccp->suspend_queue);
  334. return NULL;
  335. }
  336. if (ccp->cmd_count) {
  337. cmd_q->active = 1;
  338. cmd = list_first_entry(&ccp->cmd, struct ccp_cmd, entry);
  339. list_del(&cmd->entry);
  340. ccp->cmd_count--;
  341. }
  342. if (!list_empty(&ccp->backlog)) {
  343. backlog = list_first_entry(&ccp->backlog, struct ccp_cmd,
  344. entry);
  345. list_del(&backlog->entry);
  346. }
  347. spin_unlock_irqrestore(&ccp->cmd_lock, flags);
  348. if (backlog) {
  349. INIT_WORK(&backlog->work, ccp_do_cmd_backlog);
  350. schedule_work(&backlog->work);
  351. }
  352. return cmd;
  353. }
  354. static void ccp_do_cmd_complete(unsigned long data)
  355. {
  356. struct ccp_tasklet_data *tdata = (struct ccp_tasklet_data *)data;
  357. struct ccp_cmd *cmd = tdata->cmd;
  358. cmd->callback(cmd->data, cmd->ret);
  359. complete(&tdata->completion);
  360. }
  361. /**
  362. * ccp_cmd_queue_thread - create a kernel thread to manage a CCP queue
  363. *
  364. * @data: thread-specific data
  365. */
  366. int ccp_cmd_queue_thread(void *data)
  367. {
  368. struct ccp_cmd_queue *cmd_q = (struct ccp_cmd_queue *)data;
  369. struct ccp_cmd *cmd;
  370. struct ccp_tasklet_data tdata;
  371. struct tasklet_struct tasklet;
  372. tasklet_init(&tasklet, ccp_do_cmd_complete, (unsigned long)&tdata);
  373. set_current_state(TASK_INTERRUPTIBLE);
  374. while (!kthread_should_stop()) {
  375. schedule();
  376. set_current_state(TASK_INTERRUPTIBLE);
  377. cmd = ccp_dequeue_cmd(cmd_q);
  378. if (!cmd)
  379. continue;
  380. __set_current_state(TASK_RUNNING);
  381. /* Execute the command */
  382. cmd->ret = ccp_run_cmd(cmd_q, cmd);
  383. /* Schedule the completion callback */
  384. tdata.cmd = cmd;
  385. init_completion(&tdata.completion);
  386. tasklet_schedule(&tasklet);
  387. wait_for_completion(&tdata.completion);
  388. }
  389. __set_current_state(TASK_RUNNING);
  390. return 0;
  391. }
  392. /**
  393. * ccp_alloc_struct - allocate and initialize the ccp_device struct
  394. *
  395. * @dev: device struct of the CCP
  396. */
  397. struct ccp_device *ccp_alloc_struct(struct sp_device *sp)
  398. {
  399. struct device *dev = sp->dev;
  400. struct ccp_device *ccp;
  401. ccp = devm_kzalloc(dev, sizeof(*ccp), GFP_KERNEL);
  402. if (!ccp)
  403. return NULL;
  404. ccp->dev = dev;
  405. ccp->sp = sp;
  406. ccp->axcache = sp->axcache;
  407. INIT_LIST_HEAD(&ccp->cmd);
  408. INIT_LIST_HEAD(&ccp->backlog);
  409. spin_lock_init(&ccp->cmd_lock);
  410. mutex_init(&ccp->req_mutex);
  411. mutex_init(&ccp->sb_mutex);
  412. ccp->sb_count = KSB_COUNT;
  413. ccp->sb_start = 0;
  414. /* Initialize the wait queues */
  415. init_waitqueue_head(&ccp->sb_queue);
  416. init_waitqueue_head(&ccp->suspend_queue);
  417. snprintf(ccp->name, MAX_CCP_NAME_LEN, "ccp-%u", sp->ord);
  418. snprintf(ccp->rngname, MAX_CCP_NAME_LEN, "ccp-%u-rng", sp->ord);
  419. return ccp;
  420. }
  421. int ccp_trng_read(struct hwrng *rng, void *data, size_t max, bool wait)
  422. {
  423. struct ccp_device *ccp = container_of(rng, struct ccp_device, hwrng);
  424. u32 trng_value;
  425. int len = min_t(int, sizeof(trng_value), max);
  426. /* Locking is provided by the caller so we can update device
  427. * hwrng-related fields safely
  428. */
  429. trng_value = ioread32(ccp->io_regs + TRNG_OUT_REG);
  430. if (!trng_value) {
  431. /* Zero is returned if not data is available or if a
  432. * bad-entropy error is present. Assume an error if
  433. * we exceed TRNG_RETRIES reads of zero.
  434. */
  435. if (ccp->hwrng_retries++ > TRNG_RETRIES)
  436. return -EIO;
  437. return 0;
  438. }
  439. /* Reset the counter and save the rng value */
  440. ccp->hwrng_retries = 0;
  441. memcpy(data, &trng_value, len);
  442. return len;
  443. }
  444. #ifdef CONFIG_PM
  445. bool ccp_queues_suspended(struct ccp_device *ccp)
  446. {
  447. unsigned int suspended = 0;
  448. unsigned long flags;
  449. unsigned int i;
  450. spin_lock_irqsave(&ccp->cmd_lock, flags);
  451. for (i = 0; i < ccp->cmd_q_count; i++)
  452. if (ccp->cmd_q[i].suspended)
  453. suspended++;
  454. spin_unlock_irqrestore(&ccp->cmd_lock, flags);
  455. return ccp->cmd_q_count == suspended;
  456. }
  457. int ccp_dev_suspend(struct sp_device *sp, pm_message_t state)
  458. {
  459. struct ccp_device *ccp = sp->ccp_data;
  460. unsigned long flags;
  461. unsigned int i;
  462. /* If there's no device there's nothing to do */
  463. if (!ccp)
  464. return 0;
  465. spin_lock_irqsave(&ccp->cmd_lock, flags);
  466. ccp->suspending = 1;
  467. /* Wake all the queue kthreads to prepare for suspend */
  468. for (i = 0; i < ccp->cmd_q_count; i++)
  469. wake_up_process(ccp->cmd_q[i].kthread);
  470. spin_unlock_irqrestore(&ccp->cmd_lock, flags);
  471. /* Wait for all queue kthreads to say they're done */
  472. while (!ccp_queues_suspended(ccp))
  473. wait_event_interruptible(ccp->suspend_queue,
  474. ccp_queues_suspended(ccp));
  475. return 0;
  476. }
  477. int ccp_dev_resume(struct sp_device *sp)
  478. {
  479. struct ccp_device *ccp = sp->ccp_data;
  480. unsigned long flags;
  481. unsigned int i;
  482. /* If there's no device there's nothing to do */
  483. if (!ccp)
  484. return 0;
  485. spin_lock_irqsave(&ccp->cmd_lock, flags);
  486. ccp->suspending = 0;
  487. /* Wake up all the kthreads */
  488. for (i = 0; i < ccp->cmd_q_count; i++) {
  489. ccp->cmd_q[i].suspended = 0;
  490. wake_up_process(ccp->cmd_q[i].kthread);
  491. }
  492. spin_unlock_irqrestore(&ccp->cmd_lock, flags);
  493. return 0;
  494. }
  495. #endif
  496. int ccp_dev_init(struct sp_device *sp)
  497. {
  498. struct device *dev = sp->dev;
  499. struct ccp_device *ccp;
  500. int ret;
  501. /*
  502. * Check how many we have so far, and stop after reaching
  503. * that number
  504. */
  505. if (atomic_inc_return(&dev_count) > max_devs)
  506. return 0; /* don't fail the load */
  507. ret = -ENOMEM;
  508. ccp = ccp_alloc_struct(sp);
  509. if (!ccp)
  510. goto e_err;
  511. sp->ccp_data = ccp;
  512. if (!nqueues || (nqueues > MAX_HW_QUEUES))
  513. ccp->max_q_count = MAX_HW_QUEUES;
  514. else
  515. ccp->max_q_count = nqueues;
  516. ccp->vdata = (struct ccp_vdata *)sp->dev_vdata->ccp_vdata;
  517. if (!ccp->vdata || !ccp->vdata->version) {
  518. ret = -ENODEV;
  519. dev_err(dev, "missing driver data\n");
  520. goto e_err;
  521. }
  522. ccp->use_tasklet = sp->use_tasklet;
  523. ccp->io_regs = sp->io_map + ccp->vdata->offset;
  524. if (ccp->vdata->setup)
  525. ccp->vdata->setup(ccp);
  526. ret = ccp->vdata->perform->init(ccp);
  527. if (ret)
  528. goto e_err;
  529. dev_notice(dev, "ccp enabled\n");
  530. return 0;
  531. e_err:
  532. sp->ccp_data = NULL;
  533. dev_notice(dev, "ccp initialization failed\n");
  534. return ret;
  535. }
  536. void ccp_dev_destroy(struct sp_device *sp)
  537. {
  538. struct ccp_device *ccp = sp->ccp_data;
  539. if (!ccp)
  540. return;
  541. ccp->vdata->perform->destroy(ccp);
  542. }