Commit baa151e7 authored by Dave Jones's avatar Dave Jones Committed by Dave Jones

[AGP] add agp_num_entries() function to determine GATT table size - reserved IOMMU entries.

Currently, only the K8 GART needs this, but this is cleaner than
exporting the agp_reserved_memory variable.
parent 8dfa03eb
/* /*
* AGPGART module version 0.99 * AGPGART module version 0.100
* Copyright (C) 2002 Dave Jones
* Copyright (C) 1999 Jeff Hartmann * Copyright (C) 1999 Jeff Hartmann
* Copyright (C) 1999 Precision Insight, Inc. * Copyright (C) 1999 Precision Insight, Inc.
* Copyright (C) 1999 Xi Graphics, Inc. * Copyright (C) 1999 Xi Graphics, Inc.
...@@ -46,6 +47,7 @@ void agp_generic_destroy_page(void *addr); ...@@ -46,6 +47,7 @@ void agp_generic_destroy_page(void *addr);
int agp_generic_suspend(void); int agp_generic_suspend(void);
void agp_generic_resume(void); void agp_generic_resume(void);
void agp_free_key(int key); void agp_free_key(int key);
int agp_num_entries(void);
#define PFX "agpgart: " #define PFX "agpgart: "
......
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
#include <linux/agp_backend.h> #include <linux/agp_backend.h>
#include "agp.h" #include "agp.h"
extern int agp_memory_reserved;
static u_int64_t pci_read64 (struct pci_dev *dev, int reg) static u_int64_t pci_read64 (struct pci_dev *dev, int reg)
{ {
union { union {
...@@ -48,16 +46,13 @@ static void pci_write64 (struct pci_dev *dev, int reg, u64 value) ...@@ -48,16 +46,13 @@ static void pci_write64 (struct pci_dev *dev, int reg, u64 value)
static int x86_64_insert_memory(agp_memory * mem, off_t pg_start, int type) static int x86_64_insert_memory(agp_memory * mem, off_t pg_start, int type)
{ {
int i, j, num_entries; int i, j, num_entries;
void *temp;
long tmp; long tmp;
u32 pte; u32 pte;
u64 addr; u64 addr;
temp = agp_bridge.current_size; temp = agp_bridge.current_size;
num_entries = A_SIZE_32(temp)->num_entries; num_entries = agp_num_entries();
num_entries -= agp_memory_reserved>>PAGE_SHIFT;
if (type != 0 || mem->type != 0) if (type != 0 || mem->type != 0)
return -EINVAL; return -EINVAL;
......
...@@ -203,6 +203,40 @@ static int agp_return_size(void) ...@@ -203,6 +203,40 @@ static int agp_return_size(void)
return current_size; return current_size;
} }
int agp_num_entries(void)
{
int num_entries;
void *temp;
temp = agp_bridge.current_size;
switch (agp_bridge.size_type) {
case U8_APER_SIZE:
num_entries = A_SIZE_8(temp)->num_entries;
break;
case U16_APER_SIZE:
num_entries = A_SIZE_16(temp)->num_entries;
break;
case U32_APER_SIZE:
num_entries = A_SIZE_32(temp)->num_entries;
break;
case LVL2_APER_SIZE:
num_entries = A_SIZE_LVL2(temp)->num_entries;
break;
case FIXED_APER_SIZE:
num_entries = A_SIZE_FIX(temp)->num_entries;
break;
default:
num_entries = 0;
break;
}
num_entries -= agp_memory_reserved>>PAGE_SHIFT;
if (num_entries<0)
num_entries = 0;
return num_entries;
}
/* Routine to copy over information structure */ /* Routine to copy over information structure */
int agp_copy_info(agp_kern_info * info) int agp_copy_info(agp_kern_info * info)
...@@ -713,3 +747,5 @@ EXPORT_SYMBOL(agp_generic_alloc_by_type); ...@@ -713,3 +747,5 @@ EXPORT_SYMBOL(agp_generic_alloc_by_type);
EXPORT_SYMBOL(agp_generic_free_by_type); EXPORT_SYMBOL(agp_generic_free_by_type);
EXPORT_SYMBOL(global_cache_flush); EXPORT_SYMBOL(global_cache_flush);
EXPORT_SYMBOL_GPL(agp_num_entries);
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