【问题标题】:How to know when reset pci device is completed?如何知道重置 pci 设备何时完成?
【发布时间】:2020-01-04 12:40:16
【问题描述】:

我想知道 pci 重置何时完成,因此我认为最好的选择是从 pci 设备配置注册表中读取设备 ID 字段。

设备 id 字段在重置后变为 0xffff,并应在 200-400 毫秒后(可能在重置结束后)变回真实设备 id。

如果不等待就访问它,我会从函数“pci_read_config_word”中得到一个错误。

我不想猜测等待的时间。 还有另一种投票方式吗?

pci_set_pcie_reset_state(pdev, pcie_deassert_reset);

while(polling_counter < 100)
{
    pci_read_config_word(pdev, PCI_DEVICE_ID,
                         &device_id);

    if (device_id == pdev->device)
       break;

    polling_counter++;
}

// This function can failed if the reset is not completed.
pci_restore_state(pdev);

来自 dmesg:

[c000000167bcb200] [c0000000000155ac] .show_stack+0x6c/0x198 (unreliable)                                                                    
[c000000167bcb2b0] [c000000000076a8c] .eeh_dn_check_failure+0x354/0x3f0                                                                      
[c000000167bcb370] [c000000000029b7c] .rtas_read_config+0x13c/0x198                                                                          
[c000000167bcb410] [c00000000039c8d0] .pci_bus_read_config_word+0xa0/0xf8                                                                    
[c000000167bcb4d0] [d000000004f6043c] .reset_device+0x23c/0x530 [mst_ppc_pci_reset]                                                          
[c000000167bcb590] [c0000000003a6254] .local_pci_probe+0x7c/0xf8                                                                             
[c000000167bcb620] [c0000000003a63a8] .__pci_device_probe+0xd8/0x128                                                                         
[c000000167bcb6d0] [c0000000003a72a8] .pci_device_probe+0x38/0x68                                                                            
[c000000167bcb760] [c0000000004d0bd8] .really_probe+0xb0/0x288                                                                               
[c000000167bcb810] [c0000000004d0e4c] .driver_probe_device+0x9c/0x110                                                                        
[c000000167bcb8a0] [c0000000004d0fbc] .__driver_attach+0xfc/0x100                                                                            
[c000000167bcb930] [c0000000004cfee4] .bus_for_each_dev+0xc4/0x118                                                                           
[c000000167bcb9e0] [c0000000004d08a8] .driver_attach+0x28/0x40                                                                               
[c000000167bcba60] [c0000000004cf3b0] .bus_add_driver+0x190/0x340                                                                            
[c000000167bcbb10] [c0000000004d1950] .driver_register+0x98/0x1b8                                                                            
[c000000167bcbbb0] [c0000000003a760c] .__pci_register_driver+0x64/0x140                                                                      
[c000000167bcbc50] [d000000004f608c0] .init+0x28/0x430 [mst_ppc_pci_reset]                                                                   
[c000000167bcbcd0] [c00000000000ab68] .do_one_initcall+0x68/0x1e0                                                                            
[c000000167bcbd90] [c00000000010893c] .SyS_init_module+0xcc/0x218                                                                            
[c000000167bcbe30] [c0000000000098ec] syscall_exit+0x0/0x40

【问题讨论】:

    标签: linux-kernel linux-device-driver pci


    【解决方案1】:

    所以我很快检查了 /driver/pci.c 并找到了这个宏

    https://elixir.bootlin.com/linux/latest/source/drivers/pci/pci.c#L143

    基于它在这些地方的用途,我会说官方的方法是等待,尽管我不确定你在做什么重置。

    https://elixir.bootlin.com/linux/latest/source/drivers/pci/pci.c#L4672 https://elixir.bootlin.com/linux/latest/source/drivers/pci/pci.c#L4486

    但是,再次取决于您的重置,链接可能会重置,在这种情况下您可以尝试使用此功能(无承诺)。 https://elixir.bootlin.com/linux/latest/source/drivers/pci/pci.c#L4585

    总的来说,这个等待函数似乎是库想要你使用的。如果您说要执行哪种重置可能会有所帮助。

    https://elixir.bootlin.com/linux/latest/source/drivers/pci/pci.c#L4401

    对不起,我在手机上的格式很差,如果没有人碰这个,我稍后会更新。

    【讨论】:

    • 请在帖子中添加宏/函数名称。在当前形式中,如果不点击链接,您的答案将毫无价值。这是一个仅链接的答案,而在 Stack Overflow 上往往会避免这种答案。
    • 嗨@arduic,嗨,感谢您的回复。这是关于热复位的:pci_set_pcie_reset_state(pdev, pcie_hot_reset);
    • pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout) 没有出现在 pci.h 中
    猜你喜欢
    • 2020-08-21
    • 1970-01-01
    • 2014-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-04
    • 1970-01-01
    • 2011-09-15
    相关资源
    最近更新 更多