From patchwork Mon Feb 5 18:28:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13546016 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 9FF4CC48297 for ; Mon, 5 Feb 2024 18:28:38 +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=lcXKlH/doeZ0uTcg7HzemPOTjdVbVDm2LuO8s2YSRgA=; b=OqO7YFcLTGNyvE iQ1esrajXcrYSkMBn42NjXSSFSqnnnVcosJ6cqoQPUcFX2vwidagLgQbeOej6L2Y+VNfg7NgeHe/g PGn2GdDbar5s2TDSpuc7c/ihER0Z3mKrvoXRRvhosKPeGoQCipC1hBa4uPOVAIVT9nmC1DEFxfauS 0Lv2u9noToakZSnwvZauBHCF1fvLCxKcNUQ2tx+DKH60OBgCJ//EQkb8MaUCrxSTWxFEUBmluuv0G hSclPPGX8TmtX7oRDKDRILXNmloBgqKrlpJVglkRmFKqZyvpQwByxd7Gqjy8z0c+0SAQSohlQhdh2 GPYoTStV0o3xquKfBqtg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rX3hl-00000004MsT-15tA; Mon, 05 Feb 2024 18:28:29 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rX3hf-00000004Mof-2i08 for linux-arm-kernel@lists.infradead.org; Mon, 05 Feb 2024 18:28:25 +0000 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-33b0f36b808so3076911f8f.3 for ; Mon, 05 Feb 2024 10:28:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1707157702; x=1707762502; 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=yEj/dNYHLTAVVx1z4vuCfUrAofiAmwzp/9dgycGoE2E=; b=pOc89+0618PpnWigh9N08mWYsZsVs5VAS1w2uDVUqLJrg2WVRlbjveZ00Lz/zourSm taj7oOxxoYGfp+Fl3jMLMGXx5xZtyQrAZxVuPAeQEElOBCGtfILhsCJMlu7tfqgFFNfJ YLXLuz/S4YQfr9eMbA1cbvrU9SHCYhGV+JGCH9Vka3CxNdkBxdh40+YJ3oH2Zh7dfATn GjaDFBryMc7D2ydctpvdf5PHT3KZmvJ3ZEEDhr3EOSqXkVssNEdT3jmCa4ObJV+V36bk abdLVbPhMQkquo08yWvkW9w0hol1v3agk5xHQCNLCYBvfz65x3SJHuqxslx7Ys2XfqzI FPpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707157702; x=1707762502; 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=yEj/dNYHLTAVVx1z4vuCfUrAofiAmwzp/9dgycGoE2E=; b=MM9ckoEi88jloY7Gc0t2Yvei/lvRsnbL12PUhfxwwJIIAkIkzo3Jy28q0pfujyvmsu nloyyDX8WjvvdCpxJdufD6bz9afTRBRKF/LDjYMcawLeNILsTLQAPDh1g0OcgmLG4PhJ jezdC2gjgYLxm/UNIO6bly5d5U5Qjdhq7RM9p5aywZ9ncTv3/aBjKrF0ynpiLdstW4W+ 7FndAkN8FQ3aas+g9vDsuHgN63Upe1E5jFzNQtv3Fg7Mek56sK8uL4jASsz5MXv35pjf aBDJVamDTw9QRgzKYkSxznqRn/yz08Sf4X2rqjMUp0GAHNy+hBD6zOP6jcGxCtqnJp+A OHRA== X-Gm-Message-State: AOJu0YxxFCTVIjd7JwzXcxyXiALWSq2c+yyu8aIf57hwApFlJuuG5/9+ f4PwzW1nu3NZ18KO3+ksNmOe7jC/6jwMgVz8LDSvrTVNuJTljyDdGNPxVRJ7NMg= X-Google-Smtp-Source: AGHT+IEhRf/Nq70YfOTrEL0Ga/uegesRWr0w2slR5DVCq7BJ+6JlbySRSoBMwByr+5DcIPQnXJ4VeA== X-Received: by 2002:adf:a112:0:b0:33b:15fc:22c1 with SMTP id o18-20020adfa112000000b0033b15fc22c1mr271098wro.52.1707157701997; Mon, 05 Feb 2024 10:28:21 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCW/9WEP5RMyqyIoyiK3EYuSmo/OO7XiMrIADASEM48FGfWG76Ej9QS0/h/WB9eKfaUo4LTV04U38ij7kayZPtYlYdJStuPF9xrxBpPbRKNhOuRiNZ31hX/hvVA8qvBxmGmJWcXbAsFpICmLQgpV/QUccyZ2ObTQZcRIhhDgnRUfLVr5MtblFMmkInHMmXLpm65WgCwFBAB4BxoxQWE58HWTL9gZy4r0phfFgIL4pzF02ntmJdlzClUNpmhhb1/CdugDGekPY6B3ihBZQO+ToMxR5/73R30tQCr4zGEZ7kju6gY6nCTTBGZ3oZTVaKGQib4n9LffW33GOeE6GHDLxuTI5sIdamxWYfhEe3He7dK7mgsdfRPvvViBySp8l3c+nKhksfSShfUxLeTGy+dXcT/7rbC/dnYWv9BzQ8RfvHSdhLxwwRZT7JdFHFHUOxyAY8QFYs/iGedj6UAXerG8OFKad5cAXC5ikYPiDObMzJFnkgB18n41nZKXVd/0lufl/VfCOcmeIjIALR/Hg69nFa4wirfjL+S9VtsL6X0sBiv3jCUEtAoGuUpVxVOQBlwNrxY= Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:d929:10db:5b5c:b49d]) by smtp.gmail.com with ESMTPSA id v15-20020a5d678f000000b0033b17e18df8sm203229wru.12.2024.02.05.10.28.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 10:28: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 , Arnd Bergmann Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Bartosz Golaszewski , Deepti Jaggi Subject: [PATCH v7 02/12] firmware: qcom: scm: enable the TZ mem allocator Date: Mon, 5 Feb 2024 19:28:00 +0100 Message-Id: <20240205182810.58382-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240205182810.58382-1-brgl@bgdev.pl> References: <20240205182810.58382-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240205_102823_718298_812050B8 X-CRM114-Status: GOOD ( 14.35 ) 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 Tested-by: Andrew Halaney # sc8280xp-lenovo-thinkpad-x13s Tested-by: Deepti Jaggi #sa8775p-ride Reviewed-by: Elliot Berman --- 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 f18686edf415..d24d83223867 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. *