linux pcie 驱动程序,自定义linux pcie驱动程序MSI中断

我正在为嵌入式设备编写自定义Linux PCIe驱动程序.为此,我需要启用多个MSI向量.当我使用函数pci_enable_msi(pdev)时,代码正常工作.但是当我使用pci_enable_msi_block(pdev,4)时;该函数返回1表示它只能分配1个中断.如果我使用pci_enable_msi_block(pdev,32);函数返回16,我使用pci_enable_msi_block(pdev,16);但返回值再次为1.

我试图检查所有可能参数的返回值,结果如下:

for(i=2;i<33;i++)

{

ret = pci_enable_msi_block(pdev,i);

printk(KERN_DEBUG "For request i=%d the return value is=%d\n",i, ret);

}

[ 89.421184] For request i=2 the return value is=1

[ 89.421196] For request i=3 the return value is=1

[ 89.421208] For request i=4 the return value is=1

[ 89.421220] For request i=5 the return value is=1

[ 89.421232] For request i=6 the return value is=1

[ 89.421243] For request i=7 the return value is=1

[ 89.421255] For request i=8 the return value is=1

[ 89.421266] For request i=9 the return value is=1

[ 89.421278] For request i=10 the return value is=1

[ 89.421290] For request i=11 the return value is=1

[ 89.421301] For request i=12 the return value is=1

[ 89.421313] For request i=13 the return value is=1

[ 89.421325] For request i=14 the return value is=1

[ 89.421336] For request i=15 the return value is=1

[ 89.421348] For request i=16 the return value is=1

[ 89.421353] For request i=17 the return value is=16

[ 89.421359] For request i=18 the return value is=16

[ 89.421364] For request i=19 the return value is=16

[ 89.421369] For request i=20 the return value is=16

[ 89.421374] For request i=21 the return value is=16

[ 89.421380] For request i=22 the return value is=16

[ 89.421385] For request i=23 the return value is=16

[ 89.421390] For request i=24 the return value is=16

[ 89.421395] For request i=25 the return value is=16

[ 89.421401] For request i=26 the return value is=16

[ 89.421406] For request i=27 the return value is=16

[ 89.421411] For request i=28 the return value is=16

[ 89.421416] For request i=29 the return value is=16

[ 89.421422] For request i=30 the return value is=16

[ 89.421427] For request i=31 the return value is=16

[ 89.421432] For request i=32 the return value is=16

只有在使用pci_enable_msi_block(pdev,1)时,函数调用才会成功(返回0).

我也尝试使用pci_enable_msi_exact和pci_enable_msi_range函数,但代码不编译并给出隐式函数声明错误.

请提供有关如何解决此问题的建议,以便我可以使用四个MSI向量.

解决方法:

您需要检查配置寄存器以确定可分配的MSI数量. PCIe设备确定这一点.

您需要探测配置寄存器.获取DWORD的LSB以获取命令寄存器.这可以控制传统中断.取地址0x50的MSB来确定消息控制.这可以控制MSI.

确保禁用传统中断并在命令寄存器中启用总线主控.使用0x50(MSB)确定可以分配多少MSI.位4:6确定这一点,位0使能MSI.

我遇到了类似的问题,但事实证明我的端点只能使用一个MSI,由于供应商的限制,我无法改变它.

标签:c-3,linux,linux-kernel,linux-device-driver

来源: https://codeday.me/bug/20190711/1431573.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值