diff options
Diffstat (limited to 'drivers/gpu/drm/radeon/rs600.c')
-rw-r--r-- | drivers/gpu/drm/radeon/rs600.c | 118 |
1 files changed, 88 insertions, 30 deletions
diff --git a/drivers/gpu/drm/radeon/rs600.c b/drivers/gpu/drm/radeon/rs600.c index f1c6e02c2e6b..b4192acaab5f 100644 --- a/drivers/gpu/drm/radeon/rs600.c +++ b/drivers/gpu/drm/radeon/rs600.c | |||
@@ -46,6 +46,56 @@ | |||
46 | void rs600_gpu_init(struct radeon_device *rdev); | 46 | void rs600_gpu_init(struct radeon_device *rdev); |
47 | int rs600_mc_wait_for_idle(struct radeon_device *rdev); | 47 | int rs600_mc_wait_for_idle(struct radeon_device *rdev); |
48 | 48 | ||
49 | void rs600_pre_page_flip(struct radeon_device *rdev, int crtc) | ||
50 | { | ||
51 | struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc]; | ||
52 | u32 tmp; | ||
53 | |||
54 | /* make sure flip is at vb rather than hb */ | ||
55 | tmp = RREG32(AVIVO_D1GRPH_FLIP_CONTROL + radeon_crtc->crtc_offset); | ||
56 | tmp &= ~AVIVO_D1GRPH_SURFACE_UPDATE_H_RETRACE_EN; | ||
57 | WREG32(AVIVO_D1GRPH_FLIP_CONTROL + radeon_crtc->crtc_offset, tmp); | ||
58 | |||
59 | /* set pageflip to happen anywhere in vblank interval */ | ||
60 | WREG32(AVIVO_D1MODE_MASTER_UPDATE_MODE + radeon_crtc->crtc_offset, 0); | ||
61 | |||
62 | /* enable the pflip int */ | ||
63 | radeon_irq_kms_pflip_irq_get(rdev, crtc); | ||
64 | } | ||
65 | |||
66 | void rs600_post_page_flip(struct radeon_device *rdev, int crtc) | ||
67 | { | ||
68 | /* disable the pflip int */ | ||
69 | radeon_irq_kms_pflip_irq_put(rdev, crtc); | ||
70 | } | ||
71 | |||
72 | u32 rs600_page_flip(struct radeon_device *rdev, int crtc_id, u64 crtc_base) | ||
73 | { | ||
74 | struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc_id]; | ||
75 | u32 tmp = RREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset); | ||
76 | |||
77 | /* Lock the graphics update lock */ | ||
78 | tmp |= AVIVO_D1GRPH_UPDATE_LOCK; | ||
79 | WREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset, tmp); | ||
80 | |||
81 | /* update the scanout addresses */ | ||
82 | WREG32(AVIVO_D1GRPH_SECONDARY_SURFACE_ADDRESS + radeon_crtc->crtc_offset, | ||
83 | (u32)crtc_base); | ||
84 | WREG32(AVIVO_D1GRPH_PRIMARY_SURFACE_ADDRESS + radeon_crtc->crtc_offset, | ||
85 | (u32)crtc_base); | ||
86 | |||
87 | /* Wait for update_pending to go high. */ | ||
88 | while (!(RREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset) & AVIVO_D1GRPH_SURFACE_UPDATE_PENDING)); | ||
89 | DRM_DEBUG("Update pending now high. Unlocking vupdate_lock.\n"); | ||
90 | |||
91 | /* Unlock the lock, so double-buffering can take place inside vblank */ | ||
92 | tmp &= ~AVIVO_D1GRPH_UPDATE_LOCK; | ||
93 | WREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset, tmp); | ||
94 | |||
95 | /* Return current update_pending status: */ | ||
96 | return RREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset) & AVIVO_D1GRPH_SURFACE_UPDATE_PENDING; | ||
97 | } | ||
98 | |||
49 | void rs600_pm_misc(struct radeon_device *rdev) | 99 | void rs600_pm_misc(struct radeon_device *rdev) |
50 | { | 100 | { |
51 | int requested_index = rdev->pm.requested_power_state_index; | 101 | int requested_index = rdev->pm.requested_power_state_index; |
@@ -515,10 +565,12 @@ int rs600_irq_set(struct radeon_device *rdev) | |||
515 | if (rdev->irq.gui_idle) { | 565 | if (rdev->irq.gui_idle) { |
516 | tmp |= S_000040_GUI_IDLE(1); | 566 | tmp |= S_000040_GUI_IDLE(1); |
517 | } | 567 | } |
518 | if (rdev->irq.crtc_vblank_int[0]) { | 568 | if (rdev->irq.crtc_vblank_int[0] || |
569 | rdev->irq.pflip[0]) { | ||
519 | mode_int |= S_006540_D1MODE_VBLANK_INT_MASK(1); | 570 | mode_int |= S_006540_D1MODE_VBLANK_INT_MASK(1); |
520 | } | 571 | } |
521 | if (rdev->irq.crtc_vblank_int[1]) { | 572 | if (rdev->irq.crtc_vblank_int[1] || |
573 | rdev->irq.pflip[1]) { | ||
522 | mode_int |= S_006540_D2MODE_VBLANK_INT_MASK(1); | 574 | mode_int |= S_006540_D2MODE_VBLANK_INT_MASK(1); |
523 | } | 575 | } |
524 | if (rdev->irq.hpd[0]) { | 576 | if (rdev->irq.hpd[0]) { |
@@ -534,7 +586,7 @@ int rs600_irq_set(struct radeon_device *rdev) | |||
534 | return 0; | 586 | return 0; |
535 | } | 587 | } |
536 | 588 | ||
537 | static inline uint32_t rs600_irq_ack(struct radeon_device *rdev, u32 *r500_disp_int) | 589 | static inline u32 rs600_irq_ack(struct radeon_device *rdev) |
538 | { | 590 | { |
539 | uint32_t irqs = RREG32(R_000044_GEN_INT_STATUS); | 591 | uint32_t irqs = RREG32(R_000044_GEN_INT_STATUS); |
540 | uint32_t irq_mask = S_000044_SW_INT(1); | 592 | uint32_t irq_mask = S_000044_SW_INT(1); |
@@ -547,27 +599,27 @@ static inline uint32_t rs600_irq_ack(struct radeon_device *rdev, u32 *r500_disp_ | |||
547 | } | 599 | } |
548 | 600 | ||
549 | if (G_000044_DISPLAY_INT_STAT(irqs)) { | 601 | if (G_000044_DISPLAY_INT_STAT(irqs)) { |
550 | *r500_disp_int = RREG32(R_007EDC_DISP_INTERRUPT_STATUS); | 602 | rdev->irq.stat_regs.r500.disp_int = RREG32(R_007EDC_DISP_INTERRUPT_STATUS); |
551 | if (G_007EDC_LB_D1_VBLANK_INTERRUPT(*r500_disp_int)) { | 603 | if (G_007EDC_LB_D1_VBLANK_INTERRUPT(rdev->irq.stat_regs.r500.disp_int)) { |
552 | WREG32(R_006534_D1MODE_VBLANK_STATUS, | 604 | WREG32(R_006534_D1MODE_VBLANK_STATUS, |
553 | S_006534_D1MODE_VBLANK_ACK(1)); | 605 | S_006534_D1MODE_VBLANK_ACK(1)); |
554 | } | 606 | } |
555 | if (G_007EDC_LB_D2_VBLANK_INTERRUPT(*r500_disp_int)) { | 607 | if (G_007EDC_LB_D2_VBLANK_INTERRUPT(rdev->irq.stat_regs.r500.disp_int)) { |
556 | WREG32(R_006D34_D2MODE_VBLANK_STATUS, | 608 | WREG32(R_006D34_D2MODE_VBLANK_STATUS, |
557 | S_006D34_D2MODE_VBLANK_ACK(1)); | 609 | S_006D34_D2MODE_VBLANK_ACK(1)); |
558 | } | 610 | } |
559 | if (G_007EDC_DC_HOT_PLUG_DETECT1_INTERRUPT(*r500_disp_int)) { | 611 | if (G_007EDC_DC_HOT_PLUG_DETECT1_INTERRUPT(rdev->irq.stat_regs.r500.disp_int)) { |
560 | tmp = RREG32(R_007D08_DC_HOT_PLUG_DETECT1_INT_CONTROL); | 612 | tmp = RREG32(R_007D08_DC_HOT_PLUG_DETECT1_INT_CONTROL); |
561 | tmp |= S_007D08_DC_HOT_PLUG_DETECT1_INT_ACK(1); | 613 | tmp |= S_007D08_DC_HOT_PLUG_DETECT1_INT_ACK(1); |
562 | WREG32(R_007D08_DC_HOT_PLUG_DETECT1_INT_CONTROL, tmp); | 614 | WREG32(R_007D08_DC_HOT_PLUG_DETECT1_INT_CONTROL, tmp); |
563 | } | 615 | } |
564 | if (G_007EDC_DC_HOT_PLUG_DETECT2_INTERRUPT(*r500_disp_int)) { | 616 | if (G_007EDC_DC_HOT_PLUG_DETECT2_INTERRUPT(rdev->irq.stat_regs.r500.disp_int)) { |
565 | tmp = RREG32(R_007D18_DC_HOT_PLUG_DETECT2_INT_CONTROL); | 617 | tmp = RREG32(R_007D18_DC_HOT_PLUG_DETECT2_INT_CONTROL); |
566 | tmp |= S_007D18_DC_HOT_PLUG_DETECT2_INT_ACK(1); | 618 | tmp |= S_007D18_DC_HOT_PLUG_DETECT2_INT_ACK(1); |
567 | WREG32(R_007D18_DC_HOT_PLUG_DETECT2_INT_CONTROL, tmp); | 619 | WREG32(R_007D18_DC_HOT_PLUG_DETECT2_INT_CONTROL, tmp); |
568 | } | 620 | } |
569 | } else { | 621 | } else { |
570 | *r500_disp_int = 0; | 622 | rdev->irq.stat_regs.r500.disp_int = 0; |
571 | } | 623 | } |
572 | 624 | ||
573 | if (irqs) { | 625 | if (irqs) { |
@@ -578,32 +630,30 @@ static inline uint32_t rs600_irq_ack(struct radeon_device *rdev, u32 *r500_disp_ | |||
578 | 630 | ||
579 | void rs600_irq_disable(struct radeon_device *rdev) | 631 | void rs600_irq_disable(struct radeon_device *rdev) |
580 | { | 632 | { |
581 | u32 tmp; | ||
582 | |||
583 | WREG32(R_000040_GEN_INT_CNTL, 0); | 633 | WREG32(R_000040_GEN_INT_CNTL, 0); |
584 | WREG32(R_006540_DxMODE_INT_MASK, 0); | 634 | WREG32(R_006540_DxMODE_INT_MASK, 0); |
585 | /* Wait and acknowledge irq */ | 635 | /* Wait and acknowledge irq */ |
586 | mdelay(1); | 636 | mdelay(1); |
587 | rs600_irq_ack(rdev, &tmp); | 637 | rs600_irq_ack(rdev); |
588 | } | 638 | } |
589 | 639 | ||
590 | int rs600_irq_process(struct radeon_device *rdev) | 640 | int rs600_irq_process(struct radeon_device *rdev) |
591 | { | 641 | { |
592 | uint32_t status, msi_rearm; | 642 | u32 status, msi_rearm; |
593 | uint32_t r500_disp_int; | ||
594 | bool queue_hotplug = false; | 643 | bool queue_hotplug = false; |
595 | 644 | ||
596 | /* reset gui idle ack. the status bit is broken */ | 645 | /* reset gui idle ack. the status bit is broken */ |
597 | rdev->irq.gui_idle_acked = false; | 646 | rdev->irq.gui_idle_acked = false; |
598 | 647 | ||
599 | status = rs600_irq_ack(rdev, &r500_disp_int); | 648 | status = rs600_irq_ack(rdev); |
600 | if (!status && !r500_disp_int) { | 649 | if (!status && !rdev->irq.stat_regs.r500.disp_int) { |
601 | return IRQ_NONE; | 650 | return IRQ_NONE; |
602 | } | 651 | } |
603 | while (status || r500_disp_int) { | 652 | while (status || rdev->irq.stat_regs.r500.disp_int) { |
604 | /* SW interrupt */ | 653 | /* SW interrupt */ |
605 | if (G_000044_SW_INT(status)) | 654 | if (G_000044_SW_INT(status)) { |
606 | radeon_fence_process(rdev); | 655 | radeon_fence_process(rdev); |
656 | } | ||
607 | /* GUI idle */ | 657 | /* GUI idle */ |
608 | if (G_000040_GUI_IDLE(status)) { | 658 | if (G_000040_GUI_IDLE(status)) { |
609 | rdev->irq.gui_idle_acked = true; | 659 | rdev->irq.gui_idle_acked = true; |
@@ -611,30 +661,38 @@ int rs600_irq_process(struct radeon_device *rdev) | |||
611 | wake_up(&rdev->irq.idle_queue); | 661 | wake_up(&rdev->irq.idle_queue); |
612 | } | 662 | } |
613 | /* Vertical blank interrupts */ | 663 | /* Vertical blank interrupts */ |
614 | if (G_007EDC_LB_D1_VBLANK_INTERRUPT(r500_disp_int)) { | 664 | if (G_007EDC_LB_D1_VBLANK_INTERRUPT(rdev->irq.stat_regs.r500.disp_int)) { |
615 | drm_handle_vblank(rdev->ddev, 0); | 665 | if (rdev->irq.crtc_vblank_int[0]) { |
616 | rdev->pm.vblank_sync = true; | 666 | drm_handle_vblank(rdev->ddev, 0); |
617 | wake_up(&rdev->irq.vblank_queue); | 667 | rdev->pm.vblank_sync = true; |
668 | wake_up(&rdev->irq.vblank_queue); | ||
669 | } | ||
670 | if (rdev->irq.pflip[0]) | ||
671 | radeon_crtc_handle_flip(rdev, 0); | ||
618 | } | 672 | } |
619 | if (G_007EDC_LB_D2_VBLANK_INTERRUPT(r500_disp_int)) { | 673 | if (G_007EDC_LB_D2_VBLANK_INTERRUPT(rdev->irq.stat_regs.r500.disp_int)) { |
620 | drm_handle_vblank(rdev->ddev, 1); | 674 | if (rdev->irq.crtc_vblank_int[1]) { |
621 | rdev->pm.vblank_sync = true; | 675 | drm_handle_vblank(rdev->ddev, 1); |
622 | wake_up(&rdev->irq.vblank_queue); | 676 | rdev->pm.vblank_sync = true; |
677 | wake_up(&rdev->irq.vblank_queue); | ||
678 | } | ||
679 | if (rdev->irq.pflip[1]) | ||
680 | radeon_crtc_handle_flip(rdev, 1); | ||
623 | } | 681 | } |
624 | if (G_007EDC_DC_HOT_PLUG_DETECT1_INTERRUPT(r500_disp_int)) { | 682 | if (G_007EDC_DC_HOT_PLUG_DETECT1_INTERRUPT(rdev->irq.stat_regs.r500.disp_int)) { |
625 | queue_hotplug = true; | 683 | queue_hotplug = true; |
626 | DRM_DEBUG("HPD1\n"); | 684 | DRM_DEBUG("HPD1\n"); |
627 | } | 685 | } |
628 | if (G_007EDC_DC_HOT_PLUG_DETECT2_INTERRUPT(r500_disp_int)) { | 686 | if (G_007EDC_DC_HOT_PLUG_DETECT2_INTERRUPT(rdev->irq.stat_regs.r500.disp_int)) { |
629 | queue_hotplug = true; | 687 | queue_hotplug = true; |
630 | DRM_DEBUG("HPD2\n"); | 688 | DRM_DEBUG("HPD2\n"); |
631 | } | 689 | } |
632 | status = rs600_irq_ack(rdev, &r500_disp_int); | 690 | status = rs600_irq_ack(rdev); |
633 | } | 691 | } |
634 | /* reset gui idle ack. the status bit is broken */ | 692 | /* reset gui idle ack. the status bit is broken */ |
635 | rdev->irq.gui_idle_acked = false; | 693 | rdev->irq.gui_idle_acked = false; |
636 | if (queue_hotplug) | 694 | if (queue_hotplug) |
637 | queue_work(rdev->wq, &rdev->hotplug_work); | 695 | schedule_work(&rdev->hotplug_work); |
638 | if (rdev->msi_enabled) { | 696 | if (rdev->msi_enabled) { |
639 | switch (rdev->family) { | 697 | switch (rdev->family) { |
640 | case CHIP_RS600: | 698 | case CHIP_RS600: |