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/20211015165742.2513065-1-marc.bonnici@arm.com Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Signed-off-by: Marc Bonnici <marc.bonnici@arm.com> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
This commit is contained in:
parent
8e3f9da608
commit
82a8daaecf
2 changed files with 19 additions and 0 deletions
|
@ -613,6 +613,22 @@ ffa_memory_share(struct ffa_device *dev, struct ffa_mem_ops_args *args)
|
||||||
return ffa_memory_ops(FFA_FN_NATIVE(MEM_SHARE), args);
|
return ffa_memory_ops(FFA_FN_NATIVE(MEM_SHARE), args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
ffa_memory_lend(struct ffa_device *dev, struct ffa_mem_ops_args *args)
|
||||||
|
{
|
||||||
|
/* 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.
|
||||||
|
*/
|
||||||
|
if (dev->mode_32bit)
|
||||||
|
return ffa_memory_ops(FFA_MEM_LEND, args);
|
||||||
|
|
||||||
|
return ffa_memory_ops(FFA_FN_NATIVE(MEM_LEND), args);
|
||||||
|
}
|
||||||
|
|
||||||
static const struct ffa_dev_ops ffa_ops = {
|
static const struct ffa_dev_ops ffa_ops = {
|
||||||
.api_version_get = ffa_api_version_get,
|
.api_version_get = ffa_api_version_get,
|
||||||
.partition_info_get = ffa_partition_info_get,
|
.partition_info_get = ffa_partition_info_get,
|
||||||
|
@ -620,6 +636,7 @@ static const struct ffa_dev_ops ffa_ops = {
|
||||||
.sync_send_receive = ffa_sync_send_receive,
|
.sync_send_receive = ffa_sync_send_receive,
|
||||||
.memory_reclaim = ffa_memory_reclaim,
|
.memory_reclaim = ffa_memory_reclaim,
|
||||||
.memory_share = ffa_memory_share,
|
.memory_share = ffa_memory_share,
|
||||||
|
.memory_lend = ffa_memory_lend,
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct ffa_dev_ops *ffa_dev_ops_get(struct ffa_device *dev)
|
const struct ffa_dev_ops *ffa_dev_ops_get(struct ffa_device *dev)
|
||||||
|
|
|
@ -262,6 +262,8 @@ struct ffa_dev_ops {
|
||||||
int (*memory_reclaim)(u64 g_handle, u32 flags);
|
int (*memory_reclaim)(u64 g_handle, u32 flags);
|
||||||
int (*memory_share)(struct ffa_device *dev,
|
int (*memory_share)(struct ffa_device *dev,
|
||||||
struct ffa_mem_ops_args *args);
|
struct ffa_mem_ops_args *args);
|
||||||
|
int (*memory_lend)(struct ffa_device *dev,
|
||||||
|
struct ffa_mem_ops_args *args);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _LINUX_ARM_FFA_H */
|
#endif /* _LINUX_ARM_FFA_H */
|
||||||
|
|
Loading…
Add table
Reference in a new issue