Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost

Pull vdpa/mlx5 fixes from Michael Tsirkin:
"Last minute fixes.

These all look like something we are better off having
than not ..."

* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
vdpa/mlx5: Fix suspend/resume index restoration
vdpa/mlx5: Fix wrong use of bit numbers
vdpa/mlx5: Retrieve BAR address suitable any function
vdpa/mlx5: Use the correct dma device when registering memory
vdpa/mlx5: should exclude header length and fcs from mtu

+37 -19
+4
drivers/vdpa/mlx5/core/mlx5_vdpa.h
··· 4 4 #ifndef __MLX5_VDPA_H__ 5 5 #define __MLX5_VDPA_H__ 6 6 7 + #include <linux/etherdevice.h> 8 + #include <linux/if_vlan.h> 7 9 #include <linux/vdpa.h> 8 10 #include <linux/mlx5/driver.h> 11 + 12 + #define MLX5V_ETH_HARD_MTU (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN) 9 13 10 14 struct mlx5_vdpa_direct_mr { 11 15 u64 start;
+7 -2
drivers/vdpa/mlx5/core/mr.c
··· 219 219 mlx5_vdpa_destroy_mkey(mvdev, &mkey->mkey); 220 220 } 221 221 222 + static struct device *get_dma_device(struct mlx5_vdpa_dev *mvdev) 223 + { 224 + return &mvdev->mdev->pdev->dev; 225 + } 226 + 222 227 static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr *mr, 223 228 struct vhost_iotlb *iotlb) 224 229 { ··· 239 234 u64 pa; 240 235 u64 paend; 241 236 struct scatterlist *sg; 242 - struct device *dma = mvdev->mdev->device; 237 + struct device *dma = get_dma_device(mvdev); 243 238 244 239 for (map = vhost_iotlb_itree_first(iotlb, mr->start, mr->end - 1); 245 240 map; map = vhost_iotlb_itree_next(map, start, mr->end - 1)) { ··· 296 291 297 292 static void unmap_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr *mr) 298 293 { 299 - struct device *dma = mvdev->mdev->device; 294 + struct device *dma = get_dma_device(mvdev); 300 295 301 296 destroy_direct_mr(mvdev, mr); 302 297 dma_unmap_sg_attrs(dma, mr->sg_head.sgl, mr->nsg, DMA_BIDIRECTIONAL, 0);
+2 -1
drivers/vdpa/mlx5/core/resources.c
··· 246 246 if (err) 247 247 goto err_key; 248 248 249 - kick_addr = pci_resource_start(mdev->pdev, 0) + offset; 249 + kick_addr = mdev->bar_addr + offset; 250 + 250 251 res->kick_addr = ioremap(kick_addr, PAGE_SIZE); 251 252 if (!res->kick_addr) { 252 253 err = -ENOMEM;
+24 -16
drivers/vdpa/mlx5/net/mlx5_vnet.c
··· 820 820 MLX5_SET(virtio_q, vq_ctx, event_qpn_or_msix, mvq->fwqp.mqp.qpn); 821 821 MLX5_SET(virtio_q, vq_ctx, queue_size, mvq->num_ent); 822 822 MLX5_SET(virtio_q, vq_ctx, virtio_version_1_0, 823 - !!(ndev->mvdev.actual_features & VIRTIO_F_VERSION_1)); 823 + !!(ndev->mvdev.actual_features & BIT_ULL(VIRTIO_F_VERSION_1))); 824 824 MLX5_SET64(virtio_q, vq_ctx, desc_addr, mvq->desc_addr); 825 825 MLX5_SET64(virtio_q, vq_ctx, used_addr, mvq->device_addr); 826 826 MLX5_SET64(virtio_q, vq_ctx, available_addr, mvq->driver_addr); ··· 1169 1169 return; 1170 1170 } 1171 1171 mvq->avail_idx = attr.available_index; 1172 + mvq->used_idx = attr.used_index; 1172 1173 } 1173 1174 1174 1175 static void suspend_vqs(struct mlx5_vdpa_net *ndev) ··· 1427 1426 return -EINVAL; 1428 1427 } 1429 1428 1429 + mvq->used_idx = state->avail_index; 1430 1430 mvq->avail_idx = state->avail_index; 1431 1431 return 0; 1432 1432 } ··· 1445 1443 * that cares about emulating the index after vq is stopped. 1446 1444 */ 1447 1445 if (!mvq->initialized) { 1448 - state->avail_index = mvq->avail_idx; 1446 + /* Firmware returns a wrong value for the available index. 1447 + * Since both values should be identical, we take the value of 1448 + * used_idx which is reported correctly. 1449 + */ 1450 + state->avail_index = mvq->used_idx; 1449 1451 return 0; 1450 1452 } 1451 1453 ··· 1458 1452 mlx5_vdpa_warn(mvdev, "failed to query virtqueue\n"); 1459 1453 return err; 1460 1454 } 1461 - state->avail_index = attr.available_index; 1455 + state->avail_index = attr.used_index; 1462 1456 return 0; 1463 1457 } 1464 1458 ··· 1546 1540 } 1547 1541 } 1548 1542 1549 - static void clear_virtqueues(struct mlx5_vdpa_net *ndev) 1550 - { 1551 - int i; 1552 - 1553 - for (i = ndev->mvdev.max_vqs - 1; i >= 0; i--) { 1554 - ndev->vqs[i].avail_idx = 0; 1555 - ndev->vqs[i].used_idx = 0; 1556 - } 1557 - } 1558 - 1559 1543 /* TODO: cross-endian support */ 1560 1544 static inline bool mlx5_vdpa_is_little_endian(struct mlx5_vdpa_dev *mvdev) 1561 1545 { 1562 1546 return virtio_legacy_is_little_endian() || 1563 - (mvdev->actual_features & (1ULL << VIRTIO_F_VERSION_1)); 1547 + (mvdev->actual_features & BIT_ULL(VIRTIO_F_VERSION_1)); 1564 1548 } 1565 1549 1566 1550 static __virtio16 cpu_to_mlx5vdpa16(struct mlx5_vdpa_dev *mvdev, u16 val) ··· 1781 1785 if (!status) { 1782 1786 mlx5_vdpa_info(mvdev, "performing device reset\n"); 1783 1787 teardown_driver(ndev); 1784 - clear_virtqueues(ndev); 1785 1788 mlx5_vdpa_destroy_mr(&ndev->mvdev); 1786 1789 ndev->mvdev.status = 0; 1787 1790 ndev->mvdev.mlx_features = 0; ··· 1902 1907 .free = mlx5_vdpa_free, 1903 1908 }; 1904 1909 1910 + static int query_mtu(struct mlx5_core_dev *mdev, u16 *mtu) 1911 + { 1912 + u16 hw_mtu; 1913 + int err; 1914 + 1915 + err = mlx5_query_nic_vport_mtu(mdev, &hw_mtu); 1916 + if (err) 1917 + return err; 1918 + 1919 + *mtu = hw_mtu - MLX5V_ETH_HARD_MTU; 1920 + return 0; 1921 + } 1922 + 1905 1923 static int alloc_resources(struct mlx5_vdpa_net *ndev) 1906 1924 { 1907 1925 struct mlx5_vdpa_net_resources *res = &ndev->res; ··· 2000 1992 init_mvqs(ndev); 2001 1993 mutex_init(&ndev->reslock); 2002 1994 config = &ndev->config; 2003 - err = mlx5_query_nic_vport_mtu(mdev, &ndev->mtu); 1995 + err = query_mtu(mdev, &ndev->mtu); 2004 1996 if (err) 2005 1997 goto err_mtu; 2006 1998