mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sumit Garg <sumit.garg@kernel.org>
To: Bjorn Andersson <andersson@kernel.org>,
	 Konrad Dybcio <konradybcio@kernel.org>,
	 Vikash Garodia <vikash.garodia@oss.qualcomm.com>,
	 Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>,
	 Abhinav Kumar <abhinav.kumar@linux.dev>,
	Bryan O'Donoghue <bod@kernel.org>,
	 Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-media@vger.kernel.org,
	Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>,
	 Jorge Ramirez-Ortiz <jorge.ramirez@oss.qualcomm.com>,
	 Jorge Ramirez-Ortiz <jorge.ramirez.ortiz@gmail.com>,
	 Sumit Garg <sumit.garg@oss.qualcomm.com>
Subject: [PATCH v2 1/3] firmware: qcom: pas: Add optional video memory protection op
Date: Tue, 27 Oct 2026 18:09:03 +0530	[thread overview]
Message-ID: <20261027-pas-video-v2-1-5b52bca5add6@oss.qualcomm.com> (raw)
In-Reply-To: <20261027-pas-video-v2-0-5b52bca5add6@oss.qualcomm.com>

From: Sumit Garg <sumit.garg@oss.qualcomm.com>

qcom_scm_mem_protect_video_var() is only serviced by the SCM backend.
Other PAS backends, e.g. OP-TEE, own secure memory protection and don't
implement such a call.

Add an optional mem_protect_video_var() PAS op along with a generic
qcom_pas_mem_protect_video_var() wrapper so that clients stay agnostic
of the active backend. The SCM backend maps it to the existing SCM call
while backends leaving it unset turn it into a no-op.

Signed-off-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
---
 drivers/firmware/qcom/qcom_pas.c       | 27 +++++++++++++++++++++++++++
 drivers/firmware/qcom/qcom_pas.h       |  5 +++++
 drivers/firmware/qcom/qcom_scm.c       | 10 ++++++++++
 include/linux/firmware/qcom/qcom_pas.h |  2 ++
 4 files changed, 44 insertions(+)

diff --git a/drivers/firmware/qcom/qcom_pas.c b/drivers/firmware/qcom/qcom_pas.c
index 24485dd0fa10..d478171e4697 100644
--- a/drivers/firmware/qcom/qcom_pas.c
+++ b/drivers/firmware/qcom/qcom_pas.c
@@ -237,6 +237,33 @@ int qcom_pas_shutdown(u32 pas_id)
 }
 EXPORT_SYMBOL_GPL(qcom_pas_shutdown);
 
+/**
+ * qcom_pas_mem_protect_video_var() - Set up video content protection ranges
+ * @cp_start:		content protection region start
+ * @cp_size:		content protection region size
+ * @cp_nonpixel_start:	non-pixel region start
+ * @cp_nonpixel_size:	non-pixel region size
+ *
+ * Backends that manage secure memory protection on their own do not
+ * implement this operation, in which case it is a no-op.
+ *
+ * Return: 0 on success.
+ */
+int qcom_pas_mem_protect_video_var(u32 cp_start, u32 cp_size,
+				   u32 cp_nonpixel_start, u32 cp_nonpixel_size)
+{
+	if (!ops_ptr)
+		return -ENODEV;
+
+	if (!ops_ptr->mem_protect_video_var)
+		return 0;
+
+	return ops_ptr->mem_protect_video_var(ops_ptr->dev, cp_start, cp_size,
+					      cp_nonpixel_start,
+					      cp_nonpixel_size);
+}
+EXPORT_SYMBOL_GPL(qcom_pas_mem_protect_video_var);
+
 /**
  * qcom_pas_supported() - Check if the peripheral authentication service is
  *			  supported for the given peripheral
diff --git a/drivers/firmware/qcom/qcom_pas.h b/drivers/firmware/qcom/qcom_pas.h
index 8643e2760602..481343669e1d 100644
--- a/drivers/firmware/qcom/qcom_pas.h
+++ b/drivers/firmware/qcom/qcom_pas.h
@@ -22,6 +22,8 @@ struct device;
  *				callback.
  * @set_remote_state:		Peripheral set remote state callback.
  * @shutdown:			Peripheral shutdown callback.
+ * @mem_protect_video_var:	Optional video secure memory protection callback.
+ *				Backends that do not need it leave it unset.
  * @metadata_release:		Image metadata release callback.
  */
 struct qcom_pas_ops {
@@ -40,6 +42,9 @@ struct qcom_pas_ops {
 	int (*auth_and_reset)(struct device *dev, u32 pas_id);
 	int (*set_remote_state)(struct device *dev, u32 state, u32 pas_id);
 	int (*shutdown)(struct device *dev, u32 pas_id);
+	int (*mem_protect_video_var)(struct device *dev, u32 cp_start,
+				     u32 cp_size, u32 cp_nonpixel_start,
+				     u32 cp_nonpixel_size);
 	void (*metadata_release)(struct device *dev,
 				 struct qcom_pas_context *ctx);
 };
diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
index 43e250faea75..5445c1aa14cc 100644
--- a/drivers/firmware/qcom/qcom_scm.c
+++ b/drivers/firmware/qcom/qcom_scm.c
@@ -981,6 +981,15 @@ static bool qcom_scm_pas_supported(struct device *dev, u32 pas_id)
 	return ret ? false : !!res.result[0];
 }
 
+static int qcom_scm_pas_mem_protect_video_var(struct device *dev, u32 cp_start,
+					      u32 cp_size, u32 cp_nonpixel_start,
+					      u32 cp_nonpixel_size)
+{
+	return qcom_scm_mem_protect_video_var(cp_start, cp_size,
+					      cp_nonpixel_start,
+					      cp_nonpixel_size);
+}
+
 static struct qcom_pas_ops qcom_pas_ops_scm = {
 	.drv_name		= "qcom_scm",
 	.supported		= qcom_scm_pas_supported,
@@ -991,6 +1000,7 @@ static struct qcom_pas_ops qcom_pas_ops_scm = {
 	.prepare_and_auth_reset	= qcom_scm_pas_prepare_and_auth_reset,
 	.set_remote_state	= qcom_scm_pas_set_remote_state,
 	.shutdown		= qcom_scm_pas_shutdown,
+	.mem_protect_video_var	= qcom_scm_pas_mem_protect_video_var,
 	.metadata_release	= qcom_scm_pas_metadata_release,
 };
 
diff --git a/include/linux/firmware/qcom/qcom_pas.h b/include/linux/firmware/qcom/qcom_pas.h
index fb2ec3be6a16..bfd4a9e5a705 100644
--- a/include/linux/firmware/qcom/qcom_pas.h
+++ b/include/linux/firmware/qcom/qcom_pas.h
@@ -49,6 +49,8 @@ int qcom_pas_auth_and_reset(u32 pas_id);
 int qcom_pas_prepare_and_auth_reset(struct qcom_pas_context *ctx);
 int qcom_pas_set_remote_state(u32 state, u32 pas_id);
 int qcom_pas_shutdown(u32 pas_id);
+int qcom_pas_mem_protect_video_var(u32 cp_start, u32 cp_size,
+				   u32 cp_nonpixel_start, u32 cp_nonpixel_size);
 bool qcom_pas_supported(u32 pas_id);
 void qcom_pas_metadata_release(struct qcom_pas_context *ctx);
 

-- 
2.43.0


  reply	other threads:[~2026-10-27 12:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27 12:39 [PATCH v2 0/3] media: qcom: Skip SCM secure memory protection with OP-TEE PAS backend Sumit Garg
2026-10-27 12:39 ` Sumit Garg [this message]
2026-10-27 15:58   ` [PATCH v2 1/3] firmware: qcom: pas: Add optional video memory protection op Konrad Dybcio
2026-10-27 12:39 ` [PATCH v2 2/3] media: qcom: Use PAS API for video memory protection Sumit Garg
2026-10-27 15:59   ` Konrad Dybcio
2026-10-27 12:39 ` [PATCH v2 3/3] firmware: qcom: scm: Drop export of qcom_scm_mem_protect_video_var() Sumit Garg
2026-10-27 15:59   ` Konrad Dybcio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261027-pas-video-v2-1-5b52bca5add6@oss.qualcomm.com \
    --to=sumit.garg@kernel.org \
    --cc=abhinav.kumar@linux.dev \
    --cc=andersson@kernel.org \
    --cc=bod@kernel.org \
    --cc=dikshita.agarwal@oss.qualcomm.com \
    --cc=jorge.ramirez.ortiz@gmail.com \
    --cc=jorge.ramirez@oss.qualcomm.com \
    --cc=konrad.dybcio@oss.qualcomm.com \
    --cc=konradybcio@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sumit.garg@oss.qualcomm.com \
    --cc=vikash.garodia@oss.qualcomm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®