From patchwork Mon Oct 9 15:34:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13413932 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 CD79FE95A9E for ; Mon, 9 Oct 2023 15:35:27 +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=guLAM1rjmBUtLO WJ7QsjajZCFn8xgbsvXYaFKMC2CaAg3ZUjPy+7bjgapGQfVNsST2OHW5OSm3V3gCKkxEPGgPaVN0p CKjQQgm53JTs/+AJc+TU3vq7htAB7rKfXYPLmuTe0lGpewc1HRIvUq1Ei3tCBeNxKAWDKNHHih8F/ uVabC2hDbjMwolLs1rblZ6OraDv86L6B/v9di2A6GBFUFYkfsrc06nL8x0HvjC6j8B+txbS0J8eyH VmZ0XvFZh/bTmU2VDHU/QOlyyJqDPuG8zzCB1K7S+rrcNn0SeTqYbovv2IsG20CsFXk4LM3u9AE+o qicMhdpMQE0BtW/YblBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHd-00B46a-2u; Mon, 09 Oct 2023 15:35:01 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHQ-00B3xJ-32 for linux-arm-kernel@lists.infradead.org; Mon, 09 Oct 2023 15:34:52 +0000 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-313e742a787so2778477f8f.1 for ; Mon, 09 Oct 2023 08:34:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1696865686; x=1697470486; 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=NCzgUHfFCxfG4ND3tV61siZPFN9asVYuVK3kxcl/tojK7/MxqDAuBAxXKglRMyCY4h xfFrMw83XitjCIKSqZrWVRZyPuT0H7tR8KfaON1bcFALmsCHF8plqLvZnk4YELGXcZNG BLJ1V0R4L2xgcgxg7goSe0gwiAR7NlkrYBN0wtzgcle3H/v3tdwX0VI2s8sJ+oNdv0Tp DbTr2uT5IR6pMP2Ply9jefIy5DqnJxeWRx6WqDSDc9j6dXhIdyxHYt45Ce9hnAPc442i +ykSoUObYNdtGFHRumboNJjLDgueKCMfmiXpReFYm1jT/EK7ngYb+j1RbRQ/KET6cFxL e59A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696865686; x=1697470486; 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=B0LCJP9QYSz1BP8t/o67o6SzsvZLHWn2/C/s7g8UrN64MpgkintoI3k3azdlxI+a4K NAub75HF61Sucuwe+5nxLrIM6l/EbrDkBAH7jIEPYIshIrgrKWXdd+A4trmHDs/4HOEg RYMl12CblW5D86p14ZuWI6rzmkLQgK6BzisjB1Sj6ELCNuLGCeXpPvCBPSzSPc4QKA4M dVTWb1Dm2uJn3jNTqRSe3vtSHE7nWRhzt1YXlf1ONLfQjSOhm0vPuprWIvBeDf8qUUw9 SbHulfISZvAB4Po/9PMtrH6Z9MYFnbpj3X38FYxTHrdpWWJkPK+i/uVvlL+ppp6nk08L il0g== X-Gm-Message-State: AOJu0Yx7Qy2FLgWwK+qudqzpfXo/m9kkuEIbtDL4XqAZNZ5HUjUuywYD 4Z8hVCu+PvVYqFTp+mvRO3Ac5Q== X-Google-Smtp-Source: AGHT+IE+HfAWUS8EXGsF6LOscm1uEzgc8ZH16XyVcqAUjQDAcQSh1QPeM3HmQfHBXNvqVn6joVLStQ== X-Received: by 2002:a5d:428b:0:b0:323:3b45:c452 with SMTP id k11-20020a5d428b000000b003233b45c452mr9526845wrq.14.1696865685819; Mon, 09 Oct 2023 08:34:45 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:f20d:2959:7545:e99f]) by smtp.gmail.com with ESMTPSA id b3-20020adff243000000b0031431fb40fasm10016521wrp.89.2023.10.09.08.34.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:34:45 -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 v3 05/15] firmware: qcom: scm: enable the TZ mem allocator Date: Mon, 9 Oct 2023 17:34:17 +0200 Message-Id: <20231009153427.20951-6-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231009153427.20951-1-brgl@bgdev.pl> References: <20231009153427.20951-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231009_083448_986352_81FCCD0D X-CRM114-Status: GOOD ( 14.56 ) 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 --- 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. *