diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/dce_v8_0.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 247 |
1 files changed, 108 insertions, 139 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c index 34b9c2a9d8d4..4f7b49a6dc50 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | |||
@@ -229,46 +229,22 @@ static void dce_v8_0_pageflip_interrupt_fini(struct amdgpu_device *adev) | |||
229 | * @crtc_id: crtc to cleanup pageflip on | 229 | * @crtc_id: crtc to cleanup pageflip on |
230 | * @crtc_base: new address of the crtc (GPU MC address) | 230 | * @crtc_base: new address of the crtc (GPU MC address) |
231 | * | 231 | * |
232 | * Does the actual pageflip (evergreen+). | 232 | * Triggers the actual pageflip by updating the primary |
233 | * During vblank we take the crtc lock and wait for the update_pending | 233 | * surface base address. |
234 | * bit to go high, when it does, we release the lock, and allow the | ||
235 | * double buffered update to take place. | ||
236 | * Returns the current update pending status. | ||
237 | */ | 234 | */ |
238 | static void dce_v8_0_page_flip(struct amdgpu_device *adev, | 235 | static void dce_v8_0_page_flip(struct amdgpu_device *adev, |
239 | int crtc_id, u64 crtc_base) | 236 | int crtc_id, u64 crtc_base) |
240 | { | 237 | { |
241 | struct amdgpu_crtc *amdgpu_crtc = adev->mode_info.crtcs[crtc_id]; | 238 | struct amdgpu_crtc *amdgpu_crtc = adev->mode_info.crtcs[crtc_id]; |
242 | u32 tmp = RREG32(mmGRPH_UPDATE + amdgpu_crtc->crtc_offset); | ||
243 | int i; | ||
244 | |||
245 | /* Lock the graphics update lock */ | ||
246 | tmp |= GRPH_UPDATE__GRPH_UPDATE_LOCK_MASK; | ||
247 | WREG32(mmGRPH_UPDATE + amdgpu_crtc->crtc_offset, tmp); | ||
248 | |||
249 | /* update the scanout addresses */ | ||
250 | WREG32(mmGRPH_SECONDARY_SURFACE_ADDRESS_HIGH + amdgpu_crtc->crtc_offset, | ||
251 | upper_32_bits(crtc_base)); | ||
252 | WREG32(mmGRPH_SECONDARY_SURFACE_ADDRESS + amdgpu_crtc->crtc_offset, | ||
253 | (u32)crtc_base); | ||
254 | 239 | ||
240 | /* update the primary scanout addresses */ | ||
255 | WREG32(mmGRPH_PRIMARY_SURFACE_ADDRESS_HIGH + amdgpu_crtc->crtc_offset, | 241 | WREG32(mmGRPH_PRIMARY_SURFACE_ADDRESS_HIGH + amdgpu_crtc->crtc_offset, |
256 | upper_32_bits(crtc_base)); | 242 | upper_32_bits(crtc_base)); |
243 | /* writing to the low address triggers the update */ | ||
257 | WREG32(mmGRPH_PRIMARY_SURFACE_ADDRESS + amdgpu_crtc->crtc_offset, | 244 | WREG32(mmGRPH_PRIMARY_SURFACE_ADDRESS + amdgpu_crtc->crtc_offset, |
258 | (u32)crtc_base); | 245 | lower_32_bits(crtc_base)); |
259 | 246 | /* post the write */ | |
260 | /* Wait for update_pending to go high. */ | 247 | RREG32(mmGRPH_PRIMARY_SURFACE_ADDRESS + amdgpu_crtc->crtc_offset); |
261 | for (i = 0; i < adev->usec_timeout; i++) { | ||
262 | if (RREG32(mmGRPH_UPDATE + amdgpu_crtc->crtc_offset) & | ||
263 | GRPH_UPDATE__GRPH_SURFACE_UPDATE_PENDING_MASK) | ||
264 | break; | ||
265 | udelay(1); | ||
266 | } | ||
267 | DRM_DEBUG("Update pending now high. Unlocking vupdate_lock.\n"); | ||
268 | |||
269 | /* Unlock the lock, so double-buffering can take place inside vblank */ | ||
270 | tmp &= ~GRPH_UPDATE__GRPH_UPDATE_LOCK_MASK; | ||
271 | WREG32(mmGRPH_UPDATE + amdgpu_crtc->crtc_offset, tmp); | ||
272 | } | 248 | } |
273 | 249 | ||
274 | static int dce_v8_0_crtc_get_scanoutpos(struct amdgpu_device *adev, int crtc, | 250 | static int dce_v8_0_crtc_get_scanoutpos(struct amdgpu_device *adev, int crtc, |
@@ -2429,26 +2405,19 @@ static void dce_v8_0_show_cursor(struct drm_crtc *crtc) | |||
2429 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); | 2405 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); |
2430 | struct amdgpu_device *adev = crtc->dev->dev_private; | 2406 | struct amdgpu_device *adev = crtc->dev->dev_private; |
2431 | 2407 | ||
2408 | WREG32(mmCUR_SURFACE_ADDRESS_HIGH + amdgpu_crtc->crtc_offset, | ||
2409 | upper_32_bits(amdgpu_crtc->cursor_addr)); | ||
2410 | WREG32(mmCUR_SURFACE_ADDRESS + amdgpu_crtc->crtc_offset, | ||
2411 | lower_32_bits(amdgpu_crtc->cursor_addr)); | ||
2412 | |||
2432 | WREG32_IDX(mmCUR_CONTROL + amdgpu_crtc->crtc_offset, | 2413 | WREG32_IDX(mmCUR_CONTROL + amdgpu_crtc->crtc_offset, |
2433 | CUR_CONTROL__CURSOR_EN_MASK | | 2414 | CUR_CONTROL__CURSOR_EN_MASK | |
2434 | (CURSOR_24_8_PRE_MULT << CUR_CONTROL__CURSOR_MODE__SHIFT) | | 2415 | (CURSOR_24_8_PRE_MULT << CUR_CONTROL__CURSOR_MODE__SHIFT) | |
2435 | (CURSOR_URGENT_1_2 << CUR_CONTROL__CURSOR_URGENT_CONTROL__SHIFT)); | 2416 | (CURSOR_URGENT_1_2 << CUR_CONTROL__CURSOR_URGENT_CONTROL__SHIFT)); |
2436 | } | 2417 | } |
2437 | 2418 | ||
2438 | static void dce_v8_0_set_cursor(struct drm_crtc *crtc, struct drm_gem_object *obj, | 2419 | static int dce_v8_0_cursor_move_locked(struct drm_crtc *crtc, |
2439 | uint64_t gpu_addr) | 2420 | int x, int y) |
2440 | { | ||
2441 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); | ||
2442 | struct amdgpu_device *adev = crtc->dev->dev_private; | ||
2443 | |||
2444 | WREG32(mmCUR_SURFACE_ADDRESS_HIGH + amdgpu_crtc->crtc_offset, | ||
2445 | upper_32_bits(gpu_addr)); | ||
2446 | WREG32(mmCUR_SURFACE_ADDRESS + amdgpu_crtc->crtc_offset, | ||
2447 | gpu_addr & 0xffffffff); | ||
2448 | } | ||
2449 | |||
2450 | static int dce_v8_0_crtc_cursor_move(struct drm_crtc *crtc, | ||
2451 | int x, int y) | ||
2452 | { | 2421 | { |
2453 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); | 2422 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); |
2454 | struct amdgpu_device *adev = crtc->dev->dev_private; | 2423 | struct amdgpu_device *adev = crtc->dev->dev_private; |
@@ -2468,26 +2437,40 @@ static int dce_v8_0_crtc_cursor_move(struct drm_crtc *crtc, | |||
2468 | y = 0; | 2437 | y = 0; |
2469 | } | 2438 | } |
2470 | 2439 | ||
2471 | dce_v8_0_lock_cursor(crtc, true); | ||
2472 | WREG32(mmCUR_POSITION + amdgpu_crtc->crtc_offset, (x << 16) | y); | 2440 | WREG32(mmCUR_POSITION + amdgpu_crtc->crtc_offset, (x << 16) | y); |
2473 | WREG32(mmCUR_HOT_SPOT + amdgpu_crtc->crtc_offset, (xorigin << 16) | yorigin); | 2441 | WREG32(mmCUR_HOT_SPOT + amdgpu_crtc->crtc_offset, (xorigin << 16) | yorigin); |
2474 | WREG32(mmCUR_SIZE + amdgpu_crtc->crtc_offset, | 2442 | WREG32(mmCUR_SIZE + amdgpu_crtc->crtc_offset, |
2475 | ((amdgpu_crtc->cursor_width - 1) << 16) | (amdgpu_crtc->cursor_height - 1)); | 2443 | ((amdgpu_crtc->cursor_width - 1) << 16) | (amdgpu_crtc->cursor_height - 1)); |
2476 | dce_v8_0_lock_cursor(crtc, false); | 2444 | |
2445 | amdgpu_crtc->cursor_x = x; | ||
2446 | amdgpu_crtc->cursor_y = y; | ||
2477 | 2447 | ||
2478 | return 0; | 2448 | return 0; |
2479 | } | 2449 | } |
2480 | 2450 | ||
2481 | static int dce_v8_0_crtc_cursor_set(struct drm_crtc *crtc, | 2451 | static int dce_v8_0_crtc_cursor_move(struct drm_crtc *crtc, |
2482 | struct drm_file *file_priv, | 2452 | int x, int y) |
2483 | uint32_t handle, | 2453 | { |
2484 | uint32_t width, | 2454 | int ret; |
2485 | uint32_t height) | 2455 | |
2456 | dce_v8_0_lock_cursor(crtc, true); | ||
2457 | ret = dce_v8_0_cursor_move_locked(crtc, x, y); | ||
2458 | dce_v8_0_lock_cursor(crtc, false); | ||
2459 | |||
2460 | return ret; | ||
2461 | } | ||
2462 | |||
2463 | static int dce_v8_0_crtc_cursor_set2(struct drm_crtc *crtc, | ||
2464 | struct drm_file *file_priv, | ||
2465 | uint32_t handle, | ||
2466 | uint32_t width, | ||
2467 | uint32_t height, | ||
2468 | int32_t hot_x, | ||
2469 | int32_t hot_y) | ||
2486 | { | 2470 | { |
2487 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); | 2471 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); |
2488 | struct drm_gem_object *obj; | 2472 | struct drm_gem_object *obj; |
2489 | struct amdgpu_bo *robj; | 2473 | struct amdgpu_bo *aobj; |
2490 | uint64_t gpu_addr; | ||
2491 | int ret; | 2474 | int ret; |
2492 | 2475 | ||
2493 | if (!handle) { | 2476 | if (!handle) { |
@@ -2509,41 +2492,71 @@ static int dce_v8_0_crtc_cursor_set(struct drm_crtc *crtc, | |||
2509 | return -ENOENT; | 2492 | return -ENOENT; |
2510 | } | 2493 | } |
2511 | 2494 | ||
2512 | robj = gem_to_amdgpu_bo(obj); | 2495 | aobj = gem_to_amdgpu_bo(obj); |
2513 | ret = amdgpu_bo_reserve(robj, false); | 2496 | ret = amdgpu_bo_reserve(aobj, false); |
2514 | if (unlikely(ret != 0)) | 2497 | if (ret != 0) { |
2515 | goto fail; | 2498 | drm_gem_object_unreference_unlocked(obj); |
2516 | ret = amdgpu_bo_pin_restricted(robj, AMDGPU_GEM_DOMAIN_VRAM, | 2499 | return ret; |
2517 | 0, 0, &gpu_addr); | 2500 | } |
2518 | amdgpu_bo_unreserve(robj); | 2501 | |
2519 | if (ret) | 2502 | ret = amdgpu_bo_pin(aobj, AMDGPU_GEM_DOMAIN_VRAM, &amdgpu_crtc->cursor_addr); |
2520 | goto fail; | 2503 | amdgpu_bo_unreserve(aobj); |
2504 | if (ret) { | ||
2505 | DRM_ERROR("Failed to pin new cursor BO (%d)\n", ret); | ||
2506 | drm_gem_object_unreference_unlocked(obj); | ||
2507 | return ret; | ||
2508 | } | ||
2521 | 2509 | ||
2522 | amdgpu_crtc->cursor_width = width; | 2510 | amdgpu_crtc->cursor_width = width; |
2523 | amdgpu_crtc->cursor_height = height; | 2511 | amdgpu_crtc->cursor_height = height; |
2524 | 2512 | ||
2525 | dce_v8_0_lock_cursor(crtc, true); | 2513 | dce_v8_0_lock_cursor(crtc, true); |
2526 | dce_v8_0_set_cursor(crtc, obj, gpu_addr); | 2514 | |
2515 | if (hot_x != amdgpu_crtc->cursor_hot_x || | ||
2516 | hot_y != amdgpu_crtc->cursor_hot_y) { | ||
2517 | int x, y; | ||
2518 | |||
2519 | x = amdgpu_crtc->cursor_x + amdgpu_crtc->cursor_hot_x - hot_x; | ||
2520 | y = amdgpu_crtc->cursor_y + amdgpu_crtc->cursor_hot_y - hot_y; | ||
2521 | |||
2522 | dce_v8_0_cursor_move_locked(crtc, x, y); | ||
2523 | |||
2524 | amdgpu_crtc->cursor_hot_x = hot_x; | ||
2525 | amdgpu_crtc->cursor_hot_y = hot_y; | ||
2526 | } | ||
2527 | |||
2527 | dce_v8_0_show_cursor(crtc); | 2528 | dce_v8_0_show_cursor(crtc); |
2528 | dce_v8_0_lock_cursor(crtc, false); | 2529 | dce_v8_0_lock_cursor(crtc, false); |
2529 | 2530 | ||
2530 | unpin: | 2531 | unpin: |
2531 | if (amdgpu_crtc->cursor_bo) { | 2532 | if (amdgpu_crtc->cursor_bo) { |
2532 | robj = gem_to_amdgpu_bo(amdgpu_crtc->cursor_bo); | 2533 | struct amdgpu_bo *aobj = gem_to_amdgpu_bo(amdgpu_crtc->cursor_bo); |
2533 | ret = amdgpu_bo_reserve(robj, false); | 2534 | ret = amdgpu_bo_reserve(aobj, false); |
2534 | if (likely(ret == 0)) { | 2535 | if (likely(ret == 0)) { |
2535 | amdgpu_bo_unpin(robj); | 2536 | amdgpu_bo_unpin(aobj); |
2536 | amdgpu_bo_unreserve(robj); | 2537 | amdgpu_bo_unreserve(aobj); |
2537 | } | 2538 | } |
2538 | drm_gem_object_unreference_unlocked(amdgpu_crtc->cursor_bo); | 2539 | drm_gem_object_unreference_unlocked(amdgpu_crtc->cursor_bo); |
2539 | } | 2540 | } |
2540 | 2541 | ||
2541 | amdgpu_crtc->cursor_bo = obj; | 2542 | amdgpu_crtc->cursor_bo = obj; |
2542 | return 0; | 2543 | return 0; |
2543 | fail: | 2544 | } |
2544 | drm_gem_object_unreference_unlocked(obj); | ||
2545 | 2545 | ||
2546 | return ret; | 2546 | static void dce_v8_0_cursor_reset(struct drm_crtc *crtc) |
2547 | { | ||
2548 | struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc); | ||
2549 | |||
2550 | if (amdgpu_crtc->cursor_bo) { | ||
2551 | dce_v8_0_lock_cursor(crtc, true); | ||
2552 | |||
2553 | dce_v8_0_cursor_move_locked(crtc, amdgpu_crtc->cursor_x, | ||
2554 | amdgpu_crtc->cursor_y); | ||
2555 | |||
2556 | dce_v8_0_show_cursor(crtc); | ||
2557 | |||
2558 | dce_v8_0_lock_cursor(crtc, false); | ||
2559 | } | ||
2547 | } | 2560 | } |
2548 | 2561 | ||
2549 | static void dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, | 2562 | static void dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, |
@@ -2571,7 +2584,7 @@ static void dce_v8_0_crtc_destroy(struct drm_crtc *crtc) | |||
2571 | } | 2584 | } |
2572 | 2585 | ||
2573 | static const struct drm_crtc_funcs dce_v8_0_crtc_funcs = { | 2586 | static const struct drm_crtc_funcs dce_v8_0_crtc_funcs = { |
2574 | .cursor_set = dce_v8_0_crtc_cursor_set, | 2587 | .cursor_set2 = dce_v8_0_crtc_cursor_set2, |
2575 | .cursor_move = dce_v8_0_crtc_cursor_move, | 2588 | .cursor_move = dce_v8_0_crtc_cursor_move, |
2576 | .gamma_set = dce_v8_0_crtc_gamma_set, | 2589 | .gamma_set = dce_v8_0_crtc_gamma_set, |
2577 | .set_config = amdgpu_crtc_set_config, | 2590 | .set_config = amdgpu_crtc_set_config, |
@@ -2712,6 +2725,7 @@ static int dce_v8_0_crtc_mode_set(struct drm_crtc *crtc, | |||
2712 | dce_v8_0_crtc_do_set_base(crtc, old_fb, x, y, 0); | 2725 | dce_v8_0_crtc_do_set_base(crtc, old_fb, x, y, 0); |
2713 | amdgpu_atombios_crtc_overscan_setup(crtc, mode, adjusted_mode); | 2726 | amdgpu_atombios_crtc_overscan_setup(crtc, mode, adjusted_mode); |
2714 | amdgpu_atombios_crtc_scaler_setup(crtc); | 2727 | amdgpu_atombios_crtc_scaler_setup(crtc); |
2728 | dce_v8_0_cursor_reset(crtc); | ||
2715 | /* update the hw version fpr dpm */ | 2729 | /* update the hw version fpr dpm */ |
2716 | amdgpu_crtc->hw_mode = *adjusted_mode; | 2730 | amdgpu_crtc->hw_mode = *adjusted_mode; |
2717 | 2731 | ||
@@ -2979,22 +2993,18 @@ static int dce_v8_0_suspend(void *handle) | |||
2979 | 2993 | ||
2980 | amdgpu_atombios_scratch_regs_save(adev); | 2994 | amdgpu_atombios_scratch_regs_save(adev); |
2981 | 2995 | ||
2982 | dce_v8_0_hpd_fini(adev); | 2996 | return dce_v8_0_hw_fini(handle); |
2983 | |||
2984 | dce_v8_0_pageflip_interrupt_fini(adev); | ||
2985 | |||
2986 | return 0; | ||
2987 | } | 2997 | } |
2988 | 2998 | ||
2989 | static int dce_v8_0_resume(void *handle) | 2999 | static int dce_v8_0_resume(void *handle) |
2990 | { | 3000 | { |
2991 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 3001 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
3002 | int ret; | ||
3003 | |||
3004 | ret = dce_v8_0_hw_init(handle); | ||
2992 | 3005 | ||
2993 | amdgpu_atombios_scratch_regs_restore(adev); | 3006 | amdgpu_atombios_scratch_regs_restore(adev); |
2994 | 3007 | ||
2995 | /* init dig PHYs, disp eng pll */ | ||
2996 | amdgpu_atombios_encoder_init_dig(adev); | ||
2997 | amdgpu_atombios_crtc_set_disp_eng_pll(adev, adev->clock.default_dispclk); | ||
2998 | /* turn on the BL */ | 3008 | /* turn on the BL */ |
2999 | if (adev->mode_info.bl_encoder) { | 3009 | if (adev->mode_info.bl_encoder) { |
3000 | u8 bl_level = amdgpu_display_backlight_get_level(adev, | 3010 | u8 bl_level = amdgpu_display_backlight_get_level(adev, |
@@ -3003,12 +3013,7 @@ static int dce_v8_0_resume(void *handle) | |||
3003 | bl_level); | 3013 | bl_level); |
3004 | } | 3014 | } |
3005 | 3015 | ||
3006 | /* initialize hpd */ | 3016 | return ret; |
3007 | dce_v8_0_hpd_init(adev); | ||
3008 | |||
3009 | dce_v8_0_pageflip_interrupt_init(adev); | ||
3010 | |||
3011 | return 0; | ||
3012 | } | 3017 | } |
3013 | 3018 | ||
3014 | static bool dce_v8_0_is_idle(void *handle) | 3019 | static bool dce_v8_0_is_idle(void *handle) |
@@ -3301,37 +3306,20 @@ static int dce_v8_0_set_pageflip_interrupt_state(struct amdgpu_device *adev, | |||
3301 | unsigned type, | 3306 | unsigned type, |
3302 | enum amdgpu_interrupt_state state) | 3307 | enum amdgpu_interrupt_state state) |
3303 | { | 3308 | { |
3304 | u32 reg, reg_block; | 3309 | u32 reg; |
3305 | /* now deal with page flip IRQ */ | 3310 | |
3306 | switch (type) { | 3311 | if (type >= adev->mode_info.num_crtc) { |
3307 | case AMDGPU_PAGEFLIP_IRQ_D1: | 3312 | DRM_ERROR("invalid pageflip crtc %d\n", type); |
3308 | reg_block = CRTC0_REGISTER_OFFSET; | 3313 | return -EINVAL; |
3309 | break; | ||
3310 | case AMDGPU_PAGEFLIP_IRQ_D2: | ||
3311 | reg_block = CRTC1_REGISTER_OFFSET; | ||
3312 | break; | ||
3313 | case AMDGPU_PAGEFLIP_IRQ_D3: | ||
3314 | reg_block = CRTC2_REGISTER_OFFSET; | ||
3315 | break; | ||
3316 | case AMDGPU_PAGEFLIP_IRQ_D4: | ||
3317 | reg_block = CRTC3_REGISTER_OFFSET; | ||
3318 | break; | ||
3319 | case AMDGPU_PAGEFLIP_IRQ_D5: | ||
3320 | reg_block = CRTC4_REGISTER_OFFSET; | ||
3321 | break; | ||
3322 | case AMDGPU_PAGEFLIP_IRQ_D6: | ||
3323 | reg_block = CRTC5_REGISTER_OFFSET; | ||
3324 | break; | ||
3325 | default: | ||
3326 | DRM_ERROR("invalid pageflip crtc %d\n", type); | ||
3327 | return -EINVAL; | ||
3328 | } | 3314 | } |
3329 | 3315 | ||
3330 | reg = RREG32(mmGRPH_INTERRUPT_CONTROL + reg_block); | 3316 | reg = RREG32(mmGRPH_INTERRUPT_CONTROL + crtc_offsets[type]); |
3331 | if (state == AMDGPU_IRQ_STATE_DISABLE) | 3317 | if (state == AMDGPU_IRQ_STATE_DISABLE) |
3332 | WREG32(mmGRPH_INTERRUPT_CONTROL + reg_block, reg & ~GRPH_INTERRUPT_CONTROL__GRPH_PFLIP_INT_MASK_MASK); | 3318 | WREG32(mmGRPH_INTERRUPT_CONTROL + crtc_offsets[type], |
3319 | reg & ~GRPH_INTERRUPT_CONTROL__GRPH_PFLIP_INT_MASK_MASK); | ||
3333 | else | 3320 | else |
3334 | WREG32(mmGRPH_INTERRUPT_CONTROL + reg_block, reg | GRPH_INTERRUPT_CONTROL__GRPH_PFLIP_INT_MASK_MASK); | 3321 | WREG32(mmGRPH_INTERRUPT_CONTROL + crtc_offsets[type], |
3322 | reg | GRPH_INTERRUPT_CONTROL__GRPH_PFLIP_INT_MASK_MASK); | ||
3335 | 3323 | ||
3336 | return 0; | 3324 | return 0; |
3337 | } | 3325 | } |
@@ -3340,7 +3328,6 @@ static int dce_v8_0_pageflip_irq(struct amdgpu_device *adev, | |||
3340 | struct amdgpu_irq_src *source, | 3328 | struct amdgpu_irq_src *source, |
3341 | struct amdgpu_iv_entry *entry) | 3329 | struct amdgpu_iv_entry *entry) |
3342 | { | 3330 | { |
3343 | int reg_block; | ||
3344 | unsigned long flags; | 3331 | unsigned long flags; |
3345 | unsigned crtc_id; | 3332 | unsigned crtc_id; |
3346 | struct amdgpu_crtc *amdgpu_crtc; | 3333 | struct amdgpu_crtc *amdgpu_crtc; |
@@ -3349,33 +3336,15 @@ static int dce_v8_0_pageflip_irq(struct amdgpu_device *adev, | |||
3349 | crtc_id = (entry->src_id - 8) >> 1; | 3336 | crtc_id = (entry->src_id - 8) >> 1; |
3350 | amdgpu_crtc = adev->mode_info.crtcs[crtc_id]; | 3337 | amdgpu_crtc = adev->mode_info.crtcs[crtc_id]; |
3351 | 3338 | ||
3352 | /* ack the interrupt */ | 3339 | if (crtc_id >= adev->mode_info.num_crtc) { |
3353 | switch(crtc_id){ | 3340 | DRM_ERROR("invalid pageflip crtc %d\n", crtc_id); |
3354 | case AMDGPU_PAGEFLIP_IRQ_D1: | 3341 | return -EINVAL; |
3355 | reg_block = CRTC0_REGISTER_OFFSET; | ||
3356 | break; | ||
3357 | case AMDGPU_PAGEFLIP_IRQ_D2: | ||
3358 | reg_block = CRTC1_REGISTER_OFFSET; | ||
3359 | break; | ||
3360 | case AMDGPU_PAGEFLIP_IRQ_D3: | ||
3361 | reg_block = CRTC2_REGISTER_OFFSET; | ||
3362 | break; | ||
3363 | case AMDGPU_PAGEFLIP_IRQ_D4: | ||
3364 | reg_block = CRTC3_REGISTER_OFFSET; | ||
3365 | break; | ||
3366 | case AMDGPU_PAGEFLIP_IRQ_D5: | ||
3367 | reg_block = CRTC4_REGISTER_OFFSET; | ||
3368 | break; | ||
3369 | case AMDGPU_PAGEFLIP_IRQ_D6: | ||
3370 | reg_block = CRTC5_REGISTER_OFFSET; | ||
3371 | break; | ||
3372 | default: | ||
3373 | DRM_ERROR("invalid pageflip crtc %d\n", crtc_id); | ||
3374 | return -EINVAL; | ||
3375 | } | 3342 | } |
3376 | 3343 | ||
3377 | if (RREG32(mmGRPH_INTERRUPT_STATUS + reg_block) & GRPH_INTERRUPT_STATUS__GRPH_PFLIP_INT_OCCURRED_MASK) | 3344 | if (RREG32(mmGRPH_INTERRUPT_STATUS + crtc_offsets[crtc_id]) & |
3378 | WREG32(mmGRPH_INTERRUPT_STATUS + reg_block, GRPH_INTERRUPT_STATUS__GRPH_PFLIP_INT_CLEAR_MASK); | 3345 | GRPH_INTERRUPT_STATUS__GRPH_PFLIP_INT_OCCURRED_MASK) |
3346 | WREG32(mmGRPH_INTERRUPT_STATUS + crtc_offsets[crtc_id], | ||
3347 | GRPH_INTERRUPT_STATUS__GRPH_PFLIP_INT_CLEAR_MASK); | ||
3379 | 3348 | ||
3380 | /* IRQ could occur when in initial stage */ | 3349 | /* IRQ could occur when in initial stage */ |
3381 | if (amdgpu_crtc == NULL) | 3350 | if (amdgpu_crtc == NULL) |