diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-15 11:17:26 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-15 11:17:26 -0400 |
commit | 13626cb91f41df803c54047172bfc7a716e36c2b (patch) | |
tree | d1e24385eaad0637ce388743310471e20f0839d8 /drivers/char/drm/i915_irq.c | |
parent | 37ca506adc395a028cd12760eca419dd0dc14b5c (diff) | |
parent | ace3dff5b7f0bf5a647e60dcd0c0a7d46792f5d9 (diff) |
Merge branch 'drm-patches' of ssh://master.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6
* 'drm-patches' of ssh://master.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6:
via invalid device ids removal
radeon: Commit the ring after each partial texture upload blit.
i915: fix vbl swap allocation size.
drm: Replace DRM_IOCTL_ARGS with (dev, data, file_priv) and remove DRM_DEVICE.
drm: remove XFREE86_VERSION macros.
drm: Replace filp in ioctl arguments with drm_file *file_priv.
drm: Remove DRM_ERR OS macro.
Diffstat (limited to 'drivers/char/drm/i915_irq.c')
-rw-r--r-- | drivers/char/drm/i915_irq.c | 128 |
1 files changed, 56 insertions, 72 deletions
diff --git a/drivers/char/drm/i915_irq.c b/drivers/char/drm/i915_irq.c index bb8e9e9c8201..a443f4a202e3 100644 --- a/drivers/char/drm/i915_irq.c +++ b/drivers/char/drm/i915_irq.c | |||
@@ -311,7 +311,7 @@ static int i915_wait_irq(struct drm_device * dev, int irq_nr) | |||
311 | DRM_WAIT_ON(ret, dev_priv->irq_queue, 3 * DRM_HZ, | 311 | DRM_WAIT_ON(ret, dev_priv->irq_queue, 3 * DRM_HZ, |
312 | READ_BREADCRUMB(dev_priv) >= irq_nr); | 312 | READ_BREADCRUMB(dev_priv) >= irq_nr); |
313 | 313 | ||
314 | if (ret == DRM_ERR(EBUSY)) { | 314 | if (ret == -EBUSY) { |
315 | DRM_ERROR("%s: EBUSY -- rec: %d emitted: %d\n", | 315 | DRM_ERROR("%s: EBUSY -- rec: %d emitted: %d\n", |
316 | __FUNCTION__, | 316 | __FUNCTION__, |
317 | READ_BREADCRUMB(dev_priv), (int)dev_priv->counter); | 317 | READ_BREADCRUMB(dev_priv), (int)dev_priv->counter); |
@@ -330,7 +330,7 @@ static int i915_driver_vblank_do_wait(struct drm_device *dev, unsigned int *sequ | |||
330 | 330 | ||
331 | if (!dev_priv) { | 331 | if (!dev_priv) { |
332 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); | 332 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); |
333 | return DRM_ERR(EINVAL); | 333 | return -EINVAL; |
334 | } | 334 | } |
335 | 335 | ||
336 | DRM_WAIT_ON(ret, dev->vbl_queue, 3 * DRM_HZ, | 336 | DRM_WAIT_ON(ret, dev->vbl_queue, 3 * DRM_HZ, |
@@ -355,28 +355,25 @@ 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, filp); | 365 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
366 | 366 | ||
367 | if (!dev_priv) { | 367 | if (!dev_priv) { |
368 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); | 368 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); |
369 | return DRM_ERR(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 DRM_ERR(EFAULT); | 376 | return -EFAULT; |
380 | } | 377 | } |
381 | 378 | ||
382 | return 0; | 379 | return 0; |
@@ -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 DRM_ERR(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,64 +411,60 @@ 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 DRM_ERR(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 DRM_ERR(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) { |
455 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); | 446 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); |
456 | return DRM_ERR(EINVAL); | 447 | return -EINVAL; |
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; |
@@ -482,38 +472,35 @@ int i915_vblank_swap(DRM_IOCTL_ARGS) | |||
482 | 472 | ||
483 | if (!dev_priv) { | 473 | if (!dev_priv) { |
484 | DRM_ERROR("%s called with no initialization\n", __func__); | 474 | DRM_ERROR("%s called with no initialization\n", __func__); |
485 | return DRM_ERR(EINVAL); | 475 | return -EINVAL; |
486 | } | 476 | } |
487 | 477 | ||
488 | if (dev_priv->sarea_priv->rotation) { | 478 | if (dev_priv->sarea_priv->rotation) { |
489 | DRM_DEBUG("Rotation not supported\n"); | 479 | DRM_DEBUG("Rotation not supported\n"); |
490 | return DRM_ERR(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 DRM_ERR(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); |
508 | return DRM_ERR(EINVAL); | 495 | return -EINVAL; |
509 | } | 496 | } |
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 DRM_ERR(EINVAL); | 503 | return -EINVAL; |
517 | } | 504 | } |
518 | 505 | ||
519 | spin_unlock_irqrestore(&dev->drw_lock, irqflags); | 506 | spin_unlock_irqrestore(&dev->drw_lock, irqflags); |
@@ -521,14 +508,14 @@ 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 DRM_ERR(EINVAL); | 518 | return -EINVAL; |
532 | } | 519 | } |
533 | } | 520 | } |
534 | 521 | ||
@@ -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; |
@@ -550,21 +537,21 @@ int i915_vblank_swap(DRM_IOCTL_ARGS) | |||
550 | 537 | ||
551 | if (dev_priv->swaps_pending >= 100) { | 538 | if (dev_priv->swaps_pending >= 100) { |
552 | DRM_DEBUG("Too many swaps queued\n"); | 539 | DRM_DEBUG("Too many swaps queued\n"); |
553 | return DRM_ERR(EBUSY); | 540 | return -EBUSY; |
554 | } | 541 | } |
555 | 542 | ||
556 | vbl_swap = drm_calloc(1, sizeof(vbl_swap), DRM_MEM_DRIVER); | 543 | vbl_swap = drm_calloc(1, sizeof(*vbl_swap), DRM_MEM_DRIVER); |
557 | 544 | ||
558 | if (!vbl_swap) { | 545 | if (!vbl_swap) { |
559 | DRM_ERROR("Failed to allocate memory to queue swap\n"); | 546 | DRM_ERROR("Failed to allocate memory to queue swap\n"); |
560 | return DRM_ERR(ENOMEM); | 547 | return -ENOMEM; |
561 | } | 548 | } |
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 | ||