= 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 <linux/msm_kgsl.h>
17: #include <linux/sched/clock.h>
18: #include <soc/qcom/msm_performance.h>
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 <linux/utsname.h>
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 <linux/sched.h>
8: #include <linux/sched/clock.h>
9: #include <linux/slab.h>
10: #include <linux/spinlock.h>
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 <linux/platform_device.h>
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 <linux/vmalloc.h>
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 <linux/dma-mapping.h>
11: #include <linux/platform_device.h>
12: #include <linux/scatterlist.h>
13: #include <linux/slab.h>
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 <linux/devcoredump.h>
8: #include <linux/of.h>
9: #include <linux/panic_notifier.h>
10: #include <linux/slab.h>
11: #include <linux/utsname.h>
12: #include <linux/vmalloc.h>
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 <linux/types.h>
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 <linux/firmware/qcom/qcom_pas.h>
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 <linux/firmware/qcom/qcom_scm.h>
318: #else
319: #include <linux/qcom_scm.h>
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 <linux/iommu.h>
11:
12: #include <soc/qcom/secure_buffer.h>
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 <linux/io.h>
10: #include <linux/of.h>
11: #include <linux/of_fdt.h>
12: #include <linux/of_device.h>
13: #include <soc/qcom/of_common.h>
14: #include <linux/version.h>
15: #if (KERNEL_VERSION(6, 17, 0) <= LINUX_VERSION_CODE)
16: #include <linux/soc/qcom/ubwc.h>
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: <select,value> and <cntl,1> */
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 <select register, value> pair to
2153: * the end of the list.
2154: */
2155: if (select_reg_present) {
2156: data[offset + 1] = reg->countable;
2157: goto update;
2158: }
2159:
2160: /*
2161: * For all targets A6XX_RBBM_PERFCTR_CNTL needs to be the last entry,
2162: * so overwrite the existing A6XX_RBBM_PERFCNTL_CTRL and add it back to
2163: * the end.
2164: */
2165: data[offset] = reg->select;
2166: data[offset + 1] = reg->countable;
2167: data[offset + 2] = A6XX_RBBM_PERFCTR_CNTL;
2168: data[offset + 3] = 1;
2169:
2170: lock->list_length += 2;
2171:
2172: update:
2173: if (update_reg)
2174: kgsl_regwrite(KGSL_DEVICE(adreno_dev), reg->select,
2175: reg->countable);
2176:
2177: kgsl_hwunlock(lock);
2178: return 0;
2179: }
2180:
2181: u64 a6xx_read_alwayson(struct adreno_device *adreno_dev)
2182: {
2183: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2184: u32 lo = 0, hi = 0, tmp = 0;
2185:
2186: if (!gmu_core_isenabled(device)) {
2187: kgsl_regread(device, A6XX_CP_ALWAYS_ON_COUNTER_LO, &lo);
2188: kgsl_regread(device, A6XX_CP_ALWAYS_ON_COUNTER_HI, &hi);
2189: } else {
2190: /* Always use the GMU AO counter when doing a AHB read */
2191: gmu_core_regread(device, A6XX_GMU_ALWAYS_ON_COUNTER_H, &hi);
2192: gmu_core_regread(device, A6XX_GMU_ALWAYS_ON_COUNTER_L, &lo);
2193:
2194: /* Check for overflow */
2195: gmu_core_regread(device, A6XX_GMU_ALWAYS_ON_COUNTER_H, &tmp);
2196:
2197: if (hi != tmp) {
2198: gmu_core_regread(device, A6XX_GMU_ALWAYS_ON_COUNTER_L,
2199: &lo);
2200: hi = tmp;
2201: }
2202: }
2203:
2204: return (((u64) hi) << 32) | lo;
2205: }
2206:
2207: static void a6xx_remove(struct adreno_device *adreno_dev)
2208: {
2209: if (adreno_preemption_feature_set(adreno_dev))
2210: kgsl_delete_timer(&adreno_dev->preempt.timer);
2211: }
2212:
2213: static void a6xx_read_bus_stats(struct kgsl_device *device,
2214: struct kgsl_power_stats *stats,
2215: struct adreno_busy_data *busy)
2216: {
2217: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
2218: u64 ram_cycles, starved_ram;
2219:
2220: ram_cycles = counter_delta(device, adreno_dev->ram_cycles_lo,
2221: &busy->bif_ram_cycles);
2222:
2223: starved_ram = counter_delta(device, adreno_dev->starved_ram_lo,
2224: &busy->bif_starved_ram);
2225:
2226: if (!adreno_is_a630(adreno_dev)) {
2227: ram_cycles += counter_delta(device,
2228: adreno_dev->ram_cycles_lo_ch1_read,
2229: &busy->bif_ram_cycles_read_ch1);
2230:
2231: ram_cycles += counter_delta(device,
2232: adreno_dev->ram_cycles_lo_ch0_write,
2233: &busy->bif_ram_cycles_write_ch0);
2234:
2235: ram_cycles += counter_delta(device,
2236: adreno_dev->ram_cycles_lo_ch1_write,
2237: &busy->bif_ram_cycles_write_ch1);
2238:
2239: starved_ram += counter_delta(device,
2240: adreno_dev->starved_ram_lo_ch1,
2241: &busy->bif_starved_ram_ch1);
2242: }
2243:
2244: stats->ram_time = ram_cycles;
2245: stats->ram_wait = starved_ram;
2246: }
2247:
2248: static void a6xx_power_stats(struct adreno_device *adreno_dev,
2249: struct kgsl_power_stats *stats)
2250: {
2251: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2252: struct adreno_busy_data *busy = &adreno_dev->busy_data;
2253: s64 gpu_busy;
2254:
2255: /* Set the GPU busy counter for frequency scaling */
2256: gpu_busy = counter_delta(device, A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_L,
2257: &busy->gpu_busy);
2258:
2259: gpu_busy += a6xx_read_throttling_counters(adreno_dev);
2260: /* If adjustment cycles are more than busy cycles make gpu_busy zero */
2261: if (gpu_busy < 0)
2262: gpu_busy = 0;
2263:
2264: stats->busy_time = gpu_busy * 10;
2265: do_div(stats->busy_time, 192);
2266:
2267: if (ADRENO_FEATURE(adreno_dev, ADRENO_IFPC)) {
2268: u32 ifpc = counter_delta(device,
2269: A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_4_L,
2270: &busy->num_ifpc);
2271:
2272: adreno_dev->ifpc_count += ifpc;
2273: if (ifpc > 0)
2274: trace_adreno_ifpc_count(adreno_dev->ifpc_count);
2275: }
2276:
2277: if (device->pwrctrl.bus_control)
2278: a6xx_read_bus_stats(device, stats, busy);
2279: }
2280:
2281: static int a6xx_dev_add_to_minidump(struct adreno_device *adreno_dev)
2282: {
2283: return kgsl_add_va_to_minidump(adreno_dev->dev.dev, KGSL_ADRENO_DEVICE,
2284: (void *)(adreno_dev), sizeof(struct adreno_device));
2285: }
2286:
2287: static void a6xx_set_isdb_breakpoint_registers(struct adreno_device *adreno_dev)
2288: {
2289: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2290: struct clk *clk;
2291: int ret;
2292:
2293: /* QDSS unavailable, suppress force panic */
2294: if (!IS_ENABLED(CONFIG_QCOM_KGSL_QDSS_STM))
2295: goto err;
2296:
2297: if (!device->set_isdb_breakpoint || device->ftbl->is_hwcg_on(device)
2298: || device->qdss_gfx_virt == NULL || !device->force_panic)
2299: return;
2300:
2301: clk = clk_get(&device->pdev->dev, "apb_pclk");
2302:
2303: if (IS_ERR(clk)) {
2304: dev_err(device->dev, "Unable to get QDSS clock\n");
2305: goto err;
2306: }
2307:
2308: ret = clk_prepare_enable(clk);
2309:
2310: if (ret) {
2311: dev_err(device->dev, "QDSS Clock enable error: %d\n", ret);
MATCH LINES: 2340, 2346, 2364, 2372, 2373, 2375, 2384, 2385, 2386, 2387, 2388, 2389, 2390, 2391, 2392, 2393, 2394, 2395, 2396, 2397, 2398, 2400, 2401, 2402, 2403, 2405, 2406, 2407, 2410, 2412, 2413, 2414, 2415, 2416, 2417, 2418, 2419, 2420, 2421, 2422, 2423, 2424, 2425, 2426, 2428, 2429, 2430, 2433, 2435, 2436, 2437, 2438, 2439, 2440, 2441, 2442, 2443, 2444, 2445, 2446, 2447, 2448, 2449, 2450, 2451, 2452, 2453, 2454, 2456, 2457, 2460, 2461, 2462, 2463, 2464, 2465, 2466, 2467, 2468, 2469, 2470, 2471, 2472, 2473, 2474, 2475, 2476, 2477, 2478, 2479, 2484, 2485, 2486, 2487, 2488, 2489, 2490, 2493, 2495, 2496, 2497, 2498, 2500, 2501, 2502, 2503, 2505, 2506, 2510, 2512, 2513, 2514, 2515, 2516, 2517, 2518, 2519, 2520, 2521, 2522, 2523, 2524, 2526, 2527, 2528, 2529, 2530, 2532, 2533
2328:
2329: return;
2330:
2331: err:
2332: /* Do not force kernel panic if isdb writes did not go through */
2333: device->force_panic = false;
2334: }
2335:
2336: static int a619_holi_sptprac_enable(struct adreno_device *adreno_dev)
2337: {
2338: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2339: void __iomem *addr = kgsl_regmap_virt(&device->regmap,
2340: A6XX_GMU_SPTPRAC_PWR_CLK_STATUS);
2341: u32 val;
2342:
2343: if (test_bit(ADRENO_DEVICE_GPU_REGULATOR_ENABLED, &adreno_dev->priv))
2344: return 0;
2345:
2346: kgsl_regwrite(device, A6XX_GMU_GX_SPTPRAC_POWER_CONTROL,
2347: SPTPRAC_POWERON_CTRL_MASK);
2348:
2349: if (readl_poll_timeout(addr, val,
2350: (val & SPTPRAC_POWERON_STATUS_MASK) ==
2351: SPTPRAC_POWERON_STATUS_MASK, 10, 10 * 1000)) {
2352: dev_err(device->dev, "power on SPTPRAC fail\n");
2353: return -EINVAL;
2354: }
2355:
2356: set_bit(ADRENO_DEVICE_GPU_REGULATOR_ENABLED, &adreno_dev->priv);
2357: return 0;
2358: }
2359:
2360: static void a619_holi_sptprac_disable(struct adreno_device *adreno_dev)
2361: {
2362: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2363: void __iomem *addr = kgsl_regmap_virt(&device->regmap,
2364: A6XX_GMU_SPTPRAC_PWR_CLK_STATUS);
2365: u32 val;
2366:
2367: if (!test_and_clear_bit(ADRENO_DEVICE_GPU_REGULATOR_ENABLED,
2368: &adreno_dev->priv))
2369: return;
2370:
2371: /* Ensure that retention is on */
2372: kgsl_regrmw(device, A6XX_GPU_CC_GX_GDSCR, 0,
2373: A6XX_RETAIN_FF_ENABLE_ENABLE_MASK);
2374:
2375: kgsl_regwrite(device, A6XX_GMU_GX_SPTPRAC_POWER_CONTROL,
2376: SPTPRAC_POWEROFF_CTRL_MASK);
2377: if (readl_poll_timeout(addr, val,
2378: (val & SPTPRAC_POWEROFF_STATUS_MASK) ==
2379: SPTPRAC_POWEROFF_STATUS_MASK, 10, 10 * 1000))
2380: dev_err(device->dev, "power off SPTPRAC fail\n");
2381: }
2382:
2383: /* This is a non GMU/RGMU part */
2384: const struct adreno_gpudev adreno_a6xx_gpudev = {
2385: .reg_offsets = a6xx_register_offsets,
2386: .probe = a6xx_probe,
2387: .start = a6xx_nogmu_start,
2388: .snapshot = a6xx_snapshot,
2389: .init = a6xx_nogmu_init,
2390: .irq_handler = a6xx_irq_handler,
2391: .rb_start = a6xx_rb_start,
2392: .regulator_disable = a6xx_prepare_for_regulator_disable,
2393: .gpu_keepalive = a6xx_gpu_keepalive,
2394: .hw_isidle = a6xx_hw_isidle,
2395: .iommu_fault_block = a6xx_iommu_fault_block,
2396: .reset = a6xx_reset,
2397: .preemption_schedule = a6xx_preemption_schedule,
2398: .read_alwayson = a6xx_read_alwayson,
2399: .power_ops = &adreno_power_operations,
2400: .clear_pending_transactions = a6xx_clear_pending_transactions,
2401: .deassert_gbif_halt = a6xx_deassert_gbif_halt,
2402: .remove = a6xx_remove,
2403: .ringbuffer_submitcmd = a6xx_ringbuffer_submitcmd,
2404: .is_hw_collapsible = adreno_isidle,
2405: .power_stats = a6xx_power_stats,
2406: .add_to_va_minidump = a6xx_dev_add_to_minidump,
2407: .gx_is_on = a6xx_gx_is_on,
2408: };
2409:
2410: const struct a6xx_gpudev adreno_a6xx_hwsched_gpudev = {
2411: .base = {
2412: .reg_offsets = a6xx_register_offsets,
2413: .probe = a6xx_hwsched_probe,
2414: .snapshot = a6xx_hwsched_snapshot,
2415: .irq_handler = a6xx_hwsched_irq_handler,
2416: .iommu_fault_block = a6xx_iommu_fault_block,
2417: .context_detach = a6xx_hwsched_context_detach,
2418: .read_alwayson = a6xx_read_alwayson,
2419: .reset = a6xx_hwsched_reset_replay,
2420: .power_ops = &a6xx_hwsched_power_ops,
2421: .power_stats = a6xx_power_stats,
2422: .hw_isidle = a6xx_hw_isidle,
2423: .add_to_va_minidump = a6xx_hwsched_add_to_minidump,
2424: .gx_is_on = a6xx_gmu_gx_is_on,
2425: .send_recurring_cmdobj = a6xx_hwsched_send_recurring_cmdobj,
2426: .set_isdb_breakpoint_registers = a6xx_set_isdb_breakpoint_registers,
2427: },
2428: .hfi_probe = a6xx_hwsched_hfi_probe,
2429: .hfi_remove = a6xx_hwsched_hfi_remove,
2430: .handle_watchdog = a6xx_hwsched_handle_watchdog,
2431: };
2432:
2433: const struct a6xx_gpudev adreno_a6xx_gmu_gpudev = {
2434: .base = {
2435: .reg_offsets = a6xx_register_offsets,
2436: .probe = a6xx_gmu_device_probe,
2437: .snapshot = a6xx_gmu_snapshot,
2438: .irq_handler = a6xx_irq_handler,
2439: .rb_start = a6xx_rb_start,
2440: .regulator_enable = a6xx_sptprac_enable,
2441: .regulator_disable = a6xx_sptprac_disable,
2442: .gpu_keepalive = a6xx_gpu_keepalive,
2443: .hw_isidle = a6xx_hw_isidle,
2444: .iommu_fault_block = a6xx_iommu_fault_block,
2445: .reset = a6xx_gmu_reset,
2446: .preemption_schedule = a6xx_preemption_schedule,
2447: .read_alwayson = a6xx_read_alwayson,
2448: .power_ops = &a6xx_gmu_power_ops,
2449: .remove = a6xx_remove,
2450: .ringbuffer_submitcmd = a6xx_ringbuffer_submitcmd,
2451: .power_stats = a6xx_power_stats,
2452: .add_to_va_minidump = a6xx_gmu_add_to_minidump,
2453: .gx_is_on = a6xx_gmu_gx_is_on,
2454: .set_isdb_breakpoint_registers = a6xx_set_isdb_breakpoint_registers,
2455: },
2456: .hfi_probe = a6xx_gmu_hfi_probe,
2457: .handle_watchdog = a6xx_gmu_handle_watchdog,
2458: };
2459:
2460: const struct adreno_gpudev adreno_a6xx_rgmu_gpudev = {
2461: .reg_offsets = a6xx_register_offsets,
2462: .probe = a6xx_rgmu_device_probe,
2463: .snapshot = a6xx_rgmu_snapshot,
2464: .irq_handler = a6xx_irq_handler,
2465: .rb_start = a6xx_rb_start,
2466: .regulator_enable = a6xx_sptprac_enable,
2467: .regulator_disable = a6xx_sptprac_disable,
2468: .gpu_keepalive = a6xx_gpu_keepalive,
2469: .hw_isidle = a6xx_hw_isidle,
2470: .iommu_fault_block = a6xx_iommu_fault_block,
2471: .reset = a6xx_rgmu_reset,
2472: .preemption_schedule = a6xx_preemption_schedule,
2473: .read_alwayson = a6xx_read_alwayson,
2474: .power_ops = &a6xx_rgmu_power_ops,
2475: .remove = a6xx_remove,
2476: .ringbuffer_submitcmd = a6xx_ringbuffer_submitcmd,
2477: .power_stats = a6xx_power_stats,
2478: .add_to_va_minidump = a6xx_rgmu_add_to_minidump,
2479: .gx_is_on = a6xx_rgmu_gx_is_on,
2480: };
2481:
2482: /* This is a non GMU/RGMU part */
2483: const struct adreno_gpudev adreno_a619_holi_gpudev = {
2484: .reg_offsets = a6xx_register_offsets,
2485: .probe = a6xx_probe,
2486: .start = a6xx_nogmu_start,
2487: .snapshot = a6xx_snapshot,
2488: .init = a6xx_nogmu_init,
2489: .irq_handler = a6xx_irq_handler,
2490: .rb_start = a6xx_rb_start,
2491: .regulator_enable = a619_holi_sptprac_enable,
2492: .regulator_disable = a619_holi_sptprac_disable,
2493: .gpu_keepalive = a6xx_gpu_keepalive,
2494: .hw_isidle = a619_holi_hw_isidle,
2495: .iommu_fault_block = a6xx_iommu_fault_block,
2496: .reset = a6xx_reset,
2497: .preemption_schedule = a6xx_preemption_schedule,
2498: .read_alwayson = a6xx_read_alwayson,
2499: .power_ops = &adreno_power_operations,
2500: .clear_pending_transactions = a6xx_clear_pending_transactions,
2501: .deassert_gbif_halt = a6xx_deassert_gbif_halt,
2502: .remove = a6xx_remove,
2503: .ringbuffer_submitcmd = a6xx_ringbuffer_submitcmd,
2504: .is_hw_collapsible = adreno_isidle,
2505: .power_stats = a6xx_power_stats,
2506: .add_to_va_minidump = a6xx_dev_add_to_minidump,
2507: .gx_is_on = a619_holi_gx_is_on,
2508: };
2509:
2510: const struct a6xx_gpudev adreno_a630_gpudev = {
2511: .base = {
2512: .reg_offsets = a6xx_register_offsets,
2513: .probe = a6xx_gmu_device_probe,
2514: .snapshot = a6xx_gmu_snapshot,
2515: .irq_handler = a6xx_irq_handler,
2516: .rb_start = a6xx_rb_start,
2517: .regulator_enable = a6xx_sptprac_enable,
2518: .regulator_disable = a6xx_sptprac_disable,
2519: .gpu_keepalive = a6xx_gpu_keepalive,
2520: .hw_isidle = a6xx_hw_isidle,
2521: .iommu_fault_block = a6xx_iommu_fault_block,
2522: .reset = a6xx_gmu_reset,
2523: .preemption_schedule = a6xx_preemption_schedule,
2524: .read_alwayson = a6xx_read_alwayson,
2525: .power_ops = &a630_gmu_power_ops,
2526: .remove = a6xx_remove,
2527: .ringbuffer_submitcmd = a6xx_ringbuffer_submitcmd,
2528: .power_stats = a6xx_power_stats,
2529: .add_to_va_minidump = a6xx_gmu_add_to_minidump,
2530: .gx_is_on = a6xx_gmu_gx_is_on,
2531: },
2532: .hfi_probe = a6xx_gmu_hfi_probe,
2533: .handle_watchdog = a6xx_gmu_handle_watchdog,
2534: };
--- FILE: \adreno_a6xx.h | HITS: 110 ---
MATCH LINES: 7, 8, 12, 13, 14, 16, 17, 19, 21, 28, 29, 30, 33, 35, 37, 39, 45, 47
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 _ADRENO_A6XX_H_
8: #define _ADRENO_A6XX_H_
9:
10: #include <linux/delay.h>
11:
12: #include "a6xx_reg.h"
13: #include "adreno_a6xx_gmu.h"
14: #include "adreno_a6xx_rgmu.h"
15:
16: extern const struct adreno_power_ops a6xx_gmu_power_ops;
17: extern const struct adreno_power_ops a6xx_rgmu_power_ops;
18: extern const struct adreno_power_ops a630_gmu_power_ops;
19: extern const struct adreno_power_ops a6xx_hwsched_power_ops;
20:
21: struct a6xx_gpudev {
22: struct adreno_gpudev base;
23: int (*hfi_probe)(struct adreno_device *adreno_dev);
24: void (*hfi_remove)(struct adreno_device *adreno_dev);
25: void (*handle_watchdog)(struct adreno_device *adreno_dev);
26: };
27:
28: extern const struct a6xx_gpudev adreno_a630_gpudev;
29: extern const struct a6xx_gpudev adreno_a6xx_gmu_gpudev;
30: extern const struct a6xx_gpudev adreno_a6xx_hwsched_gpudev;
31:
32: /**
33: * struct a6xx_device - Container for the a6xx_device
34: */
35: struct a6xx_device {
36: /** @gmu: Container for the a6xx GMU device */
37: struct a6xx_gmu_device gmu;
38: /** @rgmu: Container for the a6xx rGMU device */
39: struct a6xx_rgmu_device rgmu;
40: /** @adreno_dev: Container for the generic adreno device */
41: struct adreno_device adreno_dev;
42: };
43:
44: /**
45: * struct adreno_a6xx_core - a6xx specific GPU core definitions
46: */
47: struct adreno_a6xx_core {
48: /** @base: Container for the generic GPU definitions */
49: struct adreno_gpu_core base;
50: /** @gmu_major: The maximum GMU version supported by the core */
51: u32 gmu_major;
52: /** @gmu_minor: The minimum GMU version supported by the core */
53: u32 gmu_minor;
54: /** @prim_fifo_threshold: target specific value for PC_DBG_ECO_CNTL */
55: unsigned int prim_fifo_threshold;
56: /** @sqefw_name: Name of the SQE microcode file */
57: const char *sqefw_name;
58: /** @gmufw_name: Name of the GMU firmware file */
59: const char *gmufw_name;
60: /**
61: * @zap_name: Specifies the name of the CPZ zap file. This field is deprecated.
62: * Use the 'firmware-name' device tree property instead.
63: */
64: const char *zap_name;
65: /** @hwcg: List of registers and values to write for HWCG */
66: const struct kgsl_regmap_list *hwcg;
67: /** @hwcg_count: Number of registers in @hwcg */
68: u32 hwcg_count;
69: /** @vbif: List of registers and values to write for VBIF */
70: const struct kgsl_regmap_list *vbif;
71: /** @vbif_count: Number of registers in @vbif */
MATCH LINES: 95, 106, 109, 112, 124, 139, 141, 147, 155, 157, 159, 161, 163, 167, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 185, 186, 187, 188, 189, 190, 191, 194, 200, 201, 205, 209, 210, 211, 212, 215, 221, 224, 232, 236, 238, 240, 242, 243, 244, 245, 249, 254, 257, 263, 266, 275, 278, 286, 289, 297, 300, 309, 314, 319, 323, 330, 334, 340, 343, 344, 347, 361, 366, 374, 379, 382, 385, 387, 389, 390, 392, 396, 401, 404, 409, 412, 414
83: /** @gx_cpr_toggle: True to toggle GX CPR FSM to avoid CPR stalls */
84: bool gx_cpr_toggle;
85: /** @ctxt_record_size: Size of the preemption record in bytes */
86: u64 ctxt_record_size;
87: /** @gmu_hub_clk_freq: Gmu hub interface clock frequency */
88: u64 gmu_hub_clk_freq;
89: };
90:
91: #define SPTPRAC_POWERON_CTRL_MASK 0x00778000
92: #define SPTPRAC_POWEROFF_CTRL_MASK 0x00778001
93: #define SPTPRAC_POWEROFF_STATUS_MASK BIT(2)
94: #define SPTPRAC_POWERON_STATUS_MASK BIT(3)
95: #define A6XX_RETAIN_FF_ENABLE_ENABLE_MASK BIT(11)
96:
97: #define CP_CLUSTER_FE 0x0
98: #define CP_CLUSTER_SP_VS 0x1
99: #define CP_CLUSTER_PC_VS 0x2
100: #define CP_CLUSTER_GRAS 0x3
101: #define CP_CLUSTER_SP_PS 0x4
102: #define CP_CLUSTER_PS 0x5
103: #define CP_CLUSTER_VPC_PS 0x6
104:
105: /**
106: * struct a6xx_cp_preemption_record - CP context record for
107: * preemption.
108: * @magic: (00) Value at this offset must be equal to
109: * A6XX_CP_CTXRECORD_MAGIC_REF.
110: * @info: (04) Type of record. Written non-zero (usually) by CP.
111: * we must set to zero for all ringbuffers.
112: * @errno: (08) Error code. Initialize this to A6XX_CP_CTXRECORD_ERROR_NONE.
113: * CP will update to another value if a preemption error occurs.
114: * @data: (12) DATA field in YIELD and SET_MARKER packets.
115: * Written by CP when switching out. Not used on switch-in. Initialized to 0.
116: * @cntl: (16) RB_CNTL, saved and restored by CP. We must initialize this.
117: * @rptr: (20) RB_RPTR, saved and restored by CP. We must initialize this.
118: * @wptr: (24) RB_WPTR, saved and restored by CP. We must initialize this.
119: * @_pad28: (28) Reserved/padding.
120: * @rptr_addr: (32) RB_RPTR_ADDR_LO|HI saved and restored. We must initialize.
121: * rbase: (40) RB_BASE_LO|HI saved and restored.
122: * counter: (48) Pointer to preemption counter.
123: */
124: struct a6xx_cp_preemption_record {
125: uint32_t magic;
126: uint32_t info;
127: uint32_t errno;
128: uint32_t data;
129: uint32_t cntl;
130: uint32_t rptr;
131: uint32_t wptr;
132: uint32_t _pad28;
133: uint64_t rptr_addr;
134: uint64_t rbase;
135: uint64_t counter;
136: };
137:
138: /**
139: * struct a6xx_cp_smmu_info - CP preemption SMMU info.
140: * @magic: (00) The value at this offset must be equal to
141: * A6XX_CP_SMMU_INFO_MAGIC_REF.
142: * @_pad4: (04) Reserved/padding
143: * @ttbr0: (08) Base address of the page table for the
144: * incoming context.
145: * @context_idr: (16) Context Identification Register value.
146: */
147: struct a6xx_cp_smmu_info {
148: uint32_t magic;
149: uint32_t _pad4;
150: uint64_t ttbr0;
151: uint32_t asid;
152: uint32_t context_idr;
153: };
154:
155: #define A6XX_CP_SMMU_INFO_MAGIC_REF 0x241350D5UL
156:
157: #define A6XX_CP_CTXRECORD_MAGIC_REF 0xAE399D6EUL
158: /* Size of each CP preemption record */
159: #define A6XX_CP_CTXRECORD_SIZE_IN_BYTES (2112 * 1024)
160: /* Size of the performance counter save/restore block (in bytes) */
161: #define A6XX_CP_PERFCOUNTER_SAVE_RESTORE_SIZE (4 * 1024)
162:
163: #define A6XX_CP_RB_CNTL_DEFAULT (((ilog2(4) << 8) & 0x1F00) | \
164: (ilog2(KGSL_RB_DWORDS >> 1) & 0x3F))
165:
166: /* Size of the CP_INIT pm4 stream in dwords */
167: #define A6XX_CP_INIT_DWORDS 11
168:
169: #define A6XX_INT_MASK \
170: ((1 << A6XX_INT_CP_AHB_ERROR) | \
171: (1 << A6XX_INT_ATB_ASYNCFIFO_OVERFLOW) | \
172: (1 << A6XX_INT_RBBM_GPC_ERROR) | \
173: (1 << A6XX_INT_CP_SW) | \
174: (1 << A6XX_INT_CP_HW_ERROR) | \
175: (1 << A6XX_INT_CP_IB2) | \
176: (1 << A6XX_INT_CP_IB1) | \
177: (1 << A6XX_INT_CP_RB) | \
178: (1 << A6XX_INT_CP_CACHE_FLUSH_TS) | \
179: (1 << A6XX_INT_RBBM_ATB_BUS_OVERFLOW) | \
180: (1 << A6XX_INT_RBBM_HANG_DETECT) | \
181: (1 << A6XX_INT_UCHE_OOB_ACCESS) | \
182: (1 << A6XX_INT_UCHE_TRAP_INTR) | \
183: (1 << A6XX_INT_TSB_WRITE_ERROR))
184:
185: #define A6XX_HWSCHED_INT_MASK \
186: ((1 << A6XX_INT_CP_AHB_ERROR) | \
187: (1 << A6XX_INT_ATB_ASYNCFIFO_OVERFLOW) | \
188: (1 << A6XX_INT_RBBM_ATB_BUS_OVERFLOW) | \
189: (1 << A6XX_INT_UCHE_OOB_ACCESS) | \
190: (1 << A6XX_INT_UCHE_TRAP_INTR) | \
191: (1 << A6XX_INT_TSB_WRITE_ERROR))
192:
193: /**
194: * to_a6xx_core - return the a6xx specific GPU core struct
195: * @adreno_dev: An Adreno GPU device handle
196: *
197: * Returns:
198: * A pointer to the a6xx specific GPU core struct
199: */
200: static inline const struct adreno_a6xx_core *
201: to_a6xx_core(struct adreno_device *adreno_dev)
202: {
203: const struct adreno_gpu_core *core = adreno_dev->gpucore;
204:
205: return container_of(core, struct adreno_a6xx_core, base);
206: }
207:
208: /* Preemption functions */
209: void a6xx_preemption_trigger(struct adreno_device *adreno_dev, bool atomic);
210: void a6xx_preemption_schedule(struct adreno_device *adreno_dev);
211: void a6xx_preemption_start(struct adreno_device *adreno_dev);
212: int a6xx_preemption_init(struct adreno_device *adreno_dev);
213:
214: /**
215: * a6xx_preemption_post_ibsubmit - Insert commands following a submission
216: * @adreno_dev: Adreno GPU handle
217: * @cmds: Pointer to the ringbuffer to insert opcodes
218: *
219: * Return: The number of dwords written to @cmds
220: */
221: u32 a6xx_preemption_post_ibsubmit(struct adreno_device *adreno_dev, u32 *cmds);
222:
223: /**
224: * a6xx_preemption_post_ibsubmit - Insert opcodes before a submission
225: * @adreno_dev: Adreno GPU handle
226: * @rb: The ringbuffer being written
227: * @drawctxt: The draw context being written
228: * @cmds: Pointer to the ringbuffer to insert opcodes
229: *
230: * Return: The number of dwords written to @cmds
231: */
232: u32 a6xx_preemption_pre_ibsubmit(struct adreno_device *adreno_dev,
233: struct adreno_ringbuffer *rb, struct adreno_context *drawctxt,
234: u32 *cmds);
235:
236: void a6xx_preemption_callback(struct adreno_device *adreno_dev, int bit);
237:
238: void a6xx_preemption_context_destroy(struct kgsl_context *context);
239:
240: void a6xx_snapshot(struct adreno_device *adreno_dev,
241: struct kgsl_snapshot *snapshot);
242: void a6xx_crashdump_init(struct adreno_device *adreno_dev);
243: int a6xx_gmu_sptprac_enable(struct adreno_device *adreno_dev);
244: void a6xx_gmu_sptprac_disable(struct adreno_device *adreno_dev);
245: bool a6xx_gmu_sptprac_is_on(struct adreno_device *adreno_dev);
246: bool a619_holi_gx_is_on(struct adreno_device *adreno_dev);
247:
248: /**
249: * a6xx_read_alwayson - Read the current always on clock value
250: * @adreno_dev: An Adreno GPU handle
251: *
252: * Return: The current value of the GMU always on counter
253: */
254: u64 a6xx_read_alwayson(struct adreno_device *adreno_dev);
255:
256: /**
257: * a6xx_start - Program a6xx registers
258: * @adreno_dev: An Adreno GPU handle
259: *
260: * This function does all a6xx register programming every
261: * time we boot the gpu
262: */
263: void a6xx_start(struct adreno_device *adreno_dev);
264:
265: /**
266: * a6xx_init - Initialize a6xx resources
267: * @adreno_dev: An Adreno GPU handle
268: *
269: * This function does a6xx specific one time initialization
270: * and is invoked when the very first client opens a
271: * kgsl instance
272: *
273: * Return: Zero on success and negative error on failure
274: */
275: int a6xx_init(struct adreno_device *adreno_dev);
276:
277: /**
278: * a6xx_rb_start - A6xx specific ringbuffer setup
279: * @adreno_dev: An Adreno GPU handle
280: *
281: * This function does a6xx specific ringbuffer setup and
282: * attempts to submit CP INIT and bring GPU out of secure mode
283: *
284: * Return: Zero on success and negative error on failure
285: */
286: int a6xx_rb_start(struct adreno_device *adreno_dev);
287:
288: /**
289: * a6xx_microcode_read - Get the cp microcode from the filesystem
290: * @adreno_dev: An Adreno GPU handle
291: *
292: * This function gets the firmware from filesystem and sets up
293: * the micorocode global buffer
294: *
295: * Return: Zero on success and negative error on failure
296: */
297: int a6xx_microcode_read(struct adreno_device *adreno_dev);
298:
299: /**
300: * a6xx_probe_common - Probe common a6xx resources
301: * @pdev: Pointer to the platform device
302: * @adreno_dev: Pointer to the adreno device
303: * @chipid: Chipid of the target
304: * @gpucore: Pointer to the gpucore strucure
305: *
306: * This function sets up the a6xx resources common across all
307: * a6xx targets
308: */
309: int a6xx_probe_common(struct platform_device *pdev,
310: struct adreno_device *adreno_dev, u32 chipid,
311: const struct adreno_gpu_core *gpucore);
312:
313: /**
314: * a6xx_spin_idle_debug - Debug logging used when gpu fails to idle
315: * @adreno_dev: An Adreno GPU handle
316: *
317: * This function logs interesting registers and triggers a snapshot
318: */
319: void a6xx_spin_idle_debug(struct adreno_device *adreno_dev,
320: const char *str);
321:
322: /**
323: * a6xx_perfcounter_update - Update the IFPC perfcounter list
324: * @adreno_dev: An Adreno GPU handle
325: * @reg: Perfcounter reg struct to add/remove to the list
326: * @update_reg: true if the perfcounter needs to be programmed by the CPU
327: *
328: * Return: 0 on success or -EBUSY if the lock couldn't be taken
329: */
330: int a6xx_perfcounter_update(struct adreno_device *adreno_dev,
331: struct adreno_perfcount_register *reg, bool update_reg);
332:
333: /*
334: * a6xx_ringbuffer_init - Initialize the ringbuffers
335: * @adreno_dev: An Adreno GPU handle
336: *
337: * Initialize the ringbuffer(s) for a6xx.
338: * Return: 0 on success or negative on failure
339: */
340: int a6xx_ringbuffer_init(struct adreno_device *adreno_dev);
341:
342: extern const struct adreno_perfcounters adreno_a630_perfcounters;
343: extern const struct adreno_perfcounters adreno_a6xx_perfcounters;
344: extern const struct adreno_perfcounters adreno_a6xx_legacy_perfcounters;
345:
346: /**
347: * a6xx_ringbuffer_addcmds - Submit a command to the ringbuffer
348: * @adreno_dev: An Adreno GPU handle
349: * @rb: Pointer to the ringbuffer to submit on
350: * @drawctxt: Pointer to the draw context for the submission, or NULL for
351: * internal submissions
352: * @flags: Flags for the submission
353: * @in: Commands to write to the ringbuffer
354: * @dwords: Size of @in (in dwords)
355: * @timestamp: Timestamp for the submission
356: * @time: Optional pointer to a submit time structure
357: *
358: * Submit a command to the ringbuffer.
359: * Return: 0 on success or negative on failure
360: */
361: int a6xx_ringbuffer_addcmds(struct adreno_device *adreno_dev,
362: struct adreno_ringbuffer *rb, struct adreno_context *drawctxt,
363: u32 flags, u32 *in, u32 dwords, u32 timestamp,
364: struct adreno_submit_time *time);
365: /**
366: * a6xx_ringbuffer_submitcmd - Submit a user command to the ringbuffer
367: * @adreno_dev: An Adreno GPU handle
368: * @cmdobj: Pointer to a user command object
369: * @flags: Internal submit flags
370: * @time: Optional pointer to a adreno_submit_time container
371: *
372: * Return: 0 on success or negative on failure
373: */
374: int a6xx_ringbuffer_submitcmd(struct adreno_device *adreno_dev,
375: struct kgsl_drawobj_cmd *cmdobj, u32 flags,
376: struct adreno_submit_time *time);
377:
378:
379: int a6xx_fenced_write(struct adreno_device *adreno_dev, u32 offset,
380: u32 value, u32 mask);
381:
382: int a6xx_ringbuffer_submit(struct adreno_ringbuffer *rb,
383: struct adreno_submit_time *time, bool sync);
384:
385: void a6xx_cp_init_cmds(struct adreno_device *adreno_dev, u32 *cmds);
386:
387: int a6xx_gmu_hfi_probe(struct adreno_device *adreno_dev);
388:
389: static inline const struct a6xx_gpudev *
390: to_a6xx_gpudev(const struct adreno_gpudev *gpudev)
391: {
392: return container_of(gpudev, struct a6xx_gpudev, base);
393: }
394:
395: /**
396: * a6xx_reset_preempt_records - Reset the preemption buffers
397: * @adreno_dev: Handle to the adreno device
398: *
399: * Reset the preemption records at the time of hard reset
400: */
401: void a6xx_reset_preempt_records(struct adreno_device *adreno_dev);
402:
403: /**
404: * a6xx_irq_pending - Check if there is any gpu irq pending
405: * @adreno_dev: Handle to the adreno device
406: *
407: * Return true if there is any gpu irq pending
408: */
409: bool a6xx_irq_pending(struct adreno_device *adreno_dev);
410:
411: #ifdef CONFIG_QCOM_KGSL_CORESIGHT
412: void a6xx_coresight_init(struct adreno_device *device);
413: #else
414: static inline void a6xx_coresight_init(struct adreno_device *device) { }
415: #endif
416:
417: #endif
--- FILE: \adreno_a6xx_coresight.c | HITS: 231 ---
MATCH LINES: 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 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, 60, 61, 62, 63, 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, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 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, 169, 171, 172, 173, 174, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282
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: #include "adreno.h"
8: #include "adreno_a6xx.h"
9: #include "adreno_coresight.h"
10:
11: static struct adreno_coresight_register a6xx_coresight_regs[] = {
12: { A6XX_DBGC_CFG_DBGBUS_SEL_A },
13: { A6XX_DBGC_CFG_DBGBUS_SEL_B },
14: { A6XX_DBGC_CFG_DBGBUS_SEL_C },
15: { A6XX_DBGC_CFG_DBGBUS_SEL_D },
16: { A6XX_DBGC_CFG_DBGBUS_CNTLT },
17: { A6XX_DBGC_CFG_DBGBUS_CNTLM },
18: { A6XX_DBGC_CFG_DBGBUS_OPL },
19: { A6XX_DBGC_CFG_DBGBUS_OPE },
20: { A6XX_DBGC_CFG_DBGBUS_IVTL_0 },
21: { A6XX_DBGC_CFG_DBGBUS_IVTL_1 },
22: { A6XX_DBGC_CFG_DBGBUS_IVTL_2 },
23: { A6XX_DBGC_CFG_DBGBUS_IVTL_3 },
24: { A6XX_DBGC_CFG_DBGBUS_MASKL_0 },
25: { A6XX_DBGC_CFG_DBGBUS_MASKL_1 },
26: { A6XX_DBGC_CFG_DBGBUS_MASKL_2 },
27: { A6XX_DBGC_CFG_DBGBUS_MASKL_3 },
28: { A6XX_DBGC_CFG_DBGBUS_BYTEL_0 },
29: { A6XX_DBGC_CFG_DBGBUS_BYTEL_1 },
30: { A6XX_DBGC_CFG_DBGBUS_IVTE_0 },
31: { A6XX_DBGC_CFG_DBGBUS_IVTE_1 },
32: { A6XX_DBGC_CFG_DBGBUS_IVTE_2 },
33: { A6XX_DBGC_CFG_DBGBUS_IVTE_3 },
34: { A6XX_DBGC_CFG_DBGBUS_MASKE_0 },
35: { A6XX_DBGC_CFG_DBGBUS_MASKE_1 },
36: { A6XX_DBGC_CFG_DBGBUS_MASKE_2 },
37: { A6XX_DBGC_CFG_DBGBUS_MASKE_3 },
38: { A6XX_DBGC_CFG_DBGBUS_NIBBLEE },
39: { A6XX_DBGC_CFG_DBGBUS_PTRC0 },
40: { A6XX_DBGC_CFG_DBGBUS_PTRC1 },
41: { A6XX_DBGC_CFG_DBGBUS_LOADREG },
42: { A6XX_DBGC_CFG_DBGBUS_IDX },
43: { A6XX_DBGC_CFG_DBGBUS_CLRC },
44: { A6XX_DBGC_CFG_DBGBUS_LOADIVT },
45: { A6XX_DBGC_VBIF_DBG_CNTL },
46: { A6XX_DBGC_DBG_LO_HI_GPIO },
47: { A6XX_DBGC_EXT_TRACE_BUS_CNTL },
48: { A6XX_DBGC_READ_AHB_THROUGH_DBG },
49: { A6XX_DBGC_CFG_DBGBUS_TRACE_BUF1 },
50: { A6XX_DBGC_CFG_DBGBUS_TRACE_BUF2 },
51: { A6XX_DBGC_EVT_CFG },
52: { A6XX_DBGC_EVT_INTF_SEL_0 },
53: { A6XX_DBGC_EVT_INTF_SEL_1 },
54: { A6XX_DBGC_PERF_ATB_CFG },
55: { A6XX_DBGC_PERF_ATB_COUNTER_SEL_0 },
56: { A6XX_DBGC_PERF_ATB_COUNTER_SEL_1 },
57: { A6XX_DBGC_PERF_ATB_COUNTER_SEL_2 },
58: { A6XX_DBGC_PERF_ATB_COUNTER_SEL_3 },
59: { A6XX_DBGC_PERF_ATB_TRIG_INTF_SEL_0 },
60: { A6XX_DBGC_PERF_ATB_TRIG_INTF_SEL_1 },
61: { A6XX_DBGC_PERF_ATB_DRAIN_CMD },
62: { A6XX_DBGC_ECO_CNTL },
63: { A6XX_DBGC_AHB_DBG_CNTL },
64: };
65:
66: static struct adreno_coresight_register a6xx_coresight_regs_cx[] = {
67: { A6XX_CX_DBGC_CFG_DBGBUS_SEL_A },
68: { A6XX_CX_DBGC_CFG_DBGBUS_SEL_B },
69: { A6XX_CX_DBGC_CFG_DBGBUS_SEL_C },
70: { A6XX_CX_DBGC_CFG_DBGBUS_SEL_D },
71: { A6XX_CX_DBGC_CFG_DBGBUS_CNTLT },
72: { A6XX_CX_DBGC_CFG_DBGBUS_CNTLM },
73: { A6XX_CX_DBGC_CFG_DBGBUS_OPL },
74: { A6XX_CX_DBGC_CFG_DBGBUS_OPE },
75: { A6XX_CX_DBGC_CFG_DBGBUS_IVTL_0 },
76: { A6XX_CX_DBGC_CFG_DBGBUS_IVTL_1 },
77: { A6XX_CX_DBGC_CFG_DBGBUS_IVTL_2 },
78: { A6XX_CX_DBGC_CFG_DBGBUS_IVTL_3 },
79: { A6XX_CX_DBGC_CFG_DBGBUS_MASKL_0 },
80: { A6XX_CX_DBGC_CFG_DBGBUS_MASKL_1 },
81: { A6XX_CX_DBGC_CFG_DBGBUS_MASKL_2 },
82: { A6XX_CX_DBGC_CFG_DBGBUS_MASKL_3 },
83: { A6XX_CX_DBGC_CFG_DBGBUS_BYTEL_0 },
84: { A6XX_CX_DBGC_CFG_DBGBUS_BYTEL_1 },
85: { A6XX_CX_DBGC_CFG_DBGBUS_IVTE_0 },
86: { A6XX_CX_DBGC_CFG_DBGBUS_IVTE_1 },
87: { A6XX_CX_DBGC_CFG_DBGBUS_IVTE_2 },
88: { A6XX_CX_DBGC_CFG_DBGBUS_IVTE_3 },
89: { A6XX_CX_DBGC_CFG_DBGBUS_MASKE_0 },
90: { A6XX_CX_DBGC_CFG_DBGBUS_MASKE_1 },
91: { A6XX_CX_DBGC_CFG_DBGBUS_MASKE_2 },
92: { A6XX_CX_DBGC_CFG_DBGBUS_MASKE_3 },
93: { A6XX_CX_DBGC_CFG_DBGBUS_NIBBLEE },
94: { A6XX_CX_DBGC_CFG_DBGBUS_PTRC0 },
95: { A6XX_CX_DBGC_CFG_DBGBUS_PTRC1 },
96: { A6XX_CX_DBGC_CFG_DBGBUS_LOADREG },
97: { A6XX_CX_DBGC_CFG_DBGBUS_IDX },
98: { A6XX_CX_DBGC_CFG_DBGBUS_CLRC },
99: { A6XX_CX_DBGC_CFG_DBGBUS_LOADIVT },
100: { A6XX_CX_DBGC_VBIF_DBG_CNTL },
101: { A6XX_CX_DBGC_DBG_LO_HI_GPIO },
102: { A6XX_CX_DBGC_EXT_TRACE_BUS_CNTL },
103: { A6XX_CX_DBGC_READ_AHB_THROUGH_DBG },
104: { A6XX_CX_DBGC_CFG_DBGBUS_TRACE_BUF1 },
105: { A6XX_CX_DBGC_CFG_DBGBUS_TRACE_BUF2 },
106: { A6XX_CX_DBGC_EVT_CFG },
107: { A6XX_CX_DBGC_EVT_INTF_SEL_0 },
108: { A6XX_CX_DBGC_EVT_INTF_SEL_1 },
109: { A6XX_CX_DBGC_PERF_ATB_CFG },
110: { A6XX_CX_DBGC_PERF_ATB_COUNTER_SEL_0 },
111: { A6XX_CX_DBGC_PERF_ATB_COUNTER_SEL_1 },
112: { A6XX_CX_DBGC_PERF_ATB_COUNTER_SEL_2 },
113: { A6XX_CX_DBGC_PERF_ATB_COUNTER_SEL_3 },
114: { A6XX_CX_DBGC_PERF_ATB_TRIG_INTF_SEL_0 },
115: { A6XX_CX_DBGC_PERF_ATB_TRIG_INTF_SEL_1 },
116: { A6XX_CX_DBGC_PERF_ATB_DRAIN_CMD },
117: { A6XX_CX_DBGC_ECO_CNTL },
118: { A6XX_CX_DBGC_AHB_DBG_CNTL },
119: };
120:
121: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_sel_a, &a6xx_coresight_regs[0]);
122: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_sel_b, &a6xx_coresight_regs[1]);
123: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_sel_c, &a6xx_coresight_regs[2]);
124: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_sel_d, &a6xx_coresight_regs[3]);
125: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_cntlt, &a6xx_coresight_regs[4]);
126: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_cntlm, &a6xx_coresight_regs[5]);
127: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_opl, &a6xx_coresight_regs[6]);
128: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_ope, &a6xx_coresight_regs[7]);
129: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_ivtl_0, &a6xx_coresight_regs[8]);
130: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_ivtl_1, &a6xx_coresight_regs[9]);
131: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_ivtl_2, &a6xx_coresight_regs[10]);
132: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_ivtl_3, &a6xx_coresight_regs[11]);
133: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_maskl_0, &a6xx_coresight_regs[12]);
134: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_maskl_1, &a6xx_coresight_regs[13]);
135: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_maskl_2, &a6xx_coresight_regs[14]);
136: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_maskl_3, &a6xx_coresight_regs[15]);
137: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_bytel_0, &a6xx_coresight_regs[16]);
138: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_bytel_1, &a6xx_coresight_regs[17]);
139: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_ivte_0, &a6xx_coresight_regs[18]);
140: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_ivte_1, &a6xx_coresight_regs[19]);
141: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_ivte_2, &a6xx_coresight_regs[20]);
142: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_ivte_3, &a6xx_coresight_regs[21]);
143: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_maske_0, &a6xx_coresight_regs[22]);
144: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_maske_1, &a6xx_coresight_regs[23]);
145: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_maske_2, &a6xx_coresight_regs[24]);
146: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_maske_3, &a6xx_coresight_regs[25]);
147: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_nibblee, &a6xx_coresight_regs[26]);
148: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_ptrc0, &a6xx_coresight_regs[27]);
149: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_ptrc1, &a6xx_coresight_regs[28]);
150: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_loadreg, &a6xx_coresight_regs[29]);
151: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_idx, &a6xx_coresight_regs[30]);
152: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_clrc, &a6xx_coresight_regs[31]);
153: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_loadivt, &a6xx_coresight_regs[32]);
154: static ADRENO_CORESIGHT_ATTR(vbif_dbg_cntl, &a6xx_coresight_regs[33]);
155: static ADRENO_CORESIGHT_ATTR(dbg_lo_hi_gpio, &a6xx_coresight_regs[34]);
156: static ADRENO_CORESIGHT_ATTR(ext_trace_bus_cntl, &a6xx_coresight_regs[35]);
157: static ADRENO_CORESIGHT_ATTR(read_ahb_through_dbg, &a6xx_coresight_regs[36]);
158: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_trace_buf1, &a6xx_coresight_regs[37]);
159: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_trace_buf2, &a6xx_coresight_regs[38]);
160: static ADRENO_CORESIGHT_ATTR(evt_cfg, &a6xx_coresight_regs[39]);
161: static ADRENO_CORESIGHT_ATTR(evt_intf_sel_0, &a6xx_coresight_regs[40]);
162: static ADRENO_CORESIGHT_ATTR(evt_intf_sel_1, &a6xx_coresight_regs[41]);
163: static ADRENO_CORESIGHT_ATTR(perf_atb_cfg, &a6xx_coresight_regs[42]);
164: static ADRENO_CORESIGHT_ATTR(perf_atb_counter_sel_0, &a6xx_coresight_regs[43]);
165: static ADRENO_CORESIGHT_ATTR(perf_atb_counter_sel_1, &a6xx_coresight_regs[44]);
166: static ADRENO_CORESIGHT_ATTR(perf_atb_counter_sel_2, &a6xx_coresight_regs[45]);
167: static ADRENO_CORESIGHT_ATTR(perf_atb_counter_sel_3, &a6xx_coresight_regs[46]);
168: static ADRENO_CORESIGHT_ATTR(perf_atb_trig_intf_sel_0,
169: &a6xx_coresight_regs[47]);
170: static ADRENO_CORESIGHT_ATTR(perf_atb_trig_intf_sel_1,
171: &a6xx_coresight_regs[48]);
172: static ADRENO_CORESIGHT_ATTR(perf_atb_drain_cmd, &a6xx_coresight_regs[49]);
173: static ADRENO_CORESIGHT_ATTR(eco_cntl, &a6xx_coresight_regs[50]);
174: static ADRENO_CORESIGHT_ATTR(ahb_dbg_cntl, &a6xx_coresight_regs[51]);
175:
176: /*CX debug registers*/
177: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_sel_a,
178: &a6xx_coresight_regs_cx[0]);
179: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_sel_b,
180: &a6xx_coresight_regs_cx[1]);
181: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_sel_c,
182: &a6xx_coresight_regs_cx[2]);
183: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_sel_d,
184: &a6xx_coresight_regs_cx[3]);
185: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_cntlt,
186: &a6xx_coresight_regs_cx[4]);
187: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_cntlm,
188: &a6xx_coresight_regs_cx[5]);
189: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_opl,
190: &a6xx_coresight_regs_cx[6]);
191: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_ope,
192: &a6xx_coresight_regs_cx[7]);
193: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_ivtl_0,
194: &a6xx_coresight_regs_cx[8]);
195: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_ivtl_1,
196: &a6xx_coresight_regs_cx[9]);
197: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_ivtl_2,
198: &a6xx_coresight_regs_cx[10]);
199: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_ivtl_3,
200: &a6xx_coresight_regs_cx[11]);
201: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_maskl_0,
202: &a6xx_coresight_regs_cx[12]);
203: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_maskl_1,
204: &a6xx_coresight_regs_cx[13]);
205: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_maskl_2,
206: &a6xx_coresight_regs_cx[14]);
207: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_maskl_3,
208: &a6xx_coresight_regs_cx[15]);
209: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_bytel_0,
210: &a6xx_coresight_regs_cx[16]);
211: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_bytel_1,
212: &a6xx_coresight_regs_cx[17]);
213: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_ivte_0,
214: &a6xx_coresight_regs_cx[18]);
215: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_ivte_1,
216: &a6xx_coresight_regs_cx[19]);
217: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_ivte_2,
218: &a6xx_coresight_regs_cx[20]);
219: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_ivte_3,
220: &a6xx_coresight_regs_cx[21]);
221: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_maske_0,
222: &a6xx_coresight_regs_cx[22]);
223: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_maske_1,
224: &a6xx_coresight_regs_cx[23]);
225: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_maske_2,
226: &a6xx_coresight_regs_cx[24]);
227: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_maske_3,
228: &a6xx_coresight_regs_cx[25]);
229: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_nibblee,
230: &a6xx_coresight_regs_cx[26]);
231: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_ptrc0,
232: &a6xx_coresight_regs_cx[27]);
233: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_ptrc1,
234: &a6xx_coresight_regs_cx[28]);
235: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_loadreg,
236: &a6xx_coresight_regs_cx[29]);
237: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_idx,
238: &a6xx_coresight_regs_cx[30]);
239: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_clrc,
240: &a6xx_coresight_regs_cx[31]);
241: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_loadivt,
242: &a6xx_coresight_regs_cx[32]);
243: static ADRENO_CORESIGHT_ATTR(cx_vbif_dbg_cntl,
244: &a6xx_coresight_regs_cx[33]);
245: static ADRENO_CORESIGHT_ATTR(cx_dbg_lo_hi_gpio,
246: &a6xx_coresight_regs_cx[34]);
247: static ADRENO_CORESIGHT_ATTR(cx_ext_trace_bus_cntl,
248: &a6xx_coresight_regs_cx[35]);
249: static ADRENO_CORESIGHT_ATTR(cx_read_ahb_through_dbg,
250: &a6xx_coresight_regs_cx[36]);
251: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_trace_buf1,
252: &a6xx_coresight_regs_cx[37]);
253: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_trace_buf2,
254: &a6xx_coresight_regs_cx[38]);
255: static ADRENO_CORESIGHT_ATTR(cx_evt_cfg,
256: &a6xx_coresight_regs_cx[39]);
257: static ADRENO_CORESIGHT_ATTR(cx_evt_intf_sel_0,
258: &a6xx_coresight_regs_cx[40]);
259: static ADRENO_CORESIGHT_ATTR(cx_evt_intf_sel_1,
260: &a6xx_coresight_regs_cx[41]);
261: static ADRENO_CORESIGHT_ATTR(cx_perf_atb_cfg,
262: &a6xx_coresight_regs_cx[42]);
263: static ADRENO_CORESIGHT_ATTR(cx_perf_atb_counter_sel_0,
264: &a6xx_coresight_regs_cx[43]);
265: static ADRENO_CORESIGHT_ATTR(cx_perf_atb_counter_sel_1,
266: &a6xx_coresight_regs_cx[44]);
267: static ADRENO_CORESIGHT_ATTR(cx_perf_atb_counter_sel_2,
268: &a6xx_coresight_regs_cx[45]);
269: static ADRENO_CORESIGHT_ATTR(cx_perf_atb_counter_sel_3,
270: &a6xx_coresight_regs_cx[46]);
271: static ADRENO_CORESIGHT_ATTR(cx_perf_atb_trig_intf_sel_0,
272: &a6xx_coresight_regs_cx[47]);
273: static ADRENO_CORESIGHT_ATTR(cx_perf_atb_trig_intf_sel_1,
274: &a6xx_coresight_regs_cx[48]);
275: static ADRENO_CORESIGHT_ATTR(cx_perf_atb_drain_cmd,
276: &a6xx_coresight_regs_cx[49]);
277: static ADRENO_CORESIGHT_ATTR(cx_eco_cntl,
278: &a6xx_coresight_regs_cx[50]);
279: static ADRENO_CORESIGHT_ATTR(cx_ahb_dbg_cntl,
280: &a6xx_coresight_regs_cx[51]);
281:
282: static struct attribute *a6xx_coresight_attrs[] = {
283: &coresight_attr_cfg_dbgbus_sel_a.attr.attr,
284: &coresight_attr_cfg_dbgbus_sel_b.attr.attr,
285: &coresight_attr_cfg_dbgbus_sel_c.attr.attr,
286: &coresight_attr_cfg_dbgbus_sel_d.attr.attr,
287: &coresight_attr_cfg_dbgbus_cntlt.attr.attr,
288: &coresight_attr_cfg_dbgbus_cntlm.attr.attr,
289: &coresight_attr_cfg_dbgbus_opl.attr.attr,
290: &coresight_attr_cfg_dbgbus_ope.attr.attr,
291: &coresight_attr_cfg_dbgbus_ivtl_0.attr.attr,
292: &coresight_attr_cfg_dbgbus_ivtl_1.attr.attr,
293: &coresight_attr_cfg_dbgbus_ivtl_2.attr.attr,
294: &coresight_attr_cfg_dbgbus_ivtl_3.attr.attr,
295: &coresight_attr_cfg_dbgbus_maskl_0.attr.attr,
296: &coresight_attr_cfg_dbgbus_maskl_1.attr.attr,
297: &coresight_attr_cfg_dbgbus_maskl_2.attr.attr,
298: &coresight_attr_cfg_dbgbus_maskl_3.attr.attr,
299: &coresight_attr_cfg_dbgbus_bytel_0.attr.attr,
300: &coresight_attr_cfg_dbgbus_bytel_1.attr.attr,
301: &coresight_attr_cfg_dbgbus_ivte_0.attr.attr,
302: &coresight_attr_cfg_dbgbus_ivte_1.attr.attr,
303: &coresight_attr_cfg_dbgbus_ivte_2.attr.attr,
304: &coresight_attr_cfg_dbgbus_ivte_3.attr.attr,
305: &coresight_attr_cfg_dbgbus_maske_0.attr.attr,
306: &coresight_attr_cfg_dbgbus_maske_1.attr.attr,
MATCH LINES: 339
327: &coresight_attr_perf_atb_counter_sel_1.attr.attr,
328: &coresight_attr_perf_atb_counter_sel_2.attr.attr,
329: &coresight_attr_perf_atb_counter_sel_3.attr.attr,
330: &coresight_attr_perf_atb_trig_intf_sel_0.attr.attr,
331: &coresight_attr_perf_atb_trig_intf_sel_1.attr.attr,
332: &coresight_attr_perf_atb_drain_cmd.attr.attr,
333: &coresight_attr_eco_cntl.attr.attr,
334: &coresight_attr_ahb_dbg_cntl.attr.attr,
335: NULL,
336: };
337:
338: /*cx*/
339: static struct attribute *a6xx_coresight_attrs_cx[] = {
340: &coresight_attr_cx_cfg_dbgbus_sel_a.attr.attr,
341: &coresight_attr_cx_cfg_dbgbus_sel_b.attr.attr,
342: &coresight_attr_cx_cfg_dbgbus_sel_c.attr.attr,
343: &coresight_attr_cx_cfg_dbgbus_sel_d.attr.attr,
344: &coresight_attr_cx_cfg_dbgbus_cntlt.attr.attr,
345: &coresight_attr_cx_cfg_dbgbus_cntlm.attr.attr,
346: &coresight_attr_cx_cfg_dbgbus_opl.attr.attr,
347: &coresight_attr_cx_cfg_dbgbus_ope.attr.attr,
348: &coresight_attr_cx_cfg_dbgbus_ivtl_0.attr.attr,
349: &coresight_attr_cx_cfg_dbgbus_ivtl_1.attr.attr,
350: &coresight_attr_cx_cfg_dbgbus_ivtl_2.attr.attr,
351: &coresight_attr_cx_cfg_dbgbus_ivtl_3.attr.attr,
352: &coresight_attr_cx_cfg_dbgbus_maskl_0.attr.attr,
353: &coresight_attr_cx_cfg_dbgbus_maskl_1.attr.attr,
354: &coresight_attr_cx_cfg_dbgbus_maskl_2.attr.attr,
355: &coresight_attr_cx_cfg_dbgbus_maskl_3.attr.attr,
356: &coresight_attr_cx_cfg_dbgbus_bytel_0.attr.attr,
357: &coresight_attr_cx_cfg_dbgbus_bytel_1.attr.attr,
358: &coresight_attr_cx_cfg_dbgbus_ivte_0.attr.attr,
359: &coresight_attr_cx_cfg_dbgbus_ivte_1.attr.attr,
360: &coresight_attr_cx_cfg_dbgbus_ivte_2.attr.attr,
361: &coresight_attr_cx_cfg_dbgbus_ivte_3.attr.attr,
362: &coresight_attr_cx_cfg_dbgbus_maske_0.attr.attr,
363: &coresight_attr_cx_cfg_dbgbus_maske_1.attr.attr,
MATCH LINES: 395, 396, 399, 400, 404, 405, 408, 409, 413, 414, 415, 416, 419, 420, 421, 422, 425, 428, 431
383: &coresight_attr_cx_perf_atb_counter_sel_0.attr.attr,
384: &coresight_attr_cx_perf_atb_counter_sel_1.attr.attr,
385: &coresight_attr_cx_perf_atb_counter_sel_2.attr.attr,
386: &coresight_attr_cx_perf_atb_counter_sel_3.attr.attr,
387: &coresight_attr_cx_perf_atb_trig_intf_sel_0.attr.attr,
388: &coresight_attr_cx_perf_atb_trig_intf_sel_1.attr.attr,
389: &coresight_attr_cx_perf_atb_drain_cmd.attr.attr,
390: &coresight_attr_cx_eco_cntl.attr.attr,
391: &coresight_attr_cx_ahb_dbg_cntl.attr.attr,
392: NULL,
393: };
394:
395: static const struct attribute_group a6xx_coresight_group = {
396: .attrs = a6xx_coresight_attrs,
397: };
398:
399: static const struct attribute_group *a6xx_coresight_groups[] = {
400: &a6xx_coresight_group,
401: NULL,
402: };
403:
404: static const struct attribute_group a6xx_coresight_group_cx = {
405: .attrs = a6xx_coresight_attrs_cx,
406: };
407:
408: static const struct attribute_group *a6xx_coresight_groups_cx[] = {
409: &a6xx_coresight_group_cx,
410: NULL,
411: };
412:
413: static const struct adreno_coresight a6xx_coresight = {
414: .registers = a6xx_coresight_regs,
415: .count = ARRAY_SIZE(a6xx_coresight_regs),
416: .groups = a6xx_coresight_groups,
417: };
418:
419: static const struct adreno_coresight a6xx_coresight_cx = {
420: .registers = a6xx_coresight_regs_cx,
421: .count = ARRAY_SIZE(a6xx_coresight_regs_cx),
422: .groups = a6xx_coresight_groups_cx,
423: };
424:
425: void a6xx_coresight_init(struct adreno_device *adreno_dev)
426: {
427: adreno_coresight_add_device(adreno_dev, "coresight-gfx",
428: &a6xx_coresight, &adreno_dev->gx_coresight);
429:
430: adreno_coresight_add_device(adreno_dev, "coresight-gfx-cx",
431: &a6xx_coresight_cx, &adreno_dev->cx_coresight);
432: }
--- FILE: \adreno_a6xx_gmu.c | HITS: 559 ---
MATCH LINES: 37, 63
25: #include "kgsl_device.h"
26: #include "kgsl_gmu_core.h"
27: #include "kgsl_trace.h"
28: #include "kgsl_util.h"
29:
30: #define ARC_VOTE_GET_PRI(_v) ((_v) & 0xFF)
31: #define ARC_VOTE_GET_SEC(_v) (((_v) >> 8) & 0xFF)
32: #define ARC_VOTE_GET_VLVL(_v) (((_v) >> 16) & 0xFFFF)
33:
34: #define ARC_VOTE_SET(pri, sec, vlvl) \
35: ((((vlvl) & 0xFFFF) << 16) | (((sec) & 0xFF) << 8) | ((pri) & 0xFF))
36:
37: static struct gmu_vma_entry a6xx_gmu_vma_legacy[] = {
38: [GMU_ITCM] = {
39: .start = 0x00000,
40: .size = SZ_16K
41: },
42: [GMU_ICACHE] = {
43: .start = 0x04000,
44: .size = (SZ_256K - SZ_16K),
45: .next_va = 0x4000
46: },
47: [GMU_DTCM] = {
48: .start = 0x40000,
49: .size = SZ_16K
50: },
51: [GMU_DCACHE] = {
52: .start = 0x44000,
53: .size = (SZ_256K - SZ_16K),
54: .next_va = 0x44000
55: },
56: [GMU_NONCACHED_KERNEL] = {
57: .start = 0x60000000,
58: .size = SZ_512M,
59: .next_va = 0x60000000
60: },
61: };
62:
63: static struct gmu_vma_entry a6xx_gmu_vma[] = {
64: [GMU_ITCM] = {
65: .start = 0x00000000,
66: .size = SZ_16K
67: },
68: [GMU_CACHE] = {
69: .start = SZ_16K,
70: .size = (SZ_16M - SZ_16K),
71: .next_va = SZ_16K
72: },
73: [GMU_DTCM] = {
74: .start = SZ_256M + SZ_16K,
75: .size = SZ_16K
76: },
77: [GMU_DCACHE] = {
78: .start = 0x0,
79: .size = 0x0
80: },
81: [GMU_NONCACHED_KERNEL] = {
82: .start = 0x60000000,
83: .size = SZ_512M,
84: .next_va = 0x60000000
85: },
86: };
87:
MATCH LINES: 111, 125, 133, 147, 173, 187, 195, 209, 217, 231, 263, 275, 277, 278, 280, 283, 285, 286, 288, 295, 298, 307, 310, 311, 312, 313, 314, 315, 317, 319, 320, 321, 322, 332, 333, 334, 335, 336, 338, 339, 340, 341, 342, 346, 348, 354
99: u32 val;
100:
101: reg = regbase + (offsetwords << 2);
102: val = __raw_readl(reg);
103: /* Make sure the read posted and all pending writes are done */
104: mb();
105: __raw_writel((val & ~mask) | or, reg);
106: }
107:
108: static ssize_t log_stream_enable_store(struct kobject *kobj,
109: struct kobj_attribute *attr, const char *buf, size_t count)
110: {
111: struct a6xx_gmu_device *gmu = container_of(kobj, struct a6xx_gmu_device, log_kobj);
112: bool val;
113: int ret;
114:
115: ret = kstrtobool(buf, &val);
116: if (ret)
117: return ret;
118:
119: gmu->log_stream_enable = val;
120: return count;
121: }
122:
123: static ssize_t log_stream_enable_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
124: {
125: struct a6xx_gmu_device *gmu = container_of(kobj, struct a6xx_gmu_device, log_kobj);
126:
127: return scnprintf(buf, PAGE_SIZE, "%d\n", gmu->log_stream_enable);
128: }
129:
130: static ssize_t log_group_mask_store(struct kobject *kobj,
131: struct kobj_attribute *attr, const char *buf, size_t count)
132: {
133: struct a6xx_gmu_device *gmu = container_of(kobj, struct a6xx_gmu_device, log_kobj);
134: u32 val;
135: int ret;
136:
137: ret = kstrtou32(buf, 0, &val);
138: if (ret)
139: return ret;
140:
141: gmu->log_group_mask = val;
142: return count;
143: }
144:
145: static ssize_t log_group_mask_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
146: {
147: struct a6xx_gmu_device *gmu = container_of(kobj, struct a6xx_gmu_device, log_kobj);
148:
149: return scnprintf(buf, PAGE_SIZE, "%x\n", gmu->log_group_mask);
150: }
151:
152: static struct kobj_attribute log_stream_enable_attr =
153: __ATTR(log_stream_enable, 0644, log_stream_enable_show, log_stream_enable_store);
154:
155: static struct kobj_attribute log_group_mask_attr =
156: __ATTR(log_group_mask, 0644, log_group_mask_show, log_group_mask_store);
157:
158: static struct attribute *log_attrs[] = {
159: &log_stream_enable_attr.attr,
160: &log_group_mask_attr.attr,
161: NULL,
162: };
163: ATTRIBUTE_GROUPS(log);
164:
165: static struct kobj_type log_kobj_type = {
166: .sysfs_ops = &kobj_sysfs_ops,
167: .default_groups = log_groups,
168: };
169:
170: static ssize_t stats_enable_store(struct kobject *kobj,
171: struct kobj_attribute *attr, const char *buf, size_t count)
172: {
173: struct a6xx_gmu_device *gmu = container_of(kobj, struct a6xx_gmu_device, stats_kobj);
174: bool val;
175: int ret;
176:
177: ret = kstrtobool(buf, &val);
178: if (ret)
179: return ret;
180:
181: gmu->stats_enable = val;
182: return count;
183: }
184:
185: static ssize_t stats_enable_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
186: {
187: struct a6xx_gmu_device *gmu = container_of(kobj, struct a6xx_gmu_device, stats_kobj);
188:
189: return scnprintf(buf, PAGE_SIZE, "%d\n", gmu->stats_enable);
190: }
191:
192: static ssize_t stats_mask_store(struct kobject *kobj,
193: struct kobj_attribute *attr, const char *buf, size_t count)
194: {
195: struct a6xx_gmu_device *gmu = container_of(kobj, struct a6xx_gmu_device, stats_kobj);
196: u32 val;
197: int ret;
198:
199: ret = kstrtou32(buf, 0, &val);
200: if (ret)
201: return ret;
202:
203: gmu->stats_mask = val;
204: return count;
205: }
206:
207: static ssize_t stats_mask_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
208: {
209: struct a6xx_gmu_device *gmu = container_of(kobj, struct a6xx_gmu_device, stats_kobj);
210:
211: return scnprintf(buf, PAGE_SIZE, "%x\n", gmu->stats_mask);
212: }
213:
214: static ssize_t stats_interval_store(struct kobject *kobj,
215: struct kobj_attribute *attr, const char *buf, size_t count)
216: {
217: struct a6xx_gmu_device *gmu = container_of(kobj, struct a6xx_gmu_device, stats_kobj);
218: u32 val;
219: int ret;
220:
221: ret = kstrtou32(buf, 0, &val);
222: if (ret)
223: return ret;
224:
225: gmu->stats_interval = val;
226: return count;
227: }
228:
229: static ssize_t stats_interval_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
230: {
231: struct a6xx_gmu_device *gmu = container_of(kobj, struct a6xx_gmu_device, stats_kobj);
232:
233: return scnprintf(buf, PAGE_SIZE, "%x\n", gmu->stats_interval);
234: }
235:
236: static struct kobj_attribute stats_enable_attr =
237: __ATTR(stats_enable, 0644, stats_enable_show, stats_enable_store);
238:
239: static struct kobj_attribute stats_mask_attr =
240: __ATTR(stats_mask, 0644, stats_mask_show, stats_mask_store);
241:
242: static struct kobj_attribute stats_interval_attr =
243: __ATTR(stats_interval, 0644, stats_interval_show, stats_interval_store);
244:
245: static struct attribute *stats_attrs[] = {
246: &stats_enable_attr.attr,
247: &stats_mask_attr.attr,
248: &stats_interval_attr.attr,
249: NULL,
250: };
251: ATTRIBUTE_GROUPS(stats);
252:
253: static struct kobj_type stats_kobj_type = {
254: .sysfs_ops = &kobj_sysfs_ops,
255: .default_groups = stats_groups,
256: };
257:
258: static int timed_poll_check_rscc(struct kgsl_device *device,
259: unsigned int offset, unsigned int expected_ret,
260: unsigned int timeout, unsigned int mask)
261: {
262: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
263: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
264: u32 value;
265:
266: if (!adreno_is_a650_family(adreno_dev))
267: return gmu_core_timed_poll_check(device,
268: offset + RSCC_OFFSET_LEGACY,
269: expected_ret, timeout, mask);
270:
271: return readl_poll_timeout(gmu->rscc_virt + (offset << 2), value,
272: (value & mask) == expected_ret, 100, timeout * 1000);
273: }
274:
275: struct a6xx_gmu_device *to_a6xx_gmu(struct adreno_device *adreno_dev)
276: {
277: struct a6xx_device *a6xx_dev = container_of(adreno_dev,
278: struct a6xx_device, adreno_dev);
279:
280: return &a6xx_dev->gmu;
281: }
282:
283: struct adreno_device *a6xx_gmu_to_adreno(struct a6xx_gmu_device *gmu)
284: {
285: struct a6xx_device *a6xx_dev =
286: container_of(gmu, struct a6xx_device, gmu);
287:
288: return &a6xx_dev->adreno_dev;
289: }
290:
291: #define RSC_CMD_OFFSET 2
292: #define PDC_CMD_OFFSET 4
293: #define PDC_ENABLE_REG_VALUE 0x80000001
294:
295: void a6xx_load_rsc_ucode(struct adreno_device *adreno_dev)
296: {
297: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
298: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
299: void __iomem *rscc;
300:
301: if (adreno_is_a650_family(adreno_dev))
302: rscc = gmu->rscc_virt;
303: else
304: rscc = kgsl_regmap_virt(&device->regmap, RSCC_OFFSET_LEGACY);
305:
306: /* Disable SDE clock gating */
307: _regwrite(rscc, A6XX_GPU_RSCC_RSC_STATUS0_DRV0, BIT(24));
308:
309: /* Setup RSC PDC handshake for sleep and wakeup */
310: _regwrite(rscc, A6XX_RSCC_PDC_SLAVE_ID_DRV0, 1);
311: _regwrite(rscc, A6XX_RSCC_HIDDEN_TCS_CMD0_DATA, 0);
312: _regwrite(rscc, A6XX_RSCC_HIDDEN_TCS_CMD0_ADDR, 0);
313: _regwrite(rscc, A6XX_RSCC_HIDDEN_TCS_CMD0_DATA + RSC_CMD_OFFSET, 0);
314: _regwrite(rscc, A6XX_RSCC_HIDDEN_TCS_CMD0_ADDR + RSC_CMD_OFFSET, 0);
315: _regwrite(rscc, A6XX_RSCC_HIDDEN_TCS_CMD0_DATA + RSC_CMD_OFFSET * 2,
316: adreno_is_a622(adreno_dev) ? 0x80000028 : 0x80000000);
317: _regwrite(rscc, A6XX_RSCC_HIDDEN_TCS_CMD0_ADDR + RSC_CMD_OFFSET * 2,
318: 0);
319: _regwrite(rscc, A6XX_RSCC_OVERRIDE_START_ADDR, 0);
320: _regwrite(rscc, A6XX_RSCC_PDC_SEQ_START_ADDR, 0x4520);
321: _regwrite(rscc, A6XX_RSCC_PDC_MATCH_VALUE_LO, 0x4510);
322: _regwrite(rscc, A6XX_RSCC_PDC_MATCH_VALUE_HI, 0x4514);
323:
324: /* Load RSC sequencer uCode for sleep and wakeup */
325: if (adreno_is_a622(adreno_dev)) {
326: _regwrite(rscc, A622_RSCC_SEQ_MEM_0_DRV0, 0xEAAAE5A0);
327: _regwrite(rscc, A622_RSCC_SEQ_MEM_0_DRV0 + 1, 0xE1A1EBAB);
328: _regwrite(rscc, A622_RSCC_SEQ_MEM_0_DRV0 + 2, 0xA2E0A581);
329: _regwrite(rscc, A622_RSCC_SEQ_MEM_0_DRV0 + 3, 0xECAC82E2);
330: _regwrite(rscc, A622_RSCC_SEQ_MEM_0_DRV0 + 4, 0x0020EDAD);
331: } else if (adreno_is_a650_family(adreno_dev)) {
332: _regwrite(rscc, A6XX_RSCC_SEQ_MEM_0_DRV0, 0xEAAAE5A0);
333: _regwrite(rscc, A6XX_RSCC_SEQ_MEM_0_DRV0 + 1, 0xE1A1EBAB);
334: _regwrite(rscc, A6XX_RSCC_SEQ_MEM_0_DRV0 + 2, 0xA2E0A581);
335: _regwrite(rscc, A6XX_RSCC_SEQ_MEM_0_DRV0 + 3, 0xECAC82E2);
336: _regwrite(rscc, A6XX_RSCC_SEQ_MEM_0_DRV0 + 4, 0x0020EDAD);
337: } else {
338: _regwrite(rscc, A6XX_RSCC_SEQ_MEM_0_DRV0, 0xA7A506A0);
339: _regwrite(rscc, A6XX_RSCC_SEQ_MEM_0_DRV0 + 1, 0xA1E6A6E7);
340: _regwrite(rscc, A6XX_RSCC_SEQ_MEM_0_DRV0 + 2, 0xA2E081E1);
341: _regwrite(rscc, A6XX_RSCC_SEQ_MEM_0_DRV0 + 3, 0xE9A982E2);
342: _regwrite(rscc, A6XX_RSCC_SEQ_MEM_0_DRV0 + 4, 0x0020E8A8);
343: }
344: }
345:
346: int a6xx_load_pdc_ucode(struct adreno_device *adreno_dev)
347: {
348: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
349: struct platform_device *gmu_pdev = GMU_PDEV(KGSL_DEVICE(adreno_dev));
350: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
351: struct resource *res_pdc, *res_cfg, *res_seq;
352: unsigned int cfg_offset, seq_offset;
353: void __iomem *cfg = NULL, *seq = NULL;
354: const struct adreno_a6xx_core *a6xx_core = to_a6xx_core(adreno_dev);
355: u32 vrm_resource_addr = cmd_db_read_addr("vrm.soc");
356: u32 xo_resource_addr = cmd_db_read_addr("xo.lvl");
357: u32 cx_res_addr = cmd_db_read_addr("cx.lvl");
358: u32 mx_res_addr = cmd_db_read_addr("mx.lvl");
359:
360: if (!xo_resource_addr) {
361: dev_err(gmu_pdev_dev,
362: "Failed to get 'xo.lvl' addr from cmd_db\n");
363: return -ENOENT;
364: }
365:
366: if (!cx_res_addr) {
367: dev_err(gmu_pdev_dev,
368: "Failed to get 'cx.lvl' addr from cmd_db\n");
369: return -ENOENT;
370: }
371:
372: if (!mx_res_addr) {
373: dev_err(gmu_pdev_dev,
374: "Failed to get 'mx.lvl' addr from cmd_db\n");
375: return -ENOENT;
376: }
377: /*
378: * Older A6x platforms specified PDC registers in the DT using a
MATCH LINES: 434, 438
422: gmu->pdc_cfg_base = devm_ioremap(gmu_pdev_dev,
423: res_pdc->start + cfg_offset, 0x10000);
424:
425: if (!gmu->pdc_cfg_base) {
426: dev_err(gmu_pdev_dev, "Failed to map PDC CFG\n");
427: return -ENODEV;
428: }
429: }
430:
431: cfg = gmu->pdc_cfg_base;
432:
433: /* PDC GPU SEQ start addr register is removed for A622 */
434: if (adreno_is_a622(adreno_dev) && a6xx_core->pdc_in_aop)
435: return 0;
436:
437: /* PDC is programmed in AOP for newer platforms */
438: if (a6xx_core->pdc_in_aop)
439: goto done;
440:
441: /*
442: * Map the starting address for pdc_seq programming. If the pdc_seq
443: * resource is not available use an offset from the base PDC resource.
444: */
445: if (gmu->pdc_seq_base == NULL) {
446: /*
447: * Try to get the "gmu_pdc_seq" resource, fallback to legacy
448: * "kgsl_gmu_pdc_seq" if not found.
449: */
450: res_seq = platform_get_resource_byname(gmu_pdev, IORESOURCE_MEM,
451: "gmu_pdc_seq");
452: if (!res_seq)
453: res_seq = platform_get_resource_byname(gmu_pdev,
454: IORESOURCE_MEM, "kgsl_gmu_pdc_seq");
455:
456: if (res_seq)
457: gmu->pdc_seq_base = devm_ioremap(gmu_pdev_dev,
458: res_seq->start, resource_size(res_seq));
459: else if (res_pdc)
460: gmu->pdc_seq_base = devm_ioremap(gmu_pdev_dev,
461: res_pdc->start + seq_offset, 0x10000);
462:
MATCH LINES: 566, 570, 573, 578, 579, 580, 583, 586, 588, 591, 593, 598, 610, 618, 635, 651, 657, 669, 672, 676, 679, 691, 694, 706, 708, 715, 721, 730, 736, 748, 751, 760, 764, 767, 772, 782, 785, 795, 802, 820, 822, 851, 855
554: * for main hysteresis. This is the first hysteresis. Here we set it
555: * to 0x1680 cycles, or 300 us. The highest 16 bits of this value are
556: * the number of XO clock cycles for short hysteresis. This happens
557: * after main hysteresis. Here we set it to 0xA cycles, or 0.5 us.
558: */
559: #define A6X_GMU_LONG_IFPC_HYST FIELD_PREP(GENMASK(15, 0), 0x1680)
560: #define A6X_GMU_SHORT_IFPC_HYST FIELD_PREP(GENMASK(31, 16), 0xA)
561:
562: /* Minimum IFPC timer (200usec) allowed to override default value */
563: #define A6X_GMU_LONG_IFPC_HYST_FLOOR FIELD_PREP(GENMASK(15, 0), 0x0F00)
564:
565: /*
566: * a6xx_gmu_power_config() - Configure and enable GMU's low power mode
567: * setting based on ADRENO feature flags.
568: * @adreno_dev: Pointer to adreno device
569: */
570: static void a6xx_gmu_power_config(struct adreno_device *adreno_dev)
571: {
572: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
573: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
574:
575: /* Configure registers for idle setting. The setting is cumulative */
576:
577: /* Disable GMU WB/RB buffer and caches at boot */
578: gmu_core_regwrite(device, A6XX_GMU_SYS_BUS_CONFIG, 0x1);
579: gmu_core_regwrite(device, A6XX_GMU_ICACHE_CONFIG, 0x1);
580: gmu_core_regwrite(device, A6XX_GMU_DCACHE_CONFIG, 0x1);
581:
582: gmu_core_regwrite(device,
583: A6XX_GMU_PWR_COL_INTER_FRAME_CTRL, 0x9C40400);
584:
585: if (gmu->idle_level == GPU_HW_IFPC) {
586: gmu_core_regwrite(device, A6XX_GMU_PWR_COL_INTER_FRAME_HYST,
587: A6X_GMU_SHORT_IFPC_HYST | adreno_dev->ifpc_hyst);
588: gmu_core_regrmw(device, A6XX_GMU_PWR_COL_INTER_FRAME_CTRL,
589: IFPC_ENABLE_MASK, IFPC_ENABLE_MASK);
590:
591: gmu_core_regwrite(device, A6XX_GMU_PWR_COL_SPTPRAC_HYST,
592: A6X_GMU_SHORT_IFPC_HYST | adreno_dev->ifpc_hyst);
593: gmu_core_regrmw(device, A6XX_GMU_PWR_COL_INTER_FRAME_CTRL,
594: SPTP_ENABLE_MASK, SPTP_ENABLE_MASK);
595: }
596:
597: /* Enable RPMh GPU client */
598: gmu_core_regrmw(device, A6XX_GMU_RPMH_CTRL, RPMH_ENABLE_MASK,
599: RPMH_ENABLE_MASK);
600: }
601:
602: static void gmu_ao_sync_event(struct adreno_device *adreno_dev)
603: {
604: unsigned long flags;
605: u64 ticks;
606:
607: local_irq_save(flags);
608:
609: /* Read GMU always on register */
610: ticks = a6xx_read_alwayson(adreno_dev);
611:
612: /* Trace the GMU time to create a mapping to ftrace time */
613: trace_gmu_ao_sync(ticks);
614:
615: local_irq_restore(flags);
616: }
617:
618: void a6xx_gmu_disable_gdsc(struct adreno_device *adreno_dev)
619: {
620: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
621: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
622:
623: /* ADRENO_QUIRK_CX_GDSC quirk is not supported for genpd */
624: WARN_ON_ONCE(pwr->gmu_cx_pd && ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_CX_GDSC));
625:
626: if (pwr->cx_regulator && ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_CX_GDSC))
627: regulator_set_mode(pwr->cx_regulator, REGULATOR_MODE_IDLE);
628:
629: kgsl_pwrctrl_disable_cx_gdsc(device);
630:
631: if (pwr->cx_regulator && ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_CX_GDSC))
632: regulator_set_mode(pwr->cx_regulator, REGULATOR_MODE_NORMAL);
633: }
634:
635: int a6xx_gmu_device_start(struct adreno_device *adreno_dev)
636: {
637: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
638: u32 val = 0x00000100;
639: u32 mask = 0x000001FF;
640:
641: gmu_core_reset_trace_header(&device->gmu_core.trace);
642: gmu_ao_sync_event(adreno_dev);
643:
644: /* Check for 0xBABEFACE on legacy targets */
645: if (device->gmu_core.ver.core <= 0x20010004) {
646: val = 0xBABEFACE;
647: mask = 0xFFFFFFFF;
648: }
649:
650: /* Bring GMU out of reset */
651: gmu_core_regwrite(device, A6XX_GMU_CM3_SYSRESET, 0);
652:
653: /* Make sure the write is posted before moving ahead */
654: wmb();
655:
656: if (gmu_core_timed_poll_check(device,
657: A6XX_GMU_CM3_FW_INIT_RESULT,
658: val, GMU_START_TIMEOUT, mask)) {
659:
660: dev_err(GMU_PDEV_DEV(device), "GMU doesn't boot\n");
661: gmu_core_fault_snapshot(device, GMU_FAULT_DEVICE_START);
662: return -ETIMEDOUT;
663: }
664:
665: return 0;
666: }
667:
668: /*
669: * a6xx_gmu_hfi_start() - Write registers and start HFI.
670: * @device: Pointer to KGSL device
671: */
672: int a6xx_gmu_hfi_start(struct adreno_device *adreno_dev)
673: {
674: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
675:
676: gmu_core_regwrite(device, A6XX_GMU_HFI_CTRL_INIT, 1);
677:
678: if (gmu_core_timed_poll_check(device,
679: A6XX_GMU_HFI_CTRL_STATUS,
680: BIT(0),
681: GMU_START_TIMEOUT,
682: BIT(0))) {
683: dev_err(GMU_PDEV_DEV(device), "GMU HFI init failed\n");
684: gmu_core_fault_snapshot(device, GMU_FAULT_HFI_INIT);
685: return -ETIMEDOUT;
686: }
687:
688: return 0;
689: }
690:
691: int a6xx_rscc_wakeup_sequence(struct adreno_device *adreno_dev)
692: {
693: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
694: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
695: int val;
696:
697: /* Skip wakeup sequence if we didn't do the sleep sequence */
698: if (!test_bit(GMU_PRIV_RSCC_SLEEP_DONE, &gmu->flags))
699: return 0;
700: /* A660 has a replacement register */
701: if (adreno_is_a662(adreno_dev) || adreno_is_a621(adreno_dev) ||
702: adreno_is_a622(adreno_dev) || adreno_is_a663(adreno_dev) ||
703: adreno_is_a623(adreno_dev))
704: gmu_core_regread(device, A662_GPU_CC_GX_DOMAIN_MISC3, &val);
705: else if (adreno_is_a660(ADRENO_DEVICE(device)))
706: gmu_core_regread(device, A6XX_GPU_CC_GX_DOMAIN_MISC3, &val);
707: else
708: gmu_core_regread(device, A6XX_GPU_CC_GX_DOMAIN_MISC, &val);
709:
710: if (!(val & 0x1))
711: dev_info_ratelimited(GMU_PDEV_DEV(device),
712: "GMEM CLAMP IO not set while GFX rail off\n");
713:
714: /* RSC wake sequence */
715: gmu_core_regwrite(device, A6XX_GMU_RSCC_CONTROL_REQ, BIT(1));
716:
717: /* Write request before polling */
718: wmb();
719:
720: if (gmu_core_timed_poll_check(device,
721: A6XX_GMU_RSCC_CONTROL_ACK,
722: BIT(1),
723: GPU_START_TIMEOUT,
724: BIT(1))) {
725: dev_err(GMU_PDEV_DEV(device), "Failed to do GPU RSC power on\n");
726: return -ETIMEDOUT;
727: }
728:
729: if (timed_poll_check_rscc(device,
730: A6XX_RSCC_SEQ_BUSY_DRV0,
731: 0,
732: GPU_START_TIMEOUT,
733: 0xFFFFFFFF))
734: goto error_rsc;
735:
736: gmu_core_regwrite(device, A6XX_GMU_RSCC_CONTROL_REQ, 0);
737:
738: clear_bit(GMU_PRIV_RSCC_SLEEP_DONE, &gmu->flags);
739:
740: return 0;
741:
742: error_rsc:
743: dev_err(GMU_PDEV_DEV(device),
744: "GPU RSC sequence stuck in waking up GPU\n");
745: return -ETIMEDOUT;
746: }
747:
748: int a6xx_rscc_sleep_sequence(struct adreno_device *adreno_dev)
749: {
750: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
751: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
752: int ret;
753:
754: if (!test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags))
755: return 0;
756:
757: if (test_bit(GMU_PRIV_RSCC_SLEEP_DONE, &gmu->flags))
758: return 0;
759:
760: gmu_core_regwrite(device, A6XX_GMU_CM3_SYSRESET, 1);
761: /* Make sure M3 is in reset before going on */
762: wmb();
763:
764: gmu_core_regread(device, A6XX_GPU_GMU_CX_GMU_PWR_COL_CP_RESP,
765: &gmu->log_wptr_retention);
766:
767: gmu_core_regwrite(device, A6XX_GMU_RSCC_CONTROL_REQ, 1);
768: /* Make sure the request completes before continuing */
769: wmb();
770:
771: ret = timed_poll_check_rscc(device,
772: A6XX_GPU_RSCC_RSC_STATUS0_DRV0,
773: BIT(16),
774: GPU_START_TIMEOUT,
775: BIT(16));
776:
777: if (ret) {
778: dev_err(GMU_PDEV_DEV(device), "GPU RSC power off fail\n");
779: return -ETIMEDOUT;
780: }
781:
782: gmu_core_regwrite(device, A6XX_GMU_RSCC_CONTROL_REQ, 0);
783:
784: if (adreno_dev->lm_enabled)
785: gmu_core_regwrite(device, A6XX_GMU_AO_SPARE_CNTL, 0);
786:
787: set_bit(GMU_PRIV_RSCC_SLEEP_DONE, &gmu->flags);
788:
789: return 0;
790: }
791:
792: #define MAX_GMUFW_SIZE 0x8000 /* in bytes */
793:
794: static int _load_legacy_gmu_fw(struct kgsl_device *device,
795: struct a6xx_gmu_device *gmu)
796: {
797: const struct firmware *fw = gmu->fw_image;
798:
799: if (fw->size > MAX_GMUFW_SIZE)
800: return -EINVAL;
801:
802: gmu_core_blkwrite(device, A6XX_GMU_CM3_ITCM_START, fw->data,
803: fw->size);
804:
805: /* Proceed only after the FW is written */
806: wmb();
807: return 0;
808: }
809:
810: static void load_tcm(struct adreno_device *adreno_dev, const u8 *src,
811: u32 tcm_start, u32 base, const struct gmu_block_header *blk)
812: {
813: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
814: u32 tcm_offset = tcm_start + ((blk->addr - base)/sizeof(u32));
815: void __iomem *addr = kgsl_regmap_virt(&device->regmap, tcm_offset);
816:
817: memcpy_toio(addr, src, blk->size);
818: }
819:
820: int a6xx_gmu_load_fw(struct adreno_device *adreno_dev)
821: {
822: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
823: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
824: const u8 *fw = (const u8 *)gmu->fw_image->data;
825:
826: if (adreno_is_a630(adreno_dev) || adreno_is_a615_family(adreno_dev))
827: return _load_legacy_gmu_fw(KGSL_DEVICE(adreno_dev), gmu);
828:
829: while (fw < gmu->fw_image->data + gmu->fw_image->size) {
830: const struct gmu_block_header *blk =
831: (const struct gmu_block_header *)fw;
832: int id;
833:
834: fw += sizeof(*blk);
835:
836: /* Don't deal with zero size blocks */
837: if (blk->size == 0)
838: continue;
839:
840: id = gmu_core_find_vma_block(device, blk->addr, blk->size);
841:
842: if (id < 0) {
843: dev_err(GMU_PDEV_DEV(device),
844: "Unknown block in GMU FW addr:0x%x size:0x%x\n",
845: blk->addr, blk->size);
846: return -EINVAL;
847: }
848:
849: if (id == GMU_ITCM) {
850: load_tcm(adreno_dev, fw,
851: A6XX_GMU_CM3_ITCM_START,
852: device->gmu_core.vma[GMU_ITCM].start, blk);
853: } else if (id == GMU_DTCM) {
854: load_tcm(adreno_dev, fw,
855: A6XX_GMU_CM3_DTCM_START,
856: device->gmu_core.vma[GMU_DTCM].start, blk);
857: } else {
858: struct kgsl_memdesc *md =
859: gmu_core_find_memdesc(device, blk->addr, blk->size);
860:
861: if (!md) {
862: dev_err(GMU_PDEV_DEV(device),
863: "No backing memory for GMU FW block addr:0x%x size:0x%x\n",
864: blk->addr, blk->size);
865: return -EINVAL;
866: }
867:
868: memcpy(md->hostptr + (blk->addr - md->gmuaddr), fw,
869: blk->size);
870: }
871:
872: fw += blk->size;
873: }
874:
875: /* Proceed only after the FW is written */
876: wmb();
877: return 0;
878: }
879:
MATCH LINES: 906, 910, 935, 937, 947, 953, 957, 974, 978, 981, 982, 985, 986, 988, 990, 999, 1002, 1003, 1010, 1011, 1013, 1014, 1018, 1034, 1047, 1054, 1059, 1061, 1064, 1066, 1068, 1070, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1101, 1107, 1116, 1129, 1132, 1144, 1148, 1162, 1165, 1180, 1181, 1183, 1187, 1200, 1205, 1214, 1218, 1222, 1227, 1232, 1242, 1244, 1251, 1255, 1259, 1264, 1266, 1268, 1273, 1299, 1303, 1308, 1313, 1315, 1323, 1326, 1327, 1332, 1335, 1336, 1337, 1338, 1359, 1364, 1371, 1372, 1373, 1375, 1388, 1394, 1395, 1398, 1402, 1413, 1419, 1421, 1423, 1425, 1427, 1431, 1434, 1449, 1454, 1491, 1494, 1497, 1499, 1500, 1508, 1510, 1511, 1515, 1518, 1519, 1521, 1523, 1531, 1533, 1541, 1549, 1553, 1556, 1578, 1583, 1587, 1589, 1592, 1595, 1607, 1609, 1637, 1640, 1670, 1672, 1673, 1681, 1684, 1711, 1721, 1723, 1743, 1747, 1752, 1756, 1760, 1763, 1765, 1770, 1780, 1783, 1786, 1787, 1792, 1796, 1797, 1798, 1800, 1801, 1804, 1806, 1816, 1817, 1830, 1845, 1852, 1854, 1859, 1862, 1866, 1873, 1877, 1887, 1892, 1894, 1895, 1897, 1898, 1902, 1913, 1921, 1926, 1933, 1937, 1946, 1951, 1985, 1987, 2009, 2011, 2014, 2018, 2037, 2039, 2045, 2051, 2058, 2081, 2088, 2094, 2097, 2099, 2111, 2115, 2116, 2122, 2126, 2133, 2135, 2141, 2149, 2151, 2162, 2169, 2175, 2177, 2180, 2186, 2190, 2191, 2194, 2195, 2199, 2206, 2220, 2225, 2227, 2229, 2231, 2236, 2238, 2268, 2271, 2284, 2294, 2298, 2303, 2313, 2317, 2321, 2323, 2325, 2334, 2345, 2349, 2354, 2356, 2362, 2367, 2371, 2384, 2387, 2395, 2402, 2405, 2418, 2422, 2426, 2428, 2433, 2438, 2440, 2446, 2451, 2455, 2466, 2469, 2477, 2486, 2489, 2492, 2495, 2508, 2509, 2510, 2511, 2512, 2513, 2514, 2515, 2516, 2517, 2518, 2521, 2531, 2547, 2548, 2583, 2584, 2620, 2634, 2652, 2655, 2679, 2680, 2682, 2686, 2687, 2688, 2724, 2725, 2742, 2743, 2745, 2746, 2750, 2755, 2768, 2777, 2786, 2801, 2809, 2813, 2819, 2821, 2824, 2826, 2833, 2842, 2846, 2850, 2854, 2858, 2864, 2866, 2869, 2871, 2875, 2884, 2885, 2886, 2891, 2900, 2904, 2909, 2927, 2928, 2929, 2930, 2935, 2946, 2950, 2960, 2970, 2972, 2974, 2992, 3000, 3006, 3019, 3021, 3032, 3034, 3038, 3055, 3058, 3063, 3070, 3074, 3078, 3082, 3088, 3092, 3094
894: enum oob_request req)
895: {
896: /*
897: * Trigger recovery for perfcounter oob only since only
898: * perfcounter oob can happen alongside an actively rendering gpu.
899: */
900: if (req != oob_perfcntr)
901: return;
902:
903: adreno_scheduler_fault(adreno_dev, ADRENO_GMU_FAULT_SKIP_SNAPSHOT);
904: }
905:
906: int a6xx_gmu_oob_set(struct kgsl_device *device,
907: enum oob_request req)
908: {
909: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
910: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
911: int ret = 0;
912: int set, check;
913:
914: if (req == oob_perfcntr && gmu->num_oob_perfcntr++)
915: return 0;
916:
917: if (adreno_is_a630(adreno_dev) || adreno_is_a615_family(adreno_dev)) {
918: set = BIT(req + 16);
919: check = BIT(req + 24);
920: } else {
921: /*
922: * The legacy targets have special bits that aren't supported on
923: * newer implementations
924: */
925: if (req >= oob_boot_slumber) {
926: dev_err(GMU_PDEV_DEV(device), "Unsupported OOB request %s\n",
927: oob_to_str(req));
928: return -EINVAL;
929: }
930:
931: set = BIT(30 - req * 2);
932: check = BIT(31 - req);
933: }
934:
935: gmu_core_regwrite(device, A6XX_GMU_HOST2GMU_INTR_SET, set);
936:
937: if (gmu_core_timed_poll_check(device, A6XX_GMU_GMU2HOST_INTR_INFO,
938: check, GPU_START_TIMEOUT, check)) {
939: if (req == oob_perfcntr)
940: gmu->num_oob_perfcntr--;
941: ret = -ETIMEDOUT;
942: WARN(1, "OOB request %s timed out\n", oob_to_str(req));
943: gmu_core_fault_snapshot(device, GMU_FAULT_OOB_SET);
944: trigger_reset_recovery(adreno_dev, req);
945: }
946:
947: gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_CLR, check);
948:
949: trace_kgsl_gmu_oob_set(set);
950: return ret;
951: }
952:
953: void a6xx_gmu_oob_clear(struct kgsl_device *device,
954: enum oob_request req)
955: {
956: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
957: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
958: int clear;
959:
960: if (req == oob_perfcntr && --gmu->num_oob_perfcntr)
961: return;
962:
963: if (adreno_is_a630(adreno_dev) || adreno_is_a615_family(adreno_dev)) {
964: clear = BIT(req + 24);
965: } else {
966: clear = BIT(31 - req * 2);
967: if (req >= oob_boot_slumber) {
968: dev_err(GMU_PDEV_DEV(device), "Unsupported OOB clear %s\n",
969: oob_to_str(req));
970: return;
971: }
972: }
973:
974: gmu_core_regwrite(device, A6XX_GMU_HOST2GMU_INTR_SET, clear);
975: trace_kgsl_gmu_oob_clear(clear);
976: }
977:
978: void a6xx_gmu_irq_enable(struct adreno_device *adreno_dev)
979: {
980: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
981: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
982: struct a6xx_hfi *hfi = &gmu->hfi;
983:
984: /* Clear pending IRQs and Unmask needed IRQs */
985: gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_CLR, 0xffffffff);
986: gmu_core_regwrite(device, A6XX_GMU_AO_HOST_INTERRUPT_CLR, 0xffffffff);
987:
988: gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_MASK,
989: (unsigned int)~HFI_IRQ_MASK);
990: gmu_core_regwrite(device, A6XX_GMU_AO_HOST_INTERRUPT_MASK,
991: (unsigned int)~GMU_AO_INT_MASK);
992:
993:
994: /* Enable all IRQs on host */
995: enable_irq(hfi->irq);
996: enable_irq(gmu->irq);
997: }
998:
999: void a6xx_gmu_irq_disable(struct adreno_device *adreno_dev)
1000: {
1001: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1002: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
1003: struct a6xx_hfi *hfi = &gmu->hfi;
1004:
1005: /* Disable all IRQs on host */
1006: disable_irq(gmu->irq);
1007: disable_irq(hfi->irq);
1008:
1009: /* Mask all IRQs and clear pending IRQs */
1010: gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_MASK, 0xffffffff);
1011: gmu_core_regwrite(device, A6XX_GMU_AO_HOST_INTERRUPT_MASK, 0xffffffff);
1012:
1013: gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_CLR, 0xffffffff);
1014: gmu_core_regwrite(device, A6XX_GMU_AO_HOST_INTERRUPT_CLR, 0xffffffff);
1015:
1016: }
1017:
1018: static int a6xx_gmu_hfi_start_msg(struct adreno_device *adreno_dev)
1019: {
1020: struct hfi_start_cmd req;
1021:
1022: /*
1023: * This HFI was not supported in legacy firmware and this quirk
1024: * serves as a better means to identify targets that depend on
1025: * legacy firmware.
1026: */
1027: if (!ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_HFI_USE_REG)) {
1028: int ret;
1029:
1030: ret = CMD_MSG_HDR(req, H2F_MSG_START);
1031: if (ret)
1032: return ret;
1033:
1034: return a6xx_hfi_send_generic_req(adreno_dev, &req, sizeof(req));
1035: }
1036:
1037: return 0;
1038:
1039: }
1040:
1041: #define FREQ_VOTE(idx, ack) (((idx) & 0xFF) | (((ack) & 0xF) << 28))
1042: #define BW_VOTE(idx) ((((idx) & 0xFFF) << 12) | ((idx) & 0xFFF))
1043:
1044: #define CLKSET_OPTION_ATLEAST 3
1045:
1046: /*
1047: * a6xx_gmu_dcvs_nohfi() - request GMU to do DCVS without using HFI
1048: * @device: Pointer to KGSL device
1049: * @perf_idx: Index into GPU performance level table defined in
1050: * HFI DCVS table message
1051: * @bw_idx: Index into GPU b/w table defined in HFI b/w table message
1052: *
1053: */
1054: static int a6xx_gmu_dcvs_nohfi(struct kgsl_device *device,
1055: unsigned int perf_idx, unsigned int bw_idx)
1056: {
1057: int ret;
1058:
1059: gmu_core_regwrite(device, A6XX_GMU_DCVS_ACK_OPTION, DCVS_ACK_NONBLOCK);
1060:
1061: gmu_core_regwrite(device, A6XX_GMU_DCVS_PERF_SETTING,
1062: FREQ_VOTE(perf_idx, CLKSET_OPTION_ATLEAST));
1063:
1064: gmu_core_regwrite(device, A6XX_GMU_DCVS_BW_SETTING, BW_VOTE(bw_idx));
1065:
1066: ret = a6xx_gmu_oob_set(device, oob_dcvs);
1067: if (ret == 0)
1068: gmu_core_regread(device, A6XX_GMU_DCVS_RETURN, &ret);
1069:
1070: a6xx_gmu_oob_clear(device, oob_dcvs);
1071:
1072: return ret;
1073: }
1074:
1075: static u32 a6xx_rscc_tcsm_drv0_status_reglist[] = {
1076: A6XX_RSCC_TCS0_DRV0_STATUS,
1077: A6XX_RSCC_TCS1_DRV0_STATUS,
1078: A6XX_RSCC_TCS2_DRV0_STATUS,
1079: A6XX_RSCC_TCS3_DRV0_STATUS,
1080: A6XX_RSCC_TCS4_DRV0_STATUS,
1081: A6XX_RSCC_TCS5_DRV0_STATUS,
1082: A6XX_RSCC_TCS6_DRV0_STATUS,
1083: A6XX_RSCC_TCS7_DRV0_STATUS,
1084: A6XX_RSCC_TCS8_DRV0_STATUS,
1085: A6XX_RSCC_TCS9_DRV0_STATUS,
1086: };
1087:
1088: static u32 a622_rscc_tcsm_drv0_status_reglist[] = {
1089: A622_RSCC_TCS0_DRV0_STATUS,
1090: A622_RSCC_TCS1_DRV0_STATUS,
1091: A622_RSCC_TCS2_DRV0_STATUS,
1092: A622_RSCC_TCS3_DRV0_STATUS,
1093: A622_RSCC_TCS4_DRV0_STATUS,
1094: A622_RSCC_TCS5_DRV0_STATUS,
1095: A622_RSCC_TCS6_DRV0_STATUS,
1096: A622_RSCC_TCS7_DRV0_STATUS,
1097: A622_RSCC_TCS8_DRV0_STATUS,
1098: A622_RSCC_TCS9_DRV0_STATUS,
1099: };
1100:
1101: static int a6xx_complete_rpmh_votes(struct adreno_device *adreno_dev,
1102: unsigned int timeout)
1103: {
1104: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1105: /* Number of TCS commands are increased to 10 from A650 family onwards */
1106: int count = adreno_is_a650_family(adreno_dev) ?
1107: ARRAY_SIZE(a6xx_rscc_tcsm_drv0_status_reglist) : 4;
1108: int i, ret = 0;
1109:
1110: if (adreno_is_a622(adreno_dev)) {
1111: for (i = 0; i < count; i++)
1112: ret |= timed_poll_check_rscc(device, a622_rscc_tcsm_drv0_status_reglist[i],
1113: BIT(0), timeout, BIT(0));
1114: } else {
1115: for (i = 0; i < count; i++)
1116: ret |= timed_poll_check_rscc(device, a6xx_rscc_tcsm_drv0_status_reglist[i],
1117: BIT(0), timeout, BIT(0));
1118: }
1119:
1120: if (ret)
1121: dev_err(device->dev, "RPMH votes timedout: %d\n", ret);
1122:
1123: return ret;
1124: }
1125:
1126: #define SPTPRAC_CTRL_TIMEOUT 10 /* ms */
1127:
1128: /*
1129: * a6xx_gmu_sptprac_enable() - Power on SPTPRAC
1130: * @adreno_dev: Pointer to Adreno device
1131: */
1132: int a6xx_gmu_sptprac_enable(struct adreno_device *adreno_dev)
1133: {
1134: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1135:
1136: /* Only certain targets have sptprac */
1137: if (!adreno_is_a630(adreno_dev) && !adreno_is_a615_family(adreno_dev))
1138: return 0;
1139:
1140: if (test_bit(ADRENO_DEVICE_GPU_REGULATOR_ENABLED, &adreno_dev->priv))
1141: return 0;
1142:
1143: /* GMU enabled a630 and a615 targets */
1144: gmu_core_regwrite(device, A6XX_GMU_GX_SPTPRAC_POWER_CONTROL,
1145: SPTPRAC_POWERON_CTRL_MASK);
1146:
1147: if (gmu_core_timed_poll_check(device,
1148: A6XX_GMU_SPTPRAC_PWR_CLK_STATUS,
1149: SPTPRAC_POWERON_STATUS_MASK,
1150: SPTPRAC_CTRL_TIMEOUT,
1151: SPTPRAC_POWERON_STATUS_MASK)) {
1152: dev_err(GMU_PDEV_DEV(device), "power on SPTPRAC fail\n");
1153: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
1154: return -ETIMEDOUT;
1155: }
1156:
1157: set_bit(ADRENO_DEVICE_GPU_REGULATOR_ENABLED, &adreno_dev->priv);
1158: return 0;
1159: }
1160:
1161: /*
1162: * a6xx_gmu_sptprac_disable() - Power of SPTPRAC
1163: * @adreno_dev: Pointer to Adreno device
1164: */
1165: void a6xx_gmu_sptprac_disable(struct adreno_device *adreno_dev)
1166: {
1167: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1168:
1169: /* Only certain targets have sptprac */
1170: if (!adreno_is_a630(adreno_dev) && !adreno_is_a615_family(adreno_dev))
1171: return;
1172:
1173: if (!test_and_clear_bit(ADRENO_DEVICE_GPU_REGULATOR_ENABLED,
1174: &adreno_dev->priv))
1175: return;
1176:
1177: /* GMU enabled a630 and a615 targets */
1178:
1179: /* Ensure that retention is on */
1180: gmu_core_regrmw(device, A6XX_GPU_CC_GX_GDSCR, 0,
1181: A6XX_RETAIN_FF_ENABLE_ENABLE_MASK);
1182:
1183: gmu_core_regwrite(device, A6XX_GMU_GX_SPTPRAC_POWER_CONTROL,
1184: SPTPRAC_POWEROFF_CTRL_MASK);
1185:
1186: if (gmu_core_timed_poll_check(device,
1187: A6XX_GMU_SPTPRAC_PWR_CLK_STATUS,
1188: SPTPRAC_POWEROFF_STATUS_MASK,
1189: SPTPRAC_CTRL_TIMEOUT,
1190: SPTPRAC_POWEROFF_STATUS_MASK))
1191: dev_err(GMU_PDEV_DEV(device), "power off SPTPRAC fail\n");
1192: }
1193:
1194: #define SPTPRAC_POWER_OFF BIT(2)
1195: #define SP_CLK_OFF BIT(4)
1196: #define GX_GDSC_POWER_OFF BIT(6)
1197: #define GX_CLK_OFF BIT(7)
1198: #define is_on(val) (!(val & (GX_GDSC_POWER_OFF | GX_CLK_OFF)))
1199:
1200: bool a6xx_gmu_gx_is_on(struct adreno_device *adreno_dev)
1201: {
1202: unsigned int val;
1203:
1204: gmu_core_regread(KGSL_DEVICE(adreno_dev),
1205: A6XX_GMU_SPTPRAC_PWR_CLK_STATUS, &val);
1206: return is_on(val);
1207: }
1208:
1209: bool a619_holi_gx_is_on(struct adreno_device *adreno_dev)
1210: {
1211: unsigned int val;
1212:
1213: gmu_core_regread(KGSL_DEVICE(adreno_dev),
1214: A6XX_GMU_SPTPRAC_PWR_CLK_STATUS, &val);
1215: return is_on(val);
1216: }
1217:
1218: static bool a6xx_gmu_rpmh_pwr_state_is_active(struct kgsl_device *device)
1219: {
1220: u32 val;
1221:
1222: gmu_core_regread(device, A6XX_GPU_GMU_CX_GMU_RPMH_POWER_STATE, &val);
1223: return (val == GPU_HW_ACTIVE) ? true : false;
1224: }
1225:
1226: /*
1227: * a6xx_gmu_sptprac_is_on() - Check if SPTP is on using pwr status register
1228: * @adreno_dev - Pointer to adreno_device
1229: * This check should only be performed if the keepalive bit is set or it
1230: * can be guaranteed that the power state of the GPU will remain unchanged
1231: */
1232: bool a6xx_gmu_sptprac_is_on(struct adreno_device *adreno_dev)
1233: {
1234: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1235: unsigned int val;
1236:
1237: if (!adreno_is_a630(adreno_dev) && !adreno_is_a615_family(adreno_dev))
1238: return true;
1239:
1240: if (adreno_is_a619_holi(adreno_dev))
1241: kgsl_regread(device,
1242: A6XX_GMU_SPTPRAC_PWR_CLK_STATUS, &val);
1243: else
1244: gmu_core_regread(device, A6XX_GMU_SPTPRAC_PWR_CLK_STATUS,
1245: &val);
1246:
1247: return !(val & (SPTPRAC_POWER_OFF | SP_CLK_OFF));
1248: }
1249:
1250: /*
1251: * a6xx_gmu_gfx_rail_on() - request GMU to power GPU at given OPP.
1252: * @device: Pointer to KGSL device
1253: *
1254: */
1255: static int a6xx_gmu_gfx_rail_on(struct adreno_device *adreno_dev)
1256: {
1257: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1258: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1259: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
1260: u32 perf_idx = gmu->hfi.dcvs_table.gpu_level_num -
1261: pwr->default_pwrlevel - 1;
1262: u32 default_opp = gmu->hfi.dcvs_table.gx_votes[perf_idx].vote;
1263:
1264: gmu_core_regwrite(device, A6XX_GMU_BOOT_SLUMBER_OPTION,
1265: OOB_BOOT_OPTION);
1266: gmu_core_regwrite(device, A6XX_GMU_GX_VOTE_IDX,
1267: ARC_VOTE_GET_PRI(default_opp));
1268: gmu_core_regwrite(device, A6XX_GMU_MX_VOTE_IDX,
1269: ARC_VOTE_GET_SEC(default_opp));
1270:
1271: gmu_core_rdpm_mx_freq_update(device, gmu->hfi.dcvs_table.gx_votes[perf_idx].freq);
1272:
1273: return a6xx_gmu_oob_set(device, oob_boot_slumber);
1274: }
1275:
1276: static bool idle_trandition_complete(unsigned int idle_level,
1277: unsigned int gmu_power_reg,
1278: unsigned int sptprac_clk_reg)
1279: {
1280: if (idle_level != gmu_power_reg)
1281: return false;
1282:
1283: if (idle_level == GPU_HW_IFPC && is_on(sptprac_clk_reg))
1284: return false;
1285:
1286: return true;
1287: }
1288:
1289: static const char *idle_level_name(int level)
1290: {
1291: if (level == GPU_HW_ACTIVE)
1292: return "GPU_HW_ACTIVE";
1293: else if (level == GPU_HW_IFPC)
1294: return "GPU_HW_IFPC";
1295:
1296: return "";
1297: }
1298:
1299: int a6xx_gmu_wait_for_lowest_idle(struct adreno_device *adreno_dev)
1300: {
1301: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1302: struct device *gmu_pdev_dev = GMU_PDEV_DEV(device);
1303: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
1304: unsigned int reg, reg1, reg2, reg3, reg4, reg5, reg6, reg7, reg8;
1305: unsigned long t;
1306: uint64_t ts1, ts2, ts3;
1307:
1308: ts1 = a6xx_read_alwayson(adreno_dev);
1309:
1310: t = jiffies + msecs_to_jiffies(GMU_IDLE_TIMEOUT);
1311: do {
1312: gmu_core_regread(device,
1313: A6XX_GPU_GMU_CX_GMU_RPMH_POWER_STATE, ®);
1314: gmu_core_regread(device,
1315: A6XX_GMU_SPTPRAC_PWR_CLK_STATUS, ®1);
1316:
1317: if (idle_trandition_complete(gmu->idle_level, reg, reg1))
1318: return 0;
1319: /* Wait 100us to reduce unnecessary AHB bus traffic */
1320: usleep_range(10, 100);
1321: } while (!time_after(jiffies, t));
1322:
1323: ts2 = a6xx_read_alwayson(adreno_dev);
1324: /* Check one last time */
1325:
1326: gmu_core_regread(device, A6XX_GPU_GMU_CX_GMU_RPMH_POWER_STATE, ®);
1327: gmu_core_regread(device, A6XX_GMU_SPTPRAC_PWR_CLK_STATUS, ®1);
1328:
1329: if (idle_trandition_complete(gmu->idle_level, reg, reg1))
1330: return 0;
1331:
1332: ts3 = a6xx_read_alwayson(adreno_dev);
1333:
1334: /* Collect abort data to help with debugging */
1335: gmu_core_regread(device, A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS, ®2);
1336: gmu_core_regread(device, A6XX_GMU_RBBM_INT_UNMASKED_STATUS, ®3);
1337: gmu_core_regread(device, A6XX_GMU_GMU_PWR_COL_KEEPALIVE, ®4);
1338: gmu_core_regread(device, A6XX_GMU_AO_SPARE_CNTL, ®5);
1339:
1340: dev_err(gmu_pdev_dev,
1341: "----------------------[ GMU error ]----------------------\n");
1342: dev_err(gmu_pdev_dev,
1343: "Timeout waiting for lowest idle level %s\n",
1344: idle_level_name(gmu->idle_level));
1345: dev_err(gmu_pdev_dev,
1346: "Start: %llx (absolute ticks)\n", ts1);
1347: dev_err(gmu_pdev_dev,
1348: "Poll: %llx (ticks relative to start)\n",
1349: ts2-ts1);
1350: dev_err(gmu_pdev_dev,
1351: "Retry: %llx (ticks relative to poll)\n",
1352: ts3-ts2);
1353: dev_err(gmu_pdev_dev,
1354: "RPMH_POWER_STATE=%x SPTPRAC_PWR_CLK_STATUS=%x\n", reg, reg1);
1355: dev_err(gmu_pdev_dev, "CX_BUSY_STATUS=%x\n", reg2);
1356: dev_err(gmu_pdev_dev,
1357: "RBBM_INT_UNMASKED_STATUS=%x PWR_COL_KEEPALIVE=%x\n",
1358: reg3, reg4);
1359: dev_err(gmu_pdev_dev, "A6XX_GMU_AO_SPARE_CNTL=%x\n", reg5);
1360:
1361: if (adreno_is_a660(adreno_dev)) {
1362: u32 val;
1363:
1364: gmu_core_regread(device, A6XX_GMU_PWR_COL_PREEMPT_KEEPALIVE, &val);
1365: dev_err(gmu_pdev_dev,
1366: "PWR_COL_PREEMPT_KEEPALIVE=%x\n", val);
1367: }
1368:
1369: /* Access GX registers only when GX is ON */
1370: if (is_on(reg1)) {
1371: kgsl_regread(device, A6XX_CP_STATUS_1, ®6);
1372: kgsl_regread(device, A6XX_CP_CP2GMU_STATUS, ®7);
1373: kgsl_regread(device, A6XX_CP_CONTEXT_SWITCH_CNTL, ®8);
1374:
1375: dev_err(gmu_pdev_dev, "A6XX_CP_STATUS_1=%x\n", reg6);
1376: dev_err(gmu_pdev_dev,
1377: "CP2GMU_STATUS=%x CONTEXT_SWITCH_CNTL=%x\n",
1378: reg7, reg8);
1379: }
1380:
1381: WARN_ON(1);
1382: gmu_core_fault_snapshot(device, GMU_FAULT_WAIT_FOR_LOWEST_IDLE);
1383: return -ETIMEDOUT;
1384: }
1385:
1386: /* Bitmask for GPU idle status check */
1387: #define CXGXCPUBUSYIGNAHB BIT(30)
1388: int a6xx_gmu_wait_for_idle(struct adreno_device *adreno_dev)
1389: {
1390: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1391: unsigned int status2;
1392: uint64_t ts1;
1393:
1394: ts1 = a6xx_read_alwayson(adreno_dev);
1395: if (gmu_core_timed_poll_check(device, A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS,
1396: 0, GMU_START_TIMEOUT, CXGXCPUBUSYIGNAHB)) {
1397: gmu_core_regread(device,
1398: A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS2, &status2);
1399: dev_err(GMU_PDEV_DEV(device),
1400: "GMU not idling: status2=0x%x %llx %llx\n",
1401: status2, ts1,
1402: a6xx_read_alwayson(ADRENO_DEVICE(device)));
1403: gmu_core_fault_snapshot(device, GMU_FAULT_WAIT_FOR_IDLE);
1404: return -ETIMEDOUT;
1405: }
1406:
1407: return 0;
1408: }
1409:
1410: /* A6xx GMU FENCE RANGE MASK */
1411: #define GMU_FENCE_RANGE_MASK ((0x1 << 31) | ((0xA << 2) << 18) | (0x8A0))
1412:
1413: void a6xx_gmu_version_info(struct adreno_device *adreno_dev)
1414: {
1415: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1416: struct gmu_core_device *gmu = &device->gmu_core;
1417:
1418: /* GMU version info is at a fixed offset in the DTCM */
1419: gmu_core_regread(device, A6XX_GMU_CM3_DTCM_START + 0xFF8,
1420: &gmu->ver.core);
1421: gmu_core_regread(device, A6XX_GMU_CM3_DTCM_START + 0xFF9,
1422: &gmu->ver.core_dev);
1423: gmu_core_regread(device, A6XX_GMU_CM3_DTCM_START + 0xFFA,
1424: &gmu->ver.pwr);
1425: gmu_core_regread(device, A6XX_GMU_CM3_DTCM_START + 0xFFB,
1426: &gmu->ver.pwr_dev);
1427: gmu_core_regread(device, A6XX_GMU_CM3_DTCM_START + 0xFFC,
1428: &gmu->ver.hfi);
1429: }
1430:
1431: int a6xx_gmu_itcm_shadow(struct adreno_device *adreno_dev)
1432: {
1433: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1434: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
1435: u32 i, *dest;
1436:
1437: if (gmu->itcm_shadow)
1438: return 0;
1439:
1440: gmu->itcm_shadow = vzalloc(device->gmu_core.vma[GMU_ITCM].size);
1441: if (!gmu->itcm_shadow)
1442: return -ENOMEM;
1443:
1444: dest = (u32 *)gmu->itcm_shadow;
1445:
1446: /* FIXME: use bulk read? */
1447: for (i = 0; i < (device->gmu_core.vma[GMU_ITCM].size >> 2); i++)
1448: gmu_core_regread(KGSL_DEVICE(adreno_dev),
1449: A6XX_GMU_CM3_ITCM_START + i, dest++);
1450:
1451: return 0;
1452: }
1453:
1454: static void a6xx_gmu_enable_throttle_counters(
1455: struct adreno_device *adreno_dev)
1456: {
1457: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1458: u32 val;
1459:
1460: if (!(adreno_dev->lm_enabled || adreno_dev->bcl_enabled))
1461: return;
1462:
1463: if (adreno_dev->lm_enabled) {
1464: /*
1465: * For LM throttling -
1466: * XOCLK1: countable: 0x10
1467: * XOCLK2: countable: 0x16 for newer hardware / 0x15 for others
1468: * XOCLK3: countable: 0xf for newer hardware / 0x19 for others
1469: *
1470: * POWER_CONTROL_SELECT_0 controls counters 0 - 3, each selector
1471: * is 8 bits wide.
1472: */
1473:
1474: if (adreno_is_a620(adreno_dev) || adreno_is_a650(adreno_dev))
1475: val = (0x10 << 8) | (0x16 << 16) | (0x0f << 24);
1476: else
1477: val = (0x10 << 8) | (0x15 << 16) | (0x19 << 24);
1478: } else {
1479: /*
1480: * When LM is not enabled, we can enable BCL throttling -
1481: * XOCLK1: countable: 0x13 (25% throttle)
1482: * XOCLK2: countable: 0x17 (58% throttle)
1483: * XOCLK3: countable: 0x19 (75% throttle)
1484: *
1485: * POWER_CONTROL_SELECT_0 controls counters 0 - 3, each selector
1486: * is 8 bits wide.
1487: */
1488: val = (0x13 << 8) | (0x17 << 16) | (0x19 << 24);
1489: }
1490: /* Make sure not to write over XOCLK0 */
1491: gmu_core_regrmw(device, A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_0,
1492: 0xffffff00, val);
1493:
1494: gmu_core_regwrite(device, A6XX_GMU_AO_SPARE_CNTL, 1);
1495: }
1496:
1497: void a6xx_gmu_register_config(struct adreno_device *adreno_dev)
1498: {
1499: const struct adreno_a6xx_core *a6xx_core = to_a6xx_core(adreno_dev);
1500: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
1501: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1502: u32 gmu_log_info, chipid = 0;
1503:
1504: /* Clear any previously set cm3 fault */
1505: atomic_set(&gmu->cm3_fault, 0);
1506:
1507: /* Vote veto for FAL10 feature if supported*/
1508: if (a6xx_core->veto_fal10) {
1509: gmu_core_regwrite(device,
1510: A6XX_GPU_GMU_CX_GMU_CX_FALNEXT_INTF, 0x1);
1511: gmu_core_regwrite(device, A6XX_GPU_GMU_CX_GMU_CX_FAL_INTF, 0x1);
1512: }
1513:
1514: /* Turn on TCM retention */
1515: gmu_core_regwrite(device, A6XX_GMU_GENERAL_7, 1);
1516:
1517: /* Clear init result to make sure we are getting fresh value */
1518: gmu_core_regwrite(device, A6XX_GMU_CM3_FW_INIT_RESULT, 0);
1519: gmu_core_regwrite(device, A6XX_GMU_CM3_BOOT_CONFIG, 0x2);
1520:
1521: gmu_core_regwrite(device, A6XX_GMU_HFI_QTBL_ADDR,
1522: gmu->hfi.hfi_mem->gmuaddr);
1523: gmu_core_regwrite(device, A6XX_GMU_HFI_QTBL_INFO, 1);
1524:
1525: /*
1526: * For A6xx GMUAO interrupt line BIT[1] is combined for ipcc
1527: * and doorbell. Enable dbdWakeupEn interrupt for GMU to receive
1528: * IPC interrupt.
1529: */
1530: if (ADRENO_FEATURE(adreno_dev, ADRENO_LSR))
1531: gmu_core_regwrite(device, A6XX_GMU_AO_INTERRUPT_EN, BIT(1));
1532:
1533: gmu_core_regwrite(device, A6XX_GMU_AHB_FENCE_RANGE_0,
1534: GMU_FENCE_RANGE_MASK);
1535:
1536: /*
1537: * Make sure that CM3 state is at reset value. Snapshot is changing
1538: * NMI bit and if we boot up GMU with NMI bit set GMU will boot
1539: * straight in to NMI handler without executing __main code
1540: */
1541: gmu_core_regwrite(device, A6XX_GMU_CM3_CFG, 0x4052);
1542:
1543: /**
1544: * We may have asserted gbif halt as part of reset sequence which may
1545: * not get cleared if the gdsc was not reset. So clear it before
1546: * attempting GMU boot.
1547: */
1548: if (!adreno_is_a630(adreno_dev))
1549: kgsl_regwrite(device, A6XX_GBIF_HALT, 0x0);
1550:
1551: /* Set vrb address before starting GMU */
1552: if (!IS_ERR_OR_NULL(device->gmu_core.vrb))
1553: gmu_core_regwrite(device, A6XX_GMU_GENERAL_11, device->gmu_core.vrb->gmuaddr);
1554:
1555: /* Set the log wptr index */
1556: gmu_core_regwrite(device, A6XX_GPU_GMU_CX_GMU_PWR_COL_CP_RESP,
1557: gmu->log_wptr_retention);
1558:
1559: /* Pass chipid to GMU FW, must happen before starting GMU */
1560: chipid = ADRENO_GMU_CHIPID(adreno_dev->chipid);
1561:
1562: /*
1563: * For A660 GPU variant, GMU firmware expects chipid as per below
1564: * format to differentiate between A660 and A660 variant. In device
1565: * tree, target version is specified as high nibble of patch to align
1566: * with usermode driver expectation. Format the chipid according to
1567: * firmware requirement.
1568: *
1569: * Bit 11-8: patch version
1570: * Bit 15-12: minor version
1571: * Bit 23-16: major version
1572: * Bit 27-24: core version
1573: * Bit 31-28: target version
1574: */
1575: if (adreno_is_a660_shima(adreno_dev))
1576: chipid |= ((ADRENO_CHIPID_PATCH(adreno_dev->chipid) >> 4) << 28);
1577:
1578: gmu_core_regwrite(device, A6XX_GMU_HFI_SFR_ADDR, chipid);
1579:
1580: /* Log size is encoded in (number of 4K units - 1) */
1581: gmu_log_info = (gmu->gmu_log->gmuaddr & 0xFFFFF000) |
1582: ((GMU_LOG_SIZE/SZ_4K - 1) & 0xFF);
1583: gmu_core_regwrite(device, A6XX_GPU_GMU_CX_GMU_PWR_COL_CP_MSG,
1584: gmu_log_info);
1585:
1586: /* Configure power control and bring the GMU out of reset */
1587: a6xx_gmu_power_config(adreno_dev);
1588:
1589: a6xx_gmu_enable_throttle_counters(adreno_dev);
1590: }
1591:
1592: static int reserve_entire_vma(struct a6xx_gmu_device *gmu, u32 vma_id)
1593: {
1594: struct kgsl_memdesc *md;
1595: struct kgsl_device *device = KGSL_DEVICE(a6xx_gmu_to_adreno(gmu));
1596: u32 start = device->gmu_core.vma[vma_id].start, size = device->gmu_core.vma[vma_id].size;
1597:
1598: md = gmu_core_find_memdesc(device, start, size);
1599: if (md)
1600: return 0;
1601:
1602: md = gmu_core_reserve_kernel_block(device, start, size, vma_id, 0);
1603:
1604: return PTR_ERR_OR_ZERO(md);
1605: }
1606:
1607: static int a6xx_gmu_cache_finalize(struct adreno_device *adreno_dev)
1608: {
1609: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
1610: struct kgsl_memdesc *md;
1611: int ret;
1612:
1613: /* Preallocations were made so no need to request all this memory */
1614: if (gmu->preallocations)
1615: return 0;
1616:
1617: ret = reserve_entire_vma(gmu, GMU_ICACHE);
1618: if (ret)
1619: return ret;
1620:
1621: if (!adreno_is_a650_family(adreno_dev)) {
1622: ret = reserve_entire_vma(gmu, GMU_DCACHE);
1623: if (ret)
1624: return ret;
1625: }
1626:
1627: md = gmu_core_reserve_kernel_block(KGSL_DEVICE(adreno_dev), 0, SZ_4K,
1628: GMU_NONCACHED_KERNEL, 0);
1629: if (IS_ERR(md))
1630: return PTR_ERR(md);
1631:
1632: gmu->preallocations = true;
1633:
1634: return 0;
1635: }
1636:
1637: static int a6xx_gmu_process_prealloc(struct a6xx_gmu_device *gmu,
1638: struct gmu_block_header *blk)
1639: {
1640: struct kgsl_device *device = KGSL_DEVICE(a6xx_gmu_to_adreno(gmu));
1641: struct kgsl_memdesc *md;
1642:
1643: int id = gmu_core_find_vma_block(device, blk->addr, blk->value);
1644:
1645: if (id < 0) {
1646: dev_err(GMU_PDEV_DEV(device),
1647: "Invalid prealloc block addr: 0x%x value:%d\n",
1648: blk->addr, blk->value);
1649: return id;
1650: }
1651:
1652: /* Nothing to do for TCM blocks or user uncached */
1653: if (id == GMU_ITCM || id == GMU_DTCM || id == GMU_NONCACHED_USER)
1654: return 0;
1655:
1656: /* Check if the block is already allocated */
1657: md = gmu_core_find_memdesc(device, blk->addr, blk->value);
1658: if (md != NULL)
1659: return 0;
1660:
1661: md = gmu_core_reserve_kernel_block(device, blk->addr, blk->value, id, 0);
1662: if (IS_ERR(md))
1663: return PTR_ERR(md);
1664:
1665: gmu->preallocations = true;
1666:
1667: return 0;
1668: }
1669:
1670: int a6xx_gmu_parse_fw(struct adreno_device *adreno_dev)
1671: {
1672: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
1673: const struct adreno_a6xx_core *a6xx_core = to_a6xx_core(adreno_dev);
1674: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
1675: struct gmu_block_header *blk;
1676: int ret, offset = 0;
1677:
1678: /* GMU fw already saved and verified so do nothing new */
1679: if (!gmu->fw_image) {
1680:
1681: if (a6xx_core->gmufw_name == NULL)
1682: return -EINVAL;
1683:
1684: ret = adreno_request_firmware(&gmu->fw_image, a6xx_core->gmufw_name,
1685: gmu_pdev_dev, true);
1686: if (ret)
1687: return ret;
1688: }
1689:
1690: /*
1691: * Zero payload fw blocks contain metadata and are
1692: * guaranteed to precede fw load data. Parse the
1693: * metadata blocks.
1694: */
1695: while (offset < gmu->fw_image->size) {
1696: blk = (struct gmu_block_header *)&gmu->fw_image->data[offset];
1697:
1698: if (offset + sizeof(*blk) > gmu->fw_image->size) {
1699: dev_err(gmu_pdev_dev, "Invalid FW Block\n");
1700: return -EINVAL;
1701: }
1702:
1703: /* Done with zero length blocks so return */
1704: if (blk->size)
1705: break;
1706:
1707: offset += sizeof(*blk);
1708:
1709: if (blk->type == GMU_BLK_TYPE_PREALLOC_REQ ||
1710: blk->type == GMU_BLK_TYPE_PREALLOC_PERSIST_REQ) {
1711: ret = a6xx_gmu_process_prealloc(gmu, blk);
1712:
1713: if (ret)
1714: return ret;
1715: }
1716: }
1717:
1718: return 0;
1719: }
1720:
1721: int a6xx_gmu_memory_init(struct adreno_device *adreno_dev)
1722: {
1723: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
1724: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1725:
1726: /* Allocates & maps GMU crash dump memory */
1727: if (adreno_is_a630(adreno_dev) || adreno_is_a615_family(adreno_dev)) {
1728: if (IS_ERR_OR_NULL(gmu->dump_mem))
1729: gmu->dump_mem = gmu_core_reserve_kernel_block(device, 0,
1730: SZ_16K, GMU_NONCACHED_KERNEL, 0);
1731: if (IS_ERR(gmu->dump_mem))
1732: return PTR_ERR(gmu->dump_mem);
1733: }
1734:
1735: /* GMU master log */
1736: if (IS_ERR_OR_NULL(gmu->gmu_log))
1737: gmu->gmu_log = gmu_core_reserve_kernel_block(device, 0, GMU_LOG_SIZE,
1738: GMU_NONCACHED_KERNEL, 0);
1739:
1740: return PTR_ERR_OR_ZERO(gmu->gmu_log);
1741: }
1742:
1743: static int a6xx_gmu_init(struct adreno_device *adreno_dev)
1744: {
1745: int ret;
1746:
1747: ret = a6xx_gmu_parse_fw(adreno_dev);
1748: if (ret)
1749: return ret;
1750:
1751: /* Request any other cache ranges that might be required */
1752: ret = a6xx_gmu_cache_finalize(adreno_dev);
1753: if (ret)
1754: return ret;
1755:
1756: ret = a6xx_gmu_memory_init(adreno_dev);
1757: if (ret)
1758: return ret;
1759:
1760: return a6xx_hfi_init(adreno_dev);
1761: }
1762:
1763: #define A6XX_VBIF_XIN_HALT_CTRL1_ACKS (BIT(0) | BIT(1) | BIT(2) | BIT(3))
1764:
1765: static void a6xx_gmu_pwrctrl_suspend(struct adreno_device *adreno_dev)
1766: {
1767: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1768:
1769: /* If SPTP_RAC is on, turn off SPTP_RAC HS */
1770: a6xx_gmu_sptprac_disable(adreno_dev);
1771:
1772: /* Disconnect GPU from BUS is not needed if CX GDSC goes off later */
1773:
1774: /*
1775: * GEMNOC can enter power collapse state during GPU power down sequence.
1776: * This could abort CX GDSC collapse. Assert Qactive to avoid this.
1777: */
1778: if ((adreno_is_a662(adreno_dev) || adreno_is_a621(adreno_dev) ||
1779: adreno_is_a622(adreno_dev) || adreno_is_a642l(adreno_dev)))
1780: gmu_core_regwrite(device, A6XX_GPU_GMU_CX_GMU_CX_FALNEXT_INTF, 0x1);
1781:
1782: /* Check no outstanding RPMh voting */
1783: a6xx_complete_rpmh_votes(adreno_dev, GPU_RESET_TIMEOUT);
1784:
1785: /* Clear the WRITEDROPPED fields and set fence to allow mode */
1786: gmu_core_regwrite(device, A6XX_GMU_AHB_FENCE_STATUS_CLR, 0x7);
1787: gmu_core_regwrite(device, A6XX_GMU_AO_AHB_FENCE_CTRL, 0);
1788:
1789: /* Make sure above writes are committed before we proceed to recovery */
1790: wmb();
1791:
1792: gmu_core_regwrite(device, A6XX_GMU_CM3_SYSRESET, 1);
1793:
1794: if (!adreno_is_a630(adreno_dev)) {
1795: /* Halt GX traffic */
1796: if (a6xx_gmu_gx_is_on(adreno_dev)) {
1797: kgsl_regwrite(device, A6XX_RBBM_GBIF_HALT,
1798: A6XX_GBIF_GX_HALT_MASK);
1799: adreno_wait_for_halt_ack(device,
1800: A6XX_RBBM_GBIF_HALT_ACK,
1801: A6XX_GBIF_GX_HALT_MASK);
1802: }
1803: /* Halt CX traffic */
1804: a6xx_halt_gbif(adreno_dev);
1805: /* De-assert the halts */
1806: kgsl_regwrite(device, A6XX_GBIF_HALT, 0x0);
1807: }
1808:
1809: /*
1810: * GX_CXO_CLK is needed to access RBBM_SW_RESET_CMD register. There are
1811: * scenarios where the IFPC exit sequence is still in progress, and the
1812: * above clock may not be enabled. This situation leads to unclocked
1813: * access. Thus, trigger RBBM_SW_RESET_CMD only when GPU is fully active
1814: * i.e., IFPC sequence is completed.
1815: */
1816: if (a6xx_gmu_gx_is_on(adreno_dev) && a6xx_gmu_rpmh_pwr_state_is_active(device))
1817: kgsl_regwrite(device, A6XX_RBBM_SW_RESET_CMD, 0x1);
1818:
1819: /* Make sure above writes are posted before turning off power resources */
1820: wmb();
1821:
1822: /* Allow the software reset to complete */
1823: udelay(100);
1824:
1825: /*
1826: * This is based on the assumption that GMU is the only one controlling
1827: * the GX HS. This code path is the only client voting for GX from linux
1828: * kernel.
1829: */
1830: if (!a6xx_gmu_gx_is_on(adreno_dev))
1831: return;
1832:
1833: /*
1834: * Switch gx gdsc control from GMU to CPU force non-zero reference
1835: * count in clk driver so next disable call will turn off the GDSC
1836: */
1837: kgsl_pwrctrl_enable_gx_gdsc(device);
1838:
1839: /*
1840: * Toggle the loop_en bit, across disabling the gx gdsc, with a delay
1841: * of 10 XO cycles before disabling gx gdsc. This is to prevent CPR
1842: * measurements from failing.
1843: */
1844: if (adreno_is_a660(adreno_dev)) {
1845: gmu_core_regrmw(device, A6XX_GPU_CPR_FSM_CTL, 1, 0);
1846: ndelay(520);
1847: }
1848:
1849: kgsl_pwrctrl_disable_gx_gdsc(device);
1850:
1851: if (adreno_is_a660(adreno_dev))
1852: gmu_core_regrmw(device, A6XX_GPU_CPR_FSM_CTL, 1, 1);
1853:
1854: if (a6xx_gmu_gx_is_on(adreno_dev))
1855: dev_err(GMU_PDEV_DEV(device), "gx is stuck on\n");
1856: }
1857:
1858: /*
1859: * a6xx_gmu_notify_slumber() - initiate request to GMU to prepare to slumber
1860: * @device: Pointer to KGSL device
1861: */
1862: static int a6xx_gmu_notify_slumber(struct adreno_device *adreno_dev)
1863: {
1864: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1865: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1866: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
1867: int bus_level = pwr->pwrlevels[pwr->default_pwrlevel].bus_freq;
1868: int perf_idx = gmu->hfi.dcvs_table.gpu_level_num -
1869: pwr->default_pwrlevel - 1;
1870: int ret, state;
1871:
1872: /* Disable the power counter so that the GMU is not busy */
1873: gmu_core_regwrite(device, A6XX_GMU_CX_GMU_POWER_COUNTER_ENABLE, 0);
1874:
1875: /* Turn off SPTPRAC if we own it */
1876: if (gmu->idle_level == GPU_HW_ACTIVE)
1877: a6xx_gmu_sptprac_disable(adreno_dev);
1878:
1879: if (!ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_HFI_USE_REG)) {
1880: struct hfi_prep_slumber_cmd req = {
1881: .freq = perf_idx,
1882: .bw = bus_level,
1883: };
1884:
1885: ret = CMD_MSG_HDR(req, H2F_MSG_PREPARE_SLUMBER);
1886: if (!ret)
1887: ret = a6xx_hfi_send_generic_req(adreno_dev, &req, sizeof(req));
1888:
1889: goto out;
1890: }
1891:
1892: gmu_core_regwrite(device, A6XX_GMU_BOOT_SLUMBER_OPTION,
1893: OOB_SLUMBER_OPTION);
1894: gmu_core_regwrite(device, A6XX_GMU_GX_VOTE_IDX, perf_idx);
1895: gmu_core_regwrite(device, A6XX_GMU_MX_VOTE_IDX, bus_level);
1896:
1897: ret = a6xx_gmu_oob_set(device, oob_boot_slumber);
1898: a6xx_gmu_oob_clear(device, oob_boot_slumber);
1899:
1900: if (!ret) {
1901: gmu_core_regread(device,
1902: A6XX_GPU_GMU_CX_GMU_RPMH_POWER_STATE, &state);
1903: if (state != GPU_HW_SLUMBER) {
1904: dev_err(GMU_PDEV_DEV(device),
1905: "Failed to prepare for slumber: 0x%x\n",
1906: state);
1907: ret = -ETIMEDOUT;
1908: }
1909: }
1910:
1911: out:
1912: /* Make sure the fence is in ALLOW mode */
1913: gmu_core_regwrite(device, A6XX_GMU_AO_AHB_FENCE_CTRL, 0);
1914:
1915: /*
1916: * GEMNOC can enter power collapse state during GPU power down sequence.
1917: * This could abort CX GDSC collapse. Assert Qactive to avoid this.
1918: */
1919: if ((adreno_is_a662(adreno_dev) || adreno_is_a621(adreno_dev) ||
1920: adreno_is_a622(adreno_dev) || adreno_is_a642l(adreno_dev)))
1921: gmu_core_regwrite(device, A6XX_GPU_GMU_CX_GMU_CX_FALNEXT_INTF, 0x1);
1922:
1923: return ret;
1924: }
1925:
1926: void a6xx_gmu_suspend(struct adreno_device *adreno_dev, bool force)
1927: {
1928: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1929:
1930: if (!force && test_bit(ADRENO_DEVICE_RESET_RECOVERY, &adreno_dev->priv))
1931: return;
1932:
1933: a6xx_gmu_pwrctrl_suspend(adreno_dev);
1934:
1935: gmu_core_disable_clks(device);
1936:
1937: a6xx_gmu_disable_gdsc(adreno_dev);
1938:
1939: gmu_core_rdpm_cx_freq_update(device, 0);
1940:
1941: dev_err(GMU_PDEV_DEV(device), "Suspended GMU\n");
1942:
1943: kgsl_pwrctrl_set_state(device, KGSL_STATE_NONE);
1944: }
1945:
1946: static int a6xx_gmu_dcvs_set(struct adreno_device *adreno_dev,
1947: int gpu_pwrlevel, int bus_level)
1948: {
1949: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1950: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1951: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
1952: struct hfi_dcvstable_cmd *table = &gmu->hfi.dcvs_table;
1953: struct hfi_gx_bw_perf_vote_cmd req = {
1954: .ack_type = DCVS_ACK_BLOCK,
1955: .freq = INVALID_DCVS_IDX,
1956: .bw = INVALID_DCVS_IDX,
1957: };
1958: int ret = 0;
1959:
1960: if (!test_bit(GMU_PRIV_HFI_STARTED, &gmu->flags))
1961: return 0;
1962:
1963: /* Do not set to XO and lower GPU clock vote from GMU */
1964: if ((gpu_pwrlevel != INVALID_DCVS_IDX) &&
1965: (gpu_pwrlevel >= table->gpu_level_num - 1))
1966: return -EINVAL;
1967:
1968: if (gpu_pwrlevel < table->gpu_level_num - 1)
1969: req.freq = table->gpu_level_num - gpu_pwrlevel - 1;
1970:
1971: if (bus_level < pwr->ddr_table_count && bus_level > 0)
1972: req.bw = bus_level;
1973:
1974: /* GMU will vote for slumber levels through the sleep sequence */
1975: if ((req.freq == INVALID_DCVS_IDX) &&
1976: (req.bw == INVALID_DCVS_IDX)) {
1977: return 0;
1978: }
1979:
1980: ret = CMD_MSG_HDR(req, H2F_MSG_GX_BW_PERF_VOTE);
1981: if (ret)
1982: return ret;
1983:
1984: if (ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_HFI_USE_REG))
1985: ret = a6xx_gmu_dcvs_nohfi(device, req.freq, req.bw);
1986: else
1987: ret = a6xx_hfi_send_generic_req(adreno_dev, &req, sizeof(req));
1988:
1989: if (ret) {
1990: dev_err_ratelimited(GMU_PDEV_DEV(device),
1991: "Failed to set GPU perf idx %u, bw idx %u\n",
1992: req.freq, req.bw);
1993:
1994: /*
1995: * If this was a dcvs request along side an active gpu, request
1996: * dispatcher based reset and recovery.
1997: */
1998: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags))
1999: adreno_scheduler_fault(adreno_dev, ADRENO_GMU_FAULT |
2000: ADRENO_GMU_FAULT_SKIP_SNAPSHOT);
2001: }
2002:
2003: if (req.freq != INVALID_DCVS_IDX)
2004: gmu_core_rdpm_mx_freq_update(device, table->gx_votes[req.freq].freq);
2005:
2006: return ret;
2007: }
2008:
2009: static int a6xx_gmu_clock_set(struct adreno_device *adreno_dev, u32 pwrlevel)
2010: {
2011: return a6xx_gmu_dcvs_set(adreno_dev, pwrlevel, INVALID_DCVS_IDX);
2012: }
2013:
2014: static int a6xx_gmu_ifpc_store(struct kgsl_device *device,
2015: unsigned int val)
2016: {
2017: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
2018: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
2019: unsigned int requested_idle_level;
2020:
2021: if (!ADRENO_FEATURE(adreno_dev, ADRENO_IFPC))
2022: return -EINVAL;
2023:
2024: if (val)
2025: requested_idle_level = GPU_HW_IFPC;
2026: else
2027: requested_idle_level = GPU_HW_ACTIVE;
2028:
2029: if (gmu->idle_level == requested_idle_level)
2030: return 0;
2031:
2032: /* Power down the GPU before changing the idle level */
2033: return adreno_power_cycle_u32(adreno_dev, &gmu->idle_level,
2034: requested_idle_level);
2035: }
2036:
2037: static unsigned int a6xx_gmu_ifpc_isenabled(struct kgsl_device *device)
2038: {
2039: struct a6xx_gmu_device *gmu = to_a6xx_gmu(ADRENO_DEVICE(device));
2040:
2041: return gmu->idle_level == GPU_HW_IFPC;
2042: }
2043:
2044: /* Send an NMI to the GMU */
2045: void a6xx_gmu_send_nmi(struct kgsl_device *device, bool force,
2046: enum gmu_fault_panic_policy gf_policy)
2047: {
2048: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
2049: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
2050: u64 ticks = gpudev->read_alwayson(adreno_dev);
2051: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
2052: u32 val;
2053:
2054: /*
2055: * Do not send NMI if the SMMU is stalled because GMU will not be able
2056: * to save cm3 state to DDR.
2057: */
2058: if (a6xx_gmu_gx_is_on(adreno_dev) && adreno_smmu_is_stalled(adreno_dev)) {
2059: dev_err(GMU_PDEV_DEV(device),
2060: "Skipping NMI because SMMU is stalled\n");
2061: goto done;
2062: }
2063:
2064: if (force)
2065: goto nmi;
2066:
2067: /*
2068: * We should not send NMI if there was a CM3 fault reported because we
2069: * don't want to overwrite the critical CM3 state captured by gmu before
2070: * it sent the CM3 fault interrupt. Also don't send NMI if GMU reset is
2071: * already active. We could have hit a GMU assert and NMI might have
2072: * already been triggered.
2073: */
2074:
2075: /* make sure we're reading the latest cm3_fault */
2076: smp_rmb();
2077:
2078: if (atomic_read(&gmu->cm3_fault))
2079: return;
2080:
2081: gmu_core_regread(device, A6XX_GMU_CM3_FW_INIT_RESULT, &val);
2082:
2083: if (val & 0xE00)
2084: return;
2085:
2086: nmi:
2087: /* Mask so there's no interrupt caused by NMI */
2088: gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_MASK, 0xFFFFFFFF);
2089:
2090: /* Make sure the interrupt is masked before causing it */
2091: wmb();
2092: if (ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_HFI_USE_REG))
2093: gmu_core_regwrite(device,
2094: A6XX_GMU_NMI_CONTROL_STATUS, 0);
2095:
2096: /* This will cause the GMU to save it's internal state to ddr */
2097: gmu_core_regread(device, A6XX_GMU_CM3_CFG, &val);
2098: val |= BIT(9);
2099: gmu_core_regwrite(device, A6XX_GMU_CM3_CFG, val);
2100:
2101: /* Make sure the NMI is invoked before we proceed*/
2102: wmb();
2103:
2104: /* Wait for the NMI to be handled */
2105: udelay(200);
2106:
2107: done:
2108: KGSL_GMU_CORE_FORCE_PANIC(device->gmu_core.gf_panic, GMU_PDEV(device), ticks, gf_policy);
2109: }
2110:
2111: static void a6xx_gmu_cooperative_reset(struct kgsl_device *device)
2112: {
2113: unsigned int result;
2114:
2115: gmu_core_regwrite(device, A6XX_GMU_CX_GMU_WDOG_CTRL, 0);
2116: gmu_core_regwrite(device, A6XX_GMU_HOST2GMU_INTR_SET, BIT(17));
2117:
2118: /*
2119: * After triggering graceful death wait for snapshot ready
2120: * indication from GMU.
2121: */
2122: if (!gmu_core_timed_poll_check(device, A6XX_GMU_CM3_FW_INIT_RESULT,
2123: 0x800, 2, 0x800))
2124: return;
2125:
2126: gmu_core_regread(device, A6XX_GMU_CM3_FW_INIT_RESULT, &result);
2127: dev_err(GMU_PDEV_DEV(device),
2128: "GMU cooperative reset timed out 0x%x\n", result);
2129: /*
2130: * If we dont get a snapshot ready from GMU, trigger NMI
2131: * and if we still timeout then we just continue with reset.
2132: */
2133: a6xx_gmu_send_nmi(device, true, GMU_FAULT_PANIC_NONE);
2134:
2135: gmu_core_regread(device, A6XX_GMU_CM3_FW_INIT_RESULT, &result);
2136: if ((result & 0x800) != 0x800)
2137: dev_err(GMU_PDEV_DEV(device),
2138: "GMU cooperative reset NMI timed out 0x%x\n", result);
2139: }
2140:
2141: static int a6xx_gmu_wait_for_active_transition(
2142: struct kgsl_device *device)
2143: {
2144: unsigned int reg;
2145:
2146: if (!gmu_core_isenabled(device))
2147: return 0;
2148:
2149: if (gmu_core_timed_poll_check(device, A6XX_GPU_GMU_CX_GMU_RPMH_POWER_STATE,
2150: GPU_HW_ACTIVE, 100, GENMASK(3, 0))) {
2151: gmu_core_regread(device, A6XX_GPU_GMU_CX_GMU_RPMH_POWER_STATE, ®);
2152: dev_err(GMU_PDEV_DEV(device),
2153: "GMU failed to move to ACTIVE state, Current state: 0x%x\n",
2154: reg);
2155:
2156: return -ETIMEDOUT;
2157: }
2158:
2159: return 0;
2160: }
2161:
2162: static bool a6xx_gmu_scales_bandwidth(struct kgsl_device *device)
2163: {
2164: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
2165:
2166: return (ADRENO_GPUREV(adreno_dev) >= ADRENO_REV_A640);
2167: }
2168:
2169: void a6xx_gmu_handle_watchdog(struct adreno_device *adreno_dev)
2170: {
2171: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2172: u32 mask;
2173:
2174: /* Temporarily mask the watchdog interrupt to prevent a storm */
2175: gmu_core_regread(device, A6XX_GMU_AO_HOST_INTERRUPT_MASK,
2176: &mask);
2177: gmu_core_regwrite(device, A6XX_GMU_AO_HOST_INTERRUPT_MASK,
2178: (mask | GMU_INT_WDOG_BITE));
2179:
2180: a6xx_gmu_send_nmi(device, false, GMU_FAULT_PANIC_NONE);
2181:
2182: dev_err_ratelimited(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),
2183: "GMU watchdog expired interrupt received\n");
2184: }
2185:
2186: static irqreturn_t a6xx_gmu_irq_handler(int irq, void *data)
2187: {
2188: struct kgsl_device *device = data;
2189: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
2190: const struct a6xx_gpudev *a6xx_gpudev =
2191: to_a6xx_gpudev(ADRENO_GPU_DEVICE(adreno_dev));
2192: unsigned int status = 0;
2193:
2194: gmu_core_regread(device, A6XX_GMU_AO_HOST_INTERRUPT_STATUS, &status);
2195: gmu_core_regwrite(device, A6XX_GMU_AO_HOST_INTERRUPT_CLR, status);
2196:
2197: /* Ignore GMU_INT_RSCC_COMP and GMU_INT_DBD WAKEUP interrupts */
2198: if (status & GMU_INT_WDOG_BITE)
2199: a6xx_gpudev->handle_watchdog(adreno_dev);
2200: if (status & GMU_INT_HOST_AHB_BUS_ERR)
2201: dev_err_ratelimited(GMU_PDEV_DEV(device),
2202: "AHB bus error interrupt received\n");
2203: if (status & GMU_INT_FENCE_ERR) {
2204: unsigned int fence_status;
2205:
2206: gmu_core_regread(device, A6XX_GMU_AHB_FENCE_STATUS,
2207: &fence_status);
2208: dev_err_ratelimited(GMU_PDEV_DEV(device),
2209: "FENCE error interrupt received %x\n", fence_status);
2210: }
2211:
2212: if (status & ~GMU_AO_INT_MASK)
2213: dev_err_ratelimited(GMU_PDEV_DEV(device),
2214: "Unhandled GMU interrupts 0x%lx\n",
2215: status & ~GMU_AO_INT_MASK);
2216:
2217: return IRQ_HANDLED;
2218: }
2219:
2220: void a6xx_gmu_snapshot(struct adreno_device *adreno_dev,
2221: struct kgsl_snapshot *snapshot)
2222: {
2223: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2224:
2225: a6xx_gmu_device_snapshot(device, snapshot);
2226:
2227: a6xx_snapshot(adreno_dev, snapshot);
2228:
2229: gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_CLR,
2230: 0xffffffff);
2231: gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_MASK,
2232: HFI_IRQ_MASK);
2233:
2234: }
2235:
2236: void a6xx_gmu_aop_send_acd_state(struct a6xx_gmu_device *gmu, bool flag)
2237: {
2238: struct kgsl_device *device = KGSL_DEVICE(a6xx_gmu_to_adreno(gmu));
2239: char msg_buf[36];
2240: u32 size;
2241: int ret;
2242:
2243: if (IS_ERR_OR_NULL(gmu->qmp) && IS_ERR_OR_NULL(gmu->mailbox.channel))
2244: return;
2245:
2246: size = scnprintf(msg_buf, sizeof(msg_buf),
2247: "{class: gpu, res: acd, val: %d}", flag);
2248:
2249: /* mailbox controller expects 4-byte aligned buffer */
2250: size = ALIGN((size + 1), SZ_4);
2251:
2252: if (gmu->qmp) {
2253: ret = qmp_send(gmu->qmp, msg_buf, size);
2254: } else {
2255: struct qmp_pkt msg;
2256:
2257: msg.size = size;
2258: msg.data = msg_buf;
2259:
2260: ret = mbox_send_message(gmu->mailbox.channel, &msg);
2261: }
2262:
2263: if (ret < 0)
2264: dev_err(GMU_PDEV_DEV(device),
2265: "AOP send message failed: %d\n", ret);
2266: }
2267:
2268: static void a6xx_gmu_force_first_boot(struct kgsl_device *device)
2269: {
2270: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
2271: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
2272: u32 val = 0;
2273:
2274: if (gmu->pdc_cfg_base) {
2275: kgsl_pwrctrl_enable_cx_gdsc(device);
2276: gmu_core_enable_clks(device, 0);
2277:
2278: val = __raw_readl(gmu->pdc_cfg_base + (PDC_GPU_ENABLE_PDC << 2));
2279:
2280: /* ensure this read operation is done before the next one */
2281: rmb();
2282:
2283: gmu_core_disable_clks(device);
2284: a6xx_gmu_disable_gdsc(adreno_dev);
2285: gmu_core_rdpm_cx_freq_update(device, 0);
2286: }
2287:
2288: if (val != PDC_ENABLE_REG_VALUE) {
2289: clear_bit(GMU_PRIV_RSCC_SLEEP_DONE, &gmu->flags);
2290: clear_bit(GMU_PRIV_PDC_RSC_LOADED, &gmu->flags);
2291: }
2292: }
2293:
2294: static int a6xx_gmu_first_boot(struct adreno_device *adreno_dev)
2295: {
2296: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2297: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
2298: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
2299: int level, ret;
2300:
2301: kgsl_pwrctrl_request_state(device, KGSL_STATE_AWARE);
2302:
2303: a6xx_gmu_aop_send_acd_state(gmu, adreno_dev->acd_enabled);
2304:
2305: ret = kgsl_pwrctrl_enable_cx_gdsc(device);
2306: if (ret)
2307: return ret;
2308:
2309: ret = gmu_core_enable_clks(device, 0);
2310: if (ret)
2311: goto gdsc_off;
2312:
2313: ret = a6xx_gmu_load_fw(adreno_dev);
2314: if (ret)
2315: goto clks_gdsc_off;
2316:
2317: ret = a6xx_gmu_itcm_shadow(adreno_dev);
2318: if (ret)
2319: goto clks_gdsc_off;
2320:
2321: a6xx_gmu_register_config(adreno_dev);
2322:
2323: a6xx_gmu_version_info(adreno_dev);
2324:
2325: a6xx_gmu_irq_enable(adreno_dev);
2326:
2327: /* Vote for minimal DDR BW for GMU to init */
2328: level = pwr->pwrlevels[pwr->default_pwrlevel].bus_min;
2329: icc_set_bw(pwr->icc_path, 0, kBps_to_icc(pwr->ddr_table[level]));
2330:
2331: /* Clear any GPU faults that might have been left over */
2332: adreno_clear_gpu_fault(adreno_dev);
2333:
2334: ret = a6xx_gmu_device_start(adreno_dev);
2335: if (ret)
2336: goto err;
2337:
2338: /*
2339: * Load PDC and RSC ucode before turning on
2340: * GFX rail. This avoids oob set timeout
2341: * for oob_boot_slumber request during
2342: * GMU first boot
2343: */
2344: if (!test_bit(GMU_PRIV_PDC_RSC_LOADED, &gmu->flags)) {
2345: ret = a6xx_load_pdc_ucode(adreno_dev);
2346: if (ret)
2347: goto err;
2348:
2349: a6xx_load_rsc_ucode(adreno_dev);
2350: set_bit(GMU_PRIV_PDC_RSC_LOADED, &gmu->flags);
2351: }
2352:
2353: if (ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_HFI_USE_REG)) {
2354: ret = a6xx_gmu_gfx_rail_on(adreno_dev);
2355: if (ret) {
2356: a6xx_gmu_oob_clear(device, oob_boot_slumber);
2357: goto err;
2358: }
2359: }
2360:
2361: if (gmu->idle_level == GPU_HW_ACTIVE) {
2362: ret = a6xx_gmu_sptprac_enable(adreno_dev);
2363: if (ret)
2364: goto err;
2365: }
2366:
2367: ret = a6xx_gmu_hfi_start(adreno_dev);
2368: if (ret)
2369: goto err;
2370:
2371: ret = a6xx_hfi_start(adreno_dev);
2372: if (ret)
2373: goto err;
2374:
2375: icc_set_bw(pwr->icc_path, 0, 0);
2376:
2377: device->gmu_fault = false;
2378:
2379: kgsl_pwrctrl_set_state(device, KGSL_STATE_AWARE);
2380:
2381: return 0;
2382:
2383: err:
2384: a6xx_gmu_irq_disable(adreno_dev);
2385:
2386: if (device->gmu_fault) {
2387: a6xx_gmu_suspend(adreno_dev, false);
2388: return ret;
2389: }
2390:
2391: clks_gdsc_off:
2392: gmu_core_disable_clks(device);
2393:
2394: gdsc_off:
2395: a6xx_gmu_disable_gdsc(adreno_dev);
2396:
2397: gmu_core_rdpm_cx_freq_update(device, 0);
2398:
2399: return ret;
2400: }
2401:
2402: static int a6xx_gmu_boot(struct adreno_device *adreno_dev)
2403: {
2404: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2405: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
2406: int ret = 0;
2407:
2408: kgsl_pwrctrl_request_state(device, KGSL_STATE_AWARE);
2409:
2410: ret = kgsl_pwrctrl_enable_cx_gdsc(device);
2411: if (ret)
2412: return ret;
2413:
2414: ret = gmu_core_enable_clks(device, 0);
2415: if (ret)
2416: goto gdsc_off;
2417:
2418: ret = a6xx_rscc_wakeup_sequence(adreno_dev);
2419: if (ret)
2420: goto clks_gdsc_off;
2421:
2422: ret = a6xx_gmu_load_fw(adreno_dev);
2423: if (ret)
2424: goto clks_gdsc_off;
2425:
2426: a6xx_gmu_register_config(adreno_dev);
2427:
2428: a6xx_gmu_irq_enable(adreno_dev);
2429:
2430: /* Clear any GPU faults that might have been left over */
2431: adreno_clear_gpu_fault(adreno_dev);
2432:
2433: ret = a6xx_gmu_device_start(adreno_dev);
2434: if (ret)
2435: goto err;
2436:
2437: if (ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_HFI_USE_REG)) {
2438: ret = a6xx_gmu_gfx_rail_on(adreno_dev);
2439: if (ret) {
2440: a6xx_gmu_oob_clear(device, oob_boot_slumber);
2441: goto err;
2442: }
2443: }
2444:
2445: if (gmu->idle_level == GPU_HW_ACTIVE) {
2446: ret = a6xx_gmu_sptprac_enable(adreno_dev);
2447: if (ret)
2448: goto err;
2449: }
2450:
2451: ret = a6xx_gmu_hfi_start(adreno_dev);
2452: if (ret)
2453: goto err;
2454:
2455: ret = a6xx_hfi_start(adreno_dev);
2456: if (ret)
2457: goto err;
2458:
2459: device->gmu_fault = false;
2460:
2461: kgsl_pwrctrl_set_state(device, KGSL_STATE_AWARE);
2462:
2463: return 0;
2464:
2465: err:
2466: a6xx_gmu_irq_disable(adreno_dev);
2467:
2468: if (device->gmu_fault) {
2469: a6xx_gmu_suspend(adreno_dev, false);
2470: return ret;
2471: }
2472:
2473: clks_gdsc_off:
2474: gmu_core_disable_clks(device);
2475:
2476: gdsc_off:
2477: a6xx_gmu_disable_gdsc(adreno_dev);
2478:
2479: gmu_core_rdpm_cx_freq_update(device, 0);
2480:
2481: return ret;
2482: }
2483:
2484: static void set_acd(struct adreno_device *adreno_dev, void *priv)
2485: {
2486: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
2487:
2488: adreno_dev->acd_enabled = *((bool *)priv);
2489: a6xx_gmu_aop_send_acd_state(gmu, adreno_dev->acd_enabled);
2490: }
2491:
2492: static int a6xx_gmu_acd_set(struct kgsl_device *device, bool val)
2493: {
2494: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
2495: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
2496:
2497: if (!gmu->qmp && !gmu->mailbox.channel)
2498: return -EINVAL;
2499:
2500: /* Don't do any unneeded work if ACD is already in the correct state */
2501: if (adreno_dev->acd_enabled == val)
2502: return 0;
2503:
2504: /* Power cycle the GPU for changes to take effect */
2505: return adreno_power_cycle(adreno_dev, set_acd, &val);
2506: }
2507:
2508: static const struct gmu_dev_ops a6xx_gmudev = {
2509: .oob_set = a6xx_gmu_oob_set,
2510: .oob_clear = a6xx_gmu_oob_clear,
2511: .ifpc_store = a6xx_gmu_ifpc_store,
2512: .ifpc_isenabled = a6xx_gmu_ifpc_isenabled,
2513: .cooperative_reset = a6xx_gmu_cooperative_reset,
2514: .wait_for_active_transition = a6xx_gmu_wait_for_active_transition,
2515: .scales_bandwidth = a6xx_gmu_scales_bandwidth,
2516: .acd_set = a6xx_gmu_acd_set,
2517: .force_first_boot = a6xx_gmu_force_first_boot,
2518: .send_nmi = a6xx_gmu_send_nmi,
2519: };
2520:
2521: static int a6xx_gmu_bus_set(struct adreno_device *adreno_dev, int buslevel,
2522: u32 ab)
2523: {
2524: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2525: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
2526: int ret = 0;
2527:
2528: kgsl_icc_set_tag(pwr, buslevel);
2529:
2530: if (buslevel != pwr->cur_buslevel) {
2531: ret = a6xx_gmu_dcvs_set(adreno_dev, INVALID_DCVS_IDX, buslevel);
2532: if (ret)
2533: return ret;
2534:
2535: pwr->cur_buslevel = buslevel;
2536: }
2537:
2538: if (ab != pwr->cur_ab) {
2539: icc_set_bw(pwr->icc_path, MBps_to_icc(ab), 0);
2540: pwr->cur_ab = ab;
2541: }
2542:
2543: trace_kgsl_buslevel(device, pwr->active_pwrlevel, pwr->cur_buslevel, pwr->cur_ab, 0);
2544: return ret;
2545: }
2546:
2547: static int a6xx_gmu_aop_messaging_init(struct adreno_device *adreno_dev,
2548: struct a6xx_gmu_device *gmu)
2549: {
2550: struct kgsl_mailbox *mailbox = &gmu->mailbox;
2551: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
2552: int ret;
2553:
2554: if (of_find_property(gmu_pdev_dev->of_node, "qcom,qmp", NULL)) {
2555: gmu->qmp = qmp_get(gmu_pdev_dev);
2556: ret = PTR_ERR_OR_ZERO(gmu->qmp);
2557: if (ret) {
2558: /* Clear the error pointer to ensure a clean state */
2559: gmu->qmp = NULL;
2560: return ret;
2561: }
2562: goto done;
2563: }
2564:
2565: mailbox->client.dev = gmu_pdev_dev;
2566: mailbox->client.tx_block = true;
2567: mailbox->client.tx_tout = 1000;
2568: mailbox->client.knows_txdone = false;
2569:
2570: mailbox->channel = mbox_request_channel(&mailbox->client, 0);
2571: ret = PTR_ERR_OR_ZERO(mailbox->channel);
2572: if (ret) {
2573: mailbox->channel = NULL;
2574: return ret;
2575: }
2576:
2577: done:
2578: adreno_dev->acd_enabled = true;
2579:
2580: return 0;
2581: }
2582:
2583: static int a6xx_gmu_acd_probe(struct kgsl_device *device,
2584: struct a6xx_gmu_device *gmu, struct device_node *node)
2585: {
2586: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
2587: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
2588: struct kgsl_pwrlevel *pwrlevel =
2589: &pwr->pwrlevels[pwr->num_pwrlevels - 1];
2590: struct hfi_acd_table_cmd *cmd = &gmu->hfi.acd_table;
2591: int ret, i, cmd_idx = 0;
2592:
2593: if (!ADRENO_FEATURE(adreno_dev, ADRENO_ACD))
2594: return 0;
2595:
2596: cmd->hdr = CREATE_MSG_HDR(H2F_MSG_ACD_TBL, HFI_MSG_CMD);
2597:
2598: cmd->version = 1;
2599: cmd->stride = 1;
2600: cmd->enable_by_level = 0;
2601:
2602: /*
2603: * Iterate through each gpu power level and generate a mask for GMU
2604: * firmware for ACD enabled levels and store the corresponding control
2605: * register configurations to the acd_table structure.
2606: */
2607: for (i = 0; i < pwr->num_pwrlevels; i++) {
2608: if (pwrlevel->acd_level) {
2609: cmd->enable_by_level |= (1 << (i + 1));
2610: cmd->data[cmd_idx++] = pwrlevel->acd_level;
2611: }
2612: pwrlevel--;
2613: }
2614:
2615: if (!cmd->enable_by_level)
2616: return 0;
2617:
2618: cmd->num_levels = cmd_idx;
2619:
2620: ret = a6xx_gmu_aop_messaging_init(adreno_dev, gmu);
2621:
2622: if (ret)
2623: dev_err_probe(GMU_PDEV_DEV(device), ret,
2624: "AOP messaging init failed\n");
2625:
2626: /*
2627: * Only fail probe for -EPROBE_DEFER; ignore other errors to avoid
2628: * failing probe if ACD init fails.
2629: */
2630:
2631: return ret == -EPROBE_DEFER ? ret : 0;
2632: }
2633:
2634: static int a6xx_gmu_reg_probe(struct adreno_device *adreno_dev)
2635: {
2636: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2637: int ret;
2638:
2639: /* Try to get the "gmu" resource, fallback to legacy "kgsl_gmu_reg" if not found */
2640: ret = kgsl_regmap_add_region(&device->regmap, GMU_PDEV(device),
2641: "gmu", -EINVAL, NULL, NULL);
2642: if (ret)
2643: ret = kgsl_regmap_add_region(&device->regmap, GMU_PDEV(device),
2644: "kgsl_gmu_reg", -EINVAL, NULL, NULL);
2645:
2646: if (ret)
2647: dev_err(GMU_PDEV_DEV(device), "Unable to map the GMU registers\n");
2648:
2649: return ret;
2650: }
2651:
2652: void a6xx_gmu_remove(struct kgsl_device *device)
2653: {
2654: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
2655: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
2656:
2657: if (gmu->qmp)
2658: qmp_put(gmu->qmp);
2659:
2660: if (gmu->mailbox.channel)
2661: mbox_free_channel(gmu->mailbox.channel);
2662:
2663: adreno_dev->acd_enabled = false;
2664:
2665: if (gmu->fw_image)
2666: release_firmware(gmu->fw_image);
2667:
2668: gmu_core_free_globals(device);
2669:
2670: vfree(gmu->itcm_shadow);
2671:
2672: if (gmu->log_kobj.state_initialized)
2673: kobject_put(&gmu->log_kobj);
2674: if (gmu->stats_kobj.state_initialized)
2675: kobject_put(&gmu->stats_kobj);
2676: }
2677:
2678: /* Offsets into the MX/CX mapped register regions */
2679: #define A6XX_RDPM_MX_OFFSET 0xf00
2680: #define A6XX_RDPM_CX_OFFSET 0xf18
2681:
2682: int a6xx_gmu_probe(struct kgsl_device *device,
2683: struct platform_device *pdev)
2684: {
2685: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
2686: const struct adreno_a6xx_core *a6xx_core = to_a6xx_core(adreno_dev);
2687: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
2688: u64 freq = a6xx_core->gmu_hub_clk_freq;
2689: struct device *dev = &pdev->dev;
2690: struct resource *res;
2691: int ret;
2692:
2693: adreno_dev->gmu_hub_clk_freq = freq ? freq : 150000000;
2694:
2695: device->gmu_core.pdev = pdev;
2696:
2697: dma_coerce_mask_and_coherent(&device->gmu_core.pdev->dev, DMA_BIT_MASK(64));
2698: set_dma_ops(GMU_PDEV_DEV(device), NULL);
2699:
2700: if (adreno_is_a650_family(adreno_dev)) {
2701: /* In standard device tree bindings, rscc range is part of GMU pdev */
2702: res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
2703: "rscc");
2704: if (!res)
2705: res = platform_get_resource_byname(device->pdev,
2706: IORESOURCE_MEM, "rscc");
2707:
2708: if (!res) {
2709: dev_err(GMU_PDEV_DEV(device), "Failed to get rscc resource\n");
2710: return -ENODEV;
2711: }
2712:
2713: gmu->rscc_virt = devm_ioremap(&device->pdev->dev, res->start,
2714: resource_size(res));
2715: if (!gmu->rscc_virt) {
2716: dev_err(&pdev->dev, "rscc ioremap failed\n");
2717: return -ENOMEM;
2718: }
2719: }
2720:
2721: /* Setup any rdpm register ranges */
2722: gmu_core_rdpm_probe(device);
2723:
2724: device->gmu_core.rdpm_cx_offset = A6XX_RDPM_CX_OFFSET;
2725: device->gmu_core.rdpm_mx_offset = A6XX_RDPM_MX_OFFSET;
2726:
2727: /* Set up GMU gdscs */
2728: ret = kgsl_pwrctrl_probe_gdscs(device, pdev);
2729: if (ret)
2730: return ret;
2731:
2732: ret = gmu_core_clk_probe(device);
2733: if (ret < 0)
2734: return ret;
2735:
2736: /* Set up GMU IOMMU and shared memory with GMU */
2737: ret = gmu_core_iommu_init(device);
2738: if (ret)
2739: goto error;
2740:
2741: if (adreno_is_a650_family(adreno_dev)) {
2742: device->gmu_core.vma = a6xx_gmu_vma;
2743: device->gmu_core.num_vmas = ARRAY_SIZE(a6xx_gmu_vma);
2744: } else {
2745: device->gmu_core.vma = a6xx_gmu_vma_legacy;
2746: device->gmu_core.num_vmas = ARRAY_SIZE(a6xx_gmu_vma_legacy);
2747: }
2748:
2749: /* Map and reserve GMU CSRs registers */
2750: ret = a6xx_gmu_reg_probe(adreno_dev);
2751: if (ret)
2752: goto error;
2753:
2754: /* Populates RPMh configurations */
2755: ret = a6xx_build_rpmh_tables(adreno_dev);
2756: if (ret)
2757: goto error;
2758:
2759: /* Set up GMU idle state */
2760: if (ADRENO_FEATURE(adreno_dev, ADRENO_IFPC)) {
2761: gmu->idle_level = GPU_HW_IFPC;
2762: adreno_dev->ifpc_hyst = A6X_GMU_LONG_IFPC_HYST;
2763: adreno_dev->ifpc_hyst_floor = A6X_GMU_LONG_IFPC_HYST_FLOOR;
2764: } else {
2765: gmu->idle_level = GPU_HW_ACTIVE;
2766: }
2767:
2768: ret = a6xx_gmu_acd_probe(device, gmu, pdev->dev.of_node);
2769: if (ret)
2770: goto error;
2771:
2772: set_bit(GMU_ENABLED, &device->gmu_core.flags);
2773:
2774: /* Initialize to zero to detect trace packet loss */
2775: device->gmu_core.trace.seq_num = 0;
2776:
2777: device->gmu_core.dev_ops = &a6xx_gmudev;
2778:
2779: /* Set default GMU attributes */
2780: gmu->log_stream_enable = false;
2781: gmu->log_group_mask = 0x3;
2782:
2783: /* Disabled by default */
2784: gmu->stats_enable = false;
2785: /* Set default to CM3 busy cycles countable */
2786: gmu->stats_mask = BIT(A6XX_GMU_CM3_BUSY_CYCLES);
2787: /* Interval is in 50 us units. Set default sampling frequency to 4x50 us */
2788: gmu->stats_interval = HFI_FEATURE_GMU_STATS_INTERVAL;
2789:
2790: /* GMU sysfs nodes setup */
2791: ret = kobject_init_and_add(&gmu->log_kobj, &log_kobj_type, &dev->kobj, "log");
2792: if (ret)
2793: dev_err(dev, "Failed to add log_kobj: %d\n", ret);
2794:
2795: ret = kobject_init_and_add(&gmu->stats_kobj, &stats_kobj_type, &dev->kobj, "stats");
2796: if (ret)
2797: dev_err(dev, "Failed to add stats_kobj: %d\n", ret);
2798:
2799: /* Try with "gmu" irq first. Use Fallback legacy name "kgsl_gmu_irq" if not found. */
2800: gmu->irq = kgsl_request_irq(GMU_PDEV(device), "gmu", "kgsl_gmu_irq", -EINVAL,
2801: a6xx_gmu_irq_handler, device);
2802:
2803: if (gmu->irq >= 0)
2804: return 0;
2805:
2806: ret = gmu->irq;
2807:
2808: error:
2809: a6xx_gmu_remove(device);
2810: return ret;
2811: }
2812:
2813: int a6xx_halt_gbif(struct adreno_device *adreno_dev)
2814: {
2815: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2816: int ret;
2817:
2818: /* Halt new client requests */
2819: kgsl_regwrite(device, A6XX_GBIF_HALT, A6XX_GBIF_CLIENT_HALT_MASK);
2820: ret = adreno_wait_for_halt_ack(device,
2821: A6XX_GBIF_HALT_ACK, A6XX_GBIF_CLIENT_HALT_MASK);
2822:
2823: /* Halt all AXI requests */
2824: kgsl_regwrite(device, A6XX_GBIF_HALT, A6XX_GBIF_ARB_HALT_MASK);
2825: ret = adreno_wait_for_halt_ack(device,
2826: A6XX_GBIF_HALT_ACK, A6XX_GBIF_ARB_HALT_MASK);
2827:
2828: return ret;
2829: }
2830:
2831: #define RPMH_VOTE_TIMEOUT 2 /* ms */
2832:
2833: static int a6xx_gmu_power_off(struct adreno_device *adreno_dev)
2834: {
2835: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2836: int ret = 0;
2837:
2838: if (device->gmu_fault)
2839: goto error;
2840:
2841: /* Wait for the lowest idle level we requested */
2842: ret = a6xx_gmu_wait_for_lowest_idle(adreno_dev);
2843: if (ret)
2844: goto error;
2845:
2846: ret = a6xx_complete_rpmh_votes(adreno_dev, RPMH_VOTE_TIMEOUT);
2847: if (ret)
2848: goto error;
2849:
2850: ret = a6xx_gmu_notify_slumber(adreno_dev);
2851: if (ret)
2852: goto error;
2853:
2854: ret = a6xx_gmu_wait_for_idle(adreno_dev);
2855: if (ret)
2856: goto error;
2857:
2858: ret = a6xx_rscc_sleep_sequence(adreno_dev);
2859:
2860: gmu_core_rdpm_mx_freq_update(device, 0);
2861:
2862: /* Now that we are done with GMU and GPU, Clear the GBIF */
2863: if (!adreno_is_a630(adreno_dev)) {
2864: ret = a6xx_halt_gbif(adreno_dev);
2865: /* De-assert the halts */
2866: kgsl_regwrite(device, A6XX_GBIF_HALT, 0x0);
2867: }
2868:
2869: a6xx_gmu_irq_disable(adreno_dev);
2870:
2871: a6xx_hfi_stop(adreno_dev);
2872:
2873: gmu_core_disable_clks(device);
2874:
2875: a6xx_gmu_disable_gdsc(adreno_dev);
2876:
2877: gmu_core_rdpm_cx_freq_update(device, 0);
2878:
2879: kgsl_pwrctrl_set_state(device, KGSL_STATE_NONE);
2880:
2881: return ret;
2882:
2883: error:
2884: a6xx_gmu_irq_disable(adreno_dev);
2885: a6xx_hfi_stop(adreno_dev);
2886: a6xx_gmu_suspend(adreno_dev, false);
2887:
2888: return ret;
2889: }
2890:
2891: void a6xx_enable_gpu_irq(struct adreno_device *adreno_dev)
2892: {
2893: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2894:
2895: kgsl_pwrctrl_irq(device, true);
2896:
2897: adreno_irqctrl(adreno_dev, 1);
2898: }
2899:
2900: void a6xx_disable_gpu_irq(struct adreno_device *adreno_dev)
2901: {
2902: kgsl_pwrctrl_irq(KGSL_DEVICE(adreno_dev), false);
2903:
2904: if (a6xx_gmu_gx_is_on(adreno_dev))
2905: adreno_irqctrl(adreno_dev, 0);
2906:
2907: }
2908:
2909: static void a6xx_fusa_init(struct adreno_device *adreno_dev)
2910: {
2911: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2912: void __iomem *fusa_virt;
2913: struct resource *res = platform_get_resource_byname(device->pdev,
2914: IORESOURCE_MEM, "fusa");
2915:
2916: if (!res)
2917: return;
2918:
2919: fusa_virt = ioremap(res->start, resource_size(res));
2920:
2921: if (!fusa_virt) {
2922: dev_err(device->dev, "Failed to map fusa\n");
2923: return;
2924: }
2925:
2926: /* Disable fusa mode in boot stage */
2927: _regrmw(fusa_virt, A6XX_GPU_FUSA_REG_ECC_CTRL - A6XX_GPU_FUSA_REG_BASE,
2928: A6XX_GPU_FUSA_DISABLE_MASK, A6XX_GPU_FUSA_DISABLE_BITS);
2929: _regrmw(fusa_virt, A6XX_GPU_FUSA_REG_CSR_PRIY - A6XX_GPU_FUSA_REG_BASE,
2930: A6XX_GPU_FUSA_DISABLE_MASK, A6XX_GPU_FUSA_DISABLE_BITS);
2931:
2932: iounmap(fusa_virt);
2933: }
2934:
2935: static int a6xx_gpu_boot(struct adreno_device *adreno_dev)
2936: {
2937: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2938: int ret;
2939:
2940: adreno_set_active_ctxs_null(adreno_dev);
2941:
2942: ret = kgsl_mmu_start(device);
2943: if (ret)
2944: goto err;
2945:
2946: ret = a6xx_gmu_oob_set(device, oob_gpu);
2947: if (ret)
2948: goto oob_clear;
2949:
2950: ret = a6xx_gmu_hfi_start_msg(adreno_dev);
2951: if (ret)
2952: goto oob_clear;
2953:
2954: /* Clear the busy_data stats - we're starting over from scratch */
2955: memset(&adreno_dev->busy_data, 0, sizeof(adreno_dev->busy_data));
2956:
2957: /* Restore performance counter registers with saved values */
2958: adreno_perfcounter_restore(adreno_dev);
2959:
2960: a6xx_start(adreno_dev);
2961:
2962: /* Re-initialize the coresight registers if applicable */
2963: adreno_coresight_start(adreno_dev);
2964:
2965: adreno_perfcounter_start(adreno_dev);
2966:
2967: /* Clear FSR here in case it is set from a previous pagefault */
2968: kgsl_mmu_clear_fsr(&device->mmu);
2969:
2970: a6xx_enable_gpu_irq(adreno_dev);
2971:
2972: ret = a6xx_rb_start(adreno_dev);
2973: if (ret) {
2974: a6xx_disable_gpu_irq(adreno_dev);
2975: adreno_llcc_slice_deactivate(adreno_dev);
2976: goto oob_clear;
2977: }
2978:
2979: /*
2980: * At this point it is safe to assume that we recovered. Setting
2981: * this field allows us to take a new snapshot for the next failure
2982: * if we are prioritizing the first unrecoverable snapshot.
2983: */
2984: if (device->snapshot)
2985: device->snapshot->recovered = true;
2986:
2987: /* Start the dispatcher */
2988: adreno_dispatcher_start(device);
2989:
2990: device->reset_counter++;
2991:
2992: a6xx_gmu_oob_clear(device, oob_gpu);
2993:
2994: if (ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_HFI_USE_REG))
2995: gmu_core_dev_oob_clear(device, oob_boot_slumber);
2996:
2997: return 0;
2998:
2999: oob_clear:
3000: a6xx_gmu_oob_clear(device, oob_gpu);
3001:
3002: if (ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_HFI_USE_REG))
3003: gmu_core_dev_oob_clear(device, oob_boot_slumber);
3004:
3005: err:
3006: a6xx_gmu_power_off(adreno_dev);
3007:
3008: return ret;
3009: }
3010:
3011: static void gmu_idle_timer(struct timer_list *t)
3012: {
3013: struct kgsl_device *device = container_of(t, struct kgsl_device,
3014: idle_timer);
3015:
3016: kgsl_schedule_work(&device->idle_check_ws);
3017: }
3018:
3019: static int a6xx_boot(struct adreno_device *adreno_dev)
3020: {
3021: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
3022: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
3023: int ret;
3024:
3025: if (WARN_ON(test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)))
3026: return 0;
3027:
3028: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE);
3029:
3030: if (IS_ENABLED(CONFIG_QCOM_KGSL_HIBERNATION) &&
3031: !test_bit(GMU_PRIV_PDC_RSC_LOADED, &gmu->flags))
3032: ret = a6xx_gmu_first_boot(adreno_dev);
3033: else
3034: ret = a6xx_gmu_boot(adreno_dev);
3035: if (ret)
3036: return ret;
3037:
3038: ret = a6xx_gpu_boot(adreno_dev);
3039: if (ret)
3040: return ret;
3041:
3042: kgsl_start_idle_timer(device);
3043:
3044: kgsl_pwrscale_wake(device);
3045:
3046: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags);
3047:
3048: device->pwrctrl.last_stat_updated = ktime_get();
3049:
3050: kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE);
3051:
3052: return ret;
3053: }
3054:
3055: static int a6xx_first_boot(struct adreno_device *adreno_dev)
3056: {
3057: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
3058: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
3059: int ret;
3060:
3061: if (test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags)) {
3062: if (!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags))
3063: return a6xx_boot(adreno_dev);
3064:
3065: return 0;
3066: }
3067:
3068: KGSL_BOOT_MARKER("ADRENO Init");
3069:
3070: ret = a6xx_ringbuffer_init(adreno_dev);
3071: if (ret)
3072: return ret;
3073:
3074: ret = a6xx_microcode_read(adreno_dev);
3075: if (ret)
3076: return ret;
3077:
3078: ret = a6xx_init(adreno_dev);
3079: if (ret)
3080: return ret;
3081:
3082: ret = a6xx_gmu_init(adreno_dev);
3083: if (ret)
3084: return ret;
3085:
3086: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE);
3087:
3088: ret = a6xx_gmu_first_boot(adreno_dev);
3089: if (ret)
3090: return ret;
3091:
3092: a6xx_fusa_init(adreno_dev);
3093:
3094: ret = a6xx_gpu_boot(adreno_dev);
3095: if (ret)
3096: return ret;
3097:
3098: adreno_get_bus_counters(adreno_dev);
3099:
3100: adreno_dev->cooperative_reset = ADRENO_FEATURE(adreno_dev,
3101: ADRENO_COOP_RESET);
3102:
3103: adreno_create_profile_buffer(adreno_dev);
3104:
3105: set_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags);
3106: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags);
3107:
3108: /*
3109: * BCL needs respective Central Broadcast register to
3110: * be programed from TZ. This programing happens only
3111: * when zap shader firmware load is successful. Zap firmware
3112: * load can fail in boot up path hence enable BCL only after we
3113: * successfully complete first boot to ensure that Central
3114: * Broadcast register was programed before enabling BCL.
3115: */
3116: if (ADRENO_FEATURE(adreno_dev, ADRENO_BCL))
3117: adreno_dev->bcl_enabled = true;
3118:
MATCH LINES: 3149, 3150, 3152, 3153, 3154, 3159, 3162, 3171, 3173, 3177, 3178, 3199, 3204, 3232, 3260, 3270, 3279, 3294, 3296, 3299, 3304, 3307, 3318, 3329, 3332, 3345, 3359, 3362, 3375, 3378, 3394, 3398, 3422, 3423, 3424, 3425, 3426, 3427, 3428, 3429, 3430, 3434, 3435, 3436, 3437, 3438, 3439, 3440, 3443, 3448, 3451, 3453, 3456, 3458, 3460, 3477, 3479, 3481, 3483, 3485, 3488, 3490, 3497, 3500, 3502, 3503, 3508, 3513, 3515, 3516, 3519, 3520, 3525, 3530, 3536, 3541, 3546, 3549, 3553, 3554, 3557, 3565, 3571, 3573, 3574, 3576, 3579, 3580, 3581, 3584, 3596, 3600, 3602, 3605, 3607, 3612, 3618, 3619, 3620, 3623
3137: kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE);
3138:
3139: KGSL_BOOT_MARKER("ADRENO Ready");
3140:
3141: return 0;
3142: }
3143:
3144: static int a630_vbif_halt(struct adreno_device *adreno_dev)
3145: {
3146: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
3147: int ret;
3148:
3149: kgsl_regwrite(device, A6XX_VBIF_XIN_HALT_CTRL0,
3150: A6XX_VBIF_XIN_HALT_CTRL0_MASK);
3151: ret = adreno_wait_for_halt_ack(device,
3152: A6XX_VBIF_XIN_HALT_CTRL1,
3153: A6XX_VBIF_XIN_HALT_CTRL0_MASK);
3154: kgsl_regwrite(device, A6XX_VBIF_XIN_HALT_CTRL0, 0);
3155:
3156: return ret;
3157: }
3158:
3159: static int a6xx_power_off(struct adreno_device *adreno_dev)
3160: {
3161: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
3162: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
3163: int ret;
3164:
3165: WARN_ON(!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags));
3166:
3167: adreno_check_idle(device);
3168:
3169: kgsl_pwrctrl_request_state(device, KGSL_STATE_SLUMBER);
3170:
3171: ret = a6xx_gmu_oob_set(device, oob_gpu);
3172: if (ret) {
3173: a6xx_gmu_oob_clear(device, oob_gpu);
3174: goto no_gx_power;
3175: }
3176:
3177: if (a6xx_irq_pending(adreno_dev)) {
3178: a6xx_gmu_oob_clear(device, oob_gpu);
3179: return -EBUSY;
3180: }
3181:
3182: kgsl_pwrscale_update_stats(device);
3183:
3184: /* Save active coresight registers if applicable */
3185: adreno_coresight_stop(adreno_dev);
3186:
3187: /* Save physical performance counter values before GPU power down*/
3188: adreno_perfcounter_save(adreno_dev);
3189:
3190: /*
3191: * Clear GX halt on non-gbif targets. For targets with GBIF,
3192: * GX halt is handled by the GMU FW.
3193: */
3194: if (adreno_is_a630(adreno_dev))
3195: a630_vbif_halt(adreno_dev);
3196:
3197: adreno_irqctrl(adreno_dev, 0);
3198:
3199: a6xx_gmu_oob_clear(device, oob_gpu);
3200:
3201: no_gx_power:
3202: kgsl_pwrctrl_irq(device, false);
3203:
3204: a6xx_gmu_power_off(adreno_dev);
3205:
3206: adreno_set_active_ctxs_null(adreno_dev);
3207:
3208: adreno_dispatcher_stop(adreno_dev);
3209:
3210: adreno_ringbuffer_stop(adreno_dev);
3211:
3212: adreno_llcc_slice_deactivate(adreno_dev);
3213:
3214: clear_bit(GMU_PRIV_GPU_STARTED, &gmu->flags);
3215:
3216: kgsl_delete_timer_sync(&device->idle_timer);
3217:
3218: kgsl_pwrscale_sleep(device);
3219:
3220: kgsl_pwrctrl_clear_l3_vote(device);
3221:
3222: kgsl_pwrctrl_set_state(device, KGSL_STATE_SLUMBER);
3223:
3224: return ret;
3225: }
3226:
3227: static void gmu_idle_check(struct work_struct *work)
3228: {
3229: struct kgsl_device *device = container_of(work,
3230: struct kgsl_device, idle_check_ws);
3231: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
3232: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
3233: int ret;
3234:
3235: kgsl_mutex_lock(&device->mutex);
3236:
3237: if (test_bit(GMU_DISABLE_SLUMBER, &device->gmu_core.flags))
3238: goto done;
3239:
3240: if (atomic_read(&device->active_cnt) || time_is_after_jiffies(device->idle_jiffies)) {
3241: kgsl_pwrscale_update(device);
3242: goto done;
3243: }
3244:
3245: if (!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags))
3246: goto done;
3247:
3248: spin_lock(&device->submit_lock);
3249:
3250: if (device->submit_now) {
3251: spin_unlock(&device->submit_lock);
3252: kgsl_pwrscale_update(device);
3253: kgsl_start_idle_timer(device);
3254: goto done;
3255: }
3256:
3257: device->skip_inline_submit = true;
3258: spin_unlock(&device->submit_lock);
3259:
3260: ret = a6xx_power_off(adreno_dev);
3261: if (ret == -EBUSY) {
3262: kgsl_pwrscale_update(device);
3263: kgsl_start_idle_timer(device);
3264: }
3265:
3266: done:
3267: kgsl_mutex_unlock(&device->mutex);
3268: }
3269:
3270: static int a6xx_gmu_first_open(struct adreno_device *adreno_dev)
3271: {
3272: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
3273: int ret;
3274:
3275: /*
3276: * Do the one time settings that need to happen when we
3277: * attempt to boot the gpu the very first time
3278: */
3279: ret = a6xx_first_boot(adreno_dev);
3280: if (ret)
3281: return ret;
3282:
3283: /*
3284: * A client that does a first_open but never closes the device
3285: * may prevent us from going back to SLUMBER. So trigger the idle
3286: * check by incrementing the active count and immediately releasing it.
3287: */
3288: atomic_inc(&device->active_cnt);
3289: adreno_active_count_put(adreno_dev);
3290:
3291: return 0;
3292: }
3293:
3294: static int a6xx_gmu_last_close(struct adreno_device *adreno_dev)
3295: {
3296: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
3297:
3298: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags))
3299: return a6xx_power_off(adreno_dev);
3300:
3301: return 0;
3302: }
3303:
3304: static int a6xx_gmu_active_count_get(struct adreno_device *adreno_dev)
3305: {
3306: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
3307: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
3308: int ret = 0;
3309:
3310: if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex)))
3311: return -EINVAL;
3312:
3313: if (test_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags))
3314: return -EINVAL;
3315:
3316: if ((atomic_read(&device->active_cnt) == 0) &&
3317: !test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags))
3318: ret = a6xx_boot(adreno_dev);
3319:
3320: if (ret == 0)
3321: atomic_inc(&device->active_cnt);
3322:
3323: trace_kgsl_active_count(device,
3324: (unsigned long) __builtin_return_address(0));
3325:
3326: return ret;
3327: }
3328:
3329: static int a6xx_gmu_pm_suspend(struct adreno_device *adreno_dev)
3330: {
3331: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
3332: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
3333: int ret;
3334:
3335: if (test_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags))
3336: return 0;
3337:
3338: kgsl_pwrctrl_request_state(device, KGSL_STATE_SUSPEND);
3339:
3340: ret = adreno_drain_and_idle(device);
3341: if (ret)
3342: goto err;
3343:
3344: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags))
3345: a6xx_power_off(adreno_dev);
3346:
3347: set_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags);
3348:
3349: adreno_get_gpu_halt(adreno_dev);
3350:
3351: kgsl_pwrctrl_set_state(device, KGSL_STATE_SUSPEND);
3352:
3353: return 0;
3354: err:
3355: adreno_dispatcher_start(device);
3356: return ret;
3357: }
3358:
3359: static void a6xx_gmu_pm_resume(struct adreno_device *adreno_dev)
3360: {
3361: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
3362: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
3363:
3364: if (WARN(!test_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags),
3365: "resume invoked without a suspend\n"))
3366: return;
3367:
3368: adreno_put_gpu_halt(adreno_dev);
3369:
3370: adreno_dispatcher_start(device);
3371:
3372: clear_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags);
3373: }
3374:
3375: static void a6xx_gmu_touch_wakeup(struct adreno_device *adreno_dev)
3376: {
3377: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
3378: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
3379: int ret;
3380:
3381: /*
3382: * Do not wake up a suspended device or until the first boot sequence
3383: * has been completed.
3384: */
3385: if (test_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags) ||
3386: !test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags))
3387: return;
3388:
3389: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags))
3390: goto done;
3391:
3392: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE);
3393:
3394: ret = a6xx_gmu_boot(adreno_dev);
3395: if (ret)
3396: return;
3397:
3398: ret = a6xx_gpu_boot(adreno_dev);
3399: if (ret)
3400: return;
3401:
3402: kgsl_pwrscale_wake(device);
3403:
3404: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags);
3405:
3406: device->pwrctrl.last_stat_updated = ktime_get();
3407:
3408: kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE);
3409:
3410: done:
3411: /*
3412: * When waking up from a touch event we want to stay active long enough
3413: * for the user to send a draw command. The default idle timer timeout
3414: * is shorter than we want so go ahead and push the idle timer out
3415: * further for this special case
3416: */
3417: mod_timer(&device->idle_timer, jiffies +
3418: msecs_to_jiffies(adreno_wake_timeout));
3419:
3420: }
3421:
3422: const struct adreno_power_ops a6xx_gmu_power_ops = {
3423: .first_open = a6xx_gmu_first_open,
3424: .last_close = a6xx_gmu_last_close,
3425: .active_count_get = a6xx_gmu_active_count_get,
3426: .pm_suspend = a6xx_gmu_pm_suspend,
3427: .pm_resume = a6xx_gmu_pm_resume,
3428: .touch_wakeup = a6xx_gmu_touch_wakeup,
3429: .gpu_clock_set = a6xx_gmu_clock_set,
3430: .gpu_bus_set = a6xx_gmu_bus_set,
3431: };
3432:
3433: const struct adreno_power_ops a630_gmu_power_ops = {
3434: .first_open = a6xx_gmu_first_open,
3435: .last_close = a6xx_gmu_last_close,
3436: .active_count_get = a6xx_gmu_active_count_get,
3437: .pm_suspend = a6xx_gmu_pm_suspend,
3438: .pm_resume = a6xx_gmu_pm_resume,
3439: .touch_wakeup = a6xx_gmu_touch_wakeup,
3440: .gpu_clock_set = a6xx_gmu_clock_set,
3441: };
3442:
3443: int a6xx_gmu_device_probe(struct platform_device *pdev,
3444: u32 chipid, const struct adreno_gpu_core *gpucore)
3445: {
3446: struct adreno_device *adreno_dev;
3447: struct kgsl_device *device;
3448: struct a6xx_device *a6xx_dev;
3449: int ret;
3450:
3451: a6xx_dev = devm_kzalloc(&pdev->dev, sizeof(*a6xx_dev),
3452: GFP_KERNEL);
3453: if (!a6xx_dev)
3454: return -ENOMEM;
3455:
3456: adreno_dev = &a6xx_dev->adreno_dev;
3457:
3458: adreno_dev->irq_mask = A6XX_INT_MASK;
3459:
3460: ret = a6xx_probe_common(pdev, adreno_dev, chipid, gpucore);
3461: if (ret)
3462: return ret;
3463:
3464: ret = adreno_dispatcher_init(adreno_dev);
3465: if (ret)
3466: return ret;
3467:
3468: device = KGSL_DEVICE(adreno_dev);
3469:
3470: INIT_WORK(&device->idle_check_ws, gmu_idle_check);
3471:
3472: timer_setup(&device->idle_timer, gmu_idle_timer, 0);
3473:
3474: return 0;
3475: }
3476:
3477: int a6xx_gmu_reset(struct adreno_device *adreno_dev)
3478: {
3479: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
3480:
3481: a6xx_disable_gpu_irq(adreno_dev);
3482:
3483: a6xx_gmu_irq_disable(adreno_dev);
3484:
3485: a6xx_hfi_stop(adreno_dev);
3486:
3487: /* Hard reset the gmu and gpu */
3488: a6xx_gmu_suspend(adreno_dev, true);
3489:
3490: a6xx_reset_preempt_records(adreno_dev);
3491:
3492: adreno_llcc_slice_deactivate(adreno_dev);
3493:
3494: clear_bit(GMU_PRIV_GPU_STARTED, &gmu->flags);
3495:
3496: /* Attempt to reboot the gmu and gpu */
3497: return a6xx_boot(adreno_dev);
3498: }
3499:
3500: int a6xx_gmu_hfi_probe(struct adreno_device *adreno_dev)
3501: {
3502: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
3503: struct a6xx_hfi *hfi = &gmu->hfi;
3504: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
3505:
3506: /* Try with "hfi" irq first. Use Fallback legacy name "kgsl_hfi_irq" if not found. */
3507: hfi->irq = kgsl_request_irq(GMU_PDEV(device), "hfi", "kgsl_hfi_irq", -EINVAL,
3508: a6xx_hfi_irq_handler, KGSL_DEVICE(adreno_dev));
3509:
3510: return hfi->irq < 0 ? hfi->irq : 0;
3511: }
3512:
3513: int a6xx_gmu_add_to_minidump(struct adreno_device *adreno_dev)
3514: {
3515: struct a6xx_device *a6xx_dev = container_of(adreno_dev,
3516: struct a6xx_device, adreno_dev);
3517: int ret;
3518:
3519: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, KGSL_A6XX_DEVICE,
3520: (void *)(a6xx_dev), sizeof(struct a6xx_device));
3521: if (ret)
3522: return ret;
3523:
3524: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, KGSL_GMU_LOG_ENTRY,
3525: a6xx_dev->gmu.gmu_log->hostptr, a6xx_dev->gmu.gmu_log->size);
3526: if (ret)
3527: return ret;
3528:
3529: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, KGSL_HFIMEM_ENTRY,
3530: a6xx_dev->gmu.hfi.hfi_mem->hostptr, a6xx_dev->gmu.hfi.hfi_mem->size);
3531: if (ret)
3532: return ret;
3533:
3534: if (adreno_is_a630(adreno_dev) || adreno_is_a615_family(adreno_dev))
3535: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, KGSL_GMU_DUMPMEM_ENTRY,
3536: a6xx_dev->gmu.dump_mem->hostptr, a6xx_dev->gmu.dump_mem->size);
3537:
3538: return ret;
3539: }
3540:
3541: static int a6xx_gmu_bind(struct device *dev, struct device *master, void *data)
3542: {
3543: struct kgsl_device *device = dev_get_drvdata(master);
3544: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
3545: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
3546: const struct a6xx_gpudev *a6xx_gpudev = to_a6xx_gpudev(gpudev);
3547: int ret;
3548:
3549: ret = a6xx_gmu_probe(device, to_platform_device(dev));
3550: if (ret)
3551: return ret;
3552:
3553: if (a6xx_gpudev->hfi_probe) {
3554: ret = a6xx_gpudev->hfi_probe(adreno_dev);
3555:
3556: if (ret) {
3557: a6xx_gmu_remove(device);
3558: return ret;
3559: }
3560: }
3561:
3562: return 0;
3563: }
3564:
3565: static void a6xx_gmu_unbind(struct device *dev, struct device *master,
3566: void *data)
3567: {
3568: struct kgsl_device *device = dev_get_drvdata(master);
3569: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
3570: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
3571: const struct a6xx_gpudev *a6xx_gpudev = to_a6xx_gpudev(gpudev);
3572:
3573: if (a6xx_gpudev->hfi_remove)
3574: a6xx_gpudev->hfi_remove(adreno_dev);
3575:
3576: a6xx_gmu_remove(device);
3577: }
3578:
3579: static const struct component_ops a6xx_gmu_component_ops = {
3580: .bind = a6xx_gmu_bind,
3581: .unbind = a6xx_gmu_unbind,
3582: };
3583:
3584: static int a6xx_gmu_probe_dev(struct platform_device *pdev)
3585: {
3586: /*
3587: * Let us say there are two devices. One with "qcom,adreno-gmu" compatible
3588: * and one with "qcom,gpu-gmu" compatible. In this case probe only the
3589: * device with legacy compatible string and return error for the device
3590: * with "qcom,adreno-gmu".
3591: */
3592: if (of_device_is_compatible(pdev->dev.of_node, "qcom,adreno-gmu") &&
3593: kgsl_is_compatible_node_available("qcom,gpu-gmu"))
3594: return -ENODEV;
3595:
3596: return component_add(&pdev->dev, &a6xx_gmu_component_ops);
3597: }
3598:
3599: #if (KERNEL_VERSION(6, 10, 0) <= LINUX_VERSION_CODE)
3600: static void a6xx_gmu_remove_dev(struct platform_device *pdev)
3601: {
3602: component_del(&pdev->dev, &a6xx_gmu_component_ops);
3603: }
3604: #else
3605: static int a6xx_gmu_remove_dev(struct platform_device *pdev)
3606: {
3607: component_del(&pdev->dev, &a6xx_gmu_component_ops);
3608: return 0;
3609: }
3610: #endif
3611:
3612: static const struct of_device_id a6xx_gmu_match_table[] = {
3613: { .compatible = "qcom,gpu-gmu" },
3614: { .compatible = "qcom,adreno-gmu" },
3615: { },
3616: };
3617:
3618: struct platform_driver a6xx_gmu_driver = {
3619: .probe = a6xx_gmu_probe_dev,
3620: .remove = a6xx_gmu_remove_dev,
3621: .driver = {
3622: .name = "adreno-a6xx-gmu",
3623: .of_match_table = a6xx_gmu_match_table,
3624: },
3625: };
--- FILE: \adreno_a6xx_gmu.h | HITS: 78 ---
MATCH LINES: 6, 7, 12, 16, 26, 31
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: #ifndef __ADRENO_A6XX_GMU_H
7: #define __ADRENO_A6XX_GMU_H
8:
9: #include <linux/mailbox_client.h>
10: #include <linux/soc/qcom/qcom_aoss.h>
11:
12: #include "adreno_a6xx_hfi.h"
13: #include "kgsl_gmu_core.h"
14:
15: /**
16: * struct a6xx_gmu_device - GMU device structure
17: * @irq: GMU interrupt number
18: * @fw_image: GMU FW image
19: * @dump_mem: pointer to GMU debug dump memory
20: * @gmu_log: gmu event log memory
21: * @hfi: HFI controller
22: * @idle_level: Minimal GPU idle power level
23: * @mailbox: Messages to AOP for ACD enable/disable go through this
24: * @log_wptr_retention: Store the log wptr offset on slumber
25: */
26: struct a6xx_gmu_device {
27: int irq;
28: const struct firmware *fw_image;
29: struct kgsl_memdesc *dump_mem;
30: struct kgsl_memdesc *gmu_log;
31: struct a6xx_hfi hfi;
32: unsigned int idle_level;
33: /** @qmp: Pointer to qmp struct used for AOP messages*/
34: struct qmp *qmp;
35: struct kgsl_mailbox mailbox;
36: bool preallocations;
37: unsigned int log_wptr_retention;
38: /** @cm3_fault: whether gmu received a cm3 fault interrupt */
39: atomic_t cm3_fault;
40: /**
41: * @itcm_shadow: Copy of the itcm block in firmware binary used for
42: * snapshot
43: */
44: void *itcm_shadow;
45: /** @flags: Internal gmu flags */
46: unsigned long flags;
47: /** @rscc_virt: Pointer where RSCC block is mapped */
48: void __iomem *rscc_virt;
49: /** @log_stream_enable: GMU log streaming enable. Disabled by default */
50: bool log_stream_enable;
51: /** @log_group_mask: Allows overriding default GMU log group mask */
52: u32 log_group_mask;
53: struct kobject log_kobj;
54: /** @num_oob_perfcntr: Number of active oob_perfcntr requests */
55: u32 num_oob_perfcntr;
MATCH LINES: 71, 74, 77, 84, 87, 93, 96, 103, 107, 114, 118, 123, 126, 129, 132, 135, 138, 145, 149, 157, 161, 166, 169, 176, 179, 185, 188, 191, 194, 201, 204, 209, 212, 217, 220, 225, 228, 233, 236, 239, 242, 245, 248, 251, 254, 261, 264, 272, 275, 282, 285, 292, 295, 300, 303, 308, 311, 316, 319, 327, 330, 335, 338, 341, 344, 347, 350, 353, 356, 361, 365, 368
59: void __iomem *pdc_seq_base;
60: /** @stats_enable: GMU stats feature enable */
61: bool stats_enable;
62: /** @stats_mask: GMU performance countables to enable */
63: u32 stats_mask;
64: /** @stats_interval: GMU performance counters sampling interval */
65: u32 stats_interval;
66: /** @stats_kobj: kernel object for GMU stats directory in sysfs */
67: struct kobject stats_kobj;
68: };
69:
70: /* Helper function to get to a6xx gmu device from adreno device */
71: struct a6xx_gmu_device *to_a6xx_gmu(struct adreno_device *adreno_dev);
72:
73: /* Helper function to get to adreno device from a6xx gmu device */
74: struct adreno_device *a6xx_gmu_to_adreno(struct a6xx_gmu_device *gmu);
75:
76: /**
77: * a6xx_build_rpmh_tables - Build the rpmh tables
78: * @adreno_dev: Pointer to the adreno device
79: *
80: * This function creates the gpu dcvs and bw tables
81: *
82: * Return: 0 on success and negative error on failure
83: */
84: int a6xx_build_rpmh_tables(struct adreno_device *adreno_dev);
85:
86: /**
87: * a6xx_gmu_gx_is_on - Check if GX is on
88: * @adreno_dev: Pointer to the adreno device
89: *
90: * This function reads pwr status registers to check if GX
91: * is on or off
92: */
93: bool a6xx_gmu_gx_is_on(struct adreno_device *adreno_dev);
94:
95: /**
96: * a6xx_gmu_device_snapshot - A6XX GMU snapshot function
97: * @device: Device being snapshotted
98: * @snapshot: Pointer to the snapshot instance
99: *
100: * This is where all of the A6XX GMU specific bits and pieces are grabbed
101: * into the snapshot memory
102: */
103: void a6xx_gmu_device_snapshot(struct kgsl_device *device,
104: struct kgsl_snapshot *snapshot);
105:
106: /**
107: * a6xx_gmu_device_probe - A6XX GMU snapshot function
108: * @pdev: Pointer to the platform device
109: * @chipid: Chipid of the target
110: * @gpucore: Pointer to the gpucore
111: *
112: * The target specific probe function for gmu based a6xx targets.
113: */
114: int a6xx_gmu_device_probe(struct platform_device *pdev,
115: u32 chipid, const struct adreno_gpu_core *gpucore);
116:
117: /**
118: * a6xx_gmu_reset - Reset and restart the gmu
119: * @adreno_dev: Pointer to the adreno device
120: *
121: * Return: 0 on success or negative error on failure
122: */
123: int a6xx_gmu_reset(struct adreno_device *adreno_dev);
124:
125: /**
126: * a6xx_enable_gpu_irq - Enable gpu interrupt
127: * @adreno_dev: Pointer to the adreno device
128: */
129: void a6xx_enable_gpu_irq(struct adreno_device *adreno_dev);
130:
131: /**
132: * a6xx_disable_gpu_irq - Disable gpu interrupt
133: * @adreno_dev: Pointer to the adreno device
134: */
135: void a6xx_disable_gpu_irq(struct adreno_device *adreno_dev);
136:
137: /**
138: * a6xx_gmu_snapshot- Take snapshot for gmu targets
139: * @adreno_dev: Pointer to the adreno device
140: * @snapshot: Pointer to the snapshot structure
141: *
142: * Send an NMI to gmu if we hit a gmu fault. Then take gmu
143: * snapshot and carry on with rest of the a6xx snapshot
144: */
145: void a6xx_gmu_snapshot(struct adreno_device *adreno_dev,
146: struct kgsl_snapshot *snapshot);
147:
148: /**
149: * a6xx_gmu_probe - Probe a6xx gmu resources
150: * @device: Pointer to the kgsl device
151: * @pdev: Pointer to the gmu platform device
152: *
153: * Probe the gmu and hfi resources
154: *
155: * Return: 0 on success or negative error on failure
156: */
157: int a6xx_gmu_probe(struct kgsl_device *device,
158: struct platform_device *pdev);
159:
160: /**
161: * a6xx_gmu_parse_fw - Parse the gmu fw binary
162: * @adreno_dev: Pointer to the adreno device
163: *
164: * Return: 0 on success or negative error on failure
165: */
166: int a6xx_gmu_parse_fw(struct adreno_device *adreno_dev);
167:
168: /**
169: * a6xx_gmu_memory_init - Allocate gmu memory
170: * @adreno_dev: Pointer to the adreno device
171: *
172: * Allocates the gmu log buffer and others if ndeeded.
173: *
174: * Return: 0 on success or negative error on failure
175: */
176: int a6xx_gmu_memory_init(struct adreno_device *adreno_dev);
177:
178: /**
179: * a6xx_gmu_aop_send_acd_state - Enable or disable acd feature in aop
180: * @gmu: Pointer to the a6xx gmu device
181: * @flag: Boolean to enable or disable acd in aop
182: *
183: * This function enables or disables gpu acd feature using mailbox or qmp
184: */
185: void a6xx_gmu_aop_send_acd_state(struct a6xx_gmu_device *gmu, bool flag);
186:
187: /**
188: * a6xx_gmu_disable_gdsc - Disable gmu gdsc
189: * @adreno_dev: Pointer to the adreno device
190: */
191: void a6xx_gmu_disable_gdsc(struct adreno_device *adreno_dev);
192:
193: /**
194: * a6xx_gmu_load_fw - Load gmu firmware
195: * @adreno_dev: Pointer to the adreno device
196: *
197: * Loads the gmu firmware binary into TCMs and memory
198: *
199: * Return: 0 on success or negative error on failure
200: */
201: int a6xx_gmu_load_fw(struct adreno_device *adreno_dev);
202:
203: /**
204: * a6xx_gmu_device_start - Bring gmu out of reset
205: * @adreno_dev: Pointer to the adreno device
206: *
207: * Return: 0 on success or negative error on failure
208: */
209: int a6xx_gmu_device_start(struct adreno_device *adreno_dev);
210:
211: /**
212: * a6xx_gmu_hfi_start - Indicate hfi start to gmu
213: * @device: Pointer to the kgsl device
214: *
215: * Return: 0 on success or negative error on failure
216: */
217: int a6xx_gmu_hfi_start(struct adreno_device *adreno_dev);
218:
219: /**
220: * a6xx_gmu_itcm_shadow - Create itcm shadow copy for snapshot
221: * @adreno_dev: Pointer to the adreno device
222: *
223: * Return: 0 on success or negative error on failure
224: */
225: int a6xx_gmu_itcm_shadow(struct adreno_device *adreno_dev);
226:
227: /**
228: * a6xx_gmu_register_config - gmu register configuration
229: * @adreno_dev: Pointer to the adreno device
230: *
231: * Program gmu regsiters based on features
232: */
233: void a6xx_gmu_register_config(struct adreno_device *adreno_dev);
234:
235: /**
236: * a6xx_gmu_version_info - Get gmu firmware version
237: * @adreno_dev: Pointer to the adreno device
238: */
239: void a6xx_gmu_version_info(struct adreno_device *adreno_dev);
240:
241: /**
242: * a6xx_gmu_irq_enable - Enable gmu interrupts
243: * @adreno_dev: Pointer to the adreno device
244: */
245: void a6xx_gmu_irq_enable(struct adreno_device *adreno_dev);
246:
247: /**
248: * a6xx_gmu_irq_disable - Disaable gmu interrupts
249: * @adreno_dev: Pointer to the adreno device
250: */
251: void a6xx_gmu_irq_disable(struct adreno_device *adreno_dev);
252:
253: /**
254: * a6xx_gmu_suspend - Hard reset the gpu and gmu
255: * @adreno_dev: Pointer to the adreno device
256: * @force: Set to true to enforce a hard reset
257: *
258: * In case we hit a gmu fault, hard reset the gpu and gmu
259: * to recover from the fault
260: */
261: void a6xx_gmu_suspend(struct adreno_device *adreno_dev, bool force);
262:
263: /**
264: * a6xx_gmu_oob_set - send gmu oob request
265: * @device: Pointer to the kgsl device
266: * @req: Type of oob request as defined in enum oob_request
267: *
268: * Request gmu to keep gpu powered up till the oob is cleared
269: *
270: * Return: 0 on success or negative error on failure
271: */
272: int a6xx_gmu_oob_set(struct kgsl_device *device, enum oob_request oob);
273:
274: /**
275: * a6xx_gmu_oob_clear - clear an asserted oob request
276: * @device: Pointer to the kgsl device
277: * @req: Type of oob request as defined in enum oob_request
278: *
279: * Clear a previously requested oob so that gmu can power
280: * collapse the gpu
281: */
282: void a6xx_gmu_oob_clear(struct kgsl_device *device, enum oob_request oob);
283:
284: /**
285: * a6xx_gmu_wait_for_lowest_idle - wait for gmu to complete ifpc
286: * @adreno_dev: Pointer to the adreno device
287: *
288: * If ifpc is enabled, wait for gmu to put gpu into ifpc.
289: *
290: * Return: 0 on success or negative error on failure
291: */
292: int a6xx_gmu_wait_for_lowest_idle(struct adreno_device *adreno_dev);
293:
294: /**
295: * a6xx_gmu_wait_for_idle - Wait for gmu to become idle
296: * @adreno_dev: Pointer to the adreno device
297: *
298: * Return: 0 on success or negative error on failure
299: */
300: int a6xx_gmu_wait_for_idle(struct adreno_device *adreno_dev);
301:
302: /**
303: * a6xx_rscc_sleep_sequence - Trigger rscc sleep sequence
304: * @adreno_dev: Pointer to the adreno device
305: *
306: * Return: 0 on success or negative error on failure
307: */
308: int a6xx_rscc_sleep_sequence(struct adreno_device *adreno_dev);
309:
310: /**
311: * a6xx_rscc_wakeup_sequence - Trigger rscc wakeup sequence
312: * @adreno_dev: Pointer to the adreno device
313: *
314: * Return: 0 on success or negative error on failure
315: */
316: int a6xx_rscc_wakeup_sequence(struct adreno_device *adreno_dev);
317:
318: /**
319: * a6xx_halt_gbif - Halt CX and GX requests in GBIF
320: * @adreno_dev: Pointer to the adreno device
321: *
322: * Clear any pending GX or CX transactions in GBIF and
323: * deassert GBIF halt
324: *
325: * Return: 0 on success or negative error on failure
326: */
327: int a6xx_halt_gbif(struct adreno_device *adreno_dev);
328:
329: /**
330: * a6xx_load_pdc_ucode - Load and enable pdc sequence
331: * @adreno_dev: Pointer to the adreno device
332: *
333: * Return: 0 on success or negative error on failure
334: */
335: int a6xx_load_pdc_ucode(struct adreno_device *adreno_dev);
336:
337: /**
338: * a6xx_load_rsc_ucode - Load rscc sequence
339: * @adreno_dev: Pointer to the adreno device
340: */
341: void a6xx_load_rsc_ucode(struct adreno_device *adreno_dev);
342:
343: /**
344: * a6xx_gmu_remove - Clean up gmu probed resources
345: * @device: Pointer to the kgsl device
346: */
347: void a6xx_gmu_remove(struct kgsl_device *device);
348:
349: /**
350: * a6xx_gmu_handle_watchdog - Handle watchdog interrupt
351: * @adreno_dev: Pointer to the adreno device
352: */
353: void a6xx_gmu_handle_watchdog(struct adreno_device *adreno_dev);
354:
355: /**
356: * a6xx_gmu_send_nmi - Send NMI to GMU
357: * @device: Pointer to the kgsl device
358: * @gf_policy: GMU fault panic setting policy
359: * @force: Boolean to forcefully send NMI irrespective of GMU state
360: */
361: void a6xx_gmu_send_nmi(struct kgsl_device *device, bool force,
362: enum gmu_fault_panic_policy gf_policy);
363:
364: /**
365: * a6xx_gmu_add_to_minidump - Register a6xx_device with va minidump
366: * @adreno_dev: Pointer to the adreno device
367: */
368: int a6xx_gmu_add_to_minidump(struct adreno_device *adreno_dev);
369:
370: #endif
--- FILE: \adreno_a6xx_gmu_snapshot.c | HITS: 34 ---
MATCH LINES: 7, 10, 15, 24, 31, 57
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 "a6xx_reg.h"
8: #include "adreno.h"
9: #include "adreno_a6xx.h"
10: #include "adreno_a6xx_gmu.h"
11: #include "adreno_snapshot.h"
12: #include "kgsl_device.h"
13: #include "kgsl_gmu_core.h"
14:
15: static const unsigned int a6xx_gmu_gx_registers[] = {
16: /* GMU GX */
17: 0x1A800, 0x1A800, 0x1A810, 0x1A813, 0x1A816, 0x1A816, 0x1A818, 0x1A81B,
18: 0x1A81E, 0x1A81E, 0x1A820, 0x1A823, 0x1A826, 0x1A826, 0x1A828, 0x1A82B,
19: 0x1A82E, 0x1A82E, 0x1A830, 0x1A833, 0x1A836, 0x1A836, 0x1A838, 0x1A83B,
20: 0x1A83E, 0x1A83E, 0x1A840, 0x1A843, 0x1A846, 0x1A846, 0x1A880, 0x1A884,
21: 0x1A900, 0x1A92B, 0x1A940, 0x1A940,
22: };
23:
24: static const unsigned int a6xx_gmu_tcm_registers[] = {
25: /* ITCM */
26: 0x1B400, 0x1C3FF,
27: /* DTCM */
28: 0x1C400, 0x1D3FF,
29: };
30:
31: static const unsigned int a6xx_gmu_registers[] = {
32: /* GMU CX */
33: 0x1F400, 0x1F407, 0x1F410, 0x1F412, 0x1F500, 0x1F500, 0x1F507, 0x1F50A,
34: 0x1F800, 0x1F804, 0x1F807, 0x1F808, 0x1F80B, 0x1F80C, 0x1F80F, 0x1F81C,
35: 0x1F824, 0x1F82A, 0x1F82D, 0x1F830, 0x1F840, 0x1F853, 0x1F887, 0x1F889,
36: 0x1F8A0, 0x1F8A2, 0x1F8A4, 0x1F8AF, 0x1F8C0, 0x1F8C3, 0x1F8D0, 0x1F8D0,
37: 0x1F8E4, 0x1F8E4, 0x1F8E8, 0x1F8EC, 0x1F900, 0x1F903, 0x1F940, 0x1F940,
38: 0x1F942, 0x1F944, 0x1F94C, 0x1F94D, 0x1F94F, 0x1F951, 0x1F954, 0x1F954,
39: 0x1F957, 0x1F958, 0x1F95D, 0x1F95D, 0x1F962, 0x1F962, 0x1F964, 0x1F965,
40: 0x1F980, 0x1F986, 0x1F990, 0x1F99E, 0x1F9C0, 0x1F9C0, 0x1F9C5, 0x1F9CC,
41: 0x1F9E0, 0x1F9E2, 0x1F9F0, 0x1F9F0, 0x1FA00, 0x1FA01,
42: /* GMU AO */
43: 0x23B00, 0x23B16,
44: };
45:
46: static const unsigned int a660_gmu_registers[] = {
47: /* GMU CX */
48: 0x1F408, 0x1F40D, 0x1F40F, 0x1F40F, 0x1F50B, 0x1F50B, 0x1F860, 0x1F860,
49: 0x1F870, 0x1F877, 0x1F8C4, 0x1F8C4, 0x1F8F0, 0x1F8F1, 0x1F948, 0x1F94A,
50: 0x1F966, 0x1F96B, 0x1F970, 0x1F970, 0x1F972, 0x1F979, 0x1F9CD, 0x1F9D4,
51: 0x1FA02, 0x1FA03, 0x20000, 0x20001, 0x20004, 0x20004, 0x20008, 0x20012,
52: 0x20018, 0x20018,
53: /* GMU AO LPAC */
54: 0x23B30, 0x23B30,
55: };
56:
57: static const unsigned int a6xx_gmu_gpucc_registers[] = {
58: /* GPU CC */
59: 0x24000, 0x24012, 0x24040, 0x24052, 0x24400, 0x24404, 0x24407, 0x2440B,
60: 0x24415, 0x2441C, 0x2441E, 0x2442D, 0x2443C, 0x2443D, 0x2443F, 0x24440,
61: 0x24442, 0x24449, 0x24458, 0x2445A, 0x24540, 0x2455E, 0x24800, 0x24802,
62: 0x24C00, 0x24C02, 0x25400, 0x25402, 0x25800, 0x25802, 0x25C00, 0x25C02,
63: 0x26000, 0x26002,
64: /* GPU CC ACD */
65: 0x26400, 0x26416, 0x26420, 0x26427,
66: };
67:
68: static const unsigned int a662_gmu_gpucc_registers[] = {
69: /* GPU CC */
70: 0x24000, 0x2400e, 0x24400, 0x2440e, 0x24800, 0x24805, 0x24c00, 0x24cff,
71: 0x25800, 0x25804, 0x25c00, 0x25c04, 0x26000, 0x26004, 0x26400, 0x26405,
72: 0x26414, 0x2641d, 0x2642a, 0x26430, 0x26432, 0x26432, 0x26441, 0x26455,
73: 0x26466, 0x26468, 0x26478, 0x2647a, 0x26489, 0x2648a, 0x2649c, 0x2649e,
74: 0x264a0, 0x264a3, 0x264b3, 0x264b5, 0x264c5, 0x264c7, 0x264d6, 0x264d8,
75: 0x264e8, 0x264e9, 0x264f9, 0x264fc, 0x2650b, 0x2650c, 0x2651c, 0x2651e,
76: 0x26540, 0x26570, 0x26600, 0x26616, 0x26620, 0x2662d,
77: };
78:
79: static const unsigned int a663_gmu_gpucc_registers[] = {
80: /* GPU CC */
81: 0x24000, 0x2400e, 0x24400, 0x2440e, 0x25800, 0x25804, 0x25c00, 0x25c04,
MATCH LINES: 99
87: 0x26620, 0x2662d,
88: };
89:
90: static const unsigned int a630_rscc_snapshot_registers[] = {
91: 0x23400, 0x23434, 0x23436, 0x23436, 0x23480, 0x23484, 0x23489, 0x2348C,
92: 0x23491, 0x23494, 0x23499, 0x2349C, 0x234A1, 0x234A4, 0x234A9, 0x234AC,
93: 0x23500, 0x23502, 0x23504, 0x23507, 0x23514, 0x23519, 0x23524, 0x2352B,
94: 0x23580, 0x23597, 0x23740, 0x23741, 0x23744, 0x23747, 0x2374C, 0x23787,
95: 0x237EC, 0x237EF, 0x237F4, 0x2382F, 0x23894, 0x23897, 0x2389C, 0x238D7,
96: 0x2393C, 0x2393F, 0x23944, 0x2397F,
97: };
98:
99: static const unsigned int a6xx_rscc_snapshot_registers[] = {
100: 0x23400, 0x23434, 0x23436, 0x23436, 0x23440, 0x23440, 0x23480, 0x23484,
101: 0x23489, 0x2348C, 0x23491, 0x23494, 0x23499, 0x2349C, 0x234A1, 0x234A4,
102: 0x234A9, 0x234AC, 0x23500, 0x23502, 0x23504, 0x23507, 0x23514, 0x23519,
103: 0x23524, 0x2352B, 0x23580, 0x23597, 0x23740, 0x23741, 0x23744, 0x23747,
104: 0x2374C, 0x23787, 0x237EC, 0x237EF, 0x237F4, 0x2382F, 0x23894, 0x23897,
105: 0x2389C, 0x238D7, 0x2393C, 0x2393F, 0x23944, 0x2397F,
106: };
107:
108: static const unsigned int a650_rscc_registers[] = {
109: 0x38000, 0x38034, 0x38036, 0x38036, 0x38040, 0x38042, 0x38080, 0x38084,
110: 0x38089, 0x3808C, 0x38091, 0x38094, 0x38099, 0x3809C, 0x380A1, 0x380A4,
111: 0x380A9, 0x380AC, 0x38100, 0x38102, 0x38104, 0x38107, 0x38114, 0x38119,
112: 0x38124, 0x3812E, 0x38180, 0x38197, 0x38340, 0x38341, 0x38344, 0x38347,
113: 0x3834C, 0x3834F, 0x38351, 0x38354, 0x38356, 0x38359, 0x3835B, 0x3835E,
114: 0x38360, 0x38363, 0x38365, 0x38368, 0x3836A, 0x3836D, 0x3836F, 0x38372,
115: 0x383EC, 0x383EF, 0x383F4, 0x383F7, 0x383F9, 0x383FC, 0x383FE, 0x38401,
116: 0x38403, 0x38406, 0x38408, 0x3840B, 0x3840D, 0x38410, 0x38412, 0x38415,
117: 0x38417, 0x3841A, 0x38494, 0x38497, 0x3849C, 0x3849F, 0x384A1, 0x384A4,
118: 0x384A6, 0x384A9, 0x384AB, 0x384AE, 0x384B0, 0x384B3, 0x384B5, 0x384B8,
119: 0x384BA, 0x384BD, 0x384BF, 0x384C2, 0x3853C, 0x3853F, 0x38544, 0x38547,
120: 0x38549, 0x3854C, 0x3854E, 0x38551, 0x38553, 0x38556, 0x38558, 0x3855B,
121: 0x3855D, 0x38560, 0x38562, 0x38565, 0x38567, 0x3856A, 0x385E4, 0x385E7,
122: 0x385EC, 0x385EF, 0x385F1, 0x385F4, 0x385F6, 0x385F9, 0x385FB, 0x385FE,
123: 0x38600, 0x38603, 0x38605, 0x38608, 0x3860A, 0x3860D, 0x3860F, 0x38612,
MATCH LINES: 158, 179, 184, 191, 213, 214, 249, 257
146: 0x38EA7, 0x38EA7, 0x38EAC, 0x38EAC, 0x38EB1, 0x38EB1, 0x38EB6, 0x38EB6,
147: 0x38EBB, 0x38EBB, 0x38F40, 0x38F40, 0x38F45, 0x38F45, 0x38F4A, 0x38F4A,
148: 0x38F4F, 0x38F4F, 0x38F54, 0x38F54, 0x38F59, 0x38F59, 0x38F5E, 0x38F5E,
149: 0x38F63, 0x38F63, 0x38FE8, 0x38FE8, 0x38FED, 0x38FED, 0x38FF2, 0x38FF2,
150: 0x38FF7, 0x38FF7, 0x38FFC, 0x38FFC, 0x39001, 0x39001, 0x39006, 0x39006,
151: 0x3900B, 0x3900B, 0x39090, 0x39090, 0x39095, 0x39095, 0x3909A, 0x3909A,
152: 0x3909F, 0x3909F, 0x390A4, 0x390A4, 0x390A9, 0x390A9, 0x390AE, 0x390AE,
153: 0x390B3, 0x390B3, 0x39138, 0x39138, 0x3913D, 0x3913D, 0x39142, 0x39142,
154: 0x39147, 0x39147, 0x3914C, 0x3914C, 0x39151, 0x39151, 0x39156, 0x39156,
155: 0x3915B, 0x3915B,
156: };
157:
158: static size_t a6xx_gmu_snapshot_dtcm(struct kgsl_device *device,
159: u8 *buf, size_t remain, void *priv)
160: {
161: struct gmu_core_device *gmu_core = &device->gmu_core;
162: struct kgsl_snapshot_gmu_mem *mem_hdr =
163: (struct kgsl_snapshot_gmu_mem *)buf;
164: u32 *data = (u32 *)(buf + sizeof(*mem_hdr));
165: u32 i;
166:
167: if (remain < gmu_core->vma[GMU_DTCM].size + sizeof(*mem_hdr)) {
168: SNAPSHOT_ERR_NOMEM(device, "GMU DTCM Memory");
169: return 0;
170: }
171:
172: mem_hdr->type = SNAPSHOT_GMU_MEM_BIN_BLOCK;
173: mem_hdr->hostaddr = 0;
174: mem_hdr->gmuaddr = gmu_core->vma[GMU_DTCM].start;
175: mem_hdr->gpuaddr = 0;
176:
177: /* FIXME: use a bulk read? */
178: for (i = 0; i < (gmu_core->vma[GMU_DTCM].size >> 2); i++)
179: gmu_core_regread(device, A6XX_GMU_CM3_DTCM_START + i, data++);
180:
181: return gmu_core->vma[GMU_DTCM].size + sizeof(*mem_hdr);
182: }
183:
184: static size_t a6xx_gmu_snapshot_itcm(struct kgsl_device *device,
185: u8 *buf, size_t remain, void *priv)
186: {
187: struct gmu_core_device *gmu_core = &device->gmu_core;
188: struct kgsl_snapshot_gmu_mem *mem_hdr =
189: (struct kgsl_snapshot_gmu_mem *)buf;
190: void *dest = buf + sizeof(*mem_hdr);
191: struct a6xx_gmu_device *gmu = (struct a6xx_gmu_device *)priv;
192:
193: if (!gmu->itcm_shadow) {
194: dev_err(GMU_PDEV_DEV(device), "ITCM not captured\n");
195: return 0;
196: }
197:
198: if (remain < gmu_core->vma[GMU_ITCM].size + sizeof(*mem_hdr)) {
199: SNAPSHOT_ERR_NOMEM(device, "GMU ITCM Memory");
200: return 0;
201: }
202:
203: mem_hdr->type = SNAPSHOT_GMU_MEM_BIN_BLOCK;
204: mem_hdr->hostaddr = 0;
205: mem_hdr->gmuaddr = gmu_core->vma[GMU_ITCM].start;
206: mem_hdr->gpuaddr = 0;
207:
208: memcpy(dest, gmu->itcm_shadow, gmu_core->vma[GMU_ITCM].size);
209:
210: return gmu_core->vma[GMU_ITCM].size + sizeof(*mem_hdr);
211: }
212:
213: static void a6xx_gmu_snapshot_memories(struct kgsl_device *device,
214: struct a6xx_gmu_device *gmu, struct kgsl_snapshot *snapshot)
215: {
216: struct gmu_mem_type_desc desc;
217: struct kgsl_memdesc *md;
218: struct gmu_core_device *gmu_core = &device->gmu_core;
219: int i;
220:
221: for (i = 0; i < ARRAY_SIZE(gmu_core->gmu_globals); i++) {
222:
223: md = &gmu_core->gmu_globals[i];
224: if (!md->size)
225: continue;
226:
227: desc.memdesc = md;
228: if (md == gmu->hfi.hfi_mem)
229: desc.type = SNAPSHOT_GMU_MEM_HFI;
230: else if (md == gmu->gmu_log)
231: desc.type = SNAPSHOT_GMU_MEM_LOG;
232: else if (md == gmu->dump_mem)
233: desc.type = SNAPSHOT_GMU_MEM_DEBUG;
234: else if (md == gmu_core->vrb)
235: desc.type = SNAPSHOT_GMU_MEM_VRB;
236: else if (md == gmu_core->trace.md)
237: desc.type = SNAPSHOT_GMU_MEM_TRACE;
238: else
239: desc.type = SNAPSHOT_GMU_MEM_BIN_BLOCK;
240:
241: kgsl_snapshot_add_section(device,
242: KGSL_SNAPSHOT_SECTION_GMU_MEMORY,
243: snapshot, adreno_snapshot_gmu_mem, &desc);
244: }
245: }
246:
247: #define RSCC_OFFSET_DWORDS 0x38000
248:
249: static size_t a6xx_snapshot_rscc_registers(struct kgsl_device *device, u8 *buf,
250: size_t remain, void *priv)
251: {
252: struct kgsl_snapshot_regs *header = (struct kgsl_snapshot_regs *)buf;
253: struct kgsl_snapshot_registers *regs = priv;
254: unsigned int *data = (unsigned int *)(buf + sizeof(*header));
255: int count = 0, j, k;
256: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
257: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
258:
259: /* Figure out how many registers we are going to dump */
260: for (j = 0; j < regs->count; j++) {
261: int start = regs->regs[j * 2];
262: int end = regs->regs[j * 2 + 1];
263:
264: count += (end - start + 1);
265: }
266:
267: if (remain < (count * 8) + sizeof(*header)) {
268: SNAPSHOT_ERR_NOMEM(device, "RSCC REGISTERS");
269: return 0;
270: }
271:
272: for (j = 0; j < regs->count; j++) {
273: unsigned int start = regs->regs[j * 2];
274: unsigned int end = regs->regs[j * 2 + 1];
275:
276: for (k = start; k <= end; k++) {
277: unsigned int val;
278:
279: val = __raw_readl(gmu->rscc_virt +
280: ((k - RSCC_OFFSET_DWORDS) << 2));
281: *data++ = k;
MATCH LINES: 305, 313, 314, 319, 326, 330, 333, 337, 343, 344, 346, 347, 360, 361, 370, 374, 379, 380, 391
293: struct kgsl_snapshot *snapshot)
294: {
295: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
296:
297: /* RSCC registers are on cx */
298: if (adreno_is_a650_family(adreno_dev)) {
299: struct kgsl_snapshot_registers r;
300:
301: r.regs = a650_rscc_registers;
302: r.count = ARRAY_SIZE(a650_rscc_registers) / 2;
303:
304: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS,
305: snapshot, a6xx_snapshot_rscc_registers, &r);
306: } else if (adreno_is_a615_family(adreno_dev) ||
307: adreno_is_a630(adreno_dev)) {
308: adreno_snapshot_registers(device, snapshot,
309: a630_rscc_snapshot_registers,
310: ARRAY_SIZE(a630_rscc_snapshot_registers) / 2);
311: } else if (adreno_is_a640(adreno_dev) || adreno_is_a680(adreno_dev)) {
312: adreno_snapshot_registers(device, snapshot,
313: a6xx_rscc_snapshot_registers,
314: ARRAY_SIZE(a6xx_rscc_snapshot_registers) / 2);
315: }
316: }
317:
318: /*
319: * a6xx_gmu_device_snapshot() - A6XX GMU snapshot function
320: * @device: Device being snapshotted
321: * @snapshot: Pointer to the snapshot instance
322: *
323: * This is where all of the A6XX GMU specific bits and pieces are grabbed
324: * into the snapshot memory
325: */
326: void a6xx_gmu_device_snapshot(struct kgsl_device *device,
327: struct kgsl_snapshot *snapshot)
328: {
329: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
330: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
331:
332: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_GMU_MEMORY,
333: snapshot, a6xx_gmu_snapshot_itcm, gmu);
334:
335: adreno_snapshot_gmu_versions(device, snapshot);
336:
337: a6xx_gmu_snapshot_memories(device, gmu, snapshot);
338:
339: /* Snapshot tcms as registers for legacy targets */
340: if (adreno_is_a630(adreno_dev) ||
341: adreno_is_a615_family(adreno_dev))
342: adreno_snapshot_registers(device, snapshot,
343: a6xx_gmu_tcm_registers,
344: ARRAY_SIZE(a6xx_gmu_tcm_registers) / 2);
345:
346: adreno_snapshot_registers(device, snapshot, a6xx_gmu_registers,
347: ARRAY_SIZE(a6xx_gmu_registers) / 2);
348:
349: if (adreno_is_a662(adreno_dev) || adreno_is_a621(adreno_dev) ||
350: adreno_is_a622(adreno_dev))
351: adreno_snapshot_registers(device, snapshot,
352: a662_gmu_gpucc_registers,
353: ARRAY_SIZE(a662_gmu_gpucc_registers) / 2);
354: else if (adreno_is_a663(adreno_dev) || adreno_is_a623(adreno_dev))
355: adreno_snapshot_registers(device, snapshot,
356: a663_gmu_gpucc_registers,
357: ARRAY_SIZE(a663_gmu_gpucc_registers) / 2);
358: else
359: adreno_snapshot_registers(device, snapshot,
360: a6xx_gmu_gpucc_registers,
361: ARRAY_SIZE(a6xx_gmu_gpucc_registers) / 2);
362:
363: /* Snapshot A660 specific GMU registers */
364: if (adreno_is_a660(adreno_dev))
365: adreno_snapshot_registers(device, snapshot, a660_gmu_registers,
366: ARRAY_SIZE(a660_gmu_registers) / 2);
367:
368: snapshot_rscc_registers(adreno_dev, snapshot);
369:
370: if (!a6xx_gmu_gx_is_on(adreno_dev))
371: goto dtcm;
372:
373: /* Set fence to ALLOW mode so registers can be read */
374: kgsl_regwrite(device, A6XX_GMU_AO_AHB_FENCE_CTRL, 0);
375: /* Make sure the previous write posted before reading */
376: wmb();
377:
378: adreno_snapshot_registers(device, snapshot,
379: a6xx_gmu_gx_registers,
380: ARRAY_SIZE(a6xx_gmu_gx_registers) / 2);
381:
382: /* A stalled SMMU can lead to NoC timeouts when host accesses DTCM */
383: if (adreno_smmu_is_stalled(adreno_dev)) {
384: dev_err(GMU_PDEV_DEV(device),
385: "Not dumping dtcm because SMMU is stalled\n");
386: return;
387: }
388:
389: dtcm:
390: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_GMU_MEMORY,
391: snapshot, a6xx_gmu_snapshot_dtcm, gmu);
392: }
--- FILE: \adreno_a6xx_hfi.c | HITS: 93 ---
MATCH LINES: 12, 23, 25, 31, 34
1: // SPDX-License-Identifier: GPL-2.0-only
2: /*
3: * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
5: */
6:
7: #include <linux/delay.h>
8: #include <linux/nvmem-consumer.h>
9:
10: #include "adreno.h"
11: #include "adreno_a6xx.h"
12: #include "adreno_a6xx_hfi.h"
13: #include "kgsl_device.h"
14: #include "kgsl_trace.h"
15:
16: /* Below section is for all structures related to HFI queues */
17: #define HFI_QUEUE_MAX HFI_QUEUE_DEFAULT_CNT
18:
19: /* Total header sizes + queue sizes + 16 for alignment */
20: #define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
21: (HFI_QUEUE_SIZE * HFI_QUEUE_MAX))
22:
23: struct a6xx_hfi *to_a6xx_hfi(struct adreno_device *adreno_dev)
24: {
25: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
26:
27: return &gmu->hfi;
28: }
29:
30: /* Size in below functions are in unit of dwords */
31: int a6xx_hfi_queue_read(struct a6xx_gmu_device *gmu, uint32_t queue_idx,
32: unsigned int *output, unsigned int max_size)
33: {
34: struct kgsl_device *device = KGSL_DEVICE(a6xx_gmu_to_adreno(gmu));
35: struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
36: struct hfi_queue_table *tbl = mem_addr->hostptr;
37: struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];
38: uint32_t *queue;
39: uint32_t msg_hdr;
40: uint32_t i, read;
41: uint32_t size;
42: int result = 0;
43:
44: if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
45: return -EINVAL;
46:
47: if (hdr->read_index == hdr->write_index)
48: return -ENODATA;
49:
50: /* Clear the output data before populating */
51: memset(output, 0, max_size);
52:
53: queue = HOST_QUEUE_START_ADDR(mem_addr, queue_idx);
54: msg_hdr = queue[hdr->read_index];
55: size = MSG_HDR_GET_SIZE(msg_hdr);
56:
57: if (size > (max_size >> 2)) {
58: dev_err(GMU_PDEV_DEV(device),
MATCH LINES: 100, 103
88: MSG_HDR_GET_SEQNUM(output[1]));
89: else
90: trace_kgsl_hfi_receive(MSG_HDR_GET_ID(msg_hdr),
91: MSG_HDR_GET_SIZE(msg_hdr), MSG_HDR_GET_SEQNUM(msg_hdr));
92:
93: hfi_update_read_idx(hdr, read);
94:
95: done:
96: return result;
97: }
98:
99: /* Size in below functions are in unit of dwords */
100: int a6xx_hfi_queue_write(struct adreno_device *adreno_dev, uint32_t queue_idx,
101: uint32_t *msg, u32 size_bytes)
102: {
103: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
104: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
105: struct hfi_queue_table *tbl = gmu->hfi.hfi_mem->hostptr;
106: struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];
107: uint32_t *queue;
108: uint32_t i, write_idx, read_idx, empty_space;
109: uint32_t size_dwords = size_bytes >> 2;
110: u32 align_size = ALIGN(size_dwords, SZ_4);
111: uint32_t id = MSG_HDR_GET_ID(*msg);
112:
113: if (hdr->status == HFI_QUEUE_STATUS_DISABLED || !IS_ALIGNED(size_bytes, sizeof(u32)))
114: return -EINVAL;
115:
116: queue = HOST_QUEUE_START_ADDR(gmu->hfi.hfi_mem, queue_idx);
117:
118: write_idx = hdr->write_index;
119: read_idx = hdr->read_index;
120:
121: empty_space = (write_idx >= read_idx) ?
122: (hdr->queue_size - (write_idx - read_idx))
123: : (read_idx - write_idx);
124:
125: if (empty_space <= align_size)
126: return -ENOSPC;
127:
MATCH LINES: 148, 152, 163, 172
136: queue[write_idx] = 0xFAFAFAFA;
137: write_idx = (write_idx + 1) % hdr->queue_size;
138: }
139: }
140:
141: trace_kgsl_hfi_send(id, size_dwords, MSG_HDR_GET_SEQNUM(*msg));
142:
143: hfi_update_write_idx(&hdr->write_index, write_idx);
144:
145: return 0;
146: }
147:
148: int a6xx_hfi_cmdq_write(struct adreno_device *adreno_dev, u32 *msg, u32 size_bytes)
149: {
150: int ret;
151:
152: ret = a6xx_hfi_queue_write(adreno_dev, HFI_CMD_ID, msg, size_bytes);
153:
154: /*
155: * Memory barrier to make sure packet and write index are written before
156: * an interrupt is raised
157: */
158: wmb();
159:
160: /* Send interrupt to GMU to receive the message */
161: if (!ret)
162: gmu_core_regwrite(KGSL_DEVICE(adreno_dev),
163: A6XX_GMU_HOST2GMU_INTR_SET,
164: 0x1);
165:
166: return ret;
167: }
168:
169: /* Sizes of the queue and message are in unit of dwords */
170: static void init_queues(struct adreno_device *adreno_dev)
171: {
172: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
173: struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
174: int i;
175: struct hfi_queue_table *tbl;
176: struct hfi_queue_header *hdr;
177: struct {
178: unsigned int idx;
179: unsigned int pri;
180: unsigned int status;
181: } queue[HFI_QUEUE_MAX] = {
182: { HFI_CMD_IDX, HFI_CMD_PRI, HFI_QUEUE_STATUS_ENABLED },
183: { HFI_MSG_IDX, HFI_MSG_PRI, HFI_QUEUE_STATUS_ENABLED },
184: { HFI_DBG_IDX, HFI_DBG_PRI, HFI_QUEUE_STATUS_ENABLED },
185: };
186:
187: /*
188: * Overwrite the queue IDs for A630, A615 and A616 as they use
189: * legacy firmware. Legacy firmware has different queue IDs for
190: * message, debug and dispatch queues (dispatch queues aren't used
191: * on these targets so the queue idx value update is not needed).
192: */
193: if (adreno_is_a630(adreno_dev) || adreno_is_a615_family(adreno_dev)) {
194: queue[HFI_MSG_ID].idx = HFI_MSG_IDX_LEGACY;
195: queue[HFI_DBG_ID].idx = HFI_DBG_IDX_LEGACY;
196: }
MATCH LINES: 219, 221, 222, 235, 238, 262, 265, 269, 274, 278, 282, 294, 297, 302, 309, 327, 329, 342, 345, 360, 374, 385, 388, 402, 409, 423, 431, 433, 455, 458, 469, 472, 474, 488, 490, 497, 500, 503, 510, 513, 523, 526, 529, 532, 538, 548, 551, 564, 567, 576, 577, 579, 604, 611, 616, 638, 642, 647, 649, 653, 656, 665, 682, 684, 692, 697, 702, 704, 709, 720, 724, 728, 732, 737, 749, 755, 757, 766, 769, 772, 773, 776
207: memset(&tbl->qhdr[0], 0, sizeof(tbl->qhdr));
208:
209: /* Fill Individual Queue Headers */
210: for (i = 0; i < HFI_QUEUE_MAX; i++) {
211: hdr = &tbl->qhdr[i];
212: hdr->start_addr = GMU_QUEUE_START_ADDR(mem_addr->gmuaddr, i);
213: hdr->type = QUEUE_HDR_TYPE(queue[i].idx, queue[i].pri, 0, 0);
214: hdr->status = queue[i].status;
215: hdr->queue_size = HFI_QUEUE_SIZE >> 2; /* convert to dwords */
216: }
217: }
218:
219: int a6xx_hfi_init(struct adreno_device *adreno_dev)
220: {
221: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
222: struct a6xx_hfi *hfi = &gmu->hfi;
223:
224: /* Allocates & maps memory for HFI */
225: if (IS_ERR_OR_NULL(hfi->hfi_mem)) {
226: hfi->hfi_mem = gmu_core_reserve_kernel_block(KGSL_DEVICE(adreno_dev), 0,
227: HFIMEM_SIZE, GMU_NONCACHED_KERNEL, 0);
228: if (!IS_ERR(hfi->hfi_mem))
229: init_queues(adreno_dev);
230: }
231:
232: return PTR_ERR_OR_ZERO(hfi->hfi_mem);
233: }
234:
235: int a6xx_receive_ack_cmd(struct a6xx_gmu_device *gmu, void *rcvd,
236: struct pending_cmd *ret_cmd)
237: {
238: struct adreno_device *adreno_dev = a6xx_gmu_to_adreno(gmu);
239: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
240: uint32_t *ack = rcvd;
241: uint32_t hdr = ack[0];
242: uint32_t req_hdr = ack[1];
243:
244: if (ret_cmd == NULL)
245: return -EINVAL;
246:
247: if (CMP_HFI_ACK_HDR(ret_cmd->sent_hdr, req_hdr)) {
248: memcpy(&ret_cmd->results, ack, MSG_HDR_GET_SIZE(hdr) << 2);
249: return 0;
250: }
251:
252: /* Didn't find the sender, list the waiter */
253: dev_err_ratelimited(GMU_PDEV_DEV(device),
254: "HFI ACK: Cannot find sender for 0x%8.8x Waiter: 0x%8.8x\n",
255: req_hdr, ret_cmd->sent_hdr);
256:
257: gmu_core_fault_snapshot(device, GMU_FAULT_HFI_RECIVE_ACK);
258:
259: return -ENODEV;
260: }
261:
262: static int a6xx_hfi_send_cmd_wait_inline(struct adreno_device *adreno_dev,
263: void *data, u32 size_bytes, struct pending_cmd *ret_cmd)
264: {
265: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
266: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
267: int rc;
268: uint32_t *cmd = data;
269: struct a6xx_hfi *hfi = &gmu->hfi;
270: unsigned int seqnum = atomic_inc_return(&hfi->seqnum);
271:
272: *cmd = MSG_HDR_SET_SEQNUM_SIZE(*cmd, seqnum, size_bytes >> 2);
273: if (ret_cmd == NULL)
274: return a6xx_hfi_cmdq_write(adreno_dev, cmd, size_bytes);
275:
276: ret_cmd->sent_hdr = cmd[0];
277:
278: rc = a6xx_hfi_cmdq_write(adreno_dev, cmd, size_bytes);
279: if (rc)
280: return rc;
281:
282: rc = gmu_core_timed_poll_check(device, A6XX_GMU_GMU2HOST_INTR_INFO,
283: HFI_IRQ_MSGQ_MASK, HFI_RSP_TIMEOUT, HFI_IRQ_MSGQ_MASK);
284:
285: if (rc) {
286: dev_err(GMU_PDEV_DEV(device),
287: "Timed out waiting on ack for 0x%8.8x (id %d, sequence %d)\n",
288: cmd[0], MSG_HDR_GET_ID(*cmd), MSG_HDR_GET_SEQNUM(*cmd));
289: gmu_core_fault_snapshot(device, GMU_FAULT_SEND_CMD_WAIT_INLINE);
290: return rc;
291: }
292:
293: /* Clear the interrupt */
294: gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_CLR,
295: HFI_IRQ_MSGQ_MASK);
296:
297: rc = a6xx_hfi_process_queue(gmu, HFI_MSG_ID, ret_cmd);
298:
299: return rc;
300: }
301:
302: int a6xx_hfi_send_generic_req(struct adreno_device *adreno_dev, void *cmd, u32 size_bytes)
303: {
304: struct pending_cmd ret_cmd;
305: int rc;
306:
307: memset(&ret_cmd, 0, sizeof(ret_cmd));
308:
309: rc = a6xx_hfi_send_cmd_wait_inline(adreno_dev, cmd, size_bytes, &ret_cmd);
310: if (rc)
311: return rc;
312:
313: if (ret_cmd.results[2]) {
314: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
315:
316: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),
317: "HFI ACK failure: Req=0x%8.8X, Result=0x%8.8X\n",
318: ret_cmd.results[1],
319: ret_cmd.results[2]);
320: gmu_core_fault_snapshot(device, GMU_FAULT_HFI_SEND_GENERIC_REQ);
321: return -EINVAL;
322: }
323:
324: return 0;
325: }
326:
327: static int a6xx_hfi_send_gmu_init(struct adreno_device *adreno_dev)
328: {
329: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
330: struct hfi_gmu_init_cmd cmd = {
331: .seg_id = 0,
332: .dbg_buffer_addr = (unsigned int) gmu->dump_mem->gmuaddr,
333: .dbg_buffer_size = (unsigned int) gmu->dump_mem->size,
334: .boot_state = 0x1,
335: };
336: int ret;
337:
338: ret = CMD_MSG_HDR(cmd, H2F_MSG_INIT);
339: if (ret)
340: return ret;
341:
342: return a6xx_hfi_send_generic_req(adreno_dev, &cmd, sizeof(cmd));
343: }
344:
345: static int a6xx_hfi_get_fw_version(struct adreno_device *adreno_dev,
346: uint32_t expected_ver, uint32_t *ver)
347: {
348: struct hfi_fw_version_cmd cmd = {
349: .supported_ver = expected_ver,
350: };
351: int rc;
352: struct pending_cmd ret_cmd;
353:
354: rc = CMD_MSG_HDR(cmd, H2F_MSG_FW_VER);
355: if (rc)
356: return rc;
357:
358: memset(&ret_cmd, 0, sizeof(ret_cmd));
359:
360: rc = a6xx_hfi_send_cmd_wait_inline(adreno_dev, &cmd, sizeof(cmd), &ret_cmd);
361: if (rc)
362: return rc;
363:
364: rc = ret_cmd.results[2];
365: if (!rc)
366: *ver = ret_cmd.results[3];
367: else
368: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),
369: "gmu get fw ver failed with error=%d\n", rc);
370:
371: return rc;
372: }
373:
374: int a6xx_hfi_send_core_fw_start(struct adreno_device *adreno_dev)
375: {
376: struct hfi_core_fw_start_cmd cmd = {
377: .handle = 0x0,
378: };
379: int ret;
380:
381: ret = CMD_MSG_HDR(cmd, H2F_MSG_CORE_FW_START);
382: if (ret)
383: return ret;
384:
385: return a6xx_hfi_send_generic_req(adreno_dev, &cmd, sizeof(cmd));
386: }
387:
388: int a6xx_hfi_send_feature_ctrl(struct adreno_device *adreno_dev,
389: uint32_t feature, uint32_t enable, uint32_t data)
390: {
391: struct hfi_feature_ctrl_cmd cmd = {
392: .feature = feature,
393: .enable = enable,
394: .data = data,
395: };
396: int ret;
397:
398: ret = CMD_MSG_HDR(cmd, H2F_MSG_FEATURE_CTRL);
399: if (ret)
400: return ret;
401:
402: ret = a6xx_hfi_send_generic_req(adreno_dev, &cmd, sizeof(cmd));
403: if (ret)
404: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)), "Unable to %s feature %s (%d)\n",
405: enable ? "enable" : "disable", hfi_feature_to_string(feature), feature);
406: return ret;
407: }
408:
409: int a6xx_hfi_send_set_value(struct adreno_device *adreno_dev,
410: u32 type, u32 subtype, u32 data)
411: {
412: struct hfi_set_value_cmd cmd = {
413: .type = type,
414: .subtype = subtype,
415: .data = data,
416: };
417: int ret;
418:
419: ret = CMD_MSG_HDR(cmd, H2F_MSG_SET_VALUE);
420: if (ret)
421: return ret;
422:
423: ret = a6xx_hfi_send_generic_req(adreno_dev, &cmd, sizeof(cmd));
424: if (ret)
425: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),
426: "Unable to set HFI Value %d, %d to %d, error = %d\n",
427: type, subtype, data, ret);
428: return ret;
429: }
430:
431: static int a6xx_hfi_send_dcvstbl_v1(struct adreno_device *adreno_dev)
432: {
433: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
434: struct hfi_dcvstable_cmd *table = &gmu->hfi.dcvs_table;
435: struct hfi_dcvstable_v1_cmd cmd = {
436: .gpu_level_num = table->gpu_level_num,
437: .gmu_level_num = table->gmu_level_num,
438: };
439: int i, ret;
440:
441: ret = CMD_MSG_HDR(cmd, H2F_MSG_PERF_TBL);
442: if (ret)
443: return ret;
444:
445: for (i = 0; i < table->gpu_level_num; i++) {
446: cmd.gx_votes[i].vote = table->gx_votes[i].vote;
447: cmd.gx_votes[i].freq = table->gx_votes[i].freq;
448: }
449:
450: cmd.cx_votes[0].vote = table->cx_votes[0].vote;
451: cmd.cx_votes[0].freq = table->cx_votes[0].freq;
452: cmd.cx_votes[1].vote = table->cx_votes[1].vote;
453: cmd.cx_votes[1].freq = table->cx_votes[1].freq;
454:
455: return a6xx_hfi_send_generic_req(adreno_dev, &cmd, sizeof(cmd));
456: }
457:
458: static int a6xx_hfi_send_test(struct adreno_device *adreno_dev)
459: {
460: struct hfi_test_cmd cmd;
461: int ret;
462:
463: ret = CMD_MSG_HDR(cmd, H2F_MSG_TEST);
464: if (ret)
465: return ret;
466:
467: cmd.data = 0;
468:
469: return a6xx_hfi_send_generic_req(adreno_dev, &cmd, sizeof(cmd));
470: }
471:
472: void adreno_a6xx_receive_err_req(struct a6xx_gmu_device *gmu, void *rcvd)
473: {
474: struct kgsl_device *device = KGSL_DEVICE(a6xx_gmu_to_adreno(gmu));
475: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(ADRENO_DEVICE(device));
476: u64 ticks = gpudev->read_alwayson(ADRENO_DEVICE(device));
477: struct hfi_err_cmd *cmd = rcvd;
478:
479: dev_err(GMU_PDEV_DEV(device), "HFI Error Received: %d %d %.16s\n",
480: ((cmd->error_code >> 16) & 0xFFFF),
481: (cmd->error_code & 0xFFFF),
482: (char *) cmd->data);
483:
484: KGSL_GMU_CORE_FORCE_PANIC(device->gmu_core.gf_panic,
485: GMU_PDEV(device), ticks, GMU_FAULT_F2H_MSG_ERR);
486: }
487:
488: void adreno_a6xx_receive_debug_req(struct a6xx_gmu_device *gmu, void *rcvd)
489: {
490: struct kgsl_device *device = KGSL_DEVICE(a6xx_gmu_to_adreno(gmu));
491: struct hfi_debug_cmd *cmd = rcvd;
492:
493: dev_dbg(GMU_PDEV_DEV(device), "HFI Debug Received: %d %d %d\n",
494: cmd->type, cmd->timestamp, cmd->data);
495: }
496:
497: static void a6xx_hfi_v1_receiver(struct a6xx_gmu_device *gmu, uint32_t *rcvd,
498: struct pending_cmd *ret_cmd)
499: {
500: struct kgsl_device *device = KGSL_DEVICE(a6xx_gmu_to_adreno(gmu));
501: /* V1 ACK Handler */
502: if (MSG_HDR_GET_TYPE(rcvd[0]) == HFI_V1_MSG_ACK) {
503: a6xx_receive_ack_cmd(gmu, rcvd, ret_cmd);
504: return;
505: }
506:
507: /* V1 Request Handler */
508: switch (MSG_HDR_GET_ID(rcvd[0])) {
509: case F2H_MSG_ERR: /* No Reply */
510: adreno_a6xx_receive_err_req(gmu, rcvd);
511: break;
512: case F2H_MSG_DEBUG: /* No Reply */
513: adreno_a6xx_receive_debug_req(gmu, rcvd);
514: break;
515: default: /* No Reply */
516: dev_err(GMU_PDEV_DEV(device),
517: "HFI V1 request %d not supported\n",
518: MSG_HDR_GET_ID(rcvd[0]));
519: break;
520: }
521: }
522:
523: int a6xx_hfi_process_queue(struct a6xx_gmu_device *gmu,
524: uint32_t queue_idx, struct pending_cmd *ret_cmd)
525: {
526: struct kgsl_device *device = KGSL_DEVICE(a6xx_gmu_to_adreno(gmu));
527: uint32_t rcvd[MAX_RCVD_SIZE];
528:
529: while (a6xx_hfi_queue_read(gmu, queue_idx, rcvd, sizeof(rcvd)) > 0) {
530: /* Special case if we're v1 */
531: if (GMU_VER_MAJOR(device->gmu_core.ver.hfi) < 2) {
532: a6xx_hfi_v1_receiver(gmu, rcvd, ret_cmd);
533: continue;
534: }
535:
536: /* V2 ACK Handler */
537: if (MSG_HDR_GET_TYPE(rcvd[0]) == HFI_MSG_ACK) {
538: int ret = a6xx_receive_ack_cmd(gmu, rcvd, ret_cmd);
539:
540: if (ret)
541: return ret;
542: continue;
543: }
544:
545: /* V2 Request Handler */
546: switch (MSG_HDR_GET_ID(rcvd[0])) {
547: case F2H_MSG_ERR: /* No Reply */
548: adreno_a6xx_receive_err_req(gmu, rcvd);
549: break;
550: case F2H_MSG_DEBUG: /* No Reply */
551: adreno_a6xx_receive_debug_req(gmu, rcvd);
552: break;
553: default: /* No Reply */
554: dev_err(GMU_PDEV_DEV(device),
555: "HFI request %d not supported\n",
556: MSG_HDR_GET_ID(rcvd[0]));
557: break;
558: }
559: }
560:
561: return 0;
562: }
563:
564: static int a6xx_hfi_verify_fw_version(struct adreno_device *adreno_dev)
565: {
566: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
567: const struct adreno_a6xx_core *a6xx_core = to_a6xx_core(adreno_dev);
568: struct device *gmu_pdev_dev = GMU_PDEV_DEV(device);
569: int result;
570: unsigned int ver, major, minor;
571:
572: /* GMU version is already known, so don't waste time finding again */
573: if (device->gmu_core.ver.core != 0)
574: return 0;
575:
576: major = a6xx_core->gmu_major;
577: minor = a6xx_core->gmu_minor;
578:
579: result = a6xx_hfi_get_fw_version(adreno_dev, GMU_VERSION(major, minor, 0),
580: &ver);
581: if (result) {
582: dev_err_once(gmu_pdev_dev,
583: "Failed to get FW version via HFI\n");
584: return result;
585: }
586:
587: /* For now, warn once. Could return error later if needed */
588: if (major != GMU_VER_MAJOR(ver))
589: dev_err_once(gmu_pdev_dev,
590: "FW Major Error: Wanted %d, got %d\n",
591: major, GMU_VER_MAJOR(ver));
592:
593: if (minor > GMU_VER_MINOR(ver))
594: dev_err_once(gmu_pdev_dev,
595: "FW Minor Error: Wanted < %d, got %d\n",
596: GMU_VER_MINOR(ver), minor);
597:
598: /* Save the gmu version information */
599: device->gmu_core.ver.core = ver;
600:
601: return 0;
602: }
603:
604: int a6xx_hfi_send_bcl_feature_ctrl(struct adreno_device *adreno_dev)
605: {
606: int ret;
607:
608: if (!adreno_dev->bcl_enabled)
609: return 0;
610:
611: ret = a6xx_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_BCL, 1, 0);
612:
613: return ret;
614: }
615:
616: int a6xx_hfi_send_lm_feature_ctrl(struct adreno_device *adreno_dev)
617: {
618: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
619: struct hfi_set_value_cmd req;
620: u32 slope = 0;
621: int ret;
622:
623: if (!adreno_dev->lm_enabled)
624: return 0;
625:
626: memset(&req, 0, sizeof(req));
627:
628: nvmem_cell_read_u32(&device->pdev->dev, "isense_slope", &slope);
629:
630: ret = CMD_MSG_HDR(req, H2F_MSG_SET_VALUE);
631: if (ret)
632: return ret;
633:
634: req.type = HFI_VALUE_LM_CS0;
635: req.subtype = 0;
636: req.data = slope;
637:
638: ret = a6xx_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_LM, 1,
639: device->pwrctrl.throttle_mask);
640:
641: if (!ret)
642: ret = a6xx_hfi_send_generic_req(adreno_dev, &req, sizeof(req));
643:
644: return ret;
645: }
646:
647: int a6xx_hfi_send_acd_feature_ctrl(struct adreno_device *adreno_dev)
648: {
649: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
650: int ret = 0;
651:
652: if (adreno_dev->acd_enabled) {
653: ret = a6xx_hfi_send_generic_req(adreno_dev,
654: &gmu->hfi.acd_table, sizeof(gmu->hfi.acd_table));
655: if (!ret)
656: ret = a6xx_hfi_send_feature_ctrl(adreno_dev,
657: HFI_FEATURE_ACD, 1, 0);
658: }
659:
660: return ret;
661: }
662:
663: static void reset_hfi_queues(struct adreno_device *adreno_dev)
664: {
665: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
666: struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
667: struct hfi_queue_table *tbl = mem_addr->hostptr;
668: struct hfi_queue_header *hdr;
669: unsigned int i;
670:
671: /* Flush HFI queues */
672: for (i = 0; i < HFI_QUEUE_MAX; i++) {
673: hdr = &tbl->qhdr[i];
674:
675: if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
676: continue;
677:
678: hdr->read_index = hdr->write_index;
679: }
680: }
681:
682: int a6xx_hfi_start(struct adreno_device *adreno_dev)
683: {
684: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
685: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
686: int result;
687:
688: reset_hfi_queues(adreno_dev);
689:
690: /* This is legacy HFI message for A630 and A615 family firmware */
691: if (adreno_is_a630(adreno_dev) || adreno_is_a615_family(adreno_dev)) {
692: result = a6xx_hfi_send_gmu_init(adreno_dev);
693: if (result)
694: goto err;
695: }
696:
697: result = a6xx_hfi_verify_fw_version(adreno_dev);
698: if (result)
699: goto err;
700:
701: if (GMU_VER_MAJOR(device->gmu_core.ver.hfi) < 2)
702: result = a6xx_hfi_send_dcvstbl_v1(adreno_dev);
703: else
704: result = a6xx_hfi_send_generic_req(adreno_dev,
705: &gmu->hfi.dcvs_table, sizeof(gmu->hfi.dcvs_table));
706: if (result)
707: goto err;
708:
709: result = a6xx_hfi_send_generic_req(adreno_dev, &gmu->hfi.bw_table,
710: sizeof(gmu->hfi.bw_table));
711: if (result)
712: goto err;
713:
714: /*
715: * If quirk is enabled send H2F_MSG_TEST and tell the GMU
716: * we are sending no more HFIs until the next boot otherwise
717: * send H2F_MSG_CORE_FW_START and features for A640 devices
718: */
719: if (GMU_VER_MAJOR(device->gmu_core.ver.hfi) >= 2) {
720: result = a6xx_hfi_send_acd_feature_ctrl(adreno_dev);
721: if (result)
722: goto err;
723:
724: result = a6xx_hfi_send_lm_feature_ctrl(adreno_dev);
725: if (result)
726: goto err;
727:
728: result = a6xx_hfi_send_bcl_feature_ctrl(adreno_dev);
729: if (result)
730: goto err;
731:
732: result = a6xx_hfi_send_core_fw_start(adreno_dev);
733: if (result)
734: goto err;
735: } else {
736: if (ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_HFI_USE_REG)) {
737: result = a6xx_hfi_send_test(adreno_dev);
738: if (result)
739: goto err;
740: }
741: }
742:
743: set_bit(GMU_PRIV_HFI_STARTED, &gmu->flags);
744:
745: result = kgsl_pwrctrl_setup_default_votes(device);
746:
747: err:
748: if (result)
749: a6xx_hfi_stop(adreno_dev);
750:
751: return result;
752:
753: }
754:
755: void a6xx_hfi_stop(struct adreno_device *adreno_dev)
756: {
757: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
758: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
759:
760: kgsl_pwrctrl_axi(device, false);
761:
762: clear_bit(GMU_PRIV_HFI_STARTED, &gmu->flags);
763: }
764:
765: /* HFI interrupt handler */
766: irqreturn_t a6xx_hfi_irq_handler(int irq, void *data)
767: {
768: struct kgsl_device *device = data;
769: struct a6xx_gmu_device *gmu = to_a6xx_gmu(ADRENO_DEVICE(device));
770: unsigned int status = 0;
771:
772: gmu_core_regread(device, A6XX_GMU_GMU2HOST_INTR_INFO, &status);
773: gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_CLR, HFI_IRQ_MASK);
774:
775: if (status & HFI_IRQ_DBGQ_MASK)
776: a6xx_hfi_process_queue(gmu, HFI_DBG_ID, NULL);
777: if (status & HFI_IRQ_CM3_FAULT_MASK) {
778: dev_err_ratelimited(GMU_PDEV_DEV(device),
779: "GMU CM3 fault interrupt received\n");
780: atomic_set(&gmu->cm3_fault, 1);
781:
782: /* make sure other CPUs see the update */
783: smp_wmb();
784: }
785: if (status & ~HFI_IRQ_MASK)
786: dev_err_ratelimited(GMU_PDEV_DEV(device),
787: "Unhandled HFI interrupts 0x%lx\n",
788: status & ~HFI_IRQ_MASK);
789:
790: return IRQ_HANDLED;
791: }
--- FILE: \adreno_a6xx_hfi.h | HITS: 40 ---
MATCH LINES: 6, 7, 12, 18, 30, 32, 33, 36, 41, 44, 49, 52, 60, 63, 66, 74, 78, 86, 90, 97, 101, 109, 113, 121, 125, 130, 133, 138, 141, 146, 149, 156, 159, 164, 167, 174, 178, 185, 186, 187
1: /* SPDX-License-Identifier: GPL-2.0-only */
2: /*
3: * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
4: * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
5: */
6: #ifndef __ADRENO_A6XX_HFI_H
7: #define __ADRENO_A6XX_HFI_H
8:
9: #include "adreno_hfi.h"
10:
11: /**
12: * struct a6xx_hfi - HFI control structure
13: * @seqnum: atomic counter that is incremented for each message sent. The
14: * value of the counter is used as sequence number for HFI message
15: * @bw_table: HFI BW table buffer
16: * @acd_table: HFI table for ACD data
17: */
18: struct a6xx_hfi {
19: /** @irq: HFI interrupt line */
20: int irq;
21: atomic_t seqnum;
22: /** @hfi_mem: Memory descriptor for the hfi memory */
23: struct kgsl_memdesc *hfi_mem;
24: struct hfi_bwtable_cmd bw_table;
25: struct hfi_acd_table_cmd acd_table;
26: /** @dcvs_table: HFI table for gpu dcvs levels */
27: struct hfi_dcvstable_cmd dcvs_table;
28: };
29:
30: struct a6xx_gmu_device;
31:
32: /* a6xx_hfi_irq_handler - IRQ handler for HFI interripts */
33: irqreturn_t a6xx_hfi_irq_handler(int irq, void *data);
34:
35: /**
36: * a6xx_hfi_start - Send the various HFIs during device boot up
37: * @adreno_dev: Pointer to the adreno device
38: *
39: * Return: 0 on success or negative error on failure
40: */
41: int a6xx_hfi_start(struct adreno_device *adreno_dev);
42:
43: /**
44: * a6xx_hfi_start - Send the various HFIs during device boot up
45: * @adreno_dev: Pointer to the adreno device
46: *
47: * Return: 0 on success or negative error on failure
48: */
49: void a6xx_hfi_stop(struct adreno_device *adreno_dev);
50:
51: /**
52: * a6xx_hfi_init - Initialize hfi resources
53: * @adreno_dev: Pointer to the adreno device
54: *
55: * This function allocates and sets up hfi queues
56: * when a process creates the very first kgsl instance
57: *
58: * Return: 0 on success or negative error on failure
59: */
60: int a6xx_hfi_init(struct adreno_device *adreno_dev);
61:
62: /* Helper function to get to a6xx hfi struct from adreno device */
63: struct a6xx_hfi *to_a6xx_hfi(struct adreno_device *adreno_dev);
64:
65: /**
66: * a6xx_hfi_queue_write - Write a command to hfi queue
67: * @adreno_dev: Pointer to the adreno device
68: * @queue_idx: destination queue id
69: * @msg: Data to be written to the queue
70: * @size_bytes: Size of the command in bytes
71: *
72: * Return: 0 on success or negative error on failure
73: */
74: int a6xx_hfi_queue_write(struct adreno_device *adreno_dev, u32 queue_idx,
75: u32 *msg, u32 size_bytes);
76:
77: /**
78: * a6xx_hfi_queue_read - Read data from hfi queue
79: * @gmu: Pointer to the a6xx gmu device
80: * @queue_idx: queue id to read from
81: * @output: Pointer to read the data into
82: * @max_size: Number of bytes to read from the queue
83: *
84: * Return: 0 on success or negative error on failure
85: */
86: int a6xx_hfi_queue_read(struct a6xx_gmu_device *gmu, u32 queue_idx,
87: u32 *output, u32 max_size);
88:
89: /**
90: * a6xx_receive_ack_cmd - Process ack type packets
91: * @gmu: Pointer to the a6xx gmu device
92: * @rcvd: Pointer to the data read from hfi queue
93: * @ret_cmd: Container for the hfi packet for which this ack is received
94: *
95: * Return: 0 on success or negative error on failure
96: */
97: int a6xx_receive_ack_cmd(struct a6xx_gmu_device *gmu, void *rcvd,
98: struct pending_cmd *ret_cmd);
99:
100: /**
101: * a6xx_hfi_send_feature_ctrl - Enable gmu feature via hfi
102: * @adreno_dev: Pointer to the adreno device
103: * @feature: feature to be enabled or disabled
104: * enable: Set 1 to enable or 0 to disable a feature
105: * @data: payload for the send feature hfi packet
106: *
107: * Return: 0 on success or negative error on failure
108: */
109: int a6xx_hfi_send_feature_ctrl(struct adreno_device *adreno_dev,
110: u32 feature, u32 enable, u32 data);
111:
112: /**
113: * a6xx_hfi_send_set_value - Send gmu set_values via hfi
114: * @adreno_dev: Pointer to the adreno device
115: * @type: GMU set_value type
116: * @subtype: GMU set_value subtype
117: * @data: Value to set
118: *
119: * Return: 0 on success or negative error on failure
120: */
121: int a6xx_hfi_send_set_value(struct adreno_device *adreno_dev,
122: u32 type, u32 subtype, u32 data);
123:
124: /**
125: * a6xx_hfi_send_core_fw_start - Send the core fw start hfi
126: * @adreno_dev: Pointer to the adreno device
127: *
128: * Return: 0 on success or negative error on failure
129: */
130: int a6xx_hfi_send_core_fw_start(struct adreno_device *adreno_dev);
131:
132: /**
133: * a6xx_hfi_send_acd_feature_ctrl - Send the acd table and acd feature
134: * @adreno_dev: Pointer to the adreno device
135: *
136: * Return: 0 on success or negative error on failure
137: */
138: int a6xx_hfi_send_acd_feature_ctrl(struct adreno_device *adreno_dev);
139:
140: /**
141: * a6xx_hfi_send_lm_feature_ctrl - Send the lm feature hfi packet
142: * @adreno_dev: Pointer to the adreno device
143: *
144: * Return: 0 on success or negative error on failure
145: */
146: int a6xx_hfi_send_lm_feature_ctrl(struct adreno_device *adreno_dev);
147:
148: /**
149: * a6xx_hfi_send_generic_req - Send a generic hfi packet
150: * @adreno_dev: Pointer to the adreno device
151: * @cmd: Pointer to the hfi packet header and data
152: * @size_bytes: Size of the command in bytes
153: *
154: * Return: 0 on success or negative error on failure
155: */
156: int a6xx_hfi_send_generic_req(struct adreno_device *adreno_dev, void *cmd, u32 size_bytes);
157:
158: /**
159: * a6xx_hfi_send_bcl_feature_ctrl - Send the bcl feature hfi packet
160: * @adreno_dev: Pointer to the adreno device
161: *
162: * Return: 0 on success or negative error on failure
163: */
164: int a6xx_hfi_send_bcl_feature_ctrl(struct adreno_device *adreno_dev);
165:
166: /*
167: * a6xx_hfi_process_queue - Check hfi queue for messages from gmu
168: * @gmu: Pointer to the a6xx gmu device
169: * @queue_idx: queue id to be processed
170: * @ret_cmd: Container for data needed for waiting for the ack
171: *
172: * Return: 0 on success or negative error on failure
173: */
174: int a6xx_hfi_process_queue(struct a6xx_gmu_device *gmu,
175: u32 queue_idx, struct pending_cmd *ret_cmd);
176:
177: /**
178: * a6xx_hfi_cmdq_write - Write a command to command queue
179: * @adreno_dev: Pointer to the adreno device
180: * @msg: Data to be written to the queue
181: * @size_bytes: Size of the command in bytes
182: *
183: * Return: 0 on success or negative error on failure
184: */
185: int a6xx_hfi_cmdq_write(struct adreno_device *adreno_dev, u32 *msg, u32 size_bytes);
186: void adreno_a6xx_receive_err_req(struct a6xx_gmu_device *gmu, void *rcvd);
187: void adreno_a6xx_receive_debug_req(struct a6xx_gmu_device *gmu, void *rcvd);
188: #endif
--- FILE: \adreno_a6xx_hwsched.c | HITS: 153 ---
MATCH LINES: 11, 20, 29
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 <linux/interconnect.h>
8:
9: #include "adreno.h"
10: #include "adreno_a6xx.h"
11: #include "adreno_a6xx_hwsched.h"
12: #include "adreno_hfi.h"
13: #include "adreno_snapshot.h"
14: #include "kgsl_bus.h"
15: #include "kgsl_device.h"
16: #include "kgsl_gmu_core.h"
17: #include "kgsl_trace.h"
18: #include "kgsl_util.h"
19:
20: void a6xx_hwsched_snapshot(struct adreno_device *adreno_dev,
21: struct kgsl_snapshot *snapshot)
22: {
23: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
24: struct adreno_hwsched *hwsched = &adreno_dev->hwsched;
25: u32 i;
26: bool skip_memkind_rb = false;
27: bool parse_payload;
28:
29: a6xx_gmu_snapshot(adreno_dev, snapshot);
30:
31: adreno_hwsched_parse_fault_cmdobj(adreno_dev, snapshot);
32:
33: /*
34: * First try to dump ringbuffers using context bad HFI payloads
35: * because they have all the ringbuffer parameters. If ringbuffer
36: * payloads are not present, fall back to dumping ringbuffers
37: * based on MEMKIND_RB
38: */
39: if (GMU_VER_MINOR(device->gmu_core.ver.hfi) < 2)
40: parse_payload = adreno_hwsched_parse_payload_rb_legacy(adreno_dev, snapshot);
41: else
42: parse_payload = adreno_hwsched_parse_payload_rb(adreno_dev, snapshot);
43:
44: if (parse_payload)
45: skip_memkind_rb = true;
46:
47: for (i = 0; i < hwsched->mem_alloc_entries; i++) {
48: struct hfi_mem_alloc_entry *entry = &hwsched->mem_alloc_table[i];
49:
50: if (entry->desc.mem_kind == HFI_MEMKIND_RB && !skip_memkind_rb)
51: kgsl_snapshot_add_section(device,
52: KGSL_SNAPSHOT_SECTION_RB_V2,
53: snapshot, adreno_hwsched_snapshot_rb,
MATCH LINES: 86, 88, 92, 96, 101, 111, 115, 120, 124, 128, 130, 135, 145, 149, 156, 169, 172, 182, 189, 204, 208, 212, 214, 219, 223, 230, 240, 243, 253, 260, 264, 277, 279, 287, 291, 300, 304, 308, 312, 317, 319, 321, 323, 327, 338, 339, 340, 345, 354, 364, 374, 376, 378, 393, 396, 409, 414, 418, 426, 429, 432, 448, 452, 475, 477, 501, 503, 508, 528, 531, 535, 542, 546, 550, 556, 560
74: if (entry->desc.mem_kind == HFI_MEMKIND_CSW_PRIV_NON_SECURE)
75: adreno_hwsched_snapshot_preemption_records(device, snapshot,
76: entry->md);
77:
78: if (entry->desc.mem_kind == HFI_MEMKIND_PREEMPT_SCRATCH)
79: kgsl_snapshot_add_section(device,
80: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2,
81: snapshot, adreno_snapshot_global,
82: entry->md);
83: }
84: }
85:
86: static void a6xx_hwsched_gmu_suspend(struct adreno_device *adreno_dev, bool force)
87: {
88: a6xx_gmu_suspend(adreno_dev, force);
89: adreno_hwsched_reset_hfi_mem(adreno_dev);
90: }
91:
92: static int a6xx_hwsched_gmu_first_boot(struct adreno_device *adreno_dev)
93: {
94: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
95: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
96: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
97: int level, ret = 0;
98:
99: kgsl_pwrctrl_request_state(device, KGSL_STATE_AWARE);
100:
101: a6xx_gmu_aop_send_acd_state(gmu, adreno_dev->acd_enabled);
102:
103: ret = kgsl_pwrctrl_enable_cx_gdsc(device);
104: if (ret)
105: return ret;
106:
107: ret = gmu_core_enable_clks(device, device->gmu_core.num_freqs - 1);
108: if (ret)
109: goto gdsc_off;
110:
111: ret = a6xx_gmu_load_fw(adreno_dev);
112: if (ret)
113: goto clks_gdsc_off;
114:
115: ret = a6xx_gmu_itcm_shadow(adreno_dev);
116: if (ret)
117: goto clks_gdsc_off;
118:
119: if (!test_bit(GMU_PRIV_PDC_RSC_LOADED, &gmu->flags)) {
120: ret = a6xx_load_pdc_ucode(adreno_dev);
121: if (ret)
122: goto clks_gdsc_off;
123:
124: a6xx_load_rsc_ucode(adreno_dev);
125: set_bit(GMU_PRIV_PDC_RSC_LOADED, &gmu->flags);
126: }
127:
128: a6xx_gmu_register_config(adreno_dev);
129:
130: a6xx_gmu_version_info(adreno_dev);
131:
132: if (GMU_VER_MINOR(device->gmu_core.ver.hfi) < 2)
133: set_bit(ADRENO_HWSCHED_CTX_BAD_LEGACY, &adreno_dev->hwsched.flags);
134:
135: a6xx_gmu_irq_enable(adreno_dev);
136:
137: /* Vote for minimal DDR BW for GMU to init */
138: level = pwr->pwrlevels[pwr->default_pwrlevel].bus_min;
139:
140: icc_set_bw(pwr->icc_path, 0, kBps_to_icc(pwr->ddr_table[level]));
141:
142: /* Clear any hwsched faults that might have been left over */
143: adreno_clear_gpu_fault(adreno_dev);
144:
145: ret = a6xx_gmu_device_start(adreno_dev);
146: if (ret)
147: goto err;
148:
149: ret = a6xx_hwsched_hfi_start(adreno_dev);
150: if (ret)
151: goto err;
152:
153: /* Switch to min GMU clock */
154: ret = gmu_core_clock_set_rate(device, 0);
155: if (ret) {
156: a6xx_hwsched_hfi_stop(adreno_dev);
157: goto err;
158: }
159:
160: icc_set_bw(pwr->icc_path, 0, 0);
161:
162: device->gmu_fault = false;
163:
164: kgsl_pwrctrl_set_state(device, KGSL_STATE_AWARE);
165:
166: return 0;
167:
168: err:
169: a6xx_gmu_irq_disable(adreno_dev);
170:
171: if (device->gmu_fault) {
172: a6xx_hwsched_gmu_suspend(adreno_dev, false);
173: return ret;
174: }
175:
176: adreno_hwsched_reset_hfi_mem(adreno_dev);
177:
178: clks_gdsc_off:
179: gmu_core_disable_clks(device);
180:
181: gdsc_off:
182: a6xx_gmu_disable_gdsc(adreno_dev);
183:
184: gmu_core_rdpm_cx_freq_update(device, 0);
185:
186: return ret;
187: }
188:
189: static int a6xx_hwsched_gmu_boot(struct adreno_device *adreno_dev)
190: {
191: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
192: int ret = 0;
193:
194: kgsl_pwrctrl_request_state(device, KGSL_STATE_AWARE);
195:
196: ret = kgsl_pwrctrl_enable_cx_gdsc(device);
197: if (ret)
198: return ret;
199:
200: ret = gmu_core_enable_clks(device, device->gmu_core.num_freqs - 1);
201: if (ret)
202: goto gdsc_off;
203:
204: ret = a6xx_rscc_wakeup_sequence(adreno_dev);
205: if (ret)
206: goto clks_gdsc_off;
207:
208: ret = a6xx_gmu_load_fw(adreno_dev);
209: if (ret)
210: goto clks_gdsc_off;
211:
212: a6xx_gmu_register_config(adreno_dev);
213:
214: a6xx_gmu_irq_enable(adreno_dev);
215:
216: /* Clear any hwsched faults that might have been left over */
217: adreno_clear_gpu_fault(adreno_dev);
218:
219: ret = a6xx_gmu_device_start(adreno_dev);
220: if (ret)
221: goto err;
222:
223: ret = a6xx_hwsched_hfi_start(adreno_dev);
224: if (ret)
225: goto err;
226:
227: /* Switch to min GMU clock */
228: ret = gmu_core_clock_set_rate(device, 0);
229: if (ret) {
230: a6xx_hwsched_hfi_stop(adreno_dev);
231: goto err;
232: }
233:
234: device->gmu_fault = false;
235:
236: kgsl_pwrctrl_set_state(device, KGSL_STATE_AWARE);
237:
238: return 0;
239: err:
240: a6xx_gmu_irq_disable(adreno_dev);
241:
242: if (device->gmu_fault) {
243: a6xx_hwsched_gmu_suspend(adreno_dev, false);
244: return ret;
245: }
246:
247: adreno_hwsched_reset_hfi_mem(adreno_dev);
248:
249: clks_gdsc_off:
250: gmu_core_disable_clks(device);
251:
252: gdsc_off:
253: a6xx_gmu_disable_gdsc(adreno_dev);
254:
255: gmu_core_rdpm_cx_freq_update(device, 0);
256:
257: return ret;
258: }
259:
260: static int a6xx_hwsched_notify_slumber(struct adreno_device *adreno_dev)
261: {
262: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
263: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
264: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
265: struct hfi_prep_slumber_cmd req;
266: int ret;
267:
268: ret = CMD_MSG_HDR(req, H2F_MSG_PREPARE_SLUMBER);
269: if (ret)
270: return ret;
271:
272: req.freq = gmu->hfi.dcvs_table.gpu_level_num -
273: pwr->default_pwrlevel - 1;
274: req.bw = pwr->pwrlevels[pwr->default_pwrlevel].bus_freq;
275:
276: /* Disable the power counter so that the GMU is not busy */
277: gmu_core_regwrite(device, A6XX_GMU_CX_GMU_POWER_COUNTER_ENABLE, 0);
278:
279: ret = a6xx_hfi_send_cmd_async(adreno_dev, &req, sizeof(req));
280:
281: /*
282: * GEMNOC can enter power collapse state during GPU power down sequence.
283: * This could abort CX GDSC collapse. Assert Qactive to avoid this.
284: */
285: if ((adreno_is_a662(adreno_dev) || adreno_is_a621(adreno_dev) ||
286: adreno_is_a622(adreno_dev) || adreno_is_a642l(adreno_dev)))
287: gmu_core_regwrite(device, A6XX_GPU_GMU_CX_GMU_CX_FALNEXT_INTF, 0x1);
288:
289: return ret;
290: }
291: static int a6xx_hwsched_gmu_power_off(struct adreno_device *adreno_dev)
292: {
293: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
294: int ret = 0;
295:
296: if (device->gmu_fault)
297: goto error;
298:
299: /* Wait for the lowest idle level we requested */
300: ret = a6xx_gmu_wait_for_lowest_idle(adreno_dev);
301: if (ret)
302: goto error;
303:
304: ret = a6xx_hwsched_notify_slumber(adreno_dev);
305: if (ret)
306: goto error;
307:
308: ret = a6xx_gmu_wait_for_idle(adreno_dev);
309: if (ret)
310: goto error;
311:
312: ret = a6xx_rscc_sleep_sequence(adreno_dev);
313:
314: gmu_core_rdpm_mx_freq_update(device, 0);
315:
316: /* Now that we are done with GMU and GPU, Clear the GBIF */
317: ret = a6xx_halt_gbif(adreno_dev);
318: /* De-assert the halts */
319: kgsl_regwrite(device, A6XX_GBIF_HALT, 0x0);
320:
321: a6xx_gmu_irq_disable(adreno_dev);
322:
323: a6xx_hwsched_hfi_stop(adreno_dev);
324:
325: gmu_core_disable_clks(device);
326:
327: a6xx_gmu_disable_gdsc(adreno_dev);
328:
329: gmu_core_rdpm_cx_freq_update(device, 0);
330:
331: kgsl_pwrctrl_set_state(device, KGSL_STATE_NONE);
332:
333: adreno_hwsched_reset_hfi_mem(adreno_dev);
334:
335: return ret;
336:
337: error:
338: a6xx_gmu_irq_disable(adreno_dev);
339: a6xx_hwsched_hfi_stop(adreno_dev);
340: a6xx_hwsched_gmu_suspend(adreno_dev, false);
341:
342: return ret;
343: }
344:
345: static int a6xx_hwsched_gpu_boot(struct adreno_device *adreno_dev)
346: {
347: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
348: int ret;
349:
350: ret = kgsl_mmu_start(device);
351: if (ret)
352: goto err;
353:
354: ret = a6xx_gmu_oob_set(device, oob_gpu);
355: if (ret)
356: goto err;
357:
358: /* Clear the busy_data stats - we're starting over from scratch */
359: memset(&adreno_dev->busy_data, 0, sizeof(adreno_dev->busy_data));
360:
361: /* Restore performance counter registers with saved values */
362: adreno_perfcounter_restore(adreno_dev);
363:
364: a6xx_start(adreno_dev);
365:
366: /* Re-initialize the coresight registers if applicable */
367: adreno_coresight_start(adreno_dev);
368:
369: adreno_perfcounter_start(adreno_dev);
370:
371: /* Clear FSR here in case it is set from a previous pagefault */
372: kgsl_mmu_clear_fsr(&device->mmu);
373:
374: a6xx_enable_gpu_irq(adreno_dev);
375:
376: ret = a6xx_hwsched_cp_init(adreno_dev);
377: if (ret) {
378: a6xx_disable_gpu_irq(adreno_dev);
379: adreno_llcc_slice_deactivate(adreno_dev);
380: goto err;
381: }
382:
383: /*
384: * At this point it is safe to assume that we recovered. Setting
385: * this field allows us to take a new snapshot for the next failure
386: * if we are prioritizing the first unrecoverable snapshot.
387: */
388: if (device->snapshot)
389: device->snapshot->recovered = true;
390:
391: device->reset_counter++;
392: err:
393: a6xx_gmu_oob_clear(device, oob_gpu);
394:
395: if (ret)
396: a6xx_hwsched_gmu_power_off(adreno_dev);
397:
398: return ret;
399: }
400:
401: static void hwsched_idle_timer(struct timer_list *t)
402: {
403: struct kgsl_device *device = container_of(t, struct kgsl_device,
404: idle_timer);
405:
406: kgsl_schedule_work(&device->idle_check_ws);
407: }
408:
409: static int a6xx_hwsched_gmu_init(struct adreno_device *adreno_dev)
410: {
411: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
412: int ret;
413:
414: ret = a6xx_gmu_parse_fw(adreno_dev);
415: if (ret)
416: return ret;
417:
418: ret = a6xx_gmu_memory_init(adreno_dev);
419: if (ret)
420: return ret;
421:
422: ret = gmu_core_hwsched_memory_init(device);
423: if (ret)
424: return ret;
425:
426: return a6xx_hwsched_hfi_init(adreno_dev);
427: }
428:
429: static void a6xx_hwsched_touch_wakeup(struct adreno_device *adreno_dev)
430: {
431: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
432: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
433: int ret;
434:
435: /*
436: * Do not wake up a suspended device or until the first boot sequence
437: * has been completed.
438: */
439: if (test_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags) ||
440: !test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags))
441: return;
442:
443: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags))
444: goto done;
445:
446: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE);
447:
448: ret = a6xx_hwsched_gmu_boot(adreno_dev);
449: if (ret)
450: return;
451:
452: ret = a6xx_hwsched_gpu_boot(adreno_dev);
453: if (ret)
454: return;
455:
456: kgsl_pwrscale_wake(device);
457:
458: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags);
459:
460: device->pwrctrl.last_stat_updated = ktime_get();
461:
462: kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE);
463:
464: done:
465: /*
466: * When waking up from a touch event we want to stay active long enough
467: * for the user to send a draw command. The default idle timer timeout
468: * is shorter than we want so go ahead and push the idle timer out
469: * further for this special case
470: */
471: mod_timer(&device->idle_timer, jiffies +
472: msecs_to_jiffies(adreno_wake_timeout));
473: }
474:
475: static int a6xx_hwsched_boot(struct adreno_device *adreno_dev)
476: {
477: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
478: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
479: bool bcl_state = adreno_dev->bcl_enabled;
480: int ret;
481:
482: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags))
483: return 0;
484:
485: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE);
486:
487: adreno_hwsched_start(adreno_dev);
488:
489: if (IS_ENABLED(CONFIG_QCOM_KGSL_HIBERNATION) &&
490: !test_bit(GMU_PRIV_PDC_RSC_LOADED, &gmu->flags)) {
491: /*
492: * During hibernation entry ZAP was unloaded and
493: * CBCAST BCL register is in reset state.
494: * Set bcl_enabled to false to skip KMD's HFI request
495: * to GMU for BCL feature, send BCL feature request to
496: * GMU after ZAP load at GPU boot. This ensures that
497: * Central Broadcast register was programmed before
498: * enabling BCL.
499: */
500: adreno_dev->bcl_enabled = false;
501: ret = a6xx_hwsched_gmu_first_boot(adreno_dev);
502: } else {
503: ret = a6xx_hwsched_gmu_boot(adreno_dev);
504: }
505: if (ret)
506: return ret;
507:
508: ret = a6xx_hwsched_gpu_boot(adreno_dev);
509: if (ret)
510: return ret;
511:
512: kgsl_start_idle_timer(device);
513:
514: kgsl_pwrscale_wake(device);
515:
516: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags);
517:
518: if (IS_ENABLED(CONFIG_QCOM_KGSL_HIBERNATION))
519: adreno_dev->bcl_enabled = bcl_state;
520:
521: device->pwrctrl.last_stat_updated = ktime_get();
522:
523: kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE);
524:
525: return ret;
526: }
527:
528: static int a6xx_hwsched_first_boot(struct adreno_device *adreno_dev)
529: {
530: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
531: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
532: int ret;
533:
534: if (test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags))
535: return a6xx_hwsched_boot(adreno_dev);
536:
537: if (adreno_preemption_feature_set(adreno_dev))
538: set_bit(ADRENO_DEVICE_PREEMPTION, &adreno_dev->priv);
539:
540: adreno_hwsched_start(adreno_dev);
541:
542: ret = a6xx_microcode_read(adreno_dev);
543: if (ret)
544: return ret;
545:
546: ret = a6xx_init(adreno_dev);
547: if (ret)
548: return ret;
549:
550: ret = a6xx_hwsched_gmu_init(adreno_dev);
551: if (ret)
552: return ret;
553:
554: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE);
555:
556: ret = a6xx_hwsched_gmu_first_boot(adreno_dev);
557: if (ret)
558: return ret;
559:
560: ret = a6xx_hwsched_gpu_boot(adreno_dev);
561: if (ret)
562: return ret;
563:
564: adreno_get_bus_counters(adreno_dev);
565:
566: adreno_dev->cooperative_reset = ADRENO_FEATURE(adreno_dev,
567: ADRENO_COOP_RESET);
568:
569: set_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags);
570: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags);
571:
572: /*
573: * BCL needs respective Central Broadcast register to
574: * be programed from TZ. This programing happens only
575: * when zap shader firmware load is successful. Zap firmware
576: * load can fail in boot up path hence enable BCL only after we
577: * successfully complete first boot to ensure that Central
578: * Broadcast register was programed before enabling BCL.
579: */
580: if (ADRENO_FEATURE(adreno_dev, ADRENO_BCL))
581: adreno_dev->bcl_enabled = true;
582:
583: /*
584: * There is a possible deadlock scenario during kgsl firmware reading
MATCH LINES: 606, 609, 617, 619, 633, 638
594: */
595: device->pwrscale.devfreq_enabled = true;
596:
597: device->pwrctrl.last_stat_updated = ktime_get();
598:
599: set_bit(ADRENO_DEVICE_FIRST_BOOT_DONE, &adreno_dev->priv);
600:
601: kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE);
602:
603: return 0;
604: }
605:
606: static int a6xx_hwsched_power_off(struct adreno_device *adreno_dev)
607: {
608: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
609: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
610: int ret;
611:
612: if (!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags))
613: return 0;
614:
615: kgsl_pwrctrl_request_state(device, KGSL_STATE_SLUMBER);
616:
617: ret = a6xx_gmu_oob_set(device, oob_gpu);
618: if (ret) {
619: a6xx_gmu_oob_clear(device, oob_gpu);
620: goto no_gx_power;
621: }
622:
623: kgsl_pwrscale_update_stats(device);
624:
625: /* Save active coresight registers if applicable */
626: adreno_coresight_stop(adreno_dev);
627:
628: /* Save physical performance counter values before GPU power down*/
629: adreno_perfcounter_save(adreno_dev);
630:
631: adreno_irqctrl(adreno_dev, 0);
632:
633: a6xx_gmu_oob_clear(device, oob_gpu);
634:
635: no_gx_power:
636: kgsl_pwrctrl_irq(device, false);
637:
638: a6xx_hwsched_gmu_power_off(adreno_dev);
639:
640: adreno_hwsched_unregister_contexts(adreno_dev);
641:
642: adreno_llcc_slice_deactivate(adreno_dev);
643:
644: clear_bit(GMU_PRIV_GPU_STARTED, &gmu->flags);
645:
646: kgsl_delete_timer_sync(&device->idle_timer);
647:
648: kgsl_pwrscale_sleep(device);
649:
650: kgsl_pwrctrl_clear_l3_vote(device);
651:
652: kgsl_pwrctrl_set_state(device, KGSL_STATE_SLUMBER);
653:
654: return ret;
655: }
656:
657: static void hwsched_idle_check(struct work_struct *work)
658: {
659: struct kgsl_device *device = container_of(work,
660: struct kgsl_device, idle_check_ws);
661: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
662: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
MATCH LINES: 690, 696, 705, 720, 723, 733, 744, 749, 783, 804, 807, 810, 820, 839, 842, 864, 880, 886, 888, 891, 899, 901, 914, 916, 929, 931, 940, 947, 949, 951, 953, 959, 969, 970, 971, 972, 973, 974, 975, 976, 977, 980, 981, 982, 985, 990, 993, 995, 998, 1002, 1004, 1014, 1017, 1019, 1020, 1023, 1024, 1025, 1030, 1034, 1037, 1038, 1043, 1046, 1047, 1061, 1064, 1065
678: kgsl_start_idle_timer(device);
679: goto done;
680: }
681:
682: device->skip_inline_submit = true;
683: spin_unlock(&device->submit_lock);
684:
685: if (!gpudev->hw_isidle(adreno_dev)) {
686: dev_err(device->dev, "GPU isn't idle before SLUMBER\n");
687: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
688: }
689:
690: a6xx_hwsched_power_off(adreno_dev);
691:
692: done:
693: kgsl_mutex_unlock(&device->mutex);
694: }
695:
696: static int a6xx_hwsched_first_open(struct adreno_device *adreno_dev)
697: {
698: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
699: int ret;
700:
701: /*
702: * Do the one time settings that need to happen when we
703: * attempt to boot the gpu the very first time
704: */
705: ret = a6xx_hwsched_first_boot(adreno_dev);
706: if (ret)
707: return ret;
708:
709: /*
710: * A client that does a first_open but never closes the device
711: * may prevent us from going back to SLUMBER. So trigger the idle
712: * check by incrementing the active count and immediately releasing it.
713: */
714: atomic_inc(&device->active_cnt);
715: adreno_active_count_put(adreno_dev);
716:
717: return 0;
718: }
719:
720: static int a6xx_hwsched_active_count_get(struct adreno_device *adreno_dev)
721: {
722: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
723: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
724: int ret = 0;
725:
726: if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex)))
727: return -EINVAL;
728:
729: if (test_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags))
730: return -EINVAL;
731:
732: if ((atomic_read(&device->active_cnt) == 0))
733: ret = a6xx_hwsched_boot(adreno_dev);
734:
735: if (ret == 0)
736: atomic_inc(&device->active_cnt);
737:
738: trace_kgsl_active_count(device,
739: (unsigned long) __builtin_return_address(0));
740:
741: return ret;
742: }
743:
744: static int a6xx_hwsched_dcvs_set(struct adreno_device *adreno_dev,
745: int gpu_pwrlevel, int bus_level)
746: {
747: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
748: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
749: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
750: struct hfi_dcvstable_cmd *table = &gmu->hfi.dcvs_table;
751: struct hfi_gx_bw_perf_vote_cmd req = {
752: .ack_type = DCVS_ACK_BLOCK,
753: .freq = INVALID_DCVS_IDX,
754: .bw = INVALID_DCVS_IDX,
755: };
756: int ret;
757:
758: if (!test_bit(GMU_PRIV_HFI_STARTED, &gmu->flags))
759: return 0;
760:
761: /* Do not set to XO and lower GPU clock vote from GMU */
762: if ((gpu_pwrlevel != INVALID_DCVS_IDX) &&
763: (gpu_pwrlevel >= table->gpu_level_num - 1)) {
764: dev_err(GMU_PDEV_DEV(device), "Invalid gpu dcvs request: %d\n",
765: gpu_pwrlevel);
766: return -EINVAL;
767: }
768:
769: if (gpu_pwrlevel < table->gpu_level_num - 1)
770: req.freq = table->gpu_level_num - gpu_pwrlevel - 1;
771:
772: if (bus_level < pwr->ddr_table_count && bus_level > 0)
773: req.bw = bus_level;
774:
775: /* GMU will vote for slumber levels through the sleep sequence */
776: if ((req.freq == INVALID_DCVS_IDX) && (req.bw == INVALID_DCVS_IDX))
777: return 0;
778:
779: ret = CMD_MSG_HDR(req, H2F_MSG_GX_BW_PERF_VOTE);
780: if (ret)
781: return ret;
782:
783: ret = a6xx_hfi_send_cmd_async(adreno_dev, &req, sizeof(req));
784:
785: if (ret) {
786: dev_err_ratelimited(GMU_PDEV_DEV(device),
787: "Failed to set GPU perf idx %u, bw idx %u\n",
788: req.freq, req.bw);
789:
790: /*
791: * If this was a dcvs request along side an active gpu, request
792: * dispatcher based reset and recovery.
793: */
794: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags))
795: adreno_scheduler_fault(adreno_dev, ADRENO_GMU_FAULT);
796: }
797:
798: if (req.freq != INVALID_DCVS_IDX)
799: gmu_core_rdpm_mx_freq_update(device, table->gx_votes[req.freq].freq);
800:
801: return ret;
802: }
803:
804: static int a6xx_hwsched_clock_set(struct adreno_device *adreno_dev,
805: u32 pwrlevel)
806: {
807: return a6xx_hwsched_dcvs_set(adreno_dev, pwrlevel, INVALID_DCVS_IDX);
808: }
809:
810: static int a6xx_hwsched_bus_set(struct adreno_device *adreno_dev, int buslevel,
811: u32 ab)
812: {
813: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
814: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
815: int ret = 0;
816:
817: kgsl_icc_set_tag(pwr, buslevel);
818:
819: if (buslevel != pwr->cur_buslevel) {
820: ret = a6xx_hwsched_dcvs_set(adreno_dev, INVALID_DCVS_IDX,
821: buslevel);
822: if (ret)
823: return ret;
824:
825: gmu_core_scale_gmu_frequency(device, buslevel);
826:
827: pwr->cur_buslevel = buslevel;
828: }
829:
830: if (ab != pwr->cur_ab) {
831: icc_set_bw(pwr->icc_path, MBps_to_icc(ab), 0);
832: pwr->cur_ab = ab;
833: }
834:
835: trace_kgsl_buslevel(device, pwr->active_pwrlevel, pwr->cur_buslevel, pwr->cur_ab, 0);
836: return ret;
837: }
838:
839: static int a6xx_hwsched_pm_suspend(struct adreno_device *adreno_dev)
840: {
841: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
842: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
843: int ret, active_count;
844:
845: if (test_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags))
846: return 0;
847:
848: kgsl_pwrctrl_request_state(device, KGSL_STATE_SUSPEND);
849:
850: ret = adreno_hwsched_drain_and_idle(adreno_dev);
851: if (ret)
852: goto err;
853:
854: active_count = atomic_read(&device->active_cnt);
855:
856: if (active_count > 0) {
857: ret = -ETIMEDOUT;
858: dev_err_ratelimited(GMU_PDEV_DEV(device),
859: "Aborting suspend because of active count:%d\n",
860: active_count);
861: goto err;
862: }
863:
864: a6xx_hwsched_power_off(adreno_dev);
865:
866: adreno_get_gpu_halt(adreno_dev);
867:
868: set_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags);
869:
870: kgsl_pwrctrl_set_state(device, KGSL_STATE_SUSPEND);
871:
872: return 0;
873:
874: err:
875: adreno_hwsched_start(adreno_dev);
876:
877: return ret;
878: }
879:
880: void a6xx_hwsched_handle_watchdog(struct adreno_device *adreno_dev)
881: {
882: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
883: u32 mask;
884:
885: /* Temporarily mask the watchdog interrupt to prevent a storm */
886: gmu_core_regread(device, A6XX_GMU_AO_HOST_INTERRUPT_MASK,
887: &mask);
888: gmu_core_regwrite(device, A6XX_GMU_AO_HOST_INTERRUPT_MASK,
889: (mask | GMU_INT_WDOG_BITE));
890:
891: a6xx_gmu_send_nmi(device, false, GMU_FAULT_PANIC_NONE);
892:
893: dev_err_ratelimited(GMU_PDEV_DEV(device),
894: "GMU watchdog expired interrupt received\n");
895:
896: adreno_scheduler_fault(adreno_dev, ADRENO_GMU_FAULT);
897: }
898:
899: static void a6xx_hwsched_pm_resume(struct adreno_device *adreno_dev)
900: {
901: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
902:
903: if (WARN(!test_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags),
904: "resume invoked without a suspend\n"))
905: return;
906:
907: adreno_put_gpu_halt(adreno_dev);
908:
909: adreno_hwsched_start(adreno_dev);
910:
911: clear_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags);
912: }
913:
914: static void a6xx_hwsched_drain_ctxt_unregister(struct adreno_device *adreno_dev)
915: {
916: struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
917: struct pending_cmd *cmd = NULL;
918:
919: read_lock(&hfi->msglock);
920:
921: list_for_each_entry(cmd, &hfi->msglist, node) {
922: if (MSG_HDR_GET_ID(cmd->sent_hdr) == H2F_MSG_UNREGISTER_CONTEXT)
923: complete(&cmd->complete);
924: }
925:
926: read_unlock(&hfi->msglock);
927: }
928:
929: int a6xx_hwsched_reset_replay(struct adreno_device *adreno_dev)
930: {
931: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
932: int ret;
933:
934: /*
935: * Any pending context unregister packets will be lost
936: * since we hard reset the GMU. This means any threads waiting
937: * for context unregister hfi ack will timeout. Wake them
938: * to avoid false positive ack timeout messages later.
939: */
940: a6xx_hwsched_drain_ctxt_unregister(adreno_dev);
941:
942: adreno_hwsched_unregister_contexts(adreno_dev);
943:
944: if (!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags))
945: return 0;
946:
947: a6xx_disable_gpu_irq(adreno_dev);
948:
949: a6xx_gmu_irq_disable(adreno_dev);
950:
951: a6xx_hwsched_hfi_stop(adreno_dev);
952:
953: a6xx_hwsched_gmu_suspend(adreno_dev, true);
954:
955: adreno_llcc_slice_deactivate(adreno_dev);
956:
957: clear_bit(GMU_PRIV_GPU_STARTED, &gmu->flags);
958:
959: ret = a6xx_hwsched_boot(adreno_dev);
960:
961: if (!ret)
962: adreno_hwsched_replay(adreno_dev);
963:
964: BUG_ON(ret);
965:
966: return ret;
967: }
968:
969: const struct adreno_power_ops a6xx_hwsched_power_ops = {
970: .first_open = a6xx_hwsched_first_open,
971: .last_close = a6xx_hwsched_power_off,
972: .active_count_get = a6xx_hwsched_active_count_get,
973: .touch_wakeup = a6xx_hwsched_touch_wakeup,
974: .pm_suspend = a6xx_hwsched_pm_suspend,
975: .pm_resume = a6xx_hwsched_pm_resume,
976: .gpu_clock_set = a6xx_hwsched_clock_set,
977: .gpu_bus_set = a6xx_hwsched_bus_set,
978: };
979:
980: const struct adreno_hwsched_ops a6xx_hwsched_ops = {
981: .submit_drawobj = a6xx_hwsched_submit_drawobj,
982: .preempt_count = a6xx_hwsched_preempt_count_get,
983: };
984:
985: int a6xx_hwsched_probe(struct platform_device *pdev,
986: u32 chipid, const struct adreno_gpu_core *gpucore)
987: {
988: struct adreno_device *adreno_dev;
989: struct kgsl_device *device;
990: struct a6xx_hwsched_device *a6xx_hwsched_dev;
991: int ret;
992:
993: a6xx_hwsched_dev = devm_kzalloc(&pdev->dev, sizeof(*a6xx_hwsched_dev),
994: GFP_KERNEL);
995: if (!a6xx_hwsched_dev)
996: return -ENOMEM;
997:
998: adreno_dev = &a6xx_hwsched_dev->a6xx_dev.adreno_dev;
999:
1000: adreno_dev->hwsched_enabled = true;
1001:
1002: adreno_dev->irq_mask = A6XX_HWSCHED_INT_MASK;
1003:
1004: ret = a6xx_probe_common(pdev, adreno_dev, chipid, gpucore);
1005: if (ret)
1006: return ret;
1007:
1008: device = KGSL_DEVICE(adreno_dev);
1009:
1010: INIT_WORK(&device->idle_check_ws, hwsched_idle_check);
1011:
1012: timer_setup(&device->idle_timer, hwsched_idle_timer, 0);
1013:
1014: return adreno_hwsched_init(adreno_dev, &a6xx_hwsched_ops);
1015: }
1016:
1017: int a6xx_hwsched_add_to_minidump(struct adreno_device *adreno_dev)
1018: {
1019: struct a6xx_device *a6xx_dev = container_of(adreno_dev,
1020: struct a6xx_device, adreno_dev);
1021: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1022: struct gmu_core_device *gmu_core = &device->gmu_core;
1023: struct a6xx_hwsched_device *a6xx_hwsched = container_of(a6xx_dev,
1024: struct a6xx_hwsched_device, a6xx_dev);
1025: struct a6xx_hwsched_hfi *hw_hfi = &a6xx_hwsched->hwsched_hfi;
1026: struct adreno_hwsched *hwsched = &adreno_dev->hwsched;
1027: int ret, i;
1028:
1029: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, KGSL_HWSCHED_DEVICE,
1030: (void *)(a6xx_hwsched), sizeof(struct a6xx_hwsched_device));
1031: if (ret)
1032: return ret;
1033:
1034: if (!IS_ERR_OR_NULL(a6xx_dev->gmu.gmu_log)) {
1035: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev,
1036: KGSL_GMU_LOG_ENTRY,
1037: a6xx_dev->gmu.gmu_log->hostptr,
1038: a6xx_dev->gmu.gmu_log->size);
1039: if (ret)
1040: return ret;
1041: }
1042:
1043: if (!IS_ERR_OR_NULL(a6xx_dev->gmu.hfi.hfi_mem)) {
1044: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev,
1045: KGSL_HFIMEM_ENTRY,
1046: a6xx_dev->gmu.hfi.hfi_mem->hostptr,
1047: a6xx_dev->gmu.hfi.hfi_mem->size);
1048: if (ret)
1049: return ret;
1050: }
1051:
1052: if (!IS_ERR_OR_NULL(gmu_core->vrb)) {
1053: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev,
1054: KGSL_GMU_VRB_ENTRY,
1055: gmu_core->vrb->hostptr,
1056: gmu_core->vrb->size);
1057: if (ret)
1058: return ret;
1059: }
1060:
1061: if (!IS_ERR_OR_NULL(a6xx_dev->gmu.dump_mem)) {
1062: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev,
1063: KGSL_GMU_DUMPMEM_ENTRY,
1064: a6xx_dev->gmu.dump_mem->hostptr,
1065: a6xx_dev->gmu.dump_mem->size);
1066: if (ret)
1067: return ret;
1068: }
1069:
1070: if (!IS_ERR_OR_NULL(gmu_core->trace.md)) {
1071: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev,
1072: KGSL_GMU_TRACE_ENTRY,
1073: gmu_core->trace.md->hostptr,
1074: gmu_core->trace.md->size);
1075: if (ret)
1076: return ret;
1077: }
1078:
1079: /* Dump HFI hwsched global mem alloc entries */
1080: for (i = 0; i < hwsched->mem_alloc_entries; i++) {
1081: struct hfi_mem_alloc_entry *entry = &hwsched->mem_alloc_table[i];
1082: char hfi_minidump_str[MAX_VA_MINIDUMP_STR_LEN] = {0};
1083: char name[MAX_VA_MINIDUMP_STR_LEN];
1084: u32 rb_id = 0;
1085:
1086: if (!hfi_get_minidump_string(entry->desc.mem_kind,
1087: &hfi_minidump_str[0],
1088: sizeof(hfi_minidump_str), &rb_id)) {
1089: snprintf(name, sizeof(name), "kgsl_global_%s", hfi_minidump_str);
--- FILE: \adreno_a6xx_hwsched.h | HITS: 20 ---
MATCH LINES: 7, 8, 10, 13, 15, 16, 17, 19, 23, 32, 36, 43, 46, 52, 56, 59, 62, 65, 68, 78
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: #ifndef _ADRENO_A6XX_HWSCHED_H_
8: #define _ADRENO_A6XX_HWSCHED_H_
9:
10: #include "adreno_a6xx_hwsched_hfi.h"
11:
12: /**
13: * struct a6xx_hwsched_device - Container for the a6xx hwscheduling device
14: */
15: struct a6xx_hwsched_device {
16: /** @a6xx_dev: Container for the a6xx device */
17: struct a6xx_device a6xx_dev;
18: /** @hwsched_hfi: Container for hwscheduling specific hfi resources */
19: struct a6xx_hwsched_hfi hwsched_hfi;
20: };
21:
22: /**
23: * a6xx_hwsched_probe - Target specific probe for hwsched
24: * @pdev: Pointer to the platform device
25: * @chipid: Chipid of the target
26: * @gpucore: Pointer to the gpucore
27: *
28: * The target specific probe function for hwsched enabled gmu targets.
29: *
30: * Return: 0 on success or negative error on failure
31: */
32: int a6xx_hwsched_probe(struct platform_device *pdev,
33: u32 chipid, const struct adreno_gpu_core *gpucore);
34:
35: /**
36: * a6xx_hwsched_reset_replay - Restart the gmu and gpu
37: * @adreno_dev: Pointer to the adreno device
38: *
39: * Restart the GMU and GPU and replay the inflight commands
40:
41: * Return: 0 on success or negative error on failure
42: */
43: int a6xx_hwsched_reset_replay(struct adreno_device *adreno_dev);
44:
45: /**
46: * a6xx_hwsched_snapshot - take a6xx hwsched snapshot
47: * @adreno_dev: Pointer to the adreno device
48: * @snapshot: Pointer to the snapshot instance
49: *
50: * Snapshot the faulty ib and then snapshot rest of a6xx gmu things
51: */
52: void a6xx_hwsched_snapshot(struct adreno_device *adreno_dev,
53: struct kgsl_snapshot *snapshot);
54:
55: /**
56: * a6xx_hwsched_handle_watchdog - Handle watchdog interrupt
57: * @adreno_dev: Pointer to the adreno device
58: */
59: void a6xx_hwsched_handle_watchdog(struct adreno_device *adreno_dev);
60:
61: /**
62: * a6xx_hwsched_add_to_minidump - Register hwsched_device with va minidump
63: * @adreno_dev: Pointer to the adreno device
64: */
65: int a6xx_hwsched_add_to_minidump(struct adreno_device *adreno_dev);
66:
67: /**
68: * a6xx_hwsched_send_recurring_cmdobj - Dispatch IBs to GMU
69: * @adreno_dev: Pointer to adreno device structure
70: * @cmdobj: The command object which needs to be submitted
71: *
72: * This function is used to register the context if needed and submit
73: * recurring IBs to the GMU. Upon receiving ipc interrupt GMU will submit
74: * recurring IBs to GPU.
75:
76: * Return: 0 on success and negative error on failure
77: */
78: int a6xx_hwsched_send_recurring_cmdobj(struct adreno_device *adreno_dev,
79: struct kgsl_drawobj_cmd *cmdobj);
80: #endif
--- FILE: \adreno_a6xx_hwsched_hfi.c | HITS: 145 ---
MATCH LINES: 11, 48, 55, 59, 62, 63, 64, 65, 67, 70, 83, 90, 92
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 <linux/iommu.h>
8:
9: #include "adreno.h"
10: #include "adreno_a6xx.h"
11: #include "adreno_a6xx_hwsched.h"
12: #include "adreno_hfi.h"
13: #include "adreno_perfcounter.h"
14: #include "adreno_pm4types.h"
15: #include "adreno_trace.h"
16: #include "kgsl_device.h"
17: #include "kgsl_eventlog.h"
18: #include "kgsl_gmu_core.h"
19: #include "kgsl_pwrctrl.h"
20: #include "kgsl_trace.h"
21: #include "kgsl_util.h"
22:
23: #define HFI_QUEUE_MAX (HFI_QUEUE_DEFAULT_CNT + HFI_QUEUE_DISPATCH_MAX_CNT)
24:
25: #define DEFINE_QHDR(gmuaddr, id, prio) \
26: {\
27: .status = 1, \
28: .start_addr = GMU_QUEUE_START_ADDR(gmuaddr, id), \
29: .type = QUEUE_HDR_TYPE(id, prio, 0, 0), \
30: .queue_size = SZ_4K >> 2, \
31: .msg_size = 0, \
32: .unused0 = 0, \
33: .unused1 = 0, \
34: .unused2 = 0, \
35: .unused3 = 0, \
36: .unused4 = 0, \
37: .read_index = 0, \
38: .write_index = 0, \
39: }
40:
41: static struct dq_info {
42: /** @max_dq: Maximum number of dispatch queues per RB level */
43: u32 max_dq;
44: /** @base_dq_id: Base dqid for level */
45: u32 base_dq_id;
46: /** @offset: Next dqid to use for roundrobin context assignment */
47: u32 offset;
48: } a6xx_hfi_dqs[KGSL_PRIORITY_MAX_RB_LEVELS] = {
49: { 4, 0, }, /* RB0 */
50: { 4, 4, }, /* RB1 */
51: { 3, 8, }, /* RB2 */
52: { 3, 11, }, /* RB3 */
53: };
54:
55: static int a6xx_hfi_dispatch_queue_write(struct adreno_device *adreno_dev, uint32_t queue_idx,
56: uint32_t *msg, u32 size_bytes, struct kgsl_drawobj_cmd *cmdobj,
57: struct adreno_submit_time *time);
58:
59: struct a6xx_hwsched_hfi *to_a6xx_hwsched_hfi(
60: struct adreno_device *adreno_dev)
61: {
62: struct a6xx_device *a6xx_dev = container_of(adreno_dev,
63: struct a6xx_device, adreno_dev);
64: struct a6xx_hwsched_device *a6xx_hwsched = container_of(a6xx_dev,
65: struct a6xx_hwsched_device, a6xx_dev);
66:
67: return &a6xx_hwsched->hwsched_hfi;
68: }
69:
70: static void add_waiter(struct a6xx_hwsched_hfi *hfi, u32 hdr,
71: struct pending_cmd *ack)
72: {
73: memset(ack, 0x0, sizeof(*ack));
74:
75: init_completion(&ack->complete);
76: write_lock_irq(&hfi->msglock);
77: list_add_tail(&ack->node, &hfi->msglist);
78: write_unlock_irq(&hfi->msglock);
79:
80: ack->sent_hdr = hdr;
81: }
82:
83: static void del_waiter(struct a6xx_hwsched_hfi *hfi, struct pending_cmd *ack)
84: {
85: write_lock_irq(&hfi->msglock);
86: list_del(&ack->node);
87: write_unlock_irq(&hfi->msglock);
88: }
89:
90: static void a6xx_receive_ack_async(struct adreno_device *adreno_dev, void *rcvd)
91: {
92: struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
93: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
94: struct pending_cmd *cmd = NULL;
95: u32 waiters[64], num_waiters = 0, i;
96: u32 *ack = rcvd;
97: u32 hdr = ack[0];
98: u32 req_hdr = ack[1];
99: u32 size_bytes = MSG_HDR_GET_SIZE(hdr) << 2;
100:
101: if (size_bytes > sizeof(cmd->results))
102: dev_err_ratelimited(gmu_pdev_dev,
103: "Ack result too big: %d Truncating to: %ld\n",
104: size_bytes, sizeof(cmd->results));
105:
106: read_lock(&hfi->msglock);
107:
108: list_for_each_entry(cmd, &hfi->msglist, node) {
109: if (CMP_HFI_ACK_HDR(cmd->sent_hdr, req_hdr)) {
110: memcpy(cmd->results, ack,
111: min_t(u32, size_bytes,
112: sizeof(cmd->results)));
113: complete(&cmd->complete);
114: read_unlock(&hfi->msglock);
115: return;
116: }
MATCH LINES: 138
126: "Unexpectedly got id %d seqnum %d. Total waiters: %d Top %d Waiters:\n",
127: MSG_HDR_GET_ID(req_hdr), MSG_HDR_GET_SEQNUM(req_hdr),
128: num_waiters, min_t(u32, num_waiters, 5));
129:
130: for (i = 0; i < num_waiters && i < 5; i++)
131: dev_err_ratelimited(gmu_pdev_dev,
132: " id %d seqnum %d\n",
133: MSG_HDR_GET_ID(waiters[i]),
134: MSG_HDR_GET_SEQNUM(waiters[i]));
135: }
136:
137: /* Look up a particular key's value for a given type of payload */
138: static u32 a6xx_hwsched_lookup_key_value_legacy(struct adreno_device *adreno_dev,
139: u32 type, u32 key)
140: {
141: struct hfi_context_bad_cmd_legacy *cmd = adreno_dev->hwsched.ctxt_bad;
142: u32 i = 0, payload_bytes;
143: void *start;
144:
145: if (!cmd->hdr)
146: return 0;
147:
148: payload_bytes = (MSG_HDR_GET_SIZE(cmd->hdr) << 2) -
149: offsetof(struct hfi_context_bad_cmd_legacy, payload);
150:
151: start = &cmd->payload[0];
152:
153: while (i < payload_bytes) {
154: struct payload_section *payload = start + i;
155:
156: if (payload->type == type)
157: return adreno_hwsched_parse_payload(payload, key);
158:
159: i += struct_size(payload, data, payload->dwords);
160: }
161:
162: return 0;
MATCH LINES: 181, 185, 203, 209, 211, 235
169:
170: switch (cmd->error) {
171: case GMU_GPU_HW_HANG:
172: dev_crit_ratelimited(gmu_pdev_dev, "MISC: GPU hang detected\n");
173: break;
174: case GMU_GPU_SW_HANG:
175: dev_crit_ratelimited(gmu_pdev_dev, "gpu timeout ctx %u ts %u\n",
176: cmd->ctxt_id, cmd->ts);
177: break;
178: case GMU_CP_OPCODE_ERROR:
179: dev_crit_ratelimited(gmu_pdev_dev,
180: "CP opcode error interrupt | opcode=0x%8.8x\n",
181: a6xx_hwsched_lookup_key_value_legacy(adreno_dev, PAYLOAD_FAULT_REGS,
182: KEY_CP_OPCODE_ERROR));
183: break;
184: case GMU_CP_PROTECTED_ERROR: {
185: u32 status = a6xx_hwsched_lookup_key_value_legacy(adreno_dev, PAYLOAD_FAULT_REGS,
186: KEY_CP_PROTECTED_ERROR);
187:
188: dev_crit_ratelimited(gmu_pdev_dev,
189: "CP | Protected mode error | %s | addr=0x%5.5x | status=0x%8.8x\n",
190: status & (1 << 20) ? "READ" : "WRITE",
191: status & 0x3FFFF, status);
192: }
193: break;
194: case GMU_CP_ILLEGAL_INST_ERROR:
195: dev_crit_ratelimited(gmu_pdev_dev, "CP Illegal instruction error\n");
196: break;
197: case GMU_CP_UCODE_ERROR:
198: dev_crit_ratelimited(gmu_pdev_dev, "CP ucode error interrupt\n");
199: break;
200: case GMU_CP_HW_FAULT_ERROR:
201: dev_crit_ratelimited(gmu_pdev_dev,
202: "CP | Ringbuffer HW fault | status=0x%8.8x\n",
203: a6xx_hwsched_lookup_key_value_legacy(adreno_dev, PAYLOAD_FAULT_REGS,
204: KEY_CP_HW_FAULT));
205: break;
206: case GMU_GPU_PREEMPT_TIMEOUT: {
207: u32 cur, next, cur_rptr, cur_wptr, next_rptr, next_wptr;
208:
209: cur = a6xx_hwsched_lookup_key_value_legacy(adreno_dev,
210: PAYLOAD_PREEMPT_TIMEOUT, KEY_PREEMPT_TIMEOUT_CUR_RB_ID);
211: next = a6xx_hwsched_lookup_key_value_legacy(adreno_dev,
212: PAYLOAD_PREEMPT_TIMEOUT,
213: KEY_PREEMPT_TIMEOUT_NEXT_RB_ID);
214: cur_rptr = adreno_hwsched_get_payload_rb_key_legacy(adreno_dev, cur, KEY_RB_RPTR);
215: cur_wptr = adreno_hwsched_get_payload_rb_key_legacy(adreno_dev, cur, KEY_RB_WPTR);
216: next_rptr = adreno_hwsched_get_payload_rb_key_legacy(adreno_dev, next, KEY_RB_RPTR);
217: next_wptr = adreno_hwsched_get_payload_rb_key_legacy(adreno_dev, next, KEY_RB_WPTR);
218:
219: dev_crit_ratelimited(gmu_pdev_dev,
220: "Preemption Fault: cur=%d R/W=0x%x/0x%x, next=%d R/W=0x%x/0x%x\n",
221: cur, cur_rptr, cur_wptr, next, next_rptr, next_wptr);
222: }
223: break;
224: case GMU_CP_GPC_ERROR:
225: dev_crit_ratelimited(gmu_pdev_dev, "RBBM: GPC error\n");
226: break;
227: default:
228: dev_crit_ratelimited(gmu_pdev_dev, "Unknown GPU fault: %u\n",
229: cmd->error);
230: break;
231: }
232: }
233:
234: /* Look up a particular key's value for a given type of payload */
235: static u32 a6xx_hwsched_lookup_key_value(struct adreno_device *adreno_dev,
236: u32 type, u32 key)
237: {
238: struct hfi_context_bad_cmd *cmd = adreno_dev->hwsched.ctxt_bad;
239: u32 i = 0, payload_bytes;
240: void *start;
241:
242: if (!cmd->hdr)
243: return 0;
244:
245: payload_bytes = (MSG_HDR_GET_SIZE(cmd->hdr) << 2) -
246: offsetof(struct hfi_context_bad_cmd, payload);
247:
248: start = &cmd->payload[0];
249:
250: while (i < payload_bytes) {
251: struct payload_section *payload = start + i;
252:
253: if (payload->type == type)
254: return adreno_hwsched_parse_payload(payload, key);
255:
256: i += struct_size(payload, data, payload->dwords);
257: }
258:
259: return 0;
MATCH LINES: 278, 282, 300, 306, 308, 343, 361, 363, 364, 379, 386, 394, 411, 427, 429, 433, 436, 442, 459, 462, 463, 468, 471, 472
266:
267: switch (cmd->error) {
268: case GMU_GPU_HW_HANG:
269: dev_crit_ratelimited(gmu_pdev_dev, "MISC: GPU hang detected\n");
270: break;
271: case GMU_GPU_SW_HANG:
272: dev_crit_ratelimited(gmu_pdev_dev, "gpu timeout ctx %u ts %u\n",
273: cmd->gc.ctxt_id, cmd->gc.ts);
274: break;
275: case GMU_CP_OPCODE_ERROR:
276: dev_crit_ratelimited(gmu_pdev_dev,
277: "CP opcode error interrupt | opcode=0x%8.8x\n",
278: a6xx_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS,
279: KEY_CP_OPCODE_ERROR));
280: break;
281: case GMU_CP_PROTECTED_ERROR: {
282: u32 status = a6xx_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS,
283: KEY_CP_PROTECTED_ERROR);
284:
285: dev_crit_ratelimited(gmu_pdev_dev,
286: "CP | Protected mode error | %s | addr=0x%5.5x | status=0x%8.8x\n",
287: status & (1 << 20) ? "READ" : "WRITE",
288: status & 0x3FFFF, status);
289: }
290: break;
291: case GMU_CP_ILLEGAL_INST_ERROR:
292: dev_crit_ratelimited(gmu_pdev_dev, "CP Illegal instruction error\n");
293: break;
294: case GMU_CP_UCODE_ERROR:
295: dev_crit_ratelimited(gmu_pdev_dev, "CP ucode error interrupt\n");
296: break;
297: case GMU_CP_HW_FAULT_ERROR:
298: dev_crit_ratelimited(gmu_pdev_dev,
299: "CP | Ringbuffer HW fault | status=0x%8.8x\n",
300: a6xx_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS,
301: KEY_CP_HW_FAULT));
302: break;
303: case GMU_GPU_PREEMPT_TIMEOUT: {
304: u32 cur, next, cur_rptr, cur_wptr, next_rptr, next_wptr;
305:
306: cur = a6xx_hwsched_lookup_key_value(adreno_dev,
307: PAYLOAD_PREEMPT_TIMEOUT, KEY_PREEMPT_TIMEOUT_CUR_RB_ID);
308: next = a6xx_hwsched_lookup_key_value(adreno_dev,
309: PAYLOAD_PREEMPT_TIMEOUT,
310: KEY_PREEMPT_TIMEOUT_NEXT_RB_ID);
311: cur_rptr = adreno_hwsched_get_payload_rb_key(adreno_dev, cur, KEY_RB_RPTR);
312: cur_wptr = adreno_hwsched_get_payload_rb_key(adreno_dev, cur, KEY_RB_WPTR);
313: next_rptr = adreno_hwsched_get_payload_rb_key(adreno_dev, next, KEY_RB_RPTR);
314: next_wptr = adreno_hwsched_get_payload_rb_key(adreno_dev, next, KEY_RB_WPTR);
315:
316: dev_crit_ratelimited(gmu_pdev_dev,
317: "Preemption Fault: cur=%d R/W=0x%x/0x%x, next=%d R/W=0x%x/0x%x\n",
318: cur, cur_rptr, cur_wptr, next, next_rptr, next_wptr);
319: }
320: break;
321: case GMU_CP_GPC_ERROR:
322: dev_crit_ratelimited(gmu_pdev_dev, "RBBM: GPC error\n");
323: break;
324: default:
325: dev_crit_ratelimited(gmu_pdev_dev, "Unknown GPU fault: %u\n",
326: cmd->error);
327: break;
328: }
329: }
330:
331: static void process_ctx_bad(struct adreno_device *adreno_dev)
332: {
333: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
334:
335: if (GMU_VER_MINOR(device->gmu_core.ver.hfi) < 2)
336: log_gpu_fault_legacy(adreno_dev);
337: else
338: log_gpu_fault(adreno_dev);
339:
340: adreno_scheduler_fault(adreno_dev, ADRENO_HARD_FAULT);
341: }
342:
343: static u32 peek_next_header(struct a6xx_gmu_device *gmu, uint32_t queue_idx)
344: {
345: struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
346: struct hfi_queue_table *tbl = mem_addr->hostptr;
347: struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];
348: u32 *queue;
349:
350: if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
351: return 0;
352:
353: if (hdr->read_index == hdr->write_index)
354: return 0;
355:
356: queue = HOST_QUEUE_START_ADDR(mem_addr, queue_idx);
357:
358: return queue[hdr->read_index];
359: }
360:
361: static void a6xx_hwsched_process_msgq(struct adreno_device *adreno_dev)
362: {
363: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
364: struct a6xx_hwsched_hfi *hw_hfi = to_a6xx_hwsched_hfi(adreno_dev);
365: u32 rcvd[MAX_RCVD_SIZE], next_hdr;
366:
367: if (!(hw_hfi->irq_mask & HFI_IRQ_MSGQ_MASK))
368: return;
369:
370: mutex_lock(&hw_hfi->msgq_mutex);
371:
372: for (;;) {
373: next_hdr = peek_next_header(gmu, HFI_MSG_ID);
374:
375: if (!next_hdr)
376: break;
377:
378: if (MSG_HDR_GET_ID(next_hdr) == F2H_MSG_CONTEXT_BAD) {
379: a6xx_hfi_queue_read(gmu, HFI_MSG_ID,
380: (u32 *)adreno_dev->hwsched.ctxt_bad,
381: HFI_MAX_MSG_SIZE);
382: process_ctx_bad(adreno_dev);
383: continue;
384: }
385:
386: a6xx_hfi_queue_read(gmu, HFI_MSG_ID, rcvd, sizeof(rcvd));
387:
388: /*
389: * We are assuming that there is only one outstanding ack
390: * because hfi sending thread waits for completion while
391: * holding the device mutex
392: */
393: if (MSG_HDR_GET_TYPE(rcvd[0]) == HFI_MSG_ACK) {
394: a6xx_receive_ack_async(adreno_dev, rcvd);
395: } else if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_TS_RETIRE) {
396: adreno_scheduler_queue(adreno_dev);
397: adreno_hwsched_log_profiling_info(adreno_dev, rcvd);
398: } else if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_GMU_CNTR_RELEASE) {
399: struct hfi_gmu_cntr_release_cmd *cmd =
400: (struct hfi_gmu_cntr_release_cmd *) rcvd;
401:
402: adreno_perfcounter_put(adreno_dev,
403: cmd->group_id, cmd->countable, PERFCOUNTER_FLAG_KERNEL);
404: }
405: }
406: mutex_unlock(&hw_hfi->msgq_mutex);
407: }
408:
409: static void process_log_block(struct adreno_device *adreno_dev, void *data)
410: {
411: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
412: struct hfi_log_block *cmd = data;
413: u32 *log_event = gmu->gmu_log->hostptr;
414: u32 start, end;
415:
416: start = cmd->start_index;
417: end = cmd->stop_index;
418:
419: log_event += start * 4;
420: while (start != end) {
421: trace_gmu_event(log_event);
422: log_event += 4;
423: start++;
424: }
425: }
426:
427: static void a6xx_hwsched_process_dbgq(struct adreno_device *adreno_dev, bool limited)
428: {
429: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
430: u32 rcvd[MAX_RCVD_SIZE];
431: bool recovery = false;
432:
433: while (a6xx_hfi_queue_read(gmu, HFI_DBG_ID, rcvd, sizeof(rcvd)) > 0) {
434:
435: if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_ERR) {
436: adreno_a6xx_receive_err_req(gmu, rcvd);
437: recovery = true;
438: break;
439: }
440:
441: if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_DEBUG)
442: adreno_a6xx_receive_debug_req(gmu, rcvd);
443:
444: if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_LOG_BLOCK)
445: process_log_block(adreno_dev, rcvd);
446:
447: /* Process one debug queue message and return to not delay msgq processing */
448: if (limited)
449: break;
450: }
451:
452: if (!recovery)
453: return;
454:
455: adreno_scheduler_fault(adreno_dev, ADRENO_GMU_FAULT);
456: }
457:
458: /* HFI interrupt handler */
459: static irqreturn_t a6xx_hwsched_hfi_handler(int irq, void *data)
460: {
461: struct adreno_device *adreno_dev = data;
462: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
463: struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
464: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
465: u32 status = 0;
466:
467: /*
468: * A6XX_GMU_GMU2HOST_INTR_INFO may have bits set not specified in hfi->irq_mask.
469: * Read and clear only those irq bits that we are processing here.
470: */
471: gmu_core_regread(device, A6XX_GMU_GMU2HOST_INTR_INFO, &status);
472: gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_CLR, status & hfi->irq_mask);
473:
474: /*
475: * If interrupts are not enabled on the HFI message queue,
476: * the inline message processing loop will process it,
477: * else, process it here.
478: */
479: if (!(hfi->irq_mask & HFI_IRQ_MSGQ_MASK))
480: status &= ~HFI_IRQ_MSGQ_MASK;
481:
482: if (status & (HFI_IRQ_MSGQ_MASK | HFI_IRQ_DBGQ_MASK)) {
483: wake_up_interruptible(&hfi->f2h_wq);
484: adreno_scheduler_queue(adreno_dev);
485: }
486: if (status & HFI_IRQ_CM3_FAULT_MASK) {
487: atomic_set(&gmu->cm3_fault, 1);
488:
489: /* make sure other CPUs see the update */
490: smp_wmb();
491:
492: dev_err_ratelimited(GMU_PDEV_DEV(device),
493: "GMU CM3 fault interrupt received\n");
494:
495: adreno_scheduler_fault(adreno_dev, ADRENO_GMU_FAULT);
496: }
MATCH LINES: 531, 533, 534, 546, 551, 563
519: return 0;
520:
521: dev_err(GMU_PDEV_DEV(device),
522: "ACK error: sender id %d seqnum %d\n",
523: MSG_HDR_GET_ID(ack->sent_hdr),
524: MSG_HDR_GET_SEQNUM(ack->sent_hdr));
525:
526: KGSL_GMU_CORE_FORCE_PANIC(device->gmu_core.gf_panic,
527: GMU_PDEV(device), ticks, GMU_FAULT_HFI_ACK);
528: return -EINVAL;
529: }
530:
531: int a6xx_hfi_send_cmd_async(struct adreno_device *adreno_dev, void *data, u32 size_bytes)
532: {
533: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
534: struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
535: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
536: u32 *cmd = data;
537: u32 seqnum;
538: int rc;
539: struct pending_cmd pending_ack;
540:
541: seqnum = atomic_inc_return(&gmu->hfi.seqnum);
542: *cmd = MSG_HDR_SET_SEQNUM_SIZE(*cmd, seqnum, size_bytes >> 2);
543:
544: add_waiter(hfi, *cmd, &pending_ack);
545:
546: rc = a6xx_hfi_cmdq_write(adreno_dev, cmd, size_bytes);
547: if (rc)
548: goto done;
549:
550: rc = adreno_hwsched_wait_ack_completion(adreno_dev,
551: GMU_PDEV_DEV(device), &pending_ack, a6xx_hwsched_process_msgq);
552: if (rc)
553: goto done;
554:
555: rc = check_ack_failure(adreno_dev, &pending_ack);
556:
557: done:
558: del_waiter(hfi, &pending_ack);
559:
560: return rc;
561: }
562:
563: static void init_queues(struct a6xx_hfi *hfi)
564: {
565: u32 gmuaddr = hfi->hfi_mem->gmuaddr;
566: struct hfi_queue_table hfi_table = {
567: .qtbl_hdr = {
568: .version = 0,
569: .size = sizeof(struct hfi_queue_table) >> 2,
570: .qhdr0_offset =
571: sizeof(struct hfi_queue_table_header) >> 2,
572: .qhdr_size = sizeof(struct hfi_queue_header) >> 2,
573: .num_q = HFI_QUEUE_MAX,
574: .num_active_q = HFI_QUEUE_MAX,
575: },
576: .qhdr = {
577: DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
578: DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
579: DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
580: /* 4 DQs for RB priority 0 */
581: DEFINE_QHDR(gmuaddr, 3, 0),
582: DEFINE_QHDR(gmuaddr, 4, 0),
583: DEFINE_QHDR(gmuaddr, 5, 0),
584: DEFINE_QHDR(gmuaddr, 6, 0),
585: /* 4 DQs for RB priority 1 */
586: DEFINE_QHDR(gmuaddr, 7, 1),
587: DEFINE_QHDR(gmuaddr, 8, 1),
MATCH LINES: 610, 612, 613
598: },
599: };
600:
601: memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
602: }
603:
604: /* Total header sizes + queue sizes + 16 for alignment */
605: #define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
606: (SZ_4K * HFI_QUEUE_MAX))
607:
608: static int hfi_f2h_main(void *arg);
609:
610: int a6xx_hwsched_hfi_init(struct adreno_device *adreno_dev)
611: {
612: struct a6xx_hwsched_hfi *hw_hfi = to_a6xx_hwsched_hfi(adreno_dev);
613: struct a6xx_hfi *hfi = to_a6xx_hfi(adreno_dev);
614: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
615:
616: if (IS_ERR_OR_NULL(hw_hfi->big_ib)) {
617: hw_hfi->big_ib = gmu_core_reserve_kernel_block(device,
618: 0,
619: HWSCHED_MAX_IBS * sizeof(struct hfi_issue_ib),
620: GMU_NONCACHED_KERNEL, 0);
621: if (IS_ERR(hw_hfi->big_ib))
622: return PTR_ERR(hw_hfi->big_ib);
623: }
624:
625: if (ADRENO_FEATURE(adreno_dev, ADRENO_LSR) &&
626: IS_ERR_OR_NULL(hw_hfi->big_ib_recurring)) {
627: hw_hfi->big_ib_recurring = gmu_core_reserve_kernel_block(
628: device, 0,
629: HWSCHED_MAX_IBS * sizeof(struct hfi_issue_ib),
630: GMU_NONCACHED_KERNEL, 0);
631: if (IS_ERR(hw_hfi->big_ib_recurring))
632: return PTR_ERR(hw_hfi->big_ib_recurring);
633: }
634:
635: if (IS_ERR_OR_NULL(hfi->hfi_mem)) {
636: hfi->hfi_mem = gmu_core_reserve_kernel_block(device,
637: 0, HFIMEM_SIZE, GMU_NONCACHED_KERNEL, 0);
MATCH LINES: 653, 670, 677, 697, 702, 720, 735, 753, 774, 785, 800, 802, 803, 812, 815, 824, 828, 849, 858, 865, 878, 881, 890, 896, 898, 904, 908, 913, 917, 921, 925, 929, 933, 938, 944, 950, 959, 963, 965, 985, 995, 1000, 1002, 1009, 1013, 1025, 1032, 1034, 1040, 1042, 1049, 1055, 1080, 1092, 1125, 1129, 1134, 1138, 1154, 1158, 1159, 1182, 1199, 1215, 1218, 1224, 1226, 1227, 1232, 1250, 1252, 1260
641: }
642:
643: if (IS_ERR_OR_NULL(hw_hfi->f2h_task))
644: hw_hfi->f2h_task = kthread_run(hfi_f2h_main, adreno_dev, "gmu_f2h");
645:
646: return PTR_ERR_OR_ZERO(hw_hfi->f2h_task);
647: }
648:
649: static int mem_alloc_reply(struct adreno_device *adreno_dev, void *rcvd)
650: {
651: struct hfi_mem_alloc_desc desc = {0};
652: struct hfi_mem_alloc_reply_cmd out = {0};
653: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
654: u32 seqnum;
655: int ret;
656:
657: hfi_get_mem_alloc_desc(rcvd, &desc);
658:
659: ret = adreno_hwsched_process_mem_alloc(adreno_dev, &desc);
660: if (ret)
661: return ret;
662:
663: memcpy(&out.desc, &desc, sizeof(out.desc));
664:
665: out.hdr = ACK_MSG_HDR(F2H_MSG_MEM_ALLOC);
666: seqnum = atomic_inc_return(&gmu->hfi.seqnum);
667: out.hdr = MSG_HDR_SET_SEQNUM_SIZE(out.hdr, seqnum, sizeof(out) >> 2);
668: out.req_hdr = *(u32 *)rcvd;
669:
670: return a6xx_hfi_cmdq_write(adreno_dev, (u32 *)&out, sizeof(out));
671: }
672:
673: static int gmu_cntr_register_reply(struct adreno_device *adreno_dev, void *rcvd)
674: {
675: struct hfi_gmu_cntr_register_cmd *in = (struct hfi_gmu_cntr_register_cmd *)rcvd;
676: struct hfi_gmu_cntr_register_reply_cmd out = {0};
677: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
678: u32 lo = 0, hi = 0, seqnum;
679:
680: /*
681: * Failure to allocate counter is not fatal. Sending lo = 0, hi = 0
682: * indicates to GMU that counter allocation failed.
683: */
684: adreno_perfcounter_get(adreno_dev,
685: in->group_id, in->countable, &lo, &hi, PERFCOUNTER_FLAG_KERNEL);
686:
687: out.hdr = ACK_MSG_HDR(F2H_MSG_GMU_CNTR_REGISTER);
688: seqnum = atomic_inc_return(&gmu->hfi.seqnum);
689: out.hdr = MSG_HDR_SET_SEQNUM_SIZE(out.hdr, seqnum, sizeof(out) >> 2);
690: out.req_hdr = in->hdr;
691: out.group_id = in->group_id;
692: out.countable = in->countable;
693: /* Fill in byte offset of counter */
694: out.cntr_lo = lo << 2;
695: out.cntr_hi = hi << 2;
696:
697: return a6xx_hfi_cmdq_write(adreno_dev, (u32 *)&out, sizeof(out));
698: }
699:
700: static int send_start_msg(struct adreno_device *adreno_dev)
701: {
702: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
703: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
704: struct device *gmu_pdev_dev = GMU_PDEV_DEV(device);
705: u32 seqnum;
706: int rc;
707: struct hfi_start_cmd cmd;
708: u32 rcvd[MAX_RCVD_SIZE];
709: struct pending_cmd pending_ack = {0};
710:
711: rc = CMD_MSG_HDR(cmd, H2F_MSG_START);
712: if (rc)
713: return rc;
714:
715: seqnum = atomic_inc_return(&gmu->hfi.seqnum);
716: cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
717:
718: pending_ack.sent_hdr = cmd.hdr;
719:
720: rc = a6xx_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
721: if (rc)
722: return rc;
723:
724: poll:
725: rc = adreno_hwsched_poll_msg_queue_write_index(gmu->hfi.hfi_mem);
726:
727: if (rc) {
728: dev_err(gmu_pdev_dev,
729: "Timed out processing MSG_START seqnum: %d\n",
730: seqnum);
731: gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START);
732: goto done;
733: }
734:
735: rc = a6xx_hfi_queue_read(gmu, HFI_MSG_ID, rcvd, sizeof(rcvd));
736: if (rc <= 0) {
737: dev_err(gmu_pdev_dev,
738: "MSG_START: payload error: %d\n",
739: rc);
740: gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START);
741: goto done;
742: }
743:
744: switch (MSG_HDR_GET_ID(rcvd[0])) {
745: case F2H_MSG_MEM_ALLOC:
746: rc = mem_alloc_reply(adreno_dev, rcvd);
747: break;
748: case F2H_MSG_GMU_CNTR_REGISTER:
749: rc = gmu_cntr_register_reply(adreno_dev, rcvd);
750: break;
751: default:
752: if (MSG_HDR_GET_TYPE(rcvd[0]) == HFI_MSG_ACK) {
753: rc = a6xx_receive_ack_cmd(gmu, rcvd, &pending_ack);
754: /* Check ack failure if we received an expected ack */
755: if (!rc)
756: rc = check_ack_failure(adreno_dev, &pending_ack);
757: goto done;
758: } else {
759: dev_err(gmu_pdev_dev,
760: "MSG_START: unexpected response id:%d, type:%d\n",
761: MSG_HDR_GET_ID(rcvd[0]),
762: MSG_HDR_GET_TYPE(rcvd[0]));
763: gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START);
764: rc = -EINVAL;
765: goto done;
766: }
767: }
768:
769: if (!rc)
770: goto poll;
771:
772: done:
773: /* Clear the interrupt */
774: gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_CLR, HFI_IRQ_MSGQ_MASK);
775: /*
776: * Add a write barrier to post the interrupt clear so that we dont have a
777: * pending interrupt.
778: */
779: wmb();
780: return rc;
781: }
782:
783: static void reset_hfi_queues(struct adreno_device *adreno_dev)
784: {
785: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
786: struct hfi_queue_table *tbl = gmu->hfi.hfi_mem->hostptr;
787: u32 i;
788:
789: /* Flush HFI queues */
790: for (i = 0; i < HFI_QUEUE_MAX; i++) {
791: struct hfi_queue_header *hdr = &tbl->qhdr[i];
792:
793: if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
794: continue;
795:
796: hdr->read_index = hdr->write_index;
797: }
798: }
799:
800: void a6xx_hwsched_hfi_stop(struct adreno_device *adreno_dev)
801: {
802: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
803: struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
804:
805: hfi->irq_mask &= ~HFI_IRQ_MSGQ_MASK;
806:
807: /*
808: * In some corner cases, it is possible that GMU put TS_RETIRE
809: * on the msgq after we have turned off gmu interrupts. Hence,
810: * drain the queue one last time before we reset HFI queues.
811: */
812: a6xx_hwsched_process_msgq(adreno_dev);
813:
814: /* Drain the debug queue before we reset HFI queues */
815: a6xx_hwsched_process_dbgq(adreno_dev, false);
816:
817: kgsl_pwrctrl_axi(KGSL_DEVICE(adreno_dev), false);
818:
819: clear_bit(GMU_PRIV_HFI_STARTED, &gmu->flags);
820: }
821:
822: static void enable_async_hfi(struct adreno_device *adreno_dev)
823: {
824: struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
825:
826: hfi->irq_mask |= HFI_IRQ_MSGQ_MASK;
827:
828: gmu_core_regwrite(KGSL_DEVICE(adreno_dev), A6XX_GMU_GMU2HOST_INTR_MASK,
829: (u32)~hfi->irq_mask);
830: }
831:
832: static int enable_preemption(struct adreno_device *adreno_dev)
833: {
834: u32 data;
835: int ret;
836:
837: if (!adreno_is_preemption_enabled(adreno_dev))
838: return 0;
839:
840: /*
841: * Bits [0:1] contains the preemption level
842: * Bit 2 is to enable/disable gmem save/restore
843: * Bit 3 is to enable/disable skipsaverestore
844: */
845: data = FIELD_PREP(GENMASK(1, 0), adreno_dev->preempt.preempt_level) |
846: FIELD_PREP(BIT(2), adreno_dev->preempt.usesgmem) |
847: FIELD_PREP(BIT(3), adreno_dev->preempt.skipsaverestore);
848:
849: ret = a6xx_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_PREEMPTION, 1,
850: data);
851: if (ret)
852: return ret;
853:
854: /*
855: * Bits[3:0] contain the preemption timeout enable bit per ringbuffer
856: * Bits[31:4] contain the timeout in ms
857: */
858: return a6xx_hfi_send_set_value(adreno_dev, HFI_VALUE_BIN_TIME, 1,
859: FIELD_PREP(GENMASK(31, 4), ADRENO_PREEMPT_TIMEOUT) |
860: FIELD_PREP(GENMASK(3, 0), 0xf));
861: }
862:
863: static int enable_gmu_stats(struct adreno_device *adreno_dev)
864: {
865: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
866: u32 data;
867:
868: if (!gmu->stats_enable)
869: return 0;
870:
871: /*
872: * Bits [23:0] contains the countables mask
873: * Bits [31:24] is the sampling interval
874: */
875: data = FIELD_PREP(GENMASK(23, 0), gmu->stats_mask) |
876: FIELD_PREP(GENMASK(31, 24), gmu->stats_interval);
877:
878: return a6xx_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_GMU_STATS, 1, data);
879: }
880:
881: static int a6xx_hfi_send_perfcounter_feature_ctrl(struct adreno_device *adreno_dev)
882: {
883: /*
884: * Perfcounter retention is disabled by default in GMU firmware.
885: * In case perfcounter retention behaviour is overwritten by sysfs
886: * setting dynmaically, send this HFI feature with 'enable = 0' to
887: * disable this feature in GMU firmware.
888: */
889: if (adreno_dev->perfcounter)
890: return a6xx_hfi_send_feature_ctrl(adreno_dev,
891: HFI_FEATURE_PERF_NORETAIN, 0, 0);
892:
893: return 0;
894: }
895:
896: int a6xx_hwsched_hfi_start(struct adreno_device *adreno_dev)
897: {
898: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
899: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
900: int ret;
901:
902: reset_hfi_queues(adreno_dev);
903:
904: ret = a6xx_gmu_hfi_start(adreno_dev);
905: if (ret)
906: goto err;
907:
908: ret = a6xx_hfi_send_generic_req(adreno_dev, &gmu->hfi.dcvs_table,
909: sizeof(gmu->hfi.dcvs_table));
910: if (ret)
911: goto err;
912:
913: ret = a6xx_hfi_send_generic_req(adreno_dev, &gmu->hfi.bw_table, sizeof(gmu->hfi.bw_table));
914: if (ret)
915: goto err;
916:
917: ret = a6xx_hfi_send_acd_feature_ctrl(adreno_dev);
918: if (ret)
919: goto err;
920:
921: ret = a6xx_hfi_send_lm_feature_ctrl(adreno_dev);
922: if (ret)
923: goto err;
924:
925: ret = a6xx_hfi_send_bcl_feature_ctrl(adreno_dev);
926: if (ret)
927: goto err;
928:
929: ret = a6xx_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_HWSCHED, 1, 0);
930: if (ret)
931: goto err;
932:
933: ret = a6xx_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_KPROF, 1, 0);
934: if (ret)
935: goto err;
936:
937: if (ADRENO_FEATURE(adreno_dev, ADRENO_LSR)) {
938: ret = a6xx_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_LSR,
939: 1, 0);
940: if (ret)
941: goto err;
942: }
943:
944: ret = a6xx_hfi_send_perfcounter_feature_ctrl(adreno_dev);
945: if (ret)
946: goto err;
947:
948: /* Enable the long ib timeout detection */
949: if (adreno_long_ib_detect(adreno_dev)) {
950: ret = a6xx_hfi_send_feature_ctrl(adreno_dev,
951: HFI_FEATURE_BAIL_OUT_TIMER, 1, 0);
952: if (ret)
953: goto err;
954: }
955:
956: enable_gmu_stats(adreno_dev);
957:
958: if (gmu->log_stream_enable)
959: a6xx_hfi_send_set_value(adreno_dev,
960: HFI_VALUE_LOG_STREAM_ENABLE, 0, 1);
961:
962: if (gmu->log_group_mask)
963: a6xx_hfi_send_set_value(adreno_dev, HFI_VALUE_LOG_GROUP, 0, gmu->log_group_mask);
964:
965: ret = a6xx_hfi_send_core_fw_start(adreno_dev);
966: if (ret)
967: goto err;
968:
969: ret = enable_preemption(adreno_dev);
970: if (ret)
971: goto err;
972:
973: ret = send_start_msg(adreno_dev);
974: if (ret)
975: goto err;
976:
977: enable_async_hfi(adreno_dev);
978:
979: set_bit(GMU_PRIV_HFI_STARTED, &gmu->flags);
980:
981: ret = kgsl_pwrctrl_setup_default_votes(device);
982:
983: err:
984: if (ret)
985: a6xx_hwsched_hfi_stop(adreno_dev);
986:
987: return ret;
988: }
989:
990: static int submit_raw_cmds(struct adreno_device *adreno_dev, void *cmds, u32 size_bytes,
991: const char *str)
992: {
993: int ret;
994:
995: ret = a6xx_hfi_send_cmd_async(adreno_dev, cmds, size_bytes);
996: if (ret)
997: return ret;
998:
999: ret = gmu_core_timed_poll_check(KGSL_DEVICE(adreno_dev),
1000: A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS, 0, 200, BIT(23));
1001: if (ret)
1002: a6xx_spin_idle_debug(adreno_dev, str);
1003:
1004: return ret;
1005: }
1006:
1007: static int cp_init(struct adreno_device *adreno_dev)
1008: {
1009: u32 cmds[A6XX_CP_INIT_DWORDS + 1];
1010:
1011: cmds[0] = CREATE_MSG_HDR(H2F_MSG_ISSUE_CMD_RAW, HFI_MSG_CMD);
1012:
1013: a6xx_cp_init_cmds(adreno_dev, &cmds[1]);
1014:
1015: return submit_raw_cmds(adreno_dev, cmds, sizeof(cmds),
1016: "CP initialization failed to idle\n");
1017: }
1018:
1019: static int send_switch_to_unsecure(struct adreno_device *adreno_dev)
1020: {
1021: u32 cmds[3];
1022:
1023: cmds[0] = CREATE_MSG_HDR(H2F_MSG_ISSUE_CMD_RAW, HFI_MSG_CMD);
1024:
1025: cmds[1] = cp_type7_packet(CP_SET_SECURE_MODE, 1);
1026: cmds[2] = 0;
1027:
1028: return submit_raw_cmds(adreno_dev, cmds, sizeof(cmds),
1029: "Switch to unsecure failed to idle\n");
1030: }
1031:
1032: int a6xx_hwsched_cp_init(struct adreno_device *adreno_dev)
1033: {
1034: const struct adreno_a6xx_core *a6xx_core = to_a6xx_core(adreno_dev);
1035: struct adreno_firmware *fw = ADRENO_FW(adreno_dev, ADRENO_FW_SQE);
1036: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1037: int ret;
1038:
1039: /* Program the ucode base for CP */
1040: kgsl_regwrite(device, A6XX_CP_SQE_INSTR_BASE_LO,
1041: lower_32_bits(fw->memdesc->gpuaddr));
1042: kgsl_regwrite(device, A6XX_CP_SQE_INSTR_BASE_HI,
1043: upper_32_bits(fw->memdesc->gpuaddr));
1044:
1045: ret = cp_init(adreno_dev);
1046: if (ret)
1047: return ret;
1048:
1049: ret = adreno_zap_shader_load(adreno_dev, a6xx_core->zap_name);
1050: if (ret)
1051: return ret;
1052:
1053: if (!adreno_dev->zap_loaded)
1054: kgsl_regwrite(KGSL_DEVICE(adreno_dev),
1055: A6XX_RBBM_SECVID_TRUST_CNTL, 0x0);
1056: else
1057: ret = send_switch_to_unsecure(adreno_dev);
1058:
1059: return ret;
1060: }
1061:
1062: static int register_global_ctxt(struct adreno_device *adreno_dev)
1063: {
1064: struct adreno_hwsched *hwsched = &adreno_dev->hwsched;
1065: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1066: struct hfi_register_ctxt_cmd rcmd = {0};
1067: struct hfi_context_pointers_cmd pcmd = {0};
1068: int ret;
1069:
1070: if (hwsched->global_ctxt_gmu_registered)
1071: return 0;
1072:
1073: ret = CMD_MSG_HDR(rcmd, H2F_MSG_REGISTER_CONTEXT);
1074: if (ret)
1075: return ret;
1076:
1077: rcmd.ctxt_id = KGSL_GLOBAL_CTXT_ID;
1078: rcmd.flags = (KGSL_CONTEXT_PRIORITY_HIGH << KGSL_CONTEXT_PRIORITY_SHIFT);
1079:
1080: ret = a6xx_hfi_send_cmd_async(adreno_dev, &rcmd, sizeof(rcmd));
1081: if (ret)
1082: return ret;
1083:
1084: ret = CMD_MSG_HDR(pcmd, H2F_MSG_CONTEXT_POINTERS);
1085: if (ret)
1086: return ret;
1087:
1088: pcmd.ctxt_id = KGSL_GLOBAL_CTXT_ID;
1089: pcmd.sop_addr = MEMSTORE_ID_GPU_ADDR(device, KGSL_GLOBAL_CTXT_ID, soptimestamp);
1090: pcmd.eop_addr = MEMSTORE_ID_GPU_ADDR(device, KGSL_GLOBAL_CTXT_ID, eoptimestamp);
1091:
1092: ret = a6xx_hfi_send_cmd_async(adreno_dev, &pcmd, sizeof(pcmd));
1093: if (!ret)
1094: hwsched->global_ctxt_gmu_registered = true;
1095:
1096: return ret;
1097: }
1098:
1099: #define HFI_DSP_IRQ_BASE 2
1100:
1101: #define DISPQ_IRQ_BIT(_idx) BIT((_idx) + HFI_DSP_IRQ_BASE)
1102:
1103: static int submit_global_ctxt_cmd(struct adreno_device *adreno_dev, u64 gpuaddr, u32 size)
1104: {
1105: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1106: struct {
1107: struct hfi_submit_cmd submit_cmd;
1108: struct hfi_issue_ib issue_ib;
1109: } cmd = {0};
1110: u32 seqnum, cmd_size = sizeof(cmd);
1111: static u32 ts;
1112: int ret = 0;
1113:
1114: cmd.submit_cmd.ctxt_id = KGSL_GLOBAL_CTXT_ID;
1115: cmd.submit_cmd.ts = ++ts;
1116: cmd.submit_cmd.numibs = 1;
1117:
1118: cmd.issue_ib.addr = gpuaddr;
1119: cmd.issue_ib.size = size;
1120:
1121: seqnum = atomic_inc_return(&adreno_dev->hwsched.submission_seqnum);
1122: cmd.submit_cmd.hdr = CREATE_MSG_HDR(H2F_MSG_ISSUE_CMD, HFI_MSG_CMD);
1123: cmd.submit_cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.submit_cmd.hdr, seqnum, cmd_size >> 2);
1124:
1125: ret = a6xx_hfi_dispatch_queue_write(adreno_dev, HFI_DSP_ID_0,
1126: (u32 *)&cmd, cmd_size, NULL, NULL);
1127: /* Send interrupt to GMU to receive the message */
1128: if (!ret)
1129: gmu_core_regwrite(device, A6XX_GMU_HOST2GMU_INTR_SET, DISPQ_IRQ_BIT(0));
1130:
1131: return ret;
1132: }
1133:
1134: int a6xx_hwsched_counter_inline_enable(struct adreno_device *adreno_dev,
1135: const struct adreno_perfcount_group *group,
1136: u32 counter, u32 countable)
1137: {
1138: struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
1139: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1140: struct adreno_perfcount_register *reg = &group->regs[counter];
1141: u32 val, *cmds, count = 0;
1142: int ret;
1143:
1144: ret = register_global_ctxt(adreno_dev);
1145: if (ret)
1146: goto err;
1147:
1148: ret = adreno_allocate_global(device, &hfi->perfctr_scratch,
1149: PAGE_SIZE, 0, KGSL_MEMFLAGS_GPUREADONLY, 0, "perfctr_scratch");
1150: if (ret)
1151: goto err;
1152:
1153: if (group->flags & ADRENO_PERFCOUNTER_GROUP_RESTORE)
1154: a6xx_perfcounter_update(adreno_dev, reg, false);
1155:
1156: cmds = hfi->perfctr_scratch->hostptr;
1157:
1158: cmds[count++] = cp_type7_packet(CP_WAIT_FOR_IDLE, 0);
1159: cmds[count++] = cp_type4_packet(reg->select, 1);
1160: cmds[count++] = countable;
1161:
1162: ret = submit_global_ctxt_cmd(adreno_dev, hfi->perfctr_scratch->gpuaddr, count << 2);
1163: if (ret)
1164: goto err;
1165:
1166: /* Wait till the register is programmed with the countable */
1167: ret = kgsl_regmap_read_poll_timeout(&device->regmap, reg->select, val,
1168: val == countable, 100, ADRENO_IDLE_TIMEOUT * USEC_PER_MSEC);
1169: if (!ret) {
1170: reg->value = 0;
1171: return ret;
1172: }
1173:
1174: err:
1175: dev_err(device->dev, "Perfcounter %s/%u/%u start via commands failed\n",
1176: group->name, counter, countable);
1177: return ret;
1178: }
1179:
1180: static bool is_queue_empty(struct adreno_device *adreno_dev, u32 queue_idx)
1181: {
1182: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
1183: struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
1184: struct hfi_queue_table *tbl = mem_addr->hostptr;
1185: struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];
1186:
1187: if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
1188: return true;
1189:
1190: if (hdr->read_index == hdr->write_index)
1191: return true;
1192:
1193: return false;
1194: }
1195:
1196: static int hfi_f2h_main(void *arg)
1197: {
1198: struct adreno_device *adreno_dev = arg;
1199: struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
1200: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1201:
1202: while (!kthread_should_stop()) {
1203: wait_event_interruptible(hfi->f2h_wq, kthread_should_stop() ||
1204: /* If msgq irq is enabled and msgq has messages to process */
1205: (((hfi->irq_mask & HFI_IRQ_MSGQ_MASK) &&
1206: !is_queue_empty(adreno_dev, HFI_MSG_ID)) ||
1207: /* Trace buffer has messages to process */
1208: !gmu_core_is_trace_empty(device->gmu_core.trace.md->hostptr) ||
1209: /* Dbgq has messages to process */
1210: !is_queue_empty(adreno_dev, HFI_DBG_ID)));
1211:
1212: if (kthread_should_stop())
1213: break;
1214:
1215: a6xx_hwsched_process_msgq(adreno_dev);
1216: gmu_core_process_trace_data(device,
1217: GMU_PDEV_DEV(device), &device->gmu_core.trace);
1218: a6xx_hwsched_process_dbgq(adreno_dev, true);
1219: }
1220:
1221: return 0;
1222: }
1223:
1224: int a6xx_hwsched_hfi_probe(struct adreno_device *adreno_dev)
1225: {
1226: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
1227: struct a6xx_hwsched_hfi *hw_hfi = to_a6xx_hwsched_hfi(adreno_dev);
1228: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1229:
1230: /* Try with "hfi" irq first. Use Fallback legacy name "kgsl_hfi_irq" if not found. */
1231: gmu->hfi.irq = kgsl_request_irq(GMU_PDEV(device), "hfi", "kgsl_hfi_irq", -EINVAL,
1232: a6xx_hwsched_hfi_handler, adreno_dev);
1233:
1234: if (gmu->hfi.irq < 0)
1235: return gmu->hfi.irq;
1236:
1237: hw_hfi->irq_mask = HFI_IRQ_MASK;
1238:
1239: rwlock_init(&hw_hfi->msglock);
1240:
1241: INIT_LIST_HEAD(&hw_hfi->msglist);
1242:
1243: init_waitqueue_head(&hw_hfi->f2h_wq);
1244:
1245: mutex_init(&hw_hfi->msgq_mutex);
1246:
1247: return 0;
1248: }
1249:
1250: void a6xx_hwsched_hfi_remove(struct adreno_device *adreno_dev)
1251: {
1252: struct a6xx_hwsched_hfi *hw_hfi = to_a6xx_hwsched_hfi(adreno_dev);
1253:
1254: if (hw_hfi->f2h_task)
1255: kthread_stop(hw_hfi->f2h_task);
1256: }
1257:
1258: static u32 get_next_dq(u32 priority)
1259: {
1260: struct dq_info *info = &a6xx_hfi_dqs[priority];
1261: u32 next = info->base_dq_id + info->offset;
1262:
1263: info->offset = (info->offset + 1) % info->max_dq;
1264:
1265: return next;
1266: }
1267:
1268: static u32 get_dq_id(struct kgsl_context *context)
1269: {
1270: u32 level = adreno_get_level(context);
1271:
1272: return get_next_dq(level);
1273: }
1274:
1275: static int send_context_register(struct adreno_device *adreno_dev,
1276: struct kgsl_context *context)
1277: {
1278: struct hfi_register_ctxt_cmd cmd;
1279: struct kgsl_pagetable *pt = context->proc_priv->pagetable;
1280: int ret, asid = kgsl_mmu_pagetable_get_asid(pt, context);
1281:
1282: if (asid < 0)
1283: return asid;
1284:
MATCH LINES: 1303, 1324
1291:
1292: /*
1293: * HLOS SMMU driver programs context bank to look up ASID from TTBR0 during a page
1294: * table walk. So the TLB entries are tagged with the ASID from TTBR0. TLBIASID
1295: * invalidates TLB entries whose ASID matches the value that was written to the
1296: * CBn_TLBIASID register. Set ASID along with PT address.
1297: */
1298: cmd.pt_addr = kgsl_mmu_pagetable_get_ttbr0(pt) |
1299: FIELD_PREP(GENMASK_ULL(63, KGSL_IOMMU_ASID_START_BIT), asid);
1300: cmd.ctxt_idr = pid_nr(context->proc_priv->pid);
1301: cmd.ctxt_bank = kgsl_mmu_pagetable_get_context_bank(pt, context);
1302:
1303: return a6xx_hfi_send_cmd_async(adreno_dev, &cmd, sizeof(cmd));
1304: }
1305:
1306: static int send_context_pointers(struct adreno_device *adreno_dev,
1307: struct kgsl_context *context)
1308: {
1309: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1310: struct hfi_context_pointers_cmd cmd = {0};
1311: int ret;
1312:
1313: ret = CMD_MSG_HDR(cmd, H2F_MSG_CONTEXT_POINTERS);
1314: if (ret)
1315: return ret;
1316:
1317: cmd.ctxt_id = context->id;
1318: cmd.sop_addr = MEMSTORE_ID_GPU_ADDR(device, context->id, soptimestamp);
1319: cmd.eop_addr = MEMSTORE_ID_GPU_ADDR(device, context->id, eoptimestamp);
1320: if (context->user_ctxt_record)
1321: cmd.user_ctxt_record_addr =
1322: context->user_ctxt_record->memdesc.gpuaddr;
1323:
1324: return a6xx_hfi_send_cmd_async(adreno_dev, &cmd, sizeof(cmd));
1325: }
1326:
1327: static int hfi_context_register(struct adreno_device *adreno_dev,
1328: struct kgsl_context *context)
1329: {
1330: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1331: int ret;
1332:
1333: if (context->gmu_registered)
1334: return 0;
1335:
1336: ret = send_context_register(adreno_dev, context);
1337: if (ret) {
1338: dev_err(GMU_PDEV_DEV(device),
1339: "Unable to register context %u: %d\n",
1340: context->id, ret);
1341:
1342: if (device->gmu_fault)
1343: adreno_scheduler_fault(adreno_dev, ADRENO_GMU_FAULT);
1344:
1345: return ret;
1346: }
1347:
1348: ret = send_context_pointers(adreno_dev, context);
MATCH LINES: 1373, 1400, 1405
1361: context->gmu_dispatch_queue = get_dq_id(context);
1362:
1363: return 0;
1364: }
1365:
1366: static void populate_ibs(struct adreno_device *adreno_dev,
1367: struct hfi_submit_cmd *cmd, struct kgsl_drawobj_cmd *cmdobj)
1368: {
1369: struct hfi_issue_ib *issue_ib;
1370: struct kgsl_memobj_node *ib;
1371:
1372: if (cmdobj->numibs > HWSCHED_MAX_DISPATCH_NUMIBS) {
1373: struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
1374: struct kgsl_memdesc *big_ib;
1375:
1376: if (test_bit(CMDOBJ_RECURRING_START, &cmdobj->priv))
1377: big_ib = hfi->big_ib_recurring;
1378: else
1379: big_ib = hfi->big_ib;
1380: /*
1381: * The dispatcher ensures that there is only one big IB inflight
1382: */
1383: cmd->big_ib_gmu_va = big_ib->gmuaddr;
1384: cmd->flags |= CMDBATCH_INDIRECT;
1385: issue_ib = big_ib->hostptr;
1386: } else {
1387: issue_ib = (struct hfi_issue_ib *)&cmd[1];
1388: }
1389:
1390: list_for_each_entry(ib, &cmdobj->cmdlist, node) {
1391: issue_ib->addr = ib->gpuaddr;
1392: issue_ib->size = ib->size;
1393: issue_ib++;
1394: }
1395:
1396: cmd->numibs = cmdobj->numibs;
1397: }
1398:
1399: /* Size in below functions are in unit of dwords */
1400: static int a6xx_hfi_dispatch_queue_write(struct adreno_device *adreno_dev, uint32_t queue_idx,
1401: uint32_t *msg, u32 size_bytes, struct kgsl_drawobj_cmd *cmdobj,
1402: struct adreno_submit_time *time)
1403: {
1404: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1405: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
1406: struct hfi_queue_table *tbl = gmu->hfi.hfi_mem->hostptr;
1407: struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];
1408: uint32_t *queue;
1409: uint32_t i, write, empty_space;
1410: uint32_t size_dwords = size_bytes >> 2;
1411: u32 align_size = ALIGN(size_dwords, SZ_4);
1412: uint32_t id = MSG_HDR_GET_ID(*msg);
1413:
1414: if (hdr->status == HFI_QUEUE_STATUS_DISABLED || !IS_ALIGNED(size_bytes, sizeof(u32)))
1415: return -EINVAL;
1416:
1417: queue = HOST_QUEUE_START_ADDR(gmu->hfi.hfi_mem, queue_idx);
1418:
1419: empty_space = (hdr->write_index >= hdr->read_index) ?
1420: (hdr->queue_size - (hdr->write_index - hdr->read_index))
1421: : (hdr->read_index - hdr->write_index);
1422:
1423: if (empty_space <= align_size)
1424: return -ENOSPC;
1425:
1426: write = hdr->write_index;
1427:
1428: for (i = 0; i < size_dwords; i++) {
1429: queue[write] = msg[i];
MATCH LINES: 1465
1453: * packet before the profile data is written out.
1454: */
1455: adreno_profile_submit_time(time);
1456:
1457: done:
1458: trace_kgsl_hfi_send(id, size_dwords, MSG_HDR_GET_SEQNUM(*msg));
1459:
1460: hfi_update_write_idx(&hdr->write_index, write);
1461:
1462: return 0;
1463: }
1464:
1465: int a6xx_hwsched_submit_drawobj(struct adreno_device *adreno_dev,
1466: struct kgsl_drawobj *drawobj)
1467: {
1468: int ret = 0;
1469: u32 cmd_sizebytes, seqnum;
1470: struct kgsl_drawobj_cmd *cmdobj = CMDOBJ(drawobj);
1471: struct hfi_submit_cmd *cmd;
1472: struct adreno_submit_time time = {0};
1473: static void *cmdbuf;
1474: struct adreno_context *drawctxt = ADRENO_CONTEXT(drawobj->context);
1475:
1476: if (cmdbuf == NULL) {
1477: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1478:
1479: cmdbuf = devm_kzalloc(&device->pdev->dev, HFI_MAX_MSG_SIZE,
1480: GFP_KERNEL);
1481: if (!cmdbuf)
1482: return -ENOMEM;
1483: }
1484:
1485: ret = hfi_context_register(adreno_dev, drawobj->context);
1486: if (ret)
1487: return ret;
1488:
1489: /* Add a *issue_ib struct for each IB */
MATCH LINES: 1537, 1544, 1552
1525:
1526: /* Indicate to GMU to do user profiling for this submission */
1527: cmd->flags |= CMDBATCH_PROFILING;
1528: }
1529:
1530: skipib:
1531: adreno_drawobj_set_constraint(KGSL_DEVICE(adreno_dev), drawobj);
1532:
1533: seqnum = atomic_inc_return(&adreno_dev->hwsched.submission_seqnum);
1534: cmd->hdr = CREATE_MSG_HDR(H2F_MSG_ISSUE_CMD, HFI_MSG_CMD);
1535: cmd->hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd->hdr, seqnum, cmd_sizebytes >> 2);
1536:
1537: ret = a6xx_hfi_dispatch_queue_write(adreno_dev,
1538: HFI_DSP_ID_0 + drawobj->context->gmu_dispatch_queue,
1539: (u32 *)cmd, cmd_sizebytes, cmdobj, &time);
1540: if (ret)
1541: return ret;
1542:
1543: /* Send interrupt to GMU to receive the message */
1544: gmu_core_regwrite(KGSL_DEVICE(adreno_dev), A6XX_GMU_HOST2GMU_INTR_SET,
1545: DISPQ_IRQ_BIT(drawobj->context->gmu_dispatch_queue));
1546:
1547: drawctxt->internal_timestamp = drawobj->timestamp;
1548:
1549: return ret;
1550: }
1551:
1552: int a6xx_hwsched_send_recurring_cmdobj(struct adreno_device *adreno_dev,
1553: struct kgsl_drawobj_cmd *cmdobj)
1554: {
1555: struct adreno_hwsched *hwsched = &adreno_dev->hwsched;
1556: struct kgsl_drawobj *drawobj = DRAWOBJ(cmdobj);
1557: struct hfi_submit_cmd *cmd;
1558: struct kgsl_memobj_node *ib;
1559: u32 cmd_sizebytes;
1560: int ret;
1561: static bool active;
1562:
1563: if (adreno_gpu_halt(adreno_dev) || adreno_gpu_fault(adreno_dev))
1564: return -EBUSY;
1565:
1566: if (test_bit(CMDOBJ_RECURRING_STOP, &cmdobj->priv)) {
1567: cmdobj->numibs = 0;
1568: } else {
1569: list_for_each_entry(ib, &cmdobj->cmdlist, node)
1570: cmdobj->numibs++;
1571: }
1572:
1573: if (cmdobj->numibs > HWSCHED_MAX_IBS)
1574: return -EINVAL;
1575:
1576: if (cmdobj->numibs > HWSCHED_MAX_DISPATCH_NUMIBS)
MATCH LINES: 1615
1603: cmd->ctxt_id = drawobj->context->id;
1604:
1605: ret = hfi_context_register(adreno_dev, drawobj->context);
1606: if (ret) {
1607: adreno_active_count_put(adreno_dev);
1608: active = false;
1609: kfree(cmd);
1610: return ret;
1611: }
1612:
1613: cmd->hdr = CREATE_MSG_HDR(H2F_MSG_ISSUE_RECURRING_CMD, HFI_MSG_CMD);
1614:
1615: ret = a6xx_hfi_send_cmd_async(adreno_dev, cmd, cmd_sizebytes);
1616:
1617: kfree(cmd);
1618:
1619: if (ret) {
1620: adreno_active_count_put(adreno_dev);
1621: active = false;
1622: return ret;
1623: }
1624:
1625: if (test_bit(CMDOBJ_RECURRING_STOP, &cmdobj->priv)) {
1626: adreno_hwsched_retire_cmdobj(hwsched, hwsched->recurring_cmdobj);
1627: hwsched->recurring_cmdobj = NULL;
1628: kgsl_delete_timer_sync(&hwsched->lsr_timer);
1629: if (active)
1630: adreno_active_count_put(adreno_dev);
1631: active = false;
1632: return ret;
1633: }
1634:
1635: hwsched->recurring_cmdobj = cmdobj;
1636: /* Star LSR timer for power stats collection */
1637: mod_timer(&hwsched->lsr_timer, jiffies + msecs_to_jiffies(10));
1638: return ret;
1639: }
MATCH LINES: 1660, 1661, 1696, 1703, 1718, 1746, 1750, 1751, 1770, 1775
1648: /*
1649: * Trigger dispatcher based reset and recovery. Invalidate the
1650: * context so that any un-finished inflight submissions are not
1651: * replayed after recovery.
1652: */
1653: adreno_drawctxt_set_guilty(device, context);
1654: adreno_scheduler_fault(adreno_dev, ADRENO_GMU_FAULT);
1655: }
1656:
1657: static int send_context_unregister_hfi(struct adreno_device *adreno_dev,
1658: struct kgsl_context *context, u32 ts)
1659: {
1660: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
1661: struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
1662: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1663: struct pending_cmd pending_ack;
1664: struct hfi_unregister_ctxt_cmd cmd;
1665: u32 seqnum;
1666: int ret;
1667:
1668: /* Only send HFI if device is not in SLUMBER */
1669: if (!context->gmu_registered ||
1670: !test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags))
1671: return 0;
1672:
1673: ret = CMD_MSG_HDR(cmd, H2F_MSG_UNREGISTER_CONTEXT);
1674: if (ret)
1675: return ret;
1676:
1677: cmd.ctxt_id = context->id,
1678: cmd.ts = ts,
1679:
1680: /*
1681: * Although we know device is powered on, we can still enter SLUMBER
1682: * because the wait for ack below is done without holding the mutex. So
1683: * take an active count before releasing the mutex so as to avoid a
1684: * concurrent SLUMBER sequence while GMU is un-registering this context.
1685: */
1686: ret = adreno_active_count_get(adreno_dev);
1687: if (ret) {
1688: trigger_context_unregister_fault(adreno_dev, context);
1689: return ret;
1690: }
1691:
1692: seqnum = atomic_inc_return(&gmu->hfi.seqnum);
1693: cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
1694: add_waiter(hfi, cmd.hdr, &pending_ack);
1695:
1696: ret = a6xx_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
1697: if (ret) {
1698: trigger_context_unregister_fault(adreno_dev, context);
1699: goto done;
1700: }
1701:
1702: ret = adreno_hwsched_ctxt_unregister_wait_completion(adreno_dev,
1703: GMU_PDEV_DEV(device), context, &pending_ack, a6xx_hwsched_process_msgq, &cmd);
1704: if (ret) {
1705: trigger_context_unregister_fault(adreno_dev, context);
1706: goto done;
1707: }
1708:
1709: ret = check_ack_failure(adreno_dev, &pending_ack);
1710:
1711: done:
1712: adreno_active_count_put(adreno_dev);
1713: del_waiter(hfi, &pending_ack);
1714:
1715: return ret;
1716: }
1717:
1718: void a6xx_hwsched_context_detach(struct adreno_context *drawctxt)
1719: {
1720: struct kgsl_context *context = &drawctxt->base;
1721: struct kgsl_device *device = context->device;
1722: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
1723: int ret = 0;
1724:
1725: kgsl_mutex_lock(&device->mutex);
1726:
1727: ret = send_context_unregister_hfi(adreno_dev, context,
1728: drawctxt->internal_timestamp);
1729:
1730: if (ret)
1731: goto out;
1732:
1733: kgsl_sharedmem_writel(device->memstore,
1734: KGSL_MEMSTORE_OFFSET(context->id, soptimestamp), drawctxt->timestamp);
1735:
1736: kgsl_sharedmem_writel(device->memstore,
1737: KGSL_MEMSTORE_OFFSET(context->id, eoptimestamp), drawctxt->timestamp);
1738:
1739: adreno_profile_process_results(adreno_dev);
1740: context->gmu_registered = false;
1741:
1742: out:
1743: kgsl_mutex_unlock(&device->mutex);
1744: }
1745:
1746: u32 a6xx_hwsched_preempt_count_get(struct adreno_device *adreno_dev)
1747: {
1748: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1749: struct hfi_get_value_cmd cmd;
1750: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
1751: struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
1752: struct pending_cmd pending_ack;
1753: int rc;
1754: u32 seqnum;
1755:
1756: if (device->state != KGSL_STATE_ACTIVE)
1757: return 0;
1758:
1759: rc = CMD_MSG_HDR(cmd, H2F_MSG_GET_VALUE);
1760: if (rc)
1761: return 0;
1762:
1763: seqnum = atomic_inc_return(&gmu->hfi.seqnum);
1764: cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
1765: cmd.type = HFI_VALUE_PREEMPT_COUNT;
1766: cmd.subtype = 0;
1767:
1768: add_waiter(hfi, cmd.hdr, &pending_ack);
1769:
1770: rc = a6xx_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
1771: if (rc)
1772: goto done;
1773:
1774: rc = adreno_hwsched_wait_ack_completion(adreno_dev,
1775: GMU_PDEV_DEV(device), &pending_ack, a6xx_hwsched_process_msgq);
1776: if (rc)
1777: goto done;
1778:
1779: rc = check_ack_failure(adreno_dev, &pending_ack);
1780:
1781: done:
1782: del_waiter(hfi, &pending_ack);
1783:
1784: return rc ? 0 : pending_ack.results[2];
1785: }
--- FILE: \adreno_a6xx_hwsched_hfi.h | HITS: 26 ---
MATCH LINES: 7, 8, 10, 34, 39, 42, 45, 48, 56, 59, 66, 69, 74, 77, 85, 88, 97, 102, 112, 115, 124, 128, 134, 137, 140, 148
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: #ifndef _ADRENO_A6XX_HWSCHED_HFI_H_
8: #define _ADRENO_A6XX_HWSCHED_HFI_H_
9:
10: struct a6xx_hwsched_hfi {
11: /** @irq_mask: Store the hfi interrupt mask */
12: u32 irq_mask;
13: /** @msglock: To protect the list of un-ACKed hfi packets */
14: rwlock_t msglock;
15: /** @msglist: List of un-ACKed hfi packets */
16: struct list_head msglist;
17: /** @f2h_task: Task for processing gmu fw to host packets */
18: struct task_struct *f2h_task;
19: /** @f2h_wq: Waitqueue for the f2h_task */
20: wait_queue_head_t f2h_wq;
21: /** @big_ib: GMU buffer to hold big IBs */
22: struct kgsl_memdesc *big_ib;
23: /** @big_ib_recurring: GMU buffer to hold big recurring IBs */
24: struct kgsl_memdesc *big_ib_recurring;
25: /** @perfctr_scratch: Buffer to hold perfcounter PM4 commands */
26: struct kgsl_memdesc *perfctr_scratch;
27: /** @msg_mutex: Mutex for accessing the msgq */
28: struct mutex msgq_mutex;
29: };
30:
31: struct kgsl_drawobj_cmd;
32:
33: /**
34: * a6xx_hwsched_hfi_probe - Probe hwsched hfi resources
35: * @adreno_dev: Pointer to adreno device structure
36: *
37: * Return: 0 on success and negative error on failure.
38: */
39: int a6xx_hwsched_hfi_probe(struct adreno_device *adreno_dev);
40:
41: /**
42: * a6xx_hwsched_hfi_remove - Release hwsched hfi resources
43: * @adreno_dev: Pointer to adreno device structure
44: */
45: void a6xx_hwsched_hfi_remove(struct adreno_device *adreno_dev);
46:
47: /**
48: * a6xx_hwsched_hfi_init - Initialize hfi resources
49: * @adreno_dev: Pointer to adreno device structure
50: *
51: * This function is used to initialize hfi resources
52: * once before the very first gmu boot
53: *
54: * Return: 0 on success and negative error on failure.
55: */
56: int a6xx_hwsched_hfi_init(struct adreno_device *adreno_dev);
57:
58: /**
59: * a6xx_hwsched_hfi_start - Start hfi resources
60: * @adreno_dev: Pointer to adreno device structure
61: *
62: * Send the various hfi packets before booting the gpu
63: *
64: * Return: 0 on success and negative error on failure.
65: */
66: int a6xx_hwsched_hfi_start(struct adreno_device *adreno_dev);
67:
68: /**
69: * a6xx_hwsched_hfi_stop - Stop the hfi resources
70: * @adreno_dev: Pointer to the adreno device
71: *
72: * This function does the hfi cleanup when powering down the gmu
73: */
74: void a6xx_hwsched_hfi_stop(struct adreno_device *adreno_dev);
75:
76: /**
77: * a6xx_hwched_cp_init - Send CP_INIT via HFI
78: * @adreno_dev: Pointer to adreno device structure
79: *
80: * This function is used to send CP INIT packet and bring
81: * GPU out of secure mode using hfi raw packets.
82: *
83: * Return: 0 on success and negative error on failure.
84: */
85: int a6xx_hwsched_cp_init(struct adreno_device *adreno_dev);
86:
87: /**
88: * a6xx_hwsched_counter_inline_enable - Configure a performance counter for a countable
89: * @adreno_dev - Adreno device to configure
90: * @group - Desired performance counter group
91: * @counter - Desired performance counter in the group
92: * @countable - Desired countable
93: *
94: * Physically set up a counter within a group with the desired countable
95: * Return 0 on success or negative error on failure.
96: */
97: int a6xx_hwsched_counter_inline_enable(struct adreno_device *adreno_dev,
98: const struct adreno_perfcount_group *group,
99: u32 counter, u32 countable);
100:
101: /**
102: * a6xx_hfi_send_cmd_async - Send an hfi packet
103: * @adreno_dev: Pointer to adreno device structure
104: * @data: Data to be sent in the hfi packet
105: * @size_bytes: Size of the packet in bytes
106: *
107: * Send data in the form of an HFI packet to gmu and wait for
108: * it's ack asynchronously
109: *
110: * Return: 0 on success and negative error on failure.
111: */
112: int a6xx_hfi_send_cmd_async(struct adreno_device *adreno_dev, void *data, u32 size_bytes);
113:
114: /**
115: * a6xx_hwsched_submit_drawobj - Dispatch IBs to dispatch queues
116: * @adreno_dev: Pointer to adreno device structure
117: * @drawobj: The command draw object which needs to be submitted
118: *
119: * This function is used to register the context if needed and submit
120: * IBs to the hfi dispatch queues.
121:
122: * Return: 0 on success and negative error on failure
123: */
124: int a6xx_hwsched_submit_drawobj(struct adreno_device *adreno_dev,
125: struct kgsl_drawobj *drawobj);
126:
127: /**
128: * a6xx_hwsched_context_detach - Unregister a context with GMU
129: * @drawctxt: Pointer to the adreno context
130: *
131: * This function sends context unregister HFI and waits for the ack
132: * to ensure all submissions from this context have retired
133: */
134: void a6xx_hwsched_context_detach(struct adreno_context *drawctxt);
135:
136: /* Helper function to get to a6xx hwsched hfi device from adreno device */
137: struct a6xx_hwsched_hfi *to_a6xx_hwsched_hfi(struct adreno_device *adreno_dev);
138:
139: /**
140: * a6xx_hwsched_preempt_count_get - Get preemption count from GMU
141: * @adreno_dev: Pointer to adreno device
142: *
143: * This function sends a GET_VALUE HFI packet to get the number of
144: * preemptions completed since last SLUMBER exit.
145: *
146: * Return: Preemption count
147: */
148: u32 a6xx_hwsched_preempt_count_get(struct adreno_device *adreno_dev);
149: #endif
--- FILE: \adreno_a6xx_perfcounter.c | HITS: 493 ---
MATCH LINES: 9, 34, 48, 51, 54, 61, 75, 84, 94, 104, 106, 107, 111
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_a6xx.h"
9: #include "adreno_a6xx_hwsched_hfi.h"
10: #include "adreno_perfcounter.h"
11: #include "adreno_pm4types.h"
12: #include "kgsl_device.h"
13:
14: #define VBIF2_PERF_CNT_SEL_MASK 0x7F
15: /* offset of clear register from select register */
16: #define VBIF2_PERF_CLR_REG_SEL_OFF 8
17: /* offset of enable register from select register */
18: #define VBIF2_PERF_EN_REG_SEL_OFF 16
19: /* offset of clear register from the enable register */
20: #define VBIF2_PERF_PWR_CLR_REG_EN_OFF 8
21:
22: /* offset of clear register from select register for GBIF */
23: #define GBIF_PERF_CLR_REG_SEL_OFF 1
24: /* offset of enable register from select register for GBIF*/
25: #define GBIF_PERF_EN_REG_SEL_OFF 2
26: /* offset of clear register from the power enable register for GBIF*/
27: #define GBIF_PWR_CLR_REG_EN_OFF 1
28: #define GBIF_PWR_SEL_REG_EN_OFF 3
29:
30: #define GBIF_PERF_SEL_RMW_MASK 0xFF
31: #define GBIF_PWR_SEL_RMW_MASK 0xFF
32: #define GBIF_PWR_EN_CLR_RMW_MASK 0x10000
33:
34: static void a6xx_counter_load(struct adreno_device *adreno_dev,
35: struct adreno_perfcount_register *reg)
36: {
37: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
38: int index = reg->load_bit / 32;
39: u32 enable = BIT(reg->load_bit & 31);
40:
41: /*
42: * a650 and a660 currently have the perfcounter values saved via
43: * retention in the GMU.
44: */
45: if (adreno_is_a650(adreno_dev) || adreno_is_a660(adreno_dev))
46: return;
47:
48: kgsl_regwrite(device, A6XX_RBBM_PERFCTR_LOAD_VALUE_LO,
49: lower_32_bits(reg->value));
50:
51: kgsl_regwrite(device, A6XX_RBBM_PERFCTR_LOAD_VALUE_HI,
52: upper_32_bits(reg->value));
53:
54: kgsl_regwrite(device, A6XX_RBBM_PERFCTR_LOAD_CMD0 + index, enable);
55: }
56:
57: /*
58: * For registers that do not get restored on power cycle, read the value and add
59: * the stored shadow value
60: */
61: static u64 a6xx_counter_read_norestore(struct adreno_device *adreno_dev,
62: const struct adreno_perfcount_group *group,
63: unsigned int counter)
64: {
65: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
66: struct adreno_perfcount_register *reg = &group->regs[counter];
67: u32 hi, lo;
68:
69: kgsl_regread(device, reg->offset, &lo);
70: kgsl_regread(device, reg->offset_hi, &hi);
71:
72: return ((((u64) hi) << 32) | lo) + reg->value;
73: }
74:
75: static int a6xx_counter_enable(struct adreno_device *adreno_dev,
76: const struct adreno_perfcount_group *group,
77: u32 counter, u32 countable)
78: {
79: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
80: struct adreno_perfcount_register *reg = &group->regs[counter];
81: int ret = 0;
82:
83: if (group->flags & ADRENO_PERFCOUNTER_GROUP_RESTORE)
84: ret = a6xx_perfcounter_update(adreno_dev, reg, true);
85: else
86: kgsl_regwrite(device, reg->select, countable);
87:
88: if (!ret)
89: reg->value = 0;
90:
91: return ret;
92: }
93:
94: static int a6xx_swsched_counter_inline_enable(struct adreno_device *adreno_dev,
95: const struct adreno_perfcount_group *group,
96: unsigned int counter, unsigned int countable)
97: {
98: struct adreno_perfcount_register *reg = &group->regs[counter];
99: struct adreno_ringbuffer *rb = &adreno_dev->ringbuffers[0];
100: u32 cmds[3];
101: int ret;
102:
103: if (group->flags & ADRENO_PERFCOUNTER_GROUP_RESTORE)
104: a6xx_perfcounter_update(adreno_dev, reg, false);
105:
106: cmds[0] = cp_type7_packet(CP_WAIT_FOR_IDLE, 0);
107: cmds[1] = cp_type4_packet(reg->select, 1);
108: cmds[2] = countable;
109:
110: /* submit to highest priority RB always */
111: ret = a6xx_ringbuffer_addcmds(adreno_dev, rb, NULL,
112: F_NOTPROTECTED, cmds, 3, 0, NULL);
113: if (ret)
114: return ret;
115:
116: /*
117: * schedule dispatcher to make sure rb[0] is run, because
118: * if the current RB is not rb[0] and gpu is idle then
119: * rb[0] will not get scheduled to run
120: */
121: if (adreno_dev->cur_rb != rb)
122: adreno_scheduler_queue(adreno_dev);
123:
124: /* wait for the above commands submitted to complete */
125: ret = adreno_ringbuffer_waittimestamp(rb, rb->timestamp,
126: ADRENO_IDLE_TIMEOUT);
127:
128: if (ret) {
129: /*
130: * If we were woken up because of cancelling rb events
131: * either due to soft reset or adreno_stop, ignore the
132: * error and return 0 here. The perfcounter is already
133: * set up in software and it will be programmed in
134: * hardware when we wake up or come up after soft reset,
135: * by adreno_perfcounter_restore.
MATCH LINES: 151, 155, 158, 161, 165, 180
139: else
140: dev_err(KGSL_DEVICE(adreno_dev)->dev,
141: "Perfcounter %s/%u/%u start via commands failed %d\n",
142: group->name, counter, countable, ret);
143: }
144:
145: if (!ret)
146: reg->value = 0;
147:
148: return ret;
149: }
150:
151: static int a6xx_counter_inline_enable(struct adreno_device *adreno_dev,
152: const struct adreno_perfcount_group *group, u32 counter, u32 countable)
153: {
154: if (!(KGSL_DEVICE(adreno_dev)->state == KGSL_STATE_ACTIVE))
155: return a6xx_counter_enable(adreno_dev, group, counter, countable);
156:
157: if (adreno_dev->hwsched_enabled)
158: return a6xx_hwsched_counter_inline_enable(adreno_dev, group,
159: counter, countable);
160:
161: return a6xx_swsched_counter_inline_enable(adreno_dev, group,
162: counter, countable);
163: }
164:
165: static u64 a6xx_counter_read(struct adreno_device *adreno_dev,
166: const struct adreno_perfcount_group *group,
167: unsigned int counter)
168: {
169: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
170: struct adreno_perfcount_register *reg = &group->regs[counter];
171: u32 hi, lo;
172:
173: kgsl_regread(device, reg->offset, &lo);
174: kgsl_regread(device, reg->offset_hi, &hi);
175:
176: /* These registers are restored on power resume */
177: return (((u64) hi) << 32) | lo;
178: }
179:
180: static int a6xx_counter_gbif_enable(struct adreno_device *adreno_dev,
181: const struct adreno_perfcount_group *group,
182: unsigned int counter, unsigned int countable)
183: {
184: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
185: struct adreno_perfcount_register *reg = &group->regs[counter];
186: unsigned int shift = counter << 3;
187: unsigned int perfctr_mask = 1 << counter;
188:
189: if (countable > VBIF2_PERF_CNT_SEL_MASK)
190: return -EINVAL;
191:
192: /*
193: * Write 1, followed by 0 to CLR register for
194: * clearing the counter
195: */
196: kgsl_regrmw(device, reg->select - GBIF_PERF_CLR_REG_SEL_OFF,
197: perfctr_mask, perfctr_mask);
198: kgsl_regrmw(device, reg->select - GBIF_PERF_CLR_REG_SEL_OFF,
199: perfctr_mask, 0);
200: /* select the desired countable */
201: kgsl_regrmw(device, reg->select,
202: GBIF_PERF_SEL_RMW_MASK << shift, countable << shift);
203: /* enable counter */
204: kgsl_regrmw(device, reg->select - GBIF_PERF_EN_REG_SEL_OFF,
MATCH LINES: 262, 289, 296, 302, 305, 317, 341, 345, 350, 364, 367, 373, 391, 393, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 430, 431, 432, 433, 434, 435, 436, 437, 438, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 522, 523, 524, 525, 526, 527, 528, 529, 530, 533, 534, 535, 536, 537, 538, 539, 540, 541, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 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, 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, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 670, 671, 672, 673, 674, 677, 678, 679, 680, 681, 682, 683, 684, 685, 688, 689, 690, 691, 692, 693, 694, 695, 696, 699, 700, 701, 702, 703, 704, 705, 706, 707, 710, 711, 712, 713, 714, 715, 716, 720, 721, 722, 723, 724, 725, 726, 727, 728, 731, 732, 733, 734, 735, 736, 737, 748, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 786, 787, 788, 789, 790, 791, 792, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 816, 817, 818, 826, 828, 832, 836, 837, 838, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 858, 859, 860, 861, 862, 863, 864, 866, 867, 869, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899, 901, 904, 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, 933, 934, 935, 937, 938, 940, 941, 949, 950, 951, 959, 960, 961
250: * clearing the counter
251: */
252: kgsl_regwrite(device, reg->select +
253: VBIF2_PERF_PWR_CLR_REG_EN_OFF, 1);
254: kgsl_regwrite(device, reg->select +
255: VBIF2_PERF_PWR_CLR_REG_EN_OFF, 0);
256: kgsl_regwrite(device, reg->select, 1);
257:
258: reg->value = 0;
259: return 0;
260: }
261:
262: static int a6xx_counter_gbif_pwr_enable(struct adreno_device *adreno_dev,
263: const struct adreno_perfcount_group *group,
264: unsigned int counter, unsigned int countable)
265: {
266: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
267: struct adreno_perfcount_register *reg = &group->regs[counter];
268: unsigned int shift = counter << 3;
269: unsigned int perfctr_mask = GBIF_PWR_EN_CLR_RMW_MASK << counter;
270:
271: /*
272: * Write 1, followed by 0 to CLR register for
273: * clearing the counter
274: */
275: kgsl_regrmw(device, reg->select + GBIF_PWR_CLR_REG_EN_OFF,
276: perfctr_mask, perfctr_mask);
277: kgsl_regrmw(device, reg->select + GBIF_PWR_CLR_REG_EN_OFF,
278: perfctr_mask, 0);
279: /* select the desired countable */
280: kgsl_regrmw(device, reg->select + GBIF_PWR_SEL_REG_EN_OFF,
281: GBIF_PWR_SEL_RMW_MASK << shift, countable << shift);
282: /* Enable the counter */
283: kgsl_regrmw(device, reg->select, perfctr_mask, perfctr_mask);
284:
285: reg->value = 0;
286: return 0;
287: }
288:
289: static int a6xx_counter_alwayson_enable(struct adreno_device *adreno_dev,
290: const struct adreno_perfcount_group *group,
291: unsigned int counter, unsigned int countable)
292: {
293: return 0;
294: }
295:
296: static u64 a6xx_counter_alwayson_read(struct adreno_device *adreno_dev,
297: const struct adreno_perfcount_group *group,
298: unsigned int counter)
299: {
300: struct adreno_perfcount_register *reg = &group->regs[counter];
301:
302: return a6xx_read_alwayson(adreno_dev) + reg->value;
303: }
304:
305: static void a6xx_write_gmu_counter_enable(struct kgsl_device *device,
306: struct adreno_perfcount_register *reg, u32 bit, u32 countable)
307: {
308: u32 val;
309:
310: kgsl_regread(device, reg->select, &val);
311: val &= ~(0xff << bit);
312: val |= countable << bit;
313: kgsl_regwrite(device, reg->select, val);
314:
315: }
316:
317: static int a6xx_counter_gmu_xoclk_enable(struct adreno_device *adreno_dev,
318: const struct adreno_perfcount_group *group,
319: unsigned int counter, unsigned int countable)
320: {
321: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
322: struct adreno_perfcount_register *reg = &group->regs[counter];
323:
324: if (countable > 0xff)
325: return -EINVAL;
326:
327: if (counter >= 6 && !adreno_is_a660(adreno_dev))
328: return -EINVAL;
329:
330: /*
331: * Counters [0:3] are in select 1 bit offsets 0, 8, 16 and 24
332: * Counters [4:5] are in select 2 bit offset 0, 8
333: * Counters [6:9] are in select 3 bit offset 0, 8, 16 and 24
334: */
335:
336: if (counter == 4 || counter == 5)
337: counter -= 4;
338: else if (counter >= 6)
339: counter -= 6;
340:
341: a6xx_write_gmu_counter_enable(device, reg, counter * 8, countable);
342:
343: reg->value = 0;
344:
345: kgsl_regwrite(device, A6XX_GMU_CX_GMU_POWER_COUNTER_ENABLE, 1);
346:
347: return 0;
348: }
349:
350: static int a6xx_counter_gmu_gmuclk_enable(struct adreno_device *adreno_dev,
351: const struct adreno_perfcount_group *group,
352: unsigned int counter, unsigned int countable)
353: {
354: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
355: struct adreno_perfcount_register *reg = &group->regs[counter];
356:
357: if (countable > 0xff)
358: return -EINVAL;
359:
360: /*
361: * The two counters are stuck into GMU_CX_GMU_POWER_COUNTER_SELECT_1
362: * at bit offset 16 and 24
363: */
364: a6xx_write_gmu_counter_enable(device, reg,
365: 16 + (counter * 8), countable);
366:
367: kgsl_regwrite(device, A6XX_GMU_CX_GMU_POWER_COUNTER_ENABLE, 1);
368:
369: reg->value = 0;
370: return 0;
371: }
372:
373: static int a6xx_counter_gmu_perf_enable(struct adreno_device *adreno_dev,
374: const struct adreno_perfcount_group *group,
375: unsigned int counter, unsigned int countable)
376: {
377: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
378: struct adreno_perfcount_register *reg = &group->regs[counter];
379:
380: if (countable > 0xff)
381: return -EINVAL;
382:
383: /*
384: * Counters [0:3] are in select 1 bit offsets 0, 8, 16 and 24
385: * Counters [4:5] are in select 2 bit offset 0, 8
386: */
387:
388: if (counter >= 4)
389: counter -= 4;
390:
391: a6xx_write_gmu_counter_enable(device, reg, counter * 8, countable);
392:
393: kgsl_regwrite(device, A6XX_GMU_CX_GMU_PERF_COUNTER_ENABLE, 1);
394:
395: reg->value = 0;
396: return 0;
397: }
398:
399: static struct adreno_perfcount_register a6xx_perfcounters_cp[] = {
400: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_CP_0_LO,
401: A6XX_RBBM_PERFCTR_CP_0_HI, 0, A6XX_CP_PERFCTR_CP_SEL_0 },
402: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_CP_1_LO,
403: A6XX_RBBM_PERFCTR_CP_1_HI, 1, A6XX_CP_PERFCTR_CP_SEL_1 },
404: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_CP_2_LO,
405: A6XX_RBBM_PERFCTR_CP_2_HI, 2, A6XX_CP_PERFCTR_CP_SEL_2 },
406: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_CP_3_LO,
407: A6XX_RBBM_PERFCTR_CP_3_HI, 3, A6XX_CP_PERFCTR_CP_SEL_3 },
408: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_CP_4_LO,
409: A6XX_RBBM_PERFCTR_CP_4_HI, 4, A6XX_CP_PERFCTR_CP_SEL_4 },
410: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_CP_5_LO,
411: A6XX_RBBM_PERFCTR_CP_5_HI, 5, A6XX_CP_PERFCTR_CP_SEL_5 },
412: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_CP_6_LO,
413: A6XX_RBBM_PERFCTR_CP_6_HI, 6, A6XX_CP_PERFCTR_CP_SEL_6 },
414: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_CP_7_LO,
415: A6XX_RBBM_PERFCTR_CP_7_HI, 7, A6XX_CP_PERFCTR_CP_SEL_7 },
416: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_CP_8_LO,
417: A6XX_RBBM_PERFCTR_CP_8_HI, 8, A6XX_CP_PERFCTR_CP_SEL_8 },
418: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_CP_9_LO,
419: A6XX_RBBM_PERFCTR_CP_9_HI, 9, A6XX_CP_PERFCTR_CP_SEL_9 },
420: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_CP_10_LO,
421: A6XX_RBBM_PERFCTR_CP_10_HI, 10, A6XX_CP_PERFCTR_CP_SEL_10 },
422: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_CP_11_LO,
423: A6XX_RBBM_PERFCTR_CP_11_HI, 11, A6XX_CP_PERFCTR_CP_SEL_11 },
424: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_CP_12_LO,
425: A6XX_RBBM_PERFCTR_CP_12_HI, 12, A6XX_CP_PERFCTR_CP_SEL_12 },
426: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_CP_13_LO,
427: A6XX_RBBM_PERFCTR_CP_13_HI, 13, A6XX_CP_PERFCTR_CP_SEL_13 },
428: };
429:
430: static struct adreno_perfcount_register a6xx_perfcounters_rbbm[] = {
431: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_RBBM_0_LO,
432: A6XX_RBBM_PERFCTR_RBBM_0_HI, 14, A6XX_RBBM_PERFCTR_RBBM_SEL_0 },
433: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_RBBM_1_LO,
434: A6XX_RBBM_PERFCTR_RBBM_1_HI, 15, A6XX_RBBM_PERFCTR_RBBM_SEL_1 },
435: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_RBBM_2_LO,
436: A6XX_RBBM_PERFCTR_RBBM_2_HI, 16, A6XX_RBBM_PERFCTR_RBBM_SEL_2 },
437: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_RBBM_3_LO,
438: A6XX_RBBM_PERFCTR_RBBM_3_HI, 17, A6XX_RBBM_PERFCTR_RBBM_SEL_3 },
439: };
440:
441: static struct adreno_perfcount_register a6xx_perfcounters_pc[] = {
442: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_PC_0_LO,
443: A6XX_RBBM_PERFCTR_PC_0_HI, 18, A6XX_PC_PERFCTR_PC_SEL_0 },
444: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_PC_1_LO,
445: A6XX_RBBM_PERFCTR_PC_1_HI, 19, A6XX_PC_PERFCTR_PC_SEL_1 },
446: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_PC_2_LO,
447: A6XX_RBBM_PERFCTR_PC_2_HI, 20, A6XX_PC_PERFCTR_PC_SEL_2 },
448: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_PC_3_LO,
449: A6XX_RBBM_PERFCTR_PC_3_HI, 21, A6XX_PC_PERFCTR_PC_SEL_3 },
450: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_PC_4_LO,
451: A6XX_RBBM_PERFCTR_PC_4_HI, 22, A6XX_PC_PERFCTR_PC_SEL_4 },
452: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_PC_5_LO,
453: A6XX_RBBM_PERFCTR_PC_5_HI, 23, A6XX_PC_PERFCTR_PC_SEL_5 },
454: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_PC_6_LO,
455: A6XX_RBBM_PERFCTR_PC_6_HI, 24, A6XX_PC_PERFCTR_PC_SEL_6 },
456: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_PC_7_LO,
457: A6XX_RBBM_PERFCTR_PC_7_HI, 25, A6XX_PC_PERFCTR_PC_SEL_7 },
458: };
459:
460: static struct adreno_perfcount_register a6xx_perfcounters_vfd[] = {
461: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_VFD_0_LO,
462: A6XX_RBBM_PERFCTR_VFD_0_HI, 26, A6XX_VFD_PERFCTR_VFD_SEL_0 },
463: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_VFD_1_LO,
464: A6XX_RBBM_PERFCTR_VFD_1_HI, 27, A6XX_VFD_PERFCTR_VFD_SEL_1 },
465: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_VFD_2_LO,
466: A6XX_RBBM_PERFCTR_VFD_2_HI, 28, A6XX_VFD_PERFCTR_VFD_SEL_2 },
467: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_VFD_3_LO,
468: A6XX_RBBM_PERFCTR_VFD_3_HI, 29, A6XX_VFD_PERFCTR_VFD_SEL_3 },
469: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_VFD_4_LO,
470: A6XX_RBBM_PERFCTR_VFD_4_HI, 30, A6XX_VFD_PERFCTR_VFD_SEL_4 },
471: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_VFD_5_LO,
472: A6XX_RBBM_PERFCTR_VFD_5_HI, 31, A6XX_VFD_PERFCTR_VFD_SEL_5 },
473: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_VFD_6_LO,
474: A6XX_RBBM_PERFCTR_VFD_6_HI, 32, A6XX_VFD_PERFCTR_VFD_SEL_6 },
475: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_VFD_7_LO,
476: A6XX_RBBM_PERFCTR_VFD_7_HI, 33, A6XX_VFD_PERFCTR_VFD_SEL_7 },
477: };
478:
479: static struct adreno_perfcount_register a6xx_perfcounters_hlsq[] = {
480: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_HLSQ_0_LO,
481: A6XX_RBBM_PERFCTR_HLSQ_0_HI, 34, A6XX_HLSQ_PERFCTR_HLSQ_SEL_0 },
482: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_HLSQ_1_LO,
483: A6XX_RBBM_PERFCTR_HLSQ_1_HI, 35, A6XX_HLSQ_PERFCTR_HLSQ_SEL_1 },
484: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_HLSQ_2_LO,
485: A6XX_RBBM_PERFCTR_HLSQ_2_HI, 36, A6XX_HLSQ_PERFCTR_HLSQ_SEL_2 },
486: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_HLSQ_3_LO,
487: A6XX_RBBM_PERFCTR_HLSQ_3_HI, 37, A6XX_HLSQ_PERFCTR_HLSQ_SEL_3 },
488: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_HLSQ_4_LO,
489: A6XX_RBBM_PERFCTR_HLSQ_4_HI, 38, A6XX_HLSQ_PERFCTR_HLSQ_SEL_4 },
490: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_HLSQ_5_LO,
491: A6XX_RBBM_PERFCTR_HLSQ_5_HI, 39, A6XX_HLSQ_PERFCTR_HLSQ_SEL_5 },
492: };
493:
494: static struct adreno_perfcount_register a6xx_perfcounters_vpc[] = {
495: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_VPC_0_LO,
496: A6XX_RBBM_PERFCTR_VPC_0_HI, 40, A6XX_VPC_PERFCTR_VPC_SEL_0 },
497: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_VPC_1_LO,
498: A6XX_RBBM_PERFCTR_VPC_1_HI, 41, A6XX_VPC_PERFCTR_VPC_SEL_1 },
499: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_VPC_2_LO,
500: A6XX_RBBM_PERFCTR_VPC_2_HI, 42, A6XX_VPC_PERFCTR_VPC_SEL_2 },
501: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_VPC_3_LO,
502: A6XX_RBBM_PERFCTR_VPC_3_HI, 43, A6XX_VPC_PERFCTR_VPC_SEL_3 },
503: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_VPC_4_LO,
504: A6XX_RBBM_PERFCTR_VPC_4_HI, 44, A6XX_VPC_PERFCTR_VPC_SEL_4 },
505: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_VPC_5_LO,
506: A6XX_RBBM_PERFCTR_VPC_5_HI, 45, A6XX_VPC_PERFCTR_VPC_SEL_5 },
507: };
508:
509: static struct adreno_perfcount_register a6xx_perfcounters_ccu[] = {
510: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_CCU_0_LO,
511: A6XX_RBBM_PERFCTR_CCU_0_HI, 46, A6XX_RB_PERFCTR_CCU_SEL_0 },
512: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_CCU_1_LO,
513: A6XX_RBBM_PERFCTR_CCU_1_HI, 47, A6XX_RB_PERFCTR_CCU_SEL_1 },
514: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_CCU_2_LO,
515: A6XX_RBBM_PERFCTR_CCU_2_HI, 48, A6XX_RB_PERFCTR_CCU_SEL_2 },
516: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_CCU_3_LO,
517: A6XX_RBBM_PERFCTR_CCU_3_HI, 49, A6XX_RB_PERFCTR_CCU_SEL_3 },
518: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_CCU_4_LO,
519: A6XX_RBBM_PERFCTR_CCU_4_HI, 50, A6XX_RB_PERFCTR_CCU_SEL_4 },
520: };
521:
522: static struct adreno_perfcount_register a6xx_perfcounters_tse[] = {
523: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_TSE_0_LO,
524: A6XX_RBBM_PERFCTR_TSE_0_HI, 51, A6XX_GRAS_PERFCTR_TSE_SEL_0 },
525: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_TSE_1_LO,
526: A6XX_RBBM_PERFCTR_TSE_1_HI, 52, A6XX_GRAS_PERFCTR_TSE_SEL_1 },
527: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_TSE_2_LO,
528: A6XX_RBBM_PERFCTR_TSE_2_HI, 53, A6XX_GRAS_PERFCTR_TSE_SEL_2 },
529: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_TSE_3_LO,
530: A6XX_RBBM_PERFCTR_TSE_3_HI, 54, A6XX_GRAS_PERFCTR_TSE_SEL_3 },
531: };
532:
533: static struct adreno_perfcount_register a6xx_perfcounters_ras[] = {
534: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_RAS_0_LO,
535: A6XX_RBBM_PERFCTR_RAS_0_HI, 55, A6XX_GRAS_PERFCTR_RAS_SEL_0 },
536: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_RAS_1_LO,
537: A6XX_RBBM_PERFCTR_RAS_1_HI, 56, A6XX_GRAS_PERFCTR_RAS_SEL_1 },
538: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_RAS_2_LO,
539: A6XX_RBBM_PERFCTR_RAS_2_HI, 57, A6XX_GRAS_PERFCTR_RAS_SEL_2 },
540: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_RAS_3_LO,
541: A6XX_RBBM_PERFCTR_RAS_3_HI, 58, A6XX_GRAS_PERFCTR_RAS_SEL_3 },
542: };
543:
544: static struct adreno_perfcount_register a6xx_perfcounters_uche[] = {
545: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_UCHE_0_LO,
546: A6XX_RBBM_PERFCTR_UCHE_0_HI, 59, A6XX_UCHE_PERFCTR_UCHE_SEL_0 },
547: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_UCHE_1_LO,
548: A6XX_RBBM_PERFCTR_UCHE_1_HI, 60, A6XX_UCHE_PERFCTR_UCHE_SEL_1 },
549: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_UCHE_2_LO,
550: A6XX_RBBM_PERFCTR_UCHE_2_HI, 61, A6XX_UCHE_PERFCTR_UCHE_SEL_2 },
551: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_UCHE_3_LO,
552: A6XX_RBBM_PERFCTR_UCHE_3_HI, 62, A6XX_UCHE_PERFCTR_UCHE_SEL_3 },
553: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_UCHE_4_LO,
554: A6XX_RBBM_PERFCTR_UCHE_4_HI, 63, A6XX_UCHE_PERFCTR_UCHE_SEL_4 },
555: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_UCHE_5_LO,
556: A6XX_RBBM_PERFCTR_UCHE_5_HI, 64, A6XX_UCHE_PERFCTR_UCHE_SEL_5 },
557: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_UCHE_6_LO,
558: A6XX_RBBM_PERFCTR_UCHE_6_HI, 65, A6XX_UCHE_PERFCTR_UCHE_SEL_6 },
559: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_UCHE_7_LO,
560: A6XX_RBBM_PERFCTR_UCHE_7_HI, 66, A6XX_UCHE_PERFCTR_UCHE_SEL_7 },
561: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_UCHE_8_LO,
562: A6XX_RBBM_PERFCTR_UCHE_8_HI, 67, A6XX_UCHE_PERFCTR_UCHE_SEL_8 },
563: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_UCHE_9_LO,
564: A6XX_RBBM_PERFCTR_UCHE_9_HI, 68, A6XX_UCHE_PERFCTR_UCHE_SEL_9 },
565: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_UCHE_10_LO,
566: A6XX_RBBM_PERFCTR_UCHE_10_HI, 69,
567: A6XX_UCHE_PERFCTR_UCHE_SEL_10 },
568: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_UCHE_11_LO,
569: A6XX_RBBM_PERFCTR_UCHE_11_HI, 70,
570: A6XX_UCHE_PERFCTR_UCHE_SEL_11 },
571: };
572:
573: static struct adreno_perfcount_register a6xx_perfcounters_tp[] = {
574: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_TP_0_LO,
575: A6XX_RBBM_PERFCTR_TP_0_HI, 71, A6XX_TPL1_PERFCTR_TP_SEL_0 },
576: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_TP_1_LO,
577: A6XX_RBBM_PERFCTR_TP_1_HI, 72, A6XX_TPL1_PERFCTR_TP_SEL_1 },
578: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_TP_2_LO,
579: A6XX_RBBM_PERFCTR_TP_2_HI, 73, A6XX_TPL1_PERFCTR_TP_SEL_2 },
580: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_TP_3_LO,
581: A6XX_RBBM_PERFCTR_TP_3_HI, 74, A6XX_TPL1_PERFCTR_TP_SEL_3 },
582: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_TP_4_LO,
583: A6XX_RBBM_PERFCTR_TP_4_HI, 75, A6XX_TPL1_PERFCTR_TP_SEL_4 },
584: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_TP_5_LO,
585: A6XX_RBBM_PERFCTR_TP_5_HI, 76, A6XX_TPL1_PERFCTR_TP_SEL_5 },
586: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_TP_6_LO,
587: A6XX_RBBM_PERFCTR_TP_6_HI, 77, A6XX_TPL1_PERFCTR_TP_SEL_6 },
588: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_TP_7_LO,
589: A6XX_RBBM_PERFCTR_TP_7_HI, 78, A6XX_TPL1_PERFCTR_TP_SEL_7 },
590: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_TP_8_LO,
591: A6XX_RBBM_PERFCTR_TP_8_HI, 79, A6XX_TPL1_PERFCTR_TP_SEL_8 },
592: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_TP_9_LO,
593: A6XX_RBBM_PERFCTR_TP_9_HI, 80, A6XX_TPL1_PERFCTR_TP_SEL_9 },
594: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_TP_10_LO,
595: A6XX_RBBM_PERFCTR_TP_10_HI, 81, A6XX_TPL1_PERFCTR_TP_SEL_10 },
596: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_TP_11_LO,
597: A6XX_RBBM_PERFCTR_TP_11_HI, 82, A6XX_TPL1_PERFCTR_TP_SEL_11 },
598: };
599:
600: static struct adreno_perfcount_register a6xx_perfcounters_sp[] = {
601: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_SP_0_LO,
602: A6XX_RBBM_PERFCTR_SP_0_HI, 83, A6XX_SP_PERFCTR_SP_SEL_0 },
603: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_SP_1_LO,
604: A6XX_RBBM_PERFCTR_SP_1_HI, 84, A6XX_SP_PERFCTR_SP_SEL_1 },
605: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_SP_2_LO,
606: A6XX_RBBM_PERFCTR_SP_2_HI, 85, A6XX_SP_PERFCTR_SP_SEL_2 },
607: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_SP_3_LO,
608: A6XX_RBBM_PERFCTR_SP_3_HI, 86, A6XX_SP_PERFCTR_SP_SEL_3 },
609: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_SP_4_LO,
610: A6XX_RBBM_PERFCTR_SP_4_HI, 87, A6XX_SP_PERFCTR_SP_SEL_4 },
611: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_SP_5_LO,
612: A6XX_RBBM_PERFCTR_SP_5_HI, 88, A6XX_SP_PERFCTR_SP_SEL_5 },
613: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_SP_6_LO,
614: A6XX_RBBM_PERFCTR_SP_6_HI, 89, A6XX_SP_PERFCTR_SP_SEL_6 },
615: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_SP_7_LO,
616: A6XX_RBBM_PERFCTR_SP_7_HI, 90, A6XX_SP_PERFCTR_SP_SEL_7 },
617: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_SP_8_LO,
618: A6XX_RBBM_PERFCTR_SP_8_HI, 91, A6XX_SP_PERFCTR_SP_SEL_8 },
619: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_SP_9_LO,
620: A6XX_RBBM_PERFCTR_SP_9_HI, 92, A6XX_SP_PERFCTR_SP_SEL_9 },
621: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_SP_10_LO,
622: A6XX_RBBM_PERFCTR_SP_10_HI, 93, A6XX_SP_PERFCTR_SP_SEL_10 },
623: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_SP_11_LO,
624: A6XX_RBBM_PERFCTR_SP_11_HI, 94, A6XX_SP_PERFCTR_SP_SEL_11 },
625: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_SP_12_LO,
626: A6XX_RBBM_PERFCTR_SP_12_HI, 95, A6XX_SP_PERFCTR_SP_SEL_12 },
627: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_SP_13_LO,
628: A6XX_RBBM_PERFCTR_SP_13_HI, 96, A6XX_SP_PERFCTR_SP_SEL_13 },
629: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_SP_14_LO,
630: A6XX_RBBM_PERFCTR_SP_14_HI, 97, A6XX_SP_PERFCTR_SP_SEL_14 },
631: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_SP_15_LO,
632: A6XX_RBBM_PERFCTR_SP_15_HI, 98, A6XX_SP_PERFCTR_SP_SEL_15 },
633: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_SP_16_LO,
634: A6XX_RBBM_PERFCTR_SP_16_HI, 99, A6XX_SP_PERFCTR_SP_SEL_16 },
635: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_SP_17_LO,
636: A6XX_RBBM_PERFCTR_SP_17_HI, 100, A6XX_SP_PERFCTR_SP_SEL_17 },
637: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_SP_18_LO,
638: A6XX_RBBM_PERFCTR_SP_18_HI, 101, A6XX_SP_PERFCTR_SP_SEL_18 },
639: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_SP_19_LO,
640: A6XX_RBBM_PERFCTR_SP_19_HI, 102, A6XX_SP_PERFCTR_SP_SEL_19 },
641: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_SP_20_LO,
642: A6XX_RBBM_PERFCTR_SP_20_HI, 103, A6XX_SP_PERFCTR_SP_SEL_20 },
643: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_SP_21_LO,
644: A6XX_RBBM_PERFCTR_SP_21_HI, 104, A6XX_SP_PERFCTR_SP_SEL_21 },
645: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_SP_22_LO,
646: A6XX_RBBM_PERFCTR_SP_22_HI, 105, A6XX_SP_PERFCTR_SP_SEL_22 },
647: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_SP_23_LO,
648: A6XX_RBBM_PERFCTR_SP_23_HI, 106, A6XX_SP_PERFCTR_SP_SEL_23 },
649: };
650:
651: static struct adreno_perfcount_register a6xx_perfcounters_rb[] = {
652: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_RB_0_LO,
653: A6XX_RBBM_PERFCTR_RB_0_HI, 107, A6XX_RB_PERFCTR_RB_SEL_0 },
654: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_RB_1_LO,
655: A6XX_RBBM_PERFCTR_RB_1_HI, 108, A6XX_RB_PERFCTR_RB_SEL_1 },
656: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_RB_2_LO,
657: A6XX_RBBM_PERFCTR_RB_2_HI, 109, A6XX_RB_PERFCTR_RB_SEL_2 },
658: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_RB_3_LO,
659: A6XX_RBBM_PERFCTR_RB_3_HI, 110, A6XX_RB_PERFCTR_RB_SEL_3 },
660: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_RB_4_LO,
661: A6XX_RBBM_PERFCTR_RB_4_HI, 111, A6XX_RB_PERFCTR_RB_SEL_4 },
662: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_RB_5_LO,
663: A6XX_RBBM_PERFCTR_RB_5_HI, 112, A6XX_RB_PERFCTR_RB_SEL_5 },
664: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_RB_6_LO,
665: A6XX_RBBM_PERFCTR_RB_6_HI, 113, A6XX_RB_PERFCTR_RB_SEL_6 },
666: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_RB_7_LO,
667: A6XX_RBBM_PERFCTR_RB_7_HI, 114, A6XX_RB_PERFCTR_RB_SEL_7 },
668: };
669:
670: static struct adreno_perfcount_register a6xx_perfcounters_vsc[] = {
671: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_VSC_0_LO,
672: A6XX_RBBM_PERFCTR_VSC_0_HI, 115, A6XX_VSC_PERFCTR_VSC_SEL_0 },
673: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_VSC_1_LO,
674: A6XX_RBBM_PERFCTR_VSC_1_HI, 116, A6XX_VSC_PERFCTR_VSC_SEL_1 },
675: };
676:
677: static struct adreno_perfcount_register a6xx_perfcounters_lrz[] = {
678: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_LRZ_0_LO,
679: A6XX_RBBM_PERFCTR_LRZ_0_HI, 117, A6XX_GRAS_PERFCTR_LRZ_SEL_0 },
680: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_LRZ_1_LO,
681: A6XX_RBBM_PERFCTR_LRZ_1_HI, 118, A6XX_GRAS_PERFCTR_LRZ_SEL_1 },
682: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_LRZ_2_LO,
683: A6XX_RBBM_PERFCTR_LRZ_2_HI, 119, A6XX_GRAS_PERFCTR_LRZ_SEL_2 },
684: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_LRZ_3_LO,
685: A6XX_RBBM_PERFCTR_LRZ_3_HI, 120, A6XX_GRAS_PERFCTR_LRZ_SEL_3 },
686: };
687:
688: static struct adreno_perfcount_register a6xx_perfcounters_cmp[] = {
689: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_CMP_0_LO,
690: A6XX_RBBM_PERFCTR_CMP_0_HI, 121, A6XX_RB_PERFCTR_CMP_SEL_0 },
691: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_CMP_1_LO,
692: A6XX_RBBM_PERFCTR_CMP_1_HI, 122, A6XX_RB_PERFCTR_CMP_SEL_1 },
693: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_CMP_2_LO,
694: A6XX_RBBM_PERFCTR_CMP_2_HI, 123, A6XX_RB_PERFCTR_CMP_SEL_2 },
695: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_RBBM_PERFCTR_CMP_3_LO,
696: A6XX_RBBM_PERFCTR_CMP_3_HI, 124, A6XX_RB_PERFCTR_CMP_SEL_3 },
697: };
698:
699: static struct adreno_perfcount_register a6xx_perfcounters_vbif[] = {
700: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_VBIF_PERF_CNT_LOW0,
701: A6XX_VBIF_PERF_CNT_HIGH0, -1, A6XX_VBIF_PERF_CNT_SEL0 },
702: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_VBIF_PERF_CNT_LOW1,
703: A6XX_VBIF_PERF_CNT_HIGH1, -1, A6XX_VBIF_PERF_CNT_SEL1 },
704: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_VBIF_PERF_CNT_LOW2,
705: A6XX_VBIF_PERF_CNT_HIGH2, -1, A6XX_VBIF_PERF_CNT_SEL2 },
706: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_VBIF_PERF_CNT_LOW3,
707: A6XX_VBIF_PERF_CNT_HIGH3, -1, A6XX_VBIF_PERF_CNT_SEL3 },
708: };
709:
710: static struct adreno_perfcount_register a6xx_perfcounters_vbif_pwr[] = {
711: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_VBIF_PERF_PWR_CNT_LOW0,
712: A6XX_VBIF_PERF_PWR_CNT_HIGH0, -1, A6XX_VBIF_PERF_PWR_CNT_EN0 },
713: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_VBIF_PERF_PWR_CNT_LOW1,
714: A6XX_VBIF_PERF_PWR_CNT_HIGH1, -1, A6XX_VBIF_PERF_PWR_CNT_EN1 },
715: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_VBIF_PERF_PWR_CNT_LOW2,
716: A6XX_VBIF_PERF_PWR_CNT_HIGH2, -1, A6XX_VBIF_PERF_PWR_CNT_EN2 },
717: };
718:
719:
720: static struct adreno_perfcount_register a6xx_perfcounters_gbif[] = {
721: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_GBIF_PERF_CNT_LOW0,
722: A6XX_GBIF_PERF_CNT_HIGH0, -1, A6XX_GBIF_PERF_CNT_SEL },
723: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_GBIF_PERF_CNT_LOW1,
724: A6XX_GBIF_PERF_CNT_HIGH1, -1, A6XX_GBIF_PERF_CNT_SEL },
725: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_GBIF_PERF_CNT_LOW2,
726: A6XX_GBIF_PERF_CNT_HIGH2, -1, A6XX_GBIF_PERF_CNT_SEL },
727: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_GBIF_PERF_CNT_LOW3,
728: A6XX_GBIF_PERF_CNT_HIGH3, -1, A6XX_GBIF_PERF_CNT_SEL },
729: };
730:
731: static struct adreno_perfcount_register a6xx_perfcounters_gbif_pwr[] = {
732: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_GBIF_PWR_CNT_LOW0,
733: A6XX_GBIF_PWR_CNT_HIGH0, -1, A6XX_GBIF_PERF_PWR_CNT_EN },
734: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_GBIF_PWR_CNT_LOW1,
735: A6XX_GBIF_PWR_CNT_HIGH1, -1, A6XX_GBIF_PERF_PWR_CNT_EN },
736: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_GBIF_PWR_CNT_LOW2,
737: A6XX_GBIF_PWR_CNT_HIGH2, -1, A6XX_GBIF_PERF_PWR_CNT_EN },
738: };
739:
740: #define GMU_COUNTER(lo, hi, sel) \
741: { .countable = KGSL_PERFCOUNTER_NOT_USED, \
742: .offset = lo, .offset_hi = hi, .select = sel }
743:
744: #define GMU_COUNTER_RESERVED(lo, hi, sel) \
745: { .countable = KGSL_PERFCOUNTER_BROKEN, \
746: .offset = lo, .offset_hi = hi, .select = sel }
747:
748: static struct adreno_perfcount_register a6xx_perfcounters_gmu_xoclk[] = {
749: /*
750: * COUNTER_XOCLK_0 and COUNTER_XOCLK_4 are used for the GPU
751: * busy and ifpc count. Mark them as reserved to ensure they
752: * are not re-used.
753: */
754: GMU_COUNTER_RESERVED(A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_L,
755: A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_H,
756: A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_0),
757: GMU_COUNTER(A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_1_L,
758: A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_1_H,
759: A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_0),
760: GMU_COUNTER(A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_2_L,
761: A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_2_H,
762: A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_0),
763: GMU_COUNTER(A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_3_L,
764: A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_3_H,
765: A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_0),
766: GMU_COUNTER_RESERVED(A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_4_L,
767: A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_4_H,
768: A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_1),
769: GMU_COUNTER(A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_5_L,
770: A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_5_H,
771: A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_1),
772: GMU_COUNTER(A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_6_L,
773: A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_6_H,
774: A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_2),
775: GMU_COUNTER(A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_7_L,
776: A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_7_H,
777: A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_2),
778: GMU_COUNTER(A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_8_L,
779: A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_8_H,
780: A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_2),
781: GMU_COUNTER(A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_9_L,
782: A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_9_H,
783: A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_2),
784: };
785:
786: static struct adreno_perfcount_register a6xx_perfcounters_gmu_gmuclk[] = {
787: GMU_COUNTER(A6XX_GMU_CX_GMU_POWER_COUNTER_GMUCLK_0_L,
788: A6XX_GMU_CX_GMU_POWER_COUNTER_GMUCLK_0_H,
789: A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_1),
790: GMU_COUNTER(A6XX_GMU_CX_GMU_POWER_COUNTER_GMUCLK_1_L,
791: A6XX_GMU_CX_GMU_POWER_COUNTER_GMUCLK_1_H,
792: A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_1),
793: };
794:
795: static struct adreno_perfcount_register a6xx_perfcounters_gmu_perf[] = {
796: GMU_COUNTER(A6XX_GMU_CX_GMU_PERF_COUNTER_0_L,
797: A6XX_GMU_CX_GMU_PERF_COUNTER_0_H,
798: A6XX_GMU_CX_GMU_PERF_COUNTER_SELECT_0),
799: GMU_COUNTER(A6XX_GMU_CX_GMU_PERF_COUNTER_1_L,
800: A6XX_GMU_CX_GMU_PERF_COUNTER_1_H,
801: A6XX_GMU_CX_GMU_PERF_COUNTER_SELECT_0),
802: GMU_COUNTER(A6XX_GMU_CX_GMU_PERF_COUNTER_2_L,
803: A6XX_GMU_CX_GMU_PERF_COUNTER_2_H,
804: A6XX_GMU_CX_GMU_PERF_COUNTER_SELECT_0),
805: GMU_COUNTER(A6XX_GMU_CX_GMU_PERF_COUNTER_3_L,
806: A6XX_GMU_CX_GMU_PERF_COUNTER_3_H,
807: A6XX_GMU_CX_GMU_PERF_COUNTER_SELECT_0),
808: GMU_COUNTER(A6XX_GMU_CX_GMU_PERF_COUNTER_4_L,
809: A6XX_GMU_CX_GMU_PERF_COUNTER_4_H,
810: A6XX_GMU_CX_GMU_PERF_COUNTER_SELECT_1),
811: GMU_COUNTER(A6XX_GMU_CX_GMU_PERF_COUNTER_5_L,
812: A6XX_GMU_CX_GMU_PERF_COUNTER_5_H,
813: A6XX_GMU_CX_GMU_PERF_COUNTER_SELECT_1),
814: };
815:
816: static struct adreno_perfcount_register a6xx_perfcounters_alwayson[] = {
817: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_CP_ALWAYS_ON_COUNTER_LO,
818: A6XX_CP_ALWAYS_ON_COUNTER_HI, -1 },
819: };
820:
821: /*
822: * ADRENO_PERFCOUNTER_GROUP_RESTORE flag is enabled by default
823: * because most of the perfcounter groups need to be restored
824: * as part of preemption and IFPC. Perfcounter groups that are
825: * not restored as part of preemption and IFPC should be defined
826: * using A6XX_PERFCOUNTER_GROUP_FLAGS macro
827: */
828: #define A6XX_PERFCOUNTER_GROUP(offset, name, enable, read, load) \
829: ADRENO_PERFCOUNTER_GROUP_FLAGS(a6xx, offset, name, \
830: ADRENO_PERFCOUNTER_GROUP_RESTORE, enable, read, load)
831:
832: #define A6XX_PERFCOUNTER_GROUP_FLAGS(offset, name, flags, enable, read, load) \
833: ADRENO_PERFCOUNTER_GROUP_FLAGS(a6xx, offset, name, flags, enable, \
834: read, load)
835:
836: #define A6XX_REGULAR_PERFCOUNTER_GROUP(offset, name) \
837: A6XX_PERFCOUNTER_GROUP(offset, name, \
838: a6xx_counter_enable, a6xx_counter_read, a6xx_counter_load)
839:
840: static const struct adreno_perfcount_group a630_perfcounter_groups
841: [KGSL_PERFCOUNTER_GROUP_MAX] = {
842: A6XX_REGULAR_PERFCOUNTER_GROUP(CP, cp),
843: A6XX_PERFCOUNTER_GROUP_FLAGS(RBBM, rbbm, 0,
844: a6xx_counter_enable, a6xx_counter_read, a6xx_counter_load),
845: A6XX_REGULAR_PERFCOUNTER_GROUP(PC, pc),
846: A6XX_REGULAR_PERFCOUNTER_GROUP(VFD, vfd),
847: A6XX_PERFCOUNTER_GROUP(HLSQ, hlsq, a6xx_counter_inline_enable,
848: a6xx_counter_read, a6xx_counter_load),
849: A6XX_REGULAR_PERFCOUNTER_GROUP(VPC, vpc),
850: A6XX_REGULAR_PERFCOUNTER_GROUP(CCU, ccu),
851: A6XX_REGULAR_PERFCOUNTER_GROUP(CMP, cmp),
852: A6XX_REGULAR_PERFCOUNTER_GROUP(TSE, tse),
853: A6XX_REGULAR_PERFCOUNTER_GROUP(RAS, ras),
854: A6XX_REGULAR_PERFCOUNTER_GROUP(LRZ, lrz),
855: A6XX_REGULAR_PERFCOUNTER_GROUP(UCHE, uche),
856: A6XX_PERFCOUNTER_GROUP(TP, tp, a6xx_counter_inline_enable,
857: a6xx_counter_read, a6xx_counter_load),
858: A6XX_PERFCOUNTER_GROUP(SP, sp, a6xx_counter_inline_enable,
859: a6xx_counter_read, a6xx_counter_load),
860: A6XX_REGULAR_PERFCOUNTER_GROUP(RB, rb),
861: A6XX_REGULAR_PERFCOUNTER_GROUP(VSC, vsc),
862: A6XX_PERFCOUNTER_GROUP_FLAGS(VBIF, vbif, 0,
863: a630_counter_vbif_enable, a6xx_counter_read_norestore, NULL),
864: A6XX_PERFCOUNTER_GROUP_FLAGS(VBIF_PWR, vbif_pwr,
865: ADRENO_PERFCOUNTER_GROUP_FIXED, a630_counter_vbif_pwr_enable,
866: a6xx_counter_read_norestore, NULL),
867: A6XX_PERFCOUNTER_GROUP_FLAGS(ALWAYSON, alwayson,
868: ADRENO_PERFCOUNTER_GROUP_FIXED,
869: a6xx_counter_alwayson_enable, a6xx_counter_alwayson_read, NULL),
870: };
871:
872: static const struct adreno_perfcount_group
873: a6xx_legacy_perfcounter_groups [KGSL_PERFCOUNTER_GROUP_MAX] = {
874: A6XX_REGULAR_PERFCOUNTER_GROUP(CP, cp),
875: A6XX_PERFCOUNTER_GROUP_FLAGS(RBBM, rbbm, 0,
876: a6xx_counter_enable, a6xx_counter_read, a6xx_counter_load),
877: A6XX_REGULAR_PERFCOUNTER_GROUP(PC, pc),
878: A6XX_REGULAR_PERFCOUNTER_GROUP(VFD, vfd),
879: A6XX_PERFCOUNTER_GROUP(HLSQ, hlsq, a6xx_counter_inline_enable,
880: a6xx_counter_read, a6xx_counter_load),
881: A6XX_REGULAR_PERFCOUNTER_GROUP(VPC, vpc),
882: A6XX_REGULAR_PERFCOUNTER_GROUP(CCU, ccu),
883: A6XX_REGULAR_PERFCOUNTER_GROUP(CMP, cmp),
884: A6XX_REGULAR_PERFCOUNTER_GROUP(TSE, tse),
885: A6XX_REGULAR_PERFCOUNTER_GROUP(RAS, ras),
886: A6XX_REGULAR_PERFCOUNTER_GROUP(LRZ, lrz),
887: A6XX_REGULAR_PERFCOUNTER_GROUP(UCHE, uche),
888: A6XX_PERFCOUNTER_GROUP(TP, tp, a6xx_counter_inline_enable,
889: a6xx_counter_read, a6xx_counter_load),
890: A6XX_PERFCOUNTER_GROUP(SP, sp, a6xx_counter_inline_enable,
891: a6xx_counter_read, a6xx_counter_load),
892: A6XX_REGULAR_PERFCOUNTER_GROUP(RB, rb),
893: A6XX_REGULAR_PERFCOUNTER_GROUP(VSC, vsc),
894: A6XX_PERFCOUNTER_GROUP_FLAGS(VBIF, gbif, 0,
895: a6xx_counter_gbif_enable, a6xx_counter_read_norestore, NULL),
896: A6XX_PERFCOUNTER_GROUP_FLAGS(VBIF_PWR, gbif_pwr,
897: ADRENO_PERFCOUNTER_GROUP_FIXED, a6xx_counter_gbif_pwr_enable,
898: a6xx_counter_read_norestore, NULL),
899: A6XX_PERFCOUNTER_GROUP_FLAGS(ALWAYSON, alwayson,
900: ADRENO_PERFCOUNTER_GROUP_FIXED,
901: a6xx_counter_alwayson_enable, a6xx_counter_alwayson_read, NULL),
902: };
903:
904: static const struct adreno_perfcount_group a6xx_perfcounter_groups
905: [KGSL_PERFCOUNTER_GROUP_MAX] = {
906: A6XX_REGULAR_PERFCOUNTER_GROUP(CP, cp),
907: A6XX_PERFCOUNTER_GROUP_FLAGS(RBBM, rbbm, 0,
908: a6xx_counter_enable, a6xx_counter_read, a6xx_counter_load),
909: A6XX_REGULAR_PERFCOUNTER_GROUP(PC, pc),
910: A6XX_REGULAR_PERFCOUNTER_GROUP(VFD, vfd),
911: A6XX_PERFCOUNTER_GROUP(HLSQ, hlsq, a6xx_counter_inline_enable,
912: a6xx_counter_read, a6xx_counter_load),
913: A6XX_REGULAR_PERFCOUNTER_GROUP(VPC, vpc),
914: A6XX_REGULAR_PERFCOUNTER_GROUP(CCU, ccu),
915: A6XX_REGULAR_PERFCOUNTER_GROUP(CMP, cmp),
916: A6XX_REGULAR_PERFCOUNTER_GROUP(TSE, tse),
917: A6XX_REGULAR_PERFCOUNTER_GROUP(RAS, ras),
918: A6XX_REGULAR_PERFCOUNTER_GROUP(LRZ, lrz),
919: A6XX_REGULAR_PERFCOUNTER_GROUP(UCHE, uche),
920: A6XX_PERFCOUNTER_GROUP(TP, tp, a6xx_counter_inline_enable,
921: a6xx_counter_read, a6xx_counter_load),
922: A6XX_PERFCOUNTER_GROUP(SP, sp, a6xx_counter_inline_enable,
923: a6xx_counter_read, a6xx_counter_load),
924: A6XX_REGULAR_PERFCOUNTER_GROUP(RB, rb),
925: A6XX_REGULAR_PERFCOUNTER_GROUP(VSC, vsc),
926: A6XX_PERFCOUNTER_GROUP_FLAGS(VBIF, gbif, 0,
927: a6xx_counter_gbif_enable, a6xx_counter_read_norestore, NULL),
928: A6XX_PERFCOUNTER_GROUP_FLAGS(VBIF_PWR, gbif_pwr,
929: ADRENO_PERFCOUNTER_GROUP_FIXED, a6xx_counter_gbif_pwr_enable,
930: a6xx_counter_read_norestore, NULL),
931: A6XX_PERFCOUNTER_GROUP_FLAGS(ALWAYSON, alwayson,
932: ADRENO_PERFCOUNTER_GROUP_FIXED,
933: a6xx_counter_alwayson_enable, a6xx_counter_alwayson_read, NULL),
934: A6XX_PERFCOUNTER_GROUP_FLAGS(GMU_XOCLK, gmu_xoclk, 0,
935: a6xx_counter_gmu_xoclk_enable, a6xx_counter_read_norestore,
936: NULL),
937: A6XX_PERFCOUNTER_GROUP_FLAGS(GMU_GMUCLK, gmu_gmuclk, 0,
938: a6xx_counter_gmu_gmuclk_enable, a6xx_counter_read_norestore,
939: NULL),
940: A6XX_PERFCOUNTER_GROUP_FLAGS(GMU_PERF, gmu_perf, 0,
941: a6xx_counter_gmu_perf_enable, a6xx_counter_read_norestore,
942: NULL),
943: };
944:
945: /* a610, a612, gen6_3_26_0, a616, a618 and a619 do not have the GMU registers.
946: * a605, a608, a615, a630, a640 and a680 don't have enough room in the
947: * CP_PROTECT registers so the GMU counters are not accessible
948: */
949: const struct adreno_perfcounters adreno_a6xx_legacy_perfcounters = {
950: a6xx_legacy_perfcounter_groups,
951: ARRAY_SIZE(a6xx_legacy_perfcounter_groups),
952: };
953:
954: const struct adreno_perfcounters adreno_a630_perfcounters = {
955: a630_perfcounter_groups,
956: ARRAY_SIZE(a630_perfcounter_groups),
957: };
958:
959: const struct adreno_perfcounters adreno_a6xx_perfcounters = {
960: a6xx_perfcounter_groups,
961: ARRAY_SIZE(a6xx_perfcounter_groups),
962: };
--- FILE: \adreno_a6xx_preempt.c | HITS: 65 ---
MATCH LINES: 14, 17, 36, 37, 46, 48, 80, 83, 88, 91, 95, 108, 141, 162, 172, 195, 207, 213, 234, 250
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: #include "adreno.h"
8: #include "adreno_a6xx.h"
9: #include "adreno_pm4types.h"
10: #include "adreno_trace.h"
11: #include "kgsl_util.h"
12:
13: #define PREEMPT_RECORD(_field) \
14: offsetof(struct a6xx_cp_preemption_record, _field)
15:
16: #define PREEMPT_SMMU_RECORD(_field) \
17: offsetof(struct a6xx_cp_smmu_info, _field)
18:
19: static void _update_wptr(struct adreno_device *adreno_dev, bool reset_timer,
20: bool atomic)
21: {
22: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
23: struct adreno_ringbuffer *rb = adreno_dev->cur_rb;
24: unsigned long flags;
25: int ret = 0;
26:
27: spin_lock_irqsave(&rb->preempt_lock, flags);
28:
29: if (!atomic) {
30: /*
31: * We might have skipped updating the wptr in case we are in
32: * dispatcher context. Do it now.
33: */
34: if (rb->skip_inline_wptr) {
35:
36: ret = a6xx_fenced_write(adreno_dev,
37: A6XX_CP_RB_WPTR, rb->wptr,
38: FENCE_STATUS_WRITEDROPPED0_MASK);
39:
40: reset_timer = true;
41: rb->skip_inline_wptr = false;
42: }
43: } else {
44: unsigned int wptr;
45:
46: kgsl_regread(device, A6XX_CP_RB_WPTR, &wptr);
47: if (wptr != rb->wptr) {
48: kgsl_regwrite(device, A6XX_CP_RB_WPTR, rb->wptr);
49: reset_timer = true;
50: }
51: }
52:
53: if (reset_timer)
54: rb->dispatch_q.expires = jiffies +
55: msecs_to_jiffies(adreno_drawobj_timeout);
56:
57: spin_unlock_irqrestore(&rb->preempt_lock, flags);
58:
59: if (!atomic) {
60: /* If WPTR update fails, set the fault and trigger recovery */
61: if (ret) {
62: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
63: adreno_scheduler_fault(adreno_dev,
64: ADRENO_GMU_FAULT_SKIP_SNAPSHOT);
65: }
66: }
67: }
68:
69: static void _power_collapse_set(struct adreno_device *adreno_dev, bool val)
70: {
71: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
72:
73: if (!gmu_core_isenabled(device))
74: return;
75:
76: if (val) {
77: if (adreno_is_a660(adreno_dev) ||
78: adreno_is_a663(adreno_dev))
79: gmu_core_regwrite(device,
80: A6XX_GMU_PWR_COL_PREEMPT_KEEPALIVE, 0x1);
81: else
82: gmu_core_regrmw(device,
83: A6XX_GMU_AO_SPARE_CNTL, 0x0, 0x2);
84: } else {
85: if (adreno_is_a660(adreno_dev) ||
86: adreno_is_a663(adreno_dev))
87: gmu_core_regwrite(device,
88: A6XX_GMU_PWR_COL_PREEMPT_KEEPALIVE, 0x0);
89: else
90: gmu_core_regrmw(device,
91: A6XX_GMU_AO_SPARE_CNTL, 0x2, 0x0);
92: }
93: }
94:
95: static void _a6xx_preemption_done(struct adreno_device *adreno_dev)
96: {
97: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
98: unsigned int status;
99:
100: /*
101: * In the very unlikely case that the power is off, do nothing - the
102: * state will be reset on power up and everybody will be happy
103: */
104:
105: if (!kgsl_state_is_awake(device))
106: return;
107:
108: kgsl_regread(device, A6XX_CP_CONTEXT_SWITCH_CNTL, &status);
109:
110: if (status & 0x1) {
111: dev_err(device->dev,
112: "Preemption not complete: status=%X cur=%d R/W=%X/%X next=%d R/W=%X/%X\n",
113: status, adreno_dev->cur_rb->id,
114: adreno_get_rptr(adreno_dev->cur_rb),
115: adreno_dev->cur_rb->wptr,
116: adreno_dev->next_rb->id,
117: adreno_get_rptr(adreno_dev->next_rb),
118: adreno_dev->next_rb->wptr);
119:
120: /* Set a fault and restart */
121: adreno_scheduler_fault(adreno_dev, ADRENO_PREEMPT_FAULT);
122:
123: return;
124: }
125:
126: adreno_dev->preempt.count++;
127:
128: /*
129: * In normal scenarios, preemption keep alive bit is cleared during
130: * CP interrupt callback. However, if preemption is successful
131: * immediately after preemption timer expires or there is a preemption
132: * interrupt with non-zero status, the state is transitioned to complete
133: * state. Once dispatcher is scheduled, it calls this function.
134: * We can now safely clear the preemption keepalive bit, allowing
135: * power collapse to resume its regular activity.
136: */
137: _power_collapse_set(adreno_dev, false);
138:
139: kgsl_delete_timer_sync(&adreno_dev->preempt.timer);
140:
141: kgsl_regread(device, A6XX_CP_CONTEXT_SWITCH_LEVEL_STATUS, &status);
142:
143: trace_adreno_preempt_done(adreno_dev->cur_rb->id, adreno_dev->next_rb->id,
144: status, 0);
145:
146: /* Clean up all the bits */
147: adreno_dev->prev_rb = adreno_dev->cur_rb;
148: adreno_dev->cur_rb = adreno_dev->next_rb;
149: adreno_dev->next_rb = NULL;
150:
151: /* Update the wptr for the new command queue */
152: _update_wptr(adreno_dev, true, false);
153:
154: /* Update the dispatcher timer for the new command queue */
155: mod_timer(&adreno_dev->dispatcher.timer,
156: adreno_dev->cur_rb->dispatch_q.expires);
157:
158: /* Clear the preempt state */
159: adreno_set_preempt_state(adreno_dev, ADRENO_PREEMPT_NONE);
160: }
161:
162: static void _a6xx_preemption_fault(struct adreno_device *adreno_dev)
163: {
164: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
165: unsigned int status;
166:
167: /*
168: * If the power is on check the preemption status one more time - if it
169: * was successful then just transition to the complete state
170: */
171: if (kgsl_state_is_awake(device)) {
172: kgsl_regread(device, A6XX_CP_CONTEXT_SWITCH_CNTL, &status);
173:
174: if (!(status & 0x1)) {
175: adreno_set_preempt_state(adreno_dev,
176: ADRENO_PREEMPT_COMPLETE);
177:
178: adreno_scheduler_queue(adreno_dev);
179: return;
180: }
181: }
182:
183: dev_err(device->dev,
184: "Preemption Fault: cur=%d R/W=0x%x/0x%x, next=%d R/W=0x%x/0x%x\n",
185: adreno_dev->cur_rb->id,
186: adreno_get_rptr(adreno_dev->cur_rb),
187: adreno_dev->cur_rb->wptr,
188: adreno_dev->next_rb->id,
189: adreno_get_rptr(adreno_dev->next_rb),
190: adreno_dev->next_rb->wptr);
191:
192: adreno_scheduler_fault(adreno_dev, ADRENO_PREEMPT_FAULT);
193: }
194:
195: static void _a6xx_preemption_worker(struct work_struct *work)
196: {
197: struct adreno_preemption *preempt = container_of(work,
198: struct adreno_preemption, work);
199: struct adreno_device *adreno_dev = container_of(preempt,
200: struct adreno_device, preempt);
201: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
202:
203: /* Need to take the mutex to make sure that the power stays on */
204: kgsl_mutex_lock(&device->mutex);
205:
206: if (adreno_in_preempt_state(adreno_dev, ADRENO_PREEMPT_FAULTED))
207: _a6xx_preemption_fault(adreno_dev);
208:
209: kgsl_mutex_unlock(&device->mutex);
210: }
211:
212: /* Find the highest priority active ringbuffer */
213: static struct adreno_ringbuffer *a6xx_next_ringbuffer(
214: struct adreno_device *adreno_dev)
215: {
216: struct adreno_ringbuffer *rb;
217: unsigned long flags;
218: unsigned int i;
219:
220: FOR_EACH_RINGBUFFER(adreno_dev, rb, i) {
221: bool empty;
222:
223: spin_lock_irqsave(&rb->preempt_lock, flags);
224: empty = adreno_rb_empty(rb);
225: spin_unlock_irqrestore(&rb->preempt_lock, flags);
226:
227: if (!empty)
228: return rb;
229: }
230:
231: return NULL;
232: }
233:
234: void a6xx_preemption_trigger(struct adreno_device *adreno_dev, bool atomic)
235: {
236: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
237: struct kgsl_iommu *iommu = KGSL_IOMMU(device);
238: struct adreno_ringbuffer *next;
239: uint64_t ttbr0, gpuaddr;
240: unsigned int contextidr, cntl;
241: unsigned long flags;
242: struct adreno_preemption *preempt = &adreno_dev->preempt;
243:
244: /* Put ourselves into a possible trigger state */
245: if (!adreno_move_preempt_state(adreno_dev,
246: ADRENO_PREEMPT_NONE, ADRENO_PREEMPT_START))
247: return;
248:
249: /* Get the next ringbuffer to preempt in */
250: next = a6xx_next_ringbuffer(adreno_dev);
251:
252: /*
253: * Nothing to do if every ringbuffer is empty or if the current
254: * ringbuffer is the only active one
255: */
256: if (next == NULL || next == adreno_dev->cur_rb) {
257: /*
258: * Update any critical things that might have been skipped while
259: * we were looking for a new ringbuffer
260: */
261:
262: if (next != NULL) {
263: _update_wptr(adreno_dev, false, atomic);
264:
265: mod_timer(&adreno_dev->dispatcher.timer,
266: adreno_dev->cur_rb->dispatch_q.expires);
267: }
268:
269: adreno_set_preempt_state(adreno_dev, ADRENO_PREEMPT_NONE);
270: return;
271: }
272:
273: /* Turn off the dispatcher timer */
274: kgsl_delete_timer(&adreno_dev->dispatcher.timer);
MATCH LINES: 325, 326, 343, 344, 350, 351, 356, 357, 363, 364, 369, 370, 397, 420, 429, 457, 475, 478, 488, 490, 495, 513
313: * further power collapse while it is set.
314: * It is more efficient to use a keepalive+wake-on-fence approach here
315: * rather than an OOB. Both keepalive and the fence are effectively
316: * free when the GPU is already powered on, whereas an OOB requires an
317: * unconditional handshake with the GMU.
318: */
319: _power_collapse_set(adreno_dev, true);
320:
321: /*
322: * Fenced writes on this path will make sure the GPU is woken up
323: * in case it was power collapsed by the GMU.
324: */
325: if (a6xx_fenced_write(adreno_dev,
326: A6XX_CP_CONTEXT_SWITCH_PRIV_NON_SECURE_RESTORE_ADDR_LO,
327: lower_32_bits(next->preemption_desc->gpuaddr),
328: FENCE_STATUS_WRITEDROPPED1_MASK))
329: goto err;
330:
331: /*
332: * Above fence writes will make sure GMU comes out of
333: * IFPC state if its was in IFPC state but it doesn't
334: * guarantee that GMU FW actually moved to ACTIVE state
335: * i.e. wake-up from IFPC is complete.
336: * Wait for GMU to move to ACTIVE state before triggering
337: * preemption. This is require to make sure CP doesn't
338: * interrupt GMU during wake-up from IFPC.
339: */
340: if (!atomic && gmu_core_dev_wait_for_active_transition(device))
341: goto err;
342:
343: if (a6xx_fenced_write(adreno_dev,
344: A6XX_CP_CONTEXT_SWITCH_PRIV_NON_SECURE_RESTORE_ADDR_HI,
345: upper_32_bits(next->preemption_desc->gpuaddr),
346: FENCE_STATUS_WRITEDROPPED1_MASK))
347: goto err;
348:
349: if (kgsl_mmu_is_secured(&device->mmu)) {
350: if (a6xx_fenced_write(adreno_dev,
351: A6XX_CP_CONTEXT_SWITCH_PRIV_SECURE_RESTORE_ADDR_LO,
352: lower_32_bits(next->secure_preemption_desc->gpuaddr),
353: FENCE_STATUS_WRITEDROPPED1_MASK))
354: goto err;
355:
356: if (a6xx_fenced_write(adreno_dev,
357: A6XX_CP_CONTEXT_SWITCH_PRIV_SECURE_RESTORE_ADDR_HI,
358: upper_32_bits(next->secure_preemption_desc->gpuaddr),
359: FENCE_STATUS_WRITEDROPPED1_MASK))
360: goto err;
361: }
362:
363: if (a6xx_fenced_write(adreno_dev,
364: A6XX_CP_CONTEXT_SWITCH_NON_PRIV_RESTORE_ADDR_LO,
365: lower_32_bits(gpuaddr),
366: FENCE_STATUS_WRITEDROPPED1_MASK))
367: goto err;
368:
369: if (a6xx_fenced_write(adreno_dev,
370: A6XX_CP_CONTEXT_SWITCH_NON_PRIV_RESTORE_ADDR_HI,
371: upper_32_bits(gpuaddr),
372: FENCE_STATUS_WRITEDROPPED1_MASK))
373: goto err;
374:
375: adreno_dev->next_rb = next;
376:
377: /* Start the timer to detect a stuck preemption */
378: mod_timer(&adreno_dev->preempt.timer,
379: jiffies + msecs_to_jiffies(ADRENO_PREEMPT_TIMEOUT));
380:
381: cntl = (preempt->preempt_level << 6) | 0x01;
382:
383: /* Skip save/restore during L1 preemption */
384: if (preempt->skipsaverestore)
385: cntl |= (1 << 9);
386:
387: /* Enable GMEM save/restore across preemption */
388: if (preempt->usesgmem)
389: cntl |= (1 << 8);
390:
391: trace_adreno_preempt_trigger(adreno_dev->cur_rb->id, adreno_dev->next_rb->id,
392: cntl, 0);
393:
394: adreno_set_preempt_state(adreno_dev, ADRENO_PREEMPT_TRIGGERED);
395:
396: /* Trigger the preemption */
397: if (a6xx_fenced_write(adreno_dev, A6XX_CP_CONTEXT_SWITCH_CNTL, cntl,
398: FENCE_STATUS_WRITEDROPPED1_MASK)) {
399: adreno_dev->next_rb = NULL;
400: kgsl_delete_timer(&adreno_dev->preempt.timer);
401: goto err;
402: }
403:
404: return;
405: err:
406: /* If fenced write fails, take inline snapshot and trigger recovery */
407: if (!atomic) {
408: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
409: adreno_scheduler_fault(adreno_dev,
410: ADRENO_GMU_FAULT_SKIP_SNAPSHOT);
411: } else {
412: adreno_scheduler_fault(adreno_dev, ADRENO_GMU_FAULT);
413: }
414: adreno_set_preempt_state(adreno_dev, ADRENO_PREEMPT_NONE);
415: /* Clear the keep alive */
416: _power_collapse_set(adreno_dev, false);
417:
418: }
419:
420: void a6xx_preemption_callback(struct adreno_device *adreno_dev, int bit)
421: {
422: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
423: unsigned int status;
424:
425: if (!adreno_move_preempt_state(adreno_dev,
426: ADRENO_PREEMPT_TRIGGERED, ADRENO_PREEMPT_PENDING))
427: return;
428:
429: kgsl_regread(device, A6XX_CP_CONTEXT_SWITCH_CNTL, &status);
430:
431: if (status & 0x1) {
432: dev_err(KGSL_DEVICE(adreno_dev)->dev,
433: "preempt interrupt with non-zero status: %X\n",
434: status);
435:
436: /*
437: * Under the assumption that this is a race between the
438: * interrupt and the register, schedule the worker to clean up.
439: * If the status still hasn't resolved itself by the time we get
440: * there then we have to assume something bad happened
441: */
442: adreno_set_preempt_state(adreno_dev, ADRENO_PREEMPT_COMPLETE);
443: adreno_scheduler_queue(adreno_dev);
444: return;
445: }
446:
447: adreno_dev->preempt.count++;
448:
449: /*
450: * We can now safely clear the preemption keepalive bit, allowing
451: * power collapse to resume its regular activity.
452: */
453: _power_collapse_set(adreno_dev, false);
454:
455: kgsl_delete_timer(&adreno_dev->preempt.timer);
456:
457: kgsl_regread(device, A6XX_CP_CONTEXT_SWITCH_LEVEL_STATUS, &status);
458:
459: trace_adreno_preempt_done(adreno_dev->cur_rb->id, adreno_dev->next_rb->id,
460: status, 0);
461:
462: adreno_dev->prev_rb = adreno_dev->cur_rb;
463: adreno_dev->cur_rb = adreno_dev->next_rb;
464: adreno_dev->next_rb = NULL;
465:
466: /* Update the wptr if it changed while preemption was ongoing */
467: _update_wptr(adreno_dev, true, true);
468:
469: /* Update the dispatcher timer for the new command queue */
470: mod_timer(&adreno_dev->dispatcher.timer,
471: adreno_dev->cur_rb->dispatch_q.expires);
472:
473: adreno_set_preempt_state(adreno_dev, ADRENO_PREEMPT_NONE);
474:
475: a6xx_preemption_trigger(adreno_dev, true);
476: }
477:
478: void a6xx_preemption_schedule(struct adreno_device *adreno_dev)
479: {
480: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
481:
482: if (!adreno_is_preemption_enabled(adreno_dev))
483: return;
484:
485: kgsl_mutex_lock(&device->mutex);
486:
487: if (adreno_in_preempt_state(adreno_dev, ADRENO_PREEMPT_COMPLETE))
488: _a6xx_preemption_done(adreno_dev);
489:
490: a6xx_preemption_trigger(adreno_dev, false);
491:
492: kgsl_mutex_unlock(&device->mutex);
493: }
494:
495: u32 a6xx_preemption_pre_ibsubmit(struct adreno_device *adreno_dev,
496: struct adreno_ringbuffer *rb, struct adreno_context *drawctxt,
497: u32 *cmds)
498: {
499: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
500: u32 count = kgsl_mmu_is_secured(&device->mmu) ? 12 : 9;
501: unsigned int *cmds_orig = cmds;
502: uint64_t gpuaddr = 0;
503:
504: if (!adreno_is_preemption_enabled(adreno_dev))
505: return 0;
506:
507: if (drawctxt && drawctxt->base.user_ctxt_record)
508: gpuaddr = drawctxt->base.user_ctxt_record->memdesc.gpuaddr;
509:
510: if (gpuaddr)
511: count += 3;
512:
513: *cmds++ = cp_type7_packet(CP_SET_PSEUDO_REGISTER, count);
514: /* NULL SMMU_INFO buffer - we track in KMD */
515: *cmds++ = SET_PSEUDO_SMMU_INFO;
516: cmds += cp_gpuaddr(adreno_dev, cmds, 0x0);
517:
518: *cmds++ = SET_PSEUDO_PRIV_NON_SECURE_SAVE_ADDR;
519: cmds += cp_gpuaddr(adreno_dev, cmds, rb->preemption_desc->gpuaddr);
520:
521: if (kgsl_mmu_is_secured(&device->mmu)) {
522: *cmds++ = SET_PSEUDO_PRIV_SECURE_SAVE_ADDR;
523: cmds += cp_gpuaddr(adreno_dev, cmds,
524: rb->secure_preemption_desc->gpuaddr);
525: }
526:
527: if (gpuaddr) {
528: *cmds++ = SET_PSEUDO_NON_PRIV_SAVE_ADDR;
529: cmds += cp_gpuaddr(adreno_dev, cmds, gpuaddr);
530: }
531:
532: /*
533: * There is no need to specify this address when we are about to
534: * trigger preemption. This is because CP internally stores this
535: * address specified here in the CP_SET_PSEUDO_REGISTER payload to
536: * the context record and thus knows from where to restore
537: * the saved perfcounters for the new ringbuffer.
MATCH LINES: 556, 567, 574, 583, 597, 599, 609, 612, 630, 636, 646, 659, 663, 664, 667, 668, 685, 696, 710, 714, 742, 745, 747
544: goto done;
545:
546: cmds += adreno_prepare_preib_preempt_scratch(adreno_dev, drawctxt, cmds);
547:
548: /* Add a KMD post amble to clear the perf counters during preemption */
549: if (!adreno_dev->perfcounter)
550: cmds += adreno_prepare_preib_postamble_scratch(adreno_dev, cmds);
551:
552: done:
553: return (u32) (cmds - cmds_orig);
554: }
555:
556: u32 a6xx_preemption_post_ibsubmit(struct adreno_device *adreno_dev,
557: u32 *cmds)
558: {
559: u32 index = 0;
560:
561: if (!adreno_is_preemption_enabled(adreno_dev))
562: return 0;
563:
564: if (adreno_dev->cur_rb) {
565: u64 dest = PREEMPT_SCRATCH_ADDR(adreno_dev, adreno_dev->cur_rb->id);
566:
567: cmds[index++] = cp_type7_packet(CP_MEM_WRITE, 4);
568: cmds[index++] = lower_32_bits(dest);
569: cmds[index++] = upper_32_bits(dest);
570: cmds[index++] = 0;
571: cmds[index++] = 0;
572: }
573:
574: cmds[index++] = cp_type7_packet(CP_CONTEXT_SWITCH_YIELD, 4);
575: cmds[index++] = 0;
576: cmds[index++] = 0;
577: cmds[index++] = 1;
578: cmds[index++] = 0;
579:
580: return index;
581: }
582:
583: void a6xx_preemption_start(struct adreno_device *adreno_dev)
584: {
585: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
586: struct kgsl_iommu *iommu = KGSL_IOMMU(device);
587: struct adreno_ringbuffer *rb;
588: unsigned int i;
589:
590: if (!adreno_is_preemption_enabled(adreno_dev))
591: return;
592:
593: /* Force the state to be clear */
594: adreno_set_preempt_state(adreno_dev, ADRENO_PREEMPT_NONE);
595:
596: if (kgsl_mmu_is_perprocess(&device->mmu)) {
597: /* smmu_info is allocated and mapped in a6xx_preemption_iommu_init */
598: kgsl_sharedmem_writel(iommu->smmu_info,
599: PREEMPT_SMMU_RECORD(magic), A6XX_CP_SMMU_INFO_MAGIC_REF);
600: kgsl_sharedmem_writeq(iommu->smmu_info,
601: PREEMPT_SMMU_RECORD(ttbr0), MMU_DEFAULT_TTBR0(device));
602:
603: /* The CP doesn't use the asid record, so poison it */
604: kgsl_sharedmem_writel(iommu->smmu_info,
605: PREEMPT_SMMU_RECORD(asid), 0xDECAFBAD);
606: kgsl_sharedmem_writel(iommu->smmu_info,
607: PREEMPT_SMMU_RECORD(context_idr), 0);
608:
609: kgsl_regwrite(device, A6XX_CP_CONTEXT_SWITCH_SMMU_INFO_LO,
610: lower_32_bits(iommu->smmu_info->gpuaddr));
611:
612: kgsl_regwrite(device, A6XX_CP_CONTEXT_SWITCH_SMMU_INFO_HI,
613: upper_32_bits(iommu->smmu_info->gpuaddr));
614: }
615:
616: FOR_EACH_RINGBUFFER(adreno_dev, rb, i) {
617: kgsl_sharedmem_writel(rb->preemption_desc,
618: PREEMPT_RECORD(rptr), 0);
619: kgsl_sharedmem_writel(rb->preemption_desc,
620: PREEMPT_RECORD(wptr), 0);
621:
622: adreno_ringbuffer_set_pagetable(device, rb,
623: device->mmu.defaultpagetable);
624: }
625: }
626:
627: static void reset_rb_preempt_record(struct adreno_device *adreno_dev,
628: struct adreno_ringbuffer *rb)
629: {
630: u32 cp_rb_cntl = A6XX_CP_RB_CNTL_DEFAULT |
631: (ADRENO_FEATURE(adreno_dev, ADRENO_APRIV) ? 0 : (1 << 27));
632:
633: memset(rb->preemption_desc->hostptr, 0x0, rb->preemption_desc->size);
634:
635: kgsl_sharedmem_writel(rb->preemption_desc,
636: PREEMPT_RECORD(magic), A6XX_CP_CTXRECORD_MAGIC_REF);
637: kgsl_sharedmem_writel(rb->preemption_desc,
638: PREEMPT_RECORD(cntl), cp_rb_cntl);
639: kgsl_sharedmem_writeq(rb->preemption_desc,
640: PREEMPT_RECORD(rptr_addr), SCRATCH_RB_GPU_ADDR(
641: KGSL_DEVICE(adreno_dev), rb->id, rptr));
642: kgsl_sharedmem_writeq(rb->preemption_desc,
643: PREEMPT_RECORD(rbase), rb->buffer_desc->gpuaddr);
644: }
645:
646: void a6xx_reset_preempt_records(struct adreno_device *adreno_dev)
647: {
648: int i;
649: struct adreno_ringbuffer *rb;
650:
651: if (!adreno_is_preemption_enabled(adreno_dev))
652: return;
653:
654: FOR_EACH_RINGBUFFER(adreno_dev, rb, i) {
655: reset_rb_preempt_record(adreno_dev, rb);
656: }
657: }
658:
659: static int a6xx_preemption_ringbuffer_init(struct adreno_device *adreno_dev,
660: struct adreno_ringbuffer *rb)
661: {
662: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
663: const struct adreno_a6xx_core *a6xx_core = to_a6xx_core(adreno_dev);
664: u64 ctxt_record_size = A6XX_CP_CTXRECORD_SIZE_IN_BYTES;
665: int ret;
666:
667: if (a6xx_core->ctxt_record_size)
668: ctxt_record_size = a6xx_core->ctxt_record_size;
669:
670: ret = adreno_allocate_global(device, &rb->preemption_desc,
671: ctxt_record_size, SZ_16K, 0, KGSL_MEMDESC_PRIVILEGED,
672: "preemption_desc");
673: if (ret)
674: return ret;
675:
676: if (kgsl_mmu_is_secured(&device->mmu)) {
677: ret = adreno_allocate_global(device, &rb->secure_preemption_desc,
678: ctxt_record_size, 0, KGSL_MEMFLAGS_SECURE,
679: KGSL_MEMDESC_PRIVILEGED, "preemption_desc");
680: if (ret)
681: return ret;
682: }
683:
684: ret = adreno_allocate_global(device, &rb->perfcounter_save_restore_desc,
685: A6XX_CP_PERFCOUNTER_SAVE_RESTORE_SIZE, 0, 0,
686: KGSL_MEMDESC_PRIVILEGED,
687: "perfcounter_save_restore_desc");
688: if (ret)
689: return ret;
690:
691: reset_rb_preempt_record(adreno_dev, rb);
692:
693: return 0;
694: }
695:
696: int a6xx_preemption_init(struct adreno_device *adreno_dev)
697: {
698: u32 flags = ADRENO_FEATURE(adreno_dev, ADRENO_APRIV) ? KGSL_MEMDESC_PRIVILEGED : 0;
699: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
700: struct kgsl_iommu *iommu = KGSL_IOMMU(device);
701: struct adreno_preemption *preempt = &adreno_dev->preempt;
702: struct adreno_ringbuffer *rb;
703: int ret;
704: unsigned int i;
705:
706: /* We are dependent on IOMMU to make preemption go on the CP side */
707: if (kgsl_mmu_get_mmutype(device) != KGSL_MMU_TYPE_IOMMU)
708: return -ENODEV;
709:
710: INIT_WORK(&preempt->work, _a6xx_preemption_worker);
711:
712: /* Allocate mem for storing preemption switch record */
713: FOR_EACH_RINGBUFFER(adreno_dev, rb, i) {
714: ret = a6xx_preemption_ringbuffer_init(adreno_dev, rb);
715: if (ret)
716: return ret;
717: }
718:
719: ret = adreno_allocate_global(device, &preempt->scratch,
720: PAGE_SIZE, 0, 0, flags, "preempt_scratch");
721: if (ret)
722: return ret;
723:
724: /* Allocate mem for storing preemption smmu record */
725: if (kgsl_mmu_is_perprocess(&device->mmu)) {
726: ret = adreno_allocate_global(device, &iommu->smmu_info, PAGE_SIZE, 0,
727: KGSL_MEMFLAGS_GPUREADONLY, KGSL_MEMDESC_PRIVILEGED,
728: "smmu_info");
729: if (ret)
730: return ret;
731: }
732:
733: /*
734: * First 28 dwords of the device scratch buffer are used to store shadow rb data.
735: * Insert PM4 packets in device scratch buffer to clear perfcounters. This should
736: * be in *device->scratch* so that userspace cannot access it.
737: */
738: if (!adreno_dev->perfcounter) {
739: u32 *postamble = device->scratch->hostptr + SCRATCH_POSTAMBLE_OFFSET;
740: u32 count = 0;
741:
742: postamble[count++] = cp_type4_packet(A6XX_RBBM_PERFCTR_SRAM_INIT_CMD, 1);
743: postamble[count++] = 0x1;
744:
745: postamble[count++] = cp_type7_packet(CP_WAIT_REG_MEM, 6);
746: postamble[count++] = 0x3;
747: postamble[count++] = A6XX_RBBM_PERFCTR_SRAM_INIT_STATUS;
748: postamble[count++] = 0x0;
749: postamble[count++] = 0x1;
750: postamble[count++] = 0x1;
751: postamble[count++] = 0x0;
752:
753: preempt->postamble_len = count;
754: }
755:
756: set_bit(ADRENO_DEVICE_PREEMPTION, &adreno_dev->priv);
757: return 0;
758: }
--- FILE: \adreno_a6xx_rgmu.c | HITS: 257 ---
MATCH LINES: 17, 31, 44, 46, 47, 49, 52, 55, 58, 63, 65, 80, 84, 87, 90, 114, 118, 121, 130, 133, 143, 151, 157, 161, 164, 169, 173, 175, 180, 184, 188, 194, 200, 202, 206, 207, 209, 211, 219, 221, 229, 230, 232, 233, 236, 240, 259, 261, 267, 270, 274, 279, 283, 286, 294, 300, 309, 313, 318, 321, 322, 323, 324, 325, 326, 327, 328, 329
5: */
6:
7: #include <linux/clk-provider.h>
8: #include <linux/component.h>
9: #include <linux/delay.h>
10: #include <linux/firmware.h>
11: #include <linux/io.h>
12: #include <linux/of.h>
13: #include <linux/of_platform.h>
14:
15: #include "adreno.h"
16: #include "adreno_a6xx.h"
17: #include "adreno_a6xx_rgmu.h"
18: #include "adreno_snapshot.h"
19: #include "kgsl_bus.h"
20: #include "kgsl_trace.h"
21: #include "kgsl_util.h"
22:
23: #define RGMU_CLK_FREQ 200000000
24:
25: /* RGMU timeouts */
26: #define RGMU_IDLE_TIMEOUT 100 /* ms */
27: #define RGMU_START_TIMEOUT 100 /* ms */
28: #define GPU_START_TIMEOUT 100 /* ms */
29: #define GLM_SLEEP_TIMEOUT 10 /* ms */
30:
31: static const unsigned int a6xx_rgmu_registers[] = {
32: /* GMU CX */
33: 0x1F80F, 0x1F83D, 0x1F840, 0x1F8D8, 0x1F990, 0x1F99E, 0x1F9C0, 0x1F9CC,
34: /* GMU AO */
35: 0x23B03, 0x23B16, 0x23B80, 0x23B82,
36: /* GPU CC */
37: 0x24000, 0x24012, 0x24040, 0x24052, 0x24400, 0x24404, 0x24407, 0x2440B,
38: 0x24415, 0x2441C, 0x2441E, 0x2442D, 0x2443C, 0x2443D, 0x2443F, 0x24440,
39: 0x24442, 0x24449, 0x24458, 0x2445A, 0x24540, 0x2455E, 0x24800, 0x24802,
40: 0x24C00, 0x24C02, 0x25400, 0x25402, 0x25800, 0x25802, 0x25C00, 0x25C02,
41: 0x26000, 0x26002,
42: };
43:
44: static struct a6xx_rgmu_device *to_a6xx_rgmu(struct adreno_device *adreno_dev)
45: {
46: struct a6xx_device *a6xx_dev = container_of(adreno_dev,
47: struct a6xx_device, adreno_dev);
48:
49: return &a6xx_dev->rgmu;
50: }
51:
52: static irqreturn_t a6xx_rgmu_irq_handler(int irq, void *data)
53: {
54: struct kgsl_device *device = data;
55: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(ADRENO_DEVICE(device));
56: unsigned int status = 0;
57:
58: gmu_core_regread(device, A6XX_GMU_AO_HOST_INTERRUPT_STATUS, &status);
59:
60: if (status & RGMU_AO_IRQ_FENCE_ERR) {
61: unsigned int fence_status;
62:
63: gmu_core_regread(device, A6XX_GMU_AHB_FENCE_STATUS,
64: &fence_status);
65: gmu_core_regwrite(device, A6XX_GMU_AO_HOST_INTERRUPT_CLR,
66: status);
67:
68: dev_err_ratelimited(&rgmu->pdev->dev,
69: "FENCE error interrupt received %x\n", fence_status);
70: }
71:
72: if (status & ~RGMU_AO_IRQ_MASK)
73: dev_err_ratelimited(&rgmu->pdev->dev,
74: "Unhandled RGMU interrupts 0x%lx\n",
75: status & ~RGMU_AO_IRQ_MASK);
76:
77: return IRQ_HANDLED;
78: }
79:
80: static irqreturn_t a6xx_oob_irq_handler(int irq, void *data)
81: {
82: struct kgsl_device *device = data;
83: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
84: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
85: unsigned int status = 0;
86:
87: gmu_core_regread(device, A6XX_GMU_GMU2HOST_INTR_INFO, &status);
88:
89: if (status & RGMU_OOB_IRQ_ERR_MSG) {
90: gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_CLR, status);
91:
92: dev_err_ratelimited(&rgmu->pdev->dev,
93: "RGMU oob irq error\n");
94: adreno_scheduler_fault(adreno_dev, ADRENO_GMU_FAULT);
95: }
96: if (status & ~RGMU_OOB_IRQ_MASK)
97: dev_err_ratelimited(&rgmu->pdev->dev,
98: "Unhandled OOB interrupts 0x%lx\n",
99: status & ~RGMU_OOB_IRQ_MASK);
100:
101: return IRQ_HANDLED;
102: }
103:
104: static const char *oob_to_str(enum oob_request req)
105: {
106: if (req == oob_gpu)
107: return "oob_gpu";
108: else if (req == oob_perfcntr)
109: return "oob_perfcntr";
110: return "unknown";
111: }
112:
113: /*
114: * a6xx_rgmu_oob_set() - Set OOB interrupt to RGMU
115: * @adreno_dev: Pointer to adreno device
116: * @req: Which of the OOB bits to request
117: */
118: static int a6xx_rgmu_oob_set(struct kgsl_device *device,
119: enum oob_request req)
120: {
121: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(ADRENO_DEVICE(device));
122: int ret, set, check;
123:
124: if (req == oob_perfcntr && rgmu->num_oob_perfcntr++)
125: return 0;
126:
127: set = BIT(req + 16);
128: check = BIT(req + 16);
129:
130: gmu_core_regwrite(device, A6XX_GMU_HOST2GMU_INTR_SET, set);
131:
132: ret = gmu_core_timed_poll_check(device,
133: A6XX_GMU_GMU2HOST_INTR_INFO,
134: check,
135: GPU_START_TIMEOUT,
136: check);
137:
138: if (ret) {
139: unsigned int status;
140:
141: if (req == oob_perfcntr)
142: rgmu->num_oob_perfcntr--;
143: gmu_core_regread(device, A6XX_RGMU_CX_PCC_DEBUG, &status);
144: dev_err(&rgmu->pdev->dev,
145: "Timed out while setting OOB req:%s status:0x%x\n",
146: oob_to_str(req), status);
147: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
148: return ret;
149: }
150:
151: gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_CLR, check);
152: trace_kgsl_gmu_oob_set(set);
153: return 0;
154: }
155:
156: /*
157: * a6xx_rgmu_oob_clear() - Clear a previously set OOB request.
158: * @adreno_dev: Pointer to the adreno device that has the RGMU
159: * @req: Which of the OOB bits to clear
160: */
161: static void a6xx_rgmu_oob_clear(struct kgsl_device *device,
162: enum oob_request req)
163: {
164: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(ADRENO_DEVICE(device));
165:
166: if (req == oob_perfcntr && --rgmu->num_oob_perfcntr)
167: return;
168:
169: gmu_core_regwrite(device, A6XX_GMU_HOST2GMU_INTR_SET, BIT(req + 24));
170: trace_kgsl_gmu_oob_clear(BIT(req + 24));
171: }
172:
173: static void a6xx_rgmu_bcl_config(struct kgsl_device *device, bool on)
174: {
175: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(ADRENO_DEVICE(device));
176:
177: if (on) {
178: /* Enable BCL CRC HW i/f */
179: gmu_core_regwrite(device,
180: A6XX_GMU_AO_RGMU_GLM_HW_CRC_DISABLE, 0);
181: } else {
182: /* Disable CRC HW i/f */
183: gmu_core_regwrite(device,
184: A6XX_GMU_AO_RGMU_GLM_HW_CRC_DISABLE, 1);
185:
186: /* Wait for HW CRC disable ACK */
187: if (gmu_core_timed_poll_check(device,
188: A6XX_GMU_AO_RGMU_GLM_SLEEP_STATUS,
189: BIT(1), GLM_SLEEP_TIMEOUT, BIT(1)))
190: dev_err_ratelimited(&rgmu->pdev->dev,
191: "Timed out waiting for HW CRC disable acknowledgment\n");
192:
193: /* Pull down the valid RGMU_GLM_SLEEP_CTRL[7] to 0 */
194: gmu_core_regrmw(device, A6XX_GMU_AO_RGMU_GLM_SLEEP_CTRL,
195: BIT(7), 0);
196:
197: }
198: }
199:
200: static void a6xx_rgmu_irq_enable(struct adreno_device *adreno_dev)
201: {
202: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
203: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
204:
205: /* Clear pending IRQs and Unmask needed IRQs */
206: gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_CLR, 0xffffffff);
207: gmu_core_regwrite(device, A6XX_GMU_AO_HOST_INTERRUPT_CLR, 0xffffffff);
208:
209: gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_MASK,
210: ~((unsigned int)RGMU_OOB_IRQ_MASK));
211: gmu_core_regwrite(device, A6XX_GMU_AO_HOST_INTERRUPT_MASK,
212: (unsigned int)~RGMU_AO_IRQ_MASK);
213:
214: /* Enable all IRQs on host */
215: enable_irq(rgmu->oob_interrupt_num);
216: enable_irq(rgmu->rgmu_interrupt_num);
217: }
218:
219: static void a6xx_rgmu_irq_disable(struct adreno_device *adreno_dev)
220: {
221: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
222: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
223:
224: /* Disable all IRQs on host */
225: disable_irq(rgmu->rgmu_interrupt_num);
226: disable_irq(rgmu->oob_interrupt_num);
227:
228: /* Mask all IRQs and clear pending IRQs */
229: gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_MASK, 0xffffffff);
230: gmu_core_regwrite(device, A6XX_GMU_AO_HOST_INTERRUPT_MASK, 0xffffffff);
231:
232: gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_CLR, 0xffffffff);
233: gmu_core_regwrite(device, A6XX_GMU_AO_HOST_INTERRUPT_CLR, 0xffffffff);
234: }
235:
236: static int a6xx_rgmu_ifpc_store(struct kgsl_device *device,
237: unsigned int val)
238: {
239: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
240: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
241: unsigned int requested_idle_level;
242:
243: if (!ADRENO_FEATURE(adreno_dev, ADRENO_IFPC))
244: return -EINVAL;
245:
246: if (val)
247: requested_idle_level = GPU_HW_IFPC;
248: else
249: requested_idle_level = GPU_HW_ACTIVE;
250:
251: if (requested_idle_level == rgmu->idle_level)
252: return 0;
253:
254: /* Power cycle the GPU for changes to take effect */
255: return adreno_power_cycle_u32(adreno_dev, &rgmu->idle_level,
256: requested_idle_level);
257: }
258:
259: static unsigned int a6xx_rgmu_ifpc_isenabled(struct kgsl_device *device)
260: {
261: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(ADRENO_DEVICE(device));
262:
263: return rgmu->idle_level == GPU_HW_IFPC;
264: }
265:
266:
267: static void a6xx_rgmu_prepare_stop(struct kgsl_device *device)
268: {
269: /* Turn off GX_MEM retention */
270: kgsl_regwrite(device, A6XX_RBBM_BLOCK_GX_RETENTION_CNTL, 0);
271: }
272:
273: #define GX_GDSC_POWER_OFF BIT(6)
274: bool a6xx_rgmu_gx_is_on(struct adreno_device *adreno_dev)
275: {
276: unsigned int val;
277:
278: gmu_core_regread(KGSL_DEVICE(adreno_dev),
279: A6XX_GMU_SPTPRAC_PWR_CLK_STATUS, &val);
280: return !(val & GX_GDSC_POWER_OFF);
281: }
282:
283: static int a6xx_rgmu_wait_for_lowest_idle(struct adreno_device *adreno_dev)
284: {
285: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
286: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
287: unsigned int reg[10] = {0};
288: unsigned long t;
289: uint64_t ts1, ts2, ts3;
290:
291: if (rgmu->idle_level != GPU_HW_IFPC)
292: return 0;
293:
294: ts1 = a6xx_read_alwayson(adreno_dev);
295:
296: /* FIXME: readl_poll_timeout? */
297: t = jiffies + msecs_to_jiffies(RGMU_IDLE_TIMEOUT);
298: do {
299: gmu_core_regread(device,
300: A6XX_GMU_SPTPRAC_PWR_CLK_STATUS, ®[0]);
301:
302: if (reg[0] & GX_GDSC_POWER_OFF)
303: return 0;
304:
305: /* Wait 10us to reduce unnecessary AHB bus traffic */
306: usleep_range(10, 100);
307: } while (!time_after(jiffies, t));
308:
309: ts2 = a6xx_read_alwayson(adreno_dev);
310:
311: /* Do one last read incase it succeeds */
312: gmu_core_regread(device,
313: A6XX_GMU_SPTPRAC_PWR_CLK_STATUS, ®[0]);
314:
315: if (reg[0] & GX_GDSC_POWER_OFF)
316: return 0;
317:
318: ts3 = a6xx_read_alwayson(adreno_dev);
319:
320: /* Collect abort data to help with debugging */
321: gmu_core_regread(device, A6XX_RGMU_CX_PCC_DEBUG, ®[1]);
322: gmu_core_regread(device, A6XX_RGMU_CX_PCC_STATUS, ®[2]);
323: gmu_core_regread(device, A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS, ®[3]);
324: kgsl_regread(device, A6XX_CP_STATUS_1, ®[4]);
325: gmu_core_regread(device, A6XX_GMU_RBBM_INT_UNMASKED_STATUS, ®[5]);
326: gmu_core_regread(device, A6XX_GMU_GMU_PWR_COL_KEEPALIVE, ®[6]);
327: kgsl_regread(device, A6XX_CP_CP2GMU_STATUS, ®[7]);
328: kgsl_regread(device, A6XX_CP_CONTEXT_SWITCH_CNTL, ®[8]);
329: gmu_core_regread(device, A6XX_GMU_AO_SPARE_CNTL, ®[9]);
330:
331: dev_err(&rgmu->pdev->dev,
332: "----------------------[ RGMU error ]----------------------\n");
333: dev_err(&rgmu->pdev->dev, "Timeout waiting for lowest idle level\n");
334: dev_err(&rgmu->pdev->dev,
335: "Timestamps: %llx %llx %llx\n", ts1, ts2, ts3);
336: dev_err(&rgmu->pdev->dev,
337: "SPTPRAC_PWR_CLK_STATUS=%x PCC_DEBUG=%x PCC_STATUS=%x\n",
338: reg[0], reg[1], reg[2]);
339: dev_err(&rgmu->pdev->dev,
340: "CX_BUSY_STATUS=%x CP_STATUS_1=%x\n", reg[3], reg[4]);
341: dev_err(&rgmu->pdev->dev,
342: "RBBM_INT_UNMASKED_STATUS=%x PWR_COL_KEEPALIVE=%x\n",
343: reg[5], reg[6]);
344: dev_err(&rgmu->pdev->dev,
345: "CP2GMU_STATUS=%x CONTEXT_SWITCH_CNTL=%x AO_SPARE_CNTL=%x\n",
346: reg[7], reg[8], reg[9]);
347:
348: WARN_ON(1);
349: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
350: return -ETIMEDOUT;
351: }
352:
353: /*
MATCH LINES: 372, 376, 384, 388, 395, 397, 402, 405, 408, 409, 412, 418, 421, 424, 430, 432, 434, 442, 447, 452, 455, 458, 460, 468, 478, 489, 493, 495, 496, 498, 500, 501, 508, 512, 513, 519, 523
360: #define A6X_RGMU_LONG_IFPC_HYST FIELD_PREP(GENMASK(15, 0), 0x1680)
361: #define A6X_RGMU_SHORT_IFPC_HYST FIELD_PREP(GENMASK(31, 16), 0xA)
362:
363: /* Minimum IFPC timer (200usec) allowed to override default value */
364: #define A6X_RGMU_LONG_IFPC_HYST_FLOOR FIELD_PREP(GENMASK(15, 0), 0x0F00)
365:
366: /* HOSTTOGMU and TIMER0/1 interrupt mask: 0x20060 */
367: #define RGMU_INTR_EN_MASK (BIT(5) | BIT(6) | BIT(17))
368:
369: /* RGMU FENCE RANGE MASK */
370: #define RGMU_FENCE_RANGE_MASK ((0x1 << 31) | ((0xA << 2) << 18) | (0x8A0))
371:
372: static int a6xx_rgmu_fw_start(struct adreno_device *adreno_dev,
373: unsigned int boot_state)
374: {
375: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
376: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
377: unsigned int status;
378: int i;
379:
380: switch (boot_state) {
381: case GMU_COLD_BOOT:
382: case GMU_WARM_BOOT:
383: /* Turn on TCM retention */
384: gmu_core_regwrite(device, A6XX_GMU_GENERAL_7, 1);
385:
386: /* Load RGMU FW image via AHB bus */
387: for (i = 0; i < rgmu->fw_size; i++)
388: gmu_core_regwrite(device, A6XX_GMU_CM3_ITCM_START + i,
389: rgmu->fw_hostptr[i]);
390: break;
391: }
392:
393: /* IFPC Feature Enable */
394: if (rgmu->idle_level == GPU_HW_IFPC) {
395: gmu_core_regwrite(device, A6XX_GMU_PWR_COL_INTER_FRAME_HYST,
396: A6X_RGMU_SHORT_IFPC_HYST | adreno_dev->ifpc_hyst);
397: gmu_core_regwrite(device, A6XX_GMU_PWR_COL_INTER_FRAME_CTRL,
398: BIT(0));
399: }
400:
401: /* For RGMU CX interrupt */
402: gmu_core_regwrite(device, A6XX_RGMU_CX_INTR_GEN_EN, RGMU_INTR_EN_MASK);
403:
404: /* Enable GMU AO to host interrupt */
405: gmu_core_regwrite(device, A6XX_GMU_AO_INTERRUPT_EN, RGMU_AO_IRQ_MASK);
406:
407: /* For OOB */
408: gmu_core_regwrite(device, A6XX_GMU_HOST2GMU_INTR_EN_2, 0x00FF0000);
409: gmu_core_regwrite(device, A6XX_GMU_HOST2GMU_INTR_EN_3, 0xFF000000);
410:
411: /* Fence Address range configuration */
412: gmu_core_regwrite(device, A6XX_GMU_AHB_FENCE_RANGE_0,
413: RGMU_FENCE_RANGE_MASK);
414:
415: /* During IFPC RGMU will put fence in drop mode so we would
416: * need to put fence allow mode during slumber out sequence.
417: */
418: gmu_core_regwrite(device, A6XX_GMU_AO_AHB_FENCE_CTRL, 0);
419:
420: /* BCL ON Sequence */
421: a6xx_rgmu_bcl_config(device, true);
422:
423: /* Write 0 first to make sure that rgmu is reset */
424: gmu_core_regwrite(device, A6XX_RGMU_CX_PCC_CTRL, 0);
425:
426: /* Make sure putting in reset doesn't happen after writing 1 */
427: wmb();
428:
429: /* Bring rgmu out of reset */
430: gmu_core_regwrite(device, A6XX_RGMU_CX_PCC_CTRL, 1);
431:
432: if (gmu_core_timed_poll_check(device, A6XX_RGMU_CX_PCC_INIT_RESULT,
433: BIT(0), RGMU_START_TIMEOUT, BIT(0))) {
434: gmu_core_regread(device, A6XX_RGMU_CX_PCC_DEBUG, &status);
435: dev_err(&rgmu->pdev->dev,
436: "rgmu boot Failed. status:%08x\n", status);
437: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
438: return -ETIMEDOUT;
439: }
440:
441: /* Read the RGMU firmware version from registers */
442: gmu_core_regread(device, A6XX_GMU_GENERAL_0, &rgmu->ver);
443:
444: return 0;
445: }
446:
447: static void a6xx_rgmu_notify_slumber(struct adreno_device *adreno_dev)
448: {
449: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
450:
451: /* Disable the power counter so that the RGMU is not busy */
452: gmu_core_regwrite(device, A6XX_GMU_CX_GMU_POWER_COUNTER_ENABLE, 0);
453:
454: /* BCL OFF Sequence */
455: a6xx_rgmu_bcl_config(device, false);
456: }
457:
458: static void a6xx_rgmu_disable_clks(struct adreno_device *adreno_dev)
459: {
460: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
461: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
462:
463: /*
464: * This is based on the assumption that GMU is the only one controlling
465: * the GX HS. This code path is the only client voting for GX from linux
466: * kernel.
467: */
468: if (!a6xx_rgmu_gx_is_on(adreno_dev))
469: goto done;
470:
471: /*
472: * Switch gx gdsc control from GMU to CPU force non-zero reference
473: * count in clk driver so next disable call will turn off the GDSC
474: */
475: kgsl_pwrctrl_enable_gx_gdsc(device);
476: kgsl_pwrctrl_disable_gx_gdsc(device);
477:
478: if (a6xx_rgmu_gx_is_on(adreno_dev))
479: dev_err(&rgmu->pdev->dev, "gx is stuck on\n");
480:
481: done:
482: clk_bulk_disable_unprepare(rgmu->num_clks, rgmu->clks);
483:
484: /* If gpu_clk is NOT in the bulk list, disable it explicitly */
485: if (!kgsl_of_clk_by_name(rgmu->clks, rgmu->num_clks, "core"))
486: clk_disable_unprepare(rgmu->gpu_clk);
487: }
488:
489: void a6xx_rgmu_snapshot(struct adreno_device *adreno_dev,
490: struct kgsl_snapshot *snapshot)
491: {
492: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
493: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
494:
495: adreno_snapshot_registers(device, snapshot, a6xx_rgmu_registers,
496: ARRAY_SIZE(a6xx_rgmu_registers) / 2);
497:
498: a6xx_snapshot(adreno_dev, snapshot);
499:
500: gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_CLR, 0xffffffff);
501: gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_MASK,
502: RGMU_OOB_IRQ_MASK);
503:
504: if (device->gmu_fault)
505: rgmu->fault_count++;
506: }
507:
508: static void a6xx_rgmu_suspend(struct adreno_device *adreno_dev)
509: {
510: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
511:
512: a6xx_rgmu_irq_disable(adreno_dev);
513: a6xx_rgmu_disable_clks(adreno_dev);
514: kgsl_pwrctrl_disable_cx_gdsc(device);
515:
516: kgsl_pwrctrl_set_state(KGSL_DEVICE(adreno_dev), KGSL_STATE_NONE);
517: }
518:
519: static int a6xx_rgmu_enable_clks(struct adreno_device *adreno_dev)
520: {
521: int ret;
522: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
523: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
524: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
525:
526: ret = clk_set_rate(rgmu->rgmu_clk, RGMU_CLK_FREQ);
527: if (ret) {
528: dev_err(&rgmu->pdev->dev, "Couldn't set the RGMU clock\n");
529: return ret;
530: }
531:
532: ret = clk_set_rate(rgmu->gpu_clk,
533: pwr->pwrlevels[pwr->default_pwrlevel].gpu_freq);
534: if (ret) {
535: dev_err(&rgmu->pdev->dev, "Couldn't set the GPU clock\n");
536: return ret;
537: }
538:
539: ret = clk_bulk_prepare_enable(rgmu->num_clks, rgmu->clks);
540: if (ret) {
541: dev_err(&rgmu->pdev->dev, "Failed to enable RGMU clocks\n");
542: return ret;
543: }
544:
545: /* If gpu_clk is NOT in the bulk list, enable it explicitly */
546: if (!kgsl_of_clk_by_name(rgmu->clks, rgmu->num_clks, "core")) {
547: ret = clk_prepare_enable(rgmu->gpu_clk);
MATCH LINES: 564, 567, 570, 571, 578, 594, 598, 607, 612, 613, 614, 624, 630, 640, 641, 642, 645, 650, 658, 661, 663, 665, 670, 671, 687, 706, 722, 726, 734, 737, 748, 758, 768, 770, 772, 790, 795, 798, 803, 814, 820, 825, 840, 845, 852, 880, 898, 900, 909, 913, 930, 933, 949, 953, 977, 980, 985, 990, 994, 998, 1002, 1008, 1012, 1046, 1051, 1066, 1069, 1078, 1080, 1084, 1085, 1099, 1101, 1105, 1107, 1108, 1112, 1133, 1135, 1138, 1143, 1145, 1147, 1150, 1152, 1159, 1162, 1165, 1176, 1187, 1190, 1203, 1217, 1220, 1233, 1234, 1235, 1236, 1237, 1238, 1241, 1243, 1248, 1257, 1266, 1269, 1270, 1271
552: }
553:
554: device->state = KGSL_STATE_AWARE;
555:
556: return 0;
557:
558: err_bulk_disable:
559: clk_bulk_disable_unprepare(rgmu->num_clks, rgmu->clks);
560: return ret;
561: }
562:
563: /*
564: * a6xx_rgmu_load_firmware() - Load the ucode into the RGMU TCM
565: * @adreno_dev: Pointer to adreno device
566: */
567: static int a6xx_rgmu_load_firmware(struct adreno_device *adreno_dev)
568: {
569: const struct firmware *fw = NULL;
570: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
571: const struct adreno_a6xx_core *a6xx_core = to_a6xx_core(adreno_dev);
572: int ret;
573:
574: /* RGMU fw already saved and verified so do nothing new */
575: if (rgmu->fw_hostptr)
576: return 0;
577:
578: ret = adreno_request_firmware(&fw, a6xx_core->gmufw_name,
579: &rgmu->pdev->dev, true);
580: if (ret)
581: return ret;
582:
583: rgmu->fw_hostptr = devm_kmemdup(&rgmu->pdev->dev, fw->data,
584: fw->size, GFP_KERNEL);
585:
586: if (rgmu->fw_hostptr)
587: rgmu->fw_size = (fw->size / sizeof(u32));
588:
589: release_firmware(fw);
590: return rgmu->fw_hostptr ? 0 : -ENOMEM;
591: }
592:
593: /* Halt RGMU execution */
594: static void a6xx_rgmu_halt_execution(struct kgsl_device *device, bool force,
595: enum gmu_fault_panic_policy gf_policy)
596: {
597: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
598: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
599: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
600: u64 ticks = gpudev->read_alwayson(adreno_dev);
601: unsigned int index, status, fence;
602:
603: if (!device->gmu_fault)
604: return;
605:
606: /* Mask so there's no interrupt caused by NMI */
607: gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_MASK, 0xFFFFFFFF);
608:
609: /* Make sure the interrupt is masked */
610: wmb();
611:
612: gmu_core_regread(device, A6XX_RGMU_CX_PCC_DEBUG, &index);
613: gmu_core_regread(device, A6XX_RGMU_CX_PCC_STATUS, &status);
614: gmu_core_regread(device, A6XX_GMU_AO_AHB_FENCE_CTRL, &fence);
615:
616: dev_err(&rgmu->pdev->dev,
617: "RGMU Fault PCC_DEBUG:0x%x PCC_STATUS:0x%x FENCE_CTRL:0x%x\n",
618: index, status, fence);
619:
620: /*
621: * Write 0 to halt RGMU execution. We halt it in GMU/GPU fault and
622: * re start PCC execution in recovery path.
623: */
624: gmu_core_regwrite(device, A6XX_RGMU_CX_PCC_CTRL, 0);
625:
626: /*
627: * Ensure that fence is in allow mode after halting RGMU.
628: * After halting RGMU we dump snapshot.
629: */
630: gmu_core_regwrite(device, A6XX_GMU_AO_AHB_FENCE_CTRL, 0);
631:
632: KGSL_GMU_CORE_FORCE_PANIC(device->gmu_core.gf_panic, rgmu->pdev, ticks, gf_policy);
633: }
634:
635: static void halt_gbif_arb(struct adreno_device *adreno_dev)
636: {
637: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
638:
639: /* Halt all AXI requests */
640: kgsl_regwrite(device, A6XX_GBIF_HALT, A6XX_GBIF_ARB_HALT_MASK);
641: adreno_wait_for_halt_ack(device, A6XX_GBIF_HALT_ACK,
642: A6XX_GBIF_ARB_HALT_MASK);
643:
644: /* De-assert the halts */
645: kgsl_regwrite(device, A6XX_GBIF_HALT, 0x0);
646: }
647:
648:
649: /* Caller shall ensure GPU is ready for SLUMBER */
650: static void a6xx_rgmu_power_off(struct adreno_device *adreno_dev)
651: {
652: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
653: int ret;
654:
655: kgsl_pwrctrl_axi(device, false);
656:
657: if (device->gmu_fault)
658: return a6xx_rgmu_suspend(adreno_dev);
659:
660: /* Wait for the lowest idle level we requested */
661: ret = a6xx_rgmu_wait_for_lowest_idle(adreno_dev);
662: if (ret)
663: return a6xx_rgmu_suspend(adreno_dev);
664:
665: a6xx_rgmu_notify_slumber(adreno_dev);
666:
667: /* Halt CX traffic and de-assert halt */
668: halt_gbif_arb(adreno_dev);
669:
670: a6xx_rgmu_irq_disable(adreno_dev);
671: a6xx_rgmu_disable_clks(adreno_dev);
672: kgsl_pwrctrl_disable_cx_gdsc(device);
673:
674: kgsl_pwrctrl_clear_l3_vote(device);
675:
676: /* Clear the active OPP state for the device */
677: if (device->pwrctrl.pwrlevels[0].opp) {
678: ret = dev_pm_opp_set_opp(&device->pdev->dev, NULL);
679: if (ret)
680: dev_err(&device->pdev->dev,
681: "Failed to clear active OPP state: %d\n", ret);
682: }
683:
684: kgsl_pwrctrl_set_state(device, KGSL_STATE_NONE);
685: }
686:
687: static int a6xx_rgmu_set_opp(struct kgsl_device *device, struct kgsl_pwrlevel *level)
688: {
689: struct device *dev = &device->pdev->dev;
690: int ret;
691:
692: /*
693: * level->opp is initialized with a valid OPP pointer only when the driver
694: * is probed with standard DT bindings. Use this to distinguish standard
695: * vs non‑standard kernels here.
696: *
697: * On non‑standard kernels (level->opp == NULL), vote the core clock using
698: * clk_set_rate API. The downstream clock driver internally handles the
699: * required regulator voting.
700: *
701: * On standard kernels (level->opp != NULL), use dev_pm_opp_set_opp() API
702: * and OPP framework will take care of all required votes.
703: */
704: if (!level->opp) {
705: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
706: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
707:
708: ret = clk_set_rate(rgmu->gpu_clk, level->gpu_freq);
709: if (ret)
710: dev_err(device->dev, "GPU clk freq set failure: %d\n", ret);
711:
712: return ret;
713: }
714:
715: ret = dev_pm_opp_set_opp(dev, level->opp);
716: if (ret)
717: dev_err(device->dev, "GPU OPP configure failure: %d\n", ret);
718:
719: return ret;
720: }
721:
722: static int a6xx_rgmu_clock_set(struct adreno_device *adreno_dev,
723: u32 pwrlevel)
724: {
725: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
726: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
727: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
728: struct kgsl_pwrlevel *level = &pwr->pwrlevels[pwrlevel];
729: int ret;
730:
731: if (pwrlevel == INVALID_DCVS_IDX)
732: return -EINVAL;
733:
734: return a6xx_rgmu_set_opp(device, level);
735: }
736:
737: static int a6xx_gpu_boot(struct adreno_device *adreno_dev)
738: {
739: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
740: int ret;
741:
742: adreno_set_active_ctxs_null(adreno_dev);
743:
744: ret = kgsl_mmu_start(device);
745: if (ret)
746: goto err;
747:
748: ret = a6xx_rgmu_oob_set(device, oob_gpu);
749: if (ret)
750: goto err_oob_clear;
751:
752: /* Clear the busy_data stats - we're starting over from scratch */
753: memset(&adreno_dev->busy_data, 0, sizeof(adreno_dev->busy_data));
754:
755: /* Restore performance counter registers with saved values */
756: adreno_perfcounter_restore(adreno_dev);
757:
758: a6xx_start(adreno_dev);
759:
760: /* Re-initialize the coresight registers if applicable */
761: adreno_coresight_start(adreno_dev);
762:
763: adreno_perfcounter_start(adreno_dev);
764:
765: /* Clear FSR here in case it is set from a previous pagefault */
766: kgsl_mmu_clear_fsr(&device->mmu);
767:
768: a6xx_enable_gpu_irq(adreno_dev);
769:
770: ret = a6xx_rb_start(adreno_dev);
771: if (ret) {
772: a6xx_disable_gpu_irq(adreno_dev);
773: adreno_llcc_slice_deactivate(adreno_dev);
774: goto err_oob_clear;
775: }
776:
777: /*
778: * At this point it is safe to assume that we recovered. Setting
779: * this field allows us to take a new snapshot for the next failure
780: * if we are prioritizing the first unrecoverable snapshot.
781: */
782: if (device->snapshot)
783: device->snapshot->recovered = true;
784:
785: /* Start the dispatcher */
786: adreno_dispatcher_start(device);
787:
788: device->reset_counter++;
789:
790: a6xx_rgmu_oob_clear(device, oob_gpu);
791:
792: return 0;
793:
794: err_oob_clear:
795: a6xx_rgmu_oob_clear(device, oob_gpu);
796:
797: err:
798: a6xx_rgmu_power_off(adreno_dev);
799:
800: return ret;
801: }
802:
803: static int a6xx_rgmu_boot(struct adreno_device *adreno_dev)
804: {
805: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
806: int ret;
807:
808: kgsl_pwrctrl_request_state(device, KGSL_STATE_AWARE);
809:
810: ret = kgsl_pwrctrl_enable_cx_gdsc(device);
811: if (ret)
812: return ret;
813:
814: ret = a6xx_rgmu_enable_clks(adreno_dev);
815: if (ret) {
816: kgsl_pwrctrl_disable_cx_gdsc(device);
817: return ret;
818: }
819:
820: a6xx_rgmu_irq_enable(adreno_dev);
821:
822: /* Clear any GPU faults that might have been left over */
823: adreno_clear_gpu_fault(adreno_dev);
824:
825: ret = a6xx_rgmu_fw_start(adreno_dev, GMU_COLD_BOOT);
826: if (ret)
827: goto err;
828:
829: ret = kgsl_pwrctrl_setup_default_votes(device);
830: if (ret)
831: goto err;
832:
833: device->gmu_fault = false;
834:
835: kgsl_pwrctrl_set_state(device, KGSL_STATE_AWARE);
836:
837: return 0;
838:
839: err:
840: a6xx_rgmu_power_off(adreno_dev);
841:
842: return ret;
843: }
844:
845: static int a6xx_power_off(struct adreno_device *adreno_dev);
846:
847: static void rgmu_idle_check(struct work_struct *work)
848: {
849: struct kgsl_device *device = container_of(work,
850: struct kgsl_device, idle_check_ws);
851: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
852: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
853: int ret;
854:
855: kgsl_mutex_lock(&device->mutex);
856:
857: if (test_bit(GMU_DISABLE_SLUMBER, &device->gmu_core.flags))
858: goto done;
859:
860: if (atomic_read(&device->active_cnt) || time_is_after_jiffies(device->idle_jiffies)) {
861: kgsl_pwrscale_update(device);
862: goto done;
863: }
864:
865: if (!test_bit(RGMU_PRIV_GPU_STARTED, &rgmu->flags))
866: goto done;
867:
868: spin_lock(&device->submit_lock);
869:
870: if (device->submit_now) {
871: spin_unlock(&device->submit_lock);
872: kgsl_pwrscale_update(device);
873: kgsl_start_idle_timer(device);
874: goto done;
875: }
876:
877: device->skip_inline_submit = true;
878: spin_unlock(&device->submit_lock);
879:
880: ret = a6xx_power_off(adreno_dev);
881: if (ret == -EBUSY) {
882: kgsl_pwrscale_update(device);
883: kgsl_start_idle_timer(device);
884: }
885:
886: done:
887: kgsl_mutex_unlock(&device->mutex);
888: }
889:
890: static void rgmu_idle_timer(struct timer_list *t)
891: {
892: struct kgsl_device *device = container_of(t, struct kgsl_device,
893: idle_timer);
894:
895: kgsl_schedule_work(&device->idle_check_ws);
896: }
897:
898: static int a6xx_boot(struct adreno_device *adreno_dev)
899: {
900: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
901: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
902: int ret;
903:
904: if (WARN_ON(test_bit(RGMU_PRIV_GPU_STARTED, &rgmu->flags)))
905: return 0;
906:
907: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE);
908:
909: ret = a6xx_rgmu_boot(adreno_dev);
910: if (ret)
911: return ret;
912:
913: ret = a6xx_gpu_boot(adreno_dev);
914: if (ret)
915: return ret;
916:
917: kgsl_start_idle_timer(device);
918:
919: kgsl_pwrscale_wake(device);
920:
921: set_bit(RGMU_PRIV_GPU_STARTED, &rgmu->flags);
922:
923: device->pwrctrl.last_stat_updated = ktime_get();
924:
925: kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE);
926:
927: return 0;
928: }
929:
930: static void a6xx_rgmu_touch_wakeup(struct adreno_device *adreno_dev)
931: {
932: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
933: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
934: int ret;
935:
936: /*
937: * Do not wake up a suspended device or until the first boot sequence
938: * has been completed.
939: */
940: if (test_bit(RGMU_PRIV_PM_SUSPEND, &rgmu->flags) ||
941: !test_bit(RGMU_PRIV_FIRST_BOOT_DONE, &rgmu->flags))
942: return;
943:
944: if (test_bit(RGMU_PRIV_GPU_STARTED, &rgmu->flags))
945: goto done;
946:
947: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE);
948:
949: ret = a6xx_rgmu_boot(adreno_dev);
950: if (ret)
951: return;
952:
953: ret = a6xx_gpu_boot(adreno_dev);
954: if (ret)
955: return;
956:
957: kgsl_pwrscale_wake(device);
958:
959: set_bit(RGMU_PRIV_GPU_STARTED, &rgmu->flags);
960:
961: device->pwrctrl.last_stat_updated = ktime_get();
962:
963: kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE);
964:
965: done:
966: /*
967: * When waking up from a touch event we want to stay active long enough
968: * for the user to send a draw command. The default idle timer timeout
969: * is shorter than we want so go ahead and push the idle timer out
970: * further for this special case
971: */
972: mod_timer(&device->idle_timer, jiffies +
973: msecs_to_jiffies(adreno_wake_timeout));
974:
975: }
976:
977: static int a6xx_first_boot(struct adreno_device *adreno_dev)
978: {
979: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
980: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
981: int ret;
982:
983: if (test_bit(RGMU_PRIV_FIRST_BOOT_DONE, &rgmu->flags)) {
984: if (!test_bit(RGMU_PRIV_GPU_STARTED, &rgmu->flags))
985: return a6xx_boot(adreno_dev);
986:
987: return 0;
988: }
989:
990: ret = a6xx_ringbuffer_init(adreno_dev);
991: if (ret)
992: return ret;
993:
994: ret = a6xx_microcode_read(adreno_dev);
995: if (ret)
996: return ret;
997:
998: ret = a6xx_init(adreno_dev);
999: if (ret)
1000: return ret;
1001:
1002: ret = a6xx_rgmu_load_firmware(adreno_dev);
1003: if (ret)
1004: return ret;
1005:
1006: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE);
1007:
1008: ret = a6xx_rgmu_boot(adreno_dev);
1009: if (ret)
1010: return ret;
1011:
1012: ret = a6xx_gpu_boot(adreno_dev);
1013: if (ret)
1014: return ret;
1015:
1016: adreno_get_bus_counters(adreno_dev);
1017:
1018: adreno_create_profile_buffer(adreno_dev);
1019:
1020: set_bit(RGMU_PRIV_FIRST_BOOT_DONE, &rgmu->flags);
1021: set_bit(RGMU_PRIV_GPU_STARTED, &rgmu->flags);
1022:
1023: /*
1024: * There is a possible deadlock scenario during kgsl firmware reading
1025: * (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl
1026: * device mutex is held and then firmware_request_nowarn is called for reading
1027: * firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock.
1028: * Whereas in case of devfreq update calls triggered by thermal/bcl or
1029: * devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then
1030: * tries to take kgsl device mutex as part of get_dev_status/target
1031: * calls. This results in deadlock when both thread are unable to acquire
1032: * the mutex held by other thread. Enable devfreq updates now as we are
1033: * done reading all firmware files.
1034: */
1035: device->pwrscale.devfreq_enabled = true;
1036:
1037: device->pwrctrl.last_stat_updated = ktime_get();
1038:
1039: set_bit(ADRENO_DEVICE_FIRST_BOOT_DONE, &adreno_dev->priv);
1040:
1041: kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE);
1042:
1043: return 0;
1044: }
1045:
1046: static int a6xx_rgmu_first_open(struct adreno_device *adreno_dev)
1047: {
1048: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1049: int ret;
1050:
1051: ret = a6xx_first_boot(adreno_dev);
1052: if (ret)
1053: return ret;
1054:
1055: /*
1056: * A client that does a first_open but never closes the device
1057: * may prevent us from going back to SLUMBER. So trigger the idle
1058: * check by incrementing the active count and immediately releasing it.
1059: */
1060: atomic_inc(&device->active_cnt);
1061: adreno_active_count_put(adreno_dev);
1062:
1063: return 0;
1064: }
1065:
1066: static int a6xx_power_off(struct adreno_device *adreno_dev)
1067: {
1068: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1069: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
1070: int ret;
1071:
1072: WARN_ON(!test_bit(RGMU_PRIV_GPU_STARTED, &rgmu->flags));
1073:
1074: adreno_check_idle(device);
1075:
1076: kgsl_pwrctrl_request_state(device, KGSL_STATE_SLUMBER);
1077:
1078: ret = a6xx_rgmu_oob_set(device, oob_gpu);
1079: if (ret) {
1080: a6xx_rgmu_oob_clear(device, oob_gpu);
1081: goto no_gx_power;
1082: }
1083:
1084: if (a6xx_irq_pending(adreno_dev)) {
1085: a6xx_rgmu_oob_clear(device, oob_gpu);
1086: return -EBUSY;
1087: }
1088:
1089: kgsl_pwrscale_update_stats(device);
1090:
1091: /* Save active coresight registers if applicable */
1092: adreno_coresight_stop(adreno_dev);
1093:
1094: /* Save physical performance counter values before GPU power down*/
1095: adreno_perfcounter_save(adreno_dev);
1096:
1097: adreno_irqctrl(adreno_dev, 0);
1098:
1099: a6xx_rgmu_prepare_stop(device);
1100:
1101: a6xx_rgmu_oob_clear(device, oob_gpu);
1102:
1103: no_gx_power:
1104: /* Halt all gx traffic */
1105: kgsl_regwrite(device, A6XX_GBIF_HALT, A6XX_GBIF_CLIENT_HALT_MASK);
1106:
1107: adreno_wait_for_halt_ack(device, A6XX_GBIF_HALT_ACK,
1108: A6XX_GBIF_CLIENT_HALT_MASK);
1109:
1110: kgsl_pwrctrl_irq(device, false);
1111:
1112: a6xx_rgmu_power_off(adreno_dev);
1113:
1114: adreno_set_active_ctxs_null(adreno_dev);
1115:
1116: adreno_dispatcher_stop(adreno_dev);
1117:
1118: adreno_ringbuffer_stop(adreno_dev);
1119:
1120: adreno_llcc_slice_deactivate(adreno_dev);
1121:
1122: clear_bit(RGMU_PRIV_GPU_STARTED, &rgmu->flags);
1123:
1124: kgsl_delete_timer_sync(&device->idle_timer);
1125:
1126: kgsl_pwrscale_sleep(device);
1127:
1128: kgsl_pwrctrl_set_state(device, KGSL_STATE_SLUMBER);
1129:
1130: return ret;
1131: }
1132:
1133: static int a6xx_rgmu_last_close(struct adreno_device *adreno_dev)
1134: {
1135: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
1136:
1137: if (test_bit(RGMU_PRIV_GPU_STARTED, &rgmu->flags))
1138: return a6xx_power_off(adreno_dev);
1139:
1140: return 0;
1141: }
1142:
1143: int a6xx_rgmu_reset(struct adreno_device *adreno_dev)
1144: {
1145: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
1146:
1147: a6xx_disable_gpu_irq(adreno_dev);
1148:
1149: /* Hard reset the rgmu and gpu */
1150: a6xx_rgmu_suspend(adreno_dev);
1151:
1152: a6xx_reset_preempt_records(adreno_dev);
1153:
1154: adreno_llcc_slice_deactivate(adreno_dev);
1155:
1156: clear_bit(RGMU_PRIV_GPU_STARTED, &rgmu->flags);
1157:
1158: /* Attempt rebooting the rgmu and gpu */
1159: return a6xx_boot(adreno_dev);
1160: }
1161:
1162: static int a6xx_rgmu_active_count_get(struct adreno_device *adreno_dev)
1163: {
1164: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1165: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
1166: int ret = 0;
1167:
1168: if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex)))
1169: return -EINVAL;
1170:
1171: if (test_bit(RGMU_PRIV_PM_SUSPEND, &rgmu->flags))
1172: return -EINVAL;
1173:
1174: if ((atomic_read(&device->active_cnt) == 0) &&
1175: !test_bit(RGMU_PRIV_GPU_STARTED, &rgmu->flags))
1176: ret = a6xx_boot(adreno_dev);
1177:
1178: if (ret == 0) {
1179: atomic_inc(&device->active_cnt);
1180: trace_kgsl_active_count(device,
1181: (unsigned long) __builtin_return_address(0));
1182: }
1183:
1184: return ret;
1185: }
1186:
1187: static int a6xx_rgmu_pm_suspend(struct adreno_device *adreno_dev)
1188: {
1189: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1190: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
1191: int ret;
1192:
1193: if (test_bit(RGMU_PRIV_PM_SUSPEND, &rgmu->flags))
1194: return 0;
1195:
1196: kgsl_pwrctrl_request_state(device, KGSL_STATE_SUSPEND);
1197:
1198: ret = adreno_drain_and_idle(device);
1199: if (ret)
1200: goto err;
1201:
1202: if (test_bit(RGMU_PRIV_GPU_STARTED, &rgmu->flags))
1203: a6xx_power_off(adreno_dev);
1204:
1205: set_bit(RGMU_PRIV_PM_SUSPEND, &rgmu->flags);
1206:
1207: adreno_get_gpu_halt(adreno_dev);
1208:
1209: kgsl_pwrctrl_set_state(device, KGSL_STATE_SUSPEND);
1210:
1211: return 0;
1212: err:
1213: adreno_dispatcher_start(device);
1214: return ret;
1215: }
1216:
1217: static void a6xx_rgmu_pm_resume(struct adreno_device *adreno_dev)
1218: {
1219: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1220: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
1221:
1222: if (WARN(!test_bit(RGMU_PRIV_PM_SUSPEND, &rgmu->flags),
1223: "resume invoked without a suspend\n"))
1224: return;
1225:
1226: adreno_put_gpu_halt(adreno_dev);
1227:
1228: clear_bit(RGMU_PRIV_PM_SUSPEND, &rgmu->flags);
1229:
1230: adreno_dispatcher_start(device);
1231: }
1232:
1233: static const struct gmu_dev_ops a6xx_rgmudev = {
1234: .oob_set = a6xx_rgmu_oob_set,
1235: .oob_clear = a6xx_rgmu_oob_clear,
1236: .ifpc_store = a6xx_rgmu_ifpc_store,
1237: .ifpc_isenabled = a6xx_rgmu_ifpc_isenabled,
1238: .send_nmi = a6xx_rgmu_halt_execution,
1239: };
1240:
1241: static int a6xx_rgmu_irq_probe(struct kgsl_device *device)
1242: {
1243: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(ADRENO_DEVICE(device));
1244: int ret;
1245:
1246: /* Try with "oob" irq first. Use Fallback legacy name "kgsl_oob" if not found. */
1247: ret = kgsl_request_irq(rgmu->pdev, "oob", "kgsl_oob", -EINVAL,
1248: a6xx_oob_irq_handler, device);
1249:
1250: if (ret < 0)
1251: return ret;
1252:
1253: rgmu->oob_interrupt_num = ret;
1254:
1255: /* Try with "gmu" irq first. Use Fallback legacy name "kgsl_rgmu" if not found. */
1256: ret = kgsl_request_irq(rgmu->pdev, "gmu", "kgsl_rgmu", -EINVAL,
1257: a6xx_rgmu_irq_handler, device);
1258:
1259: if (ret < 0)
1260: return ret;
1261:
1262: rgmu->rgmu_interrupt_num = ret;
1263: return 0;
1264: }
1265:
1266: static int a6xx_rgmu_clocks_probe(struct a6xx_rgmu_device *rgmu,
1267: struct device_node *node)
1268: {
1269: struct a6xx_device *a6xx_dev = container_of(rgmu,
1270: struct a6xx_device, rgmu);
1271: struct kgsl_device *device = KGSL_DEVICE(&a6xx_dev->adreno_dev);
1272: int ret, i;
1273:
1274: ret = devm_clk_bulk_get_all(&rgmu->pdev->dev, &rgmu->clks);
1275: if (ret < 0)
1276: return ret;
1277: /*
1278: * Voting for apb_pclk will enable power and clocks required for
1279: * QDSS path to function. However, if QCOM_KGSL_QDSS_STM is not enabled,
1280: * QDSS is essentially unusable. Hence, if QDSS cannot be used,
1281: * don't vote for this clock.
1282: */
1283: if (!IS_ENABLED(CONFIG_QCOM_KGSL_QDSS_STM)) {
1284: for (i = 0; i < ret; i++) {
1285: if (!strcmp(rgmu->clks[i].id, "apb_pclk")) {
1286: rgmu->clks[i].clk = NULL;
1287: break;
1288: }
1289: }
1290: }
1291: rgmu->num_clks = ret;
1292:
1293: /* Get the "core" gfx3d clock from gpu pdev, fallback to rgmu pdev if unavailable */
1294: rgmu->gpu_clk = devm_clk_get(&device->pdev->dev, "core");
1295: if (!rgmu->gpu_clk)
MATCH LINES: 1312, 1313, 1314, 1315, 1316, 1317, 1318, 1319, 1322, 1327, 1330, 1332, 1335, 1337, 1339, 1356, 1358, 1359, 1361, 1362, 1366, 1370, 1381, 1395, 1409, 1415, 1421, 1425, 1428, 1433, 1436, 1437, 1438, 1441, 1453, 1457, 1459, 1462, 1464, 1469, 1475, 1476, 1477, 1480
1300: return -ENODEV;
1301: }
1302:
1303: rgmu->rgmu_clk = kgsl_of_clk_by_name(rgmu->clks, ret, "gmu");
1304: if (!rgmu->rgmu_clk) {
1305: dev_err(&rgmu->pdev->dev, "The RGMU clock isn't defined\n");
1306: return -ENODEV;
1307: }
1308:
1309: return 0;
1310: }
1311:
1312: const struct adreno_power_ops a6xx_rgmu_power_ops = {
1313: .first_open = a6xx_rgmu_first_open,
1314: .last_close = a6xx_rgmu_last_close,
1315: .active_count_get = a6xx_rgmu_active_count_get,
1316: .pm_suspend = a6xx_rgmu_pm_suspend,
1317: .pm_resume = a6xx_rgmu_pm_resume,
1318: .touch_wakeup = a6xx_rgmu_touch_wakeup,
1319: .gpu_clock_set = a6xx_rgmu_clock_set,
1320: };
1321:
1322: int a6xx_rgmu_device_probe(struct platform_device *pdev,
1323: u32 chipid, const struct adreno_gpu_core *gpucore)
1324: {
1325: struct adreno_device *adreno_dev;
1326: struct kgsl_device *device;
1327: struct a6xx_device *a6xx_dev;
1328: int ret;
1329:
1330: a6xx_dev = devm_kzalloc(&pdev->dev, sizeof(*a6xx_dev),
1331: GFP_KERNEL);
1332: if (!a6xx_dev)
1333: return -ENOMEM;
1334:
1335: adreno_dev = &a6xx_dev->adreno_dev;
1336:
1337: adreno_dev->irq_mask = A6XX_INT_MASK;
1338:
1339: ret = a6xx_probe_common(pdev, adreno_dev, chipid, gpucore);
1340: if (ret)
1341: return ret;
1342:
1343: ret = adreno_dispatcher_init(adreno_dev);
1344: if (ret)
1345: return ret;
1346:
1347: device = KGSL_DEVICE(adreno_dev);
1348:
1349: INIT_WORK(&device->idle_check_ws, rgmu_idle_check);
1350:
1351: timer_setup(&device->idle_timer, rgmu_idle_timer, 0);
1352:
1353: return 0;
1354: }
1355:
1356: int a6xx_rgmu_add_to_minidump(struct adreno_device *adreno_dev)
1357: {
1358: struct a6xx_device *a6xx_dev = container_of(adreno_dev,
1359: struct a6xx_device, adreno_dev);
1360:
1361: return kgsl_add_va_to_minidump(adreno_dev->dev.dev, KGSL_A6XX_DEVICE,
1362: (void *)(a6xx_dev), sizeof(struct a6xx_device));
1363: }
1364:
1365: /* Do not access any RGMU registers in RGMU probe function */
1366: static int a6xx_rgmu_probe(struct kgsl_device *device,
1367: struct platform_device *pdev)
1368: {
1369: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
1370: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
1371: int ret;
1372:
1373: rgmu->pdev = pdev;
1374:
1375: /* Set up RGMU gdscs */
1376: ret = kgsl_pwrctrl_probe_gdscs(device, pdev);
1377: if (ret)
1378: return ret;
1379:
1380: /* Set up RGMU clocks */
1381: ret = a6xx_rgmu_clocks_probe(rgmu, pdev->dev.of_node);
1382: if (ret)
1383: return ret;
1384:
1385: /* Try to get the resource by index (i.e. 0), fallback to legacy "kgsl_rgmu" if not found */
1386: ret = kgsl_regmap_add_region(&device->regmap, pdev,
1387: "kgsl_rgmu", 0, NULL, NULL);
1388:
1389: if (ret) {
1390: dev_err(&pdev->dev, "Unable to map the RGMU registers\n");
1391: return ret;
1392: }
1393:
1394: /* Initialize OOB and RGMU interrupts */
1395: ret = a6xx_rgmu_irq_probe(device);
1396: if (ret)
1397: return ret;
1398:
1399: /* Set up RGMU idle states */
1400: if (ADRENO_FEATURE(ADRENO_DEVICE(device), ADRENO_IFPC)) {
1401: rgmu->idle_level = GPU_HW_IFPC;
1402: adreno_dev->ifpc_hyst = A6X_RGMU_LONG_IFPC_HYST;
1403: adreno_dev->ifpc_hyst_floor = A6X_RGMU_LONG_IFPC_HYST_FLOOR;
1404: } else {
1405: rgmu->idle_level = GPU_HW_ACTIVE;
1406: }
1407:
1408: set_bit(GMU_ENABLED, &device->gmu_core.flags);
1409: device->gmu_core.dev_ops = &a6xx_rgmudev;
1410: device->gmu_core.pdev = rgmu->pdev;
1411:
1412: return 0;
1413: }
1414:
1415: static void a6xx_rgmu_remove(struct kgsl_device *device)
1416: {
1417:
1418: memset(&device->gmu_core, 0, sizeof(device->gmu_core));
1419: }
1420:
1421: static int a6xx_rgmu_bind(struct device *dev, struct device *master, void *data)
1422: {
1423: struct kgsl_device *device = dev_get_drvdata(master);
1424:
1425: return a6xx_rgmu_probe(device, to_platform_device(dev));
1426: }
1427:
1428: static void a6xx_rgmu_unbind(struct device *dev, struct device *master,
1429: void *data)
1430: {
1431: struct kgsl_device *device = dev_get_drvdata(master);
1432:
1433: a6xx_rgmu_remove(device);
1434: }
1435:
1436: static const struct component_ops a6xx_rgmu_component_ops = {
1437: .bind = a6xx_rgmu_bind,
1438: .unbind = a6xx_rgmu_unbind,
1439: };
1440:
1441: static int a6xx_rgmu_probe_dev(struct platform_device *pdev)
1442: {
1443: /*
1444: * Let us say there are two devices. One with "qcom,adreno-rgmu" compatible
1445: * and one with "qcom,gpu-rgmu" compatible. In this case probe only the
1446: * device with legacy compatible string and return error for the device
1447: * with "qcom,adreno-rgmu".
1448: */
1449: if (of_device_is_compatible(pdev->dev.of_node, "qcom,adreno-rgmu") &&
1450: kgsl_is_compatible_node_available("qcom,gpu-rgmu"))
1451: return -ENODEV;
1452:
1453: return component_add(&pdev->dev, &a6xx_rgmu_component_ops);
1454: }
1455:
1456: #if (KERNEL_VERSION(6, 10, 0) <= LINUX_VERSION_CODE)
1457: static void a6xx_rgmu_remove_dev(struct platform_device *pdev)
1458: {
1459: component_del(&pdev->dev, &a6xx_rgmu_component_ops);
1460: }
1461: #else
1462: static int a6xx_rgmu_remove_dev(struct platform_device *pdev)
1463: {
1464: component_del(&pdev->dev, &a6xx_rgmu_component_ops);
1465: return 0;
1466: }
1467: #endif
1468:
1469: static const struct of_device_id a6xx_rgmu_match_table[] = {
1470: { .compatible = "qcom,gpu-rgmu" },
1471: { .compatible = "qcom,adreno-rgmu" },
1472: { },
1473: };
1474:
1475: struct platform_driver a6xx_rgmu_driver = {
1476: .probe = a6xx_rgmu_probe_dev,
1477: .remove = a6xx_rgmu_remove_dev,
1478: .driver = {
1479: .name = "kgsl-rgmu",
1480: .of_match_table = a6xx_rgmu_match_table,
1481: },
1482: };
--- FILE: \adreno_a6xx_rgmu.h | HITS: 14 ---
MATCH LINES: 6, 7, 29, 42, 63, 70, 74, 79, 82, 89, 93, 96, 99, 105
1: /* SPDX-License-Identifier: GPL-2.0-only */
2: /*
3: * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
4: * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
5: */
6: #ifndef __ADRENO_A6XX_RGMU_H
7: #define __ADRENO_A6XX_RGMU_H
8:
9: #define RGMU_AO_IRQ_FENCE_ERR BIT(3)
10: #define RGMU_AO_IRQ_MASK RGMU_AO_IRQ_FENCE_ERR
11:
12: #define RGMU_OOB_IRQ_ERR_MSG BIT(24)
13: #define RGMU_OOB_IRQ_ACK_MASK GENMASK(23, 16)
14: #define RGMU_OOB_IRQ_ERR_MSG_MASK GENMASK(31, 24)
15: #define RGMU_OOB_IRQ_MASK RGMU_OOB_IRQ_ERR_MSG_MASK
16:
17: #define MAX_RGMU_CLKS 8
18:
19: enum {
20: /* @RGMU_PRIV_FIRST_BOOT_DONE: The very first ggpu boot is done */
21: RGMU_PRIV_FIRST_BOOT_DONE,
22: /* @RGMU_PRIV_GPU_STARTED: GPU has been started */
23: RGMU_PRIV_GPU_STARTED,
24: /* @RGMU_PRIV_PM_SUSPEND: The rgmu driver is suspended */
25: RGMU_PRIV_PM_SUSPEND,
26: };
27:
28: /**
29: * struct a6xx_rgmu_device - rGMU device structure
30: * @ver: RGMU firmware version
31: * @rgmu_interrupt_num: RGMU interrupt number
32: * @oob_interrupt_num: number of RGMU asserted OOB interrupt
33: * @fw_hostptr: Buffer which holds the RGMU firmware
34: * @fw_size: Size of RGMU firmware buffer
35: * @clks: RGMU clocks including the GPU
36: * @gpu_clk: Pointer to GPU core clock
37: * @rgmu_clk: Pointer to rgmu clock
38: * @flags: RGMU flags
39: * @idle_level: Minimal GPU idle power level
40: * @fault_count: RGMU fault count
41: */
42: struct a6xx_rgmu_device {
43: u32 ver;
44: struct platform_device *pdev;
45: unsigned int rgmu_interrupt_num;
46: unsigned int oob_interrupt_num;
47: unsigned int *fw_hostptr;
48: uint32_t fw_size;
49: struct clk_bulk_data *clks;
50: /** @num_clks: Number of clocks in @clks */
51: int num_clks;
52: struct clk *gpu_clk;
53: struct clk *rgmu_clk;
54: unsigned int idle_level;
55: unsigned int fault_count;
56: /** @flags: rgmu internal flags */
57: unsigned long flags;
58: /** @num_oob_perfcntr: Number of active oob_perfcntr requests */
59: u32 num_oob_perfcntr;
60: };
61:
62: /**
63: * a6xx_rgmu_device_probe - Probe a6xx rgmu resources
64: * @pdev: Pointer to the platform device
65: * @chipid: Chipid of the target
66: * @gpucore: Pointer to the gpucore
67: *
68: * The target specific probe function for rgmu based a6xx targets.
69: */
70: int a6xx_rgmu_device_probe(struct platform_device *pdev,
71: u32 chipid, const struct adreno_gpu_core *gpucore);
72:
73: /**
74: * a6xx_rgmu_reset - Reset and restart the rgmu
75: * @adreno_dev: Pointer to the adreno device
76: *
77: * Return: 0 on success or negative error on failure
78: */
79: int a6xx_rgmu_reset(struct adreno_device *adreno_dev);
80:
81: /**
82: * a6xx_rgmu_snapshot - Take snapshot for rgmu based targets
83: * @adreno_dev: Pointer to the adreno device
84: * @snapshot: Pointer to the snapshot
85: *
86: * This function halts rgmu execution if we hit a rgmu
87: * fault. And then, it takes rgmu and gpu snapshot.
88: */
89: void a6xx_rgmu_snapshot(struct adreno_device *adreno_dev,
90: struct kgsl_snapshot *snapshot);
91:
92: /**
93: * a6xx_rgmu_add_to_minidump - Register a6xx_device with va minidump
94: * @adreno_dev: Pointer to the adreno device
95: */
96: int a6xx_rgmu_add_to_minidump(struct adreno_device *adreno_dev);
97:
98: /**
99: * a6xx_rgmu_gx_is_on() - Check if GX is on using pwr status register
100: * @adreno_dev: Pointer to the adreno device
101: *
102: * This check should only be performed if the keepalive bit is set or it
103: * can be guaranteed that the power state of the GPU will remain unchanged
104: */
105: bool a6xx_rgmu_gx_is_on(struct adreno_device *adreno_dev);
106: #endif
--- FILE: \adreno_a6xx_ringbuffer.c | HITS: 83 ---
MATCH LINES: 14, 26, 32, 33, 34, 38, 48, 49, 50, 57, 71, 75, 80, 82, 90, 93, 100, 107, 110, 124, 141, 151, 152, 177, 208, 212, 214, 220, 248, 252, 255, 262, 269, 277, 283, 288, 296, 304, 311, 318, 324, 332, 339, 343, 346, 351, 356, 360, 362, 363, 370, 372, 373, 383, 395, 398, 408, 424, 440, 441, 445, 446, 451, 452, 457, 459, 478, 484, 489, 491, 497, 503, 510, 513, 521, 526, 529, 534, 536, 542, 545, 548, 568
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_a6xx.h"
9: #include "adreno_pm4types.h"
10: #include "adreno_ringbuffer.h"
11: #include "adreno_trace.h"
12: #include "kgsl_trace.h"
13:
14: static int a6xx_rb_pagetable_switch(struct adreno_device *adreno_dev,
15: struct adreno_ringbuffer *rb, struct adreno_context *drawctxt,
16: struct kgsl_pagetable *pagetable, u32 *cmds)
17: {
18: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
19: u64 ttbr0 = kgsl_mmu_pagetable_get_ttbr0(pagetable);
20: int count = 0;
21: u32 id = drawctxt ? drawctxt->base.id : 0;
22:
23: if (pagetable == device->mmu.defaultpagetable)
24: return 0;
25:
26: cmds[count++] = cp_type7_packet(CP_SMMU_TABLE_UPDATE, 3);
27: cmds[count++] = lower_32_bits(ttbr0);
28: cmds[count++] = upper_32_bits(ttbr0);
29: cmds[count++] = id;
30:
31: if (!ADRENO_FEATURE(adreno_dev, ADRENO_APRIV)) {
32: cmds[count++] = cp_type7_packet(CP_WAIT_FOR_IDLE, 0);
33: cmds[count++] = cp_type7_packet(CP_WAIT_FOR_ME, 0);
34: cmds[count++] = cp_type4_packet(A6XX_CP_MISC_CNTL, 1);
35: cmds[count++] = 1;
36: }
37:
38: cmds[count++] = cp_type7_packet(CP_MEM_WRITE, 5);
39: cmds[count++] = lower_32_bits(SCRATCH_RB_GPU_ADDR(device,
40: rb->id, ttbr0));
41: cmds[count++] = upper_32_bits(SCRATCH_RB_GPU_ADDR(device,
42: rb->id, ttbr0));
43: cmds[count++] = lower_32_bits(ttbr0);
44: cmds[count++] = upper_32_bits(ttbr0);
45: cmds[count++] = id;
46:
47: if (!ADRENO_FEATURE(adreno_dev, ADRENO_APRIV)) {
48: cmds[count++] = cp_type7_packet(CP_WAIT_FOR_IDLE, 0);
49: cmds[count++] = cp_type7_packet(CP_WAIT_FOR_ME, 0);
50: cmds[count++] = cp_type4_packet(A6XX_CP_MISC_CNTL, 1);
51: cmds[count++] = 0;
52: }
53:
54: return count;
55: }
56:
57: static int a6xx_rb_context_switch(struct adreno_device *adreno_dev,
58: struct adreno_ringbuffer *rb,
59: struct adreno_context *drawctxt)
60: {
61: struct kgsl_pagetable *pagetable =
62: adreno_drawctxt_get_pagetable(drawctxt);
63: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
64: int count = 0;
65: u32 cmds[41];
66:
67: if (adreno_drawctxt_get_pagetable(rb->drawctxt_active) != pagetable) {
68:
69: /* Clear performance counters during context switches */
70: if (!adreno_dev->perfcounter) {
71: cmds[count++] = cp_type4_packet(A6XX_RBBM_PERFCTR_SRAM_INIT_CMD, 1);
72: cmds[count++] = 0x1;
73: }
74:
75: count += a6xx_rb_pagetable_switch(adreno_dev, rb, drawctxt,
76: pagetable, &cmds[count]);
77:
78: /* Wait for performance counter clear to finish */
79: if (!adreno_dev->perfcounter) {
80: cmds[count++] = cp_type7_packet(CP_WAIT_REG_MEM, 6);
81: cmds[count++] = 0x3;
82: cmds[count++] = A6XX_RBBM_PERFCTR_SRAM_INIT_STATUS;
83: cmds[count++] = 0x0;
84: cmds[count++] = 0x1;
85: cmds[count++] = 0x1;
86: cmds[count++] = 0x0;
87: }
88: }
89:
90: cmds[count++] = cp_type7_packet(CP_NOP, 1);
91: cmds[count++] = CONTEXT_TO_MEM_IDENTIFIER;
92:
93: cmds[count++] = cp_type7_packet(CP_MEM_WRITE, 3);
94: cmds[count++] = lower_32_bits(MEMSTORE_RB_GPU_ADDR(device, rb,
95: current_context));
96: cmds[count++] = upper_32_bits(MEMSTORE_RB_GPU_ADDR(device, rb,
97: current_context));
98: cmds[count++] = drawctxt->base.id;
99:
100: cmds[count++] = cp_type7_packet(CP_MEM_WRITE, 3);
101: cmds[count++] = lower_32_bits(MEMSTORE_ID_GPU_ADDR(device,
102: KGSL_MEMSTORE_GLOBAL, current_context));
103: cmds[count++] = upper_32_bits(MEMSTORE_ID_GPU_ADDR(device,
104: KGSL_MEMSTORE_GLOBAL, current_context));
105: cmds[count++] = drawctxt->base.id;
106:
107: cmds[count++] = cp_type7_packet(CP_EVENT_WRITE, 1);
108: cmds[count++] = 0x31;
109:
110: return a6xx_ringbuffer_addcmds(adreno_dev, rb, NULL, F_NOTPROTECTED,
111: cmds, count, 0, NULL);
112: }
113:
114: #define RB_SOPTIMESTAMP(device, rb) \
115: MEMSTORE_RB_GPU_ADDR(device, rb, soptimestamp)
116: #define CTXT_SOPTIMESTAMP(device, drawctxt) \
117: MEMSTORE_ID_GPU_ADDR(device, (drawctxt)->base.id, soptimestamp)
118:
119: #define RB_EOPTIMESTAMP(device, rb) \
120: MEMSTORE_RB_GPU_ADDR(device, rb, eoptimestamp)
121: #define CTXT_EOPTIMESTAMP(device, drawctxt) \
122: MEMSTORE_ID_GPU_ADDR(device, (drawctxt)->base.id, eoptimestamp)
123:
124: int a6xx_ringbuffer_submit(struct adreno_ringbuffer *rb,
125: struct adreno_submit_time *time, bool sync)
126: {
127: struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
128: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
129: int ret = 0;
130: unsigned long flags;
131:
132: adreno_get_submit_time(adreno_dev, rb, time);
133: adreno_profile_submit_time(time);
134:
135: if (sync && !ADRENO_FEATURE(adreno_dev, ADRENO_APRIV)) {
136: u32 *cmds = adreno_ringbuffer_allocspace(rb, 3);
137:
138: if (IS_ERR(cmds))
139: return PTR_ERR(cmds);
140:
141: cmds[0] = cp_type7_packet(CP_WHERE_AM_I, 2);
142: cmds[1] = lower_32_bits(SCRATCH_RB_GPU_ADDR(device, rb->id,
143: rptr));
144: cmds[2] = upper_32_bits(SCRATCH_RB_GPU_ADDR(device, rb->id,
145: rptr));
146: }
147:
148: spin_lock_irqsave(&rb->preempt_lock, flags);
149: if (adreno_in_preempt_state(adreno_dev, ADRENO_PREEMPT_NONE)) {
150: if (adreno_dev->cur_rb == rb) {
151: ret = a6xx_fenced_write(adreno_dev,
152: A6XX_CP_RB_WPTR, rb->_wptr,
153: FENCE_STATUS_WRITEDROPPED0_MASK);
154: rb->skip_inline_wptr = false;
155: }
156: } else {
157: if (adreno_dev->cur_rb == rb)
158: rb->skip_inline_wptr = true;
159: }
160:
161: rb->wptr = rb->_wptr;
162: spin_unlock_irqrestore(&rb->preempt_lock, flags);
163:
164: if (ret) {
165: /*
166: * If WPTR update fails, take inline snapshot and trigger
167: * recovery.
168: */
169: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
170: adreno_scheduler_fault(adreno_dev,
171: ADRENO_GMU_FAULT_SKIP_SNAPSHOT);
172: }
173:
174: return ret;
175: }
176:
177: int a6xx_ringbuffer_init(struct adreno_device *adreno_dev)
178: {
179: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
180: int i, ret;
181:
182: ret = adreno_allocate_global(device, &device->scratch, PAGE_SIZE,
183: 0, 0, KGSL_MEMDESC_RANDOM | KGSL_MEMDESC_PRIVILEGED,
184: "scratch");
185: if (ret)
186: return ret;
187:
188: adreno_dev->cur_rb = &(adreno_dev->ringbuffers[0]);
189:
190: if (!adreno_preemption_feature_set(adreno_dev)) {
191: adreno_dev->num_ringbuffers = 1;
192: return adreno_ringbuffer_setup(adreno_dev,
193: &adreno_dev->ringbuffers[0], 0);
194: }
195:
196: adreno_dev->num_ringbuffers = ARRAY_SIZE(adreno_dev->ringbuffers);
197:
198: for (i = 0; i < adreno_dev->num_ringbuffers; i++) {
199: int ret;
200:
201: ret = adreno_ringbuffer_setup(adreno_dev,
202: &adreno_dev->ringbuffers[i], i);
203: if (ret)
204: return ret;
205: }
206:
207: timer_setup(&adreno_dev->preempt.timer, adreno_preemption_timer, 0);
208: a6xx_preemption_init(adreno_dev);
209: return 0;
210: }
211:
212: #define A6XX_SUBMIT_MAX 79
213:
214: int a6xx_ringbuffer_addcmds(struct adreno_device *adreno_dev,
215: struct adreno_ringbuffer *rb, struct adreno_context *drawctxt,
216: u32 flags, u32 *in, u32 dwords, u32 timestamp,
217: struct adreno_submit_time *time)
218: {
219: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
220: u32 size = A6XX_SUBMIT_MAX + dwords;
221: u32 *cmds, index = 0;
222: u64 profile_gpuaddr;
223: u32 profile_dwords;
224:
225: if (adreno_drawctxt_detached(drawctxt))
226: return -ENOENT;
227:
228: if (adreno_gpu_fault(adreno_dev) != 0)
229: return -EPROTO;
230:
231: rb->timestamp++;
232:
233: if (drawctxt)
234: drawctxt->internal_timestamp = rb->timestamp;
235:
236: /*
237: * if APRIV is enabled we assume all submissions are run with protected
238: * mode off
239: */
240: if (ADRENO_FEATURE(adreno_dev, ADRENO_APRIV))
241: flags &= ~F_NOTPROTECTED;
242:
243: cmds = adreno_ringbuffer_allocspace(rb, size);
244: if (IS_ERR(cmds))
245: return PTR_ERR(cmds);
246:
247: /* Identify the start of a command */
248: cmds[index++] = cp_type7_packet(CP_NOP, 1);
249: cmds[index++] = drawctxt ? CMD_IDENTIFIER : CMD_INTERNAL_IDENTIFIER;
250:
251: /* This is 25 dwords when drawctxt is not NULL and perfcounter needs to be zapped */
252: index += a6xx_preemption_pre_ibsubmit(adreno_dev, rb, drawctxt,
253: &cmds[index]);
254:
255: cmds[index++] = cp_type7_packet(CP_SET_MARKER, 1);
256: cmds[index++] = 0x101; /* IFPC disable */
257:
258: profile_gpuaddr = adreno_profile_preib_processing(adreno_dev,
259: drawctxt, &profile_dwords);
260:
261: if (profile_gpuaddr) {
262: cmds[index++] = cp_type7_packet(CP_INDIRECT_BUFFER_PFE, 3);
263: cmds[index++] = lower_32_bits(profile_gpuaddr);
264: cmds[index++] = upper_32_bits(profile_gpuaddr);
265: cmds[index++] = profile_dwords;
266: }
267:
268: if (drawctxt) {
269: cmds[index++] = cp_type7_packet(CP_MEM_WRITE, 3);
270: cmds[index++] = lower_32_bits(CTXT_SOPTIMESTAMP(device,
271: drawctxt));
272: cmds[index++] = upper_32_bits(CTXT_SOPTIMESTAMP(device,
273: drawctxt));
274: cmds[index++] = timestamp;
275: }
276:
277: cmds[index++] = cp_type7_packet(CP_MEM_WRITE, 3);
278: cmds[index++] = lower_32_bits(RB_SOPTIMESTAMP(device, rb));
279: cmds[index++] = upper_32_bits(RB_SOPTIMESTAMP(device, rb));
280: cmds[index++] = rb->timestamp;
281:
282: if (IS_SECURE(flags)) {
283: cmds[index++] = cp_type7_packet(CP_SET_SECURE_MODE, 1);
284: cmds[index++] = 1;
285: }
286:
287: if (IS_NOTPROTECTED(flags)) {
288: cmds[index++] = cp_type7_packet(CP_SET_PROTECTED_MODE, 1);
289: cmds[index++] = 0;
290: }
291:
292: memcpy(&cmds[index], in, dwords << 2);
293: index += dwords;
294:
295: if (IS_NOTPROTECTED(flags)) {
296: cmds[index++] = cp_type7_packet(CP_SET_PROTECTED_MODE, 1);
297: cmds[index++] = 1;
298: }
299:
300: profile_gpuaddr = adreno_profile_postib_processing(adreno_dev,
301: drawctxt, &dwords);
302:
303: if (profile_gpuaddr) {
304: cmds[index++] = cp_type7_packet(CP_INDIRECT_BUFFER_PFE, 3);
305: cmds[index++] = lower_32_bits(profile_gpuaddr);
306: cmds[index++] = upper_32_bits(profile_gpuaddr);
307: cmds[index++] = profile_dwords;
308: }
309:
310: if (test_bit(KGSL_FT_PAGEFAULT_GPUHALT_ENABLE, &device->mmu.pfpolicy))
311: cmds[index++] = cp_type7_packet(CP_WAIT_MEM_WRITES, 0);
312:
313: /*
314: * If this is an internal command, just write the ringbuffer timestamp,
315: * otherwise, write both
316: */
317: if (!drawctxt) {
318: cmds[index++] = cp_type7_packet(CP_EVENT_WRITE, 4);
319: cmds[index++] = CACHE_FLUSH_TS | (1 << 31);
320: cmds[index++] = lower_32_bits(RB_EOPTIMESTAMP(device, rb));
321: cmds[index++] = upper_32_bits(RB_EOPTIMESTAMP(device, rb));
322: cmds[index++] = rb->timestamp;
323: } else {
324: cmds[index++] = cp_type7_packet(CP_EVENT_WRITE, 4);
325: cmds[index++] = CACHE_FLUSH_TS | (1 << 31);
326: cmds[index++] = lower_32_bits(CTXT_EOPTIMESTAMP(device,
327: drawctxt));
328: cmds[index++] = upper_32_bits(CTXT_EOPTIMESTAMP(device,
329: drawctxt));
330: cmds[index++] = timestamp;
331:
332: cmds[index++] = cp_type7_packet(CP_EVENT_WRITE, 4);
333: cmds[index++] = CACHE_FLUSH_TS;
334: cmds[index++] = lower_32_bits(RB_EOPTIMESTAMP(device, rb));
335: cmds[index++] = upper_32_bits(RB_EOPTIMESTAMP(device, rb));
336: cmds[index++] = rb->timestamp;
337: }
338:
339: cmds[index++] = cp_type7_packet(CP_SET_MARKER, 1);
340: cmds[index++] = 0x100; /* IFPC enable */
341:
342: if (IS_WFI(flags))
343: cmds[index++] = cp_type7_packet(CP_WAIT_FOR_IDLE, 0);
344:
345: if (IS_SECURE(flags)) {
346: cmds[index++] = cp_type7_packet(CP_SET_SECURE_MODE, 1);
347: cmds[index++] = 0;
348: }
349:
350: /* 10 dwords */
351: index += a6xx_preemption_post_ibsubmit(adreno_dev, &cmds[index]);
352:
353: /* Adjust the thing for the number of dwords we actually wrote */
354: rb->_wptr -= (size - index);
355:
356: return a6xx_ringbuffer_submit(rb, time,
357: !adreno_is_preemption_enabled(adreno_dev));
358: }
359:
360: static u32 a6xx_get_alwayson_counter(u32 *cmds, u64 gpuaddr)
361: {
362: cmds[0] = cp_type7_packet(CP_REG_TO_MEM, 3);
363: cmds[1] = A6XX_CP_ALWAYS_ON_COUNTER_LO | (1 << 30) | (2 << 18);
364: cmds[2] = lower_32_bits(gpuaddr);
365: cmds[3] = upper_32_bits(gpuaddr);
366:
367: return 4;
368: }
369:
370: static u32 a6xx_get_alwayson_context(u32 *cmds, u64 gpuaddr)
371: {
372: cmds[0] = cp_type7_packet(CP_REG_TO_MEM, 3);
373: cmds[1] = A6XX_CP_ALWAYS_ON_CONTEXT_LO | (1 << 30) | (2 << 18);
374: cmds[2] = lower_32_bits(gpuaddr);
375: cmds[3] = upper_32_bits(gpuaddr);
376:
377: return 4;
378: }
379:
380: #define PROFILE_IB_DWORDS 4
381: #define PROFILE_IB_SLOTS (PAGE_SIZE / (PROFILE_IB_DWORDS << 2))
382:
383: static u64 a6xx_get_user_profiling_ib(struct adreno_ringbuffer *rb,
384: struct kgsl_drawobj_cmd *cmdobj, u32 target_offset, u32 *cmds)
385: {
386: u32 offset, *ib, dwords;
387: u64 gpuaddr;
388:
389: if (IS_ERR(rb->profile_desc))
390: return 0;
391:
392: offset = rb->profile_index * (PROFILE_IB_DWORDS << 2);
393: ib = rb->profile_desc->hostptr + offset;
394: gpuaddr = rb->profile_desc->gpuaddr + offset;
395: dwords = a6xx_get_alwayson_counter(ib,
396: cmdobj->profiling_buffer_gpuaddr + target_offset);
397:
398: cmds[0] = cp_type7_packet(CP_INDIRECT_BUFFER_PFE, 3);
399: cmds[1] = lower_32_bits(gpuaddr);
400: cmds[2] = upper_32_bits(gpuaddr);
401: cmds[3] = dwords;
402:
403: rb->profile_index = (rb->profile_index + 1) % PROFILE_IB_SLOTS;
404:
405: return 4;
406: }
407:
408: static int a6xx_drawctxt_switch(struct adreno_device *adreno_dev,
409: struct adreno_ringbuffer *rb,
410: struct adreno_context *drawctxt)
411: {
412: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
413: int ret;
414:
415: if (rb->drawctxt_active == drawctxt)
416: return 0;
417:
418: if (kgsl_context_detached(&drawctxt->base))
419: return -ENOENT;
420:
421: if (!_kgsl_context_get(&drawctxt->base))
422: return -ENOENT;
423:
424: ret = a6xx_rb_context_switch(adreno_dev, rb, drawctxt);
425: if (ret) {
426: kgsl_context_put(&drawctxt->base);
427: return ret;
428: }
429:
430: trace_adreno_drawctxt_switch(rb, drawctxt);
431:
432: /* Release the current drawctxt as soon as the new one is switched */
433: adreno_put_drawctxt_on_timestamp(device, rb->drawctxt_active,
434: rb, rb->timestamp);
435:
436: rb->drawctxt_active = drawctxt;
437: return 0;
438: }
439:
440: #define A6XX_USER_PROFILE_IB(rb, cmdobj, cmds, field) \
441: a6xx_get_user_profiling_ib((rb), (cmdobj), \
442: offsetof(struct kgsl_drawobj_profiling_buffer, field), \
443: (cmds))
444:
445: #define A6XX_KERNEL_PROFILE(dev, cmdobj, cmds, field) \
446: a6xx_get_alwayson_counter((cmds), \
447: (dev)->profile_buffer->gpuaddr + \
448: ADRENO_DRAWOBJ_PROFILE_OFFSET((cmdobj)->profile_index, \
449: field))
450:
451: #define A6XX_KERNEL_PROFILE_CONTEXT(dev, cmdobj, cmds, field) \
452: a6xx_get_alwayson_context((cmds), \
453: (dev)->profile_buffer->gpuaddr + \
454: ADRENO_DRAWOBJ_PROFILE_OFFSET((cmdobj)->profile_index, \
455: field))
456:
457: #define A6XX_COMMAND_DWORDS 40
458:
459: int a6xx_ringbuffer_submitcmd(struct adreno_device *adreno_dev,
460: struct kgsl_drawobj_cmd *cmdobj, u32 flags,
461: struct adreno_submit_time *time)
462: {
463: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
464: struct kgsl_drawobj *drawobj = DRAWOBJ(cmdobj);
465: struct adreno_context *drawctxt = ADRENO_CONTEXT(drawobj->context);
466: struct adreno_ringbuffer *rb = drawctxt->rb;
467: int ret = 0, numibs = 0, index = 0;
468: u32 *cmds;
469:
470: /* Count the number of IBs (if we are not skipping) */
471: if (!IS_SKIP(flags)) {
472: struct list_head *tmp;
473:
474: list_for_each(tmp, &cmdobj->cmdlist)
475: numibs++;
476: }
477:
478: cmds = kvmalloc((A6XX_COMMAND_DWORDS + (numibs * 5)) << 2, GFP_KERNEL);
479: if (!cmds) {
480: ret = -ENOMEM;
481: goto done;
482: }
483:
484: cmds[index++] = cp_type7_packet(CP_NOP, 1);
485: cmds[index++] = START_IB_IDENTIFIER;
486:
487: /* Kernel profiling: 8 dwords */
488: if (IS_KERNEL_PROFILE(flags)) {
489: index += A6XX_KERNEL_PROFILE(adreno_dev, cmdobj, &cmds[index],
490: started);
491: index += A6XX_KERNEL_PROFILE_CONTEXT(adreno_dev, cmdobj, &cmds[index],
492: ctx_start);
493: }
494:
495: /* User profiling: 4 dwords */
496: if (IS_USER_PROFILE(flags))
497: index += A6XX_USER_PROFILE_IB(rb, cmdobj, &cmds[index],
498: gpu_ticks_submitted);
499:
500: if (numibs) {
501: struct kgsl_memobj_node *ib;
502:
503: cmds[index++] = cp_type7_packet(CP_SET_MARKER, 1);
504: cmds[index++] = 0x00d; /* IB1LIST start */
505:
506: list_for_each_entry(ib, &cmdobj->cmdlist, node) {
507: if (ib->priv & MEMOBJ_SKIP ||
508: (ib->flags & KGSL_CMDLIST_CTXTSWITCH_PREAMBLE
509: && !IS_PREAMBLE(flags)))
510: cmds[index++] = cp_type7_packet(CP_NOP, 4);
511:
512: cmds[index++] =
513: cp_type7_packet(CP_INDIRECT_BUFFER_PFE, 3);
514: cmds[index++] = lower_32_bits(ib->gpuaddr);
515: cmds[index++] = upper_32_bits(ib->gpuaddr);
516:
517: /* Double check that IB_PRIV is never set */
518: cmds[index++] = (ib->size >> 2) & 0xfffff;
519: }
520:
521: cmds[index++] = cp_type7_packet(CP_SET_MARKER, 1);
522: cmds[index++] = 0x00e; /* IB1LIST end */
523: }
524:
525: /* CCU invalidate */
526: cmds[index++] = cp_type7_packet(CP_EVENT_WRITE, 1);
527: cmds[index++] = 24;
528:
529: cmds[index++] = cp_type7_packet(CP_EVENT_WRITE, 1);
530: cmds[index++] = 25;
531:
532: /* 8 dwords */
533: if (IS_KERNEL_PROFILE(flags)) {
534: index += A6XX_KERNEL_PROFILE(adreno_dev, cmdobj, &cmds[index],
535: retired);
536: index += A6XX_KERNEL_PROFILE_CONTEXT(adreno_dev, cmdobj, &cmds[index],
537: ctx_end);
538: }
539:
540: /* 4 dwords */
541: if (IS_USER_PROFILE(flags))
542: index += A6XX_USER_PROFILE_IB(rb, cmdobj, &cmds[index],
543: gpu_ticks_retired);
544:
545: cmds[index++] = cp_type7_packet(CP_NOP, 1);
546: cmds[index++] = END_IB_IDENTIFIER;
547:
548: ret = a6xx_drawctxt_switch(adreno_dev, rb, drawctxt);
549:
550: /*
551: * In the unlikely event of an error in the drawctxt switch,
552: * treat it like a hang
553: */
554: if (ret) {
555: /*
556: * It is "normal" to get a -ENOSPC or a -ENOENT. Don't log it,
557: * the upper layers know how to handle it
558: */
559: if (ret != -ENOSPC && ret != -ENOENT)
560: dev_err(device->dev,
561: "Unable to switch draw context: %d\n",
562: ret);
563: goto done;
564: }
565:
566: adreno_drawobj_set_constraint(device, drawobj);
567:
568: ret = a6xx_ringbuffer_addcmds(adreno_dev, drawctxt->rb, drawctxt,
569: flags, cmds, index, drawobj->timestamp, time);
570:
571: done:
572: trace_kgsl_issueibcmds(device, drawctxt->base.id, numibs,
573: drawobj->timestamp, drawobj->flags, ret, drawctxt->type);
574:
575: kvfree(cmds);
576: return ret;
577: }
--- FILE: \adreno_a6xx_rpmh.c | HITS: 7 ---
MATCH LINES: 30, 31
18: * @sec_rail: Pointer to second/dependent power rail vlvl table
19: * @freqs: List of GMU frequencies
20: * @vlvls: List of GMU voltage levels
21: *
22: * This function initializes the cx votes for all gmu frequencies
23: * for gmu dcvs
24: */
25: static int setup_cx_arc_votes(struct adreno_device *adreno_dev,
26: struct rpmh_arc_vals *pri_rail, struct rpmh_arc_vals *sec_rail,
27: u32 *freqs, u32 *vlvls)
28: {
29: /* Hardcoded values of GMU CX voltage levels */
30: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
31: struct a6xx_hfi *hfi = &gmu->hfi;
32: u16 gmu_cx_vlvl[MAX_CX_LEVELS_LEGACY];
33: u32 cx_votes[MAX_CX_LEVELS_LEGACY];
34: struct hfi_dcvstable_cmd *table = &hfi->dcvs_table;
35: int ret, i;
36:
37: gmu_cx_vlvl[0] = 0;
38: gmu_cx_vlvl[1] = vlvls[0];
39: gmu_cx_vlvl[2] = vlvls[1];
40:
41: table->gmu_level_num = 3;
42:
43: table->cx_votes[0].freq = 0;
44: table->cx_votes[1].freq = freqs[0] / 1000;
45: table->cx_votes[2].freq = freqs[1] / 1000;
46:
47: ret = adreno_rpmh_setup_volt_dependency_tbl(cx_votes, pri_rail,
48: sec_rail, gmu_cx_vlvl, table->gmu_level_num);
49: if (!ret) {
50: for (i = 0; i < table->gmu_level_num; i++)
51: table->cx_votes[i].vote = cx_votes[i];
52: }
53:
54: return ret;
55: }
MATCH LINES: 71
59: * @hfi: Pointer to hfi device
60: * @pri_rail: Pointer to primary power rail vlvl table
61: * @sec_rail: Pointer to second/dependent power rail vlvl table
62: *
63: * This function initializes the gx votes for all gpu frequencies
64: * for gpu dcvs
65: */
66: static int setup_gx_arc_votes(struct adreno_device *adreno_dev,
67: struct rpmh_arc_vals *pri_rail, struct rpmh_arc_vals *sec_rail,
68: struct rpmh_arc_vals *cx_rail)
69: {
70: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
71: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
72: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
73: struct hfi_dcvstable_cmd *table = &gmu->hfi.dcvs_table;
74: u32 index;
75: u16 vlvl_tbl[MAX_GX_LEVELS];
76: u32 gx_votes[MAX_GX_LEVELS];
77: int ret, i;
78:
79: /* Add the zero powerlevel for the perf table */
80: table->gpu_level_num = device->pwrctrl.num_pwrlevels + 1;
81:
82: if (table->gpu_level_num > pri_rail->num ||
83: table->gpu_level_num > ARRAY_SIZE(vlvl_tbl)) {
84: dev_err(GMU_PDEV_DEV(device),
85: "Defined more GPU DCVS levels than RPMh can support\n");
86: return -ERANGE;
87: }
88:
89: memset(vlvl_tbl, 0, sizeof(vlvl_tbl));
90:
91: table->gx_votes[0].freq = 0;
92: table->gx_votes[0].dep_vote = 0;
93: /* Disable cx vote in gmu dcvs table if it is not supported in DT */
94: if (pwr->pwrlevels[0].cx_level == 0xffffffff)
95: table->gx_votes[0].dep_vote = 0xffffffff;
MATCH LINES: 126, 128
114: sec_rail, vlvl_tbl, table->gpu_level_num);
115: if (!ret) {
116: for (i = 0; i < table->gpu_level_num; i++)
117: table->gx_votes[i].vote = gx_votes[i];
118: }
119:
120: return ret;
121:
122: }
123:
124: static int build_dcvs_table(struct adreno_device *adreno_dev)
125: {
126: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
127: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
128: struct a6xx_hfi *hfi = &gmu->hfi;
129: struct rpmh_arc_vals gx_arc, cx_arc, mx_arc;
130: int ret;
131:
132: ret = CMD_MSG_HDR(hfi->dcvs_table, H2F_MSG_PERF_TBL);
133: if (ret)
134: return ret;
135:
136: ret = adreno_rpmh_arc_cmds(&gx_arc, "gfx.lvl");
137: if (ret)
138: return ret;
139:
140: ret = adreno_rpmh_arc_cmds(&cx_arc, "cx.lvl");
141: if (ret)
142: return ret;
143:
144: ret = adreno_rpmh_arc_cmds(&mx_arc, "mx.lvl");
145: if (ret)
146: return ret;
147:
148: ret = setup_cx_arc_votes(adreno_dev, &cx_arc, &mx_arc,
149: device->gmu_core.freqs, device->gmu_core.vlvls);
150: if (ret)
151: return ret;
152:
MATCH LINES: 167
155:
156: /* BIT(3) is used to vote for GPU performance mode through GMU */
157: #define ACV_GPU_PERFMODE_VOTE BIT(3)
158:
159: /* Use hardcoded CNOC table when not defined in device tree */
160: static const u32 default_cnoc_table[] = {
161: 0, /* Off */
162: 100, /* On */
163: };
164:
165: static int build_bw_table(struct adreno_device *adreno_dev)
166: {
167: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
168: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
169: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
170: struct rpmh_bw_votes *ddr, *cnoc = NULL;
171: u32 *cnoc_table;
172: u32 count = 0;
173: int ret;
174:
175: ddr = adreno_rpmh_build_bw_votes(adreno_ddr_bcms, ARRAY_SIZE(adreno_ddr_bcms),
176: pwr->ddr_table, pwr->ddr_table_count, ACV_GPU_PERFMODE_VOTE, 0,
177: adreno_dev->gmu_ab);
178: if (IS_ERR(ddr))
179: return PTR_ERR(ddr);
180:
181: cnoc_table = kgsl_bus_get_table(device->pdev, "qcom,bus-table-cnoc",
182: &count);
183:
184: /* Use hardcoded CNOC table */
185: if (!count) {
186: cnoc_table = (u32 *)default_cnoc_table;
187: count = ARRAY_SIZE(default_cnoc_table);
188: }
189:
190: cnoc = adreno_rpmh_build_bw_votes(adreno_cnoc_bcms,
191: ARRAY_SIZE(adreno_cnoc_bcms), cnoc_table, count, 0, 0,
MATCH LINES: 214
202: ret = CMD_MSG_HDR(gmu->hfi.bw_table, H2F_MSG_BW_VOTE_TBL);
203: if (ret)
204: return ret;
205:
206: adreno_rpmh_build_bw_table_cmd(&gmu->hfi.bw_table, ddr, cnoc);
207:
208: adreno_rpmh_free_bw_votes(ddr);
209: adreno_rpmh_free_bw_votes(cnoc);
210:
211: return 0;
212: }
213:
214: int a6xx_build_rpmh_tables(struct adreno_device *adreno_dev)
215: {
216: int ret;
217:
218: ret = build_dcvs_table(adreno_dev);
219: if (ret)
220: return ret;
221:
222: return build_bw_table(adreno_dev);
223: }
--- FILE: \adreno_a6xx_snapshot.c | HITS: 670 ---
MATCH LINES: 11, 12, 13, 14, 16, 22, 29, 34, 38, 47, 66, 67, 68, 71, 72, 73, 77, 84, 85, 87, 88, 89, 90, 91, 93, 95, 96, 101, 102, 106, 110, 115, 119, 123, 127, 132, 137, 141, 145, 149, 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, 186, 187, 191, 196, 201, 205, 211, 212, 213, 214, 215, 216, 217, 220, 235, 240, 246, 251, 262
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: #include "adreno.h"
8: #include "adreno_a6xx.h"
9: #include "adreno_snapshot.h"
10:
11: #define A6XX_NUM_CTXTS 2
12: #define A6XX_NUM_AXI_ARB_BLOCKS 2
13: #define A6XX_NUM_XIN_AXI_BLOCKS 5
14: #define A6XX_NUM_XIN_CORE_BLOCKS 4
15:
16: static const unsigned int a6xx_gras_cluster[] = {
17: 0x8000, 0x8006, 0x8010, 0x8092, 0x8094, 0x809D, 0x80A0, 0x80A6,
18: 0x80AF, 0x80F1, 0x8100, 0x8107, 0x8109, 0x8109, 0x8110, 0x8110,
19: 0x8400, 0x840B,
20: };
21:
22: static const unsigned int a6xx_ps_cluster_rac[] = {
23: 0x8800, 0x8806, 0x8809, 0x8811, 0x8818, 0x881E, 0x8820, 0x8865,
24: 0x8870, 0x8879, 0x8880, 0x8889, 0x8890, 0x8891, 0x8898, 0x8898,
25: 0x88C0, 0x88C1, 0x88D0, 0x88E3, 0x8900, 0x890C, 0x890F, 0x891A,
26: 0x8C00, 0x8C01, 0x8C08, 0x8C10, 0x8C17, 0x8C1F, 0x8C26, 0x8C33,
27: };
28:
29: static const unsigned int a6xx_ps_cluster_rbp[] = {
30: 0x88F0, 0x88F3, 0x890D, 0x890E, 0x8927, 0x8928, 0x8BF0, 0x8BF1,
31: 0x8C02, 0x8C07, 0x8C11, 0x8C16, 0x8C20, 0x8C25,
32: };
33:
34: static const unsigned int a6xx_vpc_ps_cluster[] = {
35: 0x9200, 0x9216, 0x9218, 0x9236, 0x9300, 0x9306,
36: };
37:
38: static const unsigned int a6xx_fe_cluster[] = {
39: 0x9300, 0x9306, 0x9800, 0x9806, 0x9B00, 0x9B07, 0xA000, 0xA009,
40: 0xA00E, 0xA0EF, 0xA0F8, 0xA0F8,
41: };
42:
43: static const unsigned int a660_fe_cluster[] = {
44: 0x9807, 0x9807,
45: };
46:
47: static const unsigned int a6xx_pc_vs_cluster[] = {
48: 0x9100, 0x9108, 0x9300, 0x9306, 0x9980, 0x9981, 0x9B00, 0x9B07,
49: };
50:
51: static const unsigned int a650_isense_registers[] = {
52: 0x22C00, 0x22C19, 0x22C26, 0x22C2D, 0x22C2F, 0x22C36, 0x22C40, 0x22C44,
53: 0x22C50, 0x22C57, 0x22C60, 0x22C67, 0x22C80, 0x22C87, 0x22D25, 0x22D2A,
54: 0x22D2C, 0x22D32, 0x22D3E, 0x22D3F, 0x22D4E, 0x22D55, 0x22D58, 0x22D60,
55: 0x22D64, 0x22D64, 0x22D66, 0x22D66, 0x22D68, 0x22D6B, 0x22D6E, 0x22D76,
56: 0x22D78, 0x22D78, 0x22D80, 0x22D87, 0x22D90, 0x22D97, 0x22DA0, 0x22DA0,
57: 0x22DB0, 0x22DB7, 0x22DC0, 0x22DC2, 0x22DC4, 0x22DE3, 0x2301A, 0x2301A,
58: 0x2301D, 0x2302A, 0x23120, 0x23121, 0x23133, 0x23133, 0x23156, 0x23157,
59: 0x23165, 0x23165, 0x2316D, 0x2316D, 0x23180, 0x23191,
60: };
61:
62: static const struct sel_reg {
63: unsigned int host_reg;
64: unsigned int cd_reg;
65: unsigned int val;
66: } _a6xx_rb_rac_aperture = {
67: .host_reg = A6XX_RB_RB_SUB_BLOCK_SEL_CNTL_HOST,
68: .cd_reg = A6XX_RB_RB_SUB_BLOCK_SEL_CNTL_CD,
69: .val = 0x0,
70: },
71: _a6xx_rb_rbp_aperture = {
72: .host_reg = A6XX_RB_RB_SUB_BLOCK_SEL_CNTL_HOST,
73: .cd_reg = A6XX_RB_RB_SUB_BLOCK_SEL_CNTL_CD,
74: .val = 0x9,
75: };
76:
77: static struct a6xx_cluster_registers {
78: unsigned int id;
79: const unsigned int *regs;
80: unsigned int num_sets;
81: const struct sel_reg *sel;
82: unsigned int offset0;
83: unsigned int offset1;
84: } a6xx_clusters[] = {
85: { CP_CLUSTER_GRAS, a6xx_gras_cluster, ARRAY_SIZE(a6xx_gras_cluster)/2,
86: NULL },
87: { CP_CLUSTER_PS, a6xx_ps_cluster_rac, ARRAY_SIZE(a6xx_ps_cluster_rac)/2,
88: &_a6xx_rb_rac_aperture },
89: { CP_CLUSTER_PS, a6xx_ps_cluster_rbp, ARRAY_SIZE(a6xx_ps_cluster_rbp)/2,
90: &_a6xx_rb_rbp_aperture },
91: { CP_CLUSTER_PS, a6xx_vpc_ps_cluster, ARRAY_SIZE(a6xx_vpc_ps_cluster)/2,
92: NULL },
93: { CP_CLUSTER_FE, a6xx_fe_cluster, ARRAY_SIZE(a6xx_fe_cluster)/2,
94: NULL },
95: { CP_CLUSTER_PC_VS, a6xx_pc_vs_cluster,
96: ARRAY_SIZE(a6xx_pc_vs_cluster)/2, NULL },
97: { CP_CLUSTER_FE, a660_fe_cluster, ARRAY_SIZE(a660_fe_cluster)/2,
98: NULL },
99: };
100:
101: struct a6xx_cluster_regs_info {
102: struct a6xx_cluster_registers *cluster;
103: unsigned int ctxt_id;
104: };
105:
106: static const unsigned int a6xx_sp_vs_hlsq_cluster[] = {
107: 0xB800, 0xB803, 0xB820, 0xB822,
108: };
109:
110: static const unsigned int a6xx_sp_vs_sp_cluster[] = {
111: 0xA800, 0xA824, 0xA830, 0xA83C, 0xA840, 0xA864, 0xA870, 0xA895,
112: 0xA8A0, 0xA8AF, 0xA8C0, 0xA8C3,
113: };
114:
115: static const unsigned int a6xx_hlsq_duplicate_cluster[] = {
116: 0xBB10, 0xBB11, 0xBB20, 0xBB29,
117: };
118:
119: static const unsigned int a6xx_sp_duplicate_cluster[] = {
120: 0xAB00, 0xAB00, 0xAB04, 0xAB05, 0xAB10, 0xAB1B, 0xAB20, 0xAB20,
121: };
122:
123: static const unsigned int a6xx_tp_duplicate_cluster[] = {
124: 0xB300, 0xB307, 0xB309, 0xB309, 0xB380, 0xB382,
125: };
126:
127: static const unsigned int a6xx_sp_ps_hlsq_cluster[] = {
128: 0xB980, 0xB980, 0xB982, 0xB987, 0xB990, 0xB99B, 0xB9A0, 0xB9A2,
129: 0xB9C0, 0xB9C9,
130: };
131:
132: static const unsigned int a6xx_sp_ps_sp_cluster[] = {
133: 0xA980, 0xA9A8, 0xA9B0, 0xA9BC, 0xA9D0, 0xA9D3, 0xA9E0, 0xA9F3,
134: 0xAA00, 0xAA00, 0xAA30, 0xAA31, 0xAAF2, 0xAAF2,
135: };
136:
137: static const unsigned int a6xx_sp_ps_sp_2d_cluster[] = {
138: 0xACC0, 0xACC0,
139: };
140:
141: static const unsigned int a6xx_sp_ps_tp_cluster[] = {
142: 0xB180, 0xB183, 0xB190, 0xB191,
143: };
144:
145: static const unsigned int a6xx_sp_ps_tp_2d_cluster[] = {
146: 0xB4C0, 0xB4D1,
147: };
148:
149: static struct a6xx_cluster_dbgahb_registers {
150: unsigned int id;
151: unsigned int regbase;
152: unsigned int statetype;
153: const unsigned int *regs;
154: unsigned int num_sets;
155: unsigned int offset0;
156: unsigned int offset1;
157: } a6xx_dbgahb_ctx_clusters[] = {
158: { CP_CLUSTER_SP_VS, 0x0002E000, 0x41, a6xx_sp_vs_hlsq_cluster,
159: ARRAY_SIZE(a6xx_sp_vs_hlsq_cluster) / 2 },
160: { CP_CLUSTER_SP_VS, 0x0002A000, 0x21, a6xx_sp_vs_sp_cluster,
161: ARRAY_SIZE(a6xx_sp_vs_sp_cluster) / 2 },
162: { CP_CLUSTER_SP_VS, 0x0002E000, 0x41, a6xx_hlsq_duplicate_cluster,
163: ARRAY_SIZE(a6xx_hlsq_duplicate_cluster) / 2 },
164: { CP_CLUSTER_SP_VS, 0x0002A000, 0x21, a6xx_sp_duplicate_cluster,
165: ARRAY_SIZE(a6xx_sp_duplicate_cluster) / 2 },
166: { CP_CLUSTER_SP_VS, 0x0002C000, 0x1, a6xx_tp_duplicate_cluster,
167: ARRAY_SIZE(a6xx_tp_duplicate_cluster) / 2 },
168: { CP_CLUSTER_SP_PS, 0x0002E000, 0x42, a6xx_sp_ps_hlsq_cluster,
169: ARRAY_SIZE(a6xx_sp_ps_hlsq_cluster) / 2 },
170: { CP_CLUSTER_SP_PS, 0x0002A000, 0x22, a6xx_sp_ps_sp_cluster,
171: ARRAY_SIZE(a6xx_sp_ps_sp_cluster) / 2 },
172: { CP_CLUSTER_SP_PS, 0x0002B000, 0x26, a6xx_sp_ps_sp_2d_cluster,
173: ARRAY_SIZE(a6xx_sp_ps_sp_2d_cluster) / 2 },
174: { CP_CLUSTER_SP_PS, 0x0002C000, 0x2, a6xx_sp_ps_tp_cluster,
175: ARRAY_SIZE(a6xx_sp_ps_tp_cluster) / 2 },
176: { CP_CLUSTER_SP_PS, 0x0002D000, 0x6, a6xx_sp_ps_tp_2d_cluster,
177: ARRAY_SIZE(a6xx_sp_ps_tp_2d_cluster) / 2 },
178: { CP_CLUSTER_SP_PS, 0x0002E000, 0x42, a6xx_hlsq_duplicate_cluster,
179: ARRAY_SIZE(a6xx_hlsq_duplicate_cluster) / 2 },
180: { CP_CLUSTER_SP_PS, 0x0002A000, 0x22, a6xx_sp_duplicate_cluster,
181: ARRAY_SIZE(a6xx_sp_duplicate_cluster) / 2 },
182: { CP_CLUSTER_SP_PS, 0x0002C000, 0x2, a6xx_tp_duplicate_cluster,
183: ARRAY_SIZE(a6xx_tp_duplicate_cluster) / 2 },
184: };
185:
186: struct a6xx_cluster_dbgahb_regs_info {
187: struct a6xx_cluster_dbgahb_registers *cluster;
188: unsigned int ctxt_id;
189: };
190:
191: static const unsigned int a6xx_hlsq_non_ctx_registers[] = {
192: 0xBE00, 0xBE01, 0xBE04, 0xBE05, 0xBE08, 0xBE09, 0xBE10, 0xBE15,
193: 0xBE20, 0xBE23,
194: };
195:
196: static const unsigned int a6xx_sp_non_ctx_registers[] = {
197: 0xAE00, 0xAE04, 0xAE0C, 0xAE0C, 0xAE0F, 0xAE2B, 0xAE30, 0xAE32,
198: 0xAE35, 0xAE35, 0xAE3A, 0xAE3F, 0xAE50, 0xAE52,
199: };
200:
201: static const unsigned int a6xx_tp_non_ctx_registers[] = {
202: 0xB600, 0xB601, 0xB604, 0xB605, 0xB610, 0xB61B, 0xB620, 0xB623,
203: };
204:
205: static struct a6xx_non_ctx_dbgahb_registers {
206: unsigned int regbase;
207: unsigned int statetype;
208: const unsigned int *regs;
209: unsigned int num_sets;
210: unsigned int offset;
211: } a6xx_non_ctx_dbgahb[] = {
212: { 0x0002F800, 0x40, a6xx_hlsq_non_ctx_registers,
213: ARRAY_SIZE(a6xx_hlsq_non_ctx_registers) / 2 },
214: { 0x0002B800, 0x20, a6xx_sp_non_ctx_registers,
215: ARRAY_SIZE(a6xx_sp_non_ctx_registers) / 2 },
216: { 0x0002D800, 0x0, a6xx_tp_non_ctx_registers,
217: ARRAY_SIZE(a6xx_tp_non_ctx_registers) / 2 },
218: };
219:
220: static const unsigned int a6xx_vbif_registers[] = {
221: /* VBIF */
222: 0x3000, 0x3007, 0x300C, 0x3014, 0x3018, 0x302D, 0x3030, 0x3031,
223: 0x3034, 0x3036, 0x303C, 0x303D, 0x3040, 0x3040, 0x3042, 0x3042,
224: 0x3049, 0x3049, 0x3058, 0x3058, 0x305A, 0x3061, 0x3064, 0x3068,
225: 0x306C, 0x306D, 0x3080, 0x3088, 0x308B, 0x308C, 0x3090, 0x3094,
226: 0x3098, 0x3098, 0x309C, 0x309C, 0x30C0, 0x30C0, 0x30C8, 0x30C8,
227: 0x30D0, 0x30D0, 0x30D8, 0x30D8, 0x30E0, 0x30E0, 0x3100, 0x3100,
228: 0x3108, 0x3108, 0x3110, 0x3110, 0x3118, 0x3118, 0x3120, 0x3120,
229: 0x3124, 0x3125, 0x3129, 0x3129, 0x3131, 0x3131, 0x3154, 0x3154,
230: 0x3156, 0x3156, 0x3158, 0x3158, 0x315A, 0x315A, 0x315C, 0x315C,
231: 0x315E, 0x315E, 0x3160, 0x3160, 0x3162, 0x3162, 0x340C, 0x340C,
232: 0x3410, 0x3410, 0x3800, 0x3801,
233: };
234:
235: static const unsigned int a6xx_gbif_registers[] = {
236: /* GBIF */
237: 0x3C00, 0X3C0B, 0X3C40, 0X3C47, 0X3CC0, 0X3CD1, 0xE3A, 0xE3A,
238: };
239:
240: static const unsigned int a6xx_gbif_reinit_registers[] = {
241: /* GBIF with REINIT */
242: 0x3C00, 0X3C0B, 0X3C40, 0X3C47, 0X3C49, 0X3C4A, 0X3CC0, 0X3CD1,
243: 0xE3A, 0xE3A, 0x0016, 0x0017,
244: };
245:
246: static const unsigned int a6xx_rb_rac_registers[] = {
247: 0x8E04, 0x8E05, 0x8E07, 0x8E08, 0x8E10, 0x8E1C, 0x8E20, 0x8E25,
248: 0x8E28, 0x8E28, 0x8E2C, 0x8E2F, 0x8E50, 0x8E52,
249: };
250:
251: static const unsigned int a6xx_rb_rbp_registers[] = {
252: 0x8E01, 0x8E01, 0x8E0C, 0x8E0C, 0x8E3B, 0x8E3E, 0x8E40, 0x8E43,
253: 0x8E53, 0x8E5F, 0x8E70, 0x8E77,
254: };
255:
256: /*
257: * Set of registers to dump for A6XX on snapshot.
258: * Registers in pairs - first value is the start offset, second
259: * is the stop offset (inclusive)
260: */
261:
262: static const unsigned int a6xx_registers[] = {
263: /* RBBM */
264: 0x0000, 0x0002, 0x0010, 0x0010, 0x0012, 0x0012, 0x0018, 0x001B,
265: 0x001e, 0x0032, 0x0038, 0x003C, 0x0042, 0x0042, 0x0044, 0x0044,
266: 0x0047, 0x0047, 0x0056, 0x0056, 0x00AD, 0x00AE, 0x00B0, 0x00FB,
267: 0x0100, 0x011D, 0x0200, 0x020D, 0x0218, 0x023D, 0x0400, 0x04F9,
268: 0x0500, 0x0500, 0x0505, 0x050B, 0x050E, 0x0511, 0x0533, 0x0533,
269: 0x0540, 0x0555,
270: /* CP */
271: 0x0800, 0x0803, 0x0806, 0x0808, 0x0810, 0x0813, 0x0820, 0x0821,
272: 0x0823, 0x0824, 0x0826, 0x0827, 0x0830, 0x0833, 0x0840, 0x0845,
273: 0x084F, 0x086F, 0x0880, 0x088A, 0x08A0, 0x08AB, 0x08C0, 0x08C4,
274: 0x08D0, 0x08DD, 0x08F0, 0x08F3, 0x0900, 0x0903, 0x0908, 0x0911,
275: 0x0928, 0x093E, 0x0942, 0x094D, 0x0980, 0x0984, 0x098D, 0x0996,
276: 0x0998, 0x099E, 0x09A0, 0x09A6, 0x09A8, 0x09AE, 0x09B0, 0x09B1,
277: 0x09C2, 0x09C8, 0x0A00, 0x0A03,
278: /* VSC */
279: 0x0C00, 0x0C04, 0x0C06, 0x0C06, 0x0C10, 0x0CD9, 0x0E00, 0x0E0E,
280: /* UCHE */
281: 0x0E10, 0x0E13, 0x0E17, 0x0E19, 0x0E1C, 0x0E2B, 0x0E30, 0x0E32,
282: 0x0E38, 0x0E39,
283: /* GRAS */
284: 0x8600, 0x8601, 0x8610, 0x861B, 0x8620, 0x8620, 0x8628, 0x862B,
285: 0x8630, 0x8637,
286: /* VPC */
MATCH LINES: 313, 320, 327, 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, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 437, 438, 441, 442, 443, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 462, 463, 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, 514, 520, 521, 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, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 574, 575, 577, 584, 585, 587, 588, 589, 590, 596, 611, 622, 630, 657, 661, 662, 668, 673, 674, 675, 694, 695, 702, 704, 713, 721, 726, 727, 728, 732, 743, 749, 753, 755, 756, 757, 759, 760, 765, 776, 777, 780, 783, 786, 793, 794, 797, 817, 820, 823, 831, 836, 837, 838, 858, 884, 894, 899, 900, 901, 909, 922, 949, 954, 955, 980, 989, 998, 1003, 1004, 1011, 1021, 1049, 1054, 1055, 1056, 1057, 1060, 1065, 1069, 1072, 1076, 1081, 1082, 1083, 1104, 1135, 1140, 1141, 1142, 1150, 1162, 1188, 1192, 1194, 1195, 1203, 1208, 1213, 1214, 1219, 1220, 1222, 1223, 1224, 1225, 1233, 1235, 1238, 1239, 1263, 1264, 1270, 1271, 1274, 1279, 1280, 1293, 1294, 1295, 1309, 1310, 1311, 1312, 1313, 1314, 1315, 1316, 1318, 1319, 1322, 1323, 1324, 1325, 1332, 1333, 1335, 1336, 1337, 1338, 1343, 1346, 1347, 1349, 1350, 1351, 1352, 1358, 1362, 1363, 1368, 1369, 1371, 1372, 1373, 1374, 1382, 1384, 1388, 1391, 1416, 1422, 1423, 1432, 1433, 1434, 1435, 1437, 1438, 1440, 1441, 1442, 1443, 1445, 1446, 1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454, 1455, 1456, 1457, 1458, 1459, 1460, 1461, 1462, 1464, 1465, 1466, 1467, 1469, 1470, 1471, 1472, 1474, 1475, 1477, 1478, 1479, 1480, 1482, 1483, 1484, 1485, 1486, 1487, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, 1501, 1502, 1503, 1504, 1506, 1509, 1510, 1517, 1530, 1531, 1535, 1536, 1539, 1540, 1543, 1544, 1555, 1556, 1560, 1570, 1571, 1580, 1582, 1583, 1584, 1585, 1586, 1596, 1607, 1610, 1620, 1627, 1638, 1640, 1645, 1657, 1664, 1679, 1695, 1696, 1699, 1700, 1703, 1708, 1709, 1713, 1714, 1718, 1719, 1723, 1727, 1731, 1732, 1734, 1735, 1738, 1739, 1743, 1745, 1748, 1752, 1757, 1761, 1766, 1774, 1777, 1778, 1780, 1781, 1783, 1786, 1787, 1790, 1799, 1805, 1809, 1812, 1815, 1818, 1819, 1825, 1831, 1838, 1845, 1846, 1855, 1865, 1872, 1878, 1891, 1898, 1901, 1902, 1906, 1908, 1921, 1927, 1928, 1929, 1933, 1941, 1949, 1951, 1962, 1968, 1969, 1970, 1976, 1984, 1986, 1996, 2005, 2006, 2019, 2020, 2047, 2048, 2049, 2050, 2054, 2055, 2066, 2082, 2083, 2084, 2086, 2105, 2106, 2107, 2129, 2135, 2143, 2146, 2147, 2165, 2172, 2173, 2178, 2181, 2183, 2187, 2189, 2190, 2193, 2194
301: 0x0E3C, 0x0E3C,
302: /* LPAC RBBM */
303: 0x05FC, 0x05FF,
304: /* LPAC CP */
305: 0x0B00, 0x0B40, 0x0B80, 0x0B83,
306: };
307:
308: /*
309: * Set of registers to dump for A6XX before actually triggering crash dumper.
310: * Registers in pairs - first value is the start offset, second
311: * is the stop offset (inclusive)
312: */
313: static const unsigned int a6xx_pre_crashdumper_registers[] = {
314: /* RBBM: RBBM_STATUS - RBBM_STATUS3 */
315: 0x210, 0x213,
316: /* CP: CP_STATUS_1 */
317: 0x825, 0x825,
318: };
319:
320: static const unsigned int a6xx_gmu_wrapper_registers[] = {
321: /* GMU CX */
322: 0x1f840, 0x1f840, 0x1f844, 0x1f845, 0x1f887, 0x1f889, 0x1f8d0, 0x1f8d0,
323: /* GMU AO*/
324: 0x23b0C, 0x23b0E, 0x23b15, 0x23b15,
325: };
326:
327: static const unsigned int a6xx_holi_gmu_wrapper_registers[] = {
328: /* GMU SPTPRAC */
329: 0x1a880, 0x1a881,
330: /* GMU CX */
331: 0x1f840, 0x1f840, 0x1f844, 0x1f845, 0x1f887, 0x1f889, 0x1f8d0, 0x1f8d0,
332: /* GMU AO*/
333: 0x23b0c, 0x23b0e, 0x23b15, 0x23b15,
334: };
335:
336: enum a6xx_debugbus_id {
337: A6XX_DBGBUS_CP = 0x1,
338: A6XX_DBGBUS_RBBM = 0x2,
339: A6XX_DBGBUS_VBIF = 0x3,
340: A6XX_DBGBUS_HLSQ = 0x4,
341: A6XX_DBGBUS_UCHE = 0x5,
342: A6XX_DBGBUS_DPM = 0x6,
343: A6XX_DBGBUS_TESS = 0x7,
344: A6XX_DBGBUS_PC = 0x8,
345: A6XX_DBGBUS_VFDP = 0x9,
346: A6XX_DBGBUS_VPC = 0xa,
347: A6XX_DBGBUS_TSE = 0xb,
348: A6XX_DBGBUS_RAS = 0xc,
349: A6XX_DBGBUS_VSC = 0xd,
350: A6XX_DBGBUS_COM = 0xe,
351: A6XX_DBGBUS_LRZ = 0x10,
352: A6XX_DBGBUS_A2D = 0x11,
353: A6XX_DBGBUS_CCUFCHE = 0x12,
354: A6XX_DBGBUS_GMU_CX = 0x13,
355: A6XX_DBGBUS_RBP = 0x14,
356: A6XX_DBGBUS_DCS = 0x15,
357: A6XX_DBGBUS_RBBM_CFG = 0x16,
358: A6XX_DBGBUS_CX = 0x17,
359: A6XX_DBGBUS_GMU_GX = 0x18,
360: A6XX_DBGBUS_TPFCHE = 0x19,
361: A6XX_DBGBUS_GBIF_GX = 0x1a,
362: A6XX_DBGBUS_GPC = 0x1d,
363: A6XX_DBGBUS_LARC = 0x1e,
364: A6XX_DBGBUS_HLSQ_SPTP = 0x1f,
365: A6XX_DBGBUS_RB_0 = 0x20,
366: A6XX_DBGBUS_RB_1 = 0x21,
367: A6XX_DBGBUS_RB_2 = 0x22,
368: A6XX_DBGBUS_UCHE_WRAPPER = 0x24,
369: A6XX_DBGBUS_CCU_0 = 0x28,
370: A6XX_DBGBUS_CCU_1 = 0x29,
371: A6XX_DBGBUS_CCU_2 = 0x2a,
372: A6XX_DBGBUS_VFD_0 = 0x38,
373: A6XX_DBGBUS_VFD_1 = 0x39,
374: A6XX_DBGBUS_VFD_2 = 0x3a,
375: A6XX_DBGBUS_VFD_3 = 0x3b,
376: A6XX_DBGBUS_VFD_4 = 0x3c,
377: A6XX_DBGBUS_VFD_5 = 0x3d,
378: A6XX_DBGBUS_SP_0 = 0x40,
379: A6XX_DBGBUS_SP_1 = 0x41,
380: A6XX_DBGBUS_SP_2 = 0x42,
381: A6XX_DBGBUS_TPL1_0 = 0x48,
382: A6XX_DBGBUS_TPL1_1 = 0x49,
383: A6XX_DBGBUS_TPL1_2 = 0x4a,
384: A6XX_DBGBUS_TPL1_3 = 0x4b,
385: A6XX_DBGBUS_TPL1_4 = 0x4c,
386: A6XX_DBGBUS_TPL1_5 = 0x4d,
387: A6XX_DBGBUS_SPTP_0 = 0x58,
388: A6XX_DBGBUS_SPTP_1 = 0x59,
389: A6XX_DBGBUS_SPTP_2 = 0x5a,
390: A6XX_DBGBUS_SPTP_3 = 0x5b,
391: A6XX_DBGBUS_SPTP_4 = 0x5c,
392: A6XX_DBGBUS_SPTP_5 = 0x5d,
393: };
394:
395: static const struct adreno_debugbus_block a6xx_dbgc_debugbus_blocks[] = {
396: { A6XX_DBGBUS_CP, 0x100, },
397: { A6XX_DBGBUS_RBBM, 0x100, },
398: { A6XX_DBGBUS_HLSQ, 0x100, },
399: { A6XX_DBGBUS_UCHE, 0x100, },
400: { A6XX_DBGBUS_DPM, 0x100, },
401: { A6XX_DBGBUS_TESS, 0x100, },
402: { A6XX_DBGBUS_PC, 0x100, },
403: { A6XX_DBGBUS_VFDP, 0x100, },
404: { A6XX_DBGBUS_VPC, 0x100, },
405: { A6XX_DBGBUS_TSE, 0x100, },
406: { A6XX_DBGBUS_RAS, 0x100, },
407: { A6XX_DBGBUS_VSC, 0x100, },
408: { A6XX_DBGBUS_COM, 0x100, },
409: { A6XX_DBGBUS_LRZ, 0x100, },
410: { A6XX_DBGBUS_A2D, 0x100, },
411: { A6XX_DBGBUS_CCUFCHE, 0x100, },
412: { A6XX_DBGBUS_RBP, 0x100, },
413: { A6XX_DBGBUS_DCS, 0x100, },
414: { A6XX_DBGBUS_RBBM_CFG, 0x100, },
415: { A6XX_DBGBUS_GMU_GX, 0x100, },
416: { A6XX_DBGBUS_TPFCHE, 0x100, },
417: { A6XX_DBGBUS_GPC, 0x100, },
418: { A6XX_DBGBUS_LARC, 0x100, },
419: { A6XX_DBGBUS_HLSQ_SPTP, 0x100, },
420: { A6XX_DBGBUS_RB_0, 0x100, },
421: { A6XX_DBGBUS_RB_1, 0x100, },
422: { A6XX_DBGBUS_UCHE_WRAPPER, 0x100, },
423: { A6XX_DBGBUS_CCU_0, 0x100, },
424: { A6XX_DBGBUS_CCU_1, 0x100, },
425: { A6XX_DBGBUS_VFD_0, 0x100, },
426: { A6XX_DBGBUS_VFD_1, 0x100, },
427: { A6XX_DBGBUS_VFD_2, 0x100, },
428: { A6XX_DBGBUS_VFD_3, 0x100, },
429: { A6XX_DBGBUS_SP_0, 0x100, },
430: { A6XX_DBGBUS_SP_1, 0x100, },
431: { A6XX_DBGBUS_TPL1_0, 0x100, },
432: { A6XX_DBGBUS_TPL1_1, 0x100, },
433: { A6XX_DBGBUS_TPL1_2, 0x100, },
434: { A6XX_DBGBUS_TPL1_3, 0x100, },
435: };
436:
437: static const struct adreno_debugbus_block a6xx_vbif_debugbus_blocks = {
438: A6XX_DBGBUS_VBIF, 0x100,
439: };
440:
441: static const struct adreno_debugbus_block a6xx_cx_dbgc_debugbus_blocks[] = {
442: { A6XX_DBGBUS_GMU_CX, 0x100, },
443: { A6XX_DBGBUS_CX, 0x100, },
444: };
445:
446: static const struct adreno_debugbus_block a650_dbgc_debugbus_blocks[] = {
447: { A6XX_DBGBUS_RB_2, 0x100, },
448: { A6XX_DBGBUS_CCU_2, 0x100, },
449: { A6XX_DBGBUS_VFD_4, 0x100, },
450: { A6XX_DBGBUS_VFD_5, 0x100, },
451: { A6XX_DBGBUS_SP_2, 0x100, },
452: { A6XX_DBGBUS_TPL1_4, 0x100, },
453: { A6XX_DBGBUS_TPL1_5, 0x100, },
454: { A6XX_DBGBUS_SPTP_0, 0x100, },
455: { A6XX_DBGBUS_SPTP_1, 0x100, },
456: { A6XX_DBGBUS_SPTP_2, 0x100, },
457: { A6XX_DBGBUS_SPTP_3, 0x100, },
458: { A6XX_DBGBUS_SPTP_4, 0x100, },
459: { A6XX_DBGBUS_SPTP_5, 0x100, },
460: };
461:
462: #define A6XX_NUM_SHADER_BANKS 3
463: #define A6XX_SHADER_STATETYPE_SHIFT 8
464:
465: enum a6xx_shader_obj {
466: A6XX_TP0_TMO_DATA = 0x9,
467: A6XX_TP0_SMO_DATA = 0xa,
468: A6XX_TP0_MIPMAP_BASE_DATA = 0xb,
469: A6XX_TP1_TMO_DATA = 0x19,
470: A6XX_TP1_SMO_DATA = 0x1a,
471: A6XX_TP1_MIPMAP_BASE_DATA = 0x1b,
472: A6XX_SP_INST_DATA = 0x29,
473: A6XX_SP_LB_0_DATA = 0x2a,
474: A6XX_SP_LB_1_DATA = 0x2b,
475: A6XX_SP_LB_2_DATA = 0x2c,
476: A6XX_SP_LB_3_DATA = 0x2d,
477: A6XX_SP_LB_4_DATA = 0x2e,
478: A6XX_SP_LB_5_DATA = 0x2f,
479: A6XX_SP_CB_BINDLESS_DATA = 0x30,
480: A6XX_SP_CB_LEGACY_DATA = 0x31,
481: A6XX_SP_UAV_DATA = 0x32,
482: A6XX_SP_INST_TAG = 0x33,
483: A6XX_SP_CB_BINDLESS_TAG = 0x34,
484: A6XX_SP_TMO_UMO_TAG = 0x35,
485: A6XX_SP_SMO_TAG = 0x36,
486: A6XX_SP_STATE_DATA = 0x37,
487: A6XX_HLSQ_CHUNK_CVS_RAM = 0x49,
488: A6XX_HLSQ_CHUNK_CPS_RAM = 0x4a,
489: A6XX_HLSQ_CHUNK_CVS_RAM_TAG = 0x4b,
490: A6XX_HLSQ_CHUNK_CPS_RAM_TAG = 0x4c,
491: A6XX_HLSQ_ICB_CVS_CB_BASE_TAG = 0x4d,
492: A6XX_HLSQ_ICB_CPS_CB_BASE_TAG = 0x4e,
493: A6XX_HLSQ_CVS_MISC_RAM = 0x50,
494: A6XX_HLSQ_CPS_MISC_RAM = 0x51,
495: A6XX_HLSQ_INST_RAM = 0x52,
496: A6XX_HLSQ_GFX_CVS_CONST_RAM = 0x53,
497: A6XX_HLSQ_GFX_CPS_CONST_RAM = 0x54,
498: A6XX_HLSQ_CVS_MISC_RAM_TAG = 0x55,
499: A6XX_HLSQ_CPS_MISC_RAM_TAG = 0x56,
500: A6XX_HLSQ_INST_RAM_TAG = 0x57,
501: A6XX_HLSQ_GFX_CVS_CONST_RAM_TAG = 0x58,
502: A6XX_HLSQ_GFX_CPS_CONST_RAM_TAG = 0x59,
503: A6XX_HLSQ_PWR_REST_RAM = 0x5a,
504: A6XX_HLSQ_PWR_REST_TAG = 0x5b,
505: A6XX_HLSQ_DATAPATH_META = 0x60,
506: A6XX_HLSQ_FRONTEND_META = 0x61,
507: A6XX_HLSQ_INDIRECT_META = 0x62,
508: A6XX_HLSQ_BACKEND_META = 0x63,
509: A6XX_SP_LB_6_DATA = 0x70,
510: A6XX_SP_LB_7_DATA = 0x71,
511: A6XX_HLSQ_INST_RAM_1 = 0x73,
512: };
513:
514: struct a6xx_shader_block {
515: unsigned int statetype;
516: unsigned int sz;
517: uint64_t offset;
518: };
519:
520: struct a6xx_shader_block_info {
521: struct a6xx_shader_block *block;
522: unsigned int bank;
523: uint64_t offset;
524: };
525:
526: static struct a6xx_shader_block a6xx_shader_blocks[] = {
527: {A6XX_TP0_TMO_DATA, 0x200},
528: {A6XX_TP0_SMO_DATA, 0x80,},
529: {A6XX_TP0_MIPMAP_BASE_DATA, 0x3C0},
530: {A6XX_TP1_TMO_DATA, 0x200},
531: {A6XX_TP1_SMO_DATA, 0x80,},
532: {A6XX_TP1_MIPMAP_BASE_DATA, 0x3C0},
533: {A6XX_SP_INST_DATA, 0x800},
534: {A6XX_SP_LB_0_DATA, 0x800},
535: {A6XX_SP_LB_1_DATA, 0x800},
536: {A6XX_SP_LB_2_DATA, 0x800},
537: {A6XX_SP_LB_3_DATA, 0x800},
538: {A6XX_SP_LB_4_DATA, 0x800},
539: {A6XX_SP_LB_5_DATA, 0x200},
540: {A6XX_SP_CB_BINDLESS_DATA, 0x800},
541: {A6XX_SP_CB_LEGACY_DATA, 0x280,},
542: {A6XX_SP_UAV_DATA, 0x80,},
543: {A6XX_SP_INST_TAG, 0x80,},
544: {A6XX_SP_CB_BINDLESS_TAG, 0x80,},
545: {A6XX_SP_TMO_UMO_TAG, 0x80,},
546: {A6XX_SP_SMO_TAG, 0x80},
547: {A6XX_SP_STATE_DATA, 0x3F},
548: {A6XX_HLSQ_CHUNK_CVS_RAM, 0x1C0},
549: {A6XX_HLSQ_CHUNK_CPS_RAM, 0x280},
550: {A6XX_HLSQ_CHUNK_CVS_RAM_TAG, 0x40,},
551: {A6XX_HLSQ_CHUNK_CPS_RAM_TAG, 0x40,},
552: {A6XX_HLSQ_ICB_CVS_CB_BASE_TAG, 0x4,},
553: {A6XX_HLSQ_ICB_CPS_CB_BASE_TAG, 0x4,},
554: {A6XX_HLSQ_CVS_MISC_RAM, 0x1C0},
555: {A6XX_HLSQ_CPS_MISC_RAM, 0x580},
556: {A6XX_HLSQ_INST_RAM, 0x800},
557: {A6XX_HLSQ_GFX_CVS_CONST_RAM, 0x800},
558: {A6XX_HLSQ_GFX_CPS_CONST_RAM, 0x800},
559: {A6XX_HLSQ_CVS_MISC_RAM_TAG, 0x8,},
560: {A6XX_HLSQ_CPS_MISC_RAM_TAG, 0x4,},
561: {A6XX_HLSQ_INST_RAM_TAG, 0x80,},
562: {A6XX_HLSQ_GFX_CVS_CONST_RAM_TAG, 0xC,},
563: {A6XX_HLSQ_GFX_CPS_CONST_RAM_TAG, 0x10},
564: {A6XX_HLSQ_PWR_REST_RAM, 0x28},
565: {A6XX_HLSQ_PWR_REST_TAG, 0x14},
566: {A6XX_HLSQ_DATAPATH_META, 0x40,},
567: {A6XX_HLSQ_FRONTEND_META, 0x40},
568: {A6XX_HLSQ_INDIRECT_META, 0x40,},
569: {A6XX_SP_LB_6_DATA, 0x200},
570: {A6XX_SP_LB_7_DATA, 0x200},
571: {A6XX_HLSQ_INST_RAM_1, 0x200},
572: };
573:
574: static struct kgsl_memdesc *a6xx_capturescript;
575: static struct kgsl_memdesc *a6xx_crashdump_registers;
576: static bool crash_dump_valid;
577: static u32 *a6xx_cd_reg_end;
578:
579: static struct reg_list {
580: const unsigned int *regs;
581: unsigned int count;
582: const struct sel_reg *sel;
583: uint64_t offset;
584: } a6xx_reg_list[] = {
585: { a6xx_registers, ARRAY_SIZE(a6xx_registers) / 2, NULL },
586: { a660_registers, ARRAY_SIZE(a660_registers) / 2, NULL },
587: { a6xx_rb_rac_registers, ARRAY_SIZE(a6xx_rb_rac_registers) / 2,
588: &_a6xx_rb_rac_aperture },
589: { a6xx_rb_rbp_registers, ARRAY_SIZE(a6xx_rb_rbp_registers) / 2,
590: &_a6xx_rb_rbp_aperture },
591: };
592:
593: #define REG_PAIR_COUNT(_a, _i) \
594: (((_a)[(2 * (_i)) + 1] - (_a)[2 * (_i)]) + 1)
595:
596: static size_t a6xx_legacy_snapshot_registers(struct kgsl_device *device,
597: u8 *buf, size_t remain, struct reg_list *regs)
598: {
599: struct kgsl_snapshot_registers snapshot_regs = {
600: .regs = regs->regs,
601: .count = regs->count,
602: };
603:
604: if (regs->sel)
605: kgsl_regwrite(device, regs->sel->host_reg, regs->sel->val);
606:
607: return kgsl_snapshot_dump_registers(device, buf, remain,
608: &snapshot_regs);
609: }
610:
611: static size_t a6xx_snapshot_registers(struct kgsl_device *device, u8 *buf,
612: size_t remain, void *priv)
613: {
614: struct kgsl_snapshot_regs *header = (struct kgsl_snapshot_regs *)buf;
615: struct reg_list *regs = (struct reg_list *)priv;
616: unsigned int *data = (unsigned int *)(buf + sizeof(*header));
617: unsigned int *src;
618: unsigned int j, k;
619: unsigned int count = 0;
620:
621: if (!crash_dump_valid)
622: return a6xx_legacy_snapshot_registers(device, buf, remain,
623: regs);
624:
625: if (remain < sizeof(*header)) {
626: SNAPSHOT_ERR_NOMEM(device, "REGISTERS");
627: return 0;
628: }
629:
630: src = a6xx_crashdump_registers->hostptr + regs->offset;
631: remain -= sizeof(*header);
632:
633: for (j = 0; j < regs->count; j++) {
634: unsigned int start = regs->regs[2 * j];
635: unsigned int end = regs->regs[(2 * j) + 1];
636:
637: if (remain < ((end - start) + 1) * 8) {
638: SNAPSHOT_ERR_NOMEM(device, "REGISTERS");
639: goto out;
640: }
641:
642: remain -= ((end - start) + 1) * 8;
643:
644: for (k = start; k <= end; k++, count++) {
645: *data++ = k;
646: *data++ = *src++;
647: }
648: }
649:
650: out:
651: header->count = count;
652:
653: /* Return the size of the section */
654: return (count * 8) + sizeof(*header);
655: }
656:
657: static size_t a6xx_snapshot_pre_crashdump_regs(struct kgsl_device *device,
658: u8 *buf, size_t remain, void *priv)
659: {
660: struct kgsl_snapshot_registers pre_cdregs = {
661: .regs = a6xx_pre_crashdumper_registers,
662: .count = ARRAY_SIZE(a6xx_pre_crashdumper_registers)/2,
663: };
664:
665: return kgsl_snapshot_dump_registers(device, buf, remain, &pre_cdregs);
666: }
667:
668: static size_t a6xx_legacy_snapshot_shader(struct kgsl_device *device,
669: u8 *buf, size_t remain, void *priv)
670: {
671: struct kgsl_snapshot_shader *header =
672: (struct kgsl_snapshot_shader *) buf;
673: struct a6xx_shader_block_info *info =
674: (struct a6xx_shader_block_info *) priv;
675: struct a6xx_shader_block *block = info->block;
676: unsigned int *data = (unsigned int *)(buf + sizeof(*header));
677: unsigned int read_sel, val;
678: int i;
679:
680: if (!device->snapshot_legacy)
681: return 0;
682:
683: if (remain < SHADER_SECTION_SZ(block->sz)) {
684: SNAPSHOT_ERR_NOMEM(device, "SHADER MEMORY");
685: return 0;
686: }
687:
688: /*
689: * If crashdumper times out, accessing some readback states from
690: * AHB path might fail. Hence, skip SP_INST_TAG and SP_INST_DATA
691: * state types during snapshot dump in legacy flow.
692: */
693: if (adreno_is_a660(ADRENO_DEVICE(device)) &&
694: (block->statetype == A6XX_SP_INST_TAG ||
695: block->statetype == A6XX_SP_INST_DATA))
696: return 0;
697:
698: header->type = block->statetype;
699: header->index = info->bank;
700: header->size = block->sz;
701:
702: read_sel = (block->statetype << A6XX_SHADER_STATETYPE_SHIFT) |
703: info->bank;
704: kgsl_regwrite(device, A6XX_HLSQ_DBG_READ_SEL, read_sel);
705:
706: /*
707: * An explicit barrier is needed so that reads do not happen before
708: * the register write.
709: */
710: mb();
711:
712: for (i = 0; i < block->sz; i++) {
713: kgsl_regread(device, (A6XX_HLSQ_DBG_AHB_READ_APERTURE + i),
714: &val);
715: *data++ = val;
716: }
717:
718: return SHADER_SECTION_SZ(block->sz);
719: }
720:
721: static size_t a6xx_snapshot_shader_memory(struct kgsl_device *device,
722: u8 *buf, size_t remain, void *priv)
723: {
724: struct kgsl_snapshot_shader *header =
725: (struct kgsl_snapshot_shader *) buf;
726: struct a6xx_shader_block_info *info =
727: (struct a6xx_shader_block_info *) priv;
728: struct a6xx_shader_block *block = info->block;
729: unsigned int *data = (unsigned int *) (buf + sizeof(*header));
730:
731: if (!crash_dump_valid)
732: return a6xx_legacy_snapshot_shader(device, buf, remain, priv);
733:
734: if (remain < SHADER_SECTION_SZ(block->sz)) {
735: SNAPSHOT_ERR_NOMEM(device, "SHADER MEMORY");
736: return 0;
737: }
738:
739: header->type = block->statetype;
740: header->index = info->bank;
741: header->size = block->sz;
742:
743: memcpy(data, a6xx_crashdump_registers->hostptr + info->offset,
744: block->sz * sizeof(unsigned int));
745:
746: return SHADER_SECTION_SZ(block->sz);
747: }
748:
749: static void a6xx_snapshot_shader(struct kgsl_device *device,
750: struct kgsl_snapshot *snapshot)
751: {
752: unsigned int i, j;
753: struct a6xx_shader_block_info info;
754:
755: for (i = 0; i < ARRAY_SIZE(a6xx_shader_blocks); i++) {
756: for (j = 0; j < A6XX_NUM_SHADER_BANKS; j++) {
757: info.block = &a6xx_shader_blocks[i];
758: info.bank = j;
759: info.offset = a6xx_shader_blocks[i].offset +
760: (j * a6xx_shader_blocks[i].sz);
761:
762: /* Shader working/shadow memory */
763: kgsl_snapshot_add_section(device,
764: KGSL_SNAPSHOT_SECTION_SHADER,
765: snapshot, a6xx_snapshot_shader_memory, &info);
766: }
767: }
768: }
769:
770: static void a650_snapshot_mempool(struct kgsl_device *device,
771: struct kgsl_snapshot *snapshot)
772: {
773: u32 val;
774:
775: /* set CP_CHICKEN_DBG[StabilizeMVC] to stabilize it while dumping */
776: kgsl_regread(device, A6XX_CP_CHICKEN_DBG, &val);
777: kgsl_regwrite(device, A6XX_CP_CHICKEN_DBG, val | BIT(2));
778:
779: kgsl_snapshot_indexed_registers(device, snapshot,
780: A6XX_CP_MEM_POOL_DBG_ADDR, A6XX_CP_MEM_POOL_DBG_DATA,
781: 0, 0x2100);
782:
783: kgsl_regwrite(device, A6XX_CP_CHICKEN_DBG, val);
784: }
785:
786: static void a6xx_snapshot_mempool(struct kgsl_device *device,
787: struct kgsl_snapshot *snapshot)
788: {
789: unsigned int pool_size;
790: u8 *buf = snapshot->ptr;
791:
792: /* Set the mempool size to 0 to stabilize it while dumping */
793: kgsl_regread(device, A6XX_CP_MEM_POOL_SIZE, &pool_size);
794: kgsl_regwrite(device, A6XX_CP_MEM_POOL_SIZE, 0);
795:
796: kgsl_snapshot_indexed_registers(device, snapshot,
797: A6XX_CP_MEM_POOL_DBG_ADDR, A6XX_CP_MEM_POOL_DBG_DATA,
798: 0, 0x2100);
799:
800: /*
801: * Data at offset 0x2000 in the mempool section is the mempool size.
802: * Since we set it to 0, patch in the original size so that the data
803: * is consistent.
804: */
805: if (buf < snapshot->ptr) {
806: unsigned int *data;
807:
808: /* Skip over the headers */
809: buf += sizeof(struct kgsl_snapshot_section_header) +
810: sizeof(struct kgsl_snapshot_indexed_regs);
811:
812: data = (unsigned int *)buf + 0x2000;
813: *data = pool_size;
814: }
815:
816: /* Restore the saved mempool size */
817: kgsl_regwrite(device, A6XX_CP_MEM_POOL_SIZE, pool_size);
818: }
819:
820: static inline unsigned int a6xx_read_dbgahb(struct kgsl_device *device,
821: unsigned int regbase, unsigned int reg)
822: {
823: unsigned int read_reg = A6XX_HLSQ_DBG_AHB_READ_APERTURE +
824: reg - regbase / 4;
825: unsigned int val;
826:
827: kgsl_regread(device, read_reg, &val);
828: return val;
829: }
830:
831: static size_t a6xx_legacy_snapshot_cluster_dbgahb(struct kgsl_device *device,
832: u8 *buf, size_t remain, void *priv)
833: {
834: struct kgsl_snapshot_mvc_regs *header =
835: (struct kgsl_snapshot_mvc_regs *)buf;
836: struct a6xx_cluster_dbgahb_regs_info *info =
837: (struct a6xx_cluster_dbgahb_regs_info *)priv;
838: struct a6xx_cluster_dbgahb_registers *cur_cluster = info->cluster;
839: unsigned int read_sel;
840: unsigned int data_size = 0;
841: unsigned int *data = (unsigned int *)(buf + sizeof(*header));
842: int i, j;
843:
844: if (!device->snapshot_legacy)
845: return 0;
846:
847: if (remain < sizeof(*header)) {
848: SNAPSHOT_ERR_NOMEM(device, "REGISTERS");
849: return 0;
850: }
851:
852: remain -= sizeof(*header);
853:
854: header->ctxt_id = info->ctxt_id;
855: header->cluster_id = cur_cluster->id;
856:
857: read_sel = ((cur_cluster->statetype + info->ctxt_id * 2) & 0xff) << 8;
858: kgsl_regwrite(device, A6XX_HLSQ_DBG_READ_SEL, read_sel);
859:
860: /*
861: * An explicit barrier is needed so that reads do not happen before
862: * the register write.
863: */
864: mb();
865:
866: for (i = 0; i < cur_cluster->num_sets; i++) {
867: unsigned int start = cur_cluster->regs[2 * i];
868: unsigned int end = cur_cluster->regs[2 * i + 1];
869:
870: if (remain < (end - start + 3) * 4) {
871: SNAPSHOT_ERR_NOMEM(device, "MVC REGISTERS");
872: goto out;
873: }
874:
875: remain -= (end - start + 3) * 4;
876: data_size += (end - start + 3) * 4;
877:
878: *data++ = start | (1 << 31);
879: *data++ = end;
880:
881: for (j = start; j <= end; j++) {
882: unsigned int val;
883:
884: val = a6xx_read_dbgahb(device, cur_cluster->regbase, j);
885: *data++ = val;
886:
887: }
888: }
889:
890: out:
891: return data_size + sizeof(*header);
892: }
893:
894: static size_t a6xx_snapshot_cluster_dbgahb(struct kgsl_device *device, u8 *buf,
895: size_t remain, void *priv)
896: {
897: struct kgsl_snapshot_mvc_regs *header =
898: (struct kgsl_snapshot_mvc_regs *)buf;
899: struct a6xx_cluster_dbgahb_regs_info *info =
900: (struct a6xx_cluster_dbgahb_regs_info *)priv;
901: struct a6xx_cluster_dbgahb_registers *cluster = info->cluster;
902: unsigned int data_size = 0;
903: unsigned int *data = (unsigned int *)(buf + sizeof(*header));
904: int i, j;
905: unsigned int *src;
906:
907:
908: if (!crash_dump_valid)
909: return a6xx_legacy_snapshot_cluster_dbgahb(device, buf, remain,
910: info);
911:
912: if (remain < sizeof(*header)) {
913: SNAPSHOT_ERR_NOMEM(device, "REGISTERS");
914: return 0;
915: }
916:
917: remain -= sizeof(*header);
918:
919: header->ctxt_id = info->ctxt_id;
920: header->cluster_id = cluster->id;
921:
922: src = a6xx_crashdump_registers->hostptr +
923: (header->ctxt_id ? cluster->offset1 : cluster->offset0);
924:
925: for (i = 0; i < cluster->num_sets; i++) {
926: unsigned int start;
927: unsigned int end;
928:
929: start = cluster->regs[2 * i];
930: end = cluster->regs[2 * i + 1];
931:
932: if (remain < (end - start + 3) * 4) {
933: SNAPSHOT_ERR_NOMEM(device, "MVC REGISTERS");
934: goto out;
935: }
936:
937: remain -= (end - start + 3) * 4;
938: data_size += (end - start + 3) * 4;
939:
940: *data++ = start | (1 << 31);
941: *data++ = end;
942: for (j = start; j <= end; j++)
943: *data++ = *src++;
944: }
945: out:
946: return data_size + sizeof(*header);
947: }
948:
949: static size_t a6xx_legacy_snapshot_non_ctx_dbgahb(struct kgsl_device *device,
950: u8 *buf, size_t remain, void *priv)
951: {
952: struct kgsl_snapshot_regs *header =
953: (struct kgsl_snapshot_regs *)buf;
954: struct a6xx_non_ctx_dbgahb_registers *regs =
955: (struct a6xx_non_ctx_dbgahb_registers *)priv;
956: unsigned int *data = (unsigned int *)(buf + sizeof(*header));
957: int count = 0;
958: unsigned int read_sel;
959: int i, j;
960:
961: if (!device->snapshot_legacy)
962: return 0;
963:
964: /* Figure out how many registers we are going to dump */
965: for (i = 0; i < regs->num_sets; i++) {
966: int start = regs->regs[i * 2];
967: int end = regs->regs[i * 2 + 1];
968:
969: count += (end - start + 1);
970: }
971:
972: if (remain < (count * 8) + sizeof(*header)) {
973: SNAPSHOT_ERR_NOMEM(device, "REGISTERS");
974: return 0;
975: }
976:
977: header->count = count;
978:
979: read_sel = (regs->statetype & 0xff) << 8;
980: kgsl_regwrite(device, A6XX_HLSQ_DBG_READ_SEL, read_sel);
981:
982: for (i = 0; i < regs->num_sets; i++) {
983: unsigned int start = regs->regs[2 * i];
984: unsigned int end = regs->regs[2 * i + 1];
985:
986: for (j = start; j <= end; j++) {
987: unsigned int val;
988:
989: val = a6xx_read_dbgahb(device, regs->regbase, j);
990: *data++ = j;
991: *data++ = val;
992:
993: }
994: }
995: return (count * 8) + sizeof(*header);
996: }
997:
998: static size_t a6xx_snapshot_non_ctx_dbgahb(struct kgsl_device *device, u8 *buf,
999: size_t remain, void *priv)
1000: {
1001: struct kgsl_snapshot_regs *header =
1002: (struct kgsl_snapshot_regs *)buf;
1003: struct a6xx_non_ctx_dbgahb_registers *regs =
1004: (struct a6xx_non_ctx_dbgahb_registers *)priv;
1005: unsigned int count = 0;
1006: unsigned int *data = (unsigned int *)(buf + sizeof(*header));
1007: unsigned int i, k;
1008: unsigned int *src;
1009:
1010: if (!crash_dump_valid)
1011: return a6xx_legacy_snapshot_non_ctx_dbgahb(device, buf, remain,
1012: regs);
1013:
1014: if (remain < sizeof(*header)) {
1015: SNAPSHOT_ERR_NOMEM(device, "REGISTERS");
1016: return 0;
1017: }
1018:
1019: remain -= sizeof(*header);
1020:
1021: src = a6xx_crashdump_registers->hostptr + regs->offset;
1022:
1023: for (i = 0; i < regs->num_sets; i++) {
1024: unsigned int start;
1025: unsigned int end;
1026:
1027: start = regs->regs[2 * i];
1028: end = regs->regs[(2 * i) + 1];
1029:
1030: if (remain < (end - start + 1) * 8) {
1031: SNAPSHOT_ERR_NOMEM(device, "REGISTERS");
1032: goto out;
1033: }
1034:
1035: remain -= ((end - start) + 1) * 8;
1036:
1037: for (k = start; k <= end; k++, count++) {
1038: *data++ = k;
1039: *data++ = *src++;
1040: }
1041: }
1042: out:
1043: header->count = count;
1044:
1045: /* Return the size of the section */
1046: return (count * 8) + sizeof(*header);
1047: }
1048:
1049: static void a6xx_snapshot_dbgahb_regs(struct kgsl_device *device,
1050: struct kgsl_snapshot *snapshot)
1051: {
1052: int i, j;
1053:
1054: for (i = 0; i < ARRAY_SIZE(a6xx_dbgahb_ctx_clusters); i++) {
1055: struct a6xx_cluster_dbgahb_registers *cluster =
1056: &a6xx_dbgahb_ctx_clusters[i];
1057: struct a6xx_cluster_dbgahb_regs_info info;
1058:
1059: info.cluster = cluster;
1060: for (j = 0; j < A6XX_NUM_CTXTS; j++) {
1061: info.ctxt_id = j;
1062:
1063: kgsl_snapshot_add_section(device,
1064: KGSL_SNAPSHOT_SECTION_MVC, snapshot,
1065: a6xx_snapshot_cluster_dbgahb, &info);
1066: }
1067: }
1068:
1069: for (i = 0; i < ARRAY_SIZE(a6xx_non_ctx_dbgahb); i++) {
1070: kgsl_snapshot_add_section(device,
1071: KGSL_SNAPSHOT_SECTION_REGS, snapshot,
1072: a6xx_snapshot_non_ctx_dbgahb, &a6xx_non_ctx_dbgahb[i]);
1073: }
1074: }
1075:
1076: static size_t a6xx_legacy_snapshot_mvc(struct kgsl_device *device, u8 *buf,
1077: size_t remain, void *priv)
1078: {
1079: struct kgsl_snapshot_mvc_regs *header =
1080: (struct kgsl_snapshot_mvc_regs *)buf;
1081: struct a6xx_cluster_regs_info *info =
1082: (struct a6xx_cluster_regs_info *)priv;
1083: struct a6xx_cluster_registers *cur_cluster = info->cluster;
1084: unsigned int *data = (unsigned int *)(buf + sizeof(*header));
1085: unsigned int ctxt = info->ctxt_id;
1086: unsigned int start, end, i, j, aperture_cntl = 0;
1087: unsigned int data_size = 0;
1088:
1089: if (remain < sizeof(*header)) {
1090: SNAPSHOT_ERR_NOMEM(device, "MVC REGISTERS");
1091: return 0;
1092: }
1093:
1094: remain -= sizeof(*header);
1095:
1096: header->ctxt_id = info->ctxt_id;
1097: header->cluster_id = cur_cluster->id;
1098:
1099: /*
1100: * Set the AHB control for the Host to read from the
1101: * cluster/context for this iteration.
1102: */
1103: aperture_cntl = ((cur_cluster->id & 0x7) << 8) | (ctxt << 4) | ctxt;
1104: kgsl_regwrite(device, A6XX_CP_APERTURE_CNTL_HOST, aperture_cntl);
1105:
1106: if (cur_cluster->sel)
1107: kgsl_regwrite(device, cur_cluster->sel->host_reg,
1108: cur_cluster->sel->val);
1109:
1110: for (i = 0; i < cur_cluster->num_sets; i++) {
1111: start = cur_cluster->regs[2 * i];
1112: end = cur_cluster->regs[2 * i + 1];
1113:
1114: if (remain < (end - start + 3) * 4) {
1115: SNAPSHOT_ERR_NOMEM(device, "MVC REGISTERS");
1116: goto out;
1117: }
1118:
1119: remain -= (end - start + 3) * 4;
1120: data_size += (end - start + 3) * 4;
1121:
1122: *data++ = start | (1 << 31);
1123: *data++ = end;
1124: for (j = start; j <= end; j++) {
1125: unsigned int val;
1126:
1127: kgsl_regread(device, j, &val);
1128: *data++ = val;
1129: }
1130: }
1131: out:
1132: return data_size + sizeof(*header);
1133: }
1134:
1135: static size_t a6xx_snapshot_mvc(struct kgsl_device *device, u8 *buf,
1136: size_t remain, void *priv)
1137: {
1138: struct kgsl_snapshot_mvc_regs *header =
1139: (struct kgsl_snapshot_mvc_regs *)buf;
1140: struct a6xx_cluster_regs_info *info =
1141: (struct a6xx_cluster_regs_info *)priv;
1142: struct a6xx_cluster_registers *cluster = info->cluster;
1143: unsigned int *data = (unsigned int *)(buf + sizeof(*header));
1144: unsigned int *src;
1145: int i, j;
1146: unsigned int start, end;
1147: size_t data_size = 0;
1148:
1149: if (!crash_dump_valid)
1150: return a6xx_legacy_snapshot_mvc(device, buf, remain, info);
1151:
1152: if (remain < sizeof(*header)) {
1153: SNAPSHOT_ERR_NOMEM(device, "MVC REGISTERS");
1154: return 0;
1155: }
1156:
1157: remain -= sizeof(*header);
1158:
1159: header->ctxt_id = info->ctxt_id;
1160: header->cluster_id = cluster->id;
1161:
1162: src = a6xx_crashdump_registers->hostptr +
1163: (header->ctxt_id ? cluster->offset1 : cluster->offset0);
1164:
1165: for (i = 0; i < cluster->num_sets; i++) {
1166: start = cluster->regs[2 * i];
1167: end = cluster->regs[2 * i + 1];
1168:
1169: if (remain < (end - start + 3) * 4) {
1170: SNAPSHOT_ERR_NOMEM(device, "MVC REGISTERS");
1171: goto out;
1172: }
1173:
1174: remain -= (end - start + 3) * 4;
1175: data_size += (end - start + 3) * 4;
1176:
1177: *data++ = start | (1 << 31);
1178: *data++ = end;
1179: for (j = start; j <= end; j++)
1180: *data++ = *src++;
1181: }
1182:
1183: out:
1184: return data_size + sizeof(*header);
1185:
1186: }
1187:
1188: static void a6xx_snapshot_mvc_regs(struct kgsl_device *device,
1189: struct kgsl_snapshot *snapshot)
1190: {
1191: int i, j;
1192: struct a6xx_cluster_regs_info info;
1193:
1194: for (i = 0; i < ARRAY_SIZE(a6xx_clusters); i++) {
1195: struct a6xx_cluster_registers *cluster = &a6xx_clusters[i];
1196:
1197: /* Skip registers that dont exists on targets other than A660 */
1198: if (!adreno_is_a660(ADRENO_DEVICE(device)) &&
1199: (cluster->regs == a660_fe_cluster))
1200: continue;
1201:
1202: info.cluster = cluster;
1203: for (j = 0; j < A6XX_NUM_CTXTS; j++) {
1204: info.ctxt_id = j;
1205:
1206: kgsl_snapshot_add_section(device,
1207: KGSL_SNAPSHOT_SECTION_MVC, snapshot,
1208: a6xx_snapshot_mvc, &info);
1209: }
1210: }
1211: }
1212:
1213: /* a6xx_dbgc_debug_bus_read() - Read data from trace bus */
1214: static void a6xx_dbgc_debug_bus_read(struct kgsl_device *device,
1215: unsigned int block_id, unsigned int index, unsigned int *val)
1216: {
1217: unsigned int reg;
1218:
1219: reg = (block_id << A6XX_DBGC_CFG_DBGBUS_SEL_PING_BLK_SEL_SHIFT) |
1220: (index << A6XX_DBGC_CFG_DBGBUS_SEL_PING_INDEX_SHIFT);
1221:
1222: kgsl_regwrite(device, A6XX_DBGC_CFG_DBGBUS_SEL_A, reg);
1223: kgsl_regwrite(device, A6XX_DBGC_CFG_DBGBUS_SEL_B, reg);
1224: kgsl_regwrite(device, A6XX_DBGC_CFG_DBGBUS_SEL_C, reg);
1225: kgsl_regwrite(device, A6XX_DBGC_CFG_DBGBUS_SEL_D, reg);
1226:
1227: /*
1228: * There needs to be a delay of 1 us to ensure enough time for correct
1229: * data is funneled into the trace buffer
1230: */
1231: udelay(1);
1232:
1233: kgsl_regread(device, A6XX_DBGC_CFG_DBGBUS_TRACE_BUF2, val);
1234: val++;
1235: kgsl_regread(device, A6XX_DBGC_CFG_DBGBUS_TRACE_BUF1, val);
1236: }
1237:
1238: /* a6xx_snapshot_dbgc_debugbus_block() - Capture debug data for a gpu block */
1239: static size_t a6xx_snapshot_dbgc_debugbus_block(struct kgsl_device *device,
1240: u8 *buf, size_t remain, void *priv)
1241: {
1242: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
1243: struct kgsl_snapshot_debugbus *header =
1244: (struct kgsl_snapshot_debugbus *)buf;
1245: struct adreno_debugbus_block *block = priv;
1246: int i;
1247: unsigned int *data = (unsigned int *)(buf + sizeof(*header));
1248: unsigned int dwords;
1249: unsigned int block_id;
1250: size_t size;
1251:
1252: dwords = block->dwords;
1253:
1254: /* For a6xx each debug bus data unit is 2 DWORDS */
1255: size = (dwords * sizeof(unsigned int) * 2) + sizeof(*header);
1256:
1257: if (remain < size) {
1258: SNAPSHOT_ERR_NOMEM(device, "DEBUGBUS");
1259: return 0;
1260: }
1261:
1262: header->id = block->block_id;
1263: if ((block->block_id == A6XX_DBGBUS_VBIF) && !adreno_is_a630(adreno_dev))
1264: header->id = A6XX_DBGBUS_GBIF_GX;
1265: header->count = dwords * 2;
1266:
1267: block_id = block->block_id;
1268: /* GMU_GX data is read using the GMU_CX block id on A630 */
1269: if ((adreno_is_a630(adreno_dev) || adreno_is_a615_family(adreno_dev)) &&
1270: (block_id == A6XX_DBGBUS_GMU_GX))
1271: block_id = A6XX_DBGBUS_GMU_CX;
1272:
1273: for (i = 0; i < dwords; i++)
1274: a6xx_dbgc_debug_bus_read(device, block_id, i, &data[i*2]);
1275:
1276: return size;
1277: }
1278:
1279: /* a6xx_snapshot_vbif_debugbus_block() - Capture debug data for VBIF block */
1280: static size_t a6xx_snapshot_vbif_debugbus_block(struct kgsl_device *device,
1281: u8 *buf, size_t remain, void *priv)
1282: {
1283: struct kgsl_snapshot_debugbus *header =
1284: (struct kgsl_snapshot_debugbus *)buf;
1285: struct adreno_debugbus_block *block = priv;
1286: int i, j;
1287: /*
1288: * Total number of VBIF data words considering 3 sections:
1289: * 2 arbiter blocks of 16 words
1290: * 5 AXI XIN blocks of 18 dwords each
1291: * 4 core clock side XIN blocks of 12 dwords each
1292: */
1293: unsigned int dwords = (16 * A6XX_NUM_AXI_ARB_BLOCKS) +
1294: (18 * A6XX_NUM_XIN_AXI_BLOCKS) +
1295: (12 * A6XX_NUM_XIN_CORE_BLOCKS);
1296: unsigned int *data = (unsigned int *)(buf + sizeof(*header));
1297: size_t size;
1298: unsigned int reg_clk;
1299:
1300: size = (dwords * sizeof(unsigned int)) + sizeof(*header);
1301:
1302: if (remain < size) {
1303: SNAPSHOT_ERR_NOMEM(device, "DEBUGBUS");
1304: return 0;
1305: }
1306: header->id = block->block_id;
1307: header->count = dwords;
1308:
1309: kgsl_regread(device, A6XX_VBIF_CLKON, ®_clk);
1310: kgsl_regwrite(device, A6XX_VBIF_CLKON, reg_clk |
1311: (A6XX_VBIF_CLKON_FORCE_ON_TESTBUS_MASK <<
1312: A6XX_VBIF_CLKON_FORCE_ON_TESTBUS_SHIFT));
1313: kgsl_regwrite(device, A6XX_VBIF_TEST_BUS1_CTRL0, 0);
1314: kgsl_regwrite(device, A6XX_VBIF_TEST_BUS_OUT_CTRL,
1315: (A6XX_VBIF_TEST_BUS_OUT_CTRL_EN_MASK <<
1316: A6XX_VBIF_TEST_BUS_OUT_CTRL_EN_SHIFT));
1317:
1318: for (i = 0; i < A6XX_NUM_AXI_ARB_BLOCKS; i++) {
1319: kgsl_regwrite(device, A6XX_VBIF_TEST_BUS2_CTRL0,
1320: (1 << (i + 16)));
1321: for (j = 0; j < 16; j++) {
1322: kgsl_regwrite(device, A6XX_VBIF_TEST_BUS2_CTRL1,
1323: ((j & A6XX_VBIF_TEST_BUS2_CTRL1_DATA_SEL_MASK)
1324: << A6XX_VBIF_TEST_BUS2_CTRL1_DATA_SEL_SHIFT));
1325: kgsl_regread(device, A6XX_VBIF_TEST_BUS_OUT,
1326: data);
1327: data++;
1328: }
1329: }
1330:
1331: /* XIN blocks AXI side */
1332: for (i = 0; i < A6XX_NUM_XIN_AXI_BLOCKS; i++) {
1333: kgsl_regwrite(device, A6XX_VBIF_TEST_BUS2_CTRL0, 1 << i);
1334: for (j = 0; j < 18; j++) {
1335: kgsl_regwrite(device, A6XX_VBIF_TEST_BUS2_CTRL1,
1336: ((j & A6XX_VBIF_TEST_BUS2_CTRL1_DATA_SEL_MASK)
1337: << A6XX_VBIF_TEST_BUS2_CTRL1_DATA_SEL_SHIFT));
1338: kgsl_regread(device, A6XX_VBIF_TEST_BUS_OUT,
1339: data);
1340: data++;
1341: }
1342: }
1343: kgsl_regwrite(device, A6XX_VBIF_TEST_BUS2_CTRL0, 0);
1344:
1345: /* XIN blocks core clock side */
1346: for (i = 0; i < A6XX_NUM_XIN_CORE_BLOCKS; i++) {
1347: kgsl_regwrite(device, A6XX_VBIF_TEST_BUS1_CTRL0, 1 << i);
1348: for (j = 0; j < 12; j++) {
1349: kgsl_regwrite(device, A6XX_VBIF_TEST_BUS1_CTRL1,
1350: ((j & A6XX_VBIF_TEST_BUS1_CTRL1_DATA_SEL_MASK)
1351: << A6XX_VBIF_TEST_BUS1_CTRL1_DATA_SEL_SHIFT));
1352: kgsl_regread(device, A6XX_VBIF_TEST_BUS_OUT,
1353: data);
1354: data++;
1355: }
1356: }
1357: /* restore the clock of VBIF */
1358: kgsl_regwrite(device, A6XX_VBIF_CLKON, reg_clk);
1359: return size;
1360: }
1361:
1362: /* a6xx_cx_dbgc_debug_bus_read() - Read data from trace bus */
1363: static void a6xx_cx_debug_bus_read(struct kgsl_device *device,
1364: unsigned int block_id, unsigned int index, unsigned int *val)
1365: {
1366: unsigned int reg;
1367:
1368: reg = (block_id << A6XX_CX_DBGC_CFG_DBGBUS_SEL_PING_BLK_SEL_SHIFT) |
1369: (index << A6XX_CX_DBGC_CFG_DBGBUS_SEL_PING_INDEX_SHIFT);
1370:
1371: kgsl_regwrite(device, A6XX_CX_DBGC_CFG_DBGBUS_SEL_A, reg);
1372: kgsl_regwrite(device, A6XX_CX_DBGC_CFG_DBGBUS_SEL_B, reg);
1373: kgsl_regwrite(device, A6XX_CX_DBGC_CFG_DBGBUS_SEL_C, reg);
1374: kgsl_regwrite(device, A6XX_CX_DBGC_CFG_DBGBUS_SEL_D, reg);
1375:
1376: /*
1377: * There needs to be a delay of 1 us to ensure enough time for correct
1378: * data is funneled into the trace buffer
1379: */
1380: udelay(1);
1381:
1382: kgsl_regread(device, A6XX_CX_DBGC_CFG_DBGBUS_TRACE_BUF2, val);
1383: val++;
1384: kgsl_regread(device, A6XX_CX_DBGC_CFG_DBGBUS_TRACE_BUF1, val);
1385: }
1386:
1387: /*
1388: * a6xx_snapshot_cx_dbgc_debugbus_block() - Capture debug data for a gpu
1389: * block from the CX DBGC block
1390: */
1391: static size_t a6xx_snapshot_cx_dbgc_debugbus_block(struct kgsl_device *device,
1392: u8 *buf, size_t remain, void *priv)
1393: {
1394: struct kgsl_snapshot_debugbus *header =
1395: (struct kgsl_snapshot_debugbus *)buf;
1396: struct adreno_debugbus_block *block = priv;
1397: int i;
1398: unsigned int *data = (unsigned int *)(buf + sizeof(*header));
1399: unsigned int dwords;
1400: size_t size;
1401:
1402: dwords = block->dwords;
1403:
1404: /* For a6xx each debug bus data unit is 2 DWRODS */
1405: size = (dwords * sizeof(unsigned int) * 2) + sizeof(*header);
1406:
1407: if (remain < size) {
1408: SNAPSHOT_ERR_NOMEM(device, "DEBUGBUS");
1409: return 0;
1410: }
1411:
1412: header->id = block->block_id;
1413: header->count = dwords * 2;
1414:
1415: for (i = 0; i < dwords; i++)
1416: a6xx_cx_debug_bus_read(device, block->block_id, i,
1417: &data[i*2]);
1418:
1419: return size;
1420: }
1421:
1422: /* a6xx_snapshot_debugbus() - Capture debug bus data */
1423: static void a6xx_snapshot_debugbus(struct adreno_device *adreno_dev,
1424: struct kgsl_snapshot *snapshot)
1425: {
1426: int i;
1427: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1428:
1429: if (device->debug_bus_bin)
1430: return;
1431:
1432: kgsl_regwrite(device, A6XX_DBGC_CFG_DBGBUS_CNTLT,
1433: (0xf << A6XX_DBGC_CFG_DBGBUS_CNTLT_SEGT_SHIFT) |
1434: (0x0 << A6XX_DBGC_CFG_DBGBUS_CNTLT_GRANU_SHIFT) |
1435: (0x0 << A6XX_DBGC_CFG_DBGBUS_CNTLT_TRACEEN_SHIFT));
1436:
1437: kgsl_regwrite(device, A6XX_DBGC_CFG_DBGBUS_CNTLM,
1438: 0xf << A6XX_DBGC_CFG_DBGBUS_CTLTM_ENABLE_SHIFT);
1439:
1440: kgsl_regwrite(device, A6XX_DBGC_CFG_DBGBUS_IVTL_0, 0);
1441: kgsl_regwrite(device, A6XX_DBGC_CFG_DBGBUS_IVTL_1, 0);
1442: kgsl_regwrite(device, A6XX_DBGC_CFG_DBGBUS_IVTL_2, 0);
1443: kgsl_regwrite(device, A6XX_DBGC_CFG_DBGBUS_IVTL_3, 0);
1444:
1445: kgsl_regwrite(device, A6XX_DBGC_CFG_DBGBUS_BYTEL_0,
1446: (0 << A6XX_DBGC_CFG_DBGBUS_BYTEL0_SHIFT) |
1447: (1 << A6XX_DBGC_CFG_DBGBUS_BYTEL1_SHIFT) |
1448: (2 << A6XX_DBGC_CFG_DBGBUS_BYTEL2_SHIFT) |
1449: (3 << A6XX_DBGC_CFG_DBGBUS_BYTEL3_SHIFT) |
1450: (4 << A6XX_DBGC_CFG_DBGBUS_BYTEL4_SHIFT) |
1451: (5 << A6XX_DBGC_CFG_DBGBUS_BYTEL5_SHIFT) |
1452: (6 << A6XX_DBGC_CFG_DBGBUS_BYTEL6_SHIFT) |
1453: (7 << A6XX_DBGC_CFG_DBGBUS_BYTEL7_SHIFT));
1454: kgsl_regwrite(device, A6XX_DBGC_CFG_DBGBUS_BYTEL_1,
1455: (8 << A6XX_DBGC_CFG_DBGBUS_BYTEL8_SHIFT) |
1456: (9 << A6XX_DBGC_CFG_DBGBUS_BYTEL9_SHIFT) |
1457: (10 << A6XX_DBGC_CFG_DBGBUS_BYTEL10_SHIFT) |
1458: (11 << A6XX_DBGC_CFG_DBGBUS_BYTEL11_SHIFT) |
1459: (12 << A6XX_DBGC_CFG_DBGBUS_BYTEL12_SHIFT) |
1460: (13 << A6XX_DBGC_CFG_DBGBUS_BYTEL13_SHIFT) |
1461: (14 << A6XX_DBGC_CFG_DBGBUS_BYTEL14_SHIFT) |
1462: (15 << A6XX_DBGC_CFG_DBGBUS_BYTEL15_SHIFT));
1463:
1464: kgsl_regwrite(device, A6XX_DBGC_CFG_DBGBUS_MASKL_0, 0);
1465: kgsl_regwrite(device, A6XX_DBGC_CFG_DBGBUS_MASKL_1, 0);
1466: kgsl_regwrite(device, A6XX_DBGC_CFG_DBGBUS_MASKL_2, 0);
1467: kgsl_regwrite(device, A6XX_DBGC_CFG_DBGBUS_MASKL_3, 0);
1468:
1469: kgsl_regwrite(device, A6XX_CX_DBGC_CFG_DBGBUS_CNTLT,
1470: (0xf << A6XX_DBGC_CFG_DBGBUS_CNTLT_SEGT_SHIFT) |
1471: (0x0 << A6XX_DBGC_CFG_DBGBUS_CNTLT_GRANU_SHIFT) |
1472: (0x0 << A6XX_DBGC_CFG_DBGBUS_CNTLT_TRACEEN_SHIFT));
1473:
1474: kgsl_regwrite(device, A6XX_CX_DBGC_CFG_DBGBUS_CNTLM,
1475: 0xf << A6XX_CX_DBGC_CFG_DBGBUS_CNTLM_ENABLE_SHIFT);
1476:
1477: kgsl_regwrite(device, A6XX_CX_DBGC_CFG_DBGBUS_IVTL_0, 0);
1478: kgsl_regwrite(device, A6XX_CX_DBGC_CFG_DBGBUS_IVTL_1, 0);
1479: kgsl_regwrite(device, A6XX_CX_DBGC_CFG_DBGBUS_IVTL_2, 0);
1480: kgsl_regwrite(device, A6XX_CX_DBGC_CFG_DBGBUS_IVTL_3, 0);
1481:
1482: kgsl_regwrite(device, A6XX_CX_DBGC_CFG_DBGBUS_BYTEL_0,
1483: (0 << A6XX_CX_DBGC_CFG_DBGBUS_BYTEL0_SHIFT) |
1484: (1 << A6XX_CX_DBGC_CFG_DBGBUS_BYTEL1_SHIFT) |
1485: (2 << A6XX_CX_DBGC_CFG_DBGBUS_BYTEL2_SHIFT) |
1486: (3 << A6XX_CX_DBGC_CFG_DBGBUS_BYTEL3_SHIFT) |
1487: (4 << A6XX_CX_DBGC_CFG_DBGBUS_BYTEL4_SHIFT) |
1488: (5 << A6XX_CX_DBGC_CFG_DBGBUS_BYTEL5_SHIFT) |
1489: (6 << A6XX_CX_DBGC_CFG_DBGBUS_BYTEL6_SHIFT) |
1490: (7 << A6XX_CX_DBGC_CFG_DBGBUS_BYTEL7_SHIFT));
1491: kgsl_regwrite(device, A6XX_CX_DBGC_CFG_DBGBUS_BYTEL_1,
1492: (8 << A6XX_CX_DBGC_CFG_DBGBUS_BYTEL8_SHIFT) |
1493: (9 << A6XX_CX_DBGC_CFG_DBGBUS_BYTEL9_SHIFT) |
1494: (10 << A6XX_CX_DBGC_CFG_DBGBUS_BYTEL10_SHIFT) |
1495: (11 << A6XX_CX_DBGC_CFG_DBGBUS_BYTEL11_SHIFT) |
1496: (12 << A6XX_CX_DBGC_CFG_DBGBUS_BYTEL12_SHIFT) |
1497: (13 << A6XX_CX_DBGC_CFG_DBGBUS_BYTEL13_SHIFT) |
1498: (14 << A6XX_CX_DBGC_CFG_DBGBUS_BYTEL14_SHIFT) |
1499: (15 << A6XX_CX_DBGC_CFG_DBGBUS_BYTEL15_SHIFT));
1500:
1501: kgsl_regwrite(device, A6XX_CX_DBGC_CFG_DBGBUS_MASKL_0, 0);
1502: kgsl_regwrite(device, A6XX_CX_DBGC_CFG_DBGBUS_MASKL_1, 0);
1503: kgsl_regwrite(device, A6XX_CX_DBGC_CFG_DBGBUS_MASKL_2, 0);
1504: kgsl_regwrite(device, A6XX_CX_DBGC_CFG_DBGBUS_MASKL_3, 0);
1505:
1506: for (i = 0; i < ARRAY_SIZE(a6xx_dbgc_debugbus_blocks); i++) {
1507: kgsl_snapshot_add_section(device,
1508: KGSL_SNAPSHOT_SECTION_DEBUGBUS,
1509: snapshot, a6xx_snapshot_dbgc_debugbus_block,
1510: (void *) &a6xx_dbgc_debugbus_blocks[i]);
1511: }
1512:
1513: if (adreno_is_a650_family(adreno_dev)) {
1514: for (i = 0; i < ARRAY_SIZE(a650_dbgc_debugbus_blocks); i++) {
1515: kgsl_snapshot_add_section(device,
1516: KGSL_SNAPSHOT_SECTION_DEBUGBUS,
1517: snapshot, a6xx_snapshot_dbgc_debugbus_block,
1518: (void *) &a650_dbgc_debugbus_blocks[i]);
1519: }
1520: }
1521:
1522: /*
1523: * GBIF has same debugbus as of other GPU blocks hence fall back to
1524: * default path if GPU uses GBIF.
1525: * GBIF uses exactly same ID as of VBIF so use it as it is.
1526: */
1527: if (!adreno_is_a630(adreno_dev))
1528: kgsl_snapshot_add_section(device,
1529: KGSL_SNAPSHOT_SECTION_DEBUGBUS,
1530: snapshot, a6xx_snapshot_dbgc_debugbus_block,
1531: (void *) &a6xx_vbif_debugbus_blocks);
1532: else
1533: kgsl_snapshot_add_section(device,
1534: KGSL_SNAPSHOT_SECTION_DEBUGBUS,
1535: snapshot, a6xx_snapshot_vbif_debugbus_block,
1536: (void *) &a6xx_vbif_debugbus_blocks);
1537:
1538: /* Dump the CX debugbus data if the block exists */
1539: if (kgsl_regmap_valid_offset(&device->regmap, A6XX_CX_DBGC_CFG_DBGBUS_SEL_A)) {
1540: for (i = 0; i < ARRAY_SIZE(a6xx_cx_dbgc_debugbus_blocks); i++) {
1541: kgsl_snapshot_add_section(device,
1542: KGSL_SNAPSHOT_SECTION_DEBUGBUS,
1543: snapshot, a6xx_snapshot_cx_dbgc_debugbus_block,
1544: (void *) &a6xx_cx_dbgc_debugbus_blocks[i]);
1545: }
1546: /*
1547: * Get debugbus for GBIF CX part if GPU has GBIF block
1548: * GBIF uses exactly same ID as of VBIF so use
1549: * it as it is.
1550: */
1551: if (!adreno_is_a630(adreno_dev))
1552: kgsl_snapshot_add_section(device,
1553: KGSL_SNAPSHOT_SECTION_DEBUGBUS,
1554: snapshot,
1555: a6xx_snapshot_cx_dbgc_debugbus_block,
1556: (void *) &a6xx_vbif_debugbus_blocks);
1557: }
1558: }
1559:
1560: static void _a6xx_do_crashdump(struct kgsl_device *device)
1561: {
1562: u32 val = 0;
1563: ktime_t timeout;
1564:
1565: crash_dump_valid = false;
1566:
1567: if (!device->snapshot_crashdumper)
1568: return;
1569:
1570: if (IS_ERR_OR_NULL(a6xx_capturescript) ||
1571: IS_ERR_OR_NULL(a6xx_crashdump_registers))
1572: return;
1573:
1574: /* IF the SMMU is stalled we cannot do a crash dump */
1575: if (adreno_smmu_is_stalled(ADRENO_DEVICE(device)))
1576: return;
1577:
1578: /* Turn on APRIV for legacy targets so we can access the buffers */
1579: if (!ADRENO_FEATURE(ADRENO_DEVICE(device), ADRENO_APRIV))
1580: kgsl_regwrite(device, A6XX_CP_MISC_CNTL, 1);
1581:
1582: kgsl_regwrite(device, A6XX_CP_CRASH_SCRIPT_BASE_LO,
1583: lower_32_bits(a6xx_capturescript->gpuaddr));
1584: kgsl_regwrite(device, A6XX_CP_CRASH_SCRIPT_BASE_HI,
1585: upper_32_bits(a6xx_capturescript->gpuaddr));
1586: kgsl_regwrite(device, A6XX_CP_CRASH_DUMP_CNTL, 1);
1587:
1588: timeout = ktime_add_ms(ktime_get(), CP_CRASH_DUMPER_TIMEOUT);
1589:
1590: if (!device->snapshot_atomic)
1591: might_sleep();
1592:
1593: for (;;) {
1594: /* make sure we're reading the latest value */
1595: rmb();
1596: if ((*a6xx_cd_reg_end) != 0xaaaaaaaa)
1597: break;
1598:
1599: if (ktime_compare(ktime_get(), timeout) > 0)
1600: break;
1601:
1602: /* Wait 1msec to avoid unnecessary looping */
1603: if (!device->snapshot_atomic)
1604: usleep_range(100, 1000);
1605: }
1606:
1607: kgsl_regread(device, A6XX_CP_CRASH_DUMP_STATUS, &val);
1608:
1609: if (!ADRENO_FEATURE(ADRENO_DEVICE(device), ADRENO_APRIV))
1610: kgsl_regwrite(device, A6XX_CP_MISC_CNTL, 0);
1611:
1612: if (!(val & 0x2)) {
1613: dev_err(device->dev, "Crash dump timed out: 0x%X\n", val);
1614: return;
1615: }
1616:
1617: crash_dump_valid = true;
1618: }
1619:
1620: static size_t a6xx_snapshot_cp_roq(struct kgsl_device *device, u8 *buf,
1621: size_t remain, void *priv)
1622: {
1623: struct kgsl_snapshot_debug *header = (struct kgsl_snapshot_debug *) buf;
1624: u32 size, *data = (u32 *) (buf + sizeof(*header));
1625: int i;
1626:
1627: kgsl_regread(device, A6XX_CP_ROQ_THRESHOLDS_2, &size);
1628: size >>= 14;
1629:
1630: if (remain < DEBUG_SECTION_SZ(size)) {
1631: SNAPSHOT_ERR_NOMEM(device, "CP ROQ DEBUG");
1632: return 0;
1633: }
1634:
1635: header->type = SNAPSHOT_DEBUG_CP_ROQ;
1636: header->size = size;
1637:
1638: kgsl_regwrite(device, A6XX_CP_ROQ_DBG_ADDR, 0x0);
1639: for (i = 0; i < size; i++)
1640: kgsl_regread(device, A6XX_CP_ROQ_DBG_DATA, &data[i]);
1641:
1642: return DEBUG_SECTION_SZ(size);
1643: }
1644:
1645: static inline bool a6xx_has_gbif_reinit(struct adreno_device *adreno_dev)
1646: {
1647: /*
1648: * Some targets in a6xx do not have reinit support in hardware.
1649: * This check is only for hardware capability and not for finding
1650: * whether gbif reinit sequence in software is enabled or not.
1651: */
1652: return !(adreno_is_a630(adreno_dev) || adreno_is_a615_family(adreno_dev) ||
1653: adreno_is_a640_family(adreno_dev));
1654: }
1655:
1656: /*
1657: * a6xx_snapshot() - A6XX GPU snapshot function
1658: * @adreno_dev: Device being snapshotted
1659: * @snapshot: Pointer to the snapshot instance
1660: *
1661: * This is where all of the A6XX specific bits and pieces are grabbed
1662: * into the snapshot memory
1663: */
1664: void a6xx_snapshot(struct adreno_device *adreno_dev,
1665: struct kgsl_snapshot *snapshot)
1666: {
1667: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1668: bool sptprac_on;
1669: unsigned int i;
1670: u32 hi, lo;
1671:
1672: /*
1673: * Dump debugbus data here to capture it for both
1674: * GMU and GPU snapshot. Debugbus data can be accessed
1675: * even if the gx headswitch or sptprac is off. If gx
1676: * headswitch is off, data for gx blocks will show as
1677: * 0x5c00bd00.
1678: */
1679: a6xx_snapshot_debugbus(adreno_dev, snapshot);
1680:
1681: /* Isense registers are on cx */
1682: if (adreno_dev->isense_reg_mapped) {
1683: struct kgsl_snapshot_registers r;
1684:
1685: r.regs = a650_isense_registers;
1686: r.count = ARRAY_SIZE(a650_isense_registers) / 2;
1687:
1688: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS,
1689: snapshot, kgsl_snapshot_dump_registers, &r);
1690: }
1691:
1692: if (!gmu_core_isenabled(device)) {
1693: if (adreno_is_a619_holi(adreno_dev))
1694: adreno_snapshot_registers(device, snapshot,
1695: a6xx_holi_gmu_wrapper_registers,
1696: ARRAY_SIZE(a6xx_holi_gmu_wrapper_registers) / 2);
1697: else
1698: adreno_snapshot_registers(device, snapshot,
1699: a6xx_gmu_wrapper_registers,
1700: ARRAY_SIZE(a6xx_gmu_wrapper_registers) / 2);
1701: }
1702:
1703: sptprac_on = a6xx_gmu_sptprac_is_on(adreno_dev);
1704:
1705: if (!adreno_gx_is_on(adreno_dev))
1706: return;
1707:
1708: kgsl_regread(device, A6XX_CP_IB1_BASE, &lo);
1709: kgsl_regread(device, A6XX_CP_IB1_BASE_HI, &hi);
1710:
1711: snapshot->ib1base = (((u64) hi) << 32) | lo;
1712:
1713: kgsl_regread(device, A6XX_CP_IB2_BASE, &lo);
1714: kgsl_regread(device, A6XX_CP_IB2_BASE_HI, &hi);
1715:
1716: snapshot->ib2base = (((u64) hi) << 32) | lo;
1717:
1718: kgsl_regread(device, A6XX_CP_IB1_REM_SIZE, &snapshot->ib1size);
1719: kgsl_regread(device, A6XX_CP_IB2_REM_SIZE, &snapshot->ib2size);
1720:
1721: /* Assert the isStatic bit before triggering snapshot */
1722: if (adreno_is_a660(adreno_dev))
1723: kgsl_regwrite(device, A6XX_RBBM_SNAPSHOT_STATUS, 0x1);
1724:
1725: /* Dump the registers which get affected by crash dumper trigger */
1726: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS,
1727: snapshot, a6xx_snapshot_pre_crashdump_regs, NULL);
1728:
1729: /* Dump vbif registers as well which get affected by crash dumper */
1730: if (adreno_is_a630(adreno_dev))
1731: SNAPSHOT_REGISTERS(device, snapshot, a6xx_vbif_registers);
1732: else if (a6xx_has_gbif_reinit(adreno_dev))
1733: adreno_snapshot_registers(device, snapshot,
1734: a6xx_gbif_reinit_registers,
1735: ARRAY_SIZE(a6xx_gbif_reinit_registers) / 2);
1736: else
1737: adreno_snapshot_registers(device, snapshot,
1738: a6xx_gbif_registers,
1739: ARRAY_SIZE(a6xx_gbif_registers) / 2);
1740:
1741: /* Try to run the crash dumper */
1742: if (sptprac_on)
1743: _a6xx_do_crashdump(device);
1744:
1745: for (i = 0; i < ARRAY_SIZE(a6xx_reg_list); i++) {
1746: /* Skip registers that dont exists on targets other than A660 */
1747: if (!adreno_is_a660(adreno_dev) &&
1748: (a6xx_reg_list[i].regs == a660_registers))
1749: continue;
1750:
1751: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS,
1752: snapshot, a6xx_snapshot_registers, &a6xx_reg_list[i]);
1753: }
1754:
1755: /* CP_SQE indexed registers */
1756: kgsl_snapshot_indexed_registers(device, snapshot,
1757: A6XX_CP_SQE_STAT_ADDR, A6XX_CP_SQE_STAT_DATA, 0, 0x33);
1758:
1759: /* CP_DRAW_STATE */
1760: kgsl_snapshot_indexed_registers(device, snapshot,
1761: A6XX_CP_DRAW_STATE_ADDR, A6XX_CP_DRAW_STATE_DATA,
1762: 0, 0x100);
1763:
1764: /* SQE_UCODE Cache */
1765: kgsl_snapshot_indexed_registers(device, snapshot,
1766: A6XX_CP_SQE_UCODE_DBG_ADDR, A6XX_CP_SQE_UCODE_DBG_DATA,
1767: 0, 0x8000);
1768:
1769: /* CP LPAC indexed registers */
1770: if (adreno_is_a660(adreno_dev)) {
1771: u32 roq_size;
1772:
1773: kgsl_snapshot_indexed_registers(device, snapshot,
1774: A6XX_CP_SQE_AC_STAT_ADDR, A6XX_CP_SQE_AC_STAT_DATA,
1775: 0, 0x33);
1776: kgsl_snapshot_indexed_registers(device, snapshot,
1777: A6XX_CP_LPAC_DRAW_STATE_ADDR,
1778: A6XX_CP_LPAC_DRAW_STATE_DATA, 0, 0x100);
1779: kgsl_snapshot_indexed_registers(device, snapshot,
1780: A6XX_CP_SQE_AC_UCODE_DBG_ADDR,
1781: A6XX_CP_SQE_AC_UCODE_DBG_DATA, 0, 0x8000);
1782:
1783: kgsl_regread(device, A6XX_CP_LPAC_ROQ_THRESHOLDS_2, &roq_size);
1784: roq_size = roq_size >> 14;
1785: kgsl_snapshot_indexed_registers(device, snapshot,
1786: A6XX_CP_LPAC_ROQ_DBG_ADDR,
1787: A6XX_CP_LPAC_ROQ_DBG_DATA, 0, roq_size);
1788:
1789: kgsl_snapshot_indexed_registers(device, snapshot,
1790: A6XX_CP_LPAC_FIFO_DBG_ADDR, A6XX_CP_LPAC_FIFO_DBG_DATA,
1791: 0, 0x40);
1792: }
1793: /*
1794: * CP ROQ dump units is 4dwords. The number of units is stored
1795: * in CP_ROQ_THRESHOLDS_2[31:16]. Read the value and convert to
1796: * dword units.
1797: */
1798: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_DEBUG,
1799: snapshot, a6xx_snapshot_cp_roq, NULL);
1800:
1801: /* Mempool debug data */
1802: if (adreno_is_a650_family(adreno_dev))
1803: a650_snapshot_mempool(device, snapshot);
1804: else
1805: a6xx_snapshot_mempool(device, snapshot);
1806:
1807: if (sptprac_on) {
1808: /* MVC register section */
1809: a6xx_snapshot_mvc_regs(device, snapshot);
1810:
1811: /* registers dumped through DBG AHB */
1812: a6xx_snapshot_dbgahb_regs(device, snapshot);
1813:
1814: /* Shader memory */
1815: a6xx_snapshot_shader(device, snapshot);
1816:
1817: if (!adreno_smmu_is_stalled(adreno_dev))
1818: memset(a6xx_crashdump_registers->hostptr, 0xaa,
1819: a6xx_crashdump_registers->size);
1820: }
1821:
1822: if (adreno_is_a660(adreno_dev)) {
1823: u32 val;
1824:
1825: kgsl_regread(device, A6XX_RBBM_SNAPSHOT_STATUS, &val);
1826:
1827: if (!val)
1828: dev_err(device->dev,
1829: "Interface signals may have changed during snapshot\n");
1830:
1831: kgsl_regwrite(device, A6XX_RBBM_SNAPSHOT_STATUS, 0x0);
1832: }
1833:
1834: /* Preemption record */
1835: adreno_snapshot_preemption_record(device, snapshot);
1836: }
1837:
1838: static int _a6xx_crashdump_init_mvc(struct adreno_device *adreno_dev,
1839: uint64_t *ptr, uint64_t *offset)
1840: {
1841: int qwords = 0;
1842: unsigned int i, j, k;
1843: unsigned int count;
1844:
1845: for (i = 0; i < ARRAY_SIZE(a6xx_clusters); i++) {
1846: struct a6xx_cluster_registers *cluster = &a6xx_clusters[i];
1847:
1848: /* Skip registers that dont exists on targets other than A660 */
1849: if (!adreno_is_a660(adreno_dev) &&
1850: (cluster->regs == a660_fe_cluster))
1851: continue;
1852:
1853: /* The VPC registers are driven by VPC_PS cluster on a650 */
1854: if (adreno_is_a650_family(adreno_dev) &&
1855: (cluster->regs == a6xx_vpc_ps_cluster))
1856: cluster->id = CP_CLUSTER_VPC_PS;
1857:
1858: if (cluster->sel) {
1859: ptr[qwords++] = cluster->sel->val;
1860: ptr[qwords++] = ((uint64_t)cluster->sel->cd_reg << 44) |
1861: (1 << 21) | 1;
1862: }
1863:
1864: cluster->offset0 = *offset;
1865: for (j = 0; j < A6XX_NUM_CTXTS; j++) {
1866:
1867: if (j == 1)
1868: cluster->offset1 = *offset;
1869:
1870: ptr[qwords++] = (cluster->id << 8) | (j << 4) | j;
1871: ptr[qwords++] =
1872: ((uint64_t)A6XX_CP_APERTURE_CNTL_CD << 44) |
1873: (1 << 21) | 1;
1874:
1875: for (k = 0; k < cluster->num_sets; k++) {
1876: count = REG_PAIR_COUNT(cluster->regs, k);
1877: ptr[qwords++] =
1878: a6xx_crashdump_registers->gpuaddr + *offset;
1879: ptr[qwords++] =
1880: (((uint64_t)cluster->regs[2 * k]) << 44) |
1881: count;
1882:
1883: *offset += count * sizeof(unsigned int);
1884: }
1885: }
1886: }
1887:
1888: return qwords;
1889: }
1890:
1891: static int _a6xx_crashdump_init_shader(struct a6xx_shader_block *block,
1892: uint64_t *ptr, uint64_t *offset)
1893: {
1894: int qwords = 0;
1895: unsigned int j;
1896:
1897: /* Capture each bank in the block */
1898: for (j = 0; j < A6XX_NUM_SHADER_BANKS; j++) {
1899: /* Program the aperture */
1900: ptr[qwords++] =
1901: (block->statetype << A6XX_SHADER_STATETYPE_SHIFT) | j;
1902: ptr[qwords++] = (((uint64_t) A6XX_HLSQ_DBG_READ_SEL << 44)) |
1903: (1 << 21) | 1;
1904:
1905: /* Read all the data in one chunk */
1906: ptr[qwords++] = a6xx_crashdump_registers->gpuaddr + *offset;
1907: ptr[qwords++] =
1908: (((uint64_t) A6XX_HLSQ_DBG_AHB_READ_APERTURE << 44)) |
1909: block->sz;
1910:
1911: /* Remember the offset of the first bank for easy access */
1912: if (j == 0)
1913: block->offset = *offset;
1914:
1915: *offset += block->sz * sizeof(unsigned int);
1916: }
1917:
1918: return qwords;
1919: }
1920:
1921: static int _a6xx_crashdump_init_ctx_dbgahb(uint64_t *ptr, uint64_t *offset)
1922: {
1923: int qwords = 0;
1924: unsigned int i, j, k;
1925: unsigned int count;
1926:
1927: for (i = 0; i < ARRAY_SIZE(a6xx_dbgahb_ctx_clusters); i++) {
1928: struct a6xx_cluster_dbgahb_registers *cluster =
1929: &a6xx_dbgahb_ctx_clusters[i];
1930:
1931: cluster->offset0 = *offset;
1932:
1933: for (j = 0; j < A6XX_NUM_CTXTS; j++) {
1934: if (j == 1)
1935: cluster->offset1 = *offset;
1936:
1937: /* Program the aperture */
1938: ptr[qwords++] =
1939: ((cluster->statetype + j * 2) & 0xff) << 8;
1940: ptr[qwords++] =
1941: (((uint64_t)A6XX_HLSQ_DBG_READ_SEL << 44)) |
1942: (1 << 21) | 1;
1943:
1944: for (k = 0; k < cluster->num_sets; k++) {
1945: unsigned int start = cluster->regs[2 * k];
1946:
1947: count = REG_PAIR_COUNT(cluster->regs, k);
1948: ptr[qwords++] =
1949: a6xx_crashdump_registers->gpuaddr + *offset;
1950: ptr[qwords++] =
1951: (((uint64_t)(A6XX_HLSQ_DBG_AHB_READ_APERTURE +
1952: start - cluster->regbase / 4) << 44)) |
1953: count;
1954:
1955: *offset += count * sizeof(unsigned int);
1956: }
1957: }
1958: }
1959: return qwords;
1960: }
1961:
1962: static int _a6xx_crashdump_init_non_ctx_dbgahb(uint64_t *ptr, uint64_t *offset)
1963: {
1964: int qwords = 0;
1965: unsigned int i, k;
1966: unsigned int count;
1967:
1968: for (i = 0; i < ARRAY_SIZE(a6xx_non_ctx_dbgahb); i++) {
1969: struct a6xx_non_ctx_dbgahb_registers *regs =
1970: &a6xx_non_ctx_dbgahb[i];
1971:
1972: regs->offset = *offset;
1973:
1974: /* Program the aperture */
1975: ptr[qwords++] = (regs->statetype & 0xff) << 8;
1976: ptr[qwords++] = (((uint64_t)A6XX_HLSQ_DBG_READ_SEL << 44)) |
1977: (1 << 21) | 1;
1978:
1979: for (k = 0; k < regs->num_sets; k++) {
1980: unsigned int start = regs->regs[2 * k];
1981:
1982: count = REG_PAIR_COUNT(regs->regs, k);
1983: ptr[qwords++] =
1984: a6xx_crashdump_registers->gpuaddr + *offset;
1985: ptr[qwords++] =
1986: (((uint64_t)(A6XX_HLSQ_DBG_AHB_READ_APERTURE +
1987: start - regs->regbase / 4) << 44)) |
1988: count;
1989:
1990: *offset += count * sizeof(unsigned int);
1991: }
1992: }
1993: return qwords;
1994: }
1995:
1996: void a6xx_crashdump_init(struct adreno_device *adreno_dev)
1997: {
1998: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1999: unsigned int script_size = 0;
2000: unsigned int data_size = 0;
2001: unsigned int i, j, k, ret;
2002: uint64_t *ptr;
2003: uint64_t offset = 0;
2004:
2005: if (!IS_ERR_OR_NULL(a6xx_capturescript) &&
2006: !IS_ERR_OR_NULL(a6xx_crashdump_registers))
2007: return;
2008:
2009: /*
2010: * We need to allocate two buffers:
2011: * 1 - the buffer to hold the draw script
2012: * 2 - the buffer to hold the data
2013: */
2014:
2015: /*
2016: * To save the registers, we need 16 bytes per register pair for the
2017: * script and a dword for each register in the data
2018: */
2019: for (i = 0; i < ARRAY_SIZE(a6xx_reg_list); i++) {
2020: struct reg_list *regs = &a6xx_reg_list[i];
2021:
2022: /* Skip registers that dont exists on targets other than A660 */
2023: if (!adreno_is_a660(adreno_dev) &&
2024: (regs->regs == a660_registers))
2025: continue;
2026:
2027: /* 16 bytes for programming the aperture */
2028: if (regs->sel)
2029: script_size += 16;
2030:
2031: /* Each pair needs 16 bytes (2 qwords) */
2032: script_size += regs->count * 16;
2033:
2034: /* Each register needs a dword in the data */
2035: for (j = 0; j < regs->count; j++)
2036: data_size += REG_PAIR_COUNT(regs->regs, j) *
2037: sizeof(unsigned int);
2038:
2039: }
2040:
2041: /*
2042: * To save the shader blocks for each block in each type we need 32
2043: * bytes for the script (16 bytes to program the aperture and 16 to
2044: * read the data) and then a block specific number of bytes to hold
2045: * the data
2046: */
2047: for (i = 0; i < ARRAY_SIZE(a6xx_shader_blocks); i++) {
2048: script_size += 32 * A6XX_NUM_SHADER_BANKS;
2049: data_size += a6xx_shader_blocks[i].sz * sizeof(unsigned int) *
2050: A6XX_NUM_SHADER_BANKS;
2051: }
2052:
2053: /* Calculate the script and data size for MVC registers */
2054: for (i = 0; i < ARRAY_SIZE(a6xx_clusters); i++) {
2055: struct a6xx_cluster_registers *cluster = &a6xx_clusters[i];
2056:
2057: /* Skip registers that dont exists on targets other than A660 */
2058: if (!adreno_is_a660(adreno_dev) &&
2059: (cluster->regs == a660_fe_cluster))
2060: continue;
2061:
2062: /* 16 bytes if cluster sel exists */
2063: if (cluster->sel)
2064: script_size += 16;
2065:
2066: for (j = 0; j < A6XX_NUM_CTXTS; j++) {
2067:
2068: /* 16 bytes for programming the aperture */
2069: script_size += 16;
2070:
2071: /* Reading each pair of registers takes 16 bytes */
2072: script_size += 16 * cluster->num_sets;
2073:
2074: /* A dword per register read from the cluster list */
2075: for (k = 0; k < cluster->num_sets; k++)
2076: data_size += REG_PAIR_COUNT(cluster->regs, k) *
2077: sizeof(unsigned int);
2078: }
2079: }
2080:
2081: /* Calculate the script and data size for debug AHB registers */
2082: for (i = 0; i < ARRAY_SIZE(a6xx_dbgahb_ctx_clusters); i++) {
2083: struct a6xx_cluster_dbgahb_registers *cluster =
2084: &a6xx_dbgahb_ctx_clusters[i];
2085:
2086: for (j = 0; j < A6XX_NUM_CTXTS; j++) {
2087:
2088: /* 16 bytes for programming the aperture */
2089: script_size += 16;
2090:
2091: /* Reading each pair of registers takes 16 bytes */
2092: script_size += 16 * cluster->num_sets;
2093:
2094: /* A dword per register read from the cluster list */
2095: for (k = 0; k < cluster->num_sets; k++)
2096: data_size += REG_PAIR_COUNT(cluster->regs, k) *
2097: sizeof(unsigned int);
2098: }
2099: }
2100:
2101: /*
2102: * Calculate the script and data size for non context debug
2103: * AHB registers
2104: */
2105: for (i = 0; i < ARRAY_SIZE(a6xx_non_ctx_dbgahb); i++) {
2106: struct a6xx_non_ctx_dbgahb_registers *regs =
2107: &a6xx_non_ctx_dbgahb[i];
2108:
2109: /* 16 bytes for programming the aperture */
2110: script_size += 16;
2111:
2112: /* Reading each pair of registers takes 16 bytes */
2113: script_size += 16 * regs->num_sets;
2114:
2115: /* A dword per register read from the cluster list */
2116: for (k = 0; k < regs->num_sets; k++)
2117: data_size += REG_PAIR_COUNT(regs->regs, k) *
2118: sizeof(unsigned int);
2119: }
2120:
2121: /* 16 bytes (2 qwords) for last entry in CD script */
2122: script_size += 16;
2123: /* Increment data size to store last entry in CD */
2124: data_size += sizeof(unsigned int);
2125:
2126: /* Now allocate the script and data buffers */
2127:
2128: /* The script buffers needs 2 extra qwords on the end */
2129: ret = adreno_allocate_global(device, &a6xx_capturescript,
2130: script_size + 16, 0, KGSL_MEMFLAGS_GPUREADONLY,
2131: KGSL_MEMDESC_PRIVILEGED, "capturescript");
2132: if (ret)
2133: return;
2134:
2135: ret = adreno_allocate_global(device, &a6xx_crashdump_registers,
2136: data_size, 0, 0, KGSL_MEMDESC_PRIVILEGED,
2137: "capturescript_regs");
2138: if (ret)
2139: return;
2140:
2141: /* Build the crash script */
2142:
2143: ptr = (uint64_t *)a6xx_capturescript->hostptr;
2144:
2145: /* For the registers, program a read command for each pair */
2146: for (i = 0; i < ARRAY_SIZE(a6xx_reg_list); i++) {
2147: struct reg_list *regs = &a6xx_reg_list[i];
2148:
2149: /* Skip registers that dont exists on targets other than A660 */
2150: if (!adreno_is_a660(adreno_dev) &&
2151: (regs->regs == a660_registers))
2152: continue;
2153:
2154: regs->offset = offset;
2155:
2156: /* Program the SEL_CNTL_CD register appropriately */
2157: if (regs->sel) {
2158: *ptr++ = regs->sel->val;
2159: *ptr++ = (((uint64_t)regs->sel->cd_reg << 44)) |
2160: (1 << 21) | 1;
2161: }
2162:
2163: for (j = 0; j < regs->count; j++) {
2164: unsigned int r = REG_PAIR_COUNT(regs->regs, j);
2165: *ptr++ = a6xx_crashdump_registers->gpuaddr + offset;
2166: *ptr++ = (((uint64_t) regs->regs[2 * j]) << 44) | r;
2167: offset += r * sizeof(unsigned int);
2168: }
2169: }
2170:
2171: /* Program each shader block */
2172: for (i = 0; i < ARRAY_SIZE(a6xx_shader_blocks); i++) {
2173: ptr += _a6xx_crashdump_init_shader(&a6xx_shader_blocks[i], ptr,
2174: &offset);
2175: }
2176:
2177: /* Program the capturescript for the MVC regsiters */
2178: ptr += _a6xx_crashdump_init_mvc(adreno_dev, ptr, &offset);
2179:
2180: if (!adreno_is_a663(adreno_dev)) {
2181: ptr += _a6xx_crashdump_init_ctx_dbgahb(ptr, &offset);
2182:
2183: ptr += _a6xx_crashdump_init_non_ctx_dbgahb(ptr, &offset);
2184: }
2185:
2186: /* Save CD register end pointer to check CD status completion */
2187: a6xx_cd_reg_end = a6xx_crashdump_registers->hostptr + offset;
2188:
2189: memset(a6xx_crashdump_registers->hostptr, 0xaa,
2190: a6xx_crashdump_registers->size);
2191:
2192: /* Program the capturescript to read the last register entry */
2193: *ptr++ = a6xx_crashdump_registers->gpuaddr + offset;
2194: *ptr++ = (((uint64_t) A6XX_CP_CRASH_DUMP_STATUS) << 44) | (uint64_t) 1;
2195:
2196: *ptr++ = 0;
2197: *ptr++ = 0;
2198: }
--- FILE: \adreno_drawctxt.c | HITS: 1 ---
MATCH LINES: 345
333: }
334:
335: u32 adreno_prepare_preib_postamble_scratch(struct adreno_device *adreno_dev, u32 *cmds)
336: {
337: u32 *cmds_orig = cmds;
338: u64 kmd_postamble_addr;
339:
340: if (!adreno_dev->preempt.postamble_len)
341: return 0;
342:
343: kmd_postamble_addr = SCRATCH_POSTAMBLE_ADDR(KGSL_DEVICE(adreno_dev));
344:
345: *cmds++ = cp_type7_packet(CP_SET_AMBLE, 3);
346: *cmds++ = lower_32_bits(kmd_postamble_addr);
347: *cmds++ = upper_32_bits(kmd_postamble_addr);
348: *cmds++ = FIELD_PREP(GENMASK(22, 20), CP_KMD_AMBLE_TYPE)
349: | (FIELD_PREP(GENMASK(19, 0), adreno_dev->preempt.postamble_len));
350:
351: return (u32) (cmds - cmds_orig);
352: }
353:
354: static int drawctxt_preemption_init(struct kgsl_context *context)
355: {
356: struct kgsl_device *device = context->device;
357: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
358: u64 flags = 0;
359:
360: /*
361: * User context record is needed for a6x and beyond targets only. Also,
362: * highest priority ringbuffer i.e. RB0 always runs to completion without
363: * preemption. Thus, user context records are not needed for RB0.
364: */
365: if (!adreno_preemption_feature_set(adreno_dev) || (ADRENO_GPUREV(adreno_dev) < 600) ||
366: (adreno_get_level(context) == 0))
367: return 0;
368:
369: if (context->flags & KGSL_CONTEXT_SECURE)
--- FILE: \adreno_gen7.c | HITS: 6 ---
MATCH LINES: 255, 277
243: *val = (u64) gmu->acd_debug_val;
244:
245: return 0;
246: }
247:
248: DEFINE_DEBUGFS_ATTRIBUTE(acd_cal_fops, acd_calibrate_get, acd_calibrate_set, "%llu\n");
249:
250: void gen7_cp_init_cmds(struct adreno_device *adreno_dev, u32 *cmds)
251: {
252: u32 i = 0, mask = 0;
253:
254: /* Disable concurrent binning before sending CP init */
255: cmds[i++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
256: cmds[i++] = BIT(27);
257:
258: /* Use multiple HW contexts */
259: mask |= BIT(0);
260:
261: /* Enable error detection */
262: mask |= BIT(1);
263:
264: /* Set default reset state */
265: mask |= BIT(3);
266:
267: /* Disable save/restore of performance counters across preemption */
268: mask |= BIT(6);
269:
270: /* Enable the register init list with the spinlock */
271: mask |= BIT(8);
272:
273: /* By default DMS is enabled from CP side, disable it if not supported */
274: if (!adreno_dev->dms_enabled)
275: mask |= BIT(11);
276:
277: cmds[i++] = cp_type7_packet(CP_ME_INIT, 7);
278:
279: /* Enabled ordinal mask */
280: cmds[i++] = mask;
281: cmds[i++] = 0x00000003; /* Set number of HW contexts */
282: cmds[i++] = 0x20000000; /* Enable error detection */
283: cmds[i++] = 0x00000002; /* Operation mode mask */
284:
285: /* Register initialization list with spinlock */
286: cmds[i++] = lower_32_bits(adreno_dev->pwrup_reglist->gpuaddr);
287: cmds[i++] = upper_32_bits(adreno_dev->pwrup_reglist->gpuaddr);
288: /*
289: * Gen7 targets with concurrent binning are expected to have a dynamic
290: * power up list with triplets which contains the pipe id in it.
291: * Bit 31 of POWER_UP_REGISTER_LIST_LENGTH is reused here to let CP
292: * know if the power up contains the triplets. If
293: * REGISTER_INIT_LIST_WITH_SPINLOCK is set and bit 31 below is set,
294: * CP expects a dynamic list with triplets.
295: */
296: cmds[i++] = BIT(31);
297: }
298:
299: int gen7_fenced_write(struct adreno_device *adreno_dev, u32 offset,
300: u32 value, u32 mask)
301: {
MATCH LINES: 1220, 1233, 1240
1208: gen7_preemption_prepare_postamble(adreno_dev);
1209:
1210: if (kgsl_mmu_is_secured(&device->mmu))
1211: count += 3;
1212:
1213: if (preempt->postamble_bootup_len)
1214: count += 4;
1215:
1216: cmds = adreno_ringbuffer_allocspace(rb, count);
1217: if (IS_ERR(cmds))
1218: return PTR_ERR(cmds);
1219:
1220: *cmds++ = cp_type7_packet(CP_SET_PSEUDO_REGISTER,
1221: kgsl_mmu_is_secured(&device->mmu) ? 6 : 3);
1222: *cmds++ = SET_PSEUDO_PRIV_NON_SECURE_SAVE_ADDR;
1223: *cmds++ = lower_32_bits(rb->preemption_desc->gpuaddr);
1224: *cmds++ = upper_32_bits(rb->preemption_desc->gpuaddr);
1225:
1226: if (kgsl_mmu_is_secured(&device->mmu)) {
1227: *cmds++ = SET_PSEUDO_PRIV_SECURE_SAVE_ADDR;
1228: *cmds++ = lower_32_bits(rb->secure_preemption_desc->gpuaddr);
1229: *cmds++ = upper_32_bits(rb->secure_preemption_desc->gpuaddr);
1230: }
1231:
1232: if (preempt->postamble_bootup_len) {
1233: *cmds++ = cp_type7_packet(CP_SET_AMBLE, 3);
1234: *cmds++ = lower_32_bits(kmd_postamble_addr);
1235: *cmds++ = upper_32_bits(kmd_postamble_addr);
1236: *cmds++ = FIELD_PREP(GENMASK(22, 20), CP_KMD_AMBLE_TYPE)
1237: | (FIELD_PREP(GENMASK(19, 0), adreno_dev->preempt.postamble_bootup_len));
1238: }
1239:
1240: *cmds++ = cp_type7_packet(CP_CONTEXT_SWITCH_YIELD, 4);
1241: *cmds++ = 0;
1242: *cmds++ = 0;
1243: *cmds++ = 0;
1244: /* generate interrupt on preemption completion */
1245: *cmds++ = 0;
1246:
1247: ret = gen7_ringbuffer_submit(rb, NULL);
1248: if (!ret) {
1249: ret = adreno_spin_idle(adreno_dev, 2000);
1250: if (ret)
1251: gen7_spin_idle_debug(adreno_dev,
1252: "hw preemption initialization failed to idle\n");
1253: }
1254:
1255: return ret;
1256: }
1257:
1258: int gen7_rb_start(struct adreno_device *adreno_dev)
1259: {
1260: const struct adreno_gen7_core *gen7_core = to_gen7_core(adreno_dev);
1261: struct adreno_firmware *fw = ADRENO_FW(adreno_dev, ADRENO_FW_SQE);
1262: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1263: struct adreno_ringbuffer *rb;
1264: u64 addr;
MATCH LINES: 1332
1320:
1321: /*
1322: * Take the GPU out of secure mode. Try the zap shader if it is loaded,
1323: * otherwise just try to write directly to the secure control register
1324: */
1325: if (!adreno_dev->zap_loaded)
1326: kgsl_regwrite(device, GEN7_RBBM_SECVID_TRUST_CNTL, 0);
1327: else {
1328: cmds = adreno_ringbuffer_allocspace(rb, 2);
1329: if (IS_ERR(cmds))
1330: return PTR_ERR(cmds);
1331:
1332: *cmds++ = cp_type7_packet(CP_SET_SECURE_MODE, 1);
1333: *cmds++ = 0;
1334:
1335: ret = gen7_ringbuffer_submit(rb, NULL);
1336: if (!ret) {
1337: ret = adreno_spin_idle(adreno_dev, 2000);
1338: if (ret) {
1339: gen7_spin_idle_debug(adreno_dev,
1340: "Switch to unsecure failed to idle\n");
1341: return ret;
1342: }
1343: }
1344: }
1345:
1346: return gen7_post_start(adreno_dev);
1347: }
1348:
1349: /*
1350: * gen7_gpu_keepalive() - GMU reg write to request GPU stays on
1351: * @adreno_dev: Pointer to the adreno device that has the GMU
1352: * @state: State to set: true is ON, false is OFF
1353: */
1354: static void gen7_gpu_keepalive(struct adreno_device *adreno_dev,
1355: bool state)
1356: {
--- FILE: \adreno_gen7_hfi.c | HITS: 1 ---
MATCH LINES: 282
270: unsigned int val;
271: unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
272: bool nmi = false;
273:
274: while (time_is_after_jiffies(timeout)) {
275: gmu_core_regread(device, offsetdwords, &val);
276: if ((val & mask) == expected_val)
277: return 0;
278:
279: /*
280: * If GMU firmware fails any assertion, error message is sent
281: * to KMD and NMI is triggered. So check if GMU is in NMI and
282: * timeout early. Bits [11:9] of A6XX_GMU_CM3_FW_INIT_RESULT
283: * contain GMU reset status. Non zero value here indicates that
284: * GMU reset is active, NMI handler would eventually complete
285: * and GMU would wait for recovery.
286: */
287: gmu_core_regread(device, GEN7_GMU_CM3_FW_INIT_RESULT, &val);
288: if (val & 0xE00) {
289: nmi = true;
290: break;
291: }
292:
293: usleep_range(10, 100);
294: }
295:
296: /* Check one last time */
297: gmu_core_regread(device, offsetdwords, &val);
298: if ((val & mask) == expected_val)
299: return 0;
300:
301: dev_err(GMU_PDEV_DEV(device),
302: "Reg poll %s: offset 0x%x, want 0x%x, got 0x%x\n",
303: nmi ? "abort" : "timeout", offsetdwords, expected_val,
304: val & mask);
305:
306: return -ETIMEDOUT;
--- FILE: \adreno_gen7_hwsched_hfi.c | HITS: 3 ---
MATCH LINES: 2336
2324:
2325: return ret;
2326: }
2327:
2328: static int send_switch_to_unsecure(struct adreno_device *adreno_dev)
2329: {
2330: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
2331: u32 cmds[3];
2332: int ret = 0;
2333:
2334: cmds[0] = CREATE_MSG_HDR(H2F_MSG_ISSUE_CMD_RAW, HFI_MSG_CMD);
2335:
2336: cmds[1] = cp_type7_packet(CP_SET_SECURE_MODE, 1);
2337: cmds[2] = 0;
2338:
2339: ret = submit_raw_cmds(adreno_dev, cmds, sizeof(cmds),
2340: "Switch to unsecure failed to idle\n");
2341:
2342: /* Save the header incase we need a warmboot debug */
2343: gmu->switch_to_unsec_hdr = cmds[0];
2344:
2345: return ret;
2346: }
2347:
2348: int gen7_hwsched_cp_init(struct adreno_device *adreno_dev)
2349: {
2350: const struct adreno_gen7_core *gen7_core = to_gen7_core(adreno_dev);
2351: int ret;
2352:
2353: ret = cp_init(adreno_dev);
2354: if (ret)
2355: return ret;
2356:
2357: ret = adreno_zap_shader_load(adreno_dev, gen7_core->zap_name);
2358: if (ret)
2359: return ret;
2360:
MATCH LINES: 3907, 3908
3895:
3896: ret = adreno_allocate_global(device, &hfi->perfctr_scratch,
3897: PAGE_SIZE, 0, KGSL_MEMFLAGS_GPUREADONLY, 0, "perfctr_scratch");
3898: if (ret)
3899: goto err;
3900:
3901: if (group->flags & ADRENO_PERFCOUNTER_GROUP_RESTORE)
3902: gen7_perfcounter_update(adreno_dev, reg, false,
3903: FIELD_PREP(GENMASK(13, 12), PIPE_NONE), group->flags);
3904:
3905: cmds = hfi->perfctr_scratch->hostptr;
3906:
3907: cmds[count++] = cp_type7_packet(CP_WAIT_FOR_IDLE, 0);
3908: cmds[count++] = cp_type4_packet(reg->select, 1);
3909: cmds[count++] = countable;
3910:
3911: ret = submit_global_ctxt_cmd(adreno_dev, hfi->perfctr_scratch->gpuaddr, count << 2);
3912: if (ret)
3913: goto err;
3914:
3915: /* Wait till the register is programmed with the countable */
3916: ret = kgsl_regmap_read_poll_timeout(&device->regmap, reg->select, val,
3917: val == countable, 100, ADRENO_IDLE_TIMEOUT * USEC_PER_MSEC);
3918: if (!ret) {
3919: reg->value = 0;
3920: return ret;
3921: }
3922:
3923: err:
3924: dev_err(device->dev, "Perfcounter %s/%u/%u start via commands failed\n",
3925: group->name, counter, countable);
3926:
3927: return ret;
3928: }
3929:
3930: int gen7_hwsched_disable_hw_fence_throttle(struct adreno_device *adreno_dev)
3931: {
3932: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence;
--- FILE: \adreno_gen7_perfcounter.c | HITS: 2 ---
MATCH LINES: 81, 82
69: static int gen7_swsched_counter_inline_enable(struct adreno_device *adreno_dev,
70: const struct adreno_perfcount_group *group,
71: unsigned int counter, unsigned int countable)
72: {
73: struct adreno_perfcount_register *reg = &group->regs[counter];
74: struct adreno_ringbuffer *rb = &adreno_dev->ringbuffers[0];
75: u32 cmds[3];
76: int ret;
77:
78: gen7_perfcounter_update(adreno_dev, reg, false,
79: FIELD_PREP(GENMASK(13, 12), PIPE_NONE), group->flags);
80:
81: cmds[0] = cp_type7_packet(CP_WAIT_FOR_IDLE, 0);
82: cmds[1] = cp_type4_packet(reg->select, 1);
83: cmds[2] = countable;
84:
85: /* submit to highest priority RB always */
86: ret = gen7_ringbuffer_addcmds(adreno_dev, rb, NULL,
87: F_NOTPROTECTED, cmds, 3, 0, NULL);
88: if (ret)
89: return ret;
90:
91: /*
92: * schedule dispatcher to make sure rb[0] is run, because
93: * if the current RB is not rb[0] and gpu is idle then
94: * rb[0] will not get scheduled to run
95: */
96: if (adreno_dev->cur_rb != rb)
97: adreno_scheduler_queue(adreno_dev);
98:
99: /* wait for the above commands submitted to complete */
100: ret = adreno_ringbuffer_waittimestamp(rb, rb->timestamp,
101: ADRENO_IDLE_TIMEOUT);
102:
103: if (ret) {
104: /*
105: * If we were woken up because of cancelling rb events
106: * either due to soft reset or adreno_stop, ignore the
--- FILE: \adreno_gen7_preempt.c | HITS: 8 ---
MATCH LINES: 474, 490, 493
462: * First 28 dwords of the device scratch buffer are used to store shadow rb data.
463: * Reserve 15 dwords in the device scratch buffer from SCRATCH_POSTAMBLE_OFFSET for
464: * KMD postamble pm4 packets. This should be in *device->scratch* so that userspace
465: * cannot access it.
466: */
467: postamble = device->scratch->hostptr + SCRATCH_POSTAMBLE_OFFSET;
468:
469: /*
470: * Reserve 4 dwords in the scratch buffer for dynamic QOS control feature. To ensure QOS
471: * value is updated for first preemption, send it during bootup
472: */
473: if (gen7_core->qos_value) {
474: postamble[count++] = cp_type7_packet(CP_MEM_TO_REG, 3);
475: postamble[count++] = GEN7_RBBM_GBIF_CLIENT_QOS_CNTL;
476: postamble[count++] = lower_32_bits(PREEMPT_SCRATCH_ADDR(adreno_dev, QOS_VALUE_IDX));
477: postamble[count++] = upper_32_bits(PREEMPT_SCRATCH_ADDR(adreno_dev, QOS_VALUE_IDX));
478: }
479:
480: /*
481: * Since postambles are not preserved across slumber, necessary packets
482: * must be sent to GPU before first submission.
483: *
484: * If a packet needs to be sent before first submission, add it above this.
485: */
486: preempt->postamble_bootup_len = count;
487:
488: /* Insert PM4 packets in device scratch buffer to clear perfcounters */
489: if (!adreno_dev->perfcounter) {
490: postamble[count++] = cp_type4_packet(GEN7_RBBM_PERFCTR_SRAM_INIT_CMD, 1);
491: postamble[count++] = 0x1;
492:
493: postamble[count++] = cp_type7_packet(CP_WAIT_REG_MEM, 6);
494: postamble[count++] = 0x3;
495: postamble[count++] = GEN7_RBBM_PERFCTR_SRAM_INIT_STATUS;
496: postamble[count++] = 0x0;
497: postamble[count++] = 0x1;
498: postamble[count++] = 0x1;
499: postamble[count++] = 0x0;
500: }
501:
502: preempt->postamble_len = count;
503: }
504:
505: void gen7_preemption_schedule(struct adreno_device *adreno_dev)
506: {
507: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
508:
509: if (!adreno_is_preemption_enabled(adreno_dev))
510: return;
511:
512: kgsl_mutex_lock(&device->mutex);
513:
514: if (adreno_in_preempt_state(adreno_dev, ADRENO_PREEMPT_COMPLETE))
515: _gen7_preemption_done(adreno_dev);
516:
517: gen7_preemption_trigger(adreno_dev, false);
MATCH LINES: 536, 539
524: u32 *cmds)
525: {
526: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
527: u32 count = kgsl_mmu_is_secured(&device->mmu) ? 12 : 9;
528: u32 *cmds_orig = cmds;
529:
530: if (!adreno_is_preemption_enabled(adreno_dev))
531: return 0;
532:
533: if (test_and_set_bit(ADRENO_RB_SET_PSEUDO_DONE, &rb->flags))
534: goto done;
535:
536: *cmds++ = cp_type7_packet(CP_THREAD_CONTROL, 1);
537: *cmds++ = CP_SET_THREAD_BR;
538:
539: *cmds++ = cp_type7_packet(CP_SET_PSEUDO_REGISTER, count);
540:
541: /* NULL SMMU_INFO buffer - we track in KMD */
542: *cmds++ = SET_PSEUDO_SMMU_INFO;
543: cmds += cp_gpuaddr(adreno_dev, cmds, 0x0);
544:
545: *cmds++ = SET_PSEUDO_PRIV_NON_SECURE_SAVE_ADDR;
546: cmds += cp_gpuaddr(adreno_dev, cmds, rb->preemption_desc->gpuaddr);
547:
548: if (kgsl_mmu_is_secured(&device->mmu)) {
549: *cmds++ = SET_PSEUDO_PRIV_SECURE_SAVE_ADDR;
550: cmds += cp_gpuaddr(adreno_dev, cmds,
551: rb->secure_preemption_desc->gpuaddr);
552: }
553:
554: /*
555: * There is no need to specify this address when we are about to
556: * trigger preemption. This is because CP internally stores this
557: * address specified here in the CP_SET_PSEUDO_REGISTER payload to
558: * the context record and thus knows from where to restore
559: * the saved perfcounters for the new ringbuffer.
560: */
561: *cmds++ = SET_PSEUDO_COUNTER;
562: cmds += cp_gpuaddr(adreno_dev, cmds,
563: rb->perfcounter_save_restore_desc->gpuaddr);
MATCH LINES: 585, 592, 594
573:
574: u32 gen7_preemption_post_ibsubmit(struct adreno_device *adreno_dev,
575: u32 *cmds)
576: {
577: u32 index = 0;
578:
579: if (!adreno_is_preemption_enabled(adreno_dev))
580: return 0;
581:
582: if (adreno_dev->cur_rb) {
583: u64 dest = PREEMPT_SCRATCH_ADDR(adreno_dev, adreno_dev->cur_rb->id);
584:
585: cmds[index++] = cp_type7_packet(CP_MEM_WRITE, 4);
586: cmds[index++] = lower_32_bits(dest);
587: cmds[index++] = upper_32_bits(dest);
588: cmds[index++] = 0;
589: cmds[index++] = 0;
590: }
591:
592: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
593: cmds[index++] = CP_SET_THREAD_BOTH;
594: cmds[index++] = cp_type7_packet(CP_CONTEXT_SWITCH_YIELD, 4);
595: cmds[index++] = 0;
596: cmds[index++] = 0;
597: cmds[index++] = 1;
598: cmds[index++] = 0;
599:
600: return index;
601: }
602:
603: void gen7_preemption_start(struct adreno_device *adreno_dev)
604: {
605: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
606: struct kgsl_iommu *iommu = KGSL_IOMMU(device);
607: struct adreno_ringbuffer *rb;
608: unsigned int i;
609:
610: if (!adreno_is_preemption_enabled(adreno_dev))
611: return;
612:
613: /* Force the state to be clear */
614: adreno_set_preempt_state(adreno_dev, ADRENO_PREEMPT_NONE);
615:
616: if (kgsl_mmu_is_perprocess(&device->mmu)) {
617: /* smmu_info is allocated and mapped in gen7_preemption_iommu_init */
618: kgsl_sharedmem_writel(iommu->smmu_info,
--- FILE: \adreno_gen7_ringbuffer.c | HITS: 55 ---
MATCH LINES: 35, 40, 54, 71, 74, 83, 88, 91, 95, 100, 109, 127, 131, 134, 141, 148, 154
23: struct adreno_ringbuffer *rb, struct adreno_context *drawctxt,
24: struct kgsl_pagetable *pagetable, u32 *cmds)
25: {
26: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
27: u64 ttbr0 = kgsl_mmu_pagetable_get_ttbr0(pagetable);
28: int count = 0;
29: u32 id = drawctxt ? drawctxt->base.id : 0;
30:
31: if (pagetable == device->mmu.defaultpagetable)
32: return 0;
33:
34: /* CP switches the pagetable and flushes the Caches */
35: cmds[count++] = cp_type7_packet(CP_SMMU_TABLE_UPDATE, 3);
36: cmds[count++] = lower_32_bits(ttbr0);
37: cmds[count++] = upper_32_bits(ttbr0);
38: cmds[count++] = id;
39:
40: cmds[count++] = cp_type7_packet(CP_MEM_WRITE, 5);
41: cmds[count++] = lower_32_bits(SCRATCH_RB_GPU_ADDR(device,
42: rb->id, ttbr0));
43: cmds[count++] = upper_32_bits(SCRATCH_RB_GPU_ADDR(device,
44: rb->id, ttbr0));
45: cmds[count++] = lower_32_bits(ttbr0);
46: cmds[count++] = upper_32_bits(ttbr0);
47: cmds[count++] = id;
48:
49: /*
50: * Sync both threads after switching pagetables and enable BR only
51: * to make sure BV doesn't race ahead while BR is still switching
52: * pagetables.
53: */
54: cmds[count++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
55: cmds[count++] = CP_SYNC_THREADS | CP_SET_THREAD_BR;
56:
57: return count;
58: }
59:
60: static int gen7_rb_context_switch(struct adreno_device *adreno_dev,
61: struct adreno_ringbuffer *rb,
62: struct adreno_context *drawctxt)
63: {
64: struct kgsl_pagetable *pagetable =
65: adreno_drawctxt_get_pagetable(drawctxt);
66: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
67: int count = 0;
68: u32 cmds[61];
69:
70: /* Sync both threads */
71: cmds[count++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
72: cmds[count++] = CP_SYNC_THREADS | CP_SET_THREAD_BOTH;
73: /* Reset context state */
74: cmds[count++] = cp_type7_packet(CP_RESET_CONTEXT_STATE, 1);
75: cmds[count++] = CP_RESET_GLOBAL_LOCAL_TS | CP_CLEAR_BV_BR_COUNTER |
76: CP_CLEAR_RESOURCE_TABLE | CP_CLEAR_ON_CHIP_TS;
77: /*
78: * Enable/disable concurrent binning for pagetable switch and
79: * set the thread to BR since only BR can execute the pagetable
80: * switch packets.
81: */
82: /* Sync both threads and enable BR only */
83: cmds[count++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
84: cmds[count++] = CP_SYNC_THREADS | CP_SET_THREAD_BR;
85:
86: if (adreno_drawctxt_get_pagetable(rb->drawctxt_active) != pagetable) {
87: /* Flush LRZ before every pagetable switch */
88: cmds[count++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
89: cmds[count++] = CP_SET_THREAD_BOTH;
90:
91: cmds[count++] = cp_type7_packet(CP_EVENT_WRITE, 1);
92: /* Add event ID for LRZ flush as packet payload */
93: cmds[count++] = LRZ_CACHE_FLUSH;
94:
95: cmds[count++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
96: cmds[count++] = CP_SYNC_THREADS | CP_SET_THREAD_BR;
97:
98: /* Clear performance counters during context switches */
99: if (!adreno_dev->perfcounter) {
100: cmds[count++] = cp_type4_packet(GEN7_RBBM_PERFCTR_SRAM_INIT_CMD, 1);
101: cmds[count++] = 0x1;
102: }
103:
104: count += gen7_rb_pagetable_switch(adreno_dev, rb,
105: drawctxt, pagetable, &cmds[count]);
106:
107: /* Wait for performance counter clear to finish */
108: if (!adreno_dev->perfcounter) {
109: cmds[count++] = cp_type7_packet(CP_WAIT_REG_MEM, 6);
110: cmds[count++] = 0x3;
111: cmds[count++] = GEN7_RBBM_PERFCTR_SRAM_INIT_STATUS;
112: cmds[count++] = 0x0;
113: cmds[count++] = 0x1;
114: cmds[count++] = 0x1;
115: cmds[count++] = 0x0;
116: }
117: } else {
118: struct kgsl_iommu *iommu = KGSL_IOMMU(device);
119:
120: u32 offset = GEN7_SMMU_BASE + (iommu->cb0_offset >> 2) + 0x0d;
121:
122: /*
123: * Set the CONTEXTIDR register to the current context id so we
124: * can use it in pagefault debugging. Unlike TTBR0 we don't
125: * need any special sequence or locking to change it
126: */
127: cmds[count++] = cp_type4_packet(offset, 1);
128: cmds[count++] = drawctxt->base.id;
129: }
130:
131: cmds[count++] = cp_type7_packet(CP_NOP, 1);
132: cmds[count++] = CONTEXT_TO_MEM_IDENTIFIER;
133:
134: cmds[count++] = cp_type7_packet(CP_MEM_WRITE, 3);
135: cmds[count++] = lower_32_bits(MEMSTORE_RB_GPU_ADDR(device, rb,
136: current_context));
137: cmds[count++] = upper_32_bits(MEMSTORE_RB_GPU_ADDR(device, rb,
138: current_context));
139: cmds[count++] = drawctxt->base.id;
140:
141: cmds[count++] = cp_type7_packet(CP_MEM_WRITE, 3);
142: cmds[count++] = lower_32_bits(MEMSTORE_ID_GPU_ADDR(device,
143: KGSL_MEMSTORE_GLOBAL, current_context));
144: cmds[count++] = upper_32_bits(MEMSTORE_ID_GPU_ADDR(device,
145: KGSL_MEMSTORE_GLOBAL, current_context));
146: cmds[count++] = drawctxt->base.id;
147:
148: cmds[count++] = cp_type7_packet(CP_EVENT_WRITE, 1);
149: cmds[count++] = 0x31;
150:
151: if (adreno_is_preemption_enabled(adreno_dev) && drawctxt->base.user_ctxt_record) {
152: u64 gpuaddr = drawctxt->base.user_ctxt_record->memdesc.gpuaddr;
153:
154: cmds[count++] = cp_type7_packet(CP_SET_PSEUDO_REGISTER, 3);
155: cmds[count++] = SET_PSEUDO_NON_PRIV_SAVE_ADDR;
156: cmds[count++] = lower_32_bits(gpuaddr);
157: cmds[count++] = upper_32_bits(gpuaddr);
158: }
159:
160: return gen7_ringbuffer_addcmds(adreno_dev, rb, NULL, F_NOTPROTECTED,
161: cmds, count, 0, NULL);
162: }
163:
164: #define RB_SOPTIMESTAMP(device, rb) \
165: MEMSTORE_RB_GPU_ADDR(device, rb, soptimestamp)
166: #define CTXT_SOPTIMESTAMP(device, drawctxt) \
167: MEMSTORE_ID_GPU_ADDR(device, (drawctxt)->base.id, soptimestamp)
168:
169: #define RB_EOPTIMESTAMP(device, rb) \
170: MEMSTORE_RB_GPU_ADDR(device, rb, eoptimestamp)
171: #define CTXT_EOPTIMESTAMP(device, drawctxt) \
172: MEMSTORE_ID_GPU_ADDR(device, (drawctxt)->base.id, eoptimestamp)
173:
174: int gen7_ringbuffer_submit(struct adreno_ringbuffer *rb,
175: struct adreno_submit_time *time)
176: {
177: struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
178: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
MATCH LINES: 281, 288, 291, 294, 301, 308, 316, 323, 325, 336, 343, 348, 355, 361, 369, 381, 387, 395, 403, 406, 408, 410, 414, 417, 420, 434, 444, 468
269:
270: if (drawctxt)
271: drawctxt->internal_timestamp = rb->timestamp;
272:
273: /* All submissions are run with protected mode off due to APRIV */
274: flags &= ~F_NOTPROTECTED;
275:
276: cmds = adreno_ringbuffer_allocspace(rb, size);
277: if (IS_ERR(cmds))
278: return PTR_ERR(cmds);
279:
280: /* Identify the start of a command */
281: cmds[index++] = cp_type7_packet(CP_NOP, 1);
282: cmds[index++] = drawctxt ? CMD_IDENTIFIER : CMD_INTERNAL_IDENTIFIER;
283:
284: /* This is 25 dwords when drawctxt is not NULL and perfcounter needs to be zapped*/
285: index += gen7_preemption_pre_ibsubmit(adreno_dev, rb, drawctxt,
286: &cmds[index]);
287:
288: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
289: cmds[index++] = CP_SET_THREAD_BOTH;
290:
291: cmds[index++] = cp_type7_packet(CP_SET_MARKER, 1);
292: cmds[index++] = 0x101; /* IFPC disable */
293:
294: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
295: cmds[index++] = CP_SET_THREAD_BR;
296:
297: profile_gpuaddr = adreno_profile_preib_processing(adreno_dev,
298: drawctxt, &profile_dwords);
299:
300: if (profile_gpuaddr) {
301: cmds[index++] = cp_type7_packet(CP_INDIRECT_BUFFER_PFE, 3);
302: cmds[index++] = lower_32_bits(profile_gpuaddr);
303: cmds[index++] = upper_32_bits(profile_gpuaddr);
304: cmds[index++] = profile_dwords;
305: }
306:
307: if (drawctxt) {
308: cmds[index++] = cp_type7_packet(CP_MEM_WRITE, 3);
309: cmds[index++] = lower_32_bits(CTXT_SOPTIMESTAMP(device,
310: drawctxt));
311: cmds[index++] = upper_32_bits(CTXT_SOPTIMESTAMP(device,
312: drawctxt));
313: cmds[index++] = timestamp;
314: }
315:
316: cmds[index++] = cp_type7_packet(CP_MEM_WRITE, 3);
317: cmds[index++] = lower_32_bits(RB_SOPTIMESTAMP(device, rb));
318: cmds[index++] = upper_32_bits(RB_SOPTIMESTAMP(device, rb));
319: cmds[index++] = rb->timestamp;
320:
321: if (IS_SECURE(flags)) {
322: /* Sync BV and BR if entering secure mode */
323: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
324: cmds[index++] = CP_SYNC_THREADS | CP_CONCURRENT_BIN_DISABLE;
325: cmds[index++] = cp_type7_packet(CP_SET_SECURE_MODE, 1);
326: cmds[index++] = 1;
327: }
328:
329: memcpy(&cmds[index], in, dwords << 2);
330: index += dwords;
331:
332: profile_gpuaddr = adreno_profile_postib_processing(adreno_dev,
333: drawctxt, &dwords);
334:
335: if (profile_gpuaddr) {
336: cmds[index++] = cp_type7_packet(CP_INDIRECT_BUFFER_PFE, 3);
337: cmds[index++] = lower_32_bits(profile_gpuaddr);
338: cmds[index++] = upper_32_bits(profile_gpuaddr);
339: cmds[index++] = profile_dwords;
340: }
341:
342: if (test_bit(KGSL_FT_PAGEFAULT_GPUHALT_ENABLE, &device->mmu.pfpolicy))
343: cmds[index++] = cp_type7_packet(CP_WAIT_MEM_WRITES, 0);
344:
345: if (is_concurrent_binning(drawctxt)) {
346: u64 addr = SCRATCH_RB_GPU_ADDR(device, rb->id, bv_ts);
347:
348: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
349: cmds[index++] = CP_SET_THREAD_BV;
350:
351: /*
352: * Make sure the timestamp is committed once BV pipe is
353: * completely done with this submission.
354: */
355: cmds[index++] = cp_type7_packet(CP_EVENT_WRITE, 4);
356: cmds[index++] = CACHE_CLEAN | BIT(27);
357: cmds[index++] = lower_32_bits(addr);
358: cmds[index++] = upper_32_bits(addr);
359: cmds[index++] = rb->timestamp;
360:
361: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
362: cmds[index++] = CP_SET_THREAD_BR;
363:
364: /*
365: * This makes sure that BR doesn't race ahead and commit
366: * timestamp to memstore while BV is still processing
367: * this submission.
368: */
369: cmds[index++] = cp_type7_packet(CP_WAIT_TIMESTAMP, 4);
370: cmds[index++] = 0;
371: cmds[index++] = lower_32_bits(addr);
372: cmds[index++] = upper_32_bits(addr);
373: cmds[index++] = rb->timestamp;
374: }
375:
376: /*
377: * If this is an internal command, just write the ringbuffer timestamp,
378: * otherwise, write both
379: */
380: if (!drawctxt) {
381: cmds[index++] = cp_type7_packet(CP_EVENT_WRITE, 4);
382: cmds[index++] = CACHE_CLEAN | BIT(31) | BIT(27);
383: cmds[index++] = lower_32_bits(RB_EOPTIMESTAMP(device, rb));
384: cmds[index++] = upper_32_bits(RB_EOPTIMESTAMP(device, rb));
385: cmds[index++] = rb->timestamp;
386: } else {
387: cmds[index++] = cp_type7_packet(CP_EVENT_WRITE, 4);
388: cmds[index++] = CACHE_CLEAN | BIT(31) | BIT(27);
389: cmds[index++] = lower_32_bits(CTXT_EOPTIMESTAMP(device,
390: drawctxt));
391: cmds[index++] = upper_32_bits(CTXT_EOPTIMESTAMP(device,
392: drawctxt));
393: cmds[index++] = timestamp;
394:
395: cmds[index++] = cp_type7_packet(CP_EVENT_WRITE, 4);
396: cmds[index++] = CACHE_CLEAN | BIT(27);
397: cmds[index++] = lower_32_bits(RB_EOPTIMESTAMP(device, rb));
398: cmds[index++] = upper_32_bits(RB_EOPTIMESTAMP(device, rb));
399: cmds[index++] = rb->timestamp;
400: }
401:
402: if (IS_WFI(flags))
403: cmds[index++] = cp_type7_packet(CP_WAIT_FOR_IDLE, 0);
404:
405: if (IS_SECURE(flags)) {
406: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
407: cmds[index++] = CP_CONCURRENT_BIN_DISABLE;
408: cmds[index++] = cp_type7_packet(CP_SET_SECURE_MODE, 1);
409: cmds[index++] = 0;
410: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
411: cmds[index++] = CP_SYNC_THREADS;
412: }
413:
414: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
415: cmds[index++] = CP_SET_THREAD_BOTH;
416:
417: cmds[index++] = cp_type7_packet(CP_SET_MARKER, 1);
418: cmds[index++] = 0x100; /* IFPC enable */
419:
420: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
421: cmds[index++] = CP_SET_THREAD_BR;
422:
423: /* 10 dwords */
424: index += gen7_preemption_post_ibsubmit(adreno_dev, &cmds[index]);
425:
426: /* Adjust the thing for the number of bytes we actually wrote */
427: rb->_wptr -= (size - index);
428:
429: return gen7_ringbuffer_submit(rb, time);
430: }
431:
432: static u32 gen7_get_alwayson_counter(u32 *cmds, u64 gpuaddr)
433: {
434: cmds[0] = cp_type7_packet(CP_REG_TO_MEM, 3);
435: cmds[1] = GEN7_CP_ALWAYS_ON_COUNTER_LO | (1 << 30) | (2 << 18);
436: cmds[2] = lower_32_bits(gpuaddr);
437: cmds[3] = upper_32_bits(gpuaddr);
438:
439: return 4;
440: }
441:
442: static u32 gen7_get_alwayson_context(u32 *cmds, u64 gpuaddr)
443: {
444: cmds[0] = cp_type7_packet(CP_REG_TO_MEM, 3);
445: cmds[1] = GEN7_CP_ALWAYS_ON_CONTEXT_LO | (1 << 30) | (2 << 18);
446: cmds[2] = lower_32_bits(gpuaddr);
447: cmds[3] = upper_32_bits(gpuaddr);
448:
449: return 4;
450: }
451:
452: #define PROFILE_IB_DWORDS 4
453: #define PROFILE_IB_SLOTS (PAGE_SIZE / (PROFILE_IB_DWORDS << 2))
454:
455: static u64 gen7_get_user_profiling_ib(struct adreno_ringbuffer *rb,
456: struct kgsl_drawobj_cmd *cmdobj, u32 target_offset, u32 *cmds)
457: {
458: u32 offset, *ib, dwords;
459:
460: if (IS_ERR(rb->profile_desc))
461: return 0;
462:
463: offset = rb->profile_index * (PROFILE_IB_DWORDS << 2);
464: ib = rb->profile_desc->hostptr + offset;
465: dwords = gen7_get_alwayson_counter(ib,
466: cmdobj->profiling_buffer_gpuaddr + target_offset);
467:
468: cmds[0] = cp_type7_packet(CP_INDIRECT_BUFFER_PFE, 3);
469: cmds[1] = lower_32_bits(rb->profile_desc->gpuaddr + offset);
470: cmds[2] = upper_32_bits(rb->profile_desc->gpuaddr + offset);
471: cmds[3] = dwords;
472:
473: rb->profile_index = (rb->profile_index + 1) % PROFILE_IB_SLOTS;
474:
475: return 4;
476: }
477:
478: static int gen7_drawctxt_switch(struct adreno_device *adreno_dev,
479: struct adreno_ringbuffer *rb,
480: struct adreno_context *drawctxt)
481: {
482: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
483: int ret;
484:
485: if (rb->drawctxt_active == drawctxt)
486: return 0;
487:
488: if (kgsl_context_detached(&drawctxt->base))
489: return -ENOENT;
490:
491: if (!_kgsl_context_get(&drawctxt->base))
492: return -ENOENT;
MATCH LINES: 555, 572, 578, 585, 588, 596, 601, 605, 609, 625
543: struct list_head *tmp;
544:
545: list_for_each(tmp, &cmdobj->cmdlist)
546: numibs++;
547: }
548:
549: cmds = kvmalloc((GEN7_COMMAND_DWORDS + (numibs * 5)) << 2, GFP_KERNEL);
550: if (!cmds) {
551: ret = -ENOMEM;
552: goto done;
553: }
554:
555: cmds[index++] = cp_type7_packet(CP_NOP, 1);
556: cmds[index++] = START_IB_IDENTIFIER;
557:
558: /* Kernel profiling: 8 dwords */
559: if (IS_KERNEL_PROFILE(flags)) {
560: index += GEN7_KERNEL_PROFILE(adreno_dev, cmdobj, &cmds[index],
561: started);
562: index += GEN7_KERNEL_PROFILE_CONTEXT(adreno_dev, cmdobj, &cmds[index],
563: ctx_start);
564: }
565:
566: /* User profiling: 4 dwords */
567: if (IS_USER_PROFILE(flags))
568: index += GEN7_USER_PROFILE_IB(rb, cmdobj, &cmds[index],
569: gpu_ticks_submitted);
570:
571: if (is_concurrent_binning(drawctxt)) {
572: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
573: cmds[index++] = CP_SET_THREAD_BOTH;
574: }
575: if (numibs) {
576: struct kgsl_memobj_node *ib;
577:
578: cmds[index++] = cp_type7_packet(CP_SET_MARKER, 1);
579: cmds[index++] = 0x00d; /* IB1LIST start */
580:
581: list_for_each_entry(ib, &cmdobj->cmdlist, node) {
582: if (ib->priv & MEMOBJ_SKIP ||
583: (ib->flags & KGSL_CMDLIST_CTXTSWITCH_PREAMBLE &&
584: !IS_PREAMBLE(flags)))
585: cmds[index++] = cp_type7_packet(CP_NOP, 4);
586:
587: cmds[index++] =
588: cp_type7_packet(CP_INDIRECT_BUFFER_PFE, 3);
589: cmds[index++] = lower_32_bits(ib->gpuaddr);
590: cmds[index++] = upper_32_bits(ib->gpuaddr);
591:
592: /* Double check that IB_PRIV is never set */
593: cmds[index++] = (ib->size >> 2) & 0xfffff;
594: }
595:
596: cmds[index++] = cp_type7_packet(CP_SET_MARKER, 1);
597: cmds[index++] = 0x00e; /* IB1LIST end */
598: }
599:
600: if (is_concurrent_binning(drawctxt)) {
601: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
602: cmds[index++] = CP_SET_THREAD_BR;
603: }
604: /* CCU invalidate depth */
605: cmds[index++] = cp_type7_packet(CP_EVENT_WRITE, 1);
606: cmds[index++] = 24;
607:
608: /* CCU invalidate color */
609: cmds[index++] = cp_type7_packet(CP_EVENT_WRITE, 1);
610: cmds[index++] = 25;
611:
612: /* 8 dwords */
613: if (IS_KERNEL_PROFILE(flags)) {
614: index += GEN7_KERNEL_PROFILE(adreno_dev, cmdobj, &cmds[index],
615: retired);
616: index += GEN7_KERNEL_PROFILE_CONTEXT(adreno_dev, cmdobj, &cmds[index],
617: ctx_end);
618: }
619:
620: /* 4 dwords */
621: if (IS_USER_PROFILE(flags))
622: index += GEN7_USER_PROFILE_IB(rb, cmdobj, &cmds[index],
623: gpu_ticks_retired);
624:
625: cmds[index++] = cp_type7_packet(CP_NOP, 1);
626: cmds[index++] = END_IB_IDENTIFIER;
627:
628: ret = gen7_drawctxt_switch(adreno_dev, rb, drawctxt);
629:
630: /*
631: * In the unlikely event of an error in the drawctxt switch,
632: * treat it like a hang
633: */
634: if (ret) {
635: /*
636: * It is "normal" to get a -ENOSPC or a -ENOENT. Don't log it,
637: * the upper layers know how to handle it
638: */
639: if (ret != -ENOSPC && ret != -ENOENT)
640: dev_err(device->dev,
641: "Unable to switch draw context: %d\n", ret);
642: goto done;
643: }
644:
645: adreno_drawobj_set_constraint(device, drawobj);
646:
647: ret = gen7_ringbuffer_addcmds(adreno_dev, drawctxt->rb, drawctxt,
648: flags, cmds, index, drawobj->timestamp, time);
649:
--- FILE: \adreno_gen8.c | HITS: 6 ---
MATCH LINES: 1110, 1128
1098: .owner = THIS_MODULE,
1099: .open = simple_open,
1100: .read = nc_override_get,
1101: .write = nc_override_set,
1102: .llseek = noop_llseek,
1103: };
1104:
1105: void gen8_cp_init_cmds(struct adreno_device *adreno_dev, u32 *cmds)
1106: {
1107: u32 i = 0, mask = 0;
1108:
1109: /* Disable concurrent binning before sending CP init */
1110: cmds[i++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
1111: cmds[i++] = BIT(27);
1112:
1113: /* Use multiple HW contexts */
1114: mask |= BIT(0);
1115:
1116: /* Enable error detection */
1117: mask |= BIT(1);
1118:
1119: /* Set default reset state */
1120: mask |= BIT(3);
1121:
1122: /* Disable save/restore of performance counters across preemption */
1123: mask |= BIT(6);
1124:
1125: /* Enable the register init list with the spinlock */
1126: mask |= BIT(8);
1127:
1128: cmds[i++] = cp_type7_packet(CP_ME_INIT, 7);
1129:
1130: /* Enabled ordinal mask */
1131: cmds[i++] = mask;
1132: cmds[i++] = 0x00000003; /* Set number of HW contexts */
1133: cmds[i++] = 0x20000000; /* Enable error detection */
1134: cmds[i++] = 0x00000002; /* Operation mode mask */
1135:
1136: /* Register initialization list with spinlock */
1137: cmds[i++] = lower_32_bits(adreno_dev->pwrup_reglist->gpuaddr);
1138: cmds[i++] = upper_32_bits(adreno_dev->pwrup_reglist->gpuaddr);
1139: /*
1140: * Gen8 targets with concurrent binning are expected to have a dynamic
1141: * power up list with triplets which contains the pipe id in it.
1142: * Bit 31 of POWER_UP_REGISTER_LIST_LENGTH is reused here to let CP
1143: * know if the power up contains the triplets. If
1144: * REGISTER_INIT_LIST_WITH_SPINLOCK is set and bit 31 below is set,
1145: * CP expects a dynamic list with triplets.
1146: */
1147: cmds[i++] = BIT(31);
1148: }
1149:
1150: int gen8_fenced_write(struct adreno_device *adreno_dev, u32 offset,
1151: u32 value, u32 mask)
1152: {
MATCH LINES: 2414, 2428, 2436
2402: gen8_preemption_prepare_postamble(adreno_dev);
2403:
2404: if (kgsl_mmu_is_secured(&device->mmu))
2405: count += 3;
2406:
2407: if (preempt->postamble_bootup_len)
2408: count += 4;
2409:
2410: cmds = adreno_ringbuffer_allocspace(rb, count);
2411: if (IS_ERR(cmds))
2412: return PTR_ERR(cmds);
2413:
2414: *cmds++ = cp_type7_packet(CP_SET_PSEUDO_REGISTER,
2415: kgsl_mmu_is_secured(&device->mmu) ? 6 : 3);
2416:
2417: *cmds++ = SET_PSEUDO_PRIV_NON_SECURE_SAVE_ADDR;
2418: *cmds++ = lower_32_bits(rb->preemption_desc->gpuaddr);
2419: *cmds++ = upper_32_bits(rb->preemption_desc->gpuaddr);
2420:
2421: if (kgsl_mmu_is_secured(&device->mmu)) {
2422: *cmds++ = SET_PSEUDO_PRIV_SECURE_SAVE_ADDR;
2423: *cmds++ = lower_32_bits(rb->secure_preemption_desc->gpuaddr);
2424: *cmds++ = upper_32_bits(rb->secure_preemption_desc->gpuaddr);
2425: }
2426:
2427: if (preempt->postamble_bootup_len) {
2428: *cmds++ = cp_type7_packet(CP_SET_AMBLE, 3);
2429: *cmds++ = lower_32_bits(kmd_postamble_addr);
2430: *cmds++ = upper_32_bits(kmd_postamble_addr);
2431: *cmds++ = FIELD_PREP(GENMASK(22, 20), CP_KMD_AMBLE_TYPE)
2432: | (FIELD_PREP(GENMASK(19, 0),
2433: adreno_dev->preempt.postamble_bootup_len));
2434: }
2435:
2436: *cmds++ = cp_type7_packet(CP_CONTEXT_SWITCH_YIELD, 4);
2437: *cmds++ = 0;
2438: *cmds++ = 0;
2439: *cmds++ = 0;
2440: /* generate interrupt on preemption completion */
2441: *cmds++ = 0;
2442:
2443: ret = gen8_ringbuffer_submit(rb, NULL);
2444: if (!ret) {
2445: ret = adreno_spin_idle(adreno_dev, 2000);
2446: if (ret)
2447: gen8_spin_idle_debug(adreno_dev,
2448: "hw preemption initialization failed to idle\n");
2449: }
2450:
2451: return ret;
2452: }
2453:
2454: int gen8_rb_start(struct adreno_device *adreno_dev)
2455: {
2456: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev);
2457: struct adreno_firmware *fw = ADRENO_FW(adreno_dev, ADRENO_FW_SQE);
2458: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2459: struct adreno_ringbuffer *rb;
2460: u64 addr;
MATCH LINES: 2525
2513:
2514: /*
2515: * Take the GPU out of secure mode. Try the zap shader if it is loaded,
2516: * otherwise just try to write directly to the secure control register
2517: */
2518: if (!adreno_dev->zap_loaded)
2519: kgsl_regwrite(device, GEN8_RBBM_SECVID_TRUST_CNTL, 0);
2520: else {
2521: cmds = adreno_ringbuffer_allocspace(rb, 2);
2522: if (IS_ERR(cmds))
2523: return PTR_ERR(cmds);
2524:
2525: *cmds++ = cp_type7_packet(CP_SET_SECURE_MODE, 1);
2526: *cmds++ = 0;
2527:
2528: ret = gen8_ringbuffer_submit(rb, NULL);
2529: if (!ret) {
2530: ret = adreno_spin_idle(adreno_dev, 2000);
2531: if (ret) {
2532: gen8_spin_idle_debug(adreno_dev,
2533: "Switch to unsecure failed to idle\n");
2534: return ret;
2535: }
2536: }
2537: }
2538:
2539: /*
2540: * When the GPU is in secure mode, any writes to the RB_GC_GMEM_PROTECT
2541: * register are ignored. At this point, the GPU should be in unsecure
2542: * mode, so program the RB_GC_GMEM_PROTECT register.
2543: */
2544: gen8_set_gmem_protect(adreno_dev);
2545:
2546: /*
2547: * All registers must be written before this point so that we don't
2548: * miss any register programming when we patch the power up register
2549: * list.
--- FILE: \adreno_gen8_hfi.c | HITS: 1 ---
MATCH LINES: 282
270: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
271: unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
272: bool nmi = false;
273:
274: while (time_is_after_jiffies(timeout)) {
275: gmu_core_regread(device, offsetdwords, &val);
276: if ((val & mask) == expected_val)
277: return 0;
278:
279: /*
280: * If GMU firmware fails any assertion, error message is sent
281: * to KMD and NMI is triggered. So check if GMU is in NMI and
282: * timeout early. Bits [11:9] of A6XX_GMU_CM3_FW_INIT_RESULT
283: * contain GMU reset status. Non zero value here indicates that
284: * GMU reset is active, NMI handler would eventually complete
285: * and GMU would wait for recovery.
286: */
287: gmu_core_regread(device, GEN8_GMUCX_CM3_FW_INIT_RESULT, &val);
288: if (val & 0xE00) {
289: nmi = true;
290: break;
291: }
292:
293: usleep_range(10, 100);
294: }
295:
296: /* Check one last time */
297: gmu_core_regread(device, offsetdwords, &val);
298: if ((val & mask) == expected_val)
299: return 0;
300:
301: dev_err(GMU_PDEV_DEV(device),
302: "Reg poll %s: offset 0x%x, want 0x%x, got 0x%x\n",
303: nmi ? "abort" : "timeout", offsetdwords, expected_val,
304: val & mask);
305:
306: return -ETIMEDOUT;
--- FILE: \adreno_gen8_hwsched_hfi.c | HITS: 1 ---
MATCH LINES: 2821
2809:
2810: return ret;
2811: }
2812:
2813: static int send_switch_to_unsecure(struct adreno_device *adreno_dev)
2814: {
2815: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
2816: u32 cmds[3];
2817: int ret = 0;
2818:
2819: cmds[0] = CREATE_MSG_HDR(H2F_MSG_ISSUE_CMD_RAW, HFI_MSG_CMD);
2820:
2821: cmds[1] = cp_type7_packet(CP_SET_SECURE_MODE, 1);
2822: cmds[2] = 0;
2823:
2824: ret = submit_raw_cmds(adreno_dev, cmds, sizeof(cmds),
2825: "Switch to unsecure failed to idle\n");
2826:
2827: /* Save the header incase we need a warmboot debug */
2828: gmu->switch_to_unsec_hdr = cmds[0];
2829:
2830: return ret;
2831: }
2832:
2833: int gen8_hwsched_cp_init(struct adreno_device *adreno_dev)
2834: {
2835: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev);
2836: int ret;
2837:
2838: ret = cp_init(adreno_dev);
2839: if (ret)
2840: return ret;
2841:
2842: ret = adreno_zap_shader_load(adreno_dev, gen8_core->zap_name);
2843: if (ret)
2844: return ret;
2845:
--- FILE: \adreno_gen8_preempt.c | HITS: 9 ---
MATCH LINES: 474, 490, 492, 495
462: * First 28 dwords of the device scratch buffer are used to store shadow rb data.
463: * Reserve 15 dwords in the device scratch buffer from SCRATCH_POSTAMBLE_OFFSET for
464: * KMD postamble pm4 packets. This should be in *device->scratch* so that userspace
465: * cannot access it.
466: */
467: postamble = device->scratch->hostptr + SCRATCH_POSTAMBLE_OFFSET;
468:
469: /*
470: * Reserve 4 dwords in the scratch buffer for dynamic QOS control feature. To ensure QOS
471: * value is updated for first preemption, send it during bootup
472: */
473: if (gen8_core->qos_value) {
474: postamble[count++] = cp_type7_packet(CP_MEM_TO_REG, 3);
475: postamble[count++] = GEN8_RBBM_GBIF_CLIENT_QOS_CNTL;
476: postamble[count++] = lower_32_bits(PREEMPT_SCRATCH_ADDR(adreno_dev, QOS_VALUE_IDX));
477: postamble[count++] = upper_32_bits(PREEMPT_SCRATCH_ADDR(adreno_dev, QOS_VALUE_IDX));
478: }
479:
480: /*
481: * Since postambles are not preserved across slumber, necessary packets
482: * must be sent to GPU before first submission.
483: *
484: * If a packet needs to be sent before first submission, add it above this.
485: */
486: preempt->postamble_bootup_len = count;
487:
488: /* Insert PM4 packets in device scratch buffer to clear perfcounters */
489: if (!adreno_dev->perfcounter) {
490: postamble[count++] = cp_type4_packet(GEN8_RBBM_PERFCTR_SRAM_INIT_CMD, 1);
491: postamble[count++] = 0x1;
492: postamble[count++] = cp_type4_packet(GEN8_RBBM_SLICE_PERFCTR_SRAM_INIT_CMD, 1);
493: postamble[count++] = 0x1;
494:
495: postamble[count++] = cp_type7_packet(CP_WAIT_REG_MEM, 6);
496: postamble[count++] = 0x3;
497: postamble[count++] = GEN8_RBBM_PERFCTR_SRAM_INIT_STATUS;
498: postamble[count++] = 0x0;
499: postamble[count++] = 0x1;
500: postamble[count++] = 0x1;
501: postamble[count++] = 0x0;
502: }
503:
504: preempt->postamble_len = count;
505: }
506:
507: void gen8_preemption_schedule(struct adreno_device *adreno_dev)
508: {
509: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
510:
511: if (!adreno_is_preemption_enabled(adreno_dev))
512: return;
513:
514: kgsl_mutex_lock(&device->mutex);
515:
516: if (adreno_in_preempt_state(adreno_dev, ADRENO_PREEMPT_COMPLETE))
517: _gen8_preemption_done(adreno_dev);
518:
519: gen8_preemption_trigger(adreno_dev, false);
MATCH LINES: 538, 541
526: u32 *cmds)
527: {
528: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
529: u32 count = kgsl_mmu_is_secured(&device->mmu) ? 12 : 9;
530: u32 *cmds_orig = cmds;
531:
532: if (!adreno_is_preemption_enabled(adreno_dev))
533: return 0;
534:
535: if (test_and_set_bit(ADRENO_RB_SET_PSEUDO_DONE, &rb->flags))
536: goto done;
537:
538: *cmds++ = cp_type7_packet(CP_THREAD_CONTROL, 1);
539: *cmds++ = CP_SET_THREAD_BR;
540:
541: *cmds++ = cp_type7_packet(CP_SET_PSEUDO_REGISTER, count);
542:
543: /* NULL SMMU_INFO buffer - we track in KMD */
544: *cmds++ = SET_PSEUDO_SMMU_INFO;
545: cmds += cp_gpuaddr(adreno_dev, cmds, 0x0);
546:
547: *cmds++ = SET_PSEUDO_PRIV_NON_SECURE_SAVE_ADDR;
548: cmds += cp_gpuaddr(adreno_dev, cmds, rb->preemption_desc->gpuaddr);
549:
550: if (kgsl_mmu_is_secured(&device->mmu)) {
551: *cmds++ = SET_PSEUDO_PRIV_SECURE_SAVE_ADDR;
552: cmds += cp_gpuaddr(adreno_dev, cmds,
553: rb->secure_preemption_desc->gpuaddr);
554: }
555:
556: /*
557: * There is no need to specify this address when we are about to
558: * trigger preemption. This is because CP internally stores this
559: * address specified here in the CP_SET_PSEUDO_REGISTER payload to
560: * the context record and thus knows from where to restore
561: * the saved perfcounters for the new ringbuffer.
562: */
563: *cmds++ = SET_PSEUDO_COUNTER;
564: cmds += cp_gpuaddr(adreno_dev, cmds,
565: rb->perfcounter_save_restore_desc->gpuaddr);
MATCH LINES: 587, 594, 596
575:
576: u32 gen8_preemption_post_ibsubmit(struct adreno_device *adreno_dev,
577: u32 *cmds)
578: {
579: u32 index = 0;
580:
581: if (!adreno_is_preemption_enabled(adreno_dev))
582: return 0;
583:
584: if (adreno_dev->cur_rb) {
585: u64 dest = PREEMPT_SCRATCH_ADDR(adreno_dev, adreno_dev->cur_rb->id);
586:
587: cmds[index++] = cp_type7_packet(CP_MEM_WRITE, 4);
588: cmds[index++] = lower_32_bits(dest);
589: cmds[index++] = upper_32_bits(dest);
590: cmds[index++] = 0;
591: cmds[index++] = 0;
592: }
593:
594: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
595: cmds[index++] = CP_SET_THREAD_BOTH;
596: cmds[index++] = cp_type7_packet(CP_CONTEXT_SWITCH_YIELD, 4);
597: cmds[index++] = 0;
598: cmds[index++] = 0;
599: cmds[index++] = 1;
600: cmds[index++] = 0;
601:
602: return index;
603: }
604:
605: void gen8_preemption_start(struct adreno_device *adreno_dev)
606: {
607: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
608: struct kgsl_iommu *iommu = KGSL_IOMMU(device);
609: struct adreno_ringbuffer *rb;
610: u32 i;
611:
612: if (!adreno_is_preemption_enabled(adreno_dev))
613: return;
614:
615: /* Force the state to be clear */
616: adreno_set_preempt_state(adreno_dev, ADRENO_PREEMPT_NONE);
617:
618: if (kgsl_mmu_is_perprocess(&device->mmu)) {
619: /* smmu_info is allocated and mapped in gen8_preemption_iommu_init */
620: kgsl_sharedmem_writel(iommu->smmu_info,
--- FILE: \adreno_gen8_ringbuffer.c | HITS: 57 ---
MATCH LINES: 35, 40, 54, 71, 74, 83, 88, 91, 95, 100, 102, 111, 129, 133, 136, 143, 150, 156
23: struct adreno_ringbuffer *rb, struct adreno_context *drawctxt,
24: struct kgsl_pagetable *pagetable, u32 *cmds)
25: {
26: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
27: u64 ttbr0 = kgsl_mmu_pagetable_get_ttbr0(pagetable);
28: int count = 0;
29: u32 id = drawctxt ? drawctxt->base.id : 0;
30:
31: if (pagetable == device->mmu.defaultpagetable)
32: return 0;
33:
34: /* CP switches the pagetable and flushes the Caches */
35: cmds[count++] = cp_type7_packet(CP_SMMU_TABLE_UPDATE, 3);
36: cmds[count++] = lower_32_bits(ttbr0);
37: cmds[count++] = upper_32_bits(ttbr0);
38: cmds[count++] = id;
39:
40: cmds[count++] = cp_type7_packet(CP_MEM_WRITE, 5);
41: cmds[count++] = lower_32_bits(SCRATCH_RB_GPU_ADDR(device,
42: rb->id, ttbr0));
43: cmds[count++] = upper_32_bits(SCRATCH_RB_GPU_ADDR(device,
44: rb->id, ttbr0));
45: cmds[count++] = lower_32_bits(ttbr0);
46: cmds[count++] = upper_32_bits(ttbr0);
47: cmds[count++] = id;
48:
49: /*
50: * Sync both threads after switching pagetables and enable BR only
51: * to make sure BV doesn't race ahead while BR is still switching
52: * pagetables.
53: */
54: cmds[count++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
55: cmds[count++] = CP_SYNC_THREADS | CP_SET_THREAD_BR;
56:
57: return count;
58: }
59:
60: static int gen8_rb_context_switch(struct adreno_device *adreno_dev,
61: struct adreno_ringbuffer *rb,
62: struct adreno_context *drawctxt)
63: {
64: struct kgsl_pagetable *pagetable =
65: adreno_drawctxt_get_pagetable(drawctxt);
66: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
67: int count = 0;
68: u32 cmds[63];
69:
70: /* Sync both threads */
71: cmds[count++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
72: cmds[count++] = CP_SYNC_THREADS | CP_SET_THREAD_BOTH;
73: /* Reset context state */
74: cmds[count++] = cp_type7_packet(CP_RESET_CONTEXT_STATE, 1);
75: cmds[count++] = CP_RESET_GLOBAL_LOCAL_TS | CP_CLEAR_BV_BR_COUNTER |
76: CP_CLEAR_RESOURCE_TABLE | CP_CLEAR_ON_CHIP_TS;
77: /*
78: * Enable/disable concurrent binning for pagetable switch and
79: * set the thread to BR since only BR can execute the pagetable
80: * switch packets.
81: */
82: /* Sync both threads and enable BR only */
83: cmds[count++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
84: cmds[count++] = CP_SYNC_THREADS | CP_SET_THREAD_BR;
85:
86: if (adreno_drawctxt_get_pagetable(rb->drawctxt_active) != pagetable) {
87: /* Flush LRZ before every pagetable switch */
88: cmds[count++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
89: cmds[count++] = CP_SET_THREAD_BOTH;
90:
91: cmds[count++] = cp_type7_packet(CP_EVENT_WRITE, 1);
92: /* Add event ID for LRZ flush as packet payload */
93: cmds[count++] = LRZ_CACHE_FLUSH;
94:
95: cmds[count++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
96: cmds[count++] = CP_SYNC_THREADS | CP_SET_THREAD_BR;
97:
98: /* Clear performance counters during context switches */
99: if (!adreno_dev->perfcounter) {
100: cmds[count++] = cp_type4_packet(GEN8_RBBM_PERFCTR_SRAM_INIT_CMD, 1);
101: cmds[count++] = 0x1;
102: cmds[count++] = cp_type4_packet(GEN8_RBBM_SLICE_PERFCTR_SRAM_INIT_CMD, 1);
103: cmds[count++] = 0x1;
104: }
105:
106: count += gen8_rb_pagetable_switch(adreno_dev, rb,
107: drawctxt, pagetable, &cmds[count]);
108:
109: /* Wait for performance counter clear to finish */
110: if (!adreno_dev->perfcounter) {
111: cmds[count++] = cp_type7_packet(CP_WAIT_REG_MEM, 6);
112: cmds[count++] = 0x3;
113: cmds[count++] = GEN8_RBBM_PERFCTR_SRAM_INIT_STATUS;
114: cmds[count++] = 0x0;
115: cmds[count++] = 0x1;
116: cmds[count++] = 0x1;
117: cmds[count++] = 0x0;
118: }
119: } else {
120: struct kgsl_iommu *iommu = KGSL_IOMMU(device);
121:
122: u32 offset = GEN8_SMMU_BASE + (iommu->cb0_offset >> 2) + 0x0d;
123:
124: /*
125: * Set the CONTEXTIDR register to the current context id so we
126: * can use it in pagefault debugging. Unlike TTBR0 we don't
127: * need any special sequence or locking to change it
128: */
129: cmds[count++] = cp_type4_packet(offset, 1);
130: cmds[count++] = drawctxt->base.id;
131: }
132:
133: cmds[count++] = cp_type7_packet(CP_NOP, 1);
134: cmds[count++] = CONTEXT_TO_MEM_IDENTIFIER;
135:
136: cmds[count++] = cp_type7_packet(CP_MEM_WRITE, 3);
137: cmds[count++] = lower_32_bits(MEMSTORE_RB_GPU_ADDR(device, rb,
138: current_context));
139: cmds[count++] = upper_32_bits(MEMSTORE_RB_GPU_ADDR(device, rb,
140: current_context));
141: cmds[count++] = drawctxt->base.id;
142:
143: cmds[count++] = cp_type7_packet(CP_MEM_WRITE, 3);
144: cmds[count++] = lower_32_bits(MEMSTORE_ID_GPU_ADDR(device,
145: KGSL_MEMSTORE_GLOBAL, current_context));
146: cmds[count++] = upper_32_bits(MEMSTORE_ID_GPU_ADDR(device,
147: KGSL_MEMSTORE_GLOBAL, current_context));
148: cmds[count++] = drawctxt->base.id;
149:
150: cmds[count++] = cp_type7_packet(CP_EVENT_WRITE, 1);
151: cmds[count++] = 0x31;
152:
153: if (adreno_is_preemption_enabled(adreno_dev) && drawctxt->base.user_ctxt_record) {
154: u64 gpuaddr = drawctxt->base.user_ctxt_record->memdesc.gpuaddr;
155:
156: cmds[count++] = cp_type7_packet(CP_SET_PSEUDO_REGISTER, 3);
157: cmds[count++] = SET_PSEUDO_NON_PRIV_SAVE_ADDR;
158: cmds[count++] = lower_32_bits(gpuaddr);
159: cmds[count++] = upper_32_bits(gpuaddr);
160: }
161:
162: return gen8_ringbuffer_addcmds(adreno_dev, rb, NULL, F_NOTPROTECTED,
163: cmds, count, 0, NULL);
164: }
165:
166: #define RB_SOPTIMESTAMP(device, rb) \
167: MEMSTORE_RB_GPU_ADDR(device, rb, soptimestamp)
168: #define CTXT_SOPTIMESTAMP(device, drawctxt) \
169: MEMSTORE_ID_GPU_ADDR(device, (drawctxt)->base.id, soptimestamp)
170:
171: #define RB_EOPTIMESTAMP(device, rb) \
172: MEMSTORE_RB_GPU_ADDR(device, rb, eoptimestamp)
173: #define CTXT_EOPTIMESTAMP(device, drawctxt) \
174: MEMSTORE_ID_GPU_ADDR(device, (drawctxt)->base.id, eoptimestamp)
175:
176: int gen8_ringbuffer_submit(struct adreno_ringbuffer *rb,
177: struct adreno_submit_time *time)
178: {
179: struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
180: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
MATCH LINES: 282, 289, 292, 295, 303, 312, 319, 327, 334, 336, 347, 354, 359, 366, 372, 380, 392, 398, 406, 414, 417, 419, 421, 425, 428, 431, 445, 455, 479
270:
271: if (drawctxt)
272: drawctxt->internal_timestamp = rb->timestamp;
273:
274: /* All submissions are run with protected mode off due to APRIV */
275: flags &= ~F_NOTPROTECTED;
276:
277: cmds = adreno_ringbuffer_allocspace(rb, size);
278: if (IS_ERR(cmds))
279: return PTR_ERR(cmds);
280:
281: /* Identify the start of a command */
282: cmds[index++] = cp_type7_packet(CP_NOP, 1);
283: cmds[index++] = drawctxt ? CMD_IDENTIFIER : CMD_INTERNAL_IDENTIFIER;
284:
285: /* This is 25 dwords when drawctxt is not NULL and perfcounter needs to be zapped*/
286: index += gen8_preemption_pre_ibsubmit(adreno_dev, rb, drawctxt,
287: &cmds[index]);
288:
289: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
290: cmds[index++] = CP_SET_THREAD_BOTH;
291:
292: cmds[index++] = cp_type7_packet(CP_SET_MARKER, 1);
293: cmds[index++] = 0x101; /* IFPC disable */
294:
295: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
296: cmds[index++] = CP_SET_THREAD_BR;
297:
298: /*
299: * The POWER_CONTROL packet should always be after IFPC disable MARKER
300: * to avoid opcode errors
301: */
302: if (flags & F_MALU) {
303: cmds[index++] = cp_type7_packet(CP_POWER_CONTROL, 2);
304: cmds[index++] = 1; /* Control mALU power */
305: cmds[index++] = 1; /* Turn on mALU */
306: }
307:
308: profile_gpuaddr = adreno_profile_preib_processing(adreno_dev,
309: drawctxt, &profile_dwords);
310:
311: if (profile_gpuaddr) {
312: cmds[index++] = cp_type7_packet(CP_INDIRECT_BUFFER_PFE, 3);
313: cmds[index++] = lower_32_bits(profile_gpuaddr);
314: cmds[index++] = upper_32_bits(profile_gpuaddr);
315: cmds[index++] = profile_dwords;
316: }
317:
318: if (drawctxt) {
319: cmds[index++] = cp_type7_packet(CP_MEM_WRITE, 3);
320: cmds[index++] = lower_32_bits(CTXT_SOPTIMESTAMP(device,
321: drawctxt));
322: cmds[index++] = upper_32_bits(CTXT_SOPTIMESTAMP(device,
323: drawctxt));
324: cmds[index++] = timestamp;
325: }
326:
327: cmds[index++] = cp_type7_packet(CP_MEM_WRITE, 3);
328: cmds[index++] = lower_32_bits(RB_SOPTIMESTAMP(device, rb));
329: cmds[index++] = upper_32_bits(RB_SOPTIMESTAMP(device, rb));
330: cmds[index++] = rb->timestamp;
331:
332: if (IS_SECURE(flags)) {
333: /* Sync BV and BR if entering secure mode */
334: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
335: cmds[index++] = CP_SYNC_THREADS | CP_CONCURRENT_BIN_DISABLE;
336: cmds[index++] = cp_type7_packet(CP_SET_SECURE_MODE, 1);
337: cmds[index++] = 1;
338: }
339:
340: memcpy(&cmds[index], in, dwords << 2);
341: index += dwords;
342:
343: profile_gpuaddr = adreno_profile_postib_processing(adreno_dev,
344: drawctxt, &dwords);
345:
346: if (profile_gpuaddr) {
347: cmds[index++] = cp_type7_packet(CP_INDIRECT_BUFFER_PFE, 3);
348: cmds[index++] = lower_32_bits(profile_gpuaddr);
349: cmds[index++] = upper_32_bits(profile_gpuaddr);
350: cmds[index++] = profile_dwords;
351: }
352:
353: if (test_bit(KGSL_FT_PAGEFAULT_GPUHALT_ENABLE, &device->mmu.pfpolicy))
354: cmds[index++] = cp_type7_packet(CP_WAIT_MEM_WRITES, 0);
355:
356: if (is_concurrent_binning(drawctxt)) {
357: u64 addr = SCRATCH_RB_GPU_ADDR(device, rb->id, bv_ts);
358:
359: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
360: cmds[index++] = CP_SET_THREAD_BV;
361:
362: /*
363: * Make sure the timestamp is committed once BV pipe is
364: * completely done with this submission.
365: */
366: cmds[index++] = cp_type7_packet(CP_EVENT_WRITE, 4);
367: cmds[index++] = CACHE_CLEAN | BIT(27);
368: cmds[index++] = lower_32_bits(addr);
369: cmds[index++] = upper_32_bits(addr);
370: cmds[index++] = rb->timestamp;
371:
372: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
373: cmds[index++] = CP_SET_THREAD_BR;
374:
375: /*
376: * This makes sure that BR doesn't race ahead and commit
377: * timestamp to memstore while BV is still processing
378: * this submission.
379: */
380: cmds[index++] = cp_type7_packet(CP_WAIT_TIMESTAMP, 4);
381: cmds[index++] = 0;
382: cmds[index++] = lower_32_bits(addr);
383: cmds[index++] = upper_32_bits(addr);
384: cmds[index++] = rb->timestamp;
385: }
386:
387: /*
388: * If this is an internal command, just write the ringbuffer timestamp,
389: * otherwise, write both
390: */
391: if (!drawctxt) {
392: cmds[index++] = cp_type7_packet(CP_EVENT_WRITE, 4);
393: cmds[index++] = CACHE_CLEAN | BIT(31) | BIT(27);
394: cmds[index++] = lower_32_bits(RB_EOPTIMESTAMP(device, rb));
395: cmds[index++] = upper_32_bits(RB_EOPTIMESTAMP(device, rb));
396: cmds[index++] = rb->timestamp;
397: } else {
398: cmds[index++] = cp_type7_packet(CP_EVENT_WRITE, 4);
399: cmds[index++] = CACHE_CLEAN | BIT(31) | BIT(27);
400: cmds[index++] = lower_32_bits(CTXT_EOPTIMESTAMP(device,
401: drawctxt));
402: cmds[index++] = upper_32_bits(CTXT_EOPTIMESTAMP(device,
403: drawctxt));
404: cmds[index++] = timestamp;
405:
406: cmds[index++] = cp_type7_packet(CP_EVENT_WRITE, 4);
407: cmds[index++] = CACHE_CLEAN | BIT(27);
408: cmds[index++] = lower_32_bits(RB_EOPTIMESTAMP(device, rb));
409: cmds[index++] = upper_32_bits(RB_EOPTIMESTAMP(device, rb));
410: cmds[index++] = rb->timestamp;
411: }
412:
413: if (IS_WFI(flags))
414: cmds[index++] = cp_type7_packet(CP_WAIT_FOR_IDLE, 0);
415:
416: if (IS_SECURE(flags)) {
417: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
418: cmds[index++] = CP_CONCURRENT_BIN_DISABLE;
419: cmds[index++] = cp_type7_packet(CP_SET_SECURE_MODE, 1);
420: cmds[index++] = 0;
421: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
422: cmds[index++] = CP_SYNC_THREADS;
423: }
424:
425: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
426: cmds[index++] = CP_SET_THREAD_BOTH;
427:
428: cmds[index++] = cp_type7_packet(CP_SET_MARKER, 1);
429: cmds[index++] = 0x100; /* IFPC enable */
430:
431: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
432: cmds[index++] = CP_SET_THREAD_BR;
433:
434: /* 10 dwords */
435: index += gen8_preemption_post_ibsubmit(adreno_dev, &cmds[index]);
436:
437: /* Adjust the thing for the number of bytes we actually wrote */
438: rb->_wptr -= (size - index);
439:
440: return gen8_ringbuffer_submit(rb, time);
441: }
442:
443: static u32 gen8_get_alwayson_counter(u32 *cmds, u64 gpuaddr)
444: {
445: cmds[0] = cp_type7_packet(CP_REG_TO_MEM, 3);
446: cmds[1] = GEN8_CP_ALWAYS_ON_COUNTER_LO | (1 << 30) | (2 << 18);
447: cmds[2] = lower_32_bits(gpuaddr);
448: cmds[3] = upper_32_bits(gpuaddr);
449:
450: return 4;
451: }
452:
453: static u32 gen8_get_alwayson_context(u32 *cmds, u64 gpuaddr)
454: {
455: cmds[0] = cp_type7_packet(CP_REG_TO_MEM, 3);
456: cmds[1] = GEN8_CP_ALWAYS_ON_CONTEXT_LO | (1 << 30) | (2 << 18);
457: cmds[2] = lower_32_bits(gpuaddr);
458: cmds[3] = upper_32_bits(gpuaddr);
459:
460: return 4;
461: }
462:
463: #define PROFILE_IB_DWORDS 4
464: #define PROFILE_IB_SLOTS (PAGE_SIZE / (PROFILE_IB_DWORDS << 2))
465:
466: static u64 gen8_get_user_profiling_ib(struct adreno_ringbuffer *rb,
467: struct kgsl_drawobj_cmd *cmdobj, u32 target_offset, u32 *cmds)
468: {
469: u32 offset, *ib, dwords;
470:
471: if (IS_ERR(rb->profile_desc))
472: return 0;
473:
474: offset = rb->profile_index * (PROFILE_IB_DWORDS << 2);
475: ib = rb->profile_desc->hostptr + offset;
476: dwords = gen8_get_alwayson_counter(ib,
477: cmdobj->profiling_buffer_gpuaddr + target_offset);
478:
479: cmds[0] = cp_type7_packet(CP_INDIRECT_BUFFER_PFE, 3);
480: cmds[1] = lower_32_bits(rb->profile_desc->gpuaddr + offset);
481: cmds[2] = upper_32_bits(rb->profile_desc->gpuaddr + offset);
482: cmds[3] = dwords;
483:
484: rb->profile_index = (rb->profile_index + 1) % PROFILE_IB_SLOTS;
485:
486: return 4;
487: }
488:
489: static int gen8_drawctxt_switch(struct adreno_device *adreno_dev,
490: struct adreno_ringbuffer *rb,
491: struct adreno_context *drawctxt)
492: {
493: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
494: int ret;
495:
496: if (rb->drawctxt_active == drawctxt)
497: return 0;
498:
499: if (kgsl_context_detached(&drawctxt->base))
500: return -ENOENT;
501:
502: if (!_kgsl_context_get(&drawctxt->base))
503: return -ENOENT;
MATCH LINES: 566, 583, 589, 596, 599, 607, 612, 616, 620, 636
554: struct list_head *tmp;
555:
556: list_for_each(tmp, &cmdobj->cmdlist)
557: numibs++;
558: }
559:
560: cmds = kvmalloc((GEN8_COMMAND_DWORDS + (numibs * 5)) << 2, GFP_KERNEL);
561: if (!cmds) {
562: ret = -ENOMEM;
563: goto done;
564: }
565:
566: cmds[index++] = cp_type7_packet(CP_NOP, 1);
567: cmds[index++] = START_IB_IDENTIFIER;
568:
569: /* Kernel profiling: 8 dwords */
570: if (IS_KERNEL_PROFILE(flags)) {
571: index += GEN8_KERNEL_PROFILE(adreno_dev, cmdobj, &cmds[index],
572: started);
573: index += GEN8_KERNEL_PROFILE_CONTEXT(adreno_dev, cmdobj, &cmds[index],
574: ctx_start);
575: }
576:
577: /* User profiling: 4 dwords */
578: if (IS_USER_PROFILE(flags))
579: index += GEN8_USER_PROFILE_IB(rb, cmdobj, &cmds[index],
580: gpu_ticks_submitted);
581:
582: if (is_concurrent_binning(drawctxt)) {
583: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
584: cmds[index++] = CP_SET_THREAD_BOTH;
585: }
586: if (numibs) {
587: struct kgsl_memobj_node *ib;
588:
589: cmds[index++] = cp_type7_packet(CP_SET_MARKER, 1);
590: cmds[index++] = 0x00d; /* IB1LIST start */
591:
592: list_for_each_entry(ib, &cmdobj->cmdlist, node) {
593: if (ib->priv & MEMOBJ_SKIP ||
594: (ib->flags & KGSL_CMDLIST_CTXTSWITCH_PREAMBLE &&
595: !IS_PREAMBLE(flags)))
596: cmds[index++] = cp_type7_packet(CP_NOP, 4);
597:
598: cmds[index++] =
599: cp_type7_packet(CP_INDIRECT_BUFFER_PFE, 3);
600: cmds[index++] = lower_32_bits(ib->gpuaddr);
601: cmds[index++] = upper_32_bits(ib->gpuaddr);
602:
603: /* Double check that IB_PRIV is never set */
604: cmds[index++] = (ib->size >> 2) & 0xfffff;
605: }
606:
607: cmds[index++] = cp_type7_packet(CP_SET_MARKER, 1);
608: cmds[index++] = 0x00e; /* IB1LIST end */
609: }
610:
611: if (is_concurrent_binning(drawctxt)) {
612: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
613: cmds[index++] = CP_SET_THREAD_BR;
614: }
615: /* CCU invalidate depth */
616: cmds[index++] = cp_type7_packet(CP_EVENT_WRITE, 1);
617: cmds[index++] = 24;
618:
619: /* CCU invalidate color */
620: cmds[index++] = cp_type7_packet(CP_EVENT_WRITE, 1);
621: cmds[index++] = 25;
622:
623: /* 8 dwords */
624: if (IS_KERNEL_PROFILE(flags)) {
625: index += GEN8_KERNEL_PROFILE(adreno_dev, cmdobj, &cmds[index],
626: retired);
627: index += GEN8_KERNEL_PROFILE_CONTEXT(adreno_dev, cmdobj, &cmds[index],
628: ctx_end);
629: }
630:
631: /* 4 dwords */
632: if (IS_USER_PROFILE(flags))
633: index += GEN8_USER_PROFILE_IB(rb, cmdobj, &cmds[index],
634: gpu_ticks_retired);
635:
636: cmds[index++] = cp_type7_packet(CP_NOP, 1);
637: cmds[index++] = END_IB_IDENTIFIER;
638:
639: ret = gen8_drawctxt_switch(adreno_dev, rb, drawctxt);
640:
641: /*
642: * In the unlikely event of an error in the drawctxt switch,
643: * treat it like a hang
644: */
645: if (ret) {
646: /*
647: * It is "normal" to get a -ENOSPC or a -ENOENT. Don't log it,
648: * the upper layers know how to handle it
649: */
650: if (ret != -ENOSPC && ret != -ENOENT)
651: dev_err(device->dev,
652: "Unable to switch draw context: %d\n", ret);
653: goto done;
654: }
655:
656: adreno_drawobj_set_constraint(device, drawobj);
657:
658: if (drawobj->flags & KGSL_DRAWOBJ_USES_MALU)
659: flags |= F_MALU;
660:
--- FILE: \adreno_pm4types.h | HITS: 7 ---
MATCH LINES: 166, 174
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)
175: {
176: return CP_TYPE7_PKT | ((cnt) << 0) |
177: (pm4_calc_odd_parity_bit(cnt) << 15) |
178: (((opcode) & 0x7F) << 16) |
179: ((pm4_calc_odd_parity_bit(opcode) << 23));
180:
181: }
182:
183: #define pkt_is_type4(pkt) \
184: ((((pkt) & 0xF0000000) == CP_TYPE4_PKT) && \
185: ((((pkt) >> 27) & 0x1) == \
186: pm4_calc_odd_parity_bit(cp_type4_base_index_one_reg_wr(pkt))) \
187: && ((((pkt) >> 7) & 0x1) == \
188: pm4_calc_odd_parity_bit(type4_pkt_size(pkt))))
189:
190: #define cp_type4_base_index_one_reg_wr(pkt) (((pkt) >> 8) & 0x7FFFF)
191: #define type4_pkt_size(pkt) ((pkt) & 0x7F)
192:
193: #define pkt_is_type7(pkt) \
194: ((((pkt) & 0xF0000000) == CP_TYPE7_PKT) && \
195: (((pkt) & 0x0F000000) == 0) && \
196: ((((pkt) >> 23) & 0x1) == \
197: pm4_calc_odd_parity_bit(cp_type7_opcode(pkt))) \
198: && ((((pkt) >> 15) & 0x1) == \
MATCH LINES: 220, 234
208: #define CP_REG(reg) ((0x4 << 16) | (SUBBLOCK_OFFSET(reg)))
209:
210: /**
211: * cp_packet - Generic CP packet to support different opcodes on
212: * different GPU cores.
213: * @adreno_dev: The adreno device
214: * @opcode: Operation for cp packet
215: * @size: size for cp packet
216: */
217: static inline uint cp_packet(struct adreno_device *adreno_dev,
218: int opcode, uint size)
219: {
220: return cp_type7_packet(opcode, size);
221: }
222:
223: /**
224: * cp_mem_packet - Generic CP memory packet to support different
225: * opcodes on different GPU cores.
226: * @adreno_dev: The adreno device
227: * @opcode: mem operation for cp packet
228: * @size: size for cp packet
229: * @num_mem: num of mem access
230: */
231: static inline uint cp_mem_packet(struct adreno_device *adreno_dev,
232: int opcode, uint size, uint num_mem)
233: {
234: return cp_type7_packet(opcode, size + num_mem);
235: }
236:
237: /* Return 1 if the command is an indirect buffer of any kind */
238: static inline int adreno_cmd_is_ib(struct adreno_device *adreno_dev,
239: unsigned int cmd)
240: {
241: return cmd == cp_mem_packet(adreno_dev,
242: CP_INDIRECT_BUFFER_PFE, 2, 1) ||
243: cmd == cp_mem_packet(adreno_dev,
244: CP_INDIRECT_BUFFER_PFD, 2, 1) ||
245: cmd == cp_mem_packet(adreno_dev,
246: CP_COND_INDIRECT_BUFFER_PFE, 2, 1) ||
247: cmd == cp_mem_packet(adreno_dev,
248: CP_COND_INDIRECT_BUFFER_PFD, 2, 1);
249: }
250:
251: /**
252: * cp_gpuaddr - Generic function to add 64bit and 32bit gpuaddr
253: * to pm4 commands
254: * @adreno_dev: The adreno device
255: * @cmds: command pointer to add gpuaddr
256: * @gpuaddr: gpuaddr to add
257: */
258: static inline uint cp_gpuaddr(struct adreno_device *adreno_dev,
MATCH LINES: 278, 291, 305
266: return cmds - start;
267: }
268:
269: /**
270: * cp_register - Generic function for gpu register operation
271: * @adreno_dev: The adreno device
272: * @reg: GPU register
273: * @size: count for PM4 operation
274: */
275: static inline uint cp_register(struct adreno_device *adreno_dev,
276: unsigned int reg, unsigned int size)
277: {
278: return cp_type4_packet(reg, size);
279: }
280:
281: /**
282: * cp_wait_for_me - common function for WAIT_FOR_ME
283: * @adreno_dev: The adreno device
284: * @cmds: command pointer to add gpuaddr
285: */
286: static inline uint cp_wait_for_me(struct adreno_device *adreno_dev,
287: uint *cmds)
288: {
289: uint *start = cmds;
290:
291: *cmds++ = cp_type7_packet(CP_WAIT_FOR_ME, 0);
292: return cmds - start;
293: }
294:
295: /**
296: * cp_wait_for_idle - common function for WAIT_FOR_IDLE
297: * @adreno_dev: The adreno device
298: * @cmds: command pointer to add gpuaddr
299: */
300: static inline uint cp_wait_for_idle(struct adreno_device *adreno_dev,
301: uint *cmds)
302: {
303: uint *start = cmds;
304:
305: *cmds++ = cp_type7_packet(CP_WAIT_FOR_IDLE, 0);
306: return cmds - start;
307: }
308:
309: static inline u32 cp_protected_mode(struct adreno_device *adreno_dev,
310: u32 *cmds, int on)
311: {
312: cmds[0] = cp_packet(adreno_dev, CP_SET_PROTECTED_MODE, 1);
313: cmds[1] = on;
314:
315: return 2;
316: }
317:
318: static inline u32 cp_identifier(struct adreno_device *adreno_dev,
319: u32 *cmds, u32 id)
320: {
321: cmds[0] = cp_packet(adreno_dev, CP_NOP, 1);
322: cmds[1] = id;
323:
324: return 2;
325: }
326:
327: #endif /* __ADRENO_PM4TYPES_H */
--- FILE: \kgsl_gmu_core.c | HITS: 6 ---
MATCH LINES: 22, 23, 26, 27, 28, 29
10: #include <linux/of_platform.h>
11: #include <linux/pm_opp.h>
12:
13: #include "adreno.h"
14: #include "adreno_trace.h"
15: #include "kgsl_device.h"
16: #include "kgsl_gmu_core.h"
17: #include "kgsl_power_trace.h"
18: #include "kgsl_sync.h"
19: #include "kgsl_trace.h"
20:
21: static const struct of_device_id gmu_match_table[] = {
22: { .compatible = "qcom,gpu-gmu", .data = &a6xx_gmu_driver },
23: { .compatible = "qcom,gpu-rgmu", .data = &a6xx_rgmu_driver },
24: { .compatible = "qcom,gen7-gmu", .data = &gen7_gmu_driver },
25: { .compatible = "qcom,gen8-gmu", .data = &gen8_gmu_driver },
26: { .compatible = "qcom,adreno-gmu-623.0", .data = &a6xx_gmu_driver },
27: { .compatible = "qcom,adreno-gmu-663.0", .data = &a6xx_gmu_driver },
28: { .compatible = "qcom,adreno-gmu-635.0", .data = &a6xx_gmu_driver },
29: { .compatible = "qcom,adreno-rgmu", .data = &a6xx_rgmu_driver },
30: { .compatible = "qcom,adreno-gmu-x185.1", .data = &gen7_gmu_driver },
31: { .compatible = "qcom,adreno-gmu-x145.0", .data = &gen7_gmu_driver },
32: { .compatible = "qcom,adreno-gmu-x285.1", .data = &gen8_gmu_driver },
33: { .compatible = "qcom,adreno-gmu-x285.0", .data = &gen8_gmu_driver },
34: { .compatible = "qcom,adreno-gmu-x290.1", .data = &gen8_gmu_driver },
35: { .compatible = "qcom,adreno-gmu-722.0", .data = &gen7_gmu_driver },
36: { .compatible = "qcom,adreno-gmu-753.1", .data = &gen7_gmu_driver },
37: { .compatible = "qcom,adreno-gmu-830.1", .data = &gen8_gmu_driver },
38: { .compatible = "qcom,adreno-gmu-840.1", .data = &gen8_gmu_driver },
39: { .compatible = "qcom,adreno-gmu-845.0", .data = &gen8_gmu_driver },
40: { .compatible = "qcom,adreno-gmu-850.1", .data = &gen8_gmu_driver },
41: {},
42: };
43:
44: void __init gmu_core_register(void)
45: {
46: const struct of_device_id *match;
47: struct device_node *node;
48:
49: node = of_find_matching_node_and_match(NULL, gmu_match_table,
50: &match);
51: if (!node)
52: return;
53:
--- FILE: \kgsl_gmu_core.h | HITS: 2 ---
MATCH LINES: 629, 630
617: /** @num_hub_freqs: Number of entries in the @hub_freqs array */
618: int num_hub_freqs;
619: /** @cur_hub_level: Tracks current frequency level for hub clock */
620: u32 cur_hub_level;
621: /** @gpu_pwrscale_enable: Flag to toggle GMU based DCVS pwrscale */
622: bool gpu_pwrscale_enable;
623: /** @vrb: GMU virtual register bank memory */
624: struct kgsl_memdesc *vrb;
625: /** @trace: gmu trace container */
626: struct kgsl_gmu_trace trace;
627: };
628:
629: extern struct platform_driver a6xx_gmu_driver;
630: extern struct platform_driver a6xx_rgmu_driver;
631: extern struct platform_driver gen7_gmu_driver;
632: extern struct platform_driver gen8_gmu_driver;
633:
634: /* GMU core functions */
635:
636: void __init gmu_core_register(void);
637: void gmu_core_unregister(void);
638:
639: bool gmu_core_gpmu_isenabled(struct kgsl_device *device);
640: bool gmu_core_scales_bandwidth(struct kgsl_device *device);
641: bool gmu_core_isenabled(struct kgsl_device *device);
642: int gmu_core_dev_acd_set(struct kgsl_device *device, bool val);
643: void gmu_core_regread(struct kgsl_device *device, unsigned int offsetwords,
644: unsigned int *value);
645: void gmu_core_regwrite(struct kgsl_device *device, unsigned int offsetwords,
646: unsigned int value);
647:
648: /**
649: * gmu_core_blkwrite - Do a bulk I/O write to GMU
650: * @device: Pointer to the kgsl device
651: * @offsetwords: Destination dword offset
652: * @buffer: Pointer to the source buffer
653: * @size: Number of bytes to copy
654: *
--- FILE: \kgsl_util.h | HITS: 1 ---
MATCH LINES: 14
2: /*
3: * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
5: */
6:
7: #ifndef _KGSL_UTIL_H_
8: #define _KGSL_UTIL_H_
9:
10: #include <linux/version.h>
11:
12: #define KGSL_DRIVER "kgsl_driver"
13: #define KGSL_ADRENO_DEVICE "kgsl_adreno_device"
14: #define KGSL_A6XX_DEVICE "kgsl_a6xx_device"
15: #define KGSL_GEN7_DEVICE "kgsl_gen7_device"
16: #define KGSL_HWSCHED_DEVICE "kgsl_hwsched_device"
17: #define KGSL_GEN8_DEVICE "kgsl_gen8_device"
18:
19: #define KGSL_SCRATCH_ENTRY "scratch"
20: #define KGSL_MEMSTORE_ENTRY "memstore"
21: #define KGSL_GMU_LOG_ENTRY "kgsl_gmu_log"
22: #define KGSL_GMU_TRACE_ENTRY "kgsl_gmu_trace"
23: #define KGSL_HFIMEM_ENTRY "kgsl_hfi_mem"
24: #define KGSL_GMU_DUMPMEM_ENTRY "kgsl_gmu_dump_mem"
25: #define KGSL_GMU_RB_ENTRY "gmu_rb"
26: #define KGSL_GMU_KERNEL_PROF_ENTRY "gmu_kernel_profiling"
27: #define KGSL_GMU_USER_PROF_ENTRY "gmu_user_profiling"
28: #define KGSL_GMU_CMD_BUFFER_ENTRY "gmu_cmd_buffer"
29: #define KGSL_HFI_BIG_IB_ENTRY "kgsl_hfi_big_ib"
30: #define KGSL_HFI_BIG_IB_REC_ENTRY "kgsl_hfi_big_ib_rec"
31: #define KGSL_ADRENO_CTX_ENTRY "kgsl_adreno_ctx"
32: #define KGSL_PROC_PRIV_ENTRY "kgsl_proc_priv"
33: #define KGSL_PGTABLE_ENTRY "kgsl_pgtable"
34: #define KGSL_GMU_VRB_ENTRY "kgsl_gmu_vrb"
35: #define KGSL_SYNC_FENCE_ENTRY "kgsl_sync_fence"
36: #define KGSL_SYNC_TIMELINE_ENTRY "kgsl_sync_timeline"
37: #define KGSL_PAGE_POOL_ENTRY "kgsl_page_pool"
38: #define KGSL_ADRENO_TZ_DATA_ENTRY "kgsl_adreno_tz_data"
TOTAL MATCHES: 5769
==========================================================================================
SUBSYSTEM: POWER_AND_CLOCK
==========================================================================================
--- FILE: \a6xx_reg.h | HITS: 30 ---
MATCH LINES: 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, 1055, 1056
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
--- FILE: \adreno-gpulist.h | HITS: 49 ---
MATCH LINES: 735
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 */
MATCH LINES: 835, 863, 891
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 = {
MATCH LINES: 1050, 1082, 1115
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,
MATCH LINES: 1259
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[] = {
MATCH LINES: 1339, 1369, 1400
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[] = {
MATCH LINES: 1477, 1505
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 = {
MATCH LINES: 1682, 1714, 1748
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,
MATCH LINES: 1813
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",
MATCH LINES: 1856
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,
MATCH LINES: 2161, 2197
2149: { GEN7_CP_PROTECT_REG + 43, 0x1f860, 0x1f860, 1 },
2150: { GEN7_CP_PROTECT_REG + 44, 0x1f87f, 0x1f8a2, 1 },
2151: { GEN7_CP_PROTECT_REG + 47, 0x1f8c0, 0x1f8c0, 1 },
2152: { 0 },
2153: };
2154:
2155: static const struct adreno_gen7_core adreno_gpu_core_gen7_0_0 = {
2156: .base = {
2157: DEFINE_ADRENO_REV(ADRENO_REV_GEN7_0_0,
2158: UINT_MAX, UINT_MAX, UINT_MAX, 0),
2159: .compatible = "qcom,adreno-gpu-gen7-0-0",
2160: .features = ADRENO_APRIV | ADRENO_IOCOHERENT |
2161: ADRENO_CONTENT_PROTECTION | ADRENO_IFPC |
2162: ADRENO_ACD | ADRENO_L3_VOTE | ADRENO_BCL |
2163: ADRENO_PREEMPTION,
2164: .gpudev = &adreno_gen7_gmu_gpudev.base,
2165: .perfcounters = &adreno_gen7_perfcounters,
2166: .uche_gmem_alignment = 0,
2167: .gmem_size = SZ_2M,
2168: .bus_width = 32,
2169: .snapshot_size = SZ_4M,
2170: .highest_bank_bit = 16,
2171: },
2172: .gmu_fw_version = GMU_VERSION(4, 0, 0),
2173: .sqefw_name = "a730_sqe.fw",
2174: .gmufw_name = "gmu_gen70000.bin",
2175: .gmufw_bak_name = "c500_gmu.bin",
2176: .zap_name = "a730_zap.mdt",
2177: .hwcg = gen7_0_0_hwcg_regs,
2178: .hwcg_count = ARRAY_SIZE(gen7_0_0_hwcg_regs),
2179: .ao_hwcg = gen7_0_0_ao_hwcg_regs,
2180: .ao_hwcg_count = ARRAY_SIZE(gen7_0_0_ao_hwcg_regs),
2181: .gbif = gen7_0_0_gbif_cx_regs,
2182: .gbif_count = ARRAY_SIZE(gen7_0_0_gbif_cx_regs),
2183: .hang_detect_cycles = 0xcfffff,
2184: .protected_regs = gen7_0_0_protected_regs,
2185: .gen7_snapshot_block_list = &gen7_0_0_snapshot_block_list,
2186: .preempt_level = 1,
2187: .ctxt_record_size = (2860 * SZ_1K),
2188: .fast_bus_hint = true,
2189: };
2190:
2191: static const struct adreno_gen7_core adreno_gpu_core_gen7_0_1 = {
2192: .base = {
2193: DEFINE_ADRENO_REV(ADRENO_REV_GEN7_0_1,
2194: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
2195: .compatible = "qcom,adreno-gpu-gen7-0-1",
2196: .features = ADRENO_APRIV | ADRENO_IOCOHERENT |
2197: ADRENO_CONTENT_PROTECTION | ADRENO_IFPC |
2198: ADRENO_ACD | ADRENO_L3_VOTE | ADRENO_BCL |
2199: ADRENO_PREEMPTION,
2200: .gpudev = &adreno_gen7_gmu_gpudev.base,
2201: .perfcounters = &adreno_gen7_perfcounters,
2202: .uche_gmem_alignment = 0,
2203: .gmem_size = SZ_2M,
2204: .bus_width = 32,
2205: .snapshot_size = SZ_4M,
2206: .highest_bank_bit = 16,
2207: },
2208: .gmu_fw_version = GMU_VERSION(4, 0, 0),
2209: .sqefw_name = "a730_sqe.fw",
2210: .gmufw_name = "gmu_gen70000.bin",
2211: .gmufw_bak_name = "c500_gmu.bin",
2212: .zap_name = "a730_zap.mdt",
2213: .hwcg = gen7_0_0_hwcg_regs,
2214: .hwcg_count = ARRAY_SIZE(gen7_0_0_hwcg_regs),
2215: .ao_hwcg = gen7_0_0_ao_hwcg_regs,
2216: .ao_hwcg_count = ARRAY_SIZE(gen7_0_0_ao_hwcg_regs),
2217: .gbif = gen7_0_0_gbif_cx_regs,
2218: .gbif_count = ARRAY_SIZE(gen7_0_0_gbif_cx_regs),
2219: .hang_detect_cycles = 0xcfffff,
2220: .protected_regs = gen7_0_0_protected_regs,
2221: .gen7_snapshot_block_list = &gen7_0_0_snapshot_block_list,
MATCH LINES: 2416, 2453, 2491, 2525
2404: { GEN7_CP_PROTECT_REG + 43, 0x1f844, 0x1f8b7, 0 },
2405: { GEN7_CP_PROTECT_REG + 44, 0x1f860, 0x1f868, 1 },
2406: { GEN7_CP_PROTECT_REG + 45, 0x1f87f, 0x1f8a2, 1 },
2407: { GEN7_CP_PROTECT_REG + 47, 0x1f8b8, 0x1f8b8, 1 },
2408: { 0 },
2409: };
2410:
2411: static const struct adreno_gen7_core adreno_gpu_core_gen7_2_0 = {
2412: .base = {
2413: DEFINE_ADRENO_REV(ADRENO_REV_GEN7_2_0,
2414: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
2415: .compatible = "qcom,adreno-gpu-gen7-2-0",
2416: .features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_IFPC |
2417: ADRENO_CONTENT_PROTECTION | ADRENO_ACD |
2418: ADRENO_LPAC | ADRENO_BCL | ADRENO_L3_VOTE |
2419: ADRENO_PREEMPTION | ADRENO_DMS,
2420: .gpudev = &adreno_gen7_hwsched_gpudev.base,
2421: .perfcounters = &adreno_gen7_2_0_perfcounters,
2422: .uche_gmem_alignment = SZ_16M,
2423: .gmem_size = 3 * SZ_1M,
2424: .bus_width = 32,
2425: .snapshot_size = SZ_8M,
2426: .highest_bank_bit = 16,
2427: },
2428: .gmu_fw_version = GMU_VERSION(4, 1, 0),
2429: .sqefw_name = "a740_sqe.fw",
2430: .gmufw_name = "gmu_gen70200.bin",
2431: .zap_name = "a740_zap.mbn",
2432: .hwcg = gen7_2_0_hwcg_regs,
2433: .hwcg_count = ARRAY_SIZE(gen7_2_0_hwcg_regs),
2434: .ao_hwcg = gen7_2_0_ao_hwcg_regs,
2435: .ao_hwcg_count = ARRAY_SIZE(gen7_2_0_ao_hwcg_regs),
2436: .gbif = gen7_2_0_gbif_cx_regs,
2437: .gbif_count = ARRAY_SIZE(gen7_2_0_gbif_cx_regs),
2438: .hang_detect_cycles = 0xcfffff,
2439: .protected_regs = gen7_2_0_protected_regs,
2440: .gmu_hub_clk_freq = 200000000,
2441: .gen7_snapshot_block_list = &gen7_2_0_snapshot_block_list,
2442: .bcl_data = 1,
2443: .preempt_level = 1,
2444: .ctxt_record_size = (4192 * SZ_1K),
2445: .fast_bus_hint = true,
2446: };
2447:
2448: static const struct adreno_gen7_core adreno_gpu_core_gen7_2_1 = {
2449: .base = {
2450: DEFINE_ADRENO_REV(ADRENO_REV_GEN7_2_1,
2451: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
2452: .compatible = "qcom,adreno-gpu-gen7-2-1",
2453: .features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_IFPC |
2454: ADRENO_CONTENT_PROTECTION | ADRENO_LPAC |
2455: ADRENO_BCL | ADRENO_L3_VOTE | ADRENO_ACD |
2456: ADRENO_PREEMPTION | ADRENO_DMS,
2457: .gpudev = &adreno_gen7_hwsched_gpudev.base,
2458: .perfcounters = &adreno_gen7_2_0_perfcounters,
2459: .uche_gmem_alignment = SZ_16M,
2460: .gmem_size = 3 * SZ_1M,
2461: .bus_width = 32,
2462: .snapshot_size = SZ_8M,
2463: .highest_bank_bit = 16,
2464: },
2465: .gmu_fw_version = GMU_VERSION(4, 1, 0),
2466: .sqefw_name = "a740_sqe.fw",
2467: .gmufw_name = "gmu_gen70200.bin",
2468: .zap_name = "a740_zap.mbn",
2469: .hwcg = gen7_2_0_hwcg_regs,
2470: .hwcg_count = ARRAY_SIZE(gen7_2_0_hwcg_regs),
2471: .ao_hwcg = gen7_2_0_ao_hwcg_regs,
2472: .ao_hwcg_count = ARRAY_SIZE(gen7_2_0_ao_hwcg_regs),
2473: .gbif = gen7_2_0_gbif_cx_regs,
2474: .gbif_count = ARRAY_SIZE(gen7_2_0_gbif_cx_regs),
2475: .hang_detect_cycles = 0xcfffff,
2476: .protected_regs = gen7_2_0_protected_regs,
2477: .gmu_hub_clk_freq = 200000000,
2478: .gen7_snapshot_block_list = &gen7_2_0_snapshot_block_list,
2479: .bcl_data = 1,
2480: .preempt_level = 1,
2481: .ctxt_record_size = (4192 * SZ_1K),
2482: .fast_bus_hint = true,
2483: };
2484:
2485: static const struct adreno_gen7_core adreno_gpu_core_gen7_3_0 = {
2486: .base = {
2487: DEFINE_ADRENO_REV(ADRENO_REV_GEN7_3_0,
2488: UINT_MAX, UINT_MAX, UINT_MAX, 0),
2489: .compatible = "qcom,adreno-gpu-gen7-3-0",
2490: .features = ADRENO_APRIV | ADRENO_IOCOHERENT |
2491: ADRENO_CONTENT_PROTECTION | ADRENO_IFPC |
2492: ADRENO_PREEMPTION | ADRENO_BCL | ADRENO_ACD,
2493: .gpudev = &adreno_gen7_gmu_gpudev.base,
2494: .perfcounters = &adreno_gen7_no_cb_perfcounters,
2495: .uche_gmem_alignment = SZ_16M,
2496: .gmem_size = SZ_512K,
2497: .bus_width = 32,
2498: .snapshot_size = SZ_2M,
2499: .highest_bank_bit = 15,
2500: },
2501: .gmu_fw_version = GMU_VERSION(4, 0, 0),
2502: .sqefw_name = "a710_sqe.fw",
2503: .gmufw_name = "gmu_gen70000.bin",
2504: .zap_name = "a710_zap.mdt",
2505: .hwcg = gen7_3_0_hwcg_regs,
2506: .hwcg_count = ARRAY_SIZE(gen7_3_0_hwcg_regs),
2507: .ao_hwcg = gen7_0_0_ao_hwcg_regs,
2508: .ao_hwcg_count = ARRAY_SIZE(gen7_0_0_ao_hwcg_regs),
2509: .gbif = gen7_0_0_gbif_cx_regs,
2510: .gbif_count = ARRAY_SIZE(gen7_0_0_gbif_cx_regs),
2511: .hang_detect_cycles = 0xcfffff,
2512: .protected_regs = gen7_0_0_protected_regs,
2513: .gen7_snapshot_block_list = &gen7_3_0_snapshot_block_list,
2514: .preempt_level = 1,
2515: .ctxt_record_size = (862 * SZ_1K),
2516: };
2517:
2518: static const struct adreno_gen7_core adreno_gpu_core_gen7_4_0 = {
2519: .base = {
2520: DEFINE_ADRENO_REV(ADRENO_REV_GEN7_4_0,
2521: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
2522: .compatible = "qcom,adreno-gpu-gen7-4-0",
2523: .features = ADRENO_APRIV | ADRENO_IOCOHERENT |
2524: ADRENO_CONTENT_PROTECTION | ADRENO_L3_VOTE |
2525: ADRENO_PREEMPTION | ADRENO_IFPC | ADRENO_ACD |
2526: ADRENO_BCL,
2527: .gpudev = &adreno_gen7_gmu_gpudev.base,
2528: .perfcounters = &adreno_gen7_perfcounters,
2529: .uche_gmem_alignment = 0,
2530: .gmem_size = SZ_2M,
2531: .bus_width = 32,
2532: .snapshot_size = SZ_4M,
2533: .highest_bank_bit = 16,
2534: },
2535: .gmu_fw_version = GMU_VERSION(4, 0, 7),
2536: .sqefw_name = "a730_sqe.fw",
2537: .gmufw_name = "gmu_gen70000.bin",
2538: .gmufw_bak_name = "c500_gmu.bin",
2539: .zap_name = "a730_zap.mdt",
2540: .hwcg = gen7_0_0_hwcg_regs,
2541: .hwcg_count = ARRAY_SIZE(gen7_0_0_hwcg_regs),
2542: .ao_hwcg = gen7_0_0_ao_hwcg_regs,
2543: .ao_hwcg_count = ARRAY_SIZE(gen7_0_0_ao_hwcg_regs),
2544: .gbif = gen7_0_0_gbif_cx_regs,
2545: .gbif_count = ARRAY_SIZE(gen7_0_0_gbif_cx_regs),
2546: .hang_detect_cycles = 0xcfffff,
2547: .protected_regs = gen7_0_0_protected_regs,
2548: .gen7_snapshot_block_list = &gen7_0_0_snapshot_block_list,
2549: .preempt_level = 1,
MATCH LINES: 2568
2556: { GEN7_GPU_GMU_AO_GMU_CGC_DELAY_CNTL, 0x00010111 },
2557: { GEN7_GPU_GMU_AO_GMU_CGC_HYST_CNTL, 0x00005555 },
2558: { GEN7_GMU_CX_GMU_WFI_CONFIG, 0x00000003 },
2559: };
2560:
2561: extern const struct gen7_snapshot_block_list gen7_5_0_snapshot_block_list;
2562:
2563: static const struct adreno_gen7_core adreno_gpu_core_gen7_5_0 = {
2564: .base = {
2565: DEFINE_ADRENO_REV(ADRENO_REV_GEN7_5_0,
2566: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
2567: .compatible = "qcom,adreno-gpu-gen7-5-0",
2568: .features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_IFPC |
2569: ADRENO_PREEMPTION | ADRENO_L3_VOTE | ADRENO_DMS | ADRENO_LPAC,
2570: .gpudev = &adreno_gen7_gmu_gpudev.base,
2571: .perfcounters = &adreno_gen7_2_0_perfcounters,
2572: .uche_gmem_alignment = SZ_16M,
2573: .gmem_size = 3 * SZ_1M,
2574: .bus_width = 32,
2575: .snapshot_size = SZ_8M,
2576: .num_ddr_channels = 8,
2577: .chipid = 0x43050c01,
2578: .speedbins = KGSL_SPEEDBINS(
2579: { 0, 0 },
2580: { 59, 1 },
2581: { 7, 2 },
2582: { 232, 3 },
2583: { 146, 4 },
2584: ),
2585: .ubwc_mode = 4,
2586: .mal = 32,
2587: .highest_bank_bit = 17,
2588: .gpu_model = "Adreno X1-85",
2589: },
2590: .sqefw_name = "gen70500_sqe.fw",
2591: .gmufw_name = "gen70500_gmu.bin",
2592: .zap_name = "gen70500_zap.mbn",
MATCH LINES: 2615
2603: .preempt_level = 1,
2604: .ctxt_record_size = (4192 * SZ_1K),
2605: .fast_bus_hint = true,
2606: };
2607:
2608: static const struct adreno_gen7_core adreno_gpu_core_gen7_6_0 = {
2609: .base = {
2610: DEFINE_ADRENO_REV(ADRENO_REV_GEN7_6_0,
2611: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
2612: .compatible = "qcom,adreno-gpu-gen7-6-0",
2613: .features = ADRENO_APRIV | ADRENO_IOCOHERENT |
2614: ADRENO_CONTENT_PROTECTION | ADRENO_L3_VOTE |
2615: ADRENO_IFPC | ADRENO_PREEMPTION | ADRENO_BCL |
2616: ADRENO_ACD | ADRENO_LPAC | ADRENO_DMS,
2617: .gpudev = &adreno_gen7_hwsched_gpudev.base,
2618: .perfcounters = &adreno_gen7_2_0_perfcounters,
2619: .uche_gmem_alignment = SZ_16M,
2620: .gmem_size = 3 * SZ_1M,
2621: .bus_width = 32,
2622: .snapshot_size = SZ_4M,
2623: .highest_bank_bit = 16,
2624: },
2625: .gmu_fw_version = GMU_VERSION(4, 1, 9),
2626: .sqefw_name = "a740v3_sqe.fw",
2627: .gmufw_name = "gmu_gen70200.bin",
2628: .zap_name = "a740v3_zap.mbn",
2629: .hwcg = gen7_2_0_hwcg_regs,
2630: .hwcg_count = ARRAY_SIZE(gen7_2_0_hwcg_regs),
2631: .ao_hwcg = gen7_2_0_ao_hwcg_regs,
2632: .ao_hwcg_count = ARRAY_SIZE(gen7_2_0_ao_hwcg_regs),
2633: .gbif = gen7_2_0_gbif_cx_regs,
2634: .gbif_count = ARRAY_SIZE(gen7_2_0_gbif_cx_regs),
2635: .hang_detect_cycles = 0xcfffff,
2636: .protected_regs = gen7_2_0_protected_regs,
2637: .gmu_hub_clk_freq = 200000000,
2638: .bcl_data = 1,
2639: .gen7_snapshot_block_list = &gen7_6_0_snapshot_block_list,
MATCH LINES: 2706
2694: { GEN7_CP_PROTECT_REG + 45, 0x27800, 0x2787f, 1 },
2695: { GEN7_CP_PROTECT_REG + 46, 0x27880, 0x27c01, 0 },
2696: { GEN7_CP_PROTECT_REG + 47, 0x27c02, 0x27c02, 1 },
2697: { 0 },
2698: };
2699:
2700: static const struct adreno_gen7_core adreno_gpu_core_gen7_9_0 = {
2701: .base = {
2702: DEFINE_ADRENO_REV(ADRENO_REV_GEN7_9_0,
2703: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
2704: .compatible = "qcom,adreno-gpu-gen7-9-0",
2705: .features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_AQE |
2706: ADRENO_CONTENT_PROTECTION | ADRENO_LPAC | ADRENO_IFPC |
2707: ADRENO_L3_VOTE | ADRENO_BCL | ADRENO_DMS |
2708: ADRENO_HW_FENCE | ADRENO_PREEMPTION | ADRENO_ACD |
2709: ADRENO_GMU_WARMBOOT | ADRENO_GMU_AB,
2710: .gpudev = &adreno_gen7_9_0_hwsched_gpudev.base,
2711: .perfcounters = &adreno_gen7_9_0_perfcounters,
2712: .uche_gmem_alignment = SZ_16M,
2713: .gmem_size = 3 * SZ_1M,
2714: .bus_width = 32,
2715: .snapshot_size = SZ_8M,
2716: .num_ddr_channels = 4,
2717: .highest_bank_bit = 16,
2718: },
2719: .aqefw_name = "gen70900_aqe.fw",
2720: .sqefw_name = "gen70900_sqe.fw",
2721: .gmufw_name = "gmu_gen70900.bin",
2722: .zap_name = "gen70900_zap.mbn",
2723: .ao_hwcg = gen7_9_0_ao_hwcg_regs,
2724: .ao_hwcg_count = ARRAY_SIZE(gen7_9_0_ao_hwcg_regs),
2725: .gbif = gen7_2_0_gbif_cx_regs,
2726: .gbif_count = ARRAY_SIZE(gen7_2_0_gbif_cx_regs),
2727: .hang_detect_cycles = 0xcfffff,
2728: .protected_regs = gen7_9_0_protected_regs,
2729: .gmu_hub_clk_freq = 200000000,
2730: .gen7_snapshot_block_list = &gen7_9_0_snapshot_block_list,
MATCH LINES: 2745
2733: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
2734: .ctxt_record_size = (4208 * SZ_1K),
2735: .preempt_level = 1,
2736: .fast_bus_hint = true,
2737: };
2738:
2739: static const struct adreno_gen7_core adreno_gpu_core_gen7_9_1 = {
2740: .base = {
2741: DEFINE_ADRENO_REV(ADRENO_REV_GEN7_9_1,
2742: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
2743: .compatible = "qcom,adreno-gpu-gen7-9-1",
2744: .features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_AQE |
2745: ADRENO_CONTENT_PROTECTION | ADRENO_LPAC | ADRENO_IFPC |
2746: ADRENO_L3_VOTE | ADRENO_BCL | ADRENO_DMS |
2747: ADRENO_HW_FENCE | ADRENO_PREEMPTION | ADRENO_ACD |
2748: ADRENO_GMU_WARMBOOT | ADRENO_GMU_AB,
2749: .gpudev = &adreno_gen7_9_0_hwsched_gpudev.base,
2750: .perfcounters = &adreno_gen7_9_0_perfcounters,
2751: .uche_gmem_alignment = SZ_16M,
2752: .gmem_size = 3 * SZ_1M,
2753: .bus_width = 32,
2754: .snapshot_size = SZ_8M,
2755: .num_ddr_channels = 4,
2756: .highest_bank_bit = 16,
2757: },
2758: .aqefw_name = "gen70900_aqe.fw",
2759: .sqefw_name = "gen70900_sqe.fw",
2760: .gmufw_name = "gmu_gen70900.bin",
2761: .zap_name = "gen70900_zap.mbn",
2762: .ao_hwcg = gen7_9_0_ao_hwcg_regs,
2763: .ao_hwcg_count = ARRAY_SIZE(gen7_9_0_ao_hwcg_regs),
2764: .gbif = gen7_2_0_gbif_cx_regs,
2765: .gbif_count = ARRAY_SIZE(gen7_2_0_gbif_cx_regs),
2766: .hang_detect_cycles = 0xcfffff,
2767: .protected_regs = gen7_9_0_protected_regs,
2768: .gmu_hub_clk_freq = 200000000,
2769: .gen7_snapshot_block_list = &gen7_9_0_snapshot_block_list,
MATCH LINES: 2828, 2861, 2897
2816: .ctxt_record_size = (4208 * SZ_1K),
2817: .preempt_level = 1,
2818: };
2819:
2820: extern const struct gen7_snapshot_block_list gen7_14_0_snapshot_block_list;
2821:
2822: static const struct adreno_gen7_core adreno_gpu_core_gen7_14_0 = {
2823: .base = {
2824: DEFINE_ADRENO_REV(ADRENO_REV_GEN7_14_0,
2825: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
2826: .compatible = "qcom,adreno-gpu-gen7-14-0",
2827: .features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_CONTENT_PROTECTION |
2828: ADRENO_PREEMPTION | ADRENO_IFPC | ADRENO_BCL | ADRENO_ACD,
2829: .gpudev = &adreno_gen7_gmu_gpudev.base,
2830: .perfcounters = &adreno_gen7_no_cb_perfcounters,
2831: .uche_gmem_alignment = 0,
2832: .gmem_size = SZ_1M,
2833: .bus_width = 32,
2834: .snapshot_size = SZ_4M,
2835: .highest_bank_bit = 15,
2836: },
2837: .sqefw_name = "gen70e00_sqe.fw",
2838: .gmufw_name = "gmu_gen70e00.bin",
2839: .zap_name = "gen70e00_zap.mbn",
2840: .hwcg = gen7_0_0_hwcg_regs,
2841: .hwcg_count = ARRAY_SIZE(gen7_0_0_hwcg_regs),
2842: .ao_hwcg = gen7_0_0_ao_hwcg_regs,
2843: .ao_hwcg_count = ARRAY_SIZE(gen7_0_0_ao_hwcg_regs),
2844: .gbif = gen7_0_0_gbif_cx_regs,
2845: .gbif_count = ARRAY_SIZE(gen7_0_0_gbif_cx_regs),
2846: .hang_detect_cycles = 0xcfffff,
2847: .protected_regs = gen7_0_0_protected_regs,
2848: .gen7_snapshot_block_list = &gen7_14_0_snapshot_block_list,
2849: .preempt_level = 1,
2850: .fast_bus_hint = false,
2851: };
2852:
2853: extern const struct gen7_snapshot_block_list gen7_11_0_snapshot_block_list;
2854:
2855: static const struct adreno_gen7_core adreno_gpu_core_gen7_11_0 = {
2856: .base = {
2857: DEFINE_ADRENO_REV(ADRENO_REV_GEN7_11_0,
2858: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
2859: .compatible = "qcom,adreno-gpu-gen7-11-0",
2860: .features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_CONTENT_PROTECTION |
2861: ADRENO_IFPC | ADRENO_PREEMPTION | ADRENO_L3_VOTE |
2862: ADRENO_DMS | ADRENO_GMU_AB,
2863: .gpudev = &adreno_gen7_hwsched_gpudev.base,
2864: .perfcounters = &adreno_gen7_2_0_perfcounters,
2865: .uche_gmem_alignment = SZ_16M,
2866: .gmem_size = SZ_1M + SZ_512K,
2867: .bus_width = 32,
2868: .snapshot_size = SZ_4M,
2869: .num_ddr_channels = 4,
2870: .highest_bank_bit = 16,
2871: },
2872: .gmu_fw_version = GMU_VERSION(4, 5, 0),
2873: .sqefw_name = "gen71100_sqe.fw",
2874: .gmufw_name = "gen71100_gmu.bin",
2875: .zap_name = "gen71100_zap.mbn",
2876: .hwcg = gen7_2_0_hwcg_regs,
2877: .hwcg_count = ARRAY_SIZE(gen7_2_0_hwcg_regs),
2878: .ao_hwcg = gen7_9_0_ao_hwcg_regs,
2879: .ao_hwcg_count = ARRAY_SIZE(gen7_9_0_ao_hwcg_regs),
2880: .gbif = gen7_2_0_gbif_cx_regs,
2881: .gbif_count = ARRAY_SIZE(gen7_2_0_gbif_cx_regs),
2882: .hang_detect_cycles = 0xcfffff,
2883: .protected_regs = gen7_2_0_protected_regs,
2884: .gmu_hub_clk_freq = 200000000,
2885: .gen7_snapshot_block_list = &gen7_11_0_snapshot_block_list,
2886: .preempt_level = 1,
2887: .fast_bus_hint = true,
2888: };
2889:
2890: extern const struct gen7_snapshot_block_list gen7_15_0_snapshot_block_list;
2891:
2892: static const struct adreno_gen7_core adreno_gpu_core_gen7_15_0 = {
2893: .base = {
2894: DEFINE_ADRENO_REV(ADRENO_REV_GEN7_15_0,
2895: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
2896: .compatible = "qcom,adreno-gpu-gen7-15-0",
2897: .features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_IFPC |
2898: ADRENO_PREEMPTION | ADRENO_L3_VOTE | ADRENO_DMS,
2899: .gpudev = &adreno_gen7_gmu_gpudev.base,
2900: .perfcounters = &adreno_gen7_2_0_perfcounters,
2901: .uche_gmem_alignment = SZ_16M,
2902: .gmem_size = SZ_1M + SZ_512K,
2903: .bus_width = 32,
2904: .snapshot_size = SZ_4M,
2905: .num_ddr_channels = 8,
2906: .highest_bank_bit = 16,
2907: .chipid = 0x43030c00,
2908: .speedbins = KGSL_SPEEDBINS(
2909: { 0, 0 },
2910: { 294, 1 },
2911: { 263, 2 },
2912: { 233, 3 },
2913: { 141, 4 },
2914: ),
2915: .ubwc_mode = 4,
2916: .mal = 32,
2917: .gpu_model = "Adreno X1-45",
2918: },
2919: .sqefw_name = "gen71500_sqe.fw",
2920: .gmufw_name = "gen71500_gmu.bin",
2921: .zap_name = "gen71500_zap.mbn",
MATCH LINES: 2944
2932: .preempt_level = 1,
2933: .fast_bus_hint = true,
2934: };
2935:
2936: extern const struct gen7_snapshot_block_list gen7_17_0_snapshot_block_list;
2937:
2938: static const struct adreno_gen7_core adreno_gpu_core_gen7_17_0 = {
2939: .base = {
2940: DEFINE_ADRENO_REV(ADRENO_REV_GEN7_17_0,
2941: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
2942: .compatible = "qcom,adreno-gpu-gen7-17-0",
2943: .features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_CONTENT_PROTECTION |
2944: ADRENO_IFPC | ADRENO_PREEMPTION | ADRENO_BCL,
2945: .gpudev = &adreno_gen7_gmu_gpudev.base,
2946: .perfcounters = &adreno_gen7_no_cb_perfcounters,
2947: .uche_gmem_alignment = SZ_16M,
2948: .gmem_size = SZ_1M,
2949: .bus_width = 32,
2950: .snapshot_size = SZ_2M,
2951: .chipid = 0x43020100,
2952: .ubwc_mode = 5,
2953: .mal = 32,
2954: .highest_bank_bit = 15,
2955: },
2956: .sqefw_name = "gen70e00_sqe.fw",
2957: .gmufw_name = "gen71700_gmu.bin",
2958: .zap_name = "gen70e00_zap.mbn",
2959: .hwcg = gen7_0_0_hwcg_regs,
2960: .hwcg_count = ARRAY_SIZE(gen7_0_0_hwcg_regs),
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,
MATCH LINES: 3265
3253: },
3254: },
3255: };
3256:
3257: static const struct adreno_gen8_core adreno_gpu_core_gen8_0_0 = {
3258: .base = {
3259: DEFINE_ADRENO_REV(ADRENO_REV_GEN8_0_0,
3260: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
3261: .compatible = "qcom,adreno-gpu-gen8-0-0",
3262: .features = ADRENO_APRIV | ADRENO_IOCOHERENT |
3263: ADRENO_CONTENT_PROTECTION | ADRENO_LPAC | ADRENO_AQE |
3264: ADRENO_GMU_WARMBOOT | ADRENO_L3_VOTE | ADRENO_BCL |
3265: ADRENO_IFPC | ADRENO_HW_FENCE | ADRENO_PREEMPTION |
3266: ADRENO_ACD | ADRENO_CLX | ADRENO_GMU_THERMAL_MITIGATION |
3267: ADRENO_GMU_AB,
3268: .gpudev = &adreno_gen8_hwsched_gpudev.base,
3269: .perfcounters = &adreno_gen8_perfcounters,
3270: .uche_gmem_alignment = SZ_64M,
3271: .gmem_size = 12 * SZ_1M,
3272: .bus_width = 32,
3273: .snapshot_size = SZ_8M,
3274: .num_ddr_channels = 4,
3275: .highest_bank_bit = 16,
3276: },
3277: .aqefw_name = "gen80000_aqe.fw",
3278: .sqefw_name = "gen80000_sqe.fw",
3279: .gmufw_name = "gen80000_gmu.bin",
3280: .zap_name = "gen80000_zap.mbn",
3281: .ao_hwcg = gen8_ao_hwcg_regs,
3282: .ao_hwcg_count = ARRAY_SIZE(gen8_ao_hwcg_regs),
3283: .gbif = gen8_0_0_gbif_cx_regs,
3284: .gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs),
3285: .hang_detect_cycles = 0xcfffff,
3286: .protected_regs = gen8_0_0_protected_regs,
3287: .nonctxt_regs = gen8_0_0_nonctxt_regs,
3288: .gmu_hub_clk_freq = 200000000,
3289: .gen8_snapshot_block_list = &gen8_0_0_snapshot_block_list,
MATCH LINES: 3309, 3313
3297: .therm_cfg = &therm_mit_cfg_8_0_0,
3298: .clx_tbl = &gen8_0_0_clx_table,
3299: };
3300:
3301: static const struct adreno_gen8_core adreno_gpu_core_gen8_0_1 = {
3302: .base = {
3303: DEFINE_ADRENO_REV(ADRENO_REV_GEN8_0_1,
3304: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
3305: .compatible = "qcom,adreno-gpu-gen8-0-1",
3306: .features = ADRENO_APRIV | ADRENO_IOCOHERENT |
3307: ADRENO_CONTENT_PROTECTION | ADRENO_LPAC | ADRENO_AQE |
3308: ADRENO_GMU_WARMBOOT | ADRENO_L3_VOTE | ADRENO_BCL |
3309: ADRENO_IFPC | ADRENO_HW_FENCE | ADRENO_PREEMPTION |
3310: ADRENO_ACD | ADRENO_CLX | ADRENO_GMU_THERMAL_MITIGATION |
3311: ADRENO_GMU_AB,
3312: .features_standard = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_PREEMPTION |
3313: ADRENO_IFPC | ADRENO_AQE | ADRENO_CONTENT_PROTECTION,
3314: .gpudev = &adreno_gen8_hwsched_gpudev.base,
3315: .perfcounters = &adreno_gen8_perfcounters,
3316: .uche_gmem_alignment = SZ_64M,
3317: .gmem_size = 12 * SZ_1M,
3318: .bus_width = 32,
3319: .snapshot_size = SZ_8M,
3320: .num_ddr_channels = 4,
3321: .highest_bank_bit = 16,
3322: .chipid = 0x44050001,
3323: .speedbins = KGSL_SPEEDBINS(
3324: { 0, 0 },
3325: { 252, 1 },
3326: { 242, 2 },
3327: { 232, 3 },
3328: { 221, 4 },
3329: { 190, 5 },
3330: ),
3331: .ubwc_mode = 5,
3332: .mal = 32,
3333: .gpu_model = "Adreno830",
3334: },
3335: .aqefw_name = "gen80000_aqe.fw",
3336: .sqefw_name = "gen80000_sqe.fw",
3337: .gmufw_name = "gen80000_gmu.bin",
MATCH LINES: 3618
3606: };
3607:
3608: /* Set the BCL throttle levels to 62/75/83 percent */
3609: #define GEN8_2_X_BCL_DATA ((62 << 15) | (75 << 8) | (83 << 1) | 0x1)
3610:
3611: static const struct adreno_gen8_core adreno_gpu_core_gen8_2_0 = {
3612: .base = {
3613: DEFINE_ADRENO_REV(ADRENO_REV_GEN8_2_0,
3614: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
3615: .compatible = "qcom,adreno-gpu-gen8-2-0",
3616: .features = ADRENO_APRIV | ADRENO_IOCOHERENT |
3617: ADRENO_PREEMPTION | ADRENO_LPAC | ADRENO_AQE |
3618: ADRENO_GMU_WARMBOOT | ADRENO_IFPC | ADRENO_CONTENT_PROTECTION |
3619: ADRENO_HW_FENCE | ADRENO_BCL | ADRENO_ACD | ADRENO_GMU_BASED_DCVS |
3620: ADRENO_GMU_THERMAL_MITIGATION | ADRENO_CLX | ADRENO_DEFER_GMEM_ALLOC |
3621: ADRENO_GMU_MINBW | ADRENO_DCVS_PROFILE | ADRENO_TSENSE_DYNAMIC_PERIOD |
3622: ADRENO_GMU_AB,
3623: .gpudev = &adreno_gen8_hwsched_gpudev.base,
3624: .perfcounters = &adreno_gen8_2_x_perfcounters,
3625: .uche_gmem_alignment = SZ_64M,
3626: .gmem_size = 18 * SZ_1M,
3627: .bus_width = 32,
3628: .snapshot_size = SZ_8M,
3629: .num_ddr_channels = 4,
3630: .highest_bank_bit = 16,
3631: },
3632: .aqefw_name = "gen80200_aqe.fw",
3633: .sqefw_name = "gen80200_sqe.fw",
3634: .gmufw_name = "gen80200_gmu.bin",
3635: .zap_name = "gen80200_zap.mbn",
3636: .ao_hwcg = gen8_2_0_ao_hwcg_regs,
3637: .ao_hwcg_count = ARRAY_SIZE(gen8_2_0_ao_hwcg_regs),
3638: .gbif = gen8_0_0_gbif_cx_regs,
3639: .gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs),
3640: .hang_detect_cycles = 0xcfffff,
3641: .protected_regs = gen8_2_0_protected_regs,
3642: .nonctxt_regs = gen8_2_0_nonctxt_regs,
MATCH LINES: 3664, 3670
3652: .limits_mit_cfg = &gen8_2_0_limits_mit_cfg,
3653: .preempt_level = 1,
3654: .clx_tbl = &gen8_2_0_clx_table,
3655: };
3656:
3657: static const struct adreno_gen8_core adreno_gpu_core_gen8_2_1 = {
3658: .base = {
3659: DEFINE_ADRENO_REV(ADRENO_REV_GEN8_2_1,
3660: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
3661: .compatible = "qcom,adreno-gpu-gen8-2-1",
3662: .features = ADRENO_APRIV | ADRENO_IOCOHERENT |
3663: ADRENO_PREEMPTION | ADRENO_LPAC | ADRENO_AQE |
3664: ADRENO_GMU_WARMBOOT | ADRENO_IFPC | ADRENO_CONTENT_PROTECTION |
3665: ADRENO_HW_FENCE | ADRENO_BCL | ADRENO_ACD | ADRENO_GMU_BASED_DCVS |
3666: ADRENO_GMU_THERMAL_MITIGATION | ADRENO_CLX | ADRENO_DEFER_GMEM_ALLOC |
3667: ADRENO_GMU_MINBW | ADRENO_DCVS_PROFILE | ADRENO_TSENSE_DYNAMIC_PERIOD |
3668: ADRENO_GMU_AB,
3669: .features_standard = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_PREEMPTION |
3670: ADRENO_IFPC | ADRENO_AQE | ADRENO_CONTENT_PROTECTION,
3671: .gpudev = &adreno_gen8_hwsched_gpudev.base,
3672: .perfcounters = &adreno_gen8_2_x_perfcounters,
3673: .uche_gmem_alignment = SZ_64M,
3674: .gmem_size = 18 * SZ_1M,
3675: .bus_width = 32,
3676: .snapshot_size = SZ_8M,
3677: .num_ddr_channels = 4,
3678: .highest_bank_bit = 16,
3679: .chipid = 0x44050a01,
3680: .speedbins = KGSL_SPEEDBINS(
3681: { 0, 0 },
3682: { 273, 1 },
3683: { 252, 2 },
3684: { 221, 3 },
3685: ),
3686: .ubwc_mode = 6,
3687: .mal = 32,
3688: .gpu_model = "Adreno840",
3689: },
3690: .aqefw_name = "gen80200_aqe.fw",
3691: .sqefw_name = "gen80200_sqe.fw",
3692: .gmufw_name = "gen80200_gmu.bin",
3693: .zap_name = "gen80200_zap.mbn",
3694: .ao_hwcg = gen8_2_0_ao_hwcg_regs,
MATCH LINES: 3876
3864: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
3865: .noc_timeout_us = 3410, /* 3.41 msec */
3866: .ctxt_record_size = (23088 * SZ_1K),
3867: .preempt_level = 1,
3868: };
3869:
3870: static const struct adreno_gen8_core adreno_gpu_core_gen8_5_0 = {
3871: .base = {
3872: DEFINE_ADRENO_REV(ADRENO_REV_GEN8_5_0,
3873: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
3874: .compatible = "qcom,adreno-gpu-gen8-5-0",
3875: .features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_PREEMPTION |
3876: ADRENO_LPAC | ADRENO_AQE | ADRENO_GMU_WARMBOOT | ADRENO_IFPC |
3877: ADRENO_CONTENT_PROTECTION | ADRENO_HW_FENCE | ADRENO_BCL |
3878: ADRENO_GMU_AB | ADRENO_GMU_BASED_DCVS | ADRENO_GMU_THERMAL_MITIGATION |
3879: ADRENO_DEFER_GMEM_ALLOC | ADRENO_GMU_MINBW |
3880: ADRENO_TSENSE_DYNAMIC_PERIOD | ADRENO_DCVS_PROFILE,
3881: .gpudev = &adreno_gen8_hwsched_gpudev.base,
3882: .perfcounters = &adreno_gen8_2_x_perfcounters,
3883: .uche_gmem_alignment = SZ_64M,
3884: .gmem_size = 18 * SZ_1M,
3885: .bus_width = 32,
3886: .snapshot_size = SZ_8M,
3887: .num_ddr_channels = 4,
3888: .highest_bank_bit = 16,
3889: },
3890: .aqefw_name = "gen80200_aqe.fw",
3891: .sqefw_name = "gen80200_sqe.fw",
3892: .gmufw_name = "gen80200_gmu.bin",
3893: .zap_name = "gen80200_zap.mbn",
3894: .ao_hwcg = gen8_2_0_ao_hwcg_regs,
3895: .ao_hwcg_count = ARRAY_SIZE(gen8_2_0_ao_hwcg_regs),
3896: .gbif = gen8_0_0_gbif_cx_regs,
3897: .gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs),
3898: .hang_detect_cycles = 0xcfffff,
3899: .protected_regs = gen8_2_0_protected_regs,
3900: .nonctxt_regs = gen8_2_0_nonctxt_regs,
MATCH LINES: 3991
3979:
3980: static const u32 gen8_4_0_gbif_client_qos_values[KGSL_PRIORITY_MAX_RB_LEVELS] = {
3981: 0x33233323,
3982: };
3983:
3984: static const struct adreno_gen8_core adreno_gpu_core_gen8_4_0 = {
3985: .base = {
3986: DEFINE_ADRENO_REV(ADRENO_REV_GEN8_4_0,
3987: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
3988: .compatible = "qcom,adreno-gpu-gen8-4-0",
3989: .features = ADRENO_APRIV | ADRENO_IOCOHERENT |
3990: ADRENO_CONTENT_PROTECTION | ADRENO_LPAC | ADRENO_AQE |
3991: ADRENO_GMU_WARMBOOT | ADRENO_L3_VOTE | ADRENO_IFPC |
3992: ADRENO_BCL | ADRENO_ACD | ADRENO_HW_FENCE |
3993: ADRENO_PREEMPTION | ADRENO_GMU_AB,
3994: .gpudev = &adreno_gen8_hwsched_gpudev.base,
3995: .perfcounters = &adreno_gen8_perfcounters,
3996: .uche_gmem_alignment = SZ_64M,
3997: .gmem_size = 12 * SZ_1M,
3998: .bus_width = 32,
3999: .snapshot_size = SZ_8M,
4000: .num_ddr_channels = 4,
4001: .highest_bank_bit = 16,
4002: },
4003: .aqefw_name = "gen80000_aqe.fw",
4004: .sqefw_name = "gen80000_sqe.fw",
4005: .gmufw_name = "gen80000_gmu.bin",
4006: .zap_name = "gen80000_zap.mbn",
4007: .ao_hwcg = gen8_ao_hwcg_regs,
4008: .ao_hwcg_count = ARRAY_SIZE(gen8_ao_hwcg_regs),
4009: .gbif = gen8_0_0_gbif_cx_regs,
4010: .gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs),
4011: .hang_detect_cycles = 0xcfffff,
4012: .protected_regs = gen8_0_0_protected_regs,
4013: .nonctxt_regs = gen8_4_0_nonctxt_regs,
4014: .gmu_hub_clk_freq = 200000000,
4015: .gen8_snapshot_block_list = &gen8_0_0_snapshot_block_list,
MATCH LINES: 4094
4082: { GEN8_VFD_CB_LP_REQ_CNT, 0x00100020, BIT(PIPE_BV) | BIT(PIPE_BR) },
4083: { GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) },
4084: { GEN8_RB_GC_GMEM_PROTECT, 0x00900000, BIT(PIPE_BR) },
4085: { 0 },
4086: };
4087:
4088: static const struct adreno_gen8_core adreno_gpu_core_gen8_3_0 = {
4089: .base = {
4090: DEFINE_ADRENO_REV(ADRENO_REV_GEN8_3_0,
4091: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
4092: .compatible = "qcom,adreno-gpu-gen8-3-0",
4093: .features = ADRENO_APRIV | ADRENO_IOCOHERENT |
4094: ADRENO_CONTENT_PROTECTION | ADRENO_IFPC | ADRENO_PREEMPTION |
4095: ADRENO_GMU_AB,
4096: .gpudev = &adreno_gen8_hwsched_gpudev.base,
4097: .perfcounters = &adreno_gen8_perfcounters,
4098: .uche_gmem_alignment = SZ_64M,
4099: .gmem_size = (SZ_512K + SZ_64K),
4100: .bus_width = 32,
4101: .snapshot_size = SZ_8M,
4102: .num_ddr_channels = 2,
4103: .highest_bank_bit = 15,
4104: },
4105: .sqefw_name = "gen80300_sqe.fw",
4106: .gmufw_name = "gen80300_gmu.bin",
4107: .zap_name = "gen80300_zap.mbn",
4108: .ao_hwcg = gen8_ao_hwcg_regs,
4109: .ao_hwcg_count = ARRAY_SIZE(gen8_ao_hwcg_regs),
4110: .gbif = gen8_3_0_gbif_cx_regs,
4111: .gbif_count = ARRAY_SIZE(gen8_3_0_gbif_cx_regs),
4112: .hang_detect_cycles = 0xcfffff,
4113: .protected_regs = gen8_0_0_protected_regs, /* Reuse the protected regs list from Gen8_0_0 */
4114: .nonctxt_regs = gen8_3_0_nonctxt_regs,
4115: .gmu_hub_clk_freq = 200000000,
4116: .gen8_snapshot_block_list = &gen8_3_0_snapshot_block_list,
4117: .ctxt_record_size = (4558 * SZ_1K),
4118: .preempt_level = 1,
MATCH LINES: 4194, 4231
4182: { 0 },
4183: };
4184:
4185: extern const struct gen8_snapshot_block_list gen8_6_0_snapshot_block_list;
4186:
4187: static const struct adreno_gen8_core adreno_gpu_core_gen8_6_0 = {
4188: .base = {
4189: DEFINE_ADRENO_REV(ADRENO_REV_GEN8_6_0,
4190: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
4191: .compatible = "qcom,adreno-gpu-gen8-6-0",
4192: .features = ADRENO_APRIV | ADRENO_IOCOHERENT |
4193: ADRENO_CONTENT_PROTECTION | ADRENO_LPAC | ADRENO_AQE |
4194: ADRENO_GMU_WARMBOOT | ADRENO_L3_VOTE | ADRENO_IFPC |
4195: ADRENO_PREEMPTION | ADRENO_BCL | ADRENO_ACD | ADRENO_GMU_AB,
4196: .gpudev = &adreno_gen8_hwsched_gpudev.base,
4197: .perfcounters = &adreno_gen8_perfcounters,
4198: .uche_gmem_alignment = SZ_64M,
4199: .gmem_size = (SZ_2M + SZ_256K + SZ_128K),
4200: .bus_width = 32,
4201: .snapshot_size = SZ_8M,
4202: .num_ddr_channels = 4,
4203: .highest_bank_bit = 16,
4204: },
4205: .aqefw_name = "gen80000_aqe.fw",
4206: .sqefw_name = "gen80000_sqe.fw",
4207: .gmufw_name = "gen80600_gmu.bin",
4208: .zap_name = "gen80000_zap.mbn",
4209: .ao_hwcg = gen8_ao_hwcg_regs,
4210: .ao_hwcg_count = ARRAY_SIZE(gen8_ao_hwcg_regs),
4211: .gbif = gen8_3_0_gbif_cx_regs,
4212: .gbif_count = ARRAY_SIZE(gen8_3_0_gbif_cx_regs),
4213: .hang_detect_cycles = 0xcfffff,
4214: .protected_regs = gen8_0_0_protected_regs,
4215: .nonctxt_regs = gen8_6_0_nonctxt_regs,
4216: .gmu_hub_clk_freq = 200000000,
4217: .gen8_snapshot_block_list = &gen8_6_0_snapshot_block_list,
4218: .noc_timeout_us = 6800, /* 6.8 msec */
4219: .ctxt_record_size = (3372 * SZ_1K),
4220: .preempt_level = 1,
4221: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
4222: .bcl_data = 1,
4223: };
4224:
4225: static const struct adreno_gen8_core adreno_gpu_core_gen8_8_0 = {
4226: .base = {
4227: DEFINE_ADRENO_REV(ADRENO_REV_GEN8_8_0,
4228: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
4229: .compatible = "qcom,adreno-gpu-gen8-8-0",
4230: .features = ADRENO_APRIV | ADRENO_IOCOHERENT |
4231: ADRENO_CONTENT_PROTECTION | ADRENO_IFPC | ADRENO_PREEMPTION |
4232: ADRENO_HW_FENCE | ADRENO_BCL | ADRENO_GMU_AB,
4233: .gpudev = &adreno_gen8_hwsched_gpudev.base,
4234: .perfcounters = &adreno_gen8_perfcounters,
4235: .uche_gmem_alignment = SZ_64M,
4236: .gmem_size = (SZ_512K + SZ_64K),
4237: .bus_width = 32,
4238: .snapshot_size = SZ_8M,
4239: .num_ddr_channels = 1,
4240: .highest_bank_bit = 14,
4241: },
4242: .sqefw_name = "gen80300_sqe.fw",
4243: .gmufw_name = "gen80800_gmu.bin",
4244: .zap_name = "gen80300_zap.mbn",
4245: .ao_hwcg = gen8_ao_hwcg_regs,
4246: .ao_hwcg_count = ARRAY_SIZE(gen8_ao_hwcg_regs),
4247: .gbif = gen8_8_0_gbif_cx_regs,
4248: .gbif_count = ARRAY_SIZE(gen8_8_0_gbif_cx_regs),
4249: .hang_detect_cycles = 0xcfffff,
4250: .protected_regs = gen8_0_0_protected_regs, /* Reuse the protected regs list from Gen8_0_0 */
4251: .nonctxt_regs = gen8_3_0_nonctxt_regs,
4252: .gmu_hub_clk_freq = 200000000,
4253: .gen8_snapshot_block_list = &gen8_3_0_snapshot_block_list,
4254: .ctxt_record_size = (4558 * SZ_1K),
4255: .preempt_level = 1,
MATCH LINES: 4326
4314: { GEN8_TPL1_DBG_ECO_CNTL1, 0x04000720, BIT(PIPE_NONE) },
4315: { 0 },
4316: };
4317:
4318: extern const struct gen8_snapshot_block_list gen8_9_0_snapshot_block_list;
4319:
4320: static const struct adreno_gen8_core adreno_gpu_core_gen8_9_0 = {
4321: .base = {
4322: DEFINE_ADRENO_REV(ADRENO_REV_GEN8_9_0,
4323: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
4324: .compatible = "qcom,adreno-gpu-gen8-9-0",
4325: .features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_LPAC |
4326: ADRENO_GMU_WARMBOOT | ADRENO_AQE | ADRENO_IFPC |
4327: ADRENO_CONTENT_PROTECTION | ADRENO_GMU_BASED_DCVS |
4328: ADRENO_DEFER_GMEM_ALLOC | ADRENO_PREEMPTION | ADRENO_GMU_AB |
4329: ADRENO_GMU_THERMAL_MITIGATION | ADRENO_HW_FENCE |
4330: ADRENO_DCVS_PROFILE | ADRENO_GMU_MINBW |
4331: ADRENO_BCL | ADRENO_ACD,
4332: .gpudev = &adreno_gen8_hwsched_gpudev.base,
4333: .perfcounters = &adreno_gen8_perfcounters,
4334: .uche_gmem_alignment = SZ_64M,
4335: .gmem_size = 2432 * SZ_1K,
4336: .bus_width = 32,
4337: .snapshot_size = SZ_8M,
4338: .num_ddr_channels = 4,
4339: .highest_bank_bit = 16,
4340: },
4341: .aqefw_name = "gen80900_aqe.fw",
4342: .sqefw_name = "gen80900_sqe.fw",
4343: .gmufw_name = "gen80900_gmu.bin",
4344: .zap_name = "gen80900_zap.mbn",
4345: .ao_hwcg = gen8_2_0_ao_hwcg_regs,
4346: .ao_hwcg_count = ARRAY_SIZE(gen8_2_0_ao_hwcg_regs),
4347: .gbif = gen8_0_0_gbif_cx_regs,
4348: .gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs),
4349: .hang_detect_cycles = 0xcfffff,
4350: .protected_regs = gen8_2_0_protected_regs,
MATCH LINES: 4411
4399: .disable_tseskip = true,
4400: .pdc_in_aop = true,
4401: .ctxt_record_size = 2496 * 1024,
4402: };
4403:
4404: extern const struct gen8_snapshot_block_list gen8_10_0_snapshot_block_list;
4405:
4406: static const struct adreno_gen8_core adreno_gpu_core_gen8_10_0 = {
4407: .base = {
4408: DEFINE_ADRENO_REV(ADRENO_REV_GEN8_10_0,
4409: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
4410: .features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_BCL | ADRENO_ACD
4411: | ADRENO_IFPC | ADRENO_CONTENT_PROTECTION | ADRENO_PREEMPTION,
4412: .features_standard = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_PREEMPTION |
4413: ADRENO_CONTENT_PROTECTION | ADRENO_SOFTFUSE,
4414: .compatible = "qcom,adreno-gpu-gen8-10-0",
4415: .gpudev = &adreno_gen8_hwsched_gpudev.base,
4416: .perfcounters = &adreno_gen8_perfcounters,
4417: .uche_gmem_alignment = SZ_64M,
4418: .gmem_size = (15 * SZ_1M + 768 * SZ_1K),
4419: .bus_width = 32,
4420: .snapshot_size = SZ_8M,
4421: .num_ddr_channels = 8,
4422: .chipid = 0x44060000,
4423: .speedbins = KGSL_SPEEDBINS(
4424: { 0, 0 },
4425: { 388, 1 },
4426: { 357, 2 },
4427: { 284, 3 },
4428: ),
4429: .ubwc_mode = 5,
4430: .mal = 32,
4431: .highest_bank_bit = 16,
4432: .gpu_model = "Adreno X2-85",
4433: },
4434: .aqefw_name = "gen80100_aqe.fw",
4435: .sqefw_name = "gen80100_sqe.fw",
MATCH LINES: 4866, 4870
4854: { GEN8_VSC_VISIBILITY_FLUSH_CNTL, 0x00080004, BIT(PIPE_NONE) },
4855: { 0 },
4856: };
4857:
4858: static const struct adreno_gen8_core adreno_gpu_core_gen8_11_1 = {
4859: .base = {
4860: DEFINE_ADRENO_REV(ADRENO_REV_GEN8_11_1,
4861: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
4862: .compatible = "qcom,adreno-gpu-gen8-11-1",
4863: .features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_LPAC | ADRENO_PREEMPTION |
4864: ADRENO_GMU_WARMBOOT | ADRENO_GMU_BASED_DCVS | ADRENO_CLX |
4865: ADRENO_GMU_THERMAL_MITIGATION | ADRENO_AQE | ADRENO_CONTENT_PROTECTION |
4866: ADRENO_BCL | ADRENO_DCVS_PROFILE | ADRENO_IFPC | ADRENO_GMU_MINBW |
4867: ADRENO_DEFER_GMEM_ALLOC | ADRENO_GMU_FAST_CONTEXT_DESTROY |
4868: ADRENO_ACD | ADRENO_GMU_AB | ADRENO_HW_FENCE,
4869: .features_standard = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_PREEMPTION |
4870: ADRENO_IFPC | ADRENO_AQE | ADRENO_CONTENT_PROTECTION | ADRENO_CLX |
4871: ADRENO_GMU_FAST_CONTEXT_DESTROY | ADRENO_GMU_BASED_DCVS | ADRENO_ACD,
4872: .gpudev = &adreno_gen8_hwsched_gpudev.base,
4873: .perfcounters = &adreno_gen8_2_x_perfcounters,
4874: .uche_gmem_alignment = SZ_64M,
4875: .gmem_size = 18 * SZ_1M,
4876: .bus_width = 32,
4877: .snapshot_size = SZ_8M,
4878: .num_ddr_channels = 4,
4879: .highest_bank_bit = 16,
4880: .chipid = 0x44051401,
4881: .speedbins = KGSL_SPEEDBINS(
4882: { 0, 0 },
4883: { 284, 2 },
4884: { 216, 3 },
4885: ),
4886: .ubwc_mode = 7,
4887: .mal = 32,
4888: },
4889: .aqefw_name = "gen81100_aqe.fw",
4890: .sqefw_name = "gen81100_sqe.fw",
4891: .gmufw_name = "gen81100_gmu.bin",
4892: .zap_name = "gen81100_zap.mbn",
4893: .ao_hwcg = gen8_2_0_ao_hwcg_regs,
4894: .ao_hwcg_count = ARRAY_SIZE(gen8_2_0_ao_hwcg_regs),
MATCH LINES: 5010, 5014
4998: { GEN8_VSC_VISIBILITY_FLUSH_CNTL, 0x00080004, BIT(PIPE_NONE) },
4999: { 0 },
5000: };
5001:
5002: static const struct adreno_gen8_core adreno_gpu_core_gen8_14_0 = {
5003: .base = {
5004: DEFINE_ADRENO_REV(ADRENO_REV_GEN8_14_0,
5005: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
5006: .compatible = "qcom,adreno-gpu-gen8-14-0",
5007: .features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_LPAC | ADRENO_PREEMPTION |
5008: ADRENO_GMU_WARMBOOT | ADRENO_GMU_BASED_DCVS |
5009: ADRENO_GMU_THERMAL_MITIGATION | ADRENO_AQE | ADRENO_CONTENT_PROTECTION |
5010: ADRENO_DCVS_PROFILE | ADRENO_IFPC | ADRENO_GMU_MINBW |
5011: ADRENO_DEFER_GMEM_ALLOC | ADRENO_GMU_FAST_CONTEXT_DESTROY |
5012: ADRENO_GMU_AB | ADRENO_HW_FENCE | ADRENO_CLX | ADRENO_ACD,
5013: .features_standard = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_PREEMPTION |
5014: ADRENO_IFPC | ADRENO_AQE | ADRENO_CONTENT_PROTECTION | ADRENO_CLX |
5015: ADRENO_GMU_FAST_CONTEXT_DESTROY | ADRENO_GMU_BASED_DCVS,
5016: .gpudev = &adreno_gen8_hwsched_gpudev.base,
5017: .perfcounters = &adreno_gen8_2_x_perfcounters,
5018: .uche_gmem_alignment = SZ_64M,
5019: .gmem_size = 12 * SZ_1M,
5020: .bus_width = 32,
5021: .snapshot_size = SZ_8M,
5022: .num_ddr_channels = 4,
5023: .highest_bank_bit = 16,
5024: .chipid = 0x44041400,
5025: .speedbins = KGSL_SPEEDBINS(
5026: { 0, 0 },
5027: { 216, 0 },
5028: { 284, 1 },
5029: ),
5030: .ubwc_mode = 7,
5031: .mal = 32,
5032: },
5033: .aqefw_name = "gen81100_aqe.fw",
5034: .sqefw_name = "gen81100_sqe.fw",
5035: .gmufw_name = "gen81400_gmu.bin",
5036: .zap_name = "gen81100_zap.mbn",
5037: .ao_hwcg = gen8_2_0_ao_hwcg_regs,
5038: .ao_hwcg_count = ARRAY_SIZE(gen8_2_0_ao_hwcg_regs),
--- FILE: \adreno.c | HITS: 57 ---
MATCH LINES: 18
6: #include <linux/component.h>
7: #include <linux/delay.h>
8: #include <linux/devfreq.h>
9: #include <linux/firmware.h>
10: #include <linux/input.h>
11: #include <linux/interconnect.h>
12: #include <linux/of.h>
13: #include <linux/of_address.h>
14: #include <linux/of_device.h>
15: #include <linux/of_fdt.h>
16: #include <linux/module.h>
17: #include <linux/msm_kgsl.h>
18: #include <linux/regulator/consumer.h>
19: #include <linux/nvmem-consumer.h>
20: #include <linux/pm_domain.h>
21: #include <linux/reset.h>
22: #include <linux/soc/qcom/mdt_loader.h>
23: #include <linux/trace.h>
24: #include <linux/units.h>
25: #include <linux/version.h>
26: #include <soc/qcom/dcvs.h>
27: #include <soc/qcom/socinfo.h>
28: #include <linux/suspend.h>
29: #if (KERNEL_VERSION(6, 10, 0) <= LINUX_VERSION_CODE)
30: #include <linux/soc/qcom/socinfo.h>
31: #endif
32: #if (KERNEL_VERSION(6, 17, 0) <= LINUX_VERSION_CODE)
33: #include <linux/soc/qcom/ubwc.h>
34: #endif
35:
36: #include "adreno.h"
37: #include "adreno_a6xx.h"
38: #include "adreno_compat.h"
39: #include "adreno_pm4types.h"
40: #include "adreno_trace.h"
41: #include "kgsl_bus.h"
42: #include "kgsl_gmu_core.h"
MATCH LINES: 491
479: /*
480: * A workqueue callback responsible for actually turning on the GPU after a
481: * touch event. kgsl_pwrctrl_change_state(ACTIVE) is used without any
482: * active_count protection to avoid the need to maintain state. Either
483: * somebody will start using the GPU or the idle timer will fire and put the
484: * GPU back into slumber.
485: */
486: static void adreno_input_work(struct work_struct *work)
487: {
488: struct adreno_device *adreno_dev = container_of(work,
489: struct adreno_device, input_work);
490: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
491: const struct adreno_power_ops *ops = ADRENO_POWER_OPS(adreno_dev);
492:
493: kgsl_mutex_lock(&device->mutex);
494:
495: device->pwrctrl.wake_on_touch = true;
496:
497: ops->touch_wakeup(adreno_dev);
498:
499: kgsl_mutex_unlock(&device->mutex);
500: }
501:
502: /* Wake up the touch event kworker to initiate GPU wakeup */
503: void adreno_touch_wake(struct kgsl_device *device)
504: {
505: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
506:
507: /*
508: * Don't do anything if anything hasn't been rendered since we've been
509: * here before
510: */
511:
512: if (device->pwrctrl.wake_on_touch)
513: return;
514:
515: if (device->state == KGSL_STATE_SLUMBER)
MATCH LINES: 625, 627, 628, 629
613: {
614: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
615: unsigned int reg;
616:
617: adreno_writereg(adreno_dev, ADRENO_REG_RBBM_SW_RESET_CMD, 1);
618: /*
619: * Do a dummy read to get a brief read cycle delay for the
620: * reset to take effect
621: */
622: adreno_readreg(adreno_dev, ADRENO_REG_RBBM_SW_RESET_CMD, ®);
623: adreno_writereg(adreno_dev, ADRENO_REG_RBBM_SW_RESET_CMD, 0);
624:
625: /* The SP/TP regulator gets turned off after a soft reset */
626:
627: clear_bit(ADRENO_DEVICE_GPU_REGULATOR_ENABLED, &adreno_dev->priv);
628: if (gpudev->regulator_enable)
629: gpudev->regulator_enable(adreno_dev);
630: }
631:
632: /**
633: * adreno_irqctrl() - Enables/disables the RBBM interrupt mask
634: * @adreno_dev: Pointer to an adreno_device
635: * @state: 1 for masked or 0 for unmasked
636: * Power: The caller of this function must make sure to use OOBs
637: * so that we know that the GPU is powered on
638: */
639: void adreno_irqctrl(struct adreno_device *adreno_dev, int state)
640: {
641: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
642:
643: if (!adreno_dev->irq_mask)
644: return;
645:
646: adreno_writereg(adreno_dev, ADRENO_REG_RBBM_INT_0_MASK,
647: state ? adreno_dev->irq_mask : 0);
648:
649: if (gpudev->swfuse_irqctrl)
650: gpudev->swfuse_irqctrl(adreno_dev, state);
651: }
652:
653: /*
MATCH LINES: 1088, 1098, 1102
1076: if (index >= ARRAY_SIZE(pwr->pwrlevels)) {
1077: dev_err(device->dev, "%pOF: Pwrlevel index %d is out of range\n",
1078: child, index);
1079: continue;
1080: }
1081:
1082: if (index >= pwr->num_pwrlevels)
1083: pwr->num_pwrlevels = index + 1;
1084:
1085: level = &pwr->pwrlevels[index];
1086:
1087: level->gpu_freq = freq;
1088: level->bus_freq = bus;
1089: level->voltage_level = voltage;
1090: level->cx_level = 0xffffffff;
1091:
1092: of_property_read_u32(child, "qcom,acd-level",
1093: &level->acd_level);
1094:
1095: of_property_read_u32(child, "qcom,cx-level",
1096: &level->cx_level);
1097:
1098: level->bus_min = level->bus_freq;
1099: kgsl_of_property_read_ddrtype(child,
1100: "qcom,bus-min", &level->bus_min);
1101:
1102: level->bus_max = level->bus_freq;
1103: kgsl_of_property_read_ddrtype(child,
1104: "qcom,bus-max", &level->bus_max);
1105: }
1106:
1107: adreno_build_opp_table(&device->pdev->dev, pwr);
1108: return 0;
1109: out:
1110: of_node_put(child);
1111: return ret;
1112: }
1113:
1114: static void adreno_of_get_initial_pwrlevels(struct kgsl_pwrctrl *pwr,
1115: struct device_node *node)
1116: {
1117: int level;
1118:
1119: /* Get and set the initial power level */
1120: if (WARN_ON(of_property_read_u32(node, "qcom,initial-pwrlevel", &level) ||
1121: level < 0 || level >= pwr->num_pwrlevels))
1122: level = 1;
1123:
1124: pwr->active_pwrlevel = level;
1125: pwr->default_pwrlevel = level;
1126:
MATCH LINES: 1191, 1196, 1200, 1202, 1203, 1205, 1212, 1214, 1218, 1219, 1223
1179: adreno_of_get_limits(adreno_dev, parent);
1180: }
1181:
1182: of_node_put(node);
1183: return ret;
1184: }
1185:
1186: static int adreno_parse_ib_votes(struct kgsl_device *device,
1187: struct dev_pm_opp *opp, struct kgsl_pwrlevel *level)
1188: {
1189: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1190: struct device_node *child;
1191: u32 bus_freq;
1192: int ret, i;
1193:
1194: child = dev_pm_opp_get_of_node(opp);
1195:
1196: /* Initialize bus_freq, bus_min, and bus_max using "qcom,bus-freq" if available.
1197: * If not, fall back to "opp-peak-kBps" and map it to ddr_table index.
1198: * Return error if neither property is found or if mapping fails.
1199: */
1200: ret = kgsl_of_property_read_ddrtype(child, "qcom,bus-freq", &bus_freq);
1201: if (!ret) {
1202: level->bus_freq = bus_freq;
1203: level->bus_min = bus_freq;
1204: kgsl_of_property_read_ddrtype(child, "qcom,bus-min", &level->bus_min);
1205: level->bus_max = bus_freq;
1206: kgsl_of_property_read_ddrtype(child, "qcom,bus-max", &level->bus_max);
1207:
1208: of_node_put(child);
1209: return 0;
1210: }
1211:
1212: ret = of_property_read_u32(child, "opp-peak-kBps", &bus_freq);
1213: if (!ret) {
1214: for (i = 0; i < pwr->ddr_table_count && pwr->ddr_table[i] != bus_freq; i++)
1215: ;
1216:
1217: if (i == pwr->ddr_table_count) {
1218: dev_err(device->dev, "%pOF: bus_freq %u not found in ddr_table\n",
1219: child, bus_freq);
1220: return -EINVAL;
1221: }
1222:
1223: level->bus_freq = i;
1224: level->bus_min = i;
1225: level->bus_max = i;
1226:
1227: of_node_put(child);
1228: return 0;
1229: }
1230:
1231: /* Neither "qcom,bus-freq" nor "opp-peak-kBps" was found */
1232: dev_err(device->dev, "%pOF: Missing bus frequency properties\n", child);
1233: of_node_put(child);
1234: return -EINVAL;
1235: }
1236:
1237: static int adreno_parse_opp_node(struct kgsl_device *device,
1238: struct dev_pm_opp *opp, struct kgsl_pwrlevel *level)
1239: {
1240: int ret;
1241:
1242: level->opp = opp;
1243:
1244: level->voltage_level = dev_pm_opp_get_level(opp);
1245:
1246: if (level->voltage_level == U32_MAX)
1247: level->voltage_level = dev_pm_opp_get_required_pstate(opp, 0);
MATCH LINES: 1758, 1759
1746: }
1747: #endif
1748:
1749: const char *hfi_feature_to_string(u32 feature)
1750: {
1751: switch (feature) {
1752: case HFI_FEATURE_HWSCHED:
1753: return "HWSCHED";
1754: case HFI_FEATURE_PREEMPTION:
1755: return "PREEMPTION";
1756: case HFI_FEATURE_LM:
1757: return "LM";
1758: case HFI_FEATURE_IFPC:
1759: return "IFPC";
1760: case HFI_FEATURE_BCL:
1761: return "BCL";
1762: case HFI_FEATURE_ACD:
1763: return "ACD";
1764: case HFI_FEATURE_KPROF:
1765: return "KPROF";
1766: case HFI_FEATURE_BAIL_OUT_TIMER:
1767: return "BAIL_OUT_TIMER";
1768: case HFI_FEATURE_GMU_STATS:
1769: return "GMU_STATS";
1770: case HFI_FEATURE_CLX:
1771: return "CLX";
1772: case HFI_FEATURE_LSR:
1773: return "LSR";
1774: case HFI_FEATURE_LPAC:
1775: return "LPAC";
1776: case HFI_FEATURE_HW_FENCE:
1777: return "HW_FENCE";
1778: case HFI_FEATURE_PERF_NORETAIN:
1779: return "PERF_NORETAIN";
1780: case HFI_FEATURE_DMS:
1781: return "DMS";
1782: case HFI_FEATURE_AQE:
1783: return "AQE";
MATCH LINES: 1967, 1970
1955:
1956: return NOTIFY_DONE;
1957: }
1958:
1959: static void validate_pwrlevels(struct kgsl_device *device)
1960: {
1961: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1962: int i, count = pwr->ddr_table_count;
1963:
1964: for (i = 0; i < pwr->num_pwrlevels - 1; i++) {
1965: struct kgsl_pwrlevel *pwrlevel = &pwr->pwrlevels[i];
1966:
1967: if (pwrlevel->bus_freq >= count) {
1968: dev_err(device->dev, "Bus setting for GPU freq %d is out of bounds\n",
1969: pwrlevel->gpu_freq);
1970: pwrlevel->bus_freq = count - 1;
1971: }
1972:
1973: if (pwrlevel->bus_max >= count) {
1974: dev_err(device->dev, "Bus max for GPU freq %d is out of bounds\n",
1975: pwrlevel->gpu_freq);
1976: pwrlevel->bus_max = count - 1;
1977: }
1978:
1979: if (pwrlevel->bus_min >= count) {
1980: dev_err(device->dev, "Bus min for GPU freq %d is out of bounds\n",
1981: pwrlevel->gpu_freq);
1982: pwrlevel->bus_min = count - 1;
1983: }
1984:
1985: if (pwrlevel->bus_min > pwrlevel->bus_max) {
1986: dev_err(device->dev, "Bus min is bigger than bus max for GPU freq %d\n",
1987: pwrlevel->gpu_freq);
1988: pwrlevel->bus_min = pwrlevel->bus_max;
1989: }
1990: }
1991: }
1992:
1993: static int adreno_init_ubwc_legacy(struct adreno_device *adreno_dev)
1994: {
MATCH LINES: 2480, 2486, 2515, 2522
2468: */
2469: if (device->state == KGSL_STATE_ACTIVE)
2470: adreno_wait_idle(device);
2471: kgsl_pwrctrl_change_state(device, KGSL_STATE_SLUMBER);
2472: dev_err(device->dev, "resume invoked without a suspend\n");
2473: }
2474: }
2475:
2476: static int adreno_pm_resume(struct device *dev)
2477: {
2478: struct kgsl_device *device = dev_get_drvdata(dev);
2479: struct adreno_device *adreno_dev;
2480: const struct adreno_power_ops *ops;
2481:
2482: if (!device)
2483: return 0;
2484:
2485: adreno_dev = ADRENO_DEVICE(device);
2486: ops = ADRENO_POWER_OPS(adreno_dev);
2487:
2488: kgsl_mutex_lock(&device->mutex);
2489: #if IS_ENABLED(CONFIG_DEEPSLEEP)
2490: if (pm_suspend_via_firmware())
2491: device->mmu.iommu.smmu_aperture_set = false;
2492: #endif
2493: ops->pm_resume(adreno_dev);
2494: kgsl_mutex_unlock(&device->mutex);
2495:
2496: kgsl_reclaim_start();
2497: return 0;
2498: }
2499:
2500: static int adreno_suspend(struct adreno_device *adreno_dev)
2501: {
2502: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2503: int status = kgsl_pwrctrl_change_state(device, KGSL_STATE_SUSPEND);
2504:
2505: if (!status && device->state == KGSL_STATE_SUSPEND)
2506: adreno_get_gpu_halt(adreno_dev);
2507:
2508: return status;
2509: }
2510:
2511: static int adreno_pm_suspend(struct device *dev)
2512: {
2513: struct kgsl_device *device = dev_get_drvdata(dev);
2514: struct adreno_device *adreno_dev;
2515: const struct adreno_power_ops *ops;
2516: int status;
2517:
2518: if (!device)
2519: return 0;
2520:
2521: adreno_dev = ADRENO_DEVICE(device);
2522: ops = ADRENO_POWER_OPS(adreno_dev);
2523:
2524: /* Return early if fault recovery is in progress */
2525: if (!mutex_trylock(&adreno_dev->fault_recovery_mutex))
2526: return -EDEADLK;
2527:
2528: kgsl_mutex_lock(&device->mutex);
2529: status = ops->pm_suspend(adreno_dev);
2530:
2531: #if IS_ENABLED(CONFIG_DEEPSLEEP)
2532: if (!status && pm_suspend_via_firmware())
2533: adreno_zap_shader_unload(adreno_dev);
2534: #endif
2535:
2536: kgsl_mutex_unlock(&device->mutex);
2537: mutex_unlock(&adreno_dev->fault_recovery_mutex);
2538:
2539: if (status)
2540: return status;
2541:
2542: /*
2543: * When the device enters in suspend state, the CX can be collapsed causing
2544: * the GPU CX timer to pause. Clear the ADRENO_DEVICE_CX_TIMER_INITIALIZED
2545: * flag to ensure that the CX timer is reseeded during resume.
2546: */
MATCH LINES: 2606, 2607, 2609, 2610
2594: set_bit(ADRENO_DEVICE_INITIALIZED, &adreno_dev->priv);
2595:
2596: return 0;
2597: }
2598:
2599: static bool gdscs_left_on(struct kgsl_device *device)
2600: {
2601: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
2602:
2603: if (gmu_core_gpmu_isenabled(device))
2604: return false;
2605:
2606: if (pwr->cx_regulator)
2607: return regulator_is_enabled(pwr->cx_regulator);
2608:
2609: if (pwr->gx_regulator)
2610: return regulator_is_enabled(pwr->gx_regulator);
2611:
2612: if (pwr->gmu_cx_pd)
2613: return kgsl_genpd_is_enabled(pwr->gmu_cx_pd);
2614:
2615: if (pwr->gx_pd)
2616: return kgsl_genpd_is_enabled(pwr->gx_pd);
2617:
2618: return false;
2619: }
2620:
2621: void adreno_set_active_ctxs_null(struct adreno_device *adreno_dev)
2622: {
2623: int i;
2624: struct adreno_ringbuffer *rb;
2625: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2626:
2627: FOR_EACH_RINGBUFFER(adreno_dev, rb, i) {
2628: if (rb->drawctxt_active)
2629: kgsl_context_put(&(rb->drawctxt_active->base));
2630: rb->drawctxt_active = NULL;
2631:
2632: kgsl_sharedmem_writel(device->scratch,
2633: SCRATCH_RB_OFFSET(rb->id, current_rb_ptname),
2634: 0);
MATCH LINES: 2676, 2693
2664:
2665: return 0;
2666: err:
2667: kgsl_pwrctrl_change_state(device, KGSL_STATE_INIT);
2668: atomic_dec(&device->active_cnt);
2669:
2670: return ret;
2671: }
2672:
2673: static int adreno_first_open(struct kgsl_device *device)
2674: {
2675: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
2676: const struct adreno_power_ops *ops = ADRENO_POWER_OPS(adreno_dev);
2677:
2678: if (!device->pdev_loaded)
2679: return -ENODEV;
2680:
2681: return ops->first_open(adreno_dev);
2682: }
2683:
2684: static int adreno_close(struct adreno_device *adreno_dev)
2685: {
2686: return kgsl_pwrctrl_change_state(KGSL_DEVICE(adreno_dev),
2687: KGSL_STATE_INIT);
2688: }
2689:
2690: static int adreno_last_close(struct kgsl_device *device)
2691: {
2692: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
2693: const struct adreno_power_ops *ops = ADRENO_POWER_OPS(adreno_dev);
2694:
2695: /*
2696: * Wait up to 1 second for the active count to go low
2697: * and then start complaining about it
2698: */
2699: if (kgsl_active_count_wait(device, 0, HZ)) {
2700: dev_err(device->dev,
2701: "Waiting for the active count to become 0\n");
2702:
2703: while (kgsl_active_count_wait(device, 0, HZ))
2704: dev_err(device->dev,
2705: "Still waiting for the active count\n");
2706: }
2707:
2708: return ops->last_close(adreno_dev);
2709: }
2710:
2711: static int adreno_pwrctrl_active_count_get(struct adreno_device *adreno_dev)
2712: {
2713: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2714: int ret = 0;
2715:
2716: if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex)))
2717: return -EINVAL;
MATCH LINES: 2764
2752:
2753: kgsl_start_idle_timer(device);
2754: }
2755:
2756: trace_kgsl_active_count(device,
2757: (unsigned long) __builtin_return_address(0));
2758:
2759: wake_up(&device->active_cnt_wq);
2760: }
2761:
2762: int adreno_active_count_get(struct adreno_device *adreno_dev)
2763: {
2764: const struct adreno_power_ops *ops = ADRENO_POWER_OPS(adreno_dev);
2765:
2766: return ops->active_count_get(adreno_dev);
2767: }
2768:
2769: void adreno_get_bus_counters(struct adreno_device *adreno_dev)
2770: {
2771: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2772: int ret = 0;
2773:
2774: if (!device->pwrctrl.bus_control)
2775: return;
2776:
2777: /* VBIF waiting for RAM */
2778: ret |= adreno_perfcounter_kernel_get(adreno_dev,
2779: KGSL_PERFCOUNTER_GROUP_VBIF_PWR, 0,
2780: &adreno_dev->starved_ram_lo, NULL);
2781:
2782: /* Target has GBIF */
2783: if (adreno_is_gen8(adreno_dev) || adreno_is_gen7(adreno_dev) ||
2784: (adreno_is_a6xx(adreno_dev) && !adreno_is_a630(adreno_dev))) {
2785: ret |= adreno_perfcounter_kernel_get(adreno_dev,
2786: KGSL_PERFCOUNTER_GROUP_VBIF_PWR, 1,
2787: &adreno_dev->starved_ram_lo_ch1, NULL);
2788:
MATCH LINES: 2899
2887: if (status)
2888: goto error_pwr_off;
2889:
2890: /* Set any stale active contexts to NULL */
2891: adreno_set_active_ctxs_null(adreno_dev);
2892:
2893: /* Set the bit to indicate that we've just powered on */
2894: set_bit(ADRENO_DEVICE_PWRON, &adreno_dev->priv);
2895:
2896: /* Clear the busy_data stats - we're starting over from scratch */
2897: memset(&adreno_dev->busy_data, 0, sizeof(adreno_dev->busy_data));
2898:
2899: /* Soft reset the GPU if a regulator is stuck on*/
2900: if (gdsc_left_on)
2901: _soft_reset(adreno_dev);
2902:
2903: /* Start the GPU */
2904: status = gpudev->start(adreno_dev);
2905: if (status)
2906: goto error_pwr_off;
2907:
2908: /* Re-initialize the coresight registers if applicable */
2909: adreno_coresight_start(adreno_dev);
2910:
2911: adreno_irqctrl(adreno_dev, 1);
2912:
2913: adreno_perfcounter_start(adreno_dev);
2914:
2915: /* Clear FSR here in case it is set from a previous pagefault */
2916: kgsl_mmu_clear_fsr(&device->mmu);
2917:
2918: status = gpudev->rb_start(adreno_dev);
2919: if (status)
2920: goto error_pwr_off;
2921:
2922: /*
2923: * At this point it is safe to assume that we recovered. Setting
MATCH LINES: 3334
3322: return ARRAY_SIZE(adreno_property_funcs);
3323:
3324: for (i = 0; i < count && i < ARRAY_SIZE(adreno_property_funcs); i++)
3325: list[i] = adreno_property_funcs[i].type;
3326:
3327: return i;
3328: }
3329:
3330: static int adreno_gmu_based_dcvs_pwr_ops(struct kgsl_device *device, u32 arg,
3331: enum gpu_pwrlevel_op op)
3332: {
3333: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
3334: const struct adreno_power_ops *ops = ADRENO_POWER_OPS(adreno_dev);
3335:
3336: if (device->host_based_dcvs)
3337: return -EOPNOTSUPP;
3338:
3339: if (ops->gmu_based_dcvs_pwr_ops)
3340: ops->gmu_based_dcvs_pwr_ops(adreno_dev, arg, op);
3341:
3342: return 0;
3343: }
3344:
3345: int adreno_set_constraint(struct kgsl_device *device,
3346: struct kgsl_context *context,
3347: struct kgsl_device_constraint *constraint)
3348: {
3349: int status = 0;
3350:
3351: switch (constraint->type) {
3352: case KGSL_CONSTRAINT_PWRLEVEL: {
3353: struct kgsl_device_constraint_pwrlevel pwr;
3354: u32 max_supported_level;
3355:
3356: if (constraint->size != sizeof(pwr)) {
3357: status = -EINVAL;
3358: break;
MATCH LINES: 4100, 4105, 4106, 4125, 4130, 4131
4088: * Power: The caller is expected to be in a clock enabled state as this
4089: * function does reg reads
4090: */
4091: static void adreno_power_stats(struct kgsl_device *device,
4092: struct kgsl_power_stats *stats)
4093: {
4094: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
4095: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
4096:
4097: return gpudev->power_stats(adreno_dev, stats);
4098: }
4099:
4100: static int adreno_regulator_enable(struct kgsl_device *device)
4101: {
4102: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
4103: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
4104:
4105: if (gpudev->regulator_enable)
4106: return gpudev->regulator_enable(adreno_dev);
4107:
4108: return 0;
4109: }
4110:
4111: static bool adreno_is_hw_collapsible(struct kgsl_device *device)
4112: {
4113: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
4114: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
4115:
4116: if (!gpudev->is_hw_collapsible(adreno_dev))
4117: return false;
4118:
4119: if (gpudev->clear_pending_transactions(adreno_dev))
4120: return false;
4121:
4122: return true;
4123: }
4124:
4125: static void adreno_regulator_disable(struct kgsl_device *device)
4126: {
4127: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
4128: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
4129:
4130: if (gpudev->regulator_disable)
4131: gpudev->regulator_disable(adreno_dev);
4132: }
4133:
4134: static void adreno_pwrlevel_change_settings(struct kgsl_device *device,
4135: unsigned int prelevel, unsigned int postlevel, bool post)
4136: {
4137: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
4138: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
4139:
4140: if (gpudev->pwrlevel_change_settings)
4141: gpudev->pwrlevel_change_settings(adreno_dev, prelevel,
4142: postlevel, post);
4143: }
4144:
4145: static bool adreno_is_hwcg_on(struct kgsl_device *device)
4146: {
4147: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
4148:
4149: return adreno_dev->hwcg_enabled;
4150: }
4151:
4152: static int adreno_queue_cmds(struct kgsl_device_private *dev_priv,
4153: struct kgsl_context *context, struct kgsl_drawobj *drawobj[],
4154: u32 count, u32 *timestamp)
4155: {
MATCH LINES: 4368
4356: }
4357:
4358: fault = adreno_gpu_fault(adreno_dev);
4359:
4360: return (fault & ADRENO_IOMMU_STALL_ON_PAGE_FAULT) ? true : false;
4361: }
4362:
4363: int adreno_power_cycle(struct adreno_device *adreno_dev,
4364: void (*callback)(struct adreno_device *adreno_dev, void *priv),
4365: void *priv)
4366: {
4367: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
4368: const struct adreno_power_ops *ops = ADRENO_POWER_OPS(adreno_dev);
4369: int ret;
4370:
4371: kgsl_mutex_lock(&device->mutex);
4372: ret = ops->pm_suspend(adreno_dev);
4373:
4374: if (!ret) {
4375: callback(adreno_dev, priv);
4376: gmu_core_mark_for_coldboot(device);
4377: ops->pm_resume(adreno_dev);
4378: }
4379:
4380: kgsl_mutex_unlock(&device->mutex);
4381:
4382: return ret;
4383: }
4384:
4385: struct cycle_data {
4386: void *ptr;
4387: void *val;
4388: };
4389:
4390: static void cycle_set_bool(struct adreno_device *adreno_dev, void *priv)
4391: {
4392: struct cycle_data *data = priv;
MATCH LINES: 4431, 4432, 4440, 4457
4419:
4420: static int adreno_set_opp(struct kgsl_device *device, struct kgsl_pwrlevel *level)
4421: {
4422: struct device *dev = &device->pdev->dev;
4423: int ret;
4424:
4425: /*
4426: * level->opp is initialized with a valid OPP pointer only when the driver
4427: * is probed with standard DT bindings. Use this to distinguish standard
4428: * vs non‑standard kernels here.
4429: *
4430: * On non‑standard kernels (level->opp == NULL), vote the core clock using
4431: * clk_set_rate API. The downstream clock driver internally handles the
4432: * required regulator voting.
4433: *
4434: * On standard kernels (level->opp != NULL), use dev_pm_opp_set_opp() API
4435: * and OPP framework will take care of all required votes.
4436: */
4437: if (!level->opp) {
4438: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
4439:
4440: ret = clk_set_rate(pwr->grp_clks[0], level->gpu_freq);
4441: if (ret)
4442: dev_err(device->dev, "GPU clk freq set failure: %d\n", ret);
4443:
4444: return ret;
4445: }
4446:
4447: ret = dev_pm_opp_set_opp(dev, level->opp);
4448: if (ret)
4449: dev_err(device->dev, "GPU OPP configure failure: %d\n", ret);
4450:
4451: return ret;
4452: }
4453:
4454: static int adreno_gpu_clock_set(struct kgsl_device *device, u32 pwrlevel)
4455: {
4456: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
4457: const struct adreno_power_ops *ops = ADRENO_POWER_OPS(adreno_dev);
4458: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
4459: struct kgsl_pwrlevel *level = &pwr->pwrlevels[pwrlevel];
4460: u32 prev_pwrlevel = pwr->previous_pwrlevel;
4461: int ret;
4462:
4463: if (ops->gpu_clock_set) {
4464: ret = ops->gpu_clock_set(adreno_dev, pwrlevel);
4465: } else
4466: ret = adreno_set_opp(device, level);
4467:
4468:
4469: if (ret)
4470: return ret;
4471:
4472: trace_kgsl_pwrlevel(device, pwrlevel, level->gpu_freq,
4473: prev_pwrlevel, pwr->pwrlevels[prev_pwrlevel].gpu_freq, 0);
4474:
4475: KGSL_TRACE_GPU_FREQ(level->gpu_freq/1000, 0, 0);
4476: return 0;
4477: }
4478:
4479: static int adreno_interconnect_bus_set(struct adreno_device *adreno_dev,
4480: int level, u32 ab)
4481: {
MATCH LINES: 4503
4491:
4492: icc_set_bw(pwr->icc_path, MBps_to_icc(ab),
4493: kBps_to_icc(pwr->ddr_table[level]));
4494:
4495: trace_kgsl_buslevel(device, pwr->active_pwrlevel, level, ab, 0);
4496:
4497: return 0;
4498: }
4499:
4500: static int adreno_gpu_bus_set(struct kgsl_device *device, int level, u32 ab)
4501: {
4502: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
4503: const struct adreno_power_ops *ops = ADRENO_POWER_OPS(adreno_dev);
4504:
4505: if (ops->gpu_bus_set)
4506: return ops->gpu_bus_set(adreno_dev, level, ab);
4507:
4508: return adreno_interconnect_bus_set(adreno_dev, level, ab);
4509: }
4510:
4511: u32 adreno_gmu_bus_ab_quantize(struct adreno_device *adreno_dev, u32 ab)
4512: {
4513: u16 vote = 0;
4514: u32 max_bw, max_ab;
4515: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
4516: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
4517:
4518: if (!adreno_dev->gmu_ab || (ab == INVALID_AB_VALUE))
4519: return (FIELD_PREP(GENMASK(31, 16), INVALID_AB_VALUE));
4520:
4521: /*
4522: * max ddr bandwidth (kbps) = (Max bw in kbps per channel * number of channel)
4523: * max ab (Mbps) = max ddr bandwidth (kbps) / 1000
4524: */
4525: max_bw = pwr->ddr_table[pwr->ddr_table_count - 1] * adreno_dev->gpucore->num_ddr_channels;
4526: max_ab = max_bw / 1000;
4527:
MATCH LINES: 4679
4667: add_proc_fault_list(adreno_dev, proc_priv);
4668: }
4669: if (drawobj_lpac) {
4670: proc_priv_lpac = drawobj_lpac->context->proc_priv;
4671: if (proc_priv_lpac != proc_priv)
4672: add_proc_fault_list(adreno_dev, proc_priv_lpac);
4673: }
4674: }
4675:
4676: static void adreno_set_thermal_index(struct kgsl_device *device)
4677: {
4678: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
4679: const struct adreno_power_ops *ops = ADRENO_POWER_OPS(adreno_dev);
4680:
4681: if (ops->set_thermal_index)
4682: ops->set_thermal_index(adreno_dev);
4683: }
4684:
4685: static int adreno_set_smmu_aperture(struct kgsl_device *device)
4686: {
4687: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
4688: const struct adreno_gpu_core *gpucore = adreno_dev->gpucore;
4689: int i;
4690:
4691: if (!gpucore->smmu_aperture_count || !device->smmu_aperture_virt)
4692: return -ENODEV;
4693:
4694: for (i = 0; i < gpucore->smmu_aperture_count; i++)
4695: writel_relaxed(gpucore->smmu_aperture[i].val, device->smmu_aperture_virt +
4696: (gpucore->smmu_aperture[i].offset << 2));
4697:
4698: /* Make sure all of the preceding writes have posted */
4699: wmb();
4700:
4701: return 0;
4702: }
4703:
MATCH LINES: 4739, 4741, 4764
4727: .drain_and_idle = adreno_drain_and_idle,
4728: .device_private_create = adreno_device_private_create,
4729: .device_private_destroy = adreno_device_private_destroy,
4730: /* Optional functions */
4731: .drawctxt_create = adreno_drawctxt_create,
4732: .drawctxt_detach = adreno_drawctxt_detach,
4733: .drawctxt_destroy = adreno_drawctxt_destroy,
4734: .drawctxt_dump = adreno_drawctxt_dump,
4735: .setproperty = adreno_setproperty,
4736: .setproperty_compat = adreno_setproperty_compat,
4737: .drawctxt_sched = adreno_drawctxt_sched,
4738: .resume = adreno_dispatcher_start,
4739: .regulator_enable = adreno_regulator_enable,
4740: .is_hw_collapsible = adreno_is_hw_collapsible,
4741: .regulator_disable = adreno_regulator_disable,
4742: .pwrlevel_change_settings = adreno_pwrlevel_change_settings,
4743: .query_property_list = adreno_query_property_list,
4744: .is_hwcg_on = adreno_is_hwcg_on,
4745: .gpu_clock_set = adreno_gpu_clock_set,
4746: .gpu_bus_set = adreno_gpu_bus_set,
4747: .deassert_gbif_halt = adreno_deassert_gbif_halt,
4748: .queue_recurring_cmd = adreno_queue_recurring_cmd,
4749: .dequeue_recurring_cmd = adreno_dequeue_recurring_cmd,
4750: .set_isdb_breakpoint_registers = adreno_set_isdb_breakpoint_registers,
4751: .create_hw_fence = adreno_create_hw_fence,
4752: .gmu_based_dcvs_pwr_ops = adreno_gmu_based_dcvs_pwr_ops,
4753: .set_thermal_index = adreno_set_thermal_index,
4754: .alloc_dcvs_profile_memory = adreno_alloc_dcvs_profile_memory,
4755: .is_first_boot_done = adreno_is_first_boot_done,
4756: .set_smmu_aperture = adreno_set_smmu_aperture,
4757: };
4758:
4759: static const struct component_master_ops adreno_ops = {
4760: .bind = adreno_bind,
4761: .unbind = adreno_unbind,
4762: };
4763:
4764: const struct adreno_power_ops adreno_power_operations = {
4765: .first_open = adreno_open,
4766: .last_close = adreno_close,
4767: .active_count_get = adreno_pwrctrl_active_count_get,
4768: .pm_suspend = adreno_suspend,
4769: .pm_resume = adreno_resume,
4770: .touch_wakeup = adreno_touch_wakeup,
4771: };
4772:
4773: static int _compare_of(struct device *dev, void *data)
4774: {
4775: return (dev->of_node == data);
4776: }
4777:
4778: static void _release_of(struct device *dev, void *data)
4779: {
4780: of_node_put(data);
4781: }
4782:
4783: static void adreno_add_components(struct device *dev,
4784: struct component_match **match, const struct of_device_id *matches)
4785: {
4786: struct device_node *node;
4787:
4788: /*
MATCH LINES: 4984, 4991
4972: }
4973:
4974: static int adreno_secure_pt_restore(struct adreno_device *adreno_dev)
4975: {
4976: return 0;
4977: }
4978: #endif /* IS_ENABLED(CONFIG_QCOM_SECURE_BUFFER) */
4979:
4980: static int adreno_hibernation_suspend(struct device *dev)
4981: {
4982: struct kgsl_device *device = dev_get_drvdata(dev);
4983: struct adreno_device *adreno_dev;
4984: const struct adreno_power_ops *ops;
4985: int status;
4986:
4987: if (!device)
4988: return 0;
4989:
4990: adreno_dev = ADRENO_DEVICE(device);
4991: ops = ADRENO_POWER_OPS(adreno_dev);
4992:
4993: kgsl_mutex_lock(&device->mutex);
4994:
4995: status = ops->pm_suspend(adreno_dev);
4996: if (status)
4997: goto err;
4998:
4999: /*
5000: * When the device enters in hibernation state, the CX will be collapsed causing
5001: * the GPU CX timer to pause. Clear the ADRENO_DEVICE_CX_TIMER_INITIALIZED flag
5002: * to ensure that the CX timer is reseeded during resume.
5003: */
5004: clear_bit(ADRENO_DEVICE_CX_TIMER_INITIALIZED, &adreno_dev->priv);
5005:
5006: /*
5007: * Unload zap shader during device hibernation and reload it
5008: * during resume as there is possibility that TZ driver
5009: * is not aware of the hibernation.
5010: */
5011: adreno_zap_shader_unload(adreno_dev);
5012: status = adreno_secure_pt_hibernate(adreno_dev);
5013:
5014: err:
5015: kgsl_mutex_unlock(&device->mutex);
MATCH LINES: 5033, 5042
5021: if (governor && !strcmp(governor, "msm-adreno-tz"))
5022: return msm_adreno_tz_reinit(devfreq);
5023:
5024: return 0;
5025: }
5026:
5027: static int adreno_hibernation_resume(struct device *dev)
5028: {
5029: struct kgsl_device *device = dev_get_drvdata(dev);
5030: struct kgsl_iommu *iommu;
5031: struct kgsl_pwrscale *pwrscale;
5032: struct adreno_device *adreno_dev;
5033: const struct adreno_power_ops *ops;
5034: int ret;
5035:
5036: if (!device)
5037: return 0;
5038:
5039: iommu = &device->mmu.iommu;
5040: pwrscale = &device->pwrscale;
5041: adreno_dev = ADRENO_DEVICE(device);
5042: ops = ADRENO_POWER_OPS(adreno_dev);
5043:
5044: kgsl_mutex_lock(&device->mutex);
5045:
5046: ret = adreno_secure_pt_restore(adreno_dev);
5047: if (ret)
5048: goto err;
5049:
5050: iommu->smmu_aperture_set = false;
5051:
5052: gmu_core_dev_force_first_boot(device);
5053:
5054: governor_reinit(pwrscale->devfreqptr, CONFIG_QCOM_ADRENO_DEFAULT_GOVERNOR);
5055:
5056: ops->pm_resume(adreno_dev);
5057:
5058: err:
5059: kgsl_mutex_unlock(&device->mutex);
5060: return ret;
5061: }
5062:
5063: static const struct dev_pm_ops adreno_pm_ops = {
5064: .suspend = adreno_pm_suspend,
5065: .resume = adreno_pm_resume,
5066: .freeze = adreno_hibernation_suspend,
--- FILE: \adreno.h | HITS: 22 ---
MATCH LINES: 54, 57
42:
43: /* KGSL_DEVICE - given an adreno_device, return the KGSL device struct */
44: #define KGSL_DEVICE(_dev) (&((_dev)->dev))
45:
46: /* ADRENO_CONTEXT - Given a context return the adreno context struct */
47: #define ADRENO_CONTEXT(context) \
48: container_of(context, struct adreno_context, base)
49:
50: /* ADRENO_GPU_DEVICE - Given an adreno device return the GPU specific struct */
51: #define ADRENO_GPU_DEVICE(_a) ((_a)->gpucore->gpudev)
52:
53: /*
54: * ADRENO_POWER_OPS - Given an adreno device return the GPU specific power
55: * ops
56: */
57: #define ADRENO_POWER_OPS(_a) ((_a)->gpucore->gpudev->power_ops)
58:
59: #define ADRENO_CHIPID_CORE(_id) FIELD_GET(GENMASK(31, 24), _id)
60: #define ADRENO_CHIPID_MAJOR(_id) FIELD_GET(GENMASK(23, 16), _id)
61: #define ADRENO_CHIPID_MINOR(_id) FIELD_GET(GENMASK(15, 8), _id)
62: #define ADRENO_CHIPID_PATCH(_id) FIELD_GET(GENMASK(7, 0), _id)
63:
64: #define ADRENO_GMU_CHIPID(_id) \
65: (FIELD_PREP(GENMASK(31, 24), ADRENO_CHIPID_CORE(_id)) | \
66: FIELD_PREP(GENMASK(23, 16), ADRENO_CHIPID_MAJOR(_id)) | \
67: FIELD_PREP(GENMASK(15, 12), ADRENO_CHIPID_MINOR(_id)) | \
68: FIELD_PREP(GENMASK(11, 8), ADRENO_CHIPID_PATCH(_id)))
69:
70: #define ADRENO_REV_MAJOR(_rev) FIELD_GET(GENMASK(23, 16), _rev)
71: #define ADRENO_REV_MINOR(_rev) FIELD_GET(GENMASK(15, 8), _rev)
72: #define ADRENO_REV_PATCH(_rev) FIELD_GET(GENMASK(7, 0), _rev)
73:
74: #define ADRENO_GMU_REV(_rev) \
75: (FIELD_PREP(GENMASK(31, 24), ADRENO_REV_MAJOR(_rev)) | \
76: FIELD_PREP(GENMASK(23, 16), ADRENO_REV_MINOR(_rev)) | \
77: FIELD_PREP(GENMASK(15, 8), ADRENO_REV_PATCH(_rev)))
78:
79: /* ADRENO_GPUREV - Return the GPU ID for the given adreno_device */
80: #define ADRENO_GPUREV(_a) ((_a)->gpucore->gpurev)
81:
MATCH LINES: 148, 149
136: /* The core supports SP/TP hw controlled power collapse */
137: #define ADRENO_SPTP_PC BIT(0)
138: /* The GPU supports content protection */
139: #define ADRENO_CONTENT_PROTECTION BIT(1)
140: /* The GPU supports preemption */
141: #define ADRENO_PREEMPTION BIT(2)
142: /* The GPMU supports Limits Management */
143: #define ADRENO_LM BIT(3)
144: /* The GPU supports retention for cpz registers */
145: #define ADRENO_CPZ_RETENTION BIT(4)
146: /* The core has soft fault detection available */
147: #define ADRENO_SOFT_FAULT_DETECT BIT(5)
148: /* The GMU supports IFPC power management*/
149: #define ADRENO_IFPC BIT(6)
150: /* The core supports IO-coherent memory */
151: #define ADRENO_IOCOHERENT BIT(7)
152: /*
153: * The GMU supports Adaptive Clock Distribution (ACD)
154: * for droop mitigation
155: */
156: #define ADRENO_ACD BIT(8)
157: /* Cooperative reset enabled GMU */
158: #define ADRENO_COOP_RESET BIT(9)
159: /* Indicates that the specific target is no longer supported */
160: #define ADRENO_DEPRECATED BIT(10)
161: /* The target supports ringbuffer level APRIV */
162: #define ADRENO_APRIV BIT(11)
163: /* The GMU supports Battery Current Limiting */
164: #define ADRENO_BCL BIT(12)
165: /* L3 voting is supported with L3 constraints */
166: #define ADRENO_L3_VOTE BIT(13)
167: /* LPAC is supported */
168: #define ADRENO_LPAC BIT(14)
169: /* Late Stage Reprojection (LSR) enablment for GMU */
170: #define ADRENO_LSR BIT(15)
171: /* GMU and kernel supports hardware fences */
172: #define ADRENO_HW_FENCE BIT(16)
173: /* Dynamic Mode Switching supported on this target */
MATCH LINES: 457
445: */
446: u32 postamble_bootup_len;
447: };
448:
449: struct adreno_busy_data {
450: unsigned int gpu_busy;
451: unsigned int bif_ram_cycles;
452: unsigned int bif_ram_cycles_read_ch1;
453: unsigned int bif_ram_cycles_write_ch0;
454: unsigned int bif_ram_cycles_write_ch1;
455: unsigned int bif_starved_ram;
456: unsigned int bif_starved_ram_ch1;
457: unsigned int num_ifpc;
458: unsigned int throttle_cycles[ADRENO_GPMU_THROTTLE_COUNTERS];
459: u32 bcl_throttle;
460: };
461:
462: /**
463: * struct adreno_firmware - Struct holding fw details
464: * @fwvirt: Buffer which holds the ucode
465: * @size: Size of ucode buffer
466: * @version: Version of ucode
467: * @memdesc: Memory descriptor which holds ucode buffer info
468: */
469: struct adreno_firmware {
470: unsigned int *fwvirt;
471: size_t size;
472: unsigned int version;
473: struct kgsl_memdesc *memdesc;
474: };
475:
476: /**
477: * struct adreno_perfcounter_list_node - struct to store perfcounters
478: * allocated by a process on a kgsl fd.
479: * @groupid: groupid of the allocated perfcounter
480: * @countable: countable assigned to the allocated perfcounter
481: * @node: list node for perfcounter_list of a process
MATCH LINES: 511, 514
499: /**
500: * struct adreno_reglist_list - A container for list of registers and
501: * number of registers in the list
502: */
503: struct adreno_reglist_list {
504: /** @reg: List of register **/
505: const u32 *regs;
506: /** @count: Number of registers in the list **/
507: u32 count;
508: };
509:
510: /**
511: * struct adreno_power_ops - Container for target specific power up/down
512: * sequences
513: */
514: struct adreno_power_ops {
515: /**
516: * @first_open: Target specific function triggered when first kgsl
517: * instance is opened
518: */
519: int (*first_open)(struct adreno_device *adreno_dev);
520: /**
521: * @last_close: Target specific function triggered when last kgsl
522: * instance is closed
523: */
524: int (*last_close)(struct adreno_device *adreno_dev);
525: /**
526: * @active_count_get: Target specific function to keep gpu from power
527: * collapsing
528: */
529: int (*active_count_get)(struct adreno_device *adreno_dev);
530: /** @pm_suspend: Target specific function to suspend the driver */
531: int (*pm_suspend)(struct adreno_device *adreno_dev);
532: /** @pm_resume: Target specific function to resume the driver */
533: void (*pm_resume)(struct adreno_device *adreno_dev);
534: /**
535: * @touch_wakeup: Target specific function to start gpu on touch event
536: */
537: void (*touch_wakeup)(struct adreno_device *adreno_dev);
538: /** @gpu_clock_set: Target specific function to set gpu frequency */
MATCH LINES: 700, 706
688: * @ram_cycles_lo_ch1_write: Number of DDR channel 0 Write clock cycles for
689: * the monitor session
690: * @starved_ram_lo: Number of cycles VBIF/GBIF is stalled by DDR (Only channel 0
691: * stall cycles in case of GBIF)
692: * @starved_ram_lo_ch1: Number of cycles GBIF is stalled by DDR channel 1
693: * @halt: Atomic variable to check whether the GPU is currently halted
694: * @pending_irq_refcnt: Atomic variable to keep track of running IRQ handlers
695: * @ctx_d_debugfs: Context debugfs node
696: * @profile_buffer: Memdesc holding the drawobj profiling buffer
697: * @profile_index: Index to store the start/stop ticks in the profiling
698: * buffer
699: * @pwrup_reglist: Memdesc holding the power up register list
700: * which is used by CP during preemption and IFPC
701: * @lm_sequence: Pointer to the start of the register write sequence for LM
702: * @lm_size: The dword size of the LM sequence
703: * @lm_limit: limiting value for LM
704: * @lm_threshold_count: register value for counter for lm threshold breakin
705: * @lm_threshold_cross: number of current peaks exceeding threshold
706: * @ifpc_count: Number of times the GPU went into IFPC
707: * @highest_bank_bit: Value of the highest bank bit
708: * @gpmu_throttle_counters - counters for number of throttled clocks
709: * @irq_storm_work: Worker to handle possible interrupt storms
710: * @active_list: List to track active contexts
711: * @active_list_lock: Lock to protect active_list
712: * @gpu_llc_slice: GPU system cache slice descriptor
713: * @gpu_llc_slice_enable: To enable the GPU system cache slice or not
714: * @gpuhtw_llc_slice: GPU pagetables system cache slice descriptor
715: * @gpuhtw_llc_slice_enable: To enable the GPUHTW system cache slice or not
716: * @gpumv_llc_slice: GPU MV buffer system cache slice descriptor
717: * @gpumv_llc_slice_enable: To enable GPUMV buffer system cache slice or not
718: * @zap_loaded: Used to track if zap was successfully loaded or not
719: */
720: struct adreno_device {
721: struct kgsl_device dev; /* Must be first field in this struct */
722: unsigned long priv;
723: unsigned int chipid;
724: /** @uche_gmem_base: Base address of GMEM for UCHE access */
725: u64 uche_gmem_base;
726: const struct adreno_gpu_core *gpucore;
727: struct adreno_firmware fw[2];
728: size_t gpmu_cmds_size;
729: unsigned int *gpmu_cmds;
730: struct adreno_ringbuffer ringbuffers[KGSL_PRIORITY_MAX_RB_LEVELS];
MATCH LINES: 790
778: bool preempt_override;
779: struct kgsl_memdesc *profile_buffer;
780: unsigned int profile_index;
781: struct kgsl_memdesc *pwrup_reglist;
782: uint32_t *lm_sequence;
783: uint32_t lm_size;
784: struct adreno_preemption preempt;
785: struct work_struct gpmu_work;
786: uint32_t lm_leakage;
787: uint32_t lm_limit;
788: uint32_t lm_threshold_count;
789: uint32_t lm_threshold_cross;
790: uint32_t ifpc_count;
791:
792: unsigned int highest_bank_bit;
793: /** @ubwc_mode: Supported UBWC mode */
794: u32 ubwc_mode;
795: /** @mal: Minimum access length */
796: u32 mal;
797: unsigned int quirks;
798:
799: #ifdef CONFIG_QCOM_KGSL_CORESIGHT
800: /** @gx_coresight: A coresight instance for GX */
801: struct adreno_coresight_device gx_coresight;
802: /** @gx_coresight: A coresight instance for CX */
803: struct adreno_coresight_device cx_coresight;
804: /** @funnel_gfx: A coresight instance for gfx funnel */
805: struct adreno_funnel_device funnel_gfx;
806: /**
807: * @coresight_en_cnt: Retain mask if either coresight-gfx
808: * or coresight-gfx-cx is enabled; remove only when both
809: * are disabled
810: */
811: u32 coresight_en_cnt;
812: #endif
813:
814: uint32_t gpmu_throttle_counters[ADRENO_GPMU_THROTTLE_COUNTERS];
MATCH LINES: 862, 882, 883, 884, 885
850: /* @patch_reglist: If false power up register list needs to be patched */
851: bool patch_reglist;
852: /*
853: * @uche_client_pf: uche_client_pf client register configuration
854: * for pf debugging
855: */
856: u32 uche_client_pf;
857: /**
858: * @bcl_data: bit 0 contains response type for bcl alarms and bits 1:24 controls
859: * throttle level for bcl alarm levels 0-2. If not set, gmu fw sets default throttle levels.
860: */
861: u32 bcl_data;
862: /* @minbw_data: Min bw level to vote for when entering ifpc */
863: u32 minbw_data;
864: /*
865: * @bcl_debugfs_dir: Debugfs directory node for bcl related nodes
866: */
867: struct dentry *bcl_debugfs_dir;
868: /** @bcl_throttle_time_us: Total time in us spent in BCL throttling */
869: u32 bcl_throttle_time_us;
870: /* @preemption_debugfs_dir: Debugfs directory node for preemption related nodes */
871: struct dentry *preemption_debugfs_dir;
872: /* @hwsched_enabled: If true, hwsched is enabled */
873: bool hwsched_enabled;
874: /* @fastblend_enabled: True if fastblend feature is enabled */
875: bool fastblend_enabled;
876: /* @raytracing_enabled: True if raytracing feature is enabled */
877: bool raytracing_enabled;
878: /* @feature_fuse: feature fuse value read from HW */
879: u32 feature_fuse;
880: /** @gmu_ab: Track if GMU supports ab vote */
881: bool gmu_ab;
882: /** @ifpc_hyst: IFPC long hysteresis value */
883: u32 ifpc_hyst;
884: /** @ifpc_hyst_floor: IFPC long hysteresis floor value */
885: u32 ifpc_hyst_floor;
886: /*
887: * @no_restore_count: Keep track of perfcounter requests that don't have
888: * ADRENO_PERFCOUNTER_GROUP_RESTORE flag set
889: */
890: u32 no_restore_count;
891: /*
892: * @ahb_timeout_val: AHB transaction timeout value.
893: * If set, a timeout will occur in 2 ^ (ahb_timeout_val + 1) cycles.
894: */
895: u32 ahb_timeout_val;
896: /** @fault_counts: Keep track of GPU faults */
897: u32 fault_counts[ADRENO_FAULT_TYPES];
898: /**
899: * @fault_procs: Array to keep track of per process GPU fault count sorted by the number
900: * of GPU faults
901: */
902: struct adreno_fault_proc fault_procs[ADRENO_MAX_FAULTING_PROCS];
903: /** @fault_stats_lock: A R/W lock to protect GPU fault statistics */
904: rwlock_t fault_stats_lock;
905: /** @fault_recovery_mutex: Mutex taken during fault handling in the dispatcher */
906: struct mutex fault_recovery_mutex;
907: /** @pm_nb: Notifier block for defining a callback that gets called during system suspend */
908: struct notifier_block pm_nb;
909: /** @suspend_recovery_gate: Gate to wait on for system to come out of suspend */
MATCH LINES: 975
963: * @ADRENO_DEVICE_ISDB_ENABLED - Set if the Integrated Shader DeBugger is
964: * attached and enabled
965: * @ADRENO_DEVICE_CACHE_FLUSH_TS_SUSPENDED - Set if a CACHE_FLUSH_TS irq storm
966: * is in progress
967: */
968: enum adreno_device_flags {
969: ADRENO_DEVICE_PWRON = 0,
970: ADRENO_DEVICE_PWRON_FIXUP = 1,
971: ADRENO_DEVICE_INITIALIZED = 2,
972: ADRENO_DEVICE_STARTED = 5,
973: ADRENO_DEVICE_FAULT = 6,
974: ADRENO_DEVICE_DRAWOBJ_PROFILE = 7,
975: ADRENO_DEVICE_GPU_REGULATOR_ENABLED = 8,
976: ADRENO_DEVICE_PREEMPTION = 9,
977: ADRENO_DEVICE_SOFT_FAULT_DETECT = 10,
978: ADRENO_DEVICE_GPMU_INITIALIZED = 11,
979: ADRENO_DEVICE_ISDB_ENABLED = 12,
980: ADRENO_DEVICE_CACHE_FLUSH_TS_SUSPENDED = 13,
981: /** @ADRENO_DEVICE_DMS: Set if DMS is enabled */
982: ADRENO_DEVICE_DMS = 14,
983: /** @ADRENO_DEVICE_GMU_AB: Set if AB vote via GMU is enabled */
984: ADRENO_DEVICE_GMU_AB = 15,
985: /** @ADRENO_DEVICE_CX_TIMER_INITIALIZED: Set if the CX timer is initialized */
986: ADRENO_DEVICE_CX_TIMER_INITIALIZED = 17,
987: /** @ADRENO_DEVICE_RESET_RECOVERY: Set if the ADRENO device under goes reset recovery */
988: ADRENO_DEVICE_RESET_RECOVERY = 18,
989: /** @ADRENO_DEVICE_FIRST_BOOT_DONE: Set if the ADRENO device first boot is done */
990: ADRENO_DEVICE_FIRST_BOOT_DONE = 19,
991: /** @ADRENO_DEVICE_FAST_CONTEXT_DESTROY: Set if fast context destroy is enabled on GMU */
992: ADRENO_DEVICE_FAST_CONTEXT_DESTROY = 20,
993: /** @ADRENO_DEVICE_ALLOW_MALU_WORKLOAD: mALU workload is supported by GMU and GPU */
994: ADRENO_DEVICE_ALLOW_MALU_WORKLOAD = 21,
995: };
996:
997: /**
998: * struct adreno_drawobj_profile_entry - a single drawobj entry in the
999: * kernel profiling buffer
MATCH LINES: 1097, 1098, 1105, 1117, 1120
1085: unsigned int *const reg_offsets;
1086:
1087: /* GPU specific function hooks */
1088: int (*probe)(struct platform_device *pdev, u32 chipid,
1089: const struct adreno_gpu_core *gpucore);
1090: void (*snapshot)(struct adreno_device *adreno_dev,
1091: struct kgsl_snapshot *snapshot);
1092: irqreturn_t (*irq_handler)(struct adreno_device *adreno_dev);
1093: int (*init)(struct adreno_device *adreno_dev);
1094: void (*remove)(struct adreno_device *adreno_dev);
1095: int (*rb_start)(struct adreno_device *adreno_dev);
1096: int (*start)(struct adreno_device *adreno_dev);
1097: int (*regulator_enable)(struct adreno_device *adreno_dev);
1098: void (*regulator_disable)(struct adreno_device *adreno_dev);
1099: void (*pwrlevel_change_settings)(struct adreno_device *adreno_dev,
1100: unsigned int prelevel, unsigned int postlevel,
1101: bool post);
1102: void (*preemption_schedule)(struct adreno_device *adreno_dev);
1103: void (*context_detach)(struct adreno_context *drawctxt);
1104: void (*pre_reset)(struct adreno_device *adreno_dev);
1105: void (*gpu_keepalive)(struct adreno_device *adreno_dev,
1106: bool state);
1107: bool (*hw_isidle)(struct adreno_device *adreno_dev);
1108: const char *(*iommu_fault_block)(struct kgsl_device *device,
1109: unsigned int fsynr1);
1110: int (*reset)(struct adreno_device *adreno_dev);
1111: /** @soft_reset: Soft reset GPU on fault recovery */
1112: int (*soft_reset)(struct adreno_device *adreno_dev,
1113: struct kgsl_context *context, bool ctx_guilty);
1114: /** @read_alwayson: Return the current value of the alwayson counter */
1115: u64 (*read_alwayson)(struct adreno_device *adreno_dev);
1116: /**
1117: * @power_ops: Target specific function pointers to power up/down the
1118: * gpu
1119: */
1120: const struct adreno_power_ops *power_ops;
1121: int (*clear_pending_transactions)(struct adreno_device *adreno_dev);
1122: void (*deassert_gbif_halt)(struct adreno_device *adreno_dev);
1123: int (*ringbuffer_submitcmd)(struct adreno_device *adreno_dev,
1124: struct kgsl_drawobj_cmd *cmdobj, u32 flags,
1125: struct adreno_submit_time *time);
1126: /**
1127: * @is_hw_collapsible: Return true if the hardware can be collapsed.
1128: * Only used by non GMU/RGMU targets
1129: */
1130: bool (*is_hw_collapsible)(struct adreno_device *adreno_dev);
1131: /**
1132: * @power_stats - Return the perfcounter statistics for DCVS
1133: */
1134: void (*power_stats)(struct adreno_device *adreno_dev,
1135: struct kgsl_power_stats *stats);
1136: int (*add_to_va_minidump)(struct adreno_device *adreno_dev);
1137: /**
1138: * @gx_is_on - Return true if both gfx clock and gxgdsc are enabled.
1139: */
1140: bool (*gx_is_on)(struct adreno_device *adreno_dev);
1141: /**
1142: * @send_recurring_cmdobj - Target specific function to send recurring IBs to GMU
1143: */
1144: int (*send_recurring_cmdobj)(struct adreno_device *adreno_dev,
MATCH LINES: 1234
1222: /* Internal bits - set during GFT */
1223: /* Skip the PM dump on replayed command obj's */
1224: KGSL_FT_SKIP_PMDUMP = 31,
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);
--- FILE: \adreno_a5xx.c | HITS: 17 ---
MATCH LINES: 37
25:
26: static int critical_packet_constructed;
27: static unsigned int crit_pkts_dwords;
28:
29: static void a5xx_irq_storm_worker(struct work_struct *work);
30: static int _read_fw2_block_header(struct kgsl_device *device,
31: uint32_t *header, uint32_t remain,
32: uint32_t id, uint32_t major, uint32_t minor);
33: static void a5xx_gpmu_reset(struct work_struct *work);
34: static int a5xx_gpmu_init(struct adreno_device *adreno_dev);
35:
36: /**
37: * Number of times to check if the regulator enabled before
38: * giving up and returning failure.
39: */
40: #define PWR_RETRY 100
41:
42: /**
43: * Number of times to check if the GPMU firmware is initialized before
44: * giving up and returning failure.
45: */
46: #define GPMU_FW_INIT_RETRY 5000
47:
48: #define A530_QFPROM_RAW_PTE_ROW0_MSB 0x134
49: #define A530_QFPROM_RAW_PTE_ROW2_MSB 0x144
50:
51: #define A5XX_INT_MASK \
52: ((1 << A5XX_INT_RBBM_AHB_ERROR) | \
53: (1 << A5XX_INT_RBBM_TRANSFER_TIMEOUT) | \
54: (1 << A5XX_INT_RBBM_ME_MS_TIMEOUT) | \
55: (1 << A5XX_INT_RBBM_PFP_MS_TIMEOUT) | \
56: (1 << A5XX_INT_RBBM_ETS_MS_TIMEOUT) | \
57: (1 << A5XX_INT_RBBM_ATB_ASYNC_OVERFLOW) | \
58: (1 << A5XX_INT_RBBM_GPC_ERROR) | \
59: (1 << A5XX_INT_CP_HW_ERROR) | \
60: (1 << A5XX_INT_CP_CACHE_FLUSH_TS) | \
61: (1 << A5XX_INT_RBBM_ATB_BUS_OVERFLOW) | \
MATCH LINES: 337, 340, 343, 348, 359, 395, 400, 403, 407, 415
325:
326: /* if we never stored memory locations - do nothing */
327: if (isense_regs[0] == 0xFFFF)
328: return;
329:
330: /* restore registers from memory */
331: for (i = 0; i < ARRAY_SIZE(isense_reg_addr); i++)
332: kgsl_regwrite(device, isense_reg_addr[i], isense_regs[i]);
333:
334: }
335:
336: /*
337: * a5xx_regulator_enable() - Enable any necessary HW regulators
338: * @adreno_dev: The adreno device pointer
339: *
340: * Some HW blocks may need their regulators explicitly enabled
341: * on a restart. Clocks must be on during this call.
342: */
343: static int a5xx_regulator_enable(struct adreno_device *adreno_dev)
344: {
345: unsigned int ret;
346: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
347:
348: if (test_bit(ADRENO_DEVICE_GPU_REGULATOR_ENABLED,
349: &adreno_dev->priv))
350: return 0;
351:
352: if (!(adreno_is_a530(adreno_dev) || adreno_is_a540(adreno_dev))) {
353: /* Halt the sp_input_clk at HM level */
354: kgsl_regwrite(device, A5XX_RBBM_CLOCK_CNTL, 0x00000055);
355: a5xx_hwcg_set(adreno_dev, true);
356: /* Turn on sp_input_clk at HM level */
357: kgsl_regrmw(device, A5XX_RBBM_CLOCK_CNTL, 0xFF, 0);
358:
359: set_bit(ADRENO_DEVICE_GPU_REGULATOR_ENABLED,
360: &adreno_dev->priv);
361: return 0;
362: }
363:
364: /*
365: * Turn on smaller power domain first to reduce voltage droop.
366: * Set the default register values; set SW_COLLAPSE to 0.
367: */
368: kgsl_regwrite(device, A5XX_GPMU_RBCCU_POWER_CNTL, 0x778000);
369: /* Insert a delay between RAC and SPTP GDSC to reduce voltage droop */
370: udelay(3);
371: ret = _poll_gdsc_status(adreno_dev, A5XX_GPMU_RBCCU_PWR_CLK_STATUS, 1);
372: if (ret) {
373: dev_err(device->dev, "RBCCU GDSC enable failed\n");
374: return ret;
375: }
376:
377: kgsl_regwrite(device, A5XX_GPMU_SP_POWER_CNTL, 0x778000);
378: ret = _poll_gdsc_status(adreno_dev, A5XX_GPMU_SP_PWR_CLK_STATUS, 1);
379: if (ret) {
380: dev_err(device->dev, "SPTP GDSC enable failed\n");
381: return ret;
382: }
383:
384: /* Disable SP clock */
385: kgsl_regrmw(device, A5XX_GPMU_GPMU_SP_CLOCK_CONTROL,
386: CNTL_IP_CLK_ENABLE, 0);
387: /* Enable hardware clockgating */
388: a5xx_hwcg_set(adreno_dev, true);
389: /* Enable SP clock */
390: kgsl_regrmw(device, A5XX_GPMU_GPMU_SP_CLOCK_CONTROL,
391: CNTL_IP_CLK_ENABLE, 1);
392:
393: a5xx_restore_isense_regs(adreno_dev);
394:
395: set_bit(ADRENO_DEVICE_GPU_REGULATOR_ENABLED, &adreno_dev->priv);
396: return 0;
397: }
398:
399: /*
400: * a5xx_regulator_disable() - Disable any necessary HW regulators
401: * @adreno_dev: The adreno device pointer
402: *
403: * Some HW blocks may need their regulators explicitly disabled
404: * on a power down to prevent current spikes. Clocks must be on
405: * during this call.
406: */
407: static void a5xx_regulator_disable(struct adreno_device *adreno_dev)
408: {
409: unsigned int reg;
410: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
411:
412: if (adreno_is_a512(adreno_dev) || adreno_is_a508(adreno_dev))
413: return;
414:
415: if (!test_and_clear_bit(ADRENO_DEVICE_GPU_REGULATOR_ENABLED,
416: &adreno_dev->priv))
417: return;
418:
419: /* If feature is not supported or not enabled */
420: if (!adreno_dev->sptp_pc_enabled) {
421: /* Set the default register values; set SW_COLLAPSE to 1 */
422: kgsl_regwrite(device, A5XX_GPMU_SP_POWER_CNTL, 0x778001);
423: /*
424: * Insert a delay between SPTP and RAC GDSC to reduce voltage
425: * droop.
426: */
427: udelay(3);
428: if (_poll_gdsc_status(adreno_dev,
429: A5XX_GPMU_SP_PWR_CLK_STATUS, 0))
430: dev_warn(device->dev, "SPTP GDSC disable failed\n");
431:
432: kgsl_regwrite(device, A5XX_GPMU_RBCCU_POWER_CNTL, 0x778001);
433: if (_poll_gdsc_status(adreno_dev,
434: A5XX_GPMU_RBCCU_PWR_CLK_STATUS, 0))
435: dev_warn(device->dev, "RBCCU GDSC disable failed\n");
436: } else if (test_bit(ADRENO_DEVICE_GPMU_INITIALIZED,
437: &adreno_dev->priv)) {
438: /* GPMU firmware is supposed to turn off SPTP & RAC GDSCs. */
439: kgsl_regread(device, A5XX_GPMU_SP_PWR_CLK_STATUS, ®);
MATCH LINES: 675
663: if (ret)
664: a5xx_spin_idle_debug(adreno_dev,
665: "gpmu initialization failed to idle\n");
666: }
667: return ret;
668: }
669:
670: /*
671: * a5xx_gpmu_start() - Initialize and start the GPMU
672: * @adreno_dev: Pointer to adreno device
673: *
674: * Load the GPMU microcode, set up any features such as hardware clock gating
675: * or IFPC, and take the GPMU out of reset.
676: */
677: static int a5xx_gpmu_start(struct adreno_device *adreno_dev)
678: {
679: int ret;
680: unsigned int reg, retry = GPMU_FW_INIT_RETRY;
681: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
682:
683: if (!a5xx_has_gpmu(adreno_dev))
684: return 0;
685:
686: ret = _gpmu_send_init_cmds(adreno_dev);
687: if (ret)
688: return ret;
689:
690: if (adreno_is_a530(adreno_dev)) {
691: /* GPMU clock gating setup */
692: kgsl_regwrite(device, A5XX_GPMU_WFI_CONFIG, 0x00004014);
693: }
694: /* Kick off GPMU firmware */
695: kgsl_regwrite(device, A5XX_GPMU_CM3_SYSRESET, 0);
696: /*
697: * The hardware team's estimation of GPMU firmware initialization
698: * latency is about 3000 cycles, that's about 5 to 24 usec.
699: */
MATCH LINES: 1196, 1217
1184: trace_kgsl_clock_throttling(
1185: th[IDLE_10PCT], th[CRC_50PCT],
1186: th[CRC_MORE50PCT], th[CRC_LESS50PCT],
1187: adj);
1188: return adj;
1189: }
1190:
1191: /*
1192: * a5xx_gpmu_reset() - Re-enable GPMU based power features and restart GPMU
1193: * @work: Pointer to the work struct for gpmu reset
1194: *
1195: * Load the GPMU microcode, set up any features such as hardware clock gating
1196: * or IFPC, and take the GPMU out of reset.
1197: */
1198: static void a5xx_gpmu_reset(struct work_struct *work)
1199: {
1200: struct adreno_device *adreno_dev = container_of(work,
1201: struct adreno_device, gpmu_work);
1202: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1203:
1204: if (test_bit(ADRENO_DEVICE_GPMU_INITIALIZED, &adreno_dev->priv))
1205: return;
1206:
1207: /*
1208: * If GPMU has already experienced a restart or is in the process of it
1209: * after the watchdog timeout, then there is no need to reset GPMU
1210: * again.
1211: */
1212: if (device->state != KGSL_STATE_AWARE && device->state != KGSL_STATE_ACTIVE)
1213: return;
1214:
1215: kgsl_mutex_lock(&device->mutex);
1216:
1217: if (a5xx_regulator_enable(adreno_dev))
1218: goto out;
1219:
1220: /* Soft reset of the GPMU block */
1221: kgsl_regwrite(device, A5XX_RBBM_BLOCK_SW_RESET_CMD, BIT(16));
1222:
1223: /* GPU comes up in secured mode, make it unsecured by default */
1224: if (!ADRENO_FEATURE(adreno_dev, ADRENO_CONTENT_PROTECTION))
1225: kgsl_regwrite(device, A5XX_RBBM_SECVID_TRUST_CNTL, 0x0);
1226:
1227:
1228: a5xx_gpmu_init(adreno_dev);
1229:
1230: out:
1231: kgsl_mutex_unlock(&device->mutex);
1232: }
1233:
1234: static void _setup_throttling_counters(struct adreno_device *adreno_dev)
1235: {
1236: int i, ret = 0;
1237:
1238: if (!adreno_is_a540(adreno_dev))
1239: return;
1240:
1241: for (i = 0; i < ADRENO_GPMU_THROTTLE_COUNTERS; i++) {
MATCH LINES: 2436, 2437, 2442
2424: stats->ram_wait = counter_delta(device, adreno_dev->starved_ram_lo,
2425: &busy->bif_starved_ram);
2426: }
2427:
2428: const struct adreno_gpudev adreno_a5xx_gpudev = {
2429: .reg_offsets = a5xx_register_offsets,
2430: .probe = a5xx_probe,
2431: .start = a5xx_start,
2432: .snapshot = a5xx_snapshot,
2433: .init = a5xx_init,
2434: .irq_handler = a5xx_irq_handler,
2435: .rb_start = a5xx_rb_start,
2436: .regulator_enable = a5xx_regulator_enable,
2437: .regulator_disable = a5xx_regulator_disable,
2438: .pwrlevel_change_settings = a5xx_pwrlevel_change_settings,
2439: .preemption_schedule = a5xx_preemption_schedule,
2440: .read_alwayson = a5xx_read_alwayson,
2441: .hw_isidle = a5xx_hw_isidle,
2442: .power_ops = &adreno_power_operations,
2443: .clear_pending_transactions = a5xx_clear_pending_transactions,
2444: .remove = a5xx_remove,
2445: .ringbuffer_submitcmd = a5xx_ringbuffer_submitcmd,
2446: .is_hw_collapsible = a5xx_is_hw_collapsible,
2447: .power_stats = a5xx_power_stats,
2448: };
--- FILE: \adreno_a6xx.c | HITS: 66 ---
MATCH LINES: 28, 62, 63
16: #include <linux/soc/qcom/ubwc.h>
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,
MATCH LINES: 103
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,
MATCH LINES: 493, 494, 498, 502, 525, 553, 554, 555
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,
MATCH LINES: 614
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;
MATCH LINES: 743, 745
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:
MATCH LINES: 832, 833
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);
MATCH LINES: 1258, 1261, 1277, 1281, 1289
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;
MATCH LINES: 1354, 1357, 1360
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: 1484
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: */
MATCH LINES: 1748
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]);
MATCH LINES: 1923, 1925, 1935, 1937, 1951, 1953, 1969, 1971
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))
MATCH LINES: 2256, 2267, 2268, 2269, 2270, 2272, 2273, 2274
2244: stats->ram_time = ram_cycles;
2245: stats->ram_wait = starved_ram;
2246: }
2247:
2248: static void a6xx_power_stats(struct adreno_device *adreno_dev,
2249: struct kgsl_power_stats *stats)
2250: {
2251: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2252: struct adreno_busy_data *busy = &adreno_dev->busy_data;
2253: s64 gpu_busy;
2254:
2255: /* Set the GPU busy counter for frequency scaling */
2256: gpu_busy = counter_delta(device, A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_L,
2257: &busy->gpu_busy);
2258:
2259: gpu_busy += a6xx_read_throttling_counters(adreno_dev);
2260: /* If adjustment cycles are more than busy cycles make gpu_busy zero */
2261: if (gpu_busy < 0)
2262: gpu_busy = 0;
2263:
2264: stats->busy_time = gpu_busy * 10;
2265: do_div(stats->busy_time, 192);
2266:
2267: if (ADRENO_FEATURE(adreno_dev, ADRENO_IFPC)) {
2268: u32 ifpc = counter_delta(device,
2269: A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_4_L,
2270: &busy->num_ifpc);
2271:
2272: adreno_dev->ifpc_count += ifpc;
2273: if (ifpc > 0)
2274: trace_adreno_ifpc_count(adreno_dev->ifpc_count);
2275: }
2276:
2277: if (device->pwrctrl.bus_control)
2278: a6xx_read_bus_stats(device, stats, busy);
2279: }
2280:
2281: static int a6xx_dev_add_to_minidump(struct adreno_device *adreno_dev)
2282: {
2283: return kgsl_add_va_to_minidump(adreno_dev->dev.dev, KGSL_ADRENO_DEVICE,
2284: (void *)(adreno_dev), sizeof(struct adreno_device));
2285: }
2286:
2287: static void a6xx_set_isdb_breakpoint_registers(struct adreno_device *adreno_dev)
2288: {
2289: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2290: struct clk *clk;
2291: int ret;
2292:
2293: /* QDSS unavailable, suppress force panic */
2294: if (!IS_ENABLED(CONFIG_QCOM_KGSL_QDSS_STM))
2295: goto err;
2296:
2297: if (!device->set_isdb_breakpoint || device->ftbl->is_hwcg_on(device)
2298: || device->qdss_gfx_virt == NULL || !device->force_panic)
MATCH LINES: 2343, 2356, 2367, 2392, 2393, 2399, 2420, 2440, 2441, 2442, 2448, 2466, 2467, 2468, 2474, 2491, 2492, 2493, 2499, 2517, 2518, 2519, 2525
2331: err:
2332: /* Do not force kernel panic if isdb writes did not go through */
2333: device->force_panic = false;
2334: }
2335:
2336: static int a619_holi_sptprac_enable(struct adreno_device *adreno_dev)
2337: {
2338: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2339: void __iomem *addr = kgsl_regmap_virt(&device->regmap,
2340: A6XX_GMU_SPTPRAC_PWR_CLK_STATUS);
2341: u32 val;
2342:
2343: if (test_bit(ADRENO_DEVICE_GPU_REGULATOR_ENABLED, &adreno_dev->priv))
2344: return 0;
2345:
2346: kgsl_regwrite(device, A6XX_GMU_GX_SPTPRAC_POWER_CONTROL,
2347: SPTPRAC_POWERON_CTRL_MASK);
2348:
2349: if (readl_poll_timeout(addr, val,
2350: (val & SPTPRAC_POWERON_STATUS_MASK) ==
2351: SPTPRAC_POWERON_STATUS_MASK, 10, 10 * 1000)) {
2352: dev_err(device->dev, "power on SPTPRAC fail\n");
2353: return -EINVAL;
2354: }
2355:
2356: set_bit(ADRENO_DEVICE_GPU_REGULATOR_ENABLED, &adreno_dev->priv);
2357: return 0;
2358: }
2359:
2360: static void a619_holi_sptprac_disable(struct adreno_device *adreno_dev)
2361: {
2362: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2363: void __iomem *addr = kgsl_regmap_virt(&device->regmap,
2364: A6XX_GMU_SPTPRAC_PWR_CLK_STATUS);
2365: u32 val;
2366:
2367: if (!test_and_clear_bit(ADRENO_DEVICE_GPU_REGULATOR_ENABLED,
2368: &adreno_dev->priv))
2369: return;
2370:
2371: /* Ensure that retention is on */
2372: kgsl_regrmw(device, A6XX_GPU_CC_GX_GDSCR, 0,
2373: A6XX_RETAIN_FF_ENABLE_ENABLE_MASK);
2374:
2375: kgsl_regwrite(device, A6XX_GMU_GX_SPTPRAC_POWER_CONTROL,
2376: SPTPRAC_POWEROFF_CTRL_MASK);
2377: if (readl_poll_timeout(addr, val,
2378: (val & SPTPRAC_POWEROFF_STATUS_MASK) ==
2379: SPTPRAC_POWEROFF_STATUS_MASK, 10, 10 * 1000))
2380: dev_err(device->dev, "power off SPTPRAC fail\n");
2381: }
2382:
2383: /* This is a non GMU/RGMU part */
2384: const struct adreno_gpudev adreno_a6xx_gpudev = {
2385: .reg_offsets = a6xx_register_offsets,
2386: .probe = a6xx_probe,
2387: .start = a6xx_nogmu_start,
2388: .snapshot = a6xx_snapshot,
2389: .init = a6xx_nogmu_init,
2390: .irq_handler = a6xx_irq_handler,
2391: .rb_start = a6xx_rb_start,
2392: .regulator_disable = a6xx_prepare_for_regulator_disable,
2393: .gpu_keepalive = a6xx_gpu_keepalive,
2394: .hw_isidle = a6xx_hw_isidle,
2395: .iommu_fault_block = a6xx_iommu_fault_block,
2396: .reset = a6xx_reset,
2397: .preemption_schedule = a6xx_preemption_schedule,
2398: .read_alwayson = a6xx_read_alwayson,
2399: .power_ops = &adreno_power_operations,
2400: .clear_pending_transactions = a6xx_clear_pending_transactions,
2401: .deassert_gbif_halt = a6xx_deassert_gbif_halt,
2402: .remove = a6xx_remove,
2403: .ringbuffer_submitcmd = a6xx_ringbuffer_submitcmd,
2404: .is_hw_collapsible = adreno_isidle,
2405: .power_stats = a6xx_power_stats,
2406: .add_to_va_minidump = a6xx_dev_add_to_minidump,
2407: .gx_is_on = a6xx_gx_is_on,
2408: };
2409:
2410: const struct a6xx_gpudev adreno_a6xx_hwsched_gpudev = {
2411: .base = {
2412: .reg_offsets = a6xx_register_offsets,
2413: .probe = a6xx_hwsched_probe,
2414: .snapshot = a6xx_hwsched_snapshot,
2415: .irq_handler = a6xx_hwsched_irq_handler,
2416: .iommu_fault_block = a6xx_iommu_fault_block,
2417: .context_detach = a6xx_hwsched_context_detach,
2418: .read_alwayson = a6xx_read_alwayson,
2419: .reset = a6xx_hwsched_reset_replay,
2420: .power_ops = &a6xx_hwsched_power_ops,
2421: .power_stats = a6xx_power_stats,
2422: .hw_isidle = a6xx_hw_isidle,
2423: .add_to_va_minidump = a6xx_hwsched_add_to_minidump,
2424: .gx_is_on = a6xx_gmu_gx_is_on,
2425: .send_recurring_cmdobj = a6xx_hwsched_send_recurring_cmdobj,
2426: .set_isdb_breakpoint_registers = a6xx_set_isdb_breakpoint_registers,
2427: },
2428: .hfi_probe = a6xx_hwsched_hfi_probe,
2429: .hfi_remove = a6xx_hwsched_hfi_remove,
2430: .handle_watchdog = a6xx_hwsched_handle_watchdog,
2431: };
2432:
2433: const struct a6xx_gpudev adreno_a6xx_gmu_gpudev = {
2434: .base = {
2435: .reg_offsets = a6xx_register_offsets,
2436: .probe = a6xx_gmu_device_probe,
2437: .snapshot = a6xx_gmu_snapshot,
2438: .irq_handler = a6xx_irq_handler,
2439: .rb_start = a6xx_rb_start,
2440: .regulator_enable = a6xx_sptprac_enable,
2441: .regulator_disable = a6xx_sptprac_disable,
2442: .gpu_keepalive = a6xx_gpu_keepalive,
2443: .hw_isidle = a6xx_hw_isidle,
2444: .iommu_fault_block = a6xx_iommu_fault_block,
2445: .reset = a6xx_gmu_reset,
2446: .preemption_schedule = a6xx_preemption_schedule,
2447: .read_alwayson = a6xx_read_alwayson,
2448: .power_ops = &a6xx_gmu_power_ops,
2449: .remove = a6xx_remove,
2450: .ringbuffer_submitcmd = a6xx_ringbuffer_submitcmd,
2451: .power_stats = a6xx_power_stats,
2452: .add_to_va_minidump = a6xx_gmu_add_to_minidump,
2453: .gx_is_on = a6xx_gmu_gx_is_on,
2454: .set_isdb_breakpoint_registers = a6xx_set_isdb_breakpoint_registers,
2455: },
2456: .hfi_probe = a6xx_gmu_hfi_probe,
2457: .handle_watchdog = a6xx_gmu_handle_watchdog,
2458: };
2459:
2460: const struct adreno_gpudev adreno_a6xx_rgmu_gpudev = {
2461: .reg_offsets = a6xx_register_offsets,
2462: .probe = a6xx_rgmu_device_probe,
2463: .snapshot = a6xx_rgmu_snapshot,
2464: .irq_handler = a6xx_irq_handler,
2465: .rb_start = a6xx_rb_start,
2466: .regulator_enable = a6xx_sptprac_enable,
2467: .regulator_disable = a6xx_sptprac_disable,
2468: .gpu_keepalive = a6xx_gpu_keepalive,
2469: .hw_isidle = a6xx_hw_isidle,
2470: .iommu_fault_block = a6xx_iommu_fault_block,
2471: .reset = a6xx_rgmu_reset,
2472: .preemption_schedule = a6xx_preemption_schedule,
2473: .read_alwayson = a6xx_read_alwayson,
2474: .power_ops = &a6xx_rgmu_power_ops,
2475: .remove = a6xx_remove,
2476: .ringbuffer_submitcmd = a6xx_ringbuffer_submitcmd,
2477: .power_stats = a6xx_power_stats,
2478: .add_to_va_minidump = a6xx_rgmu_add_to_minidump,
2479: .gx_is_on = a6xx_rgmu_gx_is_on,
2480: };
2481:
2482: /* This is a non GMU/RGMU part */
2483: const struct adreno_gpudev adreno_a619_holi_gpudev = {
2484: .reg_offsets = a6xx_register_offsets,
2485: .probe = a6xx_probe,
2486: .start = a6xx_nogmu_start,
2487: .snapshot = a6xx_snapshot,
2488: .init = a6xx_nogmu_init,
2489: .irq_handler = a6xx_irq_handler,
2490: .rb_start = a6xx_rb_start,
2491: .regulator_enable = a619_holi_sptprac_enable,
2492: .regulator_disable = a619_holi_sptprac_disable,
2493: .gpu_keepalive = a6xx_gpu_keepalive,
2494: .hw_isidle = a619_holi_hw_isidle,
2495: .iommu_fault_block = a6xx_iommu_fault_block,
2496: .reset = a6xx_reset,
2497: .preemption_schedule = a6xx_preemption_schedule,
2498: .read_alwayson = a6xx_read_alwayson,
2499: .power_ops = &adreno_power_operations,
2500: .clear_pending_transactions = a6xx_clear_pending_transactions,
2501: .deassert_gbif_halt = a6xx_deassert_gbif_halt,
2502: .remove = a6xx_remove,
2503: .ringbuffer_submitcmd = a6xx_ringbuffer_submitcmd,
2504: .is_hw_collapsible = adreno_isidle,
2505: .power_stats = a6xx_power_stats,
2506: .add_to_va_minidump = a6xx_dev_add_to_minidump,
2507: .gx_is_on = a619_holi_gx_is_on,
2508: };
2509:
2510: const struct a6xx_gpudev adreno_a630_gpudev = {
2511: .base = {
2512: .reg_offsets = a6xx_register_offsets,
2513: .probe = a6xx_gmu_device_probe,
2514: .snapshot = a6xx_gmu_snapshot,
2515: .irq_handler = a6xx_irq_handler,
2516: .rb_start = a6xx_rb_start,
2517: .regulator_enable = a6xx_sptprac_enable,
2518: .regulator_disable = a6xx_sptprac_disable,
2519: .gpu_keepalive = a6xx_gpu_keepalive,
2520: .hw_isidle = a6xx_hw_isidle,
2521: .iommu_fault_block = a6xx_iommu_fault_block,
2522: .reset = a6xx_gmu_reset,
2523: .preemption_schedule = a6xx_preemption_schedule,
2524: .read_alwayson = a6xx_read_alwayson,
2525: .power_ops = &a630_gmu_power_ops,
2526: .remove = a6xx_remove,
2527: .ringbuffer_submitcmd = a6xx_ringbuffer_submitcmd,
2528: .power_stats = a6xx_power_stats,
2529: .add_to_va_minidump = a6xx_gmu_add_to_minidump,
2530: .gx_is_on = a6xx_gmu_gx_is_on,
2531: },
2532: .hfi_probe = a6xx_gmu_hfi_probe,
2533: .handle_watchdog = a6xx_gmu_handle_watchdog,
2534: };
--- FILE: \adreno_a6xx.h | HITS: 5 ---
MATCH LINES: 16, 17, 18, 19
4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
5: */
6:
7: #ifndef _ADRENO_A6XX_H_
8: #define _ADRENO_A6XX_H_
9:
10: #include <linux/delay.h>
11:
12: #include "a6xx_reg.h"
13: #include "adreno_a6xx_gmu.h"
14: #include "adreno_a6xx_rgmu.h"
15:
16: extern const struct adreno_power_ops a6xx_gmu_power_ops;
17: extern const struct adreno_power_ops a6xx_rgmu_power_ops;
18: extern const struct adreno_power_ops a630_gmu_power_ops;
19: extern const struct adreno_power_ops a6xx_hwsched_power_ops;
20:
21: struct a6xx_gpudev {
22: struct adreno_gpudev base;
23: int (*hfi_probe)(struct adreno_device *adreno_dev);
24: void (*hfi_remove)(struct adreno_device *adreno_dev);
25: void (*handle_watchdog)(struct adreno_device *adreno_dev);
26: };
27:
28: extern const struct a6xx_gpudev adreno_a630_gpudev;
29: extern const struct a6xx_gpudev adreno_a6xx_gmu_gpudev;
30: extern const struct a6xx_gpudev adreno_a6xx_hwsched_gpudev;
31:
32: /**
33: * struct a6xx_device - Container for the a6xx_device
34: */
35: struct a6xx_device {
36: /** @gmu: Container for the a6xx GMU device */
37: struct a6xx_gmu_device gmu;
38: /** @rgmu: Container for the a6xx rGMU device */
39: struct a6xx_rgmu_device rgmu;
40: /** @adreno_dev: Container for the generic adreno device */
41: struct adreno_device adreno_dev;
42: };
43:
MATCH LINES: 323
311: const struct adreno_gpu_core *gpucore);
312:
313: /**
314: * a6xx_spin_idle_debug - Debug logging used when gpu fails to idle
315: * @adreno_dev: An Adreno GPU handle
316: *
317: * This function logs interesting registers and triggers a snapshot
318: */
319: void a6xx_spin_idle_debug(struct adreno_device *adreno_dev,
320: const char *str);
321:
322: /**
323: * a6xx_perfcounter_update - Update the IFPC perfcounter list
324: * @adreno_dev: An Adreno GPU handle
325: * @reg: Perfcounter reg struct to add/remove to the list
326: * @update_reg: true if the perfcounter needs to be programmed by the CPU
327: *
328: * Return: 0 on success or -EBUSY if the lock couldn't be taken
329: */
330: int a6xx_perfcounter_update(struct adreno_device *adreno_dev,
331: struct adreno_perfcount_register *reg, bool update_reg);
332:
333: /*
334: * a6xx_ringbuffer_init - Initialize the ringbuffers
335: * @adreno_dev: An Adreno GPU handle
336: *
337: * Initialize the ringbuffer(s) for a6xx.
338: * Return: 0 on success or negative on failure
339: */
340: int a6xx_ringbuffer_init(struct adreno_device *adreno_dev);
341:
342: extern const struct adreno_perfcounters adreno_a630_perfcounters;
343: extern const struct adreno_perfcounters adreno_a6xx_perfcounters;
344: extern const struct adreno_perfcounters adreno_a6xx_legacy_perfcounters;
345:
346: /**
347: * a6xx_ringbuffer_addcmds - Submit a command to the ringbuffer
--- FILE: \adreno_a6xx_gmu.c | HITS: 50 ---
MATCH LINES: 14
2: /*
3: * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
5: */
6:
7: #include <linux/component.h>
8: #include <linux/delay.h>
9: #include <linux/dma-map-ops.h>
10: #include <linux/firmware.h>
11: #include <linux/interconnect.h>
12: #include <linux/io.h>
13: #include <linux/kobject.h>
14: #include <linux/regulator/consumer.h>
15: #include <linux/slab.h>
16: #include <linux/sysfs.h>
17: #include <linux/mailbox/qmp.h>
18: #include <linux/vmalloc.h>
19: #include <soc/qcom/cmd-db.h>
20:
21: #include "adreno.h"
22: #include "adreno_a6xx.h"
23: #include "adreno_trace.h"
24: #include "kgsl_bus.h"
25: #include "kgsl_device.h"
26: #include "kgsl_gmu_core.h"
27: #include "kgsl_trace.h"
28: #include "kgsl_util.h"
29:
30: #define ARC_VOTE_GET_PRI(_v) ((_v) & 0xFF)
31: #define ARC_VOTE_GET_SEC(_v) (((_v) >> 8) & 0xFF)
32: #define ARC_VOTE_GET_VLVL(_v) (((_v) >> 16) & 0xFFFF)
33:
34: #define ARC_VOTE_SET(pri, sec, vlvl) \
35: ((((vlvl) & 0xFFFF) << 16) | (((sec) & 0xFF) << 8) | ((pri) & 0xFF))
36:
37: static struct gmu_vma_entry a6xx_gmu_vma_legacy[] = {
38: [GMU_ITCM] = {
MATCH LINES: 559, 560, 562, 563, 566, 570, 585, 587, 589, 592, 626, 627, 631, 632
547: #define GMU_START_TIMEOUT 100 /* ms */
548: #define GPU_START_TIMEOUT 100 /* ms */
549: #define GPU_RESET_TIMEOUT 1 /* ms */
550: #define GPU_RESET_TIMEOUT_US 10 /* us */
551:
552: /*
553: * The lowest 16 bits of this value are the number of XO clock cycles
554: * for main hysteresis. This is the first hysteresis. Here we set it
555: * to 0x1680 cycles, or 300 us. The highest 16 bits of this value are
556: * the number of XO clock cycles for short hysteresis. This happens
557: * after main hysteresis. Here we set it to 0xA cycles, or 0.5 us.
558: */
559: #define A6X_GMU_LONG_IFPC_HYST FIELD_PREP(GENMASK(15, 0), 0x1680)
560: #define A6X_GMU_SHORT_IFPC_HYST FIELD_PREP(GENMASK(31, 16), 0xA)
561:
562: /* Minimum IFPC timer (200usec) allowed to override default value */
563: #define A6X_GMU_LONG_IFPC_HYST_FLOOR FIELD_PREP(GENMASK(15, 0), 0x0F00)
564:
565: /*
566: * a6xx_gmu_power_config() - Configure and enable GMU's low power mode
567: * setting based on ADRENO feature flags.
568: * @adreno_dev: Pointer to adreno device
569: */
570: static void a6xx_gmu_power_config(struct adreno_device *adreno_dev)
571: {
572: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
573: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
574:
575: /* Configure registers for idle setting. The setting is cumulative */
576:
577: /* Disable GMU WB/RB buffer and caches at boot */
578: gmu_core_regwrite(device, A6XX_GMU_SYS_BUS_CONFIG, 0x1);
579: gmu_core_regwrite(device, A6XX_GMU_ICACHE_CONFIG, 0x1);
580: gmu_core_regwrite(device, A6XX_GMU_DCACHE_CONFIG, 0x1);
581:
582: gmu_core_regwrite(device,
583: A6XX_GMU_PWR_COL_INTER_FRAME_CTRL, 0x9C40400);
584:
585: if (gmu->idle_level == GPU_HW_IFPC) {
586: gmu_core_regwrite(device, A6XX_GMU_PWR_COL_INTER_FRAME_HYST,
587: A6X_GMU_SHORT_IFPC_HYST | adreno_dev->ifpc_hyst);
588: gmu_core_regrmw(device, A6XX_GMU_PWR_COL_INTER_FRAME_CTRL,
589: IFPC_ENABLE_MASK, IFPC_ENABLE_MASK);
590:
591: gmu_core_regwrite(device, A6XX_GMU_PWR_COL_SPTPRAC_HYST,
592: A6X_GMU_SHORT_IFPC_HYST | adreno_dev->ifpc_hyst);
593: gmu_core_regrmw(device, A6XX_GMU_PWR_COL_INTER_FRAME_CTRL,
594: SPTP_ENABLE_MASK, SPTP_ENABLE_MASK);
595: }
596:
597: /* Enable RPMh GPU client */
598: gmu_core_regrmw(device, A6XX_GMU_RPMH_CTRL, RPMH_ENABLE_MASK,
599: RPMH_ENABLE_MASK);
600: }
601:
602: static void gmu_ao_sync_event(struct adreno_device *adreno_dev)
603: {
604: unsigned long flags;
605: u64 ticks;
606:
607: local_irq_save(flags);
608:
609: /* Read GMU always on register */
610: ticks = a6xx_read_alwayson(adreno_dev);
611:
612: /* Trace the GMU time to create a mapping to ftrace time */
613: trace_gmu_ao_sync(ticks);
614:
615: local_irq_restore(flags);
616: }
617:
618: void a6xx_gmu_disable_gdsc(struct adreno_device *adreno_dev)
619: {
620: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
621: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
622:
623: /* ADRENO_QUIRK_CX_GDSC quirk is not supported for genpd */
624: WARN_ON_ONCE(pwr->gmu_cx_pd && ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_CX_GDSC));
625:
626: if (pwr->cx_regulator && ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_CX_GDSC))
627: regulator_set_mode(pwr->cx_regulator, REGULATOR_MODE_IDLE);
628:
629: kgsl_pwrctrl_disable_cx_gdsc(device);
630:
631: if (pwr->cx_regulator && ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_CX_GDSC))
632: regulator_set_mode(pwr->cx_regulator, REGULATOR_MODE_NORMAL);
633: }
634:
635: int a6xx_gmu_device_start(struct adreno_device *adreno_dev)
636: {
637: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
638: u32 val = 0x00000100;
639: u32 mask = 0x000001FF;
640:
641: gmu_core_reset_trace_header(&device->gmu_core.trace);
642: gmu_ao_sync_event(adreno_dev);
643:
644: /* Check for 0xBABEFACE on legacy targets */
645: if (device->gmu_core.ver.core <= 0x20010004) {
646: val = 0xBABEFACE;
647: mask = 0xFFFFFFFF;
648: }
649:
650: /* Bring GMU out of reset */
651: gmu_core_regwrite(device, A6XX_GMU_CM3_SYSRESET, 0);
652:
653: /* Make sure the write is posted before moving ahead */
654: wmb();
655:
656: if (gmu_core_timed_poll_check(device,
MATCH LINES: 1140, 1157, 1173
1128: /*
1129: * a6xx_gmu_sptprac_enable() - Power on SPTPRAC
1130: * @adreno_dev: Pointer to Adreno device
1131: */
1132: int a6xx_gmu_sptprac_enable(struct adreno_device *adreno_dev)
1133: {
1134: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1135:
1136: /* Only certain targets have sptprac */
1137: if (!adreno_is_a630(adreno_dev) && !adreno_is_a615_family(adreno_dev))
1138: return 0;
1139:
1140: if (test_bit(ADRENO_DEVICE_GPU_REGULATOR_ENABLED, &adreno_dev->priv))
1141: return 0;
1142:
1143: /* GMU enabled a630 and a615 targets */
1144: gmu_core_regwrite(device, A6XX_GMU_GX_SPTPRAC_POWER_CONTROL,
1145: SPTPRAC_POWERON_CTRL_MASK);
1146:
1147: if (gmu_core_timed_poll_check(device,
1148: A6XX_GMU_SPTPRAC_PWR_CLK_STATUS,
1149: SPTPRAC_POWERON_STATUS_MASK,
1150: SPTPRAC_CTRL_TIMEOUT,
1151: SPTPRAC_POWERON_STATUS_MASK)) {
1152: dev_err(GMU_PDEV_DEV(device), "power on SPTPRAC fail\n");
1153: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
1154: return -ETIMEDOUT;
1155: }
1156:
1157: set_bit(ADRENO_DEVICE_GPU_REGULATOR_ENABLED, &adreno_dev->priv);
1158: return 0;
1159: }
1160:
1161: /*
1162: * a6xx_gmu_sptprac_disable() - Power of SPTPRAC
1163: * @adreno_dev: Pointer to Adreno device
1164: */
1165: void a6xx_gmu_sptprac_disable(struct adreno_device *adreno_dev)
1166: {
1167: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1168:
1169: /* Only certain targets have sptprac */
1170: if (!adreno_is_a630(adreno_dev) && !adreno_is_a615_family(adreno_dev))
1171: return;
1172:
1173: if (!test_and_clear_bit(ADRENO_DEVICE_GPU_REGULATOR_ENABLED,
1174: &adreno_dev->priv))
1175: return;
1176:
1177: /* GMU enabled a630 and a615 targets */
1178:
1179: /* Ensure that retention is on */
1180: gmu_core_regrmw(device, A6XX_GPU_CC_GX_GDSCR, 0,
1181: A6XX_RETAIN_FF_ENABLE_ENABLE_MASK);
1182:
1183: gmu_core_regwrite(device, A6XX_GMU_GX_SPTPRAC_POWER_CONTROL,
1184: SPTPRAC_POWEROFF_CTRL_MASK);
1185:
1186: if (gmu_core_timed_poll_check(device,
1187: A6XX_GMU_SPTPRAC_PWR_CLK_STATUS,
1188: SPTPRAC_POWEROFF_STATUS_MASK,
1189: SPTPRAC_CTRL_TIMEOUT,
1190: SPTPRAC_POWEROFF_STATUS_MASK))
1191: dev_err(GMU_PDEV_DEV(device), "power off SPTPRAC fail\n");
1192: }
1193:
1194: #define SPTPRAC_POWER_OFF BIT(2)
1195: #define SP_CLK_OFF BIT(4)
1196: #define GX_GDSC_POWER_OFF BIT(6)
1197: #define GX_CLK_OFF BIT(7)
MATCH LINES: 1229
1217:
1218: static bool a6xx_gmu_rpmh_pwr_state_is_active(struct kgsl_device *device)
1219: {
1220: u32 val;
1221:
1222: gmu_core_regread(device, A6XX_GPU_GMU_CX_GMU_RPMH_POWER_STATE, &val);
1223: return (val == GPU_HW_ACTIVE) ? true : false;
1224: }
1225:
1226: /*
1227: * a6xx_gmu_sptprac_is_on() - Check if SPTP is on using pwr status register
1228: * @adreno_dev - Pointer to adreno_device
1229: * This check should only be performed if the keepalive bit is set or it
1230: * can be guaranteed that the power state of the GPU will remain unchanged
1231: */
1232: bool a6xx_gmu_sptprac_is_on(struct adreno_device *adreno_dev)
1233: {
1234: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1235: unsigned int val;
1236:
1237: if (!adreno_is_a630(adreno_dev) && !adreno_is_a615_family(adreno_dev))
1238: return true;
1239:
1240: if (adreno_is_a619_holi(adreno_dev))
1241: kgsl_regread(device,
1242: A6XX_GMU_SPTPRAC_PWR_CLK_STATUS, &val);
1243: else
1244: gmu_core_regread(device, A6XX_GMU_SPTPRAC_PWR_CLK_STATUS,
1245: &val);
1246:
1247: return !(val & (SPTPRAC_POWER_OFF | SP_CLK_OFF));
1248: }
1249:
1250: /*
1251: * a6xx_gmu_gfx_rail_on() - request GMU to power GPU at given OPP.
1252: * @device: Pointer to KGSL device
1253: *
MATCH LINES: 1277, 1280, 1283, 1293, 1294
1265: OOB_BOOT_OPTION);
1266: gmu_core_regwrite(device, A6XX_GMU_GX_VOTE_IDX,
1267: ARC_VOTE_GET_PRI(default_opp));
1268: gmu_core_regwrite(device, A6XX_GMU_MX_VOTE_IDX,
1269: ARC_VOTE_GET_SEC(default_opp));
1270:
1271: gmu_core_rdpm_mx_freq_update(device, gmu->hfi.dcvs_table.gx_votes[perf_idx].freq);
1272:
1273: return a6xx_gmu_oob_set(device, oob_boot_slumber);
1274: }
1275:
1276: static bool idle_trandition_complete(unsigned int idle_level,
1277: unsigned int gmu_power_reg,
1278: unsigned int sptprac_clk_reg)
1279: {
1280: if (idle_level != gmu_power_reg)
1281: return false;
1282:
1283: if (idle_level == GPU_HW_IFPC && is_on(sptprac_clk_reg))
1284: return false;
1285:
1286: return true;
1287: }
1288:
1289: static const char *idle_level_name(int level)
1290: {
1291: if (level == GPU_HW_ACTIVE)
1292: return "GPU_HW_ACTIVE";
1293: else if (level == GPU_HW_IFPC)
1294: return "GPU_HW_IFPC";
1295:
1296: return "";
1297: }
1298:
1299: int a6xx_gmu_wait_for_lowest_idle(struct adreno_device *adreno_dev)
1300: {
1301: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1302: struct device *gmu_pdev_dev = GMU_PDEV_DEV(device);
1303: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
1304: unsigned int reg, reg1, reg2, reg3, reg4, reg5, reg6, reg7, reg8;
1305: unsigned long t;
1306: uint64_t ts1, ts2, ts3;
1307:
1308: ts1 = a6xx_read_alwayson(adreno_dev);
1309:
1310: t = jiffies + msecs_to_jiffies(GMU_IDLE_TIMEOUT);
1311: do {
1312: gmu_core_regread(device,
1313: A6XX_GPU_GMU_CX_GMU_RPMH_POWER_STATE, ®);
1314: gmu_core_regread(device,
1315: A6XX_GMU_SPTPRAC_PWR_CLK_STATUS, ®1);
1316:
1317: if (idle_trandition_complete(gmu->idle_level, reg, reg1))
1318: return 0;
MATCH LINES: 1337, 1357, 1364, 1366
1325:
1326: gmu_core_regread(device, A6XX_GPU_GMU_CX_GMU_RPMH_POWER_STATE, ®);
1327: gmu_core_regread(device, A6XX_GMU_SPTPRAC_PWR_CLK_STATUS, ®1);
1328:
1329: if (idle_trandition_complete(gmu->idle_level, reg, reg1))
1330: return 0;
1331:
1332: ts3 = a6xx_read_alwayson(adreno_dev);
1333:
1334: /* Collect abort data to help with debugging */
1335: gmu_core_regread(device, A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS, ®2);
1336: gmu_core_regread(device, A6XX_GMU_RBBM_INT_UNMASKED_STATUS, ®3);
1337: gmu_core_regread(device, A6XX_GMU_GMU_PWR_COL_KEEPALIVE, ®4);
1338: gmu_core_regread(device, A6XX_GMU_AO_SPARE_CNTL, ®5);
1339:
1340: dev_err(gmu_pdev_dev,
1341: "----------------------[ GMU error ]----------------------\n");
1342: dev_err(gmu_pdev_dev,
1343: "Timeout waiting for lowest idle level %s\n",
1344: idle_level_name(gmu->idle_level));
1345: dev_err(gmu_pdev_dev,
1346: "Start: %llx (absolute ticks)\n", ts1);
1347: dev_err(gmu_pdev_dev,
1348: "Poll: %llx (ticks relative to start)\n",
1349: ts2-ts1);
1350: dev_err(gmu_pdev_dev,
1351: "Retry: %llx (ticks relative to poll)\n",
1352: ts3-ts2);
1353: dev_err(gmu_pdev_dev,
1354: "RPMH_POWER_STATE=%x SPTPRAC_PWR_CLK_STATUS=%x\n", reg, reg1);
1355: dev_err(gmu_pdev_dev, "CX_BUSY_STATUS=%x\n", reg2);
1356: dev_err(gmu_pdev_dev,
1357: "RBBM_INT_UNMASKED_STATUS=%x PWR_COL_KEEPALIVE=%x\n",
1358: reg3, reg4);
1359: dev_err(gmu_pdev_dev, "A6XX_GMU_AO_SPARE_CNTL=%x\n", reg5);
1360:
1361: if (adreno_is_a660(adreno_dev)) {
1362: u32 val;
1363:
1364: gmu_core_regread(device, A6XX_GMU_PWR_COL_PREEMPT_KEEPALIVE, &val);
1365: dev_err(gmu_pdev_dev,
1366: "PWR_COL_PREEMPT_KEEPALIVE=%x\n", val);
1367: }
1368:
1369: /* Access GX registers only when GX is ON */
1370: if (is_on(reg1)) {
1371: kgsl_regread(device, A6XX_CP_STATUS_1, ®6);
1372: kgsl_regread(device, A6XX_CP_CP2GMU_STATUS, ®7);
1373: kgsl_regread(device, A6XX_CP_CONTEXT_SWITCH_CNTL, ®8);
1374:
1375: dev_err(gmu_pdev_dev, "A6XX_CP_STATUS_1=%x\n", reg6);
1376: dev_err(gmu_pdev_dev,
1377: "CP2GMU_STATUS=%x CONTEXT_SWITCH_CNTL=%x\n",
1378: reg7, reg8);
1379: }
1380:
1381: WARN_ON(1);
1382: gmu_core_fault_snapshot(device, GMU_FAULT_WAIT_FOR_LOWEST_IDLE);
1383: return -ETIMEDOUT;
1384: }
1385:
1386: /* Bitmask for GPU idle status check */
1387: #define CXGXCPUBUSYIGNAHB BIT(30)
1388: int a6xx_gmu_wait_for_idle(struct adreno_device *adreno_dev)
1389: {
1390: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
MATCH LINES: 1491
1479: /*
1480: * When LM is not enabled, we can enable BCL throttling -
1481: * XOCLK1: countable: 0x13 (25% throttle)
1482: * XOCLK2: countable: 0x17 (58% throttle)
1483: * XOCLK3: countable: 0x19 (75% throttle)
1484: *
1485: * POWER_CONTROL_SELECT_0 controls counters 0 - 3, each selector
1486: * is 8 bits wide.
1487: */
1488: val = (0x13 << 8) | (0x17 << 16) | (0x19 << 24);
1489: }
1490: /* Make sure not to write over XOCLK0 */
1491: gmu_core_regrmw(device, A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_0,
1492: 0xffffff00, val);
1493:
1494: gmu_core_regwrite(device, A6XX_GMU_AO_SPARE_CNTL, 1);
1495: }
1496:
1497: void a6xx_gmu_register_config(struct adreno_device *adreno_dev)
1498: {
1499: const struct adreno_a6xx_core *a6xx_core = to_a6xx_core(adreno_dev);
1500: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
1501: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1502: u32 gmu_log_info, chipid = 0;
1503:
1504: /* Clear any previously set cm3 fault */
1505: atomic_set(&gmu->cm3_fault, 0);
1506:
1507: /* Vote veto for FAL10 feature if supported*/
1508: if (a6xx_core->veto_fal10) {
1509: gmu_core_regwrite(device,
1510: A6XX_GPU_GMU_CX_GMU_CX_FALNEXT_INTF, 0x1);
1511: gmu_core_regwrite(device, A6XX_GPU_GMU_CX_GMU_CX_FAL_INTF, 0x1);
1512: }
1513:
1514: /* Turn on TCM retention */
1515: gmu_core_regwrite(device, A6XX_GMU_GENERAL_7, 1);
MATCH LINES: 1587
1575: if (adreno_is_a660_shima(adreno_dev))
1576: chipid |= ((ADRENO_CHIPID_PATCH(adreno_dev->chipid) >> 4) << 28);
1577:
1578: gmu_core_regwrite(device, A6XX_GMU_HFI_SFR_ADDR, chipid);
1579:
1580: /* Log size is encoded in (number of 4K units - 1) */
1581: gmu_log_info = (gmu->gmu_log->gmuaddr & 0xFFFFF000) |
1582: ((GMU_LOG_SIZE/SZ_4K - 1) & 0xFF);
1583: gmu_core_regwrite(device, A6XX_GPU_GMU_CX_GMU_PWR_COL_CP_MSG,
1584: gmu_log_info);
1585:
1586: /* Configure power control and bring the GMU out of reset */
1587: a6xx_gmu_power_config(adreno_dev);
1588:
1589: a6xx_gmu_enable_throttle_counters(adreno_dev);
1590: }
1591:
1592: static int reserve_entire_vma(struct a6xx_gmu_device *gmu, u32 vma_id)
1593: {
1594: struct kgsl_memdesc *md;
1595: struct kgsl_device *device = KGSL_DEVICE(a6xx_gmu_to_adreno(gmu));
1596: u32 start = device->gmu_core.vma[vma_id].start, size = device->gmu_core.vma[vma_id].size;
1597:
1598: md = gmu_core_find_memdesc(device, start, size);
1599: if (md)
1600: return 0;
1601:
1602: md = gmu_core_reserve_kernel_block(device, start, size, vma_id, 0);
1603:
1604: return PTR_ERR_OR_ZERO(md);
1605: }
1606:
1607: static int a6xx_gmu_cache_finalize(struct adreno_device *adreno_dev)
1608: {
1609: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
1610: struct kgsl_memdesc *md;
1611: int ret;
MATCH LINES: 1811, 1814
1799: adreno_wait_for_halt_ack(device,
1800: A6XX_RBBM_GBIF_HALT_ACK,
1801: A6XX_GBIF_GX_HALT_MASK);
1802: }
1803: /* Halt CX traffic */
1804: a6xx_halt_gbif(adreno_dev);
1805: /* De-assert the halts */
1806: kgsl_regwrite(device, A6XX_GBIF_HALT, 0x0);
1807: }
1808:
1809: /*
1810: * GX_CXO_CLK is needed to access RBBM_SW_RESET_CMD register. There are
1811: * scenarios where the IFPC exit sequence is still in progress, and the
1812: * above clock may not be enabled. This situation leads to unclocked
1813: * access. Thus, trigger RBBM_SW_RESET_CMD only when GPU is fully active
1814: * i.e., IFPC sequence is completed.
1815: */
1816: if (a6xx_gmu_gx_is_on(adreno_dev) && a6xx_gmu_rpmh_pwr_state_is_active(device))
1817: kgsl_regwrite(device, A6XX_RBBM_SW_RESET_CMD, 0x1);
1818:
1819: /* Make sure above writes are posted before turning off power resources */
1820: wmb();
1821:
1822: /* Allow the software reset to complete */
1823: udelay(100);
1824:
1825: /*
1826: * This is based on the assumption that GMU is the only one controlling
1827: * the GX HS. This code path is the only client voting for GX from linux
1828: * kernel.
1829: */
1830: if (!a6xx_gmu_gx_is_on(adreno_dev))
1831: return;
1832:
1833: /*
1834: * Switch gx gdsc control from GMU to CPU force non-zero reference
1835: * count in clk driver so next disable call will turn off the GDSC
1836: */
1837: kgsl_pwrctrl_enable_gx_gdsc(device);
1838:
MATCH LINES: 1867, 1873
1855: dev_err(GMU_PDEV_DEV(device), "gx is stuck on\n");
1856: }
1857:
1858: /*
1859: * a6xx_gmu_notify_slumber() - initiate request to GMU to prepare to slumber
1860: * @device: Pointer to KGSL device
1861: */
1862: static int a6xx_gmu_notify_slumber(struct adreno_device *adreno_dev)
1863: {
1864: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1865: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1866: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
1867: int bus_level = pwr->pwrlevels[pwr->default_pwrlevel].bus_freq;
1868: int perf_idx = gmu->hfi.dcvs_table.gpu_level_num -
1869: pwr->default_pwrlevel - 1;
1870: int ret, state;
1871:
1872: /* Disable the power counter so that the GMU is not busy */
1873: gmu_core_regwrite(device, A6XX_GMU_CX_GMU_POWER_COUNTER_ENABLE, 0);
1874:
1875: /* Turn off SPTPRAC if we own it */
1876: if (gmu->idle_level == GPU_HW_ACTIVE)
1877: a6xx_gmu_sptprac_disable(adreno_dev);
1878:
1879: if (!ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_HFI_USE_REG)) {
1880: struct hfi_prep_slumber_cmd req = {
1881: .freq = perf_idx,
1882: .bw = bus_level,
1883: };
1884:
1885: ret = CMD_MSG_HDR(req, H2F_MSG_PREPARE_SLUMBER);
1886: if (!ret)
1887: ret = a6xx_hfi_send_generic_req(adreno_dev, &req, sizeof(req));
1888:
1889: goto out;
1890: }
1891:
1892: gmu_core_regwrite(device, A6XX_GMU_BOOT_SLUMBER_OPTION,
1893: OOB_SLUMBER_OPTION);
1894: gmu_core_regwrite(device, A6XX_GMU_GX_VOTE_IDX, perf_idx);
1895: gmu_core_regwrite(device, A6XX_GMU_MX_VOTE_IDX, bus_level);
1896:
1897: ret = a6xx_gmu_oob_set(device, oob_boot_slumber);
MATCH LINES: 2014, 2021, 2025, 2037, 2041
2002:
2003: if (req.freq != INVALID_DCVS_IDX)
2004: gmu_core_rdpm_mx_freq_update(device, table->gx_votes[req.freq].freq);
2005:
2006: return ret;
2007: }
2008:
2009: static int a6xx_gmu_clock_set(struct adreno_device *adreno_dev, u32 pwrlevel)
2010: {
2011: return a6xx_gmu_dcvs_set(adreno_dev, pwrlevel, INVALID_DCVS_IDX);
2012: }
2013:
2014: static int a6xx_gmu_ifpc_store(struct kgsl_device *device,
2015: unsigned int val)
2016: {
2017: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
2018: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
2019: unsigned int requested_idle_level;
2020:
2021: if (!ADRENO_FEATURE(adreno_dev, ADRENO_IFPC))
2022: return -EINVAL;
2023:
2024: if (val)
2025: requested_idle_level = GPU_HW_IFPC;
2026: else
2027: requested_idle_level = GPU_HW_ACTIVE;
2028:
2029: if (gmu->idle_level == requested_idle_level)
2030: return 0;
2031:
2032: /* Power down the GPU before changing the idle level */
2033: return adreno_power_cycle_u32(adreno_dev, &gmu->idle_level,
2034: requested_idle_level);
2035: }
2036:
2037: static unsigned int a6xx_gmu_ifpc_isenabled(struct kgsl_device *device)
2038: {
2039: struct a6xx_gmu_device *gmu = to_a6xx_gmu(ADRENO_DEVICE(device));
2040:
2041: return gmu->idle_level == GPU_HW_IFPC;
2042: }
2043:
2044: /* Send an NMI to the GMU */
2045: void a6xx_gmu_send_nmi(struct kgsl_device *device, bool force,
2046: enum gmu_fault_panic_policy gf_policy)
2047: {
2048: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
2049: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
2050: u64 ticks = gpudev->read_alwayson(adreno_dev);
2051: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
2052: u32 val;
2053:
2054: /*
2055: * Do not send NMI if the SMMU is stalled because GMU will not be able
2056: * to save cm3 state to DDR.
2057: */
2058: if (a6xx_gmu_gx_is_on(adreno_dev) && adreno_smmu_is_stalled(adreno_dev)) {
2059: dev_err(GMU_PDEV_DEV(device),
2060: "Skipping NMI because SMMU is stalled\n");
2061: goto done;
2062: }
2063:
2064: if (force)
2065: goto nmi;
MATCH LINES: 2511, 2512
2499:
2500: /* Don't do any unneeded work if ACD is already in the correct state */
2501: if (adreno_dev->acd_enabled == val)
2502: return 0;
2503:
2504: /* Power cycle the GPU for changes to take effect */
2505: return adreno_power_cycle(adreno_dev, set_acd, &val);
2506: }
2507:
2508: static const struct gmu_dev_ops a6xx_gmudev = {
2509: .oob_set = a6xx_gmu_oob_set,
2510: .oob_clear = a6xx_gmu_oob_clear,
2511: .ifpc_store = a6xx_gmu_ifpc_store,
2512: .ifpc_isenabled = a6xx_gmu_ifpc_isenabled,
2513: .cooperative_reset = a6xx_gmu_cooperative_reset,
2514: .wait_for_active_transition = a6xx_gmu_wait_for_active_transition,
2515: .scales_bandwidth = a6xx_gmu_scales_bandwidth,
2516: .acd_set = a6xx_gmu_acd_set,
2517: .force_first_boot = a6xx_gmu_force_first_boot,
2518: .send_nmi = a6xx_gmu_send_nmi,
2519: };
2520:
2521: static int a6xx_gmu_bus_set(struct adreno_device *adreno_dev, int buslevel,
2522: u32 ab)
2523: {
2524: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2525: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
2526: int ret = 0;
2527:
2528: kgsl_icc_set_tag(pwr, buslevel);
2529:
2530: if (buslevel != pwr->cur_buslevel) {
2531: ret = a6xx_gmu_dcvs_set(adreno_dev, INVALID_DCVS_IDX, buslevel);
2532: if (ret)
2533: return ret;
2534:
2535: pwr->cur_buslevel = buslevel;
2536: }
MATCH LINES: 2760, 2761, 2762, 2763
2748:
2749: /* Map and reserve GMU CSRs registers */
2750: ret = a6xx_gmu_reg_probe(adreno_dev);
2751: if (ret)
2752: goto error;
2753:
2754: /* Populates RPMh configurations */
2755: ret = a6xx_build_rpmh_tables(adreno_dev);
2756: if (ret)
2757: goto error;
2758:
2759: /* Set up GMU idle state */
2760: if (ADRENO_FEATURE(adreno_dev, ADRENO_IFPC)) {
2761: gmu->idle_level = GPU_HW_IFPC;
2762: adreno_dev->ifpc_hyst = A6X_GMU_LONG_IFPC_HYST;
2763: adreno_dev->ifpc_hyst_floor = A6X_GMU_LONG_IFPC_HYST_FLOOR;
2764: } else {
2765: gmu->idle_level = GPU_HW_ACTIVE;
2766: }
2767:
2768: ret = a6xx_gmu_acd_probe(device, gmu, pdev->dev.of_node);
2769: if (ret)
2770: goto error;
2771:
2772: set_bit(GMU_ENABLED, &device->gmu_core.flags);
2773:
2774: /* Initialize to zero to detect trace packet loss */
2775: device->gmu_core.trace.seq_num = 0;
2776:
2777: device->gmu_core.dev_ops = &a6xx_gmudev;
2778:
2779: /* Set default GMU attributes */
2780: gmu->log_stream_enable = false;
2781: gmu->log_group_mask = 0x3;
2782:
2783: /* Disabled by default */
2784: gmu->stats_enable = false;
2785: /* Set default to CM3 busy cycles countable */
2786: gmu->stats_mask = BIT(A6XX_GMU_CM3_BUSY_CYCLES);
2787: /* Interval is in 50 us units. Set default sampling frequency to 4x50 us */
MATCH LINES: 2833
2821: A6XX_GBIF_HALT_ACK, A6XX_GBIF_CLIENT_HALT_MASK);
2822:
2823: /* Halt all AXI requests */
2824: kgsl_regwrite(device, A6XX_GBIF_HALT, A6XX_GBIF_ARB_HALT_MASK);
2825: ret = adreno_wait_for_halt_ack(device,
2826: A6XX_GBIF_HALT_ACK, A6XX_GBIF_ARB_HALT_MASK);
2827:
2828: return ret;
2829: }
2830:
2831: #define RPMH_VOTE_TIMEOUT 2 /* ms */
2832:
2833: static int a6xx_gmu_power_off(struct adreno_device *adreno_dev)
2834: {
2835: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2836: int ret = 0;
2837:
2838: if (device->gmu_fault)
2839: goto error;
2840:
2841: /* Wait for the lowest idle level we requested */
2842: ret = a6xx_gmu_wait_for_lowest_idle(adreno_dev);
2843: if (ret)
2844: goto error;
2845:
2846: ret = a6xx_complete_rpmh_votes(adreno_dev, RPMH_VOTE_TIMEOUT);
2847: if (ret)
2848: goto error;
2849:
2850: ret = a6xx_gmu_notify_slumber(adreno_dev);
2851: if (ret)
2852: goto error;
2853:
2854: ret = a6xx_gmu_wait_for_idle(adreno_dev);
2855: if (ret)
2856: goto error;
2857:
MATCH LINES: 3006
2994: if (ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_HFI_USE_REG))
2995: gmu_core_dev_oob_clear(device, oob_boot_slumber);
2996:
2997: return 0;
2998:
2999: oob_clear:
3000: a6xx_gmu_oob_clear(device, oob_gpu);
3001:
3002: if (ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_HFI_USE_REG))
3003: gmu_core_dev_oob_clear(device, oob_boot_slumber);
3004:
3005: err:
3006: a6xx_gmu_power_off(adreno_dev);
3007:
3008: return ret;
3009: }
3010:
3011: static void gmu_idle_timer(struct timer_list *t)
3012: {
3013: struct kgsl_device *device = container_of(t, struct kgsl_device,
3014: idle_timer);
3015:
3016: kgsl_schedule_work(&device->idle_check_ws);
3017: }
3018:
3019: static int a6xx_boot(struct adreno_device *adreno_dev)
3020: {
3021: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
3022: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
3023: int ret;
3024:
3025: if (WARN_ON(test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)))
3026: return 0;
3027:
3028: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE);
3029:
3030: if (IS_ENABLED(CONFIG_QCOM_KGSL_HIBERNATION) &&
MATCH LINES: 3204
3192: * GX halt is handled by the GMU FW.
3193: */
3194: if (adreno_is_a630(adreno_dev))
3195: a630_vbif_halt(adreno_dev);
3196:
3197: adreno_irqctrl(adreno_dev, 0);
3198:
3199: a6xx_gmu_oob_clear(device, oob_gpu);
3200:
3201: no_gx_power:
3202: kgsl_pwrctrl_irq(device, false);
3203:
3204: a6xx_gmu_power_off(adreno_dev);
3205:
3206: adreno_set_active_ctxs_null(adreno_dev);
3207:
3208: adreno_dispatcher_stop(adreno_dev);
3209:
3210: adreno_ringbuffer_stop(adreno_dev);
3211:
3212: adreno_llcc_slice_deactivate(adreno_dev);
3213:
3214: clear_bit(GMU_PRIV_GPU_STARTED, &gmu->flags);
3215:
3216: kgsl_delete_timer_sync(&device->idle_timer);
3217:
3218: kgsl_pwrscale_sleep(device);
3219:
3220: kgsl_pwrctrl_clear_l3_vote(device);
3221:
3222: kgsl_pwrctrl_set_state(device, KGSL_STATE_SLUMBER);
3223:
3224: return ret;
3225: }
3226:
3227: static void gmu_idle_check(struct work_struct *work)
3228: {
MATCH LINES: 3422, 3433
3410: done:
3411: /*
3412: * When waking up from a touch event we want to stay active long enough
3413: * for the user to send a draw command. The default idle timer timeout
3414: * is shorter than we want so go ahead and push the idle timer out
3415: * further for this special case
3416: */
3417: mod_timer(&device->idle_timer, jiffies +
3418: msecs_to_jiffies(adreno_wake_timeout));
3419:
3420: }
3421:
3422: const struct adreno_power_ops a6xx_gmu_power_ops = {
3423: .first_open = a6xx_gmu_first_open,
3424: .last_close = a6xx_gmu_last_close,
3425: .active_count_get = a6xx_gmu_active_count_get,
3426: .pm_suspend = a6xx_gmu_pm_suspend,
3427: .pm_resume = a6xx_gmu_pm_resume,
3428: .touch_wakeup = a6xx_gmu_touch_wakeup,
3429: .gpu_clock_set = a6xx_gmu_clock_set,
3430: .gpu_bus_set = a6xx_gmu_bus_set,
3431: };
3432:
3433: const struct adreno_power_ops a630_gmu_power_ops = {
3434: .first_open = a6xx_gmu_first_open,
3435: .last_close = a6xx_gmu_last_close,
3436: .active_count_get = a6xx_gmu_active_count_get,
3437: .pm_suspend = a6xx_gmu_pm_suspend,
3438: .pm_resume = a6xx_gmu_pm_resume,
3439: .touch_wakeup = a6xx_gmu_touch_wakeup,
3440: .gpu_clock_set = a6xx_gmu_clock_set,
3441: };
3442:
3443: int a6xx_gmu_device_probe(struct platform_device *pdev,
3444: u32 chipid, const struct adreno_gpu_core *gpucore)
3445: {
3446: struct adreno_device *adreno_dev;
3447: struct kgsl_device *device;
3448: struct a6xx_device *a6xx_dev;
3449: int ret;
3450:
3451: a6xx_dev = devm_kzalloc(&pdev->dev, sizeof(*a6xx_dev),
3452: GFP_KERNEL);
3453: if (!a6xx_dev)
3454: return -ENOMEM;
3455:
3456: adreno_dev = &a6xx_dev->adreno_dev;
3457:
--- FILE: \adreno_a6xx_gmu.h | HITS: 2 ---
MATCH LINES: 285, 288
273:
274: /**
275: * a6xx_gmu_oob_clear - clear an asserted oob request
276: * @device: Pointer to the kgsl device
277: * @req: Type of oob request as defined in enum oob_request
278: *
279: * Clear a previously requested oob so that gmu can power
280: * collapse the gpu
281: */
282: void a6xx_gmu_oob_clear(struct kgsl_device *device, enum oob_request oob);
283:
284: /**
285: * a6xx_gmu_wait_for_lowest_idle - wait for gmu to complete ifpc
286: * @adreno_dev: Pointer to the adreno device
287: *
288: * If ifpc is enabled, wait for gmu to put gpu into ifpc.
289: *
290: * Return: 0 on success or negative error on failure
291: */
292: int a6xx_gmu_wait_for_lowest_idle(struct adreno_device *adreno_dev);
293:
294: /**
295: * a6xx_gmu_wait_for_idle - Wait for gmu to become idle
296: * @adreno_dev: Pointer to the adreno device
297: *
298: * Return: 0 on success or negative error on failure
299: */
300: int a6xx_gmu_wait_for_idle(struct adreno_device *adreno_dev);
301:
302: /**
303: * a6xx_rscc_sleep_sequence - Trigger rscc sleep sequence
304: * @adreno_dev: Pointer to the adreno device
305: *
306: * Return: 0 on success or negative error on failure
307: */
308: int a6xx_rscc_sleep_sequence(struct adreno_device *adreno_dev);
309:
310: /**
311: * a6xx_rscc_wakeup_sequence - Trigger rscc wakeup sequence
312: * @adreno_dev: Pointer to the adreno device
--- FILE: \adreno_a6xx_hwsched.c | HITS: 6 ---
MATCH LINES: 274, 277, 291
262: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
263: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
264: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
265: struct hfi_prep_slumber_cmd req;
266: int ret;
267:
268: ret = CMD_MSG_HDR(req, H2F_MSG_PREPARE_SLUMBER);
269: if (ret)
270: return ret;
271:
272: req.freq = gmu->hfi.dcvs_table.gpu_level_num -
273: pwr->default_pwrlevel - 1;
274: req.bw = pwr->pwrlevels[pwr->default_pwrlevel].bus_freq;
275:
276: /* Disable the power counter so that the GMU is not busy */
277: gmu_core_regwrite(device, A6XX_GMU_CX_GMU_POWER_COUNTER_ENABLE, 0);
278:
279: ret = a6xx_hfi_send_cmd_async(adreno_dev, &req, sizeof(req));
280:
281: /*
282: * GEMNOC can enter power collapse state during GPU power down sequence.
283: * This could abort CX GDSC collapse. Assert Qactive to avoid this.
284: */
285: if ((adreno_is_a662(adreno_dev) || adreno_is_a621(adreno_dev) ||
286: adreno_is_a622(adreno_dev) || adreno_is_a642l(adreno_dev)))
287: gmu_core_regwrite(device, A6XX_GPU_GMU_CX_GMU_CX_FALNEXT_INTF, 0x1);
288:
289: return ret;
290: }
291: static int a6xx_hwsched_gmu_power_off(struct adreno_device *adreno_dev)
292: {
293: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
294: int ret = 0;
295:
296: if (device->gmu_fault)
297: goto error;
298:
299: /* Wait for the lowest idle level we requested */
300: ret = a6xx_gmu_wait_for_lowest_idle(adreno_dev);
301: if (ret)
302: goto error;
303:
304: ret = a6xx_hwsched_notify_slumber(adreno_dev);
305: if (ret)
306: goto error;
307:
308: ret = a6xx_gmu_wait_for_idle(adreno_dev);
309: if (ret)
310: goto error;
311:
312: ret = a6xx_rscc_sleep_sequence(adreno_dev);
313:
314: gmu_core_rdpm_mx_freq_update(device, 0);
315:
MATCH LINES: 396
384: * At this point it is safe to assume that we recovered. Setting
385: * this field allows us to take a new snapshot for the next failure
386: * if we are prioritizing the first unrecoverable snapshot.
387: */
388: if (device->snapshot)
389: device->snapshot->recovered = true;
390:
391: device->reset_counter++;
392: err:
393: a6xx_gmu_oob_clear(device, oob_gpu);
394:
395: if (ret)
396: a6xx_hwsched_gmu_power_off(adreno_dev);
397:
398: return ret;
399: }
400:
401: static void hwsched_idle_timer(struct timer_list *t)
402: {
403: struct kgsl_device *device = container_of(t, struct kgsl_device,
404: idle_timer);
405:
406: kgsl_schedule_work(&device->idle_check_ws);
407: }
408:
409: static int a6xx_hwsched_gmu_init(struct adreno_device *adreno_dev)
410: {
411: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
412: int ret;
413:
414: ret = a6xx_gmu_parse_fw(adreno_dev);
415: if (ret)
416: return ret;
417:
418: ret = a6xx_gmu_memory_init(adreno_dev);
419: if (ret)
420: return ret;
MATCH LINES: 638
626: adreno_coresight_stop(adreno_dev);
627:
628: /* Save physical performance counter values before GPU power down*/
629: adreno_perfcounter_save(adreno_dev);
630:
631: adreno_irqctrl(adreno_dev, 0);
632:
633: a6xx_gmu_oob_clear(device, oob_gpu);
634:
635: no_gx_power:
636: kgsl_pwrctrl_irq(device, false);
637:
638: a6xx_hwsched_gmu_power_off(adreno_dev);
639:
640: adreno_hwsched_unregister_contexts(adreno_dev);
641:
642: adreno_llcc_slice_deactivate(adreno_dev);
643:
644: clear_bit(GMU_PRIV_GPU_STARTED, &gmu->flags);
645:
646: kgsl_delete_timer_sync(&device->idle_timer);
647:
648: kgsl_pwrscale_sleep(device);
649:
650: kgsl_pwrctrl_clear_l3_vote(device);
651:
652: kgsl_pwrctrl_set_state(device, KGSL_STATE_SLUMBER);
653:
654: return ret;
655: }
656:
657: static void hwsched_idle_check(struct work_struct *work)
658: {
659: struct kgsl_device *device = container_of(work,
660: struct kgsl_device, idle_check_ws);
661: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
662: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
MATCH LINES: 969
957: clear_bit(GMU_PRIV_GPU_STARTED, &gmu->flags);
958:
959: ret = a6xx_hwsched_boot(adreno_dev);
960:
961: if (!ret)
962: adreno_hwsched_replay(adreno_dev);
963:
964: BUG_ON(ret);
965:
966: return ret;
967: }
968:
969: const struct adreno_power_ops a6xx_hwsched_power_ops = {
970: .first_open = a6xx_hwsched_first_open,
971: .last_close = a6xx_hwsched_power_off,
972: .active_count_get = a6xx_hwsched_active_count_get,
973: .touch_wakeup = a6xx_hwsched_touch_wakeup,
974: .pm_suspend = a6xx_hwsched_pm_suspend,
975: .pm_resume = a6xx_hwsched_pm_resume,
976: .gpu_clock_set = a6xx_hwsched_clock_set,
977: .gpu_bus_set = a6xx_hwsched_bus_set,
978: };
979:
980: const struct adreno_hwsched_ops a6xx_hwsched_ops = {
981: .submit_drawobj = a6xx_hwsched_submit_drawobj,
982: .preempt_count = a6xx_hwsched_preempt_count_get,
983: };
984:
985: int a6xx_hwsched_probe(struct platform_device *pdev,
986: u32 chipid, const struct adreno_gpu_core *gpucore)
987: {
988: struct adreno_device *adreno_dev;
989: struct kgsl_device *device;
990: struct a6xx_hwsched_device *a6xx_hwsched_dev;
991: int ret;
992:
993: a6xx_hwsched_dev = devm_kzalloc(&pdev->dev, sizeof(*a6xx_hwsched_dev),
--- FILE: \adreno_a6xx_perfcounter.c | HITS: 42 ---
MATCH LINES: 345, 361, 367
333: * Counters [6:9] are in select 3 bit offset 0, 8, 16 and 24
334: */
335:
336: if (counter == 4 || counter == 5)
337: counter -= 4;
338: else if (counter >= 6)
339: counter -= 6;
340:
341: a6xx_write_gmu_counter_enable(device, reg, counter * 8, countable);
342:
343: reg->value = 0;
344:
345: kgsl_regwrite(device, A6XX_GMU_CX_GMU_POWER_COUNTER_ENABLE, 1);
346:
347: return 0;
348: }
349:
350: static int a6xx_counter_gmu_gmuclk_enable(struct adreno_device *adreno_dev,
351: const struct adreno_perfcount_group *group,
352: unsigned int counter, unsigned int countable)
353: {
354: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
355: struct adreno_perfcount_register *reg = &group->regs[counter];
356:
357: if (countable > 0xff)
358: return -EINVAL;
359:
360: /*
361: * The two counters are stuck into GMU_CX_GMU_POWER_COUNTER_SELECT_1
362: * at bit offset 16 and 24
363: */
364: a6xx_write_gmu_counter_enable(device, reg,
365: 16 + (counter * 8), countable);
366:
367: kgsl_regwrite(device, A6XX_GMU_CX_GMU_POWER_COUNTER_ENABLE, 1);
368:
369: reg->value = 0;
370: return 0;
371: }
372:
373: static int a6xx_counter_gmu_perf_enable(struct adreno_device *adreno_dev,
374: const struct adreno_perfcount_group *group,
375: unsigned int counter, unsigned int countable)
376: {
377: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
378: struct adreno_perfcount_register *reg = &group->regs[counter];
379:
380: if (countable > 0xff)
381: return -EINVAL;
382:
383: /*
384: * Counters [0:3] are in select 1 bit offsets 0, 8, 16 and 24
385: * Counters [4:5] are in select 2 bit offset 0, 8
386: */
387:
388: if (counter >= 4)
389: counter -= 4;
390:
391: a6xx_write_gmu_counter_enable(device, reg, counter * 8, countable);
MATCH LINES: 751, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 787, 788, 789, 790, 791, 792, 824, 825
739:
740: #define GMU_COUNTER(lo, hi, sel) \
741: { .countable = KGSL_PERFCOUNTER_NOT_USED, \
742: .offset = lo, .offset_hi = hi, .select = sel }
743:
744: #define GMU_COUNTER_RESERVED(lo, hi, sel) \
745: { .countable = KGSL_PERFCOUNTER_BROKEN, \
746: .offset = lo, .offset_hi = hi, .select = sel }
747:
748: static struct adreno_perfcount_register a6xx_perfcounters_gmu_xoclk[] = {
749: /*
750: * COUNTER_XOCLK_0 and COUNTER_XOCLK_4 are used for the GPU
751: * busy and ifpc count. Mark them as reserved to ensure they
752: * are not re-used.
753: */
754: GMU_COUNTER_RESERVED(A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_L,
755: A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_H,
756: A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_0),
757: GMU_COUNTER(A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_1_L,
758: A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_1_H,
759: A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_0),
760: GMU_COUNTER(A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_2_L,
761: A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_2_H,
762: A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_0),
763: GMU_COUNTER(A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_3_L,
764: A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_3_H,
765: A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_0),
766: GMU_COUNTER_RESERVED(A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_4_L,
767: A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_4_H,
768: A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_1),
769: GMU_COUNTER(A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_5_L,
770: A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_5_H,
771: A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_1),
772: GMU_COUNTER(A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_6_L,
773: A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_6_H,
774: A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_2),
775: GMU_COUNTER(A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_7_L,
776: A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_7_H,
777: A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_2),
778: GMU_COUNTER(A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_8_L,
779: A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_8_H,
780: A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_2),
781: GMU_COUNTER(A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_9_L,
782: A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_9_H,
783: A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_2),
784: };
785:
786: static struct adreno_perfcount_register a6xx_perfcounters_gmu_gmuclk[] = {
787: GMU_COUNTER(A6XX_GMU_CX_GMU_POWER_COUNTER_GMUCLK_0_L,
788: A6XX_GMU_CX_GMU_POWER_COUNTER_GMUCLK_0_H,
789: A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_1),
790: GMU_COUNTER(A6XX_GMU_CX_GMU_POWER_COUNTER_GMUCLK_1_L,
791: A6XX_GMU_CX_GMU_POWER_COUNTER_GMUCLK_1_H,
792: A6XX_GMU_CX_GMU_POWER_COUNTER_SELECT_1),
793: };
794:
795: static struct adreno_perfcount_register a6xx_perfcounters_gmu_perf[] = {
796: GMU_COUNTER(A6XX_GMU_CX_GMU_PERF_COUNTER_0_L,
797: A6XX_GMU_CX_GMU_PERF_COUNTER_0_H,
798: A6XX_GMU_CX_GMU_PERF_COUNTER_SELECT_0),
799: GMU_COUNTER(A6XX_GMU_CX_GMU_PERF_COUNTER_1_L,
800: A6XX_GMU_CX_GMU_PERF_COUNTER_1_H,
801: A6XX_GMU_CX_GMU_PERF_COUNTER_SELECT_0),
802: GMU_COUNTER(A6XX_GMU_CX_GMU_PERF_COUNTER_2_L,
803: A6XX_GMU_CX_GMU_PERF_COUNTER_2_H,
804: A6XX_GMU_CX_GMU_PERF_COUNTER_SELECT_0),
805: GMU_COUNTER(A6XX_GMU_CX_GMU_PERF_COUNTER_3_L,
806: A6XX_GMU_CX_GMU_PERF_COUNTER_3_H,
807: A6XX_GMU_CX_GMU_PERF_COUNTER_SELECT_0),
808: GMU_COUNTER(A6XX_GMU_CX_GMU_PERF_COUNTER_4_L,
809: A6XX_GMU_CX_GMU_PERF_COUNTER_4_H,
810: A6XX_GMU_CX_GMU_PERF_COUNTER_SELECT_1),
811: GMU_COUNTER(A6XX_GMU_CX_GMU_PERF_COUNTER_5_L,
812: A6XX_GMU_CX_GMU_PERF_COUNTER_5_H,
813: A6XX_GMU_CX_GMU_PERF_COUNTER_SELECT_1),
814: };
815:
816: static struct adreno_perfcount_register a6xx_perfcounters_alwayson[] = {
817: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A6XX_CP_ALWAYS_ON_COUNTER_LO,
818: A6XX_CP_ALWAYS_ON_COUNTER_HI, -1 },
819: };
820:
821: /*
822: * ADRENO_PERFCOUNTER_GROUP_RESTORE flag is enabled by default
823: * because most of the perfcounter groups need to be restored
824: * as part of preemption and IFPC. Perfcounter groups that are
825: * not restored as part of preemption and IFPC should be defined
826: * using A6XX_PERFCOUNTER_GROUP_FLAGS macro
827: */
828: #define A6XX_PERFCOUNTER_GROUP(offset, name, enable, read, load) \
829: ADRENO_PERFCOUNTER_GROUP_FLAGS(a6xx, offset, name, \
830: ADRENO_PERFCOUNTER_GROUP_RESTORE, enable, read, load)
831:
832: #define A6XX_PERFCOUNTER_GROUP_FLAGS(offset, name, flags, enable, read, load) \
833: ADRENO_PERFCOUNTER_GROUP_FLAGS(a6xx, offset, name, flags, enable, \
834: read, load)
835:
836: #define A6XX_REGULAR_PERFCOUNTER_GROUP(offset, name) \
837: A6XX_PERFCOUNTER_GROUP(offset, name, \
838: a6xx_counter_enable, a6xx_counter_read, a6xx_counter_load)
839:
840: static const struct adreno_perfcount_group a630_perfcounter_groups
841: [KGSL_PERFCOUNTER_GROUP_MAX] = {
842: A6XX_REGULAR_PERFCOUNTER_GROUP(CP, cp),
843: A6XX_PERFCOUNTER_GROUP_FLAGS(RBBM, rbbm, 0,
844: a6xx_counter_enable, a6xx_counter_read, a6xx_counter_load),
845: A6XX_REGULAR_PERFCOUNTER_GROUP(PC, pc),
846: A6XX_REGULAR_PERFCOUNTER_GROUP(VFD, vfd),
847: A6XX_PERFCOUNTER_GROUP(HLSQ, hlsq, a6xx_counter_inline_enable,
848: a6xx_counter_read, a6xx_counter_load),
849: A6XX_REGULAR_PERFCOUNTER_GROUP(VPC, vpc),
--- FILE: \adreno_a6xx_preempt.c | HITS: 16 ---
MATCH LINES: 69, 80, 88
57: spin_unlock_irqrestore(&rb->preempt_lock, flags);
58:
59: if (!atomic) {
60: /* If WPTR update fails, set the fault and trigger recovery */
61: if (ret) {
62: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
63: adreno_scheduler_fault(adreno_dev,
64: ADRENO_GMU_FAULT_SKIP_SNAPSHOT);
65: }
66: }
67: }
68:
69: static void _power_collapse_set(struct adreno_device *adreno_dev, bool val)
70: {
71: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
72:
73: if (!gmu_core_isenabled(device))
74: return;
75:
76: if (val) {
77: if (adreno_is_a660(adreno_dev) ||
78: adreno_is_a663(adreno_dev))
79: gmu_core_regwrite(device,
80: A6XX_GMU_PWR_COL_PREEMPT_KEEPALIVE, 0x1);
81: else
82: gmu_core_regrmw(device,
83: A6XX_GMU_AO_SPARE_CNTL, 0x0, 0x2);
84: } else {
85: if (adreno_is_a660(adreno_dev) ||
86: adreno_is_a663(adreno_dev))
87: gmu_core_regwrite(device,
88: A6XX_GMU_PWR_COL_PREEMPT_KEEPALIVE, 0x0);
89: else
90: gmu_core_regrmw(device,
91: A6XX_GMU_AO_SPARE_CNTL, 0x2, 0x0);
92: }
93: }
94:
95: static void _a6xx_preemption_done(struct adreno_device *adreno_dev)
96: {
97: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
98: unsigned int status;
99:
100: /*
101: * In the very unlikely case that the power is off, do nothing - the
102: * state will be reset on power up and everybody will be happy
103: */
104:
105: if (!kgsl_state_is_awake(device))
106: return;
107:
108: kgsl_regread(device, A6XX_CP_CONTEXT_SWITCH_CNTL, &status);
109:
110: if (status & 0x1) {
111: dev_err(device->dev,
112: "Preemption not complete: status=%X cur=%d R/W=%X/%X next=%d R/W=%X/%X\n",
MATCH LINES: 134, 137
122:
123: return;
124: }
125:
126: adreno_dev->preempt.count++;
127:
128: /*
129: * In normal scenarios, preemption keep alive bit is cleared during
130: * CP interrupt callback. However, if preemption is successful
131: * immediately after preemption timer expires or there is a preemption
132: * interrupt with non-zero status, the state is transitioned to complete
133: * state. Once dispatcher is scheduled, it calls this function.
134: * We can now safely clear the preemption keepalive bit, allowing
135: * power collapse to resume its regular activity.
136: */
137: _power_collapse_set(adreno_dev, false);
138:
139: kgsl_delete_timer_sync(&adreno_dev->preempt.timer);
140:
141: kgsl_regread(device, A6XX_CP_CONTEXT_SWITCH_LEVEL_STATUS, &status);
142:
143: trace_adreno_preempt_done(adreno_dev->cur_rb->id, adreno_dev->next_rb->id,
144: status, 0);
145:
146: /* Clean up all the bits */
147: adreno_dev->prev_rb = adreno_dev->cur_rb;
148: adreno_dev->cur_rb = adreno_dev->next_rb;
149: adreno_dev->next_rb = NULL;
150:
151: /* Update the wptr for the new command queue */
152: _update_wptr(adreno_dev, true, false);
153:
154: /* Update the dispatcher timer for the new command queue */
155: mod_timer(&adreno_dev->dispatcher.timer,
156: adreno_dev->cur_rb->dispatch_q.expires);
157:
158: /* Clear the preempt state */
159: adreno_set_preempt_state(adreno_dev, ADRENO_PREEMPT_NONE);
160: }
161:
MATCH LINES: 307, 312, 314, 315, 319, 333, 335, 338
295:
296: if (kgsl_mmu_is_perprocess(&device->mmu)) {
297: kgsl_sharedmem_writeq(iommu->smmu_info,
298: PREEMPT_SMMU_RECORD(ttbr0), ttbr0);
299: kgsl_sharedmem_writel(iommu->smmu_info,
300: PREEMPT_SMMU_RECORD(context_idr), contextidr);
301: }
302:
303: kgsl_sharedmem_readq(preempt->scratch, &gpuaddr,
304: next->id * sizeof(u64));
305:
306: /*
307: * Set a keepalive bit before the first preemption register write.
308: * This is required since while each individual write to the context
309: * switch registers will wake the GPU from collapse, it will not in
310: * itself cause GPU activity. Thus, the GPU could technically be
311: * re-collapsed between subsequent register writes leading to a
312: * prolonged preemption sequence. The keepalive bit prevents any
313: * further power collapse while it is set.
314: * It is more efficient to use a keepalive+wake-on-fence approach here
315: * rather than an OOB. Both keepalive and the fence are effectively
316: * free when the GPU is already powered on, whereas an OOB requires an
317: * unconditional handshake with the GMU.
318: */
319: _power_collapse_set(adreno_dev, true);
320:
321: /*
322: * Fenced writes on this path will make sure the GPU is woken up
323: * in case it was power collapsed by the GMU.
324: */
325: if (a6xx_fenced_write(adreno_dev,
326: A6XX_CP_CONTEXT_SWITCH_PRIV_NON_SECURE_RESTORE_ADDR_LO,
327: lower_32_bits(next->preemption_desc->gpuaddr),
328: FENCE_STATUS_WRITEDROPPED1_MASK))
329: goto err;
330:
331: /*
332: * Above fence writes will make sure GMU comes out of
333: * IFPC state if its was in IFPC state but it doesn't
334: * guarantee that GMU FW actually moved to ACTIVE state
335: * i.e. wake-up from IFPC is complete.
336: * Wait for GMU to move to ACTIVE state before triggering
337: * preemption. This is require to make sure CP doesn't
338: * interrupt GMU during wake-up from IFPC.
339: */
340: if (!atomic && gmu_core_dev_wait_for_active_transition(device))
341: goto err;
342:
343: if (a6xx_fenced_write(adreno_dev,
344: A6XX_CP_CONTEXT_SWITCH_PRIV_NON_SECURE_RESTORE_ADDR_HI,
345: upper_32_bits(next->preemption_desc->gpuaddr),
346: FENCE_STATUS_WRITEDROPPED1_MASK))
347: goto err;
348:
349: if (kgsl_mmu_is_secured(&device->mmu)) {
350: if (a6xx_fenced_write(adreno_dev,
351: A6XX_CP_CONTEXT_SWITCH_PRIV_SECURE_RESTORE_ADDR_LO,
352: lower_32_bits(next->secure_preemption_desc->gpuaddr),
353: FENCE_STATUS_WRITEDROPPED1_MASK))
354: goto err;
355:
356: if (a6xx_fenced_write(adreno_dev,
357: A6XX_CP_CONTEXT_SWITCH_PRIV_SECURE_RESTORE_ADDR_HI,
358: upper_32_bits(next->secure_preemption_desc->gpuaddr),
359: FENCE_STATUS_WRITEDROPPED1_MASK))
360: goto err;
361: }
362:
MATCH LINES: 416, 450, 453
404: return;
405: err:
406: /* If fenced write fails, take inline snapshot and trigger recovery */
407: if (!atomic) {
408: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
409: adreno_scheduler_fault(adreno_dev,
410: ADRENO_GMU_FAULT_SKIP_SNAPSHOT);
411: } else {
412: adreno_scheduler_fault(adreno_dev, ADRENO_GMU_FAULT);
413: }
414: adreno_set_preempt_state(adreno_dev, ADRENO_PREEMPT_NONE);
415: /* Clear the keep alive */
416: _power_collapse_set(adreno_dev, false);
417:
418: }
419:
420: void a6xx_preemption_callback(struct adreno_device *adreno_dev, int bit)
421: {
422: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
423: unsigned int status;
424:
425: if (!adreno_move_preempt_state(adreno_dev,
426: ADRENO_PREEMPT_TRIGGERED, ADRENO_PREEMPT_PENDING))
427: return;
428:
429: kgsl_regread(device, A6XX_CP_CONTEXT_SWITCH_CNTL, &status);
430:
431: if (status & 0x1) {
432: dev_err(KGSL_DEVICE(adreno_dev)->dev,
433: "preempt interrupt with non-zero status: %X\n",
434: status);
435:
436: /*
437: * Under the assumption that this is a race between the
438: * interrupt and the register, schedule the worker to clean up.
439: * If the status still hasn't resolved itself by the time we get
440: * there then we have to assume something bad happened
441: */
442: adreno_set_preempt_state(adreno_dev, ADRENO_PREEMPT_COMPLETE);
443: adreno_scheduler_queue(adreno_dev);
444: return;
445: }
446:
447: adreno_dev->preempt.count++;
448:
449: /*
450: * We can now safely clear the preemption keepalive bit, allowing
451: * power collapse to resume its regular activity.
452: */
453: _power_collapse_set(adreno_dev, false);
454:
455: kgsl_delete_timer(&adreno_dev->preempt.timer);
456:
457: kgsl_regread(device, A6XX_CP_CONTEXT_SWITCH_LEVEL_STATUS, &status);
458:
459: trace_adreno_preempt_done(adreno_dev->cur_rb->id, adreno_dev->next_rb->id,
460: status, 0);
461:
462: adreno_dev->prev_rb = adreno_dev->cur_rb;
463: adreno_dev->cur_rb = adreno_dev->next_rb;
464: adreno_dev->next_rb = NULL;
465:
466: /* Update the wptr if it changed while preemption was ongoing */
467: _update_wptr(adreno_dev, true, true);
468:
469: /* Update the dispatcher timer for the new command queue */
470: mod_timer(&adreno_dev->dispatcher.timer,
471: adreno_dev->cur_rb->dispatch_q.expires);
472:
473: adreno_set_preempt_state(adreno_dev, ADRENO_PREEMPT_NONE);
474:
475: a6xx_preemption_trigger(adreno_dev, true);
476: }
477:
--- FILE: \adreno_a6xx_rgmu.c | HITS: 33 ---
MATCH LINES: 236, 243, 247, 259, 263, 291, 326, 342, 360, 361, 363, 364, 393, 394, 396, 415, 452
224: /* Disable all IRQs on host */
225: disable_irq(rgmu->rgmu_interrupt_num);
226: disable_irq(rgmu->oob_interrupt_num);
227:
228: /* Mask all IRQs and clear pending IRQs */
229: gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_MASK, 0xffffffff);
230: gmu_core_regwrite(device, A6XX_GMU_AO_HOST_INTERRUPT_MASK, 0xffffffff);
231:
232: gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_CLR, 0xffffffff);
233: gmu_core_regwrite(device, A6XX_GMU_AO_HOST_INTERRUPT_CLR, 0xffffffff);
234: }
235:
236: static int a6xx_rgmu_ifpc_store(struct kgsl_device *device,
237: unsigned int val)
238: {
239: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
240: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
241: unsigned int requested_idle_level;
242:
243: if (!ADRENO_FEATURE(adreno_dev, ADRENO_IFPC))
244: return -EINVAL;
245:
246: if (val)
247: requested_idle_level = GPU_HW_IFPC;
248: else
249: requested_idle_level = GPU_HW_ACTIVE;
250:
251: if (requested_idle_level == rgmu->idle_level)
252: return 0;
253:
254: /* Power cycle the GPU for changes to take effect */
255: return adreno_power_cycle_u32(adreno_dev, &rgmu->idle_level,
256: requested_idle_level);
257: }
258:
259: static unsigned int a6xx_rgmu_ifpc_isenabled(struct kgsl_device *device)
260: {
261: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(ADRENO_DEVICE(device));
262:
263: return rgmu->idle_level == GPU_HW_IFPC;
264: }
265:
266:
267: static void a6xx_rgmu_prepare_stop(struct kgsl_device *device)
268: {
269: /* Turn off GX_MEM retention */
270: kgsl_regwrite(device, A6XX_RBBM_BLOCK_GX_RETENTION_CNTL, 0);
271: }
272:
273: #define GX_GDSC_POWER_OFF BIT(6)
274: bool a6xx_rgmu_gx_is_on(struct adreno_device *adreno_dev)
275: {
276: unsigned int val;
277:
278: gmu_core_regread(KGSL_DEVICE(adreno_dev),
279: A6XX_GMU_SPTPRAC_PWR_CLK_STATUS, &val);
280: return !(val & GX_GDSC_POWER_OFF);
281: }
282:
283: static int a6xx_rgmu_wait_for_lowest_idle(struct adreno_device *adreno_dev)
284: {
285: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
286: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
287: unsigned int reg[10] = {0};
288: unsigned long t;
289: uint64_t ts1, ts2, ts3;
290:
291: if (rgmu->idle_level != GPU_HW_IFPC)
292: return 0;
293:
294: ts1 = a6xx_read_alwayson(adreno_dev);
295:
296: /* FIXME: readl_poll_timeout? */
297: t = jiffies + msecs_to_jiffies(RGMU_IDLE_TIMEOUT);
298: do {
299: gmu_core_regread(device,
300: A6XX_GMU_SPTPRAC_PWR_CLK_STATUS, ®[0]);
301:
302: if (reg[0] & GX_GDSC_POWER_OFF)
303: return 0;
304:
305: /* Wait 10us to reduce unnecessary AHB bus traffic */
306: usleep_range(10, 100);
307: } while (!time_after(jiffies, t));
308:
309: ts2 = a6xx_read_alwayson(adreno_dev);
310:
311: /* Do one last read incase it succeeds */
312: gmu_core_regread(device,
313: A6XX_GMU_SPTPRAC_PWR_CLK_STATUS, ®[0]);
314:
315: if (reg[0] & GX_GDSC_POWER_OFF)
316: return 0;
317:
318: ts3 = a6xx_read_alwayson(adreno_dev);
319:
320: /* Collect abort data to help with debugging */
321: gmu_core_regread(device, A6XX_RGMU_CX_PCC_DEBUG, ®[1]);
322: gmu_core_regread(device, A6XX_RGMU_CX_PCC_STATUS, ®[2]);
323: gmu_core_regread(device, A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS, ®[3]);
324: kgsl_regread(device, A6XX_CP_STATUS_1, ®[4]);
325: gmu_core_regread(device, A6XX_GMU_RBBM_INT_UNMASKED_STATUS, ®[5]);
326: gmu_core_regread(device, A6XX_GMU_GMU_PWR_COL_KEEPALIVE, ®[6]);
327: kgsl_regread(device, A6XX_CP_CP2GMU_STATUS, ®[7]);
328: kgsl_regread(device, A6XX_CP_CONTEXT_SWITCH_CNTL, ®[8]);
329: gmu_core_regread(device, A6XX_GMU_AO_SPARE_CNTL, ®[9]);
330:
331: dev_err(&rgmu->pdev->dev,
332: "----------------------[ RGMU error ]----------------------\n");
333: dev_err(&rgmu->pdev->dev, "Timeout waiting for lowest idle level\n");
334: dev_err(&rgmu->pdev->dev,
335: "Timestamps: %llx %llx %llx\n", ts1, ts2, ts3);
336: dev_err(&rgmu->pdev->dev,
337: "SPTPRAC_PWR_CLK_STATUS=%x PCC_DEBUG=%x PCC_STATUS=%x\n",
338: reg[0], reg[1], reg[2]);
339: dev_err(&rgmu->pdev->dev,
340: "CX_BUSY_STATUS=%x CP_STATUS_1=%x\n", reg[3], reg[4]);
341: dev_err(&rgmu->pdev->dev,
342: "RBBM_INT_UNMASKED_STATUS=%x PWR_COL_KEEPALIVE=%x\n",
343: reg[5], reg[6]);
344: dev_err(&rgmu->pdev->dev,
345: "CP2GMU_STATUS=%x CONTEXT_SWITCH_CNTL=%x AO_SPARE_CNTL=%x\n",
346: reg[7], reg[8], reg[9]);
347:
348: WARN_ON(1);
349: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
350: return -ETIMEDOUT;
351: }
352:
353: /*
354: * The lowest 16 bits of this value are the number of XO clock cycles
355: * for main hysteresis. This is the first hysteresis. Here we set it
356: * to 0x1680 cycles, or 300 us. The highest 16 bits of this value are
357: * the number of XO clock cycles for short hysteresis. This happens
358: * after main hysteresis. Here we set it to 0xA cycles, or 0.5 us.
359: */
360: #define A6X_RGMU_LONG_IFPC_HYST FIELD_PREP(GENMASK(15, 0), 0x1680)
361: #define A6X_RGMU_SHORT_IFPC_HYST FIELD_PREP(GENMASK(31, 16), 0xA)
362:
363: /* Minimum IFPC timer (200usec) allowed to override default value */
364: #define A6X_RGMU_LONG_IFPC_HYST_FLOOR FIELD_PREP(GENMASK(15, 0), 0x0F00)
365:
366: /* HOSTTOGMU and TIMER0/1 interrupt mask: 0x20060 */
367: #define RGMU_INTR_EN_MASK (BIT(5) | BIT(6) | BIT(17))
368:
369: /* RGMU FENCE RANGE MASK */
370: #define RGMU_FENCE_RANGE_MASK ((0x1 << 31) | ((0xA << 2) << 18) | (0x8A0))
371:
372: static int a6xx_rgmu_fw_start(struct adreno_device *adreno_dev,
373: unsigned int boot_state)
374: {
375: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
376: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
377: unsigned int status;
378: int i;
379:
380: switch (boot_state) {
381: case GMU_COLD_BOOT:
382: case GMU_WARM_BOOT:
383: /* Turn on TCM retention */
384: gmu_core_regwrite(device, A6XX_GMU_GENERAL_7, 1);
385:
386: /* Load RGMU FW image via AHB bus */
387: for (i = 0; i < rgmu->fw_size; i++)
388: gmu_core_regwrite(device, A6XX_GMU_CM3_ITCM_START + i,
389: rgmu->fw_hostptr[i]);
390: break;
391: }
392:
393: /* IFPC Feature Enable */
394: if (rgmu->idle_level == GPU_HW_IFPC) {
395: gmu_core_regwrite(device, A6XX_GMU_PWR_COL_INTER_FRAME_HYST,
396: A6X_RGMU_SHORT_IFPC_HYST | adreno_dev->ifpc_hyst);
397: gmu_core_regwrite(device, A6XX_GMU_PWR_COL_INTER_FRAME_CTRL,
398: BIT(0));
399: }
400:
401: /* For RGMU CX interrupt */
402: gmu_core_regwrite(device, A6XX_RGMU_CX_INTR_GEN_EN, RGMU_INTR_EN_MASK);
403:
404: /* Enable GMU AO to host interrupt */
405: gmu_core_regwrite(device, A6XX_GMU_AO_INTERRUPT_EN, RGMU_AO_IRQ_MASK);
406:
407: /* For OOB */
408: gmu_core_regwrite(device, A6XX_GMU_HOST2GMU_INTR_EN_2, 0x00FF0000);
409: gmu_core_regwrite(device, A6XX_GMU_HOST2GMU_INTR_EN_3, 0xFF000000);
410:
411: /* Fence Address range configuration */
412: gmu_core_regwrite(device, A6XX_GMU_AHB_FENCE_RANGE_0,
413: RGMU_FENCE_RANGE_MASK);
414:
415: /* During IFPC RGMU will put fence in drop mode so we would
416: * need to put fence allow mode during slumber out sequence.
417: */
418: gmu_core_regwrite(device, A6XX_GMU_AO_AHB_FENCE_CTRL, 0);
419:
420: /* BCL ON Sequence */
421: a6xx_rgmu_bcl_config(device, true);
422:
423: /* Write 0 first to make sure that rgmu is reset */
424: gmu_core_regwrite(device, A6XX_RGMU_CX_PCC_CTRL, 0);
425:
426: /* Make sure putting in reset doesn't happen after writing 1 */
427: wmb();
428:
429: /* Bring rgmu out of reset */
430: gmu_core_regwrite(device, A6XX_RGMU_CX_PCC_CTRL, 1);
431:
432: if (gmu_core_timed_poll_check(device, A6XX_RGMU_CX_PCC_INIT_RESULT,
433: BIT(0), RGMU_START_TIMEOUT, BIT(0))) {
434: gmu_core_regread(device, A6XX_RGMU_CX_PCC_DEBUG, &status);
435: dev_err(&rgmu->pdev->dev,
436: "rgmu boot Failed. status:%08x\n", status);
437: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
438: return -ETIMEDOUT;
439: }
440:
441: /* Read the RGMU firmware version from registers */
442: gmu_core_regread(device, A6XX_GMU_GENERAL_0, &rgmu->ver);
443:
444: return 0;
445: }
446:
447: static void a6xx_rgmu_notify_slumber(struct adreno_device *adreno_dev)
448: {
449: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
450:
451: /* Disable the power counter so that the RGMU is not busy */
452: gmu_core_regwrite(device, A6XX_GMU_CX_GMU_POWER_COUNTER_ENABLE, 0);
453:
454: /* BCL OFF Sequence */
455: a6xx_rgmu_bcl_config(device, false);
456: }
457:
458: static void a6xx_rgmu_disable_clks(struct adreno_device *adreno_dev)
459: {
460: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
461: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
462:
463: /*
464: * This is based on the assumption that GMU is the only one controlling
465: * the GX HS. This code path is the only client voting for GX from linux
466: * kernel.
467: */
468: if (!a6xx_rgmu_gx_is_on(adreno_dev))
469: goto done;
470:
471: /*
472: * Switch gx gdsc control from GMU to CPU force non-zero reference
473: * count in clk driver so next disable call will turn off the GDSC
474: */
475: kgsl_pwrctrl_enable_gx_gdsc(device);
476: kgsl_pwrctrl_disable_gx_gdsc(device);
MATCH LINES: 526, 532
514: kgsl_pwrctrl_disable_cx_gdsc(device);
515:
516: kgsl_pwrctrl_set_state(KGSL_DEVICE(adreno_dev), KGSL_STATE_NONE);
517: }
518:
519: static int a6xx_rgmu_enable_clks(struct adreno_device *adreno_dev)
520: {
521: int ret;
522: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
523: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
524: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
525:
526: ret = clk_set_rate(rgmu->rgmu_clk, RGMU_CLK_FREQ);
527: if (ret) {
528: dev_err(&rgmu->pdev->dev, "Couldn't set the RGMU clock\n");
529: return ret;
530: }
531:
532: ret = clk_set_rate(rgmu->gpu_clk,
533: pwr->pwrlevels[pwr->default_pwrlevel].gpu_freq);
534: if (ret) {
535: dev_err(&rgmu->pdev->dev, "Couldn't set the GPU clock\n");
536: return ret;
537: }
538:
539: ret = clk_bulk_prepare_enable(rgmu->num_clks, rgmu->clks);
540: if (ret) {
541: dev_err(&rgmu->pdev->dev, "Failed to enable RGMU clocks\n");
542: return ret;
543: }
544:
545: /* If gpu_clk is NOT in the bulk list, enable it explicitly */
546: if (!kgsl_of_clk_by_name(rgmu->clks, rgmu->num_clks, "core")) {
547: ret = clk_prepare_enable(rgmu->gpu_clk);
548: if (ret) {
549: dev_err(&rgmu->pdev->dev, "Failed to enable core clock\n");
550: goto err_bulk_disable;
551: }
552: }
553:
554: device->state = KGSL_STATE_AWARE;
555:
556: return 0;
MATCH LINES: 650
638:
639: /* Halt all AXI requests */
640: kgsl_regwrite(device, A6XX_GBIF_HALT, A6XX_GBIF_ARB_HALT_MASK);
641: adreno_wait_for_halt_ack(device, A6XX_GBIF_HALT_ACK,
642: A6XX_GBIF_ARB_HALT_MASK);
643:
644: /* De-assert the halts */
645: kgsl_regwrite(device, A6XX_GBIF_HALT, 0x0);
646: }
647:
648:
649: /* Caller shall ensure GPU is ready for SLUMBER */
650: static void a6xx_rgmu_power_off(struct adreno_device *adreno_dev)
651: {
652: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
653: int ret;
654:
655: kgsl_pwrctrl_axi(device, false);
656:
657: if (device->gmu_fault)
658: return a6xx_rgmu_suspend(adreno_dev);
659:
660: /* Wait for the lowest idle level we requested */
661: ret = a6xx_rgmu_wait_for_lowest_idle(adreno_dev);
662: if (ret)
663: return a6xx_rgmu_suspend(adreno_dev);
664:
665: a6xx_rgmu_notify_slumber(adreno_dev);
666:
667: /* Halt CX traffic and de-assert halt */
668: halt_gbif_arb(adreno_dev);
669:
670: a6xx_rgmu_irq_disable(adreno_dev);
671: a6xx_rgmu_disable_clks(adreno_dev);
672: kgsl_pwrctrl_disable_cx_gdsc(device);
673:
674: kgsl_pwrctrl_clear_l3_vote(device);
MATCH LINES: 698, 699, 708
686:
687: static int a6xx_rgmu_set_opp(struct kgsl_device *device, struct kgsl_pwrlevel *level)
688: {
689: struct device *dev = &device->pdev->dev;
690: int ret;
691:
692: /*
693: * level->opp is initialized with a valid OPP pointer only when the driver
694: * is probed with standard DT bindings. Use this to distinguish standard
695: * vs non‑standard kernels here.
696: *
697: * On non‑standard kernels (level->opp == NULL), vote the core clock using
698: * clk_set_rate API. The downstream clock driver internally handles the
699: * required regulator voting.
700: *
701: * On standard kernels (level->opp != NULL), use dev_pm_opp_set_opp() API
702: * and OPP framework will take care of all required votes.
703: */
704: if (!level->opp) {
705: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
706: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
707:
708: ret = clk_set_rate(rgmu->gpu_clk, level->gpu_freq);
709: if (ret)
710: dev_err(device->dev, "GPU clk freq set failure: %d\n", ret);
711:
712: return ret;
713: }
714:
715: ret = dev_pm_opp_set_opp(dev, level->opp);
716: if (ret)
717: dev_err(device->dev, "GPU OPP configure failure: %d\n", ret);
718:
719: return ret;
720: }
721:
722: static int a6xx_rgmu_clock_set(struct adreno_device *adreno_dev,
723: u32 pwrlevel)
724: {
725: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
726: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
727: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
728: struct kgsl_pwrlevel *level = &pwr->pwrlevels[pwrlevel];
729: int ret;
730:
731: if (pwrlevel == INVALID_DCVS_IDX)
732: return -EINVAL;
MATCH LINES: 798
786: adreno_dispatcher_start(device);
787:
788: device->reset_counter++;
789:
790: a6xx_rgmu_oob_clear(device, oob_gpu);
791:
792: return 0;
793:
794: err_oob_clear:
795: a6xx_rgmu_oob_clear(device, oob_gpu);
796:
797: err:
798: a6xx_rgmu_power_off(adreno_dev);
799:
800: return ret;
801: }
802:
803: static int a6xx_rgmu_boot(struct adreno_device *adreno_dev)
804: {
805: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
806: int ret;
807:
808: kgsl_pwrctrl_request_state(device, KGSL_STATE_AWARE);
809:
810: ret = kgsl_pwrctrl_enable_cx_gdsc(device);
811: if (ret)
812: return ret;
813:
814: ret = a6xx_rgmu_enable_clks(adreno_dev);
815: if (ret) {
816: kgsl_pwrctrl_disable_cx_gdsc(device);
817: return ret;
818: }
819:
820: a6xx_rgmu_irq_enable(adreno_dev);
821:
822: /* Clear any GPU faults that might have been left over */
MATCH LINES: 840
828:
829: ret = kgsl_pwrctrl_setup_default_votes(device);
830: if (ret)
831: goto err;
832:
833: device->gmu_fault = false;
834:
835: kgsl_pwrctrl_set_state(device, KGSL_STATE_AWARE);
836:
837: return 0;
838:
839: err:
840: a6xx_rgmu_power_off(adreno_dev);
841:
842: return ret;
843: }
844:
845: static int a6xx_power_off(struct adreno_device *adreno_dev);
846:
847: static void rgmu_idle_check(struct work_struct *work)
848: {
849: struct kgsl_device *device = container_of(work,
850: struct kgsl_device, idle_check_ws);
851: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
852: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
853: int ret;
854:
855: kgsl_mutex_lock(&device->mutex);
856:
857: if (test_bit(GMU_DISABLE_SLUMBER, &device->gmu_core.flags))
858: goto done;
859:
860: if (atomic_read(&device->active_cnt) || time_is_after_jiffies(device->idle_jiffies)) {
861: kgsl_pwrscale_update(device);
862: goto done;
863: }
864:
MATCH LINES: 1112
1100:
1101: a6xx_rgmu_oob_clear(device, oob_gpu);
1102:
1103: no_gx_power:
1104: /* Halt all gx traffic */
1105: kgsl_regwrite(device, A6XX_GBIF_HALT, A6XX_GBIF_CLIENT_HALT_MASK);
1106:
1107: adreno_wait_for_halt_ack(device, A6XX_GBIF_HALT_ACK,
1108: A6XX_GBIF_CLIENT_HALT_MASK);
1109:
1110: kgsl_pwrctrl_irq(device, false);
1111:
1112: a6xx_rgmu_power_off(adreno_dev);
1113:
1114: adreno_set_active_ctxs_null(adreno_dev);
1115:
1116: adreno_dispatcher_stop(adreno_dev);
1117:
1118: adreno_ringbuffer_stop(adreno_dev);
1119:
1120: adreno_llcc_slice_deactivate(adreno_dev);
1121:
1122: clear_bit(RGMU_PRIV_GPU_STARTED, &rgmu->flags);
1123:
1124: kgsl_delete_timer_sync(&device->idle_timer);
1125:
1126: kgsl_pwrscale_sleep(device);
1127:
1128: kgsl_pwrctrl_set_state(device, KGSL_STATE_SLUMBER);
1129:
1130: return ret;
1131: }
1132:
1133: static int a6xx_rgmu_last_close(struct adreno_device *adreno_dev)
1134: {
1135: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
1136:
MATCH LINES: 1236, 1237
1224: return;
1225:
1226: adreno_put_gpu_halt(adreno_dev);
1227:
1228: clear_bit(RGMU_PRIV_PM_SUSPEND, &rgmu->flags);
1229:
1230: adreno_dispatcher_start(device);
1231: }
1232:
1233: static const struct gmu_dev_ops a6xx_rgmudev = {
1234: .oob_set = a6xx_rgmu_oob_set,
1235: .oob_clear = a6xx_rgmu_oob_clear,
1236: .ifpc_store = a6xx_rgmu_ifpc_store,
1237: .ifpc_isenabled = a6xx_rgmu_ifpc_isenabled,
1238: .send_nmi = a6xx_rgmu_halt_execution,
1239: };
1240:
1241: static int a6xx_rgmu_irq_probe(struct kgsl_device *device)
1242: {
1243: struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(ADRENO_DEVICE(device));
1244: int ret;
1245:
1246: /* Try with "oob" irq first. Use Fallback legacy name "kgsl_oob" if not found. */
1247: ret = kgsl_request_irq(rgmu->pdev, "oob", "kgsl_oob", -EINVAL,
1248: a6xx_oob_irq_handler, device);
1249:
1250: if (ret < 0)
1251: return ret;
1252:
1253: rgmu->oob_interrupt_num = ret;
1254:
1255: /* Try with "gmu" irq first. Use Fallback legacy name "kgsl_rgmu" if not found. */
1256: ret = kgsl_request_irq(rgmu->pdev, "gmu", "kgsl_rgmu", -EINVAL,
1257: a6xx_rgmu_irq_handler, device);
1258:
1259: if (ret < 0)
1260: return ret;
1261:
MATCH LINES: 1312
1300: return -ENODEV;
1301: }
1302:
1303: rgmu->rgmu_clk = kgsl_of_clk_by_name(rgmu->clks, ret, "gmu");
1304: if (!rgmu->rgmu_clk) {
1305: dev_err(&rgmu->pdev->dev, "The RGMU clock isn't defined\n");
1306: return -ENODEV;
1307: }
1308:
1309: return 0;
1310: }
1311:
1312: const struct adreno_power_ops a6xx_rgmu_power_ops = {
1313: .first_open = a6xx_rgmu_first_open,
1314: .last_close = a6xx_rgmu_last_close,
1315: .active_count_get = a6xx_rgmu_active_count_get,
1316: .pm_suspend = a6xx_rgmu_pm_suspend,
1317: .pm_resume = a6xx_rgmu_pm_resume,
1318: .touch_wakeup = a6xx_rgmu_touch_wakeup,
1319: .gpu_clock_set = a6xx_rgmu_clock_set,
1320: };
1321:
1322: int a6xx_rgmu_device_probe(struct platform_device *pdev,
1323: u32 chipid, const struct adreno_gpu_core *gpucore)
1324: {
1325: struct adreno_device *adreno_dev;
1326: struct kgsl_device *device;
1327: struct a6xx_device *a6xx_dev;
1328: int ret;
1329:
1330: a6xx_dev = devm_kzalloc(&pdev->dev, sizeof(*a6xx_dev),
1331: GFP_KERNEL);
1332: if (!a6xx_dev)
1333: return -ENOMEM;
1334:
1335: adreno_dev = &a6xx_dev->adreno_dev;
1336:
MATCH LINES: 1400, 1401, 1402, 1403
1388:
1389: if (ret) {
1390: dev_err(&pdev->dev, "Unable to map the RGMU registers\n");
1391: return ret;
1392: }
1393:
1394: /* Initialize OOB and RGMU interrupts */
1395: ret = a6xx_rgmu_irq_probe(device);
1396: if (ret)
1397: return ret;
1398:
1399: /* Set up RGMU idle states */
1400: if (ADRENO_FEATURE(ADRENO_DEVICE(device), ADRENO_IFPC)) {
1401: rgmu->idle_level = GPU_HW_IFPC;
1402: adreno_dev->ifpc_hyst = A6X_RGMU_LONG_IFPC_HYST;
1403: adreno_dev->ifpc_hyst_floor = A6X_RGMU_LONG_IFPC_HYST_FLOOR;
1404: } else {
1405: rgmu->idle_level = GPU_HW_ACTIVE;
1406: }
1407:
1408: set_bit(GMU_ENABLED, &device->gmu_core.flags);
1409: device->gmu_core.dev_ops = &a6xx_rgmudev;
1410: device->gmu_core.pdev = rgmu->pdev;
1411:
1412: return 0;
1413: }
1414:
1415: static void a6xx_rgmu_remove(struct kgsl_device *device)
1416: {
1417:
1418: memset(&device->gmu_core, 0, sizeof(device->gmu_core));
1419: }
1420:
1421: static int a6xx_rgmu_bind(struct device *dev, struct device *master, void *data)
1422: {
1423: struct kgsl_device *device = dev_get_drvdata(master);
1424:
1425: return a6xx_rgmu_probe(device, to_platform_device(dev));
1426: }
1427:
--- FILE: \adreno_a6xx_rgmu.h | HITS: 1 ---
MATCH LINES: 102
90: struct kgsl_snapshot *snapshot);
91:
92: /**
93: * a6xx_rgmu_add_to_minidump - Register a6xx_device with va minidump
94: * @adreno_dev: Pointer to the adreno device
95: */
96: int a6xx_rgmu_add_to_minidump(struct adreno_device *adreno_dev);
97:
98: /**
99: * a6xx_rgmu_gx_is_on() - Check if GX is on using pwr status register
100: * @adreno_dev: Pointer to the adreno device
101: *
102: * This check should only be performed if the keepalive bit is set or it
103: * can be guaranteed that the power state of the GPU will remain unchanged
104: */
105: bool a6xx_rgmu_gx_is_on(struct adreno_device *adreno_dev);
106: #endif
--- FILE: \adreno_a6xx_ringbuffer.c | HITS: 2 ---
MATCH LINES: 256
244: if (IS_ERR(cmds))
245: return PTR_ERR(cmds);
246:
247: /* Identify the start of a command */
248: cmds[index++] = cp_type7_packet(CP_NOP, 1);
249: cmds[index++] = drawctxt ? CMD_IDENTIFIER : CMD_INTERNAL_IDENTIFIER;
250:
251: /* This is 25 dwords when drawctxt is not NULL and perfcounter needs to be zapped */
252: index += a6xx_preemption_pre_ibsubmit(adreno_dev, rb, drawctxt,
253: &cmds[index]);
254:
255: cmds[index++] = cp_type7_packet(CP_SET_MARKER, 1);
256: cmds[index++] = 0x101; /* IFPC disable */
257:
258: profile_gpuaddr = adreno_profile_preib_processing(adreno_dev,
259: drawctxt, &profile_dwords);
260:
261: if (profile_gpuaddr) {
262: cmds[index++] = cp_type7_packet(CP_INDIRECT_BUFFER_PFE, 3);
263: cmds[index++] = lower_32_bits(profile_gpuaddr);
264: cmds[index++] = upper_32_bits(profile_gpuaddr);
265: cmds[index++] = profile_dwords;
266: }
267:
268: if (drawctxt) {
269: cmds[index++] = cp_type7_packet(CP_MEM_WRITE, 3);
270: cmds[index++] = lower_32_bits(CTXT_SOPTIMESTAMP(device,
271: drawctxt));
272: cmds[index++] = upper_32_bits(CTXT_SOPTIMESTAMP(device,
273: drawctxt));
274: cmds[index++] = timestamp;
275: }
276:
277: cmds[index++] = cp_type7_packet(CP_MEM_WRITE, 3);
278: cmds[index++] = lower_32_bits(RB_SOPTIMESTAMP(device, rb));
279: cmds[index++] = upper_32_bits(RB_SOPTIMESTAMP(device, rb));
280: cmds[index++] = rb->timestamp;
MATCH LINES: 340
328: cmds[index++] = upper_32_bits(CTXT_EOPTIMESTAMP(device,
329: drawctxt));
330: cmds[index++] = timestamp;
331:
332: cmds[index++] = cp_type7_packet(CP_EVENT_WRITE, 4);
333: cmds[index++] = CACHE_FLUSH_TS;
334: cmds[index++] = lower_32_bits(RB_EOPTIMESTAMP(device, rb));
335: cmds[index++] = upper_32_bits(RB_EOPTIMESTAMP(device, rb));
336: cmds[index++] = rb->timestamp;
337: }
338:
339: cmds[index++] = cp_type7_packet(CP_SET_MARKER, 1);
340: cmds[index++] = 0x100; /* IFPC enable */
341:
342: if (IS_WFI(flags))
343: cmds[index++] = cp_type7_packet(CP_WAIT_FOR_IDLE, 0);
344:
345: if (IS_SECURE(flags)) {
346: cmds[index++] = cp_type7_packet(CP_SET_SECURE_MODE, 1);
347: cmds[index++] = 0;
348: }
349:
350: /* 10 dwords */
351: index += a6xx_preemption_post_ibsubmit(adreno_dev, &cmds[index]);
352:
353: /* Adjust the thing for the number of dwords we actually wrote */
354: rb->_wptr -= (size - index);
355:
356: return a6xx_ringbuffer_submit(rb, time,
357: !adreno_is_preemption_enabled(adreno_dev));
358: }
359:
360: static u32 a6xx_get_alwayson_counter(u32 *cmds, u64 gpuaddr)
361: {
362: cmds[0] = cp_type7_packet(CP_REG_TO_MEM, 3);
363: cmds[1] = A6XX_CP_ALWAYS_ON_COUNTER_LO | (1 << 30) | (2 << 18);
364: cmds[2] = lower_32_bits(gpuaddr);
--- FILE: \adreno_coresight.h | HITS: 1 ---
MATCH LINES: 158
146: * adreno_coresight_remove - Destroy active coresight devices
147: * @adreno_dev: An Adreno GPU device handle
148: *
149: * Destroy any active coresight devices.
150: */
151: void adreno_coresight_remove(struct adreno_device *adreno_dev);
152:
153: /**
154: * adreno_coresight_patch_pwrup_reglist - Patch power up register list with coresight registers
155: * @adreno_dev: An Adreno GPU device handle
156: * @dest: Pointer to power up register list buffer
157: *
158: * Patch IFPC power up register list with GX coresight registers.
159: * Return: Number of GX coresight registers added to power up list
160: */
161: u32 adreno_coresight_patch_pwrup_reglist(struct adreno_device *adreno_dev, u32 *dest);
162: #else
163: static inline void adreno_coresight_add_device(struct kgsl_device *device,
164: const char *name,
165: const struct adreno_coresight *coresight,
166: struct adreno_coresight_device *adreno_csdev)
167: {
168: }
169:
170: static inline void adreno_coresight_start(struct adreno_device *adreno_dev) { }
171: static inline void adreno_coresight_stop(struct adreno_device *adreno_dev) { }
172: static inline void adreno_coresight_remove(struct adreno_device *adreno_dev) { }
173: static inline u32 adreno_coresight_patch_pwrup_reglist(struct adreno_device *adreno_dev, u32 *dest)
174: {
175: return 0;
176: }
177: #endif
178: #endif
--- FILE: \adreno_debugfs.c | HITS: 13 ---
MATCH LINES: 653, 658, 661, 663, 665, 669, 672, 676, 680, 700, 701
641: struct adreno_device *adreno_dev = data;
642: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
643: struct gmu_core_device *gmu_core = &device->gmu_core;
644:
645: if (gmu_core->warmboot_enabled == val)
646: return 0;
647:
648: return adreno_power_cycle_bool(adreno_dev, &gmu_core->warmboot_enabled, val);
649: }
650:
651: DEFINE_DEBUGFS_ATTRIBUTE(warmboot_fops, _warmboot_show, _warmboot_store, "%llu\n");
652:
653: static int _ifpc_hyst_store(void *data, u64 val)
654: {
655: struct adreno_device *adreno_dev = data;
656: u32 hyst;
657:
658: if (!gmu_core_dev_ifpc_isenabled(KGSL_DEVICE(adreno_dev)))
659: return -EINVAL;
660:
661: /* IFPC hysteresis timer is 16 bits */
662: hyst = max_t(u32, (u32) (FIELD_GET(GENMASK(15, 0), val)),
663: adreno_dev->ifpc_hyst_floor);
664:
665: if (hyst == adreno_dev->ifpc_hyst)
666: return 0;
667:
668: return adreno_power_cycle_u32(adreno_dev,
669: &adreno_dev->ifpc_hyst, hyst);
670: }
671:
672: static int _ifpc_hyst_show(void *data, u64 *val)
673: {
674: struct adreno_device *adreno_dev = data;
675:
676: *val = (u64) adreno_dev->ifpc_hyst;
677: return 0;
678: }
679:
680: DEFINE_DEBUGFS_ATTRIBUTE(ifpc_hyst_fops, _ifpc_hyst_show, _ifpc_hyst_store, "%llu\n");
681:
682: static void set_minbw_data(struct adreno_device *adreno_dev, void *priv)
683: {
684: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
685: const struct gmu_dev_ops *ops = GMU_DEVICE_OPS(device);
686:
687: if (ops && ops->minbw_idle_level_set)
688: ops->minbw_idle_level_set(device, *((u32 *)priv));
689: }
690:
691: static int _minbw_data_store(void *data, u64 val)
692: {
693: struct adreno_device *adreno_dev = data;
694: u32 minbw_val;
695:
696: /* Only 24 bits are allowed by GMU for this feature */
697: if (val & 0xffffffffff000000)
698: return -EINVAL;
699:
700: /* We cannot use minBW if IFPC or minBW is disabled */
701: if (!ADRENO_FEATURE(adreno_dev, ADRENO_IFPC) ||
702: (!ADRENO_FEATURE(adreno_dev, ADRENO_GMU_MINBW)))
703: return 0;
704:
705: minbw_val = (u32)val;
706:
707: return adreno_power_cycle(adreno_dev, set_minbw_data, &minbw_val);
708: }
709:
710: static int _minbw_data_show(void *data, u64 *val)
711: {
712: struct adreno_device *adreno_dev = data;
713:
714: *val = (u64)adreno_dev->minbw_data;
715: return 0;
716: }
717:
718: DEFINE_DEBUGFS_ATTRIBUTE(minbw_fops, _minbw_data_show, _minbw_data_store, "%llu\n");
719:
720: static int _gmu_fp_store(void *data, u64 val)
721: {
722: struct adreno_device *adreno_dev = data;
723: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
724:
725: /* Max allowed GMU fault settings are 9 bits */
MATCH LINES: 830, 831
818: if (ADRENO_FEATURE(adreno_dev, ADRENO_LM)) {
819: debugfs_create_file("lm_limit", 0644, device->d_debugfs, device,
820: &_lm_limit_fops);
821: debugfs_create_file("lm_threshold_count", 0444,
822: device->d_debugfs, device, &_lm_threshold_fops);
823: }
824:
825: if (adreno_is_a5xx(adreno_dev))
826: debugfs_create_file("isdb", 0644, device->d_debugfs,
827: device, &_isdb_fops);
828:
829: if (gmu_core_isenabled(device)) {
830: debugfs_create_file("ifpc_hyst", 0644, device->d_debugfs,
831: device, &ifpc_hyst_fops);
832:
833: debugfs_create_file("minbw", 0644, device->d_debugfs,
834: device, &minbw_fops);
835:
836: debugfs_create_file("gmu_fault_policy", 0644, device->d_debugfs,
837: device, &gmu_fp_fops);
838: }
839:
840: if (ADRENO_FEATURE(adreno_dev, ADRENO_GMU_WARMBOOT))
841: debugfs_create_file("warmboot", 0644, device->d_debugfs,
842: device, &warmboot_fops);
843:
844: debugfs_create_file("ctxt_record_size", 0644, snapshot_dir,
845: device, &_ctxt_record_size_fops);
846: debugfs_create_file("gpu_client_pf", 0644, snapshot_dir,
847: device, &_gpu_client_pf_fops);
848: debugfs_create_bool("dump_all_ibs", 0644, snapshot_dir,
849: &device->dump_all_ibs);
850: debugfs_create_file("prealloc_atomic_snapshot_mem", 0644, snapshot_dir,
851: device, &_prealloc_atomic_snapshot_mem_fops);
852:
853: adreno_dev->bcl_debugfs_dir = debugfs_create_dir("bcl", device->d_debugfs);
854: if (!IS_ERR_OR_NULL(adreno_dev->bcl_debugfs_dir)) {
855: debugfs_create_file("sid0", 0644, adreno_dev->bcl_debugfs_dir, device, &_sid0_fops);
--- FILE: \adreno_dispatch.c | HITS: 3 ---
MATCH LINES: 2015, 2016, 2017
2003: adreno_readreg64(adreno_dev, ADRENO_REG_CP_IB1_BASE,
2004: ADRENO_REG_CP_IB1_BASE_HI, &base);
2005:
2006: if (!test_bit(KGSL_FT_PAGEFAULT_GPUHALT_ENABLE, &device->mmu.pfpolicy)
2007: && adreno_dev->cooperative_reset)
2008: gmu_core_dev_cooperative_reset(device);
2009:
2010: if (!(fault & ADRENO_GMU_FAULT_SKIP_SNAPSHOT))
2011: do_header_and_snapshot(device, fault, hung_rb, cmdobj);
2012:
2013: adreno_gpufault_stats(adreno_dev, cmdobj ? DRAWOBJ(cmdobj) : NULL, NULL, fault);
2014:
2015: /* Turn off the KEEPALIVE vote from the ISR for hard fault */
2016: if (gpudev->gpu_keepalive && fault & ADRENO_HARD_FAULT)
2017: gpudev->gpu_keepalive(adreno_dev, false);
2018:
2019: /* Terminate the stalled transaction and resume the IOMMU */
2020: if (fault & ADRENO_IOMMU_STALL_ON_PAGE_FAULT)
2021: kgsl_mmu_pagefault_resume(&device->mmu, true);
2022:
2023: /* Reset the dispatcher queue */
2024: dispatcher->inflight = 0;
2025:
2026: /* Remove the bus hint */
2027: device->pwrctrl.rt_bus_hint_active = false;
2028:
2029: /* Reset the GPU and make sure halt is not set during recovery */
2030: halt = adreno_gpu_halt(adreno_dev);
2031: adreno_clear_gpu_halt(adreno_dev);
2032:
2033: /*
2034: * If there is a stall in the ringbuffer after all commands have been
2035: * retired then we could hit problems if contexts are waiting for
2036: * internal timestamps that will never retire
2037: */
2038:
2039: if (hung_rb != NULL) {
2040: kgsl_sharedmem_writel(device->memstore,
2041: MEMSTORE_RB_OFFSET(hung_rb, soptimestamp),
--- FILE: \adreno_gen7.c | HITS: 62 ---
MATCH LINES: 27, 64, 65
15: #include <linux/soc/qcom/ubwc.h>
16: #endif
17:
18: #include "adreno.h"
19: #include "adreno_gen7.h"
20: #include "adreno_gen7_hwsched.h"
21: #include "adreno_pm4types.h"
22: #include "adreno_trace.h"
23: #include "kgsl_pwrscale.h"
24: #include "kgsl_trace.h"
25: #include "kgsl_util.h"
26:
27: /* IFPC & Preemption static powerup restore list */
28: static const u32 gen7_pwrup_reglist[] = {
29: GEN7_UCHE_TRAP_BASE_LO,
30: GEN7_UCHE_TRAP_BASE_HI,
31: GEN7_UCHE_WRITE_THRU_BASE_LO,
32: GEN7_UCHE_WRITE_THRU_BASE_HI,
33: GEN7_UCHE_GMEM_RANGE_MIN_LO,
34: GEN7_UCHE_GMEM_RANGE_MIN_HI,
35: GEN7_UCHE_GMEM_RANGE_MAX_LO,
36: GEN7_UCHE_GMEM_RANGE_MAX_HI,
37: GEN7_UCHE_CACHE_WAYS,
38: GEN7_UCHE_MODE_CNTL,
39: GEN7_RB_NC_MODE_CNTL,
40: GEN7_RB_CONTEXT_SWITCH_GMEM_SAVE_RESTORE,
41: GEN7_UCHE_GBIF_GX_CONFIG,
42: GEN7_UCHE_CLIENT_PF,
43: GEN7_TPL1_DBG_ECO_CNTL1,
44: };
45:
46: static const u32 gen7_0_0_pwrup_reglist[] = {
47: GEN7_UCHE_TRAP_BASE_LO,
48: GEN7_UCHE_TRAP_BASE_HI,
49: GEN7_UCHE_WRITE_THRU_BASE_LO,
50: GEN7_UCHE_WRITE_THRU_BASE_HI,
51: GEN7_UCHE_GMEM_RANGE_MIN_LO,
52: GEN7_UCHE_GMEM_RANGE_MIN_HI,
53: GEN7_UCHE_GMEM_RANGE_MAX_LO,
54: GEN7_UCHE_GMEM_RANGE_MAX_HI,
55: GEN7_UCHE_CACHE_WAYS,
56: GEN7_UCHE_MODE_CNTL,
57: GEN7_RB_NC_MODE_CNTL,
58: GEN7_SP_NC_MODE_CNTL,
59: GEN7_RB_CONTEXT_SWITCH_GMEM_SAVE_RESTORE,
60: GEN7_UCHE_GBIF_GX_CONFIG,
61: GEN7_UCHE_CLIENT_PF,
62: };
63:
64: /* IFPC only static powerup restore list */
65: static const u32 gen7_ifpc_pwrup_reglist[] = {
66: GEN7_TPL1_NC_MODE_CNTL,
67: GEN7_SP_NC_MODE_CNTL,
68: GEN7_CP_DBG_ECO_CNTL,
69: GEN7_CP_PROTECT_CNTL,
70: GEN7_CP_LPAC_PROTECT_CNTL,
71: GEN7_CP_PROTECT_REG,
72: GEN7_CP_PROTECT_REG+1,
73: GEN7_CP_PROTECT_REG+2,
74: GEN7_CP_PROTECT_REG+3,
75: GEN7_CP_PROTECT_REG+4,
76: GEN7_CP_PROTECT_REG+5,
77: GEN7_CP_PROTECT_REG+6,
78: GEN7_CP_PROTECT_REG+7,
79: GEN7_CP_PROTECT_REG+8,
80: GEN7_CP_PROTECT_REG+9,
81: GEN7_CP_PROTECT_REG+10,
82: GEN7_CP_PROTECT_REG+11,
83: GEN7_CP_PROTECT_REG+12,
84: GEN7_CP_PROTECT_REG+13,
85: GEN7_CP_PROTECT_REG+14,
86: GEN7_CP_PROTECT_REG+15,
87: GEN7_CP_PROTECT_REG+16,
88: GEN7_CP_PROTECT_REG+17,
89: GEN7_CP_PROTECT_REG+18,
MATCH LINES: 121
109: GEN7_CP_PROTECT_REG+38,
110: GEN7_CP_PROTECT_REG+39,
111: GEN7_CP_PROTECT_REG+40,
112: GEN7_CP_PROTECT_REG+41,
113: GEN7_CP_PROTECT_REG+42,
114: GEN7_CP_PROTECT_REG+43,
115: GEN7_CP_PROTECT_REG+44,
116: GEN7_CP_PROTECT_REG+45,
117: GEN7_CP_PROTECT_REG+46,
118: GEN7_CP_PROTECT_REG+47,
119: };
120:
121: static const u32 gen7_0_0_ifpc_pwrup_reglist[] = {
122: GEN7_TPL1_NC_MODE_CNTL,
123: GEN7_CP_DBG_ECO_CNTL,
124: GEN7_CP_PROTECT_CNTL,
125: GEN7_CP_LPAC_PROTECT_CNTL,
126: GEN7_CP_PROTECT_REG,
127: GEN7_CP_PROTECT_REG+1,
128: GEN7_CP_PROTECT_REG+2,
129: GEN7_CP_PROTECT_REG+3,
130: GEN7_CP_PROTECT_REG+4,
131: GEN7_CP_PROTECT_REG+5,
132: GEN7_CP_PROTECT_REG+6,
133: GEN7_CP_PROTECT_REG+7,
134: GEN7_CP_PROTECT_REG+8,
135: GEN7_CP_PROTECT_REG+9,
136: GEN7_CP_PROTECT_REG+10,
137: GEN7_CP_PROTECT_REG+11,
138: GEN7_CP_PROTECT_REG+12,
139: GEN7_CP_PROTECT_REG+13,
140: GEN7_CP_PROTECT_REG+14,
141: GEN7_CP_PROTECT_REG+15,
142: GEN7_CP_PROTECT_REG+16,
143: GEN7_CP_PROTECT_REG+17,
144: GEN7_CP_PROTECT_REG+18,
145: GEN7_CP_PROTECT_REG+19,
MATCH LINES: 176, 177, 184
164: GEN7_CP_PROTECT_REG+38,
165: GEN7_CP_PROTECT_REG+39,
166: GEN7_CP_PROTECT_REG+40,
167: GEN7_CP_PROTECT_REG+41,
168: GEN7_CP_PROTECT_REG+42,
169: GEN7_CP_PROTECT_REG+43,
170: GEN7_CP_PROTECT_REG+44,
171: GEN7_CP_PROTECT_REG+45,
172: GEN7_CP_PROTECT_REG+46,
173: GEN7_CP_PROTECT_REG+47,
174: };
175:
176: /* Gen7_9_x IFPC only static powerup restore list */
177: static const u32 gen7_9_x_ifpc_pwrup_reglist[] = {
178: GEN7_TPL1_BICUBIC_WEIGHTS_TABLE_1,
179: GEN7_TPL1_BICUBIC_WEIGHTS_TABLE_2,
180: GEN7_TPL1_BICUBIC_WEIGHTS_TABLE_3,
181: GEN7_TPL1_BICUBIC_WEIGHTS_TABLE_4,
182: };
183:
184: static const u32 gen7_2_0_ifpc_pwrup_reglist[] = {
185: GEN7_SP_CHICKEN_BITS_2,
186: GEN7_SP_LPAC_CHICKEN_BITS_2,
187: };
188:
189: static const struct gen7_pwrup_extlist gen7_pwrup_extlist_cb[] = {
190: { GEN7_GRAS_NC_MODE_CNTL, BIT(PIPE_BV) | BIT(PIPE_BR)},
191: { GEN7_RB_CMP_DBG_ECO_CNTL, BIT(PIPE_BR)},
192: };
193:
194: static const u32 gen7_pwrup_reglist_no_cb[] = {
195: GEN7_UCHE_TRAP_BASE_LO,
196: GEN7_UCHE_TRAP_BASE_HI,
197: GEN7_UCHE_WRITE_THRU_BASE_LO,
198: GEN7_UCHE_WRITE_THRU_BASE_HI,
199: GEN7_UCHE_GMEM_RANGE_MIN_LO,
200: GEN7_UCHE_GMEM_RANGE_MIN_HI,
201: GEN7_UCHE_GMEM_RANGE_MAX_LO,
202: GEN7_UCHE_GMEM_RANGE_MAX_HI,
203: GEN7_UCHE_CACHE_WAYS,
204: GEN7_UCHE_MODE_CNTL,
205: GEN7_RB_NC_MODE_CNTL,
206: GEN7_RB_CMP_DBG_ECO_CNTL,
207: GEN7_GRAS_NC_MODE_CNTL,
208: GEN7_SP_NC_MODE_CNTL,
MATCH LINES: 671, 673, 674, 676, 677, 679, 685, 686, 687, 693, 694, 695, 699, 725, 728, 735, 736, 737, 740
659: }
660:
661: static void gen7_patch_pwrup_reglist(struct adreno_device *adreno_dev)
662: {
663: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
664: struct gen7_device *gen7_dev = container_of(adreno_dev, struct gen7_device, adreno_dev);
665: struct adreno_reglist_list reglist[3];
666: void *ptr = adreno_dev->pwrup_reglist->hostptr;
667: struct cpu_gpu_lock *lock = ptr;
668: u32 items = 0, i, j, pipe_id;
669: u32 *dest = ptr + sizeof(*lock);
670:
671: /* Static IFPC restore only registers */
672: if (adreno_is_gen7_0_x_family(adreno_dev) || adreno_is_gen7_no_cb_family(adreno_dev)) {
673: reglist[items].regs = gen7_0_0_ifpc_pwrup_reglist;
674: reglist[items].count = ARRAY_SIZE(gen7_0_0_ifpc_pwrup_reglist);
675: } else {
676: reglist[items].regs = gen7_ifpc_pwrup_reglist;
677: reglist[items].count = ARRAY_SIZE(gen7_ifpc_pwrup_reglist);
678: }
679: lock->ifpc_list_len = reglist[items].count;
680: items++;
681:
682: if (adreno_is_gen7_2_0(adreno_dev) || adreno_is_gen7_2_1(adreno_dev) ||
683: adreno_is_gen7_6_0(adreno_dev)) {
684: if (adreno_dev->lpac_enabled) {
685: reglist[items].regs = gen7_2_0_ifpc_pwrup_reglist;
686: reglist[items].count = ARRAY_SIZE(gen7_2_0_ifpc_pwrup_reglist);
687: lock->ifpc_list_len += reglist[items].count;
688: items++;
689: }
690: }
691:
692: if (adreno_is_gen7_9_x(adreno_dev)) {
693: reglist[items].regs = gen7_9_x_ifpc_pwrup_reglist;
694: reglist[items].count = ARRAY_SIZE(gen7_9_x_ifpc_pwrup_reglist);
695: lock->ifpc_list_len += reglist[items].count;
696: items++;
697: }
698:
699: /* Static IFPC + preemption registers */
700: if (adreno_is_gen7_no_cb_family(adreno_dev)) {
701: reglist[items].regs = gen7_pwrup_reglist_no_cb;
702: reglist[items].count = ARRAY_SIZE(gen7_pwrup_reglist_no_cb);
703: } else if (adreno_is_gen7_0_x_family(adreno_dev)) {
704: reglist[items].regs = gen7_0_0_pwrup_reglist;
705: reglist[items].count = ARRAY_SIZE(gen7_0_0_pwrup_reglist);
706: } else {
707: reglist[items].regs = gen7_pwrup_reglist;
708: reglist[items].count = ARRAY_SIZE(gen7_pwrup_reglist);
709: }
710: lock->preemption_list_len = reglist[items].count;
711: items++;
712:
713: /*
714: * For each entry in each of the lists, write the offset and the current
715: * register value into the GPU buffer
716: */
717: for (i = 0; i < items; i++) {
718: const u32 *r = reglist[i].regs;
719:
720: for (j = 0; j < reglist[i].count; j++) {
721: *dest++ = r[j];
722: kgsl_regread(device, r[j], dest++);
723: }
724:
725: if ((r == gen7_ifpc_pwrup_reglist) || (r == gen7_0_0_ifpc_pwrup_reglist)) {
726: u32 cs_len = adreno_coresight_patch_pwrup_reglist(adreno_dev, dest);
727:
728: lock->ifpc_list_len += cs_len;
729: dest += (cs_len * 2);
730: }
731: }
732:
733: /*
734: * The overall register list is composed of
735: * 1. Static IFPC restore only registers
736: * 2. Static IFPC + preemption registers
737: * 3. Dynamic IFPC + preemption registers (ex: perfcounter selects)
738: *
739: * The first two lists are static. Size of these lists are stored as
740: * number of pairs in ifpc_list_len and preemption_list_len
741: * respectively. With concurrent binning, Some of the perfcounter
742: * registers being virtualized, CP needs to know the pipe id to program
743: * the aperture inorder to restore the same. Thus, third list is a
744: * dynamic list with triplets as
745: * (<aperture, shifted 12 bits> <address> <data>), and the length is
746: * stored as number for triplets in dynamic_list_len.
747: *
748: * Starting with Gen7, some of the registers that are initialized statically
749: * by the kernel are pipe-specific. Because only the dynamic list is able to
750: * support specifying a pipe ID, these registers are bundled along with any
751: * dynamic entries such as perf counter selects into a single dynamic list.
752: */
753: gen7_dev->ext_pwrup_list_len = 0;
754:
755: /*
756: * Write external pipe specific regs (<aperture> <address> <value> - triplets)
757: * offset and the current value into GPU buffer
758: */
759: if (adreno_is_gen7_no_cb_family(adreno_dev)) {
760: lock->dynamic_list_len = 0;
761: return;
762: }
763:
764: for (pipe_id = PIPE_BR; pipe_id <= PIPE_BV; pipe_id++) {
MATCH LINES: 938, 944, 945, 950
926: */
927: if (adreno_dev->lpac_enabled)
928: kgsl_regrmw(device, GEN7_UCHE_DBG_CNTL_1, BIT(30), BIT(30));
929:
930: kgsl_regwrite(device, GEN7_UCHE_CMDQ_CONFIG,
931: FIELD_PREP(GENMASK(19, 16), 6) |
932: FIELD_PREP(GENMASK(15, 12), 6) |
933: FIELD_PREP(GENMASK(11, 8), 9) |
934: BIT(3) | BIT(2) |
935: FIELD_PREP(GENMASK(1, 0), 2));
936:
937: /*
938: * CP takes care of the restore during IFPC exit. We need to restore at slumber
939: * boundary as well
940: */
941: if (pwrup_lock->dynamic_list_len - gen7_dev->ext_pwrup_list_len > 0)
942: kgsl_regwrite(device, GEN7_RBBM_PERFCTR_CNTL, 0x1);
943:
944: /* Turn on the IFPC counter (countable 4 on XOCLK4) */
945: kgsl_regwrite(device, GEN7_GMU_CX_GMU_POWER_COUNTER_SELECT_1,
946: FIELD_PREP(GENMASK(7, 0), 0x4));
947:
948: /* Turn on counter to count total time spent in BCL throttle */
949: if (adreno_dev->bcl_enabled && adreno_is_gen7_2_x_family(adreno_dev))
950: kgsl_regrmw(device, GEN7_GMU_CX_GMU_POWER_COUNTER_SELECT_1, GENMASK(15, 8),
951: FIELD_PREP(GENMASK(15, 8), 0x26));
952:
953: if (adreno_dev->highest_bank_bit) {
954: hbb_lo = (adreno_dev->highest_bank_bit - 13) & 3;
955: hbb_hi = ((adreno_dev->highest_bank_bit - 13) >> 2) & 1;
956: }
957:
958: kgsl_regwrite(device, GEN7_RB_NC_MODE_CNTL,
959: (ubwc_props->rgb565_predicator ? BIT(11) : 0) |
960: ((hbb_hi == 1) ? BIT(10) : 0) |
961: BIT(4) | /*AMSBC is enabled on UBWC 3.0 and 4.0 */
962: ((mal == 64) ? BIT(3) : 0) |
963: FIELD_PREP(GENMASK(2, 1), hbb_lo));
964:
965: kgsl_regwrite(device, GEN7_TPL1_NC_MODE_CNTL,
966: ((hbb_hi == 1) ? BIT(4) : 0) |
967: ((mal == 64) ? BIT(3) : 0) |
968: FIELD_PREP(GENMASK(2, 1), hbb_lo));
969:
970: /* Configure TP bicubic registers */
971: if (adreno_is_gen7_9_x(adreno_dev)) {
972: kgsl_regwrite(device, GEN7_TPL1_BICUBIC_WEIGHTS_TABLE_1, 0x3fe05ff4);
973: kgsl_regwrite(device, GEN7_TPL1_BICUBIC_WEIGHTS_TABLE_2, 0x3fa0ebee);
974: kgsl_regwrite(device, GEN7_TPL1_BICUBIC_WEIGHTS_TABLE_3, 0x3f5193ed);
MATCH LINES: 1027, 1029
1015: kgsl_regrmw(device, GEN7_RB_CMP_DBG_ECO_CNTL, BIT(19), BIT(19));
1016:
1017: /* Enable TP flaghint and other performance settings */
1018: kgsl_regwrite(device, GEN7_TPL1_DBG_ECO_CNTL1, 0xc0700);
1019: } else {
1020: /* Disable non-ubwc read reqs from passing write reqs */
1021: if (!adreno_is_gen7_15_0(adreno_dev) && !adreno_is_gen7_11_0(adreno_dev))
1022: kgsl_regrmw(device, GEN7_RB_CMP_DBG_ECO_CNTL, BIT(11), BIT(11));
1023: }
1024:
1025: /* Enable GMU power counter 0 to count GPU busy */
1026: kgsl_regwrite(device, GEN7_GPU_GMU_AO_GPU_CX_BUSY_MASK, 0xff000000);
1027: kgsl_regrmw(device, GEN7_GMU_CX_GMU_POWER_COUNTER_SELECT_0,
1028: 0xFF, 0x20);
1029: kgsl_regwrite(device, GEN7_GMU_CX_GMU_POWER_COUNTER_ENABLE, 0x1);
1030:
1031: gen7_protect_init(adreno_dev);
1032:
1033: /* Configure LLCC */
1034: _llc_configure_gpu_scid(adreno_dev);
1035: _llc_gpuhtw_slice_activate(adreno_dev);
1036:
1037: kgsl_regwrite(device, GEN7_CP_APRIV_CNTL, GEN7_BR_APRIV_DEFAULT);
1038:
1039: /* Skip this regwrite for Gen7 targets that do not have BV and LPAC */
1040: if (!adreno_is_gen7_no_cb_family(adreno_dev))
1041: kgsl_regwrite(device, GEN7_CP_BV_APRIV_CNTL, GEN7_APRIV_DEFAULT);
1042:
1043: if (ADRENO_FEATURE(adreno_dev, ADRENO_LPAC))
1044: kgsl_regwrite(device, GEN7_CP_LPAC_APRIV_CNTL, GEN7_APRIV_DEFAULT);
1045:
1046: /* Marking AQE Instruction cache fetches as privileged */
1047: if (ADRENO_FEATURE(adreno_dev, ADRENO_AQE))
1048: kgsl_regwrite(device, GEN7_CP_AQE_APRIV_CNTL, BIT(0));
1049:
1050: /*
1051: * CP Icache prefetch brings no benefit on few gen7 variants because of
1052: * the prefetch granularity size.
1053: */
MATCH LINES: 1350, 1354, 1358
1338: if (ret) {
1339: gen7_spin_idle_debug(adreno_dev,
1340: "Switch to unsecure failed to idle\n");
1341: return ret;
1342: }
1343: }
1344: }
1345:
1346: return gen7_post_start(adreno_dev);
1347: }
1348:
1349: /*
1350: * gen7_gpu_keepalive() - GMU reg write to request GPU stays on
1351: * @adreno_dev: Pointer to the adreno device that has the GMU
1352: * @state: State to set: true is ON, false is OFF
1353: */
1354: static void gen7_gpu_keepalive(struct adreno_device *adreno_dev,
1355: bool state)
1356: {
1357: gmu_core_regwrite(KGSL_DEVICE(adreno_dev),
1358: GEN7_GMU_GMU_PWR_COL_KEEPALIVE, state);
1359: }
1360:
1361: bool gen7_hw_isidle(struct adreno_device *adreno_dev)
1362: {
1363: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1364: unsigned int reg;
1365:
1366: gmu_core_regread(device, GEN7_GPU_GMU_AO_GPU_CX_BUSY_STATUS, ®);
1367:
1368: /* Bit 23 is GPUBUSYIGNAHB */
1369: return (reg & BIT(23)) ? false : true;
1370: }
1371:
1372: int gen7_microcode_read(struct adreno_device *adreno_dev)
1373: {
1374: struct adreno_firmware *sqe_fw = ADRENO_FW(adreno_dev, ADRENO_FW_SQE);
1375: const struct adreno_gen7_core *gen7_core = to_gen7_core(adreno_dev);
1376:
1377: return adreno_get_firmware(adreno_dev, gen7_core->sqefw_name, sqe_fw);
1378: }
1379:
1380: /* CP Interrupt bits */
1381: #define CP_INT_OPCODEERROR 0
1382: #define CP_INT_UCODEERROR 1
MATCH LINES: 1567
1555: */
1556: if (!kgsl_mutex_trylock(&device->mutex))
1557: goto regread_fail;
1558:
1559: if (!kgsl_state_is_awake(device)) {
1560: kgsl_mutex_unlock(&device->mutex);
1561: goto regread_fail;
1562: }
1563:
1564: kgsl_regread(device, GEN7_UCHE_CLIENT_PF, &uche_client_id);
1565: kgsl_mutex_unlock(&device->mutex);
1566:
1567: /* Ignore the value if the gpu is in IFPC */
1568: if (uche_client_id == SCOOBYDOO) {
1569: uche_client_id = adreno_dev->uche_client_pf;
1570: goto regread_fail;
1571: }
1572:
1573: /* UCHE client id mask is bits [6:0] */
1574: uche_client_id &= GENMASK(6, 0);
1575:
1576: regread_fail:
1577: if (lpac) {
1578: fault_block = "UCHE_LPAC";
1579: if (uche_client_id >= ARRAY_SIZE(uche_lpac_client))
1580: goto fail;
1581: uche_client_str = uche_lpac_client[uche_client_id];
1582: } else {
1583: fault_block = "UCHE";
1584: if (uche_client_id >= ARRAY_SIZE(uche_client))
1585: goto fail;
1586: uche_client_str = uche_client[uche_client_id];
1587: }
1588:
1589: snprintf(str, size, "%s: %s", fault_block, uche_client_str);
1590: return str;
1591:
MATCH LINES: 1784, 1786, 1796, 1798, 1812, 1814, 1830, 1832
1772: return 0;
1773: }
1774:
1775: static irqreturn_t gen7_hwsched_irq_handler(struct adreno_device *adreno_dev)
1776: {
1777: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1778: irqreturn_t ret = IRQ_NONE;
1779: u32 status;
1780:
1781: /*
1782: * GPU can power down once the INT_0_STATUS is read below.
1783: * But there still might be some register reads required so
1784: * force the GMU/GPU into KEEPALIVE mode until done with the ISR.
1785: */
1786: gen7_gpu_keepalive(adreno_dev, true);
1787:
1788: kgsl_regread(device, GEN7_RBBM_INT_0_STATUS, &status);
1789:
1790: kgsl_regwrite(device, GEN7_RBBM_INT_CLEAR_CMD, status);
1791:
1792: ret = adreno_irq_callbacks(adreno_dev, gen7_irq_funcs, status);
1793:
1794: trace_kgsl_gen7_irq_status(adreno_dev, status);
1795:
1796: /* If hard fault, then let snapshot turn off the keepalive */
1797: if (!(adreno_gpu_fault(adreno_dev) & ADRENO_HARD_FAULT))
1798: gen7_gpu_keepalive(adreno_dev, false);
1799:
1800: return ret;
1801: }
1802:
1803: static irqreturn_t gen7_irq_handler(struct adreno_device *adreno_dev)
1804: {
1805: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1806: irqreturn_t ret = IRQ_NONE;
1807: u32 status;
1808:
1809: /*
1810: * GPU can power down once the INT_0_STATUS is read below.
1811: * But there still might be some register reads required so
1812: * force the GMU/GPU into KEEPALIVE mode until done with the ISR.
1813: */
1814: gen7_gpu_keepalive(adreno_dev, true);
1815:
1816: if (gen7_irq_poll_fence(adreno_dev)) {
1817: adreno_scheduler_fault(adreno_dev, ADRENO_GMU_FAULT);
1818: goto done;
1819: }
1820:
1821: kgsl_regread(device, GEN7_RBBM_INT_0_STATUS, &status);
1822:
1823: kgsl_regwrite(device, GEN7_RBBM_INT_CLEAR_CMD, status);
1824:
1825: ret = adreno_irq_callbacks(adreno_dev, gen7_irq_funcs, status);
1826:
1827: trace_kgsl_gen7_irq_status(adreno_dev, status);
1828:
1829: done:
1830: /* If hard fault, then let snapshot turn off the keepalive */
1831: if (!(adreno_gpu_fault(adreno_dev) & ADRENO_HARD_FAULT))
1832: gen7_gpu_keepalive(adreno_dev, false);
1833:
1834: return ret;
1835: }
1836:
1837: int gen7_probe_common(struct platform_device *pdev,
1838: struct adreno_device *adreno_dev, u32 chipid,
1839: const struct adreno_gpu_core *gpucore)
1840: {
1841: const struct adreno_gpudev *gpudev = gpucore->gpudev;
1842: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1843: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1844: const struct adreno_gen7_core *gen7_core = container_of(gpucore,
1845: struct adreno_gen7_core, base);
1846: int ret;
1847:
1848: adreno_dev->gpucore = gpucore;
1849: adreno_dev->chipid = chipid;
1850:
1851: adreno_reg_offset_init(gpudev->reg_offsets);
1852:
1853: adreno_dev->hwcg_enabled = true;
1854: adreno_dev->uche_client_pf = 1;
1855:
1856: kgsl_pwrscale_fast_bus_hint(gen7_core->fast_bus_hint);
MATCH LINES: 1964
1952: }
1953: }
1954:
1955: int gen7_perfcounter_remove(struct adreno_device *adreno_dev,
1956: struct adreno_perfcount_register *reg, u32 groupid)
1957: {
1958: const struct adreno_perfcounters *counters = ADRENO_PERFCOUNTERS(adreno_dev);
1959: struct gen7_device *gen7_dev = container_of(adreno_dev, struct gen7_device, adreno_dev);
1960: const struct adreno_perfcount_group *group;
1961: void *ptr = adreno_dev->pwrup_reglist->hostptr;
1962: struct cpu_gpu_lock *lock = ptr;
1963: bool remove_counter = false;
1964: u32 offset = ((lock->ifpc_list_len + lock->preemption_list_len) * 2) +
1965: (gen7_dev->ext_pwrup_list_len * 3);
1966: int i, last_offset, second_last_offset;
1967: u32 *data = ptr + sizeof(*lock), pipe = FIELD_PREP(GENMASK(13, 12), _get_pipeid(groupid));
1968: u16 perfcntr_list_len = lock->dynamic_list_len - gen7_dev->ext_pwrup_list_len;
1969:
1970: if (!perfcntr_list_len)
1971: return -EINVAL;
1972:
1973: group = &(counters->groups[groupid]);
1974:
1975: if (!(group->flags & ADRENO_PERFCOUNTER_GROUP_RESTORE)) {
1976: if (perfcntr_list_len != 1)
1977: return 0;
1978:
1979: if (kgsl_hwlock(lock)) {
1980: kgsl_hwunlock(lock);
1981: return -EBUSY;
1982: }
1983: goto disable_perfcounter;
1984: }
1985:
1986: second_last_offset = offset + (lock->dynamic_list_len - 2) * 3;
1987: last_offset = second_last_offset + 3;
1988:
MATCH LINES: 2079
2067:
2068: static void gen7_release_cp_semaphore(struct adreno_device *adreno_dev)
2069: {
2070: kgsl_regwrite(KGSL_DEVICE(adreno_dev), GEN7_CP_SEMAPHORE_REG_0, 0);
2071: }
2072:
2073: int gen7_perfcounter_update(struct adreno_device *adreno_dev,
2074: struct adreno_perfcount_register *reg, bool update_reg, u32 pipe, unsigned long flags)
2075: {
2076: struct gen7_device *gen7_dev = container_of(adreno_dev, struct gen7_device, adreno_dev);
2077: void *ptr = adreno_dev->pwrup_reglist->hostptr;
2078: struct cpu_gpu_lock *lock = ptr;
2079: u32 offset = ((lock->ifpc_list_len + lock->preemption_list_len) * 2) +
2080: (gen7_dev->ext_pwrup_list_len * 3);
2081: u32 *data = ptr + sizeof(*lock);
2082: u64 reglist_size_dwords = adreno_dev->pwrup_reglist->size / sizeof(u32);
2083: u64 lock_size_dwords = sizeof(*lock) / sizeof(u32);
2084: int i;
2085: u16 perfcntr_list_len = lock->dynamic_list_len - gen7_dev->ext_pwrup_list_len;
2086: bool select_reg_present = false;
2087: unsigned long irq_flags;
2088: int ret = 0;
2089: u32 pending_triplets = 1;
2090:
2091: if (!ADRENO_ACQUIRE_CP_SEMAPHORE(adreno_dev, irq_flags))
2092: return -EBUSY;
2093:
2094: if (flags & ADRENO_PERFCOUNTER_GROUP_RESTORE) {
2095: /* No of triplet to add if restoring: 1 main + 1 control otherwise: 1 control */
2096: pending_triplets++;
2097: for (i = 0; i < perfcntr_list_len; i++) {
2098: if ((data[offset + 1] == reg->select) && (data[offset] == pipe)) {
2099: select_reg_present = true;
2100: break;
2101: }
2102:
2103: if (data[offset + 1] == GEN7_RBBM_PERFCTR_CNTL)
MATCH LINES: 2284, 2285, 2286, 2287, 2289, 2290, 2291, 2297, 2300, 2303, 2311, 2329
2272: adreno_dev->starved_ram_lo_ch1,
2273: &busy->bif_starved_ram_ch1);
2274:
2275: stats->ram_time = ram_cycles;
2276: stats->ram_wait = starved_ram;
2277: }
2278:
2279: static void gen7_power_feature_stats(struct adreno_device *adreno_dev)
2280: {
2281: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2282: struct adreno_busy_data *busy = &adreno_dev->busy_data;
2283:
2284: if (ADRENO_FEATURE(adreno_dev, ADRENO_IFPC)) {
2285: u32 ifpc = counter_delta(device,
2286: GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_4_L,
2287: &busy->num_ifpc);
2288:
2289: adreno_dev->ifpc_count += ifpc;
2290: if (ifpc > 0)
2291: trace_adreno_ifpc_count(adreno_dev->ifpc_count);
2292: }
2293:
2294: if (adreno_dev->bcl_enabled) {
2295: u32 a, b, c;
2296:
2297: a = counter_delta(device, GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_1_L,
2298: &busy->throttle_cycles[0]);
2299:
2300: b = counter_delta(device, GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_2_L,
2301: &busy->throttle_cycles[1]);
2302:
2303: c = counter_delta(device, GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_3_L,
2304: &busy->throttle_cycles[2]);
2305:
2306: if (a || b || c)
2307: trace_kgsl_bcl_clock_throttling(a, b, c);
2308:
2309: if (adreno_is_gen7_2_x_family(adreno_dev)) {
2310: u32 bcl_throttle = counter_delta(device,
2311: GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_5_L, &busy->bcl_throttle);
2312: /*
2313: * This counts number of cycles throttled in XO cycles. Convert it to
2314: * micro seconds by dividing by XO freq which is 19.2MHz.
2315: */
2316: adreno_dev->bcl_throttle_time_us += ((bcl_throttle * 10) / 192);
2317: }
2318: }
2319: }
2320:
2321: static void gen7_power_stats(struct adreno_device *adreno_dev,
2322: struct kgsl_power_stats *stats)
2323: {
2324: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2325: struct adreno_busy_data *busy = &adreno_dev->busy_data;
2326: u64 gpu_busy;
2327:
2328: /* Set the GPU busy counter for frequency scaling */
2329: gpu_busy = counter_delta(device, GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_L,
2330: &busy->gpu_busy);
2331:
2332: stats->busy_time = gpu_busy * 10;
2333: do_div(stats->busy_time, 192);
2334:
2335: if (device->pwrctrl.bus_control)
2336: gen7_read_bus_stats(device, stats, busy);
2337:
2338: /* Read stats that are not associated with DCVS */
2339: gen7_power_feature_stats(adreno_dev);
2340: }
2341:
2342: static void gen7_set_isdb_breakpoint_registers(struct adreno_device *adreno_dev)
2343: {
2344: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2345: struct clk *clk;
2346: int ret;
2347:
2348: /* QDSS unavailable, suppress force panic */
2349: if (!IS_ENABLED(CONFIG_QCOM_KGSL_QDSS_STM))
2350: goto err;
2351:
2352: if (!device->set_isdb_breakpoint || device->ftbl->is_hwcg_on(device)
2353: || device->qdss_gfx_virt == NULL || !device->force_panic)
MATCH LINES: 2510, 2542, 2570, 2576
2498: }
2499:
2500: const struct gen7_gpudev adreno_gen7_9_0_hwsched_gpudev = {
2501: .base = {
2502: .reg_offsets = gen7_register_offsets,
2503: .probe = gen7_hwsched_probe,
2504: .snapshot = gen7_hwsched_snapshot,
2505: .irq_handler = gen7_hwsched_irq_handler,
2506: .iommu_fault_block = gen7_iommu_fault_block,
2507: .context_detach = gen7_hwsched_context_detach,
2508: .read_alwayson = gen7_9_0_read_alwayson,
2509: .reset = gen7_hwsched_reset_replay,
2510: .power_ops = &gen7_hwsched_power_ops,
2511: .power_stats = gen7_power_stats,
2512: .hw_isidle = gen7_hw_isidle,
2513: .add_to_va_minidump = gen7_hwsched_add_to_minidump,
2514: .gx_is_on = gen7_gmu_gx_is_on,
2515: .send_recurring_cmdobj = gen7_hwsched_send_recurring_cmdobj,
2516: .perfcounter_remove = gen7_perfcounter_remove,
2517: .set_isdb_breakpoint_registers = gen7_set_isdb_breakpoint_registers,
2518: .context_destroy = gen7_hwsched_context_destroy,
2519: .lpac_store = gen7_9_0_lpac_store,
2520: .get_uche_trap_base = gen7_get_uche_trap_base,
2521: .fault_header = gen7_fault_header,
2522: .lpac_fault_header = gen7_lpac_fault_header,
2523: .power_feature_stats = gen7_power_feature_stats,
2524: .acquire_cp_semaphore = gen7_acquire_cp_semaphore,
2525: .release_cp_semaphore = gen7_release_cp_semaphore,
2526: },
2527: .hfi_probe = gen7_hwsched_hfi_probe,
2528: .hfi_remove = gen7_hwsched_hfi_remove,
2529: .handle_watchdog = gen7_hwsched_handle_watchdog,
2530: };
2531:
2532: const struct gen7_gpudev adreno_gen7_hwsched_gpudev = {
2533: .base = {
2534: .reg_offsets = gen7_register_offsets,
2535: .probe = gen7_hwsched_probe,
2536: .snapshot = gen7_hwsched_snapshot,
2537: .irq_handler = gen7_hwsched_irq_handler,
2538: .iommu_fault_block = gen7_iommu_fault_block,
2539: .context_detach = gen7_hwsched_context_detach,
2540: .read_alwayson = gen7_read_alwayson,
2541: .reset = gen7_hwsched_reset_replay,
2542: .power_ops = &gen7_hwsched_power_ops,
2543: .power_stats = gen7_power_stats,
2544: .hw_isidle = gen7_hw_isidle,
2545: .add_to_va_minidump = gen7_hwsched_add_to_minidump,
2546: .gx_is_on = gen7_gmu_gx_is_on,
2547: .send_recurring_cmdobj = gen7_hwsched_send_recurring_cmdobj,
2548: .perfcounter_remove = gen7_perfcounter_remove,
2549: .set_isdb_breakpoint_registers = gen7_set_isdb_breakpoint_registers,
2550: .context_destroy = gen7_hwsched_context_destroy,
2551: .lpac_store = gen7_lpac_store,
2552: .get_uche_trap_base = gen7_get_uche_trap_base,
2553: .fault_header = gen7_fault_header,
2554: .lpac_fault_header = gen7_lpac_fault_header,
2555: .acquire_cp_semaphore = gen7_acquire_cp_semaphore,
2556: .release_cp_semaphore = gen7_release_cp_semaphore,
2557: },
2558: .hfi_probe = gen7_hwsched_hfi_probe,
2559: .hfi_remove = gen7_hwsched_hfi_remove,
2560: .handle_watchdog = gen7_hwsched_handle_watchdog,
2561: };
2562:
2563: const struct gen7_gpudev adreno_gen7_gmu_gpudev = {
2564: .base = {
2565: .reg_offsets = gen7_register_offsets,
2566: .probe = gen7_gmu_device_probe,
2567: .snapshot = gen7_gmu_snapshot,
2568: .irq_handler = gen7_irq_handler,
2569: .rb_start = gen7_rb_start,
2570: .gpu_keepalive = gen7_gpu_keepalive,
2571: .hw_isidle = gen7_hw_isidle,
2572: .iommu_fault_block = gen7_iommu_fault_block,
2573: .reset = gen7_gmu_reset,
2574: .preemption_schedule = gen7_preemption_schedule,
2575: .read_alwayson = gen7_read_alwayson,
2576: .power_ops = &gen7_gmu_power_ops,
2577: .remove = gen7_remove,
2578: .ringbuffer_submitcmd = gen7_ringbuffer_submitcmd,
2579: .power_stats = gen7_power_stats,
2580: .add_to_va_minidump = gen7_gmu_add_to_minidump,
2581: .gx_is_on = gen7_gmu_gx_is_on,
2582: .perfcounter_remove = gen7_perfcounter_remove,
2583: .set_isdb_breakpoint_registers = gen7_set_isdb_breakpoint_registers,
2584: .swfuse_irqctrl = gen7_swfuse_irqctrl,
2585: .get_uche_trap_base = gen7_get_uche_trap_base,
2586: .fault_header = gen7_fault_header,
2587: .acquire_cp_semaphore = gen7_acquire_cp_semaphore,
2588: .release_cp_semaphore = gen7_release_cp_semaphore,
2589: },
2590: .hfi_probe = gen7_gmu_hfi_probe,
2591: .handle_watchdog = gen7_gmu_handle_watchdog,
2592: };
--- FILE: \adreno_gen7.h | HITS: 3 ---
MATCH LINES: 18, 19
6:
7: #ifndef _ADRENO_GEN7_H_
8: #define _ADRENO_GEN7_H_
9:
10: #include <linux/delay.h>
11:
12: #include "gen7_reg.h"
13: #include "adreno_gen7_gmu.h"
14:
15: /* Forward struct declaration */
16: struct gen7_snapshot_block_list;
17:
18: extern const struct adreno_power_ops gen7_gmu_power_ops;
19: extern const struct adreno_power_ops gen7_hwsched_power_ops;
20: extern const struct adreno_perfcounters adreno_gen7_perfcounters;
21: extern const struct adreno_perfcounters adreno_gen7_2_0_perfcounters;
22: extern const struct adreno_perfcounters adreno_gen7_no_cb_perfcounters;
23: extern const struct adreno_perfcounters adreno_gen7_9_0_perfcounters;
24:
25: struct gen7_gpudev {
26: struct adreno_gpudev base;
27: int (*hfi_probe)(struct adreno_device *adreno_dev);
28: void (*hfi_remove)(struct adreno_device *adreno_dev);
29: void (*handle_watchdog)(struct adreno_device *adreno_dev);
30: };
31:
32: extern const struct gen7_gpudev adreno_gen7_gmu_gpudev;
33: extern const struct gen7_gpudev adreno_gen7_hwsched_gpudev;
34: extern const struct gen7_gpudev adreno_gen7_9_0_hwsched_gpudev;
35:
36: /**
37: * struct gen7_device - Container for the gen7_device
38: */
39: struct gen7_device {
40: /** @gmu: Container for the gen7 GMU device */
41: struct gen7_gmu_device gmu;
42: /** @adreno_dev: Container for the generic adreno device */
43: struct adreno_device adreno_dev;
MATCH LINES: 380
368:
369: /**
370: * gen7_spin_idle_debug - Debug logging used when gpu fails to idle
371: * @adreno_dev: An Adreno GPU handle
372: * @str: String describing the failure
373: *
374: * This function logs interesting registers and triggers a snapshot
375: */
376: void gen7_spin_idle_debug(struct adreno_device *adreno_dev,
377: const char *str);
378:
379: /**
380: * gen7_perfcounter_update - Update the IFPC perfcounter list
381: * @adreno_dev: An Adreno GPU handle
382: * @reg: Perfcounter reg struct to add/remove to the list
383: * @update_reg: true if the perfcounter needs to be programmed by the CPU
384: * @pipe: pipe id for CP aperture control
385: * @flags: Flags set for requested perfcounter group
386: *
387: * Return: 0 on success or -EBUSY if the lock couldn't be taken
388: */
389: int gen7_perfcounter_update(struct adreno_device *adreno_dev,
390: struct adreno_perfcount_register *reg, bool update_reg, u32 pipe,
391: unsigned long flags);
392:
393: /*
394: * gen7_ringbuffer_init - Initialize the ringbuffers
395: * @adreno_dev: An Adreno GPU handle
396: *
397: * Initialize the ringbuffer(s) for a5xx.
398: * Return: 0 on success or negative on failure
399: */
400: int gen7_ringbuffer_init(struct adreno_device *adreno_dev);
401:
402: /**
403: * gen7_ringbuffer_submitcmd - Submit a user command to the ringbuffer
404: * @adreno_dev: An Adreno GPU handle
--- FILE: \adreno_gen7_gmu.c | HITS: 34 ---
MATCH LINES: 332
320: _regwrite(gmu->pdc_cfg_base, GEN7_PDC_GPU_ENABLE_PDC,
321: GEN7_PDC_ENABLE_REG_VALUE);
322:
323: if (!IS_ENABLED(CONFIG_QCOM_KGSL_HIBERNATION)) {
324: devm_iounmap(gmu_pdev_dev, gmu->pdc_cfg_base);
325: gmu->pdc_cfg_base = NULL;
326: }
327:
328: return 0;
329: }
330:
331: /* Configure and enable GMU low power mode */
332: static void gen7_gmu_power_config(struct adreno_device *adreno_dev)
333: {
334: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
335:
336: /* Disable GMU WB/RB buffer and caches at boot */
337: gmu_core_regwrite(device, GEN7_GMU_SYS_BUS_CONFIG, 0x1);
338: gmu_core_regwrite(device, GEN7_GMU_ICACHE_CONFIG, 0x1);
339: gmu_core_regwrite(device, GEN7_GMU_DCACHE_CONFIG, 0x1);
340: }
341:
342: static void gmu_ao_sync_event(struct adreno_device *adreno_dev)
343: {
344: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
345: unsigned long flags;
346: u64 ticks;
347:
348: /*
349: * Get the GMU always on ticks and log it in a trace message. This
350: * will be used to map GMU ticks to ftrace time. Do this in atomic
351: * context to ensure nothing happens between reading the always
352: * on ticks and doing the trace.
353: */
354:
355: local_irq_save(flags);
356:
MATCH LINES: 764, 765, 789, 793, 805, 809, 817, 831
752: static bool gen7_gmu_rpmh_pwr_state_is_active(struct kgsl_device *device)
753: {
754: u32 val;
755:
756: gmu_core_regread(device, GEN7_GPU_GMU_CX_GMU_RPMH_POWER_STATE, &val);
757: return (val == GPU_HW_ACTIVE) ? true : false;
758: }
759:
760: static const char *idle_level_name(int level)
761: {
762: if (level == GPU_HW_ACTIVE)
763: return "GPU_HW_ACTIVE";
764: else if (level == GPU_HW_IFPC)
765: return "GPU_HW_IFPC";
766:
767: return "(Unknown)";
768: }
769:
770: int gen7_gmu_wait_for_lowest_idle(struct adreno_device *adreno_dev)
771: {
772: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
773: struct device *gmu_pdev_dev = GMU_PDEV_DEV(device);
774: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
775: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
776: u32 reg, reg1, reg2, reg3, reg4;
777: unsigned long t;
778: u64 ts1, ts2;
779:
780: ts1 = gpudev->read_alwayson(adreno_dev);
781:
782: t = jiffies + msecs_to_jiffies(100);
783: do {
784: gmu_core_regread(device,
785: GEN7_GPU_GMU_CX_GMU_RPMH_POWER_STATE, ®);
786: gmu_core_regread(device, GEN7_GMU_GFX_PWR_CLK_STATUS, ®1);
787:
788: /*
789: * Check that we are at lowest level. If lowest level is IFPC
790: * double check that GFX clock is off.
791: */
792: if (gmu->idle_level == reg)
793: if (!(gmu->idle_level == GPU_HW_IFPC && is_on(reg1)))
794: return 0;
795:
796: /* Wait 100us to reduce unnecessary AHB bus traffic */
797: usleep_range(10, 100);
798: } while (!time_after(jiffies, t));
799:
800: /* Check one last time */
801: gmu_core_regread(device, GEN7_GPU_GMU_CX_GMU_RPMH_POWER_STATE, ®);
802: gmu_core_regread(device, GEN7_GMU_GFX_PWR_CLK_STATUS, ®1);
803:
804: /*
805: * Check that we are at lowest level. If lowest level is IFPC
806: * double check that GFX clock is off.
807: */
808: if (gmu->idle_level == reg)
809: if (!(gmu->idle_level == GPU_HW_IFPC && is_on(reg1)))
810: return 0;
811:
812: ts2 = gpudev->read_alwayson(adreno_dev);
813:
814: /* Collect abort data to help with debugging */
815: gmu_core_regread(device, GEN7_GPU_GMU_AO_GPU_CX_BUSY_STATUS, ®2);
816: gmu_core_regread(device, GEN7_GMU_RBBM_INT_UNMASKED_STATUS, ®3);
817: gmu_core_regread(device, GEN7_GMU_GMU_PWR_COL_KEEPALIVE, ®4);
818:
819: dev_err(gmu_pdev_dev,
820: "----------------------[ GMU error ]----------------------\n");
821: dev_err(gmu_pdev_dev,
822: "Timeout waiting for lowest idle level %s\n",
823: idle_level_name(gmu->idle_level));
824: dev_err(gmu_pdev_dev, "Start: %llx (absolute ticks)\n", ts1);
825: dev_err(gmu_pdev_dev,
826: "Poll: %llx (ticks relative to start)\n", ts2-ts1);
827: dev_err(gmu_pdev_dev,
828: "RPMH_POWER_STATE=%x GFX_PWR_CLK_STATUS=%x\n", reg, reg1);
829: dev_err(gmu_pdev_dev, "CX_BUSY_STATUS=%x\n", reg2);
830: dev_err(gmu_pdev_dev,
831: "RBBM_INT_UNMASKED_STATUS=%x PWR_COL_KEEPALIVE=%x\n", reg3, reg4);
832:
833: /* Access GX registers only when GX is ON */
834: if (is_on(reg1)) {
835: kgsl_regread(device, GEN7_CP_STATUS_1, ®2);
836: kgsl_regread(device, GEN7_CP_CP2GMU_STATUS, ®3);
837: kgsl_regread(device, GEN7_CP_CONTEXT_SWITCH_CNTL, ®4);
838:
839: dev_err(gmu_pdev_dev, "GEN7_CP_STATUS_1=%x\n", reg2);
840: dev_err(gmu_pdev_dev,
841: "CP2GMU_STATUS=%x CONTEXT_SWITCH_CNTL=%x\n", reg3, reg4);
842: }
843:
844: WARN_ON(1);
845: gmu_core_fault_snapshot(device, GMU_FAULT_WAIT_FOR_LOWEST_IDLE);
846: return -ETIMEDOUT;
847: }
848:
849: /* Bitmask for GPU idle status check */
850: #define CXGXCPUBUSYIGNAHB BIT(30)
851: int gen7_gmu_wait_for_idle(struct adreno_device *adreno_dev)
852: {
853: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
854: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
855: u32 status2;
MATCH LINES: 998, 1009
986: else if (adreno_gmu_chipid_based(adreno_dev))
987: val = ADRENO_GMU_CHIPID(adreno_dev->chipid);
988: else
989: val = ADRENO_GMU_REV(ADRENO_GPUREV(adreno_dev));
990: gmu_core_regwrite(device, GEN7_GMU_GENERAL_10, val);
991:
992: /* Log size is encoded in (number of 4K units - 1) */
993: val = (gmu->gmu_log->gmuaddr & GENMASK(31, 12)) |
994: ((GMU_LOG_SIZE/SZ_4K - 1) & GENMASK(7, 0));
995: gmu_core_regwrite(device, GEN7_GMU_GENERAL_8, val);
996:
997: /* Configure power control and bring the GMU out of reset */
998: gen7_gmu_power_config(adreno_dev);
999:
1000: /*
1001: * Enable BCL throttling -
1002: * XOCLK1: countable: 0x13 (25% throttle)
1003: * XOCLK2: countable: 0x17 (58% throttle)
1004: * XOCLK3: countable: 0x19 (75% throttle)
1005: * POWER_CONTROL_SELECT_0 controls counters 0 - 3, each selector
1006: * is 8 bits wide.
1007: */
1008: if (adreno_dev->bcl_enabled)
1009: gmu_core_regrmw(device, GEN7_GMU_CX_GMU_POWER_COUNTER_SELECT_0,
1010: 0xffffff00, FIELD_PREP(GENMASK(31, 24), 0x19) |
1011: FIELD_PREP(GENMASK(23, 16), 0x17) |
1012: FIELD_PREP(GENMASK(15, 8), 0x13));
1013: }
1014:
1015: int gen7_gmu_parse_fw(struct adreno_device *adreno_dev)
1016: {
1017: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
1018: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
1019: const struct adreno_gen7_core *gen7_core = to_gen7_core(adreno_dev);
1020: struct gmu_block_header *blk;
1021: int ret, offset = 0;
1022: const char *gmufw_name = gen7_core->gmufw_name;
1023:
1024: /*
1025: * If GMU fw already saved and verified, do nothing new.
1026: * Skip only requesting firmware and allow preallocation to
1027: * ensure in scenario where GMU request firmware succeeded
1028: * but preallocation fails, we don't return early without
1029: * successful preallocations on next open call.
1030: */
1031: if (!gmu->fw_image) {
1032:
1033: if (gen7_core->gmufw_name == NULL)
MATCH LINES: 1181, 1184
1169: if (gen7_gmu_gx_is_on(adreno_dev))
1170: _do_gbif_halt(device, GEN7_RBBM_GBIF_HALT,
1171: GEN7_RBBM_GBIF_HALT_ACK,
1172: GEN7_GBIF_GX_HALT_MASK,
1173: "GX");
1174:
1175: /* Halt CX traffic */
1176: _do_gbif_halt(device, GEN7_GBIF_HALT, GEN7_GBIF_HALT_ACK,
1177: GEN7_GBIF_ARB_HALT_MASK, "CX");
1178:
1179: /*
1180: * GX_CXO_CLK is needed to access RBBM_SW_RESET_CMD register. There are
1181: * scenarios where the IFPC exit sequence is still in progress, and the
1182: * above clock may not be enabled. This situation leads to unclocked
1183: * access. Thus, trigger RBBM_SW_RESET_CMD only when GPU is fully active
1184: * i.e., IFPC sequence is completed.
1185: */
1186: if (gen7_gmu_gx_is_on(adreno_dev) && gen7_gmu_rpmh_pwr_state_is_active(device))
1187: kgsl_regwrite(device, GEN7_RBBM_SW_RESET_CMD, 0x1);
1188:
1189: /* Make sure above writes are posted before turning off power resources */
1190: wmb();
1191:
1192: /* Allow the software reset to complete */
1193: udelay(100);
1194:
1195: /*
1196: * This is based on the assumption that GMU is the only one controlling
1197: * the GX HS. This code path is the only client voting for GX from linux
1198: * kernel.
1199: */
1200: if (!gen7_gmu_gx_is_on(adreno_dev))
1201: return;
1202:
1203: /*
1204: * Switch gx gdsc control from GMU to CPU force non-zero reference
1205: * count in clk driver so next disable call will turn off the GDSC
1206: */
1207: kgsl_pwrctrl_enable_gx_gdsc(device);
1208: kgsl_pwrctrl_disable_gx_gdsc(device);
MATCH LINES: 1223, 1235
1211: dev_err(GMU_PDEV_DEV(device), "gx is stuck on\n");
1212: }
1213:
1214: /*
1215: * gen7_gmu_notify_slumber() - initiate request to GMU to prepare to slumber
1216: * @device: Pointer to KGSL device
1217: */
1218: static int gen7_gmu_notify_slumber(struct adreno_device *adreno_dev)
1219: {
1220: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1221: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1222: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
1223: int bus_level = pwr->pwrlevels[pwr->default_pwrlevel].bus_freq;
1224: int perf_idx = gmu->dcvs_table.gpu_level_num -
1225: pwr->default_pwrlevel - 1;
1226: struct hfi_prep_slumber_cmd req = {
1227: .freq = perf_idx,
1228: .bw = bus_level,
1229: };
1230: int ret;
1231:
1232: req.bw |= adreno_gmu_bus_ab_quantize(adreno_dev, 0);
1233:
1234: /* Disable the power counter so that the GMU is not busy */
1235: gmu_core_regwrite(device, GEN7_GMU_CX_GMU_POWER_COUNTER_ENABLE, 0);
1236:
1237: ret = CMD_MSG_HDR(req, H2F_MSG_PREPARE_SLUMBER);
1238: if (ret)
1239: return ret;
1240:
1241: ret = gen7_hfi_send_generic_req(adreno_dev, &req, sizeof(req));
1242:
1243: /* Make sure the fence is in ALLOW mode */
1244: gmu_core_regwrite(device, GEN7_GMU_AO_AHB_FENCE_CTRL, 0);
1245:
1246: /*
1247: * GEMNOC can enter power collapse state during GPU power down sequence.
1248: * This could abort CX GDSC collapse. Assert Qactive to avoid this.
1249: */
1250: gmu_core_regwrite(device, GEN7_GPU_GMU_CX_GMU_CX_FALNEXT_INTF, 0x1);
1251:
1252: return ret;
1253: }
1254:
1255: void gen7_gmu_suspend(struct adreno_device *adreno_dev, bool force)
1256: {
1257: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1258:
1259: if (!force && test_bit(ADRENO_DEVICE_RESET_RECOVERY, &adreno_dev->priv))
MATCH LINES: 1339, 1346, 1350, 1362, 1366
1327:
1328: if (req.freq != INVALID_DCVS_IDX)
1329: gmu_core_rdpm_mx_freq_update(device, table->gx_votes[req.freq].freq);
1330:
1331: return ret;
1332: }
1333:
1334: static int gen7_gmu_clock_set(struct adreno_device *adreno_dev, u32 pwrlevel)
1335: {
1336: return gen7_gmu_dcvs_set(adreno_dev, pwrlevel, INVALID_DCVS_IDX, INVALID_AB_VALUE);
1337: }
1338:
1339: static int gen7_gmu_ifpc_store(struct kgsl_device *device,
1340: unsigned int val)
1341: {
1342: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
1343: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
1344: unsigned int requested_idle_level;
1345:
1346: if (!ADRENO_FEATURE(adreno_dev, ADRENO_IFPC))
1347: return -EINVAL;
1348:
1349: if (val)
1350: requested_idle_level = GPU_HW_IFPC;
1351: else
1352: requested_idle_level = GPU_HW_ACTIVE;
1353:
1354: if (gmu->idle_level == requested_idle_level)
1355: return 0;
1356:
1357: /* Power down the GPU before changing the idle level */
1358: return adreno_power_cycle_u32(adreno_dev, &gmu->idle_level,
1359: requested_idle_level);
1360: }
1361:
1362: static unsigned int gen7_gmu_ifpc_isenabled(struct kgsl_device *device)
1363: {
1364: struct gen7_gmu_device *gmu = to_gen7_gmu(ADRENO_DEVICE(device));
1365:
1366: return gmu->idle_level == GPU_HW_IFPC;
1367: }
1368:
1369: /* Send an NMI to the GMU */
1370: void gen7_gmu_send_nmi(struct kgsl_device *device, bool force,
1371: enum gmu_fault_panic_policy gf_policy)
1372: {
1373: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
1374: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
1375: u64 ticks = gpudev->read_alwayson(adreno_dev);
1376: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
1377: u32 result;
1378:
1379: /*
1380: * Do not send NMI if the SMMU is stalled because GMU will not be able
1381: * to save cm3 state to DDR.
1382: */
1383: if (gen7_gmu_gx_is_on(adreno_dev) && adreno_smmu_is_stalled(adreno_dev)) {
1384: dev_err(GMU_PDEV_DEV(device),
1385: "Skipping NMI because SMMU is stalled\n");
1386: goto done;
1387: }
1388:
1389: if (force)
1390: goto nmi;
MATCH LINES: 1868, 1869
1856: case 1:
1857: return ((u64) FIELD_GET(BCL_SID1_MASK, adreno_dev->bcl_data));
1858: case 2:
1859: return ((u64) FIELD_GET(BCL_SID2_MASK, adreno_dev->bcl_data));
1860: default:
1861: return 0;
1862: }
1863: }
1864:
1865: static const struct gmu_dev_ops gen7_gmudev = {
1866: .oob_set = gen7_gmu_oob_set,
1867: .oob_clear = gen7_gmu_oob_clear,
1868: .ifpc_store = gen7_gmu_ifpc_store,
1869: .ifpc_isenabled = gen7_gmu_ifpc_isenabled,
1870: .cooperative_reset = gen7_gmu_cooperative_reset,
1871: .wait_for_active_transition = gen7_gmu_wait_for_active_transition,
1872: .scales_bandwidth = gen7_gmu_scales_bandwidth,
1873: .acd_set = gen7_gmu_acd_set,
1874: .bcl_sid_set = gen7_bcl_sid_set,
1875: .bcl_sid_get = gen7_bcl_sid_get,
1876: .send_nmi = gen7_gmu_send_nmi,
1877: #if IS_ENABLED(CONFIG_QCOM_KGSL_HIBERNATION)
1878: .force_first_boot = gen7_gmu_force_first_boot,
1879: #endif
1880: };
1881:
1882: static int gen7_gmu_bus_set(struct adreno_device *adreno_dev, int buslevel,
1883: u32 ab)
1884: {
1885: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1886: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1887: int ret = 0;
1888:
1889: /* Target gen7_9_x votes for perfmode through ACV. Skip icc path for same */
1890: if (!adreno_is_gen7_9_x(adreno_dev))
1891: kgsl_icc_set_tag(pwr, buslevel);
1892:
1893: if (buslevel == pwr->cur_buslevel)
MATCH LINES: 2053, 2054, 2056, 2057
2041: if (gmu->fw_image)
2042: release_firmware(gmu->fw_image);
2043:
2044: gmu_core_free_globals(device);
2045:
2046: vfree(gmu->itcm_shadow);
2047: if (gmu->log_kobj.state_initialized)
2048: kobject_put(&gmu->log_kobj);
2049: if (gmu->stats_kobj.state_initialized)
2050: kobject_put(&gmu->stats_kobj);
2051: }
2052:
2053: /* Default IFPC timer (300usec) value */
2054: #define GEN7_GMU_LONG_IFPC_HYST FIELD_PREP(GENMASK(15, 0), 0x1680)
2055:
2056: /* Minimum IFPC timer (200usec) allowed to override default value */
2057: #define GEN7_GMU_LONG_IFPC_HYST_FLOOR FIELD_PREP(GENMASK(15, 0), 0x0F00)
2058:
2059: /* Offsets into the MX/CX mapped register regions */
2060: #define GEN7_RDPM_MX_OFFSET 0xf00
2061: #define GEN7_RDPM_CX_OFFSET 0xf14
2062:
2063: int gen7_gmu_probe(struct kgsl_device *device,
2064: struct platform_device *pdev)
2065: {
2066: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
2067: const struct adreno_gen7_core *gen7_core = to_gen7_core(adreno_dev);
2068: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
2069: struct device *dev = &pdev->dev;
2070: u64 freq = gen7_core->gmu_hub_clk_freq;
2071: struct resource *res;
2072: int ret, i;
2073:
2074: adreno_dev->gmu_hub_clk_freq = freq ? freq : 150000000;
2075:
2076: device->gmu_core.pdev = pdev;
2077:
2078: dma_coerce_mask_and_coherent(&device->gmu_core.pdev->dev, DMA_BIT_MASK(64));
2079: set_dma_ops(GMU_PDEV_DEV(device), NULL);
2080:
2081: /* In standard device tree bindings, rscc range is part of GMU pdev */
MATCH LINES: 2143, 2144, 2145, 2146
2131: if (ret)
2132: goto error;
2133:
2134: if (ADRENO_FEATURE(adreno_dev, ADRENO_GMU_AB))
2135: adreno_dev->gmu_ab = true;
2136:
2137: /* Populates RPMh configurations */
2138: ret = gen7_build_rpmh_tables(adreno_dev);
2139: if (ret)
2140: goto error;
2141:
2142: /* Set up GMU idle state */
2143: if (ADRENO_FEATURE(adreno_dev, ADRENO_IFPC)) {
2144: gmu->idle_level = GPU_HW_IFPC;
2145: adreno_dev->ifpc_hyst = GEN7_GMU_LONG_IFPC_HYST;
2146: adreno_dev->ifpc_hyst_floor = GEN7_GMU_LONG_IFPC_HYST_FLOOR;
2147: } else {
2148: gmu->idle_level = GPU_HW_ACTIVE;
2149: }
2150:
2151: ret = gen7_gmu_acd_probe(device, gmu, pdev->dev.of_node);
2152: if (ret)
2153: goto error;
2154:
2155: set_bit(GMU_ENABLED, &device->gmu_core.flags);
2156:
2157: device->gmu_core.dev_ops = &gen7_gmudev;
2158:
2159: /* Set default GMU attributes */
2160: gmu->log_stream_enable = false;
2161: gmu->log_group_mask = 0x3;
2162:
2163: /* Initialize to zero to detect trace packet loss */
2164: device->gmu_core.trace.seq_num = 0;
2165:
2166: /* Disabled by default */
2167: gmu->stats_enable = false;
2168: /* Set default to CM3 busy cycles countable */
2169: gmu->stats_mask = BIT(GEN7_GMU_CM3_BUSY_CYCLES);
2170: /* Interval is in 50 us units. Set default sampling frequency to 4x50 us */
MATCH LINES: 2218
2206:
2207: /* Halt all AXI requests */
2208: kgsl_regwrite(device, GEN7_GBIF_HALT, GEN7_GBIF_ARB_HALT_MASK);
2209: ret = adreno_wait_for_halt_ack(device,
2210: GEN7_GBIF_HALT_ACK, GEN7_GBIF_ARB_HALT_MASK);
2211:
2212: /* De-assert the halts */
2213: kgsl_regwrite(device, GEN7_GBIF_HALT, 0x0);
2214:
2215: return ret;
2216: }
2217:
2218: static int gen7_gmu_power_off(struct adreno_device *adreno_dev)
2219: {
2220: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
2221: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2222: int ret = 0;
2223:
2224: if (device->gmu_fault)
2225: goto error;
2226:
2227: /* Wait for the lowest idle level we requested */
2228: ret = gen7_gmu_wait_for_lowest_idle(adreno_dev);
2229: if (ret)
2230: goto error;
2231:
2232: ret = gen7_complete_rpmh_votes(gmu, 2);
2233: if (ret)
2234: goto error;
2235:
2236: ret = gen7_gmu_notify_slumber(adreno_dev);
2237: if (ret)
2238: goto error;
2239:
2240: ret = gen7_gmu_wait_for_idle(adreno_dev);
2241: if (ret)
2242: goto error;
MATCH LINES: 2361
2349: adreno_dispatcher_start(device);
2350:
2351: device->reset_counter++;
2352:
2353: gen7_gmu_oob_clear(device, oob_gpu);
2354:
2355: return 0;
2356:
2357: oob_clear:
2358: gen7_gmu_oob_clear(device, oob_gpu);
2359:
2360: err:
2361: gen7_gmu_power_off(adreno_dev);
2362:
2363: return ret;
2364: }
2365:
2366: static void gmu_idle_timer(struct timer_list *t)
2367: {
2368: struct kgsl_device *device = container_of(t, struct kgsl_device,
2369: idle_timer);
2370:
2371: kgsl_schedule_work(&device->idle_check_ws);
2372: }
2373:
2374: static int gen7_boot(struct adreno_device *adreno_dev)
2375: {
2376: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
2377: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2378: bool bcl_state = adreno_dev->bcl_enabled;
2379: int ret;
2380:
2381: if (WARN_ON(test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)))
2382: return 0;
2383:
2384: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE);
2385:
MATCH LINES: 2553
2541: kgsl_pwrscale_update_stats(device);
2542:
2543: /* Save active coresight registers if applicable */
2544: adreno_coresight_stop(adreno_dev);
2545:
2546: adreno_irqctrl(adreno_dev, 0);
2547:
2548: no_gx_power:
2549: gen7_gmu_oob_clear(device, oob_gpu);
2550:
2551: kgsl_pwrctrl_irq(device, false);
2552:
2553: gen7_gmu_power_off(adreno_dev);
2554:
2555: adreno_set_active_ctxs_null(adreno_dev);
2556:
2557: adreno_dispatcher_stop(adreno_dev);
2558:
2559: adreno_ringbuffer_stop(adreno_dev);
2560:
2561: adreno_llcc_slice_deactivate(adreno_dev);
2562:
2563: clear_bit(GMU_PRIV_GPU_STARTED, &gmu->flags);
2564:
2565: kgsl_delete_timer_sync(&device->idle_timer);
2566:
2567: kgsl_pwrscale_sleep(device);
2568:
2569: kgsl_pwrctrl_clear_l3_vote(device);
2570:
2571: /*
2572: * Reset the context records so that CP can start
2573: * at the correct read pointer for BV thread after
2574: * coming out of slumber.
2575: */
2576: gen7_reset_preempt_records(adreno_dev);
2577:
MATCH LINES: 2777
2765:
2766: done:
2767: /*
2768: * When waking up from a touch event we want to stay active long enough
2769: * for the user to send a draw command. The default idle timer timeout
2770: * is shorter than we want so go ahead and push the idle timer out
2771: * further for this special case
2772: */
2773: mod_timer(&device->idle_timer, jiffies +
2774: msecs_to_jiffies(adreno_wake_timeout));
2775: }
2776:
2777: const struct adreno_power_ops gen7_gmu_power_ops = {
2778: .first_open = gen7_gmu_first_open,
2779: .last_close = gen7_gmu_last_close,
2780: .active_count_get = gen7_gmu_active_count_get,
2781: .pm_suspend = gen7_gmu_pm_suspend,
2782: .pm_resume = gen7_gmu_pm_resume,
2783: .touch_wakeup = gen7_gmu_touch_wakeup,
2784: .gpu_clock_set = gen7_gmu_clock_set,
2785: .gpu_bus_set = gen7_gmu_bus_set,
2786: };
2787:
2788: int gen7_gmu_device_probe(struct platform_device *pdev,
2789: u32 chipid, const struct adreno_gpu_core *gpucore)
2790: {
2791: struct adreno_device *adreno_dev;
2792: struct kgsl_device *device;
2793: struct gen7_device *gen7_dev;
2794: int ret;
2795:
2796: gen7_dev = devm_kzalloc(&pdev->dev, sizeof(*gen7_dev),
2797: GFP_KERNEL);
2798: if (!gen7_dev)
2799: return -ENOMEM;
2800:
2801: adreno_dev = &gen7_dev->adreno_dev;
--- FILE: \adreno_gen7_gmu.h | HITS: 2 ---
MATCH LINES: 285, 288
273:
274: /**
275: * gen7_gmu_oob_clear - clear an asserted oob request
276: * @device: Pointer to the kgsl device
277: * @req: Type of oob request as defined in enum oob_request
278: *
279: * Clear a previously requested oob so that gmu can power
280: * collapse the gpu
281: */
282: void gen7_gmu_oob_clear(struct kgsl_device *device, enum oob_request oob);
283:
284: /**
285: * gen7_gmu_wait_for_lowest_idle - wait for gmu to complete ifpc
286: * @adreno_dev: Pointer to the adreno device
287: *
288: * If ifpc is enabled, wait for gmu to put gpu into ifpc.
289: *
290: * Return: 0 on success or negative error on failure
291: */
292: int gen7_gmu_wait_for_lowest_idle(struct adreno_device *adreno_dev);
293:
294: /**
295: * gen7_gmu_wait_for_idle - Wait for gmu to become idle
296: * @adreno_dev: Pointer to the adreno device
297: *
298: * Return: 0 on success or negative error on failure
299: */
300: int gen7_gmu_wait_for_idle(struct adreno_device *adreno_dev);
301:
302: /**
303: * gen7_rscc_sleep_sequence - Trigger rscc sleep sequence
304: * @adreno_dev: Pointer to the adreno device
305: *
306: * Return: 0 on success or negative error on failure
307: */
308: int gen7_rscc_sleep_sequence(struct adreno_device *adreno_dev);
309:
310: /**
311: * gen7_rscc_wakeup_sequence - Trigger rscc wakeup sequence
312: * @adreno_dev: Pointer to the adreno device
--- FILE: \adreno_gen7_hfi.c | HITS: 4 ---
MATCH LINES: 626, 630, 632
614: ret = gen7_hfi_send_generic_req(adreno_dev,
615: &gmu->hfi.acd_table, sizeof(gmu->hfi.acd_table));
616: if (ret)
617: return ret;
618:
619: gen7_hfi_send_set_value(adreno_dev, HFI_VALUE_LOG_EVENT_ON,
620: EVENT_PWR_ACD_THROTTLE_PROF, 0);
621: }
622:
623: return 0;
624: }
625:
626: int gen7_hfi_send_ifpc_feature_ctrl(struct adreno_device *adreno_dev)
627: {
628: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
629:
630: if (gmu->idle_level == GPU_HW_IFPC)
631: return gen7_hfi_send_feature_ctrl(adreno_dev,
632: HFI_FEATURE_IFPC, 1, adreno_dev->ifpc_hyst);
633: return 0;
634: }
635:
636: static void reset_hfi_queues(struct adreno_device *adreno_dev)
637: {
638: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
639: struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
640: struct hfi_queue_table *tbl = mem_addr->hostptr;
641: struct hfi_queue_header *hdr;
642: unsigned int i;
643:
644: /* Flush HFI queues */
645: for (i = 0; i < HFI_QUEUE_MAX; i++) {
646: hdr = &tbl->qhdr[i];
647: if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
648: continue;
649:
650: hdr->read_index = hdr->write_index;
651: }
652: }
653:
654: /* Fill the entry and return the dword count written */
655: static u32 _fill_table_entry(struct hfi_table_entry *entry, u32 count,
656: u32 stride_bytes, u32 *data)
MATCH LINES: 766
754: result = gen7_hfi_send_acd_feature_ctrl(adreno_dev);
755: if (result)
756: goto err;
757:
758: result = gen7_hfi_send_bcl_feature_ctrl(adreno_dev);
759: if (result)
760: goto err;
761:
762: result = gen7_hfi_send_clx_feature_ctrl(adreno_dev);
763: if (result)
764: goto err;
765:
766: result = gen7_hfi_send_ifpc_feature_ctrl(adreno_dev);
767: if (result)
768: goto err;
769:
770: result = gen7_hfi_send_core_fw_start(adreno_dev);
771: if (result)
772: goto err;
773:
774: set_bit(GMU_PRIV_HFI_STARTED, &gmu->flags);
775:
776: result = kgsl_pwrctrl_setup_default_votes(device);
777:
778: err:
779: if (result)
780: gen7_hfi_stop(adreno_dev);
781:
782: return result;
783:
784: }
785:
786: void gen7_hfi_stop(struct adreno_device *adreno_dev)
787: {
788: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
789: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
790:
--- FILE: \adreno_gen7_hfi.h | HITS: 2 ---
MATCH LINES: 195, 200
183: */
184: int gen7_hfi_send_bcl_feature_ctrl(struct adreno_device *adreno_dev);
185:
186: /**
187: * gen7_hfi_send_clx_feature_ctrl - Send the clx feature hfi packet
188: * @adreno_dev: Pointer to the adreno device
189: *
190: * Return: 0 on success or negative error on failure
191: */
192: int gen7_hfi_send_clx_feature_ctrl(struct adreno_device *adreno_dev);
193:
194: /**
195: * gen7_hfi_send_ifpc_feature_ctrl - Send the ipfc feature hfi packet
196: * @adreno_dev: Pointer to the adreno device
197: *
198: * Return: 0 on success or negative error on failure
199: */
200: int gen7_hfi_send_ifpc_feature_ctrl(struct adreno_device *adreno_dev);
201:
202: /**
203: * gen7_hfi_send_gpu_perf_table - Send the gpu perf table hfi packet
204: * @adreno_dev: Pointer to the adreno device
205: *
206: * Return: 0 on success or negative error on failure
207: */
208: int gen7_hfi_send_gpu_perf_table(struct adreno_device *adreno_dev);
209:
210: /*
211: * gen7_hfi_process_queue - Check hfi queue for messages from gmu
212: * @gmu: Pointer to the gen7 gmu device
213: * @queue_idx: queue id to be processed
214: * @ret_cmd: Container for data needed for waiting for the ack
215: *
216: * Return: 0 on success or negative error on failure
217: */
218: int gen7_hfi_process_queue(struct gen7_gmu_device *gmu,
219: u32 queue_idx, struct pending_cmd *ret_cmd);
220:
221: /**
222: * gen7_hfi_cmdq_write - Write a command to command queue
223: * @adreno_dev: Pointer to the adreno device
224: * @msg: Data to be written to the queue
--- FILE: \adreno_gen7_hwsched.c | HITS: 6 ---
MATCH LINES: 384, 388, 400
372: {
373: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
374: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
375: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
376: struct hfi_prep_slumber_cmd req;
377: int ret;
378:
379: ret = CMD_MSG_HDR(req, H2F_MSG_PREPARE_SLUMBER);
380: if (ret)
381: return ret;
382:
383: req.freq = gmu->dcvs_table.gpu_level_num - pwr->default_pwrlevel - 1;
384: req.bw = pwr->pwrlevels[pwr->default_pwrlevel].bus_freq;
385:
386: req.bw |= adreno_gmu_bus_ab_quantize(adreno_dev, 0);
387: /* Disable the power counter so that the GMU is not busy */
388: gmu_core_regwrite(device, GEN7_GMU_CX_GMU_POWER_COUNTER_ENABLE, 0);
389:
390: ret = gen7_hfi_send_cmd_async(adreno_dev, &req, sizeof(req));
391:
392: /*
393: * GEMNOC can enter power collapse state during GPU power down sequence.
394: * This could abort CX GDSC collapse. Assert Qactive to avoid this.
395: */
396: gmu_core_regwrite(device, GEN7_GPU_GMU_CX_GMU_CX_FALNEXT_INTF, 0x1);
397:
398: return ret;
399: }
400: static int gen7_hwsched_gmu_power_off(struct adreno_device *adreno_dev)
401: {
402: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
403: int ret = 0;
404:
405: if (device->gmu_fault)
406: goto error;
407:
408: /* Wait for the lowest idle level we requested */
409: ret = gen7_gmu_wait_for_lowest_idle(adreno_dev);
410: if (ret)
411: goto error;
412:
413: ret = gen7_hwsched_notify_slumber(adreno_dev);
414: if (ret)
415: goto error;
416:
417: ret = gen7_gmu_wait_for_idle(adreno_dev);
418: if (ret)
419: goto error;
420:
421: ret = gen7_rscc_sleep_sequence(adreno_dev);
422:
423: gmu_core_rdpm_mx_freq_update(device, 0);
424:
MATCH LINES: 538
526: device->reset_counter++;
527:
528: /*
529: * If warmboot is enabled and we switched a sysfs node, we will do a coldboot
530: * in the subseqent slumber exit. Once that is done we need to mark this bool
531: * as false so that in the next run we can do warmboot
532: */
533: clear_bit(GMU_FORCE_COLDBOOT, &device->gmu_core.flags);
534: err:
535: gen7_gmu_oob_clear(device, oob_gpu);
536:
537: if (ret)
538: gen7_hwsched_gmu_power_off(adreno_dev);
539:
540: return ret;
541: }
542:
543: static void hwsched_idle_timer(struct timer_list *t)
544: {
545: struct kgsl_device *device = container_of(t, struct kgsl_device,
546: idle_timer);
547:
548: kgsl_schedule_work(&device->idle_check_ws);
549: }
550:
551: static int gen7_gmu_warmboot_init(struct adreno_device *adreno_dev)
552: {
553: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
554: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
555: int ret = 0;
556:
557: if (!ADRENO_FEATURE(adreno_dev, ADRENO_GMU_WARMBOOT))
558: return ret;
559:
560: if (IS_ERR_OR_NULL(gmu->gmu_init_scratch)) {
561: gmu->gmu_init_scratch = gmu_core_reserve_kernel_block(device, 0,
562: SZ_4K, GMU_CACHE, 0);
MATCH LINES: 887
875:
876: adreno_irqctrl(adreno_dev, 0);
877:
878: gen7_gmu_oob_clear(device, oob_gpu);
879:
880: no_gx_power:
881: kgsl_pwrctrl_irq(device, false);
882:
883: /* Make sure GMU has sent all hardware fences to TxQueue */
884: if (check_inflight_hw_fences(adreno_dev))
885: drain_cpu = true;
886:
887: gen7_hwsched_gmu_power_off(adreno_dev);
888:
889: /* Now that we are sure that GMU is powered off, drain pending fences */
890: if (drain_cpu)
891: drain_hw_fences_cpu(adreno_dev);
892:
893: adreno_hwsched_unregister_contexts(adreno_dev);
894:
895: adreno_llcc_slice_deactivate(adreno_dev);
896:
897: clear_bit(GMU_PRIV_GPU_STARTED, &gmu->flags);
898:
899: kgsl_delete_timer_sync(&device->idle_timer);
900:
901: kgsl_pwrscale_sleep(device);
902:
903: kgsl_pwrctrl_clear_l3_vote(device);
904:
905: kgsl_pwrctrl_set_state(device, KGSL_STATE_SLUMBER);
906:
907: return ret;
908: }
909:
910: static void check_hw_fence_unack_count(struct adreno_device *adreno_dev)
911: {
MATCH LINES: 1536
1524:
1525: if (device->state != KGSL_STATE_ACTIVE)
1526: return;
1527:
1528: /* If GMU is up, send the constraint to GMU */
1529: ret = gen7_hwsched_hfi_set_value(adreno_dev, HFI_VALUE_MAX_GPU_THERMAL_INDEX, 0,
1530: (pwr->num_pwrlevels - pwr->thermal_pwrlevel));
1531: if (ret)
1532: dev_err(GMU_PDEV_DEV(device), "Failed to set thermal level %u, ret: %d\n",
1533: pwr->thermal_pwrlevel, ret);
1534: }
1535:
1536: const struct adreno_power_ops gen7_hwsched_power_ops = {
1537: .first_open = gen7_hwsched_first_open,
1538: .last_close = gen7_hwsched_power_off,
1539: .active_count_get = gen7_hwsched_active_count_get,
1540: .touch_wakeup = gen7_hwsched_touch_wakeup,
1541: .pm_suspend = gen7_hwsched_pm_suspend,
1542: .pm_resume = gen7_hwsched_pm_resume,
1543: .gpu_clock_set = gen7_hwsched_clock_set,
1544: .gpu_bus_set = gen7_hwsched_bus_set,
1545: .set_thermal_index = gen7_hwsched_set_thermal_index,
1546: };
1547:
1548: const struct adreno_hwsched_ops gen7_hwsched_ops = {
1549: .submit_drawobj = gen7_hwsched_submit_drawobj,
1550: .preempt_count = gen7_hwsched_preempt_count_get,
1551: .create_hw_fence = gen7_hwsched_create_hw_fence,
1552: };
1553:
1554: int gen7_hwsched_probe(struct platform_device *pdev,
1555: u32 chipid, const struct adreno_gpu_core *gpucore)
1556: {
1557: struct adreno_device *adreno_dev;
1558: struct kgsl_device *device;
1559: struct gen7_hwsched_device *gen7_hwsched_dev;
1560: int ret;
--- FILE: \adreno_gen7_hwsched_hfi.c | HITS: 1 ---
MATCH LINES: 2166
2154: ret = gen7_hfi_send_acd_feature_ctrl(adreno_dev);
2155: if (ret)
2156: goto err;
2157:
2158: ret = gen7_hfi_send_bcl_feature_ctrl(adreno_dev);
2159: if (ret)
2160: goto err;
2161:
2162: ret = gen7_hfi_send_clx_feature_ctrl(adreno_dev);
2163: if (ret)
2164: goto err;
2165:
2166: ret = gen7_hfi_send_ifpc_feature_ctrl(adreno_dev);
2167: if (ret)
2168: goto err;
2169:
2170: ret = gen7_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_HWSCHED, 1, 0);
2171: if (ret)
2172: goto err;
2173:
2174: ret = gen7_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_KPROF, 1, 0);
2175: if (ret)
2176: goto err;
2177:
2178: if (ADRENO_FEATURE(adreno_dev, ADRENO_LSR)) {
2179: ret = gen7_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_LSR,
2180: 1, 0);
2181: if (ret)
2182: goto err;
2183: }
2184:
2185: ret = gen7_hfi_send_perfcounter_feature_ctrl(adreno_dev);
2186: if (ret)
2187: goto err;
2188:
2189: ret = gen7_hfi_send_dms_feature_ctrl(adreno_dev);
2190: if (ret)
--- FILE: \adreno_gen7_perfcounter.c | HITS: 45 ---
MATCH LINES: 277, 293, 299
265:
266: if (counter == 4 || counter == 5)
267: counter -= 4;
268: else if (counter >= 6 && counter <= 9)
269: counter -= 6;
270: else if (counter == 10)
271: counter = 0;
272:
273: gen7_write_gmu_counter_enable(device, reg, counter * 8, countable);
274:
275: reg->value = 0;
276:
277: kgsl_regwrite(device, GEN7_GMU_CX_GMU_POWER_COUNTER_ENABLE, 1);
278:
279: return 0;
280: }
281:
282: static int gen7_counter_gmu_gmuclk_enable(struct adreno_device *adreno_dev,
283: const struct adreno_perfcount_group *group,
284: unsigned int counter, unsigned int countable)
285: {
286: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
287: struct adreno_perfcount_register *reg = &group->regs[counter];
288:
289: if (countable > 0xff)
290: return -EINVAL;
291:
292: /*
293: * The two counters are stuck into GMU_CX_GMU_POWER_COUNTER_SELECT_1
294: * at bit offset 16 and 24
295: */
296: gen7_write_gmu_counter_enable(device, reg,
297: 16 + (counter * 8), countable);
298:
299: kgsl_regwrite(device, GEN7_GMU_CX_GMU_POWER_COUNTER_ENABLE, 1);
300:
301: reg->value = 0;
302: return 0;
303: }
304:
305: static int gen7_counter_gmu_perf_enable(struct adreno_device *adreno_dev,
306: const struct adreno_perfcount_group *group,
307: unsigned int counter, unsigned int countable)
308: {
309: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
310: struct adreno_perfcount_register *reg = &group->regs[counter];
311:
312: if (countable > 0xff)
313: return -EINVAL;
314:
315: /*
316: * Counters [0:3] are in select 1 bit offsets 0, 8, 16 and 24
317: * Counters [4:5] are in select 2 bit offset 0, 8
318: */
319:
320: if (counter >= 4)
321: counter -= 4;
322:
323: gen7_write_gmu_counter_enable(device, reg, counter * 8, countable);
MATCH LINES: 940, 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, 979, 980, 981, 982, 983, 984, 1016, 1017
928:
929: #define GMU_COUNTER(lo, hi, sel) \
930: { .countable = KGSL_PERFCOUNTER_NOT_USED, \
931: .offset = lo, .offset_hi = hi, .select = sel }
932:
933: #define GMU_COUNTER_RESERVED(lo, hi, sel) \
934: { .countable = KGSL_PERFCOUNTER_BROKEN, \
935: .offset = lo, .offset_hi = hi, .select = sel }
936:
937: static struct adreno_perfcount_register gen7_perfcounters_gmu_xoclk[] = {
938: /*
939: * COUNTER_XOCLK_0 and COUNTER_XOCLK_4 are used for the GPU
940: * busy and ifpc count. Mark them as reserved to ensure they
941: * are not re-used.
942: */
943: GMU_COUNTER_RESERVED(GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_L,
944: GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_H,
945: GEN7_GMU_CX_GMU_POWER_COUNTER_SELECT_0),
946: GMU_COUNTER(GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_1_L,
947: GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_1_H,
948: GEN7_GMU_CX_GMU_POWER_COUNTER_SELECT_0),
949: GMU_COUNTER(GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_2_L,
950: GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_2_H,
951: GEN7_GMU_CX_GMU_POWER_COUNTER_SELECT_0),
952: GMU_COUNTER(GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_3_L,
953: GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_3_H,
954: GEN7_GMU_CX_GMU_POWER_COUNTER_SELECT_0),
955: GMU_COUNTER_RESERVED(GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_4_L,
956: GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_4_H,
957: GEN7_GMU_CX_GMU_POWER_COUNTER_SELECT_1),
958: GMU_COUNTER(GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_5_L,
959: GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_5_H,
960: GEN7_GMU_CX_GMU_POWER_COUNTER_SELECT_1),
961: GMU_COUNTER(GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_6_L,
962: GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_6_H,
963: GEN7_GMU_CX_GMU_POWER_COUNTER_SELECT_2),
964: GMU_COUNTER(GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_7_L,
965: GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_7_H,
966: GEN7_GMU_CX_GMU_POWER_COUNTER_SELECT_2),
967: GMU_COUNTER(GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_8_L,
968: GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_8_H,
969: GEN7_GMU_CX_GMU_POWER_COUNTER_SELECT_2),
970: GMU_COUNTER(GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_9_L,
971: GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_9_H,
972: GEN7_GMU_CX_GMU_POWER_COUNTER_SELECT_2),
973: GMU_COUNTER(GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_10_L,
974: GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_10_H,
975: GEN7_GMU_CX_GMU_POWER_COUNTER_SELECT_3),
976: };
977:
978: static struct adreno_perfcount_register gen7_perfcounters_gmu_gmuclk[] = {
979: GMU_COUNTER(GEN7_GMU_CX_GMU_POWER_COUNTER_GMUCLK_0_L,
980: GEN7_GMU_CX_GMU_POWER_COUNTER_GMUCLK_0_H,
981: GEN7_GMU_CX_GMU_POWER_COUNTER_SELECT_1),
982: GMU_COUNTER(GEN7_GMU_CX_GMU_POWER_COUNTER_GMUCLK_1_L,
983: GEN7_GMU_CX_GMU_POWER_COUNTER_GMUCLK_1_H,
984: GEN7_GMU_CX_GMU_POWER_COUNTER_SELECT_1),
985: };
986:
987: static struct adreno_perfcount_register gen7_perfcounters_gmu_perf[] = {
988: GMU_COUNTER(GEN7_GMU_CX_GMU_PERF_COUNTER_0_L,
989: GEN7_GMU_CX_GMU_PERF_COUNTER_0_H,
990: GEN7_GMU_CX_GMU_PERF_COUNTER_SELECT_0),
991: GMU_COUNTER(GEN7_GMU_CX_GMU_PERF_COUNTER_1_L,
992: GEN7_GMU_CX_GMU_PERF_COUNTER_1_H,
993: GEN7_GMU_CX_GMU_PERF_COUNTER_SELECT_0),
994: GMU_COUNTER(GEN7_GMU_CX_GMU_PERF_COUNTER_2_L,
995: GEN7_GMU_CX_GMU_PERF_COUNTER_2_H,
996: GEN7_GMU_CX_GMU_PERF_COUNTER_SELECT_0),
997: GMU_COUNTER(GEN7_GMU_CX_GMU_PERF_COUNTER_3_L,
998: GEN7_GMU_CX_GMU_PERF_COUNTER_3_H,
999: GEN7_GMU_CX_GMU_PERF_COUNTER_SELECT_0),
1000: GMU_COUNTER(GEN7_GMU_CX_GMU_PERF_COUNTER_4_L,
1001: GEN7_GMU_CX_GMU_PERF_COUNTER_4_H,
1002: GEN7_GMU_CX_GMU_PERF_COUNTER_SELECT_1),
1003: GMU_COUNTER(GEN7_GMU_CX_GMU_PERF_COUNTER_5_L,
1004: GEN7_GMU_CX_GMU_PERF_COUNTER_5_H,
1005: GEN7_GMU_CX_GMU_PERF_COUNTER_SELECT_1),
1006: };
1007:
1008: static struct adreno_perfcount_register gen7_perfcounters_alwayson[] = {
1009: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, GEN7_CP_ALWAYS_ON_COUNTER_LO,
1010: GEN7_CP_ALWAYS_ON_COUNTER_HI, -1 },
1011: };
1012:
1013: /*
1014: * ADRENO_PERFCOUNTER_GROUP_RESTORE flag is enabled by default
1015: * because most of the perfcounter groups need to be restored
1016: * as part of preemption and IFPC. Perfcounter groups that are
1017: * not restored as part of preemption and IFPC should be defined
1018: * using GEN7_PERFCOUNTER_GROUP_FLAGS macro
1019: */
1020:
1021: #define GEN7_PERFCOUNTER_GROUP_FLAGS(core, offset, name, flags, \
1022: enable, read) \
1023: [KGSL_PERFCOUNTER_GROUP_##offset] = { core##_perfcounters_##name, \
1024: ARRAY_SIZE(core##_perfcounters_##name), __stringify(name), flags, \
1025: enable, read }
1026:
1027: #define GEN7_PERFCOUNTER_GROUP(offset, name, enable, read) \
1028: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, offset, name, \
1029: ADRENO_PERFCOUNTER_GROUP_RESTORE, enable, read)
1030:
1031: #define GEN7_REGULAR_PERFCOUNTER_GROUP(offset, name) \
1032: GEN7_PERFCOUNTER_GROUP(offset, name, \
1033: gen7_counter_enable, gen7_counter_read)
1034:
1035: #define GEN7_BV_PERFCOUNTER_GROUP(offset, name, enable, read) \
1036: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, BV_##offset, bv_##name, \
1037: ADRENO_PERFCOUNTER_GROUP_RESTORE, enable, read)
1038:
1039: #define GEN7_BV_REGULAR_PERFCOUNTER_GROUP(offset, name) \
1040: GEN7_BV_PERFCOUNTER_GROUP(offset, name, \
1041: gen7_counter_enable, gen7_counter_read)
--- FILE: \adreno_gen7_preempt.c | HITS: 13 ---
MATCH LINES: 69, 74
57: spin_unlock_irqrestore(&rb->preempt_lock, flags);
58:
59: if (!atomic) {
60: /* If WPTR update fails, set the fault and trigger recovery */
61: if (ret) {
62: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
63: adreno_scheduler_fault(adreno_dev,
64: ADRENO_GMU_FAULT_SKIP_SNAPSHOT);
65: }
66: }
67: }
68:
69: static void _power_collapse_set(struct adreno_device *adreno_dev, bool val)
70: {
71: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
72:
73: gmu_core_regwrite(device,
74: GEN7_GMU_PWR_COL_PREEMPT_KEEPALIVE, (val ? 1 : 0));
75: }
76:
77: static void _gen7_preemption_done(struct adreno_device *adreno_dev)
78: {
79: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
80: unsigned int status;
81:
82: /*
83: * In the very unlikely case that the power is off, do nothing - the
84: * state will be reset on power up and everybody will be happy
85: */
86:
87: if (!kgsl_state_is_awake(device))
88: return;
89:
90: kgsl_regread(device, GEN7_CP_CONTEXT_SWITCH_CNTL, &status);
91:
92: if (status & 0x1) {
93: dev_err(device->dev,
94: "Preemption not complete: status=%X cur=%d R/W=%X/%X next=%d R/W=%X/%X\n",
95: status, adreno_dev->cur_rb->id,
96: adreno_get_rptr(adreno_dev->cur_rb),
97: adreno_dev->cur_rb->wptr,
98: adreno_dev->next_rb->id,
MATCH LINES: 278, 283, 285, 286, 290, 304, 306, 309
266: /* And write it to the smmu info */
267: if (kgsl_mmu_is_perprocess(&device->mmu)) {
268: kgsl_sharedmem_writeq(iommu->smmu_info,
269: PREEMPT_SMMU_RECORD(ttbr0), ttbr0);
270: kgsl_sharedmem_writel(iommu->smmu_info,
271: PREEMPT_SMMU_RECORD(context_idr), contextidr);
272: }
273:
274: kgsl_sharedmem_readq(preempt->scratch, &gpuaddr,
275: next->id * sizeof(u64));
276:
277: /*
278: * Set a keepalive bit before the first preemption register write.
279: * This is required since while each individual write to the context
280: * switch registers will wake the GPU from collapse, it will not in
281: * itself cause GPU activity. Thus, the GPU could technically be
282: * re-collapsed between subsequent register writes leading to a
283: * prolonged preemption sequence. The keepalive bit prevents any
284: * further power collapse while it is set.
285: * It is more efficient to use a keepalive+wake-on-fence approach here
286: * rather than an OOB. Both keepalive and the fence are effectively
287: * free when the GPU is already powered on, whereas an OOB requires an
288: * unconditional handshake with the GMU.
289: */
290: _power_collapse_set(adreno_dev, true);
291:
292: /*
293: * Fenced writes on this path will make sure the GPU is woken up
294: * in case it was power collapsed by the GMU.
295: */
296: if (gen7_fenced_write(adreno_dev,
297: GEN7_CP_CONTEXT_SWITCH_PRIV_NON_SECURE_RESTORE_ADDR_LO,
298: lower_32_bits(next->preemption_desc->gpuaddr),
299: FENCE_STATUS_WRITEDROPPED1_MASK))
300: goto err;
301:
302: /*
303: * Above fence writes will make sure GMU comes out of
304: * IFPC state if its was in IFPC state but it doesn't
305: * guarantee that GMU FW actually moved to ACTIVE state
306: * i.e. wake-up from IFPC is complete.
307: * Wait for GMU to move to ACTIVE state before triggering
308: * preemption. This is require to make sure CP doesn't
309: * interrupt GMU during wake-up from IFPC.
310: */
311: if (!atomic && gmu_core_dev_wait_for_active_transition(device))
312: goto err;
313:
314: if (gen7_fenced_write(adreno_dev,
315: GEN7_CP_CONTEXT_SWITCH_PRIV_NON_SECURE_RESTORE_ADDR_HI,
316: upper_32_bits(next->preemption_desc->gpuaddr),
317: FENCE_STATUS_WRITEDROPPED1_MASK))
318: goto err;
319:
320: if (kgsl_mmu_is_secured(&device->mmu)) {
321: if (gen7_fenced_write(adreno_dev,
322: GEN7_CP_CONTEXT_SWITCH_PRIV_SECURE_RESTORE_ADDR_LO,
323: lower_32_bits(next->secure_preemption_desc->gpuaddr),
324: FENCE_STATUS_WRITEDROPPED1_MASK))
325: goto err;
326:
327: if (gen7_fenced_write(adreno_dev,
328: GEN7_CP_CONTEXT_SWITCH_PRIV_SECURE_RESTORE_ADDR_HI,
329: upper_32_bits(next->secure_preemption_desc->gpuaddr),
330: FENCE_STATUS_WRITEDROPPED1_MASK))
331: goto err;
332: }
333:
MATCH LINES: 392, 426, 429
380: return;
381: err:
382: /* If fenced write fails, take inline snapshot and trigger recovery */
383: if (!in_interrupt()) {
384: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
385: adreno_scheduler_fault(adreno_dev,
386: ADRENO_GMU_FAULT_SKIP_SNAPSHOT);
387: } else {
388: adreno_scheduler_fault(adreno_dev, ADRENO_GMU_FAULT);
389: }
390: adreno_set_preempt_state(adreno_dev, ADRENO_PREEMPT_NONE);
391: /* Clear the keep alive */
392: _power_collapse_set(adreno_dev, false);
393:
394: }
395:
396: void gen7_preemption_callback(struct adreno_device *adreno_dev, int bit)
397: {
398: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
399: unsigned int status;
400:
401: if (!adreno_move_preempt_state(adreno_dev,
402: ADRENO_PREEMPT_TRIGGERED, ADRENO_PREEMPT_PENDING))
403: return;
404:
405: kgsl_regread(device, GEN7_CP_CONTEXT_SWITCH_CNTL, &status);
406:
407: if (status & 0x1) {
408: dev_err(KGSL_DEVICE(adreno_dev)->dev,
409: "preempt interrupt with non-zero status: %X\n",
410: status);
411:
412: /*
413: * Under the assumption that this is a race between the
414: * interrupt and the register, schedule the worker to clean up.
415: * If the status still hasn't resolved itself by the time we get
416: * there then we have to assume something bad happened
417: */
418: adreno_set_preempt_state(adreno_dev, ADRENO_PREEMPT_COMPLETE);
419: adreno_scheduler_queue(adreno_dev);
420: return;
421: }
422:
423: adreno_dev->preempt.count++;
424:
425: /*
426: * We can now safely clear the preemption keepalive bit, allowing
427: * power collapse to resume its regular activity.
428: */
429: _power_collapse_set(adreno_dev, false);
430:
431: kgsl_delete_timer(&adreno_dev->preempt.timer);
432:
433: kgsl_regread(device, GEN7_CP_CONTEXT_SWITCH_LEVEL_STATUS, &status);
434:
435: trace_adreno_preempt_done(adreno_dev->cur_rb->id, adreno_dev->next_rb->id,
436: status, 0);
437:
438: adreno_dev->prev_rb = adreno_dev->cur_rb;
439: adreno_dev->cur_rb = adreno_dev->next_rb;
440: adreno_dev->next_rb = NULL;
441:
442: /* Update the wptr if it changed while preemption was ongoing */
443: _update_wptr(adreno_dev, true, true);
444:
445: /* Update the dispatcher timer for the new command queue */
446: mod_timer(&adreno_dev->dispatcher.timer,
447: adreno_dev->cur_rb->dispatch_q.expires);
448:
449: adreno_set_preempt_state(adreno_dev, ADRENO_PREEMPT_NONE);
450:
451: gen7_preemption_trigger(adreno_dev, true);
452: }
453:
--- FILE: \adreno_gen7_ringbuffer.c | HITS: 2 ---
MATCH LINES: 292
280: /* Identify the start of a command */
281: cmds[index++] = cp_type7_packet(CP_NOP, 1);
282: cmds[index++] = drawctxt ? CMD_IDENTIFIER : CMD_INTERNAL_IDENTIFIER;
283:
284: /* This is 25 dwords when drawctxt is not NULL and perfcounter needs to be zapped*/
285: index += gen7_preemption_pre_ibsubmit(adreno_dev, rb, drawctxt,
286: &cmds[index]);
287:
288: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
289: cmds[index++] = CP_SET_THREAD_BOTH;
290:
291: cmds[index++] = cp_type7_packet(CP_SET_MARKER, 1);
292: cmds[index++] = 0x101; /* IFPC disable */
293:
294: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
295: cmds[index++] = CP_SET_THREAD_BR;
296:
297: profile_gpuaddr = adreno_profile_preib_processing(adreno_dev,
298: drawctxt, &profile_dwords);
299:
300: if (profile_gpuaddr) {
301: cmds[index++] = cp_type7_packet(CP_INDIRECT_BUFFER_PFE, 3);
302: cmds[index++] = lower_32_bits(profile_gpuaddr);
303: cmds[index++] = upper_32_bits(profile_gpuaddr);
304: cmds[index++] = profile_dwords;
305: }
306:
307: if (drawctxt) {
308: cmds[index++] = cp_type7_packet(CP_MEM_WRITE, 3);
309: cmds[index++] = lower_32_bits(CTXT_SOPTIMESTAMP(device,
310: drawctxt));
311: cmds[index++] = upper_32_bits(CTXT_SOPTIMESTAMP(device,
312: drawctxt));
313: cmds[index++] = timestamp;
314: }
315:
316: cmds[index++] = cp_type7_packet(CP_MEM_WRITE, 3);
MATCH LINES: 418
406: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
407: cmds[index++] = CP_CONCURRENT_BIN_DISABLE;
408: cmds[index++] = cp_type7_packet(CP_SET_SECURE_MODE, 1);
409: cmds[index++] = 0;
410: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
411: cmds[index++] = CP_SYNC_THREADS;
412: }
413:
414: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
415: cmds[index++] = CP_SET_THREAD_BOTH;
416:
417: cmds[index++] = cp_type7_packet(CP_SET_MARKER, 1);
418: cmds[index++] = 0x100; /* IFPC enable */
419:
420: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
421: cmds[index++] = CP_SET_THREAD_BR;
422:
423: /* 10 dwords */
424: index += gen7_preemption_post_ibsubmit(adreno_dev, &cmds[index]);
425:
426: /* Adjust the thing for the number of bytes we actually wrote */
427: rb->_wptr -= (size - index);
428:
429: return gen7_ringbuffer_submit(rb, time);
430: }
431:
432: static u32 gen7_get_alwayson_counter(u32 *cmds, u64 gpuaddr)
433: {
434: cmds[0] = cp_type7_packet(CP_REG_TO_MEM, 3);
435: cmds[1] = GEN7_CP_ALWAYS_ON_COUNTER_LO | (1 << 30) | (2 << 18);
436: cmds[2] = lower_32_bits(gpuaddr);
437: cmds[3] = upper_32_bits(gpuaddr);
438:
439: return 4;
440: }
441:
442: static u32 gen7_get_alwayson_context(u32 *cmds, u64 gpuaddr)
--- FILE: \adreno_gen8.c | HITS: 69 ---
MATCH LINES: 129
117: BIT(CP_SW_SMMUFAULT) | \
118: BIT(CP_SW_VBIFRESPCLIENT) | \
119: BIT(CP_SW_VBIFRESPTYPE) | \
120: BIT(CP_SW_VBIFRESPREAD) | \
121: BIT(CP_SW_VBIFRESP) | \
122: BIT(CP_SW_RTWROVF) | \
123: BIT(CP_SW_LRZRTWROVF) | \
124: BIT(CP_SW_LRZRTREFCNTOVF) | \
125: BIT(CP_SW_LRZRTCLRRESMISS))
126:
127: extern u32 adreno_slice_mask_override;
128:
129: /* IFPC & Preemption static powerup restore list */
130: static const u32 gen8_pwrup_reglist[] = {
131: GEN8_UCHE_MODE_CNTL,
132: GEN8_UCHE_VARB_IDLE_TIMEOUT,
133: GEN8_UCHE_GBIF_GX_CONFIG,
134: GEN8_UCHE_CACHE_WAYS,
135: GEN8_UCHE_CCHE_MODE_CNTL,
136: GEN8_UCHE_CCHE_CACHE_WAYS,
137: GEN8_UCHE_CCHE_GC_GMEM_RANGE_MIN_LO,
138: GEN8_UCHE_CCHE_GC_GMEM_RANGE_MIN_HI,
139: GEN8_UCHE_CCHE_LPAC_GMEM_RANGE_MIN_LO,
140: GEN8_UCHE_CCHE_LPAC_GMEM_RANGE_MIN_HI,
141: GEN8_UCHE_CCHE_TRAP_BASE_LO,
142: GEN8_UCHE_CCHE_TRAP_BASE_HI,
143: GEN8_UCHE_CCHE_WRITE_THRU_BASE_LO,
144: GEN8_UCHE_CCHE_WRITE_THRU_BASE_HI,
145: GEN8_UCHE_HW_DBG_CNTL,
146: GEN8_UCHE_WRITE_THRU_BASE_LO,
147: GEN8_UCHE_WRITE_THRU_BASE_HI,
148: GEN8_UCHE_TRAP_BASE_LO,
149: GEN8_UCHE_TRAP_BASE_HI,
150: GEN8_UCHE_CLIENT_PF,
151: GEN8_VSC_KMD_DBG_ECO_CNTL,
152: GEN8_RB_CMP_NC_MODE_CNTL,
153: GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP,
MATCH LINES: 232
220: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_10,
221: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_11,
222: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_12,
223: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_13,
224: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_14,
225: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_15,
226: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_16,
227: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_17,
228: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_18,
229: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_19,
230: };
231:
232: /* IFPC & Preemption static powerup restore list for gen8_3_0 */
233: static const u32 gen8_3_0_pwrup_reglist[] = {
234: GEN8_UCHE_MODE_CNTL,
235: GEN8_UCHE_VARB_IDLE_TIMEOUT,
236: GEN8_UCHE_GBIF_GX_CONFIG,
237: GEN8_UCHE_CACHE_WAYS,
238: GEN8_UCHE_CCHE_MODE_CNTL,
239: GEN8_UCHE_CCHE_CACHE_WAYS,
240: GEN8_UCHE_CCHE_GC_GMEM_RANGE_MIN_LO,
241: GEN8_UCHE_CCHE_GC_GMEM_RANGE_MIN_HI,
242: GEN8_UCHE_CCHE_TRAP_BASE_LO,
243: GEN8_UCHE_CCHE_TRAP_BASE_HI,
244: GEN8_UCHE_CCHE_WRITE_THRU_BASE_LO,
245: GEN8_UCHE_CCHE_WRITE_THRU_BASE_HI,
246: GEN8_UCHE_HW_DBG_CNTL,
247: GEN8_UCHE_WRITE_THRU_BASE_LO,
248: GEN8_UCHE_WRITE_THRU_BASE_HI,
249: GEN8_UCHE_TRAP_BASE_LO,
250: GEN8_UCHE_TRAP_BASE_HI,
251: GEN8_UCHE_CLIENT_PF,
252: GEN8_RB_CMP_NC_MODE_CNTL,
253: GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP,
254: GEN8_SP_HLSQ_GC_GMEM_RANGE_MIN_LO,
255: GEN8_SP_HLSQ_GC_GMEM_RANGE_MIN_HI,
256: GEN8_SP_READ_SEL,
MATCH LINES: 281
269: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_10,
270: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_11,
271: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_12,
272: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_13,
273: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_14,
274: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_15,
275: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_16,
276: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_17,
277: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_18,
278: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_19,
279: };
280:
281: /* IFPC & Preemption static powerup restore list for gen8_11_0 */
282: static const u32 gen8_11_0_pwrup_reglist[] = {
283: GEN8_RB_CMP_NC_MODE_CNTL,
284: GEN8_SP_HLSQ_GC_GMEM_RANGE_MIN_LO,
285: GEN8_SP_HLSQ_GC_GMEM_RANGE_MIN_HI,
286: GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP,
287: GEN8_SP_READ_SEL,
288: GEN8_CP_MULTIDRAW_CNTL,
289: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_0,
290: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_1,
291: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_2,
292: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_3,
293: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_4,
294: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_5,
295: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_6,
296: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_7,
297: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_8,
298: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_9,
299: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_10,
300: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_11,
301: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_12,
302: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_13,
303: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_14,
304: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_15,
305: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_16,
MATCH LINES: 335, 336
323: GEN8_UCHE_CCHE_WRITE_THRU_BASE_HI,
324: GEN8_UCHE_CLIENT_PF,
325: GEN8_UCHE_DBG_ECO_CNTL_0,
326: GEN8_UCHE_GBIF_GX_CONFIG,
327: GEN8_UCHE_TRAP_BASE_LO,
328: GEN8_UCHE_TRAP_BASE_HI,
329: GEN8_UCHE_VARB_IDLE_TIMEOUT,
330: GEN8_UCHE_WRITE_THRU_BASE_LO,
331: GEN8_UCHE_WRITE_THRU_BASE_HI,
332: GEN8_VSC_VISIBILITY_FLUSH_CNTL,
333: };
334:
335: /* IFPC only static powerup restore list */
336: static const u32 gen8_ifpc_pwrup_reglist[] = {
337: GEN8_RBBM_NC_MODE_CNTL,
338: GEN8_RBBM_SLICE_INTERFACE_HANG_INT_CNTL,
339: GEN8_RBBM_SLICE_NC_MODE_CNTL,
340: GEN8_SP_NC_MODE_CNTL,
341: GEN8_SP_HLSQ_LPAC_GMEM_RANGE_MIN_LO,
342: GEN8_SP_HLSQ_LPAC_GMEM_RANGE_MIN_HI,
343: GEN8_SP_CHICKEN_BITS_1,
344: GEN8_SP_CHICKEN_BITS_2,
345: GEN8_SP_CHICKEN_BITS_3,
346: GEN8_SP_PERFCTR_SHADER_MASK,
347: GEN8_CP_PROTECT_REG_GLOBAL,
348: GEN8_CP_PROTECT_REG_GLOBAL + 1,
349: GEN8_CP_PROTECT_REG_GLOBAL + 2,
350: GEN8_CP_PROTECT_REG_GLOBAL + 3,
351: GEN8_CP_PROTECT_REG_GLOBAL + 4,
352: GEN8_CP_PROTECT_REG_GLOBAL + 5,
353: GEN8_CP_PROTECT_REG_GLOBAL + 6,
354: GEN8_CP_PROTECT_REG_GLOBAL + 7,
355: GEN8_CP_PROTECT_REG_GLOBAL + 8,
356: GEN8_CP_PROTECT_REG_GLOBAL + 9,
357: GEN8_CP_PROTECT_REG_GLOBAL + 10,
358: GEN8_CP_PROTECT_REG_GLOBAL + 11,
359: GEN8_CP_PROTECT_REG_GLOBAL + 12,
360: GEN8_CP_PROTECT_REG_GLOBAL + 13,
MATCH LINES: 398, 399
386: GEN8_CP_PROTECT_REG_GLOBAL + 39,
387: GEN8_CP_PROTECT_REG_GLOBAL + 40,
388: GEN8_CP_PROTECT_REG_GLOBAL + 41,
389: GEN8_CP_PROTECT_REG_GLOBAL + 42,
390: GEN8_CP_PROTECT_REG_GLOBAL + 43,
391: GEN8_CP_PROTECT_REG_GLOBAL + 44,
392: GEN8_CP_PROTECT_REG_GLOBAL + 45,
393: GEN8_CP_PROTECT_REG_GLOBAL + 46,
394: GEN8_CP_PROTECT_REG_GLOBAL + 63,
395: GEN8_CP_INTERRUPT_STATUS_MASK_GLOBAL,
396: };
397:
398: /* IFPC only static powerup restore list for gen8_1_0 */
399: static const u32 gen8_1_0_ifpc_pwrup_reglist[] = {
400: GEN8_RBBM_NC_MODE_CNTL,
401: GEN8_RBBM_SLICE_NC_MODE_CNTL,
402: GEN8_RBBM_SLICE_PERFCTR_CNTL,
403: GEN8_RBBM_SLICE_INTERFACE_HANG_INT_CNTL,
404: GEN8_RBBM_PERFCTR_CNTL,
405: GEN8_SP_NC_MODE_CNTL,
406: GEN8_SP_CHICKEN_BITS_2,
407: GEN8_SP_CHICKEN_BITS_3,
408: GEN8_SP_PERFCTR_SHADER_MASK,
409: GEN8_SP_HLSQ_DBG_ECO_CNTL_2,
410: GEN8_CP_INTERRUPT_STATUS_MASK_GLOBAL,
411: GEN8_CP_PROTECT_REG_GLOBAL,
412: GEN8_CP_PROTECT_REG_GLOBAL + 1,
413: GEN8_CP_PROTECT_REG_GLOBAL + 2,
414: GEN8_CP_PROTECT_REG_GLOBAL + 3,
415: GEN8_CP_PROTECT_REG_GLOBAL + 4,
416: GEN8_CP_PROTECT_REG_GLOBAL + 5,
417: GEN8_CP_PROTECT_REG_GLOBAL + 6,
418: GEN8_CP_PROTECT_REG_GLOBAL + 7,
419: GEN8_CP_PROTECT_REG_GLOBAL + 8,
420: GEN8_CP_PROTECT_REG_GLOBAL + 9,
421: GEN8_CP_PROTECT_REG_GLOBAL + 10,
422: GEN8_CP_PROTECT_REG_GLOBAL + 11,
423: GEN8_CP_PROTECT_REG_GLOBAL + 12,
MATCH LINES: 465, 466
453: GEN8_CP_PROTECT_REG_GLOBAL + 42,
454: GEN8_CP_PROTECT_REG_GLOBAL + 43,
455: GEN8_CP_PROTECT_REG_GLOBAL + 44,
456: GEN8_CP_PROTECT_REG_GLOBAL + 45,
457: GEN8_CP_PROTECT_REG_GLOBAL + 46,
458: GEN8_CP_PROTECT_REG_GLOBAL + 47,
459: GEN8_CP_PROTECT_REG_GLOBAL + 48,
460: GEN8_CP_PROTECT_REG_GLOBAL + 49,
461: GEN8_CP_PROTECT_REG_GLOBAL + 50,
462: GEN8_CP_PROTECT_REG_GLOBAL + 63,
463: };
464:
465: /* IFPC only static powerup restore list for gen8_2_0 */
466: static const u32 gen8_2_0_ifpc_pwrup_reglist[] = {
467: GEN8_RBBM_NC_MODE_CNTL,
468: GEN8_RBBM_SLICE_NC_MODE_CNTL,
469: GEN8_SP_NC_MODE_CNTL,
470: GEN8_SP_CHICKEN_BITS,
471: GEN8_SP_SS_CHICKEN_BITS_0,
472: GEN8_SP_CHICKEN_BITS_2,
473: GEN8_SP_CHICKEN_BITS_3,
474: GEN8_SP_PERFCTR_SHADER_MASK,
475: GEN8_RBBM_SLICE_INTERFACE_HANG_INT_CNTL,
476: GEN8_SP_HLSQ_DBG_ECO_CNTL_1,
477: GEN8_SP_HLSQ_DBG_ECO_CNTL_2,
478: GEN8_SP_HLSQ_DBG_ECO_CNTL_3,
479: GEN8_SP_HLSQ_LPAC_GMEM_RANGE_MIN_LO,
480: GEN8_SP_HLSQ_LPAC_GMEM_RANGE_MIN_HI,
481: GEN8_CP_INTERRUPT_STATUS_MASK_GLOBAL,
482: GEN8_CP_PROTECT_REG_GLOBAL,
483: GEN8_CP_PROTECT_REG_GLOBAL + 1,
484: GEN8_CP_PROTECT_REG_GLOBAL + 2,
485: GEN8_CP_PROTECT_REG_GLOBAL + 3,
486: GEN8_CP_PROTECT_REG_GLOBAL + 4,
487: GEN8_CP_PROTECT_REG_GLOBAL + 5,
488: GEN8_CP_PROTECT_REG_GLOBAL + 6,
489: GEN8_CP_PROTECT_REG_GLOBAL + 7,
490: GEN8_CP_PROTECT_REG_GLOBAL + 8,
MATCH LINES: 538, 539
526: GEN8_CP_PROTECT_REG_GLOBAL + 44,
527: GEN8_CP_PROTECT_REG_GLOBAL + 45,
528: GEN8_CP_PROTECT_REG_GLOBAL + 46,
529: GEN8_CP_PROTECT_REG_GLOBAL + 47,
530: GEN8_CP_PROTECT_REG_GLOBAL + 48,
531: GEN8_CP_PROTECT_REG_GLOBAL + 49,
532: GEN8_CP_PROTECT_REG_GLOBAL + 50,
533: GEN8_CP_PROTECT_REG_GLOBAL + 51,
534: GEN8_CP_PROTECT_REG_GLOBAL + 52,
535: GEN8_CP_PROTECT_REG_GLOBAL + 63,
536: };
537:
538: /* IFPC only static powerup restore list for gen8_3_0*/
539: static const u32 gen8_3_0_ifpc_pwrup_reglist[] = {
540: GEN8_RBBM_NC_MODE_CNTL,
541: GEN8_RBBM_SLICE_INTERFACE_HANG_INT_CNTL,
542: GEN8_RBBM_SLICE_NC_MODE_CNTL,
543: GEN8_SP_NC_MODE_CNTL,
544: GEN8_SP_CHICKEN_BITS_2,
545: GEN8_SP_CHICKEN_BITS_3,
546: GEN8_SP_PERFCTR_SHADER_MASK,
547: GEN8_CP_PROTECT_REG_GLOBAL,
548: GEN8_CP_PROTECT_REG_GLOBAL + 1,
549: GEN8_CP_PROTECT_REG_GLOBAL + 2,
550: GEN8_CP_PROTECT_REG_GLOBAL + 3,
551: GEN8_CP_PROTECT_REG_GLOBAL + 4,
552: GEN8_CP_PROTECT_REG_GLOBAL + 5,
553: GEN8_CP_PROTECT_REG_GLOBAL + 6,
554: GEN8_CP_PROTECT_REG_GLOBAL + 7,
555: GEN8_CP_PROTECT_REG_GLOBAL + 8,
556: GEN8_CP_PROTECT_REG_GLOBAL + 9,
557: GEN8_CP_PROTECT_REG_GLOBAL + 10,
558: GEN8_CP_PROTECT_REG_GLOBAL + 11,
559: GEN8_CP_PROTECT_REG_GLOBAL + 12,
560: GEN8_CP_PROTECT_REG_GLOBAL + 13,
561: GEN8_CP_PROTECT_REG_GLOBAL + 14,
562: GEN8_CP_PROTECT_REG_GLOBAL + 15,
563: GEN8_CP_PROTECT_REG_GLOBAL + 16,
MATCH LINES: 597
585: GEN8_CP_PROTECT_REG_GLOBAL + 38,
586: GEN8_CP_PROTECT_REG_GLOBAL + 39,
587: GEN8_CP_PROTECT_REG_GLOBAL + 40,
588: GEN8_CP_PROTECT_REG_GLOBAL + 41,
589: GEN8_CP_PROTECT_REG_GLOBAL + 42,
590: GEN8_CP_PROTECT_REG_GLOBAL + 43,
591: GEN8_CP_PROTECT_REG_GLOBAL + 44,
592: GEN8_CP_PROTECT_REG_GLOBAL + 45,
593: GEN8_CP_PROTECT_REG_GLOBAL + 46,
594: GEN8_CP_PROTECT_REG_GLOBAL + 63,
595: };
596:
597: /* IFPC + Preemption static powerup restore list for gen8_1_0 */
598: static const u32 gen8_1_0_pwrup_reglist[] = {
599: GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP,
600: GEN8_SP_READ_SEL,
601: GEN8_UCHE_MODE_CNTL,
602: GEN8_UCHE_VARB_IDLE_TIMEOUT,
603: GEN8_UCHE_GBIF_GX_CONFIG,
604: GEN8_UCHE_CCHE_MODE_CNTL,
605: GEN8_UCHE_CCHE_CACHE_WAYS,
606: GEN8_UCHE_CCHE_GC_GMEM_RANGE_MIN_LO,
607: GEN8_UCHE_CCHE_GC_GMEM_RANGE_MIN_HI,
608: GEN8_UCHE_CCHE_TRAP_BASE_LO,
609: GEN8_UCHE_CCHE_TRAP_BASE_HI,
610: GEN8_UCHE_CCHE_WRITE_THRU_BASE_LO,
611: GEN8_UCHE_CCHE_WRITE_THRU_BASE_HI,
612: GEN8_UCHE_WRITE_THRU_BASE_LO,
613: GEN8_UCHE_WRITE_THRU_BASE_HI,
614: GEN8_UCHE_TRAP_BASE_LO,
615: GEN8_UCHE_TRAP_BASE_HI,
616: GEN8_UCHE_CLIENT_PF,
617: GEN8_RB_CMP_NC_MODE_CNTL,
618: GEN8_SP_HLSQ_GC_GMEM_RANGE_MIN_LO,
619: GEN8_SP_HLSQ_GC_GMEM_RANGE_MIN_HI,
620: GEN8_TPL1_NC_MODE_CNTL,
621: GEN8_TPL1_DBG_ECO_CNTL,
MATCH LINES: 644, 677, 678
632: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_10,
633: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_11,
634: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_12,
635: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_13,
636: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_14,
637: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_15,
638: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_16,
639: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_17,
640: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_18,
641: GEN8_TPL1_BICUBIC_WEIGHTS_TABLE_19,
642: };
643:
644: /* Dynamic IFPC + Preemption extlist for gen8_1_0 */
645: static const struct gen8_pwrup_extlist gen8_1_0_pwrup_extlist[] = {
646: { GEN8_GRAS_TSEFE_DBG_ECO_CNTL, BIT(PIPE_BV) | BIT(PIPE_BR) },
647: { GEN8_GRAS_NC_MODE_CNTL, BIT(PIPE_BV) | BIT(PIPE_BR) },
648: { GEN8_GRAS_DBG_ECO_CNTL, BIT(PIPE_BV) | BIT(PIPE_BR) },
649: { GEN8_PC_AUTO_VERTEX_STRIDE, BIT(PIPE_BV) | BIT(PIPE_BR) },
650: { GEN8_PC_CHICKEN_BITS_1, BIT(PIPE_BV) | BIT(PIPE_BR) },
651: { GEN8_PC_CHICKEN_BITS_2, BIT(PIPE_BV) | BIT(PIPE_BR) },
652: { GEN8_PC_CHICKEN_BITS_3, BIT(PIPE_BV) | BIT(PIPE_BR) },
653: { GEN8_PC_CHICKEN_BITS_4, BIT(PIPE_BV) | BIT(PIPE_BR) },
654: { GEN8_PC_CONTEXT_SWITCH_STABILIZE_CNTL_1, BIT(PIPE_BV) | BIT(PIPE_BR) },
655: { GEN8_PC_VIS_STREAM_CNTL, BIT(PIPE_BV) | BIT(PIPE_BR) },
656: { GEN8_RB_CCU_NC_MODE_CNTL, BIT(PIPE_BR) },
657: { GEN8_RB_CMP_NC_MODE_CNTL, BIT(PIPE_BR) },
658: { GEN8_RB_RESOLVE_PREFETCH_CNTL, BIT(PIPE_BR) },
659: /* Note: RB_DBG_ECO_CNTL intentionally absent (x285 differs from a840) */
660: { GEN8_RB_CMP_DBG_ECO_CNTL, BIT(PIPE_BR) },
661: { GEN8_VFD_DBG_ECO_CNTL, BIT(PIPE_BV) | BIT(PIPE_BR) },
662: { GEN8_VFD_CB_BV_THRESHOLD, BIT(PIPE_BV) | BIT(PIPE_BR) },
663: { GEN8_VFD_CB_BR_THRESHOLD, BIT(PIPE_BV) | BIT(PIPE_BR) },
664: { GEN8_VFD_CB_BUSY_REQ_CNT, BIT(PIPE_BV) | BIT(PIPE_BR) },
665: { GEN8_VFD_CB_LP_REQ_CNT, BIT(PIPE_BV) | BIT(PIPE_BR) },
666: { GEN8_VPC_FLATSHADE_MODE_CNTL, BIT(PIPE_BV) | BIT(PIPE_BR) },
667: { GEN8_CP_HW_FAULT_STATUS_MASK_PIPE, BIT(PIPE_BR) | BIT(PIPE_BV) | BIT(PIPE_LPAC)
668: | BIT(PIPE_AQE0) | BIT(PIPE_AQE1) | BIT(PIPE_DDE_BR) | BIT(PIPE_DDE_BV) },
669: { GEN8_CP_INTERRUPT_STATUS_MASK_PIPE, BIT(PIPE_BR) | BIT(PIPE_BV) | BIT(PIPE_LPAC)
670: | BIT(PIPE_AQE0) | BIT(PIPE_AQE1) | BIT(PIPE_DDE_BR) | BIT(PIPE_DDE_BV) },
671: { GEN8_CP_PROTECT_CNTL_PIPE, BIT(PIPE_BR) | BIT(PIPE_BV) | BIT(PIPE_LPAC) },
672: { GEN8_CP_PROTECT_REG_PIPE + 15, BIT(PIPE_BR) | BIT(PIPE_BV) | BIT(PIPE_LPAC) },
673: { GEN8_RB_GC_GMEM_PROTECT, BIT(PIPE_BR) },
674: { GEN8_RB_CONTEXT_SWITCH_GMEM_SAVE_RESTORE, BIT(PIPE_BR) },
675: };
676:
677: /* IFPC only static powerup restore list for gen8_11_0 */
678: static const u32 gen8_11_0_ifpc_pwrup_reglist[] = {
679: GEN8_CP_INTERRUPT_STATUS_MASK_GLOBAL,
680: GEN8_RBBM_NC_MODE_CNTL,
681: GEN8_RBBM_SLICE_INTERFACE_HANG_INT_CNTL,
682: GEN8_RBBM_SLICE_NC_MODE_CNTL,
683: GEN8_RBBM_SLICE_PERFCTR_CNTL,
684: GEN8_SP_CHICKEN_BITS,
685: GEN8_SP_CHICKEN_BITS_2,
686: GEN8_SP_CHICKEN_BITS_3,
687: GEN8_SP_CHICKEN_BITS_5,
688: GEN8_SP_HLSQ_DBG_ECO_CNTL,
689: GEN8_SP_HLSQ_DBG_ECO_CNTL_1,
690: GEN8_SP_HLSQ_DBG_ECO_CNTL_3,
691: GEN8_SP_HLSQ_LPAC_GMEM_RANGE_MIN_LO,
692: GEN8_SP_HLSQ_LPAC_GMEM_RANGE_MIN_HI,
693: GEN8_SP_NC_MODE_CNTL,
694: GEN8_SP_PERFCTR_SHADER_MASK,
695: GEN8_SP_L0_PERF_TUNE,
696: GEN8_CP_PROTECT_REG_GLOBAL + 0,
697: GEN8_CP_PROTECT_REG_GLOBAL + 1,
698: GEN8_CP_PROTECT_REG_GLOBAL + 2,
699: GEN8_CP_PROTECT_REG_GLOBAL + 3,
700: GEN8_CP_PROTECT_REG_GLOBAL + 4,
701: GEN8_CP_PROTECT_REG_GLOBAL + 5,
702: GEN8_CP_PROTECT_REG_GLOBAL + 6,
MATCH LINES: 1737, 1739, 1740, 1742, 1743, 1745, 1746, 1748, 1749, 1751, 1752, 1754, 1757, 1789, 1790, 1791, 1792, 1793, 1796, 1808, 1809, 1810, 1811, 1812, 1816, 1834, 1835, 1836, 1839
1725: {
1726: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1727: struct gen8_device *gen8_dev = container_of(adreno_dev,
1728: struct gen8_device, adreno_dev);
1729: struct adreno_reglist_list reglist[3];
1730: void *ptr = adreno_dev->pwrup_reglist->hostptr;
1731: struct cpu_gpu_lock *lock = ptr;
1732: u32 items = 0, i, j, pipe_id;
1733: u32 *dest = ptr + sizeof(*lock);
1734: struct gen8_nonctxt_overrides *nc_overrides = gen8_dev->nc_overrides;
1735: u32 first_slice = gen8_first_slice(adreno_dev);
1736:
1737: /* Static IFPC restore only registers */
1738: if (adreno_is_gen8_3_0(adreno_dev) || adreno_is_gen8_8_0(adreno_dev)) {
1739: reglist[items].regs = gen8_3_0_ifpc_pwrup_reglist;
1740: reglist[items].count = ARRAY_SIZE(gen8_3_0_ifpc_pwrup_reglist);
1741: } else if (adreno_is_gen8_2_x(adreno_dev)) {
1742: reglist[items].regs = gen8_2_0_ifpc_pwrup_reglist;
1743: reglist[items].count = ARRAY_SIZE(gen8_2_0_ifpc_pwrup_reglist);
1744: } else if (adreno_is_gen8_1_0(adreno_dev)) {
1745: reglist[items].regs = gen8_1_0_ifpc_pwrup_reglist;
1746: reglist[items].count = ARRAY_SIZE(gen8_1_0_ifpc_pwrup_reglist);
1747: } else if (adreno_is_gen8_11_x(adreno_dev)) {
1748: reglist[items].regs = gen8_11_0_ifpc_pwrup_reglist;
1749: reglist[items].count = ARRAY_SIZE(gen8_11_0_ifpc_pwrup_reglist);
1750: } else {
1751: reglist[items].regs = gen8_ifpc_pwrup_reglist;
1752: reglist[items].count = ARRAY_SIZE(gen8_ifpc_pwrup_reglist);
1753: }
1754: lock->ifpc_list_len = reglist[items].count;
1755: items++;
1756:
1757: /* Static IFPC + preemption registers */
1758: if (adreno_is_gen8_3_0(adreno_dev) || adreno_is_gen8_8_0(adreno_dev)) {
1759: reglist[items].regs = gen8_3_0_pwrup_reglist;
1760: reglist[items].count = ARRAY_SIZE(gen8_3_0_pwrup_reglist);
1761: } else if (adreno_is_gen8_2_x(adreno_dev)) {
1762: reglist[items].regs = gen8_2_0_pwrup_reglist;
1763: reglist[items].count = ARRAY_SIZE(gen8_2_0_pwrup_reglist);
1764: } else if (adreno_is_gen8_1_0(adreno_dev)) {
1765: reglist[items].regs = gen8_1_0_pwrup_reglist;
1766: reglist[items].count = ARRAY_SIZE(gen8_1_0_pwrup_reglist);
1767: } else if (adreno_is_gen8_11_x(adreno_dev)) {
1768: reglist[items].regs = gen8_11_0_pwrup_reglist;
1769: reglist[items].count = ARRAY_SIZE(gen8_11_0_pwrup_reglist);
1770: } else {
1771: reglist[items].regs = gen8_pwrup_reglist;
1772: reglist[items].count = ARRAY_SIZE(gen8_pwrup_reglist);
1773: }
1774: lock->preemption_list_len = reglist[items].count;
1775: items++;
1776:
1777: /*
1778: * For each entry in each of the lists, write the offset and the current
1779: * register value into the GPU buffer
1780: */
1781: for (i = 0; i < items; i++) {
1782: const u32 *r = reglist[i].regs;
1783:
1784: for (j = 0; j < reglist[i].count; j++) {
1785: *dest++ = r[j];
1786: kgsl_regread(device, r[j], dest++);
1787: }
1788:
1789: if ((r == gen8_ifpc_pwrup_reglist ||
1790: r == gen8_1_0_ifpc_pwrup_reglist ||
1791: r == gen8_2_0_ifpc_pwrup_reglist ||
1792: r == gen8_3_0_ifpc_pwrup_reglist ||
1793: r == gen8_11_0_ifpc_pwrup_reglist)) {
1794: u32 cs_len = adreno_coresight_patch_pwrup_reglist(adreno_dev, dest);
1795:
1796: lock->ifpc_list_len += cs_len;
1797: dest += (cs_len * 2);
1798: }
1799:
1800: mutex_lock(&gen8_dev->nc_mutex);
1801: for (j = 0; j < nc_overrides[j].offset; j++) {
1802: unsigned long pipe = (unsigned long)nc_overrides[j].pipelines;
1803:
1804: if (!(test_bit(PIPE_NONE, &pipe) && nc_overrides[j].set &&
1805: nc_overrides[j].list_type))
1806: continue;
1807:
1808: if ((reglist[i].regs == gen8_ifpc_pwrup_reglist ||
1809: reglist[i].regs == gen8_1_0_ifpc_pwrup_reglist ||
1810: reglist[i].regs == gen8_3_0_ifpc_pwrup_reglist ||
1811: reglist[i].regs == gen8_2_0_ifpc_pwrup_reglist ||
1812: reglist[i].regs == gen8_11_0_ifpc_pwrup_reglist) &&
1813: (nc_overrides[j].list_type == 1)) {
1814: *dest++ = nc_overrides[j].offset;
1815: kgsl_regread(device, nc_overrides[j].offset, dest++);
1816: lock->ifpc_list_len++;
1817: } else if ((reglist[i].regs == gen8_pwrup_reglist ||
1818: reglist[i].regs == gen8_1_0_pwrup_reglist ||
1819: reglist[i].regs == gen8_3_0_pwrup_reglist ||
1820: reglist[i].regs == gen8_2_0_pwrup_reglist ||
1821: reglist[i].regs == gen8_11_0_pwrup_reglist) &&
1822: (nc_overrides[j].list_type == 2)) {
1823: *dest++ = nc_overrides[j].offset;
1824: kgsl_regread(device, nc_overrides[j].offset, dest++);
1825: lock->preemption_list_len++;
1826: }
1827: }
1828: mutex_unlock(&gen8_dev->nc_mutex);
1829:
1830: }
1831:
1832: /*
1833: * The overall register list is composed of
1834: * 1. Static IFPC-only registers
1835: * 2. Static IFPC + preemption registers
1836: * 3. Dynamic IFPC + preemption registers (ex: perfcounter selects)
1837: *
1838: * The first two lists are static. Size of these lists are stored as
1839: * number of pairs in ifpc_list_len and preemption_list_len
1840: * respectively. With concurrent binning, Some of the perfcounter
1841: * registers being virtualized, CP needs to know the pipe id to program
1842: * the aperture inorder to restore the same. Thus, third list is a
1843: * dynamic list with triplets as
1844: * (<aperture, shifted 12 bits> <address> <data>), and the length is
1845: * stored as number for triplets in dynamic_list_len.
1846: *
1847: * Starting with Gen8, some of the registers that are initialized statically
1848: * by the kernel are pipe-specific. Because only the dynamic list is able to
1849: * support specifying a pipe ID, these registers are bundled along with any
1850: * dynamic entries such as perf counter selects into a single dynamic list.
1851: */
1852:
1853: gen8_dev->ext_pwrup_list_len = 0;
1854:
1855: /*
1856: * Write external pipe specific regs (<aperture> <address> <value> - triplets)
1857: * offset and the current value into GPU buffer
1858: */
1859: for (pipe_id = PIPE_BR; pipe_id <= PIPE_DDE_BV; pipe_id++) {
1860: const struct gen8_pwrup_extlist *ext_list;
1861: u32 ext_len;
1862:
1863: if (adreno_is_gen8_2_x(adreno_dev)) {
MATCH LINES: 2130, 2138
2118: * and UCHE_CCHE_TRAP_BASE respectively, effectively disabling L2 bypass
2119: */
2120: kgsl_regwrite(device, GEN8_UCHE_TRAP_BASE_LO, lower_32_bits(uche_trap_base));
2121: kgsl_regwrite(device, GEN8_UCHE_TRAP_BASE_HI, upper_32_bits(uche_trap_base));
2122: kgsl_regwrite(device, GEN8_UCHE_WRITE_THRU_BASE_LO, lower_32_bits(uche_trap_base));
2123: kgsl_regwrite(device, GEN8_UCHE_WRITE_THRU_BASE_HI, upper_32_bits(uche_trap_base));
2124: kgsl_regwrite(device, GEN8_UCHE_CCHE_TRAP_BASE_LO, lower_32_bits(uche_trap_base));
2125: kgsl_regwrite(device, GEN8_UCHE_CCHE_TRAP_BASE_HI, upper_32_bits(uche_trap_base));
2126: kgsl_regwrite(device, GEN8_UCHE_CCHE_WRITE_THRU_BASE_LO, lower_32_bits(uche_trap_base));
2127: kgsl_regwrite(device, GEN8_UCHE_CCHE_WRITE_THRU_BASE_HI, upper_32_bits(uche_trap_base));
2128:
2129: /*
2130: * CP takes care of the restore during IFPC exit. We need to restore at slumber
2131: * boundary as well
2132: */
2133: if (pwrup_lock->dynamic_list_len - gen8_dev->ext_pwrup_list_len > 0) {
2134: kgsl_regwrite(device, GEN8_RBBM_PERFCTR_CNTL, 0x1);
2135: kgsl_regwrite(device, GEN8_RBBM_SLICE_PERFCTR_CNTL, 0x1);
2136: }
2137:
2138: /* Turn on the IFPC counter (countable 4 on XOCLK4) */
2139: kgsl_regwrite(device, GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_1,
2140: FIELD_PREP(GENMASK(7, 0), 0x4));
2141:
2142: /* Turn on counter to count total time spent in BCL throttle */
2143: if (adreno_dev->bcl_enabled)
2144: kgsl_regrmw(device, GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_1, GENMASK(15, 8),
2145: FIELD_PREP(GENMASK(15, 8), 0x26));
2146:
2147: if (adreno_dev->highest_bank_bit) {
2148: hbb = adreno_dev->highest_bank_bit - MIN_HBB;
2149: hbb_lo = hbb & 3;
2150: hbb_hi = (hbb >> 2) & 1;
2151: }
2152:
2153: mal = (mal == 64) ? 1 : 0;
2154:
2155: gen8_regwrite_aperture(device, GEN8_GRAS_NC_MODE_CNTL,
2156: FIELD_PREP(GENMASK(8, 5), hbb), PIPE_BV, 0, 0);
2157: gen8_regwrite_aperture(device, GEN8_GRAS_NC_MODE_CNTL,
2158: FIELD_PREP(GENMASK(8, 5), hbb), PIPE_BR, 0, 0);
2159: gen8_regwrite_aperture(device, GEN8_RB_CCU_NC_MODE_CNTL,
2160: FIELD_PREP(GENMASK(6, 6), ubwc_props->yuvnotcomptofc) |
2161: FIELD_PREP(GENMASK(3, 3), hbb_hi) |
2162: FIELD_PREP(GENMASK(2, 1), hbb_lo),
MATCH LINES: 2566, 2570, 2574
2554: adreno_dev->patch_reglist = true;
2555: }
2556:
2557: ret = gen8_post_start(adreno_dev);
2558: if (!ret && (adreno_is_gen8_2_x(adreno_dev) || adreno_is_gen8_1_0(adreno_dev) ||
2559: adreno_is_gen8_10_0(adreno_dev)))
2560: gen8_hwcg_set(adreno_dev, true);
2561:
2562: return ret;
2563: }
2564:
2565: /*
2566: * gen8_gpu_keepalive() - GMU reg write to request GPU stays on
2567: * @adreno_dev: Pointer to the adreno device that has the GMU
2568: * @state: State to set: true is ON, false is OFF
2569: */
2570: static void gen8_gpu_keepalive(struct adreno_device *adreno_dev,
2571: bool state)
2572: {
2573: gmu_core_regwrite(KGSL_DEVICE(adreno_dev),
2574: GEN8_GMUCX_PWR_COL_KEEPALIVE, state);
2575: }
2576:
2577: bool gen8_hw_isidle(struct adreno_device *adreno_dev)
2578: {
2579: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2580: u32 reg;
2581:
2582: gmu_core_regread(device, GEN8_GMUAO_GPU_CX_BUSY_STATUS, ®);
2583:
2584: /* Bit 23 is GPUBUSYIGNAHB */
2585: return (reg & BIT(23)) ? false : true;
2586: }
2587:
2588: int gen8_microcode_read(struct adreno_device *adreno_dev)
2589: {
2590: struct adreno_firmware *sqe_fw = ADRENO_FW(adreno_dev, ADRENO_FW_SQE);
2591: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev);
2592:
2593: return adreno_get_firmware(adreno_dev, gen8_core->sqefw_name, sqe_fw);
2594: }
2595:
2596: static void gen8_get_cp_hwfault_status(struct adreno_device *adreno_dev, u32 status)
2597: {
2598: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
MATCH LINES: 2835
2823: kgsl_mutex_unlock(&device->mutex);
2824: goto regread_fail;
2825: }
2826:
2827: if (!gen8_gmu_rpmh_pwr_state_is_active(device) || !adreno_gx_is_on(adreno_dev)) {
2828: kgsl_mutex_unlock(&device->mutex);
2829: goto regread_fail;
2830: }
2831:
2832: kgsl_regread(device, GEN8_UCHE_CLIENT_PF, &uche_client_id);
2833: kgsl_mutex_unlock(&device->mutex);
2834:
2835: /* Ignore the value if the gpu is in IFPC */
2836: if (uche_client_id == SCOOBYDOO) {
2837: uche_client_id = adreno_dev->uche_client_pf;
2838: goto regread_fail;
2839: }
2840:
2841: /* UCHE client id mask is bits [6:0] */
2842: uche_client_id &= GENMASK(6, 0);
2843:
2844: regread_fail:
2845: if (lpac) {
2846: fault_block = "UCHE_LPAC";
2847: if (uche_client_id >= ARRAY_SIZE(uche_lpac_client))
2848: goto fail;
2849: uche_client_str = uche_lpac_client[uche_client_id];
2850: } else {
2851: fault_block = "UCHE";
2852: if (uche_client_id >= ARRAY_SIZE(uche_client))
2853: goto fail;
2854: uche_client_str = uche_client[uche_client_id];
2855: }
2856:
2857: snprintf(str, size, "%s: %s", fault_block, uche_client_str);
2858: return str;
2859:
MATCH LINES: 3072, 3074, 3084, 3086, 3100, 3102, 3118, 3120
3060: return 0;
3061: }
3062:
3063: static irqreturn_t gen8_hwsched_irq_handler(struct adreno_device *adreno_dev)
3064: {
3065: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
3066: irqreturn_t ret = IRQ_NONE;
3067: u32 status;
3068:
3069: /*
3070: * GPU can power down once the INT_0_STATUS is read below.
3071: * But there still might be some register reads required so
3072: * force the GMU/GPU into KEEPALIVE mode until done with the ISR.
3073: */
3074: gen8_gpu_keepalive(adreno_dev, true);
3075:
3076: kgsl_regread(device, GEN8_RBBM_INT_0_STATUS, &status);
3077:
3078: kgsl_regwrite(device, GEN8_RBBM_INT_CLEAR_CMD, status);
3079:
3080: ret = adreno_irq_callbacks(adreno_dev, gen8_irq_funcs, status);
3081:
3082: trace_kgsl_gen8_irq_status(adreno_dev, status);
3083:
3084: /* If hard fault, then let snapshot turn off the keepalive */
3085: if (!(adreno_gpu_fault(adreno_dev) & ADRENO_HARD_FAULT))
3086: gen8_gpu_keepalive(adreno_dev, false);
3087:
3088: return ret;
3089: }
3090:
3091: static irqreturn_t gen8_irq_handler(struct adreno_device *adreno_dev)
3092: {
3093: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
3094: irqreturn_t ret = IRQ_NONE;
3095: u32 status;
3096:
3097: /*
3098: * GPU can power down once the INT_0_STATUS is read below.
3099: * But there still might be some register reads required so
3100: * force the GMU/GPU into KEEPALIVE mode until done with the ISR.
3101: */
3102: gen8_gpu_keepalive(adreno_dev, true);
3103:
3104: if (gen8_irq_poll_fence(adreno_dev)) {
3105: adreno_scheduler_fault(adreno_dev, ADRENO_GMU_FAULT);
3106: goto done;
3107: }
3108:
3109: kgsl_regread(device, GEN8_RBBM_INT_0_STATUS, &status);
3110:
3111: kgsl_regwrite(device, GEN8_RBBM_INT_CLEAR_CMD, status);
3112:
3113: ret = adreno_irq_callbacks(adreno_dev, gen8_irq_funcs, status);
3114:
3115: trace_kgsl_gen8_irq_status(adreno_dev, status);
3116:
3117: done:
3118: /* If hard fault, then let snapshot turn off the keepalive */
3119: if (!(adreno_gpu_fault(adreno_dev) & ADRENO_HARD_FAULT))
3120: gen8_gpu_keepalive(adreno_dev, false);
3121:
3122: return ret;
3123: }
3124:
3125: static irqreturn_t gen8_cx_host_irq_handler(int irq, void *data)
3126: {
3127: struct kgsl_device *device = data;
3128: u32 status;
3129:
3130: kgsl_regread(device, GEN8_GPU_CX_MISC_INT_0_STATUS, &status);
3131: kgsl_regwrite(device, GEN8_GPU_CX_MISC_INT_CLEAR_CMD, status);
3132:
3133: if (status & BIT(GEN8_CX_MISC_GPU_CC_IRQ))
3134: KGSL_PWRCTRL_LOG_FREQLIM(device);
3135:
3136: if (status & ~GEN8_CX_MISC_INT_MASK)
3137: dev_err_ratelimited(device->dev, "Unhandled CX MISC interrupts 0x%lx\n",
3138: status & ~GEN8_CX_MISC_INT_MASK);
3139:
3140: return IRQ_HANDLED;
3141: }
3142:
3143: int gen8_probe_common(struct platform_device *pdev,
3144: struct adreno_device *adreno_dev, u32 chipid,
MATCH LINES: 3305
3293: {
3294: kgsl_regwrite(KGSL_DEVICE(adreno_dev), GEN8_CP_SEMAPHORE_REG_0, 0);
3295: }
3296:
3297: int gen8_perfcounter_remove(struct adreno_device *adreno_dev,
3298: struct adreno_perfcount_register *reg, u32 groupid)
3299: {
3300: const struct adreno_perfcounters *counters = ADRENO_PERFCOUNTERS(adreno_dev);
3301: struct gen8_device *gen8_dev = container_of(adreno_dev, struct gen8_device, adreno_dev);
3302: const struct adreno_perfcount_group *group;
3303: void *ptr = adreno_dev->pwrup_reglist->hostptr;
3304: struct cpu_gpu_lock *lock = ptr;
3305: u32 offset = ((lock->ifpc_list_len + lock->preemption_list_len) * 2) +
3306: (gen8_dev->ext_pwrup_list_len * 3);
3307: int i, last_offset, num_removed, start_offset = -1;
3308: u32 *data = ptr + sizeof(*lock), pipe = FIELD_PREP(GENMASK(13, 12), _get_pipeid(groupid));
3309: u16 perfcntr_list_len = lock->dynamic_list_len - gen8_dev->ext_pwrup_list_len;
3310:
3311: if (!perfcntr_list_len)
3312: return -EINVAL;
3313:
3314: group = &(counters->groups[groupid]);
3315:
3316: if (!(group->flags & ADRENO_PERFCOUNTER_GROUP_RESTORE)) {
3317: if (perfcntr_list_len != 2)
3318: return 0;
3319:
3320: if (kgsl_hwlock(lock)) {
3321: kgsl_hwunlock(lock);
3322: return -EBUSY;
3323: }
3324: goto disable_perfcounter;
3325: }
3326:
3327: last_offset = offset + (perfcntr_list_len * 3);
3328:
3329: /* Look for the perfcounter to remove in the list */
MATCH LINES: 3381
3369: }
3370:
3371: kgsl_hwunlock(lock);
3372: return 0;
3373: }
3374:
3375: int gen8_perfcounter_update(struct adreno_device *adreno_dev,
3376: struct adreno_perfcount_register *reg, bool update_reg, u32 pipe, unsigned long flags)
3377: {
3378: struct gen8_device *gen8_dev = container_of(adreno_dev, struct gen8_device, adreno_dev);
3379: void *ptr = adreno_dev->pwrup_reglist->hostptr;
3380: struct cpu_gpu_lock *lock = ptr;
3381: u32 offset = ((lock->ifpc_list_len + lock->preemption_list_len) * 2) +
3382: (gen8_dev->ext_pwrup_list_len * 3);
3383: u32 *data = ptr + sizeof(*lock);
3384: u64 reglist_size_dwords = adreno_dev->pwrup_reglist->size / sizeof(u32);
3385: u64 lock_size_dwords = sizeof(*lock) / sizeof(u32);
3386: int i, start_offset = -1;
3387: u16 perfcntr_list_len = lock->dynamic_list_len - gen8_dev->ext_pwrup_list_len;
3388: unsigned long irq_flags;
3389: int ret = 0;
3390: u32 num_dependencies = 0;
3391: u32 pending_triplets = 2;
3392:
3393: if (!ADRENO_ACQUIRE_CP_SEMAPHORE(adreno_dev, irq_flags))
3394: return -EBUSY;
3395:
3396: if (flags & ADRENO_PERFCOUNTER_GROUP_RESTORE) {
3397: for (i = 0; i < PERFCOUNTER_REG_DEPENDENCY_LEN && reg->reg_dependency[i]; i++)
3398: num_dependencies++;
3399:
3400: /* Number of triplets to add: 1 main + dependencies + 2 controls */
3401: pending_triplets += num_dependencies + 1;
3402:
3403: for (i = 0; i < perfcntr_list_len - 2; i++) {
3404: if ((data[offset + 1] == reg->select) && (data[offset] == pipe)) {
3405: start_offset = offset;
MATCH LINES: 3569, 3570, 3572, 3574, 3575, 3576
3557: adreno_dev->starved_ram_lo_ch1,
3558: &busy->bif_starved_ram_ch1);
3559:
3560: stats->ram_time = ram_cycles;
3561: stats->ram_wait = starved_ram;
3562: }
3563:
3564: static void gen8_power_feature_stats(struct adreno_device *adreno_dev)
3565: {
3566: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
3567: struct adreno_busy_data *busy = &adreno_dev->busy_data;
3568:
3569: if (ADRENO_FEATURE(adreno_dev, ADRENO_IFPC)) {
3570: u32 ifpc = counter_delta(device,
3571: GEN8_GMUCX_POWER_COUNTER_XOCLK_L_4,
3572: &busy->num_ifpc);
3573:
3574: adreno_dev->ifpc_count += ifpc;
3575: if (ifpc > 0)
3576: trace_adreno_ifpc_count(adreno_dev->ifpc_count);
3577: }
3578:
3579: if (adreno_dev->bcl_enabled) {
3580: u32 a, b, c, bcl_throttle;
3581:
3582: a = counter_delta(device, GEN8_GMUCX_POWER_COUNTER_XOCLK_L_1,
3583: &busy->throttle_cycles[0]);
3584:
3585: b = counter_delta(device, GEN8_GMUCX_POWER_COUNTER_XOCLK_L_2,
3586: &busy->throttle_cycles[1]);
3587:
3588: c = counter_delta(device, GEN8_GMUCX_POWER_COUNTER_XOCLK_L_3,
3589: &busy->throttle_cycles[2]);
3590:
3591: if (a || b || c)
3592: trace_kgsl_bcl_clock_throttling(a, b, c);
3593:
3594: bcl_throttle = counter_delta(device,
3595: GEN8_GMUCX_POWER_COUNTER_XOCLK_L_5, &busy->bcl_throttle);
3596: /*
3597: * This counts number of cycles throttled in XO cycles. Convert it to
3598: * micro seconds by dividing by XO freq which is 19.2MHz.
3599: */
3600: adreno_dev->bcl_throttle_time_us += ((bcl_throttle * 10) / 192);
MATCH LINES: 3857, 3888, 3894
3845:
3846: const struct gen8_gpudev adreno_gen8_hwsched_gpudev = {
3847: .base = {
3848: .reg_offsets = gen8_register_offsets,
3849: .probe = gen8_hwsched_probe,
3850: .snapshot = gen8_hwsched_snapshot,
3851: .irq_handler = gen8_hwsched_irq_handler,
3852: .iommu_fault_block = gen8_iommu_fault_block,
3853: .context_detach = gen8_hwsched_context_detach,
3854: .read_alwayson = gen8_read_alwayson,
3855: .reset = gen8_hwsched_reset_replay,
3856: .soft_reset = gen8_hwsched_soft_reset,
3857: .power_ops = &gen8_hwsched_power_ops,
3858: .power_stats = gen8_power_stats,
3859: .hw_isidle = gen8_hw_isidle,
3860: .add_to_va_minidump = gen8_hwsched_add_to_minidump,
3861: .gx_is_on = gen8_gmu_gx_is_on,
3862: .send_recurring_cmdobj = gen8_hwsched_send_recurring_cmdobj,
3863: .perfcounter_remove = gen8_perfcounter_remove,
3864: .set_isdb_breakpoint_registers = gen8_set_isdb_breakpoint_registers,
3865: .context_destroy = gen8_hwsched_context_destroy,
3866: .lpac_store = gen8_lpac_store,
3867: .get_uche_trap_base = gen8_get_uche_trap_base,
3868: .fault_header = gen8_fault_header,
3869: .lpac_fault_header = gen8_lpac_fault_header,
3870: .power_feature_stats = gen8_power_feature_stats,
3871: .acquire_cp_semaphore = gen8_acquire_cp_semaphore,
3872: .release_cp_semaphore = gen8_release_cp_semaphore,
3873: .get_gmem_size = gen8_get_gmem_size,
3874: .read_speedbin = gen8_read_softfuse_speedbin,
3875: },
3876: .hfi_probe = gen8_hwsched_hfi_probe,
3877: .hfi_remove = gen8_hwsched_hfi_remove,
3878: .handle_watchdog = gen8_hwsched_handle_watchdog,
3879: };
3880:
3881: const struct gen8_gpudev adreno_gen8_gmu_gpudev = {
3882: .base = {
3883: .reg_offsets = gen8_register_offsets,
3884: .probe = gen8_gmu_device_probe,
3885: .snapshot = gen8_gmu_snapshot,
3886: .irq_handler = gen8_irq_handler,
3887: .rb_start = gen8_rb_start,
3888: .gpu_keepalive = gen8_gpu_keepalive,
3889: .hw_isidle = gen8_hw_isidle,
3890: .iommu_fault_block = gen8_iommu_fault_block,
3891: .reset = gen8_gmu_reset,
3892: .preemption_schedule = gen8_preemption_schedule,
3893: .read_alwayson = gen8_read_alwayson,
3894: .power_ops = &gen8_gmu_power_ops,
3895: .remove = gen8_remove,
3896: .ringbuffer_submitcmd = gen8_ringbuffer_submitcmd,
3897: .power_stats = gen8_power_stats,
3898: .add_to_va_minidump = gen8_gmu_add_to_minidump,
3899: .gx_is_on = gen8_gmu_gx_is_on,
3900: .perfcounter_remove = gen8_perfcounter_remove,
3901: .set_isdb_breakpoint_registers = gen8_set_isdb_breakpoint_registers,
3902: .swfuse_irqctrl = gen8_swfuse_irqctrl,
3903: .get_uche_trap_base = gen8_get_uche_trap_base,
3904: .fault_header = gen8_fault_header,
3905: .acquire_cp_semaphore = gen8_acquire_cp_semaphore,
3906: .release_cp_semaphore = gen8_release_cp_semaphore,
3907: .get_gmem_size = gen8_get_gmem_size,
3908: .read_speedbin = gen8_read_softfuse_speedbin,
3909: },
3910: .hfi_probe = gen8_gmu_hfi_probe,
3911: .handle_watchdog = gen8_gmu_handle_watchdog,
3912: };
--- FILE: \adreno_gen8.h | HITS: 5 ---
MATCH LINES: 30, 31, 56, 57
18: #define GEN8_2_0_NUM_PHYSICAL_SLICES 3
19: #define GEN8_3_0_NUM_PHYSICAL_SLICES 1
20: #define GEN8_6_0_NUM_PHYSICAL_SLICES 2
21: #define GEN8_9_0_NUM_PHYSICAL_SLICES 2
22: #define GEN8_10_0_NUM_PHYSICAL_SLICES 3
23: #define GEN8_11_0_NUM_PHYSICAL_SLICES 3
24:
25: #define GET_SLICE_MASK(num_slices, value) FIELD_GET(GENMASK(num_slices, 0), (value))
26:
27: /* Forward struct declaration */
28: struct gen8_snapshot_block_list;
29:
30: extern const struct adreno_power_ops gen8_gmu_power_ops;
31: extern const struct adreno_power_ops gen8_hwsched_power_ops;
32: extern const struct adreno_perfcounters adreno_gen8_perfcounters;
33: extern const struct adreno_perfcounters adreno_gen8_2_x_perfcounters;
34:
35: struct gen8_gpudev {
36: struct adreno_gpudev base;
37: int (*hfi_probe)(struct adreno_device *adreno_dev);
38: void (*hfi_remove)(struct adreno_device *adreno_dev);
39: void (*handle_watchdog)(struct adreno_device *adreno_dev);
40: };
41:
42: extern const struct gen8_gpudev adreno_gen8_gmu_gpudev;
43: extern const struct gen8_gpudev adreno_gen8_hwsched_gpudev;
44:
45: struct gen8_nonctxt_overrides {
46: /** offset: Dword offset of the register to write */
47: u32 offset;
48: /** pipelines: Pipelines to write */
49: u32 pipelines;
50: /** val: Value to be written to the register */
51: u32 val;
52: /** set: True for user override request */
53: bool set;
54: /**
55: * list_type: 0 If the register already present in any of exisiting static pwrup list
56: 1 if the register fits into IFPC static pwrup only list
57: 2 if the register fits into IFPC + preemption static list
58: 3 if the register fits into external powerup list
59: */
60: u32 list_type;
61: };
62:
63: /**
64: * struct gen8_device - Container for the gen8_device
65: */
66: struct gen8_device {
67: /** @gmu: Container for the gen8 GMU device */
68: struct gen8_gmu_device gmu;
69: /** @adreno_dev: Container for the generic adreno device */
70: struct adreno_device adreno_dev;
71: /** @aperture: The last value that the host aperture register was programmed to */
72: u32 aperture;
73: /** @ext_pwrup_list_len: External pwrup reglist length */
74: u16 ext_pwrup_list_len;
75: /**
76: * @nc_overrides: Noncontext registers overrides whitelist if defined,
77: * must be null terminated
78: */
79: struct gen8_nonctxt_overrides *nc_overrides;
80: /** @nc_mutex: Mutex to protect nc_overrides updates */
81: struct mutex nc_mutex;
MATCH LINES: 486
474: const struct adreno_gpu_core *gpucore);
475:
476: /**
477: * gen8_spin_idle_debug - Debug logging used when gpu fails to idle
478: * @adreno_dev: An Adreno GPU handle
479: *
480: * This function logs interesting registers and triggers a snapshot
481: */
482: void gen8_spin_idle_debug(struct adreno_device *adreno_dev,
483: const char *str);
484:
485: /**
486: * gen8_perfcounter_update - Update the IFPC perfcounter list
487: * @adreno_dev: An Adreno GPU handle
488: * @reg: Perfcounter reg struct to add/remove to the list
489: * @update_reg: true if the perfcounter needs to be programmed by the CPU
490: * @pipe: pipe id for CP aperture control
491: * @flags: Flags set for requested perfcounter group
492: *
493: * Return: 0 on success or -EBUSY if the lock couldn't be taken
494: */
495: int gen8_perfcounter_update(struct adreno_device *adreno_dev,
496: struct adreno_perfcount_register *reg, bool update_reg, u32 pipe,
497: unsigned long flags);
498:
499: /*
500: * gen8_ringbuffer_init - Initialize the ringbuffers
501: * @adreno_dev: An Adreno GPU handle
502: *
503: * Initialize the ringbuffer(s) for a5xx.
504: * Return: 0 on success or negative on failure
505: */
506: int gen8_ringbuffer_init(struct adreno_device *adreno_dev);
507:
508: /**
509: * gen8_ringbuffer_submitcmd - Submit a user command to the ringbuffer
510: * @adreno_dev: An Adreno GPU handle
--- FILE: \adreno_gen8_gmu.c | HITS: 31 ---
MATCH LINES: 240
228: return &gen8_dev->gmu;
229: }
230:
231: struct adreno_device *gen8_gmu_to_adreno(struct gen8_gmu_device *gmu)
232: {
233: struct gen8_device *gen8_dev =
234: container_of(gmu, struct gen8_device, gmu);
235:
236: return &gen8_dev->adreno_dev;
237: }
238:
239: /* Configure and enable GMU low power mode */
240: static void gen8_gmu_power_config(struct adreno_device *adreno_dev)
241: {
242: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
243:
244: /* Disable GMU WB/RB buffer and caches at boot */
245: gmu_core_regwrite(device, GEN8_GMUCX_SYS_BUS_CONFIG, 0x1);
246: gmu_core_regwrite(device, GEN8_GMUCX_ICACHE_CONFIG, 0x1);
247: gmu_core_regwrite(device, GEN8_GMUCX_DCACHE_CONFIG, 0x1);
248: }
249:
250: static void gmu_ao_sync_event(struct adreno_device *adreno_dev)
251: {
252: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
253: unsigned long flags;
254: u64 ticks;
255:
256: /*
257: * Get the GMU always on ticks and log it in a trace message. This
258: * will be used to map GMU ticks to ftrace time. Do this in atomic
259: * context to ensure nothing happens between reading the always
260: * on ticks and doing the trace.
261: */
262:
263: local_irq_save(flags);
264:
MATCH LINES: 688, 689, 705, 716, 732, 744, 758
676: bool gen8_gmu_rpmh_pwr_state_is_active(struct kgsl_device *device)
677: {
678: u32 val;
679:
680: gmu_core_regread(device, GEN8_GMUCX_RPMH_POWER_STATE, &val);
681: return (val == GPU_HW_ACTIVE) ? true : false;
682: }
683:
684: static const char *idle_level_name(int level)
685: {
686: if (level == GPU_HW_ACTIVE)
687: return "GPU_HW_ACTIVE";
688: else if (level == GPU_HW_IFPC)
689: return "GPU_HW_IFPC";
690: else if (level == GPU_HW_MINBW)
691: return "GPU_HW_MINBW";
692:
693: return "(Unknown)";
694: }
695:
696: int gen8_gmu_wait_for_lowest_idle(struct adreno_device *adreno_dev)
697: {
698: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
699: struct device *gmu_pdev_dev = GMU_PDEV_DEV(device);
700: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
701: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
702: u32 reg, reg1, reg2, reg3, reg4;
703: unsigned long t;
704: u64 ts1, ts2;
705: u32 wait_level = adreno_dev->minbw_enabled ? GPU_HW_MINBW : GPU_HW_IFPC;
706:
707: ts1 = gpudev->read_alwayson(adreno_dev);
708:
709: t = jiffies + msecs_to_jiffies(100);
710: do {
711: gmu_core_regread(device,
712: GEN8_GMUCX_RPMH_POWER_STATE, ®);
713: gmu_core_regread(device, GEN8_GMUCX_GFX_PWR_CLK_STATUS, ®1);
714:
715: /*
716: * Check that we are at lowest level. If lowest level is IFPC
717: * or MINBW double check that GFX clock is off.
718: */
719: if (gmu->idle_level == reg)
720: if (!(gmu->idle_level == wait_level && is_on(reg1)))
721: return 0;
722:
723: /* Wait 100us to reduce unnecessary AHB bus traffic */
724: usleep_range(10, 100);
725: } while (!time_after(jiffies, t));
726:
727: /* Check one last time */
728: gmu_core_regread(device, GEN8_GMUCX_RPMH_POWER_STATE, ®);
729: gmu_core_regread(device, GEN8_GMUCX_GFX_PWR_CLK_STATUS, ®1);
730:
731: /*
732: * Check that we are at lowest level. If lowest level is IFPC
733: * or MINBW double check that GFX clock is off.
734: */
735: if (gmu->idle_level == reg)
736: if (!(gmu->idle_level == wait_level && is_on(reg1)))
737: return 0;
738:
739: ts2 = gpudev->read_alwayson(adreno_dev);
740:
741: /* Collect abort data to help with debugging */
742: gmu_core_regread(device, GEN8_GMUAO_GPU_CX_BUSY_STATUS, ®2);
743: gmu_core_regread(device, GEN8_GMUAO_RBBM_INT_UNMASKED_STATUS_SHADOW, ®3);
744: gmu_core_regread(device, GEN8_GMUCX_PWR_COL_KEEPALIVE, ®4);
745:
746: dev_err(gmu_pdev_dev,
747: "----------------------[ GMU error ]----------------------\n");
748: dev_err(gmu_pdev_dev,
749: "Timeout waiting for lowest idle level %s : wait level %s\n",
750: idle_level_name(gmu->idle_level), idle_level_name(reg));
751: dev_err(gmu_pdev_dev, "Start: %llx (absolute ticks)\n", ts1);
752: dev_err(gmu_pdev_dev,
753: "Poll: %llx (ticks relative to start)\n", ts2-ts1);
754: dev_err(gmu_pdev_dev,
755: "RPMH_POWER_STATE=%x GFX_PWR_CLK_STATUS=%x\n", reg, reg1);
756: dev_err(gmu_pdev_dev, "CX_BUSY_STATUS=%x\n", reg2);
757: dev_err(gmu_pdev_dev,
758: "RBBM_INT_UNMASKED_STATUS=%x PWR_COL_KEEPALIVE=%x\n", reg3, reg4);
759:
760: /* Access GX registers only when GX is ON */
761: if (is_on(reg1)) {
762: gen8_regread_aperture(device, GEN8_CP_PIPE_STATUS_PIPE, ®, PIPE_BV, 0, 0);
763: gen8_regread_aperture(device, GEN8_CP_PIPE_STATUS_PIPE, ®1, PIPE_BR, 0, 0);
764: /* Clear aperture register */
765: gen8_host_aperture_set(adreno_dev, 0, 0, 0);
766: kgsl_regread(device, GEN8_CP_CP2GMU_STATUS, ®2);
767: kgsl_regread(device, GEN8_CP_CONTEXT_SWITCH_CNTL, ®3);
768:
769: dev_err(gmu_pdev_dev,
770: "GEN8_CP_PIPE_STATUS_PIPE BV:%x BR:%x\n", reg, reg1);
771: dev_err(gmu_pdev_dev,
772: "CP2GMU_STATUS=%x CONTEXT_SWITCH_CNTL=%x\n", reg2, reg3);
773: }
774:
775: WARN_ON(1);
776: gmu_core_fault_snapshot(device, GMU_FAULT_WAIT_FOR_LOWEST_IDLE);
777: return -ETIMEDOUT;
778: }
779:
780: /* Bitmask for GPU idle status check */
781: #define CXGXCPUBUSYIGNAHB BIT(30)
782: int gen8_gmu_wait_for_idle(struct adreno_device *adreno_dev)
MATCH LINES: 925
913: gmu->log_wptr_retention);
914:
915: /* Pass chipid to GMU FW, must happen before starting GMU */
916: gmu_core_regwrite(device, GEN8_GMUCX_GENERAL_10,
917: ADRENO_GMU_REV(ADRENO_GPUREV(adreno_dev)));
918:
919: /* Log size is encoded in (number of 4K units - 1) */
920: val = (gmu->gmu_log->gmuaddr & GENMASK(31, 12)) |
921: ((GMU_LOG_SIZE/SZ_4K - 1) & GENMASK(7, 0));
922: gmu_core_regwrite(device, GEN8_GMUCX_GENERAL_8, val);
923:
924: /* Configure power control and bring the GMU out of reset */
925: gen8_gmu_power_config(adreno_dev);
926:
927: /*
928: * Enable BCL throttling -
929: * XOCLK1: countable: 0x13 (25% throttle)
930: * XOCLK2: countable: 0x17 (58% throttle)
931: * XOCLK3: countable: 0x19 (75% throttle)
932: * POWER_CONTROL_SELECT_0 controls counters 0 - 3, each selector
933: * is 8 bits wide.
934: */
935: if (adreno_dev->bcl_enabled)
936: gmu_core_regrmw(device, GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_0,
937: 0xffffff00, FIELD_PREP(GENMASK(31, 24), 0x19) |
938: FIELD_PREP(GENMASK(23, 16), 0x17) |
939: FIELD_PREP(GENMASK(15, 8), 0x13));
940:
941: }
942:
943: static int gen8_gmu_process_caps(struct gen8_gmu_device *gmu,
944: struct gmu_core_device *gmu_core, struct gmu_block_header *blk, u32 offset)
945: {
946: struct firmware_capabilities *caps;
947: const u8 *payload = (const u8 *)&gmu->fw_image->data[offset];
948:
949: if (!blk->size)
MATCH LINES: 1264
1252: dev_err(GMU_PDEV_DEV(device), "gx is stuck on\n");
1253: }
1254:
1255: /*
1256: * gen8_gmu_notify_slumber() - initiate request to GMU to prepare to slumber
1257: * @device: Pointer to KGSL device
1258: */
1259: static int gen8_gmu_notify_slumber(struct adreno_device *adreno_dev)
1260: {
1261: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1262: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1263: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
1264: int bus_level = pwr->pwrlevels[pwr->default_pwrlevel].bus_freq;
1265: int perf_idx = gmu->dcvs_table.gpu_level_num -
1266: pwr->default_pwrlevel - 1;
1267: struct hfi_prep_slumber_cmd req = {
1268: .freq = perf_idx,
1269: .bw = bus_level,
1270: };
1271: int ret;
1272:
1273: req.bw |= adreno_gmu_bus_ab_quantize(adreno_dev, 0);
1274:
1275: /* Disable the power counter so that the GMU is not busy */
1276: gmu_core_regwrite(device, GEN8_GMUCX_POWER_COUNTER_ENABLE, 0);
1277:
1278: ret = CMD_MSG_HDR(req, H2F_MSG_PREPARE_SLUMBER);
1279: if (ret)
1280: return ret;
1281:
1282: ret = gen8_hfi_send_generic_req(adreno_dev, &req, sizeof(req));
1283:
1284: /* Make sure the fence is in ALLOW mode */
1285: gmu_core_regwrite(device, GEN8_GMUAO_AHB_FENCE_CTRL, 0);
1286:
1287: /*
1288: * GEMNOC can enter power collapse state during GPU power down sequence.
MATCH LINES: 1382, 1389, 1396, 1414, 1422, 1428, 1432
1370:
1371: if (req.freq != INVALID_DCVS_IDX)
1372: gmu_core_rdpm_mx_freq_update(device, table->gx_votes[req.freq].freq);
1373:
1374: return ret;
1375: }
1376:
1377: static int gen8_gmu_clock_set(struct adreno_device *adreno_dev, u32 pwrlevel)
1378: {
1379: return gen8_gmu_dcvs_set(adreno_dev, pwrlevel, INVALID_DCVS_IDX, INVALID_AB_VALUE);
1380: }
1381:
1382: static int gen8_gmu_ifpc_store(struct kgsl_device *device,
1383: u32 val)
1384: {
1385: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
1386: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
1387: u32 requested_idle_level;
1388:
1389: if (!ADRENO_FEATURE(adreno_dev, ADRENO_IFPC))
1390: return -EINVAL;
1391:
1392: if (val) {
1393: if (adreno_dev->minbw_enabled)
1394: requested_idle_level = GPU_HW_MINBW;
1395: else
1396: requested_idle_level = GPU_HW_IFPC;
1397: } else {
1398: requested_idle_level = GPU_HW_ACTIVE;
1399: }
1400:
1401: if (gmu->idle_level == requested_idle_level)
1402: return 0;
1403:
1404: /* Power down the GPU before changing the idle level */
1405: return adreno_power_cycle_u32(adreno_dev, &gmu->idle_level,
1406: requested_idle_level);
1407: }
1408:
1409: static void gen8_minbw_idle_level_set(struct kgsl_device *device, u32 val)
1410: {
1411: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
1412: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
1413:
1414: if (!ADRENO_FEATURE(adreno_dev, ADRENO_IFPC) ||
1415: (!ADRENO_FEATURE(adreno_dev, ADRENO_GMU_MINBW)) ||
1416: (gmu->idle_level == GPU_HW_ACTIVE))
1417: return;
1418:
1419: if (val)
1420: gmu->idle_level = GPU_HW_MINBW;
1421: else
1422: gmu->idle_level = GPU_HW_IFPC;
1423:
1424: adreno_dev->minbw_data = val;
1425: adreno_dev->minbw_enabled = val ? true : false;
1426: }
1427:
1428: static u32 gen8_gmu_ifpc_isenabled(struct kgsl_device *device)
1429: {
1430: struct gen8_gmu_device *gmu = to_gen8_gmu(ADRENO_DEVICE(device));
1431:
1432: return (gmu->idle_level == GPU_HW_IFPC) || (gmu->idle_level == GPU_HW_MINBW);
1433: }
1434:
1435: /* Send an NMI to the GMU */
1436: void gen8_gmu_send_nmi(struct kgsl_device *device, bool force,
1437: enum gmu_fault_panic_policy gf_policy)
1438: {
1439: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
1440: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
1441: u64 ticks = gpudev->read_alwayson(adreno_dev);
1442: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
1443: u32 result;
1444:
1445: /*
1446: * Do not send NMI if the SMMU is stalled because GMU will not be able
1447: * to save cm3 state to DDR.
1448: */
1449: if (gen8_gmu_gx_is_on(adreno_dev) && adreno_smmu_is_stalled(adreno_dev)) {
1450: dev_err(GMU_PDEV_DEV(device),
1451: "Skipping NMI because SMMU is stalled\n");
1452: goto done;
1453: }
1454:
1455: if (force)
1456: goto nmi;
MATCH LINES: 1897, 1898
1885: case 1:
1886: return ((u64) FIELD_GET(BCL_SID1_MASK, adreno_dev->bcl_data));
1887: case 2:
1888: return ((u64) FIELD_GET(BCL_SID2_MASK, adreno_dev->bcl_data));
1889: default:
1890: return 0;
1891: }
1892: }
1893:
1894: static const struct gmu_dev_ops gen8_gmudev = {
1895: .oob_set = gen8_gmu_oob_set,
1896: .oob_clear = gen8_gmu_oob_clear,
1897: .ifpc_store = gen8_gmu_ifpc_store,
1898: .ifpc_isenabled = gen8_gmu_ifpc_isenabled,
1899: .cooperative_reset = gen8_gmu_cooperative_reset,
1900: .wait_for_active_transition = gen8_gmu_wait_for_active_transition,
1901: .scales_bandwidth = gen8_gmu_scales_bandwidth,
1902: .acd_set = gen8_gmu_acd_set,
1903: .bcl_sid_set = gen8_bcl_sid_set,
1904: .bcl_sid_get = gen8_bcl_sid_get,
1905: .send_nmi = gen8_gmu_send_nmi,
1906: .minbw_idle_level_set = gen8_minbw_idle_level_set,
1907: };
1908:
1909: static int gen8_gmu_bus_set(struct adreno_device *adreno_dev, int buslevel,
1910: u32 ab)
1911: {
1912: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1913: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1914: int ret = 0;
1915:
1916: if (buslevel == pwr->cur_buslevel)
1917: buslevel = INVALID_DCVS_IDX;
1918:
1919: if ((ab == pwr->cur_ab) || ((ab == 0) && (adreno_dev->gmu_ab)))
1920: ab = INVALID_AB_VALUE;
1921:
1922: if ((ab == INVALID_AB_VALUE) && (buslevel == INVALID_DCVS_IDX))
MATCH LINES: 2083, 2084, 2086, 2087
2071: kfree(device->gmu_core.platform_caps.data);
2072: }
2073:
2074: gmu_core_free_globals(device);
2075:
2076: vfree(gmu->itcm_shadow);
2077: kobject_put(&gmu->log_kobj);
2078: kobject_put(&gmu->stats_kobj);
2079: kfree(gmu->dcvs_cmdbuf);
2080: kfree(gmu->gmu_scaling_cmdbuf);
2081: }
2082:
2083: /* Default IFPC timer (300usec) value */
2084: #define GEN8_GMU_LONG_IFPC_HYST FIELD_PREP(GENMASK(15, 0), 0x1680)
2085:
2086: /* Minimum IFPC timer (200usec) allowed to override default value */
2087: #define GEN8_GMU_LONG_IFPC_HYST_FLOOR FIELD_PREP(GENMASK(15, 0), 0x0F00)
2088:
2089: /* Offsets into the MX/CX mapped register regions */
2090: #define GEN8_RDPM_MX_OFFSET 0xf00
2091: #define GEN8_RDPM_CX_OFFSET 0xf14
2092:
2093: int gen8_gmu_probe(struct kgsl_device *device,
2094: struct platform_device *pdev)
2095: {
2096: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
2097: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev);
2098: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
2099: struct gmu_core_device *gmu_core = &device->gmu_core;
2100: u64 freq = gen8_core->gmu_hub_clk_freq;
2101: struct device *dev = &pdev->dev;
2102: int ret, i;
2103:
2104: adreno_dev->gmu_hub_clk_freq = freq ? freq : 150000000;
2105:
2106: gmu_core->pdev = pdev;
2107: memset(&gmu_core->common_caps, 0, sizeof(struct firmware_capabilities));
2108: memset(&gmu_core->platform_caps, 0, sizeof(struct firmware_capabilities));
2109: memset(&gmu_core->ver, 0, sizeof(gmu_core->ver));
2110:
2111: dma_coerce_mask_and_coherent(&gmu_core->pdev->dev, DMA_BIT_MASK(64));
MATCH LINES: 2164, 2170, 2171, 2172
2152: if (ret)
2153: goto error;
2154:
2155: if (ADRENO_FEATURE(adreno_dev, ADRENO_GMU_AB))
2156: adreno_dev->gmu_ab = true;
2157:
2158: /* Populates RPMh configurations */
2159: ret = gen8_build_rpmh_tables(adreno_dev);
2160: if (ret)
2161: goto error;
2162:
2163: /* Set up GMU idle state */
2164: if (ADRENO_FEATURE(adreno_dev, ADRENO_IFPC)) {
2165: if (ADRENO_FEATURE(adreno_dev, ADRENO_GMU_MINBW)) {
2166: gmu->idle_level = GPU_HW_MINBW;
2167: adreno_dev->minbw_enabled = true;
2168: adreno_dev->minbw_data = HFI_MINBW_DEFAULT;
2169: } else
2170: gmu->idle_level = GPU_HW_IFPC;
2171: adreno_dev->ifpc_hyst = GEN8_GMU_LONG_IFPC_HYST;
2172: adreno_dev->ifpc_hyst_floor = GEN8_GMU_LONG_IFPC_HYST_FLOOR;
2173: } else {
2174: gmu->idle_level = GPU_HW_ACTIVE;
2175: }
2176:
2177: gen8_gmu_acd_probe(device, gmu, pdev->dev.of_node);
2178:
2179: set_bit(GMU_ENABLED, &gmu_core->flags);
2180:
2181: gmu_core->dev_ops = &gen8_gmudev;
2182: gmu_core->gf_panic = GMU_FAULT_PANIC_NONE;
2183:
2184: /* Set default GMU attributes */
2185: gmu->log_stream_enable = false;
2186: gmu->log_group_mask = 0x3;
2187:
2188: /* Initialize to zero to detect trace packet loss */
2189: gmu_core->trace.seq_num = 0;
2190:
2191: /* Disabled by default */
2192: gmu->stats_enable = false;
2193: /* Set default to CM3 busy cycles countable */
2194: gmu->stats_mask = BIT(GEN8_GMU_CM3_BUSY_CYCLES);
2195: /* Interval is in 50 us units. Set default sampling frequency to 4x50 us */
2196: gmu->stats_interval = HFI_FEATURE_GMU_STATS_INTERVAL;
MATCH LINES: 2243
2231:
2232: /* Halt all AXI requests */
2233: kgsl_regwrite(device, GEN8_GBIF_HALT, GEN8_GBIF_ARB_HALT_MASK);
2234: ret = adreno_wait_for_halt_ack(device,
2235: GEN8_GBIF_HALT_ACK, GEN8_GBIF_ARB_HALT_MASK);
2236:
2237: /* De-assert the halts */
2238: kgsl_regwrite(device, GEN8_GBIF_HALT, 0x0);
2239:
2240: return ret;
2241: }
2242:
2243: static int gen8_gmu_power_off(struct adreno_device *adreno_dev)
2244: {
2245: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
2246: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2247: int ret = 0;
2248:
2249: if (device->gmu_fault)
2250: goto error;
2251:
2252: /* Wait for the lowest idle level we requested */
2253: ret = gen8_gmu_wait_for_lowest_idle(adreno_dev);
2254: if (ret)
2255: goto error;
2256:
2257: ret = gen8_complete_rpmh_votes(gmu, 2);
2258: if (ret)
2259: goto error;
2260:
2261: ret = gen8_gmu_notify_slumber(adreno_dev);
2262: if (ret)
2263: goto error;
2264:
2265: ret = gen8_gmu_wait_for_idle(adreno_dev);
2266: if (ret)
2267: goto error;
MATCH LINES: 2388
2376: adreno_dispatcher_start(device);
2377:
2378: device->reset_counter++;
2379:
2380: gen8_gmu_oob_clear(device, oob_gpu);
2381:
2382: return 0;
2383:
2384: oob_clear:
2385: gen8_gmu_oob_clear(device, oob_gpu);
2386:
2387: err:
2388: gen8_gmu_power_off(adreno_dev);
2389:
2390: return ret;
2391: }
2392:
2393: static void gmu_idle_timer(struct timer_list *t)
2394: {
2395: struct kgsl_device *device = container_of(t, struct kgsl_device,
2396: idle_timer);
2397:
2398: kgsl_schedule_work(&device->idle_check_ws);
2399: }
2400:
2401: static int gen8_boot(struct adreno_device *adreno_dev)
2402: {
2403: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
2404: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2405: int ret;
2406:
2407: if (WARN_ON(test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)))
2408: return 0;
2409:
2410: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE);
2411:
2412: ret = gen8_gmu_boot(adreno_dev);
MATCH LINES: 2564
2552: kgsl_pwrscale_update_stats(device);
2553:
2554: /* Save active coresight registers if applicable */
2555: adreno_coresight_stop(adreno_dev);
2556:
2557: adreno_irqctrl(adreno_dev, 0);
2558:
2559: no_gx_power:
2560: gen8_gmu_oob_clear(device, oob_gpu);
2561:
2562: kgsl_pwrctrl_irq(device, false);
2563:
2564: gen8_gmu_power_off(adreno_dev);
2565:
2566: adreno_set_active_ctxs_null(adreno_dev);
2567:
2568: adreno_dispatcher_stop(adreno_dev);
2569:
2570: adreno_ringbuffer_stop(adreno_dev);
2571:
2572: adreno_llcc_slice_deactivate(adreno_dev);
2573:
2574: clear_bit(GMU_PRIV_GPU_STARTED, &gmu->flags);
2575:
2576: kgsl_delete_timer_sync(&device->idle_timer);
2577:
2578: kgsl_pwrscale_sleep(device);
2579:
2580: kgsl_pwrctrl_clear_l3_vote(device);
2581:
2582: /*
2583: * Reset the context records so that CP can start
2584: * at the correct read pointer for BV thread after
2585: * coming out of slumber.
2586: */
2587: gen8_reset_preempt_records(adreno_dev);
2588:
MATCH LINES: 2788
2776:
2777: done:
2778: /*
2779: * When waking up from a touch event we want to stay active long enough
2780: * for the user to send a draw command. The default idle timer timeout
2781: * is shorter than we want so go ahead and push the idle timer out
2782: * further for this special case
2783: */
2784: mod_timer(&device->idle_timer, jiffies +
2785: msecs_to_jiffies(adreno_wake_timeout));
2786: }
2787:
2788: const struct adreno_power_ops gen8_gmu_power_ops = {
2789: .first_open = gen8_gmu_first_open,
2790: .last_close = gen8_gmu_last_close,
2791: .active_count_get = gen8_gmu_active_count_get,
2792: .pm_suspend = gen8_gmu_pm_suspend,
2793: .pm_resume = gen8_gmu_pm_resume,
2794: .touch_wakeup = gen8_gmu_touch_wakeup,
2795: .gpu_clock_set = gen8_gmu_clock_set,
2796: .gpu_bus_set = gen8_gmu_bus_set,
2797: };
2798:
2799: int gen8_gmu_device_probe(struct platform_device *pdev,
2800: u32 chipid, const struct adreno_gpu_core *gpucore)
2801: {
2802: struct adreno_device *adreno_dev;
2803: struct kgsl_device *device;
2804: struct gen8_device *gen8_dev;
2805: int ret;
2806:
2807: gen8_dev = devm_kzalloc(&pdev->dev, sizeof(*gen8_dev),
2808: GFP_KERNEL);
2809: if (!gen8_dev)
2810: return -ENOMEM;
2811:
2812: adreno_dev = &gen8_dev->adreno_dev;
--- FILE: \adreno_gen8_gmu.h | HITS: 2 ---
MATCH LINES: 285, 288
273:
274: /**
275: * gen8_gmu_oob_clear - clear an asserted oob request
276: * @device: Pointer to the kgsl device
277: * @req: Type of oob request as defined in enum oob_request
278: *
279: * Clear a previously requested oob so that gmu can power
280: * collapse the gpu
281: */
282: void gen8_gmu_oob_clear(struct kgsl_device *device, enum oob_request oob);
283:
284: /**
285: * gen8_gmu_wait_for_lowest_idle - wait for gmu to complete ifpc
286: * @adreno_dev: Pointer to the adreno device
287: *
288: * If ifpc is enabled, wait for gmu to put gpu into ifpc.
289: *
290: * Return: 0 on success or negative error on failure
291: */
292: int gen8_gmu_wait_for_lowest_idle(struct adreno_device *adreno_dev);
293:
294: /**
295: * gen8_gmu_wait_for_idle - Wait for gmu to become idle
296: * @adreno_dev: Pointer to the adreno device
297: *
298: * Return: 0 on success or negative error on failure
299: */
300: int gen8_gmu_wait_for_idle(struct adreno_device *adreno_dev);
301:
302: /**
303: * gen8_rscc_sleep_sequence - Trigger rscc sleep sequence
304: * @adreno_dev: Pointer to the adreno device
305: *
306: * Return: 0 on success or negative error on failure
307: */
308: int gen8_rscc_sleep_sequence(struct adreno_device *adreno_dev);
309:
310: /**
311: * gen8_rscc_wakeup_sequence - Trigger rscc wakeup sequence
312: * @adreno_dev: Pointer to the adreno device
--- FILE: \adreno_gen8_hfi.c | HITS: 5 ---
MATCH LINES: 645
633: entry->count * (entry->stride << 2));
634:
635: return gen8_hfi_send_generic_req(adreno_dev, tbl_cmd, hdr_size);
636: }
637:
638: int gen8_hfi_send_minbw_feature_ctrl(struct adreno_device *adreno_dev)
639: {
640: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
641:
642: if (!adreno_dev->minbw_enabled)
643: return 0;
644:
645: /* minbw can be enabled only if IFPC is enabled */
646: if (gmu->idle_level == GPU_HW_ACTIVE)
647: return 0;
648:
649: return gen8_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_MINBW, 1,
650: adreno_dev->minbw_data);
651: }
652:
653: int gen8_hfi_send_clx_feature_ctrl(struct adreno_device *adreno_dev)
654: {
655: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev);
656: struct hfi_clx_table_v2_cmd cmd = {0};
657: int ret;
658:
659: if (!adreno_dev->clx_enabled)
660: return 0;
661:
662: if (WARN_ON(!gen8_core->clx_tbl)) {
663: adreno_dev->clx_enabled = false;
664: return 0;
665: }
666:
667: memcpy(&cmd, gen8_core->clx_tbl, sizeof(struct hfi_clx_table_v2_cmd));
668:
669: /* Make sure the table is valid before enabling feature */
MATCH LINES: 710, 714, 716
698: ret = gen8_hfi_send_generic_req(adreno_dev,
699: &gmu->hfi.acd_table, sizeof(gmu->hfi.acd_table));
700: if (ret)
701: return ret;
702:
703: gen8_hfi_send_set_value(adreno_dev, HFI_VALUE_LOG_EVENT_ON,
704: EVENT_PWR_ACD_THROTTLE_PROF, 0);
705: }
706:
707: return 0;
708: }
709:
710: int gen8_hfi_send_ifpc_feature_ctrl(struct adreno_device *adreno_dev)
711: {
712: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
713:
714: if ((gmu->idle_level == GPU_HW_MINBW) || (gmu->idle_level == GPU_HW_IFPC))
715: return gen8_hfi_send_feature_ctrl(adreno_dev,
716: HFI_FEATURE_IFPC, 1, adreno_dev->ifpc_hyst);
717: return 0;
718: }
719:
720: static void reset_hfi_queues(struct adreno_device *adreno_dev)
721: {
722: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
723: struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
724: struct hfi_queue_table *tbl = mem_addr->hostptr;
725: struct hfi_queue_header *hdr;
726: u32 i;
727:
728: /* Flush HFI queues */
729: for (i = 0; i < HFI_QUEUE_MAX; i++) {
730: hdr = &tbl->qhdr[i];
731: if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
732: continue;
733:
734: hdr->read_index = hdr->write_index;
735: }
736: }
737:
738: /* Fill the entry and return the dword count written */
739: static u32 _fill_table_entry(struct hfi_table_entry *entry, u32 count,
740: u32 stride_bytes, u32 *data)
MATCH LINES: 823
811: result = gen8_hfi_send_bcl_feature_ctrl(adreno_dev);
812: if (result)
813: goto err;
814:
815: result = gen8_hfi_send_minbw_feature_ctrl(adreno_dev);
816: if (result)
817: goto err;
818:
819: result = gen8_hfi_send_clx_feature_ctrl(adreno_dev);
820: if (result)
821: goto err;
822:
823: result = gen8_hfi_send_ifpc_feature_ctrl(adreno_dev);
824: if (result)
825: goto err;
826:
827: result = gen8_hfi_send_core_fw_start(adreno_dev);
828: if (result)
829: goto err;
830:
831: set_bit(GMU_PRIV_HFI_STARTED, &gmu->flags);
832:
833: result = kgsl_pwrctrl_setup_default_votes(device);
834:
835: err:
836: if (result)
837: gen8_hfi_stop(adreno_dev);
838:
839: return result;
840:
841: }
842:
843: void gen8_hfi_stop(struct adreno_device *adreno_dev)
844: {
845: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
846: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
847:
--- FILE: \adreno_gen8_hfi.h | HITS: 2 ---
MATCH LINES: 204, 209
192: */
193: int gen8_hfi_send_minbw_feature_ctrl(struct adreno_device *adreno_dev);
194:
195: /**
196: * gen8_hfi_send_clx_feature_ctrl - Send the clx feature hfi packet
197: * @adreno_dev: Pointer to the adreno device
198: *
199: * Return: 0 on success or negative error on failure
200: */
201: int gen8_hfi_send_clx_feature_ctrl(struct adreno_device *adreno_dev);
202:
203: /**
204: * gen8_hfi_send_ifpc_feature_ctrl - Send the ipfc feature hfi packet
205: * @adreno_dev: Pointer to the adreno device
206: *
207: * Return: 0 on success or negative error on failure
208: */
209: int gen8_hfi_send_ifpc_feature_ctrl(struct adreno_device *adreno_dev);
210:
211: /**
212: * gen8_hfi_send_gpu_perf_table - Send the gpu perf table hfi packet
213: * @adreno_dev: Pointer to the adreno device
214: *
215: * Return: 0 on success or negative error on failure
216: */
217: int gen8_hfi_send_gpu_perf_table(struct adreno_device *adreno_dev);
218:
219: /*
220: * gen8_hfi_process_queue - Check hfi queue for messages from gmu
221: * @gmu: Pointer to the gen8 gmu device
222: * @queue_idx: queue id to be processed
223: * @ret_cmd: Container for data needed for waiting for the ack
224: *
225: * Return: 0 on success or negative error on failure
226: */
227: int gen8_hfi_process_queue(struct gen8_gmu_device *gmu,
228: u32 queue_idx, struct pending_cmd *ret_cmd);
229:
230: /**
231: * gen8_hfi_cmdq_write - Write a command to command queue
232: * @adreno_dev: Pointer to the adreno device
233: * @msg: Data to be written to the queue
--- FILE: \adreno_gen8_hwsched.c | HITS: 5 ---
MATCH LINES: 532, 550
520: {
521: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
522: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
523: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
524: struct hfi_prep_slumber_cmd req;
525: int ret;
526:
527: ret = CMD_MSG_HDR(req, H2F_MSG_PREPARE_SLUMBER);
528: if (ret)
529: return ret;
530:
531: req.freq = gmu->dcvs_table.gpu_level_num - pwr->default_pwrlevel - 1;
532: req.bw = pwr->pwrlevels[pwr->default_pwrlevel].bus_freq;
533:
534: req.bw |= adreno_gmu_bus_ab_quantize(adreno_dev, 0);
535: /* Disable the power counter so that the GMU is not busy */
536: gmu_core_regwrite(device, GEN8_GMUCX_POWER_COUNTER_ENABLE, 0);
537:
538: gen8_scm_gpu_tsense_suspend(adreno_dev);
539:
540: ret = gen8_hfi_send_cmd_async(adreno_dev, &req, sizeof(req));
541:
542: /*
543: * GEMNOC can enter power collapse state during GPU power down sequence.
544: * This could abort CX GDSC collapse. Assert Qactive to avoid this.
545: */
546: gmu_core_regwrite(device, GEN8_GMUCX_CX_FALNEXT_INTF, 0x1);
547:
548: return ret;
549: }
550: static int gen8_hwsched_gmu_power_off(struct adreno_device *adreno_dev)
551: {
552: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
553: int ret = 0;
554:
555: if (device->gmu_fault)
556: goto error;
557:
558: /* Wait for the lowest idle level we requested */
559: ret = gen8_gmu_wait_for_lowest_idle(adreno_dev);
560: if (ret)
561: goto error;
562:
563: ret = gen8_hwsched_notify_slumber(adreno_dev);
564: if (ret)
565: goto error;
566:
567: ret = gen8_gmu_wait_for_idle(adreno_dev);
568: if (ret)
569: goto error;
570:
571: ret = gen8_rscc_sleep_sequence(adreno_dev);
572:
573: gmu_core_rdpm_mx_freq_update(device, 0);
574:
MATCH LINES: 693
681: device->reset_counter++;
682:
683: /*
684: * If warmboot is enabled and we switched a sysfs node, we will do a coldboot
685: * in the subseqent slumber exit. Once that is done we need to mark this bool
686: * as false so that in the next run we can do warmboot
687: */
688: clear_bit(GMU_FORCE_COLDBOOT, &device->gmu_core.flags);
689: err:
690: gen8_gmu_oob_clear(device, oob_gpu);
691:
692: if (ret)
693: gen8_hwsched_gmu_power_off(adreno_dev);
694:
695: return ret;
696: }
697:
698: static void hwsched_idle_timer(struct timer_list *t)
699: {
700: struct kgsl_device *device = container_of(t, struct kgsl_device,
701: idle_timer);
702:
703: kgsl_schedule_work(&device->idle_check_ws);
704: }
705:
706: static int gen8_gmu_warmboot_init(struct adreno_device *adreno_dev)
707: {
708: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
709: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
710: int ret = 0;
711:
712: if (!ADRENO_FEATURE(adreno_dev, ADRENO_GMU_WARMBOOT))
713: return ret;
714:
715: if (IS_ERR_OR_NULL(gmu->gmu_init_scratch)) {
716: gmu->gmu_init_scratch = gmu_core_reserve_kernel_block(device, 0,
717: SZ_4K, GMU_CACHE, 0);
MATCH LINES: 1043
1031:
1032: adreno_irqctrl(adreno_dev, 0);
1033:
1034: gen8_gmu_oob_clear(device, oob_gpu);
1035:
1036: no_gx_power:
1037: kgsl_pwrctrl_irq(device, false);
1038:
1039: /* Make sure GMU has sent all hardware fences to TxQueue */
1040: if (check_inflight_hw_fences(adreno_dev))
1041: drain_cpu = true;
1042:
1043: gen8_hwsched_gmu_power_off(adreno_dev);
1044:
1045: /* Now that we are sure that GMU is powered off, drain pending fences */
1046: if (drain_cpu)
1047: drain_hw_fences_cpu(adreno_dev);
1048:
1049: adreno_hwsched_unregister_contexts(adreno_dev);
1050:
1051: adreno_llcc_slice_deactivate(adreno_dev);
1052:
1053: clear_bit(GMU_PRIV_GPU_STARTED, &gmu->flags);
1054:
1055: kgsl_delete_timer_sync(&device->idle_timer);
1056:
1057: kgsl_pwrscale_sleep(device);
1058:
1059: kgsl_pwrctrl_clear_l3_vote(device);
1060:
1061: gen8_hwsched_soccp_vote(adreno_dev, false);
1062:
1063: kgsl_pwrctrl_set_state(device, KGSL_STATE_SLUMBER);
1064:
1065: return ret;
1066: }
1067:
MATCH LINES: 2080
2068: kgsl_mutex_unlock(&device->mutex);
2069: }
2070: break;
2071: case GPU_PWRLEVEL_OP_DCVS_ENABLE:
2072: gen8_hwsched_set_dcvs_enable(adreno_dev, arg);
2073: break;
2074: case GPU_PWRLEVEL_OP_TUNING_ATTR:
2075: gen8_hwsched_set_tuning_param(adreno_dev, arg);
2076: break;
2077: }
2078: }
2079:
2080: const struct adreno_power_ops gen8_hwsched_power_ops = {
2081: .first_open = gen8_hwsched_first_open,
2082: .last_close = gen8_hwsched_power_off,
2083: .active_count_get = gen8_hwsched_active_count_get,
2084: .touch_wakeup = gen8_hwsched_touch_wakeup,
2085: .pm_suspend = gen8_hwsched_pm_suspend,
2086: .pm_resume = gen8_hwsched_pm_resume,
2087: .gpu_clock_set = gen8_hwsched_clock_set,
2088: .gpu_bus_set = gen8_hwsched_bus_set,
2089: .gmu_based_dcvs_pwr_ops = gen8_hwsched_gmu_based_dcvs_pwr_ops,
2090: };
2091:
2092: const struct adreno_hwsched_ops gen8_hwsched_ops = {
2093: .submit_drawobj = gen8_hwsched_submit_drawobj,
2094: .preempt_count = gen8_hwsched_preempt_count_get,
2095: .preempt_info = gen8_hwsched_preempt_info_get,
2096: .create_hw_fence = gen8_hwsched_create_hw_fence,
2097: .set_dcvs_profile = gen8_hwsched_set_dcvs_profile,
2098: };
2099:
2100: int gen8_hwsched_probe(struct platform_device *pdev,
2101: u32 chipid, const struct adreno_gpu_core *gpucore)
2102: {
2103: struct adreno_device *adreno_dev;
2104: struct kgsl_device *device;
--- FILE: \adreno_gen8_hwsched_hfi.c | HITS: 2 ---
MATCH LINES: 2404
2392: * Second entry table contains default, min and max bus indexes for each power level.
2393: */
2394: entry = (struct hfi_table_entry *)&gmu->dcvs_cmdbuf[index];
2395: entry->count = pwr->num_pwrlevels + 1;
2396: entry->stride = 3;
2397: j = 0;
2398: /* GMU has 0 MHz as its lowest level */
2399: entry->data[j++] = 0;
2400: entry->data[j++] = 0;
2401: entry->data[j++] = 0;
2402: /* GPU power levels and associated bus votes */
2403: for (i = pwr->num_pwrlevels - 1; i >= 0; i--) {
2404: entry->data[j++] = pwr->pwrlevels[i].bus_freq;
2405: entry->data[j++] = pwr->pwrlevels[i].bus_min;
2406: entry->data[j++] = pwr->pwrlevels[i].bus_max;
2407: }
2408:
2409: index += size_ddr_levels_dwords;
2410:
2411: /*
2412: * Fill up ddr table entry
2413: * This contains the ddr table
2414: */
2415: entry = (struct hfi_table_entry *)&gmu->dcvs_cmdbuf[index];
2416: entry->count = 1;
2417: entry->stride = pwr->ddr_table_count;
2418: for (i = 0; i < pwr->ddr_table_count; i++)
2419: entry->data[i] = pwr->ddr_table[i];
2420: index += size_ddr_table_dwords;
2421:
2422: /* If index is greater than size, buffer has overflown */
2423: if (index > size_table_dwords) {
2424: dev_err(device->dev, "Buffer overflown for dcvs table\n");
2425: return -EINVAL;
2426: }
2427:
2428: cmd->hdr = CREATE_MSG_HDR(H2F_MSG_TABLE, HFI_MSG_CMD);
MATCH LINES: 2586
2574: ret = gen8_hfi_send_acd_feature_ctrl(adreno_dev);
2575: if (ret)
2576: goto err;
2577:
2578: ret = gen8_hfi_send_bcl_feature_ctrl(adreno_dev);
2579: if (ret)
2580: goto err;
2581:
2582: ret = gen8_hfi_send_clx_feature_ctrl(adreno_dev);
2583: if (ret)
2584: goto err;
2585:
2586: ret = gen8_hfi_send_ifpc_feature_ctrl(adreno_dev);
2587: if (ret)
2588: goto err;
2589:
2590: ret = gen8_hfi_send_minbw_feature_ctrl(adreno_dev);
2591: if (ret)
2592: goto err;
2593:
2594: ret = gen8_hfi_send_thermal_feature_ctrl(adreno_dev);
2595: if (ret)
2596: goto err;
2597:
2598: ret = gen8_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_HWSCHED, 1, 0);
2599: if (ret)
2600: goto err;
2601:
2602: ret = gen8_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_KPROF, 1, 0);
2603: if (ret)
2604: goto err;
2605:
2606: if (ADRENO_FEATURE(adreno_dev, ADRENO_LSR)) {
2607: ret = gen8_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_LSR,
2608: 1, 0);
2609: if (ret)
2610: goto err;
--- FILE: \adreno_gen8_perfcounter.c | HITS: 3 ---
MATCH LINES: 871
859:
860: #define GMU_COUNTER(lo, hi, sel) \
861: { .countable = KGSL_PERFCOUNTER_NOT_USED, \
862: .offset = lo, .offset_hi = hi, .select = sel }
863:
864: #define GMU_COUNTER_RESERVED(lo, hi, sel) \
865: { .countable = KGSL_PERFCOUNTER_BROKEN, \
866: .offset = lo, .offset_hi = hi, .select = sel }
867:
868: static struct adreno_perfcount_register gen8_perfcounters_gmu_xoclk[] = {
869: /*
870: * COUNTER_XOCLK_0 and COUNTER_XOCLK_4 are used for the GPU
871: * busy and ifpc count. Mark them as reserved to ensure they
872: * are not re-used.
873: */
874: GMU_COUNTER_RESERVED(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_0,
875: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_0,
876: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_0),
877: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_1,
878: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_1,
879: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_0),
880: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_2,
881: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_2,
882: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_0),
883: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_3,
884: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_3,
885: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_0),
886: GMU_COUNTER_RESERVED(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_4,
887: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_4,
888: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_1),
889: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_5,
890: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_5,
891: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_1),
892: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_6,
893: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_6,
894: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_1),
895: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_7,
MATCH LINES: 1076, 1077
1064: GEN8_GMUCX_PERF_COUNTER_H_5,
1065: GEN8_GMUCX_PERF_COUNTER_SELECT_1),
1066: };
1067:
1068: static struct adreno_perfcount_register gen8_perfcounters_alwayson[] = {
1069: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, GEN8_CP_ALWAYS_ON_COUNTER_LO,
1070: GEN8_CP_ALWAYS_ON_COUNTER_HI, -1 },
1071: };
1072:
1073: /*
1074: * ADRENO_PERFCOUNTER_GROUP_RESTORE flag is enabled by default
1075: * because most of the perfcounter groups need to be restored
1076: * as part of preemption and IFPC. Perfcounter groups that are
1077: * not restored as part of preemption and IFPC should be defined
1078: * using GEN8_PERFCOUNTER_GROUP_FLAGS macro
1079: */
1080:
1081: #define GEN8_PERFCOUNTER_GROUP_FLAGS(core, offset, name, flags, \
1082: enable, read) \
1083: [KGSL_PERFCOUNTER_GROUP_##offset] = { core##_perfcounters_##name, \
1084: ARRAY_SIZE(core##_perfcounters_##name), __stringify(name), flags, \
1085: enable, read }
1086:
1087: #define GEN8_PERFCOUNTER_GROUP(offset, name, enable, read) \
1088: GEN8_PERFCOUNTER_GROUP_FLAGS(gen8, offset, name, \
1089: ADRENO_PERFCOUNTER_GROUP_RESTORE, enable, read)
1090:
1091: #define GEN8_REGULAR_PERFCOUNTER_GROUP(offset, name) \
1092: GEN8_PERFCOUNTER_GROUP(offset, name, \
1093: gen8_counter_enable, gen8_counter_read)
1094:
1095: #define GEN8_BV_PERFCOUNTER_GROUP(offset, name, enable, read) \
1096: GEN8_PERFCOUNTER_GROUP_FLAGS(gen8, BV_##offset, bv_##name, \
1097: ADRENO_PERFCOUNTER_GROUP_RESTORE, enable, read)
1098:
1099: #define GEN8_BV_REGULAR_PERFCOUNTER_GROUP(offset, name) \
1100: GEN8_BV_PERFCOUNTER_GROUP(offset, name, \
1101: gen8_counter_enable, gen8_counter_read)
--- FILE: \adreno_gen8_preempt.c | HITS: 13 ---
MATCH LINES: 69, 74
57: spin_unlock_irqrestore(&rb->preempt_lock, flags);
58:
59: if (!atomic) {
60: /* If WPTR update fails, set the fault and trigger recovery */
61: if (ret) {
62: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
63: adreno_scheduler_fault(adreno_dev,
64: ADRENO_GMU_FAULT_SKIP_SNAPSHOT);
65: }
66: }
67: }
68:
69: static void _power_collapse_set(struct adreno_device *adreno_dev, bool val)
70: {
71: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
72:
73: gmu_core_regwrite(device,
74: GEN8_GMUCX_PWR_COL_PREEMPTION_KEEPALIVE, (val ? 1 : 0));
75: }
76:
77: static void _gen8_preemption_done(struct adreno_device *adreno_dev)
78: {
79: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
80: u32 status;
81:
82: /*
83: * In the very unlikely case that the power is off, do nothing - the
84: * state will be reset on power up and everybody will be happy
85: */
86:
87: if (!kgsl_state_is_awake(device))
88: return;
89:
90: kgsl_regread(device, GEN8_CP_CONTEXT_SWITCH_CNTL, &status);
91:
92: if (status & 0x1) {
93: dev_err(device->dev,
94: "Preemption not complete: status=%X cur=%d R/W=%X/%X next=%d R/W=%X/%X\n",
95: status, adreno_dev->cur_rb->id,
96: adreno_get_rptr(adreno_dev->cur_rb),
97: adreno_dev->cur_rb->wptr,
98: adreno_dev->next_rb->id,
MATCH LINES: 278, 283, 285, 286, 290, 304, 306, 309
266: /* And write it to the smmu info */
267: if (kgsl_mmu_is_perprocess(&device->mmu)) {
268: kgsl_sharedmem_writeq(iommu->smmu_info,
269: PREEMPT_SMMU_RECORD(ttbr0), ttbr0);
270: kgsl_sharedmem_writel(iommu->smmu_info,
271: PREEMPT_SMMU_RECORD(context_idr), contextidr);
272: }
273:
274: kgsl_sharedmem_readq(preempt->scratch, &gpuaddr,
275: next->id * sizeof(u64));
276:
277: /*
278: * Set a keepalive bit before the first preemption register write.
279: * This is required since while each individual write to the context
280: * switch registers will wake the GPU from collapse, it will not in
281: * itself cause GPU activity. Thus, the GPU could technically be
282: * re-collapsed between subsequent register writes leading to a
283: * prolonged preemption sequence. The keepalive bit prevents any
284: * further power collapse while it is set.
285: * It is more efficient to use a keepalive+wake-on-fence approach here
286: * rather than an OOB. Both keepalive and the fence are effectively
287: * free when the GPU is already powered on, whereas an OOB requires an
288: * unconditional handshake with the GMU.
289: */
290: _power_collapse_set(adreno_dev, true);
291:
292: /*
293: * Fenced writes on this path will make sure the GPU is woken up
294: * in case it was power collapsed by the GMU.
295: */
296: if (gen8_fenced_write(adreno_dev,
297: GEN8_CP_CONTEXT_SWITCH_PNSR_ADDR_LO,
298: lower_32_bits(next->preemption_desc->gpuaddr),
299: FENCE_STATUS_WRITEDROPPED1_MASK))
300: goto err;
301:
302: /*
303: * Above fence writes will make sure GMU comes out of
304: * IFPC state if its was in IFPC state but it doesn't
305: * guarantee that GMU FW actually moved to ACTIVE state
306: * i.e. wake-up from IFPC is complete.
307: * Wait for GMU to move to ACTIVE state before triggering
308: * preemption. This is require to make sure CP doesn't
309: * interrupt GMU during wake-up from IFPC.
310: */
311: if (!atomic && gmu_core_dev_wait_for_active_transition(device))
312: goto err;
313:
314: if (gen8_fenced_write(adreno_dev,
315: GEN8_CP_CONTEXT_SWITCH_PNSR_ADDR_HI,
316: upper_32_bits(next->preemption_desc->gpuaddr),
317: FENCE_STATUS_WRITEDROPPED1_MASK))
318: goto err;
319:
320: if (kgsl_mmu_is_secured(&device->mmu)) {
321: if (gen8_fenced_write(adreno_dev,
322: GEN8_CP_CONTEXT_SWITCH_PSR_ADDR_LO,
323: lower_32_bits(next->secure_preemption_desc->gpuaddr),
324: FENCE_STATUS_WRITEDROPPED1_MASK))
325: goto err;
326:
327: if (gen8_fenced_write(adreno_dev,
328: GEN8_CP_CONTEXT_SWITCH_PSR_ADDR_HI,
329: upper_32_bits(next->secure_preemption_desc->gpuaddr),
330: FENCE_STATUS_WRITEDROPPED1_MASK))
331: goto err;
332: }
333:
MATCH LINES: 392, 426, 429
380: return;
381: err:
382: /* If fenced write fails, take inline snapshot and trigger recovery */
383: if (!in_interrupt()) {
384: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
385: adreno_scheduler_fault(adreno_dev,
386: ADRENO_GMU_FAULT_SKIP_SNAPSHOT);
387: } else {
388: adreno_scheduler_fault(adreno_dev, ADRENO_GMU_FAULT);
389: }
390: adreno_set_preempt_state(adreno_dev, ADRENO_PREEMPT_NONE);
391: /* Clear the keep alive */
392: _power_collapse_set(adreno_dev, false);
393:
394: }
395:
396: void gen8_preemption_callback(struct adreno_device *adreno_dev, int bit)
397: {
398: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
399: u32 status;
400:
401: if (!adreno_move_preempt_state(adreno_dev,
402: ADRENO_PREEMPT_TRIGGERED, ADRENO_PREEMPT_PENDING))
403: return;
404:
405: kgsl_regread(device, GEN8_CP_CONTEXT_SWITCH_CNTL, &status);
406:
407: if (status & 0x1) {
408: dev_err(KGSL_DEVICE(adreno_dev)->dev,
409: "preempt interrupt with non-zero status: %X\n",
410: status);
411:
412: /*
413: * Under the assumption that this is a race between the
414: * interrupt and the register, schedule the worker to clean up.
415: * If the status still hasn't resolved itself by the time we get
416: * there then we have to assume something bad happened
417: */
418: adreno_set_preempt_state(adreno_dev, ADRENO_PREEMPT_COMPLETE);
419: adreno_scheduler_queue(adreno_dev);
420: return;
421: }
422:
423: adreno_dev->preempt.count++;
424:
425: /*
426: * We can now safely clear the preemption keepalive bit, allowing
427: * power collapse to resume its regular activity.
428: */
429: _power_collapse_set(adreno_dev, false);
430:
431: kgsl_delete_timer(&adreno_dev->preempt.timer);
432:
433: kgsl_regread(device, GEN8_CP_CONTEXT_SWITCH_LEVEL_STATUS, &status);
434:
435: trace_adreno_preempt_done(adreno_dev->cur_rb->id, adreno_dev->next_rb->id,
436: status, 0);
437:
438: adreno_dev->prev_rb = adreno_dev->cur_rb;
439: adreno_dev->cur_rb = adreno_dev->next_rb;
440: adreno_dev->next_rb = NULL;
441:
442: /* Update the wptr if it changed while preemption was ongoing */
443: _update_wptr(adreno_dev, true, true);
444:
445: /* Update the dispatcher timer for the new command queue */
446: mod_timer(&adreno_dev->dispatcher.timer,
447: adreno_dev->cur_rb->dispatch_q.expires);
448:
449: adreno_set_preempt_state(adreno_dev, ADRENO_PREEMPT_NONE);
450:
451: gen8_preemption_trigger(adreno_dev, true);
452: }
453:
--- FILE: \adreno_gen8_ringbuffer.c | HITS: 3 ---
MATCH LINES: 293, 299
281: /* Identify the start of a command */
282: cmds[index++] = cp_type7_packet(CP_NOP, 1);
283: cmds[index++] = drawctxt ? CMD_IDENTIFIER : CMD_INTERNAL_IDENTIFIER;
284:
285: /* This is 25 dwords when drawctxt is not NULL and perfcounter needs to be zapped*/
286: index += gen8_preemption_pre_ibsubmit(adreno_dev, rb, drawctxt,
287: &cmds[index]);
288:
289: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
290: cmds[index++] = CP_SET_THREAD_BOTH;
291:
292: cmds[index++] = cp_type7_packet(CP_SET_MARKER, 1);
293: cmds[index++] = 0x101; /* IFPC disable */
294:
295: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
296: cmds[index++] = CP_SET_THREAD_BR;
297:
298: /*
299: * The POWER_CONTROL packet should always be after IFPC disable MARKER
300: * to avoid opcode errors
301: */
302: if (flags & F_MALU) {
303: cmds[index++] = cp_type7_packet(CP_POWER_CONTROL, 2);
304: cmds[index++] = 1; /* Control mALU power */
305: cmds[index++] = 1; /* Turn on mALU */
306: }
307:
308: profile_gpuaddr = adreno_profile_preib_processing(adreno_dev,
309: drawctxt, &profile_dwords);
310:
311: if (profile_gpuaddr) {
312: cmds[index++] = cp_type7_packet(CP_INDIRECT_BUFFER_PFE, 3);
313: cmds[index++] = lower_32_bits(profile_gpuaddr);
314: cmds[index++] = upper_32_bits(profile_gpuaddr);
315: cmds[index++] = profile_dwords;
316: }
317:
318: if (drawctxt) {
319: cmds[index++] = cp_type7_packet(CP_MEM_WRITE, 3);
320: cmds[index++] = lower_32_bits(CTXT_SOPTIMESTAMP(device,
321: drawctxt));
322: cmds[index++] = upper_32_bits(CTXT_SOPTIMESTAMP(device,
323: drawctxt));
MATCH LINES: 429
417: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
418: cmds[index++] = CP_CONCURRENT_BIN_DISABLE;
419: cmds[index++] = cp_type7_packet(CP_SET_SECURE_MODE, 1);
420: cmds[index++] = 0;
421: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
422: cmds[index++] = CP_SYNC_THREADS;
423: }
424:
425: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
426: cmds[index++] = CP_SET_THREAD_BOTH;
427:
428: cmds[index++] = cp_type7_packet(CP_SET_MARKER, 1);
429: cmds[index++] = 0x100; /* IFPC enable */
430:
431: cmds[index++] = cp_type7_packet(CP_THREAD_CONTROL, 1);
432: cmds[index++] = CP_SET_THREAD_BR;
433:
434: /* 10 dwords */
435: index += gen8_preemption_post_ibsubmit(adreno_dev, &cmds[index]);
436:
437: /* Adjust the thing for the number of bytes we actually wrote */
438: rb->_wptr -= (size - index);
439:
440: return gen8_ringbuffer_submit(rb, time);
441: }
442:
443: static u32 gen8_get_alwayson_counter(u32 *cmds, u64 gpuaddr)
444: {
445: cmds[0] = cp_type7_packet(CP_REG_TO_MEM, 3);
446: cmds[1] = GEN8_CP_ALWAYS_ON_COUNTER_LO | (1 << 30) | (2 << 18);
447: cmds[2] = lower_32_bits(gpuaddr);
448: cmds[3] = upper_32_bits(gpuaddr);
449:
450: return 4;
451: }
452:
453: static u32 gen8_get_alwayson_context(u32 *cmds, u64 gpuaddr)
--- FILE: \adreno_hfi.h | HITS: 1 ---
MATCH LINES: 62
50: #define DCVS_ACK_NONBLOCK 0
51: #define DCVS_ACK_BLOCK 1
52:
53: #define HFI_FEATURE_DCVS 0
54: #define HFI_FEATURE_HWSCHED 1
55: #define HFI_FEATURE_PREEMPTION 2
56: #define HFI_FEATURE_CLOCKS_ON 3
57: #define HFI_FEATURE_BUS_ON 4
58: #define HFI_FEATURE_RAIL_ON 5
59: #define HFI_FEATURE_HWCG 6
60: #define HFI_FEATURE_LM 7
61: #define HFI_FEATURE_THROTTLE 8
62: #define HFI_FEATURE_IFPC 9
63: #define HFI_FEATURE_NAP 10
64: #define HFI_FEATURE_BCL 11
65: #define HFI_FEATURE_ACD 12
66: #define HFI_FEATURE_DIDT 13
67: #define HFI_FEATURE_DEPRECATED 14
68: #define HFI_FEATURE_CB 15
69: #define HFI_FEATURE_KPROF 16
70: #define HFI_FEATURE_BAIL_OUT_TIMER 17
71: #define HFI_FEATURE_GMU_STATS 18
72: #define HFI_FEATURE_DBQ 19
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
--- FILE: \adreno_perfcounter.h | HITS: 1 ---
MATCH LINES: 80
68: /*
69: * ADRENO_PERFCOUNTER_GROUP_FIXED indicates that a perfcounter group is fixed -
70: * instead of having configurable countables like the other groups, registers in
71: * fixed groups have a hardwired countable. So when the user requests a
72: * countable in one of these groups, that countable should be used as the
73: * register offset to return
74: */
75:
76: #define ADRENO_PERFCOUNTER_GROUP_FIXED BIT(0)
77:
78: /*
79: * ADRENO_PERFCOUNTER_GROUP_RESTORE indicates CP needs to restore the select
80: * registers of this perfcounter group as part of preemption and IFPC
81: */
82: #define ADRENO_PERFCOUNTER_GROUP_RESTORE BIT(1)
83:
84:
85: /**
86: * adreno_perfcounts: all available perfcounter groups
87: * @groups: available groups for this device
88: * @group_count: total groups for this device
89: */
90: struct adreno_perfcounters {
91: const struct adreno_perfcount_group *groups;
92: unsigned int group_count;
93: };
94:
95: #define ADRENO_PERFCOUNTER_GROUP_FLAGS(core, offset, name, flags, \
96: enable, read, load) \
97: [KGSL_PERFCOUNTER_GROUP_##offset] = { core##_perfcounters_##name, \
98: ARRAY_SIZE(core##_perfcounters_##name), __stringify(name), flags, \
99: enable, read, load }
100:
101: #define ADRENO_PERFCOUNTER_GROUP(core, offset, name, enable, read, load) \
102: ADRENO_PERFCOUNTER_GROUP_FLAGS(core, offset, name, 0, enable, read, \
103: load)
104:
--- FILE: \adreno_sysfs.c | HITS: 10 ---
MATCH LINES: 407, 409, 412, 414, 429, 436
395: adreno_dev->lm_enabled == val)
396: return 0;
397:
398: return adreno_power_cycle_bool(adreno_dev, &adreno_dev->lm_enabled,
399: val);
400: }
401:
402: static bool _lm_show(struct adreno_device *adreno_dev)
403: {
404: return adreno_dev->lm_enabled;
405: }
406:
407: static int _ifpc_store(struct adreno_device *adreno_dev, bool val)
408: {
409: return gmu_core_dev_ifpc_store(KGSL_DEVICE(adreno_dev), val);
410: }
411:
412: static bool _ifpc_show(struct adreno_device *adreno_dev)
413: {
414: return gmu_core_dev_ifpc_isenabled(KGSL_DEVICE(adreno_dev));
415: }
416:
417: static int _touch_wake_store(struct adreno_device *adreno_dev, bool val)
418: {
419: if (val)
420: adreno_touch_wake(KGSL_DEVICE(adreno_dev));
421: return 0;
422: }
423:
424: static bool _touch_wake_show(struct adreno_device *adreno_dev)
425: {
426: return false;
427: }
428:
429: static unsigned int _ifpc_count_show(struct adreno_device *adreno_dev)
430: {
431: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
432:
433: if (gpudev->power_feature_stats)
434: gpudev->power_feature_stats(adreno_dev);
435:
436: return adreno_dev->ifpc_count;
437: }
438:
439: static bool _acd_show(struct adreno_device *adreno_dev)
440: {
441: return adreno_dev->acd_enabled;
442: }
443:
444: static int _acd_store(struct adreno_device *adreno_dev, bool val)
445: {
446: return gmu_core_dev_acd_set(KGSL_DEVICE(adreno_dev), val);
447: }
448:
449: static bool _gmu_ab_show(struct adreno_device *adreno_dev)
450: {
451: return adreno_dev->gmu_ab;
452: }
453:
454: static int _gmu_ab_store(struct adreno_device *adreno_dev, bool val)
455: {
456: if (!test_bit(ADRENO_DEVICE_GMU_AB, &adreno_dev->priv) ||
457: (adreno_dev->gmu_ab == val))
458: return 0;
459:
460: /* Power cycle the GPU for changes to take effect */
MATCH LINES: 668, 669, 705, 706
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);
678: static ADRENO_SYSFS_BOOL(gmu_ab);
679: static ADRENO_SYSFS_BOOL(dcvs_profile_enabled);
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,
717: &dev_attr_gpufaults.attr,
718: &dev_attr_gpufault_procs.attr,
719: &adreno_attr_dcvs_tuning_mingap.attr.attr,
720: &adreno_attr_dcvs_tuning_penalty.attr.attr,
721: &adreno_attr_dcvs_tuning_numbusy.attr.attr,
722: &adreno_attr_dcvs_mode.attr.attr,
723: &adreno_attr_dcvs_profile_enabled.attr.attr,
724: NULL,
725: };
726:
727: static GPU_SYSFS_ATTR(gpu_model, 0444, _gpu_model_show, NULL);
728:
729: /**
730: * adreno_sysfs_init() - Initialize adreno sysfs files
--- FILE: \adreno_trace.h | HITS: 13 ---
MATCH LINES: 982, 983, 984, 986, 989, 991
970: ),
971: TP_fast_assign(
972: __entry->context = context;
973: __entry->seq_no = seq_no;
974: __entry->flags = flags;
975: __entry->ticks = gmu_ticks;
976: ),
977: TP_printk("id=%llu seqno=%llu flags=0x%x ticks=%llu",
978: __entry->context, __entry->seq_no, __entry->flags, __entry->ticks
979: )
980: );
981:
982: TRACE_EVENT(adreno_ifpc_count,
983: TP_PROTO(unsigned int ifpc_count),
984: TP_ARGS(ifpc_count),
985: TP_STRUCT__entry(
986: __field(unsigned int, ifpc_count)
987: ),
988: TP_fast_assign(
989: __entry->ifpc_count = ifpc_count;
990: ),
991: TP_printk("total times GMU entered IFPC = %d", __entry->ifpc_count)
992: );
993:
994: TRACE_EVENT(adreno_dcvs_tuning,
995: TP_PROTO(u32 param, u32 mingap, u32 penalty, u32 numbusy),
996: TP_ARGS(param, mingap, penalty, numbusy),
997: TP_STRUCT__entry(
998: __field(u32, param)
999: __field(u32, mingap)
1000: __field(u32, penalty)
1001: __field(u32, numbusy)
1002: ),
1003: TP_fast_assign(
1004: __entry->param = param;
1005: __entry->mingap = mingap;
1006: __entry->penalty = penalty;
1007: __entry->numbusy = numbusy;
1008: ),
1009: TP_printk("param=%u mingap=%u penalty=%u numbusy=%u",
1010: __entry->param, __entry->mingap, __entry->penalty, __entry->numbusy)
1011: );
1012:
1013: TRACE_EVENT(adreno_gpu_vote_params,
1014: TP_PROTO(u32 cur_pwrlevel,
1015: u32 prev_pwrlevel,
MATCH LINES: 1093, 1094, 1112, 1113, 1115, 1134, 1135
1081: __field(int, min_gpu_freq)
1082: __field(int, max_gpu_freq)
1083: __field(int, target_fps)
1084: __field(int, penalty_up)
1085: __field(int, penalty_down)
1086: __field(int, first_step_down_count)
1087: __field(int, subsequent_step_down_count)
1088: __field(int, num_samples_up)
1089: __field(int, num_samples_down)
1090: __field(int, strict_frame)
1091: __field(int, non_linear_ramp_up)
1092: __field(int, non_linear_ramp_down)
1093: __field(int, min_bus_freq)
1094: __field(int, max_bus_freq)
1095: ),
1096: TP_fast_assign(
1097: __entry->action = prof->action;
1098: __entry->profile = prof->profile;
1099: __entry->ticks = ticks;
1100: __entry->min_gpu_freq = prof->attrs.min_gpu_freq;
1101: __entry->max_gpu_freq = prof->attrs.max_gpu_freq;
1102: __entry->target_fps = prof->attrs.target_fps;
1103: __entry->penalty_up = prof->attrs.penalty_up;
1104: __entry->penalty_down = prof->attrs.penalty_down;
1105: __entry->first_step_down_count = prof->attrs.first_step_down_count;
1106: __entry->subsequent_step_down_count = prof->attrs.subsequent_step_down_count;
1107: __entry->num_samples_up = prof->attrs.num_samples_up;
1108: __entry->num_samples_down = prof->attrs.num_samples_down;
1109: __entry->strict_frame = prof->attrs.strict_frame;
1110: __entry->non_linear_ramp_up = prof->attrs.non_linear_ramp_up;
1111: __entry->non_linear_ramp_down = prof->attrs.non_linear_ramp_down;
1112: __entry->min_bus_freq = prof->attrs.min_bus_freq;
1113: __entry->max_bus_freq = prof->attrs.max_bus_freq;
1114: ),
1115: TP_printk("action=%s profile=0x%x ticks=%llu min_gpu_freq=%d max_gpu_freq=%d target_fps=%d penalty_up=%d penalty_down=%d first_step_down_count=%d subsequent_step_down_count=%d num_samples_up=%d num_samples_down=%d strict_frame=%d non_linear_ramp_up=%d non_linear_ramp_down=%d min_bus_freq=%d max_bus_freq=%d",
1116: __print_symbolic(__entry->action,
1117: { GMU_DCVS_PROFILE_REGISTER, "REGISTER" },
1118: { GMU_DCVS_PROFILE_ACTIVATE, "ACTIVATE" },
1119: { GMU_DCVS_PROFILE_DEACTIVATE, "DEACTIVATE" }),
1120: __entry->profile,
1121: __entry->ticks,
1122: __entry->min_gpu_freq,
1123: __entry->max_gpu_freq,
1124: __entry->target_fps,
1125: __entry->penalty_up,
1126: __entry->penalty_down,
1127: __entry->first_step_down_count,
1128: __entry->subsequent_step_down_count,
1129: __entry->num_samples_up,
1130: __entry->num_samples_down,
1131: __entry->strict_frame,
1132: __entry->non_linear_ramp_up,
1133: __entry->non_linear_ramp_down,
1134: __entry->min_bus_freq,
1135: __entry->max_bus_freq
1136: )
1137: );
1138:
1139: #endif /* _ADRENO_TRACE_H */
1140:
1141: /* This part must be outside protection */
1142: #include <trace/define_trace.h>
--- FILE: \gen7_reg.h | HITS: 33 ---
MATCH LINES: 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, 1209, 1210
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
1170: #define GEN7_GMU_CX_GMU_POWER_COUNTER_GMUCLK_1_H 0x1f853
1171: #define GEN7_GMU_CX_GMU_POWER_COUNTER_SELECT_2 0x1f860
1172: #define GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_6_L 0x1f870
1173: #define GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_6_H 0x1f871
1174: #define GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_7_L 0x1f872
1175: #define GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_7_H 0x1f873
1176: #define GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_8_L 0x1f874
1177: #define GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_8_H 0x1f875
1178: #define GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_9_L 0x1f876
1179: #define GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_9_H 0x1f877
1180: #define GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_10_L 0x1f878
1181: #define GEN7_GMU_CX_GMU_POWER_COUNTER_XOCLK_10_H 0x1f879
1182: #define GEN7_GMU_CX_GMU_POWER_COUNTER_SELECT_3 0x1f87f
1183: #define GEN7_GMU_CX_AO_COUNTER_LO 0x1f880
1184: #define GEN7_GMU_CX_AO_COUNTER_HI 0x1f881
1185: #define GEN7_GMU_PWR_COL_INTER_FRAME_CTRL 0x1f8c0
1186: #define GEN7_GMU_PWR_COL_INTER_FRAME_HYST 0x1f8c1
1187: #define GEN7_GMU_GFX_PWR_CLK_STATUS 0x1f8d0
1188: #define GEN7_GMU_CX_GMU_PERF_COUNTER_ENABLE 0x1f8a0
1189: #define GEN7_GMU_CX_GMU_PERF_COUNTER_SELECT_0 0x1f8a1
1190: #define GEN7_GMU_CX_GMU_PERF_COUNTER_SELECT_1 0x1f8a2
1191: #define GEN7_GMU_CX_GMU_PERF_COUNTER_0_L 0x1f8a4
1192: #define GEN7_GMU_CX_GMU_PERF_COUNTER_0_H 0x1f8a5
1193: #define GEN7_GMU_CX_GMU_PERF_COUNTER_1_L 0x1f8a6
1194: #define GEN7_GMU_CX_GMU_PERF_COUNTER_1_H 0x1f8a7
1195: #define GEN7_GMU_CX_GMU_PERF_COUNTER_2_L 0x1f8a8
1196: #define GEN7_GMU_CX_GMU_PERF_COUNTER_2_H 0x1f8a9
1197: #define GEN7_GMU_CX_GMU_PERF_COUNTER_3_L 0x1f8aa
1198: #define GEN7_GMU_CX_GMU_PERF_COUNTER_3_H 0x1f8ab
1199: #define GEN7_GMU_CX_GMU_PERF_COUNTER_4_L 0x1f8ac
1200: #define GEN7_GMU_CX_GMU_PERF_COUNTER_4_H 0x1f8ad
1201: #define GEN7_GMU_CX_GMU_PERF_COUNTER_5_L 0x1f8ae
1202: #define GEN7_GMU_CX_GMU_PERF_COUNTER_5_H 0x1f8af
1203: #define GEN7_GPU_GMU_CX_GMU_RPMH_POWER_STATE 0x1f8ec
1204: #define GEN7_GMU_BOOT_KMD_LM_HANDSHAKE 0x1f9f0
1205:
1206: /* HFI registers*/
1207: #define GEN7_GMU_ALWAYS_ON_COUNTER_L 0x1f888
1208: #define GEN7_GMU_ALWAYS_ON_COUNTER_H 0x1f889
1209: #define GEN7_GMU_GMU_PWR_COL_KEEPALIVE 0x1f8c3
1210: #define GEN7_GMU_PWR_COL_PREEMPT_KEEPALIVE 0x1f8c4
1211: #define GEN7_GMU_HFI_CTRL_STATUS 0x1f980
1212: #define GEN7_GMU_HFI_QTBL_INFO 0x1f984
1213: #define GEN7_GMU_HFI_QTBL_ADDR 0x1f985
1214: #define GEN7_GMU_HFI_CTRL_INIT 0x1f986
1215: #define GEN7_GMU_GMU2HOST_INTR_SET 0x1f990
1216: #define GEN7_GMU_GMU2HOST_INTR_CLR 0x1f991
1217: #define GEN7_GMU_GMU2HOST_INTR_INFO 0x1f992
1218: #define GEN7_GMU_GMU2HOST_INTR_MASK 0x1f993
1219: #define GEN7_GMU_HOST2GMU_INTR_SET 0x1f994
1220: #define GEN7_GMU_HOST2GMU_INTR_CLR 0x1f995
1221: #define GEN7_GMU_HOST2GMU_INTR_RAW_INFO 0x1f996
1222: #define GEN7_GMU_HOST2GMU_INTR_EN_0 0x1f997
1223: #define GEN7_GMU_HOST2GMU_INTR_EN_1 0x1f998
1224: #define GEN7_GMU_HOST2GMU_INTR_EN_2 0x1f999
1225: #define GEN7_GMU_HOST2GMU_INTR_EN_3 0x1f99a
1226: #define GEN7_GMU_HOST2GMU_INTR_INFO_0 0x1f99b
1227: #define GEN7_GMU_HOST2GMU_INTR_INFO_1 0x1f99c
1228: #define GEN7_GMU_HOST2GMU_INTR_INFO_2 0x1f99d
1229: #define GEN7_GMU_HOST2GMU_INTR_INFO_3 0x1f99e
1230: #define GEN7_GMU_GENERAL_0 0x1f9c5
1231: #define GEN7_GMU_GENERAL_1 0x1f9c6
1232: #define GEN7_GMU_GENERAL_6 0x1f9cb
1233: #define GEN7_GMU_GENERAL_7 0x1f9cc
1234: #define GEN7_GMU_GENERAL_8 0x1f9cd
--- FILE: \gen8_reg.h | HITS: 2 ---
MATCH LINES: 1422, 1423
1410: #define GEN8_CX_DBGC_TCM_DBG_DATA 0x18581
1411:
1412: #define GEN8_GPU_GX_CLKCTL_GX_MALU_GDSCR 0x1a08e
1413: #define GEN8_GPU_GX_CLKCTL_GX_MALU_CFG_GDSCR 0x1a08f
1414:
1415: /* GMU control registers */
1416: #define GEN8_GMU_CM3_ITCM_START 0x1b400
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
--- FILE: \kgsl_bus.c | HITS: 6 ---
MATCH LINES: 65
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;
80: ab = _ab_buslevel_update(pwr,
81: pwr->ddr_table[pwr->cur_dcvs_buslevel]);
82: break;
83: case KGSL_BUS_VOTE_RT_HINT_ON:
84: pwr->rt_bus_hint_active = true;
85: /* Only update IB during bus hint */
86: ab = pwr->cur_ab;
87: break;
88: case KGSL_BUS_VOTE_RT_HINT_OFF:
89: pwr->rt_bus_hint_active = false;
MATCH LINES: 120, 143, 148, 152, 157
108: void kgsl_icc_set_tag(struct kgsl_pwrctrl *pwr, int buslevel)
109: {
110: if (buslevel == pwr->pwrlevels[0].bus_max)
111: icc_set_tag(pwr->icc_path, QCOM_ICC_TAG_ALWAYS | QCOM_ICC_TAG_PERF_MODE);
112: else
113: icc_set_tag(pwr->icc_path, QCOM_ICC_TAG_ALWAYS);
114: }
115: #endif
116:
117: static u32 *kgsl_bus_get_table_from_opp_freqs(struct platform_device *pdev, int *count)
118: {
119: struct device_node *node, *child;
120: u32 bus_freq = 0;
121: u32 *levels;
122: int index = 0, j = 0;
123:
124: node = of_parse_phandle(pdev->dev.of_node, "operating-points-v2", 0);
125: if (!node)
126: return ERR_PTR(-EINVAL);
127:
128: levels = kcalloc(KGSL_MAX_PWRLEVELS, sizeof(*levels), GFP_KERNEL);
129: if (!levels)
130: return ERR_PTR(-ENOMEM);
131:
132: /* Set lowest bandwidth vote to zero. */
133: levels[0] = 0;
134: index++;
135:
136: for_each_child_of_node(node, child) {
137: if (index >= KGSL_MAX_PWRLEVELS) {
138: dev_err(&pdev->dev, "opp-table items exceed the capacity\n");
139: kfree(levels);
140: return ERR_PTR(-EINVAL);
141: }
142:
143: if (of_property_read_u32(child, "opp-peak-kBps", &bus_freq)) {
144: dev_warn(&pdev->dev, "Missing opp-peak-kBps in OPP node\n");
145: continue;
146: }
147:
148: if (!bus_freq)
149: continue;
150:
151: for (j = 0; j < index; j++) {
152: if (levels[j] == bus_freq)
153: break;
154: }
155:
156: if (j == index)
157: levels[index++] = bus_freq;
158: }
159:
160: if (index == 1) {
161: kfree(levels);
162: return ERR_PTR(-EINVAL);
163: }
164:
165: sort(levels, index, sizeof(u32), cmp_u32, NULL);
166: *count = index;
167: return levels;
168: }
169:
170: u32 *kgsl_bus_get_table(struct platform_device *pdev,
171: const char *name, int *count)
172: {
173: u32 *levels;
174: int i, num = of_property_count_elems_of_size(pdev->dev.of_node,
175: name, sizeof(u32));
176:
177: /* If the bus wasn't specified, then build a static table */
178: if (num <= 0)
179: return ERR_PTR(-EINVAL);
180:
181: levels = kcalloc(num, sizeof(*levels), GFP_KERNEL);
--- FILE: \kgsl_device.h | HITS: 2 ---
MATCH LINES: 176, 178
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);
170: int (*setproperty_compat)(struct kgsl_device_private *dev_priv,
171: unsigned int type, void __user *value,
172: unsigned int sizebytes);
173: void (*drawctxt_sched)(struct kgsl_device *device,
174: struct kgsl_context *context);
175: void (*resume)(struct kgsl_device *device);
176: int (*regulator_enable)(struct kgsl_device *device);
177: bool (*is_hw_collapsible)(struct kgsl_device *device);
178: void (*regulator_disable)(struct kgsl_device *device);
179: void (*pwrlevel_change_settings)(struct kgsl_device *device,
180: unsigned int prelevel, unsigned int postlevel, bool post);
181: /**
182: * @query_property_list: query the list of properties
183: * supported by the device. If 'list' is NULL just return the total
184: * number of properties available otherwise copy up to 'count' items
185: * into the list and return the total number of items copied.
186: */
187: int (*query_property_list)(struct kgsl_device *device, u32 *list,
188: u32 count);
189: bool (*is_hwcg_on)(struct kgsl_device *device);
190: /** @gpu_clock_set: Target specific function to set gpu frequency */
191: int (*gpu_clock_set)(struct kgsl_device *device, u32 pwrlevel);
192: /** @gpu_bus_set: Target specific function to set gpu bandwidth */
193: int (*gpu_bus_set)(struct kgsl_device *device, int bus_level, u32 ab);
194: void (*deassert_gbif_halt)(struct kgsl_device *device);
195: /** @queue_recurring_cmd: Queue recurring commands to GMU */
196: int (*queue_recurring_cmd)(struct kgsl_device_private *dev_priv,
197: struct kgsl_context *context, struct kgsl_drawobj *drawobj);
198: /** @dequeue_recurring_cmd: Dequeue recurring commands from GMU */
199: int (*dequeue_recurring_cmd)(struct kgsl_device *device,
200: struct kgsl_context *context);
201: /** set_isdb_breakpoint_registers: Program isdb registers to issue break command */
202: void (*set_isdb_breakpoint_registers)(struct kgsl_device *device);
--- FILE: \kgsl_gmu_core.c | HITS: 11 ---
MATCH LINES: 156, 160, 161, 166, 170, 171
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);
MATCH LINES: 1245, 1247, 1252, 1274, 1292
1233: "qcom,gmu-freq-table", offset + 1, &gmu->vlvls[i]);
1234: if (ret)
1235: goto default_gmu_freq;
1236: }
1237:
1238: gmu->num_freqs = num_freqs;
1239:
1240: return 0;
1241:
1242: default_gmu_freq:
1243: /* The GMU frequency table is missing or invalid. Go with a default */
1244: gmu->freqs[0] = GMU_FREQ_MIN;
1245: gmu->vlvls[0] = RPMH_REGULATOR_LEVEL_LOW_SVS;
1246: gmu->freqs[1] = GMU_FREQ_MAX;
1247: gmu->vlvls[1] = RPMH_REGULATOR_LEVEL_SVS;
1248:
1249: gmu->num_freqs = 2;
1250:
1251: if (adreno_is_a6xx(adreno_dev) && !adreno_is_a660(adreno_dev))
1252: gmu->vlvls[0] = RPMH_REGULATOR_LEVEL_MIN_SVS;
1253:
1254: return 0;
1255: }
1256:
1257: static int scale_hub_clock(struct kgsl_device *device, u32 cx_voltage)
1258: {
1259: struct gmu_core_device *gmu = &device->gmu_core;
1260: int ret, i;
1261:
1262: for (i = 0; i < gmu->num_hub_freqs; i++) {
1263: if (gmu->hub_vlvls[i] <= cx_voltage)
1264: break;
1265: }
1266:
1267: /* Default to minimum hub frequency if no match found */
1268: if (i == gmu->num_hub_freqs)
1269: i = gmu->num_hub_freqs - 1;
1270:
1271: if (i == gmu->cur_hub_level)
1272: return 0;
1273:
1274: ret = kgsl_clk_set_rate(gmu->clks, gmu->num_clks, "hub_clk", gmu->hub_freqs[i]);
1275: if (ret && ret != -ENODEV) {
1276: dev_err(GMU_PDEV_DEV(device), "Unable to set the HUB clock ret %d\n", ret);
1277: return ret;
1278: }
1279:
1280: gmu->cur_hub_level = i;
1281: return 0;
1282: }
1283:
1284: int gmu_core_clock_set_rate(struct kgsl_device *device, u32 gmu_level)
1285: {
1286: struct gmu_core_device *gmu_core = &device->gmu_core;
1287: int ret;
1288: u32 req_freq = gmu_core->freqs[gmu_level];
1289:
1290: gmu_core_rdpm_cx_freq_update(device, req_freq / 1000);
1291:
1292: ret = kgsl_clk_set_rate(gmu_core->clks, gmu_core->num_clks, "gmu_clk", req_freq);
1293: if (ret) {
1294: dev_err(GMU_PDEV_DEV(device), "GMU clock:%d set failed:%d\n", req_freq, ret);
1295: return ret;
1296: }
1297:
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:
--- FILE: \kgsl_gmu_core.h | HITS: 8 ---
MATCH LINES: 97, 104, 112, 144
85: * and easy to ensure not reaching over/under the range
86: * of 8 bits.
87: */
88: enum oob_request {
89: oob_gpu = 0,
90: oob_perfcntr = 1,
91: oob_boot_slumber = 6, /* reserved special case */
92: oob_dcvs = 7, /* reserved special case */
93: oob_max,
94: };
95:
96: #define GPU_HW_ACTIVE 0x00
97: #define GPU_HW_IFPC 0x03
98: #define GPU_HW_MINBW 0x06
99: #define GPU_HW_SLUMBER 0x0f
100:
101: /*
102: * Wait time before trying to write the register again.
103: * Hopefully the GMU has finished waking up during this delay.
104: * This delay must be less than the IFPC main hysteresis or
105: * the GMU will start shutting down before we try again.
106: */
107: #define GMU_CORE_WAKEUP_DELAY_US 10
108:
109: /* Max amount of tries to wake up the GMU. The short retry
110: * limit is half of the long retry limit. After the short
111: * number of retries, we print an informational message to say
112: * exiting IFPC is taking longer than expected. We continue
113: * to retry after this until the long retry limit.
114: */
115: #define GMU_CORE_SHORT_WAKEUP_RETRY_LIMIT 100
116: #define GMU_CORE_LONG_WAKEUP_RETRY_LIMIT 200
117:
118: #define FENCE_STATUS_WRITEDROPPED0_MASK 0x1
119: #define FENCE_STATUS_WRITEDROPPED1_MASK 0x2
120:
121: #define HFI_VERSION(major, minor, step) \
122: (FIELD_PREP(GENMASK(31, 28), major) | \
123: FIELD_PREP(GENMASK(27, 16), minor) | \
124: FIELD_PREP(GENMASK(15, 0), step))
125:
126: #define GMU_VER_MAJOR(ver) (((ver) >> 28) & 0xF)
127: #define GMU_VER_MINOR(ver) (((ver) >> 16) & 0xFFF)
128: #define GMU_VER_STEP(ver) ((ver) & 0xFFFF)
129: #define GMU_VERSION(major, minor, step) \
130: ((((major) & 0xF) << 28) | (((minor) & 0xFFF) << 16) | ((step) & 0xFFFF))
131:
132: #define GMU_INT_WDOG_BITE BIT(0)
133: #define GMU_INT_RSCC_COMP BIT(1)
134: #define GMU_INT_FENCE_ERR BIT(3)
135: #define GMU_INT_DBD_WAKEUP BIT(4)
136: #define GMU_INT_HOST_AHB_BUS_ERR BIT(5)
137: #define GMU_AO_INT_MASK \
138: (GMU_INT_WDOG_BITE | \
139: GMU_INT_FENCE_ERR | \
140: GMU_INT_HOST_AHB_BUS_ERR)
141:
142: /* Bitmask for GPU low power mode enabling and hysterisis*/
143: #define SPTP_ENABLE_MASK (BIT(2) | BIT(0))
144: #define IFPC_ENABLE_MASK (BIT(1) | BIT(0))
145:
146: /* Bitmask for RPMH capability enabling */
147: #define RPMH_INTERFACE_ENABLE BIT(0)
148: #define LLC_VOTE_ENABLE BIT(4)
149: #define DDR_VOTE_ENABLE BIT(8)
150: #define MX_VOTE_ENABLE BIT(9)
151: #define CX_VOTE_ENABLE BIT(10)
152: #define GFX_VOTE_ENABLE BIT(11)
153: #define RPMH_ENABLE_MASK (RPMH_INTERFACE_ENABLE | \
154: LLC_VOTE_ENABLE | \
155: DDR_VOTE_ENABLE | \
156: MX_VOTE_ENABLE | \
157: CX_VOTE_ENABLE | \
158: GFX_VOTE_ENABLE)
159:
160: /* Constants for GMU OOBs */
161: #define OOB_BOOT_OPTION 0
162: #define OOB_SLUMBER_OPTION 1
163:
164: /* Gmu FW block header format */
165: struct gmu_block_header {
166: u32 addr;
167: u32 size;
168: u32 type;
MATCH LINES: 529, 530
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 {
MATCH LINES: 666, 667
654: *
655: * Write a series of GMU registers quickly without bothering to spend time
656: * logging the register writes. The logging of these writes causes extra
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
--- FILE: \kgsl_iommu.c | HITS: 8 ---
MATCH LINES: 29
17: #include <linux/pm_domain.h>
18: #include <linux/pm_runtime.h>
19: #include <linux/version.h>
20: #if (KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE)
21: #include <linux/firmware/qcom/qcom_scm.h>
22: #else
23: #include <linux/qcom_scm.h>
24: #endif
25: #if IS_ENABLED(CONFIG_QCOM_SCM_ADDON)
26: #include <linux/firmware/qcom/qcom_scm_addon.h>
27: #endif
28: #include <linux/random.h>
29: #include <linux/regulator/consumer.h>
30: #include <soc/qcom/secure_buffer.h>
31:
32: #include "adreno.h"
33: #include "kgsl_device.h"
34: #include "kgsl_iommu.h"
35: #include "kgsl_mmu.h"
36: #include "kgsl_pwrctrl.h"
37: #include "kgsl_sharedmem.h"
38: #include "kgsl_trace.h"
39:
40: #define KGSL_IOMMU_SPLIT_TABLE_BASE 0x0001ff8000000000ULL
41:
42: #define KGSL_IOMMU_IDR1_OFFSET 0x24
43: #define IDR1_NUMPAGENDXB GENMASK(30, 28)
44: #define IDR1_PAGESIZE BIT(31)
45:
46: static const struct kgsl_mmu_pt_ops secure_pt_ops;
47: static const struct kgsl_mmu_pt_ops default_pt_ops;
48: static const struct kgsl_mmu_pt_ops iopgtbl_pt_ops;
49:
50: /* Zero page for non-secure VBOs */
51: static struct page *kgsl_vbo_zero_page;
52:
53: /*
MATCH LINES: 1323, 1324, 1340, 1341
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);
1325:
1326: iommu_dev = iommu->smmu_vir_cx_pd ? iommu->smmu_vir_cx_pd : &iommu->pdev->dev;
1327: if (pm_runtime_enabled(iommu_dev))
1328: pm_runtime_put_sync(iommu_dev);
1329: }
1330:
1331: /*
1332: * kgsl_iommu_enable_clk - Enable iommu clocks
1333: * Enable all the IOMMU clocks
1334: */
1335: static void kgsl_iommu_enable_clk(struct kgsl_mmu *mmu)
1336: {
1337: struct kgsl_iommu *iommu = &mmu->iommu;
1338: struct device *iommu_dev;
1339:
1340: if (!IS_ERR_OR_NULL(iommu->cx_regulator))
1341: WARN_ON(regulator_enable(iommu->cx_regulator));
1342:
1343: iommu_dev = iommu->smmu_vir_cx_pd ? iommu->smmu_vir_cx_pd : &iommu->pdev->dev;
1344: if (pm_runtime_enabled(iommu_dev))
1345: WARN_ON(pm_runtime_resume_and_get(iommu_dev));
1346:
1347: WARN_ON(clk_bulk_prepare_enable(iommu->num_clks, iommu->clks));
1348:
1349: atomic_inc(&iommu->clk_enable_count);
1350: }
1351:
1352: /* kgsl_iommu_get_ttbr0 - Get TTBR0 setting for a pagetable */
1353: static u64 kgsl_iommu_get_ttbr0(struct kgsl_pagetable *pagetable)
1354: {
1355: struct kgsl_iommu_pt *pt = to_iommu_pt(pagetable);
1356:
1357: /* This will be zero if KGSL_MMU_IOPGTABLE is not enabled */
1358: return pt->ttbr0;
1359: }
1360:
1361: /* Set TTBR0 for the given context with the specific configuration */
1362: static void kgsl_iommu_set_ttbr0(struct kgsl_iommu_context *context,
1363: struct kgsl_mmu *mmu, const struct io_pgtable_cfg *pgtbl_cfg)
1364: {
1365: struct adreno_smmu_priv *adreno_smmu;
MATCH LINES: 3199, 3201, 3202
3187:
3188: iommu->clks[iommu->num_clks].id = kgsl_iommu_clocks[i];
3189: iommu->clks[iommu->num_clks++].clk = c;
3190: }
3191:
3192: /*
3193: * IOMMU device is already bound to power domain by core framework
3194: * as there is only single power domain
3195: */
3196: if (of_property_read_bool(pdev->dev.of_node, "power-domains")) {
3197: pm_runtime_enable(&pdev->dev);
3198: } else {
3199: struct regulator *cx_regulator = devm_regulator_get(&pdev->dev, "vddcx");
3200:
3201: if (!IS_ERR(cx_regulator))
3202: iommu->cx_regulator = cx_regulator;
3203: }
3204:
3205: set_bit(KGSL_MMU_PAGED, &mmu->features);
3206:
3207: mmu->type = KGSL_MMU_TYPE_IOMMU;
3208: mmu->mmu_ops = &kgsl_iommu_ops;
3209:
3210: /* Peek at the phandle to set up configuration */
3211: kgsl_iommu_check_config(mmu, node);
3212:
3213: /* Probe the default pagetable */
3214: ret = iommu_probe_user_context(device, node);
3215: if (ret)
3216: goto err;
3217:
3218: /* Probe the secure pagetable (this is optional) */
3219: iommu_probe_secure_context(device, node);
3220:
3221: /* Map any globals that might have been created early */
3222: kgsl_iommu_map_globals(device, mmu);
3223:
3224: /* QDSS is supported only when QCOM_KGSL_QDSS_STM is enabled */
3225: if (IS_ENABLED(CONFIG_QCOM_KGSL_QDSS_STM))
3226: device->qdss_desc = kgsl_allocate_global_fixed(device,
--- FILE: \kgsl_iommu.h | HITS: 2 ---
MATCH LINES: 206, 207
194: * be mapped in all contexts
195: */
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: };
--- FILE: \kgsl_pwrctrl.c | HITS: 63 ---
MATCH LINES: 15
3: * Copyright (c) 2010-2021, The Linux Foundation. All rights reserved.
4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
5: */
6:
7: #include <linux/clk/qcom.h>
8: #include <linux/interconnect.h>
9: #include <linux/iopoll.h>
10: #include <linux/of_device.h>
11: #include <linux/of_platform.h>
12: #include <linux/pm_domain.h>
13: #include <linux/pm_opp.h>
14: #include <linux/pm_runtime.h>
15: #include <linux/regulator/consumer.h>
16: #include <linux/slab.h>
17: #include <linux/thermal.h>
18: #include <linux/msm_kgsl.h>
19: #include <linux/units.h>
20: #include <linux/version.h>
21: #include <soc/qcom/dcvs.h>
22:
23: #include "kgsl_bus.h"
24: #include "kgsl_eventlog.h"
25: #include "kgsl_device.h"
26: #include "kgsl_gmu_core.h"
27: #include "kgsl_power_trace.h"
28: #include "kgsl_pwrscale.h"
29: #include "kgsl_sysfs.h"
30: #include "kgsl_trace.h"
31: #include "kgsl_util.h"
32:
33: #define UPDATE_BUSY_VAL 1000000
34:
35: #define KGSL_MAX_BUSLEVELS 20
36:
37: #define GX_GDSC_TIMEOUT_MS 200
38:
39: /* Order deeply matters here because reasons. New entries go on the end */
MATCH LINES: 65, 66
53: "rbcpr_clk",
54: "iref_clk",
55: "gmu_clk",
56: "ahb_clk",
57: "smmu_vote",
58: "apb_pclk",
59: "hub_cx_int_clk",
60: };
61:
62: static void kgsl_pwrctrl_clk(struct kgsl_device *device, bool state,
63: int requested_state);
64: static int kgsl_pwrctrl_pwrrail(struct kgsl_device *device, bool state);
65: static int _isense_clk_set_rate(struct kgsl_pwrctrl *pwr, int level);
66: static int kgsl_pwrctrl_clk_set_rate(struct clk *grp_clk, unsigned int freq,
67: const char *name);
68: static void _gpu_clk_prepare_enable(struct kgsl_device *device,
69: struct clk *clk, const char *name);
70: static void _bimc_clk_prepare_enable(struct kgsl_device *device,
71: struct clk *clk, const char *name);
72:
73: /**
74: * _adjust_pwrlevel() - Given a requested power level do bounds checking on the
75: * constraints and return the nearest possible level
76: * @pwr: kgsl_pwrctrl structure for the device
77: * @level: Requested level
78: * @pwrc: Pointer to the power constraint to be applied
79: *
80: * Apply thermal and max/min limits first. Then force the level with a
81: * constraint if one exists.
82: */
83: static u32 _adjust_pwrlevel(struct kgsl_pwrctrl *pwr, u32 level, struct kgsl_pwr_constraint *pwrc)
84: {
85: u32 thermal_pwrlevel = max_t(u32, READ_ONCE(pwr->thermal_pwrlevel),
86: READ_ONCE(pwr->pmqos_max_pwrlevel));
87: /* Ensure that max pwrlevel is within pmqos max limit */
88: u32 max_pwrlevel = max_t(u32, pwr->max_pwrlevel, thermal_pwrlevel);
89: /* Ensure that min pwrlevel is within thermal limit */
90: u32 min_pwrlevel = max_t(u32, pwr->min_pwrlevel, thermal_pwrlevel);
MATCH LINES: 251, 267
239: }
240: /*
241: * Update the bus before the GPU clock to prevent underrun during
242: * frequency increases.
243: */
244: if (new_level < old_level)
245: kgsl_bus_update(device, KGSL_BUS_VOTE_ON);
246:
247: pwrlevel = &pwr->pwrlevels[pwr->active_pwrlevel];
248: /* Change register settings if any BEFORE pwrlevel change*/
249: kgsl_pwrctrl_pwrlevel_change_settings(device, 0);
250: device->ftbl->gpu_clock_set(device, pwr->active_pwrlevel);
251: _isense_clk_set_rate(pwr, pwr->active_pwrlevel);
252:
253: /* Update the bus after GPU clock decreases. */
254: if (new_level > old_level)
255: kgsl_bus_update(device, KGSL_BUS_VOTE_ON);
256:
257: /*
258: * Some targets do not support the bandwidth requirement of
259: * GPU at TURBO, for such targets we need to set GPU-BIMC
260: * interface clocks to TURBO directly whenever GPU runs at
261: * TURBO. The TURBO frequency of gfx-bimc need to be defined
262: * in target device tree.
263: */
264: if (pwr->gpu_bimc_int_clk) {
265: if (pwr->active_pwrlevel == 0 &&
266: !pwr->gpu_bimc_interface_enabled) {
267: kgsl_pwrctrl_clk_set_rate(pwr->gpu_bimc_int_clk,
268: pwr->gpu_bimc_int_clk_freq,
269: "bimc_gpu_clk");
270: _bimc_clk_prepare_enable(device,
271: pwr->gpu_bimc_int_clk,
272: "bimc_gpu_clk");
273: pwr->gpu_bimc_interface_enabled = true;
274: } else if (pwr->previous_pwrlevel == 0
275: && pwr->gpu_bimc_interface_enabled) {
276: clk_disable_unprepare(pwr->gpu_bimc_int_clk);
277: pwr->gpu_bimc_interface_enabled = false;
278: }
279: }
280:
281: /* Change register settings if any AFTER pwrlevel change*/
282: kgsl_pwrctrl_pwrlevel_change_settings(device, 1);
283: }
284:
285: void kgsl_pwrctrl_set_constraint(struct kgsl_device *device,
286: struct kgsl_pwr_constraint *pwrc, uint32_t id, u32 ts)
287: {
288: unsigned int constraint;
289: struct kgsl_pwr_constraint *pwrc_old;
290:
291: if (device == NULL || pwrc == NULL)
MATCH LINES: 1283, 1296, 1309, 1321
1271: clk_disable_unprepare(pwr->gpu_bimc_int_clk);
1272: pwr->gpu_bimc_interface_enabled = false;
1273: }
1274:
1275: for (i = KGSL_MAX_CLKS - 1; i > 0; i--)
1276: clk_disable(pwr->grp_clks[i]);
1277: /* High latency clock maintenance. */
1278: if (pwr->pwrlevels[0].gpu_freq > 0) {
1279: for (i = KGSL_MAX_CLKS - 1; i > 0; i--)
1280: clk_unprepare(pwr->grp_clks[i]);
1281: device->ftbl->gpu_clock_set(device,
1282: pwr->num_pwrlevels - 1);
1283: _isense_clk_set_rate(pwr,
1284: pwr->num_pwrlevels - 1);
1285: }
1286:
1287: /* Turn off the IOMMU clocks */
1288: kgsl_mmu_disable_clk(&device->mmu);
1289: } else if (requested_state == KGSL_STATE_SLUMBER) {
1290: /* High latency clock maintenance. */
1291: for (i = KGSL_MAX_CLKS - 1; i > 0; i--)
1292: clk_unprepare(pwr->grp_clks[i]);
1293: if ((pwr->pwrlevels[0].gpu_freq > 0)) {
1294: device->ftbl->gpu_clock_set(device,
1295: pwr->num_pwrlevels - 1);
1296: _isense_clk_set_rate(pwr,
1297: pwr->num_pwrlevels - 1);
1298: }
1299: }
1300: } else {
1301: if (!test_and_set_bit(KGSL_PWRFLAGS_CLK_ON,
1302: &pwr->power_flags)) {
1303: trace_kgsl_clk(device, state,
1304: kgsl_pwrctrl_active_freq(pwr));
1305:
1306: if (pwr->pwrlevels[0].gpu_freq > 0) {
1307: device->ftbl->gpu_clock_set(device,
1308: pwr->active_pwrlevel);
1309: _isense_clk_set_rate(pwr,
1310: pwr->active_pwrlevel);
1311: }
1312:
1313: for (i = KGSL_MAX_CLKS - 1; i > 0; i--)
1314: _gpu_clk_prepare_enable(device,
1315: pwr->grp_clks[i], clocks[i]);
1316:
1317: /* Enable the gpu-bimc-interface clocks */
1318: if (pwr->gpu_bimc_int_clk) {
1319: if (pwr->active_pwrlevel == 0 &&
1320: !pwr->gpu_bimc_interface_enabled) {
1321: kgsl_pwrctrl_clk_set_rate(
1322: pwr->gpu_bimc_int_clk,
1323: pwr->gpu_bimc_int_clk_freq,
1324: "bimc_gpu_clk");
1325: _bimc_clk_prepare_enable(device,
1326: pwr->gpu_bimc_int_clk,
1327: "bimc_gpu_clk");
1328: pwr->gpu_bimc_interface_enabled = true;
1329: }
1330: }
1331:
1332: /* Turn on the IOMMU clocks */
1333: kgsl_mmu_enable_clk(&device->mmu);
1334: }
1335:
1336: }
1337: }
1338:
1339: int kgsl_pwrctrl_axi(struct kgsl_device *device, bool state)
1340: {
1341: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1342:
1343: if (test_bit(KGSL_PWRFLAGS_AXI_ON, &pwr->ctrl_flags))
1344: return 0;
1345:
MATCH LINES: 1383, 1388, 1393, 1397, 1431, 1436, 1437, 1439, 1450, 1451, 1468, 1471, 1472, 1486, 1493, 1494, 1504, 1507, 1508, 1527, 1528, 1529
1371:
1372: for (;;) {
1373: if (!kgsl_genpd_is_enabled(dev))
1374: return 0;
1375:
1376: if (ktime_compare(ktime_get(), tout) > 0)
1377: return (!kgsl_genpd_is_enabled(dev) ? 0 : -ETIMEDOUT);
1378:
1379: usleep_range((100 >> 2) + 1, 100);
1380: }
1381: }
1382:
1383: int kgsl_regulator_disable_wait(struct regulator *reg, u32 timeout)
1384: {
1385: ktime_t tout = ktime_add_us(ktime_get(), timeout * USEC_PER_MSEC);
1386: int ret;
1387:
1388: ret = regulator_disable(reg);
1389: if (ret)
1390: return ret;
1391:
1392: for (;;) {
1393: if (!regulator_is_enabled(reg))
1394: return 0;
1395:
1396: if (ktime_compare(ktime_get(), tout) > 0)
1397: return (!regulator_is_enabled(reg) ? 0 : -ETIMEDOUT);
1398:
1399: usleep_range((100 >> 2) + 1, 100);
1400: }
1401: }
1402:
1403: void kgsl_pwrctrl_disable_mx_gdsc(struct kgsl_device *device)
1404: {
1405: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1406:
1407: if (pwr->gmu_mx_pd)
1408: pm_runtime_put_sync(pwr->gmu_mx_pd);
1409: }
1410:
1411: int kgsl_pwrctrl_enable_mx_gdsc(struct kgsl_device *device)
1412: {
1413: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1414: int ret;
1415:
1416: if (!pwr->gmu_mx_pd)
1417: return 0;
1418:
1419: ret = pm_runtime_resume_and_get(pwr->gmu_mx_pd);
1420: if (ret)
1421: dev_err(device->dev, "Failed to enable MX gdsc, error %d\n", ret);
1422:
1423: return ret;
1424: }
1425:
1426: int kgsl_pwrctrl_enable_cx_gdsc(struct kgsl_device *device)
1427: {
1428: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1429: int ret;
1430:
1431: if (!pwr->cx_regulator && !pwr->gmu_cx_pd)
1432: return 0;
1433:
1434: ret = wait_for_completion_timeout(&pwr->cx_gdsc_gate, msecs_to_jiffies(5000));
1435: if (!ret) {
1436: /* Dump the cx regulator consumer list */
1437: if (pwr->cx_regulator) {
1438: dev_err(device->dev, "GPU CX wait timeout. Dumping CX votes:\n");
1439: qcom_clk_dump(NULL, pwr->cx_regulator, false);
1440: } else {
1441: dev_err(device->dev, "GPU CX wait timeout\n");
1442: }
1443: KGSL_GMU_CORE_FORCE_PANIC(device->gmu_core.gf_panic,
1444: GMU_PDEV(device), 0ULL, GMU_FAULT_CX_WAIT_TIMEOUT);
1445: }
1446:
1447: if (!completion_done(&pwr->cx_gdsc_gate))
1448: log_kgsl_cx_wait_timeout_event(HLOS_CX_WAIT_TIMEOUT);
1449:
1450: if (pwr->cx_regulator)
1451: ret = regulator_enable(pwr->cx_regulator);
1452: else
1453: ret = pm_runtime_resume_and_get(pwr->gmu_cx_pd);
1454:
1455: if (ret)
1456: dev_err(device->dev, "Failed to enable CX gdsc, error %d\n", ret);
1457:
1458: kgsl_mmu_send_tlb_hint(&device->mmu, false);
1459: pwr->cx_gdsc_wait = false;
1460: return ret;
1461: }
1462:
1463: int kgsl_pwrctrl_enable_gx_gdsc(struct kgsl_device *device)
1464: {
1465: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1466: int ret;
1467:
1468: if (!pwr->gx_regulator && !pwr->gx_pd)
1469: return 0;
1470:
1471: if (pwr->gx_regulator)
1472: ret = regulator_enable(pwr->gx_regulator);
1473: else
1474: ret = pm_runtime_resume_and_get(pwr->gx_pd);
1475:
1476: if (ret)
1477: dev_err(device->dev, "Failed to enable GX gdsc, error %d\n", ret);
1478:
1479: return ret;
1480: }
1481:
1482: void kgsl_pwrctrl_disable_cx_gdsc(struct kgsl_device *device)
1483: {
1484: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1485:
1486: if (!pwr->cx_regulator && !pwr->gmu_cx_pd)
1487: return;
1488:
1489: kgsl_mmu_send_tlb_hint(&device->mmu, true);
1490: reinit_completion(&pwr->cx_gdsc_gate);
1491: pwr->cx_gdsc_wait = true;
1492:
1493: if (pwr->cx_regulator)
1494: regulator_disable(pwr->cx_regulator);
1495: else
1496: pm_runtime_put_sync(pwr->gmu_cx_pd);
1497: }
1498:
1499: void kgsl_pwrctrl_disable_gx_gdsc(struct kgsl_device *device)
1500: {
1501: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1502: int ret;
1503:
1504: if (!pwr->gx_regulator && !pwr->gx_pd)
1505: return;
1506:
1507: if (pwr->gx_regulator)
1508: ret = kgsl_regulator_disable_wait(pwr->gx_regulator, GX_GDSC_TIMEOUT_MS);
1509: else
1510: ret = kgsl_genpd_disable_wait(pwr->gx_pd, GX_GDSC_TIMEOUT_MS);
1511:
1512: if (ret)
1513: dev_err(device->dev, "vdd is stuck on, error %d\n", ret);
1514: }
1515:
1516: static int enable_gdscs(struct kgsl_device *device)
1517: {
1518: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1519: int ret;
1520:
1521: if (test_and_set_bit(KGSL_PWRFLAGS_POWER_ON, &pwr->power_flags))
1522: return 0;
1523:
1524: ret = kgsl_pwrctrl_enable_cx_gdsc(device);
1525: if (!ret) {
1526: /* Set parent in retention voltage to power up vdd supply */
1527: ret = kgsl_regulator_set_voltage(device->dev,
1528: pwr->gx_regulator_parent,
1529: pwr->gx_regulator_parent_min_corner);
1530: if (!ret)
1531: ret = kgsl_pwrctrl_enable_gx_gdsc(device);
1532: }
1533:
1534: if (ret) {
1535: clear_bit(KGSL_PWRFLAGS_POWER_ON, &pwr->power_flags);
1536: return ret;
1537: }
1538:
1539: trace_kgsl_rail(device, KGSL_PWRFLAGS_POWER_ON);
1540: return 0;
1541: }
1542:
1543: #ifdef CONFIG_QCOM_KGSL_UPSTREAM
1544: static int kgsl_device_link_add_cxpd_iommu(struct kgsl_device *device)
1545: {
1546: struct device_node *phandle;
1547: struct kgsl_iommu *iommu = KGSL_IOMMU(device);
1548: struct platform_device *pdev = iommu->user_context.pdev;
1549: struct platform_device *iommu_pdev;
1550:
1551: if (!device->pwrctrl.cx_pd)
1552: return 0;
1553:
MATCH LINES: 1643, 1645, 1646, 1648, 1650, 1672, 1674, 1675, 1677, 1679
1631: }
1632: pwr->cx_pd = cx_pd;
1633:
1634: pwr->gmu_cx_pd = dev_pm_domain_attach_by_name(&pdev->dev, "gmu_cx");
1635: if (IS_ERR_OR_NULL(pwr->gmu_cx_pd)) {
1636: dev_err(device->dev,
1637: "Failed to attach GMU cx power domain, falling back to cx pd\n");
1638: /* Fallback to cx pd voting if gmu_cx pd is unavailable */
1639: pwr->gmu_cx_pd = cx_pd;
1640: }
1641:
1642: } else {
1643: struct regulator *cx_regulator = devm_regulator_get(&pdev->dev, "vddcx");
1644:
1645: if (IS_ERR(cx_regulator)) {
1646: dev_err_probe(&pdev->dev, PTR_ERR(cx_regulator),
1647: "Couldn't get the vddcx\n");
1648: return PTR_ERR(cx_regulator);
1649: }
1650: pwr->cx_regulator = cx_regulator;
1651: }
1652:
1653: return 0;
1654: }
1655:
1656: static int kgsl_pwrctrl_probe_gx_gdsc(struct kgsl_device *device, struct platform_device *pdev)
1657: {
1658: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1659:
1660: if (of_property_read_bool(pdev->dev.of_node, "power-domains")) {
1661: /* Get virtual device handle for GX GDSC to control it */
1662: struct device *gx_pd = dev_pm_domain_attach_by_name(&pdev->dev, "gx");
1663:
1664: if (IS_ERR_OR_NULL(gx_pd)) {
1665: dev_err_probe(&pdev->dev, PTR_ERR(gx_pd),
1666: "Failed to attach gx power domain\n");
1667: return IS_ERR(gx_pd) ? PTR_ERR(gx_pd) : -EINVAL;
1668: }
1669: pwr->gx_pd = gx_pd;
1670: dev_pm_syscore_device(pwr->gx_pd, true);
1671: } else {
1672: struct regulator *gx_regulator = devm_regulator_get(&pdev->dev, "vdd");
1673:
1674: if (IS_ERR(gx_regulator)) {
1675: dev_err_probe(&pdev->dev, PTR_ERR(gx_regulator),
1676: "Couldn't get the vdd\n");
1677: return PTR_ERR(gx_regulator);
1678: }
1679: pwr->gx_regulator = gx_regulator;
1680: }
1681:
1682: return 0;
1683: }
1684:
1685: int kgsl_pwrctrl_probe_gdscs(struct kgsl_device *device, struct platform_device *pdev)
1686: {
1687: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1688: int ret;
1689:
1690: ret = kgsl_pwrctrl_probe_cx_gdsc(device, pdev);
1691: if (ret)
1692: return ret;
1693:
1694: ret = kgsl_pwrctrl_probe_gx_gdsc(device, pdev);
1695: if (!ret)
1696: return ret;
1697:
1698: /* Detach pm domains during failure */
1699: if (pwr->gmu_cx_pd && (pwr->gmu_cx_pd != pwr->cx_pd))
1700: dev_pm_domain_detach(pwr->gmu_cx_pd, false);
1701:
1702: if (pwr->cx_pd)
1703: dev_pm_domain_detach(pwr->cx_pd, false);
MATCH LINES: 1724, 1747, 1751, 1752, 1765, 1779, 1780, 1785
1712: unsigned long event, void *data)
1713: {
1714: struct kgsl_pwrctrl *pwr = container_of(nb, struct kgsl_pwrctrl, cx_gdsc_nb);
1715: struct kgsl_device *device = container_of(pwr, struct kgsl_device, pwrctrl);
1716: u32 val;
1717:
1718: if (!pwr->cx_gdsc_wait)
1719: return 0;
1720:
1721: if (pwr->cx_pd && (event != GENPD_NOTIFY_OFF))
1722: return 0;
1723:
1724: if (pwr->cx_regulator && !(event & REGULATOR_EVENT_DISABLE))
1725: return 0;
1726:
1727: if (pwr->cx_cfg_gdsc_offset) {
1728: if (kgsl_regmap_read_poll_timeout(&device->regmap, pwr->cx_cfg_gdsc_offset,
1729: val, (val & BIT(15)), 100, 100 * 1000)) {
1730: dev_err(device->dev, "GPU CX GDSC power down timed out\n");
1731: log_kgsl_cx_wait_timeout_event(NONHLOS_CX_WAIT_TIMEOUT);
1732: KGSL_GMU_CORE_FORCE_PANIC(device->gmu_core.gf_panic,
1733: GMU_PDEV(device), 0ULL, GMU_FAULT_WAIT_FOR_CX);
1734: }
1735: }
1736:
1737: pwr->cx_gdsc_wait = false;
1738: complete_all(&pwr->cx_gdsc_gate);
1739:
1740: return 0;
1741: }
1742:
1743: static int kgsl_register_gdsc_notifier(struct kgsl_device *device)
1744: {
1745: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1746:
1747: if (!pwr->cx_regulator && !pwr->cx_pd)
1748: return 0;
1749:
1750: pwr->cx_gdsc_nb.notifier_call = kgsl_cx_gdsc_event;
1751: if (pwr->cx_regulator)
1752: return devm_regulator_register_notifier(pwr->cx_regulator, &pwr->cx_gdsc_nb);
1753:
1754: return dev_pm_genpd_add_notifier(pwr->cx_pd, &pwr->cx_gdsc_nb);
1755: }
1756:
1757: static int kgsl_pwrctrl_pwrrail(struct kgsl_device *device, bool state)
1758: {
1759: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1760: int status = 0;
1761:
1762: if (gmu_core_gpmu_isenabled(device))
1763: return 0;
1764: /*
1765: * Disabling the regulator means also disabling dependent clocks.
1766: * Hence don't disable it if force clock ON is set.
1767: */
1768: if (test_bit(KGSL_PWRFLAGS_POWER_ON, &pwr->ctrl_flags) ||
1769: test_bit(KGSL_PWRFLAGS_CLK_ON, &pwr->ctrl_flags))
1770: return 0;
1771:
1772: if (!state) {
1773: if (test_and_clear_bit(KGSL_PWRFLAGS_POWER_ON,
1774: &pwr->power_flags)) {
1775: kgsl_mmu_send_tlb_hint(&device->mmu, true);
1776: trace_kgsl_rail(device, state);
1777:
1778: /* Set the parent in retention voltage to disable CPR interrupts */
1779: kgsl_regulator_set_voltage(device->dev, pwr->gx_regulator_parent,
1780: pwr->gx_regulator_parent_min_corner);
1781:
1782: kgsl_pwrctrl_disable_gx_gdsc(device);
1783:
1784: /* Remove the vote for the vdd parent supply */
1785: kgsl_regulator_set_voltage(device->dev, pwr->gx_regulator_parent, 0);
1786:
1787: kgsl_pwrctrl_disable_cx_gdsc(device);
1788: }
1789: } else {
1790: status = enable_gdscs(device);
1791: kgsl_mmu_send_tlb_hint(&device->mmu, false);
1792: }
1793:
1794: return status;
1795: }
1796:
1797: void kgsl_pwrctrl_irq(struct kgsl_device *device, bool state)
1798: {
1799: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1800:
1801: if (!(device->freq_limiter_intr_num || pwr->interrupt_num))
1802: return;
1803:
1804: if (state) {
1805: if (!test_and_set_bit(KGSL_PWRFLAGS_IRQ_ON,
1806: &pwr->power_flags)) {
1807: trace_kgsl_irq(device, state);
1808: if (pwr->interrupt_num > 0)
1809: enable_irq(pwr->interrupt_num);
MATCH LINES: 1894, 1904, 1935, 1938
1882: break;
1883: }
1884: }
1885:
1886: if (pwr->isense_clk_indx && of_property_read_u32(dev->of_node,
1887: "qcom,isense-clk-on-level", &pwr->isense_clk_on_level)) {
1888: dev_err(dev, "Couldn't get isense clock on level\n");
1889: return -ENXIO;
1890: }
1891: return 0;
1892: }
1893:
1894: static int _isense_clk_set_rate(struct kgsl_pwrctrl *pwr, int level)
1895: {
1896: int rate;
1897:
1898: if (!pwr->isense_clk_indx)
1899: return -EINVAL;
1900:
1901: rate = clk_round_rate(pwr->grp_clks[pwr->isense_clk_indx],
1902: level > pwr->isense_clk_on_level ?
1903: KGSL_XO_CLK_FREQ : KGSL_ISENSE_CLK_FREQ);
1904: return kgsl_pwrctrl_clk_set_rate(pwr->grp_clks[pwr->isense_clk_indx],
1905: rate, clocks[pwr->isense_clk_indx]);
1906: }
1907:
1908: /*
1909: * _gpu_clk_prepare_enable - Enable the specified GPU clock
1910: * Try once to enable it and then BUG() for debug
1911: */
1912: static void _gpu_clk_prepare_enable(struct kgsl_device *device,
1913: struct clk *clk, const char *name)
1914: {
1915: int ret = clk_prepare_enable(clk);
1916:
1917: if (ret)
1918: dev_err(device->dev, "GPU Clock %s enable error:%d\n", name, ret);
1919: }
1920:
1921: /*
1922: * _bimc_clk_prepare_enable - Enable the specified GPU clock
1923: * Try once to enable it and then BUG() for debug
1924: */
1925: static void _bimc_clk_prepare_enable(struct kgsl_device *device,
1926: struct clk *clk, const char *name)
1927: {
1928: int ret = clk_prepare_enable(clk);
1929: /* Failure is fatal so BUG() to facilitate debug */
1930: if (ret)
1931: dev_err(device->dev, "GPU clock %s enable error:%d\n",
1932: name, ret);
1933: }
1934:
1935: static int kgsl_pwrctrl_clk_set_rate(struct clk *grp_clk, unsigned int freq,
1936: const char *name)
1937: {
1938: int ret = clk_set_rate(grp_clk, freq);
1939:
1940: WARN(ret, "%s set freq %d failed:%d\n", name, freq, ret);
1941: return ret;
1942: }
1943:
1944: /*
1945: * pmqos_max_notifier_call - Callback function registered to receive qos max
1946: * frequency events.
1947: * @nb: The notifier block
1948: * @val: Max frequency value in KHz for GPU
1949: *
1950: * The function subscribes to GPU max frequency change and updates thermal
1951: * power level accordingly.
1952: */
1953: static int pmqos_max_notifier_call(struct notifier_block *nb, unsigned long val, void *data)
1954: {
1955: struct kgsl_pwrctrl *pwr = container_of(nb, struct kgsl_pwrctrl, nb_max);
1956: struct kgsl_device *device = container_of(pwr, struct kgsl_device, pwrctrl);
1957: u32 max_freq = val * 1000;
1958: int level;
1959:
1960: if (device->host_based_dcvs && !device->pwrscale.devfreq_enabled)
1961: return NOTIFY_DONE;
1962:
MATCH LINES: 2153, 2158, 2161, 2188, 2190, 2192, 2193, 2198
2141: init_waitqueue_head(&device->active_cnt_wq);
2142:
2143: for (i = 0; i < pwr->num_pwrlevels; i++) {
2144: freq = pwr->pwrlevels[i].gpu_freq;
2145:
2146: if (freq > 0)
2147: freq = clk_round_rate(pwr->grp_clks[0], freq);
2148:
2149: if (freq >= pwr->pwrlevels[i].gpu_freq)
2150: pwr->pwrlevels[i].gpu_freq = freq;
2151: }
2152:
2153: clk_set_rate(pwr->grp_clks[0],
2154: pwr->pwrlevels[pwr->num_pwrlevels - 1].gpu_freq);
2155:
2156: freq = clk_round_rate(pwr->grp_clks[6], KGSL_XO_CLK_FREQ);
2157: if (freq > 0)
2158: kgsl_pwrctrl_clk_set_rate(pwr->grp_clks[6],
2159: freq, clocks[6]);
2160:
2161: _isense_clk_set_rate(pwr, pwr->num_pwrlevels - 1);
2162:
2163: if (of_property_read_bool(pdev->dev.of_node, "vddcx-supply") ||
2164: (of_property_match_string(pdev->dev.of_node,
2165: "power-domain-names", "cx") >= 0))
2166: kgsl_pwrctrl_probe_cx_gdsc(device, pdev);
2167: else if (gmu_wrapper_pdev &&
2168: of_property_match_string(gmu_wrapper_pdev->dev.of_node,
2169: "power-domain-names", "cx") >= 0)
2170: kgsl_pwrctrl_probe_cx_gdsc(device, gmu_wrapper_pdev);
2171:
2172: if (of_property_read_bool(pdev->dev.of_node, "vdd-supply") ||
2173: (of_property_match_string(pdev->dev.of_node,
2174: "power-domain-names", "gx") >= 0))
2175: kgsl_pwrctrl_probe_gx_gdsc(device, pdev);
2176: else if (gmu_wrapper_pdev &&
2177: of_property_match_string(gmu_wrapper_pdev->dev.of_node,
2178: "power-domain-names", "gx") >= 0)
2179: kgsl_pwrctrl_probe_gx_gdsc(device, gmu_wrapper_pdev);
2180:
2181: platform_device_put(gmu_wrapper_pdev);
2182:
2183: result = kgsl_device_link_add_cxpd_iommu(device);
2184: if (result)
2185: return result;
2186:
2187: if (of_property_read_bool(pdev->dev.of_node, "vdd-parent-supply")) {
2188: pwr->gx_regulator_parent = devm_regulator_get(&pdev->dev,
2189: "vdd-parent");
2190: if (IS_ERR(pwr->gx_regulator_parent)) {
2191: dev_err(device->dev,
2192: "Failed to get vdd-parent regulator:%ld\n",
2193: PTR_ERR(pwr->gx_regulator_parent));
2194: return -ENODEV;
2195: }
2196: if (of_property_read_u32(pdev->dev.of_node,
2197: "vdd-parent-min-corner",
2198: &pwr->gx_regulator_parent_min_corner)) {
2199: dev_err(device->dev,
2200: "vdd-parent-min-corner not found\n");
2201: return -ENODEV;
2202: }
2203: }
2204:
2205: init_completion(&pwr->cx_gdsc_gate);
2206: complete_all(&pwr->cx_gdsc_gate);
2207:
2208: result = kgsl_register_gdsc_notifier(device);
2209: if (result) {
2210: dev_err(&pdev->dev, "Failed to register gdsc notifier: %d\n", result);
2211: goto err;
2212: }
2213:
2214: /* Initialize the thermal clock constraints */
2215: pwr->thermal_pwrlevel = 0;
2216: result = dev_pm_qos_add_request(&pdev->dev, &pwr->sysfs_thermal_req,
2217: DEV_PM_QOS_MAX_FREQUENCY,
2218: PM_QOS_MAX_FREQUENCY_DEFAULT_VALUE);
2219: if (result < 0)
2220: dev_err(device->dev, "PM QoS sysfs thermal request failed:%d\n", result);
2221:
2222: /*
MATCH LINES: 2433, 2460
2421:
2422: level = pwr->default_pwrlevel;
2423:
2424: kgsl_pwrctrl_pwrlevel_change(device, level);
2425:
2426: /* Order pwrrail/clk sequence based upon platform */
2427: status = kgsl_pwrctrl_pwrrail(device, true);
2428: if (status)
2429: return status;
2430: kgsl_pwrctrl_clk(device, true, KGSL_STATE_ACTIVE);
2431: kgsl_pwrctrl_axi(device, true);
2432:
2433: return device->ftbl->regulator_enable(device);
2434: }
2435:
2436: void kgsl_pwrctrl_clear_l3_vote(struct kgsl_device *device)
2437: {
2438: int status;
2439: struct dcvs_freq freq = {0};
2440:
2441: if (!device->num_l3_pwrlevels)
2442: return;
2443:
2444: freq.hw_type = DCVS_L3;
2445:
2446: status = qcom_dcvs_update_votes(KGSL_L3_DEVICE, &freq, 1,
2447: DCVS_SLOW_PATH);
2448: if (!status)
2449: device->cur_l3_pwrlevel = 0;
2450: else
2451: dev_err(device->dev, "Could not clear l3_vote: %d\n",
2452: status);
2453: }
2454:
2455: static void kgsl_pwrctrl_disable(struct kgsl_device *device)
2456: {
2457: kgsl_pwrctrl_clear_l3_vote(device);
2458:
2459: /* Order pwrrail/clk sequence based upon platform */
2460: device->ftbl->regulator_disable(device);
2461: kgsl_pwrctrl_axi(device, false);
2462: kgsl_pwrctrl_clk(device, false, KGSL_STATE_SLUMBER);
2463: kgsl_pwrctrl_pwrrail(device, false);
2464:
2465: /* Clear the active OPP state for the device in nogmu targets */
2466: if (!gmu_core_gpmu_isenabled(device) &&
2467: device->pwrctrl.pwrlevels[0].opp) {
2468: int ret = dev_pm_opp_set_opp(&device->pdev->dev, NULL);
2469:
2470: if (ret)
2471: dev_err(&device->pdev->dev,
2472: "Failed to clear active OPP state: %d\n", ret);
2473: }
2474: }
2475:
2476: /**
2477: * _init() - Get the GPU ready to start, but don't turn anything on
2478: * @device - Pointer to the kgsl_device struct
2479: */
2480: static int _init(struct kgsl_device *device)
2481: {
2482: int status = 0;
2483:
2484: switch (device->state) {
--- FILE: \kgsl_pwrctrl.h | HITS: 12 ---
MATCH LINES: 62, 68
50: struct kgsl_pwr_constraint {
51: unsigned int type;
52: unsigned int sub_type;
53: unsigned long expires;
54: uint32_t owner_id;
55: u32 owner_timestamp;
56: };
57:
58: /**
59: * struct kgsl_pwrlevel - Struct holding different pwrlevel info obtained
60: * from dtsi file
61: * @gpu_freq: GPU frequency vote in Hz
62: * @bus_freq: Bus bandwidth vote index
63: * @bus_min: Min bus index @gpu_freq
64: * @bus_max: Max bus index @gpu_freq
65: */
66: struct kgsl_pwrlevel {
67: unsigned int gpu_freq;
68: unsigned int bus_freq;
69: unsigned int bus_min;
70: unsigned int bus_max;
71: unsigned int acd_level;
72: /** @cx_level: CX vote */
73: u32 cx_level;
74: /** @voltage_level: Voltage level used by the GMU to vote RPMh */
75: u32 voltage_level;
76: /** @opp: OPP node corresponding to GPU OPP table */
77: struct dev_pm_opp *opp;
78: };
79:
80: /**
81: * struct kgsl_pwrctrl - Power control settings for a KGSL device
82: * @interrupt_num - The interrupt number for the device
83: * @grp_clks - Array of clocks structures that we control
84: * @power_flags - Control flags for power
85: * @pwrlevels - List of supported power levels
86: * @active_pwrlevel - The currently active power level
87: * @previous_pwrlevel - The power level before transition
88: * @thermal_pwrlevel - maximum powerlevel constraint from thermal
89: * @default_pwrlevel - device wake up power level
90: * @max_pwrlevel - maximum allowable powerlevel per the user
91: * @min_pwrlevel - minimum allowable powerlevel per the user
92: * @min_render_pwrlevel - minimum allowable powerlevel for rendering
MATCH LINES: 115, 116, 117, 118, 132, 133, 134, 135, 136
103: * @bus_ab_mbytes - AB vote in Mbytes for current bus usage
104: * @constraint - currently active power constraint
105: * @superfast - Boolean flag to indicate that the GPU start should be run in the
106: * higher priority thread
107: * isense_clk_indx - index of isense clock, 0 if no isense
108: * isense_clk_on_level - isense clock rate is XO rate below this level.
109: */
110:
111: struct kgsl_pwrctrl {
112: int interrupt_num;
113: struct clk *grp_clks[KGSL_MAX_CLKS];
114: struct clk *gpu_bimc_int_clk;
115: /** @cx_regulator: Pointer to the CX domain regulator if applicable */
116: struct regulator *cx_regulator;
117: /** @gx_regulator: Pointer to the GX domain regulator if applicable */
118: struct regulator *gx_regulator;
119: /**
120: * @cx_pd: Power domain for registering CX GDSC notifier
121: *
122: * Only GMU device votes for GMU_CX_PD. Other client votes are consolidated
123: * in the CX GenPD instance, so use this for registering the notifier.
124: */
125: struct device *cx_pd;
126: /** @gmu_cx_pd: Power domain for controlling GMU CX GDSC instance */
127: struct device *gmu_cx_pd;
128: /** @gmu_mx_pd: Power domain for controlling GMU MX GDSC instance */
129: struct device *gmu_mx_pd;
130: /** @gx_pd: Power domain for controlling GX GDSC */
131: struct device *gx_pd;
132: /** @gx_regulator_parent: Pointer to the GX domain parent supply */
133: struct regulator *gx_regulator_parent;
134: /** @gx_regulator_parent_min_corner: Minimum supply voltage for GX parent */
135: u32 gx_regulator_parent_min_corner;
136: /** @cx_gdsc_nb: Notifier block for cx gdsc regulator */
137: struct notifier_block cx_gdsc_nb;
138: /** @cx_gdsc_gate: Completion to signal cx gdsc collapse status */
139: struct completion cx_gdsc_gate;
140: /** @cx_gdsc_wait: Whether to wait for cx gdsc to turn off */
141: bool cx_gdsc_wait;
142: /** @cx_cfg_gdsc_offset: Offset of CX CFG GDSC register */
143: u32 cx_cfg_gdsc_offset;
144: int isense_clk_indx;
145: int isense_clk_on_level;
146: unsigned long power_flags;
147: unsigned long ctrl_flags;
148: struct kgsl_pwrlevel pwrlevels[KGSL_MAX_PWRLEVELS];
149: unsigned int active_pwrlevel;
150: unsigned int previous_pwrlevel;
151: unsigned int thermal_pwrlevel;
152: unsigned int default_pwrlevel;
153: unsigned int max_pwrlevel;
154: unsigned int min_pwrlevel;
155: unsigned int min_render_pwrlevel;
156: unsigned int num_pwrlevels;
157: unsigned int throttle_mask;
158: atomic64_t interval_timeout;
159: u64 clock_times[KGSL_MAX_PWRLEVELS];
160: /** @thermal_time: Time in usecs the GPU is limited by thermal constraints */
MATCH LINES: 378
366: * Return: DDR vote level from where GPU should vote for performance mode
367: */
368: u32 kgsl_pwrctrl_get_acv_perfmode_lvl(struct kgsl_device *device, u32 ddr_freq);
369:
370: /**
371: * kgsl_pwrctrl_setup_default_votes - Set up default power level and bandwidth vote
372: * @device: Pointer to the kgsl device
373: *
374: * Return: 0 on success or a negative error code on failure.
375: */
376: int kgsl_pwrctrl_setup_default_votes(struct kgsl_device *device);
377:
378: static int kgsl_regulator_disable_wait(struct regulator *reg, u32 timeout);
379:
380: /**
381: * kgsl_pwrctrl_probe_mx_gdsc - Probe mx gdsc
382: * @device: Pointer to the kgsl device
383: * @pdev: Pointer to the platform device
384: *
385: * Return: 0 on success or negative error on failure
386: */
387: int kgsl_pwrctrl_probe_mx_gdsc(struct kgsl_device *device, struct platform_device *pdev);
388:
389: /**
390: * kgsl_pwrctrl_enable_mx_gdsc - Enable mx gdsc
391: * @device: Pointer to the kgsl device
392: *
393: * Return: 0 on success or negative error on failure
394: */
395: int kgsl_pwrctrl_enable_mx_gdsc(struct kgsl_device *device);
396:
397: /**
398: * kgsl_pwrctrl_disable_mx_gdsc - Disable mx gdsc
399: * @device: Pointer to the kgsl device
400: */
401: void kgsl_pwrctrl_disable_mx_gdsc(struct kgsl_device *device);
402:
--- FILE: \kgsl_pwrscale.c | HITS: 4 ---
MATCH LINES: 507, 508, 509, 510
495: * If the gpu frequency is different now it's better to
496: * ignore the call
497: */
498: if (pwr_level->gpu_freq != *freq) {
499: kgsl_mutex_unlock(&device->mutex);
500: return 0;
501: }
502:
503: b = pwr->bus_mod;
504: pwr->bus_mod += _read_hint(bus_flag);
505:
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:
--- FILE: \kgsl_util.c | HITS: 7 ---
MATCH LINES: 24
12: #include <linux/firmware.h>
13: #include <linux/ktime.h>
14: #include <linux/pm_domain.h>
15: #include <linux/version.h>
16: #if (KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE)
17: #include <linux/firmware/qcom/qcom_scm.h>
18: #else
19: #include <linux/qcom_scm.h>
20: #endif
21: #if IS_ENABLED(CONFIG_QCOM_SCM_ADDON)
22: #include <linux/firmware/qcom/qcom_scm_addon.h>
23: #endif
24: #include <linux/regulator/consumer.h>
25: #include <linux/slab.h>
26: #include <linux/string.h>
27:
28: #include "adreno.h"
29: #include "kgsl_pool.h"
30: #include "kgsl_util.h"
31:
32: int cmp_u32(const void *first, const void *second)
33: {
34: u32 va = *(u32 *)first;
35: u32 vb = *(u32 *)second;
36:
37: return (va > vb) - (va < vb);
38: }
39:
40: bool kgsl_genpd_is_enabled(struct device *dev)
41: {
42: struct generic_pm_domain *genpd;
43:
44: if (IS_ERR_OR_NULL(dev) || IS_ERR_OR_NULL(dev->pm_domain))
45: return false;
46:
47: genpd = pd_to_genpd(dev->pm_domain);
48: return (READ_ONCE(genpd->status) == GENPD_STATE_ON);
MATCH LINES: 63, 64, 71, 73, 78, 103
51: struct clk *kgsl_of_clk_by_name(struct clk_bulk_data *clks, int count,
52: const char *id)
53: {
54: int i;
55:
56: for (i = 0; clks && i < count; i++)
57: if (!strcmp(clks[i].id, id))
58: return clks[i].clk;
59:
60: return NULL;
61: }
62:
63: int kgsl_regulator_set_voltage(struct device *dev,
64: struct regulator *reg, u32 voltage)
65: {
66: int ret;
67:
68: if (IS_ERR_OR_NULL(reg))
69: return 0;
70:
71: ret = regulator_set_voltage(reg, voltage, INT_MAX);
72: if (ret)
73: dev_err(dev, "Regulator set voltage:%d failed:%d\n", voltage, ret);
74:
75: return ret;
76: }
77:
78: int kgsl_clk_set_rate(struct clk_bulk_data *clks, int num_clks,
79: const char *id, unsigned long rate)
80: {
81: struct clk *clk;
82:
83: clk = kgsl_of_clk_by_name(clks, num_clks, id);
84:
85: /*
86: * If the downstream clock name isn't found, try removing "_clk" and retry
87: * with corresponding standard clock name.
88: */
89: if (!clk && (strlen(id) > 4) && (strcmp(id + strlen(id) - 4, "_clk") == 0)) {
90: char alt_id[32];
91: size_t new_len = strlen(id) - 4;
92:
93: if (new_len < sizeof(alt_id)) {
94: memcpy(alt_id, id, new_len);
95: alt_id[new_len] = '\0';
96: clk = kgsl_of_clk_by_name(clks, num_clks, alt_id);
97: }
98: }
99:
100: if (!clk)
101: return -ENODEV;
102:
103: return clk_set_rate(clk, rate);
104: }
105:
106: #if (KERNEL_VERSION(6, 1, 0) > LINUX_VERSION_CODE)
107: static int _kgsl_scm_gpu_init_regs(u32 gpu_req)
108: {
109: return -EOPNOTSUPP;
110: }
111: #elif (KERNEL_VERSION(6, 11, 0) <= LINUX_VERSION_CODE)
112: static int _kgsl_scm_gpu_init_regs(u32 gpu_req)
113: {
114: return qcom_scm_gpu_init_regs(gpu_req);
115: }
116: #elif (IS_ENABLED(CONFIG_QCOM_KGSL_UPSTREAM) && !IS_ENABLED(CONFIG_QCOM_SCM_ADDON))
117: static int _kgsl_scm_gpu_init_regs(u32 gpu_req)
118: {
119: return -EINVAL;
120: }
121: #else
122: static int _kgsl_scm_gpu_init_regs(u32 gpu_req)
123: {
124: return qcom_scm_kgsl_init_regs(gpu_req);
125: }
126: #endif
127:
--- FILE: \kgsl_util.h | HITS: 11 ---
MATCH LINES: 69, 81, 95
57: */
58: #define GPU_CLX_EN_REQ BIT(2)
59: /**
60: * Request TZ to program tsense ids to access controlled registers for reading
61: * gpu temperature sensors
62: */
63: #define GPU_TSENSE_EN_REQ BIT(3)
64: /**
65: * Request TZ to program tsense measurement to a large period
66: */
67: #define GPU_TSENSE_MEASURE_DEFAULT_DISABLE BIT(4)
68:
69: struct regulator;
70: struct clk_bulk_data;
71:
72: /**
73: * struct cpu_gpu_lock - CP spinlock structure for power up list
74: * @gpu_req: flag value set by CP
75: * @cpu_req: flag value set by KMD
76: * @turn: turn variable set by both CP and KMD
77: * @list_length: this tells CP the last dword in the list:
78: * 16 + (4 * (List_Length - 1))
79: * @list_offset: this tells CP the start of preemption only list:
80: * 16 + (4 * List_Offset)
81: * @ifpc_list_len: number of static ifpc duplets in the list
82: * @preemption_list_len: number of static preemption duplets in the list
83: * @dynamic_list_len: number of dynamically added triplets in the list
84: */
85: struct cpu_gpu_lock {
86: u32 gpu_req;
87: u32 cpu_req;
88: u32 turn;
89: union {
90: struct {
91: u16 list_length;
92: u16 list_offset;
93: };
94: struct {
95: u8 ifpc_list_len;
96: u8 preemption_list_len;
97: u16 dynamic_list_len;
98: };
99: };
100: };
101:
102: /**
103: * kgsl_hwlock - Try to get the spinlock
104: * @lock: cpu_gpu_lock structure
105: *
106: * Spin while the GPU has the lock.
107: *
108: * Return: 0 if lock is successful, -EBUSY if timed out waiting for lock
109: */
110: int kgsl_hwlock(struct cpu_gpu_lock *lock);
111:
112: /**
113: * kgsl_hwunlock - Release a previously grabbed lock
114: * @lock: cpu_gpu_lock structure
115: */
116: void kgsl_hwunlock(struct cpu_gpu_lock *lock);
117:
118: /**
119: * kgsl_genpd_is_enabled - Check whether genpd is enabled or not
MATCH LINES: 138, 140, 141, 145, 146, 149, 157
126: /**
127: * kgsl_of_clk_by_name - Return a clock device for a given name
128: * @clks: Pointer to an array of bulk clk data
129: * @count: Number of entries in the array
130: * @id: Name of the clock to search for
131: *
132: * Returns: A pointer to the clock device for the given name or NULL if not
133: * found
134: */
135: struct clk *kgsl_of_clk_by_name(struct clk_bulk_data *clks, int count,
136: const char *id);
137: /**
138: * kgsl_regulator_set_voltage - Set voltage level for regulator
139: * @dev: A &struct device pointer
140: * @reg: A &struct regulator handle
141: * @voltage: Voltage value to set regulator
142: *
143: * Return: 0 on success and negative error on failure.
144: */
145: int kgsl_regulator_set_voltage(struct device *dev,
146: struct regulator *reg, u32 voltage);
147:
148: /**
149: * kgsl_clk_set_rate - Set a clock to a given rate
150: * @clks: Pointer to an array of bulk clk data
151: * @count: Number of entries in the array
152: * @id: Name of the clock to search for
153: * @rate: Rate to st the clock to
154: *
155: * Return: 0 on success or negative error on failure
156: */
157: int kgsl_clk_set_rate(struct clk_bulk_data *clks, int num_clks,
158: const char *id, unsigned long rate);
159:
160:
161: /**
162: * kgsl_is_compatible_node_available() - Check if a device with matching
163: * compatible is available
164: * @compat: The compatible string that the device must have
165: *
166: * Find a device with the compatible string that is passed and check if
167: * the device is available.
168: *
169: * Return: true if a suitable device is available, false otherwise
170: */
171: bool kgsl_is_compatible_node_available(const char *compat);
172:
173: /**
174: * kgsl_attach_iommu_group() - Get iommu group and attach domain
175: *
176: * @dev: iommu group of this device is used
177: * @domain: iommu domain to attach
178: * @group: This is updated with iommu group on successful attach
179: *
180: * Get the iommu group of a device and attach iommu domain to the group.
181: *
MATCH LINES: 291
279: unsigned int num_context_bank)
280: {
281: return -EINVAL;
282: }
283:
284: /**
285: * kgsl_get_ddrtype - Type of ddr on the current device
286: *
287: * Return: ddr type on success or negative error on failure.
288: */
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 <linux/firmware/qcom/qcom_pas.h>
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
--- FILE: \downstream_dependencies\linux\clk\qcom.h | HITS: 1 ---
MATCH LINES: 11
1: /* SPDX-License-Identifier: GPL-2.0-only */
2: /*
3: * Copyright (c) 2020, The Linux Foundation. All rights reserved.
4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
5: */
6:
7: #ifndef __LINUX_CLK_QCOM_H_
8: #define __LINUX_CLK_QCOM_H_
9:
10: #include <linux/clk.h>
11: #include <linux/regulator/consumer.h>
12:
13: #endif /* __LINUX_CLK_QCOM_H_ */
--- FILE: \include\uapi\linux\msm_kgsl.h | HITS: 4 ---
MATCH LINES: 2206, 2207, 2222, 2223
2194: * @penalty_down: Average gpu busy% threshold to step down one level
2195: * @first_step_down_count: Number of consecutive down recommendations before first step down
2196: * @subsequent_step_down_count: Number of consecutive down recommendations for subsequent step down
2197: * after first step down
2198: * @num_samples_up: Moving average window size used for vote up decision
2199: * @num_samples_down: Moving average window size used for vote down decision
2200: * @strict_frame: Flag used to enable/disable vote up decision if the average gpu busy% over some
2201: * consecutive samples is very high. This node takes effect only when target_fps is configured
2202: * @non_linear_ramp_up: Flag used to enable/disable non-linear ramp up which supports a larger
2203: * stride jump if the gpu busy% is very high
2204: * @non_linear_ramp_down: Flag used to enable/disable non-linear ramp down which supports a
2205: * larger stride jump if the gpu busy% is very low enough
2206: * @min_bus_freq: Minimum bus frequency in MHz
2207: * @max_bus_freq: Maximum bus frequency in MHz
2208: */
2209: struct kgsl_dcvs_attrs {
2210: __u32 min_gpu_freq;
2211: __u32 max_gpu_freq;
2212: __u32 target_fps;
2213: __u32 penalty_up;
2214: __u32 penalty_down;
2215: __u32 first_step_down_count;
2216: __u32 subsequent_step_down_count;
2217: __u32 num_samples_up;
2218: __u32 num_samples_down;
2219: __u32 strict_frame;
2220: __u32 non_linear_ramp_up;
2221: __u32 non_linear_ramp_down;
2222: __u32 min_bus_freq;
2223: __u32 max_bus_freq;
2224: };
2225:
2226: /**
2227: * struct kgsl_dcvs_profile - Argument for IOCTL_KGSL_SETPROPERTY
2228: * @attrs: User pointer to kgsl_dcvs_attrs structure
2229: * @attrs_size: Size of kgsl_dcvs_attrs structure in bytes
2230: *
2231: * A container to register/unregister the DCVS profile when IOCTL_KGSL_SETPROPERTY
2232: * is called with type KGSL_PROP_DCVS_PROFILE.
2233: *
2234: * User is expected to initialize @struct kgsl_dcvs_attrs with set of property
2235: * used by app profile and set the unused fields to KGSL_DCVS_ATTR_UNUSED.
2236: */
2237: struct kgsl_dcvs_profile {
2238: __u64 attrs;
2239: __u32 attrs_size;
2240: /* private: 64 bit compatibility */
2241: __u32 padding;
2242: };
2243:
2244: #endif /* _UAPI_MSM_KGSL_H */
TOTAL MATCHES: 928
==========================================================================================
SUBSYSTEM: SYNCHRONIZATION
==========================================================================================
--- FILE: \adreno.c | HITS: 7 ---
MATCH LINES: 1816, 1817, 1818
1804: .preaccess = adreno_regmap_op_preaccess,
1805: };
1806:
1807: static const struct kgsl_functable adreno_functable;
1808:
1809: static void adreno_setup_device(struct adreno_device *adreno_dev)
1810: {
1811: u32 i;
1812:
1813: adreno_dev->dev.name = "kgsl-3d0";
1814: adreno_dev->dev.ftbl = &adreno_functable;
1815:
1816: init_completion(&adreno_dev->dev.hwaccess_gate);
1817: init_completion(&adreno_dev->dev.halt_gate);
1818: init_completion(&adreno_dev->suspend_recovery_gate);
1819: complete_all(&adreno_dev->suspend_recovery_gate);
1820:
1821: idr_init(&adreno_dev->dev.context_idr);
1822:
1823: kgsl_mutex_init(&adreno_dev->dev.mutex);
1824: mutex_init(&adreno_dev->dev.file_mutex);
1825: mutex_init(&adreno_dev->fault_recovery_mutex);
1826: mutex_init(&adreno_dev->dcvs_tuning_mutex);
1827: INIT_LIST_HEAD(&adreno_dev->dev.globals);
1828:
1829: /* Set the fault tolerance policy to replay, skip, throttle */
1830: adreno_dev->ft_policy = BIT(KGSL_FT_REPLAY) |
1831: BIT(KGSL_FT_SKIPCMD) | BIT(KGSL_FT_THROTTLE);
1832:
1833: /* Enable command timeouts by default */
1834: adreno_dev->long_ib_detect = true;
1835:
1836: INIT_WORK(&adreno_dev->input_work, adreno_input_work);
1837:
1838: INIT_LIST_HEAD(&adreno_dev->active_list);
1839: spin_lock_init(&adreno_dev->active_list_lock);
1840: rwlock_init(&adreno_dev->fault_stats_lock);
1841:
1842: for (i = 0; i < ARRAY_SIZE(adreno_dev->ringbuffers); i++) {
MATCH LINES: 1937
1925: /*
1926: * In presence of a hardware fault, cancel system suspend (by returning NOTIFY_BAD)
1927: * here to make sure system suspend doesn't increment the pd prepared_count. This
1928: * ensures that cx and gx gdscs can be toggled successfully during fault recovery.
1929: */
1930: if (adreno_gpu_fault(adreno_dev)) {
1931: dev_err_ratelimited(device->dev, "cancelling suspend because of fault\n");
1932: complete_all(&adreno_dev->suspend_recovery_gate);
1933: adreno_scheduler_queue(adreno_dev);
1934: return NOTIFY_BAD;
1935: }
1936:
1937: reinit_completion(&adreno_dev->suspend_recovery_gate);
1938: return NOTIFY_DONE;
1939: }
1940:
1941: /*
1942: * We get PM_POST_SUSPEND if we failed kgsl suspend in the presence of a hardware fault,
1943: * or when system resume finishes. In either case, this means the system has come out of
1944: * suspend and has put back the power domain prepared_count. This means we are safe to
1945: * perform fault recovery.
1946: */
1947: if (event == PM_POST_SUSPEND) {
1948: complete_all(&adreno_dev->suspend_recovery_gate);
1949: /*
1950: * Queue the gpu scheduler to proceed with fault recovery in case there was a
1951: * fault
1952: */
1953: adreno_scheduler_queue(adreno_dev);
1954: }
1955:
1956: return NOTIFY_DONE;
1957: }
1958:
1959: static void validate_pwrlevels(struct kgsl_device *device)
1960: {
1961: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
MATCH LINES: 2722
2710:
2711: static int adreno_pwrctrl_active_count_get(struct adreno_device *adreno_dev)
2712: {
2713: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2714: int ret = 0;
2715:
2716: if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex)))
2717: return -EINVAL;
2718:
2719: if ((atomic_read(&device->active_cnt) == 0) &&
2720: (device->state != KGSL_STATE_ACTIVE)) {
2721: kgsl_mutex_unlock(&device->mutex);
2722: wait_for_completion(&device->hwaccess_gate);
2723: kgsl_mutex_lock(&device->mutex);
2724: device->pwrctrl.superfast = true;
2725: ret = kgsl_pwrctrl_change_state(device, KGSL_STATE_ACTIVE);
2726: }
2727: if (ret == 0)
2728: atomic_inc(&device->active_cnt);
2729: trace_kgsl_active_count(device,
2730: (unsigned long) __builtin_return_address(0));
2731: return ret;
2732: }
2733:
2734: void adreno_active_count_put(struct adreno_device *adreno_dev)
2735: {
2736: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2737:
2738: if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex)))
2739: return;
2740:
2741: if (WARN(atomic_read(&device->active_cnt) == 0,
2742: "Unbalanced get/put calls to KGSL active count\n"))
2743: return;
2744:
2745: if (atomic_dec_and_test(&device->active_cnt)) {
2746: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
MATCH LINES: 3817, 3846
3805: ret = adreno_dispatcher_idle(adreno_dev);
3806: if (ret)
3807: return ret;
3808:
3809: return adreno_spin_idle(adreno_dev, ADRENO_IDLE_TIMEOUT);
3810: }
3811:
3812: int adreno_drain(struct kgsl_device *device, unsigned long wait_jiffies)
3813: {
3814: int ret;
3815:
3816: /* Halt any new submissions */
3817: reinit_completion(&device->halt_gate);
3818:
3819: /**
3820: * Wait for the dispatcher to retire everything by waiting
3821: * for the active count to go to zero.
3822: */
3823: ret = kgsl_active_count_wait(device, 0, wait_jiffies);
3824: if (ret)
3825: dev_err(device->dev, "Timed out waiting for the active count\n");
3826:
3827: return ret;
3828: }
3829:
3830: /* Caller must hold the device mutex. */
3831: void adreno_check_idle(struct kgsl_device *device)
3832: {
3833: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
3834:
3835: /* process any profiling results that are available */
3836: adreno_profile_process_results(adreno_dev);
3837:
3838: /*
3839: * Make sure the device mutex is held so the dispatcher can't send any
3840: * more commands to the hardware
3841: */
3842: if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex)))
3843: return;
3844:
3845: /* Make sure dispatcher is idle */
3846: if (!completion_done(&adreno_dev->dispatcher.idle_gate))
3847: dev_err_ratelimited(device->dev, "Dispatcher not idle before SLUMBER\n");
3848:
3849: /* Make sure the device is idle */
3850: if (!adreno_isidle(adreno_dev))
3851: dev_err_ratelimited(device->dev, "Device not idle before SLUMBER\n");
3852: }
3853:
3854: bool adreno_gx_is_on(struct adreno_device *adreno_dev)
3855: {
3856: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
3857:
3858: return gpudev->gx_is_on(adreno_dev);
3859: }
3860:
3861: void adreno_profile_submit_time(struct adreno_submit_time *time)
3862: {
3863: struct kgsl_drawobj *drawobj;
3864: struct kgsl_drawobj_cmd *cmdobj;
3865: struct kgsl_mem_entry *entry;
3866: struct kgsl_drawobj_profiling_buffer *profile_buffer;
3867:
3868: if (!time)
3869: return;
3870:
--- FILE: \adreno.h | HITS: 1 ---
MATCH LINES: 910
898: /**
899: * @fault_procs: Array to keep track of per process GPU fault count sorted by the number
900: * of GPU faults
901: */
902: struct adreno_fault_proc fault_procs[ADRENO_MAX_FAULTING_PROCS];
903: /** @fault_stats_lock: A R/W lock to protect GPU fault statistics */
904: rwlock_t fault_stats_lock;
905: /** @fault_recovery_mutex: Mutex taken during fault handling in the dispatcher */
906: struct mutex fault_recovery_mutex;
907: /** @pm_nb: Notifier block for defining a callback that gets called during system suspend */
908: struct notifier_block pm_nb;
909: /** @suspend_recovery_gate: Gate to wait on for system to come out of suspend */
910: struct completion suspend_recovery_gate;
911: /** @scheduler_worker: kthread worker for scheduling gpu commands */
912: struct kthread_worker *scheduler_worker;
913: /** @scheduler_work: work_struct to put the gpu command scheduler in a work queue */
914: struct kthread_work scheduler_work;
915: /** @scheduler_fault: Atomic to trigger scheduler based fault recovery */
916: atomic_t scheduler_fault;
917: /** @dcvs_tuning_mutex: Mutex taken during dcvs tuning */
918: struct mutex dcvs_tuning_mutex;
919: /** @dcvs_tuning_mingap_lvl: Current DCVS tuning level for mingap */
920: u32 dcvs_tuning_mingap_lvl;
921: /** @dcvs_tuning_penalty_lvl: Current DCVS tuning level for penalty */
922: u32 dcvs_tuning_penalty_lvl;
923: /** @dcvs_tuning_numbusy_lvl: Current DCVS tuning level for numbusy */
924: u32 dcvs_tuning_numbusy_lvl;
925: /** @total_ctxt_record_sz: Size of the total preemption record in bytes */
926: u64 total_ctxt_record_sz;
927: /** @dcvs_profile_enabled: True if DCVS profile is enabled */
928: bool dcvs_profile_enabled;
929: /** @aqe_ctxt_record_sz: Size of the AQE section in preemption record in bytes */
930: u64 aqe_ctxt_record_sz;
931: /** @ubwc_cfg: Pointer to hold struct qcom_ubwc_cfg_data fetched from
932: * qcom_ubwc_config_get_data() API
933: */
934: void *ubwc_cfg_data;
--- FILE: \adreno_a5xx.c | HITS: 1 ---
MATCH LINES: 1551
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");
1573: return PTR_ERR(cmds);
1574: }
1575: start = cmds;
--- FILE: \adreno_a5xx_preempt.c | HITS: 1 ---
MATCH LINES: 407
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:
428: if (kgsl_mmu_is_perprocess(&device->mmu)) {
429: /* smmu_info is allocated and mapped in a5xx_preemption_iommu_init */
430: kgsl_sharedmem_writel(iommu->smmu_info,
431: PREEMPT_SMMU_RECORD(magic), A5XX_CP_SMMU_INFO_MAGIC_REF);
--- FILE: \adreno_a6xx.c | HITS: 1 ---
MATCH LINES: 1111
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);
--- FILE: \adreno_a6xx_hwsched_hfi.c | HITS: 6 ---
MATCH LINES: 75
63: struct a6xx_device, adreno_dev);
64: struct a6xx_hwsched_device *a6xx_hwsched = container_of(a6xx_dev,
65: struct a6xx_hwsched_device, a6xx_dev);
66:
67: return &a6xx_hwsched->hwsched_hfi;
68: }
69:
70: static void add_waiter(struct a6xx_hwsched_hfi *hfi, u32 hdr,
71: struct pending_cmd *ack)
72: {
73: memset(ack, 0x0, sizeof(*ack));
74:
75: init_completion(&ack->complete);
76: write_lock_irq(&hfi->msglock);
77: list_add_tail(&ack->node, &hfi->msglist);
78: write_unlock_irq(&hfi->msglock);
79:
80: ack->sent_hdr = hdr;
81: }
82:
83: static void del_waiter(struct a6xx_hwsched_hfi *hfi, struct pending_cmd *ack)
84: {
85: write_lock_irq(&hfi->msglock);
86: list_del(&ack->node);
87: write_unlock_irq(&hfi->msglock);
88: }
89:
90: static void a6xx_receive_ack_async(struct adreno_device *adreno_dev, void *rcvd)
91: {
92: struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
93: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
94: struct pending_cmd *cmd = NULL;
95: u32 waiters[64], num_waiters = 0, i;
96: u32 *ack = rcvd;
97: u32 hdr = ack[0];
98: u32 req_hdr = ack[1];
99: u32 size_bytes = MSG_HDR_GET_SIZE(hdr) << 2;
MATCH LINES: 390
378: if (MSG_HDR_GET_ID(next_hdr) == F2H_MSG_CONTEXT_BAD) {
379: a6xx_hfi_queue_read(gmu, HFI_MSG_ID,
380: (u32 *)adreno_dev->hwsched.ctxt_bad,
381: HFI_MAX_MSG_SIZE);
382: process_ctx_bad(adreno_dev);
383: continue;
384: }
385:
386: a6xx_hfi_queue_read(gmu, HFI_MSG_ID, rcvd, sizeof(rcvd));
387:
388: /*
389: * We are assuming that there is only one outstanding ack
390: * because hfi sending thread waits for completion while
391: * holding the device mutex
392: */
393: if (MSG_HDR_GET_TYPE(rcvd[0]) == HFI_MSG_ACK) {
394: a6xx_receive_ack_async(adreno_dev, rcvd);
395: } else if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_TS_RETIRE) {
396: adreno_scheduler_queue(adreno_dev);
397: adreno_hwsched_log_profiling_info(adreno_dev, rcvd);
398: } else if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_GMU_CNTR_RELEASE) {
399: struct hfi_gmu_cntr_release_cmd *cmd =
400: (struct hfi_gmu_cntr_release_cmd *) rcvd;
401:
402: adreno_perfcounter_put(adreno_dev,
403: cmd->group_id, cmd->countable, PERFCOUNTER_FLAG_KERNEL);
404: }
405: }
406: mutex_unlock(&hw_hfi->msgq_mutex);
407: }
408:
409: static void process_log_block(struct adreno_device *adreno_dev, void *data)
410: {
411: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
412: struct hfi_log_block *cmd = data;
413: u32 *log_event = gmu->gmu_log->hostptr;
414: u32 start, end;
MATCH LINES: 550
538: int rc;
539: struct pending_cmd pending_ack;
540:
541: seqnum = atomic_inc_return(&gmu->hfi.seqnum);
542: *cmd = MSG_HDR_SET_SEQNUM_SIZE(*cmd, seqnum, size_bytes >> 2);
543:
544: add_waiter(hfi, *cmd, &pending_ack);
545:
546: rc = a6xx_hfi_cmdq_write(adreno_dev, cmd, size_bytes);
547: if (rc)
548: goto done;
549:
550: rc = adreno_hwsched_wait_ack_completion(adreno_dev,
551: GMU_PDEV_DEV(device), &pending_ack, a6xx_hwsched_process_msgq);
552: if (rc)
553: goto done;
554:
555: rc = check_ack_failure(adreno_dev, &pending_ack);
556:
557: done:
558: del_waiter(hfi, &pending_ack);
559:
560: return rc;
561: }
562:
563: static void init_queues(struct a6xx_hfi *hfi)
564: {
565: u32 gmuaddr = hfi->hfi_mem->gmuaddr;
566: struct hfi_queue_table hfi_table = {
567: .qtbl_hdr = {
568: .version = 0,
569: .size = sizeof(struct hfi_queue_table) >> 2,
570: .qhdr0_offset =
571: sizeof(struct hfi_queue_table_header) >> 2,
572: .qhdr_size = sizeof(struct hfi_queue_header) >> 2,
573: .num_q = HFI_QUEUE_MAX,
574: .num_active_q = HFI_QUEUE_MAX,
MATCH LINES: 1203
1191: return true;
1192:
1193: return false;
1194: }
1195:
1196: static int hfi_f2h_main(void *arg)
1197: {
1198: struct adreno_device *adreno_dev = arg;
1199: struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
1200: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1201:
1202: while (!kthread_should_stop()) {
1203: wait_event_interruptible(hfi->f2h_wq, kthread_should_stop() ||
1204: /* If msgq irq is enabled and msgq has messages to process */
1205: (((hfi->irq_mask & HFI_IRQ_MSGQ_MASK) &&
1206: !is_queue_empty(adreno_dev, HFI_MSG_ID)) ||
1207: /* Trace buffer has messages to process */
1208: !gmu_core_is_trace_empty(device->gmu_core.trace.md->hostptr) ||
1209: /* Dbgq has messages to process */
1210: !is_queue_empty(adreno_dev, HFI_DBG_ID)));
1211:
1212: if (kthread_should_stop())
1213: break;
1214:
1215: a6xx_hwsched_process_msgq(adreno_dev);
1216: gmu_core_process_trace_data(device,
1217: GMU_PDEV_DEV(device), &device->gmu_core.trace);
1218: a6xx_hwsched_process_dbgq(adreno_dev, true);
1219: }
1220:
1221: return 0;
1222: }
1223:
1224: int a6xx_hwsched_hfi_probe(struct adreno_device *adreno_dev)
1225: {
1226: struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
1227: struct a6xx_hwsched_hfi *hw_hfi = to_a6xx_hwsched_hfi(adreno_dev);
MATCH LINES: 1702
1690: }
1691:
1692: seqnum = atomic_inc_return(&gmu->hfi.seqnum);
1693: cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
1694: add_waiter(hfi, cmd.hdr, &pending_ack);
1695:
1696: ret = a6xx_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
1697: if (ret) {
1698: trigger_context_unregister_fault(adreno_dev, context);
1699: goto done;
1700: }
1701:
1702: ret = adreno_hwsched_ctxt_unregister_wait_completion(adreno_dev,
1703: GMU_PDEV_DEV(device), context, &pending_ack, a6xx_hwsched_process_msgq, &cmd);
1704: if (ret) {
1705: trigger_context_unregister_fault(adreno_dev, context);
1706: goto done;
1707: }
1708:
1709: ret = check_ack_failure(adreno_dev, &pending_ack);
1710:
1711: done:
1712: adreno_active_count_put(adreno_dev);
1713: del_waiter(hfi, &pending_ack);
1714:
1715: return ret;
1716: }
1717:
1718: void a6xx_hwsched_context_detach(struct adreno_context *drawctxt)
1719: {
1720: struct kgsl_context *context = &drawctxt->base;
1721: struct kgsl_device *device = context->device;
1722: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
1723: int ret = 0;
1724:
1725: kgsl_mutex_lock(&device->mutex);
1726:
MATCH LINES: 1774
1762:
1763: seqnum = atomic_inc_return(&gmu->hfi.seqnum);
1764: cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
1765: cmd.type = HFI_VALUE_PREEMPT_COUNT;
1766: cmd.subtype = 0;
1767:
1768: add_waiter(hfi, cmd.hdr, &pending_ack);
1769:
1770: rc = a6xx_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
1771: if (rc)
1772: goto done;
1773:
1774: rc = adreno_hwsched_wait_ack_completion(adreno_dev,
1775: GMU_PDEV_DEV(device), &pending_ack, a6xx_hwsched_process_msgq);
1776: if (rc)
1777: goto done;
1778:
1779: rc = check_ack_failure(adreno_dev, &pending_ack);
1780:
1781: done:
1782: del_waiter(hfi, &pending_ack);
1783:
1784: return rc ? 0 : pending_ack.results[2];
1785: }
--- FILE: \adreno_a6xx_snapshot.c | HITS: 1 ---
MATCH LINES: 2186
2174: &offset);
2175: }
2176:
2177: /* Program the capturescript for the MVC regsiters */
2178: ptr += _a6xx_crashdump_init_mvc(adreno_dev, ptr, &offset);
2179:
2180: if (!adreno_is_a663(adreno_dev)) {
2181: ptr += _a6xx_crashdump_init_ctx_dbgahb(ptr, &offset);
2182:
2183: ptr += _a6xx_crashdump_init_non_ctx_dbgahb(ptr, &offset);
2184: }
2185:
2186: /* Save CD register end pointer to check CD status completion */
2187: a6xx_cd_reg_end = a6xx_crashdump_registers->hostptr + offset;
2188:
2189: memset(a6xx_crashdump_registers->hostptr, 0xaa,
2190: a6xx_crashdump_registers->size);
2191:
2192: /* Program the capturescript to read the last register entry */
2193: *ptr++ = a6xx_crashdump_registers->gpuaddr + offset;
2194: *ptr++ = (((uint64_t) A6XX_CP_CRASH_DUMP_STATUS) << 44) | (uint64_t) 1;
2195:
2196: *ptr++ = 0;
2197: *ptr++ = 0;
2198: }
--- FILE: \adreno_debugfs.c | HITS: 8 ---
MATCH LINES: 298, 299, 304, 306, 307, 309, 342, 343
286: }
287: if (first)
288: seq_puts(s, "None");
289: }
290:
291: #define print_flags(_s, _flag, _array...) \
292: ({ \
293: const struct flag_entry symbols[] = \
294: { _array, { -1, NULL } }; \
295: _print_flags(_s, symbols, _flag); \
296: })
297:
298: static void syncobj_print(struct seq_file *s,
299: struct kgsl_drawobj_sync *syncobj)
300: {
301: struct kgsl_drawobj_sync_event *event;
302: unsigned int i;
303:
304: seq_puts(s, " syncobj ");
305:
306: for (i = 0; i < syncobj->numsyncs; i++) {
307: event = &syncobj->synclist[i];
308:
309: if (!kgsl_drawobj_event_pending(syncobj, i))
310: continue;
311:
312: sync_event_print(s, event);
313: seq_puts(s, "\n");
314: }
315: }
316:
317: static void cmdobj_print(struct seq_file *s,
318: struct kgsl_drawobj_cmd *cmdobj)
319: {
320: struct kgsl_drawobj *drawobj = DRAWOBJ(cmdobj);
321:
322: if (drawobj->type == CMDOBJ_TYPE)
323: seq_puts(s, " cmdobj ");
324: else
325: seq_puts(s, " markerobj ");
326:
327: seq_printf(s, "\t %u ", drawobj->timestamp);
328:
329: seq_puts(s, " priv: ");
330: print_flags(s, cmdobj->priv,
331: { BIT(CMDOBJ_SKIP), "skip"},
332: { BIT(CMDOBJ_FORCE_PREAMBLE), "force_preamble"},
333: { BIT(CMDOBJ_WFI), "wait_for_idle" });
334: }
335:
336: static void drawobj_print(struct seq_file *s,
337: struct kgsl_drawobj *drawobj)
338: {
339: if (!kref_get_unless_zero(&drawobj->refcount))
340: return;
341:
342: if (drawobj->type == SYNCOBJ_TYPE)
343: syncobj_print(s, SYNCOBJ(drawobj));
344: else if ((drawobj->type == CMDOBJ_TYPE) ||
345: (drawobj->type == MARKEROBJ_TYPE))
346: cmdobj_print(s, CMDOBJ(drawobj));
347:
348: seq_puts(s, " flags: ");
349: print_flags(s, drawobj->flags, KGSL_DRAWOBJ_FLAGS);
350: kgsl_drawobj_put(drawobj);
351: seq_puts(s, "\n");
352: }
353:
354: static int ctx_print(struct seq_file *s, void *unused)
355: {
356: struct adreno_context *drawctxt = s->private;
357: unsigned int i;
358: struct kgsl_event *event;
359: unsigned int queued = 0, consumed = 0, retired = 0;
360:
361: seq_printf(s, "id: %u type: %s priority: %d process: %s (%d) tid: %d\n",
362: drawctxt->base.id,
363: kgsl_context_type(drawctxt->type),
364: drawctxt->base.priority,
365: drawctxt->base.proc_priv->comm,
366: pid_nr(drawctxt->base.proc_priv->pid),
367: drawctxt->base.tid);
--- FILE: \adreno_dispatch.c | HITS: 21 ---
MATCH LINES: 222, 225, 227, 237, 238, 239
210: /*
211: * If the marker isn't expired but the SKIP bit
212: * is set then there are real commands following
213: * this one in the queue. This means that we
214: * need to dispatch the command so that we can
215: * keep the timestamp accounting correct. If
216: * skip isn't set then we block this queue
217: * until the dependent timestamp expires
218: */
219: return test_bit(CMDOBJ_SKIP, &cmdobj->priv) ? 1 : -EAGAIN;
220: }
221:
222: static int dispatch_retire_syncobj(struct kgsl_drawobj *drawobj,
223: struct adreno_context *drawctxt)
224: {
225: struct kgsl_drawobj_sync *syncobj = SYNCOBJ(drawobj);
226:
227: if (!kgsl_drawobj_events_pending(syncobj)) {
228: _pop_drawobj(drawctxt);
229: kgsl_drawobj_destroy(drawobj);
230: return 0;
231: }
232:
233: /*
234: * If we got here, there are pending events for sync object.
235: * Start the canary timer if it hasnt been started already.
236: */
237: if (!syncobj->timeout_jiffies) {
238: syncobj->timeout_jiffies = jiffies + msecs_to_jiffies(5000);
239: mod_timer(&syncobj->timer, syncobj->timeout_jiffies);
240: }
241:
242: return -EAGAIN;
243: }
244:
245: static int drawqueue_retire_timelineobj(struct kgsl_drawobj *drawobj,
246: struct adreno_context *drawctxt)
247: {
248: _pop_drawobj(drawctxt);
249: kgsl_drawobj_destroy(drawobj);
250: return 0;
251: }
252:
253: static int drawqueue_retire_bindobj(struct kgsl_drawobj *drawobj,
254: struct adreno_context *drawctxt)
255: {
256: struct kgsl_drawobj_bind *bindobj = BINDOBJ(drawobj);
257:
258: if (test_bit(KGSL_BINDOBJ_STATE_DONE, &bindobj->state)) {
259: _pop_drawobj(drawctxt);
260: _retire_timestamp(drawobj);
261: return 0;
262: }
263:
MATCH LINES: 282, 312, 313
270: kref_get(&drawobj->refcount);
271:
272: kgsl_sharedmem_bind_ranges(bindobj->bind);
273: }
274:
275: return -EAGAIN;
276: }
277:
278: /*
279: * Retires all expired marker and sync objs from the context
280: * queue and returns one of the below
281: * a) next drawobj that needs to be sent to ringbuffer
282: * b) -EAGAIN for syncobj with syncpoints pending.
283: * c) -EAGAIN for markerobj whose marker timestamp has not expired yet.
284: * c) NULL for no commands remaining in drawqueue.
285: */
286: static struct kgsl_drawobj *_process_drawqueue_get_next_drawobj(
287: struct adreno_context *drawctxt)
288: {
289: struct kgsl_drawobj *drawobj;
290: unsigned int i = drawctxt->drawqueue_head;
291:
292: if (drawctxt->drawqueue_head == drawctxt->drawqueue_tail)
293: return NULL;
294:
295: for (i = drawctxt->drawqueue_head; i != drawctxt->drawqueue_tail;
296: i = DRAWQUEUE_NEXT(i, ADRENO_CONTEXT_DRAWQUEUE_SIZE)) {
297: int ret = 0;
298:
299: drawobj = drawctxt->drawqueue[i];
300: if (!drawobj)
301: return NULL;
302:
303: switch (drawobj->type) {
304: case CMDOBJ_TYPE:
305: return drawobj;
306: case MARKEROBJ_TYPE:
307: ret = dispatch_retire_markerobj(drawobj, drawctxt);
308: /* Special case where marker needs to be sent to GPU */
309: if (ret == 1)
310: return drawobj;
311: break;
312: case SYNCOBJ_TYPE:
313: ret = dispatch_retire_syncobj(drawobj, drawctxt);
314: break;
315: case BINDOBJ_TYPE:
316: ret = drawqueue_retire_bindobj(drawobj, drawctxt);
317: break;
318: case TIMELINEOBJ_TYPE:
319: ret = drawqueue_retire_timelineobj(drawobj, drawctxt);
320: break;
321: default:
322: ret = -EINVAL;
323: break;
324: }
325:
326: if (ret)
327: return ERR_PTR(ret);
328: }
329:
330: return NULL;
331: }
332:
333: /**
334: * adreno_dispatcher_requeue_cmdobj() - Put a command back on the context
335: * queue
336: * @drawctxt: Pointer to the adreno draw context
337: * @cmdobj: Pointer to the KGSL command object to requeue
MATCH LINES: 513
501:
502: ret = adreno_ringbuffer_submitcmd(adreno_dev, cmdobj, &time);
503:
504: /*
505: * On the first command, if the submission was successful, then read the
506: * fault registers. If it failed then turn off the GPU. Sad face.
507: */
508:
509: if (dispatcher->inflight == 1) {
510: if (ret == 0) {
511: if (!test_and_set_bit(ADRENO_DISPATCHER_ACTIVE,
512: &dispatcher->priv))
513: reinit_completion(&dispatcher->idle_gate);
514: } else {
515: adreno_active_count_put(adreno_dev);
516: clear_bit(ADRENO_DISPATCHER_POWER, &dispatcher->priv);
517: }
518: }
519:
520:
521: if (ret) {
522: dispatcher->inflight--;
523: dispatch_q->inflight--;
524:
525: process_rt_bus_hint(device, false);
526:
527: /*
528: * Don't log a message in case of:
529: * -ENOENT means that the context was detached before the
530: * command was submitted
531: * -ENOSPC means that there temporarily isn't any room in the
532: * ringbuffer
533: * -PROTO means that a fault is currently being worked
534: */
535:
536: if (ret != -ENOENT && ret != -ENOSPC && ret != -EPROTO)
537: dev_err(device->dev,
MATCH LINES: 1010
998: int ret = 0;
999:
1000: /*
1001: * There is always a possibility that dispatcher may end up pushing
1002: * the last popped draw object back to the context drawqueue. Hence,
1003: * we can only queue up to _context_drawqueue_size - 1 here to make
1004: * sure we never let drawqueue->queued exceed _context_drawqueue_size.
1005: */
1006: if ((drawctxt->queued + count) > (_context_drawqueue_size - 1)) {
1007: trace_adreno_drawctxt_sleep(drawctxt);
1008: spin_unlock(&drawctxt->lock);
1009:
1010: ret = wait_event_interruptible_timeout(drawctxt->wq,
1011: _check_context_queue(drawctxt, count),
1012: msecs_to_jiffies(_context_queue_wait));
1013:
1014: spin_lock(&drawctxt->lock);
1015: trace_adreno_drawctxt_wake(drawctxt);
1016:
1017: /*
1018: * Account for the possibility that the context got invalidated
1019: * while we were sleeping
1020: */
1021: if (ret > 0)
1022: ret = kgsl_check_context_state(&drawctxt->base);
1023: else if (ret == 0)
1024: ret = -ETIMEDOUT;
1025: }
1026:
1027: return ret;
1028: }
1029:
1030: static unsigned int _check_context_state_to_queue_cmds(
1031: struct adreno_context *drawctxt, u32 count)
1032: {
1033: int ret = kgsl_check_context_state(&drawctxt->base);
1034:
MATCH LINES: 1161
1149: j = DRAWQUEUE_NEXT(j, ADRENO_CONTEXT_DRAWQUEUE_SIZE);
1150: }
1151:
1152: drawctxt->queued_timestamp = *timestamp;
1153: _set_ft_policy(adreno_dev, drawctxt, cmdobj);
1154: _cmdobj_set_flags(drawctxt, cmdobj);
1155:
1156: _queue_drawobj(drawctxt, drawobj);
1157:
1158: return 0;
1159: }
1160:
1161: static void drawctxt_queue_syncobj(struct adreno_context *drawctxt,
1162: struct kgsl_drawobj *drawobj, uint32_t *timestamp)
1163: {
1164: *timestamp = 0;
1165: drawobj->timestamp = 0;
1166:
1167: _queue_drawobj(drawctxt, drawobj);
1168: }
1169:
1170: /*
1171: * Queue a command in the context - if there isn't any room in the queue, then
1172: * block until there is
1173: */
1174: static int adreno_dispatcher_queue_cmds(struct kgsl_device_private *dev_priv,
1175: struct kgsl_context *context, struct kgsl_drawobj *drawobj[],
1176: uint32_t count, uint32_t *timestamp)
1177:
1178: {
1179: struct kgsl_device *device = dev_priv->device;
1180: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
1181: struct adreno_context *drawctxt = ADRENO_CONTEXT(context);
1182: struct adreno_dispatcher_drawqueue *dispatch_q;
1183: struct adreno_dispatch_job *job;
1184: int ret;
1185: unsigned int i, user_ts;
MATCH LINES: 1205, 1226, 1228, 1266, 1267
1193: if (!count || count > _context_drawqueue_size - 1)
1194: return -EINVAL;
1195:
1196: ret = kgsl_check_context_state(&drawctxt->base);
1197: if (ret)
1198: return ret;
1199:
1200: ret = adreno_verify_cmdobj(dev_priv, context, drawobj, count);
1201: if (ret)
1202: return ret;
1203:
1204: /* wait for the suspend gate */
1205: wait_for_completion(&device->halt_gate);
1206:
1207: job = kmem_cache_alloc(jobs_cache, GFP_KERNEL);
1208: if (!job)
1209: return -ENOMEM;
1210:
1211: job->drawctxt = drawctxt;
1212:
1213: spin_lock(&drawctxt->lock);
1214:
1215: ret = _check_context_state_to_queue_cmds(drawctxt, count);
1216: if (ret) {
1217: spin_unlock(&drawctxt->lock);
1218: kmem_cache_free(jobs_cache, job);
1219: return ret;
1220: }
1221:
1222: user_ts = *timestamp;
1223:
1224: /*
1225: * If there is only one drawobj in the array and it is of
1226: * type SYNCOBJ_TYPE, skip comparing user_ts as it can be 0
1227: */
1228: if (!(count == 1 && drawobj[0]->type == SYNCOBJ_TYPE) &&
1229: (drawctxt->base.flags & KGSL_CONTEXT_USER_GENERATED_TS)) {
1230: /*
1231: * User specified timestamps need to be greater than the last
1232: * issued timestamp in the context
1233: */
1234: if (timestamp_cmp(drawctxt->timestamp, user_ts) >= 0) {
1235: spin_unlock(&drawctxt->lock);
1236: kmem_cache_free(jobs_cache, job);
1237: return -ERANGE;
1238: }
1239: }
1240:
1241: for (i = 0; i < count; i++) {
1242:
1243: switch (drawobj[i]->type) {
1244: case MARKEROBJ_TYPE:
1245: ret = drawctxt_queue_markerobj(adreno_dev, drawctxt,
1246: drawobj[i], timestamp, user_ts);
1247: if (ret) {
1248: spin_unlock(&drawctxt->lock);
1249: kmem_cache_free(jobs_cache, job);
1250: }
1251:
1252: if (ret == 1)
1253: goto done;
1254: else if (ret)
1255: return ret;
1256: break;
1257: case CMDOBJ_TYPE:
1258: ret = drawctxt_queue_cmdobj(adreno_dev, drawctxt,
1259: drawobj[i], timestamp, user_ts);
1260: if (ret) {
1261: spin_unlock(&drawctxt->lock);
1262: kmem_cache_free(jobs_cache, job);
1263: return ret;
1264: }
1265: break;
1266: case SYNCOBJ_TYPE:
1267: drawctxt_queue_syncobj(drawctxt, drawobj[i], timestamp);
1268: break;
1269: case BINDOBJ_TYPE:
1270: ret = drawctxt_queue_bindobj(drawctxt, drawobj[i],
1271: timestamp, user_ts);
1272: if (ret) {
1273: spin_unlock(&drawctxt->lock);
1274: kmem_cache_free(jobs_cache, job);
1275: return ret;
1276: }
1277: break;
1278: case TIMELINEOBJ_TYPE:
1279: drawctxt_queue_timelineobj(drawctxt, drawobj[i]);
1280: break;
1281: default:
1282: spin_unlock(&drawctxt->lock);
1283: kmem_cache_free(jobs_cache, job);
1284: return -EINVAL;
1285: }
1286:
1287: }
1288:
1289: dispatch_q = &(ADRENO_CONTEXT(drawobj[0]->context)->rb->dispatch_q);
1290:
1291: adreno_track_context(adreno_dev, dispatch_q, drawctxt);
MATCH LINES: 1454
1442:
1443: for (i = 0; i < count; i++) {
1444: struct kgsl_drawobj_cmd *cmdobj = replay[i];
1445: struct kgsl_drawobj *drawobj = DRAWOBJ(cmdobj);
1446:
1447: if (cmdobj == NULL)
1448: continue;
1449:
1450: if (kgsl_context_is_bad(drawobj->context)) {
1451: replay[i] = NULL;
1452:
1453: kgsl_mutex_lock(&device->mutex);
1454: kgsl_cancel_events_timestamp(device,
1455: &drawobj->context->events, drawobj->timestamp);
1456: kgsl_mutex_unlock(&device->mutex);
1457:
1458: kgsl_drawobj_destroy(drawobj);
1459: }
1460: }
1461: }
1462:
1463: #define pr_fault(_d, _c, fmt, args...) \
1464: pr_context(_d, (_c)->context, fmt, ##args)
1465:
1466: static void adreno_fault_header(struct kgsl_device *device,
1467: struct adreno_ringbuffer *rb, struct kgsl_drawobj_cmd *cmdobj,
1468: int fault)
1469: {
1470: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
1471: struct kgsl_drawobj *drawobj = DRAWOBJ(cmdobj);
1472: struct adreno_context *drawctxt =
1473: drawobj ? ADRENO_CONTEXT(drawobj->context) : NULL;
1474: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
1475: unsigned int status, rptr, wptr, ib1sz, ib2sz;
1476: uint64_t ib1base, ib2base;
1477: bool gx_on = adreno_gx_is_on(adreno_dev);
1478: int id = (rb != NULL) ? rb->id : -1;
MATCH LINES: 1908
1896:
1897: /*
1898: * Return early if there is a concurrent suspend in progress. The suspend thread will error
1899: * out in the presence of this hwsched fault and requeue the dispatcher to handle this fault
1900: */
1901: if (!mutex_trylock(&adreno_dev->fault_recovery_mutex))
1902: return 1;
1903:
1904: /*
1905: * Wait long enough to allow the system to come out of suspend completely, which can take
1906: * variable amount of time especially if it has to rewind suspend processes and devices.
1907: */
1908: if (!wait_for_completion_timeout(&adreno_dev->suspend_recovery_gate,
1909: msecs_to_jiffies(ADRENO_SUSPEND_RECOVERY_GATE_TIMEOUT_MS))) {
1910: dev_err(device->dev, "suspend recovery gate timeout\n");
1911: adreno_scheduler_queue(adreno_dev);
1912: mutex_unlock(&adreno_dev->fault_recovery_mutex);
1913: return 1;
1914: }
1915:
1916: kgsl_mutex_lock(&device->mutex);
1917:
1918: /*
1919: * In the very unlikely case that the power is off, do nothing - the
1920: * state will be reset on power up and everybody will be happy
1921: */
1922: if (!kgsl_state_is_awake(device)) {
1923: kgsl_mutex_unlock(&device->mutex);
1924: mutex_unlock(&adreno_dev->fault_recovery_mutex);
1925: return 0;
1926: }
1927:
1928: /* Mask all GMU interrupts */
1929: if (gmu_core_isenabled(device)) {
1930: adreno_write_gmureg(adreno_dev,
1931: ADRENO_REG_GMU_AO_HOST_INTERRUPT_MASK,
1932: 0xFFFFFFFF);
MATCH LINES: 2732
2720: kobject_put(&dispatcher->kobj);
2721: return PTR_ERR(adreno_dev->scheduler_worker);
2722: }
2723:
2724: WARN_ON(sysfs_create_files(&device->dev->kobj, _dispatch_attr_list));
2725:
2726: mutex_init(&dispatcher->mutex);
2727:
2728: timer_setup(&dispatcher->timer, adreno_dispatcher_timer, 0);
2729:
2730: kthread_init_work(&adreno_dev->scheduler_work, adreno_dispatcher_work);
2731:
2732: init_completion(&dispatcher->idle_gate);
2733: complete_all(&dispatcher->idle_gate);
2734:
2735: jobs_cache = KMEM_CACHE(adreno_dispatch_job, 0);
2736:
2737: for (i = 0; i < ARRAY_SIZE(dispatcher->jobs); i++) {
2738: init_llist_head(&dispatcher->jobs[i]);
2739: init_llist_head(&dispatcher->requeue[i]);
2740: }
2741:
2742: adreno_set_dispatch_ops(adreno_dev, &swsched_ops);
2743:
2744: sched_set_fifo(adreno_dev->scheduler_worker->task);
2745:
2746: set_bit(ADRENO_DISPATCHER_INIT, &dispatcher->priv);
2747:
2748: return 0;
2749: }
2750:
2751: /*
2752: * adreno_dispatcher_idle() - Wait for dispatcher to idle
2753: * @adreno_dev: Adreno device whose dispatcher needs to idle
2754: *
2755: * Signal dispatcher to stop sending more commands and complete
2756: * the commands that have already been submitted. This function
MATCH LINES: 2791
2779: kgsl_mutex_unlock(&device->mutex);
2780:
2781: /*
2782: * Flush the worker to make sure all executing
2783: * or pending dispatcher works on worker are
2784: * finished
2785: */
2786: kthread_flush_worker(adreno_dev->scheduler_worker);
2787:
2788: if (adreno_gpu_fault(adreno_dev) != 0) {
2789: ret = -EDEADLK;
2790: } else {
2791: ret = wait_for_completion_timeout(&dispatcher->idle_gate,
2792: msecs_to_jiffies(ADRENO_IDLE_TIMEOUT));
2793: if (ret == 0) {
2794: ret = -ETIMEDOUT;
2795: WARN(1, "Dispatcher halt timeout\n");
2796: } else if (ret < 0) {
2797: dev_err(device->dev, "Dispatcher halt failed %d\n", ret);
2798: } else {
2799: ret = 0;
2800: }
2801:
2802: if (adreno_gpu_fault(adreno_dev) != 0)
2803: ret = -EDEADLK;
2804: }
2805:
2806: kgsl_mutex_lock(&device->mutex);
2807: adreno_put_gpu_halt(adreno_dev);
2808: /*
2809: * requeue dispatcher work to resubmit pending commands
2810: * that may have been blocked due to this idling request
2811: */
2812: adreno_scheduler_queue(adreno_dev);
2813: return ret;
2814: }
2815:
--- FILE: \adreno_dispatch.h | HITS: 1 ---
MATCH LINES: 80
68: */
69: struct adreno_dispatcher {
70: struct mutex mutex;
71: unsigned long priv;
72: struct timer_list timer;
73: struct timer_list fault_timer;
74: unsigned int inflight;
75: /** @jobs - Array of dispatch job lists for each priority level */
76: struct llist_head jobs[16];
77: /** @requeue - Array of lists for dispatch jobs that got requeued */
78: struct llist_head requeue[16];
79: struct kobject kobj;
80: struct completion idle_gate;
81: };
82:
83: enum adreno_dispatcher_flags {
84: ADRENO_DISPATCHER_POWER = 0,
85: ADRENO_DISPATCHER_ACTIVE,
86: ADRENO_DISPATCHER_INIT,
87: };
88:
89: struct adreno_device;
90: struct adreno_submit_time;
91: struct kgsl_device;
92:
93: void adreno_dispatcher_start(struct kgsl_device *device);
94: int adreno_dispatcher_init(struct adreno_device *adreno_dev);
95: int adreno_dispatcher_idle(struct adreno_device *adreno_dev);
96: void adreno_dispatcher_stop(struct adreno_device *adreno_dev);
97:
98: void adreno_dispatcher_start_fault_timer(struct adreno_device *adreno_dev);
99: void adreno_dispatcher_stop_fault_timer(struct kgsl_device *device);
100:
101: /**
102: * adreno_drain_and_idle - Drain any pending work and wait for
103: * dispatcher and hardware to become idle
104: * @device: Pointer to the kgsl device
--- FILE: \adreno_drawctxt.c | HITS: 11 ---
MATCH LINES: 91, 92, 94, 99
79: drawctxt->drawqueue[drawctxt->drawqueue_head];
80:
81: if (test_bit(ADRENO_CONTEXT_FENCE_LOG, &context->priv)) {
82: dev_err(device->dev,
83: " possible deadlock. Context %u might be blocked for itself\n",
84: context->id);
85: goto stats;
86: }
87:
88: if (!kref_get_unless_zero(&drawobj->refcount))
89: goto stats;
90:
91: if (drawobj->type == SYNCOBJ_TYPE) {
92: struct kgsl_drawobj_sync *syncobj = SYNCOBJ(drawobj);
93:
94: if (kgsl_drawobj_events_pending(syncobj)) {
95: dev_err(device->dev,
96: " context[%u] (ts=%u) Active sync points:\n",
97: context->id, drawobj->timestamp);
98:
99: kgsl_dump_syncpoints(device, syncobj);
100: }
101: }
102:
103: kgsl_drawobj_put(drawobj);
104: }
105:
106: stats:
107: memset(buf, 0, sizeof(buf));
108:
109: pos = 0;
110:
111: for (index = 0; index < SUBMIT_RETIRE_TICKS_SIZE; index++) {
112: uint64_t msecs;
113: unsigned int usecs;
114:
115: if (!drawctxt->submit_retire_ticks[index])
116: continue;
117: msecs = drawctxt->submit_retire_ticks[index] * 10;
118: usecs = do_div(msecs, 192);
119: usecs = do_div(msecs, 1000);
120: pos += scnprintf(buf + pos, sizeof(buf) - pos, "%u.%0u ",
121: (unsigned int)msecs, usecs);
122: }
123: dev_err(device->dev, " context[%u]: submit times: %s\n",
MATCH LINES: 157, 169, 174
145: struct adreno_context *drawctxt = ADRENO_CONTEXT(context);
146: int ret;
147: long ret_temp;
148:
149: if (kgsl_context_detached(context))
150: return -ENOENT;
151:
152: if (kgsl_context_invalid(context))
153: return -EDEADLK;
154:
155: trace_adreno_drawctxt_wait_start(-1, context->id, timestamp);
156:
157: ret = kgsl_add_event(device, &context->events, timestamp,
158: wait_callback, (void *) drawctxt);
159: if (ret)
160: goto done;
161:
162: /*
163: * If timeout is 0, wait forever. msecs_to_jiffies will force
164: * values larger than INT_MAX to an infinite timeout.
165: */
166: if (timeout == 0)
167: timeout = UINT_MAX;
168:
169: ret_temp = wait_event_interruptible_timeout(drawctxt->waiting,
170: _check_context_timestamp(device, context, timestamp),
171: msecs_to_jiffies(timeout));
172:
173: if (ret_temp <= 0) {
174: kgsl_cancel_event(device, &context->events, timestamp,
175: wait_callback, (void *)drawctxt);
176:
177: ret = ret_temp ? (int)ret_temp : -ETIMEDOUT;
178: goto done;
179: }
180: ret = 0;
181:
182: /* -EDEADLK if the context was invalidated while we were waiting */
183: if (kgsl_context_invalid(context))
184: ret = -EDEADLK;
185:
186:
187: /* Return -EINVAL if the context was detached while we were waiting */
188: if (kgsl_context_detached(context))
189: ret = -ENOENT;
190:
191: done:
192: trace_adreno_drawctxt_wait_done(-1, context->id, timestamp, ret);
193: return ret;
194: }
195:
196: /**
197: * adreno_drawctxt_wait_rb() - Wait for the last RB timestamp at which this
198: * context submitted a command to the corresponding RB
MATCH LINES: 289
277: KGSL_MEMSTORE_OFFSET(context->id, soptimestamp),
278: drawctxt->timestamp);
279:
280: kgsl_sharedmem_writel(device->memstore,
281: KGSL_MEMSTORE_OFFSET(context->id, eoptimestamp),
282: drawctxt->timestamp);
283:
284: /* Get rid of commands still waiting in the queue */
285: count = drawctxt_detach_drawobjs(drawctxt, list);
286: spin_unlock(&drawctxt->lock);
287:
288: for (i = 0; i < count; i++) {
289: kgsl_cancel_events_timestamp(device, &context->events,
290: list[i]->timestamp);
291: kgsl_drawobj_destroy(list[i]);
292: }
293:
294: /* Make sure all pending events are processed or cancelled */
295: kgsl_flush_event_group(device, &context->events);
296:
297: /* Give the bad news to everybody waiting around */
298: wake_up_all(&drawctxt->waiting);
299: wake_up_all(&drawctxt->wq);
300: wake_up_all(&drawctxt->timeout);
301: }
302:
303: void adreno_drawctxt_set_guilty(struct kgsl_device *device,
304: struct kgsl_context *context)
305: {
306: if (!context)
307: return;
308:
309: context->reset_status = KGSL_CTX_STAT_GUILTY_CONTEXT_RESET_EXT;
310:
311: adreno_drawctxt_invalidate(device, context);
312: }
313:
MATCH LINES: 362
350:
351: return (u32) (cmds - cmds_orig);
352: }
353:
354: static int drawctxt_preemption_init(struct kgsl_context *context)
355: {
356: struct kgsl_device *device = context->device;
357: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
358: u64 flags = 0;
359:
360: /*
361: * User context record is needed for a6x and beyond targets only. Also,
362: * highest priority ringbuffer i.e. RB0 always runs to completion without
363: * preemption. Thus, user context records are not needed for RB0.
364: */
365: if (!adreno_preemption_feature_set(adreno_dev) || (ADRENO_GPUREV(adreno_dev) < 600) ||
366: (adreno_get_level(context) == 0))
367: return 0;
368:
369: if (context->flags & KGSL_CONTEXT_SECURE)
370: flags |= KGSL_MEMFLAGS_SECURE;
371:
372: if (is_compat_task())
373: flags |= KGSL_MEMFLAGS_FORCE_32BIT;
374:
375: /*
376: * gpumem_alloc_entry takes an extra refcount. Put it only when
377: * destroying the context to keep the context record valid
378: */
379: context->user_ctxt_record = gpumem_alloc_entry(context->dev_priv,
380: ADRENO_CP_CTXRECORD_USER_RESTORE_SIZE, flags);
381: if (IS_ERR(context->user_ctxt_record)) {
382: int ret = PTR_ERR(context->user_ctxt_record);
383:
384: context->user_ctxt_record = NULL;
385: return ret;
386: }
MATCH LINES: 581
569: "Wait for global ctx=%u ts=%u type=%d error=%d\n",
570: drawctxt->base.id, drawctxt->internal_timestamp,
571: drawctxt->type, ret);
572:
573: adreno_set_gpu_fault(adreno_dev,
574: ADRENO_CTX_DETATCH_TIMEOUT_FAULT);
575: kgsl_mutex_unlock(&device->mutex);
576:
577: /* Schedule dispatcher to kick in recovery */
578: adreno_scheduler_queue(adreno_dev);
579:
580: /* Wait for context to be invalidated and release context */
581: wait_event_interruptible_timeout(drawctxt->timeout,
582: kgsl_context_invalid(&drawctxt->base),
583: msecs_to_jiffies(5000));
584: return;
585: }
586:
587: kgsl_sharedmem_writel(device->memstore,
588: KGSL_MEMSTORE_OFFSET(context->id, soptimestamp),
589: drawctxt->timestamp);
590:
591: kgsl_sharedmem_writel(device->memstore,
592: KGSL_MEMSTORE_OFFSET(context->id, eoptimestamp),
593: drawctxt->timestamp);
594:
595: adreno_profile_process_results(adreno_dev);
596:
597: kgsl_mutex_unlock(&device->mutex);
598: }
599:
600: void adreno_drawctxt_detach(struct kgsl_context *context)
601: {
602: struct kgsl_device *device;
603: struct adreno_device *adreno_dev;
604: const struct adreno_gpudev *gpudev;
605: struct adreno_context *drawctxt;
MATCH LINES: 693
681: struct adreno_context *drawctxt = (struct adreno_context *) priv;
682:
683: kgsl_context_put(&drawctxt->base);
684: }
685:
686: void adreno_put_drawctxt_on_timestamp(struct kgsl_device *device,
687: struct adreno_context *drawctxt,
688: struct adreno_ringbuffer *rb, u32 timestamp)
689: {
690: if (!drawctxt)
691: return;
692:
693: if (kgsl_add_event(device, &rb->events, timestamp,
694: _drawctxt_switch_wait_callback, drawctxt))
695: kgsl_context_put(&drawctxt->base);
696: }
697:
698: static void _add_context(struct adreno_device *adreno_dev,
699: struct adreno_context *drawctxt)
700: {
701: /* Remove it from the list */
702: list_del_init(&drawctxt->active_node);
703:
704: /* And push it to the front */
705: drawctxt->active_time = jiffies;
706: list_add(&drawctxt->active_node, &adreno_dev->active_list);
707: }
708:
709: static int __count_context(struct adreno_context *drawctxt, void *data)
710: {
711: unsigned long expires = drawctxt->active_time + msecs_to_jiffies(100);
712:
713: return time_after(jiffies, expires) ? 0 : 1;
714: }
715:
716: static int __count_drawqueue_context(struct adreno_context *drawctxt,
717: void *data)
--- FILE: \adreno_drawctxt.h | HITS: 2 ---
MATCH LINES: 89, 90
77: struct list_head active_node;
78: unsigned long active_time;
79: /** @gmu_context_queue: Queue to dispatch submissions to GMU */
80: struct kgsl_memdesc gmu_context_queue;
81: /** @gmu_hw_fence_queue: Queue for GMU to store hardware fences for this context */
82: struct kgsl_memdesc gmu_hw_fence_queue;
83: /** @hw_fence_list: List of hardware fences(sorted by timestamp) not yet submitted to GMU */
84: struct list_head hw_fence_list;
85: /** @hw_fence_inflight_list: List of hardware fences submitted to GMU */
86: struct list_head hw_fence_inflight_list;
87: /** @hw_fence_count: Number of hardware fences not yet sent to Tx Queue */
88: u32 hw_fence_count;
89: /** @syncobj_timestamp: Timestamp to check whether GMU has consumed a syncobj */
90: u32 syncobj_timestamp;
91: /**
92: * @gmu_hw_fence_ready_ts: This timestamp is used to figure out whether a hardware fence
93: * is ready to be submitted to GMU at the time of its creation or not. This timestamp
94: * tracks the timestamp of the most recently submitted cmdbatch submission to the GMU
95: * context queue for this context. This is different from the internal_timestamp (which gets
96: * reset to 0 in some cases).
97: */
98: u32 gmu_hw_fence_ready_ts;
99: /**
100: * @hw_fence_last_ts: This tracks the latest timestamp for which a hw fence was created.
101: * This is used to figure out if a new fence has an out-of-order timestamp.
102: */
103: u32 hw_fence_last_ts;
104: };
105:
106: /* Flag definitions for flag field in adreno_context */
107:
108: /**
109: * enum adreno_context_priv - Private flags for an adreno draw context
110: * @ADRENO_CONTEXT_FAULT - set if the context has faulted (and recovered)
111: * @ADRENO_CONTEXT_GPU_HANG - Context has caused a GPU hang
112: * @ADRENO_CONTEXT_GPU_HANG_FT - Context has caused a GPU hang
113: * and fault tolerance was successful
114: * @ADRENO_CONTEXT_SKIP_EOF - Context skip IBs until the next end of frame
--- FILE: \adreno_gen7.c | HITS: 1 ---
MATCH LINES: 1244
1232: if (preempt->postamble_bootup_len) {
1233: *cmds++ = cp_type7_packet(CP_SET_AMBLE, 3);
1234: *cmds++ = lower_32_bits(kmd_postamble_addr);
1235: *cmds++ = upper_32_bits(kmd_postamble_addr);
1236: *cmds++ = FIELD_PREP(GENMASK(22, 20), CP_KMD_AMBLE_TYPE)
1237: | (FIELD_PREP(GENMASK(19, 0), adreno_dev->preempt.postamble_bootup_len));
1238: }
1239:
1240: *cmds++ = cp_type7_packet(CP_CONTEXT_SWITCH_YIELD, 4);
1241: *cmds++ = 0;
1242: *cmds++ = 0;
1243: *cmds++ = 0;
1244: /* generate interrupt on preemption completion */
1245: *cmds++ = 0;
1246:
1247: ret = gen7_ringbuffer_submit(rb, NULL);
1248: if (!ret) {
1249: ret = adreno_spin_idle(adreno_dev, 2000);
1250: if (ret)
1251: gen7_spin_idle_debug(adreno_dev,
1252: "hw preemption initialization failed to idle\n");
1253: }
1254:
1255: return ret;
1256: }
1257:
1258: int gen7_rb_start(struct adreno_device *adreno_dev)
1259: {
1260: const struct adreno_gen7_core *gen7_core = to_gen7_core(adreno_dev);
1261: struct adreno_firmware *fw = ADRENO_FW(adreno_dev, ADRENO_FW_SQE);
1262: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1263: struct adreno_ringbuffer *rb;
1264: u64 addr;
1265: int ret, i;
1266: unsigned int *cmds;
1267:
1268: /* Clear all the ringbuffers */
--- FILE: \adreno_gen7_hwsched.c | HITS: 2 ---
MATCH LINES: 1594, 1595
1582:
1583: if (ADRENO_FEATURE(adreno_dev, ADRENO_LPAC))
1584: adreno_dev->lpac_enabled = true;
1585:
1586: if (ADRENO_FEATURE(adreno_dev, ADRENO_DMS)) {
1587: set_bit(ADRENO_DEVICE_DMS, &adreno_dev->priv);
1588: adreno_dev->dms_enabled = true;
1589: }
1590:
1591: kgsl_mmu_set_feature(device, KGSL_MMU_PAGEFAULT_TERMINATE);
1592:
1593: if (ADRENO_FEATURE(adreno_dev, ADRENO_HW_FENCE))
1594: device->max_syncobj_hw_fence_count = min_t(u32, HFI_SYNCOBJ_LEGACY_HW_FENCE_MAX,
1595: MAX_SYNCOBJ_QUERY_BITS);
1596:
1597: ret = adreno_hwsched_init(adreno_dev, &gen7_hwsched_ops);
1598: if (ret)
1599: dev_err(&pdev->dev, "adreno hardware scheduler init failed ret %d\n", ret);
1600:
1601: return ret;
1602: }
1603:
1604: int gen7_hwsched_add_to_minidump(struct adreno_device *adreno_dev)
1605: {
1606: struct gen7_device *gen7_dev = container_of(adreno_dev,
1607: struct gen7_device, adreno_dev);
1608: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1609: struct gmu_core_device *gmu_core = &device->gmu_core;
1610: struct gen7_hwsched_device *gen7_hwsched = container_of(gen7_dev,
1611: struct gen7_hwsched_device, gen7_dev);
1612: struct gen7_hwsched_hfi *hw_hfi = &gen7_hwsched->hwsched_hfi;
1613: struct adreno_hwsched *hwsched = &adreno_dev->hwsched;
1614: int ret, i;
1615:
1616: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, KGSL_HWSCHED_DEVICE,
1617: (void *)(gen7_hwsched), sizeof(struct gen7_hwsched_device));
1618: if (ret)
1619: return ret;
--- FILE: \adreno_gen7_hwsched_hfi.c | HITS: 93 ---
MATCH LINES: 87
75: {
76: if (!adreno_dev->lpac_enabled)
77: return 0;
78:
79: return gen7_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_LPAC, 1, 0);
80: }
81:
82: static void add_waiter(struct gen7_hwsched_hfi *hfi, u32 hdr,
83: struct pending_cmd *ack)
84: {
85: memset(ack, 0x0, sizeof(*ack));
86:
87: init_completion(&ack->complete);
88: write_lock_irq(&hfi->msglock);
89: list_add_tail(&ack->node, &hfi->msglist);
90: write_unlock_irq(&hfi->msglock);
91:
92: ack->sent_hdr = hdr;
93: }
94:
95: static void del_waiter(struct gen7_hwsched_hfi *hfi, struct pending_cmd *ack)
96: {
97: write_lock_irq(&hfi->msglock);
98: list_del(&ack->node);
99: write_unlock_irq(&hfi->msglock);
100: }
101:
102: static void gen7_receive_ack_async(struct adreno_device *adreno_dev, void *rcvd)
103: {
104: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
105: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev);
106: struct pending_cmd *cmd = NULL;
107: u32 waiters[64], num_waiters = 0, i;
108: u32 *ack = rcvd;
109: u32 hdr = ack[0];
110: u32 req_hdr = ack[1];
111: u32 size_bytes = MSG_HDR_GET_SIZE(hdr) << 2;
MATCH LINES: 177, 182, 185, 186, 189, 190, 193, 205, 206, 210, 214, 215, 216, 219, 221, 225, 232, 251, 260, 268
165: while (i < payload_bytes) {
166: struct payload_section *payload = start + i;
167:
168: if (payload->type == type)
169: return adreno_hwsched_parse_payload(payload, key);
170:
171: i += struct_size(payload, data, payload->dwords);
172: }
173:
174: return 0;
175: }
176:
177: struct syncobj_flags {
178: unsigned long mask;
179: const char *name;
180: };
181:
182: static void _get_syncobj_string(char *str, u32 max_size, struct hfi_syncobj_legacy *syncobj,
183: u32 index)
184: {
185: u32 count = scnprintf(str, max_size, "syncobj[%d] ctxt_id:%llu seqno:%llu flags:", index,
186: syncobj->ctxt_id, syncobj->seq_no);
187: u32 i;
188: bool first = true;
189: static const struct syncobj_flags _flags[] = {
190: GMU_SYNCOBJ_FLAGS, { -1, NULL }};
191:
192: for (i = 0; _flags[i].name; i++) {
193: if (!(syncobj->flags & _flags[i].mask))
194: continue;
195:
196: if (first) {
197: count += scnprintf(str + count, max_size - count, "%s", _flags[i].name);
198: first = false;
199: } else {
200: count += scnprintf(str + count, max_size - count, "|%s", _flags[i].name);
201: }
202: }
203: }
204:
205: static void log_syncobj(struct gen7_gmu_device *gmu, struct adreno_context *drawctxt,
206: struct hfi_submit_syncobj *cmd, u32 syncobj_read_idx)
207: {
208: struct kgsl_device *device = KGSL_DEVICE(gen7_gmu_to_adreno(gmu));
209: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr;
210: struct hfi_syncobj_legacy syncobj;
211: char str[128];
212: u32 i = 0;
213:
214: for (i = 0; i < cmd->num_syncobj; i++) {
215: if (adreno_gmu_context_queue_read(drawctxt, (u32 *) &syncobj, syncobj_read_idx,
216: sizeof(syncobj) >> 2))
217: break;
218:
219: _get_syncobj_string(str, sizeof(str), &syncobj, i);
220: dev_err(GMU_PDEV_DEV(device), "%s\n", str);
221: syncobj_read_idx = (syncobj_read_idx + (sizeof(syncobj) >> 2)) % hdr->queue_size;
222: }
223: }
224:
225: static void find_timeout_syncobj(struct adreno_device *adreno_dev, u32 ctxt_id, u32 ts)
226: {
227: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
228: struct kgsl_context *context = NULL;
229: struct adreno_context *drawctxt;
230: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
231: struct gmu_context_queue_header *hdr;
232: struct hfi_submit_syncobj cmd;
233: u32 *queue, i;
234: int ret;
235:
236: /* We want to get the context even if it is detached */
237: read_lock(&device->context_lock);
238: context = idr_find(&device->context_idr, ctxt_id);
239: ret = _kgsl_context_get(context);
240: read_unlock(&device->context_lock);
241:
242: if (!ret)
243: return;
244:
245: drawctxt = ADRENO_CONTEXT(context);
246:
247: hdr = drawctxt->gmu_context_queue.hostptr;
248: queue = (u32 *)(drawctxt->gmu_context_queue.hostptr + sizeof(*hdr));
249:
250: for (i = hdr->read_index; i != hdr->write_index;) {
251: if (MSG_HDR_GET_ID(queue[i]) != H2F_MSG_ISSUE_SYNCOBJ) {
252: i = (i + MSG_HDR_GET_SIZE(queue[i])) % hdr->queue_size;
253: continue;
254: }
255:
256: if (adreno_gmu_context_queue_read(drawctxt, (u32 *) &cmd, i, sizeof(cmd) >> 2))
257: break;
258:
259: if (cmd.timestamp == ts) {
260: log_syncobj(gmu, drawctxt, &cmd,
261: (i + (sizeof(cmd) >> 2)) % hdr->queue_size);
262: break;
263: }
264: i = (i + MSG_HDR_GET_SIZE(queue[i])) % hdr->queue_size;
265: }
266:
267: if (i == hdr->write_index)
268: dev_err(GMU_PDEV_DEV(device), "Couldn't find unsignaled syncobj ctx:%d ts:%d\n",
269: ctxt_id, ts);
270:
271: kgsl_context_put(context);
272: }
273:
274: static void log_gpu_fault_legacy(struct adreno_device *adreno_dev)
275: {
276: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
277: struct hfi_context_bad_cmd_legacy *cmd = adreno_dev->hwsched.ctxt_bad;
278:
279: switch (cmd->error) {
280: case GMU_GPU_HW_HANG:
281: dev_crit_ratelimited(gmu_pdev_dev, "MISC: GPU hang detected\n");
282: break;
283: case GMU_GPU_SW_HANG:
284: dev_crit_ratelimited(gmu_pdev_dev, "gpu timeout ctx %u ts %u\n",
285: cmd->ctxt_id, cmd->ts);
286: break;
287: case GMU_CP_OPCODE_ERROR:
288: dev_crit_ratelimited(gmu_pdev_dev,
289: "CP opcode error interrupt | opcode=0x%8.8x\n",
290: gen7_hwsched_lookup_key_value_legacy(adreno_dev, PAYLOAD_FAULT_REGS,
291: KEY_CP_OPCODE_ERROR));
292: break;
MATCH LINES: 401, 402, 404
389: break;
390: case GMU_GPU_AQE1_UCODE_ERROR:
391: dev_crit_ratelimited(gmu_pdev_dev, "AQE1 ucode error interrupt\n");
392: break;
393: case GMU_GPU_AQE1_HW_FAULT_ERROR:
394: dev_crit_ratelimited(gmu_pdev_dev, "AQE1 HW fault | status=0x%8.8x\n",
395: gen7_hwsched_lookup_key_value_legacy(adreno_dev,
396: PAYLOAD_FAULT_REGS, KEY_AQE1_HW_FAULT));
397: break;
398: case GMU_GPU_AQE1_ILLEGAL_INST_ERROR:
399: dev_crit_ratelimited(gmu_pdev_dev, "AQE1 Illegal instruction error\n");
400: break;
401: case GMU_SYNCOBJ_TIMEOUT_ERROR:
402: dev_crit_ratelimited(gmu_pdev_dev, "syncobj timeout ctx %d ts %u\n",
403: cmd->ctxt_id, cmd->ts);
404: find_timeout_syncobj(adreno_dev, cmd->ctxt_id, cmd->ts);
405: break;
406: case GMU_CP_UNKNOWN_ERROR:
407: fallthrough;
408: default:
409: dev_crit_ratelimited(gmu_pdev_dev, "Unknown GPU fault: %u\n",
410: cmd->error);
411: break;
412: }
413: }
414:
415: /* Look up a particular key's value for a given type of payload */
416: static u32 gen7_hwsched_lookup_key_value(struct adreno_device *adreno_dev,
417: u32 type, u32 key)
418: {
419: struct hfi_context_bad_cmd *cmd = adreno_dev->hwsched.ctxt_bad;
420: u32 i = 0, payload_bytes;
421: void *start;
422:
423: if (!cmd->hdr)
424: return 0;
425:
426: payload_bytes = (MSG_HDR_GET_SIZE(cmd->hdr) << 2) -
427: offsetof(struct hfi_context_bad_cmd, payload);
428:
MATCH LINES: 606, 607, 609
594: break;
595: case GMU_GPU_AQE1_UCODE_ERROR:
596: dev_crit_ratelimited(gmu_pdev_dev, "AQE1 ucode error interrupt\n");
597: break;
598: case GMU_GPU_AQE1_HW_FAULT_ERROR:
599: dev_crit_ratelimited(gmu_pdev_dev, "AQE1 HW fault | status=0x%8.8x\n",
600: gen7_hwsched_lookup_key_value(adreno_dev,
601: PAYLOAD_FAULT_REGS, KEY_AQE1_HW_FAULT));
602: break;
603: case GMU_GPU_AQE1_ILLEGAL_INST_ERROR:
604: dev_crit_ratelimited(gmu_pdev_dev, "AQE1 Illegal instruction error\n");
605: break;
606: case GMU_SYNCOBJ_TIMEOUT_ERROR:
607: dev_crit_ratelimited(gmu_pdev_dev, "syncobj timeout ctx %d ts %u\n",
608: cmd->gc.ctxt_id, cmd->gc.ts);
609: find_timeout_syncobj(adreno_dev, cmd->gc.ctxt_id, cmd->gc.ts);
610: break;
611: case GMU_CP_UNKNOWN_ERROR:
612: fallthrough;
613: default:
614: dev_crit_ratelimited(gmu_pdev_dev, "Unknown GPU fault: %u\n",
615: cmd->error);
616: break;
617: }
618:
619: /* Return true for fatal errors to perform recovery sequence */
620: return true;
621: }
622:
623: static bool is_queue_empty(struct adreno_device *adreno_dev, u32 queue_idx)
624: {
625: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
626: struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
627: struct hfi_queue_table *tbl = mem_addr->hostptr;
628: struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];
629:
630: if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
631: return true;
632:
633: if (hdr->read_index == hdr->write_index)
MATCH LINES: 680, 681, 683, 692, 703, 716, 717, 719, 721, 724, 725, 733, 737, 743, 745, 748, 752, 754, 755, 756, 770, 775, 806, 809, 810, 816, 838
668: }
669:
670: /* Non fatal RBBM error interrupts don't go through reset and recovery */
671: if (!log_gpu_fault(adreno_dev)) {
672: memset(adreno_dev->hwsched.ctxt_bad, 0x0, HFI_MAX_MSG_SIZE);
673: return;
674: }
675:
676: done:
677: gen7_hwsched_fault(adreno_dev, ADRENO_HARD_FAULT);
678: }
679:
680: #define GET_QUERIED_FENCE_INDEX(x) (x / BITS_PER_SYNCOBJ_QUERY)
681: #define GET_QUERIED_FENCE_BIT(x) (x % BITS_PER_SYNCOBJ_QUERY)
682:
683: static bool fence_is_queried(struct hfi_syncobj_query_cmd *cmd, u32 fence_index)
684: {
685: u32 index = GET_QUERIED_FENCE_INDEX(fence_index);
686: u32 bit = GET_QUERIED_FENCE_BIT(fence_index);
687:
688: return (cmd->queries[index].query_bitmask & BIT(bit));
689: }
690:
691: static void set_fence_signal_bit(struct adreno_device *adreno_dev,
692: struct hfi_syncobj_query_cmd *reply, struct dma_fence *fence, u32 fence_index)
693: {
694: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
695: u32 index = GET_QUERIED_FENCE_INDEX(fence_index);
696: u32 bit = GET_QUERIED_FENCE_BIT(fence_index);
697: u64 flags = ADRENO_HW_FENCE_SW_STATUS_PENDING;
698: char name[KGSL_FENCE_NAME_LEN];
699: char value[32] = "unknown";
700:
701: kgsl_fence_timeline_value_str(fence, value, sizeof(value));
702:
703: if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) {
704: dev_err(gmu_pdev_dev,
705: "GMU is waiting for signaled fence(ctx:%llu seqno:%llu value:%s)\n",
706: fence->context, fence->seqno, value);
707: reply->queries[index].query_bitmask |= BIT(bit);
708: flags = ADRENO_HW_FENCE_SW_STATUS_SIGNALED;
709: }
710:
711: kgsl_get_fence_name(fence, name, sizeof(name));
712:
713: trace_adreno_hw_fence_query(fence->context, fence->seqno, flags, name, value);
714: }
715:
716: static void gen7_syncobj_query_reply(struct adreno_device *adreno_dev,
717: struct kgsl_drawobj *drawobj, struct hfi_syncobj_query_cmd *cmd)
718: {
719: struct hfi_syncobj_query_cmd reply = {0};
720: int i;
721: struct kgsl_drawobj_sync *syncobj = SYNCOBJ(drawobj);
722: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
723:
724: for (i = 0; i < syncobj->num_hw_fence; i++) {
725: struct dma_fence *fence = syncobj->hw_fences[i].fence;
726:
727: if (!fence_is_queried(cmd, i))
728: continue;
729:
730: set_fence_signal_bit(adreno_dev, &reply, fence, i);
731: }
732:
733: reply.hdr = CREATE_MSG_HDR(F2H_MSG_SYNCOBJ_QUERY, HFI_MSG_CMD);
734: reply.gmu_ctxt_id = cmd->gmu_ctxt_id;
735: reply.sync_obj_ts = cmd->sync_obj_ts;
736:
737: trace_adreno_syncobj_query_reply(reply.gmu_ctxt_id, reply.sync_obj_ts,
738: gpudev->read_alwayson(adreno_dev));
739:
740: gen7_hfi_send_cmd_async(adreno_dev, &reply, sizeof(reply));
741: }
742:
743: struct syncobj_query_work {
744: /** @cmd: The query command to be processed */
745: struct hfi_syncobj_query_cmd cmd;
746: /** @context: kgsl context that is waiting for this sync object */
747: struct kgsl_context *context;
748: /** @work: The work structure to execute syncobj query reply */
749: struct kthread_work work;
750: };
751:
752: static void gen7_process_syncobj_query_work(struct kthread_work *work)
753: {
754: struct syncobj_query_work *query_work = container_of(work,
755: struct syncobj_query_work, work);
756: struct hfi_syncobj_query_cmd *cmd = (struct hfi_syncobj_query_cmd *)&query_work->cmd;
757: struct kgsl_context *context = query_work->context;
758: struct kgsl_device *device = context->device;
759: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
760: struct adreno_hwsched *hwsched = &adreno_dev->hwsched;
761: struct cmd_list_obj *obj;
762: bool missing = true;
763:
764: mutex_lock(&hwsched->mutex);
765: kgsl_mutex_lock(&device->mutex);
766:
767: list_for_each_entry(obj, &hwsched->cmd_list, node) {
768: struct kgsl_drawobj *drawobj = obj->drawobj;
769:
770: if ((drawobj->type & SYNCOBJ_TYPE) == 0)
771: continue;
772:
773: if ((drawobj->context->id == cmd->gmu_ctxt_id) &&
774: (drawobj->timestamp == cmd->sync_obj_ts)) {
775: gen7_syncobj_query_reply(adreno_dev, drawobj, cmd);
776: missing = false;
777: break;
778: }
779: }
780:
781: if (missing) {
782: struct adreno_context *drawctxt = ADRENO_CONTEXT(context);
783: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr;
784:
785: /*
786: * If the sync object is not found, it can only mean that the sync object was
787: * retired by the GMU in the meanwhile. However, if that is not the case, then
788: * we have a problem.
789: */
790: if (timestamp_cmp(cmd->sync_obj_ts, hdr->sync_obj_ts) > 0) {
791: dev_err(GMU_PDEV_DEV(device),
792: "Missing sync object ctx:%d ts:%d retired:%d\n",
793: context->id, cmd->sync_obj_ts, hdr->sync_obj_ts);
794: gmu_core_fault_snapshot(device, GMU_FAULT_HW_FENCE);
795: gen7_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT);
796: }
797: }
798:
799: kgsl_mutex_unlock(&device->mutex);
800: mutex_unlock(&hwsched->mutex);
801:
802: kgsl_context_put(context);
803: kfree(query_work);
804: }
805:
806: static void gen7_trigger_syncobj_query(struct adreno_device *adreno_dev,
807: u32 *rcvd)
808: {
809: struct syncobj_query_work *query_work;
810: struct hfi_syncobj_query_cmd *cmd = (struct hfi_syncobj_query_cmd *)rcvd;
811: struct kgsl_context *context = NULL;
812: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
813: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
814: int ret;
815:
816: trace_adreno_syncobj_query(cmd->gmu_ctxt_id, cmd->sync_obj_ts,
817: gpudev->read_alwayson(adreno_dev));
818:
819: /*
820: * We need the context even if it is detached. Hence, we can't use kgsl_context_get here.
821: * We must make sure that this context id doesn't get destroyed (to avoid re-use) until GMU
822: * has ack'd the query reply.
823: */
824: read_lock(&device->context_lock);
825: context = idr_find(&device->context_idr, cmd->gmu_ctxt_id);
826: ret = _kgsl_context_get(context);
827: read_unlock(&device->context_lock);
828:
829: if (!ret)
830: return;
831:
832: query_work = kzalloc(sizeof(*query_work), GFP_KERNEL);
833: if (!query_work) {
834: kgsl_context_put(context);
835: return;
836: }
837:
838: kthread_init_work(&query_work->work, gen7_process_syncobj_query_work);
839: memcpy(&query_work->cmd, cmd, sizeof(*cmd));
840: query_work->context = context;
841:
842: kthread_queue_work(adreno_dev->scheduler_worker, &query_work->work);
843: }
844:
845: /*
846: * This defines the maximum unack'd hardware fences that we allow. When this limit is reached, we
847: * will put all threads (that want to create a hardware fence) to sleep until the maximum unack'd
848: * hardware fence count drops to MIN_HW_FENCE_UNACK_COUNT
849: */
850: #define MAX_HW_FENCE_UNACK_COUNT 20
851:
852: /*
853: * Once the maximum unack'd hardware fences drops to this value, wake up all the threads (that want
854: * to create hardware fences)
855: */
856: #define MIN_HW_FENCE_UNACK_COUNT 10
857:
858: /*
859: * This is the maximum duration (in milliseconds) a thread (that wants to create a hardware fence)
860: * is put to sleep while we wait for the maximum number of unack'd hardware fences to drop from
861: * MAX_HW_FENCE_UNACK_COUNT to MIN_HW_FENCE_UNACK_COUNT. If the count doesn't drop to the desired
862: * value, then log an error and trigger snapshot and recovery.
MATCH LINES: 1160, 1179, 1180
1148: else
1149: type = MSG_HDR_GET_ID(next_hdr);
1150:
1151: if (type != F2H_MSG_CONTEXT_BAD) {
1152: if (gen7_hfi_queue_read(gmu, HFI_MSG_ID, rcvd, sizeof(rcvd)) < 0)
1153: break;
1154: }
1155:
1156: switch (type) {
1157: case HFI_MSG_ACK:
1158: /*
1159: * We are assuming that there is only one outstanding ack because hfi
1160: * sending thread waits for completion while holding the device mutex
1161: * (except when we send H2F_MSG_HW_FENCE_INFO packets)
1162: */
1163: if (MSG_HDR_GET_ID(rcvd[1]) == H2F_MSG_HW_FENCE_INFO)
1164: process_hw_fence_ack(adreno_dev, rcvd);
1165: else
1166: gen7_receive_ack_async(adreno_dev, rcvd);
1167: break;
1168: case F2H_MSG_CONTEXT_BAD:
1169: if (gen7_hfi_queue_read(gmu, HFI_MSG_ID,
1170: (u32 *)adreno_dev->hwsched.ctxt_bad,
1171: HFI_MAX_MSG_SIZE) < 0)
1172: break;
1173: process_ctx_bad(adreno_dev);
1174: break;
1175: case F2H_MSG_TS_RETIRE:
1176: adreno_hwsched_log_profiling_info(adreno_dev, rcvd);
1177: adreno_scheduler_queue(adreno_dev);
1178: break;
1179: case F2H_MSG_SYNCOBJ_QUERY:
1180: gen7_trigger_syncobj_query(adreno_dev, rcvd);
1181: break;
1182: case F2H_MSG_GMU_CNTR_RELEASE: {
1183: struct hfi_gmu_cntr_release_cmd *cmd =
1184: (struct hfi_gmu_cntr_release_cmd *) rcvd;
1185:
1186: adreno_perfcounter_put(adreno_dev,
1187: cmd->group_id, cmd->countable, PERFCOUNTER_FLAG_KERNEL);
1188:
1189: gmu_core_mark_for_coldboot(KGSL_DEVICE(adreno_dev));
1190: }
1191: break;
1192: }
1193: }
1194: mutex_unlock(&hw_hfi->msgq_mutex);
1195: }
1196:
1197: static void process_log_block(struct adreno_device *adreno_dev, void *data)
1198: {
1199: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
1200: struct hfi_log_block *cmd = data;
1201: u32 *log_event = gmu->gmu_log->hostptr;
1202: u32 start, end;
1203:
1204: start = cmd->start_index;
MATCH LINES: 1338
1326: int rc;
1327: struct pending_cmd pending_ack;
1328:
1329: seqnum = atomic_inc_return(&gmu->hfi.seqnum);
1330: *cmd = MSG_HDR_SET_SEQNUM_SIZE(*cmd, seqnum, size_bytes >> 2);
1331:
1332: add_waiter(hfi, *cmd, &pending_ack);
1333:
1334: rc = gen7_hfi_cmdq_write(adreno_dev, cmd, size_bytes);
1335: if (rc)
1336: goto done;
1337:
1338: rc = adreno_hwsched_wait_ack_completion(adreno_dev,
1339: GMU_PDEV_DEV(device), &pending_ack, gen7_hwsched_process_msgq);
1340: if (rc)
1341: goto done;
1342:
1343: rc = check_ack_failure(adreno_dev, &pending_ack);
1344:
1345: done:
1346: del_waiter(hfi, &pending_ack);
1347:
1348: return rc;
1349: }
1350:
1351: static void init_queues(struct gen7_hfi *hfi)
1352: {
1353: u32 gmuaddr = hfi->hfi_mem->gmuaddr;
1354: struct hfi_queue_table hfi_table = {
1355: .qtbl_hdr = {
1356: .version = 0,
1357: .size = sizeof(struct hfi_queue_table) >> 2,
1358: .qhdr0_offset =
1359: sizeof(struct hfi_queue_table_header) >> 2,
1360: .qhdr_size = sizeof(struct hfi_queue_header) >> 2,
1361: .num_q = HFI_QUEUE_MAX,
1362: .num_active_q = HFI_QUEUE_MAX,
MATCH LINES: 1774
1762:
1763: seqnum = atomic_inc_return(&gmu->hfi.seqnum);
1764: cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
1765: cmd.type = prop;
1766: cmd.subtype = 0;
1767:
1768: add_waiter(hfi, cmd.hdr, &pending_ack);
1769:
1770: rc = gen7_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
1771: if (rc)
1772: goto done;
1773:
1774: rc = adreno_hwsched_wait_ack_completion(adreno_dev, gmu_pdev_dev, &pending_ack,
1775: gen7_hwsched_process_msgq);
1776:
1777: done:
1778: del_waiter(hfi, &pending_ack);
1779:
1780: if (rc || (pending_ack.results[2] == UINT_MAX))
1781: return 0;
1782:
1783: return pending_ack.results[2];
1784: }
1785:
1786: static void _context_queue_hw_fence_enable(struct adreno_device *adreno_dev)
1787: {
1788: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1789:
1790: if (GMU_VER_MINOR(device->gmu_core.ver.hfi) >= 3) {
1791: if (gen7_hfi_send_get_value(adreno_dev, HFI_VALUE_CONTEXT_QUEUE, 0) == 1) {
1792: set_bit(ADRENO_HWSCHED_CONTEXT_QUEUE, &adreno_dev->hwsched.flags);
1793: adreno_hwsched_register_hw_fence(adreno_dev);
1794: }
1795: }
1796: }
1797:
1798: int gen7_hwsched_hfi_set_value(struct adreno_device *adreno_dev, u32 type, u32 subtype, u32 data)
MATCH LINES: 1825
1813: if (rc)
1814: return 0;
1815:
1816: seqnum = atomic_inc_return(&gmu->hfi.seqnum);
1817: cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
1818:
1819: add_waiter(hfi, cmd.hdr, &pending_ack);
1820:
1821: rc = gen7_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
1822: if (rc)
1823: goto done;
1824:
1825: rc = adreno_hwsched_wait_ack_completion(adreno_dev, GMU_PDEV_DEV(device),
1826: &pending_ack, gen7_hwsched_process_msgq);
1827:
1828: if (rc)
1829: goto done;
1830:
1831: rc = check_ack_failure(adreno_dev, &pending_ack);
1832: done:
1833: del_waiter(hfi, &pending_ack);
1834:
1835: return rc;
1836: }
1837:
1838: static int gen7_hfi_send_hw_fence_feature_ctrl(struct adreno_device *adreno_dev)
1839: {
1840: struct adreno_hwsched *hwsched = &adreno_dev->hwsched;
1841: int ret;
1842:
1843: if (!test_bit(ADRENO_HWSCHED_HW_FENCE, &hwsched->flags))
1844: return 0;
1845:
1846: ret = gen7_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_HW_FENCE, 1, 0);
1847: if (ret && (ret == -ENOENT)) {
1848: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),
1849: "GMU doesn't support HW_FENCE feature\n");
MATCH LINES: 1973
1961: if (ret)
1962: return ret;
1963:
1964: seqnum = atomic_inc_return(&gmu->hfi.seqnum);
1965: cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
1966:
1967: add_waiter(hfi, cmd.hdr, ret_cmd);
1968:
1969: ret = gen7_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
1970: if (ret)
1971: goto err;
1972:
1973: ret = adreno_hwsched_wait_ack_completion(adreno_dev,
1974: GMU_PDEV_DEV(device), ret_cmd, gen7_hwsched_process_msgq);
1975: err:
1976: del_waiter(hfi, ret_cmd);
1977:
1978: return ret;
1979: }
1980:
1981: static int gen7_hwsched_warmboot_gpu(struct adreno_device *adreno_dev)
1982: {
1983: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
1984: struct pending_cmd ret_cmd = {0};
1985: int ret = 0;
1986:
1987: ret = gen7_hwsched_hfi_warmboot_gpu_cmd(adreno_dev, &ret_cmd);
1988: if (!ret)
1989: return ret;
1990:
1991: if (MSG_HDR_GET_TYPE(ret_cmd.results[1]) != H2F_MSG_WARMBOOT_CMD)
1992: goto err;
1993:
1994: switch (MSG_HDR_GET_TYPE(ret_cmd.results[2])) {
1995: case H2F_MSG_ISSUE_CMD_RAW: {
1996: if (ret_cmd.results[2] == gmu->cp_init_hdr)
1997: gen7_spin_idle_debug(adreno_dev,
MATCH LINES: 2392
2380:
2381: return submit_lpac_raw_cmds(adreno_dev, cmds, sizeof(cmds),
2382: "LPAC CP initialization failed to idle\n");
2383: }
2384:
2385: static int hfi_f2h_main(void *arg)
2386: {
2387: struct adreno_device *adreno_dev = arg;
2388: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2389: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev);
2390:
2391: while (!kthread_should_stop()) {
2392: wait_event_interruptible(hfi->f2h_wq, kthread_should_stop() ||
2393: /* If msgq irq is enabled and msgq has messages to process */
2394: (((hfi->irq_mask & HFI_IRQ_MSGQ_MASK) &&
2395: !is_queue_empty(adreno_dev, HFI_MSG_ID)) ||
2396: /* Trace buffer has messages to process */
2397: !gmu_core_is_trace_empty(device->gmu_core.trace.md->hostptr) ||
2398: /* Dbgq has messages to process */
2399: !is_queue_empty(adreno_dev, HFI_DBG_ID)));
2400:
2401: if (kthread_should_stop())
2402: break;
2403:
2404: gen7_hwsched_process_msgq(adreno_dev);
2405: gmu_core_process_trace_data(KGSL_DEVICE(adreno_dev),
2406: GMU_PDEV_DEV(device), &device->gmu_core.trace);
2407: gen7_hwsched_process_dbgq(adreno_dev, true);
2408: }
2409:
2410: return 0;
2411: }
2412:
2413: static void gen7_hwsched_hw_fence_timeout(struct work_struct *work)
2414: {
2415: struct gen7_hwsched_hfi *hfi = container_of(work, struct gen7_hwsched_hfi, hw_fence_ws);
2416: struct gen7_hwsched_device *gen7_hw_dev = container_of(hfi, struct gen7_hwsched_device,
MATCH LINES: 2728, 2742, 2748, 2753, 2769, 2770, 2771, 2775, 2777, 2778, 2785, 2786, 2788, 2789, 2792, 2797, 2798, 2800, 2805, 2806, 2819, 2822, 2823, 2827
2716:
2717: if (kgsl_context_is_lpac(drawobj->context))
2718: return 1;
2719:
2720: return 0;
2721: }
2722:
2723: static bool _is_kgsl_hw_fence_signaled(struct kgsl_drawobj_sync_hw_fence *hw_fence)
2724: {
2725: struct kgsl_sync_fence *kfence = (struct kgsl_sync_fence *)hw_fence->fence;
2726: struct kgsl_sync_timeline *ktimeline = kfence->parent;
2727:
2728: if (dma_fence_is_signaled_locked(&kfence->fence))
2729: return true;
2730:
2731: /*
2732: * If we fail to get the context refcount that means this context is detached.
2733: * In that case, treat all hardware fences from detached context as signaled.
2734: */
2735: if ((!hw_fence->context) && (!_kgsl_context_get(ktimeline->context)))
2736: return true;
2737:
2738: return false;
2739: }
2740:
2741: static void populate_kgsl_fence(struct kgsl_drawobj_sync_hw_fence *hw_fence,
2742: struct hfi_syncobj_legacy *obj)
2743: {
2744: struct kgsl_sync_fence *kfence = (struct kgsl_sync_fence *)hw_fence->fence;
2745: struct kgsl_sync_timeline *ktimeline = kfence->parent;
2746: unsigned long flags;
2747:
2748: obj->flags |= BIT(GMU_SYNCOBJ_FLAG_KGSL_FENCE_BIT);
2749:
2750: spin_lock_irqsave(&ktimeline->lock, flags);
2751:
2752: if (_is_kgsl_hw_fence_signaled(hw_fence))
2753: obj->flags |= BIT(GMU_SYNCOBJ_FLAG_SIGNALED_BIT);
2754: else
2755: hw_fence->context = ktimeline->context;
2756:
2757: spin_unlock_irqrestore(&ktimeline->lock, flags);
2758:
2759: obj->ctxt_id = kfence->context_id;
2760: obj->seq_no = kfence->timestamp;
2761: }
2762:
2763: static int _submit_hw_fence(struct adreno_device *adreno_dev,
2764: struct kgsl_drawobj *drawobj, void *cmdbuf)
2765: {
2766: struct adreno_context *drawctxt = ADRENO_CONTEXT(drawobj->context);
2767: int i;
2768: u32 cmd_sizebytes;
2769: struct kgsl_drawobj_sync *syncobj = SYNCOBJ(drawobj);
2770: struct hfi_submit_syncobj *cmd;
2771: struct hfi_syncobj_legacy *obj = NULL;
2772: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2773: u32 seqnum;
2774:
2775: /* Add hfi_syncobj struct for sync object */
2776: cmd_sizebytes = sizeof(*cmd) +
2777: (sizeof(struct hfi_syncobj) *
2778: syncobj->num_hw_fence);
2779:
2780: if (WARN_ON(cmd_sizebytes > HFI_MAX_MSG_SIZE))
2781: return -EMSGSIZE;
2782:
2783: memset(cmdbuf, 0x0, cmd_sizebytes);
2784: cmd = cmdbuf;
2785: cmd->num_syncobj = syncobj->num_hw_fence;
2786: obj = (struct hfi_syncobj_legacy *)&cmd[1];
2787:
2788: for (i = 0; i < syncobj->num_hw_fence; i++) {
2789: struct dma_fence *fence = syncobj->hw_fences[i].fence;
2790:
2791: if (is_kgsl_fence(fence)) {
2792: populate_kgsl_fence(&syncobj->hw_fences[i], obj);
2793: } else {
2794: int ret = kgsl_hw_fence_add_waiter(device, fence, NULL);
2795:
2796: if (ret) {
2797: adreno_hwsched_syncobj_kfence_put(syncobj);
2798: clear_bit(KGSL_SYNCOBJ_HW, &syncobj->flags);
2799: drawobj->timestamp = 0;
2800: clear_bit(KGSL_SYNCOBJ_HW_TS, &syncobj->flags);
2801: return ret;
2802: }
2803:
2804: if (kgsl_hw_fence_signaled(fence) ||
2805: test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
2806: obj->flags |= BIT(GMU_SYNCOBJ_FLAG_SIGNALED_BIT);
2807:
2808: obj->ctxt_id = fence->context;
2809: obj->seq_no = fence->seqno;
2810: }
2811: trace_adreno_input_hw_fence(drawobj->context->id, obj->ctxt_id,
2812: obj->seq_no, obj->flags, fence->ops->get_timeline_name ?
2813: fence->ops->get_timeline_name(fence) : "unknown");
2814:
2815: obj++;
2816: }
2817:
2818: /*
2819: * Attach a timestamp to this SYNCOBJ to keep track whether GMU has deemed it signaled
2820: * or not.
2821: */
2822: if (!test_and_set_bit(KGSL_SYNCOBJ_HW_TS, &syncobj->flags))
2823: drawobj->timestamp = ++drawctxt->syncobj_timestamp;
2824: cmd->timestamp = drawobj->timestamp;
2825:
2826: seqnum = atomic_inc_return(&adreno_dev->hwsched.submission_seqnum);
2827: cmd->hdr = CREATE_MSG_HDR(H2F_MSG_ISSUE_SYNCOBJ, HFI_MSG_CMD);
2828: cmd->hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd->hdr, seqnum, cmd_sizebytes >> 2);
2829:
2830: return adreno_gmu_context_queue_write(adreno_dev, &drawctxt->gmu_context_queue,
2831: (u32 *)cmd, cmd_sizebytes, drawobj, NULL);
2832: }
2833:
2834: int gen7_hwsched_check_context_inflight_hw_fences(struct adreno_device *adreno_dev,
2835: struct adreno_context *drawctxt)
2836: {
2837: struct adreno_hw_fence_entry *entry, *tmp;
2838: int ret = 0;
2839:
2840: spin_lock(&drawctxt->lock);
2841: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_inflight_list, node) {
2842: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr;
2843:
2844: if (timestamp_cmp((u32)entry->cmd.ts, hdr->out_fence_ts) > 0) {
2845: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),
2846: "ctx:%d has unsignaled fence ts:%d retired:%d\n",
2847: drawctxt->base.id, (u32)entry->cmd.ts, hdr->out_fence_ts);
2848: ret = -EINVAL;
2849: break;
2850: }
2851:
MATCH LINES: 3005, 3024
2993: {
2994: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2995: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence;
2996: u32 seqnum;
2997: int ret = 0;
2998:
2999: /* Device mutex is necessary to ensure only one hardware fence ack is being waited for */
3000: if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex)))
3001: return -EINVAL;
3002:
3003: spin_lock(&hwf->lock);
3004:
3005: init_completion(&hw_fence_ack.complete);
3006:
3007: entry->cmd.flags |= flags;
3008: seqnum = atomic_inc_return(&hwf->seqnum);
3009: entry->cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(entry->cmd.hdr, seqnum, sizeof(entry->cmd) >> 2);
3010:
3011: hw_fence_ack.sent_hdr = entry->cmd.hdr;
3012:
3013: /*
3014: * We don't need to increment the unack count here as we are waiting for the ack for
3015: * this fence before sending another hardware fence.
3016: */
3017: ret = gen7_hfi_cmdq_write(adreno_dev, (u32 *)&entry->cmd, sizeof(entry->cmd));
3018:
3019: spin_unlock(&hwf->lock);
3020:
3021: if (ret)
3022: goto done;
3023:
3024: ret = adreno_hwsched_wait_ack_completion(adreno_dev,
3025: GMU_PDEV_DEV(device), &hw_fence_ack,
3026: gen7_hwsched_process_msgq);
3027: if (ret)
3028: goto done;
3029:
3030: ret = _check_hw_fence_ack_failure(device, hw_fence_ack.results);
3031: if (ret)
3032: gmu_core_fault_snapshot(device, GMU_FAULT_HW_FENCE);
3033:
3034: done:
3035: memset(&hw_fence_ack, 0x0, sizeof(hw_fence_ack));
3036: return ret;
3037: }
3038:
3039: #define DRAWCTXT_SLOT_AVAILABLE(count) \
3040: ((count + 1) < (HW_FENCE_QUEUE_SIZE / sizeof(struct hfi_hw_fence_info)))
3041:
3042: /**
3043: * allocate_hw_fence_entry - Allocate an entry to keep track of a hardware fence. This is free'd
3044: * when we know GMU has sent this fence to the TxQueue
3045: */
3046: static struct adreno_hw_fence_entry *allocate_hw_fence_entry(struct adreno_device *adreno_dev,
3047: struct adreno_context *drawctxt, struct kgsl_sync_fence *kfence)
3048: {
MATCH LINES: 3077
3065: return NULL;
3066: }
3067:
3068: entry->kfence = kfence;
3069: entry->drawctxt = drawctxt;
3070:
3071: if (setup_hw_fence_info_cmd(adreno_dev, entry)) {
3072: kmem_cache_free(hwsched->hw_fence_cache, entry);
3073: kgsl_context_put_deferred(&drawctxt->base);
3074: return NULL;
3075: }
3076:
3077: dma_fence_get(&kfence->fence);
3078:
3079: drawctxt->hw_fence_count++;
3080: hwsched->hw_fence.pending_count++;
3081:
3082: INIT_LIST_HEAD(&entry->node);
3083: INIT_LIST_HEAD(&entry->reset_node);
3084: return entry;
3085: }
3086:
3087: /**
3088: * drawctxt_queue_hw_fence - Add a hardware fence to draw context's hardware fence list and make
3089: * sure the list remains sorted (with the fence with the largest timestamp at the end)
3090: */
3091: static void drawctxt_queue_hw_fence(struct adreno_device *adreno_dev,
3092: struct adreno_context *drawctxt, struct kgsl_sync_fence *kfence)
3093: {
3094: struct adreno_hw_fence_entry *new = allocate_hw_fence_entry(adreno_dev, drawctxt, kfence);
3095: struct adreno_hw_fence_entry *entry = NULL;
3096: u32 ts = kfence->timestamp;
3097:
3098: if (!new)
3099: return;
3100:
3101: /* Walk the list backwards to find the right spot for this fence */
MATCH LINES: 3142
3130: */
3131: static int _hw_fence_sleep(struct adreno_device *adreno_dev, struct adreno_context *drawctxt)
3132: {
3133: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence;
3134: int ret = 0;
3135:
3136: if (!test_bit(GEN7_HWSCHED_HW_FENCE_SLEEP_BIT, &hwf->flags))
3137: return 0;
3138:
3139: spin_unlock(&hwf->lock);
3140: spin_unlock(&drawctxt->lock);
3141:
3142: ret = wait_event_interruptible(hwf->unack_wq,
3143: _hw_fence_end_sleep(adreno_dev));
3144:
3145: spin_lock(&drawctxt->lock);
3146: spin_lock(&hwf->lock);
3147:
3148: /*
3149: * If the thread received a signal, or the context became bad in the meanwhile or the limit
3150: * is still not settled, then return error to avoid creating this hardware fence
3151: */
3152: if ((ret == -ERESTARTSYS) || kgsl_context_is_bad(&drawctxt->base) ||
3153: test_bit(GEN7_HWSCHED_HW_FENCE_MAX_BIT, &hwf->flags))
3154: return -EINVAL;
3155:
3156: /*
3157: * If fault recovery is imminent then return error code to avoid creating new hardware
3158: * fences until recovery is complete
3159: */
3160: if (test_bit(GEN7_HWSCHED_HW_FENCE_ABORT_BIT, &hwf->flags))
3161: return -EBUSY;
3162:
3163: return ret;
3164: }
3165:
3166: void gen7_hwsched_create_hw_fence(struct adreno_device *adreno_dev,
MATCH LINES: 3411
3399: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
3400:
3401: cmdbuf = devm_kzalloc(&device->pdev->dev, HFI_MAX_MSG_SIZE,
3402: GFP_KERNEL);
3403: if (!cmdbuf)
3404: return -ENOMEM;
3405: }
3406:
3407: ret = hfi_context_register(adreno_dev, drawobj->context);
3408: if (ret)
3409: return ret;
3410:
3411: if ((drawobj->type & SYNCOBJ_TYPE) != 0)
3412: return _submit_hw_fence(adreno_dev, drawobj, cmdbuf);
3413:
3414: cmdobj = CMDOBJ(drawobj);
3415:
3416: /*
3417: * If the MARKER object is retired, it doesn't need to be dispatched to GMU. Simply trigger
3418: * any pending fences that are less than/equal to this object's timestamp.
3419: */
3420: if (test_bit(CMDOBJ_MARKER_EXPIRED, &cmdobj->priv)) {
3421: spin_lock(&drawctxt->lock);
3422: process_hw_fence_queue(adreno_dev, drawctxt, drawobj->timestamp);
3423: spin_unlock(&drawctxt->lock);
3424: return 0;
3425: }
3426:
3427: /* Add a *issue_ib struct for each IB */
3428: if (cmdobj->numibs > HWSCHED_MAX_DISPATCH_NUMIBS ||
3429: test_bit(CMDOBJ_SKIP, &cmdobj->priv))
3430: cmd_sizebytes = sizeof(*cmd);
3431: else
3432: cmd_sizebytes = sizeof(*cmd) +
3433: (sizeof(struct hfi_issue_ib) * cmdobj->numibs);
3434:
3435: if (WARN_ON(cmd_sizebytes > HFI_MAX_MSG_SIZE))
MATCH LINES: 3490
3478: if (adreno_hwsched_context_queue_enabled(adreno_dev))
3479: ret = adreno_gmu_context_queue_write(adreno_dev,
3480: &drawctxt->gmu_context_queue, (u32 *)cmd, cmd_sizebytes, drawobj, &time);
3481: else
3482: ret = gen7_hfi_dispatch_queue_write(adreno_dev,
3483: HFI_DSP_ID_0 + drawobj->context->gmu_dispatch_queue,
3484: (u32 *)cmd, cmd_sizebytes, cmdobj, &time);
3485: if (ret)
3486: return ret;
3487:
3488: hdr = drawctxt->gmu_context_queue.hostptr;
3489: /* The last sync object has been retired by the GMU */
3490: if (timestamp_cmp(hdr->sync_obj_ts, drawctxt->syncobj_timestamp) >= 0)
3491: /* Send interrupt to GMU to receive the message */
3492: gmu_core_regwrite(KGSL_DEVICE(adreno_dev), GEN7_GMU_HOST2GMU_INTR_SET,
3493: DISPQ_IRQ_BIT(get_irq_bit(adreno_dev, drawobj)));
3494: else
3495: gmu_core_regwrite(KGSL_DEVICE(adreno_dev), GEN7_GMU_HOST2GMU_INTR_SET,
3496: DISPQ_SYNC_IRQ_BIT(get_irq_bit(adreno_dev, drawobj)));
3497:
3498: drawctxt->internal_timestamp = drawobj->timestamp;
3499:
3500: spin_lock(&drawctxt->lock);
3501: process_hw_fence_queue(adreno_dev, drawctxt, drawobj->timestamp);
3502: /*
3503: * We need to update the gmu_hw_fence_ready_ts while holding the drawctxt lock since we
3504: * have to check it in the hardware fence creation path, where we are not taking the device
3505: * mutex.
3506: */
3507: drawctxt->gmu_hw_fence_ready_ts = drawobj->timestamp;
3508: spin_unlock(&drawctxt->lock);
3509:
3510: return 0;
3511: }
3512:
3513: int gen7_hwsched_send_recurring_cmdobj(struct adreno_device *adreno_dev,
3514: struct kgsl_drawobj_cmd *cmdobj)
MATCH LINES: 3714
3702: }
3703:
3704: seqnum = atomic_inc_return(&gmu->hfi.seqnum);
3705: cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
3706: add_waiter(hfi, cmd.hdr, &pending_ack);
3707:
3708: ret = gen7_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
3709: if (ret) {
3710: trigger_context_unregister_fault(adreno_dev, drawctxt);
3711: goto done;
3712: }
3713:
3714: ret = adreno_hwsched_ctxt_unregister_wait_completion(adreno_dev,
3715: GMU_PDEV_DEV(device), context, &pending_ack, gen7_hwsched_process_msgq, &cmd);
3716: if (ret) {
3717: trigger_context_unregister_fault(adreno_dev, drawctxt);
3718: goto done;
3719: }
3720:
3721: ret = check_detached_context_hardware_fences(adreno_dev, drawctxt);
3722: if (!ret)
3723: ret = check_ack_failure(adreno_dev, &pending_ack);
3724:
3725: done:
3726: adreno_active_count_put(adreno_dev);
3727: del_waiter(hfi, &pending_ack);
3728:
3729: return ret;
3730: }
3731:
3732: void gen7_hwsched_context_detach(struct adreno_context *drawctxt)
3733: {
3734: struct kgsl_context *context = &drawctxt->base;
3735: struct kgsl_device *device = context->device;
3736: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
3737: int ret = 0;
3738:
--- FILE: \adreno_gen7_snapshot.c | HITS: 1 ---
MATCH LINES: 651
639: {
640: u32 read_ptr, count, write_ptr, val, idx = 0;
641: struct kgsl_snapshot_trace_buffer *header = (struct kgsl_snapshot_trace_buffer *) buf;
642: u32 *data = (u32 *)(buf + sizeof(*header));
643: struct gen7_trace_buffer_info *info = (struct gen7_trace_buffer_info *) priv;
644:
645: /* Unlock ETB buffer */
646: qdss_regwrite(tmc_virt, QDSS_AOSS_APB_TMC_LAR, 0xC5ACCE55);
647:
648: /* Make sure unlock goes through before proceeding further */
649: mb();
650:
651: /* Flush the QDSS pipeline to ensure completion of pending write to buffer */
652: val = qdss_regread(tmc_virt, QDSS_AOSS_APB_TMC_FFCR);
653: qdss_regwrite(tmc_virt, QDSS_AOSS_APB_TMC_FFCR, val | 0x40);
654:
655: /* Make sure pipeline is flushed before we get read and write pointers */
656: mb();
657:
658: /* Disable ETB */
659: qdss_regwrite(tmc_virt, QDSS_AOSS_APB_TMC_CTRL, 0);
660:
661: /* Set to circular mode */
662: qdss_regwrite(tmc_virt, QDSS_AOSS_APB_TMC_MODE, 0);
663:
664: /* Ensure buffer is set to circular mode before accessing it */
665: mb();
666:
667: /* Size of buffer is specified in register TMC_RSZ */
668: count = qdss_regread(tmc_virt, QDSS_AOSS_APB_TMC_RSZ) << 2;
669: read_ptr = qdss_regread(tmc_virt, QDSS_AOSS_APB_TMC_RRP);
670: write_ptr = qdss_regread(tmc_virt, QDSS_AOSS_APB_TMC_RWP);
671:
672: /* ETB buffer if full read_ptr will be equal to write_ptr else write_ptr leads read_ptr */
673: count = (read_ptr == write_ptr) ? count : (write_ptr - read_ptr);
674:
675: if (remain < count + sizeof(*header)) {
--- FILE: \adreno_gen8.c | HITS: 1 ---
MATCH LINES: 2440
2428: *cmds++ = cp_type7_packet(CP_SET_AMBLE, 3);
2429: *cmds++ = lower_32_bits(kmd_postamble_addr);
2430: *cmds++ = upper_32_bits(kmd_postamble_addr);
2431: *cmds++ = FIELD_PREP(GENMASK(22, 20), CP_KMD_AMBLE_TYPE)
2432: | (FIELD_PREP(GENMASK(19, 0),
2433: adreno_dev->preempt.postamble_bootup_len));
2434: }
2435:
2436: *cmds++ = cp_type7_packet(CP_CONTEXT_SWITCH_YIELD, 4);
2437: *cmds++ = 0;
2438: *cmds++ = 0;
2439: *cmds++ = 0;
2440: /* generate interrupt on preemption completion */
2441: *cmds++ = 0;
2442:
2443: ret = gen8_ringbuffer_submit(rb, NULL);
2444: if (!ret) {
2445: ret = adreno_spin_idle(adreno_dev, 2000);
2446: if (ret)
2447: gen8_spin_idle_debug(adreno_dev,
2448: "hw preemption initialization failed to idle\n");
2449: }
2450:
2451: return ret;
2452: }
2453:
2454: int gen8_rb_start(struct adreno_device *adreno_dev)
2455: {
2456: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev);
2457: struct adreno_firmware *fw = ADRENO_FW(adreno_dev, ADRENO_FW_SQE);
2458: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2459: struct adreno_ringbuffer *rb;
2460: u64 addr;
2461: int ret, i;
2462: u32 *cmds;
2463:
2464: /* Clear all the ringbuffers */
--- FILE: \adreno_gen8_hwsched.c | HITS: 2 ---
MATCH LINES: 2139, 2140
2127: device = KGSL_DEVICE(adreno_dev);
2128:
2129: INIT_WORK(&device->idle_check_ws, hwsched_idle_check);
2130:
2131: timer_setup(&device->idle_timer, hwsched_idle_timer, 0);
2132:
2133: if (ADRENO_FEATURE(adreno_dev, ADRENO_LPAC))
2134: adreno_dev->lpac_enabled = true;
2135:
2136: kgsl_mmu_set_feature(device, KGSL_MMU_PAGEFAULT_TERMINATE);
2137:
2138: if (ADRENO_FEATURE(adreno_dev, ADRENO_HW_FENCE))
2139: device->max_syncobj_hw_fence_count = min_t(u32, HFI_SYNCOBJ_HW_FENCE_MAX,
2140: MAX_SYNCOBJ_QUERY_BITS);
2141:
2142: ret = adreno_hwsched_init(adreno_dev, &gen8_hwsched_ops);
2143: if (ret)
2144: return ret;
2145:
2146: /* Initialize the dcvs tunables */
2147: for (i = 0; i < GPU_TUNING_KEY_MAX; i++)
2148: adreno_dev->hwsched.sysfs_dcvs_tunables[i].value = GPU_DCVS_TUNING_INVALID_VALUE;
2149:
2150: /* Initialize the TSENSE suspend work that is done at GPU suspend */
2151: INIT_WORK(&gen8_dev->tsense_work, gen8_scm_gpu_tsense_suspend_work);
2152:
2153: gmu_dev = GMU_PDEV_DEV(device);
2154: WARN_ON(kobject_init_and_add(&adreno_dev->hwsched.tunables_kobj, &ktype_tunables,
2155: &gmu_dev->kobj, "dcvs_tunables"));
2156:
2157: WARN_ON(kobject_init_and_add(&adreno_dev->hwsched.dcvs_kobj, &ktype_dcvs,
2158: &gmu_dev->kobj, "dcvs"));
2159:
2160: return ret;
2161: }
2162:
2163: int gen8_hwsched_add_to_minidump(struct adreno_device *adreno_dev)
2164: {
--- FILE: \adreno_gen8_hwsched_hfi.c | HITS: 93 ---
MATCH LINES: 71
59: {
60: if (!adreno_dev->lpac_enabled)
61: return 0;
62:
63: return gen8_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_LPAC, 1, 0);
64: }
65:
66: static void add_waiter(struct gen8_hwsched_hfi *hfi, u32 hdr,
67: struct pending_cmd *ack)
68: {
69: memset(ack, 0x0, sizeof(*ack));
70:
71: init_completion(&ack->complete);
72: write_lock_irq(&hfi->msglock);
73: list_add_tail(&ack->node, &hfi->msglist);
74: write_unlock_irq(&hfi->msglock);
75:
76: ack->sent_hdr = hdr;
77: }
78:
79: static void del_waiter(struct gen8_hwsched_hfi *hfi, struct pending_cmd *ack)
80: {
81: write_lock_irq(&hfi->msglock);
82: list_del(&ack->node);
83: write_unlock_irq(&hfi->msglock);
84: }
85:
86: static void gen8_receive_ack_async(struct adreno_device *adreno_dev, void *rcvd)
87: {
88: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
89: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev);
90: struct pending_cmd *cmd = NULL;
91: u32 waiters[64], num_waiters = 0, i;
92: u32 *ack = rcvd;
93: u32 hdr = ack[0];
94: u32 req_hdr = ack[1];
95: u32 size_bytes = MSG_HDR_GET_SIZE(hdr) << 2;
MATCH LINES: 133, 138, 140, 141, 144, 145, 148, 160, 161, 165, 169, 170, 171, 174, 176, 180, 187, 206, 215, 223
121: dev_err_ratelimited(gmu_pdev_dev,
122: "Unexpectedly got id %d seqnum %d. Total waiters: %d Top %d Waiters:\n",
123: MSG_HDR_GET_ID(req_hdr), MSG_HDR_GET_SEQNUM(req_hdr),
124: num_waiters, min_t(u32, num_waiters, 5));
125:
126: for (i = 0; i < num_waiters && i < 5; i++)
127: dev_err_ratelimited(gmu_pdev_dev,
128: " id %d seqnum %d\n",
129: MSG_HDR_GET_ID(waiters[i]),
130: MSG_HDR_GET_SEQNUM(waiters[i]));
131: }
132:
133: struct syncobj_flags {
134: unsigned long mask;
135: const char *name;
136: };
137:
138: static void _get_syncobj_string(char *str, u32 max_size, struct hfi_syncobj *syncobj, u32 index)
139: {
140: u32 count = scnprintf(str, max_size, "syncobj[%d] ctxt_id:%llu seqno:%llu flags:", index,
141: syncobj->ctxt_id, syncobj->seq_no);
142: u32 i;
143: bool first = true;
144: static const struct syncobj_flags _flags[] = {
145: GMU_SYNCOBJ_FLAGS, { -1, NULL }};
146:
147: for (i = 0; _flags[i].name; i++) {
148: if (!(syncobj->flags & _flags[i].mask))
149: continue;
150:
151: if (first) {
152: count += scnprintf(str + count, max_size - count, "%s", _flags[i].name);
153: first = false;
154: } else {
155: count += scnprintf(str + count, max_size - count, "|%s", _flags[i].name);
156: }
157: }
158: }
159:
160: static void log_syncobj(struct gen8_gmu_device *gmu, struct adreno_context *drawctxt,
161: struct hfi_submit_syncobj *cmd, u32 syncobj_read_idx)
162: {
163: struct kgsl_device *device = KGSL_DEVICE(gen8_gmu_to_adreno(gmu));
164: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr;
165: struct hfi_syncobj syncobj;
166: char str[128];
167: u32 i = 0;
168:
169: for (i = 0; i < cmd->num_syncobj; i++) {
170: if (adreno_gmu_context_queue_read(drawctxt, (u32 *) &syncobj, syncobj_read_idx,
171: sizeof(syncobj) >> 2))
172: break;
173:
174: _get_syncobj_string(str, sizeof(str), &syncobj, i);
175: dev_err(GMU_PDEV_DEV(device), "%s\n", str);
176: syncobj_read_idx = (syncobj_read_idx + (sizeof(syncobj) >> 2)) % hdr->queue_size;
177: }
178: }
179:
180: static void find_timeout_syncobj(struct adreno_device *adreno_dev, u32 ctxt_id, u32 ts)
181: {
182: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
183: struct kgsl_context *context = NULL;
184: struct adreno_context *drawctxt;
185: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
186: struct gmu_context_queue_header *hdr;
187: struct hfi_submit_syncobj cmd;
188: u32 *queue, i;
189: int ret;
190:
191: /* We want to get the context even if it is detached */
192: read_lock(&device->context_lock);
193: context = idr_find(&device->context_idr, ctxt_id);
194: ret = _kgsl_context_get(context);
195: read_unlock(&device->context_lock);
196:
197: if (!ret)
198: return;
199:
200: drawctxt = ADRENO_CONTEXT(context);
201:
202: hdr = drawctxt->gmu_context_queue.hostptr;
203: queue = (u32 *)(drawctxt->gmu_context_queue.hostptr + sizeof(*hdr));
204:
205: for (i = hdr->read_index; i != hdr->write_index;) {
206: if (MSG_HDR_GET_ID(queue[i]) != H2F_MSG_ISSUE_SYNCOBJ) {
207: i = (i + MSG_HDR_GET_SIZE(queue[i])) % hdr->queue_size;
208: continue;
209: }
210:
211: if (adreno_gmu_context_queue_read(drawctxt, (u32 *) &cmd, i, sizeof(cmd) >> 2))
212: break;
213:
214: if (cmd.timestamp == ts) {
215: log_syncobj(gmu, drawctxt, &cmd,
216: (i + (sizeof(cmd) >> 2)) % hdr->queue_size);
217: break;
218: }
219: i = (i + MSG_HDR_GET_SIZE(queue[i])) % hdr->queue_size;
220: }
221:
222: if (i == hdr->write_index)
223: dev_err(GMU_PDEV_DEV(device), "Couldn't find unsignaled syncobj ctx:%d ts:%d\n",
224: ctxt_id, ts);
225:
226: kgsl_context_put(context);
227: }
228:
229: /* Look up a particular key's value for a given type of payload */
230: static u32 gen8_hwsched_lookup_key_value(struct adreno_device *adreno_dev,
231: u32 type, u32 key)
232: {
233: struct hfi_context_bad_cmd *cmd = adreno_dev->hwsched.ctxt_bad;
234: u32 i = 0, payload_bytes;
235: void *start;
236:
237: if (!cmd->hdr)
238: return 0;
239:
240: payload_bytes = (MSG_HDR_GET_SIZE(cmd->hdr) << 2) -
241: offsetof(struct hfi_context_bad_cmd, payload);
242:
243: start = &cmd->payload[0];
244:
245: while (i < payload_bytes) {
246: struct payload_section *payload = start + i;
247:
MATCH LINES: 431, 432, 434
419: break;
420: case GMU_GPU_AQE1_UCODE_ERROR:
421: dev_crit_ratelimited(gmu_pdev_dev, "AQE1 ucode error interrupt\n");
422: break;
423: case GMU_GPU_AQE1_HW_FAULT_ERROR:
424: dev_crit_ratelimited(gmu_pdev_dev, "AQE1 HW fault | status=0x%8.8x\n",
425: gen8_hwsched_lookup_key_value(adreno_dev,
426: PAYLOAD_FAULT_REGS, KEY_AQE1_HW_FAULT));
427: break;
428: case GMU_GPU_AQE1_ILLEGAL_INST_ERROR:
429: dev_crit_ratelimited(gmu_pdev_dev, "AQE1 Illegal instruction error\n");
430: break;
431: case GMU_SYNCOBJ_TIMEOUT_ERROR:
432: dev_crit_ratelimited(gmu_pdev_dev, "syncobj timeout ctx %d ts %u\n",
433: cmd->gc.ctxt_id, cmd->gc.ts);
434: find_timeout_syncobj(adreno_dev, cmd->gc.ctxt_id, cmd->gc.ts);
435: break;
436: case GMU_CP_DDEBR_HW_FAULT_ERROR:
437: dev_crit_ratelimited(gmu_pdev_dev,
438: "CP DDE BR | Ringbuffer HW fault | status=0x%8.8x\n",
439: gen8_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS,
440: KEY_CP_DDEBR_HW_FAULT));
441: break;
442: case GMU_CP_DDEBR_OPCODE_ERROR:
443: dev_crit_ratelimited(gmu_pdev_dev,
444: "CP DDE BR opcode error | opcode=0x%8.8x\n",
445: gen8_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS,
446: KEY_CP_DDEBR_OPCODE_ERROR));
447: break;
448: case GMU_CP_DDEBR_UCODE_ERROR:
449: dev_crit_ratelimited(gmu_pdev_dev, "CP DDE BR ucode error\n");
450: break;
451: case GMU_CP_DDEBR_PROTECTED_ERROR: {
452: u32 status = gen8_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS,
453: KEY_CP_DDEBR_PROTECTED_ERROR);
454:
455: dev_crit_ratelimited(gmu_pdev_dev,
456: "CP DDE BR | Protected mode error | %s | addr=0x%5.5x | status=0x%8.8x\n",
457: status & (1 << 20) ? "READ" : "WRITE",
458: status & 0x3FFFF, status);
MATCH LINES: 600, 601, 603, 612, 622, 634, 635, 637, 639, 642, 643, 651, 655, 661, 663, 666, 670, 672, 673, 674, 688, 693, 724, 727, 728, 734, 756
588: /* Non fatal RBBM error interrupts don't go through reset and recovery */
589: if (!log_gpu_fault(adreno_dev)) {
590: memset(adreno_dev->hwsched.ctxt_bad, 0x0, HFI_MAX_MSG_SIZE);
591: return;
592: }
593:
594: adreno_dev->hwsched.reset_type = gen8_hwsched_lookup_key_value(adreno_dev,
595: PAYLOAD_FAULT_RESET_POLICY, KEY_GPU_RESET_POLICY);
596:
597: gen8_hwsched_fault(adreno_dev, ADRENO_HARD_FAULT);
598: }
599:
600: #define GET_QUERIED_FENCE_INDEX(x) (x / BITS_PER_SYNCOBJ_QUERY)
601: #define GET_QUERIED_FENCE_BIT(x) (x % BITS_PER_SYNCOBJ_QUERY)
602:
603: static bool fence_is_queried(struct hfi_syncobj_query_cmd *cmd, u32 fence_index)
604: {
605: u32 index = GET_QUERIED_FENCE_INDEX(fence_index);
606: u32 bit = GET_QUERIED_FENCE_BIT(fence_index);
607:
608: return (cmd->queries[index].query_bitmask & BIT(bit));
609: }
610:
611: static void set_fence_signal_bit(struct adreno_device *adreno_dev,
612: struct hfi_syncobj_query_cmd *reply, struct dma_fence *fence, u32 fence_index)
613: {
614: u32 index = GET_QUERIED_FENCE_INDEX(fence_index);
615: u32 bit = GET_QUERIED_FENCE_BIT(fence_index);
616: u64 flags = ADRENO_HW_FENCE_SW_STATUS_PENDING;
617: char name[KGSL_FENCE_NAME_LEN];
618: char value[32] = "unknown";
619:
620: kgsl_fence_timeline_value_str(fence, value, sizeof(value));
621:
622: if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) {
623: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),
624: "GMU is waiting for signaled fence(ctx:%llu seqno:%llu value:%s)\n",
625: fence->context, fence->seqno, value);
626: reply->queries[index].query_bitmask |= BIT(bit);
627: flags = ADRENO_HW_FENCE_SW_STATUS_SIGNALED;
628: }
629: kgsl_get_fence_name(fence, name, sizeof(name));
630:
631: trace_adreno_hw_fence_query(fence->context, fence->seqno, flags, name, value);
632: }
633:
634: static void gen8_syncobj_query_reply(struct adreno_device *adreno_dev,
635: struct kgsl_drawobj *drawobj, struct hfi_syncobj_query_cmd *cmd)
636: {
637: struct hfi_syncobj_query_cmd reply = {0};
638: int i;
639: struct kgsl_drawobj_sync *syncobj = SYNCOBJ(drawobj);
640: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
641:
642: for (i = 0; i < syncobj->num_hw_fence; i++) {
643: struct dma_fence *fence = syncobj->hw_fences[i].fence;
644:
645: if (!fence_is_queried(cmd, i))
646: continue;
647:
648: set_fence_signal_bit(adreno_dev, &reply, fence, i);
649: }
650:
651: reply.hdr = CREATE_MSG_HDR(F2H_MSG_SYNCOBJ_QUERY, HFI_MSG_CMD);
652: reply.gmu_ctxt_id = cmd->gmu_ctxt_id;
653: reply.sync_obj_ts = cmd->sync_obj_ts;
654:
655: trace_adreno_syncobj_query_reply(reply.gmu_ctxt_id, reply.sync_obj_ts,
656: gpudev->read_alwayson(adreno_dev));
657:
658: gen8_hfi_send_cmd_async(adreno_dev, &reply, sizeof(reply));
659: }
660:
661: struct syncobj_query_work {
662: /** @cmd: The query command to be processed */
663: struct hfi_syncobj_query_cmd cmd;
664: /** @context: kgsl context that is waiting for this sync object */
665: struct kgsl_context *context;
666: /** @work: The work structure to execute syncobj query reply */
667: struct kthread_work work;
668: };
669:
670: static void gen8_process_syncobj_query_work(struct kthread_work *work)
671: {
672: struct syncobj_query_work *query_work = container_of(work,
673: struct syncobj_query_work, work);
674: struct hfi_syncobj_query_cmd *cmd = (struct hfi_syncobj_query_cmd *)&query_work->cmd;
675: struct kgsl_context *context = query_work->context;
676: struct kgsl_device *device = context->device;
677: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
678: struct adreno_hwsched *hwsched = &adreno_dev->hwsched;
679: struct cmd_list_obj *obj;
680: bool missing = true;
681:
682: mutex_lock(&hwsched->mutex);
683: kgsl_mutex_lock(&device->mutex);
684:
685: list_for_each_entry(obj, &hwsched->cmd_list, node) {
686: struct kgsl_drawobj *drawobj = obj->drawobj;
687:
688: if ((drawobj->type & SYNCOBJ_TYPE) == 0)
689: continue;
690:
691: if ((drawobj->context->id == cmd->gmu_ctxt_id) &&
692: (drawobj->timestamp == cmd->sync_obj_ts)) {
693: gen8_syncobj_query_reply(adreno_dev, drawobj, cmd);
694: missing = false;
695: break;
696: }
697: }
698:
699: if (missing) {
700: struct adreno_context *drawctxt = ADRENO_CONTEXT(context);
701: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr;
702:
703: /*
704: * If the sync object is not found, it can only mean that the sync object was
705: * retired by the GMU in the meanwhile. However, if that is not the case, then
706: * we have a problem.
707: */
708: if (timestamp_cmp(cmd->sync_obj_ts, hdr->sync_obj_ts) > 0) {
709: dev_err(GMU_PDEV_DEV(device),
710: "Missing sync object ctx:%d ts:%d retired:%d\n",
711: context->id, cmd->sync_obj_ts, hdr->sync_obj_ts);
712: gmu_core_fault_snapshot(device, GMU_FAULT_HW_FENCE);
713: gen8_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT);
714: }
715: }
716:
717: kgsl_mutex_unlock(&device->mutex);
718: mutex_unlock(&hwsched->mutex);
719:
720: kgsl_context_put(context);
721: kfree(query_work);
722: }
723:
724: static void gen8_trigger_syncobj_query(struct adreno_device *adreno_dev,
725: u32 *rcvd)
726: {
727: struct syncobj_query_work *query_work;
728: struct hfi_syncobj_query_cmd *cmd = (struct hfi_syncobj_query_cmd *)rcvd;
729: struct kgsl_context *context = NULL;
730: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
731: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
732: int ret;
733:
734: trace_adreno_syncobj_query(cmd->gmu_ctxt_id, cmd->sync_obj_ts,
735: gpudev->read_alwayson(adreno_dev));
736:
737: /*
738: * We need the context even if it is detached. Hence, we can't use kgsl_context_get here.
739: * We must make sure that this context id doesn't get destroyed (to avoid re-use) until GMU
740: * has ack'd the query reply.
741: */
742: read_lock(&device->context_lock);
743: context = idr_find(&device->context_idr, cmd->gmu_ctxt_id);
744: ret = _kgsl_context_get(context);
745: read_unlock(&device->context_lock);
746:
747: if (!ret)
748: return;
749:
750: query_work = kzalloc(sizeof(*query_work), GFP_KERNEL);
751: if (!query_work) {
752: kgsl_context_put(context);
753: return;
754: }
755:
756: kthread_init_work(&query_work->work, gen8_process_syncobj_query_work);
757: memcpy(&query_work->cmd, cmd, sizeof(*cmd));
758: query_work->context = context;
759:
760: kthread_queue_work(adreno_dev->scheduler_worker, &query_work->work);
761: }
762:
763: /*
764: * This defines the maximum unack'd hardware fences that we allow. When this limit is reached, we
765: * will put all threads (that want to create a hardware fence) to sleep until the maximum unack'd
766: * hardware fence count drops to MIN_HW_FENCE_UNACK_COUNT
767: */
768: #define MAX_HW_FENCE_UNACK_COUNT 20
769:
770: /*
771: * Once the maximum unack'd hardware fences drops to this value, wake up all the threads (that want
772: * to create hardware fences)
773: */
774: #define MIN_HW_FENCE_UNACK_COUNT 10
775:
776: /*
777: * This is the maximum duration (in milliseconds) a thread (that wants to create a hardware fence)
778: * is put to sleep while we wait for the maximum number of unack'd hardware fences to drop from
779: * MAX_HW_FENCE_UNACK_COUNT to MIN_HW_FENCE_UNACK_COUNT. If the count doesn't drop to the desired
780: * value, then log an error and trigger snapshot and recovery.
MATCH LINES: 1094, 1113, 1114
1082: else
1083: type = MSG_HDR_GET_ID(next_hdr);
1084:
1085: if (type != F2H_MSG_CONTEXT_BAD) {
1086: if (gen8_hfi_queue_read(gmu, HFI_MSG_ID, rcvd, sizeof(rcvd)) < 0)
1087: break;
1088: }
1089:
1090: switch (type) {
1091: case HFI_MSG_ACK:
1092: /*
1093: * We are assuming that there is only one outstanding ack because hfi
1094: * sending thread waits for completion while holding the device mutex
1095: * (except when we send H2F_MSG_HW_FENCE_INFO packets)
1096: */
1097: if (MSG_HDR_GET_ID(rcvd[1]) == H2F_MSG_HW_FENCE_INFO)
1098: process_hw_fence_ack(adreno_dev, rcvd);
1099: else
1100: gen8_receive_ack_async(adreno_dev, rcvd);
1101: break;
1102: case F2H_MSG_CONTEXT_BAD:
1103: if (gen8_hfi_queue_read(gmu, HFI_MSG_ID,
1104: (u32 *)adreno_dev->hwsched.ctxt_bad,
1105: HFI_MAX_MSG_SIZE) < 0)
1106: break;
1107: process_ctx_bad(adreno_dev);
1108: break;
1109: case F2H_MSG_TS_RETIRE:
1110: adreno_hwsched_log_profiling_info(adreno_dev, rcvd);
1111: adreno_scheduler_queue(adreno_dev);
1112: break;
1113: case F2H_MSG_SYNCOBJ_QUERY:
1114: gen8_trigger_syncobj_query(adreno_dev, rcvd);
1115: break;
1116: case F2H_MSG_GMU_CNTR_RELEASE: {
1117: struct hfi_gmu_cntr_release_cmd *cmd =
1118: (struct hfi_gmu_cntr_release_cmd *) rcvd;
1119:
1120: adreno_perfcounter_put(adreno_dev,
1121: cmd->group_id, cmd->countable, PERFCOUNTER_FLAG_KERNEL);
1122:
1123: gmu_core_mark_for_coldboot(KGSL_DEVICE(adreno_dev));
1124: }
1125: break;
1126: case F2H_MSG_PLATFORM_LA:
1127: gen8_hwsched_process_f2h_platform_msg(adreno_dev, rcvd);
1128: break;
1129: }
1130: }
1131: mutex_unlock(&hw_hfi->msgq_mutex);
1132: }
1133:
1134: static void process_log_block(struct adreno_device *adreno_dev, void *data)
1135: {
1136: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
1137: struct hfi_log_block *cmd = data;
1138: u32 *log_event = gmu->gmu_log->hostptr;
MATCH LINES: 1280
1268: int rc;
1269: struct pending_cmd pending_ack;
1270:
1271: seqnum = atomic_inc_return(&gmu->hfi.seqnum);
1272: *cmd = MSG_HDR_SET_SEQNUM_SIZE(*cmd, seqnum, size_bytes >> 2);
1273:
1274: add_waiter(hfi, *cmd, &pending_ack);
1275:
1276: rc = gen8_hfi_cmdq_write(adreno_dev, cmd, size_bytes);
1277: if (rc)
1278: goto done;
1279:
1280: rc = adreno_hwsched_wait_ack_completion(adreno_dev,
1281: GMU_PDEV_DEV(device), &pending_ack, gen8_hwsched_process_msgq);
1282: if (rc)
1283: goto done;
1284:
1285: rc = check_ack_failure(adreno_dev, &pending_ack);
1286:
1287: done:
1288: del_waiter(hfi, &pending_ack);
1289:
1290: return rc;
1291: }
1292:
1293: static void init_queues(struct gen8_hfi *hfi)
1294: {
1295: u32 gmuaddr = hfi->hfi_mem->gmuaddr;
1296: struct hfi_queue_table hfi_table = {
1297: .qtbl_hdr = {
1298: .version = 0,
1299: .size = sizeof(struct hfi_queue_table) >> 2,
1300: .qhdr0_offset =
1301: sizeof(struct hfi_queue_table_header) >> 2,
1302: .qhdr_size = sizeof(struct hfi_queue_header) >> 2,
1303: .num_q = HFI_QUEUE_MAX,
1304: .num_active_q = HFI_QUEUE_MAX,
MATCH LINES: 1684, 1722
1672:
1673: seqnum = atomic_inc_return(&gmu->hfi.seqnum);
1674: cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
1675: cmd.type = prop;
1676: cmd.subtype = subtype;
1677:
1678: add_waiter(hfi, cmd.hdr, &pending_ack);
1679:
1680: rc = gen8_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
1681: if (rc)
1682: goto done;
1683:
1684: rc = adreno_hwsched_wait_ack_completion(adreno_dev,
1685: gmu_pdev_dev, &pending_ack, gen8_hwsched_process_msgq);
1686:
1687: done:
1688: del_waiter(hfi, &pending_ack);
1689:
1690: if (rc || (pending_ack.results[2] == UINT_MAX))
1691: return 0;
1692:
1693: return pending_ack.results[2];
1694: }
1695:
1696: int gen8_hwsched_hfi_set_value(struct adreno_device *adreno_dev, u32 type, u32 subtype, u32 data)
1697: {
1698: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
1699: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev);
1700: struct pending_cmd pending_ack;
1701: int rc;
1702: u32 seqnum;
1703: struct hfi_set_value_cmd cmd = {
1704: .type = type,
1705: .subtype = subtype,
1706: .data = data,
1707: };
1708:
1709: rc = CMD_MSG_HDR(cmd, H2F_MSG_SET_VALUE);
1710: if (rc)
1711: return 0;
1712:
1713: seqnum = atomic_inc_return(&gmu->hfi.seqnum);
1714: cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
1715:
1716: add_waiter(hfi, cmd.hdr, &pending_ack);
1717:
1718: rc = gen8_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
1719: if (rc)
1720: goto done;
1721:
1722: rc = adreno_hwsched_wait_ack_completion(adreno_dev, GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),
1723: &pending_ack, gen8_hwsched_process_msgq);
1724:
1725: if (rc)
1726: goto done;
1727:
1728: rc = check_ack_failure(adreno_dev, &pending_ack);
1729: done:
1730: del_waiter(hfi, &pending_ack);
1731:
1732: return rc;
1733: }
1734:
1735: static int gen8_hfi_send_hw_fence_feature_ctrl(struct adreno_device *adreno_dev)
1736: {
1737: struct adreno_hwsched *hwsched = &adreno_dev->hwsched;
1738: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
1739: int ret;
1740:
1741: if (!test_bit(ADRENO_HWSCHED_HW_FENCE, &hwsched->flags))
1742: return 0;
1743:
1744: ret = gen8_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_HW_FENCE, 1, 0);
1745: if (ret && (ret == -ENOENT)) {
1746: dev_err(gmu_pdev_dev,
MATCH LINES: 1881
1869: ret = CMD_MSG_HDR(cmd, H2F_MSG_WARMBOOT_CMD);
1870: if (ret)
1871: return ret;
1872:
1873: seqnum = atomic_inc_return(&gmu->hfi.seqnum);
1874: cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
1875: add_waiter(hfi, cmd.hdr, ret_cmd);
1876:
1877: ret = gen8_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
1878: if (ret)
1879: goto err;
1880:
1881: ret = adreno_hwsched_wait_ack_completion(adreno_dev,
1882: gmu_pdev_dev, ret_cmd, gen8_hwsched_process_msgq);
1883: err:
1884: del_waiter(hfi, ret_cmd);
1885:
1886: return ret;
1887: }
1888:
1889: static void print_warmboot_gpu_error(struct device *dev, struct pending_cmd *ret_cmd)
1890: {
1891: dev_err(dev,
1892: "HFI ACK: Req=0x%8.8X, Result=0x%8.8X Error:0x%8.8X\n",
1893: ret_cmd->results[1], ret_cmd->results[2], ret_cmd->results[3]);
1894: }
1895:
1896: static int gen8_hwsched_warmboot_gpu(struct adreno_device *adreno_dev)
1897: {
1898: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
1899: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
1900: struct pending_cmd ret_cmd = {0};
1901: int ret = 0;
1902:
1903: ret = gen8_hwsched_hfi_warmboot_gpu_cmd(adreno_dev, &ret_cmd);
1904: if (ret)
1905: goto err;
MATCH LINES: 2057
2045: if (rc)
2046: return rc;
2047:
2048: seqnum = atomic_inc_return(&gmu->hfi.seqnum);
2049: cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
2050:
2051: add_waiter(hfi, cmd.hdr, &pending_ack);
2052:
2053: rc = gen8_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
2054: if (rc)
2055: goto done;
2056:
2057: rc = adreno_hwsched_wait_ack_completion(adreno_dev, GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),
2058: &pending_ack, gen8_hwsched_process_msgq);
2059:
2060: if (rc)
2061: goto done;
2062:
2063: /**
2064: * For tunables, KGSL expects GMU to embed the ACK error code in fourth dword and
2065: * the validated data to be in third dword of the ACK packet.
2066: */
2067: if (pending_ack.results[3] != 0) {
2068: dev_err(GMU_PDEV_DEV(device),
2069: "ACK error: sender id %d seqnum %d\n",
2070: MSG_HDR_GET_ID(pending_ack.sent_hdr),
2071: MSG_HDR_GET_SEQNUM(pending_ack.sent_hdr));
2072: rc = -EINVAL;
2073: goto done;
2074: }
2075:
2076: /* If the validated data is invalid data, there is no valid data set for the tunable */
2077: if (pending_ack.results[2] != GPU_DCVS_TUNING_INVALID_ACK_DATA)
2078: *ret = pending_ack.results[2];
2079: done:
2080: del_waiter(hfi, &pending_ack);
2081:
MATCH LINES: 2164
2152:
2153: seqnum = atomic_inc_return(&gmu->hfi.seqnum);
2154: cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
2155: cmd.type = HFI_VALUE_DCVS_TUNING_PARAM;
2156: cmd.subtype = subtype;
2157:
2158: add_waiter(hfi, cmd.hdr, &pending_ack);
2159:
2160: ret = gen8_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
2161: if (ret)
2162: goto done;
2163:
2164: ret = adreno_hwsched_wait_ack_completion(adreno_dev,
2165: gmu_pdev_dev, &pending_ack, gen8_hwsched_process_msgq);
2166:
2167: done:
2168: del_waiter(hfi, &pending_ack);
2169:
2170: if (!ret) {
2171: total_dwords = MSG_HDR_GET_SIZE(pending_ack.results[0]);
2172: if (total_dwords < hdr_size_in_dwords)
2173: return;
2174:
2175: num_values = total_dwords - hdr_size_in_dwords;
2176: if (num_values > GPU_TUNING_KEY_MAX)
2177: num_values = GPU_TUNING_KEY_MAX;
2178:
2179: memcpy(data, &pending_ack.results[hdr_size_in_dwords], num_values * sizeof(u32));
2180: }
2181: }
2182:
2183: static int gen8_hwsched_set_gmu_based_dcvs_votes(struct adreno_device *adreno_dev)
2184: {
2185: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2186: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
2187: struct gen8_hfi *hfi = to_gen8_hfi(adreno_dev);
2188: struct gmu_core_device *gmu_core = &device->gmu_core;
MATCH LINES: 2878
2866: return submit_lpac_raw_cmds(adreno_dev, cmds, sizeof(cmds),
2867: "LPAC CP initialization failed to idle\n");
2868: }
2869:
2870: static int hfi_f2h_main(void *arg)
2871: {
2872: struct adreno_device *adreno_dev = arg;
2873: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
2874: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev);
2875: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2876:
2877: while (!kthread_should_stop()) {
2878: wait_event_interruptible(hfi->f2h_wq, kthread_should_stop() ||
2879: /* If msgq irq is enabled and msgq has messages to process */
2880: (((hfi->irq_mask & HFI_IRQ_MSGQ_MASK) &&
2881: !is_queue_empty(adreno_dev, HFI_MSG_ID)) ||
2882: /* Trace buffer has messages to process */
2883: !gmu_core_is_trace_empty(device->gmu_core.trace.md->hostptr) ||
2884: /* Dbgq has messages to process */
2885: !is_queue_empty(adreno_dev, HFI_DBG_ID)));
2886:
2887: if (kthread_should_stop())
2888: break;
2889:
2890: gen8_hwsched_process_msgq(adreno_dev);
2891: gmu_core_process_trace_data(KGSL_DEVICE(adreno_dev),
2892: gmu_pdev_dev, &device->gmu_core.trace);
2893: gen8_hwsched_process_dbgq(adreno_dev, true);
2894: }
2895:
2896: return 0;
2897: }
2898:
2899: static void gen8_hwsched_hw_fence_timeout(struct work_struct *work)
2900: {
2901: struct gen8_hwsched_hfi *hfi = container_of(work, struct gen8_hwsched_hfi, hw_fence_ws);
2902: struct gen8_hwsched_device *gen8_hw_dev = container_of(hfi, struct gen8_hwsched_device,
MATCH LINES: 3207, 3221, 3227, 3232, 3248, 3249, 3250, 3253, 3255, 3256, 3263, 3264, 3266, 3267, 3270, 3276, 3277, 3279, 3284, 3285, 3299, 3302, 3303, 3307
3195:
3196: if (kgsl_context_is_lpac(context))
3197: return 1;
3198:
3199: return 0;
3200: }
3201:
3202: static bool _is_kgsl_hw_fence_signaled(struct kgsl_drawobj_sync_hw_fence *hw_fence)
3203: {
3204: struct kgsl_sync_fence *kfence = (struct kgsl_sync_fence *)hw_fence->fence;
3205: struct kgsl_sync_timeline *ktimeline = kfence->parent;
3206:
3207: if (dma_fence_is_signaled_locked(&kfence->fence))
3208: return true;
3209:
3210: /*
3211: * If we fail to get the context refcount that means this context is detached.
3212: * In that case, treat all hardware fences from detached context as signaled.
3213: */
3214: if ((!hw_fence->context) && (!_kgsl_context_get(ktimeline->context)))
3215: return true;
3216:
3217: return false;
3218: }
3219:
3220: static void populate_kgsl_fence(struct kgsl_drawobj_sync_hw_fence *hw_fence,
3221: struct hfi_syncobj *obj)
3222: {
3223: struct kgsl_sync_fence *kfence = (struct kgsl_sync_fence *)hw_fence->fence;
3224: struct kgsl_sync_timeline *ktimeline = kfence->parent;
3225: unsigned long flags;
3226:
3227: obj->flags |= BIT(GMU_SYNCOBJ_FLAG_KGSL_FENCE_BIT);
3228:
3229: spin_lock_irqsave(&ktimeline->lock, flags);
3230:
3231: if (_is_kgsl_hw_fence_signaled(hw_fence))
3232: obj->flags |= BIT(GMU_SYNCOBJ_FLAG_SIGNALED_BIT);
3233: else
3234: hw_fence->context = ktimeline->context;
3235:
3236: spin_unlock_irqrestore(&ktimeline->lock, flags);
3237:
3238: obj->ctxt_id = kfence->context_id;
3239: obj->seq_no = kfence->timestamp;
3240: }
3241:
3242: static int _submit_hw_fence(struct adreno_device *adreno_dev,
3243: struct kgsl_drawobj *drawobj, void *cmdbuf)
3244: {
3245: struct adreno_context *drawctxt = ADRENO_CONTEXT(drawobj->context);
3246: int i;
3247: u32 cmd_sizebytes, seqnum;
3248: struct kgsl_drawobj_sync *syncobj = SYNCOBJ(drawobj);
3249: struct hfi_submit_syncobj *cmd;
3250: struct hfi_syncobj *obj = NULL;
3251: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
3252:
3253: /* Add hfi_syncobj struct for sync object */
3254: cmd_sizebytes = sizeof(*cmd) +
3255: (sizeof(struct hfi_syncobj) *
3256: syncobj->num_hw_fence);
3257:
3258: if (WARN_ON(cmd_sizebytes > HFI_MAX_MSG_SIZE))
3259: return -EMSGSIZE;
3260:
3261: memset(cmdbuf, 0x0, cmd_sizebytes);
3262: cmd = cmdbuf;
3263: cmd->num_syncobj = syncobj->num_hw_fence;
3264: obj = (struct hfi_syncobj *)&cmd[1];
3265:
3266: for (i = 0; i < syncobj->num_hw_fence; i++) {
3267: struct dma_fence *fence = syncobj->hw_fences[i].fence;
3268:
3269: if (is_kgsl_fence(fence)) {
3270: populate_kgsl_fence(&syncobj->hw_fences[i], obj);
3271: } else {
3272: int ret = kgsl_hw_fence_add_waiter(device, fence,
3273: &obj->hash_index);
3274:
3275: if (ret) {
3276: adreno_hwsched_syncobj_kfence_put(syncobj);
3277: clear_bit(KGSL_SYNCOBJ_HW, &syncobj->flags);
3278: drawobj->timestamp = 0;
3279: clear_bit(KGSL_SYNCOBJ_HW_TS, &syncobj->flags);
3280: return ret;
3281: }
3282:
3283: if (kgsl_hw_fence_signaled(fence) ||
3284: test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
3285: obj->flags |= BIT(GMU_SYNCOBJ_FLAG_SIGNALED_BIT);
3286:
3287: obj->ctxt_id = fence->context;
3288: obj->seq_no = fence->seqno;
3289: }
3290: trace_adreno_input_hw_fence(drawobj->context->id, obj->ctxt_id,
3291: obj->seq_no, obj->flags, fence->ops->get_timeline_name ?
3292: fence->ops->get_timeline_name(fence) : "unknown");
3293:
3294: obj->header = FIELD_PREP(GENMASK(15, 0), sizeof(*obj) >> 2);
3295: obj++;
3296: }
3297:
3298: /*
3299: * Attach a timestamp to this SYNCOBJ to keep track whether GMU has deemed it signaled
3300: * or not.
3301: */
3302: if (!test_and_set_bit(KGSL_SYNCOBJ_HW_TS, &syncobj->flags))
3303: drawobj->timestamp = ++drawctxt->syncobj_timestamp;
3304:
3305: cmd->timestamp = drawobj->timestamp;
3306:
3307: cmd->hdr = CREATE_MSG_HDR(H2F_MSG_ISSUE_SYNCOBJ, HFI_MSG_CMD);
3308: seqnum = atomic_inc_return(&adreno_dev->hwsched.submission_seqnum);
3309: cmd->hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd->hdr, seqnum, cmd_sizebytes >> 2);
3310:
3311: return adreno_gmu_context_queue_write(adreno_dev, &drawctxt->gmu_context_queue,
3312: (u32 *)cmd, cmd_sizebytes, drawobj, NULL);
3313: }
3314:
3315: int gen8_hwsched_check_context_inflight_hw_fences(struct adreno_device *adreno_dev,
3316: struct adreno_context *drawctxt)
3317: {
3318: struct adreno_hw_fence_entry *entry, *tmp;
3319: int ret = 0;
3320:
3321: spin_lock(&drawctxt->lock);
3322: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_inflight_list, node) {
3323: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr;
3324:
3325: if (timestamp_cmp((u32)entry->cmd.ts, hdr->out_fence_ts) > 0) {
3326: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),
3327: "ctx:%d has unsignaled fence ts:%d retired:%d\n",
3328: drawctxt->base.id, (u32)entry->cmd.ts, hdr->out_fence_ts);
3329: ret = -EINVAL;
3330: break;
3331: }
MATCH LINES: 3486, 3505
3474: {
3475: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
3476: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence;
3477: int ret = 0;
3478: u32 seqnum;
3479:
3480: /* Device mutex is necessary to ensure only one hardware fence ack is being waited for */
3481: if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex)))
3482: return -EINVAL;
3483:
3484: spin_lock(&hwf->lock);
3485:
3486: init_completion(&gen8_hw_fence_ack.complete);
3487:
3488: entry->cmd.flags |= flags;
3489: seqnum = atomic_inc_return(&hwf->seqnum);
3490: entry->cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(entry->cmd.hdr, seqnum, sizeof(entry->cmd) >> 2);
3491:
3492: gen8_hw_fence_ack.sent_hdr = entry->cmd.hdr;
3493:
3494: /*
3495: * We don't need to increment the unack count here as we are waiting for the ack for
3496: * this fence before sending another hardware fence.
3497: */
3498: ret = gen8_hfi_cmdq_write(adreno_dev, (u32 *)&entry->cmd, sizeof(entry->cmd));
3499:
3500: spin_unlock(&hwf->lock);
3501:
3502: if (ret)
3503: goto done;
3504:
3505: ret = adreno_hwsched_wait_ack_completion(adreno_dev,
3506: GMU_PDEV_DEV(device), &gen8_hw_fence_ack,
3507: gen8_hwsched_process_msgq);
3508: if (ret)
3509: goto done;
3510:
3511: ret = _check_hw_fence_ack_failure(device, gen8_hw_fence_ack.results);
3512: if (ret)
3513: gmu_core_fault_snapshot(device, GMU_FAULT_HW_FENCE);
3514:
3515: done:
3516: memset(&gen8_hw_fence_ack, 0x0, sizeof(gen8_hw_fence_ack));
3517: return ret;
3518: }
3519:
3520: #define DRAWCTXT_SLOT_AVAILABLE(count) \
3521: ((count + 1) < (HW_FENCE_QUEUE_SIZE / sizeof(struct hfi_hw_fence_info)))
3522:
3523: /**
3524: * allocate_hw_fence_entry - Allocate an entry to keep track of a hardware fence. This is free'd
3525: * when we know GMU has sent this fence to the TxQueue
3526: */
3527: static struct adreno_hw_fence_entry *allocate_hw_fence_entry(struct adreno_device *adreno_dev,
3528: struct adreno_context *drawctxt, struct kgsl_sync_fence *kfence)
3529: {
MATCH LINES: 3558
3546: return NULL;
3547: }
3548:
3549: entry->kfence = kfence;
3550: entry->drawctxt = drawctxt;
3551:
3552: if (setup_hw_fence_info_cmd(adreno_dev, entry)) {
3553: kmem_cache_free(hwsched->hw_fence_cache, entry);
3554: kgsl_context_put_deferred(&drawctxt->base);
3555: return NULL;
3556: }
3557:
3558: dma_fence_get(&kfence->fence);
3559:
3560: drawctxt->hw_fence_count++;
3561: hwsched->hw_fence.pending_count++;
3562:
3563: INIT_LIST_HEAD(&entry->node);
3564: INIT_LIST_HEAD(&entry->reset_node);
3565: return entry;
3566: }
3567:
3568: /**
3569: * drawctxt_queue_hw_fence - Add a hardware fence to draw context's hardware fence list and make
3570: * sure the list remains sorted (with the fence with the largest timestamp at the end)
3571: */
3572: static void drawctxt_queue_hw_fence(struct adreno_device *adreno_dev,
3573: struct adreno_context *drawctxt, struct kgsl_sync_fence *kfence)
3574: {
3575: struct adreno_hw_fence_entry *entry = NULL;
3576: struct adreno_hw_fence_entry *new = allocate_hw_fence_entry(adreno_dev, drawctxt, kfence);
3577: u32 ts = kfence->timestamp;
3578:
3579: if (!new)
3580: return;
3581:
3582: /* Walk the list backwards to find the right spot for this fence */
MATCH LINES: 3623
3611: */
3612: static int _hw_fence_sleep(struct adreno_device *adreno_dev, struct adreno_context *drawctxt)
3613: {
3614: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence;
3615: int ret = 0;
3616:
3617: if (!test_bit(GEN8_HWSCHED_HW_FENCE_SLEEP_BIT, &hwf->flags))
3618: return 0;
3619:
3620: spin_unlock(&hwf->lock);
3621: spin_unlock(&drawctxt->lock);
3622:
3623: ret = wait_event_interruptible(hwf->unack_wq, _hw_fence_end_sleep(adreno_dev));
3624:
3625: spin_lock(&drawctxt->lock);
3626: spin_lock(&hwf->lock);
3627:
3628: /*
3629: * If the thread received a signal, or the context became bad in the meanwhile or the limit
3630: * is still not settled, then return error to avoid creating this hardware fence
3631: */
3632: if ((ret == -ERESTARTSYS) || kgsl_context_is_bad(&drawctxt->base) ||
3633: test_bit(GEN8_HWSCHED_HW_FENCE_MAX_BIT, &hwf->flags))
3634: return -EINVAL;
3635:
3636: /*
3637: * If fault recovery is imminent then return error code to avoid creating new hardware
3638: * fences until recovery is complete
3639: */
3640: if (test_bit(GEN8_HWSCHED_HW_FENCE_ABORT_BIT, &hwf->flags))
3641: return -EBUSY;
3642:
3643: return ret;
3644: }
3645:
3646: void gen8_hwsched_create_hw_fence(struct adreno_device *adreno_dev,
3647: struct kgsl_sync_fence *kfence)
MATCH LINES: 3830
3818: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
3819:
3820: cmdbuf = devm_kzalloc(&device->pdev->dev, HFI_MAX_MSG_SIZE,
3821: GFP_KERNEL);
3822: if (!cmdbuf)
3823: return -ENOMEM;
3824: }
3825:
3826: ret = hfi_context_register(adreno_dev, drawobj->context);
3827: if (ret)
3828: return ret;
3829:
3830: if ((drawobj->type & SYNCOBJ_TYPE) != 0)
3831: return _submit_hw_fence(adreno_dev, drawobj, cmdbuf);
3832:
3833: cmdobj = CMDOBJ(drawobj);
3834:
3835: /*
3836: * If the MARKER object is retired, it doesn't need to be dispatched to GMU. Simply trigger
3837: * any pending fences that are less than/equal to this object's timestamp.
3838: */
3839: if (test_bit(CMDOBJ_MARKER_EXPIRED, &cmdobj->priv)) {
3840: spin_lock(&drawctxt->lock);
3841: process_hw_fence_queue(adreno_dev, drawctxt, drawobj->timestamp);
3842: spin_unlock(&drawctxt->lock);
3843: return 0;
3844: }
3845:
3846: /* Add a *issue_ib struct for each IB */
3847: if (cmdobj->numibs > HWSCHED_MAX_DISPATCH_NUMIBS ||
3848: test_bit(CMDOBJ_SKIP, &cmdobj->priv))
3849: cmd_sizebytes = sizeof(*cmd);
3850: else
3851: cmd_sizebytes = sizeof(*cmd) +
3852: (sizeof(struct hfi_issue_ib) * cmdobj->numibs);
3853:
3854: if (WARN_ON(cmd_sizebytes > HFI_MAX_MSG_SIZE))
MATCH LINES: 3906
3894:
3895: cmd->hdr = CREATE_MSG_HDR(H2F_MSG_ISSUE_CMD, HFI_MSG_CMD);
3896: seqnum = atomic_inc_return(&adreno_dev->hwsched.submission_seqnum);
3897: cmd->hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd->hdr, seqnum, cmd_sizebytes >> 2);
3898:
3899: ret = adreno_gmu_context_queue_write(adreno_dev, &drawctxt->gmu_context_queue,
3900: (u32 *)cmd, cmd_sizebytes, drawobj, &time);
3901: if (ret)
3902: return ret;
3903:
3904: hdr = drawctxt->gmu_context_queue.hostptr;
3905: /* The last sync object has been retired by the GMU */
3906: if (timestamp_cmp(hdr->sync_obj_ts, drawctxt->syncobj_timestamp) >= 0)
3907: /* Send interrupt to GMU to receive the message */
3908: gmu_core_regwrite(KGSL_DEVICE(adreno_dev), GEN8_GMUCX_HOST2GMU_INTR_SET,
3909: DISPQ_IRQ_BIT(get_irq_bit(adreno_dev, drawobj->context)));
3910: else
3911: gmu_core_regwrite(KGSL_DEVICE(adreno_dev), GEN8_GMUCX_HOST2GMU_INTR_SET,
3912: DISPQ_SYNC_IRQ_BIT(get_irq_bit(adreno_dev, drawobj->context)));
3913:
3914: drawctxt->internal_timestamp = drawobj->timestamp;
3915:
3916: spin_lock(&drawctxt->lock);
3917: process_hw_fence_queue(adreno_dev, drawctxt, drawobj->timestamp);
3918: /*
3919: * We need to update the gmu_hw_fence_ready_ts while holding the drawctxt lock since we
3920: * have to check it in the hardware fence creation path, where we are not taking the
3921: * device mutex.
3922: */
3923: drawctxt->gmu_hw_fence_ready_ts = drawobj->timestamp;
3924: spin_unlock(&drawctxt->lock);
3925:
3926: return 0;
3927: }
3928:
3929: int gen8_hwsched_send_recurring_cmdobj(struct adreno_device *adreno_dev,
3930: struct kgsl_drawobj_cmd *cmdobj)
MATCH LINES: 4169
4157: }
4158:
4159: seqnum = atomic_inc_return(&gmu->hfi.seqnum);
4160: cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
4161: add_waiter(hfi, cmd.hdr, &pending_ack);
4162:
4163: ret = gen8_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
4164: if (ret) {
4165: trigger_context_unregister_fault(adreno_dev, drawctxt);
4166: goto done;
4167: }
4168:
4169: ret = adreno_hwsched_ctxt_unregister_wait_completion(adreno_dev,
4170: gmu_pdev_dev, context, &pending_ack,
4171: gen8_hwsched_process_msgq, &cmd);
4172: if (ret) {
4173: trigger_context_unregister_fault(adreno_dev, drawctxt);
4174: goto done;
4175: }
4176:
4177: ret = check_detached_context_hardware_fences(adreno_dev, drawctxt);
4178: if (!ret)
4179: ret = check_ack_failure(adreno_dev, &pending_ack);
4180:
4181: done:
4182: adreno_active_count_put(adreno_dev);
4183: del_waiter(hfi, &pending_ack);
4184:
4185: return ret;
4186: }
4187:
4188: void gen8_hwsched_context_detach(struct adreno_context *drawctxt)
4189: {
4190: struct kgsl_context *context = &drawctxt->base;
4191: struct kgsl_device *device = context->device;
4192: struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
4193: int ret = 0;
MATCH LINES: 4353
4341: /* Re-initialize the coresight registers if applicable */
4342: adreno_coresight_start(adreno_dev);
4343:
4344: adreno_perfcounter_start(adreno_dev);
4345:
4346: /* Clear FSR here in case it is set from a previous pagefault */
4347: kgsl_mmu_clear_fsr(&device->mmu);
4348:
4349: ret = gen8_hwsched_hfi_msg_reply(adreno_dev, F2H_MSG_CONTEXT_BAD, in->hdr);
4350: if (ret)
4351: goto done;
4352:
4353: /* After sending ctxt bad reply wait for GMU soft fault recovery completion */
4354: ret = gmu_core_timed_poll_check(device, GEN8_GMUCX_CM3_FW_INIT_RESULT,
4355: FIELD_PREP(GENMASK(11, 9), 6), 1000, GENMASK(11, 9));
4356: if (ret)
4357: goto done;
4358:
4359: gen8_hwsched_init_ucode_regs(adreno_dev);
4360:
4361: gen8_enable_gpu_irq(adreno_dev);
4362:
4363: ret = gen8_hwsched_boot_gpu(adreno_dev);
4364: if (ret)
4365: goto done;
4366:
4367: gen8_hwsched_raise_dispatch_interrupt(adreno_dev);
4368:
4369: if (ctx_guilty) {
4370: struct adreno_context *drawctxt = ADRENO_CONTEXT(context);
4371:
4372: ret = handle_hw_fences_after_soft_reset(adreno_dev, drawctxt);
4373: if (ret)
4374: goto done;
4375:
4376: ret = send_context_unregister_hfi(adreno_dev, context,
4377: drawctxt->internal_timestamp);
--- FILE: \adreno_gen8_perfcounter.c | HITS: 1 ---
MATCH LINES: 30
18:
19: /*
20: * Flush delta counters (both perf counters and pipe stats) present in
21: * RBBM_S and RBBM_US to perf RAM logic to get the latest data.
22: */
23: kgsl_regwrite(device, GEN8_RBBM_PERFCTR_FLUSH_HOST_CMD, BIT(0));
24: kgsl_regwrite(device, GEN8_RBBM_SLICE_PERFCTR_FLUSH_HOST_CMD, BIT(0));
25:
26: /* Ensure all writes are posted before polling status register */
27: wmb();
28:
29: /*
30: * Poll RBBM_PERFCTR_FLUSH_HOST_STATUS to wait for perfcounter flush completion.
31: * Use a busy loop as this is called with interrupts and preemption disabled.
32: */
33: for (i = 0; i < 10; i++) {
34: kgsl_regread(device, GEN8_RBBM_PERFCTR_FLUSH_HOST_STATUS, &status);
35: if (((status & PERFCOUNTER_FLUSH_DONE_MASK) == PERFCOUNTER_FLUSH_DONE_MASK))
36: return;
37:
38: udelay(10);
39: }
40:
41: /* Check status one last time */
42: kgsl_regread(device, GEN8_RBBM_PERFCTR_FLUSH_HOST_STATUS, &status);
43:
44: if ((status & PERFCOUNTER_FLUSH_DONE_MASK) != PERFCOUNTER_FLUSH_DONE_MASK)
45: dev_err_ratelimited(device->dev,
46: "Perfcounter flush timed out: status=0x%08x\n", status);
47: }
48:
49: static int gen8_counter_br_enable(struct adreno_device *adreno_dev,
50: const struct adreno_perfcount_group *group,
51: u32 counter, u32 countable)
52: {
53: struct adreno_perfcount_register *reg = &group->regs[counter];
54: int ret;
--- FILE: \adreno_gen8_preempt.c | HITS: 1 ---
MATCH LINES: 692
680: }
681: }
682:
683: static int gen8_preemption_ringbuffer_init(struct adreno_device *adreno_dev,
684: struct adreno_ringbuffer *rb)
685: {
686: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
687: u64 ctxt_record_size = adreno_dev->total_ctxt_record_sz;
688: u64 curr_gmem_size = adreno_gmem_size(adreno_dev);
689: int ret;
690:
691: /*
692: * Since RB0 always runs to completion, there is no need to
693: * save/restore GMEM data for RB0.
694: */
695: if (rb->id == 0)
696: ctxt_record_size -= curr_gmem_size;
697:
698: ret = adreno_allocate_global(device, &rb->preemption_desc,
699: ctxt_record_size, SZ_16K, 0,
700: KGSL_MEMDESC_PRIVILEGED, "preemption_desc");
701: if (ret)
702: return ret;
703:
704: if (kgsl_mmu_is_secured(&device->mmu)) {
705: ret = adreno_allocate_global(device, &rb->secure_preemption_desc,
706: ctxt_record_size, 0,
707: KGSL_MEMFLAGS_SECURE, KGSL_MEMDESC_PRIVILEGED,
708: "secure_preemption_desc");
709: if (ret)
710: return ret;
711: }
712:
713: ret = adreno_allocate_global(device, &rb->perfcounter_save_restore_desc,
714: GEN8_CP_PERFCOUNTER_SAVE_RESTORE_SIZE, 0, 0,
715: KGSL_MEMDESC_PRIVILEGED,
716: "perfcounter_save_restore_desc");
--- FILE: \adreno_gen8_snapshot.c | HITS: 1 ---
MATCH LINES: 762
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)) {
--- FILE: \adreno_hfi.h | HITS: 43 ---
MATCH LINES: 535, 536
523: H2F_MSG_REGISTER_CONTEXT = 128,
524: H2F_MSG_UNREGISTER_CONTEXT = 129,
525: H2F_MSG_ISSUE_CMD = 130,
526: H2F_MSG_ISSUE_CMD_RAW = 131,
527: H2F_MSG_TS_NOTIFY = 132,
528: F2H_MSG_TS_RETIRE = 133,
529: H2F_MSG_CONTEXT_POINTERS = 134,
530: H2F_MSG_ISSUE_LPAC_CMD_RAW = 135,
531: H2F_MSG_CONTEXT_RULE = 140, /* AKA constraint */
532: H2F_MSG_ISSUE_RECURRING_CMD = 141,
533: F2H_MSG_CONTEXT_BAD = 150,
534: H2F_MSG_HW_FENCE_INFO = 151,
535: H2F_MSG_ISSUE_SYNCOBJ = 152,
536: F2H_MSG_SYNCOBJ_QUERY = 153,
537: H2F_MSG_WARMBOOT_CMD = 154,
538: F2H_MSG_PROCESS_TRACE = 155,
539: F2H_MSG_PLATFORM_LA = 200,
540: H2F_MSG_PLATFORM_LA = 201,
541: F2H_MSG_PLATFORM_WIN = 202, /* Reserved */
542: H2F_MSG_PLATFORM_WIN = 203, /* Reserved */
543: HFI_MAX_ID,
544: };
545:
546: enum gmu_ret_type {
547: GMU_SUCCESS = 0,
548: GMU_ERROR_FATAL,
549: GMU_ERROR_MEM_FAIL,
550: GMU_ERROR_INVAL_PARAM,
551: GMU_ERROR_NULL_PTR,
552: GMU_ERROR_OUT_OF_BOUNDS,
553: GMU_ERROR_TIMEOUT,
554: GMU_ERROR_NOT_SUPPORTED,
555: GMU_ERROR_NO_ENTRY,
556: };
557:
558: /* Platform specific F2H subtype message for GMU */
559: enum gmu_f2h_msg_platform {
560: F2H_ST_MSG_SCALE_GMU,
MATCH LINES: 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 977, 978, 979, 980, 981, 982
954: #define CMDBATCH_RETIRED 1
955: #define CMDBATCH_ERROR 2
956: #define CMDBATCH_SKIP 3
957:
958: #define CMDBATCH_PROFILING BIT(4)
959: #define CMDBATCH_EOF BIT(8)
960: #define CMDBATCH_INDIRECT BIT(9)
961: #define CMDBATCH_RECURRING_START BIT(18)
962: #define CMDBATCH_RECURRING_STOP BIT(19)
963: #define CMDBATCH_NOP_SUBMISSION BIT(20)
964: #define CMDBATCH_USES_MALU BIT(21)
965:
966: /* This indicates that the SYNCOBJ is kgsl output fence */
967: #define GMU_SYNCOBJ_FLAG_KGSL_FENCE_BIT 0
968: /* This indicates that the SYNCOBJ is signaled */
969: #define GMU_SYNCOBJ_FLAG_SIGNALED_BIT 1
970: /* This indicates that the SYNCOBJ's software status is queried */
971: #define GMU_SYNCOBJ_FLAG_QUERY_SW_STATUS_BIT 2
972: /* This indicates that the SYNCOBJ's software status is signaled */
973: #define GMU_SYNCOBJ_FLAG_SW_STATUS_SIGNALED_BIT 3
974: /* This indicates that the SYNCOBJ's software status is pending */
975: #define GMU_SYNCOBJ_FLAG_SW_STATUS_PENDING_BIT 4
976:
977: #define GMU_SYNCOBJ_FLAGS \
978: { BIT(GMU_SYNCOBJ_FLAG_KGSL_FENCE_BIT), "KGSL"}, \
979: { BIT(GMU_SYNCOBJ_FLAG_SIGNALED_BIT), "SIGNALED"}, \
980: { BIT(GMU_SYNCOBJ_FLAG_QUERY_SW_STATUS_BIT), "QUERIED"}, \
981: { BIT(GMU_SYNCOBJ_FLAG_SW_STATUS_SIGNALED_BIT), "SW_SIGNALED"}, \
982: { BIT(GMU_SYNCOBJ_FLAG_SW_STATUS_PENDING_BIT), "SW_PENDING"}
983:
984: /* F2H */
985: struct hfi_ts_retire_cmd {
986: u32 hdr;
987: u32 ctxt_id;
988: u32 ts;
989: u32 type;
990: u64 submitted_to_rb;
991: u64 sop;
992: u64 eop;
993: u64 retired_on_gmu;
994: u64 active;
995: u32 version;
996: } __packed;
997:
998: /* H2F */
999: struct hfi_context_pointers_cmd {
1000: u32 hdr;
1001: u32 ctxt_id;
1002: u64 sop_addr;
1003: u64 eop_addr;
1004: u64 user_ctxt_record_addr;
1005: u32 version;
1006: u32 gmu_context_queue_addr;
MATCH LINES: 1064, 1073, 1089, 1094, 1097, 1098, 1099, 1101, 1102, 1103
1052: struct hfi_submit_cmd {
1053: u32 hdr;
1054: u32 ctxt_id;
1055: u32 flags;
1056: u32 ts;
1057: u32 profile_gpuaddr_lo;
1058: u32 profile_gpuaddr_hi;
1059: u32 numibs;
1060: u32 big_ib_gmu_va;
1061: } __packed;
1062:
1063: /* This structure is only used for hw fence feature on gen7 hwsched targets */
1064: struct hfi_syncobj_legacy {
1065: /** @ctxt_id: dma fence context id for external fence and gmu context id for kgsl fence */
1066: u64 ctxt_id;
1067: /** @seq_no: Sequence number (or timestamp) of this fence */
1068: u64 seq_no;
1069: /** @flags: Flags for this fence */
1070: u64 flags;
1071: } __packed;
1072:
1073: struct hfi_syncobj {
1074: /**
1075: * @header: bits[0:15]: size of this packet in dwords, bits[15:23]: version,
1076: * bits[24:31] unused
1077: */
1078: u32 header;
1079: /** @hash_index: hash index of external input fence */
1080: u32 hash_index;
1081: /** @ctxt_id: dma fence context id for external fence and gmu context id for kgsl fence */
1082: u64 ctxt_id;
1083: /** @seq_no: Sequence number (or timestamp) of this fence */
1084: u64 seq_no;
1085: /** @flags: Flags for this fence */
1086: u64 flags;
1087: } __packed;
1088:
1089: struct hfi_submit_syncobj {
1090: u32 hdr;
1091: u32 version;
1092: u32 flags;
1093: u32 timestamp;
1094: u32 num_syncobj;
1095: } __packed;
1096:
1097: #define HFI_SYNCOBJ_LEGACY_HW_FENCE_MAX \
1098: ((HFI_MAX_MSG_SIZE - sizeof(struct hfi_submit_syncobj)) \
1099: / sizeof(struct hfi_syncobj_legacy))
1100:
1101: #define HFI_SYNCOBJ_HW_FENCE_MAX \
1102: ((HFI_MAX_MSG_SIZE - sizeof(struct hfi_submit_syncobj)) \
1103: / sizeof(struct hfi_syncobj))
1104:
1105: struct hfi_log_block {
1106: u32 hdr;
1107: u32 version;
1108: u32 start_index;
1109: u32 stop_index;
1110: } __packed;
1111:
1112: enum hfi_warmboot_cmd_type {
1113: HFI_WARMBOOT_SET_SCRATCH = 0,
1114: HFI_WARMBOOT_EXEC_SCRATCH,
1115: HFI_WARMBOOT_QUERY_SCRATCH,
1116: };
1117:
1118: struct hfi_warmboot_scratch_cmd {
1119: /** @hdr: Header for the scratch command packet */
1120: u32 hdr;
1121: /** @version: Version of the scratch command packet */
1122: u32 version;
1123: /** @flags: Set, Execute or Query scratch flag */
1124: u32 flags;
1125: /** @scratch_addr: Address of the scratch */
1126: u32 scratch_addr;
1127: /** @scratch_size: Size of the scratch in bytes*/
MATCH LINES: 1158, 1167, 1168, 1169, 1171, 1181, 1193, 1194
1146: u64 ts;
1147: /** @flags: Flags on how to handle this hfi packet */
1148: u64 flags;
1149: /** @hash_index: Index of the hw fence in hw fence table */
1150: u64 hash_index;
1151: } __packed;
1152:
1153: /* The software fence corresponding to the queried hardware fence has not signaled */
1154: #define ADRENO_HW_FENCE_SW_STATUS_PENDING BIT(0)
1155: /* The software fence corresponding to the queried hardware fence has signaled */
1156: #define ADRENO_HW_FENCE_SW_STATUS_SIGNALED BIT(1)
1157:
1158: struct hfi_syncobj_query {
1159: /**
1160: * @query_bitmask: Bitmask representing the sync object descriptors to be queried. For
1161: * example, to query the second sync object descriptor(index=1) in a sync object,
1162: * bit(1) should be set in this bitmask.
1163: */
1164: u32 query_bitmask;
1165: } __packed;
1166:
1167: #define MAX_SYNCOBJ_QUERY_BITS 128
1168: #define BITS_PER_SYNCOBJ_QUERY 32
1169: #define MAX_SYNCOBJ_QUERY_DWORDS (MAX_SYNCOBJ_QUERY_BITS / BITS_PER_SYNCOBJ_QUERY)
1170:
1171: struct hfi_syncobj_query_cmd {
1172: /** @hdr: Header for the fence info packet */
1173: u32 hdr;
1174: /** @version: Version of the fence info packet */
1175: u32 version;
1176: /** @gmu_ctxt_id: GMU Context id to which this SYNC object belongs */
1177: u32 gmu_ctxt_id;
1178: /** @sync_obj_ts: Timestamp of this SYNC object */
1179: u32 sync_obj_ts;
1180: /** @queries: Array of query bitmasks */
1181: struct hfi_syncobj_query queries[MAX_SYNCOBJ_QUERY_DWORDS];
1182: } __packed;
1183:
1184: /**
1185: * struct pending_cmd - data structure to track outstanding HFI
1186: * command messages
1187: */
1188: struct pending_cmd {
1189: /** @sent_hdr: Header of the un-ack'd hfi packet */
1190: u32 sent_hdr;
1191: /** @results: Array to store the ack packet */
1192: u32 results[MAX_RCVD_SIZE];
1193: /** @complete: Completion to signal hfi ack has been received */
1194: struct completion complete;
1195: /** @node: to add it to the list of hfi packets waiting for ack */
1196: struct list_head node;
1197: };
1198:
1199: struct hfi_msg_platform {
1200: /** @hdr: Header for the platform specific msg */
1201: u32 hdr;
1202: /** @sub_type: Sub type for the platform msg */
1203: u32 sub_type;
1204: } __packed;
1205:
1206: struct hfi_scale_gmu_cmd {
1207: /** @header: Header for the scale gmu packet */
1208: struct hfi_msg_platform header;
1209: /** @gmu_pwrlevel: Gmu index of gmu power level to scale to */
1210: u32 gmu_pwrlevel;
1211: } __packed;
1212:
1213: /* Platform specific H2F subtype message for GMU */
1214: enum h2f_platform_action {
1215: H2F_ST_MSG_PROFILE_REGISTER,
1216: };
1217:
1218: /* H2F */
MATCH LINES: 1385
1373: /* Fault due to software fuse violation interrupt */
1374: #define GMU_GPU_SW_FUSE_VIOLATION 621
1375: /* AQE related error codes */
1376: #define GMU_GPU_AQE0_OPCODE_ERROR 622
1377: #define GMU_GPU_AQE0_UCODE_ERROR 623
1378: #define GMU_GPU_AQE0_HW_FAULT_ERROR 624
1379: #define GMU_GPU_AQE0_ILLEGAL_INST_ERROR 625
1380: #define GMU_GPU_AQE1_OPCODE_ERROR 626
1381: #define GMU_GPU_AQE1_UCODE_ERROR 627
1382: #define GMU_GPU_AQE1_HW_FAULT_ERROR 628
1383: #define GMU_GPU_AQE1_ILLEGAL_INST_ERROR 629
1384: /* GMU encountered a sync object which is signaled via software but not via hardware */
1385: #define GMU_SYNCOBJ_TIMEOUT_ERROR 630
1386: #define GMU_CP_DDEBR_HW_FAULT_ERROR 631
1387: #define GMU_CP_DDEBR_OPCODE_ERROR 632
1388: #define GMU_CP_DDEBR_UCODE_ERROR 633
1389: #define GMU_CP_DDEBR_PROTECTED_ERROR 634
1390: #define GMU_CP_DDEBR_ILLEGAL_INST_ERROR 635
1391: #define GMU_CP_DDEBV_HW_FAULT_ERROR 636
1392: #define GMU_CP_DDEBV_OPCODE_ERROR 637
1393: #define GMU_CP_DDEBV_UCODE_ERROR 638
1394: #define GMU_CP_DDEBV_PROTECTED_ERROR 639
1395: #define GMU_CP_DDEBV_ILLEGAL_INST_ERROR 640
1396: #define GMU_CP_BR_SW_FAULT_ERROR 641
1397: #define GMU_CP_BV_SW_FAULT_ERROR 642
1398: #define GMU_CP_LPAC_SW_FAULT_ERROR 643
1399: #define GMU_CP_AQE0_SW_FAULT_ERROR 644
1400: #define GMU_CP_AQE1_SW_FAULT_ERROR 645
1401: #define GMU_CP_AQE0_PROTECTED_ERROR 646
1402: #define GMU_CP_AQE1_PROTECTED_ERROR 647
1403: #define GMU_CP_DDEBR_SW_FAULT_ERROR 648
1404: #define GMU_CP_DDEBV_SW_FAULT_ERROR 649
1405: /* Non fatal GPU error codes */
1406: #define GMU_CP_AHB_ERROR 650
1407: #define GMU_ATB_ASYNC_FIFO_OVERFLOW 651
1408: #define GMU_RBBM_ATB_BUF_OVERFLOW 652
1409: #define GMU_UCHE_OOB_ACCESS 653
MATCH LINES: 1557, 1563, 1569, 1574, 1582, 1589
1545: * which is specified in terms of power of two (2^n). For example, sz_align = 20 means
1546: * (1 << 20) = 1MB alignment. The minimum alignment (in bytes) is SZ_4K i.e. anything less
1547: * than (or equal to) a sz_align value of ilog2(SZ_4K) will default to SZ_4K alignment.
1548: */
1549: static inline u32 hfi_get_gmu_sz_alignment(u32 align)
1550: {
1551: u32 sz_align = FIELD_GET(GENMASK(15, 8), align);
1552:
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(
1590: struct adreno_device *adreno_dev,
1591: struct device *dev, struct kgsl_context *context, struct pending_cmd *ack,
1592: void (*process_msgq)(struct adreno_device *adreno_dev),
1593: struct hfi_unregister_ctxt_cmd *cmd);
1594:
1595: /**
1596: * hfi_get_minidump_string - Get the va-minidump string from entry
1597: * mem_kind: mem_kind type
1598: * hfi_minidump_str: Pointer to the output string
1599: * size: Max size of the hfi_minidump_str
1600: * rb_id: Pointer to the rb_id count
1601: *
1602: * This function return 0 on valid mem_kind and copies the VA-MINIDUMP string to
1603: * hfi_minidump_str else return error
1604: */
1605: static inline int hfi_get_minidump_string(u32 mem_kind, char *hfi_minidump_str,
1606: size_t size, u32 *rb_id)
1607: {
1608: /* Extend this if the VA mindump need more hfi alloc entries */
1609: switch (mem_kind) {
1610: case HFI_MEMKIND_RB:
1611: snprintf(hfi_minidump_str, size, KGSL_GMU_RB_ENTRY"_%d", (*rb_id)++);
1612: break;
1613: case HFI_MEMKIND_SCRATCH:
--- FILE: \adreno_hwsched.c | HITS: 69 ---
MATCH LINES: 497, 498, 502, 504, 509, 513, 520, 521, 522
485: spin_unlock(&drawctxt->lock);
486:
487: return ret;
488: }
489:
490: static void _pop_drawobj(struct adreno_context *drawctxt)
491: {
492: drawctxt->drawqueue_head = DRAWQUEUE_NEXT(drawctxt->drawqueue_head,
493: ADRENO_CONTEXT_DRAWQUEUE_SIZE);
494: drawctxt->queued--;
495: }
496:
497: static int _retire_syncobj(struct adreno_device *adreno_dev,
498: struct kgsl_drawobj_sync *syncobj, struct adreno_context *drawctxt)
499: {
500: struct adreno_hwsched *hwsched = &adreno_dev->hwsched;
501:
502: if (!kgsl_drawobj_events_pending(syncobj)) {
503: _pop_drawobj(drawctxt);
504: kgsl_drawobj_destroy(DRAWOBJ(syncobj));
505: return 0;
506: }
507:
508: /*
509: * If hardware fences are enabled, and this SYNCOBJ is backed by hardware fences,
510: * send it to the GMU
511: */
512: if (test_bit(ADRENO_HWSCHED_HW_FENCE, &hwsched->flags) &&
513: test_bit(KGSL_SYNCOBJ_HW, &syncobj->flags))
514: return 1;
515:
516: /*
517: * If we got here, there are pending events for sync object.
518: * Start the canary timer if it hasnt been started already.
519: */
520: if (!syncobj->timeout_jiffies) {
521: syncobj->timeout_jiffies = jiffies + msecs_to_jiffies(5000);
522: mod_timer(&syncobj->timer, syncobj->timeout_jiffies);
523: }
524:
525: return -EAGAIN;
526: }
527:
528: static bool _marker_expired(struct kgsl_drawobj_cmd *markerobj)
529: {
530: struct kgsl_drawobj *drawobj = DRAWOBJ(markerobj);
531:
532: return (drawobj->flags & KGSL_DRAWOBJ_MARKER) &&
533: kgsl_check_timestamp(drawobj->device, drawobj->context,
534: markerobj->marker_timestamp);
535: }
536:
537: /* Only retire the timestamp. The drawobj will be destroyed later */
538: static void _retire_timestamp_only(struct kgsl_drawobj *drawobj)
539: {
540: struct kgsl_context *context = drawobj->context;
541: struct kgsl_device *device = context->device;
542:
543: /*
544: * Write the start and end timestamp to the memstore to keep the
545: * accounting sane
546: */
MATCH LINES: 647, 681, 682
635: kref_get(&drawobj->refcount);
636:
637: kgsl_sharedmem_bind_ranges(bindobj->bind);
638: }
639:
640: return -EAGAIN;
641: }
642:
643: /*
644: * Retires all expired marker and sync objs from the context
645: * queue and returns one of the below
646: * a) next drawobj that needs to be sent to ringbuffer
647: * b) -EAGAIN for syncobj with syncpoints pending.
648: * c) -EAGAIN for markerobj whose marker timestamp has not expired yet.
649: * c) NULL for no commands remaining in drawqueue.
650: */
651: static struct kgsl_drawobj *_process_drawqueue_get_next_drawobj(
652: struct adreno_device *adreno_dev, struct adreno_context *drawctxt)
653: {
654: struct kgsl_drawobj *drawobj;
655: unsigned int i = drawctxt->drawqueue_head;
656: struct kgsl_drawobj_cmd *cmdobj;
657: struct adreno_hwsched *hwsched = &adreno_dev->hwsched;
658: int ret = 0;
659:
660: if (drawctxt->drawqueue_head == drawctxt->drawqueue_tail)
661: return NULL;
662:
663: for (i = drawctxt->drawqueue_head; i != drawctxt->drawqueue_tail;
664: i = DRAWQUEUE_NEXT(i, ADRENO_CONTEXT_DRAWQUEUE_SIZE)) {
665:
666: drawobj = drawctxt->drawqueue[i];
667:
668: if (!drawobj)
669: return NULL;
670:
671: switch (drawobj->type) {
672: case CMDOBJ_TYPE:
673: cmdobj = CMDOBJ(drawobj);
674:
675: /* We only support one big IB inflight */
676: if ((cmdobj->numibs > HWSCHED_MAX_DISPATCH_NUMIBS) &&
677: hwsched->big_cmdobj)
678: return ERR_PTR(-ENOSPC);
679:
680: return drawobj;
681: case SYNCOBJ_TYPE:
682: ret = _retire_syncobj(adreno_dev, SYNCOBJ(drawobj), drawctxt);
683: if (ret == 1)
684: return drawobj;
685: break;
686: case MARKEROBJ_TYPE:
687: ret = _retire_markerobj(adreno_dev, CMDOBJ(drawobj), drawctxt);
688: /* Special case where marker needs to be sent to GPU */
689: if (ret == 1)
690: return drawobj;
691: break;
692: case BINDOBJ_TYPE:
693: ret = drawqueue_retire_bindobj(drawobj, drawctxt);
694: break;
695: case TIMELINEOBJ_TYPE:
696: ret = _retire_timelineobj(drawobj, drawctxt);
697: break;
698: default:
699: ret = -EINVAL;
700: break;
701: }
702:
703: if (ret)
704: return ERR_PTR(ret);
705: }
706:
MATCH LINES: 890
878: */
879: if (hwsched->inflight == 1) {
880: adreno_active_count_put(adreno_dev);
881: clear_bit(ADRENO_HWSCHED_POWER, &hwsched->flags);
882: }
883:
884: hwsched->inflight--;
885: goto done;
886: }
887:
888: if ((hwsched->inflight == 1) &&
889: !test_and_set_bit(ADRENO_HWSCHED_ACTIVE, &hwsched->flags))
890: reinit_completion(&hwsched->idle_gate);
891:
892: if (is_cmdobj(drawobj)) {
893: struct kgsl_drawobj_cmd *cmdobj = CMDOBJ(drawobj);
894:
895: /* If this MARKER object is already retired, we can destroy it here */
896: if ((test_bit(CMDOBJ_MARKER_EXPIRED, &cmdobj->priv))) {
897: kmem_cache_free(obj_cache, obj);
898: kgsl_drawobj_destroy(drawobj);
899: goto done;
900: }
901:
902: if (cmdobj->numibs > HWSCHED_MAX_DISPATCH_NUMIBS) {
903: hwsched->big_cmdobj = cmdobj;
904: kref_get(&drawobj->refcount);
905: }
906: }
907:
908: obj->drawobj = drawobj;
909: list_add_tail(&obj->node, &hwsched->cmd_list);
910:
911: done:
912: if (!is_current_rt)
913: sched_set_normal(current, nice);
914: kgsl_mutex_unlock(&device->mutex);
MATCH LINES: 1203
1191: int ret = 0;
1192:
1193: /*
1194: * There is always a possibility that dispatcher may end up pushing
1195: * the last popped draw object back to the context drawqueue. Hence,
1196: * we can only queue up to _context_drawqueue_size - 1 here to make
1197: * sure we never let drawqueue->queued exceed _context_drawqueue_size.
1198: */
1199: if ((drawctxt->queued + count) > (_context_drawqueue_size - 1)) {
1200: trace_adreno_drawctxt_sleep(drawctxt);
1201: spin_unlock(&drawctxt->lock);
1202:
1203: ret = wait_event_interruptible_timeout(drawctxt->wq,
1204: _check_context_queue(drawctxt, count),
1205: msecs_to_jiffies(_context_queue_wait));
1206:
1207: spin_lock(&drawctxt->lock);
1208: trace_adreno_drawctxt_wake(drawctxt);
1209:
1210: /*
1211: * Account for the possibility that the context got invalidated
1212: * while we were sleeping
1213: */
1214: if (ret > 0)
1215: ret = kgsl_check_context_state(&drawctxt->base);
1216: else if (ret == 0)
1217: ret = -ETIMEDOUT;
1218: }
1219:
1220: return ret;
1221: }
1222:
1223: static unsigned int _check_context_state_to_queue_cmds(
1224: struct adreno_context *drawctxt, u32 count)
1225: {
1226: int ret = kgsl_check_context_state(&drawctxt->base);
1227:
MATCH LINES: 1288, 1289, 1291
1276: }
1277:
1278: j = DRAWQUEUE_NEXT(j, ADRENO_CONTEXT_DRAWQUEUE_SIZE);
1279: }
1280:
1281: drawctxt->queued_timestamp = *timestamp;
1282:
1283: _queue_drawobj(drawctxt, drawobj);
1284:
1285: return 0;
1286: }
1287:
1288: static void _queue_syncobj(struct adreno_context *drawctxt,
1289: struct kgsl_drawobj_sync *syncobj, uint32_t *timestamp)
1290: {
1291: struct kgsl_drawobj *drawobj = DRAWOBJ(syncobj);
1292:
1293: *timestamp = 0;
1294: drawobj->timestamp = 0;
1295:
1296: _queue_drawobj(drawctxt, drawobj);
1297: }
1298:
1299: static int _queue_markerobj(struct adreno_device *adreno_dev,
1300: struct adreno_context *drawctxt, struct kgsl_drawobj_cmd *markerobj,
1301: u32 *timestamp, u32 user_ts)
1302: {
1303: struct kgsl_drawobj *drawobj = DRAWOBJ(markerobj);
1304: int ret;
1305:
1306: ret = get_timestamp(drawctxt, drawobj, timestamp, user_ts);
1307: if (ret)
1308: return ret;
1309:
1310: /*
1311: * See if we can fastpath this thing - if nothing is queued
1312: * and nothing is inflight retire without bothering the GPU
1313: */
1314: if (!drawctxt->queued && kgsl_check_timestamp(drawobj->device,
1315: drawobj->context, drawctxt->queued_timestamp)) {
MATCH LINES: 1408, 1429, 1431
1396: return -EINVAL;
1397: }
1398:
1399: ret = kgsl_check_context_state(&drawctxt->base);
1400: if (ret)
1401: return ret;
1402:
1403: ret = adreno_verify_cmdobj(dev_priv, context, drawobj, count);
1404: if (ret)
1405: return ret;
1406:
1407: /* wait for the suspend gate */
1408: wait_for_completion(&device->halt_gate);
1409:
1410: job = kmem_cache_alloc(jobs_cache, GFP_KERNEL);
1411: if (!job)
1412: return -ENOMEM;
1413:
1414: job->drawctxt = drawctxt;
1415:
1416: spin_lock(&drawctxt->lock);
1417:
1418: ret = _check_context_state_to_queue_cmds(drawctxt, count);
1419: if (ret) {
1420: spin_unlock(&drawctxt->lock);
1421: kmem_cache_free(jobs_cache, job);
1422: return ret;
1423: }
1424:
1425: user_ts = *timestamp;
1426:
1427: /*
1428: * If there is only one drawobj in the array and it is of
1429: * type SYNCOBJ_TYPE, skip comparing user_ts as it can be 0
1430: */
1431: if (!(count == 1 && drawobj[0]->type == SYNCOBJ_TYPE) &&
1432: (drawctxt->base.flags & KGSL_CONTEXT_USER_GENERATED_TS)) {
1433: /*
1434: * User specified timestamps need to be greater than the last
1435: * issued timestamp in the context
1436: */
1437: if (timestamp_cmp(drawctxt->timestamp, user_ts) >= 0) {
1438: spin_unlock(&drawctxt->lock);
1439: kmem_cache_free(jobs_cache, job);
1440: return -ERANGE;
1441: }
1442: }
1443:
1444: for (i = 0; i < count; i++) {
1445:
1446: switch (drawobj[i]->type) {
1447: case MARKEROBJ_TYPE:
1448: ret = _queue_markerobj(adreno_dev, drawctxt,
1449: CMDOBJ(drawobj[i]),
1450: timestamp, user_ts);
1451: if (ret == 1) {
1452: spin_unlock(&drawctxt->lock);
1453: kmem_cache_free(jobs_cache, job);
1454: return 0;
1455: } else if (ret) {
MATCH LINES: 1471, 1472
1459: }
1460: break;
1461: case CMDOBJ_TYPE:
1462: ret = _queue_cmdobj(adreno_dev, drawctxt,
1463: CMDOBJ(drawobj[i]),
1464: timestamp, user_ts);
1465: if (ret) {
1466: spin_unlock(&drawctxt->lock);
1467: kmem_cache_free(jobs_cache, job);
1468: return ret;
1469: }
1470: break;
1471: case SYNCOBJ_TYPE:
1472: _queue_syncobj(drawctxt, SYNCOBJ(drawobj[i]),
1473: timestamp);
1474: break;
1475: case BINDOBJ_TYPE:
1476: ret = _queue_bindobj(drawctxt, drawobj[i], timestamp,
1477: user_ts);
1478: if (ret) {
1479: spin_unlock(&drawctxt->lock);
1480: kmem_cache_free(jobs_cache, job);
1481: return ret;
1482: }
1483: break;
1484: case TIMELINEOBJ_TYPE:
1485: _queue_timelineobj(drawctxt, drawobj[i]);
1486: break;
1487: default:
1488: spin_unlock(&drawctxt->lock);
1489: kmem_cache_free(jobs_cache, job);
1490: return -EINVAL;
1491: }
1492:
1493: }
1494:
1495: adreno_track_context(adreno_dev, NULL, drawctxt);
1496:
MATCH LINES: 1541, 1545, 1546, 1547, 1551, 1555, 1556, 1567, 1568, 1572, 1578, 1579, 1583, 1601, 1602, 1603
1529:
1530: trace_adreno_cmdbatch_done(drawobj->context->id,
1531: drawobj->context->priority, drawobj->timestamp);
1532:
1533: if (hwsched->big_cmdobj == cmdobj) {
1534: hwsched->big_cmdobj = NULL;
1535: kgsl_drawobj_put(drawobj);
1536: }
1537:
1538: kgsl_drawobj_destroy(drawobj);
1539: }
1540:
1541: void adreno_hwsched_syncobj_kfence_put(struct kgsl_drawobj_sync *syncobj)
1542: {
1543: int i;
1544:
1545: for (i = 0; i < syncobj->num_hw_fence; i++) {
1546: kgsl_context_put(syncobj->hw_fences[i].context);
1547: syncobj->hw_fences[i].context = NULL;
1548: }
1549: }
1550:
1551: static void adreno_hwsched_hw_syncobj_cancel_callbacks(struct kgsl_drawobj_sync *syncobj)
1552: {
1553: u32 i;
1554:
1555: for (i = 0; i < syncobj->numsyncs; i++) {
1556: struct kgsl_drawobj_sync_event *event = &syncobj->synclist[i];
1557:
1558: if (event->type != KGSL_CMD_SYNCPOINT_TYPE_FENCE)
1559: continue;
1560:
1561: kgsl_sync_fence_async_cancel(event->handle);
1562:
1563: /*
1564: * Now that we know the callback is removed, we can safely put back the
1565: * refcount if it isn't already put back
1566: */
1567: if (test_and_clear_bit(i, &syncobj->pending))
1568: kgsl_drawobj_put(DRAWOBJ(syncobj));
1569: }
1570: }
1571:
1572: static void adreno_hwsched_hw_syncobj_destroy(struct kgsl_drawobj *drawobj)
1573: {
1574: /*
1575: * It is still possible that the dma fence callbacks may not yet have
1576: * been invoked. Make sure we cancel the callbacks before we destroy the sync object
1577: */
1578: adreno_hwsched_hw_syncobj_cancel_callbacks(SYNCOBJ(drawobj));
1579: adreno_hwsched_syncobj_kfence_put(SYNCOBJ(drawobj));
1580: kgsl_drawobj_destroy(drawobj);
1581: }
1582:
1583: static bool adreno_hwsched_hw_syncobj_retired(struct kgsl_drawobj *drawobj)
1584: {
1585: struct adreno_context *drawctxt = ADRENO_CONTEXT(drawobj->context);
1586: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr;
1587:
1588: if (timestamp_cmp(drawobj->timestamp, hdr->sync_obj_ts) > 0)
1589: return false;
1590:
1591: return true;
1592: }
1593:
1594: static bool drawobj_retired(struct adreno_device *adreno_dev,
1595: struct kgsl_drawobj *drawobj)
1596: {
1597: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1598: struct kgsl_drawobj_cmd *cmdobj;
1599: struct adreno_hwsched *hwsched = &adreno_dev->hwsched;
1600:
1601: if ((drawobj->type & SYNCOBJ_TYPE) != 0) {
1602: if (adreno_hwsched_hw_syncobj_retired(drawobj)) {
1603: adreno_hwsched_hw_syncobj_destroy(drawobj);
1604: return true;
1605: }
1606:
1607: return false;
1608: }
1609:
1610: cmdobj = CMDOBJ(drawobj);
1611:
1612: if (!kgsl_check_timestamp(device, drawobj->context,
1613: drawobj->timestamp))
1614: return false;
1615:
1616: adreno_hwsched_retire_cmdobj(hwsched, cmdobj);
1617: return true;
1618: }
1619:
1620: static void retire_drawobj_list(struct adreno_device *adreno_dev)
1621: {
1622: struct adreno_hwsched *hwsched = &adreno_dev->hwsched;
1623: struct cmd_list_obj *obj, *tmp;
1624:
1625: list_for_each_entry_safe(obj, tmp, &hwsched->cmd_list, node) {
1626: struct kgsl_drawobj *drawobj = obj->drawobj;
1627:
MATCH LINES: 1820, 1822, 1823
1808: KGSL_MEMSTORE_OFFSET(drawobj->context->id, eoptimestamp),
1809: drawobj->timestamp);
1810: }
1811:
1812: /* Return true if drawobj needs to replayed, false otherwise */
1813: bool adreno_hwsched_drawobj_replay(struct adreno_device *adreno_dev,
1814: struct kgsl_drawobj *drawobj)
1815: {
1816: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1817: struct kgsl_drawobj_cmd *cmdobj;
1818: struct adreno_hwsched *hwsched = &adreno_dev->hwsched;
1819:
1820: if ((drawobj->type & SYNCOBJ_TYPE) != 0) {
1821: if (kgsl_context_is_bad(drawobj->context) ||
1822: adreno_hwsched_hw_syncobj_retired(drawobj)) {
1823: adreno_hwsched_hw_syncobj_destroy(drawobj);
1824: return false;
1825: }
1826:
1827: return true;
1828: }
1829:
1830: cmdobj = CMDOBJ(drawobj);
1831:
1832: if (kgsl_check_timestamp(device, drawobj->context,
1833: drawobj->timestamp) || kgsl_context_is_bad(drawobj->context)) {
1834: adreno_hwsched_retire_cmdobj(hwsched, cmdobj);
1835: return false;
1836: }
1837:
1838: return true;
1839: }
1840:
1841: void adreno_hwsched_replay(struct adreno_device *adreno_dev)
1842: {
1843: struct adreno_hwsched *hwsched = &adreno_dev->hwsched;
1844: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
1845: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
1846: struct cmd_list_obj *obj, *tmp;
1847: u32 retired = 0;
MATCH LINES: 2101, 2104, 2107, 2108, 2110, 2122, 2131, 2134, 2151, 2152
2089: context->fault_count++;
2090:
2091: if (context->fault_count > _fault_throttle_burst) {
2092: pr_context(device, context,
2093: "gpu fault threshold exceeded %d faults in %d msecs\n",
2094: _fault_throttle_burst, _fault_throttle_time);
2095: return true;
2096: }
2097:
2098: return false;
2099: }
2100:
2101: static void _print_syncobj(struct adreno_device *adreno_dev, struct kgsl_drawobj *drawobj)
2102: {
2103: int i;
2104: struct kgsl_drawobj_sync *syncobj = SYNCOBJ(drawobj);
2105: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
2106:
2107: for (i = 0; i < syncobj->num_hw_fence; i++) {
2108: struct dma_fence *fence = syncobj->hw_fences[i].fence;
2109: bool kgsl = is_kgsl_fence(fence);
2110: bool signaled = test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags);
2111: char value[32] = "unknown";
2112:
2113: kgsl_fence_timeline_value_str(fence, value, sizeof(value));
2114:
2115: dev_err(device->dev,
2116: "dma fence[%d] signaled:%d kgsl:%d ctx:%llu seqno:%llu value:%s\n",
2117: i, signaled, kgsl, fence->context, fence->seqno, value);
2118: }
2119:
2120: }
2121:
2122: static void print_fault_syncobj(struct adreno_device *adreno_dev,
2123: u32 ctxt_id, u32 ts)
2124: {
2125: struct adreno_hwsched *hwsched = &adreno_dev->hwsched;
2126: struct cmd_list_obj *obj;
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;
MATCH LINES: 2237, 2238
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);
MATCH LINES: 2381
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:
MATCH LINES: 2552
2540: INIT_LIST_HEAD(&hwsched->cmd_list);
2541:
2542: for (i = 0; i < ARRAY_SIZE(hwsched->jobs); i++) {
2543: init_llist_head(&hwsched->jobs[i]);
2544: init_llist_head(&hwsched->requeue[i]);
2545: }
2546:
2547: sched_set_fifo(adreno_dev->scheduler_worker->task);
2548:
2549: WARN_ON(sysfs_create_files(&device->dev->kobj, _hwsched_attr_list));
2550: adreno_set_dispatch_ops(adreno_dev, &hwsched_ops);
2551: hwsched->hwsched_ops = target_hwsched_ops;
2552: init_completion(&hwsched->idle_gate);
2553: complete_all(&hwsched->idle_gate);
2554:
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: */
MATCH LINES: 2707
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: }
MATCH LINES: 2809, 2821, 2824, 2844, 2855, 2859, 2877, 2891
2797: dev_err(device->dev, "Failed to setup HW fences memdesc: %d\n",
2798: ret);
2799: kgsl_hw_fence_close(device);
2800: memset(&hwsched->hw_fence.md, 0x0, sizeof(hwsched->hw_fence.md));
2801: return;
2802: }
2803:
2804: hwsched->hw_fence_cache = KMEM_CACHE(adreno_hw_fence_entry, 0);
2805:
2806: set_bit(ADRENO_HWSCHED_HW_FENCE, &hwsched->flags);
2807: }
2808:
2809: int adreno_hwsched_wait_ack_completion(struct adreno_device *adreno_dev,
2810: struct device *dev, struct pending_cmd *ack,
2811: void (*process_msgq)(struct adreno_device *adreno_dev))
2812: {
2813: int rc;
2814: /* Only allow a single log in a second */
2815: static DEFINE_RATELIMIT_STATE(_rs, HZ, 1);
2816: static u32 unprocessed, processed;
2817: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
2818: u64 start, end;
2819:
2820: start = gpudev->read_alwayson(adreno_dev);
2821: rc = wait_for_completion_timeout(&ack->complete,
2822: msecs_to_jiffies(HFI_RSP_TIMEOUT));
2823: /*
2824: * A non-zero return value means the completion is complete, whereas zero indicates
2825: * timeout
2826: */
2827: if (rc) {
2828: /*
2829: * If an ack goes unprocessed, keep track of processed and unprocessed acks
2830: * because we may not log each unprocessed ack due to ratelimiting
2831: */
2832: if (unprocessed)
2833: processed++;
2834: return 0;
2835: }
2836:
2837: /*
2838: * It is possible the ack came, but due to HLOS latencies in processing hfi interrupt
2839: * and/or the f2h daemon, the ack isn't processed yet. Hence, process the msgq one last
2840: * time.
2841: */
2842: process_msgq(adreno_dev);
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);
2880: if (ret)
2881: return 0;
2882:
2883: /*
2884: * It is possible the ack came, but due to HLOS latencies in processing hfi interrupt
2885: * and/or the f2h daemon, the ack isn't processed yet. Hence, process the msgq one last
2886: * time.
2887: */
2888: process_msgq(adreno_dev);
2889: end = gpudev->read_alwayson(adreno_dev);
2890:
2891: if (completion_done(&ack->complete)) {
2892: snprintf(prefix, sizeof(prefix),
2893: "Ack unprocessed for %scontext unregister", fast ? "fast " : "");
2894: dev_err_ratelimited(dev,
2895: "%s type: %s rb: %d seq: %d ctx: %u ts: %u ticks=0x%llx/0x%llx\n",
2896: prefix, kgsl_context_type(drawctxt->type), rb,
2897: MSG_HDR_GET_SEQNUM(ack->sent_hdr), cmd->ctxt_id, cmd->ts, start, end);
2898: return 0;
2899: }
2900:
2901: snprintf(prefix, sizeof(prefix),
2902: "Ack timeout for %scontext unregister", fast ? "fast " : "");
2903: dev_err_ratelimited(dev,
2904: "%s type: %s rb: %d seq: %d ctx: %u ts: %u ticks=0x%llx/0x%llx\n",
2905: prefix, kgsl_context_type(drawctxt->type), rb,
2906: MSG_HDR_GET_SEQNUM(ack->sent_hdr), cmd->ctxt_id, cmd->ts, start, end);
2907: return -ETIMEDOUT;
2908: }
2909:
2910: u32 adreno_hwsched_parse_payload(struct payload_section *payload, u32 key)
2911: {
2912: u32 i;
2913:
2914: /* Each key-value pair is 2 dwords */
2915: for (i = 0; i < payload->dwords; i += 2) {
MATCH LINES: 3142
3130: void adreno_hwsched_remove_hw_fence_entry(struct adreno_device *adreno_dev,
3131: struct adreno_hw_fence_entry *entry)
3132: {
3133: struct adreno_hwsched *hwsched = &adreno_dev->hwsched;
3134: struct adreno_context *drawctxt = entry->drawctxt;
3135: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence;
3136:
3137: spin_lock(&hwf->lock);
3138: hwf->pending_count--;
3139: spin_unlock(&hwf->lock);
3140: drawctxt->hw_fence_count--;
3141:
3142: dma_fence_put(&entry->kfence->fence);
3143: list_del_init(&entry->node);
3144: kmem_cache_free(hwsched->hw_fence_cache, entry);
3145: kgsl_context_put_deferred(&drawctxt->base);
3146: }
3147:
3148: void adreno_hwsched_add_profile_events(struct adreno_device *adreno_dev,
3149: struct kgsl_drawobj_cmd *cmdobj, struct adreno_submit_time *time)
3150: {
3151: unsigned long flags;
3152: u64 time_in_s;
3153: unsigned long time_in_ns;
3154: struct kgsl_drawobj *drawobj = DRAWOBJ(cmdobj);
3155: struct kgsl_context *context = drawobj->context;
3156: struct submission_info info = {0};
3157: struct adreno_hwsched *hwsched = &adreno_dev->hwsched;
3158: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
3159:
3160: if (!time)
3161: return;
3162:
3163: /*
3164: * Here we are attempting to create a mapping between the
3165: * GPU time domain (alwayson counter) and the CPU time domain
3166: * (local_clock) by sampling both values as close together as
MATCH LINES: 3251, 3252, 3254, 3255
3239: /* Cookify any non used data at the end of the write buffer */
3240: for (; i < align_size; i++) {
3241: queue[write_idx] = 0xfafafafa;
3242: write_idx = (write_idx + 1) % hdr->queue_size;
3243: }
3244:
3245: /* Ensure packet is written out before proceeding */
3246: wmb();
3247:
3248: if (!drawobj)
3249: goto done;
3250:
3251: if (drawobj->type & SYNCOBJ_TYPE) {
3252: struct kgsl_drawobj_sync *syncobj = SYNCOBJ(drawobj);
3253:
3254: trace_adreno_syncobj_submitted(drawobj->context->id, drawobj->timestamp,
3255: syncobj->num_hw_fence, gpudev->read_alwayson(adreno_dev));
3256: goto done;
3257: }
3258:
3259: cmdobj = CMDOBJ(drawobj);
3260:
3261: adreno_hwsched_add_profile_events(adreno_dev, cmdobj, time);
3262:
3263: /*
3264: * Put the profiling information in the user profiling buffer.
3265: * The hfi_update_write_idx below has a wmb() before the actual
3266: * write index update to ensure that the GMU does not see the
3267: * packet before the profile data is written out.
3268: */
3269: adreno_profile_submit_time(time);
3270:
3271: done:
3272: trace_kgsl_hfi_send(id, size_dwords, MSG_HDR_GET_SEQNUM(*msg));
3273:
3274: hfi_update_write_idx(&hdr->write_index, write_idx);
3275:
3276: return 0;
3277: }
3278:
3279: int adreno_hwsched_drain_and_idle(struct adreno_device *adreno_dev)
--- FILE: \adreno_hwsched.h | HITS: 4 ---
MATCH LINES: 141
129: u32 inflight;
130: /** @jobs - Array of dispatch job lists for each priority level */
131: struct llist_head jobs[16];
132: /** @requeue - Array of lists for dispatch jobs that got requeued */
133: struct llist_head requeue[16];
134: /** @cmd_list: List of objects submitted to dispatch queues */
135: struct list_head cmd_list;
136: /** @hwsched_ops: Container for target specific hwscheduler ops */
137: const struct adreno_hwsched_ops *hwsched_ops;
138: /** @ctxt_bad: Container for the context bad hfi packet */
139: void *ctxt_bad;
140: /** @idle_gate: Gate to wait on for hwscheduler to idle */
141: struct completion idle_gate;
142: /** @big_cmdobj = Points to the big IB that is inflight */
143: struct kgsl_drawobj_cmd *big_cmdobj;
144: /** @recurring_cmdobj: Recurring commmand object sent to GMU */
145: struct kgsl_drawobj_cmd *recurring_cmdobj;
146: /** @lsr_timer: Timer struct to schedule lsr work */
147: struct timer_list lsr_timer;
148: /** @lsr_check_ws: Lsr work to update power stats */
149: struct work_struct lsr_check_ws;
150: /** @hw_fence: Container for the hw fences instance */
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 */
MATCH LINES: 354, 355, 358
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
--- FILE: \adreno_ringbuffer.c | HITS: 4 ---
MATCH LINES: 111, 145
99: return RB_HOSTPTR(rb, ret);
100: }
101:
102: return ERR_PTR(-ENOSPC);
103: }
104:
105: void adreno_ringbuffer_stop(struct adreno_device *adreno_dev)
106: {
107: struct adreno_ringbuffer *rb;
108: int i;
109:
110: FOR_EACH_RINGBUFFER(adreno_dev, rb, i)
111: kgsl_cancel_events(KGSL_DEVICE(adreno_dev), &(rb->events));
112: }
113:
114: static int _rb_readtimestamp(struct kgsl_device *device,
115: void *priv, enum kgsl_timestamp_type type,
116: unsigned int *timestamp)
117: {
118: return adreno_rb_readtimestamp(ADRENO_DEVICE(device), priv, type,
119: timestamp);
120: }
121:
122: int adreno_ringbuffer_setup(struct adreno_device *adreno_dev,
123: struct adreno_ringbuffer *rb, int id)
124: {
125: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
126: unsigned int priv = 0;
127: int ret;
128:
129: /* allocate a chunk of memory to create user profiling IB1s */
130: adreno_allocate_global(device, &rb->profile_desc, PAGE_SIZE,
131: 0, KGSL_MEMFLAGS_GPUREADONLY, 0, "profile_desc");
132:
133: if (ADRENO_FEATURE(adreno_dev, ADRENO_APRIV))
134: priv |= KGSL_MEMDESC_PRIVILEGED;
135:
136: ret = adreno_allocate_global(device, &rb->buffer_desc, KGSL_RB_SIZE,
137: SZ_4K, KGSL_MEMFLAGS_GPUREADONLY, priv, "ringbuffer");
138: if (ret)
139: return ret;
140:
141: if (!list_empty(&rb->events.group))
142: return 0;
143:
144: rb->id = id;
145: kgsl_add_event_group(device, &rb->events, NULL, _rb_readtimestamp, rb,
146: "rb_events-%d", id);
147:
148: rb->timestamp = 0;
149: init_waitqueue_head(&rb->ts_expire_waitq);
150:
151: spin_lock_init(&rb->preempt_lock);
152:
153: return 0;
154: }
155:
156: void adreno_preemption_timer(struct timer_list *t)
157: {
158: struct adreno_preemption *preempt = kgsl_timer_container_of(preempt, t, timer);
159: struct adreno_device *adreno_dev = container_of(preempt,
160: struct adreno_device, preempt);
161:
162: /* We should only be here from a triggered state */
163: if (!adreno_move_preempt_state(adreno_dev,
164: ADRENO_PREEMPT_TRIGGERED, ADRENO_PREEMPT_FAULTED))
165: return;
166:
167: /* Schedule the worker to take care of the details */
168: queue_work(system_unbound_wq, &adreno_dev->preempt.work);
169: }
MATCH LINES: 401, 409
389: unsigned int msecs)
390: {
391: struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
392: struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
393: int ret;
394: unsigned long wait_time;
395:
396: /* check immediately if timeout is 0 */
397: if (msecs == 0)
398: return adreno_ringbuffer_check_timestamp(rb,
399: timestamp, KGSL_TIMESTAMP_RETIRED) ? 0 : -EBUSY;
400:
401: ret = kgsl_add_event(device, &rb->events, timestamp,
402: adreno_ringbuffer_wait_callback, NULL);
403: if (ret)
404: return ret;
405:
406: kgsl_mutex_unlock(&device->mutex);
407:
408: wait_time = msecs_to_jiffies(msecs);
409: if (wait_event_timeout(rb->ts_expire_waitq,
410: !kgsl_event_pending(device, &rb->events, timestamp,
411: adreno_ringbuffer_wait_callback, NULL),
412: wait_time) == 0)
413: ret = -ETIMEDOUT;
414:
415: kgsl_mutex_lock(&device->mutex);
416: /*
417: * after wake up make sure that expected timestamp has retired
418: * because the wakeup could have happened due to a cancel event
419: */
420: if (!ret && !adreno_ringbuffer_check_timestamp(rb,
421: timestamp, KGSL_TIMESTAMP_RETIRED)) {
422: ret = -EAGAIN;
423: }
424:
425: return ret;
426: }
--- FILE: \adreno_trace.h | HITS: 10 ---
MATCH LINES: 113, 117, 135, 153, 154, 156, 160, 166, 171, 174
101: ),
102: TP_fast_assign(
103: __entry->id = id;
104: __entry->context = context;
105: __entry->seqno = seqno;
106: __entry->flags = flags;
107: adreno_assign_str(fence_name, name);
108: ),
109: TP_printk(
110: "ctx=%u id=%lld seqno=%lld flags=%s name=%s",
111: __entry->id, __entry->context, __entry->seqno,
112: __entry->flags ? __print_flags(__entry->flags, "|",
113: GMU_SYNCOBJ_FLAGS) : "none",
114: __get_str(fence_name))
115: );
116:
117: TRACE_EVENT(adreno_syncobj_query_reply,
118: TP_PROTO(u32 id, u32 timestamp, uint64_t ticks),
119: TP_ARGS(id, timestamp, ticks),
120: TP_STRUCT__entry(
121: __field(u32, id)
122: __field(u32, timestamp)
123: __field(uint64_t, ticks)
124: ),
125: TP_fast_assign(
126: __entry->id = id;
127: __entry->timestamp = timestamp;
128: __entry->ticks = ticks;
129: ),
130: TP_printk(
131: "ctx=%u ts=%u ticks=%lld",
132: __entry->id, __entry->timestamp, __entry->ticks)
133: );
134:
135: TRACE_EVENT(adreno_syncobj_query,
136: TP_PROTO(u32 id, u32 timestamp, uint64_t ticks),
137: TP_ARGS(id, timestamp, ticks),
138: TP_STRUCT__entry(
139: __field(u32, id)
140: __field(u32, timestamp)
141: __field(uint64_t, ticks)
142: ),
143: TP_fast_assign(
144: __entry->id = id;
145: __entry->timestamp = timestamp;
146: __entry->ticks = ticks;
147: ),
148: TP_printk(
149: "ctx=%u ts=%u ticks=%lld",
150: __entry->id, __entry->timestamp, __entry->ticks)
151: );
152:
153: TRACE_EVENT(adreno_syncobj_submitted,
154: TP_PROTO(u32 id, u32 timestamp, u32 num_syncobj,
155: uint64_t ticks),
156: TP_ARGS(id, timestamp, num_syncobj, ticks),
157: TP_STRUCT__entry(
158: __field(u32, id)
159: __field(u32, timestamp)
160: __field(u32, num_syncobj)
161: __field(uint64_t, ticks)
162: ),
163: TP_fast_assign(
164: __entry->id = id;
165: __entry->timestamp = timestamp;
166: __entry->num_syncobj = num_syncobj;
167: __entry->ticks = ticks;
168: ),
169: TP_printk(
170: "ctx=%u ts=%u num_sync=%u ticks=%lld",
171: __entry->id, __entry->timestamp, __entry->num_syncobj, __entry->ticks)
172: );
173:
174: TRACE_EVENT(adreno_syncobj_retired,
175: TP_PROTO(u32 id, u32 timestamp, u64 ticks),
176: TP_ARGS(id, timestamp, ticks),
177: TP_STRUCT__entry(
178: __field(u32, id)
179: __field(u32, timestamp)
180: __field(u64, ticks)
181: ),
182: TP_fast_assign(
183: __entry->id = id;
184: __entry->timestamp = timestamp;
185: __entry->ticks = ticks;
186: ),
187: TP_printk(
188: "ctx=%u ts=%u ticks=%llu", __entry->id, __entry->timestamp, __entry->ticks)
189: );
190:
191: TRACE_EVENT(adreno_cmdbatch_submitted,
192: TP_PROTO(struct kgsl_drawobj *drawobj, struct submission_info *info,
193: uint64_t ticks, unsigned long secs, unsigned long usecs,
194: int q_inflight),
195: TP_ARGS(drawobj, info, ticks, secs, usecs, q_inflight),
196: TP_STRUCT__entry(
197: __field(unsigned int, id)
198: __field(unsigned int, timestamp)
--- FILE: \kgsl.c | HITS: 28 ---
MATCH LINES: 783
771:
772: context->device = device;
773: context->dev_priv = dev_priv;
774: context->proc_priv = proc_priv;
775: context->tid = task_pid_nr(current);
776:
777: ret = kgsl_sync_timeline_create(context);
778: if (ret) {
779: kgsl_process_private_put(proc_priv);
780: goto out;
781: }
782:
783: kgsl_add_event_group(device, &context->events, context,
784: kgsl_readtimestamp, context, "context-%d", id);
785:
786: out:
787: if (ret) {
788: atomic_dec(&proc_priv->ctxt_count);
789: write_lock(&device->context_lock);
790: idr_remove(&device->context_idr, id);
791: write_unlock(&device->context_lock);
792: }
793:
794: return ret;
795: }
796:
797: void kgsl_free_faults(struct kgsl_context *context)
798: {
799: struct kgsl_fault_node *p, *tmp;
800:
801: if (!(context->flags & KGSL_CONTEXT_FAULT_INFO))
802: return;
803:
804: list_for_each_entry_safe(p, tmp, &context->faults, node) {
805: list_del(&p->node);
806: kfree(p->priv);
807: kfree(p);
MATCH LINES: 849
837: if (test_and_set_bit(KGSL_CONTEXT_PRIV_DETACHED, &context->priv))
838: return;
839:
840: trace_kgsl_context_detach(device, context);
841:
842: context->device->ftbl->drawctxt_detach(context);
843:
844: /*
845: * Cancel all pending events after the device-specific context is
846: * detached, to avoid possibly freeing memory while it is still
847: * in use by the GPU.
848: */
849: kgsl_cancel_events(device, &context->events);
850:
851: /* Remove the event group from the list */
852: kgsl_del_event_group(device, &context->events);
853:
854: kgsl_sync_timeline_detach(context->ktimeline);
855: kgsl_context_put(context);
856: }
857:
858: void
859: kgsl_context_destroy(struct kref *kref)
860: {
861: struct kgsl_context *context = container_of(kref, struct kgsl_context,
862: refcount);
863: struct kgsl_device *device = context->device;
864:
865: trace_kgsl_context_destroy(device, context);
866:
867: /*
868: * It's not safe to destroy the context if it's not detached as GPU
869: * may still be executing commands
870: */
871: BUG_ON(!kgsl_context_detached(context));
872:
873: kgsl_free_faults(context);
MATCH LINES: 2182, 2186, 2188, 2217, 2218, 2220, 2221, 2225, 2227, 2232, 2233
2170:
2171: /*
2172: * The SYNC bit is supposed to identify a dummy sync object
2173: * so warn the user if they specified any IBs with it.
2174: * A MARKER command can either have IBs or not but if the
2175: * command has 0 IBs it is automatically assumed to be a marker.
2176: */
2177:
2178: /* If they specify the flag, go with what they say */
2179: if (flags & KGSL_DRAWOBJ_MARKER)
2180: return MARKEROBJ_TYPE;
2181: else if (flags & KGSL_DRAWOBJ_SYNC)
2182: return SYNCOBJ_TYPE;
2183:
2184: /* If not, deduce what they meant */
2185: if (numsyncs && numcmds)
2186: return SYNCOBJ_TYPE | CMDOBJ_TYPE;
2187: else if (numsyncs)
2188: return SYNCOBJ_TYPE;
2189: else if (numcmds)
2190: return CMDOBJ_TYPE;
2191: else if (numcmds == 0)
2192: return MARKEROBJ_TYPE;
2193:
2194: return 0;
2195: }
2196:
2197: long kgsl_ioctl_submit_commands(struct kgsl_device_private *dev_priv,
2198: unsigned int cmd, void *data)
2199: {
2200: struct kgsl_submit_commands *param = data;
2201: struct kgsl_device *device = dev_priv->device;
2202: struct kgsl_context *context;
2203: struct kgsl_drawobj *drawobj[2];
2204: unsigned int type;
2205: long result;
2206: unsigned int i = 0;
2207:
2208: type = _process_command_input(device, param->flags, param->numcmds, 0,
2209: param->numsyncs);
2210: if (!type)
2211: return -EINVAL;
2212:
2213: context = kgsl_context_get_owner(dev_priv, param->context_id);
2214: if (context == NULL)
2215: return -EINVAL;
2216:
2217: if (type & SYNCOBJ_TYPE) {
2218: struct kgsl_drawobj_sync *syncobj =
2219: kgsl_drawobj_sync_create(device, context);
2220: if (IS_ERR(syncobj)) {
2221: result = PTR_ERR(syncobj);
2222: goto done;
2223: }
2224:
2225: drawobj[i++] = DRAWOBJ(syncobj);
2226:
2227: result = kgsl_drawobj_sync_add_syncpoints(device, syncobj,
2228: param->synclist, param->numsyncs);
2229: if (result)
2230: goto done;
2231:
2232: if (!test_bit(KGSL_SYNCOBJ_SW, &syncobj->flags))
2233: set_bit(KGSL_SYNCOBJ_HW, &syncobj->flags);
2234: }
2235:
2236: if (type & (CMDOBJ_TYPE | MARKEROBJ_TYPE)) {
2237: struct kgsl_drawobj_cmd *cmdobj =
2238: kgsl_drawobj_cmd_create(device,
2239: context, param->flags, type);
2240: if (IS_ERR(cmdobj)) {
2241: result = PTR_ERR(cmdobj);
2242: goto done;
2243: }
2244:
2245: drawobj[i++] = DRAWOBJ(cmdobj);
2246:
2247: result = kgsl_drawobj_cmd_add_ibdesc_list(device, cmdobj,
2248: param->cmdlist, param->numcmds);
2249: if (result)
2250: goto done;
2251:
2252: /* If no profiling buffer was specified, clear the flag */
2253: if (cmdobj->profiling_buf_entry == NULL)
2254: DRAWOBJ(cmdobj)->flags &=
2255: ~(unsigned long)KGSL_DRAWOBJ_PROFILING;
2256:
2257: if (type & CMDOBJ_TYPE) {
MATCH LINES: 2302, 2303, 2306, 2307, 2311, 2313, 2319, 2320
2290: long result;
2291: unsigned int i = 0;
2292:
2293: type = _process_command_input(device, param->flags, param->numcmds,
2294: param->numobjs, param->numsyncs);
2295: if (!type)
2296: return -EINVAL;
2297:
2298: context = kgsl_context_get_owner(dev_priv, param->context_id);
2299: if (context == NULL)
2300: return -EINVAL;
2301:
2302: if (type & SYNCOBJ_TYPE) {
2303: struct kgsl_drawobj_sync *syncobj =
2304: kgsl_drawobj_sync_create(device, context);
2305:
2306: if (IS_ERR(syncobj)) {
2307: result = PTR_ERR(syncobj);
2308: goto done;
2309: }
2310:
2311: drawobj[i++] = DRAWOBJ(syncobj);
2312:
2313: result = kgsl_drawobj_sync_add_synclist(device, syncobj,
2314: u64_to_user_ptr(param->synclist),
2315: param->syncsize, param->numsyncs);
2316: if (result)
2317: goto done;
2318:
2319: if (!test_bit(KGSL_SYNCOBJ_SW, &syncobj->flags))
2320: set_bit(KGSL_SYNCOBJ_HW, &syncobj->flags);
2321: }
2322:
2323: if (type & (CMDOBJ_TYPE | MARKEROBJ_TYPE)) {
2324: struct kgsl_drawobj_cmd *cmdobj =
2325: kgsl_drawobj_cmd_create(device,
2326: context, param->flags, type);
2327:
2328: if (IS_ERR(cmdobj)) {
2329: result = PTR_ERR(cmdobj);
2330: goto done;
2331: }
2332:
2333: drawobj[i++] = DRAWOBJ(cmdobj);
2334:
2335: result = kgsl_drawobj_cmd_add_cmdlist(device, cmdobj,
2336: u64_to_user_ptr(param->cmdlist),
2337: param->cmdsize, param->numcmds);
2338: if (result)
2339: goto done;
2340:
2341: result = kgsl_drawobj_cmd_add_memlist(device, cmdobj,
2342: u64_to_user_ptr(param->objlist),
2343: param->objsize, param->numobjs);
2344: if (result)
MATCH LINES: 2425, 2428, 2429, 2433, 2435, 2465
2413: drawobjs = kvcalloc(count, sizeof(*drawobjs),
2414: GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN);
2415:
2416: if (!drawobjs) {
2417: kgsl_context_put(context);
2418: return -ENOMEM;
2419: }
2420:
2421: trace_kgsl_aux_command(context->id, param->numcmds, param->flags,
2422: param->timestamp);
2423:
2424: if (param->flags & KGSL_GPU_AUX_COMMAND_SYNC) {
2425: struct kgsl_drawobj_sync *syncobj =
2426: kgsl_drawobj_sync_create(device, context);
2427:
2428: if (IS_ERR(syncobj)) {
2429: ret = PTR_ERR(syncobj);
2430: goto err;
2431: }
2432:
2433: drawobjs[index++] = DRAWOBJ(syncobj);
2434:
2435: ret = kgsl_drawobj_sync_add_synclist(device, syncobj,
2436: u64_to_user_ptr(param->synclist),
2437: param->syncsize, param->numsyncs);
2438: if (ret)
2439: goto err;
2440: }
2441:
2442: cmdlist = u64_to_user_ptr(param->cmdlist);
2443:
2444: /*
2445: * Create a draw object for KGSL_GPU_AUX_COMMAND_BIND or
2446: * KGSL_GPU_AUX_COMMAND_TIMELINE.
2447: */
2448: if (copy_struct_from_user(&generic, sizeof(generic),
2449: cmdlist, param->cmdsize)) {
2450: ret = -EFAULT;
2451: goto err;
2452: }
2453:
2454: if (generic.type == KGSL_GPU_AUX_COMMAND_BIND) {
2455: struct kgsl_drawobj_sync *tsobj;
2456: struct kgsl_drawobj_bind *bindobj;
2457: u32 queued;
2458:
2459: kgsl_readtimestamp(device, context, KGSL_TIMESTAMP_QUEUED,
2460: &queued);
2461: /*
2462: * Make an implicit sync object for the last queued timestamp
2463: * on this context
2464: */
2465: tsobj = kgsl_drawobj_create_timestamp_syncobj(device,
2466: context, queued);
2467:
2468: if (IS_ERR(tsobj)) {
2469: ret = PTR_ERR(tsobj);
2470: goto err;
2471: }
2472:
2473: drawobjs[index++] = DRAWOBJ(tsobj);
2474:
2475: bindobj = kgsl_drawobj_bind_create(device, context);
2476:
2477: if (IS_ERR(bindobj)) {
2478: ret = PTR_ERR(bindobj);
2479: goto err;
2480: }
2481:
2482: drawobjs[index++] = DRAWOBJ(bindobj);
2483:
2484: ret = kgsl_drawobj_add_bind(dev_priv, bindobj,
2485: cmdlist, param->cmdsize);
2486: if (ret)
2487: goto err;
2488: } else if (generic.type == KGSL_GPU_AUX_COMMAND_TIMELINE) {
2489: struct kgsl_drawobj_timeline *timelineobj;
MATCH LINES: 2745
2733: struct kgsl_mem_entry *entry,
2734: struct kgsl_context *context, unsigned int timestamp)
2735: {
2736: int ret;
2737: unsigned int temp;
2738:
2739: if (!kgsl_mem_entry_set_pend(entry))
2740: return -EBUSY;
2741:
2742: kgsl_readtimestamp(device, context, KGSL_TIMESTAMP_RETIRED, &temp);
2743: trace_kgsl_mem_timestamp_queue(device, entry, context->id, temp,
2744: timestamp);
2745: ret = kgsl_add_event(device, &context->events,
2746: timestamp, gpumem_free_func, entry);
2747:
2748: if (ret)
2749: kgsl_mem_entry_unset_pend(entry);
2750:
2751: return ret;
2752: }
2753:
2754: long kgsl_ioctl_sharedmem_free(struct kgsl_device_private *dev_priv,
2755: unsigned int cmd, void *data)
2756: {
2757: struct kgsl_sharedmem_free *param = data;
2758: struct kgsl_process_private *private = dev_priv->process_priv;
2759: struct kgsl_mem_entry *entry;
2760: long ret;
2761:
2762: entry = kgsl_sharedmem_find(private, (uint64_t) param->gpuaddr);
2763: if (entry == NULL)
2764: return -EINVAL;
2765:
2766: ret = gpumem_free_entry(entry);
2767: kgsl_mem_entry_put(entry);
2768:
2769: return ret;
--- FILE: \kgsl_compat.c | HITS: 2 ---
MATCH LINES: 328, 329
316: KGSL_IOCTL_FUNC(IOCTL_KGSL_GPUMEM_GET_INFO_COMPAT,
317: kgsl_ioctl_gpumem_get_info_compat),
318: KGSL_IOCTL_FUNC(IOCTL_KGSL_GPUMEM_SYNC_CACHE_COMPAT,
319: kgsl_ioctl_gpumem_sync_cache_compat),
320: KGSL_IOCTL_FUNC(IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK_COMPAT,
321: kgsl_ioctl_gpumem_sync_cache_bulk_compat),
322: KGSL_IOCTL_FUNC(IOCTL_KGSL_SYNCSOURCE_CREATE,
323: kgsl_ioctl_syncsource_create),
324: KGSL_IOCTL_FUNC(IOCTL_KGSL_SYNCSOURCE_DESTROY,
325: kgsl_ioctl_syncsource_destroy),
326: KGSL_IOCTL_FUNC(IOCTL_KGSL_SYNCSOURCE_CREATE_FENCE,
327: kgsl_ioctl_syncsource_create_fence),
328: KGSL_IOCTL_FUNC(IOCTL_KGSL_SYNCSOURCE_SIGNAL_FENCE,
329: kgsl_ioctl_syncsource_signal_fence),
330: KGSL_IOCTL_FUNC(IOCTL_KGSL_GPUOBJ_ALLOC,
331: kgsl_ioctl_gpuobj_alloc),
332: KGSL_IOCTL_FUNC(IOCTL_KGSL_GPUOBJ_FREE,
333: kgsl_ioctl_gpuobj_free),
334: KGSL_IOCTL_FUNC(IOCTL_KGSL_GPUOBJ_INFO,
335: kgsl_ioctl_gpuobj_info),
336: KGSL_IOCTL_FUNC(IOCTL_KGSL_GPUOBJ_IMPORT,
337: kgsl_ioctl_gpuobj_import),
338: KGSL_IOCTL_FUNC(IOCTL_KGSL_GPUOBJ_SYNC,
339: kgsl_ioctl_gpuobj_sync),
340: KGSL_IOCTL_FUNC(IOCTL_KGSL_GPU_COMMAND,
341: kgsl_ioctl_gpu_command),
342: KGSL_IOCTL_FUNC(IOCTL_KGSL_GPUOBJ_SET_INFO,
343: NULL),
344: KGSL_IOCTL_FUNC(IOCTL_KGSL_SPARSE_PHYS_ALLOC,
345: NULL),
346: KGSL_IOCTL_FUNC(IOCTL_KGSL_SPARSE_PHYS_FREE,
347: NULL),
348: KGSL_IOCTL_FUNC(IOCTL_KGSL_SPARSE_VIRT_ALLOC,
349: NULL),
350: KGSL_IOCTL_FUNC(IOCTL_KGSL_SPARSE_VIRT_FREE,
351: NULL),
352: KGSL_IOCTL_FUNC(IOCTL_KGSL_SPARSE_BIND,
353: NULL),
--- FILE: \kgsl_device.h | HITS: 12 ---
MATCH LINES: 291, 292
279:
280: /* Starting kernel virtual address for QDSS GFX DBG register block */
281: void __iomem *qdss_gfx_virt;
282:
283: /* Kernel virtual address for CX SMMU aperture register block */
284: void __iomem *smmu_aperture_virt;
285:
286: struct kgsl_memdesc *memstore;
287: struct kgsl_memdesc *scratch;
288:
289: struct kgsl_mmu mmu;
290: struct gmu_core_device gmu_core;
291: struct completion hwaccess_gate;
292: struct completion halt_gate;
293: const struct kgsl_functable *ftbl;
294: struct work_struct idle_check_ws;
295: struct timer_list idle_timer;
296: struct kgsl_pwrctrl pwrctrl;
297: int open_count;
298:
299: /* For GPU inline submission */
300: uint32_t submit_now;
301: spinlock_t submit_lock;
302: /** @skip_inline_submit: Track if user threads should make an inline submission or not */
303: bool skip_inline_submit;
304:
305: #if IS_ENABLED(CONFIG_QCOM_KGSL_RT_MUTEX)
306: struct rt_mutex mutex;
307: #else
308: struct mutex mutex;
309: #endif
310: uint32_t state;
311: uint32_t requested_state;
312:
313: atomic_t active_cnt;
314: /** @total_mapped: To trace overall gpu memory usage */
315: atomic64_t total_mapped;
316:
MATCH LINES: 424, 427
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,
MATCH LINES: 684, 715
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;
MATCH LINES: 856, 866, 871, 873, 875, 881
844:
845: /**
846: * kgsl_del_event_group - Remove a GPU event group from a device
847: * @device: A KGSL GPU device handle
848: * @group: Event group to be removed
849: *
850: * Remove the specified group from the list of event groups on @device.
851: */
852: void kgsl_del_event_group(struct kgsl_device *device,
853: struct kgsl_event_group *group);
854:
855: /**
856: * kgsl_add_event_group - Add a new GPU event group
857: * @device: A KGSL GPU device handle
858: * @group: Pointer to the new group to add to the list
859: * @context: Context that owns the group (or NULL for global)
860: * @readtimestamp: Function pointer to the readtimestamp function to call when
861: * processing events
862: * @priv: Priv member to pass to the readtimestamp function
863: * @fmt: The format string to use to build the event name
864: * @...: Arguments for the format string
865: */
866: void kgsl_add_event_group(struct kgsl_device *device,
867: struct kgsl_event_group *group,
868: struct kgsl_context *context, readtimestamp_func readtimestamp,
869: void *priv, const char *fmt, ...);
870:
871: void kgsl_cancel_events_timestamp(struct kgsl_device *device,
872: struct kgsl_event_group *group, unsigned int timestamp);
873: void kgsl_cancel_events(struct kgsl_device *device,
874: struct kgsl_event_group *group);
875: void kgsl_cancel_event(struct kgsl_device *device,
876: struct kgsl_event_group *group, unsigned int timestamp,
877: kgsl_event_func func, void *priv);
878: bool kgsl_event_pending(struct kgsl_device *device,
879: struct kgsl_event_group *group, unsigned int timestamp,
880: kgsl_event_func func, void *priv);
881: int kgsl_add_event(struct kgsl_device *device, struct kgsl_event_group *group,
882: unsigned int timestamp, kgsl_event_func func, void *priv);
883: void kgsl_process_event_group(struct kgsl_device *device,
884: struct kgsl_event_group *group);
885: void kgsl_flush_event_group(struct kgsl_device *device,
886: struct kgsl_event_group *group);
887: void kgsl_process_event_groups(struct kgsl_device *device);
888:
889: void kgsl_context_destroy(struct kref *kref);
890:
891: int kgsl_context_init(struct kgsl_device_private *dev_priv,
892: struct kgsl_context *context);
893:
894: void kgsl_context_dump(struct kgsl_context *context);
895:
896: int kgsl_memfree_find_entry(pid_t ptname, uint64_t *gpuaddr,
897: uint64_t *size, uint64_t *flags, pid_t *pid);
898:
899: long kgsl_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
900:
901: long kgsl_ioctl_copy_in(unsigned int kernel_cmd, unsigned int user_cmd,
902: unsigned long arg, unsigned char *ptr);
903:
904: long kgsl_ioctl_copy_out(unsigned int kernel_cmd, unsigned int user_cmd,
905: unsigned long arg, unsigned char *ptr);
--- FILE: \kgsl_drawobj.c | HITS: 138 ---
MATCH LINES: 41, 43, 46, 47, 60, 69, 70, 71, 99, 104, 105, 107
29: #include "kgsl_eventlog.h"
30: #include "kgsl_sync.h"
31: #include "kgsl_timeline.h"
32: #include "kgsl_trace.h"
33: #include "kgsl_util.h"
34:
35: /*
36: * Define an kmem cache for the memobj structures since we
37: * allocate and free them so frequently
38: */
39: static struct kmem_cache *memobjs_cache;
40:
41: static void syncobj_destroy_object(struct kgsl_drawobj *drawobj)
42: {
43: struct kgsl_drawobj_sync *syncobj = SYNCOBJ(drawobj);
44: int i;
45:
46: for (i = 0; i < syncobj->numsyncs; i++) {
47: struct kgsl_drawobj_sync_event *event = &syncobj->synclist[i];
48:
49: if (event->type == KGSL_CMD_SYNCPOINT_TYPE_FENCE) {
50: struct event_fence_info *priv = event->priv;
51:
52: if (priv) {
53: kfree(priv->fences);
54: kfree(priv);
55: }
56:
57: if (event->handle) {
58: struct kgsl_sync_fence_cb *kcb = event->handle;
59:
60: dma_fence_put(kcb->fence);
61: kfree(kcb);
62: }
63:
64: } else if (event->type == KGSL_CMD_SYNCPOINT_TYPE_TIMELINE) {
65: kfree(event->priv);
66: }
67: }
68:
69: kfree(syncobj->hw_fences);
70: kfree(syncobj->synclist);
71: kfree(syncobj);
72: }
73:
74: static void cmdobj_destroy_object(struct kgsl_drawobj *drawobj)
75: {
76: kfree(CMDOBJ(drawobj));
77: }
78:
79: static void bindobj_destroy_object(struct kgsl_drawobj *drawobj)
80: {
81: kfree(BINDOBJ(drawobj));
82: }
83:
84: static void timelineobj_destroy_object(struct kgsl_drawobj *drawobj)
85: {
86: kfree(TIMELINEOBJ(drawobj));
87: }
88:
89: void kgsl_drawobj_destroy_object(struct kref *kref)
90: {
91: struct kgsl_drawobj *drawobj = container_of(kref,
92: struct kgsl_drawobj, refcount);
93:
94: kgsl_context_put(drawobj->context);
95: drawobj->destroy_object(drawobj);
96: }
97:
98: void kgsl_dump_syncpoints(struct kgsl_device *device,
99: struct kgsl_drawobj_sync *syncobj)
100: {
101: struct kgsl_drawobj_sync_event *event;
102: unsigned int i;
103:
104: for (i = 0; i < syncobj->numsyncs; i++) {
105: event = &syncobj->synclist[i];
106:
107: if (!kgsl_drawobj_event_pending(syncobj, i))
108: continue;
109:
110: switch (event->type) {
111: case KGSL_CMD_SYNCPOINT_TYPE_TIMESTAMP: {
112: unsigned int retired;
113:
114: kgsl_readtimestamp(event->device,
115: event->context, KGSL_TIMESTAMP_RETIRED,
116: &retired);
117:
118: dev_err(device->dev,
119: " [timestamp] context %u timestamp %u (retired %u)\n",
120: event->context->id, event->timestamp,
121: retired);
122: break;
123: }
124: case KGSL_CMD_SYNCPOINT_TYPE_FENCE: {
125: int j;
126: struct event_fence_info *info = event->priv;
127:
128: for (j = 0; info && j < info->num_fences; j++)
129: dev_err(device->dev, "[%d] fence: %s\n",
130: i, info->fences[j].name);
131: break;
MATCH LINES: 146, 149, 154, 157, 179, 180, 182, 202, 204, 241, 246, 253, 254, 258, 272, 282, 290, 291, 294, 295, 297, 298, 314, 316, 318, 320, 325, 326, 331, 341, 343, 347, 353, 354, 361, 366, 380, 381, 391, 428
134: int j;
135: struct event_timeline_info *info = event->priv;
136:
137: for (j = 0; info && info[j].timeline; j++)
138: dev_err(device->dev, "[%d] timeline: %d seqno %lld\n",
139: i, info[j].timeline, info[j].seqno);
140: break;
141: }
142: }
143: }
144: }
145:
146: static void syncobj_timer(struct timer_list *t)
147: {
148: struct kgsl_device *device;
149: struct kgsl_drawobj_sync *syncobj = kgsl_timer_container_of(syncobj, t, timer);
150: struct kgsl_drawobj *drawobj;
151: struct kgsl_drawobj_sync_event *event;
152: unsigned int i;
153:
154: if (syncobj == NULL)
155: return;
156:
157: drawobj = DRAWOBJ(syncobj);
158:
159: if (!kref_get_unless_zero(&drawobj->refcount))
160: return;
161:
162: if (drawobj->context == NULL) {
163: kgsl_drawobj_put(drawobj);
164: return;
165: }
166:
167: device = drawobj->context->device;
168:
169: dev_err(device->dev,
170: "kgsl: possible gpu syncpoint deadlock for context %u timestamp %u\n",
171: drawobj->context->id, drawobj->timestamp);
172:
173: set_bit(ADRENO_CONTEXT_FENCE_LOG, &drawobj->context->priv);
174: kgsl_context_dump(drawobj->context);
175: clear_bit(ADRENO_CONTEXT_FENCE_LOG, &drawobj->context->priv);
176:
177: dev_err(device->dev, " pending events:\n");
178:
179: for (i = 0; i < syncobj->numsyncs; i++) {
180: event = &syncobj->synclist[i];
181:
182: if (!kgsl_drawobj_event_pending(syncobj, i))
183: continue;
184:
185: switch (event->type) {
186: case KGSL_CMD_SYNCPOINT_TYPE_TIMESTAMP:
187: dev_err(device->dev, " [%u] TIMESTAMP %u:%u\n",
188: i, event->context->id, event->timestamp);
189: break;
190: case KGSL_CMD_SYNCPOINT_TYPE_FENCE: {
191: int j;
192: struct event_fence_info *info = event->priv;
193:
194: for (j = 0; info && j < info->num_fences; j++)
195: dev_err(device->dev, " [%u] FENCE %s\n",
196: i, info->fences[j].name);
197: break;
198: }
199: case KGSL_CMD_SYNCPOINT_TYPE_TIMELINE: {
200: int j;
201: struct event_timeline_info *info = event->priv;
202: struct dma_fence *fence = event->fence;
203: bool retired = false;
204: bool signaled = test_bit(DMA_FENCE_FLAG_SIGNALED_BIT,
205: &fence->flags);
206: const char *str = NULL;
207:
208: if (fence->ops->signaled && fence->ops->signaled(fence))
209: retired = true;
210:
211: if (!retired)
212: str = "not retired";
213: else if (retired && signaled)
214: str = "signaled";
215: else if (retired && !signaled)
216: str = "retired but not signaled";
217: dev_err(device->dev, " [%u] FENCE %s\n",
218: i, str);
219: for (j = 0; info && info[j].timeline; j++)
220: dev_err(device->dev, " TIMELINE %d SEQNO %lld\n",
221: info[j].timeline, info[j].seqno);
222: break;
223: }
224: }
225: }
226:
227: kgsl_drawobj_put(drawobj);
228: dev_err(device->dev, "--gpu syncpoint deadlock print end--\n");
229: }
230:
231: /*
232: * a generic function to retire a pending sync event and (possibly) kick the
233: * dispatcher.
234: * Returns false if the event was already marked for cancellation in another
235: * thread. This function should return true if this thread is responsible for
236: * freeing up the memory, and the event will not be cancelled.
237: */
238: static bool drawobj_sync_expire(struct kgsl_device *device,
239: struct kgsl_drawobj_sync_event *event)
240: {
241: struct kgsl_drawobj_sync *syncobj = event->syncobj;
242: /*
243: * Clear the event from the pending mask - if it is already clear, then
244: * leave without doing anything useful
245: */
246: if (!test_and_clear_bit(event->id, &syncobj->pending))
247: return false;
248:
249: /*
250: * If no more pending events, delete the timer and schedule the command
251: * for dispatch
252: */
253: if (!kgsl_drawobj_events_pending(event->syncobj)) {
254: kgsl_delete_timer(&syncobj->timer);
255:
256: if (device->ftbl->drawctxt_sched)
257: device->ftbl->drawctxt_sched(device,
258: event->syncobj->base.context);
259: }
260: return true;
261: }
262:
263: /*
264: * This function is called by the GPU event when the sync event timestamp
265: * expires
266: */
267: static void drawobj_sync_func(struct kgsl_device *device,
268: struct kgsl_event_group *group, void *priv, int result)
269: {
270: struct kgsl_drawobj_sync_event *event = priv;
271:
272: trace_syncpoint_timestamp_expire(event->syncobj,
273: event->context, event->timestamp);
274:
275: /*
276: * Put down the context ref count only if
277: * this thread successfully clears the pending bit mask.
278: */
279: if (drawobj_sync_expire(device, event))
280: kgsl_context_put(event->context);
281:
282: kgsl_drawobj_put(&event->syncobj->base);
283: }
284:
285: static void drawobj_sync_timeline_fence_work(struct work_struct *work)
286: {
287: struct kgsl_drawobj_sync_event *event = container_of(work,
288: struct kgsl_drawobj_sync_event, work);
289:
290: dma_fence_put(event->fence);
291: kgsl_drawobj_put(&event->syncobj->base);
292: }
293:
294: static void trace_syncpoint_timeline_fence(struct kgsl_drawobj_sync *syncobj,
295: struct dma_fence *f, bool expire)
296: {
297: struct dma_fence_array *array = to_dma_fence_array(f);
298: struct dma_fence **fences = &f;
299: u32 num_fences = 1;
300: int i;
301:
302: if (array) {
303: num_fences = array->num_fences;
304: fences = array->fences;
305: }
306:
307: for (i = 0; i < num_fences; i++) {
308: char fence_name[KGSL_FENCE_NAME_LEN];
309:
310: snprintf(fence_name, sizeof(fence_name), "%s:%llu",
311: fences[i]->ops->get_timeline_name(fences[i]),
312: fences[i]->seqno);
313: if (expire) {
314: trace_syncpoint_fence_expire(syncobj, fence_name);
315: log_kgsl_syncpoint_fence_expire_event(
316: syncobj->base.context->id, fence_name);
317: } else {
318: trace_syncpoint_fence(syncobj, fence_name);
319: log_kgsl_syncpoint_fence_event(
320: syncobj->base.context->id, fence_name);
321: }
322: }
323: }
324:
325: static void drawobj_sync_timeline_fence_callback(struct dma_fence *f,
326: struct dma_fence_cb *cb)
327: {
328: struct kgsl_drawobj_sync_event *event = container_of(cb,
329: struct kgsl_drawobj_sync_event, cb);
330:
331: trace_syncpoint_timeline_fence(event->syncobj, f, true);
332:
333: /*
334: * Mark the event as synced and then fire off a worker to handle
335: * removing the fence
336: */
337: if (drawobj_sync_expire(event->device, event))
338: queue_work(kgsl_driver.lockless_workqueue, &event->work);
339: }
340:
341: static void syncobj_destroy(struct kgsl_drawobj *drawobj)
342: {
343: struct kgsl_drawobj_sync *syncobj = SYNCOBJ(drawobj);
344: unsigned int i;
345:
346: /* Zap the canary timer */
347: kgsl_delete_timer_sync(&syncobj->timer);
348:
349: /*
350: * Clear all pending events - this will render any subsequent async
351: * callbacks harmless
352: */
353: for (i = 0; i < syncobj->numsyncs; i++) {
354: struct kgsl_drawobj_sync_event *event = &syncobj->synclist[i];
355:
356: /*
357: * Don't do anything if the event has already expired.
358: * If this thread clears the pending bit mask then it is
359: * responsible for doing context put.
360: */
361: if (!test_and_clear_bit(i, &syncobj->pending))
362: continue;
363:
364: switch (event->type) {
365: case KGSL_CMD_SYNCPOINT_TYPE_TIMESTAMP:
366: kgsl_cancel_event(drawobj->device,
367: &event->context->events, event->timestamp,
368: drawobj_sync_func, event);
369: /*
370: * Do context put here to make sure the context is alive
371: * till this thread cancels kgsl event.
372: */
373: kgsl_context_put(event->context);
374: break;
375: case KGSL_CMD_SYNCPOINT_TYPE_FENCE:
376: kgsl_sync_fence_async_cancel(event->handle);
377: kgsl_drawobj_put(drawobj);
378: break;
379: case KGSL_CMD_SYNCPOINT_TYPE_TIMELINE:
380: dma_fence_remove_callback(event->fence, &event->cb);
381: dma_fence_put(event->fence);
382: kgsl_drawobj_put(drawobj);
383: break;
384: }
385: }
386:
387: /*
388: * If we cancelled an event, there's a good chance that the context is
389: * on a dispatcher queue, so schedule to get it removed.
390: */
391: if (!bitmap_empty(&syncobj->pending, KGSL_MAX_SYNCPOINTS) &&
392: drawobj->device->ftbl->drawctxt_sched)
393: drawobj->device->ftbl->drawctxt_sched(drawobj->device,
394: drawobj->context);
395:
396: }
397:
398: static void _drawobj_timelineobj_retire(struct kref *kref)
399: {
400: int i;
401: struct kgsl_drawobj_timeline *timelineobj = container_of(kref,
402: struct kgsl_drawobj_timeline, sig_refcount);
403:
404: for (i = 0; i < timelineobj->count; i++) {
405: kgsl_timeline_signal(timelineobj->timelines[i].timeline,
406: timelineobj->timelines[i].seqno);
407:
408: kgsl_timeline_put(timelineobj->timelines[i].timeline);
409: kgsl_context_put(timelineobj->timelines[i].context);
410: }
411:
412: kvfree(timelineobj->timelines);
413: timelineobj->timelines = NULL;
414: timelineobj->count = 0;
415: }
416:
417: static void kgsl_timelineobj_signal(struct kgsl_drawobj_timeline *timelineobj)
418: {
419: kref_put(&timelineobj->sig_refcount, _drawobj_timelineobj_retire);
420: }
421:
422: static void timelineobj_destroy(struct kgsl_drawobj *drawobj)
423: {
424: struct kgsl_drawobj_timeline *timelineobj = TIMELINEOBJ(drawobj);
425: int i;
426:
427: /*
428: * At this point any syncobjs blocking this timelinobj have been
429: * signaled. The timelineobj now only needs all preceding timestamps to
430: * retire before signaling the timelines. Notify timelines to keep them
431: * in sync with the timestamps as they retire.
432: */
433: for (i = 0; i < timelineobj->count; i++)
434: kgsl_timeline_add_signal(&timelineobj->timelines[i]);
435:
436: /*
437: * The scheduler is done with the timelineobj. Put the initial
438: * sig_refcount to continue with the signaling process.
439: */
440: kgsl_timelineobj_signal(timelineobj);
441: }
442:
443: static void bindobj_destroy(struct kgsl_drawobj *drawobj)
444: {
445: struct kgsl_drawobj_bind *bindobj = BINDOBJ(drawobj);
446:
447: kgsl_sharedmem_put_bind_op(bindobj->bind);
448: }
449:
450: static void cmdobj_destroy(struct kgsl_drawobj *drawobj)
451: {
452: struct kgsl_drawobj_cmd *cmdobj = CMDOBJ(drawobj);
MATCH LINES: 505, 508, 516, 552, 555, 558, 572, 574, 578, 591, 593, 594, 595, 599, 601, 602, 604, 605, 610, 615, 618, 623, 627, 637, 639, 643, 649, 658, 668, 670, 679, 680, 689, 695, 699, 732, 734, 738, 743, 745, 749, 752, 764, 773, 780, 787, 790, 793, 797, 800, 803
493: drawobj->destroy(drawobj);
494:
495: kgsl_drawobj_put(drawobj);
496: }
497:
498: static bool drawobj_sync_fence_func(void *priv)
499: {
500: struct kgsl_drawobj_sync_event *event = priv;
501: struct event_fence_info *info = event->priv;
502: int i;
503:
504: for (i = 0; info && i < info->num_fences; i++) {
505: trace_syncpoint_fence_expire(event->syncobj,
506: info->fences[i].name);
507: log_kgsl_syncpoint_fence_expire_event(
508: event->syncobj->base.context->id, info->fences[i].name);
509: }
510:
511: /*
512: * Only call kgsl_drawobj_put() if it's not marked for cancellation
513: * in another thread.
514: */
515: if (drawobj_sync_expire(event->device, event)) {
516: kgsl_drawobj_put(&event->syncobj->base);
517: return true;
518: }
519: return false;
520: }
521:
522: static struct event_timeline_info *
523: drawobj_get_sync_timeline_priv(void __user *uptr, u64 usize, u32 count)
524: {
525: int i;
526: struct event_timeline_info *priv;
527:
528: /* Make sure we don't accidently overflow count */
529: if (count == UINT_MAX)
530: return NULL;
531:
532: priv = kcalloc(count + 1, sizeof(*priv), GFP_KERNEL);
533: if (!priv)
534: return NULL;
535:
536: for (i = 0; i < count; i++, uptr += usize) {
537: struct kgsl_timeline_val val;
538:
539: if (copy_struct_from_user(&val, sizeof(val), uptr, usize))
540: continue;
541:
542: priv[i].timeline = val.timeline;
543: priv[i].seqno = val.seqno;
544: }
545:
546: priv[i].timeline = 0;
547: return priv;
548: }
549:
550: static int drawobj_add_sync_timeline(struct kgsl_device *device,
551:
552: struct kgsl_drawobj_sync *syncobj, void __user *uptr,
553: u64 usize)
554: {
555: struct kgsl_drawobj *drawobj = DRAWOBJ(syncobj);
556: struct kgsl_cmd_syncpoint_timeline sync;
557: struct kgsl_drawobj_sync_event *event;
558: struct dma_fence *fence;
559: unsigned int id;
560: int ret;
561:
562: if (copy_struct_from_user(&sync, sizeof(sync), uptr, usize))
563: return -EFAULT;
564:
565: fence = kgsl_timelines_to_fence_array(device, sync.timelines,
566: sync.count, sync.timelines_size);
567: if (IS_ERR(fence))
568: return PTR_ERR(fence);
569:
570: kref_get(&drawobj->refcount);
571:
572: id = syncobj->numsyncs++;
573:
574: event = &syncobj->synclist[id];
575:
576: event->id = id;
577: event->type = KGSL_CMD_SYNCPOINT_TYPE_TIMELINE;
578: event->syncobj = syncobj;
579: event->device = device;
580: event->context = NULL;
581: event->fence = fence;
582: INIT_WORK(&event->work, drawobj_sync_timeline_fence_work);
583:
584: INIT_LIST_HEAD(&event->cb.node);
585:
586: event->priv =
587: drawobj_get_sync_timeline_priv(u64_to_user_ptr(sync.timelines),
588: sync.timelines_size, sync.count);
589:
590: /* Set pending flag before adding callback to avoid race */
591: set_bit(event->id, &syncobj->pending);
592:
593: /* Get a dma_fence refcount to hand over to the callback */
594: dma_fence_get(event->fence);
595: ret = dma_fence_add_callback(event->fence,
596: &event->cb, drawobj_sync_timeline_fence_callback);
597:
598: if (ret) {
599: clear_bit(event->id, &syncobj->pending);
600:
601: if (dma_fence_is_signaled(event->fence)) {
602: trace_syncpoint_fence_expire(syncobj, "signaled");
603: log_kgsl_syncpoint_fence_expire_event(
604: syncobj->base.context->id, "signaled");
605: dma_fence_put(event->fence);
606: ret = 0;
607: }
608:
609: /* Put the refcount from fence creation */
610: dma_fence_put(event->fence);
611: kgsl_drawobj_put(drawobj);
612: return ret;
613: }
614:
615: trace_syncpoint_timeline_fence(event->syncobj, event->fence, false);
616:
617: /* Put the refcount from fence creation */
618: dma_fence_put(event->fence);
619: return 0;
620: }
621:
622: static int drawobj_add_sync_fence(struct kgsl_device *device,
623: struct kgsl_drawobj_sync *syncobj, void __user *data,
624: u64 datasize)
625: {
626: struct kgsl_cmd_syncpoint_fence sync;
627: struct kgsl_drawobj *drawobj = DRAWOBJ(syncobj);
628: struct kgsl_drawobj_sync_event *event;
629: struct event_fence_info *priv;
630: unsigned int id, i;
631:
632: if (copy_struct_from_user(&sync, sizeof(sync), data, datasize))
633: return -EFAULT;
634:
635: kref_get(&drawobj->refcount);
636:
637: id = syncobj->numsyncs++;
638:
639: event = &syncobj->synclist[id];
640:
641: event->id = id;
642: event->type = KGSL_CMD_SYNCPOINT_TYPE_FENCE;
643: event->syncobj = syncobj;
644: event->device = device;
645: event->context = NULL;
646:
647: priv = kzalloc(sizeof(*priv), GFP_KERNEL);
648:
649: set_bit(event->id, &syncobj->pending);
650:
651: event->handle = kgsl_sync_fence_async_wait(sync.fd, drawobj_sync_fence_func, event);
652:
653: event->priv = priv;
654:
655: if (IS_ERR_OR_NULL(event->handle)) {
656: int ret = PTR_ERR(event->handle);
657:
658: clear_bit(event->id, &syncobj->pending);
659: event->handle = NULL;
660:
661: kgsl_drawobj_put(drawobj);
662:
663: /*
664: * If ret == 0 the fence was already signaled - print a trace
665: * message so we can track that
666: */
667: if (ret == 0) {
668: trace_syncpoint_fence_expire(syncobj, "signaled");
669: log_kgsl_syncpoint_fence_expire_event(
670: syncobj->base.context->id, "signaled");
671: }
672:
673: return ret;
674: }
675:
676: kgsl_get_fence_info(event);
677:
678: for (i = 0; priv && i < priv->num_fences; i++) {
679: trace_syncpoint_fence(syncobj, priv->fences[i].name);
680: log_kgsl_syncpoint_fence_event(syncobj->base.context->id,
681: priv->fences[i].name);
682: }
683:
684: return 0;
685: }
686:
687: /* drawobj_add_sync_timestamp() - Add a new sync point for a sync obj
688: * @device: KGSL device
689: * @syncobj: KGSL sync obj to add the sync point to
690: * @priv: Private structure passed by the user
691: *
692: * Add a new sync point timestamp event to the sync obj.
693: */
694: static int drawobj_add_sync_timestamp(struct kgsl_device *device,
695: struct kgsl_drawobj_sync *syncobj,
696: struct kgsl_cmd_syncpoint_timestamp *timestamp)
697:
698: {
699: struct kgsl_drawobj *drawobj = DRAWOBJ(syncobj);
700: struct kgsl_context *context = kgsl_context_get(device,
701: timestamp->context_id);
702: struct kgsl_drawobj_sync_event *event;
703: int ret = -EINVAL;
704: unsigned int id;
705:
706: if (context == NULL)
707: return -EINVAL;
708:
709: /*
710: * We allow somebody to create a sync point on their own context.
711: * This has the effect of delaying a command from submitting until the
712: * dependent command has cleared. That said we obviously can't let them
713: * create a sync point on a future timestamp.
714: */
715:
716: if (context == drawobj->context) {
717: unsigned int queued;
718:
719: kgsl_readtimestamp(device, context, KGSL_TIMESTAMP_QUEUED,
720: &queued);
721:
722: if (timestamp_cmp(timestamp->timestamp, queued) > 0) {
723: dev_err(device->dev,
724: "Cannot create syncpoint for future timestamp %d (current %d)\n",
725: timestamp->timestamp, queued);
726: goto done;
727: }
728: }
729:
730: kref_get(&drawobj->refcount);
731:
732: id = syncobj->numsyncs++;
733:
734: event = &syncobj->synclist[id];
735: event->id = id;
736:
737: event->type = KGSL_CMD_SYNCPOINT_TYPE_TIMESTAMP;
738: event->syncobj = syncobj;
739: event->context = context;
740: event->timestamp = timestamp->timestamp;
741: event->device = device;
742:
743: set_bit(event->id, &syncobj->pending);
744:
745: ret = kgsl_add_event(device, &context->events, timestamp->timestamp,
746: drawobj_sync_func, event);
747:
748: if (ret) {
749: clear_bit(event->id, &syncobj->pending);
750: kgsl_drawobj_put(drawobj);
751: } else {
752: trace_syncpoint_timestamp(syncobj, context,
753: timestamp->timestamp);
754: }
755:
756: done:
757: if (ret)
758: kgsl_context_put(context);
759:
760: return ret;
761: }
762:
763: static int drawobj_add_sync_timestamp_from_user(struct kgsl_device *device,
764: struct kgsl_drawobj_sync *syncobj, void __user *data,
765: u64 datasize)
766: {
767: struct kgsl_cmd_syncpoint_timestamp timestamp;
768:
769: if (copy_struct_from_user(×tamp, sizeof(timestamp),
770: data, datasize))
771: return -EFAULT;
772:
773: return drawobj_add_sync_timestamp(device, syncobj, ×tamp);
774: }
775:
776: /**
777: * kgsl_drawobj_sync_add_sync() - Add a sync point to a command
778: * batch
779: * @device: Pointer to the KGSL device struct for the GPU
780: * @syncobj: Pointer to the sync obj
781: * @sync: Pointer to the user-specified struct defining the syncpoint
782: *
783: * Create a new sync point in the sync obj based on the
784: * user specified parameters
785: */
786: int kgsl_drawobj_sync_add_sync(struct kgsl_device *device,
787: struct kgsl_drawobj_sync *syncobj,
788: struct kgsl_cmd_syncpoint *sync)
789: {
790: struct kgsl_drawobj *drawobj = DRAWOBJ(syncobj);
791:
792: if (sync->type != KGSL_CMD_SYNCPOINT_TYPE_FENCE)
793: set_bit(KGSL_SYNCOBJ_SW, &syncobj->flags);
794:
795: if (sync->type == KGSL_CMD_SYNCPOINT_TYPE_TIMESTAMP)
796: return drawobj_add_sync_timestamp_from_user(device,
797: syncobj, sync->priv, sync->size);
798: else if (sync->type == KGSL_CMD_SYNCPOINT_TYPE_FENCE)
799: return drawobj_add_sync_fence(device,
800: syncobj, sync->priv, sync->size);
801: else if (sync->type == KGSL_CMD_SYNCPOINT_TYPE_TIMELINE)
802: return drawobj_add_sync_timeline(device,
803: syncobj, sync->priv, sync->size);
804:
805: dev_err(device->dev, "bad syncpoint type %d for ctxt %u\n",
806: sync->type, drawobj->context->id);
807:
808: return -EINVAL;
809: }
810:
811: static void add_profiling_buffer(struct kgsl_device *device,
812: struct kgsl_drawobj_cmd *cmdobj,
813: uint64_t gpuaddr, uint64_t size,
814: unsigned int id, uint64_t offset)
815: {
816: struct kgsl_mem_entry *entry;
817: struct kgsl_drawobj *drawobj = DRAWOBJ(cmdobj);
818: u64 start;
819:
820: if (!(drawobj->flags & KGSL_DRAWOBJ_PROFILING))
821: return;
822:
823: /* Only the first buffer entry counts - ignore the rest */
824: if (cmdobj->profiling_buf_entry != NULL)
825: return;
826:
827: if (id != 0)
MATCH LINES: 889
877: ibdesc->ctrl &= KGSL_IBDESC_MEMLIST | KGSL_IBDESC_PROFILING_BUFFER;
878:
879: if (drawobj->flags & KGSL_DRAWOBJ_MEMLIST &&
880: ibdesc->ctrl & KGSL_IBDESC_MEMLIST) {
881: if (ibdesc->ctrl & KGSL_IBDESC_PROFILING_BUFFER) {
882: add_profiling_buffer(device, cmdobj,
883: gpuaddr, size, 0, 0);
884: return 0;
885: }
886: }
887:
888: /* Ignore if SYNC or MARKER is specified */
889: if (drawobj->type & (SYNCOBJ_TYPE | MARKEROBJ_TYPE))
890: return 0;
891:
892: mem = kmem_cache_alloc(memobjs_cache, GFP_KERNEL);
893: if (mem == NULL)
894: return -ENOMEM;
895:
896: mem->gpuaddr = gpuaddr;
897: mem->size = size;
898: mem->priv = 0;
899: mem->id = 0;
900: mem->offset = 0;
901: mem->flags = 0;
902:
903: if (drawobj->flags & KGSL_DRAWOBJ_MEMLIST &&
904: ibdesc->ctrl & KGSL_IBDESC_MEMLIST)
905: /* add to the memlist */
906: list_add_tail(&mem->node, &cmdobj->memlist);
907: else {
908: /* set the preamble flag if directed to */
909: if (drawobj->context->flags & KGSL_CONTEXT_PREAMBLE &&
910: list_empty(&cmdobj->cmdlist))
911: mem->flags = KGSL_CMDLIST_CTXTSWITCH_PREAMBLE;
912:
913: /* add to the cmd list */
MATCH LINES: 981
969:
970: ret = drawobj_init(device, context, &timelineobj->base,
971: TIMELINEOBJ_TYPE);
972: if (ret) {
973: kfree(timelineobj);
974: return ERR_PTR(ret);
975: }
976:
977: /*
978: * Initialize the sig_refcount that triggers the timeline signal.
979: * This refcount goes to 0 when:
980: * 1) This timelineobj is popped off the context queue. This implies
981: * any syncobj blocking this timelineobj was already signaled, or
982: * the context queue is cleaned up at detach time.
983: * 2) The cmdobjs queued on this context before this timeline object
984: * are retired.
985: */
986: kref_init(&timelineobj->sig_refcount);
987:
988: timelineobj->base.destroy = timelineobj_destroy;
989: timelineobj->base.destroy_object = timelineobj_destroy_object;
990:
991: return timelineobj;
992: }
993:
994: static void _timeline_signaled(struct kgsl_device *device,
995: struct kgsl_event_group *group, void *priv, int ret)
996: {
997: struct kgsl_drawobj_timeline *timelineobj = priv;
998: struct kgsl_drawobj *drawobj = DRAWOBJ(timelineobj);
999:
1000: /* Put the sig_refcount we took when registering this event */
1001: kgsl_timelineobj_signal(timelineobj);
1002:
1003: /* Put the drawobj refcount we took when registering this event */
1004: kgsl_drawobj_put(drawobj);
1005: }
MATCH LINES: 1088
1076: }
1077:
1078: timelineobj->count = cmd.count;
1079:
1080: /*
1081: * Register a kgsl_event to notify us when the last queued timestamp
1082: * retires. Take a refcount on the drawobj to keep it valid for the
1083: * callback, and take the sig_refcount to synchronize with the
1084: * timelineobj retire. Both these refcounts are put in the callback.
1085: */
1086: kref_get(&drawobj->refcount);
1087: kref_get(&timelineobj->sig_refcount);
1088: ret = kgsl_add_event(device, &context->events, queued,
1089: _timeline_signaled, timelineobj);
1090:
1091: if (ret)
1092: goto event_err;
1093:
1094: return 0;
1095:
1096: event_err:
1097: /*
1098: * If there was an error, put back sig_refcount and drawobj refcounts.
1099: * The caller still holds initial refcounts on both and puts them in
1100: * kgsl_drawobj_destroy(). Clean up the timelinelines array since we
1101: * do not want to signal anything now.
1102: */
1103: kgsl_timelineobj_signal(timelineobj);
1104: kgsl_drawobj_put(drawobj);
1105: err:
1106: for (i = 0; i < cmd.count; i++) {
1107: kgsl_timeline_put(timelineobj->timelines[i].timeline);
1108: kgsl_context_put(timelineobj->timelines[i].context);
1109: }
1110:
1111: kvfree(timelineobj->timelines);
1112: timelineobj->timelines = NULL;
MATCH LINES: 1196, 1197, 1200, 1203, 1205, 1209, 1210, 1212, 1214
1184:
1185: /**
1186: * kgsl_drawobj_sync_create() - Create a new sync obj
1187: * structure
1188: * @device: Pointer to a KGSL device struct
1189: * @context: Pointer to a KGSL context struct
1190: *
1191: * Allocate an new kgsl_drawobj_sync structure
1192: */
1193: struct kgsl_drawobj_sync *kgsl_drawobj_sync_create(struct kgsl_device *device,
1194: struct kgsl_context *context)
1195: {
1196: struct kgsl_drawobj_sync *syncobj =
1197: kzalloc(sizeof(*syncobj), GFP_KERNEL);
1198: int ret;
1199:
1200: if (!syncobj)
1201: return ERR_PTR(-ENOMEM);
1202:
1203: ret = drawobj_init(device, context, &syncobj->base, SYNCOBJ_TYPE);
1204: if (ret) {
1205: kfree(syncobj);
1206: return ERR_PTR(ret);
1207: }
1208:
1209: syncobj->base.destroy = syncobj_destroy;
1210: syncobj->base.destroy_object = syncobj_destroy_object;
1211:
1212: timer_setup(&syncobj->timer, syncobj_timer, 0);
1213:
1214: return syncobj;
1215: }
1216:
1217: /**
1218: * kgsl_drawobj_cmd_create() - Create a new command obj
1219: * structure
1220: * @device: Pointer to a KGSL device struct
1221: * @context: Pointer to a KGSL context struct
1222: * @flags: Flags for the command obj
1223: * @type: type of cmdobj MARKER/CMD
1224: *
1225: * Allocate a new kgsl_drawobj_cmd structure
1226: */
1227: struct kgsl_drawobj_cmd *kgsl_drawobj_cmd_create(struct kgsl_device *device,
1228: struct kgsl_context *context, unsigned int flags,
1229: unsigned int type)
1230: {
1231: struct kgsl_drawobj_cmd *cmdobj = kzalloc(sizeof(*cmdobj), GFP_KERNEL);
1232: int ret;
1233:
1234: if (!cmdobj)
1235: return ERR_PTR(-ENOMEM);
1236:
1237: ret = drawobj_init(device, context, &cmdobj->base,
1238: (type & (CMDOBJ_TYPE | MARKEROBJ_TYPE)));
MATCH LINES: 1315, 1333, 1350
1303:
1304: ret = kgsl_drawobj_cmd_add_ibdesc(device, cmdobj, &ibdesc);
1305: if (ret)
1306: break;
1307:
1308: ptr += sizeof(ibdesc32);
1309: }
1310:
1311: return ret;
1312: }
1313:
1314: static int add_syncpoints_compat(struct kgsl_device *device,
1315: struct kgsl_drawobj_sync *syncobj, void __user *ptr, int count)
1316: {
1317: struct kgsl_cmd_syncpoint_compat sync32;
1318: struct kgsl_cmd_syncpoint sync;
1319: int i, ret = 0;
1320:
1321: for (i = 0; i < count; i++) {
1322: memset(&sync32, 0, sizeof(sync32));
1323:
1324: if (copy_from_user(&sync32, ptr, sizeof(sync32))) {
1325: ret = -EFAULT;
1326: break;
1327: }
1328:
1329: sync.type = sync32.type;
1330: sync.priv = compat_ptr(sync32.priv);
1331: sync.size = (size_t) sync32.size;
1332:
1333: ret = kgsl_drawobj_sync_add_sync(device, syncobj, &sync);
1334: if (ret)
1335: break;
1336:
1337: ptr += sizeof(sync32);
1338: }
1339:
1340: return ret;
1341: }
1342: #else
1343: static int add_ibdesc_list_compat(struct kgsl_device *device,
1344: struct kgsl_drawobj_cmd *cmdobj, void __user *ptr, int count)
1345: {
1346: return -EINVAL;
1347: }
1348:
1349: static int add_syncpoints_compat(struct kgsl_device *device,
1350: struct kgsl_drawobj_sync *syncobj, void __user *ptr, int count)
1351: {
1352: return -EINVAL;
1353: }
1354: #endif
1355:
1356: /* Returns:
1357: * -EINVAL: Bad data
1358: * 0: All data fields are empty (nothing to do)
1359: * 1: All list information is valid
1360: */
1361: static int _verify_input_list(unsigned int count, void __user *ptr,
1362: unsigned int size)
1363: {
1364: /* Return early if nothing going on */
1365: if (count == 0 && ptr == NULL && size == 0)
1366: return 0;
1367:
1368: /* Sanity check inputs */
1369: if (count == 0 || ptr == NULL || size == 0)
1370: return -EINVAL;
1371:
1372: return 1;
1373: }
1374:
MATCH LINES: 1410, 1418, 1421, 1425, 1433
1398:
1399: ret = kgsl_drawobj_cmd_add_ibdesc(device, cmdobj, &ibdesc);
1400: if (ret)
1401: return ret;
1402:
1403: ptr += sizeof(ibdesc);
1404: }
1405:
1406: return 0;
1407: }
1408:
1409: int kgsl_drawobj_sync_add_syncpoints(struct kgsl_device *device,
1410: struct kgsl_drawobj_sync *syncobj, void __user *ptr, int count)
1411: {
1412: struct kgsl_cmd_syncpoint sync;
1413: int i, ret;
1414:
1415: if (count == 0)
1416: return 0;
1417:
1418: syncobj->synclist = kcalloc(count,
1419: sizeof(struct kgsl_drawobj_sync_event), GFP_KERNEL);
1420:
1421: if (syncobj->synclist == NULL)
1422: return -ENOMEM;
1423:
1424: if (is_compat_task())
1425: return add_syncpoints_compat(device, syncobj, ptr, count);
1426:
1427: for (i = 0; i < count; i++) {
1428: memset(&sync, 0, sizeof(sync));
1429:
1430: if (copy_from_user(&sync, ptr, sizeof(sync)))
1431: return -EFAULT;
1432:
1433: ret = kgsl_drawobj_sync_add_sync(device, syncobj, &sync);
1434: if (ret)
1435: return ret;
1436:
1437: ptr += sizeof(sync);
1438: }
1439:
1440: return 0;
1441: }
1442:
1443: static int kgsl_drawobj_add_memobject(struct list_head *head,
1444: struct kgsl_command_object *obj)
1445: {
1446: struct kgsl_memobj_node *mem;
1447:
1448: mem = kmem_cache_alloc(memobjs_cache, GFP_KERNEL);
1449: if (mem == NULL)
1450: return -ENOMEM;
1451:
1452: mem->gpuaddr = obj->gpuaddr;
1453: mem->size = obj->size;
1454: mem->id = obj->id;
1455: mem->offset = obj->offset;
1456: mem->flags = obj->flags;
1457: mem->priv = 0;
MATCH LINES: 1554, 1557, 1561, 1562, 1563, 1565, 1566, 1567, 1574, 1576, 1580, 1584, 1596, 1599, 1610
1542: &obj);
1543: if (ret)
1544: return ret;
1545: }
1546:
1547: ptr += sizeof(obj);
1548: }
1549:
1550: return 0;
1551: }
1552:
1553: struct kgsl_drawobj_sync *
1554: kgsl_drawobj_create_timestamp_syncobj(struct kgsl_device *device,
1555: struct kgsl_context *context, unsigned int timestamp)
1556: {
1557: struct kgsl_drawobj_sync *syncobj;
1558: struct kgsl_cmd_syncpoint_timestamp priv;
1559: int ret;
1560:
1561: syncobj = kgsl_drawobj_sync_create(device, context);
1562: if (IS_ERR(syncobj))
1563: return syncobj;
1564:
1565: syncobj->synclist = kzalloc(sizeof(*syncobj->synclist), GFP_KERNEL);
1566: if (!syncobj->synclist) {
1567: kgsl_drawobj_destroy(DRAWOBJ(syncobj));
1568: return ERR_PTR(-ENOMEM);
1569: }
1570:
1571: priv.timestamp = timestamp;
1572: priv.context_id = context->id;
1573:
1574: ret = drawobj_add_sync_timestamp(device, syncobj, &priv);
1575: if (ret) {
1576: kgsl_drawobj_destroy(DRAWOBJ(syncobj));
1577: return ERR_PTR(ret);
1578: }
1579:
1580: return syncobj;
1581: }
1582:
1583: int kgsl_drawobj_sync_add_synclist(struct kgsl_device *device,
1584: struct kgsl_drawobj_sync *syncobj, void __user *ptr,
1585: unsigned int size, unsigned int count)
1586: {
1587: struct kgsl_command_syncpoint syncpoint;
1588: struct kgsl_cmd_syncpoint sync;
1589: int i, ret;
1590:
1591: /* If creating a sync and the data is not there or wrong then error */
1592: ret = _verify_input_list(count, ptr, size);
1593: if (ret <= 0)
1594: return -EINVAL;
1595:
1596: syncobj->synclist = kcalloc(count,
1597: sizeof(struct kgsl_drawobj_sync_event), GFP_KERNEL);
1598:
1599: if (syncobj->synclist == NULL)
1600: return -ENOMEM;
1601:
1602: for (i = 0; i < count; i++) {
1603: if (copy_struct_from_user(&syncpoint, sizeof(syncpoint), ptr, size))
1604: return -EFAULT;
1605:
1606: sync.type = syncpoint.type;
1607: sync.priv = u64_to_user_ptr(syncpoint.priv);
1608: sync.size = syncpoint.size;
1609:
1610: ret = kgsl_drawobj_sync_add_sync(device, syncobj, &sync);
1611: if (ret)
1612: return ret;
1613:
1614: ptr += sizeof(syncpoint);
1615: }
1616:
1617: return 0;
1618: }
1619:
1620: void kgsl_drawobjs_cache_exit(void)
1621: {
1622: kmem_cache_destroy(memobjs_cache);
1623: }
1624:
1625: int kgsl_drawobjs_cache_init(void)
1626: {
1627: memobjs_cache = KMEM_CACHE(kgsl_memobj_node, 0);
1628:
1629: if (!memobjs_cache)
1630: return -ENOMEM;
1631:
1632: return 0;
1633: }
--- FILE: \kgsl_drawobj.h | HITS: 23 ---
MATCH LINES: 14, 21
2: /*
3: * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
5: */
6:
7: #ifndef __KGSL_DRAWOBJ_H
8: #define __KGSL_DRAWOBJ_H
9:
10: #include <linux/dma-fence.h>
11: #include <linux/kref.h>
12:
13: #define DRAWOBJ(obj) (&obj->base)
14: #define SYNCOBJ(obj) \
15: container_of(obj, struct kgsl_drawobj_sync, base)
16: #define CMDOBJ(obj) \
17: container_of(obj, struct kgsl_drawobj_cmd, base)
18:
19: #define CMDOBJ_TYPE BIT(0)
20: #define MARKEROBJ_TYPE BIT(1)
21: #define SYNCOBJ_TYPE BIT(2)
22: #define BINDOBJ_TYPE BIT(3)
23: #define TIMELINEOBJ_TYPE BIT(4)
24:
25: /**
26: * struct kgsl_drawobj - KGSL drawobj descriptor
27: * @device: KGSL GPU device that the command was created for
28: * @context: KGSL context that created the command
29: * @type: Object type
30: * @timestamp: Timestamp assigned to the command
31: * @flags: flags
32: * @refcount: kref structure to maintain the reference count
33: */
34: struct kgsl_drawobj {
35: struct kgsl_device *device;
36: struct kgsl_context *context;
37: uint32_t type;
38: uint32_t timestamp;
39: unsigned long flags;
40: struct kref refcount;
41: /** @destroy: Callbak function to take down the object */
42: void (*destroy)(struct kgsl_drawobj *drawobj);
43: /** @destroy_object: Callback function to free the object memory */
44: void (*destroy_object)(struct kgsl_drawobj *drawobj);
45: };
MATCH LINES: 93, 95, 97, 101, 128, 131
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: /**
103: * context: Pointer to kgsl context if this hardware fence is owned by a kgsl context
104: */
105: struct kgsl_context *context;
106: };
107:
108: /**
109: * struct kgsl_drawobj_sync - KGSL sync object
110: * @base: Base kgsl_drawobj, this needs to be the first entry
111: * @synclist: Array of context/timestamp tuples to wait for before issuing
112: * @numsyncs: Number of sync entries in the array
113: * @pending: Bitmask of sync events that are active
114: * @timer: a timer used to track possible sync timeouts for this
115: * sync obj
116: * @timeout_jiffies: For a sync obj the jiffies at
117: * which the timer will expire
118: */
119: struct kgsl_drawobj_sync {
120: struct kgsl_drawobj base;
121: struct kgsl_drawobj_sync_event *synclist;
122: unsigned int numsyncs;
123: unsigned long pending;
124: struct timer_list timer;
125: unsigned long timeout_jiffies;
126: /** @flags: sync object internal flags */
127: unsigned long flags;
128: /** @num_hw_fence: number of hw fences in this syncobj */
129: u32 num_hw_fence;
130: /**
131: * @hw_fences: Array to hold information regarding hardware fences that are in this syncobj
132: */
133: struct kgsl_drawobj_sync_hw_fence *hw_fences;
134: };
135:
136: #define KGSL_BINDOBJ_STATE_START 0
137: #define KGSL_BINDOBJ_STATE_DONE 1
138:
139: /**
140: * struct kgsl_drawobj_bind - KGSL virtual buffer object bind operation
141: * @base: &struct kgsl_drawobj container
142: * @state: Current state of the draw operation
143: * @bind: Pointer to the VBO bind operation struct
144: */
145: struct kgsl_drawobj_bind {
146: struct kgsl_drawobj base;
147: unsigned long state;
148: struct kgsl_sharedmem_bind_op *bind;
149: };
150:
151: static inline struct kgsl_drawobj_bind *BINDOBJ(struct kgsl_drawobj *obj)
152: {
153: return container_of(obj, struct kgsl_drawobj_bind, base);
154: }
155:
MATCH LINES: 196, 206, 217, 219
184: int num_fences;
185: };
186:
187: struct event_timeline_info {
188: u64 seqno;
189: u32 timeline;
190: };
191:
192: /**
193: * struct kgsl_drawobj_sync_event
194: * @id: identifer (positiion within the pending bitmap)
195: * @type: Syncpoint type
196: * @syncobj: Pointer to the syncobj that owns the sync event
197: * @context: KGSL context for whose timestamp we want to
198: * register this event
199: * @timestamp: Pending timestamp for the event
200: * @handle: Pointer to a sync fence handle
201: * @device: Pointer to the KGSL device
202: */
203: struct kgsl_drawobj_sync_event {
204: unsigned int id;
205: int type;
206: struct kgsl_drawobj_sync *syncobj;
207: struct kgsl_context *context;
208: unsigned int timestamp;
209: struct kgsl_sync_fence_cb *handle;
210: struct kgsl_device *device;
211: /** @priv: Type specific private information */
212: void *priv;
213: /**
214: * @fence: Pointer to a dma fence for KGSL_CMD_SYNCPOINT_TYPE_TIMELINE
215: * events
216: */
217: struct dma_fence *fence;
218: /** @cb: Callback struct for KGSL_CMD_SYNCPOINT_TYPE_TIMELINE */
219: struct dma_fence_cb cb;
220: /** @work : work_struct for KGSL_CMD_SYNCPOINT_TYPE_TIMELINE */
221: struct work_struct work;
222: };
223:
224: #define KGSL_DRAWOBJ_FLAGS \
225: { KGSL_DRAWOBJ_MARKER, "MARKER" }, \
226: { KGSL_DRAWOBJ_CTX_SWITCH, "CTX_SWITCH" }, \
227: { KGSL_DRAWOBJ_SYNC, "SYNC" }, \
228: { KGSL_DRAWOBJ_END_OF_FRAME, "EOF" }, \
229: { KGSL_DRAWOBJ_PWR_CONSTRAINT, "PWR_CONSTRAINT" }, \
230: { KGSL_DRAWOBJ_SUBMIT_IB_LIST, "IB_LIST" }, \
231: { KGSL_DRAWOBJ_USES_MALU, "MALU" }
232:
233: /**
234: * enum kgsl_drawobj_cmd_priv - Internal command obj flags
235: * @CMDOBJ_SKIP - skip the entire command obj
236: * @CMDOBJ_FORCE_PREAMBLE - Force the preamble on for
237: * command obj
238: * @CMDOBJ_WFI - Force wait-for-idle for the submission
239: * @CMDOBJ_PROFILE - store the start / retire ticks for
240: * @CMDOBJ_FAULT - Mark the command object as faulted
241: * the command obj in the profiling buffer
242: * @CMDOBJ_RECURRING_START: To track recurring command object at GMU
243: * @CMDOBJ_RECURRING_STOP: To untrack recurring command object from GMU
MATCH LINES: 279, 282, 285, 292, 299, 301, 305, 310, 320, 322, 329
267: int kgsl_drawobj_cmd_add_ibdesc_list(struct kgsl_device *device,
268: struct kgsl_drawobj_cmd *cmdobj, void __user *ptr, int count);
269: int kgsl_drawobj_cmd_add_cmdlist(struct kgsl_device *device,
270: struct kgsl_drawobj_cmd *cmdobj, void __user *ptr,
271: unsigned int size, unsigned int count);
272: int kgsl_drawobj_cmd_add_memlist(struct kgsl_device *device,
273: struct kgsl_drawobj_cmd *cmdobj, void __user *ptr,
274: unsigned int size, unsigned int count);
275:
276: struct kgsl_drawobj_sync *kgsl_drawobj_sync_create(struct kgsl_device *device,
277: struct kgsl_context *context);
278: int kgsl_drawobj_sync_add_syncpoints(struct kgsl_device *device,
279: struct kgsl_drawobj_sync *syncobj, void __user *ptr,
280: int count);
281: int kgsl_drawobj_sync_add_synclist(struct kgsl_device *device,
282: struct kgsl_drawobj_sync *syncobj, void __user *ptr,
283: unsigned int size, unsigned int count);
284: int kgsl_drawobj_sync_add_sync(struct kgsl_device *device,
285: struct kgsl_drawobj_sync *syncobj,
286: struct kgsl_cmd_syncpoint *sync);
287:
288: int kgsl_drawobjs_cache_init(void);
289: void kgsl_drawobjs_cache_exit(void);
290:
291: void kgsl_dump_syncpoints(struct kgsl_device *device,
292: struct kgsl_drawobj_sync *syncobj);
293:
294: void kgsl_drawobj_destroy(struct kgsl_drawobj *drawobj);
295:
296: void kgsl_drawobj_destroy_object(struct kref *kref);
297:
298: static inline bool kgsl_drawobj_events_pending(
299: struct kgsl_drawobj_sync *syncobj)
300: {
301: return !bitmap_empty(&syncobj->pending, KGSL_MAX_SYNCPOINTS);
302: }
303:
304: static inline bool kgsl_drawobj_event_pending(
305: struct kgsl_drawobj_sync *syncobj, unsigned int bit)
306: {
307: if (bit >= KGSL_MAX_SYNCPOINTS)
308: return false;
309:
310: return test_bit(bit, &syncobj->pending);
311: }
312:
313: static inline void kgsl_drawobj_put(struct kgsl_drawobj *drawobj)
314: {
315: if (drawobj)
316: kref_put(&drawobj->refcount, kgsl_drawobj_destroy_object);
317: }
318:
319: /**
320: * kgsl_drawobj_create_timestamp_syncobj - Create a syncobj for a timestamp
321: * @device: A GPU device handle
322: * @context: Draw context for the syncobj
323: * @timestamp: Timestamp to sync on
324: *
325: * Create a sync object for @timestamp on @context.
326: * Return: A pointer to the sync object
327: */
328: struct kgsl_drawobj_sync *
329: kgsl_drawobj_create_timestamp_syncobj(struct kgsl_device *device,
330: struct kgsl_context *context, unsigned int timestamp);
331:
332: struct kgsl_drawobj_bind *kgsl_drawobj_bind_create(struct kgsl_device *device,
333: struct kgsl_context *context);
334:
335: int kgsl_drawobj_add_bind(struct kgsl_device_private *dev_priv,
336: struct kgsl_drawobj_bind *bindobj,
337: void __user *src, u64 cmdsize);
338:
339: /**
340: * kgsl_drawobj_timeline_create - Create a timeline draw object
341: * @device: A GPU device handle
342: * @context: Draw context for the drawobj
343: *
344: * Create a timeline draw object on @context.
345: * Return: A pointer to the draw object
346: */
347: struct kgsl_drawobj_timeline *
348: kgsl_drawobj_timeline_create(struct kgsl_device *device,
349: struct kgsl_context *context);
350:
351: /**
352: * kgsl_drwobj_add_timeline - Add a timeline to a timeline drawobj
353: * @dev_priv: Pointer to the process private data
--- FILE: \kgsl_events.c | HITS: 9 ---
MATCH LINES: 137, 142, 158, 162, 176, 183
125: * kgsl_flush_event_group() - flush all the events in a group by retiring the
126: * ones can be retired and cancelling the ones that are pending
127: * @device: Pointer to a KGSL device
128: * @group: Pointer to a GPU events group to process
129: */
130: void kgsl_flush_event_group(struct kgsl_device *device,
131: struct kgsl_event_group *group)
132: {
133: _process_event_group(device, group, true);
134: }
135:
136: /**
137: * kgsl_cancel_events_timestamp() - Cancel pending events for a given timestamp
138: * @device: Pointer to a KGSL device
139: * @group: Ponter to the GPU event group that owns the event
140: * @timestamp: Registered expiry timestamp for the event
141: */
142: void kgsl_cancel_events_timestamp(struct kgsl_device *device,
143: struct kgsl_event_group *group, unsigned int timestamp)
144: {
145: struct kgsl_event *event, *tmp;
146:
147: spin_lock(&group->lock);
148:
149: list_for_each_entry_safe(event, tmp, &group->events, node) {
150: if (timestamp_cmp(timestamp, event->timestamp) == 0)
151: signal_event(device, event, KGSL_EVENT_CANCELLED);
152: }
153:
154: spin_unlock(&group->lock);
155: }
156:
157: /**
158: * kgsl_cancel_events() - Cancel all pending events in the group
159: * @device: Pointer to a KGSL device
160: * @group: Pointer to a kgsl_events_group
161: */
162: void kgsl_cancel_events(struct kgsl_device *device,
163: struct kgsl_event_group *group)
164: {
165: struct kgsl_event *event, *tmp;
166:
167: spin_lock(&group->lock);
168:
169: list_for_each_entry_safe(event, tmp, &group->events, node)
170: signal_event(device, event, KGSL_EVENT_CANCELLED);
171:
172: spin_unlock(&group->lock);
173: }
174:
175: /**
176: * kgsl_cancel_event() - Cancel a specific event from a group
177: * @device: Pointer to a KGSL device
178: * @group: Pointer to the group that contains the events
179: * @timestamp: Registered expiry timestamp for the event
180: * @func: Registered callback for the function
181: * @priv: Registered priv data for the function
182: */
183: void kgsl_cancel_event(struct kgsl_device *device,
184: struct kgsl_event_group *group, unsigned int timestamp,
185: kgsl_event_func func, void *priv)
186: {
187: struct kgsl_event *event, *tmp;
188:
189: spin_lock(&group->lock);
190:
191: list_for_each_entry_safe(event, tmp, &group->events, node) {
192: if (timestamp == event->timestamp && func == event->func &&
193: event->priv == priv) {
194: signal_event(device, event, KGSL_EVENT_CANCELLED);
195: break;
196: }
197: }
198:
199: spin_unlock(&group->lock);
200: }
201:
202: /**
203: * kgsl_event_pending() - Searches for an event in an event group
204: * @device: Pointer to a KGSL device
205: * @group: Pointer to the group that contains the events
206: * @timestamp: Registered expiry timestamp for the event
207: * @func: Registered callback for the function
MATCH LINES: 229, 236
217: spin_lock(&group->lock);
218: list_for_each_entry(event, &group->events, node) {
219: if (timestamp == event->timestamp && func == event->func &&
220: event->priv == priv) {
221: result = true;
222: break;
223: }
224: }
225: spin_unlock(&group->lock);
226: return result;
227: }
228: /**
229: * kgsl_add_event() - Add a new GPU event to a group
230: * @device: Pointer to a KGSL device
231: * @group: Pointer to the group to add the event to
232: * @timestamp: Timestamp that the event will expire on
233: * @func: Callback function for the event
234: * @priv: Private data to send to the callback function
235: */
236: int kgsl_add_event(struct kgsl_device *device, struct kgsl_event_group *group,
237: unsigned int timestamp, kgsl_event_func func, void *priv)
238: {
239: unsigned int queued;
240: struct kgsl_context *context = group->context;
241: struct kgsl_event *event;
242: unsigned int retired;
243:
244: if (!func)
245: return -EINVAL;
246:
247: /*
248: * If the caller is creating their own timestamps, let them schedule
249: * events in the future. Otherwise only allow timestamps that have been
250: * queued.
251: */
252: if (!context || !(context->flags & KGSL_CONTEXT_USER_GENERATED_TS)) {
253: group->readtimestamp(device, group->priv, KGSL_TIMESTAMP_QUEUED,
254: &queued);
255:
256: if (timestamp_cmp(timestamp, queued) > 0)
257: return -EINVAL;
258: }
259:
260: event = kmem_cache_alloc(events_cache, GFP_KERNEL);
MATCH LINES: 331
319: /* Check if the group is uninintalized */
320: if (!group->context)
321: return;
322:
323: /* Make sure that all the events have been deleted from the list */
324: WARN_ON(!list_empty(&group->events));
325:
326: write_lock(&device->event_groups_lock);
327: list_del(&group->group);
328: write_unlock(&device->event_groups_lock);
329: }
330:
331: void kgsl_add_event_group(struct kgsl_device *device,
332: struct kgsl_event_group *group, struct kgsl_context *context,
333: readtimestamp_func readtimestamp,
334: void *priv, const char *fmt, ...)
335: {
336: va_list args;
337:
338: WARN_ON(readtimestamp == NULL);
339:
340: spin_lock_init(&group->lock);
341: INIT_LIST_HEAD(&group->events);
342:
343: group->context = context;
344: group->readtimestamp = readtimestamp;
345: group->priv = priv;
346:
347: if (fmt) {
348: va_start(args, fmt);
349: vsnprintf(group->name, sizeof(group->name), fmt, args);
350: va_end(args);
351: }
352:
353: write_lock(&device->event_groups_lock);
354: list_add_tail(&group->group, &device->event_groups);
355: write_unlock(&device->event_groups_lock);
--- FILE: \kgsl_gmu_core.c | HITS: 4 ---
MATCH LINES: 900, 901, 902, 904
888: trace_adreno_preempt_done(data->prev_rb, data->next_rb,
889: data->ctx_switch_cntl, pkt->ticks);
890: break;
891: }
892: case GMU_TRACE_EXTERNAL_HW_FENCE_SIGNAL: {
893: struct trace_ext_hw_fence_signal *data =
894: (struct trace_ext_hw_fence_signal *)pkt->payload;
895:
896: trace_adreno_ext_hw_fence_signal(data->context, data->seq_no,
897: data->flags, pkt->ticks);
898: break;
899: }
900: case GMU_TRACE_SYNCOBJ_RETIRE: {
901: struct trace_syncobj_retire *data =
902: (struct trace_syncobj_retire *)pkt->payload;
903:
904: trace_adreno_syncobj_retired(data->gmu_ctxt_id, data->timestamp, pkt->ticks);
905: break;
906: }
907: case GMU_TRACE_DCVS_PWRLVL: {
908: _gmu_trace_dcvs_pwrlevel(device, pkt);
909: break;
910: }
911: case GMU_TRACE_DCVS_BUSLVL: {
912: _gmu_trace_dcvs_buslevel(device, pkt);
913: break;
914: }
915: case GMU_TRACE_DCVS_PWRSTATS: {
916: _gmu_trace_dcvs_pwrstats(device, pkt);
917: break;
918: }
919: case GMU_TRACE_PWR_CONSTRAINT: {
920: struct trace_pwr_constraint *data =
921: (struct trace_pwr_constraint *)pkt->payload;
922:
923: trace_kgsl_constraint(device, data->type, data->value, data->status, pkt->ticks);
924: break;
925: }
926: case GMU_TRACE_DCVS_PROFILE: {
927: struct trace_dcvs_profile *data =
928: (struct trace_dcvs_profile *)pkt->payload;
--- FILE: \kgsl_gmu_core.h | HITS: 3 ---
MATCH LINES: 329, 356
317: * value for GMU trace timerhandler to send HFI msg.
318: */
319: u32 timeout;
320: /** @log_type: To decode the trace buffer data */
321: u32 log_type;
322: } __packed;
323:
324: /* Trace ID definition */
325: enum gmu_trace_id {
326: GMU_TRACE_PREEMPT_TRIGGER = 1,
327: GMU_TRACE_PREEMPT_DONE = 2,
328: GMU_TRACE_EXTERNAL_HW_FENCE_SIGNAL = 3,
329: GMU_TRACE_SYNCOBJ_RETIRE = 4,
330: GMU_TRACE_DCVS_PWRLVL = 5,
331: GMU_TRACE_DCVS_BUSLVL = 6,
332: GMU_TRACE_DCVS_PWRSTATS = 7,
333: GMU_TRACE_PWR_CONSTRAINT = 8,
334: GMU_TRACE_DCVS_PROFILE = 9,
335: GMU_TRACE_MAX,
336: };
337:
338: struct trace_preempt_trigger {
339: u32 cur_rb;
340: u32 next_rb;
341: u32 ctx_switch_cntl;
342: } __packed;
343:
344: struct trace_preempt_done {
345: u32 prev_rb;
346: u32 next_rb;
347: u32 ctx_switch_cntl;
348: } __packed;
349:
350: struct trace_ext_hw_fence_signal {
351: u64 context;
352: u64 seq_no;
353: u32 flags;
354: } __packed;
355:
356: struct trace_syncobj_retire {
357: u32 gmu_ctxt_id;
358: u32 timestamp;
359: } __packed;
360:
361: #define TRACE_FLAG_BIT_DCVS_VOTE 0
362: #define TRACE_FLAG_BIT_STRICT_FRAME 1
363: #define TRACE_FLAG_BIT_NON_LINEAR_UP 2
364: #define TRACE_FLAG_BIT_NON_LINEAR_DOWN 3
365:
366: struct trace_dcvs_pwrlvl {
367: u32 new_pwrlvl;
368: u32 prev_pwrlvl;
369: u32 flag;
370: u16 penalty_up;
371: u16 penalty_down;
372: u16 first_step_down_count;
373: u16 subsequent_step_down_count;
374: u16 min_freq;
375: u16 max_freq;
376: u16 num_samples_up;
377: u16 num_samples_down;
378: u16 target_fps;
379: u16 mod_percent;
380: u16 avg_busy;
MATCH LINES: 505
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);
--- FILE: \kgsl_ioctl.c | HITS: 2 ---
MATCH LINES: 60, 61
48: KGSL_IOCTL_FUNC(IOCTL_KGSL_GPUMEM_GET_INFO,
49: kgsl_ioctl_gpumem_get_info),
50: KGSL_IOCTL_FUNC(IOCTL_KGSL_GPUMEM_SYNC_CACHE,
51: kgsl_ioctl_gpumem_sync_cache),
52: KGSL_IOCTL_FUNC(IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK,
53: kgsl_ioctl_gpumem_sync_cache_bulk),
54: KGSL_IOCTL_FUNC(IOCTL_KGSL_SYNCSOURCE_CREATE,
55: kgsl_ioctl_syncsource_create),
56: KGSL_IOCTL_FUNC(IOCTL_KGSL_SYNCSOURCE_DESTROY,
57: kgsl_ioctl_syncsource_destroy),
58: KGSL_IOCTL_FUNC(IOCTL_KGSL_SYNCSOURCE_CREATE_FENCE,
59: kgsl_ioctl_syncsource_create_fence),
60: KGSL_IOCTL_FUNC(IOCTL_KGSL_SYNCSOURCE_SIGNAL_FENCE,
61: kgsl_ioctl_syncsource_signal_fence),
62: KGSL_IOCTL_FUNC(IOCTL_KGSL_GPUOBJ_ALLOC,
63: kgsl_ioctl_gpuobj_alloc),
64: KGSL_IOCTL_FUNC(IOCTL_KGSL_GPUOBJ_FREE,
65: kgsl_ioctl_gpuobj_free),
66: KGSL_IOCTL_FUNC(IOCTL_KGSL_GPUOBJ_INFO,
67: kgsl_ioctl_gpuobj_info),
68: KGSL_IOCTL_FUNC(IOCTL_KGSL_GPUOBJ_IMPORT,
69: kgsl_ioctl_gpuobj_import),
70: KGSL_IOCTL_FUNC(IOCTL_KGSL_GPUOBJ_SYNC,
71: kgsl_ioctl_gpuobj_sync),
72: KGSL_IOCTL_FUNC(IOCTL_KGSL_GPU_COMMAND,
73: kgsl_ioctl_gpu_command),
74: KGSL_IOCTL_FUNC(IOCTL_KGSL_GPUOBJ_SET_INFO,
75: kgsl_ioctl_gpuobj_set_info),
76: KGSL_IOCTL_FUNC(IOCTL_KGSL_SPARSE_PHYS_ALLOC,
77: NULL),
78: KGSL_IOCTL_FUNC(IOCTL_KGSL_SPARSE_PHYS_FREE,
79: NULL),
80: KGSL_IOCTL_FUNC(IOCTL_KGSL_SPARSE_VIRT_ALLOC,
81: NULL),
82: KGSL_IOCTL_FUNC(IOCTL_KGSL_SPARSE_VIRT_FREE,
83: NULL),
84: KGSL_IOCTL_FUNC(IOCTL_KGSL_SPARSE_BIND,
85: NULL),
--- FILE: \kgsl_pwrctrl.c | HITS: 5 ---
MATCH LINES: 1434, 1447
1422:
1423: return ret;
1424: }
1425:
1426: int kgsl_pwrctrl_enable_cx_gdsc(struct kgsl_device *device)
1427: {
1428: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1429: int ret;
1430:
1431: if (!pwr->cx_regulator && !pwr->gmu_cx_pd)
1432: return 0;
1433:
1434: ret = wait_for_completion_timeout(&pwr->cx_gdsc_gate, msecs_to_jiffies(5000));
1435: if (!ret) {
1436: /* Dump the cx regulator consumer list */
1437: if (pwr->cx_regulator) {
1438: dev_err(device->dev, "GPU CX wait timeout. Dumping CX votes:\n");
1439: qcom_clk_dump(NULL, pwr->cx_regulator, false);
1440: } else {
1441: dev_err(device->dev, "GPU CX wait timeout\n");
1442: }
1443: KGSL_GMU_CORE_FORCE_PANIC(device->gmu_core.gf_panic,
1444: GMU_PDEV(device), 0ULL, GMU_FAULT_CX_WAIT_TIMEOUT);
1445: }
1446:
1447: if (!completion_done(&pwr->cx_gdsc_gate))
1448: log_kgsl_cx_wait_timeout_event(HLOS_CX_WAIT_TIMEOUT);
1449:
1450: if (pwr->cx_regulator)
1451: ret = regulator_enable(pwr->cx_regulator);
1452: else
1453: ret = pm_runtime_resume_and_get(pwr->gmu_cx_pd);
1454:
1455: if (ret)
1456: dev_err(device->dev, "Failed to enable CX gdsc, error %d\n", ret);
1457:
1458: kgsl_mmu_send_tlb_hint(&device->mmu, false);
1459: pwr->cx_gdsc_wait = false;
1460: return ret;
1461: }
1462:
1463: int kgsl_pwrctrl_enable_gx_gdsc(struct kgsl_device *device)
1464: {
1465: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1466: int ret;
1467:
1468: if (!pwr->gx_regulator && !pwr->gx_pd)
1469: return 0;
1470:
1471: if (pwr->gx_regulator)
MATCH LINES: 1490
1478:
1479: return ret;
1480: }
1481:
1482: void kgsl_pwrctrl_disable_cx_gdsc(struct kgsl_device *device)
1483: {
1484: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1485:
1486: if (!pwr->cx_regulator && !pwr->gmu_cx_pd)
1487: return;
1488:
1489: kgsl_mmu_send_tlb_hint(&device->mmu, true);
1490: reinit_completion(&pwr->cx_gdsc_gate);
1491: pwr->cx_gdsc_wait = true;
1492:
1493: if (pwr->cx_regulator)
1494: regulator_disable(pwr->cx_regulator);
1495: else
1496: pm_runtime_put_sync(pwr->gmu_cx_pd);
1497: }
1498:
1499: void kgsl_pwrctrl_disable_gx_gdsc(struct kgsl_device *device)
1500: {
1501: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
1502: int ret;
1503:
1504: if (!pwr->gx_regulator && !pwr->gx_pd)
1505: return;
1506:
1507: if (pwr->gx_regulator)
1508: ret = kgsl_regulator_disable_wait(pwr->gx_regulator, GX_GDSC_TIMEOUT_MS);
1509: else
1510: ret = kgsl_genpd_disable_wait(pwr->gx_pd, GX_GDSC_TIMEOUT_MS);
1511:
1512: if (ret)
1513: dev_err(device->dev, "vdd is stuck on, error %d\n", ret);
1514: }
MATCH LINES: 2205
2193: PTR_ERR(pwr->gx_regulator_parent));
2194: return -ENODEV;
2195: }
2196: if (of_property_read_u32(pdev->dev.of_node,
2197: "vdd-parent-min-corner",
2198: &pwr->gx_regulator_parent_min_corner)) {
2199: dev_err(device->dev,
2200: "vdd-parent-min-corner not found\n");
2201: return -ENODEV;
2202: }
2203: }
2204:
2205: init_completion(&pwr->cx_gdsc_gate);
2206: complete_all(&pwr->cx_gdsc_gate);
2207:
2208: result = kgsl_register_gdsc_notifier(device);
2209: if (result) {
2210: dev_err(&pdev->dev, "Failed to register gdsc notifier: %d\n", result);
2211: goto err;
2212: }
2213:
2214: /* Initialize the thermal clock constraints */
2215: pwr->thermal_pwrlevel = 0;
2216: result = dev_pm_qos_add_request(&pdev->dev, &pwr->sysfs_thermal_req,
2217: DEV_PM_QOS_MAX_FREQUENCY,
2218: PM_QOS_MAX_FREQUENCY_DEFAULT_VALUE);
2219: if (result < 0)
2220: dev_err(device->dev, "PM QoS sysfs thermal request failed:%d\n", result);
2221:
2222: /*
2223: * Due to the way it is implemented by the thermal driver, thermal skin mitigation event
2224: * is triggered through PMQOS. Usually, this is supposed to be handled via devfreq.
2225: * Because devfreq recommendations can be overridden by kgsl min_freq/pwrlevel sysfs nodes,
2226: * kgsl should listen to PMQOS events and apply MAX FREQUENCY limit correctly.
2227: */
2228: pwr->nb_max.notifier_call = pmqos_max_notifier_call;
2229: result = dev_pm_qos_add_notifier(&pdev->dev, &pwr->nb_max, DEV_PM_QOS_MAX_FREQUENCY);
MATCH LINES: 2793
2781: int kgsl_active_count_wait(struct kgsl_device *device, int count,
2782: unsigned long wait_jiffies)
2783: {
2784: int result = 0;
2785:
2786: if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex)))
2787: return -EINVAL;
2788:
2789: while (atomic_read(&device->active_cnt) > count) {
2790: long ret;
2791:
2792: kgsl_mutex_unlock(&device->mutex);
2793: ret = wait_event_timeout(device->active_cnt_wq,
2794: _check_active_count(device, count), wait_jiffies);
2795: kgsl_mutex_lock(&device->mutex);
2796: result = ret == 0 ? -ETIMEDOUT : 0;
2797: if (!result)
2798: wait_jiffies = ret;
2799: else
2800: break;
2801: }
2802:
2803: return result;
2804: }
2805:
2806: /**
2807: * kgsl_pwrctrl_set_default_gpu_pwrlevel() - Set GPU to default power level
2808: * @device: Pointer to the kgsl_device struct
2809: */
2810: static int kgsl_pwrctrl_set_default_gpu_pwrlevel(struct kgsl_device *device)
2811: {
2812: struct kgsl_pwrctrl *pwr = &device->pwrctrl;
2813: unsigned int new_level = pwr->default_pwrlevel;
2814: unsigned int old_level = pwr->active_pwrlevel;
2815:
2816: /*
2817: * Update the level according to any thermal,
--- FILE: \kgsl_pwrctrl.h | HITS: 2 ---
MATCH LINES: 138, 139
126: /** @gmu_cx_pd: Power domain for controlling GMU CX GDSC instance */
127: struct device *gmu_cx_pd;
128: /** @gmu_mx_pd: Power domain for controlling GMU MX GDSC instance */
129: struct device *gmu_mx_pd;
130: /** @gx_pd: Power domain for controlling GX GDSC */
131: struct device *gx_pd;
132: /** @gx_regulator_parent: Pointer to the GX domain parent supply */
133: struct regulator *gx_regulator_parent;
134: /** @gx_regulator_parent_min_corner: Minimum supply voltage for GX parent */
135: u32 gx_regulator_parent_min_corner;
136: /** @cx_gdsc_nb: Notifier block for cx gdsc regulator */
137: struct notifier_block cx_gdsc_nb;
138: /** @cx_gdsc_gate: Completion to signal cx gdsc collapse status */
139: struct completion cx_gdsc_gate;
140: /** @cx_gdsc_wait: Whether to wait for cx gdsc to turn off */
141: bool cx_gdsc_wait;
142: /** @cx_cfg_gdsc_offset: Offset of CX CFG GDSC register */
143: u32 cx_cfg_gdsc_offset;
144: int isense_clk_indx;
145: int isense_clk_on_level;
146: unsigned long power_flags;
147: unsigned long ctrl_flags;
148: struct kgsl_pwrlevel pwrlevels[KGSL_MAX_PWRLEVELS];
149: unsigned int active_pwrlevel;
150: unsigned int previous_pwrlevel;
151: unsigned int thermal_pwrlevel;
152: unsigned int default_pwrlevel;
153: unsigned int max_pwrlevel;
154: unsigned int min_pwrlevel;
155: unsigned int min_render_pwrlevel;
156: unsigned int num_pwrlevels;
157: unsigned int throttle_mask;
158: atomic64_t interval_timeout;
159: u64 clock_times[KGSL_MAX_PWRLEVELS];
160: /** @thermal_time: Time in usecs the GPU is limited by thermal constraints */
161: u64 thermal_time;
162: struct kgsl_clk_stats clk_stats;
163: bool bus_control;
--- FILE: \kgsl_sharedmem.h | HITS: 1 ---
MATCH LINES: 629
617: u32 child_offset;
618: u32 op;
619: struct kgsl_mem_entry *entry;
620: };
621:
622: struct kgsl_sharedmem_bind_op {
623: struct kgsl_mem_entry *target;
624: struct kgsl_sharedmem_bind_op_range *ops;
625: int nr_ops;
626: void (*callback)(struct kgsl_sharedmem_bind_op *op);
627: void *data;
628: struct work_struct work;
629: struct completion comp;
630: struct kref ref;
631: };
632:
633: /**
634: * kgsl_sharedmem_allocate_vbo - Allocate a new virtual buffer object
635: * @device: A KGSL GPU handle
636: * @memdesc: Memory descriptor container to initialize
637: * @size: Size of the VBO
638: * @flags: Bitmask of KGSL_MEMFLAGS_*
639: *
640: * Initialize a new virtual buffer object memory descriptor
641: *
642: * Return: 0 on success or negative on failure.
643: */
644: int kgsl_sharedmem_allocate_vbo(struct kgsl_device *device,
645: struct kgsl_memdesc *memdesc, u64 size, u64 flags);
646:
647: /**
648: * kgsl_memdesc_print_vbo_ranges - Print a new virtual buffer object
649: * @entry: A KGSL memory entry
650: * @s: seq_file pointer
651: *
652: * Print virtual buffer object memory ranges
653: */
--- FILE: \kgsl_snapshot.c | HITS: 3 ---
MATCH LINES: 498
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
MATCH LINES: 687
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:
MATCH LINES: 880
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:
--- FILE: \kgsl_sync.c | HITS: 92 ---
MATCH LINES: 10, 16, 17
1: // SPDX-License-Identifier: GPL-2.0-only
2: /*
3: * Copyright (c) 2012-2019, 2021, The Linux Foundation. All rights reserved.
4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
5: */
6:
7: #include <dt-bindings/soc/qcom,ipcc.h>
8: #include <linux/file.h>
9: #include <linux/slab.h>
10: #include <linux/sync_file.h>
11:
12: #include "kgsl_device.h"
13: #include "kgsl_gmu_core.h"
14: #include "kgsl_sync.h"
15:
16: const struct dma_fence_ops kgsl_sync_fence_ops;
17: static const struct dma_fence_ops kgsl_syncsource_fence_ops;
18:
19: /* Only allow a single log in a second */
20: static DEFINE_RATELIMIT_STATE(_rs, HZ, 1);
21:
22: /* List of hardware fences that haven't been destroyed */
23: struct list_head hw_fence_list;
24: /* Spinlock to protect access to hw_fence_list */
25: spinlock_t hw_fence_list_lock;
26:
27: static void destroy_all_hw_fences(void);
28: static void _hw_fence_destroy(struct kgsl_sync_fence *kfence);
29:
30: static inline void add_hw_fence(struct kgsl_sync_fence *kfence)
31: {
32: spin_lock(&hw_fence_list_lock);
33: list_add_tail(&kfence->hw_fence_list, &hw_fence_list);
34: spin_unlock(&hw_fence_list_lock);
35: }
36:
37: #ifdef CONFIG_QCOM_KGSL_SYNX
38:
39: #include <synx_api.h>
40: #include <synx_interop.h>
41:
MATCH LINES: 96, 111, 120
84: md->physaddr = kgsl_synx.mem_descriptor.dev_addr;
85: md->size = kgsl_synx.mem_descriptor.size;
86: md->hostptr = kgsl_synx.mem_descriptor.vaddr;
87: }
88:
89: int kgsl_hw_fence_create(struct kgsl_device *device, struct kgsl_sync_fence *kfence)
90: {
91: struct synx_create_params params = {0};
92: int ret;
93:
94: params.fence = &kfence->fence;
95: params.h_synx = (u32 *)&kfence->hw_fence_index;
96: params.flags = SYNX_CREATE_DMA_FENCE;
97:
98: ret = synx_create(kgsl_synx.handle, ¶ms);
99: if (!ret) {
100: add_hw_fence(kfence);
101: return 0;
102: }
103:
104: if (__ratelimit(&_rs))
105: dev_err(device->dev, "Failed to create ctx:%d ts:%d hardware fence:%d\n",
106: kfence->context_id, kfence->timestamp, ret);
107:
108: return -EINVAL;
109: }
110:
111: int kgsl_hw_fence_add_waiter(struct kgsl_device *device, struct dma_fence *fence, u32 *hash_index)
112: {
113: struct synx_import_params params;
114: u32 handle = 0;
115: int ret;
116:
117: params.indv.fence = fence;
118: params.type = SYNX_IMPORT_INDV_PARAMS;
119: params.indv.new_h_synx = &handle;
120: params.indv.flags = SYNX_IMPORT_DMA_FENCE;
121:
122: ret = synx_import(kgsl_synx.handle, ¶ms);
123: if (ret) {
124: dev_err_ratelimited(device->dev,
125: "Failed to add GMU as waiter ret:%d fence ctx:%llu ts:%llu\n",
126: ret, fence->context, fence->seqno);
127: return ret;
128: }
129:
130: /* release reference held by synx_import */
131: ret = synx_release(kgsl_synx.handle, handle);
132: if (ret) {
133: dev_err_ratelimited(device->dev,
134: "Failed to release wait fences ret:%d fence ctx:%llu ts:%llu\n",
135: ret, fence->context, fence->seqno);
136: } else {
137: if (hash_index)
138: *hash_index = handle;
139: }
140:
141: return ret;
142: }
143:
144: bool kgsl_hw_fence_tx_slot_available(struct kgsl_device *device, u32 pending_hw_fence_count)
MATCH LINES: 191, 196, 202
179: clear_bit(SYNX_HW_FENCE_FLAG_ENABLED_BIT, &kfence->fence.flags);
180: }
181:
182: void kgsl_hw_fence_trigger_cpu(struct kgsl_device *device, struct kgsl_sync_fence *kfence)
183: {
184: /* soccp should be powered on */
185: WARN_RATELIMIT(!test_bit(GMU_SOCCP_VOTE_ON, &device->gmu_core.flags),
186: "signaling hw fence via cpu without soccp powered up\n");
187:
188: synx_signal(kgsl_synx.handle, (u32)kfence->hw_fence_index, SYNX_STATE_SIGNALED_SUCCESS);
189: }
190:
191: bool kgsl_hw_fence_signaled(struct dma_fence *fence)
192: {
193: return test_bit(SYNX_HW_FENCE_FLAG_SIGNALED_BIT, &fence->flags);
194: }
195:
196: static bool kgsl_is_input_hw_fence(struct dma_fence *fence)
197: {
198: return test_bit(SYNX_HW_FENCE_FLAG_ENABLED_BIT, &fence->flags) ||
199: test_bit(SYNX_NATIVE_FENCE_FLAG_ENABLED_BIT, &fence->flags) || is_kgsl_fence(fence);
200: }
201:
202: static bool kgsl_is_output_hw_fence(struct dma_fence *fence)
203: {
204: return test_bit(SYNX_HW_FENCE_FLAG_ENABLED_BIT, &fence->flags);
205: }
206:
207: #else
208:
209: #if (KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE)
210: #include <msm_hw_fence.h>
211: #else
212: #include <linux/soc/qcom/msm_hw_fence.h>
213: #endif
214:
215: static struct msm_hw_fence_descriptor {
216: /** @handle: Handle for hardware fences */
217: void *handle;
218: /** @descriptor: Memory descriptor for hardware fences */
219: struct msm_hw_fence_mem_addr mem_descriptor;
220: } kgsl_msm_hw_fence;
221:
222: int kgsl_hw_fence_soccp_vote(bool pwr_on)
223: {
224: return -EINVAL;
225: }
226:
MATCH LINES: 280
268: if ((ret || IS_ERR_OR_NULL(params.handle))) {
269: if (__ratelimit(&_rs))
270: dev_err(device->dev, "Failed to create ctx:%d ts:%d hardware fence:%d\n",
271: kfence->context_id, kfence->timestamp, ret);
272: return -EINVAL;
273: }
274:
275: add_hw_fence(kfence);
276:
277: return 0;
278: }
279:
280: int kgsl_hw_fence_add_waiter(struct kgsl_device *device, struct dma_fence *fence, u32 *hash_index)
281: {
282: u64 handle = 0;
283: int ret = msm_hw_fence_wait_update_v2(kgsl_msm_hw_fence.handle, &fence, &handle, NULL, 1,
284: true);
285:
286: if (ret)
287: dev_err_ratelimited(device->dev,
288: "Failed to add GMU as waiter ret:%d fence ctx:%llu ts:%llu\n",
289: ret, fence->context, fence->seqno);
290: else {
291: if (hash_index)
292: *hash_index = (u32)handle;
293: }
294:
295: return ret;
296: }
297:
298: bool kgsl_hw_fence_tx_slot_available(struct kgsl_device *device, u32 pending_hw_fence_count)
299: {
300: void *ptr = kgsl_msm_hw_fence.mem_descriptor.virtual_addr;
301: struct msm_hw_fence_hfi_queue_header *hdr = (struct msm_hw_fence_hfi_queue_header *)
302: (ptr + sizeof(struct msm_hw_fence_hfi_queue_table_header));
303: u32 queue_size_dwords = hdr->queue_size / sizeof(u32);
304: u32 payload_size_dwords = hdr->pkt_size / sizeof(u32);
MATCH LINES: 346, 351, 356, 385, 389, 392, 394, 396, 408, 420, 429
334: 0, 0);
335: if (ret) {
336: dev_err_ratelimited(device->dev,
337: "Failed to trigger hw fence via cpu: ctx:%d ts:%d ret:%d\n",
338: kfence->context_id, kfence->timestamp, ret);
339: return;
340: }
341:
342: msm_hw_fence_trigger_signal(kgsl_msm_hw_fence.handle, IPCC_GPU_PHYS_ID,
343: IPCC_CLIENT_APSS, 0);
344: }
345:
346: bool kgsl_hw_fence_signaled(struct dma_fence *fence)
347: {
348: return test_bit(MSM_HW_FENCE_FLAG_SIGNALED_BIT, &fence->flags);
349: }
350:
351: static bool kgsl_is_output_hw_fence(struct dma_fence *fence)
352: {
353: return test_bit(MSM_HW_FENCE_FLAG_ENABLED_BIT, &fence->flags);
354: }
355:
356: static bool kgsl_is_input_hw_fence(struct dma_fence *fence)
357: {
358: return test_bit(MSM_HW_FENCE_FLAG_ENABLED_BIT, &fence->flags);
359: }
360:
361: #endif
362:
363: static struct kgsl_sync_fence *kgsl_sync_fence_create(
364: struct kgsl_context *context,
365: unsigned int timestamp)
366: {
367: struct kgsl_sync_fence *kfence;
368: struct kgsl_sync_timeline *ktimeline = context->ktimeline;
369: unsigned long flags;
370:
371: /* Get a refcount to the timeline. Put when released */
372: if (!kref_get_unless_zero(&ktimeline->kref))
373: return NULL;
374:
375: kfence = kzalloc(sizeof(*kfence), GFP_KERNEL);
376: if (kfence == NULL) {
377: kgsl_sync_timeline_put(ktimeline);
378: return NULL;
379: }
380:
381: kfence->parent = ktimeline;
382: kfence->context_id = context->id;
383: kfence->timestamp = timestamp;
384:
385: dma_fence_init(&kfence->fence, &kgsl_sync_fence_ops, &ktimeline->lock,
386: ktimeline->fence_context, timestamp);
387:
388: /*
389: * sync_file_create() takes a refcount to the fence. This refcount is
390: * put when the fence is signaled.
391: */
392: kfence->sync_file = sync_file_create(&kfence->fence);
393:
394: if (kfence->sync_file == NULL) {
395: kgsl_sync_timeline_put(ktimeline);
396: dev_err(context->device->dev, "Create sync_file failed\n");
397: kfree(kfence);
398: return NULL;
399: }
400:
401: spin_lock_irqsave(&ktimeline->lock, flags);
402: list_add_tail(&kfence->child_list, &ktimeline->child_list_head);
403: spin_unlock_irqrestore(&ktimeline->lock, flags);
404:
405: return kfence;
406: }
407:
408: static void kgsl_sync_fence_release(struct dma_fence *fence)
409: {
410: struct kgsl_sync_fence *kfence = (struct kgsl_sync_fence *)fence;
411:
412: if (kgsl_is_output_hw_fence(fence))
413: kgsl_hw_fence_destroy(kfence);
414:
415: kgsl_sync_timeline_put(kfence->parent);
416: kfree(kfence);
417: }
418:
419: /* Called with ktimeline->lock held */
420: static bool kgsl_sync_fence_has_signaled(struct dma_fence *fence)
421: {
422: struct kgsl_sync_fence *kfence = (struct kgsl_sync_fence *)fence;
423: struct kgsl_sync_timeline *ktimeline = kfence->parent;
424: unsigned int ts = kfence->timestamp;
425:
426: return (timestamp_cmp(ktimeline->last_timestamp, ts) >= 0);
427: }
428:
429: static bool kgsl_enable_signaling(struct dma_fence *fence)
430: {
431: return !kgsl_sync_fence_has_signaled(fence);
432: }
433:
434: struct kgsl_sync_fence_event_priv {
435: struct kgsl_context *context;
436: unsigned int timestamp;
437: };
438:
439: /**
440: * kgsl_sync_fence_event_cb - Event callback for a fence timestamp event
441: * @device - The KGSL device that expired the timestamp
442: * @context- Pointer to the context that owns the event
443: * @priv: Private data for the callback
444: * @result - Result of the event (retired or canceled)
445: *
446: * Signal a fence following the expiration of a timestamp
447: */
448:
449: static void kgsl_sync_fence_event_cb(struct kgsl_device *device,
450: struct kgsl_event_group *group, void *priv, int result)
451: {
452: struct kgsl_sync_fence_event_priv *ev = priv;
453:
MATCH LINES: 481, 498
469: /*
470: * Increase the refcount for the context to keep it through the
471: * callback
472: */
473: if (!_kgsl_context_get(context)) {
474: kfree(event);
475: return -ENOENT;
476: }
477:
478: event->context = context;
479: event->timestamp = timestamp;
480:
481: ret = kgsl_add_event(device, &context->events, timestamp,
482: kgsl_sync_fence_event_cb, event);
483:
484: if (ret) {
485: kgsl_context_put(context);
486: kfree(event);
487: }
488:
489: return ret;
490: }
491:
492: /* Only to be used if creating a related event failed */
493: static void kgsl_sync_cancel(struct kgsl_sync_fence *kfence)
494: {
495: spin_lock(&kfence->parent->lock);
496: if (!list_empty(&kfence->child_list)) {
497: list_del_init(&kfence->child_list);
498: dma_fence_put(&kfence->fence);
499: }
500: spin_unlock(&kfence->parent->lock);
501: }
502:
503: /**
504: * kgsl_add_fence_event - Create a new fence event
505: * @device - KGSL device to create the event on
506: * @timestamp - Timestamp to trigger the event
507: * @data - Return fence fd stored in struct kgsl_timestamp_event_fence
508: * @len - length of the fence event
509: * @owner - driver instance that owns this event
510: * @returns 0 on success or error code on error
511: *
512: * Create a fence and register an event to signal the fence when
513: * the timestamp expires
514: */
515:
516: int kgsl_add_fence_event(struct kgsl_device *device,
517: u32 context_id, u32 timestamp, void __user *data, int len,
518: struct kgsl_device_private *owner)
519: {
520: struct kgsl_timestamp_event_fence priv;
521: struct kgsl_context *context;
522: struct kgsl_sync_fence *kfence = NULL;
MATCH LINES: 582, 596, 602
570: if (ret)
571: goto out;
572: }
573:
574: if (copy_to_user(data, &priv, sizeof(priv))) {
575: ret = -EFAULT;
576: goto out;
577: }
578:
579: if (!retired)
580: device->ftbl->create_hw_fence(device, kfence);
581:
582: fd_install(priv.fence_fd, kfence->sync_file->file);
583:
584: out:
585: kgsl_context_put(context);
586: if (ret) {
587: if (priv.fence_fd >= 0)
588: put_unused_fd(priv.fence_fd);
589:
590: if (kfence) {
591: kgsl_sync_cancel(kfence);
592: /*
593: * Put the refcount of sync file. This will release
594: * kfence->fence as well.
595: */
596: fput(kfence->sync_file->file);
597: }
598: }
599: return ret;
600: }
601:
602: void kgsl_sync_timeline_value_str(struct dma_fence *fence, char *str, int size)
603: {
604: struct kgsl_sync_fence *kfence = (struct kgsl_sync_fence *)fence;
605: struct kgsl_sync_timeline *ktimeline = kfence->parent;
606: struct kgsl_context *context = NULL;
607: unsigned long flags;
608: int ret = 0;
609:
610: unsigned int timestamp_retired;
611: unsigned int timestamp_queued;
612:
613: if (fence->ops != &kgsl_sync_fence_ops)
614: return;
615:
616: if (!kref_get_unless_zero(&ktimeline->kref))
617: return;
618: if (!ktimeline->device)
619: goto put_timeline;
620:
621: spin_lock_irqsave(&ktimeline->lock, flags);
622: ret = _kgsl_context_get(ktimeline->context);
623: context = ret ? ktimeline->context : NULL;
624: spin_unlock_irqrestore(&ktimeline->lock, flags);
625:
626: /* Get the last signaled timestamp if the context is not valid */
MATCH LINES: 647, 655, 660, 689, 721, 723, 757, 762, 771, 772, 779, 813, 815, 816, 818, 826, 827, 831, 832, 833, 834, 839, 840, 842, 845, 855, 870, 891, 903, 904, 910, 930, 948, 951, 958, 967, 972, 976, 990, 1003
635:
636: kgsl_context_put(context);
637: }
638:
639: snprintf(str, size, "%u queued:%u retired:%u",
640: ktimeline->last_timestamp,
641: timestamp_queued, timestamp_retired);
642:
643: put_timeline:
644: kgsl_sync_timeline_put(ktimeline);
645: }
646:
647: static void kgsl_sync_fence_value_str(struct dma_fence *fence,
648: char *str, int size)
649: {
650: struct kgsl_sync_fence *kfence = (struct kgsl_sync_fence *)fence;
651:
652: snprintf(str, size, "%u", kfence->timestamp);
653: }
654:
655: static const char *kgsl_sync_fence_driver_name(struct dma_fence *fence)
656: {
657: return "kgsl-timeline";
658: }
659:
660: static const char *kgsl_sync_timeline_name(struct dma_fence *fence)
661: {
662: struct kgsl_sync_fence *kfence = (struct kgsl_sync_fence *)fence;
663: struct kgsl_sync_timeline *ktimeline = kfence->parent;
664:
665: return ktimeline->name;
666: }
667:
668: int kgsl_sync_timeline_create(struct kgsl_context *context)
669: {
670: struct kgsl_sync_timeline *ktimeline;
671:
672: /* Put context at detach time */
673: if (!_kgsl_context_get(context))
674: return -ENOENT;
675:
676: ktimeline = kzalloc(sizeof(*ktimeline), GFP_KERNEL);
677: if (ktimeline == NULL) {
678: kgsl_context_put(context);
679: return -ENOMEM;
680: }
681:
682: kref_init(&ktimeline->kref);
683: snprintf(ktimeline->name, sizeof(ktimeline->name),
684: "%s_%u-%.15s(%d)-%.15s(%d)",
685: context->device->name, context->id,
686: current->group_leader->comm, current->group_leader->pid,
687: current->comm, current->pid);
688:
689: ktimeline->fence_context = dma_fence_context_alloc(1);
690: ktimeline->last_timestamp = 0;
691: INIT_LIST_HEAD(&ktimeline->child_list_head);
692: spin_lock_init(&ktimeline->lock);
693: ktimeline->device = context->device;
694:
695: /*
696: * The context pointer is valid till detach time, where we put the
697: * refcount on the context
698: */
699: ktimeline->context = context;
700:
701: context->ktimeline = ktimeline;
702:
703: return 0;
704: }
705:
706: void kgsl_sync_timeline_signal(struct kgsl_sync_timeline *ktimeline,
707: unsigned int timestamp)
708: {
709: unsigned long flags;
710: struct kgsl_sync_fence *kfence, *next;
711:
712: if (!kref_get_unless_zero(&ktimeline->kref))
713: return;
714:
715: spin_lock_irqsave(&ktimeline->lock, flags);
716: if (timestamp_cmp(timestamp, ktimeline->last_timestamp) > 0)
717: ktimeline->last_timestamp = timestamp;
718:
719: list_for_each_entry_safe(kfence, next, &ktimeline->child_list_head,
720: child_list) {
721: if (dma_fence_is_signaled_locked(&kfence->fence)) {
722: list_del_init(&kfence->child_list);
723: dma_fence_put(&kfence->fence);
724: }
725: }
726:
727: spin_unlock_irqrestore(&ktimeline->lock, flags);
728: kgsl_sync_timeline_put(ktimeline);
729: }
730:
731: void kgsl_sync_timeline_detach(struct kgsl_sync_timeline *ktimeline)
732: {
733: unsigned long flags;
734: struct kgsl_context *context = ktimeline->context;
735:
736: /* Set context pointer to NULL and drop our refcount on the context */
737: spin_lock_irqsave(&ktimeline->lock, flags);
738: ktimeline->context = NULL;
739: spin_unlock_irqrestore(&ktimeline->lock, flags);
740: kgsl_context_put(context);
741: }
742:
743: static void kgsl_sync_timeline_destroy(struct kref *kref)
744: {
745: struct kgsl_sync_timeline *ktimeline =
746: container_of(kref, struct kgsl_sync_timeline, kref);
747:
748: kfree(ktimeline);
749: }
750:
751: void kgsl_sync_timeline_put(struct kgsl_sync_timeline *ktimeline)
752: {
753: if (ktimeline)
754: kref_put(&ktimeline->kref, kgsl_sync_timeline_destroy);
755: }
756:
757: const struct dma_fence_ops kgsl_sync_fence_ops = {
758: .get_driver_name = kgsl_sync_fence_driver_name,
759: .get_timeline_name = kgsl_sync_timeline_name,
760: .enable_signaling = kgsl_enable_signaling,
761: .signaled = kgsl_sync_fence_has_signaled,
762: .wait = dma_fence_default_wait,
763: .release = kgsl_sync_fence_release,
764:
765: #if (KERNEL_VERSION(6, 16, 0) > LINUX_VERSION_CODE)
766: .fence_value_str = kgsl_sync_fence_value_str,
767: .timeline_value_str = kgsl_sync_timeline_value_str,
768: #endif
769: };
770:
771: static void kgsl_sync_fence_callback(struct dma_fence *fence,
772: struct dma_fence_cb *cb)
773: {
774: struct kgsl_sync_fence_cb *kcb = (struct kgsl_sync_fence_cb *)cb;
775:
776: kcb->func(kcb->priv);
777: }
778:
779: bool is_kgsl_fence(struct dma_fence *f)
780: {
781: if (f->ops == &kgsl_sync_fence_ops)
782: return true;
783:
784: return false;
785: }
786:
787: void kgsl_hw_fence_destroy(struct kgsl_sync_fence *kfence)
788: {
789: spin_lock(&hw_fence_list_lock);
790:
791: if (!list_empty(&kfence->hw_fence_list)) {
792: _hw_fence_destroy(kfence);
793: list_del_init(&kfence->hw_fence_list);
794: }
795:
796: spin_unlock(&hw_fence_list_lock);
797: }
798:
799: static void destroy_all_hw_fences(void)
800: {
801: struct kgsl_sync_fence *kfence, *next;
802:
803: spin_lock(&hw_fence_list_lock);
804:
805: list_for_each_entry_safe(kfence, next, &hw_fence_list, hw_fence_list) {
806: _hw_fence_destroy(kfence);
807: list_del_init(&kfence->hw_fence_list);
808: }
809:
810: spin_unlock(&hw_fence_list_lock);
811: }
812:
813: static void kgsl_count_hw_fences(struct kgsl_drawobj_sync_event *event, struct dma_fence *fence)
814: {
815: struct kgsl_drawobj_sync *syncobj = event->syncobj;
816: u32 max_hw_fence = event->device->max_syncobj_hw_fence_count;
817:
818: if (test_bit(KGSL_SYNCOBJ_SW, &syncobj->flags))
819: return;
820:
821: if (!kgsl_is_input_hw_fence(fence)) {
822: /*
823: * Ignore software fences that are already signaled. Even one unsignaled sw-only
824: * fence in this sync object means we can't send this sync object to the hardware
825: */
826: if (!dma_fence_is_signaled(fence))
827: set_bit(KGSL_SYNCOBJ_SW, &syncobj->flags);
828: return;
829: }
830:
831: if (!syncobj->hw_fences) {
832: syncobj->hw_fences = kcalloc(max_hw_fence, sizeof(*syncobj->hw_fences), GFP_KERNEL);
833: if (!syncobj->hw_fences) {
834: set_bit(KGSL_SYNCOBJ_SW, &syncobj->flags);
835: return;
836: }
837: }
838:
839: if (syncobj->num_hw_fence < max_hw_fence)
840: syncobj->hw_fences[syncobj->num_hw_fence++].fence = fence;
841: else
842: set_bit(KGSL_SYNCOBJ_SW, &syncobj->flags);
843: }
844:
845: static void kgsl_syncsource_fence_value_str(struct dma_fence *fence, char *str, int size)
846: {
847: /*
848: * Each fence is independent of the others on the same timeline.
849: * We use a different context for each of them.
850: */
851: snprintf(str, size, "%llu", fence->context);
852: }
853:
854: #if (KERNEL_VERSION(6, 16, 0) > LINUX_VERSION_CODE)
855: static int kgsl_get_fence_value_str(struct dma_fence *fence, char *buf, size_t size)
856: {
857: int len = 0;
858:
859: if (!fence || !fence->ops || !buf)
860: return 0;
861:
862: if (fence->ops->fence_value_str) {
863: len += scnprintf(buf + len, size - len, ": ");
864: fence->ops->fence_value_str(fence, buf + len, size - len);
865: }
866:
867: return len;
868: }
869: #else
870: static int kgsl_get_fence_value_str(struct dma_fence *fence, char *buf, size_t size)
871: {
872: int len = 0;
873:
874: if (!fence || !fence->ops || !buf)
875: return 0;
876:
877: if (fence->ops == &kgsl_sync_fence_ops) {
878: len += scnprintf(buf + len, size - len, ": ");
879: kgsl_sync_fence_value_str(fence, buf + len, size - len);
880: }
881:
882: if (fence->ops == &kgsl_syncsource_fence_ops) {
883: len += scnprintf(buf + len, size - len, ": ");
884: kgsl_syncsource_fence_value_str(fence, buf + len, size - len);
885: }
886:
887: return len;
888: }
889: #endif
890:
891: void kgsl_get_fence_name(struct dma_fence *f, char *name, u32 max_size)
892: {
893: int len = scnprintf(name, max_size, "%s %s", f->ops->get_driver_name(f),
894: f->ops->get_timeline_name(f));
895:
896: len += kgsl_get_fence_value_str(f, name + len, max_size - len);
897:
898: }
899:
900: void kgsl_get_fence_info(struct kgsl_drawobj_sync_event *event)
901: {
902: unsigned int num_fences;
903: struct dma_fence *fence, **fences;
904: struct dma_fence_array *array;
905: struct event_fence_info *info_ptr = event->priv;
906: int i;
907:
908: fence = event->handle->fence;
909:
910: array = to_dma_fence_array(fence);
911: if (array != NULL) {
912: num_fences = array->num_fences;
913: fences = array->fences;
914: } else {
915: num_fences = 1;
916: fences = &fence;
917: }
918:
919: if (!info_ptr)
920: goto count;
921:
922: info_ptr->fences = kcalloc(num_fences, sizeof(struct fence_info),
923: GFP_KERNEL);
924: if (info_ptr->fences == NULL)
925: goto count;
926:
927: info_ptr->num_fences = num_fences;
928:
929: for (i = 0; i < num_fences; i++) {
930: struct dma_fence *f = fences[i];
931: struct fence_info *fi = &info_ptr->fences[i];
932:
933: kgsl_get_fence_name(f, fi->name, sizeof(fi->name));
934:
935: kgsl_count_hw_fences(event, f);
936: }
937:
938: return;
939: count:
940: for (i = 0; i < num_fences; i++)
941: kgsl_count_hw_fences(event, fences[i]);
942: }
943:
944: struct kgsl_sync_fence_cb *kgsl_sync_fence_async_wait(int fd,
945: bool (*func)(void *priv), void *priv)
946: {
947: struct kgsl_sync_fence_cb *kcb;
948: struct dma_fence *fence;
949: int status;
950:
951: fence = sync_file_get_fence(fd);
952: if (fence == NULL)
953: return ERR_PTR(-EINVAL);
954:
955: /* create the callback */
956: kcb = kzalloc(sizeof(*kcb), GFP_KERNEL);
957: if (kcb == NULL) {
958: dma_fence_put(fence);
959: return ERR_PTR(-ENOMEM);
960: }
961:
962: kcb->fence = fence;
963: kcb->priv = priv;
964: kcb->func = func;
965:
966: /* if status then error or signaled */
967: status = dma_fence_add_callback(fence, &kcb->fence_cb,
968: kgsl_sync_fence_callback);
969:
970: if (status) {
971: kfree(kcb);
972: if (!dma_fence_is_signaled(fence))
973: kcb = ERR_PTR(status);
974: else
975: kcb = NULL;
976: dma_fence_put(fence);
977: }
978:
979: return kcb;
980: }
981:
982: /*
983: * Cancel the fence async callback.
984: */
985: void kgsl_sync_fence_async_cancel(struct kgsl_sync_fence_cb *kcb)
986: {
987: if (kcb == NULL)
988: return;
989:
990: dma_fence_remove_callback(kcb->fence, &kcb->fence_cb);
991: }
992:
993: struct kgsl_syncsource {
994: struct kref refcount;
995: char name[32];
996: int id;
997: struct kgsl_process_private *private;
998: struct list_head child_list_head;
999: spinlock_t lock;
1000: };
1001:
1002: struct kgsl_syncsource_fence {
1003: struct dma_fence fence;
1004: struct kgsl_syncsource *parent;
1005: struct list_head child_list;
1006: };
1007:
1008: long kgsl_ioctl_syncsource_create(struct kgsl_device_private *dev_priv,
1009: unsigned int cmd, void *data)
1010: {
1011: struct kgsl_syncsource *syncsource = NULL;
1012: struct kgsl_syncsource_create *param = data;
1013: int ret = -EINVAL;
1014: int id = 0;
1015: struct kgsl_process_private *private = dev_priv->process_priv;
1016:
1017: if (!kgsl_process_private_get(private))
1018: return ret;
1019:
1020: syncsource = kzalloc(sizeof(*syncsource), GFP_KERNEL);
1021: if (syncsource == NULL) {
1022: ret = -ENOMEM;
1023: goto out;
1024: }
1025:
1026: kref_init(&syncsource->refcount);
1027: snprintf(syncsource->name, sizeof(syncsource->name),
MATCH LINES: 1104
1092:
1093: static void kgsl_syncsource_cleanup(struct kgsl_process_private *private,
1094: struct kgsl_syncsource *syncsource)
1095: {
1096: struct kgsl_syncsource_fence *sfence, *next;
1097: unsigned long flags;
1098:
1099: /* Signal all fences to release any callbacks */
1100: spin_lock_irqsave(&syncsource->lock, flags);
1101:
1102: list_for_each_entry_safe(sfence, next, &syncsource->child_list_head,
1103: child_list) {
1104: dma_fence_signal_locked(&sfence->fence);
1105: list_del_init(&sfence->child_list);
1106: }
1107:
1108: spin_unlock_irqrestore(&syncsource->lock, flags);
1109:
1110: /* put reference from syncsource creation */
1111: kgsl_syncsource_put(syncsource);
1112: }
1113:
1114: long kgsl_ioctl_syncsource_destroy(struct kgsl_device_private *dev_priv,
1115: unsigned int cmd, void *data)
1116: {
1117: struct kgsl_syncsource_destroy *param = data;
1118: struct kgsl_syncsource *syncsource = NULL;
1119: struct kgsl_process_private *private = dev_priv->process_priv;
1120:
1121: spin_lock(&private->syncsource_lock);
1122: syncsource = idr_find(&private->syncsource_idr, param->id);
1123:
1124: if (syncsource == NULL) {
1125: spin_unlock(&private->syncsource_lock);
1126: return -EINVAL;
1127: }
1128:
MATCH LINES: 1146, 1167, 1168, 1170, 1172, 1174, 1186, 1199, 1200, 1203, 1204, 1206, 1215, 1226, 1239, 1243, 1245, 1252, 1261, 1267
1134:
1135: kgsl_syncsource_cleanup(private, syncsource);
1136: return 0;
1137: }
1138:
1139: long kgsl_ioctl_syncsource_create_fence(struct kgsl_device_private *dev_priv,
1140: unsigned int cmd, void *data)
1141: {
1142: struct kgsl_syncsource_create_fence *param = data;
1143: struct kgsl_syncsource *syncsource = NULL;
1144: int ret = -EINVAL;
1145: struct kgsl_syncsource_fence *sfence = NULL;
1146: struct sync_file *sync_file = NULL;
1147: int fd = -1;
1148: unsigned long flags;
1149:
1150: /*
1151: * Take a refcount that is released when the fence is released
1152: * (or if fence can't be added to the syncsource).
1153: */
1154: syncsource = kgsl_syncsource_get(dev_priv->process_priv,
1155: param->id);
1156: if (syncsource == NULL)
1157: goto out;
1158:
1159: sfence = kzalloc(sizeof(*sfence), GFP_KERNEL);
1160: if (sfence == NULL) {
1161: ret = -ENOMEM;
1162: goto out;
1163: }
1164: sfence->parent = syncsource;
1165:
1166: /* Use a new fence context for each fence */
1167: dma_fence_init(&sfence->fence, &kgsl_syncsource_fence_ops,
1168: &syncsource->lock, dma_fence_context_alloc(1), 1);
1169:
1170: sync_file = sync_file_create(&sfence->fence);
1171:
1172: if (sync_file == NULL) {
1173: dev_err(dev_priv->device->dev,
1174: "Create sync_file failed\n");
1175: ret = -ENOMEM;
1176: goto out;
1177: }
1178:
1179: fd = get_unused_fd_flags(0);
1180: if (fd < 0) {
1181: ret = -EBADF;
1182: goto out;
1183: }
1184: ret = 0;
1185:
1186: fd_install(fd, sync_file->file);
1187:
1188: param->fence_fd = fd;
1189:
1190: spin_lock_irqsave(&syncsource->lock, flags);
1191: list_add_tail(&sfence->child_list, &syncsource->child_list_head);
1192: spin_unlock_irqrestore(&syncsource->lock, flags);
1193: out:
1194: /*
1195: * We're transferring ownership of the fence to the sync file.
1196: * The sync file takes an extra refcount when it is created, so put
1197: * our refcount.
1198: */
1199: if (sync_file)
1200: dma_fence_put(&sfence->fence);
1201:
1202: if (ret) {
1203: if (sync_file)
1204: fput(sync_file->file);
1205: else if (sfence)
1206: dma_fence_put(&sfence->fence);
1207: else
1208: kgsl_syncsource_put(syncsource);
1209: }
1210:
1211: return ret;
1212: }
1213:
1214: static int kgsl_syncsource_signal(struct kgsl_syncsource *syncsource,
1215: struct dma_fence *fence)
1216: {
1217: struct kgsl_syncsource_fence *sfence, *next;
1218: int ret = -EINVAL;
1219: unsigned long flags;
1220:
1221: spin_lock_irqsave(&syncsource->lock, flags);
1222:
1223: list_for_each_entry_safe(sfence, next, &syncsource->child_list_head,
1224: child_list) {
1225: if (fence == &sfence->fence) {
1226: dma_fence_signal_locked(fence);
1227: list_del_init(&sfence->child_list);
1228:
1229: ret = 0;
1230: break;
1231: }
1232: }
1233:
1234: spin_unlock_irqrestore(&syncsource->lock, flags);
1235:
1236: return ret;
1237: }
1238:
1239: long kgsl_ioctl_syncsource_signal_fence(struct kgsl_device_private *dev_priv,
1240: unsigned int cmd, void *data)
1241: {
1242: int ret = -EINVAL;
1243: struct kgsl_syncsource_signal_fence *param = data;
1244: struct kgsl_syncsource *syncsource = NULL;
1245: struct dma_fence *fence = NULL;
1246:
1247: syncsource = kgsl_syncsource_get(dev_priv->process_priv,
1248: param->id);
1249: if (syncsource == NULL)
1250: goto out;
1251:
1252: fence = sync_file_get_fence(param->fence_fd);
1253: if (fence == NULL) {
1254: ret = -EBADF;
1255: goto out;
1256: }
1257:
1258: ret = kgsl_syncsource_signal(syncsource, fence);
1259: out:
1260: if (fence)
1261: dma_fence_put(fence);
1262: if (syncsource)
1263: kgsl_syncsource_put(syncsource);
1264: return ret;
1265: }
1266:
1267: static void kgsl_syncsource_fence_release(struct dma_fence *fence)
1268: {
1269: struct kgsl_syncsource_fence *sfence =
1270: (struct kgsl_syncsource_fence *)fence;
1271:
1272: /* Signal if it's not signaled yet */
1273: kgsl_syncsource_signal(sfence->parent, fence);
1274:
1275: /* Release the refcount on the syncsource */
1276: kgsl_syncsource_put(sfence->parent);
1277:
1278: kfree(sfence);
1279: }
1280:
1281: void kgsl_syncsource_process_release_syncsources(
1282: struct kgsl_process_private *private)
1283: {
1284: struct kgsl_syncsource *syncsource;
1285: int next = 0;
1286:
1287: while (1) {
1288: spin_lock(&private->syncsource_lock);
1289: syncsource = idr_get_next(&private->syncsource_idr, &next);
1290:
1291: if (syncsource == NULL) {
MATCH LINES: 1307, 1316, 1321, 1326, 1330
1295:
1296: if (syncsource->id != 0) {
1297: idr_remove(&private->syncsource_idr, syncsource->id);
1298: syncsource->id = 0;
1299: }
1300: spin_unlock(&private->syncsource_lock);
1301:
1302: kgsl_syncsource_cleanup(private, syncsource);
1303: next = next + 1;
1304: }
1305: }
1306:
1307: static const char *kgsl_syncsource_get_timeline_name(struct dma_fence *fence)
1308: {
1309: struct kgsl_syncsource_fence *sfence =
1310: (struct kgsl_syncsource_fence *)fence;
1311: struct kgsl_syncsource *syncsource = sfence->parent;
1312:
1313: return syncsource->name;
1314: }
1315:
1316: static bool kgsl_syncsource_enable_signaling(struct dma_fence *fence)
1317: {
1318: return true;
1319: }
1320:
1321: static const char *kgsl_syncsource_driver_name(struct dma_fence *fence)
1322: {
1323: return "kgsl-syncsource-timeline";
1324: }
1325:
1326: static const struct dma_fence_ops kgsl_syncsource_fence_ops = {
1327: .get_driver_name = kgsl_syncsource_driver_name,
1328: .get_timeline_name = kgsl_syncsource_get_timeline_name,
1329: .enable_signaling = kgsl_syncsource_enable_signaling,
1330: .wait = dma_fence_default_wait,
1331: .release = kgsl_syncsource_fence_release,
1332:
1333: #if (KERNEL_VERSION(6, 16, 0) > LINUX_VERSION_CODE)
1334: .fence_value_str = kgsl_syncsource_fence_value_str,
1335: #endif
1336: };
1337:
--- FILE: \kgsl_sync.h | HITS: 18 ---
MATCH LINES: 42, 49, 50, 70, 71, 82, 93, 107, 115, 128, 136, 138
30: struct list_head child_list_head;
31:
32: spinlock_t lock;
33: unsigned int last_timestamp;
34: struct kgsl_device *device;
35: struct kgsl_context *context;
36: };
37:
38: /**
39: * struct kgsl_sync_fence - A struct containing a fence and other data
40: * associated with it
41: * @fence: The fence struct
42: * @sync_file: Pointer to the sync file
43: * @parent: Pointer to the kgsl sync timeline this fence is on
44: * @child_list: List of fences on the same timeline
45: * @context_id: kgsl context id
46: * @timestamp: Context timestamp that this fence is associated with
47: */
48: struct kgsl_sync_fence {
49: struct dma_fence fence;
50: struct sync_file *sync_file;
51: struct kgsl_sync_timeline *parent;
52: struct list_head child_list;
53: u32 context_id;
54: unsigned int timestamp;
55: /** @hw_fence_index: Index of hw fence in hw fence table */
56: u64 hw_fence_index;
57: /** @hw_fence_list: Global list of hw fences */
58: struct list_head hw_fence_list;
59: };
60:
61: /**
62: * struct kgsl_sync_fence_cb - Used for fence callbacks
63: * fence_cb: Fence callback struct
64: * fence: Pointer to the fence for which the callback is done
65: * priv: Private data for the callback
66: * func: Pointer to the kgsl function to call. This function should return
67: * false if the sync callback is marked for cancellation in a separate thread.
68: */
69: struct kgsl_sync_fence_cb {
70: struct dma_fence_cb fence_cb;
71: struct dma_fence *fence;
72: void *priv;
73: bool (*func)(void *priv);
74: };
75:
76: struct kgsl_device_private;
77: struct kgsl_drawobj_sync_event;
78: struct event_fence_info;
79: struct kgsl_process_private;
80: struct kgsl_syncsource;
81:
82: #if defined(CONFIG_SYNC_FILE)
83: int kgsl_add_fence_event(struct kgsl_device *device,
84: u32 context_id, u32 timestamp, void __user *data, int len,
85: struct kgsl_device_private *owner);
86:
87: int kgsl_sync_timeline_create(struct kgsl_context *context);
88:
89: void kgsl_sync_timeline_detach(struct kgsl_sync_timeline *ktimeline);
90:
91: void kgsl_sync_timeline_put(struct kgsl_sync_timeline *ktimeline);
92:
93: void kgsl_sync_timeline_value_str(struct dma_fence *fence, char *str, int size);
94:
95: struct kgsl_sync_fence_cb *kgsl_sync_fence_async_wait(int fd, bool (*func)(void *priv), void *priv);
96:
97: void kgsl_get_fence_info(struct kgsl_drawobj_sync_event *event);
98:
99: void kgsl_sync_fence_async_cancel(struct kgsl_sync_fence_cb *kcb);
100:
101: long kgsl_ioctl_syncsource_create(struct kgsl_device_private *dev_priv,
102: unsigned int cmd, void *data);
103: long kgsl_ioctl_syncsource_destroy(struct kgsl_device_private *dev_priv,
104: unsigned int cmd, void *data);
105: long kgsl_ioctl_syncsource_create_fence(struct kgsl_device_private *dev_priv,
106: unsigned int cmd, void *data);
107: long kgsl_ioctl_syncsource_signal_fence(struct kgsl_device_private *dev_priv,
108: unsigned int cmd, void *data);
109:
110: void kgsl_syncsource_put(struct kgsl_syncsource *syncsource);
111:
112: void kgsl_syncsource_process_release_syncsources(
113: struct kgsl_process_private *private);
114:
115: bool is_kgsl_fence(struct dma_fence *f);
116:
117: void kgsl_sync_timeline_signal(struct kgsl_sync_timeline *ktimeline,
118: u32 timestamp);
119:
120: int kgsl_hw_fence_init(struct kgsl_device *device);
121:
122: void kgsl_hw_fence_close(struct kgsl_device *device);
123:
124: void kgsl_hw_fence_populate_md(struct kgsl_device *device, struct kgsl_memdesc *md);
125:
126: int kgsl_hw_fence_create(struct kgsl_device *device, struct kgsl_sync_fence *kfence);
127:
128: int kgsl_hw_fence_add_waiter(struct kgsl_device *device, struct dma_fence *fence, u32 *hash_index);
129:
130: bool kgsl_hw_fence_tx_slot_available(struct kgsl_device *device, u32 pending_hw_fence_count);
131:
132: void kgsl_hw_fence_destroy(struct kgsl_sync_fence *kfence);
133:
134: void kgsl_hw_fence_trigger_cpu(struct kgsl_device *device, struct kgsl_sync_fence *kfence);
135:
136: bool kgsl_hw_fence_signaled(struct dma_fence *fence);
137:
138: void kgsl_get_fence_name(struct dma_fence *f, char *name, u32 max_size);
139:
140: int kgsl_hw_fence_soccp_vote(bool pwr_on);
141:
142: #else
143: static inline int kgsl_add_fence_event(struct kgsl_device *device,
144: u32 context_id, u32 timestamp, void __user *data, int len,
145: struct kgsl_device_private *owner)
146: {
147: return -EINVAL;
148: }
149:
150: static inline int kgsl_sync_timeline_create(struct kgsl_context *context)
151: {
152: context->ktimeline = NULL;
153: return 0;
154: }
155:
156: static inline void kgsl_sync_timeline_detach(struct kgsl_sync_timeline *ktimeline)
157: {
158: }
159:
160: static inline void kgsl_sync_timeline_put(struct kgsl_sync_timeline *ktimeline)
161: {
162: }
MATCH LINES: 202, 219, 255, 275, 280, 285
190: {
191: return -ENOIOCTLCMD;
192: }
193:
194: static inline long
195: kgsl_ioctl_syncsource_create_fence(struct kgsl_device_private *dev_priv,
196: unsigned int cmd, void *data)
197: {
198: return -ENOIOCTLCMD;
199: }
200:
201: static inline long
202: kgsl_ioctl_syncsource_signal_fence(struct kgsl_device_private *dev_priv,
203: unsigned int cmd, void *data)
204: {
205: return -ENOIOCTLCMD;
206: }
207:
208: static inline void kgsl_syncsource_put(struct kgsl_syncsource *syncsource)
209: {
210:
211: }
212:
213: static inline void kgsl_syncsource_process_release_syncsources(
214: struct kgsl_process_private *private)
215: {
216:
217: }
218:
219: bool is_kgsl_fence(struct dma_fence *f)
220: {
221: return false;
222: }
223:
224: void kgsl_sync_timeline_signal(struct kgsl_sync_timeline *ktimeline,
225: u32 timestamp)
226: {
227:
228: }
229:
230: int kgsl_hw_fence_soccp_vote(bool pwr_on)
231: {
232: return -EINVAL;
233: }
234:
235: int kgsl_hw_fence_init(struct kgsl_device *device)
236: {
237: return -EINVAL;
238: }
239:
240: void kgsl_hw_fence_close(struct kgsl_device *device)
241: {
242:
243: }
244:
245: void kgsl_hw_fence_populate_md(struct kgsl_device *device, struct kgsl_memdesc *md)
246: {
247:
248: }
249:
250: int kgsl_hw_fence_create(struct kgsl_device *device, struct kgsl_sync_fence *kfence)
251: {
252: return -EINVAL;
253: }
254:
255: int kgsl_hw_fence_add_waiter(struct kgsl_device *device, struct dma_fence *fence, u32 *hash_index)
256: {
257: return -EINVAL;
258: }
259:
260: bool kgsl_hw_fence_tx_slot_available(struct kgsl_device *device, u32 pending_hw_fence_count)
261: {
262: return false;
263: }
264:
265: void kgsl_hw_fence_destroy(struct kgsl_sync_fence *kfence)
266: {
267:
268: }
269:
270: void kgsl_hw_fence_trigger_cpu(struct kgsl_device *device, struct kgsl_sync_fence *kfence)
271: {
272:
273: }
274:
275: bool kgsl_hw_fence_signaled(struct dma_fence *fence)
276: {
277: return false;
278: }
279:
280: void kgsl_get_fence_name(struct dma_fence *f, char *name, u32 max_size)
281: {
282:
283: }
284:
285: #endif /* CONFIG_SYNC_FILE */
286:
287: #endif /* __KGSL_SYNC_H */
--- FILE: \kgsl_timeline.c | HITS: 63 ---
MATCH LINES: 11, 22, 34, 36, 41
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 <linux/dma-fence.h>
8: #include <linux/file.h>
9: #include <linux/list.h>
10: #include <linux/kref.h>
11: #include <linux/sync_file.h>
12: #include <linux/version.h>
13:
14: #include "kgsl_device.h"
15: #include "kgsl_eventlog.h"
16: #include "kgsl_sharedmem.h"
17: #include "kgsl_sync.h"
18: #include "kgsl_timeline.h"
19: #include "kgsl_trace.h"
20:
21: struct kgsl_timeline_fence {
22: struct dma_fence base;
23: struct kgsl_timeline *timeline;
24: struct list_head node;
25: };
26:
27: /*
28: * kgsl_timelines_collect_fences - Collect timeline fences from userspace
29: * @device: A KGSL device handle
30: * @timelines: Userspace pointer to an array of &struct kgsl_timeline_val
31: * @count: Number of entries in @timelines
32: * @usize: Size of each entry in @timelines
33: *
34: * Returns an array of dma_fence pointers on success, or ERR_PTR on failure.
35: */
36: static struct dma_fence **kgsl_timelines_collect_fences(
37: struct kgsl_device *device, u64 timelines, u32 count,
38: u64 usize)
39: {
40: void __user *uptr = u64_to_user_ptr(timelines);
41: struct dma_fence **fences;
42: int i, ret = 0;
43:
44: if (!count || count > INT_MAX)
45: return ERR_PTR(-EINVAL);
46:
47: fences = kcalloc(count, sizeof(*fences),
48: GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN);
49:
50: if (!fences)
51: return ERR_PTR(-ENOMEM);
52:
53: for (i = 0; i < count; i++) {
54: struct kgsl_timeline_val val;
55: struct kgsl_timeline *timeline;
56:
57: if (copy_struct_from_user(&val, sizeof(val), uptr, usize)) {
58: ret = -EFAULT;
59: goto err;
60: }
61:
62: if (val.padding) {
63: ret = -EINVAL;
64: goto err;
65: }
MATCH LINES: 88, 96, 97, 99, 100, 103, 104, 106, 107, 111, 114, 115, 123, 129, 135
76: if (IS_ERR(fences[i])) {
77: ret = PTR_ERR(fences[i]);
78: goto err;
79: }
80:
81: uptr += usize;
82: }
83:
84: return fences;
85: err:
86: for (i = 0; i < count; i++) {
87: if (!IS_ERR_OR_NULL(fences[i]))
88: dma_fence_put(fences[i]);
89: }
90:
91: kfree(fences);
92: return ERR_PTR(ret);
93: }
94:
95: #if (KERNEL_VERSION(7, 2, 0) <= LINUX_VERSION_CODE)
96: static struct dma_fence_array *kgsl_dma_fence_array_create(int count,
97: struct dma_fence **fences)
98: {
99: return dma_fence_array_create(count, fences,
100: dma_fence_context_alloc(1), 0);
101: }
102: #else
103: static struct dma_fence_array *kgsl_dma_fence_array_create(int count,
104: struct dma_fence **fences)
105: {
106: return dma_fence_array_create(count, fences,
107: dma_fence_context_alloc(1), 0, false);
108: }
109: #endif
110:
111: struct dma_fence *kgsl_timelines_to_fence_array(struct kgsl_device *device,
112: u64 timelines, u32 count, u64 usize)
113: {
114: struct dma_fence_array *array;
115: struct dma_fence **fences;
116: int i;
117:
118: fences = kgsl_timelines_collect_fences(device, timelines, count, usize);
119: if (IS_ERR(fences))
120: return ERR_CAST(fences);
121:
122: if (count == 1) {
123: struct dma_fence *fence = fences[0];
124:
125: kfree(fences);
126: return fence;
127: }
128:
129: array = kgsl_dma_fence_array_create(count, fences);
130:
131: if (array)
132: return &array->base;
133:
134: for (i = 0; i < count; i++)
135: dma_fence_put(fences[i]);
136:
137: kfree(fences);
138: return ERR_PTR(-ENOMEM);
139: }
140:
141: void kgsl_timeline_destroy(struct kref *kref)
142: {
143: struct kgsl_timeline *timeline = container_of(kref,
144: struct kgsl_timeline, ref);
145:
146: WARN_ON(!list_empty(&timeline->fences));
147: WARN_ON(!list_empty(&timeline->events));
148:
149: trace_kgsl_timeline_destroy(timeline->id);
150:
151: kfree(timeline);
152: }
153:
154: struct kgsl_timeline *kgsl_timeline_get(struct kgsl_timeline *timeline)
155: {
156: if (timeline) {
157: if (!kref_get_unless_zero(&timeline->ref))
158: return NULL;
159: }
MATCH LINES: 187, 207, 212, 234, 238, 242, 245, 249, 254, 264, 269, 276, 284, 302, 312
175: idr_preload(GFP_KERNEL);
176: spin_lock(&device->timelines_lock);
177: /* Allocate the ID but don't attach the pointer just yet */
178: id = idr_alloc(&device->timelines, NULL, 1, 0, GFP_NOWAIT);
179: spin_unlock(&device->timelines_lock);
180: idr_preload_end();
181:
182: if (id < 0) {
183: kfree(timeline);
184: return ERR_PTR(id);
185: }
186:
187: timeline->context = dma_fence_context_alloc(1);
188: timeline->id = id;
189: INIT_LIST_HEAD(&timeline->fences);
190: INIT_LIST_HEAD(&timeline->events);
191: timeline->value = initial;
192: timeline->dev_priv = dev_priv;
193:
194: snprintf((char *) timeline->name, sizeof(timeline->name),
195: "kgsl-sw-timeline-%d", id);
196:
197: trace_kgsl_timeline_alloc(id, initial);
198:
199: spin_lock_init(&timeline->lock);
200: spin_lock_init(&timeline->fence_lock);
201:
202: kref_init(&timeline->ref);
203:
204: return timeline;
205: }
206:
207: static struct kgsl_timeline_fence *to_timeline_fence(struct dma_fence *fence)
208: {
209: return container_of(fence, struct kgsl_timeline_fence, base);
210: }
211:
212: static void timeline_fence_release(struct dma_fence *fence)
213: {
214: struct kgsl_timeline_fence *f = to_timeline_fence(fence);
215: struct kgsl_timeline *timeline = f->timeline;
216: struct kgsl_timeline_fence *cur, *temp;
217: unsigned long flags;
218:
219: spin_lock_irqsave(&timeline->fence_lock, flags);
220:
221: /* If the fence is still on the active list, remove it */
222: list_for_each_entry_safe(cur, temp, &timeline->fences, node) {
223: if (f != cur)
224: continue;
225:
226: list_del_init(&f->node);
227: break;
228: }
229: spin_unlock_irqrestore(&timeline->fence_lock, flags);
230: trace_kgsl_timeline_fence_release(f->timeline->id, fence->seqno);
231: log_kgsl_timeline_fence_release_event(f->timeline->id, fence->seqno);
232:
233: kgsl_timeline_put(f->timeline);
234: dma_fence_free(fence);
235: }
236:
237: #if (KERNEL_VERSION(6, 17, 0) <= LINUX_VERSION_CODE)
238: static bool timeline_fence_signaled(struct dma_fence *fence)
239: {
240: struct kgsl_timeline_fence *f = to_timeline_fence(fence);
241:
242: return !__dma_fence_is_later(fence, fence->seqno, f->timeline->value);
243: }
244: #else
245: static bool timeline_fence_signaled(struct dma_fence *fence)
246: {
247: struct kgsl_timeline_fence *f = to_timeline_fence(fence);
248:
249: return !__dma_fence_is_later(fence->seqno, f->timeline->value,
250: fence->ops);
251: }
252: #endif
253:
254: static bool timeline_fence_enable_signaling(struct dma_fence *fence)
255: {
256: /*
257: * Return value of false indicates the fence already passed.
258: * When fence is not passed we return true indicating successful
259: * enabling.
260: */
261: return !timeline_fence_signaled(fence);
262: }
263:
264: static const char *timeline_get_driver_name(struct dma_fence *fence)
265: {
266: return "kgsl-sw-timeline";
267: }
268:
269: static const char *timeline_get_timeline_name(struct dma_fence *fence)
270: {
271: struct kgsl_timeline_fence *f = to_timeline_fence(fence);
272:
273: return f->timeline->name;
274: }
275:
276: static void timeline_get_value_str(struct dma_fence *fence,
277: char *str, int size)
278: {
279: struct kgsl_timeline_fence *f = to_timeline_fence(fence);
280:
281: snprintf(str, size, "%lld", f->timeline->value);
282: }
283:
284: static const struct dma_fence_ops timeline_fence_ops = {
285: .get_driver_name = timeline_get_driver_name,
286: .get_timeline_name = timeline_get_timeline_name,
287: .signaled = timeline_fence_signaled,
288: .release = timeline_fence_release,
289: .enable_signaling = timeline_fence_enable_signaling,
290:
291: #if (KERNEL_VERSION(6, 16, 0) > LINUX_VERSION_CODE)
292: .timeline_value_str = timeline_get_value_str,
293: #endif
294:
295: #if (KERNEL_VERSION(6, 17, 0) > LINUX_VERSION_CODE)
296: .use_64bit_seqno = true,
297: #endif
298:
299: };
300:
301: #if (KERNEL_VERSION(6, 16, 0) > LINUX_VERSION_CODE)
302: void kgsl_fence_timeline_value_str(struct dma_fence *fence, char *value, size_t size)
303: {
304: if (!fence || !fence->ops || !value || !size)
305: return;
306:
307: if (fence->ops->timeline_value_str)
308: fence->ops->timeline_value_str(fence, value, size);
309:
310: }
311: #else
312: void kgsl_fence_timeline_value_str(struct dma_fence *fence, char *value, size_t size)
313: {
314: if (!fence || !fence->ops || !value || !size)
315: return;
316:
317: if (fence->ops == &timeline_fence_ops)
318: timeline_get_value_str(fence, value, size);
319: else
320: kgsl_sync_timeline_value_str(fence, value, size);
321: }
322: #endif
323:
324: static void kgsl_timeline_add_fence(struct kgsl_timeline *timeline,
325: struct kgsl_timeline_fence *fence)
326: {
327: struct kgsl_timeline_fence *entry;
328: unsigned long flags;
329:
330: spin_lock_irqsave(&timeline->fence_lock, flags);
331: list_for_each_entry(entry, &timeline->fences, node) {
332: if (fence->base.seqno < entry->base.seqno) {
333: list_add_tail(&fence->node, &entry->node);
334: spin_unlock_irqrestore(&timeline->fence_lock, flags);
335: return;
336: }
MATCH LINES: 398, 399, 407, 408, 410, 413, 414, 416, 420, 435, 446
386: /* Remove retired nodes */
387: list_del(&event->node);
388: }
389:
390: spin_lock(&timeline->fence_lock);
391: list_for_each_entry_safe(fence, tmp, &timeline->fences, node)
392: if (timeline_fence_signaled(&fence->base) &&
393: kref_get_unless_zero(&fence->base.refcount))
394: list_move(&fence->node, &temp);
395: spin_unlock(&timeline->fence_lock);
396:
397: list_for_each_entry_safe(fence, tmp, &temp, node) {
398: dma_fence_signal_locked(&fence->base);
399: dma_fence_put(&fence->base);
400: }
401:
402: unlock:
403: spin_unlock_irq(&timeline->lock);
404: }
405:
406: #if KERNEL_VERSION(6, 17, 0) <= LINUX_VERSION_CODE
407: static inline void kgsl_timeline_dma_fence_init(struct dma_fence *fence,
408: const struct dma_fence_ops *ops, spinlock_t *lock, u64 context, u64 seqno)
409: {
410: dma_fence_init64(fence, ops, lock, context, seqno);
411: }
412: #else
413: static inline void kgsl_timeline_dma_fence_init(struct dma_fence *fence,
414: const struct dma_fence_ops *ops, spinlock_t *lock, u64 context, u64 seqno)
415: {
416: dma_fence_init(fence, ops, lock, context, seqno);
417: }
418: #endif
419:
420: struct dma_fence *kgsl_timeline_fence_alloc(struct kgsl_timeline *timeline,
421: u64 seqno)
422: {
423: struct kgsl_timeline_fence *fence;
424:
425: fence = kzalloc(sizeof(*fence), GFP_KERNEL);
426: if (!fence)
427: return ERR_PTR(-ENOMEM);
428:
429: fence->timeline = kgsl_timeline_get(timeline);
430: if (!fence->timeline) {
431: kfree(fence);
432: return ERR_PTR(-ENOENT);
433: }
434:
435: kgsl_timeline_dma_fence_init(&fence->base, &timeline_fence_ops, &timeline->lock,
436: timeline->context, seqno);
437:
438: INIT_LIST_HEAD(&fence->node);
439:
440: /*
441: * Once fence is checked as not signaled, allow it to be added
442: * in the list before other thread such as kgsl_timeline_signal
443: * can get chance to signal.
444: */
445: spin_lock_irq(&timeline->lock);
446: if (!dma_fence_is_signaled_locked(&fence->base))
447: kgsl_timeline_add_fence(timeline, fence);
448:
449: trace_kgsl_timeline_fence_alloc(timeline->id, seqno);
450: spin_unlock_irq(&timeline->lock);
451:
452: log_kgsl_timeline_fence_alloc_event(timeline->id, seqno);
453:
454: return &fence->base;
455: }
456:
457: long kgsl_ioctl_timeline_create(struct kgsl_device_private *dev_priv,
458: unsigned int cmd, void *data)
459: {
460: struct kgsl_device *device = dev_priv->device;
461: struct kgsl_timeline_create *param = data;
462: struct kgsl_timeline *timeline;
463:
464: timeline = kgsl_timeline_alloc(dev_priv, param->seqno);
465: if (IS_ERR(timeline))
466: return PTR_ERR(timeline);
467:
468: /* Commit the pointer to the timeline in timeline idr */
469: spin_lock(&device->timelines_lock);
470: idr_replace(&device->timelines, timeline, timeline->id);
MATCH LINES: 497, 498, 527, 531, 534, 537, 542, 543
485: if (timeline)
486: ret = kref_get_unless_zero(&timeline->ref);
487: spin_unlock(&device->timelines_lock);
488:
489: return ret ? timeline : NULL;
490: }
491:
492: long kgsl_ioctl_timeline_wait(struct kgsl_device_private *dev_priv,
493: unsigned int cmd, void *data)
494: {
495: struct kgsl_device *device = dev_priv->device;
496: struct kgsl_timeline_wait *param = data;
497: struct dma_fence_array *array;
498: struct dma_fence **fences;
499: unsigned long timeout;
500: signed long ret;
501: int i;
502:
503: if (param->flags != KGSL_TIMELINE_WAIT_ANY &&
504: param->flags != KGSL_TIMELINE_WAIT_ALL)
505: return -EINVAL;
506:
507: if (param->padding)
508: return -EINVAL;
509:
510: fences = kgsl_timelines_collect_fences(device, param->timelines,
511: param->count, param->timelines_size);
512:
513: if (IS_ERR(fences))
514: return PTR_ERR(fences);
515:
516: if (param->tv_sec >= KTIME_SEC_MAX)
517: timeout = MAX_SCHEDULE_TIMEOUT;
518: else {
519: ktime_t time = ktime_set(param->tv_sec, param->tv_nsec);
520:
521: timeout = msecs_to_jiffies(ktime_to_ms(time));
522: }
523:
524: trace_kgsl_timeline_wait(param->flags, param->tv_sec, param->tv_nsec);
525:
526: if (param->flags == KGSL_TIMELINE_WAIT_ANY) {
527: ret = dma_fence_wait_any_timeout(fences, param->count,
528: true, timeout, NULL);
529:
530: for (i = 0; i < param->count; i++)
531: dma_fence_put(fences[i]);
532: kfree(fences);
533: } else {
534: array = kgsl_dma_fence_array_create(param->count, fences);
535: if (!array) {
536: for (i = 0; i < param->count; i++)
537: dma_fence_put(fences[i]);
538: kfree(fences);
539: return -ENOMEM;
540: }
541:
542: ret = dma_fence_wait_timeout(&array->base, true, timeout);
543: dma_fence_put(&array->base);
544: }
545:
546: if (!ret)
547: ret = (!timeout) ? -EBUSY : -ETIMEDOUT;
548: else if (ret > 0)
549: ret = 0;
550:
551: return ret;
552: }
553:
554: long kgsl_ioctl_timeline_query(struct kgsl_device_private *dev_priv,
555: unsigned int cmd, void *data)
556: {
557: struct kgsl_timeline_val *param = data;
558: struct kgsl_timeline *timeline;
559: struct kgsl_timeline_event *event;
560: u64 seqno;
561:
562: if (param->padding)
563: return -EINVAL;
564:
565: timeline = kgsl_timeline_by_id(dev_priv->device, param->timeline);
566: if (!timeline)
567: return -ENODEV;
MATCH LINES: 598, 599, 619, 620, 621, 629
586: param->seqno = seqno;
587: kgsl_timeline_put(timeline);
588:
589: return 0;
590: }
591:
592: long kgsl_ioctl_timeline_fence_get(struct kgsl_device_private *dev_priv,
593: unsigned int cmd, void *data)
594: {
595: struct kgsl_device *device = dev_priv->device;
596: struct kgsl_timeline_fence_get *param = data;
597: struct kgsl_timeline *timeline;
598: struct sync_file *sync_file;
599: struct dma_fence *fence;
600: int ret = 0, fd;
601:
602: timeline = kgsl_timeline_by_id(device, param->timeline);
603: if (!timeline)
604: return -ENODEV;
605:
606: fence = kgsl_timeline_fence_alloc(timeline, param->seqno);
607:
608: if (IS_ERR(fence)) {
609: kgsl_timeline_put(timeline);
610: return PTR_ERR(fence);
611: }
612:
613: fd = get_unused_fd_flags(O_CLOEXEC);
614: if (fd < 0) {
615: ret = fd;
616: goto out;
617: }
618:
619: sync_file = sync_file_create(fence);
620: if (sync_file) {
621: fd_install(fd, sync_file->file);
622: param->handle = fd;
623: } else {
624: put_unused_fd(fd);
625: ret = -ENOMEM;
626: }
627:
628: out:
629: dma_fence_put(fence);
630: kgsl_timeline_put(timeline);
631:
632: return ret;
633: }
634:
635: long kgsl_ioctl_timeline_signal(struct kgsl_device_private *dev_priv,
636: unsigned int cmd, void *data)
637: {
638: struct kgsl_device *device = dev_priv->device;
639: struct kgsl_timeline_signal *param = data;
640: u64 timelines;
641: int i;
642:
643: if (!param->timelines_size) {
644: param->timelines_size = sizeof(struct kgsl_timeline_val);
645: return -EAGAIN;
646: }
647:
648: if (!param->count)
649: return -EINVAL;
650:
651: timelines = param->timelines;
652:
653: for (i = 0; i < param->count; i++) {
MATCH LINES: 721, 722, 723
709:
710: INIT_LIST_HEAD(&temp);
711:
712: spin_lock(&timeline->fence_lock);
713: list_for_each_entry_safe(fence, tmp, &timeline->fences, node)
714: if (!kref_get_unless_zero(&fence->base.refcount))
715: list_del_init(&fence->node);
716: list_replace_init(&timeline->fences, &temp);
717: spin_unlock(&timeline->fence_lock);
718:
719: spin_lock_irq(&timeline->lock);
720: list_for_each_entry_safe(fence, tmp, &temp, node) {
721: dma_fence_set_error(&fence->base, -ENOENT);
722: dma_fence_signal_locked(&fence->base);
723: dma_fence_put(&fence->base);
724: }
725: spin_unlock_irq(&timeline->lock);
726:
727: kgsl_timeline_put(timeline);
728:
729: return 0;
730: }
--- FILE: \kgsl_timeline.h | HITS: 4 ---
MATCH LINES: 54, 66
42: /** @seqno: seqno of the timeline to signal */
43: u64 seqno;
44: /** @context: context this event is waiting for */
45: struct kgsl_context *context;
46: /** @timestamp: context timestamp this event is waiting for */
47: unsigned int timestamp;
48: /** @node: list node */
49: struct list_head node;
50: };
51:
52: /**
53: * kgsl_fence_timeline_value_str - Get the timeline value as a string
54: * @fence: Pointer to the dma_fence object
55: * @value: Pointer to the character buffer to store the value string
56: * @size: Size of the character buffer
57: *
58: * This function retrieves the timeline value from a DMA fence as a string and
59: * copies at most @size characters into @value.
60: * It delegates to the appropriate timeline_value_str implementation based on
61: * the fence operations.
62: *
63: * If either the fence, fence operations, or value pointer is NULL, the function
64: * returns without doing anything.
65: */
66: void kgsl_fence_timeline_value_str(struct dma_fence *fence, char *value,
67: size_t size);
68:
69: /**
70: * kgsl_timeline_add_signal - Notify a timeline of an upcoming signal
71: * @signal: Pointer to a kgsl_timeline_event
72: *
73: * Notify the timeline that a GPU AUX command is expected to signal.
74: */
75: void kgsl_timeline_add_signal(struct kgsl_timeline_event *signal);
76:
77: /**
78: * kgsl_timeline_signal - Signal the timeline
79: * @timeline: Pointer to a timeline container
80: * @seqno: Seqeuence number to signal
81: *
82: * Advance @timeline to sequence number @seqno and signal any fences that might
83: * have expired.
84: */
85: void kgsl_timeline_signal(struct kgsl_timeline *timeline, u64 seqno);
86:
87: /**
88: * kgsl_timeline_destroy - Timeline destroy callback
89: * @kref: Refcount pointer for the timeline
90: *
MATCH LINES: 105
93: */
94: void kgsl_timeline_destroy(struct kref *kref);
95:
96: /**
97: * kgsl_timeline_fence_alloc - Allocate a new fence on a timeline
98: * @timeline: Pointer to a timeline container
99: * @seqno: Sequence number for the new fence to wait for
100: *
101: * Create and return a new fence on the timeline that will expire when the
102: * timeline value is greater or equal to @seqno.
103: * Return: A pointer to the newly created fence
104: */
105: struct dma_fence *kgsl_timeline_fence_alloc(struct kgsl_timeline *timeline,
106: u64 seqno);
107:
108: /**
109: * kgsl_timeline_by_id - Look up a timeline by an id
110: * @device: A KGSL device handle
111: * @id: Lookup identifier
112: *
113: * Find and return the timeline associated with identifer @id.
114: * Return: A pointer to a timeline or PTR_ERR() encoded error on failure.
115: */
116: struct kgsl_timeline *kgsl_timeline_by_id(struct kgsl_device *device,
117: u32 id);
118:
119: /**
120: * kgsl_timeline_get - Get a reference to an existing timeline
121: * @timeline: Pointer to a timeline container
122: *
123: * Get a new reference to the timeline and return the pointer back to the user.
124: * Return: The pointer to the timeline or PTR_ERR encoded error on failure
125: */
126: struct kgsl_timeline *kgsl_timeline_get(struct kgsl_timeline *timeline);
127:
128: /**
129: * kgsl_timeline_put - Release a reference to a timeline
MATCH LINES: 152
140:
141: /**
142: * kgsl_timelines_to_fence_array - Return a dma-fence array of timeline fences
143: * @device: A KGSL device handle
144: * @timelines: Userspace pointer to an array of &struct kgsl_timeline_val
145: * @count: Number of entries in @timelines
146: * @usize: Size of each entry in @timelines
147: *
148: * Given a list of &struct kgsl_timeline_val entries, create a dma-fence-array
149: * containing fences for each timeline/seqno pair. The fence will wait for ALL
150: * of the encapsulated timeline fences to expire.
151: */
152: struct dma_fence *kgsl_timelines_to_fence_array(struct kgsl_device *device,
153: u64 timelines, u32 count, u64 usize);
154:
155: #endif
--- FILE: \kgsl_trace.h | HITS: 18 ---
MATCH LINES: 1103, 1106, 1108, 1113, 1118, 1123, 1126, 1130, 1133, 1137, 1138, 1141, 1144, 1148, 1152, 1153, 1157, 1158
1091: TP_STRUCT__entry(
1092: __field(u64, ptbase)
1093: __field(unsigned int, name)
1094: ),
1095: TP_fast_assign(
1096: __entry->ptbase = ptbase;
1097: __entry->name = name;
1098: ),
1099: TP_printk("ptbase=%llx name=%u", __entry->ptbase, __entry->name)
1100: );
1101:
1102: DECLARE_EVENT_CLASS(syncpoint_timestamp_template,
1103: TP_PROTO(struct kgsl_drawobj_sync *syncobj,
1104: struct kgsl_context *context,
1105: unsigned int timestamp),
1106: TP_ARGS(syncobj, context, timestamp),
1107: TP_STRUCT__entry(
1108: __field(unsigned int, syncobj_context_id)
1109: __field(unsigned int, context_id)
1110: __field(unsigned int, timestamp)
1111: ),
1112: TP_fast_assign(
1113: __entry->syncobj_context_id = syncobj->base.context->id;
1114: __entry->context_id = context->id;
1115: __entry->timestamp = timestamp;
1116: ),
1117: TP_printk("ctx=%u sync ctx=%u ts=%u",
1118: __entry->syncobj_context_id, __entry->context_id,
1119: __entry->timestamp)
1120: );
1121:
1122: DEFINE_EVENT(syncpoint_timestamp_template, syncpoint_timestamp,
1123: TP_PROTO(struct kgsl_drawobj_sync *syncobj,
1124: struct kgsl_context *context,
1125: unsigned int timestamp),
1126: TP_ARGS(syncobj, context, timestamp)
1127: );
1128:
1129: DEFINE_EVENT(syncpoint_timestamp_template, syncpoint_timestamp_expire,
1130: TP_PROTO(struct kgsl_drawobj_sync *syncobj,
1131: struct kgsl_context *context,
1132: unsigned int timestamp),
1133: TP_ARGS(syncobj, context, timestamp)
1134: );
1135:
1136: DECLARE_EVENT_CLASS(syncpoint_fence_template,
1137: TP_PROTO(struct kgsl_drawobj_sync *syncobj, char *name),
1138: TP_ARGS(syncobj, name),
1139: TP_STRUCT__entry(
1140: __string(fence_name, name)
1141: __field(unsigned int, syncobj_context_id)
1142: ),
1143: TP_fast_assign(
1144: __entry->syncobj_context_id = syncobj->base.context->id;
1145: kgsl_assign_str(fence_name, name);
1146: ),
1147: TP_printk("ctx=%u fence=%s",
1148: __entry->syncobj_context_id, __get_str(fence_name))
1149: );
1150:
1151: DEFINE_EVENT(syncpoint_fence_template, syncpoint_fence,
1152: TP_PROTO(struct kgsl_drawobj_sync *syncobj, char *name),
1153: TP_ARGS(syncobj, name)
1154: );
1155:
1156: DEFINE_EVENT(syncpoint_fence_template, syncpoint_fence_expire,
1157: TP_PROTO(struct kgsl_drawobj_sync *syncobj, char *name),
1158: TP_ARGS(syncobj, name)
1159: );
1160:
1161: TRACE_EVENT(kgsl_msg,
1162: TP_PROTO(const char *msg),
1163: TP_ARGS(msg),
1164: TP_STRUCT__entry(
1165: __string(msg, msg)
1166: ),
1167: TP_fast_assign(
1168: kgsl_assign_str(msg, msg);
1169: ),
1170: TP_printk(
1171: "%s", __get_str(msg)
1172: )
1173: );
1174:
1175: TRACE_EVENT(kgsl_clock_throttling,
1176: TP_PROTO(
1177: int idle_10pct,
1178: int crc_50pct,
1179: int crc_more50pct,
1180: int crc_less50pct,
1181: int64_t adj
1182: ),
--- FILE: \kgsl_util.c | HITS: 1 ---
MATCH LINES: 354
342:
343: for (i = 0; i < kgsl_num_pools; i++) {
344: ret = kgsl_add_va_to_minidump(device->dev, KGSL_PAGE_POOL_ENTRY,
345: (void *)&kgsl_pools[i], sizeof(kgsl_pools[i]));
346: if (ret)
347: return ret;
348: }
349:
350: return 0;
351: }
352: #endif
353:
354: #ifdef CONFIG_SYNC_FILE
355: static int kgsl_add_sync_timeline_info_to_va_minidump(struct kgsl_device *device)
356: {
357: int ret, id;
358: struct kgsl_context *context;
359:
360: idr_for_each_entry(&device->context_idr, context, id) {
361: char name[MAX_VA_MINIDUMP_STR_LEN];
362: struct kgsl_sync_fence *kfence, *next;
363: struct kgsl_sync_timeline *ktimeline = context->ktimeline;
364:
365: snprintf(name, sizeof(name), KGSL_SYNC_TIMELINE_ENTRY "_ctxt:%d", context->id);
366: ret = kgsl_add_va_to_minidump(device->dev, name,
367: (void *)(ktimeline), sizeof(*ktimeline));
368: if (ret)
369: return ret;
370:
371: list_for_each_entry_safe(kfence, next, &ktimeline->child_list_head, child_list) {
372: snprintf(name, sizeof(name), KGSL_SYNC_FENCE_ENTRY "_ctxt:%d",
373: context->id);
374: ret = kgsl_add_va_to_minidump(device->dev, name,
375: (void *)(kfence), sizeof(*kfence));
376: if (ret)
377: return ret;
378: }
--- FILE: \kgsl_vbo.c | HITS: 16 ---
MATCH LINES: 10
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 <linux/file.h>
8: #include <linux/interval_tree.h>
9: #include <linux/seq_file.h>
10: #include <linux/sync_file.h>
11: #include <linux/slab.h>
12:
13: #include "kgsl_device.h"
14: #include "kgsl_mmu.h"
15: #include "kgsl_reclaim.h"
16: #include "kgsl_sharedmem.h"
17: #include "kgsl_trace.h"
18:
19: struct kgsl_memdesc_bind_range {
20: struct kgsl_mem_entry *entry;
21: struct interval_tree_node range;
22: };
23:
24: static struct kgsl_memdesc_bind_range *bind_to_range(struct interval_tree_node *node)
25: {
26: return container_of(node, struct kgsl_memdesc_bind_range, range);
27: }
28:
29: static struct kgsl_memdesc_bind_range *bind_range_create(u64 start, u64 last,
30: struct kgsl_mem_entry *entry)
31: {
32: struct kgsl_memdesc_bind_range *range =
33: kzalloc(sizeof(*range), GFP_KERNEL);
34:
MATCH LINES: 537
525: }
526:
527: op->ops[i].entry = entry;
528: op->ops[i].start = range.target_offset;
529: op->ops[i].last = range.target_offset + range.length - 1;
530: op->ops[i].child_offset = range.child_offset;
531: op->ops[i].op = range.op;
532:
533: ranges += ranges_size;
534: }
535:
536: atomic_dec(&private->cmd_count);
537: init_completion(&op->comp);
538: kref_init(&op->ref);
539:
540: return op;
541:
542: err:
543: atomic_dec(&private->cmd_count);
544: kgsl_sharedmem_free_bind_op(op);
545: return ERR_PTR(ret);
546: }
547:
548: void kgsl_sharedmem_bind_range_destroy(struct kref *kref)
549: {
550: struct kgsl_sharedmem_bind_op *op = container_of(kref,
551: struct kgsl_sharedmem_bind_op, ref);
552:
553: kgsl_sharedmem_free_bind_op(op);
554: }
555:
556: static void kgsl_sharedmem_bind_worker(struct work_struct *work)
557: {
558: struct kgsl_sharedmem_bind_op *op = container_of(work,
559: struct kgsl_sharedmem_bind_op, work);
560: int i;
561:
MATCH LINES: 603, 609, 614, 619, 633, 634, 637, 647, 656, 657, 665, 666, 672
591: }
592:
593: void kgsl_sharedmem_bind_ranges(struct kgsl_sharedmem_bind_op *op)
594: {
595: /* Take a reference to the operation while it is scheduled */
596: kref_get(&op->ref);
597:
598: INIT_WORK(&op->work, kgsl_sharedmem_bind_worker);
599: schedule_work(&op->work);
600: }
601:
602: struct kgsl_sharedmem_bind_fence {
603: struct dma_fence base;
604: spinlock_t lock;
605: int fd;
606: struct kgsl_sharedmem_bind_op *op;
607: };
608:
609: static const char *bind_fence_get_driver_name(struct dma_fence *fence)
610: {
611: return "kgsl_sharedmem_bind";
612: }
613:
614: static const char *bind_fence_get_timeline_name(struct dma_fence *fence)
615: {
616: return "(unbound)";
617: }
618:
619: static void bind_fence_release(struct dma_fence *fence)
620: {
621: struct kgsl_sharedmem_bind_fence *bind_fence = container_of(fence,
622: struct kgsl_sharedmem_bind_fence, base);
623:
624: kgsl_sharedmem_put_bind_op(bind_fence->op);
625: kfree(bind_fence);
626: }
627:
628: static void
629: kgsl_sharedmem_bind_fence_callback(struct kgsl_sharedmem_bind_op *op)
630: {
631: struct kgsl_sharedmem_bind_fence *bind_fence = op->data;
632:
633: dma_fence_signal(&bind_fence->base);
634: dma_fence_put(&bind_fence->base);
635: }
636:
637: static const struct dma_fence_ops kgsl_sharedmem_bind_fence_ops = {
638: .get_driver_name = bind_fence_get_driver_name,
639: .get_timeline_name = bind_fence_get_timeline_name,
640: .release = bind_fence_release,
641: };
642:
643: static struct kgsl_sharedmem_bind_fence *
644: kgsl_sharedmem_bind_fence(struct kgsl_sharedmem_bind_op *op)
645: {
646: struct kgsl_sharedmem_bind_fence *fence;
647: struct sync_file *sync_file;
648: int fd;
649:
650: fence = kzalloc(sizeof(*fence), GFP_KERNEL);
651: if (!fence)
652: return ERR_PTR(-ENOMEM);
653:
654: spin_lock_init(&fence->lock);
655:
656: dma_fence_init(&fence->base, &kgsl_sharedmem_bind_fence_ops,
657: &fence->lock, dma_fence_context_alloc(1), 0);
658:
659: fd = get_unused_fd_flags(O_CLOEXEC);
660: if (fd < 0) {
661: kfree(fence);
662: return ERR_PTR(fd);
663: }
664:
665: sync_file = sync_file_create(&fence->base);
666: if (!sync_file) {
667: put_unused_fd(fd);
668: kfree(fence);
669: return ERR_PTR(-ENOMEM);
670: }
671:
672: fd_install(fd, sync_file->file);
673:
674: fence->fd = fd;
675: fence->op = op;
676:
677: return fence;
678: }
679:
680: long kgsl_ioctl_gpumem_bind_ranges(struct kgsl_device_private *dev_priv,
681: unsigned int cmd, void *data)
682: {
683: struct kgsl_process_private *private = dev_priv->process_priv;
684: struct kgsl_gpumem_bind_ranges *param = data;
685: struct kgsl_sharedmem_bind_op *op;
686: int ret;
687:
688: /* If ranges_size isn't set, return the expected size to the user */
689: if (!param->ranges_size) {
690: param->ranges_size = sizeof(struct kgsl_gpumem_bind_range);
691: return 0;
692: }
693:
694: /* FENCE_OUT only makes sense with ASYNC */
695: if ((param->flags & KGSL_GPUMEM_BIND_FENCE_OUT) &&
696: !(param->flags & KGSL_GPUMEM_BIND_ASYNC))
MATCH LINES: 735
723: if (!(param->flags & KGSL_GPUMEM_BIND_FENCE_OUT))
724: kgsl_sharedmem_put_bind_op(op);
725:
726: return 0;
727: }
728:
729: /*
730: * Schedule the work. All the resources will be released after
731: * the bind operation is done
732: */
733: kgsl_sharedmem_bind_ranges(op);
734:
735: ret = wait_for_completion_interruptible(&op->comp);
736: kgsl_sharedmem_put_bind_op(op);
737:
738: return ret;
739: }
--- FILE: \downstream_dependencies\msm_hw_fence.h | HITS: 6 ---
MATCH LINES: 14, 16, 22
2: /*
3: * Copyright (c) 2020, The Linux Foundation. All rights reserved.
4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
5: */
6:
7: #ifndef __MSM_HW_FENCE_H
8: #define __MSM_HW_FENCE_H
9:
10: #include <linux/types.h>
11: #include <linux/dma-fence.h>
12:
13: /**
14: * MSM_HW_FENCE_FLAG_ENABLED_BIT - Hw-fence is enabled for the dma_fence.
15: *
16: * Drivers set this flag in the dma_fence 'flags' to fences that
17: * are backed up by a hw-fence.
18: */
19: #define MSM_HW_FENCE_FLAG_ENABLED_BIT 31
20:
21: /**
22: * MSM_HW_FENCE_FLAG_SIGNALED_BIT - Hw-fence is signaled for the dma_fence.
23: *
24: * This flag is set by hw-fence driver when a client wants to add itself as
25: * a waiter for this hw-fence. The client uses this flag to avoid adding itself
26: * as a waiter for a fence that is already retired.
27: */
28: #define MSM_HW_FENCE_FLAG_SIGNALED_BIT 30
29:
30: /**
31: * MSM_HW_FENCE_MAX_SIGNAL_PER_CLIENT - Maximum number of signals per client
32: */
33: #define MSM_HW_FENCE_MAX_SIGNAL_PER_CLIENT 64
34:
35: /**
36: * struct msm_hw_fence_create_params - Creation parameters.
37: *
38: * @name : Optional parameter associating a name with the object for debug purposes.
39: * Only first 64 bytes are accepted, rest will be ignored.
40: * @handle : Pointer to fence hash (filled by function).
41: * @fence : Pointer to fence.
42: * @flags : flags for customization.
43: */
44: struct msm_hw_fence_create_params {
45: const char *name;
46: u64 *handle;
MATCH LINES: 197, 203, 220
185:
186: static inline int msm_hw_fence_deregister(void *client_handle)
187: {
188: return -EINVAL;
189: }
190:
191: static inline int msm_hw_fence_create(void *client_handle,
192: struct msm_hw_fence_create_params *params)
193: {
194: return -EINVAL;
195: }
196:
197: static inline int msm_hw_fence_destroy(void *client_handle, struct dma_fence *fence)
198: {
199: return -EINVAL;
200: }
201:
202: static inline int msm_hw_fence_wait_update(void *client_handle,
203: struct dma_fence **fences, u32 num_fences, bool reg)
204: {
205: return -EINVAL;
206: }
207:
208: static inline int msm_hw_fence_update_txq(void *client_handle, u64 handle, u64 flags, u32 error)
209: {
210: return -EINVAL;
211: }
212:
213: static inline int msm_hw_fence_trigger_signal(void *client_handle, u32 tx_client_id,
214: u32 rx_client_id, u32 signal_id)
215: {
216: return -EINVAL;
217: }
218:
219: static inline int msm_hw_fence_wait_update_v2(void *client_handle,
220: struct dma_fence **fences, u64 *handles, u64 *client_data_list, u32 num_fences, bool reg)
221: {
222: return -EINVAL;
223: }
224: #endif
--- FILE: \include\uapi\linux\msm_kgsl.h | HITS: 7 ---
MATCH LINES: 243
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 {
MATCH LINES: 1302, 1313, 1314, 1326, 1333, 1334
1290: };
1291:
1292: #define IOCTL_KGSL_SYNCSOURCE_DESTROY \
1293: _IOWR(KGSL_IOC_TYPE, 0x41, struct kgsl_syncsource_destroy)
1294:
1295: /**
1296: * struct kgsl_syncsource_create_fence - Argument to
1297: * IOCTL_KGSL_SYNCSOURCE_CREATE_FENCE
1298: * @id: syncsource id
1299: * @fence_fd: returned sync_fence fd
1300: *
1301: * Create a fence that may be signaled by userspace by calling
1302: * IOCTL_KGSL_SYNCSOURCE_SIGNAL_FENCE. There are no order dependencies between
1303: * these fences.
1304: */
1305: struct kgsl_syncsource_create_fence {
1306: unsigned int id;
1307: int fence_fd;
1308: /* private: reserved for future use */
1309: unsigned int __pad[4];
1310: };
1311:
1312: /**
1313: * struct kgsl_syncsource_signal_fence - Argument to
1314: * IOCTL_KGSL_SYNCSOURCE_SIGNAL_FENCE
1315: * @id: syncsource id
1316: * @fence_fd: sync_fence fd to signal
1317: *
1318: * Signal a fence that was created by a IOCTL_KGSL_SYNCSOURCE_CREATE_FENCE
1319: * call using the same syncsource id. This allows a fence to be shared
1320: * to other processes but only signaled by the process owning the fd
1321: * used to create the fence.
1322: */
1323: #define IOCTL_KGSL_SYNCSOURCE_CREATE_FENCE \
1324: _IOWR(KGSL_IOC_TYPE, 0x42, struct kgsl_syncsource_create_fence)
1325:
1326: struct kgsl_syncsource_signal_fence {
1327: unsigned int id;
1328: int fence_fd;
1329: /* private: reserved for future use */
1330: unsigned int __pad[4];
1331: };
1332:
1333: #define IOCTL_KGSL_SYNCSOURCE_SIGNAL_FENCE \
1334: _IOWR(KGSL_IOC_TYPE, 0x43, struct kgsl_syncsource_signal_fence)
1335:
1336: /**
1337: * struct kgsl_cff_sync_gpuobj - Argument to IOCTL_KGSL_CFF_SYNC_GPUOBJ
1338: * @offset: Offset into the GPU object to sync
1339: * @length: Number of bytes to sync
1340: * @id: ID of the GPU object to sync
1341: */
1342: struct kgsl_cff_sync_gpuobj {
1343: __u64 offset;
1344: __u64 length;
1345: unsigned int id;
1346: };
1347:
1348: #define IOCTL_KGSL_CFF_SYNC_GPUOBJ \
1349: _IOW(KGSL_IOC_TYPE, 0x44, struct kgsl_cff_sync_gpuobj)
1350:
1351: /**
1352: * struct kgsl_gpuobj_alloc - Argument to IOCTL_KGSL_GPUOBJ_ALLOC
1353: * @size: Size in bytes of the object to allocate
1354: * @flags: mask of KGSL_MEMFLAG_* bits
1355: * @va_len: Size in bytes of the virtual region to allocate
1356: * @mmapsize: Returns the mmap() size of the object
1357: * @id: Returns the GPU object ID of the new object
1358: * @metadata_len: Length of the metdata to copy from the user
TOTAL MATCHES: 844
==========================================================================================
FINAL INVENTORY
==========================================================================================
Repository files: 250
Text files scanned: 213
Previous research files: 36
Manifest: FILE_MANIFEST.csv
Full source: SOURCE/
Previous reports: PREVIOUS_RESEARCH/