Merge "gunyah: virtio: Deregister MMIO callback on module removal"
This commit is contained in:
commit
82a0fda979
@ -57,6 +57,7 @@ static hh_virtio_mmio_cb_t hh_virtio_mmio_fn;
|
|||||||
static hh_vcpu_affinity_cb_t hh_vcpu_affinity_fn;
|
static hh_vcpu_affinity_cb_t hh_vcpu_affinity_fn;
|
||||||
|
|
||||||
static DEFINE_MUTEX(hh_rm_call_idr_lock);
|
static DEFINE_MUTEX(hh_rm_call_idr_lock);
|
||||||
|
static DEFINE_MUTEX(gh_virtio_mmio_fn_lock);
|
||||||
static DEFINE_IDR(hh_rm_call_idr);
|
static DEFINE_IDR(hh_rm_call_idr);
|
||||||
static struct hh_rm_connection *curr_connection;
|
static struct hh_rm_connection *curr_connection;
|
||||||
static DEFINE_MUTEX(hh_rm_send_lock);
|
static DEFINE_MUTEX(hh_rm_send_lock);
|
||||||
@ -892,11 +893,15 @@ int hh_rm_populate_hyp_res(hh_vmid_t vmid, const char *vm_name)
|
|||||||
case HH_RM_RES_TYPE_VPMGRP:
|
case HH_RM_RES_TYPE_VPMGRP:
|
||||||
break;
|
break;
|
||||||
case HH_RM_RES_TYPE_VIRTIO_MMIO:
|
case HH_RM_RES_TYPE_VIRTIO_MMIO:
|
||||||
if (!hh_virtio_mmio_fn)
|
mutex_lock(&gh_virtio_mmio_fn_lock);
|
||||||
|
if (!hh_virtio_mmio_fn) {
|
||||||
|
mutex_unlock(&gh_virtio_mmio_fn_lock);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
ret = (*hh_virtio_mmio_fn)(vmid, vm_name, label,
|
ret = (*hh_virtio_mmio_fn)(vmid, vm_name, label,
|
||||||
cap_id, linux_irq, base, size);
|
cap_id, linux_irq, base, size);
|
||||||
|
mutex_unlock(&gh_virtio_mmio_fn_lock);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pr_err("%s: Unknown resource type: %u\n",
|
pr_err("%s: Unknown resource type: %u\n",
|
||||||
@ -936,15 +941,30 @@ int hh_rm_set_virtio_mmio_cb(hh_virtio_mmio_cb_t fnptr)
|
|||||||
if (!fnptr)
|
if (!fnptr)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (hh_virtio_mmio_fn)
|
mutex_lock(&gh_virtio_mmio_fn_lock);
|
||||||
|
if (hh_virtio_mmio_fn) {
|
||||||
|
mutex_unlock(&gh_virtio_mmio_fn_lock);
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
}
|
||||||
|
|
||||||
hh_virtio_mmio_fn = fnptr;
|
hh_virtio_mmio_fn = fnptr;
|
||||||
|
mutex_unlock(&gh_virtio_mmio_fn_lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(hh_rm_set_virtio_mmio_cb);
|
EXPORT_SYMBOL(hh_rm_set_virtio_mmio_cb);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gh_rm_unset_virtio_mmio_cb: Unset callback that handles virtio MMIO resource
|
||||||
|
*/
|
||||||
|
void gh_rm_unset_virtio_mmio_cb(void)
|
||||||
|
{
|
||||||
|
mutex_lock(&gh_virtio_mmio_fn_lock);
|
||||||
|
hh_virtio_mmio_fn = NULL;
|
||||||
|
mutex_unlock(&gh_virtio_mmio_fn_lock);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(gh_rm_unset_virtio_mmio_cb);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hh_rm_set_vcpu_affinity_cb: Set callback that handles vcpu affinity
|
* hh_rm_set_vcpu_affinity_cb: Set callback that handles vcpu affinity
|
||||||
* @fnptr: Pointer to callback function
|
* @fnptr: Pointer to callback function
|
||||||
|
@ -1519,15 +1519,24 @@ static int __init hh_virtio_backend_init(void)
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = hh_rm_set_virtio_mmio_cb(hh_virtio_mmio_init);
|
ret = hh_rm_set_virtio_mmio_cb(hh_virtio_mmio_init);
|
||||||
if (ret)
|
if (ret) {
|
||||||
|
vb_devclass_deinit();
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
return platform_driver_register(&hh_virtio_backend_driver);
|
ret = platform_driver_register(&hh_virtio_backend_driver);
|
||||||
|
if (ret) {
|
||||||
|
gh_rm_unset_virtio_mmio_cb();
|
||||||
|
vb_devclass_deinit();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
module_init(hh_virtio_backend_init);
|
module_init(hh_virtio_backend_init);
|
||||||
|
|
||||||
static void __exit hh_virtio_backend_exit(void)
|
static void __exit hh_virtio_backend_exit(void)
|
||||||
{
|
{
|
||||||
|
gh_rm_unset_virtio_mmio_cb();
|
||||||
platform_driver_unregister(&hh_virtio_backend_driver);
|
platform_driver_unregister(&hh_virtio_backend_driver);
|
||||||
vb_devclass_deinit();
|
vb_devclass_deinit();
|
||||||
}
|
}
|
||||||
|
@ -220,6 +220,7 @@ int hh_rm_vm_irq_release_notify(hh_vmid_t vmid, hh_virq_handle_t virq_handle);
|
|||||||
int hh_rm_vm_irq_reclaim(hh_virq_handle_t virq_handle);
|
int hh_rm_vm_irq_reclaim(hh_virq_handle_t virq_handle);
|
||||||
|
|
||||||
int hh_rm_set_virtio_mmio_cb(hh_virtio_mmio_cb_t fnptr);
|
int hh_rm_set_virtio_mmio_cb(hh_virtio_mmio_cb_t fnptr);
|
||||||
|
void gh_rm_unset_virtio_mmio_cb(void);
|
||||||
int hh_rm_set_vcpu_affinity_cb(hh_vcpu_affinity_cb_t fnptr);
|
int hh_rm_set_vcpu_affinity_cb(hh_vcpu_affinity_cb_t fnptr);
|
||||||
|
|
||||||
/* Client APIs for VM management */
|
/* Client APIs for VM management */
|
||||||
@ -445,6 +446,11 @@ static inline int hh_rm_set_virtio_mmio_cb(hh_virtio_mmio_cb_t fnptr)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void gh_rm_unset_virtio_mmio_cb(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static inline int hh_rm_set_vcpu_affinity_cb(hh_vcpu_affinity_cb fnptr)
|
static inline int hh_rm_set_vcpu_affinity_cb(hh_vcpu_affinity_cb fnptr)
|
||||||
{
|
{
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
Loading…
Reference in New Issue
Block a user