diff options
author | Francisco Jerez <currojerez@riseup.net> | 2010-08-03 22:54:08 -0400 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2010-08-05 18:34:51 -0400 |
commit | d2f4e89254b5816925a207a221e6b26100357eea (patch) | |
tree | 0c3fc2fe0343b4ab81297e42177b5b82afc91516 | |
parent | 308dcebac7cb9e6dcf8972a178c535b795952931 (diff) |
drm/nv10: Fix up switching of NV10TCL_DMA_VTXBUF.
Not very nice, but I don't think there's a simpler workaround.
Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_reg.h | 18 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nv10_graph.c | 175 |
2 files changed, 132 insertions, 61 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_reg.h b/drivers/gpu/drm/nouveau/nouveau_reg.h index 9c1056cb8a90..21a6e453b975 100644 --- a/drivers/gpu/drm/nouveau/nouveau_reg.h +++ b/drivers/gpu/drm/nouveau/nouveau_reg.h | |||
@@ -220,28 +220,21 @@ | |||
220 | # define NV_PGRAPH_INTR_ERROR (1<<20) | 220 | # define NV_PGRAPH_INTR_ERROR (1<<20) |
221 | #define NV10_PGRAPH_CTX_CONTROL 0x00400144 | 221 | #define NV10_PGRAPH_CTX_CONTROL 0x00400144 |
222 | #define NV10_PGRAPH_CTX_USER 0x00400148 | 222 | #define NV10_PGRAPH_CTX_USER 0x00400148 |
223 | #define NV10_PGRAPH_CTX_SWITCH1 0x0040014C | 223 | #define NV10_PGRAPH_CTX_SWITCH(i) (0x0040014C + 0x4*(i)) |
224 | #define NV10_PGRAPH_CTX_SWITCH2 0x00400150 | ||
225 | #define NV10_PGRAPH_CTX_SWITCH3 0x00400154 | ||
226 | #define NV10_PGRAPH_CTX_SWITCH4 0x00400158 | ||
227 | #define NV10_PGRAPH_CTX_SWITCH5 0x0040015C | ||
228 | #define NV04_PGRAPH_CTX_SWITCH1 0x00400160 | 224 | #define NV04_PGRAPH_CTX_SWITCH1 0x00400160 |
229 | #define NV10_PGRAPH_CTX_CACHE1 0x00400160 | 225 | #define NV10_PGRAPH_CTX_CACHE(i, j) (0x00400160 \ |
226 | + 0x4*(i) + 0x20*(j)) | ||
230 | #define NV04_PGRAPH_CTX_SWITCH2 0x00400164 | 227 | #define NV04_PGRAPH_CTX_SWITCH2 0x00400164 |
231 | #define NV04_PGRAPH_CTX_SWITCH3 0x00400168 | 228 | #define NV04_PGRAPH_CTX_SWITCH3 0x00400168 |
232 | #define NV04_PGRAPH_CTX_SWITCH4 0x0040016C | 229 | #define NV04_PGRAPH_CTX_SWITCH4 0x0040016C |
233 | #define NV04_PGRAPH_CTX_CONTROL 0x00400170 | 230 | #define NV04_PGRAPH_CTX_CONTROL 0x00400170 |
234 | #define NV04_PGRAPH_CTX_USER 0x00400174 | 231 | #define NV04_PGRAPH_CTX_USER 0x00400174 |
235 | #define NV04_PGRAPH_CTX_CACHE1 0x00400180 | 232 | #define NV04_PGRAPH_CTX_CACHE1 0x00400180 |
236 | #define NV10_PGRAPH_CTX_CACHE2 0x00400180 | ||
237 | #define NV03_PGRAPH_CTX_CONTROL 0x00400190 | 233 | #define NV03_PGRAPH_CTX_CONTROL 0x00400190 |
238 | #define NV03_PGRAPH_CTX_USER 0x00400194 | 234 | #define NV03_PGRAPH_CTX_USER 0x00400194 |
239 | #define NV04_PGRAPH_CTX_CACHE2 0x004001A0 | 235 | #define NV04_PGRAPH_CTX_CACHE2 0x004001A0 |
240 | #define NV10_PGRAPH_CTX_CACHE3 0x004001A0 | ||
241 | #define NV04_PGRAPH_CTX_CACHE3 0x004001C0 | 236 | #define NV04_PGRAPH_CTX_CACHE3 0x004001C0 |
242 | #define NV10_PGRAPH_CTX_CACHE4 0x004001C0 | ||
243 | #define NV04_PGRAPH_CTX_CACHE4 0x004001E0 | 237 | #define NV04_PGRAPH_CTX_CACHE4 0x004001E0 |
244 | #define NV10_PGRAPH_CTX_CACHE5 0x004001E0 | ||
245 | #define NV40_PGRAPH_CTXCTL_0304 0x00400304 | 238 | #define NV40_PGRAPH_CTXCTL_0304 0x00400304 |
246 | #define NV40_PGRAPH_CTXCTL_0304_XFER_CTX 0x00000001 | 239 | #define NV40_PGRAPH_CTXCTL_0304_XFER_CTX 0x00000001 |
247 | #define NV40_PGRAPH_CTXCTL_UCODE_STAT 0x00400308 | 240 | #define NV40_PGRAPH_CTXCTL_UCODE_STAT 0x00400308 |
@@ -356,9 +349,12 @@ | |||
356 | #define NV04_PGRAPH_FFINTFC_ST2 0x00400754 | 349 | #define NV04_PGRAPH_FFINTFC_ST2 0x00400754 |
357 | #define NV10_PGRAPH_RDI_DATA 0x00400754 | 350 | #define NV10_PGRAPH_RDI_DATA 0x00400754 |
358 | #define NV04_PGRAPH_DMA_PITCH 0x00400760 | 351 | #define NV04_PGRAPH_DMA_PITCH 0x00400760 |
359 | #define NV10_PGRAPH_FFINTFC_ST2 0x00400764 | 352 | #define NV10_PGRAPH_FFINTFC_FIFO_PTR 0x00400760 |
360 | #define NV04_PGRAPH_DVD_COLORFMT 0x00400764 | 353 | #define NV04_PGRAPH_DVD_COLORFMT 0x00400764 |
354 | #define NV10_PGRAPH_FFINTFC_ST2 0x00400764 | ||
361 | #define NV04_PGRAPH_SCALED_FORMAT 0x00400768 | 355 | #define NV04_PGRAPH_SCALED_FORMAT 0x00400768 |
356 | #define NV10_PGRAPH_FFINTFC_ST2_DL 0x00400768 | ||
357 | #define NV10_PGRAPH_FFINTFC_ST2_DH 0x0040076c | ||
362 | #define NV10_PGRAPH_DMA_PITCH 0x00400770 | 358 | #define NV10_PGRAPH_DMA_PITCH 0x00400770 |
363 | #define NV10_PGRAPH_DVD_COLORFMT 0x00400774 | 359 | #define NV10_PGRAPH_DVD_COLORFMT 0x00400774 |
364 | #define NV10_PGRAPH_SCALED_FORMAT 0x00400778 | 360 | #define NV10_PGRAPH_SCALED_FORMAT 0x00400778 |
diff --git a/drivers/gpu/drm/nouveau/nv10_graph.c b/drivers/gpu/drm/nouveau/nv10_graph.c index fcf2cdd19493..b2f6a57c0cc5 100644 --- a/drivers/gpu/drm/nouveau/nv10_graph.c +++ b/drivers/gpu/drm/nouveau/nv10_graph.c | |||
@@ -43,51 +43,51 @@ struct pipe_state { | |||
43 | }; | 43 | }; |
44 | 44 | ||
45 | static int nv10_graph_ctx_regs[] = { | 45 | static int nv10_graph_ctx_regs[] = { |
46 | NV10_PGRAPH_CTX_SWITCH1, | 46 | NV10_PGRAPH_CTX_SWITCH(0), |
47 | NV10_PGRAPH_CTX_SWITCH2, | 47 | NV10_PGRAPH_CTX_SWITCH(1), |
48 | NV10_PGRAPH_CTX_SWITCH3, | 48 | NV10_PGRAPH_CTX_SWITCH(2), |
49 | NV10_PGRAPH_CTX_SWITCH4, | 49 | NV10_PGRAPH_CTX_SWITCH(3), |
50 | NV10_PGRAPH_CTX_SWITCH5, | 50 | NV10_PGRAPH_CTX_SWITCH(4), |
51 | NV10_PGRAPH_CTX_CACHE1, /* 8 values from 0x400160 to 0x40017c */ | 51 | NV10_PGRAPH_CTX_CACHE(0, 0), |
52 | NV10_PGRAPH_CTX_CACHE2, /* 8 values from 0x400180 to 0x40019c */ | 52 | NV10_PGRAPH_CTX_CACHE(0, 1), |
53 | NV10_PGRAPH_CTX_CACHE3, /* 8 values from 0x4001a0 to 0x4001bc */ | 53 | NV10_PGRAPH_CTX_CACHE(0, 2), |
54 | NV10_PGRAPH_CTX_CACHE4, /* 8 values from 0x4001c0 to 0x4001dc */ | 54 | NV10_PGRAPH_CTX_CACHE(0, 3), |
55 | NV10_PGRAPH_CTX_CACHE5, /* 8 values from 0x4001e0 to 0x4001fc */ | 55 | NV10_PGRAPH_CTX_CACHE(0, 4), |
56 | 0x00400164, | 56 | NV10_PGRAPH_CTX_CACHE(1, 0), |
57 | 0x00400184, | 57 | NV10_PGRAPH_CTX_CACHE(1, 1), |
58 | 0x004001a4, | 58 | NV10_PGRAPH_CTX_CACHE(1, 2), |
59 | 0x004001c4, | 59 | NV10_PGRAPH_CTX_CACHE(1, 3), |
60 | 0x004001e4, | 60 | NV10_PGRAPH_CTX_CACHE(1, 4), |
61 | 0x00400168, | 61 | NV10_PGRAPH_CTX_CACHE(2, 0), |
62 | 0x00400188, | 62 | NV10_PGRAPH_CTX_CACHE(2, 1), |
63 | 0x004001a8, | 63 | NV10_PGRAPH_CTX_CACHE(2, 2), |
64 | 0x004001c8, | 64 | NV10_PGRAPH_CTX_CACHE(2, 3), |
65 | 0x004001e8, | 65 | NV10_PGRAPH_CTX_CACHE(2, 4), |
66 | 0x0040016c, | 66 | NV10_PGRAPH_CTX_CACHE(3, 0), |
67 | 0x0040018c, | 67 | NV10_PGRAPH_CTX_CACHE(3, 1), |
68 | 0x004001ac, | 68 | NV10_PGRAPH_CTX_CACHE(3, 2), |
69 | 0x004001cc, | 69 | NV10_PGRAPH_CTX_CACHE(3, 3), |
70 | 0x004001ec, | 70 | NV10_PGRAPH_CTX_CACHE(3, 4), |
71 | 0x00400170, | 71 | NV10_PGRAPH_CTX_CACHE(4, 0), |
72 | 0x00400190, | 72 | NV10_PGRAPH_CTX_CACHE(4, 1), |
73 | 0x004001b0, | 73 | NV10_PGRAPH_CTX_CACHE(4, 2), |
74 | 0x004001d0, | 74 | NV10_PGRAPH_CTX_CACHE(4, 3), |
75 | 0x004001f0, | 75 | NV10_PGRAPH_CTX_CACHE(4, 4), |
76 | 0x00400174, | 76 | NV10_PGRAPH_CTX_CACHE(5, 0), |
77 | 0x00400194, | 77 | NV10_PGRAPH_CTX_CACHE(5, 1), |
78 | 0x004001b4, | 78 | NV10_PGRAPH_CTX_CACHE(5, 2), |
79 | 0x004001d4, | 79 | NV10_PGRAPH_CTX_CACHE(5, 3), |
80 | 0x004001f4, | 80 | NV10_PGRAPH_CTX_CACHE(5, 4), |
81 | 0x00400178, | 81 | NV10_PGRAPH_CTX_CACHE(6, 0), |
82 | 0x00400198, | 82 | NV10_PGRAPH_CTX_CACHE(6, 1), |
83 | 0x004001b8, | 83 | NV10_PGRAPH_CTX_CACHE(6, 2), |
84 | 0x004001d8, | 84 | NV10_PGRAPH_CTX_CACHE(6, 3), |
85 | 0x004001f8, | 85 | NV10_PGRAPH_CTX_CACHE(6, 4), |
86 | 0x0040017c, | 86 | NV10_PGRAPH_CTX_CACHE(7, 0), |
87 | 0x0040019c, | 87 | NV10_PGRAPH_CTX_CACHE(7, 1), |
88 | 0x004001bc, | 88 | NV10_PGRAPH_CTX_CACHE(7, 2), |
89 | 0x004001dc, | 89 | NV10_PGRAPH_CTX_CACHE(7, 3), |
90 | 0x004001fc, | 90 | NV10_PGRAPH_CTX_CACHE(7, 4), |
91 | NV10_PGRAPH_CTX_USER, | 91 | NV10_PGRAPH_CTX_USER, |
92 | NV04_PGRAPH_DMA_START_0, | 92 | NV04_PGRAPH_DMA_START_0, |
93 | NV04_PGRAPH_DMA_START_1, | 93 | NV04_PGRAPH_DMA_START_1, |
@@ -653,6 +653,78 @@ static int nv17_graph_ctx_regs_find_offset(struct drm_device *dev, int reg) | |||
653 | return -1; | 653 | return -1; |
654 | } | 654 | } |
655 | 655 | ||
656 | static void nv10_graph_load_dma_vtxbuf(struct nouveau_channel *chan, | ||
657 | uint32_t inst) | ||
658 | { | ||
659 | struct drm_device *dev = chan->dev; | ||
660 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
661 | struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph; | ||
662 | uint32_t st2, st2_dl, st2_dh, fifo_ptr, fifo[0x60/4]; | ||
663 | uint32_t ctx_user, ctx_switch[5]; | ||
664 | int i, subchan = -1; | ||
665 | |||
666 | /* NV10TCL_DMA_VTXBUF (method 0x18c) modifies hidden state | ||
667 | * that cannot be restored via MMIO. Do it through the FIFO | ||
668 | * instead. | ||
669 | */ | ||
670 | |||
671 | /* Look for a celsius object */ | ||
672 | for (i = 0; i < 8; i++) { | ||
673 | int class = nv_rd32(dev, NV10_PGRAPH_CTX_CACHE(i, 0)) & 0xfff; | ||
674 | |||
675 | if (class == 0x56 || class == 0x96 || class == 0x99) { | ||
676 | subchan = i; | ||
677 | break; | ||
678 | } | ||
679 | } | ||
680 | |||
681 | if (subchan < 0 || !inst) | ||
682 | return; | ||
683 | |||
684 | /* Save the current ctx object */ | ||
685 | ctx_user = nv_rd32(dev, NV10_PGRAPH_CTX_USER); | ||
686 | for (i = 0; i < 5; i++) | ||
687 | ctx_switch[i] = nv_rd32(dev, NV10_PGRAPH_CTX_SWITCH(i)); | ||
688 | |||
689 | /* Save the FIFO state */ | ||
690 | st2 = nv_rd32(dev, NV10_PGRAPH_FFINTFC_ST2); | ||
691 | st2_dl = nv_rd32(dev, NV10_PGRAPH_FFINTFC_ST2_DL); | ||
692 | st2_dh = nv_rd32(dev, NV10_PGRAPH_FFINTFC_ST2_DH); | ||
693 | fifo_ptr = nv_rd32(dev, NV10_PGRAPH_FFINTFC_FIFO_PTR); | ||
694 | |||
695 | for (i = 0; i < ARRAY_SIZE(fifo); i++) | ||
696 | fifo[i] = nv_rd32(dev, 0x4007a0 + 4 * i); | ||
697 | |||
698 | /* Switch to the celsius subchannel */ | ||
699 | for (i = 0; i < 5; i++) | ||
700 | nv_wr32(dev, NV10_PGRAPH_CTX_SWITCH(i), | ||
701 | nv_rd32(dev, NV10_PGRAPH_CTX_CACHE(subchan, i))); | ||
702 | nv_mask(dev, NV10_PGRAPH_CTX_USER, 0xe000, subchan << 13); | ||
703 | |||
704 | /* Inject NV10TCL_DMA_VTXBUF */ | ||
705 | nv_wr32(dev, NV10_PGRAPH_FFINTFC_FIFO_PTR, 0); | ||
706 | nv_wr32(dev, NV10_PGRAPH_FFINTFC_ST2, | ||
707 | 0x2c000000 | chan->id << 20 | subchan << 16 | 0x18c); | ||
708 | nv_wr32(dev, NV10_PGRAPH_FFINTFC_ST2_DL, inst); | ||
709 | nv_mask(dev, NV10_PGRAPH_CTX_CONTROL, 0, 0x10000); | ||
710 | pgraph->fifo_access(dev, true); | ||
711 | pgraph->fifo_access(dev, false); | ||
712 | |||
713 | /* Restore the FIFO state */ | ||
714 | for (i = 0; i < ARRAY_SIZE(fifo); i++) | ||
715 | nv_wr32(dev, 0x4007a0 + 4 * i, fifo[i]); | ||
716 | |||
717 | nv_wr32(dev, NV10_PGRAPH_FFINTFC_FIFO_PTR, fifo_ptr); | ||
718 | nv_wr32(dev, NV10_PGRAPH_FFINTFC_ST2, st2); | ||
719 | nv_wr32(dev, NV10_PGRAPH_FFINTFC_ST2_DL, st2_dl); | ||
720 | nv_wr32(dev, NV10_PGRAPH_FFINTFC_ST2_DH, st2_dh); | ||
721 | |||
722 | /* Restore the current ctx object */ | ||
723 | for (i = 0; i < 5; i++) | ||
724 | nv_wr32(dev, NV10_PGRAPH_CTX_SWITCH(i), ctx_switch[i]); | ||
725 | nv_wr32(dev, NV10_PGRAPH_CTX_USER, ctx_user); | ||
726 | } | ||
727 | |||
656 | int nv10_graph_load_context(struct nouveau_channel *chan) | 728 | int nv10_graph_load_context(struct nouveau_channel *chan) |
657 | { | 729 | { |
658 | struct drm_device *dev = chan->dev; | 730 | struct drm_device *dev = chan->dev; |
@@ -670,6 +742,8 @@ int nv10_graph_load_context(struct nouveau_channel *chan) | |||
670 | } | 742 | } |
671 | 743 | ||
672 | nv10_graph_load_pipe(chan); | 744 | nv10_graph_load_pipe(chan); |
745 | nv10_graph_load_dma_vtxbuf(chan, (nv_rd32(dev, NV10_PGRAPH_GLOBALSTATE1) | ||
746 | & 0xffff)); | ||
673 | 747 | ||
674 | nv_wr32(dev, NV10_PGRAPH_CTX_CONTROL, 0x10010100); | 748 | nv_wr32(dev, NV10_PGRAPH_CTX_CONTROL, 0x10010100); |
675 | tmp = nv_rd32(dev, NV10_PGRAPH_CTX_USER); | 749 | tmp = nv_rd32(dev, NV10_PGRAPH_CTX_USER); |
@@ -856,11 +930,12 @@ int nv10_graph_init(struct drm_device *dev) | |||
856 | for (i = 0; i < NV10_PFB_TILE__SIZE; i++) | 930 | for (i = 0; i < NV10_PFB_TILE__SIZE; i++) |
857 | nv10_graph_set_region_tiling(dev, i, 0, 0, 0); | 931 | nv10_graph_set_region_tiling(dev, i, 0, 0, 0); |
858 | 932 | ||
859 | nv_wr32(dev, NV10_PGRAPH_CTX_SWITCH1, 0x00000000); | 933 | nv_wr32(dev, NV10_PGRAPH_CTX_SWITCH(0), 0x00000000); |
860 | nv_wr32(dev, NV10_PGRAPH_CTX_SWITCH2, 0x00000000); | 934 | nv_wr32(dev, NV10_PGRAPH_CTX_SWITCH(1), 0x00000000); |
861 | nv_wr32(dev, NV10_PGRAPH_CTX_SWITCH3, 0x00000000); | 935 | nv_wr32(dev, NV10_PGRAPH_CTX_SWITCH(2), 0x00000000); |
862 | nv_wr32(dev, NV10_PGRAPH_CTX_SWITCH4, 0x00000000); | 936 | nv_wr32(dev, NV10_PGRAPH_CTX_SWITCH(3), 0x00000000); |
863 | nv_wr32(dev, NV10_PGRAPH_STATE , 0xFFFFFFFF); | 937 | nv_wr32(dev, NV10_PGRAPH_CTX_SWITCH(4), 0x00000000); |
938 | nv_wr32(dev, NV10_PGRAPH_STATE, 0xFFFFFFFF); | ||
864 | 939 | ||
865 | tmp = nv_rd32(dev, NV10_PGRAPH_CTX_USER) & 0x00ffffff; | 940 | tmp = nv_rd32(dev, NV10_PGRAPH_CTX_USER) & 0x00ffffff; |
866 | tmp |= (dev_priv->engine.fifo.channels - 1) << 24; | 941 | tmp |= (dev_priv->engine.fifo.channels - 1) << 24; |