diff options
author | Dave Airlie <airlied@redhat.com> | 2009-12-22 19:28:24 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2009-12-22 19:28:24 -0500 |
commit | 44f9e6c6bc508b202755d9e9e48a8ba96a5f0fa4 (patch) | |
tree | fe99d4f4e367be40923a47d40ef772d680ac8db9 | |
parent | 29ebdf925c2c45f6531a953c6c5c8e4d3b4ac2dc (diff) | |
parent | 37cb3e08852be92d94e6a65c489bd8afa2e8a15f (diff) |
Merge remote branch 'nouveau/for-airlied' into drm-linus
* nouveau/for-airlied:
drm/nouveau: fix bug causing pinned buffers to lose their NO_EVICT flag
drm/nv50: fix suspend/resume delays without firmware present
drm/nouveau: prevent all channel creation if accel not available
drm/nv50: fix two potential suspend/resume oopses
drm/nv40: implement ctxprog/state generation
drm/nv10: Add the initial graph context and soft methods needed for LMA.
drm/nouveau: Fix up buffer eviction, and evict them to GART, if possible.
drm/nouveau: Add proper error handling to nouveau_card_init
drm/nv04: Fix NV04 set_operation software method.
drm/nouveau: Kill global state in BIOS script interpreter
drm/nouveau: Kill global state in NvShadowBIOS
drm/nouveau: use drm debug levels
drm/i2c/ch7006: Fix load detection false positives right after system init.
drm/nv04-nv40: Fix "conflicting memory types" when saving/restoring VGA fonts.
30 files changed, 1710 insertions, 706 deletions
diff --git a/drivers/gpu/drm/i2c/ch7006_drv.c b/drivers/gpu/drm/i2c/ch7006_drv.c index 9422a74c8b54..81681a07a806 100644 --- a/drivers/gpu/drm/i2c/ch7006_drv.c +++ b/drivers/gpu/drm/i2c/ch7006_drv.c | |||
@@ -408,6 +408,11 @@ static int ch7006_probe(struct i2c_client *client, const struct i2c_device_id *i | |||
408 | 408 | ||
409 | ch7006_info(client, "Detected version ID: %x\n", val); | 409 | ch7006_info(client, "Detected version ID: %x\n", val); |
410 | 410 | ||
411 | /* I don't know what this is for, but otherwise I get no | ||
412 | * signal. | ||
413 | */ | ||
414 | ch7006_write(client, 0x3d, 0x0); | ||
415 | |||
411 | return 0; | 416 | return 0; |
412 | 417 | ||
413 | fail: | 418 | fail: |
diff --git a/drivers/gpu/drm/i2c/ch7006_mode.c b/drivers/gpu/drm/i2c/ch7006_mode.c index 87f5445092e8..e447dfb63890 100644 --- a/drivers/gpu/drm/i2c/ch7006_mode.c +++ b/drivers/gpu/drm/i2c/ch7006_mode.c | |||
@@ -427,11 +427,6 @@ void ch7006_state_load(struct i2c_client *client, | |||
427 | ch7006_load_reg(client, state, CH7006_SUBC_INC7); | 427 | ch7006_load_reg(client, state, CH7006_SUBC_INC7); |
428 | ch7006_load_reg(client, state, CH7006_PLL_CONTROL); | 428 | ch7006_load_reg(client, state, CH7006_PLL_CONTROL); |
429 | ch7006_load_reg(client, state, CH7006_CALC_SUBC_INC0); | 429 | ch7006_load_reg(client, state, CH7006_CALC_SUBC_INC0); |
430 | |||
431 | /* I don't know what this is for, but otherwise I get no | ||
432 | * signal. | ||
433 | */ | ||
434 | ch7006_write(client, 0x3d, 0x0); | ||
435 | } | 430 | } |
436 | 431 | ||
437 | void ch7006_state_save(struct i2c_client *client, | 432 | void ch7006_state_save(struct i2c_client *client, |
diff --git a/drivers/gpu/drm/nouveau/Makefile b/drivers/gpu/drm/nouveau/Makefile index 1d90d4d0144f..48c290b5da8c 100644 --- a/drivers/gpu/drm/nouveau/Makefile +++ b/drivers/gpu/drm/nouveau/Makefile | |||
@@ -8,14 +8,15 @@ nouveau-y := nouveau_drv.o nouveau_state.o nouveau_channel.o nouveau_mem.o \ | |||
8 | nouveau_sgdma.o nouveau_dma.o \ | 8 | nouveau_sgdma.o nouveau_dma.o \ |
9 | nouveau_bo.o nouveau_fence.o nouveau_gem.o nouveau_ttm.o \ | 9 | nouveau_bo.o nouveau_fence.o nouveau_gem.o nouveau_ttm.o \ |
10 | nouveau_hw.o nouveau_calc.o nouveau_bios.o nouveau_i2c.o \ | 10 | nouveau_hw.o nouveau_calc.o nouveau_bios.o nouveau_i2c.o \ |
11 | nouveau_display.o nouveau_connector.o nouveau_fbcon.o \ | 11 | nouveau_display.o nouveau_connector.o nouveau_fbcon.o \ |
12 | nouveau_dp.o \ | 12 | nouveau_dp.o nouveau_grctx.o \ |
13 | nv04_timer.o \ | 13 | nv04_timer.o \ |
14 | nv04_mc.o nv40_mc.o nv50_mc.o \ | 14 | nv04_mc.o nv40_mc.o nv50_mc.o \ |
15 | nv04_fb.o nv10_fb.o nv40_fb.o \ | 15 | nv04_fb.o nv10_fb.o nv40_fb.o \ |
16 | nv04_fifo.o nv10_fifo.o nv40_fifo.o nv50_fifo.o \ | 16 | nv04_fifo.o nv10_fifo.o nv40_fifo.o nv50_fifo.o \ |
17 | nv04_graph.o nv10_graph.o nv20_graph.o \ | 17 | nv04_graph.o nv10_graph.o nv20_graph.o \ |
18 | nv40_graph.o nv50_graph.o \ | 18 | nv40_graph.o nv50_graph.o \ |
19 | nv40_grctx.o \ | ||
19 | nv04_instmem.o nv50_instmem.o \ | 20 | nv04_instmem.o nv50_instmem.o \ |
20 | nv50_crtc.o nv50_dac.o nv50_sor.o \ | 21 | nv50_crtc.o nv50_dac.o nv50_sor.o \ |
21 | nv50_cursor.o nv50_display.o nv50_fbcon.o \ | 22 | nv50_cursor.o nv50_display.o nv50_fbcon.o \ |
diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c index 5eec5ed69489..ba143972769f 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c | |||
@@ -181,43 +181,42 @@ struct methods { | |||
181 | const char desc[8]; | 181 | const char desc[8]; |
182 | void (*loadbios)(struct drm_device *, uint8_t *); | 182 | void (*loadbios)(struct drm_device *, uint8_t *); |
183 | const bool rw; | 183 | const bool rw; |
184 | int score; | ||
185 | }; | 184 | }; |
186 | 185 | ||
187 | static struct methods nv04_methods[] = { | 186 | static struct methods nv04_methods[] = { |
188 | { "PROM", load_vbios_prom, false }, | 187 | { "PROM", load_vbios_prom, false }, |
189 | { "PRAMIN", load_vbios_pramin, true }, | 188 | { "PRAMIN", load_vbios_pramin, true }, |
190 | { "PCIROM", load_vbios_pci, true }, | 189 | { "PCIROM", load_vbios_pci, true }, |
191 | { } | ||
192 | }; | 190 | }; |
193 | 191 | ||
194 | static struct methods nv50_methods[] = { | 192 | static struct methods nv50_methods[] = { |
195 | { "PRAMIN", load_vbios_pramin, true }, | 193 | { "PRAMIN", load_vbios_pramin, true }, |
196 | { "PROM", load_vbios_prom, false }, | 194 | { "PROM", load_vbios_prom, false }, |
197 | { "PCIROM", load_vbios_pci, true }, | 195 | { "PCIROM", load_vbios_pci, true }, |
198 | { } | ||
199 | }; | 196 | }; |
200 | 197 | ||
198 | #define METHODCNT 3 | ||
199 | |||
201 | static bool NVShadowVBIOS(struct drm_device *dev, uint8_t *data) | 200 | static bool NVShadowVBIOS(struct drm_device *dev, uint8_t *data) |
202 | { | 201 | { |
203 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 202 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
204 | struct methods *methods, *method; | 203 | struct methods *methods; |
204 | int i; | ||
205 | int testscore = 3; | 205 | int testscore = 3; |
206 | int scores[METHODCNT]; | ||
206 | 207 | ||
207 | if (nouveau_vbios) { | 208 | if (nouveau_vbios) { |
208 | method = nv04_methods; | 209 | methods = nv04_methods; |
209 | while (method->loadbios) { | 210 | for (i = 0; i < METHODCNT; i++) |
210 | if (!strcasecmp(nouveau_vbios, method->desc)) | 211 | if (!strcasecmp(nouveau_vbios, methods[i].desc)) |
211 | break; | 212 | break; |
212 | method++; | ||
213 | } | ||
214 | 213 | ||
215 | if (method->loadbios) { | 214 | if (i < METHODCNT) { |
216 | NV_INFO(dev, "Attempting to use BIOS image from %s\n", | 215 | NV_INFO(dev, "Attempting to use BIOS image from %s\n", |
217 | method->desc); | 216 | methods[i].desc); |
218 | 217 | ||
219 | method->loadbios(dev, data); | 218 | methods[i].loadbios(dev, data); |
220 | if (score_vbios(dev, data, method->rw)) | 219 | if (score_vbios(dev, data, methods[i].rw)) |
221 | return true; | 220 | return true; |
222 | } | 221 | } |
223 | 222 | ||
@@ -229,28 +228,24 @@ static bool NVShadowVBIOS(struct drm_device *dev, uint8_t *data) | |||
229 | else | 228 | else |
230 | methods = nv50_methods; | 229 | methods = nv50_methods; |
231 | 230 | ||
232 | method = methods; | 231 | for (i = 0; i < METHODCNT; i++) { |
233 | while (method->loadbios) { | ||
234 | NV_TRACE(dev, "Attempting to load BIOS image from %s\n", | 232 | NV_TRACE(dev, "Attempting to load BIOS image from %s\n", |
235 | method->desc); | 233 | methods[i].desc); |
236 | data[0] = data[1] = 0; /* avoid reuse of previous image */ | 234 | data[0] = data[1] = 0; /* avoid reuse of previous image */ |
237 | method->loadbios(dev, data); | 235 | methods[i].loadbios(dev, data); |
238 | method->score = score_vbios(dev, data, method->rw); | 236 | scores[i] = score_vbios(dev, data, methods[i].rw); |
239 | if (method->score == testscore) | 237 | if (scores[i] == testscore) |
240 | return true; | 238 | return true; |
241 | method++; | ||
242 | } | 239 | } |
243 | 240 | ||
244 | while (--testscore > 0) { | 241 | while (--testscore > 0) { |
245 | method = methods; | 242 | for (i = 0; i < METHODCNT; i++) { |
246 | while (method->loadbios) { | 243 | if (scores[i] == testscore) { |
247 | if (method->score == testscore) { | ||
248 | NV_TRACE(dev, "Using BIOS image from %s\n", | 244 | NV_TRACE(dev, "Using BIOS image from %s\n", |
249 | method->desc); | 245 | methods[i].desc); |
250 | method->loadbios(dev, data); | 246 | methods[i].loadbios(dev, data); |
251 | return true; | 247 | return true; |
252 | } | 248 | } |
253 | method++; | ||
254 | } | 249 | } |
255 | } | 250 | } |
256 | 251 | ||
@@ -261,10 +256,7 @@ static bool NVShadowVBIOS(struct drm_device *dev, uint8_t *data) | |||
261 | struct init_tbl_entry { | 256 | struct init_tbl_entry { |
262 | char *name; | 257 | char *name; |
263 | uint8_t id; | 258 | uint8_t id; |
264 | int length; | 259 | int (*handler)(struct nvbios *, uint16_t, struct init_exec *); |
265 | int length_offset; | ||
266 | int length_multiplier; | ||
267 | bool (*handler)(struct nvbios *, uint16_t, struct init_exec *); | ||
268 | }; | 260 | }; |
269 | 261 | ||
270 | struct bit_entry { | 262 | struct bit_entry { |
@@ -820,7 +812,7 @@ static uint32_t get_tmds_index_reg(struct drm_device *dev, uint8_t mlv) | |||
820 | } | 812 | } |
821 | } | 813 | } |
822 | 814 | ||
823 | static bool | 815 | static int |
824 | init_io_restrict_prog(struct nvbios *bios, uint16_t offset, | 816 | init_io_restrict_prog(struct nvbios *bios, uint16_t offset, |
825 | struct init_exec *iexec) | 817 | struct init_exec *iexec) |
826 | { | 818 | { |
@@ -852,9 +844,10 @@ init_io_restrict_prog(struct nvbios *bios, uint16_t offset, | |||
852 | uint32_t reg = ROM32(bios->data[offset + 7]); | 844 | uint32_t reg = ROM32(bios->data[offset + 7]); |
853 | uint8_t config; | 845 | uint8_t config; |
854 | uint32_t configval; | 846 | uint32_t configval; |
847 | int len = 11 + count * 4; | ||
855 | 848 | ||
856 | if (!iexec->execute) | 849 | if (!iexec->execute) |
857 | return true; | 850 | return len; |
858 | 851 | ||
859 | BIOSLOG(bios, "0x%04X: Port: 0x%04X, Index: 0x%02X, Mask: 0x%02X, " | 852 | BIOSLOG(bios, "0x%04X: Port: 0x%04X, Index: 0x%02X, Mask: 0x%02X, " |
860 | "Shift: 0x%02X, Count: 0x%02X, Reg: 0x%08X\n", | 853 | "Shift: 0x%02X, Count: 0x%02X, Reg: 0x%08X\n", |
@@ -865,7 +858,7 @@ init_io_restrict_prog(struct nvbios *bios, uint16_t offset, | |||
865 | NV_ERROR(bios->dev, | 858 | NV_ERROR(bios->dev, |
866 | "0x%04X: Config 0x%02X exceeds maximal bound 0x%02X\n", | 859 | "0x%04X: Config 0x%02X exceeds maximal bound 0x%02X\n", |
867 | offset, config, count); | 860 | offset, config, count); |
868 | return false; | 861 | return 0; |
869 | } | 862 | } |
870 | 863 | ||
871 | configval = ROM32(bios->data[offset + 11 + config * 4]); | 864 | configval = ROM32(bios->data[offset + 11 + config * 4]); |
@@ -874,10 +867,10 @@ init_io_restrict_prog(struct nvbios *bios, uint16_t offset, | |||
874 | 867 | ||
875 | bios_wr32(bios, reg, configval); | 868 | bios_wr32(bios, reg, configval); |
876 | 869 | ||
877 | return true; | 870 | return len; |
878 | } | 871 | } |
879 | 872 | ||
880 | static bool | 873 | static int |
881 | init_repeat(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 874 | init_repeat(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
882 | { | 875 | { |
883 | /* | 876 | /* |
@@ -912,10 +905,10 @@ init_repeat(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
912 | 905 | ||
913 | iexec->repeat = false; | 906 | iexec->repeat = false; |
914 | 907 | ||
915 | return true; | 908 | return 2; |
916 | } | 909 | } |
917 | 910 | ||
918 | static bool | 911 | static int |
919 | init_io_restrict_pll(struct nvbios *bios, uint16_t offset, | 912 | init_io_restrict_pll(struct nvbios *bios, uint16_t offset, |
920 | struct init_exec *iexec) | 913 | struct init_exec *iexec) |
921 | { | 914 | { |
@@ -951,9 +944,10 @@ init_io_restrict_pll(struct nvbios *bios, uint16_t offset, | |||
951 | uint32_t reg = ROM32(bios->data[offset + 8]); | 944 | uint32_t reg = ROM32(bios->data[offset + 8]); |
952 | uint8_t config; | 945 | uint8_t config; |
953 | uint16_t freq; | 946 | uint16_t freq; |
947 | int len = 12 + count * 2; | ||
954 | 948 | ||
955 | if (!iexec->execute) | 949 | if (!iexec->execute) |
956 | return true; | 950 | return len; |
957 | 951 | ||
958 | BIOSLOG(bios, "0x%04X: Port: 0x%04X, Index: 0x%02X, Mask: 0x%02X, " | 952 | BIOSLOG(bios, "0x%04X: Port: 0x%04X, Index: 0x%02X, Mask: 0x%02X, " |
959 | "Shift: 0x%02X, IO Flag Condition: 0x%02X, " | 953 | "Shift: 0x%02X, IO Flag Condition: 0x%02X, " |
@@ -966,7 +960,7 @@ init_io_restrict_pll(struct nvbios *bios, uint16_t offset, | |||
966 | NV_ERROR(bios->dev, | 960 | NV_ERROR(bios->dev, |
967 | "0x%04X: Config 0x%02X exceeds maximal bound 0x%02X\n", | 961 | "0x%04X: Config 0x%02X exceeds maximal bound 0x%02X\n", |
968 | offset, config, count); | 962 | offset, config, count); |
969 | return false; | 963 | return 0; |
970 | } | 964 | } |
971 | 965 | ||
972 | freq = ROM16(bios->data[offset + 12 + config * 2]); | 966 | freq = ROM16(bios->data[offset + 12 + config * 2]); |
@@ -986,10 +980,10 @@ init_io_restrict_pll(struct nvbios *bios, uint16_t offset, | |||
986 | 980 | ||
987 | setPLL(bios, reg, freq * 10); | 981 | setPLL(bios, reg, freq * 10); |
988 | 982 | ||
989 | return true; | 983 | return len; |
990 | } | 984 | } |
991 | 985 | ||
992 | static bool | 986 | static int |
993 | init_end_repeat(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 987 | init_end_repeat(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
994 | { | 988 | { |
995 | /* | 989 | /* |
@@ -1007,12 +1001,12 @@ init_end_repeat(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1007 | * we're not in repeat mode | 1001 | * we're not in repeat mode |
1008 | */ | 1002 | */ |
1009 | if (iexec->repeat) | 1003 | if (iexec->repeat) |
1010 | return false; | 1004 | return 0; |
1011 | 1005 | ||
1012 | return true; | 1006 | return 1; |
1013 | } | 1007 | } |
1014 | 1008 | ||
1015 | static bool | 1009 | static int |
1016 | init_copy(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 1010 | init_copy(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
1017 | { | 1011 | { |
1018 | /* | 1012 | /* |
@@ -1041,7 +1035,7 @@ init_copy(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1041 | uint8_t crtcdata; | 1035 | uint8_t crtcdata; |
1042 | 1036 | ||
1043 | if (!iexec->execute) | 1037 | if (!iexec->execute) |
1044 | return true; | 1038 | return 11; |
1045 | 1039 | ||
1046 | BIOSLOG(bios, "0x%04X: Reg: 0x%08X, Shift: 0x%02X, SrcMask: 0x%02X, " | 1040 | BIOSLOG(bios, "0x%04X: Reg: 0x%08X, Shift: 0x%02X, SrcMask: 0x%02X, " |
1047 | "Port: 0x%04X, Index: 0x%02X, Mask: 0x%02X\n", | 1041 | "Port: 0x%04X, Index: 0x%02X, Mask: 0x%02X\n", |
@@ -1060,10 +1054,10 @@ init_copy(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1060 | crtcdata |= (uint8_t)data; | 1054 | crtcdata |= (uint8_t)data; |
1061 | bios_idxprt_wr(bios, crtcport, crtcindex, crtcdata); | 1055 | bios_idxprt_wr(bios, crtcport, crtcindex, crtcdata); |
1062 | 1056 | ||
1063 | return true; | 1057 | return 11; |
1064 | } | 1058 | } |
1065 | 1059 | ||
1066 | static bool | 1060 | static int |
1067 | init_not(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 1061 | init_not(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
1068 | { | 1062 | { |
1069 | /* | 1063 | /* |
@@ -1079,10 +1073,10 @@ init_not(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1079 | BIOSLOG(bios, "0x%04X: ------ Executing following commands ------\n", offset); | 1073 | BIOSLOG(bios, "0x%04X: ------ Executing following commands ------\n", offset); |
1080 | 1074 | ||
1081 | iexec->execute = !iexec->execute; | 1075 | iexec->execute = !iexec->execute; |
1082 | return true; | 1076 | return 1; |
1083 | } | 1077 | } |
1084 | 1078 | ||
1085 | static bool | 1079 | static int |
1086 | init_io_flag_condition(struct nvbios *bios, uint16_t offset, | 1080 | init_io_flag_condition(struct nvbios *bios, uint16_t offset, |
1087 | struct init_exec *iexec) | 1081 | struct init_exec *iexec) |
1088 | { | 1082 | { |
@@ -1100,7 +1094,7 @@ init_io_flag_condition(struct nvbios *bios, uint16_t offset, | |||
1100 | uint8_t cond = bios->data[offset + 1]; | 1094 | uint8_t cond = bios->data[offset + 1]; |
1101 | 1095 | ||
1102 | if (!iexec->execute) | 1096 | if (!iexec->execute) |
1103 | return true; | 1097 | return 2; |
1104 | 1098 | ||
1105 | if (io_flag_condition_met(bios, offset, cond)) | 1099 | if (io_flag_condition_met(bios, offset, cond)) |
1106 | BIOSLOG(bios, "0x%04X: Condition fulfilled -- continuing to execute\n", offset); | 1100 | BIOSLOG(bios, "0x%04X: Condition fulfilled -- continuing to execute\n", offset); |
@@ -1109,10 +1103,10 @@ init_io_flag_condition(struct nvbios *bios, uint16_t offset, | |||
1109 | iexec->execute = false; | 1103 | iexec->execute = false; |
1110 | } | 1104 | } |
1111 | 1105 | ||
1112 | return true; | 1106 | return 2; |
1113 | } | 1107 | } |
1114 | 1108 | ||
1115 | static bool | 1109 | static int |
1116 | init_idx_addr_latched(struct nvbios *bios, uint16_t offset, | 1110 | init_idx_addr_latched(struct nvbios *bios, uint16_t offset, |
1117 | struct init_exec *iexec) | 1111 | struct init_exec *iexec) |
1118 | { | 1112 | { |
@@ -1140,11 +1134,12 @@ init_idx_addr_latched(struct nvbios *bios, uint16_t offset, | |||
1140 | uint32_t mask = ROM32(bios->data[offset + 9]); | 1134 | uint32_t mask = ROM32(bios->data[offset + 9]); |
1141 | uint32_t data = ROM32(bios->data[offset + 13]); | 1135 | uint32_t data = ROM32(bios->data[offset + 13]); |
1142 | uint8_t count = bios->data[offset + 17]; | 1136 | uint8_t count = bios->data[offset + 17]; |
1137 | int len = 18 + count * 2; | ||
1143 | uint32_t value; | 1138 | uint32_t value; |
1144 | int i; | 1139 | int i; |
1145 | 1140 | ||
1146 | if (!iexec->execute) | 1141 | if (!iexec->execute) |
1147 | return true; | 1142 | return len; |
1148 | 1143 | ||
1149 | BIOSLOG(bios, "0x%04X: ControlReg: 0x%08X, DataReg: 0x%08X, " | 1144 | BIOSLOG(bios, "0x%04X: ControlReg: 0x%08X, DataReg: 0x%08X, " |
1150 | "Mask: 0x%08X, Data: 0x%08X, Count: 0x%02X\n", | 1145 | "Mask: 0x%08X, Data: 0x%08X, Count: 0x%02X\n", |
@@ -1164,10 +1159,10 @@ init_idx_addr_latched(struct nvbios *bios, uint16_t offset, | |||
1164 | bios_wr32(bios, controlreg, value); | 1159 | bios_wr32(bios, controlreg, value); |
1165 | } | 1160 | } |
1166 | 1161 | ||
1167 | return true; | 1162 | return len; |
1168 | } | 1163 | } |
1169 | 1164 | ||
1170 | static bool | 1165 | static int |
1171 | init_io_restrict_pll2(struct nvbios *bios, uint16_t offset, | 1166 | init_io_restrict_pll2(struct nvbios *bios, uint16_t offset, |
1172 | struct init_exec *iexec) | 1167 | struct init_exec *iexec) |
1173 | { | 1168 | { |
@@ -1196,25 +1191,26 @@ init_io_restrict_pll2(struct nvbios *bios, uint16_t offset, | |||
1196 | uint8_t shift = bios->data[offset + 5]; | 1191 | uint8_t shift = bios->data[offset + 5]; |
1197 | uint8_t count = bios->data[offset + 6]; | 1192 | uint8_t count = bios->data[offset + 6]; |
1198 | uint32_t reg = ROM32(bios->data[offset + 7]); | 1193 | uint32_t reg = ROM32(bios->data[offset + 7]); |
1194 | int len = 11 + count * 4; | ||
1199 | uint8_t config; | 1195 | uint8_t config; |
1200 | uint32_t freq; | 1196 | uint32_t freq; |
1201 | 1197 | ||
1202 | if (!iexec->execute) | 1198 | if (!iexec->execute) |
1203 | return true; | 1199 | return len; |
1204 | 1200 | ||
1205 | BIOSLOG(bios, "0x%04X: Port: 0x%04X, Index: 0x%02X, Mask: 0x%02X, " | 1201 | BIOSLOG(bios, "0x%04X: Port: 0x%04X, Index: 0x%02X, Mask: 0x%02X, " |
1206 | "Shift: 0x%02X, Count: 0x%02X, Reg: 0x%08X\n", | 1202 | "Shift: 0x%02X, Count: 0x%02X, Reg: 0x%08X\n", |
1207 | offset, crtcport, crtcindex, mask, shift, count, reg); | 1203 | offset, crtcport, crtcindex, mask, shift, count, reg); |
1208 | 1204 | ||
1209 | if (!reg) | 1205 | if (!reg) |
1210 | return true; | 1206 | return len; |
1211 | 1207 | ||
1212 | config = (bios_idxprt_rd(bios, crtcport, crtcindex) & mask) >> shift; | 1208 | config = (bios_idxprt_rd(bios, crtcport, crtcindex) & mask) >> shift; |
1213 | if (config > count) { | 1209 | if (config > count) { |
1214 | NV_ERROR(bios->dev, | 1210 | NV_ERROR(bios->dev, |
1215 | "0x%04X: Config 0x%02X exceeds maximal bound 0x%02X\n", | 1211 | "0x%04X: Config 0x%02X exceeds maximal bound 0x%02X\n", |
1216 | offset, config, count); | 1212 | offset, config, count); |
1217 | return false; | 1213 | return 0; |
1218 | } | 1214 | } |
1219 | 1215 | ||
1220 | freq = ROM32(bios->data[offset + 11 + config * 4]); | 1216 | freq = ROM32(bios->data[offset + 11 + config * 4]); |
@@ -1224,10 +1220,10 @@ init_io_restrict_pll2(struct nvbios *bios, uint16_t offset, | |||
1224 | 1220 | ||
1225 | setPLL(bios, reg, freq); | 1221 | setPLL(bios, reg, freq); |
1226 | 1222 | ||
1227 | return true; | 1223 | return len; |
1228 | } | 1224 | } |
1229 | 1225 | ||
1230 | static bool | 1226 | static int |
1231 | init_pll2(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 1227 | init_pll2(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
1232 | { | 1228 | { |
1233 | /* | 1229 | /* |
@@ -1244,16 +1240,16 @@ init_pll2(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1244 | uint32_t freq = ROM32(bios->data[offset + 5]); | 1240 | uint32_t freq = ROM32(bios->data[offset + 5]); |
1245 | 1241 | ||
1246 | if (!iexec->execute) | 1242 | if (!iexec->execute) |
1247 | return true; | 1243 | return 9; |
1248 | 1244 | ||
1249 | BIOSLOG(bios, "0x%04X: Reg: 0x%04X, Freq: %dkHz\n", | 1245 | BIOSLOG(bios, "0x%04X: Reg: 0x%04X, Freq: %dkHz\n", |
1250 | offset, reg, freq); | 1246 | offset, reg, freq); |
1251 | 1247 | ||
1252 | setPLL(bios, reg, freq); | 1248 | setPLL(bios, reg, freq); |
1253 | return true; | 1249 | return 9; |
1254 | } | 1250 | } |
1255 | 1251 | ||
1256 | static bool | 1252 | static int |
1257 | init_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 1253 | init_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
1258 | { | 1254 | { |
1259 | /* | 1255 | /* |
@@ -1277,12 +1273,13 @@ init_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1277 | uint8_t i2c_index = bios->data[offset + 1]; | 1273 | uint8_t i2c_index = bios->data[offset + 1]; |
1278 | uint8_t i2c_address = bios->data[offset + 2]; | 1274 | uint8_t i2c_address = bios->data[offset + 2]; |
1279 | uint8_t count = bios->data[offset + 3]; | 1275 | uint8_t count = bios->data[offset + 3]; |
1276 | int len = 4 + count * 3; | ||
1280 | struct nouveau_i2c_chan *chan; | 1277 | struct nouveau_i2c_chan *chan; |
1281 | struct i2c_msg msg; | 1278 | struct i2c_msg msg; |
1282 | int i; | 1279 | int i; |
1283 | 1280 | ||
1284 | if (!iexec->execute) | 1281 | if (!iexec->execute) |
1285 | return true; | 1282 | return len; |
1286 | 1283 | ||
1287 | BIOSLOG(bios, "0x%04X: DCBI2CIndex: 0x%02X, I2CAddress: 0x%02X, " | 1284 | BIOSLOG(bios, "0x%04X: DCBI2CIndex: 0x%02X, I2CAddress: 0x%02X, " |
1288 | "Count: 0x%02X\n", | 1285 | "Count: 0x%02X\n", |
@@ -1290,7 +1287,7 @@ init_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1290 | 1287 | ||
1291 | chan = init_i2c_device_find(bios->dev, i2c_index); | 1288 | chan = init_i2c_device_find(bios->dev, i2c_index); |
1292 | if (!chan) | 1289 | if (!chan) |
1293 | return false; | 1290 | return 0; |
1294 | 1291 | ||
1295 | for (i = 0; i < count; i++) { | 1292 | for (i = 0; i < count; i++) { |
1296 | uint8_t i2c_reg = bios->data[offset + 4 + i * 3]; | 1293 | uint8_t i2c_reg = bios->data[offset + 4 + i * 3]; |
@@ -1303,7 +1300,7 @@ init_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1303 | msg.len = 1; | 1300 | msg.len = 1; |
1304 | msg.buf = &value; | 1301 | msg.buf = &value; |
1305 | if (i2c_transfer(&chan->adapter, &msg, 1) != 1) | 1302 | if (i2c_transfer(&chan->adapter, &msg, 1) != 1) |
1306 | return false; | 1303 | return 0; |
1307 | 1304 | ||
1308 | BIOSLOG(bios, "0x%04X: I2CReg: 0x%02X, Value: 0x%02X, " | 1305 | BIOSLOG(bios, "0x%04X: I2CReg: 0x%02X, Value: 0x%02X, " |
1309 | "Mask: 0x%02X, Data: 0x%02X\n", | 1306 | "Mask: 0x%02X, Data: 0x%02X\n", |
@@ -1317,14 +1314,14 @@ init_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1317 | msg.len = 1; | 1314 | msg.len = 1; |
1318 | msg.buf = &value; | 1315 | msg.buf = &value; |
1319 | if (i2c_transfer(&chan->adapter, &msg, 1) != 1) | 1316 | if (i2c_transfer(&chan->adapter, &msg, 1) != 1) |
1320 | return false; | 1317 | return 0; |
1321 | } | 1318 | } |
1322 | } | 1319 | } |
1323 | 1320 | ||
1324 | return true; | 1321 | return len; |
1325 | } | 1322 | } |
1326 | 1323 | ||
1327 | static bool | 1324 | static int |
1328 | init_zm_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 1325 | init_zm_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
1329 | { | 1326 | { |
1330 | /* | 1327 | /* |
@@ -1346,12 +1343,13 @@ init_zm_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1346 | uint8_t i2c_index = bios->data[offset + 1]; | 1343 | uint8_t i2c_index = bios->data[offset + 1]; |
1347 | uint8_t i2c_address = bios->data[offset + 2]; | 1344 | uint8_t i2c_address = bios->data[offset + 2]; |
1348 | uint8_t count = bios->data[offset + 3]; | 1345 | uint8_t count = bios->data[offset + 3]; |
1346 | int len = 4 + count * 2; | ||
1349 | struct nouveau_i2c_chan *chan; | 1347 | struct nouveau_i2c_chan *chan; |
1350 | struct i2c_msg msg; | 1348 | struct i2c_msg msg; |
1351 | int i; | 1349 | int i; |
1352 | 1350 | ||
1353 | if (!iexec->execute) | 1351 | if (!iexec->execute) |
1354 | return true; | 1352 | return len; |
1355 | 1353 | ||
1356 | BIOSLOG(bios, "0x%04X: DCBI2CIndex: 0x%02X, I2CAddress: 0x%02X, " | 1354 | BIOSLOG(bios, "0x%04X: DCBI2CIndex: 0x%02X, I2CAddress: 0x%02X, " |
1357 | "Count: 0x%02X\n", | 1355 | "Count: 0x%02X\n", |
@@ -1359,7 +1357,7 @@ init_zm_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1359 | 1357 | ||
1360 | chan = init_i2c_device_find(bios->dev, i2c_index); | 1358 | chan = init_i2c_device_find(bios->dev, i2c_index); |
1361 | if (!chan) | 1359 | if (!chan) |
1362 | return false; | 1360 | return 0; |
1363 | 1361 | ||
1364 | for (i = 0; i < count; i++) { | 1362 | for (i = 0; i < count; i++) { |
1365 | uint8_t i2c_reg = bios->data[offset + 4 + i * 2]; | 1363 | uint8_t i2c_reg = bios->data[offset + 4 + i * 2]; |
@@ -1374,14 +1372,14 @@ init_zm_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1374 | msg.len = 1; | 1372 | msg.len = 1; |
1375 | msg.buf = &data; | 1373 | msg.buf = &data; |
1376 | if (i2c_transfer(&chan->adapter, &msg, 1) != 1) | 1374 | if (i2c_transfer(&chan->adapter, &msg, 1) != 1) |
1377 | return false; | 1375 | return 0; |
1378 | } | 1376 | } |
1379 | } | 1377 | } |
1380 | 1378 | ||
1381 | return true; | 1379 | return len; |
1382 | } | 1380 | } |
1383 | 1381 | ||
1384 | static bool | 1382 | static int |
1385 | init_zm_i2c(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 1383 | init_zm_i2c(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
1386 | { | 1384 | { |
1387 | /* | 1385 | /* |
@@ -1401,13 +1399,14 @@ init_zm_i2c(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1401 | uint8_t i2c_index = bios->data[offset + 1]; | 1399 | uint8_t i2c_index = bios->data[offset + 1]; |
1402 | uint8_t i2c_address = bios->data[offset + 2]; | 1400 | uint8_t i2c_address = bios->data[offset + 2]; |
1403 | uint8_t count = bios->data[offset + 3]; | 1401 | uint8_t count = bios->data[offset + 3]; |
1402 | int len = 4 + count; | ||
1404 | struct nouveau_i2c_chan *chan; | 1403 | struct nouveau_i2c_chan *chan; |
1405 | struct i2c_msg msg; | 1404 | struct i2c_msg msg; |
1406 | uint8_t data[256]; | 1405 | uint8_t data[256]; |
1407 | int i; | 1406 | int i; |
1408 | 1407 | ||
1409 | if (!iexec->execute) | 1408 | if (!iexec->execute) |
1410 | return true; | 1409 | return len; |
1411 | 1410 | ||
1412 | BIOSLOG(bios, "0x%04X: DCBI2CIndex: 0x%02X, I2CAddress: 0x%02X, " | 1411 | BIOSLOG(bios, "0x%04X: DCBI2CIndex: 0x%02X, I2CAddress: 0x%02X, " |
1413 | "Count: 0x%02X\n", | 1412 | "Count: 0x%02X\n", |
@@ -1415,7 +1414,7 @@ init_zm_i2c(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1415 | 1414 | ||
1416 | chan = init_i2c_device_find(bios->dev, i2c_index); | 1415 | chan = init_i2c_device_find(bios->dev, i2c_index); |
1417 | if (!chan) | 1416 | if (!chan) |
1418 | return false; | 1417 | return 0; |
1419 | 1418 | ||
1420 | for (i = 0; i < count; i++) { | 1419 | for (i = 0; i < count; i++) { |
1421 | data[i] = bios->data[offset + 4 + i]; | 1420 | data[i] = bios->data[offset + 4 + i]; |
@@ -1429,13 +1428,13 @@ init_zm_i2c(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1429 | msg.len = count; | 1428 | msg.len = count; |
1430 | msg.buf = data; | 1429 | msg.buf = data; |
1431 | if (i2c_transfer(&chan->adapter, &msg, 1) != 1) | 1430 | if (i2c_transfer(&chan->adapter, &msg, 1) != 1) |
1432 | return false; | 1431 | return 0; |
1433 | } | 1432 | } |
1434 | 1433 | ||
1435 | return true; | 1434 | return len; |
1436 | } | 1435 | } |
1437 | 1436 | ||
1438 | static bool | 1437 | static int |
1439 | init_tmds(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 1438 | init_tmds(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
1440 | { | 1439 | { |
1441 | /* | 1440 | /* |
@@ -1460,7 +1459,7 @@ init_tmds(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1460 | uint32_t reg, value; | 1459 | uint32_t reg, value; |
1461 | 1460 | ||
1462 | if (!iexec->execute) | 1461 | if (!iexec->execute) |
1463 | return true; | 1462 | return 5; |
1464 | 1463 | ||
1465 | BIOSLOG(bios, "0x%04X: MagicLookupValue: 0x%02X, TMDSAddr: 0x%02X, " | 1464 | BIOSLOG(bios, "0x%04X: MagicLookupValue: 0x%02X, TMDSAddr: 0x%02X, " |
1466 | "Mask: 0x%02X, Data: 0x%02X\n", | 1465 | "Mask: 0x%02X, Data: 0x%02X\n", |
@@ -1468,7 +1467,7 @@ init_tmds(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1468 | 1467 | ||
1469 | reg = get_tmds_index_reg(bios->dev, mlv); | 1468 | reg = get_tmds_index_reg(bios->dev, mlv); |
1470 | if (!reg) | 1469 | if (!reg) |
1471 | return false; | 1470 | return 0; |
1472 | 1471 | ||
1473 | bios_wr32(bios, reg, | 1472 | bios_wr32(bios, reg, |
1474 | tmdsaddr | NV_PRAMDAC_FP_TMDS_CONTROL_WRITE_DISABLE); | 1473 | tmdsaddr | NV_PRAMDAC_FP_TMDS_CONTROL_WRITE_DISABLE); |
@@ -1476,10 +1475,10 @@ init_tmds(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1476 | bios_wr32(bios, reg + 4, value); | 1475 | bios_wr32(bios, reg + 4, value); |
1477 | bios_wr32(bios, reg, tmdsaddr); | 1476 | bios_wr32(bios, reg, tmdsaddr); |
1478 | 1477 | ||
1479 | return true; | 1478 | return 5; |
1480 | } | 1479 | } |
1481 | 1480 | ||
1482 | static bool | 1481 | static int |
1483 | init_zm_tmds_group(struct nvbios *bios, uint16_t offset, | 1482 | init_zm_tmds_group(struct nvbios *bios, uint16_t offset, |
1484 | struct init_exec *iexec) | 1483 | struct init_exec *iexec) |
1485 | { | 1484 | { |
@@ -1500,18 +1499,19 @@ init_zm_tmds_group(struct nvbios *bios, uint16_t offset, | |||
1500 | 1499 | ||
1501 | uint8_t mlv = bios->data[offset + 1]; | 1500 | uint8_t mlv = bios->data[offset + 1]; |
1502 | uint8_t count = bios->data[offset + 2]; | 1501 | uint8_t count = bios->data[offset + 2]; |
1502 | int len = 3 + count * 2; | ||
1503 | uint32_t reg; | 1503 | uint32_t reg; |
1504 | int i; | 1504 | int i; |
1505 | 1505 | ||
1506 | if (!iexec->execute) | 1506 | if (!iexec->execute) |
1507 | return true; | 1507 | return len; |
1508 | 1508 | ||
1509 | BIOSLOG(bios, "0x%04X: MagicLookupValue: 0x%02X, Count: 0x%02X\n", | 1509 | BIOSLOG(bios, "0x%04X: MagicLookupValue: 0x%02X, Count: 0x%02X\n", |
1510 | offset, mlv, count); | 1510 | offset, mlv, count); |
1511 | 1511 | ||
1512 | reg = get_tmds_index_reg(bios->dev, mlv); | 1512 | reg = get_tmds_index_reg(bios->dev, mlv); |
1513 | if (!reg) | 1513 | if (!reg) |
1514 | return false; | 1514 | return 0; |
1515 | 1515 | ||
1516 | for (i = 0; i < count; i++) { | 1516 | for (i = 0; i < count; i++) { |
1517 | uint8_t tmdsaddr = bios->data[offset + 3 + i * 2]; | 1517 | uint8_t tmdsaddr = bios->data[offset + 3 + i * 2]; |
@@ -1521,10 +1521,10 @@ init_zm_tmds_group(struct nvbios *bios, uint16_t offset, | |||
1521 | bios_wr32(bios, reg, tmdsaddr); | 1521 | bios_wr32(bios, reg, tmdsaddr); |
1522 | } | 1522 | } |
1523 | 1523 | ||
1524 | return true; | 1524 | return len; |
1525 | } | 1525 | } |
1526 | 1526 | ||
1527 | static bool | 1527 | static int |
1528 | init_cr_idx_adr_latch(struct nvbios *bios, uint16_t offset, | 1528 | init_cr_idx_adr_latch(struct nvbios *bios, uint16_t offset, |
1529 | struct init_exec *iexec) | 1529 | struct init_exec *iexec) |
1530 | { | 1530 | { |
@@ -1547,11 +1547,12 @@ init_cr_idx_adr_latch(struct nvbios *bios, uint16_t offset, | |||
1547 | uint8_t crtcindex2 = bios->data[offset + 2]; | 1547 | uint8_t crtcindex2 = bios->data[offset + 2]; |
1548 | uint8_t baseaddr = bios->data[offset + 3]; | 1548 | uint8_t baseaddr = bios->data[offset + 3]; |
1549 | uint8_t count = bios->data[offset + 4]; | 1549 | uint8_t count = bios->data[offset + 4]; |
1550 | int len = 5 + count; | ||
1550 | uint8_t oldaddr, data; | 1551 | uint8_t oldaddr, data; |
1551 | int i; | 1552 | int i; |
1552 | 1553 | ||
1553 | if (!iexec->execute) | 1554 | if (!iexec->execute) |
1554 | return true; | 1555 | return len; |
1555 | 1556 | ||
1556 | BIOSLOG(bios, "0x%04X: Index1: 0x%02X, Index2: 0x%02X, " | 1557 | BIOSLOG(bios, "0x%04X: Index1: 0x%02X, Index2: 0x%02X, " |
1557 | "BaseAddr: 0x%02X, Count: 0x%02X\n", | 1558 | "BaseAddr: 0x%02X, Count: 0x%02X\n", |
@@ -1568,10 +1569,10 @@ init_cr_idx_adr_latch(struct nvbios *bios, uint16_t offset, | |||
1568 | 1569 | ||
1569 | bios_idxprt_wr(bios, NV_CIO_CRX__COLOR, crtcindex1, oldaddr); | 1570 | bios_idxprt_wr(bios, NV_CIO_CRX__COLOR, crtcindex1, oldaddr); |
1570 | 1571 | ||
1571 | return true; | 1572 | return len; |
1572 | } | 1573 | } |
1573 | 1574 | ||
1574 | static bool | 1575 | static int |
1575 | init_cr(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 1576 | init_cr(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
1576 | { | 1577 | { |
1577 | /* | 1578 | /* |
@@ -1592,7 +1593,7 @@ init_cr(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1592 | uint8_t value; | 1593 | uint8_t value; |
1593 | 1594 | ||
1594 | if (!iexec->execute) | 1595 | if (!iexec->execute) |
1595 | return true; | 1596 | return 4; |
1596 | 1597 | ||
1597 | BIOSLOG(bios, "0x%04X: Index: 0x%02X, Mask: 0x%02X, Data: 0x%02X\n", | 1598 | BIOSLOG(bios, "0x%04X: Index: 0x%02X, Mask: 0x%02X, Data: 0x%02X\n", |
1598 | offset, crtcindex, mask, data); | 1599 | offset, crtcindex, mask, data); |
@@ -1601,10 +1602,10 @@ init_cr(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1601 | value |= data; | 1602 | value |= data; |
1602 | bios_idxprt_wr(bios, NV_CIO_CRX__COLOR, crtcindex, value); | 1603 | bios_idxprt_wr(bios, NV_CIO_CRX__COLOR, crtcindex, value); |
1603 | 1604 | ||
1604 | return true; | 1605 | return 4; |
1605 | } | 1606 | } |
1606 | 1607 | ||
1607 | static bool | 1608 | static int |
1608 | init_zm_cr(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 1609 | init_zm_cr(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
1609 | { | 1610 | { |
1610 | /* | 1611 | /* |
@@ -1621,14 +1622,14 @@ init_zm_cr(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1621 | uint8_t data = bios->data[offset + 2]; | 1622 | uint8_t data = bios->data[offset + 2]; |
1622 | 1623 | ||
1623 | if (!iexec->execute) | 1624 | if (!iexec->execute) |
1624 | return true; | 1625 | return 3; |
1625 | 1626 | ||
1626 | bios_idxprt_wr(bios, NV_CIO_CRX__COLOR, crtcindex, data); | 1627 | bios_idxprt_wr(bios, NV_CIO_CRX__COLOR, crtcindex, data); |
1627 | 1628 | ||
1628 | return true; | 1629 | return 3; |
1629 | } | 1630 | } |
1630 | 1631 | ||
1631 | static bool | 1632 | static int |
1632 | init_zm_cr_group(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 1633 | init_zm_cr_group(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
1633 | { | 1634 | { |
1634 | /* | 1635 | /* |
@@ -1645,18 +1646,19 @@ init_zm_cr_group(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1645 | */ | 1646 | */ |
1646 | 1647 | ||
1647 | uint8_t count = bios->data[offset + 1]; | 1648 | uint8_t count = bios->data[offset + 1]; |
1649 | int len = 2 + count * 2; | ||
1648 | int i; | 1650 | int i; |
1649 | 1651 | ||
1650 | if (!iexec->execute) | 1652 | if (!iexec->execute) |
1651 | return true; | 1653 | return len; |
1652 | 1654 | ||
1653 | for (i = 0; i < count; i++) | 1655 | for (i = 0; i < count; i++) |
1654 | init_zm_cr(bios, offset + 2 + 2 * i - 1, iexec); | 1656 | init_zm_cr(bios, offset + 2 + 2 * i - 1, iexec); |
1655 | 1657 | ||
1656 | return true; | 1658 | return len; |
1657 | } | 1659 | } |
1658 | 1660 | ||
1659 | static bool | 1661 | static int |
1660 | init_condition_time(struct nvbios *bios, uint16_t offset, | 1662 | init_condition_time(struct nvbios *bios, uint16_t offset, |
1661 | struct init_exec *iexec) | 1663 | struct init_exec *iexec) |
1662 | { | 1664 | { |
@@ -1680,7 +1682,7 @@ init_condition_time(struct nvbios *bios, uint16_t offset, | |||
1680 | unsigned cnt; | 1682 | unsigned cnt; |
1681 | 1683 | ||
1682 | if (!iexec->execute) | 1684 | if (!iexec->execute) |
1683 | return true; | 1685 | return 3; |
1684 | 1686 | ||
1685 | if (retries > 100) | 1687 | if (retries > 100) |
1686 | retries = 100; | 1688 | retries = 100; |
@@ -1711,10 +1713,10 @@ init_condition_time(struct nvbios *bios, uint16_t offset, | |||
1711 | iexec->execute = false; | 1713 | iexec->execute = false; |
1712 | } | 1714 | } |
1713 | 1715 | ||
1714 | return true; | 1716 | return 3; |
1715 | } | 1717 | } |
1716 | 1718 | ||
1717 | static bool | 1719 | static int |
1718 | init_zm_reg_sequence(struct nvbios *bios, uint16_t offset, | 1720 | init_zm_reg_sequence(struct nvbios *bios, uint16_t offset, |
1719 | struct init_exec *iexec) | 1721 | struct init_exec *iexec) |
1720 | { | 1722 | { |
@@ -1734,10 +1736,11 @@ init_zm_reg_sequence(struct nvbios *bios, uint16_t offset, | |||
1734 | 1736 | ||
1735 | uint32_t basereg = ROM32(bios->data[offset + 1]); | 1737 | uint32_t basereg = ROM32(bios->data[offset + 1]); |
1736 | uint32_t count = bios->data[offset + 5]; | 1738 | uint32_t count = bios->data[offset + 5]; |
1739 | int len = 6 + count * 4; | ||
1737 | int i; | 1740 | int i; |
1738 | 1741 | ||
1739 | if (!iexec->execute) | 1742 | if (!iexec->execute) |
1740 | return true; | 1743 | return len; |
1741 | 1744 | ||
1742 | BIOSLOG(bios, "0x%04X: BaseReg: 0x%08X, Count: 0x%02X\n", | 1745 | BIOSLOG(bios, "0x%04X: BaseReg: 0x%08X, Count: 0x%02X\n", |
1743 | offset, basereg, count); | 1746 | offset, basereg, count); |
@@ -1749,10 +1752,10 @@ init_zm_reg_sequence(struct nvbios *bios, uint16_t offset, | |||
1749 | bios_wr32(bios, reg, data); | 1752 | bios_wr32(bios, reg, data); |
1750 | } | 1753 | } |
1751 | 1754 | ||
1752 | return true; | 1755 | return len; |
1753 | } | 1756 | } |
1754 | 1757 | ||
1755 | static bool | 1758 | static int |
1756 | init_sub_direct(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 1759 | init_sub_direct(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
1757 | { | 1760 | { |
1758 | /* | 1761 | /* |
@@ -1768,7 +1771,7 @@ init_sub_direct(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1768 | uint16_t sub_offset = ROM16(bios->data[offset + 1]); | 1771 | uint16_t sub_offset = ROM16(bios->data[offset + 1]); |
1769 | 1772 | ||
1770 | if (!iexec->execute) | 1773 | if (!iexec->execute) |
1771 | return true; | 1774 | return 3; |
1772 | 1775 | ||
1773 | BIOSLOG(bios, "0x%04X: Executing subroutine at 0x%04X\n", | 1776 | BIOSLOG(bios, "0x%04X: Executing subroutine at 0x%04X\n", |
1774 | offset, sub_offset); | 1777 | offset, sub_offset); |
@@ -1777,10 +1780,10 @@ init_sub_direct(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1777 | 1780 | ||
1778 | BIOSLOG(bios, "0x%04X: End of 0x%04X subroutine\n", offset, sub_offset); | 1781 | BIOSLOG(bios, "0x%04X: End of 0x%04X subroutine\n", offset, sub_offset); |
1779 | 1782 | ||
1780 | return true; | 1783 | return 3; |
1781 | } | 1784 | } |
1782 | 1785 | ||
1783 | static bool | 1786 | static int |
1784 | init_copy_nv_reg(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 1787 | init_copy_nv_reg(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
1785 | { | 1788 | { |
1786 | /* | 1789 | /* |
@@ -1808,7 +1811,7 @@ init_copy_nv_reg(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1808 | uint32_t srcvalue, dstvalue; | 1811 | uint32_t srcvalue, dstvalue; |
1809 | 1812 | ||
1810 | if (!iexec->execute) | 1813 | if (!iexec->execute) |
1811 | return true; | 1814 | return 22; |
1812 | 1815 | ||
1813 | BIOSLOG(bios, "0x%04X: SrcReg: 0x%08X, Shift: 0x%02X, SrcMask: 0x%08X, " | 1816 | BIOSLOG(bios, "0x%04X: SrcReg: 0x%08X, Shift: 0x%02X, SrcMask: 0x%08X, " |
1814 | "Xor: 0x%08X, DstReg: 0x%08X, DstMask: 0x%08X\n", | 1817 | "Xor: 0x%08X, DstReg: 0x%08X, DstMask: 0x%08X\n", |
@@ -1827,10 +1830,10 @@ init_copy_nv_reg(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1827 | 1830 | ||
1828 | bios_wr32(bios, dstreg, dstvalue | srcvalue); | 1831 | bios_wr32(bios, dstreg, dstvalue | srcvalue); |
1829 | 1832 | ||
1830 | return true; | 1833 | return 22; |
1831 | } | 1834 | } |
1832 | 1835 | ||
1833 | static bool | 1836 | static int |
1834 | init_zm_index_io(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 1837 | init_zm_index_io(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
1835 | { | 1838 | { |
1836 | /* | 1839 | /* |
@@ -1848,14 +1851,14 @@ init_zm_index_io(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1848 | uint8_t data = bios->data[offset + 4]; | 1851 | uint8_t data = bios->data[offset + 4]; |
1849 | 1852 | ||
1850 | if (!iexec->execute) | 1853 | if (!iexec->execute) |
1851 | return true; | 1854 | return 5; |
1852 | 1855 | ||
1853 | bios_idxprt_wr(bios, crtcport, crtcindex, data); | 1856 | bios_idxprt_wr(bios, crtcport, crtcindex, data); |
1854 | 1857 | ||
1855 | return true; | 1858 | return 5; |
1856 | } | 1859 | } |
1857 | 1860 | ||
1858 | static bool | 1861 | static int |
1859 | init_compute_mem(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 1862 | init_compute_mem(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
1860 | { | 1863 | { |
1861 | /* | 1864 | /* |
@@ -1904,7 +1907,7 @@ init_compute_mem(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1904 | struct drm_nouveau_private *dev_priv = bios->dev->dev_private; | 1907 | struct drm_nouveau_private *dev_priv = bios->dev->dev_private; |
1905 | 1908 | ||
1906 | if (dev_priv->card_type >= NV_50) | 1909 | if (dev_priv->card_type >= NV_50) |
1907 | return true; | 1910 | return 1; |
1908 | 1911 | ||
1909 | /* | 1912 | /* |
1910 | * On every card I've seen, this step gets done for us earlier in | 1913 | * On every card I've seen, this step gets done for us earlier in |
@@ -1922,10 +1925,10 @@ init_compute_mem(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1922 | /* write back the saved configuration value */ | 1925 | /* write back the saved configuration value */ |
1923 | bios_wr32(bios, NV_PFB_CFG0, bios->state.saved_nv_pfb_cfg0); | 1926 | bios_wr32(bios, NV_PFB_CFG0, bios->state.saved_nv_pfb_cfg0); |
1924 | 1927 | ||
1925 | return true; | 1928 | return 1; |
1926 | } | 1929 | } |
1927 | 1930 | ||
1928 | static bool | 1931 | static int |
1929 | init_reset(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 1932 | init_reset(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
1930 | { | 1933 | { |
1931 | /* | 1934 | /* |
@@ -1959,10 +1962,10 @@ init_reset(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1959 | pci_nv_20 &= ~NV_PBUS_PCI_NV_20_ROM_SHADOW_ENABLED; /* 0xfffffffe */ | 1962 | pci_nv_20 &= ~NV_PBUS_PCI_NV_20_ROM_SHADOW_ENABLED; /* 0xfffffffe */ |
1960 | bios_wr32(bios, NV_PBUS_PCI_NV_20, pci_nv_20); | 1963 | bios_wr32(bios, NV_PBUS_PCI_NV_20, pci_nv_20); |
1961 | 1964 | ||
1962 | return true; | 1965 | return 13; |
1963 | } | 1966 | } |
1964 | 1967 | ||
1965 | static bool | 1968 | static int |
1966 | init_configure_mem(struct nvbios *bios, uint16_t offset, | 1969 | init_configure_mem(struct nvbios *bios, uint16_t offset, |
1967 | struct init_exec *iexec) | 1970 | struct init_exec *iexec) |
1968 | { | 1971 | { |
@@ -1983,7 +1986,7 @@ init_configure_mem(struct nvbios *bios, uint16_t offset, | |||
1983 | uint32_t reg, data; | 1986 | uint32_t reg, data; |
1984 | 1987 | ||
1985 | if (bios->major_version > 2) | 1988 | if (bios->major_version > 2) |
1986 | return false; | 1989 | return 0; |
1987 | 1990 | ||
1988 | bios_idxprt_wr(bios, NV_VIO_SRX, NV_VIO_SR_CLOCK_INDEX, bios_idxprt_rd( | 1991 | bios_idxprt_wr(bios, NV_VIO_SRX, NV_VIO_SR_CLOCK_INDEX, bios_idxprt_rd( |
1989 | bios, NV_VIO_SRX, NV_VIO_SR_CLOCK_INDEX) | 0x20); | 1992 | bios, NV_VIO_SRX, NV_VIO_SR_CLOCK_INDEX) | 0x20); |
@@ -2015,10 +2018,10 @@ init_configure_mem(struct nvbios *bios, uint16_t offset, | |||
2015 | bios_wr32(bios, reg, data); | 2018 | bios_wr32(bios, reg, data); |
2016 | } | 2019 | } |
2017 | 2020 | ||
2018 | return true; | 2021 | return 1; |
2019 | } | 2022 | } |
2020 | 2023 | ||
2021 | static bool | 2024 | static int |
2022 | init_configure_clk(struct nvbios *bios, uint16_t offset, | 2025 | init_configure_clk(struct nvbios *bios, uint16_t offset, |
2023 | struct init_exec *iexec) | 2026 | struct init_exec *iexec) |
2024 | { | 2027 | { |
@@ -2038,7 +2041,7 @@ init_configure_clk(struct nvbios *bios, uint16_t offset, | |||
2038 | int clock; | 2041 | int clock; |
2039 | 2042 | ||
2040 | if (bios->major_version > 2) | 2043 | if (bios->major_version > 2) |
2041 | return false; | 2044 | return 0; |
2042 | 2045 | ||
2043 | clock = ROM16(bios->data[meminitoffs + 4]) * 10; | 2046 | clock = ROM16(bios->data[meminitoffs + 4]) * 10; |
2044 | setPLL(bios, NV_PRAMDAC_NVPLL_COEFF, clock); | 2047 | setPLL(bios, NV_PRAMDAC_NVPLL_COEFF, clock); |
@@ -2048,10 +2051,10 @@ init_configure_clk(struct nvbios *bios, uint16_t offset, | |||
2048 | clock *= 2; | 2051 | clock *= 2; |
2049 | setPLL(bios, NV_PRAMDAC_MPLL_COEFF, clock); | 2052 | setPLL(bios, NV_PRAMDAC_MPLL_COEFF, clock); |
2050 | 2053 | ||
2051 | return true; | 2054 | return 1; |
2052 | } | 2055 | } |
2053 | 2056 | ||
2054 | static bool | 2057 | static int |
2055 | init_configure_preinit(struct nvbios *bios, uint16_t offset, | 2058 | init_configure_preinit(struct nvbios *bios, uint16_t offset, |
2056 | struct init_exec *iexec) | 2059 | struct init_exec *iexec) |
2057 | { | 2060 | { |
@@ -2071,15 +2074,15 @@ init_configure_preinit(struct nvbios *bios, uint16_t offset, | |||
2071 | uint8_t cr3c = ((straps << 2) & 0xf0) | (straps & (1 << 6)); | 2074 | uint8_t cr3c = ((straps << 2) & 0xf0) | (straps & (1 << 6)); |
2072 | 2075 | ||
2073 | if (bios->major_version > 2) | 2076 | if (bios->major_version > 2) |
2074 | return false; | 2077 | return 0; |
2075 | 2078 | ||
2076 | bios_idxprt_wr(bios, NV_CIO_CRX__COLOR, | 2079 | bios_idxprt_wr(bios, NV_CIO_CRX__COLOR, |
2077 | NV_CIO_CRE_SCRATCH4__INDEX, cr3c); | 2080 | NV_CIO_CRE_SCRATCH4__INDEX, cr3c); |
2078 | 2081 | ||
2079 | return true; | 2082 | return 1; |
2080 | } | 2083 | } |
2081 | 2084 | ||
2082 | static bool | 2085 | static int |
2083 | init_io(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 2086 | init_io(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
2084 | { | 2087 | { |
2085 | /* | 2088 | /* |
@@ -2099,7 +2102,7 @@ init_io(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2099 | uint8_t data = bios->data[offset + 4]; | 2102 | uint8_t data = bios->data[offset + 4]; |
2100 | 2103 | ||
2101 | if (!iexec->execute) | 2104 | if (!iexec->execute) |
2102 | return true; | 2105 | return 5; |
2103 | 2106 | ||
2104 | BIOSLOG(bios, "0x%04X: Port: 0x%04X, Mask: 0x%02X, Data: 0x%02X\n", | 2107 | BIOSLOG(bios, "0x%04X: Port: 0x%04X, Mask: 0x%02X, Data: 0x%02X\n", |
2105 | offset, crtcport, mask, data); | 2108 | offset, crtcport, mask, data); |
@@ -2158,15 +2161,15 @@ init_io(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2158 | for (i = 0; i < 2; i++) | 2161 | for (i = 0; i < 2; i++) |
2159 | bios_wr32(bios, 0x614108 + (i*0x800), bios_rd32( | 2162 | bios_wr32(bios, 0x614108 + (i*0x800), bios_rd32( |
2160 | bios, 0x614108 + (i*0x800)) & 0x0fffffff); | 2163 | bios, 0x614108 + (i*0x800)) & 0x0fffffff); |
2161 | return true; | 2164 | return 5; |
2162 | } | 2165 | } |
2163 | 2166 | ||
2164 | bios_port_wr(bios, crtcport, (bios_port_rd(bios, crtcport) & mask) | | 2167 | bios_port_wr(bios, crtcport, (bios_port_rd(bios, crtcport) & mask) | |
2165 | data); | 2168 | data); |
2166 | return true; | 2169 | return 5; |
2167 | } | 2170 | } |
2168 | 2171 | ||
2169 | static bool | 2172 | static int |
2170 | init_sub(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 2173 | init_sub(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
2171 | { | 2174 | { |
2172 | /* | 2175 | /* |
@@ -2181,7 +2184,7 @@ init_sub(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2181 | uint8_t sub = bios->data[offset + 1]; | 2184 | uint8_t sub = bios->data[offset + 1]; |
2182 | 2185 | ||
2183 | if (!iexec->execute) | 2186 | if (!iexec->execute) |
2184 | return true; | 2187 | return 2; |
2185 | 2188 | ||
2186 | BIOSLOG(bios, "0x%04X: Calling script %d\n", offset, sub); | 2189 | BIOSLOG(bios, "0x%04X: Calling script %d\n", offset, sub); |
2187 | 2190 | ||
@@ -2191,10 +2194,10 @@ init_sub(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2191 | 2194 | ||
2192 | BIOSLOG(bios, "0x%04X: End of script %d\n", offset, sub); | 2195 | BIOSLOG(bios, "0x%04X: End of script %d\n", offset, sub); |
2193 | 2196 | ||
2194 | return true; | 2197 | return 2; |
2195 | } | 2198 | } |
2196 | 2199 | ||
2197 | static bool | 2200 | static int |
2198 | init_ram_condition(struct nvbios *bios, uint16_t offset, | 2201 | init_ram_condition(struct nvbios *bios, uint16_t offset, |
2199 | struct init_exec *iexec) | 2202 | struct init_exec *iexec) |
2200 | { | 2203 | { |
@@ -2215,7 +2218,7 @@ init_ram_condition(struct nvbios *bios, uint16_t offset, | |||
2215 | uint8_t data; | 2218 | uint8_t data; |
2216 | 2219 | ||
2217 | if (!iexec->execute) | 2220 | if (!iexec->execute) |
2218 | return true; | 2221 | return 3; |
2219 | 2222 | ||
2220 | data = bios_rd32(bios, NV_PFB_BOOT_0) & mask; | 2223 | data = bios_rd32(bios, NV_PFB_BOOT_0) & mask; |
2221 | 2224 | ||
@@ -2229,10 +2232,10 @@ init_ram_condition(struct nvbios *bios, uint16_t offset, | |||
2229 | iexec->execute = false; | 2232 | iexec->execute = false; |
2230 | } | 2233 | } |
2231 | 2234 | ||
2232 | return true; | 2235 | return 3; |
2233 | } | 2236 | } |
2234 | 2237 | ||
2235 | static bool | 2238 | static int |
2236 | init_nv_reg(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 2239 | init_nv_reg(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
2237 | { | 2240 | { |
2238 | /* | 2241 | /* |
@@ -2251,17 +2254,17 @@ init_nv_reg(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2251 | uint32_t data = ROM32(bios->data[offset + 9]); | 2254 | uint32_t data = ROM32(bios->data[offset + 9]); |
2252 | 2255 | ||
2253 | if (!iexec->execute) | 2256 | if (!iexec->execute) |
2254 | return true; | 2257 | return 13; |
2255 | 2258 | ||
2256 | BIOSLOG(bios, "0x%04X: Reg: 0x%08X, Mask: 0x%08X, Data: 0x%08X\n", | 2259 | BIOSLOG(bios, "0x%04X: Reg: 0x%08X, Mask: 0x%08X, Data: 0x%08X\n", |
2257 | offset, reg, mask, data); | 2260 | offset, reg, mask, data); |
2258 | 2261 | ||
2259 | bios_wr32(bios, reg, (bios_rd32(bios, reg) & mask) | data); | 2262 | bios_wr32(bios, reg, (bios_rd32(bios, reg) & mask) | data); |
2260 | 2263 | ||
2261 | return true; | 2264 | return 13; |
2262 | } | 2265 | } |
2263 | 2266 | ||
2264 | static bool | 2267 | static int |
2265 | init_macro(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 2268 | init_macro(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
2266 | { | 2269 | { |
2267 | /* | 2270 | /* |
@@ -2285,7 +2288,7 @@ init_macro(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2285 | int i; | 2288 | int i; |
2286 | 2289 | ||
2287 | if (!iexec->execute) | 2290 | if (!iexec->execute) |
2288 | return true; | 2291 | return 2; |
2289 | 2292 | ||
2290 | BIOSLOG(bios, "0x%04X: Macro: 0x%02X, MacroTableIndex: 0x%02X, " | 2293 | BIOSLOG(bios, "0x%04X: Macro: 0x%02X, MacroTableIndex: 0x%02X, " |
2291 | "Count: 0x%02X\n", | 2294 | "Count: 0x%02X\n", |
@@ -2300,10 +2303,10 @@ init_macro(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2300 | bios_wr32(bios, reg, data); | 2303 | bios_wr32(bios, reg, data); |
2301 | } | 2304 | } |
2302 | 2305 | ||
2303 | return true; | 2306 | return 2; |
2304 | } | 2307 | } |
2305 | 2308 | ||
2306 | static bool | 2309 | static int |
2307 | init_done(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 2310 | init_done(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
2308 | { | 2311 | { |
2309 | /* | 2312 | /* |
@@ -2315,10 +2318,10 @@ init_done(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2315 | */ | 2318 | */ |
2316 | 2319 | ||
2317 | /* mild retval abuse to stop parsing this table */ | 2320 | /* mild retval abuse to stop parsing this table */ |
2318 | return false; | 2321 | return 0; |
2319 | } | 2322 | } |
2320 | 2323 | ||
2321 | static bool | 2324 | static int |
2322 | init_resume(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 2325 | init_resume(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
2323 | { | 2326 | { |
2324 | /* | 2327 | /* |
@@ -2330,15 +2333,15 @@ init_resume(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2330 | */ | 2333 | */ |
2331 | 2334 | ||
2332 | if (iexec->execute) | 2335 | if (iexec->execute) |
2333 | return true; | 2336 | return 1; |
2334 | 2337 | ||
2335 | iexec->execute = true; | 2338 | iexec->execute = true; |
2336 | BIOSLOG(bios, "0x%04X: ---- Executing following commands ----\n", offset); | 2339 | BIOSLOG(bios, "0x%04X: ---- Executing following commands ----\n", offset); |
2337 | 2340 | ||
2338 | return true; | 2341 | return 1; |
2339 | } | 2342 | } |
2340 | 2343 | ||
2341 | static bool | 2344 | static int |
2342 | init_time(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 2345 | init_time(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
2343 | { | 2346 | { |
2344 | /* | 2347 | /* |
@@ -2353,7 +2356,7 @@ init_time(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2353 | unsigned time = ROM16(bios->data[offset + 1]); | 2356 | unsigned time = ROM16(bios->data[offset + 1]); |
2354 | 2357 | ||
2355 | if (!iexec->execute) | 2358 | if (!iexec->execute) |
2356 | return true; | 2359 | return 3; |
2357 | 2360 | ||
2358 | BIOSLOG(bios, "0x%04X: Sleeping for 0x%04X microseconds\n", | 2361 | BIOSLOG(bios, "0x%04X: Sleeping for 0x%04X microseconds\n", |
2359 | offset, time); | 2362 | offset, time); |
@@ -2363,10 +2366,10 @@ init_time(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2363 | else | 2366 | else |
2364 | msleep((time + 900) / 1000); | 2367 | msleep((time + 900) / 1000); |
2365 | 2368 | ||
2366 | return true; | 2369 | return 3; |
2367 | } | 2370 | } |
2368 | 2371 | ||
2369 | static bool | 2372 | static int |
2370 | init_condition(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 2373 | init_condition(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
2371 | { | 2374 | { |
2372 | /* | 2375 | /* |
@@ -2383,7 +2386,7 @@ init_condition(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2383 | uint8_t cond = bios->data[offset + 1]; | 2386 | uint8_t cond = bios->data[offset + 1]; |
2384 | 2387 | ||
2385 | if (!iexec->execute) | 2388 | if (!iexec->execute) |
2386 | return true; | 2389 | return 2; |
2387 | 2390 | ||
2388 | BIOSLOG(bios, "0x%04X: Condition: 0x%02X\n", offset, cond); | 2391 | BIOSLOG(bios, "0x%04X: Condition: 0x%02X\n", offset, cond); |
2389 | 2392 | ||
@@ -2394,10 +2397,10 @@ init_condition(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2394 | iexec->execute = false; | 2397 | iexec->execute = false; |
2395 | } | 2398 | } |
2396 | 2399 | ||
2397 | return true; | 2400 | return 2; |
2398 | } | 2401 | } |
2399 | 2402 | ||
2400 | static bool | 2403 | static int |
2401 | init_io_condition(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 2404 | init_io_condition(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
2402 | { | 2405 | { |
2403 | /* | 2406 | /* |
@@ -2414,7 +2417,7 @@ init_io_condition(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2414 | uint8_t cond = bios->data[offset + 1]; | 2417 | uint8_t cond = bios->data[offset + 1]; |
2415 | 2418 | ||
2416 | if (!iexec->execute) | 2419 | if (!iexec->execute) |
2417 | return true; | 2420 | return 2; |
2418 | 2421 | ||
2419 | BIOSLOG(bios, "0x%04X: IO condition: 0x%02X\n", offset, cond); | 2422 | BIOSLOG(bios, "0x%04X: IO condition: 0x%02X\n", offset, cond); |
2420 | 2423 | ||
@@ -2425,10 +2428,10 @@ init_io_condition(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2425 | iexec->execute = false; | 2428 | iexec->execute = false; |
2426 | } | 2429 | } |
2427 | 2430 | ||
2428 | return true; | 2431 | return 2; |
2429 | } | 2432 | } |
2430 | 2433 | ||
2431 | static bool | 2434 | static int |
2432 | init_index_io(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 2435 | init_index_io(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
2433 | { | 2436 | { |
2434 | /* | 2437 | /* |
@@ -2451,7 +2454,7 @@ init_index_io(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2451 | uint8_t value; | 2454 | uint8_t value; |
2452 | 2455 | ||
2453 | if (!iexec->execute) | 2456 | if (!iexec->execute) |
2454 | return true; | 2457 | return 6; |
2455 | 2458 | ||
2456 | BIOSLOG(bios, "0x%04X: Port: 0x%04X, Index: 0x%02X, Mask: 0x%02X, " | 2459 | BIOSLOG(bios, "0x%04X: Port: 0x%04X, Index: 0x%02X, Mask: 0x%02X, " |
2457 | "Data: 0x%02X\n", | 2460 | "Data: 0x%02X\n", |
@@ -2460,10 +2463,10 @@ init_index_io(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2460 | value = (bios_idxprt_rd(bios, crtcport, crtcindex) & mask) | data; | 2463 | value = (bios_idxprt_rd(bios, crtcport, crtcindex) & mask) | data; |
2461 | bios_idxprt_wr(bios, crtcport, crtcindex, value); | 2464 | bios_idxprt_wr(bios, crtcport, crtcindex, value); |
2462 | 2465 | ||
2463 | return true; | 2466 | return 6; |
2464 | } | 2467 | } |
2465 | 2468 | ||
2466 | static bool | 2469 | static int |
2467 | init_pll(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 2470 | init_pll(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
2468 | { | 2471 | { |
2469 | /* | 2472 | /* |
@@ -2481,16 +2484,16 @@ init_pll(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2481 | uint16_t freq = ROM16(bios->data[offset + 5]); | 2484 | uint16_t freq = ROM16(bios->data[offset + 5]); |
2482 | 2485 | ||
2483 | if (!iexec->execute) | 2486 | if (!iexec->execute) |
2484 | return true; | 2487 | return 7; |
2485 | 2488 | ||
2486 | BIOSLOG(bios, "0x%04X: Reg: 0x%08X, Freq: %d0kHz\n", offset, reg, freq); | 2489 | BIOSLOG(bios, "0x%04X: Reg: 0x%08X, Freq: %d0kHz\n", offset, reg, freq); |
2487 | 2490 | ||
2488 | setPLL(bios, reg, freq * 10); | 2491 | setPLL(bios, reg, freq * 10); |
2489 | 2492 | ||
2490 | return true; | 2493 | return 7; |
2491 | } | 2494 | } |
2492 | 2495 | ||
2493 | static bool | 2496 | static int |
2494 | init_zm_reg(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 2497 | init_zm_reg(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
2495 | { | 2498 | { |
2496 | /* | 2499 | /* |
@@ -2507,17 +2510,17 @@ init_zm_reg(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2507 | uint32_t value = ROM32(bios->data[offset + 5]); | 2510 | uint32_t value = ROM32(bios->data[offset + 5]); |
2508 | 2511 | ||
2509 | if (!iexec->execute) | 2512 | if (!iexec->execute) |
2510 | return true; | 2513 | return 9; |
2511 | 2514 | ||
2512 | if (reg == 0x000200) | 2515 | if (reg == 0x000200) |
2513 | value |= 1; | 2516 | value |= 1; |
2514 | 2517 | ||
2515 | bios_wr32(bios, reg, value); | 2518 | bios_wr32(bios, reg, value); |
2516 | 2519 | ||
2517 | return true; | 2520 | return 9; |
2518 | } | 2521 | } |
2519 | 2522 | ||
2520 | static bool | 2523 | static int |
2521 | init_ram_restrict_pll(struct nvbios *bios, uint16_t offset, | 2524 | init_ram_restrict_pll(struct nvbios *bios, uint16_t offset, |
2522 | struct init_exec *iexec) | 2525 | struct init_exec *iexec) |
2523 | { | 2526 | { |
@@ -2543,14 +2546,15 @@ init_ram_restrict_pll(struct nvbios *bios, uint16_t offset, | |||
2543 | uint8_t type = bios->data[offset + 1]; | 2546 | uint8_t type = bios->data[offset + 1]; |
2544 | uint32_t freq = ROM32(bios->data[offset + 2 + (index * 4)]); | 2547 | uint32_t freq = ROM32(bios->data[offset + 2 + (index * 4)]); |
2545 | uint8_t *pll_limits = &bios->data[bios->pll_limit_tbl_ptr], *entry; | 2548 | uint8_t *pll_limits = &bios->data[bios->pll_limit_tbl_ptr], *entry; |
2549 | int len = 2 + bios->ram_restrict_group_count * 4; | ||
2546 | int i; | 2550 | int i; |
2547 | 2551 | ||
2548 | if (!iexec->execute) | 2552 | if (!iexec->execute) |
2549 | return true; | 2553 | return len; |
2550 | 2554 | ||
2551 | if (!bios->pll_limit_tbl_ptr || (pll_limits[0] & 0xf0) != 0x30) { | 2555 | if (!bios->pll_limit_tbl_ptr || (pll_limits[0] & 0xf0) != 0x30) { |
2552 | NV_ERROR(dev, "PLL limits table not version 3.x\n"); | 2556 | NV_ERROR(dev, "PLL limits table not version 3.x\n"); |
2553 | return true; /* deliberate, allow default clocks to remain */ | 2557 | return len; /* deliberate, allow default clocks to remain */ |
2554 | } | 2558 | } |
2555 | 2559 | ||
2556 | entry = pll_limits + pll_limits[1]; | 2560 | entry = pll_limits + pll_limits[1]; |
@@ -2563,15 +2567,15 @@ init_ram_restrict_pll(struct nvbios *bios, uint16_t offset, | |||
2563 | offset, type, reg, freq); | 2567 | offset, type, reg, freq); |
2564 | 2568 | ||
2565 | setPLL(bios, reg, freq); | 2569 | setPLL(bios, reg, freq); |
2566 | return true; | 2570 | return len; |
2567 | } | 2571 | } |
2568 | } | 2572 | } |
2569 | 2573 | ||
2570 | NV_ERROR(dev, "PLL type 0x%02x not found in PLL limits table", type); | 2574 | NV_ERROR(dev, "PLL type 0x%02x not found in PLL limits table", type); |
2571 | return true; | 2575 | return len; |
2572 | } | 2576 | } |
2573 | 2577 | ||
2574 | static bool | 2578 | static int |
2575 | init_8c(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 2579 | init_8c(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
2576 | { | 2580 | { |
2577 | /* | 2581 | /* |
@@ -2581,10 +2585,10 @@ init_8c(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2581 | * | 2585 | * |
2582 | */ | 2586 | */ |
2583 | 2587 | ||
2584 | return true; | 2588 | return 1; |
2585 | } | 2589 | } |
2586 | 2590 | ||
2587 | static bool | 2591 | static int |
2588 | init_8d(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 2592 | init_8d(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
2589 | { | 2593 | { |
2590 | /* | 2594 | /* |
@@ -2594,10 +2598,10 @@ init_8d(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2594 | * | 2598 | * |
2595 | */ | 2599 | */ |
2596 | 2600 | ||
2597 | return true; | 2601 | return 1; |
2598 | } | 2602 | } |
2599 | 2603 | ||
2600 | static bool | 2604 | static int |
2601 | init_gpio(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 2605 | init_gpio(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
2602 | { | 2606 | { |
2603 | /* | 2607 | /* |
@@ -2615,14 +2619,17 @@ init_gpio(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2615 | const uint8_t *gpio_entry; | 2619 | const uint8_t *gpio_entry; |
2616 | int i; | 2620 | int i; |
2617 | 2621 | ||
2622 | if (!iexec->execute) | ||
2623 | return 1; | ||
2624 | |||
2618 | if (bios->bdcb.version != 0x40) { | 2625 | if (bios->bdcb.version != 0x40) { |
2619 | NV_ERROR(bios->dev, "DCB table not version 4.0\n"); | 2626 | NV_ERROR(bios->dev, "DCB table not version 4.0\n"); |
2620 | return false; | 2627 | return 0; |
2621 | } | 2628 | } |
2622 | 2629 | ||
2623 | if (!bios->bdcb.gpio_table_ptr) { | 2630 | if (!bios->bdcb.gpio_table_ptr) { |
2624 | NV_WARN(bios->dev, "Invalid pointer to INIT_8E table\n"); | 2631 | NV_WARN(bios->dev, "Invalid pointer to INIT_8E table\n"); |
2625 | return false; | 2632 | return 0; |
2626 | } | 2633 | } |
2627 | 2634 | ||
2628 | gpio_entry = gpio_table + gpio_table[1]; | 2635 | gpio_entry = gpio_table + gpio_table[1]; |
@@ -2660,13 +2667,10 @@ init_gpio(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2660 | bios_wr32(bios, r, v); | 2667 | bios_wr32(bios, r, v); |
2661 | } | 2668 | } |
2662 | 2669 | ||
2663 | return true; | 2670 | return 1; |
2664 | } | 2671 | } |
2665 | 2672 | ||
2666 | /* hack to avoid moving the itbl_entry array before this function */ | 2673 | static int |
2667 | int init_ram_restrict_zm_reg_group_blocklen; | ||
2668 | |||
2669 | static bool | ||
2670 | init_ram_restrict_zm_reg_group(struct nvbios *bios, uint16_t offset, | 2674 | init_ram_restrict_zm_reg_group(struct nvbios *bios, uint16_t offset, |
2671 | struct init_exec *iexec) | 2675 | struct init_exec *iexec) |
2672 | { | 2676 | { |
@@ -2692,21 +2696,21 @@ init_ram_restrict_zm_reg_group(struct nvbios *bios, uint16_t offset, | |||
2692 | uint8_t regincrement = bios->data[offset + 5]; | 2696 | uint8_t regincrement = bios->data[offset + 5]; |
2693 | uint8_t count = bios->data[offset + 6]; | 2697 | uint8_t count = bios->data[offset + 6]; |
2694 | uint32_t strap_ramcfg, data; | 2698 | uint32_t strap_ramcfg, data; |
2695 | uint16_t blocklen; | 2699 | /* previously set by 'M' BIT table */ |
2700 | uint16_t blocklen = bios->ram_restrict_group_count * 4; | ||
2701 | int len = 7 + count * blocklen; | ||
2696 | uint8_t index; | 2702 | uint8_t index; |
2697 | int i; | 2703 | int i; |
2698 | 2704 | ||
2699 | /* previously set by 'M' BIT table */ | ||
2700 | blocklen = init_ram_restrict_zm_reg_group_blocklen; | ||
2701 | 2705 | ||
2702 | if (!iexec->execute) | 2706 | if (!iexec->execute) |
2703 | return true; | 2707 | return len; |
2704 | 2708 | ||
2705 | if (!blocklen) { | 2709 | if (!blocklen) { |
2706 | NV_ERROR(bios->dev, | 2710 | NV_ERROR(bios->dev, |
2707 | "0x%04X: Zero block length - has the M table " | 2711 | "0x%04X: Zero block length - has the M table " |
2708 | "been parsed?\n", offset); | 2712 | "been parsed?\n", offset); |
2709 | return false; | 2713 | return 0; |
2710 | } | 2714 | } |
2711 | 2715 | ||
2712 | strap_ramcfg = (bios_rd32(bios, NV_PEXTDEV_BOOT_0) >> 2) & 0xf; | 2716 | strap_ramcfg = (bios_rd32(bios, NV_PEXTDEV_BOOT_0) >> 2) & 0xf; |
@@ -2724,10 +2728,10 @@ init_ram_restrict_zm_reg_group(struct nvbios *bios, uint16_t offset, | |||
2724 | reg += regincrement; | 2728 | reg += regincrement; |
2725 | } | 2729 | } |
2726 | 2730 | ||
2727 | return true; | 2731 | return len; |
2728 | } | 2732 | } |
2729 | 2733 | ||
2730 | static bool | 2734 | static int |
2731 | init_copy_zm_reg(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 2735 | init_copy_zm_reg(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
2732 | { | 2736 | { |
2733 | /* | 2737 | /* |
@@ -2744,14 +2748,14 @@ init_copy_zm_reg(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2744 | uint32_t dstreg = ROM32(bios->data[offset + 5]); | 2748 | uint32_t dstreg = ROM32(bios->data[offset + 5]); |
2745 | 2749 | ||
2746 | if (!iexec->execute) | 2750 | if (!iexec->execute) |
2747 | return true; | 2751 | return 9; |
2748 | 2752 | ||
2749 | bios_wr32(bios, dstreg, bios_rd32(bios, srcreg)); | 2753 | bios_wr32(bios, dstreg, bios_rd32(bios, srcreg)); |
2750 | 2754 | ||
2751 | return true; | 2755 | return 9; |
2752 | } | 2756 | } |
2753 | 2757 | ||
2754 | static bool | 2758 | static int |
2755 | init_zm_reg_group_addr_latched(struct nvbios *bios, uint16_t offset, | 2759 | init_zm_reg_group_addr_latched(struct nvbios *bios, uint16_t offset, |
2756 | struct init_exec *iexec) | 2760 | struct init_exec *iexec) |
2757 | { | 2761 | { |
@@ -2769,20 +2773,21 @@ init_zm_reg_group_addr_latched(struct nvbios *bios, uint16_t offset, | |||
2769 | 2773 | ||
2770 | uint32_t reg = ROM32(bios->data[offset + 1]); | 2774 | uint32_t reg = ROM32(bios->data[offset + 1]); |
2771 | uint8_t count = bios->data[offset + 5]; | 2775 | uint8_t count = bios->data[offset + 5]; |
2776 | int len = 6 + count * 4; | ||
2772 | int i; | 2777 | int i; |
2773 | 2778 | ||
2774 | if (!iexec->execute) | 2779 | if (!iexec->execute) |
2775 | return true; | 2780 | return len; |
2776 | 2781 | ||
2777 | for (i = 0; i < count; i++) { | 2782 | for (i = 0; i < count; i++) { |
2778 | uint32_t data = ROM32(bios->data[offset + 6 + 4 * i]); | 2783 | uint32_t data = ROM32(bios->data[offset + 6 + 4 * i]); |
2779 | bios_wr32(bios, reg, data); | 2784 | bios_wr32(bios, reg, data); |
2780 | } | 2785 | } |
2781 | 2786 | ||
2782 | return true; | 2787 | return len; |
2783 | } | 2788 | } |
2784 | 2789 | ||
2785 | static bool | 2790 | static int |
2786 | init_reserved(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 2791 | init_reserved(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
2787 | { | 2792 | { |
2788 | /* | 2793 | /* |
@@ -2793,10 +2798,10 @@ init_reserved(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2793 | * Seemingly does nothing | 2798 | * Seemingly does nothing |
2794 | */ | 2799 | */ |
2795 | 2800 | ||
2796 | return true; | 2801 | return 1; |
2797 | } | 2802 | } |
2798 | 2803 | ||
2799 | static bool | 2804 | static int |
2800 | init_96(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 2805 | init_96(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
2801 | { | 2806 | { |
2802 | /* | 2807 | /* |
@@ -2829,13 +2834,13 @@ init_96(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2829 | val <<= bios->data[offset + 16]; | 2834 | val <<= bios->data[offset + 16]; |
2830 | 2835 | ||
2831 | if (!iexec->execute) | 2836 | if (!iexec->execute) |
2832 | return true; | 2837 | return 17; |
2833 | 2838 | ||
2834 | bios_wr32(bios, reg, (bios_rd32(bios, reg) & mask) | val); | 2839 | bios_wr32(bios, reg, (bios_rd32(bios, reg) & mask) | val); |
2835 | return true; | 2840 | return 17; |
2836 | } | 2841 | } |
2837 | 2842 | ||
2838 | static bool | 2843 | static int |
2839 | init_97(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 2844 | init_97(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
2840 | { | 2845 | { |
2841 | /* | 2846 | /* |
@@ -2859,13 +2864,13 @@ init_97(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2859 | val = (val & mask) | ((val + add) & ~mask); | 2864 | val = (val & mask) | ((val + add) & ~mask); |
2860 | 2865 | ||
2861 | if (!iexec->execute) | 2866 | if (!iexec->execute) |
2862 | return true; | 2867 | return 13; |
2863 | 2868 | ||
2864 | bios_wr32(bios, reg, val); | 2869 | bios_wr32(bios, reg, val); |
2865 | return true; | 2870 | return 13; |
2866 | } | 2871 | } |
2867 | 2872 | ||
2868 | static bool | 2873 | static int |
2869 | init_auxch(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 2874 | init_auxch(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
2870 | { | 2875 | { |
2871 | /* | 2876 | /* |
@@ -2883,32 +2888,33 @@ init_auxch(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2883 | struct drm_device *dev = bios->dev; | 2888 | struct drm_device *dev = bios->dev; |
2884 | struct nouveau_i2c_chan *auxch; | 2889 | struct nouveau_i2c_chan *auxch; |
2885 | uint32_t addr = ROM32(bios->data[offset + 1]); | 2890 | uint32_t addr = ROM32(bios->data[offset + 1]); |
2886 | uint8_t len = bios->data[offset + 5]; | 2891 | uint8_t count = bios->data[offset + 5]; |
2892 | int len = 6 + count * 2; | ||
2887 | int ret, i; | 2893 | int ret, i; |
2888 | 2894 | ||
2889 | if (!bios->display.output) { | 2895 | if (!bios->display.output) { |
2890 | NV_ERROR(dev, "INIT_AUXCH: no active output\n"); | 2896 | NV_ERROR(dev, "INIT_AUXCH: no active output\n"); |
2891 | return false; | 2897 | return 0; |
2892 | } | 2898 | } |
2893 | 2899 | ||
2894 | auxch = init_i2c_device_find(dev, bios->display.output->i2c_index); | 2900 | auxch = init_i2c_device_find(dev, bios->display.output->i2c_index); |
2895 | if (!auxch) { | 2901 | if (!auxch) { |
2896 | NV_ERROR(dev, "INIT_AUXCH: couldn't get auxch %d\n", | 2902 | NV_ERROR(dev, "INIT_AUXCH: couldn't get auxch %d\n", |
2897 | bios->display.output->i2c_index); | 2903 | bios->display.output->i2c_index); |
2898 | return false; | 2904 | return 0; |
2899 | } | 2905 | } |
2900 | 2906 | ||
2901 | if (!iexec->execute) | 2907 | if (!iexec->execute) |
2902 | return true; | 2908 | return len; |
2903 | 2909 | ||
2904 | offset += 6; | 2910 | offset += 6; |
2905 | for (i = 0; i < len; i++, offset += 2) { | 2911 | for (i = 0; i < count; i++, offset += 2) { |
2906 | uint8_t data; | 2912 | uint8_t data; |
2907 | 2913 | ||
2908 | ret = nouveau_dp_auxch(auxch, 9, addr, &data, 1); | 2914 | ret = nouveau_dp_auxch(auxch, 9, addr, &data, 1); |
2909 | if (ret) { | 2915 | if (ret) { |
2910 | NV_ERROR(dev, "INIT_AUXCH: rd auxch fail %d\n", ret); | 2916 | NV_ERROR(dev, "INIT_AUXCH: rd auxch fail %d\n", ret); |
2911 | return false; | 2917 | return 0; |
2912 | } | 2918 | } |
2913 | 2919 | ||
2914 | data &= bios->data[offset + 0]; | 2920 | data &= bios->data[offset + 0]; |
@@ -2917,14 +2923,14 @@ init_auxch(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2917 | ret = nouveau_dp_auxch(auxch, 8, addr, &data, 1); | 2923 | ret = nouveau_dp_auxch(auxch, 8, addr, &data, 1); |
2918 | if (ret) { | 2924 | if (ret) { |
2919 | NV_ERROR(dev, "INIT_AUXCH: wr auxch fail %d\n", ret); | 2925 | NV_ERROR(dev, "INIT_AUXCH: wr auxch fail %d\n", ret); |
2920 | return false; | 2926 | return 0; |
2921 | } | 2927 | } |
2922 | } | 2928 | } |
2923 | 2929 | ||
2924 | return true; | 2930 | return len; |
2925 | } | 2931 | } |
2926 | 2932 | ||
2927 | static bool | 2933 | static int |
2928 | init_zm_auxch(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 2934 | init_zm_auxch(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
2929 | { | 2935 | { |
2930 | /* | 2936 | /* |
@@ -2941,106 +2947,99 @@ init_zm_auxch(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
2941 | struct drm_device *dev = bios->dev; | 2947 | struct drm_device *dev = bios->dev; |
2942 | struct nouveau_i2c_chan *auxch; | 2948 | struct nouveau_i2c_chan *auxch; |
2943 | uint32_t addr = ROM32(bios->data[offset + 1]); | 2949 | uint32_t addr = ROM32(bios->data[offset + 1]); |
2944 | uint8_t len = bios->data[offset + 5]; | 2950 | uint8_t count = bios->data[offset + 5]; |
2951 | int len = 6 + count; | ||
2945 | int ret, i; | 2952 | int ret, i; |
2946 | 2953 | ||
2947 | if (!bios->display.output) { | 2954 | if (!bios->display.output) { |
2948 | NV_ERROR(dev, "INIT_ZM_AUXCH: no active output\n"); | 2955 | NV_ERROR(dev, "INIT_ZM_AUXCH: no active output\n"); |
2949 | return false; | 2956 | return 0; |
2950 | } | 2957 | } |
2951 | 2958 | ||
2952 | auxch = init_i2c_device_find(dev, bios->display.output->i2c_index); | 2959 | auxch = init_i2c_device_find(dev, bios->display.output->i2c_index); |
2953 | if (!auxch) { | 2960 | if (!auxch) { |
2954 | NV_ERROR(dev, "INIT_ZM_AUXCH: couldn't get auxch %d\n", | 2961 | NV_ERROR(dev, "INIT_ZM_AUXCH: couldn't get auxch %d\n", |
2955 | bios->display.output->i2c_index); | 2962 | bios->display.output->i2c_index); |
2956 | return false; | 2963 | return 0; |
2957 | } | 2964 | } |
2958 | 2965 | ||
2959 | if (!iexec->execute) | 2966 | if (!iexec->execute) |
2960 | return true; | 2967 | return len; |
2961 | 2968 | ||
2962 | offset += 6; | 2969 | offset += 6; |
2963 | for (i = 0; i < len; i++, offset++) { | 2970 | for (i = 0; i < count; i++, offset++) { |
2964 | ret = nouveau_dp_auxch(auxch, 8, addr, &bios->data[offset], 1); | 2971 | ret = nouveau_dp_auxch(auxch, 8, addr, &bios->data[offset], 1); |
2965 | if (ret) { | 2972 | if (ret) { |
2966 | NV_ERROR(dev, "INIT_ZM_AUXCH: wr auxch fail %d\n", ret); | 2973 | NV_ERROR(dev, "INIT_ZM_AUXCH: wr auxch fail %d\n", ret); |
2967 | return false; | 2974 | return 0; |
2968 | } | 2975 | } |
2969 | } | 2976 | } |
2970 | 2977 | ||
2971 | return true; | 2978 | return len; |
2972 | } | 2979 | } |
2973 | 2980 | ||
2974 | static struct init_tbl_entry itbl_entry[] = { | 2981 | static struct init_tbl_entry itbl_entry[] = { |
2975 | /* command name , id , length , offset , mult , command handler */ | 2982 | /* command name , id , length , offset , mult , command handler */ |
2976 | /* INIT_PROG (0x31, 15, 10, 4) removed due to no example of use */ | 2983 | /* INIT_PROG (0x31, 15, 10, 4) removed due to no example of use */ |
2977 | { "INIT_IO_RESTRICT_PROG" , 0x32, 11 , 6 , 4 , init_io_restrict_prog }, | 2984 | { "INIT_IO_RESTRICT_PROG" , 0x32, init_io_restrict_prog }, |
2978 | { "INIT_REPEAT" , 0x33, 2 , 0 , 0 , init_repeat }, | 2985 | { "INIT_REPEAT" , 0x33, init_repeat }, |
2979 | { "INIT_IO_RESTRICT_PLL" , 0x34, 12 , 7 , 2 , init_io_restrict_pll }, | 2986 | { "INIT_IO_RESTRICT_PLL" , 0x34, init_io_restrict_pll }, |
2980 | { "INIT_END_REPEAT" , 0x36, 1 , 0 , 0 , init_end_repeat }, | 2987 | { "INIT_END_REPEAT" , 0x36, init_end_repeat }, |
2981 | { "INIT_COPY" , 0x37, 11 , 0 , 0 , init_copy }, | 2988 | { "INIT_COPY" , 0x37, init_copy }, |
2982 | { "INIT_NOT" , 0x38, 1 , 0 , 0 , init_not }, | 2989 | { "INIT_NOT" , 0x38, init_not }, |
2983 | { "INIT_IO_FLAG_CONDITION" , 0x39, 2 , 0 , 0 , init_io_flag_condition }, | 2990 | { "INIT_IO_FLAG_CONDITION" , 0x39, init_io_flag_condition }, |
2984 | { "INIT_INDEX_ADDRESS_LATCHED" , 0x49, 18 , 17 , 2 , init_idx_addr_latched }, | 2991 | { "INIT_INDEX_ADDRESS_LATCHED" , 0x49, init_idx_addr_latched }, |
2985 | { "INIT_IO_RESTRICT_PLL2" , 0x4A, 11 , 6 , 4 , init_io_restrict_pll2 }, | 2992 | { "INIT_IO_RESTRICT_PLL2" , 0x4A, init_io_restrict_pll2 }, |
2986 | { "INIT_PLL2" , 0x4B, 9 , 0 , 0 , init_pll2 }, | 2993 | { "INIT_PLL2" , 0x4B, init_pll2 }, |
2987 | { "INIT_I2C_BYTE" , 0x4C, 4 , 3 , 3 , init_i2c_byte }, | 2994 | { "INIT_I2C_BYTE" , 0x4C, init_i2c_byte }, |
2988 | { "INIT_ZM_I2C_BYTE" , 0x4D, 4 , 3 , 2 , init_zm_i2c_byte }, | 2995 | { "INIT_ZM_I2C_BYTE" , 0x4D, init_zm_i2c_byte }, |
2989 | { "INIT_ZM_I2C" , 0x4E, 4 , 3 , 1 , init_zm_i2c }, | 2996 | { "INIT_ZM_I2C" , 0x4E, init_zm_i2c }, |
2990 | { "INIT_TMDS" , 0x4F, 5 , 0 , 0 , init_tmds }, | 2997 | { "INIT_TMDS" , 0x4F, init_tmds }, |
2991 | { "INIT_ZM_TMDS_GROUP" , 0x50, 3 , 2 , 2 , init_zm_tmds_group }, | 2998 | { "INIT_ZM_TMDS_GROUP" , 0x50, init_zm_tmds_group }, |
2992 | { "INIT_CR_INDEX_ADDRESS_LATCHED" , 0x51, 5 , 4 , 1 , init_cr_idx_adr_latch }, | 2999 | { "INIT_CR_INDEX_ADDRESS_LATCHED" , 0x51, init_cr_idx_adr_latch }, |
2993 | { "INIT_CR" , 0x52, 4 , 0 , 0 , init_cr }, | 3000 | { "INIT_CR" , 0x52, init_cr }, |
2994 | { "INIT_ZM_CR" , 0x53, 3 , 0 , 0 , init_zm_cr }, | 3001 | { "INIT_ZM_CR" , 0x53, init_zm_cr }, |
2995 | { "INIT_ZM_CR_GROUP" , 0x54, 2 , 1 , 2 , init_zm_cr_group }, | 3002 | { "INIT_ZM_CR_GROUP" , 0x54, init_zm_cr_group }, |
2996 | { "INIT_CONDITION_TIME" , 0x56, 3 , 0 , 0 , init_condition_time }, | 3003 | { "INIT_CONDITION_TIME" , 0x56, init_condition_time }, |
2997 | { "INIT_ZM_REG_SEQUENCE" , 0x58, 6 , 5 , 4 , init_zm_reg_sequence }, | 3004 | { "INIT_ZM_REG_SEQUENCE" , 0x58, init_zm_reg_sequence }, |
2998 | /* INIT_INDIRECT_REG (0x5A, 7, 0, 0) removed due to no example of use */ | 3005 | /* INIT_INDIRECT_REG (0x5A, 7, 0, 0) removed due to no example of use */ |
2999 | { "INIT_SUB_DIRECT" , 0x5B, 3 , 0 , 0 , init_sub_direct }, | 3006 | { "INIT_SUB_DIRECT" , 0x5B, init_sub_direct }, |
3000 | { "INIT_COPY_NV_REG" , 0x5F, 22 , 0 , 0 , init_copy_nv_reg }, | 3007 | { "INIT_COPY_NV_REG" , 0x5F, init_copy_nv_reg }, |
3001 | { "INIT_ZM_INDEX_IO" , 0x62, 5 , 0 , 0 , init_zm_index_io }, | 3008 | { "INIT_ZM_INDEX_IO" , 0x62, init_zm_index_io }, |
3002 | { "INIT_COMPUTE_MEM" , 0x63, 1 , 0 , 0 , init_compute_mem }, | 3009 | { "INIT_COMPUTE_MEM" , 0x63, init_compute_mem }, |
3003 | { "INIT_RESET" , 0x65, 13 , 0 , 0 , init_reset }, | 3010 | { "INIT_RESET" , 0x65, init_reset }, |
3004 | { "INIT_CONFIGURE_MEM" , 0x66, 1 , 0 , 0 , init_configure_mem }, | 3011 | { "INIT_CONFIGURE_MEM" , 0x66, init_configure_mem }, |
3005 | { "INIT_CONFIGURE_CLK" , 0x67, 1 , 0 , 0 , init_configure_clk }, | 3012 | { "INIT_CONFIGURE_CLK" , 0x67, init_configure_clk }, |
3006 | { "INIT_CONFIGURE_PREINIT" , 0x68, 1 , 0 , 0 , init_configure_preinit }, | 3013 | { "INIT_CONFIGURE_PREINIT" , 0x68, init_configure_preinit }, |
3007 | { "INIT_IO" , 0x69, 5 , 0 , 0 , init_io }, | 3014 | { "INIT_IO" , 0x69, init_io }, |
3008 | { "INIT_SUB" , 0x6B, 2 , 0 , 0 , init_sub }, | 3015 | { "INIT_SUB" , 0x6B, init_sub }, |
3009 | { "INIT_RAM_CONDITION" , 0x6D, 3 , 0 , 0 , init_ram_condition }, | 3016 | { "INIT_RAM_CONDITION" , 0x6D, init_ram_condition }, |
3010 | { "INIT_NV_REG" , 0x6E, 13 , 0 , 0 , init_nv_reg }, | 3017 | { "INIT_NV_REG" , 0x6E, init_nv_reg }, |
3011 | { "INIT_MACRO" , 0x6F, 2 , 0 , 0 , init_macro }, | 3018 | { "INIT_MACRO" , 0x6F, init_macro }, |
3012 | { "INIT_DONE" , 0x71, 1 , 0 , 0 , init_done }, | 3019 | { "INIT_DONE" , 0x71, init_done }, |
3013 | { "INIT_RESUME" , 0x72, 1 , 0 , 0 , init_resume }, | 3020 | { "INIT_RESUME" , 0x72, init_resume }, |
3014 | /* INIT_RAM_CONDITION2 (0x73, 9, 0, 0) removed due to no example of use */ | 3021 | /* INIT_RAM_CONDITION2 (0x73, 9, 0, 0) removed due to no example of use */ |
3015 | { "INIT_TIME" , 0x74, 3 , 0 , 0 , init_time }, | 3022 | { "INIT_TIME" , 0x74, init_time }, |
3016 | { "INIT_CONDITION" , 0x75, 2 , 0 , 0 , init_condition }, | 3023 | { "INIT_CONDITION" , 0x75, init_condition }, |
3017 | { "INIT_IO_CONDITION" , 0x76, 2 , 0 , 0 , init_io_condition }, | 3024 | { "INIT_IO_CONDITION" , 0x76, init_io_condition }, |
3018 | { "INIT_INDEX_IO" , 0x78, 6 , 0 , 0 , init_index_io }, | 3025 | { "INIT_INDEX_IO" , 0x78, init_index_io }, |
3019 | { "INIT_PLL" , 0x79, 7 , 0 , 0 , init_pll }, | 3026 | { "INIT_PLL" , 0x79, init_pll }, |
3020 | { "INIT_ZM_REG" , 0x7A, 9 , 0 , 0 , init_zm_reg }, | 3027 | { "INIT_ZM_REG" , 0x7A, init_zm_reg }, |
3021 | /* INIT_RAM_RESTRICT_PLL's length is adjusted by the BIT M table */ | 3028 | { "INIT_RAM_RESTRICT_PLL" , 0x87, init_ram_restrict_pll }, |
3022 | { "INIT_RAM_RESTRICT_PLL" , 0x87, 2 , 0 , 0 , init_ram_restrict_pll }, | 3029 | { "INIT_8C" , 0x8C, init_8c }, |
3023 | { "INIT_8C" , 0x8C, 1 , 0 , 0 , init_8c }, | 3030 | { "INIT_8D" , 0x8D, init_8d }, |
3024 | { "INIT_8D" , 0x8D, 1 , 0 , 0 , init_8d }, | 3031 | { "INIT_GPIO" , 0x8E, init_gpio }, |
3025 | { "INIT_GPIO" , 0x8E, 1 , 0 , 0 , init_gpio }, | 3032 | { "INIT_RAM_RESTRICT_ZM_REG_GROUP" , 0x8F, init_ram_restrict_zm_reg_group }, |
3026 | /* INIT_RAM_RESTRICT_ZM_REG_GROUP's mult is loaded by M table in BIT */ | 3033 | { "INIT_COPY_ZM_REG" , 0x90, init_copy_zm_reg }, |
3027 | { "INIT_RAM_RESTRICT_ZM_REG_GROUP" , 0x8F, 7 , 6 , 0 , init_ram_restrict_zm_reg_group }, | 3034 | { "INIT_ZM_REG_GROUP_ADDRESS_LATCHED" , 0x91, init_zm_reg_group_addr_latched }, |
3028 | { "INIT_COPY_ZM_REG" , 0x90, 9 , 0 , 0 , init_copy_zm_reg }, | 3035 | { "INIT_RESERVED" , 0x92, init_reserved }, |
3029 | { "INIT_ZM_REG_GROUP_ADDRESS_LATCHED" , 0x91, 6 , 5 , 4 , init_zm_reg_group_addr_latched }, | 3036 | { "INIT_96" , 0x96, init_96 }, |
3030 | { "INIT_RESERVED" , 0x92, 1 , 0 , 0 , init_reserved }, | 3037 | { "INIT_97" , 0x97, init_97 }, |
3031 | { "INIT_96" , 0x96, 17 , 0 , 0 , init_96 }, | 3038 | { "INIT_AUXCH" , 0x98, init_auxch }, |
3032 | { "INIT_97" , 0x97, 13 , 0 , 0 , init_97 }, | 3039 | { "INIT_ZM_AUXCH" , 0x99, init_zm_auxch }, |
3033 | { "INIT_AUXCH" , 0x98, 6 , 5 , 2 , init_auxch }, | 3040 | { NULL , 0 , NULL } |
3034 | { "INIT_ZM_AUXCH" , 0x99, 6 , 5 , 1 , init_zm_auxch }, | ||
3035 | { NULL , 0 , 0 , 0 , 0 , NULL } | ||
3036 | }; | 3041 | }; |
3037 | 3042 | ||
3038 | static unsigned int get_init_table_entry_length(struct nvbios *bios, unsigned int offset, int i) | ||
3039 | { | ||
3040 | /* Calculates the length of a given init table entry. */ | ||
3041 | return itbl_entry[i].length + bios->data[offset + itbl_entry[i].length_offset]*itbl_entry[i].length_multiplier; | ||
3042 | } | ||
3043 | |||
3044 | #define MAX_TABLE_OPS 1000 | 3043 | #define MAX_TABLE_OPS 1000 |
3045 | 3044 | ||
3046 | static int | 3045 | static int |
@@ -3056,7 +3055,7 @@ parse_init_table(struct nvbios *bios, unsigned int offset, | |||
3056 | * is changed back to EXECUTE. | 3055 | * is changed back to EXECUTE. |
3057 | */ | 3056 | */ |
3058 | 3057 | ||
3059 | int count = 0, i; | 3058 | int count = 0, i, res; |
3060 | uint8_t id; | 3059 | uint8_t id; |
3061 | 3060 | ||
3062 | /* | 3061 | /* |
@@ -3076,22 +3075,21 @@ parse_init_table(struct nvbios *bios, unsigned int offset, | |||
3076 | offset, itbl_entry[i].id, itbl_entry[i].name); | 3075 | offset, itbl_entry[i].id, itbl_entry[i].name); |
3077 | 3076 | ||
3078 | /* execute eventual command handler */ | 3077 | /* execute eventual command handler */ |
3079 | if (itbl_entry[i].handler) | 3078 | res = (*itbl_entry[i].handler)(bios, offset, iexec); |
3080 | if (!(*itbl_entry[i].handler)(bios, offset, iexec)) | 3079 | if (!res) |
3081 | break; | 3080 | break; |
3081 | /* | ||
3082 | * Add the offset of the current command including all data | ||
3083 | * of that command. The offset will then be pointing on the | ||
3084 | * next op code. | ||
3085 | */ | ||
3086 | offset += res; | ||
3082 | } else { | 3087 | } else { |
3083 | NV_ERROR(bios->dev, | 3088 | NV_ERROR(bios->dev, |
3084 | "0x%04X: Init table command not found: " | 3089 | "0x%04X: Init table command not found: " |
3085 | "0x%02X\n", offset, id); | 3090 | "0x%02X\n", offset, id); |
3086 | return -ENOENT; | 3091 | return -ENOENT; |
3087 | } | 3092 | } |
3088 | |||
3089 | /* | ||
3090 | * Add the offset of the current command including all data | ||
3091 | * of that command. The offset will then be pointing on the | ||
3092 | * next op code. | ||
3093 | */ | ||
3094 | offset += get_init_table_entry_length(bios, offset, i); | ||
3095 | } | 3093 | } |
3096 | 3094 | ||
3097 | if (offset >= bios->length) | 3095 | if (offset >= bios->length) |
@@ -3854,7 +3852,7 @@ nouveau_bios_run_display_table(struct drm_device *dev, struct dcb_entry *dcbent, | |||
3854 | * script tables is a pointer to the script to execute. | 3852 | * script tables is a pointer to the script to execute. |
3855 | */ | 3853 | */ |
3856 | 3854 | ||
3857 | NV_DEBUG(dev, "Searching for output entry for %d %d %d\n", | 3855 | NV_DEBUG_KMS(dev, "Searching for output entry for %d %d %d\n", |
3858 | dcbent->type, dcbent->location, dcbent->or); | 3856 | dcbent->type, dcbent->location, dcbent->or); |
3859 | otable = bios_output_config_match(dev, dcbent, table[1] + | 3857 | otable = bios_output_config_match(dev, dcbent, table[1] + |
3860 | bios->display.script_table_ptr, | 3858 | bios->display.script_table_ptr, |
@@ -3884,7 +3882,7 @@ nouveau_bios_run_display_table(struct drm_device *dev, struct dcb_entry *dcbent, | |||
3884 | if (pxclk == 0) { | 3882 | if (pxclk == 0) { |
3885 | script = ROM16(otable[6]); | 3883 | script = ROM16(otable[6]); |
3886 | if (!script) { | 3884 | if (!script) { |
3887 | NV_DEBUG(dev, "output script 0 not found\n"); | 3885 | NV_DEBUG_KMS(dev, "output script 0 not found\n"); |
3888 | return 1; | 3886 | return 1; |
3889 | } | 3887 | } |
3890 | 3888 | ||
@@ -3894,7 +3892,7 @@ nouveau_bios_run_display_table(struct drm_device *dev, struct dcb_entry *dcbent, | |||
3894 | if (pxclk == -1) { | 3892 | if (pxclk == -1) { |
3895 | script = ROM16(otable[8]); | 3893 | script = ROM16(otable[8]); |
3896 | if (!script) { | 3894 | if (!script) { |
3897 | NV_DEBUG(dev, "output script 1 not found\n"); | 3895 | NV_DEBUG_KMS(dev, "output script 1 not found\n"); |
3898 | return 1; | 3896 | return 1; |
3899 | } | 3897 | } |
3900 | 3898 | ||
@@ -3907,7 +3905,7 @@ nouveau_bios_run_display_table(struct drm_device *dev, struct dcb_entry *dcbent, | |||
3907 | else | 3905 | else |
3908 | script = 0; | 3906 | script = 0; |
3909 | if (!script) { | 3907 | if (!script) { |
3910 | NV_DEBUG(dev, "output script 2 not found\n"); | 3908 | NV_DEBUG_KMS(dev, "output script 2 not found\n"); |
3911 | return 1; | 3909 | return 1; |
3912 | } | 3910 | } |
3913 | 3911 | ||
@@ -3931,7 +3929,7 @@ nouveau_bios_run_display_table(struct drm_device *dev, struct dcb_entry *dcbent, | |||
3931 | if (script) | 3929 | if (script) |
3932 | script = clkcmptable(bios, script, -pxclk); | 3930 | script = clkcmptable(bios, script, -pxclk); |
3933 | if (!script) { | 3931 | if (!script) { |
3934 | NV_DEBUG(dev, "clock script 1 not found\n"); | 3932 | NV_DEBUG_KMS(dev, "clock script 1 not found\n"); |
3935 | return 1; | 3933 | return 1; |
3936 | } | 3934 | } |
3937 | 3935 | ||
@@ -4606,10 +4604,6 @@ parse_bit_M_tbl_entry(struct drm_device *dev, struct nvbios *bios, | |||
4606 | * stuff that we don't use - their use currently unknown | 4604 | * stuff that we don't use - their use currently unknown |
4607 | */ | 4605 | */ |
4608 | 4606 | ||
4609 | uint16_t rr_strap_xlat; | ||
4610 | uint8_t rr_group_count; | ||
4611 | int i; | ||
4612 | |||
4613 | /* | 4607 | /* |
4614 | * Older bios versions don't have a sufficiently long table for | 4608 | * Older bios versions don't have a sufficiently long table for |
4615 | * what we want | 4609 | * what we want |
@@ -4618,24 +4612,13 @@ parse_bit_M_tbl_entry(struct drm_device *dev, struct nvbios *bios, | |||
4618 | return 0; | 4612 | return 0; |
4619 | 4613 | ||
4620 | if (bitentry->id[1] < 2) { | 4614 | if (bitentry->id[1] < 2) { |
4621 | rr_group_count = bios->data[bitentry->offset + 2]; | 4615 | bios->ram_restrict_group_count = bios->data[bitentry->offset + 2]; |
4622 | rr_strap_xlat = ROM16(bios->data[bitentry->offset + 3]); | 4616 | bios->ram_restrict_tbl_ptr = ROM16(bios->data[bitentry->offset + 3]); |
4623 | } else { | 4617 | } else { |
4624 | rr_group_count = bios->data[bitentry->offset + 0]; | 4618 | bios->ram_restrict_group_count = bios->data[bitentry->offset + 0]; |
4625 | rr_strap_xlat = ROM16(bios->data[bitentry->offset + 1]); | 4619 | bios->ram_restrict_tbl_ptr = ROM16(bios->data[bitentry->offset + 1]); |
4626 | } | 4620 | } |
4627 | 4621 | ||
4628 | /* adjust length of INIT_87 */ | ||
4629 | for (i = 0; itbl_entry[i].name && (itbl_entry[i].id != 0x87); i++); | ||
4630 | itbl_entry[i].length += rr_group_count * 4; | ||
4631 | |||
4632 | /* set up multiplier for INIT_RAM_RESTRICT_ZM_REG_GROUP */ | ||
4633 | for (; itbl_entry[i].name && (itbl_entry[i].id != 0x8f); i++); | ||
4634 | itbl_entry[i].length_multiplier = rr_group_count * 4; | ||
4635 | |||
4636 | init_ram_restrict_zm_reg_group_blocklen = itbl_entry[i].length_multiplier; | ||
4637 | bios->ram_restrict_tbl_ptr = rr_strap_xlat; | ||
4638 | |||
4639 | return 0; | 4622 | return 0; |
4640 | } | 4623 | } |
4641 | 4624 | ||
@@ -5234,7 +5217,7 @@ parse_dcb_connector_table(struct nvbios *bios) | |||
5234 | int i; | 5217 | int i; |
5235 | 5218 | ||
5236 | if (!bios->bdcb.connector_table_ptr) { | 5219 | if (!bios->bdcb.connector_table_ptr) { |
5237 | NV_DEBUG(dev, "No DCB connector table present\n"); | 5220 | NV_DEBUG_KMS(dev, "No DCB connector table present\n"); |
5238 | return; | 5221 | return; |
5239 | } | 5222 | } |
5240 | 5223 | ||
diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.h b/drivers/gpu/drm/nouveau/nouveau_bios.h index 1d5f10bd78ed..058e98c76d89 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bios.h +++ b/drivers/gpu/drm/nouveau/nouveau_bios.h | |||
@@ -227,6 +227,7 @@ struct nvbios { | |||
227 | 227 | ||
228 | uint16_t pll_limit_tbl_ptr; | 228 | uint16_t pll_limit_tbl_ptr; |
229 | uint16_t ram_restrict_tbl_ptr; | 229 | uint16_t ram_restrict_tbl_ptr; |
230 | uint8_t ram_restrict_group_count; | ||
230 | 231 | ||
231 | uint16_t some_script_ptr; /* BIT I + 14 */ | 232 | uint16_t some_script_ptr; /* BIT I + 14 */ |
232 | uint16_t init96_tbl_ptr; /* BIT I + 16 */ | 233 | uint16_t init96_tbl_ptr; /* BIT I + 16 */ |
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index aa2dfbc3e351..0cad6d834eb2 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c | |||
@@ -154,6 +154,11 @@ nouveau_bo_placement_set(struct nouveau_bo *nvbo, uint32_t memtype) | |||
154 | nvbo->placement.busy_placement = nvbo->placements; | 154 | nvbo->placement.busy_placement = nvbo->placements; |
155 | nvbo->placement.num_placement = n; | 155 | nvbo->placement.num_placement = n; |
156 | nvbo->placement.num_busy_placement = n; | 156 | nvbo->placement.num_busy_placement = n; |
157 | |||
158 | if (nvbo->pin_refcnt) { | ||
159 | while (n--) | ||
160 | nvbo->placements[n] |= TTM_PL_FLAG_NO_EVICT; | ||
161 | } | ||
157 | } | 162 | } |
158 | 163 | ||
159 | int | 164 | int |
@@ -400,10 +405,16 @@ nouveau_bo_evict_flags(struct ttm_buffer_object *bo, struct ttm_placement *pl) | |||
400 | struct nouveau_bo *nvbo = nouveau_bo(bo); | 405 | struct nouveau_bo *nvbo = nouveau_bo(bo); |
401 | 406 | ||
402 | switch (bo->mem.mem_type) { | 407 | switch (bo->mem.mem_type) { |
408 | case TTM_PL_VRAM: | ||
409 | nouveau_bo_placement_set(nvbo, TTM_PL_FLAG_TT | | ||
410 | TTM_PL_FLAG_SYSTEM); | ||
411 | break; | ||
403 | default: | 412 | default: |
404 | nouveau_bo_placement_set(nvbo, TTM_PL_FLAG_SYSTEM); | 413 | nouveau_bo_placement_set(nvbo, TTM_PL_FLAG_SYSTEM); |
405 | break; | 414 | break; |
406 | } | 415 | } |
416 | |||
417 | *pl = nvbo->placement; | ||
407 | } | 418 | } |
408 | 419 | ||
409 | 420 | ||
@@ -455,11 +466,8 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, int no_wait, | |||
455 | int ret; | 466 | int ret; |
456 | 467 | ||
457 | chan = nvbo->channel; | 468 | chan = nvbo->channel; |
458 | if (!chan || nvbo->tile_flags || nvbo->no_vm) { | 469 | if (!chan || nvbo->tile_flags || nvbo->no_vm) |
459 | chan = dev_priv->channel; | 470 | chan = dev_priv->channel; |
460 | if (!chan) | ||
461 | return -EINVAL; | ||
462 | } | ||
463 | 471 | ||
464 | src_offset = old_mem->mm_node->start << PAGE_SHIFT; | 472 | src_offset = old_mem->mm_node->start << PAGE_SHIFT; |
465 | dst_offset = new_mem->mm_node->start << PAGE_SHIFT; | 473 | dst_offset = new_mem->mm_node->start << PAGE_SHIFT; |
@@ -625,7 +633,8 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, bool intr, | |||
625 | return ret; | 633 | return ret; |
626 | } | 634 | } |
627 | 635 | ||
628 | if (dev_priv->init_state != NOUVEAU_CARD_INIT_DONE) | 636 | if (dev_priv->init_state != NOUVEAU_CARD_INIT_DONE || |
637 | !dev_priv->channel) | ||
629 | return ttm_bo_move_memcpy(bo, evict, no_wait, new_mem); | 638 | return ttm_bo_move_memcpy(bo, evict, no_wait, new_mem); |
630 | 639 | ||
631 | if (old_mem->mem_type == TTM_PL_SYSTEM && !bo->ttm) { | 640 | if (old_mem->mem_type == TTM_PL_SYSTEM && !bo->ttm) { |
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c index 032cf098fa1c..5a10deb8bdbd 100644 --- a/drivers/gpu/drm/nouveau/nouveau_connector.c +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c | |||
@@ -86,7 +86,7 @@ nouveau_connector_destroy(struct drm_connector *drm_connector) | |||
86 | struct nouveau_connector *connector = nouveau_connector(drm_connector); | 86 | struct nouveau_connector *connector = nouveau_connector(drm_connector); |
87 | struct drm_device *dev = connector->base.dev; | 87 | struct drm_device *dev = connector->base.dev; |
88 | 88 | ||
89 | NV_DEBUG(dev, "\n"); | 89 | NV_DEBUG_KMS(dev, "\n"); |
90 | 90 | ||
91 | if (!connector) | 91 | if (!connector) |
92 | return; | 92 | return; |
@@ -420,7 +420,7 @@ nouveau_connector_native_mode(struct nouveau_connector *connector) | |||
420 | /* Use preferred mode if there is one.. */ | 420 | /* Use preferred mode if there is one.. */ |
421 | list_for_each_entry(mode, &connector->base.probed_modes, head) { | 421 | list_for_each_entry(mode, &connector->base.probed_modes, head) { |
422 | if (mode->type & DRM_MODE_TYPE_PREFERRED) { | 422 | if (mode->type & DRM_MODE_TYPE_PREFERRED) { |
423 | NV_DEBUG(dev, "native mode from preferred\n"); | 423 | NV_DEBUG_KMS(dev, "native mode from preferred\n"); |
424 | return drm_mode_duplicate(dev, mode); | 424 | return drm_mode_duplicate(dev, mode); |
425 | } | 425 | } |
426 | } | 426 | } |
@@ -445,7 +445,7 @@ nouveau_connector_native_mode(struct nouveau_connector *connector) | |||
445 | largest = mode; | 445 | largest = mode; |
446 | } | 446 | } |
447 | 447 | ||
448 | NV_DEBUG(dev, "native mode from largest: %dx%d@%d\n", | 448 | NV_DEBUG_KMS(dev, "native mode from largest: %dx%d@%d\n", |
449 | high_w, high_h, high_v); | 449 | high_w, high_h, high_v); |
450 | return largest ? drm_mode_duplicate(dev, largest) : NULL; | 450 | return largest ? drm_mode_duplicate(dev, largest) : NULL; |
451 | } | 451 | } |
@@ -725,7 +725,7 @@ nouveau_connector_create(struct drm_device *dev, int index, int type) | |||
725 | struct drm_encoder *encoder; | 725 | struct drm_encoder *encoder; |
726 | int ret; | 726 | int ret; |
727 | 727 | ||
728 | NV_DEBUG(dev, "\n"); | 728 | NV_DEBUG_KMS(dev, "\n"); |
729 | 729 | ||
730 | nv_connector = kzalloc(sizeof(*nv_connector), GFP_KERNEL); | 730 | nv_connector = kzalloc(sizeof(*nv_connector), GFP_KERNEL); |
731 | if (!nv_connector) | 731 | if (!nv_connector) |
diff --git a/drivers/gpu/drm/nouveau/nouveau_dp.c b/drivers/gpu/drm/nouveau/nouveau_dp.c index de61f4640e12..9e2926c48579 100644 --- a/drivers/gpu/drm/nouveau/nouveau_dp.c +++ b/drivers/gpu/drm/nouveau/nouveau_dp.c | |||
@@ -187,7 +187,7 @@ nouveau_dp_link_train_adjust(struct drm_encoder *encoder, uint8_t *config) | |||
187 | if (ret) | 187 | if (ret) |
188 | return false; | 188 | return false; |
189 | 189 | ||
190 | NV_DEBUG(dev, "\t\tadjust 0x%02x 0x%02x\n", request[0], request[1]); | 190 | NV_DEBUG_KMS(dev, "\t\tadjust 0x%02x 0x%02x\n", request[0], request[1]); |
191 | 191 | ||
192 | /* Keep all lanes at the same level.. */ | 192 | /* Keep all lanes at the same level.. */ |
193 | for (i = 0; i < nv_encoder->dp.link_nr; i++) { | 193 | for (i = 0; i < nv_encoder->dp.link_nr; i++) { |
@@ -228,7 +228,7 @@ nouveau_dp_link_train_commit(struct drm_encoder *encoder, uint8_t *config) | |||
228 | int or = nv_encoder->or, link = !(nv_encoder->dcb->sorconf.link & 1); | 228 | int or = nv_encoder->or, link = !(nv_encoder->dcb->sorconf.link & 1); |
229 | int dpe_headerlen, ret, i; | 229 | int dpe_headerlen, ret, i; |
230 | 230 | ||
231 | NV_DEBUG(dev, "\t\tconfig 0x%02x 0x%02x 0x%02x 0x%02x\n", | 231 | NV_DEBUG_KMS(dev, "\t\tconfig 0x%02x 0x%02x 0x%02x 0x%02x\n", |
232 | config[0], config[1], config[2], config[3]); | 232 | config[0], config[1], config[2], config[3]); |
233 | 233 | ||
234 | dpe = nouveau_bios_dp_table(dev, nv_encoder->dcb, &dpe_headerlen); | 234 | dpe = nouveau_bios_dp_table(dev, nv_encoder->dcb, &dpe_headerlen); |
@@ -276,12 +276,12 @@ nouveau_dp_link_train(struct drm_encoder *encoder) | |||
276 | bool cr_done, cr_max_vs, eq_done; | 276 | bool cr_done, cr_max_vs, eq_done; |
277 | int ret = 0, i, tries, voltage; | 277 | int ret = 0, i, tries, voltage; |
278 | 278 | ||
279 | NV_DEBUG(dev, "link training!!\n"); | 279 | NV_DEBUG_KMS(dev, "link training!!\n"); |
280 | train: | 280 | train: |
281 | cr_done = eq_done = false; | 281 | cr_done = eq_done = false; |
282 | 282 | ||
283 | /* set link configuration */ | 283 | /* set link configuration */ |
284 | NV_DEBUG(dev, "\tbegin train: bw %d, lanes %d\n", | 284 | NV_DEBUG_KMS(dev, "\tbegin train: bw %d, lanes %d\n", |
285 | nv_encoder->dp.link_bw, nv_encoder->dp.link_nr); | 285 | nv_encoder->dp.link_bw, nv_encoder->dp.link_nr); |
286 | 286 | ||
287 | ret = nouveau_dp_link_bw_set(encoder, nv_encoder->dp.link_bw); | 287 | ret = nouveau_dp_link_bw_set(encoder, nv_encoder->dp.link_bw); |
@@ -297,7 +297,7 @@ train: | |||
297 | return false; | 297 | return false; |
298 | 298 | ||
299 | /* clock recovery */ | 299 | /* clock recovery */ |
300 | NV_DEBUG(dev, "\tbegin cr\n"); | 300 | NV_DEBUG_KMS(dev, "\tbegin cr\n"); |
301 | ret = nouveau_dp_link_train_set(encoder, DP_TRAINING_PATTERN_1); | 301 | ret = nouveau_dp_link_train_set(encoder, DP_TRAINING_PATTERN_1); |
302 | if (ret) | 302 | if (ret) |
303 | goto stop; | 303 | goto stop; |
@@ -314,7 +314,7 @@ train: | |||
314 | ret = auxch_rd(encoder, DP_LANE0_1_STATUS, status, 2); | 314 | ret = auxch_rd(encoder, DP_LANE0_1_STATUS, status, 2); |
315 | if (ret) | 315 | if (ret) |
316 | break; | 316 | break; |
317 | NV_DEBUG(dev, "\t\tstatus: 0x%02x 0x%02x\n", | 317 | NV_DEBUG_KMS(dev, "\t\tstatus: 0x%02x 0x%02x\n", |
318 | status[0], status[1]); | 318 | status[0], status[1]); |
319 | 319 | ||
320 | cr_done = true; | 320 | cr_done = true; |
@@ -346,7 +346,7 @@ train: | |||
346 | goto stop; | 346 | goto stop; |
347 | 347 | ||
348 | /* channel equalisation */ | 348 | /* channel equalisation */ |
349 | NV_DEBUG(dev, "\tbegin eq\n"); | 349 | NV_DEBUG_KMS(dev, "\tbegin eq\n"); |
350 | ret = nouveau_dp_link_train_set(encoder, DP_TRAINING_PATTERN_2); | 350 | ret = nouveau_dp_link_train_set(encoder, DP_TRAINING_PATTERN_2); |
351 | if (ret) | 351 | if (ret) |
352 | goto stop; | 352 | goto stop; |
@@ -357,7 +357,7 @@ train: | |||
357 | ret = auxch_rd(encoder, DP_LANE0_1_STATUS, status, 3); | 357 | ret = auxch_rd(encoder, DP_LANE0_1_STATUS, status, 3); |
358 | if (ret) | 358 | if (ret) |
359 | break; | 359 | break; |
360 | NV_DEBUG(dev, "\t\tstatus: 0x%02x 0x%02x\n", | 360 | NV_DEBUG_KMS(dev, "\t\tstatus: 0x%02x 0x%02x\n", |
361 | status[0], status[1]); | 361 | status[0], status[1]); |
362 | 362 | ||
363 | eq_done = true; | 363 | eq_done = true; |
@@ -395,9 +395,9 @@ stop: | |||
395 | 395 | ||
396 | /* retry at a lower setting, if possible */ | 396 | /* retry at a lower setting, if possible */ |
397 | if (!ret && !(eq_done && cr_done)) { | 397 | if (!ret && !(eq_done && cr_done)) { |
398 | NV_DEBUG(dev, "\twe failed\n"); | 398 | NV_DEBUG_KMS(dev, "\twe failed\n"); |
399 | if (nv_encoder->dp.link_bw != DP_LINK_BW_1_62) { | 399 | if (nv_encoder->dp.link_bw != DP_LINK_BW_1_62) { |
400 | NV_DEBUG(dev, "retry link training at low rate\n"); | 400 | NV_DEBUG_KMS(dev, "retry link training at low rate\n"); |
401 | nv_encoder->dp.link_bw = DP_LINK_BW_1_62; | 401 | nv_encoder->dp.link_bw = DP_LINK_BW_1_62; |
402 | goto train; | 402 | goto train; |
403 | } | 403 | } |
@@ -418,7 +418,7 @@ nouveau_dp_detect(struct drm_encoder *encoder) | |||
418 | if (ret) | 418 | if (ret) |
419 | return false; | 419 | return false; |
420 | 420 | ||
421 | NV_DEBUG(dev, "encoder: link_bw %d, link_nr %d\n" | 421 | NV_DEBUG_KMS(dev, "encoder: link_bw %d, link_nr %d\n" |
422 | "display: link_bw %d, link_nr %d version 0x%02x\n", | 422 | "display: link_bw %d, link_nr %d version 0x%02x\n", |
423 | nv_encoder->dcb->dpconf.link_bw, | 423 | nv_encoder->dcb->dpconf.link_bw, |
424 | nv_encoder->dcb->dpconf.link_nr, | 424 | nv_encoder->dcb->dpconf.link_nr, |
@@ -446,7 +446,7 @@ nouveau_dp_auxch(struct nouveau_i2c_chan *auxch, int cmd, int addr, | |||
446 | uint32_t tmp, ctrl, stat = 0, data32[4] = {}; | 446 | uint32_t tmp, ctrl, stat = 0, data32[4] = {}; |
447 | int ret = 0, i, index = auxch->rd; | 447 | int ret = 0, i, index = auxch->rd; |
448 | 448 | ||
449 | NV_DEBUG(dev, "ch %d cmd %d addr 0x%x len %d\n", index, cmd, addr, data_nr); | 449 | NV_DEBUG_KMS(dev, "ch %d cmd %d addr 0x%x len %d\n", index, cmd, addr, data_nr); |
450 | 450 | ||
451 | tmp = nv_rd32(dev, NV50_AUXCH_CTRL(auxch->rd)); | 451 | tmp = nv_rd32(dev, NV50_AUXCH_CTRL(auxch->rd)); |
452 | nv_wr32(dev, NV50_AUXCH_CTRL(auxch->rd), tmp | 0x00100000); | 452 | nv_wr32(dev, NV50_AUXCH_CTRL(auxch->rd), tmp | 0x00100000); |
@@ -472,7 +472,7 @@ nouveau_dp_auxch(struct nouveau_i2c_chan *auxch, int cmd, int addr, | |||
472 | if (!(cmd & 1)) { | 472 | if (!(cmd & 1)) { |
473 | memcpy(data32, data, data_nr); | 473 | memcpy(data32, data, data_nr); |
474 | for (i = 0; i < 4; i++) { | 474 | for (i = 0; i < 4; i++) { |
475 | NV_DEBUG(dev, "wr %d: 0x%08x\n", i, data32[i]); | 475 | NV_DEBUG_KMS(dev, "wr %d: 0x%08x\n", i, data32[i]); |
476 | nv_wr32(dev, NV50_AUXCH_DATA_OUT(index, i), data32[i]); | 476 | nv_wr32(dev, NV50_AUXCH_DATA_OUT(index, i), data32[i]); |
477 | } | 477 | } |
478 | } | 478 | } |
@@ -504,7 +504,7 @@ nouveau_dp_auxch(struct nouveau_i2c_chan *auxch, int cmd, int addr, | |||
504 | if (cmd & 1) { | 504 | if (cmd & 1) { |
505 | for (i = 0; i < 4; i++) { | 505 | for (i = 0; i < 4; i++) { |
506 | data32[i] = nv_rd32(dev, NV50_AUXCH_DATA_IN(index, i)); | 506 | data32[i] = nv_rd32(dev, NV50_AUXCH_DATA_IN(index, i)); |
507 | NV_DEBUG(dev, "rd %d: 0x%08x\n", i, data32[i]); | 507 | NV_DEBUG_KMS(dev, "rd %d: 0x%08x\n", i, data32[i]); |
508 | } | 508 | } |
509 | memcpy(data, data32, data_nr); | 509 | memcpy(data, data32, data_nr); |
510 | } | 510 | } |
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.c b/drivers/gpu/drm/nouveau/nouveau_drv.c index 3f943c01e995..06eb993e0883 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.c +++ b/drivers/gpu/drm/nouveau/nouveau_drv.c | |||
@@ -35,6 +35,10 @@ | |||
35 | 35 | ||
36 | #include "drm_pciids.h" | 36 | #include "drm_pciids.h" |
37 | 37 | ||
38 | MODULE_PARM_DESC(ctxfw, "Use external firmware blob for grctx init (NV40)"); | ||
39 | int nouveau_ctxfw = 0; | ||
40 | module_param_named(ctxfw, nouveau_ctxfw, int, 0400); | ||
41 | |||
38 | MODULE_PARM_DESC(noagp, "Disable AGP"); | 42 | MODULE_PARM_DESC(noagp, "Disable AGP"); |
39 | int nouveau_noagp; | 43 | int nouveau_noagp; |
40 | module_param_named(noagp, nouveau_noagp, int, 0400); | 44 | module_param_named(noagp, nouveau_noagp, int, 0400); |
@@ -273,7 +277,7 @@ nouveau_pci_resume(struct pci_dev *pdev) | |||
273 | 277 | ||
274 | for (i = 0; i < dev_priv->engine.fifo.channels; i++) { | 278 | for (i = 0; i < dev_priv->engine.fifo.channels; i++) { |
275 | chan = dev_priv->fifos[i]; | 279 | chan = dev_priv->fifos[i]; |
276 | if (!chan) | 280 | if (!chan || !chan->pushbuf_bo) |
277 | continue; | 281 | continue; |
278 | 282 | ||
279 | for (j = 0; j < NOUVEAU_DMA_SKIPS; j++) | 283 | for (j = 0; j < NOUVEAU_DMA_SKIPS; j++) |
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h index 88b4c7b77e7f..5f8cbb79c499 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h | |||
@@ -54,6 +54,7 @@ struct nouveau_fpriv { | |||
54 | #include "nouveau_drm.h" | 54 | #include "nouveau_drm.h" |
55 | #include "nouveau_reg.h" | 55 | #include "nouveau_reg.h" |
56 | #include "nouveau_bios.h" | 56 | #include "nouveau_bios.h" |
57 | struct nouveau_grctx; | ||
57 | 58 | ||
58 | #define MAX_NUM_DCB_ENTRIES 16 | 59 | #define MAX_NUM_DCB_ENTRIES 16 |
59 | 60 | ||
@@ -317,6 +318,7 @@ struct nouveau_pgraph_engine { | |||
317 | bool accel_blocked; | 318 | bool accel_blocked; |
318 | void *ctxprog; | 319 | void *ctxprog; |
319 | void *ctxvals; | 320 | void *ctxvals; |
321 | int grctx_size; | ||
320 | 322 | ||
321 | int (*init)(struct drm_device *); | 323 | int (*init)(struct drm_device *); |
322 | void (*takedown)(struct drm_device *); | 324 | void (*takedown)(struct drm_device *); |
@@ -647,6 +649,7 @@ extern int nouveau_fbpercrtc; | |||
647 | extern char *nouveau_tv_norm; | 649 | extern char *nouveau_tv_norm; |
648 | extern int nouveau_reg_debug; | 650 | extern int nouveau_reg_debug; |
649 | extern char *nouveau_vbios; | 651 | extern char *nouveau_vbios; |
652 | extern int nouveau_ctxfw; | ||
650 | 653 | ||
651 | /* nouveau_state.c */ | 654 | /* nouveau_state.c */ |
652 | extern void nouveau_preclose(struct drm_device *dev, struct drm_file *); | 655 | extern void nouveau_preclose(struct drm_device *dev, struct drm_file *); |
@@ -959,9 +962,7 @@ extern int nv40_graph_create_context(struct nouveau_channel *); | |||
959 | extern void nv40_graph_destroy_context(struct nouveau_channel *); | 962 | extern void nv40_graph_destroy_context(struct nouveau_channel *); |
960 | extern int nv40_graph_load_context(struct nouveau_channel *); | 963 | extern int nv40_graph_load_context(struct nouveau_channel *); |
961 | extern int nv40_graph_unload_context(struct drm_device *); | 964 | extern int nv40_graph_unload_context(struct drm_device *); |
962 | extern int nv40_grctx_init(struct drm_device *); | 965 | extern void nv40_grctx_init(struct nouveau_grctx *); |
963 | extern void nv40_grctx_fini(struct drm_device *); | ||
964 | extern void nv40_grctx_vals_load(struct drm_device *, struct nouveau_gpuobj *); | ||
965 | 966 | ||
966 | /* nv50_graph.c */ | 967 | /* nv50_graph.c */ |
967 | extern struct nouveau_pgraph_object_class nv50_graph_grclass[]; | 968 | extern struct nouveau_pgraph_object_class nv50_graph_grclass[]; |
@@ -975,6 +976,12 @@ extern int nv50_graph_load_context(struct nouveau_channel *); | |||
975 | extern int nv50_graph_unload_context(struct drm_device *); | 976 | extern int nv50_graph_unload_context(struct drm_device *); |
976 | extern void nv50_graph_context_switch(struct drm_device *); | 977 | extern void nv50_graph_context_switch(struct drm_device *); |
977 | 978 | ||
979 | /* nouveau_grctx.c */ | ||
980 | extern int nouveau_grctx_prog_load(struct drm_device *); | ||
981 | extern void nouveau_grctx_vals_load(struct drm_device *, | ||
982 | struct nouveau_gpuobj *); | ||
983 | extern void nouveau_grctx_fini(struct drm_device *); | ||
984 | |||
978 | /* nv04_instmem.c */ | 985 | /* nv04_instmem.c */ |
979 | extern int nv04_instmem_init(struct drm_device *); | 986 | extern int nv04_instmem_init(struct drm_device *); |
980 | extern void nv04_instmem_takedown(struct drm_device *); | 987 | extern void nv04_instmem_takedown(struct drm_device *); |
@@ -1207,14 +1214,24 @@ static inline void nv_wo32(struct drm_device *dev, struct nouveau_gpuobj *obj, | |||
1207 | pci_name(d->pdev), ##arg) | 1214 | pci_name(d->pdev), ##arg) |
1208 | #ifndef NV_DEBUG_NOTRACE | 1215 | #ifndef NV_DEBUG_NOTRACE |
1209 | #define NV_DEBUG(d, fmt, arg...) do { \ | 1216 | #define NV_DEBUG(d, fmt, arg...) do { \ |
1210 | if (drm_debug) { \ | 1217 | if (drm_debug & DRM_UT_DRIVER) { \ |
1218 | NV_PRINTK(KERN_DEBUG, d, "%s:%d - " fmt, __func__, \ | ||
1219 | __LINE__, ##arg); \ | ||
1220 | } \ | ||
1221 | } while (0) | ||
1222 | #define NV_DEBUG_KMS(d, fmt, arg...) do { \ | ||
1223 | if (drm_debug & DRM_UT_KMS) { \ | ||
1211 | NV_PRINTK(KERN_DEBUG, d, "%s:%d - " fmt, __func__, \ | 1224 | NV_PRINTK(KERN_DEBUG, d, "%s:%d - " fmt, __func__, \ |
1212 | __LINE__, ##arg); \ | 1225 | __LINE__, ##arg); \ |
1213 | } \ | 1226 | } \ |
1214 | } while (0) | 1227 | } while (0) |
1215 | #else | 1228 | #else |
1216 | #define NV_DEBUG(d, fmt, arg...) do { \ | 1229 | #define NV_DEBUG(d, fmt, arg...) do { \ |
1217 | if (drm_debug) \ | 1230 | if (drm_debug & DRM_UT_DRIVER) \ |
1231 | NV_PRINTK(KERN_DEBUG, d, fmt, ##arg); \ | ||
1232 | } while (0) | ||
1233 | #define NV_DEBUG_KMS(d, fmt, arg...) do { \ | ||
1234 | if (drm_debug & DRM_UT_KMS) \ | ||
1218 | NV_PRINTK(KERN_DEBUG, d, fmt, ##arg); \ | 1235 | NV_PRINTK(KERN_DEBUG, d, fmt, ##arg); \ |
1219 | } while (0) | 1236 | } while (0) |
1220 | #endif | 1237 | #endif |
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c index 36e8c5e4503a..84af25c238b6 100644 --- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c +++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c | |||
@@ -58,7 +58,7 @@ nouveau_fbcon_sync(struct fb_info *info) | |||
58 | struct nouveau_channel *chan = dev_priv->channel; | 58 | struct nouveau_channel *chan = dev_priv->channel; |
59 | int ret, i; | 59 | int ret, i; |
60 | 60 | ||
61 | if (!chan->accel_done || | 61 | if (!chan || !chan->accel_done || |
62 | info->state != FBINFO_STATE_RUNNING || | 62 | info->state != FBINFO_STATE_RUNNING || |
63 | info->flags & FBINFO_HWACCEL_DISABLED) | 63 | info->flags & FBINFO_HWACCEL_DISABLED) |
64 | return 0; | 64 | return 0; |
@@ -318,14 +318,16 @@ nouveau_fbcon_create(struct drm_device *dev, uint32_t fb_width, | |||
318 | par->nouveau_fb = nouveau_fb; | 318 | par->nouveau_fb = nouveau_fb; |
319 | par->dev = dev; | 319 | par->dev = dev; |
320 | 320 | ||
321 | switch (dev_priv->card_type) { | 321 | if (dev_priv->channel) { |
322 | case NV_50: | 322 | switch (dev_priv->card_type) { |
323 | nv50_fbcon_accel_init(info); | 323 | case NV_50: |
324 | break; | 324 | nv50_fbcon_accel_init(info); |
325 | default: | 325 | break; |
326 | nv04_fbcon_accel_init(info); | 326 | default: |
327 | break; | 327 | nv04_fbcon_accel_init(info); |
328 | }; | 328 | break; |
329 | }; | ||
330 | } | ||
329 | 331 | ||
330 | nouveau_fbcon_zfill(dev); | 332 | nouveau_fbcon_zfill(dev); |
331 | 333 | ||
@@ -347,7 +349,7 @@ out: | |||
347 | int | 349 | int |
348 | nouveau_fbcon_probe(struct drm_device *dev) | 350 | nouveau_fbcon_probe(struct drm_device *dev) |
349 | { | 351 | { |
350 | NV_DEBUG(dev, "\n"); | 352 | NV_DEBUG_KMS(dev, "\n"); |
351 | 353 | ||
352 | return drm_fb_helper_single_fb_probe(dev, 32, nouveau_fbcon_create); | 354 | return drm_fb_helper_single_fb_probe(dev, 32, nouveau_fbcon_create); |
353 | } | 355 | } |
diff --git a/drivers/gpu/drm/nouveau/nouveau_grctx.c b/drivers/gpu/drm/nouveau/nouveau_grctx.c new file mode 100644 index 000000000000..419f4c2b3b89 --- /dev/null +++ b/drivers/gpu/drm/nouveau/nouveau_grctx.c | |||
@@ -0,0 +1,161 @@ | |||
1 | /* | ||
2 | * Copyright 2009 Red Hat Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | * Authors: Ben Skeggs | ||
23 | */ | ||
24 | |||
25 | #include <linux/firmware.h> | ||
26 | |||
27 | #include "drmP.h" | ||
28 | #include "nouveau_drv.h" | ||
29 | |||
30 | struct nouveau_ctxprog { | ||
31 | uint32_t signature; | ||
32 | uint8_t version; | ||
33 | uint16_t length; | ||
34 | uint32_t data[]; | ||
35 | } __attribute__ ((packed)); | ||
36 | |||
37 | struct nouveau_ctxvals { | ||
38 | uint32_t signature; | ||
39 | uint8_t version; | ||
40 | uint32_t length; | ||
41 | struct { | ||
42 | uint32_t offset; | ||
43 | uint32_t value; | ||
44 | } data[]; | ||
45 | } __attribute__ ((packed)); | ||
46 | |||
47 | int | ||
48 | nouveau_grctx_prog_load(struct drm_device *dev) | ||
49 | { | ||
50 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
51 | struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph; | ||
52 | const int chipset = dev_priv->chipset; | ||
53 | const struct firmware *fw; | ||
54 | const struct nouveau_ctxprog *cp; | ||
55 | const struct nouveau_ctxvals *cv; | ||
56 | char name[32]; | ||
57 | int ret, i; | ||
58 | |||
59 | if (pgraph->accel_blocked) | ||
60 | return -ENODEV; | ||
61 | |||
62 | if (!pgraph->ctxprog) { | ||
63 | sprintf(name, "nouveau/nv%02x.ctxprog", chipset); | ||
64 | ret = request_firmware(&fw, name, &dev->pdev->dev); | ||
65 | if (ret) { | ||
66 | NV_ERROR(dev, "No ctxprog for NV%02x\n", chipset); | ||
67 | return ret; | ||
68 | } | ||
69 | |||
70 | pgraph->ctxprog = kmalloc(fw->size, GFP_KERNEL); | ||
71 | if (!pgraph->ctxprog) { | ||
72 | NV_ERROR(dev, "OOM copying ctxprog\n"); | ||
73 | release_firmware(fw); | ||
74 | return -ENOMEM; | ||
75 | } | ||
76 | memcpy(pgraph->ctxprog, fw->data, fw->size); | ||
77 | |||
78 | cp = pgraph->ctxprog; | ||
79 | if (le32_to_cpu(cp->signature) != 0x5043564e || | ||
80 | cp->version != 0 || | ||
81 | le16_to_cpu(cp->length) != ((fw->size - 7) / 4)) { | ||
82 | NV_ERROR(dev, "ctxprog invalid\n"); | ||
83 | release_firmware(fw); | ||
84 | nouveau_grctx_fini(dev); | ||
85 | return -EINVAL; | ||
86 | } | ||
87 | release_firmware(fw); | ||
88 | } | ||
89 | |||
90 | if (!pgraph->ctxvals) { | ||
91 | sprintf(name, "nouveau/nv%02x.ctxvals", chipset); | ||
92 | ret = request_firmware(&fw, name, &dev->pdev->dev); | ||
93 | if (ret) { | ||
94 | NV_ERROR(dev, "No ctxvals for NV%02x\n", chipset); | ||
95 | nouveau_grctx_fini(dev); | ||
96 | return ret; | ||
97 | } | ||
98 | |||
99 | pgraph->ctxvals = kmalloc(fw->size, GFP_KERNEL); | ||
100 | if (!pgraph->ctxprog) { | ||
101 | NV_ERROR(dev, "OOM copying ctxprog\n"); | ||
102 | release_firmware(fw); | ||
103 | nouveau_grctx_fini(dev); | ||
104 | return -ENOMEM; | ||
105 | } | ||
106 | memcpy(pgraph->ctxvals, fw->data, fw->size); | ||
107 | |||
108 | cv = (void *)pgraph->ctxvals; | ||
109 | if (le32_to_cpu(cv->signature) != 0x5643564e || | ||
110 | cv->version != 0 || | ||
111 | le32_to_cpu(cv->length) != ((fw->size - 9) / 8)) { | ||
112 | NV_ERROR(dev, "ctxvals invalid\n"); | ||
113 | release_firmware(fw); | ||
114 | nouveau_grctx_fini(dev); | ||
115 | return -EINVAL; | ||
116 | } | ||
117 | release_firmware(fw); | ||
118 | } | ||
119 | |||
120 | cp = pgraph->ctxprog; | ||
121 | |||
122 | nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_INDEX, 0); | ||
123 | for (i = 0; i < le16_to_cpu(cp->length); i++) | ||
124 | nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_DATA, | ||
125 | le32_to_cpu(cp->data[i])); | ||
126 | |||
127 | return 0; | ||
128 | } | ||
129 | |||
130 | void | ||
131 | nouveau_grctx_fini(struct drm_device *dev) | ||
132 | { | ||
133 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
134 | struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph; | ||
135 | |||
136 | if (pgraph->ctxprog) { | ||
137 | kfree(pgraph->ctxprog); | ||
138 | pgraph->ctxprog = NULL; | ||
139 | } | ||
140 | |||
141 | if (pgraph->ctxvals) { | ||
142 | kfree(pgraph->ctxprog); | ||
143 | pgraph->ctxvals = NULL; | ||
144 | } | ||
145 | } | ||
146 | |||
147 | void | ||
148 | nouveau_grctx_vals_load(struct drm_device *dev, struct nouveau_gpuobj *ctx) | ||
149 | { | ||
150 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
151 | struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph; | ||
152 | struct nouveau_ctxvals *cv = pgraph->ctxvals; | ||
153 | int i; | ||
154 | |||
155 | if (!cv) | ||
156 | return; | ||
157 | |||
158 | for (i = 0; i < le32_to_cpu(cv->length); i++) | ||
159 | nv_wo32(dev, ctx, le32_to_cpu(cv->data[i].offset), | ||
160 | le32_to_cpu(cv->data[i].value)); | ||
161 | } | ||
diff --git a/drivers/gpu/drm/nouveau/nouveau_grctx.h b/drivers/gpu/drm/nouveau/nouveau_grctx.h new file mode 100644 index 000000000000..5d39c4ce8006 --- /dev/null +++ b/drivers/gpu/drm/nouveau/nouveau_grctx.h | |||
@@ -0,0 +1,133 @@ | |||
1 | #ifndef __NOUVEAU_GRCTX_H__ | ||
2 | #define __NOUVEAU_GRCTX_H__ | ||
3 | |||
4 | struct nouveau_grctx { | ||
5 | struct drm_device *dev; | ||
6 | |||
7 | enum { | ||
8 | NOUVEAU_GRCTX_PROG, | ||
9 | NOUVEAU_GRCTX_VALS | ||
10 | } mode; | ||
11 | void *data; | ||
12 | |||
13 | uint32_t ctxprog_max; | ||
14 | uint32_t ctxprog_len; | ||
15 | uint32_t ctxprog_reg; | ||
16 | int ctxprog_label[32]; | ||
17 | uint32_t ctxvals_pos; | ||
18 | uint32_t ctxvals_base; | ||
19 | }; | ||
20 | |||
21 | #ifdef CP_CTX | ||
22 | static inline void | ||
23 | cp_out(struct nouveau_grctx *ctx, uint32_t inst) | ||
24 | { | ||
25 | uint32_t *ctxprog = ctx->data; | ||
26 | |||
27 | if (ctx->mode != NOUVEAU_GRCTX_PROG) | ||
28 | return; | ||
29 | |||
30 | BUG_ON(ctx->ctxprog_len == ctx->ctxprog_max); | ||
31 | ctxprog[ctx->ctxprog_len++] = inst; | ||
32 | } | ||
33 | |||
34 | static inline void | ||
35 | cp_lsr(struct nouveau_grctx *ctx, uint32_t val) | ||
36 | { | ||
37 | cp_out(ctx, CP_LOAD_SR | val); | ||
38 | } | ||
39 | |||
40 | static inline void | ||
41 | cp_ctx(struct nouveau_grctx *ctx, uint32_t reg, uint32_t length) | ||
42 | { | ||
43 | ctx->ctxprog_reg = (reg - 0x00400000) >> 2; | ||
44 | |||
45 | ctx->ctxvals_base = ctx->ctxvals_pos; | ||
46 | ctx->ctxvals_pos = ctx->ctxvals_base + length; | ||
47 | |||
48 | if (length > (CP_CTX_COUNT >> CP_CTX_COUNT_SHIFT)) { | ||
49 | cp_lsr(ctx, length); | ||
50 | length = 0; | ||
51 | } | ||
52 | |||
53 | cp_out(ctx, CP_CTX | (length << CP_CTX_COUNT_SHIFT) | ctx->ctxprog_reg); | ||
54 | } | ||
55 | |||
56 | static inline void | ||
57 | cp_name(struct nouveau_grctx *ctx, int name) | ||
58 | { | ||
59 | uint32_t *ctxprog = ctx->data; | ||
60 | int i; | ||
61 | |||
62 | if (ctx->mode != NOUVEAU_GRCTX_PROG) | ||
63 | return; | ||
64 | |||
65 | ctx->ctxprog_label[name] = ctx->ctxprog_len; | ||
66 | for (i = 0; i < ctx->ctxprog_len; i++) { | ||
67 | if ((ctxprog[i] & 0xfff00000) != 0xff400000) | ||
68 | continue; | ||
69 | if ((ctxprog[i] & CP_BRA_IP) != ((name) << CP_BRA_IP_SHIFT)) | ||
70 | continue; | ||
71 | ctxprog[i] = (ctxprog[i] & 0x00ff00ff) | | ||
72 | (ctx->ctxprog_len << CP_BRA_IP_SHIFT); | ||
73 | } | ||
74 | } | ||
75 | |||
76 | static inline void | ||
77 | _cp_bra(struct nouveau_grctx *ctx, u32 mod, int flag, int state, int name) | ||
78 | { | ||
79 | int ip = 0; | ||
80 | |||
81 | if (mod != 2) { | ||
82 | ip = ctx->ctxprog_label[name] << CP_BRA_IP_SHIFT; | ||
83 | if (ip == 0) | ||
84 | ip = 0xff000000 | (name << CP_BRA_IP_SHIFT); | ||
85 | } | ||
86 | |||
87 | cp_out(ctx, CP_BRA | (mod << 18) | ip | flag | | ||
88 | (state ? 0 : CP_BRA_IF_CLEAR)); | ||
89 | } | ||
90 | #define cp_bra(c,f,s,n) _cp_bra((c), 0, CP_FLAG_##f, CP_FLAG_##f##_##s, n) | ||
91 | #ifdef CP_BRA_MOD | ||
92 | #define cp_cal(c,f,s,n) _cp_bra((c), 1, CP_FLAG_##f, CP_FLAG_##f##_##s, n) | ||
93 | #define cp_ret(c,f,s) _cp_bra((c), 2, CP_FLAG_##f, CP_FLAG_##f##_##s, 0) | ||
94 | #endif | ||
95 | |||
96 | static inline void | ||
97 | _cp_wait(struct nouveau_grctx *ctx, int flag, int state) | ||
98 | { | ||
99 | cp_out(ctx, CP_WAIT | flag | (state ? CP_WAIT_SET : 0)); | ||
100 | } | ||
101 | #define cp_wait(c,f,s) _cp_wait((c), CP_FLAG_##f, CP_FLAG_##f##_##s) | ||
102 | |||
103 | static inline void | ||
104 | _cp_set(struct nouveau_grctx *ctx, int flag, int state) | ||
105 | { | ||
106 | cp_out(ctx, CP_SET | flag | (state ? CP_SET_1 : 0)); | ||
107 | } | ||
108 | #define cp_set(c,f,s) _cp_set((c), CP_FLAG_##f, CP_FLAG_##f##_##s) | ||
109 | |||
110 | static inline void | ||
111 | cp_pos(struct nouveau_grctx *ctx, int offset) | ||
112 | { | ||
113 | ctx->ctxvals_pos = offset; | ||
114 | ctx->ctxvals_base = ctx->ctxvals_pos; | ||
115 | |||
116 | cp_lsr(ctx, ctx->ctxvals_pos); | ||
117 | cp_out(ctx, CP_SET_CONTEXT_POINTER); | ||
118 | } | ||
119 | |||
120 | static inline void | ||
121 | gr_def(struct nouveau_grctx *ctx, uint32_t reg, uint32_t val) | ||
122 | { | ||
123 | if (ctx->mode != NOUVEAU_GRCTX_VALS) | ||
124 | return; | ||
125 | |||
126 | reg = (reg - 0x00400000) / 4; | ||
127 | reg = (reg - ctx->ctxprog_reg) + ctx->ctxvals_base; | ||
128 | |||
129 | nv_wo32(ctx->dev, ctx->data, reg, val); | ||
130 | } | ||
131 | #endif | ||
132 | |||
133 | #endif | ||
diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c index 2ed41d339f6a..e76ec2d207a9 100644 --- a/drivers/gpu/drm/nouveau/nouveau_state.c +++ b/drivers/gpu/drm/nouveau/nouveau_state.c | |||
@@ -299,12 +299,57 @@ nouveau_vga_set_decode(void *priv, bool state) | |||
299 | return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM; | 299 | return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM; |
300 | } | 300 | } |
301 | 301 | ||
302 | static int | ||
303 | nouveau_card_init_channel(struct drm_device *dev) | ||
304 | { | ||
305 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
306 | struct nouveau_gpuobj *gpuobj; | ||
307 | int ret; | ||
308 | |||
309 | ret = nouveau_channel_alloc(dev, &dev_priv->channel, | ||
310 | (struct drm_file *)-2, | ||
311 | NvDmaFB, NvDmaTT); | ||
312 | if (ret) | ||
313 | return ret; | ||
314 | |||
315 | gpuobj = NULL; | ||
316 | ret = nouveau_gpuobj_dma_new(dev_priv->channel, NV_CLASS_DMA_IN_MEMORY, | ||
317 | 0, nouveau_mem_fb_amount(dev), | ||
318 | NV_DMA_ACCESS_RW, NV_DMA_TARGET_VIDMEM, | ||
319 | &gpuobj); | ||
320 | if (ret) | ||
321 | goto out_err; | ||
322 | |||
323 | ret = nouveau_gpuobj_ref_add(dev, dev_priv->channel, NvDmaVRAM, | ||
324 | gpuobj, NULL); | ||
325 | if (ret) | ||
326 | goto out_err; | ||
327 | |||
328 | gpuobj = NULL; | ||
329 | ret = nouveau_gpuobj_gart_dma_new(dev_priv->channel, 0, | ||
330 | dev_priv->gart_info.aper_size, | ||
331 | NV_DMA_ACCESS_RW, &gpuobj, NULL); | ||
332 | if (ret) | ||
333 | goto out_err; | ||
334 | |||
335 | ret = nouveau_gpuobj_ref_add(dev, dev_priv->channel, NvDmaGART, | ||
336 | gpuobj, NULL); | ||
337 | if (ret) | ||
338 | goto out_err; | ||
339 | |||
340 | return 0; | ||
341 | out_err: | ||
342 | nouveau_gpuobj_del(dev, &gpuobj); | ||
343 | nouveau_channel_free(dev_priv->channel); | ||
344 | dev_priv->channel = NULL; | ||
345 | return ret; | ||
346 | } | ||
347 | |||
302 | int | 348 | int |
303 | nouveau_card_init(struct drm_device *dev) | 349 | nouveau_card_init(struct drm_device *dev) |
304 | { | 350 | { |
305 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 351 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
306 | struct nouveau_engine *engine; | 352 | struct nouveau_engine *engine; |
307 | struct nouveau_gpuobj *gpuobj; | ||
308 | int ret; | 353 | int ret; |
309 | 354 | ||
310 | NV_DEBUG(dev, "prev state = %d\n", dev_priv->init_state); | 355 | NV_DEBUG(dev, "prev state = %d\n", dev_priv->init_state); |
@@ -317,7 +362,7 @@ nouveau_card_init(struct drm_device *dev) | |||
317 | /* Initialise internal driver API hooks */ | 362 | /* Initialise internal driver API hooks */ |
318 | ret = nouveau_init_engine_ptrs(dev); | 363 | ret = nouveau_init_engine_ptrs(dev); |
319 | if (ret) | 364 | if (ret) |
320 | return ret; | 365 | goto out; |
321 | engine = &dev_priv->engine; | 366 | engine = &dev_priv->engine; |
322 | dev_priv->init_state = NOUVEAU_CARD_INIT_FAILED; | 367 | dev_priv->init_state = NOUVEAU_CARD_INIT_FAILED; |
323 | 368 | ||
@@ -325,12 +370,12 @@ nouveau_card_init(struct drm_device *dev) | |||
325 | if (drm_core_check_feature(dev, DRIVER_MODESET)) { | 370 | if (drm_core_check_feature(dev, DRIVER_MODESET)) { |
326 | ret = nouveau_bios_init(dev); | 371 | ret = nouveau_bios_init(dev); |
327 | if (ret) | 372 | if (ret) |
328 | return ret; | 373 | goto out; |
329 | } | 374 | } |
330 | 375 | ||
331 | ret = nouveau_gpuobj_early_init(dev); | 376 | ret = nouveau_gpuobj_early_init(dev); |
332 | if (ret) | 377 | if (ret) |
333 | return ret; | 378 | goto out_bios; |
334 | 379 | ||
335 | /* Initialise instance memory, must happen before mem_init so we | 380 | /* Initialise instance memory, must happen before mem_init so we |
336 | * know exactly how much VRAM we're able to use for "normal" | 381 | * know exactly how much VRAM we're able to use for "normal" |
@@ -338,100 +383,68 @@ nouveau_card_init(struct drm_device *dev) | |||
338 | */ | 383 | */ |
339 | ret = engine->instmem.init(dev); | 384 | ret = engine->instmem.init(dev); |
340 | if (ret) | 385 | if (ret) |
341 | return ret; | 386 | goto out_gpuobj_early; |
342 | 387 | ||
343 | /* Setup the memory manager */ | 388 | /* Setup the memory manager */ |
344 | ret = nouveau_mem_init(dev); | 389 | ret = nouveau_mem_init(dev); |
345 | if (ret) | 390 | if (ret) |
346 | return ret; | 391 | goto out_instmem; |
347 | 392 | ||
348 | ret = nouveau_gpuobj_init(dev); | 393 | ret = nouveau_gpuobj_init(dev); |
349 | if (ret) | 394 | if (ret) |
350 | return ret; | 395 | goto out_mem; |
351 | 396 | ||
352 | /* PMC */ | 397 | /* PMC */ |
353 | ret = engine->mc.init(dev); | 398 | ret = engine->mc.init(dev); |
354 | if (ret) | 399 | if (ret) |
355 | return ret; | 400 | goto out_gpuobj; |
356 | 401 | ||
357 | /* PTIMER */ | 402 | /* PTIMER */ |
358 | ret = engine->timer.init(dev); | 403 | ret = engine->timer.init(dev); |
359 | if (ret) | 404 | if (ret) |
360 | return ret; | 405 | goto out_mc; |
361 | 406 | ||
362 | /* PFB */ | 407 | /* PFB */ |
363 | ret = engine->fb.init(dev); | 408 | ret = engine->fb.init(dev); |
364 | if (ret) | 409 | if (ret) |
365 | return ret; | 410 | goto out_timer; |
366 | 411 | ||
367 | /* PGRAPH */ | 412 | /* PGRAPH */ |
368 | ret = engine->graph.init(dev); | 413 | ret = engine->graph.init(dev); |
369 | if (ret) | 414 | if (ret) |
370 | return ret; | 415 | goto out_fb; |
371 | 416 | ||
372 | /* PFIFO */ | 417 | /* PFIFO */ |
373 | ret = engine->fifo.init(dev); | 418 | ret = engine->fifo.init(dev); |
374 | if (ret) | 419 | if (ret) |
375 | return ret; | 420 | goto out_graph; |
376 | 421 | ||
377 | /* this call irq_preinstall, register irq handler and | 422 | /* this call irq_preinstall, register irq handler and |
378 | * call irq_postinstall | 423 | * call irq_postinstall |
379 | */ | 424 | */ |
380 | ret = drm_irq_install(dev); | 425 | ret = drm_irq_install(dev); |
381 | if (ret) | 426 | if (ret) |
382 | return ret; | 427 | goto out_fifo; |
383 | 428 | ||
384 | ret = drm_vblank_init(dev, 0); | 429 | ret = drm_vblank_init(dev, 0); |
385 | if (ret) | 430 | if (ret) |
386 | return ret; | 431 | goto out_irq; |
387 | 432 | ||
388 | /* what about PVIDEO/PCRTC/PRAMDAC etc? */ | 433 | /* what about PVIDEO/PCRTC/PRAMDAC etc? */ |
389 | 434 | ||
390 | ret = nouveau_channel_alloc(dev, &dev_priv->channel, | 435 | if (!engine->graph.accel_blocked) { |
391 | (struct drm_file *)-2, | 436 | ret = nouveau_card_init_channel(dev); |
392 | NvDmaFB, NvDmaTT); | 437 | if (ret) |
393 | if (ret) | 438 | goto out_irq; |
394 | return ret; | ||
395 | |||
396 | gpuobj = NULL; | ||
397 | ret = nouveau_gpuobj_dma_new(dev_priv->channel, NV_CLASS_DMA_IN_MEMORY, | ||
398 | 0, nouveau_mem_fb_amount(dev), | ||
399 | NV_DMA_ACCESS_RW, NV_DMA_TARGET_VIDMEM, | ||
400 | &gpuobj); | ||
401 | if (ret) | ||
402 | return ret; | ||
403 | |||
404 | ret = nouveau_gpuobj_ref_add(dev, dev_priv->channel, NvDmaVRAM, | ||
405 | gpuobj, NULL); | ||
406 | if (ret) { | ||
407 | nouveau_gpuobj_del(dev, &gpuobj); | ||
408 | return ret; | ||
409 | } | ||
410 | |||
411 | gpuobj = NULL; | ||
412 | ret = nouveau_gpuobj_gart_dma_new(dev_priv->channel, 0, | ||
413 | dev_priv->gart_info.aper_size, | ||
414 | NV_DMA_ACCESS_RW, &gpuobj, NULL); | ||
415 | if (ret) | ||
416 | return ret; | ||
417 | |||
418 | ret = nouveau_gpuobj_ref_add(dev, dev_priv->channel, NvDmaGART, | ||
419 | gpuobj, NULL); | ||
420 | if (ret) { | ||
421 | nouveau_gpuobj_del(dev, &gpuobj); | ||
422 | return ret; | ||
423 | } | 439 | } |
424 | 440 | ||
425 | if (drm_core_check_feature(dev, DRIVER_MODESET)) { | 441 | if (drm_core_check_feature(dev, DRIVER_MODESET)) { |
426 | if (dev_priv->card_type >= NV_50) { | 442 | if (dev_priv->card_type >= NV_50) |
427 | ret = nv50_display_create(dev); | 443 | ret = nv50_display_create(dev); |
428 | if (ret) | 444 | else |
429 | return ret; | ||
430 | } else { | ||
431 | ret = nv04_display_create(dev); | 445 | ret = nv04_display_create(dev); |
432 | if (ret) | 446 | if (ret) |
433 | return ret; | 447 | goto out_irq; |
434 | } | ||
435 | } | 448 | } |
436 | 449 | ||
437 | ret = nouveau_backlight_init(dev); | 450 | ret = nouveau_backlight_init(dev); |
@@ -444,6 +457,32 @@ nouveau_card_init(struct drm_device *dev) | |||
444 | drm_helper_initial_config(dev); | 457 | drm_helper_initial_config(dev); |
445 | 458 | ||
446 | return 0; | 459 | return 0; |
460 | |||
461 | out_irq: | ||
462 | drm_irq_uninstall(dev); | ||
463 | out_fifo: | ||
464 | engine->fifo.takedown(dev); | ||
465 | out_graph: | ||
466 | engine->graph.takedown(dev); | ||
467 | out_fb: | ||
468 | engine->fb.takedown(dev); | ||
469 | out_timer: | ||
470 | engine->timer.takedown(dev); | ||
471 | out_mc: | ||
472 | engine->mc.takedown(dev); | ||
473 | out_gpuobj: | ||
474 | nouveau_gpuobj_takedown(dev); | ||
475 | out_mem: | ||
476 | nouveau_mem_close(dev); | ||
477 | out_instmem: | ||
478 | engine->instmem.takedown(dev); | ||
479 | out_gpuobj_early: | ||
480 | nouveau_gpuobj_late_takedown(dev); | ||
481 | out_bios: | ||
482 | nouveau_bios_takedown(dev); | ||
483 | out: | ||
484 | vga_client_register(dev->pdev, NULL, NULL, NULL); | ||
485 | return ret; | ||
447 | } | 486 | } |
448 | 487 | ||
449 | static void nouveau_card_takedown(struct drm_device *dev) | 488 | static void nouveau_card_takedown(struct drm_device *dev) |
diff --git a/drivers/gpu/drm/nouveau/nv04_crtc.c b/drivers/gpu/drm/nouveau/nv04_crtc.c index b91363606055..d2f143ed97c1 100644 --- a/drivers/gpu/drm/nouveau/nv04_crtc.c +++ b/drivers/gpu/drm/nouveau/nv04_crtc.c | |||
@@ -143,10 +143,10 @@ static void nv_crtc_calc_state_ext(struct drm_crtc *crtc, struct drm_display_mod | |||
143 | state->pllsel |= nv_crtc->index ? PLLSEL_VPLL2_MASK : PLLSEL_VPLL1_MASK; | 143 | state->pllsel |= nv_crtc->index ? PLLSEL_VPLL2_MASK : PLLSEL_VPLL1_MASK; |
144 | 144 | ||
145 | if (pv->NM2) | 145 | if (pv->NM2) |
146 | NV_TRACE(dev, "vpll: n1 %d n2 %d m1 %d m2 %d log2p %d\n", | 146 | NV_DEBUG_KMS(dev, "vpll: n1 %d n2 %d m1 %d m2 %d log2p %d\n", |
147 | pv->N1, pv->N2, pv->M1, pv->M2, pv->log2P); | 147 | pv->N1, pv->N2, pv->M1, pv->M2, pv->log2P); |
148 | else | 148 | else |
149 | NV_TRACE(dev, "vpll: n %d m %d log2p %d\n", | 149 | NV_DEBUG_KMS(dev, "vpll: n %d m %d log2p %d\n", |
150 | pv->N1, pv->M1, pv->log2P); | 150 | pv->N1, pv->M1, pv->log2P); |
151 | 151 | ||
152 | nv_crtc->cursor.set_offset(nv_crtc, nv_crtc->cursor.offset); | 152 | nv_crtc->cursor.set_offset(nv_crtc, nv_crtc->cursor.offset); |
@@ -160,7 +160,7 @@ nv_crtc_dpms(struct drm_crtc *crtc, int mode) | |||
160 | unsigned char seq1 = 0, crtc17 = 0; | 160 | unsigned char seq1 = 0, crtc17 = 0; |
161 | unsigned char crtc1A; | 161 | unsigned char crtc1A; |
162 | 162 | ||
163 | NV_TRACE(dev, "Setting dpms mode %d on CRTC %d\n", mode, | 163 | NV_DEBUG_KMS(dev, "Setting dpms mode %d on CRTC %d\n", mode, |
164 | nv_crtc->index); | 164 | nv_crtc->index); |
165 | 165 | ||
166 | if (nv_crtc->last_dpms == mode) /* Don't do unnecesary mode changes. */ | 166 | if (nv_crtc->last_dpms == mode) /* Don't do unnecesary mode changes. */ |
@@ -603,7 +603,7 @@ nv_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode, | |||
603 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 603 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
604 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 604 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
605 | 605 | ||
606 | NV_DEBUG(dev, "CTRC mode on CRTC %d:\n", nv_crtc->index); | 606 | NV_DEBUG_KMS(dev, "CTRC mode on CRTC %d:\n", nv_crtc->index); |
607 | drm_mode_debug_printmodeline(adjusted_mode); | 607 | drm_mode_debug_printmodeline(adjusted_mode); |
608 | 608 | ||
609 | /* unlock must come after turning off FP_TG_CONTROL in output_prepare */ | 609 | /* unlock must come after turning off FP_TG_CONTROL in output_prepare */ |
@@ -703,7 +703,7 @@ static void nv_crtc_destroy(struct drm_crtc *crtc) | |||
703 | { | 703 | { |
704 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 704 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
705 | 705 | ||
706 | NV_DEBUG(crtc->dev, "\n"); | 706 | NV_DEBUG_KMS(crtc->dev, "\n"); |
707 | 707 | ||
708 | if (!nv_crtc) | 708 | if (!nv_crtc) |
709 | return; | 709 | return; |
diff --git a/drivers/gpu/drm/nouveau/nv04_dac.c b/drivers/gpu/drm/nouveau/nv04_dac.c index a5fa51714e87..d9f32879ba38 100644 --- a/drivers/gpu/drm/nouveau/nv04_dac.c +++ b/drivers/gpu/drm/nouveau/nv04_dac.c | |||
@@ -205,7 +205,7 @@ out: | |||
205 | NVWriteVgaSeq(dev, 0, NV_VIO_SR_CLOCK_INDEX, saved_seq1); | 205 | NVWriteVgaSeq(dev, 0, NV_VIO_SR_CLOCK_INDEX, saved_seq1); |
206 | 206 | ||
207 | if (blue == 0x18) { | 207 | if (blue == 0x18) { |
208 | NV_TRACE(dev, "Load detected on head A\n"); | 208 | NV_INFO(dev, "Load detected on head A\n"); |
209 | return connector_status_connected; | 209 | return connector_status_connected; |
210 | } | 210 | } |
211 | 211 | ||
@@ -350,14 +350,10 @@ static void nv04_dac_mode_set(struct drm_encoder *encoder, | |||
350 | struct drm_display_mode *mode, | 350 | struct drm_display_mode *mode, |
351 | struct drm_display_mode *adjusted_mode) | 351 | struct drm_display_mode *adjusted_mode) |
352 | { | 352 | { |
353 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); | ||
354 | struct drm_device *dev = encoder->dev; | 353 | struct drm_device *dev = encoder->dev; |
355 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 354 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
356 | int head = nouveau_crtc(encoder->crtc)->index; | 355 | int head = nouveau_crtc(encoder->crtc)->index; |
357 | 356 | ||
358 | NV_TRACE(dev, "%s called for encoder %d\n", __func__, | ||
359 | nv_encoder->dcb->index); | ||
360 | |||
361 | if (nv_gf4_disp_arch(dev)) { | 357 | if (nv_gf4_disp_arch(dev)) { |
362 | struct drm_encoder *rebind; | 358 | struct drm_encoder *rebind; |
363 | uint32_t dac_offset = nv04_dac_output_offset(encoder); | 359 | uint32_t dac_offset = nv04_dac_output_offset(encoder); |
@@ -466,7 +462,7 @@ static void nv04_dac_destroy(struct drm_encoder *encoder) | |||
466 | { | 462 | { |
467 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); | 463 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); |
468 | 464 | ||
469 | NV_DEBUG(encoder->dev, "\n"); | 465 | NV_DEBUG_KMS(encoder->dev, "\n"); |
470 | 466 | ||
471 | drm_encoder_cleanup(encoder); | 467 | drm_encoder_cleanup(encoder); |
472 | kfree(nv_encoder); | 468 | kfree(nv_encoder); |
diff --git a/drivers/gpu/drm/nouveau/nv04_dfp.c b/drivers/gpu/drm/nouveau/nv04_dfp.c index e5b33339d595..483f875bdb6a 100644 --- a/drivers/gpu/drm/nouveau/nv04_dfp.c +++ b/drivers/gpu/drm/nouveau/nv04_dfp.c | |||
@@ -261,7 +261,7 @@ static void nv04_dfp_mode_set(struct drm_encoder *encoder, | |||
261 | struct drm_display_mode *output_mode = &nv_encoder->mode; | 261 | struct drm_display_mode *output_mode = &nv_encoder->mode; |
262 | uint32_t mode_ratio, panel_ratio; | 262 | uint32_t mode_ratio, panel_ratio; |
263 | 263 | ||
264 | NV_DEBUG(dev, "Output mode on CRTC %d:\n", nv_crtc->index); | 264 | NV_DEBUG_KMS(dev, "Output mode on CRTC %d:\n", nv_crtc->index); |
265 | drm_mode_debug_printmodeline(output_mode); | 265 | drm_mode_debug_printmodeline(output_mode); |
266 | 266 | ||
267 | /* Initialize the FP registers in this CRTC. */ | 267 | /* Initialize the FP registers in this CRTC. */ |
@@ -413,7 +413,9 @@ static void nv04_dfp_commit(struct drm_encoder *encoder) | |||
413 | struct dcb_entry *dcbe = nv_encoder->dcb; | 413 | struct dcb_entry *dcbe = nv_encoder->dcb; |
414 | int head = nouveau_crtc(encoder->crtc)->index; | 414 | int head = nouveau_crtc(encoder->crtc)->index; |
415 | 415 | ||
416 | NV_TRACE(dev, "%s called for encoder %d\n", __func__, nv_encoder->dcb->index); | 416 | NV_INFO(dev, "Output %s is running on CRTC %d using output %c\n", |
417 | drm_get_connector_name(&nouveau_encoder_connector_get(nv_encoder)->base), | ||
418 | nv_crtc->index, '@' + ffs(nv_encoder->dcb->or)); | ||
417 | 419 | ||
418 | if (dcbe->type == OUTPUT_TMDS) | 420 | if (dcbe->type == OUTPUT_TMDS) |
419 | run_tmds_table(dev, dcbe, head, nv_encoder->mode.clock); | 421 | run_tmds_table(dev, dcbe, head, nv_encoder->mode.clock); |
@@ -550,7 +552,7 @@ static void nv04_dfp_destroy(struct drm_encoder *encoder) | |||
550 | { | 552 | { |
551 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); | 553 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); |
552 | 554 | ||
553 | NV_DEBUG(encoder->dev, "\n"); | 555 | NV_DEBUG_KMS(encoder->dev, "\n"); |
554 | 556 | ||
555 | drm_encoder_cleanup(encoder); | 557 | drm_encoder_cleanup(encoder); |
556 | kfree(nv_encoder); | 558 | kfree(nv_encoder); |
diff --git a/drivers/gpu/drm/nouveau/nv04_display.c b/drivers/gpu/drm/nouveau/nv04_display.c index b47c757ff48b..ef77215fa5b9 100644 --- a/drivers/gpu/drm/nouveau/nv04_display.c +++ b/drivers/gpu/drm/nouveau/nv04_display.c | |||
@@ -99,10 +99,11 @@ nv04_display_create(struct drm_device *dev) | |||
99 | uint16_t connector[16] = { 0 }; | 99 | uint16_t connector[16] = { 0 }; |
100 | int i, ret; | 100 | int i, ret; |
101 | 101 | ||
102 | NV_DEBUG(dev, "\n"); | 102 | NV_DEBUG_KMS(dev, "\n"); |
103 | 103 | ||
104 | if (nv_two_heads(dev)) | 104 | if (nv_two_heads(dev)) |
105 | nv04_display_store_initial_head_owner(dev); | 105 | nv04_display_store_initial_head_owner(dev); |
106 | nouveau_hw_save_vga_fonts(dev, 1); | ||
106 | 107 | ||
107 | drm_mode_config_init(dev); | 108 | drm_mode_config_init(dev); |
108 | drm_mode_create_scaling_mode_property(dev); | 109 | drm_mode_create_scaling_mode_property(dev); |
@@ -203,8 +204,6 @@ nv04_display_create(struct drm_device *dev) | |||
203 | /* Save previous state */ | 204 | /* Save previous state */ |
204 | NVLockVgaCrtcs(dev, false); | 205 | NVLockVgaCrtcs(dev, false); |
205 | 206 | ||
206 | nouveau_hw_save_vga_fonts(dev, 1); | ||
207 | |||
208 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) | 207 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) |
209 | crtc->funcs->save(crtc); | 208 | crtc->funcs->save(crtc); |
210 | 209 | ||
@@ -223,7 +222,7 @@ nv04_display_destroy(struct drm_device *dev) | |||
223 | struct drm_encoder *encoder; | 222 | struct drm_encoder *encoder; |
224 | struct drm_crtc *crtc; | 223 | struct drm_crtc *crtc; |
225 | 224 | ||
226 | NV_DEBUG(dev, "\n"); | 225 | NV_DEBUG_KMS(dev, "\n"); |
227 | 226 | ||
228 | /* Turn every CRTC off. */ | 227 | /* Turn every CRTC off. */ |
229 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { | 228 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
@@ -246,9 +245,9 @@ nv04_display_destroy(struct drm_device *dev) | |||
246 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) | 245 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) |
247 | crtc->funcs->restore(crtc); | 246 | crtc->funcs->restore(crtc); |
248 | 247 | ||
249 | nouveau_hw_save_vga_fonts(dev, 0); | ||
250 | |||
251 | drm_mode_config_cleanup(dev); | 248 | drm_mode_config_cleanup(dev); |
249 | |||
250 | nouveau_hw_save_vga_fonts(dev, 0); | ||
252 | } | 251 | } |
253 | 252 | ||
254 | void | 253 | void |
diff --git a/drivers/gpu/drm/nouveau/nv04_graph.c b/drivers/gpu/drm/nouveau/nv04_graph.c index 396ee92118f6..d561d773c0f4 100644 --- a/drivers/gpu/drm/nouveau/nv04_graph.c +++ b/drivers/gpu/drm/nouveau/nv04_graph.c | |||
@@ -543,7 +543,7 @@ nv04_graph_mthd_set_operation(struct nouveau_channel *chan, int grclass, | |||
543 | 543 | ||
544 | nv_wi32(dev, instance, tmp); | 544 | nv_wi32(dev, instance, tmp); |
545 | nv_wr32(dev, NV04_PGRAPH_CTX_SWITCH1, tmp); | 545 | nv_wr32(dev, NV04_PGRAPH_CTX_SWITCH1, tmp); |
546 | nv_wr32(dev, NV04_PGRAPH_CTX_CACHE1 + subc, tmp); | 546 | nv_wr32(dev, NV04_PGRAPH_CTX_CACHE1 + (subc<<2), tmp); |
547 | return 0; | 547 | return 0; |
548 | } | 548 | } |
549 | 549 | ||
diff --git a/drivers/gpu/drm/nouveau/nv10_graph.c b/drivers/gpu/drm/nouveau/nv10_graph.c index 6bf6804bb0ef..6870e0ee2e7e 100644 --- a/drivers/gpu/drm/nouveau/nv10_graph.c +++ b/drivers/gpu/drm/nouveau/nv10_graph.c | |||
@@ -389,49 +389,50 @@ struct graph_state { | |||
389 | int nv10[ARRAY_SIZE(nv10_graph_ctx_regs)]; | 389 | int nv10[ARRAY_SIZE(nv10_graph_ctx_regs)]; |
390 | int nv17[ARRAY_SIZE(nv17_graph_ctx_regs)]; | 390 | int nv17[ARRAY_SIZE(nv17_graph_ctx_regs)]; |
391 | struct pipe_state pipe_state; | 391 | struct pipe_state pipe_state; |
392 | uint32_t lma_window[4]; | ||
392 | }; | 393 | }; |
393 | 394 | ||
395 | #define PIPE_SAVE(dev, state, addr) \ | ||
396 | do { \ | ||
397 | int __i; \ | ||
398 | nv_wr32(dev, NV10_PGRAPH_PIPE_ADDRESS, addr); \ | ||
399 | for (__i = 0; __i < ARRAY_SIZE(state); __i++) \ | ||
400 | state[__i] = nv_rd32(dev, NV10_PGRAPH_PIPE_DATA); \ | ||
401 | } while (0) | ||
402 | |||
403 | #define PIPE_RESTORE(dev, state, addr) \ | ||
404 | do { \ | ||
405 | int __i; \ | ||
406 | nv_wr32(dev, NV10_PGRAPH_PIPE_ADDRESS, addr); \ | ||
407 | for (__i = 0; __i < ARRAY_SIZE(state); __i++) \ | ||
408 | nv_wr32(dev, NV10_PGRAPH_PIPE_DATA, state[__i]); \ | ||
409 | } while (0) | ||
410 | |||
394 | static void nv10_graph_save_pipe(struct nouveau_channel *chan) | 411 | static void nv10_graph_save_pipe(struct nouveau_channel *chan) |
395 | { | 412 | { |
396 | struct drm_device *dev = chan->dev; | 413 | struct drm_device *dev = chan->dev; |
397 | struct graph_state *pgraph_ctx = chan->pgraph_ctx; | 414 | struct graph_state *pgraph_ctx = chan->pgraph_ctx; |
398 | struct pipe_state *fifo_pipe_state = &pgraph_ctx->pipe_state; | 415 | struct pipe_state *pipe = &pgraph_ctx->pipe_state; |
399 | int i; | 416 | |
400 | #define PIPE_SAVE(addr) \ | 417 | PIPE_SAVE(dev, pipe->pipe_0x4400, 0x4400); |
401 | do { \ | 418 | PIPE_SAVE(dev, pipe->pipe_0x0200, 0x0200); |
402 | nv_wr32(dev, NV10_PGRAPH_PIPE_ADDRESS, addr); \ | 419 | PIPE_SAVE(dev, pipe->pipe_0x6400, 0x6400); |
403 | for (i = 0; i < ARRAY_SIZE(fifo_pipe_state->pipe_##addr); i++) \ | 420 | PIPE_SAVE(dev, pipe->pipe_0x6800, 0x6800); |
404 | fifo_pipe_state->pipe_##addr[i] = nv_rd32(dev, NV10_PGRAPH_PIPE_DATA); \ | 421 | PIPE_SAVE(dev, pipe->pipe_0x6c00, 0x6c00); |
405 | } while (0) | 422 | PIPE_SAVE(dev, pipe->pipe_0x7000, 0x7000); |
406 | 423 | PIPE_SAVE(dev, pipe->pipe_0x7400, 0x7400); | |
407 | PIPE_SAVE(0x4400); | 424 | PIPE_SAVE(dev, pipe->pipe_0x7800, 0x7800); |
408 | PIPE_SAVE(0x0200); | 425 | PIPE_SAVE(dev, pipe->pipe_0x0040, 0x0040); |
409 | PIPE_SAVE(0x6400); | 426 | PIPE_SAVE(dev, pipe->pipe_0x0000, 0x0000); |
410 | PIPE_SAVE(0x6800); | ||
411 | PIPE_SAVE(0x6c00); | ||
412 | PIPE_SAVE(0x7000); | ||
413 | PIPE_SAVE(0x7400); | ||
414 | PIPE_SAVE(0x7800); | ||
415 | PIPE_SAVE(0x0040); | ||
416 | PIPE_SAVE(0x0000); | ||
417 | |||
418 | #undef PIPE_SAVE | ||
419 | } | 427 | } |
420 | 428 | ||
421 | static void nv10_graph_load_pipe(struct nouveau_channel *chan) | 429 | static void nv10_graph_load_pipe(struct nouveau_channel *chan) |
422 | { | 430 | { |
423 | struct drm_device *dev = chan->dev; | 431 | struct drm_device *dev = chan->dev; |
424 | struct graph_state *pgraph_ctx = chan->pgraph_ctx; | 432 | struct graph_state *pgraph_ctx = chan->pgraph_ctx; |
425 | struct pipe_state *fifo_pipe_state = &pgraph_ctx->pipe_state; | 433 | struct pipe_state *pipe = &pgraph_ctx->pipe_state; |
426 | int i; | ||
427 | uint32_t xfmode0, xfmode1; | 434 | uint32_t xfmode0, xfmode1; |
428 | #define PIPE_RESTORE(addr) \ | 435 | int i; |
429 | do { \ | ||
430 | nv_wr32(dev, NV10_PGRAPH_PIPE_ADDRESS, addr); \ | ||
431 | for (i = 0; i < ARRAY_SIZE(fifo_pipe_state->pipe_##addr); i++) \ | ||
432 | nv_wr32(dev, NV10_PGRAPH_PIPE_DATA, fifo_pipe_state->pipe_##addr[i]); \ | ||
433 | } while (0) | ||
434 | |||
435 | 436 | ||
436 | nouveau_wait_for_idle(dev); | 437 | nouveau_wait_for_idle(dev); |
437 | /* XXX check haiku comments */ | 438 | /* XXX check haiku comments */ |
@@ -457,24 +458,22 @@ static void nv10_graph_load_pipe(struct nouveau_channel *chan) | |||
457 | nv_wr32(dev, NV10_PGRAPH_PIPE_DATA, 0x00000008); | 458 | nv_wr32(dev, NV10_PGRAPH_PIPE_DATA, 0x00000008); |
458 | 459 | ||
459 | 460 | ||
460 | PIPE_RESTORE(0x0200); | 461 | PIPE_RESTORE(dev, pipe->pipe_0x0200, 0x0200); |
461 | nouveau_wait_for_idle(dev); | 462 | nouveau_wait_for_idle(dev); |
462 | 463 | ||
463 | /* restore XFMODE */ | 464 | /* restore XFMODE */ |
464 | nv_wr32(dev, NV10_PGRAPH_XFMODE0, xfmode0); | 465 | nv_wr32(dev, NV10_PGRAPH_XFMODE0, xfmode0); |
465 | nv_wr32(dev, NV10_PGRAPH_XFMODE1, xfmode1); | 466 | nv_wr32(dev, NV10_PGRAPH_XFMODE1, xfmode1); |
466 | PIPE_RESTORE(0x6400); | 467 | PIPE_RESTORE(dev, pipe->pipe_0x6400, 0x6400); |
467 | PIPE_RESTORE(0x6800); | 468 | PIPE_RESTORE(dev, pipe->pipe_0x6800, 0x6800); |
468 | PIPE_RESTORE(0x6c00); | 469 | PIPE_RESTORE(dev, pipe->pipe_0x6c00, 0x6c00); |
469 | PIPE_RESTORE(0x7000); | 470 | PIPE_RESTORE(dev, pipe->pipe_0x7000, 0x7000); |
470 | PIPE_RESTORE(0x7400); | 471 | PIPE_RESTORE(dev, pipe->pipe_0x7400, 0x7400); |
471 | PIPE_RESTORE(0x7800); | 472 | PIPE_RESTORE(dev, pipe->pipe_0x7800, 0x7800); |
472 | PIPE_RESTORE(0x4400); | 473 | PIPE_RESTORE(dev, pipe->pipe_0x4400, 0x4400); |
473 | PIPE_RESTORE(0x0000); | 474 | PIPE_RESTORE(dev, pipe->pipe_0x0000, 0x0000); |
474 | PIPE_RESTORE(0x0040); | 475 | PIPE_RESTORE(dev, pipe->pipe_0x0040, 0x0040); |
475 | nouveau_wait_for_idle(dev); | 476 | nouveau_wait_for_idle(dev); |
476 | |||
477 | #undef PIPE_RESTORE | ||
478 | } | 477 | } |
479 | 478 | ||
480 | static void nv10_graph_create_pipe(struct nouveau_channel *chan) | 479 | static void nv10_graph_create_pipe(struct nouveau_channel *chan) |
@@ -832,6 +831,9 @@ int nv10_graph_init(struct drm_device *dev) | |||
832 | (1<<31)); | 831 | (1<<31)); |
833 | if (dev_priv->chipset >= 0x17) { | 832 | if (dev_priv->chipset >= 0x17) { |
834 | nv_wr32(dev, NV10_PGRAPH_DEBUG_4, 0x1f000000); | 833 | nv_wr32(dev, NV10_PGRAPH_DEBUG_4, 0x1f000000); |
834 | nv_wr32(dev, 0x400a10, 0x3ff3fb6); | ||
835 | nv_wr32(dev, 0x400838, 0x2f8684); | ||
836 | nv_wr32(dev, 0x40083c, 0x115f3f); | ||
835 | nv_wr32(dev, 0x004006b0, 0x40000020); | 837 | nv_wr32(dev, 0x004006b0, 0x40000020); |
836 | } else | 838 | } else |
837 | nv_wr32(dev, NV10_PGRAPH_DEBUG_4, 0x00000000); | 839 | nv_wr32(dev, NV10_PGRAPH_DEBUG_4, 0x00000000); |
@@ -867,6 +869,115 @@ void nv10_graph_takedown(struct drm_device *dev) | |||
867 | { | 869 | { |
868 | } | 870 | } |
869 | 871 | ||
872 | static int | ||
873 | nv17_graph_mthd_lma_window(struct nouveau_channel *chan, int grclass, | ||
874 | int mthd, uint32_t data) | ||
875 | { | ||
876 | struct drm_device *dev = chan->dev; | ||
877 | struct graph_state *ctx = chan->pgraph_ctx; | ||
878 | struct pipe_state *pipe = &ctx->pipe_state; | ||
879 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
880 | struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph; | ||
881 | uint32_t pipe_0x0040[1], pipe_0x64c0[8], pipe_0x6a80[3], pipe_0x6ab0[3]; | ||
882 | uint32_t xfmode0, xfmode1; | ||
883 | int i; | ||
884 | |||
885 | ctx->lma_window[(mthd - 0x1638) / 4] = data; | ||
886 | |||
887 | if (mthd != 0x1644) | ||
888 | return 0; | ||
889 | |||
890 | nouveau_wait_for_idle(dev); | ||
891 | |||
892 | PIPE_SAVE(dev, pipe_0x0040, 0x0040); | ||
893 | PIPE_SAVE(dev, pipe->pipe_0x0200, 0x0200); | ||
894 | |||
895 | PIPE_RESTORE(dev, ctx->lma_window, 0x6790); | ||
896 | |||
897 | nouveau_wait_for_idle(dev); | ||
898 | |||
899 | xfmode0 = nv_rd32(dev, NV10_PGRAPH_XFMODE0); | ||
900 | xfmode1 = nv_rd32(dev, NV10_PGRAPH_XFMODE1); | ||
901 | |||
902 | PIPE_SAVE(dev, pipe->pipe_0x4400, 0x4400); | ||
903 | PIPE_SAVE(dev, pipe_0x64c0, 0x64c0); | ||
904 | PIPE_SAVE(dev, pipe_0x6ab0, 0x6ab0); | ||
905 | PIPE_SAVE(dev, pipe_0x6a80, 0x6a80); | ||
906 | |||
907 | nouveau_wait_for_idle(dev); | ||
908 | |||
909 | nv_wr32(dev, NV10_PGRAPH_XFMODE0, 0x10000000); | ||
910 | nv_wr32(dev, NV10_PGRAPH_XFMODE1, 0x00000000); | ||
911 | nv_wr32(dev, NV10_PGRAPH_PIPE_ADDRESS, 0x000064c0); | ||
912 | for (i = 0; i < 4; i++) | ||
913 | nv_wr32(dev, NV10_PGRAPH_PIPE_DATA, 0x3f800000); | ||
914 | for (i = 0; i < 4; i++) | ||
915 | nv_wr32(dev, NV10_PGRAPH_PIPE_DATA, 0x00000000); | ||
916 | |||
917 | nv_wr32(dev, NV10_PGRAPH_PIPE_ADDRESS, 0x00006ab0); | ||
918 | for (i = 0; i < 3; i++) | ||
919 | nv_wr32(dev, NV10_PGRAPH_PIPE_DATA, 0x3f800000); | ||
920 | |||
921 | nv_wr32(dev, NV10_PGRAPH_PIPE_ADDRESS, 0x00006a80); | ||
922 | for (i = 0; i < 3; i++) | ||
923 | nv_wr32(dev, NV10_PGRAPH_PIPE_DATA, 0x00000000); | ||
924 | |||
925 | nv_wr32(dev, NV10_PGRAPH_PIPE_ADDRESS, 0x00000040); | ||
926 | nv_wr32(dev, NV10_PGRAPH_PIPE_DATA, 0x00000008); | ||
927 | |||
928 | PIPE_RESTORE(dev, pipe->pipe_0x0200, 0x0200); | ||
929 | |||
930 | nouveau_wait_for_idle(dev); | ||
931 | |||
932 | PIPE_RESTORE(dev, pipe_0x0040, 0x0040); | ||
933 | |||
934 | nv_wr32(dev, NV10_PGRAPH_XFMODE0, xfmode0); | ||
935 | nv_wr32(dev, NV10_PGRAPH_XFMODE1, xfmode1); | ||
936 | |||
937 | PIPE_RESTORE(dev, pipe_0x64c0, 0x64c0); | ||
938 | PIPE_RESTORE(dev, pipe_0x6ab0, 0x6ab0); | ||
939 | PIPE_RESTORE(dev, pipe_0x6a80, 0x6a80); | ||
940 | PIPE_RESTORE(dev, pipe->pipe_0x4400, 0x4400); | ||
941 | |||
942 | nv_wr32(dev, NV10_PGRAPH_PIPE_ADDRESS, 0x000000c0); | ||
943 | nv_wr32(dev, NV10_PGRAPH_PIPE_DATA, 0x00000000); | ||
944 | |||
945 | nouveau_wait_for_idle(dev); | ||
946 | |||
947 | pgraph->fifo_access(dev, true); | ||
948 | |||
949 | return 0; | ||
950 | } | ||
951 | |||
952 | static int | ||
953 | nv17_graph_mthd_lma_enable(struct nouveau_channel *chan, int grclass, | ||
954 | int mthd, uint32_t data) | ||
955 | { | ||
956 | struct drm_device *dev = chan->dev; | ||
957 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
958 | struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph; | ||
959 | |||
960 | nouveau_wait_for_idle(dev); | ||
961 | |||
962 | nv_wr32(dev, NV10_PGRAPH_DEBUG_4, | ||
963 | nv_rd32(dev, NV10_PGRAPH_DEBUG_4) | 0x1 << 8); | ||
964 | nv_wr32(dev, 0x004006b0, | ||
965 | nv_rd32(dev, 0x004006b0) | 0x8 << 24); | ||
966 | |||
967 | pgraph->fifo_access(dev, true); | ||
968 | |||
969 | return 0; | ||
970 | } | ||
971 | |||
972 | static struct nouveau_pgraph_object_method nv17_graph_celsius_mthds[] = { | ||
973 | { 0x1638, nv17_graph_mthd_lma_window }, | ||
974 | { 0x163c, nv17_graph_mthd_lma_window }, | ||
975 | { 0x1640, nv17_graph_mthd_lma_window }, | ||
976 | { 0x1644, nv17_graph_mthd_lma_window }, | ||
977 | { 0x1658, nv17_graph_mthd_lma_enable }, | ||
978 | {} | ||
979 | }; | ||
980 | |||
870 | struct nouveau_pgraph_object_class nv10_graph_grclass[] = { | 981 | struct nouveau_pgraph_object_class nv10_graph_grclass[] = { |
871 | { 0x0030, false, NULL }, /* null */ | 982 | { 0x0030, false, NULL }, /* null */ |
872 | { 0x0039, false, NULL }, /* m2mf */ | 983 | { 0x0039, false, NULL }, /* m2mf */ |
@@ -887,6 +998,6 @@ struct nouveau_pgraph_object_class nv10_graph_grclass[] = { | |||
887 | { 0x0095, false, NULL }, /* multitex_tri */ | 998 | { 0x0095, false, NULL }, /* multitex_tri */ |
888 | { 0x0056, false, NULL }, /* celcius (nv10) */ | 999 | { 0x0056, false, NULL }, /* celcius (nv10) */ |
889 | { 0x0096, false, NULL }, /* celcius (nv11) */ | 1000 | { 0x0096, false, NULL }, /* celcius (nv11) */ |
890 | { 0x0099, false, NULL }, /* celcius (nv17) */ | 1001 | { 0x0099, false, nv17_graph_celsius_mthds }, /* celcius (nv17) */ |
891 | {} | 1002 | {} |
892 | }; | 1003 | }; |
diff --git a/drivers/gpu/drm/nouveau/nv17_tv.c b/drivers/gpu/drm/nouveau/nv17_tv.c index 46cfd9c60478..81c01353a9f9 100644 --- a/drivers/gpu/drm/nouveau/nv17_tv.c +++ b/drivers/gpu/drm/nouveau/nv17_tv.c | |||
@@ -219,7 +219,7 @@ static void nv17_tv_dpms(struct drm_encoder *encoder, int mode) | |||
219 | return; | 219 | return; |
220 | nouveau_encoder(encoder)->last_dpms = mode; | 220 | nouveau_encoder(encoder)->last_dpms = mode; |
221 | 221 | ||
222 | NV_TRACE(dev, "Setting dpms mode %d on TV encoder (output %d)\n", | 222 | NV_INFO(dev, "Setting dpms mode %d on TV encoder (output %d)\n", |
223 | mode, nouveau_encoder(encoder)->dcb->index); | 223 | mode, nouveau_encoder(encoder)->dcb->index); |
224 | 224 | ||
225 | regs->ptv_200 &= ~1; | 225 | regs->ptv_200 &= ~1; |
@@ -619,7 +619,7 @@ static void nv17_tv_destroy(struct drm_encoder *encoder) | |||
619 | { | 619 | { |
620 | struct nv17_tv_encoder *tv_enc = to_tv_enc(encoder); | 620 | struct nv17_tv_encoder *tv_enc = to_tv_enc(encoder); |
621 | 621 | ||
622 | NV_DEBUG(encoder->dev, "\n"); | 622 | NV_DEBUG_KMS(encoder->dev, "\n"); |
623 | 623 | ||
624 | drm_encoder_cleanup(encoder); | 624 | drm_encoder_cleanup(encoder); |
625 | kfree(tv_enc); | 625 | kfree(tv_enc); |
diff --git a/drivers/gpu/drm/nouveau/nv40_graph.c b/drivers/gpu/drm/nouveau/nv40_graph.c index 7e8547cb5833..2b332bb55acf 100644 --- a/drivers/gpu/drm/nouveau/nv40_graph.c +++ b/drivers/gpu/drm/nouveau/nv40_graph.c | |||
@@ -24,36 +24,10 @@ | |||
24 | * | 24 | * |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <linux/firmware.h> | ||
28 | |||
29 | #include "drmP.h" | 27 | #include "drmP.h" |
30 | #include "drm.h" | 28 | #include "drm.h" |
31 | #include "nouveau_drv.h" | 29 | #include "nouveau_drv.h" |
32 | 30 | #include "nouveau_grctx.h" | |
33 | MODULE_FIRMWARE("nouveau/nv40.ctxprog"); | ||
34 | MODULE_FIRMWARE("nouveau/nv40.ctxvals"); | ||
35 | MODULE_FIRMWARE("nouveau/nv41.ctxprog"); | ||
36 | MODULE_FIRMWARE("nouveau/nv41.ctxvals"); | ||
37 | MODULE_FIRMWARE("nouveau/nv42.ctxprog"); | ||
38 | MODULE_FIRMWARE("nouveau/nv42.ctxvals"); | ||
39 | MODULE_FIRMWARE("nouveau/nv43.ctxprog"); | ||
40 | MODULE_FIRMWARE("nouveau/nv43.ctxvals"); | ||
41 | MODULE_FIRMWARE("nouveau/nv44.ctxprog"); | ||
42 | MODULE_FIRMWARE("nouveau/nv44.ctxvals"); | ||
43 | MODULE_FIRMWARE("nouveau/nv46.ctxprog"); | ||
44 | MODULE_FIRMWARE("nouveau/nv46.ctxvals"); | ||
45 | MODULE_FIRMWARE("nouveau/nv47.ctxprog"); | ||
46 | MODULE_FIRMWARE("nouveau/nv47.ctxvals"); | ||
47 | MODULE_FIRMWARE("nouveau/nv49.ctxprog"); | ||
48 | MODULE_FIRMWARE("nouveau/nv49.ctxvals"); | ||
49 | MODULE_FIRMWARE("nouveau/nv4a.ctxprog"); | ||
50 | MODULE_FIRMWARE("nouveau/nv4a.ctxvals"); | ||
51 | MODULE_FIRMWARE("nouveau/nv4b.ctxprog"); | ||
52 | MODULE_FIRMWARE("nouveau/nv4b.ctxvals"); | ||
53 | MODULE_FIRMWARE("nouveau/nv4c.ctxprog"); | ||
54 | MODULE_FIRMWARE("nouveau/nv4c.ctxvals"); | ||
55 | MODULE_FIRMWARE("nouveau/nv4e.ctxprog"); | ||
56 | MODULE_FIRMWARE("nouveau/nv4e.ctxvals"); | ||
57 | 31 | ||
58 | struct nouveau_channel * | 32 | struct nouveau_channel * |
59 | nv40_graph_channel(struct drm_device *dev) | 33 | nv40_graph_channel(struct drm_device *dev) |
@@ -83,27 +57,30 @@ nv40_graph_create_context(struct nouveau_channel *chan) | |||
83 | { | 57 | { |
84 | struct drm_device *dev = chan->dev; | 58 | struct drm_device *dev = chan->dev; |
85 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 59 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
86 | struct nouveau_gpuobj *ctx; | 60 | struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph; |
87 | int ret; | 61 | int ret; |
88 | 62 | ||
89 | /* Allocate a 175KiB block of PRAMIN to store the context. This | 63 | ret = nouveau_gpuobj_new_ref(dev, chan, NULL, 0, pgraph->grctx_size, |
90 | * is massive overkill for a lot of chipsets, but it should be safe | 64 | 16, NVOBJ_FLAG_ZERO_ALLOC, |
91 | * until we're able to implement this properly (will happen at more | 65 | &chan->ramin_grctx); |
92 | * or less the same time we're able to write our own context programs. | ||
93 | */ | ||
94 | ret = nouveau_gpuobj_new_ref(dev, chan, NULL, 0, 175*1024, 16, | ||
95 | NVOBJ_FLAG_ZERO_ALLOC, | ||
96 | &chan->ramin_grctx); | ||
97 | if (ret) | 66 | if (ret) |
98 | return ret; | 67 | return ret; |
99 | ctx = chan->ramin_grctx->gpuobj; | ||
100 | 68 | ||
101 | /* Initialise default context values */ | 69 | /* Initialise default context values */ |
102 | dev_priv->engine.instmem.prepare_access(dev, true); | 70 | dev_priv->engine.instmem.prepare_access(dev, true); |
103 | nv40_grctx_vals_load(dev, ctx); | 71 | if (!pgraph->ctxprog) { |
104 | nv_wo32(dev, ctx, 0, ctx->im_pramin->start); | 72 | struct nouveau_grctx ctx = {}; |
105 | dev_priv->engine.instmem.finish_access(dev); | ||
106 | 73 | ||
74 | ctx.dev = chan->dev; | ||
75 | ctx.mode = NOUVEAU_GRCTX_VALS; | ||
76 | ctx.data = chan->ramin_grctx->gpuobj; | ||
77 | nv40_grctx_init(&ctx); | ||
78 | } else { | ||
79 | nouveau_grctx_vals_load(dev, chan->ramin_grctx->gpuobj); | ||
80 | } | ||
81 | nv_wo32(dev, chan->ramin_grctx->gpuobj, 0, | ||
82 | chan->ramin_grctx->gpuobj->im_pramin->start); | ||
83 | dev_priv->engine.instmem.finish_access(dev); | ||
107 | return 0; | 84 | return 0; |
108 | } | 85 | } |
109 | 86 | ||
@@ -204,139 +181,6 @@ nv40_graph_unload_context(struct drm_device *dev) | |||
204 | return ret; | 181 | return ret; |
205 | } | 182 | } |
206 | 183 | ||
207 | struct nouveau_ctxprog { | ||
208 | uint32_t signature; | ||
209 | uint8_t version; | ||
210 | uint16_t length; | ||
211 | uint32_t data[]; | ||
212 | } __attribute__ ((packed)); | ||
213 | |||
214 | struct nouveau_ctxvals { | ||
215 | uint32_t signature; | ||
216 | uint8_t version; | ||
217 | uint32_t length; | ||
218 | struct { | ||
219 | uint32_t offset; | ||
220 | uint32_t value; | ||
221 | } data[]; | ||
222 | } __attribute__ ((packed)); | ||
223 | |||
224 | int | ||
225 | nv40_grctx_init(struct drm_device *dev) | ||
226 | { | ||
227 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
228 | struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph; | ||
229 | const int chipset = dev_priv->chipset; | ||
230 | const struct firmware *fw; | ||
231 | const struct nouveau_ctxprog *cp; | ||
232 | const struct nouveau_ctxvals *cv; | ||
233 | char name[32]; | ||
234 | int ret, i; | ||
235 | |||
236 | pgraph->accel_blocked = true; | ||
237 | |||
238 | if (!pgraph->ctxprog) { | ||
239 | sprintf(name, "nouveau/nv%02x.ctxprog", chipset); | ||
240 | ret = request_firmware(&fw, name, &dev->pdev->dev); | ||
241 | if (ret) { | ||
242 | NV_ERROR(dev, "No ctxprog for NV%02x\n", chipset); | ||
243 | return ret; | ||
244 | } | ||
245 | |||
246 | pgraph->ctxprog = kmalloc(fw->size, GFP_KERNEL); | ||
247 | if (!pgraph->ctxprog) { | ||
248 | NV_ERROR(dev, "OOM copying ctxprog\n"); | ||
249 | release_firmware(fw); | ||
250 | return -ENOMEM; | ||
251 | } | ||
252 | memcpy(pgraph->ctxprog, fw->data, fw->size); | ||
253 | |||
254 | cp = pgraph->ctxprog; | ||
255 | if (le32_to_cpu(cp->signature) != 0x5043564e || | ||
256 | cp->version != 0 || | ||
257 | le16_to_cpu(cp->length) != ((fw->size - 7) / 4)) { | ||
258 | NV_ERROR(dev, "ctxprog invalid\n"); | ||
259 | release_firmware(fw); | ||
260 | nv40_grctx_fini(dev); | ||
261 | return -EINVAL; | ||
262 | } | ||
263 | release_firmware(fw); | ||
264 | } | ||
265 | |||
266 | if (!pgraph->ctxvals) { | ||
267 | sprintf(name, "nouveau/nv%02x.ctxvals", chipset); | ||
268 | ret = request_firmware(&fw, name, &dev->pdev->dev); | ||
269 | if (ret) { | ||
270 | NV_ERROR(dev, "No ctxvals for NV%02x\n", chipset); | ||
271 | nv40_grctx_fini(dev); | ||
272 | return ret; | ||
273 | } | ||
274 | |||
275 | pgraph->ctxvals = kmalloc(fw->size, GFP_KERNEL); | ||
276 | if (!pgraph->ctxprog) { | ||
277 | NV_ERROR(dev, "OOM copying ctxprog\n"); | ||
278 | release_firmware(fw); | ||
279 | nv40_grctx_fini(dev); | ||
280 | return -ENOMEM; | ||
281 | } | ||
282 | memcpy(pgraph->ctxvals, fw->data, fw->size); | ||
283 | |||
284 | cv = (void *)pgraph->ctxvals; | ||
285 | if (le32_to_cpu(cv->signature) != 0x5643564e || | ||
286 | cv->version != 0 || | ||
287 | le32_to_cpu(cv->length) != ((fw->size - 9) / 8)) { | ||
288 | NV_ERROR(dev, "ctxvals invalid\n"); | ||
289 | release_firmware(fw); | ||
290 | nv40_grctx_fini(dev); | ||
291 | return -EINVAL; | ||
292 | } | ||
293 | release_firmware(fw); | ||
294 | } | ||
295 | |||
296 | cp = pgraph->ctxprog; | ||
297 | |||
298 | nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_INDEX, 0); | ||
299 | for (i = 0; i < le16_to_cpu(cp->length); i++) | ||
300 | nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_DATA, | ||
301 | le32_to_cpu(cp->data[i])); | ||
302 | |||
303 | pgraph->accel_blocked = false; | ||
304 | return 0; | ||
305 | } | ||
306 | |||
307 | void | ||
308 | nv40_grctx_fini(struct drm_device *dev) | ||
309 | { | ||
310 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
311 | struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph; | ||
312 | |||
313 | if (pgraph->ctxprog) { | ||
314 | kfree(pgraph->ctxprog); | ||
315 | pgraph->ctxprog = NULL; | ||
316 | } | ||
317 | |||
318 | if (pgraph->ctxvals) { | ||
319 | kfree(pgraph->ctxprog); | ||
320 | pgraph->ctxvals = NULL; | ||
321 | } | ||
322 | } | ||
323 | |||
324 | void | ||
325 | nv40_grctx_vals_load(struct drm_device *dev, struct nouveau_gpuobj *ctx) | ||
326 | { | ||
327 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
328 | struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph; | ||
329 | struct nouveau_ctxvals *cv = pgraph->ctxvals; | ||
330 | int i; | ||
331 | |||
332 | if (!cv) | ||
333 | return; | ||
334 | |||
335 | for (i = 0; i < le32_to_cpu(cv->length); i++) | ||
336 | nv_wo32(dev, ctx, le32_to_cpu(cv->data[i].offset), | ||
337 | le32_to_cpu(cv->data[i].value)); | ||
338 | } | ||
339 | |||
340 | /* | 184 | /* |
341 | * G70 0x47 | 185 | * G70 0x47 |
342 | * G71 0x49 | 186 | * G71 0x49 |
@@ -359,7 +203,26 @@ nv40_graph_init(struct drm_device *dev) | |||
359 | nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) | | 203 | nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) | |
360 | NV_PMC_ENABLE_PGRAPH); | 204 | NV_PMC_ENABLE_PGRAPH); |
361 | 205 | ||
362 | nv40_grctx_init(dev); | 206 | if (nouveau_ctxfw) { |
207 | nouveau_grctx_prog_load(dev); | ||
208 | dev_priv->engine.graph.grctx_size = 175 * 1024; | ||
209 | } | ||
210 | |||
211 | if (!dev_priv->engine.graph.ctxprog) { | ||
212 | struct nouveau_grctx ctx = {}; | ||
213 | uint32_t cp[256]; | ||
214 | |||
215 | ctx.dev = dev; | ||
216 | ctx.mode = NOUVEAU_GRCTX_PROG; | ||
217 | ctx.data = cp; | ||
218 | ctx.ctxprog_max = 256; | ||
219 | nv40_grctx_init(&ctx); | ||
220 | dev_priv->engine.graph.grctx_size = ctx.ctxvals_pos * 4; | ||
221 | |||
222 | nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_INDEX, 0); | ||
223 | for (i = 0; i < ctx.ctxprog_len; i++) | ||
224 | nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_DATA, cp[i]); | ||
225 | } | ||
363 | 226 | ||
364 | /* No context present currently */ | 227 | /* No context present currently */ |
365 | nv_wr32(dev, NV40_PGRAPH_CTXCTL_CUR, 0x00000000); | 228 | nv_wr32(dev, NV40_PGRAPH_CTXCTL_CUR, 0x00000000); |
@@ -539,6 +402,7 @@ nv40_graph_init(struct drm_device *dev) | |||
539 | 402 | ||
540 | void nv40_graph_takedown(struct drm_device *dev) | 403 | void nv40_graph_takedown(struct drm_device *dev) |
541 | { | 404 | { |
405 | nouveau_grctx_fini(dev); | ||
542 | } | 406 | } |
543 | 407 | ||
544 | struct nouveau_pgraph_object_class nv40_graph_grclass[] = { | 408 | struct nouveau_pgraph_object_class nv40_graph_grclass[] = { |
diff --git a/drivers/gpu/drm/nouveau/nv40_grctx.c b/drivers/gpu/drm/nouveau/nv40_grctx.c new file mode 100644 index 000000000000..11b11c31f543 --- /dev/null +++ b/drivers/gpu/drm/nouveau/nv40_grctx.c | |||
@@ -0,0 +1,678 @@ | |||
1 | /* | ||
2 | * Copyright 2009 Red Hat Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | * Authors: Ben Skeggs | ||
23 | */ | ||
24 | |||
25 | /* NVIDIA context programs handle a number of other conditions which are | ||
26 | * not implemented in our versions. It's not clear why NVIDIA context | ||
27 | * programs have this code, nor whether it's strictly necessary for | ||
28 | * correct operation. We'll implement additional handling if/when we | ||
29 | * discover it's necessary. | ||
30 | * | ||
31 | * - On context save, NVIDIA set 0x400314 bit 0 to 1 if the "3D state" | ||
32 | * flag is set, this gets saved into the context. | ||
33 | * - On context save, the context program for all cards load nsource | ||
34 | * into a flag register and check for ILLEGAL_MTHD. If it's set, | ||
35 | * opcode 0x60000d is called before resuming normal operation. | ||
36 | * - Some context programs check more conditions than the above. NV44 | ||
37 | * checks: ((nsource & 0x0857) || (0x400718 & 0x0100) || (intr & 0x0001)) | ||
38 | * and calls 0x60000d before resuming normal operation. | ||
39 | * - At the very beginning of NVIDIA's context programs, flag 9 is checked | ||
40 | * and if true 0x800001 is called with count=0, pos=0, the flag is cleared | ||
41 | * and then the ctxprog is aborted. It looks like a complicated NOP, | ||
42 | * its purpose is unknown. | ||
43 | * - In the section of code that loads the per-vs state, NVIDIA check | ||
44 | * flag 10. If it's set, they only transfer the small 0x300 byte block | ||
45 | * of state + the state for a single vs as opposed to the state for | ||
46 | * all vs units. It doesn't seem likely that it'll occur in normal | ||
47 | * operation, especially seeing as it appears NVIDIA may have screwed | ||
48 | * up the ctxprogs for some cards and have an invalid instruction | ||
49 | * rather than a cp_lsr(ctx, dwords_for_1_vs_unit) instruction. | ||
50 | * - There's a number of places where context offset 0 (where we place | ||
51 | * the PRAMIN offset of the context) is loaded into either 0x408000, | ||
52 | * 0x408004 or 0x408008. Not sure what's up there either. | ||
53 | * - The ctxprogs for some cards save 0x400a00 again during the cleanup | ||
54 | * path for auto-loadctx. | ||
55 | */ | ||
56 | |||
57 | #define CP_FLAG_CLEAR 0 | ||
58 | #define CP_FLAG_SET 1 | ||
59 | #define CP_FLAG_SWAP_DIRECTION ((0 * 32) + 0) | ||
60 | #define CP_FLAG_SWAP_DIRECTION_LOAD 0 | ||
61 | #define CP_FLAG_SWAP_DIRECTION_SAVE 1 | ||
62 | #define CP_FLAG_USER_SAVE ((0 * 32) + 5) | ||
63 | #define CP_FLAG_USER_SAVE_NOT_PENDING 0 | ||
64 | #define CP_FLAG_USER_SAVE_PENDING 1 | ||
65 | #define CP_FLAG_USER_LOAD ((0 * 32) + 6) | ||
66 | #define CP_FLAG_USER_LOAD_NOT_PENDING 0 | ||
67 | #define CP_FLAG_USER_LOAD_PENDING 1 | ||
68 | #define CP_FLAG_STATUS ((3 * 32) + 0) | ||
69 | #define CP_FLAG_STATUS_IDLE 0 | ||
70 | #define CP_FLAG_STATUS_BUSY 1 | ||
71 | #define CP_FLAG_AUTO_SAVE ((3 * 32) + 4) | ||
72 | #define CP_FLAG_AUTO_SAVE_NOT_PENDING 0 | ||
73 | #define CP_FLAG_AUTO_SAVE_PENDING 1 | ||
74 | #define CP_FLAG_AUTO_LOAD ((3 * 32) + 5) | ||
75 | #define CP_FLAG_AUTO_LOAD_NOT_PENDING 0 | ||
76 | #define CP_FLAG_AUTO_LOAD_PENDING 1 | ||
77 | #define CP_FLAG_UNK54 ((3 * 32) + 6) | ||
78 | #define CP_FLAG_UNK54_CLEAR 0 | ||
79 | #define CP_FLAG_UNK54_SET 1 | ||
80 | #define CP_FLAG_ALWAYS ((3 * 32) + 8) | ||
81 | #define CP_FLAG_ALWAYS_FALSE 0 | ||
82 | #define CP_FLAG_ALWAYS_TRUE 1 | ||
83 | #define CP_FLAG_UNK57 ((3 * 32) + 9) | ||
84 | #define CP_FLAG_UNK57_CLEAR 0 | ||
85 | #define CP_FLAG_UNK57_SET 1 | ||
86 | |||
87 | #define CP_CTX 0x00100000 | ||
88 | #define CP_CTX_COUNT 0x000fc000 | ||
89 | #define CP_CTX_COUNT_SHIFT 14 | ||
90 | #define CP_CTX_REG 0x00003fff | ||
91 | #define CP_LOAD_SR 0x00200000 | ||
92 | #define CP_LOAD_SR_VALUE 0x000fffff | ||
93 | #define CP_BRA 0x00400000 | ||
94 | #define CP_BRA_IP 0x0000ff00 | ||
95 | #define CP_BRA_IP_SHIFT 8 | ||
96 | #define CP_BRA_IF_CLEAR 0x00000080 | ||
97 | #define CP_BRA_FLAG 0x0000007f | ||
98 | #define CP_WAIT 0x00500000 | ||
99 | #define CP_WAIT_SET 0x00000080 | ||
100 | #define CP_WAIT_FLAG 0x0000007f | ||
101 | #define CP_SET 0x00700000 | ||
102 | #define CP_SET_1 0x00000080 | ||
103 | #define CP_SET_FLAG 0x0000007f | ||
104 | #define CP_NEXT_TO_SWAP 0x00600007 | ||
105 | #define CP_NEXT_TO_CURRENT 0x00600009 | ||
106 | #define CP_SET_CONTEXT_POINTER 0x0060000a | ||
107 | #define CP_END 0x0060000e | ||
108 | #define CP_LOAD_MAGIC_UNK01 0x00800001 /* unknown */ | ||
109 | #define CP_LOAD_MAGIC_NV44TCL 0x00800029 /* per-vs state (0x4497) */ | ||
110 | #define CP_LOAD_MAGIC_NV40TCL 0x00800041 /* per-vs state (0x4097) */ | ||
111 | |||
112 | #include "drmP.h" | ||
113 | #include "nouveau_drv.h" | ||
114 | #include "nouveau_grctx.h" | ||
115 | |||
116 | /* TODO: | ||
117 | * - get vs count from 0x1540 | ||
118 | * - document unimplemented bits compared to nvidia | ||
119 | * - nsource handling | ||
120 | * - R0 & 0x0200 handling | ||
121 | * - single-vs handling | ||
122 | * - 400314 bit 0 | ||
123 | */ | ||
124 | |||
125 | static int | ||
126 | nv40_graph_4097(struct drm_device *dev) | ||
127 | { | ||
128 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
129 | |||
130 | if ((dev_priv->chipset & 0xf0) == 0x60) | ||
131 | return 0; | ||
132 | |||
133 | return !!(0x0baf & (1 << dev_priv->chipset)); | ||
134 | } | ||
135 | |||
136 | static int | ||
137 | nv40_graph_vs_count(struct drm_device *dev) | ||
138 | { | ||
139 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
140 | |||
141 | switch (dev_priv->chipset) { | ||
142 | case 0x47: | ||
143 | case 0x49: | ||
144 | case 0x4b: | ||
145 | return 8; | ||
146 | case 0x40: | ||
147 | return 6; | ||
148 | case 0x41: | ||
149 | case 0x42: | ||
150 | return 5; | ||
151 | case 0x43: | ||
152 | case 0x44: | ||
153 | case 0x46: | ||
154 | case 0x4a: | ||
155 | return 3; | ||
156 | case 0x4c: | ||
157 | case 0x4e: | ||
158 | case 0x67: | ||
159 | default: | ||
160 | return 1; | ||
161 | } | ||
162 | } | ||
163 | |||
164 | |||
165 | enum cp_label { | ||
166 | cp_check_load = 1, | ||
167 | cp_setup_auto_load, | ||
168 | cp_setup_load, | ||
169 | cp_setup_save, | ||
170 | cp_swap_state, | ||
171 | cp_swap_state3d_3_is_save, | ||
172 | cp_prepare_exit, | ||
173 | cp_exit, | ||
174 | }; | ||
175 | |||
176 | static void | ||
177 | nv40_graph_construct_general(struct nouveau_grctx *ctx) | ||
178 | { | ||
179 | struct drm_nouveau_private *dev_priv = ctx->dev->dev_private; | ||
180 | int i; | ||
181 | |||
182 | cp_ctx(ctx, 0x4000a4, 1); | ||
183 | gr_def(ctx, 0x4000a4, 0x00000008); | ||
184 | cp_ctx(ctx, 0x400144, 58); | ||
185 | gr_def(ctx, 0x400144, 0x00000001); | ||
186 | cp_ctx(ctx, 0x400314, 1); | ||
187 | gr_def(ctx, 0x400314, 0x00000000); | ||
188 | cp_ctx(ctx, 0x400400, 10); | ||
189 | cp_ctx(ctx, 0x400480, 10); | ||
190 | cp_ctx(ctx, 0x400500, 19); | ||
191 | gr_def(ctx, 0x400514, 0x00040000); | ||
192 | gr_def(ctx, 0x400524, 0x55555555); | ||
193 | gr_def(ctx, 0x400528, 0x55555555); | ||
194 | gr_def(ctx, 0x40052c, 0x55555555); | ||
195 | gr_def(ctx, 0x400530, 0x55555555); | ||
196 | cp_ctx(ctx, 0x400560, 6); | ||
197 | gr_def(ctx, 0x400568, 0x0000ffff); | ||
198 | gr_def(ctx, 0x40056c, 0x0000ffff); | ||
199 | cp_ctx(ctx, 0x40057c, 5); | ||
200 | cp_ctx(ctx, 0x400710, 3); | ||
201 | gr_def(ctx, 0x400710, 0x20010001); | ||
202 | gr_def(ctx, 0x400714, 0x0f73ef00); | ||
203 | cp_ctx(ctx, 0x400724, 1); | ||
204 | gr_def(ctx, 0x400724, 0x02008821); | ||
205 | cp_ctx(ctx, 0x400770, 3); | ||
206 | if (dev_priv->chipset == 0x40) { | ||
207 | cp_ctx(ctx, 0x400814, 4); | ||
208 | cp_ctx(ctx, 0x400828, 5); | ||
209 | cp_ctx(ctx, 0x400840, 5); | ||
210 | gr_def(ctx, 0x400850, 0x00000040); | ||
211 | cp_ctx(ctx, 0x400858, 4); | ||
212 | gr_def(ctx, 0x400858, 0x00000040); | ||
213 | gr_def(ctx, 0x40085c, 0x00000040); | ||
214 | gr_def(ctx, 0x400864, 0x80000000); | ||
215 | cp_ctx(ctx, 0x40086c, 9); | ||
216 | gr_def(ctx, 0x40086c, 0x80000000); | ||
217 | gr_def(ctx, 0x400870, 0x80000000); | ||
218 | gr_def(ctx, 0x400874, 0x80000000); | ||
219 | gr_def(ctx, 0x400878, 0x80000000); | ||
220 | gr_def(ctx, 0x400888, 0x00000040); | ||
221 | gr_def(ctx, 0x40088c, 0x80000000); | ||
222 | cp_ctx(ctx, 0x4009c0, 8); | ||
223 | gr_def(ctx, 0x4009cc, 0x80000000); | ||
224 | gr_def(ctx, 0x4009dc, 0x80000000); | ||
225 | } else { | ||
226 | cp_ctx(ctx, 0x400840, 20); | ||
227 | if (!nv40_graph_4097(ctx->dev)) { | ||
228 | for (i = 0; i < 8; i++) | ||
229 | gr_def(ctx, 0x400860 + (i * 4), 0x00000001); | ||
230 | } | ||
231 | gr_def(ctx, 0x400880, 0x00000040); | ||
232 | gr_def(ctx, 0x400884, 0x00000040); | ||
233 | gr_def(ctx, 0x400888, 0x00000040); | ||
234 | cp_ctx(ctx, 0x400894, 11); | ||
235 | gr_def(ctx, 0x400894, 0x00000040); | ||
236 | if (nv40_graph_4097(ctx->dev)) { | ||
237 | for (i = 0; i < 8; i++) | ||
238 | gr_def(ctx, 0x4008a0 + (i * 4), 0x80000000); | ||
239 | } | ||
240 | cp_ctx(ctx, 0x4008e0, 2); | ||
241 | cp_ctx(ctx, 0x4008f8, 2); | ||
242 | if (dev_priv->chipset == 0x4c || | ||
243 | (dev_priv->chipset & 0xf0) == 0x60) | ||
244 | cp_ctx(ctx, 0x4009f8, 1); | ||
245 | } | ||
246 | cp_ctx(ctx, 0x400a00, 73); | ||
247 | gr_def(ctx, 0x400b0c, 0x0b0b0b0c); | ||
248 | cp_ctx(ctx, 0x401000, 4); | ||
249 | cp_ctx(ctx, 0x405004, 1); | ||
250 | switch (dev_priv->chipset) { | ||
251 | case 0x47: | ||
252 | case 0x49: | ||
253 | case 0x4b: | ||
254 | cp_ctx(ctx, 0x403448, 1); | ||
255 | gr_def(ctx, 0x403448, 0x00001010); | ||
256 | break; | ||
257 | default: | ||
258 | cp_ctx(ctx, 0x403440, 1); | ||
259 | switch (dev_priv->chipset) { | ||
260 | case 0x40: | ||
261 | gr_def(ctx, 0x403440, 0x00000010); | ||
262 | break; | ||
263 | case 0x44: | ||
264 | case 0x46: | ||
265 | case 0x4a: | ||
266 | gr_def(ctx, 0x403440, 0x00003010); | ||
267 | break; | ||
268 | case 0x41: | ||
269 | case 0x42: | ||
270 | case 0x43: | ||
271 | case 0x4c: | ||
272 | case 0x4e: | ||
273 | case 0x67: | ||
274 | default: | ||
275 | gr_def(ctx, 0x403440, 0x00001010); | ||
276 | break; | ||
277 | } | ||
278 | break; | ||
279 | } | ||
280 | } | ||
281 | |||
282 | static void | ||
283 | nv40_graph_construct_state3d(struct nouveau_grctx *ctx) | ||
284 | { | ||
285 | struct drm_nouveau_private *dev_priv = ctx->dev->dev_private; | ||
286 | int i; | ||
287 | |||
288 | if (dev_priv->chipset == 0x40) { | ||
289 | cp_ctx(ctx, 0x401880, 51); | ||
290 | gr_def(ctx, 0x401940, 0x00000100); | ||
291 | } else | ||
292 | if (dev_priv->chipset == 0x46 || dev_priv->chipset == 0x47 || | ||
293 | dev_priv->chipset == 0x49 || dev_priv->chipset == 0x4b) { | ||
294 | cp_ctx(ctx, 0x401880, 32); | ||
295 | for (i = 0; i < 16; i++) | ||
296 | gr_def(ctx, 0x401880 + (i * 4), 0x00000111); | ||
297 | if (dev_priv->chipset == 0x46) | ||
298 | cp_ctx(ctx, 0x401900, 16); | ||
299 | cp_ctx(ctx, 0x401940, 3); | ||
300 | } | ||
301 | cp_ctx(ctx, 0x40194c, 18); | ||
302 | gr_def(ctx, 0x401954, 0x00000111); | ||
303 | gr_def(ctx, 0x401958, 0x00080060); | ||
304 | gr_def(ctx, 0x401974, 0x00000080); | ||
305 | gr_def(ctx, 0x401978, 0xffff0000); | ||
306 | gr_def(ctx, 0x40197c, 0x00000001); | ||
307 | gr_def(ctx, 0x401990, 0x46400000); | ||
308 | if (dev_priv->chipset == 0x40) { | ||
309 | cp_ctx(ctx, 0x4019a0, 2); | ||
310 | cp_ctx(ctx, 0x4019ac, 5); | ||
311 | } else { | ||
312 | cp_ctx(ctx, 0x4019a0, 1); | ||
313 | cp_ctx(ctx, 0x4019b4, 3); | ||
314 | } | ||
315 | gr_def(ctx, 0x4019bc, 0xffff0000); | ||
316 | switch (dev_priv->chipset) { | ||
317 | case 0x46: | ||
318 | case 0x47: | ||
319 | case 0x49: | ||
320 | case 0x4b: | ||
321 | cp_ctx(ctx, 0x4019c0, 18); | ||
322 | for (i = 0; i < 16; i++) | ||
323 | gr_def(ctx, 0x4019c0 + (i * 4), 0x88888888); | ||
324 | break; | ||
325 | } | ||
326 | cp_ctx(ctx, 0x401a08, 8); | ||
327 | gr_def(ctx, 0x401a10, 0x0fff0000); | ||
328 | gr_def(ctx, 0x401a14, 0x0fff0000); | ||
329 | gr_def(ctx, 0x401a1c, 0x00011100); | ||
330 | cp_ctx(ctx, 0x401a2c, 4); | ||
331 | cp_ctx(ctx, 0x401a44, 26); | ||
332 | for (i = 0; i < 16; i++) | ||
333 | gr_def(ctx, 0x401a44 + (i * 4), 0x07ff0000); | ||
334 | gr_def(ctx, 0x401a8c, 0x4b7fffff); | ||
335 | if (dev_priv->chipset == 0x40) { | ||
336 | cp_ctx(ctx, 0x401ab8, 3); | ||
337 | } else { | ||
338 | cp_ctx(ctx, 0x401ab8, 1); | ||
339 | cp_ctx(ctx, 0x401ac0, 1); | ||
340 | } | ||
341 | cp_ctx(ctx, 0x401ad0, 8); | ||
342 | gr_def(ctx, 0x401ad0, 0x30201000); | ||
343 | gr_def(ctx, 0x401ad4, 0x70605040); | ||
344 | gr_def(ctx, 0x401ad8, 0xb8a89888); | ||
345 | gr_def(ctx, 0x401adc, 0xf8e8d8c8); | ||
346 | cp_ctx(ctx, 0x401b10, dev_priv->chipset == 0x40 ? 2 : 1); | ||
347 | gr_def(ctx, 0x401b10, 0x40100000); | ||
348 | cp_ctx(ctx, 0x401b18, dev_priv->chipset == 0x40 ? 6 : 5); | ||
349 | gr_def(ctx, 0x401b28, dev_priv->chipset == 0x40 ? | ||
350 | 0x00000004 : 0x00000000); | ||
351 | cp_ctx(ctx, 0x401b30, 25); | ||
352 | gr_def(ctx, 0x401b34, 0x0000ffff); | ||
353 | gr_def(ctx, 0x401b68, 0x435185d6); | ||
354 | gr_def(ctx, 0x401b6c, 0x2155b699); | ||
355 | gr_def(ctx, 0x401b70, 0xfedcba98); | ||
356 | gr_def(ctx, 0x401b74, 0x00000098); | ||
357 | gr_def(ctx, 0x401b84, 0xffffffff); | ||
358 | gr_def(ctx, 0x401b88, 0x00ff7000); | ||
359 | gr_def(ctx, 0x401b8c, 0x0000ffff); | ||
360 | if (dev_priv->chipset != 0x44 && dev_priv->chipset != 0x4a && | ||
361 | dev_priv->chipset != 0x4e) | ||
362 | cp_ctx(ctx, 0x401b94, 1); | ||
363 | cp_ctx(ctx, 0x401b98, 8); | ||
364 | gr_def(ctx, 0x401b9c, 0x00ff0000); | ||
365 | cp_ctx(ctx, 0x401bc0, 9); | ||
366 | gr_def(ctx, 0x401be0, 0x00ffff00); | ||
367 | cp_ctx(ctx, 0x401c00, 192); | ||
368 | for (i = 0; i < 16; i++) { /* fragment texture units */ | ||
369 | gr_def(ctx, 0x401c40 + (i * 4), 0x00018488); | ||
370 | gr_def(ctx, 0x401c80 + (i * 4), 0x00028202); | ||
371 | gr_def(ctx, 0x401d00 + (i * 4), 0x0000aae4); | ||
372 | gr_def(ctx, 0x401d40 + (i * 4), 0x01012000); | ||
373 | gr_def(ctx, 0x401d80 + (i * 4), 0x00080008); | ||
374 | gr_def(ctx, 0x401e00 + (i * 4), 0x00100008); | ||
375 | } | ||
376 | for (i = 0; i < 4; i++) { /* vertex texture units */ | ||
377 | gr_def(ctx, 0x401e90 + (i * 4), 0x0001bc80); | ||
378 | gr_def(ctx, 0x401ea0 + (i * 4), 0x00000202); | ||
379 | gr_def(ctx, 0x401ec0 + (i * 4), 0x00000008); | ||
380 | gr_def(ctx, 0x401ee0 + (i * 4), 0x00080008); | ||
381 | } | ||
382 | cp_ctx(ctx, 0x400f5c, 3); | ||
383 | gr_def(ctx, 0x400f5c, 0x00000002); | ||
384 | cp_ctx(ctx, 0x400f84, 1); | ||
385 | } | ||
386 | |||
387 | static void | ||
388 | nv40_graph_construct_state3d_2(struct nouveau_grctx *ctx) | ||
389 | { | ||
390 | struct drm_nouveau_private *dev_priv = ctx->dev->dev_private; | ||
391 | int i; | ||
392 | |||
393 | cp_ctx(ctx, 0x402000, 1); | ||
394 | cp_ctx(ctx, 0x402404, dev_priv->chipset == 0x40 ? 1 : 2); | ||
395 | switch (dev_priv->chipset) { | ||
396 | case 0x40: | ||
397 | gr_def(ctx, 0x402404, 0x00000001); | ||
398 | break; | ||
399 | case 0x4c: | ||
400 | case 0x4e: | ||
401 | case 0x67: | ||
402 | gr_def(ctx, 0x402404, 0x00000020); | ||
403 | break; | ||
404 | case 0x46: | ||
405 | case 0x49: | ||
406 | case 0x4b: | ||
407 | gr_def(ctx, 0x402404, 0x00000421); | ||
408 | break; | ||
409 | default: | ||
410 | gr_def(ctx, 0x402404, 0x00000021); | ||
411 | } | ||
412 | if (dev_priv->chipset != 0x40) | ||
413 | gr_def(ctx, 0x402408, 0x030c30c3); | ||
414 | switch (dev_priv->chipset) { | ||
415 | case 0x44: | ||
416 | case 0x46: | ||
417 | case 0x4a: | ||
418 | case 0x4c: | ||
419 | case 0x4e: | ||
420 | case 0x67: | ||
421 | cp_ctx(ctx, 0x402440, 1); | ||
422 | gr_def(ctx, 0x402440, 0x00011001); | ||
423 | break; | ||
424 | default: | ||
425 | break; | ||
426 | } | ||
427 | cp_ctx(ctx, 0x402480, dev_priv->chipset == 0x40 ? 8 : 9); | ||
428 | gr_def(ctx, 0x402488, 0x3e020200); | ||
429 | gr_def(ctx, 0x40248c, 0x00ffffff); | ||
430 | switch (dev_priv->chipset) { | ||
431 | case 0x40: | ||
432 | gr_def(ctx, 0x402490, 0x60103f00); | ||
433 | break; | ||
434 | case 0x47: | ||
435 | gr_def(ctx, 0x402490, 0x40103f00); | ||
436 | break; | ||
437 | case 0x41: | ||
438 | case 0x42: | ||
439 | case 0x49: | ||
440 | case 0x4b: | ||
441 | gr_def(ctx, 0x402490, 0x20103f00); | ||
442 | break; | ||
443 | default: | ||
444 | gr_def(ctx, 0x402490, 0x0c103f00); | ||
445 | break; | ||
446 | } | ||
447 | gr_def(ctx, 0x40249c, dev_priv->chipset <= 0x43 ? | ||
448 | 0x00020000 : 0x00040000); | ||
449 | cp_ctx(ctx, 0x402500, 31); | ||
450 | gr_def(ctx, 0x402530, 0x00008100); | ||
451 | if (dev_priv->chipset == 0x40) | ||
452 | cp_ctx(ctx, 0x40257c, 6); | ||
453 | cp_ctx(ctx, 0x402594, 16); | ||
454 | cp_ctx(ctx, 0x402800, 17); | ||
455 | gr_def(ctx, 0x402800, 0x00000001); | ||
456 | switch (dev_priv->chipset) { | ||
457 | case 0x47: | ||
458 | case 0x49: | ||
459 | case 0x4b: | ||
460 | cp_ctx(ctx, 0x402864, 1); | ||
461 | gr_def(ctx, 0x402864, 0x00001001); | ||
462 | cp_ctx(ctx, 0x402870, 3); | ||
463 | gr_def(ctx, 0x402878, 0x00000003); | ||
464 | if (dev_priv->chipset != 0x47) { /* belong at end!! */ | ||
465 | cp_ctx(ctx, 0x402900, 1); | ||
466 | cp_ctx(ctx, 0x402940, 1); | ||
467 | cp_ctx(ctx, 0x402980, 1); | ||
468 | cp_ctx(ctx, 0x4029c0, 1); | ||
469 | cp_ctx(ctx, 0x402a00, 1); | ||
470 | cp_ctx(ctx, 0x402a40, 1); | ||
471 | cp_ctx(ctx, 0x402a80, 1); | ||
472 | cp_ctx(ctx, 0x402ac0, 1); | ||
473 | } | ||
474 | break; | ||
475 | case 0x40: | ||
476 | cp_ctx(ctx, 0x402844, 1); | ||
477 | gr_def(ctx, 0x402844, 0x00000001); | ||
478 | cp_ctx(ctx, 0x402850, 1); | ||
479 | break; | ||
480 | default: | ||
481 | cp_ctx(ctx, 0x402844, 1); | ||
482 | gr_def(ctx, 0x402844, 0x00001001); | ||
483 | cp_ctx(ctx, 0x402850, 2); | ||
484 | gr_def(ctx, 0x402854, 0x00000003); | ||
485 | break; | ||
486 | } | ||
487 | |||
488 | cp_ctx(ctx, 0x402c00, 4); | ||
489 | gr_def(ctx, 0x402c00, dev_priv->chipset == 0x40 ? | ||
490 | 0x80800001 : 0x00888001); | ||
491 | switch (dev_priv->chipset) { | ||
492 | case 0x47: | ||
493 | case 0x49: | ||
494 | case 0x4b: | ||
495 | cp_ctx(ctx, 0x402c20, 40); | ||
496 | for (i = 0; i < 32; i++) | ||
497 | gr_def(ctx, 0x402c40 + (i * 4), 0xffffffff); | ||
498 | cp_ctx(ctx, 0x4030b8, 13); | ||
499 | gr_def(ctx, 0x4030dc, 0x00000005); | ||
500 | gr_def(ctx, 0x4030e8, 0x0000ffff); | ||
501 | break; | ||
502 | default: | ||
503 | cp_ctx(ctx, 0x402c10, 4); | ||
504 | if (dev_priv->chipset == 0x40) | ||
505 | cp_ctx(ctx, 0x402c20, 36); | ||
506 | else | ||
507 | if (dev_priv->chipset <= 0x42) | ||
508 | cp_ctx(ctx, 0x402c20, 24); | ||
509 | else | ||
510 | if (dev_priv->chipset <= 0x4a) | ||
511 | cp_ctx(ctx, 0x402c20, 16); | ||
512 | else | ||
513 | cp_ctx(ctx, 0x402c20, 8); | ||
514 | cp_ctx(ctx, 0x402cb0, dev_priv->chipset == 0x40 ? 12 : 13); | ||
515 | gr_def(ctx, 0x402cd4, 0x00000005); | ||
516 | if (dev_priv->chipset != 0x40) | ||
517 | gr_def(ctx, 0x402ce0, 0x0000ffff); | ||
518 | break; | ||
519 | } | ||
520 | |||
521 | cp_ctx(ctx, 0x403400, dev_priv->chipset == 0x40 ? 4 : 3); | ||
522 | cp_ctx(ctx, 0x403410, dev_priv->chipset == 0x40 ? 4 : 3); | ||
523 | cp_ctx(ctx, 0x403420, nv40_graph_vs_count(ctx->dev)); | ||
524 | for (i = 0; i < nv40_graph_vs_count(ctx->dev); i++) | ||
525 | gr_def(ctx, 0x403420 + (i * 4), 0x00005555); | ||
526 | |||
527 | if (dev_priv->chipset != 0x40) { | ||
528 | cp_ctx(ctx, 0x403600, 1); | ||
529 | gr_def(ctx, 0x403600, 0x00000001); | ||
530 | } | ||
531 | cp_ctx(ctx, 0x403800, 1); | ||
532 | |||
533 | cp_ctx(ctx, 0x403c18, 1); | ||
534 | gr_def(ctx, 0x403c18, 0x00000001); | ||
535 | switch (dev_priv->chipset) { | ||
536 | case 0x46: | ||
537 | case 0x47: | ||
538 | case 0x49: | ||
539 | case 0x4b: | ||
540 | cp_ctx(ctx, 0x405018, 1); | ||
541 | gr_def(ctx, 0x405018, 0x08e00001); | ||
542 | cp_ctx(ctx, 0x405c24, 1); | ||
543 | gr_def(ctx, 0x405c24, 0x000e3000); | ||
544 | break; | ||
545 | } | ||
546 | if (dev_priv->chipset != 0x4e) | ||
547 | cp_ctx(ctx, 0x405800, 11); | ||
548 | cp_ctx(ctx, 0x407000, 1); | ||
549 | } | ||
550 | |||
551 | static void | ||
552 | nv40_graph_construct_state3d_3(struct nouveau_grctx *ctx) | ||
553 | { | ||
554 | int len = nv40_graph_4097(ctx->dev) ? 0x0684 : 0x0084; | ||
555 | |||
556 | cp_out (ctx, 0x300000); | ||
557 | cp_lsr (ctx, len - 4); | ||
558 | cp_bra (ctx, SWAP_DIRECTION, SAVE, cp_swap_state3d_3_is_save); | ||
559 | cp_lsr (ctx, len); | ||
560 | cp_name(ctx, cp_swap_state3d_3_is_save); | ||
561 | cp_out (ctx, 0x800001); | ||
562 | |||
563 | ctx->ctxvals_pos += len; | ||
564 | } | ||
565 | |||
566 | static void | ||
567 | nv40_graph_construct_shader(struct nouveau_grctx *ctx) | ||
568 | { | ||
569 | struct drm_device *dev = ctx->dev; | ||
570 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
571 | struct nouveau_gpuobj *obj = ctx->data; | ||
572 | int vs, vs_nr, vs_len, vs_nr_b0, vs_nr_b1, b0_offset, b1_offset; | ||
573 | int offset, i; | ||
574 | |||
575 | vs_nr = nv40_graph_vs_count(ctx->dev); | ||
576 | vs_nr_b0 = 363; | ||
577 | vs_nr_b1 = dev_priv->chipset == 0x40 ? 128 : 64; | ||
578 | if (dev_priv->chipset == 0x40) { | ||
579 | b0_offset = 0x2200/4; /* 33a0 */ | ||
580 | b1_offset = 0x55a0/4; /* 1500 */ | ||
581 | vs_len = 0x6aa0/4; | ||
582 | } else | ||
583 | if (dev_priv->chipset == 0x41 || dev_priv->chipset == 0x42) { | ||
584 | b0_offset = 0x2200/4; /* 2200 */ | ||
585 | b1_offset = 0x4400/4; /* 0b00 */ | ||
586 | vs_len = 0x4f00/4; | ||
587 | } else { | ||
588 | b0_offset = 0x1d40/4; /* 2200 */ | ||
589 | b1_offset = 0x3f40/4; /* 0b00 : 0a40 */ | ||
590 | vs_len = nv40_graph_4097(dev) ? 0x4a40/4 : 0x4980/4; | ||
591 | } | ||
592 | |||
593 | cp_lsr(ctx, vs_len * vs_nr + 0x300/4); | ||
594 | cp_out(ctx, nv40_graph_4097(dev) ? 0x800041 : 0x800029); | ||
595 | |||
596 | offset = ctx->ctxvals_pos; | ||
597 | ctx->ctxvals_pos += (0x0300/4 + (vs_nr * vs_len)); | ||
598 | |||
599 | if (ctx->mode != NOUVEAU_GRCTX_VALS) | ||
600 | return; | ||
601 | |||
602 | offset += 0x0280/4; | ||
603 | for (i = 0; i < 16; i++, offset += 2) | ||
604 | nv_wo32(dev, obj, offset, 0x3f800000); | ||
605 | |||
606 | for (vs = 0; vs < vs_nr; vs++, offset += vs_len) { | ||
607 | for (i = 0; i < vs_nr_b0 * 6; i += 6) | ||
608 | nv_wo32(dev, obj, offset + b0_offset + i, 0x00000001); | ||
609 | for (i = 0; i < vs_nr_b1 * 4; i += 4) | ||
610 | nv_wo32(dev, obj, offset + b1_offset + i, 0x3f800000); | ||
611 | } | ||
612 | } | ||
613 | |||
614 | void | ||
615 | nv40_grctx_init(struct nouveau_grctx *ctx) | ||
616 | { | ||
617 | /* decide whether we're loading/unloading the context */ | ||
618 | cp_bra (ctx, AUTO_SAVE, PENDING, cp_setup_save); | ||
619 | cp_bra (ctx, USER_SAVE, PENDING, cp_setup_save); | ||
620 | |||
621 | cp_name(ctx, cp_check_load); | ||
622 | cp_bra (ctx, AUTO_LOAD, PENDING, cp_setup_auto_load); | ||
623 | cp_bra (ctx, USER_LOAD, PENDING, cp_setup_load); | ||
624 | cp_bra (ctx, ALWAYS, TRUE, cp_exit); | ||
625 | |||
626 | /* setup for context load */ | ||
627 | cp_name(ctx, cp_setup_auto_load); | ||
628 | cp_wait(ctx, STATUS, IDLE); | ||
629 | cp_out (ctx, CP_NEXT_TO_SWAP); | ||
630 | cp_name(ctx, cp_setup_load); | ||
631 | cp_wait(ctx, STATUS, IDLE); | ||
632 | cp_set (ctx, SWAP_DIRECTION, LOAD); | ||
633 | cp_out (ctx, 0x00910880); /* ?? */ | ||
634 | cp_out (ctx, 0x00901ffe); /* ?? */ | ||
635 | cp_out (ctx, 0x01940000); /* ?? */ | ||
636 | cp_lsr (ctx, 0x20); | ||
637 | cp_out (ctx, 0x0060000b); /* ?? */ | ||
638 | cp_wait(ctx, UNK57, CLEAR); | ||
639 | cp_out (ctx, 0x0060000c); /* ?? */ | ||
640 | cp_bra (ctx, ALWAYS, TRUE, cp_swap_state); | ||
641 | |||
642 | /* setup for context save */ | ||
643 | cp_name(ctx, cp_setup_save); | ||
644 | cp_set (ctx, SWAP_DIRECTION, SAVE); | ||
645 | |||
646 | /* general PGRAPH state */ | ||
647 | cp_name(ctx, cp_swap_state); | ||
648 | cp_pos (ctx, 0x00020/4); | ||
649 | nv40_graph_construct_general(ctx); | ||
650 | cp_wait(ctx, STATUS, IDLE); | ||
651 | |||
652 | /* 3D state, block 1 */ | ||
653 | cp_bra (ctx, UNK54, CLEAR, cp_prepare_exit); | ||
654 | nv40_graph_construct_state3d(ctx); | ||
655 | cp_wait(ctx, STATUS, IDLE); | ||
656 | |||
657 | /* 3D state, block 2 */ | ||
658 | nv40_graph_construct_state3d_2(ctx); | ||
659 | |||
660 | /* Some other block of "random" state */ | ||
661 | nv40_graph_construct_state3d_3(ctx); | ||
662 | |||
663 | /* Per-vertex shader state */ | ||
664 | cp_pos (ctx, ctx->ctxvals_pos); | ||
665 | nv40_graph_construct_shader(ctx); | ||
666 | |||
667 | /* pre-exit state updates */ | ||
668 | cp_name(ctx, cp_prepare_exit); | ||
669 | cp_bra (ctx, SWAP_DIRECTION, SAVE, cp_check_load); | ||
670 | cp_bra (ctx, USER_SAVE, PENDING, cp_exit); | ||
671 | cp_out (ctx, CP_NEXT_TO_CURRENT); | ||
672 | |||
673 | cp_name(ctx, cp_exit); | ||
674 | cp_set (ctx, USER_SAVE, NOT_PENDING); | ||
675 | cp_set (ctx, USER_LOAD, NOT_PENDING); | ||
676 | cp_out (ctx, CP_END); | ||
677 | } | ||
678 | |||
diff --git a/drivers/gpu/drm/nouveau/nv50_crtc.c b/drivers/gpu/drm/nouveau/nv50_crtc.c index f8e28a1e44e7..118d3285fd8c 100644 --- a/drivers/gpu/drm/nouveau/nv50_crtc.c +++ b/drivers/gpu/drm/nouveau/nv50_crtc.c | |||
@@ -45,7 +45,7 @@ nv50_crtc_lut_load(struct drm_crtc *crtc) | |||
45 | void __iomem *lut = nvbo_kmap_obj_iovirtual(nv_crtc->lut.nvbo); | 45 | void __iomem *lut = nvbo_kmap_obj_iovirtual(nv_crtc->lut.nvbo); |
46 | int i; | 46 | int i; |
47 | 47 | ||
48 | NV_DEBUG(crtc->dev, "\n"); | 48 | NV_DEBUG_KMS(crtc->dev, "\n"); |
49 | 49 | ||
50 | for (i = 0; i < 256; i++) { | 50 | for (i = 0; i < 256; i++) { |
51 | writew(nv_crtc->lut.r[i] >> 2, lut + 8*i + 0); | 51 | writew(nv_crtc->lut.r[i] >> 2, lut + 8*i + 0); |
@@ -68,8 +68,8 @@ nv50_crtc_blank(struct nouveau_crtc *nv_crtc, bool blanked) | |||
68 | struct nouveau_channel *evo = dev_priv->evo; | 68 | struct nouveau_channel *evo = dev_priv->evo; |
69 | int index = nv_crtc->index, ret; | 69 | int index = nv_crtc->index, ret; |
70 | 70 | ||
71 | NV_DEBUG(dev, "index %d\n", nv_crtc->index); | 71 | NV_DEBUG_KMS(dev, "index %d\n", nv_crtc->index); |
72 | NV_DEBUG(dev, "%s\n", blanked ? "blanked" : "unblanked"); | 72 | NV_DEBUG_KMS(dev, "%s\n", blanked ? "blanked" : "unblanked"); |
73 | 73 | ||
74 | if (blanked) { | 74 | if (blanked) { |
75 | nv_crtc->cursor.hide(nv_crtc, false); | 75 | nv_crtc->cursor.hide(nv_crtc, false); |
@@ -139,7 +139,7 @@ nv50_crtc_set_dither(struct nouveau_crtc *nv_crtc, bool on, bool update) | |||
139 | struct nouveau_channel *evo = dev_priv->evo; | 139 | struct nouveau_channel *evo = dev_priv->evo; |
140 | int ret; | 140 | int ret; |
141 | 141 | ||
142 | NV_DEBUG(dev, "\n"); | 142 | NV_DEBUG_KMS(dev, "\n"); |
143 | 143 | ||
144 | ret = RING_SPACE(evo, 2 + (update ? 2 : 0)); | 144 | ret = RING_SPACE(evo, 2 + (update ? 2 : 0)); |
145 | if (ret) { | 145 | if (ret) { |
@@ -193,7 +193,7 @@ nv50_crtc_set_scale(struct nouveau_crtc *nv_crtc, int scaling_mode, bool update) | |||
193 | uint32_t outX, outY, horiz, vert; | 193 | uint32_t outX, outY, horiz, vert; |
194 | int ret; | 194 | int ret; |
195 | 195 | ||
196 | NV_DEBUG(dev, "\n"); | 196 | NV_DEBUG_KMS(dev, "\n"); |
197 | 197 | ||
198 | switch (scaling_mode) { | 198 | switch (scaling_mode) { |
199 | case DRM_MODE_SCALE_NONE: | 199 | case DRM_MODE_SCALE_NONE: |
@@ -301,7 +301,7 @@ nv50_crtc_destroy(struct drm_crtc *crtc) | |||
301 | struct drm_device *dev = crtc->dev; | 301 | struct drm_device *dev = crtc->dev; |
302 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 302 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
303 | 303 | ||
304 | NV_DEBUG(dev, "\n"); | 304 | NV_DEBUG_KMS(dev, "\n"); |
305 | 305 | ||
306 | if (!crtc) | 306 | if (!crtc) |
307 | return; | 307 | return; |
@@ -433,7 +433,7 @@ nv50_crtc_prepare(struct drm_crtc *crtc) | |||
433 | struct drm_device *dev = crtc->dev; | 433 | struct drm_device *dev = crtc->dev; |
434 | struct drm_encoder *encoder; | 434 | struct drm_encoder *encoder; |
435 | 435 | ||
436 | NV_DEBUG(dev, "index %d\n", nv_crtc->index); | 436 | NV_DEBUG_KMS(dev, "index %d\n", nv_crtc->index); |
437 | 437 | ||
438 | /* Disconnect all unused encoders. */ | 438 | /* Disconnect all unused encoders. */ |
439 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { | 439 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { |
@@ -458,7 +458,7 @@ nv50_crtc_commit(struct drm_crtc *crtc) | |||
458 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 458 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
459 | int ret; | 459 | int ret; |
460 | 460 | ||
461 | NV_DEBUG(dev, "index %d\n", nv_crtc->index); | 461 | NV_DEBUG_KMS(dev, "index %d\n", nv_crtc->index); |
462 | 462 | ||
463 | nv50_crtc_blank(nv_crtc, false); | 463 | nv50_crtc_blank(nv_crtc, false); |
464 | 464 | ||
@@ -497,7 +497,7 @@ nv50_crtc_do_mode_set_base(struct drm_crtc *crtc, int x, int y, | |||
497 | struct nouveau_framebuffer *fb = nouveau_framebuffer(drm_fb); | 497 | struct nouveau_framebuffer *fb = nouveau_framebuffer(drm_fb); |
498 | int ret, format; | 498 | int ret, format; |
499 | 499 | ||
500 | NV_DEBUG(dev, "index %d\n", nv_crtc->index); | 500 | NV_DEBUG_KMS(dev, "index %d\n", nv_crtc->index); |
501 | 501 | ||
502 | switch (drm_fb->depth) { | 502 | switch (drm_fb->depth) { |
503 | case 8: | 503 | case 8: |
@@ -612,7 +612,7 @@ nv50_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode, | |||
612 | 612 | ||
613 | *nv_crtc->mode = *adjusted_mode; | 613 | *nv_crtc->mode = *adjusted_mode; |
614 | 614 | ||
615 | NV_DEBUG(dev, "index %d\n", nv_crtc->index); | 615 | NV_DEBUG_KMS(dev, "index %d\n", nv_crtc->index); |
616 | 616 | ||
617 | hsync_dur = adjusted_mode->hsync_end - adjusted_mode->hsync_start; | 617 | hsync_dur = adjusted_mode->hsync_end - adjusted_mode->hsync_start; |
618 | vsync_dur = adjusted_mode->vsync_end - adjusted_mode->vsync_start; | 618 | vsync_dur = adjusted_mode->vsync_end - adjusted_mode->vsync_start; |
@@ -706,7 +706,7 @@ nv50_crtc_create(struct drm_device *dev, int index) | |||
706 | struct nouveau_crtc *nv_crtc = NULL; | 706 | struct nouveau_crtc *nv_crtc = NULL; |
707 | int ret, i; | 707 | int ret, i; |
708 | 708 | ||
709 | NV_DEBUG(dev, "\n"); | 709 | NV_DEBUG_KMS(dev, "\n"); |
710 | 710 | ||
711 | nv_crtc = kzalloc(sizeof(*nv_crtc), GFP_KERNEL); | 711 | nv_crtc = kzalloc(sizeof(*nv_crtc), GFP_KERNEL); |
712 | if (!nv_crtc) | 712 | if (!nv_crtc) |
diff --git a/drivers/gpu/drm/nouveau/nv50_cursor.c b/drivers/gpu/drm/nouveau/nv50_cursor.c index e2e79a8f220d..753e723adb3a 100644 --- a/drivers/gpu/drm/nouveau/nv50_cursor.c +++ b/drivers/gpu/drm/nouveau/nv50_cursor.c | |||
@@ -41,7 +41,7 @@ nv50_cursor_show(struct nouveau_crtc *nv_crtc, bool update) | |||
41 | struct drm_device *dev = nv_crtc->base.dev; | 41 | struct drm_device *dev = nv_crtc->base.dev; |
42 | int ret; | 42 | int ret; |
43 | 43 | ||
44 | NV_DEBUG(dev, "\n"); | 44 | NV_DEBUG_KMS(dev, "\n"); |
45 | 45 | ||
46 | if (update && nv_crtc->cursor.visible) | 46 | if (update && nv_crtc->cursor.visible) |
47 | return; | 47 | return; |
@@ -76,7 +76,7 @@ nv50_cursor_hide(struct nouveau_crtc *nv_crtc, bool update) | |||
76 | struct drm_device *dev = nv_crtc->base.dev; | 76 | struct drm_device *dev = nv_crtc->base.dev; |
77 | int ret; | 77 | int ret; |
78 | 78 | ||
79 | NV_DEBUG(dev, "\n"); | 79 | NV_DEBUG_KMS(dev, "\n"); |
80 | 80 | ||
81 | if (update && !nv_crtc->cursor.visible) | 81 | if (update && !nv_crtc->cursor.visible) |
82 | return; | 82 | return; |
@@ -116,7 +116,7 @@ nv50_cursor_set_pos(struct nouveau_crtc *nv_crtc, int x, int y) | |||
116 | static void | 116 | static void |
117 | nv50_cursor_set_offset(struct nouveau_crtc *nv_crtc, uint32_t offset) | 117 | nv50_cursor_set_offset(struct nouveau_crtc *nv_crtc, uint32_t offset) |
118 | { | 118 | { |
119 | NV_DEBUG(nv_crtc->base.dev, "\n"); | 119 | NV_DEBUG_KMS(nv_crtc->base.dev, "\n"); |
120 | if (offset == nv_crtc->cursor.offset) | 120 | if (offset == nv_crtc->cursor.offset) |
121 | return; | 121 | return; |
122 | 122 | ||
@@ -143,7 +143,7 @@ nv50_cursor_fini(struct nouveau_crtc *nv_crtc) | |||
143 | struct drm_device *dev = nv_crtc->base.dev; | 143 | struct drm_device *dev = nv_crtc->base.dev; |
144 | int idx = nv_crtc->index; | 144 | int idx = nv_crtc->index; |
145 | 145 | ||
146 | NV_DEBUG(dev, "\n"); | 146 | NV_DEBUG_KMS(dev, "\n"); |
147 | 147 | ||
148 | nv_wr32(dev, NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(idx), 0); | 148 | nv_wr32(dev, NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(idx), 0); |
149 | if (!nv_wait(NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(idx), | 149 | if (!nv_wait(NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(idx), |
diff --git a/drivers/gpu/drm/nouveau/nv50_dac.c b/drivers/gpu/drm/nouveau/nv50_dac.c index fb5838e3be24..f08f042a8e10 100644 --- a/drivers/gpu/drm/nouveau/nv50_dac.c +++ b/drivers/gpu/drm/nouveau/nv50_dac.c | |||
@@ -44,7 +44,7 @@ nv50_dac_disconnect(struct nouveau_encoder *nv_encoder) | |||
44 | struct nouveau_channel *evo = dev_priv->evo; | 44 | struct nouveau_channel *evo = dev_priv->evo; |
45 | int ret; | 45 | int ret; |
46 | 46 | ||
47 | NV_DEBUG(dev, "Disconnecting DAC %d\n", nv_encoder->or); | 47 | NV_DEBUG_KMS(dev, "Disconnecting DAC %d\n", nv_encoder->or); |
48 | 48 | ||
49 | ret = RING_SPACE(evo, 2); | 49 | ret = RING_SPACE(evo, 2); |
50 | if (ret) { | 50 | if (ret) { |
@@ -81,11 +81,11 @@ nv50_dac_detect(struct drm_encoder *encoder, struct drm_connector *connector) | |||
81 | /* Use bios provided value if possible. */ | 81 | /* Use bios provided value if possible. */ |
82 | if (dev_priv->vbios->dactestval) { | 82 | if (dev_priv->vbios->dactestval) { |
83 | load_pattern = dev_priv->vbios->dactestval; | 83 | load_pattern = dev_priv->vbios->dactestval; |
84 | NV_DEBUG(dev, "Using bios provided load_pattern of %d\n", | 84 | NV_DEBUG_KMS(dev, "Using bios provided load_pattern of %d\n", |
85 | load_pattern); | 85 | load_pattern); |
86 | } else { | 86 | } else { |
87 | load_pattern = 340; | 87 | load_pattern = 340; |
88 | NV_DEBUG(dev, "Using default load_pattern of %d\n", | 88 | NV_DEBUG_KMS(dev, "Using default load_pattern of %d\n", |
89 | load_pattern); | 89 | load_pattern); |
90 | } | 90 | } |
91 | 91 | ||
@@ -103,9 +103,9 @@ nv50_dac_detect(struct drm_encoder *encoder, struct drm_connector *connector) | |||
103 | status = connector_status_connected; | 103 | status = connector_status_connected; |
104 | 104 | ||
105 | if (status == connector_status_connected) | 105 | if (status == connector_status_connected) |
106 | NV_DEBUG(dev, "Load was detected on output with or %d\n", or); | 106 | NV_DEBUG_KMS(dev, "Load was detected on output with or %d\n", or); |
107 | else | 107 | else |
108 | NV_DEBUG(dev, "Load was not detected on output with or %d\n", or); | 108 | NV_DEBUG_KMS(dev, "Load was not detected on output with or %d\n", or); |
109 | 109 | ||
110 | return status; | 110 | return status; |
111 | } | 111 | } |
@@ -118,7 +118,7 @@ nv50_dac_dpms(struct drm_encoder *encoder, int mode) | |||
118 | uint32_t val; | 118 | uint32_t val; |
119 | int or = nv_encoder->or; | 119 | int or = nv_encoder->or; |
120 | 120 | ||
121 | NV_DEBUG(dev, "or %d mode %d\n", or, mode); | 121 | NV_DEBUG_KMS(dev, "or %d mode %d\n", or, mode); |
122 | 122 | ||
123 | /* wait for it to be done */ | 123 | /* wait for it to be done */ |
124 | if (!nv_wait(NV50_PDISPLAY_DAC_DPMS_CTRL(or), | 124 | if (!nv_wait(NV50_PDISPLAY_DAC_DPMS_CTRL(or), |
@@ -173,7 +173,7 @@ nv50_dac_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode, | |||
173 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); | 173 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); |
174 | struct nouveau_connector *connector; | 174 | struct nouveau_connector *connector; |
175 | 175 | ||
176 | NV_DEBUG(encoder->dev, "or %d\n", nv_encoder->or); | 176 | NV_DEBUG_KMS(encoder->dev, "or %d\n", nv_encoder->or); |
177 | 177 | ||
178 | connector = nouveau_encoder_connector_get(nv_encoder); | 178 | connector = nouveau_encoder_connector_get(nv_encoder); |
179 | if (!connector) { | 179 | if (!connector) { |
@@ -213,7 +213,7 @@ nv50_dac_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode, | |||
213 | uint32_t mode_ctl = 0, mode_ctl2 = 0; | 213 | uint32_t mode_ctl = 0, mode_ctl2 = 0; |
214 | int ret; | 214 | int ret; |
215 | 215 | ||
216 | NV_DEBUG(dev, "or %d\n", nv_encoder->or); | 216 | NV_DEBUG_KMS(dev, "or %d\n", nv_encoder->or); |
217 | 217 | ||
218 | nv50_dac_dpms(encoder, DRM_MODE_DPMS_ON); | 218 | nv50_dac_dpms(encoder, DRM_MODE_DPMS_ON); |
219 | 219 | ||
@@ -264,7 +264,7 @@ nv50_dac_destroy(struct drm_encoder *encoder) | |||
264 | if (!encoder) | 264 | if (!encoder) |
265 | return; | 265 | return; |
266 | 266 | ||
267 | NV_DEBUG(encoder->dev, "\n"); | 267 | NV_DEBUG_KMS(encoder->dev, "\n"); |
268 | 268 | ||
269 | drm_encoder_cleanup(encoder); | 269 | drm_encoder_cleanup(encoder); |
270 | kfree(nv_encoder); | 270 | kfree(nv_encoder); |
@@ -280,7 +280,7 @@ nv50_dac_create(struct drm_device *dev, struct dcb_entry *entry) | |||
280 | struct nouveau_encoder *nv_encoder; | 280 | struct nouveau_encoder *nv_encoder; |
281 | struct drm_encoder *encoder; | 281 | struct drm_encoder *encoder; |
282 | 282 | ||
283 | NV_DEBUG(dev, "\n"); | 283 | NV_DEBUG_KMS(dev, "\n"); |
284 | NV_INFO(dev, "Detected a DAC output\n"); | 284 | NV_INFO(dev, "Detected a DAC output\n"); |
285 | 285 | ||
286 | nv_encoder = kzalloc(sizeof(*nv_encoder), GFP_KERNEL); | 286 | nv_encoder = kzalloc(sizeof(*nv_encoder), GFP_KERNEL); |
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c index 12c5ee63495b..a9263d92a231 100644 --- a/drivers/gpu/drm/nouveau/nv50_display.c +++ b/drivers/gpu/drm/nouveau/nv50_display.c | |||
@@ -188,7 +188,7 @@ nv50_display_init(struct drm_device *dev) | |||
188 | uint64_t start; | 188 | uint64_t start; |
189 | int ret, i; | 189 | int ret, i; |
190 | 190 | ||
191 | NV_DEBUG(dev, "\n"); | 191 | NV_DEBUG_KMS(dev, "\n"); |
192 | 192 | ||
193 | nv_wr32(dev, 0x00610184, nv_rd32(dev, 0x00614004)); | 193 | nv_wr32(dev, 0x00610184, nv_rd32(dev, 0x00614004)); |
194 | /* | 194 | /* |
@@ -232,7 +232,7 @@ nv50_display_init(struct drm_device *dev) | |||
232 | nv_wr32(dev, NV50_PDISPLAY_UNK_380, 0); | 232 | nv_wr32(dev, NV50_PDISPLAY_UNK_380, 0); |
233 | /* RAM is clamped to 256 MiB. */ | 233 | /* RAM is clamped to 256 MiB. */ |
234 | ram_amount = nouveau_mem_fb_amount(dev); | 234 | ram_amount = nouveau_mem_fb_amount(dev); |
235 | NV_DEBUG(dev, "ram_amount %d\n", ram_amount); | 235 | NV_DEBUG_KMS(dev, "ram_amount %d\n", ram_amount); |
236 | if (ram_amount > 256*1024*1024) | 236 | if (ram_amount > 256*1024*1024) |
237 | ram_amount = 256*1024*1024; | 237 | ram_amount = 256*1024*1024; |
238 | nv_wr32(dev, NV50_PDISPLAY_RAM_AMOUNT, ram_amount - 1); | 238 | nv_wr32(dev, NV50_PDISPLAY_RAM_AMOUNT, ram_amount - 1); |
@@ -398,7 +398,7 @@ static int nv50_display_disable(struct drm_device *dev) | |||
398 | struct drm_crtc *drm_crtc; | 398 | struct drm_crtc *drm_crtc; |
399 | int ret, i; | 399 | int ret, i; |
400 | 400 | ||
401 | NV_DEBUG(dev, "\n"); | 401 | NV_DEBUG_KMS(dev, "\n"); |
402 | 402 | ||
403 | list_for_each_entry(drm_crtc, &dev->mode_config.crtc_list, head) { | 403 | list_for_each_entry(drm_crtc, &dev->mode_config.crtc_list, head) { |
404 | struct nouveau_crtc *crtc = nouveau_crtc(drm_crtc); | 404 | struct nouveau_crtc *crtc = nouveau_crtc(drm_crtc); |
@@ -469,7 +469,7 @@ int nv50_display_create(struct drm_device *dev) | |||
469 | uint32_t connector[16] = {}; | 469 | uint32_t connector[16] = {}; |
470 | int ret, i; | 470 | int ret, i; |
471 | 471 | ||
472 | NV_DEBUG(dev, "\n"); | 472 | NV_DEBUG_KMS(dev, "\n"); |
473 | 473 | ||
474 | /* init basic kernel modesetting */ | 474 | /* init basic kernel modesetting */ |
475 | drm_mode_config_init(dev); | 475 | drm_mode_config_init(dev); |
@@ -573,7 +573,7 @@ int nv50_display_destroy(struct drm_device *dev) | |||
573 | { | 573 | { |
574 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 574 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
575 | 575 | ||
576 | NV_DEBUG(dev, "\n"); | 576 | NV_DEBUG_KMS(dev, "\n"); |
577 | 577 | ||
578 | drm_mode_config_cleanup(dev); | 578 | drm_mode_config_cleanup(dev); |
579 | 579 | ||
@@ -617,7 +617,7 @@ nv50_display_irq_head(struct drm_device *dev, int *phead, | |||
617 | * CRTC separately, and submission will be blocked by the GPU | 617 | * CRTC separately, and submission will be blocked by the GPU |
618 | * until we handle each in turn. | 618 | * until we handle each in turn. |
619 | */ | 619 | */ |
620 | NV_DEBUG(dev, "0x610030: 0x%08x\n", unk30); | 620 | NV_DEBUG_KMS(dev, "0x610030: 0x%08x\n", unk30); |
621 | head = ffs((unk30 >> 9) & 3) - 1; | 621 | head = ffs((unk30 >> 9) & 3) - 1; |
622 | if (head < 0) | 622 | if (head < 0) |
623 | return -EINVAL; | 623 | return -EINVAL; |
@@ -661,7 +661,7 @@ nv50_display_irq_head(struct drm_device *dev, int *phead, | |||
661 | or = i; | 661 | or = i; |
662 | } | 662 | } |
663 | 663 | ||
664 | NV_DEBUG(dev, "type %d, or %d\n", type, or); | 664 | NV_DEBUG_KMS(dev, "type %d, or %d\n", type, or); |
665 | if (type == OUTPUT_ANY) { | 665 | if (type == OUTPUT_ANY) { |
666 | NV_ERROR(dev, "unknown encoder!!\n"); | 666 | NV_ERROR(dev, "unknown encoder!!\n"); |
667 | return -1; | 667 | return -1; |
@@ -811,7 +811,7 @@ nv50_display_unk20_handler(struct drm_device *dev) | |||
811 | pclk = nv_rd32(dev, NV50_PDISPLAY_CRTC_P(head, CLOCK)) & 0x3fffff; | 811 | pclk = nv_rd32(dev, NV50_PDISPLAY_CRTC_P(head, CLOCK)) & 0x3fffff; |
812 | script = nv50_display_script_select(dev, dcbent, pclk); | 812 | script = nv50_display_script_select(dev, dcbent, pclk); |
813 | 813 | ||
814 | NV_DEBUG(dev, "head %d pxclk: %dKHz\n", head, pclk); | 814 | NV_DEBUG_KMS(dev, "head %d pxclk: %dKHz\n", head, pclk); |
815 | 815 | ||
816 | if (dcbent->type != OUTPUT_DP) | 816 | if (dcbent->type != OUTPUT_DP) |
817 | nouveau_bios_run_display_table(dev, dcbent, 0, -2); | 817 | nouveau_bios_run_display_table(dev, dcbent, 0, -2); |
@@ -870,7 +870,7 @@ nv50_display_irq_handler_bh(struct work_struct *work) | |||
870 | uint32_t intr0 = nv_rd32(dev, NV50_PDISPLAY_INTR_0); | 870 | uint32_t intr0 = nv_rd32(dev, NV50_PDISPLAY_INTR_0); |
871 | uint32_t intr1 = nv_rd32(dev, NV50_PDISPLAY_INTR_1); | 871 | uint32_t intr1 = nv_rd32(dev, NV50_PDISPLAY_INTR_1); |
872 | 872 | ||
873 | NV_DEBUG(dev, "PDISPLAY_INTR_BH 0x%08x 0x%08x\n", intr0, intr1); | 873 | NV_DEBUG_KMS(dev, "PDISPLAY_INTR_BH 0x%08x 0x%08x\n", intr0, intr1); |
874 | 874 | ||
875 | if (intr1 & NV50_PDISPLAY_INTR_1_CLK_UNK10) | 875 | if (intr1 & NV50_PDISPLAY_INTR_1_CLK_UNK10) |
876 | nv50_display_unk10_handler(dev); | 876 | nv50_display_unk10_handler(dev); |
@@ -974,7 +974,7 @@ nv50_display_irq_handler(struct drm_device *dev) | |||
974 | uint32_t intr1 = nv_rd32(dev, NV50_PDISPLAY_INTR_1); | 974 | uint32_t intr1 = nv_rd32(dev, NV50_PDISPLAY_INTR_1); |
975 | uint32_t clock; | 975 | uint32_t clock; |
976 | 976 | ||
977 | NV_DEBUG(dev, "PDISPLAY_INTR 0x%08x 0x%08x\n", intr0, intr1); | 977 | NV_DEBUG_KMS(dev, "PDISPLAY_INTR 0x%08x 0x%08x\n", intr0, intr1); |
978 | 978 | ||
979 | if (!intr0 && !(intr1 & ~delayed)) | 979 | if (!intr0 && !(intr1 & ~delayed)) |
980 | break; | 980 | break; |
diff --git a/drivers/gpu/drm/nouveau/nv50_fifo.c b/drivers/gpu/drm/nouveau/nv50_fifo.c index 77ae1aaa0bce..b7282284f080 100644 --- a/drivers/gpu/drm/nouveau/nv50_fifo.c +++ b/drivers/gpu/drm/nouveau/nv50_fifo.c | |||
@@ -416,7 +416,7 @@ nv50_fifo_unload_context(struct drm_device *dev) | |||
416 | NV_DEBUG(dev, "\n"); | 416 | NV_DEBUG(dev, "\n"); |
417 | 417 | ||
418 | chid = pfifo->channel_id(dev); | 418 | chid = pfifo->channel_id(dev); |
419 | if (chid < 0 || chid >= dev_priv->engine.fifo.channels) | 419 | if (chid < 1 || chid >= dev_priv->engine.fifo.channels - 1) |
420 | return 0; | 420 | return 0; |
421 | 421 | ||
422 | chan = dev_priv->fifos[chid]; | 422 | chan = dev_priv->fifos[chid]; |
diff --git a/drivers/gpu/drm/nouveau/nv50_graph.c b/drivers/gpu/drm/nouveau/nv50_graph.c index 177d8229336f..ca79f32be44c 100644 --- a/drivers/gpu/drm/nouveau/nv50_graph.c +++ b/drivers/gpu/drm/nouveau/nv50_graph.c | |||
@@ -107,9 +107,13 @@ nv50_graph_init_regs(struct drm_device *dev) | |||
107 | static int | 107 | static int |
108 | nv50_graph_init_ctxctl(struct drm_device *dev) | 108 | nv50_graph_init_ctxctl(struct drm_device *dev) |
109 | { | 109 | { |
110 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
111 | |||
110 | NV_DEBUG(dev, "\n"); | 112 | NV_DEBUG(dev, "\n"); |
111 | 113 | ||
112 | nv40_grctx_init(dev); | 114 | nouveau_grctx_prog_load(dev); |
115 | if (!dev_priv->engine.graph.ctxprog) | ||
116 | dev_priv->engine.graph.accel_blocked = true; | ||
113 | 117 | ||
114 | nv_wr32(dev, 0x400320, 4); | 118 | nv_wr32(dev, 0x400320, 4); |
115 | nv_wr32(dev, NV40_PGRAPH_CTXCTL_CUR, 0); | 119 | nv_wr32(dev, NV40_PGRAPH_CTXCTL_CUR, 0); |
@@ -140,7 +144,7 @@ void | |||
140 | nv50_graph_takedown(struct drm_device *dev) | 144 | nv50_graph_takedown(struct drm_device *dev) |
141 | { | 145 | { |
142 | NV_DEBUG(dev, "\n"); | 146 | NV_DEBUG(dev, "\n"); |
143 | nv40_grctx_fini(dev); | 147 | nouveau_grctx_fini(dev); |
144 | } | 148 | } |
145 | 149 | ||
146 | void | 150 | void |
@@ -207,7 +211,7 @@ nv50_graph_create_context(struct nouveau_channel *chan) | |||
207 | dev_priv->engine.instmem.finish_access(dev); | 211 | dev_priv->engine.instmem.finish_access(dev); |
208 | 212 | ||
209 | dev_priv->engine.instmem.prepare_access(dev, true); | 213 | dev_priv->engine.instmem.prepare_access(dev, true); |
210 | nv40_grctx_vals_load(dev, ctx); | 214 | nouveau_grctx_vals_load(dev, ctx); |
211 | nv_wo32(dev, ctx, 0x00000/4, chan->ramin->instance >> 12); | 215 | nv_wo32(dev, ctx, 0x00000/4, chan->ramin->instance >> 12); |
212 | if ((dev_priv->chipset & 0xf0) == 0xa0) | 216 | if ((dev_priv->chipset & 0xf0) == 0xa0) |
213 | nv_wo32(dev, ctx, 0x00004/4, 0x00000000); | 217 | nv_wo32(dev, ctx, 0x00004/4, 0x00000000); |
diff --git a/drivers/gpu/drm/nouveau/nv50_sor.c b/drivers/gpu/drm/nouveau/nv50_sor.c index 8c280463a664..e395c16d30f5 100644 --- a/drivers/gpu/drm/nouveau/nv50_sor.c +++ b/drivers/gpu/drm/nouveau/nv50_sor.c | |||
@@ -44,7 +44,7 @@ nv50_sor_disconnect(struct nouveau_encoder *nv_encoder) | |||
44 | struct nouveau_channel *evo = dev_priv->evo; | 44 | struct nouveau_channel *evo = dev_priv->evo; |
45 | int ret; | 45 | int ret; |
46 | 46 | ||
47 | NV_DEBUG(dev, "Disconnecting SOR %d\n", nv_encoder->or); | 47 | NV_DEBUG_KMS(dev, "Disconnecting SOR %d\n", nv_encoder->or); |
48 | 48 | ||
49 | ret = RING_SPACE(evo, 2); | 49 | ret = RING_SPACE(evo, 2); |
50 | if (ret) { | 50 | if (ret) { |
@@ -70,7 +70,7 @@ nv50_sor_dp_link_train(struct drm_encoder *encoder) | |||
70 | } | 70 | } |
71 | 71 | ||
72 | if (dpe->script0) { | 72 | if (dpe->script0) { |
73 | NV_DEBUG(dev, "SOR-%d: running DP script 0\n", nv_encoder->or); | 73 | NV_DEBUG_KMS(dev, "SOR-%d: running DP script 0\n", nv_encoder->or); |
74 | nouveau_bios_run_init_table(dev, le16_to_cpu(dpe->script0), | 74 | nouveau_bios_run_init_table(dev, le16_to_cpu(dpe->script0), |
75 | nv_encoder->dcb); | 75 | nv_encoder->dcb); |
76 | } | 76 | } |
@@ -79,7 +79,7 @@ nv50_sor_dp_link_train(struct drm_encoder *encoder) | |||
79 | NV_ERROR(dev, "SOR-%d: link training failed\n", nv_encoder->or); | 79 | NV_ERROR(dev, "SOR-%d: link training failed\n", nv_encoder->or); |
80 | 80 | ||
81 | if (dpe->script1) { | 81 | if (dpe->script1) { |
82 | NV_DEBUG(dev, "SOR-%d: running DP script 1\n", nv_encoder->or); | 82 | NV_DEBUG_KMS(dev, "SOR-%d: running DP script 1\n", nv_encoder->or); |
83 | nouveau_bios_run_init_table(dev, le16_to_cpu(dpe->script1), | 83 | nouveau_bios_run_init_table(dev, le16_to_cpu(dpe->script1), |
84 | nv_encoder->dcb); | 84 | nv_encoder->dcb); |
85 | } | 85 | } |
@@ -93,7 +93,7 @@ nv50_sor_dpms(struct drm_encoder *encoder, int mode) | |||
93 | uint32_t val; | 93 | uint32_t val; |
94 | int or = nv_encoder->or; | 94 | int or = nv_encoder->or; |
95 | 95 | ||
96 | NV_DEBUG(dev, "or %d mode %d\n", or, mode); | 96 | NV_DEBUG_KMS(dev, "or %d mode %d\n", or, mode); |
97 | 97 | ||
98 | /* wait for it to be done */ | 98 | /* wait for it to be done */ |
99 | if (!nv_wait(NV50_PDISPLAY_SOR_DPMS_CTRL(or), | 99 | if (!nv_wait(NV50_PDISPLAY_SOR_DPMS_CTRL(or), |
@@ -142,7 +142,7 @@ nv50_sor_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode, | |||
142 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); | 142 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); |
143 | struct nouveau_connector *connector; | 143 | struct nouveau_connector *connector; |
144 | 144 | ||
145 | NV_DEBUG(encoder->dev, "or %d\n", nv_encoder->or); | 145 | NV_DEBUG_KMS(encoder->dev, "or %d\n", nv_encoder->or); |
146 | 146 | ||
147 | connector = nouveau_encoder_connector_get(nv_encoder); | 147 | connector = nouveau_encoder_connector_get(nv_encoder); |
148 | if (!connector) { | 148 | if (!connector) { |
@@ -182,7 +182,7 @@ nv50_sor_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode, | |||
182 | uint32_t mode_ctl = 0; | 182 | uint32_t mode_ctl = 0; |
183 | int ret; | 183 | int ret; |
184 | 184 | ||
185 | NV_DEBUG(dev, "or %d\n", nv_encoder->or); | 185 | NV_DEBUG_KMS(dev, "or %d\n", nv_encoder->or); |
186 | 186 | ||
187 | nv50_sor_dpms(encoder, DRM_MODE_DPMS_ON); | 187 | nv50_sor_dpms(encoder, DRM_MODE_DPMS_ON); |
188 | 188 | ||
@@ -246,7 +246,7 @@ nv50_sor_destroy(struct drm_encoder *encoder) | |||
246 | if (!encoder) | 246 | if (!encoder) |
247 | return; | 247 | return; |
248 | 248 | ||
249 | NV_DEBUG(encoder->dev, "\n"); | 249 | NV_DEBUG_KMS(encoder->dev, "\n"); |
250 | 250 | ||
251 | drm_encoder_cleanup(encoder); | 251 | drm_encoder_cleanup(encoder); |
252 | 252 | ||
@@ -265,7 +265,7 @@ nv50_sor_create(struct drm_device *dev, struct dcb_entry *entry) | |||
265 | bool dum; | 265 | bool dum; |
266 | int type; | 266 | int type; |
267 | 267 | ||
268 | NV_DEBUG(dev, "\n"); | 268 | NV_DEBUG_KMS(dev, "\n"); |
269 | 269 | ||
270 | switch (entry->type) { | 270 | switch (entry->type) { |
271 | case OUTPUT_TMDS: | 271 | case OUTPUT_TMDS: |