I'm running RedHat 7.0.91 (Wolverine) Kernel 2.4.1-0.1.9
I'm writing a device driver for Industry Pak modules that plug into an
Industry Pak carrier which plugs into the PCI bus. I'm currently using an
Acromag APC8620 carrier which can take up to five IP modules. The IP
modules I'm using are also Acromag; one IP440 (opto-isolated digital input),
two IP445 (opto-isolated digital output), and one IP480 (timer/counter).
I've been using a pre-release copy of Linux Device Drivers (O'Reilly), as
well as the 1st edition, and I've read the device driver chapter from
Professional Linux Programming (WROX).
The pre-release LDD doesn't have the chapter on PCI, USB, etc. but does
mention PCI issues throughout. And my device driver is a loadable module,
and implements open, release, read, write, and mmap, so far.
The mmap file operation utilizes remap_page_range(), which requires a page
bounded physical address (4KB on x86).
My device shows up in /proc/iomem even before I load my device driver,
indicating that the pci subsystem mapped it into the kernel pages. But bar0
is 0xfdeff800 and bar2 is 0xfdeffc00. Neither is on a page boundary. I
have one other pci device, an Intel eepro100, and it's bars are page
bounded.
Why didn't the pci subsystem configure the device to appear on a page
boundary?
My device driver knows the bar0 and bar2 addresses and can mask them to get
the offset the userland program will need, but how can I get that offset to
the user program? I know I could create an ioctl call, but I would think
there must be some other method already in place, since this would affect
all pci devices.
Do man pages exist anywhere for:
remap_page_range, pci_register_driver, register_chrdev, request_mem_region,
etc.
Steven Friedrich
DynTel Corporation
Unit One, Box 611
Bldg 64 - NW Corner
Crane, IN 47522
> My device shows up in /proc/iomem even before I load my device driver,
> indicating that the pci subsystem mapped it into the kernel pages. But bar0
Actually the addresses you see there are physical bus addresses not neccessarily
and on x86 quite likely not actually mapped.
> Why didn't the pci subsystem configure the device to appear on a page
> boundary?
The device didnt ask to be on a page boundary
> the user program? I know I could create an ioctl call, but I would think
> there must be some other method already in place, since this would affect
> all pci devices.
If you want to mmap the device then you really want to put the device in its
own 4K aligned 4K sized PCI window, otherwise adjacent devices will become
accessible too and that might not be desirable.
Or you could avoid providing mmap.
Alan
a couple questions below...
-----Original Message-----
From: Alan Cox
Sent: Friday, April 13, 2001 14:47
To: Friedrich Steven E CONT CNIN
Cc: [email protected]
Subject: Re: device driver questions
> My device shows up in /proc/iomem even before I load my device
driver,
> indicating that the pci subsystem mapped it into the kernel pages.
But bar0
Actually the addresses you see there are physical bus addresses not
neccessarily
and on x86 quite likely not actually mapped.
Oops, sorry about that. I am using ioremap to create the kernel
pages
> Why didn't the pci subsystem configure the device to appear on a
page
> boundary?
The device didnt ask to be on a page boundary
Would seem like a good option to include on such a device, since
various OSes and platforms may have various requirements...
> the user program? I know I could create an ioctl call, but I
would think
> there must be some other method already in place, since this would
affect
> all pci devices.
If you want to mmap the device then you really want to put the
device in its
own 4K aligned 4K sized PCI window, otherwise adjacent devices will
become
accessible too and that might not be desirable.
How can I tell Linux to do this? Will the pci subsystem do it?
Or you could avoid providing mmap.
It seems to me that a lot of trouble went into creating memory
mapped i/o devices on the PC platform, and I would like to retain this
capability. Our app has real-time requirements, and we're trying to assess
if Linux can meet our requirements with/without real-time extensions. We
are also willing to move some of the real-time functionality into
hardware...
We've already developed our app under VxWorks. We access our
devices with simple, quick pointers to structures. So everything is a
*memory read* or *memory write*. Minimal overhead.
Alan
Friedrich Steven E CONT CNIN wrote:
> If you want to mmap the device then you really want to put the
> device in its own 4K aligned 4K sized PCI window, otherwise adjacent
> devices will become accessible too and that might not be desirable.
If you can, reprogram the device's PCI configuration to have a 4k or
more sized window. (You said you were willing to move functionality
into the hardware, so I assume you can do this). That guarantees it
will be page aligned, and without other devices overlapping in
userspace.
-- Jamie