msm_smmu.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. /*
  2. * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  3. * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (C) 2013 Red Hat
  5. * Author: Rob Clark <[email protected]>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published by
  9. * the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  14. * more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along with
  17. * this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include <linux/module.h>
  20. #include <linux/of_platform.h>
  21. #include <linux/pm_runtime.h>
  22. #include <linux/qcom-dma-mapping.h>
  23. #include <linux/msm_dma_iommu_mapping.h>
  24. #include <linux/dma-mapping.h>
  25. #include <linux/qcom-iommu-util.h>
  26. #include <soc/qcom/secure_buffer.h>
  27. #include "msm_drv.h"
  28. #include "msm_gem.h"
  29. #include "msm_mmu.h"
  30. #include "sde_dbg.h"
  31. #if IS_ENABLED(CONFIG_DISPLAY_SAMSUNG)
  32. #include "ss_dsi_panel_common.h"
  33. #endif
  34. struct msm_smmu_client {
  35. struct device *dev;
  36. const char *compat;
  37. struct iommu_domain *domain;
  38. const struct dma_map_ops *dma_ops;
  39. bool domain_attached;
  40. bool secure;
  41. struct list_head smmu_list;
  42. };
  43. struct msm_smmu {
  44. struct msm_mmu base;
  45. struct device *client_dev;
  46. struct msm_smmu_client *client;
  47. };
  48. struct msm_smmu_domain {
  49. const char *label;
  50. bool secure;
  51. };
  52. #define to_msm_smmu(x) container_of(x, struct msm_smmu, base)
  53. #define msm_smmu_to_client(smmu) (smmu->client)
  54. /* Serialization lock for smmu_list */
  55. static DEFINE_MUTEX(smmu_list_lock);
  56. /* List of all smmu devices installed */
  57. static LIST_HEAD(sde_smmu_list);
  58. static int msm_smmu_attach(struct msm_mmu *mmu, const char * const *names,
  59. int cnt)
  60. {
  61. struct msm_smmu *smmu = to_msm_smmu(mmu);
  62. struct msm_smmu_client *client = msm_smmu_to_client(smmu);
  63. int rc = 0;
  64. if (!client) {
  65. pr_err("undefined smmu client\n");
  66. return -EINVAL;
  67. }
  68. /* domain attach only once */
  69. if (client->domain_attached)
  70. return 0;
  71. if (client->dma_ops) {
  72. set_dma_ops(client->dev, client->dma_ops);
  73. client->dma_ops = NULL;
  74. dev_dbg(client->dev, "iommu domain ops restored\n");
  75. }
  76. rc = qcom_iommu_sid_switch(client->dev, SID_ACQUIRE);
  77. if (rc) {
  78. DISP_DEV_ERR(client->dev, "iommu sid switch failed (%d)\n", rc);
  79. return rc;
  80. }
  81. client->domain_attached = true;
  82. dev_dbg(client->dev, "iommu domain attached\n");
  83. return 0;
  84. }
  85. static void msm_smmu_detach(struct msm_mmu *mmu, const char * const *names,
  86. int cnt)
  87. {
  88. struct msm_smmu *smmu = to_msm_smmu(mmu);
  89. struct msm_smmu_client *client = msm_smmu_to_client(smmu);
  90. int rc;
  91. if (!client) {
  92. pr_err("undefined smmu client\n");
  93. return;
  94. }
  95. if (!client->domain_attached)
  96. return;
  97. pm_runtime_get_sync(mmu->dev);
  98. msm_dma_unmap_all_for_dev(client->dev);
  99. rc = qcom_iommu_sid_switch(client->dev, SID_RELEASE);
  100. if (rc)
  101. DRM_ERROR("iommu sid switch failed (%d)\n", rc);
  102. client->dma_ops = get_dma_ops(client->dev);
  103. if (client->dma_ops) {
  104. set_dma_ops(client->dev, NULL);
  105. dev_dbg(client->dev, "iommu domain ops removed\n");
  106. }
  107. pm_runtime_put_sync(mmu->dev);
  108. client->domain_attached = false;
  109. dev_dbg(client->dev, "iommu domain detached\n");
  110. }
  111. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0))
  112. static int msm_enable_smmu_translations(struct msm_mmu *mmu)
  113. {
  114. struct msm_smmu *smmu = to_msm_smmu(mmu);
  115. struct msm_smmu_client *client = msm_smmu_to_client(smmu);
  116. int ret = 0;
  117. if (!client || !client->domain)
  118. return -ENODEV;
  119. ret = qcom_iommu_enable_s1_translation(client->domain);
  120. if (ret)
  121. DRM_ERROR("enable iommu s1 translations failed:%d\n", ret);
  122. return ret;
  123. }
  124. #else
  125. static int msm_smmu_set_attribute(struct msm_mmu *mmu,
  126. enum iommu_attr attr, void *data)
  127. {
  128. struct msm_smmu *smmu = to_msm_smmu(mmu);
  129. struct msm_smmu_client *client = msm_smmu_to_client(smmu);
  130. int ret = 0;
  131. if (!client || !client->domain)
  132. return -ENODEV;
  133. ret = iommu_domain_set_attr(client->domain, attr, data);
  134. if (ret)
  135. DRM_ERROR("set domain attribute failed:%d\n", ret);
  136. return ret;
  137. }
  138. #endif
  139. static int msm_smmu_one_to_one_unmap(struct msm_mmu *mmu,
  140. uint32_t dest_address, uint32_t size)
  141. {
  142. struct msm_smmu *smmu = to_msm_smmu(mmu);
  143. struct msm_smmu_client *client = msm_smmu_to_client(smmu);
  144. int ret = 0;
  145. if (!client || !client->domain)
  146. return -ENODEV;
  147. ret = iommu_unmap(client->domain, dest_address, size);
  148. if (ret != size)
  149. pr_err("smmu unmap failed\n");
  150. return 0;
  151. }
  152. static int msm_smmu_one_to_one_map(struct msm_mmu *mmu, uint32_t iova,
  153. uint32_t dest_address, uint32_t size, int prot)
  154. {
  155. struct msm_smmu *smmu = to_msm_smmu(mmu);
  156. struct msm_smmu_client *client = msm_smmu_to_client(smmu);
  157. int ret = 0;
  158. if (!client || !client->domain)
  159. return -ENODEV;
  160. ret = iommu_map(client->domain, iova, dest_address,
  161. size, prot);
  162. if (ret)
  163. pr_err("smmu map failed\n");
  164. return ret;
  165. }
  166. static int msm_smmu_map(struct msm_mmu *mmu, uint64_t iova,
  167. struct sg_table *sgt, unsigned int len, int prot)
  168. {
  169. struct msm_smmu *smmu = to_msm_smmu(mmu);
  170. struct msm_smmu_client *client = msm_smmu_to_client(smmu);
  171. size_t ret = 0;
  172. if (sgt && sgt->sgl) {
  173. ret = iommu_map_sg(client->domain, iova, sgt->sgl,
  174. sgt->orig_nents, prot);
  175. WARN_ON((int)ret < 0);
  176. DRM_DEBUG("%pad/0x%x/0x%x/\n", &sgt->sgl->dma_address,
  177. sgt->sgl->dma_length, prot);
  178. SDE_EVT32(sgt->sgl->dma_address, sgt->sgl->dma_length, prot);
  179. }
  180. return (ret == len) ? 0 : -EINVAL;
  181. }
  182. static int msm_smmu_unmap(struct msm_mmu *mmu, uint64_t iova,
  183. struct sg_table *sgt, unsigned int len)
  184. {
  185. struct msm_smmu *smmu = to_msm_smmu(mmu);
  186. struct msm_smmu_client *client = msm_smmu_to_client(smmu);
  187. pm_runtime_get_sync(mmu->dev);
  188. iommu_unmap(client->domain, iova, len);
  189. pm_runtime_put_sync(mmu->dev);
  190. return 0;
  191. }
  192. static void msm_smmu_destroy(struct msm_mmu *mmu)
  193. {
  194. struct msm_smmu *smmu = to_msm_smmu(mmu);
  195. struct platform_device *pdev = to_platform_device(smmu->client_dev);
  196. if (smmu->client_dev)
  197. platform_device_unregister(pdev);
  198. kfree(smmu);
  199. }
  200. struct device *msm_smmu_get_dev(struct msm_mmu *mmu)
  201. {
  202. struct msm_smmu *smmu = to_msm_smmu(mmu);
  203. return smmu->client_dev;
  204. }
  205. static int msm_smmu_map_dma_buf(struct msm_mmu *mmu, struct sg_table *sgt,
  206. int dir, u32 flags)
  207. {
  208. struct msm_smmu *smmu = to_msm_smmu(mmu);
  209. struct msm_smmu_client *client = msm_smmu_to_client(smmu);
  210. unsigned long attrs = 0x0;
  211. int ret;
  212. #if IS_ENABLED(CONFIG_DISPLAY_SAMSUNG)
  213. int retry_cnt;
  214. #endif
  215. if (!sgt || !client) {
  216. DRM_ERROR("sg table is invalid\n");
  217. return -ENOMEM;
  218. }
  219. /*
  220. * For import buffer type, dma_map_sg_attrs is called during
  221. * dma_buf_map_attachment and is not required to call again
  222. */
  223. if (!(flags & MSM_BO_EXTBUF)) {
  224. ret = dma_map_sg_attrs(client->dev, sgt->sgl, sgt->nents, dir,
  225. attrs);
  226. #if IS_ENABLED(CONFIG_DISPLAY_SAMSUNG)
  227. if (!in_interrupt()) {
  228. if (!ret) {
  229. for (retry_cnt = 0; retry_cnt < 62 ; retry_cnt++) {
  230. /* To wait free page by memory reclaim*/
  231. usleep_range(16000, 16000);
  232. pr_err("dma map sg failed : retry (%d)\n", retry_cnt);
  233. ret = dma_map_sg_attrs(client->dev, sgt->sgl, sgt->nents, dir,
  234. attrs);
  235. if (!ret)
  236. break;
  237. }
  238. }
  239. }
  240. #endif
  241. if (!ret) {
  242. DRM_ERROR("dma map sg failed\n");
  243. return -ENOMEM;
  244. }
  245. }
  246. if (sgt && sgt->sgl) {
  247. DRM_DEBUG("%pad/0x%x/0x%x/0x%lx\n",
  248. &sgt->sgl->dma_address, sgt->sgl->dma_length,
  249. dir, attrs);
  250. SDE_EVT32(sgt->sgl->dma_address, sgt->sgl->dma_length,
  251. dir, attrs, client->secure, flags);
  252. }
  253. #if IS_ENABLED(CONFIG_DISPLAY_SAMSUNG) && IS_ENABLED(CONFIG_SEC_DEBUG)
  254. if (sec_debug_is_enabled() && sgt && sgt->sgl)
  255. ss_smmu_debug_map(SMMU_RT_DISPLAY_DEBUG, sgt);
  256. #endif
  257. return 0;
  258. }
  259. static void msm_smmu_unmap_dma_buf(struct msm_mmu *mmu, struct sg_table *sgt,
  260. int dir, u32 flags)
  261. {
  262. struct msm_smmu *smmu = to_msm_smmu(mmu);
  263. struct msm_smmu_client *client = msm_smmu_to_client(smmu);
  264. if (!sgt || !client) {
  265. DRM_ERROR("sg table is invalid\n");
  266. return;
  267. }
  268. if (sgt->sgl) {
  269. DRM_DEBUG("%pad/0x%x/0x%x\n",
  270. &sgt->sgl->dma_address, sgt->sgl->dma_length,
  271. dir);
  272. SDE_EVT32(sgt->sgl->dma_address, sgt->sgl->dma_length,
  273. dir, client->secure, flags);
  274. }
  275. #if IS_ENABLED(CONFIG_DISPLAY_SAMSUNG) && IS_ENABLED(CONFIG_SEC_DEBUG)
  276. if (sec_debug_is_enabled() && sgt && sgt->sgl)
  277. ss_smmu_debug_unmap(SMMU_RT_DISPLAY_DEBUG, sgt);
  278. #endif
  279. if (!(flags & MSM_BO_EXTBUF))
  280. dma_unmap_sg(client->dev, sgt->sgl, sgt->nents, dir);
  281. }
  282. static bool msm_smmu_is_domain_secure(struct msm_mmu *mmu)
  283. {
  284. struct msm_smmu *smmu = to_msm_smmu(mmu);
  285. struct msm_smmu_client *client = msm_smmu_to_client(smmu);
  286. return client->secure;
  287. }
  288. static const struct msm_mmu_funcs funcs = {
  289. .attach = msm_smmu_attach,
  290. .detach = msm_smmu_detach,
  291. .map = msm_smmu_map,
  292. .unmap = msm_smmu_unmap,
  293. .map_dma_buf = msm_smmu_map_dma_buf,
  294. .unmap_dma_buf = msm_smmu_unmap_dma_buf,
  295. .destroy = msm_smmu_destroy,
  296. .is_domain_secure = msm_smmu_is_domain_secure,
  297. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0))
  298. .enable_smmu_translations = msm_enable_smmu_translations,
  299. #else
  300. .set_attribute = msm_smmu_set_attribute,
  301. #endif
  302. .one_to_one_map = msm_smmu_one_to_one_map,
  303. .one_to_one_unmap = msm_smmu_one_to_one_unmap,
  304. .get_dev = msm_smmu_get_dev,
  305. };
  306. static struct msm_smmu_domain msm_smmu_domains[MSM_SMMU_DOMAIN_MAX] = {
  307. [MSM_SMMU_DOMAIN_UNSECURE] = {
  308. .label = "mdp_ns",
  309. .secure = false,
  310. },
  311. [MSM_SMMU_DOMAIN_SECURE] = {
  312. .label = "mdp_s",
  313. .secure = true,
  314. },
  315. [MSM_SMMU_DOMAIN_NRT_UNSECURE] = {
  316. .label = "rot_ns",
  317. .secure = false,
  318. },
  319. [MSM_SMMU_DOMAIN_NRT_SECURE] = {
  320. .label = "rot_s",
  321. .secure = true,
  322. },
  323. };
  324. static const struct of_device_id msm_smmu_dt_match[] = {
  325. { .compatible = "qcom,smmu_sde_unsec",
  326. .data = &msm_smmu_domains[MSM_SMMU_DOMAIN_UNSECURE] },
  327. { .compatible = "qcom,smmu_sde_sec",
  328. .data = &msm_smmu_domains[MSM_SMMU_DOMAIN_SECURE] },
  329. { .compatible = "qcom,smmu_sde_nrt_unsec",
  330. .data = &msm_smmu_domains[MSM_SMMU_DOMAIN_NRT_UNSECURE] },
  331. { .compatible = "qcom,smmu_sde_nrt_sec",
  332. .data = &msm_smmu_domains[MSM_SMMU_DOMAIN_NRT_SECURE] },
  333. {}
  334. };
  335. MODULE_DEVICE_TABLE(of, msm_smmu_dt_match);
  336. static struct msm_smmu_client *msm_smmu_get_smmu(const char *compat)
  337. {
  338. struct msm_smmu_client *curr = NULL;
  339. bool found = false;
  340. if (!compat) {
  341. pr_err("invalid param\n");
  342. return ERR_PTR(-EINVAL);
  343. }
  344. mutex_lock(&smmu_list_lock);
  345. list_for_each_entry(curr, &sde_smmu_list, smmu_list) {
  346. if (of_compat_cmp(compat, curr->compat, strlen(compat)) == 0) {
  347. DRM_DEBUG("found msm_smmu_client for %s\n", compat);
  348. found = true;
  349. break;
  350. }
  351. }
  352. mutex_unlock(&smmu_list_lock);
  353. if (!found)
  354. return ERR_PTR(-ENODEV);
  355. return curr;
  356. }
  357. static struct device *msm_smmu_device_add(struct device *dev,
  358. enum msm_mmu_domain_type domain,
  359. struct msm_smmu *smmu)
  360. {
  361. int i;
  362. const char *compat = NULL;
  363. for (i = 0; i < ARRAY_SIZE(msm_smmu_dt_match); i++) {
  364. if (msm_smmu_dt_match[i].data == &msm_smmu_domains[domain]) {
  365. compat = msm_smmu_dt_match[i].compatible;
  366. break;
  367. }
  368. }
  369. if (!compat) {
  370. DRM_DEBUG("unable to find matching domain for %d\n", domain);
  371. return ERR_PTR(-ENOENT);
  372. }
  373. DRM_DEBUG("found domain %d compat: %s\n", domain, compat);
  374. smmu->client = msm_smmu_get_smmu(compat);
  375. if (IS_ERR_OR_NULL(smmu->client)) {
  376. DRM_DEBUG("unable to find domain %d compat: %s\n", domain,
  377. compat);
  378. return ERR_PTR(-ENODEV);
  379. }
  380. return smmu->client->dev;
  381. }
  382. struct msm_mmu *msm_smmu_new(struct device *dev,
  383. enum msm_mmu_domain_type domain)
  384. {
  385. struct msm_smmu *smmu;
  386. struct device *client_dev;
  387. smmu = kzalloc(sizeof(*smmu), GFP_KERNEL);
  388. if (!smmu)
  389. return ERR_PTR(-ENOMEM);
  390. client_dev = msm_smmu_device_add(dev, domain, smmu);
  391. if (IS_ERR_OR_NULL(client_dev)) {
  392. kfree(smmu);
  393. return (void *)client_dev ? : ERR_PTR(-ENODEV);
  394. }
  395. smmu->client_dev = client_dev;
  396. msm_mmu_init(&smmu->base, dev, &funcs);
  397. return &smmu->base;
  398. }
  399. static int msm_smmu_fault_handler(struct iommu_domain *domain,
  400. struct device *dev, unsigned long iova,
  401. int flags, void *token)
  402. {
  403. struct msm_smmu_client *client;
  404. int rc = -EINVAL;
  405. if (!token) {
  406. DRM_ERROR("Error: token is NULL\n");
  407. return -EINVAL;
  408. }
  409. client = (struct msm_smmu_client *)token;
  410. /* see iommu.h for fault flags definition */
  411. SDE_EVT32(iova, flags);
  412. DRM_ERROR("trigger dump, iova=0x%08lx, flags=0x%x\n", iova, flags);
  413. DRM_ERROR("SMMU device:%s", client->dev ? client->dev->kobj.name : "");
  414. #if IS_ENABLED(CONFIG_DISPLAY_SAMSUNG)
  415. //ss_smmu_debug_log();
  416. SDE_DBG_DUMP(SDE_DBG_BUILT_IN_ALL, "panic"); // case 03250922
  417. #endif
  418. /*
  419. * return -ENOSYS to allow smmu driver to dump out useful
  420. * debug info.
  421. */
  422. return rc;
  423. }
  424. /**
  425. * msm_smmu_bind - bind smmu device with controlling device
  426. * @dev: Pointer to base of platform device
  427. * @master: Pointer to container of drm device
  428. * @data: Pointer to private data
  429. * Returns: Zero on success
  430. */
  431. static int msm_smmu_bind(struct device *dev, struct device *master, void *data)
  432. {
  433. return 0;
  434. }
  435. /**
  436. * msm_smmu_unbind - unbind msm_smmu from controlling device
  437. * @dev: Pointer to base of platform device
  438. * @master: Pointer to container of drm device
  439. * @data: Pointer to private data
  440. */
  441. static void msm_smmu_unbind(struct device *dev,
  442. struct device *master, void *data)
  443. {
  444. }
  445. static const struct component_ops msm_smmu_comp_ops = {
  446. .bind = msm_smmu_bind,
  447. .unbind = msm_smmu_unbind,
  448. };
  449. /**
  450. * msm_smmu_probe()
  451. * @pdev: platform device
  452. *
  453. * Each smmu context acts as a separate device and the context banks are
  454. * configured with a VA range.
  455. * Registers the clks as each context bank has its own clks, for which voting
  456. * has to be done everytime before using that context bank.
  457. */
  458. static int msm_smmu_probe(struct platform_device *pdev)
  459. {
  460. const struct of_device_id *match;
  461. struct msm_smmu_client *client;
  462. const struct msm_smmu_domain *domain;
  463. int ret;
  464. match = of_match_device(msm_smmu_dt_match, &pdev->dev);
  465. if (!match || !match->data) {
  466. DISP_DEV_ERR(&pdev->dev, "probe failed as match data is invalid\n");
  467. return -EINVAL;
  468. }
  469. domain = match->data;
  470. if (!domain) {
  471. DISP_DEV_ERR(&pdev->dev, "no matching device found\n");
  472. return -EINVAL;
  473. }
  474. #if IS_ENABLED(CONFIG_DISPLAY_SAMSUNG)
  475. pr_err("msm_smmu_probe ++ \n");
  476. #endif
  477. DRM_INFO("probing device %s\n", match->compatible);
  478. client = devm_kzalloc(&pdev->dev, sizeof(*client), GFP_KERNEL);
  479. if (!client)
  480. return -ENOMEM;
  481. client->dev = &pdev->dev;
  482. client->domain = iommu_get_domain_for_dev(client->dev);
  483. if (!client->domain) {
  484. DISP_DEV_ERR(&pdev->dev, "iommu get domain for dev failed\n");
  485. return -EINVAL;
  486. }
  487. client->compat = match->compatible;
  488. client->secure = domain->secure;
  489. client->domain_attached = true;
  490. if (!client->dev->dma_parms)
  491. client->dev->dma_parms = devm_kzalloc(client->dev,
  492. sizeof(*client->dev->dma_parms), GFP_KERNEL);
  493. dma_set_max_seg_size(client->dev, DMA_BIT_MASK(32));
  494. dma_set_seg_boundary(client->dev, (unsigned long)DMA_BIT_MASK(64));
  495. iommu_set_fault_handler(client->domain,
  496. msm_smmu_fault_handler, (void *)client);
  497. DRM_INFO("Created domain %s, secure=%d\n",
  498. domain->label, domain->secure);
  499. platform_set_drvdata(pdev, client);
  500. mutex_lock(&smmu_list_lock);
  501. list_add(&client->smmu_list, &sde_smmu_list);
  502. mutex_unlock(&smmu_list_lock);
  503. ret = component_add(&pdev->dev, &msm_smmu_comp_ops);
  504. if (ret)
  505. pr_err("component add failed\n");
  506. #if IS_ENABLED(CONFIG_DISPLAY_SAMSUNG)
  507. pr_err("msm_smmu_probe -- \n");
  508. #endif
  509. return ret;
  510. }
  511. static int msm_smmu_remove(struct platform_device *pdev)
  512. {
  513. struct msm_smmu_client *client;
  514. struct msm_smmu_client *curr, *next;
  515. client = platform_get_drvdata(pdev);
  516. client->domain_attached = false;
  517. mutex_lock(&smmu_list_lock);
  518. list_for_each_entry_safe(curr, next, &sde_smmu_list, smmu_list) {
  519. if (curr == client) {
  520. list_del(&client->smmu_list);
  521. break;
  522. }
  523. }
  524. mutex_unlock(&smmu_list_lock);
  525. return 0;
  526. }
  527. static struct platform_driver msm_smmu_driver = {
  528. .probe = msm_smmu_probe,
  529. .remove = msm_smmu_remove,
  530. .driver = {
  531. .name = "msmdrm_smmu",
  532. .of_match_table = msm_smmu_dt_match,
  533. .suppress_bind_attrs = true,
  534. },
  535. };
  536. int __init msm_smmu_driver_init(void)
  537. {
  538. int ret;
  539. ret = platform_driver_register(&msm_smmu_driver);
  540. if (ret)
  541. pr_err("mdss_smmu_register_driver() failed!\n");
  542. return ret;
  543. }
  544. void __exit msm_smmu_driver_cleanup(void)
  545. {
  546. platform_driver_unregister(&msm_smmu_driver);
  547. }
  548. MODULE_LICENSE("GPL v2");
  549. MODULE_DESCRIPTION("MSM SMMU driver");
  550. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0))
  551. MODULE_IMPORT_NS(DMA_BUF);
  552. #endif