Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1251247ybl; Fri, 23 Aug 2019 16:12:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqzl4RmGYbqWZYFuC+7tBurWsApkeOQdQCqTX4RADoRhEVAxlKjL/ZUAOXl1Qhr8/Zn93oGq X-Received: by 2002:a65:60cd:: with SMTP id r13mr6193880pgv.315.1566601957981; Fri, 23 Aug 2019 16:12:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566601957; cv=none; d=google.com; s=arc-20160816; b=Gl3Vp95iBD27CgfoEjmJ+QBH2+IVpycOic23jyLvxV7ap1ZVHSR5CEbNkRuKmHOKZV RrtmYQn0F+6dMaR0aIQ7md3a1u7WBBhz/PUxdbo3wjxKudWRRv+iWmSeUpDrPbFaWbwe NFN5A/TE33PvjXL8tAVfRA1nKAtIaS1KOE4rI+jfuE38sSUk+cPZ0W1VYm1elTBEUxS3 C0YygyTgBHeAd9C44wfv55H+5Qjf1pV09jaHcEhbgeMntHPn79BKcjBd/s2jwJZcds7e Y/LZZShNbdW95CCI7vBlGqxsyPCE9CW0yepwGnvXaC4P7Ec3JdUDQ8PaLjG2hK0/m3I1 khMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dVMaDUcpVRzMC4+/rfFT12aU9CrKdVbFRIOod/Cchpk=; b=HzK9JxEnzkPZ4JkX3zOeyu3KQ/dsXIUupQEm6+gwbDur3sQTSkJWMPuKeGrpPlNkT/ MDNfe4C7uGTAOGlAu5WA4Cws5pIAYqFxA2ib55R0TJlvXWbXnC6DFZ5vypiQKy6r8+WC frgOhaL9drbyJdln3UsWBSkMVbL9426xDz2KYot3wNLYjEhyu2SmuIg91s4JPML9qtGp NE4L7M6rnhMEw58OY1k1qTOisc9BTtJsPHOrVP7OxKUKp9Q0XLlgQwFEeTtzkridLnv6 NinfBGxxxSV8OAo/lKbFPuv5eB3dOEUxwuubVbysHLuM4uB3L5NCrOzsiS8t+tl0uch3 lniA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@onstation.org header.s=default header.b=jc4xXJ5a; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u70si3059163pgd.1.2019.08.23.16.12.22; Fri, 23 Aug 2019 16:12:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@onstation.org header.s=default header.b=jc4xXJ5a; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394399AbfHWMRB (ORCPT + 99 others); Fri, 23 Aug 2019 08:17:01 -0400 Received: from onstation.org ([52.200.56.107]:50816 "EHLO onstation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387637AbfHWMQ6 (ORCPT ); Fri, 23 Aug 2019 08:16:58 -0400 Received: from localhost.localdomain (wsip-184-191-162-253.sd.sd.cox.net [184.191.162.253]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: masneyb) by onstation.org (Postfix) with ESMTPSA id B1A4E3E955; Fri, 23 Aug 2019 12:16:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=onstation.org; s=default; t=1566562616; bh=kZ2rAe9w2QMG4oBRAiy9qz9K2mga6Cg66vxAWqEIUko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jc4xXJ5a0NV6Q186fdFX5kxywnqWh10cY/h3bdCgpE4iMDVk6dhva+2t00UQRvJdu rLshj8X17ClW7NbxHt+2C1lYbjf85xtxpaDZ+BPuzyE2tdEixwIXMpz4aXLAP5iTWV Grxp6A19w8WtiESAsPMRJGjeI4ZAZ3jWU8XT7JOI= From: Brian Masney To: agross@kernel.org, robdclark@gmail.com, sean@poorly.run, robh+dt@kernel.org, bjorn.andersson@linaro.org Cc: airlied@linux.ie, daniel@ffwll.ch, mark.rutland@arm.com, jonathan@marek.ca, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, devicetree@vger.kernel.org, jcrouse@codeaurora.org Subject: [PATCH v7 4/7] firmware: qcom: scm: add support to restore secure config to qcm_scm-32 Date: Fri, 23 Aug 2019 05:16:34 -0700 Message-Id: <20190823121637.5861-5-masneyb@onstation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190823121637.5861-1-masneyb@onstation.org> References: <20190823121637.5861-1-masneyb@onstation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rob Clark Add support to restore the secure configuration for qcm_scm-32.c. This is needed by the On Chip MEMory (OCMEM) that is present on some Snapdragon devices. Signed-off-by: Rob Clark [masneyb@onstation.org: ported to latest kernel; set ctx_bank_num to spare parameter.] Signed-off-by: Brian Masney Reviewed-by: Bjorn Andersson --- Changes since v6: - None Changes since v5: - None Changes since v4: - None Changes since v3: - None Changes since v2: - None Changes since v1: - Use existing __qcom_scm_restore_sec_cfg() function stub in qcom_scm-32.c that was unimplemented - Set the cfg.ctx_bank_num to the spare function parameter. It was previously set to the device_id. drivers/firmware/qcom_scm-32.c | 17 ++++++++++++++++- drivers/firmware/qcom_scm.c | 13 +++++++++++++ include/linux/qcom_scm.h | 11 +++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/qcom_scm-32.c b/drivers/firmware/qcom_scm-32.c index 4c2514e5e249..5d90b7f5ab5a 100644 --- a/drivers/firmware/qcom_scm-32.c +++ b/drivers/firmware/qcom_scm-32.c @@ -617,7 +617,22 @@ int __qcom_scm_assign_mem(struct device *dev, phys_addr_t mem_region, int __qcom_scm_restore_sec_cfg(struct device *dev, u32 device_id, u32 spare) { - return -ENODEV; + struct msm_scm_sec_cfg { + __le32 id; + __le32 ctx_bank_num; + } cfg; + int ret, scm_ret = 0; + + cfg.id = cpu_to_le32(device_id); + cfg.ctx_bank_num = cpu_to_le32(spare); + + ret = qcom_scm_call(dev, QCOM_SCM_SVC_MP, QCOM_SCM_RESTORE_SEC_CFG, + &cfg, sizeof(cfg), &scm_ret, sizeof(scm_ret)); + + if (ret || scm_ret) + return ret ? ret : -EINVAL; + + return 0; } int __qcom_scm_iommu_secure_ptbl_size(struct device *dev, u32 spare, diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index 7e285ff3961d..27c1d98a34e6 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -367,6 +367,19 @@ static const struct reset_control_ops qcom_scm_pas_reset_ops = { .deassert = qcom_scm_pas_reset_deassert, }; +/** + * qcom_scm_restore_sec_cfg_available() - Check if secure environment + * supports restore security config interface. + * + * Return true if restore-cfg interface is supported, false if not. + */ +bool qcom_scm_restore_sec_cfg_available(void) +{ + return __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_MP, + QCOM_SCM_RESTORE_SEC_CFG); +} +EXPORT_SYMBOL(qcom_scm_restore_sec_cfg_available); + int qcom_scm_restore_sec_cfg(u32 device_id, u32 spare) { return __qcom_scm_restore_sec_cfg(__scm->dev, device_id, spare); diff --git a/include/linux/qcom_scm.h b/include/linux/qcom_scm.h index b49b734d662c..04382e1798e4 100644 --- a/include/linux/qcom_scm.h +++ b/include/linux/qcom_scm.h @@ -34,6 +34,16 @@ enum qcom_scm_ocmem_client { QCOM_SCM_OCMEM_DEBUG_ID, }; +enum qcom_scm_sec_dev_id { + QCOM_SCM_MDSS_DEV_ID = 1, + QCOM_SCM_OCMEM_DEV_ID = 5, + QCOM_SCM_PCIE0_DEV_ID = 11, + QCOM_SCM_PCIE1_DEV_ID = 12, + QCOM_SCM_GFX_DEV_ID = 18, + QCOM_SCM_UFS_DEV_ID = 19, + QCOM_SCM_ICE_DEV_ID = 20, +}; + #define QCOM_SCM_VMID_HLOS 0x3 #define QCOM_SCM_VMID_MSS_MSA 0xF #define QCOM_SCM_VMID_WLAN 0x18 @@ -70,6 +80,7 @@ extern int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz, extern void qcom_scm_cpu_power_down(u32 flags); extern u32 qcom_scm_get_version(void); extern int qcom_scm_set_remote_state(u32 state, u32 id); +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); -- 2.21.0