Commit f6d955d8 authored by Eli Cohen's avatar Eli Cohen Committed by Michael S. Tsirkin

vdpa: Avoid taking cf_mutex lock on get status

Avoid the wrapper holding cf_mutex since it is not protecting anything.
To avoid confusion and unnecessary overhead incurred by it, remove.

Fixes: f489f27bc0ab ("vdpa: Sync calls set/get config/status with cf_mutex")
Signed-off-by: default avatarEli Cohen <elic@nvidia.com>
Link: https://lore.kernel.org/r/20220111183400.38418-2-elic@nvidia.comSigned-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Reviewed-by: Si-Wei Liu<si-wei.liu@oracle.com>
Acked-by: default avatarJason Wang <jasowang@redhat.com>
parent b2ce6197
...@@ -21,17 +21,6 @@ static LIST_HEAD(mdev_head); ...@@ -21,17 +21,6 @@ static LIST_HEAD(mdev_head);
static DEFINE_MUTEX(vdpa_dev_mutex); static DEFINE_MUTEX(vdpa_dev_mutex);
static DEFINE_IDA(vdpa_index_ida); static DEFINE_IDA(vdpa_index_ida);
u8 vdpa_get_status(struct vdpa_device *vdev)
{
u8 status;
mutex_lock(&vdev->cf_mutex);
status = vdev->config->get_status(vdev);
mutex_unlock(&vdev->cf_mutex);
return status;
}
EXPORT_SYMBOL(vdpa_get_status);
void vdpa_set_status(struct vdpa_device *vdev, u8 status) void vdpa_set_status(struct vdpa_device *vdev, u8 status)
{ {
mutex_lock(&vdev->cf_mutex); mutex_lock(&vdev->cf_mutex);
......
...@@ -142,9 +142,10 @@ static long vhost_vdpa_get_device_id(struct vhost_vdpa *v, u8 __user *argp) ...@@ -142,9 +142,10 @@ static long vhost_vdpa_get_device_id(struct vhost_vdpa *v, u8 __user *argp)
static long vhost_vdpa_get_status(struct vhost_vdpa *v, u8 __user *statusp) static long vhost_vdpa_get_status(struct vhost_vdpa *v, u8 __user *statusp)
{ {
struct vdpa_device *vdpa = v->vdpa; struct vdpa_device *vdpa = v->vdpa;
const struct vdpa_config_ops *ops = vdpa->config;
u8 status; u8 status;
status = vdpa_get_status(vdpa); status = ops->get_status(vdpa);
if (copy_to_user(statusp, &status, sizeof(status))) if (copy_to_user(statusp, &status, sizeof(status)))
return -EFAULT; return -EFAULT;
...@@ -163,7 +164,7 @@ static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp) ...@@ -163,7 +164,7 @@ static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp)
if (copy_from_user(&status, statusp, sizeof(status))) if (copy_from_user(&status, statusp, sizeof(status)))
return -EFAULT; return -EFAULT;
status_old = vdpa_get_status(vdpa); status_old = ops->get_status(vdpa);
/* /*
* Userspace shouldn't remove status bits unless reset the * Userspace shouldn't remove status bits unless reset the
......
...@@ -421,7 +421,6 @@ void vdpa_get_config(struct vdpa_device *vdev, unsigned int offset, ...@@ -421,7 +421,6 @@ void vdpa_get_config(struct vdpa_device *vdev, unsigned int offset,
void *buf, unsigned int len); void *buf, unsigned int len);
void vdpa_set_config(struct vdpa_device *dev, unsigned int offset, void vdpa_set_config(struct vdpa_device *dev, unsigned int offset,
const void *buf, unsigned int length); const void *buf, unsigned int length);
u8 vdpa_get_status(struct vdpa_device *vdev);
void vdpa_set_status(struct vdpa_device *vdev, u8 status); void vdpa_set_status(struct vdpa_device *vdev, u8 status);
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment