Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp481224rdb; Sat, 17 Feb 2024 19:25:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXiC0L2rvOC1DPnWi2Zwwh1gHAg0WWJw2zmCVIi/JgEj/a3yIEIbBn9WsD6u70R7cYOqkZECaUk/gI0mTScsG5aqTxkqL2sWNYYPWvzNA== X-Google-Smtp-Source: AGHT+IGbeZBcftvrZFiSyYbvEfrQ3JS4cwpx3araFwr3lyjNu5lhgsKFz7NdxFqb189USDi8L5+L X-Received: by 2002:a17:906:bc8d:b0:a3e:6628:f70f with SMTP id lv13-20020a170906bc8d00b00a3e6628f70fmr338496ejb.55.1708226725484; Sat, 17 Feb 2024 19:25:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708226725; cv=pass; d=google.com; s=arc-20160816; b=wLJClXTDIV86vtxexLDRY/itZMn+lLtqV613wQ7CVk8pNoVca+hqcRuHJamzbsv7x3 iQEZqa4pE28RZrnJ/WBbns9RAZONvxTc/reudzWWk6/3xPR2j1I1lWsBkBKsB8QLYTUv 8dFBXxzfeubJkjCyCvAIiCWJhsd36jXPjCU23b4xx9wQRKJpyMLa8mATUk3tB2vt9cSy pwWKGR1uisktr6T3/0JDrQUFeRgKI+OTeOt+sLJhgFa7G9SjQasiD11soeEyORnXz/wN Z8ogvpkNEqbFiZtJPo0WAeJvOrXTafX/j67QshAwObotK1jmsbdJ4st43eKNCEBo/N2E 1e/Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=L5pytv7rNFT93mQiyUvEHXrf7t4W5P2z3N27RAjEgGM=; fh=LNu0c3gNPK1mYjOca90icpQXFsjqhO0esU5jl/im0Do=; b=QjOiIBPWUeTlBEPSLKJGVSTABgLOuZr5v4C6gjL9FJbEFKodTU4KXDS+oKpvIuqIth kOlgBwEzh+ga7PDkyJGTGz2uCiyfP5otMD1aY7YwhWNvU0Eqdub9weukgvpb3VX3ZOLm SKI5Idyunr0Shdlur51wLvbSmIoB1bS65POHPN6Cs6ijV5MNOJhL2yuixxxJRIqTwvub gYpYyoerjLnlA/qSvfkcbVb0kadnklX9Fas1EUx7t8TAQAlIIoSvhWj+svoeBoFIO3OS 6xiw1sM0tyuG2TYkyM+Yb/1KHjjZXDJgSivOn5LVwf1aYChpCuFuJ8aZNZOlyqXtNH3p IQIw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ryZhzndb; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-70178-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70178-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id e22-20020a170906505600b00a3e356141f9si796450ejk.267.2024.02.17.19.25.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 19:25:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70178-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ryZhzndb; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-70178-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70178-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 13C761F2157D for ; Sun, 18 Feb 2024 03:25:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 926824689; Sun, 18 Feb 2024 03:25:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ryZhzndb" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B697F1848; Sun, 18 Feb 2024 03:25:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708226715; cv=none; b=a9dTIyjeE+DCfqc0aH7EMAOE8ylrRwmw+UyVWD33vYTz8Tx2kSRKQGyYC6HsljiOaN+/dN3QF/5nBAXlt0+C/LmkHbWcL36GO7m+haFn1fpfooJj/q46xQpKpdG6ZwIshB066M4OCodv2Q+DlzN3BYFXlbMwXBgkn12hZ92YN3A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708226715; c=relaxed/simple; bh=mSWLc4sSN134G7gn1rRMq9O57FqrO4Jhs8fU+bv3Rfw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=AMu9f8WFsXR43w2SYo3NgN5A7D/tYT8goMNYCO7zBXpMT4iaGYR4lMA3/Gn+TdfO8Or+hpM+3rJ5hzd6CYDA8KArjUEB0WheTK2C/awbY057EwFhcwCV2J+BocUaLf+CrWuwOdqLH1y1KIClvlODATJVUlp5/5PiMItkPycwEns= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ryZhzndb; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 058EBC433F1; Sun, 18 Feb 2024 03:25:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708226715; bh=mSWLc4sSN134G7gn1rRMq9O57FqrO4Jhs8fU+bv3Rfw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ryZhzndb5eonUXEh55cTcGp11eNSU8/OYbjY0+SakYLYQ8pj1fyKTkrmqKOazqcMN GKBuUQKfakDIb8jXgBmIbAo/nZwUUSrFnnRZDWcQBzUEOvb14QqwdUgxvKXVXDsk3/ WkZhT+YZnzKkOoIsCB9TKop2uZNjGolPIin/D/kW6wy8vM4hIXL4pp2I2JmhYLqIz/ NcLxn5QOKVmFh6tc2SjSwlzJQ0rk4TF73swFMsuGKn9N4KocJQ2h4ntEbfqxSThIon xiN2rFee3/YeLunngIg2QmgecM+xG7HWlsTOGc4ThicoJwNRx+OgxCPtcZXnSYBZFE IkWWRQlJED4SQ== Date: Sat, 17 Feb 2024 21:25:12 -0600 From: Bjorn Andersson To: Bartosz Golaszewski Cc: Andy Gross , Konrad Dybcio , Elliot Berman , Krzysztof Kozlowski , Guru Das Srinagesh , Andrew Halaney , Maximilian Luz , Alex Elder , Srini Kandagatla , Arnd Bergmann , 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: Re: [PATCH v7 02/12] firmware: qcom: scm: enable the TZ mem allocator Message-ID: References: <20240205182810.58382-1-brgl@bgdev.pl> <20240205182810.58382-3-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240205182810.58382-3-brgl@bgdev.pl> On Mon, Feb 05, 2024 at 07:28:00PM +0100, Bartosz Golaszewski wrote: > 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); As we're not moving from the callers freely allocating what they need, to a fixed sized pool of 256kb. Please document why 256kb was choosen, so that we have something to fall back on when someone runs out of this space, or wonders "why not 128kb?". Regards, Bjorn > + 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. > * > -- > 2.40.1 >