I am writing a PCI driver for a simple test device.
Hardware is recognized correctly with lspci (as you can see my driver vabs has been registered):
04:02.0 Non-VGA unclassified device: Device bace:55aa
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap- 66MHz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Region 0: Memory at f0000000 (32-bit, prefetchable) [size=16M]
Kernel driver in use: vabs
Initialisation and deinitalisation of driver and PCI subystem works fine. I am getting a device number, and udev creates a device file.
When reading from the device file I get the following error message:
BUG: unable to handle kernel paging request at 00000000f0000000
I request PCI ressources in the initialisation successfully. This returns 00000000f0000000 for memstart0, which is my base address 0 for PCI.
memstart0 = pci_resource_start( pdev, 0 );
memlen = pci_resource_len( pdev, 0 );
if( request_mem_region(memstart0,memlen,pdev->dev.kobj.name)==NULL ) {
dev_err(&pdev->dev,"Memory address conflict for device\n");
goto cleanup_mem;
}
Trying to read from this memio address with the following code gives the mentioned error:
ssize_t driver_read(struct file *instance, char __user *buffer, size_t max_bytes_to_read, loff_t *offset) {
u32 test;
dev_dbg(vabs_dev,"copying from %p\n", (void *) memstart0);
test = readl((void *) memstart0);
return max_bytes_to_read;
}
I also tried other access functions like memcpy_fromio, ioread32, and direct pointer access with the same result.
The hardware works on a Windows machine. The only notable difference is that Windows reserves base address 0 as 00000000fd000000 while Linux reserves it as 00000000f0000000.
This is for non-profit educational purpose in a public school. Thanks for your help!