Skip to content

Commit 82a8daa

Browse files
marcbonnicisudeep-holla
authored andcommitted
firmware: arm_ffa: Add support for MEM_LEND
As part of the FF-A spec, an endpoint is allowed to transfer access of, or lend, a memory region to one or more borrowers. Extend the existing memory sharing implementation to support FF-A MEM_LEND functionality and expose this to other kernel drivers. Note that upon a successful MEM_LEND request the caller must ensure that the memory region specified is not accessed until a successful MEM_RECALIM call has been made. On systems with a hypervisor present this will been enforced, however on systems without a hypervisor the responsibility falls to the calling kernel driver to prevent access. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Jens Wiklander <[email protected]> Signed-off-by: Marc Bonnici <[email protected]> Signed-off-by: Sudeep Holla <[email protected]>
1 parent 8e3f9da commit 82a8daa

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

drivers/firmware/arm_ffa/driver.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,13 +613,30 @@ ffa_memory_share(struct ffa_device *dev, struct ffa_mem_ops_args *args)
613613
return ffa_memory_ops(FFA_FN_NATIVE(MEM_SHARE), args);
614614
}
615615

616+
static int
617+
ffa_memory_lend(struct ffa_device *dev, struct ffa_mem_ops_args *args)
618+
{
619+
/* Note that upon a successful MEM_LEND request the caller
620+
* must ensure that the memory region specified is not accessed
621+
* until a successful MEM_RECALIM call has been made.
622+
* On systems with a hypervisor present this will been enforced,
623+
* however on systems without a hypervisor the responsibility
624+
* falls to the calling kernel driver to prevent access.
625+
*/
626+
if (dev->mode_32bit)
627+
return ffa_memory_ops(FFA_MEM_LEND, args);
628+
629+
return ffa_memory_ops(FFA_FN_NATIVE(MEM_LEND), args);
630+
}
631+
616632
static const struct ffa_dev_ops ffa_ops = {
617633
.api_version_get = ffa_api_version_get,
618634
.partition_info_get = ffa_partition_info_get,
619635
.mode_32bit_set = ffa_mode_32bit_set,
620636
.sync_send_receive = ffa_sync_send_receive,
621637
.memory_reclaim = ffa_memory_reclaim,
622638
.memory_share = ffa_memory_share,
639+
.memory_lend = ffa_memory_lend,
623640
};
624641

625642
const struct ffa_dev_ops *ffa_dev_ops_get(struct ffa_device *dev)

include/linux/arm_ffa.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,8 @@ struct ffa_dev_ops {
262262
int (*memory_reclaim)(u64 g_handle, u32 flags);
263263
int (*memory_share)(struct ffa_device *dev,
264264
struct ffa_mem_ops_args *args);
265+
int (*memory_lend)(struct ffa_device *dev,
266+
struct ffa_mem_ops_args *args);
265267
};
266268

267269
#endif /* _LINUX_ARM_FFA_H */

0 commit comments

Comments
 (0)