Skip to content

Commit f6d955d

Browse files
elic307imstsirkin
authored andcommitted
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: f489f27 ("vdpa: Sync calls set/get config/status with cf_mutex") Signed-off-by: Eli Cohen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Si-Wei Liu<[email protected]> Acked-by: Jason Wang <[email protected]>
1 parent b2ce619 commit f6d955d

File tree

3 files changed

+3
-14
lines changed

3 files changed

+3
-14
lines changed

drivers/vdpa/vdpa.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,6 @@ static LIST_HEAD(mdev_head);
2121
static DEFINE_MUTEX(vdpa_dev_mutex);
2222
static DEFINE_IDA(vdpa_index_ida);
2323

24-
u8 vdpa_get_status(struct vdpa_device *vdev)
25-
{
26-
u8 status;
27-
28-
mutex_lock(&vdev->cf_mutex);
29-
status = vdev->config->get_status(vdev);
30-
mutex_unlock(&vdev->cf_mutex);
31-
return status;
32-
}
33-
EXPORT_SYMBOL(vdpa_get_status);
34-
3524
void vdpa_set_status(struct vdpa_device *vdev, u8 status)
3625
{
3726
mutex_lock(&vdev->cf_mutex);

drivers/vhost/vdpa.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,10 @@ static long vhost_vdpa_get_device_id(struct vhost_vdpa *v, u8 __user *argp)
142142
static long vhost_vdpa_get_status(struct vhost_vdpa *v, u8 __user *statusp)
143143
{
144144
struct vdpa_device *vdpa = v->vdpa;
145+
const struct vdpa_config_ops *ops = vdpa->config;
145146
u8 status;
146147

147-
status = vdpa_get_status(vdpa);
148+
status = ops->get_status(vdpa);
148149

149150
if (copy_to_user(statusp, &status, sizeof(status)))
150151
return -EFAULT;
@@ -163,7 +164,7 @@ static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp)
163164
if (copy_from_user(&status, statusp, sizeof(status)))
164165
return -EFAULT;
165166

166-
status_old = vdpa_get_status(vdpa);
167+
status_old = ops->get_status(vdpa);
167168

168169
/*
169170
* Userspace shouldn't remove status bits unless reset the

include/linux/vdpa.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,6 @@ void vdpa_get_config(struct vdpa_device *vdev, unsigned int offset,
421421
void *buf, unsigned int len);
422422
void vdpa_set_config(struct vdpa_device *dev, unsigned int offset,
423423
const void *buf, unsigned int length);
424-
u8 vdpa_get_status(struct vdpa_device *vdev);
425424
void vdpa_set_status(struct vdpa_device *vdev, u8 status);
426425

427426
/**

0 commit comments

Comments
 (0)