Commit a8c84df9 authored by Keith Packard's avatar Keith Packard Committed by Dave Airlie

intel/agp: rewrite GTT on resume

On my Intel chipset (965GM), the GTT is entirely erased across
suspend/resume.  This patch simply re-plays the current mapping at resume
time to restore the table.=20

I noticed this once I started relying on persistent GTT mappings across VT
switch in our GEM work -- the old X server and DRM code carefully unbind
all memory from the GTT on VT switch, but GEM does not bother.

I placed the list management and rewrite code in the generic layer on the
assumption that it will be needed on other hardware, but I did not add the
rewrite call to anything other than the Intel resume function.

Keep a list of current GATT mappings.  At resume time, rewrite them into
the GATT.  This is needed on Intel (at least) as the entire GATT is
cleared across suspend/resume.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: default avatarKeith Packard <keithp@keithp.com>
Cc: Dave Jones <davej@codemonkey.org.uk>
Cc: Andi Kleen <andi@firstfloor.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent e3cf6951
...@@ -148,6 +148,9 @@ struct agp_bridge_data { ...@@ -148,6 +148,9 @@ struct agp_bridge_data {
char minor_version; char minor_version;
struct list_head list; struct list_head list;
u32 apbase_config; u32 apbase_config;
/* list of agp_memory mapped to the aperture */
struct list_head mapped_list;
spinlock_t mapped_lock;
}; };
#define KB(x) ((x) * 1024) #define KB(x) ((x) * 1024)
......
...@@ -185,6 +185,8 @@ static int agp_backend_initialize(struct agp_bridge_data *bridge) ...@@ -185,6 +185,8 @@ static int agp_backend_initialize(struct agp_bridge_data *bridge)
rc = -EINVAL; rc = -EINVAL;
goto err_out; goto err_out;
} }
INIT_LIST_HEAD(&bridge->mapped_list);
spin_lock_init(&bridge->mapped_lock);
return 0; return 0;
......
...@@ -429,6 +429,10 @@ int agp_bind_memory(struct agp_memory *curr, off_t pg_start) ...@@ -429,6 +429,10 @@ int agp_bind_memory(struct agp_memory *curr, off_t pg_start)
curr->is_bound = true; curr->is_bound = true;
curr->pg_start = pg_start; curr->pg_start = pg_start;
spin_lock(&agp_bridge->mapped_lock);
list_add(&curr->mapped_list, &agp_bridge->mapped_list);
spin_unlock(&agp_bridge->mapped_lock);
return 0; return 0;
} }
EXPORT_SYMBOL(agp_bind_memory); EXPORT_SYMBOL(agp_bind_memory);
...@@ -461,10 +465,34 @@ int agp_unbind_memory(struct agp_memory *curr) ...@@ -461,10 +465,34 @@ int agp_unbind_memory(struct agp_memory *curr)
curr->is_bound = false; curr->is_bound = false;
curr->pg_start = 0; curr->pg_start = 0;
spin_lock(&curr->bridge->mapped_lock);
list_del(&curr->mapped_list);
spin_unlock(&curr->bridge->mapped_lock);
return 0; return 0;
} }
EXPORT_SYMBOL(agp_unbind_memory); EXPORT_SYMBOL(agp_unbind_memory);
/**
* agp_rebind_emmory - Rewrite the entire GATT, useful on resume
*/
int agp_rebind_memory(void)
{
struct agp_memory *curr;
int ret_val = 0;
spin_lock(&agp_bridge->mapped_lock);
list_for_each_entry(curr, &agp_bridge->mapped_list, mapped_list) {
ret_val = curr->bridge->driver->insert_memory(curr,
curr->pg_start,
curr->type);
if (ret_val != 0)
break;
}
spin_unlock(&agp_bridge->mapped_lock);
return ret_val;
}
EXPORT_SYMBOL(agp_rebind_memory);
/* End - Routines for handling swapping of agp_memory into the GATT */ /* End - Routines for handling swapping of agp_memory into the GATT */
......
...@@ -2244,6 +2244,7 @@ static void __devexit agp_intel_remove(struct pci_dev *pdev) ...@@ -2244,6 +2244,7 @@ static void __devexit agp_intel_remove(struct pci_dev *pdev)
static int agp_intel_resume(struct pci_dev *pdev) static int agp_intel_resume(struct pci_dev *pdev)
{ {
struct agp_bridge_data *bridge = pci_get_drvdata(pdev); struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
int ret_val;
pci_restore_state(pdev); pci_restore_state(pdev);
...@@ -2271,6 +2272,10 @@ static int agp_intel_resume(struct pci_dev *pdev) ...@@ -2271,6 +2272,10 @@ static int agp_intel_resume(struct pci_dev *pdev)
else if (bridge->driver == &intel_i965_driver) else if (bridge->driver == &intel_i965_driver)
intel_i915_configure(); intel_i915_configure();
ret_val = agp_rebind_memory();
if (ret_val != 0)
return ret_val;
return 0; return 0;
} }
#endif #endif
......
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
#ifndef _AGP_BACKEND_H #ifndef _AGP_BACKEND_H
#define _AGP_BACKEND_H 1 #define _AGP_BACKEND_H 1
#include <linux/list.h>
enum chipset_type { enum chipset_type {
NOT_SUPPORTED, NOT_SUPPORTED,
SUPPORTED, SUPPORTED,
...@@ -78,6 +80,8 @@ struct agp_memory { ...@@ -78,6 +80,8 @@ struct agp_memory {
bool is_bound; bool is_bound;
bool is_flushed; bool is_flushed;
bool vmalloc_flag; bool vmalloc_flag;
/* list of agp_memory mapped to the aperture */
struct list_head mapped_list;
}; };
#define AGP_NORMAL_MEMORY 0 #define AGP_NORMAL_MEMORY 0
...@@ -96,6 +100,7 @@ extern struct agp_memory *agp_allocate_memory(struct agp_bridge_data *, size_t, ...@@ -96,6 +100,7 @@ extern struct agp_memory *agp_allocate_memory(struct agp_bridge_data *, size_t,
extern int agp_copy_info(struct agp_bridge_data *, struct agp_kern_info *); extern int agp_copy_info(struct agp_bridge_data *, struct agp_kern_info *);
extern int agp_bind_memory(struct agp_memory *, off_t); extern int agp_bind_memory(struct agp_memory *, off_t);
extern int agp_unbind_memory(struct agp_memory *); extern int agp_unbind_memory(struct agp_memory *);
extern int agp_rebind_memory(void);
extern void agp_enable(struct agp_bridge_data *, u32); extern void agp_enable(struct agp_bridge_data *, u32);
extern struct agp_bridge_data *agp_backend_acquire(struct pci_dev *); extern struct agp_bridge_data *agp_backend_acquire(struct pci_dev *);
extern void agp_backend_release(struct agp_bridge_data *); extern void agp_backend_release(struct agp_bridge_data *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment