diff options
author | Eric Anholt <eric@anholt.net> | 2007-09-02 22:06:45 -0400 |
---|---|---|
committer | Dave Airlie <airlied@optimus.(none)> | 2007-10-14 20:38:20 -0400 |
commit | c153f45f9b7e30289157bba3ff5682291df16caa (patch) | |
tree | 33f21e1ebd83ec548751f3d490afe6230ab99972 /drivers/char/drm/i915_irq.c | |
parent | b589ee5943a9610ebaea6e4e3433f2ae4d812b0b (diff) |
drm: Replace DRM_IOCTL_ARGS with (dev, data, file_priv) and remove DRM_DEVICE.
The data is now in kernel space, copied in/out as appropriate according to t
This results in DRM_COPY_{TO,FROM}_USER going away, and error paths to deal
with those failures. This also means that XFree86 4.2.0 support for i810 DR
is lost.
Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm/i915_irq.c')
-rw-r--r-- | drivers/char/drm/i915_irq.c | 92 |
1 files changed, 38 insertions, 54 deletions
diff --git a/drivers/char/drm/i915_irq.c b/drivers/char/drm/i915_irq.c index 36be24e2e8d4..380c3f387218 100644 --- a/drivers/char/drm/i915_irq.c +++ b/drivers/char/drm/i915_irq.c | |||
@@ -355,11 +355,11 @@ int i915_driver_vblank_wait2(struct drm_device *dev, unsigned int *sequence) | |||
355 | 355 | ||
356 | /* Needs the lock as it touches the ring. | 356 | /* Needs the lock as it touches the ring. |
357 | */ | 357 | */ |
358 | int i915_irq_emit(DRM_IOCTL_ARGS) | 358 | int i915_irq_emit(struct drm_device *dev, void *data, |
359 | struct drm_file *file_priv) | ||
359 | { | 360 | { |
360 | DRM_DEVICE; | ||
361 | drm_i915_private_t *dev_priv = dev->dev_private; | 361 | drm_i915_private_t *dev_priv = dev->dev_private; |
362 | drm_i915_irq_emit_t emit; | 362 | drm_i915_irq_emit_t *emit = data; |
363 | int result; | 363 | int result; |
364 | 364 | ||
365 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 365 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
@@ -369,12 +369,9 @@ int i915_irq_emit(DRM_IOCTL_ARGS) | |||
369 | return -EINVAL; | 369 | return -EINVAL; |
370 | } | 370 | } |
371 | 371 | ||
372 | DRM_COPY_FROM_USER_IOCTL(emit, (drm_i915_irq_emit_t __user *) data, | ||
373 | sizeof(emit)); | ||
374 | |||
375 | result = i915_emit_irq(dev); | 372 | result = i915_emit_irq(dev); |
376 | 373 | ||
377 | if (DRM_COPY_TO_USER(emit.irq_seq, &result, sizeof(int))) { | 374 | if (DRM_COPY_TO_USER(emit->irq_seq, &result, sizeof(int))) { |
378 | DRM_ERROR("copy_to_user\n"); | 375 | DRM_ERROR("copy_to_user\n"); |
379 | return -EFAULT; | 376 | return -EFAULT; |
380 | } | 377 | } |
@@ -384,21 +381,18 @@ int i915_irq_emit(DRM_IOCTL_ARGS) | |||
384 | 381 | ||
385 | /* Doesn't need the hardware lock. | 382 | /* Doesn't need the hardware lock. |
386 | */ | 383 | */ |
387 | int i915_irq_wait(DRM_IOCTL_ARGS) | 384 | int i915_irq_wait(struct drm_device *dev, void *data, |
385 | struct drm_file *file_priv) | ||
388 | { | 386 | { |
389 | DRM_DEVICE; | ||
390 | drm_i915_private_t *dev_priv = dev->dev_private; | 387 | drm_i915_private_t *dev_priv = dev->dev_private; |
391 | drm_i915_irq_wait_t irqwait; | 388 | drm_i915_irq_wait_t *irqwait = data; |
392 | 389 | ||
393 | if (!dev_priv) { | 390 | if (!dev_priv) { |
394 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); | 391 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); |
395 | return -EINVAL; | 392 | return -EINVAL; |
396 | } | 393 | } |
397 | 394 | ||
398 | DRM_COPY_FROM_USER_IOCTL(irqwait, (drm_i915_irq_wait_t __user *) data, | 395 | return i915_wait_irq(dev, irqwait->irq_seq); |
399 | sizeof(irqwait)); | ||
400 | |||
401 | return i915_wait_irq(dev, irqwait.irq_seq); | ||
402 | } | 396 | } |
403 | 397 | ||
404 | static void i915_enable_interrupt (struct drm_device *dev) | 398 | static void i915_enable_interrupt (struct drm_device *dev) |
@@ -417,38 +411,35 @@ static void i915_enable_interrupt (struct drm_device *dev) | |||
417 | 411 | ||
418 | /* Set the vblank monitor pipe | 412 | /* Set the vblank monitor pipe |
419 | */ | 413 | */ |
420 | int i915_vblank_pipe_set(DRM_IOCTL_ARGS) | 414 | int i915_vblank_pipe_set(struct drm_device *dev, void *data, |
415 | struct drm_file *file_priv) | ||
421 | { | 416 | { |
422 | DRM_DEVICE; | ||
423 | drm_i915_private_t *dev_priv = dev->dev_private; | 417 | drm_i915_private_t *dev_priv = dev->dev_private; |
424 | drm_i915_vblank_pipe_t pipe; | 418 | drm_i915_vblank_pipe_t *pipe = data; |
425 | 419 | ||
426 | if (!dev_priv) { | 420 | if (!dev_priv) { |
427 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); | 421 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); |
428 | return -EINVAL; | 422 | return -EINVAL; |
429 | } | 423 | } |
430 | 424 | ||
431 | DRM_COPY_FROM_USER_IOCTL(pipe, (drm_i915_vblank_pipe_t __user *) data, | 425 | if (pipe->pipe & ~(DRM_I915_VBLANK_PIPE_A|DRM_I915_VBLANK_PIPE_B)) { |
432 | sizeof(pipe)); | ||
433 | |||
434 | if (pipe.pipe & ~(DRM_I915_VBLANK_PIPE_A|DRM_I915_VBLANK_PIPE_B)) { | ||
435 | DRM_ERROR("%s called with invalid pipe 0x%x\n", | 426 | DRM_ERROR("%s called with invalid pipe 0x%x\n", |
436 | __FUNCTION__, pipe.pipe); | 427 | __FUNCTION__, pipe->pipe); |
437 | return -EINVAL; | 428 | return -EINVAL; |
438 | } | 429 | } |
439 | 430 | ||
440 | dev_priv->vblank_pipe = pipe.pipe; | 431 | dev_priv->vblank_pipe = pipe->pipe; |
441 | 432 | ||
442 | i915_enable_interrupt (dev); | 433 | i915_enable_interrupt (dev); |
443 | 434 | ||
444 | return 0; | 435 | return 0; |
445 | } | 436 | } |
446 | 437 | ||
447 | int i915_vblank_pipe_get(DRM_IOCTL_ARGS) | 438 | int i915_vblank_pipe_get(struct drm_device *dev, void *data, |
439 | struct drm_file *file_priv) | ||
448 | { | 440 | { |
449 | DRM_DEVICE; | ||
450 | drm_i915_private_t *dev_priv = dev->dev_private; | 441 | drm_i915_private_t *dev_priv = dev->dev_private; |
451 | drm_i915_vblank_pipe_t pipe; | 442 | drm_i915_vblank_pipe_t *pipe = data; |
452 | u16 flag; | 443 | u16 flag; |
453 | 444 | ||
454 | if (!dev_priv) { | 445 | if (!dev_priv) { |
@@ -457,24 +448,23 @@ int i915_vblank_pipe_get(DRM_IOCTL_ARGS) | |||
457 | } | 448 | } |
458 | 449 | ||
459 | flag = I915_READ(I915REG_INT_ENABLE_R); | 450 | flag = I915_READ(I915REG_INT_ENABLE_R); |
460 | pipe.pipe = 0; | 451 | pipe->pipe = 0; |
461 | if (flag & VSYNC_PIPEA_FLAG) | 452 | if (flag & VSYNC_PIPEA_FLAG) |
462 | pipe.pipe |= DRM_I915_VBLANK_PIPE_A; | 453 | pipe->pipe |= DRM_I915_VBLANK_PIPE_A; |
463 | if (flag & VSYNC_PIPEB_FLAG) | 454 | if (flag & VSYNC_PIPEB_FLAG) |
464 | pipe.pipe |= DRM_I915_VBLANK_PIPE_B; | 455 | pipe->pipe |= DRM_I915_VBLANK_PIPE_B; |
465 | DRM_COPY_TO_USER_IOCTL((drm_i915_vblank_pipe_t __user *) data, pipe, | 456 | |
466 | sizeof(pipe)); | ||
467 | return 0; | 457 | return 0; |
468 | } | 458 | } |
469 | 459 | ||
470 | /** | 460 | /** |
471 | * Schedule buffer swap at given vertical blank. | 461 | * Schedule buffer swap at given vertical blank. |
472 | */ | 462 | */ |
473 | int i915_vblank_swap(DRM_IOCTL_ARGS) | 463 | int i915_vblank_swap(struct drm_device *dev, void *data, |
464 | struct drm_file *file_priv) | ||
474 | { | 465 | { |
475 | DRM_DEVICE; | ||
476 | drm_i915_private_t *dev_priv = dev->dev_private; | 466 | drm_i915_private_t *dev_priv = dev->dev_private; |
477 | drm_i915_vblank_swap_t swap; | 467 | drm_i915_vblank_swap_t *swap = data; |
478 | drm_i915_vbl_swap_t *vbl_swap; | 468 | drm_i915_vbl_swap_t *vbl_swap; |
479 | unsigned int pipe, seqtype, curseq; | 469 | unsigned int pipe, seqtype, curseq; |
480 | unsigned long irqflags; | 470 | unsigned long irqflags; |
@@ -490,18 +480,15 @@ int i915_vblank_swap(DRM_IOCTL_ARGS) | |||
490 | return -EINVAL; | 480 | return -EINVAL; |
491 | } | 481 | } |
492 | 482 | ||
493 | DRM_COPY_FROM_USER_IOCTL(swap, (drm_i915_vblank_swap_t __user *) data, | 483 | if (swap->seqtype & ~(_DRM_VBLANK_RELATIVE | _DRM_VBLANK_ABSOLUTE | |
494 | sizeof(swap)); | ||
495 | |||
496 | if (swap.seqtype & ~(_DRM_VBLANK_RELATIVE | _DRM_VBLANK_ABSOLUTE | | ||
497 | _DRM_VBLANK_SECONDARY | _DRM_VBLANK_NEXTONMISS)) { | 484 | _DRM_VBLANK_SECONDARY | _DRM_VBLANK_NEXTONMISS)) { |
498 | DRM_ERROR("Invalid sequence type 0x%x\n", swap.seqtype); | 485 | DRM_ERROR("Invalid sequence type 0x%x\n", swap->seqtype); |
499 | return -EINVAL; | 486 | return -EINVAL; |
500 | } | 487 | } |
501 | 488 | ||
502 | pipe = (swap.seqtype & _DRM_VBLANK_SECONDARY) ? 1 : 0; | 489 | pipe = (swap->seqtype & _DRM_VBLANK_SECONDARY) ? 1 : 0; |
503 | 490 | ||
504 | seqtype = swap.seqtype & (_DRM_VBLANK_RELATIVE | _DRM_VBLANK_ABSOLUTE); | 491 | seqtype = swap->seqtype & (_DRM_VBLANK_RELATIVE | _DRM_VBLANK_ABSOLUTE); |
505 | 492 | ||
506 | if (!(dev_priv->vblank_pipe & (1 << pipe))) { | 493 | if (!(dev_priv->vblank_pipe & (1 << pipe))) { |
507 | DRM_ERROR("Invalid pipe %d\n", pipe); | 494 | DRM_ERROR("Invalid pipe %d\n", pipe); |
@@ -510,9 +497,9 @@ int i915_vblank_swap(DRM_IOCTL_ARGS) | |||
510 | 497 | ||
511 | spin_lock_irqsave(&dev->drw_lock, irqflags); | 498 | spin_lock_irqsave(&dev->drw_lock, irqflags); |
512 | 499 | ||
513 | if (!drm_get_drawable_info(dev, swap.drawable)) { | 500 | if (!drm_get_drawable_info(dev, swap->drawable)) { |
514 | spin_unlock_irqrestore(&dev->drw_lock, irqflags); | 501 | spin_unlock_irqrestore(&dev->drw_lock, irqflags); |
515 | DRM_DEBUG("Invalid drawable ID %d\n", swap.drawable); | 502 | DRM_DEBUG("Invalid drawable ID %d\n", swap->drawable); |
516 | return -EINVAL; | 503 | return -EINVAL; |
517 | } | 504 | } |
518 | 505 | ||
@@ -521,11 +508,11 @@ int i915_vblank_swap(DRM_IOCTL_ARGS) | |||
521 | curseq = atomic_read(pipe ? &dev->vbl_received2 : &dev->vbl_received); | 508 | curseq = atomic_read(pipe ? &dev->vbl_received2 : &dev->vbl_received); |
522 | 509 | ||
523 | if (seqtype == _DRM_VBLANK_RELATIVE) | 510 | if (seqtype == _DRM_VBLANK_RELATIVE) |
524 | swap.sequence += curseq; | 511 | swap->sequence += curseq; |
525 | 512 | ||
526 | if ((curseq - swap.sequence) <= (1<<23)) { | 513 | if ((curseq - swap->sequence) <= (1<<23)) { |
527 | if (swap.seqtype & _DRM_VBLANK_NEXTONMISS) { | 514 | if (swap->seqtype & _DRM_VBLANK_NEXTONMISS) { |
528 | swap.sequence = curseq + 1; | 515 | swap->sequence = curseq + 1; |
529 | } else { | 516 | } else { |
530 | DRM_DEBUG("Missed target sequence\n"); | 517 | DRM_DEBUG("Missed target sequence\n"); |
531 | return -EINVAL; | 518 | return -EINVAL; |
@@ -537,9 +524,9 @@ int i915_vblank_swap(DRM_IOCTL_ARGS) | |||
537 | list_for_each(list, &dev_priv->vbl_swaps.head) { | 524 | list_for_each(list, &dev_priv->vbl_swaps.head) { |
538 | vbl_swap = list_entry(list, drm_i915_vbl_swap_t, head); | 525 | vbl_swap = list_entry(list, drm_i915_vbl_swap_t, head); |
539 | 526 | ||
540 | if (vbl_swap->drw_id == swap.drawable && | 527 | if (vbl_swap->drw_id == swap->drawable && |
541 | vbl_swap->pipe == pipe && | 528 | vbl_swap->pipe == pipe && |
542 | vbl_swap->sequence == swap.sequence) { | 529 | vbl_swap->sequence == swap->sequence) { |
543 | spin_unlock_irqrestore(&dev_priv->swaps_lock, irqflags); | 530 | spin_unlock_irqrestore(&dev_priv->swaps_lock, irqflags); |
544 | DRM_DEBUG("Already scheduled\n"); | 531 | DRM_DEBUG("Already scheduled\n"); |
545 | return 0; | 532 | return 0; |
@@ -562,9 +549,9 @@ int i915_vblank_swap(DRM_IOCTL_ARGS) | |||
562 | 549 | ||
563 | DRM_DEBUG("\n"); | 550 | DRM_DEBUG("\n"); |
564 | 551 | ||
565 | vbl_swap->drw_id = swap.drawable; | 552 | vbl_swap->drw_id = swap->drawable; |
566 | vbl_swap->pipe = pipe; | 553 | vbl_swap->pipe = pipe; |
567 | vbl_swap->sequence = swap.sequence; | 554 | vbl_swap->sequence = swap->sequence; |
568 | 555 | ||
569 | spin_lock_irqsave(&dev_priv->swaps_lock, irqflags); | 556 | spin_lock_irqsave(&dev_priv->swaps_lock, irqflags); |
570 | 557 | ||
@@ -573,9 +560,6 @@ int i915_vblank_swap(DRM_IOCTL_ARGS) | |||
573 | 560 | ||
574 | spin_unlock_irqrestore(&dev_priv->swaps_lock, irqflags); | 561 | spin_unlock_irqrestore(&dev_priv->swaps_lock, irqflags); |
575 | 562 | ||
576 | DRM_COPY_TO_USER_IOCTL((drm_i915_vblank_swap_t __user *) data, swap, | ||
577 | sizeof(swap)); | ||
578 | |||
579 | return 0; | 563 | return 0; |
580 | } | 564 | } |
581 | 565 | ||