Skip to content

Commit dcee7d1

Browse files
rahulds98rfrandse
authored andcommitted
Clear PCIeSlot DBus Object LinkId/BusId property on topology refresh (#724)
This commit adds a function to clear BusId/LinkId on DBus Objects which implement the PCIeSlot interface, whenever a refresh for PCIe topology is requested from GUI, ensuring stale links are not seen on GUI Tested for Host USB Enablement usecase where USB will no longer show in PCIe topology on GUI if disabled Signed-off-by: Rahul D S <[email protected]>
1 parent b55ae09 commit dcee7d1

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

oem/ibm/libpldmresponder/file_io_type_pcie.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ int PCIeInfoHandler::fileAck(uint8_t /*fileStatus*/)
212212
}
213213
cables.clear();
214214

215+
// clears busids on all objects because only active links are
216+
// updated by setTopologyAttrsOnDbus()
217+
refreshAllPcieSlotBusIds();
218+
215219
// set topology properties & host cable dbus objects
216220
setTopologyAttrsOnDbus();
217221
// even when we fail to parse /set the topology infromation on
@@ -1217,5 +1221,50 @@ void PCIeInfoHandler::deleteTopologyFiles()
12171221
}
12181222
}
12191223

1224+
void PCIeInfoHandler::refreshAllPcieSlotBusIds()
1225+
{
1226+
// Only setting BusIDs/LinkIDs to 0 for objects
1227+
// hosted by Inventory Manager
1228+
constexpr auto basePath =
1229+
"/xyz/openbmc_project/inventory/system/chassis/motherboard";
1230+
constexpr auto property = "BusId";
1231+
constexpr auto dbusProperties = "org.freedesktop.DBus.Properties";
1232+
1233+
try
1234+
{
1235+
auto& bus = pldm::utils::DBusHandler::getBus();
1236+
auto subTree = pldm::utils::DBusHandler().getSubtree(basePath, 0,
1237+
{itemPCIeSlot});
1238+
1239+
for (const auto& [objectPath, serviceMap] : subTree)
1240+
{
1241+
for (const auto& [service, interfaces] : serviceMap)
1242+
{
1243+
try
1244+
{
1245+
auto method = bus.new_method_call(service.c_str(),
1246+
objectPath.c_str(),
1247+
dbusProperties, "Set");
1248+
uint32_t newBusIdValue = 0;
1249+
std::variant<uint32_t> value =
1250+
static_cast<uint32_t>(newBusIdValue);
1251+
method.append(itemPCIeSlot, property, value);
1252+
bus.call_noreply(method, dbusTimeout);
1253+
}
1254+
catch (const std::exception& e)
1255+
{
1256+
error(
1257+
"Error clearing BusId for {OBJPATH} from {SERVICE}: {ERROR}",
1258+
"OBJPATH", objectPath, "SERVICE", service, "ERROR", e);
1259+
}
1260+
}
1261+
}
1262+
}
1263+
catch (const std::exception& e)
1264+
{
1265+
error("Failed to refresh PCIeSlot BusIds: {ERR}", "ERR", e);
1266+
}
1267+
}
1268+
12201269
} // namespace responder
12211270
} // namespace pldm

oem/ibm/libpldmresponder/file_io_type_pcie.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,12 @@ class PCIeInfoHandler : public FileHandler
324324
static std::unordered_map<uint16_t, bool> receivedFiles;
325325

326326
void deleteTopologyFiles();
327+
328+
/** @brief Sets bus IDs to 0 on all DBus Objects
329+
*
330+
* @param[return] void
331+
*/
332+
void refreshAllPcieSlotBusIds();
327333
};
328334

329335
} // namespace responder

0 commit comments

Comments
 (0)