[XFRM]: skb_cow_data() does not set proper owner for new skbs.
[linux-2.6/verdex.git] / drivers / char / agp / alpha-agp.c
bloba072d32005a466431c5bfed2c421e3ee27837cf1
1 #include <linux/module.h>
2 #include <linux/pci.h>
3 #include <linux/init.h>
4 #include <linux/agp_backend.h>
5 #include <linux/mm.h>
6 #include <linux/slab.h>
8 #include <asm/machvec.h>
9 #include <asm/agp_backend.h>
10 #include "../../../arch/alpha/kernel/pci_impl.h"
12 #include "agp.h"
14 static struct page *alpha_core_agp_vm_nopage(struct vm_area_struct *vma,
15 unsigned long address,
16 int *type)
18 alpha_agp_info *agp = agp_bridge->dev_private_data;
19 dma_addr_t dma_addr;
20 unsigned long pa;
21 struct page *page;
23 dma_addr = address - vma->vm_start + agp->aperture.bus_base;
24 pa = agp->ops->translate(agp, dma_addr);
26 if (pa == (unsigned long)-EINVAL) return NULL; /* no translation */
29 * Get the page, inc the use count, and return it
31 page = virt_to_page(__va(pa));
32 get_page(page);
33 if (type)
34 *type = VM_FAULT_MINOR;
35 return page;
38 static struct aper_size_info_fixed alpha_core_agp_sizes[] =
40 { 0, 0, 0 }, /* filled in by alpha_core_agp_setup */
43 struct vm_operations_struct alpha_core_agp_vm_ops = {
44 .nopage = alpha_core_agp_vm_nopage,
48 static int alpha_core_agp_nop(void)
50 /* just return success */
51 return 0;
54 static int alpha_core_agp_fetch_size(void)
56 return alpha_core_agp_sizes[0].size;
59 static int alpha_core_agp_configure(void)
61 alpha_agp_info *agp = agp_bridge->dev_private_data;
62 agp_bridge->gart_bus_addr = agp->aperture.bus_base;
63 return 0;
66 static void alpha_core_agp_cleanup(void)
68 alpha_agp_info *agp = agp_bridge->dev_private_data;
70 agp->ops->cleanup(agp);
73 static void alpha_core_agp_tlbflush(struct agp_memory *mem)
75 alpha_agp_info *agp = agp_bridge->dev_private_data;
76 alpha_mv.mv_pci_tbi(agp->hose, 0, -1);
79 static void alpha_core_agp_enable(struct agp_bridge_data *bridge, u32 mode)
81 alpha_agp_info *agp = bridge->dev_private_data;
83 agp->mode.lw = agp_collect_device_status(bridge, mode,
84 agp->capability.lw);
86 agp->mode.bits.enable = 1;
87 agp->ops->configure(agp);
89 agp_device_command(agp->mode.lw, 0);
92 static int alpha_core_agp_insert_memory(struct agp_memory *mem, off_t pg_start,
93 int type)
95 alpha_agp_info *agp = agp_bridge->dev_private_data;
96 int num_entries, status;
97 void *temp;
99 temp = agp_bridge->current_size;
100 num_entries = A_SIZE_FIX(temp)->num_entries;
101 if ((pg_start + mem->page_count) > num_entries) return -EINVAL;
103 status = agp->ops->bind(agp, pg_start, mem);
104 mb();
105 alpha_core_agp_tlbflush(mem);
107 return status;
110 static int alpha_core_agp_remove_memory(struct agp_memory *mem, off_t pg_start,
111 int type)
113 alpha_agp_info *agp = agp_bridge->dev_private_data;
114 int status;
116 status = agp->ops->unbind(agp, pg_start, mem);
117 alpha_core_agp_tlbflush(mem);
118 return status;
121 struct agp_bridge_driver alpha_core_agp_driver = {
122 .owner = THIS_MODULE,
123 .aperture_sizes = alpha_core_agp_sizes,
124 .num_aperture_sizes = 1,
125 .size_type = FIXED_APER_SIZE,
126 .cant_use_aperture = 1,
127 .masks = NULL,
129 .fetch_size = alpha_core_agp_fetch_size,
130 .configure = alpha_core_agp_configure,
131 .agp_enable = alpha_core_agp_enable,
132 .cleanup = alpha_core_agp_cleanup,
133 .tlb_flush = alpha_core_agp_tlbflush,
134 .mask_memory = agp_generic_mask_memory,
135 .cache_flush = global_cache_flush,
136 .create_gatt_table = alpha_core_agp_nop,
137 .free_gatt_table = alpha_core_agp_nop,
138 .insert_memory = alpha_core_agp_insert_memory,
139 .remove_memory = alpha_core_agp_remove_memory,
140 .alloc_by_type = agp_generic_alloc_by_type,
141 .free_by_type = agp_generic_free_by_type,
142 .agp_alloc_page = agp_generic_alloc_page,
143 .agp_destroy_page = agp_generic_destroy_page,
146 struct agp_bridge_data *alpha_bridge;
148 int __init
149 alpha_core_agp_setup(void)
151 alpha_agp_info *agp = alpha_mv.agp_info();
152 struct pci_dev *pdev; /* faked */
153 struct aper_size_info_fixed *aper_size;
155 if (!agp)
156 return -ENODEV;
157 if (agp->ops->setup(agp))
158 return -ENODEV;
161 * Build the aperture size descriptor
163 aper_size = alpha_core_agp_sizes;
164 aper_size->size = agp->aperture.size / (1024 * 1024);
165 aper_size->num_entries = agp->aperture.size / PAGE_SIZE;
166 aper_size->page_order = __ffs(aper_size->num_entries / 1024);
169 * Build a fake pci_dev struct
171 pdev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL);
172 if (!pdev)
173 return -ENOMEM;
174 pdev->vendor = 0xffff;
175 pdev->device = 0xffff;
176 pdev->sysdata = agp->hose;
178 alpha_bridge = agp_alloc_bridge();
179 if (!alpha_bridge)
180 goto fail;
182 alpha_bridge->driver = &alpha_core_agp_driver;
183 alpha_bridge->vm_ops = &alpha_core_agp_vm_ops;
184 alpha_bridge->current_size = aper_size; /* only 1 size */
185 alpha_bridge->dev_private_data = agp;
186 alpha_bridge->dev = pdev;
187 alpha_bridge->mode = agp->capability.lw;
189 printk(KERN_INFO PFX "Detected AGP on hose %d\n", agp->hose->index);
190 return agp_add_bridge(alpha_bridge);
192 fail:
193 kfree(pdev);
194 return -ENOMEM;
197 static int __init agp_alpha_core_init(void)
199 if (agp_off)
200 return -EINVAL;
201 if (alpha_mv.agp_info)
202 return alpha_core_agp_setup();
203 return -ENODEV;
206 static void __exit agp_alpha_core_cleanup(void)
208 agp_remove_bridge(alpha_bridge);
209 agp_put_bridge(alpha_bridge);
212 module_init(agp_alpha_core_init);
213 module_exit(agp_alpha_core_cleanup);
215 MODULE_AUTHOR("Jeff Wiedemeier <Jeff.Wiedemeier@hp.com>");
216 MODULE_LICENSE("GPL and additional rights");