From f280ce59b7e842e9eb130e98a62e5bc5c1828717 Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Tue, 9 Jun 2020 18:09:33 +0200 Subject: [PATCH] vmd: dont remove the hooked pci device on its detach The hooked spdk_pci_device was being removed when someone stopped using it (detached from it). The following didn't work: $ rpc.py bdev_nvme_attach_controller 10000:00:01.0 $ rpc.py bdev_nvme_detach_controller 10000:00:01.0 $ rpc.py bdev_nvme_attach_controller 10000:00:01.0 The second attach can't find PCI device 10000:00:01.0. To fix it, simply don't do anything in VMD on device detach. The entire callback will be removed soon. You don't get notified when someone starts using your hooked device, so there's not much gain from knowing when someone stops. Change-Id: I147c24609077be24182ecfd2e273988a2e9e26b2 Signed-off-by: Darek Stojaczyk Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2938 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Jim Harris Reviewed-by: Michael Haeuptle --- lib/vmd/vmd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/vmd/vmd.c b/lib/vmd/vmd.c index 7fae7d421..ae018a294 100644 --- a/lib/vmd/vmd.c +++ b/lib/vmd/vmd.c @@ -863,6 +863,11 @@ vmd_dev_cfg_write(struct spdk_pci_device *_dev, void *value, return 0; } +static void +_vmd_dev_detach(struct spdk_pci_device *dev) +{ +} + static void vmd_dev_detach(struct spdk_pci_device *dev) { @@ -902,7 +907,7 @@ vmd_dev_init(struct vmd_pci_device *dev) dev->pci.unmap_bar = vmd_dev_unmap_bar; dev->pci.cfg_read = vmd_dev_cfg_read; dev->pci.cfg_write = vmd_dev_cfg_write; - dev->pci.detach = vmd_dev_detach; + dev->pci.detach = _vmd_dev_detach; dev->hotplug_capable = false; if (dev->pcie_cap != NULL) { dev->cached_slot_control = dev->pcie_cap->slot_control;