From patchwork Mon Sep 10 06:25:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 10593595 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 9861914DB for ; Mon, 10 Sep 2018 06:28:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D36A28878 for ; Mon, 10 Sep 2018 06:28:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 21224288B3; Mon, 10 Sep 2018 06:28:01 +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,RCVD_IN_DNSWL_NONE autolearn=ham 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 6860428878 for ; Mon, 10 Sep 2018 06:28:00 +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=GSm9B83m6s+3bfyQtqxFe1llYN eGCP8Ogoes+qcaMzy4iq9dG5i1xegL7Jq5jZknabPrfccpposqQTaXUYS5vLCJt1nswbY0IYQ386I ae98l+CicTrIP49DAyWBVvkf5Cxmf6ROrJss5Kj1O98DX1mc7drZsPO/xOYqXhDuJRgTTcUsWeWWV go4kRDmDr3ZVHs9MJyFjcrvBVcI68WcmAQk5TtY+RtcxYDRalxWOJxVdVT8fXfTDdkwQLL12xJXyx b3YeG0L++m37rBy9p5jq1leQblr07fnkONSS+fPQeLMmocH0OeAlW8Pjk12CKsjmNavbbZW61QYe8 IVlHhmIA==; 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 1fzFfl-0008It-Nv; Mon, 10 Sep 2018 06:27:45 +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 1fzFeR-0007kT-Jq for linux-arm-kernel@lists.infradead.org; Mon, 10 Sep 2018 06:26:27 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id C116A60807; Mon, 10 Sep 2018 06:26:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536560782; bh=rT8NUqC878iuBndcOZzhJBA0BDamjCjcvH88eZ3kR6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X5TxaRA2NhWGJOOPNRMPV3vg4nd7VV9yAu7dJNLFZAtwV1SIoC3us3+TIq8jbhdi/ W3g7aycmEADnnTMh0G5BcdLrH/V/QDkFszx+I6wTmzH/VLfEKNIP3EnpP5l4WUNHFG clNfO0F1vFPE/zmp26mecP00XZNrBVFLFukft130= 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 0BDD56085F; Mon, 10 Sep 2018 06:26:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536560781; bh=rT8NUqC878iuBndcOZzhJBA0BDamjCjcvH88eZ3kR6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nc/LZCARzInwhgM3RfFBidsrsTECue9xYPrR8vVsVh41XJrlNKrPHEbGa5ItqPI0q QdvCiLgucZlZQxPFgWln3WCD/HzOfJfxdbMT5DDySr+4MwnUNjCth2nQ45Olvafzm/ 7r20PvwWkh8I3mRz0ileycY75FOIi4sek3fbCud8= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 0BDD56085F 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, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 2/4] firmware/qcom_scm: Add atomic version of io read/write APIs Date: Mon, 10 Sep 2018 11:55:49 +0530 Message-Id: <20180910062551.28175-3-vivek.gautam@codeaurora.org> X-Mailer: git-send-email 2.16.1.72.g5be1f00a9a70 In-Reply-To: <20180910062551.28175-1-vivek.gautam@codeaurora.org> References: <20180910062551.28175-1-vivek.gautam@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180909_232623_743528_E744D76A X-CRM114-Status: GOOD ( 11.98 ) 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: linux-kernel@vger.kernel.org, swboyd@chromium.org, david.brown@linaro.org, robdclark@gmail.com, Vivek Gautam , tfiga@chromium.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 Reviewed-by: Bjorn Andersson --- 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