diff mbox series

[2/4] firmware: arm_ffa: Check if receiving direct requests are supported before sending

Message ID 20240415-ffa_msg2_support-v1-2-a28c964b1b3f@arm.com (mailing list archive)
State New, archived
Headers show
Series firmware: arm_ffa: Support for MSG_SEND2 and minor harderning checks | expand

Commit Message

Sudeep Holla April 15, 2024, 4:05 p.m. UTC
Add check to see if the target partition can receive the direct requests
before sending any message to the partition.

Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 drivers/firmware/arm_ffa/driver.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Jens Wiklander April 16, 2024, 7:18 a.m. UTC | #1
On Mon, Apr 15, 2024 at 6:05 PM Sudeep Holla <sudeep.holla@arm.com> wrote:
>
> Add check to see if the target partition can receive the direct requests
> before sending any message to the partition.
>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
>  drivers/firmware/arm_ffa/driver.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
> index d258d04c1eda..52379885a403 100644
> --- a/drivers/firmware/arm_ffa/driver.c
> +++ b/drivers/firmware/arm_ffa/driver.c
> @@ -875,9 +875,15 @@ static bool ffa_partition_check_property(struct ffa_device *dev, u32 property)
>         return partition->properties & property;
>  }
>
> +#define ffa_partition_supports_direct_recv(dev)        \
> +       ffa_partition_check_property(dev, FFA_PARTITION_DIRECT_RECV)
> +
>  static int ffa_sync_send_receive(struct ffa_device *dev,
>                                  struct ffa_send_direct_data *data)
>  {
> +       if (!ffa_partition_supports_direct_recv(dev))
> +               return -EOPNOTSUPP;

This is done in the critical path of a direct request. Checking that a
partition supports direct requests makes sense before using it, but
doing it for each call in the critical path is excessive. There are
checks in the other layers to catch unsupported requests. Can we let
the caller do this check if desired? Omitting the check shouldn't lead
to any bad things.

Cheers,
Jens

> +
>         return ffa_msg_send_direct_req(drv_info->vm_id, dev->vm_id,
>                                        dev->mode_32bit, data);
>  }
>
> --
> 2.43.2
>
diff mbox series

Patch

diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index d258d04c1eda..52379885a403 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -875,9 +875,15 @@  static bool ffa_partition_check_property(struct ffa_device *dev, u32 property)
 	return partition->properties & property;
 }
 
+#define ffa_partition_supports_direct_recv(dev)	\
+	ffa_partition_check_property(dev, FFA_PARTITION_DIRECT_RECV)
+
 static int ffa_sync_send_receive(struct ffa_device *dev,
 				 struct ffa_send_direct_data *data)
 {
+	if (!ffa_partition_supports_direct_recv(dev))
+		return -EOPNOTSUPP;
+
 	return ffa_msg_send_direct_req(drv_info->vm_id, dev->vm_id,
 				       dev->mode_32bit, data);
 }