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
diff -u -p -r1.9 proc.c
--- drivers/pci/proc.c 14 Jun 2003 22:15:29 -0000 1.9
+++ drivers/pci/proc.c 17 Jun 2003 19:36:50 -0000
@@ -383,7 +383,8 @@ int pci_proc_attach_device(struct pci_de
return -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
diff -u -p -r1.10 pci.h
--- include/asm-alpha/pci.h 14 Jun 2003 22:15:52 -0000 1.10
+++ include/asm-alpha/pci.h 20 Jun 2003 12:44:23 -0000
@@ -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
diff -u -p -r1.8 pci.h
--- include/asm-ia64/pci.h 14 Jun 2003 22:15:56 -0000 1.8
+++ include/asm-ia64/pci.h 17 Jun 2003 19:37:45 -0000
@@ -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
diff -u -p -r1.8 pci.h
--- include/asm-ppc/pci.h 17 Jun 2003 11:54:26 -0000 1.8
+++ include/asm-ppc/pci.h 20 Jun 2003 13:25:29 -0000
@@ -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
diff -u -p -r1.6 pci.h
--- include/asm-ppc64/pci.h 14 Jun 2003 22:15:59 -0000 1.6
+++ include/asm-ppc64/pci.h 20 Jun 2003 13:25:48 -0000
@@ -88,6 +88,13 @@ static inline int pci_dma_supported(stru
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;
+}
+
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
diff -u -p -r1.8 pci.h
--- include/asm-sparc64/pci.h 14 Jun 2003 22:16:00 -0000 1.8
+++ include/asm-sparc64/pci.h 20 Jun 2003 13:25:52 -0000
@@ -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
diff -u -p -r1.17 pci.h
--- include/linux/pci.h 14 Jun 2003 22:16:01 -0000 1.17
+++ include/linux/pci.h 19 Jun 2003 00:55:35 -0000
@@ -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__ */
--
"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:
>
> 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.9 proc.c
> --- drivers/pci/proc.c 14 Jun 2003 22:15:29 -0000 1.9
> +++ drivers/pci/proc.c 17 Jun 2003 19:36:50 -0000
> @@ -383,7 +383,8 @@ int pci_proc_attach_device(struct pci_de
> return -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,v
> retrieving revision 1.17
> diff -u -p -r1.17 pci.h
> --- include/linux/pci.h 14 Jun 2003 22:16:01 -0000 1.17
> +++ include/linux/pci.h 19 Jun 2003 00:55:35 -0000
> @@ -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__ */
>
--
MyExcuse:
Backbone adjustment
Martin Zwickel <[email protected]>
Research & Development
TechnoTrend AG <http://www.technotrend.de>
On Fri, Jun 20, 2003 at 02:48:11PM +0100, Matthew Wilcox wrote:
> 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.
On Fri, Jun 20, 2003 at 04:02:28PM +0200, Martin Zwickel wrote:
> 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?
That's currently correct. My understanding is that some architectures
would like to decline to create overlapping bus numbers.
--
"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
On Fri, Jun 20, 2003 at 02:48:11PM +0100, Matthew Wilcox wrote:
>
> 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.
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
On Fri, Jun 20, 2003 at 02:24:13PM -0700, Greg KH wrote:
> 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.
--- 2.5/include/asm-alpha/pci.h Sat Jun 21 15:36:01 2003
+++ linux/include/asm-alpha/pci.h Sat Jun 21 15:36:24 2003
@@ -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 {
On Sat, Jun 21, 2003 at 03:53:33PM +0400, Ivan Kokshaysky wrote:
> On Fri, Jun 20, 2003 at 02:24:13PM -0700, Greg KH wrote:
> > 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