linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* PCI Express support for 2.4 kernel
@ 2003-12-14 20:00 Vladimir Kondratiev
  2003-12-14 20:46 ` Jeff Garzik
  2003-12-15 10:07 ` Greg KH
  0 siblings, 2 replies; 80+ messages in thread
From: Vladimir Kondratiev @ 2003-12-14 20:00 UTC (permalink / raw)
  To: linux-kernel; +Cc: Alan Cox, Marcelo Tosatti

[-- Attachment #1: Type: text/plain, Size: 831 bytes --]

Please, ignore previous submission with the same subject. Patch file 
attached was wrong one. Now correct patch attached.

Hi,
PCI-Express platforms will soon appear on the market. It is worth to
support it.

Following is patch for 2.4.23 kernel. I tested it on my host, it works
properly.
I did it for i386 only, I have no other architecture to test.

It was patch on the same subject from* Seshadri, Harinarayanan*
(/harinarayanan.seshadri@intel.com/
<mailto:harinarayanan.seshadri@intel.com>)
http://www.cs.helsinki.fi/linux/linux-kernel/2003-17/0247.html
My version differ in several aspects: it is for 2.4 (vs. 2.6); it do not
ioremap/unmap page for each transaction.

How about inclusion in 2.4.24?

I am not subscribed to lkml, thus please CC me
(Vladimir Kondratiev <vladimir.kondratiev@intel.com>) in replies.

Vladimir.


[-- Attachment #2: pciexp.patch --]
[-- Type: text/plain, Size: 7703 bytes --]

Enable PCI Express access method for configuration space
This path includes:
 * access routines itself
 * command line argument "pci=exp" to force PCI Express, similar to "conf1" and "conf2"
 * full 4k config accessed through /proc/bus/pci/...

How it works:

With PCI-E, config space accessed through memory. Each device gets its own 4k memory mapped config,
total 256M for all devices.

At init time, I map whole region to not spent time for mapping later.

For /proc/bus/pci/..., I changed PCI_CFG_SPACE_SIZE to variable and changed it to 4k for PCI-E.

It is tested on 1 platform.

Author: "Vladimir Kondratiev" <vladimir.kondratiev@intel.com> 

diff -bBdur linux-2.4.23/arch/i386/kernel/pci-i386.h linux-2.4.23-pciexp/arch/i386/kernel/pci-i386.h
--- linux-2.4.23/arch/i386/kernel/pci-i386.h	2003-11-28 20:26:19.000000000 +0200
+++ linux-2.4.23-pciexp/arch/i386/kernel/pci-i386.h	2003-12-14 11:08:17.000000000 +0200
@@ -15,6 +15,7 @@
 #define PCI_PROBE_BIOS		0x0001
 #define PCI_PROBE_CONF1		0x0002
 #define PCI_PROBE_CONF2		0x0004
+#define PCI_PROBE_EXP		0x0008
 #define PCI_NO_SORT		0x0100
 #define PCI_BIOS_SORT		0x0200
 #define PCI_NO_CHECKS		0x0400
diff -bBdur linux-2.4.23/arch/i386/kernel/pci-pc.c linux-2.4.23-pciexp/arch/i386/kernel/pci-pc.c
--- linux-2.4.23/arch/i386/kernel/pci-pc.c	2003-11-28 20:26:19.000000000 +0200
+++ linux-2.4.23-pciexp/arch/i386/kernel/pci-pc.c	2003-12-14 21:27:52.000000000 +0200
@@ -20,7 +20,7 @@
 
 #include "pci-i386.h"
 
-unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2;
+unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 | PCI_PROBE_EXP;
 
 int pcibios_last_bus = -1;
 struct pci_bus *pci_root_bus = NULL;
@@ -427,6 +427,155 @@
 	pci_conf2_write_config_dword
 };
 
+/**
+ * PCI Express routines
+ * "Vladimir Kondratiev" <vladimir.kondratiev@intel.com>
+ */
+/**
+ * RRBAR (memory base for PCI-E config space) resides here.
+ * Initialized to default address. Actually, it is platform specific, and
+ * value may vary.
+ * I don't know how to detect it properly, it is chipset specific.
+ */
+static u32 rrbar_phys=0xe0000000UL;
+/**
+ * RRBAR is always 256M
+ */
+static u32 rrbar_size=0x10000000UL;
+/**
+ * Virtual address for RRBAR
+ */
+static void* rrbar_virt=NULL;
+/**
+ * It used to be #define, but I am going to change it.
+ */
+extern int PCI_CFG_SPACE_SIZE;
+
+/**
+ * Initializes PCI Express method for config space access.
+ * 
+ * There is no standard method to recognize presence of PCI Express,
+ * thus we will assume it is PCI-E, and rely on sanity check to
+ * deassert PCI-E presense. If PCI-E not present,
+ * there is no physical RAM on RRBAR address, and we should read
+ * something like 0xff.
+ * 
+ * Creates mapping for whole 256M area.
+ * 
+ * @return 1 if OK, 0 if error
+ */
+static int pci_express_init(void)
+{
+  /* TODO: check PCI-Ex presense */
+  rrbar_virt=ioremap(rrbar_phys,rrbar_size);
+  if (!rrbar_virt) return 0;
+  return 1;
+}
+
+/**
+ * Shuts down PCI-E resources.
+ */
+static void pci_express_fini(void)
+{
+  if (rrbar_virt) {
+    iounmap(rrbar_virt);
+  }
+}
+
+static int pci_exp_read (int seg, int bus, int dev, int fn, int reg, int len, u32 *value)
+{
+  void* addr=rrbar_virt+(bus << 20)+(dev << 15)+(fn << 12)+reg;
+  if ((bus > 255 || dev > 31 || fn > 7 || reg > 4095)) 
+    return -EINVAL;
+  switch (len) {
+  case 1:
+    *value=readb(addr);
+    break;
+  case 2:
+    if (reg&1) return -EINVAL;
+    *value=readw(addr);
+    break;
+  case 4:
+    if (reg&3) return -EINVAL;
+    *value=readl(addr);
+    break;
+  }
+  return 0;
+}
+
+static int pci_exp_write (int seg, int bus, int dev, int fn, int reg, int len, u32 value)
+{
+  void* addr=rrbar_virt+(bus << 20)+(dev << 15)+(fn << 12)+reg;
+  if ((bus > 255 || dev > 31 || fn > 7 || reg > 4095)) 
+    return -EINVAL;
+  switch (len) {
+  case 1:
+    writeb(value,addr);
+    break;
+  case 2:
+    if (reg&1) return -EINVAL;
+    writew(value,addr);
+    break;
+  case 4:
+    if (reg&3) return -EINVAL;
+    writel(value,addr);
+    break;
+  }
+  return 0;
+}
+
+static int pci_exp_read_config_byte(struct pci_dev *dev, int where, u8 *value)
+{
+  int result; 
+  u32 data;
+  result = pci_exp_read(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+			PCI_FUNC(dev->devfn), where, 1, &data);
+  *value = (u8)data;
+  return result;
+}
+
+static int pci_exp_read_config_word(struct pci_dev *dev, int where, u16 *value)
+{
+  int result; 
+  u32 data;
+  result = pci_exp_read(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+			PCI_FUNC(dev->devfn), where, 2, &data);
+  *value = (u16)data;
+  return result;
+}
+
+static int pci_exp_read_config_dword(struct pci_dev *dev, int where, u32 *value)
+{
+  return pci_exp_read(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		      PCI_FUNC(dev->devfn), where, 4, value);
+}
+
+static int pci_exp_write_config_byte(struct pci_dev *dev, int where, u8 value)
+{
+  return pci_exp_write(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		       PCI_FUNC(dev->devfn), where, 1, value);
+}
+
+static int pci_exp_write_config_word(struct pci_dev *dev, int where, u16 value)
+{
+  return pci_exp_write(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		       PCI_FUNC(dev->devfn), where, 2, value);
+}
+
+static int pci_exp_write_config_dword(struct pci_dev *dev, int where, u32 value)
+{
+  return pci_exp_write(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		       PCI_FUNC(dev->devfn), where, 4, value);
+}
+
+static struct pci_ops pci_express_conf = {
+  pci_exp_read_config_byte,
+  pci_exp_read_config_word,
+  pci_exp_read_config_dword,
+  pci_exp_write_config_byte,
+  pci_exp_write_config_word,
+  pci_exp_write_config_dword
+};
 
 /*
  * Before we decide to use direct hardware access mechanisms, we try to do some
@@ -465,6 +614,21 @@
 
 	__save_flags(flags); __cli();
 
+    /**
+     * Check if PCI-express access work
+     */
+    if (pci_express_init()) {
+        if (pci_sanity_check(&pci_express_conf)) {
+            PCI_CFG_SPACE_SIZE=4096;
+			__restore_flags(flags);
+			printk(KERN_INFO "PCI: Using configuration type PCI Express\n");
+			request_mem_region(rrbar_phys, rrbar_size, "PCI-Express config space");
+			return &pci_express_conf;
+        } else {
+            pci_express_fini();
+        }
+    }
+
 	/*
 	 * Check if configuration type 1 works.
 	 */
@@ -1398,16 +1562,18 @@
 #endif
 
 #ifdef CONFIG_PCI_DIRECT
-	if ((pci_probe & (PCI_PROBE_CONF1 | PCI_PROBE_CONF2)) 
+	if ((pci_probe & (PCI_PROBE_CONF1 | PCI_PROBE_CONF2 | PCI_PROBE_EXP)) 
 		&& (tmp = pci_check_direct())) {
 		pci_root_ops = tmp;
 		if (pci_root_ops == &pci_direct_conf1) {
 			pci_config_read = pci_conf1_read;
 			pci_config_write = pci_conf1_write;
-		}
-		else {
+		} else if (pci_root_ops == &pci_direct_conf2) {
 			pci_config_read = pci_conf2_read;
 			pci_config_write = pci_conf2_write;
+		} else if (pci_root_ops == &pci_express_conf) {
+			pci_config_read = pci_exp_read;
+			pci_config_write = pci_exp_write;
 		}
 	}
 #endif
@@ -1489,6 +1655,10 @@
 		pci_probe = PCI_PROBE_CONF2 | PCI_NO_CHECKS;
 		return NULL;
 	}
+	else if (!strcmp(str, "exp")) {
+		pci_probe = PCI_PROBE_EXP | PCI_NO_CHECKS;
+		return NULL;
+	}
 #endif
 	else if (!strcmp(str, "rom")) {
 		pci_probe |= PCI_ASSIGN_ROMS;
diff -bBdur linux-2.4.23/drivers/pci/proc.c linux-2.4.23-pciexp/drivers/pci/proc.c
--- linux-2.4.23/drivers/pci/proc.c	2002-11-29 01:53:14.000000000 +0200
+++ linux-2.4.23-pciexp/drivers/pci/proc.c	2003-12-14 14:18:58.000000000 +0200
@@ -16,7 +16,7 @@
 #include <asm/uaccess.h>
 #include <asm/byteorder.h>
 
-#define PCI_CFG_SPACE_SIZE 256
+int PCI_CFG_SPACE_SIZE=256;
 
 static loff_t
 proc_bus_pci_lseek(struct file *file, loff_t off, int whence)

^ permalink raw reply	[flat|nested] 80+ messages in thread
[parent not found: <12InT-wQ-5@gated-at.bofh.it>]
* RE: PCI Express support for 2.4 kernel
@ 2003-12-15 20:08 Nakajima, Jun
  0 siblings, 0 replies; 80+ messages in thread
From: Nakajima, Jun @ 2003-12-15 20:08 UTC (permalink / raw)
  To: Greg KH, Kondratiev, Vladimir; +Cc: linux-kernel, Alan Cox, Marcelo Tosatti

> > +/**
> > + * RRBAR (memory base for PCI-E config space) resides here.
> > + * Initialized to default address. Actually, it is platform
specific,
> and
> > + * value may vary.
> > + * I don't know how to detect it properly, it is chipset specific.
> > + */
> > +static u32 rrbar_phys=0xe0000000UL;

Sorry, this patch is not appropriate because it's hard coding this
chipset-specific address. The way of getting this address is being
defined by a public specification (I cannot tell which spec now). 

	Jun

> -----Original Message-----
> From: linux-kernel-owner@vger.kernel.org [mailto:linux-kernel-
> owner@vger.kernel.org] On Behalf Of Greg KH
> Sent: Monday, December 15, 2003 2:07 AM
> To: Kondratiev, Vladimir
> Cc: linux-kernel@vger.kernel.org; Alan Cox; Marcelo Tosatti
> Subject: Re: PCI Express support for 2.4 kernel
> 
> On Sun, Dec 14, 2003 at 10:00:49PM +0200, Vladimir Kondratiev wrote:
> > Please, ignore previous submission with the same subject. Patch file
> > attached was wrong one. Now correct patch attached.
> >
> > Hi,
> > PCI-Express platforms will soon appear on the market. It is worth to
> > support it.
> 
> Yes it is worth it, any chance to get access to hardware to test this
> out on?
> 
> > Following is patch for 2.4.23 kernel. I tested it on my host, it
works
> > properly.
> > I did it for i386 only, I have no other architecture to test.
> >
> > It was patch on the same subject from* Seshadri, Harinarayanan*
> > (/harinarayanan.seshadri@intel.com/
> > <mailto:harinarayanan.seshadri@intel.com>)
> > http://www.cs.helsinki.fi/linux/linux-kernel/2003-17/0247.html
> > My version differ in several aspects: it is for 2.4 (vs. 2.6); it do
not
> > ioremap/unmap page for each transaction.
> >
> > How about inclusion in 2.4.24?
> 
> No, we need to get this into 2.6 first.  Can you please forward port
> this to 2.6, clean up the formatting and address the issues everyone
> else has made so far and post it?
> 
> >  * command line argument "pci=exp" to force PCI Express, similar to
> "conf1" and "conf2"
> 
> We should be able to do this automatically, and not force this on the
> boot command line, correct?
> 
> > +/**
> > + * RRBAR (memory base for PCI-E config space) resides here.
> > + * Initialized to default address. Actually, it is platform
specific,
> and
> > + * value may vary.
> > + * I don't know how to detect it properly, it is chipset specific.
> > + */
> > +static u32 rrbar_phys=0xe0000000UL;
> 
> How about information on how to detect it as per chipset type?  We
need
> to do this automatically some how.
> 
> > +/**
> > + * Initializes PCI Express method for config space access.
> > + *
> > + * There is no standard method to recognize presence of PCI
Express,
> 
> Are you sure?  I thought there was (don't have my spec in front of me
> right now...)
> 
> thanks,
> 
> greg k-h
> -
> To unsubscribe from this list: send the line "unsubscribe
linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 80+ messages in thread
[parent not found: <Pine.LNX.4.44.0312150917170.32061-100000@coffee.psychology.mcmaster.ca>]
[parent not found: <12KJ6-4F2-13@gated-at.bofh.it>]
[parent not found: <3FDCA569.5070006@pobox.com>]
* PCI Express support for 2.4 kernel
@ 2003-12-14 17:28 Vladimir Kondratiev
  2003-12-15  7:48 ` Christoph Hellwig
  2003-12-15 18:26 ` Linus Torvalds
  0 siblings, 2 replies; 80+ messages in thread
From: Vladimir Kondratiev @ 2003-12-14 17:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: Alan Cox, Marcelo Tosatti

[-- Attachment #1: Type: text/plain, Size: 713 bytes --]

Hi,
PCI-Express platforms will soon appear on the market. It is worth to 
support it.

Following is patch for 2.4.23 kernel. I tested it on my host, it works 
properly.
I did it for i386 only, I have no other architecture to test.

It was patch on the same subject from* Seshadri, Harinarayanan* 
(/harinarayanan.seshadri@intel.com/ 
<mailto:harinarayanan.seshadri@intel.com>) 
http://www.cs.helsinki.fi/linux/linux-kernel/2003-17/0247.html
My version differ in several aspects: it is for 2.4 (vs. 2.6); it do not 
ioremap/unmap page for each transaction.

How about inclusion in 2.4.24?

I am not subscribed to lkml, thus please CC me
(Vladimir Kondratiev <vladimir.kondratiev@intel.com>) in replies.

Vladimir.

[-- Attachment #2: pciexp.patch --]
[-- Type: text/plain, Size: 8056 bytes --]

Enable PCI Express access method for configuration space
This path includes:
 * access routines itself
 * command line argument "pci=exp" to force PCI Express, similar to "conf1" and "conf2"
 * full 4k config accessed through /proc/bus/pci/...

How it works:

With PCI-E, config space accessed through memory. Each device gets its own 4k memory mapped config,
total 256M for all devices.

At init time, I map whole region to not spent time for mapping later.

For /proc/bus/pci/..., I changed PCI_CFG_SPACE_SIZE to variable and changed it to 4k for PCI-E.

It is tested on 1 platform.

Author: "Vladimir Kondratiev" <vladimir.kondratiev@intel.com> 

diff -bBdur linux-2.4.23/arch/i386/kernel/pci-i386.h linux-2.4.23-pciexp/arch/i386/kernel/pci-i386.h
--- linux-2.4.23/arch/i386/kernel/pci-i386.h	2003-11-28 20:26:19.000000000 +0200
+++ linux-2.4.23-pciexp/arch/i386/kernel/pci-i386.h	2003-12-14 11:08:17.000000000 +0200
@@ -15,6 +15,7 @@
 #define PCI_PROBE_BIOS		0x0001
 #define PCI_PROBE_CONF1		0x0002
 #define PCI_PROBE_CONF2		0x0004
+#define PCI_PROBE_EXP		0x0008
 #define PCI_NO_SORT		0x0100
 #define PCI_BIOS_SORT		0x0200
 #define PCI_NO_CHECKS		0x0400
diff -bBdur linux-2.4.23/arch/i386/kernel/pci-pc.c linux-2.4.23-pciexp/arch/i386/kernel/pci-pc.c
--- linux-2.4.23/arch/i386/kernel/pci-pc.c	2003-11-28 20:26:19.000000000 +0200
+++ linux-2.4.23-pciexp/arch/i386/kernel/pci-pc.c	2003-12-14 18:30:52.000000000 +0200
@@ -20,7 +20,7 @@
 
 #include "pci-i386.h"
 
-unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2;
+unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 | PCI_PROBE_EXP;
 
 int pcibios_last_bus = -1;
 struct pci_bus *pci_root_bus = NULL;
@@ -427,6 +427,169 @@
 	pci_conf2_write_config_dword
 };
 
+/**
+ * PCI Express routines
+ * "Vladimir Kondratiev" <vladimir.kondratiev@intel.com>
+ */
+/**
+ * RRBAR (memory base for PCI-E config space) resides here.
+ * Initialized to default address. Actually, it is platform specific, and
+ * value may vary.
+ * I don't know how to detect it properly, it is chipset specific.
+ */
+static u32 rrbar_phys=0xe0000000UL;
+/**
+ * RRBAR is always 256M
+ */
+static u32 rrbar_size=0x10000000UL;
+/**
+ * Virtual address for RRBAR
+ */
+static void* rrbar_virt=NULL;
+/**
+ * It used to be #define, but I am going to change it.
+ */
+extern int PCI_CFG_SPACE_SIZE;
+
+union pci_exp_data {
+    u32 l;
+    u16 w[2];
+    u8  b[4];
+} __attribute__((packed));
+
+/**
+ * Initializes PCI Express method for config space access.
+ * 
+ * There is no standard method to recognize presence of PCI Express,
+ * thus we will assume it is PCI-E, and rely on sanity check to
+ * deassert PCI-E presense. If PCI-E not present,
+ * there is no physical RAM on RRBAR address, and we should read
+ * something like 0xff.
+ * 
+ * Creates mapping for whole 256M area.
+ * 
+ * @return 1 if OK, 0 if error
+ */
+static int pci_express_init(void)
+{
+    /* TODO: check PCI-Ex presense */
+    rrbar_virt=ioremap(rrbar_phys,rrbar_size);
+    if (!rrbar_virt) return 0;
+    return 1;
+}
+
+/**
+ * Shuts down PCI-E resources.
+ */
+static void pci_express_fini(void)
+{
+    if (rrbar_virt) {
+        iounmap(rrbar_virt);
+    }
+}
+
+static int pci_exp_read (int seg, int bus, int dev, int fn, int reg, int len, u32 *value)
+{
+    union pci_exp_data d;
+    void* addr=rrbar_virt+(bus << 20)+(dev << 15)+(fn << 12)+(reg &~ 3);
+    d.l=readl(addr);
+    switch (len) {
+    case 1:
+        *value=d.b[reg & 3];
+        break;
+    case 2:
+        *value=d.w[(reg & 2)>>1];
+        break;
+    case 4:
+        *value=d.l;
+        break;
+    }
+	return 0;
+}
+
+static int pci_exp_write (int seg, int bus, int dev, int fn, int reg, int len, u32 value)
+{
+    void* addr=rrbar_virt+(bus << 20)+(dev << 15)+(fn << 12)+(reg &~ 3);
+	switch (len) {
+    case 1:
+    case 2:
+        {
+            unsigned long flags;
+            union pci_exp_data d;
+            spin_lock_irqsave(&pci_config_lock, flags);
+            switch (len) {
+            case 1:
+                d.l=readl(addr);
+                d.b[reg & 3]=value;
+                break;
+            case 2:
+                d.l=readl(addr);
+                d.w[(reg & 2)>>1]=value;
+                break;
+            }
+            writel(d.l,addr);
+            spin_unlock_irqrestore(&pci_config_lock, flags);
+        }
+        break;
+    case 4:
+        writel(value,addr);
+        break;
+    }
+	return 0;
+}
+
+static int pci_exp_read_config_byte(struct pci_dev *dev, int where, u8 *value)
+{
+	int result; 
+	u32 data;
+	result = pci_exp_read(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		PCI_FUNC(dev->devfn), where, 1, &data);
+	*value = (u8)data;
+	return result;
+}
+
+static int pci_exp_read_config_word(struct pci_dev *dev, int where, u16 *value)
+{
+	int result; 
+	u32 data;
+	result = pci_exp_read(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		PCI_FUNC(dev->devfn), where, 2, &data);
+	*value = (u16)data;
+	return result;
+}
+
+static int pci_exp_read_config_dword(struct pci_dev *dev, int where, u32 *value)
+{
+	return pci_exp_read(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		PCI_FUNC(dev->devfn), where, 4, value);
+}
+
+static int pci_exp_write_config_byte(struct pci_dev *dev, int where, u8 value)
+{
+	return pci_exp_write(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		PCI_FUNC(dev->devfn), where, 1, value);
+}
+
+static int pci_exp_write_config_word(struct pci_dev *dev, int where, u16 value)
+{
+	return pci_exp_write(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		PCI_FUNC(dev->devfn), where, 2, value);
+}
+
+static int pci_exp_write_config_dword(struct pci_dev *dev, int where, u32 value)
+{
+	return pci_exp_write(0, dev->bus->number, PCI_SLOT(dev->devfn), 
+		PCI_FUNC(dev->devfn), where, 4, value);
+}
+
+static struct pci_ops pci_express_conf = {
+	pci_exp_read_config_byte,
+	pci_exp_read_config_word,
+	pci_exp_read_config_dword,
+	pci_exp_write_config_byte,
+	pci_exp_write_config_word,
+	pci_exp_write_config_dword
+};
 
 /*
  * Before we decide to use direct hardware access mechanisms, we try to do some
@@ -465,6 +628,21 @@
 
 	__save_flags(flags); __cli();
 
+    /**
+     * Check if PCI-express access work
+     */
+    if (pci_express_init()) {
+        if (pci_sanity_check(&pci_express_conf)) {
+            PCI_CFG_SPACE_SIZE=4096;
+			__restore_flags(flags);
+			printk(KERN_INFO "PCI: Using configuration type PCI Express\n");
+			request_mem_region(rrbar_phys, rrbar_size, "PCI-Express config space");
+			return &pci_express_conf;
+        } else {
+            pci_express_fini();
+        }
+    }
+
 	/*
 	 * Check if configuration type 1 works.
 	 */
@@ -1398,16 +1576,18 @@
 #endif
 
 #ifdef CONFIG_PCI_DIRECT
-	if ((pci_probe & (PCI_PROBE_CONF1 | PCI_PROBE_CONF2)) 
+	if ((pci_probe & (PCI_PROBE_CONF1 | PCI_PROBE_CONF2 | PCI_PROBE_EXP)) 
 		&& (tmp = pci_check_direct())) {
 		pci_root_ops = tmp;
 		if (pci_root_ops == &pci_direct_conf1) {
 			pci_config_read = pci_conf1_read;
 			pci_config_write = pci_conf1_write;
-		}
-		else {
+		} else if (pci_root_ops == &pci_direct_conf2) {
 			pci_config_read = pci_conf2_read;
 			pci_config_write = pci_conf2_write;
+		} else if (pci_root_ops == &pci_express_conf) {
+			pci_config_read = pci_exp_read;
+			pci_config_write = pci_exp_write;
 		}
 	}
 #endif
@@ -1489,6 +1669,10 @@
 		pci_probe = PCI_PROBE_CONF2 | PCI_NO_CHECKS;
 		return NULL;
 	}
+	else if (!strcmp(str, "exp")) {
+		pci_probe = PCI_PROBE_EXP | PCI_NO_CHECKS;
+		return NULL;
+	}
 #endif
 	else if (!strcmp(str, "rom")) {
 		pci_probe |= PCI_ASSIGN_ROMS;
diff -bBdur linux-2.4.23/drivers/pci/proc.c linux-2.4.23-pciexp/drivers/pci/proc.c
--- linux-2.4.23/drivers/pci/proc.c	2002-11-29 01:53:14.000000000 +0200
+++ linux-2.4.23-pciexp/drivers/pci/proc.c	2003-12-14 14:18:58.000000000 +0200
@@ -16,7 +16,7 @@
 #include <asm/uaccess.h>
 #include <asm/byteorder.h>
 
-#define PCI_CFG_SPACE_SIZE 256
+int PCI_CFG_SPACE_SIZE=256;
 
 static loff_t
 proc_bus_pci_lseek(struct file *file, loff_t off, int whence)

^ permalink raw reply	[flat|nested] 80+ messages in thread

end of thread, other threads:[~2003-12-17 23:38 UTC | newest]

Thread overview: 80+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-14 20:00 PCI Express support for 2.4 kernel Vladimir Kondratiev
2003-12-14 20:46 ` Jeff Garzik
2003-12-15 10:01   ` Vladimir Kondratiev
2003-12-15 10:31     ` Gabriel Paubert
2003-12-15 12:44       ` Vladimir Kondratiev
2003-12-15 13:15         ` Arjan van de Ven
2003-12-15 13:58           ` Vladimir Kondratiev
2003-12-15 14:31             ` Arjan van de Ven
2003-12-15 14:44             ` Brian Gerst
2003-12-15 18:40             ` Greg KH
2003-12-15 19:23             ` Alan Cox
2003-12-15 20:00             ` Linus Torvalds
2003-12-16 10:20               ` Vladimir Kondratiev
2003-12-16 16:47                 ` Linus Torvalds
2003-12-17  6:30                   ` Vladimir Kondratiev
2003-12-17  6:46                     ` Linus Torvalds
2003-12-17  6:55                       ` Jeff Garzik
2003-12-17  7:24                         ` Vladimir Kondratiev
2003-12-17 16:17                           ` Linus Torvalds
2003-12-17  8:22                         ` Arjan van de Ven
2003-12-17 10:35                           ` Martin Mares
2003-12-17 23:06                           ` Alan Cox
2003-12-17 10:08                       ` Geert Uytterhoeven
2003-12-17 15:54                         ` Linus Torvalds
2003-12-17 16:14                           ` Geert Uytterhoeven
2003-12-17 17:44                           ` Dan Hopper
2003-12-17 18:14                             ` Vladimir Kondratiev
2003-12-17 21:44                         ` Martin Mares
2003-12-16 17:10                 ` Jeff Garzik
2003-12-16 17:48                   ` Arjan van de Ven
2003-12-16 17:55                     ` Jeff Garzik
2003-12-16 22:39                     ` Vladimir Kondratiev
2003-12-17  0:12                       ` Richard B. Johnson
2003-12-16 21:59                   ` Vladimir Kondratiev
2003-12-16 17:45                 ` Greg KH
2003-12-16 22:14                   ` Vladimir Kondratiev
2003-12-17 10:05                     ` Geert Uytterhoeven
2003-12-15 15:57       ` Vladimir Kondratiev
2003-12-15 10:42     ` Martin Mares
2003-12-15 10:07 ` Greg KH
2003-12-15 11:20   ` Vladimir Kondratiev
     [not found] <12InT-wQ-5@gated-at.bofh.it>
     [not found] ` <135Nw-5gv-3@gated-at.bofh.it>
     [not found]   ` <137wc-q1-23@gated-at.bofh.it>
2003-12-15 21:56     ` Andi Kleen
2003-12-15 22:48       ` Vladimir Kondratiev
2003-12-15 23:06         ` Andi Kleen
2003-12-15 23:14         ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2003-12-15 20:08 Nakajima, Jun
     [not found] <Pine.LNX.4.44.0312150917170.32061-100000@coffee.psychology.mcmaster.ca>
2003-12-15 15:52 ` Vladimir Kondratiev
2003-12-15 16:08   ` Kevin P. Fleming
2003-12-15 16:38     ` Vladimir Kondratiev
2003-12-15 16:55       ` Richard B. Johnson
2003-12-15 17:08         ` Tomas Szepe
2003-12-15 18:03           ` Richard B. Johnson
2003-12-15 18:15             ` Tomas Szepe
2003-12-15 18:35               ` Richard B. Johnson
2003-12-15 18:43                 ` Keith Owens
2003-12-15 18:45                 ` Tomas Szepe
2003-12-15 17:24         ` Vladimir Kondratiev
2003-12-15 17:22           ` Randy.Dunlap
2003-12-15 18:16           ` Greg KH
2003-12-15 18:20           ` Richard B. Johnson
2003-12-15 17:09   ` Keith Owens
2003-12-15 17:38     ` Tomas Szepe
2003-12-15 18:16       ` Keith Owens
2003-12-15 18:23         ` Tomas Szepe
     [not found] <12KJ6-4F2-13@gated-at.bofh.it>
     [not found] ` <12Lvu-5X5-5@gated-at.bofh.it>
     [not found]   ` <12XQ2-7Vs-9@gated-at.bofh.it>
2003-12-15 10:17     ` Andi Kleen
     [not found]     ` <12YsA-nt-1@gated-at.bofh.it>
     [not found]       ` <130kQ-3A0-13@gated-at.bofh.it>
     [not found]         ` <130Xy-4Ia-3@gated-at.bofh.it>
     [not found]           ` <131Ac-5Qy-3@gated-at.bofh.it>
     [not found]             ` <137cD-8eg-9@gated-at.bofh.it>
     [not found]               ` <13kD2-1kF-11@gated-at.bofh.it>
2003-12-16 17:44                 ` Andi Kleen
     [not found]                 ` <13r1S-3FB-11@gated-at.bofh.it>
     [not found]                   ` <13vyg-43O-7@gated-at.bofh.it>
2003-12-16 22:18                     ` Andi Kleen
     [not found]                 ` <13qIi-31G-1@gated-at.bofh.it>
     [not found]                   ` <13DvZ-2RY-9@gated-at.bofh.it>
     [not found]                     ` <13DFw-3a8-9@gated-at.bofh.it>
     [not found]                       ` <13DPq-3s4-7@gated-at.bofh.it>
     [not found]                         ` <13Fem-6iy-7@gated-at.bofh.it>
     [not found]                           ` <13SY1-35z-19@gated-at.bofh.it>
2003-12-17 23:22                             ` Andi Kleen
2003-12-17 23:38                               ` Alan Cox
     [not found] ` <12XQc-7Vs-29@gated-at.bofh.it>
     [not found]   ` <12Z5u-1tG-11@gated-at.bofh.it>
2003-12-15 14:58     ` Andi Kleen
2003-12-15 15:40       ` Vladimir Kondratiev
     [not found] <3FDCA569.5070006@pobox.com>
2003-12-15  4:47 ` Pete Zaitcev
2003-12-14 17:28 Vladimir Kondratiev
2003-12-15  7:48 ` Christoph Hellwig
2003-12-15 18:26 ` Linus Torvalds
2003-12-15 20:03   ` Jeff Garzik
2003-12-15 22:00     ` Linus Torvalds
2003-12-16  4:53       ` Jeff Garzik
2003-12-15 20:21   ` Vladimir Kondratiev
2003-12-15 20:36     ` Jeff Garzik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).