From patchwork Mon May 27 12:54:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 799302 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2413015EFD8 for ; Mon, 27 May 2024 12:56:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716814608; cv=none; b=OGGzvYEOhCSiGhjEoqyLnqZiORjxVc3iSQ2ddCYY1s83QHLGso8K5dok1TGLlOCf94x9455IMIarPtBB8q48Ed4q9J91JcPcysKO0KeYuwWGpEuj6xvISXIRFnXGF2zO2EyxFFW82AjgzP3j1aSkLwtl9oVZQcXEe9XaKgwrzSA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716814608; c=relaxed/simple; bh=PmL0knyiFwKjqefmONOyJvZ61yztGXVY3oaQIhEJ+f8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=k/ATFfdHorzit4C3FzbtWIBzex3i6LwuyIsieqdNKFrT2w/m3leTzLl2MqnEuSvl3K9jCQ1TRrVcIVNHpShupYlkkJCr3zMwCPbZ4GYwBAofPY5rilNjxRcZJ34KmARLCQHvtFsrAT6ipN60T7uhh3Cio31thGL5dNfQE2jn8y4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=xRduAUbn; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="xRduAUbn" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-420180b5838so57830415e9.2 for ; Mon, 27 May 2024 05:56:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1716814605; x=1717419405; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=gSVtWnldnZQllmMbRum27BL7QtGmRA5VldXfXUSrfms=; b=xRduAUbnD8fVQlyKaI8HA7Aj387MkspIRTZJcW6yN159iUs11oceLRHHZEiZ2TDrIn T4r+aTzvZYyoHr7sMG3XunVUIQAOu6Kpn6ogB6xnujG5yuwlXMe6ZD8tojMTM2+TAAjo z6UCjWV7+CZgaA2xEwVxU+GGREUXtu8MQll4KJLwuelSErjAKb3cS3kkUjvqzaMEGtSB /HgR10kmUINxFY9QPStcCGSu16hTGC54T2PP+BZBJVH5RvMie3LiR7MMgwnOSDavPRHj 5aaViZYigaNktnRtzmWKMdz1RjUQHwGvZWC48UBInnSE3SSnKSPweIztahQJNn6HW9Pf YMTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716814605; x=1717419405; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gSVtWnldnZQllmMbRum27BL7QtGmRA5VldXfXUSrfms=; b=kBL7qutVqixGyYND0qMS99zIN3UKYZkYwWDnuaQOLLJMP4hlYqZzkpVebL5LYg0e4i YPFKN1bdIJQLH1o5PqUpVINyV4DV67sr383vq4pOsoXXSj4Gz/oc/N0dXHUy23QbT7Ae J94jcHQV2VkhLuv7E4XZIAwMoZpRM93JZb6MewL6YT7rlkXUeUgiMjvSelpAJzJ0bpOE IqtPP4ZQBkx8otWlCMdslCfqEFSuAnKh4isQmoz6NrUMGNETv/gxFlRg34MHy6GxbrOK 4vAwlBF6jkrMTF4uYultanMR52210s+hS34qP7i0GH1H4CVekEkTnxlfb08R6/MtNbGc sIqw== X-Gm-Message-State: AOJu0YxVq9R4fXN1UTFgnLnzgKQlQ1oVtBV8JYL0rHeHCMbWdF5cV7n+ Qj/1GFl/FRSE7QQHXuUU2IvWu1omMiRcWL9wE6YvcxUYr7m31y5oVwyekzY8+iM= X-Google-Smtp-Source: AGHT+IE2BMX0ptrnaHXWfVKJZpzP9Mk2ADilIQ8OTVQeSpBoDDR7X9tWYL6FLYCjkwvu7KQgee4WLg== X-Received: by 2002:a05:600c:4f90:b0:41b:f979:e19b with SMTP id 5b1f17b1804b1-42108a18a20mr82816285e9.39.1716814605588; Mon, 27 May 2024 05:56:45 -0700 (PDT) Received: from [127.0.1.1] ([2a01:cb1d:75a:e000:c322:131e:ff9d:ef41]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42100f64f98sm138753635e9.24.2024.05.27.05.56.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 05:56:45 -0700 (PDT) From: Bartosz Golaszewski Date: Mon, 27 May 2024 14:54:51 +0200 Subject: [PATCH v10 01/15] dt-bindings: firmware: qcom,scm: add memory-region for sa8775p Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240527-shm-bridge-v10-1-ce7afaa58d3a@linaro.org> References: <20240527-shm-bridge-v10-0-ce7afaa58d3a@linaro.org> In-Reply-To: <20240527-shm-bridge-v10-0-ce7afaa58d3a@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robert Marko , Das Srinagesh , Bartosz Golaszewski , Maximilian Luz , Catalin Marinas , Will Deacon , Srini Kandagatla , Arnd Bergmann , Elliot Berman , Alex Elder Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1335; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=ImiNTKfKDCEq2Ei/PD7lBaqJ136fJAWHXhcyLN3vk+c=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBmVIMHMxbQga0jenpeezcT1mcfHP3O2WFdrsXNk TEZx9DPVBSJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZlSDBwAKCRARpy6gFHHX clpRD/0aG7ylQh4jojsxziBkTqtk4v9MTFH/EBs6S4/0Gt7VqiXwXp7c4Ex8QSma6oUMTce68GH puCIl3MSyEhgTnJo3iso4WVwG+7BH8XKQ2rK8xF+iPo9jjgNpgaEMYywaw9C25BRpjDbYJqp9XM 5tJWQH19IlXgf2w41Rnd163qjS7k6+x186xEonSfeE/+Aob8+tDi3tIh/SeHp8Z6U/bg1kUqqiT KUar9IfUwX+fv+V09sWWKxAF6vRyUGslRXDg2zyYAhjIcYhLuAipMRiQ39L9LDLSE3sxBNNqRUA hq2JQGfTc6YxnIVP47k3yYj4zkETHRuyT43331yFSp7QAJRllvXTh7O5/iOAwpQzapzc2kYWAqR dBmVjrCBktferBQkVWMLlreNTIU/6xAW7N1QNrhbG4T5pkWQK6deAMJ9CF7Wg5cH5vPOmJdkKsd OWgk8piBvK1CYIz8/S0h3/fseUq+CF4q0nZhLGnAVT76VfjEmkDi3VqCiT2x30Cl4tNlvBOotIK pVFEK9AmQRHdpNqX6ehIxGQeY8yHvOF/Nz6lrfqQAuy9ooJLMjKbU3dM77bq59Cv3nwg+sIEwUK iTrVmHHfBGuU3AKGCZstJGCBkSL4TaIJHi0hWd9dbC/X/uYOtFQQpZvr0dDXqYh+HscKuIFh7Vf b9DX3Pi3DKzJ5gw== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski Document a new property (currently only for sa8775p) that describes the memory region reserved for communicating with the TrustZone. Signed-off-by: Bartosz Golaszewski --- Documentation/devicetree/bindings/firmware/qcom,scm.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Documentation/devicetree/bindings/firmware/qcom,scm.yaml b/Documentation/devicetree/bindings/firmware/qcom,scm.yaml index 47d3d2d52acd..2cc83771d8e7 100644 --- a/Documentation/devicetree/bindings/firmware/qcom,scm.yaml +++ b/Documentation/devicetree/bindings/firmware/qcom,scm.yaml @@ -93,6 +93,11 @@ properties: protocol to handle sleeping SCM calls. maxItems: 1 + memory-region: + description: + Phandle to the memory region reserved for the shared memory bridge to TZ. + maxItems: 1 + qcom,sdi-enabled: description: Indicates that the SDI (Secure Debug Image) has been enabled by TZ @@ -193,6 +198,16 @@ allOf: then: properties: interrupts: false + - if: + not: + properties: + compatible: + contains: + enum: + - qcom,scm-sa8775p + then: + properties: + memory-region: false required: - compatible From patchwork Mon May 27 12:54:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 799301 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DCE515F318 for ; Mon, 27 May 2024 12:56:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716814611; cv=none; b=myInGTucWUT+hTtzZRgGxXqVIWZA612lAgI7dkrPUu7DNshA/Nryti8O4mFlb1xN3SSgD4U67ggEOaPcofCoHgraCpyBV11ZRy4mB3m4S++keAmvt+XJemVp8JmHSWiNuX5vPdQh5Cobl+MYAXj/LouXavsW0FU6jADDUO8Safk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716814611; c=relaxed/simple; bh=IA58S7AdH2xIYDhZoMKljASxiGtz51vTFlKP2HHrFAo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=md8Tbl/y6qPi17WP1Bh4MZL+e6jvux6uWsTBqNMfk93+fs/S5i5ux0SLe5v58y28G5Dytt/AfZ4LGueeD0kaD8aGtY/PD/rPKJqPoRHctYx/oW8oMaedkxTIJzBug+IKpLwRn/asMkOZHQRmmGcm4ULznU9d/XK7VY3+ZpbV6nY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=eIWfyzc2; arc=none smtp.client-ip=209.85.167.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="eIWfyzc2" Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-5296232e00bso3391482e87.3 for ; Mon, 27 May 2024 05:56:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1716814608; x=1717419408; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=H+cLvo74QVnhzgz8Xflm3n4b7nMWc8jqZkEXgEWJK9g=; b=eIWfyzc2lSJ9dhhYPhYFEns2D7X6p61dsDcIb4gREKnVCEB3vO4gP9KuGqWqtTMnia Y6ZQsd783v39LhHkAdk4aM6YsCHyOmnqt2wq7mIaRUD/zSSH8HPEMbCn5d3v3KQl7Gbs ifXN17WhSxW/fgvJueOCdkKC7Us78R0l0Z4AoW4MaSBtVJrxjm9PmqSjzRM6kjaDZDMh 6Tu7Cb9KYhlyIYn/SqbgVrWOW39cMZv1p2B55aXgEihcxj40S9hfgA5XaFNWUDKTF+di Tgb8/Cj8rb6cHrAZZ132Ow8zomumW7KxH3Ks0S6/sGxrEm0dV3MutUStpt7yigejMBbN +oGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716814608; x=1717419408; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H+cLvo74QVnhzgz8Xflm3n4b7nMWc8jqZkEXgEWJK9g=; b=iZzPdLvdN9toi6ETjEQ5/GB/VdGp3EhHvczDCtknzqlhdmOA1OUYFmp76iRKb3r6JC d7ZDRWcwoeuwx7QqvYwZC1evqk87q90oUPUxm224dB/AcjW+PnO1OHWUCLJ0YMH47ly/ uGm1Pzpdce2hbM0p2JqFwep6NrbfkvBZdvSrEaipXJucuP6/KHdU5ch04y26FFG/vCto 6D5Y7LtoWPpdeZ80r8YIzlSoTt8zGPfonAqLStYWVAp7EKccsw803vBagqBXC24KPC/k ZdfvMxtNH8DHuzgj05IiMBAM5yudRgma4yixa0xRW19DLVANJZH4eDNuWOKKXOkAp0nT kIXA== X-Gm-Message-State: AOJu0YwEO7fyEY4jkD+Po6esC8SnHFGmLVfUrpduNIhcayqFap+TavQ8 ynJgfEFQRvaUsL4n/zqX3F9m4xEcrUOqiDJ14/ORxVeVbZQeQfdKHQK8jRogNQQ= X-Google-Smtp-Source: AGHT+IHQ8ItaW+iFK5OlRvGfWq9EA4HNWzDi5E9PtyhLZERWJa54SDX5gErpbt5Wh8NI7hgohYlWHg== X-Received: by 2002:a19:8c07:0:b0:519:5df9:d945 with SMTP id 2adb3069b0e04-529642048d7mr5320820e87.4.1716814607620; Mon, 27 May 2024 05:56:47 -0700 (PDT) Received: from [127.0.1.1] ([2a01:cb1d:75a:e000:c322:131e:ff9d:ef41]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42100f64f98sm138753635e9.24.2024.05.27.05.56.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 05:56:47 -0700 (PDT) From: Bartosz Golaszewski Date: Mon, 27 May 2024 14:54:53 +0200 Subject: [PATCH v10 03/15] firmware: qcom: scm: enable the TZ mem allocator Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240527-shm-bridge-v10-3-ce7afaa58d3a@linaro.org> References: <20240527-shm-bridge-v10-0-ce7afaa58d3a@linaro.org> In-Reply-To: <20240527-shm-bridge-v10-0-ce7afaa58d3a@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robert Marko , Das Srinagesh , Bartosz Golaszewski , Maximilian Luz , Catalin Marinas , Will Deacon , Srini Kandagatla , Arnd Bergmann , Elliot Berman , Alex Elder Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Andrew Halaney , Deepti Jaggi X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3441; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=VMZSfmk3eqpWY9NL2dFp3h21LWVeHTxpNDflrZ1eZOM=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBmVIMITyNKHp5skdmBs6KrCE/1XNv7+uwrxG3r+ wU+iovCRPOJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZlSDCAAKCRARpy6gFHHX cowGEADgV7KVfui358E++tzUTQN3sMCwCUSy7jyWtCxHOOyGfyLAH9Tyy54loxpX2KuPJMAp8XL 3TNTe8VbUq8C5btZUZzivDiObnKDb/r6mKy0VIIXmzCTN+R9tpPVLCYrnsKTFgRkchSXqT6pVkH 579wmhzUMWRDSMMhgLRG32LpWG4lfeCqpBTUzt+A4VuN/y7MRO4/LD+0cpa7RKiYRThG8UgEJf/ nqkOR1fEP8rarhb9NCd+su7Xid31VX6Nmhe6d+6tkGLo32UDzVpJvC9CULkUBPRE41TIuvqt8WM GWTVtDYOe/23q/PBQTAr9RGjoiHbw5LeiSpGYxOAHivq3F3Lse81h1jm9+24g5x9azaePNN2fx5 PuesDthSkdfBdA7BzHnru6p2XTNIl0xWbQJQbNiDVBoUJ48sm7DoVWvbKJzJUvmjsoQlfNfpNFF MqDzdLyRM3MkJSvXFACc/YmBNLrbzWrQOcMiRYPOmSVdPMHNZYPYLDnJaG0MT1aVvZ4hHOXE4/Z Q/nRTUop3ZZDiFCw5d4t/CyPCiU2z6Bpv2QpK+sCw8kEZZdaE366AdJPlUQRIleN9/VLUVGQDiU MJGkTnIkIo3nppSe/UgvlzBQ5ETN4O9jRFGLYkAYCaspvnvDx7CasHvjI60bit8IemPFj7aXYep v6XkJxmG2+pp3lg== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 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. The policy used for the pool is "on-demand" and the initial size is 0 as - depending on the config - it's possible that no SCM calls needing to allocate memory will be called. The sizes of possible allocations also vary substiantially further warranting the "on-demand" approach. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andrew Halaney Tested-by: Andrew Halaney # sc8280xp-lenovo-thinkpad-x13s Tested-by: Deepti Jaggi #sa8775p-ride Reviewed-by: Elliot Berman --- drivers/firmware/qcom/Kconfig | 1 + drivers/firmware/qcom/qcom_scm.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/drivers/firmware/qcom/Kconfig b/drivers/firmware/qcom/Kconfig index 3c495f8698e1..4634f8cecc7b 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 68f4df7e6c3c..0e7b1813e4a7 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -10,8 +10,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -22,9 +24,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); @@ -43,6 +47,8 @@ struct qcom_scm { int scm_vote_count; u64 dload_mode_addr; + + struct qcom_tzmem_pool *mempool; }; struct qcom_scm_current_perm_info { @@ -1810,6 +1816,7 @@ static irqreturn_t qcom_scm_irq_handler(int irq, void *data) static int qcom_scm_probe(struct platform_device *pdev) { + struct qcom_tzmem_pool_config pool_config; struct qcom_scm *scm; int irq, ret; @@ -1885,6 +1892,21 @@ 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"); + + memset(&pool_config, 0, sizeof(pool_config)); + pool_config.initial_size = 0; + pool_config.policy = QCOM_TZMEM_POLICY_ON_DEMAND; + pool_config.max_size = SZ_256K; + + __scm->mempool = devm_qcom_tzmem_pool_new(__scm->dev, &pool_config); + if (IS_ERR(__scm->mempool)) + return dev_err_probe(__scm->dev, PTR_ERR(__scm->mempool), + "Failed to create the SCM memory pool\n"); + /* * Initialize the QSEECOM interface. * From patchwork Mon May 27 12:54:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 799300 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 293D315ECE9 for ; Mon, 27 May 2024 12:56:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716814613; cv=none; b=rkx8N4c1L7O6RMMNODHbvgp6nwzCm6oIGHMupvR9oy3CLz82gPplyPm1O9J4rMVCuClXC11SymRsr2CrpaIH4X/hp23axIW0Ir3oaDTVg/Clpow0px2jD22aHZk1jbh2uQpUK1GQlg/F4WqB0agjU8Z0AQhM1aGzIBBi1ELVF3A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716814613; c=relaxed/simple; bh=IA1NluuyWIC8/XotvFbpj4DqgZjTYuJun/bo3v6zFBI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kz/myHKHXMeQXaDOjzRUhLCIWiUXXaEqTIk+2c17NsDtg6kvBxbcXiOWPmgHVJEDwrnvPm437UjBpNF2bU/L4U5dG0l64ppW0ksev8AEu1L2YiOGMi78ucI/QMhkGa8XeH5bA7/g1wH0MEiLrsJtPmlobIvCpyQzTE8XSYuEiyA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=BwN7a7pB; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="BwN7a7pB" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-420180b59b7so48019115e9.0 for ; Mon, 27 May 2024 05:56:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1716814608; x=1717419408; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=WF/896sdGC2fcFcBLtp8Wafg57BR7Ezd4qNrSg9FQvk=; b=BwN7a7pBxyMNT2BPrOB6//1t4gazuGS0ola5489MnPgkYFfHLf/LayfkbNmsaJ9NHz qL6mY09AnVwYf+/GpbTTN55+vsHFpFDzKDjav/oETT3mDaY7dar6jVikQr6UEL96IY5K jJ0Jod2BqYtcwi1W44/8nU+VVneU79Qu0nohZbQlc0/wBGoHuJruU+GGSUrsjvIpsl// kigZYE8gPVcQSMvfyPicbbae8yDTbD6b75fD7KTeOyntJCBt2RMgE/5IM0xDJBlBfunL mfxOQbXzYmgoFkwtXmeLY15wNNacsOJeasMv5YUM1SHkesOqkAqFOcROCLC6a3T+6ic1 ycdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716814608; x=1717419408; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WF/896sdGC2fcFcBLtp8Wafg57BR7Ezd4qNrSg9FQvk=; b=XlXcXnV2if6DALRThga7SC+zeR4+D7h6yoWSFYYkJi2zBbl2jvsrZLkCE4qiVx/lfC 7+l1wxvHRGQpD7uyjPHvnJab6WVoGlG8+Ct5MKg4I83Bp1frmRDzXbNZ22lEZx5ZtJtK 16eAKE2pwSbad2UsyMv5JFxFTZ/pyY/JgfmbRKvXvTve0VspXxSMqfvh2XxWYmDafJgm +fXoHZNY4SXi5PL84F8gWHpqAnPqp+gVoERhB3+BC8NJL1TVyMwpyQ51gWkEgFvi6nPg PnM6sa9qn5buS0hTmynPPSxe4pHLggZt08KGFm3GYev9X0pp6kRbRZq8HK0TTqpfaPwo 86pw== X-Gm-Message-State: AOJu0YwjkJHZyLPdjAwWEtQuSdDtgvcogRBM70IaQR77sb13X+7ClrzV q1+XwAMWe6xkYWheERUaCEKhleV6tFpI0t9nwR317bnqwEH1J3MQmh9mCtHY8EuZL5AW0oLxiB+ a X-Google-Smtp-Source: AGHT+IH6VchPULTEGSRUUO5sOippxyiBXFHEUeCEq0xBz+JEny96RRYZTpf8xbzdHO8n6U/xPBWnGg== X-Received: by 2002:a05:600c:5103:b0:420:1a3:dd04 with SMTP id 5b1f17b1804b1-421089eeb0emr77231195e9.24.1716814608651; Mon, 27 May 2024 05:56:48 -0700 (PDT) Received: from [127.0.1.1] ([2a01:cb1d:75a:e000:c322:131e:ff9d:ef41]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42100f64f98sm138753635e9.24.2024.05.27.05.56.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 05:56:48 -0700 (PDT) From: Bartosz Golaszewski Date: Mon, 27 May 2024 14:54:54 +0200 Subject: [PATCH v10 04/15] firmware: qcom: scm: smc: switch to using the SCM allocator Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240527-shm-bridge-v10-4-ce7afaa58d3a@linaro.org> References: <20240527-shm-bridge-v10-0-ce7afaa58d3a@linaro.org> In-Reply-To: <20240527-shm-bridge-v10-0-ce7afaa58d3a@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robert Marko , Das Srinagesh , Bartosz Golaszewski , Maximilian Luz , Catalin Marinas , Will Deacon , Srini Kandagatla , Arnd Bergmann , Elliot Berman , Alex Elder Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Andrew Halaney , Deepti Jaggi X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4759; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=h5olK4FER0ASPIH9I24ILYd6rhf4aQB9nxqDbU4jzPQ=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBmVIMIyg5jo/L/Pq/AFrA6tqCdM/FV+kOCl9Jvh 9x10vovHz6JAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZlSDCAAKCRARpy6gFHHX crPBEADcf+aTOBUDz3TteutQQXSR2p0IkTWki6VzWv78A4/keZyujHuYKtncGvbAuj+6ZKyKgMS 5sf+bvySqH8yFjx+92RWsjsEuaT8zZyFPs3sBnXGP/gzvhaGOZCAQwALHTFhJMfTbnuULIadXGf N3EmwU+nq+C5C1tA83qr2bTIc8GD8SiJMKzuT/POGAeNEKIR8EBl3n0D7U1Sna2uL/cBPltdlRi AQ5rjhLsVBGP0ISuAbA9E9EyoMFXaJVKwneZPh/yaApP/DPuFyf5BrBGautvBjPmmjXcaDV9D7X DixeVaP0uwD6B8H781xIIqrGw7HQ5Hhdm9cbXUK2fJ662TFXbBpTE7mowYiM7iV1hgIm6FkT+jC pS0IihiMPowRhrZevczmdsNs5UrIyOf/qb/i//WOiH/DPE1cYUCX3H4XPo+I7oumnPyOBmNrXuo MSUV4PhrBjHIG+pYM4Ums4XpuATvQn5gXYMLY1gGxYO/4Etxz8qpk8gzBjLxKn9a98ZpgOkTw+y kTM8l7VDe34XO/aAnTgqAmwpdnuKeUJYxHQpfBooNwgqjlzpxHEcrF3X1iE5NZjQQ3sSi6Rh94r 0B0M4JW0ase1UWp3zIvpA77sIH0nohTmnHDT6n/hiaOwAURP0yXY1yhP5WMdY+DhiWxXjBYH2xG A5JGP5lDbaY1dIQ== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 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 call. 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 Tested-by: Andrew Halaney # sc8280xp-lenovo-thinkpad-x13s Tested-by: Deepti Jaggi #sa8775p-ride Reviewed-by: Elliot Berman --- drivers/firmware/qcom/qcom_scm-smc.c | 30 ++++++++---------------------- drivers/firmware/qcom/qcom_scm.c | 5 +++++ drivers/firmware/qcom/qcom_scm.h | 3 +++ 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/drivers/firmware/qcom/qcom_scm-smc.c b/drivers/firmware/qcom/qcom_scm-smc.c index 16cf88acfa8e..dca5f3f1883b 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,10 @@ 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 0e7b1813e4a7..1d207c14afc8 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -204,6 +204,11 @@ static void qcom_scm_bw_disable(void) enum qcom_scm_convention qcom_scm_convention = SMC_CONVENTION_UNKNOWN; static DEFINE_SPINLOCK(scm_query_lock); +struct qcom_tzmem_pool *qcom_scm_get_tzmem_pool(void) +{ + return __scm->mempool; +} + static enum qcom_scm_convention __get_convention(void) { unsigned long flags; diff --git a/drivers/firmware/qcom/qcom_scm.h b/drivers/firmware/qcom/qcom_scm.h index 4532907e8489..aa7d06939f8e 100644 --- a/drivers/firmware/qcom/qcom_scm.h +++ b/drivers/firmware/qcom/qcom_scm.h @@ -5,6 +5,7 @@ #define __QCOM_SCM_INT_H struct device; +struct qcom_tzmem_pool; enum qcom_scm_convention { SMC_CONVENTION_UNKNOWN, @@ -78,6 +79,8 @@ int scm_legacy_call_atomic(struct device *dev, const struct qcom_scm_desc *desc, int scm_legacy_call(struct device *dev, const struct qcom_scm_desc *desc, struct qcom_scm_res *res); +struct qcom_tzmem_pool *qcom_scm_get_tzmem_pool(void); + #define QCOM_SCM_SVC_BOOT 0x01 #define QCOM_SCM_BOOT_SET_ADDR 0x01 #define QCOM_SCM_BOOT_TERMINATE_PC 0x02 From patchwork Mon May 27 12:54:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 799299 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 003D715FA63 for ; Mon, 27 May 2024 12:56:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716814614; cv=none; b=P66qAQxqwQbVYOR16Od7st6OeWZJ3C6E9BI+vEq+3DdQtrS78xXjiro5DZA4rqA3K0jkkNBr+3M2CULcqKSYNoEaEUafNYdSnkItTZWWcAp/Ieu3LZIWK3aC5y/8Dsq6P7fA3G569ZHgYEfdHjaiEZ8lQywHeyB/zTq6qGirIuY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716814614; c=relaxed/simple; bh=1yzAnjpudAn6GAdkPF5EAZ6GJR3hcWBOvGh/EqSoL6A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=h+6gkDieNWzjQ6Y1lPuJV9hFzlTZWYGXzkyfdGO6a/5cA6Mbuh4E4EYUU97oeGWKn2Q+chd4kwiCbXNe9Jo6TF0+OAzrPDoMxzt3Zl7lhHGtLftTk/z/IDjM7UrYYfqiWQPUSHVBZLnJyLWELwdPzSkM0OCgsoLUgY7I+seeXyo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=A/S/VATZ; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="A/S/VATZ" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4202ca70289so79104595e9.1 for ; Mon, 27 May 2024 05:56:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1716814611; x=1717419411; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=7As7Pf6G/hV1h3Ey95u5CfG80vP81J/j45cSsKKCTWU=; b=A/S/VATZd2p0Ysb9woKD3Tcbzcnv3Kzvo8RJkkCvAMAm6npsxxV9gjpW5C+aEBi6HJ UFZ/H2US0e0TMQ3jSom86UG/BpGGbwnYa/K+Y0a8Hf/d2TjNuH3BJQ7tBvNPdKUinORV iklwkJ34XUw54we+0UKZrGeFPionn5GV8nXXu6M5ZvZ4AbcyV5pfveYktePmTQpeqb72 hAZ4C0yjjUD7Ae9LUFNXMbrTpgplhKU+9RmUqW/ezwGLYdgyJnqQlQdJqtbHRrnRIFLQ wdEYGHJGKyYrxpRl4d09tJOcw2a9K9qhobRadqT1atMhZQdgftu49so+rbY3KOxPOdyH Lbkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716814611; x=1717419411; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7As7Pf6G/hV1h3Ey95u5CfG80vP81J/j45cSsKKCTWU=; b=hH5huerbG09V1hSKIej0M+GQN5Cz7M1dfR2eJsRTfq3l9O+Q6sNWoghufOK6hPgvue 30rZD/2x5uaxIjD6TwowuiytrW/dbLVIPhXLN17XVjkwqVv6QhAyFjGa7IKo16+lylkz SOv457Zzq6zR0TXFVhJbUtosDl3QwfIUeRJFc7KEH/Uwv0bEiwYmrjE8XtdVIpwptoJR 3AY4wN33TlTYrNqcOVjB73Nw6ecdffQlAH2WEfwZf66Q2zKdusdunKL8qhlobtsJqvTq SlHKJ7f56hrJQC0qQ5K7fEznkZ5HpJqJIxjRktJSKrAUqaVG+SSi4gtflLzvl5sEsQuX xyhw== X-Gm-Message-State: AOJu0Yx0WB8AFvi7EILTB9iJBjDutv3yZAV7YA9V9xTeJ3ToapIh6okm VWH+RSa8nC2r8HIN/tcxpiBS0TLIFoZxtqqiPUjHUBGKuso3niTmM4RAum7tu7A= X-Google-Smtp-Source: AGHT+IFDkoVmx20IGGH6ONvLMGqFlUHjz0w87BRBxDaAOe40qnJ2TAftpyz3HfCVNoRGzx38/nx2wA== X-Received: by 2002:a7b:c00c:0:b0:419:f31e:267c with SMTP id 5b1f17b1804b1-421089d18fcmr66894205e9.7.1716814611426; Mon, 27 May 2024 05:56:51 -0700 (PDT) Received: from [127.0.1.1] ([2a01:cb1d:75a:e000:c322:131e:ff9d:ef41]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42100f64f98sm138753635e9.24.2024.05.27.05.56.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 05:56:51 -0700 (PDT) From: Bartosz Golaszewski Date: Mon, 27 May 2024 14:54:57 +0200 Subject: [PATCH v10 07/15] firmware: qcom: scm: make qcom_scm_lmh_dcvsh() use the TZ allocator Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240527-shm-bridge-v10-7-ce7afaa58d3a@linaro.org> References: <20240527-shm-bridge-v10-0-ce7afaa58d3a@linaro.org> In-Reply-To: <20240527-shm-bridge-v10-0-ce7afaa58d3a@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robert Marko , Das Srinagesh , Bartosz Golaszewski , Maximilian Luz , Catalin Marinas , Will Deacon , Srini Kandagatla , Arnd Bergmann , Elliot Berman , Alex Elder Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Andrew Halaney , Deepti Jaggi X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1927; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=ccNi+/2cVrwYK/FlOZHun8hUJt/1weLgkQkfP/49qfM=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBmVIMJXiuUV4um9jG2pga3byQ2edB6XT9XASHYQ 37O7TvxYTuJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZlSDCQAKCRARpy6gFHHX crmDD/4wi1vmUxHQ7UxDBl5o9C5P+ki4uXhb199ow3MfzdReUFh3mwh1oSxFrinmbmOd2WE1aar AflMky+43nXzzhOvxgK99KiLLFXuqyyhfRO28EBYcEX9lwRA42XVUeXRNzTvO6S4AQu5lyFDmTc h/w9EEh/yVwP1BPhLu1IN2d0kDlFBBotxN1n2mlLuLMwjctrpVs8m5O6f0LJrrbVu45T8UIjObY LQqMQcPXGIPbnFb5f2nSxnmyeTSJx2u161fMLbNKRKjYVw8/PEMQZRTciK4D/0cIQELIEcV9Cop OhpVA4ymdYvyXcjL4669D3i2FCurPy72Gpdsgt1OIPZXRUTsVSWxqh1DbKawVHeVxHwHg9KQVha i2pxdaicQchzsD1BGmAe4WNxJoPqrOdtknzPULTgNakmH5bNS2i3U4l07MWSwzg1/w18NsyFMZ0 xePtFOfG/Tfve0hRTfEcQLbxeB9NvVZ1IInqzKspqrQvjbbrNJ4gdjfB9wjBrG36Js0edtMQmo6 5XJRWOW1EgEgx5In/OGtl1f+UpTTq9vtJ26b/8VB/Q1tMwKxbs6YWyldsQXQbUy5IkwqnDpyR3G fP5fhUyCyXYck4P8pnY6D1yXxgjvPk2ls9pSs38HSGGDHZFFShNu2YIwgzvKMFwVV5wYKJLuVPb j5FVUVOu+zowTdA== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 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 Tested-by: Andrew Halaney # sc8280xp-lenovo-thinkpad-x13s Tested-by: Deepti Jaggi #sa8775p-ride Reviewed-by: Elliot Berman --- 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 2c350de1df07..431c279df12b 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -1361,8 +1361,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 = { @@ -1377,7 +1375,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; @@ -1387,11 +1387,10 @@ int qcom_scm_lmh_dcvsh(u32 payload_fn, u32 payload_reg, u32 payload_val, payload_buf[3] = 1; payload_buf[4] = payload_val; - desc.args[0] = payload_phys; + desc.args[0] = qcom_tzmem_to_phys(payload_buf); ret = qcom_scm_call(__scm->dev, &desc, NULL); - dma_free_coherent(__scm->dev, payload_size, payload_buf, payload_phys); return ret; } EXPORT_SYMBOL_GPL(qcom_scm_lmh_dcvsh); From patchwork Mon May 27 12:54:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 799298 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EFFD115FCE0 for ; Mon, 27 May 2024 12:56:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716814617; cv=none; b=dgxVQc0hK9/zTi/2X8UoLDT4cJm0KrIFZfxesj52V3YZJVUg1Dux7RGyZevVBtCPZ49Lyz33oNyc7t+MATHiFdkXvIYJchdc43XOLW5+e+Pg5r5TUBCUxzI8VIUxQPxS75ZtFL9xNmYYuHvb7IrZkHyEjtXyigAo+clc9RZ/w0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716814617; c=relaxed/simple; bh=XmplT1Eth2GBT+MsBmS0RH/O1ZO3FLyNBUZFBguIw/E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WlDIckcYcf7NNm2E1+fXw0+9aobA1jSZ0CeF1/wvVggUsSP885iW4noGLwVjxOZQwolO2r/aSKGe6xUgbdpeIRJPz0N2dxjPJJXRqNsPKpfyI0pU7vD/21+tPPU24sxsTb442YK+3yPmJELNP39LyX4kQe1p+wIZpiiMm0uLeJU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=q5Q9ssJS; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="q5Q9ssJS" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-420298ff5b1so109153025e9.1 for ; Mon, 27 May 2024 05:56:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1716814613; x=1717419413; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=fhvojaqLs23bAYEPCIE1YC8FfHcAtFKRisrqj92CduU=; b=q5Q9ssJSP5C3mXIQFl6c0a/QW/LbRUOOo8D8lIJrSXa65MdJVa54h2uWjMniAjGHDJ N10PMrA0kvQkwZ1kOqk+4KslYAzELJnYdd4EpKHuvwhy84vZJXTDtOdKr7oKeIbKI8P7 iFAcoAfjXav13Dr8GoqjeBZNnI9EliFOBmSMKkuVXvwKisva2vNm5A+OZq/UIlojyGVy x92JtIIwG2vkBpuPlQ9j+9IH3R93bE1/cZObWHuJYMD3NmzBVhjsJ8u845u89qPf8yMz 8w2OdCriGbElEniG2vd8aymxB3wwCF/wlVurtdwjoZVq3djqG6LETOmk0BEF9EpEO9Ak Cx+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716814613; x=1717419413; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fhvojaqLs23bAYEPCIE1YC8FfHcAtFKRisrqj92CduU=; b=VxBhV5xX0fb86l2h+LbE43MQjmrR1Oq6S3OdwdGQcOinO0TGsmnahlA6Pg+YaLUcKZ XA3POjyWctta02WFcCet9Qs5Pe5s5HXsT+e7MchLJo0iONV0v1FIOXV0DqL2WZuAtXpx J82lEks8HakjrK26uC+ka+feQVeIiMgSZ7A2Hm9Bz5gsQmNU18fukpWB6pojO+AD+ljh xsJmjlHHId2S9vIm89QXmIvgD2UpI5mCb274NaCCyAUDW8njsmsw/qg3RdKYR3oprbPf vyG26RQUO4hL4VlNMBH8Gg5xjRbQyRUV/fR3ScWFq8+yNUPUJ1TRbT/a2J7Y9Q6L9xhw 7s4A== X-Gm-Message-State: AOJu0YynmAHVAeVb8sexvq0PbHya71VeAjRZiqHHA92TPXO4pfe7EORF gt8X85b0IGo7ld9M7n3l/+cxYp7f4a6RZhYcTisDnmfrI9et8VKxhi6oop3tNxM= X-Google-Smtp-Source: AGHT+IG4m5zSr76PSMCGU2YkDYwnS0avvWAVTZtE1Tr7oifa13+tgTnjC0Ocn8UepU+6h8Z+gdnXQQ== X-Received: by 2002:a05:600c:3b29:b0:41a:5521:d82c with SMTP id 5b1f17b1804b1-42108a99bafmr90788065e9.29.1716814613378; Mon, 27 May 2024 05:56:53 -0700 (PDT) Received: from [127.0.1.1] ([2a01:cb1d:75a:e000:c322:131e:ff9d:ef41]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42100f64f98sm138753635e9.24.2024.05.27.05.56.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 05:56:53 -0700 (PDT) From: Bartosz Golaszewski Date: Mon, 27 May 2024 14:54:59 +0200 Subject: [PATCH v10 09/15] firmware: qcom: qseecom: convert to using the TZ allocator Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240527-shm-bridge-v10-9-ce7afaa58d3a@linaro.org> References: <20240527-shm-bridge-v10-0-ce7afaa58d3a@linaro.org> In-Reply-To: <20240527-shm-bridge-v10-0-ce7afaa58d3a@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robert Marko , Das Srinagesh , Bartosz Golaszewski , Maximilian Luz , Catalin Marinas , Will Deacon , Srini Kandagatla , Arnd Bergmann , Elliot Berman , Alex Elder Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=20603; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=9UYkEp0GWyL1Pew3BS7qxtaWtK2iPX6YXEM6htvJYgo=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBmVIMJap56JORrcBOfC8JFSscoa4MxhdbI7OKLA 8xV5Ib1aBeJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZlSDCQAKCRARpy6gFHHX chDvEAC/VJ5dUra5ab6/z9Waus9+fjteUxhrjbF5vi2zXtmoGpAUjI3w9Vb8pKBBOyYKRo0paah pNOmMzpGVHmyilVYPYO5GssexGGiprCTVRkHyIbdH7lOJ6Vq+glYD7A45wuK7FjXxhZP71YPwFc 6tMATqWgVQgnNelMfGwuVFM99SGCFO7SA9/G+h33uEXhAog6vRBeHZR3Tibyr/nuPKl0PwyXnR4 PBRCTrlT5Qzw+5OAsqh+zF7lO45YNxmgl1lD4kilwVhET/QivX9Hk/Ymc8JZjJmCTefQiNd/HPV XgjkIaJ1amLV/ANrh/53CoEi6DmyEUIX8vkOvIxm/82eG85gJhoEmn1+Nx460tVYPRvD/Hkrt0c 3s+j0OhVuBa0nYBVbODzMGV5/8t7hy5ROzQEp6DdeW8Qin7Kj/V9heF789UbXmWRzYcxgtIisIL bGVBs8RjX9lTXG+ExfBGhCtvEMSjK2TVpMAX/B4tLAjjnYL97I61Q/nfb+ZsL8GFHPlaLu1/swO 1qRG6CEK3CnbwFLwY0YjVaUK3XvFbGprpNUGKuGjSUSLEbADXlHn68TQRLm567blu9OnBgPdHsh 5THbJIpOtKrNuzfStNf+AKEotCAOrnyp7pU3qsqaaaFzYB/WWPYLlzuPPbYr/EwRiftVI5VT+Hg MY8cgiHieyvJGMA== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 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. As this is largely a module separate from the SCM driver, let's use a separate memory pool. Set the initial size to 4K and - if we run out - add twice the current amount to the pool. Signed-off-by: Bartosz Golaszewski --- drivers/firmware/qcom/qcom_qseecom_uefisecapp.c | 256 +++++++++--------------- drivers/firmware/qcom/qcom_scm.c | 17 +- include/linux/firmware/qcom/qcom_qseecom.h | 8 +- include/linux/firmware/qcom/qcom_scm.h | 8 +- 4 files changed, 117 insertions(+), 172 deletions(-) diff --git a/drivers/firmware/qcom/qcom_qseecom_uefisecapp.c b/drivers/firmware/qcom/qcom_qseecom_uefisecapp.c index bc550ad0dbe0..6fefa4fe80e8 100644 --- a/drivers/firmware/qcom/qcom_qseecom_uefisecapp.c +++ b/drivers/firmware/qcom/qcom_qseecom_uefisecapp.c @@ -13,11 +13,14 @@ #include #include #include +#include #include #include #include #include +#include +#include /* -- Qualcomm "uefisecapp" interface definitions. -------------------------- */ @@ -272,6 +275,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) @@ -293,12 +297,11 @@ static efi_status_t qsee_uefi_get_variable(struct qcuefi_client *qcuefi, const e { struct qsee_req_uefi_get_variable *req_data; struct qsee_rsp_uefi_get_variable *rsp_data; + void *cmd_buf __free(qcom_tzmem) = NULL; unsigned long buffer_size = *data_size; - efi_status_t efi_status = EFI_SUCCESS; unsigned long name_length; - dma_addr_t cmd_buf_dma; + efi_status_t efi_status; size_t cmd_buf_size; - void *cmd_buf; size_t guid_offs; size_t name_offs; size_t req_size; @@ -333,11 +336,9 @@ static efi_status_t qsee_uefi_get_variable(struct qcuefi_client *qcuefi, const e __reqdata_offs(rsp_size, &rsp_offs) ); - cmd_buf = qseecom_dma_alloc(qcuefi->client, cmd_buf_size, &cmd_buf_dma, GFP_KERNEL); - if (!cmd_buf) { - efi_status = EFI_OUT_OF_RESOURCES; - goto out; - } + cmd_buf = qcom_tzmem_alloc(qcuefi->mempool, cmd_buf_size, GFP_KERNEL); + if (!cmd_buf) + return EFI_OUT_OF_RESOURCES; req_data = cmd_buf + req_offs; rsp_data = cmd_buf + rsp_offs; @@ -351,30 +352,22 @@ static efi_status_t qsee_uefi_get_variable(struct qcuefi_client *qcuefi, const e req_data->length = req_size; status = ucs2_strscpy(((void *)req_data) + req_data->name_offset, name, name_length); - if (status < 0) { - efi_status = EFI_INVALID_PARAMETER; - goto out_free; - } + if (status < 0) + return EFI_INVALID_PARAMETER; memcpy(((void *)req_data) + req_data->guid_offset, guid, req_data->guid_size); status = qcom_qseecom_app_send(qcuefi->client, - cmd_buf_dma + req_offs, req_size, - cmd_buf_dma + rsp_offs, rsp_size); - if (status) { - efi_status = EFI_DEVICE_ERROR; - goto out_free; - } + cmd_buf + req_offs, req_size, + cmd_buf + rsp_offs, rsp_size); + 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", @@ -388,18 +381,14 @@ static efi_status_t qsee_uefi_get_variable(struct qcuefi_client *qcuefi, const e *attributes = rsp_data->attributes; } - goto out_free; + return qsee_uefi_status_to_efi(rsp_data->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 @@ -422,22 +411,15 @@ 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: - qseecom_dma_free(qcuefi->client, cmd_buf_size, cmd_buf, cmd_buf_dma); -out: - return efi_status; + return EFI_SUCCESS; } static efi_status_t qsee_uefi_set_variable(struct qcuefi_client *qcuefi, const efi_char16_t *name, @@ -446,11 +428,9 @@ static efi_status_t qsee_uefi_set_variable(struct qcuefi_client *qcuefi, const e { struct qsee_req_uefi_set_variable *req_data; struct qsee_rsp_uefi_set_variable *rsp_data; - efi_status_t efi_status = EFI_SUCCESS; + void *cmd_buf __free(qcom_tzmem) = NULL; unsigned long name_length; - dma_addr_t cmd_buf_dma; size_t cmd_buf_size; - void *cmd_buf; size_t name_offs; size_t guid_offs; size_t data_offs; @@ -486,11 +466,9 @@ static efi_status_t qsee_uefi_set_variable(struct qcuefi_client *qcuefi, const e __reqdata_offs(sizeof(*rsp_data), &rsp_offs) ); - cmd_buf = qseecom_dma_alloc(qcuefi->client, cmd_buf_size, &cmd_buf_dma, GFP_KERNEL); - if (!cmd_buf) { - efi_status = EFI_OUT_OF_RESOURCES; - goto out; - } + cmd_buf = qcom_tzmem_alloc(qcuefi->mempool, cmd_buf_size, GFP_KERNEL); + if (!cmd_buf) + return EFI_OUT_OF_RESOURCES; req_data = cmd_buf + req_offs; rsp_data = cmd_buf + rsp_offs; @@ -506,10 +484,8 @@ static efi_status_t qsee_uefi_set_variable(struct qcuefi_client *qcuefi, const e req_data->length = req_size; status = ucs2_strscpy(((void *)req_data) + req_data->name_offset, name, name_length); - if (status < 0) { - efi_status = EFI_INVALID_PARAMETER; - goto out_free; - } + if (status < 0) + return EFI_INVALID_PARAMETER; memcpy(((void *)req_data) + req_data->guid_offset, guid, req_data->guid_size); @@ -517,33 +493,24 @@ static efi_status_t qsee_uefi_set_variable(struct qcuefi_client *qcuefi, const e memcpy(((void *)req_data) + req_data->data_offset, data, req_data->data_size); status = qcom_qseecom_app_send(qcuefi->client, - cmd_buf_dma + req_offs, req_size, - cmd_buf_dma + rsp_offs, sizeof(*rsp_data)); - if (status) { - efi_status = EFI_DEVICE_ERROR; - goto out_free; - } + cmd_buf + req_offs, req_size, + cmd_buf + rsp_offs, sizeof(*rsp_data)); + 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: - qseecom_dma_free(qcuefi->client, cmd_buf_size, cmd_buf, cmd_buf_dma); -out: - return efi_status; + return EFI_SUCCESS; } static efi_status_t qsee_uefi_get_next_variable(struct qcuefi_client *qcuefi, @@ -552,10 +519,9 @@ static efi_status_t qsee_uefi_get_next_variable(struct qcuefi_client *qcuefi, { 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; - dma_addr_t cmd_buf_dma; + void *cmd_buf __free(qcom_tzmem) = NULL; + efi_status_t efi_status; size_t cmd_buf_size; - void *cmd_buf; size_t guid_offs; size_t name_offs; size_t req_size; @@ -587,11 +553,9 @@ static efi_status_t qsee_uefi_get_next_variable(struct qcuefi_client *qcuefi, __reqdata_offs(rsp_size, &rsp_offs) ); - cmd_buf = qseecom_dma_alloc(qcuefi->client, cmd_buf_size, &cmd_buf_dma, GFP_KERNEL); - if (!cmd_buf) { - efi_status = EFI_OUT_OF_RESOURCES; - goto out; - } + cmd_buf = qcom_tzmem_alloc(qcuefi->mempool, cmd_buf_size, GFP_KERNEL); + if (!cmd_buf) + return EFI_OUT_OF_RESOURCES; req_data = cmd_buf + req_offs; rsp_data = cmd_buf + rsp_offs; @@ -606,28 +570,20 @@ static efi_status_t qsee_uefi_get_next_variable(struct qcuefi_client *qcuefi, memcpy(((void *)req_data) + req_data->guid_offset, guid, req_data->guid_size); status = ucs2_strscpy(((void *)req_data) + req_data->name_offset, name, *name_size / sizeof(*name)); - if (status < 0) { - efi_status = EFI_INVALID_PARAMETER; - goto out_free; - } + if (status < 0) + return EFI_INVALID_PARAMETER; status = qcom_qseecom_app_send(qcuefi->client, - cmd_buf_dma + req_offs, req_size, - cmd_buf_dma + rsp_offs, rsp_size); - if (status) { - efi_status = EFI_DEVICE_ERROR; - goto out_free; - } + cmd_buf + req_offs, req_size, + cmd_buf + rsp_offs, rsp_size); + 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", @@ -642,53 +598,40 @@ 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. */ - efi_status = EFI_DEVICE_ERROR; - } + return EFI_DEVICE_ERROR; -out_free: - qseecom_dma_free(qcuefi->client, cmd_buf_size, cmd_buf, cmd_buf_dma); -out: - return efi_status; + return EFI_SUCCESS; } static efi_status_t qsee_uefi_query_variable_info(struct qcuefi_client *qcuefi, u32 attr, @@ -697,10 +640,8 @@ static efi_status_t qsee_uefi_query_variable_info(struct qcuefi_client *qcuefi, { 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; - dma_addr_t cmd_buf_dma; + void *cmd_buf __free(qcom_tzmem) = NULL; size_t cmd_buf_size; - void *cmd_buf; size_t req_offs; size_t rsp_offs; int status; @@ -710,11 +651,9 @@ static efi_status_t qsee_uefi_query_variable_info(struct qcuefi_client *qcuefi, __reqdata_offs(sizeof(*rsp_data), &rsp_offs) ); - cmd_buf = qseecom_dma_alloc(qcuefi->client, cmd_buf_size, &cmd_buf_dma, GFP_KERNEL); - if (!cmd_buf) { - efi_status = EFI_OUT_OF_RESOURCES; - goto out; - } + cmd_buf = qcom_tzmem_alloc(qcuefi->mempool, cmd_buf_size, GFP_KERNEL); + if (!cmd_buf) + return EFI_OUT_OF_RESOURCES; req_data = cmd_buf + req_offs; rsp_data = cmd_buf + rsp_offs; @@ -724,28 +663,21 @@ static efi_status_t qsee_uefi_query_variable_info(struct qcuefi_client *qcuefi, req_data->length = sizeof(*req_data); status = qcom_qseecom_app_send(qcuefi->client, - cmd_buf_dma + req_offs, sizeof(*req_data), - cmd_buf_dma + rsp_offs, sizeof(*rsp_data)); - if (status) { - efi_status = EFI_DEVICE_ERROR; - goto out_free; - } + cmd_buf + req_offs, sizeof(*req_data), + cmd_buf + rsp_offs, sizeof(*rsp_data)); + 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) @@ -757,10 +689,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: - qseecom_dma_free(qcuefi->client, cmd_buf_size, cmd_buf, cmd_buf_dma); -out: - return efi_status; + return EFI_SUCCESS; } /* -- Global efivar interface. ---------------------------------------------- */ @@ -871,6 +800,7 @@ static const struct efivar_operations qcom_efivar_ops = { static int qcom_uefisecapp_probe(struct auxiliary_device *aux_dev, const struct auxiliary_device_id *aux_dev_id) { + struct qcom_tzmem_pool_config pool_config; struct qcuefi_client *qcuefi; int status; @@ -889,6 +819,16 @@ static int qcom_uefisecapp_probe(struct auxiliary_device *aux_dev, if (status) qcuefi_set_reference(NULL); + memset(&pool_config, 0, sizeof(pool_config)); + pool_config.initial_size = SZ_4K; + pool_config.policy = QCOM_TZMEM_POLICY_MULTIPLIER; + pool_config.increment = 2; + pool_config.max_size = SZ_256K; + + qcuefi->mempool = devm_qcom_tzmem_pool_new(&aux_dev->dev, &pool_config); + 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 1b64a4f4d07d..04131e60b63a 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -1588,9 +1588,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: DMA address of the request buffer sent to the app. + * @req: Request buffer sent to the app (must be TZ memory) * @req_size: Size of the request buffer. - * @rsp: DMA address of the response buffer, written to by the app. + * @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 @@ -1601,13 +1601,18 @@ EXPORT_SYMBOL_GPL(qcom_scm_qseecom_app_get_id); * * Return: Zero on success, nonzero on failure. */ -int qcom_scm_qseecom_app_send(u32 app_id, dma_addr_t req, size_t req_size, - dma_addr_t rsp, size_t rsp_size) +int qcom_scm_qseecom_app_send(u32 app_id, void *req, size_t req_size, + void *rsp, size_t rsp_size) { struct qcom_scm_qseecom_resp res = {}; struct qcom_scm_desc desc = {}; + phys_addr_t req_phys; + phys_addr_t rsp_phys; int status; + req_phys = qcom_tzmem_to_phys(req); + rsp_phys = qcom_tzmem_to_phys(rsp); + desc.owner = QSEECOM_TZ_OWNER_TZ_APPS; desc.svc = QSEECOM_TZ_SVC_APP_ID_PLACEHOLDER; desc.cmd = QSEECOM_TZ_CMD_APP_SEND; @@ -1615,9 +1620,9 @@ int qcom_scm_qseecom_app_send(u32 app_id, dma_addr_t req, size_t req_size, QCOM_SCM_RW, QCOM_SCM_VAL, QCOM_SCM_RW, QCOM_SCM_VAL); desc.args[0] = app_id; - desc.args[1] = req; + desc.args[1] = req_phys; desc.args[2] = req_size; - desc.args[3] = rsp; + desc.args[3] = rsp_phys; desc.args[4] = rsp_size; status = qcom_scm_qseecom_call(&desc, &res); diff --git a/include/linux/firmware/qcom/qcom_qseecom.h b/include/linux/firmware/qcom/qcom_qseecom.h index 366243ee9609..1dc5b3b50aa9 100644 --- a/include/linux/firmware/qcom/qcom_qseecom.h +++ b/include/linux/firmware/qcom/qcom_qseecom.h @@ -73,9 +73,9 @@ static inline void qseecom_dma_free(struct qseecom_client *client, size_t size, /** * qcom_qseecom_app_send() - Send to and receive data from a given QSEE app. * @client: The QSEECOM client associated with the target app. - * @req: DMA address of the request buffer sent to the app. + * @req: Request buffer sent to the app (must be TZ memory). * @req_size: Size of the request buffer. - * @rsp: DMA address of the response buffer, written to by the app. + * @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 @@ -90,8 +90,8 @@ static inline void qseecom_dma_free(struct qseecom_client *client, size_t size, * Return: Zero on success, nonzero on failure. */ static inline int qcom_qseecom_app_send(struct qseecom_client *client, - dma_addr_t req, size_t req_size, - dma_addr_t rsp, size_t rsp_size) + void *req, size_t req_size, + void *rsp, size_t rsp_size) { return qcom_scm_qseecom_app_send(client->app_id, req, req_size, rsp, rsp_size); } diff --git a/include/linux/firmware/qcom/qcom_scm.h b/include/linux/firmware/qcom/qcom_scm.h index aaa19f93ac43..2c51987fb70a 100644 --- a/include/linux/firmware/qcom/qcom_scm.h +++ b/include/linux/firmware/qcom/qcom_scm.h @@ -118,8 +118,8 @@ bool qcom_scm_lmh_dcvsh_available(void); #ifdef CONFIG_QCOM_QSEECOM int qcom_scm_qseecom_app_get_id(const char *app_name, u32 *app_id); -int qcom_scm_qseecom_app_send(u32 app_id, dma_addr_t req, size_t req_size, - dma_addr_t rsp, size_t rsp_size); +int qcom_scm_qseecom_app_send(u32 app_id, void *req, size_t req_size, + void *rsp, size_t rsp_size); #else /* CONFIG_QCOM_QSEECOM */ @@ -129,8 +129,8 @@ static inline int qcom_scm_qseecom_app_get_id(const char *app_name, u32 *app_id) } static inline int qcom_scm_qseecom_app_send(u32 app_id, - dma_addr_t req, size_t req_size, - dma_addr_t rsp, size_t rsp_size) + void *req, size_t req_size, + void *rsp, size_t rsp_size) { return -EINVAL; } From patchwork Mon May 27 12:55:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 799297 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 11C291607A0 for ; Mon, 27 May 2024 12:56:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716814619; cv=none; b=Eff4wyVEJSQdFB47uSbmeEPljpf4UJJkdSFzW0Imo/WRwOSFC/SxEp7tC9nFS9qCM5ty4Kfs5THrDL3az8tb33pbJxfnYfYUafpVrZ+HjAf3s6qHASyCcVugWJI39NNlaYMWcgU93NU2ngb3vfiEOwYpx7zPYnCg09JvGxuppS4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716814619; c=relaxed/simple; bh=xVAP2yUo860qGVVdjxAiMXPUbzaHrXsGq8uq0Y6cr70=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YIMBD4tKBQyn1O+6hLo9NzaN4xDYBmDv4g67MZAFIFa+Tdak+s2axxsn7VzmDaMKUyQbBCtfU0uc07qItksrgvzOSnrBesgW1+nQTAaqzQ6SQkWfTsWZFp7e58/bZCY4EEKZ33DNSPZVmBHWAFstO2QLzaovtMB932KRXu0gQSI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=HlFd9aRp; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="HlFd9aRp" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-42102c51524so23361325e9.1 for ; Mon, 27 May 2024 05:56:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1716814615; x=1717419415; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Xb011fqkeryzcbBET/6jqlq0C5NLk6ehH9YotcPeHdY=; b=HlFd9aRpl8yOYfNwn5CyunJc8UFuK79dHIyKVIpPZBYuK29nDUhwA3Odshwt2tGAbQ 2lJi+dxv6/5KZcgpH2Y7qXXCemqMNwN9Az2feFj1KBHjrTelayhoCoQZTPs4+4di1XIX 5oEqOltxw+3YAyvcEf31b6K9gNAG1/gPmLtT+jSAoB07eUPjHaRmyMLWSfHs7mV/Adox XIgjeE89fLU1H00mqVpCOZ/wGFujKD/VXQQgV0Wx/xb0HLi5vgVZ8/EJNv19F/dQiiLd 3BPniWAMi8axCt4N7+O2fYxqWP9EDXJlH7e8cL6Q2u8fmn/hOyH/pZl85Gw3AaCS8chN RkCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716814615; x=1717419415; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Xb011fqkeryzcbBET/6jqlq0C5NLk6ehH9YotcPeHdY=; b=hHTyi4uI97eDxg8mBJ7OhV9St5nqVIgr5I42rSrVyiESJM37SL9mB/JOq+XpSVfVY/ 7hyKzHG8IiB1ngy28IZ/LL9+kkWIX0T8hcE2K6JCGJGyt1/DevwN9TsxBvBtbhB0zBuf b0pDPOKQu9qkCKR/UBZtmhNNTind61YNG1+8AwQN8j9S8BFa7rPWAbWhtfOkKK/52wzb 9sJB09a9LJjFGhOubzK5oL9f32/A0IP2JHp2MLZqrnJuDUQFVVhY3qlIQA+y0m1xg+iu HRVnQ9Q7Fbbg3Ghlux2mCYko3+LXox329xpDjGj7dbnRgLrYp2QbBdwN7TxnHJs2e/Qq yCyA== X-Gm-Message-State: AOJu0YxgCaLGrmIKwrD43XflT3QDQTgd1c6yNlZYz4EjcAnvT2WDaQew QA3GrKiS+sVyZe5Cd9IzTp1kErXXJB031zI1d8BfIkZSKXki3gmZYzLsaWADxRA= X-Google-Smtp-Source: AGHT+IFMm7MJVK46CgCVCnpTDtuqMAFg/I+zhUZQjMTG8tD0AIdgSKeVpj4upyM8cXEOycp43d68vQ== X-Received: by 2002:a05:600c:1913:b0:419:e3b9:b384 with SMTP id 5b1f17b1804b1-421015b4734mr101893285e9.11.1716814615508; Mon, 27 May 2024 05:56:55 -0700 (PDT) Received: from [127.0.1.1] ([2a01:cb1d:75a:e000:c322:131e:ff9d:ef41]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42100f64f98sm138753635e9.24.2024.05.27.05.56.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 05:56:55 -0700 (PDT) From: Bartosz Golaszewski Date: Mon, 27 May 2024 14:55:01 +0200 Subject: [PATCH v10 11/15] firmware: qcom: tzmem: enable SHM Bridge support Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240527-shm-bridge-v10-11-ce7afaa58d3a@linaro.org> References: <20240527-shm-bridge-v10-0-ce7afaa58d3a@linaro.org> In-Reply-To: <20240527-shm-bridge-v10-0-ce7afaa58d3a@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robert Marko , Das Srinagesh , Bartosz Golaszewski , Maximilian Luz , Catalin Marinas , Will Deacon , Srini Kandagatla , Arnd Bergmann , Elliot Berman , Alex Elder Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Andrew Halaney , Deepti Jaggi X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4147; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=uu55syoIGqSAHT5CWYTbsAIG3EX3ZWdIO4aqT+vkzWw=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBmVIMKq01dcR08z169Y8aOU+wTgVn8nGVClVW3X UsyKRkrcoGJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZlSDCgAKCRARpy6gFHHX cquLEADCF0YY/DACosvnIHqr0PeJpvVfdMjtv0D9JWbTZ3J8PhKl2I7qK16Ghk6K99IPsBx68mb iC7BL2JCLV/pDgMNITVRsMf1UzkOpNtcc/5OtTCO62ViA0KZrws3WSdS/0dtRRnIPQxSZXanY0V tSzQ0+4rVqLz907BSOWPSOahub9zhsya5Jf6azljX1pSe6mZlgpQNmweQqI2VMHm3QXg6992OSO wqafLWC3+oMe+AvD2VjlUAvMA2FlBxkjom1IOA03zhlL5Van9Erw1p6NvpqQ0fWrT7RqrRzE9gP iYfhfz1u8nfzbYMZT0iP9ZxrhcvsqIKjcSOqwvMilpT10mC3kY/hQhKqGtNJcTceDbIApIudKjS vQlW6kgQG8ewP0tWKNy7g3LBQL5xeCZbLqNT7z7GRtvrPx+JWLADwWKyMBcZGoPZhV8lx6+aziz V9Yq1W9K45PgfEW3p7jUOMX0dPFDQu6hup/M55QFbim0H8KGoBYarziICmqUPmetksDlJVJQQi0 8cwEZvchXDmTl5OJMpOJ9HEkSCXFps0nOpFLF8XYS6Dn2qrH1CYXsRexFxRgDToIKmfH3+I0D9y +Q97F3tnSncqZHxunogUBWLwNfMGgiUQ+YSdKnWvIQ4Zv2BizW/969mHottbTutYPTDo/tWe80e WFaQb9xPgWZlIPw== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski SHM Bridge is a safety mechanism allowing to limit the amount of memory shared between the kernel and the TrustZone to regions explicitly marked as such. Add a variant of the tzmem allocator that configures the memory pools as SHM bridges. It also enables the SHM bridge globally so non-SHM bridge memory will no longer work with SCM calls. 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 fall back to the generic mode. Signed-off-by: Bartosz Golaszewski Tested-by: Andrew Halaney # sc8280xp-lenovo-thinkpad-x13s Tested-by: Deepti Jaggi #sa8775p-ride Reviewed-by: Elliot Berman --- drivers/firmware/qcom/Kconfig | 10 +++++ drivers/firmware/qcom/qcom_tzmem.c | 79 +++++++++++++++++++++++++++++++++++++- 2 files changed, 88 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/qcom/Kconfig b/drivers/firmware/qcom/Kconfig index 4634f8cecc7b..7f6eb4174734 100644 --- a/drivers/firmware/qcom/Kconfig +++ b/drivers/firmware/qcom/Kconfig @@ -28,6 +28,16 @@ config QCOM_TZMEM_MODE_GENERIC Use the generic allocator mode. The memory is page-aligned, non-cachable and physically contiguous. +config QCOM_TZMEM_MODE_SHMBRIDGE + bool "SHM Bridge" + help + Use Qualcomm Shared Memory Bridge. The memory has the same alignment as + in the 'Generic' 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 3853385bf215..aab6376cade5 100644 --- a/drivers/firmware/qcom/qcom_tzmem.c +++ b/drivers/firmware/qcom/qcom_tzmem.c @@ -66,7 +66,84 @@ static void qcom_tzmem_cleanup_area(struct qcom_tzmem_area *area) } -#endif /* CONFIG_QCOM_TZMEM_MODE_GENERIC */ +#elif IS_ENABLED(CONFIG_QCOM_TZMEM_MODE_SHMBRIDGE) + +#include +#include + +#define QCOM_SHM_BRIDGE_NUM_VM_SHIFT 9 + +static bool qcom_tzmem_using_shm_bridge; + +/* List of machines that are known to not support SHM bridge correctly. */ +static const char *const qcom_tzmem_blacklist[] = { + "qcom,sc8180x", + NULL +}; + +static int qcom_tzmem_init(void) +{ + const char *const *platform; + int ret; + + for (platform = qcom_tzmem_blacklist; *platform; platform++) { + if (of_machine_is_compatible(*platform)) + goto notsupp; + } + + ret = qcom_scm_shm_bridge_enable(); + if (ret == -EOPNOTSUPP) + goto notsupp; + + if (!ret) + qcom_tzmem_using_shm_bridge = true; + + return ret; + +notsupp: + dev_info(qcom_tzmem_dev, "SHM Bridge not supported\n"); + return 0; +} + +static int qcom_tzmem_init_area(struct qcom_tzmem_area *area) +{ + u64 pfn_and_ns_perm, ipfn_and_s_perm, size_and_flags; + int ret; + + if (!qcom_tzmem_using_shm_bridge) + return 0; + + pfn_and_ns_perm = (u64)area->paddr | QCOM_SCM_PERM_RW; + ipfn_and_s_perm = (u64)area->paddr | QCOM_SCM_PERM_RW; + size_and_flags = area->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; + + area->priv = no_free_ptr(handle); + + return 0; +} + +static void qcom_tzmem_cleanup_area(struct qcom_tzmem_area *area) +{ + u64 *handle = area->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 */ static int qcom_tzmem_pool_add_memory(struct qcom_tzmem_pool *pool, size_t size, gfp_t gfp) From patchwork Mon May 27 12:55:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 799296 Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 582FA161336 for ; Mon, 27 May 2024 12:56:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716814621; cv=none; b=H6HH9KoYZ2VdP7bfV9qeoq25HRKd9V5VjCv1DcNu7jkxLgtIqjpQbndQarq4PZKfxCkdg1Pm883c2ODVq091oJD0wV3OjAvgyrdNiAyYIriIFLkI0UN/jFmP0scl9tR7uSGjxxTbfYYMXSpQDhXpERYvNO43E0FQ/3Nl6PW3mn8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716814621; c=relaxed/simple; bh=SIkMSB3sTwPPn0mnOg/kQxIYsQNRjn/iYM96mTvFTjo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NOvZmsI8eJYaANuO29mh5T0spG9LKoJ97/bJgHgePM8coN8vvzIKzZ5osFCn7X5YtZ5hnrCFV7xeNcmoqYf8O7I7ntCUMaNyAQdJrlpH+7FMaFG0usGnRkcQ69dlgg1Dr2nFSfc7gf1sbZK7OA96CCTmD9xKVj1WS5H4gEUbtTc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=k05NMUWE; arc=none smtp.client-ip=209.85.208.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="k05NMUWE" Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2e9819a6327so4977251fa.1 for ; Mon, 27 May 2024 05:56:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1716814617; x=1717419417; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=GmwN8T//95zxjXecxSSl+qUrKqxrPgq9A+fgiSUHBZ8=; b=k05NMUWEK2Mm3UwMDJGiJBKZru4xuxkcDhy6QUAztL/MVPCckzxVsowf2ftJlSHV3V BfPoJDCM9RkEqffjjZPAuvhQXgjRhvO+Mnvw9fZDurWL+WUgjWpHS401qIzhCJQJQT91 22lPv+KQT5xnPgGhiWZAAsjpCCBWNwWjj84RzP5VuUotJ21W8PBs9HsyZfUqdkkcOY24 /WzYxyp9Tfx9Gz9kyJarMjGIKKGihOHCtKVFwCEeHMdccs5W9QCjw8gepO6Hlgb50OR5 47yuXFv0skEk87u7STmGY6qHQ/s98yyPltGXheOzX8JB3aiT7UpUNvmxwa9Da0OegsMe l8PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716814617; x=1717419417; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GmwN8T//95zxjXecxSSl+qUrKqxrPgq9A+fgiSUHBZ8=; b=JuDDYQhbjaud0rWbgEHtIZ9jO28FETgUmYXLnDhhlrYbOD/akPQEGdO2aiKLPooZoI 9/l84G/U3AQxicxFrzOaK5aEgDUUmV/+99FL0350qW1hvwyI7OYw9Pwd/z11jW89Opx/ tm1IcC3JxoIzrrILuTtNV3i4ODE2ZsqHxxgyAaFja1uGlM1l4j/HbPZfcdJi1XCG5mYG IKafEi7XkBMqaosXJ4xSSjjkDpivLK0mzabjULL57ocXAvgJjFqltGiYPo71NhiILQj/ Qs1TkG2Qm0SXc4l9Kxa9JD/c2G9LOZK0/eXINwIQ1SUKwdUpqinhCI+LBrRDmKdbLxf7 xadw== X-Gm-Message-State: AOJu0YwXARVh7aWgdVazLqtLI50bZicm98EmEUPcPD2V9wiH9XLJViW4 6LzIXStnBWFtL4coZiDNO9eXdMQmkgU2P+6TDT8t8RjzCAh5tVFCVoMKPfVez34= X-Google-Smtp-Source: AGHT+IHKVmTORLwXgauibbUsgi4IYgXJPRYSh+jV0Ob0wIxHrRD9Y6Js2gCtG4ungVqc2e8ClOuQfw== X-Received: by 2002:a2e:beab:0:b0:2e2:7f2:9f9d with SMTP id 38308e7fff4ca-2e95b0bdc6amr68330541fa.24.1716814617360; Mon, 27 May 2024 05:56:57 -0700 (PDT) Received: from [127.0.1.1] ([2a01:cb1d:75a:e000:c322:131e:ff9d:ef41]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42100f64f98sm138753635e9.24.2024.05.27.05.56.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 05:56:57 -0700 (PDT) From: Bartosz Golaszewski Date: Mon, 27 May 2024 14:55:03 +0200 Subject: [PATCH v10 13/15] firmware: qcom: scm: clarify the comment in qcom_scm_pas_init_image() Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240527-shm-bridge-v10-13-ce7afaa58d3a@linaro.org> References: <20240527-shm-bridge-v10-0-ce7afaa58d3a@linaro.org> In-Reply-To: <20240527-shm-bridge-v10-0-ce7afaa58d3a@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robert Marko , Das Srinagesh , Bartosz Golaszewski , Maximilian Luz , Catalin Marinas , Will Deacon , Srini Kandagatla , Arnd Bergmann , Elliot Berman , Alex Elder Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Andrew Halaney , Deepti Jaggi X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1428; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=H6Dcs2qENOv98shWWncB/3KIXUDdoYx6h7wJF3Xk+vk=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBmVIMKEwgpVJ1xtFxonWJa7NAoY3e/iI4djtIu+ yVmo6rynJ+JAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZlSDCgAKCRARpy6gFHHX ciZZEACPxKDvskowoZgnc1cO2L7lXWmNUEf7Vb4zUvdaLz3U4yQ4x/xF+LXu+pa0/81K9+u8FG0 fTfFA5pEamXWboVOwXK9lYDw1ay3OUEqzBRcP3qa32nQzwYZAktYQmmw/2Lq9El0x/nwUkg5gKd CQ/0l/PFbDBVF2UsuvALOHeMq5EtvVTrDxVe6zbzb70ACVuzX+N4zK7P1DAEtZAKW6aMydLB/aw AmBL56uyR77XErIBN0bW1thuXcInFfG2KL2EVJuJYyKTOY5mhJKF0GfG/bkhWeEgdmIC9LFTgVm kiQL67QOwvvncalUbB5NBA8/sOJhlVu+hj3O4NdGuyBz9zvCUjpRIzktjnGmZxA/iHcqJvoD4UO sbyq/bXWDfZtSoOrP6i+mMXk9W+jjgdqzFtYns3HeewB5HHsmwPPlbrVMShyletl7ddgg/aDlno sxO3Wl7Zi1/Ov/cbgXSLzcy4Qtnk6vwm+J9IrQv/CFuQk02QLsX/nShjyuM9Mw1VAzjF98zd7Ji WjOI4k56oaoc1zrQITItsq4FGiPrAnY+t9WSxGycb/vlhHPC37vwaeWlJGgIe+yzDbu1Dk28tr6 fjN7Wy1nWNi+40A5OKftR7FMViFX8ObNiyUSk6JYWPb1DZ8MQHkNBZN9W57dYKVevF+uEDt70YC IQOnTuF2Q13qlHw== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 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 Tested-by: Andrew Halaney # sc8280xp-lenovo-thinkpad-x13s Tested-by: Deepti Jaggi #sa8775p-ride Reviewed-by: Elliot Berman --- drivers/firmware/qcom/qcom_scm.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c index c82957727650..86e26f17ca19 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -583,6 +583,13 @@ int qcom_scm_pas_init_image(u32 peripheral, const void *metadata, size_t size, * 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. + * + * For PIL calls the hypervisor creates SHM Bridges for the blob + * buffers on behalf of Linus so we must not do it ourselves hence + * not using the TZMem allocator here. + * + * If we pass a buffer that is already part of an SHM Bridge to this + * call, it will fail. */ mdata_buf = dma_alloc_coherent(__scm->dev, size, &mdata_phys, GFP_KERNEL); From patchwork Mon May 27 12:55:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 799295 Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 62D621649CF for ; Mon, 27 May 2024 12:57:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716814623; cv=none; b=ByUI9lowse+P89K6fiXl1QRfDECjEDPB6Kfoz0M/ZN9DJQQlwMVpTt4bRXeQZds9/+BbSh5rwD2XrXOc3uiu21Z1AKx/e9OATQowI/AqY5DozNsIO03upT/RNDE6rJ2lbcAk1Ii5yakqUpR/wyQaAm5OHeUlO7Rrk2mZcNOxgoU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716814623; c=relaxed/simple; bh=qQLSlx2vlxIKR6+8ZF/gl2kvna8bmWqtILBIWb+Weu4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=T2A67E1vscrCceD2RT6lHvFY76MVVpnP/N3JLyc947Koh4IB2efDOQAhziNbaeTwMplpJCluUaW/0oUp16Ntd06QyvhdmOmCTsbzcdPX+CBkqKe7ijhDtyM46GeXot2aMrwhcFMifbcb3jDWF166DJYtEYOqsh+XjwhWp8Gy/yA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=JUNJt//O; arc=none smtp.client-ip=209.85.208.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="JUNJt//O" Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2e9684e0288so28500731fa.1 for ; Mon, 27 May 2024 05:57:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1716814619; x=1717419419; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=L8rkN2Rf2Hp0nSXd463a14N/vLIZb9qc33eAk0xmKNk=; b=JUNJt//OPJRCOYZ91o9LnHtJamJqppQPKmLvWeSkSoKiXxvrg98fwN6NV8W8rIH5WR 9a7h3lgFykZnJRwJTgUKzy85QhVxaDuFcq23nS18FE7jrVdHZaH1P1kVTQA5u9W0KtIV GLosPL1yU1MX9+qezb3Gr+lK1mQgXBduCCLy6vUFCXtH/Q7utaSjeGWLmRHj1nF/iEGS nl0mrzg37jJUXIn6NtU1wk8fDtj3dqIPWtPfyA/QYbBi9kztOkuhG5MGuxEp+Oc4cMqJ 7hIj78xIpblmyOgSIOgcLHFx/CnklncZBfidCyEw3BURJiS2JlGbAPJ5D2OQw80HTau+ Wozw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716814619; x=1717419419; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L8rkN2Rf2Hp0nSXd463a14N/vLIZb9qc33eAk0xmKNk=; b=o7LW8XwsPgbYWAdLiIKN1ublRHFqyp/EFPNwswJJCI3eAyu3dQLydEaaXDeyOEafB/ e6tZQzjk55TzAc4bRZRXLXR8W+o9r+rVj5l6zdMvbuoRPdA48J1+/vRFxBpXXTLiEIV2 39IeBUTmbHz8HECKVTJPaDnCjAAtPzR8IjZlYSsPQQn7bNlgmSTyOuaH+4ul3o2XPdtf 3N3IAgwG+J9P9L8+XCLJ93LkcQVKrsXPRw6u90lVLi7ICHmdAuPQNFUwVmvC2ONeRUE2 oznAi0RqHtGOBhMaVbQZ0vIwqTvnl1Eckcr1+Shc249GuYsuMM0sA1BCgkxsTjoV2kJL FSfA== X-Gm-Message-State: AOJu0Yz329RhHbhoYwNQeBPQ+GKVSnIebRAfmaRANlNrXBgrEacEv8j/ H+d2EwBzfDQQT3StYQTdGh7VlwpGrJE8BSki3oZ+7YCPmZpAy8FJ52NbN6Zk6vw= X-Google-Smtp-Source: AGHT+IGb0cN1IEanxjT22vgWa2Oh/Nwkk44pYpQ3psoE+0SJXnPbzhugKey/3Mfagl312ok7FO+FHg== X-Received: by 2002:a05:651c:4cd:b0:2e9:768a:12b0 with SMTP id 38308e7fff4ca-2e9768a144fmr29910491fa.50.1716814619437; Mon, 27 May 2024 05:56:59 -0700 (PDT) Received: from [127.0.1.1] ([2a01:cb1d:75a:e000:c322:131e:ff9d:ef41]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42100f64f98sm138753635e9.24.2024.05.27.05.56.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 05:56:59 -0700 (PDT) From: Bartosz Golaszewski Date: Mon, 27 May 2024 14:55:05 +0200 Subject: [PATCH v10 15/15] arm64: dts: qcom: sa8775p: add a dedicated memory carveout for TZ Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240527-shm-bridge-v10-15-ce7afaa58d3a@linaro.org> References: <20240527-shm-bridge-v10-0-ce7afaa58d3a@linaro.org> In-Reply-To: <20240527-shm-bridge-v10-0-ce7afaa58d3a@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robert Marko , Das Srinagesh , Bartosz Golaszewski , Maximilian Luz , Catalin Marinas , Will Deacon , Srini Kandagatla , Arnd Bergmann , Elliot Berman , Alex Elder Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=965; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=SVd7PalpjimcUnnSzGmMJxD42sVU9RNmLDvL9mtYIc4=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBmVIML/1S/Eg3P8RXxcQCjjbb5YnkY2z+23gAer 8Pf6Xgu8fCJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZlSDCwAKCRARpy6gFHHX ctsGD/sHdMN9reDJMUt/1wjiJW9kBhGHtypqVB80ebCle5co7w4LFflL9JFi6RF/W8W+s1Vn2Rn lgy862NKRql+tnbWKURIgDtct4vRfDdXnZ1R+FvrJF2WqIHUg1rOGmTJ8c7dcE/h141vY3oXlHk y9Zv5/MFWfA7G9XHXgELLM4WmIr+53jZsdGJXttDMqwA5lo0bMZTWJxnQy7HdVdFlCA1hhBlBRX YRYIv+Q8Qt+51l/sxFsCjREZwuO8VxBPlIwnuhF24hOA28kvCCaEnKGesArM3BWJF55KS1nQOuF xwpgLDjUKEP+BuTpHS9xv7nD80JW7M3bhZTUv4KF9wwTL6T92k4lF4FHk12maDIIOp6mt1E5e/I hnDaH88SyX1lnjXivcke0Kr25SMzWWE5S3HZcjY+J9bUaXZwtC2diOkrdlBFGZ95zuFo1hLmYOD rLSqBNJTxWOddihl07lAviS0Yr6h0roTOtePkdXLPGMBreZN9T3ZQyuV8kL73KhDA/38vvXa201 VyRhsm8TrjDRvE2TP1afyT+yqsI/P4KMCtxRRa9c8RwW/P2cWklSXUaJ7gocy2rwdRs2fgj6BiN EXRPAaqJKMsTzxcYb16jRGgtLMMEWqIe1c2rRcqyqVsQ/hEW0cY0zl6qC10RggwANsDR+9jJZun OerT6qSU38nz0/Q== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski Add a 20MB reserved memory region for use by SCM calls. Signed-off-by: Bartosz Golaszewski --- arch/arm64/boot/dts/qcom/sa8775p.dtsi | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/sa8775p.dtsi b/arch/arm64/boot/dts/qcom/sa8775p.dtsi index 31de73594839..c183527452d7 100644 --- a/arch/arm64/boot/dts/qcom/sa8775p.dtsi +++ b/arch/arm64/boot/dts/qcom/sa8775p.dtsi @@ -208,6 +208,7 @@ core3 { firmware { scm { compatible = "qcom,scm-sa8775p", "qcom,scm"; + memory-region = <&tz_ffi_mem>; }; }; @@ -418,6 +419,12 @@ cdt_data_backup_mem: cdt-data-backup@91ba0000 { no-map; }; + tz_ffi_mem: tz-ffi@91c00000 { + compatible = "shared-dma-pool"; + reg = <0x0 0x91c00000 0x0 0x1400000>; + no-map; + }; + lpass_machine_learning_mem: lpass-machine-learning@93b00000 { reg = <0x0 0x93b00000 0x0 0xf00000>; no-map;