Lines 392-397
Link Here
|
392 |
drm_buf_t *buf; |
392 |
drm_buf_t *buf; |
393 |
drm_buf_t *last_buf = NULL; |
393 |
drm_buf_t *last_buf = NULL; |
394 |
drm_device_dma_t *dma = dev->dma; |
394 |
drm_device_dma_t *dma = dev->dma; |
|
|
395 |
int *drm_send_indices = NULL; |
396 |
int *drm_send_sizes = NULL; |
395 |
DECLARE_WAITQUEUE(entry, current); |
397 |
DECLARE_WAITQUEUE(entry, current); |
396 |
|
398 |
|
397 |
/* Turn off interrupt handling */ |
399 |
/* Turn off interrupt handling */ |
Lines 412-422
Link Here
|
412 |
} |
414 |
} |
413 |
atomic_inc(&dma->total_prio); |
415 |
atomic_inc(&dma->total_prio); |
414 |
|
416 |
|
|
|
417 |
drm_send_indices = kmalloc (d->send_count * sizeof(*drm_send_indices), GFP_KERNEL); |
418 |
drm_send_sizes = kmalloc (d->send_count * sizeof(*drm_send_sizes), GFP_KERNEL); |
419 |
if (! drm_send_indices || ! drm_send_sizes) |
420 |
{ |
421 |
retcode = -ENOMEM; |
422 |
goto cleanup; |
423 |
} |
424 |
if (copy_from_user(drm_send_indices, d->send_indices, |
425 |
d->send_count * sizeof(*drm_send_indices)) || |
426 |
copy_from_user(drm_send_sizes, d->send_sizes, |
427 |
d->send_count * sizeof(*drm_send_sizes))) |
428 |
{ |
429 |
retcode = -EFAULT; |
430 |
goto cleanup; |
431 |
} |
432 |
|
415 |
for (i = 0; i < d->send_count; i++) { |
433 |
for (i = 0; i < d->send_count; i++) { |
416 |
idx = d->send_indices[i]; |
434 |
idx = drm_send_indices[i]; |
417 |
if (idx < 0 || idx >= dma->buf_count) { |
435 |
if (idx < 0 || idx >= dma->buf_count) { |
418 |
DRM_ERROR("Index %d (of %d max)\n", |
436 |
DRM_ERROR("Index %d (of %d max)\n", |
419 |
d->send_indices[i], dma->buf_count - 1); |
437 |
drm_send_indices[i], dma->buf_count - 1); |
420 |
continue; |
438 |
continue; |
421 |
} |
439 |
} |
422 |
buf = dma->buflist[ idx ]; |
440 |
buf = dma->buflist[ idx ]; |
Lines 438-444
Link Here
|
438 |
process closes the /dev/drm? handle, so |
456 |
process closes the /dev/drm? handle, so |
439 |
it can't also be doing DMA. */ |
457 |
it can't also be doing DMA. */ |
440 |
buf->list = DRM_LIST_PRIO; |
458 |
buf->list = DRM_LIST_PRIO; |
441 |
buf->used = d->send_sizes[i]; |
459 |
buf->used = drm_send_sizes[i]; |
442 |
buf->context = d->context; |
460 |
buf->context = d->context; |
443 |
buf->while_locked = d->flags & _DRM_DMA_WHILE_LOCKED; |
461 |
buf->while_locked = d->flags & _DRM_DMA_WHILE_LOCKED; |
444 |
address = (unsigned long)buf->address; |
462 |
address = (unsigned long)buf->address; |
Lines 449-462
Link Here
|
449 |
if (buf->pending) { |
467 |
if (buf->pending) { |
450 |
DRM_ERROR("Sending pending buffer:" |
468 |
DRM_ERROR("Sending pending buffer:" |
451 |
" buffer %d, offset %d\n", |
469 |
" buffer %d, offset %d\n", |
452 |
d->send_indices[i], i); |
470 |
drm_send_indices[i], i); |
453 |
retcode = -EINVAL; |
471 |
retcode = -EINVAL; |
454 |
goto cleanup; |
472 |
goto cleanup; |
455 |
} |
473 |
} |
456 |
if (buf->waiting) { |
474 |
if (buf->waiting) { |
457 |
DRM_ERROR("Sending waiting buffer:" |
475 |
DRM_ERROR("Sending waiting buffer:" |
458 |
" buffer %d, offset %d\n", |
476 |
" buffer %d, offset %d\n", |
459 |
d->send_indices[i], i); |
477 |
drm_send_indices[i], i); |
460 |
retcode = -EINVAL; |
478 |
retcode = -EINVAL; |
461 |
goto cleanup; |
479 |
goto cleanup; |
462 |
} |
480 |
} |
Lines 505-510
Link Here
|
505 |
|
523 |
|
506 |
|
524 |
|
507 |
cleanup: |
525 |
cleanup: |
|
|
526 |
if (drm_send_indices) |
527 |
kfree(drm_send_indices); |
528 |
if (drm_send_sizes) |
529 |
kfree(drm_send_sizes); |
508 |
if (last_buf) { |
530 |
if (last_buf) { |
509 |
gamma_dma_ready(dev); |
531 |
gamma_dma_ready(dev); |
510 |
drm_free_buffer(dev, last_buf); |
532 |
drm_free_buffer(dev, last_buf); |
Lines 528-534
Link Here
|
528 |
drm_device_dma_t *dma = dev->dma; |
550 |
drm_device_dma_t *dma = dev->dma; |
529 |
|
551 |
|
530 |
if (d->flags & _DRM_DMA_BLOCK) { |
552 |
if (d->flags & _DRM_DMA_BLOCK) { |
531 |
last_buf = dma->buflist[d->send_indices[d->send_count-1]]; |
553 |
int lastindex; |
|
|
554 |
if (copy_from_user(&lastindex, &d->send_indices[d->send_count-1], |
555 |
sizeof(lastindex))) |
556 |
return -EFAULT; |
557 |
last_buf = dma->buflist[lastindex]; |
532 |
add_wait_queue(&last_buf->dma_wait, &entry); |
558 |
add_wait_queue(&last_buf->dma_wait, &entry); |
533 |
} |
559 |
} |
534 |
|
560 |
|