Re: Driver access ito PCI card memory space question.

From: Roland Dreier
Date: Wed Oct 06 2004 - 18:11:23 EST


Alan> Then I do request_mem_area(0xfeaff000,4095, "SSE");

Alan> Then I do a readl(0xfeaff100); and get this:

Alan> Unable to handle kernel paging request at virtual address feaff100

You can't blindly access an address from your device's BARs; on many
architectures PCI access needs setting up and/or addresses need
munging before use. The API you need is ioremap().

You need to do something like:

void __iomem *mybase = ioremap(pci_resource_start(my_pdev, 0), 4095);
u32 value = readl(mybase + 0x100);

(Delete the __iomem annotation for kernels before 2.6.9).

The "Linux Device Drivers" online book, available at
<http://www.xml.com/ldd/chapter/book/> will probably be pretty
helpful. In fact if you're serious about writing drivers, you should
buy a dead-tree copy.

- Roland
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/