2 * drm_bufs.h -- Generic buffer template -*- linux-c -*-
3 * Created: Thu Nov 23 03:10:50 2000 by gareth@valinux.com
6 * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
7 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
8 * Copyright (c) 2009, Intel Corporation.
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice (including the next
19 * paragraph) shall be included in all copies or substantial portions of the
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 * OTHER DEALINGS IN THE SOFTWARE.
31 * Rickard E. (Rik) Faith <faith@valinux.com>
32 * Gareth Hughes <gareth@valinux.com>
37 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
38 * Use is subject to license terms.
42 #include <sys/gfx_private.h>
46 #define PAGE_MASK (PAGE_SIZE-1)
47 #define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK)
50 * Compute order. Can be made faster.
53 drm_order(unsigned long size
)
56 unsigned long tmp
= size
;
61 if (size
& ~(1 << order
))
67 static inline drm_local_map_t
*
68 drm_find_map(drm_device_t
*dev
, uoff_t offset
, int type
)
72 TAILQ_FOREACH(map
, &dev
->maplist
, link
) {
73 if ((map
->type
== type
) && ((map
->offset
== offset
) ||
74 (map
->flags
== _DRM_CONTAINS_LOCK
) &&
75 (map
->type
== _DRM_SHM
)))
82 int drm_addmap(drm_device_t
*dev
, unsigned long offset
,
83 unsigned long size
, drm_map_type_t type
,
84 drm_map_flags_t flags
, drm_local_map_t
**map_ptr
)
91 * Only allow shared memory to be removable since we only keep
92 * enough book keeping information about shared memory to allow
93 * for removal when processes fork.
95 if ((flags
& _DRM_REMOVABLE
) && type
!= _DRM_SHM
)
97 if ((offset
& PAGE_MASK
) || (size
& PAGE_MASK
))
99 if (offset
+ size
< offset
)
103 * Check if this is just another version of a kernel-allocated
104 * map, and just hand that back if so.
106 map
= drm_find_map(dev
, offset
, type
);
112 * Allocate a new map structure, fill it in, and do any
113 * type-specific initialization necessary.
115 map
= drm_alloc(sizeof (*map
), DRM_MEM_MAPS
);
119 map
->offset
= offset
;
126 case _DRM_FRAME_BUFFER
:
127 retval
= drm_ioremap(dev
, map
);
134 * ddi_umem_alloc() grants page-aligned memory. We needn't
135 * handle alignment issue here.
137 map
->handle
= ddi_umem_alloc(map
->size
,
138 DDI_UMEM_NOSLEEP
, &map
->drm_umem_cookie
);
140 DRM_ERROR("drm_addmap: ddi_umem_alloc failed");
141 drm_free(map
, sizeof (*map
), DRM_MEM_MAPS
);
145 * record only low 32-bit of this handle, since 32-bit
146 * user app is incapable of passing in 64bit offset when
149 map
->offset
= (uintptr_t)map
->handle
;
150 map
->offset
&= 0xffffffffUL
;
151 if (map
->flags
& _DRM_CONTAINS_LOCK
) {
152 /* Prevent a 2nd X Server from creating a 2nd lock */
153 if (dev
->lock
.hw_lock
!= NULL
) {
154 ddi_umem_free(map
->drm_umem_cookie
);
155 drm_free(map
, sizeof (*map
), DRM_MEM_MAPS
);
158 dev
->lock
.hw_lock
= map
->handle
; /* Pointer to lock */
160 map
->dev_addr
= map
->handle
;
162 case _DRM_SCATTER_GATHER
:
164 drm_free(map
, sizeof (*map
), DRM_MEM_MAPS
);
167 map
->offset
+= (uintptr_t)dev
->sg
->virtual;
168 map
->handle
= (void *)(uintptr_t)map
->offset
;
169 map
->dev_addr
= dev
->sg
->virtual;
170 map
->dev_handle
= dev
->sg
->dmah_sg
->acc_hdl
;
173 case _DRM_CONSISTENT
:
174 DRM_ERROR("%d DRM_AGP_CONSISTENT", __LINE__
);
177 map
->offset
+= dev
->agp
->base
;
178 kva
= gfxp_map_kernel_space(map
->offset
, map
->size
,
179 GFXP_MEMORY_WRITECOMBINED
);
181 drm_free(map
, sizeof (*map
), DRM_MEM_MAPS
);
183 "drm_addmap: failed to map AGP aperture");
186 map
->handle
= (void *)(uintptr_t)kva
;
190 drm_free(map
, sizeof (*map
), DRM_MEM_MAPS
);
194 TAILQ_INSERT_TAIL(&dev
->maplist
, map
, link
);
197 /* Jumped to, with lock held, when a kernel map is found. */
205 drm_addmap_ioctl(DRM_IOCTL_ARGS
)
208 drm_local_map_t
*map
;
212 #ifdef _MULTI_DATAMODEL
213 if (ddi_model_convert_from(mode
& FMODELS
) == DDI_MODEL_ILP32
) {
214 drm_map_32_t request32
;
215 DRM_COPYFROM_WITH_RETURN(&request32
,
216 (void *)data
, sizeof (request32
));
217 request
.offset
= request32
.offset
;
218 request
.size
= request32
.size
;
219 request
.type
= request32
.type
;
220 request
.flags
= request32
.flags
;
221 request
.mtrr
= request32
.mtrr
;
224 DRM_COPYFROM_WITH_RETURN(&request
,
225 (void *)data
, sizeof (request
));
227 err
= drm_addmap(dev
, request
.offset
, request
.size
, request
.type
,
228 request
.flags
, &map
);
233 request
.offset
= map
->offset
;
234 request
.size
= map
->size
;
235 request
.type
= map
->type
;
236 request
.flags
= map
->flags
;
237 request
.mtrr
= map
->mtrr
;
238 request
.handle
= (uintptr_t)map
->handle
;
240 #ifdef _MULTI_DATAMODEL
241 if (ddi_model_convert_from(mode
& FMODELS
) == DDI_MODEL_ILP32
) {
242 drm_map_32_t request32
;
243 request32
.offset
= request
.offset
;
244 request32
.size
= (uint32_t)request
.size
;
245 request32
.type
= request
.type
;
246 request32
.flags
= request
.flags
;
247 request32
.handle
= request
.handle
;
248 request32
.mtrr
= request
.mtrr
;
249 DRM_COPYTO_WITH_RETURN((void *)data
,
250 &request32
, sizeof (request32
));
253 DRM_COPYTO_WITH_RETURN((void *)data
,
254 &request
, sizeof (request
));
260 drm_rmmap(drm_device_t
*dev
, drm_local_map_t
*map
)
262 DRM_SPINLOCK_ASSERT(&dev
->dev_lock
);
264 TAILQ_REMOVE(&dev
->maplist
, map
, link
);
268 drm_ioremapfree(map
);
271 case _DRM_FRAME_BUFFER
:
272 drm_ioremapfree(map
);
275 ddi_umem_free(map
->drm_umem_cookie
);
279 * we mapped AGP aperture into kernel space in drm_addmap,
280 * here, unmap them and release kernel virtual address space
282 gfxp_unmap_kernel_space(map
->dev_addr
, map
->size
);
285 case _DRM_SCATTER_GATHER
:
287 case _DRM_CONSISTENT
:
293 drm_free(map
, sizeof (*map
), DRM_MEM_MAPS
);
297 * Remove a map private from list and deallocate resources if the
298 * mapping isn't in use.
302 drm_rmmap_ioctl(DRM_IOCTL_ARGS
)
305 drm_local_map_t
*map
;
308 #ifdef _MULTI_DATAMODEL
309 if (ddi_model_convert_from(mode
& FMODELS
) == DDI_MODEL_ILP32
) {
310 drm_map_32_t request32
;
311 DRM_COPYFROM_WITH_RETURN(&request32
,
312 (void *)data
, sizeof (drm_map_32_t
));
313 request
.offset
= request32
.offset
;
314 request
.size
= request32
.size
;
315 request
.type
= request32
.type
;
316 request
.flags
= request32
.flags
;
317 request
.handle
= request32
.handle
;
318 request
.mtrr
= request32
.mtrr
;
321 DRM_COPYFROM_WITH_RETURN(&request
,
322 (void *)data
, sizeof (request
));
325 TAILQ_FOREACH(map
, &dev
->maplist
, link
) {
326 if (((uintptr_t)map
->handle
== (request
.handle
& 0xffffffff)) &&
327 (map
->flags
& _DRM_REMOVABLE
))
331 /* No match found. */
345 drm_cleanup_buf_error(drm_device_t
*dev
, drm_buf_entry_t
*entry
)
349 if (entry
->seg_count
) {
350 for (i
= 0; i
< entry
->seg_count
; i
++) {
351 if (entry
->seglist
[i
]) {
353 "drm_cleanup_buf_error: not implemented");
356 drm_free(entry
->seglist
,
358 sizeof (*entry
->seglist
), DRM_MEM_SEGS
);
359 entry
->seg_count
= 0;
362 if (entry
->buf_count
) {
363 for (i
= 0; i
< entry
->buf_count
; i
++) {
364 if (entry
->buflist
[i
].dev_private
) {
365 drm_free(entry
->buflist
[i
].dev_private
,
366 entry
->buflist
[i
].dev_priv_size
,
370 drm_free(entry
->buflist
,
372 sizeof (*entry
->buflist
), DRM_MEM_BUFS
);
373 entry
->buflist
= NULL
;
374 entry
->buf_count
= 0;
380 drm_markbufs(DRM_IOCTL_ARGS
)
382 DRM_DEBUG("drm_markbufs");
388 drm_infobufs(DRM_IOCTL_ARGS
)
390 DRM_DEBUG("drm_infobufs");
395 drm_do_addbufs_agp(drm_device_t
*dev
, drm_buf_desc_t
*request
)
397 drm_device_dma_t
*dma
= dev
->dma
;
398 drm_buf_entry_t
*entry
;
399 drm_buf_t
**temp_buflist
;
401 unsigned long offset
;
402 unsigned long agp_offset
;
414 count
= request
->count
;
415 order
= drm_order(request
->size
);
418 alignment
= (request
->flags
& _DRM_PAGE_ALIGN
)
419 ? round_page(size
) : size
;
420 page_order
= order
- PAGE_SHIFT
> 0 ? order
- PAGE_SHIFT
: 0;
423 agp_offset
= dev
->agp
->base
+ request
->agp_start
;
425 entry
= &dma
->bufs
[order
];
427 /* No more than one allocation per order */
428 if (entry
->buf_count
) {
432 entry
->buflist
= drm_alloc(count
* sizeof (*entry
->buflist
),
434 if (!entry
->buflist
) {
437 entry
->buf_size
= size
;
438 entry
->page_order
= page_order
;
442 while (entry
->buf_count
< count
) {
443 buf
= &entry
->buflist
[entry
->buf_count
];
444 buf
->idx
= dma
->buf_count
+ entry
->buf_count
;
445 buf
->total
= alignment
;
449 buf
->offset
= (dma
->byte_count
+ offset
);
450 buf
->bus_address
= agp_offset
+ offset
;
451 buf
->address
= (void *)(agp_offset
+ offset
);
456 buf
->dev_priv_size
= dev
->driver
->buf_priv_size
;
457 buf
->dev_private
= drm_alloc(buf
->dev_priv_size
, DRM_MEM_BUFS
);
458 if (buf
->dev_private
== NULL
) {
459 /* Set count correctly so we free the proper amount. */
460 entry
->buf_count
= count
;
461 drm_cleanup_buf_error(dev
, entry
);
467 byte_count
+= PAGE_SIZE
<< page_order
;
470 temp_buflist
= drm_alloc(
471 (dma
->buf_count
+ entry
->buf_count
) * sizeof (*dma
->buflist
),
474 if (temp_buflist
== NULL
) {
475 /* Free the entry because it isn't valid */
476 drm_cleanup_buf_error(dev
, entry
);
477 DRM_ERROR(" temp_buflist is NULL");
481 bcopy(temp_buflist
, dma
->buflist
,
482 dma
->buf_count
* sizeof (*dma
->buflist
));
483 kmem_free(dma
->buflist
, dma
->buf_count
*sizeof (*dma
->buflist
));
484 dma
->buflist
= temp_buflist
;
486 for (i
= 0; i
< entry
->buf_count
; i
++) {
487 dma
->buflist
[i
+ dma
->buf_count
] = &entry
->buflist
[i
];
490 dma
->buf_count
+= entry
->buf_count
;
491 dma
->byte_count
+= byte_count
;
492 dma
->seg_count
+= entry
->seg_count
;
493 dma
->page_count
+= byte_count
>> PAGE_SHIFT
;
495 request
->count
= entry
->buf_count
;
496 request
->size
= size
;
498 dma
->flags
= _DRM_DMA_USE_AGP
;
504 drm_do_addbufs_sg(drm_device_t
*dev
, drm_buf_desc_t
*request
)
506 drm_device_dma_t
*dma
= dev
->dma
;
507 drm_buf_entry_t
*entry
;
509 unsigned long offset
;
510 unsigned long agp_offset
;
518 drm_buf_t
**temp_buflist
;
520 count
= request
->count
;
521 order
= drm_order(request
->size
);
524 alignment
= (request
->flags
& _DRM_PAGE_ALIGN
)
525 ? round_page(size
) : size
;
526 page_order
= order
- PAGE_SHIFT
> 0 ? order
- PAGE_SHIFT
: 0;
529 agp_offset
= request
->agp_start
;
530 entry
= &dma
->bufs
[order
];
532 entry
->buflist
= drm_alloc(count
* sizeof (*entry
->buflist
),
534 if (entry
->buflist
== NULL
)
537 entry
->buf_size
= size
;
538 entry
->page_order
= page_order
;
542 while (entry
->buf_count
< count
) {
543 buf
= &entry
->buflist
[entry
->buf_count
];
544 buf
->idx
= dma
->buf_count
+ entry
->buf_count
;
545 buf
->total
= alignment
;
549 buf
->offset
= (dma
->byte_count
+ offset
);
550 buf
->bus_address
= agp_offset
+ offset
;
551 buf
->address
= (void *)(agp_offset
+ offset
+ dev
->sg
->handle
);
556 buf
->dev_priv_size
= dev
->driver
->buf_priv_size
;
557 buf
->dev_private
= drm_alloc(buf
->dev_priv_size
,
559 if (buf
->dev_private
== NULL
) {
560 /* Set count correctly so we free the proper amount. */
561 entry
->buf_count
= count
;
562 drm_cleanup_buf_error(dev
, entry
);
568 byte_count
+= PAGE_SIZE
<< page_order
;
571 temp_buflist
= drm_realloc(dma
->buflist
,
572 dma
->buf_count
* sizeof (*dma
->buflist
),
573 (dma
->buf_count
+ entry
->buf_count
)
574 * sizeof (*dma
->buflist
), DRM_MEM_BUFS
);
576 drm_cleanup_buf_error(dev
, entry
);
579 dma
->buflist
= temp_buflist
;
581 for (i
= 0; i
< entry
->buf_count
; i
++) {
582 dma
->buflist
[i
+ dma
->buf_count
] = &entry
->buflist
[i
];
585 dma
->buf_count
+= entry
->buf_count
;
586 dma
->byte_count
+= byte_count
;
587 request
->count
= entry
->buf_count
;
588 request
->size
= size
;
589 dma
->flags
= _DRM_DMA_USE_SG
;
595 drm_addbufs_agp(drm_device_t
*dev
, drm_buf_desc_t
*request
)
599 DRM_SPINLOCK(&dev
->dma_lock
);
601 if (request
->count
< 0 || request
->count
> 4096) {
602 DRM_SPINLOCK(&dev
->dma_lock
);
606 order
= drm_order(request
->size
);
607 if (order
< DRM_MIN_ORDER
|| order
> DRM_MAX_ORDER
) {
608 DRM_SPINLOCK(&dev
->dma_lock
);
612 /* No more allocations after first buffer-using ioctl. */
613 if (dev
->buf_use
!= 0) {
614 DRM_SPINUNLOCK(&dev
->dma_lock
);
617 /* No more than one allocation per order */
618 if (dev
->dma
->bufs
[order
].buf_count
!= 0) {
619 DRM_SPINUNLOCK(&dev
->dma_lock
);
623 ret
= drm_do_addbufs_agp(dev
, request
);
625 DRM_SPINUNLOCK(&dev
->dma_lock
);
631 drm_addbufs_sg(drm_device_t
*dev
, drm_buf_desc_t
*request
)
635 DRM_SPINLOCK(&dev
->dma_lock
);
637 if (request
->count
< 0 || request
->count
> 4096) {
638 DRM_SPINUNLOCK(&dev
->dma_lock
);
642 order
= drm_order(request
->size
);
643 if (order
< DRM_MIN_ORDER
|| order
> DRM_MAX_ORDER
) {
644 DRM_SPINUNLOCK(&dev
->dma_lock
);
648 /* No more allocations after first buffer-using ioctl. */
649 if (dev
->buf_use
!= 0) {
650 DRM_SPINUNLOCK(&dev
->dma_lock
);
654 /* No more than one allocation per order */
655 if (dev
->dma
->bufs
[order
].buf_count
!= 0) {
656 DRM_SPINUNLOCK(&dev
->dma_lock
);
660 ret
= drm_do_addbufs_sg(dev
, request
);
661 DRM_SPINUNLOCK(&dev
->dma_lock
);
667 drm_addbufs_ioctl(DRM_IOCTL_ARGS
)
670 drm_buf_desc_t request
;
673 #ifdef _MULTI_DATAMODEL
674 if (ddi_model_convert_from(mode
& FMODELS
) == DDI_MODEL_ILP32
) {
675 drm_buf_desc_32_t request32
;
676 DRM_COPYFROM_WITH_RETURN(&request32
,
677 (void *)data
, sizeof (request32
));
678 request
.count
= request32
.count
;
679 request
.size
= request32
.size
;
680 request
.low_mark
= request32
.low_mark
;
681 request
.high_mark
= request32
.high_mark
;
682 request
.flags
= request32
.flags
;
683 request
.agp_start
= request32
.agp_start
;
686 DRM_COPYFROM_WITH_RETURN(&request
,
687 (void *)data
, sizeof (request
));
689 if (request
.flags
& _DRM_AGP_BUFFER
)
690 err
= drm_addbufs_agp(dev
, &request
);
691 else if (request
.flags
& _DRM_SG_BUFFER
)
692 err
= drm_addbufs_sg(dev
, &request
);
694 #ifdef _MULTI_DATAMODEL
695 if (ddi_model_convert_from(mode
& FMODELS
) == DDI_MODEL_ILP32
) {
696 drm_buf_desc_32_t request32
;
697 request32
.count
= request
.count
;
698 request32
.size
= request
.size
;
699 request32
.low_mark
= request
.low_mark
;
700 request32
.high_mark
= request
.high_mark
;
701 request32
.flags
= request
.flags
;
702 request32
.agp_start
= (uint32_t)request
.agp_start
;
703 DRM_COPYTO_WITH_RETURN((void *)data
,
704 &request32
, sizeof (request32
));
707 DRM_COPYTO_WITH_RETURN((void *)data
,
708 &request
, sizeof (request
));
715 drm_freebufs(DRM_IOCTL_ARGS
)
718 drm_device_dma_t
*dma
= dev
->dma
;
719 drm_buf_free_t request
;
725 #ifdef _MULTI_DATAMODEL
726 if (ddi_model_convert_from(mode
& FMODELS
) == DDI_MODEL_ILP32
) {
727 drm_buf_free_32_t request32
;
728 DRM_COPYFROM_WITH_RETURN(&request32
,
729 (void*)data
, sizeof (request32
));
730 request
.count
= request32
.count
;
731 request
.list
= (int *)(uintptr_t)request32
.list
;
734 DRM_COPYFROM_WITH_RETURN(&request
,
735 (void *)data
, sizeof (request
));
737 for (i
= 0; i
< request
.count
; i
++) {
738 if (DRM_COPY_FROM_USER(&idx
, &request
.list
[i
], sizeof (idx
))) {
742 if (idx
< 0 || idx
>= dma
->buf_count
) {
743 DRM_ERROR("drm_freebufs: Index %d (of %d max)\n",
744 idx
, dma
->buf_count
- 1);
748 buf
= dma
->buflist
[idx
];
749 if (buf
->filp
!= fpriv
) {
751 "drm_freebufs: process %d not owning the buffer.\n",
756 drm_free_buffer(dev
, buf
);
763 extern caddr_t
smmap64(caddr_t
, size_t, int, int, int, off_t
);
764 #define drm_smmap smmap64
766 #error "No define for _LP64"
772 drm_mapbufs(DRM_IOCTL_ARGS
)
775 drm_buf_map_t request
;
778 unsigned long address
;
779 drm_device_dma_t
*dma
= dev
->dma
;
785 #ifdef _MULTI_DATAMODEL
786 drm_buf_map_32_t request32
;
787 drm_buf_pub_32_t
*list32
;
790 if (ddi_model_convert_from(mode
& FMODELS
) == DDI_MODEL_ILP32
) {
791 DRM_COPYFROM_WITH_RETURN(&request32
,
792 (void *)data
, sizeof (request32
));
793 request
.count
= request32
.count
;
794 request
.virtual = (void *)(uintptr_t)request32
.virtual;
795 request
.list
= (drm_buf_pub_t
*)(uintptr_t)request32
.list
;
796 request
.fd
= request32
.fd
;
799 DRM_COPYFROM_WITH_RETURN(&request
,
800 (void *)data
, sizeof (request
));
804 if (request
.count
< dma
->buf_count
)
807 if ((dev
->driver
->use_agp
&& (dma
->flags
& _DRM_DMA_USE_AGP
)) ||
808 (dev
->driver
->use_sg
&& (dma
->flags
& _DRM_DMA_USE_SG
))) {
809 drm_local_map_t
*map
= dev
->agp_buffer_map
;
812 size
= round_page(map
->size
);
813 foff
= (uintptr_t)map
->handle
;
815 size
= round_page(dma
->byte_count
);
818 request
.virtual = drm_smmap(0, size
, PROT_READ
| PROT_WRITE
,
819 MAP_SHARED
, request
.fd
, foff
);
820 if (request
.virtual == NULL
) {
821 DRM_ERROR("drm_mapbufs: request.virtual is NULL");
825 vaddr
= (unsigned long) request
.virtual;
826 #ifdef _MULTI_DATAMODEL
827 if (ddi_model_convert_from(mode
& FMODELS
) == DDI_MODEL_ILP32
) {
828 list32
= (drm_buf_pub_32_t
*)(uintptr_t)request32
.list
;
829 for (i
= 0; i
< dma
->buf_count
; i
++) {
830 if (DRM_COPY_TO_USER(&list32
[i
].idx
,
831 &dma
->buflist
[i
]->idx
, sizeof (list32
[0].idx
))) {
834 if (DRM_COPY_TO_USER(&list32
[i
].total
,
835 &dma
->buflist
[i
]->total
,
836 sizeof (list32
[0].total
))) {
839 if (DRM_COPY_TO_USER(&list32
[i
].used
,
840 &zero
, sizeof (zero
))) {
843 address32
= vaddr
+ dma
->buflist
[i
]->offset
; /* *** */
844 ret_tmp
= DRM_COPY_TO_USER(&list32
[i
].address
,
845 &address32
, sizeof (list32
[0].address
));
853 ASSERT(ddi_model_convert_from(mode
& FMODELS
) != DDI_MODEL_ILP32
);
854 for (i
= 0; i
< dma
->buf_count
; i
++) {
855 if (DRM_COPY_TO_USER(&request
.list
[i
].idx
,
856 &dma
->buflist
[i
]->idx
, sizeof (request
.list
[0].idx
))) {
859 if (DRM_COPY_TO_USER(&request
.list
[i
].total
,
860 &dma
->buflist
[i
]->total
, sizeof (request
.list
[0].total
))) {
863 if (DRM_COPY_TO_USER(&request
.list
[i
].used
, &zero
,
867 address
= vaddr
+ dma
->buflist
[i
]->offset
; /* *** */
869 ret_tmp
= DRM_COPY_TO_USER(&request
.list
[i
].address
,
870 &address
, sizeof (address
));
877 #ifdef _MULTI_DATAMODEL
878 if (ddi_model_convert_from(mode
& FMODELS
) == DDI_MODEL_ILP32
) {
879 request32
.count
= dma
->buf_count
;
880 request32
.virtual = (caddr32_t
)(uintptr_t)request
.virtual;
881 DRM_COPYTO_WITH_RETURN((void *)data
,
882 &request32
, sizeof (request32
));
885 request
.count
= dma
->buf_count
;
886 DRM_COPYTO_WITH_RETURN((void *)data
,
887 &request
, sizeof (request
));
888 #ifdef _MULTI_DATAMODEL