.. | .. |
---|
1 | | -/** |
---|
| 1 | +/* |
---|
2 | 2 | * \file drm_agpsupport.c |
---|
3 | 3 | * DRM support for AGP/GART backend |
---|
4 | 4 | * |
---|
.. | .. |
---|
31 | 31 | * OTHER DEALINGS IN THE SOFTWARE. |
---|
32 | 32 | */ |
---|
33 | 33 | |
---|
34 | | -#include <drm/drmP.h> |
---|
35 | 34 | #include <linux/module.h> |
---|
| 35 | +#include <linux/pci.h> |
---|
36 | 36 | #include <linux/slab.h> |
---|
37 | | -#include "drm_legacy.h" |
---|
38 | 37 | |
---|
39 | 38 | #include <asm/agp.h> |
---|
| 39 | + |
---|
| 40 | +#include <drm/drm_agpsupport.h> |
---|
| 41 | +#include <drm/drm_device.h> |
---|
| 42 | +#include <drm/drm_drv.h> |
---|
| 43 | +#include <drm/drm_file.h> |
---|
| 44 | +#include <drm/drm_print.h> |
---|
| 45 | + |
---|
| 46 | +#include "drm_legacy.h" |
---|
40 | 47 | |
---|
41 | 48 | /** |
---|
42 | 49 | * Get AGP information. |
---|
.. | .. |
---|
205 | 212 | if (!entry) |
---|
206 | 213 | return -ENOMEM; |
---|
207 | 214 | |
---|
208 | | - pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE; |
---|
| 215 | + pages = DIV_ROUND_UP(request->size, PAGE_SIZE); |
---|
209 | 216 | type = (u32) request->type; |
---|
210 | 217 | memory = agp_allocate_memory(dev->agp->bridge, pages, type); |
---|
211 | 218 | if (!memory) { |
---|
.. | .. |
---|
318 | 325 | entry = drm_agp_lookup_entry(dev, request->handle); |
---|
319 | 326 | if (!entry || entry->bound) |
---|
320 | 327 | return -EINVAL; |
---|
321 | | - page = (request->offset + PAGE_SIZE - 1) / PAGE_SIZE; |
---|
| 328 | + page = DIV_ROUND_UP(request->offset, PAGE_SIZE); |
---|
322 | 329 | retcode = drm_bind_agp(entry->memory, page); |
---|
323 | 330 | if (retcode) |
---|
324 | 331 | return retcode; |
---|
.. | .. |
---|
348 | 355 | * \return zero on success or a negative number on failure. |
---|
349 | 356 | * |
---|
350 | 357 | * Verifies the AGP device is present and has been acquired and looks up the |
---|
351 | | - * AGP memory entry. If the memory it's currently bound, unbind it via |
---|
| 358 | + * AGP memory entry. If the memory is currently bound, unbind it via |
---|
352 | 359 | * unbind_agp(). Frees it via free_agp() as well as the entry itself |
---|
353 | 360 | * and unlinks from the doubly linked list it's inserted in. |
---|
354 | 361 | */ |
---|
.. | .. |
---|
458 | 465 | dev->agp->acquired = 0; |
---|
459 | 466 | dev->agp->enabled = 0; |
---|
460 | 467 | } |
---|
461 | | - |
---|
462 | | -/** |
---|
463 | | - * Binds a collection of pages into AGP memory at the given offset, returning |
---|
464 | | - * the AGP memory structure containing them. |
---|
465 | | - * |
---|
466 | | - * No reference is held on the pages during this time -- it is up to the |
---|
467 | | - * caller to handle that. |
---|
468 | | - */ |
---|
469 | | -struct agp_memory * |
---|
470 | | -drm_agp_bind_pages(struct drm_device *dev, |
---|
471 | | - struct page **pages, |
---|
472 | | - unsigned long num_pages, |
---|
473 | | - uint32_t gtt_offset, |
---|
474 | | - u32 type) |
---|
475 | | -{ |
---|
476 | | - struct agp_memory *mem; |
---|
477 | | - int ret, i; |
---|
478 | | - |
---|
479 | | - DRM_DEBUG("\n"); |
---|
480 | | - |
---|
481 | | - mem = agp_allocate_memory(dev->agp->bridge, num_pages, |
---|
482 | | - type); |
---|
483 | | - if (mem == NULL) { |
---|
484 | | - DRM_ERROR("Failed to allocate memory for %ld pages\n", |
---|
485 | | - num_pages); |
---|
486 | | - return NULL; |
---|
487 | | - } |
---|
488 | | - |
---|
489 | | - for (i = 0; i < num_pages; i++) |
---|
490 | | - mem->pages[i] = pages[i]; |
---|
491 | | - mem->page_count = num_pages; |
---|
492 | | - |
---|
493 | | - mem->is_flushed = true; |
---|
494 | | - ret = agp_bind_memory(mem, gtt_offset / PAGE_SIZE); |
---|
495 | | - if (ret != 0) { |
---|
496 | | - DRM_ERROR("Failed to bind AGP memory: %d\n", ret); |
---|
497 | | - agp_free_memory(mem); |
---|
498 | | - return NULL; |
---|
499 | | - } |
---|
500 | | - |
---|
501 | | - return mem; |
---|
502 | | -} |
---|
503 | | -EXPORT_SYMBOL(drm_agp_bind_pages); |
---|