Skip to content

Commit

Permalink
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/gi…
Browse files Browse the repository at this point in the history
…t/mst/vhost

Pull virtio updates from Michael Tsirkin:
 "virtio,vdpa,qemu_fw_cfg: features, cleanups, and fixes.

   - partial support for < MAX_ORDER - 1 granularity for virtio-mem

   - driver_override for vdpa

   - sysfs ABI documentation for vdpa

   - multiqueue config support for mlx5 vdpa

   - and misc fixes, cleanups"

* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: (42 commits)
  vdpa/mlx5: Fix tracking of current number of VQs
  vdpa/mlx5: Fix is_index_valid() to refer to features
  vdpa: Protect vdpa reset with cf_mutex
  vdpa: Avoid taking cf_mutex lock on get status
  vdpa/vdpa_sim_net: Report max device capabilities
  vdpa: Use BIT_ULL for bit operations
  vdpa/vdpa_sim: Configure max supported virtqueues
  vdpa/mlx5: Report max device capabilities
  vdpa: Support reporting max device capabilities
  vdpa/mlx5: Restore cur_num_vqs in case of failure in change_num_qps()
  vdpa: Add support for returning device configuration information
  vdpa/mlx5: Support configuring max data virtqueue
  vdpa/mlx5: Fix config_attr_mask assignment
  vdpa: Allow to configure max data virtqueues
  vdpa: Read device configuration only if FEATURES_OK
  vdpa: Sync calls set/get config/status with cf_mutex
  vdpa/mlx5: Distribute RX virtqueues in RQT object
  vdpa: Provide interface to read driver features
  vdpa: clean up get_config_size ret value handling
  virtio_ring: mark ring unused on error
  ...
  • Loading branch information
torvalds committed Jan 18, 2022
2 parents 46a10fc + b03fc43 commit 3bf6a9e
Show file tree
Hide file tree
Showing 47 changed files with 578 additions and 237 deletions.
57 changes: 57 additions & 0 deletions Documentation/ABI/testing/sysfs-bus-vdpa
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
What: /sys/bus/vdpa/driver_autoprobe
Date: March 2020
Contact: [email protected]
Description:
This file determines whether new devices are immediately bound
to a driver after the creation. It initially contains 1, which
means the kernel automatically binds devices to a compatible
driver immediately after they are created.

Writing "0" to this file disable this feature, any other string
enable it.

What: /sys/bus/vdpa/driver_probe
Date: March 2020
Contact: [email protected]
Description:
Writing a device name to this file will cause the kernel binds
devices to a compatible driver.

This can be useful when /sys/bus/vdpa/driver_autoprobe is
disabled.

What: /sys/bus/vdpa/drivers/.../bind
Date: March 2020
Contact: [email protected]
Description:
Writing a device name to this file will cause the driver to
attempt to bind to the device. This is useful for overriding
default bindings.

What: /sys/bus/vdpa/drivers/.../unbind
Date: March 2020
Contact: [email protected]
Description:
Writing a device name to this file will cause the driver to
attempt to unbind from the device. This may be useful when
overriding default bindings.

What: /sys/bus/vdpa/devices/.../driver_override
Date: November 2021
Contact: [email protected]
Description:
This file allows the driver for a device to be specified.
When specified, only a driver with a name matching the value
written to driver_override will have an opportunity to bind to
the device. The override is specified by writing a string to the
driver_override file (echo vhost-vdpa > driver_override) and may
be cleared with an empty string (echo > driver_override).
This returns the device to standard matching rules binding.
Writing to driver_override does not automatically unbind the
device from its current driver or make any attempt to
automatically load the specified driver. If no driver with a
matching name is currently loaded in the kernel, the device will
not bind to any driver. This also allows devices to opt-out of
driver binding using a driver_override name such as "none".
Only a single driver may be specified in the override, there is
no support for parsing delimiters.
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -20377,6 +20377,7 @@ M: "Michael S. Tsirkin" <[email protected]>
M: Jason Wang <[email protected]>
L: [email protected]
S: Maintained
F: Documentation/ABI/testing/sysfs-bus-vdpa
F: Documentation/devicetree/bindings/virtio/
F: drivers/block/virtio_blk.c
F: drivers/crypto/virtio/
Expand Down
2 changes: 1 addition & 1 deletion arch/um/drivers/virt-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ static void um_pci_virtio_remove(struct virtio_device *vdev)
int i;

/* Stop all virtqueues */
vdev->config->reset(vdev);
virtio_reset_device(vdev);
vdev->config->del_vqs(vdev);

device_set_wakeup_enable(&vdev->dev, false);
Expand Down
4 changes: 2 additions & 2 deletions drivers/block/virtio_blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ static void virtblk_remove(struct virtio_device *vdev)
mutex_lock(&vblk->vdev_mutex);

/* Stop all the virtqueues. */
vdev->config->reset(vdev);
virtio_reset_device(vdev);

/* Virtqueues are stopped, nothing can use vblk->vdev anymore. */
vblk->vdev = NULL;
Expand All @@ -995,7 +995,7 @@ static int virtblk_freeze(struct virtio_device *vdev)
struct virtio_blk *vblk = vdev->priv;

/* Ensure we don't receive any more interrupts */
vdev->config->reset(vdev);
virtio_reset_device(vdev);

/* Make sure no work handler is accessing the device. */
flush_work(&vblk->config_work);
Expand Down
2 changes: 1 addition & 1 deletion drivers/bluetooth/virtio_bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ static void virtbt_remove(struct virtio_device *vdev)
struct hci_dev *hdev = vbt->hdev;

hci_unregister_dev(hdev);
vdev->config->reset(vdev);
virtio_reset_device(vdev);

hci_free_dev(hdev);
vbt->hdev = NULL;
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/hw_random/virtio-rng.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ static void remove_common(struct virtio_device *vdev)
vi->data_avail = 0;
vi->data_idx = 0;
complete(&vi->have_data);
vdev->config->reset(vdev);
if (vi->hwrng_register_done)
hwrng_unregister(&vi->hwrng);
virtio_reset_device(vdev);
vdev->config->del_vqs(vdev);
ida_simple_remove(&rng_index_ida, vi->index);
kfree(vi);
Expand Down
4 changes: 2 additions & 2 deletions drivers/char/virtio_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -1958,7 +1958,7 @@ static void virtcons_remove(struct virtio_device *vdev)
spin_unlock_irq(&pdrvdata_lock);

/* Disable interrupts for vqs */
vdev->config->reset(vdev);
virtio_reset_device(vdev);
/* Finish up work that's lined up */
if (use_multiport(portdev))
cancel_work_sync(&portdev->control_work);
Expand Down Expand Up @@ -2148,7 +2148,7 @@ static int virtcons_freeze(struct virtio_device *vdev)

portdev = vdev->priv;

vdev->config->reset(vdev);
virtio_reset_device(vdev);

if (use_multiport(portdev))
virtqueue_disable_cb(portdev->c_ivq);
Expand Down
8 changes: 4 additions & 4 deletions drivers/crypto/virtio/virtio_crypto_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ static int virtcrypto_probe(struct virtio_device *vdev)
free_engines:
virtcrypto_clear_crypto_engines(vcrypto);
free_vqs:
vcrypto->vdev->config->reset(vdev);
virtio_reset_device(vdev);
virtcrypto_del_vqs(vcrypto);
free_dev:
virtcrypto_devmgr_rm_dev(vcrypto);
Expand Down Expand Up @@ -436,7 +436,7 @@ static void virtcrypto_remove(struct virtio_device *vdev)

if (virtcrypto_dev_started(vcrypto))
virtcrypto_dev_stop(vcrypto);
vdev->config->reset(vdev);
virtio_reset_device(vdev);
virtcrypto_free_unused_reqs(vcrypto);
virtcrypto_clear_crypto_engines(vcrypto);
virtcrypto_del_vqs(vcrypto);
Expand All @@ -456,7 +456,7 @@ static int virtcrypto_freeze(struct virtio_device *vdev)
{
struct virtio_crypto *vcrypto = vdev->priv;

vdev->config->reset(vdev);
virtio_reset_device(vdev);
virtcrypto_free_unused_reqs(vcrypto);
if (virtcrypto_dev_started(vcrypto))
virtcrypto_dev_stop(vcrypto);
Expand Down Expand Up @@ -492,7 +492,7 @@ static int virtcrypto_restore(struct virtio_device *vdev)
free_engines:
virtcrypto_clear_crypto_engines(vcrypto);
free_vqs:
vcrypto->vdev->config->reset(vdev);
virtio_reset_device(vdev);
virtcrypto_del_vqs(vcrypto);
return err;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/firmware/arm_scmi/virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ static void scmi_vio_remove(struct virtio_device *vdev)
* outstanding message on any vqueue to be ignored by complete_cb: now
* we can just stop processing buffers and destroy the vqueues.
*/
vdev->config->reset(vdev);
virtio_reset_device(vdev);
vdev->config->del_vqs(vdev);
/* Ensure scmi_vdev is visible as NULL */
smp_store_mb(scmi_vdev, NULL);
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ static void virtio_gpio_request_vq(struct virtqueue *vq)

static void virtio_gpio_free_vqs(struct virtio_device *vdev)
{
vdev->config->reset(vdev);
virtio_reset_device(vdev);
vdev->config->del_vqs(vdev);
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/virtio/virtgpu_kms.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ void virtio_gpu_deinit(struct drm_device *dev)
flush_work(&vgdev->ctrlq.dequeue_work);
flush_work(&vgdev->cursorq.dequeue_work);
flush_work(&vgdev->config_changed_work);
vgdev->vdev->config->reset(vgdev->vdev);
virtio_reset_device(vgdev->vdev);
vgdev->vdev->config->del_vqs(vgdev->vdev);
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/i2c/busses/i2c-virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ static int virtio_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,

static void virtio_i2c_del_vqs(struct virtio_device *vdev)
{
vdev->config->reset(vdev);
virtio_reset_device(vdev);
vdev->config->del_vqs(vdev);
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/iommu/virtio-iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ static void viommu_remove(struct virtio_device *vdev)
iommu_device_unregister(&viommu->iommu);

/* Stop all virtqueues */
vdev->config->reset(vdev);
virtio_reset_device(vdev);
vdev->config->del_vqs(vdev);

dev_info(&vdev->dev, "device removed\n");
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/caif/caif_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ static void cfv_remove(struct virtio_device *vdev)
debugfs_remove_recursive(cfv->debugfs);

vringh_kiov_cleanup(&cfv->ctx.riov);
vdev->config->reset(vdev);
virtio_reset_device(vdev);
vdev->vringh_config->del_vrhs(cfv->vdev);
cfv->vr_rx = NULL;
vdev->config->del_vqs(cfv->vdev);
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/virtio_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -3312,7 +3312,7 @@ static int virtnet_probe(struct virtio_device *vdev)
return 0;

free_unregister_netdev:
vi->vdev->config->reset(vdev);
virtio_reset_device(vdev);

unregister_netdev(dev);
free_failover:
Expand All @@ -3328,7 +3328,7 @@ static int virtnet_probe(struct virtio_device *vdev)

static void remove_vq_common(struct virtnet_info *vi)
{
vi->vdev->config->reset(vi->vdev);
virtio_reset_device(vi->vdev);

/* Free unused buffers in both send and recv, if any. */
free_unused_bufs(vi);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/mac80211_hwsim.c
Original file line number Diff line number Diff line change
Expand Up @@ -4498,7 +4498,7 @@ static void remove_vqs(struct virtio_device *vdev)
{
int i;

vdev->config->reset(vdev);
virtio_reset_device(vdev);

for (i = 0; i < ARRAY_SIZE(hwsim_vqs); i++) {
struct virtqueue *vq = hwsim_vqs[i];
Expand Down
2 changes: 1 addition & 1 deletion drivers/nvdimm/virtio_pmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static void virtio_pmem_remove(struct virtio_device *vdev)

nvdimm_bus_unregister(nvdimm_bus);
vdev->config->del_vqs(vdev);
vdev->config->reset(vdev);
virtio_reset_device(vdev);
}

static struct virtio_driver virtio_pmem_driver = {
Expand Down
2 changes: 1 addition & 1 deletion drivers/rpmsg/virtio_rpmsg_bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ static void rpmsg_remove(struct virtio_device *vdev)
size_t total_buf_space = vrp->num_bufs * vrp->buf_size;
int ret;

vdev->config->reset(vdev);
virtio_reset_device(vdev);

ret = device_for_each_child(&vdev->dev, NULL, rpmsg_remove_device);
if (ret)
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/virtio_scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ static void virtscsi_init_vq(struct virtio_scsi_vq *virtscsi_vq,
static void virtscsi_remove_vqs(struct virtio_device *vdev)
{
/* Stop all the virtqueues. */
vdev->config->reset(vdev);
virtio_reset_device(vdev);
vdev->config->del_vqs(vdev);
}

Expand Down
28 changes: 12 additions & 16 deletions drivers/vdpa/alibaba/eni_vdpa.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static struct virtio_pci_legacy_device *vdpa_to_ldev(struct vdpa_device *vdpa)
return &eni_vdpa->ldev;
}

static u64 eni_vdpa_get_features(struct vdpa_device *vdpa)
static u64 eni_vdpa_get_device_features(struct vdpa_device *vdpa)
{
struct virtio_pci_legacy_device *ldev = vdpa_to_ldev(vdpa);
u64 features = vp_legacy_get_features(ldev);
Expand All @@ -69,7 +69,7 @@ static u64 eni_vdpa_get_features(struct vdpa_device *vdpa)
return features;
}

static int eni_vdpa_set_features(struct vdpa_device *vdpa, u64 features)
static int eni_vdpa_set_driver_features(struct vdpa_device *vdpa, u64 features)
{
struct virtio_pci_legacy_device *ldev = vdpa_to_ldev(vdpa);

Expand All @@ -84,6 +84,13 @@ static int eni_vdpa_set_features(struct vdpa_device *vdpa, u64 features)
return 0;
}

static u64 eni_vdpa_get_driver_features(struct vdpa_device *vdpa)
{
struct virtio_pci_legacy_device *ldev = vdpa_to_ldev(vdpa);

return vp_legacy_get_driver_features(ldev);
}

static u8 eni_vdpa_get_status(struct vdpa_device *vdpa)
{
struct virtio_pci_legacy_device *ldev = vdpa_to_ldev(vdpa);
Expand Down Expand Up @@ -401,8 +408,9 @@ static void eni_vdpa_set_config_cb(struct vdpa_device *vdpa,
}

static const struct vdpa_config_ops eni_vdpa_ops = {
.get_features = eni_vdpa_get_features,
.set_features = eni_vdpa_set_features,
.get_device_features = eni_vdpa_get_device_features,
.set_driver_features = eni_vdpa_set_driver_features,
.get_driver_features = eni_vdpa_get_driver_features,
.get_status = eni_vdpa_get_status,
.set_status = eni_vdpa_set_status,
.reset = eni_vdpa_reset,
Expand Down Expand Up @@ -450,11 +458,6 @@ static u16 eni_vdpa_get_num_queues(struct eni_vdpa *eni_vdpa)
return num;
}

static void eni_vdpa_free_irq_vectors(void *data)
{
pci_free_irq_vectors(data);
}

static int eni_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct device *dev = &pdev->dev;
Expand Down Expand Up @@ -488,13 +491,6 @@ static int eni_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id)
eni_vdpa->vdpa.dma_dev = &pdev->dev;
eni_vdpa->queues = eni_vdpa_get_num_queues(eni_vdpa);

ret = devm_add_action_or_reset(dev, eni_vdpa_free_irq_vectors, pdev);
if (ret) {
ENI_ERR(pdev,
"failed for adding devres for freeing irq vectors\n");
goto err;
}

eni_vdpa->vring = devm_kcalloc(&pdev->dev, eni_vdpa->queues,
sizeof(*eni_vdpa->vring),
GFP_KERNEL);
Expand Down
Loading

0 comments on commit 3bf6a9e

Please sign in to comment.