pci: Add ability to mmap legacy_io on some platforms
PATCH 1/2 pci: Add ability to mmap legacy_io on some platforms
This adds the ability to mmap legacy IO space to the legacy_io files in sysfs on platforms that support it. This will allow to clean up X to use this instead of /dev/mem for legacy IO accesses such as those performed by Int10.
While at it I moved pci_create/remove_legacy_files() to pci-sysfs.c where I think they belong, thus making more things statis in there and cleaned up some spurrious prototypes in the ia64 pci.h file
---
I didn't have a chance to test that I didn't break ia64, so I would be if somebody could give it a spin there ! Thanks !
arch/ia64/include/asm/pci.h | 12 ----- arch/ia64/pci/pci.c | 7 ++- drivers/pci/pci-sysfs.c | 93 +++++++++++++++++++++++++++++++++++++++++--- drivers/pci/pci.h | 6 ++ drivers/pci/probe.c | 66 ------------------------------- 5 files changed, 102 insertions(+), 82 deletions(-)
arch/ia64/include/asm/pci.h +2 -10
@@ -95,16 +95,8 @@ extern int pci_mmap_page_range (struct p enum pci_mmap_state mmap_state, int write_combine);#define HAVE_PCI_LEGACY extern int pci_mmap_legacy_page_range (struct pci_bus *bus, -struct vm_area_struct *vma); -extern ssize_t pci_read_legacy_io (struct kobject *kobj, -struct bin_attribute *bin_attr, -char *buf,loff_t off,size_t count); -extern ssize_t pci_write_legacy_io (struct kobject *kobj, -struct bin_attribute *bin_attr, -char *buf,loff_t off,size_t count); -extern int pci_mmap_legacy_mem (struct kobject *kobj, -struct bin_attribute *attr, -struct vm_area_struct *vma); +struct vm_area_struct *vma, +enum pci_mmap_state mmap_state);#define pci_get_legacy_mem platform_pci_get_legacy_mem#define pci_legacy_read platform_pci_legacy_read
arch/ia64/pci/pci.c +6 -1
@@ -614,12 +614,17 @@ char *ia64_pci_get_legacy_mem(struct pci* vector to get the base address. */ int -pci_mmap_legacy_page_range (struct pci_bus *bus,struct vm_area_struct *vma) +pci_mmap_legacy_page_range (struct pci_bus *bus,struct vm_area_struct *vma, +enum pci_mmap_state mmap_state) {unsigned long size = vma->vm_end - vma->vm_start;pgprot_t prot;char *addr; +/* We only support mmap'ing of legacy memory space */ +if (mmap_state != pci_mmap_mem) +return -ENOSYS ; +/* * Avoid attribute aliasing. See Documentation/ia64/aliasing.txt * for more details.
drivers/pci/pci-sysfs.c +88 -5
120 lines not on this page · raw message
drivers/pci/pci.h +6 -0
@@ -76,7 +76,13 @@ static inline int pci_proc_detach_bus(st/* Functions for PCI Hotplug drivers to use */ extern unsigned int pci_do_scan_bus (struct pci_bus *bus); +#ifdef HAVE_PCI_LEGACY +extern void pci_create_legacy_files (struct pci_bus *bus);extern void pci_remove_legacy_files (struct pci_bus *bus); +#else +static inline void pci_create_legacy_files (struct pci_bus *bus) {return ; } +static inline void pci_remove_legacy_files (struct pci_bus *bus) {return ; } +#endif /* Lock for read/write access to pci device and bus lists */ extern struct rw_semaphore pci_bus_sem;
drivers/pci/probe.c +0 -66
72 lines not on this page · raw message
Quoted 15 lines · Benjamin Herrenschmidt
This adds the ability to mmap legacy IO space to the
legacy_iofiles in sysfs on platforms that support it. This will allow to clean up X to use this instead of/dev/memfor legacy IO accesses such as those performed by Int10.While at it I moved pci_create/remove_legacy_files() to
pci-sysfs.cwhere I think they belong, thus making more things statis in there and cleaned up some spurrious prototypes in the ia64pci.hfileSigned-off-by Benjamin Herrenschmidt <[email protected]>---
I didn't have a chance to test that I didn't break ia64, so I would be if somebody could give it a spin there ! Thanks !
Quoted 7 lines
arch/ia64/include/asm/pci.h | 12 ----- arch/ia64/pci/pci.c | 7 ++- drivers/pci/pci-sysfs.c | 93 +++++++++++++++++++++++++++++++++++++++++--- drivers/pci/pci.h | 6 ++ drivers/pci/probe.c | 66 ------------------------------- 5 files changed, 102 insertions(+), 82 deletions(-)
Heh, is it obvious that this code originated on ia64 and no one ever ported it to another platform until now? :)
Tony and/or Bjorn, do you want to take a look and make sure this is ok? If so I can take the whole thing into the PCI tree.
Thanks,
Jesse
Quoted 2 lines · Jesse Barnes
Tony and/or Bjorn, do you want to take a look and make sure this is ok? If so I can take the whole thing into the PCI tree.
Don't take patch 2/2, only 1/2. If/when you do, I'll then get the powerpc side patch via the powerpc tree, as I didn't quite manage to test it properly yet and I may want to polish a thing or two first. It's also likely to collide with other powerpc incoming stuff, better if I sort that out.
Cheers,
Ben.
Quoted 2 lines
I didn't have a chance to test that I didn't break ia64, so I would be if somebody could give it a spin there ! Thanks !
All my ia64 config variations still build cleanly with these two patches applied. I booted a couple of systems too with no obvious ill-effects.
I have the same set of "legacy_io" and "legacy_mem" files in /sys/class/pci_bus/xxxx:xx/ that I had before applying these patches. I'm not sure how to test that they still "work".
-Tony