Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Michal Simek <michal.simek@amd.com>
To: Ajay Neeli <ajay.neeli@amd.com>,
	martin.petersen@oracle.com,
	James.Bottomley@HansenPartnership.com, robh@kernel.org,
	krzk+dt@kernel.org, conor+dt@kernel.org,
	pedrom.sousa@synopsys.com
Cc: alim.akhtar@samsung.com, avri.altman@wdc.com, bvanassche@acm.org,
	linux-scsi@vger.kernel.org, devicetree@vger.kernel.org,
	git@amd.com, srinivas.goud@amd.com, radhey.shyam.pandey@amd.com,
	Izhar Ameer Shaikh <izhar.ameer.shaikh@amd.com>
Subject: Re: [PATCH v2 2/4] firmware: xilinx: Add support for secure read/write ioctl interface
Date: Thu, 23 Oct 2025 09:31:18 +0200	[thread overview]
Message-ID: <b6a9d2a0-00d3-4419-88ca-471efc7d0ff1@amd.com> (raw)
In-Reply-To: <20251021113003.13650-3-ajay.neeli@amd.com>



On 10/21/25 13:30, Ajay Neeli wrote:
> From: Izhar Ameer Shaikh <izhar.ameer.shaikh@amd.com>
> 
> Add support for a generic ioctl read/write interface using which users
> can request firmware to perform read/write operations on a protected and
> secure address space.
> 
> The functionality is introduced through the means of two new IOCTL IDs
> which extend the existing PM_IOCTL EEMI API:
>   - IOCTL_READ_REG
>   - IOCTL_MASK_WRITE_REG
> 
> The caller only passes the node id of the given device and an offset.
> The base address is not exposed to the caller and internally retrieved
> by the firmware. Firmware will enforce an access policy on the incoming
> read/write request.
> 
> Signed-off-by: Izhar Ameer Shaikh <izhar.ameer.shaikh@amd.com>
> Reviewed-by: Tanmay Shah <tanmay.shah@amd.com>
> Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
> Signed-off-by: Ajay Neeli <ajay.neeli@amd.com>
> Acked-by: Senthil Nathan Thangaraj <senthilnathan.thangaraj@amd.com>
> ---
> Changes in v1->v2: None
> ---
>   drivers/firmware/xilinx/zynqmp.c     | 46 ++++++++++++++++++++++++++++++++++++
>   include/linux/firmware/xlnx-zynqmp.h | 15 ++++++++++++
>   2 files changed, 61 insertions(+)
> 
> diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
> index 7356e86..2422922 100644
> --- a/drivers/firmware/xilinx/zynqmp.c
> +++ b/drivers/firmware/xilinx/zynqmp.c
> @@ -1617,6 +1617,52 @@ int zynqmp_pm_get_feature_config(enum pm_feature_config_id id,
>   }
>   
>   /**
> + * zynqmp_pm_sec_read_reg - PM call to securely read from given offset
> + *		of the node
> + * @node_id:	Node Id of the device
> + * @offset:	Offset to be used (20-bit)
> + * @ret_value:	Output data read from the given offset after
> + *		firmware access policy is successfully enforced
> + *
> + * Return:	Returns 0 on success or error value on failure
> + */
> +int zynqmp_pm_sec_read_reg(u32 node_id, u32 offset, u32 *ret_value)
> +{
> +	u32 ret_payload[PAYLOAD_ARG_CNT];
> +	u32 count = 1;
> +	int ret;
> +
> +	if (!ret_value)
> +		return -EINVAL;
> +
> +	ret = zynqmp_pm_invoke_fn(PM_IOCTL, ret_payload, 4, node_id, IOCTL_READ_REG,
> +				  offset, count);
> +
> +	*ret_value = ret_payload[1];
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(zynqmp_pm_sec_read_reg);
> +
> +/**
> + * zynqmp_pm_sec_mask_write_reg - PM call to securely write to given offset
> + *		of the node
> + * @node_id:	Node Id of the device
> + * @offset:	Offset to be used (20-bit)
> + * @mask:	Mask to be used
> + * @value:	Value to be written
> + *
> + * Return:	Returns 0 on success or error value on failure
> + */
> +int zynqmp_pm_sec_mask_write_reg(const u32 node_id, const u32 offset, u32 mask,
> +				 u32 value)
> +{
> +	return zynqmp_pm_invoke_fn(PM_IOCTL, NULL, 5, node_id, IOCTL_MASK_WRITE_REG,
> +				   offset, mask, value);
> +}
> +EXPORT_SYMBOL_GPL(zynqmp_pm_sec_mask_write_reg);
> +
> +/**
>    * zynqmp_pm_set_sd_config - PM call to set value of SD config registers
>    * @node:	SD node ID
>    * @config:	The config type of SD registers
> diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
> index 6d4dbc1..f441eea 100644
> --- a/include/linux/firmware/xlnx-zynqmp.h
> +++ b/include/linux/firmware/xlnx-zynqmp.h
> @@ -241,6 +241,7 @@ enum pm_ioctl_id {
>   	IOCTL_GET_FEATURE_CONFIG = 27,
>   	/* IOCTL for Secure Read/Write Interface */
>   	IOCTL_READ_REG = 28,
> +	IOCTL_MASK_WRITE_REG = 29,
>   	/* Dynamic SD/GEM configuration */
>   	IOCTL_SET_SD_CONFIG = 30,
>   	IOCTL_SET_GEM_CONFIG = 31,
> @@ -620,6 +621,9 @@ int zynqmp_pm_register_notifier(const u32 node, const u32 event,
>   int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id);
>   int zynqmp_pm_set_feature_config(enum pm_feature_config_id id, u32 value);
>   int zynqmp_pm_get_feature_config(enum pm_feature_config_id id, u32 *payload);
> +int zynqmp_pm_sec_read_reg(u32 node_id, u32 offset, u32 *ret_value);
> +int zynqmp_pm_sec_mask_write_reg(const u32 node_id, const u32 offset,
> +				 u32 mask, u32 value);
>   int zynqmp_pm_register_sgi(u32 sgi_num, u32 reset);
>   int zynqmp_pm_force_pwrdwn(const u32 target,
>   			   const enum zynqmp_pm_request_ack ack);
> @@ -922,6 +926,17 @@ static inline int zynqmp_pm_request_wake(const u32 node,
>   	return -ENODEV;
>   }
>   
> +static inline int zynqmp_pm_sec_read_reg(u32 node_id, u32 offset, u32 *ret_value)
> +{
> +	return -ENODEV;
> +}
> +
> +static inline int zynqmp_pm_sec_mask_write_reg(const u32 node_id, const u32 offset,
> +					       u32 mask, u32 value)
> +{
> +	return -ENODEV;
> +}
> +
>   static inline int zynqmp_pm_get_rpu_mode(u32 node_id, enum rpu_oper_mode *rpu_mode)
>   {
>   	return -ENODEV;

Acked-by: Michal Simek <michal.simek@amd.com>

Feel free to take this via UFS tree.

Thanks,
Michal

  reply	other threads:[~2025-10-23  7:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-21 11:29 [PATCH v2 0/4] ufs: Add support for AMD Versal Gen2 UFS Ajay Neeli
2025-10-21 11:30 ` [PATCH v2 1/4] dt-bindings: ufs: amd-versal2: Add UFS Host Controller for AMD Versal Gen 2 SoC Ajay Neeli
2025-10-22 17:38   ` Conor Dooley
2025-10-21 11:30 ` [PATCH v2 2/4] firmware: xilinx: Add support for secure read/write ioctl interface Ajay Neeli
2025-10-23  7:31   ` Michal Simek [this message]
2025-10-21 11:30 ` [PATCH v2 3/4] firmware: xilinx: Add APIs for UFS PHY initialization Ajay Neeli
2025-10-23  7:31   ` Michal Simek
2025-10-21 11:30 ` [PATCH v2 4/4] ufs: amd-versal2: Add UFS support for AMD Versal Gen 2 SoC Ajay Neeli
2025-10-22 19:39 ` [PATCH v2 0/4] ufs: Add support for AMD Versal Gen2 UFS Bart Van Assche
2025-10-30  3:06 ` Martin K. Petersen
2025-11-03  3:29 ` Martin K. Petersen

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=b6a9d2a0-00d3-4419-88ca-471efc7d0ff1@amd.com \
    --to=michal.simek@amd.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=ajay.neeli@amd.com \
    --cc=alim.akhtar@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=bvanassche@acm.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=git@amd.com \
    --cc=izhar.ameer.shaikh@amd.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=pedrom.sousa@synopsys.com \
    --cc=radhey.shyam.pandey@amd.com \
    --cc=robh@kernel.org \
    --cc=srinivas.goud@amd.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