UIO: missing resource mapping

From: Andreas Schallenberg
Date: Thu Jul 12 2012 - 03:26:25 EST


Hello,

I'm doing experiments with the Userspace IO driver (UIO_PCI_GENERIC) and a set of PCIe cards. The kernel version is 3.4.4, CPU is a Marvell MV78200 (ARMv5te). Example with an Intel ethernet card:

This makes /dev/uio0 appear
echo -n "8086 10d3" >/sys/bus/pci/drivers/uio_pci_generic/new_id

# lspci -v -k -s 0000:00:01.0
00:01.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
Subsystem: Intel Corporation Gigabit CT Desktop Adapter
Flags: bus master, fast devsel, latency 0, IRQ 36
Memory at c00c0000 (32-bit, non-prefetchable) [size=128K]
Memory at c0000000 (32-bit, non-prefetchable) [size=512K]
I/O ports at f0800000 [size=32]
Memory at c00e0000 (32-bit, non-prefetchable) [size=16K]
[virtual] Expansion ROM at c0080000 [disabled] [size=256K]
Capabilities: [c8] Power Management version 2
Capabilities: [d0] MSI: Enable- Count=1/1 Maskable- 64bit+
Capabilities: [e0] Express Endpoint, MSI 00
Capabilities: [a0] MSI-X: Enable- Count=5 Masked-
Capabilities: [100] Advanced Error Reporting
Capabilities: [140] Device Serial Number 00-1b-21-ff-ff-c4-f7-2f
Kernel driver in use: uio_pci_generic

Suprisingly, there is no "maps" directory in /sys/class/uio/uio0 now. I made a small change to the UIO code:

diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index a783d53..b639654 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -274,8 +274,10 @@ static int uio_dev_add_attributes(struct uio_device *idev)

for (mi = 0; mi < MAX_UIO_MAPS; mi++) {
mem = &idev->info->mem[mi];
- if (mem->size == 0)
- break;
+ if (mem->size == 0) {
+ dev_err(idev->dev, "map %d has zero size\n", mi);
+ continue; // was: break
+ }
if (!map_found) {
map_found = 1;
idev->map_dir = kobject_create_and_add("maps",

If I have this in the kernel and give the "echo" command as shown above I get:
[ 43.761723] uio uio0: map 0 has zero size
[ 43.765760] uio uio0: map 1 has zero size
[ 43.769787] uio uio0: map 2 has zero size
[ 43.774298] uio uio0: map 3 has zero size
[ 43.778333] uio uio0: map 4 has zero size

On the other hand, I can see the resources:
# cat /sys/class/uio/uio0/device/resource
0x00000000c00c0000 0x00000000c00dffff 0x0000000000040200
0x00000000c0000000 0x00000000c007ffff 0x0000000000040200
0x00000000f0800000 0x00000000f080001f 0x0000000000040101
0x00000000c00e0000 0x00000000c00e3fff 0x0000000000040200
...more...

Looking further at the code, I cannot see where the mem fields are being filled at all.
Which code is supposed to write the struct uio_mem?

Best,
Andreas



--
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/