From patchwork Fri Aug 19 15:53:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 74282 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp382332qga; Fri, 19 Aug 2016 08:54:16 -0700 (PDT) X-Received: by 10.98.60.20 with SMTP id j20mr15483480pfa.114.1471622056502; Fri, 19 Aug 2016 08:54:16 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p75si5619930pfd.230.2016.08.19.08.54.16; Fri, 19 Aug 2016 08:54:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754885AbcHSPyG (ORCPT + 8 others); Fri, 19 Aug 2016 11:54:06 -0400 Received: from mail-wm0-f47.google.com ([74.125.82.47]:37310 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754770AbcHSPyD (ORCPT ); Fri, 19 Aug 2016 11:54:03 -0400 Received: by mail-wm0-f47.google.com with SMTP id i5so47550451wmg.0 for ; Fri, 19 Aug 2016 08:54:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=57EaLZE+jDwAlAkwN+oAhiOjUosvPJozBdOS9sOLH4g=; b=IutBfT2Ocgqiip1cz4I3HdV9c9V8jt3k/D2TYrNkSZksk7G60ZiA0P2kxfroqCF/xQ P97hV2VzXdzB6uycwBAm5QjH9zIt4TwQRUM8WcxpMyGJx41kcWrlsWvaCB8zQ4txlTx7 pIwX+E2qBI1OMKpX+wjbDjbQxTdrk6IKVnBcg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=57EaLZE+jDwAlAkwN+oAhiOjUosvPJozBdOS9sOLH4g=; b=DYWetpz7x2ae9PpiopKBSLskz9h+OnLysqhsWwnToO3SsYv6n7vHs33r3aRefiVLrG dMEqzkSSb5pNPT3gZE3ePkitSSgpWxzxCw7v8QpwDU1+hfCcBmKYodJWYds/ze+xMA/g TfuYYvx4ZVdcKzamr7itsHzIXPnOkIhs1SFIFHpChkg8cm2kRLeFnOkdQ1HBrXCbRhFA sf0CYekajxo6nLhnFqhMQLUSUxp/d7QKRg88eQkaB7qmTINbPQXuHPRExeZRQdbF1yXw QZfgOMyF7s4VTvGzHZjaS+UixZLt3NByEsDyAoJYmkqw39Z/bkwz/5oJ6QXExCpcGaY7 LRrQ== X-Gm-Message-State: AEkoout6Gyy4s/vK0rKJbzy2DGi2sHuRm+VzNVtf6ffYZNZDeaHt1C3yYeKBRwBFFwQq6HjO X-Received: by 10.28.28.70 with SMTP id c67mr4858915wmc.8.1471622042053; Fri, 19 Aug 2016 08:54:02 -0700 (PDT) Received: from mms-0440.wifi.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id m81sm5027581wmf.1.2016.08.19.08.54.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 19 Aug 2016 08:54:01 -0700 (PDT) From: Stanimir Varbanov To: Andy Gross , Ohad Ben-Cohen , Bjorn Andersson , Stephen Boyd , Rob Herring , Mark Rutland Cc: Rob Clark , Srinivas Kandagatla , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, Stanimir Varbanov Subject: [PATCH 2/4] firmware: qcom: scm: add iommu scm calls for pg table Date: Fri, 19 Aug 2016 18:53:18 +0300 Message-Id: <1471622000-1906-3-git-send-email-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1471622000-1906-1-git-send-email-stanimir.varbanov@linaro.org> References: <1471622000-1906-1-git-send-email-stanimir.varbanov@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Those two scm calls are used to get the size of secure iommu page table and to pass physical memory address for this page table. The calls are used by remoteproc venus driver to load the firmware. Signed-off-by: Stanimir Varbanov --- drivers/firmware/qcom_scm-64.c | 42 ++++++++++++++++++++++++++++++++++++++++++ drivers/firmware/qcom_scm.c | 12 ++++++++++++ drivers/firmware/qcom_scm.h | 11 +++++++++++ include/linux/qcom_scm.h | 3 +++ 4 files changed, 68 insertions(+) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/firmware/qcom_scm-64.c b/drivers/firmware/qcom_scm-64.c index 68484ea2aa51..ffcfbb31ae7a 100644 --- a/drivers/firmware/qcom_scm-64.c +++ b/drivers/firmware/qcom_scm-64.c @@ -374,3 +374,45 @@ int __qcom_scm_video_set_state(struct device *dev, u32 state, u32 spare) return ret ? : res.a1; } + +int __qcom_scm_iommu_secure_ptbl_size(struct device *dev, u32 spare, + size_t *size) +{ + struct qcom_scm_desc desc = {0}; + struct arm_smccc_res res; + int ret; + + desc.args[0] = spare; + desc.arginfo = QCOM_SCM_ARGS(1); + + ret = qcom_scm_call(dev, QCOM_SCM_SVC_MP, + QCOM_SCM_IOMMU_SECURE_PTBL_SIZE, &desc, &res); + + if (size) + *size = res.a1; + + return ret ? : res.a2; +} + +int __qcom_scm_iommu_secure_ptbl_init(struct device *dev, u64 addr, u32 size, + u32 spare) +{ + struct qcom_scm_desc desc = {0}; + struct arm_smccc_res res; + int ret; + + desc.args[0] = addr; + desc.args[1] = size; + desc.args[2] = spare; + desc.arginfo = QCOM_SCM_ARGS(3, QCOM_SCM_RW, QCOM_SCM_VAL, + QCOM_SCM_VAL); + + ret = qcom_scm_call(dev, QCOM_SCM_SVC_MP, + QCOM_SCM_IOMMU_SECURE_PTBL_INIT, &desc, &res); + + /* the pg table has been initialized already, ignore the error */ + if (ret == -EPERM) + ret = 0; + + return ret; +} diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index 3b0e31c48639..aa77d31b885c 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -333,6 +333,18 @@ int qcom_scm_video_set_state(u32 state, u32 spare) } EXPORT_SYMBOL(qcom_scm_video_set_state); +int qcom_scm_iommu_secure_ptbl_size(u32 spare, size_t *size) +{ + return __qcom_scm_iommu_secure_ptbl_size(__scm->dev, spare, size); +} +EXPORT_SYMBOL(qcom_scm_iommu_secure_ptbl_size); + +int qcom_scm_iommu_secure_ptbl_init(u64 addr, u32 size, u32 spare) +{ + return __qcom_scm_iommu_secure_ptbl_init(__scm->dev, addr, size, spare); +} +EXPORT_SYMBOL(qcom_scm_iommu_secure_ptbl_init); + static int qcom_scm_probe(struct platform_device *pdev) { struct qcom_scm *scm; diff --git a/drivers/firmware/qcom_scm.h b/drivers/firmware/qcom_scm.h index 4830559b2639..edeb0038e5fc 100644 --- a/drivers/firmware/qcom_scm.h +++ b/drivers/firmware/qcom_scm.h @@ -58,8 +58,17 @@ extern int __qcom_scm_pas_auth_and_reset(struct device *dev, u32 peripheral); extern int __qcom_scm_pas_shutdown(struct device *dev, u32 peripheral); extern int __qcom_scm_pas_mss_reset(struct device *dev, bool reset); +#define QCOM_SCM_SVC_MP 0xc +#define QCOM_SCM_IOMMU_SECURE_PTBL_SIZE 3 +#define QCOM_SCM_IOMMU_SECURE_PTBL_INIT 4 +extern int __qcom_scm_iommu_secure_ptbl_size(struct device *dev, u32 spare, + size_t *size); +extern int __qcom_scm_iommu_secure_ptbl_init(struct device *dev, u64 addr, + u32 size, u32 spare); + /* common error codes */ #define QCOM_SCM_V2_EBUSY -12 +#define QCOM_SCM_NOT_PERMITTED -8 #define QCOM_SCM_ENOMEM -5 #define QCOM_SCM_EOPNOTSUPP -4 #define QCOM_SCM_EINVAL_ADDR -3 @@ -81,6 +90,8 @@ static inline int qcom_scm_remap_error(int err) return -ENOMEM; case QCOM_SCM_V2_EBUSY: return -EBUSY; + case QCOM_SCM_NOT_PERMITTED: + return -EPERM; } return -EINVAL; } diff --git a/include/linux/qcom_scm.h b/include/linux/qcom_scm.h index 2ece81a6b078..a8fb98c36cce 100644 --- a/include/linux/qcom_scm.h +++ b/include/linux/qcom_scm.h @@ -48,4 +48,7 @@ extern u32 qcom_scm_get_version(void); extern int qcom_scm_video_set_state(u32 state, 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); + #endif