From patchwork Fri Oct 13 11:48:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13420780 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 6ACBBC46CA1 for ; Fri, 13 Oct 2023 11:49: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=yYFPlWaV66uspTZLgXYVKmEiYgnI7mbK6YEbJaXEfhg=; b=3KtcRAhu3DPvgq tPcafiK93PuEJY0lOOxDo5VMSCt8yEJvP6HUl3qP82DeofUDjH32d1Pf909Y7zwG8U2V2kFtlTDXO yTwePy+TKkyPALVXZ/7C+pb3sUrtEjhIdlR57ZdUzCIPRYZsTfk/CvEHkDQ52s/pL0YObc3DEOmwj PvuMQv1DVhT8mMtmK5YJkB3i0R+THI9FQFDw5rskF0jSMOupcOGkus6tN5c7FihYsPwJVLu+3gBsC fI4oKRcUQq8Qq7U77WZgZ+XVPFiWurtbU9kqQ/IhqObPkjrsjJ2U0lchNSbRXFr8yENUQS+yfxXxY s8M/Una2AOt8br1CeeEw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qrGf4-003LRC-2l; Fri, 13 Oct 2023 11:48:58 +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 1qrGf1-003LP4-1N for linux-arm-kernel@lists.infradead.org; Fri, 13 Oct 2023 11:48:57 +0000 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-406618d0992so20805875e9.0 for ; Fri, 13 Oct 2023 04:48:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697197734; x=1697802534; 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=M6K09Y088XexdMauihB7tdz9YQTYF7/0bl19cPr5Q5A=; b=v8aXPq/c0j8+HUjntdq9DIg0mcLRwv2jDRlPt4fcjQa5eDgpAq69jcVWBmm54HxCXd /CfrN4/cdX48UZOcqejzabJKBDvFYHU35GzIboQgRwU/js54vB9qQ1mByMr+Z08ZkqFN F2XMYUjxm1tN9tIpSDBOdjF1iunC3yKiCtftC7cH8OBtOA6qaxULXf0qeZ8DYb/CqvCa crqa/RHOEHifUYczbGYus1nlroCw3X5NHGw8LfKlhBdeg6M8wSeGya5kdREtn/1W7wbW AYn0pXF53yz96BtcQVYBAtf69wDQI38XYVqQlMjdpCifI8hXHqeCtCXpy8IjC/JnjlHn aWoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697197734; x=1697802534; 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=M6K09Y088XexdMauihB7tdz9YQTYF7/0bl19cPr5Q5A=; b=oWTJdCykO+Qp+P0NVZxgq4VTl7VMRAt227fUHmupewaoB8hNd0nBGsHuxEm07aW4SH +pydB3PY6zNeF+pPlmOaAgb1kJAs0vfna7rqBUcArD2JsQDAN+97JQfSAIw4REnGVpt5 iYBS0nPT19bSueQwk3G3U3kgoBl4EqL18pysUqO93pYT6cb6zab4/Y0b08uVki8dKErA OPWvZqb77NtVW3e/c8jAIpSvrq9tEehXzQgqnoN88DaJidw3atLFMoCT7ufGl7BVCWtg iVF1k3feBXek5tVceGBn0HTk7kU1LAk/783ivcmU9fO/e341xYkg0qO1Uy6vtHsuGcsK j2gQ== X-Gm-Message-State: AOJu0Yx3pgEIO/8lD44XxMxx7nSCWUg7lVOfSPLysllJi7QNFO9nzhAP uP4ukhbCauLjW5+0MjUMA71fGQ== X-Google-Smtp-Source: AGHT+IEJPz0H2qQX8CUPXs+F4O0gQvXaW4Tl6lcsbDcdyUJFwnfqxdX6pJCmcKkqyhn1RigNOYD/6Q== X-Received: by 2002:a1c:7419:0:b0:405:7b92:453e with SMTP id p25-20020a1c7419000000b004057b92453emr23606459wmc.37.1697197733668; Fri, 13 Oct 2023 04:48:53 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4209:13a:988d:80be]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c1c1700b00407754b998dsm974509wms.27.2023.10.13.04.48.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 04:48: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 v4 01/15] firmware: qcom: move Qualcomm code into its own directory Date: Fri, 13 Oct 2023 13:48:29 +0200 Message-Id: <20231013114843.63205-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231013114843.63205-1-brgl@bgdev.pl> References: <20231013114843.63205-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231013_044855_690769_348C2624 X-CRM114-Status: GOOD ( 21.84 ) 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 0ad7caea2ee2..eac76b8de7e5 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 Fri Oct 13 11:48:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13420781 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 D8A55CDB47E for ; Fri, 13 Oct 2023 11:49: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=uScs4grQ/MSnFKgCz3Zgcu5zc737oeD3CRXTUPWRN58=; b=PnmK7sFmP/TnNP pt/iijVfAJe2b3D0BhCynV3Igq5wUf3zXAIL2P8lf6gv2vJcUxl+Z3FIbkuBAdhWOw7yNkAt5r7N9 33khYfMV/cAVwzE7iTKVh/gPwTo32oJzxfbapblDx2CgWywZxGVmi66ON0C8ERQNOJYgUbWhIauNT GyjQ7N/++iBo3fvEzLBy6PmAwwE3VtRsqURwxyxY7ZyjcdN0D0EvT6Xe3d0bwDIAikvQZSAIMtXEF W/V+Uqiul6Y4hmzAxGCpWT7j1vOhrsJpSg6BT4X1Y+B5ED0EMPkC/3N9YdjAHwPudi91RFLkMBzRi Z6Di3iFjpFJgXjDpwSsw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qrGf4-003LQs-10; Fri, 13 Oct 2023 11:48:58 +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 1qrGf1-003LPC-2k for linux-arm-kernel@lists.infradead.org; Fri, 13 Oct 2023 11:48:57 +0000 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-40566f89f6eso23846305e9.3 for ; Fri, 13 Oct 2023 04:48:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697197734; x=1697802534; 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=Z/djleLEuuC3lp+936owLmRGaug8G9ZraHIR1nlDHkk=; b=agMSnl72lBdiBriMRpJ7fMDo0QtssvtWC+vZTSOosa9oYSb/S+iuvV5L/EpQgnfF0u H00zIM5Ew6X7tGFet0sIRfIytm+wV9KonmYTMF/D5oTK6DtiyBL0vhRL4euMMfGvTI5G irJBDg50aSNudFhhZu+epUAczkNjPlCJN6C9qpjZhcaPLKoIb6cIqCWilSKHEJgNZ3/b OCqTkDUZNteitxLVDtcAJBhQ5j7QlPTM4/vMrab4I5Ii1WuS6bFmkalc5mEbHVsgaGht XUaNssZ+Xt7GbuVlE9OqGMVsqU5+h2+xOTkGPDuEpqLbPD4pZphHCjvTIpKnFOagOj5f rjWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697197734; x=1697802534; 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=Z/djleLEuuC3lp+936owLmRGaug8G9ZraHIR1nlDHkk=; b=rOrE39dqx+YLNukX5vh0w0L+RzEMl0uZUODmFL+tG+x3NJjsk6L1UxXuHkHM+3kX7P xb8xsApn54qwifIr0+u7fHL0TI6/7liZczWUjA3b4HOKy5hTzMu/2syzvV24rYQDSWwP Oe26NEksbHN1neG8JD+OHzWrXYkPXanALTHZoHqwEzPFPuICbIBTOrEfIdUKFJv7G/Iu g5ybdwfsdUtCYiF8HrC0l3j671aVB47rdnxiX1fHTrT5ix4DB7hmhl4PqxeIhfHgiVI0 ZHAIU6Uba6iAgjY8nC4RNDZgT5ZVMjFn6s7UWXpMFORAoILQjXzrydoMMktw7ubT/6aZ l77Q== X-Gm-Message-State: AOJu0YzWI80S3xr58CnbATpa4F8JPhF6+tzXoj36OPdWxiUfmIJCsobg f8G9wrZ/BQKyJqz4waYNCRXNkg== X-Google-Smtp-Source: AGHT+IEnqeUgh11RR5em7SuKq8IrgD1o4vEng+unT6JpXvnQhWSAAdNm4wxzhZFquoM5eiAo/RcP8g== X-Received: by 2002:a5d:5106:0:b0:32d:a101:689d with SMTP id s6-20020a5d5106000000b0032da101689dmr332421wrt.56.1697197734660; Fri, 13 Oct 2023 04:48:54 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4209:13a:988d:80be]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c1c1700b00407754b998dsm974509wms.27.2023.10.13.04.48.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 04:48: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 v4 02/15] firmware: qcom: scm: add a missing forward declaration for struct device Date: Fri, 13 Oct 2023 13:48:30 +0200 Message-Id: <20231013114843.63205-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231013114843.63205-1-brgl@bgdev.pl> References: <20231013114843.63205-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231013_044855_889477_A98DCCDD X-CRM114-Status: UNSURE ( 9.76 ) X-CRM114-Notice: Please train this message. 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 Fri Oct 13 11:48:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13420782 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 27615CDB47E for ; Fri, 13 Oct 2023 11:49:30 +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=G52lCfrfXvV3IMtgI5vNqVt91ZQIKwhXrXAtLYoDi/4=; b=yDI3QB6x7D2JxI rdRDKnr9f4VNMS11AqhKBAGGBv8fx6HWKD2lGJ3q/FN149RcpaDZmb6LPFt/ggKTrazMGxMt/4UEJ kaAPHCRr16lDdwOVGbhOYo53iuByFIzihRlp+3kxtC7WEvk5LK8CmiuutuVriyMiPl3/rbzHw+eHP Bcp/ybchVzfUDi/Qm7riohcnE5+0uLbShPu4Oq3/YfOakV+fhBKUdLDYrrKKRADL+R1F//BeVtgzS 8m2rSeSDlJxz5XkfpW9xE/3/diScy1COe2WpLEufa4HDZyhASRPW5JfSvGGrP57t2j8iKVL819zXA JXiamF3GCBfPF28+Z/3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfD-003LWc-1b; Fri, 13 Oct 2023 11:49:07 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qrGf5-003LPz-0t for linux-arm-kernel@lists.infradead.org; Fri, 13 Oct 2023 11:49:00 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40535597f01so20533585e9.3 for ; Fri, 13 Oct 2023 04:48:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697197735; x=1697802535; 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=4lyOHM/RBgmuxKTo/vmZ0oW2gfmzXsxTpr43TXFONHQ=; b=N+CG223jZKAZj2rfS+ypF0CTt+rvo4dqRa2QPZQVTdkKFrPslQM6DUV1TgQlS8rEzz +1OTmwCY3czefemKQ5G41UAkDx4wsm9lvLAE/tyeZzlS23IrT0FN+TcOYQOcvv0OOn7N NqrR8fMWmVfXzO6g83S1wvcwckAvUlOOrAIWITZ+dMRt5RSKcIn7nUUNexkMSG/D//PJ OxstLw8Gj0424C81Ub6ZoOTHdMmlqtMlZrshT/VXXmLUqebSRjF0mHJsddQ0Tw2GK3tq WfhVwE2TdUFJHl0CwfO4vjyEj+T7+zS0BwGLoy3hyVV6WIAZ6GRIYIjC1+u81gG1OBbe xKPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697197735; x=1697802535; 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=4lyOHM/RBgmuxKTo/vmZ0oW2gfmzXsxTpr43TXFONHQ=; b=Au7jIgcrMwldvEVx6jg2YzfdzuTcS2yi0oJ1U8QmnwZRcs2FnXvXceQHaGEG7KYzrO mbBlST9WsNMjiradwafLXZ7B7/lrRIi4XuQKP+yXcrXKZxZY8bIU3mpjIv0QRljy/G7C oYih1tMUTOVM7FYjsy5PmSFwpaHOpk098Tdc1obUsq1QSBhO09aa4SOQ9DKrjMH1df77 cNqHDxE8MbgG//HyIwEEo3+nV/39IiqBHmKd65GVNLYL5AeUu9RXmDrhB0sz4uIH2Ahv 4Q1wYxOC9uU3XdxP9lXnD4MpGNUru8op+k/XCoHVtPnFqp2SXVBdwqkVPOTlGXn2A7WX jC9w== X-Gm-Message-State: AOJu0Yw3+Dw+wlQYuoziaqyUcYw89x3oJIBny6KX8/2pqmt01MBd9QhD mbsLYIF20bNXGZDXZwhDosk+UQ== X-Google-Smtp-Source: AGHT+IGwfVRxhdaPcrTgZudW4uBmd9NjhkZBeH0ym5/LLLLuWLxGrB4YZsbUy/eulNORH0ETqJvBVg== X-Received: by 2002:a05:600c:2a4e:b0:3fe:fc0f:52e2 with SMTP id x14-20020a05600c2a4e00b003fefc0f52e2mr23680112wme.37.1697197735644; Fri, 13 Oct 2023 04:48:55 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4209:13a:988d:80be]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c1c1700b00407754b998dsm974509wms.27.2023.10.13.04.48.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 04:48:55 -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 v4 03/15] firmware: qcom: scm: remove unneeded 'extern' specifiers Date: Fri, 13 Oct 2023 13:48:31 +0200 Message-Id: <20231013114843.63205-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231013114843.63205-1-brgl@bgdev.pl> References: <20231013114843.63205-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231013_044859_315413_14F9C78D X-CRM114-Status: GOOD ( 10.80 ) 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 Fri Oct 13 11:48:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13420786 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 8CA87CDB483 for ; Fri, 13 Oct 2023 11:49:39 +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=jm92JJrneQgQ8qpS7yHiZA1j1wiQeOT6ZX8fCEx4yNk=; b=2qMmxmHqcP0wez f5UL72b2vX2C0fVP4uS23ZiSI0JTHup3J7AWJWQqKiWhgvqRrdjpgo5GO/lCXH4oqKxyvpEsoO282 GmdW+qiwpZq1EHOic2S99oAN2HLUBmzFNPuhKQJ/p9jiW62T3bkqtyUcRCRMjjWLP3yei/ZXeWRUF X7sCoWTGbjDr/XsSR/mpbQpQ77DH//E32P92N5Cuh4yOzDynq6OrMzPPxPpJSanvLwh6q4YpNMEGz /3qtLtGu+inCMJaJxhyDCS1zIoaJEGlnmoMPMBkiysxPc5Ewk2SRMSMlMa8MHrA0Mhdph8s42v2PR hMRHxvSbQV2xKwT6RmVw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfE-003LXD-0L; Fri, 13 Oct 2023 11:49:08 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qrGf5-003LQH-0t for linux-arm-kernel@lists.infradead.org; Fri, 13 Oct 2023 11:49:01 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40537481094so21434635e9.0 for ; Fri, 13 Oct 2023 04:48:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697197737; x=1697802537; 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=1u5aSutwel/MgT4d0b/m8JPySgFiWzm1DTcixaYm8aY=; b=MniX1MQUY5TCt7Y6vsY+EXyl1ebmPb2IEK7fGYOM92SoMlNml15zqYk+bwJDwvZGZ+ 4CI1EINZoCds3GzYgHvCWPN5vqTCpDQybQhiralSg8OCr/hz9JidCXcrtr2EmVQBaGEn LegGFBzzO87UxQxNO+a8DfoUsWlRPiWXBXm3gTXrQS1cKL+zE8rb6eXxGTW4dv4p+Flk 9HkhAn9LKmQNxPD8ZQBIX01QtAcksCEOJXE5tuwiiEMjQ/7Vj5I8q7rCNnLP5RhhxX8/ p8e0UICatXNDZAMD8dia5h35/GdHafX8u+VVaqf0lptyigRpKhSdp74FVHICjenER2ZN gj7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697197737; x=1697802537; 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=1u5aSutwel/MgT4d0b/m8JPySgFiWzm1DTcixaYm8aY=; b=L2GhcrXrQsbwbh5xjDYGW8zMTqu1FXGpP4R5aTanNVefEz7331ps4+anqc6fY2CUDB nyVky169hV6Bn4ROBM0bbMrUNJYCPIo1a+HDz54cnrFsCvqHprZEvW3h2opDc5HDDDvv Fgp6uPVEHeVys+F7R3PEHmP16r6ffey+2xXT3BxIkktUYoTyf4s5rzB0riMw9H0qTyC4 iA6oyZtQ3KP5TI5b3gOoJVrCUzhWGMuIqhKgZtnkSrsIlE+yp0ywBLzcPPaCCfj8vZG4 ipyxJOiNaaofLO3h3bXkZORhvXm7Z6hy79p4PvdZom08HXIKmbCFqm1G0/rkYX7VcVua W5bQ== X-Gm-Message-State: AOJu0YxlrmGOwONhrgnANZbXj4rwqdzSGVvgzgB95fZSaOrewIA1bF9y AgMg/yOhR108f32wjlGzCNzbZA== X-Google-Smtp-Source: AGHT+IG12/TzzYUF8ES/v+IgawK0jbc6qqDbce54ePN0r0P+LdVtayWVK1bSZ4MjBeH6r/2uvFrF0w== X-Received: by 2002:a7b:c8c8:0:b0:402:cf9f:c02d with SMTP id f8-20020a7bc8c8000000b00402cf9fc02dmr22851158wml.8.1697197736665; Fri, 13 Oct 2023 04:48:56 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4209:13a:988d:80be]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c1c1700b00407754b998dsm974509wms.27.2023.10.13.04.48.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 04:48: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 v4 04/15] firmware: qcom: add a dedicated TrustZone buffer allocator Date: Fri, 13 Oct 2023 13:48:32 +0200 Message-Id: <20231013114843.63205-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231013114843.63205-1-brgl@bgdev.pl> References: <20231013114843.63205-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231013_044859_325239_E6F809DE X-CRM114-Status: GOOD ( 26.20 ) 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 Reviewed-by: Andrew Halaney --- drivers/firmware/qcom/Kconfig | 19 ++ drivers/firmware/qcom/Makefile | 1 + drivers/firmware/qcom/qcom_tzmem.c | 302 +++++++++++++++++++++++ drivers/firmware/qcom/qcom_tzmem.h | 13 + include/linux/firmware/qcom/qcom_tzmem.h | 28 +++ 5 files changed, 363 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..68ca59c5598e --- /dev/null +++ b/drivers/firmware/qcom/qcom_tzmem.c @@ -0,0 +1,302 @@ +// 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 __rcu **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 = radix_tree_deref_slot_protected(slot, + &qcom_tzmem_chunks_lock); + + 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 Fri Oct 13 11:48:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13420783 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 2CC8DCDB47E for ; Fri, 13 Oct 2023 11:49:33 +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=ecvo8lmpj0V8Na uVGH7HepmQpQcZlUF8tEwH6kgBrNb7vUKSTjXSxH/LirjaBYZyrax1RdQMLqEEyCScyYujvyIvQQC sA1lWsnMgrAsajGl4QRdfookpI2SIMj581zB4dgrtt5127abypeiVSFOw3g7CgQwHSgsC9kIdMVem 5GH4StBtGD31WkWpJE7ckvxUx4RIAiAh+ux7hFeaX9Ed6NKU0DAS2ILDRBhuoLsIiTcipDWdM7EUi Vqtm+8cX6wt0b7AaJ50xDPOdNL9WUadoUSivUKzQW2uTMwnGX/XGjC2JVm9ZN5sOtlW2oIjpWzHa5 +kpCfxL7dXPPpDQwfqOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfE-003LYA-2J; Fri, 13 Oct 2023 11:49:08 +0000 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qrGf8-003LQx-1F for linux-arm-kernel@lists.infradead.org; Fri, 13 Oct 2023 11:49:03 +0000 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2c1886777d9so24280421fa.0 for ; Fri, 13 Oct 2023 04:48:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697197738; x=1697802538; 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=psLaMmmynul6cdO7LuEi2ZX+E621vBPcrAkIol2ExF5Dq4R3qkBt7X0y3Fi21dS+3E roxjejwVtmyFqJoSloJOOj9xCESSBKGRpsGkomzNeGFs5cMo+UdWlCM928TWpNrJhkoE AqJJH88WmbWHJV9oTTjKpK9Yu8X1Y8m/icVaxb/tDR4Vzlda9/AtQtXfOpanIW+YKmLo wgK1gZLIg5vNAfiZnUeS/+bLQFFFlUO+qV/7/xzz81GyErdl9HuPd5Qgx10MkAazQcIs /+659dVLKxIp17kLSbru5pNxao4VwZ32BYpjzz3xLUOjDj/vETbzj/J41VpZFM5U+659 2ZNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697197738; x=1697802538; 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=CLsJ6sSvQMYPfRXRnZfriH+lgFaggtSPPTv6oPUgGieRw83E4WWbWp+Q22TBMdGQdf VqgiO2gp5FEVhwRvLBdERnGU0ucjlmdZQa0UjEuFb3WGDPcs4gGQyYNTMIqrdi6DzYSW vgeng4H2gxp0wK3uH1D9zzmeqqLqgy65Fo/7h0RLFLvS2pJLTZ6jMBCjMX2nHF1UOUK2 l5et5GmPzcfJfdzi/toVn/jxEN7jV/lDNIADvvZP5FkCMC8Zn3bnEnS5YP1U0yDk1pQ+ see5hOYIvv/+yfQGfMoU8r4p7Z+YMlS4aPw11ojuO06fzmo74KBTOXlm/bpPiOvPGzqV mwTA== X-Gm-Message-State: AOJu0YyMiDEru5FMKhVpOWXtWzyWbG6dObC5Hbk7wCT9daFYCLGOfL4X gBUCApwFPrzk6OT818KGl4gXAQ== X-Google-Smtp-Source: AGHT+IFz8Qjgh/yQazbBJwPfv7OkJ25O7SaDUN71bdEi70FN1CMs28cCOIXQdSvGfas+S8HkijPLcA== X-Received: by 2002:a05:6512:794:b0:500:7cab:efc3 with SMTP id x20-20020a056512079400b005007cabefc3mr19151756lfr.11.1697197737691; Fri, 13 Oct 2023 04:48:57 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4209:13a:988d:80be]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c1c1700b00407754b998dsm974509wms.27.2023.10.13.04.48.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 04:48: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 v4 05/15] firmware: qcom: scm: enable the TZ mem allocator Date: Fri, 13 Oct 2023 13:48:33 +0200 Message-Id: <20231013114843.63205-6-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231013114843.63205-1-brgl@bgdev.pl> References: <20231013114843.63205-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231013_044902_423622_BB8CFF4E X-CRM114-Status: GOOD ( 14.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Bartosz Golaszewski Select the TrustZone memory allocator in Kconfig and create a pool of memory shareable with the TrustZone when probing the SCM driver. This will allow a gradual conversion of all relevant SCM calls to using the dedicated allocator. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andrew Halaney --- 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 Fri Oct 13 11:48:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13420785 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 7EC25CDB483 for ; Fri, 13 Oct 2023 11:49: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=uN5y/+VUy0faOP6mzgmkyMvtQ7zruCrAJkqj2HjTKD0=; b=TE/qOTozQXuUMr YedeTuOM8a5XN8x1zaRpaqxSks3YCYP5syOqebE8Tz5xNdixjQcEwQUxqXBJywQsKh/J0GwdmaV0f sX5/8sb/zmXBZw6EweUicXEMkWnBCiXNUi3KaSGiKjnBHtyZeE2viFgkBEE9x8btJ4eYFLMS6A86z KuO054taE66S9eg+EacDmfUjhCEe1HYkO4wA9vwuCamGVSyaoiA6AxA2P00RAgyqkm7/YQOSPfA4W OWT19ZRuRNH6iwApp5QRdwRcESmdURpXjzO0bxt0s5BeAZIRjvwhLLzPkgyOzX/aMEoH8yC/vdh+q MDAsXgloV9zbse9t9InA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfF-003LYg-0p; Fri, 13 Oct 2023 11:49:09 +0000 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qrGf9-003LRW-0R for linux-arm-kernel@lists.infradead.org; Fri, 13 Oct 2023 11:49:05 +0000 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-99c1c66876aso323574766b.2 for ; Fri, 13 Oct 2023 04:48:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697197739; x=1697802539; 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=j3Nse7R/os6r+uhJloTkZlstOK0kfuV+AzH9d866bbs=; b=gSjS1V/DeZucBTc2rKGEfX8cr9wfZl/Y9wgCWIzl9xmhmMBXsnNIVYR4nDRJPgey4M JHKttfqwqpRfNdPV/IiH0A1vC0Hbft0dxZOfjZEvnbLe9b3EAdF1yAOdG4gJLa5X3ekq dcdafgIuretxrWIm44+hqOvSp79sHLezb/ZxViOL9oepfNW8cZCOaJBtohrD0kWoyEPK yTZajeU843NAjKPUcrSIpp1wv5Kd6RAuknuEclLZBMdTa4dHmdpwLg4XQLnebQNRdKmF iMhzqepXknI25zw0vChaOzp5qogkgMir1qysr8YXS9tZNDjOvU16gs47uTidH3N2UdWS G9cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697197739; x=1697802539; 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=j3Nse7R/os6r+uhJloTkZlstOK0kfuV+AzH9d866bbs=; b=sXO2pcLLot5aSmLBAM/piabfG+rC8OHSBE1H/XBXpnG+L9CzJ99G5cCw6UIQ6ofLhW 8Vt6J3YSgbt2KKaI6c4G+kSwFkT3vN+xQbhUCh7Xvol5UAI4J5nUMlenmkREzPcH1WT9 vt8eQY+gH/Rs0fWwsbOjfnvHVtPIvKwfSnS+PljUprGjj7P4aJa28MpA07EqAXUdf6cE MNLF4pwhwag/c7MnoX347ty89n4jvMgj7m6Ox11xvI4B/QwrMOJ2yt5EcSV6puKMqkwH uy6Fp3Vuoor/V+uv4NtdY+OJlIA+DdbuVE64s8kyX90qvlhOuX/w4ce54AdLNBxxcOT0 GygA== X-Gm-Message-State: AOJu0Yzc2ihU3Ud+tAck13/YXHF7Kz+MkJWznYWwhEZnA8Lm9U+lQOmy /55lWU6vCkRdP2YKr2iIU5kevijeQub1ZWhTHyQ= X-Google-Smtp-Source: AGHT+IGzK/r2TN4EgQSOnXQyCF0UpcRY/a3MD1m0bAuE0/XpNZYSAW/0KCG6QJCBZMFmyMnddEXU7A== X-Received: by 2002:a17:906:31d6:b0:99b:ed44:1a79 with SMTP id f22-20020a17090631d600b0099bed441a79mr22961296ejf.3.1697197738752; Fri, 13 Oct 2023 04:48:58 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4209:13a:988d:80be]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c1c1700b00407754b998dsm974509wms.27.2023.10.13.04.48.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 04:48: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 Subject: [PATCH v4 06/15] firmware: qcom: scm: smc: switch to using the SCM allocator Date: Fri, 13 Oct 2023 13:48:34 +0200 Message-Id: <20231013114843.63205-7-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231013114843.63205-1-brgl@bgdev.pl> References: <20231013114843.63205-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231013_044903_178132_6DA9444D X-CRM114-Status: GOOD ( 17.08 ) 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 Fri Oct 13 11:48:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13420787 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 1D369CDB47E for ; Fri, 13 Oct 2023 11:49: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=XtF5c7RBzs4ir+KdCOWikluWcDrQtM+hoCC6fpqHFGM=; b=VqQ7EOorZaen1E /zffIWeEHd5WHtrXEzCDXNa3rrAXjp3HEJSrie3yaan2BiIwVaqYn8jHcbJHcmPMlHbieGqlfekVa wC12vXWfGWqlbILsyKKU9eSUKksvcYFJ9mTxiZQKU7I4hxzJfiaLrei4L/kpYikI2B+fFMC9JgKVS 1HHHSAfcfW71HTYGvzSLvXGoeF8pi0x/UUcCF9ZX5muz5h9pIWWFN4Ao5vYTonDNo9mV31WlSAoX3 U7bF572UXi0MnZDPrdHQESGyz0xJHgFu5NTGEe6LvlEbqYr+WXayU6Z1PuiRBGS68Jiwzw/eJAXOT bcTpYKjInXV3aW4J7U0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfY-003LkQ-2U; Fri, 13 Oct 2023 11:49:28 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfC-003LS9-1y for linux-arm-kernel@lists.infradead.org; Fri, 13 Oct 2023 11:49:09 +0000 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-406618d080eso21109555e9.2 for ; Fri, 13 Oct 2023 04:49:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697197739; x=1697802539; 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=bV1cLbdTk/GE2Km4ovXWtuC2kb2GNoS6blKXRgh+nGM=; b=rn1XPNSx8Nd/+lEDEdr8t4WTa9+QY0o0yIGHfly6LMlcM8fsVhne8MwTUiezSLnQJP e5D6KYbowwJnx06zUDV7FNf/mrj8qVivvOKz80y7GP6isO+YsHzz93ye3pP1ojXzuRoP Ct1fKhV/OSpSglibSfddQO5g4bWOZBzLFKKU/nY5e8UXO8VQ0TH81Uhxx1ljIvPdLuSt kmKh7YPjfYCAcvyrtiEKNNucMrhG05k3cQBFLwumbv/htSAFm2Nis/Ntkn8y01L1dbNn mEu+nBZHAsZ1Xnyr+SMsx/nVPz0G0U2t6wvkLQF1SPSLYdOX6vCsN+bdnfq9bYZeoTaK Jc0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697197739; x=1697802539; 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=bV1cLbdTk/GE2Km4ovXWtuC2kb2GNoS6blKXRgh+nGM=; b=G2GWhUyEaCcsys7vN5hKjYUgn2OMkJ1i0yizHZggrSz/pJZ7jnNCxkaXJpZxv0L2vo IgJRbAREU17CK4EnszchiNUmHMpfl3XOR8lPqkDoTjYUMdD2j5bDjg9G8fIxX1D9gFcv qsOlDJFkIE+qsGZRUGbxQXTtGE6py734jPGP6FVI2+16M6mWy3V/dItWnJL7l4PeIZRK LMy8MBJzJNNno2BYarvKUanJKe+RbMg75wFIPbpbv/WH7Kx3tyMFYY8deQZZnzZoX5c0 GxDdc9pkSmHZHOHdr8x1fnL4D5uh+ukfYndUUMeTWA8kQsl6JO2NtKUGfjI+2oxXpK0j P7VA== X-Gm-Message-State: AOJu0YwKy/SER2jX0R4FSlzUruxcHTgZGk5mR7Ph9SqtK/UoG/jtIONW U0e6ySzH8BQezJXLzm/1ZFZpHQ== X-Google-Smtp-Source: AGHT+IF3Nc8zH3sJY1OaHMo2jowvbl+hoUS1tU4HC3QwtdngqoGeSR6CToOVOsJr2nxuoMDYK/6OdA== X-Received: by 2002:a05:600c:2197:b0:406:5227:86f0 with SMTP id e23-20020a05600c219700b00406522786f0mr22042117wme.5.1697197739744; Fri, 13 Oct 2023 04:48:59 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4209:13a:988d:80be]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c1c1700b00407754b998dsm974509wms.27.2023.10.13.04.48.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 04:48:59 -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 v4 07/15] firmware: qcom: scm: make qcom_scm_assign_mem() use the TZ allocator Date: Fri, 13 Oct 2023 13:48:35 +0200 Message-Id: <20231013114843.63205-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231013114843.63205-1-brgl@bgdev.pl> References: <20231013114843.63205-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231013_044906_658160_CBFDD10E X-CRM114-Status: GOOD ( 11.90 ) 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 Fri Oct 13 11:48:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13420788 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 34426CDB484 for ; Fri, 13 Oct 2023 11:49:54 +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=UWUv4Hg7JrnsYRXFWLhcaTsR7GS2MEaHN5tcMI23SLo=; b=0SlFeMEc6X/ifH yd4RSZuotSsM4AQ/xtZDuvy7AcEtkVdY+EFtfW1Oiq7KUPVKcudATha3oZaVRtkPRDhOwC59OkF9q U+ObV32qFe7X66HBQw7XdtrAwUaaL3jwDLOWnvZIaySiBxjCMDbcq38a0n3zKCbN8wlRt6D93avcc q1HDOcjvE+iA5DQvdzp6abAD4VIgJ0a2PqGVESY3x6feRRq4+mK8Vvod6vFhxi4OqBWplpSKc6ySu tSz5Oobk6BcYYvt68KRHbWqHQe3SYSJY9/9SHlz2P3vwz5YYjb3ZFWaTLKeHcJN0YQRaroUeVjkNf cTGDfLYbTu43OrpupeIA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfZ-003Lkz-1X; Fri, 13 Oct 2023 11:49:29 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfC-003LST-1y for linux-arm-kernel@lists.infradead.org; Fri, 13 Oct 2023 11:49:10 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4060b623e64so13096505e9.0 for ; Fri, 13 Oct 2023 04:49:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697197741; x=1697802541; 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=o08KoJEp1jyjQ9dNvbb3XNbjVFJz+FU0ksbtua1h9kU=; b=OzUn3ICVn9dTAVbdandVRiCvdAhlyMi5oe6N4cWUc2lAerpFjrTXy0/kR54fmUN5tr tRgxcTZG0EL1W47OxvwcivN1ldwS7wGfcD+tMHIFKrv8V31/xgHutQHZglbt3maHaA69 jxCCrOROAJDK121zSYjN0eheQ8dbC6vAjgd5gX+6AkQi4Z+Kc2ii4qBQYZSUg+5+54VF gySP7QcZTcgybFyumghrnvKYvYlgk4+IllIKFgXva7tGdF+1iFFCUvTZN/QvNLJeJYfH 1Hy2JYsogajLv0gUtozaY/KNJ7nvhA6588DoNP7ZPptI2Lq5ghGWns2JH1UW845Q62B1 xXGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697197741; x=1697802541; 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=o08KoJEp1jyjQ9dNvbb3XNbjVFJz+FU0ksbtua1h9kU=; b=l870/cn7wQLAjrbqKCfbwXaMYPreOvMvhFfo48PwAJts/74qcenn07oir7sy0tm+B/ pAyWPKl6IVfhDUCvxLOelJtOrUA5YwockK9L3L35MNhFFOe4DuzPV1eGL09ldq7cJRH4 9gudb+oI6C7ZEcPilSZucG5Ic6EdpwjAuVGwMjcmSXofawfXbMqLegEvV0e3No7IBIix QD0nf6Jo+nTTANThgYBNSyaRq7CTQpPhIcwM+0zct1eK9U+0wzZV8sJG8GhQfd7RzXJx f2RUrSVZ32GCJoSGGpw6W2j1elv290ijf8fLxixpt7V2+VHY3T2MbHOuvO23BggXM0q5 04tA== X-Gm-Message-State: AOJu0YzvfEY3UntXQwYdyHZRvTtKzN4Kx/nHo0HeSvyvJsVzN3IqWDLY o6EAxpGUkTWiF43MFGSqrVnD4w== X-Google-Smtp-Source: AGHT+IESLcsz5LctZsBuJll13spdgRKIkc+P4hRt3xAF1eR7x09EBzVgQ3xnO+6UB5cR8FVzALdv8A== X-Received: by 2002:a05:600c:4f51:b0:403:aced:f7f4 with SMTP id m17-20020a05600c4f5100b00403acedf7f4mr20749395wmq.12.1697197740780; Fri, 13 Oct 2023 04:49:00 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4209:13a:988d:80be]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c1c1700b00407754b998dsm974509wms.27.2023.10.13.04.48.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 04:49:00 -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 v4 08/15] firmware: qcom: scm: make qcom_scm_ice_set_key() use the TZ allocator Date: Fri, 13 Oct 2023 13:48:36 +0200 Message-Id: <20231013114843.63205-9-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231013114843.63205-1-brgl@bgdev.pl> References: <20231013114843.63205-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231013_044906_667997_F2D15D87 X-CRM114-Status: GOOD ( 11.82 ) 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 Fri Oct 13 11:48:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13420789 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 DE335CDB482 for ; Fri, 13 Oct 2023 11:49:53 +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=HvHeNrLtE99oAyaYkdnbAVwgNqQk/L8DwgtX7dSNjAc=; b=X7iqHKNXWtACp+ rckXfYxy4I4nPFVKkP9PXRexa3GT3iRIptX8pL4p3W7Z9f6rvPJf0wX/6vP97yeEe/EcjjNqHwub6 smxDR+vV9S1ETuG0BJ0bhfd1WKr/4JDkUFttiWG08q9sNDqoaV3L+0kym06EKl2OlmC9VGbZ37Bq4 r0DbyqDhHelTT02Nm/TOGcxwQ9imT7lP7dxIY++Sx9e7H6xU3SESh/bfPo9QEPcKKG0D5gAWwSVca s1Vr1i92TPACOTb2U/8exmXqwKRyU68p1aEdS8EfxYwCQ0fVBw65GjExFOAFOMkIS0tSA07fWiE2h eTkPGfG/GR/aAutAuD0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfa-003LmH-2X; Fri, 13 Oct 2023 11:49:30 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfD-003LT1-0J for linux-arm-kernel@lists.infradead.org; Fri, 13 Oct 2023 11:49:11 +0000 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4066692ad35so20910885e9.1 for ; Fri, 13 Oct 2023 04:49:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697197742; x=1697802542; 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=p/0qKoBBzx1o8heobCmZaZFWvw6elFeS/Pei4C+kHSs=; b=xYpR3FsUCNTKPkeKfGXMbzIRD03XRR0GHZoiiQ7XfUgMzuG7juPCrTzx/0ywm7zZCD fdw4v+EQc6vI9pMW3hSY1P22QjB8H2rEWHT4SfTOrSVWlAUxGkdunAkIu7mE+9SjLxbV juuw93j6v2rCM3r8IqCjIEb5CPzeVVUFBNWZVjd7+AMTvjsMZKs0thQsxHNXdGjswlc8 2L6cOKHedMe7tq0px8HNTpBC2LW+ZXfDbNzYvdgc5zLJ8AFLTGfgCCcU75HM3sg2In2a PXOISqj0M93HWwpPUjsnQ1F2WVNIB1Fu60qqLlZs4MZq2rtRhExR8WhEsHIuI0suVzmJ 4xvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697197742; x=1697802542; 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=p/0qKoBBzx1o8heobCmZaZFWvw6elFeS/Pei4C+kHSs=; b=NRVJasXQsytpm8DqO24UxMCCkCablL9VNk7Stpwa55HRDNIQH5QlRrm0RCgOgBBY1U ypyDl0MofYb0DDFwpPKCewrIz8WI1HVPcHQowgfZbb0Yi0U+8BpSSUCuimaWYAFVfwZg VNb6SjkkZuo6/cqcd5vtr/jHMUqBYnkxs1M9BQVTpipbz5dgCb9ZZuHLd1pactAUWO+I YbyciIq1ETrmvmBLS87O21wEFnDLMQ0onGbJbNBctRgMtubXLkTnSTvlZskkz/igce9+ WvlrdZY/YibYSo0N0e+bU+ZdhpVBnE3w6vScSQDCmdt14d/xrudSawvMVAmahjjz8BLr dpDQ== X-Gm-Message-State: AOJu0YwuC5n65tCGlFMW6XuUoWpnFwKTED1dS5Vb82W2oB4tr4yw05nm iSlKkdSC2+HmjjNAVDrRBz7sgg== X-Google-Smtp-Source: AGHT+IHoBO8HhGjm81+tFaTERty06vctUqUtTt7LVjwozBsdYYmJBEYr6WrYmoqnx9XpNk3164HUaQ== X-Received: by 2002:a1c:f718:0:b0:405:3a63:6d12 with SMTP id v24-20020a1cf718000000b004053a636d12mr23826471wmh.17.1697197741772; Fri, 13 Oct 2023 04:49:01 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4209:13a:988d:80be]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c1c1700b00407754b998dsm974509wms.27.2023.10.13.04.49.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 04:49:01 -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 v4 09/15] firmware: qcom: scm: make qcom_scm_lmh_dcvsh() use the TZ allocator Date: Fri, 13 Oct 2023 13:48:37 +0200 Message-Id: <20231013114843.63205-10-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231013114843.63205-1-brgl@bgdev.pl> References: <20231013114843.63205-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231013_044907_144757_DF12E339 X-CRM114-Status: GOOD ( 11.44 ) 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 Fri Oct 13 11:48:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13420793 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 207E1CDB482 for ; Fri, 13 Oct 2023 11:50:01 +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=H2qwdPaYZwzstIvHYl/Q2YrpR7Gb55+VkBrAHMZr/Lc=; b=tcp11XTAZwWAva iaEmKn/xKlEOoFQgH6U6yY6ekAKDfXZkVkjw14T2zuMkdKnQvnZwa5nQ2hcb3m8uJXNrUVqxuVePV x9RYFX2F+foAjja1DlUsF/7tOlDC7Y7dpvJENEv7Fug6/I/f7Nrp/miMbeRZxWRp9G3+SuPSeVN++ 7Q/STtdt5rpgSSSkyL8HzK/R/9ZXpPhFNPQFQB0CdYKcbjkFz3iC6TQ02CGnz0Bd7yfKgMlZ47If9 j4rlzWHq3o4QZV2XG2dSaYubL8HsPoqzgZSY2ZDZ1NJkgiPJ35sqHAAmXmGaEVY2qv23iVQINFZs8 Zu8R0sNMSNoK4gfoRTcw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfb-003Lmm-1M; Fri, 13 Oct 2023 11:49:31 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfE-003LTo-0r for linux-arm-kernel@lists.infradead.org; Fri, 13 Oct 2023 11:49:11 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-405524e6769so12849745e9.1 for ; Fri, 13 Oct 2023 04:49:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697197743; x=1697802543; 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=R1+SqUu3MEUpRvP0zkJ91SMCh/hUg62w85Orn9bNfZQ=; b=3act8eEcE7i06Op07CxrYvNpOTFdQReTZ3cmXhPje+VGN5Ejl6gdRDGHJESxFfEPFG GKgUr0+uS3zHMYhdy83F2ycYy7fAGRRXBqvbCpOM+dE9/JWccPrmjH5kFyF0+XDocSC+ aM8HQpjauQeM41Tmq9Wey3SgD8L43Ew4S96aD2B8gVjrdmiO5PQRMLRgrnZGZxnZLRGj XrSxZd2JEn7SITZPtclCWyfUYkyPf1hhZynoUTsZDRbeuY5KsChiqUD+JxRXZCGxESSz uHW3AQRyMBIsqa2ZYYuB6dE5H2z+u7ic/tnOxwKOCV5/2Avgsg9vc4lirZNeZo8mz1f0 yPig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697197743; x=1697802543; 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=R1+SqUu3MEUpRvP0zkJ91SMCh/hUg62w85Orn9bNfZQ=; b=MwG17AyembLtYEeY+0C089Mc0V0PF5T3kc+ZgTWZb4XrwsJcmlPqvuhxtvkLDmSPW7 Jh8SCyOcblsGchLZy2wdmLXWMqZleETTeZqPCXk9XoOTD8Ko4+p52WNJiabOu/N5f5rn otMqNstZxXFCIwo0LE+ujPThgxo7H4KnMUr4FjAb8BjEk56CLkIecRdetQ2YgrJ+K3dm LWxWLA2XjwUf60XXG29f96LQ2hlS5ETYz2yxC/SGxv5qQoCUksk9vpbuh5QQkYna5cb/ 3Ih4wbTShQizw6tlosnNC7TC7BFVmBwha7WAc9EXu06sOtVJzMMmA8MXfwaMFNwkiMY9 1SmA== X-Gm-Message-State: AOJu0YzPOo3uJhC4jHiURtVxHmFN/oZstjlrBMcrvceXYZgYquvI2k2d uuWHumUnqX9uv6yylBKwDP837w== X-Google-Smtp-Source: AGHT+IHDwKNnkQ4WyyEUpEb+olLuPuuRdwsgI6TaMaTMotsUWqpHhmc5CD14COCyN8ypkhuiPDZtdg== X-Received: by 2002:a05:600c:450a:b0:401:c7ec:b930 with SMTP id t10-20020a05600c450a00b00401c7ecb930mr18683731wmo.10.1697197743011; Fri, 13 Oct 2023 04:49:03 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4209:13a:988d:80be]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c1c1700b00407754b998dsm974509wms.27.2023.10.13.04.49.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 04:49:02 -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 v4 10/15] firmware: qcom: scm: make qcom_scm_qseecom_app_get_id() use the TZ allocator Date: Fri, 13 Oct 2023 13:48:38 +0200 Message-Id: <20231013114843.63205-11-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231013114843.63205-1-brgl@bgdev.pl> References: <20231013114843.63205-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231013_044908_327875_D0AF4F69 X-CRM114-Status: GOOD ( 11.18 ) 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 Fri Oct 13 11:48:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13420794 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 54727CDB483 for ; Fri, 13 Oct 2023 11:50:03 +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=T+lRwQ7vEnRtTHm+rVq6NF+TgOnuWwy1doSFf2Zx4WE=; b=vpecotfe7+D+eQ MWcDd9eOrNVNyzEjerAumLQ3WjLXpDtJoOVg4fI83zijItpWsv5TKnkqbMDPYlGEfWOhpLXIjlAvv K1rp7hMF6f4fwUu158RO0mgOO61Bpy4BQTaqlUrBEVxwlDOiqRuKN8MP8Xl9D8VK7YQ1vOFwhQ3um 3/WcwkikfowR97x/CVFKox1KcP8/KPELoz9mJcdiGV+YVkfWqA0WjDQQ2kRglRRujJ1UWX6NyihCQ TEZYwcD8OEpLzjAH20T9XnX88lZyXydy0nuvl+BG/+RyltlHl5bg7h2iHhtqPFlzJgX/5ErNakMYu cBRmGQbxTckGyvJ8lXFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfc-003LoH-2K; Fri, 13 Oct 2023 11:49:32 +0000 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfD-003LUI-1B for linux-arm-kernel@lists.infradead.org; Fri, 13 Oct 2023 11:49:13 +0000 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2c509f2c46cso5059581fa.1 for ; Fri, 13 Oct 2023 04:49:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697197744; x=1697802544; 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=41VI8KmeE6u7QeFzUVy2dJM+rNPhWh8a/KDGfSZmgfE=; b=bOZRP6oyUD7YYR7MG+l35mrK4muGLLhr1M1XjO4UdBgdivJzwz9U+NJ8e6oKhzQcbf 963tJc9b3Am345/c5Ce97pZh24fW1T7yz6syZXefsiGn9GHqWapQqZVJpVc9pxDbM4aa krMhpQH2rMso5eGAIY8mqR+gqt1zNUDdL1T/4Cbs0MPN0L5d1DrcqR9bDQkQpXw4axkM aFb2gnrgDWRhif6iqB8fL9fxZe9Ttcmld6b2cr/bLrhQm1qF3y8Ylshc9qimCZOXhCRB h4T13gvxCwqFAAdTXznPI8jNIrSvtm6du2UD5pE1YQliqYrI4Njj1e7qHlfWAt3wZuN4 F//w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697197744; x=1697802544; 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=41VI8KmeE6u7QeFzUVy2dJM+rNPhWh8a/KDGfSZmgfE=; b=crdEjOl6zkrc4PzXtlqQK6UJ4ESCgcwjvvlP7Eq5hl9UMjdUNW3RBLUg5RpvF+sP2I OSylGDqd4zcQ/hqOAyEZkoiCg87IcI7ltrJnja75DfWwfRCy9tPEYcPPskaRkvqEr7Mj hpwfcDG5PLlKU7Igx726vfr/I2zXuK3XG9pkvW7Yb2pdzuvA3mz3TM/+LjN/DsiUx4ge niyHQ859nnZKuFfFEIdfQF0tDQYPHmN8mkcun4/ihTSbf7KlCF+fq7i4HEdbD/qDyEYK LE+1P1RYo+mbQktwXoQxzl0T8w5IpV/Du9aFiGDUTX0hM+MRYEtEGUM5B8add0FuJvyT bQ3A== X-Gm-Message-State: AOJu0Yyc5uOxC3zIOSXohDv/rskOU4wRJc6/3uJM9beg5Tb9WXtWTUEr Mh2/EmxbTGuH/bv6lZQkRRrRJg== X-Google-Smtp-Source: AGHT+IE0D6+77y6Dv1lkam9mI8hiw9zqgGFDERMfB5/S0MW/bJaWj2c4bsozNzXSmAjkfFwlH89rKQ== X-Received: by 2002:a05:6512:3b8c:b0:4fe:af1:c3ae with SMTP id g12-20020a0565123b8c00b004fe0af1c3aemr25220906lfv.15.1697197744060; Fri, 13 Oct 2023 04:49:04 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4209:13a:988d:80be]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c1c1700b00407754b998dsm974509wms.27.2023.10.13.04.49.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 04:49:03 -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 v4 11/15] firmware: qcom: qseecom: convert to using the TZ allocator Date: Fri, 13 Oct 2023 13:48:39 +0200 Message-Id: <20231013114843.63205-12-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231013114843.63205-1-brgl@bgdev.pl> References: <20231013114843.63205-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231013_044907_412411_AA61D762 X-CRM114-Status: GOOD ( 20.93 ) 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 | 261 +++++++----------- drivers/firmware/qcom/qcom_scm.c | 30 +- include/linux/firmware/qcom/qcom_qseecom.h | 4 +- 3 files changed, 104 insertions(+), 191 deletions(-) diff --git a/drivers/firmware/qcom/qcom_qseecom_uefisecapp.c b/drivers/firmware/qcom/qcom_qseecom_uefisecapp.c index a33acdaf7b78..3a068f8b6990 100644 --- a/drivers/firmware/qcom/qcom_qseecom_uefisecapp.c +++ b/drivers/firmware/qcom/qcom_qseecom_uefisecapp.c @@ -7,17 +7,21 @@ * Copyright (C) 2023 Maximilian Luz */ +#include #include #include #include #include #include #include +#include #include #include #include #include +#include +#include /* -- Qualcomm "uefisecapp" interface definitions. -------------------------- */ @@ -253,6 +257,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 +277,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 +309,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 +332,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 +353,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 +383,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 +429,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 +459,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 +508,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 +530,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 +552,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 +612,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 +636,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 +765,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 Fri Oct 13 11:48:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13420792 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 70EB4CDB483 for ; Fri, 13 Oct 2023 11:49:59 +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=je/LZlEEMyloCW oilRNprWue3nU9p5xgfFQ3xzHfM7yWexWv+8UkrnHT2EmEUHZpSgKbD0wN/+xZBBm9u1tGvIPnNZz OjzSz0AZHthoT/b85LdHj32YHPbUpPi3wZ55oP96gaOyhEFEdUvDHHRWU39wcB855K1kOZqZBgZ1B ysCqxRvCoQbYWdvDuiIpqVew2Qc8VSKQrwMdpVEd9njLM9Vm+eW9/fysXMHQq7iJaeGaEVvO3ULL4 xv0jK5EfMWLR1v1Z4AKmgCG94tlwdjSLTC2re6DExE9/1w/dRkswQtQSsVyhqpuelIl/TU27G5m1U TwTAXCdLUgOq/rJ+JX2Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfa-003Llf-0V; Fri, 13 Oct 2023 11:49:30 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfC-003LUh-35 for linux-arm-kernel@lists.infradead.org; Fri, 13 Oct 2023 11:49:11 +0000 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4056ce55e7eso20488105e9.2 for ; Fri, 13 Oct 2023 04:49:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697197745; x=1697802545; 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=W43CZUVsg7THnC+A/r2NYwNvOiL02gwjximjNtUaUFvO6QSZxscx9iVUhTfoIxl3QW s58VTYRV+3hmOFn7dlm9O6S/r67fc8GsMyXXHr+dFxgzoHdzAbymuok0ewORfjRO2kp0 tmLcBoEYsJjo3cwE4QtyXT+Gw0UsVlKMV19izqzAfFfi7vT4pK6nMFnEmC5A5frIa8VZ y/nCNBONhZ9YYTrHqyeFh7gHJOjdBTXTYL/R/raXhIMs9hfestA6Knb6500eJHnhGGX6 Ea4Fyf6fEizJ/m8NtpGf2OsT95l6dBnUU18g3iA+At/+gPB5Z1v8ejOtgyzceF8RKiLz ud0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697197745; x=1697802545; 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=XgchmQtR49GzH3FMyjQcFmNktXP4+w6lQp/6SlPOIg+7r6PraSq0WufT9gNtmU9GA4 0tO3kMjiY8sMDeGPchuy8sHQuZZ1rzfFnkSHhx9NssiIM3alZxpwfpFDmqUF9hM6uZG7 QeFvhQKEiqvXl2pPEAHqOIgdIEiCCRq4ArcRK+pFI23JkOt0Ew2ze/jH7rVl82AQVEyz BsZEp4ZzAxAP5aJsRfKPOsrGhmfjSu6qmkVVi8mKIJ50HUhHdHPHmwPa88TA++6wcR6X vFrpACnK/2uJ/kV09RAyKR4JQmbe8a8BZkWI+4ScH+R/qTyT+kqVk3lNsxQz+DSQ8PR4 VNow== X-Gm-Message-State: AOJu0Yxzphv93ve92mTxPrlonr8yxV0TeH6HFWpOy9MPbNawhsAh9DM9 TnRHK4KWPAuPMqF+/LbJY9Z7y1agtf19qyhXlyM= X-Google-Smtp-Source: AGHT+IHL+JnqG9VRTnC2qee6NXKNNw4sjMUhEXf9wZ+4bLiyAwulp1PRme4XW3GsjZXweellxZf2mg== X-Received: by 2002:a05:600c:2146:b0:401:daf2:2735 with SMTP id v6-20020a05600c214600b00401daf22735mr22506011wml.31.1697197745234; Fri, 13 Oct 2023 04:49:05 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4209:13a:988d:80be]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c1c1700b00407754b998dsm974509wms.27.2023.10.13.04.49.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 04:49:04 -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 v4 12/15] firmware: qcom: scm: add support for SHM bridge operations Date: Fri, 13 Oct 2023 13:48:40 +0200 Message-Id: <20231013114843.63205-13-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231013114843.63205-1-brgl@bgdev.pl> References: <20231013114843.63205-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231013_044907_010067_F3C285A4 X-CRM114-Status: GOOD ( 12.65 ) 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 Acked-by: Andrew Halaney --- 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 Fri Oct 13 11:48:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13420795 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 5506ACDB482 for ; Fri, 13 Oct 2023 11:50:04 +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=AF0II0pwMBgNgwlppPSOQ3J7DSggIcnIknuUTF6k3Bc=; b=wI3WPrNcXMPJA0 V8Tb9kprbAYWvBw3MUNGSzc6K+yALHVMH3Vq6eo9ljKUhpnuZPHUHK16ksdsgEMq9Mm6kzi3IWcvw MQT4Ouih731K7dx99i6M+recko58/DmDH5QOKcysxWVkv6STJteBKKzxOWHDCwSUthoTgpTQhuBfr ICQZ6bp50zOzdhmXE92nuCt4CbxpVK6feqv8VwjkmaByQle/FgGp5nYDBTUIQdQF5ku9lzMS7bAa6 blGh0BEAXyRi2/jEgIiWvpncL6uK6kQrPT82ixvIx0iv+8eWVVcEFJs21cSWH+yZpRgYjQOPS2IUr +TfEXg79QNyUDCzwaMkA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qrGff-003Lqt-1e; Fri, 13 Oct 2023 11:49:35 +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 1qrGfF-003LVX-2w for linux-arm-kernel@lists.infradead.org; Fri, 13 Oct 2023 11:49:13 +0000 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3232be274a0so2075863f8f.1 for ; Fri, 13 Oct 2023 04:49:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697197746; x=1697802546; 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=rSmiR16212pc1VuL7g+w/nUHGx3yHes8fhbAMyz9G7w=; b=atLjzcP5B6ry09JGsn1xCAXiqXw2PsY32JVaDBo7htMZQ3hAe/zPiaeono6k+cB3iL KRd207Pj1lV1fySHo6Wm9vYkBsEuVzZlEfYrOBRgoKPm9jyMnx6Yq0XWvZCbKwE97FT4 zoa7/h16/GK+Ch0Hf8FlnEX1kOpOXMzahRETEHeEQx8q66xgWSim504dUXqYJ14c26vM +6j3suFmJbY4TjB3I7iUrLx40i4IaL+60DezH9C3GWVWdcMEnzf/2F3UKdAxYte8n57V UZegq/HH3U8FpwRsTJC2GMtsJl6XAo64rf+VmilE0/Eha44VBnl3+3JbUFty/XPkPEtg M0Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697197746; x=1697802546; 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=rSmiR16212pc1VuL7g+w/nUHGx3yHes8fhbAMyz9G7w=; b=gniNYBtQQkWmVNOXnJ4c8+HkRp2+B8rw39ooNOtML+SZeYmUcEOlBNuLu2x6re8xC8 Z2t6QTwTC5VSnxMxdjDkm1Z1Dax/CLjNVOdPL71wmHajxvgnIZqeHPGydH9Px3SHj2UY wOBprlFgGPht3iXNISWcUFN9aEU3tZbyCSkcyE1PR80q34Zj2Xv2rHZt+sf3eJRbctro ltHsDpmh6fYvtfrdn2G8ggTF5XeT+04TMRHCqnWwVmN1VxfkYQzqxkvKLSY0ZM6hOU5X y5JjMFw0bv24C9F2Q2yI7+ORSwGQcHF15MHbrao7m3+5Ef3rm/+D5VfA32QQRXe06Bpc FB/g== X-Gm-Message-State: AOJu0Yxx5yARKJI0KSpH4iB8s4tKQH6lxeYwdY3aLa0xT9TZgOumG/pE +8VfDkqjB8fGz8Kzz5hu1UNtfQ== X-Google-Smtp-Source: AGHT+IHw6L7hoq85hHTB9s+d4IbMElrOT24rixghAHk3Qto6JWh/PmpQqL5ZjyA49IDvCLwzEk1Hrw== X-Received: by 2002:a05:6000:1c6:b0:320:67:1887 with SMTP id t6-20020a05600001c600b0032000671887mr19763738wrx.28.1697197746239; Fri, 13 Oct 2023 04:49:06 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4209:13a:988d:80be]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c1c1700b00407754b998dsm974509wms.27.2023.10.13.04.49.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 04:49:05 -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 v4 13/15] firmware: qcom: tzmem: enable SHM Bridge support Date: Fri, 13 Oct 2023 13:48:41 +0200 Message-Id: <20231013114843.63205-14-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231013114843.63205-1-brgl@bgdev.pl> References: <20231013114843.63205-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231013_044909_974025_6F994BFF X-CRM114-Status: GOOD ( 17.64 ) 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 | 65 +++++++++++++++++++++++++++++- 2 files changed, 74 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 68ca59c5598e..6c4f29a00f26 100644 --- a/drivers/firmware/qcom/qcom_tzmem.c +++ b/drivers/firmware/qcom/qcom_tzmem.c @@ -55,7 +55,70 @@ 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; + 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); + + u64 *handle __free(kfree) = 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) + return ret; + + pool->priv = no_free_ptr(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 Fri Oct 13 11:48:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13420790 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 3CD03CDB47E for ; Fri, 13 Oct 2023 11:49:56 +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=GgZ5gu4gKTb5h9s1aYb9usuBCKON9dFKqc/SbuZmlOk=; b=I5/IuWvaXNUHyt C4ZEuSelI4z7mEtJ+rKuSw/aLqAMQ5TJe/NPyai1glkT0VNgoD0d6PLlMK44q5JaE6cPiEVK+wcBo E4HS0mHbO4uz+jKXpOBwA/VBfM35dBiJXh9fN+vFK38gd7KHRRlg8rt9I5LKz58SPFI9t3D22Y7Nw Kd3YNb0MQUZrnddsEZX/TrGMR0PwBfWBxLfugQ+soyXd67OgbxdV/HqEdlRVPDs+f3VR7DKnnxIzM EV46qYnIeJO+kCu/fG7IBrKEmD6VMVZpJH8uvgukIQqAtVV64ZIlk3zzway9TbhtWmNj+e3BqqA3g X80t/V0qTjQqrkR70lOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfc-003Lne-0N; Fri, 13 Oct 2023 11:49:32 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfE-003LX0-1o for linux-arm-kernel@lists.infradead.org; Fri, 13 Oct 2023 11:49:11 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40572aeb6d0so20608315e9.1 for ; Fri, 13 Oct 2023 04:49:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697197747; x=1697802547; 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=f9Heyw2bPG0qaWUlPboXZ9YrcRBEbXtxsdZV2np9Ptk=; b=CRHtzEOCk2dnqCTy/f9OIg8yK0FUq/Bq4QsYXCZ9hqCjSrOqy2Dijx4WW1aAESE5Ky TE5S8GUepVkdLU+lM0PLzLptvz9f2dugLaTDcJo1wdllpKKJYU/Ep6QUD8X4fJmW36tk vxpxXswSaKeqgaeIFNZ9r7oObup6Nfe1Rqu/aqyHjnY8gt1z+Allo4N1GPJR5doMavVq dl96Oo+Mm6tZ78g9Fi6Iz7VQFv2JU1jChAwo6NkKsoTpUTsGnYCnTC/F7mo6EBUH4LXa 8gtJA6pWrSyCFka1Ps0hwBOnZQW3nqjAWbmDeq2T8yUv9IkLzeHtB4LLIafaLe7NS+3h eepg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697197747; x=1697802547; 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=f9Heyw2bPG0qaWUlPboXZ9YrcRBEbXtxsdZV2np9Ptk=; b=tL2JWDNYijvoizhJ9dEQNSMcTH2cXzOFf7qOfNNY3r2zjYk9e/W0gVZnXHSKuQ2V/k 4szi8X5NuzJ9OmTaeuXFNy2MkyiS30Z10hqQG10Shh2ppZiM/Rra+xcs3+dSxvwtZc0a P6o1bvY54MtmRx3fH3TZN388XaKo5pHzmPsbU6KXVaKgklg6XkaCRdjSgBFgeX8DRfFH DdAahIqgdlUr0iVQs+tW4FGeq2+7JeOe4mjj7WkeqI4RcKOsd8wX7qGFZR7cGuvjXduc dgpexuDFie2Sey0rkQlVb0jnUijzCUtLrLYIKO3c1MDF0Nq3Jf8TW5aOCw/ebkaLgUoD TfjQ== X-Gm-Message-State: AOJu0Yz0DJM0mSX1BTDnJ4O89/cDKXlzXzUmQQZN/H3vWF/rxvtHRk1d SQrEfvxaV+OErc7/a+wAj/aeIg== X-Google-Smtp-Source: AGHT+IEnwo69CmHD5Qs5HcqhGzB/4dWNJStokIatU7263uXLolybJc7B7UGHuPytZ5oFSbz9IMF4RQ== X-Received: by 2002:a05:600c:3b18:b0:407:536d:47ae with SMTP id m24-20020a05600c3b1800b00407536d47aemr9754099wms.38.1697197747308; Fri, 13 Oct 2023 04:49:07 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4209:13a:988d:80be]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c1c1700b00407754b998dsm974509wms.27.2023.10.13.04.49.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 04:49:06 -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 v4 14/15] firmware: qcom: scm: clarify the comment in qcom_scm_pas_init_image() Date: Fri, 13 Oct 2023 13:48:42 +0200 Message-Id: <20231013114843.63205-15-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231013114843.63205-1-brgl@bgdev.pl> References: <20231013114843.63205-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231013_044908_602343_3E9CBB9C X-CRM114-Status: GOOD ( 13.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 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 TZ memory 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..7ba5cff6e4e7 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 hypervisor 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 Fri Oct 13 11:48:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13420791 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 E2BECCDB47E for ; Fri, 13 Oct 2023 11:49:58 +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=jSwiok9uzOfIXIe//9Fpf6vVsi5LkRd0SF21qoSXlq0=; b=MCpvxzj0NM44hL i07nPp75o+eecdMH/XRLrfAatKUPc9w0k5fUZjP5aMghjzYmKWgpk2qD1Y1x99/siNfX+HuuZ1Rtg OpQRFyhkanEoomtzMBJHtPBSibdCqW7W6Dgihl2V1HUrkP2ru5IVm9GWNkWdUMlkPKIvNMQSX3c/y Nvbj6ZJBpY7hlo/rEqzbsyPR+AkRNmRSXNv+JWPrum8Oh3wIlnAVsBwv3Btgfmu2oA8+hCYV8JT2U iuiIPGctTBtRcRBlyKAVhHpzfL8mx6vaqLKj2D1uC3xZIOsZz/m3LxBd9UNdzs7JuLBMpoVIiiET1 mYPIPdcR0aFjSR2VYg5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfd-003LpC-2w; Fri, 13 Oct 2023 11:49:33 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qrGfF-003LYO-1w for linux-arm-kernel@lists.infradead.org; Fri, 13 Oct 2023 11:49:13 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-40675f06f1fso20096065e9.1 for ; Fri, 13 Oct 2023 04:49:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697197748; x=1697802548; 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=PE/p2CAXymaVYCSJyW/v/kTP5stsCvV8KjJ1np5Cumk=; b=upLMx7Ka/R88PmOboqdydtrWdUqIICht4z2AcqTFkB6XuWr+ii+lFCJwv+ChKhpRRn lILPSrbAom6jKebJu2ucK3N8fzVqDcAxEyq65i7Nsu7gLPFsvfM4lp8aPYx7WtbOAlez X/eJgRBOsKKHqSU8Dm/atzs/9zR8XnN0To7tkioKnnd/bQUhmT8tljSy4C1NIjMFU4Kp cOzIXJkY3PNP3aUB49qBab8ueR5XN2ZbbDjZP2mm+iZuKf7TltB3zLMf0LKTNdnqsscD ApM5nk0OymFQBZEmGYZrczayIXDMFc4NkuQ+IWvbccKg4LvYH9J9+O2P9/PivME1+NUs xcSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697197748; x=1697802548; 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=PE/p2CAXymaVYCSJyW/v/kTP5stsCvV8KjJ1np5Cumk=; b=kOZBN4Zj260THi0J4AYFZuN6PglPy3j3fIAawPmBuJWT4/I73bvRC/IXDyTfCOHVXO ctET8H1kRuubb3Q7wPSHiKOl3cN5hXmPxO9DSq2igYD+7aC/yqlFqqi1KZN7kb7O1fO5 nEfD2cLYpBPeFYLN3QmxDYYAPABOYE1EPmmX4Ishpsf0Ww1MR0icZ1FCJCBr5POEx4vP wQLjHOUw4XnrmACL9GWW241wCMRa93sUQBIOYOpTPThHNgD7wkn/fxfW2yHHGFYOmzug pkmGm5PsAxQ0GHTfjkEr6W/2NAJpERqUxTF/beOle4Rml3CbVaAbmpxK4JPitulzDKHf iaNw== X-Gm-Message-State: AOJu0YzSQOz5Z+gkmJURkkGMwdmN4+5sTFIvkOC2SFwXzONSV3OjzqrM l0ASl2NAhDuPVG6K3b/UyzUpZQ== X-Google-Smtp-Source: AGHT+IE3EPZwdcV6+9c0MT7noLRZ3EscIaBUOrxg76lWbF2gmzuNksXZSHu188cOIVvgnjobPtdBNg== X-Received: by 2002:a05:600c:3659:b0:401:b425:2414 with SMTP id y25-20020a05600c365900b00401b4252414mr21070016wmq.18.1697197748446; Fri, 13 Oct 2023 04:49:08 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4209:13a:988d:80be]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c1c1700b00407754b998dsm974509wms.27.2023.10.13.04.49.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 04:49:08 -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 v4 15/15] arm64: defconfig: enable SHM Bridge support for the TZ memory allocator Date: Fri, 13 Oct 2023 13:48:43 +0200 Message-Id: <20231013114843.63205-16-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231013114843.63205-1-brgl@bgdev.pl> References: <20231013114843.63205-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231013_044909_700593_5633BF4E X-CRM114-Status: GOOD ( 10.75 ) 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 b4220fff2b44..8cca74242cf6 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