diff options
Diffstat (limited to 'drivers/gpu/drm/nouveau/nv50_display.c')
| -rw-r--r-- | drivers/gpu/drm/nouveau/nv50_display.c | 178 |
1 files changed, 105 insertions, 73 deletions
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c index a6237c9cbbc3..7f0e6c3f37d1 100644 --- a/drivers/gpu/drm/nouveau/nv50_display.c +++ b/drivers/gpu/drm/nouveau/nv50_display.c | |||
| @@ -55,9 +55,9 @@ | |||
| 55 | 55 | ||
| 56 | /* offsets in shared sync bo of various structures */ | 56 | /* offsets in shared sync bo of various structures */ |
| 57 | #define EVO_SYNC(c, o) ((c) * 0x0100 + (o)) | 57 | #define EVO_SYNC(c, o) ((c) * 0x0100 + (o)) |
| 58 | #define EVO_MAST_NTFY EVO_SYNC( 0, 0x00) | 58 | #define EVO_MAST_NTFY EVO_SYNC( 0, 0x00) |
| 59 | #define EVO_FLIP_SEM0(c) EVO_SYNC((c), 0x00) | 59 | #define EVO_FLIP_SEM0(c) EVO_SYNC((c) + 1, 0x00) |
| 60 | #define EVO_FLIP_SEM1(c) EVO_SYNC((c), 0x10) | 60 | #define EVO_FLIP_SEM1(c) EVO_SYNC((c) + 1, 0x10) |
| 61 | 61 | ||
| 62 | #define EVO_CORE_HANDLE (0xd1500000) | 62 | #define EVO_CORE_HANDLE (0xd1500000) |
| 63 | #define EVO_CHAN_HANDLE(t,i) (0xd15c0000 | (((t) & 0x00ff) << 8) | (i)) | 63 | #define EVO_CHAN_HANDLE(t,i) (0xd15c0000 | (((t) & 0x00ff) << 8) | (i)) |
| @@ -341,10 +341,8 @@ struct nv50_curs { | |||
| 341 | 341 | ||
| 342 | struct nv50_sync { | 342 | struct nv50_sync { |
| 343 | struct nv50_dmac base; | 343 | struct nv50_dmac base; |
| 344 | struct { | 344 | u32 addr; |
| 345 | u32 offset; | 345 | u32 data; |
| 346 | u16 value; | ||
| 347 | } sem; | ||
| 348 | }; | 346 | }; |
| 349 | 347 | ||
| 350 | struct nv50_ovly { | 348 | struct nv50_ovly { |
| @@ -471,13 +469,33 @@ nv50_display_crtc_sema(struct drm_device *dev, int crtc) | |||
| 471 | return nv50_disp(dev)->sync; | 469 | return nv50_disp(dev)->sync; |
| 472 | } | 470 | } |
| 473 | 471 | ||
| 472 | struct nv50_display_flip { | ||
| 473 | struct nv50_disp *disp; | ||
| 474 | struct nv50_sync *chan; | ||
| 475 | }; | ||
| 476 | |||
| 477 | static bool | ||
| 478 | nv50_display_flip_wait(void *data) | ||
| 479 | { | ||
| 480 | struct nv50_display_flip *flip = data; | ||
| 481 | if (nouveau_bo_rd32(flip->disp->sync, flip->chan->addr / 4) == | ||
| 482 | flip->chan->data); | ||
| 483 | return true; | ||
| 484 | usleep_range(1, 2); | ||
| 485 | return false; | ||
| 486 | } | ||
| 487 | |||
| 474 | void | 488 | void |
| 475 | nv50_display_flip_stop(struct drm_crtc *crtc) | 489 | nv50_display_flip_stop(struct drm_crtc *crtc) |
| 476 | { | 490 | { |
| 477 | struct nv50_sync *sync = nv50_sync(crtc); | 491 | struct nouveau_device *device = nouveau_dev(crtc->dev); |
| 492 | struct nv50_display_flip flip = { | ||
| 493 | .disp = nv50_disp(crtc->dev), | ||
| 494 | .chan = nv50_sync(crtc), | ||
| 495 | }; | ||
| 478 | u32 *push; | 496 | u32 *push; |
| 479 | 497 | ||
| 480 | push = evo_wait(sync, 8); | 498 | push = evo_wait(flip.chan, 8); |
| 481 | if (push) { | 499 | if (push) { |
| 482 | evo_mthd(push, 0x0084, 1); | 500 | evo_mthd(push, 0x0084, 1); |
| 483 | evo_data(push, 0x00000000); | 501 | evo_data(push, 0x00000000); |
| @@ -487,8 +505,10 @@ nv50_display_flip_stop(struct drm_crtc *crtc) | |||
| 487 | evo_data(push, 0x00000000); | 505 | evo_data(push, 0x00000000); |
| 488 | evo_mthd(push, 0x0080, 1); | 506 | evo_mthd(push, 0x0080, 1); |
| 489 | evo_data(push, 0x00000000); | 507 | evo_data(push, 0x00000000); |
| 490 | evo_kick(push, sync); | 508 | evo_kick(push, flip.chan); |
| 491 | } | 509 | } |
| 510 | |||
| 511 | nv_wait_cb(device, nv50_display_flip_wait, &flip); | ||
| 492 | } | 512 | } |
| 493 | 513 | ||
| 494 | int | 514 | int |
| @@ -496,73 +516,78 @@ nv50_display_flip_next(struct drm_crtc *crtc, struct drm_framebuffer *fb, | |||
| 496 | struct nouveau_channel *chan, u32 swap_interval) | 516 | struct nouveau_channel *chan, u32 swap_interval) |
| 497 | { | 517 | { |
| 498 | struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb); | 518 | struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb); |
| 499 | struct nv50_disp *disp = nv50_disp(crtc->dev); | ||
| 500 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 519 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
| 501 | struct nv50_sync *sync = nv50_sync(crtc); | 520 | struct nv50_sync *sync = nv50_sync(crtc); |
| 521 | int head = nv_crtc->index, ret; | ||
| 502 | u32 *push; | 522 | u32 *push; |
| 503 | int ret; | ||
| 504 | 523 | ||
| 505 | swap_interval <<= 4; | 524 | swap_interval <<= 4; |
| 506 | if (swap_interval == 0) | 525 | if (swap_interval == 0) |
| 507 | swap_interval |= 0x100; | 526 | swap_interval |= 0x100; |
| 527 | if (chan == NULL) | ||
| 528 | evo_sync(crtc->dev); | ||
| 508 | 529 | ||
| 509 | push = evo_wait(sync, 128); | 530 | push = evo_wait(sync, 128); |
| 510 | if (unlikely(push == NULL)) | 531 | if (unlikely(push == NULL)) |
| 511 | return -EBUSY; | 532 | return -EBUSY; |
| 512 | 533 | ||
| 513 | /* synchronise with the rendering channel, if necessary */ | 534 | if (chan && nv_mclass(chan->object) < NV84_CHANNEL_IND_CLASS) { |
| 514 | if (likely(chan)) { | 535 | ret = RING_SPACE(chan, 8); |
| 536 | if (ret) | ||
| 537 | return ret; | ||
| 538 | |||
| 539 | BEGIN_NV04(chan, 0, NV11_SUBCHAN_DMA_SEMAPHORE, 2); | ||
| 540 | OUT_RING (chan, NvEvoSema0 + head); | ||
| 541 | OUT_RING (chan, sync->addr ^ 0x10); | ||
| 542 | BEGIN_NV04(chan, 0, NV11_SUBCHAN_SEMAPHORE_RELEASE, 1); | ||
| 543 | OUT_RING (chan, sync->data + 1); | ||
| 544 | BEGIN_NV04(chan, 0, NV11_SUBCHAN_SEMAPHORE_OFFSET, 2); | ||
| 545 | OUT_RING (chan, sync->addr); | ||
| 546 | OUT_RING (chan, sync->data); | ||
| 547 | } else | ||
| 548 | if (chan && nv_mclass(chan->object) < NVC0_CHANNEL_IND_CLASS) { | ||
| 549 | u64 addr = nv84_fence_crtc(chan, head) + sync->addr; | ||
| 550 | ret = RING_SPACE(chan, 12); | ||
| 551 | if (ret) | ||
| 552 | return ret; | ||
| 553 | |||
| 554 | BEGIN_NV04(chan, 0, NV11_SUBCHAN_DMA_SEMAPHORE, 1); | ||
| 555 | OUT_RING (chan, chan->vram); | ||
| 556 | BEGIN_NV04(chan, 0, NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH, 4); | ||
| 557 | OUT_RING (chan, upper_32_bits(addr ^ 0x10)); | ||
| 558 | OUT_RING (chan, lower_32_bits(addr ^ 0x10)); | ||
| 559 | OUT_RING (chan, sync->data + 1); | ||
| 560 | OUT_RING (chan, NV84_SUBCHAN_SEMAPHORE_TRIGGER_WRITE_LONG); | ||
| 561 | BEGIN_NV04(chan, 0, NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH, 4); | ||
| 562 | OUT_RING (chan, upper_32_bits(addr)); | ||
| 563 | OUT_RING (chan, lower_32_bits(addr)); | ||
| 564 | OUT_RING (chan, sync->data); | ||
| 565 | OUT_RING (chan, NV84_SUBCHAN_SEMAPHORE_TRIGGER_ACQUIRE_EQUAL); | ||
| 566 | } else | ||
| 567 | if (chan) { | ||
| 568 | u64 addr = nv84_fence_crtc(chan, head) + sync->addr; | ||
| 515 | ret = RING_SPACE(chan, 10); | 569 | ret = RING_SPACE(chan, 10); |
| 516 | if (ret) | 570 | if (ret) |
| 517 | return ret; | 571 | return ret; |
| 518 | 572 | ||
| 519 | if (nv_mclass(chan->object) < NV84_CHANNEL_IND_CLASS) { | 573 | BEGIN_NVC0(chan, 0, NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH, 4); |
| 520 | BEGIN_NV04(chan, 0, NV11_SUBCHAN_DMA_SEMAPHORE, 2); | 574 | OUT_RING (chan, upper_32_bits(addr ^ 0x10)); |
| 521 | OUT_RING (chan, NvEvoSema0 + nv_crtc->index); | 575 | OUT_RING (chan, lower_32_bits(addr ^ 0x10)); |
| 522 | OUT_RING (chan, sync->sem.offset); | 576 | OUT_RING (chan, sync->data + 1); |
| 523 | BEGIN_NV04(chan, 0, NV11_SUBCHAN_SEMAPHORE_RELEASE, 1); | 577 | OUT_RING (chan, NV84_SUBCHAN_SEMAPHORE_TRIGGER_WRITE_LONG | |
| 524 | OUT_RING (chan, 0xf00d0000 | sync->sem.value); | 578 | NVC0_SUBCHAN_SEMAPHORE_TRIGGER_YIELD); |
| 525 | BEGIN_NV04(chan, 0, NV11_SUBCHAN_SEMAPHORE_OFFSET, 2); | 579 | BEGIN_NVC0(chan, 0, NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH, 4); |
| 526 | OUT_RING (chan, sync->sem.offset ^ 0x10); | 580 | OUT_RING (chan, upper_32_bits(addr)); |
| 527 | OUT_RING (chan, 0x74b1e000); | 581 | OUT_RING (chan, lower_32_bits(addr)); |
| 528 | BEGIN_NV04(chan, 0, NV11_SUBCHAN_DMA_SEMAPHORE, 1); | 582 | OUT_RING (chan, sync->data); |
| 529 | OUT_RING (chan, NvSema); | 583 | OUT_RING (chan, NV84_SUBCHAN_SEMAPHORE_TRIGGER_ACQUIRE_EQUAL | |
| 530 | } else | 584 | NVC0_SUBCHAN_SEMAPHORE_TRIGGER_YIELD); |
| 531 | if (nv_mclass(chan->object) < NVC0_CHANNEL_IND_CLASS) { | 585 | } |
| 532 | u64 offset = nv84_fence_crtc(chan, nv_crtc->index); | ||
| 533 | offset += sync->sem.offset; | ||
| 534 | |||
| 535 | BEGIN_NV04(chan, 0, NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH, 4); | ||
| 536 | OUT_RING (chan, upper_32_bits(offset)); | ||
| 537 | OUT_RING (chan, lower_32_bits(offset)); | ||
| 538 | OUT_RING (chan, 0xf00d0000 | sync->sem.value); | ||
| 539 | OUT_RING (chan, 0x00000002); | ||
| 540 | BEGIN_NV04(chan, 0, NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH, 4); | ||
| 541 | OUT_RING (chan, upper_32_bits(offset)); | ||
| 542 | OUT_RING (chan, lower_32_bits(offset ^ 0x10)); | ||
| 543 | OUT_RING (chan, 0x74b1e000); | ||
| 544 | OUT_RING (chan, 0x00000001); | ||
| 545 | } else { | ||
| 546 | u64 offset = nv84_fence_crtc(chan, nv_crtc->index); | ||
| 547 | offset += sync->sem.offset; | ||
| 548 | |||
| 549 | BEGIN_NVC0(chan, 0, NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH, 4); | ||
| 550 | OUT_RING (chan, upper_32_bits(offset)); | ||
| 551 | OUT_RING (chan, lower_32_bits(offset)); | ||
| 552 | OUT_RING (chan, 0xf00d0000 | sync->sem.value); | ||
| 553 | OUT_RING (chan, 0x00001002); | ||
| 554 | BEGIN_NVC0(chan, 0, NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH, 4); | ||
| 555 | OUT_RING (chan, upper_32_bits(offset)); | ||
| 556 | OUT_RING (chan, lower_32_bits(offset ^ 0x10)); | ||
| 557 | OUT_RING (chan, 0x74b1e000); | ||
| 558 | OUT_RING (chan, 0x00001001); | ||
| 559 | } | ||
| 560 | 586 | ||
| 587 | if (chan) { | ||
| 588 | sync->addr ^= 0x10; | ||
| 589 | sync->data++; | ||
| 561 | FIRE_RING (chan); | 590 | FIRE_RING (chan); |
| 562 | } else { | ||
| 563 | nouveau_bo_wr32(disp->sync, sync->sem.offset / 4, | ||
| 564 | 0xf00d0000 | sync->sem.value); | ||
| 565 | evo_sync(crtc->dev); | ||
| 566 | } | 591 | } |
| 567 | 592 | ||
| 568 | /* queue the flip */ | 593 | /* queue the flip */ |
| @@ -575,9 +600,9 @@ nv50_display_flip_next(struct drm_crtc *crtc, struct drm_framebuffer *fb, | |||
| 575 | evo_data(push, 0x40000000); | 600 | evo_data(push, 0x40000000); |
| 576 | } | 601 | } |
| 577 | evo_mthd(push, 0x0088, 4); | 602 | evo_mthd(push, 0x0088, 4); |
| 578 | evo_data(push, sync->sem.offset); | 603 | evo_data(push, sync->addr); |
| 579 | evo_data(push, 0xf00d0000 | sync->sem.value); | 604 | evo_data(push, sync->data++); |
| 580 | evo_data(push, 0x74b1e000); | 605 | evo_data(push, sync->data); |
| 581 | evo_data(push, NvEvoSync); | 606 | evo_data(push, NvEvoSync); |
| 582 | evo_mthd(push, 0x00a0, 2); | 607 | evo_mthd(push, 0x00a0, 2); |
| 583 | evo_data(push, 0x00000000); | 608 | evo_data(push, 0x00000000); |
| @@ -605,9 +630,6 @@ nv50_display_flip_next(struct drm_crtc *crtc, struct drm_framebuffer *fb, | |||
| 605 | evo_mthd(push, 0x0080, 1); | 630 | evo_mthd(push, 0x0080, 1); |
| 606 | evo_data(push, 0x00000000); | 631 | evo_data(push, 0x00000000); |
| 607 | evo_kick(push, sync); | 632 | evo_kick(push, sync); |
| 608 | |||
| 609 | sync->sem.offset ^= 0x10; | ||
| 610 | sync->sem.value++; | ||
| 611 | return 0; | 633 | return 0; |
| 612 | } | 634 | } |
| 613 | 635 | ||
| @@ -1379,7 +1401,8 @@ nv50_crtc_create(struct drm_device *dev, struct nouveau_object *core, int index) | |||
| 1379 | if (ret) | 1401 | if (ret) |
| 1380 | goto out; | 1402 | goto out; |
| 1381 | 1403 | ||
| 1382 | head->sync.sem.offset = EVO_SYNC(1 + index, 0x00); | 1404 | head->sync.addr = EVO_FLIP_SEM0(index); |
| 1405 | head->sync.data = 0x00000000; | ||
| 1383 | 1406 | ||
| 1384 | /* allocate overlay resources */ | 1407 | /* allocate overlay resources */ |
| 1385 | ret = nv50_pioc_create(disp->core, NV50_DISP_OIMM_CLASS, index, | 1408 | ret = nv50_pioc_create(disp->core, NV50_DISP_OIMM_CLASS, index, |
| @@ -2112,15 +2135,23 @@ nv50_display_fini(struct drm_device *dev) | |||
| 2112 | int | 2135 | int |
| 2113 | nv50_display_init(struct drm_device *dev) | 2136 | nv50_display_init(struct drm_device *dev) |
| 2114 | { | 2137 | { |
| 2115 | u32 *push = evo_wait(nv50_mast(dev), 32); | 2138 | struct nv50_disp *disp = nv50_disp(dev); |
| 2116 | if (push) { | 2139 | struct drm_crtc *crtc; |
| 2117 | evo_mthd(push, 0x0088, 1); | 2140 | u32 *push; |
| 2118 | evo_data(push, NvEvoSync); | 2141 | |
| 2119 | evo_kick(push, nv50_mast(dev)); | 2142 | push = evo_wait(nv50_mast(dev), 32); |
| 2120 | return 0; | 2143 | if (!push) |
| 2144 | return -EBUSY; | ||
| 2145 | |||
| 2146 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { | ||
| 2147 | struct nv50_sync *sync = nv50_sync(crtc); | ||
| 2148 | nouveau_bo_wr32(disp->sync, sync->addr / 4, sync->data); | ||
| 2121 | } | 2149 | } |
| 2122 | 2150 | ||
| 2123 | return -EBUSY; | 2151 | evo_mthd(push, 0x0088, 1); |
| 2152 | evo_data(push, NvEvoSync); | ||
| 2153 | evo_kick(push, nv50_mast(dev)); | ||
| 2154 | return 0; | ||
| 2124 | } | 2155 | } |
| 2125 | 2156 | ||
| 2126 | void | 2157 | void |
| @@ -2245,6 +2276,7 @@ nv50_display_create(struct drm_device *dev) | |||
| 2245 | NV_WARN(drm, "failed to create encoder %d/%d/%d: %d\n", | 2276 | NV_WARN(drm, "failed to create encoder %d/%d/%d: %d\n", |
| 2246 | dcbe->location, dcbe->type, | 2277 | dcbe->location, dcbe->type, |
| 2247 | ffs(dcbe->or) - 1, ret); | 2278 | ffs(dcbe->or) - 1, ret); |
| 2279 | ret = 0; | ||
| 2248 | } | 2280 | } |
| 2249 | } | 2281 | } |
| 2250 | 2282 | ||
