Do I need to “enable” a PCIe memory region in a Linux 3.12 driver?

杀马特。学长 韩版系。学妹 提交于 2019-12-03 08:55:25

You definitely have to enable it. These are the basic steps:

pci_enable_device(dev);
pci_request_regions(dev, "driver/device name");
bar0 = pci_iomap(dev, 0, 0);
x = ioread(bar0 + offset);  /* there you are */

Error checking is required for all the pci_* calls. If the device needs to do DMA you also need to call pci_set_master and pci_set_dma_mask.

To elaborate, bypassing the PCI kernel code and directly ioremapping the BARs may have worked a long time ago. I'm not sure if it is even legal anymore in current code but it certainly isn't advisable.

To Enable the memory you can try out the below command directly.

setpci -s <BUS_ADDR> COMMAND=0x02 -s : Used for device selection COMMAND : Asks for the word-sized command register, 0x02 is to enable memory

lspci Output : 0000:01:00.0 RAM memory: Xilinx Corporation Default PCIe endpoint ID 0001:02:00.0 Memory controller: Xilinx Corporation Device 8011 Example : setpci -s 0001:02:00.0 COMMAND=0x02

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!