fsl-mc-allocator.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * fsl-mc object allocator driver
  4. *
  5. * Copyright (C) 2013-2016 Freescale Semiconductor, Inc.
  6. *
  7. */
  8. #include <linux/module.h>
  9. #include <linux/msi.h>
  10. #include <linux/fsl/mc.h>
  11. #include "fsl-mc-private.h"
  12. static bool __must_check fsl_mc_is_allocatable(struct fsl_mc_device *mc_dev)
  13. {
  14. return is_fsl_mc_bus_dpbp(mc_dev) ||
  15. is_fsl_mc_bus_dpmcp(mc_dev) ||
  16. is_fsl_mc_bus_dpcon(mc_dev);
  17. }
  18. /**
  19. * fsl_mc_resource_pool_add_device - add allocatable object to a resource
  20. * pool of a given fsl-mc bus
  21. *
  22. * @mc_bus: pointer to the fsl-mc bus
  23. * @pool_type: pool type
  24. * @mc_dev: pointer to allocatable fsl-mc device
  25. */
  26. static int __must_check fsl_mc_resource_pool_add_device(struct fsl_mc_bus
  27. *mc_bus,
  28. enum fsl_mc_pool_type
  29. pool_type,
  30. struct fsl_mc_device
  31. *mc_dev)
  32. {
  33. struct fsl_mc_resource_pool *res_pool;
  34. struct fsl_mc_resource *resource;
  35. struct fsl_mc_device *mc_bus_dev = &mc_bus->mc_dev;
  36. int error = -EINVAL;
  37. if (pool_type < 0 || pool_type >= FSL_MC_NUM_POOL_TYPES)
  38. goto out;
  39. if (!fsl_mc_is_allocatable(mc_dev))
  40. goto out;
  41. if (mc_dev->resource)
  42. goto out;
  43. res_pool = &mc_bus->resource_pools[pool_type];
  44. if (res_pool->type != pool_type)
  45. goto out;
  46. if (res_pool->mc_bus != mc_bus)
  47. goto out;
  48. mutex_lock(&res_pool->mutex);
  49. if (res_pool->max_count < 0)
  50. goto out_unlock;
  51. if (res_pool->free_count < 0 ||
  52. res_pool->free_count > res_pool->max_count)
  53. goto out_unlock;
  54. resource = devm_kzalloc(&mc_bus_dev->dev, sizeof(*resource),
  55. GFP_KERNEL);
  56. if (!resource) {
  57. error = -ENOMEM;
  58. dev_err(&mc_bus_dev->dev,
  59. "Failed to allocate memory for fsl_mc_resource\n");
  60. goto out_unlock;
  61. }
  62. resource->type = pool_type;
  63. resource->id = mc_dev->obj_desc.id;
  64. resource->data = mc_dev;
  65. resource->parent_pool = res_pool;
  66. INIT_LIST_HEAD(&resource->node);
  67. list_add_tail(&resource->node, &res_pool->free_list);
  68. mc_dev->resource = resource;
  69. res_pool->free_count++;
  70. res_pool->max_count++;
  71. error = 0;
  72. out_unlock:
  73. mutex_unlock(&res_pool->mutex);
  74. out:
  75. return error;
  76. }
  77. /**
  78. * fsl_mc_resource_pool_remove_device - remove an allocatable device from a
  79. * resource pool
  80. *
  81. * @mc_dev: pointer to allocatable fsl-mc device
  82. *
  83. * It permanently removes an allocatable fsl-mc device from the resource
  84. * pool. It's an error if the device is in use.
  85. */
  86. static int __must_check fsl_mc_resource_pool_remove_device(struct fsl_mc_device
  87. *mc_dev)
  88. {
  89. struct fsl_mc_device *mc_bus_dev;
  90. struct fsl_mc_bus *mc_bus;
  91. struct fsl_mc_resource_pool *res_pool;
  92. struct fsl_mc_resource *resource;
  93. int error = -EINVAL;
  94. if (!fsl_mc_is_allocatable(mc_dev))
  95. goto out;
  96. resource = mc_dev->resource;
  97. if (!resource || resource->data != mc_dev)
  98. goto out;
  99. mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
  100. mc_bus = to_fsl_mc_bus(mc_bus_dev);
  101. res_pool = resource->parent_pool;
  102. if (res_pool != &mc_bus->resource_pools[resource->type])
  103. goto out;
  104. mutex_lock(&res_pool->mutex);
  105. if (res_pool->max_count <= 0)
  106. goto out_unlock;
  107. if (res_pool->free_count <= 0 ||
  108. res_pool->free_count > res_pool->max_count)
  109. goto out_unlock;
  110. /*
  111. * If the device is currently allocated, its resource is not
  112. * in the free list and thus, the device cannot be removed.
  113. */
  114. if (list_empty(&resource->node)) {
  115. error = -EBUSY;
  116. dev_err(&mc_bus_dev->dev,
  117. "Device %s cannot be removed from resource pool\n",
  118. dev_name(&mc_dev->dev));
  119. goto out_unlock;
  120. }
  121. list_del_init(&resource->node);
  122. res_pool->free_count--;
  123. res_pool->max_count--;
  124. devm_kfree(&mc_bus_dev->dev, resource);
  125. mc_dev->resource = NULL;
  126. error = 0;
  127. out_unlock:
  128. mutex_unlock(&res_pool->mutex);
  129. out:
  130. return error;
  131. }
  132. static const char *const fsl_mc_pool_type_strings[] = {
  133. [FSL_MC_POOL_DPMCP] = "dpmcp",
  134. [FSL_MC_POOL_DPBP] = "dpbp",
  135. [FSL_MC_POOL_DPCON] = "dpcon",
  136. [FSL_MC_POOL_IRQ] = "irq",
  137. };
  138. static int __must_check object_type_to_pool_type(const char *object_type,
  139. enum fsl_mc_pool_type
  140. *pool_type)
  141. {
  142. unsigned int i;
  143. for (i = 0; i < ARRAY_SIZE(fsl_mc_pool_type_strings); i++) {
  144. if (strcmp(object_type, fsl_mc_pool_type_strings[i]) == 0) {
  145. *pool_type = i;
  146. return 0;
  147. }
  148. }
  149. return -EINVAL;
  150. }
  151. int __must_check fsl_mc_resource_allocate(struct fsl_mc_bus *mc_bus,
  152. enum fsl_mc_pool_type pool_type,
  153. struct fsl_mc_resource **new_resource)
  154. {
  155. struct fsl_mc_resource_pool *res_pool;
  156. struct fsl_mc_resource *resource;
  157. struct fsl_mc_device *mc_bus_dev = &mc_bus->mc_dev;
  158. int error = -EINVAL;
  159. BUILD_BUG_ON(ARRAY_SIZE(fsl_mc_pool_type_strings) !=
  160. FSL_MC_NUM_POOL_TYPES);
  161. *new_resource = NULL;
  162. if (pool_type < 0 || pool_type >= FSL_MC_NUM_POOL_TYPES)
  163. goto out;
  164. res_pool = &mc_bus->resource_pools[pool_type];
  165. if (res_pool->mc_bus != mc_bus)
  166. goto out;
  167. mutex_lock(&res_pool->mutex);
  168. resource = list_first_entry_or_null(&res_pool->free_list,
  169. struct fsl_mc_resource, node);
  170. if (!resource) {
  171. error = -ENXIO;
  172. dev_err(&mc_bus_dev->dev,
  173. "No more resources of type %s left\n",
  174. fsl_mc_pool_type_strings[pool_type]);
  175. goto out_unlock;
  176. }
  177. if (resource->type != pool_type)
  178. goto out_unlock;
  179. if (resource->parent_pool != res_pool)
  180. goto out_unlock;
  181. if (res_pool->free_count <= 0 ||
  182. res_pool->free_count > res_pool->max_count)
  183. goto out_unlock;
  184. list_del_init(&resource->node);
  185. res_pool->free_count--;
  186. error = 0;
  187. out_unlock:
  188. mutex_unlock(&res_pool->mutex);
  189. *new_resource = resource;
  190. out:
  191. return error;
  192. }
  193. EXPORT_SYMBOL_GPL(fsl_mc_resource_allocate);
  194. void fsl_mc_resource_free(struct fsl_mc_resource *resource)
  195. {
  196. struct fsl_mc_resource_pool *res_pool;
  197. res_pool = resource->parent_pool;
  198. if (resource->type != res_pool->type)
  199. return;
  200. mutex_lock(&res_pool->mutex);
  201. if (res_pool->free_count < 0 ||
  202. res_pool->free_count >= res_pool->max_count)
  203. goto out_unlock;
  204. if (!list_empty(&resource->node))
  205. goto out_unlock;
  206. list_add_tail(&resource->node, &res_pool->free_list);
  207. res_pool->free_count++;
  208. out_unlock:
  209. mutex_unlock(&res_pool->mutex);
  210. }
  211. EXPORT_SYMBOL_GPL(fsl_mc_resource_free);
  212. /**
  213. * fsl_mc_object_allocate - Allocates an fsl-mc object of the given
  214. * pool type from a given fsl-mc bus instance
  215. *
  216. * @mc_dev: fsl-mc device which is used in conjunction with the
  217. * allocated object
  218. * @pool_type: pool type
  219. * @new_mc_dev: pointer to area where the pointer to the allocated device
  220. * is to be returned
  221. *
  222. * Allocatable objects are always used in conjunction with some functional
  223. * device. This function allocates an object of the specified type from
  224. * the DPRC containing the functional device.
  225. *
  226. * NOTE: pool_type must be different from FSL_MC_POOL_MCP, since MC
  227. * portals are allocated using fsl_mc_portal_allocate(), instead of
  228. * this function.
  229. */
  230. int __must_check fsl_mc_object_allocate(struct fsl_mc_device *mc_dev,
  231. enum fsl_mc_pool_type pool_type,
  232. struct fsl_mc_device **new_mc_adev)
  233. {
  234. struct fsl_mc_device *mc_bus_dev;
  235. struct fsl_mc_bus *mc_bus;
  236. struct fsl_mc_device *mc_adev;
  237. int error = -EINVAL;
  238. struct fsl_mc_resource *resource = NULL;
  239. *new_mc_adev = NULL;
  240. if (mc_dev->flags & FSL_MC_IS_DPRC)
  241. goto error;
  242. if (!dev_is_fsl_mc(mc_dev->dev.parent))
  243. goto error;
  244. if (pool_type == FSL_MC_POOL_DPMCP)
  245. goto error;
  246. mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
  247. mc_bus = to_fsl_mc_bus(mc_bus_dev);
  248. error = fsl_mc_resource_allocate(mc_bus, pool_type, &resource);
  249. if (error < 0)
  250. goto error;
  251. mc_adev = resource->data;
  252. if (!mc_adev) {
  253. error = -EINVAL;
  254. goto error;
  255. }
  256. mc_adev->consumer_link = device_link_add(&mc_dev->dev,
  257. &mc_adev->dev,
  258. DL_FLAG_AUTOREMOVE_CONSUMER);
  259. if (!mc_adev->consumer_link) {
  260. error = -EINVAL;
  261. goto error;
  262. }
  263. *new_mc_adev = mc_adev;
  264. return 0;
  265. error:
  266. if (resource)
  267. fsl_mc_resource_free(resource);
  268. return error;
  269. }
  270. EXPORT_SYMBOL_GPL(fsl_mc_object_allocate);
  271. /**
  272. * fsl_mc_object_free - Returns an fsl-mc object to the resource
  273. * pool where it came from.
  274. * @mc_adev: Pointer to the fsl-mc device
  275. */
  276. void fsl_mc_object_free(struct fsl_mc_device *mc_adev)
  277. {
  278. struct fsl_mc_resource *resource;
  279. resource = mc_adev->resource;
  280. if (resource->type == FSL_MC_POOL_DPMCP)
  281. return;
  282. if (resource->data != mc_adev)
  283. return;
  284. fsl_mc_resource_free(resource);
  285. mc_adev->consumer_link = NULL;
  286. }
  287. EXPORT_SYMBOL_GPL(fsl_mc_object_free);
  288. /*
  289. * A DPRC and the devices in the DPRC all share the same GIC-ITS device
  290. * ID. A block of IRQs is pre-allocated and maintained in a pool
  291. * from which devices can allocate them when needed.
  292. */
  293. /*
  294. * Initialize the interrupt pool associated with an fsl-mc bus.
  295. * It allocates a block of IRQs from the GIC-ITS.
  296. */
  297. int fsl_mc_populate_irq_pool(struct fsl_mc_device *mc_bus_dev,
  298. unsigned int irq_count)
  299. {
  300. unsigned int i;
  301. struct msi_desc *msi_desc;
  302. struct fsl_mc_device_irq *irq_resources;
  303. struct fsl_mc_device_irq *mc_dev_irq;
  304. int error;
  305. struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);
  306. struct fsl_mc_resource_pool *res_pool =
  307. &mc_bus->resource_pools[FSL_MC_POOL_IRQ];
  308. /* do nothing if the IRQ pool is already populated */
  309. if (mc_bus->irq_resources)
  310. return 0;
  311. if (irq_count == 0 ||
  312. irq_count > FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS)
  313. return -EINVAL;
  314. error = fsl_mc_msi_domain_alloc_irqs(&mc_bus_dev->dev, irq_count);
  315. if (error < 0)
  316. return error;
  317. irq_resources = devm_kcalloc(&mc_bus_dev->dev,
  318. irq_count, sizeof(*irq_resources),
  319. GFP_KERNEL);
  320. if (!irq_resources) {
  321. error = -ENOMEM;
  322. goto cleanup_msi_irqs;
  323. }
  324. for (i = 0; i < irq_count; i++) {
  325. mc_dev_irq = &irq_resources[i];
  326. /*
  327. * NOTE: This mc_dev_irq's MSI addr/value pair will be set
  328. * by the fsl_mc_msi_write_msg() callback
  329. */
  330. mc_dev_irq->resource.type = res_pool->type;
  331. mc_dev_irq->resource.data = mc_dev_irq;
  332. mc_dev_irq->resource.parent_pool = res_pool;
  333. INIT_LIST_HEAD(&mc_dev_irq->resource.node);
  334. list_add_tail(&mc_dev_irq->resource.node, &res_pool->free_list);
  335. }
  336. for_each_msi_entry(msi_desc, &mc_bus_dev->dev) {
  337. mc_dev_irq = &irq_resources[msi_desc->fsl_mc.msi_index];
  338. mc_dev_irq->msi_desc = msi_desc;
  339. mc_dev_irq->resource.id = msi_desc->irq;
  340. }
  341. res_pool->max_count = irq_count;
  342. res_pool->free_count = irq_count;
  343. mc_bus->irq_resources = irq_resources;
  344. return 0;
  345. cleanup_msi_irqs:
  346. fsl_mc_msi_domain_free_irqs(&mc_bus_dev->dev);
  347. return error;
  348. }
  349. EXPORT_SYMBOL_GPL(fsl_mc_populate_irq_pool);
  350. /**
  351. * Teardown the interrupt pool associated with an fsl-mc bus.
  352. * It frees the IRQs that were allocated to the pool, back to the GIC-ITS.
  353. */
  354. void fsl_mc_cleanup_irq_pool(struct fsl_mc_device *mc_bus_dev)
  355. {
  356. struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);
  357. struct fsl_mc_resource_pool *res_pool =
  358. &mc_bus->resource_pools[FSL_MC_POOL_IRQ];
  359. if (!mc_bus->irq_resources)
  360. return;
  361. if (res_pool->max_count == 0)
  362. return;
  363. if (res_pool->free_count != res_pool->max_count)
  364. return;
  365. INIT_LIST_HEAD(&res_pool->free_list);
  366. res_pool->max_count = 0;
  367. res_pool->free_count = 0;
  368. mc_bus->irq_resources = NULL;
  369. fsl_mc_msi_domain_free_irqs(&mc_bus_dev->dev);
  370. }
  371. EXPORT_SYMBOL_GPL(fsl_mc_cleanup_irq_pool);
  372. /**
  373. * Allocate the IRQs required by a given fsl-mc device.
  374. */
  375. int __must_check fsl_mc_allocate_irqs(struct fsl_mc_device *mc_dev)
  376. {
  377. int i;
  378. int irq_count;
  379. int res_allocated_count = 0;
  380. int error = -EINVAL;
  381. struct fsl_mc_device_irq **irqs = NULL;
  382. struct fsl_mc_bus *mc_bus;
  383. struct fsl_mc_resource_pool *res_pool;
  384. if (mc_dev->irqs)
  385. return -EINVAL;
  386. irq_count = mc_dev->obj_desc.irq_count;
  387. if (irq_count == 0)
  388. return -EINVAL;
  389. if (is_fsl_mc_bus_dprc(mc_dev))
  390. mc_bus = to_fsl_mc_bus(mc_dev);
  391. else
  392. mc_bus = to_fsl_mc_bus(to_fsl_mc_device(mc_dev->dev.parent));
  393. if (!mc_bus->irq_resources)
  394. return -EINVAL;
  395. res_pool = &mc_bus->resource_pools[FSL_MC_POOL_IRQ];
  396. if (res_pool->free_count < irq_count) {
  397. dev_err(&mc_dev->dev,
  398. "Not able to allocate %u irqs for device\n", irq_count);
  399. return -ENOSPC;
  400. }
  401. irqs = devm_kcalloc(&mc_dev->dev, irq_count, sizeof(irqs[0]),
  402. GFP_KERNEL);
  403. if (!irqs)
  404. return -ENOMEM;
  405. for (i = 0; i < irq_count; i++) {
  406. struct fsl_mc_resource *resource;
  407. error = fsl_mc_resource_allocate(mc_bus, FSL_MC_POOL_IRQ,
  408. &resource);
  409. if (error < 0)
  410. goto error_resource_alloc;
  411. irqs[i] = to_fsl_mc_irq(resource);
  412. res_allocated_count++;
  413. irqs[i]->mc_dev = mc_dev;
  414. irqs[i]->dev_irq_index = i;
  415. }
  416. mc_dev->irqs = irqs;
  417. return 0;
  418. error_resource_alloc:
  419. for (i = 0; i < res_allocated_count; i++) {
  420. irqs[i]->mc_dev = NULL;
  421. fsl_mc_resource_free(&irqs[i]->resource);
  422. }
  423. return error;
  424. }
  425. EXPORT_SYMBOL_GPL(fsl_mc_allocate_irqs);
  426. /*
  427. * Frees the IRQs that were allocated for an fsl-mc device.
  428. */
  429. void fsl_mc_free_irqs(struct fsl_mc_device *mc_dev)
  430. {
  431. int i;
  432. int irq_count;
  433. struct fsl_mc_bus *mc_bus;
  434. struct fsl_mc_device_irq **irqs = mc_dev->irqs;
  435. if (!irqs)
  436. return;
  437. irq_count = mc_dev->obj_desc.irq_count;
  438. if (is_fsl_mc_bus_dprc(mc_dev))
  439. mc_bus = to_fsl_mc_bus(mc_dev);
  440. else
  441. mc_bus = to_fsl_mc_bus(to_fsl_mc_device(mc_dev->dev.parent));
  442. if (!mc_bus->irq_resources)
  443. return;
  444. for (i = 0; i < irq_count; i++) {
  445. irqs[i]->mc_dev = NULL;
  446. fsl_mc_resource_free(&irqs[i]->resource);
  447. }
  448. mc_dev->irqs = NULL;
  449. }
  450. EXPORT_SYMBOL_GPL(fsl_mc_free_irqs);
  451. void fsl_mc_init_all_resource_pools(struct fsl_mc_device *mc_bus_dev)
  452. {
  453. int pool_type;
  454. struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);
  455. for (pool_type = 0; pool_type < FSL_MC_NUM_POOL_TYPES; pool_type++) {
  456. struct fsl_mc_resource_pool *res_pool =
  457. &mc_bus->resource_pools[pool_type];
  458. res_pool->type = pool_type;
  459. res_pool->max_count = 0;
  460. res_pool->free_count = 0;
  461. res_pool->mc_bus = mc_bus;
  462. INIT_LIST_HEAD(&res_pool->free_list);
  463. mutex_init(&res_pool->mutex);
  464. }
  465. }
  466. static void fsl_mc_cleanup_resource_pool(struct fsl_mc_device *mc_bus_dev,
  467. enum fsl_mc_pool_type pool_type)
  468. {
  469. struct fsl_mc_resource *resource;
  470. struct fsl_mc_resource *next;
  471. struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);
  472. struct fsl_mc_resource_pool *res_pool =
  473. &mc_bus->resource_pools[pool_type];
  474. int free_count = 0;
  475. list_for_each_entry_safe(resource, next, &res_pool->free_list, node) {
  476. free_count++;
  477. devm_kfree(&mc_bus_dev->dev, resource);
  478. }
  479. }
  480. void fsl_mc_cleanup_all_resource_pools(struct fsl_mc_device *mc_bus_dev)
  481. {
  482. int pool_type;
  483. for (pool_type = 0; pool_type < FSL_MC_NUM_POOL_TYPES; pool_type++)
  484. fsl_mc_cleanup_resource_pool(mc_bus_dev, pool_type);
  485. }
  486. /**
  487. * fsl_mc_allocator_probe - callback invoked when an allocatable device is
  488. * being added to the system
  489. */
  490. static int fsl_mc_allocator_probe(struct fsl_mc_device *mc_dev)
  491. {
  492. enum fsl_mc_pool_type pool_type;
  493. struct fsl_mc_device *mc_bus_dev;
  494. struct fsl_mc_bus *mc_bus;
  495. int error;
  496. if (!fsl_mc_is_allocatable(mc_dev))
  497. return -EINVAL;
  498. mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
  499. if (!dev_is_fsl_mc(&mc_bus_dev->dev))
  500. return -EINVAL;
  501. mc_bus = to_fsl_mc_bus(mc_bus_dev);
  502. error = object_type_to_pool_type(mc_dev->obj_desc.type, &pool_type);
  503. if (error < 0)
  504. return error;
  505. error = fsl_mc_resource_pool_add_device(mc_bus, pool_type, mc_dev);
  506. if (error < 0)
  507. return error;
  508. dev_dbg(&mc_dev->dev,
  509. "Allocatable fsl-mc device bound to fsl_mc_allocator driver");
  510. return 0;
  511. }
  512. /**
  513. * fsl_mc_allocator_remove - callback invoked when an allocatable device is
  514. * being removed from the system
  515. */
  516. static int fsl_mc_allocator_remove(struct fsl_mc_device *mc_dev)
  517. {
  518. int error;
  519. if (!fsl_mc_is_allocatable(mc_dev))
  520. return -EINVAL;
  521. if (mc_dev->resource) {
  522. error = fsl_mc_resource_pool_remove_device(mc_dev);
  523. if (error < 0)
  524. return error;
  525. }
  526. dev_dbg(&mc_dev->dev,
  527. "Allocatable fsl-mc device unbound from fsl_mc_allocator driver");
  528. return 0;
  529. }
  530. static const struct fsl_mc_device_id match_id_table[] = {
  531. {
  532. .vendor = FSL_MC_VENDOR_FREESCALE,
  533. .obj_type = "dpbp",
  534. },
  535. {
  536. .vendor = FSL_MC_VENDOR_FREESCALE,
  537. .obj_type = "dpmcp",
  538. },
  539. {
  540. .vendor = FSL_MC_VENDOR_FREESCALE,
  541. .obj_type = "dpcon",
  542. },
  543. {.vendor = 0x0},
  544. };
  545. static struct fsl_mc_driver fsl_mc_allocator_driver = {
  546. .driver = {
  547. .name = "fsl_mc_allocator",
  548. .pm = NULL,
  549. },
  550. .match_id_table = match_id_table,
  551. .probe = fsl_mc_allocator_probe,
  552. .remove = fsl_mc_allocator_remove,
  553. };
  554. int __init fsl_mc_allocator_driver_init(void)
  555. {
  556. return fsl_mc_driver_register(&fsl_mc_allocator_driver);
  557. }
  558. void fsl_mc_allocator_driver_exit(void)
  559. {
  560. fsl_mc_driver_unregister(&fsl_mc_allocator_driver);
  561. }