如果我只有一个 nvme 设备,我想看看这两组命令有何不同。块设备
ls -l /sys/block/nvme0n1
lrwxrwxrwx 1 root root 0 Apr 28 11:59 /sys/block/nvme0n1 -> ../devices/pci0000:00/0000:00:03.1/0000:09:00.0/nvme/nvme0/nvme0n1
sudo sh -c "echo 1 > /sys/block/nvme0n1/device/device/remove"
# LINK DISABLE/DOWN
sudo setpci -s 0000:00:03.1 BRIDGE_CONTROL.W=0x40:0x40
# LINK ENABLE
sudo setpci -s 0000:00:03.1 BRIDGE_CONTROL.W=0x00:0x40
sudo sh -c "echo 1 > /sys/bus/pci/rescan"
如果我sudo nvme list
按照上述操作运行,则该设备就存在。
sudo modprobe -r nvme
sudo setpci -s 0000:00:03.1 BRIDGE_CONTROL.W=0x40:0x40
sudo setpci -s 0000:00:03.1 BRIDGE_CONTROL.W=0x00:0x40
sudo modprobe nvme
如果我sudo nvme list
按照上述步骤运行,设备就会丢失。但是,如果我从 PCI 总线上移除设备并重新扫描,它就可以恢复。
当不使用链接关闭命令运行时,任何一种删除方法都不会出现问题。
链路断开和连接是否需要重置 mmu 空间?根据 dmesg
echo 1 > .. /remove; echo 1 > .. ./rescan
命令重置 mmu 和 BAR
[Fri Apr 28 12:11:04 2023] pci 0000:09:00.0: Removing from iommu group 23
[Fri Apr 28 12:11:04 2023] pci 0000:09:00.0: [1d82:0401] type 00 class 0x010802
[Fri Apr 28 12:11:04 2023] pci 0000:09:00.0: reg 0x10: [mem 0xea1e0000-0xea1e3fff 64bit]
[Fri Apr 28 12:11:04 2023] pci 0000:09:00.0: reg 0x18: [mem 0xea1e4000-0xea1e7fff 64bit]
[Fri Apr 28 12:11:04 2023] pci 0000:09:00.0: reg 0x20: [mem 0xd0000000-0xdfffffff 64bit pref]
[Fri Apr 28 12:11:04 2023] pci 0000:09:00.0: supports D1
[Fri Apr 28 12:11:04 2023] pci 0000:09:00.0: PME# supported from D0 D1 D3hot
[Fri Apr 28 12:11:04 2023] pci 0000:09:00.0: reg 0x1d8: [mem 0xea1e8000-0xea1ebfff 64bit]
[Fri Apr 28 12:11:04 2023] pci 0000:09:00.0: VF(n) BAR0 space: [mem 0xea1e8000-0xea1fffff 64bit] (contains BAR0 for 6 VFs)
[Fri Apr 28 12:11:04 2023] pci 0000:09:00.0: reg 0x1e0: [mem 0xea180000-0xea18ffff 64bit]
[Fri Apr 28 12:11:04 2023] pci 0000:09:00.0: VF(n) BAR2 space: [mem 0xea180000-0xea1dffff 64bit] (contains BAR2 for 6 VFs)
[Fri Apr 28 12:11:04 2023] pci 0000:09:00.0: reg 0x1ec: [mem 0xea000000-0xea03ffff]
[Fri Apr 28 12:11:04 2023] pci 0000:09:00.0: VF(n) BAR5 space: [mem 0xea000000-0xea17ffff] (contains BAR5 for 6 VFs)
[Fri Apr 28 12:11:04 2023] pci 0000:09:00.0: Adding to iommu group 23
[Fri Apr 28 12:11:04 2023] pci 0000:09:00.0: BAR 4: assigned [mem 0xd0000000-0xdfffffff 64bit pref]
[Fri Apr 28 12:11:04 2023] pci 0000:09:00.0: BAR 12: assigned [mem 0xea000000-0xea17ffff]
[Fri Apr 28 12:11:04 2023] pci 0000:09:00.0: BAR 9: assigned [mem 0xea180000-0xea1dffff 64bit]
[Fri Apr 28 12:11:04 2023] pci 0000:09:00.0: BAR 0: assigned [mem 0xea1e0000-0xea1e3fff 64bit]
[Fri Apr 28 12:11:04 2023] pci 0000:09:00.0: BAR 2: assigned [mem 0xea1e4000-0xea1e7fff 64bit]
[Fri Apr 28 12:11:04 2023] pci 0000:09:00.0: BAR 7: assigned [mem 0xea1e8000-0xea1fffff 64bit]
[Fri Apr 28 12:11:04 2023] nvme nvme0: pci function 0000:09:00.0
[Fri Apr 28 12:11:04 2023] nvme nvme0: 15/0/0 default/read/poll queues
但不是 modprobe
[Fri Apr 28 12:23:31 2023] nvme nvme0: pci function 0000:09:00.0
[Fri Apr 28 12:23:31 2023] nvme 0000:09:00.0: enabling device (0000 -> 0002)
[Fri Apr 28 12:23:31 2023] nvme nvme0: 15/0/0 default/read/poll queues
[Fri Apr 28 12:23:31 2023] blk_update_request: I/O error, dev nvme0n1, sector 264 op 0x0:(READ) flags 0x80700 phys_seg 30 prio class 0
[Fri Apr 28 12:23:31 2023] blk_update_request: I/O error, dev nvme0n1, sector 520 op 0x0:(READ) flags 0x80700 phys_seg 39 prio class 0
[Fri Apr 28 12:23:31 2023] blk_update_request: I/O error, dev nvme0n1, sector 16777215096 op 0x0:(READ) flags 0x80700 phys_seg 11 prio class 0