diff options
author | Marcin KoĆcielnicki <koriakin@0x04.net> | 2016-12-26 22:21:39 +0000 |
---|---|---|
committer | Marcin KoĆcielnicki <koriakin@0x04.net> | 2016-12-26 22:21:39 +0000 |
commit | 254066fd86aba05f55916c14af6f8ff4404ab6ca (patch) | |
tree | 71661112e28dcc3373c7aa333c58261453c27084 | |
parent | df2ad5c55885ed4b0fd72931b1ae86f083386deb (diff) |
hwtest/pgraph: Convert remaining celsius mthd tests.
-rw-r--r-- | hwtest/nv04_pgraph.cc | 234 | ||||
-rw-r--r-- | hwtest/pgraph_class_celsius.cc | 67 |
2 files changed, 66 insertions, 235 deletions
diff --git a/hwtest/nv04_pgraph.cc b/hwtest/nv04_pgraph.cc index a5b6a3d0..c0aadfbd 100644 --- a/hwtest/nv04_pgraph.cc +++ b/hwtest/nv04_pgraph.cc @@ -192,16 +192,6 @@ static void nv04_pgraph_mthd(struct pgraph_state *state, uint32_t grobj[4], int state->trap_data[1] = state->fifo_data_st2[1]; } -static uint32_t get_random_celsius(struct hwtest_ctx *ctx) { - uint32_t classes[] = {0x56, 0x96, 0x98, 0x99}; - if (!nv04_pgraph_is_nv15p(&ctx->chipset)) - return 0x56; - else if (!nv04_pgraph_is_nv17p(&ctx->chipset)) - return classes[jrand48(ctx->rand48) & 1]; - else - return classes[jrand48(ctx->rand48) & 3]; -} - static int test_invalid_class(struct hwtest_ctx *ctx) { int i; for (int cls = 0; cls < 0x100; cls++) { @@ -314,213 +304,6 @@ static int test_invalid_class(struct hwtest_ctx *ctx) { return HWTEST_RES_PASS; } -static int test_invalid_mthd_celsius(struct hwtest_ctx *ctx) { - if (ctx->chipset.card_type < 0x10) - return HWTEST_RES_NA; - for (int cls : {0x85, 0x56, 0x96, 0x98, 0x99}) { - if (cls == 0x96 && !nv04_pgraph_is_nv15p(&ctx->chipset)) - continue; - if ((cls == 0x98 || cls == 0x99) && !nv04_pgraph_is_nv17p(&ctx->chipset)) - continue; - for (int mthd = 0; mthd < 0x2000; mthd += 4) { - if (mthd == 0) - continue; - if (mthd >= 0x100 && mthd <= 0x110) - continue; - if (mthd == 0x114 && cls >= 0x96) - continue; - if ((mthd >= 0x120 && mthd <= 0x130) && cls >= 0x96) - continue; - if (mthd == 0x140 && ctx->chipset.card_type >= 0x10) - continue; - if (mthd >= 0x180 && mthd <= 0x198) - continue; - if (mthd >= 0x1ac && mthd <= 0x1b0 && cls == 0x99) - continue; - if (mthd >= 0x200 && mthd < 0x258) - continue; - if (mthd >= 0x258 && mthd < 0x260 && cls == 0x99) - continue; - if (mthd >= 0x260 && mthd < 0x2b8) - continue; - if (mthd >= 0x2b8 && mthd < 0x2c0 && cls == 0x99) - continue; - if (mthd >= 0x2c0 && mthd < 0x3fc) - continue; - if (mthd == 0x3fc && cls == 0x99) - continue; - if (mthd >= 0x400 && mthd < 0x5c0) - continue; - if (mthd >= 0x600 && mthd < 0x69c) - continue; - if (mthd >= 0x6a0 && mthd < 0x6b8) - continue; - if (mthd >= 0x6c4 && mthd < 0x6d0) - continue; - if (mthd >= 0x6e8 && mthd < 0x728) - continue; - if ((mthd & 0x1c7c) >= 0x800 && (mthd & 0x1c7c) < 0x874) - continue; - if (mthd >= 0xc00 && mthd < 0xc0c) - continue; - if (mthd >= 0xc10 && mthd < 0xc3c) - continue; - if (mthd >= 0xc40 && mthd < 0xc9c) - continue; - if (mthd >= 0xca0 && mthd < 0xcc4) - continue; - if (mthd >= 0xcc8 && mthd < 0xce8) - continue; - if (mthd >= 0xcec && mthd < 0xd40) - continue; - if ((mthd >= 0xd40 && mthd <= 0xd44) && cls >= 0x96) - continue; - if (mthd >= 0xd54 && mthd < 0xd88 && cls == 0x99) - continue; - if (mthd >= 0xdfc && mthd < 0x1000) - continue; - if (mthd >= 0x10fc && mthd < 0x1200) - continue; - if (mthd >= 0x13fc && mthd < 0x1600) - continue; - if (mthd >= 0x17fc) - continue; - for (int i = 0; i < 10; i++) { - uint32_t val = jrand48(ctx->rand48); - uint32_t addr = (jrand48(ctx->rand48) & 0xe000) | mthd; - struct pgraph_state orig, exp, real; - nv04_pgraph_gen_state(ctx, &orig); - orig.notify &= ~0x10000; - uint32_t grobj[4]; - nv04_pgraph_prep_mthd(ctx, grobj, &orig, cls, addr, val); - nv04_pgraph_load_state(ctx, &orig); - exp = orig; - nv04_pgraph_mthd(&exp, grobj); - nv04_pgraph_blowup(&exp, 0x0040); - nv04_pgraph_dump_state(ctx, &real); - if (nv04_pgraph_cmp_state(&orig, &exp, &real)) { - printf("Iter %d mthd %02x.%04x %08x\n", i, cls, addr, val); - return HWTEST_RES_FAIL; - } - } - } - } - return HWTEST_RES_PASS; -} - -static int test_mthd_celsius_unk290(struct hwtest_ctx *ctx) { - int i; - for (i = 0; i < 10000; i++) { - uint32_t val = jrand48(ctx->rand48); - if (jrand48(ctx->rand48) & 1) { - val &= ~0xceeeeefe; - if (jrand48(ctx->rand48) & 1) { - val |= 1 << (jrand48(ctx->rand48) & 0x1f); - } - if (jrand48(ctx->rand48) & 1) { - val |= 1 << (jrand48(ctx->rand48) & 0x1f); - } - } - uint32_t cls = get_random_celsius(ctx); - uint32_t mthd = 0x290; - int trapbit = 30; - uint32_t addr = (jrand48(ctx->rand48) & 0xe000) | mthd; - struct pgraph_state orig, exp, real; - nv04_pgraph_gen_state(ctx, &orig); - orig.notify &= ~0x10000; - uint32_t grobj[4]; - nv04_pgraph_prep_mthd(ctx, grobj, &orig, cls, addr, val); - nv04_pgraph_load_state(ctx, &orig); - exp = orig; - nv04_pgraph_mthd(&exp, grobj, trapbit); - if (!extr(exp.intr, 4, 1)) { - bool bad = false; - if (val & 0xceeeeefe) - bad = true; - if (extr(val, 28, 2) && cls != 0x99) - bad = true; - if (extr(val, 8, 1) && !extr(val, 16, 1)) - bad = true; - if (extr(exp.debug[3], 20, 1) && bad) - nv04_pgraph_blowup(&exp, 2); - insrt(exp.valid[1], 17, 1, 1); - if (!exp.intr) { - insrt(exp.celsius_config_a, 25, 1, extr(val, 0, 1)); - insrt(exp.celsius_config_a, 23, 1, extr(val, 16, 1)); - insrt(exp.celsius_config_b, 2, 1, extr(val, 24, 1)); - insrt(exp.celsius_config_b, 6, 1, extr(val, 20, 1)); - insrt(exp.celsius_config_b, 10, 4, extr(val, 8, 4)); - if (nv04_pgraph_is_nv17p(&ctx->chipset)) - insrt(exp.celsius_config_b, 14, 2, extr(val, 28, 2)); - insrt(exp.celsius_unke88, 29, 1, extr(val, 12, 1)); - } - } - nv04_pgraph_dump_state(ctx, &real); - if (nv04_pgraph_cmp_state(&orig, &exp, &real)) { - printf("Iter %d mthd %02x.%04x %08x\n", i, cls, addr, val); - return HWTEST_RES_FAIL; - } - } - return HWTEST_RES_PASS; -} - -static int test_mthd_celsius_light_model(struct hwtest_ctx *ctx) { - int i; - for (i = 0; i < 10000; i++) { - uint32_t val = jrand48(ctx->rand48); - if (jrand48(ctx->rand48) & 1) { - val &= ~0xfffefff8; - if (jrand48(ctx->rand48) & 1) { - val |= 1 << (jrand48(ctx->rand48) & 0x1f); - } - if (jrand48(ctx->rand48) & 1) { - val |= 1 << (jrand48(ctx->rand48) & 0x1f); - } - } - uint32_t cls = get_random_celsius(ctx); - uint32_t mthd = 0x294; - int trapbit = 31; - uint32_t addr = (jrand48(ctx->rand48) & 0xe000) | mthd; - struct pgraph_state orig, exp, real; - nv04_pgraph_gen_state(ctx, &orig); - orig.notify &= ~0x10000; - uint32_t grobj[4]; - nv04_pgraph_prep_mthd(ctx, grobj, &orig, cls, addr, val); - nv04_pgraph_load_state(ctx, &orig); - exp = orig; - nv04_pgraph_mthd(&exp, grobj, trapbit); - if (!extr(exp.intr, 4, 1)) { - bool bad = false; - if (val & 0xfffefff8) - bad = true; - if (extr(exp.debug[3], 20, 1) && bad) - nv04_pgraph_blowup(&exp, 2); - if (!exp.intr) { - insrt(exp.celsius_unkf40, 18, 1, extr(val, 2, 1)); - insrt(exp.celsius_unkf40, 19, 1, extr(val, 0, 1)); - insrt(exp.celsius_unkf40, 20, 1, extr(val, 1, 1)); - insrt(exp.celsius_unkf44, 28, 1, extr(val, 16, 1)); - } - } - nv04_pgraph_dump_state(ctx, &real); - if (nv04_pgraph_cmp_state(&orig, &exp, &real)) { - printf("Iter %d mthd %02x.%04x %08x\n", i, cls, addr, val); - return HWTEST_RES_FAIL; - } - } - return HWTEST_RES_PASS; -} - -static int invalid_mthd_prep(struct hwtest_ctx *ctx) { - return HWTEST_RES_PASS; -} - -static int celsius_mthd_prep(struct hwtest_ctx *ctx) { - if (ctx->chipset.card_type != 0x10) - return HWTEST_RES_NA; - return HWTEST_RES_PASS; -} - static int nv04_pgraph_prep(struct hwtest_ctx *ctx) { if (ctx->chipset.card_type < 0x04 || ctx->chipset.card_type > 0x10) return HWTEST_RES_NA; @@ -532,21 +315,6 @@ static int nv04_pgraph_prep(struct hwtest_ctx *ctx) { return HWTEST_RES_PASS; } -namespace { - -HWTEST_DEF_GROUP(invalid_mthd, - HWTEST_TEST(test_invalid_class, 0), - HWTEST_TEST(test_invalid_mthd_celsius, 0), -) - -HWTEST_DEF_GROUP(celsius_mthd, - HWTEST_TEST(test_mthd_celsius_unk290, 0), - HWTEST_TEST(test_mthd_celsius_light_model, 0), -) - -} - HWTEST_DEF_GROUP(nv04_pgraph, - HWTEST_GROUP(invalid_mthd), - HWTEST_GROUP(celsius_mthd), + HWTEST_TEST(test_invalid_class, 0), ) diff --git a/hwtest/pgraph_class_celsius.cc b/hwtest/pgraph_class_celsius.cc index b8d0c646..9e3baad4 100644 --- a/hwtest/pgraph_class_celsius.cc +++ b/hwtest/pgraph_class_celsius.cc @@ -671,6 +671,69 @@ class MthdCelsiusRcFinal1 : public SingleMthdTest { using SingleMthdTest::SingleMthdTest; }; +class MthdCelsiusConfig : public SingleMthdTest { + void adjust_orig_mthd() override { + if (rnd() & 1) { + val &= 0x31111101; + if (rnd() & 1) { + val |= 1 << (rnd() & 0x1f); + } + if (rnd() & 1) { + val |= 1 << (rnd() & 0x1f); + } + } + } + bool is_valid_val() override { + if (val & 0xceeeeefe) + return false; + if (extr(val, 28, 2) && cls != 0x99) + return false; + if (extr(val, 8, 1) && !extr(val, 16, 1)) + return false; + return true; + } + void emulate_mthd() override { + insrt(exp.valid[1], 17, 1, 1); + if (!extr(exp.nsource, 1, 1)) { + insrt(exp.celsius_config_a, 25, 1, extr(val, 0, 1)); + insrt(exp.celsius_config_a, 23, 1, extr(val, 16, 1)); + insrt(exp.celsius_config_b, 2, 1, extr(val, 24, 1)); + insrt(exp.celsius_config_b, 6, 1, extr(val, 20, 1)); + insrt(exp.celsius_config_b, 10, 4, extr(val, 8, 4)); + if (nv04_pgraph_is_nv17p(&chipset)) + insrt(exp.celsius_config_b, 14, 2, extr(val, 28, 2)); + insrt(exp.celsius_unke88, 29, 1, extr(val, 12, 1)); + } + } + using SingleMthdTest::SingleMthdTest; +}; + +class MthdCelsiusLightModel : public SingleMthdTest { + void adjust_orig_mthd() override { + if (rnd() & 1) { + val &= 0x00010007; + if (rnd() & 1) { + val |= 1 << (rnd() & 0x1f); + } + if (rnd() & 1) { + val |= 1 << (rnd() & 0x1f); + } + } + } + bool is_valid_val() override { + return !(val & 0xfffefff8); + } + void emulate_mthd() override { + if (!extr(exp.nsource, 1, 1)) { + insrt(exp.celsius_unkf40, 18, 1, extr(val, 2, 1)); + insrt(exp.celsius_unkf40, 19, 1, extr(val, 0, 1)); + insrt(exp.celsius_unkf40, 20, 1, extr(val, 1, 1)); + insrt(exp.celsius_unkf44, 28, 1, extr(val, 16, 1)); + } + } + using SingleMthdTest::SingleMthdTest; +}; + class MthdDmaZcull : public SingleMthdTest { bool takes_dma() override { return true; } void emulate_mthd() override { @@ -1033,8 +1096,8 @@ std::vector<SingleMthdTest *> Celsius::mthds() { new MthdCelsiusRcOutColor(opt, rnd(), "rc_out_color", 27, cls, 0x280, 2), new MthdCelsiusRcFinal0(opt, rnd(), "rc_final_0", 28, cls, 0x288), new MthdCelsiusRcFinal1(opt, rnd(), "rc_final_1", 29, cls, 0x28c), - new UntestedMthd(opt, rnd(), "meh", 30, cls, 0x290), // XXX - new UntestedMthd(opt, rnd(), "meh", 31, cls, 0x294), // XXX + new MthdCelsiusConfig(opt, rnd(), "config", 30, cls, 0x290), + new MthdCelsiusLightModel(opt, rnd(), "light_model", 31, cls, 0x294), new UntestedMthd(opt, rnd(), "meh", -1, cls, 0x298), // XXX new UntestedMthd(opt, rnd(), "meh", -1, cls, 0x29c), // XXX new UntestedMthd(opt, rnd(), "meh", -1, cls, 0x2a0), // XXX |