From 362ef08af0f7e599f7b1e6e5dd47fd9764649895 Mon Sep 17 00:00:00 2001 From: Andy Gross Date: Fri, 10 Jul 2015 12:35:29 -0500 Subject: [PATCH] firmware: qcom: scm: Fix NULL coherent device Signed-off-by: Andy Gross --- drivers/firmware/qcom_scm-32.c | 6 +++--- drivers/firmware/qcom_scm-64.c | 9 ++++++--- drivers/firmware/qcom_scm.c | 5 +++-- drivers/firmware/qcom_scm.h | 2 +- include/linux/qcom_scm.h | 4 +++- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/firmware/qcom_scm-32.c b/drivers/firmware/qcom_scm-32.c index bbff5fe6d949..4bafb1abd937 100644 --- a/drivers/firmware/qcom_scm-32.c +++ b/drivers/firmware/qcom_scm-32.c @@ -496,7 +496,7 @@ bool __qcom_scm_pas_supported(u32 peripheral) return ret ? false : !!ret_val; } -int __qcom_scm_pas_init_image(u32 peripheral, const void *metadata, size_t size) +int __qcom_scm_pas_init_image(struct device *dev, u32 peripheral, const void *metadata, size_t size) { dma_addr_t mdata_phys; void *mdata_buf; @@ -512,7 +512,7 @@ int __qcom_scm_pas_init_image(u32 peripheral, const void *metadata, size_t size) * data blob, so make sure it's physically contiguous, 4K aligned and * non-cachable to avoid XPU violations. */ - mdata_buf = dma_alloc_coherent(NULL, size, &mdata_phys, GFP_KERNEL); + mdata_buf = dma_alloc_coherent(dev, size, &mdata_phys, GFP_KERNEL); if (!mdata_buf) { pr_err("Allocation of metadata buffer failed.\n"); return -ENOMEM; @@ -526,7 +526,7 @@ int __qcom_scm_pas_init_image(u32 peripheral, const void *metadata, size_t size) &request, sizeof(request), &scm_ret, sizeof(scm_ret)); - dma_free_coherent(NULL, size, mdata_buf, mdata_phys); + dma_free_coherent(dev, size, mdata_buf, mdata_phys); return ret ? : scm_ret; } diff --git a/drivers/firmware/qcom_scm-64.c b/drivers/firmware/qcom_scm-64.c index 751e2ef8ba41..934746eca59a 100644 --- a/drivers/firmware/qcom_scm-64.c +++ b/drivers/firmware/qcom_scm-64.c @@ -15,6 +15,7 @@ * 02110-1301, USA. */ +#include #include #include #include @@ -460,7 +461,7 @@ bool __qcom_scm_pas_supported(u32 peripheral) return ret ? false : !!desc.ret[0]; } -int __qcom_scm_pas_init_image(u32 peripheral, const void *metadata, size_t size) +int __qcom_scm_pas_init_image(struct device *dev, u32 peripheral, const void *metadata, size_t size) { int ret; struct qcom_scm_desc desc = {0}; @@ -468,12 +469,14 @@ int __qcom_scm_pas_init_image(u32 peripheral, const void *metadata, size_t size) dma_addr_t mdata_phys; void *mdata_buf; +dev->coherent_dma_mask = DMA_BIT_MASK(sizeof(dma_addr_t) * 8); + /* * During the scm call memory protection will be enabled for the meta * data blob, so make sure it's physically contiguous, 4K aligned and * non-cachable to avoid XPU violations. */ - mdata_buf = dma_alloc_coherent(NULL, size, &mdata_phys, GFP_KERNEL); + mdata_buf = dma_alloc_coherent(dev, size, &mdata_phys, GFP_KERNEL); if (!mdata_buf) { pr_err("Allocation of metadata buffer failed.\n"); return -ENOMEM; @@ -488,7 +491,7 @@ int __qcom_scm_pas_init_image(u32 peripheral, const void *metadata, size_t size) &desc); scm_ret = desc.ret[0]; - dma_free_coherent(NULL, size, mdata_buf, mdata_phys); + dma_free_coherent(dev, size, mdata_buf, mdata_phys); return ret ? : scm_ret; } diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index ee7150d93b29..cbdf5fdd91eb 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -16,6 +16,7 @@ * 02110-1301, USA. */ +#include #include #include #include @@ -127,9 +128,9 @@ EXPORT_SYMBOL(qcom_scm_pas_supported); * * Returns 0 on success. */ -int qcom_scm_pas_init_image(u32 peripheral, const void *metadata, size_t size) +int qcom_scm_pas_init_image(struct device *dev, u32 peripheral, const void *metadata, size_t size) { - return __qcom_scm_pas_init_image(peripheral, metadata, size); + return __qcom_scm_pas_init_image(dev, peripheral, metadata, size); } EXPORT_SYMBOL(qcom_scm_pas_init_image); diff --git a/drivers/firmware/qcom_scm.h b/drivers/firmware/qcom_scm.h index ffdf9e835de6..f7219025156c 100644 --- a/drivers/firmware/qcom_scm.h +++ b/drivers/firmware/qcom_scm.h @@ -43,7 +43,7 @@ extern int __qcom_scm_hdcp_req(struct qcom_scm_hdcp_req *req, u32 req_cnt, #define QCOM_SCM_PAS_SHUTDOWN_CMD 0x6 #define QCOM_SCM_PAS_IS_SUPPORTED_CMD 0x7 extern bool __qcom_scm_pas_supported(u32 peripheral); -extern int __qcom_scm_pas_init_image(u32 peripheral, const void *metadata, size_t size); +extern int __qcom_scm_pas_init_image(struct device *dev, u32 peripheral, const void *metadata, size_t size); extern int __qcom_scm_pas_mem_setup(u32 peripheral, phys_addr_t addr, phys_addr_t size); extern int __qcom_scm_pas_auth_and_reset(u32 peripheral); extern int __qcom_scm_pas_shutdown(u32 peripheral); diff --git a/include/linux/qcom_scm.h b/include/linux/qcom_scm.h index 1e36898edbda..46d9a51bf674 100644 --- a/include/linux/qcom_scm.h +++ b/include/linux/qcom_scm.h @@ -13,6 +13,8 @@ #ifndef __QCOM_SCM_H #define __QCOM_SCM_H +#include + extern int qcom_scm_set_cold_boot_addr(void *entry, const cpumask_t *cpus); extern int qcom_scm_set_warm_boot_addr(void *entry, const cpumask_t *cpus); @@ -30,7 +32,7 @@ extern int qcom_scm_hdcp_req(struct qcom_scm_hdcp_req *req, u32 req_cnt, u32 *resp); extern bool qcom_scm_pas_supported(u32 peripheral); -extern int qcom_scm_pas_init_image(u32 peripheral, const void *metadata, size_t size); +extern int qcom_scm_pas_init_image(struct device *dev, u32 peripheral, const void *metadata, size_t size); extern int qcom_scm_pas_mem_setup(u32 peripheral, phys_addr_t addr, phys_addr_t size); extern int qcom_scm_pas_auth_and_reset(u32 peripheral); extern int qcom_scm_pas_shutdown(u32 peripheral); -- 2.39.5