This is a note to let you know that I've just added the patch titled vDPA/ifcvf: alloc the mgmt_dev before the adapter to the 6.2-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: vdpa-ifcvf-alloc-the-mgmt_dev-before-the-adapter.patch and it can be found in the queue-6.2 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 66e3970b16d1e960afbece65739a3628273633f1 Mon Sep 17 00:00:00 2001 From: Zhu Lingshan <lingshan.zhu@xxxxxxxxx> Date: Fri, 25 Nov 2022 22:57:15 +0800 Subject: vDPA/ifcvf: alloc the mgmt_dev before the adapter From: Zhu Lingshan <lingshan.zhu@xxxxxxxxx> commit 66e3970b16d1e960afbece65739a3628273633f1 upstream. This commit reverses the order of allocating the management device and the adapter. So that it would be possible to move the allocation of the adapter to dev_add(). Signed-off-by: Zhu Lingshan <lingshan.zhu@xxxxxxxxx> Cc: stable@xxxxxxxxxxxxxxx Message-Id: <20221125145724.1129962-4-lingshan.zhu@xxxxxxxxx> Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/vdpa/ifcvf/ifcvf_main.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) --- a/drivers/vdpa/ifcvf/ifcvf_main.c +++ b/drivers/vdpa/ifcvf/ifcvf_main.c @@ -831,22 +831,30 @@ static int ifcvf_probe(struct pci_dev *p } pci_set_master(pdev); + ifcvf_mgmt_dev = kzalloc(sizeof(struct ifcvf_vdpa_mgmt_dev), GFP_KERNEL); + if (!ifcvf_mgmt_dev) { + IFCVF_ERR(pdev, "Failed to alloc memory for the vDPA management device\n"); + return -ENOMEM; + } adapter = vdpa_alloc_device(struct ifcvf_adapter, vdpa, dev, &ifc_vdpa_ops, 1, 1, NULL, false); if (IS_ERR(adapter)) { IFCVF_ERR(pdev, "Failed to allocate vDPA structure"); - return PTR_ERR(adapter); + ret = PTR_ERR(adapter); + goto err; } + adapter->pdev = pdev; + adapter->vdpa.dma_dev = &pdev->dev; + adapter->vdpa.mdev = &ifcvf_mgmt_dev->mdev; + ifcvf_mgmt_dev->adapter = adapter; + vf = &adapter->vf; vf->dev_type = get_dev_type(pdev); vf->base = pcim_iomap_table(pdev); vf->pdev = pdev; - adapter->pdev = pdev; - adapter->vdpa.dma_dev = &pdev->dev; - ret = ifcvf_init_hw(vf, pdev); if (ret) { IFCVF_ERR(pdev, "Failed to init IFCVF hw\n"); @@ -859,16 +867,6 @@ static int ifcvf_probe(struct pci_dev *p vf->hw_features = ifcvf_get_hw_features(vf); vf->config_size = ifcvf_get_config_size(vf); - ifcvf_mgmt_dev = kzalloc(sizeof(struct ifcvf_vdpa_mgmt_dev), GFP_KERNEL); - if (!ifcvf_mgmt_dev) { - IFCVF_ERR(pdev, "Failed to alloc memory for the vDPA management device\n"); - return -ENOMEM; - } - - ifcvf_mgmt_dev->mdev.ops = &ifcvf_vdpa_mgmt_dev_ops; - ifcvf_mgmt_dev->mdev.device = dev; - ifcvf_mgmt_dev->adapter = adapter; - dev_type = get_dev_type(pdev); switch (dev_type) { case VIRTIO_ID_NET: @@ -883,12 +881,11 @@ static int ifcvf_probe(struct pci_dev *p goto err; } + ifcvf_mgmt_dev->mdev.ops = &ifcvf_vdpa_mgmt_dev_ops; + ifcvf_mgmt_dev->mdev.device = dev; ifcvf_mgmt_dev->mdev.max_supported_vqs = vf->nr_vring; ifcvf_mgmt_dev->mdev.supported_features = vf->hw_features; - adapter->vdpa.mdev = &ifcvf_mgmt_dev->mdev; - - ret = vdpa_mgmtdev_register(&ifcvf_mgmt_dev->mdev); if (ret) { IFCVF_ERR(pdev, Patches currently in stable-queue which might be from lingshan.zhu@xxxxxxxxx are queue-6.2/vdpa-ifcvf-allocate-the-adapter-in-dev_add.patch queue-6.2/vdpa-ifcvf-decouple-vq-irq-releasers-from-the-adapter.patch queue-6.2/vdpa-ifcvf-decouple-vq-irq-requester-from-the-adapter.patch queue-6.2/vdpa-ifcvf-ifcvf_request_irq-works-on-ifcvf_hw.patch queue-6.2/vdpa-ifcvf-decouple-config-space-ops-from-the-adapter.patch queue-6.2/vdpa-ifcvf-decouple-config-irq-releaser-from-the-adapter.patch queue-6.2/vdpa-ifcvf-alloc-the-mgmt_dev-before-the-adapter.patch queue-6.2/vdpa-ifcvf-manage-ifcvf_hw-in-the-mgmt_dev.patch queue-6.2/vdpa-ifcvf-decouple-hw-features-manipulators-from-the-adapter.patch queue-6.2/vdpa-ifcvf-decouple-config-dev-irq-requester-and-vectors-allocator-from-the-adapter.patch