From patchwork Mon Jan 22 10:21:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13525118 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 4BB9DC4725D for ; Mon, 22 Jan 2024 10:22:51 +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=ppMm/1c+ugTqXvDz2oVRXwl+yDyud5whBFNqQdr26rI=; b=L4fBkyFo7j6SwL 981Y7MHm42mJQ9e+1m5nZCOMLGf1Rcd7cssGJ7lJ0ygFJ/m+KdYfSRUOA1aveOA1SAdpF2HOk1NXB RH3b/upGq1WZ0mdfFjbd8VsyU5+vitc4ReZjo4DbiYHKnU+H4tGWjgFGUlUUl8V6j5ovF10K144HX eKOhDQoOr25OOc8nvQyeIZ7iiu6du3jPnLZC36aAkN97px3Z5OD+BJvxygKWQGlYjqybqRTXUJqi+ uI7sjmdk4Kb1Dkn1BhGk6gD9MHMb25DXMYjTjBYDxBHSjdxTSt4g0yUsSPZleO7aA6G8cSnrNzvZD yZFpwQ2jLxMm3IVMnUUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rRrRb-00BUZO-0Y; Mon, 22 Jan 2024 10:22:19 +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 1rRrRV-00BUU6-08 for linux-arm-kernel@lists.infradead.org; Mon, 22 Jan 2024 10:22:17 +0000 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3387ef9fc62so2817034f8f.2 for ; Mon, 22 Jan 2024 02:22:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1705918928; x=1706523728; 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=9Xo+3rW2/GniBJfX+Sj7KlIfHlCcTjykgBLMr0N5dgw=; b=v61nrRqjrQ4nNuetcUZVN9D1EPfxWAplHYVDPx3nAFLSuCLkjj8iYYFfc1SJ3YXvwl kpZljW+pz8LVC8W103sjgnAt5V+HeOBEXu+HgMFmY3BSL6UIKRMwtDgH0i06toJvrzhl G0b3MLmwojDBlqRwpEYZu0BZcYWX0z76PTLIo9tC66xta+I9U0FbdJZX7vuf2GB4g7pV bBTb9aCrQZREj4kJm0u5ERgDEWM+A7N6J1Fe5K7biNHltaTm19AVm8h8ZaQB6uieYyqb gdZG4LPR+OcUbKEeBNjIM+8jFO/296T14gobwnvnbSDKXxCQmZXdFYF+0Yp3kTZpCAF4 t8gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705918928; x=1706523728; 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=9Xo+3rW2/GniBJfX+Sj7KlIfHlCcTjykgBLMr0N5dgw=; b=wmsWcIHl4YiQZ0ZLK92QSH1svYsQi1LLiYlaGAEMv9B7LZdks7WEGqpJKfIEsotF0Y x8fUKz54PYsMb/a09jWnKQwvPsBBGWBXsfYWAyGdijLSBZ4W+Y79lqn5wYa50XyeTBYC WotlcHM88X+SeQb1s7AmfetegJD1W4gbItKvWzGGRm+fRYJcuQS/btw35QWhFB7bUcPg X3uKqRbvxQPTgkXp0+AR/9KRmttHOs59n43aHuXyKNZ75lL6Qb2QKkhyhoqz4juzwt9H y0JxMPLRmdMCm5/l+FI14NPtOm5IcglH+7WHY5LxkvVjOW8GnbDIcFbqOL/7ExUo991u jV/A== X-Gm-Message-State: AOJu0YySa+7MF/ypcfV9XAmSc1wgn/zmcaP90lszB26NGXSK8bATeEvX MevfSrRnmlWg99BT68S9EzGeYvrXCnxboMQwPvdkLNRC3afg7k1ck6HXZzcjEGg= X-Google-Smtp-Source: AGHT+IGbvfgWjlKT91yD/2mxr857mszRjDG1tRRSzICku5wC1rFULpFkLCee+kNyE6DMGDeinrJV/g== X-Received: by 2002:a05:6000:11c5:b0:337:d535:2310 with SMTP id i5-20020a05600011c500b00337d5352310mr1672712wrx.139.1705918927723; Mon, 22 Jan 2024 02:22:07 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:92a0:6172:d229:1898]) by smtp.gmail.com with ESMTPSA id q7-20020adffec7000000b0033926505eafsm6377904wrs.32.2024.01.22.02.22.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 02:22:07 -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 , Catalin Marinas , Will Deacon , 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: [RESEND PATCH v6 02/12] firmware: qcom: scm: enable the TZ mem allocator Date: Mon, 22 Jan 2024 11:21:47 +0100 Message-Id: <20240122102157.22761-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240122102157.22761-1-brgl@bgdev.pl> References: <20240122102157.22761-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240122_022213_082357_6B2BD21E X-CRM114-Status: GOOD ( 14.74 ) 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 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. *