From patchwork Mon Nov 27 14:15:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13469724 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0647CC07D59 for ; Mon, 27 Nov 2023 14:17:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VBqwSGJrAso4tIpfzhe/c9akJDciCZMSMNrzulxXaRQ=; b=wOv/VTfdr81cMf 098iYFKUkCQXwIZ1A+iAoBAAkD0/yRT8Zs2/gR199kYI60X3tClwvPNJvSfVGz12WU3IZ+gm6flEy uPuLOL8Sksu1/H8MaCdQkbM78njkq5Yd2rrz738WabUNcxeY27EVYdPZ0kTA9hJU2Lk/264gDWbDt UKu7JMw2uA00jISdxTvd5QPFOX1lmxaRhW2/HG1cbb0Ez16fOVqnkbnVa76JNOg5mQ3laso24OEq8 G6e04DvhpaVzluVUJ9GvvHLFJ55Iwzpz5hJsv15vZvjtpOoifkX6BffHbXqgxYu5Axk7ED2AEYyeb HtBN1UNFfQ0Mz1vrrJJQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r7cPz-002fVk-1Z; Mon, 27 Nov 2023 14:16:59 +0000 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r7cPQ-002fLH-1z for linux-arm-kernel@lists.infradead.org; Mon, 27 Nov 2023 14:16:26 +0000 Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2c59a4dd14cso47636791fa.2 for ; Mon, 27 Nov 2023 06:16:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701094582; x=1701699382; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=W4078kP/f/V2Gky4lpqf6UFEH3ZYOdfKZS8n60prFLY=; b=Sk40wxBwklmlCl49/IaCrmwZMhaj0Zt8j27ZGOvDoGCHFXbuKdQKdSgfptCXLDh5SD aeFLeF+nYhKnflgXn9sWfHb8r7IpoJoN2iBqiBDLkWOsi1mwoaCUUoouFSCmR7Zm8u6y I99yT4JH7Sxue2QcYdL70naa+PfSfi9HZf9zUExwMkVENMVbZqC2p3PwyAWxvt2Qfi10 rZHECFFjxg4+Na4LBZWK1Wbi0VyJx/yMOiUIglM3NKR2MO/3N9UuaIVecyf6GfBJampx JZSorUiSRo3W8Qpk0+flk1EE2d6fg3LK5kC2vrjuI5VeGpa/rCmFkscUc8Pm8O25SmAF pNuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701094582; x=1701699382; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W4078kP/f/V2Gky4lpqf6UFEH3ZYOdfKZS8n60prFLY=; b=i/laxkUMXrF672xWwMaVxBZJJ5hNirbZsjfSA/LlBYwRir/j+5wEwuhwvLRkJaRHPb ekmTFRuD0UuNLZoAQuutHc2WFIbfw/YarEW2LS5E/BmSkLqIWntFu7RSSYP96kL3/JXW D17/etT9V4jD0VuF+4q09yy4K8o6NEJY5w32hVk4hnqXTjCBw5K5c+jqaFA3hVtpo2jh qZVBMjcAtQgMIx2LrN8aPwH6bKhHH2Lmfmn88QVJopVNK95LqeYVhtZk8No29/aRm5Qw F3bpQ8HLxnY3kl+YkPXhlAZ9g2LSX0Q8bcamT4GY8FMz8RI3+y+UY0GEV65L/fbNiDva fWeg== X-Gm-Message-State: AOJu0YyaBKev7/ufDWIGCgd+J+EGMBS8GtpXFzFTKYHqsnO14QC5J6i8 gN9gLGaMdofMiEWxAxSMJR/CYQ== X-Google-Smtp-Source: AGHT+IF7kvO8X4eOkspE0GqfGCCgZHim4OOCuXV37SApn3RrE1w/XnxV1AHmL/UE2FyPm/i4XpHryg== X-Received: by 2002:a05:651c:3d1:b0:2c9:a274:a511 with SMTP id f17-20020a05651c03d100b002c9a274a511mr2410154ljp.43.1701094581791; Mon, 27 Nov 2023 06:16:21 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:bf33:77c7:8131:5e64]) by smtp.gmail.com with ESMTPSA id be7-20020a05600c1e8700b00405442edc69sm14658830wmb.14.2023.11.27.06.16.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:16:21 -0800 (PST) From: Bartosz Golaszewski To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Elliot Berman , Krzysztof Kozlowski , Guru Das Srinagesh , Andrew Halaney , Maximilian Luz , Alex Elder , Srini Kandagatla Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Bartosz Golaszewski Subject: [PATCH v6 10/13] firmware: qcom: scm: add support for SHM bridge operations Date: Mon, 27 Nov 2023 15:15:57 +0100 Message-Id: <20231127141600.20929-11-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231127141600.20929-1-brgl@bgdev.pl> References: <20231127141600.20929-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231127_061624_767252_94F30B01 X-CRM114-Status: GOOD ( 12.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Bartosz Golaszewski Add low-level primitives for enabling SHM bridge support as well as creating and destroying SHM bridge pools to qcom-scm. Signed-off-by: Bartosz Golaszewski Acked-by: Andrew Halaney Tested-by: Andrew Halaney # sc8280xp-lenovo-thinkpad-x13s --- drivers/firmware/qcom/qcom_scm.c | 60 ++++++++++++++++++++++++++ drivers/firmware/qcom/qcom_scm.h | 3 ++ include/linux/firmware/qcom/qcom_scm.h | 6 +++ 3 files changed, 69 insertions(+) diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c index 318d7d398e5f..839773270a21 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -1323,6 +1323,66 @@ bool qcom_scm_lmh_dcvsh_available(void) } EXPORT_SYMBOL_GPL(qcom_scm_lmh_dcvsh_available); +int qcom_scm_shm_bridge_enable(void) +{ + struct qcom_scm_desc desc = { + .svc = QCOM_SCM_SVC_MP, + .cmd = QCOM_SCM_MP_SHM_BRIDGE_ENABLE, + .owner = ARM_SMCCC_OWNER_SIP + }; + + struct qcom_scm_res res; + + if (!__qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_MP, + QCOM_SCM_MP_SHM_BRIDGE_ENABLE)) + return -EOPNOTSUPP; + + return qcom_scm_call(__scm->dev, &desc, &res) ?: res.result[0]; +} +EXPORT_SYMBOL_GPL(qcom_scm_shm_bridge_enable); + +int qcom_scm_shm_bridge_create(struct device *dev, u64 pfn_and_ns_perm_flags, + u64 ipfn_and_s_perm_flags, u64 size_and_flags, + u64 ns_vmids, u64 *handle) +{ + struct qcom_scm_desc desc = { + .svc = QCOM_SCM_SVC_MP, + .cmd = QCOM_SCM_MP_SHM_BRIDGE_CREATE, + .owner = ARM_SMCCC_OWNER_SIP, + .args[0] = pfn_and_ns_perm_flags, + .args[1] = ipfn_and_s_perm_flags, + .args[2] = size_and_flags, + .args[3] = ns_vmids, + .arginfo = QCOM_SCM_ARGS(4, QCOM_SCM_VAL, QCOM_SCM_VAL, + QCOM_SCM_VAL, QCOM_SCM_VAL), + }; + + struct qcom_scm_res res; + int ret; + + ret = qcom_scm_call(__scm->dev, &desc, &res); + + if (handle && !ret) + *handle = res.result[1]; + + return ret ?: res.result[0]; +} +EXPORT_SYMBOL_GPL(qcom_scm_shm_bridge_create); + +int qcom_scm_shm_bridge_delete(struct device *dev, u64 handle) +{ + struct qcom_scm_desc desc = { + .svc = QCOM_SCM_SVC_MP, + .cmd = QCOM_SCM_MP_SHM_BRIDGE_DELETE, + .owner = ARM_SMCCC_OWNER_SIP, + .args[0] = handle, + .arginfo = QCOM_SCM_ARGS(1, QCOM_SCM_VAL), + }; + + return qcom_scm_call(__scm->dev, &desc, NULL); +} +EXPORT_SYMBOL_GPL(qcom_scm_shm_bridge_delete); + int qcom_scm_lmh_profile_change(u32 profile_id) { struct qcom_scm_desc desc = { diff --git a/drivers/firmware/qcom/qcom_scm.h b/drivers/firmware/qcom/qcom_scm.h index aa7d06939f8e..cb7273aa0a5e 100644 --- a/drivers/firmware/qcom/qcom_scm.h +++ b/drivers/firmware/qcom/qcom_scm.h @@ -116,6 +116,9 @@ struct qcom_tzmem_pool *qcom_scm_get_tzmem_pool(void); #define QCOM_SCM_MP_IOMMU_SET_CP_POOL_SIZE 0x05 #define QCOM_SCM_MP_VIDEO_VAR 0x08 #define QCOM_SCM_MP_ASSIGN 0x16 +#define QCOM_SCM_MP_SHM_BRIDGE_ENABLE 0x1c +#define QCOM_SCM_MP_SHM_BRIDGE_DELETE 0x1d +#define QCOM_SCM_MP_SHM_BRIDGE_CREATE 0x1e #define QCOM_SCM_SVC_OCMEM 0x0f #define QCOM_SCM_OCMEM_LOCK_CMD 0x01 diff --git a/include/linux/firmware/qcom/qcom_scm.h b/include/linux/firmware/qcom/qcom_scm.h index ccaf28846054..9b6054813f59 100644 --- a/include/linux/firmware/qcom/qcom_scm.h +++ b/include/linux/firmware/qcom/qcom_scm.h @@ -115,6 +115,12 @@ int qcom_scm_lmh_dcvsh(u32 payload_fn, u32 payload_reg, u32 payload_val, int qcom_scm_lmh_profile_change(u32 profile_id); bool qcom_scm_lmh_dcvsh_available(void); +int qcom_scm_shm_bridge_enable(void); +int qcom_scm_shm_bridge_create(struct device *dev, u64 pfn_and_ns_perm_flags, + u64 ipfn_and_s_perm_flags, u64 size_and_flags, + u64 ns_vmids, u64 *handle); +int qcom_scm_shm_bridge_delete(struct device *dev, u64 handle); + #ifdef CONFIG_QCOM_QSEECOM int qcom_scm_qseecom_app_get_id(const char *app_name, u32 *app_id);