做的时候
echo 1 > /sys/bus/pci/slots/[slot number]/power内核会改变这个设备的PCIe配置空间的某些(或特定)寄存器中的值吗?
据我理解,当一个系统( PC )电源打开时,电源已经提供给PCIe设备,但是内核仍然可以控制某些时隙的开关(如本文中的sysfs contorl命令),这是因为内核在PCIe配置空间中设置寄存器来控制其功率吗?
当我们阅读它时,它是否也是从插槽控制寄存器中的寄存器读取的?
例:
cat /sys/bus/pci/slots/[slot number]/power 发布于 2018-10-01 09:22:37
这是我的追踪(如果我错了请告诉我)
power_write_file() https://elixir.bootlin.com/linux/v4.10/source/drivers/pci/hotplug/pci_热插拔_core.c#L95
slot->ops->disable_slot(slot);
ops->disable_slot = disable_slot;https://elixir.bootlin.com/linux/v4.10/source/drivers/pci/hotplug/pciehp_core.c#L107
static int disable_slot(struct hotplug_slot *hotplug_slot)
{
struct slot *slot = hotplug_slot->private;
return pciehp_sysfs_disable_slot(slot);
}https://elixir.bootlin.com/linux/v4.10/source/drivers/pci/hotplug/pciehp_core.c#L167
retval = pciehp_disable_slot(p_slot);
remove_board(struct slot *p_slot)https://elixir.bootlin.com/linux/v4.10/source/drivers/pci/hotplug/pciehp_ctrl.c#L135
最后,我们得到了:
void pciehp_power_off_slot(struct slot *slot)
{
struct controller *ctrl = slot->ctrl;
pcie_write_cmd(ctrl, PCI_EXP_SLTCTL_PWR_OFF, PCI_EXP_SLTCTL_PCC);
ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL,
PCI_EXP_SLTCTL_PWR_OFF);
}https://elixir.bootlin.com/linux/v4.10/source/drivers/pci/hotplug/pciehp_hpc.c#L551
#define PCI_EXP_SLTCTL_PWR_OFF 0x0400 /* Power Off */
#define PCI_EXP_SLTCTL 24 /* Slot Control */0x0400 ==> 10000000000 #位10 == 1 ==>功率控制器控制寄存器在插槽控制寄存器中为1(偏移18h == 24 )
根据PCIe关于功率控制器控制寄存器的规范:
0b Power On
1b Power Off所以答案是肯定的,
内核将更改插槽控制寄存器中的功率控制器控制寄存器。
https://unix.stackexchange.com/questions/471532
复制相似问题