Deleted Added
full compact
drm_bufs.c (183603) drm_bufs.c (183833)
1/*-
2 * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
3 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation

--- 15 unchanged lines hidden (view full) ---

24 *
25 * Authors:
26 * Rickard E. (Rik) Faith <faith@valinux.com>
27 * Gareth Hughes <gareth@valinux.com>
28 *
29 */
30
31#include <sys/cdefs.h>
1/*-
2 * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
3 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation

--- 15 unchanged lines hidden (view full) ---

24 *
25 * Authors:
26 * Rickard E. (Rik) Faith <faith@valinux.com>
27 * Gareth Hughes <gareth@valinux.com>
28 *
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/sys/dev/drm/drm_bufs.c 183603 2008-10-04 14:45:34Z rnoland $");
32__FBSDID("$FreeBSD: head/sys/dev/drm/drm_bufs.c 183833 2008-10-13 18:03:27Z rnoland $");
33
34/** @file drm_bufs.c
35 * Implementation of the ioctls for setup of DRM mappings and DMA buffers.
36 */
37
38#include "dev/pci/pcireg.h"
39
40#include "dev/drm/drmP.h"

--- 92 unchanged lines hidden (view full) ---

133 }
134 }
135 }
136 DRM_UNLOCK();
137
138 /* Allocate a new map structure, fill it in, and do any type-specific
139 * initialization necessary.
140 */
33
34/** @file drm_bufs.c
35 * Implementation of the ioctls for setup of DRM mappings and DMA buffers.
36 */
37
38#include "dev/pci/pcireg.h"
39
40#include "dev/drm/drmP.h"

--- 92 unchanged lines hidden (view full) ---

133 }
134 }
135 }
136 DRM_UNLOCK();
137
138 /* Allocate a new map structure, fill it in, and do any type-specific
139 * initialization necessary.
140 */
141 map = malloc(sizeof(*map), M_DRM, M_ZERO | M_NOWAIT);
141 map = malloc(sizeof(*map), DRM_MEM_MAPS, M_ZERO | M_NOWAIT);
142 if (!map) {
143 DRM_LOCK();
144 return ENOMEM;
145 }
146
147 map->offset = offset;
148 map->size = size;
149 map->type = type;

--- 5 unchanged lines hidden (view full) ---

155 if (!(map->flags & _DRM_WRITE_COMBINING))
156 break;
157 /* FALLTHROUGH */
158 case _DRM_FRAME_BUFFER:
159 if (drm_mtrr_add(map->offset, map->size, DRM_MTRR_WC) == 0)
160 map->mtrr = 1;
161 break;
162 case _DRM_SHM:
142 if (!map) {
143 DRM_LOCK();
144 return ENOMEM;
145 }
146
147 map->offset = offset;
148 map->size = size;
149 map->type = type;

--- 5 unchanged lines hidden (view full) ---

155 if (!(map->flags & _DRM_WRITE_COMBINING))
156 break;
157 /* FALLTHROUGH */
158 case _DRM_FRAME_BUFFER:
159 if (drm_mtrr_add(map->offset, map->size, DRM_MTRR_WC) == 0)
160 map->mtrr = 1;
161 break;
162 case _DRM_SHM:
163 map->handle = malloc(map->size, M_DRM, M_NOWAIT);
163 map->handle = malloc(map->size, DRM_MEM_MAPS, M_NOWAIT);
164 DRM_DEBUG("%lu %d %p\n",
165 map->size, drm_order(map->size), map->handle);
166 if (!map->handle) {
164 DRM_DEBUG("%lu %d %p\n",
165 map->size, drm_order(map->size), map->handle);
166 if (!map->handle) {
167 free(map, M_DRM);
167 free(map, DRM_MEM_MAPS);
168 DRM_LOCK();
169 return ENOMEM;
170 }
171 map->offset = (unsigned long)map->handle;
172 if (map->flags & _DRM_CONTAINS_LOCK) {
173 /* Prevent a 2nd X Server from creating a 2nd lock */
174 DRM_LOCK();
175 if (dev->lock.hw_lock != NULL) {
176 DRM_UNLOCK();
168 DRM_LOCK();
169 return ENOMEM;
170 }
171 map->offset = (unsigned long)map->handle;
172 if (map->flags & _DRM_CONTAINS_LOCK) {
173 /* Prevent a 2nd X Server from creating a 2nd lock */
174 DRM_LOCK();
175 if (dev->lock.hw_lock != NULL) {
176 DRM_UNLOCK();
177 free(map->handle, M_DRM);
178 free(map, M_DRM);
177 free(map->handle, DRM_MEM_MAPS);
178 free(map, DRM_MEM_MAPS);
179 return EBUSY;
180 }
181 dev->lock.hw_lock = map->handle; /* Pointer to lock */
182 DRM_UNLOCK();
183 }
184 break;
185 case _DRM_AGP:
186 /*valid = 0;*/

--- 13 unchanged lines hidden (view full) ---

200 if ((map->offset >= entry->bound) &&
201 (map->offset + map->size <=
202 entry->bound + entry->pages * PAGE_SIZE)) {
203 valid = 1;
204 break;
205 }
206 }
207 if (!valid) {
179 return EBUSY;
180 }
181 dev->lock.hw_lock = map->handle; /* Pointer to lock */
182 DRM_UNLOCK();
183 }
184 break;
185 case _DRM_AGP:
186 /*valid = 0;*/

--- 13 unchanged lines hidden (view full) ---

200 if ((map->offset >= entry->bound) &&
201 (map->offset + map->size <=
202 entry->bound + entry->pages * PAGE_SIZE)) {
203 valid = 1;
204 break;
205 }
206 }
207 if (!valid) {
208 free(map, M_DRM);
208 free(map, DRM_MEM_MAPS);
209 DRM_LOCK();
210 return EACCES;
211 }*/
212 break;
213 case _DRM_SCATTER_GATHER:
214 if (!dev->sg) {
209 DRM_LOCK();
210 return EACCES;
211 }*/
212 break;
213 case _DRM_SCATTER_GATHER:
214 if (!dev->sg) {
215 free(map, M_DRM);
215 free(map, DRM_MEM_MAPS);
216 DRM_LOCK();
217 return EINVAL;
218 }
219 map->offset = map->offset + dev->sg->handle;
220 break;
221 case _DRM_CONSISTENT:
222 /* Unfortunately, we don't get any alignment specification from
223 * the caller, so we have to guess. drm_pci_alloc requires
224 * a power-of-two alignment, so try to align the bus address of
225 * the map to it size if possible, otherwise just assume
226 * PAGE_SIZE alignment.
227 */
228 align = map->size;
229 if ((align & (align - 1)) != 0)
230 align = PAGE_SIZE;
231 map->dmah = drm_pci_alloc(dev, map->size, align, 0xfffffffful);
232 if (map->dmah == NULL) {
216 DRM_LOCK();
217 return EINVAL;
218 }
219 map->offset = map->offset + dev->sg->handle;
220 break;
221 case _DRM_CONSISTENT:
222 /* Unfortunately, we don't get any alignment specification from
223 * the caller, so we have to guess. drm_pci_alloc requires
224 * a power-of-two alignment, so try to align the bus address of
225 * the map to it size if possible, otherwise just assume
226 * PAGE_SIZE alignment.
227 */
228 align = map->size;
229 if ((align & (align - 1)) != 0)
230 align = PAGE_SIZE;
231 map->dmah = drm_pci_alloc(dev, map->size, align, 0xfffffffful);
232 if (map->dmah == NULL) {
233 free(map, M_DRM);
233 free(map, DRM_MEM_MAPS);
234 DRM_LOCK();
235 return ENOMEM;
236 }
237 map->handle = map->dmah->vaddr;
238 map->offset = map->dmah->busaddr;
239 break;
240 default:
241 DRM_ERROR("Bad map type %d\n", map->type);
234 DRM_LOCK();
235 return ENOMEM;
236 }
237 map->handle = map->dmah->vaddr;
238 map->offset = map->dmah->busaddr;
239 break;
240 default:
241 DRM_ERROR("Bad map type %d\n", map->type);
242 free(map, M_DRM);
242 free(map, DRM_MEM_MAPS);
243 DRM_LOCK();
244 return EINVAL;
245 }
246
247 DRM_LOCK();
248 TAILQ_INSERT_TAIL(&dev->maplist, map, link);
249
250done:

--- 57 unchanged lines hidden (view full) ---

308 int __unused retcode;
309
310 retcode = drm_mtrr_del(0, map->offset, map->size,
311 DRM_MTRR_WC);
312 DRM_DEBUG("mtrr_del = %d\n", retcode);
313 }
314 break;
315 case _DRM_SHM:
243 DRM_LOCK();
244 return EINVAL;
245 }
246
247 DRM_LOCK();
248 TAILQ_INSERT_TAIL(&dev->maplist, map, link);
249
250done:

--- 57 unchanged lines hidden (view full) ---

308 int __unused retcode;
309
310 retcode = drm_mtrr_del(0, map->offset, map->size,
311 DRM_MTRR_WC);
312 DRM_DEBUG("mtrr_del = %d\n", retcode);
313 }
314 break;
315 case _DRM_SHM:
316 free(map->handle, M_DRM);
316 free(map->handle, DRM_MEM_MAPS);
317 break;
318 case _DRM_AGP:
319 case _DRM_SCATTER_GATHER:
320 break;
321 case _DRM_CONSISTENT:
322 drm_pci_free(dev, map->dmah);
323 break;
324 default:
325 DRM_ERROR("Bad map type %d\n", map->type);
326 break;
327 }
328
329 if (map->bsr != NULL) {
330 bus_release_resource(dev->device, SYS_RES_MEMORY, map->rid,
331 map->bsr);
332 }
333
317 break;
318 case _DRM_AGP:
319 case _DRM_SCATTER_GATHER:
320 break;
321 case _DRM_CONSISTENT:
322 drm_pci_free(dev, map->dmah);
323 break;
324 default:
325 DRM_ERROR("Bad map type %d\n", map->type);
326 break;
327 }
328
329 if (map->bsr != NULL) {
330 bus_release_resource(dev->device, SYS_RES_MEMORY, map->rid,
331 map->bsr);
332 }
333
334 free(map, M_DRM);
334 free(map, DRM_MEM_MAPS);
335}
336
337/* Remove a map private from list and deallocate resources if the mapping
338 * isn't in use.
339 */
340
341int drm_rmmap_ioctl(struct drm_device *dev, void *data,
342 struct drm_file *file_priv)

--- 26 unchanged lines hidden (view full) ---

369 drm_buf_entry_t *entry)
370{
371 int i;
372
373 if (entry->seg_count) {
374 for (i = 0; i < entry->seg_count; i++) {
375 drm_pci_free(dev, entry->seglist[i]);
376 }
335}
336
337/* Remove a map private from list and deallocate resources if the mapping
338 * isn't in use.
339 */
340
341int drm_rmmap_ioctl(struct drm_device *dev, void *data,
342 struct drm_file *file_priv)

--- 26 unchanged lines hidden (view full) ---

369 drm_buf_entry_t *entry)
370{
371 int i;
372
373 if (entry->seg_count) {
374 for (i = 0; i < entry->seg_count; i++) {
375 drm_pci_free(dev, entry->seglist[i]);
376 }
377 free(entry->seglist, M_DRM);
377 free(entry->seglist, DRM_MEM_SEGS);
378
379 entry->seg_count = 0;
380 }
381
382 if (entry->buf_count) {
383 for (i = 0; i < entry->buf_count; i++) {
378
379 entry->seg_count = 0;
380 }
381
382 if (entry->buf_count) {
383 for (i = 0; i < entry->buf_count; i++) {
384 free(entry->buflist[i].dev_private, M_DRM);
384 free(entry->buflist[i].dev_private, DRM_MEM_BUFS);
385 }
385 }
386 free(entry->buflist, M_DRM);
386 free(entry->buflist, DRM_MEM_BUFS);
387
388 entry->buf_count = 0;
389 }
390}
391
392static int drm_do_addbufs_agp(struct drm_device *dev, struct drm_buf_desc *request)
393{
394 drm_device_dma_t *dma = dev->dma;

--- 50 unchanged lines hidden (view full) ---

445 }
446 if (!valid) {
447 DRM_DEBUG("zone invalid\n");
448 return EINVAL;
449 }*/
450
451 entry = &dma->bufs[order];
452
387
388 entry->buf_count = 0;
389 }
390}
391
392static int drm_do_addbufs_agp(struct drm_device *dev, struct drm_buf_desc *request)
393{
394 drm_device_dma_t *dma = dev->dma;

--- 50 unchanged lines hidden (view full) ---

445 }
446 if (!valid) {
447 DRM_DEBUG("zone invalid\n");
448 return EINVAL;
449 }*/
450
451 entry = &dma->bufs[order];
452
453 entry->buflist = malloc(count * sizeof(*entry->buflist), M_DRM,
453 entry->buflist = malloc(count * sizeof(*entry->buflist), DRM_MEM_BUFS,
454 M_NOWAIT | M_ZERO);
455 if (!entry->buflist) {
456 return ENOMEM;
457 }
458
459 entry->buf_size = size;
460 entry->page_order = page_order;
461

--- 9 unchanged lines hidden (view full) ---

471 buf->offset = (dma->byte_count + offset);
472 buf->bus_address = agp_offset + offset;
473 buf->address = (void *)(agp_offset + offset);
474 buf->next = NULL;
475 buf->pending = 0;
476 buf->file_priv = NULL;
477
478 buf->dev_priv_size = dev->driver->buf_priv_size;
454 M_NOWAIT | M_ZERO);
455 if (!entry->buflist) {
456 return ENOMEM;
457 }
458
459 entry->buf_size = size;
460 entry->page_order = page_order;
461

--- 9 unchanged lines hidden (view full) ---

471 buf->offset = (dma->byte_count + offset);
472 buf->bus_address = agp_offset + offset;
473 buf->address = (void *)(agp_offset + offset);
474 buf->next = NULL;
475 buf->pending = 0;
476 buf->file_priv = NULL;
477
478 buf->dev_priv_size = dev->driver->buf_priv_size;
479 buf->dev_private = malloc(buf->dev_priv_size, M_DRM,
479 buf->dev_private = malloc(buf->dev_priv_size, DRM_MEM_BUFS,
480 M_NOWAIT | M_ZERO);
481 if (buf->dev_private == NULL) {
482 /* Set count correctly so we free the proper amount. */
483 entry->buf_count = count;
484 drm_cleanup_buf_error(dev, entry);
485 return ENOMEM;
486 }
487
488 offset += alignment;
489 entry->buf_count++;
490 byte_count += PAGE_SIZE << page_order;
491 }
492
493 DRM_DEBUG("byte_count: %d\n", byte_count);
494
495 temp_buflist = realloc(dma->buflist,
480 M_NOWAIT | M_ZERO);
481 if (buf->dev_private == NULL) {
482 /* Set count correctly so we free the proper amount. */
483 entry->buf_count = count;
484 drm_cleanup_buf_error(dev, entry);
485 return ENOMEM;
486 }
487
488 offset += alignment;
489 entry->buf_count++;
490 byte_count += PAGE_SIZE << page_order;
491 }
492
493 DRM_DEBUG("byte_count: %d\n", byte_count);
494
495 temp_buflist = realloc(dma->buflist,
496 (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), M_DRM,
497 M_NOWAIT);
496 (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist),
497 DRM_MEM_BUFS, M_NOWAIT);
498 if (temp_buflist == NULL) {
499 /* Free the entry because it isn't valid */
500 drm_cleanup_buf_error(dev, entry);
501 return ENOMEM;
502 }
503 dma->buflist = temp_buflist;
504
505 for (i = 0; i < entry->buf_count; i++) {

--- 41 unchanged lines hidden (view full) ---

547
548 alignment = (request->flags & _DRM_PAGE_ALIGN)
549 ? round_page(size) : size;
550 page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0;
551 total = PAGE_SIZE << page_order;
552
553 entry = &dma->bufs[order];
554
498 if (temp_buflist == NULL) {
499 /* Free the entry because it isn't valid */
500 drm_cleanup_buf_error(dev, entry);
501 return ENOMEM;
502 }
503 dma->buflist = temp_buflist;
504
505 for (i = 0; i < entry->buf_count; i++) {

--- 41 unchanged lines hidden (view full) ---

547
548 alignment = (request->flags & _DRM_PAGE_ALIGN)
549 ? round_page(size) : size;
550 page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0;
551 total = PAGE_SIZE << page_order;
552
553 entry = &dma->bufs[order];
554
555 entry->buflist = malloc(count * sizeof(*entry->buflist), M_DRM,
555 entry->buflist = malloc(count * sizeof(*entry->buflist), DRM_MEM_BUFS,
556 M_NOWAIT | M_ZERO);
556 M_NOWAIT | M_ZERO);
557 entry->seglist = malloc(count * sizeof(*entry->seglist), M_DRM,
557 entry->seglist = malloc(count * sizeof(*entry->seglist), DRM_MEM_SEGS,
558 M_NOWAIT | M_ZERO);
559
560 /* Keep the original pagelist until we know all the allocations
561 * have succeeded
562 */
563 temp_pagelist = malloc((dma->page_count + (count << page_order)) *
558 M_NOWAIT | M_ZERO);
559
560 /* Keep the original pagelist until we know all the allocations
561 * have succeeded
562 */
563 temp_pagelist = malloc((dma->page_count + (count << page_order)) *
564 sizeof(*dma->pagelist), M_DRM, M_NOWAIT);
564 sizeof(*dma->pagelist), DRM_MEM_PAGES, M_NOWAIT);
565
566 if (entry->buflist == NULL || entry->seglist == NULL ||
567 temp_pagelist == NULL) {
565
566 if (entry->buflist == NULL || entry->seglist == NULL ||
567 temp_pagelist == NULL) {
568 free(temp_pagelist, M_DRM);
569 free(entry->seglist, M_DRM);
570 free(entry->buflist, M_DRM);
568 free(temp_pagelist, DRM_MEM_PAGES);
569 free(entry->seglist, DRM_MEM_SEGS);
570 free(entry->buflist, DRM_MEM_BUFS);
571 return ENOMEM;
572 }
573
574 memcpy(temp_pagelist, dma->pagelist, dma->page_count *
575 sizeof(*dma->pagelist));
576
577 DRM_DEBUG("pagelist: %d entries\n",
578 dma->page_count + (count << page_order));

--- 8 unchanged lines hidden (view full) ---

587 drm_dma_handle_t *dmah = drm_pci_alloc(dev, size, alignment,
588 0xfffffffful);
589 DRM_SPINLOCK(&dev->dma_lock);
590 if (dmah == NULL) {
591 /* Set count correctly so we free the proper amount. */
592 entry->buf_count = count;
593 entry->seg_count = count;
594 drm_cleanup_buf_error(dev, entry);
571 return ENOMEM;
572 }
573
574 memcpy(temp_pagelist, dma->pagelist, dma->page_count *
575 sizeof(*dma->pagelist));
576
577 DRM_DEBUG("pagelist: %d entries\n",
578 dma->page_count + (count << page_order));

--- 8 unchanged lines hidden (view full) ---

587 drm_dma_handle_t *dmah = drm_pci_alloc(dev, size, alignment,
588 0xfffffffful);
589 DRM_SPINLOCK(&dev->dma_lock);
590 if (dmah == NULL) {
591 /* Set count correctly so we free the proper amount. */
592 entry->buf_count = count;
593 entry->seg_count = count;
594 drm_cleanup_buf_error(dev, entry);
595 free(temp_pagelist, M_DRM);
595 free(temp_pagelist, DRM_MEM_PAGES);
596 return ENOMEM;
597 }
598
599 entry->seglist[entry->seg_count++] = dmah;
600 for (i = 0; i < (1 << page_order); i++) {
601 DRM_DEBUG("page %d @ %p\n",
602 dma->page_count + page_count,
603 (char *)dmah->vaddr + PAGE_SIZE * i);

--- 11 unchanged lines hidden (view full) ---

615 buf->offset = (dma->byte_count + byte_count + offset);
616 buf->address = ((char *)dmah->vaddr + offset);
617 buf->bus_address = dmah->busaddr + offset;
618 buf->next = NULL;
619 buf->pending = 0;
620 buf->file_priv = NULL;
621
622 buf->dev_priv_size = dev->driver->buf_priv_size;
596 return ENOMEM;
597 }
598
599 entry->seglist[entry->seg_count++] = dmah;
600 for (i = 0; i < (1 << page_order); i++) {
601 DRM_DEBUG("page %d @ %p\n",
602 dma->page_count + page_count,
603 (char *)dmah->vaddr + PAGE_SIZE * i);

--- 11 unchanged lines hidden (view full) ---

615 buf->offset = (dma->byte_count + byte_count + offset);
616 buf->address = ((char *)dmah->vaddr + offset);
617 buf->bus_address = dmah->busaddr + offset;
618 buf->next = NULL;
619 buf->pending = 0;
620 buf->file_priv = NULL;
621
622 buf->dev_priv_size = dev->driver->buf_priv_size;
623 buf->dev_private = malloc(buf->dev_priv_size, M_DRM,
624 M_NOWAIT | M_ZERO);
623 buf->dev_private = malloc(buf->dev_priv_size,
624 DRM_MEM_BUFS, M_NOWAIT | M_ZERO);
625 if (buf->dev_private == NULL) {
626 /* Set count correctly so we free the proper amount. */
627 entry->buf_count = count;
628 entry->seg_count = count;
629 drm_cleanup_buf_error(dev, entry);
625 if (buf->dev_private == NULL) {
626 /* Set count correctly so we free the proper amount. */
627 entry->buf_count = count;
628 entry->seg_count = count;
629 drm_cleanup_buf_error(dev, entry);
630 free(temp_pagelist, M_DRM);
630 free(temp_pagelist, DRM_MEM_PAGES);
631 return ENOMEM;
632 }
633
634 DRM_DEBUG("buffer %d @ %p\n",
635 entry->buf_count, buf->address);
636 }
637 byte_count += PAGE_SIZE << page_order;
638 }
639
640 temp_buflist = realloc(dma->buflist,
631 return ENOMEM;
632 }
633
634 DRM_DEBUG("buffer %d @ %p\n",
635 entry->buf_count, buf->address);
636 }
637 byte_count += PAGE_SIZE << page_order;
638 }
639
640 temp_buflist = realloc(dma->buflist,
641 (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), M_DRM,
642 M_NOWAIT);
641 (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist),
642 DRM_MEM_BUFS, M_NOWAIT);
643 if (temp_buflist == NULL) {
644 /* Free the entry because it isn't valid */
645 drm_cleanup_buf_error(dev, entry);
643 if (temp_buflist == NULL) {
644 /* Free the entry because it isn't valid */
645 drm_cleanup_buf_error(dev, entry);
646 free(temp_pagelist, M_DRM);
646 free(temp_pagelist, DRM_MEM_PAGES);
647 return ENOMEM;
648 }
649 dma->buflist = temp_buflist;
650
651 for (i = 0; i < entry->buf_count; i++) {
652 dma->buflist[i + dma->buf_count] = &entry->buflist[i];
653 }
654
655 /* No allocations failed, so now we can replace the orginal pagelist
656 * with the new one.
657 */
647 return ENOMEM;
648 }
649 dma->buflist = temp_buflist;
650
651 for (i = 0; i < entry->buf_count; i++) {
652 dma->buflist[i + dma->buf_count] = &entry->buflist[i];
653 }
654
655 /* No allocations failed, so now we can replace the orginal pagelist
656 * with the new one.
657 */
658 free(dma->pagelist, M_DRM);
658 free(dma->pagelist, DRM_MEM_PAGES);
659 dma->pagelist = temp_pagelist;
660
661 dma->buf_count += entry->buf_count;
662 dma->seg_count += entry->seg_count;
663 dma->page_count += entry->seg_count << page_order;
664 dma->byte_count += PAGE_SIZE * (entry->seg_count << page_order);
665
666 request->count = entry->buf_count;

--- 37 unchanged lines hidden (view full) ---

704 DRM_DEBUG("size: %d\n", size);
705 DRM_DEBUG("agp_offset: %ld\n", agp_offset);
706 DRM_DEBUG("alignment: %d\n", alignment);
707 DRM_DEBUG("page_order: %d\n", page_order);
708 DRM_DEBUG("total: %d\n", total);
709
710 entry = &dma->bufs[order];
711
659 dma->pagelist = temp_pagelist;
660
661 dma->buf_count += entry->buf_count;
662 dma->seg_count += entry->seg_count;
663 dma->page_count += entry->seg_count << page_order;
664 dma->byte_count += PAGE_SIZE * (entry->seg_count << page_order);
665
666 request->count = entry->buf_count;

--- 37 unchanged lines hidden (view full) ---

704 DRM_DEBUG("size: %d\n", size);
705 DRM_DEBUG("agp_offset: %ld\n", agp_offset);
706 DRM_DEBUG("alignment: %d\n", alignment);
707 DRM_DEBUG("page_order: %d\n", page_order);
708 DRM_DEBUG("total: %d\n", total);
709
710 entry = &dma->bufs[order];
711
712 entry->buflist = malloc(count * sizeof(*entry->buflist), M_DRM,
712 entry->buflist = malloc(count * sizeof(*entry->buflist), DRM_MEM_BUFS,
713 M_NOWAIT | M_ZERO);
714 if (entry->buflist == NULL)
715 return ENOMEM;
716
717 entry->buf_size = size;
718 entry->page_order = page_order;
719
720 offset = 0;

--- 8 unchanged lines hidden (view full) ---

729 buf->offset = (dma->byte_count + offset);
730 buf->bus_address = agp_offset + offset;
731 buf->address = (void *)(agp_offset + offset + dev->sg->handle);
732 buf->next = NULL;
733 buf->pending = 0;
734 buf->file_priv = NULL;
735
736 buf->dev_priv_size = dev->driver->buf_priv_size;
713 M_NOWAIT | M_ZERO);
714 if (entry->buflist == NULL)
715 return ENOMEM;
716
717 entry->buf_size = size;
718 entry->page_order = page_order;
719
720 offset = 0;

--- 8 unchanged lines hidden (view full) ---

729 buf->offset = (dma->byte_count + offset);
730 buf->bus_address = agp_offset + offset;
731 buf->address = (void *)(agp_offset + offset + dev->sg->handle);
732 buf->next = NULL;
733 buf->pending = 0;
734 buf->file_priv = NULL;
735
736 buf->dev_priv_size = dev->driver->buf_priv_size;
737 buf->dev_private = malloc(buf->dev_priv_size, M_DRM,
737 buf->dev_private = malloc(buf->dev_priv_size, DRM_MEM_BUFS,
738 M_NOWAIT | M_ZERO);
739 if (buf->dev_private == NULL) {
740 /* Set count correctly so we free the proper amount. */
741 entry->buf_count = count;
742 drm_cleanup_buf_error(dev, entry);
743 return ENOMEM;
744 }
745
746 DRM_DEBUG("buffer %d @ %p\n",
747 entry->buf_count, buf->address);
748
749 offset += alignment;
750 entry->buf_count++;
751 byte_count += PAGE_SIZE << page_order;
752 }
753
754 DRM_DEBUG("byte_count: %d\n", byte_count);
755
756 temp_buflist = realloc(dma->buflist,
738 M_NOWAIT | M_ZERO);
739 if (buf->dev_private == NULL) {
740 /* Set count correctly so we free the proper amount. */
741 entry->buf_count = count;
742 drm_cleanup_buf_error(dev, entry);
743 return ENOMEM;
744 }
745
746 DRM_DEBUG("buffer %d @ %p\n",
747 entry->buf_count, buf->address);
748
749 offset += alignment;
750 entry->buf_count++;
751 byte_count += PAGE_SIZE << page_order;
752 }
753
754 DRM_DEBUG("byte_count: %d\n", byte_count);
755
756 temp_buflist = realloc(dma->buflist,
757 (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), M_DRM,
758 M_NOWAIT);
757 (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist),
758 DRM_MEM_BUFS, M_NOWAIT);
759 if (temp_buflist == NULL) {
760 /* Free the entry because it isn't valid */
761 drm_cleanup_buf_error(dev, entry);
762 return ENOMEM;
763 }
764 dma->buflist = temp_buflist;
765
766 for (i = 0; i < entry->buf_count; i++) {

--- 348 unchanged lines hidden ---
759 if (temp_buflist == NULL) {
760 /* Free the entry because it isn't valid */
761 drm_cleanup_buf_error(dev, entry);
762 return ENOMEM;
763 }
764 dma->buflist = temp_buflist;
765
766 for (i = 0; i < entry->buf_count; i++) {

--- 348 unchanged lines hidden ---