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 virtio fixes from Michael Tsirkin:
"A collection of small fixes that look like worth having in this
release"

* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
virtio_pci: fix the common cfg map size
virtio-crypto: handle config changed by work queue
vhost: Allow null msg.size on VHOST_IOTLB_INVALIDATE
vdpa/mlx5: Fix firmware error on creation of 1k VQs
virtio_balloon: Fix endless deflation and inflation on arm64
vdpa/mlx5: Fix double release of debugfs entry
virtio-mmio: fix memory leak of vm_dev
vdpa_sim_blk: Fix the potential leak of mgmt_dev
tools/virtio: Add dma sync api for virtio test

+121 -30
+3
drivers/crypto/virtio/virtio_crypto_common.h
··· 35 35 struct virtqueue *ctrl_vq; 36 36 struct data_queue *data_vq; 37 37 38 + /* Work struct for config space updates */ 39 + struct work_struct config_work; 40 + 38 41 /* To protect the vq operations for the controlq */ 39 42 spinlock_t ctrl_lock; 40 43
+13 -1
drivers/crypto/virtio/virtio_crypto_core.c
··· 335 335 virtcrypto_free_queues(vcrypto); 336 336 } 337 337 338 + static void vcrypto_config_changed_work(struct work_struct *work) 339 + { 340 + struct virtio_crypto *vcrypto = 341 + container_of(work, struct virtio_crypto, config_work); 342 + 343 + virtcrypto_update_status(vcrypto); 344 + } 345 + 338 346 static int virtcrypto_probe(struct virtio_device *vdev) 339 347 { 340 348 int err = -EFAULT; ··· 462 454 if (err) 463 455 goto free_engines; 464 456 457 + INIT_WORK(&vcrypto->config_work, vcrypto_config_changed_work); 458 + 465 459 return 0; 466 460 467 461 free_engines: ··· 500 490 501 491 dev_info(&vdev->dev, "Start virtcrypto_remove.\n"); 502 492 493 + flush_work(&vcrypto->config_work); 503 494 if (virtcrypto_dev_started(vcrypto)) 504 495 virtcrypto_dev_stop(vcrypto); 505 496 virtio_reset_device(vdev); ··· 515 504 { 516 505 struct virtio_crypto *vcrypto = vdev->priv; 517 506 518 - virtcrypto_update_status(vcrypto); 507 + schedule_work(&vcrypto->config_work); 519 508 } 520 509 521 510 #ifdef CONFIG_PM_SLEEP ··· 523 512 { 524 513 struct virtio_crypto *vcrypto = vdev->priv; 525 514 515 + flush_work(&vcrypto->config_work); 526 516 virtio_reset_device(vdev); 527 517 virtcrypto_free_unused_reqs(vcrypto); 528 518 if (virtcrypto_dev_started(vcrypto))
+3 -2
drivers/vdpa/mlx5/net/debug.c
··· 146 146 ndev->rx_dent = debugfs_create_dir("rx", ndev->debugfs); 147 147 } 148 148 149 - void mlx5_vdpa_remove_debugfs(struct dentry *dbg) 149 + void mlx5_vdpa_remove_debugfs(struct mlx5_vdpa_net *ndev) 150 150 { 151 - debugfs_remove_recursive(dbg); 151 + debugfs_remove_recursive(ndev->debugfs); 152 + ndev->debugfs = NULL; 152 153 }
+56 -14
drivers/vdpa/mlx5/net/mlx5_vnet.c
··· 625 625 mlx5_db_free(ndev->mvdev.mdev, &vcq->db); 626 626 } 627 627 628 + static int read_umem_params(struct mlx5_vdpa_net *ndev) 629 + { 630 + u32 in[MLX5_ST_SZ_DW(query_hca_cap_in)] = {}; 631 + u16 opmod = (MLX5_CAP_VDPA_EMULATION << 1) | (HCA_CAP_OPMOD_GET_CUR & 0x01); 632 + struct mlx5_core_dev *mdev = ndev->mvdev.mdev; 633 + int out_size; 634 + void *caps; 635 + void *out; 636 + int err; 637 + 638 + out_size = MLX5_ST_SZ_BYTES(query_hca_cap_out); 639 + out = kzalloc(out_size, GFP_KERNEL); 640 + if (!out) 641 + return -ENOMEM; 642 + 643 + MLX5_SET(query_hca_cap_in, in, opcode, MLX5_CMD_OP_QUERY_HCA_CAP); 644 + MLX5_SET(query_hca_cap_in, in, op_mod, opmod); 645 + err = mlx5_cmd_exec_inout(mdev, query_hca_cap, in, out); 646 + if (err) { 647 + mlx5_vdpa_warn(&ndev->mvdev, 648 + "Failed reading vdpa umem capabilities with err %d\n", err); 649 + goto out; 650 + } 651 + 652 + caps = MLX5_ADDR_OF(query_hca_cap_out, out, capability); 653 + 654 + ndev->umem_1_buffer_param_a = MLX5_GET(virtio_emulation_cap, caps, umem_1_buffer_param_a); 655 + ndev->umem_1_buffer_param_b = MLX5_GET(virtio_emulation_cap, caps, umem_1_buffer_param_b); 656 + 657 + ndev->umem_2_buffer_param_a = MLX5_GET(virtio_emulation_cap, caps, umem_2_buffer_param_a); 658 + ndev->umem_2_buffer_param_b = MLX5_GET(virtio_emulation_cap, caps, umem_2_buffer_param_b); 659 + 660 + ndev->umem_3_buffer_param_a = MLX5_GET(virtio_emulation_cap, caps, umem_3_buffer_param_a); 661 + ndev->umem_3_buffer_param_b = MLX5_GET(virtio_emulation_cap, caps, umem_3_buffer_param_b); 662 + 663 + out: 664 + kfree(out); 665 + return 0; 666 + } 667 + 628 668 static void set_umem_size(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq, int num, 629 669 struct mlx5_vdpa_umem **umemp) 630 670 { 631 - struct mlx5_core_dev *mdev = ndev->mvdev.mdev; 632 - int p_a; 633 - int p_b; 671 + u32 p_a; 672 + u32 p_b; 634 673 635 674 switch (num) { 636 675 case 1: 637 - p_a = MLX5_CAP_DEV_VDPA_EMULATION(mdev, umem_1_buffer_param_a); 638 - p_b = MLX5_CAP_DEV_VDPA_EMULATION(mdev, umem_1_buffer_param_b); 676 + p_a = ndev->umem_1_buffer_param_a; 677 + p_b = ndev->umem_1_buffer_param_b; 639 678 *umemp = &mvq->umem1; 640 679 break; 641 680 case 2: 642 - p_a = MLX5_CAP_DEV_VDPA_EMULATION(mdev, umem_2_buffer_param_a); 643 - p_b = MLX5_CAP_DEV_VDPA_EMULATION(mdev, umem_2_buffer_param_b); 681 + p_a = ndev->umem_2_buffer_param_a; 682 + p_b = ndev->umem_2_buffer_param_b; 644 683 *umemp = &mvq->umem2; 645 684 break; 646 685 case 3: 647 - p_a = MLX5_CAP_DEV_VDPA_EMULATION(mdev, umem_3_buffer_param_a); 648 - p_b = MLX5_CAP_DEV_VDPA_EMULATION(mdev, umem_3_buffer_param_b); 686 + p_a = ndev->umem_3_buffer_param_a; 687 + p_b = ndev->umem_3_buffer_param_b; 649 688 *umemp = &mvq->umem3; 650 689 break; 651 690 } 691 + 652 692 (*umemp)->size = p_a * mvq->num_ent + p_b; 653 693 } 654 694 ··· 2719 2679 goto out; 2720 2680 } 2721 2681 mlx5_vdpa_add_debugfs(ndev); 2682 + 2683 + err = read_umem_params(ndev); 2684 + if (err) 2685 + goto err_setup; 2686 + 2722 2687 err = setup_virtqueues(mvdev); 2723 2688 if (err) { 2724 2689 mlx5_vdpa_warn(mvdev, "setup_virtqueues\n"); ··· 2758 2713 err_rqt: 2759 2714 teardown_virtqueues(ndev); 2760 2715 err_setup: 2761 - mlx5_vdpa_remove_debugfs(ndev->debugfs); 2716 + mlx5_vdpa_remove_debugfs(ndev); 2762 2717 out: 2763 2718 return err; 2764 2719 } ··· 2772 2727 if (!ndev->setup) 2773 2728 return; 2774 2729 2775 - mlx5_vdpa_remove_debugfs(ndev->debugfs); 2776 - ndev->debugfs = NULL; 2730 + mlx5_vdpa_remove_debugfs(ndev); 2777 2731 teardown_steering(ndev); 2778 2732 destroy_tir(ndev); 2779 2733 destroy_rqt(ndev); ··· 3533 3489 struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev); 3534 3490 struct workqueue_struct *wq; 3535 3491 3536 - mlx5_vdpa_remove_debugfs(ndev->debugfs); 3537 - ndev->debugfs = NULL; 3538 3492 unregister_link_notifier(ndev); 3539 3493 _vdpa_unregister_device(dev); 3540 3494 wq = mvdev->wq;
+10 -1
drivers/vdpa/mlx5/net/mlx5_vnet.h
··· 65 65 struct hlist_head macvlan_hash[MLX5V_MACVLAN_SIZE]; 66 66 struct mlx5_vdpa_irq_pool irqp; 67 67 struct dentry *debugfs; 68 + 69 + u32 umem_1_buffer_param_a; 70 + u32 umem_1_buffer_param_b; 71 + 72 + u32 umem_2_buffer_param_a; 73 + u32 umem_2_buffer_param_b; 74 + 75 + u32 umem_3_buffer_param_a; 76 + u32 umem_3_buffer_param_b; 68 77 }; 69 78 70 79 struct mlx5_vdpa_counter { ··· 97 88 }; 98 89 99 90 void mlx5_vdpa_add_debugfs(struct mlx5_vdpa_net *ndev); 100 - void mlx5_vdpa_remove_debugfs(struct dentry *dbg); 91 + void mlx5_vdpa_remove_debugfs(struct mlx5_vdpa_net *ndev); 101 92 void mlx5_vdpa_add_rx_flow_table(struct mlx5_vdpa_net *ndev); 102 93 void mlx5_vdpa_remove_rx_flow_table(struct mlx5_vdpa_net *ndev); 103 94 void mlx5_vdpa_add_tirn(struct mlx5_vdpa_net *ndev);
+3 -2
drivers/vdpa/vdpa_sim/vdpa_sim_blk.c
··· 499 499 GFP_KERNEL); 500 500 if (!shared_buffer) { 501 501 ret = -ENOMEM; 502 - goto parent_err; 502 + goto mgmt_dev_err; 503 503 } 504 504 } 505 505 506 506 return 0; 507 - 507 + mgmt_dev_err: 508 + vdpa_mgmtdev_unregister(&mgmt_dev); 508 509 parent_err: 509 510 device_unregister(&vdpasim_blk_mgmtdev); 510 511 return ret;
+1 -3
drivers/vhost/vhost.c
··· 1458 1458 goto done; 1459 1459 } 1460 1460 1461 - if ((msg.type == VHOST_IOTLB_UPDATE || 1462 - msg.type == VHOST_IOTLB_INVALIDATE) && 1463 - msg.size == 0) { 1461 + if (msg.type == VHOST_IOTLB_UPDATE && msg.size == 0) { 1464 1462 ret = -EINVAL; 1465 1463 goto done; 1466 1464 }
+5 -1
drivers/virtio/virtio_balloon.c
··· 395 395 virtio_cread_le(vb->vdev, struct virtio_balloon_config, num_pages, 396 396 &num_pages); 397 397 398 - target = num_pages; 398 + /* 399 + * Aligned up to guest page size to avoid inflating and deflating 400 + * balloon endlessly. 401 + */ 402 + target = ALIGN(num_pages, VIRTIO_BALLOON_PAGES_PER_PAGE); 399 403 return target - vb->num_pages; 400 404 } 401 405
+14 -5
drivers/virtio/virtio_mmio.c
··· 631 631 spin_lock_init(&vm_dev->lock); 632 632 633 633 vm_dev->base = devm_platform_ioremap_resource(pdev, 0); 634 - if (IS_ERR(vm_dev->base)) 635 - return PTR_ERR(vm_dev->base); 634 + if (IS_ERR(vm_dev->base)) { 635 + rc = PTR_ERR(vm_dev->base); 636 + goto free_vm_dev; 637 + } 636 638 637 639 /* Check magic value */ 638 640 magic = readl(vm_dev->base + VIRTIO_MMIO_MAGIC_VALUE); 639 641 if (magic != ('v' | 'i' << 8 | 'r' << 16 | 't' << 24)) { 640 642 dev_warn(&pdev->dev, "Wrong magic value 0x%08lx!\n", magic); 641 - return -ENODEV; 643 + rc = -ENODEV; 644 + goto free_vm_dev; 642 645 } 643 646 644 647 /* Check device version */ ··· 649 646 if (vm_dev->version < 1 || vm_dev->version > 2) { 650 647 dev_err(&pdev->dev, "Version %ld not supported!\n", 651 648 vm_dev->version); 652 - return -ENXIO; 649 + rc = -ENXIO; 650 + goto free_vm_dev; 653 651 } 654 652 655 653 vm_dev->vdev.id.device = readl(vm_dev->base + VIRTIO_MMIO_DEVICE_ID); ··· 659 655 * virtio-mmio device with an ID 0 is a (dummy) placeholder 660 656 * with no function. End probing now with no error reported. 661 657 */ 662 - return -ENODEV; 658 + rc = -ENODEV; 659 + goto free_vm_dev; 663 660 } 664 661 vm_dev->vdev.id.vendor = readl(vm_dev->base + VIRTIO_MMIO_VENDOR_ID); 665 662 ··· 689 684 if (rc) 690 685 put_device(&vm_dev->vdev.dev); 691 686 687 + return rc; 688 + 689 + free_vm_dev: 690 + kfree(vm_dev); 692 691 return rc; 693 692 } 694 693
+1 -1
drivers/virtio/virtio_pci_modern_dev.c
··· 291 291 err = -EINVAL; 292 292 mdev->common = vp_modern_map_capability(mdev, common, 293 293 sizeof(struct virtio_pci_common_cfg), 4, 294 - 0, sizeof(struct virtio_pci_common_cfg), 294 + 0, sizeof(struct virtio_pci_modern_common_cfg), 295 295 NULL, NULL); 296 296 if (!mdev->common) 297 297 goto err_map_common;
+12
tools/virtio/linux/dma-mapping.h
··· 24 24 #define dma_map_page(d, p, o, s, dir) (page_to_phys(p) + (o)) 25 25 26 26 #define dma_map_single(d, p, s, dir) (virt_to_phys(p)) 27 + #define dma_map_single_attrs(d, p, s, dir, a) (virt_to_phys(p)) 27 28 #define dma_mapping_error(...) (0) 28 29 29 30 #define dma_unmap_single(d, a, s, r) do { (void)(d); (void)(a); (void)(s); (void)(r); } while (0) 30 31 #define dma_unmap_page(d, a, s, r) do { (void)(d); (void)(a); (void)(s); (void)(r); } while (0) 31 32 33 + #define sg_dma_address(sg) (0) 34 + #define dma_need_sync(v, a) (0) 35 + #define dma_unmap_single_attrs(d, a, s, r, t) do { \ 36 + (void)(d); (void)(a); (void)(s); (void)(r); (void)(t); \ 37 + } while (0) 38 + #define dma_sync_single_range_for_cpu(d, a, o, s, r) do { \ 39 + (void)(d); (void)(a); (void)(o); (void)(s); (void)(r); \ 40 + } while (0) 41 + #define dma_sync_single_range_for_device(d, a, o, s, r) do { \ 42 + (void)(d); (void)(a); (void)(o); (void)(s); (void)(r); \ 43 + } while (0) 32 44 #define dma_max_mapping_size(...) SIZE_MAX 33 45 34 46 #endif