Message ID | 20231009153427.20951-6-brgl@bgdev.pl (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | arm64: qcom: add and enable SHM Bridge support | expand |
Hi Bartosz,
kernel test robot noticed the following build warnings:
[auto build test WARNING on next-20231009]
[cannot apply to arm64/for-next/core krzk-dt/for-next linus/master v6.6-rc5 v6.6-rc4 v6.6-rc3 v6.6-rc5]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Bartosz-Golaszewski/firmware-qcom-move-Qualcomm-code-into-its-own-directory/20231009-233826
base: next-20231009
patch link: https://lore.kernel.org/r/20231009153427.20951-6-brgl%40bgdev.pl
patch subject: [PATCH v3 05/15] firmware: qcom: scm: enable the TZ mem allocator
config: arc-randconfig-001-20231010 (https://download.01.org/0day-ci/archive/20231010/202310101720.hVVWyJf3-lkp@intel.com/config)
compiler: arc-elf-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231010/202310101720.hVVWyJf3-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202310101720.hVVWyJf3-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/firmware/qcom/qcom_tzmem.c:72: warning: Function parameter or member 'size' not described in 'qcom_tzmem_pool_new'
vim +72 drivers/firmware/qcom/qcom_tzmem.c
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 59
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 60 /**
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 61 * qcom_tzmem_pool_new() - Create a new TZ memory pool.
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 62 * @size - Size of the new pool in bytes.
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 63 *
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 64 * Create a new pool of memory suitable for sharing with the TrustZone.
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 65 *
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 66 * Must not be used in atomic context.
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 67 *
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 68 * Returns:
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 69 * New memory pool address or ERR_PTR() on error.
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 70 */
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 71 struct qcom_tzmem_pool *qcom_tzmem_pool_new(size_t size)
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 @72 {
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 73 struct qcom_tzmem_pool *pool;
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 74 int ret = -ENOMEM;
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 75
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 76 if (!size)
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 77 return ERR_PTR(-EINVAL);
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 78
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 79 size = PAGE_ALIGN(size);
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 80
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 81 pool = kzalloc(sizeof(*pool), GFP_KERNEL);
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 82 if (!pool)
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 83 return ERR_PTR(-ENOMEM);
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 84
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 85 pool->size = size;
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 86
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 87 pool->vbase = dma_alloc_coherent(qcom_tzmem_dev, size, &pool->pbase,
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 88 GFP_KERNEL);
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 89 if (!pool->vbase)
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 90 goto err_kfree_pool;
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 91
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 92 pool->pool = gen_pool_create(PAGE_SHIFT, -1);
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 93 if (!pool)
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 94 goto err_dma_free;
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 95
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 96 gen_pool_set_algo(pool->pool, gen_pool_best_fit, NULL);
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 97
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 98 ret = gen_pool_add_virt(pool->pool, (unsigned long)pool->vbase,
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 99 pool->pbase, size, -1);
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 100 if (ret)
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 101 goto err_destroy_genpool;
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 102
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 103 ret = qcom_tzmem_init_pool(pool);
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 104 if (ret)
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 105 goto err_destroy_genpool;
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 106
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 107 return pool;
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 108
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 109 err_destroy_genpool:
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 110 gen_pool_destroy(pool->pool);
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 111 err_dma_free:
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 112 dma_free_coherent(qcom_tzmem_dev, size, pool->vbase, pool->pbase);
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 113 err_kfree_pool:
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 114 kfree(pool);
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 115 return ERR_PTR(ret);
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 116 }
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 117 EXPORT_SYMBOL_GPL(qcom_tzmem_pool_new);
2e798cd92c1686 Bartosz Golaszewski 2023-10-09 118
diff --git a/drivers/firmware/qcom/Kconfig b/drivers/firmware/qcom/Kconfig index b80269a28224..237da40de832 100644 --- a/drivers/firmware/qcom/Kconfig +++ b/drivers/firmware/qcom/Kconfig @@ -7,6 +7,7 @@ menu "Qualcomm firmware drivers" config QCOM_SCM + select QCOM_TZMEM tristate config QCOM_TZMEM diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c index 520de9b5633a..0d4c028be0c1 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -8,8 +8,10 @@ #include <linux/completion.h> #include <linux/cpumask.h> #include <linux/dma-mapping.h> +#include <linux/err.h> #include <linux/export.h> #include <linux/firmware/qcom/qcom_scm.h> +#include <linux/firmware/qcom/qcom_tzmem.h> #include <linux/init.h> #include <linux/interconnect.h> #include <linux/interrupt.h> @@ -20,9 +22,11 @@ #include <linux/of_platform.h> #include <linux/platform_device.h> #include <linux/reset-controller.h> +#include <linux/sizes.h> #include <linux/types.h> #include "qcom_scm.h" +#include "qcom_tzmem.h" static bool download_mode = IS_ENABLED(CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT); module_param(download_mode, bool, 0); @@ -41,6 +45,8 @@ struct qcom_scm { int scm_vote_count; u64 dload_mode_addr; + + struct qcom_tzmem_pool *mempool; }; struct qcom_scm_current_perm_info { @@ -1887,6 +1893,16 @@ static int qcom_scm_probe(struct platform_device *pdev) if (of_property_read_bool(pdev->dev.of_node, "qcom,sdi-enabled")) qcom_scm_disable_sdi(); + ret = qcom_tzmem_enable(__scm->dev); + if (ret) + return dev_err_probe(__scm->dev, ret, + "Failed to enable the TrustZone memory allocator\n"); + + __scm->mempool = devm_qcom_tzmem_pool_new(__scm->dev, SZ_256K); + if (IS_ERR(__scm->mempool)) + return dev_err_probe(__scm->dev, PTR_ERR(__scm->mempool), + "Failed to create the SCM memory pool\n"); + /* * Initialize the QSEECOM interface. *