alpha: pci sysfs resources
Subsystems (2)
PATCH 1/1 alpha: pci sysfs resources
This closes http://bugzilla.kernel.org/show_bug.cgi?id=10893
which is a showstopper for X development on alpha.
The generic HAVE_PCI_MMAP code (drivers/pci-sysfs.c) is not very useful since we have to deal with three different types of MMIO address spaces: sparse and dense mappings for old ev4/ev5 machines and "normal" 1:1 MMIO space (bwx) for ev56 and later.
Also "write combine" mappings are meaningless on alpha - roughly speaking, alpha does write combining, IO reordering and other optimizations by default, unless user splits IO accesses with memory barriers.
I think the cleanest way to deal with resource files on alpha is to convert the default no-op pci_create_resource_files() and pci_remove_resource_files() for !HAVE_PCI_MMAP case into __weak functions and override them with alpha specific ones.
Another alpha hook is needed for "legacy_" resource files to handle sparse addressing (pci_adjust_legacy_attr).
With the "standard" resourceN files on ev56/ev6 libpciaccess works "out of the box". Handling of resourceN_sparse/resourceN_dense files on older machines obviously requires some userland work.
Sparse/dense stuff has been tested on sx164 (pca56/pyxis, normally uses bwx IO) with the kernel hacked into "cia compatible" mode.
--- arch/alpha/include/asm/pci.h | 14 ++ arch/alpha/kernel/Makefile | 2 +- arch/alpha/kernel/pci-sysfs.c | 366 +++++++++++++++++++++++++++++++++++++++++ drivers/pci/pci-sysfs.c | 19 ++- 4 files changed, 398 insertions(+), 3 deletions(-)
arch/alpha/include/asm/pci.h +14 -0
@@ -273,4 +273,18 @@ struct pci_dev *alpha_gendev_to_pci(struct device *dev);extern struct pci_dev *isa_bridge; +extern int pci_legacy_read (struct pci_bus *bus,loff_t port,u32 *val, +size_t count); +extern int pci_legacy_write (struct pci_bus *bus,loff_t port,u32 val, +size_t count); +extern int pci_mmap_legacy_page_range (struct pci_bus *bus, +struct vm_area_struct *vma, +enum pci_mmap_state mmap_state); +extern void pci_adjust_legacy_attr (struct pci_bus *bus, +enum pci_mmap_state mmap_type); +#define HAVE_PCI_LEGACY 1 + +extern int pci_create_resource_files (struct pci_dev *dev); +extern void pci_remove_resource_files (struct pci_dev *dev); +#endif /* __ALPHA_PCI_H */
arch/alpha/kernel/Makefile +1 -1
@@ -12,7 +12,7 @@ obj-y := entry.o traps.o process.o init_task.o osf_sys.o irq.o \ obj-$(CONFIG_VGA_HOSE) += console.o obj-$(CONFIG_SMP) += smp.o -obj-$(CONFIG_PCI) += pci.o pci_iommu.o +obj-$(CONFIG_PCI) += pci.o pci_iommu.o pci-sysfs.o obj-$(CONFIG_SRM_ENV) += srm_env.o obj-$(CONFIG_MODULES) += module.o
arch/alpha/kernel/pci-sysfs.c new file +366 -0
366 lines not on this page · raw message
drivers/pci/pci-sysfs.c +17 -2
@@ -493,6 +493,19 @@ pci_mmap_legacy_io(struct kobject *kobj, struct bin_attribute *attr, }/** +* pci_adjust_legacy_attr - adjustment of legacy file attributes +* @b: bus to create files under +* @mmap_type: I/O port or memory +* +* Stub implementation. Can be overridden by arch if necessary. +*/ +void __weak +pci_adjust_legacy_attr (struct pci_bus *b,enum pci_mmap_state mmap_type) +{ +return ; +} + +/** * pci_create_legacy_files - create legacy I/O port and memory files * @b: bus to create files under *
@@ -518,6 +531,7 @@ void pci_create_legacy_files(struct pci_bus *b) b->legacy_io->read = pci_read_legacy_io; b->legacy_io->write = pci_write_legacy_io; b->legacy_io->mmap = pci_mmap_legacy_io; +pci_adjust_legacy_attr (b, pci_mmap_io); error =device_create_bin_file (&b->dev, b->legacy_io);if (error) goto legacy_io_err;
@@ -528,6 +542,7 @@ void pci_create_legacy_files(struct pci_bus *b) b->legacy_mem->size =1024 *1024 ; b->legacy_mem->attr.mode =S_IRUSR |S_IWUSR ; b->legacy_mem->mmap = pci_mmap_legacy_mem; +pci_adjust_legacy_attr (b, pci_mmap_mem); error =device_create_bin_file (&b->dev, b->legacy_mem);if (error) goto legacy_mem_err;
@@ -719,8 +734,8 @@ static int pci_create_resource_files(struct pci_dev *pdev) return 0; }#else /* !HAVE_PCI_MMAP */ -static inline int pci_create_resource_files (struct pci_dev *dev) {return 0 ; } -static inline void pci_remove_resource_files (struct pci_dev *dev) {return ; } +int __weak pci_create_resource_files (struct pci_dev *dev) {return 0 ; } +void __weak pci_remove_resource_files (struct pci_dev *dev) {return ; }#endif /* HAVE_PCI_MMAP */ /**
Quoted 21 lines · Ivan Kokshaysky
This closes http://bugzilla.kernel.org/show_bug.cgi?id=10893
which is a showstopper for X development on alpha.The generic
HAVE_PCI_MMAPcode (drivers/pci-sysfs.c) is not very useful since we have to deal with three different types of MMIO address spaces: sparse and dense mappings for old ev4/ev5 machines and "normal" 1:1 MMIO space (bwx) for ev56 and later.
Also "write combine" mappings are meaningless on alpha - roughly speaking, alpha does write combining, IO reordering and other optimizations by default, unless user splits IO accesses with memory barriers.I think the cleanest way to deal with resource files on alpha is to convert the default no-op
pci_create_resource_files()andpci_remove_resource_files()for !HAVE_PCI_MMAP case into__weakfunctions and override them with alpha specific ones.Another alpha hook is needed for "
legacy_" resource files to handle sparse addressing (pci_adjust_legacy_attr).
Quoted 6 lines
With the "standard" resourceN files on ev56/ev6 libpciaccess works "out of the box". Handling of resourceN_sparse/resourceN_dense files on older machines obviously requires some userland work.
Sparse/dense stuff has been tested on sx164 (pca56/pyxis, normally uses bwx IO) with the kernel hacked into "cia compatible" mode.
Excellent, thanks Ivan. I've applied this one to my linux-next branch. Should make userspace stuff on the ev56/6 machines that much easier.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center