From patchwork Tue Aug 14 10:55:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 10565351 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9E7791390 for ; Tue, 14 Aug 2018 10:56:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87FF329934 for ; Tue, 14 Aug 2018 10:56:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7BC2729939; Tue, 14 Aug 2018 10:56:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0D5DE29934 for ; Tue, 14 Aug 2018 10:56:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=rvzraC2ImyObulQm4BesHKPRoyaihsGgobiA8TLWs7I=; b=U4mtdGbYBKYlYmSME+uP6lDEGW LtYn5o8J+1bbHCjKcM2UR3pXvR5uSnPbQ/Ti49qeTxqJ/T2voi8jREfOgqmdznqo6tTlXggjnMEsM /TZ4Ln0pVoNMio28/ZJ2wR2CH7eFYM7CedPdJiRXo3s3R87YYxJXNRIoq6B1gObCQqMqEZgoAHnku BufOT1mCAHynEmvswJdmeblHK/VmrQXy6G4Gg3oRMcnvfz3Kw2FvYS9RwanZqcBlVw980Og2j43yd sMIe2E2m4hT9y2La7dW1qFiGdoXlohwIiekgFLQ0ikX3z+7RtY5iK6Nk0DlmYD+0QFFztGL71IDoE 6gC6WFIA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fpWzt-0006Wo-9T; Tue, 14 Aug 2018 10:56:21 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fpWzP-0005xk-TL for linux-arm-kernel@lists.infradead.org; Tue, 14 Aug 2018 10:55:54 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 53EB960BE3; Tue, 14 Aug 2018 10:55:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1534244151; bh=rT8NUqC878iuBndcOZzhJBA0BDamjCjcvH88eZ3kR6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fjh688bv+6Jq0khNJv1Nbd3hu0nWpamw0sYrQp8+HrLH2MNnKg3hoG/HB0uTGzJQd AIVyCAOWlyN+TVAsF5weW6hTFDhaaf4PuoKEFuazRT4g1zEeCHis+BD4S1YBT3oZEK DtFds+WBBHEKFM5Bs27BQnFIkdB0030/xOd0SxnM= Received: from blr-ubuntu-41.ap.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vivek.gautam@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id A06F360B84; Tue, 14 Aug 2018 10:55:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1534244149; bh=rT8NUqC878iuBndcOZzhJBA0BDamjCjcvH88eZ3kR6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V22xvL3UOua6Hr8LXMdX6htlboGtGIu1jPZSavGZ/TXpwEDOvpzMwfcWQqWRtt49V 98odCEtSlNsw1LzGbT1JIseo9BHxQtFxXewdH+NZDabo+g3iCg3zZFglzgcXxhcbIo /M3XV1quLaeAHUAr3Ak7j1QJZqviVf8lqb9KOD3I= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A06F360B84 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=vivek.gautam@codeaurora.org From: Vivek Gautam To: joro@8bytes.org, andy.gross@linaro.org, will.deacon@arm.com, robin.murphy@arm.com, bjorn.andersson@linaro.org, iommu@lists.linux-foundation.org Subject: [PATCH 2/5] firmware/qcom_scm: Add atomic version of io read/write APIs Date: Tue, 14 Aug 2018 16:25:25 +0530 Message-Id: <20180814105528.20592-3-vivek.gautam@codeaurora.org> X-Mailer: git-send-email 2.16.1.72.g5be1f00a9a70 In-Reply-To: <20180814105528.20592-1-vivek.gautam@codeaurora.org> References: <20180814105528.20592-1-vivek.gautam@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180814_035551_987886_A6C3CC02 X-CRM114-Status: GOOD ( 11.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, swboyd@chromium.org, david.brown@linaro.org, Vivek Gautam , tfiga@chromium.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add atomic versions of qcom_scm_io_readl/writel to enable reading/writing secure registers from atomic context. Signed-off-by: Vivek Gautam --- drivers/firmware/qcom_scm-32.c | 12 ++++++++++++ drivers/firmware/qcom_scm-64.c | 32 ++++++++++++++++++++++++++++++++ drivers/firmware/qcom_scm.c | 12 ++++++++++++ drivers/firmware/qcom_scm.h | 4 ++++ include/linux/qcom_scm.h | 4 ++++ 5 files changed, 64 insertions(+) diff --git a/drivers/firmware/qcom_scm-32.c b/drivers/firmware/qcom_scm-32.c index 4e24e591ae74..7293e5efad69 100644 --- a/drivers/firmware/qcom_scm-32.c +++ b/drivers/firmware/qcom_scm-32.c @@ -627,3 +627,15 @@ int __qcom_scm_io_writel(struct device *dev, phys_addr_t addr, unsigned int val) return qcom_scm_call_atomic2(QCOM_SCM_SVC_IO, QCOM_SCM_IO_WRITE, addr, val); } + +int __qcom_scm_io_readl_atomic(struct device *dev, phys_addr_t addr, + unsigned int *val) +{ + return -ENODEV; +} + +int __qcom_scm_io_writel_atomic(struct device *dev, phys_addr_t addr, + unsigned int val) +{ + return -ENODEV; +} diff --git a/drivers/firmware/qcom_scm-64.c b/drivers/firmware/qcom_scm-64.c index 3a8c867cdf51..6bf55403f6e3 100644 --- a/drivers/firmware/qcom_scm-64.c +++ b/drivers/firmware/qcom_scm-64.c @@ -558,3 +558,35 @@ int __qcom_scm_io_writel(struct device *dev, phys_addr_t addr, unsigned int val) return qcom_scm_call(dev, QCOM_SCM_SVC_IO, QCOM_SCM_IO_WRITE, &desc, &res); } + +int __qcom_scm_io_readl_atomic(struct device *dev, phys_addr_t addr, + unsigned int *val) +{ + struct qcom_scm_desc desc = {0}; + struct arm_smccc_res res; + int ret; + + desc.args[0] = addr; + desc.arginfo = QCOM_SCM_ARGS(1); + + ret = qcom_scm_call_atomic(dev, QCOM_SCM_SVC_IO, QCOM_SCM_IO_READ, + &desc, &res); + if (ret >= 0) + *val = res.a1; + + return ret < 0 ? ret : 0; +} + +int __qcom_scm_io_writel_atomic(struct device *dev, phys_addr_t addr, + unsigned int val) +{ + struct qcom_scm_desc desc = {0}; + struct arm_smccc_res res; + + desc.args[0] = addr; + desc.args[1] = val; + desc.arginfo = QCOM_SCM_ARGS(2); + + return qcom_scm_call_atomic(dev, QCOM_SCM_SVC_IO, QCOM_SCM_IO_WRITE, + &desc, &res); +} diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index e778af766fae..36da0000b37f 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -365,6 +365,18 @@ int qcom_scm_io_writel(phys_addr_t addr, unsigned int val) } EXPORT_SYMBOL(qcom_scm_io_writel); +int qcom_scm_io_readl_atomic(phys_addr_t addr, unsigned int *val) +{ + return __qcom_scm_io_readl_atomic(__scm->dev, addr, val); +} +EXPORT_SYMBOL(qcom_scm_io_readl_atomic); + +int qcom_scm_io_writel_atomic(phys_addr_t addr, unsigned int val) +{ + return __qcom_scm_io_writel_atomic(__scm->dev, addr, val); +} +EXPORT_SYMBOL(qcom_scm_io_writel_atomic); + static void qcom_scm_set_download_mode(bool enable) { bool avail; diff --git a/drivers/firmware/qcom_scm.h b/drivers/firmware/qcom_scm.h index dcd7f7917fc7..bb176107f51e 100644 --- a/drivers/firmware/qcom_scm.h +++ b/drivers/firmware/qcom_scm.h @@ -37,6 +37,10 @@ extern void __qcom_scm_cpu_power_down(u32 flags); #define QCOM_SCM_IO_WRITE 0x2 extern int __qcom_scm_io_readl(struct device *dev, phys_addr_t addr, unsigned int *val); extern int __qcom_scm_io_writel(struct device *dev, phys_addr_t addr, unsigned int val); +extern int __qcom_scm_io_readl_atomic(struct device *dev, phys_addr_t addr, + unsigned int *val); +extern int __qcom_scm_io_writel_atomic(struct device *dev, phys_addr_t addr, + unsigned int val); #define QCOM_SCM_SVC_INFO 0x6 #define QCOM_IS_CALL_AVAIL_CMD 0x1 diff --git a/include/linux/qcom_scm.h b/include/linux/qcom_scm.h index 5d65521260b3..6a5d0c98b328 100644 --- a/include/linux/qcom_scm.h +++ b/include/linux/qcom_scm.h @@ -64,6 +64,8 @@ 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_io_readl(phys_addr_t addr, unsigned int *val); extern int qcom_scm_io_writel(phys_addr_t addr, unsigned int val); +extern int qcom_scm_io_readl_atomic(phys_addr_t addr, unsigned int *val); +extern int qcom_scm_io_writel_atomic(phys_addr_t addr, unsigned int val); #else static inline int qcom_scm_set_cold_boot_addr(void *entry, const cpumask_t *cpus) @@ -100,5 +102,7 @@ static inline int qcom_scm_iommu_secure_ptbl_size(u32 spare, size_t *size) { ret static inline int qcom_scm_iommu_secure_ptbl_init(u64 addr, u32 size, u32 spare) { return -ENODEV; } static inline int qcom_scm_io_readl(phys_addr_t addr, unsigned int *val) { return -ENODEV; } static inline int qcom_scm_io_writel(phys_addr_t addr, unsigned int val) { return -ENODEV; } +static inline int qcom_scm_io_readl_atomic(phys_addr_t addr, unsigned int *val) { return -ENODEV; } +static inline int qcom_scm_io_writel_atomic(phys_addr_t addr, unsigned int val) { return -ENODEV; } #endif #endif