= gen8_2_0_shader_blocks, 232: .num_shader_blocks = ARRAY_SIZE(gen8_2_0_shader_blocks), 233: .cp_clusters = gen8_2_0_cp_clusters, 234: .num_cp_clusters = ARRAY_SIZE(gen8_2_0_cp_clusters), 235: .clusters = gen8_2_0_mvc_clusters, 236: .num_clusters = ARRAY_SIZE(gen8_2_0_mvc_clusters), 237: .sptp_clusters = gen8_2_0_sptp_clusters, 238: .num_sptp_clusters = ARRAY_SIZE(gen8_2_0_sptp_clusters), 239: .index_registers = gen8_2_0_cp_indexed_reg_list, 240: .index_registers_len = ARRAY_SIZE(gen8_2_0_cp_indexed_reg_list), 241: .mempool_index_registers = gen8_2_0_cp_mempool_reg_list, 242: .mempool_index_registers_len = ARRAY_SIZE(gen8_2_0_cp_mempool_reg_list), 243: }; 244: 245: const struct gen8_snapshot_block_list gen8_11_0_snapshot_block_list = { 246: .pre_crashdumper_regs = gen8_11_0_ahb_registers, 247: .num_pre_crashdumper_regs = ARRAY_SIZE(gen8_11_0_ahb_registers), 248: .debugbus_blocks = gen8_11_0_debugbus_blocks, 249: .debugbus_blocks_len = ARRAY_SIZE(gen8_11_0_debugbus_blocks), 250: .gbif_debugbus_blocks = gen8_gbif_debugbus_blocks, 251: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen8_gbif_debugbus_blocks), 252: .cx_debugbus_blocks = gen8_cx_debugbus_blocks, 253: .cx_debugbus_blocks_len = ARRAY_SIZE(gen8_cx_debugbus_blocks), 254: .sized_gx_debugbus_blocks = gen8_11_0_gx_debugbus_blocks_sized, 255: .sized_gx_debugbus_blocks_len = ARRAY_SIZE(gen8_11_0_gx_debugbus_blocks_sized), 256: .sized_cx_debugbus_blocks = gen8_11_0_cx_debugbus_blocks_sized, 257: .sized_cx_debugbus_blocks_len = ARRAY_SIZE(gen8_11_0_cx_debugbus_blocks_sized), 258: .external_core_regs = gen8_11_0_external_core_regs, 259: .num_external_core_regs = ARRAY_SIZE(gen8_11_0_external_core_regs), 260: .gmu_cx_unsliced_regs = gen8_11_0_gmucx_registers, 261: .gmu_gx_regs = gen8_2_0_gmu_gx_registers, 262: .num_gmu_gx_regs = ARRAY_SIZE(gen8_2_0_gmu_gx_registers), 263: .rscc_regs = gen8_2_0_rscc_rsc_registers, 264: .reg_list = gen8_11_0_misc_registers, 265: .cx_misc_regs = gen8_11_0_cx_misc_registers, 266: .shader_blocks = gen8_11_0_shader_blocks, 267: .num_shader_blocks = ARRAY_SIZE(gen8_11_0_shader_blocks), 268: .cp_clusters = gen8_11_0_cp_clusters, 269: .num_cp_clusters = ARRAY_SIZE(gen8_11_0_cp_clusters), MATCH LINES: 298, 333, 355, 365, 372, 383, 396, 401, 402, 404, 408, 446, 451, 452, 456, 459, 491, 494, 495, 502, 532, 535, 536, 542 286: (FIELD_PREP(GENMASK(17, 16), _pipe)) | \ 287: (FIELD_PREP(GENMASK(15, 8), _statetype)) | \ 288: (FIELD_PREP(GENMASK(7, 4), _usptp)) | \ 289: (FIELD_PREP(GENMASK(3, 0), _sptp))) 290: 291: #define GEN8_CP_APERTURE_REG_VAL(_sliceid, _pipe, _cluster, _context) \ 292: (FIELD_PREP(GENMASK(23, 23), 1) | \ 293: FIELD_PREP(GENMASK(18, 16), _sliceid) | \ 294: FIELD_PREP(GENMASK(15, 12), _pipe) | \ 295: FIELD_PREP(GENMASK(11, 8), _cluster) | \ 296: FIELD_PREP(GENMASK(5, 4), _context)) 297: 298: #define GEN8_DEBUGBUS_SECTION_SIZE (sizeof(struct kgsl_snapshot_debugbus) \ 299: + (GEN8_DEBUGBUS_BLOCK_SIZE << 3)) 300: 301: #define CD_REG_END 0xaaaaaaaa 302: 303: static u32 CD_WRITE(u64 *ptr, u32 offset, u64 val) 304: { 305: ptr[0] = val; 306: ptr[1] = FIELD_PREP(GENMASK(63, 44), offset) | BIT(21) | BIT(0); 307: 308: return 2; 309: } 310: 311: static u32 CD_READ(u64 *ptr, u32 offset, u32 size, u64 target) 312: { 313: ptr[0] = target; 314: ptr[1] = FIELD_PREP(GENMASK(63, 44), offset) | size; 315: 316: return 2; 317: } 318: 319: static void CD_FINISH(u64 *ptr, u32 offset) 320: { 321: gen8_cd_reg_end = gen8_crashdump_registers->hostptr + offset; 322: *gen8_cd_reg_end = CD_REG_END; 323: ptr[0] = gen8_crashdump_registers->gpuaddr + offset; 324: ptr[1] = FIELD_PREP(GENMASK(63, 44), GEN8_CP_CRASH_DUMP_STATUS) | BIT(0); 325: ptr[2] = 0; 326: ptr[3] = 0; 327: } 328: 329: static bool CD_SCRIPT_CHECK(struct kgsl_device *device) 330: { 331: return (adreno_smmu_is_stalled(ADRENO_DEVICE(device)) || 332: (kgsl_mmu_ctx_terminated_on_fault(&device->mmu)) || 333: (!device->snapshot_crashdumper) || 334: IS_ERR_OR_NULL(gen8_capturescript) || 335: IS_ERR_OR_NULL(gen8_crashdump_registers) || 336: gen8_crashdump_timedout); 337: } 338: 339: static bool _gen8_do_crashdump(struct kgsl_device *device) 340: { 341: u32 reg = 0; 342: ktime_t timeout; 343: 344: if (CD_SCRIPT_CHECK(device)) 345: return false; 346: 347: kgsl_regwrite(device, GEN8_CP_CRASH_DUMP_SCRIPT_BASE_LO, 348: lower_32_bits(gen8_capturescript->gpuaddr)); 349: kgsl_regwrite(device, GEN8_CP_CRASH_DUMP_SCRIPT_BASE_HI, 350: upper_32_bits(gen8_capturescript->gpuaddr)); 351: kgsl_regwrite(device, GEN8_CP_CRASH_DUMP_CNTL, 1); 352: 353: timeout = ktime_add_ms(ktime_get(), CP_CRASH_DUMPER_TIMEOUT); 354: 355: if (!device->snapshot_atomic) 356: might_sleep(); 357: for (;;) { 358: /* make sure we're reading the latest value */ 359: rmb(); 360: if ((*gen8_cd_reg_end) != CD_REG_END) 361: break; 362: if (ktime_compare(ktime_get(), timeout) > 0) 363: break; 364: /* Wait 50us to avoid unnecessary looping */ 365: if (!device->snapshot_atomic) 366: usleep_range(5, 50); 367: } 368: 369: kgsl_regread(device, GEN8_CP_CRASH_DUMP_STATUS, ®); 370: 371: /* 372: * Writing to the GEN8_CP_CRASH_DUMP_CNTL also resets the 373: * GEN8_CP_CRASH_DUMP_STATUS. Make sure the read above is 374: * complete before we change the value 375: */ 376: rmb(); 377: 378: kgsl_regwrite(device, GEN8_CP_CRASH_DUMP_CNTL, 0); 379: 380: if (WARN(!(reg & 0x2), "Crashdumper timed out\n")) { 381: /* 382: * Gen7 crash dumper script is broken down into multiple chunks 383: * and script will be invoked multiple times to capture snapshot 384: * of different sections of GPU. If crashdumper fails once, it is 385: * highly likely it will fail subsequently as well. Hence update 386: * gen8_crashdump_timedout variable to avoid running crashdumper 387: * after it fails once. 388: */ 389: gen8_crashdump_timedout = true; 390: return false; 391: } 392: 393: return true; 394: } 395: 396: size_t gen8_legacy_snapshot_registers(struct kgsl_device *device, 397: u8 *buf, size_t remain, void *priv) 398: { 399: struct gen8_reg_list_info *info = (struct gen8_reg_list_info *)priv; 400: const u32 *ptr = info->regs->regs; 401: struct kgsl_snapshot_mvc_regs_v3 *header = 402: (struct kgsl_snapshot_mvc_regs_v3 *)buf; 403: u32 *data = (u32 *)(buf + sizeof(*header)); 404: u32 size = (adreno_snapshot_regs_count(ptr) * sizeof(*data)) + sizeof(*header); 405: u32 count, k; 406: 407: if (remain < size) { 408: SNAPSHOT_ERR_NOMEM(device, "REGISTERS"); 409: return 0; 410: } 411: 412: header->ctxt_id = 0; 413: header->cluster_id = CLUSTER_NONE; 414: header->pipe_id = PIPE_NONE; 415: header->location_id = UINT_MAX; 416: header->sp_id = UINT_MAX; 417: header->usptp_id = UINT_MAX; 418: header->slice_id = HEADER_SLICE_ID(info->regs->slice_region, info->slice_id); 419: 420: if (info->regs->sel) 421: kgsl_regwrite(device, info->regs->sel->host_reg, info->regs->sel->val); 422: 423: if (info->regs->slice_region) 424: kgsl_regwrite(device, GEN8_CP_APERTURE_CNTL_HOST, GEN8_CP_APERTURE_REG_VAL 425: (info->slice_id, 0, 0, 0)); 426: 427: /* Make sure the previous writes are posted before reading */ 428: mb(); 429: 430: for (ptr = info->regs->regs; ptr[0] != UINT_MAX; ptr += 2) { 431: count = REG_COUNT(ptr); 432: 433: if (count == 1) 434: *data++ = ptr[0]; 435: else { 436: *data++ = ptr[0] | (1 << 31); 437: *data++ = ptr[1]; 438: } 439: for (k = ptr[0]; k <= ptr[1]; k++) 440: kgsl_regread(device, k, data++); 441: } 442: 443: return size; 444: } 445: 446: static size_t gen8_snapshot_registers(struct kgsl_device *device, u8 *buf, 447: size_t remain, void *priv) 448: { 449: struct gen8_reg_list_info *info = (struct gen8_reg_list_info *)priv; 450: const u32 *ptr = info->regs->regs; 451: struct kgsl_snapshot_mvc_regs_v3 *header = 452: (struct kgsl_snapshot_mvc_regs_v3 *)buf; 453: u32 *data = (u32 *)(buf + sizeof(*header)); 454: u32 *src; 455: u32 cnt; 456: u32 size = (adreno_snapshot_regs_count(ptr) * sizeof(*data)) + sizeof(*header); 457: 458: if (remain < size) { 459: SNAPSHOT_ERR_NOMEM(device, "REGISTERS"); 460: return 0; 461: } 462: 463: header->ctxt_id = 0; 464: header->cluster_id = CLUSTER_NONE; 465: header->pipe_id = PIPE_NONE; 466: header->location_id = UINT_MAX; 467: header->sp_id = UINT_MAX; 468: header->usptp_id = UINT_MAX; 469: header->slice_id = HEADER_SLICE_ID(info->regs->slice_region, info->slice_id); 470: 471: src = gen8_crashdump_registers->hostptr + info->offset; 472: 473: for (ptr = info->regs->regs; ptr[0] != UINT_MAX; ptr += 2) { 474: cnt = REG_COUNT(ptr); 475: 476: if (cnt == 1) 477: *data++ = ptr[0]; 478: else { 479: *data++ = BIT(31) | ptr[0]; 480: *data++ = ptr[1]; 481: } 482: memcpy(data, src, cnt << 2); 483: data += cnt; 484: src += cnt; 485: } 486: 487: /* Return the size of the section */ 488: return size; 489: } 490: 491: static size_t gen8_legacy_snapshot_shader(struct kgsl_device *device, 492: u8 *buf, size_t remain, void *priv) 493: { 494: struct kgsl_snapshot_shader_v3 *header = 495: (struct kgsl_snapshot_shader_v3 *) buf; 496: struct gen8_shader_block_info *info = (struct gen8_shader_block_info *) priv; 497: struct gen8_shader_block *block = info->block; 498: u32 *data = (u32 *)(buf + sizeof(*header)); 499: u32 read_sel, i; 500: 501: if (remain < (sizeof(*header) + (block->size << 2))) { 502: SNAPSHOT_ERR_NOMEM(device, "SHADER MEMORY"); 503: return 0; 504: } 505: 506: header->type = block->statetype; 507: header->slice_id = HEADER_SLICE_ID(block->slice_region, info->slice_id); 508: header->sp_index = info->sp_id; 509: header->usptp = info->usptp; 510: header->pipe_id = block->pipeid; 511: header->location = block->location; 512: header->ctxt_id = info->context_id; 513: header->size = block->size; 514: 515: read_sel = GEN8_SP_READ_SEL_VAL(info->context_id, info->slice_id, block->location, 516: block->pipeid, block->statetype, info->usptp, info->sp_id); 517: 518: kgsl_regwrite(device, GEN8_SP_READ_SEL, read_sel); 519: 520: /* 521: * An explicit barrier is needed so that reads do not happen before 522: * the register write. 523: */ 524: mb(); 525: 526: for (i = 0; i < block->size; i++) 527: data[i] = kgsl_regmap_read(&device->regmap, GEN8_SP_AHB_READ_APERTURE + i); 528: 529: return (sizeof(*header) + (block->size << 2)); 530: } 531: 532: static size_t gen8_snapshot_shader_memory(struct kgsl_device *device, 533: u8 *buf, size_t remain, void *priv) 534: { 535: struct kgsl_snapshot_shader_v3 *header = 536: (struct kgsl_snapshot_shader_v3 *) buf; 537: struct gen8_shader_block_info *info = (struct gen8_shader_block_info *) priv; 538: struct gen8_shader_block *block = info->block; 539: u32 *data = (u32 *) (buf + sizeof(*header)); 540: 541: if (remain < (sizeof(*header) + (block->size << 2))) { 542: SNAPSHOT_ERR_NOMEM(device, "SHADER MEMORY"); 543: return 0; 544: } 545: 546: header->type = block->statetype; 547: header->slice_id = HEADER_SLICE_ID(block->slice_region, info->slice_id); 548: header->sp_index = info->sp_id; 549: header->usptp = info->usptp; 550: header->pipe_id = block->pipeid; 551: header->location = block->location; 552: header->ctxt_id = 1; 553: header->size = block->size; 554: 555: memcpy(data, gen8_crashdump_registers->hostptr + info->offset, 556: (block->size << 2)); 557: 558: return (sizeof(*header) + (block->size << 2)); 559: } 560: 561: static void qdss_regwrite(void __iomem *regbase, u32 offsetbytes, u32 value) 562: { 563: void __iomem *reg; 564: 565: reg = regbase + offsetbytes; 566: MATCH LINES: 585, 588, 589, 590, 604 573: { 574: void __iomem *reg; 575: u32 val; 576: 577: reg = regbase + offsetbytes; 578: val = __raw_readl(reg); 579: 580: /* Make sure memory is updated before next access */ 581: rmb(); 582: return val; 583: } 584: 585: static size_t gen8_snapshot_dump_indexed_regs(struct kgsl_device *device, 586: u8 *buf, size_t remain, void *priv) 587: { 588: struct kgsl_snapshot_indexed_registers_v2 *iregs = priv; 589: struct kgsl_snapshot_indexed_regs_v2 *header = 590: (struct kgsl_snapshot_indexed_regs_v2 *)buf; 591: u32 *dest = (u32 *)(buf + sizeof(*header)); 592: u32 count = iregs->count, start = iregs->start; 593: /* 594: * CD script is built as follows: 595: * - 2 u64s to set aperture + 4 u64s to finalize the CD script 596: * - 4 u64s for reading each register 597: * Therefore, maximum registers that can be read in single CD iteration is: 598: * (size - (6 * sizeof(u64))) / (4 * sizeof(u64)) 599: */ 600: u32 max_cd_regs = (gen8_capturescript->size - (6 * sizeof(u64))) / (4 * sizeof(u64)); 601: u64 *ptr; 602: 603: if (remain < ((iregs->count * 4) + sizeof(*header))) { 604: SNAPSHOT_ERR_NOMEM(device, "INDEXED REGS"); 605: return 0; 606: } 607: 608: header->index_reg = iregs->index; 609: header->data_reg = iregs->data; 610: header->count = iregs->count; 611: header->start = iregs->start; 612: header->pipe_id = iregs->pipe_id; 613: header->slice_id = iregs->slice_id; 614: 615: while (count > 0) { 616: u32 i, num_cd_regs = min(count, max_cd_regs); 617: u64 offset = 0; 618: 619: /* Build the crash script */ 620: ptr = gen8_capturescript->hostptr; 621: 622: ptr += CD_WRITE(ptr, GEN8_CP_APERTURE_CNTL_CD, GEN8_CP_APERTURE_REG_VAL 623: ((iregs->slice_id == UINT_MAX) ? 0 : iregs->slice_id, iregs->pipe_id, 624: 0, 0)); 625: 626: for (i = 0; i < num_cd_regs; i++) { 627: /* Write the address register */ 628: ptr += CD_WRITE(ptr, iregs->index, start + i); MATCH LINES: 657, 658, 662, 668, 680, 681, 686, 690, 691, 697 645: } 646: 647: memcpy(dest, gen8_crashdump_registers->hostptr, offset); 648: 649: count -= num_cd_regs; 650: start += num_cd_regs; 651: dest = (u32 *)((u8 *)dest + offset); 652: } 653: 654: return (iregs->count * 4) + sizeof(*header); 655: } 656: 657: static bool gen8_snapshot_indexed_registers(struct kgsl_device *device, 658: struct kgsl_snapshot *snapshot, 659: u32 index, u32 data, u32 start, u32 count, 660: u32 pipe_id, u32 slice_id) 661: { 662: struct kgsl_snapshot_indexed_registers_v2 iregs; 663: 664: if (CD_SCRIPT_CHECK(device)) { 665: kgsl_regwrite(device, GEN8_CP_APERTURE_CNTL_HOST, GEN8_CP_APERTURE_REG_VAL 666: ((slice_id == UINT_MAX) ? 0 : slice_id, pipe_id, 0, 0)); 667: 668: kgsl_snapshot_indexed_registers_v2(device, snapshot, 669: index, data, start, count, pipe_id, slice_id); 670: return true; 671: } 672: 673: iregs.index = index; 674: iregs.data = data; 675: iregs.start = start; 676: iregs.count = count; 677: iregs.pipe_id = pipe_id; 678: iregs.slice_id = slice_id; 679: 680: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_INDEXED_REGS_V2, 681: snapshot, gen8_snapshot_dump_indexed_regs, &iregs); 682: 683: return !gen8_crashdump_timedout; 684: } 685: 686: static size_t gen8_snapshot_trace_buffer_gfx_trace(struct kgsl_device *device, 687: u8 *buf, size_t remain, void *priv) 688: { 689: u32 start_idx = 0, status = 0, count = 0, wrap_count = 0, write_ptr = 0; 690: struct kgsl_snapshot_trace_buffer *header = 691: (struct kgsl_snapshot_trace_buffer *) buf; 692: u32 *data = (u32 *)(buf + sizeof(*header)); 693: struct gen8_trace_buffer_info *info = 694: (struct gen8_trace_buffer_info *) priv; 695: 696: if (remain < SZ_2K + sizeof(*header)) { 697: SNAPSHOT_ERR_NOMEM(device, "TRACE 2K BUFFER"); 698: return 0; 699: } 700: 701: memcpy(header->ping_blk, info->ping_blk, sizeof(header->ping_blk)); 702: memcpy(header->ping_idx, info->ping_idx, sizeof(header->ping_idx)); 703: header->granularity = info->granularity; 704: header->segment = info->segment; 705: header->dbgc_ctrl = info->dbgc_ctrl; 706: 707: /* Read the status of trace buffer to determine if it's full or empty */ 708: kgsl_regread(device, GEN8_DBGC_TRACE_BUFFER_STATUS, &status); 709: 710: /* 711: * wrap_count and write ptr are part of status. 712: * if status is 0 => wrap_count = 0 and write ptr = 0 buffer is empty. 713: * if status is non zero and wrap count is 0 read partial buffer. 714: * if wrap count in non zero read entier 2k buffer. 715: * Always read the oldest data available. 716: */ 717: 718: /* if status is 0 then buffer is empty */ 719: if (!status) { 720: header->size = 0; 721: return sizeof(*header); MATCH LINES: 748, 752, 787, 814, 815, 842, 843 736: start_idx = write_ptr + 1; 737: count = SZ_512; 738: header->size = SZ_2K; 739: } 740: 741: kgsl_regmap_read_indexed_interleaved(&device->regmap, 742: GEN8_DBGC_DBG_TRACE_BUFFER_RD_ADDR, GEN8_DBGC_DBG_TRACE_BUFFER_RD_DATA, data, 743: start_idx, count); 744: 745: return (sizeof(*header) + header->size); 746: } 747: 748: static size_t gen8_snapshot_trace_buffer_etb(struct kgsl_device *device, 749: u8 *buf, size_t remain, void *priv) 750: { 751: u32 read_ptr, count, write_ptr, val, idx = 0; 752: struct kgsl_snapshot_trace_buffer *header = (struct kgsl_snapshot_trace_buffer *) buf; 753: u32 *data = (u32 *)(buf + sizeof(*header)); 754: struct gen8_trace_buffer_info *info = (struct gen8_trace_buffer_info *) priv; 755: 756: /* Unlock ETB buffer */ 757: qdss_regwrite(tmc_virt, QDSS_AOSS_APB_TMC_LAR, 0xC5ACCE55); 758: 759: /* Make sure unlock goes through before proceeding further */ 760: mb(); 761: 762: /* Flush the QDSS pipeline to ensure completion of pending write to buffer */ 763: val = qdss_regread(tmc_virt, QDSS_AOSS_APB_TMC_FFCR); 764: qdss_regwrite(tmc_virt, QDSS_AOSS_APB_TMC_FFCR, val | 0x40); 765: 766: /* Make sure pipeline is flushed before we get read and write pointers */ 767: mb(); 768: 769: /* Disable ETB */ 770: qdss_regwrite(tmc_virt, QDSS_AOSS_APB_TMC_CTRL, 0); 771: 772: /* Set to circular mode */ 773: qdss_regwrite(tmc_virt, QDSS_AOSS_APB_TMC_MODE, 0); 774: 775: /* Ensure buffer is set to circular mode before accessing it */ 776: mb(); 777: 778: /* Size of buffer is specified in register TMC_RSZ */ 779: count = qdss_regread(tmc_virt, QDSS_AOSS_APB_TMC_RSZ) << 2; 780: read_ptr = qdss_regread(tmc_virt, QDSS_AOSS_APB_TMC_RRP); 781: write_ptr = qdss_regread(tmc_virt, QDSS_AOSS_APB_TMC_RWP); 782: 783: /* ETB buffer if full read_ptr will be equal to write_ptr else write_ptr leads read_ptr */ 784: count = (read_ptr == write_ptr) ? count : (write_ptr - read_ptr); 785: 786: if (remain < count + sizeof(*header)) { 787: SNAPSHOT_ERR_NOMEM(device, "ETB BUFFER"); 788: return 0; 789: } 790: 791: /* 792: * Read pointer is 4 byte aligned and write pointer is 2 byte aligned 793: * We read 4 bytes of data in one iteration below so aligin it down 794: * to 4 bytes. 795: */ 796: count = ALIGN_DOWN(count, 4); 797: 798: header->size = count; 799: header->dbgc_ctrl = info->dbgc_ctrl; 800: memcpy(header->ping_blk, info->ping_blk, sizeof(header->ping_blk)); 801: memcpy(header->ping_idx, info->ping_idx, sizeof(header->ping_idx)); 802: header->granularity = info->granularity; 803: header->segment = info->segment; 804: 805: while (count != 0) { 806: /* This indexed register auto increments index as we read */ 807: data[idx++] = qdss_regread(tmc_virt, QDSS_AOSS_APB_TMC_RRD); 808: count = count - 4; 809: } 810: 811: return (sizeof(*header) + header->size); 812: } 813: 814: static void gen8_snapshot_trace_buffer(struct kgsl_device *device, 815: struct kgsl_snapshot *snapshot) 816: { 817: u32 val_tmc_ctrl = 0, val_etr_ctrl = 0, val_etr1_ctrl = 0; 818: u32 i = 0, sel_gx = 0, sel_cx = 0, val_gx = 0, val_cx = 0, val = 0; 819: struct gen8_trace_buffer_info info; 820: struct resource *res1, *res2; 821: struct clk *clk; 822: int ret; 823: void __iomem *etr_virt; 824: 825: /* 826: * Data can be collected from CX_DBGC or DBGC and it's mutually exclusive. 827: * Read the necessary select registers and determine the source of data. 828: * This loop reads SEL_A to SEL_D of both CX_DBGC and DBGC and accordingly 829: * updates the header information of trace buffer section. 830: */ 831: for (i = 0; i < TRACE_BUF_NUM_SIG; i++) { 832: kgsl_regread(device, GEN8_DBGC_CFG_DBGBUS_SEL_A + i, &sel_gx); 833: kgsl_regread(device, GEN8_CX_DBGC_CFG_DBGBUS_SEL_A + i, &sel_cx); 834: val_gx |= sel_gx; 835: val_cx |= sel_cx; 836: info.ping_idx[i] = FIELD_GET(GENMASK(7, 0), (sel_gx | sel_cx)); 837: info.ping_blk[i] = FIELD_GET(GENMASK(27, 16), (sel_gx | sel_cx)); 838: } 839: 840: /* Zero the header if not programmed to export any buffer or QDSS is unavailable */ 841: if ((!val_gx && !val_cx) || !IS_ENABLED(CONFIG_QCOM_KGSL_QDSS_STM)) { 842: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_TRACE_BUFFER, 843: snapshot, NULL, &info); 844: return; 845: } 846: 847: /* Enable APB clock to read data from trace buffer */ 848: clk = clk_get(&device->pdev->dev, "apb_pclk"); 849: 850: if (IS_ERR(clk)) { 851: dev_err(device->dev, "Unable to get QDSS clock\n"); 852: return; 853: } 854: 855: ret = clk_prepare_enable(clk); 856: 857: if (ret) { 858: dev_err(device->dev, "QDSS Clock enable error: %d\n", ret); 859: clk_put(clk); 860: return; 861: } 862: 863: res1 = platform_get_resource_byname(device->pdev, IORESOURCE_MEM, "qdss_etr"); 864: res2 = platform_get_resource_byname(device->pdev, IORESOURCE_MEM, "qdss_tmc"); 865: 866: if (!res1 || !res2) 867: goto err_clk_put; MATCH LINES: 901, 902, 904, 905, 910, 911, 924, 927, 931, 936, 943, 946, 950, 955, 962, 965, 969, 974, 981, 982, 987, 988, 1010, 1011, 1012 889: 890: val_tmc_ctrl = qdss_regread(tmc_virt, QDSS_AOSS_APB_TMC_CTRL); 891: 892: /* 893: * Incase TMC CTRL is 0 and val_cx is non zero dump empty buffer. 894: * Incase TMC CTRL is 0 and val_gx is non zero dump 2k gfx buffer. 895: * 2k buffer is not present for CX blocks. 896: * Incase both ETR's CTRL is 0 Dump ETB QDSS buffer and disable QDSS. 897: * Incase either ETR's CTRL is 1 Disable QDSS dumping ETB buffer to DDR. 898: */ 899: if (!val_tmc_ctrl) { 900: if (val_gx) 901: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_TRACE_BUFFER, 902: snapshot, gen8_snapshot_trace_buffer_gfx_trace, &info); 903: else 904: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_TRACE_BUFFER, 905: snapshot, NULL, &info); 906: } else { 907: val_etr_ctrl = qdss_regread(etr_virt, QDSS_AOSS_APB_ETR_CTRL); 908: val_etr1_ctrl = qdss_regread(etr_virt, QDSS_AOSS_APB_ETR1_CTRL); 909: if (!val_etr_ctrl && !val_etr1_ctrl) 910: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_TRACE_BUFFER, 911: snapshot, gen8_snapshot_trace_buffer_etb, &info); 912: qdss_regwrite(tmc_virt, QDSS_AOSS_APB_TMC_CTRL, 0); 913: } 914: 915: err_unmap: 916: iounmap(tmc_virt); 917: iounmap(etr_virt); 918: 919: err_clk_put: 920: clk_disable_unprepare(clk); 921: clk_put(clk); 922: } 923: 924: static size_t gen8_snapshot_rbbm_status(struct kgsl_device *device, u8 *buf, 925: size_t remain, void *priv) 926: { 927: struct kgsl_snapshot_debug *header = (struct kgsl_snapshot_debug *)buf; 928: u32 *data = (u32 *)(buf + sizeof(*header)); 929: 930: if (remain < DEBUG_SECTION_SZ(1)) { 931: SNAPSHOT_ERR_NOMEM(device, "RBBM STATUS"); 932: return 0; 933: } 934: 935: /* Dump the rbbm status information */ 936: header->type = SNAPSHOT_DEBUG_RBBM_STATUS; 937: header->size = 1; 938: kgsl_regread(device, GEN8_RBBM_STATUS, data); 939: 940: return DEBUG_SECTION_SZ(1); 941: } 942: 943: static size_t gen8_snapshot_malu_status(struct kgsl_device *device, u8 *buf, 944: size_t remain, void *priv) 945: { 946: struct kgsl_snapshot_debug *header = (struct kgsl_snapshot_debug *)buf; 947: u32 *data = (u32 *)(buf + sizeof(*header)); 948: 949: if (remain < DEBUG_SECTION_SZ(1)) { 950: SNAPSHOT_ERR_NOMEM(device, "MALU STATUS"); 951: return 0; 952: } 953: 954: /* Dump the malu status information */ 955: header->type = SNAPSHOT_DEBUG_MALU_STATUS; 956: header->size = 1; 957: *data = gen8_gmu_malu_is_on(ADRENO_DEVICE(device)); 958: 959: return DEBUG_SECTION_SZ(1); 960: } 961: 962: static size_t gen8_snapshot_slice_mask(struct kgsl_device *device, u8 *buf, 963: size_t remain, void *priv) 964: { 965: struct kgsl_snapshot_debug *header = (struct kgsl_snapshot_debug *)buf; 966: u32 *data = (u32 *)(buf + sizeof(*header)); 967: 968: if (remain < DEBUG_SECTION_SZ(1)) { 969: SNAPSHOT_ERR_NOMEM(device, "SLICE MASK DEBUG"); 970: return 0; 971: } 972: 973: /* Dump the slice information */ 974: header->type = SNAPSHOT_DEBUG_SLICE_MASK; 975: header->size = 1; 976: *data = gen8_get_slice_mask(ADRENO_DEVICE(device)); 977: 978: return DEBUG_SECTION_SZ(1); 979: } 980: 981: static bool gen8_snapshot_shader(struct kgsl_device *device, 982: struct kgsl_snapshot *snapshot) 983: { 984: struct gen8_shader_block_info info = {0}; 985: u64 *ptr; 986: u32 offset = 0; 987: struct gen8_shader_block *shader_blocks = gen8_snapshot_block_list->shader_blocks; 988: size_t num_shader_blocks = gen8_snapshot_block_list->num_shader_blocks; 989: u32 i, sp, ctxt, slice; 990: u32 slice_mask = gen8_get_slice_mask(ADRENO_DEVICE(device)); 991: 992: if (!CD_SCRIPT_CHECK(device)) 993: goto crashdumper; 994: 995: for (i = 0; i < num_shader_blocks; i++) { 996: struct gen8_shader_block *block = &shader_blocks[i]; 997: 998: FOR_EACH_SLICE(slice, block->slice_region, slice_mask) { 999: for (sp = 0; sp < block->num_sps; sp++) { 1000: for (ctxt = 0; ctxt < block->num_ctx; ctxt++) { 1001: info.block = block; 1002: info.sp_id = sp; 1003: info.usptp = block->usptp_id; 1004: info.slice_id = slice; 1005: info.offset = offset; 1006: info.context_id = ctxt; 1007: offset += block->size << 2; 1008: 1009: /* Shader working/shadow memory */ 1010: kgsl_snapshot_add_section(device, 1011: KGSL_SNAPSHOT_SECTION_SHADER_V3, snapshot, 1012: gen8_legacy_snapshot_shader, &info); 1013: } 1014: } 1015: } 1016: } 1017: return true; 1018: 1019: crashdumper: 1020: for (i = 0; i < num_shader_blocks; i++) { 1021: struct gen8_shader_block *block = &shader_blocks[i]; 1022: 1023: /* Build the crash script */ 1024: ptr = gen8_capturescript->hostptr; 1025: offset = 0; 1026: 1027: FOR_EACH_SLICE(slice, block->slice_region, slice_mask) { 1028: for (sp = 0; sp < block->num_sps; sp++) { 1029: for (ctxt = 0; ctxt < block->num_ctx; ctxt++) { 1030: /* Program the aperture */ 1031: ptr += CD_WRITE(ptr, GEN8_SP_READ_SEL, 1032: GEN8_SP_READ_SEL_VAL(ctxt, slice, 1033: block->location, block->pipeid, 1034: block->statetype, block->usptp_id, sp)); 1035: 1036: /* Read all the data in one chunk */ MATCH LINES: 1064, 1065, 1066, 1082, 1083, 1087, 1094, 1105, 1112, 1136, 1139, 1140, 1146, 1149 1052: FOR_EACH_SLICE(slice, block->slice_region, slice_mask) { 1053: for (sp = 0; sp < block->num_sps; sp++) { 1054: for (ctxt = 0; ctxt < block->num_ctx; ctxt++) { 1055: info.block = block; 1056: info.sp_id = sp; 1057: info.usptp = block->usptp_id; 1058: info.slice_id = slice; 1059: info.offset = offset; 1060: info.context_id = ctxt; 1061: offset += block->size << 2; 1062: 1063: /* Shader working/shadow memory */ 1064: kgsl_snapshot_add_section(device, 1065: KGSL_SNAPSHOT_SECTION_SHADER_V3, snapshot, 1066: gen8_snapshot_shader_memory, &info); 1067: } 1068: } 1069: } 1070: } 1071: return true; 1072: } 1073: 1074: static void gen8_rmw_aperture(struct kgsl_device *device, 1075: u32 offsetwords, u32 mask, u32 val, u32 pipe, u32 slice_id, u32 use_slice_id) 1076: { 1077: gen8_host_aperture_set(ADRENO_DEVICE(device), pipe, slice_id, use_slice_id); 1078: 1079: kgsl_regmap_rmw(&device->regmap, offsetwords, mask, val); 1080: } 1081: 1082: static bool gen8_snapshot_mempool(struct kgsl_device *device, 1083: struct kgsl_snapshot *snapshot) 1084: { 1085: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1086: struct gen8_cp_indexed_reg *cp_indexed_reg; 1087: size_t mempool_index_registers_len = gen8_snapshot_block_list->mempool_index_registers_len; 1088: u32 i, j; 1089: u32 slice_mask = gen8_get_slice_mask(adreno_dev); 1090: u32 first_slice = gen8_first_slice(adreno_dev); 1091: bool ret = true; 1092: 1093: for (i = 0; i < mempool_index_registers_len; i++) { 1094: cp_indexed_reg = &gen8_snapshot_block_list->mempool_index_registers[i]; 1095: 1096: FOR_EACH_SLICE(j, cp_indexed_reg->slice_region, slice_mask) { 1097: 1098: /* set CP_CHICKEN_DBG[StabilizeMVC] to stabilize it while dumping */ 1099: gen8_rmw_aperture(device, GEN8_CP_CHICKEN_DBG_PIPE, 0x4, 0x4, 1100: cp_indexed_reg->pipe_id, first_slice, 0); 1101: 1102: gen8_rmw_aperture(device, GEN8_CP_SLICE_CHICKEN_DBG_PIPE, 0x4, 0x4, 1103: cp_indexed_reg->pipe_id, j, 1); 1104: 1105: ret = gen8_snapshot_indexed_registers(device, snapshot, 1106: cp_indexed_reg->addr, cp_indexed_reg->data, 1107: 0, cp_indexed_reg->size, cp_indexed_reg->pipe_id, 1108: HEADER_SLICE_ID(cp_indexed_reg->slice_region, j)); 1109: if (!ret) 1110: break; 1111: 1112: /* Reset CP_CHICKEN_DBG[StabilizeMVC] once we are done */ 1113: gen8_rmw_aperture(device, GEN8_CP_CHICKEN_DBG_PIPE, 0x4, 0x0, 1114: cp_indexed_reg->pipe_id, first_slice, 0); 1115: 1116: gen8_rmw_aperture(device, GEN8_CP_SLICE_CHICKEN_DBG_PIPE, 0x4, 0x0, 1117: cp_indexed_reg->pipe_id, j, 1); 1118: } 1119: } 1120: 1121: /* Clear aperture register */ 1122: gen8_host_aperture_set(ADRENO_DEVICE(device), 0, 0, 0); 1123: 1124: return ret; 1125: } 1126: 1127: static u32 gen8_read_dbgahb(struct kgsl_device *device, 1128: u32 regbase, u32 reg) 1129: { 1130: u32 val; 1131: 1132: kgsl_regread(device, (GEN8_SP_AHB_READ_APERTURE + reg - regbase), &val); 1133: return val; 1134: } 1135: 1136: static size_t gen8_legacy_snapshot_cluster_dbgahb(struct kgsl_device *device, 1137: u8 *buf, size_t remain, void *priv) 1138: { 1139: struct kgsl_snapshot_mvc_regs_v3 *header = 1140: (struct kgsl_snapshot_mvc_regs_v3 *)buf; 1141: struct gen8_sptp_cluster_registers_info *info = 1142: (struct gen8_sptp_cluster_registers_info *)priv; 1143: const u32 *ptr = info->cluster->regs; 1144: u32 *data = (u32 *)(buf + sizeof(*header)); 1145: u32 read_sel, j; 1146: u32 size = adreno_snapshot_regs_count(ptr) * sizeof(*data); 1147: 1148: if (remain < (sizeof(*header) + size)) { 1149: SNAPSHOT_ERR_NOMEM(device, "MVC REGISTERS"); 1150: return 0; 1151: } 1152: 1153: header->ctxt_id = info->context_id; 1154: header->cluster_id = info->cluster_id; 1155: header->pipe_id = info->pipe_id; 1156: header->location_id = info->location_id; 1157: header->sp_id = info->sp_id; 1158: header->usptp_id = info->usptp_id; 1159: header->slice_id = HEADER_SLICE_ID(info->cluster->slice_region, info->slice_id); 1160: 1161: read_sel = GEN8_SP_READ_SEL_VAL(0, info->slice_id, info->location_id, 1162: info->pipe_id, info->statetype_id, info->usptp_id, info->sp_id); 1163: 1164: kgsl_regwrite(device, GEN8_SP_READ_SEL, read_sel); 1165: 1166: /* 1167: * An explicit barrier is needed so that reads do not happen before 1168: * the register write. 1169: */ 1170: mb(); 1171: 1172: for (; ptr[0] != UINT_MAX; ptr += 2) { 1173: u32 count = REG_COUNT(ptr); MATCH LINES: 1188, 1191, 1192, 1198, 1201, 1232, 1233, 1238, 1239, 1258, 1259, 1260 1176: *data++ = ptr[0]; 1177: else { 1178: *data++ = ptr[0] | (1 << 31); 1179: *data++ = ptr[1]; 1180: } 1181: for (j = ptr[0]; j <= ptr[1]; j++) 1182: *data++ = gen8_read_dbgahb(device, info->cluster->regbase, j); 1183: } 1184: 1185: return (size + sizeof(*header)); 1186: } 1187: 1188: static size_t gen8_snapshot_cluster_dbgahb(struct kgsl_device *device, u8 *buf, 1189: size_t remain, void *priv) 1190: { 1191: struct kgsl_snapshot_mvc_regs_v3 *header = 1192: (struct kgsl_snapshot_mvc_regs_v3 *)buf; 1193: struct gen8_sptp_cluster_registers_info *info = 1194: (struct gen8_sptp_cluster_registers_info *)priv; 1195: const u32 *ptr = info->cluster->regs; 1196: u32 *data = (u32 *)(buf + sizeof(*header)); 1197: u32 *src; 1198: u32 size = adreno_snapshot_regs_count(ptr) * sizeof(*data); 1199: 1200: if (remain < (sizeof(*header) + size)) { 1201: SNAPSHOT_ERR_NOMEM(device, "REGISTERS"); 1202: return 0; 1203: } 1204: 1205: header->ctxt_id = info->context_id; 1206: header->cluster_id = info->cluster_id; 1207: header->pipe_id = info->pipe_id; 1208: header->location_id = info->location_id; 1209: header->sp_id = info->sp_id; 1210: header->usptp_id = info->usptp_id; 1211: header->slice_id = HEADER_SLICE_ID(info->cluster->slice_region, info->slice_id); 1212: 1213: src = gen8_crashdump_registers->hostptr + info->offset; 1214: 1215: for (ptr = info->cluster->regs; ptr[0] != UINT_MAX; ptr += 2) { 1216: u32 cnt = REG_COUNT(ptr); 1217: 1218: if (cnt == 1) 1219: *data++ = ptr[0]; 1220: else { 1221: *data++ = ptr[0] | (1 << 31); 1222: *data++ = ptr[1]; 1223: } 1224: memcpy(data, src, cnt << 2); 1225: data += cnt; 1226: src += cnt; 1227: } 1228: 1229: return (size + sizeof(*header)); 1230: } 1231: 1232: static bool gen8_snapshot_dbgahb_regs(struct kgsl_device *device, 1233: struct kgsl_snapshot *snapshot) 1234: { 1235: u32 i, j, sp, usptp, count; 1236: u64 *ptr, offset = 0; 1237: struct gen8_sptp_cluster_registers_info info = {0}; 1238: struct gen8_sptp_cluster_registers *sptp_clusters = gen8_snapshot_block_list->sptp_clusters; 1239: size_t num_sptp_clusters = gen8_snapshot_block_list->num_sptp_clusters; 1240: u32 slice_mask = gen8_get_slice_mask(ADRENO_DEVICE(device)); 1241: 1242: if (CD_SCRIPT_CHECK(device)) { 1243: for (i = 0; i < num_sptp_clusters; i++) { 1244: struct gen8_sptp_cluster_registers *cluster = &sptp_clusters[i]; 1245: 1246: for (sp = 0; sp < cluster->num_sps; sp++) { 1247: for (usptp = 0; usptp < cluster->num_usptps; usptp++) { 1248: FOR_EACH_SLICE(j, cluster->slice_region, slice_mask) { 1249: info.cluster = cluster; 1250: info.location_id = cluster->location_id; 1251: info.pipe_id = cluster->pipe_id; 1252: info.usptp_id = usptp; 1253: info.sp_id = sp; 1254: info.slice_id = SLICE_ID(cluster->slice_region, j); 1255: info.statetype_id = cluster->statetype; 1256: info.cluster_id = cluster->cluster_id; 1257: info.context_id = cluster->context_id; 1258: kgsl_snapshot_add_section(device, 1259: KGSL_SNAPSHOT_SECTION_MVC_V3, snapshot, 1260: gen8_legacy_snapshot_cluster_dbgahb, &info); 1261: } 1262: } 1263: } 1264: } 1265: return true; 1266: } 1267: 1268: for (i = 0; i < num_sptp_clusters; i++) { 1269: struct gen8_sptp_cluster_registers *cluster = &sptp_clusters[i]; 1270: 1271: cluster->offset = offset; 1272: 1273: for (sp = 0; sp < cluster->num_sps; sp++) { 1274: for (usptp = 0; usptp < cluster->num_usptps; usptp++) { 1275: FOR_EACH_SLICE(j, cluster->slice_region, slice_mask) { 1276: const u32 *regs = cluster->regs; 1277: 1278: info.cluster = cluster; 1279: info.location_id = cluster->location_id; 1280: info.pipe_id = cluster->pipe_id; 1281: info.usptp_id = usptp; 1282: info.sp_id = sp; 1283: info.slice_id = SLICE_ID(cluster->slice_region, j); 1284: info.statetype_id = cluster->statetype; MATCH LINES: 1313, 1314, 1315, 1323, 1326, 1327, 1332, 1336 1301: (gen8_crashdump_registers->gpuaddr + 1302: offset)); 1303: 1304: offset += count * sizeof(u32); 1305: } 1306: /* Marker for end of script */ 1307: CD_FINISH(ptr, offset); 1308: 1309: /* Try to run the crash dumper and bail if it times out */ 1310: if (!_gen8_do_crashdump(device)) 1311: return false; 1312: 1313: kgsl_snapshot_add_section(device, 1314: KGSL_SNAPSHOT_SECTION_MVC_V3, snapshot, 1315: gen8_snapshot_cluster_dbgahb, &info); 1316: } 1317: } 1318: } 1319: } 1320: return true; 1321: } 1322: 1323: static size_t gen8_legacy_snapshot_mvc(struct kgsl_device *device, u8 *buf, 1324: size_t remain, void *priv) 1325: { 1326: struct kgsl_snapshot_mvc_regs_v3 *header = 1327: (struct kgsl_snapshot_mvc_regs_v3 *)buf; 1328: u32 *data = (u32 *)(buf + sizeof(*header)); 1329: struct gen8_cluster_registers_info *info = 1330: (struct gen8_cluster_registers_info *)priv; 1331: const u32 *ptr = info->cluster->regs; 1332: u32 size = adreno_snapshot_regs_count(ptr) * sizeof(*data); 1333: u32 j; 1334: 1335: if (remain < (sizeof(*header) + size)) { 1336: SNAPSHOT_ERR_NOMEM(device, "MVC REGISTERS"); 1337: return 0; 1338: } 1339: 1340: header->ctxt_id = (info->context_id == STATE_FORCE_CTXT_1) ? 1 : 0; 1341: header->cluster_id = info->cluster_id; 1342: header->pipe_id = info->pipe_id; 1343: header->location_id = UINT_MAX; 1344: header->sp_id = UINT_MAX; 1345: header->usptp_id = UINT_MAX; 1346: header->slice_id = HEADER_SLICE_ID(info->cluster->slice_region, info->slice_id); 1347: 1348: /* 1349: * Set the AHB control for the Host to read from the 1350: * cluster/context for this iteration. 1351: */ 1352: kgsl_regwrite(device, GEN8_CP_APERTURE_CNTL_HOST, GEN8_CP_APERTURE_REG_VAL 1353: (info->slice_id, info->pipe_id, info->cluster_id, info->context_id)); 1354: 1355: if (info->cluster->sel) 1356: kgsl_regwrite(device, info->cluster->sel->host_reg, info->cluster->sel->val); 1357: 1358: /* Make sure the previous writes are posted before reading */ 1359: mb(); 1360: MATCH LINES: 1377, 1380, 1381, 1388, 1391, 1422, 1423, 1443, 1444, 1445 1365: *data++ = ptr[0]; 1366: else { 1367: *data++ = ptr[0] | (1 << 31); 1368: *data++ = ptr[1]; 1369: } 1370: for (j = ptr[0]; j <= ptr[1]; j++) 1371: kgsl_regread(device, j, data++); 1372: } 1373: 1374: return (size + sizeof(*header)); 1375: } 1376: 1377: static size_t gen8_snapshot_mvc(struct kgsl_device *device, u8 *buf, 1378: size_t remain, void *priv) 1379: { 1380: struct kgsl_snapshot_mvc_regs_v3 *header = 1381: (struct kgsl_snapshot_mvc_regs_v3 *)buf; 1382: struct gen8_cluster_registers_info *info = 1383: (struct gen8_cluster_registers_info *)priv; 1384: const u32 *ptr = info->cluster->regs; 1385: u32 *data = (u32 *)(buf + sizeof(*header)); 1386: u32 *src; 1387: u32 cnt; 1388: u32 size = adreno_snapshot_regs_count(ptr) * sizeof(*data); 1389: 1390: if (remain < (sizeof(*header) + size)) { 1391: SNAPSHOT_ERR_NOMEM(device, "MVC REGISTERS"); 1392: return 0; 1393: } 1394: 1395: header->ctxt_id = (info->context_id == STATE_FORCE_CTXT_1) ? 1 : 0; 1396: header->cluster_id = info->cluster_id; 1397: header->pipe_id = info->pipe_id; 1398: header->location_id = UINT_MAX; 1399: header->sp_id = UINT_MAX; 1400: header->usptp_id = UINT_MAX; 1401: header->slice_id = HEADER_SLICE_ID(info->cluster->slice_region, info->slice_id); 1402: 1403: src = gen8_crashdump_registers->hostptr + info->offset; 1404: 1405: for (; ptr[0] != UINT_MAX; ptr += 2) { 1406: cnt = REG_COUNT(ptr); 1407: 1408: if (cnt == 1) 1409: *data++ = ptr[0]; 1410: else { 1411: *data++ = ptr[0] | (1 << 31); 1412: *data++ = ptr[1]; 1413: } 1414: memcpy(data, src, cnt << 2); 1415: src += cnt; 1416: data += cnt; 1417: } 1418: 1419: return (size + sizeof(*header)); 1420: } 1421: 1422: static bool gen8_snapshot_mvc_regs(struct kgsl_device *device, 1423: struct kgsl_snapshot *snapshot, 1424: struct gen8_cluster_registers *clusters, 1425: size_t num_cluster) 1426: { 1427: u32 i, j; 1428: u64 *ptr, offset = 0; 1429: u32 count; 1430: struct gen8_cluster_registers_info info = {0}; 1431: u32 slice_mask = gen8_get_slice_mask(ADRENO_DEVICE(device)); 1432: 1433: if (CD_SCRIPT_CHECK(device)) { 1434: for (i = 0; i < num_cluster; i++) { 1435: struct gen8_cluster_registers *cluster = &clusters[i]; 1436: 1437: FOR_EACH_SLICE(j, cluster->slice_region, slice_mask) { 1438: info.cluster = cluster; 1439: info.pipe_id = cluster->pipe_id; 1440: info.cluster_id = cluster->cluster_id; 1441: info.context_id = cluster->context_id; 1442: info.slice_id = SLICE_ID(cluster->slice_region, j); 1443: kgsl_snapshot_add_section(device, 1444: KGSL_SNAPSHOT_SECTION_MVC_V3, snapshot, 1445: gen8_legacy_snapshot_mvc, &info); 1446: } 1447: } 1448: return true; 1449: } 1450: 1451: for (i = 0; i < num_cluster; i++) { 1452: struct gen8_cluster_registers *cluster = &clusters[i]; 1453: 1454: cluster->offset = offset; 1455: 1456: FOR_EACH_SLICE(j, cluster->slice_region, slice_mask) { 1457: const u32 *regs = cluster->regs; 1458: 1459: info.cluster = cluster; 1460: info.pipe_id = cluster->pipe_id; 1461: info.cluster_id = cluster->cluster_id; 1462: info.context_id = cluster->context_id; 1463: info.slice_id = SLICE_ID(cluster->slice_region, j); 1464: info.offset = offset; 1465: 1466: /* Build the crash script */ 1467: ptr = gen8_capturescript->hostptr; 1468: 1469: ptr += CD_WRITE(ptr, GEN8_CP_APERTURE_CNTL_CD, GEN8_CP_APERTURE_REG_VAL MATCH LINES: 1491, 1492 1479: count, (gen8_crashdump_registers->gpuaddr + offset)); 1480: 1481: offset += count * sizeof(u32); 1482: } 1483: 1484: /* Marker for end of script */ 1485: CD_FINISH(ptr, offset); 1486: 1487: /* Try to run the crash dumper and bail if it times out */ 1488: if (!_gen8_do_crashdump(device)) 1489: return false; 1490: 1491: kgsl_snapshot_add_section(device, 1492: KGSL_SNAPSHOT_SECTION_MVC_V3, snapshot, gen8_snapshot_mvc, &info); 1493: } 1494: } 1495: return true; 1496: } 1497: 1498: static void gen8_debugbus_internal_read_setup(struct kgsl_device *device) 1499: { 1500: /* Clear the DBGC logic/events */ 1501: kgsl_regwrite(device, GEN8_CX_DBGC_CFG_DBGBUS_CNTLM, 0x70000000); 1502: 1503: /* Enable the internal buffer mode and program to tail mode */ 1504: kgsl_regwrite(device, GEN8_CX_DBGC_CFG_DBGBUS_OPL, 0x28000000); 1505: 1506: /* Program the logic unit 0 to high when the side data is 1 */ 1507: kgsl_regwrite(device, GEN8_CX_DBGC_CFG_DBGBUS_BYTEL_0, 0x0000000c); 1508: kgsl_regwrite(device, GEN8_CX_DBGC_CFG_DBGBUS_MASKL_0, 0x000000f0); 1509: 1510: /* Enable the DBGC logic/events */ 1511: kgsl_regwrite(device, GEN8_CX_DBGC_CFG_DBGBUS_CNTLM, 0x07000000); 1512: } 1513: 1514: static void gen8_cx_gc_us_i_0_debugbus_read(struct kgsl_device *device, 1515: u32 block_id, u32 index, u32 *val) 1516: { MATCH LINES: 1574, 1575, 1578, 1579, 1585, 1620, 1623, 1624, 1631 1562: 1563: /* 1564: * There needs to be a delay of 1 us to ensure enough time for correct 1565: * data is funneled into the trace buffer 1566: */ 1567: udelay(1); 1568: 1569: kgsl_regread(device, GEN8_DBGC_CFG_DBGBUS_TRACE_BUF2, val); 1570: val++; 1571: kgsl_regread(device, GEN8_DBGC_CFG_DBGBUS_TRACE_BUF1, val); 1572: } 1573: 1574: /* gen8_snapshot_dbgc_debugbus_block() - Capture debug data for a gpu block */ 1575: static size_t gen8_snapshot_dbgc_debugbus_block(struct kgsl_device *device, 1576: u8 *buf, size_t remain, void *priv) 1577: { 1578: struct kgsl_snapshot_debugbus *header = 1579: (struct kgsl_snapshot_debugbus *)buf; 1580: const u32 *block = priv; 1581: u32 i; 1582: u32 *data = (u32 *)(buf + sizeof(*header)); 1583: 1584: if (remain < GEN8_DEBUGBUS_SECTION_SIZE) { 1585: SNAPSHOT_ERR_NOMEM(device, "DEBUGBUS"); 1586: return 0; 1587: } 1588: 1589: header->id = *block; 1590: header->count = GEN8_DEBUGBUS_BLOCK_SIZE * 2; 1591: 1592: for (i = 0; i < GEN8_DEBUGBUS_BLOCK_SIZE; i++) 1593: gen8_dbgc_debug_bus_read(device, *block, i, &data[i*2]); 1594: 1595: return GEN8_DEBUGBUS_SECTION_SIZE; 1596: } 1597: 1598: static void gen8_dbgc_side_debug_bus_read(struct kgsl_device *device, 1599: u32 block_id, u32 index, u32 *val) 1600: { 1601: u32 reg = FIELD_PREP(GENMASK(7, 0), index) | 1602: FIELD_PREP(GENMASK(27, 16), block_id); 1603: 1604: kgsl_regwrite(device, GEN8_DBGC_CFG_DBGBUS_SEL_A, reg); 1605: kgsl_regwrite(device, GEN8_DBGC_CFG_DBGBUS_SEL_B, reg); 1606: kgsl_regwrite(device, GEN8_DBGC_CFG_DBGBUS_SEL_C, reg); 1607: kgsl_regwrite(device, GEN8_DBGC_CFG_DBGBUS_SEL_D, reg); 1608: 1609: /* 1610: * There needs to be a delay of 1 us to ensure enough time for correct 1611: * data is funneled into the trace buffer 1612: */ 1613: udelay(1); 1614: 1615: reg = kgsl_regmap_read(&device->regmap, GEN8_DBGC_CFG_DBGBUS_OVER); 1616: 1617: *val = FIELD_GET(GENMASK(27, 24), reg); 1618: } 1619: 1620: static size_t gen8_snapshot_dbgc_side_debugbus_block(struct kgsl_device *device, 1621: u8 *buf, size_t remain, void *priv) 1622: { 1623: struct kgsl_snapshot_side_debugbus *header = 1624: (struct kgsl_snapshot_side_debugbus *)buf; 1625: const u32 *block = priv; 1626: int i; 1627: u32 *data = (u32 *)(buf + sizeof(*header)); 1628: size_t size = (GEN8_DEBUGBUS_BLOCK_SIZE * sizeof(u32)) + sizeof(*header); 1629: 1630: if (remain < size) { 1631: SNAPSHOT_ERR_NOMEM(device, "DEBUGBUS"); 1632: return 0; 1633: } 1634: 1635: header->id = *block; 1636: header->size = GEN8_DEBUGBUS_BLOCK_SIZE; 1637: header->valid_data = 0x4; 1638: 1639: for (i = 0; i < GEN8_DEBUGBUS_BLOCK_SIZE; i++) 1640: gen8_dbgc_side_debug_bus_read(device, *block, i, &data[i]); 1641: 1642: return size; 1643: } 1644: 1645: /* gen8_cx_dbgc_debug_bus_read() - Read data from trace bus */ 1646: static void gen8_cx_debug_bus_read(struct kgsl_device *device, 1647: u32 block_id, u32 index, u32 *val) 1648: { 1649: u32 reg = FIELD_PREP(GENMASK(7, 0), index) | 1650: FIELD_PREP(GENMASK(27, 16), block_id); 1651: 1652: kgsl_regwrite(device, GEN8_CX_DBGC_CFG_DBGBUS_SEL_A, reg); 1653: kgsl_regwrite(device, GEN8_CX_DBGC_CFG_DBGBUS_SEL_B, reg); 1654: kgsl_regwrite(device, GEN8_CX_DBGC_CFG_DBGBUS_SEL_C, reg); 1655: kgsl_regwrite(device, GEN8_CX_DBGC_CFG_DBGBUS_SEL_D, reg); MATCH LINES: 1672, 1675, 1678, 1679, 1685 1660: */ 1661: udelay(1); 1662: 1663: kgsl_regread(device, GEN8_CX_DBGC_CFG_DBGBUS_TRACE_BUF2, val); 1664: val++; 1665: kgsl_regread(device, GEN8_CX_DBGC_CFG_DBGBUS_TRACE_BUF1, val); 1666: } 1667: 1668: #define GEN8_DEBUGBUS_BLOCK_IDX_1 128 1669: #define GEN8_DEBUGBUS_BLOCK_IDX_2 192 1670: 1671: /* 1672: * gen8_snapshot_cx_dbgc_debugbus_block() - Capture debug data for a gpu 1673: * block from the CX DBGC block 1674: */ 1675: static size_t gen8_snapshot_cx_dbgc_debugbus_block(struct kgsl_device *device, 1676: u8 *buf, size_t remain, void *priv) 1677: { 1678: struct kgsl_snapshot_debugbus *header = 1679: (struct kgsl_snapshot_debugbus *)buf; 1680: const u32 *block = priv; 1681: int i; 1682: u32 *data = (u32 *)(buf + sizeof(*header)); 1683: 1684: if (remain < GEN8_DEBUGBUS_SECTION_SIZE) { 1685: SNAPSHOT_ERR_NOMEM(device, "DEBUGBUS"); 1686: return 0; 1687: } 1688: 1689: header->id = *block; 1690: header->count = GEN8_DEBUGBUS_BLOCK_SIZE * 2; 1691: 1692: /* This block requires an out of order access due to a HW limitation */ 1693: if (*block == DEBUGBUS_CX_GC_US_I_0) { 1694: gen8_debugbus_internal_read_setup(device); 1695: for (i = 0; i < GEN8_DEBUGBUS_BLOCK_IDX_1; i++) 1696: gen8_cx_gc_us_i_0_debugbus_read(device, *block, i, &data[i * 2]); 1697: for (i = GEN8_DEBUGBUS_BLOCK_IDX_2; i < GEN8_DEBUGBUS_BLOCK_SIZE; i++) 1698: gen8_cx_gc_us_i_0_debugbus_read(device, *block, i, &data[i * 2]); 1699: for (i = GEN8_DEBUGBUS_BLOCK_IDX_1; i < GEN8_DEBUGBUS_BLOCK_IDX_2; i++) 1700: gen8_cx_gc_us_i_0_debugbus_read(device, *block, i, &data[i * 2]); 1701: } else { 1702: for (i = 0; i < GEN8_DEBUGBUS_BLOCK_SIZE; i++) 1703: gen8_cx_debug_bus_read(device, *block, i, &data[i * 2]); 1704: } 1705: 1706: return GEN8_DEBUGBUS_SECTION_SIZE; 1707: } 1708: 1709: /* gen8_cx_side_dbgc_debug_bus_read() - Read data from trace bus */ MATCH LINES: 1732, 1735, 1738, 1739, 1746, 1760, 1761 1720: 1721: /* 1722: * There needs to be a delay of 1 us to ensure enough time for correct 1723: * data is funneled into the trace buffer 1724: */ 1725: udelay(1); 1726: 1727: kgsl_regread(device, GEN8_CX_DBGC_CFG_DBGBUS_OVER, ®); 1728: *val = FIELD_GET(GENMASK(27, 24), reg); 1729: } 1730: 1731: /* 1732: * gen8_snapshot_cx_dbgc_debugbus_block() - Capture debug data for a gpu 1733: * block from the CX DBGC block 1734: */ 1735: static size_t gen8_snapshot_cx_side_dbgc_debugbus_block(struct kgsl_device *device, 1736: u8 *buf, size_t remain, void *priv) 1737: { 1738: struct kgsl_snapshot_side_debugbus *header = 1739: (struct kgsl_snapshot_side_debugbus *)buf; 1740: const u32 *block = priv; 1741: int i; 1742: u32 *data = (u32 *)(buf + sizeof(*header)); 1743: size_t size = (GEN8_DEBUGBUS_BLOCK_SIZE * sizeof(u32)) + sizeof(*header); 1744: 1745: if (remain < size) { 1746: SNAPSHOT_ERR_NOMEM(device, "DEBUGBUS"); 1747: return 0; 1748: } 1749: 1750: header->id = *block; 1751: header->size = GEN8_DEBUGBUS_BLOCK_SIZE; 1752: header->valid_data = 0x4; 1753: 1754: for (i = 0; i < GEN8_DEBUGBUS_BLOCK_SIZE; i++) 1755: gen8_cx_side_debug_bus_read(device, *block, i, &data[i]); 1756: 1757: return size; 1758: } 1759: 1760: static void gen8_snapshot_cx_debugbus(struct adreno_device *adreno_dev, 1761: struct kgsl_snapshot *snapshot) 1762: { 1763: u32 i; 1764: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1765: 1766: if (device->debug_bus_bin) 1767: return; 1768: 1769: kgsl_regwrite(device, GEN8_CX_DBGC_CFG_DBGBUS_CNTLT, 1770: FIELD_PREP(GENMASK(31, 28), 0xf)); 1771: 1772: kgsl_regwrite(device, GEN8_CX_DBGC_CFG_DBGBUS_CNTLM, 1773: FIELD_PREP(GENMASK(27, 24), 0xf)); 1774: 1775: kgsl_regwrite(device, GEN8_CX_DBGC_CFG_DBGBUS_IVTL_0, 0); 1776: kgsl_regwrite(device, GEN8_CX_DBGC_CFG_DBGBUS_IVTL_1, 0); 1777: kgsl_regwrite(device, GEN8_CX_DBGC_CFG_DBGBUS_IVTL_2, 0); 1778: kgsl_regwrite(device, GEN8_CX_DBGC_CFG_DBGBUS_IVTL_3, 0); 1779: 1780: kgsl_regwrite(device, GEN8_CX_DBGC_CFG_DBGBUS_BYTEL_0, 1781: FIELD_PREP(GENMASK(3, 0), 0x0) | 1782: FIELD_PREP(GENMASK(7, 4), 0x1) | 1783: FIELD_PREP(GENMASK(11, 8), 0x2) | 1784: FIELD_PREP(GENMASK(15, 12), 0x3) | 1785: FIELD_PREP(GENMASK(19, 16), 0x4) | MATCH LINES: 1806, 1807, 1808, 1809, 1810, 1811, 1812, 1813, 1814, 1818, 1819, 1820 1794: FIELD_PREP(GENMASK(19, 16), 0xc) | 1795: FIELD_PREP(GENMASK(23, 20), 0xd) | 1796: FIELD_PREP(GENMASK(27, 24), 0xe) | 1797: FIELD_PREP(GENMASK(31, 28), 0xf)); 1798: 1799: kgsl_regwrite(device, GEN8_CX_DBGC_CFG_DBGBUS_MASKL_0, 0); 1800: kgsl_regwrite(device, GEN8_CX_DBGC_CFG_DBGBUS_MASKL_1, 0); 1801: 1802: /* Dump the CX debugbus data if the block exists */ 1803: if (!kgsl_regmap_valid_offset(&device->regmap, GEN8_CX_DBGC_CFG_DBGBUS_SEL_A)) 1804: return; 1805: 1806: for (i = 0; i < gen8_snapshot_block_list->cx_debugbus_blocks_len; i++) { 1807: kgsl_snapshot_add_section(device, 1808: KGSL_SNAPSHOT_SECTION_DEBUGBUS, 1809: snapshot, gen8_snapshot_cx_dbgc_debugbus_block, 1810: (void *) &gen8_snapshot_block_list->cx_debugbus_blocks[i]); 1811: kgsl_snapshot_add_section(device, 1812: KGSL_SNAPSHOT_SECTION_SIDE_DEBUGBUS, 1813: snapshot, gen8_snapshot_cx_side_dbgc_debugbus_block, 1814: (void *) &gen8_snapshot_block_list->cx_debugbus_blocks[i]); 1815: } 1816: } 1817: 1818: /* gen8_snapshot_debugbus() - Capture debug bus data */ 1819: static void gen8_snapshot_debugbus(struct adreno_device *adreno_dev, 1820: struct kgsl_snapshot *snapshot) 1821: { 1822: u32 i; 1823: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1824: 1825: if (device->debug_bus_bin) 1826: return; 1827: 1828: kgsl_regwrite(device, GEN8_DBGC_CFG_DBGBUS_CNTLT, 1829: FIELD_PREP(GENMASK(31, 28), 0xf)); 1830: 1831: kgsl_regwrite(device, GEN8_DBGC_CFG_DBGBUS_CNTLM, 1832: FIELD_PREP(GENMASK(27, 24), 0xf)); 1833: 1834: kgsl_regwrite(device, GEN8_DBGC_CFG_DBGBUS_IVTL_0, 0); 1835: kgsl_regwrite(device, GEN8_DBGC_CFG_DBGBUS_IVTL_1, 0); 1836: kgsl_regwrite(device, GEN8_DBGC_CFG_DBGBUS_IVTL_2, 0); 1837: kgsl_regwrite(device, GEN8_DBGC_CFG_DBGBUS_IVTL_3, 0); 1838: 1839: kgsl_regwrite(device, GEN8_DBGC_CFG_DBGBUS_BYTEL_0, 1840: FIELD_PREP(GENMASK(3, 0), 0x0) | 1841: FIELD_PREP(GENMASK(7, 4), 0x1) | 1842: FIELD_PREP(GENMASK(11, 8), 0x2) | 1843: FIELD_PREP(GENMASK(15, 12), 0x3) | 1844: FIELD_PREP(GENMASK(19, 16), 0x4) | MATCH LINES: 1863, 1864, 1865, 1866, 1867, 1868, 1869, 1870, 1871, 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1886, 1887, 1891, 1902, 1903 1851: FIELD_PREP(GENMASK(11, 8), 0xa) | 1852: FIELD_PREP(GENMASK(15, 12), 0xb) | 1853: FIELD_PREP(GENMASK(19, 16), 0xc) | 1854: FIELD_PREP(GENMASK(23, 20), 0xd) | 1855: FIELD_PREP(GENMASK(27, 24), 0xe) | 1856: FIELD_PREP(GENMASK(31, 28), 0xf)); 1857: 1858: kgsl_regwrite(device, GEN8_DBGC_CFG_DBGBUS_MASKL_0, 0); 1859: kgsl_regwrite(device, GEN8_DBGC_CFG_DBGBUS_MASKL_1, 0); 1860: kgsl_regwrite(device, GEN8_DBGC_CFG_DBGBUS_MASKL_2, 0); 1861: kgsl_regwrite(device, GEN8_DBGC_CFG_DBGBUS_MASKL_3, 0); 1862: 1863: for (i = 0; i < gen8_snapshot_block_list->debugbus_blocks_len; i++) { 1864: kgsl_snapshot_add_section(device, 1865: KGSL_SNAPSHOT_SECTION_DEBUGBUS, 1866: snapshot, gen8_snapshot_dbgc_debugbus_block, 1867: (void *) &gen8_snapshot_block_list->debugbus_blocks[i]); 1868: kgsl_snapshot_add_section(device, 1869: KGSL_SNAPSHOT_SECTION_SIDE_DEBUGBUS, 1870: snapshot, gen8_snapshot_dbgc_side_debugbus_block, 1871: (void *) &gen8_snapshot_block_list->debugbus_blocks[i]); 1872: } 1873: 1874: for (i = 0; i < gen8_snapshot_block_list->gbif_debugbus_blocks_len; i++) { 1875: kgsl_snapshot_add_section(device, 1876: KGSL_SNAPSHOT_SECTION_DEBUGBUS, 1877: snapshot, gen8_snapshot_dbgc_debugbus_block, 1878: (void *) &gen8_snapshot_block_list->gbif_debugbus_blocks[i]); 1879: kgsl_snapshot_add_section(device, 1880: KGSL_SNAPSHOT_SECTION_SIDE_DEBUGBUS, 1881: snapshot, gen8_snapshot_dbgc_side_debugbus_block, 1882: (void *) &gen8_snapshot_block_list->gbif_debugbus_blocks[i]); 1883: } 1884: } 1885: 1886: static bool gen8_reglist_snapshot(struct kgsl_device *device, 1887: struct kgsl_snapshot *snapshot) 1888: { 1889: u64 *ptr, offset = 0; 1890: u32 i, j, r; 1891: struct gen8_reg_list *reg_list = gen8_snapshot_block_list->reg_list; 1892: struct gen8_reg_list_info info = {0}; 1893: u32 slice_mask = gen8_get_slice_mask(ADRENO_DEVICE(device)); 1894: 1895: if (CD_SCRIPT_CHECK(device)) { 1896: for (i = 0; reg_list[i].regs; i++) { 1897: struct gen8_reg_list *regs = ®_list[i]; 1898: 1899: FOR_EACH_SLICE(j, regs->slice_region, slice_mask) { 1900: info.regs = regs; 1901: info.slice_id = SLICE_ID(regs->slice_region, j); 1902: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_MVC_V3, 1903: snapshot, gen8_legacy_snapshot_registers, &info); 1904: } 1905: } 1906: return true; 1907: } 1908: 1909: for (i = 0; reg_list[i].regs; i++) { 1910: struct gen8_reg_list *regs = ®_list[i]; 1911: 1912: regs->offset = offset; 1913: 1914: FOR_EACH_SLICE(j, regs->slice_region, slice_mask) { 1915: const u32 *regs_ptr = regs->regs; 1916: 1917: /* Build the crash script */ 1918: ptr = gen8_capturescript->hostptr; 1919: 1920: ptr += CD_WRITE(ptr, GEN8_CP_APERTURE_CNTL_CD, GEN8_CP_APERTURE_REG_VAL 1921: (j, 0, 0, 0)); 1922: /* Program the SEL_CNTL_CD register appropriately */ 1923: if (regs->sel) 1924: ptr += CD_WRITE(ptr, regs->sel->cd_reg, regs->sel->val); 1925: info.regs = regs; 1926: info.slice_id = SLICE_ID(regs->slice_region, j); 1927: info.offset = offset; MATCH LINES: 1943, 1944, 1951, 1956, 1959, 1983, 1984, 1987, 1991, 2009, 2010, 2011, 2016, 2017, 2024, 2025, 2030, 2031, 2037, 2038, 2039, 2042, 2043, 2047, 2048, 2053, 2054, 2055, 2056, 2057, 2058, 2066, 2067, 2076, 2077, 2078, 2079, 2080, 2081, 2090, 2091, 2092, 2095, 2097, 2098, 2106, 2108, 2110, 2116, 2120, 2121, 2123, 2124, 2126, 2127, 2129, 2135, 2137, 2145, 2148, 2151, 2154, 2156, 2158, 2162, 2165, 2168, 2170, 2179, 2180, 2181, 2184, 2188, 2189, 2196, 2197, 2205, 2209, 2213, 2217, 2225, 2226, 2230, 2231, 2235, 2239, 2242, 2246 1931: ptr += CD_READ(ptr, regs_ptr[0], r, 1932: (gen8_crashdump_registers->gpuaddr + offset)); 1933: offset += r * sizeof(u32); 1934: } 1935: 1936: /* Marker for end of script */ 1937: CD_FINISH(ptr, offset); 1938: 1939: /* Try to run the crash dumper and bail if it times out */ 1940: if (!_gen8_do_crashdump(device)) 1941: return false; 1942: 1943: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_MVC_V3, 1944: snapshot, gen8_snapshot_registers, &info); 1945: } 1946: } 1947: 1948: return true; 1949: } 1950: 1951: static size_t gen8_snapshot_cx_misc_registers(struct kgsl_device *device, u8 *buf, 1952: size_t remain, void *priv) 1953: { 1954: const u32 *ptr = (u32 *)priv; 1955: u32 *src, *data = (unsigned int *)buf; 1956: size_t size = adreno_snapshot_regs_count(ptr) * sizeof(u32); 1957: 1958: if (remain < size) { 1959: SNAPSHOT_ERR_NOMEM(device, "CX_MISC REGISTERS"); 1960: return 0; 1961: } 1962: 1963: src = gen8_crashdump_registers->hostptr; 1964: 1965: for (; ptr[0] != UINT_MAX; ptr += 2) { 1966: u32 cnt = REG_COUNT(ptr); 1967: 1968: if (cnt == 1) 1969: *data++ = BIT(31) | ptr[0]; 1970: else { 1971: *data++ = ptr[0]; 1972: *data++ = cnt; 1973: } 1974: memcpy(data, src, cnt << 2); 1975: data += cnt; 1976: src += cnt; 1977: } 1978: 1979: /* Return the size of the section */ 1980: return size; 1981: } 1982: 1983: static bool gen8_cx_misc_regs_snapshot(struct kgsl_device *device, 1984: struct kgsl_snapshot *snapshot) 1985: { 1986: u64 *ptr, offset = 0; 1987: const u32 *regs_ptr = (const u32 *)gen8_snapshot_block_list->cx_misc_regs; 1988: 1989: if (CD_SCRIPT_CHECK(device) || !gen8_gmu_rpmh_pwr_state_is_active(device) 1990: || !gen8_gmu_gx_is_on(ADRENO_DEVICE(device))) 1991: goto legacy_snapshot; 1992: 1993: /* Build the crash script */ 1994: ptr = (u64 *)gen8_capturescript->hostptr; 1995: 1996: for (; regs_ptr[0] != UINT_MAX; regs_ptr += 2) { 1997: u32 r = REG_COUNT(regs_ptr); 1998: 1999: ptr += CD_READ(ptr, regs_ptr[0], r, 2000: (gen8_crashdump_registers->gpuaddr + offset)); 2001: offset += r * sizeof(u32); 2002: } 2003: 2004: /* Marker for end of script */ 2005: CD_FINISH(ptr, offset); 2006: 2007: /* Try to run the crash dumper if it fails return */ 2008: if (_gen8_do_crashdump(device)) { 2009: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, 2010: snapshot, gen8_snapshot_cx_misc_registers, 2011: (void *)gen8_snapshot_block_list->cx_misc_regs); 2012: return true; 2013: } else 2014: return false; 2015: 2016: legacy_snapshot: 2017: regs_ptr = (const u32 *)gen8_snapshot_block_list->cx_misc_regs; 2018: 2019: if (!kgsl_regmap_valid_offset(&device->regmap, regs_ptr[0])) { 2020: WARN_ONCE(1, "cx_misc registers are not defined in device tree"); 2021: return true; 2022: } 2023: 2024: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, 2025: snapshot, adreno_snapshot_registers_v2, (void *)regs_ptr); 2026: 2027: return true; 2028: } 2029: 2030: void gen8_snapshot_external_core_regs(struct kgsl_device *device, 2031: struct kgsl_snapshot *snapshot) 2032: { 2033: const u32 **external_core_regs; 2034: u32 i, num_external_core_regs; 2035: const struct adreno_gen8_core *gpucore = to_gen8_core(ADRENO_DEVICE(device)); 2036: 2037: gen8_snapshot_block_list = gpucore->gen8_snapshot_block_list; 2038: external_core_regs = gen8_snapshot_block_list->external_core_regs; 2039: num_external_core_regs = gen8_snapshot_block_list->num_external_core_regs; 2040: 2041: for (i = 0; i < num_external_core_regs; i++) 2042: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, 2043: snapshot, adreno_snapshot_registers_v2, 2044: (void *) external_core_regs[i]); 2045: } 2046: 2047: static bool gen8_snapshot_cp_indexed_regs(struct kgsl_device *device, 2048: struct kgsl_snapshot *snapshot) 2049: { 2050: bool ret = true; 2051: int i; 2052: 2053: for (i = 0; i < gen8_snapshot_block_list->index_registers_len; i++) { 2054: ret = gen8_snapshot_indexed_registers(device, snapshot, 2055: gen8_snapshot_block_list->index_registers[i].addr, 2056: gen8_snapshot_block_list->index_registers[i].data, 0, 2057: gen8_snapshot_block_list->index_registers[i].size, 2058: gen8_snapshot_block_list->index_registers[i].pipe_id, UINT_MAX); 2059: if (!ret) 2060: break; 2061: } 2062: 2063: return ret; 2064: } 2065: 2066: static bool gen8_snapshot_pc_indexed_regs(struct kgsl_device *device, 2067: struct kgsl_snapshot *snapshot) 2068: { 2069: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 2070: bool ret = true; 2071: int i; 2072: 2073: if (!adreno_is_gen8_11_x(adreno_dev)) 2074: return true; 2075: 2076: for (i = 0; i < gen8_snapshot_block_list->pc_index_registers_len; i++) { 2077: ret = gen8_snapshot_indexed_registers(device, snapshot, 2078: gen8_snapshot_block_list->pc_index_registers[i].addr, 2079: gen8_snapshot_block_list->pc_index_registers[i].data, 0, 2080: gen8_snapshot_block_list->pc_index_registers[i].size, 2081: gen8_snapshot_block_list->pc_index_registers[i].pipe_id, UINT_MAX); 2082: if (!ret) 2083: break; 2084: } 2085: 2086: return ret; 2087: } 2088: 2089: /* 2090: * gen8_snapshot() - GEN8 GPU snapshot function 2091: * @adreno_dev: Device being snapshotted 2092: * @snapshot: Pointer to the snapshot instance 2093: * 2094: * This is where all of the GEN8 specific bits and pieces are grabbed 2095: * into the snapshot memory 2096: */ 2097: void gen8_snapshot(struct adreno_device *adreno_dev, 2098: struct kgsl_snapshot *snapshot) 2099: { 2100: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2101: u32 i, slice_mask; 2102: const struct adreno_gen8_core *gpucore = to_gen8_core(ADRENO_DEVICE(device)); 2103: int is_current_rt; 2104: 2105: gen8_crashdump_timedout = false; 2106: gen8_snapshot_block_list = gpucore->gen8_snapshot_block_list; 2107: 2108: /* External core and CX MISC regs are dumped in the beginning of gmu snapshot */ 2109: if (!gmu_core_isenabled(device)) { 2110: gen8_snapshot_external_core_regs(device, snapshot); 2111: 2112: /* 2113: * If crashdumper timed out while dumping this section skip everything 2114: * since even AHB accesses to the GPU might cause NoC errors. 2115: */ 2116: if (!gen8_cx_misc_regs_snapshot(device, snapshot)) 2117: return; 2118: } 2119: 2120: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_DEBUG, 2121: snapshot, gen8_snapshot_slice_mask, NULL); 2122: 2123: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_DEBUG, 2124: snapshot, gen8_snapshot_rbbm_status, NULL); 2125: 2126: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_DEBUG, 2127: snapshot, gen8_snapshot_malu_status, NULL); 2128: 2129: gen8_snapshot_cx_debugbus(adreno_dev, snapshot); 2130: 2131: if (!gen8_gmu_rpmh_pwr_state_is_active(device) || 2132: !gen8_gmu_gx_is_on(adreno_dev)) 2133: return; 2134: 2135: gen8_snapshot_trace_buffer(device, snapshot); 2136: 2137: gen8_snapshot_debugbus(adreno_dev, snapshot); 2138: 2139: is_current_rt = rt_task(current); 2140: 2141: if (is_current_rt) 2142: sched_set_normal(current, 0); 2143: 2144: gen8_periph_regread64(device, GEN8_CP_PERIPH_IB1_BASE_LO, 2145: GEN8_CP_PERIPH_IB1_BASE_HI, &snapshot->ib1base, PIPE_BR); 2146: 2147: gen8_periph_regread64(device, GEN8_CP_PERIPH_IB2_BASE_LO, 2148: GEN8_CP_PERIPH_IB2_BASE_HI, &snapshot->ib2base, PIPE_BR); 2149: 2150: gen8_periph_regread64(device, GEN8_CP_PERIPH_IB3_BASE_LO, 2151: GEN8_CP_PERIPH_IB3_BASE_HI, &snapshot->ib3base, PIPE_BR); 2152: 2153: gen8_periph_regread(device, GEN8_CP_PERIPH_IB1_SIZE, 2154: &snapshot->ib1size, PIPE_BR); 2155: gen8_periph_regread(device, GEN8_CP_PERIPH_IB2_SIZE, 2156: &snapshot->ib2size, PIPE_BR); 2157: gen8_periph_regread(device, GEN8_CP_PERIPH_IB3_SIZE, 2158: &snapshot->ib3size, PIPE_BR); 2159: 2160: if (ADRENO_FEATURE(adreno_dev, ADRENO_LPAC)) { 2161: gen8_periph_regread64(device, GEN8_CP_PERIPH_IB1_BASE_LO, 2162: GEN8_CP_PERIPH_IB1_BASE_HI, &snapshot->ib1base_lpac, PIPE_LPAC); 2163: 2164: gen8_periph_regread64(device, GEN8_CP_PERIPH_IB2_BASE_LO, 2165: GEN8_CP_PERIPH_IB2_BASE_HI, &snapshot->ib2base_lpac, PIPE_LPAC); 2166: 2167: gen8_periph_regread(device, GEN8_CP_PERIPH_IB1_SIZE, 2168: &snapshot->ib1size_lpac, PIPE_LPAC); 2169: gen8_periph_regread(device, GEN8_CP_PERIPH_IB2_SIZE, 2170: &snapshot->ib2size_lpac, PIPE_LPAC); 2171: } 2172: 2173: /* Clear aperture register */ 2174: gen8_host_aperture_set(adreno_dev, 0, 0, 0); 2175: 2176: slice_mask = gen8_get_slice_mask(adreno_dev); 2177: 2178: /* 2179: * Assert the isStatic bit before triggering snapshot. 2180: * BIT(0): GPU activity during snapshot dump 2181: * BIT(1): GPU UNSLICE activity during snapshot dump 2182: * Similarly, BIT(4) for slice-0, BIT(5) for slice-1 and so on. 2183: */ 2184: kgsl_regwrite(device, GEN8_RBBM_SNAPSHOT_STATUS, BIT(0) | BIT(1) | 2185: FIELD_PREP(GENMASK(7, 4), slice_mask)); 2186: 2187: /* Dump the registers which get affected by crash dumper trigger */ 2188: for (i = 0; i < gen8_snapshot_block_list->num_pre_crashdumper_regs; i++) { 2189: struct gen8_reg_list *regs = &gen8_snapshot_block_list->pre_crashdumper_regs[i]; 2190: struct gen8_reg_list_info info = {0}; 2191: u32 j; 2192: 2193: FOR_EACH_SLICE(j, regs->slice_region, slice_mask) { 2194: info.regs = regs; 2195: info.slice_id = SLICE_ID(regs->slice_region, j); 2196: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_MVC_V3, 2197: snapshot, gen8_legacy_snapshot_registers, &info); 2198: } 2199: } 2200: 2201: /* 2202: * If crashdumper timed out while dumping this section skip everything 2203: * since even AHB acceses to the GPU might cause NoC errors. 2204: */ 2205: if (!gen8_reglist_snapshot(device, snapshot)) 2206: goto err; 2207: 2208: /* CP indexed regs data */ 2209: if (!gen8_snapshot_cp_indexed_regs(device, snapshot)) 2210: goto err; 2211: 2212: /* Mempool debug data */ 2213: if (!gen8_snapshot_mempool(device, snapshot)) 2214: goto err; 2215: 2216: /* PC indexed regs data */ 2217: if (!gen8_snapshot_pc_indexed_regs(device, snapshot)) 2218: goto err; 2219: 2220: /* 2221: * CP MVC register section 2222: * If crashdumper timed out while dumping any section below skip everything 2223: * since even AHB acceses to the GPU might cause NoC errors. 2224: */ 2225: if (!gen8_snapshot_mvc_regs(device, snapshot, 2226: gen8_snapshot_block_list->cp_clusters, gen8_snapshot_block_list->num_cp_clusters)) 2227: goto err; 2228: 2229: /* MVC register section */ 2230: if (!gen8_snapshot_mvc_regs(device, snapshot, 2231: gen8_snapshot_block_list->clusters, gen8_snapshot_block_list->num_clusters)) 2232: goto err; 2233: 2234: /* registers dumped through DBG AHB */ 2235: if (!gen8_snapshot_dbgahb_regs(device, snapshot)) 2236: goto err; 2237: 2238: /* Shader memory */ 2239: if (!gen8_snapshot_shader(device, snapshot)) 2240: goto err; 2241: 2242: kgsl_regwrite(device, GEN8_RBBM_SNAPSHOT_STATUS, 0x0); 2243: 2244: err: 2245: /* Preemption record */ 2246: adreno_snapshot_preemption_record(device, snapshot); 2247: 2248: if (is_current_rt) 2249: sched_set_fifo(current); 2250: } 2251: 2252: void gen8_crashdump_init(struct adreno_device *adreno_dev) 2253: { 2254: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2255: int ret; 2256: u64 capturescript_regs_pages = 2257: ((adreno_is_gen8_2_x(adreno_dev) || 2258: adreno_is_gen8_1_0(adreno_dev) || 2259: adreno_is_gen8_11_x(adreno_dev)) ? 400 : 200); 2260: 2261: ret = adreno_allocate_global(device, &gen8_capturescript, 2262: 50 * PAGE_SIZE, 0, KGSL_MEMFLAGS_GPUREADONLY, 2263: KGSL_MEMDESC_PRIVILEGED, "capturescript"); 2264: 2265: if (!ret) 2266: ret = adreno_allocate_global(device, &gen8_crashdump_registers, 2267: capturescript_regs_pages * PAGE_SIZE, 0, 0, 2268: KGSL_MEMDESC_PRIVILEGED, "capturescript_regs"); 2269: 2270: if (ret) --- FILE: \adreno_gen8_snapshot.h | HITS: 6 --- MATCH LINES: 6, 7, 12 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: #ifndef __ADRENO_GEN8_SNAPSHOT_H 7: #define __ADRENO_GEN8_SNAPSHOT_H 8: 9: #include "adreno.h" 10: #include "adreno_gen8.h" 11: #include "kgsl_regmap.h" 12: #include "kgsl_snapshot.h" 13: 14: enum cluster_id { 15: CLUSTER_NONE = 0, 16: CLUSTER_FE_US = 1, 17: CLUSTER_FE_S = 2, 18: CLUSTER_SP_VS = 3, 19: CLUSTER_VPC_VS = 4, 20: CLUSTER_VPC_US = 5, 21: CLUSTER_GRAS = 6, 22: CLUSTER_SP_PS = 7, 23: CLUSTER_VPC_PS = 8, 24: CLUSTER_PS = 9, 25: }; 26: 27: enum location_id { 28: HLSQ_STATE = 0, 29: HLSQ_DP = 1, 30: SP_TOP = 2, 31: USPTP = 3, 32: HLSQ_DP_STR = 4, 33: }; 34: 35: enum uSPTP_id { 36: uSPTP0 = 0, MATCH LINES: 60 48: #define STATE_TOGGLE_CTXT 1 49: #define STATE_FORCE_CTXT_0 2 50: #define STATE_FORCE_CTXT_1 3 51: 52: #define UNSLICE 0 53: #define SLICE 1 54: 55: /* Use SLICE_ID to access the region (0 for unsliced) */ 56: #define SLICE_ID(region, j) ((region == SLICE) ? j : 0) 57: 58: /* 59: * Use HEADER_SLICE_ID to specify the slice in the section header (UINT_MAX for unsliced). 60: * This allows snapshot parsers to differentiate between slice ID 0 and unsliced regions. 61: */ 62: #define HEADER_SLICE_ID(region, j) ((region == SLICE) ? j : UINT_MAX) 63: 64: #define SLICE_ACTIVE(_slice, _slice_mask) \ 65: (!!(BIT(_slice) & (_slice_mask))) 66: 67: static inline int next_slice(int slice, u32 slice_mask) 68: { 69: for (slice++; slice < fls(slice_mask); slice++) { 70: if (SLICE_ACTIVE(slice, slice_mask)) 71: return slice; 72: } 73: 74: return slice; 75: } 76: 77: #define NEXT_SLICE(_slice, _region, _slice_mask) \ 78: ((_region != SLICE) ? fls(_slice_mask) : next_slice(_slice, _slice_mask)) 79: 80: #define FIRST_SLICE(_region, _slice_mask) \ 81: (((_region != SLICE) || SLICE_ACTIVE(0, _slice_mask)) ? 0 : \ 82: NEXT_SLICE(0, _region, _slice_mask)) 83: 84: #define FOR_EACH_SLICE(_slice, _region, _slice_mask) \ MATCH LINES: 745 733: HLSQ_GFX_LOCAL_MISC_RAM_TAG = 91, 734: HLSQ_INST_RAM_1 = 92, 735: HLSQ_STPROC_META = 93, 736: HLSQ_SLICE_BACKEND_META = 94, 737: HLSQ_INST_RAM_2 = 95, 738: HLSQ_DATAPATH_META = 96, 739: HLSQ_FRONTEND_META = 97, 740: HLSQ_INDIRECT_META = 98, 741: HLSQ_BACKEND_META = 99, 742: HLSQ_SHADOW_SP_RAM = 100, 743: }; 744: 745: struct gen8_snapshot_block_list { 746: /* pre_crashdumper_regs : Registers which need to be dumped before CD runs */ 747: struct gen8_reg_list *pre_crashdumper_regs; 748: /* pre_crashdumper_regs_size : Size of registers which need to be dumped before CD runs */ 749: size_t num_pre_crashdumper_regs; 750: /* debugbus_blocks : List of debugbus blocks */ 751: const u32 *debugbus_blocks; 752: /* debugbus_blocks_len : Length of the debugbus list */ 753: size_t debugbus_blocks_len; 754: /* gbif_debugbus_blocks : List of GBIF debugbus blocks */ 755: const u32 *gbif_debugbus_blocks; 756: /* gbif_debugbus_blocks_len : Length of GBIF debugbus list */ 757: size_t gbif_debugbus_blocks_len; 758: /* cx_debugbus_blocks : List of CX debugbus blocks */ 759: const u32 *cx_debugbus_blocks; 760: /* cx_debugbus_blocks_len : Length of the CX debugbus list */ 761: size_t cx_debugbus_blocks_len; 762: /* gx_debugbus_blocks : List of debugbus blocks with sizes */ 763: struct gen8_debugbus_info *sized_gx_debugbus_blocks; 764: /* gx_debugbus_blocks_len : Length of the GX debugbus list */ 765: size_t sized_gx_debugbus_blocks_len; 766: /* cx_debugbus_blocks : List of CX debugbus blocks with sizes */ 767: struct gen8_debugbus_info *sized_cx_debugbus_blocks; 768: /* cx_debugbus_blocks_len : Length of CX the debugbus list */ 769: size_t sized_cx_debugbus_blocks_len; MATCH LINES: 816 804: /* index_registers_len : Length of the index registers */ 805: size_t index_registers_len; 806: /* mempool_index_registers : List of CP mempool_index_registers */ 807: struct gen8_cp_indexed_reg *mempool_index_registers; 808: /* mempool_index_registers_len : Length of the mempool index registers */ 809: size_t mempool_index_registers_len; 810: /* pc_index_registers : List of PC index_registers */ 811: struct gen8_pc_indexed_reg *pc_index_registers; 812: /* pc_index_registers_len : Length of the PC index registers */ 813: size_t pc_index_registers_len; 814: }; 815: 816: #endif /*__ADRENO_GEN8_SNAPSHOT_H */ --- FILE: \adreno_hfi.h | HITS: 5 --- MATCH LINES: 85 73: #define HFI_FEATURE_MINBW 20 74: #define HFI_FEATURE_CLX 21 75: #define HFI_FEATURE_LSR 23 76: #define HFI_FEATURE_LPAC 24 77: #define HFI_FEATURE_HW_FENCE 25 78: #define HFI_FEATURE_PERF_NORETAIN 26 79: #define HFI_FEATURE_DMS 27 80: #define HFI_FEATURE_THERMAL 28 81: #define HFI_FEATURE_AQE 29 82: #define HFI_FEATURE_TDCVS 30 83: #define HFI_FEATURE_DCE 31 84: #define HFI_FEATURE_IFF_PCLX 32 85: #define HFI_FEATURE_SOFT_RESET 0x10000001 86: #define HFI_FEATURE_DCVS_PROFILE 0x10000002 87: #define HFI_FEATURE_FAST_CONTEXT_DESTROY 0x10000003 88: 89: /* 90: * MINBW_HYST_MASK = 0xffff 91: * (7680 xo ticks which is 400us) 92: */ 93: #define DEFAULT_MINBW_HYST 0x1e00 94: 95: /* MINBW_IDX_MASK = 0xff0000*/ 96: #define DEFAULT_MINBW_IDX 0x1 97: 98: #define HFI_MINBW_DEFAULT (DEFAULT_MINBW_HYST | (DEFAULT_MINBW_IDX << 16)) 99: 100: /* Types to be used with H2F_MSG_TABLE */ 101: enum hfi_table_type { 102: HFI_TABLE_BW_VOTE = 0, 103: HFI_TABLE_GPU_PERF = 1, 104: HFI_TABLE_DIDT = 2, 105: HFI_TABLE_ACD = 3, 106: HFI_TABLE_CLX_V1 = 4, 107: HFI_TABLE_CLX_V2 = 5, 108: HFI_TABLE_THERM = 6, 109: HFI_TABLE_DCVS_DATA = 7, MATCH LINES: 1277 1265: /** @type: Type of the payload */ 1266: u16 type; 1267: /** @dwords: Number of dwords in the data array. */ 1268: u16 dwords; 1269: /** @data: A sequence of key-value pairs. Each pair is 2 dwords. */ 1270: u32 data[]; 1271: } __packed; 1272: 1273: /* IDs for context bad hfi payloads */ 1274: #define PAYLOAD_FAULT_REGS 1 1275: #define PAYLOAD_RB 2 1276: #define PAYLOAD_PREEMPT_TIMEOUT 3 1277: #define PAYLOAD_FAULT_RESET_POLICY 4 1278: 1279: /* Keys for PAYLOAD_FAULT_REGS type payload */ 1280: #define KEY_CP_OPCODE_ERROR 1 1281: #define KEY_CP_PROTECTED_ERROR 2 1282: #define KEY_CP_HW_FAULT 3 1283: #define KEY_CP_BV_OPCODE_ERROR 4 1284: #define KEY_CP_BV_PROTECTED_ERROR 5 1285: #define KEY_CP_BV_HW_FAULT 6 1286: #define KEY_CP_LPAC_OPCODE_ERROR 7 1287: #define KEY_CP_LPAC_PROTECTED_ERROR 8 1288: #define KEY_CP_LPAC_HW_FAULT 9 1289: #define KEY_SWFUSE_VIOLATION_FAULT 10 1290: #define KEY_AQE0_OPCODE_ERROR 11 1291: #define KEY_AQE0_HW_FAULT 12 1292: #define KEY_AQE1_OPCODE_ERROR 13 1293: #define KEY_AQE1_HW_FAULT 14 1294: #define KEY_CP_BR_SW_FAULT 15 1295: #define KEY_CP_BV_SW_FAULT 16 1296: #define KEY_CP_LPAC_SW_FAULT 17 1297: #define KEY_CP_AQE0_SW_FAULT 18 1298: #define KEY_CP_AQE0_PROTECTED_ERROR 19 1299: #define KEY_CP_AQE1_SW_FAULT 20 1300: #define KEY_CP_AQE1_PROTECTED_ERROR 21 1301: #define KEY_CP_DDEBR_OPCODE_ERROR 22 MATCH LINES: 1326, 1327 1314: #define KEY_RB_RPTR 2 1315: #define KEY_RB_WPTR 3 1316: #define KEY_RB_SIZEDWORDS 4 1317: #define KEY_RB_QUEUED_TS 5 1318: #define KEY_RB_RETIRED_TS 6 1319: #define KEY_RB_GPUADDR_LO 7 1320: #define KEY_RB_GPUADDR_HI 8 1321: 1322: /* Keys for PAYLOAD_PREEMPT_TIMEOUT type payload */ 1323: #define KEY_PREEMPT_TIMEOUT_CUR_RB_ID 1 1324: #define KEY_PREEMPT_TIMEOUT_NEXT_RB_ID 2 1325: 1326: /* Keys for PAYLOAD_FAULT_RESET_POLICY type payload */ 1327: #define KEY_GPU_RESET_POLICY 1 1328: 1329: /* Types of errors that trigger context bad HFI */ 1330: 1331: /* GPU encountered a CP HW error */ 1332: #define GMU_CP_HW_ERROR 600 1333: /* GPU encountered a GPU Hang interrupt */ 1334: #define GMU_GPU_HW_HANG 601 1335: /* Preemption didn't complete in given time */ 1336: #define GMU_GPU_PREEMPT_TIMEOUT 602 1337: /* Fault due to Long IB timeout */ 1338: #define GMU_GPU_SW_HANG 603 1339: /* GPU encountered a bad opcode */ 1340: #define GMU_CP_OPCODE_ERROR 604 1341: /* GPU encountered protected mode error */ 1342: #define GMU_CP_PROTECTED_ERROR 605 1343: /* GPU encountered an illegal instruction */ 1344: #define GMU_CP_ILLEGAL_INST_ERROR 606 1345: /* GPU encountered a CP ucode error */ 1346: #define GMU_CP_UCODE_ERROR 607 1347: /* GPU encountered a CP hw fault error */ 1348: #define GMU_CP_HW_FAULT_ERROR 608 1349: /* GPU encountered a GPC error */ 1350: #define GMU_CP_GPC_ERROR 609 1351: /* GPU BV encountered a bad opcode */ MATCH LINES: 1565 1553: return (sz_align > ilog2(SZ_4K)) ? (1 << sz_align) : SZ_4K; 1554: } 1555: 1556: /** 1557: * adreno_hwsched_wait_ack_completion - Wait for HFI ack asynchronously 1558: * adreno_dev: Pointer to the adreno device 1559: * dev: Pointer to the device structure 1560: * ack: Pointer to the pending ack 1561: * process_msgq: Function pointer to the msgq processing function 1562: * 1563: * This function waits for the completion structure, which gets signaled asynchronously. In case 1564: * there is a timeout, process the msgq one last time. If the ack is present, log an error and move 1565: * on. If the ack isn't present, log an error, take a snapshot and return -ETIMEDOUT. 1566: * 1567: * Return: 0 on success and -ETIMEDOUT on failure 1568: */ 1569: int adreno_hwsched_wait_ack_completion(struct adreno_device *adreno_dev, 1570: struct device *dev, struct pending_cmd *ack, 1571: void (*process_msgq)(struct adreno_device *adreno_dev)); 1572: 1573: /** 1574: * adreno_hwsched_ctxt_unregister_wait_completion - Wait for HFI ack for context unregister 1575: * adreno_dev: Pointer to the adreno device 1576: * dev: Pointer to the device structure 1577: * context: Pointer to the context structure 1578: * ack: Pointer to the pending ack 1579: * process_msgq: Function pointer to the msgq processing function 1580: * cmd: Pointer to the hfi packet header and data 1581: * 1582: * This function waits for the completion structure for context unregister hfi ack, 1583: * which gets signaled asynchronously. In case there is a timeout, process the msgq 1584: * one last time. If the ack is present, log an error and move on. If the ack isn't 1585: * present, log an error and return -ETIMEDOUT. 1586: * 1587: * Return: 0 on success and -ETIMEDOUT on failure 1588: */ 1589: int adreno_hwsched_ctxt_unregister_wait_completion( --- FILE: \adreno_hwsched.c | HITS: 58 --- MATCH LINES: 9, 35, 36 1: // SPDX-License-Identifier: GPL-2.0-only 2: /* 3: * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #include "adreno.h" 8: #include "adreno_hfi.h" 9: #include "adreno_snapshot.h" 10: #include "adreno_sysfs.h" 11: #include "adreno_trace.h" 12: #include "kgsl_eventlog.h" 13: #include "kgsl_trace.h" 14: #include "kgsl_pwrctrl.h" 15: #include "kgsl_timeline.h" 16: #include 17: #include 18: #include 19: 20: #define POLL_SLEEP_US 100 21: 22: /* 23: * Number of commands that can be queued in a context before it sleeps 24: * 25: * Our code that "puts back" a command from the context is much cleaner 26: * if we are sure that there will always be enough room in the ringbuffer 27: * so restrict the size of the context queue to ADRENO_CONTEXT_DRAWQUEUE_SIZE - 1 28: */ 29: static u32 _context_drawqueue_size = ADRENO_CONTEXT_DRAWQUEUE_SIZE - 1; 30: 31: /* Number of milliseconds to wait for the context queue to clear */ 32: static unsigned int _context_queue_wait = 10000; 33: 34: /* 35: * GFT throttle parameters. If GFT recovered more than 36: * X times in Y ms invalidate the context and do not attempt recovery. 37: * X -> _fault_throttle_burst 38: * Y -> _fault_throttle_time 39: */ 40: static unsigned int _fault_throttle_time = 2000; 41: static unsigned int _fault_throttle_burst = 3; 42: 43: /* Use a kmem cache to speed up allocations for dispatcher jobs */ 44: static struct kmem_cache *jobs_cache; 45: /* Use a kmem cache to speed up allocations for inflight command objects */ 46: static struct kmem_cache *obj_cache; 47: 48: inline bool adreno_hwsched_context_queue_enabled(struct adreno_device *adreno_dev) 49: { 50: return test_bit(ADRENO_HWSCHED_CONTEXT_QUEUE, &adreno_dev->hwsched.flags); 51: } 52: 53: static inline u32 get_gmu_vma_id(u32 flags) 54: { 55: return (flags & HFI_MEMFLAG_GMU_CACHEABLE) ? GMU_CACHE : GMU_NONCACHED_KERNEL; 56: } 57: 58: static void setup_gfx_flags_priv(u32 desc_flags, u64 *flags, u32 *priv) 59: { 60: if (desc_flags & HFI_MEMFLAG_GFX_PRIV) MATCH LINES: 749 737: (drawctxt->drawqueue_head - 1); 738: 739: /* 740: * The maximum queue size always needs to be one less then the size of 741: * the ringbuffer queue so there is "room" to put the drawobj back in 742: */ 743: 744: WARN_ON(prev == drawctxt->drawqueue_tail); 745: 746: drawctxt->drawqueue[prev] = drawobj; 747: drawctxt->queued++; 748: 749: /* Reset the command queue head to reflect the newly requeued change */ 750: drawctxt->drawqueue_head = prev; 751: if (is_cmdobj(drawobj)) { 752: struct kgsl_drawobj_cmd *cmdobj = CMDOBJ(drawobj); 753: 754: cmdobj->requeue_cnt++; 755: } 756: spin_unlock(&drawctxt->lock); 757: return 0; 758: } 759: 760: /** 761: * hwsched_queue_context() - Queue a context in the dispatcher list of jobs 762: * @adreno_dev: Pointer to the adreno device structure 763: * @drawctxt: Pointer to the adreno draw context 764: * 765: * Add a context to the dispatcher list of jobs. 766: */ 767: static int hwsched_queue_context(struct adreno_device *adreno_dev, 768: struct adreno_context *drawctxt) 769: { 770: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 771: struct adreno_dispatch_job *job; 772: 773: /* Refuse to queue a detached context */ MATCH LINES: 1138 1126: spin_unlock(&device->submit_lock); 1127: goto done; 1128: } 1129: device->submit_now++; 1130: spin_unlock(&device->submit_lock); 1131: 1132: /* If the dispatcher is busy then schedule the work for later */ 1133: if (!mutex_trylock(&hwsched->mutex)) { 1134: _decrement_submit_now(device); 1135: goto done; 1136: } 1137: 1138: if (!adreno_gpu_fault(adreno_dev)) 1139: hwsched_issuecmds(adreno_dev); 1140: 1141: if (hwsched->inflight > 0) { 1142: kgsl_mutex_lock(&device->mutex); 1143: kgsl_pwrscale_update(device); 1144: kgsl_start_idle_timer(device); 1145: kgsl_mutex_unlock(&device->mutex); 1146: } 1147: 1148: mutex_unlock(&hwsched->mutex); 1149: _decrement_submit_now(device); 1150: return; 1151: 1152: done: 1153: adreno_scheduler_queue(adreno_dev); 1154: } 1155: 1156: /** 1157: * get_timestamp() - Return the next timestamp for the context 1158: * @drawctxt - Pointer to an adreno draw context struct 1159: * @drawobj - Pointer to a drawobj 1160: * @timestamp - Pointer to a timestamp value possibly passed from the user 1161: * @user_ts - user generated timestamp 1162: * MATCH LINES: 1937, 1944 1925: 1926: if (drawobj) { 1927: drawctxt = ADRENO_CONTEXT(drawobj->context); 1928: drawobj->context->last_faulted_cmd_ts = drawobj->timestamp; 1929: drawobj->context->total_fault_count++; 1930: ctxt_id = drawobj->context->id; 1931: ts = drawobj->timestamp; 1932: rb_id = adreno_get_level(drawobj->context); 1933: 1934: pr_context(device, drawobj->context, 1935: "ctx %u ctx_type %s ts %u policy %lX dispatch_queue=%d\n", 1936: drawobj->context->id, kgsl_context_type(drawctxt->type), 1937: drawobj->timestamp, CMDOBJ(drawobj)->fault_recovery, 1938: drawobj->context->gmu_dispatch_queue); 1939: 1940: pr_context(device, drawobj->context, 1941: "cmdline: %s\n", drawctxt->base.proc_priv->cmdline); 1942: } 1943: 1944: trace_adreno_gpu_fault(ctxt_id, ts, status, rptr, wptr, ib1base, ib1sz, 1945: ib2base, ib2sz, rb_id); 1946: } 1947: 1948: static struct cmd_list_obj *get_active_cmdobj_lpac( 1949: struct adreno_device *adreno_dev) 1950: { 1951: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 1952: struct cmd_list_obj *obj, *tmp, *active_obj = NULL; 1953: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1954: u32 consumed = 0, retired = 0; 1955: struct kgsl_drawobj *drawobj = NULL; 1956: 1957: list_for_each_entry_safe(obj, tmp, &hwsched->cmd_list, node) { 1958: drawobj = obj->drawobj; 1959: 1960: if (!is_cmdobj(drawobj) || !kgsl_context_is_lpac(drawobj->context)) 1961: continue; 1962: 1963: kgsl_readtimestamp(device, drawobj->context, 1964: KGSL_TIMESTAMP_CONSUMED, &consumed); 1965: kgsl_readtimestamp(device, drawobj->context, 1966: KGSL_TIMESTAMP_RETIRED, &retired); 1967: 1968: if (!consumed) MATCH LINES: 2139, 2153, 2186, 2188, 2196, 2215, 2233, 2235, 2239, 2259, 2263, 2278, 2280, 2284, 2285, 2294, 2303, 2316, 2317, 2339, 2340, 2351, 2352, 2355, 2366, 2374, 2381, 2382, 2383, 2385, 2400, 2402, 2404, 2407, 2414 2127: 2128: list_for_each_entry(obj, &hwsched->cmd_list, node) { 2129: struct kgsl_drawobj *drawobj = obj->drawobj; 2130: 2131: if (drawobj->type == SYNCOBJ_TYPE) { 2132: if ((ctxt_id == drawobj->context->id) && 2133: (ts == drawobj->timestamp)) 2134: _print_syncobj(adreno_dev, drawobj); 2135: } 2136: } 2137: } 2138: 2139: static void adreno_hwsched_snapshot_legacy(struct adreno_device *adreno_dev, int fault) 2140: { 2141: struct kgsl_drawobj *drawobj = NULL; 2142: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2143: struct kgsl_context *context = NULL; 2144: struct cmd_list_obj *obj; 2145: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 2146: struct hfi_context_bad_cmd_legacy *cmd = hwsched->ctxt_bad; 2147: 2148: if (hwsched->recurring_cmdobj) 2149: srcu_notifier_call_chain(&device->nh, GPU_SSR_BEGIN, NULL); 2150: 2151: if (cmd->error == GMU_SYNCOBJ_TIMEOUT_ERROR) { 2152: print_fault_syncobj(adreno_dev, cmd->ctxt_id, cmd->ts); 2153: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE); 2154: return; 2155: } 2156: 2157: /* 2158: * First, try to see if the faulted command object is marked 2159: * in case there was a context bad hfi. But, with stall-on-fault, 2160: * we know that GMU cannot send context bad hfi. Hence, attempt 2161: * to walk the list of active submissions to find the one that 2162: * faulted. 2163: */ 2164: obj = get_fault_cmdobj(adreno_dev, cmd->ctxt_id, cmd->ts); 2165: if (!obj && (fault & ADRENO_IOMMU_STALL_ON_PAGE_FAULT)) 2166: obj = get_active_cmdobj(adreno_dev); 2167: 2168: if (obj) { 2169: drawobj = obj->drawobj; 2170: trace_adreno_cmdbatch_fault(CMDOBJ(drawobj), fault); 2171: } else if (hwsched->recurring_cmdobj && 2172: hwsched->recurring_cmdobj->base.context->id == cmd->ctxt_id) { 2173: drawobj = DRAWOBJ(hwsched->recurring_cmdobj); 2174: trace_adreno_cmdbatch_fault(hwsched->recurring_cmdobj, fault); 2175: if (!kref_get_unless_zero(&drawobj->refcount)) 2176: drawobj = NULL; 2177: } 2178: 2179: if (drawobj && drawobj->context) 2180: set_bit(ADRENO_CONTEXT_FAULT, &drawobj->context->priv); 2181: 2182: adreno_gpufault_stats(adreno_dev, drawobj, NULL, fault); 2183: 2184: if (!drawobj) { 2185: if (fault & ADRENO_GMU_FAULT) 2186: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE); 2187: else 2188: kgsl_device_snapshot(device, NULL, NULL, false); 2189: return; 2190: } 2191: 2192: context = drawobj->context; 2193: 2194: do_fault_header(adreno_dev, drawobj, fault); 2195: 2196: kgsl_device_snapshot(device, context, NULL, false); 2197: 2198: force_retire_timestamp(device, drawobj); 2199: 2200: if ((context->flags & KGSL_CONTEXT_INVALIDATE_ON_FAULT) || 2201: (context->flags & KGSL_CONTEXT_NO_FAULT_TOLERANCE) || 2202: (cmd->error == GMU_GPU_SW_HANG) || 2203: (cmd->error == GMU_GPU_SW_FUSE_VIOLATION) || 2204: context_is_throttled(device, context)) { 2205: adreno_drawctxt_set_guilty(device, context); 2206: } 2207: 2208: /* 2209: * Put back the reference which we incremented while trying to find 2210: * faulted command object 2211: */ 2212: kgsl_drawobj_put(drawobj); 2213: } 2214: 2215: static int adreno_hwsched_snapshot_and_soft_reset(struct adreno_device *adreno_dev, int fault) 2216: { 2217: struct kgsl_drawobj *drawobj = NULL; 2218: struct kgsl_drawobj *drawobj_lpac = NULL; 2219: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2220: struct kgsl_context *context = NULL; 2221: struct kgsl_context *context_lpac = NULL; 2222: struct cmd_list_obj *obj; 2223: struct cmd_list_obj *obj_lpac; 2224: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 2225: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 2226: struct hfi_context_bad_cmd *cmd = hwsched->ctxt_bad; 2227: int ret = 0; 2228: bool ctx_guilty = false; 2229: 2230: if (hwsched->recurring_cmdobj) 2231: srcu_notifier_call_chain(&device->nh, GPU_SSR_BEGIN, NULL); 2232: 2233: /* Do not do soft reset for a IOMMU fault (because IOMMU hardware needs a reset too) */ 2234: if (fault & ADRENO_IOMMU_STALL_ON_PAGE_FAULT) 2235: adreno_dev->hwsched.reset_type = GMU_GPU_HARD_RESET; 2236: 2237: if (cmd->error == GMU_SYNCOBJ_TIMEOUT_ERROR) { 2238: print_fault_syncobj(adreno_dev, cmd->gc.ctxt_id, cmd->gc.ts); 2239: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE); 2240: ret = -ETIMEDOUT; 2241: goto done; 2242: } 2243: 2244: /* 2245: * First, try to see if the faulted command object is marked 2246: * in case there was a context bad hfi. But, with stall-on-fault, 2247: * we know that GMU cannot send context bad hfi. Hence, attempt 2248: * to walk the list of active submissions to find the one that 2249: * faulted. 2250: */ 2251: obj = get_fault_cmdobj(adreno_dev, cmd->gc.ctxt_id, cmd->gc.ts); 2252: obj_lpac = get_fault_cmdobj(adreno_dev, cmd->lpac.ctxt_id, cmd->lpac.ts); 2253: 2254: if (!obj && (fault & ADRENO_IOMMU_STALL_ON_PAGE_FAULT)) 2255: obj = get_active_cmdobj(adreno_dev); 2256: 2257: if (obj) { 2258: drawobj = obj->drawobj; 2259: CMDOBJ(drawobj)->fault_recovery = cmd->gc.policy; 2260: } else if (hwsched->recurring_cmdobj && 2261: hwsched->recurring_cmdobj->base.context->id == cmd->gc.ctxt_id) { 2262: drawobj = DRAWOBJ(hwsched->recurring_cmdobj); 2263: CMDOBJ(drawobj)->fault_recovery = cmd->gc.policy; 2264: if (!kref_get_unless_zero(&drawobj->refcount)) 2265: drawobj = NULL; 2266: } 2267: 2268: if (drawobj && drawobj->context) 2269: set_bit(ADRENO_CONTEXT_FAULT, &drawobj->context->priv); 2270: 2271: do_fault_header(adreno_dev, drawobj, fault); 2272: 2273: if (!obj_lpac && (fault & ADRENO_IOMMU_STALL_ON_PAGE_FAULT)) 2274: obj_lpac = get_active_cmdobj_lpac(adreno_dev); 2275: 2276: if (!obj && !obj_lpac) { 2277: if (fault & ADRENO_GMU_FAULT) 2278: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE); 2279: else 2280: kgsl_device_snapshot(device, NULL, NULL, false); 2281: 2282: adreno_gpufault_stats(adreno_dev, NULL, NULL, fault); 2283: 2284: /* Faulting command not found, Hence force hard reset */ 2285: adreno_dev->hwsched.reset_type = GMU_GPU_HARD_RESET; 2286: goto done; 2287: } 2288: 2289: if (obj) 2290: context = drawobj->context; 2291: 2292: if (obj_lpac) { 2293: drawobj_lpac = obj_lpac->drawobj; 2294: CMDOBJ(drawobj_lpac)->fault_recovery = cmd->lpac.policy; 2295: context_lpac = drawobj_lpac->context; 2296: if (gpudev->lpac_fault_header) 2297: gpudev->lpac_fault_header(adreno_dev, drawobj_lpac); 2298: } 2299: 2300: if (drawobj_lpac && drawobj_lpac->context) 2301: set_bit(ADRENO_CONTEXT_FAULT, &drawobj_lpac->context->priv); 2302: 2303: kgsl_device_snapshot(device, context, context_lpac, false); 2304: adreno_gpufault_stats(adreno_dev, drawobj, drawobj_lpac, fault); 2305: 2306: if (drawobj) { 2307: force_retire_timestamp(device, drawobj); 2308: if (context && ((context->flags & KGSL_CONTEXT_INVALIDATE_ON_FAULT) || 2309: (context->flags & KGSL_CONTEXT_NO_FAULT_TOLERANCE) || 2310: (cmd->error == GMU_GPU_SW_HANG) || 2311: (cmd->error == GMU_GPU_SW_FUSE_VIOLATION) || 2312: context_is_throttled(device, context))) { 2313: ctx_guilty = true; 2314: } 2315: 2316: if (gpudev->soft_reset) 2317: ret = gpudev->soft_reset(adreno_dev, context, ctx_guilty); 2318: 2319: if (ctx_guilty) 2320: adreno_drawctxt_set_guilty(device, context); 2321: /* 2322: * Put back the reference which we incremented while trying to find 2323: * faulted command object 2324: */ 2325: kgsl_drawobj_put(drawobj); 2326: } 2327: 2328: if (drawobj_lpac) { 2329: ctx_guilty = false; 2330: force_retire_timestamp(device, drawobj_lpac); 2331: if (context_lpac && ((context_lpac->flags & KGSL_CONTEXT_INVALIDATE_ON_FAULT) || 2332: (context_lpac->flags & KGSL_CONTEXT_NO_FAULT_TOLERANCE) || 2333: (cmd->error == GMU_GPU_SW_HANG) || 2334: (cmd->error == GMU_GPU_SW_FUSE_VIOLATION) || 2335: context_is_throttled(device, context_lpac))) { 2336: ctx_guilty = true; 2337: } 2338: 2339: if (gpudev->soft_reset) 2340: ret = gpudev->soft_reset(adreno_dev, context_lpac, ctx_guilty); 2341: 2342: if (ctx_guilty) 2343: adreno_drawctxt_set_guilty(device, context_lpac); 2344: /* 2345: * Put back the reference which we incremented while trying to find 2346: * faulted command object 2347: */ 2348: kgsl_drawobj_put(drawobj_lpac); 2349: } 2350: done: 2351: if (gpudev->soft_reset && !drawobj && !drawobj_lpac) 2352: ret = gpudev->soft_reset(adreno_dev, NULL, ctx_guilty); 2353: 2354: memset(hwsched->ctxt_bad, 0x0, HFI_MAX_MSG_SIZE); 2355: adreno_dev->hwsched.reset_type = GMU_GPU_RESET_NONE; 2356: 2357: return ret; 2358: } 2359: 2360: static bool adreno_hwsched_do_fault(struct adreno_device *adreno_dev) 2361: { 2362: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2363: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 2364: int fault; 2365: 2366: fault = adreno_gpu_fault(adreno_dev); 2367: if (fault == 0) 2368: return false; 2369: 2370: /* 2371: * Return early if there is a concurrent suspend in progress. The suspend thread will error 2372: * out in the presence of this hwsched fault and requeue the dispatcher to handle this fault 2373: */ 2374: if (!mutex_trylock(&adreno_dev->fault_recovery_mutex)) 2375: return true; 2376: 2377: /* 2378: * Wait long enough to allow the system to come out of suspend completely, which can take 2379: * variable amount of time especially if it has to rewind suspend processes and devices. 2380: */ 2381: if (!wait_for_completion_timeout(&adreno_dev->suspend_recovery_gate, 2382: msecs_to_jiffies(ADRENO_SUSPEND_RECOVERY_GATE_TIMEOUT_MS))) { 2383: dev_err(device->dev, "suspend recovery gate timeout\n"); 2384: adreno_scheduler_queue(adreno_dev); 2385: mutex_unlock(&adreno_dev->fault_recovery_mutex); 2386: return true; 2387: } 2388: 2389: kgsl_mutex_lock(&device->mutex); 2390: 2391: if (device->state == KGSL_STATE_ACTIVE) { 2392: /* 2393: * Halt CP for page faults here. CP is halted from GMU when required, 2394: * for other faults. 2395: */ 2396: if ((fault & ADRENO_IOMMU_STALL_ON_PAGE_FAULT) && adreno_gx_is_on(adreno_dev)) 2397: adreno_writereg(adreno_dev, ADRENO_REG_CP_ME_CNTL, 0); 2398: 2399: if (test_bit(ADRENO_HWSCHED_CTX_BAD_LEGACY, &hwsched->flags)) { 2400: adreno_hwsched_snapshot_legacy(adreno_dev, fault); 2401: memset(hwsched->ctxt_bad, 0x0, HFI_MAX_MSG_SIZE); 2402: adreno_gpudev_reset(adreno_dev); 2403: } else { 2404: int ret = adreno_hwsched_snapshot_and_soft_reset(adreno_dev, fault); 2405: 2406: if (ret) 2407: adreno_gpudev_reset(adreno_dev); 2408: } 2409: } 2410: 2411: adreno_scheduler_queue(adreno_dev); 2412: 2413: kgsl_mutex_unlock(&device->mutex); 2414: mutex_unlock(&adreno_dev->fault_recovery_mutex); 2415: 2416: return true; 2417: } 2418: 2419: static void adreno_hwsched_work(struct kthread_work *work) 2420: { 2421: struct adreno_device *adreno_dev = container_of(work, 2422: struct adreno_device, scheduler_work); 2423: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 2424: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2425: 2426: mutex_lock(&hwsched->mutex); 2427: 2428: if (adreno_hwsched_do_fault(adreno_dev)) { 2429: mutex_unlock(&hwsched->mutex); 2430: return; 2431: } 2432: 2433: /* 2434: * As long as there are inflight commands, process retired comamnds from 2435: * all drawqueues 2436: */ 2437: retire_drawobj_list(adreno_dev); 2438: MATCH LINES: 2567, 2575, 2577, 2595, 2599, 2616, 2623, 2657 2555: if (ADRENO_FEATURE(adreno_dev, ADRENO_LSR)) { 2556: INIT_WORK(&hwsched->lsr_check_ws, hwsched_lsr_check); 2557: timer_setup(&hwsched->lsr_timer, hwsched_lsr_timer, 0); 2558: } 2559: 2560: init_waitqueue_head(&hwf->unack_wq); 2561: spin_lock_init(&hwf->lock); 2562: 2563: return 0; 2564: } 2565: 2566: void adreno_hwsched_parse_fault_cmdobj(struct adreno_device *adreno_dev, 2567: struct kgsl_snapshot *snapshot) 2568: { 2569: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 2570: struct cmd_list_obj *obj, *tmp; 2571: 2572: /* 2573: * During IB parse, vmalloc is called which can sleep and 2574: * should not be called from atomic context. Since IBs are not 2575: * dumped during atomic snapshot, there is no need to parse it. 2576: */ 2577: if (adreno_dev->dev.snapshot_atomic) 2578: return; 2579: 2580: list_for_each_entry_safe(obj, tmp, &hwsched->cmd_list, node) { 2581: struct kgsl_drawobj *drawobj = obj->drawobj; 2582: struct kgsl_drawobj_cmd *cmdobj; 2583: 2584: if (!is_cmdobj(drawobj)) 2585: continue; 2586: 2587: cmdobj = CMDOBJ(drawobj); 2588: 2589: if (test_bit(CMDOBJ_FAULT, &cmdobj->priv)) { 2590: struct kgsl_memobj_node *ib; 2591: 2592: list_for_each_entry(ib, &cmdobj->cmdlist, node) { 2593: if (drawobj->context->flags & KGSL_CONTEXT_LPAC) 2594: adreno_parse_ib_lpac(KGSL_DEVICE(adreno_dev), 2595: snapshot, snapshot->process_lpac, 2596: ib->gpuaddr, ib->size >> 2); 2597: else 2598: adreno_parse_ib(KGSL_DEVICE(adreno_dev), 2599: snapshot, snapshot->process, 2600: ib->gpuaddr, ib->size >> 2); 2601: } 2602: clear_bit(CMDOBJ_FAULT, &cmdobj->priv); 2603: } 2604: } 2605: } 2606: 2607: static int unregister_context(int id, void *ptr, void *data) 2608: { 2609: struct kgsl_context *context = ptr; 2610: struct adreno_context *drawctxt = ADRENO_CONTEXT(context); 2611: 2612: if (drawctxt->gmu_context_queue.gmuaddr != 0) { 2613: struct gmu_context_queue_header *header = drawctxt->gmu_context_queue.hostptr; 2614: 2615: header->read_index = header->write_index; 2616: /* This is to make sure GMU sees the correct indices after recovery */ 2617: mb(); 2618: } 2619: 2620: /* 2621: * We don't need to send the unregister hfi packet because 2622: * we are anyway going to lose the gmu state of registered 2623: * contexts. So just reset the flag so that the context 2624: * registers with gmu on its first submission post slumber. 2625: */ 2626: context->gmu_registered = false; 2627: 2628: /* 2629: * Consider the scenario where non-recurring submissions were made 2630: * by a context. Here internal_timestamp of context would be non 2631: * zero. After slumber, last retired timestamp is not held by GMU. 2632: * If this context submits a recurring workload, the context is 2633: * registered again, but the internal timestamp is not updated. When 2634: * the context is unregistered in send_context_unregister_hfi(), 2635: * we could be waiting on old internal_timestamp which is not held by 2636: * GMU. This can result in GMU errors. Hence set internal_timestamp 2637: * to zero when entering slumber. 2638: */ 2639: drawctxt->internal_timestamp = 0; 2640: 2641: return 0; 2642: } 2643: 2644: void adreno_hwsched_unregister_contexts(struct adreno_device *adreno_dev) 2645: { 2646: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2647: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 2648: 2649: read_lock(&device->context_lock); 2650: idr_for_each(&device->context_idr, unregister_context, NULL); 2651: read_unlock(&device->context_lock); 2652: 2653: if (hwsched->global_ctxtq.hostptr) { 2654: struct gmu_context_queue_header *header = hwsched->global_ctxtq.hostptr; 2655: 2656: header->read_index = header->write_index; 2657: /* This is to make sure GMU sees the correct indices after recovery */ 2658: mb(); 2659: } 2660: 2661: hwsched->global_ctxt_gmu_registered = false; 2662: } 2663: 2664: int adreno_gmu_context_queue_read(struct adreno_context *drawctxt, u32 *output, 2665: u32 read_idx, u32 size_dwords) 2666: { 2667: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr; 2668: u32 *queue = drawctxt->gmu_context_queue.hostptr + sizeof(*hdr); 2669: u32 i; 2670: 2671: if ((size_dwords > hdr->queue_size) || (read_idx >= hdr->queue_size)) 2672: return -EINVAL; 2673: 2674: /* Clear the output data before populating */ 2675: memset(output, 0, size_dwords << 2); 2676: 2677: for (i = 0; i < size_dwords; i++) { 2678: output[i] = queue[read_idx]; 2679: read_idx = (read_idx + 1) % hdr->queue_size; 2680: } 2681: MATCH LINES: 2703, 2718, 2751, 2763 2691: /* Block any new submissions from being submitted */ 2692: adreno_get_gpu_halt(adreno_dev); 2693: 2694: kgsl_mutex_unlock(&device->mutex); 2695: 2696: /* 2697: * Flush the worker to make sure all executing 2698: * or pending dispatcher works on worker are 2699: * finished 2700: */ 2701: kthread_flush_worker(adreno_dev->scheduler_worker); 2702: 2703: if (adreno_gpu_fault(adreno_dev)) { 2704: ret = -EDEADLK; 2705: } else { 2706: 2707: ret = wait_for_completion_timeout(&hwsched->idle_gate, 2708: msecs_to_jiffies(ADRENO_IDLE_TIMEOUT)); 2709: if (ret == 0) { 2710: ret = -ETIMEDOUT; 2711: WARN(1, "hwsched halt timeout\n"); 2712: } else if (ret < 0) { 2713: dev_err(device->dev, "hwsched halt failed %d\n", ret); 2714: } else { 2715: ret = 0; 2716: } 2717: 2718: if (adreno_gpu_fault(adreno_dev)) 2719: ret = -EDEADLK; 2720: } 2721: 2722: kgsl_mutex_lock(&device->mutex); 2723: 2724: /* 2725: * This will allow the dispatcher to start submitting to 2726: * hardware once device mutex is released 2727: */ 2728: adreno_put_gpu_halt(adreno_dev); 2729: 2730: return ret; 2731: } 2732: 2733: static int adreno_hwsched_idle(struct adreno_device *adreno_dev) 2734: { 2735: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2736: unsigned long wait = jiffies + msecs_to_jiffies(ADRENO_IDLE_TIMEOUT); 2737: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 2738: int ret; 2739: 2740: if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex))) 2741: return -EDEADLK; 2742: 2743: if (!kgsl_state_is_awake(device)) 2744: return 0; 2745: 2746: ret = hwsched_idle(adreno_dev); 2747: if (ret) 2748: return ret; 2749: 2750: do { 2751: if (adreno_gpu_fault(adreno_dev)) 2752: return -EDEADLK; 2753: 2754: if (gpudev->hw_isidle(adreno_dev)) 2755: return 0; 2756: } while (time_before(jiffies, wait)); 2757: 2758: /* 2759: * Under rare conditions, preemption can cause the while loop to exit 2760: * without checking if the gpu is idle. check one last time before we 2761: * return failure. 2762: */ 2763: if (adreno_gpu_fault(adreno_dev)) 2764: return -EDEADLK; 2765: 2766: if (gpudev->hw_isidle(adreno_dev)) 2767: return 0; 2768: 2769: return -ETIMEDOUT; 2770: } 2771: 2772: void adreno_hwsched_register_hw_fence(struct adreno_device *adreno_dev) 2773: { 2774: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 2775: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2776: int ret; 2777: 2778: if (!ADRENO_FEATURE(adreno_dev, ADRENO_HW_FENCE)) 2779: return; 2780: 2781: if (test_bit(ADRENO_HWSCHED_HW_FENCE, &hwsched->flags)) 2782: return; 2783: 2784: if (kgsl_hw_fence_init(device)) 2785: return; 2786: 2787: /* MATCH LINES: 2855 2843: end = gpudev->read_alwayson(adreno_dev); 2844: if (completion_done(&ack->complete)) { 2845: unprocessed++; 2846: if (__ratelimit(&_rs)) 2847: dev_err(dev, "Ack unprocessed for id:%d sequence=%d count=%d/%d ticks=0x%llx/0x%llx\n", 2848: MSG_HDR_GET_ID(ack->sent_hdr), MSG_HDR_GET_SEQNUM(ack->sent_hdr), 2849: unprocessed, processed, start, end); 2850: return 0; 2851: } 2852: 2853: dev_err(dev, "Ack timeout for id:%d sequence=%d ticks=0x%llx/0x%llx\n", 2854: MSG_HDR_GET_ID(ack->sent_hdr), MSG_HDR_GET_SEQNUM(ack->sent_hdr), start, end); 2855: gmu_core_fault_snapshot(KGSL_DEVICE(adreno_dev), GMU_FAULT_WAIT_ACK_COMPLETION); 2856: return -ETIMEDOUT; 2857: } 2858: 2859: int adreno_hwsched_ctxt_unregister_wait_completion( 2860: struct adreno_device *adreno_dev, 2861: struct device *dev, struct kgsl_context *context, struct pending_cmd *ack, 2862: void (*process_msgq)(struct adreno_device *adreno_dev), 2863: struct hfi_unregister_ctxt_cmd *cmd) 2864: { 2865: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2866: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 2867: struct adreno_context *drawctxt = ADRENO_CONTEXT(context); 2868: int rb = adreno_get_level(context); 2869: int ret; 2870: bool fast = adreno_is_fast_context_destroy_enabled(adreno_dev); 2871: u64 start, end; 2872: char prefix[60]; 2873: 2874: start = gpudev->read_alwayson(adreno_dev); 2875: kgsl_mutex_unlock(&device->mutex); 2876: 2877: ret = wait_for_completion_timeout(&ack->complete, msecs_to_jiffies(30 * 1000)); 2878: 2879: kgsl_mutex_lock(&device->mutex); MATCH LINES: 3054 3042: 3043: while (num_values--) { 3044: ptr[j - 1] = payload->data[i + j]; 3045: j++; 3046: } 3047: break; 3048: } 3049: 3050: i += struct_size(payload, data, payload->dwords); 3051: } 3052: } 3053: 3054: bool adreno_hwsched_log_nonfatal_gpu_fault(struct adreno_device *adreno_dev, 3055: struct device *dev, u32 error) 3056: { 3057: bool non_fatal = true; 3058: 3059: switch (error) { 3060: case GMU_CP_AHB_ERROR: { 3061: u32 err_details[2]; 3062: 3063: adreno_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 3064: KEY_CP_AHB_ERROR, err_details, 2); 3065: dev_crit_ratelimited(dev, 3066: "CP: AHB bus error, CP_RL_ERROR_DETAILS_0:0x%x CP_RL_ERROR_DETAILS_1:0x%x\n", 3067: err_details[0], err_details[1]); 3068: break; 3069: } 3070: case GMU_ATB_ASYNC_FIFO_OVERFLOW: 3071: dev_crit_ratelimited(dev, "RBBM: ATB ASYNC overflow\n"); 3072: break; 3073: case GMU_RBBM_ATB_BUF_OVERFLOW: 3074: dev_crit_ratelimited(dev, "RBBM: ATB bus overflow\n"); 3075: break; 3076: case GMU_UCHE_OOB_ACCESS: 3077: dev_crit_ratelimited(dev, "UCHE: Out of bounds access\n"); 3078: break; MATCH LINES: 3374, 3394 3362: for (i = 0; i < hwsched->mem_alloc_entries; i++) { 3363: struct kgsl_memdesc *md = hwsched->mem_alloc_table[i].md; 3364: 3365: if (kgsl_gpuaddr_in_memdesc(md, gpuaddr, size)) { 3366: offset = gpuaddr - md->gpuaddr; 3367: return md->hostptr + offset; 3368: } 3369: } 3370: 3371: return NULL; 3372: } 3373: 3374: void adreno_hwsched_reset_hfi_mem(struct adreno_device *adreno_dev) 3375: { 3376: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 3377: struct kgsl_memdesc *md = NULL; 3378: u32 i; 3379: 3380: for (i = 0; i < hwsched->mem_alloc_entries; i++) { 3381: struct hfi_mem_alloc_desc *desc = &hwsched->mem_alloc_table[i].desc; 3382: 3383: if (desc->flags & HFI_MEMFLAG_HOST_INIT) { 3384: md = hwsched->mem_alloc_table[i].md; 3385: if (md->hostptr) 3386: memset(md->hostptr, 0x0, md->size); 3387: } 3388: } 3389: 3390: if (!(adreno_is_preemption_enabled(adreno_dev) && 3391: ADRENO_FEATURE(adreno_dev, ADRENO_DEFER_GMEM_ALLOC))) 3392: return; 3393: 3394: /* No need to reset gmem portion of the preemption records */ 3395: for (i = 0; i < KGSL_PRIORITY_MAX_RB_LEVELS; i++) { 3396: md = hwsched->preempt_rec[i]; 3397: if (md && md->hostptr) 3398: memset(md->hostptr, 0x0, md->size); 3399: } 3400: } --- FILE: \adreno_hwsched.h | HITS: 23 --- MATCH LINES: 69, 70, 103, 104, 105, 106 57: /** 58: * struct adreno_hw_fence_entry - A structure to store hardware fence and the context 59: */ 60: struct adreno_hw_fence_entry { 61: /** @cmd: H2F_MSG_HW_FENCE_INFO packet for this hardware fence */ 62: struct hfi_hw_fence_info cmd; 63: /** @kfence: Pointer to the kgsl fence */ 64: struct kgsl_sync_fence *kfence; 65: /** @drawctxt: Pointer to the context */ 66: struct adreno_context *drawctxt; 67: /** @node: list node to add it to a list */ 68: struct list_head node; 69: /** @reset_node: list node to add it to post reset list of hardware fences */ 70: struct list_head reset_node; 71: }; 72: 73: /** 74: * struct adreno_hwsched_ops - Function table to hook hwscheduler things 75: * to target specific routines 76: */ 77: struct adreno_hwsched_ops { 78: /** 79: * @submit_drawobj - Target specific function to submit IBs to hardware 80: */ 81: int (*submit_drawobj)(struct adreno_device *adreno_dev, 82: struct kgsl_drawobj *drawobj); 83: /** 84: * @preempt_count - Target specific function to get preemption count 85: */ 86: u32 (*preempt_count)(struct adreno_device *adreno_dev); 87: /** 88: * @preempt_info - Target specific function to get preemption information 89: */ 90: ssize_t (*preempt_info)(struct adreno_device *adreno_dev, char *buf); 91: /** 92: * @create_hw_fence - Target specific function to create a hardware fence 93: */ 94: void (*create_hw_fence)(struct adreno_device *adreno_dev, 95: struct kgsl_sync_fence *kfence); 96: /** 97: * @set_dcvs_profile - Set dcvs profile for a process 98: */ 99: int (*set_dcvs_profile)(struct adreno_device *adreno_dev, 100: struct kgsl_process_private *proc_priv); 101: }; 102: 103: enum gpu_reset_type { 104: GMU_GPU_RESET_NONE, 105: GMU_GPU_SOFT_RESET, 106: GMU_GPU_HARD_RESET, 107: }; 108: 109: struct adreno_dcvs_tunable { 110: /** @value: Stores the requested value for the tunable **/ 111: u32 value; 112: /** @update: True if this value needs to be sent to GMU at slumber exit **/ 113: bool update; 114: }; 115: 116: /** 117: * struct adreno_hwsched - Container for the hardware scheduler 118: */ 119: struct adreno_hwsched { 120: /** @mem_alloc_table: Array of HFI memory allocation entries */ 121: struct hfi_mem_alloc_entry mem_alloc_table[32]; 122: /** @mem_alloc_entries: Number of entries in the memory allocation table */ 123: u32 mem_alloc_entries; 124: /** @mutex: Mutex needed to run dispatcher function */ 125: struct mutex mutex; 126: /** @flags: Container for the dispatcher internal flags */ 127: unsigned long flags; 128: /** @inflight: Number of active submissions to the dispatch queues */ 129: u32 inflight; 130: /** @jobs - Array of dispatch job lists for each priority level */ MATCH LINES: 163, 164 151: struct kmem_cache *hw_fence_cache; 152: /** 153: * @submission_seqnum: Sequence number for sending submissions to GMU context queues or 154: * dispatch queues 155: */ 156: atomic_t submission_seqnum; 157: /** @global_ctxtq: Memory descriptor for global context queue */ 158: struct kgsl_memdesc global_ctxtq; 159: /** @global_ctxt_gmu_registered: Whether global context is registered with gmu */ 160: bool global_ctxt_gmu_registered; 161: /** @hw_fence: Container for hw fence related structures */ 162: struct adreno_hwsched_hw_fence hw_fence; 163: /** @reset_type: GPU fault reset (hard/soft) type */ 164: enum gpu_reset_type reset_type; 165: /** @preempt_rec: Memory descriptors for non-gmem part of preemption records */ 166: struct kgsl_memdesc *preempt_rec[KGSL_PRIORITY_MAX_RB_LEVELS]; 167: /** 168: * @preempt_rec_gmem: Memory descriptors for gmem part of preemption 169: * records. No gmem buffer needed for rb0 preemption record. 170: */ 171: struct kgsl_memdesc *preempt_rec_gmem[KGSL_PRIORITY_MAX_RB_LEVELS - 1]; 172: /** 173: * @secure_preempt_rec: Memory descriptors for non-gmem part of secure 174: * preemption records 175: */ 176: struct kgsl_memdesc *secure_preempt_rec[KGSL_PRIORITY_MAX_RB_LEVELS]; 177: /** 178: * @secure_preempt_rec_gmem: Memory descriptors for gmem part of secure 179: * preemption records. No gmem buffer needed for rb0 preemption record. 180: */ 181: struct kgsl_memdesc *secure_preempt_rec_gmem[KGSL_PRIORITY_MAX_RB_LEVELS - 1]; 182: /** @dcvs_param_update: True if dcvs params have to be sent to GMU at slumber exit */ 183: bool dcvs_param_update; 184: /** @tunables_kobj: Kobj for dcvs tunables **/ 185: struct kobject tunables_kobj; 186: /** @dcvs_kobj: Kobj for dcvs params **/ 187: struct kobject dcvs_kobj; 188: /** @sysfs_dcvs_tunables : Tuning parameters for GMU based DCVS **/ MATCH LINES: 207, 245, 248, 251, 254, 257 195: * This value is based on maximum number of IBs that can fit 196: * in the ringbuffer. 197: */ 198: #define HWSCHED_MAX_IBS 2000 199: 200: enum adreno_hwsched_flags { 201: ADRENO_HWSCHED_POWER = 0, 202: ADRENO_HWSCHED_ACTIVE, 203: ADRENO_HWSCHED_CTX_BAD_LEGACY, 204: ADRENO_HWSCHED_CONTEXT_QUEUE, 205: ADRENO_HWSCHED_HW_FENCE, 206: ADRENO_HWSCHED_FORCE_RETIRE_GMU, 207: ADRENO_HWSCHED_GPU_SOFT_RESET, 208: }; 209: 210: /** 211: * adreno_hwsched_process_mem_alloc - Process memory allocation for hwsched 212: * @adreno_dev: Pointer to the adreno device 213: * @mad: Pointer to the HFI memory allocation descriptor 214: * 215: * This function processes the memory allocation request for the hwsched. 216: * It retrieves or allocates the necessary memory based on the provided 217: * descriptor and updates the descriptor with the allocated memory addresses. 218: * 219: * Return: 0 on success, or a negative error code on failure. 220: */ 221: int adreno_hwsched_process_mem_alloc(struct adreno_device *adreno_dev, 222: struct hfi_mem_alloc_desc *mad); 223: 224: /** 225: * adreno_hwsched_start() - activate the hwsched dispatcher 226: * @adreno_dev: pointer to the adreno device 227: * 228: * Enable dispatcher thread to execute 229: */ 230: void adreno_hwsched_start(struct adreno_device *adreno_dev); 231: /** 232: * adreno_hwsched_init() - Initialize the hwsched 233: * @adreno_dev: pointer to the adreno device 234: * @hwsched_ops: Pointer to target specific hwsched ops 235: * 236: * Set up the hwsched resources. 237: * Return: 0 on success or negative on failure. 238: */ 239: int adreno_hwsched_init(struct adreno_device *adreno_dev, 240: const struct adreno_hwsched_ops *hwsched_ops); 241: 242: /** 243: * adreno_hwsched_parse_fault_ib - Parse the faulty submission 244: * @adreno_dev: pointer to the adreno device 245: * @snapshot: Pointer to the snapshot structure 246: * 247: * Walk the list of active submissions to find the one that faulted and 248: * parse it so that relevant command buffers can be added to the snapshot 249: */ 250: void adreno_hwsched_parse_fault_cmdobj(struct adreno_device *adreno_dev, 251: struct kgsl_snapshot *snapshot); 252: 253: /** 254: * adreno_hwsched_unregister_contexts - Reset context gmu_registered bit 255: * @adreno_dev: pointer to the adreno device 256: * 257: * Walk the list of contexts and reset the gmu_registered for all 258: * contexts 259: */ 260: void adreno_hwsched_unregister_contexts(struct adreno_device *adreno_dev); 261: 262: /** 263: * adreno_hwsched_drain_and_idle - Drain pending work and wait for dispatcher and 264: * hardware to become idle 265: * @adreno_dev: A handle to adreno device 266: * 267: * Return: 0 on success or negative error on failure 268: */ 269: int adreno_hwsched_drain_and_idle(struct adreno_device *adreno_dev); 270: 271: void adreno_hwsched_retire_cmdobj(struct adreno_hwsched *hwsched, 272: struct kgsl_drawobj_cmd *cmdobj); 273: 274: bool adreno_hwsched_context_queue_enabled(struct adreno_device *adreno_dev); 275: 276: /** 277: * adreno_hwsched_register_hw_fence - Register GPU as a hardware fence client 278: * @adreno_dev: pointer to the adreno device 279: * 280: * Register with the hardware fence driver to be able to trigger and wait 281: * for hardware fences. Also, set up the memory descriptor for mapping the MATCH LINES: 296, 299, 337, 342, 361, 370 284: void adreno_hwsched_register_hw_fence(struct adreno_device *adreno_dev); 285: 286: /** 287: * adreno_hwsched_deregister_hw_fence - Deregister GPU as a hardware fence client 288: * @adreno_dev: pointer to the adreno device 289: * 290: * Deregister with the hardware fence driver and free up any resources allocated 291: * as part of registering with the hardware fence driver 292: */ 293: void adreno_hwsched_deregister_hw_fence(struct adreno_device *adreno_dev); 294: 295: /** 296: * adreno_hwsched_replay - Resubmit inflight cmdbatches after gpu reset 297: * @adreno_dev: pointer to the adreno device 298: * 299: * Resubmit all cmdbatches to GMU after device reset 300: */ 301: void adreno_hwsched_replay(struct adreno_device *adreno_dev); 302: 303: /** 304: * adreno_hwsched_parse_payload - Parse payload to look up a key 305: * @payload: Pointer to a payload section 306: * @key: The key who's value is to be looked up 307: * 308: * This function parses the payload data which is a sequence 309: * of key-value pairs. 310: * 311: * Return: The value of the key or 0 if key is not found 312: */ 313: u32 adreno_hwsched_parse_payload(struct payload_section *payload, u32 key); 314: 315: /** 316: * adreno_hwsched_get_payload_rb_key - Retrieve the payload based on ring buffer key 317: * @adreno_dev: Pointer to the adreno device 318: * @rb_id: Ring buffer ID to search for 319: * @key: Key to retrieve from the payload 320: * 321: * Return: The value of the key if found, otherwise 0. 322: */ 323: u32 adreno_hwsched_get_payload_rb_key(struct adreno_device *adreno_dev, u32 rb_id, u32 key); 324: 325: /** 326: * adreno_hwsched_get_payload_rb_key_legacy - Same as adreno_hwsched_get_payload_rb_key, 327: * but for legacy 328: * @adreno_dev: Pointer to the adreno device 329: * @rb_id: Ring buffer ID to search for 330: * @key: Key to retrieve from the payload 331: * 332: * Return: The value of the key if found, otherwise 0. 333: */ 334: u32 adreno_hwsched_get_payload_rb_key_legacy(struct adreno_device *adreno_dev, u32 rb_id, u32 key); 335: 336: /** 337: * adreno_hwsched_gpu_fault - Gets hwsched gpu fault info 338: * @adreno_dev: pointer to the adreno device 339: * 340: * Returns zero for hwsched fault else non zero value 341: */ 342: u32 adreno_hwsched_gpu_fault(struct adreno_device *adreno_dev); 343: 344: /** 345: * adreno_hwsched_log_remove_pending_fences - Log and remove any pending hardware fences if soccp 346: * vote failed 347: * @adreno_dev: pointer to the adreno device 348: * @dev: Pointer to the gmu pdev device 349: */ 350: void adreno_hwsched_log_remove_pending_hw_fences(struct adreno_device *adreno_dev, 351: struct device *dev); 352: 353: /** 354: * adreno_hwsched_syncobj_kfence_put - Put back kfence context refcounts for this sync object 355: * @syncobj: Pointer to the sync object 356: * 357: */ 358: void adreno_hwsched_syncobj_kfence_put(struct kgsl_drawobj_sync *syncobj); 359: 360: /** 361: * adreno_hwsched_log_nonfatal_gpu_fault - Logs non fatal GPU error from context bad hfi packet 362: * @adreno_dev: pointer to the adreno device 363: * @dev: Pointer to the struct device for the GMU platform device 364: * @error: Types of error that triggered from context bad HFI 365: * 366: * This function parses context bad hfi packet and logs error information. 367: * 368: * Return: True for non fatal error code else false. 369: */ 370: bool adreno_hwsched_log_nonfatal_gpu_fault(struct adreno_device *adreno_dev, 371: struct device *dev, u32 error); 372: 373: /** 374: * adreno_hwsched_poll_msg_queue_write_index - Poll on write index of HFI message queue 375: * @hfi_mem: Memory descriptor for HFI queue table 376: * 377: * Returns zero if write index advances or ETIMEDOUT if timed out polling 378: */ 379: int adreno_hwsched_poll_msg_queue_write_index(struct kgsl_memdesc *hfi_mem); 380: 381: /** 382: * adreno_hwsched_remove_hw_fence_entry - Remove hardware fence entry 383: * @adreno_dev: pointer to the adreno device 384: * @entry: Pointer to the hardware fence entry 385: */ 386: void adreno_hwsched_remove_hw_fence_entry(struct adreno_device *adreno_dev, 387: struct adreno_hw_fence_entry *entry); 388: 389: /** 390: * adreno_gmu_context_queue_read - Read data from context queue 391: * @drawctxt: Pointer to the adreno draw context 392: * @output: Pointer to read the data into 393: * @read_idx: Index to read the data from 394: * @size: Number of dwords to read from the context queue MATCH LINES: 462, 466, 469 450: * 451: * This function retrieves the host pointer corresponding to a given GPU address. 452: * It searches through the memory allocation table to find the matching memory 453: * descriptor and calculates the host pointer offset. 454: * 455: * Return: Host pointer if found, or NULL if the GPU address is not found in the 456: * memory allocation table. 457: */ 458: void *adreno_hwsched_get_rb_hostptr(struct adreno_device *adreno_dev, 459: u64 gpuaddr, u32 size); 460: 461: /** 462: * adreno_hwsched_reset_hfi_mem - Reset HFI memory records 463: * @adreno_dev: Pointer to the adreno device 464: * 465: * GMU expects hfi memory records to be clear during bootup. This function 466: * iterates through the memory allocation table and resets entries with 467: * HFI_MEMFLAG_HOST_INIT set. 468: */ 469: void adreno_hwsched_reset_hfi_mem(struct adreno_device *adreno_dev); 470: 471: /** 472: * adreno_hwsched_context_init - Function for context creation 473: * @drawctxt: Pointer to the adreno context 474: * 475: * Allocate resources at the time of context creation 476: * 477: * Return: Zero on success or negative error on failure 478: */ 479: int adreno_hwsched_context_init(struct adreno_context *drawctxt); 480: 481: /* 482: * adreno_hwsched_retire_cmdlist_obj - helper function for cleaning up cmd_list_obj 483: * @adreno_dev: Pointer to the adreno device 484: * @obj: pointer to cmd_list_obj 485: * 486: * Helper function to remove node from cmd_list. 487: * 488: */ 489: void adreno_hwsched_retire_cmdlist_obj(struct adreno_device *adreno_dev, 490: struct cmd_list_obj *obj); 491: #endif --- FILE: \adreno_hwsched_snapshot.c | HITS: 60 --- MATCH LINES: 7, 8, 10, 13, 18, 47, 48, 51, 52, 53, 54, 66, 75, 90, 106, 107, 110, 111, 112, 117, 121, 141, 152, 172, 173, 183, 188, 189, 197, 204, 211, 213, 222, 223, 224, 225, 230, 231, 237, 241, 242, 244, 245, 246, 247, 248, 249, 259, 260, 264, 265, 272, 278, 279, 280, 283, 284, 296, 310, 315 1: // SPDX-License-Identifier: GPL-2.0-only 2: /* 3: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 4: */ 5: 6: #include "adreno.h" 7: #include "adreno_hwsched_snapshot.h" 8: #include "adreno_snapshot.h" 9: 10: size_t adreno_hwsched_snapshot_rb(struct kgsl_device *device, u8 *buf, 11: size_t remain, void *priv) 12: { 13: struct kgsl_snapshot_rb_v2 *header = (struct kgsl_snapshot_rb_v2 *)buf; 14: u32 *data = (u32 *)(buf + sizeof(*header)); 15: struct kgsl_memdesc *rb = (struct kgsl_memdesc *)priv; 16: 17: if (remain < rb->size + sizeof(*header)) { 18: SNAPSHOT_ERR_NOMEM(device, "RB"); 19: return 0; 20: } 21: 22: header->start = 0; 23: header->end = rb->size >> 2; 24: header->rptr = 0; 25: header->rbsize = rb->size >> 2; 26: header->count = rb->size >> 2; 27: header->timestamp_queued = 0; 28: header->timestamp_retired = 0; 29: header->gpuaddr = rb->gpuaddr; 30: header->id = 0; 31: 32: memcpy(data, rb->hostptr, rb->size); 33: 34: return rb->size + sizeof(*header); 35: } 36: 37: static u32 copy_gpu_global(void *out, void *in, u32 size) 38: { 39: if (out && in) { 40: memcpy(out, in, size); 41: return size; 42: } 43: 44: return 0; 45: } 46: 47: static void adreno_hwsched_snapshot_rb_payload(struct adreno_device *adreno_dev, 48: struct kgsl_snapshot *snapshot, struct payload_section *payload) 49: { 50: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 51: struct kgsl_snapshot_section_header *section_header = 52: (struct kgsl_snapshot_section_header *)snapshot->ptr; 53: u8 *buf = snapshot->ptr + sizeof(*section_header); 54: struct kgsl_snapshot_rb_v2 *header = (struct kgsl_snapshot_rb_v2 *)buf; 55: u32 *data = (u32 *)(buf + sizeof(*header)); 56: u32 size = adreno_hwsched_parse_payload(payload, KEY_RB_SIZEDWORDS) << 2; 57: u64 lo, hi, gpuaddr; 58: void *rb_hostptr = NULL; 59: char str[16]; 60: 61: lo = adreno_hwsched_parse_payload(payload, KEY_RB_GPUADDR_LO); 62: hi = adreno_hwsched_parse_payload(payload, KEY_RB_GPUADDR_HI); 63: gpuaddr = hi << 32 | lo; 64: 65: /* Sanity check to make sure there is enough for the header */ 66: if (snapshot->remain < sizeof(*section_header)) 67: goto err; 68: 69: rb_hostptr = adreno_hwsched_get_rb_hostptr(adreno_dev, gpuaddr, size); 70: 71: if (rb_hostptr == NULL) 72: goto err; 73: 74: /* If the gpuaddress and size don't match any allocation, then abort */ 75: if (((snapshot->remain - sizeof(*section_header)) < (size + sizeof(*header))) || 76: !copy_gpu_global(data, rb_hostptr, size)) 77: goto err; 78: 79: if (device->dump_all_ibs) { 80: u64 rbaddr, lpac_rbaddr; 81: 82: adreno_readreg64(adreno_dev, ADRENO_REG_CP_RB_BASE, 83: ADRENO_REG_CP_RB_BASE_HI, &rbaddr); 84: 85: adreno_readreg64(adreno_dev, ADRENO_REG_CP_LPAC_RB_BASE, 86: ADRENO_REG_CP_LPAC_RB_BASE_HI, &lpac_rbaddr); 87: 88: /* Parse all IBs from current RB */ 89: if ((rbaddr == gpuaddr) || (lpac_rbaddr == gpuaddr)) 90: adreno_snapshot_dump_all_ibs(device, rb_hostptr, snapshot); 91: } 92: 93: header->start = 0; 94: header->end = size >> 2; 95: header->rptr = adreno_hwsched_parse_payload(payload, KEY_RB_RPTR); 96: header->wptr = adreno_hwsched_parse_payload(payload, KEY_RB_WPTR); 97: header->rbsize = size >> 2; 98: header->count = size >> 2; 99: header->timestamp_queued = adreno_hwsched_parse_payload(payload, 100: KEY_RB_QUEUED_TS); 101: header->timestamp_retired = adreno_hwsched_parse_payload(payload, 102: KEY_RB_RETIRED_TS); 103: header->gpuaddr = gpuaddr; 104: header->id = adreno_hwsched_parse_payload(payload, KEY_RB_ID); 105: 106: section_header->magic = SNAPSHOT_SECTION_MAGIC; 107: section_header->id = KGSL_SNAPSHOT_SECTION_RB_V2; 108: section_header->size = size + sizeof(*header) + sizeof(*section_header); 109: 110: snapshot->ptr += section_header->size; 111: snapshot->remain -= section_header->size; 112: snapshot->size += section_header->size; 113: 114: return; 115: err: 116: snprintf(str, sizeof(str), "RB addr:0x%llx", gpuaddr); 117: SNAPSHOT_ERR_NOMEM(device, str); 118: } 119: 120: bool adreno_hwsched_parse_payload_rb_legacy(struct adreno_device *adreno_dev, 121: struct kgsl_snapshot *snapshot) 122: { 123: struct hfi_context_bad_cmd_legacy *cmd = adreno_dev->hwsched.ctxt_bad; 124: u32 i = 0, payload_bytes; 125: void *start; 126: bool ret = false; 127: 128: /* Skip if we didn't receive a context bad HFI */ 129: if (!cmd->hdr) 130: return false; 131: 132: payload_bytes = (MSG_HDR_GET_SIZE(cmd->hdr) << 2) - 133: offsetof(struct hfi_context_bad_cmd_legacy, payload); 134: 135: start = &cmd->payload[0]; 136: 137: while (i < payload_bytes) { 138: struct payload_section *payload = start + i; 139: 140: if (payload->type == PAYLOAD_RB) { 141: adreno_hwsched_snapshot_rb_payload(adreno_dev, snapshot, payload); 142: ret = true; 143: } 144: 145: i += sizeof(*payload) + (payload->dwords << 2); 146: } 147: 148: return ret; 149: } 150: 151: bool adreno_hwsched_parse_payload_rb(struct adreno_device *adreno_dev, 152: struct kgsl_snapshot *snapshot) 153: { 154: struct hfi_context_bad_cmd *cmd = adreno_dev->hwsched.ctxt_bad; 155: u32 i = 0, payload_bytes; 156: void *start; 157: bool ret = false; 158: 159: /* Skip if we didn't receive a context bad HFI */ 160: if (!cmd->hdr) 161: return false; 162: 163: payload_bytes = (MSG_HDR_GET_SIZE(cmd->hdr) << 2) - 164: offsetof(struct hfi_context_bad_cmd, payload); 165: 166: start = &cmd->payload[0]; 167: 168: while (i < payload_bytes) { 169: struct payload_section *payload = start + i; 170: 171: if (payload->type == PAYLOAD_RB) { 172: adreno_hwsched_snapshot_rb_payload(adreno_dev, 173: snapshot, payload); 174: ret = true; 175: } 176: 177: i += sizeof(*payload) + (payload->dwords << 2); 178: } 179: 180: return ret; 181: } 182: 183: size_t adreno_hwsched_snapshot_aqe_buffer(struct kgsl_device *device, u8 *buf, 184: size_t remain, void *priv) 185: { 186: struct kgsl_memdesc *memdesc = priv; 187: 188: struct kgsl_snapshot_gpu_object_v2 *header = 189: (struct kgsl_snapshot_gpu_object_v2 *)buf; 190: 191: u8 *ptr = buf + sizeof(*header); 192: 193: if (IS_ERR_OR_NULL(memdesc) || memdesc->size == 0) 194: return 0; 195: 196: if (remain < (memdesc->size + sizeof(*header))) { 197: SNAPSHOT_ERR_NOMEM(device, "AQE BUFFER"); 198: return 0; 199: } 200: 201: header->size = memdesc->size >> 2; 202: header->gpuaddr = memdesc->gpuaddr; 203: header->ptbase = MMU_DEFAULT_TTBR0(device); 204: header->type = SNAPSHOT_GPU_OBJECT_GLOBAL; 205: 206: memcpy(ptr, memdesc->hostptr, memdesc->size); 207: 208: return memdesc->size + sizeof(*header); 209: } 210: 211: static int snapshot_context_queue(int id, void *ptr, void *data) 212: { 213: struct kgsl_snapshot *snapshot = data; 214: struct kgsl_context *context = ptr; 215: struct adreno_context *drawctxt = ADRENO_CONTEXT(context); 216: struct gmu_mem_type_desc desc; 217: 218: if (!context->gmu_registered) 219: return 0; 220: 221: desc.memdesc = &drawctxt->gmu_context_queue; 222: desc.type = SNAPSHOT_GMU_MEM_CONTEXT_QUEUE; 223: kgsl_snapshot_add_section(context->device, 224: KGSL_SNAPSHOT_SECTION_GMU_MEMORY, 225: snapshot, adreno_snapshot_gmu_mem, &desc); 226: 227: return 0; 228: } 229: 230: void adreno_hwsched_snapshot_context_queue(struct kgsl_device *device, 231: struct kgsl_snapshot *snapshot) 232: { 233: if (!adreno_hwsched_context_queue_enabled(ADRENO_DEVICE(device))) 234: return; 235: 236: read_lock(&device->context_lock); 237: idr_for_each(&device->context_idr, snapshot_context_queue, snapshot); 238: read_unlock(&device->context_lock); 239: } 240: 241: static void snapshot_preemption_record(struct kgsl_device *device, 242: struct kgsl_snapshot *snapshot, struct kgsl_memdesc *md, u64 offset, u64 size) 243: { 244: struct kgsl_snapshot_section_header *section_header = 245: (struct kgsl_snapshot_section_header *)snapshot->ptr; 246: u8 *dest = snapshot->ptr + sizeof(*section_header); 247: struct kgsl_snapshot_gpu_object_v2 *header = 248: (struct kgsl_snapshot_gpu_object_v2 *)dest; 249: u64 ctxt_record_size = min_t(u64, device->snapshot_ctxt_record_size, size); 250: size_t section_size; 251: 252: if (WARN_RATELIMIT((ctxt_record_size > md->size) || 253: (offset > (md->size - ctxt_record_size)), 254: "Invalid preemption context record size: md_size: 0x%llx, ctxt_record_size: 0x%llx\n", 255: md->size, ctxt_record_size)) 256: return; 257: 258: section_size = sizeof(*section_header) + sizeof(*header) + ctxt_record_size; 259: if (snapshot->remain < section_size) { 260: SNAPSHOT_ERR_NOMEM(device, "PREEMPTION RECORD"); 261: return; 262: } 263: 264: section_header->magic = SNAPSHOT_SECTION_MAGIC; 265: section_header->id = KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2; 266: section_header->size = section_size; 267: 268: header->size = ctxt_record_size >> 2; 269: header->gpuaddr = md->gpuaddr + offset; 270: header->ptbase = 271: kgsl_mmu_pagetable_get_ttbr0(device->mmu.defaultpagetable); 272: header->type = SNAPSHOT_GPU_OBJECT_GLOBAL; 273: 274: dest += sizeof(*header); 275: 276: memcpy(dest, md->hostptr + offset, ctxt_record_size); 277: 278: snapshot->ptr += section_header->size; 279: snapshot->remain -= section_header->size; 280: snapshot->size += section_header->size; 281: } 282: 283: void adreno_hwsched_snapshot_preemption_records(struct kgsl_device *device, 284: struct kgsl_snapshot *snapshot, struct kgsl_memdesc *md) 285: { 286: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 287: u64 offset = 0, ctxt_record_size = md->size; 288: u64 rb0_ctxt_record_size = PAGE_ALIGN(adreno_dev->total_ctxt_record_sz); 289: u64 curr_gmem_size = adreno_gmem_size(adreno_dev); 290: int i; 291: 292: if (ADRENO_FEATURE(adreno_dev, ADRENO_DEFER_GMEM_ALLOC)) { 293: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 294: 295: for (i = 0; i < KGSL_PRIORITY_MAX_RB_LEVELS; i++) 296: snapshot_preemption_record(device, snapshot, 297: hwsched->preempt_rec[i], 0, hwsched->preempt_rec[i]->size); 298: return; 299: } 300: 301: /* Check whether GMU has removed GMEM size from RB0 context record */ 302: if (md->size == (rb0_ctxt_record_size * KGSL_PRIORITY_MAX_RB_LEVELS)) { 303: do_div(ctxt_record_size, KGSL_PRIORITY_MAX_RB_LEVELS); 304: } else { 305: rb0_ctxt_record_size -= PAGE_ALIGN(curr_gmem_size); 306: ctxt_record_size -= rb0_ctxt_record_size; 307: do_div(ctxt_record_size, KGSL_PRIORITY_MAX_RB_LEVELS - 1); 308: } 309: 310: snapshot_preemption_record(device, snapshot, md, offset, rb0_ctxt_record_size); 311: offset += rb0_ctxt_record_size; 312: 313: /* All preemption records exist as a single mem alloc entry */ 314: for (i = 1; i < KGSL_PRIORITY_MAX_RB_LEVELS; i++) { 315: snapshot_preemption_record(device, snapshot, md, 316: offset, ctxt_record_size); 317: offset += ctxt_record_size; 318: } 319: } --- FILE: \adreno_hwsched_snapshot.h | HITS: 10 --- MATCH LINES: 6, 7, 10, 13, 15, 18, 21, 22, 24, 25 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 4: */ 5: 6: #ifndef _ADRENO_HWSCHED_SNAPSHOT_H_ 7: #define _ADRENO_HWSCHED_SNAPSHOT_H_ 8: 9: bool adreno_hwsched_parse_payload_rb_legacy(struct adreno_device *adreno_dev, 10: struct kgsl_snapshot *snapshot); 11: 12: bool adreno_hwsched_parse_payload_rb(struct adreno_device *adreno_dev, 13: struct kgsl_snapshot *snapshot); 14: 15: size_t adreno_hwsched_snapshot_rb(struct kgsl_device *device, u8 *buf, 16: size_t remain, void *priv); 17: 18: size_t adreno_hwsched_snapshot_aqe_buffer(struct kgsl_device *device, u8 *buf, 19: size_t remain, void *priv); 20: 21: void adreno_hwsched_snapshot_context_queue(struct kgsl_device *device, 22: struct kgsl_snapshot *snapshot); 23: 24: void adreno_hwsched_snapshot_preemption_records(struct kgsl_device *device, 25: struct kgsl_snapshot *snapshot, struct kgsl_memdesc *md); 26: 27: #endif --- FILE: \adreno_pm4types.h | HITS: 2 --- MATCH LINES: 148, 150 136: 137: /* Controls which threads execute the PM4 commands the follow this packet */ 138: #define CP_THREAD_CONTROL 0x17 139: 140: #define CP_WAIT_TIMESTAMP 0x14 141: 142: #define CP_SET_THREAD_BR FIELD_PREP(GENMASK(1, 0), 1) 143: #define CP_SET_THREAD_BV FIELD_PREP(GENMASK(1, 0), 2) 144: #define CP_SET_THREAD_BOTH FIELD_PREP(GENMASK(1, 0), 3) 145: #define CP_SYNC_THREADS BIT(31) 146: #define CP_CONCURRENT_BIN_DISABLE BIT(27) 147: 148: #define CP_RESET_CONTEXT_STATE 0x1F 149: 150: #define CP_RESET_GLOBAL_LOCAL_TS BIT(3) 151: #define CP_CLEAR_BV_BR_COUNTER BIT(2) 152: #define CP_CLEAR_RESOURCE_TABLE BIT(1) 153: #define CP_CLEAR_ON_CHIP_TS BIT(0) 154: 155: /* Used to define amble type in SET_AMBLE packet to execute during preemption */ 156: #define CP_KMD_AMBLE_TYPE 3 157: 158: static inline uint pm4_calc_odd_parity_bit(uint val) 159: { 160: return (0x9669 >> (0xf & ((val) ^ 161: ((val) >> 4) ^ ((val) >> 8) ^ ((val) >> 12) ^ 162: ((val) >> 16) ^ ((val) >> 20) ^ ((val) >> 24) ^ 163: ((val) >> 28)))) & 1; 164: } 165: 166: static inline uint cp_type4_packet(uint opcode, uint cnt) 167: { 168: return CP_TYPE4_PKT | ((cnt) << 0) | 169: (pm4_calc_odd_parity_bit(cnt) << 7) | 170: (((opcode) & 0x3FFFF) << 8) | 171: ((pm4_calc_odd_parity_bit(opcode) << 27)); 172: } 173: 174: static inline uint cp_type7_packet(uint opcode, uint cnt) --- FILE: \adreno_profile.c | HITS: 2 --- MATCH LINES: 451, 461 439: log_buf_wrapinc(log_base, &log_ptr); 440: *log_ptr = *(ptr + buf_off++); /* perf cntr end lo */ 441: log_buf_wrapinc(log_base, &log_ptr); 442: 443: } 444: 445: tmp_tail = profile->shared_tail; 446: shared_buf_inc(profile->shared_size, 447: &profile->shared_tail, 448: SIZE_SHARED_ENTRY(cnt)); 449: /* 450: * Possibly lost some room as we cycled around, so it's safe to 451: * reset the max size 452: */ 453: if (profile->shared_tail < tmp_tail) 454: profile->shared_size = 455: ADRENO_PROFILE_SHARED_BUF_SIZE_DWORDS; 456: 457: } 458: profile->log_head = log_ptr; 459: return; 460: err: 461: /* reset head/tail to same on error in hopes we work correctly later */ 462: profile->log_head = profile->log_tail; 463: } 464: 465: static int profile_enable_get(void *data, u64 *val) 466: { 467: struct kgsl_device *device = data; 468: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 469: 470: kgsl_mutex_lock(&device->mutex); 471: *val = adreno_profile_enabled(&adreno_dev->profile); 472: kgsl_mutex_unlock(&device->mutex); 473: 474: return 0; 475: } 476: 477: static int profile_enable_set(void *data, u64 val) 478: { 479: struct kgsl_device *device = data; 480: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 481: struct adreno_profile *profile = &adreno_dev->profile; 482: 483: kgsl_mutex_lock(&device->mutex); 484: 485: if (val && profile->log_buffer == NULL) { --- FILE: \adreno_ringbuffer.c | HITS: 3 --- MATCH LINES: 255, 264, 268 243: struct adreno_submit_time *time) 244: { 245: struct adreno_submit_time local = { 0 }; 246: struct kgsl_drawobj *drawobj = DRAWOBJ(cmdobj); 247: struct adreno_context *drawctxt = ADRENO_CONTEXT(drawobj->context); 248: struct adreno_ringbuffer *rb = drawctxt->rb; 249: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 250: u32 flags = 0; 251: int ret; 252: 253: /* 254: * If SKIP CMD flag is set for current context 255: * a) set SKIPCMD as fault_recovery for current commandbatch 256: * b) store context's commandbatch fault_policy in current 257: * commandbatch fault_policy and clear context's commandbatch 258: * fault_policy 259: * c) force preamble for commandbatch 260: */ 261: if (test_bit(ADRENO_CONTEXT_SKIP_CMD, &drawctxt->base.priv) && 262: (!test_bit(CMDOBJ_SKIP, &cmdobj->priv))) { 263: 264: set_bit(KGSL_FT_SKIPCMD, &cmdobj->fault_recovery); 265: cmdobj->fault_policy = drawctxt->fault_policy; 266: set_bit(CMDOBJ_FORCE_PREAMBLE, &cmdobj->priv); 267: 268: /* if context is detached print fault recovery */ 269: adreno_fault_skipcmd_detached(adreno_dev, drawctxt, drawobj); 270: 271: /* clear the drawctxt flags */ 272: clear_bit(ADRENO_CONTEXT_SKIP_CMD, &drawctxt->base.priv); 273: drawctxt->fault_policy = 0; 274: } 275: 276: /* Check if user profiling should be enabled */ 277: 278: if ((drawobj->flags & KGSL_DRAWOBJ_PROFILING) && 279: cmdobj->profiling_buf_entry) { 280: flags |= F_USER_PROFILE; 281: 282: /* 283: * we want to use an adreno_submit_time struct to get the 284: * precise moment when the command is submitted to the 285: * ringbuffer. If an upstream caller already passed down a 286: * pointer piggyback on that otherwise use a local struct 287: */ 288: if (!time) 289: time = &local; 290: 291: time->drawobj = drawobj; 292: } --- FILE: \adreno_snapshot.c | HITS: 289 --- MATCH LINES: 12, 16, 21, 22, 26, 27, 29, 42, 71, 83, 84, 91, 98, 105, 135, 136, 137, 143, 172, 175, 180, 198, 209, 213, 215, 216, 217, 221, 226, 231, 236, 247, 251, 253, 254, 255, 259, 264, 269, 273, 274, 300, 308, 312, 314, 316, 326, 328, 338, 370, 375, 378, 379, 392 1: // SPDX-License-Identifier: GPL-2.0-only 2: /* 3: * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #include 8: 9: #include "adreno.h" 10: #include "adreno_cp_parser.h" 11: #include "adreno_pm4types.h" 12: #include "adreno_snapshot.h" 13: 14: /* Maintain a list of the objects we see during parsing */ 15: 16: #define SNAPSHOT_OBJ_BUFSIZE 64 17: 18: /* Used to print error message if an IB has too many objects in it */ 19: static int ib_max_objs; 20: 21: struct snapshot_rb_params { 22: struct kgsl_snapshot *snapshot; 23: struct adreno_ringbuffer *rb; 24: }; 25: 26: /* Keep track of how many bytes are frozen after a snapshot and tell the user */ 27: static size_t snapshot_frozen_objsize; 28: 29: static struct kgsl_snapshot_object objbuf[SNAPSHOT_OBJ_BUFSIZE]; 30: 31: /* Pointer to the next open entry in the object list */ 32: static unsigned int objbufptr; 33: 34: static inline int adreno_rb_ctxtswitch(struct adreno_device *adreno_dev, 35: unsigned int *cmd) 36: { 37: return cmd[0] == cp_packet(adreno_dev, CP_NOP, 1) && 38: cmd[1] == CONTEXT_TO_MEM_IDENTIFIER; 39: } 40: 41: /* Push a new buffer object onto the list */ 42: void kgsl_snapshot_push_object(struct kgsl_device *device, 43: struct kgsl_process_private *process, 44: uint64_t gpuaddr, uint64_t dwords) 45: { 46: int index; 47: struct kgsl_mem_entry *entry; 48: 49: if (process == NULL || gpuaddr == 0) 50: return; 51: 52: /* 53: * Sometimes IBs can be reused in the same dump. Because we parse from 54: * oldest to newest, if we come across an IB that has already been used, 55: * assume that it has been reused and update the list with the newest 56: * size. 57: */ 58: 59: for (index = 0; index < objbufptr; index++) { 60: if (objbuf[index].gpuaddr == gpuaddr && 61: objbuf[index].entry->priv == process) { 62: /* 63: * Check if newly requested size is within the 64: * allocated range or not, otherwise continue 65: * with previous size. 66: */ 67: if (!kgsl_gpuaddr_in_memdesc( 68: &objbuf[index].entry->memdesc, 69: gpuaddr, dwords << 2)) { 70: dev_err(device->dev, 71: "snapshot: gpuaddr 0x%016llX size is less than requested\n", 72: gpuaddr); 73: return; 74: } 75: 76: objbuf[index].size = max_t(uint64_t, 77: objbuf[index].size, 78: dwords << 2); 79: return; 80: } 81: } 82: 83: if (objbufptr == SNAPSHOT_OBJ_BUFSIZE) { 84: dev_err(device->dev, "snapshot: too many snapshot objects\n"); 85: return; 86: } 87: 88: entry = kgsl_sharedmem_find(process, gpuaddr); 89: if (entry == NULL) { 90: dev_err(device->dev, 91: "snapshot: Can't find entry for 0x%016llX\n", gpuaddr); 92: return; 93: } 94: 95: /* 96: * In some gpu fault scenarios incorrect dword size resulting to return 97: * without putting IB addrs into the list. Hence update IB dword size 98: * within memdesc size to have IB dump in snapshot. 99: */ 100: if ((gpuaddr + (dwords << 2)) > (entry->memdesc.gpuaddr + entry->memdesc.size)) 101: dwords = (entry->memdesc.size - (gpuaddr - entry->memdesc.gpuaddr)) >> 2; 102: 103: if (!kgsl_gpuaddr_in_memdesc(&entry->memdesc, gpuaddr, dwords << 2)) { 104: dev_err(device->dev, 105: "snapshot: Mem entry 0x%016llX is too small\n", 106: gpuaddr); 107: kgsl_mem_entry_put(entry); 108: return; 109: } 110: 111: /* Put it on the list of things to parse */ 112: objbuf[objbufptr].gpuaddr = gpuaddr; 113: objbuf[objbufptr].size = dwords << 2; 114: objbuf[objbufptr++].entry = entry; 115: } 116: 117: /* 118: * Returns index of the specified object is already on the list of buffers 119: * to be dumped 120: */ 121: 122: static int find_object(uint64_t gpuaddr, struct kgsl_process_private *process) 123: { 124: int index; 125: 126: for (index = 0; index < objbufptr; index++) { 127: if (objbuf[index].gpuaddr == gpuaddr && 128: objbuf[index].entry->priv == process) 129: return index; 130: } 131: return -ENOENT; 132: } 133: 134: /* 135: * snapshot_freeze_obj_list() - Take a list of ib objects and freeze their 136: * memory for snapshot 137: * @snapshot: The snapshot data. 138: * @process: The process to which the IB belongs 139: * @ib_obj_list: List of the IB objects 140: * 141: * Returns 0 on success else error code 142: */ 143: static int snapshot_freeze_obj_list(struct kgsl_snapshot *snapshot, 144: struct kgsl_process_private *process, 145: struct adreno_ib_object_list *ib_obj_list) 146: { 147: int ret = 0; 148: struct adreno_ib_object *ib_objs; 149: int i; 150: 151: for (i = 0; i < ib_obj_list->num_objs; i++) { 152: int temp_ret; 153: int index; 154: int freeze = 1; 155: 156: ib_objs = &(ib_obj_list->obj_list[i]); 157: /* Make sure this object is not going to be saved statically */ 158: for (index = 0; index < objbufptr; index++) { 159: if ((objbuf[index].gpuaddr <= ib_objs->gpuaddr) && 160: ((objbuf[index].gpuaddr + 161: (objbuf[index].size)) >= 162: (ib_objs->gpuaddr + ib_objs->size)) && 163: (objbuf[index].entry->priv == process)) { 164: freeze = 0; 165: CLEAR_FLAG(KGSL_MEMDESC_SKIP_RECLAIM, 166: &(objbuf[index].entry->memdesc.priv)); 167: break; 168: } 169: } 170: 171: if (freeze) { 172: temp_ret = kgsl_snapshot_get_object(snapshot, 173: process, ib_objs->gpuaddr, 174: ib_objs->size, 175: ib_objs->snapshot_obj_type); 176: if (temp_ret < 0) { 177: if (ret >= 0) 178: ret = temp_ret; 179: } else { 180: snapshot_frozen_objsize += temp_ret; 181: } 182: } 183: } 184: return ret; 185: } 186: 187: static inline bool adreno_ib_addr_overlap(u64 ibaddr, u64 gpuaddr, u64 dwords) 188: { 189: u64 size = dwords << 2; 190: 191: if (size > (U64_MAX - gpuaddr)) 192: return false; 193: 194: return (ibaddr >= gpuaddr && ibaddr < (gpuaddr + size)); 195: } 196: 197: void adreno_parse_ib(struct kgsl_device *device, 198: struct kgsl_snapshot *snapshot, 199: struct kgsl_process_private *process, 200: uint64_t gpuaddr, uint64_t dwords) 201: { 202: struct adreno_ib_object_list *ib_obj_list; 203: 204: /* 205: * Check the IB address - if it is either the last executed IB1 206: * then push it into the static blob otherwise put it in the dynamic 207: * list 208: */ 209: if (adreno_ib_addr_overlap(snapshot->ib1base, gpuaddr, dwords)) { 210: /* 211: * During restore after preemption, ib1base in the register 212: * can be updated by CP. In such scenarios, to dump complete 213: * IB1 in snapshot, we should consider ib1base from ringbuffer. 214: */ 215: snapshot->ib1base = gpuaddr; 216: snapshot->ib1size = dwords; 217: kgsl_snapshot_push_object(device, process, gpuaddr, dwords); 218: return; 219: } 220: 221: if (kgsl_snapshot_have_object(snapshot, process, 222: gpuaddr, dwords << 2)) 223: return; 224: 225: if (-E2BIG == adreno_ib_create_object_list(device, process, 226: gpuaddr, dwords, snapshot->ib2base, 227: &ib_obj_list)) 228: ib_max_objs = 1; 229: 230: if (ib_obj_list) 231: kgsl_snapshot_add_ib_obj_list(snapshot, ib_obj_list); 232: 233: } 234: 235: void adreno_parse_ib_lpac(struct kgsl_device *device, 236: struct kgsl_snapshot *snapshot, 237: struct kgsl_process_private *process, 238: u64 gpuaddr, u64 dwords) 239: { 240: struct adreno_ib_object_list *ib_obj_list; 241: 242: /* 243: * Check the IB address - if it is either the last executed IB1 244: * then push it into the static blob otherwise put it in the dynamic 245: * list 246: */ 247: if (adreno_ib_addr_overlap(snapshot->ib1base_lpac, gpuaddr, dwords)) { 248: /* 249: * During restore after preemption, ib1base in the register 250: * can be updated by CP. In such scenarios, to dump complete 251: * IB1 in snapshot, we should consider ib1base from ringbuffer. 252: */ 253: snapshot->ib1base_lpac = gpuaddr; 254: snapshot->ib1size_lpac = dwords; 255: kgsl_snapshot_push_object(device, process, gpuaddr, dwords); 256: return; 257: } 258: 259: if (kgsl_snapshot_have_object(snapshot, process, 260: gpuaddr, dwords << 2)) 261: return; 262: 263: if (-E2BIG == adreno_ib_create_object_list(device, process, 264: gpuaddr, dwords, snapshot->ib2base_lpac, 265: &ib_obj_list)) 266: ib_max_objs = 1; 267: 268: if (ib_obj_list) 269: kgsl_snapshot_add_ib_obj_list(snapshot, ib_obj_list); 270: 271: } 272: 273: void adreno_snapshot_dump_all_ibs(struct kgsl_device *device, 274: unsigned int *rbptr, struct kgsl_snapshot *snapshot) 275: { 276: int index = 0; 277: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 278: struct kgsl_iommu *iommu = KGSL_IOMMU(device); 279: 280: for (index = 0; index < KGSL_RB_DWORDS;) { 281: 282: if (adreno_cmd_is_ib(adreno_dev, rbptr[index])) { 283: uint64_t ibaddr; 284: uint64_t ibsize; 285: 286: ibaddr = rbptr[(index + 2) % KGSL_RB_DWORDS]; 287: ibaddr = ibaddr << 32 | rbptr[(index + 1) % KGSL_RB_DWORDS]; 288: ibsize = rbptr[(index + 3) % KGSL_RB_DWORDS]; 289: index += 4; 290: 291: /* Don't parse known global IBs */ 292: if (kgsl_gpuaddr_in_memdesc(iommu->setstate, 293: ibaddr, ibsize)) 294: continue; 295: 296: if (kgsl_gpuaddr_in_memdesc(adreno_dev->pwron_fixup, 297: ibaddr, ibsize)) 298: continue; 299: 300: adreno_parse_ib(device, snapshot, snapshot->process, 301: ibaddr, ibsize); 302: } else 303: index = index + 1; 304: } 305: } 306: 307: /** 308: * snapshot_rb_ibs() - Dump rb data and capture the IB's in the RB as well 309: * @device: Pointer to a KGSL device 310: * @rb: The RB to dump 311: * @data: Pointer to memory where the RB data is to be dumped 312: * @snapshot: Pointer to information about the current snapshot being taken 313: */ 314: static void snapshot_rb_ibs(struct kgsl_device *device, 315: struct adreno_ringbuffer *rb, 316: struct kgsl_snapshot *snapshot) 317: { 318: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 319: unsigned int *rbptr, rptr = adreno_get_rptr(rb); 320: int index, i; 321: int parse_ibs = 0, ib_parse_start; 322: 323: /* 324: * During IB parse, vmalloc is called which can sleep and 325: * should not be called from atomic context. Since IBs are not 326: * dumped during atomic snapshot, there is no need to parse it. 327: */ 328: if (device->snapshot_atomic) 329: return; 330: 331: rbptr = rb->buffer_desc->hostptr; 332: /* 333: * KGSL tries to dump the active IB first. If it is not present, then 334: * only it dumps all the IBs. In few cases, non-active IBs may help to 335: * establish the flow and understand the hardware state better. 336: */ 337: if (device->dump_all_ibs) { 338: adreno_snapshot_dump_all_ibs(device, rbptr, snapshot); 339: return; 340: } 341: 342: /* 343: * Figure out the window of ringbuffer data to dump. First we need to 344: * find where the last processed IB ws submitted. Start walking back 345: * from the rptr 346: */ 347: index = rptr; 348: 349: do { 350: index--; 351: 352: if (index < 0) { 353: index = KGSL_RB_DWORDS - 4; 354: 355: /* We wrapped without finding what we wanted */ 356: if (index < rb->wptr) { 357: index = rb->wptr; 358: break; 359: } 360: } 361: 362: if (adreno_cmd_is_ib(adreno_dev, rbptr[index])) { 363: uint64_t ibaddr; 364: uint64_t ibsize; 365: 366: ibaddr = rbptr[index + 2]; 367: ibaddr = ibaddr << 32 | rbptr[index + 1]; 368: ibsize = rbptr[index + 3]; 369: 370: if (adreno_ib_addr_overlap(snapshot->ib1base, 371: ibaddr, ibsize)) { 372: /* 373: * During restore after preemption, ib1base in 374: * the register can be updated by CP. In such 375: * scenario, to dump complete IB1 in snapshot, 376: * we should consider ib1base from ringbuffer. 377: */ 378: snapshot->ib1base = ibaddr; 379: snapshot->ib1size = ibsize; 380: break; 381: } 382: } 383: } while (index != rb->wptr); 384: 385: /* 386: * If the ib1 was not found, for example, if ib1base was restored 387: * incorrectly after preemption, then simply dump the entire 388: * ringbuffer along with all the IBs in the ringbuffer. 389: */ 390: 391: if (index == rb->wptr) { 392: adreno_snapshot_dump_all_ibs(device, rb->buffer_desc->hostptr, snapshot); 393: return; 394: } 395: 396: /* 397: * index points at the last submitted IB. We can only trust that the 398: * memory between the context switch and the hanging IB is valid, so 399: * the next step is to find the context switch before the submission 400: */ 401: 402: while (index != rb->wptr) { 403: index--; 404: 405: if (index < 0) { 406: index = KGSL_RB_DWORDS - 2; 407: 408: /* 409: * Wrapped without finding the context switch. This is 410: * harmless - we should still have enough data to dump a 411: * valid state 412: */ 413: 414: if (index < rb->wptr) { 415: index = rb->wptr; 416: break; MATCH LINES: 471, 479, 480, 483, 486, 487, 497, 516, 538, 541, 542, 562, 571, 586, 587, 592, 593, 597, 602, 607, 614, 617, 618, 622, 623, 628, 629, 633, 638, 643, 650, 653, 654, 682, 683, 686, 687, 691, 692, 695, 696, 699, 708, 715, 723, 728, 733, 742, 747, 752, 757, 765, 783, 785, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 798, 799, 814, 841, 866, 867, 872, 873, 882, 888, 896, 903, 904, 905, 910, 911, 914, 915, 916, 919, 920, 922, 923, 930, 931, 934, 935, 938, 939, 940, 941, 947, 948, 952, 983, 984, 988, 1009, 1010, 1012, 1014, 1015, 1016, 1054, 1070, 1073, 1077, 1079, 1080, 1083, 1085, 1089, 1093, 1094, 1099, 1100, 1101, 1103, 1106, 1107, 1111, 1123, 1124, 1129, 1130, 1131, 1133, 1136, 1137, 1141, 1142, 1145, 1146, 1149, 1150, 1151, 1153, 1154, 1155, 1157, 1163, 1164, 1167, 1172, 1173, 1174, 1177, 1180, 1183, 1185, 1187, 1190, 1193, 1194, 1196, 1197, 1198, 1199, 1201, 1205, 1210, 1213, 1217, 1218, 1220, 1221, 1223, 1224, 1227, 1228, 1232, 1238, 1239, 1241, 1242, 1244, 1245, 1246, 1248, 1249, 1250, 1256, 1259, 1261, 1263, 1264, 1269, 1270, 1275, 1277, 1278, 1282, 1283, 1286, 1291, 1292, 1295, 1316, 1324, 1327, 1350, 1353, 1355, 1358, 1370, 1371, 1375, 1376, 1378, 1380, 1382, 1384, 1389, 1390, 1393, 1396, 1397, 1406, 1417, 1425, 1426, 1430, 1431, 1433, 1436, 1444, 1451, 1452, 1460, 1461, 1462 459: 460: index = (index + 1) % KGSL_RB_DWORDS; 461: 462: /* Don't parse known global IBs */ 463: if (kgsl_gpuaddr_in_memdesc(iommu->setstate, 464: ibaddr, ibsize)) 465: continue; 466: 467: if (kgsl_gpuaddr_in_memdesc(adreno_dev->pwron_fixup, 468: ibaddr, ibsize)) 469: continue; 470: 471: adreno_parse_ib(device, snapshot, snapshot->process, 472: ibaddr, ibsize); 473: } else 474: index = (index + 1) % KGSL_RB_DWORDS; 475: } 476: 477: } 478: 479: /* Snapshot the ringbuffer memory */ 480: static size_t snapshot_rb(struct kgsl_device *device, u8 *buf, 481: size_t remain, void *priv) 482: { 483: struct kgsl_snapshot_rb_v2 *header = (struct kgsl_snapshot_rb_v2 *)buf; 484: unsigned int *data = (unsigned int *)(buf + sizeof(*header)); 485: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 486: struct snapshot_rb_params *snap_rb_params = priv; 487: struct kgsl_snapshot *snapshot = snap_rb_params->snapshot; 488: struct adreno_ringbuffer *rb = snap_rb_params->rb; 489: 490: /* 491: * Dump the entire ringbuffer - the parser can choose how much of it to 492: * process 493: */ 494: 495: if (remain < KGSL_RB_SIZE + sizeof(*header)) { 496: dev_err(device->dev, 497: "snapshot: Not enough memory for the rb section\n"); 498: return 0; 499: } 500: 501: /* Write the sub-header for the section */ 502: header->start = 0; 503: header->end = KGSL_RB_DWORDS; 504: header->wptr = rb->wptr; 505: header->rptr = adreno_get_rptr(rb); 506: header->rbsize = KGSL_RB_DWORDS; 507: header->count = KGSL_RB_DWORDS; 508: adreno_rb_readtimestamp(adreno_dev, rb, KGSL_TIMESTAMP_QUEUED, 509: &header->timestamp_queued); 510: adreno_rb_readtimestamp(adreno_dev, rb, KGSL_TIMESTAMP_RETIRED, 511: &header->timestamp_retired); 512: header->gpuaddr = rb->buffer_desc->gpuaddr; 513: header->id = rb->id; 514: 515: if (rb == adreno_dev->cur_rb) 516: snapshot_rb_ibs(device, rb, snapshot); 517: 518: /* Just copy the ringbuffer, there are no active IBs */ 519: memcpy(data, rb->buffer_desc->hostptr, KGSL_RB_SIZE); 520: 521: /* Return the size of the section */ 522: return KGSL_RB_SIZE + sizeof(*header); 523: } 524: 525: static int _count_mem_entries(int id, void *ptr, void *data) 526: { 527: int *count = data; 528: *count = *count + 1; 529: return 0; 530: } 531: 532: struct mem_entry { 533: uint64_t gpuaddr; 534: uint64_t size; 535: unsigned int type; 536: } __packed; 537: 538: static size_t snapshot_capture_mem_list(struct kgsl_device *device, 539: u8 *buf, size_t remain, void *priv) 540: { 541: struct kgsl_snapshot_mem_list_v2 *header = 542: (struct kgsl_snapshot_mem_list_v2 *)buf; 543: int id, index = 0, ret = 0, num_mem = 0; 544: struct kgsl_process_private *process = priv; 545: struct mem_entry *m = (struct mem_entry *)(buf + sizeof(*header)); 546: struct kgsl_mem_entry *entry; 547: 548: /* we need a process to search! */ 549: if (process == NULL) 550: return 0; 551: 552: spin_lock(&process->mem_lock); 553: 554: /* We need to know the number of memory objects that the process has */ 555: idr_for_each(&process->mem_idr, _count_mem_entries, &num_mem); 556: 557: if (num_mem == 0) 558: goto out; 559: 560: if (remain < ((num_mem * sizeof(struct mem_entry)) + sizeof(*header))) { 561: dev_err(device->dev, 562: "snapshot: Not enough memory for the mem list\n"); 563: goto out; 564: } 565: 566: header->num_entries = num_mem; 567: header->ptbase = kgsl_mmu_pagetable_get_ttbr0(process->pagetable); 568: 569: /* 570: * Walk through the memory list and store the 571: * tuples(gpuaddr, size, memtype) in snapshot 572: */ 573: idr_for_each_entry(&process->mem_idr, entry, id) { 574: m[index].gpuaddr = entry->memdesc.gpuaddr; 575: m[index].size = entry->memdesc.size; 576: m[index].type = kgsl_memdesc_get_memtype(&entry->memdesc); 577: index++; 578: } 579: 580: ret = sizeof(*header) + (num_mem * sizeof(struct mem_entry)); 581: out: 582: spin_unlock(&process->mem_lock); 583: return ret; 584: } 585: 586: static void kgsl_snapshot_add_active_ib_obj_list(struct kgsl_device *device, 587: struct kgsl_snapshot *snapshot) 588: { 589: struct adreno_ib_object_list *ib_obj_list; 590: int index = -ENOENT; 591: 592: if (!snapshot->ib1dumped) 593: index = find_object(snapshot->ib1base, snapshot->process); 594: 595: /* only do this for IB1 because the IB2's are part of IB1 objects */ 596: if ((index != -ENOENT) && 597: (snapshot->ib1base == objbuf[index].gpuaddr)) { 598: if (-E2BIG == adreno_ib_create_object_list(device, 599: objbuf[index].entry->priv, 600: objbuf[index].gpuaddr, 601: objbuf[index].size >> 2, 602: snapshot->ib2base, 603: &ib_obj_list)) 604: ib_max_objs = 1; 605: if (ib_obj_list) { 606: /* freeze the IB objects in the IB */ 607: snapshot_freeze_obj_list(snapshot, 608: objbuf[index].entry->priv, 609: ib_obj_list); 610: adreno_ib_destroy_obj_list(ib_obj_list); 611: } 612: } else { 613: /* Get the IB2 index from parsed object */ 614: index = find_object(snapshot->ib2base, snapshot->process); 615: 616: if (index != -ENOENT) 617: adreno_parse_ib(device, snapshot, snapshot->process, 618: snapshot->ib2base, objbuf[index].size >> 2); 619: } 620: } 621: 622: static void kgsl_snapshot_add_active_lpac_ib_obj_list(struct kgsl_device *device, 623: struct kgsl_snapshot *snapshot) 624: { 625: struct adreno_ib_object_list *ib_obj_list; 626: int index = -ENOENT; 627: 628: if (!snapshot->ib1dumped_lpac) 629: index = find_object(snapshot->ib1base_lpac, snapshot->process_lpac); 630: 631: /* only do this for IB1 because the IB2's are part of IB1 objects */ 632: if ((index != -ENOENT) && 633: (snapshot->ib1base_lpac == objbuf[index].gpuaddr)) { 634: if (-E2BIG == adreno_ib_create_object_list(device, 635: objbuf[index].entry->priv, 636: objbuf[index].gpuaddr, 637: objbuf[index].size >> 2, 638: snapshot->ib2base_lpac, 639: &ib_obj_list)) 640: ib_max_objs = 1; 641: if (ib_obj_list) { 642: /* freeze the IB objects in the IB */ 643: snapshot_freeze_obj_list(snapshot, 644: objbuf[index].entry->priv, 645: ib_obj_list); 646: adreno_ib_destroy_obj_list(ib_obj_list); 647: } 648: } else { 649: /* Get the IB2 index from parsed object */ 650: index = find_object(snapshot->ib2base_lpac, snapshot->process_lpac); 651: 652: if (index != -ENOENT) 653: adreno_parse_ib_lpac(device, snapshot, snapshot->process_lpac, 654: snapshot->ib2base_lpac, objbuf[index].size >> 2); 655: } 656: } 657: 658: /* 659: * active_ib_is_parsed() - Checks if active ib is already parsed 660: * @gpuaddr: Active IB base address at the time of fault 661: * @size: Active IB size 662: * @process: The process to which the IB belongs 663: * 664: * Function returns true if the active is already is parsed 665: * else false 666: */ 667: static bool active_ib_is_parsed(uint64_t gpuaddr, uint64_t size, 668: struct kgsl_process_private *process) 669: { 670: int index; 671: /* go through the static list for gpuaddr is in list or not */ 672: for (index = 0; index < objbufptr; index++) { 673: if ((objbuf[index].gpuaddr <= gpuaddr) && 674: ((objbuf[index].gpuaddr + 675: (objbuf[index].size)) >= 676: (gpuaddr + size)) && 677: (objbuf[index].entry->priv == process)) 678: return true; 679: } 680: return false; 681: } 682: /* Snapshot the memory for an indirect buffer */ 683: static size_t snapshot_ib(struct kgsl_device *device, u8 *buf, 684: size_t remain, void *priv) 685: { 686: struct kgsl_snapshot_ib_v2 *header = (struct kgsl_snapshot_ib_v2 *)buf; 687: struct snapshot_ib_meta *metadata = priv; 688: unsigned int *src; 689: unsigned int *dst = (unsigned int *)(buf + sizeof(*header)); 690: struct adreno_ib_object_list *ib_obj_list; 691: struct kgsl_snapshot *snapshot; 692: struct kgsl_snapshot_object *obj; 693: struct kgsl_memdesc *memdesc; 694: 695: if (metadata == NULL || metadata->snapshot == NULL || metadata->obj == NULL) { 696: dev_err(device->dev, "snapshot: bad metadata\n"); 697: return 0; 698: } 699: snapshot = metadata->snapshot; 700: obj = metadata->obj; 701: memdesc = &obj->entry->memdesc; 702: 703: /* If size is zero get it from the medesc size */ 704: if (!obj->size) 705: obj->size = (memdesc->size - (obj->gpuaddr - memdesc->gpuaddr)); 706: 707: if (remain < (obj->size + sizeof(*header))) { 708: dev_err(device->dev, "snapshot: Not enough memory for the ib\n"); 709: return 0; 710: } 711: 712: src = kgsl_gpuaddr_to_vaddr(memdesc, obj->gpuaddr); 713: if (src == NULL) { 714: dev_err(device->dev, 715: "snapshot: Unable to map GPU memory object 0x%016llX into the kernel\n", 716: obj->gpuaddr); 717: return 0; 718: } 719: 720: /* only do this for IB1 because the IB2's are part of IB1 objects */ 721: if (metadata->ib1base == obj->gpuaddr) { 722: 723: snapshot->ib1dumped = active_ib_is_parsed(obj->gpuaddr, 724: obj->size, obj->entry->priv); 725: if (-E2BIG == adreno_ib_create_object_list(device, 726: obj->entry->priv, 727: obj->gpuaddr, obj->size >> 2, 728: snapshot->ib2base, 729: &ib_obj_list)) 730: ib_max_objs = 1; 731: if (ib_obj_list) { 732: /* freeze the IB objects in the IB */ 733: snapshot_freeze_obj_list(snapshot, 734: obj->entry->priv, 735: ib_obj_list); 736: adreno_ib_destroy_obj_list(ib_obj_list); 737: } 738: } 739: 740: 741: if (metadata->ib2base == obj->gpuaddr) 742: snapshot->ib2dumped = active_ib_is_parsed(obj->gpuaddr, 743: obj->size, obj->entry->priv); 744: 745: if (metadata->ib1base_lpac == obj->gpuaddr) { 746: 747: snapshot->ib1dumped_lpac = active_ib_is_parsed(obj->gpuaddr, 748: obj->size, obj->entry->priv); 749: if (-E2BIG == adreno_ib_create_object_list(device, 750: obj->entry->priv, 751: obj->gpuaddr, obj->size >> 2, 752: snapshot->ib2base_lpac, 753: &ib_obj_list)) 754: ib_max_objs = 1; 755: if (ib_obj_list) { 756: /* freeze the IB objects in the IB */ 757: snapshot_freeze_obj_list(snapshot, 758: obj->entry->priv, 759: ib_obj_list); 760: adreno_ib_destroy_obj_list(ib_obj_list); 761: } 762: } 763: 764: if (metadata->ib2base_lpac == obj->gpuaddr) 765: snapshot->ib2dumped_lpac = active_ib_is_parsed(obj->gpuaddr, 766: obj->size, obj->entry->priv); 767: 768: /* Write the sub-header for the section */ 769: header->gpuaddr = obj->gpuaddr; 770: header->ptbase = 771: kgsl_mmu_pagetable_get_ttbr0(obj->entry->priv->pagetable); 772: header->size = obj->size >> 2; 773: 774: /* Write the contents of the ib */ 775: memcpy((void *)dst, (void *)src, (size_t) obj->size); 776: /* Write the contents of the ib */ 777: 778: return obj->size + sizeof(*header); 779: } 780: 781: /* Dump another item on the current pending list */ 782: static void dump_object(struct kgsl_device *device, int obj, 783: struct kgsl_snapshot *snapshot) 784: { 785: metadata.snapshot = snapshot; 786: metadata.obj = &objbuf[obj]; 787: metadata.ib1base = snapshot->ib1base; 788: metadata.ib1size = snapshot->ib1size; 789: metadata.ib2base = snapshot->ib2base; 790: metadata.ib2size = snapshot->ib2size; 791: metadata.ib3base = snapshot->ib3base; 792: metadata.ib3size = snapshot->ib3size; 793: metadata.ib1base_lpac = snapshot->ib1base_lpac; 794: metadata.ib1size_lpac = snapshot->ib1size_lpac; 795: metadata.ib2base_lpac = snapshot->ib2base_lpac; 796: metadata.ib2size_lpac = snapshot->ib2size_lpac; 797: 798: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_IB_V2, 799: snapshot, snapshot_ib, &metadata); 800: if (objbuf[obj].entry) { 801: kgsl_memdesc_unmap(&(objbuf[obj].entry->memdesc)); 802: kgsl_mem_entry_put(objbuf[obj].entry); 803: } 804: } 805: 806: /* setup_fault process - Find kgsl_process_private struct that caused the fault 807: * 808: * Find the faulting process based what the dispatcher thinks happened and 809: * what the hardware is using for the current pagetable. The process struct 810: * will be used to look up GPU addresses that are encountered while parsing 811: * the GPU state. 812: */ 813: static struct kgsl_process_private *setup_fault_process(struct kgsl_device *device, 814: struct kgsl_snapshot *snapshot, 815: struct kgsl_context *context) 816: { 817: u64 hw_ptbase, proc_ptbase; 818: struct kgsl_process_private *process = context ? context->proc_priv : NULL; 819: 820: if (process != NULL && !kgsl_process_private_get(process)) 821: process = NULL; 822: 823: /* Get the physical address of the MMU pagetable */ 824: hw_ptbase = kgsl_mmu_get_current_ttbr0(&device->mmu, context); 825: 826: /* if we have an input process, make sure the ptbases match */ 827: if (process) { 828: int asid = kgsl_mmu_pagetable_get_asid(process->pagetable, context); 829: 830: proc_ptbase = kgsl_mmu_pagetable_get_ttbr0(process->pagetable); 831: if (asid >= 0) 832: proc_ptbase |= FIELD_PREP(GENMASK_ULL(63, KGSL_IOMMU_ASID_START_BIT), asid); 833: 834: /* agreement! No need to check further */ 835: if (hw_ptbase == proc_ptbase) 836: goto done; 837: 838: kgsl_process_private_put(process); 839: process = NULL; 840: dev_err(device->dev, 841: "snapshot: ptbase mismatch hw %llx sw %llx\n", 842: hw_ptbase, proc_ptbase); 843: } 844: 845: /* try to find the right pagetable by walking the process list */ 846: if (kgsl_mmu_is_perprocess(&device->mmu)) { 847: struct kgsl_process_private *tmp; 848: 849: read_lock(&kgsl_driver.proclist_lock); 850: list_for_each_entry(tmp, &kgsl_driver.process_list, list) { 851: u64 pt_ttbr0; 852: 853: pt_ttbr0 = kgsl_mmu_pagetable_get_ttbr0(tmp->pagetable); 854: if ((pt_ttbr0 == MMU_SW_PT_BASE(hw_ptbase)) 855: && kgsl_process_private_get(tmp)) { 856: process = tmp; 857: break; 858: } 859: } 860: read_unlock(&kgsl_driver.proclist_lock); 861: } 862: done: 863: return process; 864: } 865: 866: /* Snapshot a global memory buffer */ 867: size_t adreno_snapshot_global(struct kgsl_device *device, u8 *buf, 868: size_t remain, void *priv) 869: { 870: struct kgsl_memdesc *memdesc = priv; 871: 872: struct kgsl_snapshot_gpu_object_v2 *header = 873: (struct kgsl_snapshot_gpu_object_v2 *)buf; 874: 875: u8 *ptr = buf + sizeof(*header); 876: 877: if (IS_ERR_OR_NULL(memdesc) || memdesc->size == 0) 878: return 0; 879: 880: if (remain < (memdesc->size + sizeof(*header))) { 881: dev_err(device->dev, 882: "snapshot: Not enough memory for the memdesc\n"); 883: return 0; 884: } 885: 886: if (memdesc->hostptr == NULL) { 887: dev_err(device->dev, 888: "snapshot: no kernel mapping for global object 0x%016llX\n", 889: memdesc->gpuaddr); 890: return 0; 891: } 892: 893: header->size = memdesc->size >> 2; 894: header->gpuaddr = memdesc->gpuaddr; 895: header->ptbase = MMU_DEFAULT_TTBR0(device); 896: header->type = SNAPSHOT_GPU_OBJECT_GLOBAL; 897: 898: memcpy(ptr, memdesc->hostptr, memdesc->size); 899: 900: return memdesc->size + sizeof(*header); 901: } 902: 903: /* Snapshot IOMMU specific buffers */ 904: static void adreno_snapshot_iommu(struct kgsl_device *device, 905: struct kgsl_snapshot *snapshot) 906: { 907: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 908: struct kgsl_iommu *iommu = KGSL_IOMMU(device); 909: 910: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 911: snapshot, adreno_snapshot_global, iommu->setstate); 912: 913: if (adreno_is_preemption_enabled(adreno_dev)) 914: kgsl_snapshot_add_section(device, 915: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 916: snapshot, adreno_snapshot_global, iommu->smmu_info); 917: } 918: 919: static void adreno_snapshot_ringbuffer(struct kgsl_device *device, 920: struct kgsl_snapshot *snapshot, struct adreno_ringbuffer *rb) 921: { 922: struct snapshot_rb_params params = { 923: .snapshot = snapshot, 924: .rb = rb, 925: }; 926: 927: if (rb == NULL) 928: return; 929: 930: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_RB_V2, snapshot, 931: snapshot_rb, ¶ms); 932: } 933: 934: static void adreno_snapshot_os(struct kgsl_device *device, 935: struct kgsl_snapshot *snapshot, struct kgsl_context *guilty, 936: struct kgsl_context *guilty_lpac) 937: { 938: struct kgsl_snapshot_section_header *sect = 939: (struct kgsl_snapshot_section_header *) snapshot->ptr; 940: struct kgsl_snapshot_linux_v4 *header = (struct kgsl_snapshot_linux_v4 *) 941: (snapshot->ptr + sizeof(*sect)); 942: struct kgsl_context *context; 943: u32 remain; 944: void *mem; 945: int id; 946: 947: if (snapshot->remain < (sizeof(*sect) + sizeof(*header))) { 948: SNAPSHOT_ERR_NOMEM(device, "OS"); 949: return; 950: } 951: 952: header->osid = KGSL_SNAPSHOT_OS_LINUX_V4; 953: 954: strscpy(header->release, init_utsname()->release, sizeof(header->release)); 955: strscpy(header->version, init_utsname()->version, sizeof(header->version)); 956: 957: header->seconds = ktime_get_real_seconds(); 958: header->power_flags = device->pwrctrl.power_flags; 959: header->power_level = device->pwrctrl.active_pwrlevel; 960: header->power_interval_timeout = atomic64_read(&device->pwrctrl.interval_timeout); 961: header->grpclk = clk_get_rate(device->pwrctrl.grp_clks[0]); 962: 963: /* Get the current PT base */ 964: header->ptbase = kgsl_mmu_get_current_ttbr0(&device->mmu, guilty); 965: header->ptbase_lpac = kgsl_mmu_get_current_ttbr0(&device->mmu, guilty_lpac); 966: header->ctxtcount = 0; 967: 968: /* If we know the guilty context then dump it */ 969: if (guilty) { 970: header->current_context = guilty->id; 971: header->pid = guilty->tid; 972: strscpy(header->comm, guilty->proc_priv->comm, 973: sizeof(header->comm)); 974: } 975: 976: if (guilty_lpac) { 977: header->current_context_lpac = guilty_lpac->id; 978: header->pid_lpac = guilty_lpac->tid; 979: strscpy(header->comm_lpac, guilty_lpac->proc_priv->comm, 980: sizeof(header->comm_lpac)); 981: } 982: 983: remain = snapshot->remain - sizeof(*sect) + sizeof(*header); 984: mem = snapshot->ptr + sizeof(*sect) + sizeof(*header); 985: 986: read_lock(&device->context_lock); 987: idr_for_each_entry(&device->context_idr, context, id) { 988: struct kgsl_snapshot_linux_context_v2 *c = mem; 989: 990: if (remain < sizeof(*c)) 991: break; 992: 993: kgsl_readtimestamp(device, context, KGSL_TIMESTAMP_QUEUED, 994: &c->timestamp_queued); 995: 996: kgsl_readtimestamp(device, context, KGSL_TIMESTAMP_CONSUMED, 997: &c->timestamp_consumed); 998: 999: kgsl_readtimestamp(device, context, KGSL_TIMESTAMP_RETIRED, 1000: &c->timestamp_retired); 1001: 1002: header->ctxtcount++; 1003: 1004: mem += sizeof(*c); 1005: remain -= sizeof(*c); 1006: } 1007: read_unlock(&device->context_lock); 1008: 1009: sect->magic = SNAPSHOT_SECTION_MAGIC; 1010: sect->id = KGSL_SNAPSHOT_SECTION_OS; 1011: sect->size = sizeof(*sect) + sizeof(*header) + 1012: header->ctxtcount * sizeof(struct kgsl_snapshot_linux_context_v2); 1013: 1014: snapshot->ptr += sect->size; 1015: snapshot->remain -= sect->size; 1016: snapshot->size += sect->size; 1017: } 1018: 1019: static void adreno_static_ib_dump(struct kgsl_device *device, 1020: struct kgsl_process_private *process, u64 ib1base, 1021: u32 ib1size, u64 ib2base, u32 ib2size, 1022: u64 ib3base, u32 ib3size) 1023: { 1024: if (process == NULL) 1025: return; 1026: 1027: /* Make sure that the last IB1 that was being executed is dumped. 1028: * Since this was the last IB1 that was processed, we should have 1029: * already added it to the list during the ringbuffer parse but we 1030: * want to be double plus sure. 1031: * The problem is that IB size from the register is the unprocessed size 1032: * of the buffer not the original size, so if we didn't catch this 1033: * buffer being directly used in the RB, then we might not be able to 1034: * dump the whole thing. Try to dump the maximum possible size from the 1035: * IB1 base address till the end of memdesc size so that we dont miss 1036: * what we are interested in. Print a warning message so we can try to 1037: * figure how often this really happens. 1038: */ 1039: 1040: if (ib1base && (-ENOENT == find_object(ib1base, process))) { 1041: struct kgsl_mem_entry *entry; 1042: u64 ibsize; 1043: 1044: entry = kgsl_sharedmem_find(process, ib1base); 1045: if (entry == NULL) { 1046: dev_err(device->dev, 1047: "Can't find a memory entry containing IB1BASE %16llx\n", 1048: ib1base); 1049: } else { 1050: ibsize = entry->memdesc.size - 1051: (ib1base - entry->memdesc.gpuaddr); 1052: kgsl_mem_entry_put(entry); 1053: 1054: kgsl_snapshot_push_object(device, process, 1055: ib1base, ibsize >> 2); 1056: dev_err(device->dev, 1057: "CP_IB1_BASE %16llx is not found in the ringbuffer. Dumping %llx dwords of the buffer\n", 1058: ib1base, ibsize >> 2); 1059: } 1060: } 1061: 1062: /* 1063: * Add the last parsed IB2 and IB3 to the list. These should be found as we 1064: * parse the objects below, but we try to add them to the list first, so 1065: * they too can be parsed. Don't print an error message in this case - if 1066: * the IB2 and IB3 are found during parsing, the list will be updated with 1067: * the correct size. 1068: */ 1069: if (ib2base && (-ENOENT == find_object(ib2base, process))) 1070: kgsl_snapshot_push_object(device, process, ib2base, ib2size); 1071: 1072: if (ib3base && (-ENOENT == find_object(ib3base, process))) 1073: kgsl_snapshot_push_object(device, process, ib3base, ib3size); 1074: } 1075: 1076: /** 1077: * adreno_snapshot_sqe - Dump the SQE firmware version and few dwords 1078: * @device: Pointer to the kgsl device 1079: * @buf: Pointer to the snapshot buffer 1080: * @remain: Remaining size in snapshot buffer 1081: * @priv: Private pointer to pass to the function 1082: * 1083: * Return: Number of bytes written to the snapshot buffer 1084: */ 1085: static size_t adreno_snapshot_sqe(struct kgsl_device *device, u8 *buf, 1086: size_t remain, void *priv) 1087: { 1088: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1089: struct kgsl_snapshot_debug *header = (struct kgsl_snapshot_debug *)buf; 1090: void *data = buf + sizeof(*header); 1091: struct adreno_firmware *fw = ADRENO_FW(adreno_dev, ADRENO_FW_SQE); 1092: 1093: if (remain < DEBUG_SECTION_SZ(SQE_FW_SNAPSHOT_DWORDS)) { 1094: SNAPSHOT_ERR_NOMEM(device, "SQE VERSION DEBUG"); 1095: return 0; 1096: } 1097: 1098: /* Dump the SQE firmware version and few dwords */ 1099: header->type = SNAPSHOT_DEBUG_SQE_VERSION; 1100: header->size = SQE_FW_SNAPSHOT_DWORDS; 1101: memcpy(data, fw->memdesc->hostptr, (SQE_FW_SNAPSHOT_DWORDS * sizeof(u32))); 1102: 1103: return DEBUG_SECTION_SZ(SQE_FW_SNAPSHOT_DWORDS); 1104: } 1105: 1106: /* adreno_snapshot_aqe() - Dump AQE data in snapshot */ 1107: static size_t adreno_snapshot_aqe(struct kgsl_device *device, u8 *buf, 1108: size_t remain, void *priv) 1109: { 1110: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1111: struct kgsl_snapshot_debug *header = (struct kgsl_snapshot_debug *)buf; 1112: u32 *data = (u32 *)(buf + sizeof(*header)); 1113: struct adreno_firmware *fw = ADRENO_FW(adreno_dev, ADRENO_FW_AQE); 1114: 1115: /* 1116: * AQE firmware memory is allocated in the hwsched path. 1117: * In swsched path, the address is NULL, so add a check 1118: * to avoid NULL pointer dereference. 1119: */ 1120: if ((!ADRENO_FEATURE(adreno_dev, ADRENO_AQE)) || (fw->memdesc == NULL)) 1121: return 0; 1122: 1123: if (remain < DEBUG_SECTION_SZ(AQE_FW_SNAPSHOT_DWORDS)) { 1124: SNAPSHOT_ERR_NOMEM(device, "AQE VERSION DEBUG"); 1125: return 0; 1126: } 1127: 1128: /* Dump the AQE firmware version and few dwords */ 1129: header->type = SNAPSHOT_DEBUG_AQE_VERSION; 1130: header->size = AQE_FW_SNAPSHOT_DWORDS; 1131: memcpy(data, fw->memdesc->hostptr, AQE_FW_SNAPSHOT_DWORDS * sizeof(u32)); 1132: 1133: return DEBUG_SECTION_SZ(AQE_FW_SNAPSHOT_DWORDS); 1134: } 1135: 1136: static void adreno_snapshot_firmware(struct kgsl_device *device, 1137: struct kgsl_snapshot *snapshot) 1138: { 1139: 1140: /* Dump SQE firmware version and few dwords */ 1141: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_DEBUG, 1142: snapshot, adreno_snapshot_sqe, NULL); 1143: 1144: /* Dump AQE firmware version */ 1145: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_DEBUG, 1146: snapshot, adreno_snapshot_aqe, NULL); 1147: } 1148: 1149: /* adreno_snapshot - Snapshot the Adreno GPU state 1150: * @device - KGSL device to snapshot 1151: * @snapshot - Pointer to the snapshot instance 1152: * @context - context that caused the fault, if known by the driver 1153: * This is a hook function called by kgsl_snapshot to snapshot the 1154: * Adreno specific information for the GPU snapshot. In turn, this function 1155: * calls the GPU specific snapshot function to get core specific information. 1156: */ 1157: void adreno_snapshot(struct kgsl_device *device, struct kgsl_snapshot *snapshot, 1158: struct kgsl_context *context, struct kgsl_context *context_lpac) 1159: { 1160: unsigned int i; 1161: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1162: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 1163: struct kgsl_snapshot_header *header = (struct kgsl_snapshot_header *) 1164: snapshot->ptr; 1165: 1166: /* Set up the master header */ 1167: header->magic = SNAPSHOT_MAGIC; 1168: /* gpuid is deprecated so initialize it to an obviously wrong value */ 1169: header->gpuid = UINT_MAX; 1170: header->chipid = adreno_dev->chipid; 1171: 1172: snapshot->ptr += sizeof(*header); 1173: snapshot->remain -= sizeof(*header); 1174: snapshot->size += sizeof(*header); 1175: 1176: /* Write the OS section */ 1177: adreno_snapshot_os(device, snapshot, context, context_lpac); 1178: 1179: ib_max_objs = 0; 1180: /* Reset the list of objects */ 1181: objbufptr = 0; 1182: 1183: snapshot_frozen_objsize = 0; 1184: 1185: snapshot->process = setup_fault_process(device, snapshot, context); 1186: if (context_lpac) 1187: snapshot->process_lpac = setup_fault_process(device, snapshot, context_lpac); 1188: 1189: /* Dump firmware version and few dwords */ 1190: adreno_snapshot_firmware(device, snapshot); 1191: 1192: /* Add GPU specific sections - registers mainly, but other stuff too */ 1193: if (gpudev->snapshot) 1194: gpudev->snapshot(adreno_dev, snapshot); 1195: 1196: snapshot->ib1dumped = false; 1197: snapshot->ib2dumped = false; 1198: snapshot->ib1dumped_lpac = false; 1199: snapshot->ib2dumped_lpac = false; 1200: 1201: adreno_snapshot_ringbuffer(device, snapshot, adreno_dev->cur_rb); 1202: 1203: /* Dump the prev ringbuffer */ 1204: if (adreno_dev->prev_rb != adreno_dev->cur_rb) 1205: adreno_snapshot_ringbuffer(device, snapshot, 1206: adreno_dev->prev_rb); 1207: 1208: if ((adreno_dev->next_rb != adreno_dev->prev_rb) && 1209: (adreno_dev->next_rb != adreno_dev->cur_rb)) 1210: adreno_snapshot_ringbuffer(device, snapshot, 1211: adreno_dev->next_rb); 1212: 1213: if (device->snapshot_atomic) 1214: return; 1215: 1216: /* Dump selected global buffers */ 1217: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 1218: snapshot, adreno_snapshot_global, device->memstore); 1219: 1220: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 1221: snapshot, adreno_snapshot_global, device->scratch); 1222: 1223: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 1224: snapshot, adreno_snapshot_global, 1225: adreno_dev->pwron_fixup); 1226: 1227: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 1228: snapshot, adreno_snapshot_global, 1229: adreno_dev->profile_buffer); 1230: 1231: if (kgsl_mmu_get_mmutype(device) == KGSL_MMU_TYPE_IOMMU) 1232: adreno_snapshot_iommu(device, snapshot); 1233: 1234: /* 1235: * Add a section that lists (gpuaddr, size, memtype) tuples of the 1236: * hanging process 1237: */ 1238: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_MEMLIST_V2, 1239: snapshot, snapshot_capture_mem_list, snapshot->process); 1240: 1241: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_MEMLIST_V2, 1242: snapshot, snapshot_capture_mem_list, snapshot->process_lpac); 1243: 1244: adreno_static_ib_dump(device, snapshot->process, 1245: snapshot->ib1base, snapshot->ib1size, snapshot->ib2base, snapshot->ib2size, 1246: snapshot->ib3base, snapshot->ib3size); 1247: 1248: adreno_static_ib_dump(device, snapshot->process_lpac, 1249: snapshot->ib1base_lpac, snapshot->ib1size_lpac, 1250: snapshot->ib2base_lpac, snapshot->ib2size_lpac, 0, 0); 1251: /* 1252: * Go through the list of found objects and dump each one. As the IBs 1253: * are parsed, more objects might be found, and objbufptr will increase 1254: */ 1255: for (i = 0; i < objbufptr; i++) 1256: dump_object(device, i, snapshot); 1257: 1258: /* 1259: * Incase snapshot static blob is running out of memory, Add Active IB1 1260: * and IB2 entries to obj_list so that active ib's can be dumped to 1261: * snapshot dynamic blob. 1262: */ 1263: if (!snapshot->ib1dumped || !snapshot->ib2dumped) 1264: kgsl_snapshot_add_active_ib_obj_list(device, snapshot); 1265: 1266: if (ib_max_objs) 1267: dev_err(device->dev, "Max objects found in GC IB\n"); 1268: 1269: if (!snapshot->ib1dumped_lpac || !snapshot->ib2dumped_lpac) 1270: kgsl_snapshot_add_active_lpac_ib_obj_list(device, snapshot); 1271: 1272: if (ib_max_objs) 1273: dev_err(device->dev, "Max objects found in LPAC IB\n"); 1274: 1275: if (snapshot_frozen_objsize) 1276: dev_err(device->dev, 1277: "GPU snapshot froze %zdKb of GPU buffers\n", 1278: snapshot_frozen_objsize / 1024); 1279: 1280: } 1281: 1282: void adreno_snapshot_registers(struct kgsl_device *device, 1283: struct kgsl_snapshot *snapshot, 1284: const unsigned int *regs, unsigned int count) 1285: { 1286: struct kgsl_snapshot_registers r; 1287: 1288: r.regs = regs; 1289: r.count = count; 1290: 1291: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS, snapshot, 1292: kgsl_snapshot_dump_registers, &r); 1293: } 1294: 1295: int adreno_snapshot_regs_count(const u32 *ptr) 1296: { 1297: unsigned int count = 0; 1298: unsigned int group_count; 1299: 1300: for ( ; ptr[0] != UINT_MAX; ptr += 2) { 1301: group_count = REG_COUNT(ptr); 1302: if (group_count == 1) 1303: count += group_count + 1; 1304: else 1305: count += group_count + 2; 1306: } 1307: return count; 1308: } 1309: 1310: /* 1311: * This is a new format for dumping the registers, where we dump just the first 1312: * address of the register along with the count of the contiguous registers 1313: * which we going to dump. This helps us save memory by not dumping the 1314: * address for each register 1315: */ 1316: size_t adreno_snapshot_registers_v2(struct kgsl_device *device, u8 *buf, 1317: size_t remain, void *priv) 1318: { 1319: const u32 *ptr = (const u32 *)priv; 1320: unsigned int *data = (unsigned int *)buf; 1321: int count = 0, k; 1322: 1323: /* Figure out how many registers we are going to dump */ 1324: count = adreno_snapshot_regs_count(ptr); 1325: 1326: if (remain < (count * 4)) { 1327: SNAPSHOT_ERR_NOMEM(device, "REGISTERS"); 1328: return 0; 1329: } 1330: 1331: for (ptr = (const u32 *)priv; ptr[0] != UINT_MAX; ptr += 2) { 1332: int cnt = REG_COUNT(ptr); 1333: 1334: if (cnt == 1) 1335: *data++ = BIT(31) | ptr[0]; 1336: else { 1337: *data++ = ptr[0]; 1338: *data++ = cnt; 1339: } 1340: for (k = ptr[0]; k <= ptr[1]; k++) { 1341: kgsl_regread(device, k, data); 1342: data++; 1343: } 1344: } 1345: 1346: /* Return the size of the section */ 1347: return (count * 4); 1348: } 1349: 1350: static size_t snapshot_gmu_version(struct kgsl_device *device, 1351: u8 *buf, size_t remain, void *priv) 1352: { 1353: struct kgsl_snapshot_debug *header = (struct kgsl_snapshot_debug *)buf; 1354: u32 *data = (u32 *) (buf + sizeof(*header)); 1355: struct kgsl_snapshot_gmu_version *ver = priv; 1356: 1357: if (remain < DEBUG_SECTION_SZ(1)) { 1358: SNAPSHOT_ERR_NOMEM(device, "GMU Version"); 1359: return 0; 1360: } 1361: 1362: header->type = ver->type; 1363: header->size = 1; 1364: 1365: *data = ver->value; 1366: 1367: return DEBUG_SECTION_SZ(1); 1368: } 1369: 1370: void adreno_snapshot_gmu_versions(struct kgsl_device *device, 1371: struct kgsl_snapshot *snapshot) 1372: { 1373: int i; 1374: struct gmu_core_device *gmu = &device->gmu_core; 1375: struct kgsl_snapshot_gmu_version gmu_vers[] = { 1376: { .type = SNAPSHOT_DEBUG_GMU_CORE_VERSION, 1377: .value = gmu->ver.core, }, 1378: { .type = SNAPSHOT_DEBUG_GMU_CORE_DEV_VERSION, 1379: .value = gmu->ver.core_dev, }, 1380: { .type = SNAPSHOT_DEBUG_GMU_PWR_VERSION, 1381: .value = gmu->ver.pwr, }, 1382: { .type = SNAPSHOT_DEBUG_GMU_PWR_DEV_VERSION, 1383: .value = gmu->ver.pwr_dev, }, 1384: { .type = SNAPSHOT_DEBUG_GMU_HFI_VERSION, 1385: .value = gmu->ver.hfi, }, 1386: }; 1387: 1388: for (i = 0; i < ARRAY_SIZE(gmu_vers); i++) 1389: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_DEBUG, 1390: snapshot, snapshot_gmu_version, &gmu_vers[i]); 1391: } 1392: 1393: size_t adreno_snapshot_gmu_mem(struct kgsl_device *device, 1394: u8 *buf, size_t remain, void *priv) 1395: { 1396: struct kgsl_snapshot_gmu_mem *mem_hdr = 1397: (struct kgsl_snapshot_gmu_mem *)buf; 1398: void *data = buf + sizeof(*mem_hdr); 1399: struct gmu_mem_type_desc *desc = priv; 1400: 1401: if (priv == NULL || desc->memdesc->hostptr == NULL) 1402: return 0; 1403: 1404: if (remain < desc->memdesc->size + sizeof(*mem_hdr)) { 1405: dev_err(device->dev, 1406: "snapshot: Not enough memory for the gmu section %d\n", 1407: desc->type); 1408: return 0; 1409: } 1410: 1411: mem_hdr->type = desc->type; 1412: mem_hdr->hostaddr = 0; 1413: mem_hdr->gmuaddr = desc->memdesc->gmuaddr; 1414: mem_hdr->gpuaddr = 0; 1415: 1416: /* The hw fence queues are mapped as iomem in the kernel */ 1417: if (desc->type == SNAPSHOT_GMU_MEM_HW_FENCE) 1418: memcpy_fromio(data, desc->memdesc->hostptr, desc->memdesc->size); 1419: else 1420: memcpy(data, desc->memdesc->hostptr, desc->memdesc->size); 1421: 1422: return desc->memdesc->size + sizeof(*mem_hdr); 1423: } 1424: 1425: /* Snapshot the preemption related buffers */ 1426: static size_t snapshot_preemption_record(struct kgsl_device *device, 1427: u8 *buf, size_t remain, void *priv) 1428: { 1429: struct kgsl_memdesc *memdesc = priv; 1430: struct kgsl_snapshot_gpu_object_v2 *header = 1431: (struct kgsl_snapshot_gpu_object_v2 *)buf; 1432: u8 *ptr = buf + sizeof(*header); 1433: u64 ctxt_record_size = min_t(u64, device->snapshot_ctxt_record_size, memdesc->size); 1434: 1435: if (remain < (ctxt_record_size + sizeof(*header))) { 1436: SNAPSHOT_ERR_NOMEM(device, "PREEMPTION RECORD"); 1437: return 0; 1438: } 1439: 1440: header->size = ctxt_record_size >> 2; 1441: header->gpuaddr = memdesc->gpuaddr; 1442: header->ptbase = 1443: kgsl_mmu_pagetable_get_ttbr0(device->mmu.defaultpagetable); 1444: header->type = SNAPSHOT_GPU_OBJECT_GLOBAL; 1445: 1446: memcpy(ptr, memdesc->hostptr, ctxt_record_size); 1447: 1448: return ctxt_record_size + sizeof(*header); 1449: } 1450: 1451: void adreno_snapshot_preemption_record(struct kgsl_device *device, 1452: struct kgsl_snapshot *snapshot) 1453: { 1454: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1455: struct adreno_ringbuffer *rb; 1456: u32 i; 1457: 1458: if (adreno_is_preemption_enabled(adreno_dev)) { 1459: FOR_EACH_RINGBUFFER(adreno_dev, rb, i) { 1460: kgsl_snapshot_add_section(device, 1461: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 1462: snapshot, snapshot_preemption_record, 1463: rb->preemption_desc); 1464: } 1465: } 1466: } --- FILE: \adreno_snapshot.h | HITS: 61 --- MATCH LINES: 6, 7, 9, 10, 12, 13, 14, 15, 20, 23, 24, 29, 30, 31, 44, 46, 47, 51, 60, 63, 65, 66, 69, 73, 75, 79, 81, 82, 85, 89, 91, 97, 103, 108, 115, 121, 126, 131, 134, 137, 139, 143, 146, 150, 152, 155, 157, 159, 161, 162, 165, 167, 168, 171, 173, 177, 179, 181, 183, 184, 186 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) 2013-2015,2020-2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: #ifndef __ADRENO_SNAPSHOT_H 7: #define __ADRENO_SNAPSHOT_H 8: 9: #include "adreno_hwsched_snapshot.h" 10: #include "kgsl_snapshot.h" 11: 12: /* Number of dwords to dump in snapshot for CP SQE */ 13: #define SQE_FW_SNAPSHOT_DWORDS 5 14: /* Number of dwords to dump in snapshot for CP AQE */ 15: #define AQE_FW_SNAPSHOT_DWORDS 6 16: 17: #define CP_CRASH_DUMPER_TIMEOUT 500 18: 19: #define SHADER_SECTION_SZ(_dwords) (((_dwords) * sizeof(unsigned int)) \ 20: + sizeof(struct kgsl_snapshot_shader)) 21: 22: /* Macro to make it super easy to dump registers */ 23: #define SNAPSHOT_REGISTERS(_d, _s, _r) \ 24: adreno_snapshot_registers((_d), (_s), \ 25: (unsigned int *) _r, ARRAY_SIZE(_r) / 2) 26: 27: #define REG_COUNT(_ptr) ((_ptr[1] - _ptr[0]) + 1) 28: 29: struct snapshot_ib_meta { 30: struct kgsl_snapshot *snapshot; 31: struct kgsl_snapshot_object *obj; 32: u64 ib1base; 33: u64 ib1size; 34: u64 ib2base; 35: u64 ib2size; 36: u64 ib3base; 37: u64 ib3size; 38: u64 ib1base_lpac; 39: u64 ib1size_lpac; 40: u64 ib2base_lpac; 41: u64 ib2size_lpac; 42: }; 43: 44: extern struct snapshot_ib_meta metadata; 45: 46: void adreno_snapshot_registers(struct kgsl_device *device, 47: struct kgsl_snapshot *snapshot, 48: const unsigned int *regs, unsigned int count); 49: 50: /** 51: * adreno_snapshot_regs_count - Helper function to calculate register and 52: * header size 53: * @ptr: Pointer to the register array 54: * 55: * Return: Number of registers in the array 56: * 57: * Helper function to count the total number of regsiters 58: * in a given array plus the header space needed for each group. 59: */ 60: int adreno_snapshot_regs_count(const u32 *ptr); 61: 62: /** 63: * adreno_snapshot_registers_v2 - Dump a series of registers 64: * @device: Pointer to the kgsl device 65: * @buf: The snapshot buffer 66: * @remain: The size remaining in the snapshot buffer 67: * @priv: Pointer to the register array to be dumped 68: * 69: * Return: Number of bytes written to the snapshot 70: * 71: * This function dumps the registers in a way that we need to 72: * only dump the start address and count for each pair of register 73: * in the array. This helps us save some memory in snapshot. 74: */ 75: size_t adreno_snapshot_registers_v2(struct kgsl_device *device, 76: u8 *buf, size_t remain, void *priv); 77: 78: /** 79: * adreno_snapshot_registers_v2 - Dump a series of CX_MISC registers 80: * @device: Pointer to the kgsl device 81: * @buf: The snapshot buffer 82: * @remain: The size remaining in the snapshot buffer 83: * @priv: Pointer to the CX_MISC register array to be dumped 84: * 85: * Return: Number of bytes written to the snapshot 86: * 87: * This function dumps the CX_MISC registers in a way that we need to 88: * only dump the start address and count for each pair of register 89: * in the array. This helps us save some memory in snapshot. 90: */ 91: size_t adreno_snapshot_cx_misc_registers(struct kgsl_device *device, 92: u8 *buf, size_t remain, void *priv); 93: 94: /** 95: * adreno_parse_ib - Parse the given IB 96: * @device: Pointer to the kgsl device 97: * @snapshot: Pointer to the snapshot structure 98: * @process: Process to which this IB belongs 99: * @gpuaddr: Gpu address of the IB 100: * @dwords: Size in dwords of the IB 101: * 102: * We want to store the last executed IB1 and IB2 in the static region to ensure 103: * that we get at least some information out of the snapshot even if we can't 104: * access the dynamic data from the sysfs file. Push all other IBs on the 105: * dynamic list 106: */ 107: void adreno_parse_ib(struct kgsl_device *device, 108: struct kgsl_snapshot *snapshot, 109: struct kgsl_process_private *process, 110: u64 gpuaddr, u64 dwords); 111: 112: /** 113: * adreno_parse_ib_lpac - Parse the given LPAC IB 114: * @device: Pointer to the kgsl device 115: * @snapshot: Pointer to the snapshot structure 116: * @process: Process to which this LPAC IB belongs 117: * @gpuaddr: Gpu address of the LPAC IB 118: * @dwords: Size in dwords of the LPAC IB 119: * 120: * We want to store the last executed LPAC IB1 and IB2 in the static region to ensure 121: * that we get at least some information out of the snapshot even if we can't 122: * access the dynamic data from the sysfs file. Push all other IBs on the 123: * dynamic list 124: */ 125: void adreno_parse_ib_lpac(struct kgsl_device *device, 126: struct kgsl_snapshot *snapshot, 127: struct kgsl_process_private *process, 128: u64 gpuaddr, u64 dwords); 129: 130: /** 131: * adreno_snapshot_global - Add global buffer to snapshot 132: * @device: Pointer to the kgsl device 133: * @buf: Where the global buffer section is to be written 134: * @remain: Remaining bytes in snapshot buffer 135: * @priv: Opaque data 136: * 137: * Return: Number of bytes written to the snapshot buffer 138: */ 139: size_t adreno_snapshot_global(struct kgsl_device *device, u8 *buf, 140: size_t remain, void *priv); 141: 142: /** 143: * adreno_snapshot_dump_all_ibs - To dump all ibs from ringbuffer 144: * @device: Pointer to the kgsl device 145: * @rbptr: Ringbuffer host pointer 146: * @snapshot: Pointer to the snapshot structure 147: * 148: * Parse all IBs from the ringbuffer and add to IB dump list. 149: */ 150: void adreno_snapshot_dump_all_ibs(struct kgsl_device *device, 151: unsigned int *rbptr, 152: struct kgsl_snapshot *snapshot); 153: 154: /** 155: * adreno_snapshot_gmu_versions - To dump gmu versions info to snapshot buffer 156: * @device: Pointer to the kgsl device 157: * @snapshot: Pointer to the snapshot structure 158: * 159: * Dump gmu versions info to the snapshot buffer. 160: */ 161: void adreno_snapshot_gmu_versions(struct kgsl_device *device, 162: struct kgsl_snapshot *snapshot); 163: 164: /** 165: * kgsl_snapshot_gmu_mem - Snapshot a GMU memory descriptor 166: * @device: Pointer to the kgsl device 167: * @buf: Destination snapshot buffer 168: * @remain: Remaining size of the snapshot buffer 169: * @priv: Opaque handle 170: * 171: * Return: Number of bytes written to snapshot buffer 172: */ 173: size_t adreno_snapshot_gmu_mem(struct kgsl_device *device, 174: u8 *buf, size_t remain, void *priv); 175: 176: /** 177: * adreno_snapshot_preemption_record - To dump preemption related buffers 178: * @device: Pointer to the kgsl device 179: * @snapshot: Pointer to the snapshot structure 180: * 181: * Snapshot the preemption related buffers . 182: */ 183: void adreno_snapshot_preemption_record(struct kgsl_device *device, 184: struct kgsl_snapshot *snapshot); 185: 186: #endif /*__ADRENO_SNAPSHOT_H */ --- FILE: \adreno_sysfs.c | HITS: 6 --- MATCH LINES: 63, 70, 73, 84 51: static int _ft_policy_store(struct adreno_device *adreno_dev, 52: unsigned int val) 53: { 54: adreno_dev->ft_policy = val & KGSL_FT_POLICY_MASK; 55: return 0; 56: } 57: 58: static unsigned int _ft_policy_show(struct adreno_device *adreno_dev) 59: { 60: return adreno_dev->ft_policy; 61: } 62: 63: static int _ft_pagefault_policy_store(struct adreno_device *adreno_dev, 64: unsigned int val) 65: { 66: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 67: int ret = 0; 68: 69: kgsl_mutex_lock(&device->mutex); 70: val &= KGSL_FT_PAGEFAULT_MASK; 71: 72: if (device->state == KGSL_STATE_ACTIVE) 73: ret = kgsl_mmu_set_pagefault_policy(&device->mmu, 74: (unsigned long) val); 75: 76: if (ret == 0) 77: device->mmu.pfpolicy = val; 78: 79: kgsl_mutex_unlock(&device->mutex); 80: 81: return 0; 82: } 83: 84: static unsigned int _ft_pagefault_policy_show(struct adreno_device *adreno_dev) 85: { 86: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 87: 88: return device->mmu.pfpolicy; 89: } 90: 91: static int _rt_bus_hint_store(struct adreno_device *adreno_dev, u32 val) 92: { 93: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 94: struct kgsl_pwrctrl *pwrctrl = &device->pwrctrl; 95: 96: if (!ADRENO_FEATURE(adreno_dev, ADRENO_RT_HINT) || 97: val == pwrctrl->rt_bus_hint) 98: return 0; 99: 100: if (val > pwrctrl->pwrlevels[0].bus_max) 101: val = 0; 102: 103: adreno_power_cycle_u32(adreno_dev, &pwrctrl->rt_bus_hint, val); 104: 105: return 0; 106: } 107: 108: static u32 _rt_bus_hint_show(struct adreno_device *adreno_dev) MATCH LINES: 653 641: adreno_dev->dcvs_profile_enabled == val) 642: return 0; 643: 644: return adreno_power_cycle_bool(adreno_dev, &adreno_dev->dcvs_profile_enabled, val); 645: } 646: 647: static bool _dcvs_profile_enabled_show(struct adreno_device *adreno_dev) 648: { 649: return adreno_dev->dcvs_profile_enabled; 650: } 651: 652: static ADRENO_SYSFS_U32(ft_policy); 653: static ADRENO_SYSFS_U32(ft_pagefault_policy); 654: static ADRENO_SYSFS_U32(rt_bus_hint); 655: static ADRENO_SYSFS_U32(rt_pwrlevel_hint); 656: static ADRENO_SYSFS_RO_BOOL(ft_hang_intr_status); 657: static ADRENO_SYSFS_BOOL(gpu_llc_slice_enable); 658: static ADRENO_SYSFS_BOOL(gpuhtw_llc_slice_enable); 659: static ADRENO_SYSFS_BOOL(gpumv_llc_slice_enable); 660: 661: static DEVICE_INT_ATTR(wake_nice, 0644, adreno_wake_nice); 662: static DEVICE_INT_ATTR(wake_timeout, 0644, adreno_wake_timeout); 663: 664: static ADRENO_SYSFS_BOOL(sptp_pc); 665: static ADRENO_SYSFS_BOOL(lm); 666: static ADRENO_SYSFS_BOOL(hwcg); 667: static ADRENO_SYSFS_BOOL(throttling); 668: static ADRENO_SYSFS_BOOL(ifpc); 669: static ADRENO_SYSFS_RO_U32(ifpc_count); 670: static ADRENO_SYSFS_BOOL(acd); 671: static ADRENO_SYSFS_BOOL(bcl); 672: static ADRENO_SYSFS_BOOL(clx); 673: static ADRENO_SYSFS_BOOL(l3_vote); 674: static ADRENO_SYSFS_BOOL(perfcounter); 675: static ADRENO_SYSFS_BOOL(lpac); 676: static ADRENO_SYSFS_BOOL(dms); 677: static ADRENO_SYSFS_BOOL(touch_wake); MATCH LINES: 692 680: 681: static DEVICE_ATTR_RO(gpu_model); 682: static DEVICE_ATTR_RO(gpufaults); 683: static DEVICE_ATTR_RO(gpufault_procs); 684: 685: static ADRENO_SYSFS_U32(dcvs_tuning_mingap); 686: static ADRENO_SYSFS_U32(dcvs_tuning_penalty); 687: static ADRENO_SYSFS_U32(dcvs_tuning_numbusy); 688: static ADRENO_SYSFS_RO_U32(dcvs_mode); 689: 690: static const struct attribute *_attr_list[] = { 691: &adreno_attr_ft_policy.attr.attr, 692: &adreno_attr_ft_pagefault_policy.attr.attr, 693: &adreno_attr_rt_bus_hint.attr.attr, 694: &adreno_attr_rt_pwrlevel_hint.attr.attr, 695: &adreno_attr_ft_hang_intr_status.attr.attr, 696: &dev_attr_wake_nice.attr.attr, 697: &dev_attr_wake_timeout.attr.attr, 698: &adreno_attr_sptp_pc.attr.attr, 699: &adreno_attr_lm.attr.attr, 700: &adreno_attr_hwcg.attr.attr, 701: &adreno_attr_throttling.attr.attr, 702: &adreno_attr_gpu_llc_slice_enable.attr.attr, 703: &adreno_attr_gpuhtw_llc_slice_enable.attr.attr, 704: &adreno_attr_gpumv_llc_slice_enable.attr.attr, 705: &adreno_attr_ifpc.attr.attr, 706: &adreno_attr_ifpc_count.attr.attr, 707: &adreno_attr_acd.attr.attr, 708: &adreno_attr_bcl.attr.attr, 709: &dev_attr_gpu_model.attr, 710: &adreno_attr_l3_vote.attr.attr, 711: &adreno_attr_perfcounter.attr.attr, 712: &adreno_attr_lpac.attr.attr, 713: &adreno_attr_dms.attr.attr, 714: &adreno_attr_touch_wake.attr.attr, 715: &adreno_attr_gmu_ab.attr.attr, 716: &adreno_attr_clx.attr.attr, --- FILE: \adreno_trace.h | HITS: 11 --- MATCH LINES: 241, 242, 247, 256, 266, 282, 285, 286 229: __entry->inflight, 230: __entry->flags ? __print_flags(__entry->flags, "|", 231: KGSL_DRAWOBJ_FLAGS) : "none", 232: __entry->ticks, __entry->secs, __entry->usecs, 233: __entry->rb_id, __entry->rptr, __entry->wptr, 234: __entry->q_inflight, __entry->dispatch_queue 235: ) 236: ); 237: 238: TRACE_EVENT(adreno_cmdbatch_retired, 239: TP_PROTO(struct kgsl_context *context, struct retire_info *info, 240: unsigned int flags, int q_inflight, 241: unsigned long fault_recovery), 242: TP_ARGS(context, info, flags, q_inflight, fault_recovery), 243: TP_STRUCT__entry( 244: __field(unsigned int, id) 245: __field(unsigned int, timestamp) 246: __field(int, inflight) 247: __field(unsigned int, recovery) 248: __field(unsigned int, flags) 249: __field(uint64_t, start) 250: __field(uint64_t, retire) 251: __field(int, prio) 252: __field(int, rb_id) 253: __field(unsigned int, rptr) 254: __field(unsigned int, wptr) 255: __field(int, q_inflight) 256: __field(unsigned long, fault_recovery) 257: __field(unsigned int, dispatch_queue) 258: __field(uint64_t, submitted_to_rb) 259: __field(uint64_t, retired_on_gmu) 260: __field(uint64_t, active) 261: ), 262: TP_fast_assign( 263: __entry->id = context->id; 264: __entry->timestamp = info->timestamp; 265: __entry->inflight = info->inflight; 266: __entry->recovery = fault_recovery; 267: __entry->flags = flags; 268: __entry->start = info->sop; 269: __entry->retire = info->eop; 270: __entry->prio = context->priority; 271: __entry->rb_id = info->rb_id; 272: __entry->rptr = info->rptr; 273: __entry->wptr = info->wptr; 274: __entry->q_inflight = q_inflight; 275: __entry->dispatch_queue = info->gmu_dispatch_queue; 276: __entry->submitted_to_rb = info->submitted_to_rb; 277: __entry->retired_on_gmu = info->retired_on_gmu; 278: __entry->active = info->active; 279: ), 280: 281: TP_printk( 282: "ctx=%u ctx_prio=%d ts=%u inflight=%d recovery=%s flags=%s start=%llu retire=%llu rb_id=%d, r/w=%x/%x, q_inflight=%d, dq_id=%u, submitted_to_rb=%llu retired_on_gmu=%llu active=%llu", 283: __entry->id, __entry->prio, __entry->timestamp, 284: __entry->inflight, 285: __entry->recovery ? 286: __print_flags(__entry->fault_recovery, "|", 287: ADRENO_FT_TYPES) : "none", 288: __entry->flags ? __print_flags(__entry->flags, "|", 289: KGSL_DRAWOBJ_FLAGS) : "none", 290: __entry->start, 291: __entry->retire, 292: __entry->rb_id, __entry->rptr, __entry->wptr, 293: __entry->q_inflight, 294: __entry->dispatch_queue, 295: __entry->submitted_to_rb, __entry->retired_on_gmu, 296: __entry->active 297: ) 298: ); 299: 300: TRACE_EVENT(gmu_ao_sync, 301: TP_PROTO(u64 ticks), 302: TP_ARGS(ticks), 303: TP_STRUCT__entry( 304: __field(u64, ticks) 305: ), 306: TP_fast_assign( 307: __entry->ticks = ticks; 308: ), 309: TP_printk( 310: "ticks=%llu", __entry->ticks MATCH LINES: 425 413: ), 414: TP_printk( 415: "ctx=%u ts=%u type=%s", 416: __entry->id, __entry->timestamp, 417: __print_symbolic(__entry->fault, 418: { 0, "none" }, 419: { ADRENO_SOFT_FAULT, "soft" }, 420: { ADRENO_HARD_FAULT, "hard" }, 421: { ADRENO_TIMEOUT_FAULT, "timeout" }) 422: ) 423: ); 424: 425: TRACE_EVENT(adreno_cmdbatch_recovery, 426: TP_PROTO(struct kgsl_drawobj_cmd *cmdobj, unsigned int action), 427: TP_ARGS(cmdobj, action), 428: TP_STRUCT__entry( 429: __field(unsigned int, id) 430: __field(unsigned int, timestamp) 431: __field(unsigned int, action) 432: ), 433: TP_fast_assign( 434: __entry->id = cmdobj->base.context->id; 435: __entry->timestamp = cmdobj->base.timestamp; 436: __entry->action = action; 437: ), 438: TP_printk( 439: "ctx=%u ts=%u action=%s", 440: __entry->id, __entry->timestamp, 441: __print_symbolic(__entry->action, ADRENO_FT_TYPES) 442: ) 443: ); 444: 445: DECLARE_EVENT_CLASS(adreno_drawctxt_template, 446: TP_PROTO(struct adreno_context *drawctxt), 447: TP_ARGS(drawctxt), 448: TP_STRUCT__entry( 449: __field(unsigned int, id) MATCH LINES: 542 530: TP_fast_assign( 531: __entry->rb_level = rb->id; 532: __entry->oldctx = rb->drawctxt_active ? 533: rb->drawctxt_active->base.id : 0; 534: __entry->newctx = newctx ? newctx->base.id : 0; 535: ), 536: TP_printk( 537: "rb level=%d oldctx=%u newctx=%u", 538: __entry->rb_level, __entry->oldctx, __entry->newctx 539: ) 540: ); 541: 542: TRACE_EVENT(adreno_gpu_fault, 543: TP_PROTO(unsigned int ctx, unsigned int ts, 544: unsigned int status, unsigned int rptr, unsigned int wptr, 545: u64 ib1base, unsigned int ib1size, 546: u64 ib2base, unsigned int ib2size, int rb_id), 547: TP_ARGS(ctx, ts, status, rptr, wptr, ib1base, ib1size, ib2base, 548: ib2size, rb_id), 549: TP_STRUCT__entry( 550: __field(unsigned int, ctx) 551: __field(unsigned int, ts) 552: __field(unsigned int, status) 553: __field(unsigned int, rptr) 554: __field(unsigned int, wptr) 555: __field(u64, ib1base) 556: __field(unsigned int, ib1size) 557: __field(u64, ib2base) 558: __field(unsigned int, ib2size) 559: __field(int, rb_id) 560: ), 561: TP_fast_assign( 562: __entry->ctx = ctx; 563: __entry->ts = ts; 564: __entry->status = status; 565: __entry->rptr = rptr; 566: __entry->wptr = wptr; MATCH LINES: 655 643: { BIT(A5XX_INT_CP_IB2), "CP_IB2_INT" }, 644: { BIT(A5XX_INT_CP_IB1), "CP_IB1_INT" }, 645: { BIT(A5XX_INT_CP_RB), "CP_RB_INT" }, 646: { BIT(A5XX_INT_CP_UNUSED_1), "CP_UNUSED_1" }, 647: { BIT(A5XX_INT_CP_RB_DONE_TS), "CP_RB_DONE_TS" }, 648: { BIT(A5XX_INT_CP_WT_DONE_TS), "CP_WT_DONE_TS" }, 649: { BIT(A5XX_INT_UNKNOWN_1), "UNKNOWN_1" }, 650: { BIT(A5XX_INT_CP_CACHE_FLUSH_TS), 651: "CP_CACHE_FLUSH_TS" }, 652: { BIT(A5XX_INT_UNUSED_2), "UNUSED_2" }, 653: { BIT(A5XX_INT_RBBM_ATB_BUS_OVERFLOW), 654: "RBBM_ATB_BUS_OVERFLOW" }, 655: { BIT(A5XX_INT_MISC_HANG_DETECT), "MISC_HANG_DETECT" }, 656: { BIT(A5XX_INT_UCHE_OOB_ACCESS), "UCHE_OOB_ACCESS" }, 657: { BIT(A5XX_INT_UCHE_TRAP_INTR), "UCHE_TRAP_INTR" }, 658: { BIT(A5XX_INT_DEBBUS_INTR_0), "DEBBUS_INTR_0" }, 659: { BIT(A5XX_INT_DEBBUS_INTR_1), "DEBBUS_INTR_1" }, 660: { BIT(A5XX_INT_GPMU_VOLTAGE_DROOP), 661: "GPMU_VOLTAGE_DROOP" }, 662: { BIT(A5XX_INT_GPMU_FIRMWARE), "GPMU_FIRMWARE" }, 663: { BIT(A5XX_INT_ISDB_CPU_IRQ), "ISDB_CPU_IRQ" }, 664: { BIT(A5XX_INT_ISDB_UNDER_DEBUG), "ISDB_UNDER_DEBUG" }) 665: : "None" 666: ) 667: ); 668: 669: /* 670: * Tracepoint for gen7 irq. Includes status info 671: */ 672: TRACE_EVENT(kgsl_gen7_irq_status, 673: 674: TP_PROTO(struct adreno_device *adreno_dev, unsigned int status), 675: 676: TP_ARGS(adreno_dev, status), 677: 678: TP_STRUCT__entry( 679: __string(device_name, adreno_dev->dev.name) --- FILE: \gen7_reg.h | HITS: 3 --- MATCH LINES: 608 596: 597: #define GEN7_RBBM_PERFCTR_CNTL 0x500 598: #define GEN7_RBBM_PERFCTR_RBBM_SEL_0 0x507 599: #define GEN7_RBBM_PERFCTR_RBBM_SEL_1 0x508 600: #define GEN7_RBBM_PERFCTR_RBBM_SEL_2 0x509 601: #define GEN7_RBBM_PERFCTR_RBBM_SEL_3 0x50a 602: #define GEN7_RBBM_PERFCTR_GPU_BUSY_MASKED 0x50b 603: #define GEN7_RBBM_PERFCTR_SRAM_INIT_CMD 0x50e 604: #define GEN7_RBBM_PERFCTR_SRAM_INIT_STATUS 0x50f 605: 606: #define GEN7_RBBM_ISDB_CNT 0x533 607: #define GEN7_RBBM_NC_MODE_CNTL 0x534 608: #define GEN7_RBBM_SNAPSHOT_STATUS 0x535 609: 610: #define GEN7_RBBM_PERFCTR_UCHE_12_LO 0x584 611: #define GEN7_RBBM_PERFCTR_UCHE_12_HI 0x585 612: #define GEN7_RBBM_PERFCTR_UCHE_13_LO 0x586 613: #define GEN7_RBBM_PERFCTR_UCHE_13_HI 0x587 614: #define GEN7_RBBM_PERFCTR_UCHE_14_LO 0x588 615: #define GEN7_RBBM_PERFCTR_UCHE_14_HI 0x589 616: #define GEN7_RBBM_PERFCTR_UCHE_15_LO 0x58a 617: #define GEN7_RBBM_PERFCTR_UCHE_15_HI 0x58b 618: #define GEN7_RBBM_PERFCTR_UCHE_16_LO 0x58c 619: #define GEN7_RBBM_PERFCTR_UCHE_16_HI 0x58d 620: #define GEN7_RBBM_PERFCTR_UCHE_17_LO 0x58e 621: #define GEN7_RBBM_PERFCTR_UCHE_17_HI 0x58f 622: #define GEN7_RBBM_PERFCTR_UCHE_18_LO 0x590 623: #define GEN7_RBBM_PERFCTR_UCHE_18_HI 0x591 624: #define GEN7_RBBM_PERFCTR_UCHE_19_LO 0x592 625: #define GEN7_RBBM_PERFCTR_UCHE_19_HI 0x593 626: #define GEN7_RBBM_PERFCTR_UCHE_20_LO 0x594 627: #define GEN7_RBBM_PERFCTR_UCHE_20_HI 0x595 628: #define GEN7_RBBM_PERFCTR_UCHE_21_LO 0x596 629: #define GEN7_RBBM_PERFCTR_UCHE_21_HI 0x597 630: #define GEN7_RBBM_PERFCTR_UCHE_22_LO 0x598 631: #define GEN7_RBBM_PERFCTR_UCHE_22_HI 0x599 632: #define GEN7_RBBM_PERFCTR_UCHE_23_LO 0x59a MATCH LINES: 651 639: #define GEN7_RBBM_SECVID_TSB_CNTL 0xf803 640: #define GEN7_RBBM_SECVID_TSB_STATUS_LO 0xfc00 641: #define GEN7_RBBM_SECVID_TSB_STATUS_HI 0xfc01 642: 643: #define GEN7_RBBM_GBIF_CLIENT_QOS_CNTL 0x00011 644: #define GEN7_RBBM_GBIF_HALT 0x00016 645: #define GEN7_RBBM_GBIF_HALT_ACK 0x00017 646: #define GEN7_RBBM_INTERFACE_HANG_INT_CNTL 0x0001f 647: #define GEN7_RBBM_INT_CLEAR_CMD 0x00037 648: #define GEN7_RBBM_INT_0_MASK 0x00038 649: #define GEN7_RBBM_INT_2_MASK 0x0003a 650: #define GEN7_RBBM_SP_HYST_CNT 0x00042 651: #define GEN7_RBBM_SW_RESET_CMD 0x00043 652: #define GEN7_RBBM_RAC_THRESHOLD_CNT 0x00044 653: #define GEN7_RBBM_CLOCK_CNTL_GLOBAL 0x000ad 654: #define GEN7_RBBM_CLOCK_CNTL 0x000ae 655: #define GEN7_RBBM_CLOCK_CNTL_SP0 0x000b0 656: #define GEN7_RBBM_CLOCK_CNTL2_SP0 0x000b4 657: #define GEN7_RBBM_CLOCK_DELAY_SP0 0x000b8 658: #define GEN7_RBBM_CLOCK_HYST_SP0 0x000bc 659: #define GEN7_RBBM_CLOCK_CNTL_TP0 0x000c0 660: #define GEN7_RBBM_CLOCK_CNTL2_TP0 0x000c4 661: #define GEN7_RBBM_CLOCK_CNTL3_TP0 0x000c8 662: #define GEN7_RBBM_CLOCK_CNTL4_TP0 0x000cc 663: #define GEN7_RBBM_CLOCK_DELAY_TP0 0x000d0 664: #define GEN7_RBBM_CLOCK_DELAY2_TP0 0x000d4 665: #define GEN7_RBBM_CLOCK_DELAY3_TP0 0x000d8 666: #define GEN7_RBBM_CLOCK_DELAY4_TP0 0x000dc 667: #define GEN7_RBBM_CLOCK_HYST_TP0 0x000e0 668: #define GEN7_RBBM_CLOCK_HYST2_TP0 0x000e4 669: #define GEN7_RBBM_CLOCK_HYST3_TP0 0x000e8 670: #define GEN7_RBBM_CLOCK_HYST4_TP0 0x000ec 671: #define GEN7_RBBM_CLOCK_CNTL_RB0 0x000f0 672: #define GEN7_RBBM_CLOCK_CNTL2_RB0 0x000f4 673: #define GEN7_RBBM_CLOCK_CNTL_CCU0 0x000f8 674: #define GEN7_RBBM_CLOCK_HYST_RB_CCU0 0x00100 675: #define GEN7_RBBM_CLOCK_CNTL_RAC 0x00104 MATCH LINES: 1145 1133: #define GEN7_GMU_NMI_CONTROL_STATUS 0x1cbf0 1134: #define GEN7_GMU_BOOT_SLUMBER_OPTION 0x1cbf8 1135: #define GEN7_GMU_GX_VOTE_IDX 0x1cbf9 1136: #define GEN7_GMU_MX_VOTE_IDX 0x1cbfa 1137: #define GEN7_GMU_DCVS_ACK_OPTION 0x1cbfc 1138: #define GEN7_GMU_DCVS_PERF_SETTING 0x1cbfd 1139: #define GEN7_GMU_DCVS_BW_SETTING 0x1cbfe 1140: #define GEN7_GMU_DCVS_RETURN 0x1cbff 1141: #define GEN7_GMU_ICACHE_CONFIG 0x1f400 1142: #define GEN7_GMU_DCACHE_CONFIG 0x1f401 1143: #define GEN7_GMU_SYS_BUS_CONFIG 0x1f40f 1144: #define GEN7_GMU_CX_MRC_GBIF_QOS_CTRL 0x1f50b 1145: #define GEN7_GMU_CM3_SYSRESET 0x1f800 1146: #define GEN7_GMU_CM3_BOOT_CONFIG 0x1f801 1147: #define GEN7_GMU_CX_GMU_WFI_CONFIG 0x1f802 1148: #define GEN7_GMU_CX_GMU_WDOG_CTRL 0x1f813 1149: #define GEN7_GMU_CM3_FW_BUSY 0x1f81a 1150: #define GEN7_GMU_CM3_FW_INIT_RESULT 0x1f81c 1151: #define GEN7_GMU_CM3_CFG 0x1f82d 1152: #define GEN7_GMU_CX_GMU_POWER_COUNTER_ENABLE 0x1f840 1153: #define GEN7_GMU_CX_GMU_POWER_COUNTER_SELECT_0 0x1f841 1154: #define GEN7_GMU_CX_GMU_POWER_COUNTER_SELECT_1 0x1f842 1155: #define GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_L 0x1f844 1156: #define GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_H 0x1f845 1157: #define GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_1_L 0x1f846 1158: #define GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_1_H 0x1f847 1159: #define GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_2_L 0x1f848 1160: #define GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_2_H 0x1f849 1161: #define GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_3_L 0x1f84a 1162: #define GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_3_H 0x1f84b 1163: #define GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_4_L 0x1f84c 1164: #define GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_4_H 0x1f84d 1165: #define GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_5_L 0x1f84e 1166: #define GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_5_H 0x1f84f 1167: #define GEN7_GMU_CX_GMU_POWER_COUNTER_GMUCLK_0_L 0x1f850 1168: #define GEN7_GMU_CX_GMU_POWER_COUNTER_GMUCLK_0_H 0x1f851 1169: #define GEN7_GMU_CX_GMU_POWER_COUNTER_GMUCLK_1_L 0x1f852 --- FILE: \gen8_reg.h | HITS: 6 --- MATCH LINES: 52, 60, 61, 62 40: #define GEN8_RBBM_GBIF_HALT 0x00a 41: #define GEN8_RBBM_GBIF_HALT_ACK 0x00b 42: #define GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL 0x010 43: #define GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL2 0x011 44: #define GEN8_RBBM_STATUS 0x012 45: #define GEN8_RBBM_STATUS1 0x013 46: #define GEN8_RBBM_GFX_STATUS 0x015 47: #define GEN8_RBBM_GFX_STATUS1 0x016 48: #define GEN8_RBBM_LPAC_STATUS 0x018 49: #define GEN8_RBBM_GFX_BR_STATUS 0x01a 50: #define GEN8_RBBM_GFX_BV_STATUS 0x01c 51: #define GEN8_RBBM_ISDB_CNT 0x02d 52: #define GEN8_RBBM_SNAPSHOT_STATUS 0x02e 53: #define GEN8_RBBM_INTERFACE_HANG_INT_CNTL 0x02f 54: #define GEN8_RBBM_INT_CLEAR_CMD 0x061 55: #define GEN8_RBBM_INT_0_MASK 0x062 56: #define GEN8_RBBM_INT_2_MASK 0x064 57: #define GEN8_RBBM_INT_0_STATUS 0x06a 58: #define GEN8_RBBM_SW_FUSE_INT_STATUS 0x071 59: #define GEN8_RBBM_SW_FUSE_INT_MASK 0x072 60: #define GEN8_RBBM_SW_RESET_CMD 0x073 61: #define GEN8_RBBM_POWER_UP_RESET_SW_OVERRIDE 0x07d 62: #define GEN8_RBBM_POWER_UP_RESET_SW_BV_OVERRIDE 0x07e 63: #define GEN8_RBBM_CLOCK_CNTL_GLOBAL 0x09a 64: #define GEN8_RBBM_CGC_GLOBAL_LOAD_CMD 0x09b 65: #define GEN8_RBBM_CGC_P2S_TRIG_CMD 0x09c 66: #define GEN8_RBBM_CGC_P2S_CNTL 0x09d 67: #define GEN8_RBBM_CGC_P2S_STATUS 0x09f 68: 69: #define GEN8_RBBM_CGC_0_PC 0x10b 70: #define GEN8_RBBM_PERFCTR_GPU_BUSY_MASKED 0x19e 71: #define GEN8_RBBM_PERFCTR_SRAM_INIT_STATUS 0x19f 72: #define GEN8_RBBM_PERFCTR_FLUSH_HOST_STATUS 0x1a1 73: #define GEN8_RBBM_PERFCTR_CP_0_LO 0x1b0 74: #define GEN8_RBBM_PERFCTR_CP_0_HI 0x1b1 75: #define GEN8_RBBM_PERFCTR_CP_1_LO 0x1b2 76: #define GEN8_RBBM_PERFCTR_CP_1_HI 0x1b3 77: #define GEN8_RBBM_PERFCTR_CP_2_LO 0x1b4 78: #define GEN8_RBBM_PERFCTR_CP_2_HI 0x1b5 79: #define GEN8_RBBM_PERFCTR_CP_3_LO 0x1b6 80: #define GEN8_RBBM_PERFCTR_CP_3_HI 0x1b7 81: #define GEN8_RBBM_PERFCTR_CP_4_LO 0x1b8 82: #define GEN8_RBBM_PERFCTR_CP_4_HI 0x1b9 83: #define GEN8_RBBM_PERFCTR_CP_5_LO 0x1ba 84: #define GEN8_RBBM_PERFCTR_CP_5_HI 0x1bb 85: #define GEN8_RBBM_PERFCTR_CP_6_LO 0x1bc 86: #define GEN8_RBBM_PERFCTR_CP_6_HI 0x1bd MATCH LINES: 1360 1348: #define GEN8_GBIF_PERF_CNT_HI_5 0x3cd1 1349: #define GEN8_GBIF_PERF_CNT_LO_6 0x3cd2 1350: #define GEN8_GBIF_PERF_CNT_HI_6 0x3cd3 1351: #define GEN8_GBIF_PERF_CNT_LO_7 0x3cd4 1352: #define GEN8_GBIF_PERF_CNT_HI_7 0x3cd5 1353: #define GEN8_GBIF_PWR_CNT_LO_0 0x3ce0 /* Indexed Register */ 1354: #define GEN8_GBIF_PWR_CNT_LO_1 0x3ce1 /* Indexed Register */ 1355: #define GEN8_GBIF_PWR_CNT_LO_2 0x3ce2 /* Indexed Register */ 1356: #define GEN8_GBIF_PWR_CNT_HI_0 0x3ce3 /* Indexed Register */ 1357: #define GEN8_GBIF_PWR_CNT_HI_1 0x3ce4 /* Indexed Register */ 1358: #define GEN8_GBIF_PWR_CNT_HI_2 0x3ce5 /* Indexed Register */ 1359: 1360: /* CX_DBGC_CFG registers: Fixme for Snapshot */ 1361: #define GEN8_CX_DBGC_CFG_DBGBUS_SEL_A 0x18400 1362: #define GEN8_CX_DBGC_CFG_DBGBUS_SEL_B 0x18401 1363: #define GEN8_CX_DBGC_CFG_DBGBUS_SEL_C 0x18402 1364: #define GEN8_CX_DBGC_CFG_DBGBUS_SEL_D 0x18403 1365: #define GEN8_CX_DBGC_CFG_DBGBUS_CNTLT 0x18404 1366: #define GEN8_CX_DBGC_CFG_DBGBUS_CNTLM 0x18405 1367: #define GEN8_CX_DBGC_CFG_DBGBUS_OPL 0x18406 1368: #define GEN8_CX_DBGC_CFG_DBGBUS_OPE 0x18407 1369: #define GEN8_CX_DBGC_CFG_DBGBUS_IVTL_0 0x18408 1370: #define GEN8_CX_DBGC_CFG_DBGBUS_IVTL_1 0x18409 1371: #define GEN8_CX_DBGC_CFG_DBGBUS_IVTL_2 0x1840a 1372: #define GEN8_CX_DBGC_CFG_DBGBUS_IVTL_3 0x1840b 1373: #define GEN8_CX_DBGC_CFG_DBGBUS_MASKL_0 0x1840c 1374: #define GEN8_CX_DBGC_CFG_DBGBUS_MASKL_1 0x1840d 1375: #define GEN8_CX_DBGC_CFG_DBGBUS_MASKL_2 0x1840e 1376: #define GEN8_CX_DBGC_CFG_DBGBUS_MASKL_3 0x1840f 1377: #define GEN8_CX_DBGC_CFG_DBGBUS_BYTEL_0 0x18410 1378: #define GEN8_CX_DBGC_CFG_DBGBUS_BYTEL_1 0x18411 1379: #define GEN8_CX_DBGC_CFG_DBGBUS_IVTE_0 0x18412 1380: #define GEN8_CX_DBGC_CFG_DBGBUS_IVTE_1 0x18413 1381: #define GEN8_CX_DBGC_CFG_DBGBUS_IVTE_2 0x18414 1382: #define GEN8_CX_DBGC_CFG_DBGBUS_IVTE_3 0x18415 1383: #define GEN8_CX_DBGC_CFG_DBGBUS_MASKE_0 0x18416 1384: #define GEN8_CX_DBGC_CFG_DBGBUS_MASKE_1 0x18417 MATCH LINES: 1429 1417: #define GEN8_GMU_CM3_DTCM_START 0x1c400 1418: #define GEN8_GMUCX_ICACHE_CONFIG 0x1f400 1419: #define GEN8_GMUCX_DCACHE_CONFIG 0x1f401 1420: #define GEN8_GMUCX_SYS_BUS_CONFIG 0x1f40f 1421: #define GEN8_GMUCX_MRC_GBIF_QOS_CTRL 0x1f50b 1422: #define GEN8_GMUCX_PWR_COL_KEEPALIVE 0x1f7e4 1423: #define GEN8_GMUCX_PWR_COL_PREEMPTION_KEEPALIVE 0x1f7e5 1424: #define GEN8_GMUCX_GFX_PWR_CLK_STATUS 0x1f7e8 1425: #define GEN8_GMUCX_RPMH_POWER_STATE 0x1f7e9 1426: /* FAL10 veto register */ 1427: #define GEN8_GMUCX_CX_FAL_INTF 0x1f7ec 1428: #define GEN8_GMUCX_CX_FALNEXT_INTF 0x1f7ed 1429: #define GEN8_GMUCX_CM3_SYSRESET 0x1f800 1430: #define GEN8_GMUCX_CM3_BOOT_CONFIG 0x1f801 1431: #define GEN8_GMUCX_WFI_CONFIG 0x1f802 1432: #define GEN8_GMUCX_WDOG_CTRL 0x1f813 1433: #define GEN8_GMUCX_CM3_FW_INIT_RESULT 0x1f81c 1434: #define GEN8_GMUCX_CM3_CFG 0x1f82d 1435: #define GEN8_GMUCX_AO_COUNTER_LO 0x1f840 1436: #define GEN8_GMUCX_AO_COUNTER_HI 0x1f841 1437: 1438: #define GEN8_GMUCX_PERF_COUNTER_ENABLE 0x1f848 1439: #define GEN8_GMUCX_PERF_COUNTER_SELECT_0 0x1f858 1440: #define GEN8_GMUCX_PERF_COUNTER_SELECT_1 0x1f859 1441: #define GEN8_GMUCX_PERF_COUNTER_SELECT_H_0 0x1f868 1442: #define GEN8_GMUCX_PERF_COUNTER_SELECT_H_1 0x1f869 1443: #define GEN8_GMUCX_PERF_COUNTER_L_0 0x1f878 1444: #define GEN8_GMUCX_PERF_COUNTER_H_0 0x1f879 1445: #define GEN8_GMUCX_PERF_COUNTER_L_1 0x1f87a 1446: #define GEN8_GMUCX_PERF_COUNTER_H_1 0x1f87b 1447: #define GEN8_GMUCX_PERF_COUNTER_L_2 0x1f87c 1448: #define GEN8_GMUCX_PERF_COUNTER_H_2 0x1f87d 1449: #define GEN8_GMUCX_PERF_COUNTER_L_3 0x1f87e 1450: #define GEN8_GMUCX_PERF_COUNTER_H_3 0x1f87f 1451: #define GEN8_GMUCX_PERF_COUNTER_L_4 0x1f880 1452: #define GEN8_GMUCX_PERF_COUNTER_H_4 0x1f881 1453: #define GEN8_GMUCX_PERF_COUNTER_L_5 0x1f882 --- FILE: \gfx_kernel_board.mk | HITS: 1 --- MATCH LINES: 7 1: #SPDX-License-Identifier: GPL-2.0-only 2: 3: ifneq ($(TARGET_USES_QMAA),true) 4: ifeq ($(call is-board-platform-in-list,$(TARGET_BOARD_PLATFORM)),true) 5: BOARD_VENDOR_KERNEL_MODULES += $(KERNEL_MODULES_OUT)/msm_kgsl.ko 6: BOARD_VENDOR_RAMDISK_KERNEL_MODULES += $(KERNEL_MODULES_OUT)/msm_kgsl.ko 7: BOARD_VENDOR_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD += $(KERNEL_MODULES_OUT)/msm_kgsl.ko 8: endif 9: endif --- FILE: \governor_msm_adreno_tz.c | HITS: 9 --- MATCH LINES: 54, 58 42: #define FLOOR 5000 43: /* 44: * MIN_BUSY is 1 msec for the sample to be sent 45: */ 46: #define MIN_BUSY 1000 47: #define MAX_TZ_VERSION 0 48: 49: /* 50: * CEILING is 50msec, larger than any standard 51: * frame length, but less than the idle timer. 52: */ 53: #define CEILING 50000 54: #define TZ_RESET_ID 0x3 55: #define TZ_UPDATE_ID 0x4 56: #define TZ_INIT_ID 0x6 57: 58: #define TZ_RESET_ID_64 0x7 59: #define TZ_UPDATE_ID_64 0x8 60: #define TZ_INIT_ID_64 0x9 61: 62: #define TZ_V2_UPDATE_ID_64 0xA 63: #define TZ_V2_INIT_ID_64 0xB 64: #define TZ_V2_INIT_CA_ID_64 0xC 65: #define TZ_V2_UPDATE_WITH_CA_ID_64 0xD 66: 67: #define TZ_DCVS_TUNING_ID 0xE 68: 69: #define TAG "msm_adreno_tz: " 70: 71: static u64 suspend_time; 72: static u64 suspend_start; 73: static unsigned long acc_total, acc_relative_busy; 74: 75: /* 76: * Returns GPU suspend time in millisecond. 77: */ 78: u64 suspend_time_ms(void) 79: { 80: u64 suspend_sampling_time; 81: u64 time_diff = 0; 82: MATCH LINES: 107 95: char *buf) 96: { 97: unsigned long sysfs_busy_perc = 0; 98: /* 99: * Average out the samples taken since last read 100: * This will keep the average value in sync with 101: * the client sampling duration. 102: */ 103: spin_lock(&sample_lock); 104: if (acc_total) 105: sysfs_busy_perc = (acc_relative_busy * 100) / acc_total; 106: 107: /* Reset the parameters */ 108: acc_total = 0; 109: acc_relative_busy = 0; 110: spin_unlock(&sample_lock); 111: return snprintf(buf, PAGE_SIZE, "%lu\n", sysfs_busy_perc); 112: } 113: 114: /* 115: * Returns the time in ms for which gpu was in suspend state 116: * since last time the entry is read. 117: */ 118: static ssize_t suspend_time_show(struct device *dev, 119: struct device_attribute *attr, 120: char *buf) 121: { 122: u64 time_diff = 0; 123: 124: spin_lock(&suspend_lock); 125: time_diff = suspend_time_ms(); 126: /* 127: * Adding the previous suspend time also as the gpu 128: * can go and come out of suspend states in between 129: * reads also and we should have the total suspend 130: * since last read. 131: */ MATCH LINES: 187, 199, 208, 211 175: NULL 176: }; 177: 178: void compute_work_load(struct devfreq_dev_status *stats, 179: struct devfreq_msm_adreno_tz_data *priv, 180: struct devfreq *devfreq) 181: { 182: u64 busy; 183: 184: spin_lock(&sample_lock); 185: /* 186: * Keep collecting the stats till the client 187: * reads it. Average of all samples and reset 188: * is done when the entry is read 189: */ 190: acc_total += stats->total_time; 191: busy = (u64)stats->busy_time * stats->current_frequency; 192: do_div(busy, devfreq->profile->freq_table[0]); 193: acc_relative_busy += busy; 194: 195: spin_unlock(&sample_lock); 196: } 197: 198: /* Trap into the TrustZone, and call funcs there. */ 199: static int __secure_tz_reset_entry2(unsigned int *scm_data, u32 size_scm_data, 200: bool is_64) 201: { 202: int ret; 203: /* sync memory before sending the commands to tz */ 204: __iowmb(); 205: 206: if (!is_64) { 207: spin_lock(&tz_lock); 208: ret = qcom_scm_io_reset(); 209: spin_unlock(&tz_lock); 210: } else { 211: ret = qcom_scm_dcvs_reset(); 212: } 213: 214: return ret; 215: } 216: 217: static int __secure_tz_update_entry3(int level, s64 total_time, s64 busy_time, 218: int context_count, struct devfreq_msm_adreno_tz_data *priv) 219: { 220: int ret; 221: /* sync memory before sending the commands to tz */ 222: __iowmb(); 223: 224: if (!priv->is_64) { 225: spin_lock(&tz_lock); 226: ret = qcom_scm_dcvs_update(level, total_time, busy_time); 227: spin_unlock(&tz_lock); 228: } else if (!priv->ctxt_aware_enable) { 229: ret = qcom_scm_dcvs_update_v2(level, total_time, busy_time); 230: } else { 231: ret = qcom_scm_dcvs_update_ca_v2(level, total_time, busy_time, 232: context_count); 233: } 234: 235: return ret; MATCH LINES: 601 589: devfreq->data = NULL; 590: return 0; 591: } 592: 593: static int tz_suspend(struct devfreq *devfreq) 594: { 595: struct devfreq_msm_adreno_tz_data *priv = devfreq->data; 596: unsigned int scm_data[2] = {0, 0}; 597: 598: if (!priv) 599: return 0; 600: 601: __secure_tz_reset_entry2(scm_data, sizeof(scm_data), priv->is_64); 602: 603: priv->bin.total_time = 0; 604: priv->bin.busy_time = 0; 605: return 0; 606: } 607: 608: static int tz_handler(struct devfreq *devfreq, unsigned int event, void *data) 609: { 610: int result; 611: struct device_node *node = devfreq->dev.parent->of_node; 612: 613: if (!(of_device_is_compatible(node, "qcom,kgsl-3d0") || 614: of_device_is_compatible(node, "qcom,kgsl") || 615: of_device_is_compatible(node, "qcom,adreno"))) 616: return -EINVAL; 617: 618: switch (event) { 619: case DEVFREQ_GOV_START: 620: result = tz_start(devfreq); 621: break; 622: 623: case DEVFREQ_GOV_STOP: 624: spin_lock(&suspend_lock); 625: suspend_start = 0; MATCH LINES: 643 631: result = tz_suspend(devfreq); 632: if (!result) { 633: spin_lock(&suspend_lock); 634: /* Collect the start sample for suspend time */ 635: suspend_start = (u64)ktime_to_ms(ktime_get()); 636: spin_unlock(&suspend_lock); 637: } 638: break; 639: 640: case DEVFREQ_GOV_RESUME: 641: spin_lock(&suspend_lock); 642: suspend_time += suspend_time_ms(); 643: /* Reset the suspend_start when gpu resumes */ 644: suspend_start = 0; 645: spin_unlock(&suspend_lock); 646: fallthrough; 647: case DEVFREQ_GOV_UPDATE_INTERVAL: 648: /* This governor doesn't use polling */ 649: fallthrough; 650: default: 651: result = 0; 652: break; 653: } 654: 655: return result; 656: } 657: 658: static struct devfreq_governor msm_adreno_tz = { 659: .name = "msm-adreno-tz", 660: .get_target_freq = tz_get_target_freq, 661: .event_handler = tz_handler, 662: .flags = DEVFREQ_GOV_FLAG_IMMUTABLE, 663: }; 664: 665: int msm_adreno_tz_reinit(struct devfreq *devfreq) 666: { 667: return __tz_init(devfreq); --- FILE: \Kconfig | HITS: 4 --- MATCH LINES: 122, 125, 126, 128 110: kgsl will use msm_hw_fence APIs for hardware fence feature. 111: 112: config QCOM_KGSL_RT_MUTEX 113: bool "Use RT-mutex in KGSL" 114: depends on RT_MUTEXES 115: help 116: Say 'Y' to use RT-mutex instead of mutex in KGSL driver. If 117: enabled, KGSL will use RT-mutex instead of mutex to prevent 118: priority inversion. RT-mutexes extend the semantics of simple 119: mutexes by the priority inheritance protocol. 120: 121: config QCOM_KGSL_DEVCOREDUMP 122: bool "Use devcoredump for KGSL snapshots" 123: depends on DEV_COREDUMP 124: help 125: Say 'Y' to use devcoredump framework for GPU snapshot dumps 126: instead of the custom sysfs interface. Snapshot data will be 127: accessible through /sys/class/devcoredump/ interface. If enabled, 128: the snapshot/dump sysfs node will not be set up. 129: 130: config QCOM_KGSL_UPSTREAM 131: bool "Enable KGSL compilation with upstream kernel" 132: help 133: Say 'Y' to enable kgsl compilation with upstream kernel. If enabled, 134: all downstream dependencies are stubbed out. --- FILE: \kgsl.c | HITS: 10 --- MATCH LINES: 1117 1105: active_time = min_t(u64, active_time, 1106: device->gpu_period.end - device->gpu_period.begin); 1107: /* 1108: * Emit GPU work period events via a kernel tracepoint 1109: * to provide information to the Android OS about how 1110: * apps are using the GPU. 1111: */ 1112: if (active_time) 1113: trace_gpu_work_period(KGSL_GPU_ID, wp->uid, 1114: device->gpu_period.begin, 1115: device->gpu_period.end, 1116: active_time); 1117: /* Reset gpu work period stats */ 1118: wp->active = 0; 1119: wp->cmds = 0; 1120: atomic_set(&wp->frames, 0); 1121: 1122: /* make sure other CPUs see the update */ 1123: smp_wmb(); 1124: 1125: if (!atomic_read(&wp->active_cmds)) { 1126: __clear_bit(KGSL_WORK_PERIOD, &wp->flags); 1127: queue_work(kgsl_driver.lockless_workqueue, &wp->defer_ws); 1128: } else { 1129: restart = true; 1130: } 1131: } 1132: spin_unlock(&kgsl_driver.wp_list_lock); 1133: 1134: if (restart) { 1135: /* 1136: * GPU work period duration (end time - begin time) must be at 1137: * most 1 second. The event for a period must be emitted within 1138: * 1 second of the end time of the period. Restart timer within 1139: * 1 second to emit gpu work period events. 1140: */ 1141: mod_timer(&device->work_period_timer, MATCH LINES: 1777, 1778, 1796, 1799, 1801 1765: .dev_minor = 1, 1766: }; 1767: 1768: if (param->sizebytes != sizeof(version)) 1769: return -EINVAL; 1770: 1771: if (copy_to_user(param->value, &version, sizeof(version))) 1772: return -EFAULT; 1773: 1774: return 0; 1775: } 1776: 1777: /* Return reset status of given context and clear it */ 1778: static long kgsl_prop_gpu_reset_stat(struct kgsl_device_private *dev_priv, 1779: struct kgsl_device_getproperty *param) 1780: { 1781: u32 id; 1782: struct kgsl_context *context; 1783: 1784: if (param->sizebytes != sizeof(id)) 1785: return -EINVAL; 1786: 1787: /* We expect the value passed in to contain the context id */ 1788: if (copy_from_user(&id, param->value, sizeof(id))) 1789: return -EFAULT; 1790: 1791: context = kgsl_context_get_owner(dev_priv, id); 1792: if (!context) 1793: return -EINVAL; 1794: 1795: /* 1796: * Copy the reset status to value which also serves as 1797: * the out parameter 1798: */ 1799: id = context->reset_status; 1800: 1801: context->reset_status = KGSL_CTX_STAT_NO_ERROR; 1802: kgsl_context_put(context); 1803: 1804: if (copy_to_user(param->value, &id, sizeof(id))) 1805: return -EFAULT; 1806: 1807: return 0; 1808: } 1809: 1810: static long kgsl_prop_secure_buf_alignment(struct kgsl_device_private *dev_priv, 1811: struct kgsl_device_getproperty *param) 1812: { 1813: u32 align = PAGE_SIZE; 1814: 1815: if (param->sizebytes != sizeof(align)) 1816: return -EINVAL; 1817: 1818: if (copy_to_user(param->value, &align, sizeof(align))) 1819: return -EFAULT; 1820: 1821: return 0; 1822: } 1823: 1824: static long kgsl_prop_secure_ctxt_support(struct kgsl_device_private *dev_priv, 1825: struct kgsl_device_getproperty *param) MATCH LINES: 1990 1978: if (copy_to_user(param->value, &val, sizeof(val))) 1979: return -EFAULT; 1980: 1981: return 0; 1982: } 1983: 1984: static const struct { 1985: int type; 1986: long (*func)(struct kgsl_device_private *dev_priv, 1987: struct kgsl_device_getproperty *param); 1988: } kgsl_property_funcs[] = { 1989: { KGSL_PROP_VERSION, kgsl_prop_version }, 1990: { KGSL_PROP_GPU_RESET_STAT, kgsl_prop_gpu_reset_stat}, 1991: { KGSL_PROP_SECURE_BUFFER_ALIGNMENT, kgsl_prop_secure_buf_alignment }, 1992: { KGSL_PROP_SECURE_CTXT_SUPPORT, kgsl_prop_secure_ctxt_support }, 1993: { KGSL_PROP_QUERY_CAPABILITIES, kgsl_prop_query_capabilities }, 1994: { KGSL_PROP_CONTEXT_PROPERTY, kgsl_get_ctxt_properties }, 1995: { KGSL_PROP_GPU_VA64_SIZE, kgsl_get_gpu_va64_size }, 1996: { KGSL_PROP_GPU_SECURE_VA_SIZE, kgsl_get_gpu_secure_va_size }, 1997: { KGSL_PROP_GPU_SECURE_VA_INUSE, kgsl_get_gpu_secure_va_inuse }, 1998: }; 1999: 2000: /*call all ioctl sub functions with driver locked*/ 2001: long kgsl_ioctl_device_getproperty(struct kgsl_device_private *dev_priv, 2002: unsigned int cmd, void *data) 2003: { 2004: struct kgsl_device *device = dev_priv->device; 2005: struct kgsl_device_getproperty *param = data; 2006: int i; 2007: 2008: for (i = 0; i < ARRAY_SIZE(kgsl_property_funcs); i++) { 2009: if (param->type == kgsl_property_funcs[i].type) 2010: return kgsl_property_funcs[i].func(dev_priv, param); 2011: } 2012: 2013: if (is_compat_task()) 2014: return device->ftbl->getproperty_compat(device, param); MATCH LINES: 3991, 3992 3979: memcpy(&faults[fault.type], &fault, sizeof(fault)); 3980: } 3981: 3982: mutex_lock(&context->fault_lock); 3983: 3984: list_for_each_entry(fault_node, &context->faults, node) { 3985: u32 fault_type = fault_node->type; 3986: 3987: if (cur_idx[fault_type] >= faults[fault_type].count) 3988: continue; 3989: 3990: switch (fault_type) { 3991: case KGSL_FAULT_TYPE_PAGEFAULT: 3992: size = sizeof(struct kgsl_pagefault_report); 3993: } 3994: 3995: size = min_t(u32, size, faults[fault_type].size); 3996: 3997: if (copy_to_user(u64_to_user_ptr(faults[fault_type].fault + 3998: cur_idx[fault_type] * faults[fault_type].size), 3999: fault_node->priv, size)) { 4000: ret = -EFAULT; 4001: goto release_lock; 4002: } 4003: 4004: cur_idx[fault_type] += 1; 4005: } 4006: 4007: release_lock: 4008: mutex_unlock(&context->fault_lock); 4009: 4010: err: 4011: kfree(faults); 4012: return ret; 4013: } 4014: 4015: static int kgsl_update_fault_count(struct kgsl_context *context, 4016: void __user *faults, u32 faultnents, u32 faultsize) MATCH LINES: 5393 5381: kgsl_pwrctrl_close(device); 5382: error: 5383: _unregister_device(device); 5384: return status; 5385: } 5386: 5387: void kgsl_device_platform_remove(struct kgsl_device *device) 5388: { 5389: kgsl_delete_timer(&device->work_period_timer); 5390: 5391: kthread_destroy_worker(device->events_worker); 5392: 5393: kgsl_device_snapshot_close(device); 5394: 5395: idr_destroy(&device->context_idr); 5396: idr_destroy(&device->timelines); 5397: 5398: kgsl_device_events_remove(device); 5399: 5400: kgsl_free_globals(device); 5401: 5402: kgsl_pwrctrl_close(device); 5403: 5404: kgsl_device_debugfs_close(device); 5405: _unregister_device(device); 5406: } 5407: 5408: void kgsl_core_exit(void) 5409: { 5410: kgsl_exit_page_pools(); 5411: kgsl_eventlog_exit(); 5412: 5413: if (kgsl_driver.workqueue) { 5414: destroy_workqueue(kgsl_driver.workqueue); 5415: kgsl_driver.workqueue = NULL; 5416: } 5417: --- FILE: \kgsl_bus.c | HITS: 1 --- MATCH LINES: 55 43: u32 ab; 44: 45: /* the bus should be ON to update the active frequency */ 46: if ((vote_state != KGSL_BUS_VOTE_OFF) && 47: !(test_bit(KGSL_PWRFLAGS_AXI_ON, &pwr->power_flags))) 48: return 0; 49: /* 50: * If the bus should remain on calculate our request and submit it, 51: * otherwise request bus level 0, off. 52: */ 53: switch (vote_state) { 54: case KGSL_BUS_VOTE_OFF: 55: /* If the bus is being turned off, reset to default level */ 56: pwr->cur_dcvs_buslevel = 0; 57: pwr->bus_mod = 0; 58: pwr->bus_percent_ab = 0; 59: pwr->bus_ab_mbytes = 0; 60: ab = 0; 61: break; 62: case KGSL_BUS_VOTE_ON: 63: { 64: /* FIXME: this might be wrong? */ 65: int cur = pwr->pwrlevels[pwr->active_pwrlevel].bus_freq; 66: 67: buslevel = min_t(int, pwr->pwrlevels[0].bus_max, 68: cur + pwr->bus_mod); 69: buslevel = max_t(int, buslevel, 1); 70: pwr->cur_dcvs_buslevel = buslevel; 71: ab = _ab_buslevel_update(pwr, pwr->ddr_table[buslevel]); 72: break; 73: } 74: case KGSL_BUS_VOTE_MINIMUM: 75: /* Request bus level 1, minimum non-zero value */ 76: pwr->cur_dcvs_buslevel = 1; 77: pwr->bus_mod = 0; 78: pwr->bus_percent_ab = 0; 79: pwr->bus_ab_mbytes = 0; --- FILE: \kgsl_debugfs.c | HITS: 3 --- MATCH LINES: 126, 137, 138 114: WARN((IS_ERR_OR_NULL(dentry)), 115: "Unable to create 'reserved' file for %s\n", name); 116: 117: dentry = debugfs_create_file("count", 0444, 118: pool_debugfs, pool, &_page_count_fops); 119: 120: WARN((IS_ERR_OR_NULL(dentry)), 121: "Unable to create 'count' file for %s\n", name); 122: } 123: 124: void kgsl_device_debugfs_init(struct kgsl_device *device) 125: { 126: struct dentry *snapshot_dir; 127: 128: if (IS_ERR_OR_NULL(kgsl_debugfs_dir)) 129: return; 130: 131: device->d_debugfs = debugfs_create_dir(device->name, 132: kgsl_debugfs_dir); 133: 134: debugfs_create_file("globals", 0444, device->d_debugfs, device, 135: &globals_fops); 136: 137: snapshot_dir = debugfs_create_dir("snapshot", kgsl_debugfs_dir); 138: debugfs_create_file("break_isdb", 0644, snapshot_dir, device, 139: &_isdb_fops); 140: } 141: 142: void kgsl_device_debugfs_close(struct kgsl_device *device) 143: { 144: debugfs_remove_recursive(device->d_debugfs); 145: } 146: 147: static const char *memtype_str(int memtype) 148: { 149: if (memtype == KGSL_MEM_ENTRY_KERNEL) 150: return "gpumem"; 151: else if (memtype == KGSL_MEM_ENTRY_USER) 152: return "usermem"; 153: else if (memtype == KGSL_MEM_ENTRY_ION) 154: return "ion"; 155: 156: return "unknown"; 157: } 158: 159: static char get_alignflag(const struct kgsl_memdesc *m) 160: { 161: u32 align = kgsl_memdesc_get_align(m); 162: --- FILE: \kgsl_device.h | HITS: 74 --- MATCH LINES: 52, 53 40: #define kgsl_mutex_trylock(mutex) mutex_trylock(mutex) 41: #define kgsl_mutex_is_locked(mutex) mutex_is_locked(mutex) 42: #endif 43: 44: /* 45: * KGSL device state is initialized to INIT when platform_probe * 46: * successfully initialized the device. Once a device has been opened * 47: * (started) it becomes active. NAP implies that only low latency * 48: * resources (for now clocks on some platforms) are off. SLEEP implies * 49: * that the KGSL module believes a device is idle (has been inactive * 50: * past its timer) and all system resources are released. SUSPEND is * 51: * requested by the kernel and will be enforced upon all open devices. * 52: * RESET indicates that GPU or GMU hang happens. KGSL is handling * 53: * snapshot or recover GPU from hang. MINBW implies that DDR BW vote is * 54: * set to non-zero minimum value. 55: */ 56: 57: #define KGSL_STATE_NONE 0x00000000 58: #define KGSL_STATE_INIT 0x00000001 59: #define KGSL_STATE_ACTIVE 0x00000002 60: #define KGSL_STATE_NAP 0x00000004 /* Not Used */ 61: #define KGSL_STATE_SUSPEND 0x00000010 62: #define KGSL_STATE_AWARE 0x00000020 63: #define KGSL_STATE_SLUMBER 0x00000080 64: #define KGSL_STATE_MINBW 0x00000100 /* Not Used */ 65: 66: /** 67: * enum kgsl_event_results - result codes passed to an event callback when the 68: * event is retired or cancelled 69: * @KGSL_EVENT_RETIRED: The timestamp associated with the event retired 70: * successflly 71: * @KGSL_EVENT_CANCELLED: The event was cancelled before the event was fired 72: */ 73: enum kgsl_event_results { 74: KGSL_EVENT_RETIRED = 1, 75: KGSL_EVENT_CANCELLED = 2, 76: }; 77: MATCH LINES: 96, 117, 144, 145 84: { KGSL_CONTEXT_PREAMBLE, "PREAMBLE" }, \ 85: { KGSL_CONTEXT_TRASH_STATE, "TRASH_STATE" }, \ 86: { KGSL_CONTEXT_CTX_SWITCH, "CTX_SWITCH" }, \ 87: { KGSL_CONTEXT_PER_CONTEXT_TS, "PER_CONTEXT_TS" }, \ 88: { KGSL_CONTEXT_USER_GENERATED_TS, "USER_TS" }, \ 89: { KGSL_CONTEXT_NO_FAULT_TOLERANCE, "NO_FT" }, \ 90: { KGSL_CONTEXT_INVALIDATE_ON_FAULT, "INVALIDATE_ON_FAULT" }, \ 91: { KGSL_CONTEXT_PWR_CONSTRAINT, "PWR" }, \ 92: { KGSL_CONTEXT_SAVE_GMEM, "SAVE_GMEM" }, \ 93: { KGSL_CONTEXT_IFH_NOP, "IFH_NOP" }, \ 94: { KGSL_CONTEXT_SECURE, "SECURE" }, \ 95: { KGSL_CONTEXT_LPAC, "LPAC" }, \ 96: { KGSL_CONTEXT_NO_SNAPSHOT, "NO_SNAPSHOT" } 97: 98: #define KGSL_CONTEXT_ID(_context) \ 99: ((_context != NULL) ? (_context)->id : KGSL_MEMSTORE_GLOBAL) 100: 101: enum gpu_pwrlevel_op { 102: GPU_PWRLEVEL_OP_THERMAL, 103: GPU_PWRLEVEL_OP_MIN_PWRLEVEL, 104: GPU_PWRLEVEL_OP_MAX_PWRLEVEL, 105: GPU_PWRLEVEL_OP_GPUCLK, 106: GPU_PWRLEVEL_OP_PERF_HINT, /* Mutex grabbed in the ops function */ 107: GPU_PWRLEVEL_OP_DCVS_ENABLE, 108: GPU_PWRLEVEL_OP_TUNING_ATTR, 109: }; 110: 111: struct kgsl_device; 112: struct platform_device; 113: struct kgsl_device_private; 114: struct kgsl_context; 115: struct kgsl_power_stats; 116: struct kgsl_event; 117: struct kgsl_snapshot; 118: struct kgsl_sync_fence; 119: 120: struct kgsl_functable { 121: /* Mandatory functions - these functions must be implemented 122: * by the client device. The driver will not check for a NULL 123: * pointer before calling the hook. 124: */ 125: void (*check_idle)(struct kgsl_device *device); 126: int (*first_open)(struct kgsl_device *device); 127: int (*last_close)(struct kgsl_device *device); 128: int (*start)(struct kgsl_device *device, int priority); 129: int (*stop)(struct kgsl_device *device); 130: int (*getproperty)(struct kgsl_device *device, 131: struct kgsl_device_getproperty *param); 132: int (*getproperty_compat)(struct kgsl_device *device, 133: struct kgsl_device_getproperty *param); 134: int (*waittimestamp)(struct kgsl_device *device, 135: struct kgsl_context *context, unsigned int timestamp, 136: unsigned int msecs); 137: int (*readtimestamp)(struct kgsl_device *device, void *priv, 138: enum kgsl_timestamp_type type, unsigned int *timestamp); 139: int (*queue_cmds)(struct kgsl_device_private *dev_priv, 140: struct kgsl_context *context, struct kgsl_drawobj *drawobj[], 141: uint32_t count, uint32_t *timestamp); 142: void (*power_stats)(struct kgsl_device *device, 143: struct kgsl_power_stats *stats); 144: void (*snapshot)(struct kgsl_device *device, 145: struct kgsl_snapshot *snapshot, struct kgsl_context *context, 146: struct kgsl_context *context_lpac); 147: /** @drain_and_idle: Drain the GPU and wait for it to idle */ 148: int (*drain_and_idle)(struct kgsl_device *device); 149: struct kgsl_device_private * (*device_private_create)(void); 150: void (*device_private_destroy)(struct kgsl_device_private *dev_priv); 151: /* 152: * Optional functions - these functions are not mandatory. The 153: * driver will check that the function pointer is not NULL before 154: * calling the hook 155: */ 156: struct kgsl_context *(*drawctxt_create) 157: (struct kgsl_device_private *dev_priv, 158: uint32_t *flags); 159: void (*drawctxt_detach)(struct kgsl_context *context); 160: void (*drawctxt_destroy)(struct kgsl_context *context); 161: void (*drawctxt_dump)(struct kgsl_device *device, 162: struct kgsl_context *context); 163: long (*ioctl)(struct kgsl_device_private *dev_priv, 164: unsigned int cmd, unsigned long arg); 165: long (*compat_ioctl)(struct kgsl_device_private *dev_priv, 166: unsigned int cmd, unsigned long arg); 167: int (*setproperty)(struct kgsl_device_private *dev_priv, 168: unsigned int type, void __user *value, 169: unsigned int sizebytes); MATCH LINES: 327, 329, 330, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 351, 355 315: atomic64_t total_mapped; 316: 317: wait_queue_head_t active_cnt_wq; 318: struct platform_device *pdev; 319: struct dentry *d_debugfs; 320: struct idr context_idr; 321: rwlock_t context_lock; 322: 323: struct { 324: void *ptr; 325: dma_addr_t dma_handle; 326: u32 size; 327: } snapshot_memory; 328: 329: struct kgsl_snapshot *snapshot; 330: /** @panic_nb: notifier block to capture GPU snapshot on kernel panic */ 331: struct notifier_block panic_nb; 332: struct { 333: void *ptr; 334: dma_addr_t dma_handle; 335: u32 size; 336: } snapshot_memory_atomic; 337: 338: u32 snapshot_faultcount; /* Total number of faults since boot */ 339: bool force_panic; /* Force panic after snapshot dump */ 340: bool skip_ib_capture; /* Skip IB capture after snapshot */ 341: bool prioritize_unrecoverable; /* Overwrite with new GMU snapshots */ 342: bool set_isdb_breakpoint; /* Set isdb registers before snapshot */ 343: bool snapshot_atomic; /* To capture snapshot in atomic context*/ 344: /* Use CP Crash dumper to get GPU snapshot*/ 345: bool snapshot_crashdumper; 346: /* Use HOST side register reads to get GPU snapshot*/ 347: bool snapshot_legacy; 348: /* Use to dump the context record in bytes */ 349: u64 snapshot_ctxt_record_size; 350: 351: struct kobject snapshot_kobj; 352: 353: struct kgsl_pwrscale pwrscale; 354: 355: int reset_counter; /* Track how many GPU core resets have occurred */ 356: struct kthread_worker *events_worker; 357: 358: /* Number of active contexts seen globally for this device */ 359: int active_context_count; 360: struct kobject gpu_sysfs_kobj; 361: unsigned int l3_freq[3]; 362: unsigned int num_l3_pwrlevels; 363: /* store current L3 vote to determine if we should change our vote */ 364: unsigned int cur_l3_pwrlevel; 365: /** @globals: List of global memory objects */ 366: struct list_head globals; 367: /** @globlal_map: bitmap for global memory allocations */ 368: unsigned long *global_map; 369: /* @qdss_desc: Memory descriptor for the QDSS region if applicable */ 370: struct kgsl_memdesc *qdss_desc; 371: /* @qtimer_desc: Memory descriptor for the QDSS region if applicable */ 372: struct kgsl_memdesc *qtimer_desc; 373: /** @event_groups: List of event groups for this device */ 374: struct list_head event_groups; 375: /** @event_groups_lock: A R/W lock for the events group list */ 376: rwlock_t event_groups_lock; 377: /** @speed_bin: Speed bin for the GPU device if applicable */ 378: u32 speed_bin; 379: /** @debug_bus_bin: Debug bus bin for the GPU device if applicable */ MATCH LINES: 415, 417, 418, 444, 448, 454, 491, 516 403: /** @work_period_lock: Lock to protect application GPU work periods */ 404: spinlock_t work_period_lock; 405: /** @work_period_ws: Work struct to emulate application GPU work events */ 406: struct work_struct work_period_ws; 407: /** @flags: Flags for gpu_period stats */ 408: unsigned long flags; 409: struct { 410: u64 begin; 411: u64 end; 412: } gpu_period; 413: /** @idle_jiffies: Latest idle jiffies */ 414: unsigned long idle_jiffies; 415: /** @dump_all_ibs: Whether to dump all ibs in snapshot */ 416: bool dump_all_ibs; 417: /** @freq_limiter_irq_clear: reset controller to clear freq limiter irq */ 418: struct reset_control *freq_limiter_irq_clear; 419: /** @freq_limiter_intr_num: The interrupt number for freq limiter */ 420: int freq_limiter_intr_num; 421: /** @cx_host_irq_num: Interrupt number for cx_host_irq */ 422: int cx_host_irq_num; 423: /** 424: * @max_syncobj_hw_fence_count: Maximum number of hardware fences that are allowed in a sync 425: * object 426: */ 427: u32 max_syncobj_hw_fence_count; 428: /** @file_mutex: Mutex to protect device open and close operations */ 429: struct mutex file_mutex; 430: /** @host_based_dcvs: Set when KGSL is in charge of DCVS */ 431: bool host_based_dcvs; 432: }; 433: 434: #define KGSL_MMU_DEVICE(_mmu) \ 435: container_of((_mmu), struct kgsl_device, mmu) 436: 437: /** 438: * enum bits for struct kgsl_context.priv 439: * @KGSL_CONTEXT_PRIV_SUBMITTED - The context has submitted commands to gpu. 440: * @KGSL_CONTEXT_PRIV_DETACHED - The context has been destroyed by userspace 441: * and is no longer using the gpu. 442: * @KGSL_CONTEXT_PRIV_INVALID - The context has been destroyed by the kernel 443: * because it caused a GPU fault. 444: * @KGSL_CONTEXT_PRIV_PAGEFAULT - The context has caused a page fault. 445: * @KGSL_CONTEXT_PRIV_DEVICE_SPECIFIC - this value and higher values are 446: * reserved for devices specific use. 447: * @KGSL_CONTEXT_PRIV_INVALID_DRAIN_HW_FENCE - this context got invalidated 448: * and needs its hardware fences drained after device reset 449: */ 450: enum kgsl_context_priv { 451: KGSL_CONTEXT_PRIV_SUBMITTED = 0, 452: KGSL_CONTEXT_PRIV_DETACHED, 453: KGSL_CONTEXT_PRIV_INVALID, 454: KGSL_CONTEXT_PRIV_PAGEFAULT, 455: KGSL_CONTEXT_PRIV_DEVICE_SPECIFIC = 16, 456: KGSL_CONTEXT_PRIV_INVALID_DRAIN_HW_FENCE, 457: }; 458: 459: struct kgsl_process_private; 460: 461: #define KGSL_MAX_FAULT_ENTRIES 40 462: 463: /* Maintain faults observed within threshold time (in milliseconds) */ 464: #define KGSL_MAX_FAULT_TIME_THRESHOLD 5000 465: 466: /** 467: * struct kgsl_fault_node - GPU fault descriptor 468: * @node: List node for list of faults 469: * @type: Type of fault 470: * @priv: Pointer to type specific fault 471: * @time: Time when fault was observed 472: */ 473: struct kgsl_fault_node { 474: struct list_head node; 475: u32 type; 476: void *priv; 477: ktime_t time; 478: }; 479: 480: /** 481: * struct kgsl_context - The context fields that are valid for a user defined 482: * context 483: * @refcount: kref object for reference counting the context 484: * @id: integer identifier for the context 485: * @priority; The context's priority to submit commands to GPU 486: * @tid: task that created this context. 487: * @dev_priv: pointer to the owning device instance 488: * @proc_priv: pointer to process private, the process that allocated the 489: * context 490: * @priv: in-kernel context flags, use KGSL_CONTEXT_* values 491: * @reset_status: status indication whether a gpu reset occurred and whether 492: * this context was responsible for causing it 493: * @timeline: sync timeline used to create fences that can be signaled when a 494: * sync_pt timestamp expires 495: * @events: A kgsl_event_group for this context - contains the list of GPU 496: * events 497: * @flags: flags from userspace controlling the behavior of this context 498: * @pwr_constraint: power constraint from userspace for this context 499: * @fault_count: number of times gpu hanged in last _context_throttle_time ms 500: * @fault_time: time of the first gpu hang in last _context_throttle_time ms 501: * @user_ctxt_record: memory descriptor used by CP to save/restore VPC data 502: * across preemption 503: * @total_fault_count: number of times gpu faulted in this context 504: * @last_faulted_cmd_ts: last faulted command batch timestamp 505: * @gmu_registered: whether context is registered with gmu or not 506: */ 507: struct kgsl_context { 508: struct kref refcount; 509: uint32_t id; 510: uint32_t priority; 511: pid_t tid; 512: struct kgsl_device_private *dev_priv; 513: struct kgsl_process_private *proc_priv; 514: unsigned long priv; 515: struct kgsl_device *device; 516: unsigned int reset_status; 517: struct kgsl_sync_timeline *ktimeline; 518: struct kgsl_event_group events; 519: unsigned int flags; 520: struct kgsl_pwr_constraint pwr_constraint; 521: struct kgsl_pwr_constraint l3_pwr_constraint; 522: unsigned int fault_count; 523: ktime_t fault_time; 524: struct kgsl_mem_entry *user_ctxt_record; 525: unsigned int total_fault_count; 526: unsigned int last_faulted_cmd_ts; 527: bool gmu_registered; 528: /** 529: * @gmu_dispatch_queue: dispatch queue id to which this context will be 530: * submitted 531: */ 532: u32 gmu_dispatch_queue; 533: /** @faults: List of @kgsl_fault_node to store fault information */ 534: struct list_head faults; 535: /** @fault_lock: Mutex to protect faults */ 536: struct mutex fault_lock; 537: /** @deferred_destroy_ws: Work struct used to destroy context in a deferred manner */ 538: struct work_struct deferred_destroy_ws; 539: }; 540: MATCH LINES: 651, 653, 654, 665, 674, 675, 676, 677, 678, 687, 688, 690, 720, 725, 726, 727, 729, 731, 733 639: */ 640: struct kobject kobj_memtype; 641: /** 642: * @private_mutex: Mutex lock to protect kgsl_process_private 643: */ 644: struct mutex private_mutex; 645: /** 646: * @cmdline: Cmdline string of the process 647: */ 648: char *cmdline; 649: /** @fault_count: Count of GPU faults from this process */ 650: u32 fault_count; 651: /** @pf_count: Total count of pagefaults from this process */ 652: u32 pf_count; 653: /** @pf_type_counts: Count of pagefaults of each type from this process */ 654: u32 pf_type_counts[KGSL_IOMMU_PAGEFAULT_TYPES]; 655: /** @profile: Container for the DCVS profile */ 656: struct kgsl_dcvs_profile_private profile; 657: }; 658: 659: struct kgsl_device_private { 660: struct kgsl_device *device; 661: struct kgsl_process_private *process_priv; 662: }; 663: 664: /** 665: * struct kgsl_snapshot - details for a specific snapshot instance 666: * @ib1base: Active IB1 base address at the time of fault 667: * @ib2base: Active IB2 base address at the time of fault 668: * @ib3base: Active IB3 base address at the time of fault 669: * @ib1size: Number of DWORDS pending in IB1 at the time of fault 670: * @ib2size: Number of DWORDS pending in IB2 at the time of fault 671: * @ib3size: Number of DWORDS pending in IB3 at the time of fault 672: * @ib1dumped: Active IB1 dump status to sansphot binary 673: * @ib2dumped: Active IB2 dump status to sansphot binary 674: * @start: Pointer to the start of the static snapshot region 675: * @size: Size of the current snapshot instance 676: * @ptr: Pointer to the next block of memory to write to during snapshotting 677: * @remain: Bytes left in the snapshot region 678: * @timestamp: Timestamp of the snapshot instance (in seconds since boot) 679: * @mempool: Pointer to the memory pool for storing memory objects 680: * @mempool_size: Size of the memory pool 681: * @obj_list: List of frozen GPU buffers that are waiting to be dumped. 682: * @cp_list: List of IB's to be dumped. 683: * @work: worker to dump the frozen memory 684: * @dump_gate: completion gate signaled by worker when it is finished. 685: * @process: the process that caused the hang, if known. 686: * @sysfs_read: Count of current reads via sysfs 687: * @first_read: True until the snapshot read is started 688: * @recovered: True if GPU was recovered after previous snapshot 689: */ 690: struct kgsl_snapshot { 691: u64 ib1base; 692: u64 ib2base; 693: u64 ib3base; 694: u32 ib1size; 695: u32 ib2size; 696: u32 ib3size; 697: bool ib1dumped; 698: bool ib2dumped; 699: u64 ib1base_lpac; 700: u64 ib2base_lpac; 701: u32 ib1size_lpac; 702: u32 ib2size_lpac; 703: bool ib1dumped_lpac; 704: bool ib2dumped_lpac; 705: u8 *start; 706: size_t size; 707: u8 *ptr; 708: size_t remain; 709: unsigned long timestamp; 710: u8 *mempool; 711: size_t mempool_size; 712: struct list_head obj_list; 713: struct list_head cp_list; 714: struct work_struct work; 715: struct completion dump_gate; 716: struct kgsl_process_private *process; 717: struct kgsl_process_private *process_lpac; 718: unsigned int sysfs_read; 719: bool first_read; 720: bool recovered; 721: struct kgsl_device *device; 722: }; 723: 724: /** 725: * struct kgsl_snapshot_object - GPU memory in the snapshot 726: * @gpuaddr: The GPU address identified during snapshot 727: * @size: The buffer size identified during snapshot 728: * @offset: offset from start of the allocated kgsl_mem_entry 729: * @type: SNAPSHOT_OBJ_TYPE_* identifier. 730: * @entry: the reference counted memory entry for this buffer 731: * @node: node for kgsl_snapshot.obj_list 732: */ 733: struct kgsl_snapshot_object { 734: uint64_t gpuaddr; 735: uint64_t size; 736: uint64_t offset; 737: int type; 738: struct kgsl_mem_entry *entry; 739: struct list_head node; 740: }; 741: 742: struct kgsl_device *kgsl_get_device(int dev_idx); 743: 744: static inline void kgsl_regread(struct kgsl_device *device, 745: unsigned int offsetwords, 746: unsigned int *value) 747: { 748: *value = kgsl_regmap_read(&device->regmap, offsetwords); 749: } 750: 751: static inline void kgsl_regread64(struct kgsl_device *device, 752: u32 offsetwords_lo, u32 offsetwords_hi, 753: u64 *value) 754: { 755: u32 val_lo = 0, val_hi = 0; 756: 757: val_lo = kgsl_regmap_read(&device->regmap, offsetwords_lo); MATCH LINES: 809, 813, 816, 818, 821 797: enum kgsl_timestamp_type type, unsigned int *timestamp); 798: 799: bool kgsl_check_timestamp(struct kgsl_device *device, 800: struct kgsl_context *context, unsigned int timestamp); 801: 802: int kgsl_device_platform_probe(struct kgsl_device *device); 803: 804: void kgsl_device_platform_remove(struct kgsl_device *device); 805: 806: const char *kgsl_pwrstate_to_str(unsigned int state); 807: 808: /** 809: * kgsl_device_snapshot_probe - add resources for the device GPU snapshot 810: * @device: The device to initialize 811: * @size: The size of the static region to allocate 812: * 813: * Allocate memory for a GPU snapshot for the specified device, 814: * and create the sysfs files to manage it 815: */ 816: void kgsl_device_snapshot_probe(struct kgsl_device *device, u32 size); 817: 818: void kgsl_device_snapshot(struct kgsl_device *device, 819: struct kgsl_context *context, struct kgsl_context *context_lpac, 820: bool gmu_fault); 821: void kgsl_device_snapshot_close(struct kgsl_device *device); 822: 823: void kgsl_events_init(void); 824: void kgsl_events_exit(void); 825: 826: /** 827: * kgsl_device_events_probe - Set up events for the KGSL device 828: * @device: A KGSL GPU device handle 829: * 830: * Set up the list and lock for GPU events for this device 831: */ 832: void kgsl_device_events_probe(struct kgsl_device *device); 833: 834: /** 835: * kgsl_device_events_remove - Remove all event groups from the KGSL device 836: * @device: A KGSL GPU device handle 837: * 838: * Remove all of the GPU event groups from the device and warn if any of them 839: * still have events pending 840: */ 841: void kgsl_device_events_remove(struct kgsl_device *device); 842: 843: void kgsl_context_detach(struct kgsl_context *context); 844: 845: /** MATCH LINES: 1101, 1103, 1106, 1110, 1115, 1118, 1119, 1123, 1124, 1125, 1126, 1134, 1136, 1137, 1140, 1144, 1150, 1153, 1154 1089: } 1090: 1091: void kgsl_process_private_put(struct kgsl_process_private *private); 1092: 1093: 1094: struct kgsl_process_private *kgsl_process_private_find(pid_t pid); 1095: 1096: /* 1097: * A helper macro to print out "not enough memory functions" - this 1098: * makes it easy to standardize the messages as well as cut down on 1099: * the number of strings in the binary 1100: */ 1101: #define SNAPSHOT_ERR_NOMEM(_d, _s) \ 1102: dev_err_ratelimited((_d)->dev, \ 1103: "snapshot: not enough snapshot memory for section %s\n", (_s)) 1104: 1105: /** 1106: * struct kgsl_snapshot_registers - list of registers to snapshot 1107: * @regs: Pointer to an array of register ranges 1108: * @count: Number of entries in the array 1109: */ 1110: struct kgsl_snapshot_registers { 1111: const unsigned int *regs; 1112: unsigned int count; 1113: }; 1114: 1115: size_t kgsl_snapshot_dump_registers(struct kgsl_device *device, u8 *buf, 1116: size_t remain, void *priv); 1117: 1118: void kgsl_snapshot_indexed_registers(struct kgsl_device *device, 1119: struct kgsl_snapshot *snapshot, unsigned int index, 1120: unsigned int data, unsigned int start, unsigned int count); 1121: 1122: /** 1123: * kgsl_snapshot_indexed_registers_v2 - Add a set of indexed registers to the 1124: * snapshot 1125: * @device: Pointer to the KGSL device being snapshotted 1126: * @snapshot: Snapshot instance 1127: * @index: Offset for the index register 1128: * @data: Offset for the data register 1129: * @start: Index to start reading 1130: * @count: Number of entries to read 1131: * @pipe_id: Pipe ID to be dumped 1132: * @slice_id: Slice ID to be dumped 1133: * 1134: * Dump the values from an indexed register group into the snapshot 1135: */ 1136: void kgsl_snapshot_indexed_registers_v2(struct kgsl_device *device, 1137: struct kgsl_snapshot *snapshot, u32 index, u32 data, 1138: u32 start, u32 count, u32 pipe_id, u32 slice_id); 1139: 1140: int kgsl_snapshot_get_object(struct kgsl_snapshot *snapshot, 1141: struct kgsl_process_private *process, uint64_t gpuaddr, 1142: uint64_t size, unsigned int type); 1143: 1144: int kgsl_snapshot_have_object(struct kgsl_snapshot *snapshot, 1145: struct kgsl_process_private *process, 1146: uint64_t gpuaddr, uint64_t size); 1147: 1148: struct adreno_ib_object_list; 1149: 1150: int kgsl_snapshot_add_ib_obj_list(struct kgsl_snapshot *snapshot, 1151: struct adreno_ib_object_list *ib_obj_list); 1152: 1153: void kgsl_snapshot_add_section(struct kgsl_device *device, u16 id, 1154: struct kgsl_snapshot *snapshot, 1155: size_t (*func)(struct kgsl_device *, u8 *, size_t, void *), 1156: void *priv); 1157: 1158: /** 1159: * kgsl_of_property_read_ddrtype - Get property from devicetree based on 1160: * the type of DDR. 1161: * @node: Devicetree node 1162: * @base: prefix string of the property 1163: * @ptr: Pointer to store the value of the property 1164: * 1165: * First look up the devicetree property based on the prefix string and DDR 1166: * type. If property is not specified per DDR type, then look for the property 1167: * based on prefix string only. 1168: * 1169: * Return: 0 on success or error code on failure. 1170: */ 1171: int kgsl_of_property_read_ddrtype(struct device_node *node, const char *base, 1172: u32 *ptr); 1173: 1174: /** 1175: * kgsl_query_property_list - Get a list of valid properties 1176: * @device: A KGSL device handle 1177: * @list: Pointer to a list of u32s 1178: * @count: Number of items in @list --- FILE: \kgsl_drawobj.h | HITS: 2 --- MATCH LINES: 57, 78 45: }; 46: 47: /** 48: * struct kgsl_drawobj_cmd - KGSL command obj, This covers marker 49: * cmds also since markers are special form of cmds that do not 50: * need their cmds to be executed. 51: * @base: Base kgsl_drawobj, this needs to be the first entry 52: * @priv: Internal flags 53: * @global_ts: The ringbuffer timestamp corresponding to this 54: * command obj 55: * @fault_policy: Internal policy describing how to handle this command in case 56: * of a fault 57: * @fault_recovery: recovery actions actually tried for this batch 58: * be hung 59: * @refcount: kref structure to maintain the reference count 60: * @cmdlist: List of IBs to issue 61: * @memlist: List of all memory used in this command batch 62: * @marker_timestamp: For markers, the timestamp of the last "real" command that 63: * was queued 64: * @profiling_buf_entry: Mem entry containing the profiling buffer 65: * @profiling_buffer_gpuaddr: GPU virt address of the profile buffer added here 66: * for easy access 67: * @profile_index: Index to store the start/stop ticks in the kernel profiling 68: * buffer 69: * @submit_ticks: Variable to hold ticks at the time of 70: * command obj submit. 71: 72: */ 73: struct kgsl_drawobj_cmd { 74: struct kgsl_drawobj base; 75: unsigned long priv; 76: unsigned int global_ts; 77: unsigned long fault_policy; 78: unsigned long fault_recovery; 79: struct list_head cmdlist; 80: struct list_head memlist; 81: unsigned int marker_timestamp; 82: struct kgsl_mem_entry *profiling_buf_entry; 83: uint64_t profiling_buffer_gpuaddr; 84: unsigned int profile_index; 85: uint64_t submit_ticks; 86: /* @numibs: Number of ibs in this cmdobj */ 87: u32 numibs; 88: /* @requeue_cnt: Number of times cmdobj was requeued before submission to dq succeeded */ 89: u32 requeue_cnt; 90: }; 91: 92: /* This sync object cannot be sent to hardware */ 93: #define KGSL_SYNCOBJ_SW 0 94: /* This sync object can be sent to hardware */ 95: #define KGSL_SYNCOBJ_HW 1 96: /* This hw sync object has been assigned a timestamp */ 97: #define KGSL_SYNCOBJ_HW_TS 2 98: 99: struct kgsl_drawobj_sync_hw_fence { 100: /** @fence: Pointer to hardware fence */ 101: struct dma_fence *fence; 102: /** --- FILE: \kgsl_eventlog.c | HITS: 9 --- MATCH LINES: 14, 21, 22 2: /* 3: * Copyright (c) 2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #include 8: #include 9: #include 10: #include 11: 12: #include "kgsl_device.h" 13: #include "kgsl_eventlog.h" 14: #include "kgsl_snapshot.h" 15: #include "kgsl_util.h" 16: 17: #define EVENTLOG_SIZE (SZ_64K + SZ_32K) 18: #define MAGIC 0xabbaabba 19: #define LOG_FENCE_NAME_LEN 74 20: 21: #define KGSL_SNAPSHOT_EVENTLOG_TYPE 0x1 22: #define KGSL_SNAPSHOT_EVENTLOG_VERSION 0x0 23: 24: /* 25: * This an internal event used to skip empty space at the bottom of the 26: * ringbuffer 27: */ 28: 29: #define LOG_SKIP 1 30: #define LOG_FIRE_EVENT 2 31: #define LOG_CMDBATCH_SUBMITTED_EVENT 3 32: #define LOG_CMDBATCH_RETIRED_EVENT 4 33: #define LOG_SYNCPOINT_FENCE_EVENT 5 34: #define LOG_SYNCPOINT_FENCE_EXPIRE_EVENT 6 35: #define LOG_TIMELINE_FENCE_ALLOC_EVENT 7 36: #define LOG_TIMELINE_FENCE_RELEASE_EVENT 8 37: #define LOG_CX_WAIT_TIMEOUT_EVENT 9 38: 39: static spinlock_t lock; 40: static void *kgsl_eventlog; 41: static int eventlog_wptr; 42: 43: struct kgsl_log_header { 44: /** @magic: Magic value to identify header */ 45: u32 magic; 46: /** @pid: : PID of the process */ MATCH LINES: 258, 261, 262, 270, 275, 276 246: { 247: struct __packed { 248: u32 timeout_vote; 249: } *entry; 250: 251: entry = kgsl_eventlog_alloc(LOG_CX_WAIT_TIMEOUT_EVENT, sizeof(*entry)); 252: if (!entry) 253: return; 254: 255: entry->timeout_vote = timeout_vote; 256: } 257: 258: size_t kgsl_snapshot_eventlog_buffer(struct kgsl_device *device, 259: u8 *buf, size_t remain, void *priv) 260: { 261: struct kgsl_snapshot_eventlog *hdr = 262: (struct kgsl_snapshot_eventlog *)buf; 263: u32 *data = (u32 *)(buf + sizeof(*hdr)); 264: 265: if (!kgsl_eventlog) 266: return 0; 267: 268: if (remain < EVENTLOG_SIZE + sizeof(*hdr)) { 269: dev_err(device->dev, 270: "snapshot: Not enough memory for eventlog\n"); 271: return 0; 272: } 273: 274: hdr->size = EVENTLOG_SIZE; 275: hdr->type = KGSL_SNAPSHOT_EVENTLOG_TYPE; 276: hdr->version = KGSL_SNAPSHOT_EVENTLOG_VERSION; 277: memcpy(data, kgsl_eventlog, EVENTLOG_SIZE); 278: 279: return EVENTLOG_SIZE + sizeof(*hdr); 280: } --- FILE: \kgsl_eventlog.h | HITS: 1 --- MATCH LINES: 25 13: void kgsl_eventlog_init(void); 14: void kgsl_eventlog_exit(void); 15: 16: void log_kgsl_fire_event(u32 id, u32 ts, u32 type, u32 age); 17: void log_kgsl_cmdbatch_submitted_event(u32 id, u32 ts, u32 prio, u64 flags); 18: void log_kgsl_cmdbatch_retired_event(u32 id, u32 ts, u32 prio, u64 flags, 19: u64 start, u64 retire); 20: void log_kgsl_syncpoint_fence_event(u32 id, char *fence_name); 21: void log_kgsl_syncpoint_fence_expire_event(u32 id, char *fence_name); 22: void log_kgsl_timeline_fence_alloc_event(u32 id, u64 seqno); 23: void log_kgsl_timeline_fence_release_event(u32 id, u64 seqno); 24: void log_kgsl_cx_wait_timeout_event(u32 timeout_vote); 25: size_t kgsl_snapshot_eventlog_buffer(struct kgsl_device *device, 26: u8 *buf, size_t remain, void *priv); 27: #endif --- FILE: \kgsl_gmu_core.c | HITS: 23 --- MATCH LINES: 147, 152, 153, 186, 195 135: 136: return 0; 137: } 138: 139: void gmu_core_dev_oob_clear(struct kgsl_device *device, enum oob_request req) 140: { 141: const struct gmu_dev_ops *ops = GMU_DEVICE_OPS(device); 142: 143: if (ops && ops->oob_clear) 144: ops->oob_clear(device, req); 145: } 146: 147: void gmu_core_dev_cooperative_reset(struct kgsl_device *device) 148: { 149: 150: const struct gmu_dev_ops *ops = GMU_DEVICE_OPS(device); 151: 152: if (ops && ops->cooperative_reset) 153: ops->cooperative_reset(device); 154: } 155: 156: int gmu_core_dev_ifpc_isenabled(struct kgsl_device *device) 157: { 158: const struct gmu_dev_ops *ops = GMU_DEVICE_OPS(device); 159: 160: if (ops && ops->ifpc_isenabled) 161: return ops->ifpc_isenabled(device); 162: 163: return 0; 164: } 165: 166: int gmu_core_dev_ifpc_store(struct kgsl_device *device, unsigned int val) 167: { 168: const struct gmu_dev_ops *ops = GMU_DEVICE_OPS(device); 169: 170: if (ops && ops->ifpc_store) 171: return ops->ifpc_store(device, val); 172: 173: return -EINVAL; 174: } 175: 176: int gmu_core_dev_wait_for_active_transition(struct kgsl_device *device) 177: { 178: const struct gmu_dev_ops *ops = GMU_DEVICE_OPS(device); 179: 180: if (ops && ops->wait_for_active_transition) 181: return ops->wait_for_active_transition(device); 182: 183: return 0; 184: } 185: 186: void gmu_core_fault_snapshot(struct kgsl_device *device, 187: enum gmu_fault_panic_policy gf_policy) 188: { 189: const struct gmu_dev_ops *ops = GMU_DEVICE_OPS(device); 190: 191: /* Send NMI first to halt GMU and capture the state close to the point of failure */ 192: if (ops && ops->send_nmi) 193: ops->send_nmi(device, false, gf_policy); 194: 195: kgsl_device_snapshot(device, NULL, NULL, true); 196: } 197: 198: int gmu_core_timed_poll_check(struct kgsl_device *device, 199: unsigned int offset, unsigned int expected_ret, 200: unsigned int timeout_ms, unsigned int mask) 201: { 202: u32 val; 203: 204: return kgsl_regmap_read_poll_timeout(&device->regmap, offset, 205: val, (val & mask) == expected_ret, 100, timeout_ms * 1000); 206: } 207: 208: int gmu_core_map_memdesc(struct iommu_domain *domain, struct kgsl_memdesc *memdesc, 209: u64 gmuaddr, int attrs) 210: { 211: ssize_t mapped; 212: 213: if (!memdesc->pages) { 214: mapped = kgsl_mmu_map_sg(domain, gmuaddr, memdesc->sgt->sgl, 215: memdesc->sgt->nents, attrs); 216: } else { 217: struct sg_table sgt = { 0 }; 218: int ret; 219: MATCH LINES: 679, 684, 686, 688, 690, 694, 730, 735, 736 667: return 0; 668: 669: /* Check if the block is already allocated */ 670: md = gmu_core_find_memdesc(device, blk->addr, blk->value); 671: if (md != NULL) 672: return 0; 673: 674: md = gmu_core_reserve_kernel_block(device, blk->addr, blk->value, id, 0); 675: 676: return PTR_ERR_OR_ZERO(md); 677: } 678: 679: static int gmu_core_iommu_fault_handler(struct iommu_domain *domain, 680: struct device *dev, unsigned long addr, int flags, void *token) 681: { 682: char *fault_type = "unknown"; 683: 684: if (flags & IOMMU_FAULT_TRANSLATION) 685: fault_type = "translation"; 686: else if (flags & IOMMU_FAULT_PERMISSION) 687: fault_type = "permission"; 688: else if (flags & IOMMU_FAULT_EXTERNAL) 689: fault_type = "external"; 690: else if (flags & IOMMU_FAULT_TRANSACTION_STALLED) 691: fault_type = "transaction stalled"; 692: 693: dev_err(dev, "GMU fault addr = %lX, context=kernel (%s %s fault)\n", 694: addr, (flags & IOMMU_FAULT_WRITE) ? "write" : "read", fault_type); 695: 696: return 0; 697: } 698: 699: #if (KERNEL_VERSION(6, 13, 0) <= LINUX_VERSION_CODE) 700: static struct iommu_domain *gmu_core_iommu_domain_alloc(struct device *dev) 701: { 702: return iommu_paging_domain_alloc(dev); 703: } 704: #else 705: #include 706: static struct iommu_domain *gmu_core_iommu_domain_alloc(struct device *dev) 707: { 708: return iommu_domain_alloc(&platform_bus_type); 709: } 710: #endif 711: 712: int gmu_core_iommu_init(struct kgsl_device *device) 713: { 714: struct device *gmu_pdev_dev = GMU_PDEV_DEV(device); 715: int ret; 716: 717: device->gmu_core.domain = gmu_core_iommu_domain_alloc(gmu_pdev_dev); 718: if (IS_ERR_OR_NULL(device->gmu_core.domain)) { 719: ret = (device->gmu_core.domain) ? PTR_ERR(device->gmu_core.domain) : -ENODEV; 720: dev_err(gmu_pdev_dev, "Unable to allocate GMU IOMMU domain: %d\n", ret); 721: return ret; 722: } 723: 724: /* 725: * Disable stall on fault for the GMU context bank. 726: * This sets SCTLR.CFCFG = 0. 727: * Also note that, the smmu driver sets SCTLR.HUPCF = 0 by default. 728: */ 729: qcom_iommu_set_fault_model(device->gmu_core.domain, 730: QCOM_IOMMU_FAULT_MODEL_NO_STALL); 731: 732: ret = kgsl_attach_iommu_group(gmu_pdev_dev, device->gmu_core.domain, 733: &device->gmu_core.group); 734: if (!ret) { 735: iommu_set_fault_handler(device->gmu_core.domain, 736: gmu_core_iommu_fault_handler, device); 737: return 0; 738: } 739: 740: dev_err(gmu_pdev_dev, "Unable to attach GMU IOMMU domain: %d\n", ret); 741: iommu_domain_free(device->gmu_core.domain); 742: device->gmu_core.domain = NULL; 743: 744: return ret; 745: } 746: 747: void gmu_core_dev_force_first_boot(struct kgsl_device *device) 748: { 749: const struct gmu_dev_ops *ops = GMU_DEVICE_OPS(device); 750: 751: if (ops && ops->force_first_boot) 752: return ops->force_first_boot(device); 753: } 754: 755: int gmu_core_set_vrb_register(struct kgsl_memdesc *vrb, u32 index, u32 val) 756: { 757: u32 *vrb_buf; 758: 759: if (WARN_ON(IS_ERR_OR_NULL(vrb))) 760: return -ENODEV; MATCH LINES: 967, 981, 987, 993 955: buffer = trace->md->hostptr; 956: 957: ridx = readl(&trace_hdr->read_index); 958: widx = readl(&trace_hdr->write_index); 959: 960: if (ridx == widx) 961: return; 962: 963: /* 964: * Don't process any traces and force set read_index to write_index if 965: * previously encountered invalid trace packet 966: */ 967: if (trace->reset_hdr) { 968: /* update read index to let f2h daemon to go to sleep */ 969: writel(trace_hdr->write_index, &trace_hdr->read_index); 970: return; 971: } 972: 973: /* start reading trace buffer data */ 974: pkt = (struct gmu_trace_packet *)&buffer[trace_hdr->payload_offset + ridx]; 975: 976: /* Validate packet header */ 977: if (TRACE_PKT_GET_VALID_FIELD(pkt->hdr) != TRACE_PKT_VALID) { 978: char str[128]; 979: 980: snprintf(str, sizeof(str), 981: "Invalid trace packet found at read index: %d resetting trace header\n", 982: trace_hdr->read_index); 983: /* 984: * GMU is not expected to write an invalid trace packet. This 985: * condition can be true in case there is memory corruption. In 986: * such scenario fastforward readindex to writeindex so the we 987: * don't process any trace packets until we reset the trace 988: * header in next slumber exit. 989: */ 990: dev_err_ratelimited(device->dev, "%s\n", str); 991: trace_kgsl_msg(str); 992: writel(trace_hdr->write_index, &trace_hdr->read_index); 993: trace->reset_hdr = true; 994: return; 995: } 996: 997: size = TRACE_PKT_GET_SIZE(pkt->hdr); 998: 999: if (TRACE_PKT_GET_SKIP_FIELD(pkt->hdr)) 1000: goto done; 1001: 1002: seq_num = TRACE_PKT_GET_SEQNUM(pkt->hdr); 1003: num_pkts = seq_num - trace->seq_num; 1004: 1005: /* Detect trace packet loss by tracking any gaps in the sequence number */ 1006: if (num_pkts > 1) { 1007: char str[128]; 1008: 1009: snprintf(str, sizeof(str), 1010: "%d GMU trace packets dropped from sequence number: %d\n", 1011: num_pkts - 1, trace->seq_num); 1012: trace_kgsl_msg(str); 1013: } 1014: 1015: trace->seq_num = seq_num; 1016: stream_trace_data(device, pkt); 1017: done: MATCH LINES: 1040, 1042, 1046, 1049 1028: { 1029: struct gmu_trace_header *hdr = trace->md->hostptr; 1030: 1031: hdr->threshold = TRACE_BUFFER_THRESHOLD; 1032: hdr->timeout = TRACE_TIMEOUT_MSEC; 1033: hdr->metadata = FIELD_PREP(GENMASK(31, 30), TRACE_MODE_DROP) | 1034: FIELD_PREP(GENMASK(3, 0), TRACE_HEADER_VERSION_1); 1035: hdr->cookie = trace->md->gmuaddr; 1036: hdr->size = trace->md->size; 1037: hdr->log_type = TRACE_LOGTYPE_HWSCHED; 1038: } 1039: 1040: void gmu_core_reset_trace_header(struct kgsl_gmu_trace *trace) 1041: { 1042: if (!trace->reset_hdr || IS_ERR_OR_NULL(trace->md)) 1043: return; 1044: 1045: memset(trace->md->hostptr, 0, sizeof(struct gmu_trace_header)); 1046: /* Reset sequence number to detect trace packet loss */ 1047: trace->seq_num = 0; 1048: gmu_core_trace_header_init(trace); 1049: trace->reset_hdr = false; 1050: } 1051: 1052: int gmu_core_soccp_vote(struct kgsl_device *device, bool pwr_on) 1053: { 1054: int ret; 1055: 1056: if (!(test_bit(GMU_SOCCP_VOTE_ON, &device->gmu_core.flags) ^ pwr_on)) 1057: return 0; 1058: 1059: ret = kgsl_hw_fence_soccp_vote(pwr_on); 1060: if (!ret) { 1061: change_bit(GMU_SOCCP_VOTE_ON, &device->gmu_core.flags); 1062: return 0; 1063: } 1064: 1065: dev_err(GMU_PDEV_DEV(device), "soccp power %s failed: %d. Disabling hw fences\n", 1066: pwr_on ? "on" : "off", ret); 1067: 1068: return ret; 1069: } 1070: 1071: bool gmu_core_capabilities_enabled(struct firmware_capabilities *caps, u32 field) 1072: { 1073: if (!caps->length || !caps->data) MATCH LINES: 1310 1298: trace_kgsl_gmu_pwrlevel(req_freq, gmu_core->freqs[gmu_core->cur_level]); 1299: 1300: gmu_core->cur_level = gmu_level; 1301: 1302: return scale_hub_clock(device, gmu_core->vlvls[gmu_level]); 1303: } 1304: 1305: int gmu_core_enable_clks(struct kgsl_device *device, u32 level) 1306: { 1307: struct gmu_core_device *gmu = &device->gmu_core; 1308: int ret; 1309: 1310: /* Reset hub clock level */ 1311: gmu->cur_hub_level = gmu->num_hub_freqs; 1312: 1313: ret = gmu_core_clock_set_rate(device, level); 1314: if (ret) 1315: return ret; 1316: 1317: ret = clk_bulk_prepare_enable(gmu->num_clks, gmu->clks); 1318: if (ret) { 1319: dev_err(GMU_PDEV_DEV(device), "Cannot enable GMU clocks ret %d\n", ret); 1320: return ret; 1321: } 1322: 1323: device->state = KGSL_STATE_AWARE; 1324: 1325: return 0; 1326: } 1327: 1328: void gmu_core_disable_clks(struct kgsl_device *device) 1329: { 1330: struct gmu_core_device *gmu = &device->gmu_core; 1331: 1332: clk_bulk_disable_unprepare(gmu->num_clks, gmu->clks); 1333: } 1334: --- FILE: \kgsl_gmu_core.h | HITS: 14 --- MATCH LINES: 51, 58, 59, 64 39: 40: enum gmu_common_capabilities { 41: FCC_VERSION_INFO = 0, 42: }; 43: 44: enum gmu_platform_capabilities { 45: FAC_TRACE_BUFFER = 0, 46: FAC_VRB_HW_FENCE_SHADOW_NUM_ENTRIES = 1, 47: FAC_VRB_CL_NO_FT_TIMEOUT = 2, 48: FAC_VRB_PREEMPT_COUNT = 3, 49: FAC_RBBM_INTERRUPTS_HANDLE_ALL = 4, 50: FAC_FORCE_RETIRE_COMMAND = 5, 51: FAC_SOFT_RESET = 6, 52: FAC_FAST_CONTEXT_DESTROY = 7, 53: FAC_POWER_CONTROL_WA = 8, 54: }; 55: 56: /* 57: * These are the different ways the GMU can boot. GMU_WARM_BOOT is waking up 58: * from slumber. GMU_COLD_BOOT is booting for the first time. GMU_RESET 59: * is a soft reset of the GMU. 60: */ 61: enum gmu_core_boot { 62: GMU_WARM_BOOT = 0, 63: GMU_COLD_BOOT = 1, 64: GMU_RESET = 2 65: }; 66: 67: /* Bits for the flags field in the gmu structure */ 68: enum gmu_core_flags { 69: GMU_BOOT_INIT_DONE = 0, 70: GMU_HFI_ON, 71: GMU_FAULT, 72: GMU_DCVS_REPLAY, 73: GMU_ENABLED, 74: GMU_RSCC_SLEEP_SEQ_DONE, 75: GMU_DISABLE_SLUMBER, 76: GMU_THERMAL_MITIGATION, 77: GMU_FORCE_COLDBOOT, 78: GMU_SOCCP_VOTE_ON, 79: }; 80: 81: /* 82: * OOB requests values. These range from 0 to 7 and then 83: * the BIT() offset into the actual value is calculated 84: * later based on the request. This keeps the math clean 85: * and easy to ensure not reaching over/under the range 86: * of 8 bits. 87: */ 88: enum oob_request { MATCH LINES: 419, 420 407: u32 profile; 408: struct kgsl_dcvs_attrs attrs; 409: } __packed; 410: 411: /** 412: * struct kgsl_gmu_trace - wrapper for gmu trace memory object 413: */ 414: struct kgsl_gmu_trace { 415: /** @md: gmu trace memory descriptor */ 416: struct kgsl_memdesc *md; 417: /* @seq_num: GMU trace packet sequence number to detect drop packet count */ 418: u16 seq_num; 419: /* @reset_hdr: To reset trace buffer header incase of invalid packet */ 420: bool reset_hdr; 421: }; 422: 423: /* GMU memdesc entries */ 424: #define GMU_KERNEL_ENTRIES 32 425: 426: enum gmu_mem_type { 427: GMU_ITCM = 0, 428: GMU_ICACHE, 429: GMU_CACHE = GMU_ICACHE, 430: GMU_DTCM, 431: GMU_DCACHE, 432: GMU_NONCACHED_KERNEL, /* GMU VBIF3 uncached VA range: 0x60000000 - 0x7fffffff */ 433: GMU_NONCACHED_KERNEL_EXTENDED, /* GMU VBIF3 uncached VA range: 0xc0000000 - 0xdfffffff */ 434: GMU_NONCACHED_USER, 435: GMU_MEM_TYPE_MAX, 436: }; 437: 438: /** 439: * struct gmu_memdesc - Gmu shared memory object descriptor 440: * @hostptr: Kernel virtual address 441: * @gmuaddr: GPU virtual address 442: * @physaddr: Physical address of the memory object 443: * @size: Size of the memory object 444: */ MATCH LINES: 493, 531 481: GMU_PRIV_HFI_STARTED, 482: GMU_PRIV_RSCC_SLEEP_DONE, 483: GMU_PRIV_PM_SUSPEND, 484: GMU_PRIV_PDC_RSC_LOADED, 485: /* Indicates if GMU INIT HFI messages are recorded successfully */ 486: GMU_PRIV_WARMBOOT_GMU_INIT_DONE, 487: /* Indicates if GPU BOOT HFI messages are recorded successfully */ 488: GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, 489: }; 490: 491: struct device_node; 492: struct kgsl_device; 493: struct kgsl_snapshot; 494: 495: #define GMU_FAULT_PANIC_NONE 0 496: enum gmu_fault_panic_policy { 497: GMU_FAULT_DEVICE_START = 1, 498: GMU_FAULT_HFI_INIT, 499: GMU_FAULT_OOB_SET, 500: GMU_FAULT_HFI_RECIVE_ACK, 501: GMU_FAULT_SEND_CMD_WAIT_INLINE, 502: GMU_FAULT_HFI_SEND_GENERIC_REQ, 503: GMU_FAULT_F2H_MSG_ERR, 504: GMU_FAULT_H2F_MSG_START, 505: GMU_FAULT_WAIT_ACK_COMPLETION, 506: GMU_FAULT_HFI_ACK, 507: GMU_FAULT_CTX_UNREGISTER, 508: GMU_FAULT_WAIT_FOR_LOWEST_IDLE, 509: GMU_FAULT_WAIT_FOR_IDLE, 510: GMU_FAULT_HW_FENCE, 511: GMU_FAULT_WAIT_FOR_CX, 512: GMU_FAULT_CX_WAIT_TIMEOUT, 513: GMU_FAULT_CM3, 514: GMU_FAULT_MAX, 515: }; 516: 517: #define KGSL_GMU_CORE_FORCE_PANIC(gf_panic, pdev, ticks, policy) do { \ 518: if (gf_panic & BIT(policy)) { \ 519: dev_err(&pdev->dev, \ 520: "GMU always on ticks: %llx gf_policy: 0x%x gf_trigger: 0x%lx\n", \ 521: ticks, gf_panic, BIT(policy));\ 522: BUG();\ 523: } \ 524: } while (0) 525: 526: struct gmu_dev_ops { 527: int (*oob_set)(struct kgsl_device *device, enum oob_request req); 528: void (*oob_clear)(struct kgsl_device *device, enum oob_request req); 529: int (*ifpc_store)(struct kgsl_device *device, unsigned int val); 530: unsigned int (*ifpc_isenabled)(struct kgsl_device *device); 531: void (*cooperative_reset)(struct kgsl_device *device); 532: int (*wait_for_active_transition)(struct kgsl_device *device); 533: bool (*scales_bandwidth)(struct kgsl_device *device); 534: int (*acd_set)(struct kgsl_device *device, bool val); 535: int (*bcl_sid_set)(struct kgsl_device *device, u32 sid_id, u64 sid_val); 536: u64 (*bcl_sid_get)(struct kgsl_device *device, u32 sid_id); 537: void (*force_first_boot)(struct kgsl_device *device); 538: void (*send_nmi)(struct kgsl_device *device, bool force, 539: enum gmu_fault_panic_policy gf_policy); 540: void (*minbw_idle_level_set)(struct kgsl_device *device, u32 val); 541: }; 542: 543: struct firmware_capabilities { 544: u32 length; 545: u8 *data; 546: }; 547: 548: /** 549: * struct gmu_core_device - GMU Core device structure 550: * @ptr: Pointer to GMU device structure 551: * @dev_ops: Pointer to gmu device operations 552: * @flags: GMU flags 553: */ 554: struct gmu_core_device { 555: void *ptr; MATCH LINES: 669, 672, 676, 678 657: * delays that could allow IRQs arrive and be serviced before finishing 658: * all the writes. 659: */ 660: void gmu_core_blkwrite(struct kgsl_device *device, unsigned int offsetwords, 661: const void *buffer, size_t size); 662: void gmu_core_regrmw(struct kgsl_device *device, unsigned int offsetwords, 663: unsigned int mask, unsigned int bits); 664: int gmu_core_dev_oob_set(struct kgsl_device *device, enum oob_request req); 665: void gmu_core_dev_oob_clear(struct kgsl_device *device, enum oob_request req); 666: int gmu_core_dev_ifpc_isenabled(struct kgsl_device *device); 667: int gmu_core_dev_ifpc_store(struct kgsl_device *device, unsigned int val); 668: int gmu_core_dev_wait_for_active_transition(struct kgsl_device *device); 669: void gmu_core_dev_cooperative_reset(struct kgsl_device *device); 670: 671: /** 672: * gmu_core_fault_snapshot - Set gmu fault and trigger snapshot 673: * @device: Pointer to the kgsl device 674: * @gf_policy: GMU fault panic setting policy 675: * 676: * Set the gmu fault and take snapshot when we hit a gmu fault 677: */ 678: void gmu_core_fault_snapshot(struct kgsl_device *device, 679: enum gmu_fault_panic_policy gf_policy); 680: 681: /** 682: * gmu_core_timed_poll_check() - polling *gmu* register at given offset until 683: * its value changed to match expected value. The function times 684: * out and returns after given duration if register is not updated 685: * as expected. 686: * 687: * @device: Pointer to KGSL device 688: * @offset: Register offset in dwords 689: * @expected_ret: expected register value that stops polling 690: * @timeout_ms: time in milliseconds to poll the register 691: * @mask: bitmask to filter register value to match expected_ret 692: */ 693: int gmu_core_timed_poll_check(struct kgsl_device *device, 694: unsigned int offset, unsigned int expected_ret, 695: unsigned int timeout_ms, unsigned int mask); 696: 697: struct kgsl_memdesc; 698: struct iommu_domain; 699: struct hfi_mem_alloc_entry; 700: 701: struct gmu_mem_type_desc { 702: /** @memdesc: Pointer to the memory descriptor */ MATCH LINES: 895, 898 883: * 884: * Return: true if readidex equl to writeindex else false 885: */ 886: bool gmu_core_is_trace_empty(struct gmu_trace_header *hdr); 887: 888: /** 889: * gmu_core_trace_header_init - Initialize the GMU trace buffer header 890: * @trace: Pointer to kgsl gmu trace 891: */ 892: void gmu_core_trace_header_init(struct kgsl_gmu_trace *trace); 893: 894: /** 895: * gmu_core_reset_trace_header - Reset GMU trace buffer header 896: * @trace: Pointer to kgsl gmu trace 897: */ 898: void gmu_core_reset_trace_header(struct kgsl_gmu_trace *trace); 899: 900: /** 901: * gmu_core_soccp_vote - vote for soccp power 902: * @device: Pointer to kgsl device 903: * @pwr_on: Boolean to indicate vote on or off 904: 905: * Return: Negative error on failure and zero on success. 906: */ 907: int gmu_core_soccp_vote(struct kgsl_device *device, bool pwr_on); 908: 909: /** 910: * gmu_core_capabilities_enabled - Check specific capabilities are enabled or not 911: * @caps: Pointer to struct firmware_capabilities 912: * @field: Common/Platform capabilities bit field value 913: 914: * Return: true if capabilities value is being set otherwise false 915: */ 916: bool gmu_core_capabilities_enabled(struct firmware_capabilities *caps, u32 field); 917: 918: /** 919: * gmu_core_mark_for_coldboot - Set a flag to coldboot gpu in the slumber exit 920: * @device: Pointer to KGSL device 921: * 922: */ --- FILE: \kgsl_iommu.c | HITS: 91 --- MATCH LINES: 873 861: { 862: if (!memdesc->gpuaddr) { 863: if (kgsl_iommu_reserve_global_gpuaddr(mmu, memdesc, padding)) 864: return; 865: } 866: 867: if (memdesc->flags & KGSL_MEMFLAGS_SECURE) 868: kgsl_iommu_secure_map(mmu->securepagetable, memdesc); 869: else 870: kgsl_iommu_default_map(mmu->defaultpagetable, memdesc); 871: } 872: 873: /* Print the mem entry for the pagefault debugging */ 874: static void print_entry(struct device *dev, struct kgsl_mem_entry *entry, 875: pid_t pid) 876: { 877: char name[32]; 878: 879: if (!entry) { 880: dev_crit(dev, "**EMPTY**\n"); 881: return; 882: } 883: 884: kgsl_get_memory_usage(name, sizeof(name), entry->memdesc.flags); 885: 886: dev_err(dev, "[%016llX - %016llX] %s %s (pid = %d) (%s)\n", 887: entry->memdesc.gpuaddr, 888: entry->memdesc.gpuaddr + entry->memdesc.size - 1, 889: TEST_FLAG(KGSL_MEMDESC_GUARD_PAGE, &entry->memdesc.priv) ? "(+guard)" : "", 890: entry->pending_free ? "(pending free)" : "", 891: pid, name); 892: } 893: 894: /* Check if the address in the list of recently freed memory */ 895: static void kgsl_iommu_check_if_freed(struct device *dev, 896: struct kgsl_iommu_context *context, u64 addr, u32 ptname) 897: { MATCH LINES: 940, 946, 950, 951, 952, 953, 954, 955, 956, 957, 959, 960, 964, 977, 979, 987, 988, 991, 1001, 1002 928: return p; 929: } 930: } 931: 932: read_unlock(&kgsl_driver.proclist_lock); 933: 934: return NULL; 935: } 936: 937: static void kgsl_iommu_add_fault_info(struct kgsl_context *context, 938: unsigned long addr, int flags) 939: { 940: struct kgsl_pagefault_report *report; 941: u32 fault_flag = 0; 942: 943: if (!context || !(context->flags & KGSL_CONTEXT_FAULT_INFO)) 944: return; 945: 946: report = kzalloc(sizeof(struct kgsl_pagefault_report), GFP_KERNEL); 947: if (!report) 948: return; 949: 950: if (flags & IOMMU_FAULT_TRANSLATION) 951: fault_flag = KGSL_PAGEFAULT_TYPE_TRANSLATION; 952: else if (flags & IOMMU_FAULT_PERMISSION) 953: fault_flag = KGSL_PAGEFAULT_TYPE_PERMISSION; 954: else if (flags & IOMMU_FAULT_EXTERNAL) 955: fault_flag = KGSL_PAGEFAULT_TYPE_EXTERNAL; 956: else if (flags & IOMMU_FAULT_TRANSACTION_STALLED) 957: fault_flag = KGSL_PAGEFAULT_TYPE_TRANSACTION_STALLED; 958: 959: fault_flag |= (flags & IOMMU_FAULT_WRITE) ? KGSL_PAGEFAULT_TYPE_WRITE : 960: KGSL_PAGEFAULT_TYPE_READ; 961: 962: report->fault_addr = addr; 963: report->fault_type = fault_flag; 964: if (kgsl_add_fault(context, KGSL_FAULT_TYPE_PAGEFAULT, report)) 965: kfree(report); 966: } 967: 968: static void _increment_pf_counts(struct kgsl_iommu *iommu, 969: struct kgsl_process_private *proc_priv, int flags) 970: { 971: u32 type; 972: int cur_idx = -1; 973: int new_idx = -1; 974: int i; 975: 976: write_lock(&iommu->pf_stats_lock); 977: iommu->pf_type_counts[!!(flags & IOMMU_FAULT_WRITE)]++; 978: 979: type = ffs(flags & ~IOMMU_FAULT_WRITE) - 1; 980: if (type < ARRAY_SIZE(iommu->pf_type_counts)) 981: iommu->pf_type_counts[type]++; 982: 983: if (!proc_priv) 984: goto unlock; 985: 986: /* 987: * Add the process to array of pagefaulting processes. This array is sorted (processes with 988: * more pagefaults are higher ranked). 989: */ 990: proc_priv->pf_count++; 991: proc_priv->pf_type_counts[!!(flags & IOMMU_FAULT_WRITE)]++; 992: if (type < ARRAY_SIZE(proc_priv->pf_type_counts)) 993: proc_priv->pf_type_counts[type]++; 994: 995: for (i = ARRAY_SIZE(iommu->pf_procs) - 1; i >= 0; i--) { 996: struct kgsl_iommu_pf_proc *proc = &iommu->pf_procs[i]; 997: 998: /* Check whether this process is already tracked in the array */ 999: if (!strcmp(proc->comm, proc_priv->comm)) { 1000: proc_priv->pf_count = ++proc->pf_count; 1001: proc_priv->pf_type_counts[!!(flags & IOMMU_FAULT_WRITE)] = 1002: ++proc->pf_type_counts[!!(flags & IOMMU_FAULT_WRITE)]; 1003: if (type < ARRAY_SIZE(proc_priv->pf_type_counts)) 1004: proc_priv->pf_type_counts[type] = ++proc->pf_type_counts[type]; 1005: 1006: cur_idx = i; 1007: break; 1008: } 1009: 1010: /* Find left most entry with lower fault count than current process */ 1011: if (proc->pf_count < proc_priv->pf_count) 1012: new_idx = i; 1013: } 1014: 1015: /* 1016: * If the process is not currently tracked, we can place it at the left most index that has 1017: * a fault count less than its fault count. If such an index does not exist, the array is 1018: * already full. 1019: */ 1020: if (cur_idx < 0) { 1021: if (new_idx >= 0) 1022: goto write_new_idx; 1023: goto unlock; 1024: } 1025: 1026: /* Find the left most entry (if any) with a lower pf_count */ MATCH LINES: 1075, 1077, 1079, 1081, 1083, 1085, 1093, 1108, 1110, 1116, 1120 1063: struct kgsl_mem_entry *prev = NULL, *next = NULL, *entry; 1064: const char *fault_type = NULL; 1065: const char *comm = NULL; 1066: u32 ptname = KGSL_MMU_GLOBAL_PT; 1067: struct adreno_context *drawctxt = context ? ADRENO_CONTEXT(context) : NULL; 1068: int id; 1069: 1070: if (private) { 1071: comm = private->comm; 1072: ptname = pid_nr(private->pid); 1073: } 1074: 1075: trace_kgsl_mmu_pagefault(device, addr, 1076: ptname, comm, 1077: (flags & IOMMU_FAULT_WRITE) ? "write" : "read"); 1078: 1079: if (flags & IOMMU_FAULT_TRANSLATION) 1080: fault_type = "translation"; 1081: else if (flags & IOMMU_FAULT_PERMISSION) 1082: fault_type = "permission"; 1083: else if (flags & IOMMU_FAULT_EXTERNAL) 1084: fault_type = "external"; 1085: else if (flags & IOMMU_FAULT_TRANSACTION_STALLED) 1086: fault_type = "transaction stalled"; 1087: else 1088: fault_type = "unknown"; 1089: 1090: _increment_pf_counts(&mmu->iommu, private, flags); 1091: 1092: /* FIXME: This seems buggy */ 1093: if (test_bit(KGSL_FT_PAGEFAULT_LOG_ONE_PER_PAGE, &mmu->pfpolicy)) 1094: if (!kgsl_mmu_log_fault_addr(mmu, ptbase, addr)) 1095: return; 1096: 1097: if (!__ratelimit(&ctxt->ratelimit)) 1098: return; 1099: 1100: dev_crit(device->dev, 1101: "GPU PAGE FAULT: addr = %lX group id= %d name=%s drawctxt=%d context pid = %d ctx_type=%s\n", 1102: addr, ptname, comm, contextid, context ? context->tid : 0, 1103: drawctxt ? kgsl_context_type(drawctxt->type) : "ANY"); 1104: 1105: dev_crit(device->dev, 1106: "context=%s TTBR0=0x%llx (%s %s fault)\n", 1107: ctxt->name, ptbase, 1108: (flags & IOMMU_FAULT_WRITE) ? "write" : "read", fault_type); 1109: 1110: if (gpudev->iommu_fault_block) { 1111: u32 fsynr1 = KGSL_IOMMU_GET_CTX_REG(ctxt, 1112: KGSL_IOMMU_CTX_FSYNR1); 1113: 1114: dev_crit(device->dev, 1115: "FAULTING BLOCK: %s\n", 1116: gpudev->iommu_fault_block(device, fsynr1)); 1117: } 1118: 1119: /* Don't print the debug if this is a permissions fault */ 1120: if ((flags & IOMMU_FAULT_PERMISSION)) 1121: return; 1122: 1123: kgsl_iommu_check_if_freed(device->dev, ctxt, addr, ptname); 1124: 1125: /* 1126: * Don't print any debug information if the address is 1127: * in the global region. These are rare and nobody needs 1128: * to know the addresses that are in here 1129: */ 1130: if (kgsl_iommu_addr_is_global(mmu, addr)) { 1131: dev_crit(device->dev, "Fault in global memory\n"); 1132: return; 1133: } 1134: 1135: if (!private) 1136: return; 1137: 1138: dev_crit(device->dev, "---- nearby memory ----\n"); 1139: 1140: spin_lock(&private->mem_lock); 1141: idr_for_each_entry(&private->mem_idr, entry, id) { 1142: u64 cur = entry->memdesc.gpuaddr; 1143: 1144: if (cur < addr) { MATCH LINES: 1163, 1170, 1173, 1176, 1181, 1202, 1219, 1220, 1240, 1246, 1265, 1271, 1275, 1290, 1294, 1300 1151: next = entry; 1152: } 1153: } 1154: 1155: print_entry(device->dev, prev, pid_nr(private->pid)); 1156: dev_crit(device->dev, "<- fault @ %16.16lx\n", addr); 1157: print_entry(device->dev, next, pid_nr(private->pid)); 1158: 1159: spin_unlock(&private->mem_lock); 1160: } 1161: 1162: /* 1163: * Return true if the IOMMU should stall and trigger a snapshot on a pagefault 1164: */ 1165: static bool kgsl_iommu_check_stall_on_fault(struct kgsl_iommu_context *ctx, 1166: struct kgsl_mmu *mmu, int flags) 1167: { 1168: struct kgsl_device *device = KGSL_MMU_DEVICE(mmu); 1169: 1170: if (!(flags & IOMMU_FAULT_TRANSACTION_STALLED)) 1171: return false; 1172: 1173: if (!test_bit(KGSL_FT_PAGEFAULT_GPUHALT_ENABLE, &mmu->pfpolicy)) 1174: return false; 1175: 1176: if (test_bit(KGSL_MMU_PAGEFAULT_TERMINATE, &mmu->features)) 1177: return false; 1178: 1179: /* 1180: * Sometimes, there can be multiple invocations of the fault handler. 1181: * Make sure we trigger reset/recovery only once. 1182: */ 1183: if (ctx->stalled_on_fault) 1184: return false; 1185: 1186: if (!kgsl_mutex_trylock(&device->mutex)) 1187: return true; 1188: 1189: /* 1190: * Turn off GPU IRQ so we don't get faults from it too. 1191: * The device mutex must be held to change power state 1192: */ 1193: if (gmu_core_isenabled(device)) 1194: kgsl_pwrctrl_irq(device, false); 1195: else 1196: kgsl_pwrctrl_change_state(device, KGSL_STATE_AWARE); 1197: 1198: kgsl_mutex_unlock(&device->mutex); 1199: return true; 1200: } 1201: 1202: static int kgsl_iommu_fault_handler(struct kgsl_mmu *mmu, 1203: struct kgsl_iommu_context *ctx, unsigned long addr, int flags) 1204: { 1205: struct kgsl_device *device = KGSL_MMU_DEVICE(mmu); 1206: u64 ptbase; 1207: u32 contextidr; 1208: bool stall, terminate; 1209: struct kgsl_process_private *private; 1210: struct kgsl_context *context; 1211: 1212: ptbase = KGSL_IOMMU_GET_CTX_REG_Q(ctx, KGSL_IOMMU_CTX_TTBR0); 1213: contextidr = KGSL_IOMMU_GET_CTX_REG(ctx, KGSL_IOMMU_CTX_CONTEXTIDR); 1214: 1215: private = kgsl_iommu_get_process(ptbase); 1216: context = kgsl_context_get(device, contextidr); 1217: 1218: stall = kgsl_iommu_check_stall_on_fault(ctx, mmu, flags); 1219: terminate = test_bit(KGSL_FT_PAGEFAULT_GPUHALT_ENABLE, &mmu->pfpolicy) && 1220: test_bit(KGSL_MMU_PAGEFAULT_TERMINATE, &mmu->features); 1221: 1222: kgsl_iommu_print_fault(mmu, ctx, addr, ptbase, contextidr, flags, private, 1223: context); 1224: kgsl_iommu_add_fault_info(context, addr, flags); 1225: 1226: if (stall || terminate) { 1227: u32 sctlr; 1228: 1229: /* 1230: * Disable context fault interrupts as we do not clear FSR in 1231: * the ISR. Will be re-enabled after FSR is cleared. 1232: */ 1233: sctlr = KGSL_IOMMU_GET_CTX_REG(ctx, KGSL_IOMMU_CTX_SCTLR); 1234: sctlr &= ~(0x1 << KGSL_IOMMU_SCTLR_CFIE_SHIFT); 1235: KGSL_IOMMU_SET_CTX_REG(ctx, KGSL_IOMMU_CTX_SCTLR, sctlr); 1236: 1237: /* Make sure the above write goes through before we return */ 1238: wmb(); 1239: 1240: /* This is used by reset/recovery path */ 1241: if (stall) { 1242: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1243: 1244: ctx->stalled_on_fault = true; 1245: 1246: /* Go ahead with recovery*/ 1247: adreno_scheduler_fault(adreno_dev, ADRENO_IOMMU_STALL_ON_PAGE_FAULT); 1248: } 1249: } 1250: 1251: kgsl_context_put(context); 1252: kgsl_process_private_put(private); 1253: 1254: /* 1255: * Fallback to smmu fault handler during globals faults to print useful 1256: * debug information. 1257: */ 1258: if ((!(stall || terminate)) && kgsl_iommu_addr_is_global(mmu, addr)) 1259: return -EFAULT; 1260: 1261: /* Return -EBUSY to keep the IOMMU driver from resuming on a stall or terminate */ 1262: return (stall || terminate) ? -EBUSY : 0; 1263: } 1264: 1265: static int kgsl_iommu_default_fault_handler(struct iommu_domain *domain, 1266: struct device *dev, unsigned long addr, int flags, void *token) 1267: { 1268: struct kgsl_mmu *mmu = token; 1269: struct kgsl_iommu *iommu = &mmu->iommu; 1270: 1271: return kgsl_iommu_fault_handler(mmu, &iommu->user_context, 1272: addr, flags); 1273: } 1274: 1275: static int kgsl_iommu_lpac_fault_handler(struct iommu_domain *domain, 1276: struct device *dev, unsigned long addr, int flags, void *token) 1277: { 1278: struct kgsl_mmu *mmu = token; 1279: struct kgsl_iommu *iommu = &mmu->iommu; 1280: struct kgsl_iommu_context *ctx = &iommu->lpac_context; 1281: u32 fsynr0, fsynr1; 1282: 1283: fsynr0 = KGSL_IOMMU_GET_CTX_REG(ctx, KGSL_IOMMU_CTX_FSYNR0); 1284: fsynr1 = KGSL_IOMMU_GET_CTX_REG(ctx, KGSL_IOMMU_CTX_FSYNR1); 1285: 1286: dev_crit(KGSL_MMU_DEVICE(mmu)->dev, 1287: "LPAC PAGE FAULT iova=0x%16lx, fsynr0=0x%x, fsynr1=0x%x\n", 1288: addr, fsynr0, fsynr1); 1289: 1290: return kgsl_iommu_fault_handler(mmu, &iommu->lpac_context, 1291: addr, flags); 1292: } 1293: 1294: static int kgsl_iommu_secure_fault_handler(struct iommu_domain *domain, 1295: struct device *dev, unsigned long addr, int flags, void *token) 1296: { 1297: struct kgsl_mmu *mmu = token; 1298: struct kgsl_iommu *iommu = &mmu->iommu; 1299: 1300: return kgsl_iommu_fault_handler(mmu, &iommu->secure_context, 1301: addr, flags); 1302: } 1303: 1304: /* 1305: * kgsl_iommu_disable_clk() - Disable iommu clocks 1306: * Disable IOMMU clocks 1307: */ 1308: static void kgsl_iommu_disable_clk(struct kgsl_mmu *mmu) 1309: { 1310: struct kgsl_iommu *iommu = &mmu->iommu; 1311: struct device *iommu_dev; 1312: 1313: atomic_dec(&iommu->clk_enable_count); 1314: 1315: /* 1316: * Make sure the clk refcounts are good. An unbalance may 1317: * cause the clocks to be off when we need them on. 1318: */ 1319: WARN_ON(atomic_read(&iommu->clk_enable_count) < 0); 1320: 1321: clk_bulk_disable_unprepare(iommu->num_clks, iommu->clks); 1322: 1323: if (!IS_ERR_OR_NULL(iommu->cx_regulator)) 1324: regulator_disable(iommu->cx_regulator); MATCH LINES: 1817, 1833, 1834, 1856, 1857 1805: 1806: /* Make sure all of the preceding writes have posted */ 1807: wmb(); 1808: } 1809: 1810: static void kgsl_iommu_configure_gpu_sctlr(struct kgsl_mmu *mmu, 1811: unsigned long pf_policy, 1812: struct kgsl_iommu_context *ctx) 1813: { 1814: u32 sctlr_val; 1815: 1816: /* 1817: * If pagefault policy is GPUHALT_ENABLE, 1818: * If terminate feature flag is enabled: 1819: * 1) Program CFCFG to 0 to terminate the faulting transaction 1820: * 2) Program HUPCF to 0 (terminate subsequent transactions 1821: * in the presence of an outstanding fault) 1822: * Else configure stall: 1823: * 1) Program CFCFG to 1 to enable STALL mode 1824: * 2) Program HUPCF to 0 (Stall subsequent 1825: * transactions in the presence of an outstanding fault) 1826: * else 1827: * 1) Program CFCFG to 0 to disable STALL mode (0=Terminate) 1828: * 2) Program HUPCF to 1 (Process subsequent transactions 1829: * independently of any outstanding fault) 1830: */ 1831: 1832: sctlr_val = KGSL_IOMMU_GET_CTX_REG(ctx, KGSL_IOMMU_CTX_SCTLR); 1833: if (test_bit(KGSL_FT_PAGEFAULT_GPUHALT_ENABLE, &pf_policy)) { 1834: if (test_bit(KGSL_MMU_PAGEFAULT_TERMINATE, &mmu->features)) { 1835: sctlr_val &= ~(0x1 << KGSL_IOMMU_SCTLR_CFCFG_SHIFT); 1836: sctlr_val &= ~(0x1 << KGSL_IOMMU_SCTLR_HUPCF_SHIFT); 1837: } else { 1838: sctlr_val |= (0x1 << KGSL_IOMMU_SCTLR_CFCFG_SHIFT); 1839: sctlr_val &= ~(0x1 << KGSL_IOMMU_SCTLR_HUPCF_SHIFT); 1840: } 1841: } else { 1842: sctlr_val &= ~(0x1 << KGSL_IOMMU_SCTLR_CFCFG_SHIFT); 1843: sctlr_val |= (0x1 << KGSL_IOMMU_SCTLR_HUPCF_SHIFT); 1844: } 1845: KGSL_IOMMU_SET_CTX_REG(ctx, KGSL_IOMMU_CTX_SCTLR, sctlr_val); 1846: } 1847: 1848: static bool _ctx_terminated_on_fault(struct kgsl_mmu *mmu, struct kgsl_iommu_context *ctx) 1849: { 1850: u32 fsr; 1851: 1852: /* 1853: * We only need this if SMMU is configured to be in TERMINATE mode in the presence of an 1854: * outstanding fault 1855: */ 1856: if (!test_bit(KGSL_MMU_PAGEFAULT_TERMINATE, &mmu->features) || 1857: !test_bit(KGSL_FT_PAGEFAULT_GPUHALT_ENABLE, &mmu->pfpolicy)) 1858: return false; 1859: 1860: kgsl_iommu_enable_clk(mmu); 1861: 1862: fsr = KGSL_IOMMU_GET_CTX_REG(ctx, KGSL_IOMMU_CTX_FSR); 1863: 1864: /* Make sure the above read finishes before we compare it */ 1865: rmb(); 1866: 1867: kgsl_iommu_disable_clk(mmu); 1868: 1869: /* See if there is an outstanding fault */ 1870: if (fsr & ~KGSL_IOMMU_FSR_TRANSLATION_FORMAT_MASK) 1871: return true; 1872: 1873: return false; 1874: } 1875: 1876: /* 1877: * kgsl_iommu_ctx_terminated_on_fault - Detect if GC SMMU is terminating transactions in the 1878: * presense of an outstanding fault. 1879: */ 1880: static bool kgsl_iommu_ctx_terminated_on_fault(struct kgsl_mmu *mmu) 1881: { MATCH LINES: 1971, 1993, 2025, 2038 1959: 1960: _iommu_context_set_prr(mmu, &iommu->user_context); 1961: if (mmu->secured) 1962: _iommu_context_set_prr(mmu, &iommu->secure_context); 1963: 1964: if (iommu->lpac_context.domain) { 1965: _iommu_context_set_prr(mmu, &iommu->lpac_context); 1966: kgsl_iommu_configure_gpu_sctlr(mmu, mmu->pfpolicy, &iommu->lpac_context); 1967: } 1968: 1969: /* 1970: * If CP is halted while executing SMMU_TABLE_UPDATE packet, there is a chance of 1971: * recovery failure. The problematic window is right after the page table walk 1972: * disable and before it is enabled in SMMU_TABLE_UPDATE packet. 1973: * So, enable page table walk in user and lpac contexts during boot. It is not needed 1974: * for secure context, as per process page table is not enabled for secure context. 1975: */ 1976: kgsl_iommu_enable_ptwalk(&iommu->user_context); 1977: if (iommu->lpac_context.domain) 1978: kgsl_iommu_enable_ptwalk(&iommu->lpac_context); 1979: 1980: kgsl_iommu_disable_clk(mmu); 1981: return 0; 1982: } 1983: 1984: static void kgsl_iommu_context_clear_fsr(struct kgsl_mmu *mmu, struct kgsl_iommu_context *ctx) 1985: { 1986: unsigned int sctlr_val; 1987: 1988: if (ctx->stalled_on_fault || _ctx_terminated_on_fault(mmu, ctx)) { 1989: struct kgsl_device *device = KGSL_MMU_DEVICE(mmu); 1990: 1991: kgsl_iommu_enable_clk(mmu); 1992: 1993: dev_err_ratelimited(device->dev, "Clearing pagefault bits in FSR\n"); 1994: 1995: KGSL_IOMMU_SET_CTX_REG(ctx, KGSL_IOMMU_CTX_FSR, 0xffffffff); 1996: /* 1997: * Re-enable context fault interrupts after clearing 1998: * FSR to prevent the interrupt from firing repeatedly 1999: */ 2000: sctlr_val = KGSL_IOMMU_GET_CTX_REG(ctx, KGSL_IOMMU_CTX_SCTLR); 2001: sctlr_val |= (0x1 << KGSL_IOMMU_SCTLR_CFIE_SHIFT); 2002: KGSL_IOMMU_SET_CTX_REG(ctx, KGSL_IOMMU_CTX_SCTLR, sctlr_val); 2003: /* 2004: * Make sure the above register writes 2005: * are not reordered across the barrier 2006: * as we use writel_relaxed to write them 2007: */ 2008: wmb(); 2009: kgsl_iommu_disable_clk(mmu); 2010: if (ctx->stalled_on_fault) 2011: ctx->stalled_on_fault = false; 2012: } 2013: } 2014: 2015: static void kgsl_iommu_clear_fsr(struct kgsl_mmu *mmu) 2016: { 2017: struct kgsl_iommu *iommu = &mmu->iommu; 2018: 2019: kgsl_iommu_context_clear_fsr(mmu, &iommu->user_context); 2020: 2021: if (iommu->lpac_context.domain) 2022: kgsl_iommu_context_clear_fsr(mmu, &iommu->lpac_context); 2023: } 2024: 2025: static void kgsl_iommu_context_pagefault_resume(struct kgsl_iommu *iommu, struct kgsl_iommu_context *ctx, 2026: bool terminate) 2027: { 2028: u32 sctlr_val = 0; 2029: 2030: if (!ctx->stalled_on_fault) 2031: return; 2032: 2033: if (!terminate) 2034: goto clear_fsr; 2035: 2036: sctlr_val = KGSL_IOMMU_GET_CTX_REG(ctx, KGSL_IOMMU_CTX_SCTLR); 2037: /* 2038: * As part of recovery, GBIF halt sequence should be performed. 2039: * In a worst case scenario, if any GPU block is generating a 2040: * stream of un-ending faulting transactions, SMMU would enter 2041: * stall-on-fault mode again after resuming and not let GBIF 2042: * halt succeed. In order to avoid that situation and terminate 2043: * those faulty transactions, set CFCFG and HUPCF to 0. 2044: */ 2045: sctlr_val &= ~(0x1 << KGSL_IOMMU_SCTLR_CFCFG_SHIFT); 2046: sctlr_val &= ~(0x1 << KGSL_IOMMU_SCTLR_HUPCF_SHIFT); 2047: KGSL_IOMMU_SET_CTX_REG(ctx, KGSL_IOMMU_CTX_SCTLR, sctlr_val); 2048: /* 2049: * Make sure the above register write is not reordered across 2050: * the barrier as we use writel_relaxed to write it. 2051: */ 2052: wmb(); 2053: 2054: clear_fsr: 2055: /* 2056: * This will only clear fault bits in FSR. FSR.SS will still 2057: * be set. Writing to RESUME (below) is the only way to clear 2058: * FSR.SS bit. 2059: */ 2060: KGSL_IOMMU_SET_CTX_REG(ctx, KGSL_IOMMU_CTX_FSR, 0xffffffff); 2061: /* 2062: * Make sure the above register write is not reordered across MATCH LINES: 2079, 2083, 2086, 2103, 2105, 2118, 2120, 2131, 2132 2067: /* 2068: * Write 1 to RESUME.TnR to terminate the stalled transaction. 2069: * This will also allow the SMMU to process new transactions. 2070: */ 2071: KGSL_IOMMU_SET_CTX_REG(ctx, KGSL_IOMMU_CTX_RESUME, 1); 2072: /* 2073: * Make sure the above register writes are not reordered across 2074: * the barrier as we use writel_relaxed to write them. 2075: */ 2076: wmb(); 2077: } 2078: 2079: static void kgsl_iommu_pagefault_resume(struct kgsl_mmu *mmu, bool terminate) 2080: { 2081: struct kgsl_iommu *iommu = &mmu->iommu; 2082: 2083: kgsl_iommu_context_pagefault_resume(iommu, &iommu->user_context, terminate); 2084: 2085: if (iommu->lpac_context.domain) 2086: kgsl_iommu_context_pagefault_resume(iommu, &iommu->lpac_context, terminate); 2087: } 2088: 2089: static u64 2090: kgsl_iommu_get_current_ttbr0(struct kgsl_mmu *mmu, struct kgsl_context *context) 2091: { 2092: u64 val; 2093: struct kgsl_iommu *iommu = &mmu->iommu; 2094: struct kgsl_iommu_context *ctx = &iommu->user_context; 2095: struct kgsl_device *device = KGSL_MMU_DEVICE(mmu); 2096: 2097: if (kgsl_context_is_lpac(context)) 2098: ctx = &iommu->lpac_context; 2099: 2100: /* 2101: * We cannot enable or disable the clocks in interrupt and atomic context, this 2102: * function is called from interrupt context if there is an axi error and atomic 2103: * context GPU snapshot for panic notifier callback. 2104: */ 2105: if (in_interrupt() || device->snapshot_atomic) 2106: return 0; 2107: 2108: if (ctx->cb_num < 0) 2109: return 0; 2110: 2111: kgsl_iommu_enable_clk(mmu); 2112: val = KGSL_IOMMU_GET_CTX_REG_Q(ctx, KGSL_IOMMU_CTX_TTBR0); 2113: kgsl_iommu_disable_clk(mmu); 2114: return val; 2115: } 2116: 2117: /* 2118: * kgsl_iommu_set_pf_policy() - Set the pagefault policy for IOMMU 2119: * @mmu: Pointer to mmu structure 2120: * @pf_policy: The pagefault polict to set 2121: * 2122: * Check if the new policy indicated by pf_policy is same as current 2123: * policy, if same then return else set the policy 2124: */ 2125: static int kgsl_iommu_set_pf_policy_ctxt(struct kgsl_mmu *mmu, 2126: unsigned long pf_policy, struct kgsl_iommu_context *ctx) 2127: { 2128: int cur, new; 2129: struct kgsl_iommu *iommu = &mmu->iommu; 2130: 2131: cur = test_bit(KGSL_FT_PAGEFAULT_GPUHALT_ENABLE, &mmu->pfpolicy); 2132: new = test_bit(KGSL_FT_PAGEFAULT_GPUHALT_ENABLE, &pf_policy); 2133: 2134: if (cur == new) 2135: return 0; 2136: 2137: kgsl_iommu_enable_clk(mmu); 2138: 2139: kgsl_iommu_configure_gpu_sctlr(mmu, pf_policy, &iommu->user_context); 2140: if (iommu->lpac_context.domain) 2141: kgsl_iommu_configure_gpu_sctlr(mmu, pf_policy, &iommu->lpac_context); 2142: 2143: kgsl_iommu_disable_clk(mmu); 2144: return 0; 2145: } 2146: 2147: static int kgsl_iommu_set_pf_policy(struct kgsl_mmu *mmu, 2148: unsigned long pf_policy) 2149: { 2150: struct kgsl_iommu *iommu = &mmu->iommu; 2151: 2152: kgsl_iommu_set_pf_policy_ctxt(mmu, pf_policy, &iommu->user_context); 2153: 2154: if (iommu->lpac_context.domain) 2155: kgsl_iommu_set_pf_policy_ctxt(mmu, pf_policy, &iommu->lpac_context); 2156: MATCH LINES: 2604, 2631, 2644, 2674 2592: return iommu_paging_domain_alloc(dev); 2593: } 2594: #else 2595: static struct iommu_domain *kgsl_iommu_domain_alloc(struct device *dev) 2596: { 2597: return iommu_domain_alloc(&platform_bus_type); 2598: } 2599: #endif 2600: 2601: static int kgsl_iommu_setup_context_common(struct kgsl_mmu *mmu, 2602: struct platform_device *pdev, struct device_node *node, 2603: struct kgsl_iommu_context *context, const char *name, 2604: iommu_fault_handler_t handler, bool restore_drvdata) 2605: { 2606: struct kgsl_device *device = KGSL_MMU_DEVICE(mmu); 2607: void *kgsl_drvdata = NULL; 2608: int ret; 2609: 2610: context->cb_num = -1; 2611: context->name = name; 2612: context->kgsldev = device; 2613: context->pdev = pdev; 2614: ratelimit_default_init(&context->ratelimit); 2615: 2616: if (restore_drvdata) 2617: kgsl_drvdata = dev_get_drvdata(&pdev->dev); 2618: 2619: dev_set_drvdata(&pdev->dev, &context->adreno_smmu); 2620: 2621: context->domain = kgsl_iommu_domain_alloc(&context->pdev->dev); 2622: if (IS_ERR_OR_NULL(context->domain)) { 2623: ret = (context->domain) ? PTR_ERR(context->domain) : -ENODEV; 2624: dev_err(&device->pdev->dev, "Failed to allocate domain for %s: %d\n", name, ret); 2625: context->domain = NULL; 2626: if (restore_drvdata) 2627: dev_set_drvdata(&pdev->dev, kgsl_drvdata); 2628: goto err_device_put; 2629: } 2630: 2631: qcom_iommu_set_fault_model(context->domain, QCOM_IOMMU_FAULT_MODEL_NON_FATAL); 2632: 2633: _enable_gpuhtw_llc(mmu, context->domain); 2634: 2635: ret = kgsl_attach_iommu_group(&context->pdev->dev, context->domain, 2636: &context->group); 2637: 2638: if (restore_drvdata) 2639: dev_set_drvdata(&pdev->dev, kgsl_drvdata); 2640: 2641: if (ret) 2642: goto err_domain_free; 2643: 2644: iommu_set_fault_handler(context->domain, handler, mmu); 2645: 2646: context->cb_num = qcom_iommu_get_context_bank_nr(context->domain); 2647: 2648: if (context->cb_num >= 0) { 2649: of_node_put(node); 2650: return 0; 2651: } 2652: 2653: ret = context->cb_num; 2654: dev_err(&device->pdev->dev, "Couldn't get the context bank for %s: %d\n", 2655: context->name, ret); 2656: 2657: kgsl_detach_iommu_group(context->domain, context->group); 2658: 2659: err_domain_free: 2660: iommu_domain_free(context->domain); 2661: context->domain = NULL; 2662: err_device_put: 2663: platform_device_put(pdev); 2664: context->pdev = NULL; 2665: err_node_put: 2666: of_node_put(node); 2667: err: 2668: return ret; 2669: } 2670: 2671: static int kgsl_iommu_setup_context(struct kgsl_mmu *mmu, 2672: struct device_node *parent, 2673: struct kgsl_iommu_context *context, const char *name, 2674: iommu_fault_handler_t handler) 2675: { 2676: struct device_node *node; 2677: struct platform_device *pdev; 2678: int ret; 2679: 2680: node = of_find_node_by_name(parent, name); 2681: if (!node) { 2682: ret = -ENOENT; 2683: goto err; 2684: } 2685: 2686: pdev = of_find_device_by_node(node); 2687: if (!pdev) { 2688: ret = -ENODEV; 2689: goto err_node_put; 2690: } 2691: 2692: ret = of_dma_configure(&pdev->dev, node, true); 2693: if (ret) 2694: goto err_device_put; 2695: 2696: return kgsl_iommu_setup_context_common(mmu, pdev, node, context, name, handler, false); 2697: 2698: err_device_put: MATCH LINES: 2717, 2736 2705: } 2706: 2707: static int iommu_probe_user_context(struct kgsl_device *device, 2708: struct device_node *node) 2709: { 2710: struct kgsl_iommu *iommu = KGSL_IOMMU(device); 2711: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 2712: struct kgsl_mmu *mmu = &device->mmu; 2713: struct kgsl_iommu_pt *pt; 2714: int ret; 2715: 2716: ret = kgsl_iommu_setup_context(mmu, node, &iommu->user_context, 2717: "gfx3d_user", kgsl_iommu_default_fault_handler); 2718: if (ret) 2719: return ret; 2720: 2721: /* 2722: * It is problamatic if smmu driver does system suspend before consumer 2723: * device (gpu). So smmu driver creates a device_link to act as a 2724: * supplier which in turn will ensure correct order during system 2725: * suspend. In kgsl, since we don't initialize iommu on the gpu device, 2726: * we should create a device_link between kgsl iommu device and gpu 2727: * device to maintain a correct suspend order between smmu device and 2728: * gpu device. 2729: */ 2730: if (!device_link_add(&device->pdev->dev, &iommu->user_context.pdev->dev, 2731: DL_FLAG_AUTOREMOVE_CONSUMER)) 2732: dev_err(&iommu->user_context.pdev->dev, 2733: "Unable to create device link to gpu device\n"); 2734: 2735: ret = kgsl_iommu_setup_context(mmu, node, &iommu->lpac_context, 2736: "gfx3d_lpac", kgsl_iommu_lpac_fault_handler); 2737: /* LPAC is optional, ignore setup failures in absence of LPAC feature */ 2738: if ((ret < 0) && ADRENO_FEATURE(adreno_dev, ADRENO_LPAC)) 2739: goto err; 2740: 2741: /* 2742: * FIXME: If adreno_smmu->cookie wasn't initialized then we can't do 2743: * IOPGTABLE 2744: */ 2745: 2746: /* Make the default pagetable */ 2747: mmu->defaultpagetable = kgsl_iommu_default_pagetable(mmu); 2748: if (IS_ERR(mmu->defaultpagetable)) { 2749: ret = PTR_ERR(mmu->defaultpagetable); 2750: goto err; 2751: } 2752: 2753: /* If IOPGTABLE isn't enabled then we are done */ 2754: if (!test_bit(KGSL_MMU_IOPGTABLE, &mmu->features)) 2755: return 0; 2756: 2757: pt = to_iommu_pt(mmu->defaultpagetable); 2758: 2759: /* Enable TTBR0 on the default and LPAC contexts */ 2760: kgsl_iommu_set_ttbr0(&iommu->user_context, mmu, &pt->cfg); MATCH LINES: 2835, 2836 2823: dev_err(&device->pdev->dev, "Unable to set the secure VMID: %d\n", ret); 2824: goto err_domain_free; 2825: } 2826: } 2827: 2828: _enable_gpuhtw_llc(mmu, context->domain); 2829: 2830: ret = kgsl_attach_iommu_group(&context->pdev->dev, context->domain, 2831: &context->group); 2832: if (ret) 2833: goto err_domain_free; 2834: 2835: iommu_set_fault_handler(context->domain, 2836: kgsl_iommu_secure_fault_handler, mmu); 2837: 2838: context->cb_num = qcom_iommu_get_context_bank_nr(context->domain); 2839: 2840: if (context->cb_num < 0) { 2841: ret = context->cb_num; 2842: goto err_detach_group; 2843: } 2844: 2845: mmu->securepagetable = kgsl_iommu_secure_pagetable(mmu); 2846: 2847: if (!IS_ERR(mmu->securepagetable)) 2848: return 0; 2849: 2850: err_detach_group: 2851: kgsl_detach_iommu_group(context->domain, context->group); 2852: err_domain_free: 2853: iommu_domain_free(context->domain); 2854: context->domain = NULL; 2855: err_device_put: 2856: platform_device_put(pdev); 2857: context->pdev = NULL; 2858: err_node_put: 2859: of_node_put(node); 2860: mmu->secured = false; MATCH LINES: 2943 2931: 2932: kgsl_iommu_secure_map(mmu->securepagetable, 2933: &md->memdesc); 2934: } else 2935: kgsl_iommu_default_map(mmu->defaultpagetable, 2936: &md->memdesc); 2937: } 2938: } 2939: 2940: static int kgsl_iommu_setup_context_standard(struct kgsl_mmu *mmu, 2941: struct device_node *node, 2942: struct kgsl_iommu_context *context, const char *name, 2943: iommu_fault_handler_t handler) 2944: { 2945: struct platform_device *pdev; 2946: int ret; 2947: 2948: pdev = of_find_device_by_node(node); 2949: if (!pdev) { 2950: ret = -ENODEV; 2951: goto err_node_put; 2952: } 2953: 2954: ret = of_dma_configure(&pdev->dev, node, true); 2955: if (ret) 2956: goto err_device_put; 2957: 2958: return kgsl_iommu_setup_context_common(mmu, pdev, node, context, name, handler, true); 2959: 2960: err_device_put: 2961: platform_device_put(pdev); 2962: context->pdev = NULL; 2963: err_node_put: 2964: of_node_put(node); 2965: err: 2966: return ret; 2967: } MATCH LINES: 3085 3073: mmu->type = KGSL_MMU_TYPE_IOMMU; 3074: mmu->mmu_ops = &kgsl_iommu_ops; 3075: 3076: if (of_device_is_compatible(smmu_node, "qcom,qsmmu-v500") || 3077: of_device_is_compatible(smmu_node, "arm,mmu-500")) 3078: mmu->subtype = KGSL_IOMMU_SMMU_V500; 3079: 3080: if (of_device_is_compatible(smmu_node, "qcom,adreno-smmu")) 3081: set_bit(KGSL_MMU_IOPGTABLE, &mmu->features); 3082: 3083: /* Setup iommu default non secure context */ 3084: ret = kgsl_iommu_setup_context_standard(mmu, node, &iommu->user_context, 3085: "gfx3d_user", kgsl_iommu_default_fault_handler); 3086: if (ret) 3087: goto err; 3088: 3089: /* Make the default pagetable */ 3090: mmu->defaultpagetable = kgsl_iommu_default_pagetable(mmu); 3091: if (IS_ERR(mmu->defaultpagetable)) { 3092: ret = PTR_ERR(mmu->defaultpagetable); 3093: goto err; 3094: } 3095: 3096: /* If IOPGTABLE isn't enabled then we are done */ 3097: if (!test_bit(KGSL_MMU_IOPGTABLE, &mmu->features)) 3098: return 0; 3099: 3100: pt = to_iommu_pt(mmu->defaultpagetable); 3101: 3102: /* Enable TTBR0 on the default context */ 3103: kgsl_iommu_set_ttbr0(&iommu->user_context, mmu, &pt->cfg); 3104: 3105: /* Map any globals that might have been created early */ 3106: kgsl_iommu_map_globals(device, mmu); 3107: 3108: /* QDSS is supported only when QCOM_KGSL_QDSS_STM is enabled */ 3109: if (IS_ENABLED(CONFIG_QCOM_KGSL_QDSS_STM)) MATCH LINES: 3252, 3253, 3256, 3257, 3258, 3259, 3262, 3284, 3289, 3305 3240: return 0; 3241: 3242: err: 3243: if (pm_runtime_enabled(&pdev->dev)) 3244: pm_runtime_disable(&pdev->dev); 3245: 3246: kmem_cache_destroy(addr_entry_cache); 3247: addr_entry_cache = NULL; 3248: 3249: return ret; 3250: } 3251: 3252: /* Update this array if KGSL_IOMMU_PAGEFAULT_TYPES increases */ 3253: static const char *pf_types[KGSL_IOMMU_PAGEFAULT_TYPES] = { 3254: [0] = "READ", /* Read fault */ 3255: [1] = "WRITE", /* Write fault */ 3256: [ilog2(IOMMU_FAULT_TRANSLATION)] = "TRANS", 3257: [ilog2(IOMMU_FAULT_PERMISSION)] = "PERM", 3258: [ilog2(IOMMU_FAULT_EXTERNAL)] = "EXT", 3259: [ilog2(IOMMU_FAULT_TRANSACTION_STALLED)] = "STALL", 3260: }; 3261: 3262: static ssize_t pagefaults_show(struct device *dev, 3263: struct device_attribute *attr, char *buf) 3264: { 3265: struct kgsl_device *device = dev_get_drvdata(dev); 3266: struct kgsl_iommu *iommu = KGSL_IOMMU(device); 3267: int i; 3268: size_t num_chars = 0; 3269: 3270: /* Print out a header */ 3271: num_chars += scnprintf(buf + num_chars, 3272: PAGE_SIZE - num_chars - 2, 3273: "%10s", "Total"); 3274: 3275: for (i = 0; i < ARRAY_SIZE(pf_types); i++) { 3276: num_chars += scnprintf(buf + num_chars, 3277: PAGE_SIZE - num_chars - 2, 3278: "|%10s", pf_types[i]); 3279: } 3280: buf[num_chars++] = '\n'; 3281: 3282: read_lock(&iommu->pf_stats_lock); 3283: 3284: /* Sum of R and W pagefaults is the total */ 3285: num_chars += scnprintf(buf + num_chars, 3286: PAGE_SIZE - num_chars - 2, "%10u", 3287: iommu->pf_type_counts[0] + iommu->pf_type_counts[1]); 3288: 3289: /* Print out count of each pagefault type */ 3290: for (i = 0; i < ARRAY_SIZE(iommu->pf_type_counts); i++) { 3291: num_chars += scnprintf(buf + num_chars, 3292: PAGE_SIZE - num_chars - 2, 3293: " %10u", iommu->pf_type_counts[i]); 3294: 3295: if (num_chars >= PAGE_SIZE - 2) 3296: break; 3297: } 3298: 3299: read_unlock(&iommu->pf_stats_lock); 3300: 3301: buf[num_chars++] = '\n'; 3302: return num_chars; 3303: } 3304: 3305: static ssize_t pagefault_procs_show(struct device *dev, 3306: struct device_attribute *attr, char *buf) 3307: { 3308: struct kgsl_device *device = dev_get_drvdata(dev); 3309: struct kgsl_iommu *iommu = KGSL_IOMMU(device); 3310: size_t num_chars = 0; 3311: int i; 3312: 3313: /* Print out a header */ 3314: num_chars += scnprintf(buf + num_chars, 3315: PAGE_SIZE - num_chars - 2, 3316: "%16s|%10s", "Process", "Total"); 3317: 3318: for (i = 0; i < ARRAY_SIZE(pf_types); i++) { 3319: num_chars += scnprintf(buf + num_chars, 3320: PAGE_SIZE - num_chars - 2, 3321: "|%10s", pf_types[i]); 3322: } 3323: buf[num_chars++] = '\n'; 3324: 3325: read_lock(&iommu->pf_stats_lock); 3326: for (i = 0; i < ARRAY_SIZE(iommu->pf_procs); i++) { 3327: struct kgsl_iommu_pf_proc *proc = &iommu->pf_procs[i]; 3328: int j; 3329: MATCH LINES: 3354, 3355, 3358, 3359, 3379 3342: 3343: if (num_chars < PAGE_SIZE - 1) 3344: buf[num_chars++] = '\n'; 3345: 3346: if (num_chars >= PAGE_SIZE - 1) 3347: break; 3348: } 3349: read_unlock(&iommu->pf_stats_lock); 3350: 3351: return num_chars; 3352: } 3353: 3354: static DEVICE_ATTR_RO(pagefaults); 3355: static DEVICE_ATTR_RO(pagefault_procs); 3356: 3357: static const struct attribute *iommu_sysfs_attr_list[] = { 3358: &dev_attr_pagefaults.attr, 3359: &dev_attr_pagefault_procs.attr, 3360: NULL 3361: }; 3362: 3363: static void kgsl_iommu_sysfs_init(struct kgsl_mmu *mmu) 3364: { 3365: struct kgsl_device *device = KGSL_MMU_DEVICE(mmu); 3366: 3367: WARN_ON(sysfs_create_files(&device->dev->kobj, iommu_sysfs_attr_list)); 3368: } 3369: 3370: static const struct kgsl_mmu_ops kgsl_iommu_ops = { 3371: .mmu_close = kgsl_iommu_close, 3372: .mmu_start = kgsl_iommu_start, 3373: .mmu_ctx_terminated_on_fault = kgsl_iommu_ctx_terminated_on_fault, 3374: .mmu_clear_fsr = kgsl_iommu_clear_fsr, 3375: .mmu_get_current_ttbr0 = kgsl_iommu_get_current_ttbr0, 3376: .mmu_enable_clk = kgsl_iommu_enable_clk, 3377: .mmu_disable_clk = kgsl_iommu_disable_clk, 3378: .mmu_set_pf_policy = kgsl_iommu_set_pf_policy, 3379: .mmu_pagefault_resume = kgsl_iommu_pagefault_resume, 3380: .mmu_getpagetable = kgsl_iommu_getpagetable, 3381: .mmu_map_global = kgsl_iommu_map_global, 3382: .mmu_reserve_global_gpuaddr = kgsl_iommu_reserve_global_gpuaddr, 3383: .mmu_send_tlb_hint = kgsl_iommu_send_tlb_hint, 3384: .mmu_sysfs_init = kgsl_iommu_sysfs_init, 3385: }; 3386: 3387: static const struct kgsl_mmu_pt_ops iopgtbl_pt_ops = { 3388: .mmu_map = kgsl_iopgtbl_map, 3389: .mmu_map_child = kgsl_iopgtbl_map_child, 3390: .mmu_map_zero_page_to_range = kgsl_iopgtbl_map_zero_page_to_range, 3391: .mmu_unmap = kgsl_iopgtbl_unmap, 3392: .mmu_unmap_range = kgsl_iopgtbl_unmap_range, 3393: .mmu_destroy_pagetable = kgsl_iommu_destroy_pagetable, 3394: .get_ttbr0 = kgsl_iommu_get_ttbr0, 3395: .get_context_bank = kgsl_iommu_get_context_bank, 3396: .get_asid = kgsl_iommu_get_asid, 3397: .get_gpuaddr = kgsl_iommu_get_gpuaddr, 3398: .put_gpuaddr = kgsl_iommu_put_gpuaddr, 3399: .set_svm_region = kgsl_iommu_set_svm_region, 3400: .find_svm_region = kgsl_iommu_find_svm_region, 3401: .svm_range = kgsl_iommu_svm_range, 3402: .addr_in_range = kgsl_iommu_addr_in_range, 3403: }; --- FILE: \kgsl_iommu.h | HITS: 11 --- MATCH LINES: 124, 153, 156, 158, 160, 161 112: #define KGSL_IOMMU_TCR_LPAE_EPD1 BIT(7) 113: 114: /* FSR fields */ 115: #define KGSL_IOMMU_FSR_SS_SHIFT 30 116: #define KGSL_IOMMU_FSR_TRANSLATION_FORMAT_MASK GENMASK(10, 9) 117: 118: /* ASID field in TTBR register */ 119: #define KGSL_IOMMU_ASID_START_BIT 48 120: 121: /* offset at which a nop command is placed in setstate */ 122: #define KGSL_IOMMU_SETSTATE_NOP_OFFSET 1024 123: 124: #define KGSL_IOMMU_PAGEFAULT_TYPES (ilog2(IOMMU_FAULT_TRANSACTION_STALLED) + 1) 125: 126: /* 127: * struct kgsl_iommu_context - Structure holding data about an iommu context 128: * bank 129: * @pdev: pointer to the iommu context's platform device 130: * @name: context name 131: * @id: The id of the context, used for deciding how it is used. 132: * @cb_num: The hardware context bank number, used for calculating register 133: * offsets. 134: * @kgsldev: The kgsl device that uses this context. 135: * @stalled_on_fault: Flag when set indicates that this iommu device is stalled 136: * on a page fault 137: */ 138: struct kgsl_iommu_context { 139: struct platform_device *pdev; 140: const char *name; 141: int cb_num; 142: struct kgsl_device *kgsldev; 143: bool stalled_on_fault; 144: /** ratelimit: Ratelimit state for the context */ 145: struct ratelimit_state ratelimit; 146: struct iommu_domain *domain; 147: /** @group: IOMMU group for the context */ 148: struct iommu_group *group; 149: struct adreno_smmu_priv adreno_smmu; 150: }; 151: 152: /* 153: * struct kgsl_iommu_pf_proc - Structure to hold data on pagefaulting processes 154: */ 155: struct kgsl_iommu_pf_proc { 156: /** @comm: Task name of the pagefaulting process */ 157: char comm[TASK_COMM_LEN]; 158: /** @pf_count: Total count of pagefaults from this process */ 159: u32 pf_count; 160: /** @pf_type_counts: Count of pagefaults of each type from this process */ 161: u32 pf_type_counts[KGSL_IOMMU_PAGEFAULT_TYPES]; 162: }; 163: 164: #define KGSL_IOMMU_MAX_PF_PROCS 10 165: 166: /* 167: * struct kgsl_iommu - Structure holding iommu data for kgsl driver 168: * @regbase: Virtual address of the IOMMU register base 169: * @regstart: Physical address of the iommu registers 170: * @regsize: Length of the iommu register region. 171: * @setstate: Scratch GPU memory for IOMMU operations 172: * @clk_enable_count: The ref count of clock enable calls 173: * @clks: Array of pointers to IOMMU clocks 174: * @smmu_info: smmu info used in a5xx preemption 175: */ 176: struct kgsl_iommu { 177: /** @user_context: Container for the user iommu context */ 178: struct kgsl_iommu_context user_context; 179: /** @secure_context: Container for the secure iommu context */ 180: struct kgsl_iommu_context secure_context; 181: /** @lpac_context: Container for the LPAC iommu context */ 182: struct kgsl_iommu_context lpac_context; 183: void __iomem *regbase; 184: struct kgsl_memdesc *setstate; 185: atomic_t clk_enable_count; MATCH LINES: 208, 209, 211, 212, 215 196: bool ppt_active; 197: /** 198: * @smmu_aperture_set: Set once the SMMU aperture is programmed. Cleared 199: * when the aperture is lost so that the next MMU start programs it again. 200: */ 201: bool smmu_aperture_set; 202: /** @cb0_offset: Offset of context bank 0 from iommu register base */ 203: u32 cb0_offset; 204: /** @pagesize: Size of each context bank register space */ 205: u32 pagesize; 206: /** @cx_regulator: CX regulator handle in case the IOMMU needs it */ 207: struct regulator *cx_regulator; 208: /** @pf_type_counts: Keep track of pagefaults */ 209: u32 pf_type_counts[KGSL_IOMMU_PAGEFAULT_TYPES]; 210: /** 211: * @pf_procs: Array to keep track of per process pagefault count sorted by the number 212: * of pagefaults 213: */ 214: struct kgsl_iommu_pf_proc pf_procs[KGSL_IOMMU_MAX_PF_PROCS]; 215: /** @pf_stats_lock: A R/W lock to protect pagefault statistics */ 216: rwlock_t pf_stats_lock; 217: struct device *smmu_vir_cx_pd; 218: }; 219: 220: /* 221: * struct kgsl_iommu_pt - Iommu pagetable structure private to kgsl driver 222: * @domain: Pointer to the iommu domain that contains the iommu pagetable 223: * @ttbr0: register value to set when using this pagetable 224: */ 225: struct kgsl_iommu_pt { 226: struct kgsl_pagetable base; 227: u64 ttbr0; 228: 229: struct io_pgtable_ops *pgtbl_ops; 230: struct io_pgtable_cfg cfg; 231: }; 232: 233: int kgsl_iommu_probe_standard(struct kgsl_device *device, struct platform_device *pdev); 234: #endif --- FILE: \kgsl_mmu.h | HITS: 21 --- MATCH LINES: 30, 31, 32, 33, 34, 37, 38, 39, 40, 41, 42, 45, 47 18: 19: #define MMU_DEFAULT_TTBR0(_d) \ 20: (kgsl_mmu_pagetable_get_ttbr0((_d)->mmu.defaultpagetable)) 21: 22: /* Mask ASID fields to match 48bit ptbase address*/ 23: #define MMU_SW_PT_BASE(_ttbr0) \ 24: (_ttbr0 & (BIT_ULL(KGSL_IOMMU_ASID_START_BIT) - 1)) 25: 26: #define KGSL_MMU_DEVICE(_mmu) \ 27: container_of((_mmu), struct kgsl_device, mmu) 28: 29: /** 30: * enum kgsl_ft_pagefault_policy_bits - KGSL pagefault policy bits 31: * @KGSL_FT_PAGEFAULT_INT_ENABLE: No longer used, but retained for compatibility 32: * @KGSL_FT_PAGEFAULT_GPUHALT_ENABLE: enable GPU halt on pagefaults 33: * @KGSL_FT_PAGEFAULT_LOG_ONE_PER_PAGE: log one pagefault per page 34: * @KGSL_FT_PAGEFAULT_LOG_ONE_PER_INT: log one pagefault per interrupt 35: */ 36: enum { 37: KGSL_FT_PAGEFAULT_INT_ENABLE = 0, 38: KGSL_FT_PAGEFAULT_GPUHALT_ENABLE = 1, 39: KGSL_FT_PAGEFAULT_LOG_ONE_PER_PAGE = 2, 40: KGSL_FT_PAGEFAULT_LOG_ONE_PER_INT = 3, 41: /* KGSL_FT_PAGEFAULT_MAX_BITS is used to calculate the mask */ 42: KGSL_FT_PAGEFAULT_MAX_BITS, 43: }; 44: 45: #define KGSL_FT_PAGEFAULT_MASK GENMASK(KGSL_FT_PAGEFAULT_MAX_BITS - 1, 0) 46: 47: #define KGSL_FT_PAGEFAULT_DEFAULT_POLICY 0 48: 49: struct kgsl_device; 50: 51: enum kgsl_mmutype { 52: KGSL_MMU_TYPE_IOMMU = 0, 53: KGSL_MMU_TYPE_NONE 54: }; 55: 56: #define KGSL_IOMMU_SMMU_V500 1 57: 58: struct kgsl_pagetable { 59: spinlock_t lock; 60: struct kref refcount; 61: struct list_head list; 62: unsigned int name; 63: struct kobject *kobj; 64: struct work_struct destroy_ws; 65: 66: struct { 67: atomic_t entries; 68: atomic_long_t mapped; 69: atomic_long_t max_mapped; 70: } stats; 71: const struct kgsl_mmu_pt_ops *pt_ops; MATCH LINES: 109 97: /** @va_hint: Virtual address hint for 64-bit non-SVM allocations */ 98: u64 va_hint; 99: u64 global_base; 100: }; 101: 102: struct kgsl_mmu; 103: 104: struct kgsl_mmu_ops { 105: void (*mmu_close)(struct kgsl_mmu *mmu); 106: int (*mmu_start)(struct kgsl_mmu *mmu); 107: bool (*mmu_ctx_terminated_on_fault)(struct kgsl_mmu *mmu); 108: uint64_t (*mmu_get_current_ttbr0)(struct kgsl_mmu *mmu, struct kgsl_context *context); 109: void (*mmu_pagefault_resume)(struct kgsl_mmu *mmu, bool terminate); 110: void (*mmu_clear_fsr)(struct kgsl_mmu *mmu); 111: void (*mmu_enable_clk)(struct kgsl_mmu *mmu); 112: void (*mmu_disable_clk)(struct kgsl_mmu *mmu); 113: int (*mmu_set_pf_policy)(struct kgsl_mmu *mmu, unsigned long pf_policy); 114: int (*mmu_init_pt)(struct kgsl_mmu *mmu, struct kgsl_pagetable *pt); 115: struct kgsl_pagetable * (*mmu_getpagetable)(struct kgsl_mmu *mmu, 116: unsigned long name); 117: void (*mmu_map_global)(struct kgsl_mmu *mmu, 118: struct kgsl_memdesc *memdesc, u32 padding); 119: int (*mmu_reserve_global_gpuaddr)(struct kgsl_mmu *mmu, struct kgsl_memdesc *memdesc, 120: u32 padding); 121: void (*mmu_send_tlb_hint)(struct kgsl_mmu *mmu, bool hint); 122: void (*mmu_sysfs_init)(struct kgsl_mmu *mmu); 123: }; 124: 125: struct kgsl_mmu_pt_ops { 126: int (*mmu_map)(struct kgsl_pagetable *pt, 127: struct kgsl_memdesc *memdesc); 128: int (*mmu_map_child)(struct kgsl_pagetable *pt, 129: struct kgsl_memdesc *memdesc, u64 offset, 130: struct kgsl_memdesc *child, u64 child_offset, 131: u64 length); 132: int (*mmu_map_zero_page_to_range)(struct kgsl_pagetable *pt, 133: struct kgsl_memdesc *memdesc, u64 start, u64 length); MATCH LINES: 178, 179, 206 166: KGSL_MMU_IO_COHERENT, 167: /** @KGSL_MMU_LLC_ENABLE: Set if LLC is activated for the target */ 168: KGSL_MMU_LLCC_ENABLE, 169: /** @KGSL_MMU_SMMU_APERTURE: Set the SMMU aperture */ 170: KGSL_MMU_SMMU_APERTURE, 171: /** 172: * @KGSL_MMU_IOPGTABLE: Set if the qcom,adreno-smmu implementation is 173: * available. Implies split address space and per-process pagetables 174: */ 175: KGSL_MMU_IOPGTABLE, 176: /** @KGSL_MMU_SUPPORT_VBO: Non-secure VBOs are supported */ 177: KGSL_MMU_SUPPORT_VBO, 178: /** @KGSL_MMU_PAGEFAULT_TERMINATE: Set to make pagefaults fatal */ 179: KGSL_MMU_PAGEFAULT_TERMINATE, 180: /** @KGSL_MMU_LLCC_NWA: Set to make no write allocate the default LLCC policy */ 181: KGSL_MMU_FORCE_LLCC_NWA, 182: }; 183: 184: #include "kgsl_iommu.h" 185: 186: /** 187: * struct kgsl_mmu - Master definition for KGSL MMU devices 188: * @flags: MMU device flags 189: * @type: Type of MMU that is attached 190: * @subtype: Sub Type of MMU that is attached 191: * @defaultpagetable: Default pagetable object for the MMU 192: * @securepagetable: Default secure pagetable object for the MMU 193: * @mmu_ops: Function pointers for the MMU sub-type 194: * @secured: True if the MMU needs to be secured 195: * @feature: Static list of MMU features 196: */ 197: struct kgsl_mmu { 198: unsigned long flags; 199: enum kgsl_mmutype type; 200: u32 subtype; 201: struct kgsl_pagetable *defaultpagetable; 202: struct kgsl_pagetable *securepagetable; 203: const struct kgsl_mmu_ops *mmu_ops; 204: bool secured; 205: unsigned long features; 206: /** @pfpolicy: The current pagefault policy for the device */ 207: unsigned long pfpolicy; 208: /** mmu: Pointer to the IOMMU sub-device */ 209: struct kgsl_iommu iommu; 210: }; 211: 212: #define KGSL_IOMMU(d) (&((d)->mmu.iommu)) 213: 214: int __init kgsl_mmu_init(void); 215: void kgsl_mmu_exit(void); 216: 217: int kgsl_mmu_start(struct kgsl_device *device); 218: 219: void kgsl_mmu_putpagetable(struct kgsl_pagetable *pagetable); 220: 221: int kgsl_mmu_map(struct kgsl_pagetable *pagetable, 222: struct kgsl_memdesc *memdesc); 223: int kgsl_mmu_map_child(struct kgsl_pagetable *pt, 224: struct kgsl_memdesc *memdesc, u64 offset, 225: struct kgsl_memdesc *child, u64 child_offset, 226: u64 length); 227: int kgsl_mmu_map_zero_page_to_range(struct kgsl_pagetable *pt, 228: struct kgsl_memdesc *memdesc, u64 start, u64 length); 229: int kgsl_mmu_unmap(struct kgsl_pagetable *pagetable, 230: struct kgsl_memdesc *memdesc); MATCH LINES: 335, 344, 347, 348 323: static inline void kgsl_mmu_enable_clk(struct kgsl_mmu *mmu) 324: { 325: if (MMU_OP_VALID(mmu, mmu_enable_clk)) 326: mmu->mmu_ops->mmu_enable_clk(mmu); 327: } 328: 329: static inline void kgsl_mmu_disable_clk(struct kgsl_mmu *mmu) 330: { 331: if (MMU_OP_VALID(mmu, mmu_disable_clk)) 332: mmu->mmu_ops->mmu_disable_clk(mmu); 333: } 334: 335: static inline int kgsl_mmu_set_pagefault_policy(struct kgsl_mmu *mmu, 336: unsigned long pf_policy) 337: { 338: if (MMU_OP_VALID(mmu, mmu_set_pf_policy)) 339: return mmu->mmu_ops->mmu_set_pf_policy(mmu, pf_policy); 340: 341: return 0; 342: } 343: 344: static inline void kgsl_mmu_pagefault_resume(struct kgsl_mmu *mmu, 345: bool terminate) 346: { 347: if (MMU_OP_VALID(mmu, mmu_pagefault_resume)) 348: return mmu->mmu_ops->mmu_pagefault_resume(mmu, terminate); 349: } 350: 351: static inline void kgsl_mmu_clear_fsr(struct kgsl_mmu *mmu) 352: { 353: if (MMU_OP_VALID(mmu, mmu_clear_fsr)) 354: return mmu->mmu_ops->mmu_clear_fsr(mmu); 355: } 356: 357: static inline bool kgsl_mmu_is_perprocess(struct kgsl_mmu *mmu) 358: { 359: return test_bit(KGSL_MMU_IOPGTABLE, &mmu->features); 360: } 361: 362: static inline bool kgsl_mmu_is_secured(struct kgsl_mmu *mmu) 363: { 364: return mmu && (mmu->secured) && (!IS_ERR_OR_NULL(mmu->securepagetable)); 365: } 366: 367: static inline u64 368: kgsl_mmu_pagetable_get_ttbr0(struct kgsl_pagetable *pagetable) 369: { 370: if (PT_OP_VALID(pagetable, get_ttbr0)) 371: return pagetable->pt_ops->get_ttbr0(pagetable); 372: --- FILE: \kgsl_pwrctrl.c | HITS: 13 --- MATCH LINES: 146, 157, 167, 183 134: } 135: 136: /** 137: * kgsl_pwrctrl_adjust_pwrlevel() - Adjust the power level if 138: * required by thermal, max/min, constraints, etc 139: * @device: Pointer to the kgsl_device struct 140: * @new_level: Requested powerlevel, an index into the pwrlevel array 141: */ 142: static u32 kgsl_pwrctrl_adjust_pwrlevel(struct kgsl_device *device, u32 new_level) 143: { 144: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 145: u32 old_level = pwr->active_pwrlevel; 146: bool reset = false; 147: 148: /* If a pwr constraint is expired, remove it */ 149: if ((pwr->constraint.type != KGSL_CONSTRAINT_NONE) && 150: (time_after(jiffies, pwr->constraint.expires))) { 151: 152: struct kgsl_context *context = kgsl_context_get(device, 153: pwr->constraint.owner_id); 154: 155: /* We couldn't get a reference, clear the constraint */ 156: if (!context) { 157: reset = true; 158: goto done; 159: } 160: 161: /* 162: * If the last timestamp that set the constraint has retired, 163: * clear the constraint 164: */ 165: if (kgsl_check_timestamp(device, context, 166: pwr->constraint.owner_timestamp)) { 167: reset = true; 168: kgsl_context_put(context); 169: goto done; 170: } 171: 172: /* 173: * Increase the timeout to keep the constraint at least till 174: * the timestamp retires 175: */ 176: pwr->constraint.expires = jiffies + 177: msecs_to_jiffies(atomic64_read(&device->pwrctrl.interval_timeout)); 178: 179: kgsl_context_put(context); 180: } 181: 182: done: 183: if (reset) { 184: /* Trace the constraint being un-set by the driver */ 185: trace_kgsl_constraint(device, pwr->constraint.type, 186: old_level, 0, 0); 187: /*Invalidate the constraint set */ 188: pwr->constraint.expires = 0; 189: pwr->constraint.type = KGSL_CONSTRAINT_NONE; 190: } 191: 192: /* 193: * Adjust the power level if required by thermal, max/min, 194: * constraints, etc 195: */ 196: return _adjust_pwrlevel(pwr, new_level, &pwr->constraint); 197: } 198: 199: /** 200: * kgsl_pwrctrl_pwrlevel_change() - Validate and change power levels 201: * @device: Pointer to the kgsl_device struct 202: * @new_level: Requested powerlevel, an index into the pwrlevel array 203: * 204: * Check that any power level constraints are still valid. Update the 205: * requested level according to any thermal, max/min, or power constraints. 206: * If a new GPU level is going to be set, update the bus to that level's 207: * default value. Do not change the bus if a constraint keeps the new MATCH LINES: 627 615: 616: static ssize_t gpubusy_show(struct device *dev, 617: struct device_attribute *attr, char *buf) 618: { 619: int ret; 620: struct kgsl_device *device = dev_get_drvdata(dev); 621: struct kgsl_clk_stats *stats = &device->pwrctrl.clk_stats; 622: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 623: 624: ret = scnprintf(buf, PAGE_SIZE, "%7d %7d\n", 625: stats->busy_old, stats->total_old); 626: 627: /* Reset the stats if GPU is OFF */ 628: if ((atomic_read(&device->active_cnt) == 0)) { 629: spin_lock(&pwr->stats_lock); 630: stats->busy_old = 0; 631: stats->total_old = 0; 632: spin_unlock(&pwr->stats_lock); 633: } 634: return ret; 635: } 636: 637: static ssize_t gpu_available_frequencies_show(struct device *dev, 638: struct device_attribute *attr, 639: char *buf) 640: { 641: struct kgsl_device *device = dev_get_drvdata(dev); 642: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 643: int index, num_chars = 0; 644: 645: for (index = 0; index < pwr->num_pwrlevels; index++) { 646: num_chars += scnprintf(buf + num_chars, 647: PAGE_SIZE - num_chars - 1, 648: "%d ", pwr->pwrlevels[index].gpu_freq); 649: /* One space for trailing null and another for the newline */ 650: if (num_chars >= PAGE_SIZE - 2) 651: break; MATCH LINES: 677, 682 665: kgsl_pwrscale_update_stats(device); 666: kgsl_mutex_unlock(&device->mutex); 667: for (index = 0; index < pwr->num_pwrlevels; index++) 668: num_chars += scnprintf(buf + num_chars, PAGE_SIZE - num_chars, 669: "%llu ", pwr->clock_times[index]); 670: 671: if (num_chars < PAGE_SIZE) 672: buf[num_chars++] = '\n'; 673: 674: return num_chars; 675: } 676: 677: static ssize_t reset_count_show(struct device *dev, 678: struct device_attribute *attr, char *buf) 679: { 680: struct kgsl_device *device = dev_get_drvdata(dev); 681: 682: return scnprintf(buf, PAGE_SIZE, "%d\n", device->reset_counter); 683: } 684: 685: static void __force_on(struct kgsl_device *device, int flag, int on) 686: { 687: if (on) { 688: switch (flag) { 689: case KGSL_PWRFLAGS_CLK_ON: 690: /* make sure pwrrail is ON before enabling clocks */ 691: kgsl_pwrctrl_pwrrail(device, true); 692: kgsl_pwrctrl_clk(device, true, 693: KGSL_STATE_ACTIVE); 694: break; 695: case KGSL_PWRFLAGS_AXI_ON: 696: kgsl_pwrctrl_axi(device, true); 697: break; 698: case KGSL_PWRFLAGS_POWER_ON: 699: kgsl_pwrctrl_pwrrail(device, true); 700: break; 701: } 702: set_bit(flag, &device->pwrctrl.ctrl_flags); 703: } else { 704: clear_bit(flag, &device->pwrctrl.ctrl_flags); 705: } 706: } MATCH LINES: 897 885: char *buf) 886: { 887: int ret; 888: struct kgsl_clk_stats *stats = &device->pwrctrl.clk_stats; 889: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 890: unsigned int busy_percent = 0; 891: 892: if (stats->total_old != 0) 893: busy_percent = (stats->busy_old * 100) / stats->total_old; 894: 895: ret = scnprintf(buf, PAGE_SIZE, "%d %%\n", busy_percent); 896: 897: /* Reset the stats if GPU is OFF */ 898: if ((atomic_read(&device->active_cnt) == 0)) { 899: spin_lock(&pwr->stats_lock); 900: stats->busy_old = 0; 901: stats->total_old = 0; 902: spin_unlock(&pwr->stats_lock); 903: } 904: return ret; 905: } 906: 907: static ssize_t gpu_busy_percentage_show(struct device *dev, 908: struct device_attribute *attr, 909: char *buf) 910: { 911: struct kgsl_device *device = dev_get_drvdata(dev); 912: 913: return _gpu_busy_show(device, buf); 914: } 915: 916: static ssize_t _min_clock_mhz_show(struct kgsl_device *device, 917: char *buf) 918: { 919: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 920: 921: return scnprintf(buf, PAGE_SIZE, "%d\n", MATCH LINES: 1147, 1175 1135: static DEVICE_ATTR_RW(gpuclk); 1136: static DEVICE_ATTR_RW(max_gpuclk); 1137: static DEVICE_ATTR_RW(idle_timer); 1138: static DEVICE_ATTR_RW(minbw_timer); 1139: static DEVICE_ATTR_RO(gpubusy); 1140: static DEVICE_ATTR_RO(gpu_available_frequencies); 1141: static DEVICE_ATTR_RO(gpu_clock_stats); 1142: static DEVICE_ATTR_RW(max_pwrlevel); 1143: static DEVICE_ATTR_RW(min_pwrlevel); 1144: static DEVICE_ATTR_RW(thermal_pwrlevel); 1145: static DEVICE_ATTR_RO(thermal_time); 1146: static DEVICE_ATTR_RO(num_pwrlevels); 1147: static DEVICE_ATTR_RO(reset_count); 1148: static DEVICE_ATTR_RW(force_clk_on); 1149: static DEVICE_ATTR_RW(force_bus_on); 1150: static DEVICE_ATTR_RW(force_rail_on); 1151: static DEVICE_ATTR_RW(bus_split); 1152: static DEVICE_ATTR_RW(default_pwrlevel); 1153: static DEVICE_ATTR_RO(popp); 1154: static DEVICE_ATTR_RW(force_no_nap); 1155: static DEVICE_ATTR_RO(gpu_busy_percentage); 1156: static DEVICE_ATTR_RW(min_clock_mhz); 1157: static DEVICE_ATTR_RW(max_clock_mhz); 1158: static DEVICE_ATTR_RO(clock_mhz); 1159: static DEVICE_ATTR_RO(freq_table_mhz); 1160: static DEVICE_ATTR_RW(pwrscale); 1161: 1162: static const struct attribute *pwrctrl_attr_list[] = { 1163: &dev_attr_gpuclk.attr, 1164: &dev_attr_max_gpuclk.attr, 1165: &dev_attr_idle_timer.attr, 1166: &dev_attr_minbw_timer.attr, 1167: &dev_attr_gpubusy.attr, 1168: &dev_attr_gpu_available_frequencies.attr, 1169: &dev_attr_gpu_clock_stats.attr, 1170: &dev_attr_max_pwrlevel.attr, 1171: &dev_attr_min_pwrlevel.attr, 1172: &dev_attr_thermal_pwrlevel.attr, 1173: &dev_attr_thermal_time.attr, 1174: &dev_attr_num_pwrlevels.attr, 1175: &dev_attr_reset_count.attr, 1176: &dev_attr_force_clk_on.attr, 1177: &dev_attr_force_bus_on.attr, 1178: &dev_attr_force_rail_on.attr, 1179: &dev_attr_force_no_nap.attr, 1180: &dev_attr_bus_split.attr, 1181: &dev_attr_default_pwrlevel.attr, 1182: &dev_attr_popp.attr, 1183: &dev_attr_gpu_busy_percentage.attr, 1184: &dev_attr_min_clock_mhz.attr, 1185: &dev_attr_max_clock_mhz.attr, 1186: &dev_attr_clock_mhz.attr, 1187: &dev_attr_freq_table_mhz.attr, 1188: &dev_attr_temp.attr, 1189: &dev_attr_pwrscale.attr, 1190: NULL, 1191: }; 1192: 1193: static GPU_SYSFS_ATTR(gpu_busy, 0444, _gpu_busy_show, NULL); 1194: static GPU_SYSFS_ATTR(gpu_min_clock, 0644, _min_clock_mhz_show, 1195: _min_clock_mhz_store); 1196: static GPU_SYSFS_ATTR(gpu_max_clock, 0644, _max_clock_mhz_show, 1197: _max_clock_mhz_store); 1198: static GPU_SYSFS_ATTR(gpu_clock, 0444, _clock_mhz_show, NULL); 1199: static GPU_SYSFS_ATTR(gpu_freq_table, 0444, _freq_table_mhz_show, NULL); MATCH LINES: 1242 1230: void kgsl_pwrctrl_busy_time(struct kgsl_device *device, u64 time, u64 busy, u64 ticks) 1231: { 1232: struct kgsl_clk_stats *stats = &device->pwrctrl.clk_stats; 1233: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1234: 1235: stats->total += time; 1236: stats->busy += busy; 1237: 1238: if (stats->total < UPDATE_BUSY_VAL) 1239: return; 1240: 1241: spin_lock(&pwr->stats_lock); 1242: /* Update the output regularly and reset the counters. */ 1243: stats->total_old = stats->total; 1244: stats->busy_old = stats->busy; 1245: stats->total = 0; 1246: stats->busy = 0; 1247: spin_unlock(&pwr->stats_lock); 1248: 1249: trace_kgsl_gpubusy(device, stats->busy_old, stats->total_old, ticks); 1250: } 1251: 1252: static void kgsl_pwrctrl_clk(struct kgsl_device *device, bool state, 1253: int requested_state) 1254: { 1255: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1256: int i = 0; 1257: 1258: if (gmu_core_gpmu_isenabled(device)) 1259: return; 1260: if (test_bit(KGSL_PWRFLAGS_CLK_ON, &pwr->ctrl_flags)) 1261: return; 1262: 1263: if (!state) { 1264: if (test_and_clear_bit(KGSL_PWRFLAGS_CLK_ON, 1265: &pwr->power_flags)) { 1266: trace_kgsl_clk(device, state, MATCH LINES: 1573, 1577 1561: phandle = of_parse_phandle(pdev->dev.of_node, "iommus", 0); 1562: 1563: if (!phandle) 1564: return -ENOENT; 1565: 1566: iommu_pdev = of_find_device_by_node(phandle); 1567: of_node_put(phandle); 1568: 1569: if (!iommu_pdev) 1570: return -ENOENT; 1571: 1572: /* 1573: * As part of runtime_resume PM callback, the smmu driver resets the device. 1574: * This creates problems if GPU is active and runtime_resume callback of 1575: * iommu device kicks in. Hence, add device link between the CX power domain 1576: * and iommu device to keep the iommu device active when GPU is active. This 1577: * is not needed when using downstream driver with qcom addons because reset 1578: * of the device is done only during resume PM callback. 1579: */ 1580: if (!device_link_add(device->pwrctrl.cx_pd, &iommu_pdev->dev, DL_FLAG_PM_RUNTIME | 1581: DL_FLAG_AUTOREMOVE_SUPPLIER)) { 1582: dev_err(device->dev, 1583: "Unable to create device link between cxpd and iommu\n"); 1584: put_device(&iommu_pdev->dev); 1585: return -EINVAL; 1586: } 1587: 1588: put_device(&iommu_pdev->dev); 1589: 1590: return 0; 1591: } 1592: #else 1593: static int kgsl_device_link_add_cxpd_iommu(struct kgsl_device *device) 1594: { 1595: return 0; 1596: } 1597: #endif 1598: 1599: int kgsl_pwrctrl_probe_mx_gdsc(struct kgsl_device *device, struct platform_device *pdev) 1600: { 1601: struct kgsl_pwrctrl *pwr = &device->pwrctrl; --- FILE: \kgsl_pwrscale.c | HITS: 1 --- MATCH LINES: 518 506: /* trim calculated change to fit range */ 507: if (pwr_level->bus_freq + pwr->bus_mod < pwr_level->bus_min) 508: pwr->bus_mod = -(pwr_level->bus_freq - pwr_level->bus_min); 509: else if (pwr_level->bus_freq + pwr->bus_mod > pwr_level->bus_max) 510: pwr->bus_mod = pwr_level->bus_max - pwr_level->bus_freq; 511: 512: /* Update bus vote if AB or IB is modified */ 513: if ((pwr->bus_mod != b) || (pwr->bus_ab_mbytes != ab_mbytes)) { 514: pwr->bus_percent_ab = device->pwrscale.bus_profile.percent_ab; 515: /* 516: * When gpu is thermally throttled to its lowest power level, 517: * drop GPU's AB vote as a last resort to lower CX voltage and 518: * to prevent thermal reset. 519: * Ignore this check when only single power level in use to 520: * avoid setting default AB vote in normal situations too. 521: */ 522: if ((pwr->thermal_pwrlevel != pwr->num_pwrlevels - 1 && 523: pwr->pmqos_max_pwrlevel != pwr->num_pwrlevels - 1) || 524: pwr->num_pwrlevels == 1) 525: pwr->bus_ab_mbytes = ab_mbytes; 526: else 527: pwr->bus_ab_mbytes = 0; 528: kgsl_bus_update(device, KGSL_BUS_VOTE_ON); 529: } 530: 531: kgsl_mutex_unlock(&device->mutex); 532: return 0; 533: } 534: 535: static int kgsl_busmon_get_cur_freq(struct device *dev, unsigned long *freq) 536: { 537: return 0; 538: } 539: 540: static void busmon_dev_release(struct device *dev) 541: { 542: } --- FILE: \kgsl_sharedmem.c | HITS: 5 --- MATCH LINES: 27 15: #include 16: 17: #include "kgsl_device.h" 18: #include "kgsl_pool.h" 19: #include "kgsl_reclaim.h" 20: #include "kgsl_sharedmem.h" 21: #include "kgsl_util.h" 22: 23: /* 24: * The user can set this from debugfs to force failed memory allocations to 25: * fail without trying OOM first. This is a debug setting useful for 26: * stress applications that want to test failure cases without pushing the 27: * system into unrecoverable OOM panics 28: */ 29: 30: bool kgsl_sharedmem_noretry_flag; 31: 32: static DEFINE_MUTEX(kernel_map_global_lock); 33: 34: #define MEMTYPE(_type, _name) \ 35: static struct kgsl_memtype memtype_##_name = { \ 36: .type = _type, \ 37: .attr = { .name = __stringify(_name), .mode = 0444 } \ 38: } 39: 40: struct kgsl_memtype { 41: unsigned int type; 42: struct attribute attr; 43: }; 44: 45: /* We can not use macro MEMTYPE for "any(0)" because of special characters */ 46: static struct kgsl_memtype memtype_any0 = { 47: .type = KGSL_MEMTYPE_OBJECTANY, 48: .attr = { .name = "any(0)", .mode = 0444 }, 49: }; 50: 51: MEMTYPE(KGSL_MEMTYPE_FRAMEBUFFER, framebuffer); MATCH LINES: 616 604: &dest_perms, 1); 605: } while (ret == -EAGAIN); 606: 607: if (ret) { 608: /* 609: * If returned error code is EADDRNOTAVAIL, then this 610: * memory may no longer be in a usable state as security 611: * state of the pages is unknown after this failure. This 612: * memory can neither be added back to the pool nor buddy 613: * system. 614: */ 615: if (ret == -EADDRNOTAVAIL) 616: pr_err("Failure to lock secure GPU memory 0x%llx bytes will not be recoverable\n", 617: size); 618: 619: return ret; 620: } 621: 622: return 0; 623: } 624: 625: int kgsl_unlock_sgt(struct sg_table *sgt) 626: { 627: int dest_perms = PERM_READ | PERM_WRITE | PERM_EXEC; 628: int source_vm = VMID_CP_PIXEL; 629: int dest_vm = VMID_HLOS; 630: int ret; 631: 632: do { 633: ret = hyp_assign_table(sgt, &source_vm, 1, &dest_vm, 634: &dest_perms, 1); 635: } while (ret == -EAGAIN); 636: 637: if (ret) 638: return ret; 639: 640: return 0; MATCH LINES: 1583, 1617, 1655 1571: int i; 1572: struct scatterlist *sg; 1573: int ret; 1574: 1575: if (TEST_FLAG(KGSL_MEMDESC_MAPPED, &memdesc->priv)) 1576: return; 1577: 1578: ret = kgsl_unlock_sgt(memdesc->sgt); 1579: 1580: if (ret) { 1581: /* 1582: * Unlock of the secure buffer failed. This buffer will 1583: * be stuck in secure side forever and is unrecoverable. 1584: * Give up on the buffer and don't return it to the 1585: * pool. 1586: */ 1587: pr_err("kgsl: secure buf unlock failed: gpuaddr: %llx size: %llx ret: %d\n", 1588: memdesc->gpuaddr, memdesc->size, ret); 1589: return; 1590: } 1591: 1592: atomic_long_sub(memdesc->size, &kgsl_driver.stats.secure); 1593: 1594: for_each_sg(memdesc->sgt->sgl, sg, memdesc->sgt->nents, i) { 1595: struct page *page = sg_page(sg); 1596: 1597: __free_pages(page, get_order(PAGE_SIZE)); 1598: } 1599: 1600: sg_free_table(memdesc->sgt); 1601: kfree(memdesc->sgt); 1602: 1603: memdesc->sgt = NULL; 1604: } 1605: 1606: static void kgsl_free_secure_pages(struct kgsl_memdesc *memdesc) 1607: { 1608: int ret; 1609: 1610: if (TEST_FLAG(KGSL_MEMDESC_MAPPED, &memdesc->priv)) 1611: return; 1612: 1613: ret = kgsl_unlock_sgt(memdesc->sgt); 1614: if (ret) { 1615: /* 1616: * Unlock of the secure buffer failed. This buffer will 1617: * be stuck in secure side forever and is unrecoverable. 1618: * Give up on the buffer and don't return it to the 1619: * pool. 1620: */ 1621: pr_err("kgsl: secure buf unlock failed: gpuaddr: %llx size: %llx ret: %d\n", 1622: memdesc->gpuaddr, memdesc->size, ret); 1623: return; 1624: } 1625: 1626: atomic_long_sub(memdesc->size, &kgsl_driver.stats.secure); 1627: 1628: kgsl_free_pages_from_sgt(memdesc); 1629: 1630: sg_free_table(memdesc->sgt); 1631: kfree(memdesc->sgt); 1632: 1633: memdesc->sgt = NULL; 1634: } 1635: 1636: void kgsl_free_secure_page(struct page *page) 1637: { 1638: struct sg_table sgt; 1639: struct scatterlist sgl; 1640: int ret; 1641: 1642: if (!page) 1643: return; 1644: 1645: sgt.sgl = &sgl; 1646: sgt.nents = 1; 1647: sgt.orig_nents = 1; 1648: sg_init_table(&sgl, 1); 1649: sg_set_page(&sgl, page, PAGE_SIZE, 0); 1650: 1651: ret = kgsl_unlock_sgt(&sgt); 1652: if (ret) 1653: /* 1654: * Unlock of the secure page failed. This page will be 1655: * stuck in secure side forever and is unrecoverable. 1656: * Give up on this page and don't free it. 1657: */ 1658: pr_err("kgsl_unlock_sgt failed ret %d\n", ret); 1659: else 1660: __free_page(page); 1661: } 1662: 1663: struct page *kgsl_alloc_secure_page(void) 1664: { 1665: struct page *page; 1666: struct sg_table sgt; 1667: struct scatterlist sgl; 1668: int status; 1669: 1670: page = alloc_page(GFP_KERNEL | __GFP_ZERO | 1671: __GFP_NORETRY | __GFP_HIGHMEM); 1672: if (!page) 1673: return NULL; 1674: 1675: sgt.sgl = &sgl; 1676: sgt.nents = 1; 1677: sgt.orig_nents = 1; 1678: sg_init_table(&sgl, 1); 1679: sg_set_page(&sgl, page, PAGE_SIZE, 0); --- FILE: \kgsl_sharedmem.h | HITS: 1 --- MATCH LINES: 22 10: #include 11: #include 12: #include 13: #include 14: 15: struct kgsl_device; 16: struct kgsl_process_private; 17: 18: /* Internal definitions for memdesc->priv */ 19: #define KGSL_MEMDESC_GUARD_PAGE BIT(0) 20: /* Set if the memdesc is mapped into all pagetables */ 21: #define KGSL_MEMDESC_GLOBAL BIT(1) 22: /* The memdesc is frozen during a snapshot */ 23: #define KGSL_MEMDESC_FROZEN BIT(2) 24: /* The memdesc is mapped into a pagetable */ 25: #define KGSL_MEMDESC_MAPPED BIT(3) 26: /* The memdesc is secured for content protection */ 27: #define KGSL_MEMDESC_SECURE BIT(4) 28: /* Memory is accessible in privileged mode */ 29: #define KGSL_MEMDESC_PRIVILEGED BIT(6) 30: /* This is an instruction buffer */ 31: #define KGSL_MEMDESC_UCODE BIT(7) 32: /* For global buffers, randomly assign an address from the region */ 33: #define KGSL_MEMDESC_RANDOM BIT(8) 34: /* Allocate memory from the system instead of the pools */ 35: #define KGSL_MEMDESC_SYSMEM BIT(9) 36: /* The memdesc pages can be reclaimed */ 37: #define KGSL_MEMDESC_CAN_RECLAIM BIT(10) 38: /* The memdesc pages were reclaimed */ 39: #define KGSL_MEMDESC_RECLAIMED BIT(11) 40: /* Skip reclaim of the memdesc pages */ 41: #define KGSL_MEMDESC_SKIP_RECLAIM BIT(12) 42: /* The memdesc is hypassigned to HLOS*/ 43: #define KGSL_MEMDESC_HYPASSIGNED_HLOS BIT(13) 44: 45: #define TEST_FLAG(_bit, _val) ((atomic_read(_val) & (_bit)) != 0) 46: #define SET_FLAG(_bit, _val) atomic_or((int)(_bit), (_val)) --- FILE: \kgsl_snapshot.c | HITS: 400 --- MATCH LINES: 18, 21, 25, 30, 38, 40, 41, 44, 46, 47, 49, 50, 51, 54, 64, 96, 107, 108, 117, 121, 122, 127, 145, 158, 159, 166, 169, 174, 191, 222, 223, 229, 260, 283, 285, 286, 287, 290, 294, 297, 298, 312, 335, 342, 345, 346, 347, 351, 367, 368, 369, 370, 376, 378, 379, 384, 391, 392, 395, 398, 399, 400, 404, 421, 422, 426, 435, 436, 440, 441, 443, 447, 450, 451, 455, 456, 457, 467, 472, 484, 488, 489, 490, 493, 495, 496, 498, 501, 502, 504, 505, 507, 508, 537, 539, 542, 546, 549, 550, 552, 553, 554, 555, 557, 558, 559, 561, 562, 565, 566, 567, 568, 569, 572, 574, 579, 580, 581, 582, 585, 586, 587, 589, 590, 595, 598, 602, 603, 605, 606, 613, 615, 616, 619, 620, 624, 625, 628, 630, 631, 633, 637, 643, 645, 650, 654, 657, 660, 661, 663, 664, 665, 666, 667, 669, 670, 677, 678, 679, 682, 683, 684, 687, 688, 689, 690, 692, 693, 694, 695, 696, 697, 699, 701, 702, 710, 713, 714, 717, 718, 719, 721, 722, 727, 730, 736, 738, 741, 742, 750, 751, 753, 755, 757, 761, 765, 767, 775, 776, 779, 781, 782, 784, 788, 791, 792, 794, 796, 797, 800, 801, 805, 808, 809, 814, 819, 820, 821, 826, 827, 838, 841, 846, 851, 852, 854, 855, 858, 862, 865, 872, 873, 880, 882, 886, 895, 898, 899, 900, 901, 905, 906, 910, 917, 920, 925, 962, 963, 967, 970, 971, 979, 983, 984, 986, 990, 991, 996, 1000, 1006, 1011, 1013, 1016, 1021, 1025, 1029, 1032, 1033, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1051, 1054, 1066, 1069, 1079, 1080, 1081, 1084, 1085, 1088, 1092, 1093, 1094, 1108, 1117, 1120, 1121, 1124, 1136, 1138, 1139, 1141, 1142, 1147, 1153, 1155, 1157, 1158, 1161, 1164, 1165, 1166, 1167, 1170, 1172, 1176, 1177, 1179, 1180, 1182, 1185, 1188, 1189, 1192, 1194, 1195, 1199, 1200, 1204, 1206, 1212, 1216, 1218, 1220, 1223, 1224, 1230, 1232, 1234, 1236, 1237, 1238, 1240, 1241, 1242, 1243, 1247, 1249, 1254, 1257, 1260, 1266, 1270, 1271, 1273, 1274, 1275, 1276, 1283, 1284, 1288, 1289, 1299, 1300, 1303, 1304, 1313, 1314, 1318, 1320, 1321, 1322, 1326, 1329, 1331, 1335, 1336, 1342, 1344, 1345, 1348, 1349, 1350, 1353, 1356, 1361, 1363, 1364, 1365, 1366, 1368, 1369, 1370, 1371, 1372, 1373, 1374, 1375, 1378, 1379, 1380, 1381 6: 7: #include 8: #include 9: #include 10: #include 11: #include 12: #include 13: 14: #include "adreno_cp_parser.h" 15: #include "kgsl_device.h" 16: #include "kgsl_eventlog.h" 17: #include "kgsl_sharedmem.h" 18: #include "kgsl_snapshot.h" 19: #include "kgsl_util.h" 20: 21: static void kgsl_snapshot_save_frozen_objs(struct work_struct *work); 22: 23: /* Placeholder for list of ib objects that contain all objects in that IB */ 24: 25: struct kgsl_snapshot_cp_obj { 26: struct adreno_ib_object_list *ib_obj_list; 27: struct list_head node; 28: }; 29: 30: struct snapshot_obj_itr { 31: u8 *buf; /* Buffer pointer to write to */ 32: int pos; /* Current position in the sequence */ 33: loff_t offset; /* file offset to start writing from */ 34: size_t remain; /* Bytes remaining in buffer */ 35: size_t write; /* Bytes written so far */ 36: }; 37: 38: static inline u64 snapshot_phy_addr(struct kgsl_device *device) 39: { 40: return device->snapshot_memory.dma_handle ? 41: device->snapshot_memory.dma_handle : __pa(device->snapshot_memory.ptr); 42: } 43: 44: static inline u64 atomic_snapshot_phy_addr(struct kgsl_device *device) 45: { 46: if (device->snapshot_memory_atomic.ptr == device->snapshot_memory.ptr) 47: return snapshot_phy_addr(device); 48: 49: return device->snapshot_memory_atomic.dma_handle ? 50: device->snapshot_memory_atomic.dma_handle : 51: __pa(device->snapshot_memory_atomic.ptr); 52: } 53: 54: static void obj_itr_init(struct snapshot_obj_itr *itr, u8 *buf, 55: loff_t offset, size_t remain) 56: { 57: itr->buf = buf; 58: itr->offset = offset; 59: itr->remain = remain; 60: itr->pos = 0; 61: itr->write = 0; 62: } 63: 64: static int obj_itr_out(struct snapshot_obj_itr *itr, void *src, int size) 65: { 66: if (itr->remain == 0) 67: return 0; 68: 69: if ((itr->pos + size) <= itr->offset) 70: goto done; 71: 72: /* Handle the case that offset is in the middle of the buffer */ 73: 74: if (itr->offset > itr->pos) { 75: src += (itr->offset - itr->pos); 76: size -= (itr->offset - itr->pos); 77: 78: /* Advance pos to the offset start */ 79: itr->pos = itr->offset; 80: } 81: 82: if (size > itr->remain) 83: size = itr->remain; 84: 85: memcpy(itr->buf, src, size); 86: 87: itr->buf += size; 88: itr->write += size; 89: itr->remain -= size; 90: 91: done: 92: itr->pos += size; 93: return size; 94: } 95: 96: static void kgsl_snapshot_put_object(struct kgsl_snapshot_object *obj) 97: { 98: list_del(&obj->node); 99: 100: CLEAR_FLAG(KGSL_MEMDESC_FROZEN | KGSL_MEMDESC_SKIP_RECLAIM, &obj->entry->memdesc.priv); 101: kgsl_mem_entry_put(obj->entry); 102: 103: kfree(obj); 104: } 105: 106: /** 107: * kgsl_snapshot_have_object() - return 1 if the object has been processed 108: * @snapshot: the snapshot data 109: * @process: The process that owns the object to freeze 110: * @gpuaddr: The gpu address of the object to freeze 111: * @size: the size of the object (may not always be the size of the region) 112: * 113: * Return 1 if the object is already in the list - this can save us from 114: * having to parse the same thing over again. There are 2 lists that are 115: * tracking objects so check for the object in both lists 116: */ 117: int kgsl_snapshot_have_object(struct kgsl_snapshot *snapshot, 118: struct kgsl_process_private *process, 119: uint64_t gpuaddr, uint64_t size) 120: { 121: struct kgsl_snapshot_object *obj; 122: struct kgsl_snapshot_cp_obj *obj_cp; 123: struct adreno_ib_object *ib_obj; 124: int i; 125: 126: /* Check whether the object is tracked already in ib list */ 127: list_for_each_entry(obj_cp, &snapshot->cp_list, node) { 128: if (obj_cp->ib_obj_list == NULL 129: || obj_cp->ib_obj_list->num_objs == 0) 130: continue; 131: 132: ib_obj = &(obj_cp->ib_obj_list->obj_list[0]); 133: if (ib_obj->entry == NULL || ib_obj->entry->priv != process) 134: continue; 135: 136: for (i = 0; i < obj_cp->ib_obj_list->num_objs; i++) { 137: ib_obj = &(obj_cp->ib_obj_list->obj_list[i]); 138: if ((gpuaddr >= ib_obj->gpuaddr) && 139: ((gpuaddr + size) <= 140: (ib_obj->gpuaddr + ib_obj->size))) 141: return 1; 142: } 143: } 144: 145: list_for_each_entry(obj, &snapshot->obj_list, node) { 146: if (obj->entry == NULL || obj->entry->priv != process) 147: continue; 148: 149: if ((gpuaddr >= obj->gpuaddr) && 150: ((gpuaddr + size) <= (obj->gpuaddr + obj->size))) 151: return 1; 152: } 153: 154: return 0; 155: } 156: 157: /** 158: * kgsl_snapshot_get_object() - Mark a GPU buffer to be frozen 159: * @snapshot: The snapshot data 160: * @process: The process that owns the object we want to freeze 161: * @gpuaddr: The gpu address of the object to freeze 162: * @size: the size of the object (may not always be the size of the region) 163: * @type: the type of object being saved (shader, vbo, etc) 164: * 165: * Mark and freeze a GPU buffer object. This will prevent it from being 166: * freed until it can be copied out as part of the snapshot dump. Returns the 167: * size of the object being frozen 168: */ 169: int kgsl_snapshot_get_object(struct kgsl_snapshot *snapshot, 170: struct kgsl_process_private *process, uint64_t gpuaddr, 171: uint64_t size, u32 type) 172: { 173: struct kgsl_mem_entry *entry; 174: struct kgsl_snapshot_object *obj; 175: uint64_t offset; 176: int ret = -EINVAL; 177: u32 mem_type; 178: 179: if (!gpuaddr) 180: return 0; 181: 182: entry = kgsl_sharedmem_find(process, gpuaddr); 183: 184: if (entry == NULL) 185: return -EINVAL; 186: 187: /* We can't freeze external memory, because we don't own it */ 188: if (entry->memdesc.flags & KGSL_MEMFLAGS_USERMEM_MASK) 189: goto err_put; 190: /* 191: * Do not save texture and render targets in snapshot, 192: * they can be just too big 193: */ 194: 195: mem_type = kgsl_memdesc_get_memtype(&entry->memdesc); 196: if (mem_type == KGSL_MEMTYPE_TEXTURE || 197: mem_type == KGSL_MEMTYPE_EGL_SURFACE || 198: mem_type == KGSL_MEMTYPE_SURFACE || 199: mem_type == KGSL_MEMTYPE_EGL_IMAGE) { 200: ret = 0; 201: goto err_put; 202: } 203: 204: /* 205: * size indicates the number of bytes in the region to save. This might 206: * not always be the entire size of the region because some buffers are 207: * sub-allocated from a larger region. However, if size 0 was passed 208: * thats a flag that the caller wants to capture the entire buffer 209: */ 210: 211: if (size == 0) { 212: size = entry->memdesc.size; 213: offset = 0; 214: 215: /* Adjust the gpuaddr to the start of the object */ 216: gpuaddr = entry->memdesc.gpuaddr; 217: } else { 218: offset = gpuaddr - entry->memdesc.gpuaddr; 219: } 220: 221: if (size + offset > entry->memdesc.size) { 222: dev_err(snapshot->device->dev, 223: "snapshot: invalid size for GPU buffer 0x%016llx\n", 224: gpuaddr); 225: goto err_put; 226: } 227: 228: /* If the buffer is already on the list, skip it */ 229: list_for_each_entry(obj, &snapshot->obj_list, node) { 230: /* combine the range with existing object if they overlap */ 231: if (obj->entry->priv == process && obj->type == type && 232: kgsl_addr_range_overlap(obj->gpuaddr, obj->size, 233: gpuaddr, size)) { 234: uint64_t end1 = obj->gpuaddr + obj->size; 235: uint64_t end2 = gpuaddr + size; 236: 237: if (obj->gpuaddr > gpuaddr) 238: obj->gpuaddr = gpuaddr; 239: if (end1 > end2) 240: obj->size = end1 - obj->gpuaddr; 241: else 242: obj->size = end2 - obj->gpuaddr; 243: obj->offset = obj->gpuaddr - entry->memdesc.gpuaddr; 244: ret = 0; 245: goto err_put; 246: } 247: } 248: 249: obj = kzalloc(sizeof(*obj), GFP_KERNEL); 250: 251: if (obj == NULL) 252: goto err_put; 253: 254: obj->type = type; 255: obj->entry = entry; 256: obj->gpuaddr = gpuaddr; 257: obj->size = size; 258: obj->offset = offset; 259: 260: list_add(&obj->node, &snapshot->obj_list); 261: 262: /* 263: * Return the size of the entire mem entry that was frozen - this gets 264: * used for tracking how much memory is frozen for a hang. Also, mark 265: * the memory entry as frozen. If the entry was already marked as 266: * frozen, then another buffer already got to it. In that case, return 267: * 0 so it doesn't get counted twice 268: */ 269: 270: ret = (TEST_FLAG(KGSL_MEMDESC_FROZEN, &entry->memdesc.priv)) ? 0 271: : entry->memdesc.size; 272: 273: SET_FLAG(KGSL_MEMDESC_FROZEN, &entry->memdesc.priv); 274: 275: return ret; 276: err_put: 277: CLEAR_FLAG(KGSL_MEMDESC_SKIP_RECLAIM, &entry->memdesc.priv); 278: kgsl_mem_entry_put(entry); 279: return ret; 280: } 281: 282: /** 283: * kgsl_snapshot_dump_registers - helper function to dump device registers 284: * @device - the device to dump registers from 285: * @snapshot - pointer to the start of the region of memory for the snapshot 286: * @remain - a pointer to the number of bytes remaining in the snapshot 287: * @priv - A pointer to the kgsl_snapshot_registers data 288: * 289: * Given an array of register ranges pairs (start,end [inclusive]), dump the 290: * registers into a snapshot register section. The snapshot region stores a 291: * part of dwords for each register - the word address of the register, and 292: * the value. 293: */ 294: size_t kgsl_snapshot_dump_registers(struct kgsl_device *device, u8 *buf, 295: size_t remain, void *priv) 296: { 297: struct kgsl_snapshot_regs *header = (struct kgsl_snapshot_regs *)buf; 298: struct kgsl_snapshot_registers *regs = priv; 299: u32 *data = (u32 *)(buf + sizeof(*header)); 300: int count = 0, j, k; 301: 302: /* Figure out how many registers we are going to dump */ 303: 304: for (j = 0; j < regs->count; j++) { 305: int start = regs->regs[j * 2]; 306: int end = regs->regs[j * 2 + 1]; 307: 308: count += (end - start + 1); 309: } 310: 311: if (remain < (count * 8) + sizeof(*header)) { 312: SNAPSHOT_ERR_NOMEM(device, "REGISTERS"); 313: return 0; 314: } 315: 316: for (j = 0; j < regs->count; j++) { 317: u32 start = regs->regs[j * 2]; 318: u32 end = regs->regs[j * 2 + 1]; 319: 320: for (k = start; k <= end; k++) { 321: u32 val; 322: 323: kgsl_regread(device, k, &val); 324: *data++ = k; 325: *data++ = val; 326: } 327: } 328: 329: header->count = count; 330: 331: /* Return the size of the section */ 332: return (count * 8) + sizeof(*header); 333: } 334: 335: struct kgsl_snapshot_indexed_registers { 336: u32 index; 337: u32 data; 338: u32 start; 339: u32 count; 340: }; 341: 342: static size_t kgsl_snapshot_dump_indexed_regs(struct kgsl_device *device, 343: u8 *buf, size_t remain, void *priv) 344: { 345: struct kgsl_snapshot_indexed_registers *iregs = priv; 346: struct kgsl_snapshot_indexed_regs *header = 347: (struct kgsl_snapshot_indexed_regs *)buf; 348: u32 *data = (u32 *)(buf + sizeof(*header)); 349: 350: if (remain < (iregs->count * 4) + sizeof(*header)) { 351: SNAPSHOT_ERR_NOMEM(device, "INDEXED REGS"); 352: return 0; 353: } 354: 355: header->index_reg = iregs->index; 356: header->data_reg = iregs->data; 357: header->count = iregs->count; 358: header->start = iregs->start; 359: 360: kgsl_regmap_read_indexed_interleaved(&device->regmap, iregs->index, 361: iregs->data, data, iregs->start, iregs->count); 362: 363: return (iregs->count * 4) + sizeof(*header); 364: } 365: 366: /** 367: * kgsl_snapshot_indexed_registers - Add a set of indexed registers to the 368: * snapshot 369: * @device: Pointer to the KGSL device being snapshotted 370: * @snapshot: Snapshot instance 371: * @index: Offset for the index register 372: * @data: Offset for the data register 373: * @start: Index to start reading 374: * @count: Number of entries to read 375: * 376: * Dump the values from an indexed register group into the snapshot 377: */ 378: void kgsl_snapshot_indexed_registers(struct kgsl_device *device, 379: struct kgsl_snapshot *snapshot, 380: u32 index, u32 data, 381: u32 start, 382: u32 count) 383: { 384: struct kgsl_snapshot_indexed_registers iregs; 385: 386: iregs.index = index; 387: iregs.data = data; 388: iregs.start = start; 389: iregs.count = count; 390: 391: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_INDEXED_REGS, 392: snapshot, kgsl_snapshot_dump_indexed_regs, &iregs); 393: } 394: 395: static size_t kgsl_snapshot_dump_indexed_regs_v2(struct kgsl_device *device, 396: u8 *buf, size_t remain, void *priv) 397: { 398: struct kgsl_snapshot_indexed_registers_v2 *iregs = priv; 399: struct kgsl_snapshot_indexed_regs_v2 *header = 400: (struct kgsl_snapshot_indexed_regs_v2 *)buf; 401: u32 *data = (u32 *)(buf + sizeof(*header)); 402: 403: if (remain < ((iregs->count * 4) + sizeof(*header))) { 404: SNAPSHOT_ERR_NOMEM(device, "INDEXED REGS"); 405: return 0; 406: } 407: 408: header->index_reg = iregs->index; 409: header->data_reg = iregs->data; 410: header->count = iregs->count; 411: header->start = iregs->start; 412: header->pipe_id = iregs->pipe_id; 413: header->slice_id = iregs->slice_id; 414: 415: kgsl_regmap_read_indexed_interleaved(&device->regmap, iregs->index, 416: iregs->data, data, iregs->start, iregs->count); 417: 418: return (iregs->count * 4) + sizeof(*header); 419: } 420: 421: void kgsl_snapshot_indexed_registers_v2(struct kgsl_device *device, 422: struct kgsl_snapshot *snapshot, 423: u32 index, u32 data, u32 start, u32 count, 424: u32 pipe_id, u32 slice_id) 425: { 426: struct kgsl_snapshot_indexed_registers_v2 iregs; 427: 428: iregs.index = index; 429: iregs.data = data; 430: iregs.start = start; 431: iregs.count = count; 432: iregs.pipe_id = pipe_id; 433: iregs.slice_id = slice_id; 434: 435: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_INDEXED_REGS_V2, 436: snapshot, kgsl_snapshot_dump_indexed_regs_v2, &iregs); 437: } 438: 439: /** 440: * kgsl_snapshot_add_section() - Add a new section to the GPU snapshot 441: * @device: the KGSL device being snapshotted 442: * @id: the section id 443: * @snapshot: pointer to the snapshot instance 444: * @func: Function pointer to fill the section 445: * @priv: Private pointer to pass to the function 446: * 447: * Set up a KGSL snapshot header by filling the memory with the callback 448: * function and adding the standard section header 449: */ 450: void kgsl_snapshot_add_section(struct kgsl_device *device, u16 id, 451: struct kgsl_snapshot *snapshot, 452: size_t (*func)(struct kgsl_device *, u8 *, size_t, void *), 453: void *priv) 454: { 455: struct kgsl_snapshot_section_header *header = 456: (struct kgsl_snapshot_section_header *)snapshot->ptr; 457: u8 *data = snapshot->ptr + sizeof(*header); 458: size_t ret = 0; 459: 460: /* 461: * Sanity check to make sure there is enough for the header. The 462: * callback will check to make sure there is enough for the rest 463: * of the data. If there isn't enough room then don't advance the 464: * pointer. 465: */ 466: 467: if (snapshot->remain < sizeof(*header)) 468: return; 469: 470: /* It is legal to have no function (i.e. - make an empty section) */ 471: if (func) { 472: ret = func(device, data, snapshot->remain - sizeof(*header), 473: priv); 474: 475: /* 476: * If there wasn't enough room for the data then don't bother 477: * setting up the header. 478: */ 479: 480: if (ret == 0) 481: return; 482: } 483: 484: header->magic = SNAPSHOT_SECTION_MAGIC; 485: header->id = id; 486: header->size = ret + sizeof(*header); 487: 488: snapshot->ptr += header->size; 489: snapshot->remain -= header->size; 490: snapshot->size += header->size; 491: } 492: 493: static void kgsl_free_snapshot(struct kgsl_snapshot *snapshot) 494: { 495: struct kgsl_snapshot_object *obj, *tmp; 496: struct kgsl_device *device = snapshot->device; 497: 498: wait_for_completion(&snapshot->dump_gate); 499: 500: list_for_each_entry_safe(obj, tmp, 501: &snapshot->obj_list, node) 502: kgsl_snapshot_put_object(obj); 503: 504: if (snapshot->mempool) 505: vfree(snapshot->mempool); 506: 507: kfree(snapshot); 508: dev_err(device->dev, "snapshot: objects released\n"); 509: } 510: 511: #define SP0_ISDB_ISDB_BRKPT_CFG 0x40014 512: #define SP0_ISDB_ISDB_EN 0x40004 513: #define SP0_ISDB_ISDB_CMD 0x4000C 514: 515: void isdb_write(void __iomem *base, u32 offset) 516: { 517: /* To set the SCHBREAKTYPE bit */ 518: __raw_writel(0x801, base + SP0_ISDB_ISDB_BRKPT_CFG + offset); 519: 520: /* 521: * ensure the configurations are set before 522: * enabling ISDB 523: */ 524: wmb(); 525: /* To set the ISDBCLKON and ISDB_EN bits*/ 526: __raw_writel(0x03, base + SP0_ISDB_ISDB_EN + offset); 527: 528: /* 529: * ensure previous write to enable isdb posts 530: * before issuing the break command 531: */ 532: wmb(); 533: /*To issue ISDB_0_ISDB_CMD_BREAK*/ 534: __raw_writel(0x1, base + SP0_ISDB_ISDB_CMD + offset); 535: } 536: 537: static void kgsl_device_snapshot_atomic(struct kgsl_device *device) 538: { 539: struct kgsl_snapshot *snapshot; 540: struct timespec64 boot; 541: 542: if (device->snapshot && device->force_panic) 543: return; 544: 545: if (WARN(!kgsl_state_is_awake(device), 546: "snapshot: device is powered off\n")) 547: return; 548: 549: if (device->snapshot_memory_atomic.ptr) 550: goto snapshot; 551: 552: device->snapshot_memory_atomic.size = device->snapshot_memory.size; 553: if (!device->snapshot_faultcount) { 554: /* Use non-atomic snapshot memory if it is unused */ 555: device->snapshot_memory_atomic.ptr = device->snapshot_memory.ptr; 556: } else { 557: /* Limit size to 3MB to avoid failure for atomic snapshot memory */ 558: if (device->snapshot_memory_atomic.size > (SZ_2M + SZ_1M)) 559: device->snapshot_memory_atomic.size = (SZ_2M + SZ_1M); 560: 561: device->snapshot_memory_atomic.ptr = devm_kzalloc(&device->pdev->dev, 562: device->snapshot_memory_atomic.size, GFP_ATOMIC); 563: 564: /* If we fail to allocate more than 1MB fall back to 1MB */ 565: if (WARN_ON((!device->snapshot_memory_atomic.ptr) && 566: device->snapshot_memory_atomic.size > SZ_1M)) { 567: device->snapshot_memory_atomic.size = SZ_1M; 568: device->snapshot_memory_atomic.ptr = devm_kzalloc(&device->pdev->dev, 569: device->snapshot_memory_atomic.size, GFP_ATOMIC); 570: } 571: 572: if (!device->snapshot_memory_atomic.ptr) { 573: dev_err(device->dev, 574: "Failed to allocate memory for atomic snapshot\n"); 575: return; 576: } 577: } 578: 579: snapshot: 580: /* Allocate memory for the snapshot instance */ 581: snapshot = kzalloc(sizeof(*snapshot), GFP_ATOMIC); 582: if (snapshot == NULL) 583: return; 584: 585: device->snapshot_atomic = true; 586: INIT_LIST_HEAD(&snapshot->obj_list); 587: INIT_LIST_HEAD(&snapshot->cp_list); 588: 589: snapshot->start = device->snapshot_memory_atomic.ptr; 590: snapshot->ptr = device->snapshot_memory_atomic.ptr; 591: 592: /* Ensure size is read after reading address */ 593: smp_rmb(); 594: 595: snapshot->remain = device->snapshot_memory_atomic.size; 596: 597: /* 598: * Trigger both GPU and GMU snapshot. GPU specific code 599: * will take care of whether to dumps full state or only 600: * GMU state based on current GPU power state. 601: */ 602: if (device->ftbl->snapshot) 603: device->ftbl->snapshot(device, snapshot, NULL, NULL); 604: 605: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_EVENTLOG, 606: snapshot, kgsl_snapshot_eventlog_buffer, NULL); 607: 608: /* 609: * The timestamp is the seconds since boot so it is easier to match to 610: * the kernel log 611: */ 612: getboottime64(&boot); 613: snapshot->timestamp = ktime_get_real_seconds() - boot.tv_sec; 614: 615: kgsl_add_to_minidump("ATOMIC_GPU_SNAPSHOT", (u64) device->snapshot_memory_atomic.ptr, 616: atomic_snapshot_phy_addr(device), device->snapshot_memory_atomic.size); 617: 618: /* log buffer info to aid in ramdump fault tolerance */ 619: dev_err(device->dev, "Atomic GPU snapshot created at pa %llx++0x%zx\n", 620: atomic_snapshot_phy_addr(device), snapshot->size); 621: } 622: 623: /** 624: * kgsl_device_snapshot() - construct a device snapshot 625: * @device: device to snapshot 626: * @context: the context that is hung, might be NULL if unknown. 627: * @context_lpac: the lpac context that is hung, might be NULL if unknown. 628: * @gmu_fault: whether this snapshot is triggered by a GMU fault. 629: * 630: * Given a device, construct a binary snapshot dump of the current device state 631: * and store it in the device snapshot memory. 632: */ 633: void kgsl_device_snapshot(struct kgsl_device *device, 634: struct kgsl_context *context, struct kgsl_context *context_lpac, 635: bool gmu_fault) 636: { 637: struct kgsl_snapshot *snapshot; 638: struct timespec64 boot; 639: 640: if (device->ftbl->set_isdb_breakpoint_registers) 641: device->ftbl->set_isdb_breakpoint_registers(device); 642: 643: if (device->snapshot_memory.ptr == NULL) { 644: dev_err(device->dev, 645: "snapshot: no snapshot memory available\n"); 646: return; 647: } 648: 649: if (WARN(!kgsl_state_is_awake(device), 650: "snapshot: device is powered off\n")) 651: return; 652: 653: /* increment the hang count for good book keeping */ 654: device->snapshot_faultcount++; 655: device->gmu_fault = gmu_fault; 656: 657: if (device->snapshot != NULL) { 658: 659: /* 660: * Snapshot over-write policy: 661: * 1. By default, don't over-write the very first snapshot, 662: * be it a gmu or gpu fault. 663: * 2. Never over-write existing snapshot on a gpu fault. 664: * 3. Never over-write a snapshot that we didn't recover from. 665: * 4. In order to over-write a new gmu fault snapshot with a 666: * previously recovered fault, then set the sysfs knob 667: * prioritize_recoverable to true. 668: */ 669: if (!device->prioritize_unrecoverable || 670: !device->snapshot->recovered || !gmu_fault) 671: return; 672: 673: /* 674: * If another thread is currently reading it, that thread 675: * will free it, otherwise free it now. 676: */ 677: if (!device->snapshot->sysfs_read) 678: kgsl_free_snapshot(device->snapshot); 679: device->snapshot = NULL; 680: } 681: 682: /* Allocate memory for the snapshot instance */ 683: snapshot = kzalloc(sizeof(*snapshot), GFP_KERNEL); 684: if (snapshot == NULL) 685: return; 686: 687: init_completion(&snapshot->dump_gate); 688: INIT_LIST_HEAD(&snapshot->obj_list); 689: INIT_LIST_HEAD(&snapshot->cp_list); 690: INIT_WORK(&snapshot->work, kgsl_snapshot_save_frozen_objs); 691: 692: snapshot->start = device->snapshot_memory.ptr; 693: snapshot->ptr = device->snapshot_memory.ptr; 694: snapshot->remain = device->snapshot_memory.size; 695: snapshot->recovered = false; 696: snapshot->first_read = true; 697: snapshot->sysfs_read = 0; 698: 699: device->ftbl->snapshot(device, snapshot, context, context_lpac); 700: 701: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_EVENTLOG, 702: snapshot, kgsl_snapshot_eventlog_buffer, NULL); 703: 704: /* 705: * The timestamp is the seconds since boot so it is easier to match to 706: * the kernel log 707: */ 708: 709: getboottime64(&boot); 710: snapshot->timestamp = ktime_get_real_seconds() - boot.tv_sec; 711: 712: /* Store the instance in the device until it gets dumped */ 713: device->snapshot = snapshot; 714: snapshot->device = device; 715: 716: /* log buffer info to aid in ramdump fault tolerance */ 717: dev_err(device->dev, "%s snapshot created at pa %llx++0x%zx\n", 718: gmu_fault ? "GMU" : "GPU", snapshot_phy_addr(device), 719: snapshot->size); 720: 721: kgsl_add_to_minidump("GPU_SNAPSHOT", (u64) device->snapshot_memory.ptr, 722: snapshot_phy_addr(device), device->snapshot_memory.size); 723: 724: if (device->skip_ib_capture) 725: BUG_ON(device->force_panic); 726: 727: sysfs_notify(&device->snapshot_kobj, NULL, "timestamp"); 728: 729: /* 730: * Queue a work item that will save the IB data in snapshot into 731: * static memory to prevent loss of data due to overwriting of 732: * memory. If force panic is enabled, there is no need to move 733: * ahead and IB data can be dumped inline. 734: */ 735: if (device->force_panic) 736: kgsl_snapshot_save_frozen_objs(&snapshot->work); 737: else 738: kgsl_schedule_work(&snapshot->work); 739: } 740: 741: /* An attribute for showing snapshot details */ 742: struct kgsl_snapshot_attribute { 743: struct attribute attr; 744: ssize_t (*show)(struct kgsl_device *device, char *buf); 745: ssize_t (*store)(struct kgsl_device *device, const char *buf, 746: size_t count); 747: }; 748: 749: /** 750: * kgsl_snapshot_process_ib_obj_list() - Go through the list of IB's which need 751: * to be dumped for snapshot and move them to the global snapshot list so 752: * they will get dumped when the global list is dumped 753: * @device: device being snapshotted 754: */ 755: static void kgsl_snapshot_process_ib_obj_list(struct kgsl_snapshot *snapshot) 756: { 757: struct kgsl_snapshot_cp_obj *obj, *obj_temp; 758: struct adreno_ib_object *ib_obj; 759: int i; 760: 761: list_for_each_entry_safe(obj, obj_temp, &snapshot->cp_list, 762: node) { 763: for (i = 0; i < obj->ib_obj_list->num_objs; i++) { 764: ib_obj = &(obj->ib_obj_list->obj_list[i]); 765: kgsl_snapshot_get_object(snapshot, ib_obj->entry->priv, 766: ib_obj->gpuaddr, ib_obj->size, 767: ib_obj->snapshot_obj_type); 768: } 769: list_del(&obj->node); 770: adreno_ib_destroy_obj_list(obj->ib_obj_list); 771: kfree(obj); 772: } 773: } 774: 775: #define to_snapshot_attr(a) \ 776: container_of(a, struct kgsl_snapshot_attribute, attr) 777: 778: #define kobj_to_device(a) \ 779: container_of(a, struct kgsl_device, snapshot_kobj) 780: 781: static int snapshot_release(struct kgsl_device *device, 782: struct kgsl_snapshot *snapshot) 783: { 784: bool snapshot_free = false; 785: int ret = 0; 786: 787: kgsl_mutex_lock(&device->mutex); 788: snapshot->sysfs_read--; 789: 790: /* 791: * If someone's replaced the snapshot, return an error and free 792: * the snapshot if this is the last thread to read it. 793: */ 794: if (device->snapshot != snapshot) { 795: ret = -EIO; 796: if (!snapshot->sysfs_read) 797: snapshot_free = true; 798: } 799: kgsl_mutex_unlock(&device->mutex); 800: if (snapshot_free) 801: kgsl_free_snapshot(snapshot); 802: return ret; 803: } 804: 805: static ssize_t kgsl_snapshot_do_read(struct kgsl_snapshot *snapshot, 806: char *buf, loff_t off, size_t count) 807: { 808: struct kgsl_snapshot_section_header head; 809: struct snapshot_obj_itr itr; 810: int ret; 811: 812: obj_itr_init(&itr, buf, off, count); 813: 814: ret = obj_itr_out(&itr, snapshot->start, snapshot->size); 815: if (ret == 0) 816: goto out; 817: 818: /* Dump the memory pool if it exists */ 819: if (snapshot->mempool) { 820: ret = obj_itr_out(&itr, snapshot->mempool, 821: snapshot->mempool_size); 822: if (ret == 0) 823: goto out; 824: } 825: 826: head.magic = SNAPSHOT_SECTION_MAGIC; 827: head.id = KGSL_SNAPSHOT_SECTION_END; 828: head.size = sizeof(head); 829: 830: obj_itr_out(&itr, &head, sizeof(head)); 831: 832: out: 833: return itr.write; 834: } 835: 836: /* Dump the sysfs binary data to the user */ 837: #if (KERNEL_VERSION(6, 16, 0) > LINUX_VERSION_CODE) 838: static ssize_t snapshot_show(struct file *filep, struct kobject *kobj, 839: struct bin_attribute *attr, char *buf, loff_t off, size_t count) 840: #else 841: static ssize_t snapshot_show(struct file *filep, struct kobject *kobj, 842: const struct bin_attribute *attr, char *buf, loff_t off, size_t count) 843: #endif 844: { 845: struct kgsl_device *device = kobj_to_device(kobj); 846: struct kgsl_snapshot *snapshot; 847: ssize_t written; 848: int ret = 0; 849: 850: kgsl_mutex_lock(&device->mutex); 851: snapshot = device->snapshot; 852: if (snapshot != NULL) { 853: /* 854: * If we're reading at a non-zero offset from a new snapshot, 855: * that means we want to read from the previous snapshot (which 856: * was overwritten), so return an error 857: */ 858: if (snapshot->first_read) { 859: if (off) 860: ret = -EIO; 861: else 862: snapshot->first_read = false; 863: } 864: if (!ret) 865: snapshot->sysfs_read++; 866: } 867: kgsl_mutex_unlock(&device->mutex); 868: 869: if (ret) 870: return ret; 871: 872: /* Return nothing if we haven't taken a snapshot yet */ 873: if (snapshot == NULL) 874: return 0; 875: 876: /* 877: * Wait for the dump worker to finish. This is interruptible 878: * to allow userspace to bail if things go horribly wrong. 879: */ 880: ret = wait_for_completion_interruptible(&snapshot->dump_gate); 881: if (ret) { 882: snapshot_release(device, snapshot); 883: return ret; 884: } 885: 886: written = kgsl_snapshot_do_read(snapshot, buf, off, count); 887: 888: /* 889: * Make sure everything has been written out before destroying things. 890: * The best way to confirm this is to go all the way through without 891: * writing any bytes - so only release if we get this far and 892: * written is 0 and there are no concurrent reads pending 893: */ 894: if (written == 0) { 895: bool snapshot_free = false; 896: 897: kgsl_mutex_lock(&device->mutex); 898: if (--snapshot->sysfs_read == 0) { 899: if (device->snapshot == snapshot) 900: device->snapshot = NULL; 901: snapshot_free = true; 902: } 903: kgsl_mutex_unlock(&device->mutex); 904: 905: if (snapshot_free) 906: kgsl_free_snapshot(snapshot); 907: return 0; 908: } 909: 910: ret = snapshot_release(device, snapshot); 911: return (ret < 0) ? ret : written; 912: } 913: 914: /* Show the total number of hangs since device boot */ 915: static ssize_t faultcount_show(struct kgsl_device *device, char *buf) 916: { 917: return scnprintf(buf, PAGE_SIZE, "%d\n", device->snapshot_faultcount); 918: } 919: 920: /* Reset the total number of hangs since device boot */ 921: static ssize_t faultcount_store(struct kgsl_device *device, const char *buf, 922: size_t count) 923: { 924: if (count) 925: device->snapshot_faultcount = 0; 926: 927: return count; 928: } 929: 930: /* Show the force_panic request status */ 931: static ssize_t force_panic_show(struct kgsl_device *device, char *buf) 932: { 933: return scnprintf(buf, PAGE_SIZE, "%d\n", device->force_panic); 934: } 935: 936: /* Store the panic request value to force_panic */ 937: static ssize_t force_panic_store(struct kgsl_device *device, const char *buf, 938: size_t count) 939: { 940: int ret; 941: 942: ret = kstrtobool(buf, &device->force_panic); 943: return ret ? ret : count; 944: } 945: 946: /* Show the break_ib request status */ 947: static ssize_t skip_ib_capture_show(struct kgsl_device *device, char *buf) 948: { 949: return scnprintf(buf, PAGE_SIZE, "%d\n", device->skip_ib_capture); 950: } 951: 952: /* Store the panic request value to break_ib */ 953: static ssize_t skip_ib_capture_store(struct kgsl_device *device, 954: const char *buf, size_t count) 955: { 956: int ret; 957: 958: ret = kstrtobool(buf, &device->skip_ib_capture); 959: return ret ? ret : count; 960: } 961: 962: /* Show the prioritize_unrecoverable status */ 963: static ssize_t prioritize_unrecoverable_show( 964: struct kgsl_device *device, char *buf) 965: { 966: return scnprintf(buf, PAGE_SIZE, "%d\n", 967: device->prioritize_unrecoverable); 968: } 969: 970: /* Store the priority value to prioritize unrecoverable */ 971: static ssize_t prioritize_unrecoverable_store( 972: struct kgsl_device *device, const char *buf, size_t count) 973: { 974: int ret; 975: 976: if (IS_ENABLED(CONFIG_QCOM_KGSL_DEVCOREDUMP)) 977: return -EOPNOTSUPP; 978: 979: ret = kstrtobool(buf, &device->prioritize_unrecoverable); 980: return ret ? ret : count; 981: } 982: 983: /* Show the snapshot_crashdumper request status */ 984: static ssize_t snapshot_crashdumper_show(struct kgsl_device *device, char *buf) 985: { 986: return scnprintf(buf, PAGE_SIZE, "%d\n", device->snapshot_crashdumper); 987: } 988: 989: 990: /* Store the value to snapshot_crashdumper*/ 991: static ssize_t snapshot_crashdumper_store(struct kgsl_device *device, 992: const char *buf, size_t count) 993: { 994: int ret; 995: 996: ret = kstrtobool(buf, &device->snapshot_crashdumper); 997: return ret ? ret : count; 998: } 999: 1000: /* Show the timestamp of the last collected snapshot */ 1001: static ssize_t timestamp_show(struct kgsl_device *device, char *buf) 1002: { 1003: unsigned long timestamp; 1004: 1005: kgsl_mutex_lock(&device->mutex); 1006: timestamp = device->snapshot ? device->snapshot->timestamp : 0; 1007: kgsl_mutex_unlock(&device->mutex); 1008: return scnprintf(buf, PAGE_SIZE, "%lu\n", timestamp); 1009: } 1010: 1011: static ssize_t snapshot_legacy_show(struct kgsl_device *device, char *buf) 1012: { 1013: return scnprintf(buf, PAGE_SIZE, "%d\n", device->snapshot_legacy); 1014: } 1015: 1016: static ssize_t snapshot_legacy_store(struct kgsl_device *device, 1017: const char *buf, size_t count) 1018: { 1019: int ret; 1020: 1021: ret = kstrtobool(buf, &device->snapshot_legacy); 1022: return ret ? ret : count; 1023: } 1024: 1025: static struct bin_attribute snapshot_attr = { 1026: .attr.name = "dump", 1027: .attr.mode = 0444, 1028: .size = 0, 1029: .read = snapshot_show 1030: }; 1031: 1032: #define SNAPSHOT_ATTR(_name, _mode, _show, _store) \ 1033: struct kgsl_snapshot_attribute attr_##_name = { \ 1034: .attr = { .name = __stringify(_name), .mode = _mode }, \ 1035: .show = _show, \ 1036: .store = _store, \ 1037: } 1038: 1039: static SNAPSHOT_ATTR(timestamp, 0444, timestamp_show, NULL); 1040: static SNAPSHOT_ATTR(faultcount, 0644, faultcount_show, faultcount_store); 1041: static SNAPSHOT_ATTR(force_panic, 0644, force_panic_show, force_panic_store); 1042: static SNAPSHOT_ATTR(prioritize_unrecoverable, 0644, 1043: prioritize_unrecoverable_show, prioritize_unrecoverable_store); 1044: static SNAPSHOT_ATTR(snapshot_crashdumper, 0644, snapshot_crashdumper_show, 1045: snapshot_crashdumper_store); 1046: static SNAPSHOT_ATTR(snapshot_legacy, 0644, snapshot_legacy_show, 1047: snapshot_legacy_store); 1048: static SNAPSHOT_ATTR(skip_ib_capture, 0644, skip_ib_capture_show, 1049: skip_ib_capture_store); 1050: 1051: static ssize_t snapshot_sysfs_show(struct kobject *kobj, 1052: struct attribute *attr, char *buf) 1053: { 1054: struct kgsl_snapshot_attribute *pattr = to_snapshot_attr(attr); 1055: struct kgsl_device *device = kobj_to_device(kobj); 1056: ssize_t ret; 1057: 1058: if (device && pattr->show) 1059: ret = pattr->show(device, buf); 1060: else 1061: ret = -EIO; 1062: 1063: return ret; 1064: } 1065: 1066: static ssize_t snapshot_sysfs_store(struct kobject *kobj, 1067: struct attribute *attr, const char *buf, size_t count) 1068: { 1069: struct kgsl_snapshot_attribute *pattr = to_snapshot_attr(attr); 1070: struct kgsl_device *device = kobj_to_device(kobj); 1071: ssize_t ret = -EIO; 1072: 1073: if (pattr->store) 1074: ret = pattr->store(device, buf, count); 1075: 1076: return ret; 1077: } 1078: 1079: static const struct sysfs_ops snapshot_sysfs_ops = { 1080: .show = snapshot_sysfs_show, 1081: .store = snapshot_sysfs_store, 1082: }; 1083: 1084: static struct kobj_type ktype_snapshot = { 1085: .sysfs_ops = &snapshot_sysfs_ops, 1086: }; 1087: 1088: static const struct attribute *snapshot_attrs[] = { 1089: &attr_timestamp.attr, 1090: &attr_faultcount.attr, 1091: &attr_force_panic.attr, 1092: &attr_prioritize_unrecoverable.attr, 1093: &attr_snapshot_crashdumper.attr, 1094: &attr_snapshot_legacy.attr, 1095: &attr_skip_ib_capture.attr, 1096: NULL, 1097: }; 1098: 1099: static int kgsl_panic_notifier_callback(struct notifier_block *nb, 1100: unsigned long action, void *unused) 1101: { 1102: struct kgsl_device *device = container_of(nb, struct kgsl_device, 1103: panic_nb); 1104: 1105: /* To send NMI to GMU */ 1106: device->gmu_fault = gmu_core_isenabled(device); 1107: 1108: kgsl_device_snapshot_atomic(device); 1109: 1110: return NOTIFY_OK; 1111: } 1112: 1113: static ssize_t kgsl_devcoredump_read(char *buf, loff_t off, 1114: size_t count, void *data, size_t datalen) 1115: { 1116: struct kgsl_device *device = data; 1117: struct kgsl_snapshot *snapshot; 1118: ssize_t written; 1119: 1120: snapshot = device->snapshot; 1121: if (!snapshot) 1122: return 0; 1123: 1124: written = kgsl_snapshot_do_read(snapshot, buf, off, count); 1125: return written; 1126: } 1127: 1128: /* 1129: * Note: kgsl_devcoredump_read() and kgsl_devcoredump_free() are not 1130: * called concurrently. Devcoredump framework maintains a reference count 1131: * to ensure that free is called only after all readers have finished. 1132: */ 1133: static void kgsl_devcoredump_free(void *data) 1134: { 1135: struct kgsl_device *device = data; 1136: struct kgsl_snapshot *snapshot; 1137: 1138: snapshot = device->snapshot; 1139: device->snapshot = NULL; 1140: 1141: if (snapshot) 1142: kgsl_free_snapshot(snapshot); 1143: } 1144: 1145: static void kgsl_devcoredump(struct kgsl_device *device) 1146: { 1147: /* Dump the snapshot through coredump when config is enabled */ 1148: if (IS_ENABLED(CONFIG_QCOM_KGSL_DEVCOREDUMP)) 1149: dev_coredumpm(device->dev, THIS_MODULE, device, 0, GFP_KERNEL, 1150: kgsl_devcoredump_read, kgsl_devcoredump_free); 1151: } 1152: 1153: void kgsl_device_snapshot_probe(struct kgsl_device *device, u32 size) 1154: { 1155: device->snapshot_memory.size = size; 1156: 1157: device->snapshot_memory.ptr = dma_alloc_coherent(&device->pdev->dev, 1158: device->snapshot_memory.size, &device->snapshot_memory.dma_handle, 1159: GFP_KERNEL); 1160: /* 1161: * If we fail to allocate more than 1MB for snapshot fall back 1162: * to 1MB 1163: */ 1164: if (WARN_ON((!device->snapshot_memory.ptr) && size > SZ_1M)) { 1165: device->snapshot_memory.size = SZ_1M; 1166: device->snapshot_memory.ptr = devm_kzalloc(&device->pdev->dev, 1167: device->snapshot_memory.size, GFP_KERNEL); 1168: } 1169: 1170: if (!device->snapshot_memory.ptr) { 1171: dev_err(device->dev, 1172: "KGSL failed to allocate memory for snapshot\n"); 1173: return; 1174: } 1175: 1176: device->snapshot = NULL; 1177: device->snapshot_faultcount = 0; 1178: device->force_panic = false; 1179: device->snapshot_crashdumper = true; 1180: device->snapshot_legacy = false; 1181: 1182: device->snapshot_atomic = false; 1183: device->panic_nb.notifier_call = kgsl_panic_notifier_callback; 1184: device->panic_nb.priority = 1; 1185: device->snapshot_ctxt_record_size = 64 * 1024; 1186: 1187: /* 1188: * Set this to false so that we only ever keep the first snapshot around 1189: * If we want to over-write with a gmu snapshot, then set it to true 1190: * via sysfs 1191: */ 1192: device->prioritize_unrecoverable = false; 1193: 1194: if (kobject_init_and_add(&device->snapshot_kobj, &ktype_snapshot, 1195: &device->dev->kobj, "snapshot")) 1196: return; 1197: 1198: /* 1199: * When using coredump, the snapshot sysfs nodes will not be initialized 1200: * as the snapshot data is handled through the devcoredump framework 1201: * instead of the traditional sysfs interface. 1202: */ 1203: if (!IS_ENABLED(CONFIG_QCOM_KGSL_DEVCOREDUMP)) 1204: WARN_ON(sysfs_create_bin_file(&device->snapshot_kobj, &snapshot_attr)); 1205: 1206: WARN_ON(sysfs_create_files(&device->snapshot_kobj, snapshot_attrs)); 1207: atomic_notifier_chain_register(&panic_notifier_list, 1208: &device->panic_nb); 1209: } 1210: 1211: /** 1212: * kgsl_device_snapshot_close() - take down snapshot memory for a device 1213: * @device: Pointer to the kgsl_device 1214: * 1215: * Remove the sysfs files and free the memory allocated for the GPU 1216: * snapshot 1217: */ 1218: void kgsl_device_snapshot_close(struct kgsl_device *device) 1219: { 1220: if (device->snapshot_memory.ptr == NULL) 1221: return; 1222: 1223: kgsl_remove_from_minidump("GPU_SNAPSHOT", (u64) device->snapshot_memory.ptr, 1224: snapshot_phy_addr(device), device->snapshot_memory.size); 1225: 1226: atomic_notifier_chain_unregister(&panic_notifier_list, 1227: &device->panic_nb); 1228: 1229: if (!IS_ENABLED(CONFIG_QCOM_KGSL_DEVCOREDUMP)) 1230: sysfs_remove_bin_file(&device->snapshot_kobj, &snapshot_attr); 1231: 1232: sysfs_remove_files(&device->snapshot_kobj, snapshot_attrs); 1233: 1234: kobject_put(&device->snapshot_kobj); 1235: 1236: if (device->snapshot_memory.dma_handle) 1237: dma_free_coherent(&device->pdev->dev, device->snapshot_memory.size, 1238: device->snapshot_memory.ptr, device->snapshot_memory.dma_handle); 1239: 1240: if (device->snapshot_memory_atomic.dma_handle) 1241: dma_free_coherent(&device->pdev->dev, device->snapshot_memory_atomic.size, 1242: device->snapshot_memory_atomic.ptr, 1243: device->snapshot_memory_atomic.dma_handle); 1244: } 1245: 1246: /** 1247: * kgsl_snapshot_add_ib_obj_list() - Add a IB object list to the snapshot 1248: * object list 1249: * @device: the device that is being snapshotted 1250: * @ib_obj_list: The IB list that has objects required to execute an IB 1251: * @num_objs: Number of IB objects 1252: * @ptbase: The pagetable base in which the IB is mapped 1253: * 1254: * Adds a new IB to the list of IB objects maintained when getting snapshot 1255: * Returns 0 on success else -ENOMEM on error 1256: */ 1257: int kgsl_snapshot_add_ib_obj_list(struct kgsl_snapshot *snapshot, 1258: struct adreno_ib_object_list *ib_obj_list) 1259: { 1260: struct kgsl_snapshot_cp_obj *obj; 1261: 1262: obj = kzalloc(sizeof(*obj), GFP_KERNEL); 1263: if (!obj) 1264: return -ENOMEM; 1265: obj->ib_obj_list = ib_obj_list; 1266: list_add(&obj->node, &snapshot->cp_list); 1267: return 0; 1268: } 1269: 1270: static size_t _mempool_add_object(struct kgsl_snapshot *snapshot, u8 *data, 1271: struct kgsl_snapshot_object *obj) 1272: { 1273: struct kgsl_snapshot_section_header *section = 1274: (struct kgsl_snapshot_section_header *)data; 1275: struct kgsl_snapshot_gpu_object_v2 *header = 1276: (struct kgsl_snapshot_gpu_object_v2 *)(data + sizeof(*section)); 1277: u8 *dest = data + sizeof(*section) + sizeof(*header); 1278: uint64_t size; 1279: 1280: size = obj->size; 1281: 1282: if (!kgsl_memdesc_map(&obj->entry->memdesc)) { 1283: dev_err(snapshot->device->dev, 1284: "snapshot: failed to map GPU object\n"); 1285: return 0; 1286: } 1287: 1288: section->magic = SNAPSHOT_SECTION_MAGIC; 1289: section->id = KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2; 1290: section->size = size + sizeof(*header) + sizeof(*section); 1291: 1292: header->size = size >> 2; 1293: header->gpuaddr = obj->gpuaddr; 1294: header->ptbase = 1295: kgsl_mmu_pagetable_get_ttbr0(obj->entry->priv->pagetable); 1296: header->type = obj->type; 1297: 1298: if (kgsl_addr_range_overlap(obj->gpuaddr, obj->size, 1299: snapshot->ib1base, snapshot->ib1size)) 1300: snapshot->ib1dumped = true; 1301: 1302: if (kgsl_addr_range_overlap(obj->gpuaddr, obj->size, 1303: snapshot->ib2base, snapshot->ib2size)) 1304: snapshot->ib2dumped = true; 1305: 1306: memcpy(dest, obj->entry->memdesc.hostptr + obj->offset, size); 1307: kgsl_memdesc_unmap(&obj->entry->memdesc); 1308: 1309: return section->size; 1310: } 1311: 1312: /** 1313: * kgsl_snapshot_save_frozen_objs() - Save the objects frozen in snapshot into 1314: * memory so that the data reported in these objects is correct when snapshot 1315: * is taken 1316: * @work: The work item that scheduled this work 1317: */ 1318: static void kgsl_snapshot_save_frozen_objs(struct work_struct *work) 1319: { 1320: struct kgsl_snapshot *snapshot = container_of(work, 1321: struct kgsl_snapshot, work); 1322: struct kgsl_snapshot_object *obj, *tmp; 1323: size_t size = 0; 1324: void *ptr; 1325: 1326: if (snapshot->device->gmu_fault) 1327: goto gmu_only; 1328: 1329: kgsl_snapshot_process_ib_obj_list(snapshot); 1330: 1331: list_for_each_entry(obj, &snapshot->obj_list, node) { 1332: obj->size = ALIGN(obj->size, 4); 1333: 1334: size += ((size_t) obj->size + 1335: sizeof(struct kgsl_snapshot_gpu_object_v2) + 1336: sizeof(struct kgsl_snapshot_section_header)); 1337: } 1338: 1339: if (size == 0) 1340: goto done; 1341: 1342: snapshot->mempool = vmalloc(size); 1343: 1344: ptr = snapshot->mempool; 1345: snapshot->mempool_size = 0; 1346: 1347: /* even if vmalloc fails, make sure we clean up the obj_list */ 1348: list_for_each_entry_safe(obj, tmp, &snapshot->obj_list, node) { 1349: if (snapshot->mempool) { 1350: size_t ret = _mempool_add_object(snapshot, ptr, obj); 1351: 1352: ptr += ret; 1353: snapshot->mempool_size += ret; 1354: } 1355: 1356: kgsl_snapshot_put_object(obj); 1357: } 1358: done: 1359: /* 1360: * Get rid of the process struct here, so that it doesn't sit 1361: * around until someone bothers to read the snapshot file. 1362: */ 1363: kgsl_process_private_put(snapshot->process); 1364: kgsl_process_private_put(snapshot->process_lpac); 1365: snapshot->process = NULL; 1366: snapshot->process_lpac = NULL; 1367: 1368: if (snapshot->ib1base && !snapshot->ib1dumped) 1369: dev_err(snapshot->device->dev, 1370: "snapshot: Active IB1:%016llx not dumped\n", 1371: snapshot->ib1base); 1372: else if (snapshot->ib2base && !snapshot->ib2dumped) 1373: dev_err(snapshot->device->dev, 1374: "snapshot: Active IB2:%016llx not dumped\n", 1375: snapshot->ib2base); 1376: 1377: gmu_only: 1378: BUG_ON(!snapshot->device->skip_ib_capture && 1379: snapshot->device->force_panic); 1380: complete_all(&snapshot->dump_gate); 1381: kgsl_devcoredump(snapshot->device); 1382: } --- FILE: \kgsl_snapshot.h | HITS: 92 --- MATCH LINES: 7, 8, 12, 14, 15, 18, 25, 28, 33, 35, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 65, 68, 71, 73, 97, 105, 119, 130, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 150, 158, 163, 170, 180, 185, 192, 205, 206, 207, 208, 209, 210, 211, 214, 215, 216, 217, 218, 219, 222, 225, 228, 230, 235, 240, 246, 252, 261, 285, 287, 302, 303, 304, 305, 306, 308, 315, 324, 331, 343 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #ifndef _KGSL_SNAPSHOT_H_ 8: #define _KGSL_SNAPSHOT_H_ 9: 10: #include 11: 12: /* Snapshot header */ 13: 14: /* High word is static, low word is snapshot version ID */ 15: #define SNAPSHOT_MAGIC 0x504D0002 16: 17: #define DEBUG_SECTION_SZ(_dwords) (((_dwords) * sizeof(unsigned int)) \ 18: + sizeof(struct kgsl_snapshot_debug)) 19: 20: /* GPU ID scheme: 21: * [16:31] - core identifer (0x0002 for 2D or 0x0003 for 3D) 22: * [00:16] - GPU specific identifier 23: */ 24: 25: struct kgsl_snapshot_header { 26: __u32 magic; /* Magic identifier */ 27: __u32 gpuid; /* GPU ID - see above */ 28: /* Added in snapshot version 2 */ 29: __u32 chipid; /* Chip ID from the GPU */ 30: } __packed; 31: 32: /* Section header */ 33: #define SNAPSHOT_SECTION_MAGIC 0xABCD 34: 35: struct kgsl_snapshot_section_header { 36: __u16 magic; /* Magic identifier */ 37: __u16 id; /* Type of section */ 38: __u32 size; /* Size of the section including this header */ 39: } __packed; 40: 41: /* Section identifiers */ 42: #define KGSL_SNAPSHOT_SECTION_OS 0x0101 43: #define KGSL_SNAPSHOT_SECTION_REGS 0x0201 44: #define KGSL_SNAPSHOT_SECTION_REGS_V2 0x0202 45: #define KGSL_SNAPSHOT_SECTION_RB_V2 0x0302 46: #define KGSL_SNAPSHOT_SECTION_IB_V2 0x0402 47: #define KGSL_SNAPSHOT_SECTION_INDEXED_REGS 0x0501 48: #define KGSL_SNAPSHOT_SECTION_INDEXED_REGS_V2 0x0502 49: #define KGSL_SNAPSHOT_SECTION_DEBUG 0x0901 50: #define KGSL_SNAPSHOT_SECTION_DEBUGBUS 0x0A01 51: #define KGSL_SNAPSHOT_SECTION_DEBUGBUS_ENCRYPTED 0x0A02 52: #define KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2 0x0B02 53: #define KGSL_SNAPSHOT_SECTION_MEMLIST_V2 0x0E02 54: #define KGSL_SNAPSHOT_SECTION_SHADER 0x1201 55: #define KGSL_SNAPSHOT_SECTION_SHADER_V2 0x1202 56: #define KGSL_SNAPSHOT_SECTION_SHADER_V3 0x1203 57: #define KGSL_SNAPSHOT_SECTION_MVC 0x1501 58: #define KGSL_SNAPSHOT_SECTION_MVC_V2 0x1502 59: #define KGSL_SNAPSHOT_SECTION_MVC_V3 0x1503 60: #define KGSL_SNAPSHOT_SECTION_GMU_MEMORY 0x1701 61: #define KGSL_SNAPSHOT_SECTION_SIDE_DEBUGBUS 0x1801 62: #define KGSL_SNAPSHOT_SECTION_TRACE_BUFFER 0x1901 63: #define KGSL_SNAPSHOT_SECTION_EVENTLOG 0x1A01 64: 65: #define KGSL_SNAPSHOT_SECTION_END 0xFFFF 66: 67: /* OS sub-section header */ 68: #define KGSL_SNAPSHOT_OS_LINUX_V4 0x00000203 69: 70: /* Linux OS specific information */ 71: struct kgsl_snapshot_linux_v4 { 72: int osid; /* subsection OS identifier */ 73: __u32 seconds; /* Unix timestamp for the snapshot */ 74: __u32 power_flags; /* Current power flags */ 75: __u32 power_level; /* Current power level */ 76: __u32 power_interval_timeout; /* Power interval timeout */ 77: __u32 grpclk; /* Current GP clock value */ 78: __u32 busclk; /* Current busclk value */ 79: __u64 ptbase; /* Current ptbase */ 80: __u64 ptbase_lpac; /* Current LPAC ptbase */ 81: __u32 pid; /* PID of the process that owns the PT */ 82: __u32 pid_lpac; /* PID of the LPAC process that owns the PT */ 83: __u32 current_context; /* ID of the current context */ 84: __u32 current_context_lpac; /* ID of the current LPAC context */ 85: __u32 ctxtcount; /* Number of contexts appended to section */ 86: unsigned char release[32]; /* kernel release */ 87: unsigned char version[32]; /* kernel version */ 88: unsigned char comm[16]; /* Name of the process that owns the PT */ 89: unsigned char comm_lpac[16]; /* Name of the LPAC process that owns the PT */ 90: } __packed; 91: 92: /* 93: * This structure contains a record of an active context. 94: * These are appended one after another in the OS section below 95: * the header above 96: */ 97: struct kgsl_snapshot_linux_context_v2 { 98: __u32 id; /* The context ID */ 99: __u32 timestamp_queued; /* The last queued timestamp */ 100: __u32 timestamp_consumed; /* The last timestamp consumed by HW */ 101: __u32 timestamp_retired; /* The last timestamp retired by HW */ 102: }; 103: 104: /* Ringbuffer sub-section header */ 105: struct kgsl_snapshot_rb_v2 { 106: int start; /* dword at the start of the dump */ 107: int end; /* dword at the end of the dump */ 108: int rbsize; /* Size (in dwords) of the ringbuffer */ 109: int wptr; /* Current index of the CPU write pointer */ 110: int rptr; /* Current index of the GPU read pointer */ 111: int count; /* Number of dwords in the dump */ 112: __u32 timestamp_queued; /* The last queued timestamp */ 113: __u32 timestamp_retired; /* The last timestamp retired by HW */ 114: __u64 gpuaddr; /* The GPU address of the ringbuffer */ 115: __u32 id; /* Ringbuffer identifier */ 116: } __packed; 117: 118: /* Replay or Memory list section, both sections have same header */ 119: struct kgsl_snapshot_mem_list_v2 { 120: /* 121: * Number of IBs to replay for replay section or 122: * number of memory list entries for mem list section 123: */ 124: int num_entries; 125: /* Pagetable base to which the replay IBs or memory entries belong */ 126: __u64 ptbase; 127: } __packed; 128: 129: /* Indirect buffer sub-section header (v2) */ 130: struct kgsl_snapshot_ib_v2 { 131: __u64 gpuaddr; /* GPU address of the IB */ 132: __u64 ptbase; /* Base for the pagetable the GPU address is valid in */ 133: __u64 size; /* Size of the IB */ 134: } __packed; 135: 136: /* GMU memory ID's */ 137: #define SNAPSHOT_GMU_MEM_UNKNOWN 0x00 138: #define SNAPSHOT_GMU_MEM_HFI 0x01 139: #define SNAPSHOT_GMU_MEM_LOG 0x02 140: #define SNAPSHOT_GMU_MEM_BWTABLE 0x03 141: #define SNAPSHOT_GMU_MEM_DEBUG 0x04 142: #define SNAPSHOT_GMU_MEM_BIN_BLOCK 0x05 143: #define SNAPSHOT_GMU_MEM_CONTEXT_QUEUE 0x06 144: #define SNAPSHOT_GMU_MEM_HW_FENCE 0x07 145: #define SNAPSHOT_GMU_MEM_WARMBOOT 0x08 146: #define SNAPSHOT_GMU_MEM_VRB 0x09 147: #define SNAPSHOT_GMU_MEM_TRACE 0x0a 148: 149: /* GMU memory section data */ 150: struct kgsl_snapshot_gmu_mem { 151: int type; 152: uint64_t hostaddr; 153: uint64_t gmuaddr; 154: uint64_t gpuaddr; 155: } __packed; 156: 157: /* Register sub-section header */ 158: struct kgsl_snapshot_regs { 159: __u32 count; /* Number of register pairs in the section */ 160: } __packed; 161: 162: /* Indexed register sub-section header */ 163: struct kgsl_snapshot_indexed_regs { 164: __u32 index_reg; /* Offset of the index register for this section */ 165: __u32 data_reg; /* Offset of the data register for this section */ 166: int start; /* Starting index */ 167: int count; /* Number of dwords in the data */ 168: } __packed; 169: 170: struct kgsl_snapshot_indexed_regs_v2 { 171: u32 index_reg; /* Offset of the index register for this section */ 172: u32 data_reg; /* Offset of the data register for this section */ 173: u32 start; /* Starting index */ 174: u32 count; /* Number of dwords in the data */ 175: u32 pipe_id; /* Id of pipe, BV, Br etc */ 176: u32 slice_id; /* Slice ID to be dumped */ 177: } __packed; 178: 179: /* MVC register sub-section header */ 180: struct kgsl_snapshot_mvc_regs { 181: int ctxt_id; 182: int cluster_id; 183: } __packed; 184: 185: struct kgsl_snapshot_mvc_regs_v2 { 186: int ctxt_id; 187: int cluster_id; 188: int pipe_id; 189: int location_id; 190: } __packed; 191: 192: struct kgsl_snapshot_mvc_regs_v3 { 193: u32 ctxt_id; 194: u32 cluster_id; 195: u32 pipe_id; 196: u32 location_id; 197: u32 slice_id; 198: u32 sp_id; 199: u32 usptp_id; 200: } __packed; 201: 202: /* Debug data sub-section header */ 203: 204: /* A5XX debug sections */ 205: #define SNAPSHOT_DEBUG_CP_MEQ 7 206: #define SNAPSHOT_DEBUG_CP_PM4_RAM 8 207: #define SNAPSHOT_DEBUG_CP_PFP_RAM 9 208: #define SNAPSHOT_DEBUG_CP_ROQ 10 209: #define SNAPSHOT_DEBUG_SHADER_MEMORY 11 210: #define SNAPSHOT_DEBUG_CP_MERCIU 12 211: #define SNAPSHOT_DEBUG_SQE_VERSION 14 212: 213: /* GMU Version information */ 214: #define SNAPSHOT_DEBUG_GMU_CORE_VERSION 15 215: #define SNAPSHOT_DEBUG_GMU_CORE_DEV_VERSION 16 216: #define SNAPSHOT_DEBUG_GMU_PWR_VERSION 17 217: #define SNAPSHOT_DEBUG_GMU_PWR_DEV_VERSION 18 218: #define SNAPSHOT_DEBUG_GMU_HFI_VERSION 19 219: #define SNAPSHOT_DEBUG_AQE_VERSION 20 220: 221: /* RBBM status info */ 222: #define SNAPSHOT_DEBUG_RBBM_STATUS 32 223: 224: /* Slice mask info */ 225: #define SNAPSHOT_DEBUG_SLICE_MASK 8192 226: 227: /* Malu GDSC on/off */ 228: #define SNAPSHOT_DEBUG_MALU_STATUS 8194 229: 230: struct kgsl_snapshot_debug { 231: int type; /* Type identifier for the attached tata */ 232: int size; /* Size of the section in dwords */ 233: } __packed; 234: 235: struct kgsl_snapshot_debugbus { 236: int id; /* Debug bus ID */ 237: int count; /* Number of dwords in the dump */ 238: } __packed; 239: 240: struct kgsl_snapshot_side_debugbus { 241: int id; /* Debug bus ID */ 242: int size; /* Number of dwords in the dump */ 243: int valid_data; /* Mask of valid bits of the side debugbus */ 244: } __packed; 245: 246: struct kgsl_snapshot_shader { 247: int type; /* SP/TP statetype */ 248: int index; /* SP/TP index */ 249: int size; /* Number of dwords in the dump */ 250: } __packed; 251: 252: struct kgsl_snapshot_shader_v2 { 253: int type; /* SP/TP statetype */ 254: int index; /* SP/TP index */ 255: int usptp; /* USPTP index */ 256: int pipe_id; /* Pipe id */ 257: int location; /* Location value */ 258: u32 size; /* Number of dwords in the dump */ 259: } __packed; 260: 261: struct kgsl_snapshot_shader_v3 { 262: u32 type; /* SP/TP statetype */ 263: u32 slice_id; /* Slice ID */ 264: u32 sp_index; /* SP/TP index */ 265: u32 usptp; /* USPTP index */ 266: u32 pipe_id; /* Pipe id */ 267: u32 location; /* Location value */ 268: u32 ctxt_id; /* Context ID */ 269: u32 size; /* Number of dwords in the dump */ 270: } __packed; 271: 272: #define TRACE_BUF_NUM_SIG 4 273: 274: /** 275: * enum trace_buffer_source - Bits to identify the source block of trace buffer information 276: * GX_DBGC : Signals captured from GX block 277: * CX_DBGC : Signals captured from CX block 278: */ 279: enum trace_buffer_source { 280: GX_DBGC = 1, 281: CX_DBGC = 2, 282: }; 283: 284: /** 285: * kgsl_snapshot_trace_buffer: Header Information for the tracebuffer in snapshot. 286: */ 287: struct kgsl_snapshot_trace_buffer { 288: /** @dbgc_ctrl: Identify source for trace */ 289: __u16 dbgc_ctrl; 290: /** @dbgc_ctrl: Identify source for trace */ 291: __u16 segment; 292: /** @granularity: The total number of segments in each packet */ 293: __u16 granularity; 294: /** @ping_blk: Signal block */ 295: __u16 ping_blk[TRACE_BUF_NUM_SIG]; 296: /** @ping_idx: Signal Index */ 297: __u16 ping_idx[TRACE_BUF_NUM_SIG]; 298: /** @size: Number of bytes in the dump */ 299: __u32 size; 300: } __packed; 301: 302: #define SNAPSHOT_GPU_OBJECT_SHADER 1 303: #define SNAPSHOT_GPU_OBJECT_IB 2 304: #define SNAPSHOT_GPU_OBJECT_GENERIC 3 305: #define SNAPSHOT_GPU_OBJECT_DRAW 4 306: #define SNAPSHOT_GPU_OBJECT_GLOBAL 5 307: 308: struct kgsl_snapshot_gpu_object_v2 { 309: int type; /* Type of GPU object */ 310: __u64 gpuaddr; /* GPU address of the object */ 311: __u64 ptbase; /* Base for the pagetable the GPU address is valid in */ 312: __u64 size; /* Size of the object (in dwords) */ 313: } __packed; 314: 315: struct kgsl_snapshot_eventlog { 316: /** @type: Type of the event log buffer */ 317: __u16 type; 318: /** @version: Version of the event log buffer */ 319: __u16 version; 320: /** @size: Size of the eventlog buffer in bytes */ 321: u32 size; 322: } __packed; 323: 324: struct kgsl_snapshot_gmu_version { 325: /** @type: Type of the GMU version buffer */ 326: u32 type; 327: /** @value: GMU FW version value */ 328: u32 value; 329: } __packed; 330: 331: struct kgsl_snapshot_indexed_registers_v2 { 332: u32 index; 333: u32 data; 334: u32 start; 335: u32 count; 336: u32 pipe_id; 337: u32 slice_id; 338: }; 339: 340: struct kgsl_device; 341: struct kgsl_process_private; 342: 343: void kgsl_snapshot_push_object(struct kgsl_device *device, 344: struct kgsl_process_private *process, 345: uint64_t gpuaddr, uint64_t dwords); 346: #endif --- FILE: \kgsl_trace.h | HITS: 1 --- MATCH LINES: 965 953: ), 954: 955: TP_printk( 956: "d_name=%s constraint_type=%s constraint_value=%u status=%s ticks=%llu", 957: __get_str(device_name), 958: show_constraint(__entry->type), 959: __entry->value, 960: __entry->on ? "ON" : "OFF", 961: __entry->ticks 962: ) 963: ); 964: 965: TRACE_EVENT(kgsl_mmu_pagefault, 966: 967: TP_PROTO(struct kgsl_device *device, unsigned long page, 968: unsigned int pt, const char *name, const char *op), 969: 970: TP_ARGS(device, page, pt, name, op), 971: 972: TP_STRUCT__entry( 973: __string(device_name, device->name) 974: __field(unsigned long, page) 975: __field(unsigned int, pt) 976: __string(name, name) 977: __string(op, op) 978: ), 979: 980: TP_fast_assign( 981: kgsl_assign_str(device_name, device->name); 982: __entry->page = page; 983: __entry->pt = pt; 984: kgsl_assign_str(name, name); 985: kgsl_assign_str(op, op); 986: ), 987: 988: TP_printk( 989: "d_name=%s page=0x%lx pt=%u op=%s name=%s", --- FILE: \kgsl_util.h | HITS: 4 --- MATCH LINES: 301, 303, 322, 324 289: int kgsl_get_ddrtype(void); 290: 291: static inline void qcom_clk_dump(struct clk *clk, struct regulator *regulator, 292: bool calltrace) 293: { 294: } 295: 296: #endif 297: 298: #if IS_ENABLED(CONFIG_QCOM_PAS) 299: #include 300: 301: static inline int kgsl_pas_auth_and_reset(u32 pas_id) 302: { 303: return qcom_pas_auth_and_reset(pas_id); 304: } 305: 306: static inline int kgsl_pas_shutdown(u32 pas_id) 307: { 308: return qcom_pas_shutdown(pas_id); 309: } 310: 311: static inline int kgsl_pas_set_remote_state(u32 state, u32 pas_id) 312: { 313: return qcom_pas_set_remote_state(state, pas_id); 314: } 315: #else 316: #if (KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE) 317: #include 318: #else 319: #include 320: #endif 321: 322: static inline int kgsl_pas_auth_and_reset(u32 pas_id) 323: { 324: return qcom_scm_pas_auth_and_reset(pas_id); 325: } 326: 327: static inline int kgsl_pas_shutdown(u32 pas_id) 328: { 329: return qcom_scm_pas_shutdown_retry(pas_id); 330: } 331: 332: static inline int kgsl_pas_set_remote_state(u32 state, u32 pas_id) 333: { 334: return qcom_scm_set_remote_state(state, pas_id); 335: } 336: #endif 337: 338: /** 339: * isdb_write - Program isdb registers to issue break commands to SP 340: * @base: Base address of qdss registers to be programmed 341: * @offset: offset to the SP block 342: */ 343: void isdb_write(void __iomem *base, u32 offset); 344: 345: /** 346: * cmp_u32 - Comparator function for sorting u32 values 347: * @first: Pointer to the first element 348: * @second: Pointer to the second element --- FILE: \msm_adreno_devfreq.h | HITS: 2 --- MATCH LINES: 112, 117 100: static inline bool qtee_shmbridge_is_enabled(void) 101: { 102: return false; 103: } 104: static inline int32_t qtee_shmbridge_allocate_shm(size_t size, struct qtee_shm *shm) 105: { 106: return -EINVAL; 107: } 108: static inline void qtee_shmbridge_free_shm(struct qtee_shm *shm) { } 109: #endif 110: 111: #if IS_ENABLED(CONFIG_QCOM_KGSL_UPSTREAM) && !IS_ENABLED(CONFIG_QCOM_SCM_ADDON) 112: static inline int qcom_scm_io_reset(void) 113: { 114: return -EINVAL; 115: } 116: 117: static inline int qcom_scm_dcvs_reset(void) 118: { 119: return -EINVAL; 120: } 121: 122: static inline int qcom_scm_dcvs_update(int level, s64 total_time, s64 busy_time) 123: { 124: return -EINVAL; 125: } 126: 127: static inline int qcom_scm_dcvs_update_v2(int level, s64 total_time, s64 busy_time) 128: { 129: return -EINVAL; 130: } 131: 132: static inline int qcom_scm_dcvs_update_ca_v2(int level, s64 total_time, s64 busy_time, 133: int context_count) 134: { 135: return -EINVAL; 136: } 137: 138: static inline bool qcom_scm_dcvs_core_available(void) 139: { 140: return false; 141: } --- FILE: \downstream_dependencies\linux\qcom-iommu-util.h | HITS: 6 --- MATCH LINES: 15, 16, 31, 32, 33, 34 3: * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #ifndef __QCOM_IOMMU_UTIL_H 8: #define __QCOM_IOMMU_UTIL_H 9: 10: #include 11: 12: #include 13: 14: /* IOMMU fault behaviors */ 15: #define QCOM_IOMMU_FAULT_MODEL_NO_STALL BIT(2) 16: #define QCOM_IOMMU_FAULT_MODEL_NON_FATAL BIT(0) 17: 18: #ifndef IOMMU_SYS_CACHE 19: /* Attributes are not supported, so render them ineffective. */ 20: #define IOMMU_SYS_CACHE (0) 21: #define IOMMU_SYS_CACHE_NWA (0) 22: #endif 23: 24: /* Use upstream device's bus attribute */ 25: #define IOMMU_USE_UPSTREAM_HINT (IOMMU_SYS_CACHE) 26: 27: /* Use upstream device's bus attribute with no write-allocate cache policy */ 28: #define IOMMU_USE_LLC_NWA (IOMMU_SYS_CACHE_NWA) 29: 30: /* vendor iommu fault flags */ 31: #define IOMMU_FAULT_TRANSLATION (1 << 2) 32: #define IOMMU_FAULT_PERMISSION (1 << 3) 33: #define IOMMU_FAULT_EXTERNAL (1 << 4) 34: #define IOMMU_FAULT_TRANSACTION_STALLED (1 << 5) 35: 36: static inline int qcom_iommu_set_fault_model(struct iommu_domain *domain, int fault_model) 37: { 38: return -EINVAL; 39: } 40: 41: static inline int qcom_iommu_get_context_bank_nr(struct iommu_domain *domain) 42: { 43: return 0; 44: } 45: 46: static inline int qcom_iommu_get_asid_nr(struct iommu_domain *domain) 47: { 48: return 0; 49: } 50: 51: static inline int qcom_iommu_set_secure_vmid(struct iommu_domain *domain, enum vmid vmid) 52: { 53: return -EINVAL; 54: } 55: 56: static inline int qcom_skip_tlb_management(struct device *dev, bool skip) 57: { 58: return -EINVAL; --- FILE: \include\linux\msm_kgsl.h | HITS: 2 --- MATCH LINES: 56, 57 44: * @pid: pid of the process for which frame count is required 45: * @frame_count: pointer to a u64 to store frame count 46: * 47: * Return: zero on success and number of frames processed corresponding 48: * to @pid in @frame_count or negative error on failure 49: */ 50: int kgsl_gpu_frame_count(pid_t pid, u64 *frame_count); 51: 52: /** 53: * enum kgsl_srcu_events - kgsl srcu notify events for listeners 54: * @GPU_GMU_READY - GMU initialized to handle other requests 55: * @GPU_GMU_STOP - GMU is not ready to handle other requests 56: * @GPU_SSR_BEGIN - GPU/GMU fault detected to start recovery 57: * @GPU_SSR_END - GPU/GMU fault recovery end 58: * @GPU_SSR_FATAL - LSR context invalidated 59: */ 60: enum kgsl_srcu_events { 61: GPU_GMU_READY, 62: GPU_GMU_STOP, 63: GPU_SSR_BEGIN, 64: GPU_SSR_END, 65: GPU_SSR_FATAL, 66: }; 67: 68: /** 69: * kgsl_add_rcu_notifier - Adds a notifier to an SRCU notifier chain. 70: * @nb: Notifier block new entry to add in notifier chain 71: * 72: * Returns zero on success or error on failure. 73: */ 74: int kgsl_add_rcu_notifier(struct notifier_block *nb); 75: 76: /** 77: * kgsl_del_rcu_notifier - Remove notifier from an SRCU notifier chain. 78: * @nb: Entry to remove from notifier chain 79: * 80: * Returns zero on success or -ENOENT on failure. 81: */ --- FILE: \include\uapi\linux\msm_kgsl.h | HITS: 20 --- MATCH LINES: 58 46: /* This is a cmdbatch exclusive flag - use the CMDBATCH equivalent instead */ 47: #define KGSL_CONTEXT_END_OF_FRAME 0x00000100 48: #define KGSL_CONTEXT_NO_FAULT_TOLERANCE 0x00000200 49: /* This is a cmdbatch exclusive flag - use the CMDBATCH equivalent instead */ 50: #define KGSL_CONTEXT_SYNC 0x00000400 51: #define KGSL_CONTEXT_PWR_CONSTRAINT 0x00000800 52: #define KGSL_CONTEXT_PRIORITY_MASK 0x0000F000 53: #define KGSL_CONTEXT_PRIORITY_SHIFT 12 54: #define KGSL_CONTEXT_PRIORITY_UNDEF 0 55: 56: #define KGSL_CONTEXT_IFH_NOP 0x00010000 57: #define KGSL_CONTEXT_SECURE 0x00020000 58: #define KGSL_CONTEXT_NO_SNAPSHOT 0x00040000 59: #define KGSL_CONTEXT_SPARSE 0x00080000 60: 61: #define KGSL_CONTEXT_PREEMPT_STYLE_MASK 0x0E000000 62: #define KGSL_CONTEXT_PREEMPT_STYLE_SHIFT 25 63: #define KGSL_CONTEXT_PREEMPT_STYLE_DEFAULT 0x0 64: #define KGSL_CONTEXT_PREEMPT_STYLE_RINGBUFFER 0x1 65: #define KGSL_CONTEXT_PREEMPT_STYLE_FINEGRAIN 0x2 66: 67: #define KGSL_CONTEXT_TYPE_MASK 0x01F00000 68: #define KGSL_CONTEXT_TYPE_SHIFT 20 69: #define KGSL_CONTEXT_TYPE_ANY 0 70: #define KGSL_CONTEXT_TYPE_GL 1 71: #define KGSL_CONTEXT_TYPE_CL 2 72: #define KGSL_CONTEXT_TYPE_C2D 3 73: #define KGSL_CONTEXT_TYPE_RS 4 74: #define KGSL_CONTEXT_TYPE_VK 5 75: #define KGSL_CONTEXT_TYPE_UNKNOWN 0x1E 76: 77: #define KGSL_CONTEXT_INVALIDATE_ON_FAULT 0x10000000 78: #define KGSL_CONTEXT_LPAC 0x20000000 79: #define KGSL_CONTEXT_FAULT_INFO 0x40000000 80: 81: #define KGSL_CONTEXT_INVALID 0xffffffff 82: MATCH LINES: 239, 255, 257, 259, 260, 261 227: 228: /* --- generic KGSL flag values --- */ 229: 230: #define KGSL_FLAGS_NORMALMODE 0x00000000 231: #define KGSL_FLAGS_SAFEMODE 0x00000001 232: #define KGSL_FLAGS_INITIALIZED0 0x00000002 233: #define KGSL_FLAGS_INITIALIZED 0x00000004 234: #define KGSL_FLAGS_STARTED 0x00000008 235: #define KGSL_FLAGS_ACTIVE 0x00000010 236: #define KGSL_FLAGS_RESERVED0 0x00000020 237: #define KGSL_FLAGS_RESERVED1 0x00000040 238: #define KGSL_FLAGS_RESERVED2 0x00000080 239: #define KGSL_FLAGS_SOFT_RESET 0x00000100 240: #define KGSL_FLAGS_PER_CONTEXT_TIMESTAMPS 0x00000200 241: 242: /* Server Side Sync Timeout in milliseconds */ 243: #define KGSL_SYNCOBJ_SERVER_TIMEOUT 2000 244: 245: /* UBWC Modes */ 246: #define KGSL_UBWC_NONE 0 247: #define KGSL_UBWC_1_0 1 248: #define KGSL_UBWC_2_0 2 249: #define KGSL_UBWC_3_0 3 250: #define KGSL_UBWC_4_0 4 251: #define KGSL_UBWC_5_0 5 252: #define KGSL_UBWC_6_0 6 253: 254: /* 255: * Reset status values for context 256: */ 257: enum kgsl_ctx_reset_stat { 258: KGSL_CTX_STAT_NO_ERROR = 0x00000000, 259: KGSL_CTX_STAT_GUILTY_CONTEXT_RESET_EXT = 0x00000001, 260: KGSL_CTX_STAT_INNOCENT_CONTEXT_RESET_EXT = 0x00000002, 261: KGSL_CTX_STAT_UNKNOWN_CONTEXT_RESET_EXT = 0x00000003 262: }; 263: 264: #define KGSL_CONVERT_TO_MBPS(val) \ 265: (val*1000*1000U) 266: 267: struct kgsl_devinfo { 268: 269: unsigned int device_id; 270: /* 271: * chip revision id 272: * coreid:8 majorrev:8 minorrev:8 patch:8 273: */ 274: unsigned int chip_id; 275: unsigned int mmu_enabled; 276: unsigned long gmem_gpubaseaddr; 277: /* 278: * This field contains the adreno revision 279: * number 200, 205, 220, etc... 280: */ 281: unsigned int gpu_id; 282: __kernel_size_t gmem_sizebytes; 283: }; 284: 285: /* MATCH LINES: 335 323: KGSL_TIMESTAMP_QUEUED = 0x00000003, 324: }; 325: 326: /* property types - used with kgsl_device_getproperty */ 327: #define KGSL_PROP_DEVICE_INFO 0x1 328: #define KGSL_PROP_DEVICE_SHADOW 0x2 329: #define KGSL_PROP_DEVICE_POWER 0x3 330: #define KGSL_PROP_SHMEM 0x4 331: #define KGSL_PROP_SHMEM_APERTURES 0x5 332: #define KGSL_PROP_MMU_ENABLE 0x6 333: #define KGSL_PROP_INTERRUPT_WAITS 0x7 334: #define KGSL_PROP_VERSION 0x8 335: #define KGSL_PROP_GPU_RESET_STAT 0x9 336: #define KGSL_PROP_PWRCTRL 0xE 337: #define KGSL_PROP_PWR_CONSTRAINT 0x12 338: #define KGSL_PROP_UCHE_GMEM_VADDR 0x13 339: #define KGSL_PROP_SP_GENERIC_MEM 0x14 340: #define KGSL_PROP_UCODE_VERSION 0x15 341: #define KGSL_PROP_GPMU_VERSION 0x16 342: #define KGSL_PROP_HIGHEST_BANK_BIT 0x17 343: #define KGSL_PROP_DEVICE_BITNESS 0x18 344: #define KGSL_PROP_DEVICE_QDSS_STM 0x19 345: #define KGSL_PROP_MIN_ACCESS_LENGTH 0x1A 346: #define KGSL_PROP_UBWC_MODE 0x1B 347: #define KGSL_PROP_DEVICE_QTIMER 0x20 348: #define KGSL_PROP_L3_PWR_CONSTRAINT 0x22 349: #define KGSL_PROP_SECURE_BUFFER_ALIGNMENT 0x23 350: #define KGSL_PROP_SECURE_CTXT_SUPPORT 0x24 351: #define KGSL_PROP_SPEED_BIN 0x25 352: #define KGSL_PROP_GAMING_BIN 0x26 353: #define KGSL_PROP_QUERY_CAPABILITIES 0x27 354: #define KGSL_PROP_CONTEXT_PROPERTY 0x28 355: #define KGSL_PROP_GPU_MODEL 0x29 356: #define KGSL_PROP_VK_DEVICE_ID 0x2A 357: #define KGSL_PROP_IS_LPAC_ENABLED 0x2B 358: #define KGSL_PROP_GPU_VA64_SIZE 0x2C 359: #define KGSL_PROP_IS_RAYTRACING_ENABLED 0x2D MATCH LINES: 2043, 2046, 2047, 2048, 2049, 2050, 2051, 2052, 2053, 2056, 2061, 2063 2031: * An aux command for timeline signals that can be pointed to by 2032: * &struct kgsl_gpu_aux_command_generic when the type is 2033: * KGSL_GPU_AUX_COMMAND_TIMELINE. 2034: */ 2035: struct kgsl_gpu_aux_command_timeline { 2036: __u64 timelines; 2037: __u32 count; 2038: __u32 timelines_size; 2039: }; 2040: 2041: /* Macros for fault type used in kgsl_fault structure */ 2042: #define KGSL_FAULT_TYPE_NO_FAULT 0 2043: #define KGSL_FAULT_TYPE_PAGEFAULT 1 2044: #define KGSL_FAULT_TYPE_MAX 2 2045: 2046: /* Macros to be used in kgsl_pagefault_report structure */ 2047: #define KGSL_PAGEFAULT_TYPE_NONE 0 2048: #define KGSL_PAGEFAULT_TYPE_READ (1 << 0) 2049: #define KGSL_PAGEFAULT_TYPE_WRITE (1 << 1) 2050: #define KGSL_PAGEFAULT_TYPE_TRANSLATION (1 << 2) 2051: #define KGSL_PAGEFAULT_TYPE_PERMISSION (1 << 3) 2052: #define KGSL_PAGEFAULT_TYPE_EXTERNAL (1 << 4) 2053: #define KGSL_PAGEFAULT_TYPE_TRANSACTION_STALLED (1 << 5) 2054: 2055: /** 2056: * struct kgsl_pagefault_report - Descriptor for each page fault 2057: * @fault_addr: page fault address 2058: * @fault_type: type of page fault 2059: * 2060: * Contains information about supported GPU page fault. 2061: * Supported fault type: KGSL_PAGEFAULT_TYPE_* 2062: */ 2063: struct kgsl_pagefault_report { 2064: __u64 fault_addr; 2065: /* private: reserved for future use */ 2066: __u64 reserved[2]; 2067: __u32 fault_type; 2068: /* private: padding for 64 bit compatibility */ 2069: __u32 __pad; 2070: }; 2071: 2072: /** 2073: * struct kgsl_fault - Descriptor for each GPU fault type 2074: * @fault: User memory pointer to list of specific fault type 2075: * @type: Type of gpu fault 2076: * @count: Number of entries in @fault 2077: * @size: Size of each entry in @fault in bytes 2078: * 2079: * Contains information about each GPU fault type. If user passes 0 for all the fields, KGSL 2080: * will return the @count and @type of fault. Based on this, user can allocate a buffer for 2081: * specific fault type, fill the @fault and specify the structure size of type specific fault 2082: * in @size. User can walk through @fault list to parse the fault type specific information. 2083: * 2084: * Supported type: KGSL_FAULT_TYPE_* 2085: */ 2086: struct kgsl_fault { 2087: __u64 fault; TOTAL MATCHES: 3780 ========================================================================================== SUBSYSTEM: REGISTERS_AND_PACKETS ========================================================================================== --- FILE: \a6xx_reg.h | HITS: 1109 --- MATCH LINES: 7, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 37, 38, 39, 40, 41, 42, 43, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 415, 416, 417, 418, 420, 421, 422, 423, 424, 425, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 562, 563, 564, 565, 566, 567, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 646, 647, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 701, 702, 703, 704, 705, 706, 707, 708, 709, 712, 713, 714, 715, 716, 717, 718, 719, 720, 723, 724, 725, 726, 727, 728, 729, 732, 733, 734, 735, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854, 863, 864, 865, 866, 867, 868, 869, 870, 871, 873, 874, 875, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 897, 898, 899, 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1086, 1087, 1088, 1091, 1094, 1095, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1114, 1115, 1116, 1119, 1120, 1123, 1124, 1127, 1130, 1131, 1132, 1133, 1144, 1147, 1148, 1149, 1150, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158, 1159, 1160, 1161, 1162, 1163, 1164, 1165, 1166, 1167, 1168, 1169, 1170 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #ifndef _A6XX_REG_H 8: #define _A6XX_REG_H 9: 10: /* A6XX interrupt bits */ 11: #define A6XX_INT_RBBM_GPU_IDLE 0 12: #define A6XX_INT_CP_AHB_ERROR 1 13: #define A6XX_INT_ATB_ASYNCFIFO_OVERFLOW 6 14: #define A6XX_INT_RBBM_GPC_ERROR 7 15: #define A6XX_INT_CP_SW 8 16: #define A6XX_INT_CP_HW_ERROR 9 17: #define A6XX_INT_CP_CCU_FLUSH_DEPTH_TS 10 18: #define A6XX_INT_CP_CCU_FLUSH_COLOR_TS 11 19: #define A6XX_INT_CP_CCU_RESOLVE_TS 12 20: #define A6XX_INT_CP_IB2 13 21: #define A6XX_INT_CP_IB1 14 22: #define A6XX_INT_CP_RB 15 23: #define A6XX_INT_CP_RB_DONE_TS 17 24: #define A6XX_INT_CP_WT_DONE_TS 18 25: #define A6XX_INT_CP_CACHE_FLUSH_TS 20 26: #define A6XX_INT_RBBM_ATB_BUS_OVERFLOW 22 27: #define A6XX_INT_RBBM_HANG_DETECT 23 28: #define A6XX_INT_UCHE_OOB_ACCESS 24 29: #define A6XX_INT_UCHE_TRAP_INTR 25 30: #define A6XX_INT_DEBBUS_INTR_0 26 31: #define A6XX_INT_DEBBUS_INTR_1 27 32: #define A6XX_INT_TSB_WRITE_ERROR 28 33: #define A6XX_INT_ISDB_CPU_IRQ 30 34: #define A6XX_INT_ISDB_UNDER_DEBUG 31 35: 36: /* CP Interrupt bits */ 37: #define A6XX_CP_OPCODE_ERROR 0 38: #define A6XX_CP_UCODE_ERROR 1 39: #define A6XX_CP_HW_FAULT_ERROR 2 40: #define A6XX_CP_REGISTER_PROTECTION_ERROR 4 41: #define A6XX_CP_AHB_ERROR 5 42: #define A6XX_CP_VSD_PARITY_ERROR 6 43: #define A6XX_CP_ILLEGAL_INSTR_ERROR 7 44: 45: /* CP registers */ 46: #define A6XX_CP_RB_BASE 0x800 47: #define A6XX_CP_RB_BASE_HI 0x801 48: #define A6XX_CP_RB_CNTL 0x802 49: #define A6XX_CP_RB_RPTR_ADDR_LO 0x804 50: #define A6XX_CP_RB_RPTR_ADDR_HI 0x805 51: #define A6XX_CP_RB_RPTR 0x806 52: #define A6XX_CP_RB_WPTR 0x807 53: #define A6XX_CP_SQE_CNTL 0x808 54: #define A6XX_CP_CP2GMU_STATUS 0x812 55: #define A6XX_CP_HW_FAULT 0x821 56: #define A6XX_CP_INTERRUPT_STATUS 0x823 57: #define A6XX_CP_PROTECT_STATUS 0x824 58: #define A6XX_CP_STATUS_1 0x825 59: #define A6XX_CP_SQE_INSTR_BASE_LO 0x830 60: #define A6XX_CP_SQE_INSTR_BASE_HI 0x831 61: #define A6XX_CP_MISC_CNTL 0x840 62: #define A6XX_CP_APRIV_CNTL 0X844 63: #define A6XX_CP_ROQ_THRESHOLDS_1 0x8C1 64: #define A6XX_CP_ROQ_THRESHOLDS_2 0x8C2 65: #define A6XX_CP_MEM_POOL_SIZE 0x8C3 66: #define A6XX_CP_CHICKEN_DBG 0x841 67: #define A6XX_CP_ADDR_MODE_CNTL 0x842 68: #define A6XX_CP_DBG_ECO_CNTL 0x843 69: #define A6XX_CP_PROTECT_CNTL 0x84F 70: #define A6XX_CP_PROTECT_REG 0x850 71: #define A6XX_CP_CONTEXT_SWITCH_CNTL 0x8A0 72: #define A6XX_CP_CONTEXT_SWITCH_SMMU_INFO_LO 0x8A1 73: #define A6XX_CP_CONTEXT_SWITCH_SMMU_INFO_HI 0x8A2 74: #define A6XX_CP_CONTEXT_SWITCH_PRIV_NON_SECURE_RESTORE_ADDR_LO 0x8A3 75: #define A6XX_CP_CONTEXT_SWITCH_PRIV_NON_SECURE_RESTORE_ADDR_HI 0x8A4 76: #define A6XX_CP_CONTEXT_SWITCH_PRIV_SECURE_RESTORE_ADDR_LO 0x8A5 77: #define A6XX_CP_CONTEXT_SWITCH_PRIV_SECURE_RESTORE_ADDR_HI 0x8A6 78: #define A6XX_CP_CONTEXT_SWITCH_NON_PRIV_RESTORE_ADDR_LO 0x8A7 79: #define A6XX_CP_CONTEXT_SWITCH_NON_PRIV_RESTORE_ADDR_HI 0x8A8 80: #define A6XX_CP_CONTEXT_SWITCH_LEVEL_STATUS 0x8AB 81: #define A6XX_CP_PERFCTR_CP_SEL_0 0x8D0 82: #define A6XX_CP_PERFCTR_CP_SEL_1 0x8D1 83: #define A6XX_CP_PERFCTR_CP_SEL_2 0x8D2 84: #define A6XX_CP_PERFCTR_CP_SEL_3 0x8D3 85: #define A6XX_CP_PERFCTR_CP_SEL_4 0x8D4 86: #define A6XX_CP_PERFCTR_CP_SEL_5 0x8D5 87: #define A6XX_CP_PERFCTR_CP_SEL_6 0x8D6 88: #define A6XX_CP_PERFCTR_CP_SEL_7 0x8D7 89: #define A6XX_CP_PERFCTR_CP_SEL_8 0x8D8 90: #define A6XX_CP_PERFCTR_CP_SEL_9 0x8D9 91: #define A6XX_CP_PERFCTR_CP_SEL_10 0x8DA 92: #define A6XX_CP_PERFCTR_CP_SEL_11 0x8DB 93: #define A6XX_CP_PERFCTR_CP_SEL_12 0x8DC 94: #define A6XX_CP_PERFCTR_CP_SEL_13 0x8DD 95: #define A6XX_CP_CRASH_SCRIPT_BASE_LO 0x900 96: #define A6XX_CP_CRASH_SCRIPT_BASE_HI 0x901 97: #define A6XX_CP_CRASH_DUMP_CNTL 0x902 98: #define A6XX_CP_CRASH_DUMP_STATUS 0x903 99: #define A6XX_CP_SQE_STAT_ADDR 0x908 100: #define A6XX_CP_SQE_STAT_DATA 0x909 101: #define A6XX_CP_DRAW_STATE_ADDR 0x90A 102: #define A6XX_CP_DRAW_STATE_DATA 0x90B 103: #define A6XX_CP_ROQ_DBG_ADDR 0x90C 104: #define A6XX_CP_ROQ_DBG_DATA 0x90D 105: #define A6XX_CP_MEM_POOL_DBG_ADDR 0x90E 106: #define A6XX_CP_MEM_POOL_DBG_DATA 0x90F 107: #define A6XX_CP_SQE_UCODE_DBG_ADDR 0x910 108: #define A6XX_CP_SQE_UCODE_DBG_DATA 0x911 109: #define A6XX_CP_IB1_BASE 0x928 110: #define A6XX_CP_IB1_BASE_HI 0x929 111: #define A6XX_CP_IB1_REM_SIZE 0x92A 112: #define A6XX_CP_IB2_BASE 0x92B 113: #define A6XX_CP_IB2_BASE_HI 0x92C 114: #define A6XX_CP_IB2_REM_SIZE 0x92D 115: #define A6XX_CP_ALWAYS_ON_COUNTER_LO 0x980 116: #define A6XX_CP_ALWAYS_ON_COUNTER_HI 0x981 117: #define A6XX_CP_ALWAYS_ON_CONTEXT_LO 0x982 118: #define A6XX_CP_ALWAYS_ON_CONTEXT_HI 0x983 119: #define A6XX_CP_AHB_CNTL 0x98D 120: #define A6XX_CP_APERTURE_CNTL_HOST 0xA00 121: #define A6XX_CP_APERTURE_CNTL_CD 0xA03 122: #define A6XX_VSC_ADDR_MODE_CNTL 0xC01 123: 124: /* LPAC registers */ 125: #define A6XX_CP_LPAC_DRAW_STATE_ADDR 0xB0A 126: #define A6XX_CP_LPAC_DRAW_STATE_DATA 0xB0B 127: #define A6XX_CP_LPAC_ROQ_DBG_ADDR 0xB0C 128: #define A6XX_CP_SQE_AC_UCODE_DBG_ADDR 0xB27 129: #define A6XX_CP_SQE_AC_UCODE_DBG_DATA 0xB28 130: #define A6XX_CP_SQE_AC_STAT_ADDR 0xB29 131: #define A6XX_CP_SQE_AC_STAT_DATA 0xB2A 132: #define A6XX_CP_LPAC_ROQ_THRESHOLDS_1 0xB32 133: #define A6XX_CP_LPAC_ROQ_THRESHOLDS_2 0xB33 134: #define A6XX_CP_LPAC_PROG_FIFO_SIZE 0xB34 135: #define A6XX_CP_LPAC_ROQ_DBG_DATA 0xB35 136: #define A6XX_CP_LPAC_FIFO_DBG_DATA 0xB36 137: #define A6XX_CP_LPAC_FIFO_DBG_ADDR 0xB40 138: 139: /* RBBM registers */ 140: #define A6XX_RBBM_INT_0_STATUS 0x201 141: #define A6XX_RBBM_STATUS 0x210 142: #define A6XX_RBBM_STATUS3 0x213 143: #define A6XX_RBBM_VBIF_GX_RESET_STATUS 0x215 144: #define A6XX_RBBM_PERFCTR_CP_0_LO 0x400 145: #define A6XX_RBBM_PERFCTR_CP_0_HI 0x401 146: #define A6XX_RBBM_PERFCTR_CP_1_LO 0x402 147: #define A6XX_RBBM_PERFCTR_CP_1_HI 0x403 148: #define A6XX_RBBM_PERFCTR_CP_2_LO 0x404 149: #define A6XX_RBBM_PERFCTR_CP_2_HI 0x405 150: #define A6XX_RBBM_PERFCTR_CP_3_LO 0x406 151: #define A6XX_RBBM_PERFCTR_CP_3_HI 0x407 152: #define A6XX_RBBM_PERFCTR_CP_4_LO 0x408 153: #define A6XX_RBBM_PERFCTR_CP_4_HI 0x409 154: #define A6XX_RBBM_PERFCTR_CP_5_LO 0x40a 155: #define A6XX_RBBM_PERFCTR_CP_5_HI 0x40b 156: #define A6XX_RBBM_PERFCTR_CP_6_LO 0x40c 157: #define A6XX_RBBM_PERFCTR_CP_6_HI 0x40d 158: #define A6XX_RBBM_PERFCTR_CP_7_LO 0x40e 159: #define A6XX_RBBM_PERFCTR_CP_7_HI 0x40f 160: #define A6XX_RBBM_PERFCTR_CP_8_LO 0x410 161: #define A6XX_RBBM_PERFCTR_CP_8_HI 0x411 162: #define A6XX_RBBM_PERFCTR_CP_9_LO 0x412 163: #define A6XX_RBBM_PERFCTR_CP_9_HI 0x413 164: #define A6XX_RBBM_PERFCTR_CP_10_LO 0x414 165: #define A6XX_RBBM_PERFCTR_CP_10_HI 0x415 166: #define A6XX_RBBM_PERFCTR_CP_11_LO 0x416 167: #define A6XX_RBBM_PERFCTR_CP_11_HI 0x417 168: #define A6XX_RBBM_PERFCTR_CP_12_LO 0x418 169: #define A6XX_RBBM_PERFCTR_CP_12_HI 0x419 170: #define A6XX_RBBM_PERFCTR_CP_13_LO 0x41a 171: #define A6XX_RBBM_PERFCTR_CP_13_HI 0x41b 172: #define A6XX_RBBM_PERFCTR_RBBM_0_LO 0x41c 173: #define A6XX_RBBM_PERFCTR_RBBM_0_HI 0x41d 174: #define A6XX_RBBM_PERFCTR_RBBM_1_LO 0x41e 175: #define A6XX_RBBM_PERFCTR_RBBM_1_HI 0x41f 176: #define A6XX_RBBM_PERFCTR_RBBM_2_LO 0x420 177: #define A6XX_RBBM_PERFCTR_RBBM_2_HI 0x421 178: #define A6XX_RBBM_PERFCTR_RBBM_3_LO 0x422 179: #define A6XX_RBBM_PERFCTR_RBBM_3_HI 0x423 180: #define A6XX_RBBM_PERFCTR_PC_0_LO 0x424 181: #define A6XX_RBBM_PERFCTR_PC_0_HI 0x425 182: #define A6XX_RBBM_PERFCTR_PC_1_LO 0x426 183: #define A6XX_RBBM_PERFCTR_PC_1_HI 0x427 184: #define A6XX_RBBM_PERFCTR_PC_2_LO 0x428 185: #define A6XX_RBBM_PERFCTR_PC_2_HI 0x429 186: #define A6XX_RBBM_PERFCTR_PC_3_LO 0x42a 187: #define A6XX_RBBM_PERFCTR_PC_3_HI 0x42b 188: #define A6XX_RBBM_PERFCTR_PC_4_LO 0x42c 189: #define A6XX_RBBM_PERFCTR_PC_4_HI 0x42d 190: #define A6XX_RBBM_PERFCTR_PC_5_LO 0x42e 191: #define A6XX_RBBM_PERFCTR_PC_5_HI 0x42f 192: #define A6XX_RBBM_PERFCTR_PC_6_LO 0x430 193: #define A6XX_RBBM_PERFCTR_PC_6_HI 0x431 194: #define A6XX_RBBM_PERFCTR_PC_7_LO 0x432 195: #define A6XX_RBBM_PERFCTR_PC_7_HI 0x433 196: #define A6XX_RBBM_PERFCTR_VFD_0_LO 0x434 197: #define A6XX_RBBM_PERFCTR_VFD_0_HI 0x435 198: #define A6XX_RBBM_PERFCTR_VFD_1_LO 0x436 199: #define A6XX_RBBM_PERFCTR_VFD_1_HI 0x437 200: #define A6XX_RBBM_PERFCTR_VFD_2_LO 0x438 201: #define A6XX_RBBM_PERFCTR_VFD_2_HI 0x439 202: #define A6XX_RBBM_PERFCTR_VFD_3_LO 0x43a 203: #define A6XX_RBBM_PERFCTR_VFD_3_HI 0x43b 204: #define A6XX_RBBM_PERFCTR_VFD_4_LO 0x43c 205: #define A6XX_RBBM_PERFCTR_VFD_4_HI 0x43d 206: #define A6XX_RBBM_PERFCTR_VFD_5_LO 0x43e 207: #define A6XX_RBBM_PERFCTR_VFD_5_HI 0x43f 208: #define A6XX_RBBM_PERFCTR_VFD_6_LO 0x440 209: #define A6XX_RBBM_PERFCTR_VFD_6_HI 0x441 210: #define A6XX_RBBM_PERFCTR_VFD_7_LO 0x442 211: #define A6XX_RBBM_PERFCTR_VFD_7_HI 0x443 212: #define A6XX_RBBM_PERFCTR_HLSQ_0_LO 0x444 213: #define A6XX_RBBM_PERFCTR_HLSQ_0_HI 0x445 214: #define A6XX_RBBM_PERFCTR_HLSQ_1_LO 0x446 215: #define A6XX_RBBM_PERFCTR_HLSQ_1_HI 0x447 216: #define A6XX_RBBM_PERFCTR_HLSQ_2_LO 0x448 217: #define A6XX_RBBM_PERFCTR_HLSQ_2_HI 0x449 218: #define A6XX_RBBM_PERFCTR_HLSQ_3_LO 0x44a 219: #define A6XX_RBBM_PERFCTR_HLSQ_3_HI 0x44b 220: #define A6XX_RBBM_PERFCTR_HLSQ_4_LO 0x44c 221: #define A6XX_RBBM_PERFCTR_HLSQ_4_HI 0x44d 222: #define A6XX_RBBM_PERFCTR_HLSQ_5_LO 0x44e 223: #define A6XX_RBBM_PERFCTR_HLSQ_5_HI 0x44f 224: #define A6XX_RBBM_PERFCTR_VPC_0_LO 0x450 225: #define A6XX_RBBM_PERFCTR_VPC_0_HI 0x451 226: #define A6XX_RBBM_PERFCTR_VPC_1_LO 0x452 227: #define A6XX_RBBM_PERFCTR_VPC_1_HI 0x453 228: #define A6XX_RBBM_PERFCTR_VPC_2_LO 0x454 229: #define A6XX_RBBM_PERFCTR_VPC_2_HI 0x455 230: #define A6XX_RBBM_PERFCTR_VPC_3_LO 0x456 231: #define A6XX_RBBM_PERFCTR_VPC_3_HI 0x457 232: #define A6XX_RBBM_PERFCTR_VPC_4_LO 0x458 233: #define A6XX_RBBM_PERFCTR_VPC_4_HI 0x459 234: #define A6XX_RBBM_PERFCTR_VPC_5_LO 0x45a 235: #define A6XX_RBBM_PERFCTR_VPC_5_HI 0x45b 236: #define A6XX_RBBM_PERFCTR_CCU_0_LO 0x45c 237: #define A6XX_RBBM_PERFCTR_CCU_0_HI 0x45d 238: #define A6XX_RBBM_PERFCTR_CCU_1_LO 0x45e 239: #define A6XX_RBBM_PERFCTR_CCU_1_HI 0x45f 240: #define A6XX_RBBM_PERFCTR_CCU_2_LO 0x460 241: #define A6XX_RBBM_PERFCTR_CCU_2_HI 0x461 242: #define A6XX_RBBM_PERFCTR_CCU_3_LO 0x462 243: #define A6XX_RBBM_PERFCTR_CCU_3_HI 0x463 244: #define A6XX_RBBM_PERFCTR_CCU_4_LO 0x464 245: #define A6XX_RBBM_PERFCTR_CCU_4_HI 0x465 246: #define A6XX_RBBM_PERFCTR_TSE_0_LO 0x466 247: #define A6XX_RBBM_PERFCTR_TSE_0_HI 0x467 248: #define A6XX_RBBM_PERFCTR_TSE_1_LO 0x468 249: #define A6XX_RBBM_PERFCTR_TSE_1_HI 0x469 250: #define A6XX_RBBM_PERFCTR_TSE_2_LO 0x46a 251: #define A6XX_RBBM_PERFCTR_CCU_4_HI 0x465 252: #define A6XX_RBBM_PERFCTR_TSE_0_LO 0x466 253: #define A6XX_RBBM_PERFCTR_TSE_0_HI 0x467 254: #define A6XX_RBBM_PERFCTR_TSE_1_LO 0x468 255: #define A6XX_RBBM_PERFCTR_TSE_1_HI 0x469 256: #define A6XX_RBBM_PERFCTR_TSE_2_LO 0x46a 257: #define A6XX_RBBM_PERFCTR_TSE_2_HI 0x46b 258: #define A6XX_RBBM_PERFCTR_TSE_3_LO 0x46c 259: #define A6XX_RBBM_PERFCTR_TSE_3_HI 0x46d 260: #define A6XX_RBBM_PERFCTR_RAS_0_LO 0x46e 261: #define A6XX_RBBM_PERFCTR_RAS_0_HI 0x46f 262: #define A6XX_RBBM_PERFCTR_RAS_1_LO 0x470 263: #define A6XX_RBBM_PERFCTR_RAS_1_HI 0x471 264: #define A6XX_RBBM_PERFCTR_RAS_2_LO 0x472 265: #define A6XX_RBBM_PERFCTR_RAS_2_HI 0x473 266: #define A6XX_RBBM_PERFCTR_RAS_3_LO 0x474 267: #define A6XX_RBBM_PERFCTR_RAS_3_HI 0x475 268: #define A6XX_RBBM_PERFCTR_UCHE_0_LO 0x476 269: #define A6XX_RBBM_PERFCTR_UCHE_0_HI 0x477 270: #define A6XX_RBBM_PERFCTR_UCHE_1_LO 0x478 271: #define A6XX_RBBM_PERFCTR_UCHE_1_HI 0x479 272: #define A6XX_RBBM_PERFCTR_UCHE_2_LO 0x47a 273: #define A6XX_RBBM_PERFCTR_UCHE_2_HI 0x47b 274: #define A6XX_RBBM_PERFCTR_UCHE_3_LO 0x47c 275: #define A6XX_RBBM_PERFCTR_UCHE_3_HI 0x47d 276: #define A6XX_RBBM_PERFCTR_UCHE_4_LO 0x47e 277: #define A6XX_RBBM_PERFCTR_UCHE_4_HI 0x47f 278: #define A6XX_RBBM_PERFCTR_UCHE_5_LO 0x480 279: #define A6XX_RBBM_PERFCTR_UCHE_5_HI 0x481 280: #define A6XX_RBBM_PERFCTR_UCHE_6_LO 0x482 281: #define A6XX_RBBM_PERFCTR_UCHE_6_HI 0x483 282: #define A6XX_RBBM_PERFCTR_UCHE_7_LO 0x484 283: #define A6XX_RBBM_PERFCTR_UCHE_7_HI 0x485 284: #define A6XX_RBBM_PERFCTR_UCHE_8_LO 0x486 285: #define A6XX_RBBM_PERFCTR_UCHE_8_HI 0x487 286: #define A6XX_RBBM_PERFCTR_UCHE_9_LO 0x488 287: #define A6XX_RBBM_PERFCTR_UCHE_9_HI 0x489 288: #define A6XX_RBBM_PERFCTR_UCHE_10_LO 0x48a 289: #define A6XX_RBBM_PERFCTR_UCHE_10_HI 0x48b 290: #define A6XX_RBBM_PERFCTR_UCHE_11_LO 0x48c 291: #define A6XX_RBBM_PERFCTR_UCHE_11_HI 0x48d 292: #define A6XX_RBBM_PERFCTR_TP_0_LO 0x48e 293: #define A6XX_RBBM_PERFCTR_TP_0_HI 0x48f 294: #define A6XX_RBBM_PERFCTR_TP_1_LO 0x490 295: #define A6XX_RBBM_PERFCTR_TP_1_HI 0x491 296: #define A6XX_RBBM_PERFCTR_TP_2_LO 0x492 297: #define A6XX_RBBM_PERFCTR_TP_2_HI 0x493 298: #define A6XX_RBBM_PERFCTR_TP_3_LO 0x494 299: #define A6XX_RBBM_PERFCTR_TP_3_HI 0x495 300: #define A6XX_RBBM_PERFCTR_TP_4_LO 0x496 301: #define A6XX_RBBM_PERFCTR_TP_4_HI 0x497 302: #define A6XX_RBBM_PERFCTR_TP_5_LO 0x498 303: #define A6XX_RBBM_PERFCTR_TP_5_HI 0x499 304: #define A6XX_RBBM_PERFCTR_TP_6_LO 0x49a 305: #define A6XX_RBBM_PERFCTR_TP_6_HI 0x49b 306: #define A6XX_RBBM_PERFCTR_TP_7_LO 0x49c 307: #define A6XX_RBBM_PERFCTR_TP_7_HI 0x49d 308: #define A6XX_RBBM_PERFCTR_TP_8_LO 0x49e 309: #define A6XX_RBBM_PERFCTR_TP_8_HI 0x49f 310: #define A6XX_RBBM_PERFCTR_TP_9_LO 0x4a0 311: #define A6XX_RBBM_PERFCTR_TP_9_HI 0x4a1 312: #define A6XX_RBBM_PERFCTR_TP_10_LO 0x4a2 313: #define A6XX_RBBM_PERFCTR_TP_10_HI 0x4a3 314: #define A6XX_RBBM_PERFCTR_TP_11_LO 0x4a4 315: #define A6XX_RBBM_PERFCTR_TP_11_HI 0x4a5 316: #define A6XX_RBBM_PERFCTR_SP_0_LO 0x4a6 317: #define A6XX_RBBM_PERFCTR_SP_0_HI 0x4a7 318: #define A6XX_RBBM_PERFCTR_SP_1_LO 0x4a8 319: #define A6XX_RBBM_PERFCTR_SP_1_HI 0x4a9 320: #define A6XX_RBBM_PERFCTR_SP_2_LO 0x4aa 321: #define A6XX_RBBM_PERFCTR_SP_2_HI 0x4ab 322: #define A6XX_RBBM_PERFCTR_SP_3_LO 0x4ac 323: #define A6XX_RBBM_PERFCTR_SP_3_HI 0x4ad 324: #define A6XX_RBBM_PERFCTR_SP_4_LO 0x4ae 325: #define A6XX_RBBM_PERFCTR_SP_4_HI 0x4af 326: #define A6XX_RBBM_PERFCTR_SP_5_LO 0x4b0 327: #define A6XX_RBBM_PERFCTR_SP_5_HI 0x4b1 328: #define A6XX_RBBM_PERFCTR_SP_6_LO 0x4b2 329: #define A6XX_RBBM_PERFCTR_SP_6_HI 0x4b3 330: #define A6XX_RBBM_PERFCTR_SP_7_LO 0x4b4 331: #define A6XX_RBBM_PERFCTR_SP_7_HI 0x4b5 332: #define A6XX_RBBM_PERFCTR_SP_8_LO 0x4b6 333: #define A6XX_RBBM_PERFCTR_SP_8_HI 0x4b7 334: #define A6XX_RBBM_PERFCTR_SP_9_LO 0x4b8 335: #define A6XX_RBBM_PERFCTR_SP_9_HI 0x4b9 336: #define A6XX_RBBM_PERFCTR_SP_10_LO 0x4ba 337: #define A6XX_RBBM_PERFCTR_SP_10_HI 0x4bb 338: #define A6XX_RBBM_PERFCTR_SP_11_LO 0x4bc 339: #define A6XX_RBBM_PERFCTR_SP_11_HI 0x4bd 340: #define A6XX_RBBM_PERFCTR_SP_12_LO 0x4be 341: #define A6XX_RBBM_PERFCTR_SP_12_HI 0x4bf 342: #define A6XX_RBBM_PERFCTR_SP_13_LO 0x4c0 343: #define A6XX_RBBM_PERFCTR_SP_13_HI 0x4c1 344: #define A6XX_RBBM_PERFCTR_SP_14_LO 0x4c2 345: #define A6XX_RBBM_PERFCTR_SP_14_HI 0x4c3 346: #define A6XX_RBBM_PERFCTR_SP_15_LO 0x4c4 347: #define A6XX_RBBM_PERFCTR_SP_15_HI 0x4c5 348: #define A6XX_RBBM_PERFCTR_SP_16_LO 0x4c6 349: #define A6XX_RBBM_PERFCTR_SP_16_HI 0x4c7 350: #define A6XX_RBBM_PERFCTR_SP_17_LO 0x4c8 351: #define A6XX_RBBM_PERFCTR_SP_17_HI 0x4c9 352: #define A6XX_RBBM_PERFCTR_SP_18_LO 0x4ca 353: #define A6XX_RBBM_PERFCTR_SP_18_HI 0x4cb 354: #define A6XX_RBBM_PERFCTR_SP_19_LO 0x4cc 355: #define A6XX_RBBM_PERFCTR_SP_19_HI 0x4cd 356: #define A6XX_RBBM_PERFCTR_SP_20_LO 0x4ce 357: #define A6XX_RBBM_PERFCTR_SP_20_HI 0x4cf 358: #define A6XX_RBBM_PERFCTR_SP_21_LO 0x4d0 359: #define A6XX_RBBM_PERFCTR_SP_21_HI 0x4d1 360: #define A6XX_RBBM_PERFCTR_SP_22_LO 0x4d2 361: #define A6XX_RBBM_PERFCTR_SP_22_HI 0x4d3 362: #define A6XX_RBBM_PERFCTR_SP_23_LO 0x4d4 363: #define A6XX_RBBM_PERFCTR_SP_23_HI 0x4d5 364: #define A6XX_RBBM_PERFCTR_RB_0_LO 0x4d6 365: #define A6XX_RBBM_PERFCTR_RB_0_HI 0x4d7 366: #define A6XX_RBBM_PERFCTR_RB_1_LO 0x4d8 367: #define A6XX_RBBM_PERFCTR_RB_1_HI 0x4d9 368: #define A6XX_RBBM_PERFCTR_RB_2_LO 0x4da 369: #define A6XX_RBBM_PERFCTR_RB_2_HI 0x4db 370: #define A6XX_RBBM_PERFCTR_RB_3_LO 0x4dc 371: #define A6XX_RBBM_PERFCTR_RB_3_HI 0x4dd 372: #define A6XX_RBBM_PERFCTR_RB_4_LO 0x4de 373: #define A6XX_RBBM_PERFCTR_RB_4_HI 0x4df 374: #define A6XX_RBBM_PERFCTR_RB_5_LO 0x4e0 375: #define A6XX_RBBM_PERFCTR_RB_5_HI 0x4e1 376: #define A6XX_RBBM_PERFCTR_RB_6_LO 0x4e2 377: #define A6XX_RBBM_PERFCTR_RB_6_HI 0x4e3 378: #define A6XX_RBBM_PERFCTR_RB_7_LO 0x4e4 379: #define A6XX_RBBM_PERFCTR_RB_7_HI 0x4e5 380: #define A6XX_RBBM_PERFCTR_VSC_0_LO 0x4e6 381: #define A6XX_RBBM_PERFCTR_VSC_0_HI 0x4e7 382: #define A6XX_RBBM_PERFCTR_VSC_1_LO 0x4e8 383: #define A6XX_RBBM_PERFCTR_VSC_1_HI 0x4e9 384: #define A6XX_RBBM_PERFCTR_LRZ_0_LO 0x4ea 385: #define A6XX_RBBM_PERFCTR_LRZ_0_HI 0x4eb 386: #define A6XX_RBBM_PERFCTR_LRZ_1_LO 0x4ec 387: #define A6XX_RBBM_PERFCTR_LRZ_1_HI 0x4ed 388: #define A6XX_RBBM_PERFCTR_LRZ_2_LO 0x4ee 389: #define A6XX_RBBM_PERFCTR_LRZ_2_HI 0x4ef 390: #define A6XX_RBBM_PERFCTR_LRZ_3_LO 0x4f0 391: #define A6XX_RBBM_PERFCTR_LRZ_3_HI 0x4f1 392: #define A6XX_RBBM_PERFCTR_CMP_0_LO 0x4f2 393: #define A6XX_RBBM_PERFCTR_CMP_0_HI 0x4f3 394: #define A6XX_RBBM_PERFCTR_CMP_1_LO 0x4f4 395: #define A6XX_RBBM_PERFCTR_CMP_1_HI 0x4f5 396: #define A6XX_RBBM_PERFCTR_CMP_2_LO 0x4f6 397: #define A6XX_RBBM_PERFCTR_CMP_2_HI 0x4f7 398: #define A6XX_RBBM_PERFCTR_CMP_3_LO 0x4f8 399: #define A6XX_RBBM_PERFCTR_CMP_3_HI 0x4f9 400: #define A6XX_RBBM_PERFCTR_CNTL 0x500 401: #define A6XX_RBBM_PERFCTR_LOAD_CMD0 0x501 402: #define A6XX_RBBM_PERFCTR_LOAD_CMD1 0x502 403: #define A6XX_RBBM_PERFCTR_LOAD_CMD2 0x503 404: #define A6XX_RBBM_PERFCTR_LOAD_CMD3 0x504 405: #define A6XX_RBBM_PERFCTR_LOAD_VALUE_LO 0x505 406: #define A6XX_RBBM_PERFCTR_LOAD_VALUE_HI 0x506 407: #define A6XX_RBBM_PERFCTR_RBBM_SEL_0 0x507 408: #define A6XX_RBBM_PERFCTR_RBBM_SEL_1 0x508 409: #define A6XX_RBBM_PERFCTR_RBBM_SEL_2 0x509 410: #define A6XX_RBBM_PERFCTR_RBBM_SEL_3 0x50A 411: #define A6XX_RBBM_PERFCTR_GPU_BUSY_MASKED 0x50B 412: #define A6XX_RBBM_PERFCTR_SRAM_INIT_CMD 0x50e 413: #define A6XX_RBBM_PERFCTR_SRAM_INIT_STATUS 0x50f 414: 415: #define A6XX_RBBM_ISDB_CNT 0x533 416: #define A6XX_RBBM_NC_MODE_CNTL 0X534 417: #define A6XX_RBBM_SNAPSHOT_STATUS 0x535 418: #define A6XX_RBBM_LPAC_GBIF_CLIENT_QOS_CNTL 0x5ff 419: 420: #define A6XX_RBBM_SECVID_TRUST_CNTL 0xF400 421: #define A6XX_RBBM_SECVID_TSB_TRUSTED_BASE_LO 0xF800 422: #define A6XX_RBBM_SECVID_TSB_TRUSTED_BASE_HI 0xF801 423: #define A6XX_RBBM_SECVID_TSB_TRUSTED_SIZE 0xF802 424: #define A6XX_RBBM_SECVID_TSB_CNTL 0xF803 425: #define A6XX_RBBM_SECVID_TSB_ADDR_MODE_CNTL 0xF810 426: 427: #define A6XX_RBBM_VBIF_CLIENT_QOS_CNTL 0x00010 428: #define A6XX_RBBM_GBIF_CLIENT_QOS_CNTL 0x00011 429: #define A6XX_RBBM_GBIF_HALT 0x00016 430: #define A6XX_RBBM_GBIF_HALT_ACK 0x00017 431: #define A6XX_RBBM_GPR0_CNTL 0x00018 432: #define A6XX_RBBM_INTERFACE_HANG_INT_CNTL 0x0001f 433: #define A6XX_RBBM_INT_CLEAR_CMD 0x00037 434: #define A6XX_RBBM_INT_0_MASK 0x00038 435: #define A6XX_RBBM_INT_2_MASK 0x0003A 436: #define A6XX_RBBM_SP_HYST_CNT 0x00042 437: #define A6XX_RBBM_SW_RESET_CMD 0x00043 438: #define A6XX_RBBM_RAC_THRESHOLD_CNT 0x00044 439: #define A6XX_RBBM_BLOCK_SW_RESET_CMD 0x00045 440: #define A6XX_RBBM_BLOCK_SW_RESET_CMD2 0x00046 441: #define A6XX_RBBM_BLOCK_GX_RETENTION_CNTL 0x00050 442: #define A6XX_RBBM_CLOCK_CNTL 0x000ae 443: #define A6XX_RBBM_CLOCK_CNTL_SP0 0x000b0 444: #define A6XX_RBBM_CLOCK_CNTL_SP1 0x000b1 445: #define A6XX_RBBM_CLOCK_CNTL_SP2 0x000b2 446: #define A6XX_RBBM_CLOCK_CNTL_SP3 0x000b3 447: #define A6XX_RBBM_CLOCK_CNTL2_SP0 0x000b4 448: #define A6XX_RBBM_CLOCK_CNTL2_SP1 0x000b5 449: #define A6XX_RBBM_CLOCK_CNTL2_SP2 0x000b6 450: #define A6XX_RBBM_CLOCK_CNTL2_SP3 0x000b7 451: #define A6XX_RBBM_CLOCK_DELAY_SP0 0x000b8 452: #define A6XX_RBBM_CLOCK_DELAY_SP1 0x000b9 453: #define A6XX_RBBM_CLOCK_DELAY_SP2 0x000ba 454: #define A6XX_RBBM_CLOCK_DELAY_SP3 0x000bb 455: #define A6XX_RBBM_CLOCK_HYST_SP0 0x000bc 456: #define A6XX_RBBM_CLOCK_HYST_SP1 0x000bd 457: #define A6XX_RBBM_CLOCK_HYST_SP2 0x000be 458: #define A6XX_RBBM_CLOCK_HYST_SP3 0x000bf 459: #define A6XX_RBBM_CLOCK_CNTL_TP0 0x000c0 460: #define A6XX_RBBM_CLOCK_CNTL_TP1 0x000c1 461: #define A6XX_RBBM_CLOCK_CNTL_TP2 0x000c2 462: #define A6XX_RBBM_CLOCK_CNTL_TP3 0x000c3 463: #define A6XX_RBBM_CLOCK_CNTL2_TP0 0x000c4 464: #define A6XX_RBBM_CLOCK_CNTL2_TP1 0x000c5 465: #define A6XX_RBBM_CLOCK_CNTL2_TP2 0x000c6 466: #define A6XX_RBBM_CLOCK_CNTL2_TP3 0x000c7 467: #define A6XX_RBBM_CLOCK_CNTL3_TP0 0x000c8 468: #define A6XX_RBBM_CLOCK_CNTL3_TP1 0x000c9 469: #define A6XX_RBBM_CLOCK_CNTL3_TP2 0x000ca 470: #define A6XX_RBBM_CLOCK_CNTL3_TP3 0x000cb 471: #define A6XX_RBBM_CLOCK_CNTL4_TP0 0x000cc 472: #define A6XX_RBBM_CLOCK_CNTL4_TP1 0x000cd 473: #define A6XX_RBBM_CLOCK_CNTL4_TP2 0x000ce 474: #define A6XX_RBBM_CLOCK_CNTL4_TP3 0x000cf 475: #define A6XX_RBBM_CLOCK_DELAY_TP0 0x000d0 476: #define A6XX_RBBM_CLOCK_DELAY_TP1 0x000d1 477: #define A6XX_RBBM_CLOCK_DELAY_TP2 0x000d2 478: #define A6XX_RBBM_CLOCK_DELAY_TP3 0x000d3 479: #define A6XX_RBBM_CLOCK_DELAY2_TP0 0x000d4 480: #define A6XX_RBBM_CLOCK_DELAY2_TP1 0x000d5 481: #define A6XX_RBBM_CLOCK_DELAY2_TP2 0x000d6 482: #define A6XX_RBBM_CLOCK_DELAY2_TP3 0x000d7 483: #define A6XX_RBBM_CLOCK_DELAY3_TP0 0x000d8 484: #define A6XX_RBBM_CLOCK_DELAY3_TP1 0x000d9 485: #define A6XX_RBBM_CLOCK_DELAY3_TP2 0x000da 486: #define A6XX_RBBM_CLOCK_DELAY3_TP3 0x000db 487: #define A6XX_RBBM_CLOCK_DELAY4_TP0 0x000dc 488: #define A6XX_RBBM_CLOCK_DELAY4_TP1 0x000dd 489: #define A6XX_RBBM_CLOCK_DELAY4_TP2 0x000de 490: #define A6XX_RBBM_CLOCK_DELAY4_TP3 0x000df 491: #define A6XX_RBBM_CLOCK_HYST_TP0 0x000e0 492: #define A6XX_RBBM_CLOCK_HYST_TP1 0x000e1 493: #define A6XX_RBBM_CLOCK_HYST_TP2 0x000e2 494: #define A6XX_RBBM_CLOCK_HYST_TP3 0x000e3 495: #define A6XX_RBBM_CLOCK_HYST2_TP0 0x000e4 496: #define A6XX_RBBM_CLOCK_HYST2_TP1 0x000e5 497: #define A6XX_RBBM_CLOCK_HYST2_TP2 0x000e6 498: #define A6XX_RBBM_CLOCK_HYST2_TP3 0x000e7 499: #define A6XX_RBBM_CLOCK_HYST3_TP0 0x000e8 500: #define A6XX_RBBM_CLOCK_HYST3_TP1 0x000e9 501: #define A6XX_RBBM_CLOCK_HYST3_TP2 0x000ea 502: #define A6XX_RBBM_CLOCK_HYST3_TP3 0x000eb 503: #define A6XX_RBBM_CLOCK_HYST4_TP0 0x000ec 504: #define A6XX_RBBM_CLOCK_HYST4_TP1 0x000ed 505: #define A6XX_RBBM_CLOCK_HYST4_TP2 0x000ee 506: #define A6XX_RBBM_CLOCK_HYST4_TP3 0x000ef 507: #define A6XX_RBBM_CLOCK_CNTL_RB0 0x000f0 508: #define A6XX_RBBM_CLOCK_CNTL_RB1 0x000f1 509: #define A6XX_RBBM_CLOCK_CNTL_RB2 0x000f2 510: #define A6XX_RBBM_CLOCK_CNTL_RB3 0x000f3 511: #define A6XX_RBBM_CLOCK_CNTL2_RB0 0x000f4 512: #define A6XX_RBBM_CLOCK_CNTL2_RB1 0x000f5 513: #define A6XX_RBBM_CLOCK_CNTL2_RB2 0x000f6 514: #define A6XX_RBBM_CLOCK_CNTL2_RB3 0x000f7 515: #define A6XX_RBBM_CLOCK_CNTL_CCU0 0x000f8 516: #define A6XX_RBBM_CLOCK_CNTL_CCU1 0x000f9 517: #define A6XX_RBBM_CLOCK_CNTL_CCU2 0x000fa 518: #define A6XX_RBBM_CLOCK_CNTL_CCU3 0x000fb 519: #define A6XX_RBBM_CLOCK_HYST_RB_CCU0 0x00100 520: #define A6XX_RBBM_CLOCK_HYST_RB_CCU1 0x00101 521: #define A6XX_RBBM_CLOCK_HYST_RB_CCU2 0x00102 522: #define A6XX_RBBM_CLOCK_HYST_RB_CCU3 0x00103 523: #define A6XX_RBBM_CLOCK_CNTL_RAC 0x00104 524: #define A6XX_RBBM_CLOCK_CNTL2_RAC 0x00105 525: #define A6XX_RBBM_CLOCK_DELAY_RAC 0x00106 526: #define A6XX_RBBM_CLOCK_HYST_RAC 0x00107 527: #define A6XX_RBBM_CLOCK_CNTL_TSE_RAS_RBBM 0x00108 528: #define A6XX_RBBM_CLOCK_DELAY_TSE_RAS_RBBM 0x00109 529: #define A6XX_RBBM_CLOCK_HYST_TSE_RAS_RBBM 0x0010a 530: #define A6XX_RBBM_CLOCK_CNTL_UCHE 0x0010b 531: #define A6XX_RBBM_CLOCK_CNTL2_UCHE 0x0010c 532: #define A6XX_RBBM_CLOCK_CNTL3_UCHE 0x0010d 533: #define A6XX_RBBM_CLOCK_CNTL4_UCHE 0x0010e 534: #define A6XX_RBBM_CLOCK_DELAY_UCHE 0x0010f 535: #define A6XX_RBBM_CLOCK_HYST_UCHE 0x00110 536: #define A6XX_RBBM_CLOCK_MODE_VFD 0x00111 537: #define A6XX_RBBM_CLOCK_DELAY_VFD 0x00112 538: #define A6XX_RBBM_CLOCK_HYST_VFD 0x00113 539: #define A6XX_RBBM_CLOCK_MODE_GPC 0x00114 540: #define A6XX_RBBM_CLOCK_DELAY_GPC 0x00115 541: #define A6XX_RBBM_CLOCK_HYST_GPC 0x00116 542: #define A6XX_RBBM_CLOCK_DELAY_HLSQ_2 0x00117 543: #define A6XX_RBBM_CLOCK_CNTL_GMU_GX 0x00118 544: #define A6XX_RBBM_CLOCK_DELAY_GMU_GX 0x00119 545: #define A6XX_RBBM_CLOCK_CNTL_TEX_FCHE 0x00120 546: #define A6XX_RBBM_CLOCK_DELAY_TEX_FCHE 0x00121 547: #define A6XX_RBBM_CLOCK_HYST_TEX_FCHE 0x00122 548: #define A6XX_RBBM_CLOCK_HYST_GMU_GX 0x0011a 549: #define A6XX_RBBM_CLOCK_MODE_HLSQ 0x0011b 550: #define A6XX_RBBM_CLOCK_DELAY_HLSQ 0x0011c 551: #define A6XX_RBBM_CLOCK_HYST_HLSQ 0x0011d 552: #define A6XX_RBBM_CLOCK_CNTL_FCHE 0x00123 553: #define A6XX_RBBM_CLOCK_DELAY_FCHE 0x00124 554: #define A6XX_RBBM_CLOCK_HYST_FCHE 0x00125 555: #define A6XX_RBBM_CLOCK_CNTL_MHUB 0x00126 556: #define A6XX_RBBM_CLOCK_DELAY_MHUB 0x00127 557: #define A6XX_RBBM_CLOCK_HYST_MHUB 0x00128 558: #define A6XX_RBBM_CLOCK_DELAY_GLC 0x00129 559: #define A6XX_RBBM_CLOCK_HYST_GLC 0x0012a 560: #define A6XX_RBBM_CLOCK_CNTL_GLC 0x0012b 561: 562: #define A6XX_GMUAO_GMU_CGC_MODE_CNTL 0x23b09 563: #define A6XX_GMUAO_GMU_CGC_DELAY_CNTL 0x23b0a 564: #define A6XX_GMUAO_GMU_CGC_HYST_CNTL 0x23b0b 565: #define A6XX_GMUCX_GMU_WFI_CONFIG 0x1f802 566: #define A6XX_GMUGX_GMU_SP_RF_CONTROL_0 0x1a883 567: #define A6XX_GMUGX_GMU_SP_RF_CONTROL_1 0x1a884 568: 569: /* DBGC_CFG registers */ 570: #define A6XX_DBGC_CFG_DBGBUS_SEL_A 0x600 571: #define A6XX_DBGC_CFG_DBGBUS_SEL_B 0x601 572: #define A6XX_DBGC_CFG_DBGBUS_SEL_C 0x602 573: #define A6XX_DBGC_CFG_DBGBUS_SEL_D 0x603 574: #define A6XX_DBGC_CFG_DBGBUS_SEL_PING_INDEX_SHIFT 0x0 575: #define A6XX_DBGC_CFG_DBGBUS_SEL_PING_BLK_SEL_SHIFT 0x8 576: #define A6XX_DBGC_CFG_DBGBUS_CNTLT 0x604 577: #define A6XX_DBGC_CFG_DBGBUS_CNTLT_TRACEEN_SHIFT 0x0 578: #define A6XX_DBGC_CFG_DBGBUS_CNTLT_GRANU_SHIFT 0xC 579: #define A6XX_DBGC_CFG_DBGBUS_CNTLT_SEGT_SHIFT 0x1C 580: #define A6XX_DBGC_CFG_DBGBUS_CNTLM 0x605 581: #define A6XX_DBGC_CFG_DBGBUS_CTLTM_ENABLE_SHIFT 0x18 582: #define A6XX_DBGC_CFG_DBGBUS_OPL 0x606 583: #define A6XX_DBGC_CFG_DBGBUS_OPE 0x607 584: #define A6XX_DBGC_CFG_DBGBUS_IVTL_0 0x608 585: #define A6XX_DBGC_CFG_DBGBUS_IVTL_1 0x609 586: #define A6XX_DBGC_CFG_DBGBUS_IVTL_2 0x60a 587: #define A6XX_DBGC_CFG_DBGBUS_IVTL_3 0x60b 588: #define A6XX_DBGC_CFG_DBGBUS_MASKL_0 0x60c 589: #define A6XX_DBGC_CFG_DBGBUS_MASKL_1 0x60d 590: #define A6XX_DBGC_CFG_DBGBUS_MASKL_2 0x60e 591: #define A6XX_DBGC_CFG_DBGBUS_MASKL_3 0x60f 592: #define A6XX_DBGC_CFG_DBGBUS_BYTEL_0 0x610 593: #define A6XX_DBGC_CFG_DBGBUS_BYTEL_1 0x611 594: #define A6XX_DBGC_CFG_DBGBUS_BYTEL0_SHIFT 0x0 595: #define A6XX_DBGC_CFG_DBGBUS_BYTEL1_SHIFT 0x4 596: #define A6XX_DBGC_CFG_DBGBUS_BYTEL2_SHIFT 0x8 597: #define A6XX_DBGC_CFG_DBGBUS_BYTEL3_SHIFT 0xC 598: #define A6XX_DBGC_CFG_DBGBUS_BYTEL4_SHIFT 0x10 599: #define A6XX_DBGC_CFG_DBGBUS_BYTEL5_SHIFT 0x14 600: #define A6XX_DBGC_CFG_DBGBUS_BYTEL6_SHIFT 0x18 601: #define A6XX_DBGC_CFG_DBGBUS_BYTEL7_SHIFT 0x1C 602: #define A6XX_DBGC_CFG_DBGBUS_BYTEL8_SHIFT 0x0 603: #define A6XX_DBGC_CFG_DBGBUS_BYTEL9_SHIFT 0x4 604: #define A6XX_DBGC_CFG_DBGBUS_BYTEL10_SHIFT 0x8 605: #define A6XX_DBGC_CFG_DBGBUS_BYTEL11_SHIFT 0xC 606: #define A6XX_DBGC_CFG_DBGBUS_BYTEL12_SHIFT 0x10 607: #define A6XX_DBGC_CFG_DBGBUS_BYTEL13_SHIFT 0x14 608: #define A6XX_DBGC_CFG_DBGBUS_BYTEL14_SHIFT 0x18 609: #define A6XX_DBGC_CFG_DBGBUS_BYTEL15_SHIFT 0x1C 610: #define A6XX_DBGC_CFG_DBGBUS_IVTE_0 0x612 611: #define A6XX_DBGC_CFG_DBGBUS_IVTE_1 0x613 612: #define A6XX_DBGC_CFG_DBGBUS_IVTE_2 0x614 613: #define A6XX_DBGC_CFG_DBGBUS_IVTE_3 0x615 614: #define A6XX_DBGC_CFG_DBGBUS_MASKE_0 0x616 615: #define A6XX_DBGC_CFG_DBGBUS_MASKE_1 0x617 616: #define A6XX_DBGC_CFG_DBGBUS_MASKE_2 0x618 617: #define A6XX_DBGC_CFG_DBGBUS_MASKE_3 0x619 618: #define A6XX_DBGC_CFG_DBGBUS_NIBBLEE 0x61a 619: #define A6XX_DBGC_CFG_DBGBUS_PTRC0 0x61b 620: #define A6XX_DBGC_CFG_DBGBUS_PTRC1 0x61c 621: #define A6XX_DBGC_CFG_DBGBUS_LOADREG 0x61d 622: #define A6XX_DBGC_CFG_DBGBUS_IDX 0x61e 623: #define A6XX_DBGC_CFG_DBGBUS_CLRC 0x61f 624: #define A6XX_DBGC_CFG_DBGBUS_LOADIVT 0x620 625: #define A6XX_DBGC_VBIF_DBG_CNTL 0x621 626: #define A6XX_DBGC_DBG_LO_HI_GPIO 0x622 627: #define A6XX_DBGC_EXT_TRACE_BUS_CNTL 0x623 628: #define A6XX_DBGC_READ_AHB_THROUGH_DBG 0x624 629: #define A6XX_DBGC_CFG_DBGBUS_TRACE_BUF1 0x62f 630: #define A6XX_DBGC_CFG_DBGBUS_TRACE_BUF2 0x630 631: #define A6XX_DBGC_EVT_CFG 0x640 632: #define A6XX_DBGC_EVT_INTF_SEL_0 0x641 633: #define A6XX_DBGC_EVT_INTF_SEL_1 0x642 634: #define A6XX_DBGC_PERF_ATB_CFG 0x643 635: #define A6XX_DBGC_PERF_ATB_COUNTER_SEL_0 0x644 636: #define A6XX_DBGC_PERF_ATB_COUNTER_SEL_1 0x645 637: #define A6XX_DBGC_PERF_ATB_COUNTER_SEL_2 0x646 638: #define A6XX_DBGC_PERF_ATB_COUNTER_SEL_3 0x647 639: #define A6XX_DBGC_PERF_ATB_TRIG_INTF_SEL_0 0x648 640: #define A6XX_DBGC_PERF_ATB_TRIG_INTF_SEL_1 0x649 641: #define A6XX_DBGC_PERF_ATB_DRAIN_CMD 0x64a 642: #define A6XX_DBGC_ECO_CNTL 0x650 643: #define A6XX_DBGC_AHB_DBG_CNTL 0x651 644: 645: /* VSC registers */ 646: #define A6XX_VSC_PERFCTR_VSC_SEL_0 0xCD8 647: #define A6XX_VSC_PERFCTR_VSC_SEL_1 0xCD9 648: 649: /* GRAS registers */ 650: #define A6XX_GRAS_ADDR_MODE_CNTL 0x8601 651: #define A6XX_GRAS_PERFCTR_TSE_SEL_0 0x8610 652: #define A6XX_GRAS_PERFCTR_TSE_SEL_1 0x8611 653: #define A6XX_GRAS_PERFCTR_TSE_SEL_2 0x8612 654: #define A6XX_GRAS_PERFCTR_TSE_SEL_3 0x8613 655: #define A6XX_GRAS_PERFCTR_RAS_SEL_0 0x8614 656: #define A6XX_GRAS_PERFCTR_RAS_SEL_1 0x8615 657: #define A6XX_GRAS_PERFCTR_RAS_SEL_2 0x8616 658: #define A6XX_GRAS_PERFCTR_RAS_SEL_3 0x8617 659: #define A6XX_GRAS_PERFCTR_LRZ_SEL_0 0x8618 660: #define A6XX_GRAS_PERFCTR_LRZ_SEL_1 0x8619 661: #define A6XX_GRAS_PERFCTR_LRZ_SEL_2 0x861A 662: #define A6XX_GRAS_PERFCTR_LRZ_SEL_3 0x861B 663: 664: /* RB registers */ 665: #define A6XX_RB_ADDR_MODE_CNTL 0x8E05 666: #define A6XX_RB_NC_MODE_CNTL 0x8E08 667: #define A6XX_RB_PERFCTR_RB_SEL_0 0x8E10 668: #define A6XX_RB_PERFCTR_RB_SEL_1 0x8E11 669: #define A6XX_RB_PERFCTR_RB_SEL_2 0x8E12 670: #define A6XX_RB_PERFCTR_RB_SEL_3 0x8E13 671: #define A6XX_RB_PERFCTR_RB_SEL_4 0x8E14 672: #define A6XX_RB_PERFCTR_RB_SEL_5 0x8E15 673: #define A6XX_RB_PERFCTR_RB_SEL_6 0x8E16 674: #define A6XX_RB_PERFCTR_RB_SEL_7 0x8E17 675: #define A6XX_RB_PERFCTR_CCU_SEL_0 0x8E18 676: #define A6XX_RB_PERFCTR_CCU_SEL_1 0x8E19 677: #define A6XX_RB_PERFCTR_CCU_SEL_2 0x8E1A 678: #define A6XX_RB_PERFCTR_CCU_SEL_3 0x8E1B 679: #define A6XX_RB_PERFCTR_CCU_SEL_4 0x8E1C 680: #define A6XX_RB_PERFCTR_CMP_SEL_0 0x8E2C 681: #define A6XX_RB_PERFCTR_CMP_SEL_1 0x8E2D 682: #define A6XX_RB_PERFCTR_CMP_SEL_2 0x8E2E 683: #define A6XX_RB_PERFCTR_CMP_SEL_3 0x8E2F 684: #define A6XX_RB_RB_SUB_BLOCK_SEL_CNTL_HOST 0x8E3B 685: #define A6XX_RB_RB_SUB_BLOCK_SEL_CNTL_CD 0x8E3D 686: #define A6XX_RB_CONTEXT_SWITCH_GMEM_SAVE_RESTORE 0x8E50 687: 688: /* PC registers */ 689: #define A6XX_PC_DBG_ECO_CNTL 0x9E00 690: #define A6XX_PC_ADDR_MODE_CNTL 0x9E01 691: #define A6XX_PC_PERFCTR_PC_SEL_0 0x9E34 692: #define A6XX_PC_PERFCTR_PC_SEL_1 0x9E35 693: #define A6XX_PC_PERFCTR_PC_SEL_2 0x9E36 694: #define A6XX_PC_PERFCTR_PC_SEL_3 0x9E37 695: #define A6XX_PC_PERFCTR_PC_SEL_4 0x9E38 696: #define A6XX_PC_PERFCTR_PC_SEL_5 0x9E39 697: #define A6XX_PC_PERFCTR_PC_SEL_6 0x9E3A 698: #define A6XX_PC_PERFCTR_PC_SEL_7 0x9E3B 699: 700: /* HLSQ registers */ 701: #define A6XX_HLSQ_ADDR_MODE_CNTL 0xBE05 702: #define A6XX_HLSQ_PERFCTR_HLSQ_SEL_0 0xBE10 703: #define A6XX_HLSQ_PERFCTR_HLSQ_SEL_1 0xBE11 704: #define A6XX_HLSQ_PERFCTR_HLSQ_SEL_2 0xBE12 705: #define A6XX_HLSQ_PERFCTR_HLSQ_SEL_3 0xBE13 706: #define A6XX_HLSQ_PERFCTR_HLSQ_SEL_4 0xBE14 707: #define A6XX_HLSQ_PERFCTR_HLSQ_SEL_5 0xBE15 708: #define A6XX_HLSQ_DBG_AHB_READ_APERTURE 0xC800 709: #define A6XX_HLSQ_DBG_READ_SEL 0xD000 710: 711: /* VFD registers */ 712: #define A6XX_VFD_ADDR_MODE_CNTL 0xA601 713: #define A6XX_VFD_PERFCTR_VFD_SEL_0 0xA610 714: #define A6XX_VFD_PERFCTR_VFD_SEL_1 0xA611 715: #define A6XX_VFD_PERFCTR_VFD_SEL_2 0xA612 716: #define A6XX_VFD_PERFCTR_VFD_SEL_3 0xA613 717: #define A6XX_VFD_PERFCTR_VFD_SEL_4 0xA614 718: #define A6XX_VFD_PERFCTR_VFD_SEL_5 0xA615 719: #define A6XX_VFD_PERFCTR_VFD_SEL_6 0xA616 720: #define A6XX_VFD_PERFCTR_VFD_SEL_7 0xA617 721: 722: /* VPC registers */ 723: #define A6XX_VPC_ADDR_MODE_CNTL 0x9601 724: #define A6XX_VPC_PERFCTR_VPC_SEL_0 0x9604 725: #define A6XX_VPC_PERFCTR_VPC_SEL_1 0x9605 726: #define A6XX_VPC_PERFCTR_VPC_SEL_2 0x9606 727: #define A6XX_VPC_PERFCTR_VPC_SEL_3 0x9607 728: #define A6XX_VPC_PERFCTR_VPC_SEL_4 0x9608 729: #define A6XX_VPC_PERFCTR_VPC_SEL_5 0x9609 730: 731: /* UCHE registers */ 732: #define A6XX_UCHE_ADDR_MODE_CNTL 0xE00 733: #define A6XX_UCHE_MODE_CNTL 0xE01 734: #define A6XX_UCHE_WRITE_RANGE_MAX_LO 0xE05 735: #define A6XX_UCHE_WRITE_RANGE_MAX_HI 0xE06 736: #define A6XX_UCHE_WRITE_THRU_BASE_LO 0xE07 737: #define A6XX_UCHE_WRITE_THRU_BASE_HI 0xE08 738: #define A6XX_UCHE_TRAP_BASE_LO 0xE09 739: #define A6XX_UCHE_TRAP_BASE_HI 0xE0A 740: #define A6XX_UCHE_GMEM_RANGE_MIN_LO 0xE0B 741: #define A6XX_UCHE_GMEM_RANGE_MIN_HI 0xE0C 742: #define A6XX_UCHE_GMEM_RANGE_MAX_LO 0xE0D 743: #define A6XX_UCHE_GMEM_RANGE_MAX_HI 0xE0E 744: #define A6XX_UCHE_CACHE_WAYS 0xE17 745: #define A6XX_UCHE_FILTER_CNTL 0xE18 746: #define A6XX_UCHE_CLIENT_PF 0xE19 747: #define A6XX_UCHE_CLIENT_PF_CLIENT_ID_MASK 0x7 748: #define A6XX_UCHE_PERFCTR_UCHE_SEL_0 0xE1C 749: #define A6XX_UCHE_PERFCTR_UCHE_SEL_1 0xE1D 750: #define A6XX_UCHE_PERFCTR_UCHE_SEL_2 0xE1E 751: #define A6XX_UCHE_PERFCTR_UCHE_SEL_3 0xE1F 752: #define A6XX_UCHE_PERFCTR_UCHE_SEL_4 0xE20 753: #define A6XX_UCHE_PERFCTR_UCHE_SEL_5 0xE21 754: #define A6XX_UCHE_PERFCTR_UCHE_SEL_6 0xE22 755: #define A6XX_UCHE_PERFCTR_UCHE_SEL_7 0xE23 756: #define A6XX_UCHE_PERFCTR_UCHE_SEL_8 0xE24 757: #define A6XX_UCHE_PERFCTR_UCHE_SEL_9 0xE25 758: #define A6XX_UCHE_PERFCTR_UCHE_SEL_10 0xE26 759: #define A6XX_UCHE_PERFCTR_UCHE_SEL_11 0xE27 760: #define A6XX_UCHE_GBIF_GX_CONFIG 0xE3A 761: #define A6XX_UCHE_CMDQ_CONFIG 0xE3C 762: 763: /* SP registers */ 764: #define A6XX_SP_DBG_ECO_CNTL 0xAE00 765: #define A6XX_SP_ADDR_MODE_CNTL 0xAE01 766: #define A6XX_SP_NC_MODE_CNTL 0xAE02 767: #define A6XX_SP_PERFCTR_SP_SEL_0 0xAE10 768: #define A6XX_SP_PERFCTR_SP_SEL_1 0xAE11 769: #define A6XX_SP_PERFCTR_SP_SEL_2 0xAE12 770: #define A6XX_SP_PERFCTR_SP_SEL_3 0xAE13 771: #define A6XX_SP_PERFCTR_SP_SEL_4 0xAE14 772: #define A6XX_SP_PERFCTR_SP_SEL_5 0xAE15 773: #define A6XX_SP_PERFCTR_SP_SEL_6 0xAE16 774: #define A6XX_SP_PERFCTR_SP_SEL_7 0xAE17 775: #define A6XX_SP_PERFCTR_SP_SEL_8 0xAE18 776: #define A6XX_SP_PERFCTR_SP_SEL_9 0xAE19 777: #define A6XX_SP_PERFCTR_SP_SEL_10 0xAE1A 778: #define A6XX_SP_PERFCTR_SP_SEL_11 0xAE1B 779: #define A6XX_SP_PERFCTR_SP_SEL_12 0xAE1C 780: #define A6XX_SP_PERFCTR_SP_SEL_13 0xAE1D 781: #define A6XX_SP_PERFCTR_SP_SEL_14 0xAE1E 782: #define A6XX_SP_PERFCTR_SP_SEL_15 0xAE1F 783: #define A6XX_SP_PERFCTR_SP_SEL_16 0xAE20 784: #define A6XX_SP_PERFCTR_SP_SEL_17 0xAE21 785: #define A6XX_SP_PERFCTR_SP_SEL_18 0xAE22 786: #define A6XX_SP_PERFCTR_SP_SEL_19 0xAE23 787: #define A6XX_SP_PERFCTR_SP_SEL_20 0xAE24 788: #define A6XX_SP_PERFCTR_SP_SEL_21 0xAE25 789: #define A6XX_SP_PERFCTR_SP_SEL_22 0xAE26 790: #define A6XX_SP_PERFCTR_SP_SEL_23 0xAE27 791: 792: /* TP registers */ 793: #define A6XX_TPL1_ADDR_MODE_CNTL 0xB601 794: #define A6XX_TPL1_NC_MODE_CNTL 0xB604 795: #define A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_0 0xB608 796: #define A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_1 0xB609 797: #define A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_2 0xB60A 798: #define A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_3 0xB60B 799: #define A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_4 0xB60C 800: #define A6XX_TPL1_PERFCTR_TP_SEL_0 0xB610 801: #define A6XX_TPL1_PERFCTR_TP_SEL_1 0xB611 802: #define A6XX_TPL1_PERFCTR_TP_SEL_2 0xB612 803: #define A6XX_TPL1_PERFCTR_TP_SEL_3 0xB613 804: #define A6XX_TPL1_PERFCTR_TP_SEL_4 0xB614 805: #define A6XX_TPL1_PERFCTR_TP_SEL_5 0xB615 806: #define A6XX_TPL1_PERFCTR_TP_SEL_6 0xB616 807: #define A6XX_TPL1_PERFCTR_TP_SEL_7 0xB617 808: #define A6XX_TPL1_PERFCTR_TP_SEL_8 0xB618 809: #define A6XX_TPL1_PERFCTR_TP_SEL_9 0xB619 810: #define A6XX_TPL1_PERFCTR_TP_SEL_10 0xB61A 811: #define A6XX_TPL1_PERFCTR_TP_SEL_11 0xB61B 812: 813: /* VBIF registers */ 814: #define A6XX_VBIF_VERSION 0x3000 815: #define A6XX_VBIF_CLKON 0x3001 816: #define A6XX_VBIF_CLKON_FORCE_ON_TESTBUS_MASK 0x1 817: #define A6XX_VBIF_CLKON_FORCE_ON_TESTBUS_SHIFT 0x1 818: #define A6XX_VBIF_GATE_OFF_WRREQ_EN 0x302A 819: #define A6XX_VBIF_XIN_HALT_CTRL0 0x3080 820: #define A6XX_VBIF_XIN_HALT_CTRL0_MASK 0xF 821: #define A6XX_VBIF_XIN_HALT_CTRL1 0x3081 822: #define A6XX_VBIF_TEST_BUS_OUT_CTRL 0x3084 823: #define A6XX_VBIF_TEST_BUS_OUT_CTRL_EN_MASK 0x1 824: #define A6XX_VBIF_TEST_BUS_OUT_CTRL_EN_SHIFT 0x0 825: #define A6XX_VBIF_TEST_BUS1_CTRL0 0x3085 826: #define A6XX_VBIF_TEST_BUS1_CTRL1 0x3086 827: #define A6XX_VBIF_TEST_BUS1_CTRL1_DATA_SEL_MASK 0xF 828: #define A6XX_VBIF_TEST_BUS1_CTRL1_DATA_SEL_SHIFT 0x0 829: #define A6XX_VBIF_TEST_BUS2_CTRL0 0x3087 830: #define A6XX_VBIF_TEST_BUS2_CTRL1 0x3088 831: #define A6XX_VBIF_TEST_BUS2_CTRL1_DATA_SEL_MASK 0x1FF 832: #define A6XX_VBIF_TEST_BUS2_CTRL1_DATA_SEL_SHIFT 0x0 833: #define A6XX_VBIF_TEST_BUS_OUT 0x308C 834: #define A6XX_VBIF_PERF_CNT_SEL0 0x30d0 835: #define A6XX_VBIF_PERF_CNT_SEL1 0x30d1 836: #define A6XX_VBIF_PERF_CNT_SEL2 0x30d2 837: #define A6XX_VBIF_PERF_CNT_SEL3 0x30d3 838: #define A6XX_VBIF_PERF_CNT_LOW0 0x30d8 839: #define A6XX_VBIF_PERF_CNT_LOW1 0x30d9 840: #define A6XX_VBIF_PERF_CNT_LOW2 0x30da 841: #define A6XX_VBIF_PERF_CNT_LOW3 0x30db 842: #define A6XX_VBIF_PERF_CNT_HIGH0 0x30e0 843: #define A6XX_VBIF_PERF_CNT_HIGH1 0x30e1 844: #define A6XX_VBIF_PERF_CNT_HIGH2 0x30e2 845: #define A6XX_VBIF_PERF_CNT_HIGH3 0x30e3 846: #define A6XX_VBIF_PERF_PWR_CNT_EN0 0x3100 847: #define A6XX_VBIF_PERF_PWR_CNT_EN1 0x3101 848: #define A6XX_VBIF_PERF_PWR_CNT_EN2 0x3102 849: #define A6XX_VBIF_PERF_PWR_CNT_LOW0 0x3110 850: #define A6XX_VBIF_PERF_PWR_CNT_LOW1 0x3111 851: #define A6XX_VBIF_PERF_PWR_CNT_LOW2 0x3112 852: #define A6XX_VBIF_PERF_PWR_CNT_HIGH0 0x3118 853: #define A6XX_VBIF_PERF_PWR_CNT_HIGH1 0x3119 854: #define A6XX_VBIF_PERF_PWR_CNT_HIGH2 0x311a 855: 856: /* GBIF countables */ 857: #define GBIF_AXI0_READ_DATA_TOTAL_BEATS 34 858: #define GBIF_AXI1_READ_DATA_TOTAL_BEATS 35 859: #define GBIF_AXI0_WRITE_DATA_TOTAL_BEATS 46 860: #define GBIF_AXI1_WRITE_DATA_TOTAL_BEATS 47 861: 862: /* GBIF registers */ 863: #define A6XX_GBIF_CX_CONFIG 0x3c00 864: #define A6XX_GBIF_SCACHE_CNTL0 0x3c01 865: #define A6XX_GBIF_SCACHE_CNTL1 0x3c02 866: #define A6XX_GBIF_QSB_SIDE0 0x3c03 867: #define A6XX_GBIF_QSB_SIDE1 0x3c04 868: #define A6XX_GBIF_QSB_SIDE2 0x3c05 869: #define A6XX_GBIF_QSB_SIDE3 0x3c06 870: #define A6XX_GBIF_HALT 0x3c45 871: #define A6XX_GBIF_HALT_ACK 0x3c46 872: 873: #define A6XX_GBIF_CLIENT_HALT_MASK BIT(0) 874: #define A6XX_GBIF_ARB_HALT_MASK BIT(1) 875: #define A6XX_GBIF_GX_HALT_MASK BIT(0) 876: 877: #define A6XX_GBIF_PERF_PWR_CNT_EN 0x3cc0 878: #define A6XX_GBIF_PERF_CNT_SEL 0x3cc2 879: #define A6XX_GBIF_PERF_PWR_CNT_SEL 0x3cc3 880: #define A6XX_GBIF_PERF_CNT_LOW0 0x3cc4 881: #define A6XX_GBIF_PERF_CNT_LOW1 0x3cc5 882: #define A6XX_GBIF_PERF_CNT_LOW2 0x3cc6 883: #define A6XX_GBIF_PERF_CNT_LOW3 0x3cc7 884: #define A6XX_GBIF_PERF_CNT_HIGH0 0x3cc8 885: #define A6XX_GBIF_PERF_CNT_HIGH1 0x3cc9 886: #define A6XX_GBIF_PERF_CNT_HIGH2 0x3cca 887: #define A6XX_GBIF_PERF_CNT_HIGH3 0x3ccb 888: #define A6XX_GBIF_PWR_CNT_LOW0 0x3ccc 889: #define A6XX_GBIF_PWR_CNT_LOW1 0x3ccd 890: #define A6XX_GBIF_PWR_CNT_LOW2 0x3cce 891: #define A6XX_GBIF_PWR_CNT_HIGH0 0x3ccf 892: #define A6XX_GBIF_PWR_CNT_HIGH1 0x3cd0 893: #define A6XX_GBIF_PWR_CNT_HIGH2 0x3cd1 894: 895: 896: /* CX_DBGC_CFG registers */ 897: #define A6XX_CX_DBGC_CFG_DBGBUS_SEL_A 0x18400 898: #define A6XX_CX_DBGC_CFG_DBGBUS_SEL_B 0x18401 899: #define A6XX_CX_DBGC_CFG_DBGBUS_SEL_C 0x18402 900: #define A6XX_CX_DBGC_CFG_DBGBUS_SEL_D 0x18403 901: #define A6XX_CX_DBGC_CFG_DBGBUS_SEL_PING_INDEX_SHIFT 0x0 902: #define A6XX_CX_DBGC_CFG_DBGBUS_SEL_PING_BLK_SEL_SHIFT 0x8 903: #define A6XX_CX_DBGC_CFG_DBGBUS_CNTLT 0x18404 904: #define A6XX_CX_DBGC_CFG_DBGBUS_CNTLT_TRACEEN_SHIFT 0x0 905: #define A6XX_CX_DBGC_CFG_DBGBUS_CNTLT_GRANU_SHIFT 0xC 906: #define A6XX_CX_DBGC_CFG_DBGBUS_CNTLT_SEGT_SHIFT 0x1C 907: #define A6XX_CX_DBGC_CFG_DBGBUS_CNTLM 0x18405 908: #define A6XX_CX_DBGC_CFG_DBGBUS_CNTLM_ENABLE_SHIFT 0x18 909: #define A6XX_CX_DBGC_CFG_DBGBUS_OPL 0x18406 910: #define A6XX_CX_DBGC_CFG_DBGBUS_OPE 0x18407 911: #define A6XX_CX_DBGC_CFG_DBGBUS_IVTL_0 0x18408 912: #define A6XX_CX_DBGC_CFG_DBGBUS_IVTL_1 0x18409 913: #define A6XX_CX_DBGC_CFG_DBGBUS_IVTL_2 0x1840A 914: #define A6XX_CX_DBGC_CFG_DBGBUS_IVTL_3 0x1840B 915: #define A6XX_CX_DBGC_CFG_DBGBUS_MASKL_0 0x1840C 916: #define A6XX_CX_DBGC_CFG_DBGBUS_MASKL_1 0x1840D 917: #define A6XX_CX_DBGC_CFG_DBGBUS_MASKL_2 0x1840E 918: #define A6XX_CX_DBGC_CFG_DBGBUS_MASKL_3 0x1840F 919: #define A6XX_CX_DBGC_CFG_DBGBUS_BYTEL_0 0x18410 920: #define A6XX_CX_DBGC_CFG_DBGBUS_BYTEL_1 0x18411 921: #define A6XX_CX_DBGC_CFG_DBGBUS_BYTEL0_SHIFT 0x0 922: #define A6XX_CX_DBGC_CFG_DBGBUS_BYTEL1_SHIFT 0x4 923: #define A6XX_CX_DBGC_CFG_DBGBUS_BYTEL2_SHIFT 0x8 924: #define A6XX_CX_DBGC_CFG_DBGBUS_BYTEL3_SHIFT 0xC 925: #define A6XX_CX_DBGC_CFG_DBGBUS_BYTEL4_SHIFT 0x10 926: #define A6XX_CX_DBGC_CFG_DBGBUS_BYTEL5_SHIFT 0x14 927: #define A6XX_CX_DBGC_CFG_DBGBUS_BYTEL6_SHIFT 0x18 928: #define A6XX_CX_DBGC_CFG_DBGBUS_BYTEL7_SHIFT 0x1C 929: #define A6XX_CX_DBGC_CFG_DBGBUS_BYTEL8_SHIFT 0x0 930: #define A6XX_CX_DBGC_CFG_DBGBUS_BYTEL9_SHIFT 0x4 931: #define A6XX_CX_DBGC_CFG_DBGBUS_BYTEL10_SHIFT 0x8 932: #define A6XX_CX_DBGC_CFG_DBGBUS_BYTEL11_SHIFT 0xC 933: #define A6XX_CX_DBGC_CFG_DBGBUS_BYTEL12_SHIFT 0x10 934: #define A6XX_CX_DBGC_CFG_DBGBUS_BYTEL13_SHIFT 0x14 935: #define A6XX_CX_DBGC_CFG_DBGBUS_BYTEL14_SHIFT 0x18 936: #define A6XX_CX_DBGC_CFG_DBGBUS_BYTEL15_SHIFT 0x1C 937: #define A6XX_CX_DBGC_CFG_DBGBUS_IVTE_0 0x18412 938: #define A6XX_CX_DBGC_CFG_DBGBUS_IVTE_1 0x18413 939: #define A6XX_CX_DBGC_CFG_DBGBUS_IVTE_2 0x18414 940: #define A6XX_CX_DBGC_CFG_DBGBUS_IVTE_3 0x18415 941: #define A6XX_CX_DBGC_CFG_DBGBUS_MASKE_0 0x18416 942: #define A6XX_CX_DBGC_CFG_DBGBUS_MASKE_1 0x18417 943: #define A6XX_CX_DBGC_CFG_DBGBUS_MASKE_2 0x18418 944: #define A6XX_CX_DBGC_CFG_DBGBUS_MASKE_3 0x18419 945: #define A6XX_CX_DBGC_CFG_DBGBUS_NIBBLEE 0x1841A 946: #define A6XX_CX_DBGC_CFG_DBGBUS_PTRC0 0x1841B 947: #define A6XX_CX_DBGC_CFG_DBGBUS_PTRC1 0x1841C 948: #define A6XX_CX_DBGC_CFG_DBGBUS_LOADREG 0x1841D 949: #define A6XX_CX_DBGC_CFG_DBGBUS_IDX 0x1841E 950: #define A6XX_CX_DBGC_CFG_DBGBUS_CLRC 0x1841F 951: #define A6XX_CX_DBGC_CFG_DBGBUS_LOADIVT 0x18420 952: #define A6XX_CX_DBGC_VBIF_DBG_CNTL 0x18421 953: #define A6XX_CX_DBGC_DBG_LO_HI_GPIO 0x18422 954: #define A6XX_CX_DBGC_EXT_TRACE_BUS_CNTL 0x18423 955: #define A6XX_CX_DBGC_READ_AHB_THROUGH_DBG 0x18424 956: #define A6XX_CX_DBGC_CFG_DBGBUS_TRACE_BUF1 0x1842F 957: #define A6XX_CX_DBGC_CFG_DBGBUS_TRACE_BUF2 0x18430 958: #define A6XX_CX_DBGC_EVT_CFG 0x18440 959: #define A6XX_CX_DBGC_EVT_INTF_SEL_0 0x18441 960: #define A6XX_CX_DBGC_EVT_INTF_SEL_1 0x18442 961: #define A6XX_CX_DBGC_PERF_ATB_CFG 0x18443 962: #define A6XX_CX_DBGC_PERF_ATB_COUNTER_SEL_0 0x18444 963: #define A6XX_CX_DBGC_PERF_ATB_COUNTER_SEL_1 0x18445 964: #define A6XX_CX_DBGC_PERF_ATB_COUNTER_SEL_2 0x18446 965: #define A6XX_CX_DBGC_PERF_ATB_COUNTER_SEL_3 0x18447 966: #define A6XX_CX_DBGC_PERF_ATB_TRIG_INTF_SEL_0 0x18448 967: #define A6XX_CX_DBGC_PERF_ATB_TRIG_INTF_SEL_1 0x18449 968: #define A6XX_CX_DBGC_PERF_ATB_DRAIN_CMD 0x1844A 969: #define A6XX_CX_DBGC_ECO_CNTL 0x18450 970: #define A6XX_CX_DBGC_AHB_DBG_CNTL 0x18451 971: 972: /* GMU control registers */ 973: #define A6XX_GPU_GMU_GX_SPTPRAC_CLOCK_CONTROL 0x1A880 974: #define A6XX_GMU_GX_SPTPRAC_POWER_CONTROL 0x1A881 975: #define A6XX_GMU_CM3_ITCM_START 0x1B400 976: #define A6XX_GMU_CM3_DTCM_START 0x1C400 977: #define A6XX_GMU_NMI_CONTROL_STATUS 0x1CBF0 978: #define A6XX_GMU_BOOT_SLUMBER_OPTION 0x1CBF8 979: #define A6XX_GMU_GX_VOTE_IDX 0x1CBF9 980: #define A6XX_GMU_MX_VOTE_IDX 0x1CBFA 981: #define A6XX_GMU_DCVS_ACK_OPTION 0x1CBFC 982: #define A6XX_GMU_DCVS_PERF_SETTING 0x1CBFD 983: #define A6XX_GMU_DCVS_BW_SETTING 0x1CBFE 984: #define A6XX_GMU_DCVS_RETURN 0x1CBFF 985: #define A6XX_GMU_ICACHE_CONFIG 0x1F400 986: #define A6XX_GMU_DCACHE_CONFIG 0x1F401 987: #define A6XX_GMU_SYS_BUS_CONFIG 0x1F40F 988: #define A6XX_GMU_CM3_SYSRESET 0x1F800 989: #define A6XX_GMU_CM3_BOOT_CONFIG 0x1F801 990: #define A6XX_GMU_CX_GMU_WFI_CONFIG 0x1F802 991: #define A6XX_GMU_CX_GMU_WDOG_CTRL 0x1F813 992: #define A6XX_GMU_CM3_FW_BUSY 0x1F81A 993: #define A6XX_GMU_CM3_FW_INIT_RESULT 0x1F81C 994: #define A6XX_GMU_CM3_CFG 0x1F82D 995: #define A6XX_GMU_CX_GMU_POWER_COUNTER_ENABLE 0x1F840 996: #define A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_0 0x1F841 997: #define A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_1 0x1F842 998: #define A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_L 0x1F844 999: #define A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_H 0x1F845 1000: #define A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_1_L 0x1F846 1001: #define A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_1_H 0x1F847 1002: #define A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_2_L 0x1F848 1003: #define A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_2_H 0x1F849 1004: #define A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_3_L 0x1F84A 1005: #define A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_3_H 0x1F84B 1006: #define A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_4_L 0x1F84C 1007: #define A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_4_H 0x1F84D 1008: #define A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_5_L 0x1F84E 1009: #define A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_5_H 0x1F84F 1010: #define A6XX_GMU_CX_GMU_POWER_COUNTER_GMUCLK_0_L 0x1F850 1011: #define A6XX_GMU_CX_GMU_POWER_COUNTER_GMUCLK_0_H 0x1F851 1012: #define A6XX_GMU_CX_GMU_POWER_COUNTER_GMUCLK_1_L 0x1F852 1013: #define A6XX_GMU_CX_GMU_POWER_COUNTER_GMUCLK_1_H 0x1F853 1014: #define A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_2 0x1F860 1015: #define A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_6_L 0x1F870 1016: #define A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_6_H 0x1F871 1017: #define A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_7_L 0x1F872 1018: #define A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_7_H 0x1F843 1019: #define A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_8_L 0x1F874 1020: #define A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_8_H 0x1F875 1021: #define A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_9_L 0x1F876 1022: #define A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_9_H 0x1F877 1023: #define A6XX_GMU_CX_GMU_PERF_COUNTER_ENABLE 0x1F8A0 1024: #define A6XX_GMU_CX_GMU_PERF_COUNTER_SELECT_0 0x1F8A1 1025: #define A6XX_GMU_CX_GMU_PERF_COUNTER_SELECT_1 0x1F8A2 1026: #define A6XX_GMU_CX_GMU_PERF_COUNTER_0_L 0x1F8A4 1027: #define A6XX_GMU_CX_GMU_PERF_COUNTER_0_H 0x1F8A5 1028: #define A6XX_GMU_CX_GMU_PERF_COUNTER_1_L 0x1F8A6 1029: #define A6XX_GMU_CX_GMU_PERF_COUNTER_1_H 0x1F8A7 1030: #define A6XX_GMU_CX_GMU_PERF_COUNTER_2_L 0x1F8A8 1031: #define A6XX_GMU_CX_GMU_PERF_COUNTER_2_H 0x1F8A9 1032: #define A6XX_GMU_CX_GMU_PERF_COUNTER_3_L 0x1F8AA 1033: #define A6XX_GMU_CX_GMU_PERF_COUNTER_3_H 0x1F8AB 1034: #define A6XX_GMU_CX_GMU_PERF_COUNTER_4_L 0x1F8AC 1035: #define A6XX_GMU_CX_GMU_PERF_COUNTER_4_H 0x1F8AD 1036: #define A6XX_GMU_CX_GMU_PERF_COUNTER_5_L 0x1F8AE 1037: #define A6XX_GMU_CX_GMU_PERF_COUNTER_5_H 0x1F8AF 1038: #define A6XX_GMU_PWR_COL_INTER_FRAME_CTRL 0x1F8C0 1039: #define A6XX_GMU_PWR_COL_INTER_FRAME_HYST 0x1F8C1 1040: #define A6XX_GMU_PWR_COL_SPTPRAC_HYST 0x1F8C2 1041: #define A6XX_GMU_SPTPRAC_PWR_CLK_STATUS 0x1F8D0 1042: #define A6XX_GMU_GPU_NAP_CTRL 0x1F8E4 1043: #define A6XX_GMU_RPMH_CTRL 0x1F8E8 1044: #define A6XX_GMU_RPMH_HYST_CTRL 0x1F8E9 1045: #define A6XX_GPU_GMU_CX_GMU_RPMH_POWER_STATE 0x1F8EC 1046: #define A6XX_GPU_GMU_CX_GMU_PWR_COL_CP_MSG 0x1F900 1047: #define A6XX_GPU_GMU_CX_GMU_PWR_COL_CP_RESP 0x1F901 1048: #define A6XX_GMU_BOOT_KMD_LM_HANDSHAKE 0x1F9F0 1049: #define A6XX_GMU_LLM_GLM_SLEEP_CTRL 0x1F957 1050: #define A6XX_GMU_LLM_GLM_SLEEP_STATUS 0x1F958 1051: 1052: /* HFI registers*/ 1053: #define A6XX_GMU_ALWAYS_ON_COUNTER_L 0x1F888 1054: #define A6XX_GMU_ALWAYS_ON_COUNTER_H 0x1F889 1055: #define A6XX_GMU_GMU_PWR_COL_KEEPALIVE 0x1F8C3 1056: #define A6XX_GMU_PWR_COL_PREEMPT_KEEPALIVE 0x1F8C4 1057: #define A6XX_GMU_HFI_CTRL_STATUS 0x1F980 1058: #define A6XX_GMU_HFI_VERSION_INFO 0x1F981 1059: #define A6XX_GMU_HFI_SFR_ADDR 0x1F982 1060: #define A6XX_GMU_HFI_MMAP_ADDR 0x1F983 1061: #define A6XX_GMU_HFI_QTBL_INFO 0x1F984 1062: #define A6XX_GMU_HFI_QTBL_ADDR 0x1F985 1063: #define A6XX_GMU_HFI_CTRL_INIT 0x1F986 1064: #define A6XX_GMU_GMU2HOST_INTR_SET 0x1F990 1065: #define A6XX_GMU_GMU2HOST_INTR_CLR 0x1F991 1066: #define A6XX_GMU_GMU2HOST_INTR_INFO 0x1F992 1067: #define A6XX_GMU_GMU2HOST_INTR_MASK 0x1F993 1068: #define A6XX_GMU_HOST2GMU_INTR_SET 0x1F994 1069: #define A6XX_GMU_HOST2GMU_INTR_CLR 0x1F995 1070: #define A6XX_GMU_HOST2GMU_INTR_RAW_INFO 0x1F996 1071: #define A6XX_GMU_HOST2GMU_INTR_EN_0 0x1F997 1072: #define A6XX_GMU_HOST2GMU_INTR_EN_1 0x1F998 1073: #define A6XX_GMU_HOST2GMU_INTR_EN_2 0x1F999 1074: #define A6XX_GMU_HOST2GMU_INTR_EN_3 0x1F99A 1075: #define A6XX_GMU_HOST2GMU_INTR_INFO_0 0x1F99B 1076: #define A6XX_GMU_HOST2GMU_INTR_INFO_1 0x1F99C 1077: #define A6XX_GMU_HOST2GMU_INTR_INFO_2 0x1F99D 1078: #define A6XX_GMU_HOST2GMU_INTR_INFO_3 0x1F99E 1079: #define A6XX_GMU_GENERAL_0 0x1F9C5 1080: #define A6XX_GMU_GENERAL_1 0x1F9C6 1081: #define A6XX_GMU_GENERAL_6 0x1F9CB 1082: #define A6XX_GMU_GENERAL_7 0x1F9CC 1083: #define A6XX_GMU_GENERAL_11 0x1F9D0 1084: 1085: /* ISENSE registers */ 1086: #define A6XX_GMU_ISENSE_CTRL 0x1F95D 1087: #define A6XX_GPU_GMU_CX_GMU_ISENSE_CTRL 0x1f95d 1088: #define A6XX_GPU_CS_ENABLE_REG 0x23120 1089: 1090: /* LM registers */ 1091: #define A6XX_GPU_GMU_CX_GMU_PWR_THRESHOLD 0x1F94D 1092: 1093: /* FAL10 veto register */ 1094: #define A6XX_GPU_GMU_CX_GMU_CX_FAL_INTF 0x1F8F0 1095: #define A6XX_GPU_GMU_CX_GMU_CX_FALNEXT_INTF 0x1F8F1 1096: 1097: #define A6XX_GMU_AO_INTERRUPT_EN 0x23B03 1098: #define A6XX_GMU_AO_HOST_INTERRUPT_CLR 0x23B04 1099: #define A6XX_GMU_AO_HOST_INTERRUPT_STATUS 0x23B05 1100: #define A6XX_GMU_AO_HOST_INTERRUPT_MASK 0x23B06 1101: #define A6XX_GPU_GMU_AO_GMU_CGC_MODE_CNTL 0x23B09 1102: #define A6XX_GPU_GMU_AO_GMU_CGC_DELAY_CNTL 0x23B0A 1103: #define A6XX_GPU_GMU_AO_GMU_CGC_HYST_CNTL 0x23B0B 1104: #define A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS 0x23B0C 1105: #define A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS2 0x23B0D 1106: #define A6XX_GPU_GMU_AO_GPU_CX_BUSY_MASK 0x23B0E 1107: #define A6XX_GMU_AO_AHB_FENCE_CTRL 0x23B10 1108: #define A6XX_GMU_AHB_FENCE_STATUS 0x23B13 1109: #define A6XX_GMU_AHB_FENCE_STATUS_CLR 0x23B14 1110: #define A6XX_GMU_RBBM_INT_UNMASKED_STATUS 0x23B15 1111: #define A6XX_GMU_AO_SPARE_CNTL 0x23B16 1112: 1113: /* RGMU GLM registers */ 1114: #define A6XX_GMU_AO_RGMU_GLM_SLEEP_CTRL 0x23B80 1115: #define A6XX_GMU_AO_RGMU_GLM_SLEEP_STATUS 0x23B81 1116: #define A6XX_GMU_AO_RGMU_GLM_HW_CRC_DISABLE 0x23B82 1117: 1118: /* GMU RSC control registers */ 1119: #define A6XX_GMU_RSCC_CONTROL_REQ 0x23B07 1120: #define A6XX_GMU_RSCC_CONTROL_ACK 0x23B08 1121: 1122: /* FENCE control registers */ 1123: #define A6XX_GMU_AHB_FENCE_RANGE_0 0x23B11 1124: #define A6XX_GMU_AHB_FENCE_RANGE_1 0x23B12 1125: 1126: /* GMU countables */ 1127: #define A6XX_GMU_CM3_BUSY_CYCLES 0 1128: 1129: /* GPUCC registers */ 1130: #define A6XX_GPU_CC_GX_GDSCR 0x24403 1131: #define A6XX_GPU_CC_GX_DOMAIN_MISC 0x24542 1132: #define A6XX_GPU_CC_GX_DOMAIN_MISC3 0x24563 1133: #define A6XX_GPU_CC_CX_CFG_GDSCR 0x2441C 1134: 1135: /* GPUCC offsets are different for A662 */ 1136: #define A662_GPU_CC_GX_GDSCR 0x26417 1137: #define A662_GPU_CC_GX_DOMAIN_MISC3 0x26541 1138: #define A662_GPU_CC_CX_CFG_GDSCR 0x26443 1139: 1140: /* GPUCC offsets are different for A622 */ 1141: #define A622_GPU_CC_CX_CFG_GDSCR 0x26445 1142: 1143: /* GPU CPR registers */ 1144: #define A6XX_GPU_CPR_FSM_CTL 0x26801 1145: 1146: /* GPU RSC sequencer registers */ 1147: #define A6XX_GPU_RSCC_RSC_STATUS0_DRV0 0x00004 1148: #define A6XX_RSCC_PDC_SEQ_START_ADDR 0x00008 1149: #define A6XX_RSCC_PDC_MATCH_VALUE_LO 0x00009 1150: #define A6XX_RSCC_PDC_MATCH_VALUE_HI 0x0000A 1151: #define A6XX_RSCC_PDC_SLAVE_ID_DRV0 0x0000B 1152: #define A6XX_RSCC_HIDDEN_TCS_CMD0_ADDR 0x0000D 1153: #define A6XX_RSCC_HIDDEN_TCS_CMD0_DATA 0x0000E 1154: #define A6XX_RSCC_TIMESTAMP_UNIT0_TIMESTAMP_L_DRV0 0x00082 1155: #define A6XX_RSCC_TIMESTAMP_UNIT0_TIMESTAMP_H_DRV0 0x00083 1156: #define A6XX_RSCC_TIMESTAMP_UNIT1_EN_DRV0 0x00089 1157: #define A6XX_RSCC_TIMESTAMP_UNIT1_OUTPUT_DRV0 0x0008C 1158: #define A6XX_RSCC_OVERRIDE_START_ADDR 0x00100 1159: #define A6XX_RSCC_SEQ_BUSY_DRV0 0x00101 1160: #define A6XX_RSCC_SEQ_MEM_0_DRV0 0x00180 1161: #define A6XX_RSCC_TCS0_DRV0_STATUS 0x00346 1162: #define A6XX_RSCC_TCS1_DRV0_STATUS 0x003EE 1163: #define A6XX_RSCC_TCS2_DRV0_STATUS 0x00496 1164: #define A6XX_RSCC_TCS3_DRV0_STATUS 0x0053E 1165: #define A6XX_RSCC_TCS4_DRV0_STATUS 0x005E6 1166: #define A6XX_RSCC_TCS5_DRV0_STATUS 0x0068E 1167: #define A6XX_RSCC_TCS6_DRV0_STATUS 0x00736 1168: #define A6XX_RSCC_TCS7_DRV0_STATUS 0x007DE 1169: #define A6XX_RSCC_TCS8_DRV0_STATUS 0x00886 1170: #define A6XX_RSCC_TCS9_DRV0_STATUS 0x0092E 1171: 1172: /* GPU RSC sequencer offsets are different for A622 */ 1173: #define A622_RSCC_SEQ_MEM_0_DRV0 0x00154 1174: #define A622_RSCC_TCS0_DRV0_STATUS 0x0034a 1175: #define A622_RSCC_TCS1_DRV0_STATUS 0x003f2 1176: #define A622_RSCC_TCS2_DRV0_STATUS 0x0049a 1177: #define A622_RSCC_TCS3_DRV0_STATUS 0x00542 1178: #define A622_RSCC_TCS4_DRV0_STATUS 0x005ea 1179: #define A622_RSCC_TCS5_DRV0_STATUS 0x00692 1180: #define A622_RSCC_TCS6_DRV0_STATUS 0x0073a 1181: #define A622_RSCC_TCS7_DRV0_STATUS 0x007e2 1182: #define A622_RSCC_TCS8_DRV0_STATUS 0x0088a 1183: #define A622_RSCC_TCS9_DRV0_STATUS 0x00932 1184: 1185: /* GPU PDC sequencer registers in AOSS.RPMh domain */ 1186: #define PDC_GPU_ENABLE_PDC 0x1140 1187: #define PDC_GPU_SEQ_START_ADDR 0x1148 1188: #define PDC_GPU_TCS0_CONTROL 0x1540 1189: #define PDC_GPU_TCS0_CMD_ENABLE_BANK 0x1541 1190: #define PDC_GPU_TCS0_CMD_WAIT_FOR_CMPL_BANK 0x1542 1191: #define PDC_GPU_TCS0_CMD0_MSGID 0x1543 1192: #define PDC_GPU_TCS0_CMD0_ADDR 0x1544 1193: #define PDC_GPU_TCS0_CMD0_DATA 0x1545 1194: #define PDC_GPU_TCS1_CONTROL 0x1572 MATCH LINES: 1228, 1229, 1230, 1231, 1232, 1233, 1234, 1235, 1236, 1239, 1240, 1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250, 1254, 1255, 1256, 1257, 1258, 1259, 1260, 1262 1216: * start the PDC SEQ offset at zero. 1217: */ 1218: #define PDC_GPU_SEQ_MEM_0 0x0 1219: 1220: /* 1221: * Legacy RSCC register range was a part of the GMU register space 1222: * now we are using a separate section for RSCC regsiters. Add the 1223: * offset for backward compatibility. 1224: */ 1225: #define RSCC_OFFSET_LEGACY 0x23400 1226: 1227: /* RGMU(PCC) registers in A6X_GMU_CX_0_NON_CONTEXT_DEC domain */ 1228: #define A6XX_RGMU_CX_INTR_GEN_EN 0x1F80F 1229: #define A6XX_RGMU_CX_RGMU_TIMER0 0x1F834 1230: #define A6XX_RGMU_CX_RGMU_TIMER1 0x1F835 1231: #define A6XX_RGMU_CX_PCC_CTRL 0x1F838 1232: #define A6XX_RGMU_CX_PCC_INIT_RESULT 0x1F839 1233: #define A6XX_RGMU_CX_PCC_BKPT_CFG 0x1F83A 1234: #define A6XX_RGMU_CX_PCC_BKPT_ADDR 0x1F83B 1235: #define A6XX_RGMU_CX_PCC_STATUS 0x1F83C 1236: #define A6XX_RGMU_CX_PCC_DEBUG 0x1F83D 1237: 1238: /* GPU CX_MISC registers */ 1239: #define A6XX_GPU_CX_MISC_SYSTEM_CACHE_CNTL_0 0x27801 1240: #define A6XX_GPU_CX_MISC_SYSTEM_CACHE_CNTL_1 0x27802 1241: #define A6XX_LLC_NUM_GPU_SCIDS 5 1242: #define A6XX_GPU_LLC_SCID_NUM_BITS 5 1243: #define A6XX_GPU_LLC_SCID_MASK \ 1244: ((1 << (A6XX_LLC_NUM_GPU_SCIDS * A6XX_GPU_LLC_SCID_NUM_BITS)) - 1) 1245: #define A6XX_GPUHTW_LLC_SCID_SHIFT 25 1246: #define A6XX_GPUHTW_LLC_SCID_MASK \ 1247: (((1 << A6XX_GPU_LLC_SCID_NUM_BITS) - 1) << A6XX_GPUHTW_LLC_SCID_SHIFT) 1248: #define A6XX_GPUMV_LLC_SCID_SHIFT 15 1249: #define A6XX_GPUMV_LLC_SCID_MASK \ 1250: (((1 << A6XX_GPU_LLC_SCID_NUM_BITS) - 1) << A6XX_GPUMV_LLC_SCID_SHIFT) 1251: 1252: 1253: /* FUSA registers */ 1254: #define A6XX_GPU_FUSA_REG_BASE 0x3FC00 1255: #define A6XX_GPU_FUSA_REG_ECC_CTRL 0x3FC00 1256: #define A6XX_GPU_FUSA_REG_CSR_PRIY 0x3FC52 1257: #define A6XX_GPU_FUSA_DISABLE_NUM_BITS 4 1258: #define A6XX_GPU_FUSA_DISABLE_BITS 0x5 1259: #define A6XX_GPU_FUSA_DISABLE_MASK \ 1260: ((1 << A6XX_GPU_FUSA_DISABLE_NUM_BITS) - 1) 1261: 1262: #endif /* _A6XX_REG_H */ 1263: --- FILE: \adreno-gpulist.h | HITS: 768 --- MATCH LINES: 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 690, 691, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 732, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 828, 831, 838, 859, 866, 887, 894, 915, 921, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 994, 995, 996, 997, 998, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1046, 1053, 1076, 1083, 1084, 1109, 1116, 1117, 1143, 1144, 1145, 1146, 1147, 1148, 1149, 1150, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158, 1159, 1160, 1161, 1162, 1163, 1164, 1165, 1166, 1167, 1168, 1169, 1170, 1171, 1172, 1173, 1174, 1175, 1176, 1177, 1178, 1179, 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1191, 1195, 1196, 1197, 1198, 1199, 1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207, 1208, 1209, 1210, 1211, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220, 1221, 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229, 1230, 1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1248, 1249, 1250, 1251, 1252, 1255, 1260, 1261, 1284, 1285, 1286, 1287, 1288, 1289, 1290, 1291, 1292, 1293, 1294, 1295, 1296, 1297, 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1305, 1306, 1307, 1308, 1309, 1310, 1311, 1312, 1313, 1314, 1315, 1316, 1317, 1318, 1319, 1320, 1321, 1322, 1323, 1324, 1325, 1326, 1327, 1328, 1329, 1330, 1331, 1332, 1335, 1340, 1341, 1365, 1371, 1372, 1396, 1401, 1402, 1425, 1426, 1427, 1428, 1429, 1430, 1431, 1432, 1433, 1434, 1435, 1436, 1437, 1438, 1439, 1440, 1441, 1442, 1443, 1444, 1445, 1446, 1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454, 1455, 1456, 1457, 1458, 1459, 1460, 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, 1469, 1470, 1473, 1478, 1479, 1501, 1508, 1529, 1534, 1535, 1553, 1559, 1560, 1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 1591, 1592, 1593, 1594, 1595, 1596, 1597, 1598, 1599, 1600, 1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615, 1616, 1617, 1618, 1619, 1620, 1621, 1622, 1623, 1624, 1625, 1626, 1627, 1632, 1633, 1634, 1635, 1636, 1637, 1638, 1639, 1640, 1641, 1642, 1643, 1644, 1645, 1646, 1647, 1648, 1649, 1650, 1651, 1652, 1653, 1654, 1655, 1656, 1657, 1658, 1659, 1660, 1661, 1662, 1663, 1664, 1665, 1666, 1667, 1668, 1669, 1670, 1671, 1672, 1673, 1677, 1683, 1684, 1709, 1716, 1717, 1742, 1749, 1750, 1775, 1781, 1782, 1807, 1814, 1815, 1850, 1857, 1858, 1883, 1889, 1890, 1918, 1919, 1920, 1921, 1922, 1923, 1924, 1925, 1926, 1927, 1928, 1929, 1930, 1931, 1932, 1933, 1934, 1935, 1936, 1937, 1938, 1939, 1940, 1941, 1942, 1943, 1944, 1945, 1946, 1947, 1948, 1949, 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1975, 1980, 1981, 2013, 2018, 2019 570: .pm4fw_name = "a530_pm4.fw", 571: .pfpfw_name = "a530_pfp.fw", 572: .zap_name = "a508_zap.mdt", 573: .hwcg = a50x_hwcg_regs, 574: .hwcg_count = ARRAY_SIZE(a50x_hwcg_regs), 575: .vbif = a530_vbif_regs, 576: .vbif_count = ARRAY_SIZE(a530_vbif_regs), 577: }; 578: 579: DEFINE_DEPRECATED_CORE(a630v1, ADRENO_REV_A630, 6, 3, 0, 0); 580: 581: static const struct kgsl_regmap_list a630_hwcg_regs[] = { 582: {A6XX_RBBM_CLOCK_CNTL_SP0, 0x02222222}, 583: {A6XX_RBBM_CLOCK_CNTL_SP1, 0x02222222}, 584: {A6XX_RBBM_CLOCK_CNTL_SP2, 0x02222222}, 585: {A6XX_RBBM_CLOCK_CNTL_SP3, 0x02222222}, 586: {A6XX_RBBM_CLOCK_CNTL2_SP0, 0x02022220}, 587: {A6XX_RBBM_CLOCK_CNTL2_SP1, 0x02022220}, 588: {A6XX_RBBM_CLOCK_CNTL2_SP2, 0x02022220}, 589: {A6XX_RBBM_CLOCK_CNTL2_SP3, 0x02022220}, 590: {A6XX_RBBM_CLOCK_DELAY_SP0, 0x00000080}, 591: {A6XX_RBBM_CLOCK_DELAY_SP1, 0x00000080}, 592: {A6XX_RBBM_CLOCK_DELAY_SP2, 0x00000080}, 593: {A6XX_RBBM_CLOCK_DELAY_SP3, 0x00000080}, 594: {A6XX_RBBM_CLOCK_HYST_SP0, 0x0000F3CF}, 595: {A6XX_RBBM_CLOCK_HYST_SP1, 0x0000F3CF}, 596: {A6XX_RBBM_CLOCK_HYST_SP2, 0x0000F3CF}, 597: {A6XX_RBBM_CLOCK_HYST_SP3, 0x0000F3CF}, 598: {A6XX_RBBM_CLOCK_CNTL_TP0, 0x02222222}, 599: {A6XX_RBBM_CLOCK_CNTL_TP1, 0x02222222}, 600: {A6XX_RBBM_CLOCK_CNTL_TP2, 0x02222222}, 601: {A6XX_RBBM_CLOCK_CNTL_TP3, 0x02222222}, 602: {A6XX_RBBM_CLOCK_CNTL2_TP0, 0x22222222}, 603: {A6XX_RBBM_CLOCK_CNTL2_TP1, 0x22222222}, 604: {A6XX_RBBM_CLOCK_CNTL2_TP2, 0x22222222}, 605: {A6XX_RBBM_CLOCK_CNTL2_TP3, 0x22222222}, 606: {A6XX_RBBM_CLOCK_CNTL3_TP0, 0x22222222}, 607: {A6XX_RBBM_CLOCK_CNTL3_TP1, 0x22222222}, 608: {A6XX_RBBM_CLOCK_CNTL3_TP2, 0x22222222}, 609: {A6XX_RBBM_CLOCK_CNTL3_TP3, 0x22222222}, 610: {A6XX_RBBM_CLOCK_CNTL4_TP0, 0x00022222}, 611: {A6XX_RBBM_CLOCK_CNTL4_TP1, 0x00022222}, 612: {A6XX_RBBM_CLOCK_CNTL4_TP2, 0x00022222}, 613: {A6XX_RBBM_CLOCK_CNTL4_TP3, 0x00022222}, 614: {A6XX_RBBM_CLOCK_HYST_TP0, 0x77777777}, 615: {A6XX_RBBM_CLOCK_HYST_TP1, 0x77777777}, 616: {A6XX_RBBM_CLOCK_HYST_TP2, 0x77777777}, 617: {A6XX_RBBM_CLOCK_HYST_TP3, 0x77777777}, 618: {A6XX_RBBM_CLOCK_HYST2_TP0, 0x77777777}, 619: {A6XX_RBBM_CLOCK_HYST2_TP1, 0x77777777}, 620: {A6XX_RBBM_CLOCK_HYST2_TP2, 0x77777777}, 621: {A6XX_RBBM_CLOCK_HYST2_TP3, 0x77777777}, 622: {A6XX_RBBM_CLOCK_HYST3_TP0, 0x77777777}, 623: {A6XX_RBBM_CLOCK_HYST3_TP1, 0x77777777}, 624: {A6XX_RBBM_CLOCK_HYST3_TP2, 0x77777777}, 625: {A6XX_RBBM_CLOCK_HYST3_TP3, 0x77777777}, 626: {A6XX_RBBM_CLOCK_HYST4_TP0, 0x00077777}, 627: {A6XX_RBBM_CLOCK_HYST4_TP1, 0x00077777}, 628: {A6XX_RBBM_CLOCK_HYST4_TP2, 0x00077777}, 629: {A6XX_RBBM_CLOCK_HYST4_TP3, 0x00077777}, 630: {A6XX_RBBM_CLOCK_DELAY_TP0, 0x11111111}, 631: {A6XX_RBBM_CLOCK_DELAY_TP1, 0x11111111}, 632: {A6XX_RBBM_CLOCK_DELAY_TP2, 0x11111111}, 633: {A6XX_RBBM_CLOCK_DELAY_TP3, 0x11111111}, 634: {A6XX_RBBM_CLOCK_DELAY2_TP0, 0x11111111}, 635: {A6XX_RBBM_CLOCK_DELAY2_TP1, 0x11111111}, 636: {A6XX_RBBM_CLOCK_DELAY2_TP2, 0x11111111}, 637: {A6XX_RBBM_CLOCK_DELAY2_TP3, 0x11111111}, 638: {A6XX_RBBM_CLOCK_DELAY3_TP0, 0x11111111}, 639: {A6XX_RBBM_CLOCK_DELAY3_TP1, 0x11111111}, 640: {A6XX_RBBM_CLOCK_DELAY3_TP2, 0x11111111}, 641: {A6XX_RBBM_CLOCK_DELAY3_TP3, 0x11111111}, 642: {A6XX_RBBM_CLOCK_DELAY4_TP0, 0x00011111}, 643: {A6XX_RBBM_CLOCK_DELAY4_TP1, 0x00011111}, 644: {A6XX_RBBM_CLOCK_DELAY4_TP2, 0x00011111}, 645: {A6XX_RBBM_CLOCK_DELAY4_TP3, 0x00011111}, 646: {A6XX_RBBM_CLOCK_CNTL_UCHE, 0x22222222}, 647: {A6XX_RBBM_CLOCK_CNTL2_UCHE, 0x22222222}, 648: {A6XX_RBBM_CLOCK_CNTL3_UCHE, 0x22222222}, 649: {A6XX_RBBM_CLOCK_CNTL4_UCHE, 0x00222222}, 650: {A6XX_RBBM_CLOCK_HYST_UCHE, 0x00000004}, 651: {A6XX_RBBM_CLOCK_DELAY_UCHE, 0x00000002}, 652: {A6XX_RBBM_CLOCK_CNTL_RB0, 0x22222222}, 653: {A6XX_RBBM_CLOCK_CNTL_RB1, 0x22222222}, 654: {A6XX_RBBM_CLOCK_CNTL_RB2, 0x22222222}, 655: {A6XX_RBBM_CLOCK_CNTL_RB3, 0x22222222}, 656: {A6XX_RBBM_CLOCK_CNTL2_RB0, 0x00002222}, 657: {A6XX_RBBM_CLOCK_CNTL2_RB1, 0x00002222}, 658: {A6XX_RBBM_CLOCK_CNTL2_RB2, 0x00002222}, 659: {A6XX_RBBM_CLOCK_CNTL2_RB3, 0x00002222}, 660: {A6XX_RBBM_CLOCK_CNTL_CCU0, 0x00002220}, 661: {A6XX_RBBM_CLOCK_CNTL_CCU1, 0x00002220}, 662: {A6XX_RBBM_CLOCK_CNTL_CCU2, 0x00002220}, 663: {A6XX_RBBM_CLOCK_CNTL_CCU3, 0x00002220}, 664: {A6XX_RBBM_CLOCK_HYST_RB_CCU0, 0x00040F00}, 665: {A6XX_RBBM_CLOCK_HYST_RB_CCU1, 0x00040F00}, 666: {A6XX_RBBM_CLOCK_HYST_RB_CCU2, 0x00040F00}, 667: {A6XX_RBBM_CLOCK_HYST_RB_CCU3, 0x00040F00}, 668: {A6XX_RBBM_CLOCK_CNTL_RAC, 0x05022022}, 669: {A6XX_RBBM_CLOCK_CNTL2_RAC, 0x00005555}, 670: {A6XX_RBBM_CLOCK_DELAY_RAC, 0x00000011}, 671: {A6XX_RBBM_CLOCK_HYST_RAC, 0x00445044}, 672: {A6XX_RBBM_CLOCK_CNTL_TSE_RAS_RBBM, 0x04222222}, 673: {A6XX_RBBM_CLOCK_MODE_GPC, 0x00222222}, 674: {A6XX_RBBM_CLOCK_MODE_VFD, 0x00002222}, 675: {A6XX_RBBM_CLOCK_HYST_TSE_RAS_RBBM, 0x00000000}, 676: {A6XX_RBBM_CLOCK_HYST_GPC, 0x04104004}, 677: {A6XX_RBBM_CLOCK_HYST_VFD, 0x00000000}, 678: {A6XX_RBBM_CLOCK_DELAY_HLSQ, 0x00000000}, 679: {A6XX_RBBM_CLOCK_DELAY_TSE_RAS_RBBM, 0x00004000}, 680: {A6XX_RBBM_CLOCK_DELAY_GPC, 0x00000200}, 681: {A6XX_RBBM_CLOCK_DELAY_VFD, 0x00002222}, 682: {A6XX_RBBM_CLOCK_DELAY_HLSQ_2, 0x00000002}, 683: {A6XX_RBBM_CLOCK_MODE_HLSQ, 0x00002222}, 684: {A6XX_RBBM_CLOCK_CNTL_GMU_GX, 0x00000222}, 685: {A6XX_RBBM_CLOCK_DELAY_GMU_GX, 0x00000111}, 686: {A6XX_RBBM_CLOCK_HYST_GMU_GX, 0x00000555}, 687: }; 688: 689: static const struct kgsl_regmap_list a630_vbif_regs[] = { 690: {A6XX_VBIF_GATE_OFF_WRREQ_EN, 0x00000009}, 691: {A6XX_RBBM_VBIF_CLIENT_QOS_CNTL, 0x3}, 692: }; 693: 694: 695: /* For a615, a616, a618, A619, a630, a640 and a680 */ 696: static const struct adreno_protected_regs a630_protected_regs[] = { 697: { A6XX_CP_PROTECT_REG + 0, 0x00000, 0x004ff, 0 }, 698: { A6XX_CP_PROTECT_REG + 1, 0x00501, 0x00506, 0 }, 699: { A6XX_CP_PROTECT_REG + 2, 0x0050b, 0x007ff, 0 }, 700: { A6XX_CP_PROTECT_REG + 3, 0x0050e, 0x0050e, 1 }, 701: { A6XX_CP_PROTECT_REG + 4, 0x00510, 0x00510, 1 }, 702: { A6XX_CP_PROTECT_REG + 5, 0x00534, 0x00534, 1 }, 703: { A6XX_CP_PROTECT_REG + 6, 0x00800, 0x00882, 1 }, 704: { A6XX_CP_PROTECT_REG + 7, 0x008a0, 0x008a8, 1 }, 705: { A6XX_CP_PROTECT_REG + 8, 0x008ab, 0x008cf, 1 }, 706: { A6XX_CP_PROTECT_REG + 9, 0x008d0, 0x0098c, 0 }, 707: { A6XX_CP_PROTECT_REG + 10, 0x00900, 0x0094d, 1 }, 708: { A6XX_CP_PROTECT_REG + 11, 0x0098d, 0x00bff, 1 }, 709: { A6XX_CP_PROTECT_REG + 12, 0x00e00, 0x00e01, 1 }, 710: { A6XX_CP_PROTECT_REG + 13, 0x00e03, 0x00e0f, 1 }, 711: { A6XX_CP_PROTECT_REG + 14, 0x03c00, 0x03cc3, 1 }, 712: { A6XX_CP_PROTECT_REG + 15, 0x03cc4, 0x05cc3, 0 }, 713: { A6XX_CP_PROTECT_REG + 16, 0x08630, 0x087ff, 1 }, 714: { A6XX_CP_PROTECT_REG + 17, 0x08e00, 0x08e00, 1 }, 715: { A6XX_CP_PROTECT_REG + 18, 0x08e08, 0x08e08, 1 }, 716: { A6XX_CP_PROTECT_REG + 19, 0x08e50, 0x08e6f, 1 }, 717: { A6XX_CP_PROTECT_REG + 20, 0x09624, 0x097ff, 1 }, 718: { A6XX_CP_PROTECT_REG + 21, 0x09e70, 0x09e71, 1 }, 719: { A6XX_CP_PROTECT_REG + 22, 0x09e78, 0x09fff, 1 }, 720: { A6XX_CP_PROTECT_REG + 23, 0x0a630, 0x0a7ff, 1 }, 721: { A6XX_CP_PROTECT_REG + 24, 0x0ae02, 0x0ae02, 1 }, 722: { A6XX_CP_PROTECT_REG + 25, 0x0ae50, 0x0b17f, 1 }, 723: { A6XX_CP_PROTECT_REG + 26, 0x0b604, 0x0b604, 1 }, 724: { A6XX_CP_PROTECT_REG + 27, 0x0be02, 0x0be03, 1 }, 725: { A6XX_CP_PROTECT_REG + 28, 0x0be20, 0x0d5ff, 1 }, 726: { A6XX_CP_PROTECT_REG + 29, 0x0f000, 0x0fbff, 1 }, 727: { A6XX_CP_PROTECT_REG + 30, 0x0fc00, 0x11bff, 0 }, 728: { A6XX_CP_PROTECT_REG + 31, 0x11c00, 0x11c00, 1 }, 729: { 0 }, 730: }; 731: 732: static const struct adreno_a6xx_core adreno_gpu_core_a630v2 = { 733: .base = { 734: DEFINE_ADRENO_REV(ADRENO_REV_A630, 6, 3, 0, ANY_ID), 735: .features = ADRENO_IFPC | ADRENO_CONTENT_PROTECTION | 736: ADRENO_IOCOHERENT | ADRENO_PREEMPTION, 737: .gpudev = &adreno_a630_gpudev.base, 738: .perfcounters = &adreno_a630_perfcounters, 739: .uche_gmem_alignment = SZ_1M, 740: .gmem_size = SZ_1M, 741: .bus_width = 32, 742: .snapshot_size = SZ_1M, 743: .highest_bank_bit = 15, 744: }, 745: .prim_fifo_threshold = 0x0018000, 746: .gmu_major = 1, 747: .gmu_minor = 3, 748: .sqefw_name = "a630_sqe.fw", 749: .gmufw_name = "a630_gmu.bin", 750: .zap_name = "a630_zap.mdt", 751: .hwcg = a630_hwcg_regs, 752: .hwcg_count = ARRAY_SIZE(a630_hwcg_regs), 753: .vbif = a630_vbif_regs, 754: .vbif_count = ARRAY_SIZE(a630_vbif_regs), 755: .hang_detect_cycles = 0xcfffff, 756: .protected_regs = a630_protected_regs, 757: }; 758: 759: /* For a615, a616, a618 and a619 */ 760: static const struct kgsl_regmap_list a615_hwcg_regs[] = { 761: {A6XX_RBBM_CLOCK_CNTL_SP0, 0x02222222}, 762: {A6XX_RBBM_CLOCK_CNTL2_SP0, 0x02222220}, 763: {A6XX_RBBM_CLOCK_DELAY_SP0, 0x00000080}, 764: {A6XX_RBBM_CLOCK_HYST_SP0, 0x0000F3CF}, 765: {A6XX_RBBM_CLOCK_CNTL_TP0, 0x02222222}, 766: {A6XX_RBBM_CLOCK_CNTL_TP1, 0x02222222}, 767: {A6XX_RBBM_CLOCK_CNTL2_TP0, 0x22222222}, 768: {A6XX_RBBM_CLOCK_CNTL2_TP1, 0x22222222}, 769: {A6XX_RBBM_CLOCK_CNTL3_TP0, 0x22222222}, 770: {A6XX_RBBM_CLOCK_CNTL3_TP1, 0x22222222}, 771: {A6XX_RBBM_CLOCK_CNTL4_TP0, 0x00022222}, 772: {A6XX_RBBM_CLOCK_CNTL4_TP1, 0x00022222}, 773: {A6XX_RBBM_CLOCK_HYST_TP0, 0x77777777}, 774: {A6XX_RBBM_CLOCK_HYST_TP1, 0x77777777}, 775: {A6XX_RBBM_CLOCK_HYST2_TP0, 0x77777777}, 776: {A6XX_RBBM_CLOCK_HYST2_TP1, 0x77777777}, 777: {A6XX_RBBM_CLOCK_HYST3_TP0, 0x77777777}, 778: {A6XX_RBBM_CLOCK_HYST3_TP1, 0x77777777}, 779: {A6XX_RBBM_CLOCK_HYST4_TP0, 0x00077777}, 780: {A6XX_RBBM_CLOCK_HYST4_TP1, 0x00077777}, 781: {A6XX_RBBM_CLOCK_DELAY_TP0, 0x11111111}, 782: {A6XX_RBBM_CLOCK_DELAY_TP1, 0x11111111}, 783: {A6XX_RBBM_CLOCK_DELAY2_TP0, 0x11111111}, 784: {A6XX_RBBM_CLOCK_DELAY2_TP1, 0x11111111}, 785: {A6XX_RBBM_CLOCK_DELAY3_TP0, 0x11111111}, 786: {A6XX_RBBM_CLOCK_DELAY3_TP1, 0x11111111}, 787: {A6XX_RBBM_CLOCK_DELAY4_TP0, 0x00011111}, 788: {A6XX_RBBM_CLOCK_DELAY4_TP1, 0x00011111}, 789: {A6XX_RBBM_CLOCK_CNTL_UCHE, 0x22222222}, 790: {A6XX_RBBM_CLOCK_CNTL2_UCHE, 0x22222222}, 791: {A6XX_RBBM_CLOCK_CNTL3_UCHE, 0x22222222}, 792: {A6XX_RBBM_CLOCK_CNTL4_UCHE, 0x00222222}, 793: {A6XX_RBBM_CLOCK_HYST_UCHE, 0x00000004}, 794: {A6XX_RBBM_CLOCK_DELAY_UCHE, 0x00000002}, 795: {A6XX_RBBM_CLOCK_CNTL_RB0, 0x22222222}, 796: {A6XX_RBBM_CLOCK_CNTL2_RB0, 0x00002222}, 797: {A6XX_RBBM_CLOCK_CNTL_CCU0, 0x00002220}, 798: {A6XX_RBBM_CLOCK_CNTL_CCU1, 0x00002220}, 799: {A6XX_RBBM_CLOCK_CNTL_CCU2, 0x00002220}, 800: {A6XX_RBBM_CLOCK_CNTL_CCU3, 0x00002220}, 801: {A6XX_RBBM_CLOCK_HYST_RB_CCU0, 0x00040F00}, 802: {A6XX_RBBM_CLOCK_HYST_RB_CCU1, 0x00040F00}, 803: {A6XX_RBBM_CLOCK_HYST_RB_CCU2, 0x00040F00}, 804: {A6XX_RBBM_CLOCK_HYST_RB_CCU3, 0x00040F00}, 805: {A6XX_RBBM_CLOCK_CNTL_RAC, 0x05022022}, 806: {A6XX_RBBM_CLOCK_CNTL2_RAC, 0x00005555}, 807: {A6XX_RBBM_CLOCK_DELAY_RAC, 0x00000011}, 808: {A6XX_RBBM_CLOCK_HYST_RAC, 0x00445044}, 809: {A6XX_RBBM_CLOCK_CNTL_TSE_RAS_RBBM, 0x04222222}, 810: {A6XX_RBBM_CLOCK_MODE_GPC, 0x00222222}, 811: {A6XX_RBBM_CLOCK_MODE_VFD, 0x00002222}, 812: {A6XX_RBBM_CLOCK_HYST_TSE_RAS_RBBM, 0x00000000}, 813: {A6XX_RBBM_CLOCK_HYST_GPC, 0x04104004}, 814: {A6XX_RBBM_CLOCK_HYST_VFD, 0x00000000}, 815: {A6XX_RBBM_CLOCK_DELAY_HLSQ, 0x00000000}, 816: {A6XX_RBBM_CLOCK_DELAY_TSE_RAS_RBBM, 0x00004000}, 817: {A6XX_RBBM_CLOCK_DELAY_GPC, 0x00000200}, 818: {A6XX_RBBM_CLOCK_DELAY_VFD, 0x00002222}, 819: {A6XX_RBBM_CLOCK_DELAY_HLSQ_2, 0x00000002}, 820: {A6XX_RBBM_CLOCK_MODE_HLSQ, 0x00002222}, 821: {A6XX_RBBM_CLOCK_CNTL_GMU_GX, 0x00000222}, 822: {A6XX_RBBM_CLOCK_DELAY_GMU_GX, 0x00000111}, 823: {A6XX_RBBM_CLOCK_HYST_GMU_GX, 0x00000555} 824: }; 825: 826: /* For a615, a616, a618 and a619 */ 827: static const struct kgsl_regmap_list a615_gbif_regs[] = { 828: {A6XX_RBBM_VBIF_CLIENT_QOS_CNTL, 0x3}, 829: }; 830: 831: static const struct adreno_a6xx_core adreno_gpu_core_a615 = { 832: .base = { 833: DEFINE_ADRENO_REV(ADRENO_REV_A615, 6, 1, 5, ANY_ID), 834: .features = ADRENO_PREEMPTION | 835: ADRENO_CONTENT_PROTECTION | ADRENO_IFPC | 836: ADRENO_IOCOHERENT, 837: .gpudev = &adreno_a630_gpudev.base, 838: .perfcounters = &adreno_a6xx_legacy_perfcounters, 839: .uche_gmem_alignment = SZ_1M, 840: .gmem_size = SZ_512K, 841: .bus_width = 32, 842: .snapshot_size = SZ_1M, 843: .highest_bank_bit = 14, 844: }, 845: .prim_fifo_threshold = 0x0018000, 846: .gmu_major = 1, 847: .gmu_minor = 3, 848: .sqefw_name = "a630_sqe.fw", 849: .gmufw_name = "a630_gmu.bin", 850: .zap_name = "a615_zap.mdt", 851: .hwcg = a615_hwcg_regs, 852: .hwcg_count = ARRAY_SIZE(a615_hwcg_regs), 853: .vbif = a615_gbif_regs, 854: .vbif_count = ARRAY_SIZE(a615_gbif_regs), 855: .hang_detect_cycles = 0xcfffff, 856: .protected_regs = a630_protected_regs, 857: }; 858: 859: static const struct adreno_a6xx_core adreno_gpu_core_a618 = { 860: .base = { 861: DEFINE_ADRENO_REV(ADRENO_REV_A618, 6, 1, 8, ANY_ID), 862: .features = ADRENO_PREEMPTION | 863: ADRENO_CONTENT_PROTECTION | ADRENO_IFPC | 864: ADRENO_IOCOHERENT, 865: .gpudev = &adreno_a630_gpudev.base, 866: .perfcounters = &adreno_a6xx_legacy_perfcounters, 867: .uche_gmem_alignment = SZ_1M, 868: .gmem_size = SZ_512K, 869: .bus_width = 32, 870: .snapshot_size = SZ_1M, 871: .highest_bank_bit = 14, 872: }, 873: .prim_fifo_threshold = 0x0018000, 874: .gmu_major = 1, 875: .gmu_minor = 7, 876: .sqefw_name = "a630_sqe.fw", 877: .gmufw_name = "a630_gmu.bin", 878: .zap_name = "a615_zap.mdt", 879: .hwcg = a615_hwcg_regs, 880: .hwcg_count = ARRAY_SIZE(a615_hwcg_regs), 881: .vbif = a615_gbif_regs, 882: .vbif_count = ARRAY_SIZE(a615_gbif_regs), 883: .hang_detect_cycles = 0x3fffff, 884: .protected_regs = a630_protected_regs, 885: }; 886: 887: static const struct adreno_a6xx_core adreno_gpu_core_a619 = { 888: .base = { 889: DEFINE_ADRENO_REV(ADRENO_REV_A619, 6, 1, 9, ANY_ID), 890: .features = ADRENO_PREEMPTION | 891: ADRENO_CONTENT_PROTECTION | ADRENO_IFPC | 892: ADRENO_IOCOHERENT, 893: .gpudev = &adreno_a630_gpudev.base, 894: .perfcounters = &adreno_a6xx_legacy_perfcounters, 895: .uche_gmem_alignment = SZ_1M, 896: .gmem_size = SZ_512K, 897: .bus_width = 32, 898: .snapshot_size = SZ_2M, 899: .highest_bank_bit = 14, 900: }, 901: .prim_fifo_threshold = 0x0018000, 902: .gmu_major = 1, 903: .gmu_minor = 9, 904: .sqefw_name = "a630_sqe.fw", 905: .gmufw_name = "a619_gmu.bin", 906: .zap_name = "a615_zap.mdt", 907: .hwcg = a615_hwcg_regs, 908: .hwcg_count = ARRAY_SIZE(a615_hwcg_regs), 909: .vbif = a615_gbif_regs, 910: .vbif_count = ARRAY_SIZE(a615_gbif_regs), 911: .hang_detect_cycles = 0x3fffff, 912: .protected_regs = a630_protected_regs, 913: }; 914: 915: static const struct adreno_a6xx_core adreno_gpu_core_a619_variant = { 916: .base = { 917: DEFINE_ADRENO_REV(ADRENO_REV_A619, 6, 1, 9, ANY_ID), 918: .compatible = "qcom,adreno-gpu-a619-holi", 919: .features = ADRENO_PREEMPTION | ADRENO_CONTENT_PROTECTION, 920: .gpudev = &adreno_a619_holi_gpudev, 921: .perfcounters = &adreno_a6xx_legacy_perfcounters, 922: .uche_gmem_alignment = SZ_1M, 923: .gmem_size = SZ_512K, 924: .bus_width = 32, 925: .snapshot_size = SZ_2M, 926: .highest_bank_bit = 14, 927: }, 928: .prim_fifo_threshold = 0x0018000, 929: .sqefw_name = "a630_sqe.fw", 930: .zap_name = "gen6_3_25_0_zap.mdt", 931: .hwcg = a615_hwcg_regs, 932: .hwcg_count = ARRAY_SIZE(a615_hwcg_regs), 933: .vbif = a615_gbif_regs, 934: .vbif_count = ARRAY_SIZE(a615_gbif_regs), 935: .hang_detect_cycles = 0x3fffff, 936: .protected_regs = a630_protected_regs, 937: .gx_cpr_toggle = true, 938: }; 939: 940: static const struct kgsl_regmap_list a620_hwcg_regs[] = { 941: {A6XX_RBBM_CLOCK_CNTL_SP0, 0x02222222}, 942: {A6XX_RBBM_CLOCK_CNTL2_SP0, 0x02222220}, 943: {A6XX_RBBM_CLOCK_DELAY_SP0, 0x00000080}, 944: {A6XX_RBBM_CLOCK_HYST_SP0, 0x0000F3CF}, 945: {A6XX_RBBM_CLOCK_CNTL_TP0, 0x02222222}, 946: {A6XX_RBBM_CLOCK_CNTL2_TP0, 0x22222222}, 947: {A6XX_RBBM_CLOCK_CNTL3_TP0, 0x22222222}, 948: {A6XX_RBBM_CLOCK_CNTL4_TP0, 0x00022222}, 949: {A6XX_RBBM_CLOCK_DELAY_TP0, 0x11111111}, 950: {A6XX_RBBM_CLOCK_DELAY2_TP0, 0x11111111}, 951: {A6XX_RBBM_CLOCK_DELAY3_TP0, 0x11111111}, 952: {A6XX_RBBM_CLOCK_DELAY4_TP0, 0x00011111}, 953: {A6XX_RBBM_CLOCK_HYST_TP0, 0x77777777}, 954: {A6XX_RBBM_CLOCK_HYST2_TP0, 0x77777777}, 955: {A6XX_RBBM_CLOCK_HYST3_TP0, 0x77777777}, 956: {A6XX_RBBM_CLOCK_HYST4_TP0, 0x00077777}, 957: {A6XX_RBBM_CLOCK_CNTL_RB0, 0x22222222}, 958: {A6XX_RBBM_CLOCK_CNTL2_RB0, 0x01002222}, 959: {A6XX_RBBM_CLOCK_CNTL_CCU0, 0x00002220}, 960: {A6XX_RBBM_CLOCK_HYST_RB_CCU0, 0x00040F00}, 961: {A6XX_RBBM_CLOCK_CNTL_RAC, 0x25222022}, 962: {A6XX_RBBM_CLOCK_CNTL2_RAC, 0x00005555}, 963: {A6XX_RBBM_CLOCK_DELAY_RAC, 0x00000011}, 964: {A6XX_RBBM_CLOCK_HYST_RAC, 0x00445044}, 965: {A6XX_RBBM_CLOCK_CNTL_TSE_RAS_RBBM, 0x04222222}, 966: {A6XX_RBBM_CLOCK_MODE_VFD, 0x00002222}, 967: {A6XX_RBBM_CLOCK_MODE_GPC, 0x00222222}, 968: {A6XX_RBBM_CLOCK_DELAY_HLSQ_2, 0x00000002}, 969: {A6XX_RBBM_CLOCK_MODE_HLSQ, 0x00002222}, 970: {A6XX_RBBM_CLOCK_DELAY_TSE_RAS_RBBM, 0x00004000}, 971: {A6XX_RBBM_CLOCK_DELAY_VFD, 0x00002222}, 972: {A6XX_RBBM_CLOCK_DELAY_GPC, 0x00000200}, 973: {A6XX_RBBM_CLOCK_DELAY_HLSQ, 0x00000000}, 974: {A6XX_RBBM_CLOCK_HYST_TSE_RAS_RBBM, 0x00000000}, 975: {A6XX_RBBM_CLOCK_HYST_VFD, 0x00000000}, 976: {A6XX_RBBM_CLOCK_HYST_GPC, 0x04104004}, 977: {A6XX_RBBM_CLOCK_HYST_HLSQ, 0x00000000}, 978: {A6XX_RBBM_CLOCK_CNTL_TEX_FCHE, 0x00000222}, 979: {A6XX_RBBM_CLOCK_DELAY_TEX_FCHE, 0x00000111}, 980: {A6XX_RBBM_CLOCK_HYST_TEX_FCHE, 0x00000777}, 981: {A6XX_RBBM_CLOCK_CNTL_UCHE, 0x22222222}, 982: {A6XX_RBBM_CLOCK_HYST_UCHE, 0x00000004}, 983: {A6XX_RBBM_CLOCK_DELAY_UCHE, 0x00000002}, 984: {A6XX_RBBM_ISDB_CNT, 0x00000182}, 985: {A6XX_RBBM_RAC_THRESHOLD_CNT, 0x00000000}, 986: {A6XX_RBBM_SP_HYST_CNT, 0x00000000}, 987: {A6XX_RBBM_CLOCK_CNTL_GMU_GX, 0x00000222}, 988: {A6XX_RBBM_CLOCK_DELAY_GMU_GX, 0x00000111}, 989: {A6XX_RBBM_CLOCK_HYST_GMU_GX, 0x00000555}, 990: }; 991: 992: /* a620, a621, a622 and a650 */ 993: static const struct kgsl_regmap_list a650_gbif_regs[] = { 994: {A6XX_GBIF_QSB_SIDE0, 0x00071620}, 995: {A6XX_GBIF_QSB_SIDE1, 0x00071620}, 996: {A6XX_GBIF_QSB_SIDE2, 0x00071620}, 997: {A6XX_GBIF_QSB_SIDE3, 0x00071620}, 998: {A6XX_RBBM_GBIF_CLIENT_QOS_CNTL, 0x3}, 999: }; 1000: 1001: /* These are for a620, a621, a622 and a650 */ 1002: static const struct adreno_protected_regs a620_protected_regs[] = { 1003: { A6XX_CP_PROTECT_REG + 0, 0x00000, 0x004ff, 0 }, 1004: { A6XX_CP_PROTECT_REG + 1, 0x00501, 0x00506, 0 }, 1005: { A6XX_CP_PROTECT_REG + 2, 0x0050b, 0x007ff, 0 }, 1006: { A6XX_CP_PROTECT_REG + 3, 0x0050e, 0x0050e, 1 }, 1007: { A6XX_CP_PROTECT_REG + 4, 0x00510, 0x00510, 1 }, 1008: { A6XX_CP_PROTECT_REG + 5, 0x00534, 0x00534, 1 }, 1009: { A6XX_CP_PROTECT_REG + 6, 0x00800, 0x00882, 1 }, 1010: { A6XX_CP_PROTECT_REG + 7, 0x008a0, 0x008a8, 1 }, 1011: { A6XX_CP_PROTECT_REG + 8, 0x008ab, 0x008cf, 1 }, 1012: { A6XX_CP_PROTECT_REG + 9, 0x008d0, 0x0098c, 0 }, 1013: { A6XX_CP_PROTECT_REG + 10, 0x00900, 0x0094d, 1 }, 1014: { A6XX_CP_PROTECT_REG + 11, 0x0098d, 0x00bff, 1 }, 1015: { A6XX_CP_PROTECT_REG + 12, 0x00e00, 0x00e01, 1 }, 1016: { A6XX_CP_PROTECT_REG + 13, 0x00e03, 0x00e0f, 1 }, 1017: { A6XX_CP_PROTECT_REG + 14, 0x03c00, 0x03cc3, 1 }, 1018: { A6XX_CP_PROTECT_REG + 15, 0x03cc4, 0x05cc3, 0 }, 1019: { A6XX_CP_PROTECT_REG + 16, 0x08630, 0x087ff, 1 }, 1020: { A6XX_CP_PROTECT_REG + 17, 0x08e00, 0x08e00, 1 }, 1021: { A6XX_CP_PROTECT_REG + 18, 0x08e08, 0x08e08, 1 }, 1022: { A6XX_CP_PROTECT_REG + 19, 0x08e50, 0x08e6f, 1 }, 1023: { A6XX_CP_PROTECT_REG + 20, 0x08e80, 0x090ff, 1 }, 1024: { A6XX_CP_PROTECT_REG + 21, 0x09624, 0x097ff, 1 }, 1025: { A6XX_CP_PROTECT_REG + 22, 0x09e60, 0x09e71, 1 }, 1026: { A6XX_CP_PROTECT_REG + 23, 0x09e78, 0x09fff, 1 }, 1027: { A6XX_CP_PROTECT_REG + 24, 0x0a630, 0x0a7ff, 1 }, 1028: { A6XX_CP_PROTECT_REG + 25, 0x0ae02, 0x0ae02, 1 }, 1029: { A6XX_CP_PROTECT_REG + 26, 0x0ae50, 0x0b17f, 1 }, 1030: { A6XX_CP_PROTECT_REG + 27, 0x0b604, 0x0b604, 1 }, 1031: { A6XX_CP_PROTECT_REG + 28, 0x0b608, 0x0b60f, 1 }, 1032: { A6XX_CP_PROTECT_REG + 29, 0x0be02, 0x0be03, 1 }, 1033: { A6XX_CP_PROTECT_REG + 30, 0x0be20, 0x0d5ff, 1 }, 1034: { A6XX_CP_PROTECT_REG + 31, 0x0f000, 0x0fbff, 1 }, 1035: { A6XX_CP_PROTECT_REG + 32, 0x0fc00, 0x11bff, 0 }, 1036: { A6XX_CP_PROTECT_REG + 33, 0x18400, 0x1a3ff, 1 }, 1037: { A6XX_CP_PROTECT_REG + 34, 0x1a800, 0x1c7ff, 1 }, 1038: { A6XX_CP_PROTECT_REG + 35, 0x1c800, 0x1e7ff, 1 }, 1039: { A6XX_CP_PROTECT_REG + 36, 0x1f400, 0x1f843, 1 }, 1040: { A6XX_CP_PROTECT_REG + 37, 0x1f844, 0x1f8bf, 0 }, 1041: { A6XX_CP_PROTECT_REG + 38, 0x1f887, 0x1f8a2, 1 }, 1042: { A6XX_CP_PROTECT_REG + 47, 0x1f8c0, 0x1f8c0, 1 }, 1043: { 0 }, 1044: }; 1045: 1046: static const struct adreno_a6xx_core adreno_gpu_core_a620 = { 1047: .base = { 1048: DEFINE_ADRENO_REV(ADRENO_REV_A620, 6, 2, 0, ANY_ID), 1049: .features = ADRENO_CONTENT_PROTECTION | ADRENO_IOCOHERENT | 1050: ADRENO_IFPC | ADRENO_PREEMPTION | ADRENO_ACD | 1051: ADRENO_APRIV, 1052: .gpudev = &adreno_a630_gpudev.base, 1053: .perfcounters = &adreno_a6xx_perfcounters, 1054: .uche_gmem_alignment = 0, 1055: .gmem_size = SZ_512K, 1056: .bus_width = 32, 1057: .snapshot_size = 2 * SZ_1M, 1058: .highest_bank_bit = 14, 1059: }, 1060: .prim_fifo_threshold = 0x0010000, 1061: .gmu_major = 2, 1062: .gmu_minor = 0, 1063: .sqefw_name = "a650_sqe.fw", 1064: .gmufw_name = "a650_gmu.bin", 1065: .zap_name = "a620_zap.mdt", 1066: .hwcg = a620_hwcg_regs, 1067: .hwcg_count = ARRAY_SIZE(a620_hwcg_regs), 1068: .vbif = a650_gbif_regs, 1069: .vbif_count = ARRAY_SIZE(a650_gbif_regs), 1070: .veto_fal10 = true, 1071: .hang_detect_cycles = 0x3ffff, 1072: .protected_regs = a620_protected_regs, 1073: .disable_tseskip = true, 1074: }; 1075: 1076: static const struct adreno_a6xx_core adreno_gpu_core_a621 = { 1077: .base = { 1078: DEFINE_ADRENO_REV(ADRENO_REV_A621, 6, 2, 1, ANY_ID), 1079: .compatible = "qcom,adreno-gpu-a621", 1080: .features = ADRENO_CONTENT_PROTECTION | ADRENO_IOCOHERENT | 1081: ADRENO_APRIV | ADRENO_LSR | ADRENO_PREEMPTION | 1082: ADRENO_IFPC | ADRENO_ACD | ADRENO_BCL, 1083: .gpudev = &adreno_a6xx_hwsched_gpudev.base, 1084: .perfcounters = &adreno_a6xx_perfcounters, 1085: .uche_gmem_alignment = 0, 1086: .gmem_size = SZ_512K, 1087: .bus_width = 32, 1088: .snapshot_size = 2 * SZ_1M, 1089: .highest_bank_bit = 13, 1090: }, 1091: .prim_fifo_threshold = 0x0010000, 1092: .gmu_major = 2, 1093: .gmu_minor = 0, 1094: .sqefw_name = "a650_sqe.fw", 1095: .gmufw_name = "a621_gmu.bin", 1096: .zap_name = "a620_zap.mdt", 1097: .hwcg = a620_hwcg_regs, 1098: .hwcg_count = ARRAY_SIZE(a620_hwcg_regs), 1099: .vbif = a650_gbif_regs, 1100: .vbif_count = ARRAY_SIZE(a650_gbif_regs), 1101: .veto_fal10 = true, 1102: .pdc_in_aop = true, 1103: .hang_detect_cycles = 0x3ffff, 1104: .protected_regs = a620_protected_regs, 1105: .disable_tseskip = true, 1106: .gmu_hub_clk_freq = 200000000, 1107: }; 1108: 1109: static const struct adreno_a6xx_core adreno_gpu_core_a622 = { 1110: .base = { 1111: DEFINE_ADRENO_REV(ADRENO_REV_A622, 6, 2, 2, ANY_ID), 1112: .compatible = "qcom,adreno-gpu-a622", 1113: .features = ADRENO_CONTENT_PROTECTION | ADRENO_IOCOHERENT | 1114: ADRENO_APRIV | ADRENO_PREEMPTION | ADRENO_BCL | 1115: ADRENO_IFPC, 1116: .gpudev = &adreno_a6xx_hwsched_gpudev.base, 1117: .perfcounters = &adreno_a6xx_perfcounters, 1118: .uche_gmem_alignment = 0, 1119: .gmem_size = SZ_512K, 1120: .bus_width = 32, 1121: .snapshot_size = 2 * SZ_1M, 1122: .highest_bank_bit = 14, 1123: }, 1124: .prim_fifo_threshold = 0x0010000, 1125: .gmu_major = 2, 1126: .gmu_minor = 0, 1127: .sqefw_name = "a650_sqe.fw", 1128: .gmufw_name = "a622_gmu.bin", 1129: .zap_name = "a622_zap.mdt", 1130: .hwcg = a620_hwcg_regs, 1131: .hwcg_count = ARRAY_SIZE(a620_hwcg_regs), 1132: .vbif = a650_gbif_regs, 1133: .vbif_count = ARRAY_SIZE(a650_gbif_regs), 1134: .veto_fal10 = true, 1135: .pdc_in_aop = true, 1136: .hang_detect_cycles = 0x3ffff, 1137: .protected_regs = a620_protected_regs, 1138: .disable_tseskip = true, 1139: .gmu_hub_clk_freq = 200000000, 1140: }; 1141: 1142: static const struct kgsl_regmap_list a640_hwcg_regs[] = { 1143: {A6XX_RBBM_CLOCK_CNTL_SP0, 0x02222222}, 1144: {A6XX_RBBM_CLOCK_CNTL2_SP0, 0x02222220}, 1145: {A6XX_RBBM_CLOCK_DELAY_SP0, 0x00000080}, 1146: {A6XX_RBBM_CLOCK_HYST_SP0, 0x0000F3CF}, 1147: {A6XX_RBBM_CLOCK_CNTL_TP0, 0x02222222}, 1148: {A6XX_RBBM_CLOCK_CNTL2_TP0, 0x22222222}, 1149: {A6XX_RBBM_CLOCK_CNTL3_TP0, 0x22222222}, 1150: {A6XX_RBBM_CLOCK_CNTL4_TP0, 0x00022222}, 1151: {A6XX_RBBM_CLOCK_DELAY_TP0, 0x11111111}, 1152: {A6XX_RBBM_CLOCK_DELAY2_TP0, 0x11111111}, 1153: {A6XX_RBBM_CLOCK_DELAY3_TP0, 0x11111111}, 1154: {A6XX_RBBM_CLOCK_DELAY4_TP0, 0x00011111}, 1155: {A6XX_RBBM_CLOCK_HYST_TP0, 0x77777777}, 1156: {A6XX_RBBM_CLOCK_HYST2_TP0, 0x77777777}, 1157: {A6XX_RBBM_CLOCK_HYST3_TP0, 0x77777777}, 1158: {A6XX_RBBM_CLOCK_HYST4_TP0, 0x00077777}, 1159: {A6XX_RBBM_CLOCK_CNTL_RB0, 0x22222222}, 1160: {A6XX_RBBM_CLOCK_CNTL2_RB0, 0x01002222}, 1161: {A6XX_RBBM_CLOCK_CNTL_CCU0, 0x00002220}, 1162: {A6XX_RBBM_CLOCK_HYST_RB_CCU0, 0x00040F00}, 1163: {A6XX_RBBM_CLOCK_CNTL_RAC, 0x05222022}, 1164: {A6XX_RBBM_CLOCK_CNTL2_RAC, 0x00005555}, 1165: {A6XX_RBBM_CLOCK_DELAY_RAC, 0x00000011}, 1166: {A6XX_RBBM_CLOCK_HYST_RAC, 0x00445044}, 1167: {A6XX_RBBM_CLOCK_CNTL_TSE_RAS_RBBM, 0x04222222}, 1168: {A6XX_RBBM_CLOCK_MODE_VFD, 0x00002222}, 1169: {A6XX_RBBM_CLOCK_MODE_GPC, 0x00222222}, 1170: {A6XX_RBBM_CLOCK_DELAY_HLSQ_2, 0x00000002}, 1171: {A6XX_RBBM_CLOCK_MODE_HLSQ, 0x00002222}, 1172: {A6XX_RBBM_CLOCK_DELAY_TSE_RAS_RBBM, 0x00004000}, 1173: {A6XX_RBBM_CLOCK_DELAY_VFD, 0x00002222}, 1174: {A6XX_RBBM_CLOCK_DELAY_GPC, 0x00000200}, 1175: {A6XX_RBBM_CLOCK_DELAY_HLSQ, 0x00000000}, 1176: {A6XX_RBBM_CLOCK_HYST_TSE_RAS_RBBM, 0x00000000}, 1177: {A6XX_RBBM_CLOCK_HYST_VFD, 0x00000000}, 1178: {A6XX_RBBM_CLOCK_HYST_GPC, 0x04104004}, 1179: {A6XX_RBBM_CLOCK_HYST_HLSQ, 0x00000000}, 1180: {A6XX_RBBM_CLOCK_CNTL_TEX_FCHE, 0x00000222}, 1181: {A6XX_RBBM_CLOCK_DELAY_TEX_FCHE, 0x00000111}, 1182: {A6XX_RBBM_CLOCK_HYST_TEX_FCHE, 0x00000000}, 1183: {A6XX_RBBM_CLOCK_CNTL_UCHE, 0x22222222}, 1184: {A6XX_RBBM_CLOCK_HYST_UCHE, 0x00000004}, 1185: {A6XX_RBBM_CLOCK_DELAY_UCHE, 0x00000002}, 1186: {A6XX_RBBM_ISDB_CNT, 0x00000182}, 1187: {A6XX_RBBM_RAC_THRESHOLD_CNT, 0x00000000}, 1188: {A6XX_RBBM_SP_HYST_CNT, 0x00000000}, 1189: {A6XX_RBBM_CLOCK_CNTL_GMU_GX, 0x00000222}, 1190: {A6XX_RBBM_CLOCK_DELAY_GMU_GX, 0x00000111}, 1191: {A6XX_RBBM_CLOCK_HYST_GMU_GX, 0x00000555}, 1192: }; 1193: 1194: static const struct kgsl_regmap_list a680_hwcg_regs[] = { 1195: {A6XX_RBBM_CLOCK_CNTL_SP0, 0x02222222}, 1196: {A6XX_RBBM_CLOCK_CNTL2_SP0, 0x02222220}, 1197: {A6XX_RBBM_CLOCK_DELAY_SP0, 0x00000080}, 1198: {A6XX_RBBM_CLOCK_HYST_SP0, 0x0000F3CF}, 1199: {A6XX_RBBM_CLOCK_CNTL_TP0, 0x22222222}, 1200: {A6XX_RBBM_CLOCK_CNTL2_TP0, 0x22222222}, 1201: {A6XX_RBBM_CLOCK_CNTL3_TP0, 0x22222222}, 1202: {A6XX_RBBM_CLOCK_CNTL4_TP0, 0x00022222}, 1203: {A6XX_RBBM_CLOCK_DELAY_TP0, 0x11111111}, 1204: {A6XX_RBBM_CLOCK_DELAY2_TP0, 0x11111111}, 1205: {A6XX_RBBM_CLOCK_DELAY3_TP0, 0x11111111}, 1206: {A6XX_RBBM_CLOCK_DELAY4_TP0, 0x00011111}, 1207: {A6XX_RBBM_CLOCK_HYST_TP0, 0x00000000}, 1208: {A6XX_RBBM_CLOCK_HYST2_TP0, 0x00000000}, 1209: {A6XX_RBBM_CLOCK_HYST3_TP0, 0x00000000}, 1210: {A6XX_RBBM_CLOCK_HYST4_TP0, 0x00000000}, 1211: {A6XX_RBBM_CLOCK_CNTL_RB0, 0x22222222}, 1212: {A6XX_RBBM_CLOCK_CNTL2_RB0, 0x01002222}, 1213: {A6XX_RBBM_CLOCK_CNTL_CCU0, 0x00002220}, 1214: {A6XX_RBBM_CLOCK_HYST_RB_CCU0, 0x00040F00}, 1215: {A6XX_RBBM_CLOCK_CNTL_RAC, 0x05222022}, 1216: {A6XX_RBBM_CLOCK_CNTL2_RAC, 0x00005555}, 1217: {A6XX_RBBM_CLOCK_DELAY_RAC, 0x00000011}, 1218: {A6XX_RBBM_CLOCK_HYST_RAC, 0x00445044}, 1219: {A6XX_RBBM_CLOCK_CNTL_TSE_RAS_RBBM, 0x04222222}, 1220: {A6XX_RBBM_CLOCK_MODE_VFD, 0x00002222}, 1221: {A6XX_RBBM_CLOCK_MODE_GPC, 0x00222222}, 1222: {A6XX_RBBM_CLOCK_DELAY_HLSQ_2, 0x00000002}, 1223: {A6XX_RBBM_CLOCK_MODE_HLSQ, 0x00002222}, 1224: {A6XX_RBBM_CLOCK_DELAY_TSE_RAS_RBBM, 0x00004000}, 1225: {A6XX_RBBM_CLOCK_DELAY_VFD, 0x00002222}, 1226: {A6XX_RBBM_CLOCK_DELAY_GPC, 0x00000200}, 1227: {A6XX_RBBM_CLOCK_DELAY_HLSQ, 0x00000000}, 1228: {A6XX_RBBM_CLOCK_HYST_TSE_RAS_RBBM, 0x00000000}, 1229: {A6XX_RBBM_CLOCK_HYST_VFD, 0x00000000}, 1230: {A6XX_RBBM_CLOCK_HYST_GPC, 0x04104004}, 1231: {A6XX_RBBM_CLOCK_HYST_HLSQ, 0x00000000}, 1232: {A6XX_RBBM_CLOCK_CNTL_UCHE, 0x22222222}, 1233: {A6XX_RBBM_CLOCK_HYST_UCHE, 0x00000004}, 1234: {A6XX_RBBM_CLOCK_DELAY_UCHE, 0x00000002}, 1235: {A6XX_RBBM_CLOCK_CNTL, 0x8AA8AA82}, 1236: {A6XX_RBBM_ISDB_CNT, 0x00000182}, 1237: {A6XX_RBBM_RAC_THRESHOLD_CNT, 0x00000000}, 1238: {A6XX_RBBM_SP_HYST_CNT, 0x00000000}, 1239: {A6XX_RBBM_CLOCK_CNTL_GMU_GX, 0x00000222}, 1240: {A6XX_RBBM_CLOCK_DELAY_GMU_GX, 0x00000111}, 1241: {A6XX_RBBM_CLOCK_HYST_GMU_GX, 0x00000555}, 1242: {A6XX_GMUGX_GMU_SP_RF_CONTROL_0, 0x00000001}, 1243: {A6XX_GMUGX_GMU_SP_RF_CONTROL_1, 0x00000001}, 1244: }; 1245: 1246: /* These apply to a640, a680, a612, a610 and a702 */ 1247: static const struct kgsl_regmap_list a640_vbif_regs[] = { 1248: {A6XX_GBIF_QSB_SIDE0, 0x00071620}, 1249: {A6XX_GBIF_QSB_SIDE1, 0x00071620}, 1250: {A6XX_GBIF_QSB_SIDE2, 0x00071620}, 1251: {A6XX_GBIF_QSB_SIDE3, 0x00071620}, 1252: {A6XX_RBBM_GBIF_CLIENT_QOS_CNTL, 0x3}, 1253: }; 1254: 1255: static const struct adreno_a6xx_core adreno_gpu_core_a640 = { 1256: .base = { 1257: DEFINE_ADRENO_REV(ADRENO_REV_A640, 6, 4, 0, ANY_ID), 1258: .features = ADRENO_CONTENT_PROTECTION | ADRENO_IOCOHERENT | 1259: ADRENO_IFPC | ADRENO_PREEMPTION | ADRENO_L3_VOTE, 1260: .gpudev = &adreno_a6xx_gmu_gpudev.base, 1261: .perfcounters = &adreno_a6xx_legacy_perfcounters, 1262: .uche_gmem_alignment = SZ_1M, 1263: .gmem_size = SZ_1M, //Verified 1MB 1264: .bus_width = 32, 1265: .snapshot_size = 2 * SZ_1M, 1266: .highest_bank_bit = 15, 1267: }, 1268: .prim_fifo_threshold = 0x00200000, 1269: .gmu_major = 2, 1270: .gmu_minor = 0, 1271: .sqefw_name = "a630_sqe.fw", 1272: .gmufw_name = "a640_gmu.bin", 1273: .zap_name = "a640_zap.mdt", 1274: .hwcg = a640_hwcg_regs, 1275: .hwcg_count = ARRAY_SIZE(a640_hwcg_regs), 1276: .vbif = a640_vbif_regs, 1277: .vbif_count = ARRAY_SIZE(a640_vbif_regs), 1278: .hang_detect_cycles = 0xcfffff, 1279: .protected_regs = a630_protected_regs, 1280: .disable_tseskip = true, 1281: }; 1282: 1283: static const struct kgsl_regmap_list a650_hwcg_regs[] = { 1284: {A6XX_RBBM_CLOCK_CNTL_SP0, 0x02222222}, 1285: {A6XX_RBBM_CLOCK_CNTL2_SP0, 0x02222220}, 1286: {A6XX_RBBM_CLOCK_DELAY_SP0, 0x00000080}, 1287: {A6XX_RBBM_CLOCK_HYST_SP0, 0x0000F3CF}, 1288: {A6XX_RBBM_CLOCK_CNTL_TP0, 0x02222222}, 1289: {A6XX_RBBM_CLOCK_CNTL2_TP0, 0x22222222}, 1290: {A6XX_RBBM_CLOCK_CNTL3_TP0, 0x22222222}, 1291: {A6XX_RBBM_CLOCK_CNTL4_TP0, 0x00022222}, 1292: {A6XX_RBBM_CLOCK_DELAY_TP0, 0x11111111}, 1293: {A6XX_RBBM_CLOCK_DELAY2_TP0, 0x11111111}, 1294: {A6XX_RBBM_CLOCK_DELAY3_TP0, 0x11111111}, 1295: {A6XX_RBBM_CLOCK_DELAY4_TP0, 0x00011111}, 1296: {A6XX_RBBM_CLOCK_HYST_TP0, 0x77777777}, 1297: {A6XX_RBBM_CLOCK_HYST2_TP0, 0x77777777}, 1298: {A6XX_RBBM_CLOCK_HYST3_TP0, 0x77777777}, 1299: {A6XX_RBBM_CLOCK_HYST4_TP0, 0x00077777}, 1300: {A6XX_RBBM_CLOCK_CNTL_RB0, 0x22222222}, 1301: {A6XX_RBBM_CLOCK_CNTL2_RB0, 0x01002222}, 1302: {A6XX_RBBM_CLOCK_CNTL_CCU0, 0x00002220}, 1303: {A6XX_RBBM_CLOCK_HYST_RB_CCU0, 0x00040F00}, 1304: {A6XX_RBBM_CLOCK_CNTL_RAC, 0x25222022}, 1305: {A6XX_RBBM_CLOCK_CNTL2_RAC, 0x00005555}, 1306: {A6XX_RBBM_CLOCK_DELAY_RAC, 0x00000011}, 1307: {A6XX_RBBM_CLOCK_HYST_RAC, 0x00445044}, 1308: {A6XX_RBBM_CLOCK_CNTL_TSE_RAS_RBBM, 0x04222222}, 1309: {A6XX_RBBM_CLOCK_MODE_VFD, 0x00002222}, 1310: {A6XX_RBBM_CLOCK_MODE_GPC, 0x00222222}, 1311: {A6XX_RBBM_CLOCK_DELAY_HLSQ_2, 0x00000002}, 1312: {A6XX_RBBM_CLOCK_MODE_HLSQ, 0x00002222}, 1313: {A6XX_RBBM_CLOCK_DELAY_TSE_RAS_RBBM, 0x00004000}, 1314: {A6XX_RBBM_CLOCK_DELAY_VFD, 0x00002222}, 1315: {A6XX_RBBM_CLOCK_DELAY_GPC, 0x00000200}, 1316: {A6XX_RBBM_CLOCK_DELAY_HLSQ, 0x00000000}, 1317: {A6XX_RBBM_CLOCK_HYST_TSE_RAS_RBBM, 0x00000000}, 1318: {A6XX_RBBM_CLOCK_HYST_VFD, 0x00000000}, 1319: {A6XX_RBBM_CLOCK_HYST_GPC, 0x04104004}, 1320: {A6XX_RBBM_CLOCK_HYST_HLSQ, 0x00000000}, 1321: {A6XX_RBBM_CLOCK_CNTL_TEX_FCHE, 0x00000222}, 1322: {A6XX_RBBM_CLOCK_DELAY_TEX_FCHE, 0x00000111}, 1323: {A6XX_RBBM_CLOCK_HYST_TEX_FCHE, 0x00000777}, 1324: {A6XX_RBBM_CLOCK_CNTL_UCHE, 0x22222222}, 1325: {A6XX_RBBM_CLOCK_HYST_UCHE, 0x00000004}, 1326: {A6XX_RBBM_CLOCK_DELAY_UCHE, 0x00000002}, 1327: {A6XX_RBBM_ISDB_CNT, 0x00000182}, 1328: {A6XX_RBBM_RAC_THRESHOLD_CNT, 0x00000000}, 1329: {A6XX_RBBM_SP_HYST_CNT, 0x00000000}, 1330: {A6XX_RBBM_CLOCK_CNTL_GMU_GX, 0x00000222}, 1331: {A6XX_RBBM_CLOCK_DELAY_GMU_GX, 0x00000111}, 1332: {A6XX_RBBM_CLOCK_HYST_GMU_GX, 0x00000555}, 1333: }; 1334: 1335: static const struct adreno_a6xx_core adreno_gpu_core_a650 = { 1336: .base = { 1337: DEFINE_ADRENO_REV(ADRENO_REV_A650, 6, 5, 0, 0), 1338: .features = ADRENO_IOCOHERENT | ADRENO_CONTENT_PROTECTION | 1339: ADRENO_IFPC | ADRENO_APRIV | ADRENO_L3_VOTE, 1340: .gpudev = &adreno_a6xx_gmu_gpudev.base, 1341: .perfcounters = &adreno_a6xx_perfcounters, 1342: .uche_gmem_alignment = 0, 1343: .gmem_size = SZ_1M + SZ_128K, /* verified 1152kB */ 1344: .bus_width = 32, 1345: .snapshot_size = 2 * SZ_1M, 1346: .highest_bank_bit = 16, 1347: }, 1348: .prim_fifo_threshold = 0x00300000, 1349: .gmu_major = 2, 1350: .gmu_minor = 0, 1351: .sqefw_name = "a650_sqe.fw", 1352: .gmufw_name = "a650_gmu.bin", 1353: .zap_name = "a650_zap.mdt", 1354: .hwcg = a650_hwcg_regs, 1355: .hwcg_count = ARRAY_SIZE(a650_hwcg_regs), 1356: .vbif = a650_gbif_regs, 1357: .vbif_count = ARRAY_SIZE(a650_gbif_regs), 1358: .veto_fal10 = true, 1359: .pdc_in_aop = true, 1360: .hang_detect_cycles = 0xcfffff, 1361: .protected_regs = a620_protected_regs, 1362: .disable_tseskip = true, 1363: }; 1364: 1365: static const struct adreno_a6xx_core adreno_gpu_core_a650v2 = { 1366: .base = { 1367: DEFINE_ADRENO_REV(ADRENO_REV_A650, 6, 5, 0, ANY_ID), 1368: .features = ADRENO_IOCOHERENT | ADRENO_CONTENT_PROTECTION | 1369: ADRENO_IFPC | ADRENO_PREEMPTION | ADRENO_ACD | 1370: ADRENO_LM | ADRENO_APRIV | ADRENO_L3_VOTE, 1371: .gpudev = &adreno_a6xx_gmu_gpudev.base, 1372: .perfcounters = &adreno_a6xx_perfcounters, 1373: .uche_gmem_alignment = 0, 1374: .gmem_size = SZ_1M + SZ_128K, /* verified 1152kB */ 1375: .bus_width = 32, 1376: .snapshot_size = 2 * SZ_1M, 1377: .highest_bank_bit = 16, 1378: }, 1379: .prim_fifo_threshold = 0x00300000, 1380: .gmu_major = 2, 1381: .gmu_minor = 0, 1382: .sqefw_name = "a650_sqe.fw", 1383: .gmufw_name = "a650_gmu.bin", 1384: .zap_name = "a650_zap.mdt", 1385: .hwcg = a650_hwcg_regs, 1386: .hwcg_count = ARRAY_SIZE(a650_hwcg_regs), 1387: .vbif = a650_gbif_regs, 1388: .vbif_count = ARRAY_SIZE(a650_gbif_regs), 1389: .veto_fal10 = true, 1390: .pdc_in_aop = true, 1391: .hang_detect_cycles = 0x3ffff, 1392: .protected_regs = a620_protected_regs, 1393: .disable_tseskip = true, 1394: }; 1395: 1396: static const struct adreno_a6xx_core adreno_gpu_core_a680 = { 1397: .base = { 1398: DEFINE_ADRENO_REV(ADRENO_REV_A680, 6, 8, 0, ANY_ID), 1399: .features = ADRENO_IOCOHERENT | ADRENO_CONTENT_PROTECTION | 1400: ADRENO_IFPC | ADRENO_PREEMPTION, 1401: .gpudev = &adreno_a6xx_gmu_gpudev.base, 1402: .perfcounters = &adreno_a6xx_legacy_perfcounters, 1403: .uche_gmem_alignment = SZ_1M, 1404: .gmem_size = SZ_2M, 1405: .bus_width = 32, 1406: .snapshot_size = SZ_2M, 1407: .highest_bank_bit = 16, 1408: }, 1409: .prim_fifo_threshold = 0x00400000, 1410: .gmu_major = 2, 1411: .gmu_minor = 0, 1412: .sqefw_name = "a630_sqe.fw", 1413: .gmufw_name = "a640_gmu.bin", 1414: .zap_name = "a640_zap.mdt", 1415: .hwcg = a680_hwcg_regs, 1416: .hwcg_count = ARRAY_SIZE(a680_hwcg_regs), 1417: .vbif = a640_vbif_regs, 1418: .vbif_count = ARRAY_SIZE(a640_vbif_regs), 1419: .hang_detect_cycles = 0xcfffff, 1420: .protected_regs = a630_protected_regs, 1421: .disable_tseskip = true, 1422: }; 1423: 1424: static const struct kgsl_regmap_list a612_hwcg_regs[] = { 1425: {A6XX_RBBM_CLOCK_CNTL_SP0, 0x22222222}, 1426: {A6XX_RBBM_CLOCK_CNTL2_SP0, 0x02222220}, 1427: {A6XX_RBBM_CLOCK_DELAY_SP0, 0x00000081}, 1428: {A6XX_RBBM_CLOCK_HYST_SP0, 0x0000F3CF}, 1429: {A6XX_RBBM_CLOCK_CNTL_TP0, 0x22222222}, 1430: {A6XX_RBBM_CLOCK_CNTL2_TP0, 0x22222222}, 1431: {A6XX_RBBM_CLOCK_CNTL3_TP0, 0x22222222}, 1432: {A6XX_RBBM_CLOCK_CNTL4_TP0, 0x00022222}, 1433: {A6XX_RBBM_CLOCK_DELAY_TP0, 0x11111111}, 1434: {A6XX_RBBM_CLOCK_DELAY2_TP0, 0x11111111}, 1435: {A6XX_RBBM_CLOCK_DELAY3_TP0, 0x11111111}, 1436: {A6XX_RBBM_CLOCK_DELAY4_TP0, 0x00011111}, 1437: {A6XX_RBBM_CLOCK_HYST_TP0, 0x77777777}, 1438: {A6XX_RBBM_CLOCK_HYST2_TP0, 0x77777777}, 1439: {A6XX_RBBM_CLOCK_HYST3_TP0, 0x77777777}, 1440: {A6XX_RBBM_CLOCK_HYST4_TP0, 0x00077777}, 1441: {A6XX_RBBM_CLOCK_CNTL_RB0, 0x22222222}, 1442: {A6XX_RBBM_CLOCK_CNTL2_RB0, 0x01202222}, 1443: {A6XX_RBBM_CLOCK_CNTL_CCU0, 0x00002220}, 1444: {A6XX_RBBM_CLOCK_HYST_RB_CCU0, 0x00040F00}, 1445: {A6XX_RBBM_CLOCK_CNTL_RAC, 0x05522022}, 1446: {A6XX_RBBM_CLOCK_CNTL2_RAC, 0x00005555}, 1447: {A6XX_RBBM_CLOCK_DELAY_RAC, 0x00000011}, 1448: {A6XX_RBBM_CLOCK_HYST_RAC, 0x00445044}, 1449: {A6XX_RBBM_CLOCK_CNTL_TSE_RAS_RBBM, 0x04222222}, 1450: {A6XX_RBBM_CLOCK_MODE_VFD, 0x00002222}, 1451: {A6XX_RBBM_CLOCK_MODE_GPC, 0x02222222}, 1452: {A6XX_RBBM_CLOCK_DELAY_HLSQ_2, 0x00000002}, 1453: {A6XX_RBBM_CLOCK_MODE_HLSQ, 0x00002222}, 1454: {A6XX_RBBM_CLOCK_DELAY_TSE_RAS_RBBM, 0x00004000}, 1455: {A6XX_RBBM_CLOCK_DELAY_VFD, 0x00002222}, 1456: {A6XX_RBBM_CLOCK_DELAY_GPC, 0x00000200}, 1457: {A6XX_RBBM_CLOCK_DELAY_HLSQ, 0x00000000}, 1458: {A6XX_RBBM_CLOCK_HYST_TSE_RAS_RBBM, 0x00000000}, 1459: {A6XX_RBBM_CLOCK_HYST_VFD, 0x00000000}, 1460: {A6XX_RBBM_CLOCK_HYST_GPC, 0x04104004}, 1461: {A6XX_RBBM_CLOCK_HYST_HLSQ, 0x00000000}, 1462: {A6XX_RBBM_CLOCK_CNTL_UCHE, 0x22222222}, 1463: {A6XX_RBBM_CLOCK_HYST_UCHE, 0x00000004}, 1464: {A6XX_RBBM_CLOCK_DELAY_UCHE, 0x00000002}, 1465: {A6XX_RBBM_ISDB_CNT, 0x00000182}, 1466: {A6XX_RBBM_RAC_THRESHOLD_CNT, 0x00000000}, 1467: {A6XX_RBBM_SP_HYST_CNT, 0x00000000}, 1468: {A6XX_RBBM_CLOCK_CNTL_GMU_GX, 0x00000222}, 1469: {A6XX_RBBM_CLOCK_DELAY_GMU_GX, 0x00000111}, 1470: {A6XX_RBBM_CLOCK_HYST_GMU_GX, 0x00000555}, 1471: }; 1472: 1473: static const struct adreno_a6xx_core adreno_gpu_core_a612 = { 1474: .base = { 1475: DEFINE_ADRENO_REV(ADRENO_REV_A612, 6, 1, 2, ANY_ID), 1476: .features = ADRENO_CONTENT_PROTECTION | 1477: ADRENO_IOCOHERENT | ADRENO_PREEMPTION | ADRENO_IFPC, 1478: .gpudev = &adreno_a6xx_rgmu_gpudev, 1479: .perfcounters = &adreno_a6xx_legacy_perfcounters, 1480: .uche_gmem_alignment = SZ_1M, 1481: .gmem_size = (SZ_128K + SZ_4K), 1482: .bus_width = 32, 1483: .snapshot_size = SZ_1M, 1484: .chipid = 0x06010200, 1485: .ubwc_mode = 2, 1486: .mal = 32, 1487: .highest_bank_bit = 14, 1488: }, 1489: .prim_fifo_threshold = 0x00080000, 1490: .sqefw_name = "a630_sqe.fw", 1491: .gmufw_name = "a612_rgmu.bin", 1492: .zap_name = "a612_zap.mbn", 1493: .hwcg = a612_hwcg_regs, 1494: .hwcg_count = ARRAY_SIZE(a612_hwcg_regs), 1495: .vbif = a640_vbif_regs, 1496: .vbif_count = ARRAY_SIZE(a640_vbif_regs), 1497: .hang_detect_cycles = 0x3fffff, 1498: .protected_regs = a630_protected_regs, 1499: }; 1500: 1501: static const struct adreno_a6xx_core adreno_gpu_core_a616 = { 1502: .base = { 1503: DEFINE_ADRENO_REV(ADRENO_REV_A616, 6, 1, 6, ANY_ID), 1504: .features = ADRENO_PREEMPTION | 1505: ADRENO_CONTENT_PROTECTION | ADRENO_IFPC | 1506: ADRENO_IOCOHERENT, 1507: .gpudev = &adreno_a630_gpudev.base, 1508: .perfcounters = &adreno_a6xx_legacy_perfcounters, 1509: .uche_gmem_alignment = SZ_1M, 1510: .gmem_size = SZ_512K, 1511: .bus_width = 32, 1512: .snapshot_size = SZ_1M, 1513: .highest_bank_bit = 14, 1514: }, 1515: .prim_fifo_threshold = 0x0018000, 1516: .gmu_major = 1, 1517: .gmu_minor = 3, 1518: .sqefw_name = "a630_sqe.fw", 1519: .gmufw_name = "a630_gmu.bin", 1520: .zap_name = "a615_zap.mdt", 1521: .hwcg = a615_hwcg_regs, 1522: .hwcg_count = ARRAY_SIZE(a615_hwcg_regs), 1523: .vbif = a615_gbif_regs, 1524: .vbif_count = ARRAY_SIZE(a615_gbif_regs), 1525: .hang_detect_cycles = 0xcfffff, 1526: .protected_regs = a630_protected_regs, 1527: }; 1528: 1529: static const struct adreno_a6xx_core adreno_gpu_core_a610 = { 1530: .base = { 1531: DEFINE_ADRENO_REV(ADRENO_REV_A610, 6, 1, 0, ANY_ID), 1532: .features = ADRENO_CONTENT_PROTECTION | 1533: ADRENO_PREEMPTION, 1534: .gpudev = &adreno_a6xx_gpudev, 1535: .perfcounters = &adreno_a6xx_legacy_perfcounters, 1536: .uche_gmem_alignment = SZ_1M, 1537: .gmem_size = (SZ_128K + SZ_4K), 1538: .bus_width = 32, 1539: .snapshot_size = SZ_1M, 1540: .highest_bank_bit = 14, 1541: }, 1542: .prim_fifo_threshold = 0x00080000, 1543: .sqefw_name = "a630_sqe.fw", 1544: .zap_name = "a610_zap.mdt", 1545: .hwcg = a612_hwcg_regs, 1546: .hwcg_count = ARRAY_SIZE(a612_hwcg_regs), 1547: .vbif = a640_vbif_regs, 1548: .vbif_count = ARRAY_SIZE(a640_vbif_regs), 1549: .hang_detect_cycles = 0x3ffff, 1550: .protected_regs = a630_protected_regs, 1551: }; 1552: 1553: static const struct adreno_a6xx_core adreno_gpu_core_a611 = { 1554: .base = { 1555: DEFINE_ADRENO_REV(ADRENO_REV_A611, 6, 1, 1, ANY_ID), 1556: .compatible = "qcom,adreno-gpu-a611", 1557: .features = ADRENO_CONTENT_PROTECTION | 1558: ADRENO_PREEMPTION, 1559: .gpudev = &adreno_a6xx_gpudev, 1560: .perfcounters = &adreno_a6xx_legacy_perfcounters, 1561: .uche_gmem_alignment = SZ_1M, 1562: .gmem_size = (SZ_128K + SZ_4K), 1563: .bus_width = 32, 1564: .snapshot_size = SZ_1M, 1565: .highest_bank_bit = 14, 1566: }, 1567: .prim_fifo_threshold = 0x00080000, 1568: .sqefw_name = "a630_sqe.fw", 1569: .zap_name = "a610_zap.mbn", 1570: .hwcg = a612_hwcg_regs, 1571: .hwcg_count = ARRAY_SIZE(a612_hwcg_regs), 1572: .vbif = a640_vbif_regs, 1573: .vbif_count = ARRAY_SIZE(a640_vbif_regs), 1574: .hang_detect_cycles = 0x3ffff, 1575: .protected_regs = a630_protected_regs, 1576: }; 1577: 1578: static const struct kgsl_regmap_list a660_hwcg_regs[] = { 1579: {A6XX_RBBM_CLOCK_CNTL_SP0, 0x02222222}, 1580: {A6XX_RBBM_CLOCK_CNTL2_SP0, 0x02222220}, 1581: {A6XX_RBBM_CLOCK_DELAY_SP0, 0x00000080}, 1582: {A6XX_RBBM_CLOCK_HYST_SP0, 0x0000F3CF}, 1583: {A6XX_RBBM_CLOCK_CNTL_TP0, 0x22222222}, 1584: {A6XX_RBBM_CLOCK_CNTL2_TP0, 0x22222222}, 1585: {A6XX_RBBM_CLOCK_CNTL3_TP0, 0x22222222}, 1586: {A6XX_RBBM_CLOCK_CNTL4_TP0, 0x00022222}, 1587: {A6XX_RBBM_CLOCK_DELAY_TP0, 0x11111111}, 1588: {A6XX_RBBM_CLOCK_DELAY2_TP0, 0x11111111}, 1589: {A6XX_RBBM_CLOCK_DELAY3_TP0, 0x11111111}, 1590: {A6XX_RBBM_CLOCK_DELAY4_TP0, 0x00011111}, 1591: {A6XX_RBBM_CLOCK_HYST_TP0, 0x77777777}, 1592: {A6XX_RBBM_CLOCK_HYST2_TP0, 0x77777777}, 1593: {A6XX_RBBM_CLOCK_HYST3_TP0, 0x77777777}, 1594: {A6XX_RBBM_CLOCK_HYST4_TP0, 0x00077777}, 1595: {A6XX_RBBM_CLOCK_CNTL_RB0, 0x22222222}, 1596: {A6XX_RBBM_CLOCK_CNTL2_RB0, 0x01002222}, 1597: {A6XX_RBBM_CLOCK_CNTL_CCU0, 0x00002220}, 1598: {A6XX_RBBM_CLOCK_HYST_RB_CCU0, 0x00040F00}, 1599: {A6XX_RBBM_CLOCK_CNTL_RAC, 0x25222022}, 1600: {A6XX_RBBM_CLOCK_CNTL2_RAC, 0x00005555}, 1601: {A6XX_RBBM_CLOCK_DELAY_RAC, 0x00000011}, 1602: {A6XX_RBBM_CLOCK_HYST_RAC, 0x00445044}, 1603: {A6XX_RBBM_CLOCK_CNTL_TSE_RAS_RBBM, 0x04222222}, 1604: {A6XX_RBBM_CLOCK_MODE_VFD, 0x00002222}, 1605: {A6XX_RBBM_CLOCK_MODE_GPC, 0x00222222}, 1606: {A6XX_RBBM_CLOCK_DELAY_HLSQ_2, 0x00000002}, 1607: {A6XX_RBBM_CLOCK_MODE_HLSQ, 0x00002222}, 1608: {A6XX_RBBM_CLOCK_DELAY_TSE_RAS_RBBM, 0x00004000}, 1609: {A6XX_RBBM_CLOCK_DELAY_VFD, 0x00002222}, 1610: {A6XX_RBBM_CLOCK_DELAY_GPC, 0x00000200}, 1611: {A6XX_RBBM_CLOCK_DELAY_HLSQ, 0x00000000}, 1612: {A6XX_RBBM_CLOCK_HYST_TSE_RAS_RBBM, 0x00000000}, 1613: {A6XX_RBBM_CLOCK_HYST_VFD, 0x00000000}, 1614: {A6XX_RBBM_CLOCK_HYST_GPC, 0x04104004}, 1615: {A6XX_RBBM_CLOCK_HYST_HLSQ, 0x00000000}, 1616: {A6XX_RBBM_CLOCK_CNTL_TEX_FCHE, 0x00000222}, 1617: {A6XX_RBBM_CLOCK_DELAY_TEX_FCHE, 0x00000111}, 1618: {A6XX_RBBM_CLOCK_HYST_TEX_FCHE, 0x00000000}, 1619: {A6XX_RBBM_CLOCK_CNTL_UCHE, 0x22222222}, 1620: {A6XX_RBBM_CLOCK_HYST_UCHE, 0x00000004}, 1621: {A6XX_RBBM_CLOCK_DELAY_UCHE, 0x00000002}, 1622: {A6XX_RBBM_ISDB_CNT, 0x00000182}, 1623: {A6XX_RBBM_RAC_THRESHOLD_CNT, 0x00000000}, 1624: {A6XX_RBBM_SP_HYST_CNT, 0x00000000}, 1625: {A6XX_RBBM_CLOCK_CNTL_GMU_GX, 0x00000222}, 1626: {A6XX_RBBM_CLOCK_DELAY_GMU_GX, 0x00000111}, 1627: {A6XX_RBBM_CLOCK_HYST_GMU_GX, 0x00000555}, 1628: }; 1629: 1630: /* A660 protected register list */ 1631: static const struct adreno_protected_regs a660_protected_regs[] = { 1632: { A6XX_CP_PROTECT_REG + 0, 0x00000, 0x004ff, 0 }, 1633: { A6XX_CP_PROTECT_REG + 1, 0x00501, 0x00506, 0 }, 1634: { A6XX_CP_PROTECT_REG + 2, 0x0050b, 0x007ff, 0 }, 1635: { A6XX_CP_PROTECT_REG + 3, 0x0050e, 0x0050e, 1 }, 1636: { A6XX_CP_PROTECT_REG + 4, 0x00510, 0x00510, 1 }, 1637: { A6XX_CP_PROTECT_REG + 5, 0x00534, 0x00534, 1 }, 1638: { A6XX_CP_PROTECT_REG + 6, 0x00800, 0x00882, 1 }, 1639: { A6XX_CP_PROTECT_REG + 7, 0x008a0, 0x008a8, 1 }, 1640: { A6XX_CP_PROTECT_REG + 8, 0x008ab, 0x008cf, 1 }, 1641: { A6XX_CP_PROTECT_REG + 9, 0x008d0, 0x0098c, 0 }, 1642: { A6XX_CP_PROTECT_REG + 10, 0x00900, 0x0094d, 1 }, 1643: { A6XX_CP_PROTECT_REG + 11, 0x0098d, 0x00bff, 1 }, 1644: { A6XX_CP_PROTECT_REG + 12, 0x00e00, 0x00e01, 1 }, 1645: { A6XX_CP_PROTECT_REG + 13, 0x00e03, 0x00e0f, 1 }, 1646: { A6XX_CP_PROTECT_REG + 14, 0x03c00, 0x03cc3, 1 }, 1647: { A6XX_CP_PROTECT_REG + 15, 0x03cc4, 0x05cc3, 0 }, 1648: { A6XX_CP_PROTECT_REG + 16, 0x08630, 0x087ff, 1 }, 1649: { A6XX_CP_PROTECT_REG + 17, 0x08e00, 0x08e00, 1 }, 1650: { A6XX_CP_PROTECT_REG + 18, 0x08e08, 0x08e08, 1 }, 1651: { A6XX_CP_PROTECT_REG + 19, 0x08e50, 0x08e6f, 1 }, 1652: { A6XX_CP_PROTECT_REG + 20, 0x08e80, 0x090ff, 1 }, 1653: { A6XX_CP_PROTECT_REG + 21, 0x09624, 0x097ff, 1 }, 1654: { A6XX_CP_PROTECT_REG + 22, 0x09e60, 0x09e71, 1 }, 1655: { A6XX_CP_PROTECT_REG + 23, 0x09e78, 0x09fff, 1 }, 1656: { A6XX_CP_PROTECT_REG + 24, 0x0a630, 0x0a7ff, 1 }, 1657: { A6XX_CP_PROTECT_REG + 25, 0x0ae02, 0x0ae02, 1 }, 1658: { A6XX_CP_PROTECT_REG + 26, 0x0ae50, 0x0af7f, 1 }, 1659: { A6XX_CP_PROTECT_REG + 27, 0x0b604, 0x0b604, 1 }, 1660: { A6XX_CP_PROTECT_REG + 28, 0x0b608, 0x0b60e, 1 }, 1661: { A6XX_CP_PROTECT_REG + 29, 0x0be02, 0x0be03, 1 }, 1662: { A6XX_CP_PROTECT_REG + 30, 0x0be20, 0x0bf7f, 1 }, 1663: { A6XX_CP_PROTECT_REG + 31, 0x0d000, 0x0d5ff, 1 }, 1664: { A6XX_CP_PROTECT_REG + 32, 0x0f000, 0x0fbff, 1 }, 1665: { A6XX_CP_PROTECT_REG + 33, 0x0fc00, 0x11bff, 0 }, 1666: { A6XX_CP_PROTECT_REG + 34, 0x18400, 0x1a3ff, 1 }, 1667: { A6XX_CP_PROTECT_REG + 35, 0x1a400, 0x1c3ff, 1 }, 1668: { A6XX_CP_PROTECT_REG + 36, 0x1c400, 0x1e3ff, 1 }, 1669: { A6XX_CP_PROTECT_REG + 37, 0x1f400, 0x1f843, 1 }, 1670: { A6XX_CP_PROTECT_REG + 38, 0x1f844, 0x1f8bf, 0 }, 1671: { A6XX_CP_PROTECT_REG + 39, 0x1f860, 0x1f860, 1 }, 1672: { A6XX_CP_PROTECT_REG + 40, 0x1f887, 0x1f8a2, 1 }, 1673: { A6XX_CP_PROTECT_REG + 47, 0x1f8c0, 0x1f8c0, 1 }, 1674: { 0 }, 1675: }; 1676: 1677: static const struct adreno_a6xx_core adreno_gpu_core_a660 = { 1678: .base = { 1679: DEFINE_ADRENO_REV(ADRENO_REV_A660, 6, 6, 0, 0), 1680: .features = ADRENO_APRIV | 1681: ADRENO_IOCOHERENT | ADRENO_CONTENT_PROTECTION | 1682: ADRENO_IFPC | ADRENO_PREEMPTION | ADRENO_L3_VOTE, 1683: .gpudev = &adreno_a6xx_gmu_gpudev.base, 1684: .perfcounters = &adreno_a6xx_perfcounters, 1685: .uche_gmem_alignment = 0, 1686: .gmem_size = SZ_1M + SZ_512K, 1687: .bus_width = 32, 1688: .snapshot_size = SZ_2M, 1689: .highest_bank_bit = 16, 1690: }, 1691: .prim_fifo_threshold = 0x00300000, 1692: .gmu_major = 2, 1693: .gmu_minor = 0, 1694: .sqefw_name = "a660_sqe.fw", 1695: .gmufw_name = "a660_gmu.bin", 1696: .zap_name = "a660_zap.mdt", 1697: .hwcg = a660_hwcg_regs, 1698: .hwcg_count = ARRAY_SIZE(a660_hwcg_regs), 1699: .vbif = a650_gbif_regs, 1700: .vbif_count = ARRAY_SIZE(a650_gbif_regs), 1701: .hang_detect_cycles = 0xcfffff, 1702: .veto_fal10 = true, 1703: .protected_regs = a660_protected_regs, 1704: .disable_tseskip = true, 1705: .pdc_in_aop = true, 1706: .ctxt_record_size = 2496 * 1024, 1707: }; 1708: 1709: static const struct adreno_a6xx_core adreno_gpu_core_a660v2 = { 1710: .base = { 1711: DEFINE_ADRENO_REV(ADRENO_REV_A660, 6, 6, 0, ANY_ID), 1712: .features = ADRENO_APRIV | 1713: ADRENO_IOCOHERENT | ADRENO_CONTENT_PROTECTION | 1714: ADRENO_IFPC | ADRENO_PREEMPTION | ADRENO_ACD | 1715: ADRENO_L3_VOTE, 1716: .gpudev = &adreno_a6xx_gmu_gpudev.base, 1717: .perfcounters = &adreno_a6xx_perfcounters, 1718: .uche_gmem_alignment = 0, 1719: .gmem_size = SZ_1M + SZ_512K, 1720: .bus_width = 32, 1721: .snapshot_size = SZ_2M, 1722: .highest_bank_bit = 16, 1723: }, 1724: .prim_fifo_threshold = 0x00300000, 1725: .gmu_major = 2, 1726: .gmu_minor = 0, 1727: .sqefw_name = "a660_sqe.fw", 1728: .gmufw_name = "a660_gmu.bin", 1729: .zap_name = "a660_zap.mdt", 1730: .hwcg = a660_hwcg_regs, 1731: .hwcg_count = ARRAY_SIZE(a660_hwcg_regs), 1732: .vbif = a650_gbif_regs, 1733: .vbif_count = ARRAY_SIZE(a650_gbif_regs), 1734: .hang_detect_cycles = 0xcfffff, 1735: .veto_fal10 = true, 1736: .protected_regs = a660_protected_regs, 1737: .disable_tseskip = true, 1738: .pdc_in_aop = true, 1739: .ctxt_record_size = 2496 * 1024, 1740: }; 1741: 1742: static const struct adreno_a6xx_core adreno_gpu_core_a660_shima = { 1743: .base = { 1744: DEFINE_ADRENO_REV(ADRENO_REV_A660, 6, 6, 0, ANY_ID), 1745: .compatible = "qcom,adreno-gpu-a660-shima", 1746: .features = ADRENO_APRIV | 1747: ADRENO_IOCOHERENT | ADRENO_CONTENT_PROTECTION | 1748: ADRENO_IFPC | ADRENO_PREEMPTION | ADRENO_ACD, 1749: .gpudev = &adreno_a6xx_gmu_gpudev.base, 1750: .perfcounters = &adreno_a6xx_perfcounters, 1751: .uche_gmem_alignment = 0, 1752: .gmem_size = SZ_1M + SZ_512K, 1753: .bus_width = 32, 1754: .snapshot_size = SZ_2M, 1755: .highest_bank_bit = 15, 1756: }, 1757: .prim_fifo_threshold = 0x00300000, 1758: .gmu_major = 2, 1759: .gmu_minor = 0, 1760: .sqefw_name = "a660_sqe.fw", 1761: .gmufw_name = "a660_gmu.bin", 1762: .zap_name = "a660_zap.mdt", 1763: .hwcg = a660_hwcg_regs, 1764: .hwcg_count = ARRAY_SIZE(a660_hwcg_regs), 1765: .vbif = a650_gbif_regs, 1766: .vbif_count = ARRAY_SIZE(a650_gbif_regs), 1767: .hang_detect_cycles = 0x3ffff, 1768: .veto_fal10 = true, 1769: .protected_regs = a660_protected_regs, 1770: .disable_tseskip = true, 1771: .pdc_in_aop = true, 1772: .ctxt_record_size = 2496 * 1024, 1773: }; 1774: 1775: static const struct adreno_a6xx_core adreno_gpu_core_a642l = { 1776: .base = { 1777: DEFINE_ADRENO_REV(ADRENO_REV_A642, ANY_ID, ANY_ID, ANY_ID, ANY_ID), 1778: .compatible = "qcom,adreno-gpu-a642l", 1779: .features = ADRENO_APRIV | ADRENO_IOCOHERENT | 1780: ADRENO_CONTENT_PROTECTION, 1781: .gpudev = &adreno_a6xx_gmu_gpudev.base, 1782: .perfcounters = &adreno_a6xx_perfcounters, 1783: .uche_gmem_alignment = 0, 1784: .gmem_size = SZ_512K, 1785: .bus_width = 32, 1786: .snapshot_size = SZ_2M, 1787: .highest_bank_bit = 15, 1788: }, 1789: .prim_fifo_threshold = 0x00200000, 1790: .gmu_major = 2, 1791: .gmu_minor = 0, 1792: .sqefw_name = "a660_sqe.fw", 1793: .gmufw_name = "a660_gmu.bin", 1794: .zap_name = "a660_zap.mdt", 1795: .hwcg = a660_hwcg_regs, 1796: .hwcg_count = ARRAY_SIZE(a660_hwcg_regs), 1797: .vbif = a650_gbif_regs, 1798: .vbif_count = ARRAY_SIZE(a650_gbif_regs), 1799: .hang_detect_cycles = 0x3ffff, 1800: .veto_fal10 = true, 1801: .protected_regs = a660_protected_regs, 1802: .disable_tseskip = true, 1803: .pdc_in_aop = true, 1804: .ctxt_record_size = 2496 * 1024, 1805: }; 1806: 1807: static const struct adreno_a6xx_core adreno_gpu_core_a643 = { 1808: .base = { 1809: DEFINE_ADRENO_REV(ADRENO_REV_A643, ANY_ID, ANY_ID, ANY_ID, ANY_ID), 1810: .compatible = "qcom,adreno-gpu-a643", 1811: .features = ADRENO_APRIV | 1812: ADRENO_IOCOHERENT | ADRENO_CONTENT_PROTECTION | 1813: ADRENO_PREEMPTION | ADRENO_IFPC, 1814: .gpudev = &adreno_a6xx_gmu_gpudev.base, 1815: .perfcounters = &adreno_a6xx_perfcounters, 1816: .uche_gmem_alignment = 0, 1817: .gmem_size = SZ_512K, 1818: .bus_width = 32, 1819: .snapshot_size = SZ_2M, 1820: .chipid = 0x06030500, 1821: .speedbins = KGSL_SPEEDBINS( 1822: { 0, 0 }, 1823: { 117, 0 }, 1824: { 129, 4 }, 1825: { 172, 2 }, 1826: { 190, 1 }, 1827: ), 1828: .ubwc_mode = 3, 1829: .mal = 32, 1830: .highest_bank_bit = 15, 1831: }, 1832: .prim_fifo_threshold = 0x00200000, 1833: .gmu_major = 2, 1834: .gmu_minor = 0, 1835: .sqefw_name = "a660_sqe.fw", 1836: .gmufw_name = "a660_gmu.bin", 1837: .zap_name = "a660_zap.mbn", 1838: .hwcg = a660_hwcg_regs, 1839: .hwcg_count = ARRAY_SIZE(a660_hwcg_regs), 1840: .vbif = a650_gbif_regs, 1841: .vbif_count = ARRAY_SIZE(a650_gbif_regs), 1842: .hang_detect_cycles = 0x3ffff, 1843: .veto_fal10 = true, 1844: .protected_regs = a660_protected_regs, 1845: .disable_tseskip = true, 1846: .pdc_in_aop = true, 1847: .ctxt_record_size = 2496 * 1024, 1848: }; 1849: 1850: static const struct adreno_a6xx_core adreno_gpu_core_a662 = { 1851: .base = { 1852: DEFINE_ADRENO_REV(ADRENO_REV_A662, ANY_ID, ANY_ID, ANY_ID, ANY_ID), 1853: .compatible = "qcom,adreno-gpu-a662", 1854: .features = ADRENO_APRIV | ADRENO_IOCOHERENT | 1855: ADRENO_CONTENT_PROTECTION | ADRENO_PREEMPTION | 1856: ADRENO_IFPC | ADRENO_BCL | ADRENO_ACD, 1857: .gpudev = &adreno_a6xx_gmu_gpudev.base, 1858: .perfcounters = &adreno_a6xx_perfcounters, 1859: .uche_gmem_alignment = 0, 1860: .gmem_size = SZ_1M + SZ_512K, 1861: .bus_width = 32, 1862: .snapshot_size = SZ_2M, 1863: .highest_bank_bit = 15, 1864: }, 1865: .prim_fifo_threshold = 0x00300000, 1866: .gmu_major = 2, 1867: .gmu_minor = 0, 1868: .sqefw_name = "a660_sqe.fw", 1869: .gmufw_name = "a662_gmu.bin", 1870: .zap_name = "a662_zap.mdt", 1871: .hwcg = a660_hwcg_regs, 1872: .hwcg_count = ARRAY_SIZE(a660_hwcg_regs), 1873: .vbif = a650_gbif_regs, 1874: .vbif_count = ARRAY_SIZE(a650_gbif_regs), 1875: .hang_detect_cycles = 0x3ffff, 1876: .veto_fal10 = true, 1877: .protected_regs = a660_protected_regs, 1878: .disable_tseskip = true, 1879: .pdc_in_aop = true, 1880: .ctxt_record_size = 2496 * 1024, 1881: }; 1882: 1883: static const struct adreno_a6xx_core adreno_gpu_core_gen6_3_26_0 = { 1884: .base = { 1885: DEFINE_ADRENO_REV(ADRENO_REV_GEN6_3_26_0, ANY_ID, ANY_ID, ANY_ID, ANY_ID), 1886: .compatible = "qcom,adreno-gpu-gen6-3-26-0", 1887: .features = ADRENO_CONTENT_PROTECTION | ADRENO_IOCOHERENT | 1888: ADRENO_PREEMPTION, 1889: .gpudev = &adreno_a6xx_gpudev, 1890: .perfcounters = &adreno_a6xx_legacy_perfcounters, 1891: .uche_gmem_alignment = SZ_1M, 1892: .gmem_size = (SZ_128K + SZ_4K), 1893: .bus_width = 32, 1894: .snapshot_size = SZ_2M, 1895: .highest_bank_bit = 15, 1896: }, 1897: .prim_fifo_threshold = 0x00080000, 1898: .sqefw_name = "a630_sqe.fw", 1899: .zap_name = "gen6_3_26_0_zap.mdt", 1900: .hwcg = a612_hwcg_regs, 1901: .hwcg_count = ARRAY_SIZE(a612_hwcg_regs), 1902: .vbif = a640_vbif_regs, 1903: .vbif_count = ARRAY_SIZE(a640_vbif_regs), 1904: .hang_detect_cycles = 0x3fffff, 1905: .protected_regs = a630_protected_regs, 1906: }; 1907: 1908: extern const struct gen7_snapshot_block_list gen7_0_0_snapshot_block_list; 1909: 1910: static const struct kgsl_regmap_list gen7_0_0_gbif_cx_regs[] = { 1911: { GEN7_GBIF_QSB_SIDE0, 0x00071620 }, 1912: { GEN7_GBIF_QSB_SIDE1, 0x00071620 }, 1913: { GEN7_GBIF_QSB_SIDE2, 0x00071620 }, 1914: { GEN7_GBIF_QSB_SIDE3, 0x00071620 }, 1915: }; 1916: 1917: static const struct kgsl_regmap_list a702_hwcg_regs[] = { 1918: {A6XX_RBBM_CLOCK_CNTL_SP0, 0x22222222}, 1919: {A6XX_RBBM_CLOCK_CNTL2_SP0, 0x02222220}, 1920: {A6XX_RBBM_CLOCK_DELAY_SP0, 0x00000081}, 1921: {A6XX_RBBM_CLOCK_HYST_SP0, 0x0000f3cf}, 1922: {A6XX_RBBM_CLOCK_CNTL_TP0, 0x22222222}, 1923: {A6XX_RBBM_CLOCK_CNTL2_TP0, 0x22222222}, 1924: {A6XX_RBBM_CLOCK_CNTL3_TP0, 0x22222222}, 1925: {A6XX_RBBM_CLOCK_CNTL4_TP0, 0x00022222}, 1926: {A6XX_RBBM_CLOCK_DELAY_TP0, 0x11111111}, 1927: {A6XX_RBBM_CLOCK_DELAY2_TP0, 0x11111111}, 1928: {A6XX_RBBM_CLOCK_DELAY3_TP0, 0x11111111}, 1929: {A6XX_RBBM_CLOCK_DELAY4_TP0, 0x00011111}, 1930: {A6XX_RBBM_CLOCK_HYST_TP0, 0x77777777}, 1931: {A6XX_RBBM_CLOCK_HYST2_TP0, 0x77777777}, 1932: {A6XX_RBBM_CLOCK_HYST3_TP0, 0x77777777}, 1933: {A6XX_RBBM_CLOCK_HYST4_TP0, 0x00077777}, 1934: {A6XX_RBBM_CLOCK_CNTL_RB0, 0x22222222}, 1935: {A6XX_RBBM_CLOCK_CNTL2_RB0, 0x01202222}, 1936: {A6XX_RBBM_CLOCK_CNTL_CCU0, 0x00002220}, 1937: {A6XX_RBBM_CLOCK_HYST_RB_CCU0, 0x00040f00}, 1938: {A6XX_RBBM_CLOCK_CNTL_RAC, 0x05522022}, 1939: {A6XX_RBBM_CLOCK_CNTL2_RAC, 0x00005555}, 1940: {A6XX_RBBM_CLOCK_DELAY_RAC, 0x00000011}, 1941: {A6XX_RBBM_CLOCK_HYST_RAC, 0x00445044}, 1942: {A6XX_RBBM_CLOCK_CNTL_TSE_RAS_RBBM, 0x04222222}, 1943: {A6XX_RBBM_CLOCK_MODE_VFD, 0x00002222}, 1944: {A6XX_RBBM_CLOCK_MODE_GPC, 0x02222222}, 1945: {A6XX_RBBM_CLOCK_DELAY_HLSQ_2, 0x00000002}, 1946: {A6XX_RBBM_CLOCK_MODE_HLSQ, 0x00002222}, 1947: {A6XX_RBBM_CLOCK_DELAY_TSE_RAS_RBBM, 0x00004000}, 1948: {A6XX_RBBM_CLOCK_DELAY_VFD, 0x00002222}, 1949: {A6XX_RBBM_CLOCK_DELAY_GPC, 0x00000200}, 1950: {A6XX_RBBM_CLOCK_DELAY_HLSQ, 0x00000000}, 1951: {A6XX_RBBM_CLOCK_HYST_TSE_RAS_RBBM, 0x00000000}, 1952: {A6XX_RBBM_CLOCK_HYST_VFD, 0x00000000}, 1953: {A6XX_RBBM_CLOCK_HYST_GPC, 0x04104004}, 1954: {A6XX_RBBM_CLOCK_HYST_HLSQ, 0x00000000}, 1955: {A6XX_RBBM_CLOCK_CNTL_UCHE, 0x22222222}, 1956: {A6XX_RBBM_CLOCK_HYST_UCHE, 0x00000004}, 1957: {A6XX_RBBM_CLOCK_DELAY_UCHE, 0x00000002}, 1958: {A6XX_RBBM_ISDB_CNT, 0x00000182}, 1959: {A6XX_RBBM_RAC_THRESHOLD_CNT, 0x00000000}, 1960: {A6XX_RBBM_SP_HYST_CNT, 0x00000000}, 1961: {A6XX_RBBM_CLOCK_CNTL_GMU_GX, 0x00000222}, 1962: {A6XX_RBBM_CLOCK_DELAY_GMU_GX, 0x00000111}, 1963: {A6XX_RBBM_CLOCK_HYST_GMU_GX, 0x00000555}, 1964: {A6XX_RBBM_CLOCK_CNTL_FCHE, 0x00000222}, 1965: {A6XX_RBBM_CLOCK_DELAY_FCHE, 0x00000000}, 1966: {A6XX_RBBM_CLOCK_HYST_FCHE, 0x00000000}, 1967: {A6XX_RBBM_CLOCK_CNTL_GLC, 0x00222222}, 1968: {A6XX_RBBM_CLOCK_DELAY_GLC, 0x00000000}, 1969: {A6XX_RBBM_CLOCK_HYST_GLC, 0x00000000}, 1970: {A6XX_RBBM_CLOCK_CNTL_MHUB, 0x00000002}, 1971: {A6XX_RBBM_CLOCK_DELAY_MHUB, 0x00000000}, 1972: {A6XX_RBBM_CLOCK_HYST_MHUB, 0x00000000}, 1973: }; 1974: 1975: static const struct adreno_a6xx_core adreno_gpu_core_a702 = { 1976: .base = { 1977: DEFINE_ADRENO_REV(ADRENO_REV_A702, 7, 0, 2, ANY_ID), 1978: .features = ADRENO_CONTENT_PROTECTION | 1979: ADRENO_APRIV | ADRENO_PREEMPTION, 1980: .gpudev = &adreno_a6xx_gpudev, 1981: .perfcounters = &adreno_a6xx_legacy_perfcounters, 1982: .gmem_size = SZ_128K, 1983: .bus_width = 16, 1984: .snapshot_size = SZ_1M, 1985: .highest_bank_bit = 14, 1986: .chipid = 0x07000200, 1987: .speedbins = KGSL_SPEEDBINS( 1988: { 0, 0 }, 1989: { 236, 1 }, 1990: { 178, 2 }, 1991: { 142, 3 }, 1992: ), 1993: .ubwc_mode = 1, 1994: .mal = 64, 1995: }, 1996: .prim_fifo_threshold = 0x0000c000, 1997: .sqefw_name = "a702_sqe.fw", 1998: .zap_name = "a702_zap.mdt", 1999: .hwcg = a702_hwcg_regs, 2000: .hwcg_count = ARRAY_SIZE(a702_hwcg_regs), 2001: .vbif = a640_vbif_regs, 2002: .vbif_count = ARRAY_SIZE(a640_vbif_regs), 2003: .hang_detect_cycles = 0x3ffff, 2004: .protected_regs = a620_protected_regs, 2005: }; 2006: 2007: /* SMMU aperture registers: GC to context bank 0, LPAC disabled */ 2008: static const struct kgsl_regmap_list a704_smmu_aperture_regs[] = { 2009: { 0x0, 0x000a8000 }, /* GC: CB0 */ 2010: { 0x2, 0x00000000 }, /* CTRL: GC only */ 2011: }; 2012: 2013: static const struct adreno_a6xx_core adreno_gpu_core_a704 = { 2014: .base = { 2015: DEFINE_ADRENO_REV(ADRENO_REV_A704, 7, 0, 4, ANY_ID), 2016: .features = ADRENO_CONTENT_PROTECTION | 2017: ADRENO_APRIV | ADRENO_PREEMPTION, 2018: .gpudev = &adreno_a6xx_gpudev, 2019: .perfcounters = &adreno_a6xx_legacy_perfcounters, 2020: .gmem_size = SZ_128K, 2021: .bus_width = 16, 2022: .snapshot_size = SZ_1M, 2023: .highest_bank_bit = 14, 2024: .chipid = 0x07000400, 2025: .ubwc_mode = 2, 2026: .mal = 32, 2027: .gpu_model = "Adreno704v1", 2028: .smmu_aperture = a704_smmu_aperture_regs, 2029: .smmu_aperture_count = ARRAY_SIZE(a704_smmu_aperture_regs), 2030: }, 2031: .prim_fifo_threshold = 0x0000c000, 2032: .sqefw_name = "a702_sqe.fw", 2033: .zap_name = "a704_zap.mbn", 2034: .hwcg = a702_hwcg_regs, 2035: .hwcg_count = ARRAY_SIZE(a702_hwcg_regs), 2036: .vbif = a640_vbif_regs, 2037: .vbif_count = ARRAY_SIZE(a640_vbif_regs), 2038: .hang_detect_cycles = 0x3ffff, 2039: .protected_regs = a620_protected_regs, 2040: }; 2041: 2042: static const struct kgsl_regmap_list gen7_0_0_hwcg_regs[] = { 2043: { GEN7_RBBM_CLOCK_CNTL_SP0, 0x02222222 }, MATCH LINES: 2973, 2974, 2975, 2976, 2977, 2978, 2979, 2980, 2981, 2982, 2983, 2984, 2985, 2986, 2987, 2988, 2989, 2990, 2991, 2992, 2993, 2994, 2995, 2996, 2997, 2998, 2999, 3000, 3001, 3002, 3003, 3004, 3005, 3006, 3007, 3008, 3009, 3010, 3011, 3012, 3013, 3014, 3015, 3016, 3017, 3018, 3019, 3020, 3021, 3022, 3023, 3024, 3025, 3026, 3029, 3035, 3036 2961: .ao_hwcg = gen7_0_0_ao_hwcg_regs, 2962: .ao_hwcg_count = ARRAY_SIZE(gen7_0_0_ao_hwcg_regs), 2963: .gbif = gen7_0_0_gbif_cx_regs, 2964: .gbif_count = ARRAY_SIZE(gen7_0_0_gbif_cx_regs), 2965: .hang_detect_cycles = 0xcfffff, 2966: .protected_regs = gen7_0_0_protected_regs, 2967: .gen7_snapshot_block_list = &gen7_17_0_snapshot_block_list, 2968: .preempt_level = 1, 2969: .ctxt_record_size = 1536 * 1024 2970: }; 2971: 2972: static const struct kgsl_regmap_list a663_hwcg_regs[] = { 2973: {A6XX_RBBM_CLOCK_CNTL_SP0, 0x02222222}, 2974: {A6XX_RBBM_CLOCK_CNTL2_SP0, 0x02222220}, 2975: {A6XX_RBBM_CLOCK_DELAY_SP0, 0x00000080}, 2976: {A6XX_RBBM_CLOCK_HYST_SP0, 0x0000F3CF}, 2977: {A6XX_RBBM_CLOCK_CNTL_TP0, 0x22222222}, 2978: {A6XX_RBBM_CLOCK_CNTL2_TP0, 0x22222222}, 2979: {A6XX_RBBM_CLOCK_CNTL3_TP0, 0x22222222}, 2980: {A6XX_RBBM_CLOCK_CNTL4_TP0, 0x00022222}, 2981: {A6XX_RBBM_CLOCK_DELAY_TP0, 0x11111111}, 2982: {A6XX_RBBM_CLOCK_DELAY2_TP0, 0x11111111}, 2983: {A6XX_RBBM_CLOCK_DELAY3_TP0, 0x11111111}, 2984: {A6XX_RBBM_CLOCK_DELAY4_TP0, 0x00011111}, 2985: {A6XX_RBBM_CLOCK_HYST_TP0, 0x77777777}, 2986: {A6XX_RBBM_CLOCK_HYST2_TP0, 0x77777777}, 2987: {A6XX_RBBM_CLOCK_HYST3_TP0, 0x77777777}, 2988: {A6XX_RBBM_CLOCK_HYST4_TP0, 0x00077777}, 2989: {A6XX_RBBM_CLOCK_CNTL_RB0, 0x22222222}, 2990: {A6XX_RBBM_CLOCK_CNTL2_RB0, 0x01002222}, 2991: {A6XX_RBBM_CLOCK_CNTL_CCU0, 0x00002220}, 2992: {A6XX_RBBM_CLOCK_HYST_RB_CCU0, 0x00040F00}, 2993: {A6XX_RBBM_CLOCK_CNTL_RAC, 0x25222022}, 2994: {A6XX_RBBM_CLOCK_CNTL2_RAC, 0x00005555}, 2995: {A6XX_RBBM_CLOCK_DELAY_RAC, 0x00000011}, 2996: {A6XX_RBBM_CLOCK_HYST_RAC, 0x00445044}, 2997: {A6XX_RBBM_CLOCK_CNTL_TSE_RAS_RBBM, 0x04222222}, 2998: {A6XX_RBBM_CLOCK_MODE_VFD, 0x00002222}, 2999: {A6XX_RBBM_CLOCK_MODE_GPC, 0x00222222}, 3000: {A6XX_RBBM_CLOCK_DELAY_HLSQ_2, 0x00000002}, 3001: {A6XX_RBBM_CLOCK_MODE_HLSQ, 0x00002222}, 3002: {A6XX_RBBM_CLOCK_DELAY_TSE_RAS_RBBM, 0x00004000}, 3003: {A6XX_RBBM_CLOCK_DELAY_VFD, 0x00002222}, 3004: {A6XX_RBBM_CLOCK_DELAY_GPC, 0x00000200}, 3005: {A6XX_RBBM_CLOCK_DELAY_HLSQ, 0x00000000}, 3006: {A6XX_RBBM_CLOCK_HYST_TSE_RAS_RBBM, 0x00000000}, 3007: {A6XX_RBBM_CLOCK_HYST_VFD, 0x00000000}, 3008: {A6XX_RBBM_CLOCK_HYST_GPC, 0x04104004}, 3009: {A6XX_RBBM_CLOCK_HYST_HLSQ, 0x00000000}, 3010: {A6XX_RBBM_CLOCK_CNTL_TEX_FCHE, 0x00000222}, 3011: {A6XX_RBBM_CLOCK_DELAY_TEX_FCHE, 0x00000111}, 3012: {A6XX_RBBM_CLOCK_HYST_TEX_FCHE, 0x00000000}, 3013: {A6XX_RBBM_CLOCK_CNTL_UCHE, 0x22222222}, 3014: {A6XX_RBBM_CLOCK_HYST_UCHE, 0x00000004}, 3015: {A6XX_RBBM_CLOCK_DELAY_UCHE, 0x00000002}, 3016: {A6XX_RBBM_CLOCK_CNTL, 0x8AA8AA82}, 3017: {A6XX_RBBM_ISDB_CNT, 0x00000182}, 3018: {A6XX_RBBM_RAC_THRESHOLD_CNT, 0x00000000}, 3019: {A6XX_RBBM_SP_HYST_CNT, 0x00000000}, 3020: {A6XX_RBBM_CLOCK_CNTL_GMU_GX, 0x00000222}, 3021: {A6XX_RBBM_CLOCK_DELAY_GMU_GX, 0x00000111}, 3022: {A6XX_RBBM_CLOCK_HYST_GMU_GX, 0x00000555}, 3023: {A6XX_GMUAO_GMU_CGC_MODE_CNTL, 0x00020200}, 3024: {A6XX_GMUAO_GMU_CGC_DELAY_CNTL, 0x00010111}, 3025: {A6XX_GMUAO_GMU_CGC_HYST_CNTL, 0x00005555}, 3026: {A6XX_GMUCX_GMU_WFI_CONFIG, 0x00000000}, 3027: }; 3028: 3029: static const struct adreno_a6xx_core adreno_gpu_core_a663 = { 3030: .base = { 3031: DEFINE_ADRENO_REV(ADRENO_REV_A663, 6, 6, 3, ANY_ID), 3032: .features = ADRENO_APRIV | 3033: ADRENO_IOCOHERENT | ADRENO_CONTENT_PROTECTION | 3034: ADRENO_PREEMPTION | ADRENO_ACD, 3035: .gpudev = &adreno_a6xx_gmu_gpudev.base, 3036: .perfcounters = &adreno_a6xx_perfcounters, 3037: .gmem_size = SZ_1M + SZ_512K, 3038: .bus_width = 32, 3039: .snapshot_size = SZ_2M, 3040: .chipid = 0x06060300, 3041: .speedbins = KGSL_SPEEDBINS( 3042: { 0, 0 }, 3043: { 169, 0 }, 3044: { 113, 1 }, 3045: ), 3046: .ubwc_mode = 4, 3047: .mal = 32, 3048: .highest_bank_bit = 13, 3049: }, 3050: .prim_fifo_threshold = 0x00300000, 3051: .gmu_major = 2, 3052: .gmu_minor = 0, 3053: .sqefw_name = "a660_sqe.fw", 3054: .gmufw_name = "a663_gmu.bin", 3055: .zap_name = "a663_zap.mbn", 3056: .hwcg = a663_hwcg_regs, 3057: .hwcg_count = ARRAY_SIZE(a663_hwcg_regs), 3058: .vbif = a650_gbif_regs, 3059: .vbif_count = ARRAY_SIZE(a650_gbif_regs), 3060: .hang_detect_cycles = 0xcfffff, MATCH LINES: 4364, 4370, 4371 4352: .gmu_hub_clk_freq = 200000000, 4353: .gen8_snapshot_block_list = &gen8_9_0_snapshot_block_list, 4354: .fast_bus_hint = true, 4355: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 4356: .noc_timeout_us = 3410, /* 3.41 msec */ 4357: .cl_no_ft_timeout_ms = 6500, 4358: .ctxt_record_size = (3708 * SZ_1K), 4359: .preempt_level = 1, 4360: .therm_cfg = &therm_mit_cfg_8_2_0, 4361: .bcl_data = 1, 4362: }; 4363: 4364: static const struct adreno_a6xx_core adreno_gpu_core_a623 = { 4365: .base = { 4366: DEFINE_ADRENO_REV(ADRENO_REV_A623, 6, 2, 3, ANY_ID), 4367: .features = ADRENO_APRIV | 4368: ADRENO_IOCOHERENT | ADRENO_CONTENT_PROTECTION | 4369: ADRENO_PREEMPTION | ADRENO_ACD, 4370: .gpudev = &adreno_a6xx_gmu_gpudev.base, 4371: .perfcounters = &adreno_a6xx_perfcounters, 4372: .uche_gmem_alignment = SZ_1M + SZ_512K, 4373: .gmem_size = SZ_512K, 4374: .bus_width = 32, 4375: .snapshot_size = SZ_2M, 4376: .chipid = 0x06020300, 4377: .speedbins = KGSL_SPEEDBINS( 4378: { 0, 0 }, 4379: { 185, 0 }, 4380: { 127, 1 }, 4381: ), 4382: .ubwc_mode = 4, 4383: .mal = 32, 4384: .highest_bank_bit = 16, 4385: }, 4386: .prim_fifo_threshold = 0x0010000, 4387: .gmu_major = 2, 4388: .gmu_minor = 0, 4389: .sqefw_name = "a650_sqe.fw", 4390: .gmufw_name = "a623_gmu.bin", 4391: .zap_name = "a623_zap.mbn", 4392: .hwcg = a620_hwcg_regs, 4393: .hwcg_count = ARRAY_SIZE(a620_hwcg_regs), 4394: .vbif = a650_gbif_regs, 4395: .vbif_count = ARRAY_SIZE(a650_gbif_regs), --- FILE: \adreno.h | HITS: 2 --- MATCH LINES: 1237, 1238 1225: }; 1226: 1227: #define KGSL_FT_POLICY_MASK GENMASK(KGSL_FT_MAX_BITS - 1, 0) 1228: 1229: #define FOR_EACH_RINGBUFFER(_dev, _rb, _i) \ 1230: for ((_i) = 0, (_rb) = &((_dev)->ringbuffers[0]); \ 1231: (_i) < (_dev)->num_ringbuffers; \ 1232: (_i)++, (_rb)++) 1233: 1234: extern const struct adreno_power_ops adreno_power_operations; 1235: 1236: extern const struct adreno_gpudev adreno_a5xx_gpudev; 1237: extern const struct adreno_gpudev adreno_a6xx_gpudev; 1238: extern const struct adreno_gpudev adreno_a6xx_rgmu_gpudev; 1239: extern const struct adreno_gpudev adreno_a619_holi_gpudev; 1240: extern const struct adreno_gpudev adreno_a611_gpudev; 1241: 1242: extern int adreno_wake_nice; 1243: extern unsigned int adreno_wake_timeout; 1244: 1245: int adreno_start(struct kgsl_device *device, int priority); 1246: long adreno_ioctl(struct kgsl_device_private *dev_priv, 1247: unsigned int cmd, unsigned long arg); 1248: 1249: long adreno_ioctl_helper(struct kgsl_device_private *dev_priv, 1250: unsigned int cmd, unsigned long arg, 1251: const struct kgsl_ioctl *cmds, int len); 1252: 1253: int adreno_spin_idle(struct adreno_device *device, unsigned int timeout); 1254: int adreno_wait_idle(struct kgsl_device *device); 1255: 1256: int adreno_set_constraint(struct kgsl_device *device, 1257: struct kgsl_context *context, 1258: struct kgsl_device_constraint *constraint); 1259: 1260: void adreno_snapshot(struct kgsl_device *device, 1261: struct kgsl_snapshot *snapshot, 1262: struct kgsl_context *context, struct kgsl_context *context_lpac); --- FILE: \adreno_a5xx.c | HITS: 8 --- MATCH LINES: 526 514: cmds += cp_protected_mode(adreno_dev, cmds, 0); 515: 516: /* 517: * Prebuild the cmd stream to send to the GPU to load 518: * the GPMU firmware 519: */ 520: while (size > 0) { 521: int tmp_size = size; 522: 523: if (size >= TYPE4_MAX_PAYLOAD) 524: tmp_size = TYPE4_MAX_PAYLOAD; 525: 526: *cmds++ = cp_type4_packet( 527: A5XX_GPMU_INST_RAM_BASE + offset, 528: tmp_size); 529: 530: memcpy(cmds, &ucode[offset], tmp_size << 2); 531: 532: cmds += tmp_size; 533: offset += tmp_size; 534: size -= tmp_size; 535: } 536: 537: /* Turn CP protection ON */ 538: cmds += cp_protected_mode(adreno_dev, cmds, 1); 539: 540: adreno_dev->gpmu_cmds_size = (size_t) (cmds - start); 541: 542: return 0; 543: } 544: 545: 546: /* 547: * _load_gpmu_firmware() - Load the ucode into the GPMU RAM 548: * @adreno_dev: Pointer to adreno device 549: */ 550: static int _load_gpmu_firmware(struct adreno_device *adreno_dev) MATCH LINES: 1530, 1532, 1538, 1541, 1545, 1548 1518: struct adreno_ringbuffer *rb, unsigned int *cmds, 1519: struct kgsl_context *context) 1520: { 1521: unsigned int *cmds_orig = cmds; 1522: uint64_t gpuaddr = rb->preemption_desc->gpuaddr; 1523: 1524: /* Turn CP protection OFF */ 1525: cmds += cp_protected_mode(adreno_dev, cmds, 0); 1526: /* 1527: * CP during context switch will save context switch info to 1528: * a5xx_cp_preemption_record pointed by CONTEXT_SWITCH_SAVE_ADDR 1529: */ 1530: *cmds++ = cp_type4_packet(A5XX_CP_CONTEXT_SWITCH_SAVE_ADDR_LO, 1); 1531: *cmds++ = lower_32_bits(gpuaddr); 1532: *cmds++ = cp_type4_packet(A5XX_CP_CONTEXT_SWITCH_SAVE_ADDR_HI, 1); 1533: *cmds++ = upper_32_bits(gpuaddr); 1534: 1535: /* Turn CP protection ON */ 1536: cmds += cp_protected_mode(adreno_dev, cmds, 1); 1537: 1538: *cmds++ = cp_type7_packet(CP_PREEMPT_ENABLE_GLOBAL, 1); 1539: *cmds++ = 0; 1540: 1541: *cmds++ = cp_type7_packet(CP_PREEMPT_ENABLE_LOCAL, 1); 1542: *cmds++ = 1; 1543: 1544: /* Enable yield in RB only */ 1545: *cmds++ = cp_type7_packet(CP_YIELD_ENABLE, 1); 1546: *cmds++ = 1; 1547: 1548: *cmds++ = cp_type7_packet(CP_CONTEXT_SWITCH_YIELD, 4); 1549: cmds += cp_gpuaddr(adreno_dev, cmds, 0x0); 1550: *cmds++ = 0; 1551: /* generate interrupt on preemption completion */ 1552: *cmds++ = 1; 1553: 1554: return cmds - cmds_orig; 1555: } 1556: 1557: static int a5xx_post_start(struct adreno_device *adreno_dev) 1558: { 1559: int ret; 1560: unsigned int *cmds, *start; 1561: struct adreno_ringbuffer *rb = adreno_dev->cur_rb; 1562: 1563: if (!adreno_is_a530(adreno_dev) && 1564: !adreno_is_preemption_enabled(adreno_dev)) 1565: return 0; 1566: 1567: cmds = adreno_ringbuffer_allocspace(rb, 42); 1568: if (IS_ERR(cmds)) { 1569: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1570: 1571: dev_err(device->dev, 1572: "error allocating preemtion init cmds\n"); MATCH LINES: 1764 1752: * Submit commands for ME initialization, 1753: */ 1754: static int a5xx_send_me_init(struct adreno_device *adreno_dev, 1755: struct adreno_ringbuffer *rb) 1756: { 1757: unsigned int *cmds; 1758: int i = 0, ret; 1759: 1760: cmds = adreno_ringbuffer_allocspace(rb, 9); 1761: if (IS_ERR(cmds)) 1762: return PTR_ERR(cmds); 1763: 1764: cmds[i++] = cp_type7_packet(CP_ME_INIT, 8); 1765: 1766: /* Enabled ordinal mask */ 1767: cmds[i++] = CP_INIT_MASK; 1768: 1769: if (CP_INIT_MASK & CP_INIT_MAX_CONTEXT) 1770: cmds[i++] = 0x00000003; 1771: 1772: if (CP_INIT_MASK & CP_INIT_ERROR_DETECTION_CONTROL) 1773: cmds[i++] = 0x20000000; 1774: 1775: if (CP_INIT_MASK & CP_INIT_HEADER_DUMP) { 1776: /* Header dump address */ 1777: cmds[i++] = 0x00000000; 1778: /* Header dump enable and dump size */ 1779: cmds[i++] = 0x00000000; 1780: } 1781: 1782: if (CP_INIT_MASK & CP_INIT_DRAWCALL_FILTER_RANGE) { 1783: /* Start range */ 1784: cmds[i++] = 0x00000000; 1785: /* End range (inclusive) */ 1786: cmds[i++] = 0x00000000; 1787: } 1788: --- FILE: \adreno_a5xx_perfcounter.c | HITS: 2 --- MATCH LINES: 78, 79 66: unsigned int counter, unsigned int countable) 67: { 68: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 69: struct adreno_perfcount_register *reg = &group->regs[counter]; 70: struct adreno_ringbuffer *rb = &adreno_dev->ringbuffers[0]; 71: u32 cmds[3]; 72: int ret; 73: 74: if (!(device->state == KGSL_STATE_ACTIVE)) 75: return a5xx_counter_enable(adreno_dev, group, counter, 76: countable); 77: 78: cmds[0] = cp_type7_packet(CP_WAIT_FOR_IDLE, 0); 79: cmds[1] = cp_type4_packet(reg->select, 1); 80: cmds[2] = countable; 81: 82: /* submit to highest priority RB always */ 83: ret = a5xx_ringbuffer_addcmds(adreno_dev, rb, NULL, 84: F_NOTPROTECTED, cmds, 3, 0, NULL); 85: 86: if (ret) 87: return ret; 88: 89: /* 90: * schedule dispatcher to make sure rb[0] is run, because 91: * if the current RB is not rb[0] and gpu is idle then 92: * rb[0] will not get scheduled to run 93: */ 94: if (adreno_dev->cur_rb != rb) 95: adreno_scheduler_queue(adreno_dev); 96: 97: /* wait for the above commands submitted to complete */ 98: ret = adreno_ringbuffer_waittimestamp(rb, rb->timestamp, 99: ADRENO_IDLE_TIMEOUT); 100: 101: if (ret) { 102: /* 103: * If we were woken up because of cancelling rb events --- FILE: \adreno_a5xx_preempt.c | HITS: 7 --- MATCH LINES: 357, 368, 370, 381, 384, 389, 403 345: 346: /* 347: * CP_PREEMPT_ENABLE_GLOBAL(global preemption) can only be set by KMD 348: * in ringbuffer. 349: * 1) set global preemption to 0x0 to disable global preemption. 350: * Only RB level preemption is allowed in this mode 351: * 2) Set global preemption to defer(0x2) for finegrain preemption. 352: * when global preemption is set to defer(0x2), 353: * CP_PREEMPT_ENABLE_LOCAL(local preemption) determines the 354: * preemption point. Local preemption 355: * can be enabled by both UMD(within IB) and KMD. 356: */ 357: *cmds++ = cp_type7_packet(CP_PREEMPT_ENABLE_GLOBAL, 1); 358: *cmds++ = ((preempt_style == KGSL_CONTEXT_PREEMPT_STYLE_FINEGRAIN) 359: ? 2 : 0); 360: 361: /* Turn CP protection OFF */ 362: cmds += cp_protected_mode(adreno_dev, cmds, 0); 363: 364: /* 365: * CP during context switch will save context switch info to 366: * a5xx_cp_preemption_record pointed by CONTEXT_SWITCH_SAVE_ADDR 367: */ 368: *cmds++ = cp_type4_packet(A5XX_CP_CONTEXT_SWITCH_SAVE_ADDR_LO, 1); 369: *cmds++ = lower_32_bits(gpuaddr); 370: *cmds++ = cp_type4_packet(A5XX_CP_CONTEXT_SWITCH_SAVE_ADDR_HI, 1); 371: *cmds++ = upper_32_bits(gpuaddr); 372: 373: /* Turn CP protection ON */ 374: cmds += cp_protected_mode(adreno_dev, cmds, 1); 375: 376: /* 377: * Enable local preemption for finegrain preemption in case of 378: * a misbehaving IB 379: */ 380: if (preempt_style == KGSL_CONTEXT_PREEMPT_STYLE_FINEGRAIN) { 381: *cmds++ = cp_type7_packet(CP_PREEMPT_ENABLE_LOCAL, 1); 382: *cmds++ = 1; 383: } else { 384: *cmds++ = cp_type7_packet(CP_PREEMPT_ENABLE_LOCAL, 1); 385: *cmds++ = 0; 386: } 387: 388: /* Enable CP_CONTEXT_SWITCH_YIELD packets in the IB2s */ 389: *cmds++ = cp_type7_packet(CP_YIELD_ENABLE, 1); 390: *cmds++ = 2; 391: 392: return (unsigned int) (cmds - cmds_orig); 393: } 394: 395: unsigned int a5xx_preemption_post_ibsubmit(struct adreno_device *adreno_dev, 396: unsigned int *cmds) 397: { 398: int dwords = 0; 399: 400: if (!adreno_is_preemption_enabled(adreno_dev)) 401: return 0; 402: 403: cmds[dwords++] = cp_type7_packet(CP_CONTEXT_SWITCH_YIELD, 4); 404: /* Write NULL to the address to skip the data write */ 405: dwords += cp_gpuaddr(adreno_dev, &cmds[dwords], 0x0); 406: cmds[dwords++] = 1; 407: /* generate interrupt on preemption completion */ 408: cmds[dwords++] = 1; 409: 410: return dwords; 411: } 412: 413: void a5xx_preemption_start(struct adreno_device *adreno_dev) 414: { 415: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 416: struct kgsl_iommu *iommu = KGSL_IOMMU(device); 417: struct adreno_ringbuffer *rb; 418: unsigned int i; 419: 420: if (!adreno_is_preemption_enabled(adreno_dev)) 421: return; 422: 423: /* Force the state to be clear */ 424: adreno_set_preempt_state(adreno_dev, ADRENO_PREEMPT_NONE); 425: 426: /* Only set up smmu info when per-process pagetables are enabled */ 427: --- FILE: \adreno_a5xx_ringbuffer.c | HITS: 36 --- MATCH LINES: 25, 30, 31, 32, 35, 44, 45, 46, 78 13: 14: static int a5xx_rb_pagetable_switch(struct kgsl_device *device, 15: struct adreno_context *drawctxt, 16: struct adreno_ringbuffer *rb, 17: struct kgsl_pagetable *pagetable, u32 *cmds) 18: { 19: u64 ttbr0 = kgsl_mmu_pagetable_get_ttbr0(pagetable); 20: u32 id = drawctxt ? drawctxt->base.id : 0; 21: 22: if (pagetable == device->mmu.defaultpagetable) 23: return 0; 24: 25: cmds[0] = cp_type7_packet(CP_SMMU_TABLE_UPDATE, 3); 26: cmds[1] = lower_32_bits(ttbr0); 27: cmds[2] = upper_32_bits(ttbr0); 28: cmds[3] = id; 29: 30: cmds[4] = cp_type7_packet(CP_WAIT_FOR_IDLE, 0); 31: cmds[5] = cp_type7_packet(CP_WAIT_FOR_ME, 0); 32: cmds[6] = cp_type4_packet(A5XX_CP_CNTL, 1); 33: cmds[7] = 1; 34: 35: cmds[8] = cp_type7_packet(CP_MEM_WRITE, 5); 36: cmds[9] = lower_32_bits(SCRATCH_RB_GPU_ADDR(device, 37: rb->id, ttbr0)); 38: cmds[10] = upper_32_bits(SCRATCH_RB_GPU_ADDR(device, 39: rb->id, ttbr0)); 40: cmds[11] = lower_32_bits(ttbr0); 41: cmds[12] = upper_32_bits(ttbr0); 42: cmds[13] = id; 43: 44: cmds[14] = cp_type7_packet(CP_WAIT_FOR_IDLE, 0); 45: cmds[15] = cp_type7_packet(CP_WAIT_FOR_ME, 0); 46: cmds[16] = cp_type4_packet(A5XX_CP_CNTL, 1); 47: cmds[17] = 0; 48: 49: return 18; 50: } 51: 52: #define RB_SOPTIMESTAMP(device, rb) \ 53: MEMSTORE_RB_GPU_ADDR(device, rb, soptimestamp) 54: #define CTXT_SOPTIMESTAMP(device, drawctxt) \ 55: MEMSTORE_ID_GPU_ADDR(device, (drawctxt)->base.id, soptimestamp) 56: 57: #define RB_EOPTIMESTAMP(device, rb) \ 58: MEMSTORE_RB_GPU_ADDR(device, rb, eoptimestamp) 59: #define CTXT_EOPTIMESTAMP(device, drawctxt) \ 60: MEMSTORE_ID_GPU_ADDR(device, (drawctxt)->base.id, eoptimestamp) 61: 62: int a5xx_ringbuffer_submit(struct adreno_ringbuffer *rb, 63: struct adreno_submit_time *time, bool sync) 64: { 65: struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb); 66: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 67: unsigned long flags; 68: 69: adreno_get_submit_time(adreno_dev, rb, time); 70: adreno_profile_submit_time(time); 71: 72: if (sync) { 73: u32 *cmds = adreno_ringbuffer_allocspace(rb, 3); 74: 75: if (IS_ERR(cmds)) 76: return PTR_ERR(cmds); 77: 78: cmds[0] = cp_type7_packet(CP_WHERE_AM_I, 2); 79: cmds[1] = lower_32_bits(SCRATCH_RB_GPU_ADDR(device, rb->id, 80: rptr)); 81: cmds[2] = upper_32_bits(SCRATCH_RB_GPU_ADDR(device, rb->id, 82: rptr)); 83: } 84: 85: spin_lock_irqsave(&rb->preempt_lock, flags); 86: if (adreno_in_preempt_state(adreno_dev, ADRENO_PREEMPT_NONE)) { 87: if (adreno_dev->cur_rb == rb) 88: kgsl_regwrite(device, A5XX_CP_RB_WPTR, rb->_wptr); 89: } 90: 91: rb->wptr = rb->_wptr; 92: spin_unlock_irqrestore(&rb->preempt_lock, flags); 93: 94: return 0; 95: } 96: 97: int a5xx_ringbuffer_init(struct adreno_device *adreno_dev) 98: { 99: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 100: int i; 101: 102: if (IS_ERR_OR_NULL(device->scratch)) MATCH LINES: 164, 175, 182, 190, 196, 201, 209, 218, 227, 234, 246, 252, 260, 268, 271, 290, 323, 347, 350, 357, 364 152: return -EPROTO; 153: 154: rb->timestamp++; 155: 156: if (drawctxt) 157: drawctxt->internal_timestamp = rb->timestamp; 158: 159: cmds = adreno_ringbuffer_allocspace(rb, size); 160: if (IS_ERR(cmds)) 161: return PTR_ERR(cmds); 162: 163: /* Identify the start of a command */ 164: cmds[index++] = cp_type7_packet(CP_NOP, 1); 165: cmds[index++] = drawctxt ? CMD_IDENTIFIER : CMD_INTERNAL_IDENTIFIER; 166: 167: /* 14 dwords */ 168: index += a5xx_preemption_pre_ibsubmit(adreno_dev, rb, drawctxt, 169: &cmds[index]); 170: 171: profile_gpuaddr = adreno_profile_preib_processing(adreno_dev, 172: drawctxt, &profile_dwords); 173: 174: if (profile_gpuaddr) { 175: cmds[index++] = cp_type7_packet(CP_INDIRECT_BUFFER_PFE, 3); 176: cmds[index++] = lower_32_bits(profile_gpuaddr); 177: cmds[index++] = upper_32_bits(profile_gpuaddr); 178: cmds[index++] = profile_dwords; 179: } 180: 181: if (drawctxt) { 182: cmds[index++] = cp_type7_packet(CP_MEM_WRITE, 3); 183: cmds[index++] = lower_32_bits(CTXT_SOPTIMESTAMP(device, 184: drawctxt)); 185: cmds[index++] = upper_32_bits(CTXT_SOPTIMESTAMP(device, 186: drawctxt)); 187: cmds[index++] = timestamp; 188: } 189: 190: cmds[index++] = cp_type7_packet(CP_MEM_WRITE, 3); 191: cmds[index++] = lower_32_bits(RB_SOPTIMESTAMP(device, rb)); 192: cmds[index++] = upper_32_bits(RB_SOPTIMESTAMP(device, rb)); 193: cmds[index++] = rb->timestamp; 194: 195: if (IS_SECURE(flags)) { 196: cmds[index++] = cp_type7_packet(CP_SET_SECURE_MODE, 1); 197: cmds[index++] = 1; 198: } 199: 200: if (IS_NOTPROTECTED(flags)) { 201: cmds[index++] = cp_type7_packet(CP_SET_PROTECTED_MODE, 1); 202: cmds[index++] = 0; 203: } 204: 205: memcpy(&cmds[index], in, dwords << 2); 206: index += dwords; 207: 208: if (IS_NOTPROTECTED(flags)) { 209: cmds[index++] = cp_type7_packet(CP_SET_PROTECTED_MODE, 1); 210: cmds[index++] = 1; 211: } 212: 213: /* 4 dwords */ 214: profile_gpuaddr = adreno_profile_postib_processing(adreno_dev, 215: drawctxt, &profile_dwords); 216: 217: if (profile_gpuaddr) { 218: cmds[index++] = cp_type7_packet(CP_INDIRECT_BUFFER_PFE, 3); 219: cmds[index++] = lower_32_bits(profile_gpuaddr); 220: cmds[index++] = upper_32_bits(profile_gpuaddr); 221: cmds[index++] = profile_dwords; 222: } 223: 224: if (!adreno_is_a510(adreno_dev) && 225: test_bit(KGSL_FT_PAGEFAULT_GPUHALT_ENABLE, 226: &device->mmu.pfpolicy)) 227: cmds[index++] = cp_type7_packet(CP_WAIT_MEM_WRITES, 0); 228: 229: /* 230: * Do a unique memory write from the GPU to assist in early detection of 231: * interrupt storms 232: */ 233: 234: cmds[index++] = cp_type7_packet(CP_MEM_WRITE, 3); 235: cmds[index++] = lower_32_bits(MEMSTORE_ID_GPU_ADDR(device, 236: KGSL_MEMSTORE_GLOBAL, ref_wait_ts)); 237: cmds[index++] = upper_32_bits(MEMSTORE_ID_GPU_ADDR(device, 238: KGSL_MEMSTORE_GLOBAL, ref_wait_ts)); 239: cmds[index++] = ++sequence; 240: 241: /* 242: * If this is an internal command, just write the ringbuffer timestamp, 243: * otherwise, write both 244: */ 245: if (!drawctxt) { 246: cmds[index++] = cp_type7_packet(CP_EVENT_WRITE, 4); 247: cmds[index++] = CACHE_FLUSH_TS | (1 << 31); 248: cmds[index++] = lower_32_bits(RB_EOPTIMESTAMP(device, rb)); 249: cmds[index++] = upper_32_bits(RB_EOPTIMESTAMP(device, rb)); 250: cmds[index++] = rb->timestamp; 251: } else { 252: cmds[index++] = cp_type7_packet(CP_EVENT_WRITE, 4); 253: cmds[index++] = CACHE_FLUSH_TS | (1 << 31); 254: cmds[index++] = lower_32_bits(CTXT_EOPTIMESTAMP(device, 255: drawctxt)); 256: cmds[index++] = upper_32_bits(CTXT_EOPTIMESTAMP(device, 257: drawctxt)); 258: cmds[index++] = timestamp; 259: 260: cmds[index++] = cp_type7_packet(CP_EVENT_WRITE, 4); 261: cmds[index++] = CACHE_FLUSH_TS; 262: cmds[index++] = lower_32_bits(RB_EOPTIMESTAMP(device, rb)); 263: cmds[index++] = upper_32_bits(RB_EOPTIMESTAMP(device, rb)); 264: cmds[index++] = rb->timestamp; 265: } 266: 267: if (IS_WFI(flags)) 268: cmds[index++] = cp_type7_packet(CP_WAIT_FOR_IDLE, 0); 269: 270: if (IS_SECURE(flags)) { 271: cmds[index++] = cp_type7_packet(CP_SET_SECURE_MODE, 1); 272: cmds[index++] = 0; 273: } 274: 275: /* 5 dwords */ 276: index += a5xx_preemption_post_ibsubmit(adreno_dev, &cmds[index]); 277: 278: /* Adjust the thing for the number of bytes we actually wrote */ 279: rb->_wptr -= (size - index); 280: 281: a5xx_ringbuffer_submit(rb, time, 282: !adreno_is_preemption_enabled(adreno_dev)); 283: 284: return 0; 285: } 286: 287: static u32 a5xx_get_alwayson_counter(struct adreno_device *adreno_dev, 288: u32 *cmds, u64 gpuaddr) 289: { 290: cmds[0] = cp_type7_packet(CP_REG_TO_MEM, 3); 291: cmds[1] = A5XX_RBBM_ALWAYSON_COUNTER_LO; 292: 293: /* On some targets the upper 32 bits are not reliable */ 294: if (ADRENO_GPUREV(adreno_dev) > ADRENO_REV_A530) 295: cmds[1] |= (1 << 30) | (2 << 18); 296: 297: cmds[2] = lower_32_bits(gpuaddr); 298: cmds[3] = upper_32_bits(gpuaddr); 299: 300: return 4; 301: } 302: 303: /* This is the maximum possible size for 64 bit targets */ 304: #define PROFILE_IB_DWORDS 4 305: #define PROFILE_IB_SLOTS (PAGE_SIZE / (PROFILE_IB_DWORDS << 2)) 306: 307: static u64 a5xx_get_user_profiling_ib(struct adreno_device *adreno_dev, 308: struct adreno_ringbuffer *rb, struct kgsl_drawobj_cmd *cmdobj, 309: u32 target_offset, u32 *cmds) 310: { 311: u32 offset, *ib, dwords; 312: u64 gpuaddr; 313: 314: if (IS_ERR(rb->profile_desc)) 315: return 0; 316: 317: offset = rb->profile_index * (PROFILE_IB_DWORDS << 2); 318: ib = rb->profile_desc->hostptr + offset; 319: gpuaddr = rb->profile_desc->gpuaddr + offset; 320: dwords = a5xx_get_alwayson_counter(adreno_dev, ib, 321: cmdobj->profiling_buffer_gpuaddr + target_offset); 322: 323: cmds[0] = cp_type7_packet(CP_INDIRECT_BUFFER_PFE, 3); 324: cmds[1] = lower_32_bits(gpuaddr); 325: cmds[2] = upper_32_bits(gpuaddr); 326: cmds[3] = dwords; 327: 328: rb->profile_index = (rb->profile_index + 1) % PROFILE_IB_SLOTS; 329: 330: return 4; 331: } 332: 333: static int a5xx_rb_context_switch(struct adreno_device *adreno_dev, 334: struct adreno_ringbuffer *rb, 335: struct adreno_context *drawctxt) 336: { 337: struct kgsl_pagetable *pagetable = 338: adreno_drawctxt_get_pagetable(drawctxt); 339: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 340: int count = 0; 341: u32 cmds[32]; 342: 343: if (adreno_drawctxt_get_pagetable(rb->drawctxt_active) != pagetable) 344: count += a5xx_rb_pagetable_switch(device, drawctxt, 345: rb, pagetable, cmds); 346: 347: cmds[count++] = cp_type7_packet(CP_NOP, 1); 348: cmds[count++] = CONTEXT_TO_MEM_IDENTIFIER; 349: 350: cmds[count++] = cp_type7_packet(CP_MEM_WRITE, 3); 351: cmds[count++] = lower_32_bits(MEMSTORE_RB_GPU_ADDR(device, rb, 352: current_context)); 353: cmds[count++] = upper_32_bits(MEMSTORE_RB_GPU_ADDR(device, rb, 354: current_context)); 355: cmds[count++] = drawctxt->base.id; 356: 357: cmds[count++] = cp_type7_packet(CP_MEM_WRITE, 3); 358: cmds[count++] = lower_32_bits(MEMSTORE_ID_GPU_ADDR(device, 359: KGSL_MEMSTORE_GLOBAL, current_context)); 360: cmds[count++] = upper_32_bits(MEMSTORE_ID_GPU_ADDR(device, 361: KGSL_MEMSTORE_GLOBAL, current_context)); 362: cmds[count++] = drawctxt->base.id; 363: 364: cmds[count++] = cp_type4_packet(A5XX_UCHE_INVALIDATE0, 1); 365: cmds[count++] = 0x12; 366: 367: return a5xx_ringbuffer_addcmds(adreno_dev, rb, NULL, F_NOTPROTECTED, 368: cmds, count, 0, NULL); 369: } 370: 371: static int a5xx_drawctxt_switch(struct adreno_device *adreno_dev, 372: struct adreno_ringbuffer *rb, 373: struct adreno_context *drawctxt) 374: { 375: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 376: 377: if (rb->drawctxt_active == drawctxt) 378: return 0; 379: 380: if (kgsl_context_detached(&drawctxt->base)) 381: return -ENOENT; 382: 383: if (!_kgsl_context_get(&drawctxt->base)) 384: return -ENOENT; 385: 386: trace_adreno_drawctxt_switch(rb, drawctxt); 387: 388: a5xx_rb_context_switch(adreno_dev, rb, drawctxt); MATCH LINES: 437, 457, 460, 476, 483, 496 425: struct list_head *tmp; 426: 427: list_for_each(tmp, &cmdobj->cmdlist) 428: numibs++; 429: } 430: 431: cmds = kmalloc((A5XX_COMMAND_DWORDS + (numibs * 5)) << 2, GFP_KERNEL); 432: if (!cmds) { 433: ret = -ENOMEM; 434: goto done; 435: } 436: 437: cmds[index++] = cp_type7_packet(CP_NOP, 1); 438: cmds[index++] = START_IB_IDENTIFIER; 439: 440: /* Kernel profiling: 4 dwords */ 441: if (IS_KERNEL_PROFILE(flags)) 442: index += A5XX_KERNEL_PROFILE(adreno_dev, cmdobj, &cmds[index], 443: started); 444: 445: /* User profiling: 4 dwords */ 446: if (IS_USER_PROFILE(flags)) 447: index += A5XX_USER_PROFILE_IB(adreno_dev, rb, cmdobj, 448: &cmds[index], gpu_ticks_submitted); 449: 450: if (numibs) { 451: struct kgsl_memobj_node *ib; 452: 453: list_for_each_entry(ib, &cmdobj->cmdlist, node) { 454: if (ib->priv & MEMOBJ_SKIP || 455: (ib->flags & KGSL_CMDLIST_CTXTSWITCH_PREAMBLE 456: && !IS_PREAMBLE(flags))) 457: cmds[index++] = cp_type7_packet(CP_NOP, 4); 458: 459: cmds[index++] = 460: cp_type7_packet(CP_INDIRECT_BUFFER_PFE, 3); 461: cmds[index++] = lower_32_bits(ib->gpuaddr); 462: cmds[index++] = upper_32_bits(ib->gpuaddr); 463: 464: /* Double check that IB_PRIV is never set */ 465: cmds[index++] = (ib->size >> 2) & 0xfffff; 466: } 467: } 468: 469: /* 470: * SRM -- set render mode (ex binning, direct render etc) 471: * SRM is set by UMD usually at start of IB to tell CP the type of 472: * preemption. 473: * KMD needs to set SRM to NULL to indicate CP that rendering is 474: * done by IB. 475: */ 476: cmds[index++] = cp_type7_packet(CP_SET_RENDER_MODE, 5); 477: cmds[index++] = 0; 478: cmds[index++] = 0; 479: cmds[index++] = 0; 480: cmds[index++] = 0; 481: cmds[index++] = 0; 482: 483: cmds[index++] = cp_type7_packet(CP_YIELD_ENABLE, 1); 484: cmds[index++] = 1; 485: 486: /* 4 dwords */ 487: if (IS_KERNEL_PROFILE(flags)) 488: index += A5XX_KERNEL_PROFILE(adreno_dev, cmdobj, &cmds[index], 489: retired); 490: 491: /* 4 dwords */ 492: if (IS_USER_PROFILE(flags)) 493: index += A5XX_USER_PROFILE_IB(adreno_dev, rb, cmdobj, 494: &cmds[index], gpu_ticks_retired); 495: 496: cmds[index++] = cp_type7_packet(CP_NOP, 1); 497: cmds[index++] = END_IB_IDENTIFIER; 498: 499: ret = a5xx_drawctxt_switch(adreno_dev, rb, drawctxt); 500: 501: /* 502: * In the unlikely event of an error in the drawctxt switch, 503: * treat it like a hang 504: */ 505: if (ret) { 506: /* 507: * It is "normal" to get a -ENOSPC or a -ENOENT. Don't log it, 508: * the upper layers know how to handle it 509: */ 510: if (ret != -ENOSPC && ret != -ENOENT) 511: dev_err(device->dev, 512: "Unable to switch draw context: %d\n", 513: ret); 514: goto done; 515: } 516: 517: adreno_drawobj_set_constraint(device, drawobj); 518: 519: ret = a5xx_ringbuffer_addcmds(adreno_dev, drawctxt->rb, drawctxt, 520: flags, cmds, index, drawobj->timestamp, time); --- FILE: \adreno_a6xx.c | HITS: 593 --- MATCH LINES: 21, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 124, 125, 126, 127, 128, 129, 130, 134, 137, 149, 157, 177, 191, 219, 226, 235, 241, 249, 251, 255, 260, 262, 270, 275, 279, 291, 294, 297, 298, 306 9: #include 10: #include 11: #include 12: #include 13: #include 14: #include 15: #if (KERNEL_VERSION(6, 17, 0) <= LINUX_VERSION_CODE) 16: #include 17: #endif 18: 19: #include "adreno.h" 20: #include "adreno_a6xx.h" 21: #include "adreno_a6xx_hwsched.h" 22: #include "adreno_pm4types.h" 23: #include "adreno_trace.h" 24: #include "kgsl_gmu_core.h" 25: #include "kgsl_trace.h" 26: #include "kgsl_util.h" 27: 28: /* IFPC & Preemption static powerup restore list */ 29: static u32 a6xx_pwrup_reglist[] = { 30: A6XX_VSC_ADDR_MODE_CNTL, 31: A6XX_GRAS_ADDR_MODE_CNTL, 32: A6XX_RB_ADDR_MODE_CNTL, 33: A6XX_PC_ADDR_MODE_CNTL, 34: A6XX_HLSQ_ADDR_MODE_CNTL, 35: A6XX_VFD_ADDR_MODE_CNTL, 36: A6XX_VPC_ADDR_MODE_CNTL, 37: A6XX_UCHE_ADDR_MODE_CNTL, 38: A6XX_SP_ADDR_MODE_CNTL, 39: A6XX_TPL1_ADDR_MODE_CNTL, 40: A6XX_UCHE_WRITE_RANGE_MAX_LO, 41: A6XX_UCHE_WRITE_RANGE_MAX_HI, 42: A6XX_UCHE_TRAP_BASE_LO, 43: A6XX_UCHE_TRAP_BASE_HI, 44: A6XX_UCHE_WRITE_THRU_BASE_LO, 45: A6XX_UCHE_WRITE_THRU_BASE_HI, 46: A6XX_UCHE_GMEM_RANGE_MIN_LO, 47: A6XX_UCHE_GMEM_RANGE_MIN_HI, 48: A6XX_UCHE_GMEM_RANGE_MAX_LO, 49: A6XX_UCHE_GMEM_RANGE_MAX_HI, 50: A6XX_UCHE_FILTER_CNTL, 51: A6XX_UCHE_CACHE_WAYS, 52: A6XX_UCHE_MODE_CNTL, 53: A6XX_RB_NC_MODE_CNTL, 54: A6XX_TPL1_NC_MODE_CNTL, 55: A6XX_SP_NC_MODE_CNTL, 56: A6XX_PC_DBG_ECO_CNTL, 57: A6XX_RB_CONTEXT_SWITCH_GMEM_SAVE_RESTORE, 58: A6XX_UCHE_GBIF_GX_CONFIG, 59: A6XX_UCHE_CLIENT_PF, 60: }; 61: 62: /* IFPC only static powerup restore list */ 63: static u32 a6xx_ifpc_pwrup_reglist[] = { 64: A6XX_CP_CHICKEN_DBG, 65: A6XX_CP_DBG_ECO_CNTL, 66: A6XX_CP_PROTECT_CNTL, 67: A6XX_CP_PROTECT_REG, 68: A6XX_CP_PROTECT_REG+1, 69: A6XX_CP_PROTECT_REG+2, 70: A6XX_CP_PROTECT_REG+3, 71: A6XX_CP_PROTECT_REG+4, 72: A6XX_CP_PROTECT_REG+5, 73: A6XX_CP_PROTECT_REG+6, 74: A6XX_CP_PROTECT_REG+7, 75: A6XX_CP_PROTECT_REG+8, 76: A6XX_CP_PROTECT_REG+9, 77: A6XX_CP_PROTECT_REG+10, 78: A6XX_CP_PROTECT_REG+11, 79: A6XX_CP_PROTECT_REG+12, 80: A6XX_CP_PROTECT_REG+13, 81: A6XX_CP_PROTECT_REG+14, 82: A6XX_CP_PROTECT_REG+15, 83: A6XX_CP_PROTECT_REG+16, 84: A6XX_CP_PROTECT_REG+17, 85: A6XX_CP_PROTECT_REG+18, 86: A6XX_CP_PROTECT_REG+19, 87: A6XX_CP_PROTECT_REG+20, 88: A6XX_CP_PROTECT_REG+21, 89: A6XX_CP_PROTECT_REG+22, 90: A6XX_CP_PROTECT_REG+23, 91: A6XX_CP_PROTECT_REG+24, 92: A6XX_CP_PROTECT_REG+25, 93: A6XX_CP_PROTECT_REG+26, 94: A6XX_CP_PROTECT_REG+27, 95: A6XX_CP_PROTECT_REG+28, 96: A6XX_CP_PROTECT_REG+29, 97: A6XX_CP_PROTECT_REG+30, 98: A6XX_CP_PROTECT_REG+31, 99: A6XX_CP_AHB_CNTL, 100: }; 101: 102: /* Applicable to a620, a621, a622, a642l, a643, a650 and a660 */ 103: static u32 a650_ifpc_pwrup_reglist[] = { 104: A6XX_CP_PROTECT_REG+32, 105: A6XX_CP_PROTECT_REG+33, 106: A6XX_CP_PROTECT_REG+34, 107: A6XX_CP_PROTECT_REG+35, 108: A6XX_CP_PROTECT_REG+36, 109: A6XX_CP_PROTECT_REG+37, 110: A6XX_CP_PROTECT_REG+38, 111: A6XX_CP_PROTECT_REG+39, 112: A6XX_CP_PROTECT_REG+40, 113: A6XX_CP_PROTECT_REG+41, 114: A6XX_CP_PROTECT_REG+42, 115: A6XX_CP_PROTECT_REG+43, 116: A6XX_CP_PROTECT_REG+44, 117: A6XX_CP_PROTECT_REG+45, 118: A6XX_CP_PROTECT_REG+46, 119: A6XX_CP_PROTECT_REG+47, 120: }; 121: 122: /* Applicable to a620, a621, a622, a642l, a643, a650 and a660 */ 123: static u32 a650_pwrup_reglist[] = { 124: A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_0, 125: A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_1, 126: A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_2, 127: A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_3, 128: A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_4, 129: A6XX_UCHE_CMDQ_CONFIG, 130: A6XX_SP_DBG_ECO_CNTL, 131: }; 132: 133: static u32 a615_pwrup_reglist[] = { 134: A6XX_UCHE_GBIF_GX_CONFIG, 135: }; 136: 137: int a6xx_fenced_write(struct adreno_device *adreno_dev, u32 offset, 138: u32 value, u32 mask) 139: { 140: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 141: unsigned int status, i; 142: u64 ts1, ts2; 143: 144: kgsl_regwrite(device, offset, value); 145: 146: if (!gmu_core_isenabled(device)) 147: return 0; 148: 149: ts1 = a6xx_read_alwayson(adreno_dev); 150: for (i = 0; i < GMU_CORE_LONG_WAKEUP_RETRY_LIMIT; i++) { 151: /* 152: * Make sure the previous register write is posted before 153: * checking the fence status 154: */ 155: mb(); 156: 157: kgsl_regread(device, A6XX_GMU_AHB_FENCE_STATUS, &status); 158: 159: /* 160: * If !writedropped0/1, then the write to fenced register 161: * was successful 162: */ 163: if (!(status & mask)) 164: break; 165: 166: /* Wait a small amount of time before trying again */ 167: udelay(GMU_CORE_WAKEUP_DELAY_US); 168: 169: /* Try to write the fenced register again */ 170: kgsl_regwrite(device, offset, value); 171: } 172: 173: if (i < GMU_CORE_SHORT_WAKEUP_RETRY_LIMIT) 174: return 0; 175: 176: if (i == GMU_CORE_LONG_WAKEUP_RETRY_LIMIT) { 177: ts2 = a6xx_read_alwayson(adreno_dev); 178: dev_err(adreno_dev->dev.dev, 179: "Timed out waiting %d usecs to write fenced register 0x%x, timestamps: %llx %llx\n", 180: i * GMU_CORE_WAKEUP_DELAY_US, offset, ts1, ts2); 181: return -ETIMEDOUT; 182: } 183: 184: dev_err(adreno_dev->dev.dev, 185: "Waited %d usecs to write fenced register 0x%x\n", 186: i * GMU_CORE_WAKEUP_DELAY_US, offset); 187: 188: return 0; 189: } 190: 191: static void a6xx_calc_ubwc_config_legacy(struct adreno_device *adreno_dev) 192: { 193: struct adreno_ubwc_props *ubwc_props = &adreno_dev->ubwc_props; 194: 195: switch (adreno_dev->ubwc_mode) { 196: case KGSL_UBWC_1_0: 197: ubwc_props->mode = 1; 198: break; 199: case KGSL_UBWC_2_0: 200: ubwc_props->mode = 0; 201: break; 202: case KGSL_UBWC_3_0: 203: ubwc_props->mode = 0; 204: ubwc_props->amsbc = true; 205: break; 206: case KGSL_UBWC_4_0: 207: ubwc_props->mode = 0; 208: ubwc_props->rgb565_predicator = true; 209: ubwc_props->amsbc = true; 210: if (adreno_is_a663(adreno_dev)) 211: ubwc_props->level2_swizzling_dis = 1; 212: break; 213: default: 214: break; 215: } 216: } 217: 218: #if (KERNEL_VERSION(7, 3, 0) <= LINUX_VERSION_CODE) 219: static void a6xx_calc_ubwc_config(struct adreno_device *adreno_dev) 220: { 221: const struct qcom_ubwc_cfg_data *cfg = 222: (const struct qcom_ubwc_cfg_data *)adreno_dev->ubwc_cfg_data; 223: struct adreno_ubwc_props *ubwc_props = &adreno_dev->ubwc_props; 224: 225: if (!cfg) 226: return a6xx_calc_ubwc_config_legacy(adreno_dev); 227: 228: ubwc_props->mode = qcom_ubwc_get_ubwc_mode(cfg); 229: ubwc_props->amsbc = qcom_ubwc_enable_amsbc(cfg); 230: ubwc_props->rgb565_predicator = cfg->ubwc_enc_version >= UBWC_4_0; 231: ubwc_props->level2_swizzling_dis = 232: !(qcom_ubwc_swizzle(cfg) & UBWC_SWIZZLE_ENABLE_LVL2); 233: } 234: #elif (KERNEL_VERSION(6, 17, 0) <= LINUX_VERSION_CODE) 235: static void a6xx_calc_ubwc_config(struct adreno_device *adreno_dev) 236: { 237: struct qcom_ubwc_cfg_data *cfg = (struct qcom_ubwc_cfg_data *)adreno_dev->ubwc_cfg_data; 238: struct adreno_ubwc_props *ubwc_props = &adreno_dev->ubwc_props; 239: 240: if (!cfg) 241: return a6xx_calc_ubwc_config_legacy(adreno_dev); 242: 243: ubwc_props->mode = (cfg->ubwc_enc_version == UBWC_1_0) ? 1 : 0; 244: ubwc_props->amsbc = cfg->ubwc_enc_version >= UBWC_3_0; 245: ubwc_props->rgb565_predicator = cfg->ubwc_enc_version >= UBWC_4_0; 246: ubwc_props->level2_swizzling_dis = !(cfg->ubwc_swizzle & UBWC_SWIZZLE_ENABLE_LVL2); 247: } 248: #else 249: static void a6xx_calc_ubwc_config(struct adreno_device *adreno_dev) 250: { 251: a6xx_calc_ubwc_config_legacy(adreno_dev); 252: } 253: #endif 254: 255: int a6xx_init(struct adreno_device *adreno_dev) 256: { 257: adreno_dev->cooperative_reset = ADRENO_FEATURE(adreno_dev, 258: ADRENO_COOP_RESET); 259: 260: a6xx_calc_ubwc_config(adreno_dev); 261: 262: a6xx_crashdump_init(adreno_dev); 263: 264: return adreno_allocate_global(KGSL_DEVICE(adreno_dev), 265: &adreno_dev->pwrup_reglist, 266: PAGE_SIZE, 0, 0, KGSL_MEMDESC_PRIVILEGED, 267: "powerup_register_list"); 268: } 269: 270: static int a6xx_nogmu_init(struct adreno_device *adreno_dev) 271: { 272: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 273: int ret; 274: 275: ret = a6xx_ringbuffer_init(adreno_dev); 276: if (ret) 277: return ret; 278: 279: ret = a6xx_microcode_read(adreno_dev); 280: if (ret) 281: return ret; 282: 283: /* Try to map the GMU wrapper region if applicable */ 284: ret = kgsl_regmap_add_region(&device->regmap, device->pdev, 285: "gmu_wrapper", -EINVAL, NULL, NULL); 286: if (ret && ret != -ENODEV) 287: dev_err(device->dev, "Couldn't map the GMU wrapper registers\n"); 288: 289: adreno_create_profile_buffer(adreno_dev); 290: 291: return a6xx_init(adreno_dev); 292: } 293: 294: static void a6xx_protect_init(struct adreno_device *adreno_dev) 295: { 296: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 297: const struct adreno_a6xx_core *a6xx_core = to_a6xx_core(adreno_dev); 298: const struct adreno_protected_regs *regs = a6xx_core->protected_regs; 299: int i; 300: 301: /* 302: * Enable access protection to privileged registers, fault on an access 303: * protect violation and select the last span to protect from the start 304: * address all the way to the end of the register address space 305: */ 306: kgsl_regwrite(device, A6XX_CP_PROTECT_CNTL, 307: (1 << 0) | (1 << 1) | (1 << 3)); 308: 309: /* Program each register defined by the core definition */ 310: for (i = 0; regs[i].reg; i++) { 311: u32 count; 312: 313: /* 314: * This is the offset of the end register as counted from the 315: * start, i.e. # of registers in the range - 1 316: */ 317: count = regs[i].end - regs[i].start; 318: 319: kgsl_regwrite(device, regs[i].reg, 320: (regs[i].start & 0x3ffff) | ((count & 0x1fff) << 18) | 321: (regs[i].noaccess << 31)); 322: } 323: } 324: 325: static inline unsigned int 326: __get_rbbm_clock_cntl_on(struct adreno_device *adreno_dev) 327: { 328: if (adreno_is_a630(adreno_dev)) 329: return 0x8AA8AA02; 330: else if (adreno_is_a612_family(adreno_dev) || adreno_is_a610_family(adreno_dev)) MATCH LINES: 392, 394, 398, 401, 409, 411, 413, 415, 419, 428, 433, 451, 455, 456, 457, 467, 472, 476, 482, 484, 486, 494, 503, 525, 536, 538, 540, 542, 547, 566, 567, 568, 569, 571, 578, 579, 581, 583, 591, 595, 598, 600, 603, 630, 633, 636, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 657, 658, 661, 664, 670, 671, 672, 673, 674, 675, 683, 685, 686, 689, 692, 693, 698, 699, 701, 702, 704, 705, 709, 712, 713, 714, 719, 720, 722, 723, 725, 729, 730, 734, 738, 741, 745, 750, 752, 761, 772, 779, 783, 788, 791, 792, 794, 799, 800, 802, 804, 806, 810, 812, 815, 816, 820, 824, 831, 832, 833, 835, 845, 846, 847, 849, 852, 857, 858, 864, 867, 869, 875, 884, 898, 903, 916, 917, 926 380: 381: if ((rev == ADRENO_REV_A620) || adreno_is_a640(adreno_dev) || 382: adreno_is_a650(adreno_dev)) 383: return 0x00000002; 384: 385: return 0x00000000; 386: } 387: 388: static void set_holi_sptprac_clock(struct kgsl_device *device, bool enable) 389: { 390: u32 val = 0; 391: 392: kgsl_regread(device, A6XX_GPU_GMU_GX_SPTPRAC_CLOCK_CONTROL, &val); 393: val &= ~1; 394: kgsl_regwrite(device, A6XX_GPU_GMU_GX_SPTPRAC_CLOCK_CONTROL, 395: val | (enable ? 1 : 0)); 396: } 397: 398: static void a6xx_hwcg_set(struct adreno_device *adreno_dev, bool on) 399: { 400: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 401: const struct adreno_a6xx_core *a6xx_core = to_a6xx_core(adreno_dev); 402: unsigned int value; 403: int i; 404: 405: if (!adreno_dev->hwcg_enabled) 406: on = false; 407: 408: if (gmu_core_isenabled(device)) { 409: gmu_core_regwrite(device, A6XX_GPU_GMU_AO_GMU_CGC_MODE_CNTL, 410: on ? __get_gmu_ao_cgc_mode_cntl(adreno_dev) : 0); 411: gmu_core_regwrite(device, A6XX_GPU_GMU_AO_GMU_CGC_DELAY_CNTL, 412: on ? __get_gmu_ao_cgc_delay_cntl(adreno_dev) : 0); 413: gmu_core_regwrite(device, A6XX_GPU_GMU_AO_GMU_CGC_HYST_CNTL, 414: on ? __get_gmu_ao_cgc_hyst_cntl(adreno_dev) : 0); 415: gmu_core_regwrite(device, A6XX_GMU_CX_GMU_WFI_CONFIG, 416: on ? __get_gmu_wfi_config(adreno_dev) : 0); 417: } 418: 419: kgsl_regread(device, A6XX_RBBM_CLOCK_CNTL, &value); 420: 421: /* 422: * GBIF L2 CGC control is not part of the UCHE and is enabled by 423: * default. Hence modify the register when CGC disabled is 424: * requested. 425: * Note: The below programming will need modification in case 426: * of change in the register reset value in future. 427: */ 428: kgsl_regrmw(device, A6XX_UCHE_GBIF_GX_CONFIG, GENMASK(18, 16), 429: FIELD_PREP(GENMASK(18, 16), on ? 2 : 0)); 430: 431: /* Recommended to always disable GBIF_CX_CONFIG for gen6_3_26_0 */ 432: if (!on || adreno_is_gen6_3_26_0(adreno_dev)) 433: kgsl_regrmw(device, A6XX_GBIF_CX_CONFIG, GENMASK(18, 16), 434: FIELD_PREP(GENMASK(18, 16), 0)); 435: 436: if (value == __get_rbbm_clock_cntl_on(adreno_dev) && on) 437: return; 438: 439: if (value == 0 && !on) 440: return; 441: 442: /* 443: * Disable SP clock before programming HWCG registers. 444: * A612, A610 and A702 family GPU is not having the GX power domain. 445: * Hence skip GMU_GX registers for A612, A610 and A702 family. 446: */ 447: 448: if (gmu_core_isenabled(device) && !adreno_is_a612_family(adreno_dev) && 449: !adreno_is_a610_family(adreno_dev) && !adreno_is_a702_family(adreno_dev)) 450: gmu_core_regrmw(device, 451: A6XX_GPU_GMU_GX_SPTPRAC_CLOCK_CONTROL, 1, 0); 452: else if (adreno_is_a619_holi(adreno_dev)) 453: set_holi_sptprac_clock(device, false); 454: 455: for (i = 0; i < a6xx_core->hwcg_count; i++) 456: kgsl_regwrite(device, a6xx_core->hwcg[i].offset, 457: on ? a6xx_core->hwcg[i].val : 0); 458: 459: /* 460: * Enable SP clock after programming HWCG registers. 461: * A612, A610 and A702 family GPU is not having the GX power domain. 462: * Hence skip GMU_GX registers for A612, A610 and A702 family. 463: */ 464: if (gmu_core_isenabled(device) && !adreno_is_a612_family(adreno_dev) && 465: !adreno_is_a610_family(adreno_dev) && !adreno_is_a702_family(adreno_dev)) 466: gmu_core_regrmw(device, 467: A6XX_GPU_GMU_GX_SPTPRAC_CLOCK_CONTROL, 0, 1); 468: else if (adreno_is_a619_holi(adreno_dev)) 469: set_holi_sptprac_clock(device, true); 470: 471: /* enable top level HWCG */ 472: kgsl_regwrite(device, A6XX_RBBM_CLOCK_CNTL, 473: on ? __get_rbbm_clock_cntl_on(adreno_dev) : 0); 474: } 475: 476: struct a6xx_reglist_list { 477: u32 *regs; 478: u32 count; 479: }; 480: 481: #define REGLIST(_a) \ 482: ((struct a6xx_reglist_list) { .regs = _a, .count = ARRAY_SIZE(_a), }) 483: 484: static void a6xx_patch_pwrup_reglist(struct adreno_device *adreno_dev) 485: { 486: struct a6xx_reglist_list reglist[4]; 487: void *ptr = adreno_dev->pwrup_reglist->hostptr; 488: struct cpu_gpu_lock *lock = ptr; 489: int items = 0, i, j; 490: u32 *dest = ptr + sizeof(*lock); 491: u16 list_offset = 0; 492: 493: /* Static IFPC-only registers */ 494: reglist[items] = REGLIST(a6xx_ifpc_pwrup_reglist); 495: list_offset += reglist[items++].count * 2; 496: 497: if (adreno_is_a650_family(adreno_dev)) { 498: reglist[items] = REGLIST(a650_ifpc_pwrup_reglist); 499: list_offset += reglist[items++].count * 2; 500: } 501: 502: /* Static IFPC + preemption registers */ 503: reglist[items++] = REGLIST(a6xx_pwrup_reglist); 504: 505: /* Add target specific registers */ 506: if (adreno_is_a615_family(adreno_dev)) 507: reglist[items++] = REGLIST(a615_pwrup_reglist); 508: else if (adreno_is_a650_family(adreno_dev)) 509: reglist[items++] = REGLIST(a650_pwrup_reglist); 510: 511: /* 512: * For each entry in each of the lists, write the offset and the current 513: * register value into the GPU buffer 514: */ 515: for (i = 0; i < items; i++) { 516: u32 *r = reglist[i].regs; 517: 518: for (j = 0; j < reglist[i].count; j++) { 519: *dest++ = r[j]; 520: kgsl_regread(KGSL_DEVICE(adreno_dev), r[j], dest++); 521: } 522: 523: lock->list_length += reglist[i].count * 2; 524: 525: if ((r == a6xx_ifpc_pwrup_reglist) || (r == a650_ifpc_pwrup_reglist)) { 526: u32 cs_len = adreno_coresight_patch_pwrup_reglist(adreno_dev, dest); 527: 528: cs_len = cs_len * 2; 529: lock->list_length += cs_len; 530: list_offset += cs_len; 531: dest += cs_len; 532: } 533: } 534: 535: if (adreno_is_a630(adreno_dev)) { 536: *dest++ = A6XX_RBBM_VBIF_CLIENT_QOS_CNTL; 537: kgsl_regread(KGSL_DEVICE(adreno_dev), 538: A6XX_RBBM_VBIF_CLIENT_QOS_CNTL, dest++); 539: } else { 540: *dest++ = A6XX_RBBM_GBIF_CLIENT_QOS_CNTL; 541: kgsl_regread(KGSL_DEVICE(adreno_dev), 542: A6XX_RBBM_GBIF_CLIENT_QOS_CNTL, dest++); 543: } 544: 545: lock->list_length += 2; 546: 547: *dest++ = A6XX_RBBM_PERFCTR_CNTL; 548: *dest++ = 1; 549: lock->list_length += 2; 550: 551: /* 552: * The overall register list is composed of 553: * 1. Static IFPC-only registers 554: * 2. Static IFPC + preemption registers 555: * 3. Dynamic IFPC + preemption registers (ex: perfcounter selects) 556: * 557: * The CP views the second and third entries as one dynamic list 558: * starting from list_offset. list_length should be the total dwords in 559: * all the lists and list_offset should be specified as the size in 560: * dwords of the first entry in the list. 561: */ 562: lock->list_offset = list_offset; 563: } 564: 565: 566: static void a6xx_llc_configure_gpu_scid(struct adreno_device *adreno_dev); 567: static void a6xx_llc_configure_gpuhtw_scid(struct adreno_device *adreno_dev); 568: static void a6xx_llc_configure_gpumv_scid(struct adreno_device *adreno_dev); 569: static void a6xx_llc_enable_overrides(struct adreno_device *adreno_dev); 570: 571: static void a6xx_set_secvid(struct kgsl_device *device) 572: { 573: static bool set; 574: 575: if (set || !device->mmu.secured) 576: return; 577: 578: kgsl_regwrite(device, A6XX_RBBM_SECVID_TSB_CNTL, 0x0); 579: kgsl_regwrite(device, A6XX_RBBM_SECVID_TSB_TRUSTED_BASE_LO, 580: lower_32_bits(KGSL_IOMMU_SECURE_BASE32)); 581: kgsl_regwrite(device, A6XX_RBBM_SECVID_TSB_TRUSTED_BASE_HI, 582: upper_32_bits(KGSL_IOMMU_SECURE_BASE32)); 583: kgsl_regwrite(device, A6XX_RBBM_SECVID_TSB_TRUSTED_SIZE, 584: FIELD_PREP(GENMASK(31, 12), 585: (KGSL_IOMMU_SECURE_SIZE(&device->mmu) / SZ_4K))); 586: 587: if (ADRENO_QUIRK(ADRENO_DEVICE(device), ADRENO_QUIRK_SECVID_SET_ONCE)) 588: set = true; 589: } 590: 591: static void a6xx_deassert_gbif_halt(struct adreno_device *adreno_dev) 592: { 593: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 594: 595: kgsl_regwrite(device, A6XX_GBIF_HALT, 0x0); 596: 597: if (adreno_is_a619_holi(adreno_dev)) 598: kgsl_regwrite(device, A6XX_RBBM_GPR0_CNTL, 0x0); 599: else 600: kgsl_regwrite(device, A6XX_RBBM_GBIF_HALT, 0x0); 601: } 602: 603: bool a6xx_gx_is_on(struct adreno_device *adreno_dev) 604: { 605: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 606: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 607: bool gdsc_on, clk_on; 608: 609: clk_on = __clk_is_enabled(pwr->grp_clks[0]); 610: 611: if (pwr->gx_pd) 612: gdsc_on = kgsl_genpd_is_enabled(pwr->gx_pd); 613: else 614: gdsc_on = regulator_is_enabled(pwr->gx_regulator); 615: 616: return (gdsc_on & clk_on); 617: } 618: 619: /* 620: * Some targets support marking certain transactions as always privileged which 621: * allows us to mark more memory as privileged without having to explicitly set 622: * the APRIV bit. For those targets, choose the following transactions to be 623: * privileged by default: 624: * CDWRITE [6:6] - Crashdumper writes 625: * CDREAD [5:5] - Crashdumper reads 626: * RBRPWB [3:3] - RPTR shadow writes 627: * RBPRIVLEVEL [2:2] - Memory accesses from PM4 packets in the ringbuffer 628: * RBFETCH [1:1] - Ringbuffer reads 629: */ 630: #define A6XX_APRIV_DEFAULT \ 631: ((1 << 6) | (1 << 5) | (1 << 3) | (1 << 2) | (1 << 1)) 632: 633: void a6xx_start(struct adreno_device *adreno_dev) 634: { 635: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 636: const struct adreno_a6xx_core *a6xx_core = to_a6xx_core(adreno_dev); 637: unsigned int hbb_hi = 0, hbb_lo = 0; 638: unsigned int uavflagprd_inv; 639: struct adreno_ubwc_props *ubwc_props = &adreno_dev->ubwc_props; 640: u32 mal = adreno_dev->mal; 641: 642: /* Enable 64 bit addressing */ 643: kgsl_regwrite(device, A6XX_CP_ADDR_MODE_CNTL, 0x1); 644: kgsl_regwrite(device, A6XX_VSC_ADDR_MODE_CNTL, 0x1); 645: kgsl_regwrite(device, A6XX_GRAS_ADDR_MODE_CNTL, 0x1); 646: kgsl_regwrite(device, A6XX_RB_ADDR_MODE_CNTL, 0x1); 647: kgsl_regwrite(device, A6XX_PC_ADDR_MODE_CNTL, 0x1); 648: kgsl_regwrite(device, A6XX_HLSQ_ADDR_MODE_CNTL, 0x1); 649: kgsl_regwrite(device, A6XX_VFD_ADDR_MODE_CNTL, 0x1); 650: kgsl_regwrite(device, A6XX_VPC_ADDR_MODE_CNTL, 0x1); 651: kgsl_regwrite(device, A6XX_UCHE_ADDR_MODE_CNTL, 0x1); 652: kgsl_regwrite(device, A6XX_SP_ADDR_MODE_CNTL, 0x1); 653: kgsl_regwrite(device, A6XX_TPL1_ADDR_MODE_CNTL, 0x1); 654: kgsl_regwrite(device, A6XX_RBBM_SECVID_TSB_ADDR_MODE_CNTL, 0x1); 655: 656: /* Set up VBIF registers from the GPU core definition */ 657: kgsl_regmap_multi_write(&device->regmap, a6xx_core->vbif, 658: a6xx_core->vbif_count); 659: 660: if (ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_LIMIT_UCHE_GBIF_RW)) 661: kgsl_regwrite(device, A6XX_UCHE_GBIF_GX_CONFIG, 0x10200F9); 662: 663: /* Make all blocks contribute to the GPU BUSY perf counter */ 664: kgsl_regwrite(device, A6XX_RBBM_PERFCTR_GPU_BUSY_MASKED, 0xFFFFFFFF); 665: 666: /* 667: * Set UCHE_WRITE_THRU_BASE to the UCHE_TRAP_BASE effectively 668: * disabling L2 bypass 669: */ 670: kgsl_regwrite(device, A6XX_UCHE_WRITE_RANGE_MAX_LO, 0xffffffc0); 671: kgsl_regwrite(device, A6XX_UCHE_WRITE_RANGE_MAX_HI, 0x0001ffff); 672: kgsl_regwrite(device, A6XX_UCHE_TRAP_BASE_LO, 0xfffff000); 673: kgsl_regwrite(device, A6XX_UCHE_TRAP_BASE_HI, 0x0001ffff); 674: kgsl_regwrite(device, A6XX_UCHE_WRITE_THRU_BASE_LO, 0xfffff000); 675: kgsl_regwrite(device, A6XX_UCHE_WRITE_THRU_BASE_HI, 0x0001ffff); 676: 677: /* 678: * Some A6xx targets no longer use a programmed UCHE GMEM base 679: * address, so only write the registers if this address is 680: * non-zero. 681: */ 682: if (adreno_dev->uche_gmem_base) { 683: kgsl_regwrite(device, A6XX_UCHE_GMEM_RANGE_MIN_LO, 684: adreno_dev->uche_gmem_base); 685: kgsl_regwrite(device, A6XX_UCHE_GMEM_RANGE_MIN_HI, 0x0); 686: kgsl_regwrite(device, A6XX_UCHE_GMEM_RANGE_MAX_LO, 687: adreno_dev->uche_gmem_base + 688: adreno_dev->gpucore->gmem_size - 1); 689: kgsl_regwrite(device, A6XX_UCHE_GMEM_RANGE_MAX_HI, 0x0); 690: } 691: 692: kgsl_regwrite(device, A6XX_UCHE_FILTER_CNTL, 0x804); 693: kgsl_regwrite(device, A6XX_UCHE_CACHE_WAYS, 0x4); 694: 695: /* ROQ sizes are twice as big on a640/a680 than on a630 */ 696: if (adreno_is_a612_family(adreno_dev) || adreno_is_a610_family(adreno_dev) || 697: adreno_is_a702_family(adreno_dev)) { 698: kgsl_regwrite(device, A6XX_CP_ROQ_THRESHOLDS_2, 0x00800060); 699: kgsl_regwrite(device, A6XX_CP_ROQ_THRESHOLDS_1, 0x40201b16); 700: } else if (ADRENO_GPUREV(adreno_dev) >= ADRENO_REV_A640) { 701: kgsl_regwrite(device, A6XX_CP_ROQ_THRESHOLDS_2, 0x02000140); 702: kgsl_regwrite(device, A6XX_CP_ROQ_THRESHOLDS_1, 0x8040362C); 703: } else { 704: kgsl_regwrite(device, A6XX_CP_ROQ_THRESHOLDS_2, 0x010000C0); 705: kgsl_regwrite(device, A6XX_CP_ROQ_THRESHOLDS_1, 0x8040362C); 706: } 707: 708: if (adreno_is_a660(adreno_dev)) 709: kgsl_regwrite(device, A6XX_CP_LPAC_PROG_FIFO_SIZE, 0x00000020); 710: 711: if (adreno_is_a663(adreno_dev)) { 712: kgsl_regwrite(device, A6XX_RBBM_GBIF_CLIENT_QOS_CNTL, 0x0); 713: kgsl_regwrite(device, A6XX_RBBM_LPAC_GBIF_CLIENT_QOS_CNTL, 0x0); 714: kgsl_regwrite(device, A6XX_CP_LPAC_PROG_FIFO_SIZE, 0x00000020); 715: } 716: 717: if (adreno_is_a612_family(adreno_dev) || adreno_is_a610_family(adreno_dev)) { 718: /* For A612, gen6_3_26_0 and A610 Mem pool size is reduced to 48 */ 719: kgsl_regwrite(device, A6XX_CP_MEM_POOL_SIZE, 48); 720: kgsl_regwrite(device, A6XX_CP_MEM_POOL_DBG_ADDR, 47); 721: } else if (adreno_is_a702_family(adreno_dev)) { 722: kgsl_regwrite(device, A6XX_CP_MEM_POOL_SIZE, 64); 723: kgsl_regwrite(device, A6XX_CP_MEM_POOL_DBG_ADDR, 63); 724: } else { 725: kgsl_regwrite(device, A6XX_CP_MEM_POOL_SIZE, 128); 726: } 727: 728: /* Setting the primFifo thresholds values */ 729: kgsl_regwrite(device, A6XX_PC_DBG_ECO_CNTL, 730: a6xx_core->prim_fifo_threshold); 731: 732: /* This enables ECO for an issue in SP instruction fetching */ 733: if (adreno_is_a642l(adreno_dev) || adreno_is_a643(adreno_dev)) 734: kgsl_regrmw(device, A6XX_SP_DBG_ECO_CNTL, 0x6, 735: FIELD_PREP(GENMASK(2, 1), 0x3)); 736: 737: /* Set the AHB default slave response to "ERROR" */ 738: kgsl_regwrite(device, A6XX_CP_AHB_CNTL, 0x1); 739: 740: /* Turn on performance counters */ 741: kgsl_regwrite(device, A6XX_RBBM_PERFCTR_CNTL, 0x1); 742: 743: /* Turn on the IFPC counter (countable 4 on XOCLK4) */ 744: if (gmu_core_isenabled(device)) 745: gmu_core_regrmw(device, A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_1, 746: 0xff, 0x4); 747: 748: /* Turn on GX_MEM retention */ 749: if (gmu_core_isenabled(device) && adreno_is_a612(adreno_dev)) { 750: kgsl_regwrite(device, A6XX_RBBM_BLOCK_GX_RETENTION_CNTL, 0x7FB); 751: /* For CP IPC interrupt */ 752: kgsl_regwrite(device, A6XX_RBBM_INT_2_MASK, 0x00000010); 753: } 754: 755: /* macrotilingmode 0: 4 channels (default) 756: * overwrite to 1: 8 channels for supported gpus 757: */ 758: if (adreno_is_a680(adreno_dev) || 759: adreno_is_a663(adreno_dev) || 760: adreno_is_a704(adreno_dev)) 761: kgsl_regwrite(device, A6XX_RBBM_NC_MODE_CNTL, 1); 762: 763: if (adreno_dev->highest_bank_bit) { 764: hbb_lo = (adreno_dev->highest_bank_bit - 13) & 3; 765: hbb_hi = ((adreno_dev->highest_bank_bit - 13) >> 2) & 1; 766: } 767: 768: mal = (mal == 64) ? 1 : 0; 769: 770: uavflagprd_inv = (adreno_is_a650_family(adreno_dev)) ? 2 : 0; 771: 772: kgsl_regwrite(device, A6XX_RB_NC_MODE_CNTL, 773: (ubwc_props->level2_swizzling_dis << 12) | 774: (ubwc_props->rgb565_predicator << 11) | 775: (hbb_hi << 10) | (ubwc_props->amsbc << 4) | (mal << 3) | 776: (hbb_lo << 1) | ubwc_props->mode); 777: 778: 779: kgsl_regwrite(device, A6XX_TPL1_NC_MODE_CNTL, 780: (ubwc_props->level2_swizzling_dis << 6) | (hbb_hi << 4) | 781: (mal << 3) | (hbb_lo << 1) | ubwc_props->mode); 782: 783: kgsl_regwrite(device, A6XX_SP_NC_MODE_CNTL, 784: (ubwc_props->level2_swizzling_dis << 12) | (hbb_hi << 10) | 785: (mal << 3) | (uavflagprd_inv << 4) | 786: (hbb_lo << 1) | ubwc_props->mode); 787: 788: kgsl_regwrite(device, A6XX_UCHE_MODE_CNTL, (mal << 23) | 789: (hbb_lo << 21)); 790: 791: kgsl_regwrite(device, A6XX_RBBM_INTERFACE_HANG_INT_CNTL, 792: (1 << 30) | a6xx_core->hang_detect_cycles); 793: 794: kgsl_regwrite(device, A6XX_UCHE_CLIENT_PF, BIT(7) | 795: FIELD_PREP(GENMASK(3, 0), adreno_dev->uche_client_pf)); 796: 797: /* Set weights for bicubic filtering */ 798: if (adreno_is_a650_family(adreno_dev)) { 799: kgsl_regwrite(device, A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_0, 0); 800: kgsl_regwrite(device, A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_1, 801: 0x3FE05FF4); 802: kgsl_regwrite(device, A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_2, 803: 0x3FA0EBEE); 804: kgsl_regwrite(device, A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_3, 805: 0x3F5193ED); 806: kgsl_regwrite(device, A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_4, 807: 0x3F0243F0); 808: } 809: 810: /* Set TWOPASSUSEWFI in A6XX_PC_DBG_ECO_CNTL if requested */ 811: if (ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_TWO_PASS_USE_WFI)) 812: kgsl_regrmw(device, A6XX_PC_DBG_ECO_CNTL, 0, (1 << 8)); 813: 814: /* Set the bit vccCacheSkipDis=1 to get rid of TSEskip logic */ 815: if (a6xx_core->disable_tseskip) 816: kgsl_regrmw(device, A6XX_PC_DBG_ECO_CNTL, 0, (1 << 9)); 817: 818: /* Set the bit in HLSQ Cluster for A702 family */ 819: if (adreno_is_a702_family(adreno_dev)) 820: kgsl_regwrite(device, A6XX_CP_CHICKEN_DBG, (1 << 24)); 821: 822: /* Enable the GMEM save/restore feature for preemption */ 823: if (adreno_is_preemption_enabled(adreno_dev)) 824: kgsl_regwrite(device, A6XX_RB_CONTEXT_SWITCH_GMEM_SAVE_RESTORE, 825: 0x1); 826: 827: /* 828: * Enable GMU power counter 0 to count GPU busy. This is applicable to 829: * all a6xx targets 830: */ 831: kgsl_regwrite(device, A6XX_GPU_GMU_AO_GPU_CX_BUSY_MASK, 0xff000000); 832: kgsl_regrmw(device, A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_0, 0xff, 0x20); 833: kgsl_regwrite(device, A6XX_GMU_CX_GMU_POWER_COUNTER_ENABLE, 0x1); 834: 835: a6xx_protect_init(adreno_dev); 836: /* 837: * We start LM here because we want all the following to be up 838: * 1. GX HS 839: * 2. SPTPRAC 840: * 3. HFI 841: * At this point, we are guaranteed all. 842: */ 843: 844: /* Configure LLCC */ 845: a6xx_llc_configure_gpu_scid(adreno_dev); 846: a6xx_llc_configure_gpuhtw_scid(adreno_dev); 847: a6xx_llc_configure_gpumv_scid(adreno_dev); 848: 849: a6xx_llc_enable_overrides(adreno_dev); 850: 851: if (adreno_is_a662(adreno_dev)) 852: kgsl_regrmw(device, A6XX_GBIF_CX_CONFIG, 0x3c0, 853: FIELD_PREP(GENMASK(7, 6), 0x1) | 854: FIELD_PREP(GENMASK(9, 8), 0x1)); 855: 856: if (adreno_is_a660(adreno_dev)) { 857: kgsl_regwrite(device, A6XX_CP_CHICKEN_DBG, 0x1); 858: kgsl_regwrite(device, A6XX_RBBM_GBIF_CLIENT_QOS_CNTL, 0x0); 859: } 860: 861: /* Set dualQ + disable afull for A660 and A663 GPU but not for A642l and A643 */ 862: if ((adreno_is_a660(adreno_dev) || adreno_is_a663(adreno_dev)) && 863: !(adreno_is_a642l(adreno_dev) || adreno_is_a643(adreno_dev))) 864: kgsl_regwrite(device, A6XX_UCHE_CMDQ_CONFIG, 0x66906); 865: 866: if (ADRENO_FEATURE(adreno_dev, ADRENO_APRIV)) 867: kgsl_regwrite(device, A6XX_CP_APRIV_CNTL, A6XX_APRIV_DEFAULT); 868: 869: a6xx_set_secvid(device); 870: 871: /* 872: * Enable hardware clock gating here to prevent any register access 873: * issue due to internal clock gating. 874: */ 875: a6xx_hwcg_set(adreno_dev, true); 876: 877: /* 878: * All registers must be written before this point so that we don't 879: * miss any register programming when we patch the power up register 880: * list. 881: */ 882: if (!adreno_dev->patch_reglist && 883: (adreno_dev->pwrup_reglist->gpuaddr != 0)) { 884: a6xx_patch_pwrup_reglist(adreno_dev); 885: adreno_dev->patch_reglist = true; 886: } 887: 888: /* 889: * During adreno_stop, GBIF halt is asserted to ensure 890: * no further transaction can go through GPU before GPU 891: * headswitch is turned off. 892: * 893: * This halt is deasserted once headswitch goes off but 894: * incase headswitch doesn't goes off clear GBIF halt 895: * here to ensure GPU wake-up doesn't fail because of 896: * halted GPU transactions. 897: */ 898: a6xx_deassert_gbif_halt(adreno_dev); 899: 900: } 901: 902: /* This is the start point for non GMU/RGMU targets */ 903: static int a6xx_nogmu_start(struct adreno_device *adreno_dev) 904: { 905: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 906: int ret; 907: 908: /* 909: * During adreno_stop() GBIF halt is asserted to ensure that 910: * no further transactions go through the GPU before the 911: * GPU headswitch is turned off. 912: * 913: * The halt is supposed to be deasserted when the headswitch goes off 914: * but clear it again during start to be sure 915: */ 916: kgsl_regwrite(device, A6XX_GBIF_HALT, 0x0); 917: kgsl_regwrite(device, A6XX_RBBM_GBIF_HALT, 0x0); 918: 919: ret = kgsl_mmu_start(device); 920: if (ret) 921: return ret; 922: 923: adreno_get_bus_counters(adreno_dev); 924: adreno_perfcounter_restore(adreno_dev); 925: 926: a6xx_start(adreno_dev); 927: return 0; 928: } 929: 930: /* 931: * CP_INIT_MAX_CONTEXT bit tells if the multiple hardware contexts can 932: * be used at once of if they should be serialized 933: */ 934: #define CP_INIT_MAX_CONTEXT BIT(0) 935: 936: /* Enables register protection mode */ 937: #define CP_INIT_ERROR_DETECTION_CONTROL BIT(1) 938: 939: /* Header dump information */ 940: #define CP_INIT_HEADER_DUMP BIT(2) /* Reserved */ 941: 942: /* Default Reset states enabled for PFP and ME */ 943: #define CP_INIT_DEFAULT_RESET_STATE BIT(3) 944: 945: /* Drawcall filter range */ 946: #define CP_INIT_DRAWCALL_FILTER_RANGE BIT(4) 947: 948: /* Ucode workaround masks */ 949: #define CP_INIT_UCODE_WORKAROUND_MASK BIT(5) 950: MATCH LINES: 973, 977, 1010, 1020, 1021, 1023, 1024, 1025, 1026, 1041, 1047, 1054, 1058, 1060, 1064, 1092, 1108, 1117, 1139, 1143, 1150, 1152, 1154, 1173, 1179, 1180, 1186, 1188, 1191, 1195, 1197, 1201, 1203, 1207, 1216, 1225, 1229, 1236, 1240, 1243, 1245, 1249, 1252, 1254, 1258, 1261, 1269, 1277, 1281, 1289, 1292, 1297, 1309, 1313, 1316, 1323, 1327, 1330, 1336, 1339, 1341, 1344, 1354, 1357, 1360 961: 962: /* Register initialization list with spinlock */ 963: #define CP_INIT_REGISTER_INIT_LIST_WITH_SPINLOCK BIT(8) 964: 965: #define CP_INIT_MASK (CP_INIT_MAX_CONTEXT | \ 966: CP_INIT_ERROR_DETECTION_CONTROL | \ 967: CP_INIT_HEADER_DUMP | \ 968: CP_INIT_DEFAULT_RESET_STATE | \ 969: CP_INIT_UCODE_WORKAROUND_MASK | \ 970: CP_INIT_OPERATION_MODE_MASK | \ 971: CP_INIT_REGISTER_INIT_LIST_WITH_SPINLOCK) 972: 973: void a6xx_cp_init_cmds(struct adreno_device *adreno_dev, u32 *cmds) 974: { 975: int i = 0; 976: 977: cmds[i++] = cp_type7_packet(CP_ME_INIT, A6XX_CP_INIT_DWORDS - 1); 978: 979: /* Enabled ordinal mask */ 980: cmds[i++] = CP_INIT_MASK; 981: 982: if (CP_INIT_MASK & CP_INIT_MAX_CONTEXT) 983: cmds[i++] = 0x00000003; 984: 985: if (CP_INIT_MASK & CP_INIT_ERROR_DETECTION_CONTROL) 986: cmds[i++] = 0x20000000; 987: 988: if (CP_INIT_MASK & CP_INIT_HEADER_DUMP) { 989: /* Header dump address */ 990: cmds[i++] = 0x00000000; 991: /* Header dump enable and dump size */ 992: cmds[i++] = 0x00000000; 993: } 994: 995: if (CP_INIT_MASK & CP_INIT_UCODE_WORKAROUND_MASK) 996: cmds[i++] = 0x00000000; 997: 998: if (CP_INIT_MASK & CP_INIT_OPERATION_MODE_MASK) 999: cmds[i++] = 0x00000002; 1000: 1001: if (CP_INIT_MASK & CP_INIT_REGISTER_INIT_LIST_WITH_SPINLOCK) { 1002: uint64_t gpuaddr = adreno_dev->pwrup_reglist->gpuaddr; 1003: 1004: cmds[i++] = lower_32_bits(gpuaddr); 1005: cmds[i++] = upper_32_bits(gpuaddr); 1006: cmds[i++] = 0; 1007: } 1008: } 1009: 1010: void a6xx_spin_idle_debug(struct adreno_device *adreno_dev, 1011: const char *str) 1012: { 1013: struct kgsl_device *device = &adreno_dev->dev; 1014: unsigned int rptr, wptr; 1015: unsigned int status, status3, intstatus; 1016: unsigned int hwfault; 1017: 1018: dev_err(device->dev, str); 1019: 1020: kgsl_regread(device, A6XX_CP_RB_RPTR, &rptr); 1021: kgsl_regread(device, A6XX_CP_RB_WPTR, &wptr); 1022: 1023: kgsl_regread(device, A6XX_RBBM_STATUS, &status); 1024: kgsl_regread(device, A6XX_RBBM_STATUS3, &status3); 1025: kgsl_regread(device, A6XX_RBBM_INT_0_STATUS, &intstatus); 1026: kgsl_regread(device, A6XX_CP_HW_FAULT, &hwfault); 1027: 1028: 1029: dev_err(device->dev, 1030: "rb=%d pos=%X/%X rbbm_status=%8.8X/%8.8X int_0_status=%8.8X\n", 1031: adreno_dev->cur_rb ? adreno_dev->cur_rb->id : -1, rptr, wptr, 1032: status, status3, intstatus); 1033: 1034: dev_err(device->dev, " hwfault=%8.8X\n", hwfault); 1035: 1036: kgsl_device_snapshot(device, NULL, NULL, false); 1037: 1038: } 1039: 1040: /* 1041: * a6xx_send_cp_init() - Initialize ringbuffer 1042: * @adreno_dev: Pointer to adreno device 1043: * @rb: Pointer to the ringbuffer of device 1044: * 1045: * Submit commands for ME initialization, 1046: */ 1047: static int a6xx_send_cp_init(struct adreno_device *adreno_dev, 1048: struct adreno_ringbuffer *rb) 1049: { 1050: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1051: unsigned int *cmds; 1052: int ret; 1053: 1054: cmds = adreno_ringbuffer_allocspace(rb, A6XX_CP_INIT_DWORDS); 1055: if (IS_ERR(cmds)) 1056: return PTR_ERR(cmds); 1057: 1058: a6xx_cp_init_cmds(adreno_dev, cmds); 1059: 1060: ret = a6xx_ringbuffer_submit(rb, NULL, true); 1061: if (!ret) { 1062: ret = adreno_spin_idle(adreno_dev, 2000); 1063: if (ret) { 1064: a6xx_spin_idle_debug(adreno_dev, 1065: "CP initialization failed to idle\n"); 1066: 1067: kgsl_sharedmem_writel(device->scratch, 1068: SCRATCH_RB_OFFSET(rb->id, rptr), 0); 1069: rb->wptr = 0; 1070: rb->_wptr = 0; 1071: } 1072: } 1073: 1074: return ret; 1075: } 1076: 1077: /* 1078: * Follow the ME_INIT sequence with a preemption yield to allow the GPU to move 1079: * to a different ringbuffer, if desired 1080: */ 1081: static int _preemption_init(struct adreno_device *adreno_dev, 1082: struct adreno_ringbuffer *rb, unsigned int *cmds, 1083: struct kgsl_context *context) 1084: { 1085: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1086: unsigned int *cmds_orig = cmds; 1087: 1088: /* Turn CP protection OFF on legacy targets */ 1089: if (!ADRENO_FEATURE(adreno_dev, ADRENO_APRIV)) 1090: cmds += cp_protected_mode(adreno_dev, cmds, 0); 1091: 1092: *cmds++ = cp_type7_packet(CP_SET_PSEUDO_REGISTER, 1093: kgsl_mmu_is_secured(&device->mmu) ? 6 : 3); 1094: *cmds++ = SET_PSEUDO_PRIV_NON_SECURE_SAVE_ADDR; 1095: cmds += cp_gpuaddr(adreno_dev, cmds, 1096: rb->preemption_desc->gpuaddr); 1097: 1098: if (kgsl_mmu_is_secured(&device->mmu)) { 1099: *cmds++ = SET_PSEUDO_PRIV_SECURE_SAVE_ADDR; 1100: cmds += cp_gpuaddr(adreno_dev, cmds, 1101: rb->secure_preemption_desc->gpuaddr); 1102: } 1103: 1104: /* Turn CP protection back ON */ 1105: if (!ADRENO_FEATURE(adreno_dev, ADRENO_APRIV)) 1106: cmds += cp_protected_mode(adreno_dev, cmds, 1); 1107: 1108: *cmds++ = cp_type7_packet(CP_CONTEXT_SWITCH_YIELD, 4); 1109: cmds += cp_gpuaddr(adreno_dev, cmds, 0x0); 1110: *cmds++ = 0; 1111: /* generate interrupt on preemption completion */ 1112: *cmds++ = 0; 1113: 1114: return cmds - cmds_orig; 1115: } 1116: 1117: static int a6xx_post_start(struct adreno_device *adreno_dev) 1118: { 1119: int ret; 1120: unsigned int *cmds, *start; 1121: struct adreno_ringbuffer *rb = adreno_dev->cur_rb; 1122: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1123: 1124: if (!adreno_is_preemption_enabled(adreno_dev)) 1125: return 0; 1126: 1127: cmds = adreno_ringbuffer_allocspace(rb, 42); 1128: if (IS_ERR(cmds)) { 1129: dev_err(device->dev, 1130: "error allocating preemption init cmds\n"); 1131: return PTR_ERR(cmds); 1132: } 1133: start = cmds; 1134: 1135: cmds += _preemption_init(adreno_dev, rb, cmds, NULL); 1136: 1137: rb->_wptr = rb->_wptr - (42 - (cmds - start)); 1138: 1139: ret = a6xx_ringbuffer_submit(rb, NULL, false); 1140: if (!ret) { 1141: ret = adreno_spin_idle(adreno_dev, 2000); 1142: if (ret) 1143: a6xx_spin_idle_debug(adreno_dev, 1144: "hw preemption initialization failed to idle\n"); 1145: } 1146: 1147: return ret; 1148: } 1149: 1150: int a6xx_rb_start(struct adreno_device *adreno_dev) 1151: { 1152: const struct adreno_a6xx_core *a6xx_core = to_a6xx_core(adreno_dev); 1153: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1154: u32 cp_rb_cntl = A6XX_CP_RB_CNTL_DEFAULT | 1155: (ADRENO_FEATURE(adreno_dev, ADRENO_APRIV) ? 0 : (1 << 27)); 1156: struct adreno_firmware *fw = ADRENO_FW(adreno_dev, ADRENO_FW_SQE); 1157: struct adreno_ringbuffer *rb; 1158: uint64_t addr; 1159: int ret, i; 1160: unsigned int *cmds; 1161: 1162: /* Clear all the ringbuffers */ 1163: FOR_EACH_RINGBUFFER(adreno_dev, rb, i) { 1164: memset(rb->buffer_desc->hostptr, 0xaa, KGSL_RB_SIZE); 1165: kgsl_sharedmem_writel(device->scratch, 1166: SCRATCH_RB_OFFSET(rb->id, rptr), 0); 1167: 1168: rb->wptr = 0; 1169: rb->_wptr = 0; 1170: rb->wptr_preempt_end = ~0; 1171: } 1172: 1173: a6xx_preemption_start(adreno_dev); 1174: 1175: /* Set up the current ringbuffer */ 1176: rb = ADRENO_CURRENT_RINGBUFFER(adreno_dev); 1177: addr = SCRATCH_RB_GPU_ADDR(device, rb->id, rptr); 1178: 1179: kgsl_regwrite(device, A6XX_CP_RB_RPTR_ADDR_LO, lower_32_bits(addr)); 1180: kgsl_regwrite(device, A6XX_CP_RB_RPTR_ADDR_HI, upper_32_bits(addr)); 1181: 1182: /* 1183: * The size of the ringbuffer in the hardware is the log2 1184: * representation of the size in quadwords (sizedwords / 2). 1185: */ 1186: kgsl_regwrite(device, A6XX_CP_RB_CNTL, cp_rb_cntl); 1187: 1188: kgsl_regwrite(device, A6XX_CP_RB_BASE, 1189: lower_32_bits(rb->buffer_desc->gpuaddr)); 1190: 1191: kgsl_regwrite(device, A6XX_CP_RB_BASE_HI, 1192: upper_32_bits(rb->buffer_desc->gpuaddr)); 1193: 1194: /* Program the ucode base for CP */ 1195: kgsl_regwrite(device, A6XX_CP_SQE_INSTR_BASE_LO, 1196: lower_32_bits(fw->memdesc->gpuaddr)); 1197: kgsl_regwrite(device, A6XX_CP_SQE_INSTR_BASE_HI, 1198: upper_32_bits(fw->memdesc->gpuaddr)); 1199: 1200: /* Clear the SQE_HALT to start the CP engine */ 1201: kgsl_regwrite(device, A6XX_CP_SQE_CNTL, 1); 1202: 1203: ret = a6xx_send_cp_init(adreno_dev, rb); 1204: if (ret) 1205: return ret; 1206: 1207: ret = adreno_zap_shader_load(adreno_dev, a6xx_core->zap_name); 1208: if (ret) 1209: return ret; 1210: 1211: /* 1212: * Take the GPU out of secure mode. Try the zap shader if it is loaded, 1213: * otherwise just try to write directly to the secure control register 1214: */ 1215: if (!adreno_dev->zap_loaded) 1216: kgsl_regwrite(device, A6XX_RBBM_SECVID_TRUST_CNTL, 0); 1217: else { 1218: cmds = adreno_ringbuffer_allocspace(rb, 2); 1219: if (IS_ERR(cmds)) 1220: return PTR_ERR(cmds); 1221: 1222: *cmds++ = cp_packet(adreno_dev, CP_SET_SECURE_MODE, 1); 1223: *cmds++ = 0; 1224: 1225: ret = a6xx_ringbuffer_submit(rb, NULL, true); 1226: if (!ret) { 1227: ret = adreno_spin_idle(adreno_dev, 2000); 1228: if (ret) { 1229: a6xx_spin_idle_debug(adreno_dev, 1230: "Switch to unsecure failed to idle\n"); 1231: return ret; 1232: } 1233: } 1234: } 1235: 1236: return a6xx_post_start(adreno_dev); 1237: } 1238: 1239: /* 1240: * a6xx_sptprac_enable() - Power on SPTPRAC 1241: * @adreno_dev: Pointer to Adreno device 1242: */ 1243: static int a6xx_sptprac_enable(struct adreno_device *adreno_dev) 1244: { 1245: return a6xx_gmu_sptprac_enable(adreno_dev); 1246: } 1247: 1248: /* 1249: * a6xx_sptprac_disable() - Power off SPTPRAC 1250: * @adreno_dev: Pointer to Adreno device 1251: */ 1252: static void a6xx_sptprac_disable(struct adreno_device *adreno_dev) 1253: { 1254: a6xx_gmu_sptprac_disable(adreno_dev); 1255: } 1256: 1257: /* 1258: * a6xx_prepare_for_regulator_disable() - Prepare for regulator disable 1259: * @adreno_dev: Pointer to Adreno device 1260: */ 1261: static void a6xx_prepare_for_regulator_disable(struct adreno_device *adreno_dev) 1262: { 1263: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1264: 1265: /* This sequence is only required for A611 */ 1266: if (!adreno_is_a611(adreno_dev)) 1267: return; 1268: 1269: kgsl_regwrite(device, A6XX_RBBM_SW_RESET_CMD, 0x1); 1270: /* Make sure above writes are posted before turning off power resource.*/ 1271: wmb(); 1272: /*wait for 100usecs, to allow the software reset to complete*/ 1273: udelay(100); 1274: } 1275: 1276: /* 1277: * a6xx_gpu_keepalive() - GMU reg write to request GPU stays on 1278: * @adreno_dev: Pointer to the adreno device that has the GMU 1279: * @state: State to set: true is ON, false is OFF 1280: */ 1281: static void a6xx_gpu_keepalive(struct adreno_device *adreno_dev, 1282: bool state) 1283: { 1284: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1285: 1286: if (!gmu_core_isenabled(device)) 1287: return; 1288: 1289: gmu_core_regwrite(device, A6XX_GMU_GMU_PWR_COL_KEEPALIVE, state); 1290: } 1291: 1292: bool a6xx_irq_pending(struct adreno_device *adreno_dev) 1293: { 1294: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1295: u32 status; 1296: 1297: kgsl_regread(device, A6XX_RBBM_INT_0_STATUS, &status); 1298: 1299: /* Return busy if a interrupt is pending */ 1300: return ((status & adreno_dev->irq_mask) || 1301: atomic_read(&adreno_dev->pending_irq_refcnt)); 1302: } 1303: 1304: static bool a619_holi_hw_isidle(struct adreno_device *adreno_dev) 1305: { 1306: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1307: unsigned int reg; 1308: 1309: kgsl_regread(device, A6XX_RBBM_STATUS, ®); 1310: if (reg & 0xfffffffe) 1311: return false; 1312: 1313: return a6xx_irq_pending(adreno_dev) ? false : true; 1314: } 1315: 1316: bool a6xx_hw_isidle(struct adreno_device *adreno_dev) 1317: { 1318: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1319: unsigned int reg; 1320: 1321: /* Non GMU devices monitor the RBBM status */ 1322: if (!gmu_core_isenabled(device)) { 1323: kgsl_regread(device, A6XX_RBBM_STATUS, ®); 1324: if (reg & 0xfffffffe) 1325: return false; 1326: 1327: return a6xx_irq_pending(adreno_dev) ? false : true; 1328: } 1329: 1330: gmu_core_regread(device, A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS, ®); 1331: 1332: /* Bit 23 is GPUBUSYIGNAHB */ 1333: return (reg & BIT(23)) ? false : true; 1334: } 1335: 1336: int a6xx_microcode_read(struct adreno_device *adreno_dev) 1337: { 1338: struct adreno_firmware *sqe_fw = ADRENO_FW(adreno_dev, ADRENO_FW_SQE); 1339: const struct adreno_a6xx_core *a6xx_core = to_a6xx_core(adreno_dev); 1340: 1341: return adreno_get_firmware(adreno_dev, a6xx_core->sqefw_name, sqe_fw); 1342: } 1343: 1344: static int64_t a6xx_read_throttling_counters(struct adreno_device *adreno_dev) 1345: { 1346: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1347: int64_t adj = -1; 1348: u32 a, b, c; 1349: struct adreno_busy_data *busy = &adreno_dev->busy_data; 1350: 1351: if (!(adreno_dev->lm_enabled || adreno_dev->bcl_enabled)) 1352: return 0; 1353: 1354: a = counter_delta(device, A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_1_L, 1355: &busy->throttle_cycles[0]); 1356: 1357: b = counter_delta(device, A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_2_L, 1358: &busy->throttle_cycles[1]); 1359: 1360: c = counter_delta(device, A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_3_L, 1361: &busy->throttle_cycles[2]); 1362: 1363: /* 1364: * Currently there are no a6xx targets with both LM and BCL enabled. 1365: * So if BCL is enabled, we can log bcl counters and return. 1366: */ 1367: if (adreno_dev->bcl_enabled) { 1368: trace_kgsl_bcl_clock_throttling(a, b, c); 1369: return 0; 1370: } 1371: 1372: /* 1373: * The adjustment is the number of cycles lost to throttling, which 1374: * is calculated as a weighted average of the cycles throttled 1375: * at different levels. The adjustment is negative because in A6XX, 1376: * the busy count includes the throttled cycles. Therefore, we want 1377: * to remove them to prevent appearing to be busier than 1378: * we actually are. 1379: */ 1380: if (adreno_is_a620(adreno_dev) || adreno_is_a650(adreno_dev)) 1381: /* 1382: * With the newer generations, CRC throttle from SIDs of 0x14 1383: * and above cannot be observed in power counters. Since 90% 1384: * throttle uses SID 0x16 the adjustment calculation needs MATCH LINES: 1399, 1402, 1407, 1445, 1451, 1453, 1455, 1456, 1457, 1458, 1464, 1468, 1474, 1480, 1492, 1503, 1515, 1520, 1522, 1525, 1526, 1530, 1532, 1533, 1537, 1538, 1544, 1547, 1550, 1556, 1561, 1564, 1568, 1572, 1576, 1579, 1589, 1592, 1608, 1609, 1613, 1614, 1616, 1617, 1621, 1627, 1632, 1635, 1657, 1658, 1662, 1665, 1680, 1681, 1685, 1688, 1706, 1724, 1745, 1767, 1778, 1789, 1801, 1804, 1810, 1814, 1831, 1833, 1839, 1840, 1841, 1842, 1853, 1855, 1858, 1859, 1862, 1875, 1884, 1886, 1889, 1893, 1896, 1898, 1914, 1925, 1927, 1929, 1931, 1937, 1942, 1953, 1955, 1960, 1962, 1964, 1971, 1976, 1989, 1993, 2003, 2005, 2006, 2018, 2022, 2035, 2037 1387: * which are taken into consideration for the final formula. 1388: */ 1389: adj *= div_s64((a * 42) + (b * 500) + 1390: (div_s64((int64_t)c - a - b * 12, 22) * 917), 1000); 1391: else 1392: adj *= ((a * 5) + (b * 50) + (c * 90)) / 100; 1393: 1394: trace_kgsl_clock_throttling(0, b, c, a, adj); 1395: 1396: return adj; 1397: } 1398: #define GPU_CPR_FSM_CTL_OFFSET 0x4 1399: static void a6xx_gx_cpr_toggle(struct kgsl_device *device) 1400: { 1401: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1402: const struct adreno_a6xx_core *a6xx_core = to_a6xx_core(adreno_dev); 1403: static void __iomem *gx_cpr_virt; 1404: struct resource *res; 1405: u32 val = 0; 1406: 1407: if (!a6xx_core->gx_cpr_toggle) 1408: return; 1409: 1410: if (!gx_cpr_virt) { 1411: res = platform_get_resource_byname(device->pdev, IORESOURCE_MEM, 1412: "gx_cpr"); 1413: if (res == NULL) 1414: return; 1415: 1416: gx_cpr_virt = devm_ioremap_resource(&device->pdev->dev, res); 1417: if (!gx_cpr_virt) { 1418: dev_err(device->dev, "Failed to map GX CPR\n"); 1419: return; 1420: } 1421: } 1422: 1423: /* 1424: * Toggle(disable -> enable) closed loop functionality to recover 1425: * CPR measurements stall happened under certain conditions. 1426: */ 1427: 1428: val = readl_relaxed(gx_cpr_virt + GPU_CPR_FSM_CTL_OFFSET); 1429: /* Make sure memory is updated before access */ 1430: rmb(); 1431: 1432: writel_relaxed(val & 0xfffffff0, gx_cpr_virt + GPU_CPR_FSM_CTL_OFFSET); 1433: /* make sure register write committed */ 1434: wmb(); 1435: 1436: /* Wait for small time before we enable GX CPR */ 1437: udelay(5); 1438: 1439: writel_relaxed(val | 0x00000001, gx_cpr_virt + GPU_CPR_FSM_CTL_OFFSET); 1440: /* make sure register write committed */ 1441: wmb(); 1442: } 1443: 1444: /* This is only defined for non-GMU and non-RGMU targets */ 1445: static int a6xx_clear_pending_transactions(struct adreno_device *adreno_dev) 1446: { 1447: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1448: int ret; 1449: 1450: if (adreno_is_a619_holi(adreno_dev)) { 1451: kgsl_regwrite(device, A6XX_RBBM_GPR0_CNTL, 0x1e0); 1452: ret = adreno_wait_for_halt_ack(device, 1453: A6XX_RBBM_VBIF_GX_RESET_STATUS, 0xf0); 1454: } else { 1455: kgsl_regwrite(device, A6XX_RBBM_GBIF_HALT, 1456: A6XX_GBIF_GX_HALT_MASK); 1457: ret = adreno_wait_for_halt_ack(device, A6XX_RBBM_GBIF_HALT_ACK, 1458: A6XX_GBIF_GX_HALT_MASK); 1459: } 1460: 1461: if (ret) 1462: return ret; 1463: 1464: return a6xx_halt_gbif(adreno_dev); 1465: } 1466: 1467: /** 1468: * a6xx_reset() - Helper function to reset the GPU 1469: * @adreno_dev: Pointer to the adreno device structure for the GPU 1470: * 1471: * Try to reset the GPU to recover from a fault for targets without 1472: * a GMU. 1473: */ 1474: static int a6xx_reset(struct adreno_device *adreno_dev) 1475: { 1476: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1477: int ret; 1478: unsigned long flags = device->pwrctrl.ctrl_flags; 1479: 1480: ret = a6xx_clear_pending_transactions(adreno_dev); 1481: if (ret) 1482: return ret; 1483: 1484: /* Clear ctrl_flags to ensure clocks and regulators are turned off */ 1485: device->pwrctrl.ctrl_flags = 0; 1486: 1487: kgsl_pwrctrl_change_state(device, KGSL_STATE_INIT); 1488: 1489: /* since device is officially off now clear start bit */ 1490: clear_bit(ADRENO_DEVICE_STARTED, &adreno_dev->priv); 1491: 1492: a6xx_reset_preempt_records(adreno_dev); 1493: 1494: ret = adreno_start(device, 0); 1495: if (ret) 1496: return ret; 1497: 1498: kgsl_pwrctrl_change_state(device, KGSL_STATE_ACTIVE); 1499: 1500: device->pwrctrl.ctrl_flags = flags; 1501: 1502: /* Toggle GX CPR on demand */ 1503: a6xx_gx_cpr_toggle(device); 1504: 1505: /* 1506: * If active_cnt is zero, there is no need to keep the GPU active. So, 1507: * we should transition to SLUMBER. 1508: */ 1509: if (!atomic_read(&device->active_cnt)) 1510: kgsl_pwrctrl_change_state(device, KGSL_STATE_SLUMBER); 1511: 1512: return 0; 1513: } 1514: 1515: static void a6xx_cp_hw_err_callback(struct adreno_device *adreno_dev, int bit) 1516: { 1517: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1518: unsigned int status1, status2; 1519: 1520: kgsl_regread(device, A6XX_CP_INTERRUPT_STATUS, &status1); 1521: 1522: if (status1 & BIT(A6XX_CP_OPCODE_ERROR)) { 1523: unsigned int opcode; 1524: 1525: kgsl_regwrite(device, A6XX_CP_SQE_STAT_ADDR, 1); 1526: kgsl_regread(device, A6XX_CP_SQE_STAT_DATA, &opcode); 1527: dev_crit_ratelimited(device->dev, 1528: "CP opcode error interrupt | opcode=0x%8.8x\n", opcode); 1529: } 1530: if (status1 & BIT(A6XX_CP_UCODE_ERROR)) 1531: dev_crit_ratelimited(device->dev, "CP ucode error interrupt\n"); 1532: if (status1 & BIT(A6XX_CP_HW_FAULT_ERROR)) { 1533: kgsl_regread(device, A6XX_CP_HW_FAULT, &status2); 1534: dev_crit_ratelimited(device->dev, 1535: "CP | Ringbuffer HW fault | status=%x\n", status2); 1536: } 1537: if (status1 & BIT(A6XX_CP_REGISTER_PROTECTION_ERROR)) { 1538: kgsl_regread(device, A6XX_CP_PROTECT_STATUS, &status2); 1539: dev_crit_ratelimited(device->dev, 1540: "CP | Protected mode error | %s | addr=%x | status=%x\n", 1541: status2 & (1 << 20) ? "READ" : "WRITE", 1542: status2 & 0x3FFFF, status2); 1543: } 1544: if (status1 & BIT(A6XX_CP_AHB_ERROR)) 1545: dev_crit_ratelimited(device->dev, 1546: "CP AHB error interrupt\n"); 1547: if (status1 & BIT(A6XX_CP_VSD_PARITY_ERROR)) 1548: dev_crit_ratelimited(device->dev, 1549: "CP VSD decoder parity error\n"); 1550: if (status1 & BIT(A6XX_CP_ILLEGAL_INSTR_ERROR)) 1551: dev_crit_ratelimited(device->dev, 1552: "CP Illegal instruction error\n"); 1553: 1554: } 1555: 1556: static void a6xx_err_callback(struct adreno_device *adreno_dev, int bit) 1557: { 1558: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1559: 1560: switch (bit) { 1561: case A6XX_INT_CP_AHB_ERROR: 1562: dev_crit_ratelimited(device->dev, "CP: AHB bus error\n"); 1563: break; 1564: case A6XX_INT_ATB_ASYNCFIFO_OVERFLOW: 1565: dev_crit_ratelimited(device->dev, 1566: "RBBM: ATB ASYNC overflow\n"); 1567: break; 1568: case A6XX_INT_RBBM_ATB_BUS_OVERFLOW: 1569: dev_crit_ratelimited(device->dev, 1570: "RBBM: ATB bus overflow\n"); 1571: break; 1572: case A6XX_INT_UCHE_OOB_ACCESS: 1573: dev_crit_ratelimited(device->dev, 1574: "UCHE: Out of bounds access\n"); 1575: break; 1576: case A6XX_INT_UCHE_TRAP_INTR: 1577: dev_crit_ratelimited(device->dev, "UCHE: Trap interrupt\n"); 1578: break; 1579: case A6XX_INT_TSB_WRITE_ERROR: 1580: dev_crit_ratelimited(device->dev, "TSB: Write error interrupt\n"); 1581: break; 1582: default: 1583: dev_crit_ratelimited(device->dev, "Unknown interrupt %d\n", 1584: bit); 1585: } 1586: } 1587: 1588: /* 1589: * a6xx_llc_configure_gpu_scid() - Program the sub-cache ID for all GPU blocks 1590: * @adreno_dev: The adreno device pointer 1591: */ 1592: static void a6xx_llc_configure_gpu_scid(struct adreno_device *adreno_dev) 1593: { 1594: uint32_t gpu_scid; 1595: uint32_t gpu_cntl1_val = 0; 1596: int i; 1597: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1598: struct kgsl_mmu *mmu = &device->mmu; 1599: 1600: if (IS_ERR_OR_NULL(adreno_dev->gpu_llc_slice) || 1601: !adreno_dev->gpu_llc_slice_enable) 1602: return; 1603: 1604: if (llcc_slice_activate(adreno_dev->gpu_llc_slice)) 1605: return; 1606: 1607: gpu_scid = llcc_get_slice_id(adreno_dev->gpu_llc_slice); 1608: for (i = 0; i < A6XX_LLC_NUM_GPU_SCIDS; i++) 1609: gpu_cntl1_val = (gpu_cntl1_val << A6XX_GPU_LLC_SCID_NUM_BITS) 1610: | gpu_scid; 1611: 1612: if (mmu->subtype == KGSL_IOMMU_SMMU_V500) 1613: kgsl_regrmw(device, A6XX_GBIF_SCACHE_CNTL1, 1614: A6XX_GPU_LLC_SCID_MASK, gpu_cntl1_val); 1615: else 1616: kgsl_regrmw(device, A6XX_GPU_CX_MISC_SYSTEM_CACHE_CNTL_1, 1617: A6XX_GPU_LLC_SCID_MASK, gpu_cntl1_val); 1618: 1619: /* 1620: * On A660, the SCID programming for UCHE traffic is done in 1621: * A6XX_GBIF_SCACHE_CNTL0[14:10] 1622: * GFO ENABLE BIT(8) : LLC uses a 64 byte cache line size enabling 1623: * GFO allows it allocate partial cache lines 1624: */ 1625: if (adreno_is_a660(adreno_dev) || 1626: adreno_is_a663(adreno_dev)) 1627: kgsl_regrmw(device, A6XX_GBIF_SCACHE_CNTL0, (0x1f << 10) | 1628: BIT(8), (gpu_scid << 10) | BIT(8)); 1629: } 1630: 1631: /* 1632: * a6xx_llc_configure_gpuhtw_scid() - Program the SCID for GPU pagetables 1633: * @adreno_dev: The adreno device pointer 1634: */ 1635: static void a6xx_llc_configure_gpuhtw_scid(struct adreno_device *adreno_dev) 1636: { 1637: uint32_t gpuhtw_scid; 1638: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1639: struct kgsl_mmu *mmu = &device->mmu; 1640: 1641: if (IS_ERR_OR_NULL(adreno_dev->gpuhtw_llc_slice) || 1642: !adreno_dev->gpuhtw_llc_slice_enable) 1643: return; 1644: 1645: if (llcc_slice_activate(adreno_dev->gpuhtw_llc_slice)) 1646: return; 1647: 1648: /* 1649: * On SMMU-v500, the GPUHTW SCID is configured via a NoC override in 1650: * the XBL image. 1651: */ 1652: if (mmu->subtype == KGSL_IOMMU_SMMU_V500) 1653: return; 1654: 1655: gpuhtw_scid = llcc_get_slice_id(adreno_dev->gpuhtw_llc_slice); 1656: 1657: kgsl_regrmw(device, A6XX_GPU_CX_MISC_SYSTEM_CACHE_CNTL_1, 1658: A6XX_GPUHTW_LLC_SCID_MASK, gpuhtw_scid << A6XX_GPUHTW_LLC_SCID_SHIFT); 1659: } 1660: 1661: /* 1662: * a6xx_llc_configure_gpumv_scid() - Program the sub-cache ID for CCU block 1663: * @adreno_dev: The adreno device pointer 1664: */ 1665: static void a6xx_llc_configure_gpumv_scid(struct adreno_device *adreno_dev) 1666: { 1667: u32 gpumv_scid = 0; 1668: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1669: struct kgsl_mmu *mmu = &device->mmu; 1670: 1671: if (IS_ERR_OR_NULL(adreno_dev->gpumv_llc_slice) || 1672: !adreno_dev->gpumv_llc_slice_enable || 1673: mmu->subtype != KGSL_IOMMU_SMMU_V500) 1674: return; 1675: 1676: if (llcc_slice_activate(adreno_dev->gpumv_llc_slice)) 1677: return; 1678: 1679: gpumv_scid = llcc_get_slice_id(adreno_dev->gpumv_llc_slice); 1680: kgsl_regrmw(device, A6XX_GBIF_SCACHE_CNTL1, 1681: A6XX_GPUMV_LLC_SCID_MASK, FIELD_PREP(GENMASK(19, 15), gpumv_scid)); 1682: } 1683: 1684: /* 1685: * a6xx_llc_enable_overrides() - Override the page attributes 1686: * @adreno_dev: The adreno device pointer 1687: */ 1688: static void a6xx_llc_enable_overrides(struct adreno_device *adreno_dev) 1689: { 1690: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1691: struct kgsl_mmu *mmu = &device->mmu; 1692: 1693: /* 1694: * Attributes override through GBIF is not supported with MMU-500. 1695: * Attributes are used as configured through SMMU pagetable entries. 1696: */ 1697: if (mmu->subtype == KGSL_IOMMU_SMMU_V500) 1698: return; 1699: 1700: /* 1701: * 0x3: readnoallocoverrideen=0 1702: * read-no-alloc=0 - Allocate lines on read miss 1703: * writenoallocoverrideen=1 1704: * write-no-alloc=1 - Do not allocates lines on write miss 1705: */ 1706: kgsl_regwrite(device, A6XX_GPU_CX_MISC_SYSTEM_CACHE_CNTL_0, 0x3); 1707: } 1708: 1709: static const char *uche_client[7][3] = { 1710: {"SP | VSC | VPC | HLSQ | PC | LRZ", "TP", "VFD"}, 1711: {"VSC | VPC | HLSQ | PC | LRZ", "TP | VFD", "SP"}, 1712: {"SP | VPC | HLSQ | PC | LRZ", "TP | VFD", "VSC"}, 1713: {"SP | VSC | HLSQ | PC | LRZ", "TP | VFD", "VPC"}, 1714: {"SP | VSC | VPC | PC | LRZ", "TP | VFD", "HLSQ"}, 1715: {"SP | VSC | VPC | HLSQ | LRZ", "TP | VFD", "PC"}, 1716: {"SP | VSC | VPC | HLSQ | PC", "TP | VFD", "LRZ"}, 1717: }; 1718: 1719: static const char *const uche_client_a660[] = { "VFD", "SP", "VSC", "VPC", 1720: "HLSQ", "PC", "LRZ", "TP" }; 1721: 1722: #define SCOOBYDOO 0x5c00bd00 1723: 1724: static const char *a6xx_fault_block_uche(struct kgsl_device *device, 1725: unsigned int mid) 1726: { 1727: unsigned int uche_client_id = 0; 1728: static char str[40]; 1729: 1730: /* 1731: * Smmu driver takes a vote on CX gdsc before calling the kgsl 1732: * pagefault handler. If there is contention for device mutex in this 1733: * path and the dispatcher fault handler is holding this lock, trying 1734: * to turn off CX gdsc will fail during the reset. So to avoid blocking 1735: * here, try to lock device mutex and return if it fails. 1736: */ 1737: if (!kgsl_mutex_trylock(&device->mutex)) 1738: return "UCHE: unknown"; 1739: 1740: if (!kgsl_state_is_awake(device)) { 1741: kgsl_mutex_unlock(&device->mutex); 1742: return "UCHE: unknown"; 1743: } 1744: 1745: kgsl_regread(device, A6XX_UCHE_CLIENT_PF, &uche_client_id); 1746: kgsl_mutex_unlock(&device->mutex); 1747: 1748: /* Ignore the value if the gpu is in IFPC */ 1749: if (uche_client_id == SCOOBYDOO) 1750: return "UCHE: unknown"; 1751: 1752: if (adreno_is_a660(ADRENO_DEVICE(device))) { 1753: 1754: /* Mask is 7 bits for A660 */ 1755: uche_client_id &= 0x7F; 1756: if (uche_client_id >= ARRAY_SIZE(uche_client_a660) || 1757: (mid == 2)) 1758: return "UCHE: Unknown"; 1759: 1760: if (mid == 1) 1761: snprintf(str, sizeof(str), "UCHE: Not %s", 1762: uche_client_a660[uche_client_id]); 1763: else if (mid == 3) 1764: snprintf(str, sizeof(str), "UCHE: %s", 1765: uche_client_a660[uche_client_id]); 1766: } else { 1767: uche_client_id &= A6XX_UCHE_CLIENT_PF_CLIENT_ID_MASK; 1768: if (uche_client_id >= ARRAY_SIZE(uche_client)) 1769: return "UCHE: Unknown"; 1770: 1771: snprintf(str, sizeof(str), "UCHE: %s", 1772: uche_client[uche_client_id][mid - 1]); 1773: } 1774: 1775: return str; 1776: } 1777: 1778: static const char *a6xx_iommu_fault_block(struct kgsl_device *device, 1779: unsigned int fsynr1) 1780: { 1781: unsigned int mid = fsynr1 & 0xff; 1782: 1783: switch (mid) { 1784: case 0: 1785: return "CP"; 1786: case 1: 1787: case 2: 1788: case 3: 1789: return a6xx_fault_block_uche(device, mid); 1790: case 4: 1791: return "CCU"; 1792: case 6: 1793: return "CDP Prefetch"; 1794: case 7: 1795: return "GPMU"; 1796: } 1797: 1798: return "Unknown"; 1799: } 1800: 1801: static void a6xx_cp_callback(struct adreno_device *adreno_dev, int bit) 1802: { 1803: if (adreno_is_preemption_enabled(adreno_dev)) 1804: a6xx_preemption_trigger(adreno_dev, true); 1805: 1806: adreno_scheduler_queue(adreno_dev); 1807: } 1808: 1809: /* 1810: * a6xx_gpc_err_int_callback() - Isr for GPC error interrupts 1811: * @adreno_dev: Pointer to device 1812: * @bit: Interrupt bit 1813: */ 1814: static void a6xx_gpc_err_int_callback(struct adreno_device *adreno_dev, int bit) 1815: { 1816: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1817: 1818: /* 1819: * GPC error is typically the result of mistake SW programming. 1820: * Force GPU fault for this interrupt so that we can debug it 1821: * with help of register dump. 1822: */ 1823: 1824: dev_crit(device->dev, "RBBM: GPC error\n"); 1825: adreno_irqctrl(adreno_dev, 0); 1826: 1827: /* Trigger a fault in the dispatcher - this will effect a restart */ 1828: adreno_scheduler_fault(adreno_dev, ADRENO_SOFT_FAULT); 1829: } 1830: 1831: static const struct adreno_irq_funcs a6xx_irq_funcs[32] = { 1832: ADRENO_IRQ_CALLBACK(NULL), /* 0 - RBBM_GPU_IDLE */ 1833: ADRENO_IRQ_CALLBACK(a6xx_err_callback), /* 1 - RBBM_AHB_ERROR */ 1834: ADRENO_IRQ_CALLBACK(NULL), /* 2 - UNUSED */ 1835: ADRENO_IRQ_CALLBACK(NULL), /* 3 - UNUSED */ 1836: ADRENO_IRQ_CALLBACK(NULL), /* 4 - UNUSED */ 1837: ADRENO_IRQ_CALLBACK(NULL), /* 5 - UNUSED */ 1838: /* 6 - RBBM_ATB_ASYNC_OVERFLOW */ 1839: ADRENO_IRQ_CALLBACK(a6xx_err_callback), 1840: ADRENO_IRQ_CALLBACK(a6xx_gpc_err_int_callback), /* 7 - GPC_ERR */ 1841: ADRENO_IRQ_CALLBACK(a6xx_preemption_callback),/* 8 - CP_SW */ 1842: ADRENO_IRQ_CALLBACK(a6xx_cp_hw_err_callback), /* 9 - CP_HW_ERROR */ 1843: ADRENO_IRQ_CALLBACK(NULL), /* 10 - CP_CCU_FLUSH_DEPTH_TS */ 1844: ADRENO_IRQ_CALLBACK(NULL), /* 11 - CP_CCU_FLUSH_COLOR_TS */ 1845: ADRENO_IRQ_CALLBACK(NULL), /* 12 - CP_CCU_RESOLVE_TS */ 1846: ADRENO_IRQ_CALLBACK(adreno_cp_callback), /* 13 - CP_IB2_INT */ 1847: ADRENO_IRQ_CALLBACK(adreno_cp_callback), /* 14 - CP_IB1_INT */ 1848: ADRENO_IRQ_CALLBACK(adreno_cp_callback), /* 15 - CP_RB_INT */ 1849: ADRENO_IRQ_CALLBACK(NULL), /* 16 - UNUSED */ 1850: ADRENO_IRQ_CALLBACK(NULL), /* 17 - CP_RB_DONE_TS */ 1851: ADRENO_IRQ_CALLBACK(NULL), /* 18 - CP_WT_DONE_TS */ 1852: ADRENO_IRQ_CALLBACK(NULL), /* 19 - UNUSED */ 1853: ADRENO_IRQ_CALLBACK(a6xx_cp_callback), /* 20 - CP_CACHE_FLUSH_TS */ 1854: ADRENO_IRQ_CALLBACK(NULL), /* 21 - UNUSED */ 1855: ADRENO_IRQ_CALLBACK(a6xx_err_callback), /* 22 - RBBM_ATB_BUS_OVERFLOW */ 1856: /* 23 - MISC_HANG_DETECT */ 1857: ADRENO_IRQ_CALLBACK(adreno_hang_int_callback), 1858: ADRENO_IRQ_CALLBACK(a6xx_err_callback), /* 24 - UCHE_OOB_ACCESS */ 1859: ADRENO_IRQ_CALLBACK(a6xx_err_callback), /* 25 - UCHE_TRAP_INTR */ 1860: ADRENO_IRQ_CALLBACK(NULL), /* 26 - DEBBUS_INTR_0 */ 1861: ADRENO_IRQ_CALLBACK(NULL), /* 27 - DEBBUS_INTR_1 */ 1862: ADRENO_IRQ_CALLBACK(a6xx_err_callback), /* 28 - TSBWRITEERROR */ 1863: ADRENO_IRQ_CALLBACK(NULL), /* 29 - UNUSED */ 1864: ADRENO_IRQ_CALLBACK(NULL), /* 30 - ISDB_CPU_IRQ */ 1865: ADRENO_IRQ_CALLBACK(NULL), /* 31 - ISDB_UNDER_DEBUG */ 1866: }; 1867: 1868: /* 1869: * If the AHB fence is not in ALLOW mode when we receive an RBBM 1870: * interrupt, something went wrong. This means that we cannot proceed 1871: * since the IRQ status and clear registers are not accessible. 1872: * This is usually harmless because the GMU will abort power collapse 1873: * and change the fence back to ALLOW. Poll so that this can happen. 1874: */ 1875: static int a6xx_irq_poll_fence(struct adreno_device *adreno_dev) 1876: { 1877: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1878: u32 status, fence, fence_retries = 0; 1879: u64 a, b, c; 1880: 1881: if (!gmu_core_isenabled(device)) 1882: return 0; 1883: 1884: a = a6xx_read_alwayson(adreno_dev); 1885: 1886: kgsl_regread(device, A6XX_GMU_AO_AHB_FENCE_CTRL, &fence); 1887: 1888: while (fence != 0) { 1889: b = a6xx_read_alwayson(adreno_dev); 1890: 1891: /* Wait for small time before trying again */ 1892: udelay(1); 1893: kgsl_regread(device, A6XX_GMU_AO_AHB_FENCE_CTRL, &fence); 1894: 1895: if (fence_retries == 100 && fence != 0) { 1896: c = a6xx_read_alwayson(adreno_dev); 1897: 1898: kgsl_regread(device, A6XX_GMU_RBBM_INT_UNMASKED_STATUS, 1899: &status); 1900: 1901: dev_crit_ratelimited(device->dev, 1902: "status=0x%x Unmasked status=0x%x Mask=0x%x timestamps: %llx %llx %llx\n", 1903: status & adreno_dev->irq_mask, status, 1904: adreno_dev->irq_mask, a, b, c); 1905: return -ETIMEDOUT; 1906: } 1907: 1908: fence_retries++; 1909: } 1910: 1911: return 0; 1912: } 1913: 1914: static irqreturn_t a6xx_hwsched_irq_handler(struct adreno_device *adreno_dev) 1915: { 1916: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1917: irqreturn_t ret = IRQ_NONE; 1918: u32 status; 1919: 1920: /* 1921: * On A6xx, the GPU can power down once the INT_0_STATUS is read 1922: * below. But there still might be some register reads required 1923: * so force the GMU/GPU into KEEPALIVE mode until done with the ISR. 1924: */ 1925: a6xx_gpu_keepalive(adreno_dev, true); 1926: 1927: kgsl_regread(device, A6XX_RBBM_INT_0_STATUS, &status); 1928: 1929: kgsl_regwrite(device, A6XX_RBBM_INT_CLEAR_CMD, status); 1930: 1931: ret = adreno_irq_callbacks(adreno_dev, a6xx_irq_funcs, status); 1932: 1933: trace_kgsl_a5xx_irq_status(adreno_dev, status); 1934: 1935: /* If hard fault, then let snapshot turn off the keepalive */ 1936: if (!(adreno_gpu_fault(adreno_dev) & ADRENO_HARD_FAULT)) 1937: a6xx_gpu_keepalive(adreno_dev, false); 1938: 1939: return ret; 1940: } 1941: 1942: static irqreturn_t a6xx_irq_handler(struct adreno_device *adreno_dev) 1943: { 1944: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1945: irqreturn_t ret = IRQ_NONE; 1946: u32 status; 1947: 1948: /* 1949: * On A6xx, the GPU can power down once the INT_0_STATUS is read 1950: * below. But there still might be some register reads required 1951: * so force the GMU/GPU into KEEPALIVE mode until done with the ISR. 1952: */ 1953: a6xx_gpu_keepalive(adreno_dev, true); 1954: 1955: if (a6xx_irq_poll_fence(adreno_dev)) { 1956: adreno_scheduler_fault(adreno_dev, ADRENO_GMU_FAULT); 1957: goto done; 1958: } 1959: 1960: kgsl_regread(device, A6XX_RBBM_INT_0_STATUS, &status); 1961: 1962: kgsl_regwrite(device, A6XX_RBBM_INT_CLEAR_CMD, status); 1963: 1964: ret = adreno_irq_callbacks(adreno_dev, a6xx_irq_funcs, status); 1965: 1966: trace_kgsl_a5xx_irq_status(adreno_dev, status); 1967: 1968: done: 1969: /* If hard fault, then let snapshot turn off the keepalive */ 1970: if (!(adreno_gpu_fault(adreno_dev) & ADRENO_HARD_FAULT)) 1971: a6xx_gpu_keepalive(adreno_dev, false); 1972: 1973: return ret; 1974: } 1975: 1976: int a6xx_probe_common(struct platform_device *pdev, 1977: struct adreno_device *adreno_dev, u32 chipid, 1978: const struct adreno_gpu_core *gpucore) 1979: { 1980: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1981: const struct adreno_gpudev *gpudev = gpucore->gpudev; 1982: int ret; 1983: 1984: adreno_dev->gpucore = gpucore; 1985: adreno_dev->chipid = chipid; 1986: 1987: adreno_reg_offset_init(gpudev->reg_offsets); 1988: 1989: if (gmu_core_isenabled(device) && (gpudev != &adreno_a6xx_rgmu_gpudev)) { 1990: device->pwrctrl.cx_cfg_gdsc_offset = (adreno_is_a662(adreno_dev) || 1991: adreno_is_a621(adreno_dev) || adreno_is_a663(adreno_dev) || 1992: adreno_is_a623(adreno_dev)) ? 1993: A662_GPU_CC_CX_CFG_GDSCR : A6XX_GPU_CC_CX_CFG_GDSCR; 1994: 1995: if (adreno_is_a622(adreno_dev)) 1996: device->pwrctrl.cx_cfg_gdsc_offset = A622_GPU_CC_CX_CFG_GDSCR; 1997: } 1998: 1999: adreno_dev->hwcg_enabled = true; 2000: adreno_dev->uche_client_pf = 1; 2001: 2002: if (adreno_preemption_feature_set(adreno_dev)) { 2003: const struct adreno_a6xx_core *a6xx_core = to_a6xx_core(adreno_dev); 2004: 2005: adreno_dev->total_ctxt_record_sz = a6xx_core->ctxt_record_size ? 2006: a6xx_core->ctxt_record_size : A6XX_CP_CTXRECORD_SIZE_IN_BYTES; 2007: 2008: adreno_dev->preempt.preempt_level = 1; 2009: adreno_dev->preempt.skipsaverestore = true; 2010: adreno_dev->preempt.usesgmem = true; 2011: } 2012: 2013: ret = adreno_device_probe(pdev, adreno_dev); 2014: 2015: if (ret) 2016: return ret; 2017: 2018: a6xx_coresight_init(adreno_dev); 2019: return 0; 2020: } 2021: 2022: static int a6xx_probe(struct platform_device *pdev, 2023: u32 chipid, const struct adreno_gpu_core *gpucore) 2024: { 2025: struct adreno_device *adreno_dev; 2026: struct kgsl_device *device; 2027: struct platform_device *gmu_wrapper_pdev; 2028: int ret; 2029: 2030: adreno_dev = (struct adreno_device *) 2031: of_device_get_match_data(&pdev->dev); 2032: 2033: memset(adreno_dev, 0, sizeof(*adreno_dev)); 2034: 2035: adreno_dev->irq_mask = A6XX_INT_MASK; 2036: 2037: ret = a6xx_probe_common(pdev, adreno_dev, chipid, gpucore); 2038: if (ret) 2039: return ret; 2040: 2041: device = KGSL_DEVICE(adreno_dev); 2042: 2043: /* 2044: * In standard DT bindings, no-GMU targets have a wrapper device 2045: * with a dedicated "gmu" register range. In contrast, non-standard 2046: * DT bindings include these registers within "kgsl_3d0_reg_memory" 2047: * for such targets. To handle the first case, add the "gmu" block to 2048: * the regmap if the wrapper device is present. 2049: */ 2050: gmu_wrapper_pdev = get_gmu_wrapper_pdev(); 2051: 2052: if (gmu_wrapper_pdev) { 2053: struct resource *res; 2054: struct kgsl_regmap *regmap = &device->regmap; 2055: struct kgsl_regmap_region *region; 2056: 2057: res = platform_get_resource_byname(gmu_wrapper_pdev, IORESOURCE_MEM, "gmu"); 2058: 2059: if (!res) { 2060: platform_device_put(gmu_wrapper_pdev); 2061: return -ENODEV; MATCH LINES: 2092, 2094, 2095, 2096, 2097, 2098, 2099, 2100, 2101, 2102, 2103, 2104, 2105, 2106, 2107, 2108, 2109, 2111, 2113, 2116, 2134, 2161, 2162, 2167, 2181, 2187, 2188, 2191, 2192, 2195, 2198, 2207, 2213, 2248, 2256, 2259, 2269, 2278, 2281, 2287 2080: ret = adreno_dispatcher_init(adreno_dev); 2081: if (ret) 2082: return ret; 2083: 2084: timer_setup(&device->idle_timer, kgsl_timer, 0); 2085: 2086: INIT_WORK(&device->idle_check_ws, kgsl_idle_check); 2087: 2088: return 0; 2089: } 2090: 2091: /* Register offset defines for A6XX, in order of enum adreno_regs */ 2092: static unsigned int a6xx_register_offsets[ADRENO_REG_REGISTER_MAX] = { 2093: 2094: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_BASE, A6XX_CP_RB_BASE), 2095: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_BASE_HI, A6XX_CP_RB_BASE_HI), 2096: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_RPTR, A6XX_CP_RB_RPTR), 2097: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_WPTR, A6XX_CP_RB_WPTR), 2098: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_CNTL, A6XX_CP_RB_CNTL), 2099: ADRENO_REG_DEFINE(ADRENO_REG_CP_ME_CNTL, A6XX_CP_SQE_CNTL), 2100: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BASE, A6XX_CP_IB1_BASE), 2101: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BASE_HI, A6XX_CP_IB1_BASE_HI), 2102: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BUFSZ, A6XX_CP_IB1_REM_SIZE), 2103: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BASE, A6XX_CP_IB2_BASE), 2104: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BASE_HI, A6XX_CP_IB2_BASE_HI), 2105: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BUFSZ, A6XX_CP_IB2_REM_SIZE), 2106: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_STATUS, A6XX_RBBM_STATUS), 2107: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_STATUS3, A6XX_RBBM_STATUS3), 2108: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_INT_0_MASK, A6XX_RBBM_INT_0_MASK), 2109: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_SW_RESET_CMD, A6XX_RBBM_SW_RESET_CMD), 2110: ADRENO_REG_DEFINE(ADRENO_REG_GMU_AO_HOST_INTERRUPT_MASK, 2111: A6XX_GMU_AO_HOST_INTERRUPT_MASK), 2112: ADRENO_REG_DEFINE(ADRENO_REG_GMU_GMU2HOST_INTR_MASK, 2113: A6XX_GMU_GMU2HOST_INTR_MASK), 2114: }; 2115: 2116: int a6xx_perfcounter_update(struct adreno_device *adreno_dev, 2117: struct adreno_perfcount_register *reg, bool update_reg) 2118: { 2119: void *ptr = adreno_dev->pwrup_reglist->hostptr; 2120: struct cpu_gpu_lock *lock = ptr; 2121: u32 *data = ptr + sizeof(*lock); 2122: u64 reglist_size_dwords = adreno_dev->pwrup_reglist->size / sizeof(u32); 2123: u64 lock_size_dwords = sizeof(*lock) / sizeof(u32); 2124: int i, offset = 0; 2125: bool select_reg_present = false; 2126: u32 pending_pairs = 2; /* No of pairs to add: and */ 2127: 2128: for (i = 0; i < lock->list_length >> 1; i++) { 2129: if (data[offset] == reg->select) { 2130: select_reg_present = true; 2131: break; 2132: } 2133: 2134: if (data[offset] == A6XX_RBBM_PERFCTR_CNTL) 2135: break; 2136: 2137: offset += 2; 2138: } 2139: 2140: /* Ensure there is enough space in the reglist buffer for new pairs */ 2141: if ((!select_reg_present) && ((offset + (pending_pairs * 2) + lock_size_dwords) >= 2142: reglist_size_dwords)) 2143: return -ENOSPC; 2144: 2145: if (kgsl_hwlock(lock)) { 2146: kgsl_hwunlock(lock); 2147: return -EBUSY; 2148: } 2149: 2150: /* 2151: * If the perfcounter select register is already present in reglist 2152: * update it, otherwise append the