From patchwork Fri Oct 13 11:48:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13420783 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 2CC8DCDB47E for ; Fri, 13 Oct 2023 11:49:33 +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=HtaTP9npj6DLk1uPnBkkLlp6oHBoajtWw7q5mEHT4RM=; b=ecvo8lmpj0V8Na uVGH7HepmQpQcZlUF8tEwH6kgBrNb7vUKSTjXSxH/LirjaBYZyrax1RdQMLqEEyCScyYujvyIvQQC sA1lWsnMgrAsajGl4QRdfookpI2SIMj581zB4dgrtt5127abypeiVSFOw3g7CgQwHSgsC9kIdMVem 5GH4StBtGD31WkWpJE7ckvxUx4RIAiAh+ux7hFeaX9Ed6NKU0DAS2ILDRBhuoLsIiTcipDWdM7EUi Vqtm+8cX6wt0b7AaJ50xDPOdNL9WUadoUSivUKzQW2uTMwnGX/XGjC2JVm9ZN5sOtlW2oIjpWzHa5 +kpCfxL7dXPPpDQwfqOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfE-003LYA-2J; Fri, 13 Oct 2023 11:49:08 +0000 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qrGf8-003LQx-1F for linux-arm-kernel@lists.infradead.org; Fri, 13 Oct 2023 11:49:03 +0000 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2c1886777d9so24280421fa.0 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=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=GC/5cw5j4gsHJ9iomK+6pv+kPUVJjLbCpiT9I+Feyy0=; b=psLaMmmynul6cdO7LuEi2ZX+E621vBPcrAkIol2ExF5Dq4R3qkBt7X0y3Fi21dS+3E roxjejwVtmyFqJoSloJOOj9xCESSBKGRpsGkomzNeGFs5cMo+UdWlCM928TWpNrJhkoE AqJJH88WmbWHJV9oTTjKpK9Yu8X1Y8m/icVaxb/tDR4Vzlda9/AtQtXfOpanIW+YKmLo wgK1gZLIg5vNAfiZnUeS/+bLQFFFlUO+qV/7/xzz81GyErdl9HuPd5Qgx10MkAazQcIs /+659dVLKxIp17kLSbru5pNxao4VwZ32BYpjzz3xLUOjDj/vETbzj/J41VpZFM5U+659 2ZNQ== 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=CLsJ6sSvQMYPfRXRnZfriH+lgFaggtSPPTv6oPUgGieRw83E4WWbWp+Q22TBMdGQdf VqgiO2gp5FEVhwRvLBdERnGU0ucjlmdZQa0UjEuFb3WGDPcs4gGQyYNTMIqrdi6DzYSW vgeng4H2gxp0wK3uH1D9zzmeqqLqgy65Fo/7h0RLFLvS2pJLTZ6jMBCjMX2nHF1UOUK2 l5et5GmPzcfJfdzi/toVn/jxEN7jV/lDNIADvvZP5FkCMC8Zn3bnEnS5YP1U0yDk1pQ+ see5hOYIvv/+yfQGfMoU8r4p7Z+YMlS4aPw11ojuO06fzmo74KBTOXlm/bpPiOvPGzqV mwTA== X-Gm-Message-State: AOJu0YyMiDEru5FMKhVpOWXtWzyWbG6dObC5Hbk7wCT9daFYCLGOfL4X gBUCApwFPrzk6OT818KGl4gXAQ== X-Google-Smtp-Source: AGHT+IFz8Qjgh/yQazbBJwPfv7OkJ25O7SaDUN71bdEi70FN1CMs28cCOIXQdSvGfas+S8HkijPLcA== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231013_044902_423622_BB8CFF4E X-CRM114-Status: GOOD ( 14.26 ) 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 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 Reviewed-by: Andrew Halaney --- 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. *