Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2539409rdb; Wed, 21 Feb 2024 10:39:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV2oDfkGod5bYNu4huEXnzfEC2CYofHz2qBNtu0kLZeJ2BdvlXQYwDqtKvaUBvHRRHykWNA+E7mugQlFk418dhGvCq2of/tpZO8VZuHIQ== X-Google-Smtp-Source: AGHT+IH+rGy/tL7vbcYEeZM/V95biPx+b3Zrt4gTWzkR0OWMtyFONDGYCWlaulQNbXTKB9Hfd9/I X-Received: by 2002:a17:906:b354:b0:a3e:d128:673f with SMTP id cd20-20020a170906b35400b00a3ed128673fmr6901637ejb.2.1708540788300; Wed, 21 Feb 2024 10:39:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708540788; cv=pass; d=google.com; s=arc-20160816; b=ShGVHU+pPu5IU4feMG1eq0BNP/AW8g1t6CNPO1e33xJoKxCUmLAine92S7693OIfiA B+0eAQm+axY88AjiG1Y+XH9GI67LpVMGa1i92AQnWgtbXncboOg30bNJSmiXqKfiT3YW j2ozYtUmakkNT3nYbwnWzyKfjNcDUhjRHSKzoaAUiV8We2EeBKcf6mxSK8VZTNyGg7q9 xqVDHLkJb/rUsOVttjrKaqaewTay3JyDGBSmvEI+rTrW1/kzsTEuRSs5MC9EyHhI5GLI YXAROpVWzszuSvkShuan/nJIh9GpoaM8ZEU3fnOWskcrdkFKtS7KfLA0yHTfZbSoqzdz z5wA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=lr4IUMnYmNnkEtsozLmsyunjWbfVFxd6vy9GXcYNIEQ=; fh=Licw5DcKSEP37nDLLsNGGuUc+LybZz5QfMg16LsMvT8=; b=MWmU7+y0Ux2o+Kq/KQO5WAw5KDcsijCsPMdpAdUApqxRgQ92pBMpLa2mN46pEs+doD KEqBYZJf8VeOhku90W7fYMwlJJ6zS4OIBok4E1+Kl8HI8IwaV1RUeGZFPm5iXpz6aBdV a0YxUS5Q/Sx0AuiY3QzZOP8Tq4PUUO/lNfRb1BnCBzRSbHBVF1T51amuymzlsBeEh4ME f9ZVx4Xvloiez4admvdTLRQ+ErMxS9yWryjRVJ30Uc5HpTwc6fb6EHQnpoMxCk1rw2J9 C48P/KiRp5RPncecBkUIdk+u4H7Mjg4vAqq8Nq15br/+dsU9fSvi5Za6uoDbT4oCUyqP JhVw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=r8oIrkJy; arc=pass (i=1 dkim=pass dkdomain=bgdev-pl.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-75320-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75320-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a17-20020a17090680d100b00a3ee027e9c7si2136222ejx.336.2024.02.21.10.39.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 10:39:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75320-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=r8oIrkJy; arc=pass (i=1 dkim=pass dkdomain=bgdev-pl.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-75320-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75320-linux.lists.archive=gmail.com@vger.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 CC2421F2768B for ; Wed, 21 Feb 2024 18:39:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 599D58593B; Wed, 21 Feb 2024 18:39:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="r8oIrkJy" Received: from mail-vs1-f50.google.com (mail-vs1-f50.google.com [209.85.217.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73EBC82D97 for ; Wed, 21 Feb 2024 18:39:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708540774; cv=none; b=W5f/hA3C9IC6S7pt4aZNO7iZQlvqVRjf1sS0tLWRzp2kYeCDfdxhjYUR6JhkSaQ8n4B1c7XYpsn/hSYsJSZw+5h2Xkm666+hiDRPT3N7tyF63i9YMtp+AeemVbKKbnko9lpzjmLHFozVVg2y+EOEKQQK9v1qkk9/Uesw6WuOOdw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708540774; c=relaxed/simple; bh=ltCLerzsny1Mf/3etibB5mXyU8baMLxo3QojaxcO5q0=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=BPin1Hwtlx0mixiQdpR8XQGPOwo/cCG4VU8JyaiQFquDFGaMhqzDBOHOn/02seMtsygVlIp6YWRx0mbHt1yH/xtQqLBIDQA27wNHEeX0iiJcE39vxxGFBFmcpyMvULh1z3J3uc4SEVb01YQhwlhtr5ougVjUI/qbtW/BP4gPigs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=r8oIrkJy; arc=none smtp.client-ip=209.85.217.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Received: by mail-vs1-f50.google.com with SMTP id ada2fe7eead31-47050fd33f5so562499137.1 for ; Wed, 21 Feb 2024 10:39:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1708540770; x=1709145570; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=lr4IUMnYmNnkEtsozLmsyunjWbfVFxd6vy9GXcYNIEQ=; b=r8oIrkJyHaWr8XhJLfEQPt8izKBGUM6LFUa8XbPVZT0v77+KMhB47wg+Go9i0wz0Bc HTOAKv6agbZHZh5bwKY1nDe6lfNoVPwgmrWvUEJUWy75Tp1cJAV8m9UYyOp4ZCzvY19C 9LXHI3Z+iYtg9xqcQrW3OHd28m+CokM/CZT585Cl3Mu7JopChb+6N128tyaYN1iVnW5O wMSIQW2zoUGSS9G+It/q+F9MzVnvfdg4GHwDr9BPV7UySBUDqdSXwAc/MboElL5e2iGs fmQfhLd8wYXP3QNcs3+Hd23rmZ4UMpsl0oMu5Bao4EO17RwiGJ2KlE0XYh6qu/3XOdXs 98wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708540770; x=1709145570; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lr4IUMnYmNnkEtsozLmsyunjWbfVFxd6vy9GXcYNIEQ=; b=uYnKMe+4TvkM92MFB+QpSJ76GAsCXbR0lhkGVgj3WukA0p6yCLeNMpnPKQpSjrZWDF wvlSGTIsgBHN0BGc2/tvPIa0NkrW6+ew0b1Uiv6o3DS1hvvnlG1VOgFgP8EP6bJ8Bmow SWN1ILprRFjHzXXR/hgnfDL6lRV9Fxo5ciiGaS1ff0X2ZZ2JDLAWMIjKXQ1KpJmbWV7l ax0EP6W4R96FZ8ztmgqQxW0uTKwT8zLngZjosaS+7EJngfB8G/FOIx/VyFiUKOKO99HP xeq5yUfUrJ7XDc6051h09QaOcgL+7yqF2U5w6drWAdVfYfbU2q0gvHRY6Bra3baQMSUk iHZA== X-Forwarded-Encrypted: i=1; AJvYcCXc4ftFX8U+pAYHdJKLfdxqPOVlOQTZF5r/eyMLoSKxBTS5Zh9AsVM58sBVfgp2vlQiaXVBmYZJ8/zpisq1seFAATxeR/QwXAbTVSVz X-Gm-Message-State: AOJu0YzkHYCxBOcCVhcGA6kGuC65ptcOZQSDpzoRFnEZzBgPt4fxjVsK Cqmgk+EvQO1SMsZEk5AHMjlSx4R4SCmjDvPTD/EyrFt34mYL8J7P8TdOU7VQw7q3hvhHp2KKZkm ucICD8BlGm6pCwYNngS8HAsoPWP+sGm+OkuXhPw== X-Received: by 2002:a67:e8cf:0:b0:470:4744:704a with SMTP id y15-20020a67e8cf000000b004704744704amr6823220vsn.9.1708540770337; Wed, 21 Feb 2024 10:39:30 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240205182810.58382-1-brgl@bgdev.pl> <20240205182810.58382-3-brgl@bgdev.pl> In-Reply-To: From: Bartosz Golaszewski Date: Wed, 21 Feb 2024 19:39:19 +0100 Message-ID: Subject: Re: [PATCH v7 02/12] firmware: qcom: scm: enable the TZ mem allocator To: Bjorn Andersson 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Feb 18, 2024 at 4:25=E2=80=AFAM Bjorn Andersson wrote: > > 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-think= pad-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/Kcon= fig > > 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/q= com_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 =3D 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 =3D qcom_tzmem_enable(__scm->dev); > > + if (ret) > > + return dev_err_probe(__scm->dev, ret, > > + "Failed to enable the TrustZone memo= ry allocator\n"); > > + > > + __scm->mempool =3D 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?". > If you worry about these pools being taken out of the total memory and prefer to have a way to avoid it, I was thinking about another build-time mode for the allocator - one where there's no pool but it just allocates chunks using dma_alloc_coherent() like before and pool size is ignored. Does it sound good? Bart > Regards, > Bjorn > > > + if (IS_ERR(__scm->mempool)) > > + return dev_err_probe(__scm->dev, PTR_ERR(__scm->mempool), > > + "Failed to create the SCM memory poo= l\n"); > > + > > /* > > * Initialize the QSEECOM interface. > > * > > -- > > 2.40.1 > >