Skip to content

Commit

Permalink
x86: iommu: use symbolic constants, not hardcoded numbers
Browse files Browse the repository at this point in the history
Move symbolic constants into gart.h, and use them instead of hardcoded
constant.

Signed-off-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Pavel Machek authored and Ingo Molnar committed May 12, 2008
1 parent 492c2e4 commit aa134f1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
10 changes: 5 additions & 5 deletions arch/x86/kernel/pci-gart_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,13 +598,13 @@ static __init int init_k8_gatt(struct agp_kern_info *info)
dev = k8_northbridges[i];
gatt_reg = __pa(gatt) >> 12;
gatt_reg <<= 4;
pci_write_config_dword(dev, 0x98, gatt_reg);
pci_read_config_dword(dev, 0x90, &ctl);
pci_write_config_dword(dev, AMD64_GARTTABLEBASE, gatt_reg);
pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &ctl);

ctl |= 1;
ctl &= ~((1<<4) | (1<<5));
ctl |= GARTEN;
ctl &= ~(DISGARTCPU | DISGARTIO);

pci_write_config_dword(dev, 0x90, ctl);
pci_write_config_dword(dev, AMD64_GARTAPERTURECTL, ctl);
}
flush_gart();

Expand Down
25 changes: 3 additions & 22 deletions drivers/char/agp/amd64-agp.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,9 @@
#include <asm/page.h> /* PAGE_SIZE */
#include <asm/e820.h>
#include <asm/k8.h>
#include <asm/gart.h>
#include "agp.h"

/* PTE bits. */
#define GPTE_VALID 1
#define GPTE_COHERENT 2

/* Aperture control register bits. */
#define GARTEN (1<<0)
#define DISGARTCPU (1<<4)
#define DISGARTIO (1<<5)

/* GART cache control register bits. */
#define INVGART (1<<0)
#define GARTPTEERR (1<<1)

/* K8 On-cpu GART registers */
#define AMD64_GARTAPERTURECTL 0x90
#define AMD64_GARTAPERTUREBASE 0x94
#define AMD64_GARTTABLEBASE 0x98
#define AMD64_GARTCACHECTL 0x9c
#define AMD64_GARTEN (1<<0)

/* NVIDIA K8 registers */
#define NVIDIA_X86_64_0_APBASE 0x10
#define NVIDIA_X86_64_1_APBASE1 0x50
Expand Down Expand Up @@ -165,7 +146,7 @@ static int amd64_fetch_size(void)
* In a multiprocessor x86-64 system, this function gets
* called once for each CPU.
*/
static u64 amd64_configure (struct pci_dev *hammer, u64 gatt_table)
static u64 amd64_configure(struct pci_dev *hammer, u64 gatt_table)
{
u64 aperturebase;
u32 tmp;
Expand All @@ -181,7 +162,7 @@ static u64 amd64_configure (struct pci_dev *hammer, u64 gatt_table)
addr >>= 12;
tmp = (u32) addr<<4;
tmp &= ~0xf;
pci_write_config_dword (hammer, AMD64_GARTTABLEBASE, tmp);
pci_write_config_dword(hammer, AMD64_GARTTABLEBASE, tmp);

/* Enable GART translation for this hammer. */
pci_read_config_dword(hammer, AMD64_GARTAPERTURECTL, &tmp);
Expand Down
21 changes: 21 additions & 0 deletions include/asm-x86/gart.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ extern void pci_iommu_shutdown(void);
extern void no_iommu_init(void);
extern int force_iommu, no_iommu;
extern int iommu_detected;
extern int agp_amd64_init(void);
#ifdef CONFIG_GART_IOMMU
extern void gart_iommu_init(void);
extern void gart_iommu_shutdown(void);
Expand All @@ -31,4 +32,24 @@ static inline void gart_iommu_shutdown(void)

#endif

/* PTE bits. */
#define GPTE_VALID 1
#define GPTE_COHERENT 2

/* Aperture control register bits. */
#define GARTEN (1<<0)
#define DISGARTCPU (1<<4)
#define DISGARTIO (1<<5)

/* GART cache control register bits. */
#define INVGART (1<<0)
#define GARTPTEERR (1<<1)

/* K8 On-cpu GART registers */
#define AMD64_GARTAPERTURECTL 0x90
#define AMD64_GARTAPERTUREBASE 0x94
#define AMD64_GARTTABLEBASE 0x98
#define AMD64_GARTCACHECTL 0x9c
#define AMD64_GARTEN (1<<0)

#endif

0 comments on commit aa134f1

Please sign in to comment.