Re: [PATCH v5 17/17] firmware: qcom_scm: Dynamically support SMCCC and legacy conventions

From: Stephen Boyd
Date: Wed Jan 08 2020 - 02:03:07 EST


(Nitpick trivia late at night)

Quoting Elliot Berman (2020-01-07 13:04:26)
> diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
> index 895f148..059bb0f 100644
> --- a/drivers/firmware/qcom_scm.c
> +++ b/drivers/firmware/qcom_scm.c
> @@ -72,6 +72,13 @@ static struct qcom_scm_wb_entry qcom_scm_wb[] = {
> { .flag = QCOM_SCM_FLAG_WARMBOOT_CPU3 },
> };
>
> +static const char *qcom_scm_convention_names[] = {

Can this be const char * const ?

> + [SMC_CONVENTION_UNKNOWN] = "unknown",
> + [SMC_CONVENTION_ARM_32] = "smc arm 32",
> + [SMC_CONVENTION_ARM_64] = "smc arm 64",
> + [SMC_CONVENTION_LEGACY] = "smc legacy",
> +};
> +
> static struct qcom_scm *__scm;
>
> static int qcom_scm_clk_enable(void)
> @@ -107,6 +114,143 @@ static void qcom_scm_clk_disable(void)
> clk_disable_unprepare(__scm->bus_clk);
> }
>
> +static int __qcom_scm_is_call_available(struct device *dev, u32 svc_id,
> + u32 cmd_id);
> +
> +enum qcom_scm_convention qcom_scm_convention;
> +static bool has_queried __read_mostly;
> +static DEFINE_SPINLOCK(query_lock);
> +
> +static void __query_convention(void)
> +{
> + unsigned long flags;
> + struct qcom_scm_desc desc = {
> + .svc = QCOM_SCM_SVC_INFO,
> + .cmd = QCOM_SCM_INFO_IS_CALL_AVAIL,
> + .args[0] = SCM_SMC_FNID(QCOM_SCM_SVC_INFO,
> + QCOM_SCM_INFO_IS_CALL_AVAIL) |
> + (ARM_SMCCC_OWNER_SIP << ARM_SMCCC_OWNER_SHIFT),
> + .arginfo = QCOM_SCM_ARGS(1),
> + .owner = ARM_SMCCC_OWNER_SIP,
> + };
> + struct qcom_scm_res res;
> + int ret;
> +
> + spin_lock_irqsave(&query_lock, flags);
> + if (has_queried)
> + goto out;
> +
> + qcom_scm_convention = SMC_CONVENTION_ARM_64;
> + // Device isn't required as there is only one argument - no device
> + // needed to dma_map_single to secure world

This isn't kernel style for multiline comments. Please use /* and */.

> + ret = scm_smc_call(NULL, &desc, &res, true);
> + if (!ret && res.result[0] == 1)
> + goto out;
> +