aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86_64
diff options
context:
space:
mode:
authorJon Mason <jdmason@us.ibm.com>2006-06-26 07:58:14 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-26 13:48:19 -0400
commite465058d55a88feb4c7ecabe63eea7ea7147e206 (patch)
treed431ed689e072415915694eecdfbcb9304287f01 /include/asm-x86_64
parent0dc243ae10c8309c170a3af9f1adad1924a9f217 (diff)
[PATCH] x86_64: Calgary IOMMU - Calgary specific bits
This patch hooks Calgary into the build, the x86-64 IOMMU initialization paths, and introduces the Calgary specific bits. The implementation draws inspiration from both PPC (which has support for the same chip but requires firmware support which we don't have on x86-64) and gart. Calgary is different from gart in that it support a translation table per PHB, as opposed to the single gart aperture. Changes from previous version: * Addition of boot-time disablement for bus-level translation/isolation (e.g, enable userspace DMA for things like X) * Usage of newer IOMMU abstraction functions Signed-off-by: Muli Ben-Yehuda <muli@il.ibm.com> Signed-off-by: Jon Mason <jdmason@us.ibm.com> Signed-off-by: Andi Kleen <ak@suse.de> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/asm-x86_64')
-rw-r--r--include/asm-x86_64/calgary.h66
-rw-r--r--include/asm-x86_64/pci.h2
-rw-r--r--include/asm-x86_64/tce.h47
3 files changed, 114 insertions, 1 deletions
diff --git a/include/asm-x86_64/calgary.h b/include/asm-x86_64/calgary.h
new file mode 100644
index 000000000000..6e1654f30986
--- /dev/null
+++ b/include/asm-x86_64/calgary.h
@@ -0,0 +1,66 @@
1/*
2 * Derived from include/asm-powerpc/iommu.h
3 *
4 * Copyright (C) 2006 Jon Mason <jdmason@us.ibm.com>, IBM Corporation
5 * Copyright (C) 2006 Muli Ben-Yehuda <muli@il.ibm.com>, IBM Corporation
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#ifndef _ASM_X86_64_CALGARY_H
23#define _ASM_X86_64_CALGARY_H
24
25#include <linux/config.h>
26#include <linux/spinlock.h>
27#include <linux/device.h>
28#include <linux/dma-mapping.h>
29#include <asm/types.h>
30
31struct iommu_table {
32 unsigned long it_base; /* mapped address of tce table */
33 unsigned long it_hint; /* Hint for next alloc */
34 unsigned long *it_map; /* A simple allocation bitmap for now */
35 spinlock_t it_lock; /* Protects it_map */
36 unsigned int it_size; /* Size of iommu table in entries */
37 unsigned char it_busno; /* Bus number this table belongs to */
38 void __iomem *bbar;
39 u64 tar_val;
40 struct timer_list watchdog_timer;
41};
42
43#define TCE_TABLE_SIZE_UNSPECIFIED ~0
44#define TCE_TABLE_SIZE_64K 0
45#define TCE_TABLE_SIZE_128K 1
46#define TCE_TABLE_SIZE_256K 2
47#define TCE_TABLE_SIZE_512K 3
48#define TCE_TABLE_SIZE_1M 4
49#define TCE_TABLE_SIZE_2M 5
50#define TCE_TABLE_SIZE_4M 6
51#define TCE_TABLE_SIZE_8M 7
52
53#ifdef CONFIG_CALGARY_IOMMU
54extern int calgary_iommu_init(void);
55extern void detect_calgary(void);
56#else
57static inline int calgary_iommu_init(void) { return 1; }
58static inline void detect_calgary(void) { return; }
59#endif
60
61static inline unsigned int bus_to_phb(unsigned char busno)
62{
63 return ((busno % 15 == 0) ? 0 : busno / 2 + 1);
64}
65
66#endif /* _ASM_X86_64_CALGARY_H */
diff --git a/include/asm-x86_64/pci.h b/include/asm-x86_64/pci.h
index 4dbc07c54f7a..49c5e9280598 100644
--- a/include/asm-x86_64/pci.h
+++ b/include/asm-x86_64/pci.h
@@ -52,7 +52,7 @@ extern int iommu_setup(char *opt);
52 */ 52 */
53#define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys) 53#define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys)
54 54
55#ifdef CONFIG_IOMMU 55#if defined(CONFIG_IOMMU) || defined(CONFIG_CALGARY_IOMMU)
56 56
57/* 57/*
58 * x86-64 always supports DAC, but sometimes it is useful to force 58 * x86-64 always supports DAC, but sometimes it is useful to force
diff --git a/include/asm-x86_64/tce.h b/include/asm-x86_64/tce.h
new file mode 100644
index 000000000000..ee51d31528d6
--- /dev/null
+++ b/include/asm-x86_64/tce.h
@@ -0,0 +1,47 @@
1/*
2 * Copyright (C) 2006 Muli Ben-Yehuda <muli@il.ibm.com>, IBM Corporation
3 * Copyright (C) 2006 Jon Mason <jdmason@us.ibm.com>, IBM Corporation
4 *
5 * This file is derived from asm-powerpc/tce.h.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#ifndef _ASM_X86_64_TCE_H
23#define _ASM_X86_64_TCE_H
24
25extern void* tce_table_kva[];
26extern unsigned int specified_table_size;
27struct iommu_table;
28
29#define TCE_ENTRY_SIZE 8 /* in bytes */
30
31#define TCE_READ_SHIFT 0
32#define TCE_WRITE_SHIFT 1
33#define TCE_HUBID_SHIFT 2 /* unused */
34#define TCE_RSVD_SHIFT 8 /* unused */
35#define TCE_RPN_SHIFT 12
36#define TCE_UNUSED_SHIFT 48 /* unused */
37
38#define TCE_RPN_MASK 0x0000fffffffff000ULL
39
40extern void tce_build(struct iommu_table *tbl, unsigned long index,
41 unsigned int npages, unsigned long uaddr, int direction);
42extern void tce_free(struct iommu_table *tbl, long index, unsigned int npages);
43extern void* alloc_tce_table(void);
44extern void free_tce_table(void *tbl);
45extern int build_tce_table(struct pci_dev *dev, void __iomem *bbar);
46
47#endif /* _ASM_X86_64_TCE_H */