Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3087667rdh; Mon, 27 Nov 2023 06:19:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IEGtWeQ9JwFZnwMiEo3W3qAJDJM9wG8qqIdh3CL/zoJvR0jMjZGoXRfNrGInghlITVOgMxY X-Received: by 2002:a17:903:22c1:b0:1cf:9902:66c5 with SMTP id y1-20020a17090322c100b001cf990266c5mr14855904plg.36.1701094774088; Mon, 27 Nov 2023 06:19:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701094774; cv=none; d=google.com; s=arc-20160816; b=v1xPxkiBj6iCM8KYGNPGAC5E4t1pxMbkbBHLqjcmQUzYM15h289vQehLT8AoIUN5YH f1wBxjnFrlWmQNJ62lc0ba5Sv/zC6mbKl6hLBJGnGXQc2Mu0t4lfpKxc0EoddT1YMzF3 2X6UDfb2LPLWN6a8Vo7Jxth8W5sma93YJbDwZuROXviZyKpYD62vnu8F/RQ9dySgYB6x W5dabDekVuqWwzOwrm8bcfIRca20TyDU7zb38kL8yG7NeV9HkdSXae/j87HeBrDjd5eN Ajf9/pQKB42LnbmNRh/qcEZCnIjZhqoWRcLFvKWjefc51UUGt8RSxsMZAEvPHRSr9R7p 5Xtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dkEfLIdUazWHVoS/f6N40pGJ+r4HD9QT8ToB//6WjKI=; fh=lirm1ccAeXZZB1cIo+N1DqklpgcFmD/vJ7PCWNIL0HU=; b=GYuHVQC8+GEOdaQSs781Fp5fuc2HRsqUTsPkiZ4RgJbJ1aBVJtWs0kGRDIbCVUG602 A9+myFbb3DyfZH4+AINbyCBkn1RsVLdOpj2ZJaehhUeh28sj/qo1KhiQrfM4AB7CZ0FD 46ChPhZSd8uWusdMJMo7jlz5Oe+AgqgzgwTKEsr9iqd3PScR1/rjq24T9eNanrroS6d/ YHqgzILnW+APuKeEGJq9KT0YSwVl1EQSjyM0G9JNsVBZXq5JQxNjyi12m2LxzD1m3xNj tN3JuthXpghhVhY6hWn4ROAylQaamHOlt9+eI3jFAY9RxR61yb0RlX7jfVTPJuDW49Y0 6h9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=LSYcZMTC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id f4-20020a170902ce8400b001cdf9442d20si5218965plg.336.2023.11.27.06.19.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:19:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=LSYcZMTC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 1C8D3809FC91; Mon, 27 Nov 2023 06:19:33 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233784AbjK0OTM (ORCPT + 99 others); Mon, 27 Nov 2023 09:19:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233633AbjK0OSo (ORCPT ); Mon, 27 Nov 2023 09:18:44 -0500 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFE9D3AA9 for ; Mon, 27 Nov 2023 06:16:14 -0800 (PST) Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-50ba75e33f3so3224874e87.2 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=vger.kernel.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=LSYcZMTCNaRrj6L8z+aF/OKYEJbWcexUWhK33Q8zuPPp4wq/acijnx4yWpBpTT5W0n d9WibDy97tueE2jy+oTHhkVe7tDy1us9e3zNTuOG+nDtVhA5LT+/Z1y6d4jerxdcjyS8 H74OEwqhtU1oTD83lYTOiXKOd4h4AYlQBS5L1cdPSkqJxOGYN8trK5c/7WSR78mywwx7 vAJwut24mh/o1+vbYjYkqlS9DuZVrHSxYpuEDHu+126rCDz1gTELP5EbJRMOEd2tN5q2 6LXsUg98mYzBMyfRoQh9sOPgovA1F22KiE2Wv8eEGePsnLMOPlQusY5r48m+VzleuzGj goMw== 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=BdoGasG4RU3Y9/3x9Penvqr8P8Ok/K/I4VJhVfq9VONZKJfO+d3e7BiEEH14cqRQB6 VssX1FFoDYN+j5DxUcvF6X3IJ1/61MYfLxcw+Vlqos+ootgNMyHBUN/TvQf9xRCvcMBw LwyThoy6zLwISGYH6AKmIW03MOkWRu1BHXDm1gI4XN6gX0yRfL2Kz8+viiiomZcwZxzQ KlqRZkMUOhSJVRRhbPeMnxyu/mIxIPu2qfr9vwSYOXjk45c1+DSOCDNNu1nhzXmgjjWL d9VOy/23r3x3MKYEykZGXzEQ1bq83CeXNySbJfXjKF/mehj0VWRd3djGWsMUtPN/Mafz r3jQ== X-Gm-Message-State: AOJu0YxQUxDN33Txjj+MN5vee6y9PAszY/jkC5wvKEJXcQHJXC6oEcLG tQdwZJa0sMcOUCezkZVxfLeFTw== 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 27 Nov 2023 06:19:33 -0800 (PST) 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. * -- 2.40.1