mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 11:41:38 -04:00
haven: Add support for the MEM_ACCEPTED notification
It's useful for other virtual machines (VMs) to know if another VM has successfully received a resource that was shared with it (e.g. state tracking can be controlled better with this sort of information). Add support for the MEM_ACCEPTED notification, which clients can use to notify the VM that owns the resource that was shared with it that it has accepted the resource and is using it. Also, add support in the mem-notifier driver to forward the MEM_ACCEPTED notification to clients. Change-Id: I05b9f1d37906d7c2aa729b97df2f8ceb78b560bd Signed-off-by: Isaac J. Manjarres <[email protected]>
This commit is contained in:
parent
38b1718d28
commit
1451a11662
6 changed files with 47 additions and 18 deletions
|
|
@ -93,9 +93,14 @@ EXPORT_SYMBOL(hh_mem_notifier_unregister);
|
|||
static enum hh_mem_notifier_tag hh_mem_notifier_get_tag(unsigned long action,
|
||||
void *msg)
|
||||
{
|
||||
return action == HH_RM_NOTIF_MEM_SHARED ?
|
||||
((struct hh_rm_notif_mem_shared_payload *)msg)->mem_info_tag :
|
||||
if (action == HH_RM_NOTIF_MEM_SHARED)
|
||||
return
|
||||
((struct hh_rm_notif_mem_shared_payload *)msg)->mem_info_tag;
|
||||
else if (action == HH_RM_NOTIF_MEM_RELEASED)
|
||||
return
|
||||
((struct hh_rm_notif_mem_released_payload *)msg)->mem_info_tag;
|
||||
|
||||
return ((struct hh_rm_notif_mem_accepted_payload *)msg)->mem_info_tag;
|
||||
}
|
||||
|
||||
static int hh_mem_notifier_call(struct notifier_block *nb, unsigned long action,
|
||||
|
|
@ -107,7 +112,8 @@ static int hh_mem_notifier_call(struct notifier_block *nb, unsigned long action,
|
|||
void *data;
|
||||
|
||||
if ((action != HH_RM_NOTIF_MEM_SHARED) &&
|
||||
(action != HH_RM_NOTIF_MEM_RELEASED))
|
||||
(action != HH_RM_NOTIF_MEM_RELEASED) &&
|
||||
(action != HH_RM_NOTIF_MEM_ACCEPTED))
|
||||
return NOTIFY_DONE;
|
||||
|
||||
tag = hh_mem_notifier_get_tag(action, msg);
|
||||
|
|
|
|||
|
|
@ -236,6 +236,15 @@ static int hh_rm_process_notif(void *recv_buff, size_t recv_buff_size)
|
|||
goto err;
|
||||
}
|
||||
break;
|
||||
case HH_RM_NOTIF_MEM_ACCEPTED:
|
||||
if (recv_buff_size != sizeof(*hdr) +
|
||||
sizeof(struct hh_rm_notif_mem_accepted_payload)) {
|
||||
pr_err("%s: Invalid size for MEM_ACCEPTED notif: %u\n",
|
||||
__func__, recv_buff_size - sizeof(*hdr));
|
||||
ret = -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
break;
|
||||
case HH_RM_NOTIF_VM_CONSOLE_CHARS:
|
||||
if (recv_buff_size < sizeof(*hdr) +
|
||||
sizeof(struct hh_rm_notif_vm_console_chars)) {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@
|
|||
#define HH_RM_MEM_SHARE_VALID_FLAGS HH_RM_MEM_SHARE_SANITIZE
|
||||
#define HH_RM_MEM_LEND_VALID_FLAGS HH_RM_MEM_LEND_SANITIZE
|
||||
#define HH_RM_MEM_NOTIFY_VALID_FLAGS\
|
||||
(HH_RM_MEM_NOTIFY_RECIPIENT | HH_RM_MEM_NOTIFY_OWNER)
|
||||
(HH_RM_MEM_NOTIFY_RECIPIENT_SHARED |\
|
||||
HH_RM_MEM_NOTIFY_OWNER_RELEASED | HH_RM_MEM_NOTIFY_OWNER_ACCEPTED)
|
||||
|
||||
static struct hh_vm_property hh_vm_table[HH_VM_MAX];
|
||||
|
||||
|
|
@ -1214,9 +1215,9 @@ EXPORT_SYMBOL(hh_rm_mem_lend);
|
|||
* out
|
||||
* @flags: Flags to determine if the notification is for notifying that memory
|
||||
* has been shared to another VM, or that a VM has released memory
|
||||
* @mem_info_tag: A 32-bit value that is attached to the MEM_SHARED/MEM_RELEASED
|
||||
* notifications to aid in distinguishing different resources
|
||||
* from one another.
|
||||
* @mem_info_tag: A 32-bit value that is attached to the
|
||||
* MEM_SHARED/MEM_RELEASED/MEM_ACCEPTED notifications to aid in
|
||||
* distinguishing different resources from one another.
|
||||
* @vmid_desc: A list of VMIDs to notify that memory has been shared with them.
|
||||
* This parameter should only be non-NULL if other VMs are being
|
||||
* notified (i.e. it is invalid to specify this parameter when the
|
||||
|
|
@ -1238,13 +1239,15 @@ int hh_rm_mem_notify(hh_memparcel_handle_t handle, u8 flags,
|
|||
int ret = 0, hh_ret;
|
||||
|
||||
if ((flags & ~HH_RM_MEM_NOTIFY_VALID_FLAGS) ||
|
||||
((flags & HH_RM_MEM_NOTIFY_RECIPIENT) && (!vmid_desc ||
|
||||
(vmid_desc &&
|
||||
((flags & HH_RM_MEM_NOTIFY_RECIPIENT_SHARED) && (!vmid_desc ||
|
||||
(vmid_desc &&
|
||||
!vmid_desc->n_vmid_entries))) ||
|
||||
((flags & HH_RM_MEM_NOTIFY_OWNER) && vmid_desc))
|
||||
((flags & (HH_RM_MEM_NOTIFY_OWNER_RELEASED |
|
||||
HH_RM_MEM_NOTIFY_OWNER_ACCEPTED)) && vmid_desc) ||
|
||||
(hweight8(flags) != 1))
|
||||
return -EINVAL;
|
||||
|
||||
if (flags & HH_RM_MEM_NOTIFY_RECIPIENT) {
|
||||
if (flags & HH_RM_MEM_NOTIFY_RECIPIENT_SHARED) {
|
||||
n_vmid_entries = vmid_desc->n_vmid_entries;
|
||||
req_vmid_desc_size = offsetof(struct hh_notify_vmid_desc,
|
||||
vmid_entries[n_vmid_entries]);
|
||||
|
|
@ -1260,7 +1263,7 @@ int hh_rm_mem_notify(hh_memparcel_handle_t handle, u8 flags,
|
|||
req_payload_hdr->flags = flags;
|
||||
req_payload_hdr->mem_info_tag = mem_info_tag;
|
||||
|
||||
if (flags & HH_RM_MEM_NOTIFY_RECIPIENT) {
|
||||
if (flags & HH_RM_MEM_NOTIFY_RECIPIENT_SHARED) {
|
||||
dst_vmid_desc = req_buf + sizeof(*req_payload_hdr);
|
||||
dst_vmid_desc->n_vmid_entries = n_vmid_entries;
|
||||
for (i = 0; i < n_vmid_entries; i++)
|
||||
|
|
|
|||
Loading…
Reference in a new issue