mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/
synced 2026-04-17 22:23:45 -04:00
net/vdpa: Use readers/writers semaphore instead of cf_mutex
Replace cf_mutex with rw_semaphore to reflect the fact that some calls could be called concurrently but can suffice with read lock. Suggested-by: Si-Wei Liu <si-wei.liu@oracle.com> Signed-off-by: Eli Cohen <elic@nvidia.com> Message-Id: <20220518133804.1075129-5-elic@nvidia.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
committed by
Michael S. Tsirkin
parent
0078ad905d
commit
a6a51adc6e
@@ -66,7 +66,7 @@ struct vdpa_mgmt_dev;
|
||||
* @dma_dev: the actual device that is performing DMA
|
||||
* @driver_override: driver name to force a match
|
||||
* @config: the configuration ops for this device.
|
||||
* @cf_mutex: Protects get and set access to configuration layout.
|
||||
* @cf_lock: Protects get and set access to configuration layout.
|
||||
* @index: device index
|
||||
* @features_valid: were features initialized? for legacy guests
|
||||
* @use_va: indicate whether virtual address must be used by this device
|
||||
@@ -79,7 +79,7 @@ struct vdpa_device {
|
||||
struct device *dma_dev;
|
||||
const char *driver_override;
|
||||
const struct vdpa_config_ops *config;
|
||||
struct mutex cf_mutex; /* Protects get/set config */
|
||||
struct rw_semaphore cf_lock; /* Protects get/set config */
|
||||
unsigned int index;
|
||||
bool features_valid;
|
||||
bool use_va;
|
||||
@@ -398,10 +398,10 @@ static inline int vdpa_reset(struct vdpa_device *vdev)
|
||||
const struct vdpa_config_ops *ops = vdev->config;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&vdev->cf_mutex);
|
||||
down_write(&vdev->cf_lock);
|
||||
vdev->features_valid = false;
|
||||
ret = ops->reset(vdev);
|
||||
mutex_unlock(&vdev->cf_mutex);
|
||||
up_write(&vdev->cf_lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -420,9 +420,9 @@ static inline int vdpa_set_features(struct vdpa_device *vdev, u64 features)
|
||||
{
|
||||
int ret;
|
||||
|
||||
mutex_lock(&vdev->cf_mutex);
|
||||
down_write(&vdev->cf_lock);
|
||||
ret = vdpa_set_features_unlocked(vdev, features);
|
||||
mutex_unlock(&vdev->cf_mutex);
|
||||
up_write(&vdev->cf_lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user