Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp899023rdg; Fri, 13 Oct 2023 04:51:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFIpdJ4Alfovimci3/fde6ZW/UxLXswBvKSXSxqIbaSB/xBKdaqK0+OnzYdgIarF2rXbi9u X-Received: by 2002:a05:6a20:9707:b0:172:dc0d:1413 with SMTP id hr7-20020a056a20970700b00172dc0d1413mr7992279pzc.11.1697197912733; Fri, 13 Oct 2023 04:51:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697197912; cv=none; d=google.com; s=arc-20160816; b=vkWOayCncrFOf/DOtmYwMVei/AZwZKnodBQ4q55PC3odC+tZkH54+8MYWuTKH20Ti0 W/QEd79WnwYdE91Ik7D+G9/KaGLCuOucMYhDxqfQYnlEVjZ/Bz7Q4cVmB0W41NTQJBuC TbH9qIrbxP+yUdfhLPVbtVM0ylgsRZu+6qIdFwKuG0++G0bWQR0WnXG0Ka/saqb/X0rx tMBCO1C0ev0cw+8/5sZF2+ccjF59bb4im4Hx3c55MsUF2Bf2RLMnTeMrsQOtqzh8ZOZd +MWS6/s+Ujm8AjD0mHicgkmUztFBsZlPea7ZmNPWofcLLgBSi0y4jD5O3Z0qQNd2DwB1 AtSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GC/5cw5j4gsHJ9iomK+6pv+kPUVJjLbCpiT9I+Feyy0=; fh=lirm1ccAeXZZB1cIo+N1DqklpgcFmD/vJ7PCWNIL0HU=; b=dxs5e23dRD/nSaUQmhqj2/vBt4y9cIHIwFLpQ1jsXU2XlhpjRsnfxmBhySeKulgA2f qzjReiq594TTgp8jEGYCIBBaXVrsL/GU4Ev80Fc+vEgsJQ4OlQXKFdqoqWvlf6C8c/Sl nvM07ZIYe0wuI4Afu5AUm2RstscoQhEBBPLfpaZLB2bCi/9gc1kJpptkJyQIIe9n8SzW 2eBlcxp8NuHIjjyeZHNpdf6Zm+tCrnDjGsdZEGVqaRI5OuCt1fd1gAhzilEQCaVv2Jgp rMQLTzxtKMVFEY1cTKNzhZMeFtsuvUMUBx/t3mdnwxnJXajbO4pSWZXnYVvvVejhBlSG xuBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=nH6pdoPh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id pg9-20020a17090b1e0900b0026934bf746bsi4863628pjb.62.2023.10.13.04.51.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 04:51:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=nH6pdoPh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id DD6AB809BE47; Fri, 13 Oct 2023 04:50:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231537AbjJMLtO (ORCPT + 99 others); Fri, 13 Oct 2023 07:49:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231439AbjJMLtB (ORCPT ); Fri, 13 Oct 2023 07:49:01 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87FB3C9 for ; Fri, 13 Oct 2023 04:48:59 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-503056c8195so2716958e87.1 for ; Fri, 13 Oct 2023 04:48:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697197738; x=1697802538; darn=vger.kernel.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=GC/5cw5j4gsHJ9iomK+6pv+kPUVJjLbCpiT9I+Feyy0=; b=nH6pdoPhEccxkrKzB0YUST9q2ND7WyGwKU2zI/BewMmvCaSjJAdK0u74yB6G4jrFDE BLDz7iUwMg6t03EX3ehLZ4PDFzQDOjKVTnw2CPfFLUBPuh6HVKUTBZ/oJCXKPqR6Elul FFoW26Sc8Y5WDcsgcynuTERIP3xyDMpaVRzEo0d9jkeINskAIGfers5GlEgf9g+tpYrx +ISYv/3Yqe5ZM7dHhlVsWsd3T6uoZvYvvWiAS4zPyaiwdTo8BkBRg7TGXdVw1mastnZ9 1POXJ1bwSlyq3op7zx516DHhJhF3yfveaUC3Zgcranm6v8aUnwLwGIhyf2tScuUSL37z yPbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697197738; x=1697802538; 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=GC/5cw5j4gsHJ9iomK+6pv+kPUVJjLbCpiT9I+Feyy0=; b=tmPRu0yITDXX3YMLZTkAIDVv+byludkU56hjCU3xubPwO1nt1RSILZFwqYDJDmjAex yQsBug/ppD9yd69P/LHOsrWnV/EG+3f86PcWDbGwqNe7U8ZH4PX5SgzgTGf+Qw92+oob D6W/oWM1VIi6kGOH3ASSFEM2/VFgH5M57IiEAasIHsWpgFMn/eVaCrkTs+ekHTTjOyDr 2QepNoME+oLBgU7Po/q8x48uDIhU/QcrMcllIoIJzRtWPNrOw7JnC1WxqUKjV44viHJm SfDMGwNYi+ULydhJBC+h158Nd0Si+XKHoxWFQOabexhzGMf2k7dhb8AQIUjh5XnpLgV8 0ARA== X-Gm-Message-State: AOJu0YyR9DTcePF4yIoN2yET2skukRc5igOpKMvSK5KDBZiLF+M7kLZy 4Mpmern9GRf17OpyoGiUBknFjg== X-Received: by 2002:a05:6512:794:b0:500:7cab:efc3 with SMTP id x20-20020a056512079400b005007cabefc3mr19151756lfr.11.1697197737691; Fri, 13 Oct 2023 04:48:57 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4209:13a:988d:80be]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c1c1700b00407754b998dsm974509wms.27.2023.10.13.04.48.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 04:48:57 -0700 (PDT) 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 v4 05/15] firmware: qcom: scm: enable the TZ mem allocator Date: Fri, 13 Oct 2023 13:48:33 +0200 Message-Id: <20231013114843.63205-6-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231013114843.63205-1-brgl@bgdev.pl> References: <20231013114843.63205-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 13 Oct 2023 04:50:37 -0700 (PDT) From: Bartosz Golaszewski Select the TrustZone memory allocator in Kconfig and create a pool of memory shareable with the TrustZone when probing the SCM driver. This will allow a gradual conversion of all relevant SCM calls to using the dedicated allocator. Signed-off-by: Bartosz Golaszewski --- drivers/firmware/qcom/Kconfig | 1 + drivers/firmware/qcom/qcom_scm.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/drivers/firmware/qcom/Kconfig b/drivers/firmware/qcom/Kconfig index b80269a28224..237da40de832 100644 --- a/drivers/firmware/qcom/Kconfig +++ b/drivers/firmware/qcom/Kconfig @@ -7,6 +7,7 @@ menu "Qualcomm firmware drivers" config QCOM_SCM + select QCOM_TZMEM tristate config QCOM_TZMEM diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c index 520de9b5633a..0d4c028be0c1 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -8,8 +8,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -20,9 +22,11 @@ #include #include #include +#include #include #include "qcom_scm.h" +#include "qcom_tzmem.h" static bool download_mode = IS_ENABLED(CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT); module_param(download_mode, bool, 0); @@ -41,6 +45,8 @@ struct qcom_scm { int scm_vote_count; u64 dload_mode_addr; + + struct qcom_tzmem_pool *mempool; }; struct qcom_scm_current_perm_info { @@ -1887,6 +1893,16 @@ static int qcom_scm_probe(struct platform_device *pdev) if (of_property_read_bool(pdev->dev.of_node, "qcom,sdi-enabled")) qcom_scm_disable_sdi(); + ret = qcom_tzmem_enable(__scm->dev); + if (ret) + return dev_err_probe(__scm->dev, ret, + "Failed to enable the TrustZone memory allocator\n"); + + __scm->mempool = devm_qcom_tzmem_pool_new(__scm->dev, SZ_256K); + if (IS_ERR(__scm->mempool)) + return dev_err_probe(__scm->dev, PTR_ERR(__scm->mempool), + "Failed to create the SCM memory pool\n"); + /* * Initialize the QSEECOM interface. * -- 2.39.2