From patchwork Mon Nov 27 14:15:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13469716 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 EDE25C07D59 for ; Mon, 27 Nov 2023 14:17:01 +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=HBKuKnls15oM7x0HGtTWwKAbOR+7jJJz5spYWYrGCZ4=; b=L8Q51JkSHIwepz 7+coQbqVLUI1K6rE3636QSZU5U+/WGHpndWzWythN6SDYGouJleQUNzQJEbIeCYmKV9NFbfTJrK1e 2uGUqeUKQwCNRGvNeTiW6aHwYoH2H3xeJ4KXRXjjqU+RJr4H4nRIQrGxKlg32gvMnxPy3qXyLdl8b A9rHhEjFS3jQ4yn2vu7f/OCPeLzSff7zCAvSjUeqdGbwJM1shEzyxXWLkXKt1zbNo54YZSEdvFZW9 rpv5EDSkROhwRg5x5o5Pdva1vxNJlgAn0BSdhq/3MSUk1YSlKqgN0z8bj+vN7UD18nW2AkcoH8GAi B72RrAh+ODA1qfa2OZNA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r7cPN-002fKd-2g; Mon, 27 Nov 2023 14:16:21 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r7cPK-002fHl-0Z for linux-arm-kernel@lists.infradead.org; Mon, 27 Nov 2023 14:16:20 +0000 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-507be298d2aso5786630e87.1 for ; Mon, 27 Nov 2023 06:16:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701094573; x=1701699373; 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=dkEfLIdUazWHVoS/f6N40pGJ+r4HD9QT8ToB//6WjKI=; b=bmkSbkkkTay38HHBgijS7xoYvsl8r0wNmtr28b2KMC3JqbItJ/vg8GBtpduImNn+mn 4b1e8tY4rnNlnzF621/EzWZ/hVgD+5arnz+Pz6whgOy1xONA7sig1EC1n9CtdRcqtzE5 0L3XyUJTkNdwf3F1mTA1pdFTa0uZ7iWQQOAImf/VvkRXTTavi47zk7JmfY8mtIa2zQx5 mUxEFY/fRaVHQSbMDvmeUpVS3yRucLQuC/rkWg6QTyjBMsMhQkJqZXig+ep3MJNI3h0P h0GaSBSqZrdAgLp9IaoRSq8+HoaDuehfFMoCtKkGXFh9MOmUB1aMZO/0I4tYbLou6+eD gLcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701094573; x=1701699373; 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=dkEfLIdUazWHVoS/f6N40pGJ+r4HD9QT8ToB//6WjKI=; b=V7n+d5i1vf9nr+Qcdod0fblkc7VyesOeEX1MBeXVAAFVcUlqQ7cI7pTiuNqniOBt8A mS0VTbt8d+edJoFwJyqRSZymOBwjCV5vOjqMAxayPtab4FfjB75m9h4A72cOvD+ywBUh n1fcrv/ATQBmWkqxavdCDELhy0sjXk+ZRNklMWbG5XPYpm6/Qz1Pz82S4TYlZPeLdvYC bRdxglVgoewR1Wlh+hQtAUKAMPPGeZ4+ob1HMgrt4CqY+CXz2ukpKtugp3SPkQVw6Odr y/lXuasud/HtsNLn0D8ZYFt1N5YgRlT1QFZu3sgAhNs5tM4prjuLBvEvfvBe+OBiZzJV svpA== X-Gm-Message-State: AOJu0YxrhSfsZh7RuM+BHeBmOtmv/4AQ3pCFudE4V6YwTYSdUHaCx5m+ oSO1joe9Clib4jSJ1gCvULNR9w== X-Google-Smtp-Source: AGHT+IHu7l09DTCJJuDJ288P8P+c4aWNjuqsJh1cEjuw9t082HlZXCAWJIkZM5tGipzeUI3odwZCeg== X-Received: by 2002:a05:6512:239e:b0:50a:763f:ecf1 with SMTP id c30-20020a056512239e00b0050a763fecf1mr10914778lfv.12.1701094572678; Mon, 27 Nov 2023 06:16:12 -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.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:16:11 -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 03/13] firmware: qcom: scm: enable the TZ mem allocator Date: Mon, 27 Nov 2023 15:15:50 +0100 Message-Id: <20231127141600.20929-4-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_061618_396336_2FA62C7E 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 --- 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. *