mbox series

[v2,0/2] Venus - fix firmware load failure

Message ID 20200817082723.17458-1-stanimir.varbanov@linaro.org
Headers show
Series Venus - fix firmware load failure | expand

Message

Stanimir Varbanov Aug. 17, 2020, 8:27 a.m. UTC
Hi,

Changes since v1:
 * Move the new scm call above assign mem - Elliot Berman

v1 can be found at [1].

regards,
Stan

[1] https://lkml.org/lkml/2020/7/9/472

Stanimir Varbanov (2):
  firmware: qcom_scm: Add memory protect virtual address ranges
  venus: firmware: Set virtual address ranges

 drivers/firmware/qcom_scm.c                  | 24 ++++++++++++++++++++
 drivers/firmware/qcom_scm.h                  |  1 +
 drivers/media/platform/qcom/venus/core.c     |  4 ++++
 drivers/media/platform/qcom/venus/core.h     |  4 ++++
 drivers/media/platform/qcom/venus/firmware.c | 18 ++++++++++++++-
 include/linux/qcom_scm.h                     |  8 ++++++-
 6 files changed, 57 insertions(+), 2 deletions(-)

-- 
2.17.1

Comments

Bjorn Andersson Sept. 8, 2020, 2:40 p.m. UTC | #1
On Mon 17 Aug 03:27 CDT 2020, Stanimir Varbanov wrote:

> This adds a new SCM memprotect command to set virtual address ranges.

> 


Acked-by: Bjorn Andersson <bjorn.andersson@linaro.org>



Please feel free to pick this through linux-media.

Regards,
Bjorn

> Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>

> ---

>  drivers/firmware/qcom_scm.c | 24 ++++++++++++++++++++++++

>  drivers/firmware/qcom_scm.h |  1 +

>  include/linux/qcom_scm.h    |  8 +++++++-

>  3 files changed, 32 insertions(+), 1 deletion(-)

> 

> diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c

> index 0e7233a20f34..dec8dc42a6bc 100644

> --- a/drivers/firmware/qcom_scm.c

> +++ b/drivers/firmware/qcom_scm.c

> @@ -757,6 +757,30 @@ int qcom_scm_iommu_secure_ptbl_init(u64 addr, u32 size, u32 spare)

>  }

>  EXPORT_SYMBOL(qcom_scm_iommu_secure_ptbl_init);

>  

> +int qcom_scm_mem_protect_video_var(u32 cp_start, u32 cp_size,

> +				   u32 cp_nonpixel_start,

> +				   u32 cp_nonpixel_size)

> +{

> +	int ret;

> +	struct qcom_scm_desc desc = {

> +		.svc = QCOM_SCM_SVC_MP,

> +		.cmd = QCOM_SCM_MP_VIDEO_VAR,

> +		.arginfo = QCOM_SCM_ARGS(4, QCOM_SCM_VAL, QCOM_SCM_VAL,

> +					 QCOM_SCM_VAL, QCOM_SCM_VAL),

> +		.args[0] = cp_start,

> +		.args[1] = cp_size,

> +		.args[2] = cp_nonpixel_start,

> +		.args[3] = cp_nonpixel_size,

> +		.owner = ARM_SMCCC_OWNER_SIP,

> +	};

> +	struct qcom_scm_res res;

> +

> +	ret = qcom_scm_call(__scm->dev, &desc, &res);

> +

> +	return ret ? : res.result[0];

> +}

> +EXPORT_SYMBOL(qcom_scm_mem_protect_video_var);

> +

>  static int __qcom_scm_assign_mem(struct device *dev, phys_addr_t mem_region,

>  				 size_t mem_sz, phys_addr_t src, size_t src_sz,

>  				 phys_addr_t dest, size_t dest_sz)

> diff --git a/drivers/firmware/qcom_scm.h b/drivers/firmware/qcom_scm.h

> index d9ed670da222..14da834ac593 100644

> --- a/drivers/firmware/qcom_scm.h

> +++ b/drivers/firmware/qcom_scm.h

> @@ -97,6 +97,7 @@ extern int scm_legacy_call(struct device *dev, const struct qcom_scm_desc *desc,

>  #define QCOM_SCM_MP_RESTORE_SEC_CFG		0x02

>  #define QCOM_SCM_MP_IOMMU_SECURE_PTBL_SIZE	0x03

>  #define QCOM_SCM_MP_IOMMU_SECURE_PTBL_INIT	0x04

> +#define QCOM_SCM_MP_VIDEO_VAR			0x08

>  #define QCOM_SCM_MP_ASSIGN			0x16

>  

>  #define QCOM_SCM_SVC_OCMEM		0x0f

> diff --git a/include/linux/qcom_scm.h b/include/linux/qcom_scm.h

> index 3d6a24697761..ba45537f688b 100644

> --- a/include/linux/qcom_scm.h

> +++ b/include/linux/qcom_scm.h

> @@ -77,11 +77,13 @@ extern bool qcom_scm_restore_sec_cfg_available(void);

>  extern int qcom_scm_restore_sec_cfg(u32 device_id, u32 spare);

>  extern int qcom_scm_iommu_secure_ptbl_size(u32 spare, size_t *size);

>  extern int qcom_scm_iommu_secure_ptbl_init(u64 addr, u32 size, u32 spare);

> +extern int qcom_scm_mem_protect_video_var(u32 cp_start, u32 cp_size,

> +					  u32 cp_nonpixel_start,

> +					  u32 cp_nonpixel_size);

>  extern int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz,

>  			       unsigned int *src,

>  			       const struct qcom_scm_vmperm *newvm,

>  			       unsigned int dest_cnt);

> -

>  extern bool qcom_scm_ocmem_lock_available(void);

>  extern int qcom_scm_ocmem_lock(enum qcom_scm_ocmem_client id, u32 offset,

>  			       u32 size, u32 mode);

> @@ -128,6 +130,10 @@ static inline int qcom_scm_iommu_secure_ptbl_size(u32 spare, size_t *size)

>  		{ return -ENODEV; }

>  static inline int qcom_scm_iommu_secure_ptbl_init(u64 addr, u32 size, u32 spare)

>  		{ return -ENODEV; }

> +extern inline int qcom_scm_mem_protect_video_var(u32 cp_start, u32 cp_size,

> +						 u32 cp_nonpixel_start,

> +						 u32 cp_nonpixel_size)

> +		{ return -ENODEV; }

>  static inline int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz,

>  		unsigned int *src, const struct qcom_scm_vmperm *newvm,

>  		unsigned int dest_cnt) { return -ENODEV; }

> -- 

> 2.17.1

>