Rev 6084 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6084 | Rev 6296 | ||
---|---|---|---|
Line 56... | Line 56... | ||
56 | dmah = kmalloc(sizeof(drm_dma_handle_t), GFP_KERNEL); |
56 | dmah = kmalloc(sizeof(drm_dma_handle_t), GFP_KERNEL); |
57 | if (!dmah) |
57 | if (!dmah) |
58 | return NULL; |
58 | return NULL; |
Line 59... | Line 59... | ||
59 | 59 | ||
60 | dmah->size = size; |
- | |
61 | dmah->vaddr = (void*)KernelAlloc(size); |
60 | dmah->size = size; |
Line 62... | Line 61... | ||
62 | dmah->busaddr = GetPgAddr(dmah->vaddr); |
61 | dmah->vaddr = dma_alloc_coherent(&dev->pdev->dev, size, &dmah->busaddr, GFP_KERNEL | __GFP_COMP); |
63 | 62 | ||
64 | if (dmah->vaddr == NULL) { |
63 | if (dmah->vaddr == NULL) { |
65 | kfree(dmah); |
64 | kfree(dmah); |
Line 71... | Line 70... | ||
71 | return dmah; |
70 | return dmah; |
72 | } |
71 | } |
Line 73... | Line 72... | ||
73 | 72 | ||
Line 74... | Line -... | ||
74 | EXPORT_SYMBOL(drm_pci_alloc); |
- | |
75 | 73 | EXPORT_SYMBOL(drm_pci_alloc); |
|
76 | #if 0 |
74 | |
77 | /** |
75 | /* |
78 | * \brief Free a PCI consistent memory block without freeing its descriptor. |
76 | * Free a PCI consistent memory block without freeing its descriptor. |
79 | * |
77 | * |
80 | * This function is for internal use in the Linux-specific DRM core code. |
78 | * This function is for internal use in the Linux-specific DRM core code. |
81 | */ |
79 | */ |
82 | void __drm_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah) |
80 | void __drm_legacy_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah) |
83 | { |
81 | { |
Line 84... | Line 82... | ||
84 | unsigned long addr; |
82 | unsigned long addr; |
85 | size_t sz; |
- | |
86 | - | ||
87 | if (dmah->vaddr) { |
- | |
88 | /* XXX - Is virt_to_page() legal for consistent mem? */ |
- | |
89 | /* Unreserve */ |
- | |
90 | for (addr = (unsigned long)dmah->vaddr, sz = dmah->size; |
- | |
91 | sz > 0; addr += PAGE_SIZE, sz -= PAGE_SIZE) { |
- | |
92 | ClearPageReserved(virt_to_page((void *)addr)); |
83 | size_t sz; |
93 | } |
84 | |
94 | dma_free_coherent(&dev->pdev->dev, dmah->size, dmah->vaddr, |
85 | if (dmah->vaddr) { |
Line 95... | Line 86... | ||
95 | dmah->busaddr); |
86 | KernelFree(dmah->vaddr); |
96 | } |
87 | } |
97 | } |
88 | } |
98 | 89 | ||
99 | /** |
90 | /** |
100 | * drm_pci_free - Free a PCI consistent memory block |
91 | * drm_pci_free - Free a PCI consistent memory block |
101 | * @dev: DRM device |
92 | * @dev: DRM device |
102 | * @dmah: handle to memory block |
93 | * @dmah: handle to memory block |
103 | */ |
94 | */ |
104 | void drm_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah) |
95 | void drm_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah) |
Line 105... | Line 96... | ||
105 | { |
96 | { |
Line -... | Line 97... | ||
- | 97 | __drm_legacy_pci_free(dev, dmah); |
|
Line 106... | Line 98... | ||
106 | __drm_pci_free(dev, dmah); |
98 | kfree(dmah); |
107 | kfree(dmah); |
99 | } |
108 | } |
100 | |
109 | 101 | EXPORT_SYMBOL(drm_pci_free); |
|
Line 122... | Line 114... | ||
122 | #endif /* __alpha__ */ |
114 | #endif /* __alpha__ */ |
Line 123... | Line 115... | ||
123 | 115 | ||
124 | return pci_domain_nr(dev->pdev->bus); |
116 | return pci_domain_nr(dev->pdev->bus); |
Line 125... | Line 117... | ||
125 | } |
117 | } |
126 | 118 | ||
127 | static int drm_pci_get_irq(struct drm_device *dev) |
- | |
128 | { |
- | |
129 | return dev->pdev->irq; |
- | |
130 | } |
- | |
131 | - | ||
132 | static const char *drm_pci_get_name(struct drm_device *dev) |
- | |
133 | { |
- | |
134 | struct pci_driver *pdriver = dev->driver->kdriver.pci; |
- | |
135 | return pdriver->name; |
- | |
136 | } |
- | |
137 | - | ||
138 | static int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master) |
- | |
139 | { |
- | |
140 | int len, ret; |
- | |
141 | struct pci_driver *pdriver = dev->driver->kdriver.pci; |
- | |
142 | master->unique_len = 40; |
119 | int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master) |
143 | master->unique_size = master->unique_len; |
- | |
144 | master->unique = kmalloc(master->unique_size, GFP_KERNEL); |
- | |
145 | if (master->unique == NULL) |
- | |
146 | return -ENOMEM; |
- | |
147 | - | ||
148 | - | ||
149 | len = snprintf(master->unique, master->unique_len, |
120 | { |
150 | "pci:%04x:%02x:%02x.%d", |
121 | master->unique = kasprintf(GFP_KERNEL, "pci:%04x:%02x:%02x.%d", |
151 | drm_get_pci_domain(dev), |
122 | drm_get_pci_domain(dev), |
152 | dev->pdev->bus->number, |
123 | dev->pdev->bus->number, |
- | 124 | PCI_SLOT(dev->pdev->devfn), |
|
- | 125 | PCI_FUNC(dev->pdev->devfn)); |
|
Line 153... | Line -... | ||
153 | PCI_SLOT(dev->pdev->devfn), |
- | |
154 | PCI_FUNC(dev->pdev->devfn)); |
- | |
155 | - | ||
156 | if (len >= master->unique_len) { |
- | |
157 | DRM_ERROR("buffer overflow"); |
- | |
158 | ret = -EINVAL; |
126 | if (!master->unique) |
159 | goto err; |
- | |
160 | } else |
- | |
161 | master->unique_len = len; |
- | |
162 | - | ||
163 | dev->devname = |
- | |
164 | kmalloc(strlen(pdriver->name) + |
- | |
165 | master->unique_len + 2, GFP_KERNEL); |
- | |
166 | - | ||
167 | if (dev->devname == NULL) { |
- | |
168 | ret = -ENOMEM; |
- | |
169 | goto err; |
- | |
170 | } |
- | |
171 | - | ||
172 | sprintf(dev->devname, "%s@%s", pdriver->name, |
127 | return -ENOMEM; |
173 | master->unique); |
- | |
174 | - | ||
175 | return 0; |
128 | |
- | 129 | master->unique_len = strlen(master->unique); |
|
Line 176... | Line 130... | ||
176 | err: |
130 | return 0; |
177 | return ret; |
131 | } |
178 | } |
132 | EXPORT_SYMBOL(drm_pci_set_busid); |
179 | 133 | ||
180 | static int drm_pci_set_unique(struct drm_device *dev, |
134 | int drm_pci_set_unique(struct drm_device *dev, |
181 | struct drm_master *master, |
- | |
Line 182... | Line 135... | ||
182 | struct drm_unique *u) |
135 | struct drm_master *master, |
183 | { |
- | |
184 | int domain, bus, slot, func, ret; |
136 | struct drm_unique *u) |
185 | const char *bus_name; |
137 | { |
186 | 138 | int domain, bus, slot, func, ret; |
|
187 | master->unique_len = u->unique_len; |
139 | |
188 | master->unique_size = u->unique_len + 1; |
140 | master->unique_len = u->unique_len; |
Line 197... | Line 149... | ||
197 | goto err; |
149 | goto err; |
198 | } |
150 | } |
Line 199... | Line 151... | ||
199 | 151 | ||
Line 200... | Line -... | ||
200 | master->unique[master->unique_len] = '\0'; |
- | |
201 | - | ||
202 | bus_name = dev->driver->bus->get_name(dev); |
- | |
203 | dev->devname = kmalloc(strlen(bus_name) + |
- | |
204 | strlen(master->unique) + 2, GFP_KERNEL); |
- | |
205 | if (!dev->devname) { |
- | |
206 | ret = -ENOMEM; |
- | |
207 | goto err; |
- | |
208 | } |
- | |
209 | - | ||
210 | sprintf(dev->devname, "%s@%s", bus_name, |
- | |
211 | master->unique); |
152 | master->unique[master->unique_len] = '\0'; |
212 | 153 | ||
213 | /* Return error if the busid submitted doesn't match the device's actual |
154 | /* Return error if the busid submitted doesn't match the device's actual |
214 | * busid. |
155 | * busid. |
215 | */ |
156 | */ |
Line 269... | Line 210... | ||
269 | drm_agp_clear(dev); |
210 | drm_agp_clear(dev); |
270 | kfree(dev->agp); |
211 | kfree(dev->agp); |
271 | dev->agp = NULL; |
212 | dev->agp = NULL; |
272 | } |
213 | } |
273 | } |
214 | } |
274 | - | ||
275 | static struct drm_bus drm_pci_bus = { |
- | |
276 | .bus_type = DRIVER_BUS_PCI, |
- | |
277 | .get_irq = drm_pci_get_irq, |
- | |
278 | .get_name = drm_pci_get_name, |
- | |
279 | .set_busid = drm_pci_set_busid, |
- | |
280 | .set_unique = drm_pci_set_unique, |
- | |
281 | .irq_by_busid = drm_pci_irq_by_busid, |
- | |
282 | }; |
- | |
283 | #endif |
215 | #endif |
Line 284... | Line 216... | ||
284 | 216 | ||
285 | /** |
217 | /** |
286 | * Register. |
- | |
287 | * |
218 | * drm_get_pci_dev - Register a PCI device with the DRM subsystem |
288 | * \param pdev - PCI device structure |
219 | * @pdev: PCI device |
289 | * \param ent entry from the PCI ID table with device type flags |
220 | * @ent: entry from the PCI ID table that matches @pdev |
290 | * \return zero on success or a negative number on failure. |
221 | * @driver: DRM device driver |
291 | * |
222 | * |
292 | * Attempt to gets inter module "drm" information. If we are first |
223 | * Attempt to gets inter module "drm" information. If we are first |
293 | * then register the character device and inter module information. |
224 | * then register the character device and inter module information. |
294 | * Try and register, if we fail to register, backout previous work. |
225 | * Try and register, if we fail to register, backout previous work. |
- | 226 | * |
|
- | 227 | * NOTE: This function is deprecated, please use drm_dev_alloc() and |
|
- | 228 | * drm_dev_register() instead and remove your ->load() callback. |
|
295 | * |
229 | * |
296 | * Return: 0 on success or a negative error code on failure. |
230 | * Return: 0 on success or a negative error code on failure. |
297 | */ |
231 | */ |
298 | int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent, |
232 | int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent, |
299 | struct drm_driver *driver) |
233 | struct drm_driver *driver) |