Skip to content

Commit 57b0779

Browse files
committed
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio updates from Michael Tsirkin: - IRQ bypass support for vdpa and IFC - MLX5 vdpa driver - Endianness fixes for virtio drivers - Misc other fixes * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: (71 commits) vdpa/mlx5: fix up endian-ness for mtu vdpa: Fix pointer math bug in vdpasim_get_config() vdpa/mlx5: Fix pointer math in mlx5_vdpa_get_config() vdpa/mlx5: fix memory allocation failure checks vdpa/mlx5: Fix uninitialised variable in core/mr.c vdpa_sim: init iommu lock virtio_config: fix up warnings on parisc vdpa/mlx5: Add VDPA driver for supported mlx5 devices vdpa/mlx5: Add shared memory registration code vdpa/mlx5: Add support library for mlx5 VDPA implementation vdpa/mlx5: Add hardware descriptive header file vdpa: Modify get_vq_state() to return error code net/vdpa: Use struct for set/get vq state vdpa: remove hard coded virtq num vdpasim: support batch updating vhost-vdpa: support IOTLB batching hints vhost-vdpa: support get/set backend features vhost: generialize backend features setting/getting vhost-vdpa: refine ioctl pre-processing vDPA: dont change vq irq after DRIVER_OK ...
2 parents ce13266 + 8a7c321 commit 57b0779

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+3886
-408
lines changed

arch/um/drivers/virtio_uml.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ static irqreturn_t vu_req_interrupt(int irq, void *data)
385385
}
386386
break;
387387
case VHOST_USER_SLAVE_IOTLB_MSG:
388-
/* not supported - VIRTIO_F_IOMMU_PLATFORM */
388+
/* not supported - VIRTIO_F_ACCESS_PLATFORM */
389389
case VHOST_USER_SLAVE_VRING_HOST_NOTIFIER_MSG:
390390
/* not supported - VHOST_USER_PROTOCOL_F_HOST_NOTIFIER */
391391
default:

arch/x86/kvm/x86.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -10667,11 +10667,17 @@ int kvm_arch_irq_bypass_add_producer(struct irq_bypass_consumer *cons,
1066710667
{
1066810668
struct kvm_kernel_irqfd *irqfd =
1066910669
container_of(cons, struct kvm_kernel_irqfd, consumer);
10670+
int ret;
1067010671

1067110672
irqfd->producer = prod;
10673+
kvm_arch_start_assignment(irqfd->kvm);
10674+
ret = kvm_x86_ops.update_pi_irte(irqfd->kvm,
10675+
prod->irq, irqfd->gsi, 1);
10676+
10677+
if (ret)
10678+
kvm_arch_end_assignment(irqfd->kvm);
1067210679

10673-
return kvm_x86_ops.update_pi_irte(irqfd->kvm,
10674-
prod->irq, irqfd->gsi, 1);
10680+
return ret;
1067510681
}
1067610682

1067710683
void kvm_arch_irq_bypass_del_producer(struct irq_bypass_consumer *cons,
@@ -10694,6 +10700,8 @@ void kvm_arch_irq_bypass_del_producer(struct irq_bypass_consumer *cons,
1069410700
if (ret)
1069510701
printk(KERN_INFO "irq bypass consumer (token %p) unregistration"
1069610702
" fails: %d\n", irqfd->consumer.token, ret);
10703+
10704+
kvm_arch_end_assignment(irqfd->kvm);
1069710705
}
1069810706

1069910707
int kvm_arch_update_irqfd_routing(struct kvm *kvm, unsigned int host_irq,

drivers/crypto/virtio/virtio_crypto_core.c

+23-23
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ static int virtcrypto_update_status(struct virtio_crypto *vcrypto)
204204
u32 status;
205205
int err;
206206

207-
virtio_cread(vcrypto->vdev,
208-
struct virtio_crypto_config, status, &status);
207+
virtio_cread_le(vcrypto->vdev,
208+
struct virtio_crypto_config, status, &status);
209209

210210
/*
211211
* Unknown status bits would be a host error and the driver
@@ -323,31 +323,31 @@ static int virtcrypto_probe(struct virtio_device *vdev)
323323
if (!vcrypto)
324324
return -ENOMEM;
325325

326-
virtio_cread(vdev, struct virtio_crypto_config,
326+
virtio_cread_le(vdev, struct virtio_crypto_config,
327327
max_dataqueues, &max_data_queues);
328328
if (max_data_queues < 1)
329329
max_data_queues = 1;
330330

331-
virtio_cread(vdev, struct virtio_crypto_config,
332-
max_cipher_key_len, &max_cipher_key_len);
333-
virtio_cread(vdev, struct virtio_crypto_config,
334-
max_auth_key_len, &max_auth_key_len);
335-
virtio_cread(vdev, struct virtio_crypto_config,
336-
max_size, &max_size);
337-
virtio_cread(vdev, struct virtio_crypto_config,
338-
crypto_services, &crypto_services);
339-
virtio_cread(vdev, struct virtio_crypto_config,
340-
cipher_algo_l, &cipher_algo_l);
341-
virtio_cread(vdev, struct virtio_crypto_config,
342-
cipher_algo_h, &cipher_algo_h);
343-
virtio_cread(vdev, struct virtio_crypto_config,
344-
hash_algo, &hash_algo);
345-
virtio_cread(vdev, struct virtio_crypto_config,
346-
mac_algo_l, &mac_algo_l);
347-
virtio_cread(vdev, struct virtio_crypto_config,
348-
mac_algo_h, &mac_algo_h);
349-
virtio_cread(vdev, struct virtio_crypto_config,
350-
aead_algo, &aead_algo);
331+
virtio_cread_le(vdev, struct virtio_crypto_config,
332+
max_cipher_key_len, &max_cipher_key_len);
333+
virtio_cread_le(vdev, struct virtio_crypto_config,
334+
max_auth_key_len, &max_auth_key_len);
335+
virtio_cread_le(vdev, struct virtio_crypto_config,
336+
max_size, &max_size);
337+
virtio_cread_le(vdev, struct virtio_crypto_config,
338+
crypto_services, &crypto_services);
339+
virtio_cread_le(vdev, struct virtio_crypto_config,
340+
cipher_algo_l, &cipher_algo_l);
341+
virtio_cread_le(vdev, struct virtio_crypto_config,
342+
cipher_algo_h, &cipher_algo_h);
343+
virtio_cread_le(vdev, struct virtio_crypto_config,
344+
hash_algo, &hash_algo);
345+
virtio_cread_le(vdev, struct virtio_crypto_config,
346+
mac_algo_l, &mac_algo_l);
347+
virtio_cread_le(vdev, struct virtio_crypto_config,
348+
mac_algo_h, &mac_algo_h);
349+
virtio_cread_le(vdev, struct virtio_crypto_config,
350+
aead_algo, &aead_algo);
351351

352352
/* Add virtio crypto device to global table */
353353
err = virtcrypto_devmgr_add_dev(vcrypto);

drivers/gpu/drm/virtio/virtgpu_kms.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ static void virtio_gpu_config_changed_work_func(struct work_struct *work)
3939
u32 events_read, events_clear = 0;
4040

4141
/* read the config space */
42-
virtio_cread(vgdev->vdev, struct virtio_gpu_config,
43-
events_read, &events_read);
42+
virtio_cread_le(vgdev->vdev, struct virtio_gpu_config,
43+
events_read, &events_read);
4444
if (events_read & VIRTIO_GPU_EVENT_DISPLAY) {
4545
if (vgdev->has_edid)
4646
virtio_gpu_cmd_get_edids(vgdev);
@@ -49,8 +49,8 @@ static void virtio_gpu_config_changed_work_func(struct work_struct *work)
4949
drm_helper_hpd_irq_event(vgdev->ddev);
5050
events_clear |= VIRTIO_GPU_EVENT_DISPLAY;
5151
}
52-
virtio_cwrite(vgdev->vdev, struct virtio_gpu_config,
53-
events_clear, &events_clear);
52+
virtio_cwrite_le(vgdev->vdev, struct virtio_gpu_config,
53+
events_clear, &events_clear);
5454
}
5555

5656
static void virtio_gpu_init_vq(struct virtio_gpu_queue *vgvq,
@@ -165,8 +165,8 @@ int virtio_gpu_init(struct drm_device *dev)
165165
}
166166

167167
/* get display info */
168-
virtio_cread(vgdev->vdev, struct virtio_gpu_config,
169-
num_scanouts, &num_scanouts);
168+
virtio_cread_le(vgdev->vdev, struct virtio_gpu_config,
169+
num_scanouts, &num_scanouts);
170170
vgdev->num_scanouts = min_t(uint32_t, num_scanouts,
171171
VIRTIO_GPU_MAX_SCANOUTS);
172172
if (!vgdev->num_scanouts) {
@@ -176,8 +176,8 @@ int virtio_gpu_init(struct drm_device *dev)
176176
}
177177
DRM_INFO("number of scanouts: %d\n", num_scanouts);
178178

179-
virtio_cread(vgdev->vdev, struct virtio_gpu_config,
180-
num_capsets, &num_capsets);
179+
virtio_cread_le(vgdev->vdev, struct virtio_gpu_config,
180+
num_capsets, &num_capsets);
181181
DRM_INFO("number of cap sets: %d\n", num_capsets);
182182

183183
virtio_gpu_modeset_init(vgdev);

drivers/gpu/drm/virtio/virtgpu_object.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ static int virtio_gpu_object_shmem_init(struct virtio_gpu_device *vgdev,
141141
struct virtio_gpu_mem_entry **ents,
142142
unsigned int *nents)
143143
{
144-
bool use_dma_api = !virtio_has_iommu_quirk(vgdev->vdev);
144+
bool use_dma_api = !virtio_has_dma_quirk(vgdev->vdev);
145145
struct virtio_gpu_object_shmem *shmem = to_virtio_gpu_shmem(bo);
146146
struct scatterlist *sg;
147147
int si, ret;

drivers/gpu/drm/virtio/virtgpu_vq.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ void virtio_gpu_cmd_transfer_to_host_2d(struct virtio_gpu_device *vgdev,
599599
struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(objs->objs[0]);
600600
struct virtio_gpu_transfer_to_host_2d *cmd_p;
601601
struct virtio_gpu_vbuffer *vbuf;
602-
bool use_dma_api = !virtio_has_iommu_quirk(vgdev->vdev);
602+
bool use_dma_api = !virtio_has_dma_quirk(vgdev->vdev);
603603
struct virtio_gpu_object_shmem *shmem = to_virtio_gpu_shmem(bo);
604604

605605
if (use_dma_api)
@@ -1015,7 +1015,7 @@ void virtio_gpu_cmd_transfer_to_host_3d(struct virtio_gpu_device *vgdev,
10151015
struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(objs->objs[0]);
10161016
struct virtio_gpu_transfer_host_3d *cmd_p;
10171017
struct virtio_gpu_vbuffer *vbuf;
1018-
bool use_dma_api = !virtio_has_iommu_quirk(vgdev->vdev);
1018+
bool use_dma_api = !virtio_has_dma_quirk(vgdev->vdev);
10191019
struct virtio_gpu_object_shmem *shmem = to_virtio_gpu_shmem(bo);
10201020

10211021
if (use_dma_api)

drivers/iommu/virtio-iommu.c

+17-17
Original file line numberDiff line numberDiff line change
@@ -1010,8 +1010,8 @@ static int viommu_probe(struct virtio_device *vdev)
10101010
if (ret)
10111011
return ret;
10121012

1013-
virtio_cread(vdev, struct virtio_iommu_config, page_size_mask,
1014-
&viommu->pgsize_bitmap);
1013+
virtio_cread_le(vdev, struct virtio_iommu_config, page_size_mask,
1014+
&viommu->pgsize_bitmap);
10151015

10161016
if (!viommu->pgsize_bitmap) {
10171017
ret = -EINVAL;
@@ -1022,25 +1022,25 @@ static int viommu_probe(struct virtio_device *vdev)
10221022
viommu->last_domain = ~0U;
10231023

10241024
/* Optional features */
1025-
virtio_cread_feature(vdev, VIRTIO_IOMMU_F_INPUT_RANGE,
1026-
struct virtio_iommu_config, input_range.start,
1027-
&input_start);
1025+
virtio_cread_le_feature(vdev, VIRTIO_IOMMU_F_INPUT_RANGE,
1026+
struct virtio_iommu_config, input_range.start,
1027+
&input_start);
10281028

1029-
virtio_cread_feature(vdev, VIRTIO_IOMMU_F_INPUT_RANGE,
1030-
struct virtio_iommu_config, input_range.end,
1031-
&input_end);
1029+
virtio_cread_le_feature(vdev, VIRTIO_IOMMU_F_INPUT_RANGE,
1030+
struct virtio_iommu_config, input_range.end,
1031+
&input_end);
10321032

1033-
virtio_cread_feature(vdev, VIRTIO_IOMMU_F_DOMAIN_RANGE,
1034-
struct virtio_iommu_config, domain_range.start,
1035-
&viommu->first_domain);
1033+
virtio_cread_le_feature(vdev, VIRTIO_IOMMU_F_DOMAIN_RANGE,
1034+
struct virtio_iommu_config, domain_range.start,
1035+
&viommu->first_domain);
10361036

1037-
virtio_cread_feature(vdev, VIRTIO_IOMMU_F_DOMAIN_RANGE,
1038-
struct virtio_iommu_config, domain_range.end,
1039-
&viommu->last_domain);
1037+
virtio_cread_le_feature(vdev, VIRTIO_IOMMU_F_DOMAIN_RANGE,
1038+
struct virtio_iommu_config, domain_range.end,
1039+
&viommu->last_domain);
10401040

1041-
virtio_cread_feature(vdev, VIRTIO_IOMMU_F_PROBE,
1042-
struct virtio_iommu_config, probe_size,
1043-
&viommu->probe_size);
1041+
virtio_cread_le_feature(vdev, VIRTIO_IOMMU_F_PROBE,
1042+
struct virtio_iommu_config, probe_size,
1043+
&viommu->probe_size);
10441044

10451045
viommu->geometry = (struct iommu_domain_geometry) {
10461046
.aperture_start = input_start,

drivers/net/virtio_net.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -2264,12 +2264,13 @@ static void virtnet_update_settings(struct virtnet_info *vi)
22642264
if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_SPEED_DUPLEX))
22652265
return;
22662266

2267-
speed = virtio_cread32(vi->vdev, offsetof(struct virtio_net_config,
2268-
speed));
2267+
virtio_cread_le(vi->vdev, struct virtio_net_config, speed, &speed);
2268+
22692269
if (ethtool_validate_speed(speed))
22702270
vi->speed = speed;
2271-
duplex = virtio_cread8(vi->vdev, offsetof(struct virtio_net_config,
2272-
duplex));
2271+
2272+
virtio_cread_le(vi->vdev, struct virtio_net_config, duplex, &duplex);
2273+
22732274
if (ethtool_validate_duplex(duplex))
22742275
vi->duplex = duplex;
22752276
}

drivers/nvdimm/virtio_pmem.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ static int virtio_pmem_probe(struct virtio_device *vdev)
5858
goto out_err;
5959
}
6060

61-
virtio_cread(vpmem->vdev, struct virtio_pmem_config,
61+
virtio_cread_le(vpmem->vdev, struct virtio_pmem_config,
6262
start, &vpmem->start);
63-
virtio_cread(vpmem->vdev, struct virtio_pmem_config,
63+
virtio_cread_le(vpmem->vdev, struct virtio_pmem_config,
6464
size, &vpmem->size);
6565

6666
res.start = vpmem->start;

drivers/platform/mellanox/mlxbf-tmfifo.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,10 @@ static void mlxbf_tmfifo_rxtx_header(struct mlxbf_tmfifo_vring *vring,
625625
vdev_id = VIRTIO_ID_NET;
626626
hdr_len = sizeof(struct virtio_net_hdr);
627627
config = &fifo->vdev[vdev_id]->config.net;
628-
if (ntohs(hdr.len) > config->mtu +
628+
/* A legacy-only interface for now. */
629+
if (ntohs(hdr.len) >
630+
__virtio16_to_cpu(virtio_legacy_is_little_endian(),
631+
config->mtu) +
629632
MLXBF_TMFIFO_NET_L2_OVERHEAD)
630633
return;
631634
} else {
@@ -1231,8 +1234,12 @@ static int mlxbf_tmfifo_probe(struct platform_device *pdev)
12311234

12321235
/* Create the network vdev. */
12331236
memset(&net_config, 0, sizeof(net_config));
1234-
net_config.mtu = ETH_DATA_LEN;
1235-
net_config.status = VIRTIO_NET_S_LINK_UP;
1237+
1238+
/* A legacy-only interface for now. */
1239+
net_config.mtu = __cpu_to_virtio16(virtio_legacy_is_little_endian(),
1240+
ETH_DATA_LEN);
1241+
net_config.status = __cpu_to_virtio16(virtio_legacy_is_little_endian(),
1242+
VIRTIO_NET_S_LINK_UP);
12361243
mlxbf_tmfifo_get_cfg_mac(net_config.mac);
12371244
rc = mlxbf_tmfifo_create_vdev(dev, fifo, VIRTIO_ID_NET,
12381245
MLXBF_TMFIFO_NET_FEATURES, &net_config,

drivers/scsi/virtio_scsi.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -754,14 +754,14 @@ static struct scsi_host_template virtscsi_host_template = {
754754

755755
#define virtscsi_config_get(vdev, fld) \
756756
({ \
757-
typeof(((struct virtio_scsi_config *)0)->fld) __val; \
757+
__virtio_native_type(struct virtio_scsi_config, fld) __val; \
758758
virtio_cread(vdev, struct virtio_scsi_config, fld, &__val); \
759759
__val; \
760760
})
761761

762762
#define virtscsi_config_set(vdev, fld, val) \
763763
do { \
764-
typeof(((struct virtio_scsi_config *)0)->fld) __val = (val); \
764+
__virtio_native_type(struct virtio_scsi_config, fld) __val = (val); \
765765
virtio_cwrite(vdev, struct virtio_scsi_config, fld, &__val); \
766766
} while(0)
767767

drivers/vdpa/Kconfig

+19
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,23 @@ config IFCVF
2929
To compile this driver as a module, choose M here: the module will
3030
be called ifcvf.
3131

32+
config MLX5_VDPA
33+
bool "MLX5 VDPA support library for ConnectX devices"
34+
depends on MLX5_CORE
35+
default n
36+
help
37+
Support library for Mellanox VDPA drivers. Provides code that is
38+
common for all types of VDPA drivers. The following drivers are planned:
39+
net, block.
40+
41+
config MLX5_VDPA_NET
42+
tristate "vDPA driver for ConnectX devices"
43+
depends on MLX5_VDPA
44+
default n
45+
help
46+
VDPA network driver for ConnectX6 and newer. Provides offloading
47+
of virtio net datapath such that descriptors put on the ring will
48+
be executed by the hardware. It also supports a variety of stateless
49+
offloads depending on the actual device used and firmware version.
50+
3251
endif # VDPA

drivers/vdpa/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
obj-$(CONFIG_VDPA) += vdpa.o
33
obj-$(CONFIG_VDPA_SIM) += vdpa_sim/
44
obj-$(CONFIG_IFCVF) += ifcvf/
5+
obj-$(CONFIG_MLX5_VDPA) += mlx5/

drivers/vdpa/ifcvf/ifcvf_base.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ static int ifcvf_config_features(struct ifcvf_hw *hw)
272272
return 0;
273273
}
274274

275-
u64 ifcvf_get_vq_state(struct ifcvf_hw *hw, u16 qid)
275+
u16 ifcvf_get_vq_state(struct ifcvf_hw *hw, u16 qid)
276276
{
277277
struct ifcvf_lm_cfg __iomem *ifcvf_lm;
278278
void __iomem *avail_idx_addr;
@@ -287,7 +287,7 @@ u64 ifcvf_get_vq_state(struct ifcvf_hw *hw, u16 qid)
287287
return last_avail_idx;
288288
}
289289

290-
int ifcvf_set_vq_state(struct ifcvf_hw *hw, u16 qid, u64 num)
290+
int ifcvf_set_vq_state(struct ifcvf_hw *hw, u16 qid, u16 num)
291291
{
292292
struct ifcvf_lm_cfg __iomem *ifcvf_lm;
293293
void __iomem *avail_idx_addr;

drivers/vdpa/ifcvf/ifcvf_base.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
(1ULL << VIRTIO_F_VERSION_1) | \
3030
(1ULL << VIRTIO_NET_F_STATUS) | \
3131
(1ULL << VIRTIO_F_ORDER_PLATFORM) | \
32-
(1ULL << VIRTIO_F_IOMMU_PLATFORM) | \
32+
(1ULL << VIRTIO_F_ACCESS_PLATFORM) | \
3333
(1ULL << VIRTIO_NET_F_MRG_RXBUF))
3434

3535
/* Only one queue pair for now. */
@@ -116,7 +116,7 @@ void ifcvf_set_status(struct ifcvf_hw *hw, u8 status);
116116
void io_write64_twopart(u64 val, u32 *lo, u32 *hi);
117117
void ifcvf_reset(struct ifcvf_hw *hw);
118118
u64 ifcvf_get_features(struct ifcvf_hw *hw);
119-
u64 ifcvf_get_vq_state(struct ifcvf_hw *hw, u16 qid);
120-
int ifcvf_set_vq_state(struct ifcvf_hw *hw, u16 qid, u64 num);
119+
u16 ifcvf_get_vq_state(struct ifcvf_hw *hw, u16 qid);
120+
int ifcvf_set_vq_state(struct ifcvf_hw *hw, u16 qid, u16 num);
121121
struct ifcvf_adapter *vf_to_adapter(struct ifcvf_hw *hw);
122122
#endif /* _IFCVF_H_ */

0 commit comments

Comments
 (0)