2006-08-09 19:04:29

by Eric Anholt

[permalink] [raw]
Subject: [PATCH] Add support for Intel i965G/Q GARTs.

From: Alan Hourihane <[email protected]>

Signed-off-by: Eric Anholt <[email protected]>


---

drivers/char/agp/intel-agp.c | 167 +++++++++++++++++++++++++++++++++++++++++-
1 files changed, 162 insertions(+), 5 deletions(-)

0bc75aab93ee69dcf547ca55a8afcd1464dbfc95
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index 61ac380..c51b365 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -8,8 +8,15 @@
*
* Intel(R) 915G/915GM support added by Alan Hourihane
* <[email protected]>.
+ *
+ * Intel(R) 945G/945GM support added by Alan Hourihane
+ * <[email protected]>.
+ *
+ * Intel(R) 946GZ/965Q/965G support added by Alan Hourihane
+ * <[email protected]>.
*/

+#include <linux/version.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/init.h>
@@ -17,6 +24,22 @@ #include <linux/pagemap.h>
#include <linux/agp_backend.h>
#include "agp.h"

+/* Should be moved to include/linux/pci_ids.h */
+#define PCI_DEVICE_ID_INTEL_82946GZ_HB 0x2970
+#define PCI_DEVICE_ID_INTEL_82946GZ_IG 0x2972
+#define PCI_DEVICE_ID_INTEL_82965G_1_HB 0x2980
+#define PCI_DEVICE_ID_INTEL_82965G_1_IG 0x2982
+#define PCI_DEVICE_ID_INTEL_82965Q_HB 0x2990
+#define PCI_DEVICE_ID_INTEL_82965Q_IG 0x2992
+#define PCI_DEVICE_ID_INTEL_82965G_HB 0x29A0
+#define PCI_DEVICE_ID_INTEL_82965G_IG 0x29A2
+
+#define IS_I965 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82946GZ_HB || \
+ agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_1_HB || \
+ agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965Q_HB || \
+ agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB)
+
+
/* Intel 815 register */
#define INTEL_815_APCONT 0x51
#define INTEL_815_ATTBASE_MASK ~0x1FFFFFFF
@@ -40,6 +63,8 @@ #define I915_PTEADDR 0x1C
#define I915_GMCH_GMS_STOLEN_48M (0x6 << 4)
#define I915_GMCH_GMS_STOLEN_64M (0x7 << 4)

+/* Intel 965G registers */
+#define I965_MSAC 0x62

/* Intel 7505 registers */
#define INTEL_I7505_APSIZE 0x74
@@ -354,6 +379,7 @@ static struct aper_size_info_fixed intel
/* The 64M mode still requires a 128k gatt */
{64, 16384, 5},
{256, 65536, 6},
+ {512, 131072, 7},
};

static struct _intel_i830_private {
@@ -377,7 +403,11 @@ static void intel_i830_init_gtt_entries(
/* We obtain the size of the GTT, which is also stored (for some
* reason) at the top of stolen memory. Then we add 4KB to that
* for the video BIOS popup, which is also stored in there. */
- size = agp_bridge->driver->fetch_size() + 4;
+
+ if (IS_I965)
+ size = 512 + 4;
+ else
+ size = agp_bridge->driver->fetch_size() + 4;

if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82830_HB ||
agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) {
@@ -423,7 +453,7 @@ static void intel_i830_init_gtt_entries(
if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB ||
agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB ||
agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB ||
- agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB)
+ agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || IS_I965 )
gtt_entries = MB(48) - KB(size);
else
gtt_entries = 0;
@@ -433,7 +463,7 @@ static void intel_i830_init_gtt_entries(
if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB ||
agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB ||
agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB ||
- agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB)
+ agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || IS_I965)
gtt_entries = MB(64) - KB(size);
else
gtt_entries = 0;
@@ -736,7 +766,7 @@ static int intel_i915_remove_entries(str
static int intel_i915_fetch_size(void)
{
struct aper_size_info_fixed *values;
- u32 temp, offset;
+ u32 temp, offset = 0;

#define I915_256MB_ADDRESS_MASK (1<<27)

@@ -791,6 +821,77 @@ static int intel_i915_create_gatt_table(

return 0;
}
+static int intel_i965_fetch_size(void)
+{
+ struct aper_size_info_fixed *values;
+ u32 offset = 0;
+ u8 temp;
+
+#define I965_512MB_ADDRESS_MASK (3<<1)
+
+ values = A_SIZE_FIX(agp_bridge->driver->aperture_sizes);
+
+ pci_read_config_byte(intel_i830_private.i830_dev, I965_MSAC, &temp);
+ temp &= I965_512MB_ADDRESS_MASK;
+ switch (temp) {
+ case 0x00:
+ offset = 0; /* 128MB */
+ break;
+ case 0x06:
+ offset = 3; /* 512MB */
+ break;
+ default:
+ case 0x02:
+ offset = 2; /* 256MB */
+ break;
+ }
+
+ agp_bridge->previous_size = agp_bridge->current_size = (void *)(values + offset);
+
+ return values[offset].size;
+}
+
+/* The intel i965 automatically initializes the agp aperture during POST.
++ * Use the memory already set aside for in the GTT.
++ */
+static int intel_i965_create_gatt_table(struct agp_bridge_data *bridge)
+{
+ int page_order;
+ struct aper_size_info_fixed *size;
+ int num_entries;
+ u32 temp;
+
+ size = agp_bridge->current_size;
+ page_order = size->page_order;
+ num_entries = size->num_entries;
+ agp_bridge->gatt_table_real = NULL;
+
+ pci_read_config_dword(intel_i830_private.i830_dev, I915_MMADDR, &temp);
+
+ temp &= 0xfff00000;
+ intel_i830_private.gtt = ioremap((temp + (512 * 1024)) , 512 * 1024);
+
+ if (!intel_i830_private.gtt)
+ return -ENOMEM;
+
+
+ intel_i830_private.registers = ioremap(temp,128 * 4096);
+ if (!intel_i830_private.registers)
+ return -ENOMEM;
+
+ temp = readl(intel_i830_private.registers+I810_PGETBL_CTL) & 0xfffff000;
+ global_cache_flush(); /* FIXME: ? */
+
+ /* we have to call this as early as possible after the MMIO base address is known */
+ intel_i830_init_gtt_entries();
+
+ agp_bridge->gatt_table = NULL;
+
+ agp_bridge->gatt_bus_addr = temp;
+
+ return 0;
+}
+

static int intel_fetch_size(void)
{
@@ -1469,7 +1570,7 @@ static struct agp_bridge_driver intel_91
.owner = THIS_MODULE,
.aperture_sizes = intel_i830_sizes,
.size_type = FIXED_APER_SIZE,
- .num_aperture_sizes = 3,
+ .num_aperture_sizes = 4,
.needs_scratch_page = TRUE,
.configure = intel_i915_configure,
.fetch_size = intel_i915_fetch_size,
@@ -1489,6 +1590,29 @@ static struct agp_bridge_driver intel_91
.agp_destroy_page = agp_generic_destroy_page,
};

+static struct agp_bridge_driver intel_i965_driver = {
+ .owner = THIS_MODULE,
+ .aperture_sizes = intel_i830_sizes,
+ .size_type = FIXED_APER_SIZE,
+ .num_aperture_sizes = 4,
+ .needs_scratch_page = TRUE,
+ .configure = intel_i915_configure,
+ .fetch_size = intel_i965_fetch_size,
+ .cleanup = intel_i915_cleanup,
+ .tlb_flush = intel_i810_tlbflush,
+ .mask_memory = intel_i810_mask_memory,
+ .masks = intel_i810_masks,
+ .agp_enable = intel_i810_agp_enable,
+ .cache_flush = global_cache_flush,
+ .create_gatt_table = intel_i965_create_gatt_table,
+ .free_gatt_table = intel_i830_free_gatt_table,
+ .insert_memory = intel_i915_insert_entries,
+ .remove_memory = intel_i915_remove_entries,
+ .alloc_by_type = intel_i830_alloc_by_type,
+ .free_by_type = intel_i810_free_by_type,
+ .agp_alloc_page = agp_generic_alloc_page,
+ .agp_destroy_page = agp_generic_destroy_page,
+};

static struct agp_bridge_driver intel_7505_driver = {
.owner = THIS_MODULE,
@@ -1684,6 +1808,35 @@ static int __devinit agp_intel_probe(str
bridge->driver = &intel_845_driver;
name = "945GM";
break;
+ case PCI_DEVICE_ID_INTEL_82946GZ_HB:
+ if (find_i830(PCI_DEVICE_ID_INTEL_82946GZ_IG))
+ bridge->driver = &intel_i965_driver;
+ else
+ bridge->driver = &intel_845_driver;
+ name = "946GZ";
+ break;
+ case PCI_DEVICE_ID_INTEL_82965G_1_HB:
+ if (find_i830(PCI_DEVICE_ID_INTEL_82965G_1_IG))
+ bridge->driver = &intel_i965_driver;
+ else
+ bridge->driver = &intel_845_driver;
+ name = "965G";
+ break;
+ case PCI_DEVICE_ID_INTEL_82965Q_HB:
+ if (find_i830(PCI_DEVICE_ID_INTEL_82965Q_IG))
+ bridge->driver = &intel_i965_driver;
+ else
+ bridge->driver = &intel_845_driver;
+ name = "965Q";
+ break;
+ case PCI_DEVICE_ID_INTEL_82965G_HB:
+ if (find_i830(PCI_DEVICE_ID_INTEL_82965G_IG))
+ bridge->driver = &intel_i965_driver;
+ else
+ bridge->driver = &intel_845_driver;
+ name = "965G";
+ break;
+
case PCI_DEVICE_ID_INTEL_7505_0:
bridge->driver = &intel_7505_driver;
name = "E7505";
@@ -1825,6 +1978,10 @@ #define ID(x) \
ID(PCI_DEVICE_ID_INTEL_82915GM_HB),
ID(PCI_DEVICE_ID_INTEL_82945G_HB),
ID(PCI_DEVICE_ID_INTEL_82945GM_HB),
+ ID(PCI_DEVICE_ID_INTEL_82946GZ_HB),
+ ID(PCI_DEVICE_ID_INTEL_82965G_1_HB),
+ ID(PCI_DEVICE_ID_INTEL_82965Q_HB),
+ ID(PCI_DEVICE_ID_INTEL_82965G_HB),
{ }
};

--
1.3.0.g34962


2006-08-09 19:21:47

by Dave Jones

[permalink] [raw]
Subject: Re: [PATCH] Add support for Intel i965G/Q GARTs.

On Wed, Aug 09, 2006 at 12:04:27PM -0700, Eric Anholt wrote:

> 0bc75aab93ee69dcf547ca55a8afcd1464dbfc95
> diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
> index 61ac380..c51b365 100644
> --- a/drivers/char/agp/intel-agp.c
> +++ b/drivers/char/agp/intel-agp.c
> @@ -8,8 +8,15 @@
> *
> * Intel(R) 915G/915GM support added by Alan Hourihane
> * <[email protected]>.
> + *
> + * Intel(R) 945G/945GM support added by Alan Hourihane
> + * <[email protected]>.
> + *
> + * Intel(R) 946GZ/965Q/965G support added by Alan Hourihane
> + * <[email protected]>.
> */

I think we should just strip out this whole credit section.
The attributions are stored in the SCM anyway, and this just
seems to grow and grow.

> +#include <linux/version.h>

Unnecessary.

> +/* Should be moved to include/linux/pci_ids.h */
> +#define PCI_DEVICE_ID_INTEL_82946GZ_HB 0x2970
> +#define PCI_DEVICE_ID_INTEL_82946GZ_IG 0x2972
> +#define PCI_DEVICE_ID_INTEL_82965G_1_HB 0x2980
> +#define PCI_DEVICE_ID_INTEL_82965G_1_IG 0x2982
> +#define PCI_DEVICE_ID_INTEL_82965Q_HB 0x2990
> +#define PCI_DEVICE_ID_INTEL_82965Q_IG 0x2992
> +#define PCI_DEVICE_ID_INTEL_82965G_HB 0x29A0
> +#define PCI_DEVICE_ID_INTEL_82965G_IG 0x29A2

Actually if this is the only place they're used, this is the right
place for them. Stuff should only go into linux/pci_ids.h if
theres another driver that uses the same ID.

> +#define IS_I965 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82946GZ_HB || \
> + agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_1_HB || \
> + agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965Q_HB || \
> + agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB)
> +

How about just doing this once during module init, and setting a global
'is_i965' variable ?

> @@ -354,6 +379,7 @@ static struct aper_size_info_fixed intel
> /* The 64M mode still requires a 128k gatt */
> {64, 16384, 5},
> {256, 65536, 6},
> + {512, 131072, 7},
> };

Broken indentation

> static struct _intel_i830_private {
> @@ -377,7 +403,11 @@ static void intel_i830_init_gtt_entries(
> /* We obtain the size of the GTT, which is also stored (for some
> * reason) at the top of stolen memory. Then we add 4KB to that
> * for the video BIOS popup, which is also stored in there. */
> - size = agp_bridge->driver->fetch_size() + 4;
> +
> + if (IS_I965)
> + size = 512 + 4;
> + else
> + size = agp_bridge->driver->fetch_size() + 4;

ditto. (Use tabs, not spaces).

> @@ -736,7 +766,7 @@ static int intel_i915_remove_entries(str
> static int intel_i915_fetch_size(void)
> {
> struct aper_size_info_fixed *values;
> - u32 temp, offset;
> + u32 temp, offset = 0;
>
> #define I915_256MB_ADDRESS_MASK (1<<27)

Unnecessary. We never read this before we write to it.

> +/* The intel i965 automatically initializes the agp aperture during POST.
> ++ * Use the memory already set aside for in the GTT.
> ++ */
> +static int intel_i965_create_gatt_table(struct agp_bridge_data *bridge)
> +{
> + int page_order;
> + struct aper_size_info_fixed *size;
> + int num_entries;
> + u32 temp;
> +
> + size = agp_bridge->current_size;
> + page_order = size->page_order;
> + num_entries = size->num_entries;
> + agp_bridge->gatt_table_real = NULL;
> +
> + pci_read_config_dword(intel_i830_private.i830_dev, I915_MMADDR, &temp);
> +
> + temp &= 0xfff00000;
> + intel_i830_private.gtt = ioremap((temp + (512 * 1024)) , 512 * 1024);
> +
> + if (!intel_i830_private.gtt)
> + return -ENOMEM;
> +
> +
> + intel_i830_private.registers = ioremap(temp,128 * 4096);
> + if (!intel_i830_private.registers)
> + return -ENOMEM;
> +
> + temp = readl(intel_i830_private.registers+I810_PGETBL_CTL) & 0xfffff000;
> + global_cache_flush(); /* FIXME: ? */

After we spent quite a while cleaning up all the uses of this a few months back,
it'd be a shame to add more fixme's related to this.

> static int intel_fetch_size(void)
> {
> @@ -1469,7 +1570,7 @@ static struct agp_bridge_driver intel_91
> .owner = THIS_MODULE,
> .aperture_sizes = intel_i830_sizes,
> .size_type = FIXED_APER_SIZE,
> - .num_aperture_sizes = 3,
> + .num_aperture_sizes = 4,
> .needs_scratch_page = TRUE,
> .configure = intel_i915_configure,
> .fetch_size = intel_i915_fetch_size,

This is ok with all the other chipsets that use intel_915_driver ?

> @@ -1684,6 +1808,35 @@ static int __devinit agp_intel_probe(str
> bridge->driver = &intel_845_driver;
> name = "945GM";
> break;
> + case PCI_DEVICE_ID_INTEL_82946GZ_HB:
> + if (find_i830(PCI_DEVICE_ID_INTEL_82946GZ_IG))
> + bridge->driver = &intel_i965_driver;
> + else
> + bridge->driver = &intel_845_driver;
> + name = "946GZ";
> + break;
> + case PCI_DEVICE_ID_INTEL_82965G_1_HB:
> + if (find_i830(PCI_DEVICE_ID_INTEL_82965G_1_IG))
> + bridge->driver = &intel_i965_driver;
> + else
> + bridge->driver = &intel_845_driver;
> + name = "965G";
> + break;
> + case PCI_DEVICE_ID_INTEL_82965Q_HB:
> + if (find_i830(PCI_DEVICE_ID_INTEL_82965Q_IG))
> + bridge->driver = &intel_i965_driver;
> + else
> + bridge->driver = &intel_845_driver;
> + name = "965Q";
> + break;
> + case PCI_DEVICE_ID_INTEL_82965G_HB:
> + if (find_i830(PCI_DEVICE_ID_INTEL_82965G_IG))
> + bridge->driver = &intel_i965_driver;
> + else
> + bridge->driver = &intel_845_driver;
> + name = "965G";
> + break;

This switch just keeps getting more and more horrific.
It'd be nice to have this converted to be somehow table-driven
at some point.

> @@ -1825,6 +1978,10 @@ #define ID(x) \
> ID(PCI_DEVICE_ID_INTEL_82915GM_HB),
> ID(PCI_DEVICE_ID_INTEL_82945G_HB),
> ID(PCI_DEVICE_ID_INTEL_82945GM_HB),
> + ID(PCI_DEVICE_ID_INTEL_82946GZ_HB),
> + ID(PCI_DEVICE_ID_INTEL_82965G_1_HB),
> + ID(PCI_DEVICE_ID_INTEL_82965Q_HB),
> + ID(PCI_DEVICE_ID_INTEL_82965G_HB),
> { }

Indendation again.

Dave

--
http://www.codemonkey.org.uk

2006-08-10 21:43:35

by Lukas Hejtmanek

[permalink] [raw]
Subject: Re: [PATCH] Add support for Intel i965G/Q GARTs.

Hello,

tried patch on P965 chipset containing 8086:29a0 memory controller.
I got in dmesg:
agpgart: Detected an Intel 965G Chipset.
agpgart: AGP aperture is 256M @ 0x0

is this supposed to be correct?

This warning can be related (0000:01:00.0 is Nvidia NX7600GS graphic).
PCI: Failed to allocate mem resource #6:20000@30000000 for 0000:01:00.0

--
Luk?? Hejtm?nek

2006-09-05 17:42:44

by Eric Anholt

[permalink] [raw]
Subject: Resubmit: Intel 965 Express AGP patches

The following should be the updated patch series for the Intel 965 Express
support, unless I'm making some mistake with git-send-email. I think I've
covered Dave's concerns, except for making the PCI ID stuff table-driven. You
can find a patch for that on the intel-agp-i965 branch at
git://anongit.freedesktop.org/~anholt/linux-2.6

2006-09-05 17:43:13

by Eric Anholt

[permalink] [raw]
Subject: [PATCH] Add support for Intel i965G/Q GARTs.

From: Alan Hourihane <[email protected]>

diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index 61ac380..c51b365 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -8,8 +8,15 @@
*
* Intel(R) 915G/915GM support added by Alan Hourihane
* <[email protected]>.
+ *
+ * Intel(R) 945G/945GM support added by Alan Hourihane
+ * <[email protected]>.
+ *
+ * Intel(R) 946GZ/965Q/965G support added by Alan Hourihane
+ * <[email protected]>.
*/

+#include <linux/version.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/init.h>
@@ -17,6 +24,22 @@ #include <linux/pagemap.h>
#include <linux/agp_backend.h>
#include "agp.h"

+/* Should be moved to include/linux/pci_ids.h */
+#define PCI_DEVICE_ID_INTEL_82946GZ_HB 0x2970
+#define PCI_DEVICE_ID_INTEL_82946GZ_IG 0x2972
+#define PCI_DEVICE_ID_INTEL_82965G_1_HB 0x2980
+#define PCI_DEVICE_ID_INTEL_82965G_1_IG 0x2982
+#define PCI_DEVICE_ID_INTEL_82965Q_HB 0x2990
+#define PCI_DEVICE_ID_INTEL_82965Q_IG 0x2992
+#define PCI_DEVICE_ID_INTEL_82965G_HB 0x29A0
+#define PCI_DEVICE_ID_INTEL_82965G_IG 0x29A2
+
+#define IS_I965 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82946GZ_HB || \
+ agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_1_HB || \
+ agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965Q_HB || \
+ agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB)
+
+
/* Intel 815 register */
#define INTEL_815_APCONT 0x51
#define INTEL_815_ATTBASE_MASK ~0x1FFFFFFF
@@ -40,6 +63,8 @@ #define I915_PTEADDR 0x1C
#define I915_GMCH_GMS_STOLEN_48M (0x6 << 4)
#define I915_GMCH_GMS_STOLEN_64M (0x7 << 4)

+/* Intel 965G registers */
+#define I965_MSAC 0x62

/* Intel 7505 registers */
#define INTEL_I7505_APSIZE 0x74
@@ -354,6 +379,7 @@ static struct aper_size_info_fixed intel
/* The 64M mode still requires a 128k gatt */
{64, 16384, 5},
{256, 65536, 6},
+ {512, 131072, 7},
};

static struct _intel_i830_private {
@@ -377,7 +403,11 @@ static void intel_i830_init_gtt_entries(
/* We obtain the size of the GTT, which is also stored (for some
* reason) at the top of stolen memory. Then we add 4KB to that
* for the video BIOS popup, which is also stored in there. */
- size = agp_bridge->driver->fetch_size() + 4;
+
+ if (IS_I965)
+ size = 512 + 4;
+ else
+ size = agp_bridge->driver->fetch_size() + 4;

if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82830_HB ||
agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) {
@@ -423,7 +453,7 @@ static void intel_i830_init_gtt_entries(
if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB ||
agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB ||
agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB ||
- agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB)
+ agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || IS_I965 )
gtt_entries = MB(48) - KB(size);
else
gtt_entries = 0;
@@ -433,7 +463,7 @@ static void intel_i830_init_gtt_entries(
if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB ||
agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB ||
agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB ||
- agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB)
+ agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || IS_I965)
gtt_entries = MB(64) - KB(size);
else
gtt_entries = 0;
@@ -736,7 +766,7 @@ static int intel_i915_remove_entries(str
static int intel_i915_fetch_size(void)
{
struct aper_size_info_fixed *values;
- u32 temp, offset;
+ u32 temp, offset = 0;

#define I915_256MB_ADDRESS_MASK (1<<27)

@@ -791,6 +821,77 @@ static int intel_i915_create_gatt_table(

return 0;
}
+static int intel_i965_fetch_size(void)
+{
+ struct aper_size_info_fixed *values;
+ u32 offset = 0;
+ u8 temp;
+
+#define I965_512MB_ADDRESS_MASK (3<<1)
+
+ values = A_SIZE_FIX(agp_bridge->driver->aperture_sizes);
+
+ pci_read_config_byte(intel_i830_private.i830_dev, I965_MSAC, &temp);
+ temp &= I965_512MB_ADDRESS_MASK;
+ switch (temp) {
+ case 0x00:
+ offset = 0; /* 128MB */
+ break;
+ case 0x06:
+ offset = 3; /* 512MB */
+ break;
+ default:
+ case 0x02:
+ offset = 2; /* 256MB */
+ break;
+ }
+
+ agp_bridge->previous_size = agp_bridge->current_size = (void *)(values + offset);
+
+ return values[offset].size;
+}
+
+/* The intel i965 automatically initializes the agp aperture during POST.
++ * Use the memory already set aside for in the GTT.
++ */
+static int intel_i965_create_gatt_table(struct agp_bridge_data *bridge)
+{
+ int page_order;
+ struct aper_size_info_fixed *size;
+ int num_entries;
+ u32 temp;
+
+ size = agp_bridge->current_size;
+ page_order = size->page_order;
+ num_entries = size->num_entries;
+ agp_bridge->gatt_table_real = NULL;
+
+ pci_read_config_dword(intel_i830_private.i830_dev, I915_MMADDR, &temp);
+
+ temp &= 0xfff00000;
+ intel_i830_private.gtt = ioremap((temp + (512 * 1024)) , 512 * 1024);
+
+ if (!intel_i830_private.gtt)
+ return -ENOMEM;
+
+
+ intel_i830_private.registers = ioremap(temp,128 * 4096);
+ if (!intel_i830_private.registers)
+ return -ENOMEM;
+
+ temp = readl(intel_i830_private.registers+I810_PGETBL_CTL) & 0xfffff000;
+ global_cache_flush(); /* FIXME: ? */
+
+ /* we have to call this as early as possible after the MMIO base address is known */
+ intel_i830_init_gtt_entries();
+
+ agp_bridge->gatt_table = NULL;
+
+ agp_bridge->gatt_bus_addr = temp;
+
+ return 0;
+}
+

static int intel_fetch_size(void)
{
@@ -1469,7 +1570,7 @@ static struct agp_bridge_driver intel_91
.owner = THIS_MODULE,
.aperture_sizes = intel_i830_sizes,
.size_type = FIXED_APER_SIZE,
- .num_aperture_sizes = 3,
+ .num_aperture_sizes = 4,
.needs_scratch_page = TRUE,
.configure = intel_i915_configure,
.fetch_size = intel_i915_fetch_size,
@@ -1489,6 +1590,29 @@ static struct agp_bridge_driver intel_91
.agp_destroy_page = agp_generic_destroy_page,
};

+static struct agp_bridge_driver intel_i965_driver = {
+ .owner = THIS_MODULE,
+ .aperture_sizes = intel_i830_sizes,
+ .size_type = FIXED_APER_SIZE,
+ .num_aperture_sizes = 4,
+ .needs_scratch_page = TRUE,
+ .configure = intel_i915_configure,
+ .fetch_size = intel_i965_fetch_size,
+ .cleanup = intel_i915_cleanup,
+ .tlb_flush = intel_i810_tlbflush,
+ .mask_memory = intel_i810_mask_memory,
+ .masks = intel_i810_masks,
+ .agp_enable = intel_i810_agp_enable,
+ .cache_flush = global_cache_flush,
+ .create_gatt_table = intel_i965_create_gatt_table,
+ .free_gatt_table = intel_i830_free_gatt_table,
+ .insert_memory = intel_i915_insert_entries,
+ .remove_memory = intel_i915_remove_entries,
+ .alloc_by_type = intel_i830_alloc_by_type,
+ .free_by_type = intel_i810_free_by_type,
+ .agp_alloc_page = agp_generic_alloc_page,
+ .agp_destroy_page = agp_generic_destroy_page,
+};

static struct agp_bridge_driver intel_7505_driver = {
.owner = THIS_MODULE,
@@ -1684,6 +1808,35 @@ static int __devinit agp_intel_probe(str
bridge->driver = &intel_845_driver;
name = "945GM";
break;
+ case PCI_DEVICE_ID_INTEL_82946GZ_HB:
+ if (find_i830(PCI_DEVICE_ID_INTEL_82946GZ_IG))
+ bridge->driver = &intel_i965_driver;
+ else
+ bridge->driver = &intel_845_driver;
+ name = "946GZ";
+ break;
+ case PCI_DEVICE_ID_INTEL_82965G_1_HB:
+ if (find_i830(PCI_DEVICE_ID_INTEL_82965G_1_IG))
+ bridge->driver = &intel_i965_driver;
+ else
+ bridge->driver = &intel_845_driver;
+ name = "965G";
+ break;
+ case PCI_DEVICE_ID_INTEL_82965Q_HB:
+ if (find_i830(PCI_DEVICE_ID_INTEL_82965Q_IG))
+ bridge->driver = &intel_i965_driver;
+ else
+ bridge->driver = &intel_845_driver;
+ name = "965Q";
+ break;
+ case PCI_DEVICE_ID_INTEL_82965G_HB:
+ if (find_i830(PCI_DEVICE_ID_INTEL_82965G_IG))
+ bridge->driver = &intel_i965_driver;
+ else
+ bridge->driver = &intel_845_driver;
+ name = "965G";
+ break;
+
case PCI_DEVICE_ID_INTEL_7505_0:
bridge->driver = &intel_7505_driver;
name = "E7505";
@@ -1825,6 +1978,10 @@ #define ID(x) \
ID(PCI_DEVICE_ID_INTEL_82915GM_HB),
ID(PCI_DEVICE_ID_INTEL_82945G_HB),
ID(PCI_DEVICE_ID_INTEL_82945GM_HB),
+ ID(PCI_DEVICE_ID_INTEL_82946GZ_HB),
+ ID(PCI_DEVICE_ID_INTEL_82965G_1_HB),
+ ID(PCI_DEVICE_ID_INTEL_82965Q_HB),
+ ID(PCI_DEVICE_ID_INTEL_82965G_HB),
{ }
};

--
1.4.1

2006-09-05 17:43:31

by Eric Anholt

[permalink] [raw]
Subject: [PATCH] Remove attribution section, which is unnecessary with revision control.

diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index e643445..4ad5a03 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -2,20 +2,6 @@
* Intel AGPGART routines.
*/

-/*
- * Intel(R) 855GM/852GM and 865G support added by David Dawes
- * <[email protected]>.
- *
- * Intel(R) 915G/915GM support added by Alan Hourihane
- * <[email protected]>.
- *
- * Intel(R) 945G/945GM support added by Alan Hourihane
- * <[email protected]>.
- *
- * Intel(R) 946GZ/965Q/965G support added by Alan Hourihane
- * <[email protected]>.
- */
-
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/init.h>
--
1.4.1

2006-09-05 18:27:49

by Eric Anholt

[permalink] [raw]
Subject: [PATCH] Whitespace cleanup, remove an unnecessary comment, and remove an unnecessary include.

diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index c51b365..e643445 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -16,7 +16,6 @@
* <[email protected]>.
*/

-#include <linux/version.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/init.h>
@@ -24,7 +23,6 @@ #include <linux/pagemap.h>
#include <linux/agp_backend.h>
#include "agp.h"

-/* Should be moved to include/linux/pci_ids.h */
#define PCI_DEVICE_ID_INTEL_82946GZ_HB 0x2970
#define PCI_DEVICE_ID_INTEL_82946GZ_IG 0x2972
#define PCI_DEVICE_ID_INTEL_82965G_1_HB 0x2980
@@ -379,7 +377,7 @@ static struct aper_size_info_fixed intel
/* The 64M mode still requires a 128k gatt */
{64, 16384, 5},
{256, 65536, 6},
- {512, 131072, 7},
+ {512, 131072, 7},
};

static struct _intel_i830_private {
@@ -404,10 +402,10 @@ static void intel_i830_init_gtt_entries(
* reason) at the top of stolen memory. Then we add 4KB to that
* for the video BIOS popup, which is also stored in there. */

- if (IS_I965)
- size = 512 + 4;
- else
- size = agp_bridge->driver->fetch_size() + 4;
+ if (IS_I965)
+ size = 512 + 4;
+ else
+ size = agp_bridge->driver->fetch_size() + 4;

if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82830_HB ||
agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) {
@@ -766,7 +764,7 @@ static int intel_i915_remove_entries(str
static int intel_i915_fetch_size(void)
{
struct aper_size_info_fixed *values;
- u32 temp, offset = 0;
+ u32 temp, offset;

#define I915_256MB_ADDRESS_MASK (1<<27)

@@ -1808,34 +1806,34 @@ static int __devinit agp_intel_probe(str
bridge->driver = &intel_845_driver;
name = "945GM";
break;
- case PCI_DEVICE_ID_INTEL_82946GZ_HB:
- if (find_i830(PCI_DEVICE_ID_INTEL_82946GZ_IG))
- bridge->driver = &intel_i965_driver;
- else
- bridge->driver = &intel_845_driver;
- name = "946GZ";
- break;
- case PCI_DEVICE_ID_INTEL_82965G_1_HB:
- if (find_i830(PCI_DEVICE_ID_INTEL_82965G_1_IG))
- bridge->driver = &intel_i965_driver;
- else
- bridge->driver = &intel_845_driver;
- name = "965G";
- break;
- case PCI_DEVICE_ID_INTEL_82965Q_HB:
- if (find_i830(PCI_DEVICE_ID_INTEL_82965Q_IG))
- bridge->driver = &intel_i965_driver;
- else
- bridge->driver = &intel_845_driver;
- name = "965Q";
- break;
- case PCI_DEVICE_ID_INTEL_82965G_HB:
- if (find_i830(PCI_DEVICE_ID_INTEL_82965G_IG))
- bridge->driver = &intel_i965_driver;
- else
- bridge->driver = &intel_845_driver;
- name = "965G";
- break;
+ case PCI_DEVICE_ID_INTEL_82946GZ_HB:
+ if (find_i830(PCI_DEVICE_ID_INTEL_82946GZ_IG))
+ bridge->driver = &intel_i965_driver;
+ else
+ bridge->driver = &intel_845_driver;
+ name = "946GZ";
+ break;
+ case PCI_DEVICE_ID_INTEL_82965G_1_HB:
+ if (find_i830(PCI_DEVICE_ID_INTEL_82965G_1_IG))
+ bridge->driver = &intel_i965_driver;
+ else
+ bridge->driver = &intel_845_driver;
+ name = "965G";
+ break;
+ case PCI_DEVICE_ID_INTEL_82965Q_HB:
+ if (find_i830(PCI_DEVICE_ID_INTEL_82965Q_IG))
+ bridge->driver = &intel_i965_driver;
+ else
+ bridge->driver = &intel_845_driver;
+ name = "965Q";
+ break;
+ case PCI_DEVICE_ID_INTEL_82965G_HB:
+ if (find_i830(PCI_DEVICE_ID_INTEL_82965G_IG))
+ bridge->driver = &intel_i965_driver;
+ else
+ bridge->driver = &intel_845_driver;
+ name = "965G";
+ break;

case PCI_DEVICE_ID_INTEL_7505_0:
bridge->driver = &intel_7505_driver;
@@ -1978,10 +1976,10 @@ #define ID(x) \
ID(PCI_DEVICE_ID_INTEL_82915GM_HB),
ID(PCI_DEVICE_ID_INTEL_82945G_HB),
ID(PCI_DEVICE_ID_INTEL_82945GM_HB),
- ID(PCI_DEVICE_ID_INTEL_82946GZ_HB),
- ID(PCI_DEVICE_ID_INTEL_82965G_1_HB),
- ID(PCI_DEVICE_ID_INTEL_82965Q_HB),
- ID(PCI_DEVICE_ID_INTEL_82965G_HB),
+ ID(PCI_DEVICE_ID_INTEL_82946GZ_HB),
+ ID(PCI_DEVICE_ID_INTEL_82965G_1_HB),
+ ID(PCI_DEVICE_ID_INTEL_82965Q_HB),
+ ID(PCI_DEVICE_ID_INTEL_82965G_HB),
{ }
};

--
1.4.1

2006-09-06 15:55:09

by Dave Jones

[permalink] [raw]
Subject: Re: Resubmit: Intel 965 Express AGP patches

On Tue, Sep 05, 2006 at 10:37:32AM -0700, Eric Anholt wrote:
> The following should be the updated patch series for the Intel 965 Express
> support, unless I'm making some mistake with git-send-email. I think I've
> covered Dave's concerns

This chunk seems unrelated to 965 support.

@@ -1469,7 +1570,7 @@ static struct agp_bridge_driver intel_91
.owner = THIS_MODULE,
.aperture_sizes = intel_i830_sizes,
.size_type = FIXED_APER_SIZE,
- .num_aperture_sizes = 3,
+ .num_aperture_sizes = 4,
.needs_scratch_page = TRUE,
.configure = intel_i915_configure,
.fetch_size = intel_i915_fetch_size,

It seems to be a valid fix (as there are indeed 4 entries in
intel_i830_sizes), but I wonder if this was intentional ?
Has this been tested on 915/945?
I've chopped this bit out and committed the rest, we can
add this as a separate commit, which may ease future bisecting
if anything should go awry.
The intel_830_driver struct also lists the num of sizes as '3' btw.
It could just be lots of cut-n-paste braindamage, but things like
this make me nervous in a driver that supports so much hardware
and is so.. twisted.

Also, do we need an entry in agp_intel_resume() for the 965 ?

>, except for making the PCI ID stuff table-driven.
> You can find a patch for that on the intel-agp-i965 branch at
> git://anongit.freedesktop.org/~anholt/linux-2.6

I'll take a look at those soon.

Dave

2006-09-06 17:00:53

by Eric Anholt

[permalink] [raw]
Subject: Re: Resubmit: Intel 965 Express AGP patches

On Wed, 2006-09-06 at 12:02 -0400, Dave Jones wrote:
> On Tue, Sep 05, 2006 at 10:37:32AM -0700, Eric Anholt wrote:
> > The following should be the updated patch series for the Intel 965 Express
> > support, unless I'm making some mistake with git-send-email. I think I've
> > covered Dave's concerns
>
> This chunk seems unrelated to 965 support.
>
> @@ -1469,7 +1570,7 @@ static struct agp_bridge_driver intel_91
> .owner = THIS_MODULE,
> .aperture_sizes = intel_i830_sizes,
> .size_type = FIXED_APER_SIZE,
> - .num_aperture_sizes = 3,
> + .num_aperture_sizes = 4,
> .needs_scratch_page = TRUE,
> .configure = intel_i915_configure,
> .fetch_size = intel_i915_fetch_size,
>
> It seems to be a valid fix (as there are indeed 4 entries in
> intel_i830_sizes), but I wonder if this was intentional ?
> Has this been tested on 915/945?
> I've chopped this bit out and committed the rest, we can
> add this as a separate commit, which may ease future bisecting
> if anything should go awry.
> The intel_830_driver struct also lists the num of sizes as '3' btw.
> It could just be lots of cut-n-paste braindamage, but things like
> this make me nervous in a driver that supports so much hardware
> and is so.. twisted.

It just looks to me like when the 512MB entry was added for the 965, the
count was bumped for 915 too. It wouldn't have mattered for the 915 (or
i830, if it had got the treatment), since it'll never have a 512MB
aperture anyway, and doesn't use the generic gatt creation.

> Also, do we need an entry in agp_intel_resume() for the 965 ?

Yeah, looks like it.

> >, except for making the PCI ID stuff table-driven.
> > You can find a patch for that on the intel-agp-i965 branch at
> > git://anongit.freedesktop.org/~anholt/linux-2.6
>
> I'll take a look at those soon.

Thanks!

--
Eric Anholt [email protected]
[email protected] [email protected]


Attachments:
signature.asc (187.00 B)
This is a digitally signed message part

2006-09-06 17:15:56

by Dave Jones

[permalink] [raw]
Subject: Re: Resubmit: Intel 965 Express AGP patches

On Wed, Sep 06, 2006 at 09:56:25AM -0700, Eric Anholt wrote:
> > Also, do we need an entry in agp_intel_resume() for the 965 ?
> Yeah, looks like it.

Ok, I added this ..


diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index 42c7d8d..d1ede7d 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -1924,6 +1924,8 @@ static int agp_intel_resume(struct pci_d
intel_i830_configure();
else if (bridge->driver == &intel_810_driver)
intel_i810_configure();
+ else if (bridge->driver == &intel_i965_driver)
+ intel_i915_configure();

return 0;
}


This bit could probably be cleaned up a lot by having a .suspend method
in the bridge struct too, but thats for another day.

Dave

2006-11-06 17:55:22

by Dave Jones

[permalink] [raw]
Subject: Re: Resubmit: Intel 965 Express AGP patches

On Tue, Sep 05, 2006 at 10:37:32AM -0700, Eric Anholt wrote:
> The following should be the updated patch series for the Intel 965 Express
> support, unless I'm making some mistake with git-send-email. I think I've
> covered Dave's concerns, except for making the PCI ID stuff table-driven. You
> can find a patch for that on the intel-agp-i965 branch at
> git://anongit.freedesktop.org/~anholt/linux-2.6

Hmm, now that this is merged, crawlies are coming out of the woodwork..
http://bugzilla.kernel.org/show_bug.cgi?id=7464

Dave

--
http://www.codemonkey.org.uk