ChangeSet 1.1159.256.67, 2005/03/22 11:35:53+00:00, kaf24@xxxxxxxxxxxxxxxxxxxx
Back-port the AGP patch that has been checked into the 2.6-mm tree
by Andrew Morton.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/agp.h | 37 +++
patches/linux-2.6.11/agpgart.patch | 207 +++++++----------
2 files changed, 123 insertions(+), 121 deletions(-)
diff -Nru a/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/agp.h
b/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/agp.h
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/agp.h 2005-03-22
07:02:58 -05:00
@@ -0,0 +1,37 @@
+#ifndef AGP_H
+#define AGP_H 1
+
+#include <asm/pgtable.h>
+#include <asm/cacheflush.h>
+#include <asm/system.h>
+
+/*
+ * Functions to keep the agpgart mappings coherent with the MMU.
+ * The GART gives the CPU a physical alias of pages in memory. The alias
region is
+ * mapped uncacheable. Make sure there are no conflicting mappings
+ * with different cachability attributes for the same page. This avoids
+ * data corruption on some CPUs.
+ */
+
+int map_page_into_agp(struct page *page);
+int unmap_page_from_agp(struct page *page);
+#define flush_agp_mappings() global_flush_tlb()
+
+/* Could use CLFLUSH here if the cpu supports it. But then it would
+ need to be called for each cacheline of the whole page so it may not be
+ worth it. Would need a page for it. */
+#define flush_agp_cache() wbinvd()
+
+/* Convert a physical address to an address suitable for the GART. */
+#define phys_to_gart(x) phys_to_machine(x)
+#define gart_to_phys(x) machine_to_phys(x)
+
+/* GATT allocation. Returns/accepts GATT kernel virtual address. */
+#define alloc_gatt_pages(order) ({
\
+ char *_t; dma_addr_t _d; \
+ _t = dma_alloc_coherent(NULL,PAGE_SIZE<<(order),&_d,GFP_KERNEL); \
+ _t; })
+#define free_gatt_pages(table, order) \
+ dma_free_coherent(NULL,PAGE_SIZE<<(order),(table),virt_to_bus(table))
+
+#endif
diff -Nru a/patches/linux-2.6.11/agpgart.patch
b/patches/linux-2.6.11/agpgart.patch
--- a/patches/linux-2.6.11/agpgart.patch 2005-03-22 07:02:58 -05:00
+++ b/patches/linux-2.6.11/agpgart.patch 2005-03-22 07:02:58 -05:00
@@ -1,371 +1,437 @@
-diff -rup pristine-linux-2.6.11/drivers/char/agp/ali-agp.c
linux-2.6.11/drivers/char/agp/ali-agp.c
---- pristine-linux-2.6.11/drivers/char/agp/ali-agp.c 2005-03-02
07:38:13.000000000 +0000
-+++ linux-2.6.11/drivers/char/agp/ali-agp.c 2005-03-11 00:35:21.320192760
+0000
-@@ -150,7 +150,7 @@ static void *m1541_alloc_page(void)
+--- linux-2.6.11/drivers/char/agp/agp.h 2005-03-02 07:38:07 +00:00
++++ linux-2.6.11-agp/drivers/char/agp/agp.h 2005-03-22 11:14:02 +00:00
+@@ -272,6 +272,8 @@
+ #define AGP_GENERIC_SIZES_ENTRIES 11
+ extern struct aper_size_info_16 agp3_generic_sizes[];
+
++#define virt_to_gart(x) (phys_to_gart(virt_to_phys(x)))
++#define gart_to_virt(x) (phys_to_virt(gart_to_phys(x)))
+
+ extern int agp_off;
+ extern int agp_try_unsupported_boot;
+--- linux-2.6.11/drivers/char/agp/ali-agp.c 2005-03-02 07:38:13 +00:00
++++ linux-2.6.11-agp/drivers/char/agp/ali-agp.c 2005-03-22 11:14:56
+00:00
+@@ -150,7 +150,7 @@
pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp);
pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL,
(((temp & ALI_CACHE_FLUSH_ADDR_MASK) |
- virt_to_phys(addr)) | ALI_CACHE_FLUSH_EN ));
-+ virt_to_bus(addr)) | ALI_CACHE_FLUSH_EN ));
++ virt_to_gart(addr)) | ALI_CACHE_FLUSH_EN ));
return addr;
}
-@@ -174,7 +174,7 @@ static void m1541_destroy_page(void * ad
+@@ -174,7 +174,7 @@
pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp);
pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL,
(((temp & ALI_CACHE_FLUSH_ADDR_MASK) |
- virt_to_phys(addr)) | ALI_CACHE_FLUSH_EN));
-+ virt_to_bus(addr)) | ALI_CACHE_FLUSH_EN));
++ virt_to_gart(addr)) | ALI_CACHE_FLUSH_EN));
agp_generic_destroy_page(addr);
}
-diff -rup pristine-linux-2.6.11/drivers/char/agp/amd-k7-agp.c
linux-2.6.11/drivers/char/agp/amd-k7-agp.c
---- pristine-linux-2.6.11/drivers/char/agp/amd-k7-agp.c 2005-03-02
07:38:33.000000000 +0000
-+++ linux-2.6.11/drivers/char/agp/amd-k7-agp.c 2005-03-11 00:35:21.321192788
+0000
-@@ -43,7 +43,7 @@ static int amd_create_page_map(struct am
+--- linux-2.6.11/drivers/char/agp/amd-k7-agp.c 2005-03-02 07:38:33 +00:00
++++ linux-2.6.11-agp/drivers/char/agp/amd-k7-agp.c 2005-03-22 11:14:56
+00:00
+@@ -43,7 +43,7 @@
SetPageReserved(virt_to_page(page_map->real));
global_cache_flush();
- page_map->remapped = ioremap_nocache(virt_to_phys(page_map->real),
-+ page_map->remapped = ioremap_nocache(virt_to_bus(page_map->real),
++ page_map->remapped = ioremap_nocache(virt_to_gart(page_map->real),
PAGE_SIZE);
if (page_map->remapped == NULL) {
ClearPageReserved(virt_to_page(page_map->real));
-@@ -154,7 +154,7 @@ static int amd_create_gatt_table(void)
+@@ -154,7 +154,7 @@
agp_bridge->gatt_table_real = (u32 *)page_dir.real;
agp_bridge->gatt_table = (u32 __iomem *)page_dir.remapped;
- agp_bridge->gatt_bus_addr = virt_to_phys(page_dir.real);
-+ agp_bridge->gatt_bus_addr = virt_to_bus(page_dir.real);
++ agp_bridge->gatt_bus_addr = virt_to_gart(page_dir.real);
/* Get the address for the gart region.
* This is a bus address even on the alpha, b/c its
-@@ -167,7 +167,7 @@ static int amd_create_gatt_table(void)
+@@ -167,7 +167,7 @@
/* Calculate the agp offset */
for (i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) {
- writel(virt_to_phys(amd_irongate_private.gatt_pages[i]->real) |
1,
-+ writel(virt_to_bus(amd_irongate_private.gatt_pages[i]->real) |
1,
++ writel(virt_to_gart(amd_irongate_private.gatt_pages[i]->real) |
1,
page_dir.remapped+GET_PAGE_DIR_OFF(addr));
readl(page_dir.remapped+GET_PAGE_DIR_OFF(addr)); /* PCI
Posting. */
}
-diff -rup pristine-linux-2.6.11/drivers/char/agp/amd64-agp.c
linux-2.6.11/drivers/char/agp/amd64-agp.c
---- pristine-linux-2.6.11/drivers/char/agp/amd64-agp.c 2005-03-02
07:38:13.000000000 +0000
-+++ linux-2.6.11/drivers/char/agp/amd64-agp.c 2005-03-11 00:35:21.322192816
+0000
-@@ -218,7 +218,7 @@ static struct aper_size_info_32 amd_8151
+--- linux-2.6.11/drivers/char/agp/amd64-agp.c 2005-03-02 07:38:13 +00:00
++++ linux-2.6.11-agp/drivers/char/agp/amd64-agp.c 2005-03-22 11:14:56
+00:00
+@@ -218,7 +218,7 @@
static int amd_8151_configure(void)
{
- unsigned long gatt_bus = virt_to_phys(agp_bridge->gatt_table_real);
-+ unsigned long gatt_bus = virt_to_bus(agp_bridge->gatt_table_real);
++ unsigned long gatt_bus = virt_to_gart(agp_bridge->gatt_table_real);
/* Configure AGP regs in each x86-64 host bridge. */
for_each_nb() {
-@@ -590,7 +590,7 @@ static void __devexit agp_amd64_remove(s
+@@ -590,7 +590,7 @@
{
struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
- release_mem_region(virt_to_phys(bridge->gatt_table_real),
-+ release_mem_region(virt_to_bus(bridge->gatt_table_real),
++ release_mem_region(virt_to_gart(bridge->gatt_table_real),
amd64_aperture_sizes[bridge->aperture_size_idx].size);
agp_remove_bridge(bridge);
agp_put_bridge(bridge);
-diff -rup pristine-linux-2.6.11/drivers/char/agp/ati-agp.c
linux-2.6.11/drivers/char/agp/ati-agp.c
---- pristine-linux-2.6.11/drivers/char/agp/ati-agp.c 2005-03-02
07:38:13.000000000 +0000
-+++ linux-2.6.11/drivers/char/agp/ati-agp.c 2005-03-11 00:41:25.848450763
+0000
-@@ -61,7 +61,7 @@ static int ati_create_page_map(ati_page_
+--- linux-2.6.11/drivers/char/agp/ati-agp.c 2005-03-02 07:38:13 +00:00
++++ linux-2.6.11-agp/drivers/char/agp/ati-agp.c 2005-03-22 11:14:56
+00:00
+@@ -61,7 +61,7 @@
SetPageReserved(virt_to_page(page_map->real));
err = map_page_into_agp(virt_to_page(page_map->real));
- page_map->remapped = ioremap_nocache(virt_to_phys(page_map->real),
-+ page_map->remapped = ioremap_nocache(virt_to_bus(page_map->real),
++ page_map->remapped = ioremap_nocache(virt_to_gart(page_map->real),
PAGE_SIZE);
if (page_map->remapped == NULL || err) {
ClearPageReserved(virt_to_page(page_map->real));
-diff -rup pristine-linux-2.6.11/drivers/char/agp/backend.c
linux-2.6.11/drivers/char/agp/backend.c
---- pristine-linux-2.6.11/drivers/char/agp/backend.c 2005-03-02
07:38:13.000000000 +0000
-+++ linux-2.6.11/drivers/char/agp/backend.c 2005-03-11 00:35:21.323192844
+0000
-@@ -142,7 +142,7 @@ static int agp_backend_initialize(struct
+--- linux-2.6.11/drivers/char/agp/backend.c 2005-03-02 07:38:13 +00:00
++++ linux-2.6.11-agp/drivers/char/agp/backend.c 2005-03-22 11:14:56
+00:00
+@@ -142,7 +142,7 @@
return -ENOMEM;
}
- bridge->scratch_page_real = virt_to_phys(addr);
-+ bridge->scratch_page_real = virt_to_bus(addr);
++ bridge->scratch_page_real = virt_to_gart(addr);
bridge->scratch_page =
bridge->driver->mask_memory(bridge->scratch_page_real, 0);
}
-@@ -186,7 +186,7 @@ static int agp_backend_initialize(struct
+@@ -186,7 +186,7 @@
err_out:
if (bridge->driver->needs_scratch_page)
bridge->driver->agp_destroy_page(
- phys_to_virt(bridge->scratch_page_real));
-+ bus_to_virt(bridge->scratch_page_real));
++ gart_to_virt(bridge->scratch_page_real));
if (got_gatt)
bridge->driver->free_gatt_table();
if (got_keylist) {
-@@ -211,7 +211,7 @@ static void agp_backend_cleanup(struct a
+@@ -211,7 +211,7 @@
if (bridge->driver->agp_destroy_page &&
bridge->driver->needs_scratch_page)
bridge->driver->agp_destroy_page(
- phys_to_virt(bridge->scratch_page_real));
-+ bus_to_virt(bridge->scratch_page_real));
++ gart_to_virt(bridge->scratch_page_real));
}
/* XXX Kludge alert: agpgart isn't ready for multiple bridges yet */
-diff -rup pristine-linux-2.6.11/drivers/char/agp/efficeon-agp.c
linux-2.6.11/drivers/char/agp/efficeon-agp.c
---- pristine-linux-2.6.11/drivers/char/agp/efficeon-agp.c 2005-03-02
07:37:30.000000000 +0000
-+++ linux-2.6.11/drivers/char/agp/efficeon-agp.c 2005-03-11
00:35:21.324192872 +0000
-@@ -219,7 +219,7 @@ static int efficeon_create_gatt_table(vo
+--- linux-2.6.11/drivers/char/agp/efficeon-agp.c 2005-03-02 07:37:30
+00:00
++++ linux-2.6.11-agp/drivers/char/agp/efficeon-agp.c 2005-03-22 11:15:17
+00:00
+@@ -219,7 +219,7 @@
efficeon_private.l1_table[index] = page;
- value = __pa(page) | pati | present | index;
-+ value = virt_to_bus(page) | pati | present | index;
++ value = virt_to_gart(page) | pati | present | index;
pci_write_config_dword(agp_bridge->dev,
EFFICEON_ATTPAGE, value);
-diff -rup pristine-linux-2.6.11/drivers/char/agp/generic.c
linux-2.6.11/drivers/char/agp/generic.c
---- pristine-linux-2.6.11/drivers/char/agp/generic.c 2005-03-02
07:37:55.000000000 +0000
-+++ linux-2.6.11/drivers/char/agp/generic.c 2005-03-11 00:44:53.858248651
+0000
-@@ -151,7 +151,7 @@ void agp_free_memory(struct agp_memory *
+--- linux-2.6.11/drivers/char/agp/generic.c 2005-03-02 07:37:55 +00:00
++++ linux-2.6.11-agp/drivers/char/agp/generic.c 2005-03-22 11:17:37
+00:00
+@@ -151,7 +151,7 @@
}
if (curr->page_count != 0) {
for (i = 0; i < curr->page_count; i++) {
-
agp_bridge->driver->agp_destroy_page(phys_to_virt(curr->memory[i]));
-+
agp_bridge->driver->agp_destroy_page(bus_to_virt(curr->memory[i]));
++
agp_bridge->driver->agp_destroy_page(gart_to_virt(curr->memory[i]));
}
}
agp_free_key(curr->key);
-@@ -204,7 +204,7 @@ struct agp_memory *agp_allocate_memory(s
+@@ -204,7 +204,7 @@
agp_free_memory(new);
return NULL;
}
- new->memory[i] = virt_to_phys(addr);
-+ new->memory[i] = virt_to_bus(addr);
++ new->memory[i] = virt_to_gart(addr);
new->page_count++;
}
-@@ -659,6 +659,7 @@ int agp_generic_create_gatt_table(void)
- int i;
- void *temp;
- struct page *page;
-+ dma_addr_t dma;
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/xen-changelog
|