hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/gpu/drm/drm_agpsupport.c
....@@ -1,4 +1,4 @@
1
-/**
1
+/*
22 * \file drm_agpsupport.c
33 * DRM support for AGP/GART backend
44 *
....@@ -31,12 +31,19 @@
3131 * OTHER DEALINGS IN THE SOFTWARE.
3232 */
3333
34
-#include <drm/drmP.h>
3534 #include <linux/module.h>
35
+#include <linux/pci.h>
3636 #include <linux/slab.h>
37
-#include "drm_legacy.h"
3837
3938 #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"
4047
4148 /**
4249 * Get AGP information.
....@@ -205,7 +212,7 @@
205212 if (!entry)
206213 return -ENOMEM;
207214
208
- pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE;
215
+ pages = DIV_ROUND_UP(request->size, PAGE_SIZE);
209216 type = (u32) request->type;
210217 memory = agp_allocate_memory(dev->agp->bridge, pages, type);
211218 if (!memory) {
....@@ -318,7 +325,7 @@
318325 entry = drm_agp_lookup_entry(dev, request->handle);
319326 if (!entry || entry->bound)
320327 return -EINVAL;
321
- page = (request->offset + PAGE_SIZE - 1) / PAGE_SIZE;
328
+ page = DIV_ROUND_UP(request->offset, PAGE_SIZE);
322329 retcode = drm_bind_agp(entry->memory, page);
323330 if (retcode)
324331 return retcode;
....@@ -348,7 +355,7 @@
348355 * \return zero on success or a negative number on failure.
349356 *
350357 * 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
352359 * unbind_agp(). Frees it via free_agp() as well as the entry itself
353360 * and unlinks from the doubly linked list it's inserted in.
354361 */
....@@ -458,46 +465,3 @@
458465 dev->agp->acquired = 0;
459466 dev->agp->enabled = 0;
460467 }
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);