From patchwork Mon Oct 9 15:34:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13413926 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 22561E95A9B for ; Mon, 9 Oct 2023 15:35:18 +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=ucNQMWdhkAQAxSAElmwDcuiH1d1UXw3C7/yrJJN0q8g=; b=zD+pOhsGjfi375 T1mFFWoMlyMW+5xlHREcpWHM2clLcTLdFvSf+gFobg7xuPgm1VOB2HuERvyuwe6wZ7vRcD5D7uKV6 RAjxXvdW1kMLzJwN+GHdT5OrrV9R5FGhUOMne59ZbLEyv2Rswrmi0a3uiKrqq5KWhIVE8glwzBQPR +EmwyXz8OuCEWKIdsxbK9+dMVM6+R09/oH90g6aQ+of3JrvR8rrt/T6cZBli/sS550fiTUppPO1Cv LLSkOlxTB+WhLDBrAPF7jvgSL4NZcgGoqoZjYmLUrZ6AQemtIPZjfSdYcTVnihe4VWf6bqxMGk13M lA4cS2ELhtlXFFW4cJSQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHP-00B3xi-1S; Mon, 09 Oct 2023 15:34:47 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHM-00B3wW-0J for linux-arm-kernel@lists.infradead.org; Mon, 09 Oct 2023 15:34:46 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-406618d0992so45664835e9.0 for ; Mon, 09 Oct 2023 08:34:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1696865681; x=1697470481; 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=3JgFvFXMn5Y6xZ4S2gUYlHQTeZ5E3kahjOuIj+D5Dvo=; b=GWN3wpkmEjZJYaaBnUW9rHPds6h6JxNuV4wESGyV1k5gQcGdbdGc4gqB1i71/w6ASB YG2x9ukwmycpTPrIJH0Q3sd7cNMVuIdAW9JD1nTOMnM9wyPxhkPTD/ZCH5XojRB+tHCx jcDUE9+ponxS99fEpV6bGexPr4mlWJZbLxyeUNPOeOzQt1TTau+kQiJeYQ5FMEbyS59+ iziT+ecJRuXn3FKf00OE1QJLyO1Ets4U5Ub65Uem25t3CY6TsEQ7HBHxpElHqcocLEB0 IRAod2TdHGICIqBBlYA3o8vCXSSKPFjVY2t/sRUe5MztKiZBlPk/WzhM2jOK0u4dTZI0 SJSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696865681; x=1697470481; 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=3JgFvFXMn5Y6xZ4S2gUYlHQTeZ5E3kahjOuIj+D5Dvo=; b=upt5BQJmGDan5iHLeqyVCsBB3HJ9EYJNGcTAr9eMESiHNeItYzDlSXnu6a2jf+nzkn n9HLHLX+2B7z4H+f1WR2YdI4bR13G0LpvxYAIKuKB1Oog9wSaVxAMl0IA+hAXTDfPZSZ kKFOM4TMWPC8K9NjPU+BwWjP8zb83hYxqqOglQgGnKlfKbY3yU9UT9ZtNWXhOI1zRhwJ GvSPX29ixvxh2zaYdRyq9tD1Gh7y7rsEhnlJMjmUiacAYv213/ufQCA4KglXj32F7nHO kCeaaCRehMangY7Bc/R8whTVwdd6QK3Um8LagHpkzjSi0eXRQzOOYYzocr+IUeLhrNLW X3bQ== X-Gm-Message-State: AOJu0YxgzS1ypk/86HNuE7vRbTCJUxFWMGFSc2HSJNQgt91M2sbsZ69O LrSdB5OkomrE3eY/Id9qxvWbHQ== X-Google-Smtp-Source: AGHT+IEqi4677J4pAGP0xKAYVO8OCleif7+alJ1NmS0aO/nzLWnEnTcYF64a+uAPiUGjLKxHVg/fiQ== X-Received: by 2002:adf:fd12:0:b0:321:4ca9:ee86 with SMTP id e18-20020adffd12000000b003214ca9ee86mr14312384wrr.53.1696865680844; Mon, 09 Oct 2023 08:34:40 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:34:40 -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 01/15] firmware: qcom: move Qualcomm code into its own directory Date: Mon, 9 Oct 2023 17:34:13 +0200 Message-Id: <20231009153427.20951-2-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_083444_355298_A8F732F0 X-CRM114-Status: GOOD ( 22.25 ) 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 We're getting more and more qcom specific .c files in drivers/firmware/ and about to get even more. Create a separate directory for Qualcomm firmware drivers and move existing sources in there. Signed-off-by: Bartosz Golaszewski Acked-by: Elliot Berman Reviewed-by: Krzysztof Kozlowski Reviewed-by: Maximilian Luz --- MAINTAINERS | 4 +- drivers/firmware/Kconfig | 48 +--------------- drivers/firmware/Makefile | 5 +- drivers/firmware/qcom/Kconfig | 56 +++++++++++++++++++ drivers/firmware/qcom/Makefile | 9 +++ drivers/firmware/{ => qcom}/qcom_qseecom.c | 0 .../{ => qcom}/qcom_qseecom_uefisecapp.c | 0 drivers/firmware/{ => qcom}/qcom_scm-legacy.c | 0 drivers/firmware/{ => qcom}/qcom_scm-smc.c | 0 drivers/firmware/{ => qcom}/qcom_scm.c | 0 drivers/firmware/{ => qcom}/qcom_scm.h | 0 11 files changed, 69 insertions(+), 53 deletions(-) create mode 100644 drivers/firmware/qcom/Kconfig create mode 100644 drivers/firmware/qcom/Makefile rename drivers/firmware/{ => qcom}/qcom_qseecom.c (100%) rename drivers/firmware/{ => qcom}/qcom_qseecom_uefisecapp.c (100%) rename drivers/firmware/{ => qcom}/qcom_scm-legacy.c (100%) rename drivers/firmware/{ => qcom}/qcom_scm-smc.c (100%) rename drivers/firmware/{ => qcom}/qcom_scm.c (100%) rename drivers/firmware/{ => qcom}/qcom_scm.h (100%) diff --git a/MAINTAINERS b/MAINTAINERS index c934244acc31..0d032572cce0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -17930,13 +17930,13 @@ QUALCOMM QSEECOM DRIVER M: Maximilian Luz L: linux-arm-msm@vger.kernel.org S: Maintained -F: drivers/firmware/qcom_qseecom.c +F: drivers/firmware/qcom/qcom_qseecom.c QUALCOMM QSEECOM UEFISECAPP DRIVER M: Maximilian Luz L: linux-arm-msm@vger.kernel.org S: Maintained -F: drivers/firmware/qcom_qseecom_uefisecapp.c +F: drivers/firmware/qcom/qcom_qseecom_uefisecapp.c QUALCOMM RMNET DRIVER M: Subash Abhinov Kasiviswanathan diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig index 817e011a8945..74d00b0c83fe 100644 --- a/drivers/firmware/Kconfig +++ b/drivers/firmware/Kconfig @@ -188,53 +188,6 @@ config MTK_ADSP_IPC ADSP exists on some mtk processors. Client might use shared memory to exchange information with ADSP. -config QCOM_SCM - tristate - -config QCOM_SCM_DOWNLOAD_MODE_DEFAULT - bool "Qualcomm download mode enabled by default" - depends on QCOM_SCM - help - A device with "download mode" enabled will upon an unexpected - warm-restart enter a special debug mode that allows the user to - "download" memory content over USB for offline postmortem analysis. - The feature can be enabled/disabled on the kernel command line. - - Say Y here to enable "download mode" by default. - -config QCOM_QSEECOM - bool "Qualcomm QSEECOM interface driver" - depends on QCOM_SCM=y - select AUXILIARY_BUS - help - Various Qualcomm SoCs have a Secure Execution Environment (SEE) running - in the Trust Zone. This module provides an interface to that via the - QSEECOM mechanism, using SCM calls. - - The QSEECOM interface allows, among other things, access to applications - running in the SEE. An example of such an application is 'uefisecapp', - which is required to access UEFI variables on certain systems. If - selected, the interface will also attempt to detect and register client - devices for supported applications. - - Select Y here to enable the QSEECOM interface driver. - -config QCOM_QSEECOM_UEFISECAPP - bool "Qualcomm SEE UEFI Secure App client driver" - depends on QCOM_QSEECOM - depends on EFI - help - Various Qualcomm SoCs do not allow direct access to EFI variables. - Instead, these need to be accessed via the UEFI Secure Application - (uefisecapp), residing in the Secure Execution Environment (SEE). - - This module provides a client driver for uefisecapp, installing efivar - operations to allow the kernel accessing EFI variables, and via that also - provide user-space with access to EFI variables via efivarfs. - - Select Y here to provide access to EFI variables on the aforementioned - platforms. - config SYSFB bool select BOOT_VESA_SUPPORT @@ -320,6 +273,7 @@ source "drivers/firmware/efi/Kconfig" source "drivers/firmware/imx/Kconfig" source "drivers/firmware/meson/Kconfig" source "drivers/firmware/psci/Kconfig" +source "drivers/firmware/qcom/Kconfig" source "drivers/firmware/smccc/Kconfig" source "drivers/firmware/tegra/Kconfig" source "drivers/firmware/xilinx/Kconfig" diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile index cb18fd8882dc..5f9dab82e1a0 100644 --- a/drivers/firmware/Makefile +++ b/drivers/firmware/Makefile @@ -17,10 +17,6 @@ obj-$(CONFIG_FIRMWARE_MEMMAP) += memmap.o obj-$(CONFIG_MTK_ADSP_IPC) += mtk-adsp-ipc.o obj-$(CONFIG_RASPBERRYPI_FIRMWARE) += raspberrypi.o obj-$(CONFIG_FW_CFG_SYSFS) += qemu_fw_cfg.o -obj-$(CONFIG_QCOM_SCM) += qcom-scm.o -qcom-scm-objs += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o -obj-$(CONFIG_QCOM_QSEECOM) += qcom_qseecom.o -obj-$(CONFIG_QCOM_QSEECOM_UEFISECAPP) += qcom_qseecom_uefisecapp.o obj-$(CONFIG_SYSFB) += sysfb.o obj-$(CONFIG_SYSFB_SIMPLEFB) += sysfb_simplefb.o obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o @@ -36,6 +32,7 @@ obj-$(CONFIG_GOOGLE_FIRMWARE) += google/ obj-y += efi/ obj-y += imx/ obj-y += psci/ +obj-y += qcom/ obj-y += smccc/ obj-y += tegra/ obj-y += xilinx/ diff --git a/drivers/firmware/qcom/Kconfig b/drivers/firmware/qcom/Kconfig new file mode 100644 index 000000000000..3f05d9854ddf --- /dev/null +++ b/drivers/firmware/qcom/Kconfig @@ -0,0 +1,56 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# For a description of the syntax of this configuration file, +# see Documentation/kbuild/kconfig-language.rst. +# + +menu "Qualcomm firmware drivers" + +config QCOM_SCM + tristate + +config QCOM_SCM_DOWNLOAD_MODE_DEFAULT + bool "Qualcomm download mode enabled by default" + depends on QCOM_SCM + help + A device with "download mode" enabled will upon an unexpected + warm-restart enter a special debug mode that allows the user to + "download" memory content over USB for offline postmortem analysis. + The feature can be enabled/disabled on the kernel command line. + + Say Y here to enable "download mode" by default. + +config QCOM_QSEECOM + bool "Qualcomm QSEECOM interface driver" + depends on QCOM_SCM=y + select AUXILIARY_BUS + help + Various Qualcomm SoCs have a Secure Execution Environment (SEE) running + in the Trust Zone. This module provides an interface to that via the + QSEECOM mechanism, using SCM calls. + + The QSEECOM interface allows, among other things, access to applications + running in the SEE. An example of such an application is 'uefisecapp', + which is required to access UEFI variables on certain systems. If + selected, the interface will also attempt to detect and register client + devices for supported applications. + + Select Y here to enable the QSEECOM interface driver. + +config QCOM_QSEECOM_UEFISECAPP + bool "Qualcomm SEE UEFI Secure App client driver" + depends on QCOM_QSEECOM + depends on EFI + help + Various Qualcomm SoCs do not allow direct access to EFI variables. + Instead, these need to be accessed via the UEFI Secure Application + (uefisecapp), residing in the Secure Execution Environment (SEE). + + This module provides a client driver for uefisecapp, installing efivar + operations to allow the kernel accessing EFI variables, and via that also + provide user-space with access to EFI variables via efivarfs. + + Select Y here to provide access to EFI variables on the aforementioned + platforms. + +endmenu diff --git a/drivers/firmware/qcom/Makefile b/drivers/firmware/qcom/Makefile new file mode 100644 index 000000000000..c9f12ee8224a --- /dev/null +++ b/drivers/firmware/qcom/Makefile @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for the linux kernel. +# + +obj-$(CONFIG_QCOM_SCM) += qcom-scm.o +qcom-scm-objs += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o +obj-$(CONFIG_QCOM_QSEECOM) += qcom_qseecom.o +obj-$(CONFIG_QCOM_QSEECOM_UEFISECAPP) += qcom_qseecom_uefisecapp.o diff --git a/drivers/firmware/qcom_qseecom.c b/drivers/firmware/qcom/qcom_qseecom.c similarity index 100% rename from drivers/firmware/qcom_qseecom.c rename to drivers/firmware/qcom/qcom_qseecom.c diff --git a/drivers/firmware/qcom_qseecom_uefisecapp.c b/drivers/firmware/qcom/qcom_qseecom_uefisecapp.c similarity index 100% rename from drivers/firmware/qcom_qseecom_uefisecapp.c rename to drivers/firmware/qcom/qcom_qseecom_uefisecapp.c diff --git a/drivers/firmware/qcom_scm-legacy.c b/drivers/firmware/qcom/qcom_scm-legacy.c similarity index 100% rename from drivers/firmware/qcom_scm-legacy.c rename to drivers/firmware/qcom/qcom_scm-legacy.c diff --git a/drivers/firmware/qcom_scm-smc.c b/drivers/firmware/qcom/qcom_scm-smc.c similarity index 100% rename from drivers/firmware/qcom_scm-smc.c rename to drivers/firmware/qcom/qcom_scm-smc.c diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c similarity index 100% rename from drivers/firmware/qcom_scm.c rename to drivers/firmware/qcom/qcom_scm.c diff --git a/drivers/firmware/qcom_scm.h b/drivers/firmware/qcom/qcom_scm.h similarity index 100% rename from drivers/firmware/qcom_scm.h rename to drivers/firmware/qcom/qcom_scm.h From patchwork Mon Oct 9 15:34:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13413929 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 88676E95A9B for ; Mon, 9 Oct 2023 15:35:22 +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=aSD6IUabuzezQ3OjJYjDCmmdRoLuJ6cGOVjoiBI6dIE=; b=ftkUaFDD+oHmh3 qLQC8dTrQkvpHQEqKOjt4X8ukT1TpMW7c5ergZ0V+YgV/xIkmEsQXgpKs5ppxWEPcoNFdBTVc8lcM AxfuuUJZ/lLRMmvuhRBgL9bN4opsjwUs9VajMxePNbGCwQKhs4OpHz3ijPHze0nC1CXd8IBQqC5Ou VkYZgW4RhXNM9qFctdjuf4RbC4yvsntQkFY2z4NRA3FRrPX7IBamC4TYoSVbtcNWEvhjsO62eOqol um68jtbnTE1YqmtRFejcBerdyYgDY/8MWRhvE4+wpIExu4jPut6pP5Xzreg/cQAwMADQfoZjiJgej o7LWf4ALFvIs1hbet03g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHU-00B404-0Q; Mon, 09 Oct 2023 15:34:52 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHO-00B3wa-2L for linux-arm-kernel@lists.infradead.org; Mon, 09 Oct 2023 15:34:47 +0000 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-32329d935d4so4247352f8f.2 for ; Mon, 09 Oct 2023 08:34:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1696865682; x=1697470482; 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=ALY9Lnunr5db7q3qvzbnZl3K+5+m0WgnB3YOM2cNc3c=; b=zGdIrIeqXdXhd5M/TdIcuEoB2UbNCXDBIlrQoHPCFXu24enQ6LlU/ezvC9n2WNHhGX BftGTCB5/zQjdrVP5g5+yOUdoSK5rEAW3SOH8eWe5eR3Ki6Mu/Kui+f2e/GXOLGuO8Es NGwyegVvx8uRXeN4L6ni8gmZ/9YPQXJYSUQOdkJedymxxWkk5hpy/JEsNEcNGZKiOAtq KTK1JFKdlecIW3dqv9xKEPXfEhFW7eTREL0Vx9HmFmD177orBsHR9cSRewBgdZwAAE/3 52rarjnk8P2aEYoL2xBanW7iaVn3GmI+4Ua0eMqgMbEwCSOGyiC2Nl/S7fGBL+jzmgXj PcpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696865682; x=1697470482; 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=ALY9Lnunr5db7q3qvzbnZl3K+5+m0WgnB3YOM2cNc3c=; b=F0pj31z/hAMSik+rK0cP+oDIagYaS4xx10HHpgN59sch/wizkvuQbi4ykK59x6LNGR H8fXU6FX/9WJCKGt8/UCbDFK67hb56+p8PtYFTDVb302wMduFnSeq7frXYyoCJUPAbo3 XnzEv/GGhasot5Wkldn8MMENP+vsRibt+zrsJ0GGSY2qNjfw+VA/oRGIjSiKTLkmh3X2 jXRc4QOa2Kjajnr3jr0j4DIGHVkShzclUeyw8oavS4wdMOsa49hnOpry+RVz/ATMtzZt CbmC5VOf7eTk6UywCYrWlg4f/hADOuqq26IBxfVbWcqUTYYJL8l+AMIG9FtsjBgzMn9U b5ug== X-Gm-Message-State: AOJu0Yz0lYXCDBc0XjL70I/+gs7R930NrJ5Y7gINS08IVr8n0vw87quc O+6Hc614NYHm6BHGfNCIu5YmTw== X-Google-Smtp-Source: AGHT+IGfg4tN8OVm/Uv0hOiVhjVIt3rKwgD+zzMAu3rLsKW+sCrUPcY/lBvoMT8ujc86jhUTbapRyg== X-Received: by 2002:a5d:4f8a:0:b0:319:7722:30c with SMTP id d10-20020a5d4f8a000000b003197722030cmr12432000wru.22.1696865682327; Mon, 09 Oct 2023 08:34:42 -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.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:34:41 -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 02/15] firmware: qcom: scm: add a missing forward declaration for struct device Date: Mon, 9 Oct 2023 17:34:14 +0200 Message-Id: <20231009153427.20951-3-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_083446_761065_BC37BCB9 X-CRM114-Status: GOOD ( 10.14 ) 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 We reference struct device in the private scm header but we neither include linux/device.h nor forward declare it. Fix it. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andrew Halaney --- drivers/firmware/qcom/qcom_scm.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/firmware/qcom/qcom_scm.h b/drivers/firmware/qcom/qcom_scm.h index 7b68fa820495..c88e29051d20 100644 --- a/drivers/firmware/qcom/qcom_scm.h +++ b/drivers/firmware/qcom/qcom_scm.h @@ -4,6 +4,8 @@ #ifndef __QCOM_SCM_INT_H #define __QCOM_SCM_INT_H +struct device; + enum qcom_scm_convention { SMC_CONVENTION_UNKNOWN, SMC_CONVENTION_LEGACY, From patchwork Mon Oct 9 15:34:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13413931 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 E3D98E95A91 for ; Mon, 9 Oct 2023 15:35:26 +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=YUCyusaV8nRY1sqTYW6xDZRJz+7A0qs7poiCx0aCPBE=; b=WfjWvr0Vt767Oz MOBXEVo6EV+23kzdgepOi0So6PQneWyl0NAj3HgzYOS+oB1GJFeam63VsPRREPxnnql1oXiyyRBz7 yzCJbUCH/aE+Q047AmozyCBc8cN20i0r/MraVqN77UoW/B3mNSctG6nJECwH698/bAFGZCOAoD4nQ 41voIpvjaLf+MSyqS/LKEoe+szvzZ+by3u81IKSfolpVUyQUWuCJInHzmx79PFOrFXTq8TP4E2lhf TuX24YLpe46bj3KumrjkfWkIopVP9FnFABRMTCsn8afNqJ+Gy02ClxwhGvLLKfSlaEp6UK6R8SS0Y oPYAuhGGXRrRczo74YRg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHU-00B40l-2Z; Mon, 09 Oct 2023 15:34:52 +0000 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHP-00B3wc-2i for linux-arm-kernel@lists.infradead.org; Mon, 09 Oct 2023 15:34:49 +0000 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-307d20548adso4306847f8f.0 for ; Mon, 09 Oct 2023 08:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1696865683; x=1697470483; 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=D6eAwp+/NLgzsLQxQqIe9/6ILdI8QAjkHJ9+by+NSlg=; b=ibk3iDgTJMXU/7Jh3ZAxwWaS3FMxLwn6fN+RNsKAGOfgjPGxfVN+VndXsdogsCaBvZ zwXNztuqe7Tw6PhXFKX5OssZxUmDbUMuaBGphwu1cW0MoSQRKwEop8+OQHpJpMtHZVPM Co10i7mw1MdjtALbsd7aPwt+gf1PHcx7k90WEC3GHVHOFrxmhYYjsNCkqLe/L+WEj0yJ 7EXQgEJGQrULgxQnRQwcS9TL30u3aPsvYHKYDSojSWA9Aoq3ptUhGWyIgmzc/OAiUOng WqZWWEMcMVt2wzeG5ePd86sLduyP6T+NlMh76TnlM3H4MX19r5Lae4g6kFLPAEIYhtmO FJFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696865683; x=1697470483; 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=D6eAwp+/NLgzsLQxQqIe9/6ILdI8QAjkHJ9+by+NSlg=; b=KRHwcOZTeT5ujEcqF4guwGMaCuLmwT3HFLxCszNuj1mpygJQ7oebEi+RlUizNHlkE0 ihJMVcP1DMz8LN8RVB5JAtRk+2yb9kyeGb4/LqyZDv9RUU7vF+iLNiscX4Mh1+q9+HGO QyGutCX8FKtQJi75zkeSoTnOpI6b28zWcHYszQeayeBU7X+HSfr7a1UQy42xQzXN6+t/ ZqmG8csXPRvYeTyKf23mwHR1qdw5OlkC4BYDAArUZn4hP7hJc38OICH+ZjA/0hJ9gJQs UnnDrPFsDGf3bxJiNPJAoMKLLuNjfIVsbPaSpYgy7pXIkpbPPE6BrBCQ8wArD/EGhH4p o9wA== X-Gm-Message-State: AOJu0YxnH03BTAWm/zLG9olskGR6J7q9E82EGrAUmC8BeO3i4oJezfRR J9Zet+bLyUM+wxHu3oLK4V4eZkURfh11iCOiv757Vg== X-Google-Smtp-Source: AGHT+IGQPbmjtWzlwmkDpMj8BrV+CGMweKgLmWJRazlR2GfQlg6tpQhTsj0X/JeH7Ks7AF7tx4ODyw== X-Received: by 2002:adf:f407:0:b0:31f:eed7:2fdc with SMTP id g7-20020adff407000000b0031feed72fdcmr14360253wro.35.1696865683428; Mon, 09 Oct 2023 08:34:43 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:34:43 -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 03/15] firmware: qcom: scm: remove unneeded 'extern' specifiers Date: Mon, 9 Oct 2023 17:34:15 +0200 Message-Id: <20231009153427.20951-4-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_083447_883128_D3CCFF47 X-CRM114-Status: GOOD ( 10.88 ) 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 'extern' specifiers do nothing for function declarations. Remove them from the private qcom-scm header. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andrew Halaney --- drivers/firmware/qcom/qcom_scm.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/firmware/qcom/qcom_scm.h b/drivers/firmware/qcom/qcom_scm.h index c88e29051d20..4532907e8489 100644 --- a/drivers/firmware/qcom/qcom_scm.h +++ b/drivers/firmware/qcom/qcom_scm.h @@ -66,18 +66,17 @@ int qcom_scm_wait_for_wq_completion(u32 wq_ctx); int scm_get_wq_ctx(u32 *wq_ctx, u32 *flags, u32 *more_pending); #define SCM_SMC_FNID(s, c) ((((s) & 0xFF) << 8) | ((c) & 0xFF)) -extern int __scm_smc_call(struct device *dev, const struct qcom_scm_desc *desc, - enum qcom_scm_convention qcom_convention, - struct qcom_scm_res *res, bool atomic); +int __scm_smc_call(struct device *dev, const struct qcom_scm_desc *desc, + enum qcom_scm_convention qcom_convention, + struct qcom_scm_res *res, bool atomic); #define scm_smc_call(dev, desc, res, atomic) \ __scm_smc_call((dev), (desc), qcom_scm_convention, (res), (atomic)) #define SCM_LEGACY_FNID(s, c) (((s) << 10) | ((c) & 0x3ff)) -extern int scm_legacy_call_atomic(struct device *dev, - const struct qcom_scm_desc *desc, - struct qcom_scm_res *res); -extern int scm_legacy_call(struct device *dev, const struct qcom_scm_desc *desc, +int scm_legacy_call_atomic(struct device *dev, const struct qcom_scm_desc *desc, struct qcom_scm_res *res); +int scm_legacy_call(struct device *dev, const struct qcom_scm_desc *desc, + struct qcom_scm_res *res); #define QCOM_SCM_SVC_BOOT 0x01 #define QCOM_SCM_BOOT_SET_ADDR 0x01 From patchwork Mon Oct 9 15:34:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13413927 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 62A61E95A91 for ; Mon, 9 Oct 2023 15:35:20 +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=8OUaShVP5Kn5WM+Aedzduo4TDqRI3jjXSsLOB1xr6G0=; b=v6SFunGBarm/WE L1FgXs7jyK2oxgO/mbxybsp9oMXNM10MNgIXBPY3EiQvBhv/dbmwTSJzPtzega1RQqO53fHWoVyeU 6ITSg9z32PWEIrBlKQPdmdFjp3TgM9ieFfWhNzDSmFCH4jFOUQNYFAld04NCkdnEvuAR1YpHDUbTp YYBeWQ7Peko8hRx5Zext+baq6c3mN7CB1OSIGiJ6Cwh+xh/R1jNjGKZKZMe/YlXN2sjU4+j4jdYU/ vx3A79u4GNPIAuZnyK0Ar2Shfm40ydJ0S9jKsnrsEEsqshFQiCGx5PoTSuPLyCedKlmeNocLVdC1u 9Ch0Qjdbm/42AYy/BBUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHV-00B41B-16; Mon, 09 Oct 2023 15:34:53 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHQ-00B3x8-32 for linux-arm-kernel@lists.infradead.org; Mon, 09 Oct 2023 15:34:51 +0000 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-313e742a787so2778466f8f.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=1696865685; x=1697470485; 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=cSty+qu7PhsayrWz/+spX0I6HlUtb1zRWeYY1WbVRhc=; b=RBFHfOaJevU2VThyzlGwLfHqEJWVVVtY2zlAX8l4ACQjTg+SWZmTKGI3YyRTceng53 TQvCiOxRN0IVUBPGp4ETqd+fxghaNzXA5T/BWBgEZmuxgDRPNFV8/ev8iJvooLUjuPd7 9co44F6NVf97oy1Q629N10Ltg6WZzqaMDkzs5fdRm8Om3onE1jJ8zl4zCcIkQY6Uifjl iWwqxrLkIGJJhQaSFpW+EjBinWPGOuDTIGREFaN/ZSdHxQE1nFvYsxsK1024RH2aQCBd DKhOPpxI1aDXeezYXigWd2OqX/JysmQGLJT5JINGqFv5DDKLNRtEB34AASM03bPcV5rL qvsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696865685; x=1697470485; 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=cSty+qu7PhsayrWz/+spX0I6HlUtb1zRWeYY1WbVRhc=; b=wySKwqAllwgNtqc6d+iEK+mcvvvSwxg5CPAm4UaGcxvVFZfxZWMib6aqAr5wn/MDbU g3/15ww/3cBLPhVbb//zYYNSDYVyEx2531RympI7xZ32F0MzcRbcMP9nNeSM/Fr56H32 wMXH669ZJvWp8IUpGibCTAY0qGMPhN54kM7HKPKoPY1R0ugizGsmsgNtpp2Y2tsh6w/i p6nRRZfDUchzHk8AbwuCn/UbLXKQrUuZwpCyOFdDOhfH0uNQMBDr6O9cer6a+qUiLTwa Q0NrUfHOt49QEweuDqAMX0tkIXpf3ksRj/GWn4eVtBS4DBZhi6OYgaSEv1t77ew2ogjw Cywg== X-Gm-Message-State: AOJu0YwrncSthhpgwRp737pYtqxYfwjMsWm0xBi9yaVIhqyaJDXEgZ1D 1zc3MfIZDWBPwKWfz87MiOEp3Q== X-Google-Smtp-Source: AGHT+IFLlBhqM6BGDyhJdUpDgpP5Slde5utpkQjAFWVdQMRse5U0Gna9VNOFr3IdwfVkk07XW21B5A== X-Received: by 2002:adf:f984:0:b0:314:314e:fdda with SMTP id f4-20020adff984000000b00314314efddamr11126451wrr.23.1696865684529; Mon, 09 Oct 2023 08:34:44 -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.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:34:44 -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 04/15] firmware: qcom: add a dedicated TrustZone buffer allocator Date: Mon, 9 Oct 2023 17:34:16 +0200 Message-Id: <20231009153427.20951-5-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_985892_F1EDFEA6 X-CRM114-Status: GOOD ( 26.32 ) 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 We have several SCM calls that require passing buffers to the TrustZone on top of the SMC core which allocates memory for calls that require more than 4 arguments. Currently every user does their own thing which leads to code duplication. Many users call dma_alloc_coherent() for every call which is terribly unperformant (speed- and size-wise). Provide a set of library functions for creating and managing pool of memory which is suitable for sharing with the TrustZone, that is: page-aligned, contiguous and non-cachable as well as provides a way of mapping of kernel virtual addresses to physical space. Signed-off-by: Bartosz Golaszewski --- drivers/firmware/qcom/Kconfig | 19 ++ drivers/firmware/qcom/Makefile | 1 + drivers/firmware/qcom/qcom_tzmem.c | 301 +++++++++++++++++++++++ drivers/firmware/qcom/qcom_tzmem.h | 13 + include/linux/firmware/qcom/qcom_tzmem.h | 28 +++ 5 files changed, 362 insertions(+) create mode 100644 drivers/firmware/qcom/qcom_tzmem.c create mode 100644 drivers/firmware/qcom/qcom_tzmem.h create mode 100644 include/linux/firmware/qcom/qcom_tzmem.h diff --git a/drivers/firmware/qcom/Kconfig b/drivers/firmware/qcom/Kconfig index 3f05d9854ddf..b80269a28224 100644 --- a/drivers/firmware/qcom/Kconfig +++ b/drivers/firmware/qcom/Kconfig @@ -9,6 +9,25 @@ menu "Qualcomm firmware drivers" config QCOM_SCM tristate +config QCOM_TZMEM + tristate + +choice + prompt "TrustZone interface memory allocator mode" + default QCOM_TZMEM_MODE_DEFAULT + help + Selects the mode of the memory allocator providing memory buffers of + suitable format for sharing with the TrustZone. If in doubt, select + 'Default'. + +config QCOM_TZMEM_MODE_DEFAULT + bool "Default" + help + Use the default allocator mode. The memory is page-aligned, non-cachable + and contiguous. + +endchoice + config QCOM_SCM_DOWNLOAD_MODE_DEFAULT bool "Qualcomm download mode enabled by default" depends on QCOM_SCM diff --git a/drivers/firmware/qcom/Makefile b/drivers/firmware/qcom/Makefile index c9f12ee8224a..0be40a1abc13 100644 --- a/drivers/firmware/qcom/Makefile +++ b/drivers/firmware/qcom/Makefile @@ -5,5 +5,6 @@ obj-$(CONFIG_QCOM_SCM) += qcom-scm.o qcom-scm-objs += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o +obj-$(CONFIG_QCOM_TZMEM) += qcom_tzmem.o obj-$(CONFIG_QCOM_QSEECOM) += qcom_qseecom.o obj-$(CONFIG_QCOM_QSEECOM_UEFISECAPP) += qcom_qseecom_uefisecapp.o diff --git a/drivers/firmware/qcom/qcom_tzmem.c b/drivers/firmware/qcom/qcom_tzmem.c new file mode 100644 index 000000000000..eee51fed756e --- /dev/null +++ b/drivers/firmware/qcom/qcom_tzmem.c @@ -0,0 +1,301 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Memory allocator for buffers shared with the TrustZone. + * + * Copyright (C) 2023 Linaro Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "qcom_tzmem.h" + +struct qcom_tzmem_pool { + void *vbase; + phys_addr_t pbase; + size_t size; + struct gen_pool *pool; + void *priv; +}; + +struct qcom_tzmem_chunk { + phys_addr_t paddr; + size_t size; + struct qcom_tzmem_pool *owner; +}; + +static struct device *qcom_tzmem_dev; +static RADIX_TREE(qcom_tzmem_chunks, GFP_ATOMIC); +static DEFINE_SPINLOCK(qcom_tzmem_chunks_lock); + +#if IS_ENABLED(CONFIG_QCOM_TZMEM_MODE_DEFAULT) + +static int qcom_tzmem_init(void) +{ + return 0; +} + +static int qcom_tzmem_init_pool(struct qcom_tzmem_pool *pool) +{ + return 0; +} + +static void qcom_tzmem_cleanup_pool(struct qcom_tzmem_pool *pool) +{ + +} + +#endif /* CONFIG_QCOM_TZMEM_MODE_DEFAULT */ + +/** + * qcom_tzmem_pool_new() - Create a new TZ memory pool. + * @size - Size of the new pool in bytes. + * + * Create a new pool of memory suitable for sharing with the TrustZone. + * + * Must not be used in atomic context. + * + * Returns: + * New memory pool address or ERR_PTR() on error. + */ +struct qcom_tzmem_pool *qcom_tzmem_pool_new(size_t size) +{ + struct qcom_tzmem_pool *pool; + int ret = -ENOMEM; + + if (!size) + return ERR_PTR(-EINVAL); + + size = PAGE_ALIGN(size); + + pool = kzalloc(sizeof(*pool), GFP_KERNEL); + if (!pool) + return ERR_PTR(-ENOMEM); + + pool->size = size; + + pool->vbase = dma_alloc_coherent(qcom_tzmem_dev, size, &pool->pbase, + GFP_KERNEL); + if (!pool->vbase) + goto err_kfree_pool; + + pool->pool = gen_pool_create(PAGE_SHIFT, -1); + if (!pool) + goto err_dma_free; + + gen_pool_set_algo(pool->pool, gen_pool_best_fit, NULL); + + ret = gen_pool_add_virt(pool->pool, (unsigned long)pool->vbase, + pool->pbase, size, -1); + if (ret) + goto err_destroy_genpool; + + ret = qcom_tzmem_init_pool(pool); + if (ret) + goto err_destroy_genpool; + + return pool; + +err_destroy_genpool: + gen_pool_destroy(pool->pool); +err_dma_free: + dma_free_coherent(qcom_tzmem_dev, size, pool->vbase, pool->pbase); +err_kfree_pool: + kfree(pool); + return ERR_PTR(ret); +} +EXPORT_SYMBOL_GPL(qcom_tzmem_pool_new); + +/** + * qcom_tzmem_pool_free() - Destroy a TZ memory pool and free all resources. + * @pool: Memory pool to free. + * + * Must not be called if any of the allocated chunks has not been freed. + * Must not be used in atomic context. + */ +void qcom_tzmem_pool_free(struct qcom_tzmem_pool *pool) +{ + struct qcom_tzmem_chunk *chunk; + struct radix_tree_iter iter; + bool non_empty = false; + void **slot; + + if (!pool) + return; + + qcom_tzmem_cleanup_pool(pool); + + scoped_guard(spinlock_irqsave, &qcom_tzmem_chunks_lock) { + radix_tree_for_each_slot(slot, &qcom_tzmem_chunks, &iter, 0) { + chunk = *slot; + + if (chunk->owner == pool) + non_empty = true; + } + } + + WARN(non_empty, "Freeing TZ memory pool with memory still allocated"); + + gen_pool_destroy(pool->pool); + dma_free_coherent(qcom_tzmem_dev, pool->size, pool->vbase, pool->pbase); + kfree(pool); +} +EXPORT_SYMBOL_GPL(qcom_tzmem_pool_free); + +static void devm_qcom_tzmem_pool_free(void *data) +{ + struct qcom_tzmem_pool *pool = data; + + qcom_tzmem_pool_free(pool); +} + +/** + * devm_qcom_tzmem_pool_new() - Managed variant of qcom_tzmem_pool_new(). + * @dev: Device managing this resource. + * @size: Size of the pool in bytes. + * + * Must not be used in atomic context. + * + * Returns: + * Address of the managed pool or ERR_PTR() on failure. + */ +struct qcom_tzmem_pool * +devm_qcom_tzmem_pool_new(struct device *dev, size_t size) +{ + struct qcom_tzmem_pool *pool; + int ret; + + pool = qcom_tzmem_pool_new(size); + if (IS_ERR(pool)) + return pool; + + ret = devm_add_action_or_reset(dev, devm_qcom_tzmem_pool_free, pool); + if (ret) + return ERR_PTR(ret); + + return pool; +} + +/** + * qcom_tzmem_alloc() - Allocate a memory chunk suitable for sharing with TZ. + * @pool: TZ memory pool from which to allocate memory. + * @size: Number of bytes to allocate. + * @gfp: GFP flags. + * + * Can be used in any context. + * + * Returns: + * Address of the allocated buffer or NULL if no more memory can be allocated. + * The buffer must be released using qcom_tzmem_free(). + */ +void *qcom_tzmem_alloc(struct qcom_tzmem_pool *pool, size_t size, gfp_t gfp) +{ + struct qcom_tzmem_chunk *chunk; + unsigned long vaddr; + int ret; + + if (!size) + return NULL; + + size = PAGE_ALIGN(size); + + chunk = kzalloc(sizeof(*chunk), gfp); + if (!chunk) + return NULL; + + vaddr = gen_pool_alloc(pool->pool, size); + if (!vaddr) { + kfree(chunk); + return NULL; + } + + chunk->paddr = gen_pool_virt_to_phys(pool->pool, vaddr); + chunk->size = size; + chunk->owner = pool; + + scoped_guard(spinlock_irqsave, &qcom_tzmem_chunks_lock) { + ret = radix_tree_insert(&qcom_tzmem_chunks, vaddr, chunk); + if (ret) { + gen_pool_free(pool->pool, vaddr, size); + kfree(chunk); + return NULL; + } + } + + return (void *)vaddr; +} +EXPORT_SYMBOL_GPL(qcom_tzmem_alloc); + +/** + * qcom_tzmem_free() - Release a buffer allocated from a TZ memory pool. + * @vaddr: Virtual address of the buffer. + * + * Can be used in any context. + */ +void qcom_tzmem_free(void *vaddr) +{ + struct qcom_tzmem_chunk *chunk; + + scoped_guard(spinlock_irqsave, &qcom_tzmem_chunks_lock) + chunk = radix_tree_delete_item(&qcom_tzmem_chunks, + (unsigned long)vaddr, NULL); + + if (!chunk) { + WARN(1, "Virtual address %p not owned by TZ memory allocator", + vaddr); + return; + } + + gen_pool_free(chunk->owner->pool, (unsigned long)vaddr, chunk->size); + kfree(chunk); +} +EXPORT_SYMBOL_GPL(qcom_tzmem_free); + +/** + * qcom_tzmem_to_phys() - Map the virtual address of a TZ buffer to physical. + * @vaddr: Virtual address of the buffer allocated from a TZ memory pool. + * + * Can be used in any context. The address must have been returned by a call + * to qcom_tzmem_alloc(). + * + * Returns: + * Physical address of the buffer. + */ +phys_addr_t qcom_tzmem_to_phys(void *vaddr) +{ + struct qcom_tzmem_chunk *chunk; + + guard(spinlock_irqsave)(&qcom_tzmem_chunks_lock); + + chunk = radix_tree_lookup(&qcom_tzmem_chunks, (unsigned long)vaddr); + if (!chunk) + return 0; + + return chunk->paddr; +} +EXPORT_SYMBOL_GPL(qcom_tzmem_to_phys); + +int qcom_tzmem_enable(struct device *dev) +{ + if (qcom_tzmem_dev) + return -EBUSY; + + qcom_tzmem_dev = dev; + + return qcom_tzmem_init(); +} +EXPORT_SYMBOL_GPL(qcom_tzmem_enable); + +MODULE_DESCRIPTION("TrustZone memory allocator for Qualcomm firmware drivers"); +MODULE_AUTHOR("Bartosz Golaszewski "); +MODULE_LICENSE("GPL"); diff --git a/drivers/firmware/qcom/qcom_tzmem.h b/drivers/firmware/qcom/qcom_tzmem.h new file mode 100644 index 000000000000..f82f5dc5b7b1 --- /dev/null +++ b/drivers/firmware/qcom/qcom_tzmem.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2023 Linaro Ltd. + */ + +#ifndef __QCOM_TZMEM_PRIV_H +#define __QCOM_TZMEM_PRIV_H + +struct device; + +int qcom_tzmem_enable(struct device *dev); + +#endif /* __QCOM_TZMEM_PRIV_H */ diff --git a/include/linux/firmware/qcom/qcom_tzmem.h b/include/linux/firmware/qcom/qcom_tzmem.h new file mode 100644 index 000000000000..8e7fddab8cb4 --- /dev/null +++ b/include/linux/firmware/qcom/qcom_tzmem.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2023 Linaro Ltd. + */ + +#ifndef __QCOM_TZMEM_H +#define __QCOM_TZMEM_H + +#include +#include +#include + +struct device; +struct qcom_tzmem_pool; + +struct qcom_tzmem_pool *qcom_tzmem_pool_new(size_t size); +void qcom_tzmem_pool_free(struct qcom_tzmem_pool *pool); +struct qcom_tzmem_pool * +devm_qcom_tzmem_pool_new(struct device *dev, size_t size); + +void *qcom_tzmem_alloc(struct qcom_tzmem_pool *pool, size_t size, gfp_t gfp); +void qcom_tzmem_free(void *ptr); + +DEFINE_FREE(qcom_tzmem, void *, if (_T) qcom_tzmem_free(_T)); + +phys_addr_t qcom_tzmem_to_phys(void *ptr); + +#endif /* __QCOM_TZMEM */ 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. * From patchwork Mon Oct 9 15:34:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13413930 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 8413AE95A96 for ; Mon, 9 Oct 2023 15:35:25 +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=hmv+ZfpidzrmCAE7BJlsf7Za8Cg3OLQCGvetod1iLrk=; b=uvkrpWXEmY+ZKW JVJG4QZ1IyomVEpo9+vFtTWTfd+fJJQKghIgNdjUd1M1QmxVRQ8b6eGAtXXMaLuPbZWUdVNAZueBO nUSh8DQL9rBZ6T7Tf3VXjZfscvbkLei01Ynl8bvdOMsuVqYFmqWTN2E+4ZuiwSuhbcea+g7WouWIi DmClvdz8zOxq/WAx0SH+yTM8FQ2rfMWj02nKMM0ZNuKDNRpoCoERAj2LOK6cXcDn9oVRldlZJF0LS fG55tjCJycbNfcV5JHXJ3DRKn2W4PvXErngtooXGy0cdSUgIE8KHiB3BBxddc0p/Rt6liSUJ2QiYm NINuZZJGdFMKFZfyBpPg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHV-00B41p-30; Mon, 09 Oct 2023 15:34:53 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHS-00B3xj-0L for linux-arm-kernel@lists.infradead.org; Mon, 09 Oct 2023 15:34:51 +0000 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3215f19a13aso4649116f8f.3 for ; Mon, 09 Oct 2023 08:34:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1696865687; x=1697470487; 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=UnwTp4Lw3p1rKX5DDWLu+LDu8u+Ycx0lOsGSllntXJo=; b=oUmeuMXhRTHRqSZEW6fHJ+79/V3LiMoajI2xjB7VTGjjF5VUnRwFKQNN7l6kV58qF9 gbbn4JvJJXmMoDWVJIJPiJdeet5MTMNdg6ufHJdZ5nQ82u+oJf3cQtX7sxYW9y8nTa/E CJYQNRk6jWBbY/znW0AIj/RSJQ7KubxZ6GbnlGmHTw2B2wr2d8V1575kymoLb5SUt2D2 8GQ1ycB+l6uzu+y0rnUsT91HWRfFFfTIwKFGoZhFBCWSpJmCmj8UP+mnM0C8c96ckG5Q RIfpo1mf7DPjMljKQUGfQyzQHcxzh0UBis5JASFERO783dNhDE2KzXBwNHTAZTedQAaN BUEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696865687; x=1697470487; 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=UnwTp4Lw3p1rKX5DDWLu+LDu8u+Ycx0lOsGSllntXJo=; b=Ai1kdnOV1CRF+PCEOULtqVcvcQdGiCREDPplG2HXSbwdz6sRS2IIMkAFuxpf2JkSxO Fc/Zp0uc0Dw5Jo8DApEyUh/bQcGJvn/JuWvSzfxelM8Z3UTCKUuOYlHIDWbjUG/wq0Gw X4Tn/BvdbJT4xPB9INzvLxSppo5bUxYVXIPA54CQTFcBP2EpLrqA0AK+MfS9VVh7Rj+M jjy7Ed1WT6oIExV5HXf7i1UhET0jA25d638wVv9zUMyqbgFevF9my8Kj6yc3FmVEKtiw xGkApqFp7N3J/hEVsMaBJYg7DeEBPYIFxn7dzrFRNhFQy4igz9DsVwYENwsERTQivUkt BCuQ== X-Gm-Message-State: AOJu0Yw1Dr1+57aos3s3ouL/UQYT+xrvCrtUpuGT6ckr90mORRcbxV6p A4zD2qOuvhiZTRLTNqetwH+kNQ== X-Google-Smtp-Source: AGHT+IGLjnHniMAjzx5YA9kSNp3FSmqF7ZGnRmOAQ4To9QUDJhLfsrlElrqxtpxfypXNLeKa+MM9Iw== X-Received: by 2002:adf:f452:0:b0:31f:fed4:d79d with SMTP id f18-20020adff452000000b0031ffed4d79dmr14359230wrp.30.1696865686884; Mon, 09 Oct 2023 08:34:46 -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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:34:46 -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 06/15] firmware: qcom: scm: smc: switch to using the SCM allocator Date: Mon, 9 Oct 2023 17:34:18 +0200 Message-Id: <20231009153427.20951-7-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_083450_144953_A87471E4 X-CRM114-Status: GOOD ( 17.60 ) 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 We need to allocate, map and pass a buffer to the trustzone if we have more than 4 arguments for a given SCM calls. Let's use the new TrustZone allocator for that memory and shrink the code in process. As this code lives in a different compilation unit than the rest of the SCM code, we need to provide a helper in the form of qcom_scm_get_tzmem_pool() that allows the SMC low-level routines to access the SCM memory pool. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andrew Halaney --- drivers/firmware/qcom/qcom_scm-smc.c | 28 ++++++++-------------------- drivers/firmware/qcom/qcom_scm.c | 5 +++++ drivers/firmware/qcom/qcom_scm.h | 3 +++ 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/drivers/firmware/qcom/qcom_scm-smc.c b/drivers/firmware/qcom/qcom_scm-smc.c index 16cf88acfa8e..1a423d1cba6c 100644 --- a/drivers/firmware/qcom/qcom_scm-smc.c +++ b/drivers/firmware/qcom/qcom_scm-smc.c @@ -2,6 +2,7 @@ /* Copyright (c) 2015,2019 The Linux Foundation. All rights reserved. */ +#include #include #include #include @@ -9,6 +10,7 @@ #include #include #include +#include #include #include @@ -150,11 +152,10 @@ int __scm_smc_call(struct device *dev, const struct qcom_scm_desc *desc, enum qcom_scm_convention qcom_convention, struct qcom_scm_res *res, bool atomic) { + struct qcom_tzmem_pool *mempool = qcom_scm_get_tzmem_pool(); int arglen = desc->arginfo & 0xf; int i, ret; - dma_addr_t args_phys = 0; - void *args_virt = NULL; - size_t alloc_len; + void *args_virt __free(qcom_tzmem) = NULL; gfp_t flag = atomic ? GFP_ATOMIC : GFP_KERNEL; u32 smccc_call_type = atomic ? ARM_SMCCC_FAST_CALL : ARM_SMCCC_STD_CALL; u32 qcom_smccc_convention = (qcom_convention == SMC_CONVENTION_ARM_32) ? @@ -172,9 +173,9 @@ int __scm_smc_call(struct device *dev, const struct qcom_scm_desc *desc, smc.args[i + SCM_SMC_FIRST_REG_IDX] = desc->args[i]; if (unlikely(arglen > SCM_SMC_N_REG_ARGS)) { - alloc_len = SCM_SMC_N_EXT_ARGS * sizeof(u64); - args_virt = kzalloc(PAGE_ALIGN(alloc_len), flag); - + args_virt = qcom_tzmem_alloc(mempool, + SCM_SMC_N_EXT_ARGS * sizeof(u64), + flag); if (!args_virt) return -ENOMEM; @@ -192,25 +193,12 @@ int __scm_smc_call(struct device *dev, const struct qcom_scm_desc *desc, SCM_SMC_FIRST_EXT_IDX]); } - args_phys = dma_map_single(dev, args_virt, alloc_len, - DMA_TO_DEVICE); - - if (dma_mapping_error(dev, args_phys)) { - kfree(args_virt); - return -ENOMEM; - } - - smc.args[SCM_SMC_LAST_REG_IDX] = args_phys; + smc.args[SCM_SMC_LAST_REG_IDX] = qcom_tzmem_to_phys(args_virt); } /* ret error check follows after args_virt cleanup*/ ret = __scm_smc_do(dev, &smc, &smc_res, atomic); - if (args_virt) { - dma_unmap_single(dev, args_phys, alloc_len, DMA_TO_DEVICE); - kfree(args_virt); - } - if (ret) return ret; diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c index 0d4c028be0c1..71e98b666391 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -201,6 +201,11 @@ static void qcom_scm_bw_disable(void) enum qcom_scm_convention qcom_scm_convention = SMC_CONVENTION_UNKNOWN; static DEFINE_SPINLOCK(scm_query_lock); +struct qcom_tzmem_pool *qcom_scm_get_tzmem_pool(void) +{ + return __scm->mempool; +} + static enum qcom_scm_convention __get_convention(void) { unsigned long flags; diff --git a/drivers/firmware/qcom/qcom_scm.h b/drivers/firmware/qcom/qcom_scm.h index 4532907e8489..aa7d06939f8e 100644 --- a/drivers/firmware/qcom/qcom_scm.h +++ b/drivers/firmware/qcom/qcom_scm.h @@ -5,6 +5,7 @@ #define __QCOM_SCM_INT_H struct device; +struct qcom_tzmem_pool; enum qcom_scm_convention { SMC_CONVENTION_UNKNOWN, @@ -78,6 +79,8 @@ int scm_legacy_call_atomic(struct device *dev, const struct qcom_scm_desc *desc, int scm_legacy_call(struct device *dev, const struct qcom_scm_desc *desc, struct qcom_scm_res *res); +struct qcom_tzmem_pool *qcom_scm_get_tzmem_pool(void); + #define QCOM_SCM_SVC_BOOT 0x01 #define QCOM_SCM_BOOT_SET_ADDR 0x01 #define QCOM_SCM_BOOT_TERMINATE_PC 0x02 From patchwork Mon Oct 9 15:34:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13413935 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 5B2E0E95A96 for ; Mon, 9 Oct 2023 15:35:32 +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=cB2JBeiougWWvJfxcF9yGMfB03qS231yEFgWQhm8IMQ=; b=s/a/1JLRLYqNK+ 9TmTeAvqtSNLolrHNClSSKFYj3gLL2K7XDETho9gCWoKFbIlLSqBBk0/GJcbxB09fIyqJYzyZ9dVD +8CMCKxQAVWgbxuWxNLNaD+Dki84PaRWi65l/wICbWgzjIblO55DqzeEBXO/TccF3WWS/HRcyd7QD Og64quiHI6tcjNs+S6yzBKXiN36AaSOTZ+vseEKtPq1hRSlOX8X/UwWIogQJYlXzJIE71/MANjMB0 0xBzzF2bNuOtCS0OUoqUSIp6Naqc2CrRc35BvLozR/LqpJVq083vzXCIh+GuUeFwAnYbzNZL8zJn8 U6PIfL7iPfkQZDtC+6ow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHe-00B47D-22; Mon, 09 Oct 2023 15:35:02 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHU-00B3z5-14 for linux-arm-kernel@lists.infradead.org; Mon, 09 Oct 2023 15:34:53 +0000 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-32615eaa312so4296249f8f.2 for ; Mon, 09 Oct 2023 08:34:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1696865688; x=1697470488; 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=gVGoERFE3fa+HCgKC7RA440wyH71tSjIV08rhDsASMw=; b=dqZGL2qKtVkmO3SmSM/C8IvG0IBwqRVQsbNAxThQJhkHD6iWoYWXozPqdHGC32bvj7 zYavFFbgg5d+5LGIvfpcxHdq+lsls0qQTiPBA4kt+sJG48IvWac1hY61K5l01YtPv6J6 MCnbm+3O3WlwSwc5BJ4Uvt0yXiMFRTt3pCoumotVZa8UEwV2VRhCbxLOyW95cYxvkggn ssYf7Oc9Fdz7ilt+6YQZyF2bItKNihp6JunVKBcTNGJIb7960UvzhrK/teZ0la1NLoNc YdVGstLh0i12ziM90Sa36wcnHXIkZxb/gpwXZPByWZ00AGNZKmVilj692NDdJTApOqrY T0lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696865688; x=1697470488; 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=gVGoERFE3fa+HCgKC7RA440wyH71tSjIV08rhDsASMw=; b=nN0/AvkPh14Nl9dY5TmCO1rFeASv+bI2vtj34KfvoJ1y97G5EZBjbrXCQyMkhc8ZiP VV88ueqkVoOazeVs5nw/6Qxe1eDGZJhDUk6CgR7M2so0LYHwnWpyi5v1veh1FQQHINny 7a34R3RpE+N6ej38pC+hM4/AG2xLIPeQpc8lcRSXMTQBWDjtnVxofNHXcA3vv3JpoBmX xe+1OQTi+RST8QORkcFLQTMWUIJcsU7MpCFywhi2mtruknqtVIEqZUMskopOPkmwiW1S iXJEtoowdeTIeexQboRiVjotBPbXa8JSc05SNk7fsYyr+AVVfPk6duFcmimY6a9sXd8v UAvg== X-Gm-Message-State: AOJu0YyDDX3DO4VLkP52/vKjEkCE+gcEGmnmv0TwzuxP1kA5zIU8O9qh 3f4jUCSnm18yGECbnn32pKVQ+w== X-Google-Smtp-Source: AGHT+IGmR2OVbb8Xjr+DkHBylNE3rUpt0NZEh1/jquLYFhGjN/bGj4/O5LQWquHImkG2t/Wp9xDlbw== X-Received: by 2002:adf:e6ce:0:b0:31f:b7b2:d4e1 with SMTP id y14-20020adfe6ce000000b0031fb7b2d4e1mr13710904wrm.20.1696865688018; Mon, 09 Oct 2023 08:34:48 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:34:47 -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 07/15] firmware: qcom: scm: make qcom_scm_assign_mem() use the TZ allocator Date: Mon, 9 Oct 2023 17:34:19 +0200 Message-Id: <20231009153427.20951-8-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_083452_371184_C980E483 X-CRM114-Status: GOOD ( 12.41 ) 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 Let's use the new TZ memory allocator to obtain a buffer for this call instead of using dma_alloc_coherent(). Signed-off-by: Bartosz Golaszewski Reviewed-by: Andrew Halaney --- drivers/firmware/qcom/qcom_scm.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c index 71e98b666391..754f6056b99f 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -998,14 +999,13 @@ int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz, struct qcom_scm_mem_map_info *mem_to_map; phys_addr_t mem_to_map_phys; phys_addr_t dest_phys; - dma_addr_t ptr_phys; + phys_addr_t ptr_phys; size_t mem_to_map_sz; size_t dest_sz; size_t src_sz; size_t ptr_sz; int next_vm; __le32 *src; - void *ptr; int ret, i, b; u64 srcvm_bits = *srcvm; @@ -1015,10 +1015,13 @@ int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz, ptr_sz = ALIGN(src_sz, SZ_64) + ALIGN(mem_to_map_sz, SZ_64) + ALIGN(dest_sz, SZ_64); - ptr = dma_alloc_coherent(__scm->dev, ptr_sz, &ptr_phys, GFP_KERNEL); + void *ptr __free(qcom_tzmem) = qcom_tzmem_alloc(__scm->mempool, + ptr_sz, GFP_KERNEL); if (!ptr) return -ENOMEM; + ptr_phys = qcom_tzmem_to_phys(ptr); + /* Fill source vmid detail */ src = ptr; i = 0; @@ -1047,7 +1050,6 @@ int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz, ret = __qcom_scm_assign_mem(__scm->dev, mem_to_map_phys, mem_to_map_sz, ptr_phys, src_sz, dest_phys, dest_sz); - dma_free_coherent(__scm->dev, ptr_sz, ptr, ptr_phys); if (ret) { dev_err(__scm->dev, "Assign memory protection call failed %d\n", ret); From patchwork Mon Oct 9 15:34:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13413937 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 51B03E95A96 for ; Mon, 9 Oct 2023 15:35:36 +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=PJ9KqHft4ctVMalS3RubfezRetOse+JzdhkwoOpoCZI=; b=HswhS4vcYjZ4w1 Bct0cUxYA6SZ2DolexXBWQGpQbzV5QFBMUocqIpLqC5i9kZZJ/Fg2m3zEaEj4mAl4pygAJ9eop2KK 1787rzBgidGTMtS0HpgrD8ozMAnjBonWj7jsvGt+ILVauOgszw/Va5NtkE6+o1bDrQCcG7scrwuet YU8QwNSyRbVxN2Ur6xCsy7HpRva1Y4OkjiDd65Hh2/Ui8iP+Sk2xwjSS/5lTA60tIzwuIGeXcsuaz GurrWXRJHxGLr5HIw0/GuqWLQ/UbsdrnsRIfn4gcbzOywdKCtQyyAIBUJbSpAyK4q9S/PAuV831Sf k2/G7zmjqtVDzD0y/cCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHf-00B48Q-2q; Mon, 09 Oct 2023 15:35:03 +0000 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHV-00B3zX-2X for linux-arm-kernel@lists.infradead.org; Mon, 09 Oct 2023 15:34:55 +0000 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-406619b53caso42956915e9.1 for ; Mon, 09 Oct 2023 08:34:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1696865690; x=1697470490; 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=WT7V6AZ26cidOG3ruLe3K86NfrAEQ3oBaGfcZy0uWnU=; b=yWIJGRYYG0ZaQxR+oDGVsXjInpR5iZQZiktU1ja2em/Aw0mHMkY8D8hNTQQscqpdsF +OcY6YN8mP0SRym7+rLoRYMNfJgqpo3gQEj+ILdnAHjOUW9q+MwYgL2FAbgnb9hWJhyb htQaqz8jnY8bndwyRu64Tw7Y0emeWVRvFK2Z/rtd4GtC6EPlkyqr4xSOKjhi6wxNwgAF ZfIbrLl4mpqKIle1KFqWGwK5qIVza8ESJxYG10BB2j+gbzTx46IPhkukLQtDamypCWeD RWoq73oe1S63cbakMjt+L9vDFgYP1HKQNo3zX8j0/IXOQZozQGGYi1us+ZgIhZmmND3k GS4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696865690; x=1697470490; 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=WT7V6AZ26cidOG3ruLe3K86NfrAEQ3oBaGfcZy0uWnU=; b=fFqO29T5CG/gr3+PpSjsd7adDV9mBIWp/Q+to3VfFPRvtAWO12LhSHtQOkNs6LUF5i 9rDgl3dTAmL3xgWHQ5SZvTWXBzQMNcfF3R7gkwJdN9Ccq1kwqMcs8nTVrqbURZGPYz7S E2SBb8b1P32R84yChj05TPy1WVcpGMy6qNy1/3OH+ppI/39reQl3OQiJDs/7HC8ucylD ADmGht5VxAeaK0Q5cJ7JeXZIVIuszpmTWOeKlovISGqii834TEY4alFwGHKtmoZCo3CM qj9KBi8wEUvVP4x7a95Z8GwBZIJYYL2vlTiTFsCqVb7RyZRwORmRkOQcVcfjnI3ynLp5 5jcQ== X-Gm-Message-State: AOJu0YziuIc0V8Kj2ztMQT2tJ6k36NtiOuKEOJYsqo2mhxieoP5NfhOF zrA1weKKCQlM08YF/QXiDr703Q== X-Google-Smtp-Source: AGHT+IG2Kyg2+eJFy8yr/9Sv3Py49/NM5wcjqgfeeWHCRX3tIetOY73CKPk4pgTaDtvl/4eX4+JlKQ== X-Received: by 2002:a5d:58f2:0:b0:31f:f326:766b with SMTP id f18-20020a5d58f2000000b0031ff326766bmr13334322wrd.6.1696865689675; Mon, 09 Oct 2023 08:34:49 -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.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:34:49 -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 08/15] firmware: qcom: scm: make qcom_scm_ice_set_key() use the TZ allocator Date: Mon, 9 Oct 2023 17:34:20 +0200 Message-Id: <20231009153427.20951-9-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_083453_824982_1DF136D0 X-CRM114-Status: GOOD ( 12.34 ) 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 Let's use the new TZ memory allocator to obtain a buffer for this call instead of using dma_alloc_coherent(). Signed-off-by: Bartosz Golaszewski Reviewed-by: Andrew Halaney --- drivers/firmware/qcom/qcom_scm.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c index 754f6056b99f..31071a714cf1 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -1197,32 +1197,21 @@ int qcom_scm_ice_set_key(u32 index, const u8 *key, u32 key_size, .args[4] = data_unit_size, .owner = ARM_SMCCC_OWNER_SIP, }; - void *keybuf; - dma_addr_t key_phys; + int ret; - /* - * 'key' may point to vmalloc()'ed memory, but we need to pass a - * physical address that's been properly flushed. The sanctioned way to - * do this is by using the DMA API. But as is best practice for crypto - * keys, we also must wipe the key after use. This makes kmemdup() + - * dma_map_single() not clearly correct, since the DMA API can use - * bounce buffers. Instead, just use dma_alloc_coherent(). Programming - * keys is normally rare and thus not performance-critical. - */ - - keybuf = dma_alloc_coherent(__scm->dev, key_size, &key_phys, - GFP_KERNEL); + void *keybuf __free(qcom_tzmem) = qcom_tzmem_alloc(__scm->mempool, + key_size, + GFP_KERNEL); if (!keybuf) return -ENOMEM; memcpy(keybuf, key, key_size); - desc.args[1] = key_phys; + desc.args[1] = qcom_tzmem_to_phys(keybuf); ret = qcom_scm_call(__scm->dev, &desc, NULL); memzero_explicit(keybuf, key_size); - dma_free_coherent(__scm->dev, key_size, keybuf, key_phys); return ret; } EXPORT_SYMBOL_GPL(qcom_scm_ice_set_key); From patchwork Mon Oct 9 15:34:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13413933 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 A0AFAE95A9B for ; Mon, 9 Oct 2023 15:35:31 +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=BhxSHdOCiSj3aQcgXAklb2+Zhay7VmZ3P4VS2rt+W/A=; b=liPq0RHhknBnyn z/kPyE2OTAcf/uy+zPb2Bjt4pSQgTDTv244IvIrJYEcmhuUAneeLHPmV6CQnsWHlhyhCtZjNj7JjW LU7Z40Gtj3rAzHflrf8tevvElTXO4Am/C9OyHNfXuGHwMS28qf34t7CC1eJm/Wcyfq/A2V1qQTklw sE2ZBzkTmZTOQA3fxH4E1tv0RpJlEKpZ0M8NS3X07M8EQzeyZef3xpR2MoqEYPvdm7LKxe0AMj/SN /8ANu9U2GfvayV2vSa+jJuKHq62RuTAM3PQHKHlBeP9VtJs141sB+Md9vYfeFUpoowVwlZvtE1lAy 2AlvBAwTmzNxBLrNct1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHf-00B47u-0p; Mon, 09 Oct 2023 15:35:03 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHU-00B401-20 for linux-arm-kernel@lists.infradead.org; Mon, 09 Oct 2023 15:34:53 +0000 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3296b87aa13so2820738f8f.3 for ; Mon, 09 Oct 2023 08:34:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1696865691; x=1697470491; 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=VbTZKQqdpJrILRniIPDrMxLXgf0p/DyB9D6pPMY/qic=; b=e19Jqby4Tj0v7VeYa/TJHDSRwUFZGBjHDwfZfM3h/VsNz7XBZzNP5NUwoH9SWzKQeM fM5z7JxyWdzVzT+WC2587AM8WJm+6hbMmHU0Evbul2I/hh3nnQKfeb7c3wbz+8p3lPK5 BNL9IDdoIbsdm33KdF6E82IxR52tRtZY2XY8FyEADZxvSRFKRSmTWH3iUzQMVEMYG3/m B0QFAZSJ7YliylOzIeFeEvpIVjzT7sTVvk4R3I1IcHZtmBuAu8+ymWuXXpQltvbn59kf m2v2qAM8Yy1VPB4pW//Yp1dCSWm5en1E7YDMoexQPcP1PB0K8IfsrYLe3IckmKTW8ij0 SLgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696865691; x=1697470491; 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=VbTZKQqdpJrILRniIPDrMxLXgf0p/DyB9D6pPMY/qic=; b=ejmCofyF7tNmv16ycIM41uLNWEi6Y81ydcoJ0LJdETLllf5SIdLHniKNXRJx7cNczu M73mXdjkTcEIADYnk0ais9NebLo9xjdT5PwsQJj2eQUPdDhv1tqDFMNnAbZBp2j3hkz8 499ss1pVPp6UHGAUQ1B7tRy2cd94UP11K6sQcedqJ0DhwhY9Qs4EJnaJqls+kn7zXs+j zLASrine491ZEZ9tYB+JcnvqhipTDkZtUXcKIkguWq6tEI0mhkgZEiQAU8+SMQSL8OfN y0uFQrcKqeILLPPR7xnjW99KUAxxW3Byi9Yig/WeP9Z0zRx+vTY3OnYU94N2bViL/EjR zb6g== X-Gm-Message-State: AOJu0Yw5nWYbhnIsJjowbYKjmiBl4Q6+mSvQxRLLiXpxoy2xK1WDcP37 nbzFdFUrdRUAp4ksY4UBcGzGCA== X-Google-Smtp-Source: AGHT+IGQF2q6zQswu+XOUXPGnGNpbRCfcHwX//5E5r9lPC5kW2bwvkYXF5J2WzPCCp+4tjNW7qT8Jw== X-Received: by 2002:a5d:54cf:0:b0:31f:9838:dfc4 with SMTP id x15-20020a5d54cf000000b0031f9838dfc4mr13054433wrv.33.1696865690821; Mon, 09 Oct 2023 08:34:50 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:34:50 -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 09/15] firmware: qcom: scm: make qcom_scm_lmh_dcvsh() use the TZ allocator Date: Mon, 9 Oct 2023 17:34:21 +0200 Message-Id: <20231009153427.20951-10-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_083452_691563_416CA686 X-CRM114-Status: GOOD ( 11.95 ) 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 Let's use the new TZ memory allocator to obtain a buffer for this call instead of using dma_alloc_coherent(). Signed-off-by: Bartosz Golaszewski Reviewed-by: Andrew Halaney --- drivers/firmware/qcom/qcom_scm.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c index 31071a714cf1..11638daa2fe5 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -1340,8 +1340,6 @@ EXPORT_SYMBOL_GPL(qcom_scm_lmh_profile_change); int qcom_scm_lmh_dcvsh(u32 payload_fn, u32 payload_reg, u32 payload_val, u64 limit_node, u32 node_id, u64 version) { - dma_addr_t payload_phys; - u32 *payload_buf; int ret, payload_size = 5 * sizeof(u32); struct qcom_scm_desc desc = { @@ -1356,7 +1354,9 @@ int qcom_scm_lmh_dcvsh(u32 payload_fn, u32 payload_reg, u32 payload_val, .owner = ARM_SMCCC_OWNER_SIP, }; - payload_buf = dma_alloc_coherent(__scm->dev, payload_size, &payload_phys, GFP_KERNEL); + u32 *payload_buf __free(qcom_tzmem) = qcom_tzmem_alloc(__scm->mempool, + payload_size, + GFP_KERNEL); if (!payload_buf) return -ENOMEM; @@ -1366,11 +1366,10 @@ int qcom_scm_lmh_dcvsh(u32 payload_fn, u32 payload_reg, u32 payload_val, payload_buf[3] = 1; payload_buf[4] = payload_val; - desc.args[0] = payload_phys; + desc.args[0] = qcom_tzmem_to_phys(payload_buf); ret = qcom_scm_call(__scm->dev, &desc, NULL); - dma_free_coherent(__scm->dev, payload_size, payload_buf, payload_phys); return ret; } EXPORT_SYMBOL_GPL(qcom_scm_lmh_dcvsh); From patchwork Mon Oct 9 15:34:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13413934 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 BEBDFE95A9F for ; Mon, 9 Oct 2023 15:35:31 +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=54teT0YAV07Dq4me/nGyDaZ1Bx+hdWoelFDxfrElBRc=; b=LR+9hxfNV9fSBs CTvDqb4Sz77FjXQHcTFCYX87DQ7XLIJgnewpV2z9X2CaYUSpSjx4WvonNcFO98gLEqydl6A/4T0rH gFURm8Up1DTm/MgyJKpTC8t1MeyWhpoQrsXlD4j0AMxPho+ww8G0rIDwozz3qz5KmDLVujfvIBa/i FsblbhOKGD4dLlxGoh2IM4RSVuq4qCsV5zjUfw9foyDYKnyuTeLDHeXKvRBO/W217loCT3nxtObO3 y1sHIJunCQkroM5mJpIuoJd+Tm4GxswaDbnZyNmToi0y/uFRZenkc+JoHJZtq1DJa8GWgE7yywzFr 9rhlCs3S0+9zh/enITcw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHg-00B48t-1V; Mon, 09 Oct 2023 15:35:04 +0000 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHW-00B41j-1w for linux-arm-kernel@lists.infradead.org; Mon, 09 Oct 2023 15:34:57 +0000 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-31427ddd3fbso4490635f8f.0 for ; Mon, 09 Oct 2023 08:34:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1696865693; x=1697470493; 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=Nb4tcSfQ92DzRQCExn+0+N39FtrJHx6Q4bK89f1YGng=; b=tnLSTH0hjniQg+/Fw9p9/V1LEQouGaZdSeSns8aAbIZh0cx0B/NqumFepId0pq1LiS oZfsf0b7fMCLz5zaL48NYK2t7YFzELgYR+wAGa/CBDaWmU1AL+VeZjnJEi1FWag87fuV NuVtaZXFrdO1nmx9Avlx6g+RWcWeHFf53xND0i36AG+JY+24RI7iPjP073TmP8Suq8C6 7mWMP6rcQtLzQ44aBIuFA1kwyIpFGnCrg5IVLO1bGfKyXB9v8MvQleXk96bOySw0jhvz 69PzBscxYUy0JHi88mrnwUbC1MScvIlrXhvFuBhJkS6RdYntJ6YBui/XyExUiKW+jzCu vsoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696865693; x=1697470493; 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=Nb4tcSfQ92DzRQCExn+0+N39FtrJHx6Q4bK89f1YGng=; b=t7csCPQQWzRHK+lrMS6IFAngVGz7GAinv9U7DLDrv9Fv3iL8AnFBKz85TM82399wds xDbnFA74FGtf686GOtMSwoH2jZCSHp/q222q9eCwqmeTHeBSzjioc4ap7mlB8mxf9ORi BgvU6H0mI6fWV0lg9bHlluUJjo8eobk8yy2fVV6l8NhZM5HmPBNf8HX6pRKSb8TVae0o 6U6SSm6Nb53EiD9hq7DdJJPbVXcHuaNeUQ9dUz1+nCPV1IbL+gV/luC4z2fmM0QcPHsw ypM1HynHRynXnt/Qg4zmuKD3bkVTpUyXFsAmwKhOKZqA27puR/luEaVAjP6iptowtB4n snBg== X-Gm-Message-State: AOJu0YwxSqcFlXnufT/KvDaejMFZXZbrgkWNGFtasGet+8gAugrV9DAW peF0//Obfv0zn2X7qfYDSClDhQ== X-Google-Smtp-Source: AGHT+IF/ATwNhgOWfbF6ffkoc4v5R/7+WBbSX0OpK95f8UD7VXSz1nm9Y6NL0KGaM1loMPbeBPKrCQ== X-Received: by 2002:a05:6000:1815:b0:317:e1fb:d56a with SMTP id m21-20020a056000181500b00317e1fbd56amr13467982wrh.40.1696865692794; Mon, 09 Oct 2023 08:34:52 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:34:52 -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 10/15] firmware: qcom: scm: make qcom_scm_qseecom_app_get_id() use the TZ allocator Date: Mon, 9 Oct 2023 17:34:22 +0200 Message-Id: <20231009153427.20951-11-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_083454_640617_8E0ABB46 X-CRM114-Status: GOOD ( 11.70 ) 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 Let's use the new TZ memory allocator to obtain a buffer for this call instead of manually kmalloc()ing it and then mapping to physical space. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andrew Halaney Tested-by: Maximilian Luz --- drivers/firmware/qcom/qcom_scm.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c index 11638daa2fe5..3a6cefb4eb2e 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -1525,37 +1525,27 @@ int qcom_scm_qseecom_app_get_id(const char *app_name, u32 *app_id) unsigned long app_name_len = strlen(app_name); struct qcom_scm_desc desc = {}; struct qcom_scm_qseecom_resp res = {}; - dma_addr_t name_buf_phys; - char *name_buf; int status; if (app_name_len >= name_buf_size) return -EINVAL; - name_buf = kzalloc(name_buf_size, GFP_KERNEL); + char *name_buf __free(qcom_tzmem) = qcom_tzmem_alloc(__scm->mempool, + name_buf_size, + GFP_KERNEL); if (!name_buf) return -ENOMEM; memcpy(name_buf, app_name, app_name_len); - name_buf_phys = dma_map_single(__scm->dev, name_buf, name_buf_size, DMA_TO_DEVICE); - status = dma_mapping_error(__scm->dev, name_buf_phys); - if (status) { - kfree(name_buf); - dev_err(__scm->dev, "qseecom: failed to map dma address\n"); - return status; - } - desc.owner = QSEECOM_TZ_OWNER_QSEE_OS; desc.svc = QSEECOM_TZ_SVC_APP_MGR; desc.cmd = QSEECOM_TZ_CMD_APP_LOOKUP; desc.arginfo = QCOM_SCM_ARGS(2, QCOM_SCM_RW, QCOM_SCM_VAL); - desc.args[0] = name_buf_phys; + desc.args[0] = qcom_tzmem_to_phys(name_buf); desc.args[1] = app_name_len; status = qcom_scm_qseecom_call(&desc, &res); - dma_unmap_single(__scm->dev, name_buf_phys, name_buf_size, DMA_TO_DEVICE); - kfree(name_buf); if (status) return status; From patchwork Mon Oct 9 15:34:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13413936 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 35048E95A9B for ; Mon, 9 Oct 2023 15:35:35 +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=dBlz4ehZsdwcNXSZcbxv06cGTQfmNa+lrZwCc/ySMBI=; b=vwmEs1yNc0g3L2 2w0KaEL3VKU3WjnveVyoHoTdLKDXArEGyvNjT0bmMD8D8fmRY+9xIfXrUCjVUpbUy5YjGibyQuPy/ hIALCeiYebDZsyuAtdmVTBkhmIs8MMnc4jzwU1rgvpsVmvi5yIeUzX69v3KNLNDZsDYA0MW3bY0Bp qAa6Cebrowubq/NfB24eabftTrKQiCshSV14hj+DbnJTqhOd2YnXWgNbB0FT5XV+CVYuW++NorGNL bm8x6CtIk2o8O1umz/YZViLswN0UNsnw9SG4VTbKyqhb2nEmU0uEHkVVDkY+l16dXjOF8bQVeAPR4 kE3wUG24uyJ5xL7jUPZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHh-00B49r-2k; Mon, 09 Oct 2023 15:35:05 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHZ-00B42H-2Y for linux-arm-kernel@lists.infradead.org; Mon, 09 Oct 2023 15:35:00 +0000 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-40566f8a093so43434305e9.3 for ; Mon, 09 Oct 2023 08:34:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1696865694; x=1697470494; 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=uWZ9ax+OP6vcJAY7a8Qv9uADb1sdulZJxjzOEl3gO/A=; b=aFU4OuxRJKC8819ZqBMNA4RG8yMelvNewcAcF/NQQtcIj2gKJg+1Tkt2yz4wzF56rO qDCS20A2uOsxB9UkSR0jhTxXNT4CPsA+P3V2oBJJxhJJKZAfj48UBaEZTAyvd28+2cyK xLLvmqvLUNrnnLyzEFvFQ2f+I4hRIzngPKb/zg2Sc8pZYqPSPuh9PoT2WigvJr8yrAoU n33qJaGACyGZec5raJD8ZUXokANylVR79VnjOebwZZhoAN6b+j4yFldJ5yxE8NfBZKpi oFNaJeIoezfalmaNTTSZHFoOVdHQlBzwkL0Cw9BqhdeGY2vD09iRbUuLj1lfMLl7rBZU nrnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696865694; x=1697470494; 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=uWZ9ax+OP6vcJAY7a8Qv9uADb1sdulZJxjzOEl3gO/A=; b=TQb1NRrXC0XUReV/tHkhGqIB44o5sQu5cbW4AOZ3NA3B2+qmBTxLHAzZLAK6HMFfgq M27wS4KPJ6lnxqDw+O80eaHUj8rCb2hGE/28JwKbwihpHhVy/h/IaUlZmDTUa9YO1bY5 OLc8JRNLtHS7YtCzy5EU8toeaNBjxhirIU9udMilUCFIcCHhTRfABKGb6XVpk/BKBVL9 uUUKlkSyT9nRvKrUm9C2GZCrKA4KHIn0Js5BXyl1//bFweuww+E/LJJbUZGw3/Iidmlb kCnmibhZP/i8bayAOlDii3y0aOjaNzrBC+OluUEQHBPEe7Ub2fB88geV9tWSGVnW3W50 jRVw== X-Gm-Message-State: AOJu0Yz2yZkWycDfk8lI8rbT80twzP+HugnUk3DUQyjHq61ynrdXIDb8 45fgjqI5WkVCWV0IKwxTTjyjzA== X-Google-Smtp-Source: AGHT+IFTRmbtr2N9OcVlyA80lfrpXaH3F4eWViimdbPXAQ/fi50i+F3PclVPJ2Frm3UlxNv0j/46JA== X-Received: by 2002:a7b:ce89:0:b0:402:f07c:4b48 with SMTP id q9-20020a7bce89000000b00402f07c4b48mr13448294wmj.28.1696865694013; Mon, 09 Oct 2023 08:34:54 -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.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:34:53 -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 11/15] firmware: qcom: qseecom: convert to using the TZ allocator Date: Mon, 9 Oct 2023 17:34:23 +0200 Message-Id: <20231009153427.20951-12-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_083457_837535_24E5E297 X-CRM114-Status: GOOD ( 21.86 ) 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 Drop the DMA mapping operations from qcom_scm_qseecom_app_send() and convert all users of it in the qseecom module to using the TZ allocator for creating SCM call buffers. Together with using the cleanup macros, it has the added benefit of a significant code shrink. As this is largely a module separate from the SCM driver, let's use a separate memory pool. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andrew Halaney Tested-by: Maximilian Luz --- .../firmware/qcom/qcom_qseecom_uefisecapp.c | 260 +++++++----------- drivers/firmware/qcom/qcom_scm.c | 30 +- include/linux/firmware/qcom/qcom_qseecom.h | 4 +- 3 files changed, 103 insertions(+), 191 deletions(-) diff --git a/drivers/firmware/qcom/qcom_qseecom_uefisecapp.c b/drivers/firmware/qcom/qcom_qseecom_uefisecapp.c index a33acdaf7b78..720cddd7c8c7 100644 --- a/drivers/firmware/qcom/qcom_qseecom_uefisecapp.c +++ b/drivers/firmware/qcom/qcom_qseecom_uefisecapp.c @@ -7,6 +7,7 @@ * Copyright (C) 2023 Maximilian Luz */ +#include #include #include #include @@ -18,6 +19,8 @@ #include #include +#include +#include /* -- Qualcomm "uefisecapp" interface definitions. -------------------------- */ @@ -253,6 +256,7 @@ struct qsee_rsp_uefi_query_variable_info { struct qcuefi_client { struct qseecom_client *client; struct efivars efivars; + struct qcom_tzmem_pool *mempool; }; static struct device *qcuefi_dev(struct qcuefi_client *qcuefi) @@ -272,11 +276,11 @@ static efi_status_t qsee_uefi_get_variable(struct qcuefi_client *qcuefi, const e const efi_guid_t *guid, u32 *attributes, unsigned long *data_size, void *data) { - struct qsee_req_uefi_get_variable *req_data; - struct qsee_rsp_uefi_get_variable *rsp_data; + struct qsee_req_uefi_get_variable *req_data __free(qcom_tzmem) = NULL; + struct qsee_rsp_uefi_get_variable *rsp_data __free(qcom_tzmem) = NULL; unsigned long buffer_size = *data_size; - efi_status_t efi_status = EFI_SUCCESS; unsigned long name_length; + efi_status_t efi_status; size_t guid_offs; size_t name_offs; size_t req_size; @@ -304,17 +308,13 @@ static efi_status_t qsee_uefi_get_variable(struct qcuefi_client *qcuefi, const e __array(u8, buffer_size) ); - req_data = kzalloc(req_size, GFP_KERNEL); - if (!req_data) { - efi_status = EFI_OUT_OF_RESOURCES; - goto out; - } + req_data = qcom_tzmem_alloc(qcuefi->mempool, req_size, GFP_KERNEL); + if (!req_data) + return EFI_OUT_OF_RESOURCES; - rsp_data = kzalloc(rsp_size, GFP_KERNEL); - if (!rsp_data) { - efi_status = EFI_OUT_OF_RESOURCES; - goto out_free_req; - } + rsp_data = qcom_tzmem_alloc(qcuefi->mempool, rsp_size, GFP_KERNEL); + if (!rsp_data) + return EFI_OUT_OF_RESOURCES; req_data->command_id = QSEE_CMD_UEFI_GET_VARIABLE; req_data->data_size = buffer_size; @@ -331,20 +331,14 @@ static efi_status_t qsee_uefi_get_variable(struct qcuefi_client *qcuefi, const e memcpy(((void *)req_data) + req_data->guid_offset, guid, req_data->guid_size); status = qcom_qseecom_app_send(qcuefi->client, req_data, req_size, rsp_data, rsp_size); - if (status) { - efi_status = EFI_DEVICE_ERROR; - goto out_free; - } + if (status) + return EFI_DEVICE_ERROR; - if (rsp_data->command_id != QSEE_CMD_UEFI_GET_VARIABLE) { - efi_status = EFI_DEVICE_ERROR; - goto out_free; - } + if (rsp_data->command_id != QSEE_CMD_UEFI_GET_VARIABLE) + return EFI_DEVICE_ERROR; - if (rsp_data->length < sizeof(*rsp_data)) { - efi_status = EFI_DEVICE_ERROR; - goto out_free; - } + if (rsp_data->length < sizeof(*rsp_data)) + return EFI_DEVICE_ERROR; if (rsp_data->status) { dev_dbg(qcuefi_dev(qcuefi), "%s: uefisecapp error: 0x%x\n", @@ -358,18 +352,14 @@ static efi_status_t qsee_uefi_get_variable(struct qcuefi_client *qcuefi, const e *attributes = rsp_data->attributes; } - goto out_free; + return efi_status; } - if (rsp_data->length > rsp_size) { - efi_status = EFI_DEVICE_ERROR; - goto out_free; - } + if (rsp_data->length > rsp_size) + return EFI_DEVICE_ERROR; - if (rsp_data->data_offset + rsp_data->data_size > rsp_data->length) { - efi_status = EFI_DEVICE_ERROR; - goto out_free; - } + if (rsp_data->data_offset + rsp_data->data_size > rsp_data->length) + return EFI_DEVICE_ERROR; /* * Note: We need to set attributes and data size even if the buffer is @@ -392,33 +382,23 @@ static efi_status_t qsee_uefi_get_variable(struct qcuefi_client *qcuefi, const e if (attributes) *attributes = rsp_data->attributes; - if (buffer_size == 0 && !data) { - efi_status = EFI_SUCCESS; - goto out_free; - } + if (buffer_size == 0 && !data) + return EFI_SUCCESS; - if (buffer_size < rsp_data->data_size) { - efi_status = EFI_BUFFER_TOO_SMALL; - goto out_free; - } + if (buffer_size < rsp_data->data_size) + return EFI_BUFFER_TOO_SMALL; memcpy(data, ((void *)rsp_data) + rsp_data->data_offset, rsp_data->data_size); -out_free: - kfree(rsp_data); -out_free_req: - kfree(req_data); -out: - return efi_status; + return EFI_SUCCESS; } static efi_status_t qsee_uefi_set_variable(struct qcuefi_client *qcuefi, const efi_char16_t *name, const efi_guid_t *guid, u32 attributes, unsigned long data_size, const void *data) { - struct qsee_req_uefi_set_variable *req_data; - struct qsee_rsp_uefi_set_variable *rsp_data; - efi_status_t efi_status = EFI_SUCCESS; + struct qsee_req_uefi_set_variable *req_data __free(qcom_tzmem) = NULL; + struct qsee_rsp_uefi_set_variable *rsp_data __free(qcom_tzmem) = NULL; unsigned long name_length; size_t name_offs; size_t guid_offs; @@ -448,17 +428,14 @@ static efi_status_t qsee_uefi_set_variable(struct qcuefi_client *qcuefi, const e __array_offs(u8, data_size, &data_offs) ); - req_data = kzalloc(req_size, GFP_KERNEL); - if (!req_data) { - efi_status = EFI_OUT_OF_RESOURCES; - goto out; - } + req_data = qcom_tzmem_alloc(qcuefi->mempool, req_size, GFP_KERNEL); + if (!req_data) + return EFI_OUT_OF_RESOURCES; - rsp_data = kzalloc(sizeof(*rsp_data), GFP_KERNEL); - if (!rsp_data) { - efi_status = EFI_OUT_OF_RESOURCES; - goto out_free_req; - } + rsp_data = qcom_tzmem_alloc(qcuefi->mempool, sizeof(*rsp_data), + GFP_KERNEL); + if (!rsp_data) + return EFI_OUT_OF_RESOURCES; req_data->command_id = QSEE_CMD_UEFI_SET_VARIABLE; req_data->attributes = attributes; @@ -481,42 +458,31 @@ static efi_status_t qsee_uefi_set_variable(struct qcuefi_client *qcuefi, const e status = qcom_qseecom_app_send(qcuefi->client, req_data, req_size, rsp_data, sizeof(*rsp_data)); - if (status) { - efi_status = EFI_DEVICE_ERROR; - goto out_free; - } + if (status) + return EFI_DEVICE_ERROR; - if (rsp_data->command_id != QSEE_CMD_UEFI_SET_VARIABLE) { - efi_status = EFI_DEVICE_ERROR; - goto out_free; - } + if (rsp_data->command_id != QSEE_CMD_UEFI_SET_VARIABLE) + return EFI_DEVICE_ERROR; - if (rsp_data->length != sizeof(*rsp_data)) { - efi_status = EFI_DEVICE_ERROR; - goto out_free; - } + if (rsp_data->length != sizeof(*rsp_data)) + return EFI_DEVICE_ERROR; if (rsp_data->status) { dev_dbg(qcuefi_dev(qcuefi), "%s: uefisecapp error: 0x%x\n", __func__, rsp_data->status); - efi_status = qsee_uefi_status_to_efi(rsp_data->status); + return qsee_uefi_status_to_efi(rsp_data->status); } -out_free: - kfree(rsp_data); -out_free_req: - kfree(req_data); -out: - return efi_status; + return EFI_SUCCESS; } static efi_status_t qsee_uefi_get_next_variable(struct qcuefi_client *qcuefi, unsigned long *name_size, efi_char16_t *name, efi_guid_t *guid) { - struct qsee_req_uefi_get_next_variable *req_data; - struct qsee_rsp_uefi_get_next_variable *rsp_data; - efi_status_t efi_status = EFI_SUCCESS; + struct qsee_req_uefi_get_next_variable *req_data __free(qcom_tzmem) = NULL; + struct qsee_rsp_uefi_get_next_variable *rsp_data __free(qcom_tzmem) = NULL; + efi_status_t efi_status; size_t guid_offs; size_t name_offs; size_t req_size; @@ -541,17 +507,13 @@ static efi_status_t qsee_uefi_get_next_variable(struct qcuefi_client *qcuefi, __array(*name, *name_size / sizeof(*name)) ); - req_data = kzalloc(req_size, GFP_KERNEL); - if (!req_data) { - efi_status = EFI_OUT_OF_RESOURCES; - goto out; - } + req_data = qcom_tzmem_alloc(qcuefi->mempool, req_size, GFP_KERNEL); + if (!req_data) + return EFI_OUT_OF_RESOURCES; - rsp_data = kzalloc(rsp_size, GFP_KERNEL); - if (!rsp_data) { - efi_status = EFI_OUT_OF_RESOURCES; - goto out_free_req; - } + rsp_data = qcom_tzmem_alloc(qcuefi->mempool, rsp_size, GFP_KERNEL); + if (!rsp_data) + return EFI_OUT_OF_RESOURCES; req_data->command_id = QSEE_CMD_UEFI_GET_NEXT_VARIABLE; req_data->guid_offset = guid_offs; @@ -567,20 +529,14 @@ static efi_status_t qsee_uefi_get_next_variable(struct qcuefi_client *qcuefi, return EFI_INVALID_PARAMETER; status = qcom_qseecom_app_send(qcuefi->client, req_data, req_size, rsp_data, rsp_size); - if (status) { - efi_status = EFI_DEVICE_ERROR; - goto out_free; - } + if (status) + return EFI_DEVICE_ERROR; - if (rsp_data->command_id != QSEE_CMD_UEFI_GET_NEXT_VARIABLE) { - efi_status = EFI_DEVICE_ERROR; - goto out_free; - } + if (rsp_data->command_id != QSEE_CMD_UEFI_GET_NEXT_VARIABLE) + return EFI_DEVICE_ERROR; - if (rsp_data->length < sizeof(*rsp_data)) { - efi_status = EFI_DEVICE_ERROR; - goto out_free; - } + if (rsp_data->length < sizeof(*rsp_data)) + return EFI_DEVICE_ERROR; if (rsp_data->status) { dev_dbg(qcuefi_dev(qcuefi), "%s: uefisecapp error: 0x%x\n", @@ -595,77 +551,59 @@ static efi_status_t qsee_uefi_get_next_variable(struct qcuefi_client *qcuefi, if (efi_status == EFI_BUFFER_TOO_SMALL) *name_size = rsp_data->name_size; - goto out_free; + return efi_status; } - if (rsp_data->length > rsp_size) { - efi_status = EFI_DEVICE_ERROR; - goto out_free; - } + if (rsp_data->length > rsp_size) + return EFI_DEVICE_ERROR; - if (rsp_data->name_offset + rsp_data->name_size > rsp_data->length) { - efi_status = EFI_DEVICE_ERROR; - goto out_free; - } + if (rsp_data->name_offset + rsp_data->name_size > rsp_data->length) + return EFI_DEVICE_ERROR; - if (rsp_data->guid_offset + rsp_data->guid_size > rsp_data->length) { - efi_status = EFI_DEVICE_ERROR; - goto out_free; - } + if (rsp_data->guid_offset + rsp_data->guid_size > rsp_data->length) + return EFI_DEVICE_ERROR; if (rsp_data->name_size > *name_size) { *name_size = rsp_data->name_size; - efi_status = EFI_BUFFER_TOO_SMALL; - goto out_free; + return EFI_BUFFER_TOO_SMALL; } - if (rsp_data->guid_size != sizeof(*guid)) { - efi_status = EFI_DEVICE_ERROR; - goto out_free; - } + if (rsp_data->guid_size != sizeof(*guid)) + return EFI_DEVICE_ERROR; memcpy(guid, ((void *)rsp_data) + rsp_data->guid_offset, rsp_data->guid_size); status = ucs2_strscpy(name, ((void *)rsp_data) + rsp_data->name_offset, rsp_data->name_size / sizeof(*name)); *name_size = rsp_data->name_size; - if (status < 0) { + if (status < 0) /* * Return EFI_DEVICE_ERROR here because the buffer size should * have already been validated above, causing this function to * bail with EFI_BUFFER_TOO_SMALL. */ return EFI_DEVICE_ERROR; - } -out_free: - kfree(rsp_data); -out_free_req: - kfree(req_data); -out: - return efi_status; + return EFI_SUCCESS; } static efi_status_t qsee_uefi_query_variable_info(struct qcuefi_client *qcuefi, u32 attr, u64 *storage_space, u64 *remaining_space, u64 *max_variable_size) { - struct qsee_req_uefi_query_variable_info *req_data; - struct qsee_rsp_uefi_query_variable_info *rsp_data; - efi_status_t efi_status = EFI_SUCCESS; + struct qsee_req_uefi_query_variable_info *req_data __free(qcom_tzmem) = NULL; + struct qsee_rsp_uefi_query_variable_info *rsp_data __free(qcom_tzmem) = NULL; int status; - req_data = kzalloc(sizeof(*req_data), GFP_KERNEL); - if (!req_data) { - efi_status = EFI_OUT_OF_RESOURCES; - goto out; - } + req_data = qcom_tzmem_alloc(qcuefi->mempool, sizeof(*req_data), + GFP_KERNEL); + if (!req_data) + return EFI_OUT_OF_RESOURCES; - rsp_data = kzalloc(sizeof(*rsp_data), GFP_KERNEL); - if (!rsp_data) { - efi_status = EFI_OUT_OF_RESOURCES; - goto out_free_req; - } + rsp_data = qcom_tzmem_alloc(qcuefi->mempool, sizeof(*rsp_data), + GFP_KERNEL); + if (!rsp_data) + return EFI_OUT_OF_RESOURCES; req_data->command_id = QSEE_CMD_UEFI_QUERY_VARIABLE_INFO; req_data->attributes = attr; @@ -673,26 +611,19 @@ static efi_status_t qsee_uefi_query_variable_info(struct qcuefi_client *qcuefi, status = qcom_qseecom_app_send(qcuefi->client, req_data, sizeof(*req_data), rsp_data, sizeof(*rsp_data)); - if (status) { - efi_status = EFI_DEVICE_ERROR; - goto out_free; - } + if (status) + return EFI_DEVICE_ERROR; - if (rsp_data->command_id != QSEE_CMD_UEFI_QUERY_VARIABLE_INFO) { - efi_status = EFI_DEVICE_ERROR; - goto out_free; - } + if (rsp_data->command_id != QSEE_CMD_UEFI_QUERY_VARIABLE_INFO) + return EFI_DEVICE_ERROR; - if (rsp_data->length != sizeof(*rsp_data)) { - efi_status = EFI_DEVICE_ERROR; - goto out_free; - } + if (rsp_data->length != sizeof(*rsp_data)) + return EFI_DEVICE_ERROR; if (rsp_data->status) { dev_dbg(qcuefi_dev(qcuefi), "%s: uefisecapp error: 0x%x\n", __func__, rsp_data->status); - efi_status = qsee_uefi_status_to_efi(rsp_data->status); - goto out_free; + return qsee_uefi_status_to_efi(rsp_data->status); } if (storage_space) @@ -704,12 +635,7 @@ static efi_status_t qsee_uefi_query_variable_info(struct qcuefi_client *qcuefi, if (max_variable_size) *max_variable_size = rsp_data->max_variable_size; -out_free: - kfree(rsp_data); -out_free_req: - kfree(req_data); -out: - return efi_status; + return EFI_SUCCESS; } /* -- Global efivar interface. ---------------------------------------------- */ @@ -838,6 +764,10 @@ static int qcom_uefisecapp_probe(struct auxiliary_device *aux_dev, if (status) qcuefi_set_reference(NULL); + qcuefi->mempool = devm_qcom_tzmem_pool_new(&aux_dev->dev, SZ_256K); + if (IS_ERR(qcuefi->mempool)) + return PTR_ERR(qcuefi->mempool); + return status; } diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c index 3a6cefb4eb2e..318d7d398e5f 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -1567,9 +1567,9 @@ EXPORT_SYMBOL_GPL(qcom_scm_qseecom_app_get_id); /** * qcom_scm_qseecom_app_send() - Send to and receive data from a given QSEE app. * @app_id: The ID of the target app. - * @req: Request buffer sent to the app (must be DMA-mappable). + * @req: Request buffer sent to the app (must be TZ memory) * @req_size: Size of the request buffer. - * @rsp: Response buffer, written to by the app (must be DMA-mappable). + * @rsp: Response buffer, written to by the app (must be TZ memory) * @rsp_size: Size of the response buffer. * * Sends a request to the QSEE app associated with the given ID and read back @@ -1585,26 +1585,12 @@ int qcom_scm_qseecom_app_send(u32 app_id, void *req, size_t req_size, void *rsp, { struct qcom_scm_qseecom_resp res = {}; struct qcom_scm_desc desc = {}; - dma_addr_t req_phys; - dma_addr_t rsp_phys; + phys_addr_t req_phys; + phys_addr_t rsp_phys; int status; - /* Map request buffer */ - req_phys = dma_map_single(__scm->dev, req, req_size, DMA_TO_DEVICE); - status = dma_mapping_error(__scm->dev, req_phys); - if (status) { - dev_err(__scm->dev, "qseecom: failed to map request buffer\n"); - return status; - } - - /* Map response buffer */ - rsp_phys = dma_map_single(__scm->dev, rsp, rsp_size, DMA_FROM_DEVICE); - status = dma_mapping_error(__scm->dev, rsp_phys); - if (status) { - dma_unmap_single(__scm->dev, req_phys, req_size, DMA_TO_DEVICE); - dev_err(__scm->dev, "qseecom: failed to map response buffer\n"); - return status; - } + req_phys = qcom_tzmem_to_phys(req); + rsp_phys = qcom_tzmem_to_phys(rsp); /* Set up SCM call data */ desc.owner = QSEECOM_TZ_OWNER_TZ_APPS; @@ -1622,10 +1608,6 @@ int qcom_scm_qseecom_app_send(u32 app_id, void *req, size_t req_size, void *rsp, /* Perform call */ status = qcom_scm_qseecom_call(&desc, &res); - /* Unmap buffers */ - dma_unmap_single(__scm->dev, rsp_phys, rsp_size, DMA_FROM_DEVICE); - dma_unmap_single(__scm->dev, req_phys, req_size, DMA_TO_DEVICE); - if (status) return status; diff --git a/include/linux/firmware/qcom/qcom_qseecom.h b/include/linux/firmware/qcom/qcom_qseecom.h index b531547e1dc9..26af1e778f00 100644 --- a/include/linux/firmware/qcom/qcom_qseecom.h +++ b/include/linux/firmware/qcom/qcom_qseecom.h @@ -23,9 +23,9 @@ struct qseecom_client { /** * qcom_qseecom_app_send() - Send to and receive data from a given QSEE app. * @client: The QSEECOM client associated with the target app. - * @req: Request buffer sent to the app (must be DMA-mappable). + * @req: Request buffer sent to the app (must be TZ memory). * @req_size: Size of the request buffer. - * @rsp: Response buffer, written to by the app (must be DMA-mappable). + * @rsp: Response buffer, written to by the app (must be TZ memory). * @rsp_size: Size of the response buffer. * * Sends a request to the QSEE app associated with the given client and read From patchwork Mon Oct 9 15:34:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13413938 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 64608E95A9E for ; Mon, 9 Oct 2023 15:35:38 +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=1eSQXMcQI/jWtsedOlEdjKgswqLKDxUAF6Fh9bPZJII=; b=HBg8ZzS2f21FUr CGHzdN7y9FlfDktY/8i/GxUVU0YUsJZhOHeRPB1bByGaxxgBVYsmEPyOEBtBWuVKhN+TmpcyQFHsN gNZGVG2DMbqkSMGqNFhczzhaUlhFDieqIBTRqTCoo9RmJG6+IRsOWFOaLrdl8rnI/ll99w7DcULJB 4qV70oyaBdPZTPW9t7PLvGFUXRXB6Hf3A8dfIQ/F/QnzURPJJynK1F/r1pbFnwBUVWn4HILs9yH9U 0M0pSdvA8rRFYywD7qscMfzUbe1xY7DspEpROqVK8lhTo8PfiF9q9diFVKB/K6XmdMUnCvW/pkd6R MGsdwFtdC+ZUrkq9kx4A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHh-00B49M-0x; Mon, 09 Oct 2023 15:35:05 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHZ-00B43D-2Y for linux-arm-kernel@lists.infradead.org; Mon, 09 Oct 2023 15:34:59 +0000 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-405497850dbso43618335e9.0 for ; Mon, 09 Oct 2023 08:34:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1696865695; x=1697470495; 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=AGMo0XfPtT2eoS0TClJYKLLiBxw0PNFjU9Xb0WM0Oqk=; b=hzTGCozdZAjYwSvqEO1rZpfWKcaFV5Cm5Q8RkaLBYl6fa8M/kvvqVbMxtYPCPEGb+F MBRG4l2ZLtbbuHltPfPeo+Yt5dxAXQzivU5QYJAIYIdPf9DLrqe7WhNy2Is75QXWfzGV mj15MCKDQHbk1/RLKI26Xey4L61EDXFKNxnhCskfKEsvB5qZs9unGd17B1Iw8QRALsEU Lkk0kmbKwOPO2w3FyGQd6ivPUrY76t/vsJtdAwxkIA54fodyE8NxjpC7e1zPtC3Csj16 Rdo/rFo/QO8q4LAC/kcUvv2VzKCI3aaCz4bDWHCq/4/x56PiwByJkhDFRanUjfD2x6MF kGTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696865695; x=1697470495; 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=AGMo0XfPtT2eoS0TClJYKLLiBxw0PNFjU9Xb0WM0Oqk=; b=l1DkHWBQhcV06+QW6IzMVa4ghEifQWV3+gvTh//W1ORTHDJBrb6c8AG6LGznY4Fm0B kClXyV32OrzpOHRV3a5YOpO7QIr549Xwf/9pB4m8KW44Y8XOtx+GK/1vhcMHnKiMWCR8 qH8go76IwIzBqD6uwisnCuPxTCopy08q/8GMdpH6nHUkyAsFkfalDTRK/AQfJV0piQ6t Pup4+3L7pJe2g88kyEfHA9FcX4MuGthMYqovht5hb1c192yTvJ+epEGiaLmf+vvgYCV9 LfSq9AIflzdZ4790uQLikeamVxPGW1ID5ondxNaFXw2xpNA2vZjJwsgnbzRE0h9aXkTR wTaQ== X-Gm-Message-State: AOJu0Yzr0BCrCHK5rrT9HRFrEQ3olNuCPtcduXj0OMsBmVwIon0/tfxj /CSXs/cZQZb5BDIRaFnV+pxxLQ== X-Google-Smtp-Source: AGHT+IExMQGmoR910TN87hWZUaBBToBu+dIq/NTctCOEhsbuP+TC5cdn0qj3s9d/swCgx1y0tiBEZw== X-Received: by 2002:adf:cc81:0:b0:321:5971:23a5 with SMTP id p1-20020adfcc81000000b00321597123a5mr13956454wrj.20.1696865695351; Mon, 09 Oct 2023 08:34:55 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:34:54 -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 12/15] firmware: qcom: scm: add support for SHM bridge operations Date: Mon, 9 Oct 2023 17:34:24 +0200 Message-Id: <20231009153427.20951-13-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_083457_830271_5ADF3AE9 X-CRM114-Status: GOOD ( 12.95 ) 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 Add low-level primitives for enabling SHM bridge support as well as creating and destroying SHM bridge pools to qcom-scm. Signed-off-by: Bartosz Golaszewski --- drivers/firmware/qcom/qcom_scm.c | 60 ++++++++++++++++++++++++++ drivers/firmware/qcom/qcom_scm.h | 3 ++ include/linux/firmware/qcom/qcom_scm.h | 6 +++ 3 files changed, 69 insertions(+) diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c index 318d7d398e5f..839773270a21 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -1323,6 +1323,66 @@ bool qcom_scm_lmh_dcvsh_available(void) } EXPORT_SYMBOL_GPL(qcom_scm_lmh_dcvsh_available); +int qcom_scm_shm_bridge_enable(void) +{ + struct qcom_scm_desc desc = { + .svc = QCOM_SCM_SVC_MP, + .cmd = QCOM_SCM_MP_SHM_BRIDGE_ENABLE, + .owner = ARM_SMCCC_OWNER_SIP + }; + + struct qcom_scm_res res; + + if (!__qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_MP, + QCOM_SCM_MP_SHM_BRIDGE_ENABLE)) + return -EOPNOTSUPP; + + return qcom_scm_call(__scm->dev, &desc, &res) ?: res.result[0]; +} +EXPORT_SYMBOL_GPL(qcom_scm_shm_bridge_enable); + +int qcom_scm_shm_bridge_create(struct device *dev, u64 pfn_and_ns_perm_flags, + u64 ipfn_and_s_perm_flags, u64 size_and_flags, + u64 ns_vmids, u64 *handle) +{ + struct qcom_scm_desc desc = { + .svc = QCOM_SCM_SVC_MP, + .cmd = QCOM_SCM_MP_SHM_BRIDGE_CREATE, + .owner = ARM_SMCCC_OWNER_SIP, + .args[0] = pfn_and_ns_perm_flags, + .args[1] = ipfn_and_s_perm_flags, + .args[2] = size_and_flags, + .args[3] = ns_vmids, + .arginfo = QCOM_SCM_ARGS(4, QCOM_SCM_VAL, QCOM_SCM_VAL, + QCOM_SCM_VAL, QCOM_SCM_VAL), + }; + + struct qcom_scm_res res; + int ret; + + ret = qcom_scm_call(__scm->dev, &desc, &res); + + if (handle && !ret) + *handle = res.result[1]; + + return ret ?: res.result[0]; +} +EXPORT_SYMBOL_GPL(qcom_scm_shm_bridge_create); + +int qcom_scm_shm_bridge_delete(struct device *dev, u64 handle) +{ + struct qcom_scm_desc desc = { + .svc = QCOM_SCM_SVC_MP, + .cmd = QCOM_SCM_MP_SHM_BRIDGE_DELETE, + .owner = ARM_SMCCC_OWNER_SIP, + .args[0] = handle, + .arginfo = QCOM_SCM_ARGS(1, QCOM_SCM_VAL), + }; + + return qcom_scm_call(__scm->dev, &desc, NULL); +} +EXPORT_SYMBOL_GPL(qcom_scm_shm_bridge_delete); + int qcom_scm_lmh_profile_change(u32 profile_id) { struct qcom_scm_desc desc = { diff --git a/drivers/firmware/qcom/qcom_scm.h b/drivers/firmware/qcom/qcom_scm.h index aa7d06939f8e..cb7273aa0a5e 100644 --- a/drivers/firmware/qcom/qcom_scm.h +++ b/drivers/firmware/qcom/qcom_scm.h @@ -116,6 +116,9 @@ struct qcom_tzmem_pool *qcom_scm_get_tzmem_pool(void); #define QCOM_SCM_MP_IOMMU_SET_CP_POOL_SIZE 0x05 #define QCOM_SCM_MP_VIDEO_VAR 0x08 #define QCOM_SCM_MP_ASSIGN 0x16 +#define QCOM_SCM_MP_SHM_BRIDGE_ENABLE 0x1c +#define QCOM_SCM_MP_SHM_BRIDGE_DELETE 0x1d +#define QCOM_SCM_MP_SHM_BRIDGE_CREATE 0x1e #define QCOM_SCM_SVC_OCMEM 0x0f #define QCOM_SCM_OCMEM_LOCK_CMD 0x01 diff --git a/include/linux/firmware/qcom/qcom_scm.h b/include/linux/firmware/qcom/qcom_scm.h index ccaf28846054..9b6054813f59 100644 --- a/include/linux/firmware/qcom/qcom_scm.h +++ b/include/linux/firmware/qcom/qcom_scm.h @@ -115,6 +115,12 @@ int qcom_scm_lmh_dcvsh(u32 payload_fn, u32 payload_reg, u32 payload_val, int qcom_scm_lmh_profile_change(u32 profile_id); bool qcom_scm_lmh_dcvsh_available(void); +int qcom_scm_shm_bridge_enable(void); +int qcom_scm_shm_bridge_create(struct device *dev, u64 pfn_and_ns_perm_flags, + u64 ipfn_and_s_perm_flags, u64 size_and_flags, + u64 ns_vmids, u64 *handle); +int qcom_scm_shm_bridge_delete(struct device *dev, u64 handle); + #ifdef CONFIG_QCOM_QSEECOM int qcom_scm_qseecom_app_get_id(const char *app_name, u32 *app_id); From patchwork Mon Oct 9 15:34:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13413939 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 412B9E95A91 for ; Mon, 9 Oct 2023 15:35: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=BSlicdlek65d5p6PQd4SQzLfImcXStMiJIZsgSAgmBc=; b=FMNbj/8IIEN0V1 E5PJXhIXEmTQst8GuScQsuuWUWdxOVIYPZWumYPMW0243ao0wy5m8s5QYJ9m+3ugFxlVbUMoUr1IE 8x+mcbl/lxdui6aNrqvx5XeAQmMvF2OzZALBJA7t2Oi/p3yLu0MsD775pbop8Xh1q/6hWqW6ebyHz D20SrYF2KP5un427L96kogY7CroPsz3Cy+6ICwKk+M5fyoerlRrz8DqFrMZnfWxydbxYxVBDvclma 5ak1AW8OJ+L5MkWP5knNca50G6J+TRPVG9jAg5nN1ADdqjPriGSEc5WVAohPMBF2Fxu1ioFHf33Rq QyElqP0ry7JIDvAf1kwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHz-00B4N4-2C; Mon, 09 Oct 2023 15:35:23 +0000 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHc-00B43Z-0m for linux-arm-kernel@lists.infradead.org; Mon, 09 Oct 2023 15:35:03 +0000 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-323168869daso4618370f8f.2 for ; Mon, 09 Oct 2023 08:34:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1696865696; x=1697470496; 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=bf2AqtKJ/+ji6DGMnGdvnoiBlKH8gD5Uamvdkv0NVy0=; b=q8ngttvyrjoqUK9RYeXPFiLuOtzXD9TcJPV5SsyGSPtH7I7s6AmohjczNLfiYFglh+ nhQmAmxhOVeNMcreIxxYylCN9VFfE5A3VL+7SSAk6kbBCOndv4zVimhyDG0w+Zc70bfS gBoVfIS/jM+U1a4WniBJQs/NCVnG7jQAXWZ8LwBcpYoaAYVlbLYc/45VcIhIQ7INrWyW xTxWbKDG0HD1akjR3WhwypVv8OPyo7WZXDdYPBvGGzxjsP/zwdv98ZJS2nrfRZ6yLvvq bOKA2qzU4WajAvsZQtdXWJLJhG/6AYWbql9KGKyG0gzvLdCdbNwwygh+m4UOddRqBhqL OSqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696865696; x=1697470496; 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=bf2AqtKJ/+ji6DGMnGdvnoiBlKH8gD5Uamvdkv0NVy0=; b=Kqmne6JADLwPW2xMFKkiaJXlCY4z32rF3A4CWYvZxb71ab7CKeEJGzNqYNGogRSw75 lERZQS1d1qOBL3uVNCg+l6cL2fZEZuBvwBnjjBPyJG5qV1Y/Q3QfD+ugnUIokEJPCFk5 2jiwj3VD9qJtng38ssjlNIx5piyPFGHk63Pso+gZ16GkiZiH1UBOd1FqM4+FfIiKR2mo PsLGnktnZGpWxkkpb5bt19Uz9M5AC+noA4XnTrpgQNCOqdQ4MAlzoPT2YyNytfgKQP0o /mz6msMAN+RjVzFHwCGbgvyLZXli8Hn5ri4YsCCbGA9a8MKWtEoPlMuIniv10iPj5uDW U4Gw== X-Gm-Message-State: AOJu0Ywx14Aq7cAOYot8fnPFjMaYAcWmHOdWK/i3xPMkR2Om3sgpZXXV BYWFGpK+aHJCFii9NfqR2mcDPg== X-Google-Smtp-Source: AGHT+IGTXsa/CCoBPozrI8MbjUY8dJrEvFIpOtzhxfmR9YMRhYHQyCuiNShfgxVY3ik1ZrBWgpo12g== X-Received: by 2002:a5d:6909:0:b0:317:70da:abdd with SMTP id t9-20020a5d6909000000b0031770daabddmr14203281wru.59.1696865696468; Mon, 09 Oct 2023 08:34:56 -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.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:34:56 -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 13/15] firmware: qcom: tzmem: enable SHM Bridge support Date: Mon, 9 Oct 2023 17:34:25 +0200 Message-Id: <20231009153427.20951-14-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_083500_286180_E936B5CE X-CRM114-Status: GOOD ( 18.17 ) 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 Add a new Kconfig option for selecting the SHM Bridge mode of operation for the TrustZone memory allocator. If enabled at build-time, it will still be checked for availability at run-time. If the architecture doesn't support SHM Bridge, the allocator will work just like in the default mode. Signed-off-by: Bartosz Golaszewski --- drivers/firmware/qcom/Kconfig | 10 +++++ drivers/firmware/qcom/qcom_tzmem.c | 67 +++++++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/qcom/Kconfig b/drivers/firmware/qcom/Kconfig index 237da40de832..e01407e31ae4 100644 --- a/drivers/firmware/qcom/Kconfig +++ b/drivers/firmware/qcom/Kconfig @@ -27,6 +27,16 @@ config QCOM_TZMEM_MODE_DEFAULT Use the default allocator mode. The memory is page-aligned, non-cachable and contiguous. +config QCOM_TZMEM_MODE_SHMBRIDGE + bool "SHM Bridge" + help + Use Qualcomm Shared Memory Bridge. The memory has the same alignment as + in the 'Default' allocator but is also explicitly marked as an SHM Bridge + buffer. + + With this selected, all buffers passed to the TrustZone must be allocated + using the TZMem allocator or else the TrustZone will refuse to use them. + endchoice config QCOM_SCM_DOWNLOAD_MODE_DEFAULT diff --git a/drivers/firmware/qcom/qcom_tzmem.c b/drivers/firmware/qcom/qcom_tzmem.c index eee51fed756e..b3137844fe43 100644 --- a/drivers/firmware/qcom/qcom_tzmem.c +++ b/drivers/firmware/qcom/qcom_tzmem.c @@ -55,7 +55,72 @@ static void qcom_tzmem_cleanup_pool(struct qcom_tzmem_pool *pool) } -#endif /* CONFIG_QCOM_TZMEM_MODE_DEFAULT */ +#elif IS_ENABLED(CONFIG_QCOM_TZMEM_MODE_SHMBRIDGE) + +#include + +#define QCOM_SHM_BRIDGE_NUM_VM_SHIFT 9 + +static bool qcom_tzmem_using_shm_bridge; + +static int qcom_tzmem_init(void) +{ + int ret; + + ret = qcom_scm_shm_bridge_enable(); + if (ret == -EOPNOTSUPP) { + dev_info(qcom_tzmem_dev, "SHM Bridge not supported\n"); + ret = 0; + } + + if (!ret) + qcom_tzmem_using_shm_bridge = true; + + return ret; +} + +static int qcom_tzmem_init_pool(struct qcom_tzmem_pool *pool) +{ + u64 pfn_and_ns_perm, ipfn_and_s_perm, size_and_flags, ns_perms, *handle; + int ret; + + if (!qcom_tzmem_using_shm_bridge) + return 0; + + ns_perms = (QCOM_SCM_PERM_WRITE | QCOM_SCM_PERM_READ); + pfn_and_ns_perm = (u64)pool->pbase | ns_perms; + ipfn_and_s_perm = (u64)pool->pbase | ns_perms; + size_and_flags = pool->size | (1 << QCOM_SHM_BRIDGE_NUM_VM_SHIFT); + + handle = kzalloc(sizeof(*handle), GFP_KERNEL); + if (!handle) + return -ENOMEM; + + ret = qcom_scm_shm_bridge_create(qcom_tzmem_dev, pfn_and_ns_perm, + ipfn_and_s_perm, size_and_flags, + QCOM_SCM_VMID_HLOS, handle); + if (ret) { + kfree(handle); + return ret; + } + + pool->priv = handle; + + return 0; +} + +static void qcom_tzmem_cleanup_pool(struct qcom_tzmem_pool *pool) +{ + u64 *handle = pool->priv; + + if (!qcom_tzmem_using_shm_bridge) + return; + + qcom_scm_shm_bridge_delete(qcom_tzmem_dev, *handle); + kfree(handle); +} + +#endif /* CONFIG_QCOM_TZMEM_MODE_SHMBRIDGE */ /** * qcom_tzmem_pool_new() - Create a new TZ memory pool. From patchwork Mon Oct 9 15:34:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13413940 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 A2AD9E95A9F for ; Mon, 9 Oct 2023 15:35:52 +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=Z02Y8zJZtGEKOXf+eNiXuz1dPKqyNuOinz+VMxnntU0=; b=2Jud5JLSa45rc6 QsRaBFky5HZhQZINwoMC8qaVMTOgQiW3s1PM9qRfaQ8Bx4PS1Oq0zvtpac7R40wlriZWepHWBEAmu 7ziGH7jhidAq1S2oqpRuTYblTatGEskIxb01d65uV8w0+//sbo82acv4SETKP9esYABnfStFlBl6j 1WQzEN9BEzw+psQDFYcTC8MwT8WQMcQ+1YQ2/E7kzbGZ0fEf6V2vEcMEkm2cKpR6n6K60SXq5X/3I hlAzMBSI2+xq2qaKrnzXyAQ4H/Bqmkq9RQfEDeWLwPWN3ABNK8sQoINaPtesj6V0VufrA1YWSk48G 600uKeQVGbpHYipJkJUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHy-00B4MB-2R; Mon, 09 Oct 2023 15:35:22 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHb-00B44M-0k for linux-arm-kernel@lists.infradead.org; Mon, 09 Oct 2023 15:35:02 +0000 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-317c3ac7339so4265659f8f.0 for ; Mon, 09 Oct 2023 08:34:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1696865698; x=1697470498; 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=yU/L4mkVh98Gvp/+ieSh1ph2o5TQmVYw2ScTJAizm9U=; b=ZFI94Zk/vO+5eXW+y4LfWKQdCiKcqnthYW3y6kNZxmCVXQShOg97eFAzwWkIIudAqJ l7yt2VT80dMlPA0V0m3RxPzrjuF/UGhnBloj4JgjVDujHf0rpeW+8cwUW13dpjTbwgSn L7avXoLhfRSX8nOTgsDUOaqZMpaakaPQzoBYBN9OkMDde8BCxcoicKEQJlEk+jBMiHDm FHk2/8/bTrdUwknGvetwrUs6R42DJ/LY2GIpOY78c0OLI6FBjilovnMf1umk8BBbkM8b y4CQgMWlncrd9rpKGdFFMdQH94Yuml7G0vtYegnGC5ioByk9O/Wvep37xYjF3thX2epb ppsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696865698; x=1697470498; 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=yU/L4mkVh98Gvp/+ieSh1ph2o5TQmVYw2ScTJAizm9U=; b=KSndru0i5BEw3JXCBJ46JUgWxp+GLbwW5zKfPrR3z5sHnRpTR3Cn4/wck9q+fYWWiD D3rDQyyfPcUmpjdFH/DOhfpov5ZqCbgEsAAm7upX9n6f9RovSL07bByy2aA5GzfQUMww 1z/YcyOmIbaKTq92Weo0J9blTWspMphJqgx1OT4lUFsF0BiXaeyc/bgh3VYKDPi/+BnL 68xezczf4+dv3JLgAGA7wnI0WxirO9OKi5GUYkXva7K8VqL7GmE94J32xNKJooBhsowN AifjnWyNxpr64Z9cSJJh5faZviwG5ecoDELNeNw8mw1kvh3Stc9QjYVZxj2xo55+70YN ibxQ== X-Gm-Message-State: AOJu0YxVw2vg71xmN15sYIhBPHUQOoGA8SUS5b3s20324TZM2ISuK8qX eShyu9FyT+tB2JQRs20NkiUdLw== X-Google-Smtp-Source: AGHT+IHYcrsYv1nA5MYThjpwSuTukqOWDTcfUOtrCI/nJyTGzDEIOg2pbtM2LIVFV2JlyVtYlvoKQg== X-Received: by 2002:a5d:54cf:0:b0:31f:ffd1:6cf4 with SMTP id x15-20020a5d54cf000000b0031fffd16cf4mr12817049wrv.12.1696865697570; Mon, 09 Oct 2023 08:34:57 -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.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:34:57 -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 14/15] firmware: qcom: scm: clarify the comment in qcom_scm_pas_init_image() Date: Mon, 9 Oct 2023 17:34:26 +0200 Message-Id: <20231009153427.20951-15-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_083459_286022_57382A23 X-CRM114-Status: GOOD ( 14.07 ) 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 The "memory protection" mechanism mentioned in the comment is the SHM Bridge. This is also the reason why we do not convert this call to using the TM mem allocator. Signed-off-by: Bartosz Golaszewski --- drivers/firmware/qcom/qcom_scm.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c index 839773270a21..8a2475ced10a 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -563,9 +563,13 @@ int qcom_scm_pas_init_image(u32 peripheral, const void *metadata, size_t size, struct qcom_scm_res res; /* - * During the scm call memory protection will be enabled for the meta - * data blob, so make sure it's physically contiguous, 4K aligned and - * non-cachable to avoid XPU violations. + * During the SCM call the TrustZone will make the buffer containing + * the program data into an SHM Bridge. This is why we exceptionally + * must not use the TrustZone memory allocator here as - depending on + * Kconfig - it may already use the SHM Bridge mechanism internally. + * + * If we pass a buffer that is already part of an SHM Bridge to this + * call, it will fail. */ mdata_buf = dma_alloc_coherent(__scm->dev, size, &mdata_phys, GFP_KERNEL); From patchwork Mon Oct 9 15:34:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13413941 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 57B10E95A9E for ; Mon, 9 Oct 2023 15:35: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=zt+EM1rwdwQ32uCDm7W0n+jKPyP94XKVFkWq/H6Z+eQ=; b=uYQ8pRvl1lsUli HTSB4+a/dbNG9qJJ+N18CtyFrWO3E0HG4PgQ34NYT+Js8T2d+2QYhFDl2FhYfYw1go2PKn+FYIGVU KW5IdZLxMHe0LUOWp0Hc1Fkpc7xJ1MXiVZwExtO3SScIP15fXHx4O5Ro/U9uFWcfiE2M2GzrUEhr+ s7H44m4npKedR9NT6KIeb1DG4ZUC+6MXcI5IxwFB9xr2HO92lP4tp33sM9/73O82bja41f/1JSe/+ GGFWIQsaR/XQGa2jqrxDZ8Xjhhv5YLUaLReP3khkpvWH9+XJnHKUGrIhXmwxPU9bat+bpkyuGeKoA W6VQsXDql7GTUeZhVJgQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHx-00B4LI-2x; Mon, 09 Oct 2023 15:35:21 +0000 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpsHc-00B44e-0n for linux-arm-kernel@lists.infradead.org; Mon, 09 Oct 2023 15:35:01 +0000 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-32320381a07so4642324f8f.0 for ; Mon, 09 Oct 2023 08:34:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1696865698; x=1697470498; 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=ICq8xSC80Kt4obE0o4+sSt1jGbe7ldZCyofAgnJ+E2Q=; b=r3Tjl/jJvyb+4ISeUvXoxUe8LHMMBsgsjZY9MTsNzeeteqF+JYSV9Uq9V/G+hcwWjo lQ7AF+dQNh5stM6ehzRpg2nabi/roDV7mJr4yNeEjdKKMlbfevIEzqkQJpYtEjZOOPEb +hRWQZXqUmcUdWx3DRNyDR5JO6SKXmBSfHq970P6QonYgWZubgv2Xdy7vH0fMf6LeKeT etNRtguXZGyea5RdyKw55akNhWzDkdDMiC9g/NUNQXKiOOPLE6mhOeGb4gFlE9hEAyaU TXl42WyMHuIIqvV5tvFyVkg0F1iwmZy60gWcaGz3knbBE4u/QMC2clBVmtz59Vu/j+5j ODCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696865698; x=1697470498; 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=ICq8xSC80Kt4obE0o4+sSt1jGbe7ldZCyofAgnJ+E2Q=; b=J8hvJ5wS7ohEWAdU+NGS5JOM4QkltAGLfCIYZ6H6685uTw9EC0OBtYI1hCZCiE+Kzj /L3CJuKXnfVbi530p/o2wa4tgxIBVx2vhy3yFbZ+weoB9SRc6OuZENV9B8fiUTwerxVq xHojsv6aeAvDtm6+hgmFWvnj81lH1Dty0ZysnNHnq6DK5o+FKRbnHe5OBKOGIyZ/kX5B h59mJ3dajqEUJECA+jFkr6lbhiP+bVIkN56PaobwRK9T4Ac/iTd/HL3Vv75Kyw+FRtt+ HHIWnEyClRTwChM8lwq1jVF8iqAkBL6yXYG7qUd84As9DZkviILeWs9JnzjIiiWF7IFz UQsQ== X-Gm-Message-State: AOJu0Yx65bXjMRvwcvbOP1XQLKmUcW6x+LbudSxw8tqFmw/xXnh6Axrz kuIOVbTf7CSsZJ9OC3O6QE9tpg== X-Google-Smtp-Source: AGHT+IGSVNNDH76sRB3Lqa5m+uNOKv1cgVjk/f2Eil+mLsb6i7DQTO49NsVCo55KWQXwRnMHeDJ5SQ== X-Received: by 2002:adf:f08f:0:b0:318:f7a:e3c8 with SMTP id n15-20020adff08f000000b003180f7ae3c8mr15642287wro.57.1696865698736; Mon, 09 Oct 2023 08:34:58 -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.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:34:58 -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 , Catalin Marinas , Will Deacon , Arnd Bergmann Subject: [PATCH v3 15/15] arm64: defconfig: enable SHM Bridge support for the TZ memory allocator Date: Mon, 9 Oct 2023 17:34:27 +0200 Message-Id: <20231009153427.20951-16-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_083500_285065_5D353530 X-CRM114-Status: GOOD ( 11.06 ) 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 Enable SHM Bridge support in the Qualcomm TrustZone allocator by default as even on architectures that don't support it, we automatically fall back to the default behavior. Signed-off-by: Bartosz Golaszewski --- arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig index 07011114eef8..ebe97fec6e33 100644 --- a/arch/arm64/configs/defconfig +++ b/arch/arm64/configs/defconfig @@ -255,6 +255,7 @@ CONFIG_INTEL_STRATIX10_RSU=m CONFIG_EFI_CAPSULE_LOADER=y CONFIG_IMX_SCU=y CONFIG_IMX_SCU_PD=y +CONFIG_QCOM_TZMEM_MODE_SHMBRIDGE=y CONFIG_GNSS=m CONFIG_GNSS_MTK_SERIAL=m CONFIG_MTD=y