From f942281913928b05c6b21e26e6c172ae840051b5 Mon Sep 17 00:00:00 2001 From: Konrad Sztyber Date: Thu, 3 Oct 2019 13:11:43 +0200 Subject: [PATCH] lib/vmd: additional hotplug capability checks Check PCIe Capability slot_implemented field before hotplug structures instantiation. Change-Id: Id40c10839e51b238a6ffd64592052604d50e2850 Signed-off-by: orden smith Signed-off-by: Konrad Sztyber Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470649 Tested-by: SPDK CI Jenkins Reviewed-by: Tomasz Zawadzki Reviewed-by: Jim Harris Reviewed-by: Wojciech Malikowski --- lib/vmd/vmd.c | 13 ++++++++++--- lib/vmd/vmd.h | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/vmd/vmd.c b/lib/vmd/vmd.c index aa4d38ff4..39e3a1cc0 100644 --- a/lib/vmd/vmd.c +++ b/lib/vmd/vmd.c @@ -843,7 +843,8 @@ vmd_scan_single_bus(struct vmd_pci_bus *bus, struct vmd_pci_device *parent_bridg new_bus->self = new_dev; new_dev->bus_object = new_bus; - if (slot_cap.bit_field.hotplug_capable) { + if (slot_cap.bit_field.hotplug_capable && + new_dev->pcie_cap->express_cap_register.bit_field.slot_implemented) { new_bus->hotplug_buses = vmd_get_hotplug_bus_numbers(new_dev); new_bus->subordinate_bus += new_bus->hotplug_buses; } @@ -856,8 +857,14 @@ vmd_scan_single_bus(struct vmd_pci_bus *bus, struct vmd_pci_device *parent_bridg vmd_add_bus_to_list(bus->vmd, new_bus); /* Attach hot plug instance if HP is supported */ - if (slot_cap.bit_field.hotplug_capable) { - new_dev->hp = vmd_new_hotplug(new_bus, new_bus->hotplug_buses); + /* Hot inserted SSDs can be assigned port bus of sub-ordinate + 1 */ + SPDK_DEBUGLOG(SPDK_LOG_VMD, "bit_field.hotplug_capable:slot_implemented = %x:%x\n", + slot_cap.bit_field.hotplug_capable, + new_dev->pcie_cap->express_cap_register.bit_field.slot_implemented); + + if (slot_cap.bit_field.hotplug_capable && + new_dev->pcie_cap->express_cap_register.bit_field.slot_implemented) { + new_dev->hp = vmd_new_hotplug(new_bus); } vmd_dev_init(new_dev); diff --git a/lib/vmd/vmd.h b/lib/vmd/vmd.h index a88ba7223..592cc985e 100644 --- a/lib/vmd/vmd.h +++ b/lib/vmd/vmd.h @@ -190,7 +190,7 @@ vmd_hp_enable_hotplug(struct vmd_hot_plug *hp) } static inline struct vmd_hot_plug * -vmd_new_hotplug(struct vmd_pci_bus *newBus, uint8_t reservedBuses) +vmd_new_hotplug(struct vmd_pci_bus *newBus) { return NULL; }