Skip to content

Commit 7ef30ea

Browse files
danieldegrassecfriedt
authored andcommitted
scripts: pcie_utils.py: rescan even if no card is on bus
Commit d33106d (app: pytest: e2e_smoke: support rescan if no card is on bus) added this behavior to the e2e smoke test, but commit d1ea6e1 (boards: tt_blackhole: rename bmc to dmc to avoid confusion) did not port the behavior into the new pcie_utils.py script. Reintroduce it. Signed-off-by: Daniel DeGrasse <[email protected]>
1 parent 7887d15 commit 7ef30ea

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

scripts/pcie_utils.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,23 @@ def rescan_pcie():
2727
"""
2828
# First, we must find the PCIe card to power it off
2929
dev = find_tt_bus()
30-
if dev is None:
31-
raise RuntimeError("No tenstorrent card found to power off")
32-
print(f"Powering off device at {dev}")
30+
if dev is not None:
31+
print(f"Powering off device at {dev}")
32+
try:
33+
with open(os.path.join(dev, "remove"), "w") as f:
34+
f.write("1")
35+
except PermissionError as e:
36+
print(
37+
"Error, this script must be run with elevated permissions to rescan PCIe bus"
38+
)
39+
raise e
40+
# Now, rescan the bus
3341
try:
34-
with open(os.path.join(dev, "remove"), "w") as f:
42+
with open("/sys/bus/pci/rescan", "w") as f:
3543
f.write("1")
44+
time.sleep(1)
3645
except PermissionError as e:
3746
print(
3847
"Error, this script must be run with elevated permissions to rescan PCIe bus"
3948
)
4049
raise e
41-
# Now, rescan the bus
42-
with open("/sys/bus/pci/rescan", "w") as f:
43-
f.write("1")
44-
time.sleep(1)

0 commit comments

Comments
 (0)