reimplement pci proc name
PATCH 1/1 reimplement pci proc name
Hi Greg. Ivan's not happy with the solution I came up with for naming /proc/bus/pci and Anton would prefer something slightly different too, so I abstracted the name out so each architecture can do its own thing.
This is against 2.5.72 so won't apply cleanly to your tree (it applies to bitkeeper as of a few minutes ago with only minor offsets). I've implemented the original name for non-PCI-domain machines; done what ia64 and alpha need, respectively (assuming I didn't misunderstand Ivan), and plopped in the Old Way of doing things for Sparc64, PPC and PPC64. Maintainers may alter this to whatever degree of complexity they wish.
Index: drivers/pci/proc.c
===================================================================
RCS file: /var/cvs/linux-2.5/drivers/pci/proc.c,v
retrieving revision 1.9
pci/proc.c +2 -1
@@ -383,7 +383,8 @@ int pci_proc_attach_device(struct pci_dereturn -EACCES ;if (!(de = bus->procdir)) { -sprintf (name,"%02x" , bus->number); +if (!pci_name_bus (name, bus)) +return -EEXIST ; de = bus->procdir =proc_mkdir (name, proc_bus_pci_dir);if (!de)return -ENOMEM ;
Index: include/asm-alpha/pci.h
===================================================================
RCS file: /var/cvs/linux-2.5/include/asm-alpha/pci.h,v retrieving revision 1.10
asm-alpha/pci.h +12 -0
@@ -194,6 +194,18 @@ pcibios_resource_to_bus(struct pci_dev *#define pci_domain_nr (bus) ((struct pci_controller *)(bus)->sysdata)->index +/* Bus number == domain number until we get above 256 busses */ +static inline int pci_name_bus (char *name,struct pci_bus *bus) +{ + int domain = pci_domain_nr(bus) +if (domain <256 ) { +sprintf (name,"%02x" , domain); + }else { +sprintf (name,"%04x:%02x" , domain, bus->number); + } +return 0 ; +} +#endif /* __KERNEL__ */ /* Values for the `which' argument to sys_pciconfig_iobase. */
Index: include/asm-ia64/pci.h
===================================================================
RCS file: /var/cvs/linux-2.5/include/asm-ia64/pci.h,v retrieving revision 1.8
asm-ia64/pci.h +10 -0
@@ -93,6 +93,16 @@ struct pci_controller {#define PCI_CONTROLLER (busdev) ((struct pci_controller *) busdev->sysdata)#define pci_domain_nr (busdev) (PCI_CONTROLLER(busdev)->segment) + +static inline int pci_name_bus (char *name,struct pci_bus *bus) +{ +if (pci_domain_nr (bus) ==0 ) { +sprintf (name,"%02x" , bus->number); + }else { +sprintf (name,"%04x:%02x" ,pci_domain_nr (bus), bus->number); + } +return 0 ; +}/* generic pci stuff */ #include <asm-generic/pci.h>
Index: include/asm-ppc/pci.h
===================================================================
RCS file: /var/cvs/linux-2.5/include/asm-ppc/pci.h,v retrieving revision 1.8
asm-ppc/pci.h +7 -0
@@ -269,6 +269,13 @@ pci_dac_dma_sync_single(struct pci_dev */* Return the index of the PCI controller for device PDEV. */ #define pci_domain_nr (bus) ((struct pci_controller *)(bus)->sysdata)->index +/* Set the name of the bus as it appears in /proc/bus/pci */ +static inline int pci_name_bus (char *name,struct pci_bus *bus) +{ +sprintf (name,"%02x" , bus->number); +return 0 ; +} +/* Map a range of PCI memory or I/O space for a device into user space */ int pci_mmap_page_range (struct pci_dev *pdev,struct vm_area_struct *vma,enum pci_mmap_state mmap_state,int write_combine);
Index: include/asm-ppc64/pci.h
===================================================================
RCS file: /var/cvs/linux-2.5/include/asm-ppc64/pci.h,v retrieving revision 1.6
asm-ppc64/pci.h +7 -0
@@ -88,6 +88,13 @@ static inline int pci_dma_supported(struextern int pci_domain_nr (struct pci_bus *bus); +/* Set the name of the bus as it appears in /proc/bus/pci */ +static inline int pci_name_bus (char *name,struct pci_bus *bus) +{ +sprintf (name,"%02x" , bus->number); +return 0 ; +} +struct vm_area_struct ;/* Map a range of PCI memory or I/O space for a device into user space */ int pci_mmap_page_range(struct pci_dev *pdev, struct vm_area_struct *vma,
Index: include/asm-sparc64/pci.h
===================================================================
RCS file: /var/cvs/linux-2.5/include/asm-sparc64/pci.h,v retrieving revision 1.8
asm-sparc64/pci.h +7 -0
@@ -191,6 +191,13 @@ pci_dac_dma_sync_single(struct pci_dev *extern int pci_domain_nr (struct pci_bus *bus); +/* Set the name of the bus as it appears in /proc/bus/pci */ +static inline int pci_name_bus (char *name,struct pci_bus *bus) +{ +sprintf (name,"%02x" , bus->number); +return 0 ; +} +/* Platform support for /proc/bus/pci/X/Y mmap()s. */ #define HAVE_PCI_MMAP
Index: include/linux/pci.h
===================================================================
RCS file: /var/cvs/linux-2.5/include/linux/pci.h,v retrieving revision 1.17
linux/pci.h +5 -0
@@ -808,6 +815,11 @@ extern int pci_pci_problems;#ifndef CONFIG_PCI_DOMAINS static inline int pci_domain_nr (struct pci_bus *bus) {return 0 ; } +static inline int pci_name_bus (char *name,struct pci_bus *bus) +{ +sprintf (name,"%02x" , bus->number); +return 0 ; +}#endif #endif /* __KERNEL__ */
Signature · 3 lines
"It's not Hollywood. War is real, war is primarily not about defeat or victory, it is about death. I've seen thousands and thousands of dead bodies. Do you think I want to have an academic debate on this subject?" -- Robert Fisk
Hi Matthew!
Just one question:
If pci_name_bus copies the bus' hex to name and always returns 0, the "if (!pci_name_bus(name, bus)) return -EEXIST;" would always be true, right?
Or did I miss something?
Regards,
Martin
On Fri, 20 Jun 2003 14:48:11 +0100
Matthew Wilcox <[email protected]> bubbled:
Quoted 39 lines
Index:
drivers/pci/proc.c
===================================================================
RCS file:/var/cvs/linux-2.5/drivers/pci/proc.c,v
retrieving revision 1.9
diff -u -p -r1.9proc.cpci/proc.c +2
-1@@ -383,7 +383,8 @@ int pci_proc_attach_device(struct pci_dereturn -EACCES ;if (!(de = bus->procdir)) { -sprintf (name,"%02x" , bus->number); +if (!pci_name_bus (name, bus)) +return -EEXIST ; de = bus->procdir =proc_mkdir (name, proc_bus_pci_dir);if (!de)return -ENOMEM ;Index:
include/linux/pci.h
===================================================================
RCS file:/var/cvs/linux-2.5/include/linux/pci.h,vretrieving revision 1.17
diff -u -p -r1.17pci.hlinux/pci.h +5
-0@@ -808,6 +815,11 @@ extern int pci_pci_problems;#ifndef CONFIG_PCI_DOMAINS static inline int pci_domain_nr (struct pci_bus *bus) {return 0 ; } +static inline int pci_name_bus (char *name,struct pci_bus *bus) +{ +sprintf (name,"%02x" , bus->number); +return 0 ; +}#endif #endif /* __KERNEL__ */
Signature · 7 lines
MyExcuse: Backbone adjustment Martin Zwickel <[email protected]> Research & Development TechnoTrend AG <http://www.technotrend.de>
Quoted 2 lines · Matthew Wilcox
I've implemented the original name for non-PCI-domain machines; done what ia64 and alpha need, respectively (assuming I didn't misunderstand Ivan)
You didn't. :-)
Looks fine to me, thanks.
Ivan.
Quoted 7 lines · Martin Zwickel
Hi Matthew!
Just one question:
Ifpci_name_buscopies the bus' hex to name and always returns 0, the "if (!pci_name_bus(name, bus)) return-EEXIST;" would always be true, right?Or did I miss something?
That's currently correct. My understanding is that some architectures would like to decline to create overlapping bus numbers.
Signature · 3 lines
"It's not Hollywood. War is real, war is primarily not about defeat or victory, it is about death. I've seen thousands and thousands of dead bodies. Do you think I want to have an academic debate on this subject?" -- Robert Fisk
Quoted 11 lines · Matthew Wilcox
Hi Greg. Ivan's not happy with the solution I came up with for naming
/proc/bus/pciand Anton would prefer something slightly different too, so I abstracted the name out so each architecture can do its own thing.This is against 2.5.72 so won't apply cleanly to your tree (it applies to bitkeeper as of a few minutes ago with only minor offsets). I've implemented the original name for non-PCI-domain machines; done what ia64 and alpha need, respectively (assuming I didn't misunderstand Ivan), and plopped in the Old Way of doing things for Sparc64, PPC and PPC64. Maintainers may alter this to whatever degree of complexity they wish.
Thanks, I've reverted your previous patch, and fixed the one typo in this patch and applied it all to my bk tree. Hopefully Linus will pull from it sometime soon :)
thanks,
greg k-h
Quoted 3 lines · Greg KH
Thanks, I've reverted your previous patch, and fixed the one typo in this patch and applied it all to my bk tree. Hopefully Linus will pull from it sometime soon :)
Argh, where were my eyes... There was another typo which broke Alpha.
Greg, please apply.
Ivan.
include/asm-alpha/pci.h +2 -1
@@ -197,7 +197,8 @@ pcibios_resource_to_bus(struct pci_dev */* Bus number == domain number until we get above 256 busses */ static inline int pci_name_bus (char *name,struct pci_bus *bus) { - int domain = pci_domain_nr(bus) +int domain =pci_domain_nr (bus); +if (domain <256 ) {sprintf (name,"%02x" , domain); }else {
Greg KH
AppliedQuoted 8 lines · Ivan Kokshaysky
Quoted 3 lines · Greg KH
Thanks, I've reverted your previous patch, and fixed the one typo in this patch and applied it all to my bk tree. Hopefully Linus will pull from it sometime soon :)
Argh, where were my eyes... There was another typo which broke Alpha.
Greg, please apply.
Applied, thanks.
greg k-h