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 Precision Insight, Inc.
* Copyright (C) 1999 Xi Graphics, Inc.
......@@ -46,6 +47,7 @@ void agp_generic_destroy_page(void *addr);
int agp_generic_suspend(void);
void agp_generic_resume(void);
void agp_free_key(int key);
int agp_num_entries(void);
#define PFX "agpgart: "
......
......@@ -14,8 +14,6 @@
#include <linux/agp_backend.h>
#include "agp.h"
extern int agp_memory_reserved;
static u_int64_t pci_read64 (struct pci_dev *dev, int reg)
{
union {
......@@ -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)
{
int i, j, num_entries;
void *temp;
long tmp;
u32 pte;
u64 addr;
temp = agp_bridge.current_size;
num_entries = A_SIZE_32(temp)->num_entries;
num_entries -= agp_memory_reserved>>PAGE_SHIFT;
num_entries = agp_num_entries();
if (type != 0 || mem->type != 0)
return -EINVAL;
......
......@@ -203,6 +203,40 @@ static int agp_return_size(void)
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 */
int agp_copy_info(agp_kern_info * info)
......@@ -713,3 +747,5 @@ EXPORT_SYMBOL(agp_generic_alloc_by_type);
EXPORT_SYMBOL(agp_generic_free_by_type);
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