_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) | \ --- FILE: \adreno_a6xx_gmu.c | HITS: 5 --- MATCH LINES: 2055, 2058, 2060 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; MATCH LINES: 2736, 2737 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; --- FILE: \adreno_a6xx_gmu_snapshot.c | HITS: 3 --- MATCH LINES: 382, 383, 385 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_hwsched.c | HITS: 1 --- MATCH LINES: 68 56: if (entry->desc.mem_kind == HFI_MEMKIND_SCRATCH) 57: kgsl_snapshot_add_section(device, 58: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 59: snapshot, adreno_snapshot_global, 60: entry->md); 61: 62: if (entry->desc.mem_kind == HFI_MEMKIND_PROFILE) 63: kgsl_snapshot_add_section(device, 64: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 65: snapshot, adreno_snapshot_global, 66: entry->md); 67: 68: if (entry->desc.mem_kind == HFI_MEMKIND_CSW_SMMU_INFO) 69: kgsl_snapshot_add_section(device, 70: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 71: snapshot, adreno_snapshot_global, 72: entry->md); 73: 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) --- FILE: \adreno_a6xx_hwsched_hfi.c | HITS: 8 --- MATCH LINES: 7 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 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, \ MATCH LINES: 1279, 1280, 1293, 1294, 1298, 1299, 1301 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: 1285: ret = CMD_MSG_HDR(cmd, H2F_MSG_REGISTER_CONTEXT); 1286: if (ret) 1287: return ret; 1288: 1289: cmd.ctxt_id = context->id; 1290: cmd.flags = HFI_CTXT_FLAG_NOTIFY | context->flags; 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: } --- FILE: \adreno_a6xx_preempt.c | HITS: 39 --- MATCH LINES: 16, 17 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; MATCH LINES: 237, 239, 240 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: MATCH LINES: 283, 284, 285, 286, 287, 294, 297, 298, 299, 300 271: } 272: 273: /* Turn off the dispatcher timer */ 274: kgsl_delete_timer(&adreno_dev->dispatcher.timer); 275: 276: /* 277: * This is the most critical section - we need to take care not to race 278: * until we have programmed the CP for the switch 279: */ 280: 281: spin_lock_irqsave(&next->preempt_lock, flags); 282: 283: /* Get the pagetable from the pagetable info. */ 284: kgsl_sharedmem_readq(device->scratch, &ttbr0, 285: SCRATCH_RB_OFFSET(next->id, ttbr0)); 286: kgsl_sharedmem_readl(device->scratch, &contextidr, 287: SCRATCH_RB_OFFSET(next->id, contextidr)); 288: 289: kgsl_sharedmem_writel(next->preemption_desc, 290: PREEMPT_RECORD(wptr), next->wptr); 291: 292: spin_unlock_irqrestore(&next->preempt_lock, flags); 293: 294: /* And write it to the smmu info */ 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: */ MATCH LINES: 514, 515 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. 538: */ 539: *cmds++ = SET_PSEUDO_COUNTER; MATCH LINES: 586, 597, 598, 599, 600, 601, 604, 605, 606, 607, 609, 610, 612, 613, 622, 623 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: { MATCH LINES: 700, 706, 707, 724, 726, 728 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: --- FILE: \adreno_a6xx_ringbuffer.c | HITS: 16 --- MATCH LINES: 14, 16, 19, 23, 26, 27, 28, 40, 42, 43, 44, 61, 62, 67, 75, 76 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); --- FILE: \adreno_a6xx_snapshot.c | HITS: 3 --- MATCH LINES: 1574, 1575 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) MATCH LINES: 1817 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; --- FILE: \adreno_dispatch.c | HITS: 5 --- MATCH LINES: 1945, 1946, 1950 1933: adreno_write_gmureg(adreno_dev, 1934: ADRENO_REG_GMU_GMU2HOST_INTR_MASK, 1935: 0xFFFFFFFF); 1936: } 1937: 1938: gx_on = adreno_gx_is_on(adreno_dev); 1939: 1940: /* 1941: * Check if this function was entered after a pagefault. If so, only 1942: * proceed if the fault handler has already run in the IRQ thread, 1943: * else return early to give the fault handler a chance to run. 1944: */ 1945: if (!(fault & ADRENO_IOMMU_STALL_ON_PAGE_FAULT) && gx_on) { 1946: if (adreno_smmu_is_stalled(adreno_dev)) { 1947: kgsl_mutex_unlock(&device->mutex); 1948: mutex_unlock(&adreno_dev->fault_recovery_mutex); 1949: dev_err(device->dev, 1950: "SMMU is stalled without a pagefault\n"); 1951: return -EBUSY; 1952: } 1953: } 1954: 1955: /* Turn off all the timers */ 1956: kgsl_delete_timer_sync(&dispatcher->timer); 1957: 1958: /* 1959: * Deleting uninitialized timer will block for ever on kernel debug 1960: * disable build. Hence skip del timer if it is not initialized. 1961: */ 1962: if (adreno_is_preemption_enabled(adreno_dev)) 1963: kgsl_delete_timer_sync(&adreno_dev->preempt.timer); 1964: 1965: if (gx_on) 1966: adreno_readreg64(adreno_dev, ADRENO_REG_CP_RB_BASE, 1967: ADRENO_REG_CP_RB_BASE_HI, &base); 1968: 1969: /* Force the CP off for all faults to make sure it is good and stopped */ 1970: if (gx_on) { 1971: adreno_readreg(adreno_dev, ADRENO_REG_CP_ME_CNTL, ®); 1972: 1973: if (adreno_is_a5xx(adreno_dev) || adreno_is_a6xx(adreno_dev)) 1974: reg |= 1 | (1 << 1); MATCH LINES: 2019, 2020 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), 2042: hung_rb->timestamp); 2043: 2044: kgsl_sharedmem_writel(device->memstore, --- FILE: \adreno_drawctxt.h | HITS: 5 --- MATCH LINES: 180, 184, 187, 188, 191 168: * @rb: The ringbuffer that will trigger the timestamp event 169: * @timestamp: The timestamp on @rb that will trigger the event 170: * 171: * Add an event to put the refcount on @drawctxt after @timestamp expires on 172: * @rb. This is used by the context switch to safely put away the context after 173: * a new context is switched in. 174: */ 175: void adreno_put_drawctxt_on_timestamp(struct kgsl_device *device, 176: struct adreno_context *drawctxt, 177: struct adreno_ringbuffer *rb, u32 timestamp); 178: 179: /** 180: * adreno_drawctxt_get_pagetable - Helper function to return the pagetable for a 181: * context 182: * @drawctxt: The adreno draw context to query 183: * 184: * Return: A pointer to the pagetable for the process that owns the context or 185: * NULL 186: */ 187: static inline struct kgsl_pagetable * 188: adreno_drawctxt_get_pagetable(struct adreno_context *drawctxt) 189: { 190: if (drawctxt) 191: return drawctxt->base.proc_priv->pagetable; 192: 193: return NULL; 194: } 195: 196: /** 197: * adreno_drawctxt_set_guilty - Mark a context as guilty and invalidate it 198: * @device: Pointer to a GPU device handle 199: * @context: Pointer to the context to invalidate 200: * 201: * Mark the specified context as guilty and invalidate it 202: */ 203: void adreno_drawctxt_set_guilty(struct kgsl_device *device, 204: struct kgsl_context *context); 205: 206: /** 207: * adreno_prepare_preib_preempt_scratch - Update drawctxt pointer in preemption 208: * scratch buffer before IB commands 209: * @adreno_dev: Pointer to the adreno device 210: * @drawctxt: Pointer to the adreno draw context 211: * @cmds: Pointer to the ringbuffer to insert opcodes 212: * 213: * Return: The number of dwords written to @cmds 214: */ 215: u32 adreno_prepare_preib_preempt_scratch(struct adreno_device *adreno_dev, --- FILE: \adreno_gen7.c | HITS: 9 --- MATCH LINES: 823, 825, 828 811: { 812: if (IS_ERR_OR_NULL(adreno_dev->gpuhtw_llc_slice) || 813: !adreno_dev->gpuhtw_llc_slice_enable) 814: return; 815: 816: llcc_slice_activate(adreno_dev->gpuhtw_llc_slice); 817: } 818: 819: static void _set_secvid(struct kgsl_device *device) 820: { 821: kgsl_regwrite(device, GEN7_RBBM_SECVID_TSB_CNTL, 0x0); 822: kgsl_regwrite(device, GEN7_RBBM_SECVID_TSB_TRUSTED_BASE_LO, 823: lower_32_bits(KGSL_IOMMU_SECURE_BASE32)); 824: kgsl_regwrite(device, GEN7_RBBM_SECVID_TSB_TRUSTED_BASE_HI, 825: upper_32_bits(KGSL_IOMMU_SECURE_BASE32)); 826: kgsl_regwrite(device, GEN7_RBBM_SECVID_TSB_TRUSTED_SIZE, 827: FIELD_PREP(GENMASK(31, 12), 828: (KGSL_IOMMU_SECURE_SIZE(&device->mmu) / SZ_4K))); 829: } 830: 831: /* Set UCHE_TRAP_BASE to a page below the top of the memory space */ 832: #define GEN7_UCHE_TRAP_BASE 0x1FFFFFFFFF000ULL 833: 834: static u64 gen7_get_uche_trap_base(void) 835: { 836: return GEN7_UCHE_TRAP_BASE; 837: } 838: 839: /* 840: * All Gen7 targets support marking certain transactions as always privileged 841: * which allows us to mark more memory as privileged without having to 842: * explicitly set the APRIV bit. Choose the following transactions to be 843: * privileged by default: 844: * CDWRITE [6:6] - Crashdumper writes 845: * CDREAD [5:5] - Crashdumper reads 846: * RBRPWB [3:3] - RPTR shadow writes 847: * RBPRIVLEVEL [2:2] - Memory accesses from PM4 packets in the ringbuffer 848: * RBFETCH [1:1] - Ringbuffer reads 849: * ICACHE [0:0] - Instruction cache fetches 850: */ 851: 852: #define GEN7_APRIV_DEFAULT (BIT(3) | BIT(2) | BIT(1) | BIT(0)) MATCH LINES: 869 857: { 858: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 859: u32 val; 860: 861: if (!adreno_dev->ahb_timeout_val) 862: return; 863: 864: val = (ADRENO_AHB_CNTL_DEFAULT | FIELD_PREP(GENMASK(4, 0), 865: adreno_dev->ahb_timeout_val)); 866: kgsl_regwrite(device, GEN7_GPU_CX_MISC_CX_AHB_AON_CNTL, val); 867: kgsl_regwrite(device, GEN7_GPU_CX_MISC_CX_AHB_GMU_CNTL, val); 868: kgsl_regwrite(device, GEN7_GPU_CX_MISC_CX_AHB_CP_CNTL, val); 869: kgsl_regwrite(device, GEN7_GPU_CX_MISC_CX_AHB_VBIF_SMMU_CNTL, val); 870: kgsl_regwrite(device, GEN7_GPU_CX_MISC_CX_AHB_HOST_CNTL, val); 871: } 872: 873: int gen7_start(struct adreno_device *adreno_dev) 874: { 875: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 876: const struct adreno_gen7_core *gen7_core = to_gen7_core(adreno_dev); 877: struct adreno_ubwc_props *ubwc_props = &adreno_dev->ubwc_props; 878: u32 mal = adreno_dev->mal; 879: struct gen7_device *gen7_dev = container_of(adreno_dev, struct gen7_device, adreno_dev); 880: /* 881: * HBB values 13 to 16 can represented LSB of HBB from 0 to 3. 882: * Any HBB value beyond 16 needs programming MSB of HBB. 883: * By default highest bank bit is 14, Hence set default HBB LSB 884: * to "1" and MSB to "0". 885: */ 886: u32 hbb_lo = 1, hbb_hi = 0; 887: struct cpu_gpu_lock *pwrup_lock = adreno_dev->pwrup_reglist->hostptr; 888: u64 uche_trap_base = gen7_get_uche_trap_base(); 889: 890: /* Set up GX GBIF registers */ 891: kgsl_regwrite(device, GEN7_RBBM_GBIF_CLIENT_QOS_CNTL, 892: (adreno_is_gen7_3_0(adreno_dev)) ? 0x00000003 : 0x2120212); 893: kgsl_regwrite(device, GEN7_UCHE_GBIF_GX_CONFIG, 0x10240e0); MATCH LINES: 1550 1538: }; 1539: 1540: #define SCOOBYDOO 0x5c00bd00 1541: 1542: static const char *gen7_fault_block_uche(struct kgsl_device *device, 1543: char *str, int size, bool lpac) 1544: { 1545: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1546: unsigned int uche_client_id = adreno_dev->uche_client_pf; 1547: const char *uche_client_str, *fault_block; 1548: 1549: /* 1550: * Smmu driver takes a vote on CX gdsc before calling the kgsl 1551: * pagefault handler. If there is contention for device mutex in this 1552: * path and the dispatcher fault handler is holding this lock, trying 1553: * to turn off CX gdsc will fail during the reset. So to avoid blocking 1554: * here, try to lock device mutex and return if it fails. 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); MATCH LINES: 1598 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: 1592: fail: 1593: snprintf(str, size, "%s: Unknown (client_id: %u)", 1594: fault_block, uche_client_id); 1595: return str; 1596: } 1597: 1598: static const char *gen7_iommu_fault_block(struct kgsl_device *device, 1599: unsigned int fsynr1) 1600: { 1601: unsigned int mid = fsynr1 & 0xff; 1602: static char str[36]; 1603: 1604: switch (mid) { 1605: case 0x0: 1606: return "CP"; 1607: case 0x1: 1608: return "UCHE: Unknown"; 1609: case 0x2: 1610: return "UCHE_LPAC: Unknown"; 1611: case 0x3: 1612: return gen7_fault_block_uche(device, str, sizeof(str), false); 1613: case 0x4: 1614: return "CCU"; 1615: case 0x5: 1616: return "Flag cache"; 1617: case 0x6: 1618: return "PREFETCH"; 1619: case 0x7: 1620: return "GMU"; 1621: case 0x8: 1622: return gen7_fault_block_uche(device, str, sizeof(str), true); MATCH LINES: 2506, 2538, 2572 2494: status, rptr, wptr, ib1base, ib1sz, ib2base, ib2sz); 2495: done: 2496: trace_adreno_gpu_fault(ctxt_id, ts, status, 2497: rptr, wptr, ib1base, ib1sz, ib2base, ib2sz, rb_id); 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: 7 --- MATCH LINES: 190, 192, 194, 197, 199, 202, 208 178: u32 data; 179: u32 cntl; 180: u32 rptr; 181: u32 wptr; 182: u32 _pad28; 183: u64 rptr_addr; 184: u64 rbase; 185: u64 counter; 186: u64 bv_rptr_addr; 187: }; 188: 189: /** 190: * struct gen7_cp_smmu_info - CP preemption SMMU info. 191: * @magic: (00) The value at this offset must be equal to 192: * GEN7_CP_SMMU_INFO_MAGIC_REF 193: * @_pad4: (04) Reserved/padding 194: * @ttbr0: (08) Base address of the page table for the * incoming context 195: * @asid: (16) Address Space IDentifier (ASID) of the incoming context 196: * @context_idr: (20) Context Identification Register value 197: * @context_bank: (24) Which Context Bank in SMMU to update 198: */ 199: struct gen7_cp_smmu_info { 200: u32 magic; 201: u32 _pad4; 202: u64 ttbr0; 203: u32 asid; 204: u32 context_idr; 205: u32 context_bank; 206: }; 207: 208: #define GEN7_CP_SMMU_INFO_MAGIC_REF 0x241350d5UL 209: 210: #define GEN7_CP_CTXRECORD_MAGIC_REF 0xae399d6eUL 211: /* Size of each CP preemption record */ 212: #define GEN7_CP_CTXRECORD_SIZE_IN_BYTES (4192 * 1024) 213: /* Size of the performance counter save/restore block (in bytes) */ 214: #define GEN7_CP_PERFCOUNTER_SAVE_RESTORE_SIZE (4 * 1024) 215: 216: #define GEN7_CP_RB_CNTL_DEFAULT \ 217: (FIELD_PREP(GENMASK(7, 0), ilog2(KGSL_RB_DWORDS >> 1)) | \ 218: FIELD_PREP(GENMASK(12, 8), ilog2(4))) 219: 220: /* Size of the CP_INIT pm4 stream in dwords */ 221: #define GEN7_CP_INIT_DWORDS 10 222: 223: #define GEN7_INT_MASK \ 224: ((1 << GEN7_INT_AHBERROR) | \ 225: (1 << GEN7_INT_ATBASYNCFIFOOVERFLOW) | \ 226: (1 << GEN7_INT_GPCERROR) | \ 227: (1 << GEN7_INT_SWINTERRUPT) | \ 228: (1 << GEN7_INT_HWERROR) | \ 229: (1 << GEN7_INT_PM4CPINTERRUPT) | \ 230: (1 << GEN7_INT_RB_DONE_TS) | \ 231: (1 << GEN7_INT_CACHE_CLEAN_TS) | \ 232: (1 << GEN7_INT_ATBBUSOVERFLOW) | \ --- FILE: \adreno_gen7_coresight.c | HITS: 1 --- MATCH LINES: 67 55: { GEN7_DBGC_EVT_INTF_SEL_1 }, 56: { GEN7_DBGC_PERF_ATB_CFG }, 57: { GEN7_DBGC_PERF_ATB_COUNTER_SEL_0 }, 58: { GEN7_DBGC_PERF_ATB_COUNTER_SEL_1 }, 59: { GEN7_DBGC_PERF_ATB_COUNTER_SEL_2 }, 60: { GEN7_DBGC_PERF_ATB_COUNTER_SEL_3 }, 61: { GEN7_DBGC_PERF_ATB_TRIG_INTF_SEL_0 }, 62: { GEN7_DBGC_PERF_ATB_TRIG_INTF_SEL_1 }, 63: { GEN7_DBGC_PERF_ATB_DRAIN_CMD }, 64: { GEN7_DBGC_ECO_CNTL }, 65: { GEN7_DBGC_AHB_DBG_CNTL }, 66: { GEN7_DBGC_CFG_DBGBUS_MISC_MODE }, 67: { GEN7_DBGC_SMMU_FAULT_BLOCK_HALT_CFG }, 68: }; 69: 70: static struct adreno_coresight_register gen7_coresight_regs_cx[] = { 71: { GEN7_CX_DBGC_CFG_DBGBUS_SEL_A }, 72: { GEN7_CX_DBGC_CFG_DBGBUS_SEL_B }, 73: { GEN7_CX_DBGC_CFG_DBGBUS_SEL_C }, 74: { GEN7_CX_DBGC_CFG_DBGBUS_SEL_D }, 75: { GEN7_CX_DBGC_CFG_DBGBUS_CNTLT }, 76: { GEN7_CX_DBGC_CFG_DBGBUS_CNTLM }, 77: { GEN7_CX_DBGC_CFG_DBGBUS_OPL }, 78: { GEN7_CX_DBGC_CFG_DBGBUS_OPE }, 79: { GEN7_CX_DBGC_CFG_DBGBUS_IVTL_0 }, 80: { GEN7_CX_DBGC_CFG_DBGBUS_IVTL_1 }, 81: { GEN7_CX_DBGC_CFG_DBGBUS_IVTL_2 }, 82: { GEN7_CX_DBGC_CFG_DBGBUS_IVTL_3 }, 83: { GEN7_CX_DBGC_CFG_DBGBUS_MASKL_0 }, 84: { GEN7_CX_DBGC_CFG_DBGBUS_MASKL_1 }, 85: { GEN7_CX_DBGC_CFG_DBGBUS_MASKL_2 }, 86: { GEN7_CX_DBGC_CFG_DBGBUS_MASKL_3 }, 87: { GEN7_CX_DBGC_CFG_DBGBUS_BYTEL_0 }, 88: { GEN7_CX_DBGC_CFG_DBGBUS_BYTEL_1 }, 89: { GEN7_CX_DBGC_CFG_DBGBUS_IVTE_0 }, 90: { GEN7_CX_DBGC_CFG_DBGBUS_IVTE_1 }, 91: { GEN7_CX_DBGC_CFG_DBGBUS_IVTE_2 }, --- FILE: \adreno_gen7_gmu.c | HITS: 6 --- MATCH LINES: 1125 1113: unsigned long t; 1114: 1115: kgsl_regwrite(device, reg, mask); 1116: 1117: t = jiffies + msecs_to_jiffies(100); 1118: do { 1119: kgsl_regread(device, ack_reg, &ack); 1120: if ((ack & mask) == mask) 1121: return; 1122: 1123: /* 1124: * If we are attempting recovery in case of stall-on-fault 1125: * then the halt sequence will not complete as long as SMMU 1126: * is stalled. 1127: */ 1128: kgsl_mmu_pagefault_resume(&device->mmu, false); 1129: 1130: usleep_range(10, 100); 1131: } while (!time_after(jiffies, t)); 1132: 1133: /* Check one last time */ 1134: kgsl_mmu_pagefault_resume(&device->mmu, false); 1135: 1136: kgsl_regread(device, ack_reg, &ack); 1137: if ((ack & mask) == mask) 1138: return; 1139: 1140: dev_err(device->dev, "%s GBIF halt timed out\n", client); 1141: } 1142: 1143: static void gen7_gmu_pwrctrl_suspend(struct adreno_device *adreno_dev) 1144: { 1145: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1146: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1147: 1148: /* Disconnect GPU from BUS is not needed if CX GDSC goes off later */ 1149: MATCH LINES: 1380, 1383, 1385 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; 1391: 1392: /* 1393: * We should not send NMI if there was a CM3 fault reported because we 1394: * don't want to overwrite the critical CM3 state captured by gmu before 1395: * it sent the CM3 fault interrupt. Also don't send NMI if GMU reset is 1396: * already active. We could have hit a GMU assert and NMI might have 1397: * already been triggered. 1398: */ 1399: 1400: /* make sure we're reading the latest cm3_fault */ 1401: smp_rmb(); 1402: 1403: if (atomic_read(&gmu->cm3_fault)) 1404: return; 1405: 1406: gmu_core_regread(device, GEN7_GMU_CM3_FW_INIT_RESULT, &result); 1407: 1408: if (result & 0xE00) 1409: return; MATCH LINES: 2114, 2115 2102: device->gmu_core.rdpm_cx_offset = GEN7_RDPM_CX_OFFSET; 2103: device->gmu_core.rdpm_mx_offset = GEN7_RDPM_MX_OFFSET; 2104: 2105: /* Set up GMU gdscs */ 2106: ret = kgsl_pwrctrl_probe_gdscs(device, pdev); 2107: if (ret) 2108: return ret; 2109: 2110: ret = gmu_core_clk_probe(device); 2111: if (ret) 2112: return ret; 2113: 2114: /* Set up GMU IOMMU and shared memory with GMU */ 2115: ret = gmu_core_iommu_init(device); 2116: if (ret) 2117: goto error; 2118: 2119: device->gmu_core.vma = gen7_gmu_vma; 2120: device->gmu_core.num_vmas = ARRAY_SIZE(gen7_gmu_vma); 2121: 2122: for (i = 0; i < device->gmu_core.num_vmas; i++) { 2123: struct gmu_vma_entry *vma = &gen7_gmu_vma[i]; 2124: 2125: vma->vma_root = RB_ROOT; 2126: spin_lock_init(&vma->lock); 2127: } 2128: 2129: /* Map and reserve GMU CSRs registers */ 2130: ret = gen7_gmu_reg_probe(adreno_dev); 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) --- FILE: \adreno_gen7_gmu_snapshot.c | HITS: 3 --- MATCH LINES: 218, 221, 223 206: 207: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, snapshot, 208: adreno_snapshot_registers_v2, (void *) gen7_snapshot_block_list->gmu_gx_regs); 209: 210: regs_ptr = (const u32 *)gen7_snapshot_block_list->gmu_gx_blk_dec0_dec1_regs; 211: if (regs_ptr && kgsl_regmap_valid_offset(&device->regmap, regs_ptr[0])) { 212: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, snapshot, 213: adreno_snapshot_registers_v2, 214: (void *) gen7_snapshot_block_list->gmu_gx_blk_dec0_dec1_regs); 215: } 216: 217: /* 218: * A stalled SMMU can lead to NoC timeouts when host accesses DTCM. 219: * DTCM can be read through side-band DBGC interface on gen7_2_x family. 220: */ 221: if (adreno_smmu_is_stalled(adreno_dev) && !adreno_is_gen7_2_x_family(adreno_dev)) { 222: dev_err(GMU_PDEV_DEV(device), 223: "Not dumping dtcm because SMMU is stalled\n"); 224: return; 225: } 226: 227: dtcm: 228: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_GMU_MEMORY, 229: snapshot, gen7_gmu_snapshot_dtcm, gmu); 230: } 231: 232: void gen7_gmu_snapshot(struct adreno_device *adreno_dev, 233: struct kgsl_snapshot *snapshot) 234: { 235: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 236: 237: /* 238: * Dump external register first to have GPUCC and other external 239: * register in snapshot to analyze the system state even in partial 240: * snapshot dump 241: */ 242: gen7_snapshot_external_core_regs(device, snapshot); 243: 244: gen7_gmu_device_snapshot(device, snapshot); 245: 246: gen7_snapshot(adreno_dev, snapshot); 247: --- FILE: \adreno_gen7_hwsched.c | HITS: 1 --- MATCH LINES: 113 101: if (entry->desc.mem_kind == HFI_MEMKIND_SCRATCH) 102: kgsl_snapshot_add_section(device, 103: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 104: snapshot, adreno_snapshot_global, 105: entry->md); 106: 107: if (entry->desc.mem_kind == HFI_MEMKIND_PROFILE) 108: kgsl_snapshot_add_section(device, 109: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 110: snapshot, adreno_snapshot_global, 111: entry->md); 112: 113: if (entry->desc.mem_kind == HFI_MEMKIND_CSW_SMMU_INFO) 114: kgsl_snapshot_add_section(device, 115: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 116: snapshot, adreno_snapshot_global, 117: entry->md); 118: 119: if (entry->desc.mem_kind == HFI_MEMKIND_CSW_PRIV_NON_SECURE) 120: adreno_hwsched_snapshot_preemption_records(device, snapshot, 121: entry->md); 122: 123: if (entry->desc.mem_kind == HFI_MEMKIND_PREEMPT_SCRATCH) 124: kgsl_snapshot_add_section(device, 125: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 126: snapshot, adreno_snapshot_global, 127: entry->md); 128: 129: if (entry->desc.mem_kind == HFI_MEMKIND_AQE_BUFFER) 130: kgsl_snapshot_add_section(device, 131: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 132: snapshot, adreno_hwsched_snapshot_aqe_buffer, 133: entry->md); 134: 135: if (entry->desc.mem_kind == HFI_MEMKIND_HW_FENCE) { 136: struct gmu_mem_type_desc desc; 137: --- FILE: \adreno_gen7_hwsched_hfi.c | HITS: 11 --- MATCH LINES: 7 1: // SPDX-License-Identifier: GPL-2.0-only 2: /* 3: * Copyright (c) 2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #include 8: 9: #include "adreno.h" 10: #include "adreno_gen7.h" 11: #include "adreno_gen7_hwsched.h" 12: #include "adreno_hfi.h" 13: #include "adreno_pm4types.h" 14: #include "adreno_trace.h" 15: #include "kgsl_device.h" 16: #include "kgsl_eventlog.h" 17: #include "kgsl_gmu_core.h" 18: #include "kgsl_pwrctrl.h" 19: #include "kgsl_timeline.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, \ MATCH LINES: 2545, 2557, 2574, 2575, 2591, 2592, 2596, 2597, 2599 2533: { 2534: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2535: int ret = 0; 2536: 2537: if (!adreno_hwsched_context_queue_enabled(adreno_dev)) 2538: return 0; 2539: 2540: if (test_bit(ADRENO_HWSCHED_HW_FENCE, &adreno_dev->hwsched.flags) && 2541: !drawctxt->gmu_hw_fence_queue.gmuaddr) { 2542: ret = gmu_core_alloc_kernel_block( 2543: device, &drawctxt->gmu_hw_fence_queue, 2544: HW_FENCE_QUEUE_SIZE, GMU_NONCACHED_KERNEL, 2545: IOMMU_READ | IOMMU_WRITE | IOMMU_PRIV); 2546: if (ret) { 2547: memset(&drawctxt->gmu_hw_fence_queue, 0x0, 2548: sizeof(drawctxt->gmu_hw_fence_queue)); 2549: return ret; 2550: } 2551: } 2552: 2553: if (!drawctxt->gmu_context_queue.gmuaddr) { 2554: ret = gmu_core_alloc_kernel_block( 2555: device, &drawctxt->gmu_context_queue, 2556: SZ_4K, GMU_NONCACHED_KERNEL, 2557: IOMMU_READ | IOMMU_WRITE | IOMMU_PRIV); 2558: if (ret) { 2559: memset(&drawctxt->gmu_context_queue, 0x0, 2560: sizeof(drawctxt->gmu_context_queue)); 2561: return ret; 2562: } 2563: init_gmu_context_queue(drawctxt); 2564: } 2565: 2566: return 0; 2567: } 2568: 2569: static int send_context_register(struct adreno_device *adreno_dev, 2570: struct kgsl_context *context) 2571: { 2572: struct adreno_context *drawctxt = ADRENO_CONTEXT(context); 2573: struct hfi_register_ctxt_cmd cmd; 2574: struct kgsl_pagetable *pt = context->proc_priv->pagetable; 2575: int ret, asid = kgsl_mmu_pagetable_get_asid(pt, context); 2576: 2577: if (asid < 0) 2578: return asid; 2579: 2580: ret = CMD_MSG_HDR(cmd, H2F_MSG_REGISTER_CONTEXT); 2581: if (ret) 2582: return ret; 2583: 2584: ret = allocate_context_queues(adreno_dev, drawctxt); 2585: if (ret) 2586: return ret; 2587: 2588: cmd.ctxt_id = context->id; 2589: cmd.flags = HFI_CTXT_FLAG_NOTIFY | context->flags; 2590: /* 2591: * HLOS SMMU driver programs context bank to look up ASID from TTBR0 during a page 2592: * table walk. So the TLB entries are tagged with the ASID from TTBR0. TLBIASID 2593: * invalidates TLB entries whose ASID matches the value that was written to the 2594: * CBn_TLBIASID register. Set ASID along with PT address. 2595: */ 2596: cmd.pt_addr = kgsl_mmu_pagetable_get_ttbr0(pt) | 2597: FIELD_PREP(GENMASK_ULL(63, KGSL_IOMMU_ASID_START_BIT), asid); 2598: cmd.ctxt_idr = context->id; 2599: cmd.ctxt_bank = kgsl_mmu_pagetable_get_context_bank(pt, context); 2600: 2601: return gen7_hfi_send_cmd_async(adreno_dev, &cmd, sizeof(cmd)); 2602: } 2603: 2604: static int send_context_pointers(struct adreno_device *adreno_dev, 2605: struct kgsl_context *context) 2606: { 2607: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2608: struct hfi_context_pointers_cmd cmd = {0}; 2609: struct adreno_context *drawctxt = ADRENO_CONTEXT(context); 2610: int ret; 2611: 2612: ret = CMD_MSG_HDR(cmd, H2F_MSG_CONTEXT_POINTERS); 2613: if (ret) 2614: return ret; 2615: 2616: cmd.ctxt_id = context->id; 2617: cmd.sop_addr = MEMSTORE_ID_GPU_ADDR(device, context->id, soptimestamp); 2618: cmd.eop_addr = MEMSTORE_ID_GPU_ADDR(device, context->id, eoptimestamp); 2619: if (context->user_ctxt_record) 2620: cmd.user_ctxt_record_addr = 2621: context->user_ctxt_record->memdesc.gpuaddr; 2622: 2623: if (adreno_hwsched_context_queue_enabled(adreno_dev)) MATCH LINES: 3805 3793: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 3794: struct hfi_register_ctxt_cmd rcmd = {0}; 3795: struct hfi_context_pointers_cmd pcmd = {0}; 3796: int ret; 3797: 3798: if (hwsched->global_ctxt_gmu_registered) 3799: return 0; 3800: 3801: if (adreno_hwsched_context_queue_enabled(adreno_dev) && !hwsched->global_ctxtq.hostptr) { 3802: struct gmu_context_queue_header *hdr; 3803: 3804: ret = gmu_core_alloc_kernel_block(device, &hwsched->global_ctxtq, 3805: SZ_4K, GMU_NONCACHED_KERNEL, IOMMU_READ | IOMMU_WRITE | IOMMU_PRIV); 3806: if (ret) { 3807: memset(&hwsched->global_ctxtq, 0x0, sizeof(hwsched->global_ctxtq)); 3808: return ret; 3809: } 3810: 3811: hdr = hwsched->global_ctxtq.hostptr; 3812: hdr->start_addr = hwsched->global_ctxtq.gmuaddr + sizeof(*hdr); 3813: hdr->queue_size = (hwsched->global_ctxtq.size - sizeof(*hdr)) >> 2; 3814: } 3815: 3816: ret = CMD_MSG_HDR(rcmd, H2F_MSG_REGISTER_CONTEXT); 3817: if (ret) 3818: return ret; 3819: 3820: rcmd.ctxt_id = KGSL_GLOBAL_CTXT_ID; 3821: rcmd.flags = (KGSL_CONTEXT_PRIORITY_HIGH << KGSL_CONTEXT_PRIORITY_SHIFT); 3822: 3823: ret = gen7_hfi_send_cmd_async(adreno_dev, &rcmd, sizeof(rcmd)); 3824: if (ret) 3825: return ret; 3826: 3827: ret = CMD_MSG_HDR(pcmd, H2F_MSG_CONTEXT_POINTERS); 3828: if (ret) 3829: return ret; --- FILE: \adreno_gen7_preempt.c | HITS: 39 --- MATCH LINES: 16, 17 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #include "adreno.h" 8: #include "adreno_gen7.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 gen7_cp_preemption_record, _field) 15: 16: #define PREEMPT_SMMU_RECORD(_field) \ 17: offsetof(struct gen7_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 = gen7_fenced_write(adreno_dev, 37: GEN7_CP_RB_WPTR, rb->wptr, 38: FENCE_STATUS_WRITEDROPPED0_MASK); 39: 40: reset_timer = true; 41: rb->skip_inline_wptr = false; MATCH LINES: 209, 211, 212 197: 198: if (!empty) 199: return rb; 200: } 201: 202: return NULL; 203: } 204: 205: void gen7_preemption_trigger(struct adreno_device *adreno_dev, bool atomic) 206: { 207: const struct adreno_gen7_core *gen7_core = to_gen7_core(adreno_dev); 208: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 209: struct kgsl_iommu *iommu = KGSL_IOMMU(device); 210: struct adreno_ringbuffer *next; 211: u64 ttbr0, gpuaddr; 212: u32 contextidr, cntl; 213: unsigned long flags; 214: struct adreno_preemption *preempt = &adreno_dev->preempt; 215: 216: /* Put ourselves into a possible trigger state */ 217: if (!adreno_move_preempt_state(adreno_dev, 218: ADRENO_PREEMPT_NONE, ADRENO_PREEMPT_START)) 219: return; 220: 221: /* Get the next ringbuffer to preempt in */ 222: next = gen7_next_ringbuffer(adreno_dev); 223: 224: /* 225: * Nothing to do if every ringbuffer is empty or if the current 226: * ringbuffer is the only active one 227: */ 228: if (next == NULL || next == adreno_dev->cur_rb) { 229: /* 230: * Update any critical things that might have been skipped while 231: * we were looking for a new ringbuffer 232: */ 233: 234: if (next != NULL) { 235: _update_wptr(adreno_dev, false, atomic); 236: MATCH LINES: 255, 256, 257, 258, 259, 266, 268, 269, 270, 271 243: } 244: 245: /* Turn off the dispatcher timer */ 246: kgsl_delete_timer(&adreno_dev->dispatcher.timer); 247: 248: /* 249: * This is the most critical section - we need to take care not to race 250: * until we have programmed the CP for the switch 251: */ 252: 253: spin_lock_irqsave(&next->preempt_lock, flags); 254: 255: /* Get the pagetable from the pagetable info. */ 256: kgsl_sharedmem_readq(device->scratch, &ttbr0, 257: SCRATCH_RB_OFFSET(next->id, ttbr0)); 258: kgsl_sharedmem_readl(device->scratch, &contextidr, 259: SCRATCH_RB_OFFSET(next->id, contextidr)); 260: 261: kgsl_sharedmem_writel(next->preemption_desc, 262: PREEMPT_RECORD(wptr), next->wptr); 263: 264: spin_unlock_irqrestore(&next->preempt_lock, flags); 265: 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: */ MATCH LINES: 541, 542 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); 564: 565: done: 566: if (drawctxt) { MATCH LINES: 606, 617, 618, 619, 620, 621, 624, 625, 626, 627, 629, 630, 632, 633, 642, 643 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, 619: PREEMPT_SMMU_RECORD(magic), GEN7_CP_SMMU_INFO_MAGIC_REF); 620: kgsl_sharedmem_writeq(iommu->smmu_info, 621: PREEMPT_SMMU_RECORD(ttbr0), MMU_DEFAULT_TTBR0(device)); 622: 623: /* The CP doesn't use the asid record, so poison it */ 624: kgsl_sharedmem_writel(iommu->smmu_info, 625: PREEMPT_SMMU_RECORD(asid), 0xdecafbad); 626: kgsl_sharedmem_writel(iommu->smmu_info, 627: PREEMPT_SMMU_RECORD(context_idr), 0); 628: 629: kgsl_regwrite(device, GEN7_CP_CONTEXT_SWITCH_SMMU_INFO_LO, 630: lower_32_bits(iommu->smmu_info->gpuaddr)); 631: 632: kgsl_regwrite(device, GEN7_CP_CONTEXT_SWITCH_SMMU_INFO_HI, 633: upper_32_bits(iommu->smmu_info->gpuaddr)); 634: } 635: 636: FOR_EACH_RINGBUFFER(adreno_dev, rb, i) { 637: kgsl_sharedmem_writel(rb->preemption_desc, 638: PREEMPT_RECORD(rptr), 0); 639: kgsl_sharedmem_writel(rb->preemption_desc, 640: PREEMPT_RECORD(wptr), 0); 641: 642: adreno_ringbuffer_set_pagetable(device, rb, 643: device->mmu.defaultpagetable); 644: 645: clear_bit(ADRENO_RB_SET_PSEUDO_DONE, &rb->flags); 646: } 647: } 648: 649: static void reset_rb_preempt_record(struct adreno_device *adreno_dev, 650: struct adreno_ringbuffer *rb) 651: { 652: memset(rb->preemption_desc->hostptr, 0x0, rb->preemption_desc->size); 653: 654: kgsl_sharedmem_writel(rb->preemption_desc, 655: PREEMPT_RECORD(magic), GEN7_CP_CTXRECORD_MAGIC_REF); 656: kgsl_sharedmem_writel(rb->preemption_desc, 657: PREEMPT_RECORD(cntl), GEN7_CP_RB_CNTL_DEFAULT); 658: kgsl_sharedmem_writeq(rb->preemption_desc, 659: PREEMPT_RECORD(rptr_addr), SCRATCH_RB_GPU_ADDR( 660: KGSL_DEVICE(adreno_dev), rb->id, rptr)); 661: kgsl_sharedmem_writeq(rb->preemption_desc, 662: PREEMPT_RECORD(rbase), rb->buffer_desc->gpuaddr); 663: kgsl_sharedmem_writeq(rb->preemption_desc, 664: PREEMPT_RECORD(bv_rptr_addr), SCRATCH_RB_GPU_ADDR( 665: KGSL_DEVICE(adreno_dev), rb->id, bv_rptr)); 666: } 667: MATCH LINES: 723, 729, 730, 749, 751, 753 711: if (ret) 712: return ret; 713: 714: reset_rb_preempt_record(adreno_dev, rb); 715: 716: return 0; 717: } 718: 719: int gen7_preemption_init(struct adreno_device *adreno_dev) 720: { 721: u32 flags = ADRENO_FEATURE(adreno_dev, ADRENO_APRIV) ? KGSL_MEMDESC_PRIVILEGED : 0; 722: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 723: struct kgsl_iommu *iommu = KGSL_IOMMU(device); 724: struct adreno_preemption *preempt = &adreno_dev->preempt; 725: struct adreno_ringbuffer *rb; 726: int ret; 727: unsigned int i; 728: 729: /* We are dependent on IOMMU to make preemption go on the CP side */ 730: if (kgsl_mmu_get_mmutype(device) != KGSL_MMU_TYPE_IOMMU) { 731: ret = -ENODEV; 732: goto done; 733: } 734: 735: INIT_WORK(&preempt->work, _gen7_preemption_worker); 736: 737: /* Allocate mem for storing preemption switch record */ 738: FOR_EACH_RINGBUFFER(adreno_dev, rb, i) { 739: ret = gen7_preemption_ringbuffer_init(adreno_dev, rb); 740: if (ret) 741: goto done; 742: } 743: 744: ret = adreno_allocate_global(device, &preempt->scratch, PAGE_SIZE, 745: 0, 0, flags, "preempt_scratch"); 746: if (ret) 747: goto done; 748: 749: /* Allocate mem for storing preemption smmu record */ 750: if (kgsl_mmu_is_perprocess(&device->mmu)) { 751: ret = adreno_allocate_global(device, &iommu->smmu_info, PAGE_SIZE, 0, 752: KGSL_MEMFLAGS_GPUREADONLY, KGSL_MEMDESC_PRIVILEGED, 753: "smmu_info"); 754: if (ret) 755: goto done; 756: } 757: 758: return 0; 759: done: 760: clear_bit(ADRENO_DEVICE_PREEMPTION, &adreno_dev->priv); 761: return ret; 762: } --- FILE: \adreno_gen7_ringbuffer.c | HITS: 26 --- MATCH LINES: 22, 24, 27, 31, 34, 35, 36, 37, 42, 44, 45, 46, 50, 52, 64, 65, 78, 79, 86, 87, 104, 105, 118, 120, 123, 124 10: #include "adreno_ringbuffer.h" 11: #include "adreno_trace.h" 12: #include "kgsl_trace.h" 13: 14: static bool is_concurrent_binning(struct adreno_context *drawctxt) 15: { 16: if (!drawctxt) 17: return false; 18: 19: return !(drawctxt->base.flags & KGSL_CONTEXT_SECURE); 20: } 21: 22: static int gen7_rb_pagetable_switch(struct adreno_device *adreno_dev, 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); --- FILE: \adreno_gen7_snapshot.c | HITS: 1 --- MATCH LINES: 362 350: static void CD_FINISH(u64 *ptr, u32 offset) 351: { 352: gen7_cd_reg_end = gen7_crashdump_registers->hostptr + offset; 353: *gen7_cd_reg_end = CD_REG_END; 354: ptr[0] = gen7_crashdump_registers->gpuaddr + offset; 355: ptr[1] = FIELD_PREP(GENMASK(63, 44), GEN7_CP_CRASH_DUMP_STATUS) | BIT(0); 356: ptr[2] = 0; 357: ptr[3] = 0; 358: } 359: 360: static bool CD_SCRIPT_CHECK(struct kgsl_device *device) 361: { 362: return (adreno_smmu_is_stalled(ADRENO_DEVICE(device)) || (!device->snapshot_crashdumper) || 363: IS_ERR_OR_NULL(gen7_capturescript) || 364: IS_ERR_OR_NULL(gen7_crashdump_registers) || 365: gen7_crashdump_timedout); 366: } 367: 368: static bool _gen7_do_crashdump(struct kgsl_device *device) 369: { 370: unsigned int reg = 0; 371: ktime_t timeout; 372: 373: if (CD_SCRIPT_CHECK(device)) 374: return false; 375: 376: kgsl_regwrite(device, GEN7_CP_CRASH_SCRIPT_BASE_LO, 377: lower_32_bits(gen7_capturescript->gpuaddr)); 378: kgsl_regwrite(device, GEN7_CP_CRASH_SCRIPT_BASE_HI, 379: upper_32_bits(gen7_capturescript->gpuaddr)); 380: kgsl_regwrite(device, GEN7_CP_CRASH_DUMP_CNTL, 1); 381: 382: timeout = ktime_add_ms(ktime_get(), CP_CRASH_DUMPER_TIMEOUT); 383: 384: if (!device->snapshot_atomic) 385: might_sleep(); 386: for (;;) { --- FILE: \adreno_gen8.c | HITS: 13 --- MATCH LINES: 95, 117 83: /* CP SW Fault status bits */ 84: #define CP_SW_CSFRBWRAP 0 85: #define CP_SW_CSFIB1WRAP 1 86: #define CP_SW_CSFIB2WRAP 2 87: #define CP_SW_CSFIB3WRAP 3 88: #define CP_SW_SDSWRAP 4 89: #define CP_SW_MRBWRAP 5 90: #define CP_SW_VSDWRAP 6 91: #define CP_SW_OPCODEERROR 8 92: #define CP_SW_VSDPARITYERROR 9 93: #define CP_SW_REGISTERPROTECTIONERROR 10 94: #define CP_SW_ILLEGALINSTRUCTION 11 95: #define CP_SW_SMMUFAULT 12 96: #define CP_SW_VBIFRESPCLIENT 13 97: #define CP_SW_VBIFRESPTYPE 19 98: #define CP_SW_VBIFRESPREAD 21 99: #define CP_SW_VBIFRESP 22 100: #define CP_SW_RTWROVF 23 101: #define CP_SW_LRZRTWROVF 24 102: #define CP_SW_LRZRTREFCNTOVF 25 103: #define CP_SW_LRZRTCLRRESMISS 26 104: 105: #define CP_SW_FAULT_STATUS_MASK_PIPE \ 106: (BIT(CP_SW_CSFRBWRAP) | \ 107: BIT(CP_SW_CSFIB1WRAP) | \ 108: BIT(CP_SW_CSFIB2WRAP) | \ 109: BIT(CP_SW_CSFIB3WRAP) | \ 110: BIT(CP_SW_SDSWRAP) | \ 111: BIT(CP_SW_MRBWRAP) | \ 112: BIT(CP_SW_VSDWRAP) | \ 113: BIT(CP_SW_OPCODEERROR) | \ 114: BIT(CP_SW_VSDPARITYERROR) | \ 115: BIT(CP_SW_REGISTERPROTECTIONERROR) | \ 116: BIT(CP_SW_ILLEGALINSTRUCTION) | \ 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, MATCH LINES: 893, 894 881: { GEN8_VFD_CB_BV_THRESHOLD, BIT(PIPE_BV) | BIT(PIPE_BR) }, 882: { GEN8_VFD_CB_BR_THRESHOLD, BIT(PIPE_BV) | BIT(PIPE_BR) }, 883: { GEN8_VFD_CB_BUSY_REQ_CNT, BIT(PIPE_BV) | BIT(PIPE_BR) }, 884: { GEN8_VFD_CB_LP_REQ_CNT, BIT(PIPE_BV) | BIT(PIPE_BR) }, 885: { GEN8_VPC_FLATSHADE_MODE_CNTL, BIT(PIPE_BV) | BIT(PIPE_BR) }, 886: }; 887: 888: struct gen8_nonctxt_overrides gen8_nc_overrides[] = { 889: { GEN8_CP_RESERVED_REG_0, BIT(PIPE_NONE), 0, 0, 1, }, 890: { GEN8_CP_CHICKEN_DBG_PIPE, BIT(PIPE_BV) | BIT(PIPE_BR) | BIT(PIPE_LPAC) | BIT(PIPE_AQE0) | 891: BIT(PIPE_AQE1) | BIT(PIPE_DDE_BR) | BIT(PIPE_DDE_BV), 0, 0, 0, }, 892: { GEN8_CP_MULTIDRAW_CNTL, BIT(PIPE_NONE), 0, 0, 0, }, 893: { GEN8_GPU_CX_MISC_SMMU_INTR_MASK0, BIT(PIPE_NONE), 0, 0, 0, }, 894: { GEN8_GPU_CX_MISC_SMMU_INTR_MASK1, BIT(PIPE_NONE), 0, 0, 0, }, 895: { GEN8_UCHE_MODE_CNTL, BIT(PIPE_NONE), 0, 0, 0, }, 896: { GEN8_UCHE_CACHE_WAYS, BIT(PIPE_NONE), 0, 0, 0, }, 897: { GEN8_UCHE_CLIENT_PF, BIT(PIPE_NONE), 0, 0, 0, }, 898: { GEN8_UCHE_DBG_ECO_CNTL_0, BIT(PIPE_NONE), 0, 0, 2, }, 899: { GEN8_UCHE_HW_DBG_CNTL, BIT(PIPE_NONE), 0, 0, 2, }, 900: { GEN8_UCHE_CCHE_HW_DBG_CNTL, BIT(PIPE_NONE), 0, 0, 2, }, 901: { GEN8_GRAS_NC_MODE_CNTL, BIT(PIPE_BV) | BIT(PIPE_BR), 0, 0, 0, }, 902: { GEN8_GRAS_DBG_ECO_CNTL, BIT(PIPE_BV) | BIT(PIPE_BR), 0, 0, 0, }, 903: { GEN8_RB_RBP_CNTL, BIT(PIPE_BV) | BIT(PIPE_BR), 0, 0, 0, }, 904: { GEN8_RB_DBG_ECO_CNTL, BIT(PIPE_BR), 0, 0, 3, }, 905: { GEN8_RB_CCU_DBG_ECO_CNTL, BIT(PIPE_BR), 0, 0, 3, }, 906: { GEN8_RB_CCU_CNTL, BIT(PIPE_BR), 0, 0, 0, }, 907: { GEN8_RB_CCU_NC_MODE_CNTL, BIT(PIPE_BR), 0, 0, 0, }, 908: { GEN8_RB_SLICE_UFC_PREFETCH_CNTL, BIT(PIPE_BR), 0, 0, 3, }, 909: { GEN8_RB_SLICE_UFC_DBG_CNTL, BIT(PIPE_BR), 0, 0, 3, }, 910: { GEN8_RB_CMP_NC_MODE_CNTL, BIT(PIPE_BR), 0, 0, 0, }, 911: { GEN8_RB_RESOLVE_PREFETCH_CNTL, BIT(PIPE_BR), 0, 0, 0, }, 912: { GEN8_RB_CMP_DBG_ECO_CNTL, BIT(PIPE_BR), 0, 0, 0, }, 913: { GEN8_RB_UFC_DBG_CNTL, BIT(PIPE_BR), 0, 0, 3, }, 914: { GEN8_PC_CHICKEN_BITS_1, BIT(PIPE_BV) | BIT(PIPE_BR), 0, 0, 0, }, 915: { GEN8_PC_CHICKEN_BITS_2, BIT(PIPE_BV) | BIT(PIPE_BR), 0, 0, 0, }, 916: { GEN8_PC_CHICKEN_BITS_3, BIT(PIPE_BV) | BIT(PIPE_BR), 0, 0, 0, }, 917: { GEN8_PC_CHICKEN_BITS_4, BIT(PIPE_BV) | BIT(PIPE_BR), 0, 0, 0, }, 918: { GEN8_PC_CHICKEN_BITS_5, BIT(PIPE_BV) | BIT(PIPE_BR), 0, 0, 0, }, MATCH LINES: 1966, 1968, 1971 1954: { 1955: if (IS_ERR_OR_NULL(adreno_dev->gpuhtw_llc_slice) || 1956: !adreno_dev->gpuhtw_llc_slice_enable) 1957: return; 1958: 1959: llcc_slice_activate(adreno_dev->gpuhtw_llc_slice); 1960: } 1961: 1962: static void _set_secvid(struct kgsl_device *device) 1963: { 1964: kgsl_regwrite(device, GEN8_RBBM_SECVID_TSB_CNTL, 0x0); 1965: kgsl_regwrite(device, GEN8_RBBM_SECVID_TSB_TRUSTED_BASE_LO, 1966: lower_32_bits(KGSL_IOMMU_SECURE_BASE32)); 1967: kgsl_regwrite(device, GEN8_RBBM_SECVID_TSB_TRUSTED_BASE_HI, 1968: upper_32_bits(KGSL_IOMMU_SECURE_BASE32)); 1969: kgsl_regwrite(device, GEN8_RBBM_SECVID_TSB_TRUSTED_SIZE, 1970: FIELD_PREP(GENMASK(31, 12), 1971: (KGSL_IOMMU_SECURE_SIZE(&device->mmu) / SZ_4K))); 1972: } 1973: 1974: /* Set UCHE_TRAP_BASE to a page below the top of the memory space */ 1975: #define GEN8_UCHE_TRAP_BASE 0x1FFFFFFFFF000ULL 1976: 1977: static u64 gen8_get_uche_trap_base(void) 1978: { 1979: return GEN8_UCHE_TRAP_BASE; 1980: } 1981: 1982: void gen8_setup_adreno_props(struct adreno_device *adreno_dev) 1983: { 1984: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1985: u32 reg; 1986: 1987: if (!adreno_is_gen8_11_x(adreno_dev)) 1988: return; 1989: 1990: /* Store the multidraw and visibility flush settings */ 1991: kgsl_regread(device, GEN8_CP_MULTIDRAW_CNTL, ®); 1992: adreno_dev->multidraw_mode = FIELD_GET(GENMASK(0, 0), reg); 1993: kgsl_regread(device, GEN8_VSC_VISIBILITY_FLUSH_CNTL, ®); 1994: adreno_dev->viz_flush_draw_count = FIELD_GET(GENMASK(7, 0), reg); 1995: adreno_dev->viz_flush_prim_count = FIELD_GET(GENMASK(23, 8), reg); MATCH LINES: 2051 2039: { 2040: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2041: u32 val; 2042: 2043: if (!adreno_dev->ahb_timeout_val) 2044: return; 2045: 2046: val = (ADRENO_AHB_CNTL_DEFAULT | FIELD_PREP(GENMASK(4, 0), 2047: adreno_dev->ahb_timeout_val)); 2048: kgsl_regwrite(device, GEN8_GPU_CX_MISC_CX_AHB_AON_CNTL, val); 2049: kgsl_regwrite(device, GEN8_GPU_CX_MISC_CX_AHB_GMU_CNTL, val); 2050: kgsl_regwrite(device, GEN8_GPU_CX_MISC_CX_AHB_CP_CNTL, val); 2051: kgsl_regwrite(device, GEN8_GPU_CX_MISC_CX_AHB_VBIF_SMMU_CNTL, val); 2052: kgsl_regwrite(device, GEN8_GPU_CX_MISC_CX_AHB_HOST_CNTL, val); 2053: } 2054: 2055: int gen8_start(struct adreno_device *adreno_dev) 2056: { 2057: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2058: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev); 2059: u32 pipe_id; 2060: struct adreno_ubwc_props *ubwc_props = &adreno_dev->ubwc_props; 2061: u32 mal = adreno_dev->mal; 2062: 2063: struct gen8_device *gen8_dev = container_of(adreno_dev, 2064: struct gen8_device, adreno_dev); 2065: /* 2066: * HBB values 13 to 16 can represented LSB of HBB from 0 to 3. 2067: * Any HBB value beyond 16 needs programming MSB of HBB. 2068: * By default highest bank bit is 14, Hence set default HBB LSB 2069: * to "1" and MSB to "0". 2070: */ 2071: u32 hbb_lo = 1, hbb_hi = 0, hbb = 1; 2072: struct cpu_gpu_lock *pwrup_lock = adreno_dev->pwrup_reglist->hostptr; 2073: u64 uche_trap_base = gen8_get_uche_trap_base(); 2074: int is_current_rt = rt_task(current); 2075: int nice = task_nice(current); MATCH LINES: 2664 2652: const char * const table[] = { 2653: [CP_SW_CSFRBWRAP] = "CSFRBWRAP", 2654: [CP_SW_CSFIB1WRAP] = "CSFIB1WRAP", 2655: [CP_SW_CSFIB2WRAP] = "CSFIB2WRAP", 2656: [CP_SW_CSFIB3WRAP] = "CSFIB3WRAP", 2657: [CP_SW_SDSWRAP] = "SDSWRAP", 2658: [CP_SW_MRBWRAP] = "MRBWRAP", 2659: [CP_SW_VSDWRAP] = "VSDWRAP", 2660: [CP_SW_OPCODEERROR] = "OPCODEERROR", 2661: [CP_SW_VSDPARITYERROR] = "VSDPARITYERROR", 2662: [CP_SW_REGISTERPROTECTIONERROR] = "REGISTERPROTECTIONERROR", 2663: [CP_SW_ILLEGALINSTRUCTION] = "ILLEGALINSTRUCTION", 2664: [CP_SW_SMMUFAULT] = "SMMUFAULT", 2665: [CP_SW_VBIFRESPCLIENT] = "VBIFRESPCLIENT", 2666: [CP_SW_VBIFRESPTYPE] = "VBIFRESPTYPE", 2667: [CP_SW_VBIFRESPREAD] = "VBIFRESPREAD", 2668: [CP_SW_VBIFRESP] = "VBIFRESP", 2669: [CP_SW_RTWROVF] = "RTWROVF", 2670: [CP_SW_LRZRTWROVF] = "LRZRTWROVF", 2671: [CP_SW_LRZRTREFCNTOVF] = "LRZRTREFCNTOVF", 2672: [CP_SW_LRZRTCLRRESMISS] = "LRZRTCLRRESMISS", 2673: }; 2674: 2675: switch (status) { 2676: case BIT(GEN8_CP_GLOBAL_INT_SWFAULTBR): 2677: pipe_id = PIPE_BR; 2678: break; 2679: case BIT(GEN8_CP_GLOBAL_INT_SWFAULTBV): 2680: pipe_id = PIPE_BV; 2681: break; 2682: case BIT(GEN8_CP_GLOBAL_INT_SWFAULTLPAC): 2683: pipe_id = PIPE_LPAC; 2684: break; 2685: case BIT(GEN8_CP_GLOBAL_INT_SWFAULTAQE0): 2686: pipe_id = PIPE_AQE0; 2687: break; 2688: case BIT(GEN8_CP_GLOBAL_INT_SWFAULTAQE1): MATCH LINES: 2813 2801: }; 2802: 2803: #define SCOOBYDOO 0x5c00bd00 2804: 2805: static const char *gen8_fault_block_uche(struct kgsl_device *device, 2806: char *str, int size, bool lpac) 2807: { 2808: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 2809: u32 uche_client_id = adreno_dev->uche_client_pf; 2810: const char *uche_client_str, *fault_block; 2811: 2812: /* 2813: * Smmu driver takes a vote on CX gdsc before calling the kgsl 2814: * pagefault handler. If there is contention for device mutex in this 2815: * path and the dispatcher fault handler is holding this lock, trying 2816: * to turn off CX gdsc will fail during the reset. So to avoid blocking 2817: * here, try to lock device mutex and return if it fails. 2818: */ 2819: if (!kgsl_mutex_trylock(&device->mutex)) 2820: goto regread_fail; 2821: 2822: if (!kgsl_state_is_awake(device)) { 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; MATCH LINES: 2866 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: 2860: fail: 2861: snprintf(str, size, "%s: Unknown (client_id: %u)", 2862: fault_block, uche_client_id); 2863: return str; 2864: } 2865: 2866: static const char *gen8_iommu_fault_block(struct kgsl_device *device, 2867: u32 fsynr1) 2868: { 2869: u32 mid = fsynr1 & 0xff; 2870: static char str[36]; 2871: 2872: switch (mid) { 2873: case 0x0: 2874: return "CP"; 2875: case 0x1: 2876: return "UCHE: Unknown"; 2877: case 0x2: 2878: return "UCHE_LPAC: Unknown"; 2879: case 0x3: 2880: return gen8_fault_block_uche(device, str, sizeof(str), false); 2881: case 0x4: 2882: return "CCU"; 2883: case 0x5: 2884: return "Flag cache"; 2885: case 0x6: 2886: return "PREFETCH"; 2887: case 0x7: 2888: return "GMU"; 2889: case 0x8: 2890: return gen8_fault_block_uche(device, str, sizeof(str), true); MATCH LINES: 3852, 3890 3840: return (adreno_dev->gpucore->gmem_size / GEN8_10_0_NUM_PHYSICAL_SLICES) * 3841: gen8_get_num_slices(adreno_dev); 3842: 3843: return adreno_dev->gpucore->gmem_size; 3844: } 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: 7 --- MATCH LINES: 271, 273, 275, 278, 280, 283, 289 259: u32 data; 260: u32 cntl; 261: u32 rptr; 262: u32 wptr; 263: u32 _pad28; 264: u64 rptr_addr; 265: u64 rbase; 266: u64 counter; 267: u64 bv_rptr_addr; 268: }; 269: 270: /** 271: * struct gen8_cp_smmu_info - CP preemption SMMU info. 272: * @magic: (00) The value at this offset must be equal to 273: * GEN8_CP_SMMU_INFO_MAGIC_REF 274: * @_pad4: (04) Reserved/padding 275: * @ttbr0: (08) Base address of the page table for the * incoming context 276: * @asid: (16) Address Space IDentifier (ASID) of the incoming context 277: * @context_idr: (20) Context Identification Register value 278: * @context_bank: (24) Which Context Bank in SMMU to update 279: */ 280: struct gen8_cp_smmu_info { 281: u32 magic; 282: u32 _pad4; 283: u64 ttbr0; 284: u32 asid; 285: u32 context_idr; 286: u32 context_bank; 287: }; 288: 289: #define GEN8_CP_SMMU_INFO_MAGIC_REF 0x241350d5UL 290: 291: #define GEN8_CP_CTXRECORD_MAGIC_REF 0xae399d6eUL 292: /* Size of each CP preemption record */ 293: #define GEN8_CP_CTXRECORD_SIZE_IN_BYTES (13536 * SZ_1K) 294: /* Size of preemption record to be dumped in snapshot */ 295: #define GEN8_SNAPSHOT_CTXRECORD_SIZE_IN_BYTES (128 * 1024) 296: /* Size of AQE context record */ 297: #define GEN8_CP_AQE_CTXRECORD_SIZE_IN_BYTES (16 * 1024) 298: /* Size of the performance counter save/restore block (in bytes) */ 299: #define GEN8_CP_PERFCOUNTER_SAVE_RESTORE_SIZE (4 * 1024) 300: 301: #define GEN8_CP_RB_CNTL_DEFAULT \ 302: (FIELD_PREP(GENMASK(7, 0), ilog2(KGSL_RB_DWORDS >> 1)) | \ 303: FIELD_PREP(GENMASK(12, 8), ilog2(4))) 304: 305: /* Size of the CP_INIT pm4 stream in dwords */ 306: #define GEN8_CP_INIT_DWORDS 10 307: 308: #define GEN8_INT_MASK \ 309: ((1 << GEN8_INT_AHBERROR) | \ 310: (1 << GEN8_INT_ATBASYNCFIFOOVERFLOW) | \ 311: (1 << GEN8_INT_GPCERROR) | \ 312: (1 << GEN8_INT_SWINTERRUPT) | \ 313: (1 << GEN8_INT_HWERROR) | \ --- FILE: \adreno_gen8_coresight.c | HITS: 3 --- MATCH LINES: 59 47: { GEN8_DBGC_VBIF_DBG_CNTL }, 48: { GEN8_DBGC_DBG_LO_HI_GPIO }, 49: { GEN8_DBGC_EXT_TRACE_BUS_CNTL }, 50: { GEN8_DBGC_READ_AHB_THROUGH_DBG }, 51: { GEN8_DBGC_CFG_DBGBUS_TRACE_BUF1 }, 52: { GEN8_DBGC_CFG_DBGBUS_TRACE_BUF2 }, 53: { GEN8_DBGC_EVT_CFG }, 54: { GEN8_DBGC_EVT_INTF_SEL_0 }, 55: { GEN8_DBGC_EVT_INTF_SEL_1 }, 56: { GEN8_DBGC_ECO_CNTL }, 57: { GEN8_DBGC_AHB_DBG_CNTL }, 58: { GEN8_DBGC_CFG_DBGBUS_MISC_MODE }, 59: { GEN8_DBGC_SMMU_FAULT_BLOCK_HALT_CFG }, 60: }; 61: 62: static struct adreno_coresight_register gen8_coresight_regs_cx[] = { 63: { GEN8_CX_DBGC_CFG_DBGBUS_SEL_A }, 64: { GEN8_CX_DBGC_CFG_DBGBUS_SEL_B }, 65: { GEN8_CX_DBGC_CFG_DBGBUS_SEL_C }, 66: { GEN8_CX_DBGC_CFG_DBGBUS_SEL_D }, 67: { GEN8_CX_DBGC_CFG_DBGBUS_CNTLT }, 68: { GEN8_CX_DBGC_CFG_DBGBUS_CNTLM }, 69: { GEN8_CX_DBGC_CFG_DBGBUS_OPL }, 70: { GEN8_CX_DBGC_CFG_DBGBUS_OPE }, 71: { GEN8_CX_DBGC_CFG_DBGBUS_IVTL_0 }, 72: { GEN8_CX_DBGC_CFG_DBGBUS_IVTL_1 }, 73: { GEN8_CX_DBGC_CFG_DBGBUS_IVTL_2 }, 74: { GEN8_CX_DBGC_CFG_DBGBUS_IVTL_3 }, 75: { GEN8_CX_DBGC_CFG_DBGBUS_MASKL_0 }, 76: { GEN8_CX_DBGC_CFG_DBGBUS_MASKL_1 }, 77: { GEN8_CX_DBGC_CFG_DBGBUS_MASKL_2 }, 78: { GEN8_CX_DBGC_CFG_DBGBUS_MASKL_3 }, 79: { GEN8_CX_DBGC_CFG_DBGBUS_BYTEL_0 }, 80: { GEN8_CX_DBGC_CFG_DBGBUS_BYTEL_1 }, 81: { GEN8_CX_DBGC_CFG_DBGBUS_IVTE_0 }, 82: { GEN8_CX_DBGC_CFG_DBGBUS_IVTE_1 }, 83: { GEN8_CX_DBGC_CFG_DBGBUS_IVTE_2 }, MATCH LINES: 156 144: static ADRENO_CORESIGHT_ATTR(vbif_dbg_cntl, &gen8_coresight_regs[33]); 145: static ADRENO_CORESIGHT_ATTR(dbg_lo_hi_gpio, &gen8_coresight_regs[34]); 146: static ADRENO_CORESIGHT_ATTR(ext_trace_bus_cntl, &gen8_coresight_regs[35]); 147: static ADRENO_CORESIGHT_ATTR(read_ahb_through_dbg, &gen8_coresight_regs[36]); 148: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_trace_buf1, &gen8_coresight_regs[37]); 149: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_trace_buf2, &gen8_coresight_regs[38]); 150: static ADRENO_CORESIGHT_ATTR(evt_cfg, &gen8_coresight_regs[39]); 151: static ADRENO_CORESIGHT_ATTR(evt_intf_sel_0, &gen8_coresight_regs[40]); 152: static ADRENO_CORESIGHT_ATTR(evt_intf_sel_1, &gen8_coresight_regs[41]); 153: static ADRENO_CORESIGHT_ATTR(eco_cntl, &gen8_coresight_regs[42]); 154: static ADRENO_CORESIGHT_ATTR(ahb_dbg_cntl, &gen8_coresight_regs[43]); 155: static ADRENO_CORESIGHT_ATTR(cfg_dbgbus_misc_mode, &gen8_coresight_regs[44]); 156: static ADRENO_CORESIGHT_ATTR(cfg_smmu_fault_block_halt, &gen8_coresight_regs[45]); 157: 158: /*CX debug registers*/ 159: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_sel_a, 160: &gen8_coresight_regs_cx[0]); 161: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_sel_b, 162: &gen8_coresight_regs_cx[1]); 163: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_sel_c, 164: &gen8_coresight_regs_cx[2]); 165: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_sel_d, 166: &gen8_coresight_regs_cx[3]); 167: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_cntlt, 168: &gen8_coresight_regs_cx[4]); 169: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_cntlm, 170: &gen8_coresight_regs_cx[5]); 171: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_opl, 172: &gen8_coresight_regs_cx[6]); 173: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_ope, 174: &gen8_coresight_regs_cx[7]); 175: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_ivtl_0, 176: &gen8_coresight_regs_cx[8]); 177: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_ivtl_1, 178: &gen8_coresight_regs_cx[9]); 179: static ADRENO_CORESIGHT_ATTR(cx_cfg_dbgbus_ivtl_2, 180: &gen8_coresight_regs_cx[10]); MATCH LINES: 298 286: &coresight_attr_vbif_dbg_cntl.attr.attr, 287: &coresight_attr_dbg_lo_hi_gpio.attr.attr, 288: &coresight_attr_ext_trace_bus_cntl.attr.attr, 289: &coresight_attr_read_ahb_through_dbg.attr.attr, 290: &coresight_attr_cfg_dbgbus_trace_buf1.attr.attr, 291: &coresight_attr_cfg_dbgbus_trace_buf2.attr.attr, 292: &coresight_attr_evt_cfg.attr.attr, 293: &coresight_attr_evt_intf_sel_0.attr.attr, 294: &coresight_attr_evt_intf_sel_1.attr.attr, 295: &coresight_attr_eco_cntl.attr.attr, 296: &coresight_attr_ahb_dbg_cntl.attr.attr, 297: &coresight_attr_cfg_dbgbus_misc_mode.attr.attr, 298: &coresight_attr_cfg_smmu_fault_block_halt.attr.attr, 299: NULL, 300: }; 301: 302: /*cx*/ 303: static struct attribute *gen8_coresight_attrs_cx[] = { 304: &coresight_attr_cx_cfg_dbgbus_sel_a.attr.attr, 305: &coresight_attr_cx_cfg_dbgbus_sel_b.attr.attr, 306: &coresight_attr_cx_cfg_dbgbus_sel_c.attr.attr, 307: &coresight_attr_cx_cfg_dbgbus_sel_d.attr.attr, 308: &coresight_attr_cx_cfg_dbgbus_cntlt.attr.attr, 309: &coresight_attr_cx_cfg_dbgbus_cntlm.attr.attr, 310: &coresight_attr_cx_cfg_dbgbus_opl.attr.attr, 311: &coresight_attr_cx_cfg_dbgbus_ope.attr.attr, 312: &coresight_attr_cx_cfg_dbgbus_ivtl_0.attr.attr, 313: &coresight_attr_cx_cfg_dbgbus_ivtl_1.attr.attr, 314: &coresight_attr_cx_cfg_dbgbus_ivtl_2.attr.attr, 315: &coresight_attr_cx_cfg_dbgbus_ivtl_3.attr.attr, 316: &coresight_attr_cx_cfg_dbgbus_maskl_0.attr.attr, 317: &coresight_attr_cx_cfg_dbgbus_maskl_1.attr.attr, 318: &coresight_attr_cx_cfg_dbgbus_maskl_2.attr.attr, 319: &coresight_attr_cx_cfg_dbgbus_maskl_3.attr.attr, 320: &coresight_attr_cx_cfg_dbgbus_bytel_0.attr.attr, 321: &coresight_attr_cx_cfg_dbgbus_bytel_1.attr.attr, 322: &coresight_attr_cx_cfg_dbgbus_ivte_0.attr.attr, --- FILE: \adreno_gen8_gmu.c | HITS: 6 --- MATCH LINES: 1109 1097: unsigned long t; 1098: 1099: kgsl_regwrite(device, reg, mask); 1100: 1101: t = jiffies + msecs_to_jiffies(100); 1102: do { 1103: kgsl_regread(device, ack_reg, &ack); 1104: if ((ack & mask) == mask) 1105: return; 1106: 1107: /* 1108: * If we are attempting recovery in case of stall-on-fault 1109: * then the halt sequence will not complete as long as SMMU 1110: * is stalled. 1111: */ 1112: kgsl_mmu_pagefault_resume(&device->mmu, false); 1113: 1114: usleep_range(10, 100); 1115: } while (!time_after(jiffies, t)); 1116: 1117: /* Check one last time */ 1118: kgsl_mmu_pagefault_resume(&device->mmu, false); 1119: 1120: kgsl_regread(device, ack_reg, &ack); 1121: if ((ack & mask) == mask) 1122: return; 1123: 1124: dev_err(device->dev, "%s GBIF halt timed out\n", client); 1125: } 1126: 1127: /** 1128: * gen8_gbif_gx_reinit - Apply reinit sequence and wait for ack during GPU recovery 1129: * @device: Pointer to the KGSL device 1130: */ 1131: static inline void gen8_gbif_gx_reinit(struct kgsl_device *device) 1132: { 1133: u32 ack; MATCH LINES: 1446, 1449, 1451 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; 1457: 1458: /* 1459: * We should not send NMI if there was a CM3 fault reported because we 1460: * don't want to overwrite the critical CM3 state captured by gmu before 1461: * it sent the CM3 fault interrupt. Also don't send NMI if GMU reset is 1462: * already active. We could have hit a GMU assert and NMI might have 1463: * already been triggered. 1464: */ 1465: 1466: /* make sure we're reading the latest cm3_fault */ 1467: smp_rmb(); 1468: 1469: if (atomic_read(&gmu->cm3_fault)) 1470: return; 1471: 1472: gmu_core_regread(device, GEN8_GMUCX_CM3_FW_INIT_RESULT, &result); 1473: 1474: if (result & 0xE00) 1475: return; MATCH LINES: 2135, 2136 2123: return ret; 2124: 2125: if (gen8_core->gmu_mx_gdsc) { 2126: ret = kgsl_pwrctrl_probe_mx_gdsc(device, pdev); 2127: if (ret) 2128: return ret; 2129: } 2130: 2131: ret = gmu_core_clk_probe(device); 2132: if (ret) 2133: return ret; 2134: 2135: /* Set up GMU IOMMU and shared memory with GMU */ 2136: ret = gmu_core_iommu_init(device); 2137: if (ret) 2138: goto error; 2139: 2140: gmu_core->vma = gen8_gmu_vma; 2141: gmu_core->num_vmas = ARRAY_SIZE(gen8_gmu_vma); 2142: 2143: for (i = 0; i < gmu_core->num_vmas; i++) { 2144: struct gmu_vma_entry *vma = &gen8_gmu_vma[i]; 2145: 2146: vma->vma_root = RB_ROOT; 2147: spin_lock_init(&vma->lock); 2148: } 2149: 2150: /* Map and reserve GMU CSRs registers */ 2151: ret = gen8_gmu_reg_probe(adreno_dev); 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) --- FILE: \adreno_gen8_hwsched.c | HITS: 1 --- MATCH LINES: 111 99: if (entry->desc.mem_kind == HFI_MEMKIND_SCRATCH) 100: kgsl_snapshot_add_section(device, 101: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 102: snapshot, adreno_snapshot_global, 103: entry->md); 104: 105: if (entry->desc.mem_kind == HFI_MEMKIND_PROFILE) 106: kgsl_snapshot_add_section(device, 107: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 108: snapshot, adreno_snapshot_global, 109: entry->md); 110: 111: if (entry->desc.mem_kind == HFI_MEMKIND_CSW_SMMU_INFO) 112: kgsl_snapshot_add_section(device, 113: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 114: snapshot, adreno_snapshot_global, 115: entry->md); 116: 117: if (entry->desc.mem_kind == HFI_MEMKIND_CSW_PRIV_NON_SECURE) 118: adreno_hwsched_snapshot_preemption_records(device, snapshot, 119: entry->md); 120: 121: if (entry->desc.mem_kind == HFI_MEMKIND_PREEMPT_SCRATCH) 122: kgsl_snapshot_add_section(device, 123: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 124: snapshot, adreno_snapshot_global, 125: entry->md); 126: 127: if (entry->desc.mem_kind == HFI_MEMKIND_AQE_BUFFER) 128: kgsl_snapshot_add_section(device, 129: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 130: snapshot, adreno_hwsched_snapshot_aqe_buffer, 131: entry->md); 132: 133: if (entry->desc.mem_kind == HFI_MEMKIND_HW_FENCE) { 134: struct gmu_mem_type_desc desc; 135: --- FILE: \adreno_gen8_hwsched_hfi.c | HITS: 12 --- MATCH LINES: 7 1: // SPDX-License-Identifier: GPL-2.0-only 2: /* 3: * Copyright (c) 2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #include 8: 9: #include "adreno.h" 10: #include "adreno_gen8.h" 11: #include "adreno_gen8_hwsched.h" 12: #include "adreno_hfi.h" 13: #include "adreno_pm4types.h" 14: #include "adreno_trace.h" 15: #include "kgsl_device.h" 16: #include "kgsl_eventlog.h" 17: #include "kgsl_gmu_core.h" 18: #include "kgsl_pwrctrl.h" 19: #include "kgsl_timeline.h" 20: #include "kgsl_util.h" 21: 22: #define HFI_QUEUE_MAX (HFI_QUEUE_DEFAULT_CNT) 23: 24: #define DEFINE_QHDR(gmuaddr, id, prio) \ 25: {\ 26: .status = 1, \ 27: .start_addr = GMU_QUEUE_START_ADDR(gmuaddr, id), \ 28: .type = QUEUE_HDR_TYPE(id, prio, 0, 0), \ 29: .queue_size = SZ_4K >> 2, \ 30: .msg_size = 0, \ 31: .unused0 = 0, \ MATCH LINES: 263, 265 251: i += struct_size(payload, data, payload->dwords); 252: } 253: 254: return 0; 255: } 256: 257: static void handle_sw_fault(struct adreno_device *adreno_dev, const char *str, u32 key) 258: { 259: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)); 260: u32 status = gen8_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, key); 261: 262: dev_crit_ratelimited(gmu_pdev_dev, "CP %s | SW fault | status=0x%8.8x\n", str, status); 263: /* BIT(12) - SMMU fault */ 264: if (status & BIT(12)) 265: adreno_scheduler_fault(adreno_dev, ADRENO_IOMMU_STALL_ON_PAGE_FAULT); 266: } 267: 268: static bool log_gpu_fault(struct adreno_device *adreno_dev) 269: { 270: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)); 271: struct hfi_context_bad_cmd *cmd = adreno_dev->hwsched.ctxt_bad; 272: 273: /* Return false for non fatal errors */ 274: if (adreno_hwsched_log_nonfatal_gpu_fault(adreno_dev, gmu_pdev_dev, cmd->error)) 275: return false; 276: 277: switch (cmd->error) { 278: case GMU_GPU_HW_HANG: 279: dev_crit_ratelimited(gmu_pdev_dev, "MISC: GPU hang detected\n"); 280: break; 281: case GMU_GPU_SW_HANG: 282: dev_crit_ratelimited(gmu_pdev_dev, "gpu timeout ctx %u ts %u\n", 283: cmd->gc.ctxt_id, cmd->gc.ts); 284: break; 285: case GMU_CP_OPCODE_ERROR: 286: dev_crit_ratelimited(gmu_pdev_dev, 287: "CP opcode error interrupt | opcode=0x%8.8x\n", 288: gen8_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 289: KEY_CP_OPCODE_ERROR)); MATCH LINES: 3013, 3025, 3042, 3043, 3059, 3060, 3064, 3065, 3067 3001: 3002: static int allocate_context_queues(struct adreno_device *adreno_dev, 3003: struct adreno_context *drawctxt) 3004: { 3005: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 3006: int ret = 0; 3007: 3008: if (test_bit(ADRENO_HWSCHED_HW_FENCE, &adreno_dev->hwsched.flags) && 3009: !drawctxt->gmu_hw_fence_queue.gmuaddr) { 3010: ret = gmu_core_alloc_kernel_block( 3011: device, &drawctxt->gmu_hw_fence_queue, 3012: HW_FENCE_QUEUE_SIZE, GMU_NONCACHED_KERNEL, 3013: IOMMU_READ | IOMMU_WRITE | IOMMU_PRIV); 3014: if (ret) { 3015: memset(&drawctxt->gmu_hw_fence_queue, 0x0, 3016: sizeof(drawctxt->gmu_hw_fence_queue)); 3017: return ret; 3018: } 3019: } 3020: 3021: if (!drawctxt->gmu_context_queue.gmuaddr) { 3022: ret = gmu_core_alloc_kernel_block( 3023: device, &drawctxt->gmu_context_queue, 3024: SZ_4K, GMU_NONCACHED_KERNEL, 3025: IOMMU_READ | IOMMU_WRITE | IOMMU_PRIV); 3026: if (ret) { 3027: memset(&drawctxt->gmu_context_queue, 0x0, 3028: sizeof(drawctxt->gmu_context_queue)); 3029: return ret; 3030: } 3031: init_gmu_context_queue(drawctxt); 3032: } 3033: 3034: return 0; 3035: } 3036: 3037: static int send_context_register(struct adreno_device *adreno_dev, 3038: struct kgsl_context *context) 3039: { 3040: struct adreno_context *drawctxt = ADRENO_CONTEXT(context); 3041: struct hfi_register_ctxt_cmd cmd; 3042: struct kgsl_pagetable *pt = context->proc_priv->pagetable; 3043: int ret, asid = kgsl_mmu_pagetable_get_asid(pt, context); 3044: 3045: if (asid < 0) 3046: return asid; 3047: 3048: ret = CMD_MSG_HDR(cmd, H2F_MSG_REGISTER_CONTEXT); 3049: if (ret) 3050: return ret; 3051: 3052: ret = allocate_context_queues(adreno_dev, drawctxt); 3053: if (ret) 3054: return ret; 3055: 3056: cmd.ctxt_id = context->id; 3057: cmd.flags = HFI_CTXT_FLAG_NOTIFY | context->flags; 3058: /* 3059: * HLOS SMMU driver programs context bank to look up ASID from TTBR0 during a page 3060: * table walk. So the TLB entries are tagged with the ASID from TTBR0. TLBIASID 3061: * invalidates TLB entries whose ASID matches the value that was written to the 3062: * CBn_TLBIASID register. Set ASID along with PT address. 3063: */ 3064: cmd.pt_addr = kgsl_mmu_pagetable_get_ttbr0(pt) | 3065: FIELD_PREP(GENMASK_ULL(63, KGSL_IOMMU_ASID_START_BIT), asid); 3066: cmd.ctxt_idr = context->id; 3067: cmd.ctxt_bank = kgsl_mmu_pagetable_get_context_bank(pt, context); 3068: 3069: return gen8_hfi_send_cmd_async(adreno_dev, &cmd, sizeof(cmd)); 3070: } 3071: 3072: static int send_context_pointers(struct adreno_device *adreno_dev, 3073: struct kgsl_context *context) 3074: { 3075: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 3076: struct hfi_context_pointers_cmd cmd = {0}; 3077: struct adreno_context *drawctxt = ADRENO_CONTEXT(context); 3078: struct kgsl_process_private *proc_priv = drawctxt->base.proc_priv; 3079: struct kgsl_memdesc md = proc_priv->profile.md; 3080: int ret; 3081: 3082: ret = CMD_MSG_HDR(cmd, H2F_MSG_CONTEXT_POINTERS); 3083: if (ret) 3084: return ret; 3085: 3086: cmd.ctxt_id = context->id; 3087: cmd.sop_addr = MEMSTORE_ID_GPU_ADDR(device, context->id, soptimestamp); 3088: cmd.eop_addr = MEMSTORE_ID_GPU_ADDR(device, context->id, eoptimestamp); 3089: cmd.version = 1; 3090: cmd.dcvs_profile_addr = GMU_BUF_ADDR(md); 3091: if (context->user_ctxt_record) --- FILE: \adreno_gen8_preempt.c | HITS: 39 --- MATCH LINES: 16, 17 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #include "adreno.h" 8: #include "adreno_gen8.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 gen8_cp_preemption_record, _field) 15: 16: #define PREEMPT_SMMU_RECORD(_field) \ 17: offsetof(struct gen8_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 = gen8_fenced_write(adreno_dev, 37: GEN8_CP_RB_WPTR_GC, rb->wptr, 38: FENCE_STATUS_WRITEDROPPED0_MASK); 39: 40: reset_timer = true; 41: rb->skip_inline_wptr = false; MATCH LINES: 209, 211, 212 197: 198: if (!empty) 199: return rb; 200: } 201: 202: return NULL; 203: } 204: 205: void gen8_preemption_trigger(struct adreno_device *adreno_dev, bool atomic) 206: { 207: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev); 208: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 209: struct kgsl_iommu *iommu = KGSL_IOMMU(device); 210: struct adreno_ringbuffer *next; 211: u64 ttbr0, gpuaddr; 212: u32 contextidr, cntl; 213: unsigned long flags; 214: struct adreno_preemption *preempt = &adreno_dev->preempt; 215: 216: /* Put ourselves into a possible trigger state */ 217: if (!adreno_move_preempt_state(adreno_dev, 218: ADRENO_PREEMPT_NONE, ADRENO_PREEMPT_START)) 219: return; 220: 221: /* Get the next ringbuffer to preempt in */ 222: next = gen8_next_ringbuffer(adreno_dev); 223: 224: /* 225: * Nothing to do if every ringbuffer is empty or if the current 226: * ringbuffer is the only active one 227: */ 228: if (next == NULL || next == adreno_dev->cur_rb) { 229: /* 230: * Update any critical things that might have been skipped while 231: * we were looking for a new ringbuffer 232: */ 233: 234: if (next != NULL) { 235: _update_wptr(adreno_dev, false, atomic); 236: MATCH LINES: 255, 256, 257, 258, 259, 266, 268, 269, 270, 271 243: } 244: 245: /* Turn off the dispatcher timer */ 246: kgsl_delete_timer(&adreno_dev->dispatcher.timer); 247: 248: /* 249: * This is the most critical section - we need to take care not to race 250: * until we have programmed the CP for the switch 251: */ 252: 253: spin_lock_irqsave(&next->preempt_lock, flags); 254: 255: /* Get the pagetable from the pagetable info. */ 256: kgsl_sharedmem_readq(device->scratch, &ttbr0, 257: SCRATCH_RB_OFFSET(next->id, ttbr0)); 258: kgsl_sharedmem_readl(device->scratch, &contextidr, 259: SCRATCH_RB_OFFSET(next->id, contextidr)); 260: 261: kgsl_sharedmem_writel(next->preemption_desc, 262: PREEMPT_RECORD(wptr), next->wptr); 263: 264: spin_unlock_irqrestore(&next->preempt_lock, flags); 265: 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: */ MATCH LINES: 543, 544 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); 566: 567: done: 568: if (drawctxt) { MATCH LINES: 608, 619, 620, 621, 622, 623, 626, 627, 628, 629, 631, 632, 634, 635, 644, 645 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, 621: PREEMPT_SMMU_RECORD(magic), GEN8_CP_SMMU_INFO_MAGIC_REF); 622: kgsl_sharedmem_writeq(iommu->smmu_info, 623: PREEMPT_SMMU_RECORD(ttbr0), MMU_DEFAULT_TTBR0(device)); 624: 625: /* The CP doesn't use the asid record, so poison it */ 626: kgsl_sharedmem_writel(iommu->smmu_info, 627: PREEMPT_SMMU_RECORD(asid), 0xdecafbad); 628: kgsl_sharedmem_writel(iommu->smmu_info, 629: PREEMPT_SMMU_RECORD(context_idr), 0); 630: 631: kgsl_regwrite(device, GEN8_CP_CONTEXT_SWITCH_SMMU_INFO_LO, 632: lower_32_bits(iommu->smmu_info->gpuaddr)); 633: 634: kgsl_regwrite(device, GEN8_CP_CONTEXT_SWITCH_SMMU_INFO_HI, 635: upper_32_bits(iommu->smmu_info->gpuaddr)); 636: } 637: 638: FOR_EACH_RINGBUFFER(adreno_dev, rb, i) { 639: kgsl_sharedmem_writel(rb->preemption_desc, 640: PREEMPT_RECORD(rptr), 0); 641: kgsl_sharedmem_writel(rb->preemption_desc, 642: PREEMPT_RECORD(wptr), 0); 643: 644: adreno_ringbuffer_set_pagetable(device, rb, 645: device->mmu.defaultpagetable); 646: 647: clear_bit(ADRENO_RB_SET_PSEUDO_DONE, &rb->flags); 648: } 649: } 650: 651: static void reset_rb_preempt_record(struct adreno_device *adreno_dev, 652: struct adreno_ringbuffer *rb) 653: { 654: memset(rb->preemption_desc->hostptr, 0x0, rb->preemption_desc->size); 655: 656: kgsl_sharedmem_writel(rb->preemption_desc, 657: PREEMPT_RECORD(magic), GEN8_CP_CTXRECORD_MAGIC_REF); 658: kgsl_sharedmem_writel(rb->preemption_desc, 659: PREEMPT_RECORD(cntl), GEN8_CP_RB_CNTL_DEFAULT); 660: kgsl_sharedmem_writeq(rb->preemption_desc, 661: PREEMPT_RECORD(rptr_addr), SCRATCH_RB_GPU_ADDR( 662: KGSL_DEVICE(adreno_dev), rb->id, rptr)); 663: kgsl_sharedmem_writeq(rb->preemption_desc, 664: PREEMPT_RECORD(rbase), rb->buffer_desc->gpuaddr); 665: kgsl_sharedmem_writeq(rb->preemption_desc, 666: PREEMPT_RECORD(bv_rptr_addr), SCRATCH_RB_GPU_ADDR( 667: KGSL_DEVICE(adreno_dev), rb->id, bv_rptr)); 668: } 669: MATCH LINES: 729, 735, 736, 755, 757, 759 717: if (ret) 718: return ret; 719: 720: reset_rb_preempt_record(adreno_dev, rb); 721: 722: return 0; 723: } 724: 725: int gen8_preemption_init(struct adreno_device *adreno_dev) 726: { 727: u32 flags = ADRENO_FEATURE(adreno_dev, ADRENO_APRIV) ? KGSL_MEMDESC_PRIVILEGED : 0; 728: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 729: struct kgsl_iommu *iommu = KGSL_IOMMU(device); 730: struct adreno_preemption *preempt = &adreno_dev->preempt; 731: struct adreno_ringbuffer *rb; 732: int ret; 733: u32 i; 734: 735: /* We are dependent on IOMMU to make preemption go on the CP side */ 736: if (kgsl_mmu_get_mmutype(device) != KGSL_MMU_TYPE_IOMMU) { 737: ret = -ENODEV; 738: goto done; 739: } 740: 741: INIT_WORK(&preempt->work, _gen8_preemption_worker); 742: 743: /* Allocate mem for storing preemption switch record */ 744: FOR_EACH_RINGBUFFER(adreno_dev, rb, i) { 745: ret = gen8_preemption_ringbuffer_init(adreno_dev, rb); 746: if (ret) 747: goto done; 748: } 749: 750: ret = adreno_allocate_global(device, &preempt->scratch, PAGE_SIZE, 751: 0, 0, flags, "preempt_scratch"); 752: if (ret) 753: goto done; 754: 755: /* Allocate mem for storing preemption smmu record */ 756: if (kgsl_mmu_is_perprocess(&device->mmu)) { 757: ret = adreno_allocate_global(device, &iommu->smmu_info, PAGE_SIZE, 0, 758: KGSL_MEMFLAGS_GPUREADONLY, KGSL_MEMDESC_PRIVILEGED, 759: "smmu_info"); 760: if (ret) 761: goto done; 762: } 763: 764: return 0; 765: done: 766: clear_bit(ADRENO_DEVICE_PREEMPTION, &adreno_dev->priv); 767: return ret; 768: } --- FILE: \adreno_gen8_ringbuffer.c | HITS: 26 --- MATCH LINES: 22, 24, 27, 31, 34, 35, 36, 37, 42, 44, 45, 46, 50, 52, 64, 65, 78, 79, 86, 87, 106, 107, 120, 122, 125, 126 10: #include "adreno_ringbuffer.h" 11: #include "adreno_trace.h" 12: #include "kgsl_trace.h" 13: 14: static bool is_concurrent_binning(struct adreno_context *drawctxt) 15: { 16: if (!drawctxt) 17: return false; 18: 19: return !(drawctxt->base.flags & KGSL_CONTEXT_SECURE); 20: } 21: 22: static int gen8_rb_pagetable_switch(struct adreno_device *adreno_dev, 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); --- FILE: \adreno_gen8_snapshot.c | HITS: 1 --- MATCH LINES: 331 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) --- FILE: \adreno_hfi.h | HITS: 3 --- MATCH LINES: 183, 186 171: 172: /* Default sampling interval in units of 50 us */ 173: #define HFI_FEATURE_GMU_STATS_INTERVAL 4 174: 175: enum hfi_mem_kind { 176: /** @HFI_MEMKIND_GENERIC: Used for requesting generic memory */ 177: HFI_MEMKIND_GENERIC = 0, 178: /** @HFI_MEMKIND_RB: Used for requesting ringbuffer memory */ 179: HFI_MEMKIND_RB, 180: /** @HFI_MEMKIND_SCRATCH: Used for requesting scratch memory */ 181: HFI_MEMKIND_SCRATCH, 182: /** 183: * @HFI_MEMKIND_CSW_SMMU_INFO: Used for requesting SMMU record for 184: * preemption context switching 185: */ 186: HFI_MEMKIND_CSW_SMMU_INFO, 187: /** 188: * @HFI_MEMKIND_CSW_PRIV_NON_SECURE: Used for requesting privileged non 189: * secure preemption records 190: */ 191: HFI_MEMKIND_CSW_PRIV_NON_SECURE, 192: /** 193: * @HFI_MEMKIND_CSW_PRIV_SECURE: Used for requesting privileged secure 194: * preemption records 195: */ 196: HFI_MEMKIND_CSW_PRIV_SECURE, 197: /** 198: * @HFI_MEMKIND_CSW_NON_PRIV: Used for requesting non privileged per 199: * context preemption buffer 200: */ 201: HFI_MEMKIND_CSW_NON_PRIV, 202: /** 203: * @HFI_MEMKIND_CSW_COUNTER: Used for requesting preemption performance 204: * counter save/restore buffer 205: */ 206: HFI_MEMKIND_CSW_COUNTER, 207: /** 208: * @HFI_MEMKIND_CTXTREC_PREEMPT_CNTR: Used for requesting preemption 209: * counter buffer 210: */ MATCH LINES: 293 281: /** 282: * @HFI_MEMKIND_DUMMY_CSW_COUNTER: Used for requesting preemption performance 283: * counter save/restore buffer for the internal dummy buffer 284: */ 285: HFI_MEMKIND_DUMMY_CSW_COUNTER, 286: HFI_MEMKIND_MAX, 287: }; 288: 289: static const char * const hfi_memkind_strings[] = { 290: [HFI_MEMKIND_GENERIC] = "GMU GENERIC", 291: [HFI_MEMKIND_RB] = "GMU RB", 292: [HFI_MEMKIND_SCRATCH] = "GMU SCRATCH", 293: [HFI_MEMKIND_CSW_SMMU_INFO] = "GMU SMMU INFO", 294: [HFI_MEMKIND_CSW_PRIV_NON_SECURE] = "GMU CSW PRIV NON SECURE", 295: [HFI_MEMKIND_CSW_PRIV_SECURE] = "GMU CSW PRIV SECURE", 296: [HFI_MEMKIND_CSW_NON_PRIV] = "GMU CSW NON PRIV", 297: [HFI_MEMKIND_CSW_COUNTER] = "GMU CSW COUNTER", 298: [HFI_MEMKIND_CTXTREC_PREEMPT_CNTR] = "GMU PREEMPT CNTR", 299: [HFI_MEMKIND_SYS_LOG] = "GMU SYS LOG", 300: [HFI_MEMKIND_CRASH_DUMP] = "GMU CRASHDUMP", 301: [HFI_MEMKIND_MMIO_DPU] = "GMU MMIO DPU", 302: [HFI_MEMKIND_MMIO_TCSR] = "GMU MMIO TCSR", 303: [HFI_MEMKIND_MMIO_QDSS_STM] = "GMU MMIO QDSS STM", 304: [HFI_MEMKIND_PROFILE] = "GMU KERNEL PROFILING", 305: [HFI_MEMKIND_USER_PROFILE_IBS] = "GMU USER PROFILING", 306: [HFI_MEMKIND_CMD_BUFFER] = "GMU CMD BUFFER", 307: [HFI_MEMKIND_GPU_BUSY_DATA_BUFFER] = "GMU BUSY DATA BUFFER", 308: [HFI_MEMKIND_GPU_BUSY_CMD_BUFFER] = "GMU BUSY CMD BUFFER", 309: [HFI_MEMKIND_MMIO_IPC_CORE] = "GMU MMIO IPC", 310: [HFI_MEMKIND_MMIO_IPCC_AOSS] = "GMU MMIO IPCC AOSS", 311: [HFI_MEMKIND_CSW_LPAC_PRIV_NON_SECURE] = "GMU CSW LPAC PRIV NON SECURE", 312: [HFI_MEMKIND_MEMSTORE] = "GMU MEMSTORE", 313: [HFI_MEMKIND_HW_FENCE] = "GMU HW FENCE", 314: [HFI_MEMKIND_PREEMPT_SCRATCH] = "GMU PREEMPTION", 315: [HFI_MEMKIND_AQE_BUFFER] = "GMU AQE BUFFER", 316: [HFI_MEMKIND_HW_FENCE_SHADOW] = "GMU HW FENCE SHADOW", 317: [HFI_MEMKIND_FREQMGR_SCRATCH] = "GMU FREQMGR SCRATCH", --- FILE: \adreno_hwsched.c | HITS: 6 --- MATCH LINES: 2165 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; MATCH LINES: 2233, 2234, 2254, 2273 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); MATCH LINES: 2396 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: { --- FILE: \adreno_hwsched_snapshot.c | HITS: 2 --- MATCH LINES: 203 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; MATCH LINES: 271 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++) --- FILE: \adreno_pm4types.h | HITS: 2 --- MATCH LINES: 44, 45 32: /* indirect buffer dispatch. same as IB, but init is pipelined */ 33: #define CP_INDIRECT_BUFFER_PFD 0x37 34: 35: /* wait for the IDLE state of the engine */ 36: #define CP_WAIT_FOR_IDLE 0x26 37: 38: /* wait until a register or memory location is a specific value */ 39: #define CP_WAIT_REG_MEM 0x3c 40: 41: /* wait until a register location is equal to a specific value */ 42: #define CP_WAIT_REG_EQ 0x52 43: 44: /* switches SMMU pagetable, used on a5xx only */ 45: #define CP_SMMU_TABLE_UPDATE 0x53 46: 47: /* Designate command streams to be executed before/after CP does state restore during preemption */ 48: #define CP_SET_AMBLE 0x55 49: 50: /* Set internal CP registers, used to indicate context save data addresses */ 51: #define CP_SET_PSEUDO_REGISTER 0x56 52: 53: /* Tell CP the current operation mode, indicates save and restore procedure */ 54: #define CP_SET_MARKER 0x65 55: 56: /* register read/modify/write */ 57: #define CP_REG_RMW 0x21 58: 59: /* Set binning configuration registers */ 60: #define CP_SET_BIN_DATA 0x2f 61: 62: /* reads register in chip and writes to memory */ 63: #define CP_REG_TO_MEM 0x3e 64: 65: /* reads memory and writes to register in chip */ 66: #define CP_MEM_TO_REG 0x42 67: 68: /* write N 32-bit words to memory */ 69: #define CP_MEM_WRITE 0x3d --- FILE: \adreno_ringbuffer.h | HITS: 2 --- MATCH LINES: 76, 83 64: * struct adreno_ringbuffer - Definition for an adreno ringbuffer object 65: * @flags: Internal control flags for the ringbuffer 66: * @buffer_desc: Pointer to the ringbuffer memory descriptor 67: * @_wptr: The next value of wptr to be written to the hardware on submit 68: * @wptr: Local copy of the wptr offset last written to hardware 69: * @last_wptr: offset of the last wptr that was written to CFF 70: * @rb_ctx: The context that represents a ringbuffer 71: * @id: Priority level of the ringbuffer, also used as an ID 72: * @fault_detect_ts: The last retired global timestamp read during fault detect 73: * @timestamp: The RB's global timestamp 74: * @events: A kgsl_event_group for this context - contains the list of GPU 75: * events 76: * @drawctxt_active: The last pagetable that this ringbuffer is set to 77: * @preemption_desc: The memory descriptor containing 78: * preemption info written/read by CP 79: * @secure_preemption_desc: The memory descriptor containing 80: * preemption info written/read by CP for secure contexts 81: * @perfcounter_save_restore_desc: Used by CP to save/restore the perfcounter 82: * values across preemption 83: * and the commands to switch pagetable on the RB 84: * @dispatch_q: The dispatcher side queue for this ringbuffer 85: * @ts_expire_waitq: Wait queue to wait for rb timestamp to expire 86: * @ts_expire_waitq: Wait q to wait for rb timestamp to expire 87: * @wptr_preempt_end: Used during preemption to check that preemption occurred 88: * at the right rptr 89: * @gpr11: The gpr11 value of this RB 90: * @preempted_midway: Indicates that the RB was preempted before rptr = wptr 91: * @preempt_lock: Lock to protect the wptr pointer while it is being updated 92: * @skip_inline_wptr: Used during preemption to make sure wptr is updated in 93: * hardware 94: */ 95: struct adreno_ringbuffer { 96: unsigned long flags; 97: struct kgsl_memdesc *buffer_desc; 98: unsigned int _wptr; 99: unsigned int wptr; 100: unsigned int last_wptr; 101: int id; 102: unsigned int fault_detect_ts; 103: unsigned int timestamp; 104: struct kgsl_event_group events; 105: struct adreno_context *drawctxt_active; 106: struct kgsl_memdesc *preemption_desc; 107: struct kgsl_memdesc *secure_preemption_desc; --- FILE: \adreno_snapshot.c | HITS: 28 --- MATCH LINES: 278, 292 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) MATCH LINES: 434, 452, 463 422: (rbptr[index + 1] == CONTEXT_TO_MEM_IDENTIFIER)) 423: break; 424: } 425: 426: /* 427: * Index represents the start of the window of interest. We will try 428: * to dump all buffers between here and the rptr 429: */ 430: 431: ib_parse_start = index; 432: 433: /* 434: * Loop through the RB, looking for indirect buffers and MMU pagetable 435: * changes 436: */ 437: 438: index = rb->wptr; 439: for (i = 0; i < KGSL_RB_DWORDS; i++) { 440: /* 441: * Only parse IBs between the start and the rptr or the next 442: * context switch, whichever comes first 443: */ 444: 445: if (parse_ibs == 0 && index == ib_parse_start) 446: parse_ibs = 1; 447: else if (index == rptr || adreno_rb_ctxtswitch(adreno_dev, 448: &rbptr[index])) 449: parse_ibs = 0; 450: 451: if (parse_ibs && adreno_cmd_is_ib(adreno_dev, rbptr[index])) { 452: struct kgsl_iommu *iommu = KGSL_IOMMU(device); 453: uint64_t ibaddr; 454: uint64_t ibsize; 455: 456: ibaddr = rbptr[index + 2]; 457: ibaddr = ibaddr << 32 | rbptr[index + 1]; 458: ibsize = rbptr[index + 3]; 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; MATCH LINES: 567 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: MATCH LINES: 771, 809, 823, 824, 828, 830, 832, 845, 851, 853, 854 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; MATCH LINES: 895, 903, 904, 908, 911, 916 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 *) MATCH LINES: 964, 965 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: MATCH LINES: 1231, 1232 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); MATCH LINES: 1443 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: \gen7_reg.h | HITS: 5 --- MATCH LINES: 62, 63 50: #define GEN7_CP_PROTECT_STATUS 0x824 51: #define GEN7_CP_STATUS_1 0x825 52: #define GEN7_CP_SQE_INSTR_BASE_LO 0x830 53: #define GEN7_CP_SQE_INSTR_BASE_HI 0x831 54: #define GEN7_CP_MISC_CNTL 0x840 55: #define GEN7_CP_CHICKEN_DBG 0x841 56: #define GEN7_CP_DBG_ECO_CNTL 0x843 57: #define GEN7_CP_APRIV_CNTL 0x844 58: #define GEN7_CP_SEMAPHORE_REG_0 0x846 59: #define GEN7_CP_PROTECT_CNTL 0x84f 60: #define GEN7_CP_PROTECT_REG 0x850 61: #define GEN7_CP_CONTEXT_SWITCH_CNTL 0x8a0 62: #define GEN7_CP_CONTEXT_SWITCH_SMMU_INFO_LO 0x8a1 63: #define GEN7_CP_CONTEXT_SWITCH_SMMU_INFO_HI 0x8a2 64: #define GEN7_CP_CONTEXT_SWITCH_PRIV_NON_SECURE_RESTORE_ADDR_LO 0x8a3 65: #define GEN7_CP_CONTEXT_SWITCH_PRIV_NON_SECURE_RESTORE_ADDR_HI 0x8a4 66: #define GEN7_CP_CONTEXT_SWITCH_PRIV_SECURE_RESTORE_ADDR_LO 0x8a5 67: #define GEN7_CP_CONTEXT_SWITCH_PRIV_SECURE_RESTORE_ADDR_HI 0x8a6 68: #define GEN7_CP_CONTEXT_SWITCH_NON_PRIV_RESTORE_ADDR_LO 0x8a7 69: #define GEN7_CP_CONTEXT_SWITCH_NON_PRIV_RESTORE_ADDR_HI 0x8a8 70: #define GEN7_CP_CONTEXT_SWITCH_LEVEL_STATUS 0x8ab 71: #define GEN7_CP_PERFCTR_CP_SEL_0 0x8d0 72: #define GEN7_CP_PERFCTR_CP_SEL_1 0x8d1 73: #define GEN7_CP_PERFCTR_CP_SEL_2 0x8d2 74: #define GEN7_CP_PERFCTR_CP_SEL_3 0x8d3 75: #define GEN7_CP_PERFCTR_CP_SEL_4 0x8d4 76: #define GEN7_CP_PERFCTR_CP_SEL_5 0x8d5 77: #define GEN7_CP_PERFCTR_CP_SEL_6 0x8d6 78: #define GEN7_CP_PERFCTR_CP_SEL_7 0x8d7 79: #define GEN7_CP_PERFCTR_CP_SEL_8 0x8d8 80: #define GEN7_CP_PERFCTR_CP_SEL_9 0x8d9 81: #define GEN7_CP_PERFCTR_CP_SEL_10 0x8da 82: #define GEN7_CP_PERFCTR_CP_SEL_11 0x8db 83: #define GEN7_CP_PERFCTR_CP_SEL_12 0x8dc 84: #define GEN7_CP_PERFCTR_CP_SEL_13 0x8dd 85: #define GEN7_CP_BV_PERFCTR_CP_SEL_0 0x8e0 86: #define GEN7_CP_BV_PERFCTR_CP_SEL_1 0x8e1 87: #define GEN7_CP_BV_PERFCTR_CP_SEL_2 0x8e2 MATCH LINES: 770 758: #define GEN7_DBGC_PERF_ATB_COUNTER_SEL_1 0x645 759: #define GEN7_DBGC_PERF_ATB_COUNTER_SEL_2 0x646 760: #define GEN7_DBGC_PERF_ATB_COUNTER_SEL_3 0x647 761: #define GEN7_DBGC_PERF_ATB_TRIG_INTF_SEL_0 0x648 762: #define GEN7_DBGC_PERF_ATB_TRIG_INTF_SEL_1 0x649 763: #define GEN7_DBGC_PERF_ATB_DRAIN_CMD 0x64a 764: #define GEN7_DBGC_ECO_CNTL 0x650 765: #define GEN7_DBGC_AHB_DBG_CNTL 0x651 766: #define GEN7_DBGC_CFG_DBGBUS_MISC_MODE 0x658 767: #define GEN7_DBGC_TRACE_BUFFER_STATUS 0x699 768: #define GEN7_DBGC_DBG_TRACE_BUFFER_RD_ADDR 0x69b 769: #define GEN7_DBGC_DBG_TRACE_BUFFER_RD_DATA 0x69c 770: #define GEN7_DBGC_SMMU_FAULT_BLOCK_HALT_CFG 0x69e 771: 772: /* VSC registers */ 773: #define GEN7_VSC_PERFCTR_VSC_SEL_0 0xcd8 774: #define GEN7_VSC_PERFCTR_VSC_SEL_1 0xcd9 775: 776: /* GRAS registers */ 777: #define GEN7_GRAS_NC_MODE_CNTL 0x8602 778: #define GEN7_GRAS_PERFCTR_TSE_SEL_0 0x8610 779: #define GEN7_GRAS_PERFCTR_TSE_SEL_1 0x8611 780: #define GEN7_GRAS_PERFCTR_TSE_SEL_2 0x8612 781: #define GEN7_GRAS_PERFCTR_TSE_SEL_3 0x8613 782: #define GEN7_GRAS_PERFCTR_RAS_SEL_0 0x8614 783: #define GEN7_GRAS_PERFCTR_RAS_SEL_1 0x8615 784: #define GEN7_GRAS_PERFCTR_RAS_SEL_2 0x8616 785: #define GEN7_GRAS_PERFCTR_RAS_SEL_3 0x8617 786: #define GEN7_GRAS_PERFCTR_LRZ_SEL_0 0x8618 787: #define GEN7_GRAS_PERFCTR_LRZ_SEL_1 0x8619 788: #define GEN7_GRAS_PERFCTR_LRZ_SEL_2 0x861a 789: #define GEN7_GRAS_PERFCTR_LRZ_SEL_3 0x861b 790: 791: /* RB registers */ 792: #define GEN7_RB_NC_MODE_CNTL 0x8e08 793: #define GEN7_RB_PERFCTR_RB_SEL_0 0x8e10 794: #define GEN7_RB_PERFCTR_RB_SEL_1 0x8e11 MATCH LINES: 1324, 1330 1312: #define GEN7_2_0_RSCC_TCS3_DRV0_STATUS 0x00542 1313: #define GEN7_2_0_RSCC_TCS4_DRV0_STATUS 0x005ea 1314: #define GEN7_2_0_RSCC_TCS5_DRV0_STATUS 0x00692 1315: #define GEN7_2_0_RSCC_TCS6_DRV0_STATUS 0x0073a 1316: #define GEN7_2_0_RSCC_TCS7_DRV0_STATUS 0x007e2 1317: #define GEN7_2_0_RSCC_TCS8_DRV0_STATUS 0x0088a 1318: #define GEN7_2_0_RSCC_TCS9_DRV0_STATUS 0x00932 1319: 1320: /* GPU PDC sequencer registers in AOSS.RPMh domain */ 1321: #define GEN7_PDC_GPU_ENABLE_PDC 0x1140 1322: #define GEN7_PDC_GPU_SEQ_START_ADDR 0x1148 1323: 1324: #define GEN7_SMMU_BASE 0x28000 1325: 1326: /* GPU CX_MISC registers */ 1327: #define GEN7_GPU_CX_MISC_CX_AHB_AON_CNTL 0x27810 1328: #define GEN7_GPU_CX_MISC_CX_AHB_GMU_CNTL 0x27811 1329: #define GEN7_GPU_CX_MISC_CX_AHB_CP_CNTL 0x27812 1330: #define GEN7_GPU_CX_MISC_CX_AHB_VBIF_SMMU_CNTL 0x27813 1331: #define GEN7_GPU_CX_MISC_CX_AHB_HOST_CNTL 0x27814 1332: #define GEN7_GPU_CX_MISC_AO_COUNTER_LO 0x27880 1333: #define GEN7_GPU_CX_MISC_AO_COUNTER_HI 0x27881 1334: #define GEN7_GPU_CX_MISC_SW_FUSE_VALUE 0x27C00 1335: 1336: /* GPU SW Fuse Feature bit fields */ 1337: #define GEN7_FASTBLEND_SW_FUSE 0 1338: #define GEN7_LPAC_SW_FUSE 1 1339: #define GEN7_RAYTRACING_SW_FUSE 2 1340: 1341: #define GEN7_SW_FUSE_INT_MASK \ 1342: ((1 << GEN7_FASTBLEND_SW_FUSE) | \ 1343: (1 << GEN7_LPAC_SW_FUSE) | \ 1344: (1 << GEN7_RAYTRACING_SW_FUSE)) 1345: 1346: /* QDSS register offsets */ 1347: #define QDSS_AOSS_APB_TMC_RSZ 0x04 1348: #define QDSS_AOSS_APB_TMC_RRD 0x10 1349: #define QDSS_AOSS_APB_TMC_RRP 0x14 1350: #define QDSS_AOSS_APB_TMC_RWP 0x18 1351: #define QDSS_AOSS_APB_TMC_CTRL 0x20 1352: #define QDSS_AOSS_APB_TMC_MODE 0x28 1353: #define QDSS_AOSS_APB_TMC_FFCR 0x304 1354: #define QDSS_AOSS_APB_TMC_LAR 0xfb0 --- FILE: \gen8_reg.h | HITS: 8 --- MATCH LINES: 615 603: #define GEN8_DBGC_CFG_DBGBUS_MISC_MODE 0x644 604: #define GEN8_DBGC_EVT_INTF_SEL_3_0 0x650 /* Indexed Register */ 605: #define GEN8_DBGC_EVT_INTF_SEL_3_1 0x651 /* Indexed Register */ 606: #define GEN8_DBGC_EVT_INTF_SEL_3_2 0x652 /* Indexed Register */ 607: #define GEN8_DBGC_EVT_INTF_SEL_3_3 0x653 /* Indexed Register */ 608: #define GEN8_DBGC_EVT_INTF_SEL_3_4 0x654 /* Indexed Register */ 609: #define GEN8_DBGC_EVT_INTF_SEL_3_5 0x655 /* Indexed Register */ 610: #define GEN8_DBGC_TRACE_BUFFER_STATUS 0x660 611: #define GEN8_DBGC_TRACE_BUFFER_CMD 0x661 612: #define GEN8_DBGC_DBG_TRACE_BUFFER_RD_ADDR 0x662 613: #define GEN8_DBGC_DBG_TRACE_BUFFER_RD_DATA 0x663 614: #define GEN8_DBGC_TRACE_BUFFER_ATB_RD_STATUS 0x664 615: #define GEN8_DBGC_SMMU_FAULT_BLOCK_HALT_CFG 0x665 616: #define GEN8_DBGC_DBG_LOPC_SB_RD_ADDR 0x666 617: #define GEN8_DBGC_DBG_LOPC_SB_RD_DATA 0x667 618: #define GEN8_DBGC_DBG_LOPC_SB_WR_ADDR 0x668 619: #define GEN8_DBGC_DBG_LOPC_SB_WR_DATA 0x669 620: #define GEN8_DBGC_INTERRUPT_STATUS 0x66a 621: #define GEN8_DBGC_GBIF_DBG_BASE_LO 0x680 622: #define GEN8_DBGC_GBIF_DBG_BASE_HI 0x681 623: #define GEN8_DBGC_GBIF_DBG_BUFF_SIZE 0x682 624: #define GEN8_DBGC_GBIF_DBG_CNTL 0x683 625: #define GEN8_DBGC_GBIF_DBG_CMD 0x684 626: #define GEN8_DBGC_GBIF_DBG_STATUS 0x685 627: #define GEN8_DBGC_SCOPE_PERF_COUNTER_CFG_US 0x700 628: #define GEN8_DBGC_CFG_PERF_TRIG_CLUSTER_FE_US 0x701 629: #define GEN8_DBGC_CFG_PERF_TRIG_CLUSTER_VPC_US 0x702 630: #define GEN8_DBGC_CFG_PERF_TRIG_CLUSTER_SP_VS_US 0x703 631: #define GEN8_DBGC_CFG_PERF_TRIG_CLUSTER_SP_PS_US 0x704 632: #define GEN8_DBGC_CFG_PERF_TRIG_CLUSTER_NONE_US 0x707 633: #define GEN8_DBGC_CFG_BV_PERF_TRIG_CLUSTER_FE_US 0x708 634: #define GEN8_DBGC_CFG_BV_PERF_TRIG_CLUSTER_VPC_US 0x709 635: #define GEN8_DBGC_CFG_BV_PERF_TRIG_CLUSTER_SP_VS_US 0x70a 636: #define GEN8_DBGC_CFG_BV_PERF_TRIG_CLUSTER_NONE_US 0x70f 637: #define GEN8_DBGC_CFG_PERF_COUNTER_SEL_FE_US 0x710 638: #define GEN8_DBGC_CFG_PERF_COUNTER_SEL_FE_US_1 0x711 639: #define GEN8_DBGC_CFG_PERF_COUNTER_SEL_FE_US_2 0x712 MATCH LINES: 780 768: #define GEN8_CP_RB_WPTR_GC 0x807 769: #define GEN8_CP_RB_RPTR_ADDR_LO_BV 0x808 770: #define GEN8_CP_RB_RPTR_ADDR_HI_BV 0x809 771: #define GEN8_CP_RB_RPTR_BV 0x80a 772: #define GEN8_CP_RB_BASE_LO_LPAC 0x80b 773: #define GEN8_CP_RB_BASE_HI_LPAC 0x80c 774: #define GEN8_CP_RB_CNTL_LPAC 0x80d 775: #define GEN8_CP_RB_RPTR_WR_LPAC 0x80e 776: #define GEN8_CP_RB_RPTR_ADDR_LO_LPAC 0x80f 777: #define GEN8_CP_RB_RPTR_ADDR_HI_LPAC 0x810 778: #define GEN8_CP_RB_RPTR_LPAC 0x811 779: #define GEN8_CP_RB_WPTR_LPAC 0x812 780: #define GEN8_CP_SMMU_STREAM_ID_LPAC 0x814 781: #define GEN8_CP_SQE_CNTL 0x815 782: #define GEN8_CP_SQE_INSTR_BASE_LO 0x816 783: #define GEN8_CP_SQE_INSTR_BASE_HI 0x817 784: #define GEN8_CP_AQE_INSTR_BASE_LO_0 0x818 785: #define GEN8_CP_AQE_INSTR_BASE_HI_0 0x819 786: #define GEN8_CP_AQE_INSTR_BASE_LO_1 0x81a 787: #define GEN8_CP_AQE_INSTR_BASE_HI_1 0x81b 788: #define GEN8_CP_APERTURE_CNTL_HOST 0x81c 789: #define GEN8_CP_APERTURE_CNTL_GMU 0x81d 790: #define GEN8_CP_APERTURE_CNTL_CD 0x81e 791: #define GEN8_CP_CP2GMU_STATUS 0x822 792: #define GEN8_CP_SEMAPHORE_REG_0 0x825 793: #define GEN8_CP_RL_ERROR_DETAILS_0 0x840 794: #define GEN8_CP_RL_ERROR_DETAILS_1 0x841 795: #define GEN8_CP_CRASH_DUMP_SCRIPT_BASE_LO 0x842 796: #define GEN8_CP_CRASH_DUMP_SCRIPT_BASE_HI 0x843 797: #define GEN8_CP_CRASH_DUMP_CNTL 0x844 798: #define GEN8_CP_CRASH_DUMP_STATUS 0x845 799: #define GEN8_CP_MULTIDRAW_CNTL 0x84a 800: #define GEN8_CP_DBG_ECO_CNTL 0x84b 801: #define GEN8_CP_MISC_CNTL 0x84c 802: #define GEN8_CP_APRIV_CNTL_PIPE 0x84d 803: #define GEN8_CP_PROTECT_CNTL_PIPE 0x84e 804: #define GEN8_CP_PROTECT_STATUS_PIPE 0x84f MATCH LINES: 821, 822 809: #define GEN8_CP_SQE_DCACHE_CNTL_PIPE 0x8b1 810: #define GEN8_CP_CHICKEN_DBG_PIPE 0x8b2 811: #define GEN8_CP_HW_FAULT_STATUS_PIPE 0x8b3 812: #define GEN8_CP_HW_FAULT_STATUS_MASK_PIPE 0x8b4 813: #define GEN8_CP_INTERRUPT_STATUS_GLOBAL 0x8b5 814: #define GEN8_CP_INTERRUPT_STATUS_MASK_GLOBAL 0x8b6 815: #define GEN8_CP_INTERRUPT_STATUS_PIPE 0x8b7 816: #define GEN8_CP_INTERRUPT_STATUS_MASK_PIPE 0x8b8 817: #define GEN8_CP_PIPE_STATUS_PIPE 0x8b9 818: #define GEN8_CP_GPU_BATCH_ID_PIPE 0x8ba 819: #define GEN8_CP_SQE_STATUS_PIPE 0x8bb 820: #define GEN8_CP_CONTEXT_SWITCH_CNTL 0x8c0 821: #define GEN8_CP_CONTEXT_SWITCH_SMMU_INFO_LO 0x8c1 822: #define GEN8_CP_CONTEXT_SWITCH_SMMU_INFO_HI 0x8c2 823: #define GEN8_CP_CONTEXT_SWITCH_PNSR_ADDR_LO 0x8c3 824: #define GEN8_CP_CONTEXT_SWITCH_PNSR_ADDR_HI 0x8c4 825: #define GEN8_CP_CONTEXT_SWITCH_PSR_ADDR_LO 0x8c5 826: #define GEN8_CP_CONTEXT_SWITCH_PSR_ADDR_HI 0x8c6 827: #define GEN8_CP_CONTEXT_SWITCH_NPR_ADDR_LO 0x8c7 828: #define GEN8_CP_CONTEXT_SWITCH_NPR_ADDR_HI 0x8c8 829: #define GEN8_CP_CONTEXT_SWITCH_LEVEL_STATUS 0x8cb 830: #define GEN8_CP_PERFCTR_CP_SEL_0 0x8d0 831: #define GEN8_CP_PERFCTR_CP_SEL_1 0x8d1 832: #define GEN8_CP_PERFCTR_CP_SEL_2 0x8d2 833: #define GEN8_CP_PERFCTR_CP_SEL_3 0x8d3 834: #define GEN8_CP_PERFCTR_CP_SEL_4 0x8d4 835: #define GEN8_CP_PERFCTR_CP_SEL_5 0x8d5 836: #define GEN8_CP_PERFCTR_CP_SEL_6 0x8d6 837: #define GEN8_CP_PERFCTR_CP_SEL_7 0x8d7 838: #define GEN8_CP_PERFCTR_CP_SEL_8 0x8d8 839: #define GEN8_CP_PERFCTR_CP_SEL_9 0x8d9 840: #define GEN8_CP_PERFCTR_CP_SEL_10 0x8da 841: #define GEN8_CP_PERFCTR_CP_SEL_11 0x8db 842: #define GEN8_CP_PERFCTR_CP_SEL_12 0x8dc 843: #define GEN8_CP_PERFCTR_CP_SEL_13 0x8dd 844: #define GEN8_CP_PERFCTR_CP_SEL_14 0x8de 845: #define GEN8_CP_PERFCTR_CP_SEL_15 0x8df 846: #define GEN8_CP_PERFCTR_CP_SEL_16 0x8e0 MATCH LINES: 1663, 1669, 1674, 1675 1651: #define GEN8_RSCC_SEQ_BUSY_DRV0 0x00101 1652: #define GEN8_RSCC_TCS0_DRV0_STATUS 0x0034a 1653: #define GEN8_RSCC_TCS1_DRV0_STATUS 0x003f2 1654: #define GEN8_RSCC_TCS2_DRV0_STATUS 0x0049a 1655: #define GEN8_RSCC_TCS3_DRV0_STATUS 0x00542 1656: #define GEN8_RSCC_TCS4_DRV0_STATUS 0x005ea 1657: #define GEN8_RSCC_TCS5_DRV0_STATUS 0x00692 1658: #define GEN8_RSCC_TCS6_DRV0_STATUS 0x0073a 1659: #define GEN8_RSCC_TCS7_DRV0_STATUS 0x007e2 1660: #define GEN8_RSCC_TCS8_DRV0_STATUS 0x0088a 1661: #define GEN8_RSCC_TCS9_DRV0_STATUS 0x00932 1662: 1663: #define GEN8_SMMU_BASE 0x28000 1664: 1665: /* GPU CX_MISC registers */ 1666: #define GEN8_GPU_CX_MISC_CX_AHB_AON_CNTL 0x27810 1667: #define GEN8_GPU_CX_MISC_CX_AHB_GMU_CNTL 0x27811 1668: #define GEN8_GPU_CX_MISC_CX_AHB_CP_CNTL 0x27812 1669: #define GEN8_GPU_CX_MISC_CX_AHB_VBIF_SMMU_CNTL 0x27813 1670: #define GEN8_GPU_CX_MISC_CX_AHB_HOST_CNTL 0x27814 1671: #define GEN8_GPU_CX_MISC_INT_CLEAR_CMD 0x27831 1672: #define GEN8_GPU_CX_MISC_INT_0_MASK 0x27833 1673: #define GEN8_GPU_CX_MISC_INT_0_STATUS 0x27834 1674: #define GEN8_GPU_CX_MISC_SMMU_INTR_MASK0 0x27846 1675: #define GEN8_GPU_CX_MISC_SMMU_INTR_MASK1 0x27847 1676: #define GEN8_GPU_CX_MISC_AO_COUNTER_LO 0x27880 1677: #define GEN8_GPU_CX_MISC_AO_COUNTER_HI 0x27881 1678: #define GEN8_GPU_CX_MISC_GFX_PWR_CLK_STATUS 0x27883 1679: #define GEN8_GPU_CX_MISC_SLICE_ENABLE_TEST 0x27886 1680: #define GEN8_GPU_CX_MISC_SLICE_ENABLE_FINAL 0x27887 1681: #define GEN8_GPU_CX_MISC_SW_FUSE_VALUE 0x27c00 1682: #define GEN8_GPU_CX_MISC_SW_FUSE_FREQ_LIMIT_STATUS 0x27c05 1683: 1684: /* GPU SW Fuse Feature bit fields */ 1685: #define GEN8_FASTBLEND_SW_FUSE 0 1686: #define GEN8_LPAC_SW_FUSE 1 1687: #define GEN8_RAYTRACING_SW_FUSE 2 1688: #define GEN8_MALU_SW_FUSE 3 1689: 1690: #define GEN8_SW_FUSE_INT_MASK \ 1691: ((1 << GEN8_FASTBLEND_SW_FUSE) | \ 1692: (1 << GEN8_LPAC_SW_FUSE) | \ 1693: (1 << GEN8_RAYTRACING_SW_FUSE)) 1694: 1695: /* QDSS register offsets */ 1696: #define QDSS_AOSS_APB_TMC_RSZ 0x04 1697: #define QDSS_AOSS_APB_TMC_RRD 0x10 1698: #define QDSS_AOSS_APB_TMC_RRP 0x14 1699: #define QDSS_AOSS_APB_TMC_RWP 0x18 --- FILE: \kgsl.c | HITS: 79 --- MATCH LINES: 85, 86, 88, 90 73: struct list_head dmabuf_list; 74: }; 75: 76: struct kgsl_dma_buf_meta { 77: struct kgsl_mem_entry *entry; 78: struct dma_buf_attachment *attach; 79: struct dma_buf *dmabuf; 80: struct sg_table *table; 81: struct dmabuf_list_entry *dle; 82: struct list_head node; 83: }; 84: 85: static inline struct kgsl_pagetable *_get_memdesc_pagetable( 86: struct kgsl_pagetable *pt, struct kgsl_mem_entry *entry) 87: { 88: /* if a secured buffer, map it to secure global pagetable */ 89: if (kgsl_memdesc_is_secured(&entry->memdesc)) 90: return pt->mmu->securepagetable; 91: 92: return pt; 93: } 94: 95: static void kgsl_mem_entry_detach_process(struct kgsl_mem_entry *entry); 96: 97: static const struct vm_operations_struct kgsl_gpumem_vm_ops; 98: 99: #if (KERNEL_VERSION(6, 10, 0) > LINUX_VERSION_CODE) 100: static unsigned long kgsl_mm_get_unmapped_area(struct mm_struct *mm, struct file *file, 101: unsigned long addr, unsigned long len, 102: unsigned long pgoff, unsigned long flags) 103: { 104: return mm->get_unmapped_area(file, addr, len, pgoff, flags); 105: } 106: #elif (KERNEL_VERSION(6, 19, 0) > LINUX_VERSION_CODE) 107: static unsigned long kgsl_mm_get_unmapped_area(struct mm_struct *mm, struct file *file, 108: unsigned long addr, unsigned long len, 109: unsigned long pgoff, unsigned long flags) 110: { 111: return mm_get_unmapped_area(mm, file, addr, len, pgoff, flags); 112: } 113: #else 114: static unsigned long kgsl_mm_get_unmapped_area(struct mm_struct *mm, struct file *file, MATCH LINES: 192, 195 180: } 181: 182: ptr = ptr - 1; 183: 184: if (ptr < 0) 185: ptr = MEMFREE_ENTRIES - 1; 186: } 187: 188: spin_unlock(&memfree_lock); 189: return 0; 190: } 191: 192: static void kgsl_memfree_purge(struct kgsl_pagetable *pagetable, 193: uint64_t gpuaddr, uint64_t size) 194: { 195: pid_t ptname = pagetable ? pagetable->name : 0; 196: int i; 197: 198: if (memfree.list == NULL) 199: return; 200: 201: spin_lock(&memfree_lock); 202: 203: for (i = 0; i < MEMFREE_ENTRIES; i++) { 204: struct memfree_entry *entry = &memfree.list[i]; 205: 206: if (entry->ptname != ptname || entry->size == 0) 207: continue; 208: 209: if (gpuaddr > entry->gpuaddr && 210: gpuaddr < entry->gpuaddr + entry->size) { 211: /* truncate the end of the entry */ 212: entry->size = gpuaddr - entry->gpuaddr; 213: } else if (gpuaddr <= entry->gpuaddr) { 214: if (gpuaddr + size > entry->gpuaddr && 215: gpuaddr + size < entry->gpuaddr + entry->size) 216: /* Truncate the beginning of the entry */ 217: entry->gpuaddr = gpuaddr + size; 218: else if (gpuaddr + size >= entry->gpuaddr + entry->size) 219: /* Remove the entire entry */ MATCH LINES: 514, 516, 517, 519, 535, 567, 575 502: struct kgsl_mem_entry *entry) 503: { 504: struct kgsl_memdesc *memdesc = &entry->memdesc; 505: int ret, id; 506: 507: ret = kgsl_process_private_get(process); 508: if (!ret) 509: return -EBADF; 510: 511: /* Assign a gpu address */ 512: if (!kgsl_memdesc_use_cpu_map(memdesc) && 513: kgsl_mmu_get_mmutype(device) != KGSL_MMU_TYPE_NONE) { 514: struct kgsl_pagetable *pagetable; 515: 516: pagetable = kgsl_memdesc_is_secured(memdesc) ? 517: device->mmu.securepagetable : process->pagetable; 518: 519: ret = kgsl_mmu_get_gpuaddr(pagetable, memdesc); 520: if (ret) { 521: kgsl_process_private_put(process); 522: return ret; 523: } 524: } 525: 526: idr_preload(GFP_KERNEL); 527: spin_lock(&process->mem_lock); 528: /* Allocate the ID but don't attach the pointer just yet */ 529: id = idr_alloc(&process->mem_idr, NULL, 1, 0, GFP_NOWAIT); 530: spin_unlock(&process->mem_lock); 531: idr_preload_end(); 532: 533: if (id < 0) { 534: if (!kgsl_memdesc_use_cpu_map(memdesc)) 535: kgsl_mmu_put_gpuaddr(memdesc->pagetable, memdesc); 536: kgsl_process_private_put(process); 537: return id; 538: } 539: 540: entry->id = id; 541: entry->priv = process; 542: 543: return 0; 544: } 545: 546: /* 547: * Attach the memory object to a process by (possibly) getting a GPU address and 548: * (possibly) mapping it 549: */ 550: static int kgsl_mem_entry_attach_and_map(struct kgsl_device *device, 551: struct kgsl_process_private *process, 552: struct kgsl_mem_entry *entry) 553: { 554: struct kgsl_memdesc *memdesc = &entry->memdesc; 555: int ret; 556: 557: ret = kgsl_mem_entry_attach_to_process(device, process, entry); 558: if (ret) 559: return ret; 560: 561: if (memdesc->gpuaddr) { 562: /* 563: * Map the memory if a GPU address is already assigned, either 564: * through kgsl_mem_entry_attach_to_process() or via some other 565: * SVM process 566: */ 567: ret = kgsl_mmu_map(memdesc->pagetable, memdesc); 568: 569: if (ret) { 570: kgsl_mem_entry_detach_process(entry); 571: return ret; 572: } 573: } 574: 575: kgsl_memfree_purge(memdesc->pagetable, memdesc->gpuaddr, 576: memdesc->size); 577: 578: return ret; 579: } 580: 581: /* Detach a memory entry from a process and unmap it from the MMU */ 582: static void kgsl_mem_entry_detach_process(struct kgsl_mem_entry *entry) 583: { 584: if (entry == NULL) 585: return; 586: 587: /* 588: * First remove the entry from mem_idr list 589: * so that no one can operate on obsolete values 590: */ 591: spin_lock(&entry->priv->mem_lock); 592: if (entry->id != 0) 593: idr_remove(&entry->priv->mem_idr, entry->id); 594: entry->id = 0; 595: 596: spin_unlock(&entry->priv->mem_lock); 597: 598: kgsl_sharedmem_put_gpuaddr(&entry->memdesc); 599: MATCH LINES: 764 752: } 753: atomic_dec(&proc_priv->ctxt_count); 754: return id; 755: } 756: 757: context->id = id; 758: 759: mutex_init(&context->fault_lock); 760: INIT_LIST_HEAD(&context->faults); 761: kref_init(&context->refcount); 762: /* 763: * Get a refernce to the process private so its not destroyed, until 764: * the context is destroyed. This will also prevent the pagetable 765: * from being destroyed 766: */ 767: if (!kgsl_process_private_get(proc_priv)) { 768: ret = -EBADF; 769: goto out; 770: } 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); MATCH LINES: 985, 1000, 1001, 1002, 1016, 1017, 1018, 1023 973: * kgsl_destroy_process_private() - Cleanup function to free process private 974: * @kref: - Pointer to object being destroyed's kref struct 975: * Free struct object and all other resources attached to it. 976: * Since the function can be used when not all resources inside process 977: * private have been allocated, there is a check to (before each resource 978: * cleanup) see if the struct member being cleaned is in fact allocated or not. 979: * If the value is not NULL, resource is freed. 980: */ 981: static void kgsl_destroy_process_private(struct kref *kref) 982: { 983: struct kgsl_process_private *private = container_of(kref, 984: struct kgsl_process_private, refcount); 985: struct kgsl_device *device = KGSL_MMU_DEVICE(private->pagetable->mmu); 986: 987: kgsl_put_work_period(private->period); 988: /* 989: * While removing sysfs entries, kernfs_mutex is held by sysfs apis. Since 990: * it is a global fs mutex, sometimes it takes longer for kgsl to get hold 991: * of the lock. Meanwhile, kgsl open thread may exhaust all its re-tries 992: * and open can fail. To avoid this, remove sysfs entries inside process 993: * mutex to avoid wasting re-tries when kgsl is waiting for kernfs mutex. 994: */ 995: mutex_lock(&kgsl_driver.process_mutex); 996: debugfs_remove_recursive(private->debug_root); 997: kobject_put(&private->kobj_memtype); 998: kobject_put(&private->kobj); 999: 1000: /* When using global pagetables, do not detach global pagetable */ 1001: if (private->pagetable->name != KGSL_MMU_GLOBAL_PT) 1002: kgsl_mmu_detach_pagetable(private->pagetable); 1003: 1004: /* Remove the process struct from the master list */ 1005: write_lock(&kgsl_driver.proclist_lock); 1006: list_del(&private->list); 1007: write_unlock(&kgsl_driver.proclist_lock); 1008: mutex_unlock(&kgsl_driver.process_mutex); 1009: 1010: kfree(private->cmdline); 1011: put_pid(private->pid); 1012: mmdrop(private->mm); 1013: idr_destroy(&private->mem_idr); 1014: idr_destroy(&private->syncsource_idr); 1015: 1016: /* When using global pagetables, do not put global pagetable */ 1017: if (private->pagetable->name != KGSL_MMU_GLOBAL_PT) 1018: kgsl_mmu_putpagetable(private->pagetable); 1019: 1020: 1021: if (private->profile.md.gmuaddr) { 1022: /* 1023: * This calls iommu_unmap(), which may take variable amount of time to 1024: * complete. So do this at the very end of process private cleanup, so that 1025: * this doesn't delay the clean up of rest of the process private resources. 1026: */ 1027: gmu_core_free_block(device, &private->profile.md); 1028: } 1029: 1030: kfree(private); 1031: } 1032: 1033: void 1034: kgsl_process_private_put(struct kgsl_process_private *private) 1035: { 1036: if (private) 1037: kref_put(&private->refcount, kgsl_destroy_process_private); 1038: } 1039: 1040: /** 1041: * kgsl_process_private_find() - Find the process associated with the specified 1042: * name 1043: * @name: pid_t of the process to search for 1044: * Return the process struct for the given ID. 1045: */ 1046: struct kgsl_process_private *kgsl_process_private_find(pid_t pid) 1047: { MATCH LINES: 1254, 1255, 1256, 1257 1242: private->cmdline = kstrdup_quotable_cmdline(current, GFP_KERNEL); 1243: 1244: spin_lock_init(&private->mem_lock); 1245: spin_lock_init(&private->syncsource_lock); 1246: spin_lock_init(&private->ctxt_count_lock); 1247: mutex_init(&private->private_mutex); 1248: 1249: idr_init(&private->mem_idr); 1250: idr_init(&private->syncsource_idr); 1251: 1252: kgsl_reclaim_proc_private_init(private); 1253: 1254: /* Allocate a pagetable for the new process object */ 1255: private->pagetable = kgsl_mmu_getpagetable(&device->mmu, pid_nr(cur_pid)); 1256: if (IS_ERR(private->pagetable)) { 1257: int err = PTR_ERR(private->pagetable); 1258: 1259: kgsl_put_work_period(private->period); 1260: idr_destroy(&private->mem_idr); 1261: idr_destroy(&private->syncsource_idr); 1262: put_pid(private->pid); 1263: mmdrop(private->mm); 1264: 1265: kfree(private); 1266: private = ERR_PTR(err); 1267: return private; 1268: } 1269: 1270: /* Allocate profile memory for gmu based DCVS targets */ 1271: device->ftbl->alloc_dcvs_profile_memory(device, private); 1272: mutex_init(&private->profile.profile_mutex); 1273: kgsl_process_init_sysfs(device, private); 1274: kgsl_process_init_debugfs(private); 1275: write_lock(&kgsl_driver.proclist_lock); 1276: list_add(&private->list, &kgsl_driver.process_list); 1277: write_unlock(&kgsl_driver.proclist_lock); 1278: 1279: return private; 1280: } 1281: MATCH LINES: 1552, 1553 1540: goto err; 1541: } 1542: 1543: dev_priv->device = device; 1544: filep->private_data = dev_priv; 1545: 1546: result = kgsl_open_device(device); 1547: if (result) 1548: goto err; 1549: 1550: /* 1551: * Get file (per process) private struct. This must be done 1552: * after the first start so that the global pagetable mappings 1553: * are set up before we create the per-process pagetable. 1554: */ 1555: dev_priv->process_priv = kgsl_process_private_open(device); 1556: if (IS_ERR(dev_priv->process_priv)) { 1557: result = PTR_ERR(dev_priv->process_priv); 1558: kgsl_close_device(device); 1559: goto err; 1560: } 1561: 1562: err: 1563: if (result) { 1564: filep->private_data = NULL; 1565: kfree(dev_priv); 1566: pm_runtime_put(&device->pdev->dev); 1567: } 1568: return result; 1569: } 1570: 1571: #define GPUADDR_IN_MEMDESC(_val, _memdesc) \ 1572: (((_val) >= (_memdesc)->gpuaddr) && \ 1573: ((_val) < ((_memdesc)->gpuaddr + (_memdesc)->size))) 1574: 1575: /** 1576: * kgsl_sharedmem_find() - Find a gpu memory allocation 1577: * MATCH LINES: 1593, 1595 1581: * Find a gpu allocation. Caller must kgsl_mem_entry_put() 1582: * the returned entry when finished using it. 1583: */ 1584: struct kgsl_mem_entry * __must_check 1585: kgsl_sharedmem_find(struct kgsl_process_private *private, uint64_t gpuaddr) 1586: { 1587: int id; 1588: struct kgsl_mem_entry *entry, *ret = NULL; 1589: 1590: if (!private) 1591: return NULL; 1592: 1593: if (!kgsl_mmu_gpuaddr_in_range(private->pagetable, gpuaddr, 0) && 1594: !kgsl_mmu_gpuaddr_in_range( 1595: private->pagetable->mmu->securepagetable, gpuaddr, 0)) 1596: return NULL; 1597: 1598: spin_lock(&private->mem_lock); 1599: idr_for_each_entry(&private->mem_idr, entry, id) { 1600: if (GPUADDR_IN_MEMDESC(gpuaddr, &entry->memdesc)) { 1601: if (!entry->pending_free) 1602: ret = kgsl_mem_entry_get(entry); 1603: break; 1604: } 1605: } 1606: spin_unlock(&private->mem_lock); 1607: 1608: return ret; 1609: } 1610: 1611: static struct kgsl_mem_entry * __must_check 1612: kgsl_sharedmem_find_id_flags(struct kgsl_process_private *process, 1613: unsigned int id, uint64_t flags) 1614: { 1615: struct kgsl_mem_entry *entry, *ret = NULL; 1616: 1617: spin_lock(&process->mem_lock); 1618: entry = idr_find(&process->mem_idr, id); 1619: if (entry) MATCH LINES: 1943, 1957 1931: return -EOPNOTSUPP; 1932: } 1933: 1934: if (copy_to_user(param->value, &caps, copy)) 1935: return -EFAULT; 1936: 1937: return ret; 1938: } 1939: 1940: static long kgsl_get_gpu_va64_size(struct kgsl_device_private *dev_priv, 1941: struct kgsl_device_getproperty *param) 1942: { 1943: u64 va_size = KGSL_IOMMU_VA_END64 - KGSL_IOMMU_VA_BASE64; 1944: 1945: if (param->sizebytes != sizeof(va_size)) 1946: return -EINVAL; 1947: 1948: if (copy_to_user(param->value, &va_size, sizeof(va_size))) 1949: return -EFAULT; 1950: 1951: return 0; 1952: } 1953: 1954: static long kgsl_get_gpu_secure_va_size(struct kgsl_device_private *dev_priv, 1955: struct kgsl_device_getproperty *param) 1956: { 1957: u64 size = KGSL_IOMMU_SECURE_SIZE(&dev_priv->device->mmu); 1958: 1959: if (param->sizebytes != sizeof(size)) 1960: return -EINVAL; 1961: 1962: if (copy_to_user(param->value, &size, sizeof(size))) 1963: return -EFAULT; 1964: 1965: return 0; 1966: } 1967: 1968: static long kgsl_get_gpu_secure_va_inuse(struct kgsl_device_private *dev_priv, 1969: struct kgsl_device_getproperty *param) 1970: { 1971: u64 val; 1972: 1973: if (param->sizebytes != sizeof(val)) 1974: return -EINVAL; 1975: 1976: val = atomic_long_read(&kgsl_driver.stats.secure); 1977: 1978: if (copy_to_user(param->value, &val, sizeof(val))) 1979: return -EFAULT; 1980: 1981: return 0; MATCH LINES: 2701, 2702, 2724, 2725 2689: kgsl_context_put(context); 2690: 2691: return 0; 2692: } 2693: 2694: long gpumem_free_entry(struct kgsl_mem_entry *entry) 2695: { 2696: if (!kgsl_mem_entry_set_pend(entry)) 2697: return -EBUSY; 2698: 2699: trace_kgsl_mem_free(entry); 2700: kgsl_memfree_add(pid_nr(entry->priv->pid), 2701: entry->memdesc.pagetable ? 2702: entry->memdesc.pagetable->name : 0, 2703: entry->memdesc.gpuaddr, entry->memdesc.size, 2704: entry->memdesc.flags); 2705: 2706: kgsl_mem_entry_put(entry); 2707: 2708: return 0; 2709: } 2710: 2711: static void gpumem_free_func(struct kgsl_device *device, 2712: struct kgsl_event_group *group, void *priv, int ret) 2713: { 2714: struct kgsl_context *context = group->context; 2715: struct kgsl_mem_entry *entry = priv; 2716: unsigned int timestamp; 2717: 2718: kgsl_readtimestamp(device, context, KGSL_TIMESTAMP_RETIRED, ×tamp); 2719: 2720: /* Free the memory for all event types */ 2721: trace_kgsl_mem_timestamp_free(device, entry, KGSL_CONTEXT_ID(context), 2722: timestamp, 0); 2723: kgsl_memfree_add(pid_nr(entry->priv->pid), 2724: entry->memdesc.pagetable ? 2725: entry->memdesc.pagetable->name : 0, 2726: entry->memdesc.gpuaddr, entry->memdesc.size, 2727: entry->memdesc.flags); 2728: 2729: kgsl_mem_entry_put_deferred(entry); 2730: } 2731: 2732: static long gpumem_free_entry_on_timestamp(struct kgsl_device *device, 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); MATCH LINES: 2821, 2822 2809: event.timestamp); 2810: 2811: kgsl_context_put(context); 2812: return ret; 2813: } 2814: 2815: static bool gpuobj_free_fence_func(void *priv) 2816: { 2817: struct kgsl_mem_entry *entry = priv; 2818: 2819: trace_kgsl_mem_free(entry); 2820: kgsl_memfree_add(pid_nr(entry->priv->pid), 2821: entry->memdesc.pagetable ? 2822: entry->memdesc.pagetable->name : 0, 2823: entry->memdesc.gpuaddr, entry->memdesc.size, 2824: entry->memdesc.flags); 2825: 2826: kgsl_mem_entry_put_deferred(entry); 2827: return true; 2828: } 2829: 2830: static long gpuobj_free_on_fence(struct kgsl_device_private *dev_priv, 2831: struct kgsl_mem_entry *entry, struct kgsl_gpuobj_free *param) 2832: { 2833: struct kgsl_sync_fence_cb *handle; 2834: struct kgsl_gpu_event_fence event; 2835: 2836: if (!kgsl_mem_entry_set_pend(entry)) 2837: return -EBUSY; 2838: 2839: if (copy_struct_from_user(&event, sizeof(event), 2840: u64_to_user_ptr(param->priv), param->len)) { 2841: kgsl_mem_entry_unset_pend(entry); 2842: return -EFAULT; 2843: } 2844: 2845: if (event.fd < 0) { 2846: kgsl_mem_entry_unset_pend(entry); MATCH LINES: 3061, 3072, 3080, 3086, 3099, 3105, 3112, 3117, 3144, 3159, 3164 3049: kfree(memdesc->sgt); 3050: memdesc->sgt = NULL; 3051: } 3052: kvfree(pages); 3053: return ret; 3054: } 3055: 3056: static const struct kgsl_memdesc_ops kgsl_usermem_ops = { 3057: .free = kgsl_destroy_anon, 3058: .put_gpuaddr = kgsl_unmap_and_put_gpuaddr, 3059: }; 3060: 3061: static int kgsl_setup_anon_useraddr(struct kgsl_device *device, struct kgsl_pagetable *pagetable, 3062: struct kgsl_mem_entry *entry, unsigned long hostptr, size_t offset, size_t size) 3063: { 3064: /* Map an anonymous memory chunk */ 3065: 3066: int ret; 3067: 3068: if (size == 0 || offset != 0 || 3069: !IS_ALIGNED(size, PAGE_SIZE)) 3070: return -EINVAL; 3071: 3072: entry->memdesc.pagetable = pagetable; 3073: entry->memdesc.size = (uint64_t) size; 3074: entry->memdesc.flags |= (uint64_t)KGSL_MEMFLAGS_USERMEM_ADDR; 3075: entry->memdesc.ops = &kgsl_usermem_ops; 3076: 3077: if (kgsl_memdesc_use_cpu_map(&entry->memdesc)) { 3078: 3079: /* Register the address in the database */ 3080: ret = kgsl_mmu_set_svm_region(pagetable, 3081: (uint64_t) hostptr, (uint64_t) size); 3082: 3083: /* if OOM, retry once after flushing lockless_workqueue */ 3084: if (ret == -ENOMEM) { 3085: flush_workqueue(kgsl_driver.lockless_workqueue); 3086: ret = kgsl_mmu_set_svm_region(pagetable, 3087: (uint64_t) hostptr, (uint64_t) size); 3088: } 3089: 3090: if (ret) 3091: return ret; 3092: 3093: entry->memdesc.gpuaddr = (uint64_t) hostptr; 3094: } 3095: 3096: ret = memdesc_sg_virt(device, &entry->memdesc, hostptr); 3097: 3098: if (ret && kgsl_memdesc_use_cpu_map(&entry->memdesc)) 3099: kgsl_mmu_put_gpuaddr(pagetable, &entry->memdesc); 3100: 3101: return ret; 3102: } 3103: 3104: static int kgsl_setup_useraddr(struct kgsl_device *device, 3105: struct kgsl_pagetable *pagetable, 3106: struct kgsl_mem_entry *entry, 3107: unsigned long hostptr, size_t offset, size_t size) 3108: { 3109: if (hostptr == 0 || !IS_ALIGNED(hostptr, PAGE_SIZE)) 3110: return -EINVAL; 3111: 3112: return kgsl_setup_anon_useraddr(device, pagetable, entry, 3113: hostptr, offset, size); 3114: } 3115: 3116: static long _gpuobj_map_useraddr(struct kgsl_device *device, 3117: struct kgsl_pagetable *pagetable, 3118: struct kgsl_mem_entry *entry, 3119: struct kgsl_gpuobj_import *param) 3120: { 3121: struct kgsl_gpuobj_import_useraddr useraddr; 3122: 3123: param->flags &= KGSL_MEMFLAGS_GPUREADONLY 3124: | KGSL_CACHEMODE_MASK 3125: | KGSL_MEMFLAGS_USE_CPU_MAP 3126: | KGSL_MEMTYPE_MASK 3127: | KGSL_MEMFLAGS_FORCE_32BIT 3128: | KGSL_MEMFLAGS_IOCOHERENT; 3129: 3130: /* Specifying SECURE is an explicit error */ 3131: if (param->flags & KGSL_MEMFLAGS_SECURE) 3132: return -ENOTSUPP; 3133: 3134: kgsl_memdesc_init(device, &entry->memdesc, param->flags); 3135: 3136: if (copy_from_user(&useraddr, 3137: u64_to_user_ptr(param->priv), sizeof(useraddr))) 3138: return -EINVAL; 3139: 3140: /* Verify that the virtaddr and len are within bounds */ 3141: if (useraddr.virtaddr > ULONG_MAX) 3142: return -EINVAL; 3143: 3144: return kgsl_setup_useraddr(device, pagetable, entry, 3145: (unsigned long) useraddr.virtaddr, 0, param->priv_len); 3146: } 3147: 3148: static bool check_and_warn_secured(struct kgsl_device *device) 3149: { 3150: if (kgsl_mmu_is_secured(&device->mmu)) 3151: return true; 3152: 3153: dev_WARN_ONCE(device->dev, 1, "Secure buffers are not supported\n"); 3154: return false; 3155: } 3156: 3157: #ifdef CONFIG_DMA_SHARED_BUFFER 3158: static int kgsl_setup_dma_buf(struct kgsl_device *device, 3159: struct kgsl_pagetable *pagetable, 3160: struct kgsl_mem_entry *entry, 3161: struct dma_buf *dmabuf); 3162: 3163: static long _gpuobj_map_dma_buf(struct kgsl_device *device, 3164: struct kgsl_pagetable *pagetable, 3165: struct kgsl_mem_entry *entry, 3166: struct kgsl_gpuobj_import *param, 3167: int *fd) 3168: { 3169: bool iocoherent = (param->flags & KGSL_MEMFLAGS_IOCOHERENT); 3170: struct kgsl_gpuobj_import_dma_buf buf; 3171: struct dma_buf *dmabuf; 3172: int ret; 3173: 3174: param->flags &= KGSL_MEMFLAGS_GPUREADONLY | 3175: KGSL_MEMTYPE_MASK | 3176: KGSL_MEMALIGN_MASK | 3177: KGSL_MEMFLAGS_SECURE | 3178: KGSL_MEMFLAGS_FORCE_32BIT | 3179: KGSL_MEMFLAGS_GUARD_PAGE; 3180: 3181: kgsl_memdesc_init(device, &entry->memdesc, param->flags); 3182: 3183: /* 3184: * If content protection is not enabled and secure buffer 3185: * is requested to be mapped return error. 3186: */ 3187: if (entry->memdesc.flags & KGSL_MEMFLAGS_SECURE) { 3188: if (!check_and_warn_secured(device)) MATCH LINES: 3223, 3231 3211: entry->memdesc.flags |= 3212: FIELD_PREP(KGSL_CACHEMODE_MASK, KGSL_CACHEMODE_WRITEBACK); 3213: 3214: /* 3215: * Enable I/O coherency if it is 1) a thing, and either 3216: * 2) enabled by default or 3) enabled by the caller 3217: */ 3218: if (kgsl_mmu_has_feature(device, KGSL_MMU_IO_COHERENT) && 3219: (IS_ENABLED(CONFIG_QCOM_KGSL_IOCOHERENCY_DEFAULT) || 3220: iocoherent)) 3221: entry->memdesc.flags |= KGSL_MEMFLAGS_IOCOHERENT; 3222: 3223: ret = kgsl_setup_dma_buf(device, pagetable, entry, dmabuf); 3224: if (ret) 3225: dma_buf_put(dmabuf); 3226: 3227: return ret; 3228: } 3229: #else 3230: static long _gpuobj_map_dma_buf(struct kgsl_device *device, 3231: struct kgsl_pagetable *pagetable, 3232: struct kgsl_mem_entry *entry, 3233: struct kgsl_gpuobj_import *param, 3234: int *fd) 3235: { 3236: return -EINVAL; 3237: } 3238: #endif 3239: 3240: static void kgsl_process_add_stats(struct kgsl_process_private *priv, 3241: unsigned int type, uint64_t size) 3242: { 3243: u64 ret = atomic64_add_return(size, &priv->stats[type].cur); 3244: 3245: if (ret > priv->stats[type].max) 3246: priv->stats[type].max = ret; 3247: } 3248: 3249: u64 kgsl_get_stats(pid_t pid) 3250: { 3251: struct kgsl_process_private *process; 3252: u64 ret; 3253: 3254: if (pid < 0) 3255: return atomic_long_read(&kgsl_driver.stats.page_alloc); MATCH LINES: 3289, 3292 3277: if (param->type != KGSL_USER_MEM_TYPE_ADDR && 3278: param->type != KGSL_USER_MEM_TYPE_DMABUF) 3279: return -ENOTSUPP; 3280: 3281: if (param->flags & KGSL_MEMFLAGS_VBO) 3282: return -EINVAL; 3283: 3284: entry = kgsl_mem_entry_create(); 3285: if (entry == NULL) 3286: return -ENOMEM; 3287: 3288: if (param->type == KGSL_USER_MEM_TYPE_ADDR) 3289: ret = _gpuobj_map_useraddr(device, private->pagetable, 3290: entry, param); 3291: else 3292: ret = _gpuobj_map_dma_buf(device, private->pagetable, 3293: entry, param, &fd); 3294: 3295: if (ret) 3296: goto out; 3297: 3298: if (entry->memdesc.size >= SZ_1M) 3299: kgsl_memdesc_set_align(&entry->memdesc, ilog2(SZ_1M)); 3300: else if (entry->memdesc.size >= SZ_64K) 3301: kgsl_memdesc_set_align(&entry->memdesc, ilog2(SZ_64K)); 3302: 3303: param->flags = entry->memdesc.flags; 3304: 3305: ret = kgsl_mem_entry_attach_and_map(device, private, entry); 3306: if (ret) 3307: goto unmap; 3308: 3309: param->id = entry->id; 3310: 3311: KGSL_STATS_ADD(entry->memdesc.size, &kgsl_driver.stats.mapped, 3312: &kgsl_driver.stats.mapped_max); 3313: 3314: kgsl_process_add_stats(private, 3315: kgsl_memdesc_usermem_type(&entry->memdesc), 3316: entry->memdesc.size); MATCH LINES: 3336, 3346, 3352, 3376, 3383 3324: 3325: return 0; 3326: 3327: unmap: 3328: kgsl_sharedmem_free(&entry->memdesc); 3329: 3330: out: 3331: kfree(entry); 3332: return ret; 3333: } 3334: 3335: static long _map_usermem_addr(struct kgsl_device *device, 3336: struct kgsl_pagetable *pagetable, struct kgsl_mem_entry *entry, 3337: unsigned long hostptr, size_t offset, size_t size) 3338: { 3339: if (!kgsl_mmu_has_feature(device, KGSL_MMU_PAGED)) 3340: return -EINVAL; 3341: 3342: /* No CPU mapped buffer could ever be secure */ 3343: if (entry->memdesc.flags & KGSL_MEMFLAGS_SECURE) 3344: return -EINVAL; 3345: 3346: return kgsl_setup_useraddr(device, pagetable, entry, hostptr, 3347: offset, size); 3348: } 3349: 3350: #ifdef CONFIG_DMA_SHARED_BUFFER 3351: static int _map_usermem_dma_buf(struct kgsl_device *device, 3352: struct kgsl_pagetable *pagetable, 3353: struct kgsl_mem_entry *entry, 3354: unsigned int fd) 3355: { 3356: int ret; 3357: struct dma_buf *dmabuf; 3358: 3359: /* 3360: * If content protection is not enabled and secure buffer 3361: * is requested to be mapped return error. 3362: */ 3363: 3364: if (entry->memdesc.flags & KGSL_MEMFLAGS_SECURE) { 3365: if (!check_and_warn_secured(device)) 3366: return -EOPNOTSUPP; 3367: 3368: SET_FLAG(KGSL_MEMDESC_SECURE, &entry->memdesc.priv); 3369: } 3370: 3371: dmabuf = dma_buf_get(fd); 3372: if (IS_ERR_OR_NULL(dmabuf)) { 3373: ret = PTR_ERR(dmabuf); 3374: return ret ? ret : -EINVAL; 3375: } 3376: ret = kgsl_setup_dma_buf(device, pagetable, entry, dmabuf); 3377: if (ret) 3378: dma_buf_put(dmabuf); 3379: return ret; 3380: } 3381: #else 3382: static int _map_usermem_dma_buf(struct kgsl_device *device, 3383: struct kgsl_pagetable *pagetable, 3384: struct kgsl_mem_entry *entry, 3385: unsigned int fd) 3386: { 3387: return -EINVAL; 3388: } 3389: #endif 3390: 3391: #ifdef CONFIG_DMA_SHARED_BUFFER 3392: static int verify_secure_access(struct kgsl_device *device, 3393: struct kgsl_mem_entry *entry, struct dma_buf *dmabuf) 3394: { 3395: bool secure = TEST_FLAG(KGSL_MEMDESC_SECURE, &entry->memdesc.priv); 3396: uint32_t *vmid_list = NULL, *perms_list = NULL; 3397: uint32_t nelems = 0; 3398: int i; 3399: 3400: if (mem_buf_dma_buf_copy_vmperm(dmabuf, (int **)&vmid_list, 3401: (int **)&perms_list, (int *)&nelems)) { 3402: dev_dbg(device->dev, "Skipped access check\n"); 3403: return 0; 3404: } 3405: 3406: /* Check if secure buffer is accessible to CP_PIXEL */ 3407: for (i = 0; i < nelems; i++) { MATCH LINES: 3430, 3466 3418: * accessible to secure GPU, it must be accessible to CP_PIXEL 3419: */ 3420: if (!(secure ^ (i == nelems))) 3421: return -EPERM; 3422: 3423: if (secure && mem_buf_dma_buf_exclusive_owner(dmabuf)) 3424: return -EPERM; 3425: 3426: return 0; 3427: } 3428: 3429: static int kgsl_setup_dma_buf(struct kgsl_device *device, 3430: struct kgsl_pagetable *pagetable, 3431: struct kgsl_mem_entry *entry, 3432: struct dma_buf *dmabuf) 3433: { 3434: int ret = 0; 3435: struct scatterlist *s; 3436: struct sg_table *sg_table = NULL; 3437: struct dma_buf_attachment *attach = NULL; 3438: struct kgsl_dma_buf_meta *metadata; 3439: 3440: metadata = kzalloc(sizeof(*metadata), GFP_KERNEL); 3441: if (!metadata) 3442: return -ENOMEM; 3443: 3444: attach = dma_buf_attach(dmabuf, device->dev); 3445: 3446: if (IS_ERR(attach)) { 3447: ret = PTR_ERR(attach); 3448: goto out; 3449: } 3450: 3451: #ifndef CONFIG_QCOM_KGSL_UPSTREAM 3452: /* 3453: * If dma buffer is marked IO coherent, skip sync at attach, 3454: * which involves flushing the buffer on CPU. 3455: * HW manages coherency for IO coherent buffers. 3456: */ 3457: if (entry->memdesc.flags & KGSL_MEMFLAGS_IOCOHERENT) 3458: attach->dma_map_attrs |= DMA_ATTR_SKIP_CPU_SYNC; 3459: #endif 3460: 3461: metadata->dmabuf = dmabuf; 3462: metadata->attach = attach; 3463: metadata->entry = entry; 3464: 3465: entry->priv_data = metadata; 3466: entry->memdesc.pagetable = pagetable; 3467: entry->memdesc.size = 0; 3468: entry->memdesc.ops = &kgsl_dmabuf_ops; 3469: /* USE_CPU_MAP is not impemented for ION. */ 3470: entry->memdesc.flags &= ~((uint64_t) KGSL_MEMFLAGS_USE_CPU_MAP); 3471: entry->memdesc.flags |= (uint64_t)KGSL_MEMFLAGS_USERMEM_ION; 3472: 3473: #if (KERNEL_VERSION(6, 2, 0) <= LINUX_VERSION_CODE) 3474: sg_table = dma_buf_map_attachment_unlocked(attach, DMA_BIDIRECTIONAL); 3475: #else 3476: sg_table = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL); 3477: #endif 3478: if (IS_ERR_OR_NULL(sg_table)) { 3479: ret = PTR_ERR(sg_table); 3480: goto out; 3481: } 3482: 3483: metadata->table = sg_table; 3484: entry->priv_data = metadata; 3485: entry->memdesc.sgt = sg_table; 3486: 3487: ret = verify_secure_access(device, entry, dmabuf); 3488: if (ret) 3489: goto out; 3490: MATCH LINES: 3624, 3632 3612: | KGSL_MEMALIGN_MASK 3613: | KGSL_MEMFLAGS_USE_CPU_MAP 3614: | KGSL_MEMFLAGS_SECURE 3615: | KGSL_MEMFLAGS_IOCOHERENT); 3616: 3617: if (is_compat_task()) 3618: flags |= KGSL_MEMFLAGS_FORCE_32BIT; 3619: 3620: kgsl_memdesc_init(device, &entry->memdesc, flags); 3621: 3622: switch (memtype) { 3623: case KGSL_MEM_ENTRY_USER: 3624: result = _map_usermem_addr(device, private->pagetable, 3625: entry, param->hostptr, param->offset, param->len); 3626: break; 3627: case KGSL_MEM_ENTRY_ION: 3628: if (param->offset != 0) 3629: result = -EINVAL; 3630: else 3631: result = _map_usermem_dma_buf(device, 3632: private->pagetable, entry, param->fd); 3633: break; 3634: default: 3635: result = -EOPNOTSUPP; 3636: break; 3637: } 3638: 3639: if (result) 3640: goto error; 3641: 3642: if (entry->memdesc.size >= SZ_2M) 3643: kgsl_memdesc_set_align(&entry->memdesc, ilog2(SZ_2M)); 3644: else if (entry->memdesc.size >= SZ_1M) 3645: kgsl_memdesc_set_align(&entry->memdesc, ilog2(SZ_1M)); 3646: else if (entry->memdesc.size >= SZ_64K) 3647: kgsl_memdesc_set_align(&entry->memdesc, ilog2(SZ_64)); 3648: 3649: /* echo back flags */ 3650: param->flags = (unsigned int) entry->memdesc.flags; 3651: 3652: result = kgsl_mem_entry_attach_and_map(device, private, 3653: entry); 3654: if (result) 3655: goto error_attach; 3656: MATCH LINES: 4188, 4204, 4226, 4254 4176: if (align >= ilog2(KGSL_MAX_ALIGN)) { 4177: /* Cap the alignment bits to the highest number we can handle */ 4178: dev_err(device->dev, 4179: "Alignment too large; restricting to %dK\n", 4180: KGSL_MAX_ALIGN >> 10); 4181: align = ilog2(KGSL_MAX_ALIGN); 4182: } 4183: 4184: flags &= ~((u64) KGSL_MEMALIGN_MASK); 4185: return flags | FIELD_PREP(KGSL_MEMALIGN_MASK, align); 4186: } 4187: 4188: static u64 gpumem_max_va_size(struct kgsl_pagetable *pt, u64 flags) 4189: { 4190: if (flags & KGSL_MEMFLAGS_FORCE_32BIT) 4191: return pt->compat_va_end - pt->compat_va_start; 4192: 4193: return pt->va_end - pt->va_start; 4194: } 4195: 4196: static struct kgsl_mem_entry * 4197: gpumem_alloc_vbo_entry(struct kgsl_device_private *dev_priv, 4198: u64 size, u64 flags) 4199: { 4200: struct kgsl_process_private *private = dev_priv->process_priv; 4201: struct kgsl_device *device = dev_priv->device; 4202: struct kgsl_memdesc *memdesc; 4203: struct kgsl_mem_entry *entry; 4204: struct kgsl_pagetable *pt; 4205: int ret; 4206: 4207: /* Disallow specific flags */ 4208: if (flags & (KGSL_MEMFLAGS_GPUREADONLY | KGSL_CACHEMODE_MASK)) 4209: return ERR_PTR(-EINVAL); 4210: 4211: if (flags & (KGSL_MEMFLAGS_USE_CPU_MAP | KGSL_MEMFLAGS_IOCOHERENT)) 4212: return ERR_PTR(-EINVAL); 4213: 4214: /* Quietly ignore the other flags that aren't this list */ 4215: flags &= KGSL_MEMFLAGS_SECURE | 4216: KGSL_MEMFLAGS_VBO | 4217: KGSL_MEMFLAGS_VBO_NO_MAP_ZERO | 4218: KGSL_MEMTYPE_MASK | 4219: KGSL_MEMALIGN_MASK | 4220: KGSL_MEMFLAGS_FORCE_32BIT; 4221: 4222: if ((flags & KGSL_MEMFLAGS_SECURE) && !check_and_warn_secured(device)) 4223: return ERR_PTR(-EOPNOTSUPP); 4224: 4225: pt = (flags & KGSL_MEMFLAGS_SECURE) ? 4226: device->mmu.securepagetable : private->pagetable; 4227: 4228: if (!size || (size > gpumem_max_va_size(pt, flags))) 4229: return ERR_PTR(-EINVAL); 4230: 4231: flags = cap_alignment(device, flags); 4232: 4233: entry = kgsl_mem_entry_create(); 4234: if (!entry) 4235: return ERR_PTR(-ENOMEM); 4236: 4237: memdesc = &entry->memdesc; 4238: 4239: ret = kgsl_sharedmem_allocate_vbo(device, memdesc, size, flags); 4240: if (ret) { 4241: kfree(entry); 4242: return ERR_PTR(ret); 4243: } 4244: 4245: if (flags & KGSL_MEMFLAGS_SECURE) 4246: SET_FLAG(KGSL_MEMDESC_SECURE, &entry->memdesc.priv); 4247: 4248: ret = kgsl_mem_entry_attach_to_process(device, private, entry); 4249: if (ret) 4250: goto out; 4251: 4252: /* Map the zero page unless explicitly asked not to */ 4253: if (!(flags & KGSL_MEMFLAGS_VBO_NO_MAP_ZERO)) 4254: ret = kgsl_mmu_map_zero_page_to_range(memdesc->pagetable, 4255: memdesc, 0, memdesc->size); 4256: 4257: if (!ret) { 4258: trace_kgsl_mem_alloc(entry); 4259: kgsl_mem_entry_commit_process(entry); 4260: return entry; 4261: } 4262: 4263: out: 4264: kgsl_sharedmem_free(memdesc); 4265: kfree(entry); 4266: return ERR_PTR(ret); 4267: } 4268: 4269: struct kgsl_mem_entry *gpumem_alloc_entry( 4270: struct kgsl_device_private *dev_priv, 4271: uint64_t size, uint64_t flags) 4272: { 4273: int ret; 4274: struct kgsl_process_private *private = dev_priv->process_priv; 4275: struct kgsl_mem_entry *entry; 4276: struct kgsl_device *device = dev_priv->device; 4277: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 4278: u32 cachemode; MATCH LINES: 4777, 4788, 4790, 4792, 4796 4765: 4766: /* 4767: * Protect access to the gpuaddr here to prevent multiple vmas from 4768: * trying to map a SVM region at the same time 4769: */ 4770: spin_lock(&entry->memdesc.lock); 4771: 4772: if (entry->memdesc.gpuaddr) { 4773: spin_unlock(&entry->memdesc.lock); 4774: return (unsigned long) -EBUSY; 4775: } 4776: 4777: ret = kgsl_mmu_set_svm_region(private->pagetable, (uint64_t) addr, 4778: (uint64_t) size); 4779: 4780: if (ret != 0) { 4781: spin_unlock(&entry->memdesc.lock); 4782: return (unsigned long) ret; 4783: } 4784: 4785: entry->memdesc.gpuaddr = (uint64_t) addr; 4786: spin_unlock(&entry->memdesc.lock); 4787: 4788: entry->memdesc.pagetable = private->pagetable; 4789: 4790: ret = kgsl_mmu_map(private->pagetable, &entry->memdesc); 4791: if (ret) { 4792: kgsl_mmu_put_gpuaddr(private->pagetable, &entry->memdesc); 4793: return (unsigned long) ret; 4794: } 4795: 4796: kgsl_memfree_purge(private->pagetable, entry->memdesc.gpuaddr, 4797: entry->memdesc.size); 4798: 4799: return addr; 4800: } 4801: 4802: unsigned long kgsl_get_align(struct kgsl_memdesc *memdesc) 4803: { 4804: u32 bit = kgsl_memdesc_get_align(memdesc); 4805: 4806: if (bit >= ilog2(SZ_2M)) 4807: return SZ_2M; 4808: else if (bit >= ilog2(SZ_1M)) 4809: return SZ_1M; 4810: else if (bit >= ilog2(SZ_64K)) 4811: return SZ_64K; 4812: 4813: return PAGE_SIZE; 4814: } 4815: 4816: static unsigned long set_svm_area(struct file *file, 4817: struct kgsl_mem_entry *entry, 4818: unsigned long addr, unsigned long len, 4819: unsigned long flags) 4820: { MATCH LINES: 4868, 4873, 4896 4856: } 4857: 4858: /* If a hint was provided, try to use that first */ 4859: if (addr) { 4860: if (IS_ALIGNED(addr, align)) { 4861: ret = set_svm_area(file, entry, addr, len, flags); 4862: if (!IS_ERR_VALUE(ret)) 4863: return ret; 4864: } 4865: } 4866: 4867: /* Get the SVM range for the current process */ 4868: if (kgsl_mmu_svm_range(private->pagetable, &start, &end, 4869: entry->memdesc.flags)) 4870: return -ERANGE; 4871: 4872: /* Find the first gap in the iova map */ 4873: iova = kgsl_mmu_find_svm_region(private->pagetable, start, end, 4874: len, align); 4875: 4876: while (!IS_ERR_VALUE(iova)) { 4877: vma = find_vma_intersection(current->mm, iova, iova + len - 1); 4878: if (vma) { 4879: iova = vma->vm_start; 4880: } else { 4881: ret = set_svm_area(file, entry, iova, len, flags); 4882: if (!IS_ERR_VALUE(ret)) 4883: return ret; 4884: 4885: /* 4886: * set_svm_area will return -EBUSY if we tried to set up 4887: * SVM on an object that already has a GPU address. If 4888: * that happens don't bother walking the rest of the 4889: * region 4890: */ 4891: if ((long) ret == -EBUSY) 4892: return -EBUSY; 4893: 4894: } 4895: 4896: iova = kgsl_mmu_find_svm_region(private->pagetable, 4897: start, iova - 1, len, align); 4898: } 4899: 4900: return -ENOMEM; 4901: } 4902: 4903: static unsigned long 4904: kgsl_get_unmapped_area(struct file *file, unsigned long addr, 4905: unsigned long len, unsigned long pgoff, 4906: unsigned long flags) 4907: { 4908: unsigned long val; 4909: unsigned long vma_offset = pgoff << PAGE_SHIFT; 4910: struct kgsl_device_private *dev_priv = file->private_data; 4911: struct kgsl_process_private *private = dev_priv->process_priv; 4912: struct kgsl_device *device = dev_priv->device; 4913: struct kgsl_mem_entry *entry = NULL; 4914: 4915: if (vma_offset == (unsigned long) KGSL_MEMSTORE_TOKEN_ADDRESS) 4916: return kgsl_mm_get_unmapped_area(current->mm, NULL, addr, len, pgoff, flags); 4917: 4918: val = get_mmap_entry(private, &entry, pgoff, len); 4919: if (val) 4920: return val; MATCH LINES: 5320, 5331, 5333 5308: if (WARN_ON(ret > sizeof(str))) 5309: return -ENOMEM; 5310: 5311: /* Read the expanded string */ 5312: if (!of_property_read_u32(node, str, ptr)) 5313: return 0; 5314: } 5315: 5316: /* Read the default string */ 5317: return of_property_read_u32(node, base, ptr); 5318: } 5319: 5320: int kgsl_iommu_probe_standard(struct kgsl_device *device, struct platform_device *pdev); 5321: 5322: int kgsl_device_platform_probe(struct kgsl_device *device) 5323: { 5324: struct platform_device *pdev = device->pdev; 5325: int status = -EINVAL; 5326: 5327: status = _register_device(device); 5328: if (status) 5329: return status; 5330: 5331: /* Probe standard kgsl smmu dt bindings */ 5332: if (of_device_is_compatible(pdev->dev.of_node, "qcom,adreno")) 5333: kgsl_iommu_probe_standard(device, pdev); 5334: 5335: /* Can return -EPROBE_DEFER */ 5336: status = kgsl_pwrctrl_init(device); 5337: if (status) 5338: goto error; 5339: 5340: device->events_worker = kgsl_kthread_run_worker(0, "kgsl-events"); 5341: 5342: if (IS_ERR(device->events_worker)) { 5343: status = PTR_ERR(device->events_worker); 5344: dev_err(device->dev, "Failed to create events worker ret=%d\n", status); 5345: goto error_pwrctrl_close; 5346: } 5347: 5348: sched_set_fifo(device->events_worker->task); 5349: 5350: status = kgsl_reclaim_init(); 5351: if (status) 5352: goto error_pwrctrl_close; 5353: 5354: rwlock_init(&device->context_lock); 5355: spin_lock_init(&device->submit_lock); 5356: 5357: idr_init(&device->timelines); MATCH LINES: 5517, 5535 5505: } 5506: 5507: kgsl_driver.virtdev.dma_mask = &dma_mask; 5508: kgsl_driver.virtdev.dma_parms = &dma_parms; 5509: 5510: dma_set_max_seg_size(&kgsl_driver.virtdev, (u32)DMA_BIT_MASK(32)); 5511: 5512: set_dma_ops(&kgsl_driver.virtdev, NULL); 5513: 5514: /* Make kobjects in the virtual device for storing statistics */ 5515: 5516: kgsl_driver.ptkobj = 5517: kobject_create_and_add("pagetables", 5518: &kgsl_driver.virtdev.kobj); 5519: 5520: kgsl_driver.prockobj = 5521: kobject_create_and_add("proc", 5522: &kgsl_driver.virtdev.kobj); 5523: 5524: kgsl_core_debugfs_init(); 5525: 5526: kgsl_sharedmem_init_sysfs(); 5527: 5528: /* Initialize the memory pools */ 5529: kgsl_probe_page_pools(); 5530: 5531: kgsl_register_shmem_callback(); 5532: 5533: INIT_LIST_HEAD(&kgsl_driver.process_list); 5534: 5535: INIT_LIST_HEAD(&kgsl_driver.pagetable_list); 5536: 5537: INIT_LIST_HEAD(&kgsl_driver.wp_list); 5538: 5539: kgsl_driver.workqueue = alloc_workqueue("kgsl-workqueue", 5540: WQ_UNBOUND | WQ_MEM_RECLAIM | WQ_SYSFS, 0); 5541: 5542: if (!kgsl_driver.workqueue) { 5543: pr_err("kgsl: Failed to allocate kgsl workqueue\n"); 5544: result = -ENOMEM; 5545: goto err; 5546: } 5547: 5548: /* 5549: * The lockless workqueue is used to perform work which doesn't need to 5550: * take the device mutex 5551: */ 5552: kgsl_driver.lockless_workqueue = alloc_workqueue("kgsl-lockless-work", 5553: WQ_UNBOUND | WQ_MEM_RECLAIM, 0); 5554: 5555: if (!kgsl_driver.lockless_workqueue) { 5556: pr_err("kgsl: Failed to allocate lockless workqueue\n"); 5557: result = -ENOMEM; 5558: goto err; 5559: } --- FILE: \kgsl.h | HITS: 10 --- MATCH LINES: 94, 96, 97, 98, 99 82: * the GPU and CPU. For example, it will be used by the GPU to write 83: * each updated RPTR for each RB. 84: */ 85: 86: /* Shadow global helpers */ 87: struct adreno_rb_shadow { 88: /** @rptr: per ringbuffer address where GPU writes the rptr */ 89: u32 rptr; 90: /** @bv_rptr: per ringbuffer address where GPU writes BV rptr */ 91: u32 bv_rptr; 92: /** @bv_ts: per ringbuffer address where BV ringbuffer timestamp is written to */ 93: u32 bv_ts; 94: /** @current_rb_ptname: The current pagetable active on the given RB */ 95: u32 current_rb_ptname; 96: /** @ttbr0: value to program into TTBR0 during pagetable switch */ 97: u64 ttbr0; 98: /** @contextidr: value to program into CONTEXTIDR during pagetable switch */ 99: u32 contextidr; 100: }; 101: 102: /** 103: * struct gpu_work_period - App specific GPU work period stats 104: */ 105: struct gpu_work_period { 106: struct kref refcount; 107: struct list_head list; 108: /** @uid: application unique identifier */ 109: uid_t uid; 110: /** @active: Total amount of time the GPU spent running work */ 111: u64 active; 112: /** @cmds: Total number of commands completed within work period */ 113: u32 cmds; 114: /** @frames: Total number of frames completed within work period */ 115: atomic_t frames; 116: /** @flags: Flags to accumulate GPU busy stats */ 117: unsigned long flags; 118: /** @active_cmds: The number of active cmds from application */ 119: atomic_t active_cmds; 120: /** @defer_ws: Work struct to clear gpu work period */ 121: struct work_struct defer_ws; 122: }; 123: MATCH LINES: 162, 166, 167, 188, 217 150: #define KGSL_MAX_NUMIBS 2000 151: #define KGSL_MAX_SYNCPOINTS 32 152: 153: struct kgsl_device; 154: struct kgsl_context; 155: 156: /** 157: * struct kgsl_driver - main container for global KGSL things 158: * @cdev: Character device struct 159: * @major: Major ID for the KGSL device 160: * @class: Pointer to the class struct for the core KGSL sysfs entries 161: * @virtdev: Virtual device for managing the core 162: * @ptkobj: kobject for storing the pagetable statistics 163: * @prockobj: kobject for storing the process statistics 164: * @devp: Array of pointers to the individual KGSL device structs 165: * @process_list: List of open processes 166: * @pagetable_list: LIst of open pagetables 167: * @ptlock: Lock for accessing the pagetable list 168: * @process_mutex: Mutex for accessing the process list 169: * @proclist_lock: Lock for accessing the process list 170: * @devlock: Mutex protecting the device list 171: * @stats: Struct containing atomic memory statistics 172: * @full_cache_threshold: the threshold that triggers a full cache flush 173: * @workqueue: Pointer to a single threaded workqueue 174: */ 175: struct kgsl_driver { 176: struct cdev cdev; 177: dev_t major; 178: struct class *class; 179: struct device virtdev; 180: struct kobject *ptkobj; 181: struct kobject *prockobj; 182: struct kgsl_device *devp[1]; 183: struct list_head process_list; 184: /** @wp_list: List of work period allocated per uid */ 185: struct list_head wp_list; 186: /** @wp_list_lock: Lock for accessing the work period list */ 187: spinlock_t wp_list_lock; 188: struct list_head pagetable_list; 189: spinlock_t ptlock; 190: struct mutex process_mutex; 191: rwlock_t proclist_lock; 192: struct mutex devlock; 193: struct { 194: atomic_long_t vmalloc; 195: atomic_long_t vmalloc_max; 196: atomic_long_t page_alloc; 197: atomic_long_t page_alloc_max; 198: atomic_long_t coherent; 199: atomic_long_t coherent_max; 200: atomic_long_t secure; 201: atomic_long_t secure_max; 202: atomic_long_t mapped; 203: atomic_long_t mapped_max; 204: } stats; 205: unsigned int full_cache_threshold; 206: struct workqueue_struct *workqueue; 207: /* @lockless_workqueue: Pointer to a workqueue handler which doesn't hold device mutex */ 208: struct workqueue_struct *lockless_workqueue; 209: /** @pool_shrinker: Pointer to a shrinker that resizes the kgsl page pools */ 210: struct shrinker *pool_shrinker; 211: /** @reclaim_shrinker: Pointer to a shrinker that reclaims kgsl memory */ 212: struct shrinker *reclaim_shrinker; 213: }; 214: 215: extern struct kgsl_driver kgsl_driver; 216: 217: struct kgsl_pagetable; 218: 219: /* 220: * List of different memory entry types. The usermem enum 221: * starts at 0, which we use for allocated memory, so 1 is 222: * added to the enum values. 223: */ 224: #define KGSL_MEM_ENTRY_KERNEL 0 225: #define KGSL_MEM_ENTRY_USER (KGSL_USER_MEM_TYPE_ADDR + 1) 226: #define KGSL_MEM_ENTRY_ION (KGSL_USER_MEM_TYPE_ION + 1) 227: #define KGSL_MEM_ENTRY_MAX (KGSL_USER_MEM_TYPE_MAX + 1) 228: 229: /* For application specific GPU work period stats */ 230: #define KGSL_WORK_PERIOD 0 231: /* GPU work period time in msec to emulate application work stats */ 232: #define KGSL_WORK_PERIOD_MS 900 233: 234: struct kgsl_device_private; 235: struct kgsl_event_group; 236: 237: typedef void (*kgsl_event_func)(struct kgsl_device *, struct kgsl_event_group *, 238: void *, int); 239: 240: /** 241: * struct kgsl_event - KGSL GPU timestamp event --- FILE: \kgsl_device.h | HITS: 7 --- MATCH LINES: 215, 216 203: /** @create_hw_fence: Create a hardware fence */ 204: void (*create_hw_fence)(struct kgsl_device *device, struct kgsl_sync_fence *kfence); 205: /** @gmu_based_dcvs_pwr_ops: Function ops for GMU based DCVS power operations */ 206: int (*gmu_based_dcvs_pwr_ops)(struct kgsl_device *device, u32 arg, 207: enum gpu_pwrlevel_op op); 208: /** @set_thermal_index: Target specific function to send thermal constraint to GMU */ 209: void (*set_thermal_index)(struct kgsl_device *device); 210: /** @alloc_dcvs_profile_memory: Function ops for GMU based DCVS profile operations */ 211: void (*alloc_dcvs_profile_memory)(struct kgsl_device *device, 212: struct kgsl_process_private *proc_priv); 213: /** @is_first_boot_done: Check if the ADRENO device first boot is done */ 214: bool (*is_first_boot_done)(struct kgsl_device *device); 215: /** @set_smmu_aperture: Target specific function to program the SMMU aperture registers */ 216: int (*set_smmu_aperture)(struct kgsl_device *device); 217: }; 218: 219: struct kgsl_ioctl { 220: unsigned int cmd; 221: long (*func)(struct kgsl_device_private *dev_priv, 222: unsigned int cmd, void *data); 223: }; 224: 225: long kgsl_ioctl_helper(struct file *filep, unsigned int cmd, unsigned long arg, 226: const struct kgsl_ioctl *cmds, int len); 227: 228: /* Flag to mark that the memobj_node should not go to the hadrware */ 229: #define MEMOBJ_SKIP BIT(1) 230: 231: /** 232: * struct kgsl_memobj_node - Memory object descriptor 233: * @node: Local list node for the object 234: * @id: GPU memory ID for the object 235: * offset: Offset within the object 236: * @gpuaddr: GPU address for the object 237: * @flags: External flags passed by the user 238: * @priv: Internal flags set by the driver 239: */ 240: struct kgsl_memobj_node { MATCH LINES: 283, 284 271: 272: struct kgsl_device { 273: struct device *dev; 274: const char *name; 275: u32 id; 276: 277: /* Kernel virtual address for GPU shader memory */ 278: void __iomem *shader_mem_virt; 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; MATCH LINES: 578, 598 566: }; 567: 568: /** 569: * struct kgsl_process_private - Private structure for a KGSL process (across 570: * all devices) 571: * @priv: Internal flags, use KGSL_PROCESS_* values 572: * @pid: Identification structure for the task owner of the process 573: * @comm: task name of the process 574: * @mm: mm_struct of the opening process, used to prevent other mm mmap 575: * @mem_lock: Spinlock to protect the process memory lists 576: * @refcount: kref object for reference counting the process 577: * @idr: Iterator for assigning IDs to memory allocations 578: * @pagetable: Pointer to the pagetable owned by this process 579: * @kobj: Pointer to a kobj for the sysfs directory for this process 580: * @debug_root: Pointer to the debugfs root for this process 581: * @stats: Memory allocation statistics for this process 582: * @gpumem_mapped: KGSL memory mapped in the process address space 583: * @syncsource_idr: sync sources created by this process 584: * @syncsource_lock: Spinlock to protect the syncsource idr 585: * @fd_count: Counter for the number of FDs for this process 586: * @ctxt_count: Count for the number of contexts for this process 587: * @ctxt_count_lock: Spinlock to protect ctxt_count 588: * @frame_count: Count for the number of frames processed 589: */ 590: struct kgsl_process_private { 591: unsigned long priv; 592: struct pid *pid; 593: char comm[TASK_COMM_LEN]; 594: struct mm_struct *mm; 595: spinlock_t mem_lock; 596: struct kref refcount; 597: struct idr mem_idr; 598: struct kgsl_pagetable *pagetable; 599: struct list_head list; 600: struct list_head reclaim_list; 601: struct kobject kobj; 602: struct dentry *debug_root; 603: struct { 604: atomic64_t cur; 605: uint64_t max; 606: } stats[KGSL_MEM_ENTRY_MAX]; 607: atomic64_t gpumem_mapped; 608: struct idr syncsource_idr; 609: spinlock_t syncsource_lock; 610: int fd_count; 611: atomic_t ctxt_count; 612: spinlock_t ctxt_count_lock; 613: atomic64_t frame_count; 614: /** 615: * @state: state consisting KGSL_PROC_STATE and KGSL_PROC_PINNED_STATE 616: */ 617: unsigned long state; 618: /** 619: * @unpinned_page_count: The number of pages unpinned for reclaim 620: */ 621: atomic_t unpinned_page_count; 622: /** MATCH LINES: 654 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) --- FILE: \kgsl_gmu_core.c | HITS: 34 --- MATCH LINES: 208, 214, 226 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: 220: ret = sg_alloc_table_from_pages(&sgt, memdesc->pages, 221: memdesc->page_count, 0, memdesc->size, GFP_KERNEL); 222: 223: if (ret) 224: return ret; 225: 226: mapped = kgsl_mmu_map_sg(domain, gmuaddr, sgt.sgl, sgt.nents, attrs); 227: sg_free_table(&sgt); 228: } 229: 230: if (!mapped) 231: mapped = -ENOMEM; 232: 233: return (mapped < 0) ? mapped : 0; 234: } 235: 236: struct kgsl_memdesc *gmu_core_find_memdesc(struct kgsl_device *device, u32 addr, u32 size) 237: { 238: struct gmu_core_device *gmu = &device->gmu_core; 239: int i; 240: 241: for (i = 0; i < gmu->global_entries; i++) { 242: struct kgsl_memdesc *md = &gmu->gmu_globals[i]; 243: 244: if ((addr >= md->gmuaddr) && 245: (((addr + size) <= (md->gmuaddr + md->size)))) 246: return md; 247: } 248: 249: return NULL; 250: } MATCH LINES: 279, 288, 289 267: 268: void gmu_core_free_globals(struct kgsl_device *device) 269: { 270: struct gmu_core_device *gmu = &device->gmu_core; 271: int i; 272: 273: for (i = 0; i < gmu->global_entries && i < ARRAY_SIZE(gmu->gmu_globals); i++) { 274: struct kgsl_memdesc *md = &gmu->gmu_globals[i]; 275: 276: if (!md->gmuaddr) 277: continue; 278: 279: iommu_unmap(gmu->domain, md->gmuaddr, md->size); 280: 281: if (TEST_FLAG(KGSL_MEMDESC_SYSMEM, &md->priv)) 282: kgsl_sharedmem_free(md); 283: 284: memset(md, 0, sizeof(*md)); 285: } 286: 287: if (gmu->domain) { 288: kgsl_detach_iommu_group(gmu->domain, gmu->group); 289: iommu_domain_free(gmu->domain); 290: gmu->domain = NULL; 291: } 292: 293: gmu->global_entries = 0; 294: } 295: 296: static struct gmu_vma_node *find_va(struct gmu_vma_entry *vma, u32 addr, u32 size) 297: { 298: struct rb_node *node = vma->vma_root.rb_node; 299: 300: while (node != NULL) { 301: struct gmu_vma_node *data = rb_entry(node, struct gmu_vma_node, node); 302: 303: if (addr + size <= data->va) 304: node = node->rb_left; 305: else if (addr >= data->va + data->size) 306: node = node->rb_right; 307: else 308: return data; 309: } 310: return NULL; 311: } 312: 313: /* Return true if VMA supports dynamic allocations */ MATCH LINES: 502, 505, 508, 527, 540 490: } 491: 492: int gmu_core_map_gmu(struct kgsl_device *device, struct kgsl_memdesc *md, 493: u32 addr, u32 vma_id, int attrs, u32 align) 494: { 495: return vma_is_dynamic(device, vma_id) ? 496: _map_gmu_dynamic(device, md, addr, vma_id, attrs, align) : 497: _map_gmu_static(device, md, addr, vma_id, attrs, align); 498: } 499: 500: int gmu_core_get_attrs(u32 flags) 501: { 502: int attrs = IOMMU_READ; 503: 504: if (flags & HFI_MEMFLAG_GMU_PRIV) 505: attrs |= IOMMU_PRIV; 506: 507: if (flags & HFI_MEMFLAG_GMU_WRITEABLE) 508: attrs |= IOMMU_WRITE; 509: 510: return attrs; 511: } 512: 513: int gmu_core_import_buffer(struct kgsl_device *device, struct hfi_mem_alloc_entry *entry) 514: { 515: struct hfi_mem_alloc_desc *desc = &entry->desc; 516: u32 attrs = gmu_core_get_attrs(desc->flags); 517: u32 vma_id = (desc->flags & HFI_MEMFLAG_GMU_CACHEABLE) ? GMU_CACHE : GMU_NONCACHED_KERNEL; 518: 519: /* 520: * GMU Tx/Rx queues are mapped as I/O-coherent on both SOCCP and CPU, 521: * mark the buffer I/O-coherent on GMU side as well to prevent stale 522: * data and immediate updates in DDR. 523: */ 524: if (desc->mem_kind == HFI_MEMKIND_HW_FENCE && 525: kgsl_mmu_has_feature(device, KGSL_MMU_IO_COHERENT)) { 526: entry->md->flags |= KGSL_MEMFLAGS_IOCOHERENT; 527: attrs |= IOMMU_CACHE; 528: } 529: 530: return gmu_core_map_gmu(device, entry->md, 0, vma_id, attrs, desc->align); 531: } 532: 533: struct kgsl_memdesc *gmu_core_reserve_kernel_block(struct kgsl_device *device, 534: u32 addr, u32 size, u32 vma_id, u32 align) 535: { 536: int ret; 537: u64 memflags = 0; 538: struct kgsl_memdesc *md; 539: struct gmu_core_device *gmu = &device->gmu_core; 540: int attrs = IOMMU_READ | IOMMU_WRITE | IOMMU_PRIV; 541: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 542: 543: if (gmu->global_entries == ARRAY_SIZE(gmu->gmu_globals)) 544: return ERR_PTR(-ENOMEM); 545: 546: md = &gmu->gmu_globals[gmu->global_entries]; 547: 548: /* 549: * Apply WB cache policy to fetch GMU FW successfully for A622. 550: * A622 has specific cache coherency requirements that can lead to data 551: * inconsistency if not using writeback cache policy. 552: */ 553: if (adreno_is_a622(adreno_dev)) 554: memflags = FIELD_PREP(KGSL_CACHEMODE_MASK, KGSL_CACHEMODE_WRITEBACK); 555: 556: ret = kgsl_allocate_kernel(device, md, size, memflags, KGSL_MEMDESC_SYSMEM); 557: if (ret) { 558: memset(md, 0x0, sizeof(*md)); 559: return ERR_PTR(-ENOMEM); 560: } 561: 562: ret = gmu_core_map_gmu(device, md, addr, vma_id, attrs, align); 563: if (ret) { 564: kgsl_sharedmem_free(md); MATCH LINES: 638, 640 626: struct gmu_core_device *gmu = &device->gmu_core; 627: int vma_id = gmu_core_find_vma_block(device, md->gmuaddr, md->size); 628: struct gmu_vma_entry *vma; 629: struct gmu_vma_node *vma_node; 630: 631: if ((vma_id < 0) || !vma_is_dynamic(device, vma_id)) 632: return; 633: 634: vma = &gmu->vma[vma_id]; 635: 636: /* 637: * Do not remove the vma node if we failed to unmap the entire buffer. This is because the 638: * iommu driver considers remapping an already mapped iova as fatal. 639: */ 640: if (md->size != iommu_unmap(device->gmu_core.domain, md->gmuaddr, md->size)) 641: goto free; 642: 643: spin_lock(&vma->lock); 644: vma_node = find_va(vma, md->gmuaddr, md->size); 645: if (vma_node) 646: rb_erase(&vma_node->node, &vma->vma_root); 647: spin_unlock(&vma->lock); 648: kfree(vma_node); 649: free: 650: kgsl_sharedmem_free(md); 651: } 652: 653: int gmu_core_process_prealloc(struct kgsl_device *device, struct gmu_block_header *blk) 654: { 655: struct kgsl_memdesc *md; 656: int id = gmu_core_find_vma_block(device, blk->addr, blk->value); 657: 658: if (id < 0) { 659: dev_err(GMU_PDEV_DEV(device), 660: "Invalid prealloc block addr: 0x%x value:%d\n", 661: blk->addr, blk->value); 662: return id; 663: } 664: MATCH LINES: 679, 684, 686, 688, 690, 694, 700, 702, 706, 708, 712, 717, 720, 727, 729, 730, 732, 735, 736, 740, 741 667: return 0; 668: 669: /* Check if the block is already allocated */ 670: md = gmu_core_find_memdesc(device, blk->addr, blk->value); 671: if (md != NULL) 672: return 0; 673: 674: md = gmu_core_reserve_kernel_block(device, blk->addr, blk->value, id, 0); 675: 676: return PTR_ERR_OR_ZERO(md); 677: } 678: 679: static int gmu_core_iommu_fault_handler(struct iommu_domain *domain, 680: struct device *dev, unsigned long addr, int flags, void *token) 681: { 682: char *fault_type = "unknown"; 683: 684: if (flags & IOMMU_FAULT_TRANSLATION) 685: fault_type = "translation"; 686: else if (flags & IOMMU_FAULT_PERMISSION) 687: fault_type = "permission"; 688: else if (flags & IOMMU_FAULT_EXTERNAL) 689: fault_type = "external"; 690: else if (flags & IOMMU_FAULT_TRANSACTION_STALLED) 691: fault_type = "transaction stalled"; 692: 693: dev_err(dev, "GMU fault addr = %lX, context=kernel (%s %s fault)\n", 694: addr, (flags & IOMMU_FAULT_WRITE) ? "write" : "read", fault_type); 695: 696: return 0; 697: } 698: 699: #if (KERNEL_VERSION(6, 13, 0) <= LINUX_VERSION_CODE) 700: static struct iommu_domain *gmu_core_iommu_domain_alloc(struct device *dev) 701: { 702: return iommu_paging_domain_alloc(dev); 703: } 704: #else 705: #include 706: static struct iommu_domain *gmu_core_iommu_domain_alloc(struct device *dev) 707: { 708: return iommu_domain_alloc(&platform_bus_type); 709: } 710: #endif 711: 712: int gmu_core_iommu_init(struct kgsl_device *device) 713: { 714: struct device *gmu_pdev_dev = GMU_PDEV_DEV(device); 715: int ret; 716: 717: device->gmu_core.domain = gmu_core_iommu_domain_alloc(gmu_pdev_dev); 718: if (IS_ERR_OR_NULL(device->gmu_core.domain)) { 719: ret = (device->gmu_core.domain) ? PTR_ERR(device->gmu_core.domain) : -ENODEV; 720: dev_err(gmu_pdev_dev, "Unable to allocate GMU IOMMU domain: %d\n", ret); 721: return ret; 722: } 723: 724: /* 725: * Disable stall on fault for the GMU context bank. 726: * This sets SCTLR.CFCFG = 0. 727: * Also note that, the smmu driver sets SCTLR.HUPCF = 0 by default. 728: */ 729: qcom_iommu_set_fault_model(device->gmu_core.domain, 730: QCOM_IOMMU_FAULT_MODEL_NO_STALL); 731: 732: ret = kgsl_attach_iommu_group(gmu_pdev_dev, device->gmu_core.domain, 733: &device->gmu_core.group); 734: if (!ret) { 735: iommu_set_fault_handler(device->gmu_core.domain, 736: gmu_core_iommu_fault_handler, device); 737: return 0; 738: } 739: 740: dev_err(gmu_pdev_dev, "Unable to attach GMU IOMMU domain: %d\n", ret); 741: iommu_domain_free(device->gmu_core.domain); 742: device->gmu_core.domain = NULL; 743: 744: return ret; 745: } 746: 747: void gmu_core_dev_force_first_boot(struct kgsl_device *device) 748: { 749: const struct gmu_dev_ops *ops = GMU_DEVICE_OPS(device); 750: 751: if (ops && ops->force_first_boot) 752: return ops->force_first_boot(device); 753: } 754: 755: int gmu_core_set_vrb_register(struct kgsl_memdesc *vrb, u32 index, u32 val) 756: { 757: u32 *vrb_buf; 758: 759: if (WARN_ON(IS_ERR_OR_NULL(vrb))) 760: return -ENODEV; 761: 762: if (WARN_ON(index >= (vrb->size >> 2))) { 763: pr_err("kgsl: Unable to set VRB register for index %u\n", index); 764: return -EINVAL; 765: } --- FILE: \kgsl_gmu_core.h | HITS: 11 --- MATCH LINES: 562, 563, 564, 565 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; 556: const struct gmu_dev_ops *dev_ops; 557: unsigned long flags; 558: /** @gf_panic: GMU fault panic policy */ 559: enum gmu_fault_panic_policy gf_panic; 560: /** @pdev: platform device for the gmu */ 561: struct platform_device *pdev; 562: /** @domain: IOMMU domain for the gmu context */ 563: struct iommu_domain *domain; 564: /** @group: IOMMU group for the gmu context */ 565: struct iommu_group *group; 566: /** @gmu_globals: Array to store gmu global buffers */ 567: struct kgsl_memdesc gmu_globals[GMU_KERNEL_ENTRIES]; 568: /** @global_entries: To keep track of number of gmu buffers */ 569: u32 global_entries; 570: /** @vma: VMA entry for GMU */ 571: struct gmu_vma_entry *vma; 572: /** @num_vmas: Number of entries in the @vma array */ 573: u32 num_vmas; 574: /** @common_caps: GMU firmware common capabilities */ 575: struct firmware_capabilities common_caps; 576: /** @platform_caps: GMU firmware platform capabilities */ 577: struct firmware_capabilities platform_caps; 578: /* @ver: GMU Version information */ 579: struct { 580: u32 core; 581: u32 core_dev; 582: u32 pwr; 583: u32 pwr_dev; 584: u32 hfi; 585: } ver; 586: /** @warmboot_enabled: True if warmboot is enabled */ 587: bool warmboot_enabled; 588: /** @rdpm_cx_virt: Pointer where the RDPM CX block is mapped */ 589: void __iomem *rdpm_cx_virt; MATCH LINES: 698, 709, 717 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 */ 703: struct kgsl_memdesc *memdesc; 704: /** @type: Type of the memory descriptor */ 705: u32 type; 706: }; 707: 708: /** 709: * gmu_core_map_memdesc - Map the memdesc into the GMU IOMMU domain 710: * @domain: Domain to map the memory into 711: * @memdesc: Memory descriptor to map 712: * @gmuaddr: Virtual GMU address to map the memory into 713: * @attrs: Attributes for the mapping 714: * 715: * Return: 0 on success or -ENOMEM on failure 716: */ 717: int gmu_core_map_memdesc(struct iommu_domain *domain, struct kgsl_memdesc *memdesc, 718: u64 gmuaddr, int attrs); 719: 720: /** 721: * gmu_core_map_gmu - Map a kgsl memdesc to GMU 722: * @device: Pointer to kgsl device 723: * @md: Pointer to the kgsl memdesc 724: * @addr: Address where to map this memdesc 725: * @vma_id: VMA id to which this memdesc needs to be mapped 726: * @attrs: mapping attributes 727: * @align: Alignment request for this memdesc 728: 729: * Return: Zero on success or negative error on failure. 730: */ 731: int gmu_core_map_gmu(struct kgsl_device *device, struct kgsl_memdesc *md, 732: u32 addr, u32 vma_id, int attrs, u32 align); 733: 734: /** 735: * gmu_core_find_memdesc - Find the GMU memory descriptor for a given address and size 736: * @device: Pointer to KGSL device 737: * @addr: Address of the memory region 738: * @size: Size of the memory region 739: * 740: * Return: Pointer to the matching kgsl_memdesc structure if found, NULL otherwise. 741: */ MATCH LINES: 761, 764 749: * 750: * Return: The index of the matching VMA entry if found, -ENOENT otherwise. 751: */ 752: int gmu_core_find_vma_block(struct kgsl_device *device, u32 addr, u32 size); 753: 754: /** 755: * gmu_core_free_globals - Free the GMU global memory descriptors 756: * @device: Pointer to KGSL device 757: */ 758: void gmu_core_free_globals(struct kgsl_device *device); 759: 760: /** 761: * gmu_core_get_attrs - Get the IOMMU attributes based on flags 762: * @flags: The memory flags indicating the attributes 763: * 764: * Return: IOMMU attributes. 765: */ 766: int gmu_core_get_attrs(u32 flags); 767: 768: /** 769: * gmu_core_import_buffer - Import a gmu buffer 770: * @device: Pointer to KGSL device 771: * @entry: GMU memory entry 772: * This function imports and maps a buffer to a gmu vma 773: * 774: * Return: 0 on success or error code on failure 775: */ 776: int gmu_core_import_buffer(struct kgsl_device *device, struct hfi_mem_alloc_entry *entry); 777: 778: /** 779: * gmu_core_reserve_kernel_block - Allocate a gmu buffer 780: * @device: Pointer to KGSL device 781: * @addr: Desired gmu virtual address 782: * @size: Size of the buffer in bytes 783: * @vma_id: Target gmu vma where this buffer should be mapped 784: * @align: Alignment as a power of two(2^n) bytes for the GMU VA 785: * 786: * This function allocates a buffer and maps it in the desired gmu vma 787: * 788: * Return: Pointer to the memory descriptor or error pointer on failure MATCH LINES: 842, 847 830: void gmu_core_free_block(struct kgsl_device *device, struct kgsl_memdesc *md); 831: 832: /** 833: * gmu_core_process_prealloc - Process preallocate GMU blocks 834: * @device: Pointer to the KGSL device structure 835: * @blk: Pointer to the GMU block header structure 836: * 837: * Return: 0 on success, negative error code on failure. 838: */ 839: int gmu_core_process_prealloc(struct kgsl_device *device, struct gmu_block_header *blk); 840: 841: /** 842: * gmu_core_iommu_init - Set up GMU IOMMU and shared memory with GMU 843: * @device: Pointer to KGSL device 844: * 845: * Return: 0 on success or error value on failure 846: */ 847: int gmu_core_iommu_init(struct kgsl_device *device); 848: 849: void gmu_core_dev_force_first_boot(struct kgsl_device *device); 850: 851: /** 852: * gmu_core_set_vrb_register - set vrb register value at specified index 853: * @vrb: GMU virtual register bank memory 854: * @index: vrb index to write the value 855: * @val: value to be writen into vrb 856: * 857: * Return: Negative error on failure and zero on success. 858: */ 859: int gmu_core_set_vrb_register(struct kgsl_memdesc *vrb, u32 index, u32 val); 860: 861: /** 862: * gmu_core_get_vrb_register - get vrb register value at specified index 863: * @vrb: GMU virtual register bank memory 864: * @index: vrb index to write the value 865: * @val: Pointer to update the data after reading from vrb 866: * 867: * Return: Negative error on failure and zero on success. 868: */ 869: int gmu_core_get_vrb_register(struct kgsl_memdesc *vrb, u32 index, u32 *val); 870: 871: /** --- FILE: \kgsl_iommu.c | HITS: 843 --- MATCH LINES: 13, 34, 40, 42, 48, 54, 59, 67, 70, 72, 86, 91, 97, 99, 109, 115, 118, 123, 126, 129, 132, 169, 174, 176, 186, 202 1: // SPDX-License-Identifier: GPL-2.0-only 2: /* 3: * Copyright (c) 2011-2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #include 8: #include 9: #include 10: #include 11: #include 12: #include 13: #include 14: #include 15: #include 16: #include 17: #include 18: #include 19: #include 20: #if (KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE) 21: #include 22: #else 23: #include 24: #endif 25: #if IS_ENABLED(CONFIG_QCOM_SCM_ADDON) 26: #include 27: #endif 28: #include 29: #include 30: #include 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: /* 54: * struct kgsl_iommu_addr_entry - entry in the kgsl_pagetable rbtree. 55: * @base: starting virtual address of the entry 56: * @size: size of the entry 57: * @node: the rbtree node 58: */ 59: struct kgsl_iommu_addr_entry { 60: uint64_t base; 61: uint64_t size; 62: struct rb_node node; 63: }; 64: 65: static struct kmem_cache *addr_entry_cache; 66: 67: static struct adreno_smmu_priv *kgsl_get_prvdata(struct device *dev) 68: { 69: struct kgsl_device *kgsl = dev_get_drvdata(dev); 70: struct kgsl_iommu *iommu = KGSL_IOMMU(kgsl); 71: 72: return &((iommu->user_context).adreno_smmu); 73: } 74: 75: /* These are dummy TLB ops for the io-pgtable instances */ 76: 77: static void _tlb_flush_all(void *cookie) 78: { 79: } 80: 81: static void _tlb_flush_walk(unsigned long iova, size_t size, 82: size_t granule, void *cookie) 83: { 84: } 85: 86: static void _tlb_add_page(struct iommu_iotlb_gather *gather, 87: unsigned long iova, size_t granule, void *cookie) 88: { 89: } 90: 91: static const struct iommu_flush_ops kgsl_iopgtbl_tlb_ops = { 92: .tlb_flush_all = _tlb_flush_all, 93: .tlb_flush_walk = _tlb_flush_walk, 94: .tlb_add_page = _tlb_add_page, 95: }; 96: 97: static struct kgsl_iommu_pt *to_iommu_pt(struct kgsl_pagetable *pagetable) 98: { 99: return container_of(pagetable, struct kgsl_iommu_pt, base); 100: } 101: 102: static u32 get_llcc_flags(struct kgsl_mmu *mmu) 103: { 104: if (!test_bit(KGSL_MMU_LLCC_ENABLE, &mmu->features)) 105: return 0; 106: 107: /* Return no-write-allocate if mmu feature for no-write-allocate is set */ 108: if (test_bit(KGSL_MMU_FORCE_LLCC_NWA, &mmu->features)) 109: return IOMMU_SYS_CACHE_NWA; 110: 111: /* Return 0 as default llcc allocation policy */ 112: return 0; 113: } 114: 115: static int _iommu_get_protection_flags(struct kgsl_mmu *mmu, 116: struct kgsl_memdesc *memdesc) 117: { 118: int flags = IOMMU_READ | IOMMU_WRITE | IOMMU_NOEXEC; 119: 120: flags |= get_llcc_flags(mmu); 121: 122: if (memdesc->flags & KGSL_MEMFLAGS_GPUREADONLY) 123: flags &= ~IOMMU_WRITE; 124: 125: if (TEST_FLAG(KGSL_MEMDESC_PRIVILEGED, &memdesc->priv)) 126: flags |= IOMMU_PRIV; 127: 128: if (memdesc->flags & KGSL_MEMFLAGS_IOCOHERENT) 129: flags |= IOMMU_CACHE; 130: 131: if (TEST_FLAG(KGSL_MEMDESC_UCODE, &memdesc->priv)) 132: flags &= ~IOMMU_NOEXEC; 133: 134: return flags; 135: } 136: 137: /* Get a scattterlist for the subrange in the child memdesc */ 138: static int get_sg_from_child(struct sg_table *sgt, struct kgsl_memdesc *child, 139: u64 offset, u64 length) 140: { 141: int npages = (length >> PAGE_SHIFT); 142: int pgoffset = (offset >> PAGE_SHIFT); 143: struct scatterlist *target_sg; 144: struct sg_page_iter iter; 145: int i = 0, ret; 146: 147: if (child->pages) 148: return sg_alloc_table_from_pages(sgt, 149: child->pages + pgoffset, npages, 0, 150: length, GFP_KERNEL); 151: 152: ret = sg_alloc_table(sgt, npages, GFP_KERNEL); 153: if (ret) 154: return ret; 155: 156: target_sg = sgt->sgl; 157: 158: for_each_sgtable_page(child->sgt, &iter, pgoffset) { 159: sg_set_page(target_sg, sg_page_iter_page(&iter), PAGE_SIZE, 0); 160: target_sg = sg_next(target_sg); 161: 162: if (++i == npages) 163: break; 164: } 165: 166: return 0; 167: } 168: 169: static struct iommu_domain *to_iommu_domain(struct kgsl_iommu_context *context) 170: { 171: return context->domain; 172: } 173: 174: static struct kgsl_iommu *to_kgsl_iommu(struct kgsl_pagetable *pt) 175: { 176: return &pt->mmu->iommu; 177: } 178: 179: /* 180: * One page allocation for a guard region to protect against over-zealous 181: * GPU pre-fetch 182: */ 183: static struct page *kgsl_guard_page; 184: static struct page *kgsl_secure_guard_page; 185: 186: static struct page *iommu_get_guard_page(struct kgsl_memdesc *memdesc) 187: { 188: if (kgsl_memdesc_is_secured(memdesc)) { 189: if (!kgsl_secure_guard_page) 190: kgsl_secure_guard_page = kgsl_alloc_secure_page(); 191: 192: return kgsl_secure_guard_page; 193: } 194: 195: if (!kgsl_guard_page) 196: kgsl_guard_page = alloc_page(GFP_KERNEL | __GFP_ZERO | 197: __GFP_NORETRY | __GFP_HIGHMEM); 198: 199: return kgsl_guard_page; 200: } 201: 202: static size_t iommu_pgsize(unsigned long pgsize_bitmap, unsigned long iova, 203: phys_addr_t paddr, size_t size, size_t *count) 204: { 205: unsigned int pgsize_idx, pgsize_idx_next; 206: unsigned long pgsizes; 207: size_t offset, pgsize, pgsize_next; 208: unsigned long addr_merge = paddr | iova; 209: 210: /* Page sizes supported by the hardware and small enough for @size */ 211: pgsizes = pgsize_bitmap & GENMASK(__fls(size), 0); 212: 213: /* Constrain the page sizes further based on the maximum alignment */ 214: if (likely(addr_merge)) 215: pgsizes &= GENMASK(__ffs(addr_merge), 0); 216: 217: /* Make sure we have at least one suitable page size */ 218: if (!pgsizes) 219: return 0; 220: 221: /* Pick the biggest page size remaining */ 222: pgsize_idx = __fls(pgsizes); 223: pgsize = BIT(pgsize_idx); 224: if (!count) 225: return pgsize; 226: MATCH LINES: 257, 260, 262, 265, 266, 270, 273, 282, 300, 304, 316, 325, 340, 349, 363, 366, 370, 373, 374, 375, 384, 388, 391, 402, 404, 413, 420, 424, 436, 447, 451, 457, 458, 468, 475, 478, 483, 486, 489, 498, 502, 504, 507, 515, 518, 522, 533, 539, 555, 558, 562, 574, 581, 585, 588, 599, 609, 620, 624, 625, 628, 636, 639, 640, 642, 646, 647, 652, 655, 661, 665, 666, 669, 670, 671, 675, 677, 680, 683, 686, 690, 697, 700, 705, 709, 712, 713, 720, 723, 726, 730, 733, 735, 736, 737, 740, 743, 745, 747, 749, 756, 760, 761, 764, 766, 771, 774, 779, 781, 786, 789 245: /* 246: * If size is big enough to accommodate the larger page, reduce 247: * the number of smaller pages. 248: */ 249: if (offset + pgsize_next <= size) 250: size = offset; 251: 252: out_set_count: 253: *count = size >> pgsize_idx; 254: return pgsize; 255: } 256: 257: static void kgsl_iommu_flush_tlb(struct kgsl_mmu *mmu) 258: { 259: struct kgsl_device *device = KGSL_MMU_DEVICE(mmu); 260: struct kgsl_iommu *iommu = &mmu->iommu; 261: 262: iommu_flush_iotlb_all(to_iommu_domain(&iommu->user_context)); 263: 264: /* As LPAC is optional, check LPAC domain is present before flush */ 265: if (iommu->lpac_context.domain) 266: iommu_flush_iotlb_all(to_iommu_domain(&iommu->lpac_context)); 267: 268: /* Flush iotbl for GMU domian */ 269: if (device->gmu_core.domain) 270: iommu_flush_iotlb_all(device->gmu_core.domain); 271: } 272: 273: static int _iopgtbl_unmap(struct kgsl_iommu_pt *pt, u64 gpuaddr, size_t size) 274: { 275: struct io_pgtable_ops *ops = pt->pgtbl_ops; 276: size_t unmapped = 0; 277: 278: while (unmapped < size) { 279: size_t ret, size_to_unmap, remaining, pgcount; 280: 281: remaining = (size - unmapped); 282: size_to_unmap = iommu_pgsize(pt->cfg.pgsize_bitmap, 283: gpuaddr, gpuaddr, remaining, &pgcount); 284: if (size_to_unmap == 0) 285: break; 286: 287: ret = ops->unmap_pages(ops, gpuaddr, size_to_unmap, 288: pgcount, NULL); 289: 290: if (ret == 0) 291: break; 292: 293: gpuaddr += ret; 294: unmapped += ret; 295: } 296: 297: if (unmapped != size) 298: return -EINVAL; 299: 300: kgsl_iommu_flush_tlb(pt->base.mmu); 301: return 0; 302: } 303: 304: static size_t _iopgtbl_map_pages(struct kgsl_iommu_pt *pt, u64 gpuaddr, 305: struct page **pages, int npages, int prot) 306: { 307: struct io_pgtable_ops *ops = pt->pgtbl_ops; 308: size_t mapped = 0; 309: u64 addr = gpuaddr; 310: int ret, i; 311: 312: for (i = 0; i < npages; i++) { 313: ret = ops->map_pages(ops, addr, page_to_phys(pages[i]), PAGE_SIZE, 1, 314: prot, GFP_KERNEL, &mapped); 315: if (ret) { 316: _iopgtbl_unmap(pt, gpuaddr, mapped); 317: return 0; 318: } 319: addr += PAGE_SIZE; 320: } 321: 322: return mapped; 323: } 324: 325: static size_t _iopgtbl_map_sg(struct kgsl_iommu_pt *pt, u64 gpuaddr, 326: struct sg_table *sgt, int prot) 327: { 328: struct io_pgtable_ops *ops = pt->pgtbl_ops; 329: struct scatterlist *sg; 330: size_t mapped = 0; 331: u64 addr = gpuaddr; 332: int ret, i; 333: 334: for_each_sg(sgt->sgl, sg, sgt->nents, i) { 335: size_t size = sg->length; 336: phys_addr_t phys = sg_phys(sg); 337: 338: while (size) { 339: size_t count, map_size = 0; 340: size_t pgsize = iommu_pgsize(pt->cfg.pgsize_bitmap, 341: addr, phys, size, &count); 342: 343: ret = ops->map_pages(ops, addr, phys, pgsize, count, 344: prot, GFP_KERNEL, &map_size); 345: 346: mapped += map_size; 347: 348: if (ret) { 349: _iopgtbl_unmap(pt, gpuaddr, mapped); 350: return 0; 351: } 352: 353: addr += map_size; 354: phys += map_size; 355: size -= map_size; 356: } 357: 358: } 359: 360: return mapped; 361: } 362: 363: static void kgsl_iommu_send_tlb_hint(struct kgsl_mmu *mmu, bool hint) 364: { 365: struct kgsl_device *device = KGSL_MMU_DEVICE(mmu); 366: struct kgsl_iommu *iommu = &mmu->iommu; 367: 368: /* 369: * Send skip TLB hints for user context, LPAC context, and GMU domains 370: * to the SMMU driver to skip TLB operations during slumber. This will 371: * help avoid unnecessary CX GDSC toggling. 372: */ 373: qcom_skip_tlb_management(&iommu->user_context.pdev->dev, hint); 374: if (iommu->lpac_context.domain) 375: qcom_skip_tlb_management(&iommu->lpac_context.pdev->dev, hint); 376: if (device->gmu_core.domain) 377: qcom_skip_tlb_management(&device->gmu_core.pdev->dev, hint); 378: /* 379: * TLB operations are skipped during slumber. Incase CX doesn't 380: * go down, it can result in incorrect translations due to stale 381: * TLB entries. Flush TLB before boot up to ensure fresh start. 382: */ 383: if (!hint) 384: kgsl_iommu_flush_tlb(mmu); 385: } 386: 387: static int 388: kgsl_iopgtbl_map_child(struct kgsl_pagetable *pt, struct kgsl_memdesc *memdesc, 389: u64 offset, struct kgsl_memdesc *child, u64 child_offset, u64 length) 390: { 391: struct kgsl_iommu_pt *iommu_pt = to_iommu_pt(pt); 392: struct sg_table sgt; 393: u32 flags; 394: size_t mapped; 395: int ret; 396: 397: ret = get_sg_from_child(&sgt, child, child_offset, length); 398: if (ret) 399: return ret; 400: 401: /* Inherit the flags from the child for this mapping */ 402: flags = _iommu_get_protection_flags(pt->mmu, child); 403: 404: mapped = _iopgtbl_map_sg(iommu_pt, memdesc->gpuaddr + offset, &sgt, flags); 405: 406: sg_free_table(&sgt); 407: 408: return mapped ? 0 : -ENOMEM; 409: } 410: 411: 412: static int 413: kgsl_iopgtbl_unmap_range(struct kgsl_pagetable *pt, struct kgsl_memdesc *memdesc, 414: u64 offset, u64 length) 415: { 416: if (WARN_ON(offset >= memdesc->size || 417: (offset + length) > memdesc->size)) 418: return -ERANGE; 419: 420: return _iopgtbl_unmap(to_iommu_pt(pt), memdesc->gpuaddr + offset, 421: length); 422: } 423: 424: static size_t _iopgtbl_map_page_to_range(struct kgsl_iommu_pt *pt, 425: struct page *page, u64 gpuaddr, size_t range, int prot) 426: { 427: struct io_pgtable_ops *ops = pt->pgtbl_ops; 428: size_t mapped = 0; 429: u64 addr = gpuaddr; 430: int ret; 431: 432: while (range) { 433: ret = ops->map_pages(ops, addr, page_to_phys(page), PAGE_SIZE, 434: 1, prot, GFP_KERNEL, &mapped); 435: if (ret) { 436: _iopgtbl_unmap(pt, gpuaddr, mapped); 437: return 0; 438: } 439: 440: addr += PAGE_SIZE; 441: range -= PAGE_SIZE; 442: } 443: 444: return mapped; 445: } 446: 447: static int kgsl_iopgtbl_map_zero_page_to_range(struct kgsl_pagetable *pt, 448: struct kgsl_memdesc *memdesc, u64 offset, u64 length) 449: { 450: /* 451: * The SMMU only does the PRT compare at the bottom level of the page table, because 452: * there is not an easy way for the hardware to perform this check at earlier levels. 453: * Mark this page writable to avoid page faults while writing to it. Since the address 454: * of this zero page is programmed in PRR register, MMU will intercept any accesses to 455: * the page before they go to DDR and will terminate the transaction. 456: */ 457: u32 flags = IOMMU_READ | IOMMU_WRITE | IOMMU_NOEXEC | get_llcc_flags(pt->mmu); 458: struct kgsl_iommu_pt *iommu_pt = to_iommu_pt(pt); 459: struct page *page = kgsl_vbo_zero_page; 460: 461: if (WARN_ON(!page)) 462: return -ENODEV; 463: 464: if (WARN_ON((offset >= memdesc->size) || 465: (offset + length) > memdesc->size)) 466: return -ERANGE; 467: 468: if (!_iopgtbl_map_page_to_range(iommu_pt, page, memdesc->gpuaddr + offset, 469: length, flags)) 470: return -ENOMEM; 471: 472: return 0; 473: } 474: 475: static int kgsl_iopgtbl_map(struct kgsl_pagetable *pagetable, 476: struct kgsl_memdesc *memdesc) 477: { 478: struct kgsl_iommu_pt *pt = to_iommu_pt(pagetable); 479: size_t mapped, padding; 480: int prot; 481: 482: /* Get the protection flags for the user context */ 483: prot = _iommu_get_protection_flags(pagetable->mmu, memdesc); 484: 485: if (memdesc->sgt) 486: mapped = _iopgtbl_map_sg(pt, memdesc->gpuaddr, 487: memdesc->sgt, prot); 488: else 489: mapped = _iopgtbl_map_pages(pt, memdesc->gpuaddr, 490: memdesc->pages, memdesc->page_count, prot); 491: 492: if (mapped == 0) 493: return -ENOMEM; 494: 495: padding = kgsl_memdesc_footprint(memdesc) - mapped; 496: 497: if (padding) { 498: struct page *page = iommu_get_guard_page(memdesc); 499: size_t ret; 500: 501: if (page) 502: ret = _iopgtbl_map_page_to_range(pt, page, 503: memdesc->gpuaddr + mapped, padding, 504: prot & ~IOMMU_WRITE); 505: 506: if (!page || !ret) { 507: _iopgtbl_unmap(pt, memdesc->gpuaddr, mapped); 508: return -ENOMEM; 509: } 510: } 511: 512: return 0; 513: } 514: 515: static int kgsl_iopgtbl_unmap(struct kgsl_pagetable *pagetable, 516: struct kgsl_memdesc *memdesc) 517: { 518: return _iopgtbl_unmap(to_iommu_pt(pagetable), memdesc->gpuaddr, 519: kgsl_memdesc_footprint(memdesc)); 520: } 521: 522: static int _iommu_unmap(struct iommu_domain *domain, u64 addr, size_t size) 523: { 524: size_t unmapped = 0; 525: 526: if (!domain) 527: return 0; 528: 529: /* Sign extend TTBR1 addresses all the way to avoid warning */ 530: if (addr & (1ULL << 48)) 531: addr |= 0xffff000000000000; 532: 533: unmapped = iommu_unmap(domain, addr, size); 534: 535: return (unmapped == size) ? 0 : -ENOMEM; 536: } 537: 538: 539: static size_t _iommu_map_page_to_range(struct iommu_domain *domain, 540: struct page *page, u64 gpuaddr, size_t range, int prot) 541: { 542: size_t mapped = 0; 543: u64 addr = gpuaddr; 544: 545: if (!page) 546: return 0; 547: 548: /* Sign extend TTBR1 addresses all the way to avoid warning */ 549: if (gpuaddr & (1ULL << 48)) 550: gpuaddr |= 0xffff000000000000; 551: 552: 553: while (range) { 554: #if (KERNEL_VERSION(6, 2, 0) <= LINUX_VERSION_CODE) 555: int ret = iommu_map(domain, addr, page_to_phys(page), 556: PAGE_SIZE, prot, GFP_KERNEL); 557: #else 558: int ret = iommu_map(domain, addr, page_to_phys(page), 559: PAGE_SIZE, prot); 560: #endif 561: if (ret) { 562: iommu_unmap(domain, gpuaddr, mapped); 563: return 0; 564: } 565: 566: addr += PAGE_SIZE; 567: mapped += PAGE_SIZE; 568: range -= PAGE_SIZE; 569: } 570: 571: return mapped; 572: } 573: 574: static ssize_t _iommu_map_sg(struct iommu_domain *domain, u64 gpuaddr, 575: struct sg_table *sgt, int prot) 576: { 577: /* Sign extend TTBR1 addresses all the way to avoid warning */ 578: if (gpuaddr & (1ULL << 48)) 579: gpuaddr |= 0xffff000000000000; 580: 581: return kgsl_mmu_map_sg(domain, gpuaddr, sgt->sgl, sgt->orig_nents, prot); 582: } 583: 584: static int 585: _kgsl_iommu_map(struct kgsl_mmu *mmu, struct iommu_domain *domain, 586: struct kgsl_memdesc *memdesc) 587: { 588: int prot = _iommu_get_protection_flags(mmu, memdesc); 589: ssize_t mapped; 590: size_t padding; 591: int ret = 0; 592: 593: /* 594: * For paged memory allocated through kgsl, memdesc->pages is not NULL. 595: * Allocate sgt here just for its map operation. Contiguous memory 596: * already has its sgt, so no need to allocate it here. 597: */ 598: if (!memdesc->pages) { 599: mapped = _iommu_map_sg(domain, memdesc->gpuaddr, 600: memdesc->sgt, prot); 601: } else { 602: struct sg_table sgt; 603: 604: ret = sg_alloc_table_from_pages(&sgt, memdesc->pages, 605: memdesc->page_count, 0, memdesc->size, GFP_KERNEL); 606: if (ret) 607: return ret; 608: 609: mapped = _iommu_map_sg(domain, memdesc->gpuaddr, &sgt, prot); 610: sg_free_table(&sgt); 611: } 612: 613: /* Check for errors or no pages mapped */ 614: if (mapped <= 0) 615: return mapped ? mapped : -ENOMEM; 616: 617: padding = kgsl_memdesc_footprint(memdesc) - mapped; 618: 619: if (padding) { 620: struct page *page = iommu_get_guard_page(memdesc); 621: size_t guard_mapped; 622: 623: if (page) 624: guard_mapped = _iommu_map_page_to_range(domain, page, 625: memdesc->gpuaddr + mapped, padding, prot & ~IOMMU_WRITE); 626: 627: if (!page || !guard_mapped) { 628: _iommu_unmap(domain, memdesc->gpuaddr, mapped); 629: ret = -ENOMEM; 630: } 631: } 632: 633: return ret; 634: } 635: 636: static int kgsl_iommu_secure_map(struct kgsl_pagetable *pagetable, 637: struct kgsl_memdesc *memdesc) 638: { 639: struct kgsl_iommu *iommu = &pagetable->mmu->iommu; 640: struct iommu_domain *domain = to_iommu_domain(&iommu->secure_context); 641: 642: return _kgsl_iommu_map(pagetable->mmu, domain, memdesc); 643: } 644: 645: /* 646: * Return true if the address is in the TTBR0 region. This is used for cases 647: * when the "default" pagetable is used for both TTBR0 and TTBR1 648: */ 649: static bool is_lower_address(struct kgsl_mmu *mmu, u64 addr) 650: { 651: return (test_bit(KGSL_MMU_IOPGTABLE, &mmu->features) && 652: addr < KGSL_IOMMU_SPLIT_TABLE_BASE); 653: } 654: 655: static int _kgsl_iommu_unmap(struct iommu_domain *domain, 656: struct kgsl_memdesc *memdesc) 657: { 658: if (memdesc->size == 0 || memdesc->gpuaddr == 0) 659: return -EINVAL; 660: 661: return _iommu_unmap(domain, memdesc->gpuaddr, 662: kgsl_memdesc_footprint(memdesc)); 663: } 664: 665: /* Map on the default pagetable and the LPAC pagetable if it exists */ 666: static int kgsl_iommu_default_map(struct kgsl_pagetable *pagetable, 667: struct kgsl_memdesc *memdesc) 668: { 669: struct kgsl_mmu *mmu = pagetable->mmu; 670: struct kgsl_iommu *iommu = &mmu->iommu; 671: struct iommu_domain *domain, *lpac; 672: int ret; 673: 674: if (is_lower_address(mmu, memdesc->gpuaddr)) 675: return kgsl_iopgtbl_map(pagetable, memdesc); 676: 677: domain = to_iommu_domain(&iommu->user_context); 678: 679: /* Map the object to the default GPU domain */ 680: ret = _kgsl_iommu_map(mmu, domain, memdesc); 681: 682: /* Also map the object to the LPAC domain if it exists */ 683: lpac = to_iommu_domain(&iommu->lpac_context); 684: 685: if (!ret && lpac) { 686: ret = _kgsl_iommu_map(mmu, lpac, memdesc); 687: 688: /* On failure, also unmap from the default domain */ 689: if (ret) 690: _kgsl_iommu_unmap(domain, memdesc); 691: 692: } 693: 694: return ret; 695: } 696: 697: static int kgsl_iommu_secure_unmap(struct kgsl_pagetable *pagetable, 698: struct kgsl_memdesc *memdesc) 699: { 700: struct kgsl_iommu *iommu = &pagetable->mmu->iommu; 701: 702: if (memdesc->size == 0 || memdesc->gpuaddr == 0) 703: return -EINVAL; 704: 705: return _kgsl_iommu_unmap(to_iommu_domain(&iommu->secure_context), 706: memdesc); 707: } 708: 709: static int kgsl_iommu_default_unmap(struct kgsl_pagetable *pagetable, 710: struct kgsl_memdesc *memdesc) 711: { 712: struct kgsl_mmu *mmu = pagetable->mmu; 713: struct kgsl_iommu *iommu = &mmu->iommu; 714: int ret; 715: 716: if (memdesc->size == 0 || memdesc->gpuaddr == 0) 717: return -EINVAL; 718: 719: if (is_lower_address(mmu, memdesc->gpuaddr)) 720: return kgsl_iopgtbl_unmap(pagetable, memdesc); 721: 722: /* Unmap from the default domain */ 723: ret = _kgsl_iommu_unmap(to_iommu_domain(&iommu->user_context), memdesc); 724: 725: /* Unmap from the LPAC domain if it exists */ 726: ret |= _kgsl_iommu_unmap(to_iommu_domain(&iommu->lpac_context), memdesc); 727: return ret; 728: } 729: 730: static bool kgsl_iommu_addr_is_global(struct kgsl_mmu *mmu, u64 addr) 731: { 732: if (test_bit(KGSL_MMU_IOPGTABLE, &mmu->features)) 733: return (addr >= KGSL_IOMMU_SPLIT_TABLE_BASE); 734: 735: return ((addr >= KGSL_IOMMU_GLOBAL_MEM_BASE(mmu)) && 736: (addr < KGSL_IOMMU_GLOBAL_MEM_BASE(mmu) + 737: KGSL_IOMMU_GLOBAL_MEM_SIZE)); 738: } 739: 740: static void __iomem *kgsl_iommu_reg(struct kgsl_iommu_context *ctx, 741: u32 offset) 742: { 743: struct kgsl_iommu *iommu = KGSL_IOMMU(ctx->kgsldev); 744: 745: if (!iommu->cb0_offset) { 746: u32 reg = 747: readl_relaxed(iommu->regbase + KGSL_IOMMU_IDR1_OFFSET); 748: 749: iommu->pagesize = 750: FIELD_GET(IDR1_PAGESIZE, reg) ? SZ_64K : SZ_4K; 751: 752: /* 753: * The number of pages in the global address space or 754: * translation bank address space is 2^(NUMPAGENDXB + 1). 755: */ 756: iommu->cb0_offset = iommu->pagesize * 757: (1 << (FIELD_GET(IDR1_NUMPAGENDXB, reg) + 1)); 758: } 759: 760: return (void __iomem *) (iommu->regbase + iommu->cb0_offset + 761: (ctx->cb_num * iommu->pagesize) + offset); 762: } 763: 764: static u64 KGSL_IOMMU_GET_CTX_REG_Q(struct kgsl_iommu_context *ctx, u32 offset) 765: { 766: void __iomem *addr = kgsl_iommu_reg(ctx, offset); 767: 768: return readq_relaxed(addr); 769: } 770: 771: static void KGSL_IOMMU_SET_CTX_REG(struct kgsl_iommu_context *ctx, u32 offset, 772: u32 val) 773: { 774: void __iomem *addr = kgsl_iommu_reg(ctx, offset); 775: 776: writel_relaxed(val, addr); 777: } 778: 779: static u32 KGSL_IOMMU_GET_CTX_REG(struct kgsl_iommu_context *ctx, u32 offset) 780: { 781: void __iomem *addr = kgsl_iommu_reg(ctx, offset); 782: 783: return readl_relaxed(addr); 784: } 785: 786: static int kgsl_iommu_get_gpuaddr(struct kgsl_pagetable *pagetable, 787: struct kgsl_memdesc *memdesc); 788: 789: #define KGSL_GLOBAL_MEM_PAGES (KGSL_IOMMU_GLOBAL_MEM_SIZE >> PAGE_SHIFT) 790: 791: static u64 global_get_offset(struct kgsl_device *device, u64 size, 792: atomic_t *priv) 793: { 794: int start = 0, bit; 795: 796: if (!device->global_map) { 797: device->global_map = 798: kcalloc(BITS_TO_LONGS(KGSL_GLOBAL_MEM_PAGES), 799: sizeof(unsigned long), GFP_KERNEL); 800: if (!device->global_map) 801: return (unsigned long) -ENOMEM; 802: } 803: 804: if (TEST_FLAG(KGSL_MEMDESC_RANDOM, priv)) { 805: u32 offset = KGSL_GLOBAL_MEM_PAGES - (size >> PAGE_SHIFT); 806: 807: start = get_random_u32() % offset; 808: } 809: 810: while (start >= 0) { 811: bit = bitmap_find_next_zero_area(device->global_map, 812: KGSL_GLOBAL_MEM_PAGES, start, size >> PAGE_SHIFT, 0); 813: MATCH LINES: 832, 842, 854, 859, 863, 868, 870, 895, 896, 914, 917, 922, 923, 937, 950, 952, 954, 956, 959, 968, 976, 977, 979, 980, 981, 991, 995, 996, 1001, 1002, 1028, 1037, 1038, 1039, 1040, 1041, 1044, 1045, 1046, 1047, 1048, 1051, 1054, 1055, 1077, 1079, 1081, 1083, 1085, 1090, 1106, 1108, 1110, 1111, 1112, 1116, 1120, 1123, 1130, 1163, 1165, 1170, 1202, 1203, 1207, 1212, 1213, 1215, 1216, 1218, 1222, 1224, 1233, 1234, 1235, 1247, 1255, 1258, 1261, 1265, 1269, 1271, 1275, 1279, 1280, 1283, 1284, 1290, 1294, 1298, 1300, 1305, 1306, 1308, 1310, 1311, 1313, 1319, 1321, 1323, 1324, 1326, 1327, 1328, 1332, 1333, 1335, 1337, 1338, 1340, 1341, 1343, 1344, 1345, 1347, 1349, 1352, 1353, 1355, 1358, 1361, 1362, 1365, 1373, 1375, 1377, 1378, 1379, 1380, 1383, 1385, 1386, 1389, 1391, 1393, 1396, 1398, 1399, 1402, 1404, 1406, 1409, 1411, 1412, 1419, 1425, 1427, 1433, 1438, 1440, 1443, 1447, 1449, 1452, 1454, 1457, 1459, 1462, 1468, 1469, 1473, 1476, 1478, 1481, 1487, 1489, 1491, 1492, 1498, 1499, 1504, 1508, 1510, 1516, 1518, 1522, 1524, 1526, 1527, 1533, 1540, 1545, 1547, 1548, 1551, 1552, 1555, 1557, 1558, 1559, 1562, 1563, 1564, 1565, 1568, 1569, 1570, 1571, 1575, 1577, 1578, 1581, 1584, 1585, 1588, 1590, 1594, 1595, 1600, 1602, 1607, 1608, 1611, 1612, 1613, 1614, 1616, 1617, 1618, 1619, 1621, 1622, 1625, 1631, 1633, 1634, 1641, 1645, 1648, 1649, 1650, 1651, 1654, 1655, 1657, 1658, 1662, 1663, 1666, 1667, 1674, 1675, 1678, 1681, 1687, 1691, 1694, 1696, 1697, 1701, 1703, 1705, 1709, 1712, 1717, 1722, 1723, 1732, 1734, 1736, 1737, 1739, 1742, 1747, 1748, 1750, 1751, 1754, 1755, 1756, 1766, 1767, 1768, 1769, 1770, 1771, 1772, 1779, 1780, 1782, 1797, 1800, 1802, 1803, 1804, 1810, 1812, 1832, 1835, 1836, 1838, 1839, 1842, 1843, 1845, 1848, 1853, 1860, 1862, 1867, 1870, 1877, 1880, 1882, 1884, 1890, 1892, 1896, 1898, 1901, 1902, 1903, 1906, 1910, 1914, 1918, 1919, 1922, 1924, 1929, 1933, 1935, 1938, 1940, 1941, 1942, 1943, 1945, 1946, 1952, 1954, 1956, 1960, 1962, 1964, 1965, 1966, 1970, 1972, 1976, 1977, 1978, 1980, 1984, 1991, 1995, 2000, 2001, 2002, 2009, 2015, 2017, 2019, 2021, 2022, 2025, 2036, 2040, 2045, 2046, 2047, 2060, 2069, 2071, 2079, 2081, 2083, 2085, 2086, 2090, 2093, 2094, 2098, 2111, 2112, 2113, 2118, 2125, 2126, 2129, 2137, 2139, 2140, 2141, 2143, 2147, 2150, 2152, 2154, 2155, 2160, 2161, 2163, 2166, 2167, 2180, 2183, 2185, 2194, 2195, 2197, 2199, 2201, 2202, 2205, 2210, 2214, 2223, 2226, 2229, 2244, 2249, 2255, 2259, 2263, 2274, 2278, 2286, 2291, 2297, 2298 820: */ 821: start--; 822: } 823: 824: if (WARN_ON(start < 0)) 825: return (unsigned long) -ENOMEM; 826: 827: bitmap_set(device->global_map, bit, size >> PAGE_SHIFT); 828: 829: return bit << PAGE_SHIFT; 830: } 831: 832: static int kgsl_iommu_reserve_global_gpuaddr(struct kgsl_mmu *mmu, 833: struct kgsl_memdesc *memdesc, u32 padding) 834: { 835: struct kgsl_device *device = KGSL_MMU_DEVICE(mmu); 836: u64 offset; 837: 838: if (memdesc->gpuaddr) 839: return -EINVAL; 840: 841: if (memdesc->flags & KGSL_MEMFLAGS_SECURE) { 842: int ret = kgsl_iommu_get_gpuaddr(mmu->securepagetable, memdesc); 843: 844: WARN_ON(ret); 845: 846: return ret; 847: } 848: 849: offset = global_get_offset(device, memdesc->size + padding, &memdesc->priv); 850: 851: if (IS_ERR_VALUE(offset)) 852: return -ENOSPC; 853: 854: memdesc->gpuaddr = mmu->defaultpagetable->global_base + offset; 855: 856: return 0; 857: } 858: 859: static void kgsl_iommu_map_global(struct kgsl_mmu *mmu, 860: struct kgsl_memdesc *memdesc, u32 padding) 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: { 898: uint64_t gpuaddr = addr; 899: uint64_t size = 0; 900: uint64_t flags = 0; 901: char name[32]; 902: pid_t pid; 903: 904: if (!kgsl_memfree_find_entry(ptname, &gpuaddr, &size, &flags, &pid)) 905: return; 906: 907: kgsl_get_memory_usage(name, sizeof(name), flags); 908: 909: dev_err(dev, "---- premature free ----\n"); 910: dev_err(dev, "[%8.8llX-%8.8llX] (%s) was already freed by pid %d\n", 911: gpuaddr, gpuaddr + size, name, pid); 912: } 913: 914: static struct kgsl_process_private *kgsl_iommu_get_process(u64 ptbase) 915: { 916: struct kgsl_process_private *p; 917: struct kgsl_iommu_pt *iommu_pt; 918: 919: read_lock(&kgsl_driver.proclist_lock); 920: 921: list_for_each_entry(p, &kgsl_driver.process_list, list) { 922: iommu_pt = to_iommu_pt(p->pagetable); 923: if (iommu_pt->ttbr0 == MMU_SW_PT_BASE(ptbase)) { 924: if (!kgsl_process_private_get(p)) 925: p = NULL; 926: 927: read_unlock(&kgsl_driver.proclist_lock); 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 */ 1027: for (new_idx = 0; new_idx < cur_idx; new_idx++) { 1028: if (iommu->pf_procs[new_idx].pf_count < proc_priv->pf_count) 1029: break; 1030: } 1031: 1032: /* Check if the current process is already at its correct position */ 1033: if (new_idx == cur_idx) 1034: goto unlock; 1035: 1036: /* Swap the two entries */ 1037: iommu->pf_procs[cur_idx].pf_count = iommu->pf_procs[new_idx].pf_count; 1038: memcpy(iommu->pf_procs[cur_idx].pf_type_counts, iommu->pf_procs[new_idx].pf_type_counts, 1039: sizeof(iommu->pf_procs[cur_idx].pf_type_counts)); 1040: strscpy(iommu->pf_procs[cur_idx].comm, iommu->pf_procs[new_idx].comm, 1041: sizeof(iommu->pf_procs[cur_idx].comm)); 1042: 1043: write_new_idx: 1044: iommu->pf_procs[new_idx].pf_count = proc_priv->pf_count; 1045: memcpy(iommu->pf_procs[new_idx].pf_type_counts, proc_priv->pf_type_counts, 1046: sizeof(iommu->pf_procs[new_idx].pf_type_counts)); 1047: strscpy(iommu->pf_procs[new_idx].comm, proc_priv->comm, 1048: sizeof(iommu->pf_procs[new_idx].comm)); 1049: 1050: unlock: 1051: write_unlock(&iommu->pf_stats_lock); 1052: } 1053: 1054: static void kgsl_iommu_print_fault(struct kgsl_mmu *mmu, 1055: struct kgsl_iommu_context *ctxt, unsigned long addr, 1056: u64 ptbase, u32 contextid, 1057: int flags, struct kgsl_process_private *private, 1058: struct kgsl_context *context) 1059: { 1060: struct kgsl_device *device = KGSL_MMU_DEVICE(mmu); 1061: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1062: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 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) { 1145: if (!prev || prev->memdesc.gpuaddr < cur) 1146: prev = entry; 1147: } 1148: 1149: if (cur > addr) { 1150: if (!next || next->memdesc.gpuaddr > cur) 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); 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; 1366: struct kgsl_device *device = KGSL_MMU_DEVICE(mmu); 1367: 1368: /* Quietly return if the context doesn't have a domain */ 1369: if (!context->domain) 1370: return; 1371: 1372: if (of_device_is_compatible(device->pdev->dev.of_node, "qcom,adreno")) 1373: adreno_smmu = kgsl_get_prvdata(device->dev); 1374: else 1375: adreno_smmu = dev_get_drvdata(&context->pdev->dev); 1376: 1377: /* Enable CX and clocks before we call into SMMU to setup registers */ 1378: kgsl_iommu_enable_clk(mmu); 1379: adreno_smmu->set_ttbr0_cfg(adreno_smmu->cookie, pgtbl_cfg); 1380: kgsl_iommu_disable_clk(mmu); 1381: } 1382: 1383: static int kgsl_iommu_get_context_bank(struct kgsl_pagetable *pt, struct kgsl_context *context) 1384: { 1385: struct kgsl_iommu *iommu = to_kgsl_iommu(pt); 1386: struct iommu_domain *domain; 1387: 1388: if (kgsl_context_is_lpac(context)) 1389: domain = to_iommu_domain(&iommu->lpac_context); 1390: else 1391: domain = to_iommu_domain(&iommu->user_context); 1392: 1393: return qcom_iommu_get_context_bank_nr(domain); 1394: } 1395: 1396: static int kgsl_iommu_get_asid(struct kgsl_pagetable *pt, struct kgsl_context *context) 1397: { 1398: struct kgsl_iommu *iommu = to_kgsl_iommu(pt); 1399: struct iommu_domain *domain; 1400: 1401: if (kgsl_context_is_lpac(context)) 1402: domain = to_iommu_domain(&iommu->lpac_context); 1403: else 1404: domain = to_iommu_domain(&iommu->user_context); 1405: 1406: return qcom_iommu_get_asid_nr(domain); 1407: } 1408: 1409: static void kgsl_iommu_destroy_default_pagetable(struct kgsl_pagetable *pagetable) 1410: { 1411: struct kgsl_device *device = KGSL_MMU_DEVICE(pagetable->mmu); 1412: struct kgsl_iommu_pt *pt = to_iommu_pt(pagetable); 1413: struct kgsl_global_memdesc *md; 1414: 1415: list_for_each_entry(md, &device->globals, node) { 1416: if (md->memdesc.flags & KGSL_MEMFLAGS_SECURE) 1417: continue; 1418: 1419: kgsl_iommu_default_unmap(pagetable, &md->memdesc); 1420: } 1421: 1422: kfree(pt); 1423: } 1424: 1425: static void kgsl_iommu_destroy_pagetable(struct kgsl_pagetable *pagetable) 1426: { 1427: struct kgsl_iommu_pt *pt = to_iommu_pt(pagetable); 1428: 1429: free_io_pgtable_ops(pt->pgtbl_ops); 1430: kfree(pt); 1431: } 1432: 1433: static void _enable_gpuhtw_llc(struct kgsl_mmu *mmu, struct iommu_domain *domain) 1434: { 1435: if (!test_bit(KGSL_MMU_LLCC_ENABLE, &mmu->features)) 1436: return; 1437: 1438: if (mmu->subtype == KGSL_IOMMU_SMMU_V500) { 1439: if (!test_bit(KGSL_MMU_IO_COHERENT, &mmu->features)) 1440: iommu_set_pgtable_quirks(domain, 1441: IO_PGTABLE_QUIRK_QCOM_USE_LLC_NWA); 1442: } else 1443: iommu_set_pgtable_quirks(domain, IO_PGTABLE_QUIRK_ARM_OUTER_WBWA); 1444: } 1445: 1446: #if (KERNEL_VERSION(6, 13, 0) <= LINUX_VERSION_CODE) || !defined(CONFIG_QCOM_SCM_ADDON) 1447: static int _kgsl_set_smmu_aperture(u32 num_context_bank) 1448: { 1449: return qcom_scm_set_gpu_smmu_aperture(num_context_bank); 1450: } 1451: 1452: static bool _kgsl_smmu_aperture_scm_available(void) 1453: { 1454: return qcom_scm_is_available() && qcom_scm_set_gpu_smmu_aperture_is_available(); 1455: } 1456: #else 1457: static int _kgsl_set_smmu_aperture(u32 num_context_bank) 1458: { 1459: return qcom_scm_kgsl_set_smmu_aperture(num_context_bank); 1460: } 1461: 1462: static bool _kgsl_smmu_aperture_scm_available(void) 1463: { 1464: return true; 1465: } 1466: #endif 1467: 1468: static int kgsl_set_smmu_aperture(struct kgsl_device *device, 1469: struct kgsl_iommu_context *context) 1470: { 1471: int ret; 1472: 1473: if (!test_bit(KGSL_MMU_SMMU_APERTURE, &device->mmu.features)) 1474: return 0; 1475: 1476: ret = _kgsl_set_smmu_aperture(context->cb_num); 1477: if (ret == -EBUSY) 1478: ret = _kgsl_set_smmu_aperture(context->cb_num); 1479: 1480: if (ret) 1481: dev_err(&device->pdev->dev, "Unable to set the SMMU aperture: %d. The aperture needs to be set to use per-process pagetables\n", 1482: ret); 1483: 1484: return ret; 1485: } 1486: 1487: static void kgsl_iommu_enable_ptwalk(struct kgsl_iommu_context *context) 1488: { 1489: u32 tcr = KGSL_IOMMU_GET_CTX_REG(context, KGSL_IOMMU_CTX_TCR_LPAE); 1490: 1491: tcr &= ~(KGSL_IOMMU_TCR_LPAE_EPD0 | KGSL_IOMMU_TCR_LPAE_EPD1); 1492: KGSL_IOMMU_SET_CTX_REG(context, KGSL_IOMMU_CTX_TCR_LPAE, tcr); 1493: 1494: /* Make sure all of the preceding writes have posted */ 1495: wmb(); 1496: } 1497: 1498: static int kgsl_set_smmu_lpac_aperture(struct kgsl_device *device, 1499: struct kgsl_iommu_context *context) 1500: { 1501: int ret; 1502: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1503: 1504: if (!test_bit(KGSL_MMU_SMMU_APERTURE, &device->mmu.features) || 1505: !ADRENO_FEATURE(adreno_dev, ADRENO_LPAC)) 1506: return 0; 1507: 1508: ret = qcom_scm_kgsl_set_smmu_lpac_aperture(context->cb_num); 1509: if (ret == -EBUSY) 1510: ret = qcom_scm_kgsl_set_smmu_lpac_aperture(context->cb_num); 1511: 1512: return ret; 1513: } 1514: 1515: /* FIXME: better name feor this function */ 1516: static int kgsl_iopgtbl_alloc(struct kgsl_iommu_context *ctx, struct kgsl_iommu_pt *pt) 1517: { 1518: struct adreno_smmu_priv *adreno_smmu; 1519: const struct io_pgtable_cfg *cfg = NULL; 1520: 1521: if (of_device_is_compatible(ctx->kgsldev->pdev->dev.of_node, "qcom,adreno")) 1522: adreno_smmu = kgsl_get_prvdata(ctx->kgsldev->dev); 1523: else 1524: adreno_smmu = dev_get_drvdata(&ctx->pdev->dev); 1525: 1526: if (adreno_smmu->cookie) 1527: cfg = adreno_smmu->get_ttbr1_cfg(adreno_smmu->cookie); 1528: if (!cfg) 1529: return -ENODEV; 1530: 1531: pt->cfg = *cfg; 1532: pt->cfg.quirks &= ~IO_PGTABLE_QUIRK_ARM_TTBR1; 1533: pt->cfg.tlb = &kgsl_iopgtbl_tlb_ops; 1534: 1535: pt->pgtbl_ops = alloc_io_pgtable_ops(ARM_64_LPAE_S1, &pt->cfg, NULL); 1536: 1537: if (!pt->pgtbl_ops) 1538: return -ENOMEM; 1539: 1540: pt->ttbr0 = pt->cfg.arm_lpae_s1_cfg.ttbr; 1541: 1542: return 0; 1543: } 1544: 1545: static struct kgsl_pagetable *kgsl_iommu_default_pagetable(struct kgsl_mmu *mmu) 1546: { 1547: struct kgsl_iommu *iommu = &mmu->iommu; 1548: struct kgsl_iommu_pt *iommu_pt; 1549: int ret; 1550: 1551: iommu_pt = kzalloc(sizeof(*iommu_pt), GFP_KERNEL); 1552: if (!iommu_pt) 1553: return ERR_PTR(-ENOMEM); 1554: 1555: kgsl_mmu_pagetable_init(mmu, &iommu_pt->base, KGSL_MMU_GLOBAL_PT); 1556: 1557: iommu_pt->base.fault_addr = U64_MAX; 1558: iommu_pt->base.rbtree = RB_ROOT; 1559: iommu_pt->base.pt_ops = &default_pt_ops; 1560: 1561: if (test_bit(KGSL_MMU_64BIT, &mmu->features)) { 1562: iommu_pt->base.compat_va_start = KGSL_IOMMU_SVM_BASE32(mmu); 1563: iommu_pt->base.compat_va_end = KGSL_IOMMU_SVM_END32(mmu); 1564: iommu_pt->base.va_start = KGSL_IOMMU_VA_BASE64; 1565: iommu_pt->base.va_end = KGSL_IOMMU_VA_END64; 1566: 1567: } else { 1568: iommu_pt->base.va_start = KGSL_IOMMU_SVM_BASE32(mmu); 1569: iommu_pt->base.va_end = KGSL_IOMMU_GLOBAL_MEM_BASE(mmu); 1570: iommu_pt->base.compat_va_start = iommu_pt->base.va_start; 1571: iommu_pt->base.compat_va_end = iommu_pt->base.va_end; 1572: } 1573: 1574: if (!test_bit(KGSL_MMU_IOPGTABLE, &mmu->features)) { 1575: iommu_pt->base.global_base = KGSL_IOMMU_GLOBAL_MEM_BASE(mmu); 1576: 1577: kgsl_mmu_pagetable_add(mmu, &iommu_pt->base); 1578: return &iommu_pt->base; 1579: } 1580: 1581: iommu_pt->base.global_base = KGSL_IOMMU_SPLIT_TABLE_BASE; 1582: 1583: /* 1584: * Set up a "default' TTBR0 for the pagetable - this would only be used 1585: * in cases when the per-process pagetable allocation failed for some 1586: * reason 1587: */ 1588: ret = kgsl_iopgtbl_alloc(&iommu->user_context, iommu_pt); 1589: if (ret) { 1590: kfree(iommu_pt); 1591: return ERR_PTR(ret); 1592: } 1593: 1594: kgsl_mmu_pagetable_add(mmu, &iommu_pt->base); 1595: return &iommu_pt->base; 1596: 1597: } 1598: 1599: #if IS_ENABLED(CONFIG_QCOM_SECURE_BUFFER) 1600: static struct kgsl_pagetable *kgsl_iommu_secure_pagetable(struct kgsl_mmu *mmu) 1601: { 1602: struct kgsl_iommu_pt *iommu_pt; 1603: 1604: if (!mmu->secured) 1605: return ERR_PTR(-EPERM); 1606: 1607: iommu_pt = kzalloc(sizeof(*iommu_pt), GFP_KERNEL); 1608: if (!iommu_pt) 1609: return ERR_PTR(-ENOMEM); 1610: 1611: kgsl_mmu_pagetable_init(mmu, &iommu_pt->base, KGSL_MMU_SECURE_PT); 1612: iommu_pt->base.fault_addr = U64_MAX; 1613: iommu_pt->base.rbtree = RB_ROOT; 1614: iommu_pt->base.pt_ops = &secure_pt_ops; 1615: 1616: iommu_pt->base.compat_va_start = KGSL_IOMMU_SECURE_BASE32; 1617: iommu_pt->base.compat_va_end = KGSL_IOMMU_SECURE_END32; 1618: iommu_pt->base.va_start = KGSL_IOMMU_SECURE_BASE(mmu); 1619: iommu_pt->base.va_end = KGSL_IOMMU_SECURE_END(mmu); 1620: 1621: kgsl_mmu_pagetable_add(mmu, &iommu_pt->base); 1622: return &iommu_pt->base; 1623: } 1624: #else 1625: static struct kgsl_pagetable *kgsl_iommu_secure_pagetable(struct kgsl_mmu *mmu) 1626: { 1627: return ERR_PTR(-EPERM); 1628: } 1629: #endif 1630: 1631: static struct kgsl_pagetable *kgsl_iopgtbl_pagetable(struct kgsl_mmu *mmu, u32 name) 1632: { 1633: struct kgsl_iommu *iommu = &mmu->iommu; 1634: struct kgsl_iommu_pt *pt; 1635: int ret; 1636: 1637: pt = kzalloc(sizeof(*pt), GFP_KERNEL); 1638: if (!pt) 1639: return ERR_PTR(-ENOMEM); 1640: 1641: kgsl_mmu_pagetable_init(mmu, &pt->base, name); 1642: 1643: pt->base.fault_addr = U64_MAX; 1644: pt->base.rbtree = RB_ROOT; 1645: pt->base.pt_ops = &iopgtbl_pt_ops; 1646: 1647: if (test_bit(KGSL_MMU_64BIT, &mmu->features)) { 1648: pt->base.compat_va_start = KGSL_IOMMU_SVM_BASE32(mmu); 1649: pt->base.compat_va_end = KGSL_IOMMU_SVM_END32(mmu); 1650: pt->base.va_start = KGSL_IOMMU_VA_BASE64; 1651: pt->base.va_end = KGSL_IOMMU_VA_END64; 1652: 1653: if (is_compat_task()) { 1654: pt->base.svm_start = KGSL_IOMMU_SVM_BASE32(mmu); 1655: pt->base.svm_end = KGSL_IOMMU_SVM_END32(mmu); 1656: } else { 1657: pt->base.svm_start = KGSL_IOMMU_SVM_BASE64; 1658: pt->base.svm_end = KGSL_IOMMU_SVM_END64; 1659: } 1660: 1661: } else { 1662: pt->base.va_start = KGSL_IOMMU_SVM_BASE32(mmu); 1663: pt->base.va_end = KGSL_IOMMU_GLOBAL_MEM_BASE(mmu); 1664: pt->base.compat_va_start = pt->base.va_start; 1665: pt->base.compat_va_end = pt->base.va_end; 1666: pt->base.svm_start = KGSL_IOMMU_SVM_BASE32(mmu); 1667: pt->base.svm_end = KGSL_IOMMU_SVM_END32(mmu); 1668: } 1669: 1670: /* 1671: * We expect the 64-bit SVM and non-SVM ranges not to overlap so that 1672: * va_hint points to VA space at the top of the 64-bit non-SVM range. 1673: */ 1674: BUILD_BUG_ON_MSG(!((KGSL_IOMMU_VA_BASE64 >= KGSL_IOMMU_SVM_END64) || 1675: (KGSL_IOMMU_SVM_BASE64 >= KGSL_IOMMU_VA_END64)), 1676: "64-bit SVM and non-SVM ranges should not overlap"); 1677: 1678: /* Set up the hint for 64-bit non-SVM VA on per-process pagetables */ 1679: pt->base.va_hint = pt->base.va_start; 1680: 1681: ret = kgsl_iopgtbl_alloc(&iommu->user_context, pt); 1682: if (ret) { 1683: kfree(pt); 1684: return ERR_PTR(ret); 1685: } 1686: 1687: kgsl_mmu_pagetable_add(mmu, &pt->base); 1688: return &pt->base; 1689: } 1690: 1691: static struct kgsl_pagetable *kgsl_iommu_getpagetable(struct kgsl_mmu *mmu, 1692: unsigned long name) 1693: { 1694: struct kgsl_pagetable *pt; 1695: 1696: /* If we already know the pagetable, return it */ 1697: pt = kgsl_get_pagetable(name); 1698: if (pt) 1699: return pt; 1700: 1701: /* If io-pgtables are not in effect, just use the default pagetable */ 1702: if (!test_bit(KGSL_MMU_IOPGTABLE, &mmu->features)) 1703: return mmu->defaultpagetable; 1704: 1705: pt = kgsl_iopgtbl_pagetable(mmu, name); 1706: 1707: /* 1708: * If the io-pgtable allocation didn't work then fall back to the 1709: * default pagetable for this cycle 1710: */ 1711: if (!pt) 1712: return mmu->defaultpagetable; 1713: 1714: return pt; 1715: } 1716: 1717: static void kgsl_iommu_detach_context(struct kgsl_iommu_context *context) 1718: { 1719: if (!context->domain) 1720: return; 1721: 1722: kgsl_detach_iommu_group(context->domain, context->group); 1723: iommu_domain_free(context->domain); 1724: 1725: context->domain = NULL; 1726: 1727: platform_device_put(context->pdev); 1728: 1729: context->pdev = NULL; 1730: } 1731: 1732: static void kgsl_iommu_close(struct kgsl_mmu *mmu) 1733: { 1734: struct kgsl_iommu *iommu = &mmu->iommu; 1735: 1736: /* First put away the default pagetables */ 1737: kgsl_mmu_putpagetable(mmu->defaultpagetable); 1738: 1739: kgsl_mmu_putpagetable(mmu->securepagetable); 1740: 1741: /* 1742: * Flush the workqueue to ensure pagetables are 1743: * destroyed before proceeding further 1744: */ 1745: flush_workqueue(kgsl_driver.workqueue); 1746: 1747: mmu->defaultpagetable = NULL; 1748: mmu->securepagetable = NULL; 1749: 1750: kgsl_iommu_set_ttbr0(&iommu->lpac_context, mmu, NULL); 1751: kgsl_iommu_set_ttbr0(&iommu->user_context, mmu, NULL); 1752: 1753: /* Next, detach the context banks */ 1754: kgsl_iommu_detach_context(&iommu->user_context); 1755: kgsl_iommu_detach_context(&iommu->lpac_context); 1756: kgsl_iommu_detach_context(&iommu->secure_context); 1757: 1758: kgsl_free_secure_page(kgsl_secure_guard_page); 1759: kgsl_secure_guard_page = NULL; 1760: 1761: if (kgsl_guard_page != NULL) { 1762: __free_page(kgsl_guard_page); 1763: kgsl_guard_page = NULL; 1764: } 1765: 1766: if (iommu->smmu_vir_cx_pd && pm_runtime_enabled(iommu->smmu_vir_cx_pd)) { 1767: pm_runtime_disable(iommu->smmu_vir_cx_pd); 1768: dev_pm_domain_detach(iommu->smmu_vir_cx_pd, false); 1769: kfree(iommu->smmu_vir_cx_pd); 1770: iommu->smmu_vir_cx_pd = NULL; 1771: } else if (pm_runtime_enabled(&iommu->pdev->dev)) 1772: pm_runtime_disable(&iommu->pdev->dev); 1773: 1774: kmem_cache_destroy(addr_entry_cache); 1775: addr_entry_cache = NULL; 1776: } 1777: 1778: /* Program the PRR marker and enable it in the ACTLR register */ 1779: static void _iommu_context_set_prr(struct kgsl_mmu *mmu, 1780: struct kgsl_iommu_context *ctx) 1781: { 1782: struct kgsl_iommu *iommu = &mmu->iommu; 1783: struct page *page = kgsl_vbo_zero_page; 1784: u32 val; 1785: 1786: if (ctx->cb_num < 0) 1787: return; 1788: 1789: /* Quietly return if the context doesn't have a domain */ 1790: if (!ctx->domain) 1791: return; 1792: 1793: if (!page) 1794: return; 1795: 1796: writel_relaxed(lower_32_bits(page_to_phys(page)), 1797: iommu->regbase + KGSL_IOMMU_PRR_CFG_LADDR); 1798: 1799: writel_relaxed(upper_32_bits(page_to_phys(page)), 1800: iommu->regbase + KGSL_IOMMU_PRR_CFG_UADDR); 1801: 1802: val = KGSL_IOMMU_GET_CTX_REG(ctx, KGSL_IOMMU_CTX_ACTLR); 1803: val |= FIELD_PREP(KGSL_IOMMU_ACTLR_PRR_ENABLE, 1); 1804: KGSL_IOMMU_SET_CTX_REG(ctx, KGSL_IOMMU_CTX_ACTLR, val); 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: { 1882: struct kgsl_iommu *iommu = &mmu->iommu; 1883: 1884: if (_ctx_terminated_on_fault(mmu, &iommu->user_context)) 1885: return true; 1886: 1887: return false; 1888: } 1889: 1890: static int kgsl_iommu_set_aperture(struct kgsl_device *device) 1891: { 1892: struct kgsl_iommu *iommu = KGSL_IOMMU(device); 1893: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1894: int ret; 1895: 1896: if (!test_bit(KGSL_MMU_SMMU_APERTURE, &device->mmu.features) || 1897: !test_bit(KGSL_MMU_IOPGTABLE, &device->mmu.features) || 1898: iommu->smmu_aperture_set) 1899: return 0; 1900: 1901: /* Use the catalog to set the SMMU aperture only if the SCM call is not available */ 1902: if (!_kgsl_smmu_aperture_scm_available()) { 1903: ret = device->ftbl->set_smmu_aperture(device); 1904: if (ret) { 1905: dev_err(&device->pdev->dev, 1906: "Unable to set the SMMU aperture without the SCM call: %d\n", ret); 1907: return ret; 1908: } 1909: 1910: iommu->smmu_aperture_set = true; 1911: return 0; 1912: } 1913: 1914: ret = kgsl_set_smmu_aperture(device, &iommu->user_context); 1915: if (ret) 1916: return ret; 1917: 1918: if (iommu->lpac_context.domain) { 1919: ret = kgsl_set_smmu_lpac_aperture(device, &iommu->lpac_context); 1920: if (ret < 0 && ADRENO_FEATURE(adreno_dev, ADRENO_LPAC)) { 1921: dev_err(&device->pdev->dev, 1922: "Unable to set the LPAC SMMU aperture: %d.\n", ret); 1923: dev_err(&device->pdev->dev, 1924: "The aperture needs to be set to use per-process pagetables\n"); 1925: return ret; 1926: } 1927: } 1928: 1929: iommu->smmu_aperture_set = true; 1930: return 0; 1931: } 1932: 1933: static int kgsl_iommu_start(struct kgsl_mmu *mmu) 1934: { 1935: struct kgsl_iommu *iommu = &mmu->iommu; 1936: int ret; 1937: 1938: kgsl_iommu_enable_clk(mmu); 1939: 1940: /* Set the following registers only when the MMU type is QSMMU */ 1941: if (mmu->subtype != KGSL_IOMMU_SMMU_V500) { 1942: /* Enable hazard check from GPU_SMMU_HUM_CFG */ 1943: writel_relaxed(0x02, iommu->regbase + 0x6800); 1944: 1945: /* Write to GPU_SMMU_DORA_ORDERING to disable reordering */ 1946: writel_relaxed(0x01, iommu->regbase + 0x64a0); 1947: 1948: /* make sure register write committed */ 1949: wmb(); 1950: } 1951: 1952: kgsl_iommu_configure_gpu_sctlr(mmu, mmu->pfpolicy, &iommu->user_context); 1953: 1954: ret = kgsl_iommu_set_aperture(KGSL_MMU_DEVICE(mmu)); 1955: if (ret) { 1956: kgsl_iommu_disable_clk(mmu); 1957: return ret; 1958: } 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 2063: * the barrier as we use writel_relaxed to write it. 2064: */ 2065: wmb(); 2066: 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: 2157: return 0; 2158: } 2159: 2160: static struct kgsl_iommu_addr_entry *_find_gpuaddr( 2161: struct kgsl_pagetable *pagetable, uint64_t gpuaddr) 2162: { 2163: struct rb_node *node = pagetable->rbtree.rb_node; 2164: 2165: while (node != NULL) { 2166: struct kgsl_iommu_addr_entry *entry = rb_entry(node, 2167: struct kgsl_iommu_addr_entry, node); 2168: 2169: if (gpuaddr < entry->base) 2170: node = node->rb_left; 2171: else if (gpuaddr > entry->base) 2172: node = node->rb_right; 2173: else 2174: return entry; 2175: } 2176: 2177: return NULL; 2178: } 2179: 2180: static int _remove_gpuaddr(struct kgsl_pagetable *pagetable, 2181: uint64_t gpuaddr) 2182: { 2183: struct kgsl_iommu_addr_entry *entry; 2184: 2185: entry = _find_gpuaddr(pagetable, gpuaddr); 2186: 2187: if (WARN(!entry, "GPU address %llx doesn't exist\n", gpuaddr)) 2188: return -ENOMEM; 2189: 2190: /* 2191: * If the hint was based on this entry, adjust it to the end of the 2192: * previous entry. 2193: */ 2194: if (pagetable->va_hint == (entry->base + entry->size)) { 2195: struct kgsl_iommu_addr_entry *prev = 2196: rb_entry_safe(rb_prev(&entry->node), 2197: struct kgsl_iommu_addr_entry, node); 2198: 2199: pagetable->va_hint = pagetable->va_start; 2200: if (prev) 2201: pagetable->va_hint = max_t(u64, prev->base + prev->size, 2202: pagetable->va_start); 2203: } 2204: 2205: rb_erase(&entry->node, &pagetable->rbtree); 2206: kmem_cache_free(addr_entry_cache, entry); 2207: return 0; 2208: } 2209: 2210: static int _insert_gpuaddr(struct kgsl_pagetable *pagetable, 2211: uint64_t gpuaddr, uint64_t size) 2212: { 2213: struct rb_node **node, *parent = NULL; 2214: struct kgsl_iommu_addr_entry *new = 2215: kmem_cache_alloc(addr_entry_cache, GFP_ATOMIC); 2216: 2217: if (new == NULL) 2218: return -ENOMEM; 2219: 2220: new->base = gpuaddr; 2221: new->size = size; 2222: 2223: node = &pagetable->rbtree.rb_node; 2224: 2225: while (*node != NULL) { 2226: struct kgsl_iommu_addr_entry *this; 2227: 2228: parent = *node; 2229: this = rb_entry(parent, struct kgsl_iommu_addr_entry, node); 2230: 2231: if (new->base < this->base) 2232: node = &parent->rb_left; 2233: else if (new->base > this->base) 2234: node = &parent->rb_right; 2235: else { 2236: /* Duplicate entry */ 2237: WARN_RATELIMIT(1, "duplicate gpuaddr: 0x%llx\n", gpuaddr); 2238: kmem_cache_free(addr_entry_cache, new); 2239: return -EEXIST; 2240: } 2241: } 2242: 2243: rb_link_node(&new->node, parent, node); 2244: rb_insert_color(&new->node, &pagetable->rbtree); 2245: 2246: return 0; 2247: } 2248: 2249: static u64 _get_unmapped_area_hint(struct kgsl_pagetable *pagetable, 2250: u64 bottom, u64 top, u64 size, u64 align) 2251: { 2252: u64 hint; 2253: 2254: /* 2255: * VA fragmentation can be a problem on global and secure pagetables 2256: * that are common to all processes, or if we're constrained to a 32-bit 2257: * range. Don't use the va_hint in these cases. 2258: */ 2259: if (!pagetable->va_hint || !upper_32_bits(top)) 2260: return (u64) -EINVAL; 2261: 2262: /* Satisfy requested alignment */ 2263: hint = ALIGN(pagetable->va_hint, align); 2264: 2265: /* 2266: * The va_hint is the highest VA that was allocated in the non-SVM 2267: * region. The 64-bit SVM and non-SVM regions do not overlap. So, we 2268: * know there is no VA allocated at this gpuaddr. Therefore, we only 2269: * need to check whether we have enough space for this allocation. 2270: */ 2271: if ((hint + size) > top) 2272: return (u64) -ENOMEM; 2273: 2274: pagetable->va_hint = hint + size; 2275: return hint; 2276: } 2277: 2278: static uint64_t _get_unmapped_area(struct kgsl_pagetable *pagetable, 2279: uint64_t bottom, uint64_t top, uint64_t size, 2280: uint64_t align) 2281: { 2282: struct rb_node *node; 2283: uint64_t start; 2284: 2285: /* Check if we can assign a gpuaddr based on the last allocation */ 2286: start = _get_unmapped_area_hint(pagetable, bottom, top, size, align); 2287: if (!IS_ERR_VALUE(start)) 2288: return start; 2289: 2290: /* Fall back to searching through the range. */ 2291: node = rb_first(&pagetable->rbtree); 2292: bottom = ALIGN(bottom, align); 2293: start = bottom; 2294: 2295: while (node != NULL) { 2296: uint64_t gap; 2297: struct kgsl_iommu_addr_entry *entry = rb_entry(node, 2298: struct kgsl_iommu_addr_entry, node); 2299: 2300: /* 2301: * Skip any entries that are outside of the range, but make sure 2302: * to account for some that might straddle the lower bound 2303: */ 2304: if (entry->base < bottom) { 2305: if (entry->base + entry->size > bottom) 2306: start = ALIGN(entry->base + entry->size, align); 2307: node = rb_next(node); 2308: continue; 2309: } 2310: 2311: /* Stop if we went over the top */ 2312: if (entry->base >= top) 2313: break; 2314: 2315: /* Make sure there is a gap to consider */ 2316: if (start < entry->base) { 2317: gap = entry->base - start; 2318: 2319: if (gap >= size) 2320: return start; 2321: } 2322: MATCH LINES: 2338, 2342, 2345, 2355, 2356, 2364 2326: 2327: /* Start the next cycle at the end of the current entry */ 2328: start = ALIGN(entry->base + entry->size, align); 2329: node = rb_next(node); 2330: } 2331: 2332: if (start + size <= top) 2333: return start; 2334: 2335: return (uint64_t) -ENOMEM; 2336: } 2337: 2338: static uint64_t _get_unmapped_area_topdown(struct kgsl_pagetable *pagetable, 2339: uint64_t bottom, uint64_t top, uint64_t size, 2340: uint64_t align) 2341: { 2342: struct rb_node *node = rb_last(&pagetable->rbtree); 2343: uint64_t end = top; 2344: uint64_t mask = ~(align - 1); 2345: struct kgsl_iommu_addr_entry *entry; 2346: 2347: /* Make sure that the bottom is correctly aligned */ 2348: bottom = ALIGN(bottom, align); 2349: 2350: /* Make sure the requested size will fit in the range */ 2351: if (size > (top - bottom)) 2352: return -ENOMEM; 2353: 2354: /* Walk back through the list to find the highest entry in the range */ 2355: for (node = rb_last(&pagetable->rbtree); node != NULL; node = rb_prev(node)) { 2356: entry = rb_entry(node, struct kgsl_iommu_addr_entry, node); 2357: if (entry->base < top) 2358: break; 2359: } 2360: 2361: while (node != NULL) { 2362: uint64_t offset; 2363: 2364: entry = rb_entry(node, struct kgsl_iommu_addr_entry, node); 2365: 2366: /* If the entire entry is below the range the search is over */ 2367: if ((entry->base + entry->size) < bottom) 2368: break; 2369: 2370: /* Get the top of the entry properly aligned */ 2371: offset = ALIGN(entry->base + entry->size, align); 2372: 2373: /* 2374: * Try to allocate the memory from the top of the gap, 2375: * making sure that it fits between the top of this entry and 2376: * the bottom of the previous one 2377: */ 2378: 2379: if ((end > size) && (offset < end)) { 2380: uint64_t chunk = (end - size) & mask; 2381: 2382: if (chunk >= offset) 2383: return chunk; 2384: } 2385: 2386: /* 2387: * If we get here and the current entry is outside of the range 2388: * then we are officially out of room MATCH LINES: 2408, 2418, 2419, 2421, 2425, 2434, 2435, 2436, 2439, 2440, 2441, 2447, 2454, 2457, 2458, 2462, 2463, 2476, 2478, 2482, 2489, 2490, 2492, 2496, 2497, 2501, 2507, 2517, 2525, 2526, 2528, 2529, 2532, 2536, 2542, 2544, 2547, 2549, 2551, 2554, 2560, 2562, 2567, 2576, 2579, 2580, 2583, 2590, 2592, 2595, 2597, 2601, 2603, 2604, 2619, 2621, 2631, 2635, 2644, 2646, 2657, 2660, 2671, 2673, 2674, 2696, 2707, 2710, 2713, 2716, 2717, 2722, 2723, 2725, 2726, 2727, 2730, 2732, 2735, 2736, 2742, 2746, 2747, 2748, 2749, 2757, 2759, 2760, 2762, 2767, 2768, 2769, 2770, 2775, 2781, 2783, 2811, 2820, 2821, 2830, 2835, 2836, 2838, 2845, 2847, 2851, 2853, 2861, 2865, 2870, 2876, 2880, 2882, 2891, 2894, 2896, 2897, 2906, 2908, 2923, 2929, 2932, 2935, 2940, 2942, 2943, 2958, 2969, 2971, 2973, 2975, 2981, 2982, 2987, 2989, 2998, 3012, 3022, 3023, 3026, 3027, 3031, 3032, 3033, 3038, 3039, 3040, 3042, 3043, 3044, 3045, 3050, 3051, 3052, 3054, 3055, 3060, 3062, 3063, 3067, 3068, 3069, 3073, 3074, 3076, 3077, 3078, 3080, 3083, 3084, 3085, 3089, 3090, 3091, 3092, 3100, 3102, 3103, 3106, 3120, 3121, 3135, 3139, 3143, 3147, 3149, 3159, 3164, 3165, 3166, 3171, 3172, 3174, 3175, 3176, 3181, 3184, 3188, 3189, 3193, 3202, 3207, 3208, 3211, 3213, 3214, 3218, 3219, 3222, 3236, 3238, 3252, 3253, 3256, 3257, 3258, 3259, 3266, 3282, 3287, 3290, 3293, 3299, 3309, 3325, 3326, 3327, 3349, 3357, 3363, 3367, 3370, 3371, 3372, 3373, 3374, 3375, 3376, 3377, 3378, 3379, 3380, 3381, 3382, 3383, 3384, 3387, 3388, 3389, 3390, 3391, 3392, 3393, 3394, 3395, 3396, 3397, 3398, 3399, 3400, 3401, 3402, 3406, 3407, 3408, 3409, 3410, 3411, 3412, 3413, 3417, 3418, 3419, 3420, 3421, 3422, 3423, 3424, 3425 2396: 2397: /* And move on to the next lower entry */ 2398: node = rb_prev(node); 2399: } 2400: 2401: /* If we get here then there are no more entries in the region */ 2402: if ((end > size) && (((end - size) & mask) >= bottom)) 2403: return (end - size) & mask; 2404: 2405: return (uint64_t) -ENOMEM; 2406: } 2407: 2408: static uint64_t kgsl_iommu_find_svm_region(struct kgsl_pagetable *pagetable, 2409: uint64_t start, uint64_t end, uint64_t size, 2410: uint64_t alignment) 2411: { 2412: uint64_t addr; 2413: 2414: /* Avoid black holes */ 2415: if (WARN(end <= start, "Bad search range: 0x%llx-0x%llx", start, end)) 2416: return (uint64_t) -EINVAL; 2417: 2418: spin_lock(&pagetable->lock); 2419: addr = _get_unmapped_area_topdown(pagetable, 2420: start, end, size, alignment); 2421: spin_unlock(&pagetable->lock); 2422: return addr; 2423: } 2424: 2425: static bool iommu_addr_in_svm_ranges(struct kgsl_pagetable *pagetable, 2426: u64 gpuaddr, u64 size) 2427: { 2428: u64 end = gpuaddr + size; 2429: 2430: /* Make sure size is not zero and we don't wrap around */ 2431: if (end <= gpuaddr) 2432: return false; 2433: 2434: if ((gpuaddr >= pagetable->compat_va_start && gpuaddr < pagetable->compat_va_end) && 2435: (end > pagetable->compat_va_start && 2436: end <= pagetable->compat_va_end)) 2437: return true; 2438: 2439: if ((gpuaddr >= pagetable->svm_start && gpuaddr < pagetable->svm_end) && 2440: (end > pagetable->svm_start && 2441: end <= pagetable->svm_end)) 2442: return true; 2443: 2444: return false; 2445: } 2446: 2447: static int kgsl_iommu_set_svm_region(struct kgsl_pagetable *pagetable, 2448: uint64_t gpuaddr, uint64_t size) 2449: { 2450: int ret = -ENOMEM; 2451: struct rb_node *node; 2452: 2453: /* Make sure the requested address doesn't fall out of SVM range */ 2454: if (!iommu_addr_in_svm_ranges(pagetable, gpuaddr, size)) 2455: return -ENOMEM; 2456: 2457: spin_lock(&pagetable->lock); 2458: node = pagetable->rbtree.rb_node; 2459: 2460: while (node != NULL) { 2461: uint64_t start, end; 2462: struct kgsl_iommu_addr_entry *entry = rb_entry(node, 2463: struct kgsl_iommu_addr_entry, node); 2464: 2465: start = entry->base; 2466: end = entry->base + entry->size; 2467: 2468: if (gpuaddr + size <= start) 2469: node = node->rb_left; 2470: else if (end <= gpuaddr) 2471: node = node->rb_right; 2472: else 2473: goto out; 2474: } 2475: 2476: ret = _insert_gpuaddr(pagetable, gpuaddr, size); 2477: out: 2478: spin_unlock(&pagetable->lock); 2479: return ret; 2480: } 2481: 2482: static int get_gpuaddr(struct kgsl_pagetable *pagetable, 2483: struct kgsl_memdesc *memdesc, u64 start, u64 end, 2484: u64 size, u64 align) 2485: { 2486: u64 addr; 2487: int ret; 2488: 2489: spin_lock(&pagetable->lock); 2490: addr = _get_unmapped_area(pagetable, start, end, size, align); 2491: if (addr == (u64) -ENOMEM) { 2492: spin_unlock(&pagetable->lock); 2493: return -ENOMEM; 2494: } 2495: 2496: ret = _insert_gpuaddr(pagetable, addr, size); 2497: spin_unlock(&pagetable->lock); 2498: 2499: if (ret == 0) { 2500: memdesc->gpuaddr = addr; 2501: memdesc->pagetable = pagetable; 2502: } 2503: 2504: return ret; 2505: } 2506: 2507: static int kgsl_iommu_get_gpuaddr(struct kgsl_pagetable *pagetable, 2508: struct kgsl_memdesc *memdesc) 2509: { 2510: int ret = 0; 2511: u64 start, end, size, align; 2512: 2513: if (WARN_ON(kgsl_memdesc_use_cpu_map(memdesc))) 2514: return -EINVAL; 2515: 2516: if (memdesc->flags & KGSL_MEMFLAGS_SECURE && 2517: pagetable->name != KGSL_MMU_SECURE_PT) 2518: return -EINVAL; 2519: 2520: size = kgsl_memdesc_footprint(memdesc); 2521: 2522: align = kgsl_get_align(memdesc); 2523: 2524: if (memdesc->flags & KGSL_MEMFLAGS_FORCE_32BIT) { 2525: start = pagetable->compat_va_start; 2526: end = pagetable->compat_va_end; 2527: } else { 2528: start = pagetable->va_start; 2529: end = pagetable->va_end; 2530: } 2531: 2532: ret = get_gpuaddr(pagetable, memdesc, start, end, size, align); 2533: /* if OOM, retry once after flushing lockless_workqueue */ 2534: if (ret == -ENOMEM) { 2535: flush_workqueue(kgsl_driver.lockless_workqueue); 2536: ret = get_gpuaddr(pagetable, memdesc, start, end, size, align); 2537: } 2538: 2539: return ret; 2540: } 2541: 2542: static void kgsl_iommu_put_gpuaddr(struct kgsl_memdesc *memdesc) 2543: { 2544: if (memdesc->pagetable == NULL) 2545: return; 2546: 2547: spin_lock(&memdesc->pagetable->lock); 2548: 2549: _remove_gpuaddr(memdesc->pagetable, memdesc->gpuaddr); 2550: 2551: spin_unlock(&memdesc->pagetable->lock); 2552: } 2553: 2554: static int kgsl_iommu_svm_range(struct kgsl_pagetable *pagetable, 2555: uint64_t *lo, uint64_t *hi, uint64_t memflags) 2556: { 2557: bool gpu_compat = (memflags & KGSL_MEMFLAGS_FORCE_32BIT) != 0; 2558: 2559: if (lo != NULL) 2560: *lo = gpu_compat ? pagetable->compat_va_start : pagetable->svm_start; 2561: if (hi != NULL) 2562: *hi = gpu_compat ? pagetable->compat_va_end : pagetable->svm_end; 2563: 2564: return 0; 2565: } 2566: 2567: static bool kgsl_iommu_addr_in_range(struct kgsl_pagetable *pagetable, 2568: uint64_t gpuaddr, uint64_t size) 2569: { 2570: u64 end = gpuaddr + size; 2571: 2572: /* Make sure we don't wrap around */ 2573: if (gpuaddr == 0 || end < gpuaddr) 2574: return false; 2575: 2576: if (gpuaddr >= pagetable->va_start && end <= pagetable->va_end) 2577: return true; 2578: 2579: if (gpuaddr >= pagetable->compat_va_start && 2580: end <= pagetable->compat_va_end) 2581: return true; 2582: 2583: if (gpuaddr >= pagetable->svm_start && end <= pagetable->svm_end) 2584: return true; 2585: 2586: return false; 2587: } 2588: 2589: #if (KERNEL_VERSION(6, 13, 0) <= LINUX_VERSION_CODE) 2590: static struct iommu_domain *kgsl_iommu_domain_alloc(struct device *dev) 2591: { 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: 2699: platform_device_put(pdev); 2700: context->pdev = NULL; 2701: err_node_put: 2702: of_node_put(node); 2703: err: 2704: return ret; 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); 2761: 2762: kgsl_iommu_set_ttbr0(&iommu->lpac_context, mmu, &pt->cfg); 2763: 2764: return 0; 2765: 2766: err: 2767: kgsl_mmu_putpagetable(mmu->defaultpagetable); 2768: mmu->defaultpagetable = NULL; 2769: kgsl_iommu_detach_context(&iommu->lpac_context); 2770: kgsl_iommu_detach_context(&iommu->user_context); 2771: 2772: return ret; 2773: } 2774: 2775: static int iommu_probe_secure_context(struct kgsl_device *device, 2776: struct device_node *parent) 2777: { 2778: struct device_node *node; 2779: struct platform_device *pdev; 2780: int ret; 2781: struct kgsl_iommu *iommu = KGSL_IOMMU(device); 2782: struct kgsl_mmu *mmu = &device->mmu; 2783: struct kgsl_iommu_context *context = &iommu->secure_context; 2784: int secure_vmid = VMID_CP_PIXEL; 2785: 2786: if (!mmu->secured) 2787: return -EPERM; 2788: 2789: node = of_find_node_by_name(parent, "gfx3d_secure"); 2790: if (!of_device_is_available(node)) { 2791: ret = -ENOENT; 2792: goto err_node_put; 2793: } 2794: 2795: pdev = of_find_device_by_node(node); 2796: if (!pdev) { 2797: ret = -ENODEV; 2798: goto err_node_put; 2799: } 2800: 2801: ret = of_dma_configure(&pdev->dev, node, true); 2802: if (ret) 2803: goto err_device_put; 2804: 2805: context->cb_num = -1; 2806: context->name = "gfx3d_secure"; 2807: context->kgsldev = device; 2808: context->pdev = pdev; 2809: ratelimit_default_init(&context->ratelimit); 2810: 2811: context->domain = kgsl_iommu_domain_alloc(&context->pdev->dev); 2812: if (IS_ERR_OR_NULL(context->domain)) { 2813: ret = (context->domain) ? PTR_ERR(context->domain) : -ENODEV; 2814: dev_err(&device->pdev->dev, 2815: "Failed to allocate domain for secure context: %d\n", ret); 2816: context->domain = NULL; 2817: goto err_device_put; 2818: } 2819: 2820: if (!of_property_read_bool(node, "qcom,iommu-vmid")) { 2821: ret = qcom_iommu_set_secure_vmid(context->domain, secure_vmid); 2822: if (ret) { 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; 2861: mmu->securepagetable = NULL; 2862: return ret; 2863: } 2864: 2865: static const char * const kgsl_iommu_clocks[] = { 2866: "gcc_gpu_memnoc_gfx", 2867: "gcc_gpu_snoc_dvm_gfx", 2868: "gpu_cc_ahb", 2869: "gpu_cc_cx_gmu", 2870: "gpu_cc_hlos1_vote_gpu_smmu", 2871: "gpu_cc_hub_aon", 2872: "gpu_cc_hub_cx_int", 2873: "gcc_bimc_gpu_axi", 2874: "gcc_gpu_ahb", 2875: "gcc_gpu_axi_clk", 2876: "gcc_smmu_cfg_clk", 2877: "gcc_gfx_tcu_clk", 2878: }; 2879: 2880: static const struct kgsl_mmu_ops kgsl_iommu_ops; 2881: 2882: static void kgsl_iommu_check_config(struct kgsl_mmu *mmu, 2883: struct device_node *parent) 2884: { 2885: struct device_node *node = of_find_node_by_name(parent, "gfx3d_user"); 2886: struct device_node *phandle; 2887: 2888: if (!node) 2889: return; 2890: 2891: phandle = of_parse_phandle(node, "iommus", 0); 2892: 2893: if (phandle) { 2894: if (of_device_is_compatible(phandle, "qcom,qsmmu-v500") || 2895: of_device_is_compatible(phandle, "arm,mmu-500")) 2896: mmu->subtype = KGSL_IOMMU_SMMU_V500; 2897: if (of_device_is_compatible(phandle, "qcom,adreno-smmu")) 2898: set_bit(KGSL_MMU_IOPGTABLE, &mmu->features); 2899: 2900: of_node_put(phandle); 2901: } 2902: 2903: of_node_put(node); 2904: } 2905: 2906: static void kgsl_iommu_setup_vbo(struct kgsl_mmu *mmu) 2907: { 2908: if ((mmu->subtype == KGSL_IOMMU_SMMU_V500) && 2909: test_bit(KGSL_MMU_SUPPORT_VBO, &mmu->features)) { 2910: /* 2911: * We need to allocate a page because we need a known physical 2912: * address to program in the PRR register but the hardware 2913: * should intercept accesses to the page before they go to DDR 2914: * so this should be mostly just a placeholder 2915: */ 2916: kgsl_vbo_zero_page = alloc_page(GFP_KERNEL | __GFP_ZERO | 2917: __GFP_NORETRY | __GFP_HIGHMEM); 2918: } 2919: if (!kgsl_vbo_zero_page) 2920: clear_bit(KGSL_MMU_SUPPORT_VBO, &mmu->features); 2921: } 2922: 2923: static void kgsl_iommu_map_globals(struct kgsl_device *device, struct kgsl_mmu *mmu) 2924: { 2925: struct kgsl_global_memdesc *md; 2926: 2927: list_for_each_entry(md, &device->globals, node) { 2928: if (md->memdesc.flags & KGSL_MEMFLAGS_SECURE) { 2929: if (IS_ERR_OR_NULL(mmu->securepagetable)) 2930: continue; 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: } 2968: 2969: int kgsl_iommu_probe_standard(struct kgsl_device *device, struct platform_device *pdev) 2970: { 2971: struct kgsl_iommu *iommu = KGSL_IOMMU(device); 2972: struct device *virt_dev = NULL; 2973: struct device_node *node, *smmu_node = NULL; 2974: struct kgsl_mmu *mmu = &device->mmu; 2975: struct kgsl_iommu_pt *pt; 2976: struct of_phandle_args args; 2977: u32 val[4]; 2978: int ret; 2979: 2980: node = pdev->dev.of_node; 2981: smmu_node = of_parse_phandle(node, "iommus", 0); 2982: if (!smmu_node) { 2983: ret = -EINVAL; 2984: goto err; 2985: } 2986: 2987: /* Create a kmem cache for the pagetable address objects */ 2988: if (!addr_entry_cache) { 2989: addr_entry_cache = KMEM_CACHE(kgsl_iommu_addr_entry, 0); 2990: if (!addr_entry_cache) { 2991: ret = -ENOMEM; 2992: goto err; 2993: } 2994: } 2995: 2996: /* 2997: * Allocate and register a virtual device, associate it with 2998: * power domain from the smmu dt node, and enable runtime 2999: * power management. 3000: */ 3001: virt_dev = kzalloc(sizeof(*virt_dev), GFP_KERNEL); 3002: if (!virt_dev) { 3003: ret = -ENOMEM; 3004: goto err; 3005: } 3006: 3007: dev_set_name(virt_dev, "genpd:kgsl_cx_pd"); 3008: ret = device_register(virt_dev); 3009: if (ret) 3010: goto err; 3011: 3012: ret = of_parse_phandle_with_fixed_args(smmu_node, "power-domains", 1, 0, &args); 3013: if (ret) 3014: goto err; 3015: 3016: ret = of_genpd_add_device(&args, virt_dev); 3017: if (ret) 3018: goto err; 3019: 3020: pm_runtime_enable(virt_dev); 3021: 3022: /* Map IOMMU register range from smmu node to virtual memory */ 3023: ret = of_property_read_u32_array(smmu_node, "reg", val, 4); 3024: if (ret) { 3025: dev_err(&device->pdev->dev, 3026: "%pOF: Unable to read KGSL IOMMU register range\n", 3027: smmu_node); 3028: goto err; 3029: } 3030: 3031: iommu->regbase = devm_ioremap(&device->pdev->dev, val[1], val[3]); 3032: if (!iommu->regbase) { 3033: dev_err(&device->pdev->dev, "Couldn't map IOMMU registers\n"); 3034: ret = -ENOMEM; 3035: goto err; 3036: } 3037: 3038: iommu->pdev = pdev; 3039: iommu->num_clks = 0; 3040: iommu->smmu_vir_cx_pd = virt_dev; 3041: 3042: /* Retrieve and initialize IOMMU clocks from smmu node. */ 3043: iommu->clks = devm_kcalloc(&pdev->dev, ARRAY_SIZE(kgsl_iommu_clocks), 3044: sizeof(*iommu->clks), GFP_KERNEL); 3045: if (!iommu->clks) { 3046: ret = -ENOMEM; 3047: goto err; 3048: } 3049: 3050: if (!of_parse_phandle_with_args(node, "iommus", "#iommu-cells", 0, &args)) { 3051: struct device_node *iommu_np = args.np; 3052: struct platform_device *iommu_pdev = of_find_device_by_node(iommu_np); 3053: 3054: if (!iommu_pdev) { 3055: of_node_put(iommu_np); 3056: ret = -EPROBE_DEFER; 3057: goto err; 3058: } 3059: 3060: ret = devm_clk_bulk_get_all(&iommu_pdev->dev, &iommu->clks); 3061: if (ret < 0) { 3062: put_device(&iommu_pdev->dev); 3063: of_node_put(iommu_np); 3064: goto err; 3065: } 3066: 3067: iommu->num_clks = ret; 3068: put_device(&iommu_pdev->dev); 3069: of_node_put(iommu_np); 3070: } 3071: 3072: set_bit(KGSL_MMU_PAGED, &mmu->features); 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)) 3110: device->qdss_desc = kgsl_allocate_global_fixed(device, 3111: "qcom,gpu-qdss-stm", "gpu-qdss"); 3112: 3113: device->qtimer_desc = kgsl_allocate_global_fixed(device, 3114: "qcom,gpu-timer", "gpu-qtimer"); 3115: 3116: /* 3117: * Only support VBOs on MMU500 hardware that supports the PRR 3118: * marker register to ignore writes to the zero page 3119: */ 3120: kgsl_iommu_setup_vbo(mmu); 3121: of_node_put(smmu_node); 3122: return 0; 3123: 3124: err: 3125: if (virt_dev) { 3126: if (pm_runtime_enabled(virt_dev)) 3127: pm_runtime_disable(virt_dev); 3128: device_unregister(virt_dev); 3129: kfree(virt_dev); 3130: } 3131: 3132: kmem_cache_destroy(addr_entry_cache); 3133: addr_entry_cache = NULL; 3134: 3135: of_node_put(smmu_node); 3136: return ret; 3137: } 3138: 3139: int kgsl_iommu_bind(struct kgsl_device *device, struct platform_device *pdev) 3140: { 3141: u32 val[2]; 3142: int ret, i; 3143: struct kgsl_iommu *iommu = KGSL_IOMMU(device); 3144: struct kgsl_mmu *mmu = &device->mmu; 3145: struct device_node *node = pdev->dev.of_node; 3146: 3147: /* Create a kmem cache for the pagetable address objects */ 3148: if (!addr_entry_cache) { 3149: addr_entry_cache = KMEM_CACHE(kgsl_iommu_addr_entry, 0); 3150: if (!addr_entry_cache) { 3151: ret = -ENOMEM; 3152: goto err; 3153: } 3154: } 3155: 3156: ret = of_property_read_u32_array(node, "reg", val, 2); 3157: if (ret) { 3158: dev_err(&device->pdev->dev, 3159: "%pOF: Unable to read KGSL IOMMU register range\n", 3160: node); 3161: goto err; 3162: } 3163: 3164: iommu->regbase = devm_ioremap(&device->pdev->dev, val[0], val[1]); 3165: if (!iommu->regbase) { 3166: dev_err(&device->pdev->dev, "Couldn't map IOMMU registers\n"); 3167: ret = -ENOMEM; 3168: goto err; 3169: } 3170: 3171: iommu->pdev = pdev; 3172: iommu->num_clks = 0; 3173: 3174: iommu->clks = devm_kcalloc(&pdev->dev, ARRAY_SIZE(kgsl_iommu_clocks), 3175: sizeof(*iommu->clks), GFP_KERNEL); 3176: if (!iommu->clks) { 3177: ret = -ENOMEM; 3178: goto err; 3179: } 3180: 3181: for (i = 0; i < ARRAY_SIZE(kgsl_iommu_clocks); i++) { 3182: struct clk *c; 3183: 3184: c = devm_clk_get(&device->pdev->dev, kgsl_iommu_clocks[i]); 3185: if (IS_ERR(c)) 3186: continue; 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, 3227: "qcom,gpu-qdss-stm", "gpu-qdss"); 3228: 3229: device->qtimer_desc = kgsl_allocate_global_fixed(device, 3230: "qcom,gpu-timer", "gpu-qtimer"); 3231: 3232: /* 3233: * Only support VBOs on MMU500 hardware that supports the PRR 3234: * marker register to ignore writes to the zero page 3235: */ 3236: kgsl_iommu_setup_vbo(mmu); 3237: 3238: rwlock_init(&iommu->pf_stats_lock); 3239: 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: 3330: /* Array is sorted, so break on first 0 */ 3331: if (!proc->pf_count) 3332: break; 3333: 3334: num_chars += scnprintf(buf + num_chars, 3335: PAGE_SIZE - num_chars - 1, "%16s %10u", 3336: proc->comm, proc->pf_count); 3337: 3338: for (j = 0; j < ARRAY_SIZE(proc->pf_type_counts); j++) 3339: num_chars += scnprintf(buf + num_chars, 3340: PAGE_SIZE - num_chars - 1, " %10u", 3341: proc->pf_type_counts[j]); 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: }; 3404: 3405: static const struct kgsl_mmu_pt_ops secure_pt_ops = { 3406: .mmu_map = kgsl_iommu_secure_map, 3407: .mmu_unmap = kgsl_iommu_secure_unmap, 3408: .mmu_destroy_pagetable = kgsl_iommu_destroy_pagetable, 3409: .get_context_bank = kgsl_iommu_get_context_bank, 3410: .get_asid = kgsl_iommu_get_asid, 3411: .get_gpuaddr = kgsl_iommu_get_gpuaddr, 3412: .put_gpuaddr = kgsl_iommu_put_gpuaddr, 3413: .addr_in_range = kgsl_iommu_addr_in_range, 3414: }; 3415: 3416: static const struct kgsl_mmu_pt_ops default_pt_ops = { 3417: .mmu_map = kgsl_iommu_default_map, 3418: .mmu_unmap = kgsl_iommu_default_unmap, 3419: .mmu_destroy_pagetable = kgsl_iommu_destroy_default_pagetable, 3420: .get_ttbr0 = kgsl_iommu_get_ttbr0, 3421: .get_context_bank = kgsl_iommu_get_context_bank, 3422: .get_asid = kgsl_iommu_get_asid, 3423: .get_gpuaddr = kgsl_iommu_get_gpuaddr, 3424: .put_gpuaddr = kgsl_iommu_put_gpuaddr, 3425: .addr_in_range = kgsl_iommu_addr_in_range, 3426: }; --- FILE: \kgsl_iommu.h | HITS: 109 --- MATCH LINES: 6, 7, 9, 11, 14, 16, 17, 18, 19, 29, 31, 33, 35, 39, 43, 49, 50, 51, 52, 54, 55, 56, 58, 60, 61, 63, 64, 65, 66, 67, 68, 69, 70, 71, 74, 75, 76, 77, 80, 82, 83, 84, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 101, 104, 105, 106, 108, 111, 112, 115, 116, 119, 122, 124, 127, 129, 135, 138, 146, 147, 148, 149, 153, 155, 161, 164, 167, 168, 169, 170, 171, 173, 174, 176, 177, 178, 179, 180, 181, 182, 188, 189, 192, 198, 201, 202, 206, 209, 214, 217, 221, 222, 223, 225, 226, 227, 233 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: #ifndef __KGSL_IOMMU_H 7: #define __KGSL_IOMMU_H 8: 9: #include 10: #include 11: #include 12: /* 13: * These defines control the address range for allocations that 14: * are mapped into all pagetables. 15: */ 16: #define KGSL_IOMMU_GLOBAL_MEM_SIZE (90 * SZ_1M) 17: #define KGSL_IOMMU_GLOBAL_MEM_BASE32 0xf8000000 18: #define KGSL_IOMMU_GLOBAL_MEM_BASE64 \ 19: (KGSL_MEMSTORE_TOKEN_ADDRESS - KGSL_IOMMU_GLOBAL_MEM_SIZE) 20: 21: /* 22: * This is a dummy token address that we use to identify memstore when the user 23: * wants to map it. mmap() uses a unsigned long for the offset so we need a 32 24: * bit value that works with all sized apps. We chose a value that was purposely 25: * unmapped so if you increase the global memory size make sure it doesn't 26: * conflict 27: */ 28: 29: #define KGSL_MEMSTORE_TOKEN_ADDRESS (KGSL_IOMMU_SECURE_BASE32 - SZ_4K) 30: 31: #define KGSL_IOMMU_GLOBAL_MEM_BASE(__mmu) \ 32: (test_bit(KGSL_MMU_64BIT, &(__mmu)->features) ? \ 33: KGSL_IOMMU_GLOBAL_MEM_BASE64 : KGSL_IOMMU_GLOBAL_MEM_BASE32) 34: 35: #define KGSL_IOMMU_SVM_BASE32(__mmu) \ 36: (ADRENO_DEVICE(KGSL_MMU_DEVICE(__mmu))->uche_gmem_base + \ 37: ADRENO_DEVICE(KGSL_MMU_DEVICE(__mmu))->gpucore->gmem_size) 38: 39: #define KGSL_IOMMU_SVM_END32(__mmu) \ 40: (test_bit(KGSL_MMU_64BIT, &(__mmu)->features) ? \ 41: (test_bit(KGSL_MMU_IOPGTABLE, &(__mmu)->features) ? \ 42: KGSL_MEMSTORE_TOKEN_ADDRESS : \ 43: KGSL_IOMMU_GLOBAL_MEM_BASE64) : \ 44: (0xC0000000 - SZ_16M)) 45: 46: /* 47: * Limit secure size to 256MB for 32bit kernels. 48: */ 49: #define KGSL_IOMMU_SECURE_SIZE32 SZ_256M 50: #define KGSL_IOMMU_SECURE_BASE32 \ 51: (KGSL_IOMMU_SECURE_BASE64 - KGSL_IOMMU_SECURE_SIZE32) 52: #define KGSL_IOMMU_SECURE_END32 KGSL_IOMMU_SECURE_BASE64 53: 54: #define KGSL_IOMMU_SECURE_BASE64 0x100000000ULL 55: #define KGSL_IOMMU_SECURE_END64 \ 56: (KGSL_IOMMU_SECURE_BASE64 + KGSL_IOMMU_SECURE_SIZE64) 57: 58: #define KGSL_IOMMU_MAX_SECURE_SIZE 0xFFFFF000 59: 60: #define KGSL_IOMMU_SECURE_SIZE64 \ 61: (KGSL_IOMMU_MAX_SECURE_SIZE - KGSL_IOMMU_SECURE_SIZE32) 62: 63: #define KGSL_IOMMU_SECURE_BASE(_mmu) (test_bit(KGSL_MMU_64BIT, \ 64: &(_mmu)->features) ? KGSL_IOMMU_SECURE_BASE64 : \ 65: KGSL_IOMMU_SECURE_BASE32) 66: #define KGSL_IOMMU_SECURE_END(_mmu) (test_bit(KGSL_MMU_64BIT, \ 67: &(_mmu)->features) ? KGSL_IOMMU_SECURE_END64 : \ 68: KGSL_IOMMU_SECURE_END32) 69: #define KGSL_IOMMU_SECURE_SIZE(_mmu) (test_bit(KGSL_MMU_64BIT, \ 70: &(_mmu)->features) ? KGSL_IOMMU_MAX_SECURE_SIZE : \ 71: KGSL_IOMMU_SECURE_SIZE32) 72: 73: /* The CPU supports 39 bit addresses */ 74: #define KGSL_IOMMU_SVM_BASE64 0x1000000000ULL 75: #define KGSL_IOMMU_SVM_END64 0x4000000000ULL 76: #define KGSL_IOMMU_VA_BASE64 0x4000000000ULL 77: #define KGSL_IOMMU_VA_END64 0x8000000000ULL 78: 79: #define CP_APERTURE_REG 0 80: #define CP_SMMU_APERTURE_ID 0x1B 81: 82: /* Global SMMU register offsets */ 83: #define KGSL_IOMMU_PRR_CFG_LADDR 0x6008 84: #define KGSL_IOMMU_PRR_CFG_UADDR 0x600c 85: 86: /* Register offsets */ 87: #define KGSL_IOMMU_CTX_SCTLR 0x0000 88: #define KGSL_IOMMU_CTX_ACTLR 0x0004 89: #define KGSL_IOMMU_CTX_TTBR0 0x0020 90: #define KGSL_IOMMU_CTX_TCR_LPAE 0x0030 91: #define KGSL_IOMMU_CTX_CONTEXTIDR 0x0034 92: #define KGSL_IOMMU_CTX_FSR 0x0058 93: #define KGSL_IOMMU_CTX_TLBIALL 0x0618 94: #define KGSL_IOMMU_CTX_RESUME 0x0008 95: #define KGSL_IOMMU_CTX_FSYNR0 0x0068 96: #define KGSL_IOMMU_CTX_FSYNR1 0x006c 97: #define KGSL_IOMMU_CTX_TLBSYNC 0x07f0 98: #define KGSL_IOMMU_CTX_TLBSTATUS 0x07f4 99: 100: /* TLBSTATUS register fields */ 101: #define KGSL_IOMMU_CTX_TLBSTATUS_SACTIVE BIT(0) 102: 103: /* SCTLR fields */ 104: #define KGSL_IOMMU_SCTLR_HUPCF_SHIFT 8 105: #define KGSL_IOMMU_SCTLR_CFCFG_SHIFT 7 106: #define KGSL_IOMMU_SCTLR_CFIE_SHIFT 6 107: 108: #define KGSL_IOMMU_ACTLR_PRR_ENABLE BIT(5) 109: 110: /* TCR LPAE fields */ 111: #define KGSL_IOMMU_TCR_LPAE_EPD0 BIT(23) 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; 186: struct clk_bulk_data *clks; 187: int num_clks; 188: struct kgsl_memdesc *smmu_info; 189: /** @pdev: Pointer to the platform device for the IOMMU device */ 190: struct platform_device *pdev; 191: /** 192: * @ppt_active: Set when the first per process pagetable is created. 193: * This is used to warn when global buffers are created that might not 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: }; 232: 233: int kgsl_iommu_probe_standard(struct kgsl_device *device, struct platform_device *pdev); 234: #endif --- FILE: \kgsl_mmu.c | HITS: 152 --- MATCH LINES: 16, 20, 21, 23, 25, 28, 30, 31, 33, 35, 38, 39, 41, 45, 56, 67, 75, 86, 95, 106, 115, 126, 148, 155, 156, 160, 162, 163, 164, 166, 167, 171, 176, 177, 179, 182, 186, 187, 189, 196, 198, 199, 202, 203, 206, 212, 218, 219, 223, 230, 234, 235, 260, 261, 263, 265, 266, 268, 269, 271, 272, 273, 276, 281, 285, 288, 290, 291, 296, 302, 306, 307, 314, 318, 321, 322, 328, 332, 346, 349, 353, 354, 355, 356, 369, 381, 384, 396, 408, 409, 423, 428, 431, 432, 439, 443, 455, 460, 464, 465, 466, 479, 488, 489, 493, 510, 515, 516, 519, 522, 523, 528, 531, 532, 542, 545, 546, 557, 563, 573, 580, 588, 591, 595, 598, 600, 601, 602, 605, 606, 612, 615, 619, 622, 627, 629, 650, 653, 686, 687, 689, 691, 694, 695, 698, 702, 715, 739, 740, 745, 747, 753 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #include 8: #include 9: #include 10: #include 11: 12: #include "kgsl_device.h" 13: #include "kgsl_mmu.h" 14: #include "kgsl_sharedmem.h" 15: 16: static void pagetable_remove_sysfs_objects(struct kgsl_pagetable *pagetable); 17: 18: static void _deferred_destroy(struct work_struct *ws) 19: { 20: struct kgsl_pagetable *pagetable = container_of(ws, 21: struct kgsl_pagetable, destroy_ws); 22: 23: WARN_ON(!list_empty(&pagetable->list)); 24: 25: pagetable->pt_ops->mmu_destroy_pagetable(pagetable); 26: } 27: 28: static void kgsl_destroy_pagetable(struct kref *kref) 29: { 30: struct kgsl_pagetable *pagetable = container_of(kref, 31: struct kgsl_pagetable, refcount); 32: 33: kgsl_mmu_detach_pagetable(pagetable); 34: 35: kgsl_schedule_work(&pagetable->destroy_ws); 36: } 37: 38: struct kgsl_pagetable * 39: kgsl_get_pagetable(unsigned long name) 40: { 41: struct kgsl_pagetable *pt, *ret = NULL; 42: unsigned long flags; 43: 44: spin_lock_irqsave(&kgsl_driver.ptlock, flags); 45: list_for_each_entry(pt, &kgsl_driver.pagetable_list, list) { 46: if (name == pt->name && kref_get_unless_zero(&pt->refcount)) { 47: ret = pt; 48: break; 49: } 50: } 51: 52: spin_unlock_irqrestore(&kgsl_driver.ptlock, flags); 53: return ret; 54: } 55: 56: static struct kgsl_pagetable * 57: _get_pt_from_kobj(struct kobject *kobj) 58: { 59: unsigned int ptname; 60: 61: if (!kobj) 62: return NULL; 63: 64: if (kstrtou32(kobj->name, 0, &ptname)) 65: return NULL; 66: 67: return kgsl_get_pagetable(ptname); 68: } 69: 70: static ssize_t 71: sysfs_show_entries(struct kobject *kobj, 72: struct kobj_attribute *attr, 73: char *buf) 74: { 75: struct kgsl_pagetable *pt; 76: int ret = 0; 77: 78: pt = _get_pt_from_kobj(kobj); 79: 80: if (pt) { 81: unsigned int val = atomic_read(&pt->stats.entries); 82: 83: ret += scnprintf(buf, PAGE_SIZE, "%d\n", val); 84: } 85: 86: kref_put(&pt->refcount, kgsl_destroy_pagetable); 87: return ret; 88: } 89: 90: static ssize_t 91: sysfs_show_mapped(struct kobject *kobj, 92: struct kobj_attribute *attr, 93: char *buf) 94: { 95: struct kgsl_pagetable *pt; 96: int ret = 0; 97: 98: pt = _get_pt_from_kobj(kobj); 99: 100: if (pt) { 101: uint64_t val = atomic_long_read(&pt->stats.mapped); 102: 103: ret += scnprintf(buf, PAGE_SIZE, "%llu\n", val); 104: } 105: 106: kref_put(&pt->refcount, kgsl_destroy_pagetable); 107: return ret; 108: } 109: 110: static ssize_t 111: sysfs_show_max_mapped(struct kobject *kobj, 112: struct kobj_attribute *attr, 113: char *buf) 114: { 115: struct kgsl_pagetable *pt; 116: int ret = 0; 117: 118: pt = _get_pt_from_kobj(kobj); 119: 120: if (pt) { 121: uint64_t val = atomic_long_read(&pt->stats.max_mapped); 122: 123: ret += scnprintf(buf, PAGE_SIZE, "%llu\n", val); 124: } 125: 126: kref_put(&pt->refcount, kgsl_destroy_pagetable); 127: return ret; 128: } 129: 130: static struct kobj_attribute attr_entries = { 131: .attr = { .name = "entries", .mode = 0444 }, 132: .show = sysfs_show_entries, 133: .store = NULL, 134: }; 135: 136: static struct kobj_attribute attr_mapped = { 137: .attr = { .name = "mapped", .mode = 0444 }, 138: .show = sysfs_show_mapped, 139: .store = NULL, 140: }; 141: 142: static struct kobj_attribute attr_max_mapped = { 143: .attr = { .name = "max_mapped", .mode = 0444 }, 144: .show = sysfs_show_max_mapped, 145: .store = NULL, 146: }; 147: 148: static struct attribute *pagetable_attrs[] = { 149: &attr_entries.attr, 150: &attr_mapped.attr, 151: &attr_max_mapped.attr, 152: NULL, 153: }; 154: 155: static struct attribute_group pagetable_attr_group = { 156: .attrs = pagetable_attrs, 157: }; 158: 159: static void 160: pagetable_remove_sysfs_objects(struct kgsl_pagetable *pagetable) 161: { 162: if (pagetable->kobj) 163: sysfs_remove_group(pagetable->kobj, 164: &pagetable_attr_group); 165: 166: kobject_put(pagetable->kobj); 167: pagetable->kobj = NULL; 168: } 169: 170: static int 171: pagetable_add_sysfs_objects(struct kgsl_pagetable *pagetable) 172: { 173: char ptname[16]; 174: int ret = -ENOMEM; 175: 176: snprintf(ptname, sizeof(ptname), "%d", pagetable->name); 177: pagetable->kobj = kobject_create_and_add(ptname, 178: kgsl_driver.ptkobj); 179: if (pagetable->kobj == NULL) 180: goto err; 181: 182: ret = sysfs_create_group(pagetable->kobj, &pagetable_attr_group); 183: 184: err: 185: if (ret) { 186: if (pagetable->kobj) 187: kobject_put(pagetable->kobj); 188: 189: pagetable->kobj = NULL; 190: } 191: 192: return ret; 193: } 194: 195: #ifdef CONFIG_TRACE_GPU_MEM 196: static void kgsl_mmu_trace_gpu_mem_pagetable(struct kgsl_pagetable *pagetable) 197: { 198: if (pagetable->name == KGSL_MMU_GLOBAL_PT || 199: pagetable->name == KGSL_MMU_SECURE_PT) 200: return; 201: 202: trace_gpu_mem_total(0, pagetable->name, 203: (u64)atomic_long_read(&pagetable->stats.mapped)); 204: } 205: #else 206: static void kgsl_mmu_trace_gpu_mem_pagetable(struct kgsl_pagetable *pagetable) 207: { 208: } 209: #endif 210: 211: void 212: kgsl_mmu_detach_pagetable(struct kgsl_pagetable *pagetable) 213: { 214: unsigned long flags; 215: 216: spin_lock_irqsave(&kgsl_driver.ptlock, flags); 217: 218: if (!list_empty(&pagetable->list)) 219: list_del_init(&pagetable->list); 220: 221: spin_unlock_irqrestore(&kgsl_driver.ptlock, flags); 222: 223: pagetable_remove_sysfs_objects(pagetable); 224: } 225: 226: unsigned int 227: kgsl_mmu_log_fault_addr(struct kgsl_mmu *mmu, u64 pt_base, 228: uint64_t addr) 229: { 230: struct kgsl_pagetable *pt; 231: unsigned int ret = 0; 232: 233: spin_lock(&kgsl_driver.ptlock); 234: list_for_each_entry(pt, &kgsl_driver.pagetable_list, list) { 235: if (kgsl_mmu_pagetable_get_ttbr0(pt) == MMU_SW_PT_BASE(pt_base)) { 236: if ((addr & ~(PAGE_SIZE-1)) == pt->fault_addr) { 237: ret = 1; 238: break; 239: } 240: pt->fault_addr = (addr & ~(PAGE_SIZE-1)); 241: ret = 0; 242: break; 243: } 244: } 245: spin_unlock(&kgsl_driver.ptlock); 246: 247: return ret; 248: } 249: 250: int kgsl_mmu_start(struct kgsl_device *device) 251: { 252: struct kgsl_mmu *mmu = &device->mmu; 253: 254: if (MMU_OP_VALID(mmu, mmu_start)) 255: return mmu->mmu_ops->mmu_start(mmu); 256: 257: return 0; 258: } 259: 260: void kgsl_mmu_pagetable_init(struct kgsl_mmu *mmu, 261: struct kgsl_pagetable *pagetable, u32 name) 262: { 263: kref_init(&pagetable->refcount); 264: 265: spin_lock_init(&pagetable->lock); 266: INIT_WORK(&pagetable->destroy_ws, _deferred_destroy); 267: 268: pagetable->mmu = mmu; 269: pagetable->name = name; 270: 271: atomic_set(&pagetable->stats.entries, 0); 272: atomic_long_set(&pagetable->stats.mapped, 0); 273: atomic_long_set(&pagetable->stats.max_mapped, 0); 274: } 275: 276: void kgsl_mmu_pagetable_add(struct kgsl_mmu *mmu, struct kgsl_pagetable *pagetable) 277: { 278: unsigned long flags; 279: 280: spin_lock_irqsave(&kgsl_driver.ptlock, flags); 281: list_add(&pagetable->list, &kgsl_driver.pagetable_list); 282: spin_unlock_irqrestore(&kgsl_driver.ptlock, flags); 283: 284: /* Create the sysfs entries */ 285: pagetable_add_sysfs_objects(pagetable); 286: } 287: 288: void kgsl_mmu_putpagetable(struct kgsl_pagetable *pagetable) 289: { 290: if (!IS_ERR_OR_NULL(pagetable)) 291: kref_put(&pagetable->refcount, kgsl_destroy_pagetable); 292: } 293: 294: /** 295: * kgsl_mmu_find_svm_region() - Find a empty spot in the SVM region 296: * @pagetable: KGSL pagetable to search 297: * @start: start of search range, must be within kgsl_mmu_svm_range() 298: * @end: end of search range, must be within kgsl_mmu_svm_range() 299: * @size: Size of the region to find 300: * @align: Desired alignment of the address 301: */ 302: uint64_t kgsl_mmu_find_svm_region(struct kgsl_pagetable *pagetable, 303: uint64_t start, uint64_t end, uint64_t size, 304: uint64_t align) 305: { 306: if (PT_OP_VALID(pagetable, find_svm_region)) 307: return pagetable->pt_ops->find_svm_region(pagetable, start, 308: end, size, align); 309: return -ENOMEM; 310: } 311: 312: /** 313: * kgsl_mmu_set_svm_region() - Check if a region is empty and reserve it if so 314: * @pagetable: KGSL pagetable to search 315: * @gpuaddr: GPU address to check/reserve 316: * @size: Size of the region to check/reserve 317: */ 318: int kgsl_mmu_set_svm_region(struct kgsl_pagetable *pagetable, uint64_t gpuaddr, 319: uint64_t size) 320: { 321: if (PT_OP_VALID(pagetable, set_svm_region)) 322: return pagetable->pt_ops->set_svm_region(pagetable, gpuaddr, 323: size); 324: return -ENOMEM; 325: } 326: 327: int 328: kgsl_mmu_map(struct kgsl_pagetable *pagetable, 329: struct kgsl_memdesc *memdesc) 330: { 331: int size; 332: struct kgsl_device *device = KGSL_MMU_DEVICE(pagetable->mmu); 333: 334: if (!memdesc->gpuaddr) 335: return -EINVAL; 336: /* Only global mappings should be mapped multiple times */ 337: if (!kgsl_memdesc_is_global(memdesc) && 338: (TEST_FLAG(KGSL_MEMDESC_MAPPED, &memdesc->priv))) 339: return -EINVAL; 340: 341: if (memdesc->flags & KGSL_MEMFLAGS_VBO) 342: return -EINVAL; 343: 344: size = kgsl_memdesc_footprint(memdesc); 345: 346: if (PT_OP_VALID(pagetable, mmu_map)) { 347: int ret; 348: 349: ret = pagetable->pt_ops->mmu_map(pagetable, memdesc); 350: if (ret) 351: return ret; 352: 353: atomic_inc(&pagetable->stats.entries); 354: KGSL_STATS_ADD(size, &pagetable->stats.mapped, 355: &pagetable->stats.max_mapped); 356: kgsl_mmu_trace_gpu_mem_pagetable(pagetable); 357: 358: if (!kgsl_memdesc_is_global(memdesc) 359: && !(memdesc->flags & KGSL_MEMFLAGS_USERMEM_ION)) { 360: kgsl_trace_gpu_mem_total(device, size); 361: } 362: 363: SET_FLAG(KGSL_MEMDESC_MAPPED, &memdesc->priv); 364: } 365: 366: return 0; 367: } 368: 369: int kgsl_mmu_map_child(struct kgsl_pagetable *pt, 370: struct kgsl_memdesc *memdesc, u64 offset, 371: struct kgsl_memdesc *child, u64 child_offset, 372: u64 length) 373: { 374: /* This only makes sense for virtual buffer objects */ 375: if (!(memdesc->flags & KGSL_MEMFLAGS_VBO)) 376: return -EINVAL; 377: 378: if (!memdesc->gpuaddr) 379: return -EINVAL; 380: 381: if (PT_OP_VALID(pt, mmu_map_child)) { 382: int ret; 383: 384: ret = pt->pt_ops->mmu_map_child(pt, memdesc, 385: offset, child, child_offset, length); 386: if (ret) 387: return ret; 388: 389: KGSL_STATS_ADD(length, &pt->stats.mapped, 390: &pt->stats.max_mapped); 391: } 392: 393: return 0; 394: } 395: 396: int kgsl_mmu_map_zero_page_to_range(struct kgsl_pagetable *pt, 397: struct kgsl_memdesc *memdesc, u64 start, u64 length) 398: { 399: int ret = -EINVAL; 400: 401: /* This only makes sense for virtual buffer objects */ 402: if (!(memdesc->flags & KGSL_MEMFLAGS_VBO)) 403: return -EINVAL; 404: 405: if (!memdesc->gpuaddr) 406: return -EINVAL; 407: 408: if (PT_OP_VALID(pt, mmu_map_zero_page_to_range)) { 409: ret = pt->pt_ops->mmu_map_zero_page_to_range(pt, 410: memdesc, start, length); 411: if (ret) 412: return ret; 413: 414: KGSL_STATS_ADD(length, &pt->stats.mapped, 415: &pt->stats.max_mapped); 416: } 417: 418: return 0; 419: } 420: 421: /** 422: * kgsl_mmu_svm_range() - Return the range for SVM (if applicable) 423: * @pagetable: Pagetable to query the range from 424: * @lo: Pointer to store the start of the SVM range 425: * @hi: Pointer to store the end of the SVM range 426: * @memflags: Flags from the buffer we are mapping 427: */ 428: int kgsl_mmu_svm_range(struct kgsl_pagetable *pagetable, 429: uint64_t *lo, uint64_t *hi, uint64_t memflags) 430: { 431: if (PT_OP_VALID(pagetable, svm_range)) 432: return pagetable->pt_ops->svm_range(pagetable, lo, hi, 433: memflags); 434: 435: return -ENODEV; 436: } 437: 438: int 439: kgsl_mmu_unmap(struct kgsl_pagetable *pagetable, 440: struct kgsl_memdesc *memdesc) 441: { 442: int ret = 0; 443: struct kgsl_device *device = KGSL_MMU_DEVICE(pagetable->mmu); 444: 445: if (memdesc->size == 0) 446: return -EINVAL; 447: 448: if ((memdesc->flags & KGSL_MEMFLAGS_VBO)) 449: return -EINVAL; 450: 451: /* Only global mappings should be mapped multiple times */ 452: if (!(TEST_FLAG(KGSL_MEMDESC_MAPPED, &memdesc->priv))) 453: return -EINVAL; 454: 455: if (PT_OP_VALID(pagetable, mmu_unmap)) { 456: uint64_t size; 457: 458: size = kgsl_memdesc_footprint(memdesc); 459: 460: ret = pagetable->pt_ops->mmu_unmap(pagetable, memdesc); 461: if (ret) 462: return ret; 463: 464: atomic_dec(&pagetable->stats.entries); 465: atomic_long_sub(size, &pagetable->stats.mapped); 466: kgsl_mmu_trace_gpu_mem_pagetable(pagetable); 467: 468: if (!kgsl_memdesc_is_global(memdesc)) { 469: CLEAR_FLAG(KGSL_MEMDESC_MAPPED, &memdesc->priv); 470: if (!(memdesc->flags & KGSL_MEMFLAGS_USERMEM_ION)) 471: kgsl_trace_gpu_mem_total(device, -(size)); 472: } 473: } 474: 475: return ret; 476: } 477: 478: int 479: kgsl_mmu_unmap_range(struct kgsl_pagetable *pagetable, 480: struct kgsl_memdesc *memdesc, u64 offset, u64 length) 481: { 482: int ret = 0; 483: 484: /* Only allow virtual buffer objects to use this function */ 485: if (!(memdesc->flags & KGSL_MEMFLAGS_VBO)) 486: return -EINVAL; 487: 488: if (PT_OP_VALID(pagetable, mmu_unmap_range)) { 489: ret = pagetable->pt_ops->mmu_unmap_range(pagetable, memdesc, 490: offset, length); 491: 492: if (!ret) 493: atomic_long_sub(length, &pagetable->stats.mapped); 494: } 495: 496: return ret; 497: } 498: 499: int kgsl_mmu_reserve_global_gpuaddr(struct kgsl_device *device, 500: struct kgsl_memdesc *memdesc) 501: { 502: struct kgsl_mmu *mmu = &(device->mmu); 503: 504: if (MMU_OP_VALID(mmu, mmu_reserve_global_gpuaddr)) 505: return mmu->mmu_ops->mmu_reserve_global_gpuaddr(mmu, memdesc, 0); 506: 507: return -EINVAL; 508: } 509: 510: void kgsl_mmu_map_global(struct kgsl_device *device, 511: struct kgsl_memdesc *memdesc, u32 padding) 512: { 513: struct kgsl_mmu *mmu = &(device->mmu); 514: 515: if (MMU_OP_VALID(mmu, mmu_map_global)) 516: mmu->mmu_ops->mmu_map_global(mmu, memdesc, padding); 517: } 518: 519: int kgsl_mmu_pagetable_get_context_bank(struct kgsl_pagetable *pagetable, 520: struct kgsl_context *context) 521: { 522: if (PT_OP_VALID(pagetable, get_context_bank)) 523: return pagetable->pt_ops->get_context_bank(pagetable, context); 524: 525: return -ENOENT; 526: } 527: 528: int kgsl_mmu_pagetable_get_asid(struct kgsl_pagetable *pagetable, 529: struct kgsl_context *context) 530: { 531: if (PT_OP_VALID(pagetable, get_asid)) 532: return pagetable->pt_ops->get_asid(pagetable, context); 533: 534: return -ENOENT; 535: } 536: 537: enum kgsl_mmutype kgsl_mmu_get_mmutype(struct kgsl_device *device) 538: { 539: return device ? device->mmu.type : KGSL_MMU_TYPE_NONE; 540: } 541: 542: bool kgsl_mmu_gpuaddr_in_range(struct kgsl_pagetable *pagetable, 543: uint64_t gpuaddr, uint64_t size) 544: { 545: if (PT_OP_VALID(pagetable, addr_in_range)) 546: return pagetable->pt_ops->addr_in_range(pagetable, gpuaddr, size); 547: 548: return false; 549: } 550: 551: /* 552: * NOMMU definitions - NOMMU really just means that the MMU is kept in pass 553: * through and the GPU directly accesses physical memory. Used in debug mode 554: * and when a real MMU isn't up and running yet. 555: */ 556: 557: static bool nommu_gpuaddr_in_range(struct kgsl_pagetable *pagetable, 558: uint64_t gpuaddr, uint64_t size) 559: { 560: return (gpuaddr != 0) ? true : false; 561: } 562: 563: static int nommu_get_gpuaddr(struct kgsl_pagetable *pagetable, 564: struct kgsl_memdesc *memdesc) 565: { 566: if (WARN_ONCE(memdesc->sgt->nents > 1, 567: "Attempt to map non-contiguous memory with NOMMU\n")) 568: return -EINVAL; 569: 570: memdesc->gpuaddr = (uint64_t) sg_phys(memdesc->sgt->sgl); 571: 572: if (memdesc->gpuaddr) { 573: memdesc->pagetable = pagetable; 574: return 0; 575: } 576: 577: return -ENOMEM; 578: } 579: 580: static void nommu_destroy_pagetable(struct kgsl_pagetable *pt) 581: { 582: kfree(pt); 583: } 584: 585: static const struct kgsl_mmu_pt_ops nommu_pt_ops = { 586: .get_gpuaddr = nommu_get_gpuaddr, 587: .addr_in_range = nommu_gpuaddr_in_range, 588: .mmu_destroy_pagetable = nommu_destroy_pagetable, 589: }; 590: 591: static struct kgsl_pagetable *nommu_getpagetable(struct kgsl_mmu *mmu, 592: unsigned long name) 593: { 594: struct kgsl_device *device = KGSL_MMU_DEVICE(mmu); 595: struct kgsl_pagetable *pagetable; 596: struct kgsl_global_memdesc *md; 597: 598: pagetable = kgsl_get_pagetable(KGSL_MMU_GLOBAL_PT); 599: 600: if (pagetable == NULL) { 601: pagetable = kzalloc(sizeof(*pagetable), GFP_KERNEL); 602: if (!pagetable) 603: return ERR_PTR(-ENOMEM); 604: 605: kgsl_mmu_pagetable_init(mmu, pagetable, KGSL_MMU_GLOBAL_PT); 606: pagetable->pt_ops = &nommu_pt_ops; 607: 608: list_for_each_entry(md, &device->globals, node) 609: md->memdesc.gpuaddr = 610: (uint64_t) sg_phys(md->memdesc.sgt->sgl); 611: 612: kgsl_mmu_pagetable_add(mmu, pagetable); 613: } 614: 615: return pagetable; 616: } 617: 618: static struct kgsl_mmu_ops kgsl_nommu_ops = { 619: .mmu_getpagetable = nommu_getpagetable, 620: }; 621: 622: ssize_t kgsl_mmu_map_sg(struct iommu_domain *domain, 623: unsigned long iova, struct scatterlist *sg, 624: unsigned int nents, int prot) 625: { 626: #if (KERNEL_VERSION(6, 2, 0) <= LINUX_VERSION_CODE) 627: return iommu_map_sg(domain, iova, sg, nents, prot, GFP_KERNEL); 628: #else 629: return iommu_map_sg(domain, iova, sg, nents, prot); 630: #endif 631: } 632: 633: static int kgsl_mmu_cb_bind(struct device *dev, struct device *master, void *data) 634: { 635: return 0; 636: } 637: 638: static void kgsl_mmu_cb_unbind(struct device *dev, struct device *master, 639: void *data) 640: { 641: } 642: 643: static int kgsl_mmu_bind(struct device *dev, struct device *master, void *data) 644: { 645: struct kgsl_device *device = dev_get_drvdata(master); 646: struct kgsl_mmu *mmu = &device->mmu; 647: int ret; 648: 649: /* 650: * Try to bind the IOMMU and if it doesn't exist for some reason 651: * go for the NOMMU option instead 652: */ 653: ret = kgsl_iommu_bind(device, to_platform_device(dev)); 654: 655: if (!ret || ret == -EPROBE_DEFER) 656: return ret; 657: 658: mmu->mmu_ops = &kgsl_nommu_ops; 659: mmu->type = KGSL_MMU_TYPE_NONE; 660: return 0; 661: } 662: 663: static void kgsl_mmu_unbind(struct device *dev, struct device *master, 664: void *data) 665: { 666: struct kgsl_device *device = dev_get_drvdata(master); 667: struct kgsl_mmu *mmu = &device->mmu; 668: 669: if (MMU_OP_VALID(mmu, mmu_close)) 670: mmu->mmu_ops->mmu_close(mmu); 671: } 672: 673: static const struct component_ops kgsl_mmu_cb_component_ops = { 674: .bind = kgsl_mmu_cb_bind, 675: .unbind = kgsl_mmu_cb_unbind, 676: }; 677: 678: static const struct component_ops kgsl_mmu_component_ops = { 679: .bind = kgsl_mmu_bind, 680: .unbind = kgsl_mmu_unbind, 681: }; 682: 683: static int kgsl_mmu_dev_probe(struct platform_device *pdev) 684: { 685: /* 686: * Add kgsl-smmu and context bank as a component device to establish 687: * correct probe order with smmu driver. 688: * 689: * As context bank node in DT contains "iommus" property. fw_devlink 690: * ensures that context bank is probed only after corresponding 691: * supplier (smmu driver) probe is done. 692: * 693: * Adding context bank as a component device ensures master bind 694: * (adreno_bind) is called only once component (kgsl-smmu and context 695: * banks) probe is done thus ensuring correct probe order with smmu 696: * driver. 697: * 698: * kgsl-smmu also need to be a component because we need kgsl-smmu 699: * device info in order to initialize the context banks. 700: */ 701: if (of_device_is_compatible(pdev->dev.of_node, 702: "qcom,smmu-kgsl-cb")) { 703: return component_add(&pdev->dev, &kgsl_mmu_cb_component_ops); 704: } 705: 706: /* Fill out the rest of the devices in the node */ 707: of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev); 708: 709: return component_add(&pdev->dev, &kgsl_mmu_component_ops); 710: } 711: 712: static void _kgsl_mmu_dev_remove(struct platform_device *pdev) 713: { 714: if (of_device_is_compatible(pdev->dev.of_node, 715: "qcom,smmu-kgsl-cb")) { 716: component_del(&pdev->dev, &kgsl_mmu_cb_component_ops); 717: return; 718: } 719: 720: component_del(&pdev->dev, &kgsl_mmu_component_ops); 721: 722: of_platform_depopulate(&pdev->dev); 723: } 724: 725: #if (KERNEL_VERSION(6, 10, 0) <= LINUX_VERSION_CODE) 726: static void kgsl_mmu_dev_remove(struct platform_device *pdev) 727: { 728: _kgsl_mmu_dev_remove(pdev); 729: } 730: #else 731: static int kgsl_mmu_dev_remove(struct platform_device *pdev) 732: { 733: _kgsl_mmu_dev_remove(pdev); 734: return 0; 735: } 736: #endif 737: 738: static const struct of_device_id mmu_match_table[] = { 739: { .compatible = "qcom,kgsl-smmu-v2" }, 740: { .compatible = "qcom,smmu-kgsl-cb" }, 741: {}, 742: }; 743: 744: /* 745: * Legacy pdev for kgsl-smmu component. This is required 746: * with non-standard GPU DT bindings which maintains dummy 747: * IOMMU device. 748: */ 749: static struct platform_driver kgsl_mmu_driver = { 750: .probe = kgsl_mmu_dev_probe, 751: .remove = kgsl_mmu_dev_remove, 752: .driver = { 753: .name = "kgsl-iommu", 754: .of_match_table = mmu_match_table, 755: } 756: }; 757: 758: int __init kgsl_mmu_init(void) 759: { 760: return platform_driver_register(&kgsl_mmu_driver); 761: } 762: 763: void kgsl_mmu_exit(void) 764: { 765: platform_driver_unregister(&kgsl_mmu_driver); 766: } --- FILE: \kgsl_mmu.h | HITS: 97 --- MATCH LINES: 19, 20, 23, 24, 52, 56, 58, 74, 76, 108, 114, 115, 117, 126, 128, 132, 134, 136, 138, 139, 140, 141, 142, 145, 147, 149, 151, 169, 170, 172, 173, 184, 191, 192, 201, 202, 208, 209, 212, 219, 221, 223, 227, 229, 231, 234, 235, 238, 242, 245, 247, 250, 253, 270, 275, 278, 279, 285, 286, 291, 294, 295, 306, 308, 309, 314, 317, 318 7: #define __KGSL_MMU_H 8: 9: #include 10: 11: /* Identifier for the global page table */ 12: /* 13: * Per process page tables will probably pass in the thread group 14: * as an identifier 15: */ 16: #define KGSL_MMU_GLOBAL_PT 0 17: #define KGSL_MMU_SECURE_PT 1 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; 72: uint64_t fault_addr; 73: struct kgsl_mmu *mmu; 74: /** @rbtree: all buffers mapped into the pagetable, indexed by gpuaddr */ 75: struct rb_root rbtree; 76: /** @va_start: Start of virtual range used in this pagetable */ 77: u64 va_start; 78: /** @va_end: End of virtual range */ 79: u64 va_end; 80: /** 81: * @svm_start: Start of shared virtual memory range. Addresses in this 82: * range are also valid in the process's CPU address space. 83: */ 84: u64 svm_start; 85: /** @svm_end: end of 32 bit compatible range */ 86: u64 svm_end; 87: /** 88: * @compat_va_start - Start of the "compat" virtual address range for 89: * forced 32 bit allocations 90: */ 91: u64 compat_va_start; 92: /** 93: * @compat_va_end - End of the "compat" virtual address range for 94: * forced 32 bit allocations 95: */ 96: u64 compat_va_end; 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); 134: int (*mmu_unmap)(struct kgsl_pagetable *pt, 135: struct kgsl_memdesc *memdesc); 136: int (*mmu_unmap_range)(struct kgsl_pagetable *pt, 137: struct kgsl_memdesc *memdesc, u64 offset, u64 length); 138: void (*mmu_destroy_pagetable)(struct kgsl_pagetable *pt); 139: u64 (*get_ttbr0)(struct kgsl_pagetable *pt); 140: int (*get_context_bank)(struct kgsl_pagetable *pt, struct kgsl_context *context); 141: int (*get_asid)(struct kgsl_pagetable *pt, struct kgsl_context *context); 142: int (*get_gpuaddr)(struct kgsl_pagetable *pt, 143: struct kgsl_memdesc *memdesc); 144: void (*put_gpuaddr)(struct kgsl_memdesc *memdesc); 145: uint64_t (*find_svm_region)(struct kgsl_pagetable *pt, uint64_t start, 146: uint64_t end, uint64_t size, uint64_t align); 147: int (*set_svm_region)(struct kgsl_pagetable *pt, 148: uint64_t gpuaddr, uint64_t size); 149: int (*svm_range)(struct kgsl_pagetable *pt, uint64_t *lo, uint64_t *hi, 150: uint64_t memflags); 151: bool (*addr_in_range)(struct kgsl_pagetable *pagetable, 152: uint64_t gpuaddr, uint64_t size); 153: }; 154: 155: enum kgsl_mmu_feature { 156: /* @KGSL_MMU_64BIT: Use 64 bit virtual address space */ 157: KGSL_MMU_64BIT, 158: /* @KGSL_MMU_PAGED: Support paged memory */ 159: KGSL_MMU_PAGED, 160: /* 161: * @KGSL_MMU_NEED_GUARD_PAGE: Set if a guard page is needed for each 162: * mapped region 163: */ 164: KGSL_MMU_NEED_GUARD_PAGE, 165: /** @KGSL_MMU_IO_COHERENT: Set if a device supports I/O coherency */ 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); 231: int kgsl_mmu_unmap_range(struct kgsl_pagetable *pt, 232: struct kgsl_memdesc *memdesc, u64 offset, u64 length); 233: unsigned int kgsl_mmu_log_fault_addr(struct kgsl_mmu *mmu, 234: u64 ttbr0, uint64_t addr); 235: bool kgsl_mmu_gpuaddr_in_range(struct kgsl_pagetable *pt, uint64_t gpuaddr, 236: uint64_t size); 237: 238: uint64_t kgsl_mmu_find_svm_region(struct kgsl_pagetable *pagetable, 239: uint64_t start, uint64_t end, uint64_t size, 240: uint64_t alignment); 241: 242: int kgsl_mmu_set_svm_region(struct kgsl_pagetable *pagetable, uint64_t gpuaddr, 243: uint64_t size); 244: 245: void kgsl_mmu_detach_pagetable(struct kgsl_pagetable *pagetable); 246: 247: int kgsl_mmu_svm_range(struct kgsl_pagetable *pagetable, 248: uint64_t *lo, uint64_t *hi, uint64_t memflags); 249: 250: struct kgsl_pagetable *kgsl_get_pagetable(unsigned long name); 251: 252: /* 253: * Static inline functions of MMU that simply call the SMMU specific 254: * function using a function pointer. These functions can be thought 255: * of as wrappers around the actual function 256: */ 257: 258: #define MMU_OP_VALID(_mmu, _field) \ 259: (((_mmu) != NULL) && \ 260: ((_mmu)->mmu_ops != NULL) && \ 261: ((_mmu)->mmu_ops->_field != NULL)) 262: 263: #define PT_OP_VALID(_pt, _field) \ 264: (((_pt) != NULL) && \ 265: ((_pt)->pt_ops != NULL) && \ 266: ((_pt)->pt_ops->_field != NULL)) 267: 268: /** 269: * kgsl_mmu_get_gpuaddr - Assign a GPU address to the memdesc 270: * @pagetable: GPU pagetable to assign the address in 271: * @memdesc: mem descriptor to assign the memory to 272: * 273: * Return: 0 on success or negative on failure 274: */ 275: static inline int kgsl_mmu_get_gpuaddr(struct kgsl_pagetable *pagetable, 276: struct kgsl_memdesc *memdesc) 277: { 278: if (PT_OP_VALID(pagetable, get_gpuaddr)) 279: return pagetable->pt_ops->get_gpuaddr(pagetable, memdesc); 280: 281: return -ENOMEM; 282: } 283: 284: /** 285: * kgsl_mmu_put_gpuaddr - Remove a GPU address from a pagetable 286: * @pagetable: Pagetable to release the memory from 287: * @memdesc: Memory descriptor containing the GPU address to free 288: * 289: * Release a GPU address in the MMU virtual address space. 290: */ 291: static inline void kgsl_mmu_put_gpuaddr(struct kgsl_pagetable *pagetable, 292: struct kgsl_memdesc *memdesc) 293: { 294: if (PT_OP_VALID(pagetable, put_gpuaddr)) 295: pagetable->pt_ops->put_gpuaddr(memdesc); 296: } 297: 298: static inline bool kgsl_mmu_ctx_terminated_on_fault(struct kgsl_mmu *mmu) 299: { 300: if (MMU_OP_VALID(mmu, mmu_ctx_terminated_on_fault)) 301: return mmu->mmu_ops->mmu_ctx_terminated_on_fault(mmu); 302: 303: return false; 304: } 305: 306: static inline u64 kgsl_mmu_get_current_ttbr0(struct kgsl_mmu *mmu, struct kgsl_context *context) 307: { 308: if (MMU_OP_VALID(mmu, mmu_get_current_ttbr0)) 309: return mmu->mmu_ops->mmu_get_current_ttbr0(mmu, context); 310: 311: return 0; 312: } 313: 314: static inline struct kgsl_pagetable *kgsl_mmu_getpagetable(struct kgsl_mmu *mmu, 315: unsigned long name) 316: { 317: if (MMU_OP_VALID(mmu, mmu_getpagetable)) 318: return mmu->mmu_ops->mmu_getpagetable(mmu, name); 319: 320: return NULL; 321: } 322: 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: } MATCH LINES: 364, 368, 370, 371, 387, 395, 400, 402, 406, 407, 410, 412, 415, 420, 421, 424, 426, 429, 432, 433, 435, 437, 438, 440, 447, 448, 451, 454, 456 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: 373: return 0; 374: } 375: 376: static inline void kgsl_mmu_send_tlb_hint(struct kgsl_mmu *mmu, bool hint) 377: { 378: if (MMU_OP_VALID(mmu, mmu_send_tlb_hint)) 379: return mmu->mmu_ops->mmu_send_tlb_hint(mmu, hint); 380: } 381: 382: /** 383: * kgsl_mmu_reserve_global_gpuaddr - Reserve VA in the global VA space 384: * @device: A KGSL GPU device handle 385: * @memdesc: Pointer to a GPU memory descriptor 386: * 387: * Reserve VA in the global pagetable without mapping anything to this VA 388: * 389: * Return: 0 on success and negative error on failure 390: */ 391: int kgsl_mmu_reserve_global_gpuaddr(struct kgsl_device *device, 392: struct kgsl_memdesc *memdesc); 393: 394: /** 395: * kgsl_mmu_map_global - Map a memdesc as a global buffer 396: * @device: A KGSL GPU device handle 397: * @memdesc: Pointer to a GPU memory descriptor 398: * @padding: Any padding to add to the end of the VA allotment (in bytes) 399: * 400: * Map a buffer as globally accessible in all pagetable contexts 401: */ 402: void kgsl_mmu_map_global(struct kgsl_device *device, 403: struct kgsl_memdesc *memdesc, u32 padding); 404: 405: /** 406: * kgsl_mmu_pagetable_get_context_bank - Return the context bank number 407: * @pagetable: A handle to a given pagetable 408: * @context : LPAC or User context 409: * 410: * This function will find the context number of the given pagetable 411: 412: * Return: The context bank number the pagetable is attached to or 413: * negative error on failure. 414: */ 415: int kgsl_mmu_pagetable_get_context_bank(struct kgsl_pagetable *pagetable, 416: struct kgsl_context *context); 417: 418: 419: /** 420: * kgsl_mmu_pagetable_get_asid - Return the ASID number 421: * @pagetable: A handle to a given pagetable 422: * @context: LPAC or GC context 423: * 424: * This function will find the ASID number of the given pagetable 425: 426: * Return: The ASID number the pagetable is attached to or 427: * negative error on failure. 428: */ 429: int kgsl_mmu_pagetable_get_asid(struct kgsl_pagetable *pagetable, 430: struct kgsl_context *context); 431: 432: void kgsl_mmu_pagetable_init(struct kgsl_mmu *mmu, 433: struct kgsl_pagetable *pagetable, u32 name); 434: 435: void kgsl_mmu_pagetable_add(struct kgsl_mmu *mmu, struct kgsl_pagetable *pagetable); 436: 437: #if IS_ENABLED(CONFIG_ARM_SMMU) 438: int kgsl_iommu_bind(struct kgsl_device *device, struct platform_device *pdev); 439: #else 440: static inline int kgsl_iommu_bind(struct kgsl_device *device, struct platform_device *pdev) 441: { 442: return -ENODEV; 443: } 444: #endif 445: 446: /** 447: * kgsl_mmu_map_sg - Map the given buffer to the IOMMU domain 448: * @domain: The IOMMU domain to perform the mapping 449: * @iova: The start address to map the buffer 450: * @sgt: The sg_table object describing the buffer 451: * @prot: IOMMU protection bits 452: * 453: * Creates a mapping at @iova for the buffer described by a scatterlist 454: * stored in the given sg_table object in the provided IOMMU domain. 455: */ 456: ssize_t kgsl_mmu_map_sg(struct iommu_domain *domain, 457: unsigned long iova, struct scatterlist *sg, 458: unsigned int nents, int prot); 459: 460: /** 461: * kgsl_mmu_sysfs_init - Initialize sysfs nodes for the MMU 462: * @mmu: A KGSL MMU handle 463: */ 464: static inline void kgsl_mmu_sysfs_init(struct kgsl_mmu *mmu) 465: { 466: if (MMU_OP_VALID(mmu, mmu_sysfs_init)) 467: mmu->mmu_ops->mmu_sysfs_init(mmu); 468: } 469: #endif /* __KGSL_MMU_H */ --- FILE: \kgsl_pwrctrl.c | HITS: 21 --- MATCH LINES: 57 45: "mem_iface_clk", 46: "alt_mem_iface_clk", 47: "rbbmtimer_clk", 48: "gtcu_clk", 49: "gtbu_clk", 50: "gtcu_iface_clk", 51: "alwayson_clk", 52: "isense_clk", 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. MATCH LINES: 1287 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: } MATCH LINES: 1332 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: 1346: if (!state) { 1347: if (test_and_clear_bit(KGSL_PWRFLAGS_AXI_ON, 1348: &pwr->power_flags)) { 1349: trace_kgsl_bus(device, state); 1350: return kgsl_bus_update(device, KGSL_BUS_VOTE_OFF); 1351: } 1352: } else { 1353: if (!test_and_set_bit(KGSL_PWRFLAGS_AXI_ON, 1354: &pwr->power_flags)) { 1355: trace_kgsl_bus(device, state); 1356: return kgsl_bus_update(device, KGSL_BUS_VOTE_ON); MATCH LINES: 1544, 1547, 1548, 1549, 1555, 1559, 1561, 1566, 1569, 1573, 1575, 1576, 1580, 1583, 1584, 1588, 1593 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: 1554: /* 1555: * With standard bindings, iommus property is defined in the GPU node. 1556: * If the property is not found in GPU node, try the legacy way by 1557: * checking for the property in user context node. 1558: */ 1559: phandle = of_parse_phandle(device->pdev->dev.of_node, "iommus", 0); 1560: if (!phandle) 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; 1602: 1603: if (!IS_ERR_OR_NULL(pwr->gmu_mx_pd)) 1604: return 0; 1605: 1606: if (of_property_read_bool(pdev->dev.of_node, "power-domains")) { 1607: pwr->gmu_mx_pd = dev_pm_domain_attach_by_name(&pdev->dev, "gmu_mx"); 1608: 1609: if (IS_ERR_OR_NULL(pwr->gmu_mx_pd)) { 1610: dev_err(device->dev, 1611: "Failed to attach GMU mx power domain\n"); 1612: return -EINVAL; 1613: } 1614: } 1615: 1616: return 0; 1617: } MATCH LINES: 2183 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: --- FILE: \kgsl_reclaim.c | HITS: 4 --- MATCH LINES: 162 150: * updated it meanwhile 151: */ 152: spin_lock(&memdesc->lock); 153: if (!memdesc->pages[i]) { 154: memdesc->pages[i] = page; 155: atomic_dec(&entry->priv->unpinned_page_count); 156: } else 157: put_page(page); 158: spin_unlock(&memdesc->lock); 159: } 160: spin_unlock(&memdesc->lock); 161: 162: ret = kgsl_mmu_map(memdesc->pagetable, memdesc); 163: if (ret) 164: return ret; 165: 166: trace_kgsl_reclaim_memdesc(entry, false); 167: 168: CLEAR_FLAG(KGSL_MEMDESC_RECLAIMED | KGSL_MEMDESC_SKIP_RECLAIM, &memdesc->priv); 169: 170: return 0; 171: } 172: 173: int kgsl_reclaim_to_pinned_state( 174: struct kgsl_process_private *process) 175: { 176: struct kgsl_mem_entry *entry, *valid_entry; 177: int next = 0, ret = 0, count; 178: 179: mutex_lock(&process->reclaim_lock); 180: 181: if (test_bit(KGSL_PROC_PINNED_STATE, &process->state)) 182: goto done; 183: 184: count = atomic_read(&process->unpinned_page_count); 185: 186: for ( ; ; ) { MATCH LINES: 285 273: /* Allocate replacement shmem pages */ 274: for (i = 0; i < memdesc->page_count; i++) { 275: ret = kgsl_alloc_shmem_page(memdesc, shmem_filp, &page_size, &pages[i], NULL, i); 276: if (ret <= 0) { 277: pr_err_ratelimited( 278: "kgsl: Failed to alloc shmem page process %d entry %d offset %d\n", 279: pid_nr(entry->priv->pid), entry->id, i); 280: goto cleanup_shmem; 281: } 282: } 283: 284: /* Unmap the memdesc from the mmu */ 285: ret = kgsl_mmu_unmap(memdesc->pagetable, memdesc); 286: if (ret) { 287: pr_err_ratelimited("kgsl: Failed to unmap process %d entry %d\n", 288: pid_nr(entry->priv->pid), entry->id); 289: kill_pid(entry->priv->pid, SIGKILL, 1); 290: goto cleanup_shmem; 291: } 292: 293: /* Take the mmap write lock to prevent concurrent entry mmaps and vm_faults */ 294: mmap_write_lock(mm); 295: 296: /* 297: * Zap ptes to force a vm_fault on the next userspace access. 298: * vma_idr is protected by the mmap lock 299: */ 300: idr_for_each_entry(&memdesc->vma_idr, vma, vidx) { 301: zap_page_range_single(vma, vma->vm_start, 302: vma->vm_end - vma->vm_start, NULL); 303: } 304: 305: for (i = 0; i < memdesc->page_count; ) { 306: struct page *p; 307: int n; 308: int count; 309: MATCH LINES: 340 328: memdesc->shmem_filp = shmem_filp; 329: SET_FLAG(KGSL_MEMDESC_MIGRATED, &memdesc->priv); 330: spin_unlock(&memdesc->lock); 331: 332: /* Re-enable mmaps and vm_faults on the entry memdesc */ 333: mmap_write_unlock(mm); 334: 335: /* Free the old pages back into the pool */ 336: kgsl_pool_free_pages(old_pages, memdesc->page_count); 337: kvfree(old_pages); 338: 339: /* Map the new pages to the mmu */ 340: ret = kgsl_mmu_map(memdesc->pagetable, memdesc); 341: if (ret) { 342: pr_err_ratelimited("kgsl: Failed to map process %d entry %d\n", 343: pid_nr(entry->priv->pid), entry->id); 344: kill_pid(entry->priv->pid, SIGKILL, 1); 345: } 346: 347: atomic_add(memdesc->page_count, &entry->priv->migrated_page_count); 348: trace_kgsl_migrate_memdesc(entry); 349: 350: return page_count; 351: 352: cleanup_shmem: 353: for (i--; i >= 0; i--) 354: put_page(pages[i]); 355: 356: kgsl_memdesc_pagelist_cleanup(shmem_filp, memdesc); 357: SHMEM_I(shmem_filp->f_mapping->host)->android_vendor_data1 = 0; 358: fput(shmem_filp); 359: 360: cleanup_pages: 361: kvfree(pages); 362: 363: return 0; 364: } MATCH LINES: 606 594: memdesc->page_count) > kgsl_reclaim_max_page_limit) { 595: kgsl_mem_entry_put(entry); 596: next++; 597: continue; 598: } 599: 600: if (memdesc->page_count > remaining) { 601: kgsl_mem_entry_put(entry); 602: next++; 603: continue; 604: } 605: 606: if (!kgsl_mmu_unmap(memdesc->pagetable, memdesc)) { 607: kgsl_memdesc_clear_unevictable(process, memdesc); 608: remaining -= memdesc->page_count; 609: reclaim_shmem_address_space(memdesc->shmem_filp->f_mapping); 610: mapping_set_unevictable(memdesc->shmem_filp->f_mapping); 611: SET_FLAG(KGSL_MEMDESC_RECLAIMED, &memdesc->priv); 612: trace_kgsl_reclaim_memdesc(entry, true); 613: } 614: 615: kgsl_mem_entry_put(entry); 616: next++; 617: } 618: 619: if (next) 620: clear_bit(KGSL_PROC_PINNED_STATE, &process->state); 621: 622: trace_kgsl_reclaim_process(process, pages_to_reclaim - remaining, true); 623: mutex_unlock(&process->reclaim_lock); 624: 625: return (pages_to_reclaim - remaining); 626: } 627: 628: static void kgsl_reclaim_background_work(struct work_struct *work) 629: { 630: u32 bg_proc = 0, nr_pages = atomic_read(&kgsl_nr_to_reclaim); --- FILE: \kgsl_sharedmem.c | HITS: 6 --- MATCH LINES: 1514, 1518, 1521, 1524 1502: } 1503: 1504: void kgsl_unmap_and_put_gpuaddr(struct kgsl_memdesc *memdesc) 1505: { 1506: if (!memdesc->size || !memdesc->gpuaddr) 1507: return; 1508: 1509: if (WARN_ON(kgsl_memdesc_is_global(memdesc))) 1510: return; 1511: 1512: /* 1513: * Don't release the GPU address if the memory fails to unmap because 1514: * the IOMMU driver will BUG later if we reallocated the address and 1515: * tried to map it 1516: */ 1517: if (!kgsl_memdesc_is_reclaimed(memdesc) && 1518: kgsl_mmu_unmap(memdesc->pagetable, memdesc)) 1519: return; 1520: 1521: kgsl_mmu_put_gpuaddr(memdesc->pagetable, memdesc); 1522: 1523: memdesc->gpuaddr = 0; 1524: memdesc->pagetable = NULL; 1525: } 1526: 1527: static const struct kgsl_memdesc_ops kgsl_contiguous_ops = { 1528: .free = kgsl_contiguous_free, 1529: .vmflags = VM_DONTDUMP | VM_PFNMAP | VM_DONTEXPAND | VM_DONTCOPY, 1530: .vmfault = kgsl_contiguous_vmfault, 1531: .put_gpuaddr = kgsl_unmap_and_put_gpuaddr, 1532: }; 1533: 1534: #if IS_ENABLED(CONFIG_QCOM_SECURE_BUFFER) 1535: static void kgsl_free_pages_from_sgt(struct kgsl_memdesc *memdesc) 1536: { 1537: int i; 1538: struct scatterlist *sg; 1539: 1540: if (WARN_ON(!memdesc->sgt)) 1541: return; 1542: 1543: for_each_sg(memdesc->sgt->sgl, sg, memdesc->sgt->nents, i) { 1544: /* 1545: * sg_alloc_table_from_pages() will collapse any physically 1546: * adjacent pages into a single scatterlist entry. We cannot 1547: * just call __free_pages() on the entire set since we cannot 1548: * ensure that the size is a whole order. Instead, free each MATCH LINES: 2011 1999: kfree(gmd); 2000: return ERR_PTR(ret); 2001: } 2002: 2003: atomic_set(&gmd->memdesc.priv, KGSL_MEMDESC_GLOBAL); 2004: gmd->name = name; 2005: 2006: /* 2007: * No lock here, because this function is only called during probe/init 2008: * while the caller is holding the mutex 2009: */ 2010: list_add_tail(&gmd->node, &device->globals); 2011: kgsl_mmu_map_global(device, &gmd->memdesc, 0); 2012: 2013: return &gmd->memdesc; 2014: } 2015: 2016: struct kgsl_memdesc *kgsl_alloc_map_gpu_global(struct kgsl_device *device, 2017: u64 gpuaddr, u64 size, u32 padding, u64 flags, u32 priv, const char *name) 2018: { 2019: int ret; 2020: struct kgsl_global_memdesc *md; 2021: 2022: if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex))) 2023: return ERR_PTR(-EINVAL); 2024: 2025: md = kzalloc(sizeof(*md), GFP_KERNEL); 2026: if (!md) 2027: return ERR_PTR(-ENOMEM); 2028: 2029: /* 2030: * Make sure that we get global memory from system memory to keep from 2031: * taking up pool memory for the life of the driver 2032: */ 2033: priv |= KGSL_MEMDESC_GLOBAL | KGSL_MEMDESC_SYSMEM; 2034: 2035: if (flags & KGSL_MEMFLAGS_SECURE) MATCH LINES: 2056 2044: 2045: if (gpuaddr) 2046: md->memdesc.gpuaddr = gpuaddr; 2047: 2048: md->name = name; 2049: 2050: /* 2051: * No lock here, because this function is only called during probe/init 2052: * while the caller is holding the mute 2053: */ 2054: list_add_tail(&md->node, &device->globals); 2055: 2056: kgsl_mmu_map_global(device, &md->memdesc, padding); 2057: kgsl_trace_gpu_mem_total(device, md->memdesc.size); 2058: 2059: return &md->memdesc; 2060: } 2061: 2062: int kgsl_get_global_gpuaddr(struct kgsl_device *device, struct kgsl_memdesc *memdesc, 2063: u64 size, u64 flags, u32 priv) 2064: { 2065: if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex))) 2066: return -EINVAL; 2067: 2068: if (!size || size > UINT_MAX) 2069: return -EINVAL; 2070: 2071: priv |= KGSL_MEMDESC_GLOBAL; 2072: 2073: size = PAGE_ALIGN(size); 2074: 2075: kgsl_memdesc_init(device, memdesc, flags); 2076: 2077: atomic_or(priv, &memdesc->priv); 2078: memdesc->size = size; 2079: 2080: return kgsl_mmu_reserve_global_gpuaddr(device, memdesc); --- FILE: \kgsl_sharedmem.h | HITS: 9 --- MATCH LINES: 20, 24 8: 9: #include 10: #include 11: #include 12: #include 13: #include 14: 15: struct kgsl_device; 16: struct kgsl_process_private; 17: 18: /* Internal definitions for memdesc->priv */ 19: #define KGSL_MEMDESC_GUARD_PAGE BIT(0) 20: /* Set if the memdesc is mapped into all pagetables */ 21: #define KGSL_MEMDESC_GLOBAL BIT(1) 22: /* The memdesc is frozen during a snapshot */ 23: #define KGSL_MEMDESC_FROZEN BIT(2) 24: /* The memdesc is mapped into a pagetable */ 25: #define KGSL_MEMDESC_MAPPED BIT(3) 26: /* The memdesc is secured for content protection */ 27: #define KGSL_MEMDESC_SECURE BIT(4) 28: /* Memory is accessible in privileged mode */ 29: #define KGSL_MEMDESC_PRIVILEGED BIT(6) 30: /* This is an instruction buffer */ 31: #define KGSL_MEMDESC_UCODE BIT(7) 32: /* For global buffers, randomly assign an address from the region */ 33: #define KGSL_MEMDESC_RANDOM BIT(8) 34: /* Allocate memory from the system instead of the pools */ 35: #define KGSL_MEMDESC_SYSMEM BIT(9) 36: /* The memdesc pages can be reclaimed */ 37: #define KGSL_MEMDESC_CAN_RECLAIM BIT(10) 38: /* The memdesc pages were reclaimed */ 39: #define KGSL_MEMDESC_RECLAIMED BIT(11) 40: /* Skip reclaim of the memdesc pages */ 41: #define KGSL_MEMDESC_SKIP_RECLAIM BIT(12) 42: /* The memdesc is hypassigned to HLOS*/ 43: #define KGSL_MEMDESC_HYPASSIGNED_HLOS BIT(13) 44: 45: #define TEST_FLAG(_bit, _val) ((atomic_read(_val) & (_bit)) != 0) 46: #define SET_FLAG(_bit, _val) atomic_or((int)(_bit), (_val)) 47: #define CLEAR_FLAG(_bit, _val) atomic_and(~(int)(_bit), (_val)) 48: MATCH LINES: 67, 83 55: void (*free)(struct kgsl_memdesc *memdesc); 56: int (*map_kernel)(struct kgsl_memdesc *memdesc); 57: void (*unmap_kernel)(struct kgsl_memdesc *memdesc); 58: /** 59: * @put_gpuaddr: Put away the GPU address and unmap the memory 60: * descriptor 61: */ 62: void (*put_gpuaddr)(struct kgsl_memdesc *memdesc); 63: }; 64: 65: /** 66: * struct kgsl_memdesc - GPU memory object descriptor 67: * @pagetable: Pointer to the pagetable that the object is mapped in 68: * @hostptr: Kernel virtual address 69: * @hostptr_count: Number of threads using hostptr 70: * @gpuaddr: GPU virtual address 71: * @physaddr: Physical address of the memory object 72: * @size: Size of the memory object 73: * @priv: Internal flags and settings 74: * @sgt: Scatter gather table for allocated pages 75: * @ops: Function hooks for the memdesc memory type 76: * @flags: Flags set from userspace 77: * @dev: Pointer to the struct device that owns this memory 78: * @attrs: dma attributes for this memory 79: * @pages: An array of pointers to allocated pages 80: * @page_count: Total number of pages allocated 81: */ 82: struct kgsl_memdesc { 83: struct kgsl_pagetable *pagetable; 84: void *hostptr; 85: u32 hostptr_count; 86: u64 gpuaddr; 87: phys_addr_t physaddr; 88: u64 size; 89: atomic_t priv; 90: struct sg_table *sgt; 91: const struct kgsl_memdesc_ops *ops; 92: u64 flags; 93: struct device *dev; 94: unsigned long attrs; 95: struct page **pages; 96: u32 page_count; 97: /** 98: * @lock: Spinlock to protect the gpuaddr from being accessed by 99: * multiple entities trying to map the same SVM region at once 100: */ 101: spinlock_t lock; 102: /** @shmem_filp: Pointer to the shmem file backing this memdesc */ 103: struct file *shmem_filp; 104: /** @ranges: rbtree base for the interval list of vbo ranges */ 105: struct rb_root_cached ranges; 106: /** @ranges_lock: Mutex to protect the range database */ 107: struct mutex ranges_lock; MATCH LINES: 302, 320, 337, 365 290: u64 size, u64 flags, u32 priv); 291: 292: /** 293: * kgsl_alloc_map_gpu_global - Allocate and map a global GPU memory object 294: * @device: A GPU device handle 295: * @gpuaddr: pre-allocated GPU VA for this memory object 296: * @size: Size of the allocation in bytes 297: * @padding: Amount of extra adding to add to the VA allocation 298: * @flags: Control flags for the allocation 299: * @priv: Internal flags for the allocation 300: * @name: Name of the allocation (for the debugfs file) 301: * 302: * Allocate a global GPU object that is mapped into the default pagetables only. 303: * 304: * Return: 0 on success or negative error on failure 305: */ 306: struct kgsl_memdesc *kgsl_alloc_map_gpu_global(struct kgsl_device *device, 307: u64 gpuaddr, u64 size, u32 padding, u64 flags, u32 priv, const char *name); 308: 309: /** 310: * kgsl_allocate_global - Allocate a global GPU memory object 311: * @device: A GPU device handle 312: * @size: Size of the allocation in bytes 313: * @padding: Amount of extra adding to add to the VA allocation 314: * @flags: Control flags for the allocation 315: * @priv: Internal flags for the allocation 316: * @name: Name of the allocation (for the debugfs file) 317: * 318: * Allocate a global GPU object for use by all processes. The buffer is 319: * automatically mapped into the kernel address space and added to the list of 320: * global buffers that get mapped into each newly created pagetable. 321: * Return: The memory descriptor on success or a ERR_PTR encoded error on 322: * failure. 323: */ 324: struct kgsl_memdesc *kgsl_allocate_global(struct kgsl_device *device, 325: u64 size, u32 padding, u64 flags, u32 priv, const char *name); 326: 327: /** 328: * kgsl_allocate_global_fixed - Allocate a global GPU memory object from a fixed 329: * region defined in the device tree 330: * @device: A GPU device handle 331: * @size: Size of the allocation in bytes 332: * @flags: Control flags for the allocation 333: * @priv: Internal flags for the allocation 334: * 335: * Allocate a global GPU object for use by all processes. The buffer is 336: * added to the list of global buffers that get mapped into each newly created 337: * pagetable. 338: * 339: * Return: The memory descriptor on success or a ERR_PTR encoded error on 340: * failure. 341: */ 342: struct kgsl_memdesc *kgsl_allocate_global_fixed(struct kgsl_device *device, 343: const char *resource, const char *name); 344: /** 345: * kgsl_memdesc_init_fixed - Intializes a memory object from a fixed 346: * region defined in the device tree 347: * @device: A GPU device handle 348: * @pdev: Pointer to the platform device 349: * @resource: Name of the resource to get the size and address to allocate 350: * @memdesc: Memory descriptor for the object 351: * 352: * Intializes a memory object for a fixed I/O region defined in device tree. 353: * 354: * Return: 0 on success or negative on failure. 355: */ 356: int kgsl_memdesc_init_fixed(struct kgsl_device *device, 357: struct platform_device *pdev, const char *resource, 358: struct kgsl_memdesc *memdesc); 359: 360: /** 361: * kgsl_free_globals - Free all global objects 362: * @device: A GPU device handle 363: * 364: * Free all the global buffer objects. Should only be called during shutdown 365: * after the pagetables have been freed 366: */ 367: void kgsl_free_globals(struct kgsl_device *device); 368: 369: /** 370: * kgsl_page_sync_for_device - Initialize SG table with page & sync to/from device 371: * @dev: A GPU device handle 372: * @page: Pointer to the struct page 373: * @size: Size of the page 374: * @dir: DMA direction flag 375: */ 376: void kgsl_page_sync(struct device *dev, struct page *page, 377: size_t size, enum dma_data_direction dir); 378: 379: /* 380: * kgsl_memdesc_get_align - Get alignment flags from a memdesc 381: * @memdesc - the memdesc 382: * 383: * Returns the alignment requested, as power of 2 exponent. 384: */ 385: static inline u32 386: kgsl_memdesc_get_align(const struct kgsl_memdesc *memdesc) 387: { 388: return FIELD_GET(KGSL_MEMALIGN_MASK, memdesc->flags); 389: } MATCH LINES: 590 578: if ((gpuaddr >= memdesc->gpuaddr) && 579: (gpuaddr < (memdesc->gpuaddr + memdesc->size))) 580: hostptr = kgsl_memdesc_map(memdesc); 581: 582: return hostptr != NULL ? hostptr + (gpuaddr - memdesc->gpuaddr) : NULL; 583: } 584: 585: /** 586: * kgsl_unmap_and_put_gpuaddr - Unmap the memory and release the gpuaddr 587: * assigned to a memdesc 588: * @memdesc: Pointer to a GPU memory object 589: * 590: * Remove the mapping from pagetable and release the GPU address assigned 591: * to the memdesc 592: */ 593: void kgsl_unmap_and_put_gpuaddr(struct kgsl_memdesc *memdesc); 594: 595: /** 596: * struct kgsl_process_attribute - basic attribute for a process 597: * @attr: Underlying struct attribute 598: * @show: Attribute show function 599: * @store: Attribute store function 600: */ 601: struct kgsl_process_attribute { 602: struct attribute attr; 603: ssize_t (*show)(struct kobject *kobj, 604: struct kgsl_process_attribute *attr, char *buf); 605: ssize_t (*store)(struct kobject *kobj, 606: struct kgsl_process_attribute *attr, const char *buf, 607: ssize_t count); 608: }; 609: 610: #define PROCESS_ATTR(_name, _mode, _show, _store) \ 611: static struct kgsl_process_attribute attr_##_name = \ 612: __ATTR(_name, _mode, _show, _store) 613: 614: struct kgsl_sharedmem_bind_op_range { --- FILE: \kgsl_snapshot.c | HITS: 2 --- MATCH LINES: 1252 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)); MATCH LINES: 1295 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: { --- FILE: \kgsl_snapshot.h | HITS: 3 --- MATCH LINES: 125, 132 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: MATCH LINES: 311 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; --- FILE: \kgsl_trace.h | HITS: 1 --- MATCH LINES: 1088 1076: TP_fast_assign( 1077: kgsl_assign_str(device_name, device->name); 1078: __entry->count = atomic_read(&device->active_cnt); 1079: __entry->ip = ip; 1080: ), 1081: 1082: TP_printk( 1083: "d_name=%s active_cnt=%u func=%ps", 1084: __get_str(device_name), __entry->count, (void *) __entry->ip 1085: ) 1086: ); 1087: 1088: TRACE_EVENT(kgsl_pagetable_destroy, 1089: TP_PROTO(u64 ptbase, unsigned int name), 1090: TP_ARGS(ptbase, name), 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( --- FILE: \kgsl_util.c | HITS: 11 --- MATCH LINES: 207, 208, 210, 216, 218, 227, 229, 230 195: 196: node = of_find_compatible_node(NULL, NULL, compat); 197: 198: if (!node) 199: return false; 200: 201: avail = of_device_is_available(node); 202: of_node_put(node); 203: 204: return avail; 205: } 206: 207: int kgsl_attach_iommu_group(struct device *dev, struct iommu_domain *domain, 208: struct iommu_group **group) 209: { 210: struct iommu_group *grp = iommu_group_get(dev); 211: int ret; 212: 213: if (!grp) 214: return -ENODEV; 215: 216: ret = iommu_attach_group(domain, grp); 217: if (ret) { 218: iommu_group_put(grp); 219: return ret; 220: } 221: 222: *group = grp; 223: 224: return 0; 225: } 226: 227: void kgsl_detach_iommu_group(struct iommu_domain *domain, struct iommu_group *group) 228: { 229: iommu_detach_group(domain, group); 230: iommu_group_put(group); 231: } 232: 233: #if IS_ENABLED(CONFIG_QCOM_KGSL_UPSTREAM) 234: #include 235: #include 236: 237: #if defined(SMEM_DDR_BUILD_ID) 238: int kgsl_get_ddrtype(void) 239: { 240: struct ddrinfo *ddr; 241: 242: ddr = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_DDR_BUILD_ID, NULL); 243: if (IS_ERR(ddr)) { 244: pr_err("kgsl: Unable to get ddr type\n"); 245: return PTR_ERR(ddr); 246: } 247: 248: return ddr->device_type; 249: } 250: #else /* !defined(SMEM_DDR_BUILD_ID) */ 251: int kgsl_get_ddrtype(void) 252: { 253: return -ENOENT; 254: } MATCH LINES: 394 382: } 383: #else 384: static int kgsl_add_sync_timeline_info_to_va_minidump(struct kgsl_device *device) 385: { 386: return 0; 387: } 388: #endif 389: 390: static int kgsl_add_driver_data_to_va_minidump(struct kgsl_device *device) 391: { 392: int ret; 393: char name[MAX_VA_MINIDUMP_STR_LEN]; 394: struct kgsl_pagetable *pt; 395: struct adreno_context *ctxt; 396: struct kgsl_process_private *p; 397: struct kgsl_global_memdesc *md; 398: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 399: 400: ret = kgsl_add_va_to_minidump(device->dev, KGSL_DRIVER, 401: (void *)(&kgsl_driver), sizeof(struct kgsl_driver)); 402: if (ret) 403: return ret; 404: 405: if (!ADRENO_FEATURE(adreno_dev, ADRENO_GMU_BASED_DCVS) && 406: device->pwrscale.enabled) { 407: struct msm_busmon_extended_profile bus_profile = device->pwrscale.bus_profile; 408: 409: ret = kgsl_add_va_to_minidump(device->dev, KGSL_ADRENO_TZ_DATA_ENTRY, 410: (void *)bus_profile.private_data, 411: sizeof(*bus_profile.private_data)); 412: if (ret) 413: return ret; 414: } 415: 416: ret = kgsl_add_page_pools_to_va_minidump(device); 417: if (ret) 418: return ret; MATCH LINES: 436, 439 424: if (ret) 425: break; 426: } 427: 428: list_for_each_entry(p, &kgsl_driver.process_list, list) { 429: snprintf(name, sizeof(name), KGSL_PROC_PRIV_ENTRY "_%d", pid_nr(p->pid)); 430: ret = kgsl_add_va_to_minidump(device->dev, name, 431: (void *)(p), sizeof(struct kgsl_process_private)); 432: if (ret) 433: break; 434: } 435: 436: list_for_each_entry(pt, &kgsl_driver.pagetable_list, list) { 437: snprintf(name, sizeof(name), KGSL_PGTABLE_ENTRY"_%d", pt->name); 438: ret = kgsl_add_va_to_minidump(device->dev, name, 439: (void *)(pt), sizeof(struct kgsl_pagetable)); 440: if (ret) 441: break; 442: } 443: 444: ret = kgsl_add_sync_timeline_info_to_va_minidump(device); 445: if (ret) 446: return ret; 447: 448: /* 449: * Global buffers for HWSCHED are dumped in target-specific code. Therefore, 450: * only dump the required globals for SWSCHED here. 451: */ 452: if (!adreno_dev->hwsched_enabled) { 453: list_for_each_entry(md, &device->globals, node) { 454: if (include_global_in_minidump(md)) { 455: snprintf(name, sizeof(name), "kgsl_global_%s", md->name); 456: ret = kgsl_add_va_to_minidump(device->dev, name, 457: md->memdesc.hostptr, md->memdesc.size); 458: if (ret) 459: break; 460: } 461: } 462: } 463: --- FILE: \kgsl_util.h | HITS: 13 --- MATCH LINES: 174, 176, 177, 178, 180, 184, 185, 188, 190, 191, 193, 195 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: * 182: * Return: 0 on success, negative error on failure 183: */ 184: int kgsl_attach_iommu_group(struct device *dev, struct iommu_domain *domain, 185: struct iommu_group **group); 186: 187: /** 188: * kgsl_detach_iommu_group() - Detach iommu domain from group 189: * 190: * @domain: iommu domain to detach 191: * @group: iommu group to be used for detach 192: * 193: * Detach iommu domain from iommu group 194: */ 195: void kgsl_detach_iommu_group(struct iommu_domain *domain, struct iommu_group *group); 196: 197: /** 198: * kgsl_scm_gpu_init_regs - Load secure registers through tz 199: * @dev: Pointer to the GPU platform device 200: * @gpu_req: Bit mask of requests to enable 201: * @zap_enabled: True when there is no zap-shader 202: * 203: * Return: 0 on success or negative on failure and EOPNOTSUPP if scm call 204: * not supported 205: */ 206: int kgsl_scm_gpu_init_regs(struct device *dev, u32 gpu_req, bool zap_enabled); 207: 208: #if IS_ENABLED(CONFIG_QCOM_VA_MINIDUMP) 209: /** 210: * kgsl_add_to_minidump - Add a physically contiguous section to minidump 211: * @name: Name of the section 212: * @virt_addr: Virtual address of the section 213: * @phy_addr: Physical address of the section 214: * @size: Size of the section 215: */ 216: void kgsl_add_to_minidump(char *name, u64 virt_addr, u64 phy_addr, size_t size); 217: 218: /** 219: * kgsl_remove_from_minidump - Remove a contiguous section from minidump MATCH LINES: 278 266: 267: static inline void kgsl_qcom_va_md_unregister(struct kgsl_device *device) 268: { 269: } 270: #endif 271: 272: #ifdef CONFIG_QCOM_KGSL_UPSTREAM 273: static inline int qcom_scm_pas_shutdown_retry(u32 peripheral) 274: { 275: return -EINVAL; 276: } 277: 278: static inline int qcom_scm_kgsl_set_smmu_lpac_aperture( 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 300: 301: static inline int kgsl_pas_auth_and_reset(u32 pas_id) 302: { --- FILE: \kgsl_vbo.c | HITS: 12 --- MATCH LINES: 115, 125, 155, 179, 194 103: 104: next = interval_tree_iter_first(&memdesc->ranges, start, last); 105: while (next) { 106: node = next; 107: range = bind_to_range(node); 108: next = interval_tree_iter_next(node, start, last); 109: 110: /* 111: * If entry is null, consider it as a special request. Unbind 112: * the entire range between start and last in this case. 113: */ 114: if (!entry || range->entry->id == entry->id) { 115: if (kgsl_mmu_unmap_range(memdesc->pagetable, 116: memdesc, range->range.start, bind_range_len(range))) 117: continue; 118: 119: interval_tree_remove(node, &memdesc->ranges); 120: trace_kgsl_mem_remove_bind_range(target, 121: range->range.start, range->entry, 122: bind_range_len(range)); 123: 124: if (!(memdesc->flags & KGSL_MEMFLAGS_VBO_NO_MAP_ZERO)) 125: kgsl_mmu_map_zero_page_to_range(memdesc->pagetable, 126: memdesc, range->range.start, bind_range_len(range)); 127: 128: bind_range_destroy(range); 129: } 130: } 131: 132: mutex_unlock(&memdesc->ranges_lock); 133: } 134: 135: static int kgsl_memdesc_add_range(struct kgsl_mem_entry *target, 136: u64 start, u64 last, struct kgsl_mem_entry *entry, u64 offset) 137: { 138: struct interval_tree_node *node, *next; 139: struct kgsl_memdesc *memdesc = &target->memdesc; 140: struct kgsl_memdesc_bind_range *range = 141: bind_range_create(start, last, entry); 142: int ret = 0; 143: 144: if (IS_ERR(range)) 145: return PTR_ERR(range); 146: 147: mutex_lock(&memdesc->ranges_lock); 148: 149: /* 150: * If the VBO maps the zero page, then we can unmap the requested range 151: * in one call. Otherwise we have to figure out what ranges to unmap 152: * while walking the interval tree. 153: */ 154: if (!(memdesc->flags & KGSL_MEMFLAGS_VBO_NO_MAP_ZERO)) { 155: ret = kgsl_mmu_unmap_range(memdesc->pagetable, memdesc, start, 156: last - start + 1); 157: if (ret) 158: goto error; 159: } 160: 161: next = interval_tree_iter_first(&memdesc->ranges, start, last); 162: 163: while (next) { 164: struct kgsl_memdesc_bind_range *cur; 165: 166: node = next; 167: cur = bind_to_range(node); 168: next = interval_tree_iter_next(node, start, last); 169: 170: trace_kgsl_mem_remove_bind_range(target, cur->range.start, 171: cur->entry, bind_range_len(cur)); 172: 173: interval_tree_remove(node, &memdesc->ranges); 174: 175: if (start <= cur->range.start) { 176: if (last >= cur->range.last) { 177: /* Unmap the entire cur range */ 178: if (memdesc->flags & KGSL_MEMFLAGS_VBO_NO_MAP_ZERO) { 179: ret = kgsl_mmu_unmap_range(memdesc->pagetable, memdesc, 180: cur->range.start, 181: cur->range.last - cur->range.start + 1); 182: if (ret) { 183: interval_tree_insert(node, &memdesc->ranges); 184: goto error; 185: } 186: } 187: 188: bind_range_destroy(cur); 189: continue; 190: } 191: 192: /* Unmap the range overlapping cur */ 193: if (memdesc->flags & KGSL_MEMFLAGS_VBO_NO_MAP_ZERO) { 194: ret = kgsl_mmu_unmap_range(memdesc->pagetable, memdesc, 195: cur->range.start, 196: last - cur->range.start + 1); 197: if (ret) { 198: interval_tree_insert(node, &memdesc->ranges); 199: goto error; 200: } 201: } 202: 203: /* Adjust the start of the mapping */ 204: cur->range.start = last + 1; 205: /* And put it back into the tree */ 206: interval_tree_insert(node, &memdesc->ranges); 207: 208: trace_kgsl_mem_add_bind_range(target, 209: cur->range.start, cur->entry, bind_range_len(cur)); 210: } else { 211: if (last < cur->range.last) { 212: struct kgsl_memdesc_bind_range *temp; 213: 214: /* 215: * The range is split into two so make a new 216: * entry for the far side 217: */ 218: temp = bind_range_create(last + 1, cur->range.last, MATCH LINES: 233, 250, 279, 282, 304, 321, 324 221: BUG_ON(IS_ERR(temp)); 222: 223: interval_tree_insert(&temp->range, 224: &memdesc->ranges); 225: 226: trace_kgsl_mem_add_bind_range(target, 227: temp->range.start, 228: temp->entry, bind_range_len(temp)); 229: } 230: 231: /* Unmap the range overlapping cur */ 232: if (memdesc->flags & KGSL_MEMFLAGS_VBO_NO_MAP_ZERO) { 233: ret = kgsl_mmu_unmap_range(memdesc->pagetable, memdesc, 234: start, 235: min_t(u64, cur->range.last, last) - start + 1); 236: if (ret) { 237: interval_tree_insert(node, &memdesc->ranges); 238: goto error; 239: } 240: } 241: 242: cur->range.last = start - 1; 243: interval_tree_insert(node, &memdesc->ranges); 244: 245: trace_kgsl_mem_add_bind_range(target, cur->range.start, 246: cur->entry, bind_range_len(cur)); 247: } 248: } 249: 250: ret = kgsl_mmu_map_child(memdesc->pagetable, memdesc, start, 251: &entry->memdesc, offset, last - start + 1); 252: if (ret) 253: goto error; 254: 255: /* Add the new range */ 256: interval_tree_insert(&range->range, &memdesc->ranges); 257: 258: trace_kgsl_mem_add_bind_range(target, range->range.start, 259: range->entry, bind_range_len(range)); 260: mutex_unlock(&memdesc->ranges_lock); 261: 262: return ret; 263: 264: error: 265: bind_range_destroy(range); 266: mutex_unlock(&memdesc->ranges_lock); 267: return ret; 268: } 269: 270: static void kgsl_sharedmem_vbo_put_gpuaddr(struct kgsl_memdesc *memdesc) 271: { 272: struct interval_tree_node *node, *next; 273: struct kgsl_memdesc_bind_range *range; 274: int ret = 0; 275: bool unmap_fail; 276: 277: /* 278: * If the VBO maps the zero range then we can unmap the entire 279: * pagetable region in one call. 280: */ 281: if (!(memdesc->flags & KGSL_MEMFLAGS_VBO_NO_MAP_ZERO)) 282: ret = kgsl_mmu_unmap_range(memdesc->pagetable, memdesc, 283: 0, memdesc->size); 284: 285: unmap_fail = ret; 286: 287: /* 288: * FIXME: do we have a use after free potential here? We might need to 289: * lock this and set a "do not update" bit 290: */ 291: 292: /* Now delete each range and release the mem entries */ 293: next = interval_tree_iter_first(&memdesc->ranges, 0, ~0UL); 294: 295: while (next) { 296: node = next; 297: range = bind_to_range(node); 298: next = interval_tree_iter_next(node, 0, ~0UL); 299: 300: interval_tree_remove(node, &memdesc->ranges); 301: 302: /* Unmap this range */ 303: if (memdesc->flags & KGSL_MEMFLAGS_VBO_NO_MAP_ZERO) 304: ret = kgsl_mmu_unmap_range(memdesc->pagetable, memdesc, 305: range->range.start, 306: range->range.last - range->range.start + 1); 307: 308: /* Put the child's refcount if unmap succeeds */ 309: if (!ret) 310: bind_range_destroy(range); 311: else 312: kfree(range); 313: 314: unmap_fail = unmap_fail || ret; 315: } 316: 317: if (unmap_fail) 318: return; 319: 320: /* Put back the GPU address */ 321: kgsl_mmu_put_gpuaddr(memdesc->pagetable, memdesc); 322: 323: memdesc->gpuaddr = 0; 324: memdesc->pagetable = NULL; 325: } 326: 327: static struct kgsl_memdesc_ops kgsl_vbo_ops = { 328: .put_gpuaddr = kgsl_sharedmem_vbo_put_gpuaddr, 329: }; 330: 331: int kgsl_sharedmem_allocate_vbo(struct kgsl_device *device, 332: struct kgsl_memdesc *memdesc, u64 size, u64 flags) 333: { 334: size = PAGE_ALIGN(size); 335: 336: /* Make sure that VBOs are supported by the MMU */ 337: if (WARN_ON_ONCE(!kgsl_mmu_has_feature(device, 338: KGSL_MMU_SUPPORT_VBO))) 339: return -EOPNOTSUPP; 340: 341: kgsl_memdesc_init(device, memdesc, flags); 342: atomic_set(&memdesc->priv, 0); 343: 344: memdesc->ops = &kgsl_vbo_ops; 345: memdesc->size = size; 346: 347: /* Set up the interval tree and lock */ 348: memdesc->ranges = RB_ROOT_CACHED; --- FILE: \downstream_dependencies\linux\qcom-iommu-util.h | HITS: 21 --- MATCH LINES: 7, 8, 10, 14, 15, 16, 18, 20, 21, 25, 28, 30, 31, 32, 33, 34, 36, 41, 46, 51, 61 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 __QCOM_IOMMU_UTIL_H 8: #define __QCOM_IOMMU_UTIL_H 9: 10: #include 11: 12: #include 13: 14: /* IOMMU fault behaviors */ 15: #define QCOM_IOMMU_FAULT_MODEL_NO_STALL BIT(2) 16: #define QCOM_IOMMU_FAULT_MODEL_NON_FATAL BIT(0) 17: 18: #ifndef IOMMU_SYS_CACHE 19: /* Attributes are not supported, so render them ineffective. */ 20: #define IOMMU_SYS_CACHE (0) 21: #define IOMMU_SYS_CACHE_NWA (0) 22: #endif 23: 24: /* Use upstream device's bus attribute */ 25: #define IOMMU_USE_UPSTREAM_HINT (IOMMU_SYS_CACHE) 26: 27: /* Use upstream device's bus attribute with no write-allocate cache policy */ 28: #define IOMMU_USE_LLC_NWA (IOMMU_SYS_CACHE_NWA) 29: 30: /* vendor iommu fault flags */ 31: #define IOMMU_FAULT_TRANSLATION (1 << 2) 32: #define IOMMU_FAULT_PERMISSION (1 << 3) 33: #define IOMMU_FAULT_EXTERNAL (1 << 4) 34: #define IOMMU_FAULT_TRANSACTION_STALLED (1 << 5) 35: 36: static inline int qcom_iommu_set_fault_model(struct iommu_domain *domain, int fault_model) 37: { 38: return -EINVAL; 39: } 40: 41: static inline int qcom_iommu_get_context_bank_nr(struct iommu_domain *domain) 42: { 43: return 0; 44: } 45: 46: static inline int qcom_iommu_get_asid_nr(struct iommu_domain *domain) 47: { 48: return 0; 49: } 50: 51: static inline int qcom_iommu_set_secure_vmid(struct iommu_domain *domain, enum vmid vmid) 52: { 53: return -EINVAL; 54: } 55: 56: static inline int qcom_skip_tlb_management(struct device *dev, bool skip) 57: { 58: return -EINVAL; 59: } 60: 61: #endif /* __QCOM_IOMMU_UTIL_H */ TOTAL MATCHES: 1963 ========================================================================================== SUBSYSTEM: GMU_AND_HFI ========================================================================================== --- FILE: \a5xx_reg.h | HITS: 1 --- MATCH LINES: 35 23: #define A5XX_INT_CP_CCU_RESOLVE_TS 12 24: #define A5XX_INT_CP_IB2 13 25: #define A5XX_INT_CP_IB1 14 26: #define A5XX_INT_CP_RB 15 27: #define A5XX_INT_CP_UNUSED_1 16 28: #define A5XX_INT_CP_RB_DONE_TS 17 29: #define A5XX_INT_CP_WT_DONE_TS 18 30: #define A5XX_INT_UNKNOWN_1 19 31: #define A5XX_INT_CP_CACHE_FLUSH_TS 20 32: #define A5XX_INT_UNUSED_2 21 33: #define A5XX_INT_RBBM_ATB_BUS_OVERFLOW 22 34: #define A5XX_INT_MISC_HANG_DETECT 23 35: #define A5XX_INT_UCHE_OOB_ACCESS 24 36: #define A5XX_INT_UCHE_TRAP_INTR 25 37: #define A5XX_INT_DEBBUS_INTR_0 26 38: #define A5XX_INT_DEBBUS_INTR_1 27 39: #define A5XX_INT_GPMU_VOLTAGE_DROOP 28 40: #define A5XX_INT_GPMU_FIRMWARE 29 41: #define A5XX_INT_ISDB_CPU_IRQ 30 42: #define A5XX_INT_ISDB_UNDER_DEBUG 31 43: 44: /* CP Interrupt bits */ 45: #define A5XX_CP_OPCODE_ERROR 0 46: #define A5XX_CP_RESERVED_BIT_ERROR 1 47: #define A5XX_CP_HW_FAULT_ERROR 2 48: #define A5XX_CP_DMA_ERROR 3 49: #define A5XX_CP_REGISTER_PROTECTION_ERROR 4 50: #define A5XX_CP_AHB_ERROR 5 51: 52: /* CP registers */ 53: #define A5XX_CP_RB_BASE 0x800 54: #define A5XX_CP_RB_BASE_HI 0x801 55: #define A5XX_CP_RB_CNTL 0x802 56: #define A5XX_CP_RB_RPTR_ADDR_LO 0x804 57: #define A5XX_CP_RB_RPTR_ADDR_HI 0x805 58: #define A5XX_CP_RB_RPTR 0x806 59: #define A5XX_CP_RB_WPTR 0x807 --- FILE: \a6xx_reg.h | HITS: 158 --- MATCH LINES: 28, 54 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 MATCH LINES: 543, 544, 548, 562, 563, 564, 565, 566, 567 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 MATCH LINES: 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, 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 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 MATCH LINES: 1227, 1228, 1229, 1230, 1231, 1232, 1233, 1234, 1235, 1236 1215: * for PDC SEQ programming. We are now using PDC subsections so 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) --- FILE: \adreno-gpulist.h | HITS: 235 --- MATCH LINES: 684, 685, 686 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 }, MATCH LINES: 746, 747 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}, MATCH LINES: 821, 822, 823, 846, 847, 874, 875, 902, 903 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: }, MATCH LINES: 987, 988, 989 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 }, MATCH LINES: 1061, 1062, 1092, 1093, 1106, 1125, 1126, 1139 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}, MATCH LINES: 1189, 1190, 1191 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}, MATCH LINES: 1239, 1240, 1241, 1242, 1243, 1260, 1269, 1270 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}, MATCH LINES: 1330, 1331, 1332, 1340, 1349, 1350, 1371, 1380, 1381, 1401, 1410, 1411 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}, MATCH LINES: 1468, 1469, 1470, 1478, 1516, 1517 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: }, MATCH LINES: 1625, 1626, 1627 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 }, MATCH LINES: 1683, 1692, 1693, 1716, 1725, 1726, 1749, 1758, 1759, 1781, 1790, 1791, 1814, 1833, 1834, 1857, 1866, 1867 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, MATCH LINES: 1961, 1962, 1963 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( MATCH LINES: 2093, 2094, 2095, 2099, 2100, 2101 2081: { GEN7_RBBM_CLOCK_DELAY_GPC, 0x00000200 }, 2082: { GEN7_RBBM_CLOCK_DELAY_VFD, 0x00002222 }, 2083: { GEN7_RBBM_CLOCK_MODE_HLSQ, 0x00002222 }, 2084: { GEN7_RBBM_CLOCK_DELAY_HLSQ, 0x00000000 }, 2085: { GEN7_RBBM_CLOCK_HYST_HLSQ, 0x00000000 }, 2086: { GEN7_RBBM_CLOCK_DELAY_HLSQ_2, 0x00000002 }, 2087: { GEN7_RBBM_CLOCK_MODE_BV_LRZ, 0x55555552 }, 2088: { GEN7_RBBM_CLOCK_MODE_CP, 0x00000223 }, 2089: { GEN7_RBBM_CLOCK_CNTL, 0x8aa8aa82 }, 2090: { GEN7_RBBM_ISDB_CNT, 0x00000182 }, 2091: { GEN7_RBBM_RAC_THRESHOLD_CNT, 0x00000000 }, 2092: { GEN7_RBBM_SP_HYST_CNT, 0x00000000 }, 2093: { GEN7_RBBM_CLOCK_CNTL_GMU_GX, 0x00000222 }, 2094: { GEN7_RBBM_CLOCK_DELAY_GMU_GX, 0x00000111 }, 2095: { GEN7_RBBM_CLOCK_HYST_GMU_GX, 0x00000555 }, 2096: }; 2097: 2098: static const struct kgsl_regmap_list gen7_0_0_ao_hwcg_regs[] = { 2099: { GEN7_GPU_GMU_AO_GMU_CGC_MODE_CNTL, 0x00020000 }, 2100: { GEN7_GPU_GMU_AO_GMU_CGC_DELAY_CNTL, 0x00010111 }, 2101: { GEN7_GPU_GMU_AO_GMU_CGC_HYST_CNTL, 0x00005555 }, 2102: }; 2103: 2104: /* GEN7_0_0 protected register list */ 2105: static const struct gen7_protected_regs gen7_0_0_protected_regs[] = { 2106: { GEN7_CP_PROTECT_REG + 0, 0x00000, 0x004ff, 0 }, 2107: { GEN7_CP_PROTECT_REG + 1, 0x0050b, 0x00563, 0 }, 2108: { GEN7_CP_PROTECT_REG + 2, 0x0050e, 0x0050e, 1 }, 2109: { GEN7_CP_PROTECT_REG + 3, 0x00510, 0x00510, 1 }, 2110: { GEN7_CP_PROTECT_REG + 4, 0x00534, 0x00534, 1 }, 2111: { GEN7_CP_PROTECT_REG + 5, 0x005fb, 0x00698, 0 }, 2112: { GEN7_CP_PROTECT_REG + 6, 0x00699, 0x00882, 1 }, 2113: { GEN7_CP_PROTECT_REG + 7, 0x008a0, 0x008a8, 1 }, 2114: { GEN7_CP_PROTECT_REG + 8, 0x008ab, 0x008cf, 1 }, 2115: { GEN7_CP_PROTECT_REG + 9, 0x008d0, 0x00a40, 0 }, 2116: { GEN7_CP_PROTECT_REG + 10, 0x00900, 0x0094d, 1 }, 2117: { GEN7_CP_PROTECT_REG + 11, 0x0098d, 0x00a3f, 1 }, 2118: { GEN7_CP_PROTECT_REG + 12, 0x00a41, 0x00bff, 1 }, 2119: { GEN7_CP_PROTECT_REG + 13, 0x00df0, 0x00df1, 1 }, 2120: { GEN7_CP_PROTECT_REG + 14, 0x00e01, 0x00e01, 1 }, 2121: { GEN7_CP_PROTECT_REG + 15, 0x00e07, 0x00e0f, 1 }, 2122: { GEN7_CP_PROTECT_REG + 16, 0x03c00, 0x03cc3, 1 }, 2123: { GEN7_CP_PROTECT_REG + 17, 0x03cc4, 0x05cc3, 0 }, 2124: { GEN7_CP_PROTECT_REG + 18, 0x08630, 0x087ff, 1 }, 2125: { GEN7_CP_PROTECT_REG + 19, 0x08e00, 0x08e00, 1 }, MATCH LINES: 2164, 2172, 2174, 2200, 2208, 2210, 2235 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, 2222: .preempt_level = 1, 2223: .ctxt_record_size = (2860 * SZ_1K), 2224: .fast_bus_hint = true, 2225: }; 2226: 2227: extern const struct gen7_snapshot_block_list gen7_2_0_snapshot_block_list; 2228: extern const struct gen7_snapshot_block_list gen7_6_0_snapshot_block_list; 2229: 2230: static const struct kgsl_regmap_list gen7_2_0_gbif_cx_regs[] = { 2231: { GEN7_GBIF_QSB_SIDE0, 0x00071e20 }, 2232: { GEN7_GBIF_QSB_SIDE1, 0x00071e20 }, 2233: { GEN7_GBIF_QSB_SIDE2, 0x00071e20 }, 2234: { GEN7_GBIF_QSB_SIDE3, 0x00071e20 }, 2235: { GEN7_GMU_CX_MRC_GBIF_QOS_CTRL, 0x33 }, 2236: }; 2237: 2238: extern const struct gen7_snapshot_block_list gen7_3_0_snapshot_block_list; 2239: 2240: static const u32 gen7_6_0_gbif_client_qos_values[KGSL_PRIORITY_MAX_RB_LEVELS] = { 2241: 0x03230323, 2242: }; 2243: 2244: static const struct kgsl_regmap_list gen7_2_0_hwcg_regs[] = { 2245: { GEN7_RBBM_CLOCK_CNTL_SP0, 0x02222222 }, 2246: { GEN7_RBBM_CLOCK_CNTL2_SP0, 0x22022222 }, 2247: { GEN7_RBBM_CLOCK_HYST_SP0, 0x003cf3cf }, 2248: { GEN7_RBBM_CLOCK_DELAY_SP0, 0x00000080 }, 2249: { GEN7_RBBM_CLOCK_CNTL_TP0, 0x22222220 }, 2250: { GEN7_RBBM_CLOCK_CNTL2_TP0, 0x22222222 }, 2251: { GEN7_RBBM_CLOCK_CNTL3_TP0, 0x22220222 }, 2252: { GEN7_RBBM_CLOCK_CNTL4_TP0, 0x00222222 }, 2253: { GEN7_RBBM_CLOCK_HYST_TP0, 0x77777777 }, 2254: { GEN7_RBBM_CLOCK_HYST2_TP0, 0x77777777 }, 2255: { GEN7_RBBM_CLOCK_HYST3_TP0, 0x77777777 }, 2256: { GEN7_RBBM_CLOCK_HYST4_TP0, 0x00077777 }, 2257: { GEN7_RBBM_CLOCK_DELAY_TP0, 0x11111111 }, 2258: { GEN7_RBBM_CLOCK_DELAY2_TP0, 0x11111111 }, 2259: { GEN7_RBBM_CLOCK_DELAY3_TP0, 0x11111111 }, MATCH LINES: 2296, 2297, 2298 2284: { GEN7_RBBM_CLOCK_DELAY_GPC, 0x00000200 }, 2285: { GEN7_RBBM_CLOCK_DELAY_VFD, 0x00000000 }, 2286: { GEN7_RBBM_CLOCK_MODE_HLSQ, 0x00002222 }, 2287: { GEN7_RBBM_CLOCK_DELAY_HLSQ, 0x00000000 }, 2288: { GEN7_RBBM_CLOCK_HYST_HLSQ, 0x00000000 }, 2289: { GEN7_RBBM_CLOCK_MODE_BV_LRZ, 0x55555552 }, 2290: { GEN7_RBBM_CLOCK_HYST2_VFD, 0x00000000 }, 2291: { GEN7_RBBM_CLOCK_MODE_CP, 0x00000222 }, 2292: { GEN7_RBBM_CLOCK_CNTL, 0x8aa8aa82 }, 2293: { GEN7_RBBM_ISDB_CNT, 0x00000182 }, 2294: { GEN7_RBBM_RAC_THRESHOLD_CNT, 0x00000000 }, 2295: { GEN7_RBBM_SP_HYST_CNT, 0x00000000 }, 2296: { GEN7_RBBM_CLOCK_CNTL_GMU_GX, 0x00000222 }, 2297: { GEN7_RBBM_CLOCK_DELAY_GMU_GX, 0x00000111 }, 2298: { GEN7_RBBM_CLOCK_HYST_GMU_GX, 0x00000555 }, 2299: }; 2300: 2301: static const struct kgsl_regmap_list gen7_3_0_hwcg_regs[] = { 2302: { GEN7_RBBM_CLOCK_CNTL_SP0, 0x02222222 }, 2303: { GEN7_RBBM_CLOCK_CNTL2_SP0, 0x02022222 }, 2304: { GEN7_RBBM_CLOCK_HYST_SP0, 0x0000f3cf }, 2305: { GEN7_RBBM_CLOCK_DELAY_SP0, 0x00000080 }, 2306: { GEN7_RBBM_CLOCK_CNTL_TP0, 0x22222220 }, 2307: { GEN7_RBBM_CLOCK_CNTL2_TP0, 0x22222222 }, 2308: { GEN7_RBBM_CLOCK_CNTL3_TP0, 0x22220222 }, 2309: { GEN7_RBBM_CLOCK_CNTL4_TP0, 0x00222222 }, 2310: { GEN7_RBBM_CLOCK_HYST_TP0, 0x77777777 }, 2311: { GEN7_RBBM_CLOCK_HYST2_TP0, 0x77777777 }, 2312: { GEN7_RBBM_CLOCK_HYST3_TP0, 0x77777777 }, 2313: { GEN7_RBBM_CLOCK_HYST4_TP0, 0x00077777 }, 2314: { GEN7_RBBM_CLOCK_DELAY_TP0, 0x11111111 }, 2315: { GEN7_RBBM_CLOCK_DELAY2_TP0, 0x11111111 }, 2316: { GEN7_RBBM_CLOCK_DELAY3_TP0, 0x11111111 }, 2317: { GEN7_RBBM_CLOCK_DELAY4_TP0, 0x00011111 }, 2318: { GEN7_RBBM_CLOCK_CNTL_UCHE, 0x22222222 }, 2319: { GEN7_RBBM_CLOCK_HYST_UCHE, 0x00000004 }, 2320: { GEN7_RBBM_CLOCK_DELAY_UCHE, 0x00000002 }, 2321: { GEN7_RBBM_CLOCK_CNTL_RB0, 0x22222222 }, 2322: { GEN7_RBBM_CLOCK_CNTL2_RB0, 0x01002222 }, MATCH LINES: 2348, 2349, 2350, 2354, 2355, 2356 2336: { GEN7_RBBM_CLOCK_DELAY_TSE_RAS_RBBM, 0x00004000 }, 2337: { GEN7_RBBM_CLOCK_DELAY_GPC, 0x00000200 }, 2338: { GEN7_RBBM_CLOCK_DELAY_VFD, 0x00002222 }, 2339: { GEN7_RBBM_CLOCK_MODE_HLSQ, 0x00002222 }, 2340: { GEN7_RBBM_CLOCK_DELAY_HLSQ, 0x00000000 }, 2341: { GEN7_RBBM_CLOCK_HYST_HLSQ, 0x00000000 }, 2342: { GEN7_RBBM_CLOCK_DELAY_HLSQ_2, 0x00000002 }, 2343: { GEN7_RBBM_CLOCK_MODE_CP, 0x00000223 }, 2344: { GEN7_RBBM_CLOCK_CNTL, 0x8aa8aa82 }, 2345: { GEN7_RBBM_ISDB_CNT, 0x00000182 }, 2346: { GEN7_RBBM_RAC_THRESHOLD_CNT, 0x00000000 }, 2347: { GEN7_RBBM_SP_HYST_CNT, 0x00000000 }, 2348: { GEN7_RBBM_CLOCK_CNTL_GMU_GX, 0x00000222 }, 2349: { GEN7_RBBM_CLOCK_DELAY_GMU_GX, 0x00000111 }, 2350: { GEN7_RBBM_CLOCK_HYST_GMU_GX, 0x00000555 }, 2351: }; 2352: 2353: static const struct kgsl_regmap_list gen7_2_0_ao_hwcg_regs[] = { 2354: { GEN7_GPU_GMU_AO_GMU_CGC_MODE_CNTL, 0x00020202 }, 2355: { GEN7_GPU_GMU_AO_GMU_CGC_DELAY_CNTL, 0x00010111 }, 2356: { GEN7_GPU_GMU_AO_GMU_CGC_HYST_CNTL, 0x00005555 }, 2357: }; 2358: 2359: /* GEN7_2_0 protected register list */ 2360: static const struct gen7_protected_regs gen7_2_0_protected_regs[] = { 2361: { GEN7_CP_PROTECT_REG + 0, 0x00000, 0x004ff, 0 }, 2362: { GEN7_CP_PROTECT_REG + 1, 0x0050b, 0x00563, 0 }, 2363: { GEN7_CP_PROTECT_REG + 2, 0x0050e, 0x0050e, 1 }, 2364: { GEN7_CP_PROTECT_REG + 3, 0x00510, 0x00510, 1 }, 2365: { GEN7_CP_PROTECT_REG + 4, 0x00534, 0x00534, 1 }, 2366: { GEN7_CP_PROTECT_REG + 5, 0x00584, 0x007ff, 0 }, 2367: { GEN7_CP_PROTECT_REG + 6, 0x00699, 0x0069e, 1 }, 2368: { GEN7_CP_PROTECT_REG + 7, 0x00800, 0x00882, 1 }, 2369: { GEN7_CP_PROTECT_REG + 8, 0x008a0, 0x008a8, 1 }, 2370: { GEN7_CP_PROTECT_REG + 9, 0x008ab, 0x008cf, 1 }, 2371: { GEN7_CP_PROTECT_REG + 10, 0x008d0, 0x00a40, 0 }, 2372: { GEN7_CP_PROTECT_REG + 11, 0x00900, 0x0094d, 1 }, 2373: { GEN7_CP_PROTECT_REG + 12, 0x0098d, 0x00a3f, 1 }, 2374: { GEN7_CP_PROTECT_REG + 13, 0x00a41, 0x00bff, 1 }, 2375: { GEN7_CP_PROTECT_REG + 14, 0x00df0, 0x00df1, 1 }, 2376: { GEN7_CP_PROTECT_REG + 15, 0x00e01, 0x00e01, 1 }, 2377: { GEN7_CP_PROTECT_REG + 16, 0x00e07, 0x00e0f, 1 }, 2378: { GEN7_CP_PROTECT_REG + 17, 0x03c00, 0x03cc3, 1 }, 2379: { GEN7_CP_PROTECT_REG + 18, 0x03cc4, 0x05cc3, 0 }, 2380: { GEN7_CP_PROTECT_REG + 19, 0x08630, 0x087ff, 1 }, MATCH LINES: 2428, 2430, 2440, 2465, 2467, 2477, 2493, 2501, 2503, 2527, 2535, 2537, 2555, 2556, 2557, 2558, 2570, 2601, 2625, 2627, 2637 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, 2550: .ctxt_record_size = (2860 * SZ_1K), 2551: .fast_bus_hint = true, 2552: }; 2553: 2554: static const struct kgsl_regmap_list gen7_9_0_ao_hwcg_regs[] = { 2555: { GEN7_GPU_GMU_AO_GMU_CGC_MODE_CNTL, 0x00020222 }, 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", 2593: .hwcg = gen7_2_0_hwcg_regs, 2594: .hwcg_count = ARRAY_SIZE(gen7_2_0_hwcg_regs), 2595: .ao_hwcg = gen7_9_0_ao_hwcg_regs, 2596: .ao_hwcg_count = ARRAY_SIZE(gen7_9_0_ao_hwcg_regs), 2597: .gbif = gen7_2_0_gbif_cx_regs, 2598: .gbif_count = ARRAY_SIZE(gen7_2_0_gbif_cx_regs), 2599: .hang_detect_cycles = 0xcfffff, 2600: .protected_regs = gen7_2_0_protected_regs, 2601: .gmu_hub_clk_freq = 200000000, 2602: .gen7_snapshot_block_list = &gen7_5_0_snapshot_block_list, 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, 2640: .qos_value = gen7_6_0_gbif_client_qos_values, 2641: .preempt_level = 1, 2642: .ctxt_record_size = (4192 * SZ_1K), 2643: }; 2644: 2645: extern const struct gen7_snapshot_block_list gen7_9_0_snapshot_block_list; 2646: 2647: /* GEN7_9_0 protected register list */ 2648: static const struct gen7_protected_regs gen7_9_0_protected_regs[] = { 2649: { GEN7_CP_PROTECT_REG + 0, 0x00000, 0x004ff, 0 }, 2650: { GEN7_CP_PROTECT_REG + 1, 0x0050b, 0x00563, 0 }, 2651: { GEN7_CP_PROTECT_REG + 2, 0x00584, 0x006c1, 0 }, 2652: { GEN7_CP_PROTECT_REG + 3, 0x00706, 0x00706, 0 }, 2653: { GEN7_CP_PROTECT_REG + 4, 0x00720, 0x0073f, 0 }, 2654: { GEN7_CP_PROTECT_REG + 5, 0x00760, 0x007ff, 0 }, 2655: { GEN7_CP_PROTECT_REG + 6, 0x00800, 0x00882, 1 }, 2656: { GEN7_CP_PROTECT_REG + 7, 0x008a0, 0x008a8, 1 }, 2657: { GEN7_CP_PROTECT_REG + 8, 0x008ab, 0x00a40, 0 }, 2658: { GEN7_CP_PROTECT_REG + 9, 0x00900, 0x0094d, 1 }, 2659: { GEN7_CP_PROTECT_REG + 10, 0x0098d, 0x00a3f, 1 }, 2660: { GEN7_CP_PROTECT_REG + 11, 0x00a41, 0x00bff, 1 }, 2661: { GEN7_CP_PROTECT_REG + 12, 0x00df0, 0x00df1, 1 }, MATCH LINES: 2709, 2721, 2729, 2748, 2760, 2768, 2792, 2807, 2814, 2829, 2838, 2862, 2872, 2884, 2899, 2930, 2945 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, 2731: .bcl_data = 1, 2732: .acv_perfmode_vote = BIT(2), 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, 2770: .bcl_data = 1, 2771: .acv_perfmode_vote = BIT(2), 2772: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 2773: .ctxt_record_size = (4208 * SZ_1K), 2774: .preempt_level = 1, 2775: .fast_bus_hint = true, 2776: }; 2777: 2778: extern const struct gen7_snapshot_block_list gen7_13_0_snapshot_block_list; 2779: 2780: /* SMMU aperture registers: GC to context bank 0, LPAC to context bank 1 */ 2781: static const struct kgsl_regmap_list gen7_13_0_smmu_aperture_regs[] = { 2782: { 0x0, 0x000c0000 }, /* GC: CB0 */ 2783: { 0x1, 0x000c1000 }, /* LPAC: CB1 */ 2784: { 0x2, 0x00000002 }, /* CTRL: GC + LPAC */ 2785: }; 2786: 2787: static const struct adreno_gen7_core adreno_gpu_core_gen7_13_0 = { 2788: .base = { 2789: DEFINE_ADRENO_REV(ADRENO_REV_GEN7_13_0, 2790: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID), 2791: .features = ADRENO_APRIV | ADRENO_IOCOHERENT, 2792: .gpudev = &adreno_gen7_gmu_gpudev.base, 2793: .perfcounters = &adreno_gen7_9_0_perfcounters, 2794: .uche_gmem_alignment = SZ_16M, 2795: .gmem_size = 3 * SZ_1M, 2796: .bus_width = 32, 2797: .snapshot_size = SZ_8M, 2798: .num_ddr_channels = 4, 2799: .highest_bank_bit = 16, 2800: .chipid = 0x43051701, 2801: .smmu_aperture = gen7_13_0_smmu_aperture_regs, 2802: .smmu_aperture_count = ARRAY_SIZE(gen7_13_0_smmu_aperture_regs), 2803: }, 2804: .sqefw_name = "gen71300_sqe.fw", 2805: .gmufw_name = "gen71300_gmu.bin", 2806: .zap_name = "gen71300_zap.mbn", 2807: .gmu_chipid = 0x70D0000, 2808: .ao_hwcg = gen7_9_0_ao_hwcg_regs, 2809: .ao_hwcg_count = ARRAY_SIZE(gen7_9_0_ao_hwcg_regs), 2810: .gbif = gen7_2_0_gbif_cx_regs, 2811: .gbif_count = ARRAY_SIZE(gen7_2_0_gbif_cx_regs), 2812: .hang_detect_cycles = 0xcfffff, 2813: .protected_regs = gen7_9_0_protected_regs, 2814: .gmu_hub_clk_freq = 200000000, 2815: .gen7_snapshot_block_list = &gen7_13_0_snapshot_block_list, 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", 2922: .hwcg = gen7_2_0_hwcg_regs, 2923: .hwcg_count = ARRAY_SIZE(gen7_2_0_hwcg_regs), 2924: .ao_hwcg = gen7_9_0_ao_hwcg_regs, 2925: .ao_hwcg_count = ARRAY_SIZE(gen7_9_0_ao_hwcg_regs), 2926: .gbif = gen7_2_0_gbif_cx_regs, 2927: .gbif_count = ARRAY_SIZE(gen7_2_0_gbif_cx_regs), 2928: .hang_detect_cycles = 0xcfffff, 2929: .protected_regs = gen7_2_0_protected_regs, 2930: .gmu_hub_clk_freq = 200000000, 2931: .gen7_snapshot_block_list = &gen7_15_0_snapshot_block_list, 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, 2969: .ctxt_record_size = 1536 * 1024 MATCH LINES: 3020, 3021, 3022, 3023, 3024, 3025, 3026, 3035, 3051, 3052 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, 3061: .veto_fal10 = true, 3062: .protected_regs = a660_protected_regs, 3063: .disable_tseskip = true, 3064: .pdc_in_aop = true, 3065: .ctxt_record_size = 2496 * 1024, 3066: }; 3067: 3068: extern const struct gen8_snapshot_block_list gen8_0_0_snapshot_block_list; 3069: 3070: static const struct kgsl_regmap_list gen8_0_0_gbif_cx_regs[] = { 3071: { GEN8_GBIF_QSB_SIDE0, 0x00071e20 }, 3072: { GEN8_GBIF_QSB_SIDE1, 0x00071e20 }, 3073: { GEN8_GBIF_QSB_SIDE2, 0x00071e20 }, 3074: { GEN8_GBIF_QSB_SIDE3, 0x00071e20 }, 3075: { GEN8_GBIF_CX_CONFIG, 0x20023000 }, 3076: { GEN8_GMUCX_MRC_GBIF_QOS_CTRL, 0x33 }, MATCH LINES: 3203, 3233, 3264, 3266, 3267, 3288, 3308, 3310, 3311, 3346, 3361, 3385, 3387, 3388, 3401, 3402, 3415, 3416, 3429, 3430 3191: { GEN8_CP_PROTECT_REG_GLOBAL + 45, 0x27880, 0x27c01, 0 }, 3192: { GEN8_CP_PROTECT_REG_GLOBAL + 46, 0x27882, 0x27883, 1 }, 3193: { GEN8_CP_PROTECT_REG_GLOBAL + 63, 0x27c02, 0x27c02, 1 }, 3194: { 0 }, 3195: }; 3196: 3197: static const struct kgsl_regmap_list gen8_ao_hwcg_regs[] = { 3198: { GEN8_GMUAO_CGC_MODE_CNTL, 0x00020000 }, 3199: { GEN8_GMUAO_CGC_DELAY_CNTL, 0x00010111 }, 3200: { GEN8_GMUAO_CGC_HYST_CNTL, 0x00005555 }, 3201: }; 3202: 3203: static struct hfi_therm_profile_ctrl therm_profile_8_0_0 = { 3204: .feature_en = 1, 3205: .feature_rev = 1, 3206: .tj_limit = 900, 3207: .tskin_addr = 0, 3208: .tskin_limit = 0, 3209: .tsens_cfg_cnt = 1, 3210: .tsens_cfg.limit_u = 1130, 3211: .tsens_cfg.limit_l = 10, 3212: .tsens_cfg.margin_u = 30, 3213: .tsens_cfg.margin_l = 20, 3214: .throttle_cfg.throttle_hyst = 250, 3215: .throttle_cfg.num_throttle_cnt = 3, 3216: .throttle_cfg.throttle_lvls[0] = 50, 3217: .throttle_cfg.throttle_lvls[1] = 37, 3218: .throttle_cfg.throttle_lvls[2] = 20, 3219: }; 3220: 3221: static const struct therm_tsens_en_cfg tsens_en_cfg_8_0_0 = { 3222: /* 3 GPU slices, each with 2 tsens bits */ 3223: .tsens_sl_cnt = 2, 3224: /* GPU unslice with 2 tsens bits */ 3225: .tsens_us_cnt = 2, 3226: }; 3227: 3228: static struct gen8_thermal_mit_cfg therm_mit_cfg_8_0_0 = { 3229: .therm = &therm_profile_8_0_0, 3230: .tsens_en_cfg = &tsens_en_cfg_8_0_0, 3231: }; 3232: 3233: static const struct hfi_clx_table_v2_cmd gen8_0_0_clx_table = { 3234: .version = (2 << 16) | 1, 3235: .domain = { 3236: /* GFX domain */ 3237: { 3238: .data0 = CLX_DATA(55, 4, 1, 1), 3239: .clxt = 0, 3240: .clxh = 0, 3241: .urgmode = 1, 3242: .lkgen = 0, 3243: .currbudget = 100, 3244: }, 3245: /* MxG domain */ 3246: { 3247: .data0 = CLX_DATA(55, 1, 1, 1), 3248: .clxt = 0, 3249: .clxh = 0, 3250: .urgmode = 1, 3251: .lkgen = 0, 3252: .currbudget = 50, 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, 3290: .fast_bus_hint = true, 3291: .bcl_data = 1, 3292: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 3293: .noc_timeout_us = 3410, /* 3.41 msec */ 3294: .ctxt_record_size = (13536 * SZ_1K), 3295: .preempt_level = 1, 3296: .cl_no_ft_timeout_ms = 6500, 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", 3338: .zap_name = "gen80000_zap.mbn", 3339: .ao_hwcg = gen8_ao_hwcg_regs, 3340: .ao_hwcg_count = ARRAY_SIZE(gen8_ao_hwcg_regs), 3341: .gbif = gen8_0_0_gbif_cx_regs, 3342: .gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs), 3343: .hang_detect_cycles = 0xcfffff, 3344: .protected_regs = gen8_0_0_protected_regs, 3345: .nonctxt_regs = gen8_0_0_nonctxt_regs, 3346: .gmu_hub_clk_freq = 200000000, 3347: .gen8_snapshot_block_list = &gen8_0_0_snapshot_block_list, 3348: .fast_bus_hint = true, 3349: .bcl_data = 1, 3350: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 3351: .noc_timeout_us = 3410, /* 3.41 msec */ 3352: .ctxt_record_size = (13536 * SZ_1K), 3353: .preempt_level = 1, 3354: .cl_no_ft_timeout_ms = 6500, 3355: .therm_cfg = &therm_mit_cfg_8_0_0, 3356: .clx_tbl = &gen8_0_0_clx_table, 3357: }; 3358: 3359: extern const struct gen8_snapshot_block_list gen8_2_0_snapshot_block_list; 3360: 3361: static const struct hfi_clx_table_v2_cmd gen8_2_0_clx_table = { 3362: .version = (2 << 16) | 1, 3363: .domain = { 3364: /* GFX domain */ 3365: { 3366: .data0 = CLX_DATA(60, 5, 1, 1), 3367: .clxt = 0, 3368: .clxh = 0, 3369: .urgmode = 1, 3370: .lkgen = 0, 3371: .currbudget = 100, 3372: }, 3373: /* MxG domain */ 3374: { 3375: .data0 = CLX_DATA(60, 1, 1, 1), 3376: .clxt = 0, 3377: .clxh = 0, 3378: .urgmode = 1, 3379: .lkgen = 0, 3380: .currbudget = 50, 3381: }, 3382: }, 3383: }; 3384: 3385: static const struct hfi_limits_mit_tbl gen8_2_0_limits_mit_tbl[] = { 3386: { 3387: .feature_id = GMU_MIT_IFF, 3388: .domain = GMU_GX_DOMAIN, 3389: .feature_rev = 0, 3390: .mit_cfg = { 3391: .enable = 1, 3392: .msg_path = 0, 3393: .lkgen = 0, 3394: .mode = 0, 3395: .sid_val = 0xC, 3396: .mit_time = 5, 3397: .curr_limit = 6000, 3398: } 3399: }, 3400: { 3401: .feature_id = GMU_MIT_IFF, 3402: .domain = GMU_MX_DOMAIN, 3403: .feature_rev = 0, 3404: .mit_cfg = { 3405: .enable = 1, 3406: .msg_path = 0, 3407: .lkgen = 0, 3408: .mode = 0, 3409: .sid_val = 0x9, 3410: .mit_time = 2000, 3411: .curr_limit = 6000, 3412: } 3413: }, 3414: { 3415: .feature_id = GMU_MIT_PCLX, 3416: .domain = GMU_GX_DOMAIN, 3417: .feature_rev = 0, 3418: .mit_cfg = { 3419: .enable = 1, 3420: .msg_path = 0, 3421: .lkgen = 0, 3422: .mode = 0, 3423: .sid_val = 7, 3424: .mit_time = 3, 3425: .curr_limit = 30000, 3426: } 3427: }, 3428: { 3429: .feature_id = GMU_MIT_PCLX, 3430: .domain = GMU_MX_DOMAIN, 3431: .feature_rev = 0, 3432: .mit_cfg = { 3433: .enable = 0, 3434: .msg_path = 0, 3435: .lkgen = 0, 3436: .mode = 0, 3437: .sid_val = 7, 3438: .mit_time = 3, 3439: .curr_limit = 6000, 3440: } 3441: }, 3442: }; 3443: 3444: static const struct gen8_limits_mit_cfg gen8_2_0_limits_mit_cfg = { 3445: .limits_mit_tbl = gen8_2_0_limits_mit_tbl, 3446: .len = ARRAY_SIZE(gen8_2_0_limits_mit_tbl), 3447: }; 3448: 3449: static const struct kgsl_regmap_list gen8_2_0_ao_hwcg_regs[] = { 3450: { GEN8_GMUAO_CGC_MODE_CNTL, 0x02220000 }, 3451: { GEN8_GMUAO_CGC_DELAY_CNTL, 0x00110111 }, 3452: { GEN8_GMUAO_CGC_HYST_CNTL, 0x00055555 }, 3453: }; 3454: MATCH LINES: 3589, 3618, 3619, 3620, 3621, 3622, 3643, 3664, 3665, 3666, 3667, 3668, 3701 3577: static const struct therm_tsens_en_cfg tsens_en_cfg_8_2_0 = { 3578: /* 3 GPU slices, each with 3 tsens bits */ 3579: .tsens_sl_cnt = 3, 3580: /* GPU unslice with 2 tsens bits */ 3581: .tsens_us_cnt = 2, 3582: }; 3583: 3584: static struct gen8_thermal_mit_cfg therm_mit_cfg_8_2_0 = { 3585: .therm = &therm_profile_8_0_0, 3586: .tsens_en_cfg = &tsens_en_cfg_8_2_0, 3587: }; 3588: 3589: static const struct hfi_therm_profile_ctrl therm_profile_8_9_0 = { 3590: .feature_en = 1, 3591: .feature_rev = 1, 3592: .tsens_en = 0xFF, 3593: .tj_limit = 900, 3594: .tskin_addr = 0, 3595: .tskin_limit = 0, 3596: .tsens_cfg_cnt = 1, 3597: .tsens_cfg.limit_u = 1130, 3598: .tsens_cfg.limit_l = 10, 3599: .tsens_cfg.margin_u = 30, 3600: .tsens_cfg.margin_l = 20, 3601: .throttle_cfg.throttle_hyst = 250, 3602: .throttle_cfg.num_throttle_cnt = 3, 3603: .throttle_cfg.throttle_lvls[0] = 50, 3604: .throttle_cfg.throttle_lvls[1] = 37, 3605: .throttle_cfg.throttle_lvls[2] = 20, 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, 3643: .gmu_hub_clk_freq = 150000000, 3644: .gen8_snapshot_block_list = &gen8_2_0_snapshot_block_list, 3645: .fast_bus_hint = true, 3646: .bcl_data = GEN8_2_X_BCL_DATA, 3647: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 3648: .noc_timeout_us = 3410, /* 3.41 msec */ 3649: .cl_no_ft_timeout_ms = 6500, 3650: .ctxt_record_size = (19708 * SZ_1K), 3651: .therm_cfg = &therm_mit_cfg_8_2_0, 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, 3695: .ao_hwcg_count = ARRAY_SIZE(gen8_2_0_ao_hwcg_regs), 3696: .gbif = gen8_0_0_gbif_cx_regs, 3697: .gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs), 3698: .hang_detect_cycles = 0xcfffff, 3699: .protected_regs = gen8_2_0_protected_regs, 3700: .nonctxt_regs = gen8_2_0_nonctxt_regs, 3701: .gmu_hub_clk_freq = 150000000, 3702: .gen8_snapshot_block_list = &gen8_2_0_snapshot_block_list, 3703: .fast_bus_hint = true, 3704: .bcl_data = GEN8_2_X_BCL_DATA, 3705: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 3706: .noc_timeout_us = 3410, /* 3.41 msec */ 3707: .cl_no_ft_timeout_ms = 6500, 3708: .ctxt_record_size = (19708 * SZ_1K), 3709: .therm_cfg = &therm_mit_cfg_8_2_0, 3710: .limits_mit_cfg = &gen8_2_0_limits_mit_cfg, 3711: .preempt_level = 1, 3712: .clx_tbl = &gen8_2_0_clx_table, 3713: }; 3714: 3715: static const struct gen8_nonctxt_regs gen8_1_0_nonctxt_regs[] = { 3716: { GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) }, 3717: { GEN8_GRAS_DBG_ECO_CNTL, 0x00000800, BIT(PIPE_BV) | BIT(PIPE_BR) }, 3718: { GEN8_GRAS_TSEFE_DBG_ECO_CNTL, 0x00200000, BIT(PIPE_BV) | BIT(PIPE_BR) }, 3719: { GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) }, 3720: { GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BV) | BIT(PIPE_BR) }, 3721: { GEN8_PC_CONTEXT_SWITCH_STABILIZE_CNTL_1, 0x00000002, BIT(PIPE_BV) | BIT(PIPE_BR) }, 3722: { GEN8_PC_CHICKEN_BITS_1, 0x00000003, BIT(PIPE_BV) | BIT(PIPE_BR) }, 3723: { GEN8_PC_CHICKEN_BITS_2, 0x00000200, BIT(PIPE_BV) | BIT(PIPE_BR) }, 3724: { GEN8_PC_CHICKEN_BITS_3, 0x00500000, BIT(PIPE_BV) | BIT(PIPE_BR) }, 3725: { GEN8_PC_CHICKEN_BITS_4, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) }, MATCH LINES: 3861, 3876, 3878, 3879, 3901 3849: }, 3850: .aqefw_name = "gen80100_aqe.fw", 3851: .sqefw_name = "gen80100_sqe.fw", 3852: .gmufw_name = "gen80100_gmu.bin", 3853: .zap_name = "gen80100_zap.mbn", 3854: .ao_hwcg = gen8_1_0_ao_hwcg_regs, 3855: .ao_hwcg_count = ARRAY_SIZE(gen8_1_0_ao_hwcg_regs), 3856: .gbif = gen8_0_0_gbif_cx_regs, 3857: .gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs), 3858: .hang_detect_cycles = 0xcfffff, 3859: .protected_regs = gen8_1_0_protected_regs, 3860: .nonctxt_regs = gen8_1_0_nonctxt_regs, 3861: .gmu_hub_clk_freq = 200000000, 3862: .gen8_snapshot_block_list = &gen8_1_0_snapshot_block_list, 3863: .fast_bus_hint = true, 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, 3901: .gmu_hub_clk_freq = 150000000, 3902: .gen8_snapshot_block_list = &gen8_2_0_snapshot_block_list, 3903: .fast_bus_hint = true, 3904: .bcl_data = GEN8_2_X_BCL_DATA, 3905: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 3906: .noc_timeout_us = 3410, /* 3.41 msec */ 3907: .cl_no_ft_timeout_ms = 6500, 3908: .ctxt_record_size = (19708 * SZ_1K), 3909: .therm_cfg = &therm_mit_cfg_8_2_0, 3910: .limits_mit_cfg = &gen8_2_0_limits_mit_cfg, 3911: .preempt_level = 1, 3912: .clx_tbl = &gen8_2_0_clx_table, 3913: }; 3914: 3915: /* GEN8_4_0 noncontext register list */ 3916: static const struct gen8_nonctxt_regs gen8_4_0_nonctxt_regs[] = { 3917: { GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) }, 3918: { GEN8_GRAS_DBG_ECO_CNTL, 0x00000800, BIT(PIPE_BR) | BIT(PIPE_BV) }, 3919: { GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BR) | BIT(PIPE_BV) }, 3920: { GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BR) | BIT(PIPE_BV) }, 3921: { GEN8_PC_CONTEXT_SWITCH_STABILIZE_CNTL_1, 0x00000002, BIT(PIPE_BR) | BIT(PIPE_BV) }, 3922: { GEN8_PC_CHICKEN_BITS_1, 0x00000003, BIT(PIPE_BR) | BIT(PIPE_BV) }, 3923: { GEN8_PC_CHICKEN_BITS_2, 0x00000200, BIT(PIPE_BR) | BIT(PIPE_BV) }, 3924: /* Disable BR throttling */ 3925: { GEN8_PC_CHICKEN_BITS_3, 0x00400000, BIT(PIPE_BR) | BIT(PIPE_BV) }, MATCH LINES: 3991, 3993, 4014 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, 4016: .qos_value = gen8_4_0_gbif_client_qos_values, 4017: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 4018: .bcl_data = 1, 4019: .preempt_level = 1, 4020: .ctxt_record_size = (13536 * SZ_1K), 4021: .noc_timeout_us = 3410, /* 3.41 msec */ 4022: .cl_no_ft_timeout_ms = 10000, 4023: }; 4024: 4025: extern const struct gen8_snapshot_block_list gen8_3_0_snapshot_block_list; 4026: 4027: static const struct kgsl_regmap_list gen8_3_0_gbif_cx_regs[] = { 4028: { GEN8_GBIF_QSB_SIDE0, 0x00071e20 }, 4029: { GEN8_GBIF_QSB_SIDE1, 0x00071e20 }, 4030: { GEN8_GBIF_QSB_SIDE2, 0x00071e20 }, 4031: { GEN8_GBIF_QSB_SIDE3, 0x00071e20 }, 4032: { GEN8_GBIF_CX_CONFIG, 0x20023000 }, 4033: }; 4034: 4035: static const struct kgsl_regmap_list gen8_8_0_gbif_cx_regs[] = { 4036: { GEN8_GBIF_QSB_SIDE0, 0x00071e20 }, 4037: { GEN8_GBIF_QSB_SIDE1, 0x00071e20 }, 4038: { GEN8_GBIF_QSB_SIDE2, 0x00071e20 }, MATCH LINES: 4095, 4115 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, 4119: }; 4120: 4121: /* GEN8_6_0 noncontext register list */ 4122: static const struct gen8_nonctxt_regs gen8_6_0_nonctxt_regs[] = { 4123: { GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) }, 4124: { GEN8_GRAS_DBG_ECO_CNTL, 0x00000800, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4125: { GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4126: { GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4127: { GEN8_PC_CONTEXT_SWITCH_STABILIZE_CNTL_1, 0x00000002, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4128: { GEN8_PC_CHICKEN_BITS_1, 0x00000003, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4129: { GEN8_PC_CHICKEN_BITS_2, 0x00000200, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4130: { GEN8_PC_CHICKEN_BITS_3, 0x00500000, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4131: { GEN8_PC_CHICKEN_BITS_4, 0x00500050, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4132: /* Configure GBIF GX registers */ 4133: { GEN8_UCHE_GBIF_GX_CONFIG, 0x010240e0, BIT(PIPE_NONE) }, 4134: { GEN8_RBBM_GBIF_CLIENT_QOS_CNTL, 0x22122212, BIT(PIPE_NONE) }, 4135: /* Enable full concurrent resolve and unresolves */ 4136: { GEN8_RB_CCU_CNTL, 0x00000068, BIT(PIPE_BR) }, 4137: { GEN8_RB_GC_GMEM_PROTECT, 0x02600000, BIT(PIPE_BR) }, 4138: /* Configure number of outstanding transactions to 32 */ 4139: { GEN8_RB_RESOLVE_PREFETCH_CNTL, 0x00000007, BIT(PIPE_BR) }, MATCH LINES: 4194, 4195, 4216, 4232, 4252 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, 4256: .noc_timeout_us = 3410, /* 3.41 msec */ 4257: .bcl_data = 1, 4258: }; 4259: 4260: /* GEN8_9_0 noncontext register list */ 4261: static const struct gen8_nonctxt_regs gen8_9_0_nonctxt_regs[] = { 4262: { GEN8_RBBM_GBIF_CLIENT_QOS_CNTL, 0x22122212, BIT(PIPE_NONE) }, 4263: { GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL, 0x00000030, BIT(PIPE_NONE) }, 4264: { GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL2, 0x00000030, BIT(PIPE_NONE) }, 4265: /* Disable Dead Draw Merge scheme on RB-HLSQ */ 4266: { GEN8_RB_RBP_CNTL, BIT(5), BIT(PIPE_BV) | BIT(PIPE_BR) }, 4267: { GEN8_RBBM_INTERFACE_HANG_INT_CNTL, 0x0fffffff, BIT(PIPE_NONE) }, 4268: { GEN8_RBBM_POWER_UP_RESET_SW_OVERRIDE, 0x70809060, BIT(PIPE_NONE) }, 4269: { GEN8_RBBM_POWER_UP_RESET_SW_BV_OVERRIDE, 0x30000000, BIT(PIPE_NONE) }, 4270: { GEN8_RBBM_CGC_P2S_CNTL, 0x00000040, BIT(PIPE_NONE) }, 4271: /* Disable mode_switch optimization in UMAS */ 4272: { GEN8_SP_CHICKEN_BITS, BIT(26), BIT(PIPE_NONE) }, 4273: /* Disable LPAC large-LM mode */ 4274: { GEN8_SP_SS_CHICKEN_BITS_0, BIT(3), BIT(PIPE_NONE) }, 4275: /* Disable PS out of order retire */ 4276: { GEN8_SP_CHICKEN_BITS_2, 0xc21800, BIT(PIPE_NONE) }, MATCH LINES: 4326, 4327, 4328, 4329, 4330, 4352, 4370, 4387, 4388 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, 4351: .nonctxt_regs = gen8_9_0_nonctxt_regs, 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), 4396: .hang_detect_cycles = 0xc3ffff, 4397: .veto_fal10 = true, 4398: .protected_regs = a620_protected_regs, 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 | MATCH LINES: 4445, 4456, 4480, 4504, 4506, 4507, 4520, 4521, 4534, 4535, 4548, 4549 4433: }, 4434: .aqefw_name = "gen80100_aqe.fw", 4435: .sqefw_name = "gen80100_sqe.fw", 4436: .gmufw_name = "gen80100_gmu.bin", 4437: .zap_name = "gen80100_zap.mbn", 4438: .ao_hwcg = gen8_1_0_ao_hwcg_regs, 4439: .ao_hwcg_count = ARRAY_SIZE(gen8_1_0_ao_hwcg_regs), 4440: .gbif = gen8_0_0_gbif_cx_regs, 4441: .gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs), 4442: .hang_detect_cycles = 0xcfffff, 4443: .protected_regs = gen8_1_0_protected_regs, 4444: .nonctxt_regs = gen8_1_0_nonctxt_regs, 4445: .gmu_hub_clk_freq = 200000000, 4446: .fast_bus_hint = true, 4447: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 4448: .noc_timeout_us = 3410, /* 3.41 msec */ 4449: .cl_no_ft_timeout_ms = 6500, 4450: .ctxt_record_size = (23088 * SZ_1K), 4451: .bcl_data = 1, 4452: .gen8_snapshot_block_list = &gen8_10_0_snapshot_block_list, 4453: .preempt_level = 1, 4454: }; 4455: 4456: static const struct hfi_clx_table_v2_cmd gen8_11_0_clx_table = { 4457: .version = (2 << 16) | 1, 4458: .domain = { 4459: /* GFX domain */ 4460: { 4461: .data0 = CLX_DATA(60, 5, 0, 1), 4462: .clxt = 0, 4463: .clxh = 0, 4464: .urgmode = 1, 4465: .lkgen = 0, 4466: .currbudget = 100, 4467: }, 4468: /* MxG domain */ 4469: { 4470: .data0 = CLX_DATA(30, 1, 1, 1), 4471: .clxt = 0, 4472: .clxh = 0, 4473: .urgmode = 1, 4474: .lkgen = 0, 4475: .currbudget = 100, 4476: }, 4477: }, 4478: }; 4479: 4480: static const struct hfi_clx_table_v2_cmd gen8_14_0_clx_table = { 4481: .version = (2 << 16) | 1, 4482: .domain = { 4483: /* GFX domain */ 4484: { 4485: .data0 = CLX_DATA(60, 4, 1, 1), 4486: .clxt = 10, 4487: .clxh = 0, 4488: .urgmode = 1, 4489: .lkgen = 0, 4490: .currbudget = 100, 4491: }, 4492: /* MxG domain */ 4493: { 4494: .data0 = CLX_DATA(60, 1, 1, 1), 4495: .clxt = 10, 4496: .clxh = 0, 4497: .urgmode = 1, 4498: .lkgen = 0, 4499: .currbudget = 100, 4500: }, 4501: }, 4502: }; 4503: 4504: static const struct hfi_limits_mit_tbl gen8_11_0_limits_mit_tbl[] = { 4505: { 4506: .feature_id = GMU_MIT_IFF, 4507: .domain = GMU_GX_DOMAIN, 4508: .feature_rev = 0, 4509: .mit_cfg = { 4510: .enable = 1, 4511: .msg_path = 0, 4512: .lkgen = 0, 4513: .mode = 0, 4514: .sid_val = 0xC, 4515: .mit_time = 5, 4516: .curr_limit = 30000, 4517: } 4518: }, 4519: { 4520: .feature_id = GMU_MIT_IFF, 4521: .domain = GMU_MX_DOMAIN, 4522: .feature_rev = 0, 4523: .mit_cfg = { 4524: .enable = 1, 4525: .msg_path = 0, 4526: .lkgen = 0, 4527: .mode = BIT(1), 4528: .sid_val = 0x12, 4529: .mit_time = 2000, 4530: .curr_limit = 5000, 4531: } 4532: }, 4533: { 4534: .feature_id = GMU_MIT_PCLX, 4535: .domain = GMU_GX_DOMAIN, 4536: .feature_rev = 0, 4537: .mit_cfg = { 4538: .enable = 1, 4539: .msg_path = 0, 4540: .lkgen = 0, 4541: .mode = 0, 4542: .sid_val = 0x8, 4543: .mit_time = 3, 4544: .curr_limit = 30000, 4545: } 4546: }, 4547: { 4548: .feature_id = GMU_MIT_PCLX, 4549: .domain = GMU_MX_DOMAIN, 4550: .feature_rev = 0, 4551: .mit_cfg = { 4552: .enable = 0, 4553: .msg_path = 0, 4554: .lkgen = 0, 4555: .mode = BIT(1), 4556: .sid_val = 0x8, 4557: .mit_time = 3, 4558: .curr_limit = 5000, 4559: } 4560: }, 4561: }; 4562: 4563: static const struct gen8_limits_mit_cfg gen8_11_0_limits_mit_cfg = { 4564: .limits_mit_tbl = gen8_11_0_limits_mit_tbl, 4565: .len = ARRAY_SIZE(gen8_11_0_limits_mit_tbl), 4566: }; 4567: 4568: /* GEN8_11_0 protected register list */ 4569: static const struct gen8_protected_regs gen8_11_0_protected_regs[] = { 4570: { GEN8_CP_PROTECT_REG_GLOBAL + 0, 0x00008, 0x003a3, 0 }, 4571: { GEN8_CP_PROTECT_REG_GLOBAL + 1, 0x003b4, 0x0043f, 0 }, 4572: { GEN8_CP_PROTECT_REG_GLOBAL + 2, 0x00440, 0x0045f, 1 }, 4573: { GEN8_CP_PROTECT_REG_GLOBAL + 3, 0x00580, 0x005df, 0 }, MATCH LINES: 4753, 4763 4741: }, 4742: .aqefw_name = "gen81100_aqe.fw", 4743: .sqefw_name = "gen81100_sqe.fw", 4744: .gmufw_name = "gen81100_gmu.bin", 4745: .zap_name = "gen81100_zap.mbn", 4746: .ao_hwcg = gen8_2_0_ao_hwcg_regs, 4747: .ao_hwcg_count = ARRAY_SIZE(gen8_2_0_ao_hwcg_regs), 4748: .gbif = gen8_11_0_gbif_cx_regs, 4749: .gbif_count = ARRAY_SIZE(gen8_11_0_gbif_cx_regs), 4750: .hang_detect_cycles = 0xcfffff, 4751: .protected_regs = gen8_11_0_protected_regs, 4752: .nonctxt_regs = gen8_11_0_nonctxt_regs, 4753: .gmu_hub_clk_freq = 150000000, 4754: .gen8_snapshot_block_list = &gen8_11_0_snapshot_block_list, 4755: .fast_bus_hint = true, 4756: .bcl_data = 1, 4757: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 4758: .noc_timeout_us = 3410, /* 3.41 msec */ 4759: .cl_no_ft_timeout_ms = 6500, 4760: .ctxt_record_size = (19708 * SZ_1K), 4761: .limits_mit_cfg = &gen8_11_0_limits_mit_cfg, 4762: .preempt_level = 1, 4763: .gmu_mx_gdsc = true, 4764: .three_rail_memory = true, 4765: .malu = true, 4766: .clx_tbl = &gen8_11_0_clx_table, 4767: }; 4768: 4769: /* GEN8_11_1 noncontext register list */ 4770: static const struct gen8_nonctxt_regs gen8_11_1_nonctxt_regs[] = { 4771: { GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) }, 4772: { GEN8_CP_MULTIDRAW_CNTL, 0x00000001, BIT(PIPE_NONE) }, 4773: /* Keep the raster direction as topleft */ 4774: { GEN8_GRAS_DBG_ECO_CNTL, 0x01000800, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4775: { GEN8_GRAS_TSEFE_DBG_ECO_CNTL, 0x00200000, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4776: /* GEN8_GRAS_NC_MODE_CNTL explicitly set elsewhere */ 4777: { GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4778: { GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4779: { GEN8_PC_CONTEXT_SWITCH_STABILIZE_CNTL_1, 0x00000002, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4780: /* BIT(11): Disable skipIdx to avoid PDMA hang with restart-index draws */ 4781: { GEN8_PC_CHICKEN_BITS_1, 0x00000803, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4782: { GEN8_PC_CHICKEN_BITS_2, 0x00000200, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4783: { GEN8_PC_CHICKEN_BITS_3, 0x00400000, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4784: { GEN8_PC_CHICKEN_BITS_4, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4785: /* 4786: * BIT(28): Disable GS Quad primitive 4787: * BIT(30): Disable skipIdx to avoid PDMA hang with restart-index draws MATCH LINES: 4864, 4865, 4866, 4867, 4868, 4871, 4900, 4910 4852: { GEN8_VFD_CB_LP_REQ_CNT, 0x00080020, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4853: { GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) }, 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), 4895: .gbif = gen8_11_0_gbif_cx_regs, 4896: .gbif_count = ARRAY_SIZE(gen8_11_0_gbif_cx_regs), 4897: .hang_detect_cycles = 0xcfffff, 4898: .protected_regs = gen8_11_0_protected_regs, 4899: .nonctxt_regs = gen8_11_1_nonctxt_regs, 4900: .gmu_hub_clk_freq = 150000000, 4901: .gen8_snapshot_block_list = &gen8_11_0_snapshot_block_list, 4902: .fast_bus_hint = true, 4903: .bcl_data = GEN8_2_X_BCL_DATA, 4904: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(4224, 4), 4905: .noc_timeout_us = 3410, /* 3.41 msec */ 4906: .cl_no_ft_timeout_ms = 6500, 4907: .ctxt_record_size = (19708 * SZ_1K), 4908: .limits_mit_cfg = &gen8_11_0_limits_mit_cfg, 4909: .preempt_level = 1, 4910: .gmu_mx_gdsc = true, 4911: .three_rail_memory = true, 4912: .malu = true, 4913: .clx_tbl = &gen8_11_0_clx_table, 4914: }; 4915: 4916: static const struct gen8_nonctxt_regs gen8_14_0_nonctxt_regs[] = { 4917: { GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) }, 4918: { GEN8_CP_MULTIDRAW_CNTL, 0x00000001, BIT(PIPE_NONE) }, 4919: /* Keep the raster direction as topleft */ 4920: { GEN8_GRAS_DBG_ECO_CNTL, 0x01000800, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4921: { GEN8_GRAS_TSEFE_DBG_ECO_CNTL, 0x00200000, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4922: /* GEN8_GRAS_NC_MODE_CNTL explicitly set elsewhere */ 4923: { GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4924: { GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4925: { GEN8_PC_CONTEXT_SWITCH_STABILIZE_CNTL_1, 0x00000002, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4926: /* BIT(11): Disable skipIdx to avoid PDMA hang with restart-index draws */ 4927: { GEN8_PC_CHICKEN_BITS_1, 0x00000803, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4928: { GEN8_PC_CHICKEN_BITS_2, 0x00000200, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4929: { GEN8_PC_CHICKEN_BITS_3, 0x00400000, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4930: { GEN8_PC_CHICKEN_BITS_4, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4931: /* 4932: * BIT(28): Disable GS Quad primitive 4933: * BIT(30): Disable skipIdx to avoid PDMA hang with restart-index draws 4934: */ MATCH LINES: 5008, 5009, 5010, 5011, 5012, 5015, 5044, 5053 4996: { GEN8_VFD_CB_LP_REQ_CNT, 0x00080020, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4997: { GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) }, 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), 5039: .gbif = gen8_11_0_gbif_cx_regs, 5040: .gbif_count = ARRAY_SIZE(gen8_11_0_gbif_cx_regs), 5041: .hang_detect_cycles = 0xcfffff, 5042: .protected_regs = gen8_11_0_protected_regs, 5043: .nonctxt_regs = gen8_14_0_nonctxt_regs, 5044: .gmu_hub_clk_freq = 150000000, 5045: .gen8_snapshot_block_list = &gen8_11_0_snapshot_block_list, 5046: .fast_bus_hint = true, 5047: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(4224, 4), 5048: .noc_timeout_us = 3410, /* 3.41 msec */ 5049: .cl_no_ft_timeout_ms = 6500, 5050: .ctxt_record_size = (13564 * SZ_1K), 5051: .limits_mit_cfg = &gen8_11_0_limits_mit_cfg, 5052: .preempt_level = 1, 5053: .gmu_mx_gdsc = true, 5054: .three_rail_memory = true, 5055: .malu = false, 5056: .clx_tbl = &gen8_14_0_clx_table, 5057: }; 5058: 5059: static const struct adreno_gpu_core *adreno_gpulist[] = { 5060: &adreno_gpu_core_a306, /* Deprecated */ 5061: &adreno_gpu_core_a306a, /* Deprecated */ 5062: &adreno_gpu_core_a304, /* Deprecated */ 5063: &adreno_gpu_core_a405, /* Deprecated */ 5064: &adreno_gpu_core_a418, /* Deprecated */ 5065: &adreno_gpu_core_a420, /* Deprecated */ 5066: &adreno_gpu_core_a430, /* Deprecated */ 5067: &adreno_gpu_core_a530v1, /* Deprecated */ 5068: &adreno_gpu_core_a530v2.base, 5069: &adreno_gpu_core_a530v3.base, 5070: &adreno_gpu_core_a505.base, 5071: &adreno_gpu_core_a506.base, 5072: &adreno_gpu_core_a510.base, 5073: &adreno_gpu_core_a540v1, /* Deprecated */ 5074: &adreno_gpu_core_a540v2.base, 5075: &adreno_gpu_core_a512.base, 5076: &adreno_gpu_core_a508.base, 5077: &adreno_gpu_core_a630v1, /* Deprecated */ --- FILE: \adreno.c | HITS: 59 --- MATCH LINES: 42 30: #include 31: #endif 32: #if (KERNEL_VERSION(6, 17, 0) <= LINUX_VERSION_CODE) 33: #include 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" 43: #include "kgsl_power_trace.h" 44: #include "kgsl_reclaim.h" 45: #include "kgsl_trace.h" 46: #include "kgsl_util.h" 47: 48: /* Include the master list of GPU cores that are supported */ 49: #include "adreno-gpulist.h" 50: 51: #define HOSTADDR_IN_MEMDESC(_addr, _memdesc) \ 52: (((_addr) >= (_memdesc)->hostptr) && \ 53: ((_addr) < ((_memdesc)->hostptr + (_memdesc)->size))) 54: 55: /* Indicates that the context record table is present in CP ucode */ 56: #define CTXT_RECORD_TBL_MAGIC 0xADDED 57: #define CTXT_RECORD_MAGIC_OFFSET 5 58: #define CTXT_TBL_OFFSET 6 59: /* Mask for extracting the instruction payload from ucode instructions */ 60: #define CTXT_RECORD_PAYLOAD_MASK GENMASK(23, 0) 61: 62: /** 63: * struct gpu_ctxt_record - Information about GPU context record, defined per GPU. 64: * If a ucode is shared by multiple targets, there will be multiple instances 65: * of this structure embedded in the ucode. Instances of this structure will be 66: * present immediately after ctxt_record_info. MATCH LINES: 636 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: /* 654: * adreno_hang_int_callback() - Isr for fatal interrupts that hang GPU 655: * @adreno_dev: Pointer to device 656: * @bit: Interrupt bit 657: */ 658: void adreno_hang_int_callback(struct adreno_device *adreno_dev, int bit) 659: { 660: dev_crit_ratelimited(KGSL_DEVICE(adreno_dev)->dev, MATCH LINES: 847 835: 836: static struct { 837: unsigned int quirk; 838: const char *prop; 839: } adreno_quirks[] = { 840: { ADRENO_QUIRK_TWO_PASS_USE_WFI, "qcom,gpu-quirk-two-pass-use-wfi" }, 841: { ADRENO_QUIRK_CRITICAL_PACKETS, "qcom,gpu-quirk-critical-packets" }, 842: { ADRENO_QUIRK_FAULT_DETECT_MASK, "qcom,gpu-quirk-fault-detect-mask" }, 843: { ADRENO_QUIRK_DISABLE_RB_DP2CLOCKGATING, 844: "qcom,gpu-quirk-dp2clockgating-disable" }, 845: { ADRENO_QUIRK_DISABLE_LMLOADKILL, 846: "qcom,gpu-quirk-lmloadkill-disable" }, 847: { ADRENO_QUIRK_HFI_USE_REG, "qcom,gpu-quirk-hfi-use-reg" }, 848: { ADRENO_QUIRK_SECVID_SET_ONCE, "qcom,gpu-quirk-secvid-set-once" }, 849: { ADRENO_QUIRK_LIMIT_UCHE_GBIF_RW, 850: "qcom,gpu-quirk-limit-uche-gbif-rw" }, 851: { ADRENO_QUIRK_CX_GDSC, "qcom,gpu-quirk-cx-gdsc" }, 852: }; 853: 854: static int adreno_get_chipid(struct platform_device *pdev, u32 *chipid) 855: { 856: u32 id; 857: 858: if (!of_property_read_u32(pdev->dev.of_node, "qcom,chipid", chipid)) 859: return 0; 860: 861: id = socinfo_get_partinfo_chip_id(SOCINFO_PART_GPU); 862: if (id) 863: *chipid = id; 864: 865: return id ? 0 : -EINVAL; 866: } 867: 868: static void 869: adreno_update_soc_hw_revision_quirks(struct adreno_device *adreno_dev, 870: struct platform_device *pdev) 871: { MATCH LINES: 1275 1263: 1264: static int adreno_of_parse_pwrlevels(struct adreno_device *adreno_dev) 1265: { 1266: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1267: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1268: struct device *dev = &device->pdev->dev; 1269: struct dev_pm_opp *opp; 1270: u32 index = 0, count = 0, i; 1271: unsigned long freq = ULONG_MAX; 1272: int ret; 1273: 1274: /* Only handle the core clock for no GMU and RGMU targets */ 1275: if (is_gmu_wrapper_available() || ADRENO_GPUREV(adreno_dev) == ADRENO_REV_A612) { 1276: /* 1277: * This can only be done before devm_pm_opp_of_add_table(), or 1278: * dev_pm_opp_set_config() will WARN_ON() 1279: */ 1280: if (IS_ERR(devm_clk_get(dev, "core"))) { 1281: /* 1282: * If "core" is absent, go for the legacy clock name. 1283: * If we got this far in probing, it's a given one of 1284: * them exists. 1285: */ 1286: ret = devm_pm_opp_set_clkname(dev, "core_clk"); 1287: } else 1288: ret = devm_pm_opp_set_clkname(dev, "core"); 1289: 1290: if (ret) { 1291: dev_err(dev, "Failed to set OPP clock name, ret: %d\n", ret); 1292: return ret; 1293: } 1294: } 1295: 1296: ret = devm_pm_opp_of_add_table(&device->pdev->dev); 1297: if (ret) { 1298: dev_err(dev, "Unable to initialize opp table from device tree\n"); 1299: return ret; MATCH LINES: 1749, 1752, 1754, 1756, 1758, 1760, 1762, 1764, 1766, 1768, 1769, 1770, 1772, 1774, 1776, 1778, 1780, 1782, 1784 1737: #endif 1738: 1739: return 0; 1740: } 1741: #else 1742: static int adreno_probe_llcc(struct adreno_device *adreno_dev, 1743: struct platform_device *pdev) 1744: { 1745: return 0; 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"; 1784: case HFI_FEATURE_FAST_CONTEXT_DESTROY: 1785: return "FAST_CONTEXT_DESTROY"; 1786: } 1787: return "unknown"; 1788: } 1789: 1790: static void adreno_regmap_op_preaccess(struct kgsl_regmap_region *region) 1791: { 1792: struct kgsl_device *device = region->priv; 1793: /* 1794: * kgsl panic notifier will be called in atomic context to get 1795: * GPU snapshot. Also panic handler will skip snapshot dumping 1796: * incase GPU is in SLUMBER state. So we can safely ignore the 1797: * kgsl_pre_hwaccess(). 1798: */ 1799: if (!device->snapshot_atomic && !in_interrupt()) 1800: kgsl_pre_hwaccess(device); 1801: } 1802: 1803: static const struct kgsl_regmap_ops adreno_regmap_ops = { 1804: .preaccess = adreno_regmap_op_preaccess, 1805: }; 1806: 1807: static const struct kgsl_functable adreno_functable; 1808: MATCH LINES: 1913, 1914 1901: 1902: if (pwr->gx_pd) { 1903: pd = container_of(pwr->gx_pd->pm_domain, struct generic_pm_domain, domain); 1904: 1905: if (pd->prepared_count) { 1906: dev_err_ratelimited(device->dev, 1907: "unexpected gx pd prepared_count:%d event:%lu\n", 1908: pd->prepared_count, event); 1909: return NOTIFY_BAD; 1910: } 1911: } 1912: 1913: if (pwr->gmu_cx_pd) { 1914: pd = container_of(pwr->gmu_cx_pd->pm_domain, struct generic_pm_domain, domain); 1915: 1916: if (pd->prepared_count) { 1917: dev_err_ratelimited(device->dev, 1918: "unexpected cx pd prepared_count:%d event:%lu\n", 1919: pd->prepared_count, event); 1920: return NOTIFY_BAD; 1921: } 1922: } 1923: 1924: if (event == PM_SUSPEND_PREPARE) { 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; MATCH LINES: 2104 2092: 2093: return ret; 2094: } 2095: #endif 2096: 2097: static int adreno_bind_components(struct device *dev) 2098: { 2099: /* 2100: * Bind components before performing the KGSL platform probe. 2101: * Note: with standard DT bindings, there are no components to bind 2102: * for no GMU targets, so skip invoking component_bind_all in this case. 2103: */ 2104: if (!is_gmu_wrapper_available()) 2105: return component_bind_all(dev, NULL); 2106: 2107: return 0; 2108: } 2109: 2110: int adreno_device_probe(struct platform_device *pdev, 2111: struct adreno_device *adreno_dev) 2112: { 2113: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2114: struct device *dev = &pdev->dev; 2115: struct resource *res; 2116: unsigned int priv = 0; 2117: int status; 2118: u32 size; 2119: 2120: KGSL_BOOT_MARKER("GPU Init"); 2121: 2122: /* Initialize the adreno device structure */ 2123: adreno_setup_device(adreno_dev); 2124: 2125: dev_set_drvdata(dev, device); 2126: 2127: device->pdev = pdev; 2128: adreno_dev->zap_enabled = adreno_check_zap_enabled(device); MATCH LINES: 2297, 2331 2285: 2286: if (WARN(!size, "The snapshot size was not specified in the gpucore\n")) 2287: size = SZ_1M; 2288: 2289: kgsl_device_snapshot_probe(device, size); 2290: 2291: adreno_debugfs_init(adreno_dev); 2292: 2293: adreno_dev->perfcounter = false; 2294: 2295: adreno_sysfs_init(adreno_dev); 2296: 2297: if (!ADRENO_FEATURE(adreno_dev, ADRENO_GMU_BASED_DCVS)) 2298: device->host_based_dcvs = true; 2299: else if (ADRENO_FEATURE(adreno_dev, ADRENO_DCVS_PROFILE)) 2300: adreno_dev->dcvs_profile_enabled = true; 2301: 2302: kgsl_pwrscale_init(device, pdev); 2303: 2304: if (ADRENO_FEATURE(adreno_dev, ADRENO_L3_VOTE)) 2305: device->l3_vote = true; 2306: 2307: #ifdef CONFIG_INPUT 2308: 2309: if (!of_property_read_bool(pdev->dev.of_node, 2310: "qcom,disable-wake-on-touch")) { 2311: adreno_input_handler.private = device; 2312: /* 2313: * It isn't fatal if we cannot register the input handler. Sad, 2314: * perhaps, but not fatal 2315: */ 2316: if (input_register_handler(&adreno_input_handler)) { 2317: adreno_input_handler.private = NULL; 2318: dev_err(device->dev, 2319: "Unable to register the input handler\n"); 2320: } 2321: } 2322: #endif 2323: 2324: /* 2325: * With power domains, we cannot perform recovery during a concurrent system suspend because 2326: * system suspend path increments power domain prepared_count, which prevents successful 2327: * toggling of the power domain gdsc while system is in suspend path. Hence, get 2328: * notifications when system has come out of suspend completely, so that we can perform 2329: * fault recovery. 2330: */ 2331: if (device->pwrctrl.gx_pd || device->pwrctrl.gmu_cx_pd) { 2332: adreno_dev->pm_nb.notifier_call = adreno_pm_notifier; 2333: register_pm_notifier(&adreno_dev->pm_nb); 2334: } 2335: 2336: kgsl_qcom_va_md_register(device); 2337: 2338: KGSL_BOOT_MARKER("GPU Ready"); 2339: 2340: return 0; 2341: 2342: err_unbind: 2343: component_unbind_all(dev, NULL); 2344: 2345: err_remove_llcc: 2346: if (!IS_ERR_OR_NULL(adreno_dev->gpu_llc_slice)) 2347: llcc_slice_putd(adreno_dev->gpu_llc_slice); 2348: 2349: if (!IS_ERR_OR_NULL(adreno_dev->gpuhtw_llc_slice)) 2350: llcc_slice_putd(adreno_dev->gpuhtw_llc_slice); 2351: 2352: err_bus_close: 2353: kgsl_bus_close(device); 2354: 2355: err: MATCH LINES: 2603, 2612, 2613 2591: if (ret) 2592: return ret; 2593: 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); 2635: } 2636: } 2637: MATCH LINES: 2825 2813: &adreno_dev->ram_cycles_lo, NULL); 2814: } 2815: 2816: if (ret) 2817: dev_err(KGSL_DEVICE(adreno_dev)->dev, 2818: "Unable to get perf counters for bus DCVS\n"); 2819: } 2820: 2821: #define ADRENO_AHB_MIN_TIMEOUT_VAL_USEC 1000 2822: 2823: u32 adreno_get_ahb_timeout_val(struct adreno_device *adreno_dev, u32 noc_timeout_us) 2824: { 2825: u64 cycles, hub_clk_freq = adreno_dev->gmu_hub_clk_freq; 2826: u32 timeout_val; 2827: 2828: if (!noc_timeout_us) 2829: return 0; 2830: 2831: do_div(hub_clk_freq, HZ_PER_MHZ); 2832: cycles = hub_clk_freq * noc_timeout_us; 2833: 2834: /* 2835: * Get max possible AHB timeout value which is less than the GPU NOC timeout value. 2836: * When cycles are exact power of two, the calculated AHB timeout value will be same 2837: * as GPU config NOC timeout. Just reduce one cycle to make sure we do not program AHB 2838: * timeout same as GPU config NOC timeout. 2839: */ 2840: if (is_power_of_2(cycles)) 2841: cycles -= 1; 2842: 2843: timeout_val = ilog2(cycles); 2844: 2845: /* 2846: * Make sure, AHB timeout value fits into bit fields and it is not too low 2847: * which can cause false timeouts. 2848: */ 2849: if ((timeout_val > GENMASK(4, 0)) || MATCH LINES: 3330, 3339, 3340 3318: { 3319: int i; 3320: 3321: if (!list) 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; 3359: } 3360: 3361: if (copy_from_user(&pwr, 3362: (void __user *)constraint->data, 3363: sizeof(pwr))) { 3364: status = -EFAULT; MATCH LINES: 3379, 3395 3367: 3368: max_supported_level = (device->host_based_dcvs) ? 3369: KGSL_CONSTRAINT_PWR_MAXLEVELS - 1 : KGSL_CONSTRAINT_PWR_PERC_MAX; 3370: if (pwr.level > max_supported_level) { 3371: status = -EINVAL; 3372: break; 3373: } 3374: 3375: context->pwr_constraint.type = 3376: KGSL_CONSTRAINT_PWRLEVEL; 3377: context->pwr_constraint.sub_type = pwr.level; 3378: 3379: adreno_gmu_based_dcvs_pwr_ops(device, context->id, GPU_PWRLEVEL_OP_PERF_HINT); 3380: 3381: trace_kgsl_user_pwrlevel_constraint(device, 3382: context->id, 3383: context->pwr_constraint.type, 3384: context->pwr_constraint.sub_type); 3385: } 3386: break; 3387: case KGSL_CONSTRAINT_NONE: { 3388: if (context->pwr_constraint.type == KGSL_CONSTRAINT_PWRLEVEL) { 3389: trace_kgsl_user_pwrlevel_constraint(device, 3390: context->id, 3391: KGSL_CONSTRAINT_NONE, 3392: context->pwr_constraint.sub_type); 3393: 3394: context->pwr_constraint.type = KGSL_CONSTRAINT_NONE; 3395: adreno_gmu_based_dcvs_pwr_ops(device, context->id, 3396: GPU_PWRLEVEL_OP_PERF_HINT); 3397: } else { 3398: context->pwr_constraint.type = KGSL_CONSTRAINT_NONE; 3399: } 3400: } 3401: break; 3402: case KGSL_CONSTRAINT_L3_PWRLEVEL: { 3403: struct kgsl_device_constraint_pwrlevel pwr; 3404: 3405: if (constraint->size != sizeof(pwr)) { 3406: status = -EINVAL; 3407: break; 3408: } 3409: 3410: if (copy_from_user(&pwr, constraint->data, sizeof(pwr))) { 3411: status = -EFAULT; 3412: break; 3413: } 3414: 3415: status = register_l3_voter(device); 3416: if (status) 3417: break; 3418: 3419: if (pwr.level >= KGSL_CONSTRAINT_PWR_MAXLEVELS) MATCH LINES: 3474, 3475, 3482, 3485, 3486, 3497, 3499, 3518, 3519 3462: if (type != KGSL_PROP_PWRCTRL) 3463: return -ENODEV; 3464: 3465: if (sizebytes != sizeof(enable)) 3466: return -EINVAL; 3467: 3468: if (copy_from_user(&enable, value, sizeof(enable))) 3469: return -EFAULT; 3470: 3471: kgsl_mutex_lock(&device->mutex); 3472: 3473: if (enable) { 3474: if (gmu_core_isenabled(device)) 3475: clear_bit(GMU_DISABLE_SLUMBER, &device->gmu_core.flags); 3476: else 3477: device->pwrctrl.ctrl_flags = 0; 3478: 3479: if (device->host_based_dcvs) 3480: kgsl_pwrscale_governor_enable(device); 3481: else 3482: device->ftbl->gmu_based_dcvs_pwr_ops(device, enable, 3483: GPU_PWRLEVEL_OP_DCVS_ENABLE); 3484: } else { 3485: if (gmu_core_isenabled(device)) { 3486: set_bit(GMU_DISABLE_SLUMBER, &device->gmu_core.flags); 3487: 3488: if (!adreno_active_count_get(adreno_dev)) 3489: adreno_active_count_put(adreno_dev); 3490: } else { 3491: kgsl_pwrctrl_change_state(device, KGSL_STATE_ACTIVE); 3492: device->pwrctrl.ctrl_flags = KGSL_PWR_ON; 3493: } 3494: if (device->host_based_dcvs) { 3495: kgsl_pwrscale_governor_disable(device, true); 3496: } else { 3497: device->ftbl->gmu_based_dcvs_pwr_ops(device, enable, 3498: GPU_PWRLEVEL_OP_DCVS_ENABLE); 3499: device->ftbl->gmu_based_dcvs_pwr_ops(device, 0, GPU_PWRLEVEL_OP_GPUCLK); 3500: } 3501: } 3502: 3503: kgsl_mutex_unlock(&device->mutex); 3504: 3505: return 0; 3506: } 3507: 3508: static void adreno_alloc_dcvs_profile_memory(struct kgsl_device *device, 3509: struct kgsl_process_private *proc_priv) 3510: { 3511: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 3512: struct kgsl_memdesc *md = &proc_priv->profile.md; 3513: u32 sizebytes; 3514: 3515: if (!ADRENO_FEATURE(adreno_dev, ADRENO_DCVS_PROFILE)) 3516: return; 3517: 3518: if (!gmu_core_alloc_kernel_block(device, md, 3519: SZ_4K, GMU_NONCACHED_KERNEL, 3520: IOMMU_READ | IOMMU_WRITE | IOMMU_PRIV)) { 3521: /* KMD need to initialize KGSL region to KGSL_DCVS_ATTR_UNUSED for 3522: * torn state handling as per design and second half region to 0 so that 3523: * if there is no profile ever registered for a process, GMU can skip 3524: * tracking for this profile. 3525: */ 3526: sizebytes = md->size >> 1; 3527: memset(md->hostptr, KGSL_DCVS_ATTR_UNUSED, sizebytes); 3528: memset(md->hostptr + sizebytes, 0, sizebytes); 3529: } 3530: } 3531: 3532: static int adreno_set_dcvs_profile(struct kgsl_device_private *dev_priv, 3533: void __user *data, u32 sizebytes) 3534: { 3535: struct kgsl_device *device = dev_priv->device; 3536: struct kgsl_process_private *proc_priv = dev_priv->process_priv; 3537: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 3538: const struct adreno_hwsched_ops *hwsched_ops = adreno_dev->hwsched.hwsched_ops; 3539: struct kgsl_memdesc *md = &proc_priv->profile.md; 3540: struct kgsl_dcvs_profile param = {0}; 3541: struct kgsl_dcvs_attrs attrs; 3542: u32 size; 3543: int ret = 0; MATCH LINES: 4268 4256: ret = kgsl_check_context_state(context); 4257: if (ret) { 4258: kgsl_mutex_unlock(&device->mutex); 4259: return ret; 4260: } 4261: 4262: set_bit(CMDOBJ_RECURRING_START, &cmdobj->priv); 4263: 4264: ret = gpudev->send_recurring_cmdobj(adreno_dev, cmdobj); 4265: kgsl_mutex_unlock(&device->mutex); 4266: 4267: if (!ret) 4268: srcu_notifier_call_chain(&device->nh, GPU_GMU_READY, NULL); 4269: 4270: return ret; 4271: } 4272: 4273: static int adreno_dequeue_recurring_cmd(struct kgsl_device *device, 4274: struct kgsl_context *context) 4275: { 4276: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 4277: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 4278: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 4279: struct kgsl_drawobj *recurring_drawobj; 4280: int ret; 4281: 4282: if (!ADRENO_FEATURE(adreno_dev, ADRENO_LSR)) 4283: return -EOPNOTSUPP; 4284: 4285: if (!gpudev->send_recurring_cmdobj) 4286: return -ENODEV; 4287: 4288: kgsl_mutex_lock(&device->mutex); 4289: 4290: /* We can safely return here as recurring wokload is already untracked */ 4291: if (hwsched->recurring_cmdobj == NULL) { 4292: kgsl_mutex_unlock(&device->mutex); MATCH LINES: 4318 4306: kgsl_mutex_unlock(&device->mutex); 4307: return ret; 4308: } 4309: 4310: clear_bit(CMDOBJ_RECURRING_START, &hwsched->recurring_cmdobj->priv); 4311: set_bit(CMDOBJ_RECURRING_STOP, &hwsched->recurring_cmdobj->priv); 4312: 4313: ret = gpudev->send_recurring_cmdobj(adreno_dev, hwsched->recurring_cmdobj); 4314: 4315: kgsl_mutex_unlock(&device->mutex); 4316: 4317: if (!ret) 4318: srcu_notifier_call_chain(&device->nh, GPU_GMU_STOP, NULL); 4319: 4320: return ret; 4321: } 4322: 4323: static void adreno_set_isdb_breakpoint_registers(struct kgsl_device *device) 4324: { 4325: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 4326: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 4327: 4328: if (gpudev->set_isdb_breakpoint_registers) 4329: gpudev->set_isdb_breakpoint_registers(adreno_dev); 4330: } 4331: 4332: static void adreno_drawctxt_sched(struct kgsl_device *device, 4333: struct kgsl_context *context) 4334: { 4335: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 4336: 4337: if (WARN_ON(!adreno_dev->dispatch_ops || !adreno_dev->dispatch_ops->queue_context)) 4338: return; 4339: 4340: adreno_dev->dispatch_ops->queue_context(adreno_dev, 4341: ADRENO_CONTEXT(context)); 4342: } MATCH LINES: 4376 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; 4393: 4394: *((bool *) data->ptr) = *((bool *) data->val); 4395: } 4396: 4397: int adreno_power_cycle_bool(struct adreno_device *adreno_dev, 4398: bool *flag, bool val) 4399: { 4400: struct cycle_data data = { .ptr = flag, .val = &val }; MATCH LINES: 4511, 4518 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: 4528: /* 4529: * If requested AB is higher than theoretical max bandwidth, set AB vote as max 4530: * allowable quantized AB value. 4531: * 4532: * Power FW supports a 16 bit AB BW level. We can quantize the entire vote-able BW 4533: * range to a 16 bit space and the quantized value can be used to vote for AB though 4534: * GMU. Quantization can be performed as below. 4535: * 4536: * quantized_vote = (ab vote (kbps) * 2^16) / max ddr bandwidth (kbps) 4537: */ 4538: if (ab >= max_ab) 4539: vote = MAX_AB_VALUE; 4540: else 4541: vote = (u16)(((u64)ab * 1000 * (1 << 16)) / max_bw); 4542: MATCH LINES: 4752 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: } MATCH LINES: 4825, 4840, 4848 4813: if (of_device_is_compatible(pdev->dev.of_node, "qcom,adreno")) { 4814: if (kgsl_is_compatible_node_available("qcom,kgsl") || 4815: kgsl_is_compatible_node_available("qcom,kgsl-3d0")) 4816: return -ENODEV; 4817: matches = adreno_component_match; 4818: } 4819: 4820: /* 4821: * With standard DT bindings, there is no component to match 4822: * from adreno_component_match list for no GMU targets. Invoke 4823: * adreno_bind directly in this case. 4824: */ 4825: if (is_gmu_wrapper_available()) 4826: return adreno_bind(&pdev->dev); 4827: 4828: adreno_add_components(&pdev->dev, &match, matches); 4829: 4830: if (!match) 4831: return -ENODEV; 4832: 4833: return component_master_add_with_match(&pdev->dev, 4834: &adreno_ops, match); 4835: } 4836: 4837: #if (KERNEL_VERSION(6, 10, 0) <= LINUX_VERSION_CODE) 4838: static void adreno_remove(struct platform_device *pdev) 4839: { 4840: if (is_gmu_wrapper_available()) 4841: adreno_unbind(&pdev->dev); 4842: else 4843: component_master_del(&pdev->dev, &adreno_ops); 4844: } 4845: #else 4846: static int adreno_remove(struct platform_device *pdev) 4847: { 4848: if (is_gmu_wrapper_available()) 4849: adreno_unbind(&pdev->dev); 4850: else 4851: component_master_del(&pdev->dev, &adreno_ops); 4852: 4853: return 0; 4854: } 4855: #endif 4856: 4857: #if IS_ENABLED(CONFIG_QCOM_KGSL_HIBERNATION) 4858: #if IS_ENABLED(CONFIG_QCOM_SECURE_BUFFER) 4859: /* 4860: * Issue hyp_assign call to assign non-used internal/userspace secure 4861: * buffers to kernel. 4862: */ 4863: static int adreno_secure_pt_hibernate(struct adreno_device *adreno_dev) 4864: { 4865: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 4866: struct kgsl_process_private *process; 4867: struct kgsl_mem_entry *entry; 4868: struct kgsl_global_memdesc *md; 4869: struct kgsl_memdesc *memdesc; 4870: int ret, id; 4871: 4872: read_lock(&kgsl_driver.proclist_lock); MATCH LINES: 5052 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, 5067: .thaw = adreno_hibernation_resume, 5068: .poweroff = adreno_hibernation_suspend, 5069: .restore = adreno_hibernation_resume, 5070: }; 5071: #else 5072: static const struct dev_pm_ops adreno_pm_ops = { 5073: SET_SYSTEM_SLEEP_PM_OPS(adreno_pm_suspend, adreno_pm_resume) 5074: }; 5075: #endif /* IS_ENABLED(CONFIG_QCOM_KGSL_HIBERNATION) */ 5076: MATCH LINES: 5101, 5104, 5115 5089: int ret; 5090: 5091: ret = kgsl_core_init(); 5092: if (ret) 5093: return ret; 5094: 5095: ret = kgsl_mmu_init(); 5096: if (ret) { 5097: kgsl_core_exit(); 5098: return ret; 5099: } 5100: 5101: gmu_core_register(); 5102: ret = platform_driver_register(&adreno_platform_driver); 5103: if (ret) { 5104: gmu_core_unregister(); 5105: kgsl_mmu_exit(); 5106: kgsl_core_exit(); 5107: } 5108: 5109: return ret; 5110: } 5111: 5112: static void __exit kgsl_3d_exit(void) 5113: { 5114: platform_driver_unregister(&adreno_platform_driver); 5115: gmu_core_unregister(); 5116: kgsl_mmu_exit(); 5117: kgsl_core_exit(); 5118: } 5119: 5120: module_param_named(preempt_enable, adreno_preemption_enable, bool, 0600); 5121: MODULE_PARM_DESC(preempt_enable, "Enable GPU HW Preemption"); 5122: 5123: module_param_named(gpu_sku_override, kgsl_gpu_sku_override, uint, 0600); 5124: MODULE_PARM_DESC(gpu_sku_override, "Override SKU code identifier for GPU driver"); 5125: 5126: module_param_named(gpu_speed_bin_override, kgsl_gpu_speed_bin_override, uint, 0600); 5127: MODULE_PARM_DESC(gpu_speed_bin_override, "Override GPU speed bin"); 5128: 5129: module_param_named(slice_mask_override, adreno_slice_mask_override, uint, 0600); 5130: MODULE_PARM_DESC(slice_mask_override, "Override GPU slice mask"); 5131: 5132: module_init(kgsl_3d_init); 5133: module_exit(kgsl_3d_exit); 5134: 5135: MODULE_DESCRIPTION("3D Graphics driver"); 5136: MODULE_LICENSE("GPL v2"); 5137: MODULE_SOFTDEP("pre: arm_smmu nvmem_qfprom socinfo governor_msm_adreno_tz governor_gpubw_mon governor_msm_adreno_ro"); 5138: #if (KERNEL_VERSION(6, 13, 0) <= LINUX_VERSION_CODE) 5139: MODULE_IMPORT_NS("DMA_BUF"); --- FILE: \adreno.h | HITS: 29 --- MATCH LINES: 64, 74 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: 82: /* 83: * Disable local interrupts and CPU preemption to avoid interruptions 84: * while holding the CP semaphore; otherwise, it could stall the CP. 85: * Make sure to call ADRENO_RELEASE_CP_SEMAPHORE after calling the 86: * below macro to reenable CPU interrupts. 87: */ 88: #define ADRENO_ACQUIRE_CP_SEMAPHORE(_adreno_dev, _flags) \ 89: ({ \ 90: bool ret = true; \ 91: if ((_adreno_dev)->gpucore->gpudev->acquire_cp_semaphore) { \ 92: local_irq_save(_flags); \ 93: preempt_disable(); \ 94: ret = (_adreno_dev)->gpucore->gpudev->acquire_cp_semaphore(_adreno_dev); \ 95: if (!ret) { \ 96: preempt_enable(); \ 97: local_irq_restore(_flags); \ 98: dev_err_ratelimited(KGSL_DEVICE(_adreno_dev)->dev, \ MATCH LINES: 178, 182, 184, 190, 196, 198, 219 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 */ 174: #define ADRENO_DMS BIT(17) 175: /* AQE supported on this target */ 176: #define ADRENO_AQE BIT(18) 177: /* Warm Boot supported on this target */ 178: #define ADRENO_GMU_WARMBOOT BIT(19) 179: /* The GPU supports CLX */ 180: #define ADRENO_CLX BIT(20) 181: /* Enable GMU support for GMU based thermal mitigation */ 182: #define ADRENO_GMU_THERMAL_MITIGATION BIT(21) 183: /* GMU Based DCVS */ 184: #define ADRENO_GMU_BASED_DCVS BIT(22) 185: /* RT hint feature for RB0 workloads */ 186: #define ADRENO_RT_HINT BIT(23) 187: /* Defer allocation of preemption record gmem memory when needed */ 188: #define ADRENO_DEFER_GMEM_ALLOC BIT(24) 189: /* The GMU supports MINBW voting */ 190: #define ADRENO_GMU_MINBW BIT(25) 191: /* Enable GMU Based DCVS profile */ 192: #define ADRENO_DCVS_PROFILE BIT(26) 193: /* Enable TSENSE power savings during sleep */ 194: #define ADRENO_TSENSE_DYNAMIC_PERIOD BIT(27) 195: /* Enable GMU Based AB voting */ 196: #define ADRENO_GMU_AB BIT(28) 197: /* Enable GMU Fast Context Destroy optimization */ 198: #define ADRENO_GMU_FAST_CONTEXT_DESTROY BIT(29) 199: /* 200: * The target uses the GPU_CX_MISC_SW_FUSE_FREQ_LIMIT_STATUS register to 201: * get combined (HW + SW) speedbin when no nvmem speed_bin cell exists. 202: */ 203: #define ADRENO_SOFTFUSE BIT_ULL(32) 204: /* 205: * Adreno GPU quirks - control bits for various workarounds 206: */ 207: 208: /* Set TWOPASSUSEWFI in PC_DBG_ECO_CNTL (5XX/6XX) */ 209: #define ADRENO_QUIRK_TWO_PASS_USE_WFI BIT(0) 210: /* Submit critical packets at GPU wake up */ 211: #define ADRENO_QUIRK_CRITICAL_PACKETS BIT(1) 212: /* Mask out RB1-3 activity signals from HW hang detection logic */ 213: #define ADRENO_QUIRK_FAULT_DETECT_MASK BIT(2) 214: /* Disable RB sampler datapath clock gating optimization */ 215: #define ADRENO_QUIRK_DISABLE_RB_DP2CLOCKGATING BIT(3) 216: /* Disable local memory(LM) feature to avoid corner case error */ 217: #define ADRENO_QUIRK_DISABLE_LMLOADKILL BIT(4) 218: /* Allow HFI to use registers to send message to GMU */ 219: #define ADRENO_QUIRK_HFI_USE_REG BIT(5) 220: /* Only set protected SECVID registers once */ 221: #define ADRENO_QUIRK_SECVID_SET_ONCE BIT(6) 222: /* 223: * Limit number of read and write transactions from 224: * UCHE block to GBIF to avoid possible deadlock 225: * between GBIF, SMMU and MEMNOC. 226: */ 227: #define ADRENO_QUIRK_LIMIT_UCHE_GBIF_RW BIT(8) 228: /* Do explicit mode control of cx gdsc */ 229: #define ADRENO_QUIRK_CX_GDSC BIT(9) 230: 231: /* Command identifiers */ 232: #define CONTEXT_TO_MEM_IDENTIFIER 0x2EADBEEF 233: #define CMD_IDENTIFIER 0x2EEDFACE 234: #define CMD_INTERNAL_IDENTIFIER 0x2EEDD00D 235: #define START_IB_IDENTIFIER 0x2EADEABE 236: #define END_IB_IDENTIFIER 0x2ABEDEAD 237: #define START_PROFILE_IDENTIFIER 0x2DEFADE1 238: #define END_PROFILE_IDENTIFIER 0x2DEFADE2 239: #define PWRON_FIXUP_IDENTIFIER 0x2AFAFAFA 240: 241: /* One cannot wait forever for the core to idle, so set an upper limit to the 242: * amount of time to wait for the core to go idle 243: */ MATCH LINES: 342, 344 330: ADRENO_REV_GEN8_9_0 = ADRENO_GPUREV_VALUE(8, 9, 0), 331: ADRENO_REV_GEN8_10_0 = ADRENO_GPUREV_VALUE(8, 10, 0), 332: ADRENO_REV_GEN8_11_0 = ADRENO_GPUREV_VALUE(8, 11, 0), 333: ADRENO_REV_GEN8_11_1 = ADRENO_GPUREV_VALUE(8, 11, 1), 334: ADRENO_REV_GEN8_14_0 = ADRENO_GPUREV_VALUE(8, 14, 0), 335: }; 336: 337: #define ADRENO_SOFT_FAULT BIT(0) 338: #define ADRENO_HARD_FAULT BIT(1) 339: #define ADRENO_TIMEOUT_FAULT BIT(2) 340: #define ADRENO_IOMMU_STALL_ON_PAGE_FAULT BIT(3) 341: #define ADRENO_PREEMPT_FAULT BIT(4) 342: #define ADRENO_GMU_FAULT BIT(5) 343: #define ADRENO_CTX_DETATCH_TIMEOUT_FAULT BIT(6) 344: #define ADRENO_GMU_FAULT_SKIP_SNAPSHOT BIT(7) 345: #define ADRENO_FAULT_TYPES 8 346: 347: /** 348: * Bit fields for GPU_CX_MISC_CX_AHB_*_CNTL registers 349: * AHB_TXFRTIMEOUTRELEASE [8:8] 350: * AHB_TXFRTIMEOUTENABLE [9:9] 351: * AHB_RESPONDERROR [11:11] 352: * AHB_ERRORSTATUSENABLE [12:12] 353: */ 354: #define ADRENO_AHB_CNTL_DEFAULT (BIT(12) | BIT(11) | BIT(9) | BIT(8)) 355: 356: enum adreno_pipe_type { 357: PIPE_NONE = 0, 358: PIPE_BR = 1, 359: PIPE_BV = 2, 360: PIPE_LPAC = 3, 361: PIPE_AQE0 = 4, 362: PIPE_AQE1 = 5, 363: PIPE_DDE_BR = 6, 364: PIPE_DDE_BV = 7, 365: }; 366: 367: /* number of throttle counters for DCVS adjustment */ 368: #define ADRENO_GPMU_THROTTLE_COUNTERS 4 MATCH LINES: 543, 544 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 */ 539: int (*gpu_clock_set)(struct adreno_device *adreno_dev, u32 pwrlevel); 540: /** @gpu_bus_set: Target specific function to set gpu bandwidth */ 541: int (*gpu_bus_set)(struct adreno_device *adreno_dev, int bus_level, 542: u32 ab); 543: /** @gmu_based_dcvs_pwr_ops: Function ops for GMU based DCVS power operations */ 544: void (*gmu_based_dcvs_pwr_ops)(struct adreno_device *adreno_dev, u32 arg, 545: enum gpu_pwrlevel_op op); 546: /** @set_thermal_index: Function ops for sending thermal constraint to GMU */ 547: void (*set_thermal_index)(struct adreno_device *adreno_dev); 548: }; 549: 550: struct adreno_ubwc_props { 551: /** @mode: UBWC mode value */ 552: u32 mode; 553: /** @mode2: Secondary UBWC mode (Gen8 only) */ 554: u32 mode2; 555: /** @level2_swizzling_dis: Level 2 swizzling disable (Gen6 only) */ 556: u32 level2_swizzling_dis; 557: /** @amsbc: AMSBC enable flag */ 558: bool amsbc; 559: /** @rgb565_predicator: RGB565 predictor enable */ 560: bool rgb565_predicator; 561: /** @yuvnotcomptofc: YUV not compressed to FC (Gen8 only) */ 562: bool yuvnotcomptofc; 563: /** @fp16compoptdis: FP16 compression optimization disable (Gen8 only) */ 564: bool fp16compoptdis; 565: /** @rgba8888_lossless: RGBA8888 lossless mode (Gen8 only) */ 566: bool rgba8888_lossless; 567: }; 568: MATCH LINES: 848, 849, 880, 881 836: struct kgsl_memdesc *critpkts_secure; 837: /** @irq_mask: The current interrupt mask for the GPU device */ 838: u32 irq_mask; 839: /* @dispatch_ops: A pointer to a set of adreno dispatch ops */ 840: const struct adreno_dispatch_ops *dispatch_ops; 841: /** @hwsched: Container for the hardware dispatcher */ 842: struct adreno_hwsched hwsched; 843: /* 844: * @perfcounter: Flag to clear perfcounters across contexts and 845: * controls perfcounter ioctl read 846: */ 847: bool perfcounter; 848: /** @gmu_hub_clk_freq: Gmu hub interface clock frequency */ 849: u64 gmu_hub_clk_freq; 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 */ MATCH LINES: 983, 984 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 1000: * @started: Number of GPU ticks at start of the drawobj 1001: * @retired: Number of GPU ticks at the end of the drawobj 1002: * @ctx_start: CP_ALWAYS_ON_CONTEXT tick at start of the drawobj 1003: * @ctx_end: CP_ALWAYS_ON_CONTEXT tick at end of the drawobj 1004: */ 1005: struct adreno_drawobj_profile_entry { 1006: uint64_t started; 1007: uint64_t retired; 1008: uint64_t ctx_start; MATCH LINES: 1056, 1057 1044: ADRENO_REG_CP_ME_CNTL, 1045: ADRENO_REG_CP_RB_CNTL, 1046: ADRENO_REG_CP_IB1_BASE, 1047: ADRENO_REG_CP_IB1_BASE_HI, 1048: ADRENO_REG_CP_IB1_BUFSZ, 1049: ADRENO_REG_CP_IB2_BASE, 1050: ADRENO_REG_CP_IB2_BASE_HI, 1051: ADRENO_REG_CP_IB2_BUFSZ, 1052: ADRENO_REG_RBBM_STATUS, 1053: ADRENO_REG_RBBM_STATUS3, 1054: ADRENO_REG_RBBM_INT_0_MASK, 1055: ADRENO_REG_RBBM_SW_RESET_CMD, 1056: ADRENO_REG_GMU_AO_HOST_INTERRUPT_MASK, 1057: ADRENO_REG_GMU_GMU2HOST_INTR_MASK, 1058: ADRENO_REG_REGISTER_MAX, 1059: }; 1060: 1061: #define ADRENO_REG_UNUSED 0xFFFFFFFF 1062: #define ADRENO_REG_SKIP 0xFFFFFFFE 1063: #define ADRENO_REG_DEFINE(_offset, _reg)[_offset] = _reg 1064: 1065: struct adreno_irq_funcs { 1066: void (*func)(struct adreno_device *adreno_dev, int mask); 1067: }; 1068: #define ADRENO_IRQ_CALLBACK(_c) { .func = _c } 1069: 1070: /* 1071: * struct adreno_debugbus_block - Holds info about debug buses of a chip 1072: * @block_id: Bus identifier 1073: * @dwords: Number of dwords of data that this block holds 1074: */ 1075: struct adreno_debugbus_block { 1076: unsigned int block_id; 1077: unsigned int dwords; 1078: }; 1079: 1080: struct adreno_gpudev { 1081: /* MATCH LINES: 1238 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); MATCH LINES: 1679 1667: * adreno_write_gmureg() - Write a GMU register by getting its offset from the 1668: * offset array defined in gpudev node 1669: * @adreno_dev: Pointer to the adreno device 1670: * @offset_name: The register enum that is to be written 1671: * @val: Value to write 1672: */ 1673: static inline void adreno_write_gmureg(struct adreno_device *adreno_dev, 1674: enum adreno_regs offset_name, unsigned int val) 1675: { 1676: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 1677: 1678: if (adreno_checkreg_off(adreno_dev, offset_name)) 1679: gmu_core_regwrite(KGSL_DEVICE(adreno_dev), 1680: gpudev->reg_offsets[offset_name], val); 1681: } 1682: 1683: /** 1684: * adreno_gpu_fault() - Return the current state of the GPU 1685: * @adreno_dev: A pointer to the adreno_device to query 1686: * 1687: * Return 0 if there is no fault or positive with the last type of fault that 1688: * occurred 1689: */ 1690: static inline unsigned int adreno_gpu_fault(struct adreno_device *adreno_dev) 1691: { 1692: /* make sure we're reading the latest value */ 1693: smp_rmb(); 1694: return atomic_read(&adreno_dev->scheduler_fault); 1695: } 1696: 1697: /** 1698: * adreno_set_gpu_fault() - Set the current fault status of the GPU 1699: * @adreno_dev: A pointer to the adreno_device to set 1700: * @state: fault state to set 1701: * 1702: */ 1703: static inline void adreno_set_gpu_fault(struct adreno_device *adreno_dev, MATCH LINES: 1991, 1998, 2006, 2011 1979: 1980: if (*counter) { 1981: if (val >= *counter) 1982: ret = val - *counter; 1983: else 1984: ret = (UINT_MAX - *counter) + val; 1985: } 1986: 1987: *counter = val; 1988: return ret; 1989: } 1990: 1991: static inline int adreno_perfcntr_active_oob_get( 1992: struct adreno_device *adreno_dev) 1993: { 1994: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1995: int ret = adreno_active_count_get(adreno_dev); 1996: 1997: if (!ret) { 1998: ret = gmu_core_dev_oob_set(device, oob_perfcntr); 1999: if (ret) 2000: adreno_active_count_put(adreno_dev); 2001: } 2002: 2003: return ret; 2004: } 2005: 2006: static inline void adreno_perfcntr_active_oob_put( 2007: struct adreno_device *adreno_dev) 2008: { 2009: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2010: 2011: gmu_core_dev_oob_clear(device, oob_perfcntr); 2012: adreno_active_count_put(adreno_dev); 2013: } 2014: 2015: /** 2016: * adreno_wait_for_halt_ack - wait for acknowlegement for a bus halt request 2017: * @ack_reg: register offset to wait for acknowledge 2018: * @mask: A mask value to wait for 2019: * 2020: * Return: 0 on success or -ETIMEDOUT if the request timed out 2021: */ 2022: static inline int adreno_wait_for_halt_ack(struct kgsl_device *device, 2023: int ack_reg, unsigned int mask) 2024: { 2025: u32 val; 2026: int ret = kgsl_regmap_read_poll_timeout(&device->regmap, ack_reg, 2027: val, (val & mask) == mask, 100, 100 * 1000); 2028: 2029: if (ret) 2030: dev_err(device->dev, 2031: "GBIF/VBIF Halt ack timeout: reg=%08x mask=%08x status=%08x\n", 2032: ack_reg, mask, val); 2033: 2034: return ret; 2035: } MATCH LINES: 2216, 2222 2204: void adreno_set_active_ctxs_null(struct adreno_device *adreno_dev); 2205: 2206: /** 2207: * adreno_get_bus_counters - Allocate the bus dcvs counters 2208: * @adreno_dev: Adreno GPU device handle 2209: * 2210: * This function allocates the various gpu counters to measure 2211: * gpu bus usage for bus dcvs 2212: */ 2213: void adreno_get_bus_counters(struct adreno_device *adreno_dev); 2214: 2215: /** 2216: * adreno_gmu_bus_ab_quantize - Calculate the AB vote that needs to be sent to GMU 2217: * @adreno_dev: Handle to the adreno device 2218: * @ab: ab request that needs to be scaled in MBps 2219: * 2220: * Returns the AB value that needs to be prefixed to bandwidth vote in kbps 2221: */ 2222: u32 adreno_gmu_bus_ab_quantize(struct adreno_device *adreno_dev, u32 ab); 2223: 2224: /** 2225: * adreno_check_idle - Make sure device is idle 2226: * @device: Pointer to the kgsl device 2227: * 2228: * This function processes the profiling results and log an error if 2229: * device is not idle 2230: */ 2231: void adreno_check_idle(struct kgsl_device *device); 2232: 2233: /* 2234: * adreno_profile_submit_time - Populate profiling buffer with timestamps 2235: * @time: Container for the statistics 2236: * 2237: * Populate the draw object user profiling buffer with the timestamps 2238: * recored in the adreno_submit_time structure at the time of draw object 2239: * submission. 2240: */ 2241: void adreno_profile_submit_time(struct adreno_submit_time *time); 2242: 2243: void adreno_preemption_timer(struct timer_list *t); 2244: 2245: /** 2246: * adreno_create_profile_buffer - Create a buffer to store profiling data --- FILE: \adreno_a5xx.c | HITS: 6 --- MATCH LINES: 63 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) | \ 62: (1 << A5XX_INT_MISC_HANG_DETECT) | \ 63: (1 << A5XX_INT_UCHE_OOB_ACCESS) | \ 64: (1 << A5XX_INT_UCHE_TRAP_INTR) | \ 65: (1 << A5XX_INT_CP_SW) | \ 66: (1 << A5XX_INT_GPMU_FIRMWARE) | \ 67: (1 << A5XX_INT_GPMU_VOLTAGE_DROOP)) 68: 69: static int a5xx_probe(struct platform_device *pdev, 70: u32 chipid, const struct adreno_gpu_core *gpucore) 71: { 72: struct adreno_device *adreno_dev; 73: struct kgsl_device *device; 74: int ret; 75: 76: adreno_dev = (struct adreno_device *) 77: of_device_get_match_data(&pdev->dev); 78: 79: memset(adreno_dev, 0, sizeof(*adreno_dev)); 80: 81: adreno_dev->gpucore = gpucore; 82: adreno_dev->chipid = chipid; 83: 84: adreno_reg_offset_init(gpucore->gpudev->reg_offsets); 85: 86: adreno_dev->sptp_pc_enabled = 87: ADRENO_FEATURE(adreno_dev, ADRENO_SPTP_PC); MATCH LINES: 558, 565, 587 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) 551: { 552: uint32_t *data; 553: const struct firmware *fw = NULL; 554: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 555: const struct adreno_a5xx_core *a5xx_core = to_a5xx_core(adreno_dev); 556: uint32_t *cmds, cmd_size; 557: int ret = -EINVAL; 558: u32 gmu_major = 1; 559: 560: if (!a5xx_has_gpmu(adreno_dev)) 561: return 0; 562: 563: /* a530 used GMU major 1 and A540 used GMU major 3 */ 564: if (adreno_is_a540(adreno_dev)) 565: gmu_major = 3; 566: 567: /* gpmu fw already saved and verified so do nothing new */ 568: if (adreno_dev->gpmu_cmds_size != 0) 569: return 0; 570: 571: if (a5xx_core->gpmufw_name == NULL) 572: return 0; 573: 574: ret = adreno_request_firmware(&fw, a5xx_core->gpmufw_name, 575: &device->pdev->dev, true); 576: if (ret || fw == NULL) 577: return ret; 578: 579: data = (uint32_t *)fw->data; 580: 581: if (data[0] >= (fw->size / sizeof(uint32_t)) || data[0] < 2) 582: goto err; 583: 584: if (data[1] != GPMU_FIRMWARE_ID) 585: goto err; 586: ret = _read_fw2_block_header(device, &data[2], 587: data[0] - 2, GPMU_FIRMWARE_ID, gmu_major, 0); 588: if (ret) 589: goto err; 590: 591: /* Integer overflow check for cmd_size */ 592: if (data[2] > (data[0] - 2)) 593: goto err; 594: 595: cmds = data + data[2] + 3; 596: cmd_size = data[0] - data[2] - 2; 597: 598: if (cmd_size > GPMU_INST_RAM_SIZE) { 599: dev_err(device->dev, 600: "GPMU firmware block size is larger than RAM size\n"); 601: goto err; 602: } 603: 604: /* Everything is cool, so create some commands */ 605: ret = _gpmu_create_load_cmds(adreno_dev, cmds, cmd_size); 606: err: 607: if (fw) 608: release_firmware(fw); 609: 610: return ret; 611: } MATCH LINES: 2050 2038: case A5XX_INT_RBBM_ETS_MS_TIMEOUT: 2039: dev_crit_ratelimited(device->dev, 2040: "RBBM: ME master split timeout\n"); 2041: break; 2042: case A5XX_INT_RBBM_ATB_ASYNC_OVERFLOW: 2043: dev_crit_ratelimited(device->dev, 2044: "RBBM: ATB ASYNC overflow\n"); 2045: break; 2046: case A5XX_INT_RBBM_ATB_BUS_OVERFLOW: 2047: dev_crit_ratelimited(device->dev, 2048: "RBBM: ATB bus overflow\n"); 2049: break; 2050: case A5XX_INT_UCHE_OOB_ACCESS: 2051: dev_crit_ratelimited(device->dev, 2052: "UCHE: Out of bounds access\n"); 2053: break; 2054: case A5XX_INT_UCHE_TRAP_INTR: 2055: dev_crit_ratelimited(device->dev, "UCHE: Trap interrupt\n"); 2056: break; 2057: case A5XX_INT_GPMU_VOLTAGE_DROOP: 2058: dev_crit_ratelimited(device->dev, "GPMU: Voltage droop\n"); 2059: break; 2060: default: 2061: dev_crit_ratelimited(device->dev, "Unknown interrupt %d\n", 2062: bit); 2063: } 2064: } 2065: 2066: static void a5xx_irq_storm_worker(struct work_struct *work) 2067: { 2068: struct adreno_device *adreno_dev = container_of(work, 2069: struct adreno_device, irq_storm_work); 2070: struct kgsl_device *device = &adreno_dev->dev; 2071: unsigned int status; 2072: 2073: kgsl_mutex_lock(&device->mutex); 2074: MATCH LINES: 2269 2257: ADRENO_IRQ_CALLBACK(NULL), /* 15 - CP_RB_INT */ 2258: /* 16 - CCP_UNUSED_1 */ 2259: ADRENO_IRQ_CALLBACK(NULL), 2260: ADRENO_IRQ_CALLBACK(NULL), /* 17 - CP_RB_DONE_TS */ 2261: ADRENO_IRQ_CALLBACK(NULL), /* 18 - CP_WT_DONE_TS */ 2262: ADRENO_IRQ_CALLBACK(NULL), /* 19 - UNKNOWN_1 */ 2263: ADRENO_IRQ_CALLBACK(a5xx_cp_callback), /* 20 - CP_CACHE_FLUSH_TS */ 2264: /* 21 - UNUSED_2 */ 2265: ADRENO_IRQ_CALLBACK(NULL), 2266: ADRENO_IRQ_CALLBACK(a5xx_err_callback), /* 22 - RBBM_ATB_BUS_OVERFLOW */ 2267: /* 23 - MISC_HANG_DETECT */ 2268: ADRENO_IRQ_CALLBACK(adreno_hang_int_callback), 2269: ADRENO_IRQ_CALLBACK(a5xx_err_callback), /* 24 - UCHE_OOB_ACCESS */ 2270: ADRENO_IRQ_CALLBACK(a5xx_err_callback), /* 25 - UCHE_TRAP_INTR */ 2271: ADRENO_IRQ_CALLBACK(NULL), /* 26 - DEBBUS_INTR_0 */ 2272: ADRENO_IRQ_CALLBACK(NULL), /* 27 - DEBBUS_INTR_1 */ 2273: ADRENO_IRQ_CALLBACK(a5xx_err_callback), /* 28 - GPMU_VOLTAGE_DROOP */ 2274: ADRENO_IRQ_CALLBACK(a5xx_gpmu_int_callback), /* 29 - GPMU_FIRMWARE */ 2275: ADRENO_IRQ_CALLBACK(NULL), /* 30 - ISDB_CPU_IRQ */ 2276: ADRENO_IRQ_CALLBACK(NULL), /* 31 - ISDB_UNDER_DEBUG */ 2277: }; 2278: 2279: static irqreturn_t a5xx_irq_handler(struct adreno_device *adreno_dev) 2280: { 2281: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2282: irqreturn_t ret; 2283: u32 status; 2284: 2285: kgsl_regread(device, A5XX_RBBM_INT_0_STATUS, &status); 2286: 2287: /* 2288: * Clear all the interrupt bits except A5XX_INT_RBBM_AHB_ERROR. 2289: * The interrupt will stay asserted until it is cleared by the handler 2290: * so don't touch it yet to avoid a storm 2291: */ 2292: kgsl_regwrite(device, A5XX_RBBM_INT_CLEAR_CMD, 2293: status & ~A5XX_INT_RBBM_AHB_ERROR); --- FILE: \adreno_a6xx.c | HITS: 113 --- MATCH LINES: 24 12: #include 13: #include 14: #include 15: #if (KERNEL_VERSION(6, 17, 0) <= LINUX_VERSION_CODE) 16: #include 17: #endif 18: 19: #include "adreno.h" 20: #include "adreno_a6xx.h" 21: #include "adreno_a6xx_hwsched.h" 22: #include "adreno_pm4types.h" 23: #include "adreno_trace.h" 24: #include "kgsl_gmu_core.h" 25: #include "kgsl_trace.h" 26: #include "kgsl_util.h" 27: 28: /* IFPC & Preemption static powerup restore list */ 29: static u32 a6xx_pwrup_reglist[] = { 30: A6XX_VSC_ADDR_MODE_CNTL, 31: A6XX_GRAS_ADDR_MODE_CNTL, 32: A6XX_RB_ADDR_MODE_CNTL, 33: A6XX_PC_ADDR_MODE_CNTL, 34: A6XX_HLSQ_ADDR_MODE_CNTL, 35: A6XX_VFD_ADDR_MODE_CNTL, 36: A6XX_VPC_ADDR_MODE_CNTL, 37: A6XX_UCHE_ADDR_MODE_CNTL, 38: A6XX_SP_ADDR_MODE_CNTL, 39: A6XX_TPL1_ADDR_MODE_CNTL, 40: A6XX_UCHE_WRITE_RANGE_MAX_LO, 41: A6XX_UCHE_WRITE_RANGE_MAX_HI, 42: A6XX_UCHE_TRAP_BASE_LO, 43: A6XX_UCHE_TRAP_BASE_HI, 44: A6XX_UCHE_WRITE_THRU_BASE_LO, 45: A6XX_UCHE_WRITE_THRU_BASE_HI, 46: A6XX_UCHE_GMEM_RANGE_MIN_LO, 47: A6XX_UCHE_GMEM_RANGE_MIN_HI, 48: A6XX_UCHE_GMEM_RANGE_MAX_LO, MATCH LINES: 146, 150, 157, 167, 173, 176, 180, 186 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)) MATCH LINES: 270, 285 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 */ MATCH LINES: 339, 356, 367, 377, 392, 394, 408, 409, 410, 411, 412, 413, 414, 415, 416, 445, 448, 450, 451, 462, 464, 466, 467 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)) 331: return 0xAAA8AA82; 332: else if (adreno_is_a702_family(adreno_dev)) 333: return 0xAAAAAA82; 334: else 335: return 0x8AA8AA82; 336: } 337: 338: static inline unsigned int 339: __get_gmu_ao_cgc_mode_cntl(struct adreno_device *adreno_dev) 340: { 341: if (adreno_is_a612(adreno_dev)) 342: return 0x00000022; 343: else if (adreno_is_a615_family(adreno_dev)) 344: return 0x00000222; 345: /* a662 should be checked before a660 */ 346: else if (adreno_is_a662(adreno_dev) || adreno_is_a621(adreno_dev) || 347: adreno_is_a622(adreno_dev) || adreno_is_a623(adreno_dev)) 348: return 0x00020200; 349: else if (adreno_is_a660(adreno_dev)) 350: return 0x00020000; 351: else 352: return 0x00020202; 353: } 354: 355: static inline unsigned int 356: __get_gmu_ao_cgc_delay_cntl(struct adreno_device *adreno_dev) 357: { 358: if (adreno_is_a612(adreno_dev)) 359: return 0x00000011; 360: else if (adreno_is_a615_family(adreno_dev)) 361: return 0x00000111; 362: else 363: return 0x00010111; 364: } 365: 366: static inline unsigned int 367: __get_gmu_ao_cgc_hyst_cntl(struct adreno_device *adreno_dev) 368: { 369: if (adreno_is_a612(adreno_dev)) 370: return 0x00000055; 371: else if (adreno_is_a615_family(adreno_dev)) 372: return 0x00000555; 373: else 374: return 0x00005555; 375: } 376: 377: static unsigned int __get_gmu_wfi_config(struct adreno_device *adreno_dev) 378: { 379: unsigned int rev = ADRENO_GPUREV(adreno_dev); 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; MATCH LINES: 744, 745, 749 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) | MATCH LINES: 831, 832, 833 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); MATCH LINES: 903 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; MATCH LINES: 1245, 1254, 1286, 1289, 1322, 1330, 1354, 1357, 1360 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: 1572 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; MATCH LINES: 1722, 1749 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: } MATCH LINES: 1858, 1881, 1886, 1893, 1898 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 MATCH LINES: 1956, 1989, 2027, 2050, 2052, 2057, 2060, 2065, 2074, 2110, 2111, 2112, 2113 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; 2062: } 2063: 2064: if (WARN_ON(regmap->count >= ARRAY_SIZE(regmap->region))) { 2065: platform_device_put(gmu_wrapper_pdev); 2066: return -ENODEV; 2067: } 2068: 2069: region = ®map->region[regmap->count]; 2070: 2071: ret = kgsl_regmap_init_region(regmap, device->pdev, region, res, NULL, NULL); 2072: if (!ret) 2073: regmap->count++; 2074: platform_device_put(gmu_wrapper_pdev); 2075: } 2076: 2077: if (ret) 2078: return ret; 2079: 2080: ret = adreno_dispatcher_init(adreno_dev); 2081: if (ret) 2082: return ret; 2083: 2084: timer_setup(&device->idle_timer, kgsl_timer, 0); 2085: 2086: INIT_WORK(&device->idle_check_ws, kgsl_idle_check); 2087: 2088: return 0; 2089: } 2090: 2091: /* Register offset defines for A6XX, in order of enum adreno_regs */ 2092: static unsigned int a6xx_register_offsets[ADRENO_REG_REGISTER_MAX] = { 2093: 2094: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_BASE, A6XX_CP_RB_BASE), 2095: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_BASE_HI, A6XX_CP_RB_BASE_HI), 2096: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_RPTR, A6XX_CP_RB_RPTR), 2097: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_WPTR, A6XX_CP_RB_WPTR), 2098: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_CNTL, A6XX_CP_RB_CNTL), 2099: ADRENO_REG_DEFINE(ADRENO_REG_CP_ME_CNTL, A6XX_CP_SQE_CNTL), 2100: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BASE, A6XX_CP_IB1_BASE), 2101: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BASE_HI, A6XX_CP_IB1_BASE_HI), 2102: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BUFSZ, A6XX_CP_IB1_REM_SIZE), 2103: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BASE, A6XX_CP_IB2_BASE), 2104: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BASE_HI, A6XX_CP_IB2_BASE_HI), 2105: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BUFSZ, A6XX_CP_IB2_REM_SIZE), 2106: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_STATUS, A6XX_RBBM_STATUS), 2107: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_STATUS3, A6XX_RBBM_STATUS3), 2108: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_INT_0_MASK, A6XX_RBBM_INT_0_MASK), 2109: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_SW_RESET_CMD, A6XX_RBBM_SW_RESET_CMD), 2110: ADRENO_REG_DEFINE(ADRENO_REG_GMU_AO_HOST_INTERRUPT_MASK, 2111: A6XX_GMU_AO_HOST_INTERRUPT_MASK), 2112: ADRENO_REG_DEFINE(ADRENO_REG_GMU_GMU2HOST_INTR_MASK, 2113: A6XX_GMU_GMU2HOST_INTR_MASK), 2114: }; 2115: 2116: int a6xx_perfcounter_update(struct adreno_device *adreno_dev, 2117: struct adreno_perfcount_register *reg, bool update_reg) 2118: { 2119: void *ptr = adreno_dev->pwrup_reglist->hostptr; 2120: struct cpu_gpu_lock *lock = ptr; 2121: u32 *data = ptr + sizeof(*lock); 2122: u64 reglist_size_dwords = adreno_dev->pwrup_reglist->size / sizeof(u32); 2123: u64 lock_size_dwords = sizeof(*lock) / sizeof(u32); 2124: int i, offset = 0; 2125: bool select_reg_present = false; 2126: u32 pending_pairs = 2; /* No of pairs to add: and */ 2127: 2128: for (i = 0; i < lock->list_length >> 1; i++) { 2129: if (data[offset] == reg->select) { 2130: select_reg_present = true; 2131: break; 2132: } 2133: 2134: if (data[offset] == A6XX_RBBM_PERFCTR_CNTL) 2135: break; 2136: 2137: offset += 2; MATCH LINES: 2186, 2191, 2192, 2195, 2198 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: MATCH LINES: 2256, 2269 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 */ MATCH LINES: 2340, 2346, 2364, 2375, 2387, 2389, 2424, 2428, 2429, 2433, 2436, 2437, 2445, 2448, 2452, 2453, 2456, 2457, 2460, 2462, 2463, 2471, 2474, 2478, 2479, 2486, 2488, 2513, 2514, 2522, 2525, 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: 20 --- MATCH LINES: 16, 17, 18, 23, 24, 29, 37, 39, 50, 51, 52, 53, 87, 88 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 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 */ 72: u32 vbif_count; 73: /** @veto_fal10: veto status for fal10 feature */ 74: bool veto_fal10; 75: /** @pdc_in_aop: True if PDC programmed in AOP */ 76: bool pdc_in_aop; 77: /** @hang_detect_cycles: Hang detect counter timeout value */ 78: u32 hang_detect_cycles; 79: /** @protected_regs: Array of protected registers for the target */ 80: const struct adreno_protected_regs *protected_regs; 81: /** @disable_tseskip: True if TSESkip logic is disabled */ 82: bool disable_tseskip; 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. MATCH LINES: 181, 189 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: MATCH LINES: 243, 244, 245 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 MATCH LINES: 387 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 --- FILE: \adreno_a6xx_gmu.c | HITS: 732 --- MATCH LINES: 26, 37, 38, 42, 47, 51, 56, 63, 64, 68, 73, 77, 81, 111, 125, 133, 147, 173, 187, 195, 209, 217, 231, 263, 267, 275, 283, 298 14: #include 15: #include 16: #include 17: #include 18: #include 19: #include 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] = { 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: 88: static void _regwrite(void __iomem *regbase, u32 offsetwords, u32 value) 89: { 90: void __iomem *reg; 91: 92: reg = regbase + (offsetwords << 2); 93: __raw_writel(value, reg); 94: } 95: 96: static void _regrmw(void __iomem *regbase, u32 offsetwords, u32 mask, u32 or) 97: { 98: void __iomem *reg; 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); MATCH LINES: 348, 349, 350, 361, 367, 373, 402, 403, 405, 408, 410, 411, 419, 422, 426, 447, 448, 450, 451, 453, 454, 457, 460, 464 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 379: * single base pointer that encompassed the entire PDC range. Current 380: * targets specify the individual GPU-owned PDC register blocks 381: * (sequence and config). 382: * 383: * This code handles both possibilities and generates individual 384: * pointers to the GPU PDC blocks, either as offsets from the single 385: * base, or as directly specified ranges. 386: * 387: * PDC programming has moved to AOP for newer A6x platforms. 388: * However registers to enable GPU PDC and set the sequence start 389: * address still need to be programmed. 390: */ 391: 392: /* Offsets from the base PDC (if no PDC subsections in the DTSI) */ 393: if (adreno_is_a640v2(adreno_dev)) { 394: cfg_offset = 0x90000; 395: seq_offset = 0x290000; 396: } else { 397: cfg_offset = 0x80000; 398: seq_offset = 0x280000; 399: } 400: 401: /* Get pointers to each of the possible PDC resources */ 402: res_pdc = platform_get_resource_byname(gmu_pdev, 403: IORESOURCE_MEM, "kgsl_gmu_pdc_reg"); 404: /* 405: * Try to get the "gmu_pdc" resource, fallback to legacy "kgsl_gmu_pdc_cfg" 406: * if not found 407: */ 408: res_cfg = platform_get_resource_byname(gmu_pdev, IORESOURCE_MEM, "gmu_pdc"); 409: if (!res_cfg) 410: res_cfg = platform_get_resource_byname(gmu_pdev, IORESOURCE_MEM, 411: "kgsl_gmu_pdc_cfg"); 412: 413: /* 414: * Map the starting address for pdc_cfg programming. If the pdc_cfg 415: * resource is not available use an offset from the base PDC resource. 416: */ 417: if (gmu->pdc_cfg_base == NULL) { 418: if (res_cfg) 419: gmu->pdc_cfg_base = devm_ioremap(gmu_pdev_dev, 420: res_cfg->start, resource_size(res_cfg)); 421: else if (res_pdc) 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: 463: if (!gmu->pdc_seq_base) { 464: dev_err(gmu_pdev_dev, "Failed to map PDC SEQ\n"); 465: return -ENODEV; 466: } 467: } 468: 469: seq = gmu->pdc_seq_base; 470: 471: /* Load PDC sequencer uCode for power up and power down sequence */ 472: _regwrite(seq, PDC_GPU_SEQ_MEM_0, 0xFEBEA1E1); 473: _regwrite(seq, PDC_GPU_SEQ_MEM_0 + 1, 0xA5A4A3A2); 474: _regwrite(seq, PDC_GPU_SEQ_MEM_0 + 2, 0x8382A6E0); 475: _regwrite(seq, PDC_GPU_SEQ_MEM_0 + 3, 0xBCE3E284); 476: _regwrite(seq, PDC_GPU_SEQ_MEM_0 + 4, 0x002081FC); 477: 478: /* Set TCS commands used by PDC sequence for low power modes */ 479: _regwrite(cfg, PDC_GPU_TCS1_CMD_ENABLE_BANK, 7); 480: _regwrite(cfg, PDC_GPU_TCS1_CMD_WAIT_FOR_CMPL_BANK, 0); 481: _regwrite(cfg, PDC_GPU_TCS1_CONTROL, 0); 482: _regwrite(cfg, PDC_GPU_TCS1_CMD0_MSGID, 0x10108); 483: _regwrite(cfg, PDC_GPU_TCS1_CMD0_ADDR, mx_res_addr); 484: _regwrite(cfg, PDC_GPU_TCS1_CMD0_DATA, 1); 485: _regwrite(cfg, PDC_GPU_TCS1_CMD0_MSGID + PDC_CMD_OFFSET, 0x10108); 486: _regwrite(cfg, PDC_GPU_TCS1_CMD0_ADDR + PDC_CMD_OFFSET, cx_res_addr); 487: _regwrite(cfg, PDC_GPU_TCS1_CMD0_DATA + PDC_CMD_OFFSET, 0x0); 488: _regwrite(cfg, PDC_GPU_TCS1_CMD0_MSGID + PDC_CMD_OFFSET * 2, 0x10108); MATCH LINES: 546, 547, 559, 560, 563, 566, 570, 573, 578, 579, 580, 582, 583, 586, 587, 588, 591, 592, 593, 598, 602, 613, 618, 624, 635, 641, 642, 645, 651, 656, 657, 658, 660, 661, 669, 672, 676, 678, 679, 681, 683, 684, 694, 698, 704, 706, 708, 711, 715, 720, 721, 725, 736, 738, 743, 751, 754, 757, 760, 764, 767, 778, 782, 785, 787, 794, 795, 802, 811, 820, 822, 827, 830, 831, 840, 843, 849, 851, 852, 853, 855, 856, 859, 862, 868, 880, 882, 883, 884, 885, 886, 887, 888, 889, 894, 897, 898, 900, 903, 906, 907, 910, 914, 925, 926, 927, 935, 937, 939, 940, 942, 943, 947, 949, 953, 954, 957, 960, 967, 968, 969, 974, 975, 978, 981, 985, 986, 988, 989, 990, 991, 999, 1002, 1010, 1011, 1013, 1014, 1018, 1020, 1027, 1034, 1047, 1054, 1059, 1061, 1064, 1066, 1068, 1070 534: 535: done: 536: /* Setup GPU PDC */ 537: _regwrite(cfg, PDC_GPU_SEQ_START_ADDR, 0); 538: _regwrite(cfg, PDC_GPU_ENABLE_PDC, PDC_ENABLE_REG_VALUE); 539: 540: /* ensure no writes happen before the uCode is fully written */ 541: wmb(); 542: return 0; 543: } 544: 545: /* GMU timeouts */ 546: #define GMU_IDLE_TIMEOUT 100 /* ms */ 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, 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: 880: static const char *oob_to_str(enum oob_request req) 881: { 882: if (req == oob_gpu) 883: return "oob_gpu"; 884: else if (req == oob_perfcntr) 885: return "oob_perfcntr"; 886: else if (req == oob_boot_slumber) 887: return "oob_boot_slumber"; 888: else if (req == oob_dcvs) 889: return "oob_dcvs"; 890: return "unknown"; 891: } 892: 893: static void trigger_reset_recovery(struct adreno_device *adreno_dev, 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, MATCH LINES: 1129, 1132, 1144, 1147, 1148, 1152, 1153, 1162, 1165, 1180, 1183, 1186, 1187, 1191, 1200, 1204, 1205, 1213, 1214, 1218, 1222, 1227, 1232, 1242, 1244, 1251, 1255, 1259, 1264, 1265, 1266, 1268, 1271, 1273, 1277, 1280, 1299, 1302, 1303, 1310, 1312, 1313, 1314, 1315, 1326, 1327, 1335, 1336, 1337, 1338, 1340, 1342, 1345, 1347, 1350, 1353, 1355, 1356, 1359, 1364, 1365, 1372, 1375, 1376, 1377, 1382, 1388, 1395, 1396, 1397, 1398, 1399, 1403, 1411, 1413, 1416, 1419, 1421, 1423, 1425, 1427, 1431, 1434, 1440, 1447, 1448, 1449, 1454, 1491, 1494, 1497, 1500, 1502, 1509, 1510, 1511, 1515, 1518, 1519, 1521, 1522, 1523, 1531, 1533, 1534, 1541, 1552, 1553, 1556, 1560, 1578, 1581, 1582, 1583, 1584, 1587, 1589, 1592, 1595, 1596, 1598, 1602, 1607, 1609, 1617, 1622, 1627, 1628, 1637, 1638, 1640, 1643, 1646, 1653, 1657, 1661, 1670, 1672, 1674, 1675, 1685, 1696, 1699, 1709, 1710, 1711, 1721, 1723, 1729, 1730, 1736, 1737, 1738, 1740, 1743, 1747, 1752, 1756, 1760, 1765, 1770, 1780, 1786, 1787, 1792, 1796, 1816, 1830, 1845, 1852, 1854, 1855, 1859, 1862, 1866, 1873, 1877, 1879, 1880, 1887, 1892, 1893, 1894, 1895, 1897, 1898, 1901, 1902, 1904, 1913, 1921, 1926, 1933, 1935, 1937, 1939, 1941, 1946, 1951, 1952, 1953, 1960, 1984, 1985, 1987, 1990, 1998, 1999, 2000, 2004, 2009, 2011, 2014, 2018, 2037, 2039, 2045, 2046, 2051, 2058, 2059, 2081, 2088, 2092, 2093, 2094, 2097, 2099, 2108, 2111, 2115, 2116, 2122, 2126, 2127, 2133, 2135, 2137, 2141, 2146, 2149, 2151, 2152, 2162, 2169, 2175, 2177, 2178, 2180, 2182, 2186, 2194, 2195, 2197, 2198, 2200, 2201, 2203, 2206, 2208, 2212, 2213, 2215, 2220, 2225, 2229, 2231, 2232, 2236, 2238, 2264, 2268, 2271, 2276, 2283, 2284, 2285, 2289, 2290, 2294, 2298, 2303, 2309, 2313, 2317, 2321, 2323, 2325, 2334, 2340, 2341, 2344, 2350, 2353, 2354, 2356, 2362, 2367, 2371, 2377, 2384, 2386, 2387, 2392, 2395, 2397, 2402, 2405, 2414, 2422, 2426, 2428, 2433, 2437, 2438, 2440, 2446, 2451, 2455, 2459, 2466, 2468, 2469, 2474, 2477, 2479, 2486, 2489, 2492, 2495, 2508, 2509, 2510, 2511, 2512, 2513, 2514, 2515, 2516, 2517, 2518, 2521, 2531, 2547, 2548, 2551, 2554, 2555, 2565, 2583, 2584, 2590, 2596, 2620, 2623, 2634, 2639, 2640, 2643, 2644, 2647, 2652, 2655, 2668, 2682, 2687, 2688, 2693, 2695, 2697, 2698, 2709, 2722, 2724, 2725, 2732, 2737, 2742, 2743, 2745, 2746, 2750, 2762, 2763, 2768, 2772, 2775, 2777, 2786, 2788, 2799, 2800, 2801, 2809, 2833, 2838, 2842, 2850, 2854, 2860, 2869, 2871, 2873, 2875, 2877, 2884, 2885, 2886, 2904 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); MATCH LINES: 2946, 2948, 2950, 2952, 2976, 2992, 2994, 2995, 2999, 3000, 3002, 3003, 3006, 3011, 3021, 3025, 3031, 3032, 3034, 3046, 3058, 3061, 3062, 3082, 3088, 3105, 3106 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: 3119: /* 3120: * There is a possible deadlock scenario during kgsl firmware reading 3121: * (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl 3122: * device mutex is held and then firmware_request_nowarn is called for reading 3123: * firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock. 3124: * Whereas in case of devfreq update calls triggered by thermal/bcl or 3125: * devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then 3126: * tries to take kgsl device mutex as part of get_dev_status/target 3127: * calls. This results in deadlock when both thread are unable to acquire 3128: * the mutex held by other thread. Enable devfreq updates now as we are 3129: * done reading all firmware files. 3130: */ MATCH LINES: 3162, 3165, 3171, 3173, 3178, 3199, 3204, 3214, 3227, 3232, 3237, 3245, 3270, 3294, 3296, 3298, 3304, 3307, 3313, 3317, 3329, 3332, 3335, 3344, 3347, 3359, 3362, 3364, 3372, 3375, 3378, 3385, 3386, 3389, 3394, 3404, 3422, 3423, 3424, 3425, 3426, 3427, 3428, 3429, 3430, 3433, 3434, 3435, 3436, 3437, 3438, 3439, 3440, 3443, 3470, 3472, 3477, 3479, 3483, 3485, 3488, 3494, 3500, 3502, 3506, 3507, 3508, 3513, 3524, 3525, 3530, 3535, 3541, 3549, 3553, 3554, 3557, 3565, 3573, 3574, 3576, 3579, 3580, 3581, 3584, 3596, 3600, 3602, 3605, 3607, 3612, 3618, 3619, 3620, 3623 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: 70 --- MATCH LINES: 6, 7, 13, 16, 20, 26, 30, 54, 55, 71, 74, 87, 93, 96, 103, 107, 114, 118, 123, 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, 266, 268, 272, 275, 277, 279, 282, 285, 292, 295, 300 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 10: #include 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; 56: /** @pdc_cfg_base: Base address of PDC cfg registers */ 57: void __iomem *pdc_cfg_base; 58: /** @pdc_seq_base: Base address of PDC seq registers */ 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: * MATCH LINES: 344, 347, 350, 353, 356, 361, 362, 365, 368 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: 74 --- MATCH LINES: 13, 15, 24, 31, 46, 57, 68, 79 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, 82: 0x26000, 0x26004, 0x26400, 0x26405, 0x26414, 0x2641d, 0x2642a, 0x26430, 83: 0x26432, 0x26432, 0x26441, 0x26455, 0x26466, 0x26468, 0x26478, 0x2647a, 84: 0x26489, 0x2648a, 0x2649c, 0x2649e, 0x264a0, 0x264a3, 0x264b3, 0x264b5, 85: 0x264c5, 0x264c7, 0x264d6, 0x264d8, 0x264e8, 0x264e9, 0x264f9, 0x264fc, 86: 0x2650b, 0x2650c, 0x2651c, 0x2651e, 0x26540, 0x26570, 0x26600, 0x26616, 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, MATCH LINES: 158, 161, 162, 163, 167, 172, 174, 178, 179, 181, 184, 187, 188, 189, 191, 194, 198, 203, 205, 208, 210, 213, 214, 216, 218, 221, 223, 228, 229, 230, 231, 233, 234, 235, 236, 237, 239, 242, 243, 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: 319, 326, 330, 332, 333, 335, 337, 343, 344, 346, 347, 352, 353, 356, 357, 360, 361, 365, 366, 370, 374, 379, 380, 384, 390, 391 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: 191 --- MATCH LINES: 17, 20, 21, 25, 31, 34, 35, 36, 37, 44, 58, 75, 81, 85, 86, 90, 93, 100, 103, 105, 106, 113, 116, 134, 141, 143, 148, 152, 162, 163, 172, 173, 175, 176, 181, 182, 183, 184, 194, 195, 201, 202, 203, 204, 205, 210, 212, 215, 219, 221, 225, 226, 227, 228, 232, 235, 238, 247, 253, 257, 262, 265, 274, 278, 282, 283, 286, 289, 294, 295, 297, 302, 309, 316, 320, 327, 329, 330, 332, 342, 345, 348, 360, 368, 374, 376, 385, 388, 391, 402, 404, 405, 409, 412, 423, 425, 431, 433, 434, 435, 437, 455, 458, 460, 469, 472, 474, 477, 479, 484, 485, 488, 490, 491, 493, 497, 500, 502, 516, 523, 526, 529, 531, 532, 537, 554, 564, 568, 573, 576, 577, 579, 582, 588, 589, 591, 593, 594, 596, 599, 604, 611, 616, 619, 634, 638, 642, 647, 649, 653, 656, 657, 663, 665, 666, 667, 668, 672, 675, 682, 684, 688, 692, 697, 701, 702, 704, 709, 719, 720, 724, 728, 732, 736, 737, 743, 749, 755, 757, 762, 766, 769, 772, 773, 775, 776, 777, 778, 785, 786, 788 5: */ 6: 7: #include 8: #include 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), 59: "HFI message too big: hdr:0x%x rd idx=%d\n", 60: msg_hdr, hdr->read_index); 61: result = -EMSGSIZE; 62: goto done; 63: } 64: 65: read = hdr->read_index; 66: 67: if (read < hdr->queue_size) { 68: for (i = 0; i < size && i < (max_size >> 2); i++) { 69: output[i] = queue[read]; 70: read = (read + 1)%hdr->queue_size; 71: } 72: result = size; 73: } else { 74: /* In case FW messed up */ 75: dev_err(GMU_PDEV_DEV(device), 76: "Read index %d greater than queue size %d\n", 77: hdr->read_index, hdr->queue_size); 78: result = -ENODATA; 79: } 80: 81: if (GMU_VER_MAJOR(device->gmu_core.ver.hfi) >= 2) 82: read = ALIGN(read, SZ_4) % hdr->queue_size; 83: 84: /* For acks, trace the packet for which this ack was sent */ 85: if (MSG_HDR_GET_TYPE(msg_hdr) == HFI_MSG_ACK) 86: trace_kgsl_hfi_receive(MSG_HDR_GET_ID(output[1]), 87: MSG_HDR_GET_SIZE(output[1]), 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: 128: for (i = 0; i < size_dwords; i++) { 129: queue[write_idx] = msg[i]; 130: write_idx = (write_idx + 1) % hdr->queue_size; 131: } 132: 133: /* Cookify any non used data at the end of the write buffer */ 134: if (GMU_VER_MAJOR(device->gmu_core.ver.hfi) >= 2) { 135: for (; i < align_size; i++) { 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: } 197: 198: /* Fill Table Header */ 199: tbl = mem_addr->hostptr; 200: tbl->qtbl_hdr.version = 0; 201: tbl->qtbl_hdr.size = sizeof(struct hfi_queue_table) >> 2; 202: tbl->qtbl_hdr.qhdr0_offset = sizeof(struct hfi_queue_table_header) >> 2; 203: tbl->qtbl_hdr.qhdr_size = sizeof(struct hfi_queue_header) >> 2; 204: tbl->qtbl_hdr.num_q = HFI_QUEUE_MAX; 205: tbl->qtbl_hdr.num_active_q = HFI_QUEUE_MAX; 206: 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: 41 --- MATCH LINES: 6, 7, 22, 23, 24, 25, 27, 30, 32, 33, 36, 41, 44, 49, 52, 60, 66, 74, 78, 86, 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: 165 --- MATCH LINES: 16, 29, 39, 48, 50, 56, 62, 68, 74, 78, 86, 88, 89, 92, 96, 101, 107, 111, 115, 119, 125, 128, 130, 132, 135, 145, 149, 154, 156, 162, 169, 171, 172, 176, 179, 182, 184, 189, 200, 208, 212, 214, 219, 223, 228, 230, 234, 240, 242, 243, 247, 250, 253, 255, 264, 265, 277, 279, 287, 291, 296, 300, 308, 314, 321, 323, 325, 327, 329, 333, 338, 339, 340, 354 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #include 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, 54: entry->md); 55: 56: if (entry->desc.mem_kind == HFI_MEMKIND_SCRATCH) 57: kgsl_snapshot_add_section(device, 58: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 59: snapshot, adreno_snapshot_global, 60: entry->md); 61: 62: if (entry->desc.mem_kind == HFI_MEMKIND_PROFILE) 63: kgsl_snapshot_add_section(device, 64: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 65: snapshot, adreno_snapshot_global, 66: entry->md); 67: 68: if (entry->desc.mem_kind == HFI_MEMKIND_CSW_SMMU_INFO) 69: kgsl_snapshot_add_section(device, 70: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 71: snapshot, adreno_snapshot_global, 72: entry->md); 73: 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); MATCH LINES: 393, 396, 409, 414, 418, 422, 426, 432, 439, 440, 443, 448, 458, 477, 482, 490, 501, 503, 516, 531, 534, 550, 556, 569, 570 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 585: * (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl 586: * device mutex is held and then firmware_request_nowarn is called for reading 587: * firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock. 588: * Whereas in case of devfreq update calls triggered by thermal/bcl or 589: * devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then 590: * tries to take kgsl device mutex as part of get_dev_status/target 591: * calls. This results in deadlock when both thread are unable to acquire 592: * the mutex held by other thread. Enable devfreq updates now as we are 593: * done reading all firmware files. 594: */ MATCH LINES: 609, 612, 617, 619, 633, 638, 644, 666, 687, 723, 729, 749, 750, 751, 758, 764, 783, 786, 794, 795, 799, 825, 842, 845, 858, 868, 886, 888, 889, 891, 893, 896, 901, 903, 911, 931, 944, 949, 951, 953, 957 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); 663: 664: kgsl_mutex_lock(&device->mutex); 665: 666: if (test_bit(GMU_DISABLE_SLUMBER, &device->gmu_core.flags)) 667: goto done; 668: 669: if (atomic_read(&device->active_cnt) || time_is_after_jiffies(device->idle_jiffies)) { 670: kgsl_pwrscale_update(device); 671: goto done; 672: } 673: 674: spin_lock(&device->submit_lock); 675: if (device->submit_now) { 676: spin_unlock(&device->submit_lock); 677: kgsl_pwrscale_update(device); 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, MATCH LINES: 1022, 1034, 1036, 1037, 1038, 1043, 1046, 1047, 1052, 1054, 1055, 1056, 1063, 1070, 1072, 1073, 1074, 1081, 1082, 1086, 1087, 1088, 1089, 1101, 1110 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); 1090: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, 1091: name, 1092: entry->md->hostptr, 1093: entry->md->size); 1094: if (ret) 1095: return ret; 1096: } 1097: } 1098: 1099: if (!IS_ERR_OR_NULL(hw_hfi->big_ib)) { 1100: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, 1101: KGSL_HFI_BIG_IB_ENTRY, 1102: hw_hfi->big_ib->hostptr, 1103: hw_hfi->big_ib->size); 1104: if (ret) 1105: return ret; 1106: } 1107: 1108: if (!IS_ERR_OR_NULL(hw_hfi->big_ib_recurring)) 1109: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, 1110: KGSL_HFI_BIG_IB_REC_ENTRY, 1111: hw_hfi->big_ib_recurring->hostptr, 1112: hw_hfi->big_ib_recurring->size); 1113: 1114: return ret; 1115: } --- FILE: \adreno_a6xx_hwsched_hfi.c | HITS: 310 --- MATCH LINES: 18, 23, 25, 28, 48, 55, 93, 102, 109, 125, 131, 141, 149, 167, 168, 171, 172, 174, 175, 178, 179, 184, 188, 194, 195, 197, 198, 200, 201, 206, 219, 224, 225, 228, 238, 246, 264, 265, 268, 269, 271, 272, 275, 276, 281, 285, 291, 292, 294, 295, 297, 298, 303, 316, 321, 322, 325, 335, 343, 345, 346, 347, 350, 363, 367, 373, 379, 381, 386, 393, 398, 399, 400, 411, 412, 413, 421, 429, 433, 455, 459, 462, 468, 471, 472, 479, 480, 482, 486, 492, 495, 498, 499, 502, 509, 521, 526, 527, 531, 533, 546, 551, 565, 566, 569, 571, 572, 573, 574, 577, 578, 579, 581, 582, 583, 584, 586, 587, 588, 589, 591, 592, 593, 595, 596, 597, 601, 605, 606, 608, 610, 617, 619, 620, 627, 629, 630, 635, 636, 637, 638, 639, 644, 651, 652, 653, 657, 670, 673, 675, 676, 677, 687, 697, 702, 704, 707, 720, 725, 728, 731, 735, 737, 740, 748, 749, 752, 759, 763, 774, 783, 785, 786, 790, 791, 793, 800, 802, 805, 819, 826, 828, 849, 858, 863, 865, 878, 881, 890, 891, 896, 898, 902, 904, 908, 913, 917, 921, 925, 929, 933, 938, 944, 950, 951, 956, 959, 960, 963, 965, 979, 985, 995, 999, 1000, 1011, 1023 6: 7: #include 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: } 117: 118: if (num_waiters < ARRAY_SIZE(waiters)) 119: waiters[num_waiters++] = cmd->sent_hdr; 120: } 121: 122: read_unlock(&hfi->msglock); 123: 124: /* Didn't find the sender, list the waiter */ 125: dev_err_ratelimited(gmu_pdev_dev, 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; 163: } 164: 165: static void log_gpu_fault_legacy(struct adreno_device *adreno_dev) 166: { 167: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)); 168: struct hfi_context_bad_cmd_legacy *cmd = adreno_dev->hwsched.ctxt_bad; 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; 260: } 261: 262: static void log_gpu_fault(struct adreno_device *adreno_dev) 263: { 264: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)); 265: struct hfi_context_bad_cmd *cmd = adreno_dev->hwsched.ctxt_bad; 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: } 497: 498: /* Ignore OOB bits */ 499: status &= GENMASK(31 - (oob_max - 1), 0); 500: 501: if (status & ~hfi->irq_mask) 502: dev_err_ratelimited(GMU_PDEV_DEV(device), 503: "Unhandled HFI interrupts 0x%x\n", 504: status & ~hfi->irq_mask); 505: 506: return IRQ_HANDLED; 507: } 508: 509: #define HFI_IRQ_MSGQ_MASK BIT(0) 510: 511: static int check_ack_failure(struct adreno_device *adreno_dev, 512: struct pending_cmd *ack) 513: { 514: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 515: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 516: u64 ticks = gpudev->read_alwayson(adreno_dev); 517: 518: if (ack->results[2] != 0xffffffff) 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), 588: DEFINE_QHDR(gmuaddr, 9, 1), 589: DEFINE_QHDR(gmuaddr, 10, 1), 590: /* 3 DQs for RB priority 2 */ 591: DEFINE_QHDR(gmuaddr, 11, 2), 592: DEFINE_QHDR(gmuaddr, 12, 2), 593: DEFINE_QHDR(gmuaddr, 13, 2), 594: /* 3 DQs for RB priority 3 */ 595: DEFINE_QHDR(gmuaddr, 14, 3), 596: DEFINE_QHDR(gmuaddr, 15, 3), 597: DEFINE_QHDR(gmuaddr, 16, 3), 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); 638: if (IS_ERR(hfi->hfi_mem)) 639: return PTR_ERR(hfi->hfi_mem); 640: init_queues(hfi); 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; MATCH LINES: 1066, 1067, 1070, 1080, 1092, 1094, 1099, 1101, 1107, 1108, 1122, 1125, 1129 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) MATCH LINES: 1182, 1183, 1184, 1185, 1187, 1196, 1205, 1206, 1208, 1210, 1216, 1217, 1224, 1226, 1230, 1231, 1232, 1237, 1250, 1260, 1278, 1290, 1303, 1310, 1324, 1327, 1333, 1338, 1342, 1343, 1350, 1354, 1355, 1360, 1361, 1367, 1369, 1383, 1387, 1400, 1405, 1406, 1407, 1414, 1417, 1434, 1451, 1458, 1460, 1471, 1479, 1485, 1495, 1497, 1505, 1534, 1537, 1538, 1544, 1545, 1557, 1580, 1582, 1605, 1613, 1615, 1646, 1654, 1660, 1664, 1669, 1670, 1696, 1703, 1740, 1749, 1750, 1765, 1770, 1775 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: 1285: ret = CMD_MSG_HDR(cmd, H2F_MSG_REGISTER_CONTEXT); 1286: if (ret) 1287: return ret; 1288: 1289: cmd.ctxt_id = context->id; 1290: cmd.flags = HFI_CTXT_FLAG_NOTIFY | context->flags; 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); 1349: if (ret) { 1350: dev_err(GMU_PDEV_DEV(device), 1351: "Unable to register context %u pointers: %d\n", 1352: context->id, ret); 1353: 1354: if (device->gmu_fault) 1355: adreno_scheduler_fault(adreno_dev, ADRENO_GMU_FAULT); 1356: 1357: return ret; 1358: } 1359: 1360: context->gmu_registered = true; 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]; 1430: write = (write + 1) % hdr->queue_size; 1431: } 1432: 1433: /* Cookify any non used data at the end of the write buffer */ 1434: if (GMU_VER_MAJOR(device->gmu_core.ver.hfi) >= 2) { 1435: for (; i < align_size; i++) { 1436: queue[write] = 0xFAFAFAFA; 1437: write = (write + 1) % hdr->queue_size; 1438: } 1439: } 1440: 1441: /* Ensure packet is written out before proceeding */ 1442: wmb(); 1443: 1444: if (!cmdobj) 1445: goto done; 1446: 1447: adreno_hwsched_add_profile_events(adreno_dev, cmdobj, time); 1448: 1449: /* 1450: * Put the profiling information in the user profiling buffer. 1451: * The hfi_update_write_idx below has a wmb() before the actual 1452: * write index update to ensure that the GMU does not see the 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 */ 1490: if (cmdobj->numibs > HWSCHED_MAX_DISPATCH_NUMIBS || 1491: test_bit(CMDOBJ_SKIP, &cmdobj->priv)) 1492: cmd_sizebytes = sizeof(*cmd); 1493: else 1494: cmd_sizebytes = sizeof(*cmd) + 1495: (sizeof(struct hfi_issue_ib) * cmdobj->numibs); 1496: 1497: if (WARN_ON(cmd_sizebytes > HFI_MAX_MSG_SIZE)) 1498: return -EMSGSIZE; 1499: 1500: memset(cmdbuf, 0x0, cmd_sizebytes); 1501: 1502: cmd = cmdbuf; 1503: 1504: cmd->ctxt_id = drawobj->context->id; 1505: cmd->flags = HFI_CTXT_FLAG_NOTIFY; 1506: if (drawobj->flags & KGSL_DRAWOBJ_END_OF_FRAME) 1507: cmd->flags |= CMDBATCH_EOF; 1508: 1509: cmd->ts = drawobj->timestamp; 1510: 1511: if (test_bit(CMDOBJ_SKIP, &cmdobj->priv)) 1512: goto skipib; 1513: 1514: populate_ibs(adreno_dev, cmd, cmdobj); 1515: 1516: if ((drawobj->flags & KGSL_DRAWOBJ_PROFILING) && 1517: cmdobj->profiling_buf_entry) { 1518: 1519: time.drawobj = drawobj; 1520: 1521: cmd->profile_gpuaddr_lo = 1522: lower_32_bits(cmdobj->profiling_buffer_gpuaddr); 1523: cmd->profile_gpuaddr_hi = 1524: upper_32_bits(cmdobj->profiling_buffer_gpuaddr); 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) 1577: cmd_sizebytes = sizeof(*cmd); 1578: else 1579: cmd_sizebytes = sizeof(*cmd) + 1580: (sizeof(struct hfi_issue_ib) * cmdobj->numibs); 1581: 1582: if (WARN_ON(cmd_sizebytes > HFI_MAX_MSG_SIZE)) 1583: return -EMSGSIZE; 1584: 1585: cmd = kzalloc(cmd_sizebytes, GFP_KERNEL); 1586: if (cmd == NULL) 1587: return -ENOMEM; 1588: 1589: if (test_bit(CMDOBJ_RECURRING_START, &cmdobj->priv)) { 1590: if (!active) { 1591: ret = adreno_active_count_get(adreno_dev); 1592: if (ret) { 1593: kfree(cmd); 1594: return ret; 1595: } 1596: active = true; 1597: } 1598: cmd->flags |= CMDBATCH_RECURRING_START; 1599: populate_ibs(adreno_dev, cmd, cmdobj); 1600: } else 1601: cmd->flags |= CMDBATCH_RECURRING_STOP; 1602: 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: } 1640: 1641: static void trigger_context_unregister_fault(struct adreno_device *adreno_dev, 1642: struct kgsl_context *context) 1643: { 1644: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1645: 1646: gmu_core_fault_snapshot(device, GMU_FAULT_CTX_UNREGISTER); 1647: 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: 14 --- MATCH LINES: 7, 8, 34, 39, 42, 45, 48, 56, 59, 66, 69, 74, 102, 112 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 */ --- FILE: \adreno_a6xx_perfcounter.c | HITS: 76 --- MATCH LINES: 305, 317, 341, 345, 350, 361, 364, 367, 373, 391, 393 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 }, MATCH LINES: 740, 744, 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 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, \ MATCH LINES: 934, 935, 937, 938, 940, 941 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: 17 --- MATCH LINES: 62, 64, 73, 79, 80, 82, 83, 87, 88, 90, 91 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, MATCH LINES: 315, 316, 340 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: 363: if (a6xx_fenced_write(adreno_dev, 364: A6XX_CP_CONTEXT_SWITCH_NON_PRIV_RESTORE_ADDR_LO, MATCH LINES: 408, 410, 412 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: /* --- FILE: \adreno_a6xx_rgmu.c | HITS: 308 --- MATCH LINES: 23, 26, 27, 31, 44, 52, 55, 58, 60, 63, 65, 72, 75, 80, 84, 87, 89, 90, 93, 94, 96, 98, 99, 104, 106, 107, 108, 109, 114, 116, 118, 119, 121, 124, 130, 132, 133, 141, 142, 143, 145, 146, 147, 151, 152, 157, 159, 161, 162, 164, 166, 169, 170, 173, 175, 179, 180, 183, 184, 187, 188, 193, 194, 200, 202, 206, 207, 209, 210, 211, 212, 215, 216, 219, 221, 225, 226, 229, 230, 232, 233, 236, 240, 259, 261, 267, 274, 278, 279, 283, 286, 297, 299, 300, 312, 313, 321, 322, 323, 325, 326, 327, 329, 345, 349, 360, 361, 364, 367, 370, 372, 376, 381, 382, 384, 388, 395, 396, 397, 402, 405, 407, 408, 409, 412, 413, 418, 421, 424, 430, 432, 433, 434, 437, 442, 447, 452, 455, 458, 460, 468, 478, 489, 493, 495, 496, 500, 501, 502, 504, 508, 512, 513, 519, 523, 526, 564, 567, 570, 594, 595, 598, 603, 607, 612, 613, 614, 624, 630, 632, 650, 657, 658, 661, 663, 665, 670, 671, 687, 706, 722, 726, 734, 748, 750, 774, 790, 794, 795, 798, 803, 814, 820, 825, 833, 840, 847, 852, 857, 865, 890, 900, 904, 909, 921, 930, 933, 940, 941, 944, 949, 959, 980, 983, 984, 1002, 1008, 1020, 1021, 1046, 1069, 1072, 1078, 1080, 1085, 1099, 1101, 1112, 1122, 1133, 1135, 1137, 1143, 1145, 1150, 1156, 1162, 1165, 1171, 1175, 1187, 1190, 1193, 1202, 1205, 1217, 1220, 1222, 1228, 1233, 1234, 1235, 1236, 1237, 1238, 1241, 1243, 1246, 1247, 1248, 1253, 1257, 1262, 1266, 1303, 1304, 1312, 1313, 1314, 1315, 1316, 1317, 1318, 1319, 1322, 1349, 1351, 1356, 1366, 1370, 1381, 1394, 1395, 1402, 1403, 1408, 1409, 1410, 1415, 1418, 1421, 1425, 1428, 1433, 1436, 1437, 1438, 1441, 1453, 1457, 1459, 1462, 1464, 1469, 1475, 1476, 1477, 1480 11: #include 12: #include 13: #include 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: /* 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); 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); 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; 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) 1296: rgmu->gpu_clk = kgsl_of_clk_by_name(rgmu->clks, ret, "core"); 1297: 1298: if (!rgmu->gpu_clk) { 1299: dev_err(&rgmu->pdev->dev, "The GPU clock isn't defined\n"); 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: 35 --- MATCH LINES: 6, 7, 9, 10, 12, 13, 14, 15, 17, 20, 21, 22, 23, 24, 25, 29, 31, 32, 37, 42, 45, 46, 53, 58, 59, 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: 2 --- MATCH LINES: 169, 171 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: --- FILE: \adreno_a6xx_rpmh.c | HITS: 19 --- MATCH LINES: 15, 30, 32, 34, 37, 38, 39, 41, 48, 50, 71, 73, 84, 107, 126, 149, 167, 177, 192 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_hfi.h" 10: #include "adreno_rpmh.h" 11: #include "kgsl_bus.h" 12: #include "kgsl_device.h" 13: 14: /* 15: * setup_gmu_arc_votes - Build the gmu voting table 16: * @adreno_dev: Pointer to adreno device 17: * @pri_rail: Pointer to primary power rail vlvl table 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: } 56: 57: /* 58: * setup_gx_arc_votes - Build the gpu dcvs voting table 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; 96: 97: /* GMU power levels are in ascending order */ 98: for (index = 1, i = pwr->num_pwrlevels - 1; i >= 0; i--, index++) { 99: u32 cx_vlvl = pwr->pwrlevels[i].cx_level; 100: 101: vlvl_tbl[index] = pwr->pwrlevels[i].voltage_level; 102: table->gx_votes[index].freq = pwr->pwrlevels[i].gpu_freq / 1000; 103: 104: ret = adreno_rpmh_to_cx_hlvl(cx_rail, cx_vlvl, 105: &table->gx_votes[index].dep_vote); 106: if (ret) { 107: dev_err(GMU_PDEV_DEV(device), "Unsupported cx corner: %u\n", 108: cx_vlvl); 109: return ret; 110: } 111: } 112: 113: ret = adreno_rpmh_setup_volt_dependency_tbl(gx_votes, pri_rail, 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: 153: return setup_gx_arc_votes(adreno_dev, &gx_arc, &mx_arc, &cx_arc); 154: } 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, 192: adreno_dev->gmu_ab); 193: 194: if (cnoc_table != default_cnoc_table) 195: kfree(cnoc_table); 196: 197: if (IS_ERR(cnoc)) { 198: adreno_rpmh_free_bw_votes(ddr); 199: return PTR_ERR(cnoc); 200: } 201: 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; --- FILE: \adreno_a6xx_snapshot.c | HITS: 15 --- MATCH LINES: 320, 327, 354, 359 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, MATCH LINES: 415, 442 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, MATCH LINES: 1268, 1270, 1271 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); MATCH LINES: 1692, 1695, 1696, 1699, 1700, 1703 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); --- FILE: \adreno_coresight.c | HITS: 2 --- MATCH LINES: 104 92: kgsl_mutex_lock(&device->mutex); 93: 94: if (!adreno_csdev->enabled) { 95: kgsl_mutex_unlock(&device->mutex); 96: return; 97: } 98: 99: adreno_dev->coresight_en_cnt--; 100: 101: /* GMU takes care of DBGC interrupt mask for HWSCHED */ 102: if (!adreno_dev->coresight_en_cnt) { 103: if (adreno_dev->hwsched_enabled) 104: gmu_core_set_vrb_register(device->gmu_core.vrb, 105: VRB_DBGC_FAULT_ENABLE, 0); 106: else 107: adreno_dev->irq_mask &= ~ADRENO_DEBUG_BUS_INT_MASK; 108: } 109: 110: if (!adreno_active_count_get(adreno_dev)) { 111: for (i = 0; i < coresight->count; i++) 112: kgsl_regwrite(device, 113: coresight->registers[i].offset, 0); 114: adreno_active_count_put(adreno_dev); 115: } 116: 117: adreno_csdev->enabled = false; 118: 119: kgsl_mutex_unlock(&device->mutex); 120: } 121: 122: static void _adreno_coresight_get_and_clear(struct adreno_device *adreno_dev, 123: struct adreno_coresight_device *adreno_csdev) 124: { 125: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 126: const struct adreno_coresight *coresight = adreno_csdev->coresight; 127: int i; 128: MATCH LINES: 201 189: adreno_csdev->enabled = true; 190: 191: /* Reset all the debug registers to their default values */ 192: for (i = 0; i < coresight->count; i++) 193: coresight->registers[i].value = 194: coresight->registers[i].initial; 195: 196: adreno_dev->coresight_en_cnt++; 197: 198: /* GMU takes care of DBGC interrupt mask for HWSCHED */ 199: if (adreno_dev->coresight_en_cnt == 1) { 200: if (adreno_dev->hwsched_enabled) 201: gmu_core_set_vrb_register(device->gmu_core.vrb, 202: VRB_DBGC_FAULT_ENABLE, 1); 203: else 204: adreno_dev->irq_mask |= ADRENO_DEBUG_BUS_INT_MASK; 205: } 206: 207: ret = adreno_active_count_get(adreno_dev); 208: if (!ret) { 209: _adreno_coresight_set(adreno_dev, adreno_csdev); 210: adreno_active_count_put(adreno_dev); 211: } 212: 213: } 214: kgsl_mutex_unlock(&device->mutex); 215: return ret; 216: } 217: 218: #if (KERNEL_VERSION(6, 4, 0) >= LINUX_VERSION_CODE) 219: static int adreno_coresight_enable(struct coresight_device *csdev, 220: struct perf_event *event, u32 mode) 221: { 222: return _adreno_coresight_enable(csdev, event, mode); 223: } 224: #else 225: static int adreno_coresight_enable(struct coresight_device *csdev, --- FILE: \adreno_debugfs.c | HITS: 25 --- MATCH LINES: 469, 480, 492, 503, 515, 526 457: */ 458: _kgsl_context_get(&ctx->base); 459: 460: snprintf(name, sizeof(name), "%d", ctx->base.id); 461: 462: ctx->debug_root = debugfs_create_file(name, 0444, 463: adreno_dev->ctx_d_debugfs, ctx, &ctx_fops); 464: } 465: 466: static int _bcl_sid0_set(void *data, u64 val) 467: { 468: struct kgsl_device *device = data; 469: const struct gmu_dev_ops *ops = GMU_DEVICE_OPS(device); 470: 471: if (ops && ops->bcl_sid_set) 472: return ops->bcl_sid_set(device, 0, val); 473: 474: return 0; 475: } 476: 477: static int _bcl_sid0_get(void *data, u64 *val) 478: { 479: struct kgsl_device *device = data; 480: const struct gmu_dev_ops *ops = GMU_DEVICE_OPS(device); 481: 482: if (ops && ops->bcl_sid_get) 483: *val = ops->bcl_sid_get(device, 0); 484: 485: return 0; 486: } 487: DEFINE_DEBUGFS_ATTRIBUTE(_sid0_fops, _bcl_sid0_get, _bcl_sid0_set, "%llu\n"); 488: 489: static int _bcl_sid1_set(void *data, u64 val) 490: { 491: struct kgsl_device *device = data; 492: const struct gmu_dev_ops *ops = GMU_DEVICE_OPS(device); 493: 494: if (ops && ops->bcl_sid_set) 495: return ops->bcl_sid_set(device, 1, val); 496: 497: return 0; 498: } 499: 500: static int _bcl_sid1_get(void *data, u64 *val) 501: { 502: struct kgsl_device *device = data; 503: const struct gmu_dev_ops *ops = GMU_DEVICE_OPS(device); 504: 505: if (ops && ops->bcl_sid_get) 506: *val = ops->bcl_sid_get(device, 1); 507: 508: return 0; 509: } 510: DEFINE_DEBUGFS_ATTRIBUTE(_sid1_fops, _bcl_sid1_get, _bcl_sid1_set, "%llu\n"); 511: 512: static int _bcl_sid2_set(void *data, u64 val) 513: { 514: struct kgsl_device *device = data; 515: const struct gmu_dev_ops *ops = GMU_DEVICE_OPS(device); 516: 517: if (ops && ops->bcl_sid_set) 518: return ops->bcl_sid_set(device, 2, val); 519: 520: return 0; 521: } 522: 523: static int _bcl_sid2_get(void *data, u64 *val) 524: { 525: struct kgsl_device *device = data; 526: const struct gmu_dev_ops *ops = GMU_DEVICE_OPS(device); 527: 528: if (ops && ops->bcl_sid_get) 529: *val = ops->bcl_sid_get(device, 2); 530: 531: return 0; 532: } 533: DEFINE_DEBUGFS_ATTRIBUTE(_sid2_fops, _bcl_sid2_get, _bcl_sid2_set, "%llu\n"); 534: 535: static int _bcl_throttle_time_us_get(void *data, u64 *val) 536: { 537: struct kgsl_device *device = data; 538: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 539: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 540: 541: if (gpudev->power_feature_stats) 542: gpudev->power_feature_stats(adreno_dev); 543: 544: if (!ADRENO_FEATURE(adreno_dev, ADRENO_BCL)) 545: *val = 0; 546: else 547: *val = (u64) adreno_dev->bcl_throttle_time_us; 548: 549: return 0; 550: } MATCH LINES: 628, 643, 645, 648, 658, 685, 702, 720, 726, 728, 732, 738, 742, 746 616: struct adreno_device *adreno_dev = data; 617: 618: *val = (u64) adreno_dev->preempt.preempt_level; 619: return 0; 620: } 621: 622: DEFINE_DEBUGFS_ATTRIBUTE(preempt_level_fops, _preempt_level_show, _preempt_level_store, "%llu\n"); 623: 624: static int _warmboot_show(void *data, u64 *val) 625: { 626: struct adreno_device *adreno_dev = data; 627: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 628: struct gmu_core_device *gmu = &device->gmu_core; 629: 630: *val = (u64)gmu->warmboot_enabled; 631: return 0; 632: } 633: 634: /* 635: * When warmboot feature is enabled from debugfs, the first slumber exit will be a cold boot 636: * and all hfi messages will be recorded, so that warmboot can happen on subsequent slumber 637: * exit. When warmboot feature is disabled from debugfs, every slumber exit will be a coldboot. 638: */ 639: static int _warmboot_store(void *data, u64 val) 640: { 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 */ 726: val = FIELD_GET(GENMASK(GMU_FAULT_MAX, 0), val); 727: 728: if (val == device->gmu_core.gf_panic) 729: return 0; 730: 731: kgsl_mutex_lock(&device->mutex); 732: device->gmu_core.gf_panic = val; 733: kgsl_mutex_unlock(&device->mutex); 734: 735: return 0; 736: } 737: 738: static int _gmu_fp_show(void *data, u64 *val) 739: { 740: struct adreno_device *adreno_dev = data; 741: 742: *val = (u64) KGSL_DEVICE(adreno_dev)->gmu_core.gf_panic; 743: return 0; 744: } 745: 746: DEFINE_DEBUGFS_ATTRIBUTE(gmu_fp_fops, _gmu_fp_show, _gmu_fp_store, "%llu\n"); 747: 748: static void _toggle_host_based_dcvs(struct adreno_device *adreno_dev, void *priv) 749: { 750: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 751: bool val = *((bool *)priv); 752: 753: if (val) { 754: /* Enable host based DCVS */ 755: device->pwrscale.devfreq_enabled = true; 756: device->pwrctrl.bus_control = true; 757: kgsl_pwrscale_close(device); 758: device->host_based_dcvs = val; 759: kgsl_pwrscale_init(device, device->pdev); 760: kgsl_pwrscale_governor_enable(device); 761: adreno_dev->dcvs_profile_enabled = false; 762: } else { 763: /* Disable host based DCVS */ 764: kgsl_pwrscale_governor_disable(device, false); 765: kgsl_pwrscale_close(device); 766: device->host_based_dcvs = val; 767: kgsl_pwrscale_init(device, device->pdev); 768: device->pwrscale.devfreq_enabled = false; 769: device->pwrctrl.bus_control = false; 770: if (ADRENO_FEATURE(adreno_dev, ADRENO_DCVS_PROFILE)) MATCH LINES: 829, 836, 837, 840, 872 817: 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); 856: debugfs_create_file("sid1", 0644, adreno_dev->bcl_debugfs_dir, device, &_sid1_fops); 857: debugfs_create_file("sid2", 0644, adreno_dev->bcl_debugfs_dir, device, &_sid2_fops); 858: debugfs_create_file("bcl_throttle_time_us", 0444, adreno_dev->bcl_debugfs_dir, 859: device, &_bcl_throttle_fops); 860: } 861: 862: adreno_dev->preemption_debugfs_dir = debugfs_create_dir("preemption", device->d_debugfs); 863: if (!IS_ERR_OR_NULL(adreno_dev->preemption_debugfs_dir)) { 864: debugfs_create_file("preempt_level", 0644, adreno_dev->preemption_debugfs_dir, 865: device, &preempt_level_fops); 866: debugfs_create_file("usesgmem", 0644, adreno_dev->preemption_debugfs_dir, device, 867: &usesgmem_fops); 868: debugfs_create_file("skipsaverestore", 0644, adreno_dev->preemption_debugfs_dir, 869: device, &skipsaverestore_fops); 870: } 871: 872: if (ADRENO_FEATURE(adreno_dev, ADRENO_GMU_BASED_DCVS)) 873: debugfs_create_file("host_based_dcvs", 0644, device->d_debugfs, 874: device, &host_based_dcvs_fops); 875: } --- FILE: \adreno_dispatch.c | HITS: 11 --- MATCH LINES: 15 3: * Copyright (c) 2013-2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #include 8: #include 9: #include 10: #include "adreno.h" 11: #include "adreno_sysfs.h" 12: #include "adreno_trace.h" 13: #include "kgsl_bus.h" 14: #include "kgsl_eventlog.h" 15: #include "kgsl_gmu_core.h" 16: #include "kgsl_util.h" 17: 18: #define DRAWQUEUE_NEXT(_i, _s) (((_i) + 1) % (_s)) 19: 20: /* Number of commands that can be queued in a context before it sleeps */ 21: static unsigned int _context_drawqueue_size = 50; 22: 23: /* Number of milliseconds to wait for the context queue to clear */ 24: static unsigned int _context_queue_wait = 10000; 25: 26: /* Number of drawobjs sent at a time from a single context */ 27: static unsigned int _context_drawobj_burst = 5; 28: 29: /* 30: * GFT throttle parameters. If GFT recovered more than 31: * X times in Y ms invalidate the context and do not attempt recovery. 32: * X -> _fault_throttle_burst 33: * Y -> _fault_throttle_time 34: */ 35: static unsigned int _fault_throttle_time = 3000; 36: static unsigned int _fault_throttle_burst = 3; 37: 38: /* 39: * Maximum ringbuffer inflight for the single submitting context case - this MATCH LINES: 561 549: * the command queue in question goes current, but universally setting 550: * it here avoids the possibilty of some race conditions with preempt 551: */ 552: 553: if (dispatch_q->inflight == 1) 554: dispatch_q->expires = jiffies + 555: msecs_to_jiffies(adreno_drawobj_timeout); 556: 557: info.inflight = (int) dispatcher->inflight; 558: info.rb_id = drawctxt->rb->id; 559: info.rptr = adreno_get_rptr(drawctxt->rb); 560: info.wptr = drawctxt->rb->wptr; 561: info.gmu_dispatch_queue = -1; 562: 563: msm_perf_events_update(MSM_PERF_GFX, MSM_PERF_SUBMIT, 564: pid_nr(context->proc_priv->pid), 565: context->id, drawobj->timestamp, 566: !!(drawobj->flags & KGSL_DRAWOBJ_END_OF_FRAME)); 567: 568: trace_adreno_cmdbatch_submitted(drawobj, &info, 569: time.ticks, (unsigned long) secs, nsecs / 1000, 570: dispatch_q->inflight); 571: 572: log_kgsl_cmdbatch_submitted_event(context->id, drawobj->timestamp, 573: context->priority, drawobj->flags); 574: 575: kgsl_mutex_unlock(&device->mutex); 576: 577: cmdobj->submit_ticks = time.ticks; 578: 579: dispatch_q->cmd_q[dispatch_q->tail] = cmdobj; 580: dispatch_q->tail = (dispatch_q->tail + 1) % 581: ADRENO_DISPATCH_DRAWQUEUE_SIZE; 582: 583: /* 584: * If we believe ourselves to be current and preemption isn't a thing, 585: * then set up the timer. If this misses, then preemption is indeed a MATCH LINES: 1479 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; 1479: const char *type = fault & ADRENO_GMU_FAULT ? "gmu" : "gpu"; 1480: 1481: if (!gx_on) { 1482: if (drawobj != NULL) { 1483: pr_fault(device, drawobj, 1484: "%s fault ctx %u ctx_type %s ts %u and GX is OFF\n", 1485: type, drawobj->context->id, 1486: kgsl_context_type(drawctxt->type), 1487: drawobj->timestamp); 1488: pr_fault(device, drawobj, "cmdline: %s\n", 1489: drawctxt->base.proc_priv->cmdline); 1490: } else 1491: dev_err(device->dev, "RB[%d] : %s fault and GX is OFF\n", 1492: id, type); 1493: 1494: return; 1495: } 1496: 1497: if (gpudev->fault_header) 1498: return gpudev->fault_header(adreno_dev, drawobj); 1499: 1500: adreno_readreg(adreno_dev, ADRENO_REG_RBBM_STATUS, &status); 1501: adreno_readreg(adreno_dev, ADRENO_REG_CP_RB_RPTR, &rptr); 1502: adreno_readreg(adreno_dev, ADRENO_REG_CP_RB_WPTR, &wptr); 1503: adreno_readreg64(adreno_dev, ADRENO_REG_CP_IB1_BASE, MATCH LINES: 1858, 1859, 1874 1846: } 1847: 1848: static void do_header_and_snapshot(struct kgsl_device *device, int fault, 1849: struct adreno_ringbuffer *rb, struct kgsl_drawobj_cmd *cmdobj) 1850: { 1851: struct kgsl_drawobj *drawobj = DRAWOBJ(cmdobj); 1852: 1853: /* Always dump the snapshot on a non-drawobj failure */ 1854: if (cmdobj == NULL) { 1855: adreno_fault_header(device, rb, NULL, fault); 1856: 1857: /* GMU snapshot will also pull a full device snapshot */ 1858: if (fault & ADRENO_GMU_FAULT) 1859: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE); 1860: else 1861: kgsl_device_snapshot(device, NULL, NULL, false); 1862: return; 1863: } 1864: 1865: /* Skip everything if the PMDUMP flag is set */ 1866: if (test_bit(KGSL_FT_SKIP_PMDUMP, &cmdobj->fault_policy)) 1867: return; 1868: 1869: /* Print the fault header */ 1870: adreno_fault_header(device, rb, cmdobj, fault); 1871: 1872: if (!(drawobj->context->flags & KGSL_CONTEXT_NO_SNAPSHOT)) 1873: kgsl_device_snapshot(device, drawobj->context, NULL, 1874: fault & ADRENO_GMU_FAULT); 1875: } 1876: 1877: static int dispatcher_do_fault(struct adreno_device *adreno_dev) 1878: { 1879: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1880: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 1881: struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher; 1882: struct adreno_dispatcher_drawqueue *dispatch_q = NULL, *dispatch_q_temp; 1883: struct adreno_ringbuffer *rb; 1884: struct adreno_ringbuffer *hung_rb = NULL; 1885: unsigned int reg; 1886: uint64_t base = 0; 1887: struct kgsl_drawobj_cmd *cmdobj = NULL; 1888: int ret, i; 1889: int fault; 1890: int halt; 1891: bool gx_on; 1892: 1893: fault = adreno_gpu_fault(adreno_dev); 1894: if (fault == 0) 1895: return 0; 1896: 1897: /* 1898: * Return early if there is a concurrent suspend in progress. The suspend thread will error MATCH LINES: 1929, 1931, 1934 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); 1933: adreno_write_gmureg(adreno_dev, 1934: ADRENO_REG_GMU_GMU2HOST_INTR_MASK, 1935: 0xFFFFFFFF); 1936: } 1937: 1938: gx_on = adreno_gx_is_on(adreno_dev); 1939: 1940: /* 1941: * Check if this function was entered after a pagefault. If so, only 1942: * proceed if the fault handler has already run in the IRQ thread, 1943: * else return early to give the fault handler a chance to run. 1944: */ 1945: if (!(fault & ADRENO_IOMMU_STALL_ON_PAGE_FAULT) && gx_on) { 1946: if (adreno_smmu_is_stalled(adreno_dev)) { 1947: kgsl_mutex_unlock(&device->mutex); 1948: mutex_unlock(&adreno_dev->fault_recovery_mutex); 1949: dev_err(device->dev, 1950: "SMMU is stalled without a pagefault\n"); 1951: return -EBUSY; 1952: } 1953: } 1954: 1955: /* Turn off all the timers */ 1956: kgsl_delete_timer_sync(&dispatcher->timer); 1957: 1958: /* MATCH LINES: 2008, 2010 1996: 1997: if (dispatch_q && !adreno_drawqueue_is_empty(dispatch_q)) { 1998: cmdobj = dispatch_q->cmd_q[dispatch_q->head]; 1999: trace_adreno_cmdbatch_fault(cmdobj, fault); 2000: } 2001: 2002: if (gx_on) 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 --- FILE: \adreno_drawctxt.h | HITS: 6 --- MATCH LINES: 79, 80, 81, 82, 92, 98 67: 68: int queued; 69: unsigned int fault_policy; 70: struct dentry *debug_root; 71: unsigned int queued_timestamp; 72: struct adreno_ringbuffer *rb; 73: unsigned int submitted_timestamp; 74: uint64_t submit_retire_ticks[SUBMIT_RETIRE_TICKS_SIZE]; 75: int ticks_index; 76: 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 115: * marker. 116: * @ADRENO_CONTEXT_FORCE_PREAMBLE - Force the preamble for the next submission. 117: * @ADRENO_CONTEXT_SKIP_CMD - Context's drawobj's skipped during 118: fault tolerance. 119: * @ADRENO_CONTEXT_FENCE_LOG - Dump fences on this context. 120: */ 121: enum adreno_context_priv { 122: ADRENO_CONTEXT_FAULT = KGSL_CONTEXT_PRIV_DEVICE_SPECIFIC, --- FILE: \adreno_gen7.c | HITS: 64 --- MATCH LINES: 218, 227, 241 206: GEN7_RB_CMP_DBG_ECO_CNTL, 207: GEN7_GRAS_NC_MODE_CNTL, 208: GEN7_SP_NC_MODE_CNTL, 209: GEN7_RB_CONTEXT_SWITCH_GMEM_SAVE_RESTORE, 210: GEN7_UCHE_GBIF_GX_CONFIG, 211: GEN7_UCHE_CLIENT_PF, 212: }; 213: 214: static int acd_calibrate_set(void *data, u64 val) 215: { 216: struct kgsl_device *device = data; 217: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 218: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 219: u32 debug_val = (u32) val; 220: int ret; 221: 222: kgsl_mutex_lock(&device->mutex); 223: ret = adreno_active_count_get(adreno_dev); 224: if (ret) 225: goto err; 226: 227: ret = gen7_hfi_send_set_value(adreno_dev, HFI_VALUE_DBG, F_PWR_ACD_CALIBRATE, debug_val); 228: if (!ret) 229: gmu->acd_debug_val = debug_val; 230: 231: adreno_active_count_put(adreno_dev); 232: err: 233: kgsl_mutex_unlock(&device->mutex); 234: return ret; 235: } 236: 237: static int acd_calibrate_get(void *data, u64 *val) 238: { 239: struct kgsl_device *device = data; 240: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 241: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 242: 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); MATCH LINES: 309, 316, 326, 332, 335, 339, 345 297: } 298: 299: int gen7_fenced_write(struct adreno_device *adreno_dev, u32 offset, 300: u32 value, u32 mask) 301: { 302: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 303: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 304: unsigned int status, i; 305: u64 ts1, ts2; 306: 307: kgsl_regwrite(device, offset, value); 308: ts1 = gpudev->read_alwayson(adreno_dev); 309: for (i = 0; i < GMU_CORE_LONG_WAKEUP_RETRY_LIMIT; i++) { 310: /* 311: * Make sure the previous register write is posted before 312: * checking the fence status 313: */ 314: mb(); 315: 316: gmu_core_regread(device, GEN7_GMU_AHB_FENCE_STATUS, &status); 317: 318: /* 319: * If !writedropped0/1, then the write to fenced register 320: * was successful 321: */ 322: if (!(status & mask)) 323: break; 324: 325: /* Wait a small amount of time before trying again */ 326: udelay(GMU_CORE_WAKEUP_DELAY_US); 327: 328: /* Try to write the fenced register again */ 329: kgsl_regwrite(device, offset, value); 330: } 331: 332: if (i < GMU_CORE_SHORT_WAKEUP_RETRY_LIMIT) 333: return 0; 334: 335: if (i == GMU_CORE_LONG_WAKEUP_RETRY_LIMIT) { 336: ts2 = gpudev->read_alwayson(adreno_dev); 337: dev_err(device->dev, 338: "Timed out waiting %d usecs to write fenced register 0x%x, timestamps: %llx %llx\n", 339: i * GMU_CORE_WAKEUP_DELAY_US, offset, ts1, ts2); 340: return -ETIMEDOUT; 341: } 342: 343: dev_info(device->dev, 344: "Waited %d usecs to write fenced register 0x%x\n", 345: i * GMU_CORE_WAKEUP_DELAY_US, offset); 346: 347: return 0; 348: } 349: 350: static void gen7_calc_ubwc_config_legacy(struct adreno_device *adreno_dev) 351: { 352: struct adreno_ubwc_props *ubwc_props = &adreno_dev->ubwc_props; 353: 354: if (adreno_dev->ubwc_mode == KGSL_UBWC_4_0) 355: ubwc_props->rgb565_predicator = true; 356: } 357: 358: #if (KERNEL_VERSION(6, 17, 0) <= LINUX_VERSION_CODE) 359: static void gen7_calc_ubwc_config(struct adreno_device *adreno_dev) 360: { 361: struct qcom_ubwc_cfg_data *cfg = (struct qcom_ubwc_cfg_data *)adreno_dev->ubwc_cfg_data; 362: struct adreno_ubwc_props *ubwc_props = &adreno_dev->ubwc_props; 363: 364: if (!cfg) 365: return gen7_calc_ubwc_config_legacy(adreno_dev); 366: 367: ubwc_props->rgb565_predicator = cfg->ubwc_enc_version >= UBWC_4_0; 368: } 369: #else MATCH LINES: 605 593: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 594: const struct adreno_gen7_core *gen7_core = to_gen7_core(adreno_dev); 595: unsigned int value; 596: int i; 597: 598: if (!adreno_dev->hwcg_enabled) 599: on = false; 600: 601: if (adreno_is_gen7_13_0(adreno_dev)) 602: on = false; 603: 604: for (i = 0; i < gen7_core->ao_hwcg_count; i++) 605: gmu_core_regwrite(device, gen7_core->ao_hwcg[i].offset, 606: on ? gen7_core->ao_hwcg[i].val : 0); 607: 608: if (!adreno_is_gen7_9_x(adreno_dev)) 609: kgsl_regrmw(device, GEN7_UCHE_GBIF_GX_CONFIG, GENMASK(18, 16), 610: FIELD_PREP(GENMASK(18, 16), on ? 2 : 0)); 611: 612: if (!on) 613: kgsl_regrmw(device, GEN7_GBIF_CX_CONFIG, GENMASK(18, 16), 614: FIELD_PREP(GENMASK(18, 16), 0)); 615: 616: if (!gen7_core->hwcg) { 617: kgsl_regwrite(device, GEN7_RBBM_CLOCK_CNTL_GLOBAL, 1); 618: kgsl_regwrite(device, GEN7_RBBM_CGC_GLOBAL_LOAD_CMD, on ? 1 : 0); 619: 620: if (on) { 621: u32 retry = 3; 622: 623: kgsl_regwrite(device, GEN7_RBBM_CGC_P2S_TRIG_CMD, 1); 624: /* Poll for the TXDONE:BIT(0) status */ 625: do { 626: /* Wait for small amount of time for TXDONE status*/ 627: udelay(1); 628: kgsl_regread(device, GEN7_RBBM_CGC_P2S_STATUS, &value); 629: } while (!(value & BIT(0)) && --retry); MATCH LINES: 867 855: 856: void gen7_enable_ahb_timeout_detection(struct adreno_device *adreno_dev) 857: { 858: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 859: u32 val; 860: 861: if (!adreno_dev->ahb_timeout_val) 862: return; 863: 864: val = (ADRENO_AHB_CNTL_DEFAULT | FIELD_PREP(GENMASK(4, 0), 865: adreno_dev->ahb_timeout_val)); 866: kgsl_regwrite(device, GEN7_GPU_CX_MISC_CX_AHB_AON_CNTL, val); 867: kgsl_regwrite(device, GEN7_GPU_CX_MISC_CX_AHB_GMU_CNTL, val); 868: kgsl_regwrite(device, GEN7_GPU_CX_MISC_CX_AHB_CP_CNTL, val); 869: kgsl_regwrite(device, GEN7_GPU_CX_MISC_CX_AHB_VBIF_SMMU_CNTL, val); 870: kgsl_regwrite(device, GEN7_GPU_CX_MISC_CX_AHB_HOST_CNTL, val); 871: } 872: 873: int gen7_start(struct adreno_device *adreno_dev) 874: { 875: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 876: const struct adreno_gen7_core *gen7_core = to_gen7_core(adreno_dev); 877: struct adreno_ubwc_props *ubwc_props = &adreno_dev->ubwc_props; 878: u32 mal = adreno_dev->mal; 879: struct gen7_device *gen7_dev = container_of(adreno_dev, struct gen7_device, adreno_dev); 880: /* 881: * HBB values 13 to 16 can represented LSB of HBB from 0 to 3. 882: * Any HBB value beyond 16 needs programming MSB of HBB. 883: * By default highest bank bit is 14, Hence set default HBB LSB 884: * to "1" and MSB to "0". 885: */ 886: u32 hbb_lo = 1, hbb_hi = 0; 887: struct cpu_gpu_lock *pwrup_lock = adreno_dev->pwrup_reglist->hostptr; 888: u64 uche_trap_base = gen7_get_uche_trap_base(); 889: 890: /* Set up GX GBIF registers */ 891: kgsl_regwrite(device, GEN7_RBBM_GBIF_CLIENT_QOS_CNTL, MATCH LINES: 945, 950 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: 1026, 1027, 1029 1014: /* Disable ubwc merged UFC request feature */ 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: 1357, 1358, 1366 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 1383: #define CP_INT_CPHWFAULT 2 1384: #define CP_INT_REGISTERPROTECTION 4 1385: #define CP_INT_VSDPARITYERROR 6 1386: #define CP_INT_ILLEGALINSTRUCTION 7 1387: #define CP_INT_OPCODEERRORLPAC 8 1388: #define CP_INT_UCODEERRORLPAC 9 1389: #define CP_INT_CPHWFAULTLPAC 10 1390: #define CP_INT_REGISTERPROTECTIONLPAC 11 MATCH LINES: 1540, 1568 1528: 1529: static const char *const uche_client[] = { 1530: "BR_VFD", "BR_SP", "BR_VSC", "BR_VPC", 1531: "BR_HLSQ", "BR_PC", "BR_LRZ", "BR_TP", 1532: "BV_VFD", "BV_SP", "BV_VSC", "BV_VPC", 1533: "BV_HLSQ", "BV_PC", "BV_LRZ", "BV_TP" 1534: }; 1535: 1536: static const char *const uche_lpac_client[] = { 1537: "-", "SP_LPAC", "-", "-", "HLSQ_LPAC", "-", "-", "TP_LPAC" 1538: }; 1539: 1540: #define SCOOBYDOO 0x5c00bd00 1541: 1542: static const char *gen7_fault_block_uche(struct kgsl_device *device, 1543: char *str, int size, bool lpac) 1544: { 1545: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1546: unsigned int uche_client_id = adreno_dev->uche_client_pf; 1547: const char *uche_client_str, *fault_block; 1548: 1549: /* 1550: * Smmu driver takes a vote on CX gdsc before calling the kgsl 1551: * pagefault handler. If there is contention for device mutex in this 1552: * path and the dispatcher fault handler is holding this lock, trying 1553: * to turn off CX gdsc will fail during the reset. So to avoid blocking 1554: * here, try to lock device mutex and return if it fails. 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: 1592: fail: MATCH LINES: 1721, 1747, 1754, 1759 1709: ADRENO_IRQ_CALLBACK(NULL), /* 12 - CP_CCU_RESOLVE_TS */ 1710: ADRENO_IRQ_CALLBACK(NULL), /* 13 - UNUSED */ 1711: ADRENO_IRQ_CALLBACK(NULL), /* 14 - UNUSED */ 1712: ADRENO_IRQ_CALLBACK(adreno_cp_callback), /* 15 - CP_RB_INT */ 1713: ADRENO_IRQ_CALLBACK(NULL), /* 16 - CP_RB_INT_LPAC*/ 1714: ADRENO_IRQ_CALLBACK(NULL), /* 17 - CP_RB_DONE_TS */ 1715: ADRENO_IRQ_CALLBACK(NULL), /* 18 - UNUSED */ 1716: ADRENO_IRQ_CALLBACK(NULL), /* 19 - UNUSED */ 1717: ADRENO_IRQ_CALLBACK(gen7_cp_callback), /* 20 - CP_CACHE_FLUSH_TS */ 1718: ADRENO_IRQ_CALLBACK(NULL), /* 21 - CP_CACHE_TS_LPAC */ 1719: ADRENO_IRQ_CALLBACK(gen7_err_callback), /* 22 - RBBM_ATB_BUS_OVERFLOW */ 1720: ADRENO_IRQ_CALLBACK(adreno_hang_int_callback), /* 23 - MISHANGDETECT */ 1721: ADRENO_IRQ_CALLBACK(gen7_err_callback), /* 24 - UCHE_OOB_ACCESS */ 1722: ADRENO_IRQ_CALLBACK(gen7_err_callback), /* 25 - UCHE_TRAP_INTR */ 1723: ADRENO_IRQ_CALLBACK(NULL), /* 26 - DEBBUS_INTR_0 */ 1724: ADRENO_IRQ_CALLBACK(NULL), /* 27 - DEBBUS_INTR_1 */ 1725: ADRENO_IRQ_CALLBACK(gen7_err_callback), /* 28 - TSBWRITEERROR */ 1726: ADRENO_IRQ_CALLBACK(gen7_swfuse_violation_callback), /* 29 - SWFUSEVIOLATION */ 1727: ADRENO_IRQ_CALLBACK(NULL), /* 30 - ISDB_CPU_IRQ */ 1728: ADRENO_IRQ_CALLBACK(NULL), /* 31 - ISDB_UNDER_DEBUG */ 1729: }; 1730: 1731: /* 1732: * If the AHB fence is not in ALLOW mode when we receive an RBBM 1733: * interrupt, something went wrong. This means that we cannot proceed 1734: * since the IRQ status and clear registers are not accessible. 1735: * This is usually harmless because the GMU will abort power collapse 1736: * and change the fence back to ALLOW. Poll so that this can happen. 1737: */ 1738: static int gen7_irq_poll_fence(struct adreno_device *adreno_dev) 1739: { 1740: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1741: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 1742: u32 status, fence, fence_retries = 0; 1743: u64 a, b, c; 1744: 1745: a = gpudev->read_alwayson(adreno_dev); 1746: 1747: kgsl_regread(device, GEN7_GMU_AO_AHB_FENCE_CTRL, &fence); 1748: 1749: while (fence != 0) { 1750: b = gpudev->read_alwayson(adreno_dev); 1751: 1752: /* Wait for small time before trying again */ 1753: udelay(1); 1754: kgsl_regread(device, GEN7_GMU_AO_AHB_FENCE_CTRL, &fence); 1755: 1756: if (fence_retries == 100 && fence != 0) { 1757: c = gpudev->read_alwayson(adreno_dev); 1758: 1759: kgsl_regread(device, GEN7_GMU_RBBM_INT_UNMASKED_STATUS, 1760: &status); 1761: 1762: dev_crit_ratelimited(device->dev, 1763: "status=0x%x Unmasked status=0x%x Mask=0x%x timestamps: %llx %llx %llx\n", 1764: status & adreno_dev->irq_mask, status, 1765: adreno_dev->irq_mask, a, b, c); 1766: return -ETIMEDOUT; 1767: } 1768: 1769: fence_retries++; 1770: } 1771: 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 MATCH LINES: 1817 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; MATCH LINES: 1916, 1917, 1918, 1919 1904: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_WPTR, GEN7_CP_RB_WPTR), 1905: ADRENO_REG_DEFINE(ADRENO_REG_CP_ME_CNTL, GEN7_CP_SQE_CNTL), 1906: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BASE, GEN7_CP_IB1_BASE), 1907: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BASE_HI, GEN7_CP_IB1_BASE_HI), 1908: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BUFSZ, GEN7_CP_IB1_REM_SIZE), 1909: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BASE, GEN7_CP_IB2_BASE), 1910: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BASE_HI, GEN7_CP_IB2_BASE_HI), 1911: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BUFSZ, GEN7_CP_IB2_REM_SIZE), 1912: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_STATUS, GEN7_RBBM_STATUS), 1913: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_STATUS3, GEN7_RBBM_STATUS3), 1914: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_INT_0_MASK, GEN7_RBBM_INT_0_MASK), 1915: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_SW_RESET_CMD, GEN7_RBBM_SW_RESET_CMD), 1916: ADRENO_REG_DEFINE(ADRENO_REG_GMU_AO_HOST_INTERRUPT_MASK, 1917: GEN7_GMU_AO_HOST_INTERRUPT_MASK), 1918: ADRENO_REG_DEFINE(ADRENO_REG_GMU_GMU2HOST_INTR_MASK, 1919: GEN7_GMU_GMU2HOST_INTR_MASK), 1920: }; 1921: 1922: 1923: static u32 _get_pipeid(u32 groupid) 1924: { 1925: switch (groupid) { 1926: case KGSL_PERFCOUNTER_GROUP_BV_PC: 1927: fallthrough; 1928: case KGSL_PERFCOUNTER_GROUP_BV_VPC: 1929: fallthrough; 1930: case KGSL_PERFCOUNTER_GROUP_BV_TSE: 1931: fallthrough; 1932: case KGSL_PERFCOUNTER_GROUP_BV_RAS: 1933: fallthrough; 1934: case KGSL_PERFCOUNTER_GROUP_BV_LRZ: 1935: fallthrough; 1936: case KGSL_PERFCOUNTER_GROUP_BV_HLSQ: 1937: return PIPE_BV; 1938: case KGSL_PERFCOUNTER_GROUP_PC: 1939: fallthrough; 1940: case KGSL_PERFCOUNTER_GROUP_VPC: 1941: fallthrough; 1942: case KGSL_PERFCOUNTER_GROUP_TSE: 1943: fallthrough; MATCH LINES: 2173, 2174, 2177, 2180, 2194, 2195, 2198, 2201, 2238, 2242 2161: reg->countable); 2162: err: 2163: ADRENO_RELEASE_CP_SEMAPHORE(adreno_dev, irq_flags); 2164: return ret; 2165: } 2166: 2167: static u64 gen7_9_0_read_alwayson(struct adreno_device *adreno_dev) 2168: { 2169: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2170: u32 lo = 0, hi = 0, tmp = 0; 2171: 2172: /* Always use the GMU AO counter when doing a AHB read */ 2173: gmu_core_regread(device, GEN7_GMU_CX_AO_COUNTER_HI, &hi); 2174: gmu_core_regread(device, GEN7_GMU_CX_AO_COUNTER_LO, &lo); 2175: 2176: /* Check for overflow */ 2177: gmu_core_regread(device, GEN7_GMU_CX_AO_COUNTER_HI, &tmp); 2178: 2179: if (hi != tmp) { 2180: gmu_core_regread(device, GEN7_GMU_CX_AO_COUNTER_LO, 2181: &lo); 2182: hi = tmp; 2183: } 2184: 2185: return (((u64) hi) << 32) | lo; 2186: } 2187: 2188: static u64 gen7_read_alwayson(struct adreno_device *adreno_dev) 2189: { 2190: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2191: u32 lo = 0, hi = 0, tmp = 0; 2192: 2193: /* Always use the GMU AO counter when doing a AHB read */ 2194: gmu_core_regread(device, GEN7_GMU_ALWAYS_ON_COUNTER_H, &hi); 2195: gmu_core_regread(device, GEN7_GMU_ALWAYS_ON_COUNTER_L, &lo); 2196: 2197: /* Check for overflow */ 2198: gmu_core_regread(device, GEN7_GMU_ALWAYS_ON_COUNTER_H, &tmp); 2199: 2200: if (hi != tmp) { 2201: gmu_core_regread(device, GEN7_GMU_ALWAYS_ON_COUNTER_L, 2202: &lo); 2203: hi = tmp; 2204: } 2205: 2206: return (((u64) hi) << 32) | lo; 2207: } 2208: 2209: static int gen7_9_0_lpac_store(struct adreno_device *adreno_dev, bool enable) 2210: { 2211: if (!ADRENO_FEATURE(adreno_dev, ADRENO_LPAC)) 2212: return -EINVAL; 2213: 2214: if (!(adreno_dev->feature_fuse & BIT(GEN7_LPAC_SW_FUSE)) || 2215: (adreno_dev->lpac_enabled == enable)) 2216: return 0; 2217: 2218: /* Power down the GPU before changing the lpac setting */ 2219: return adreno_power_cycle_bool(adreno_dev, &adreno_dev->lpac_enabled, 2220: enable); 2221: } 2222: 2223: static int gen7_lpac_store(struct adreno_device *adreno_dev, bool enable) 2224: { 2225: if (!ADRENO_FEATURE(adreno_dev, ADRENO_LPAC)) 2226: return -EINVAL; 2227: 2228: if (adreno_dev->lpac_enabled == enable) 2229: return 0; 2230: 2231: /* Power down the GPU before changing the lpac setting */ 2232: return adreno_power_cycle_bool(adreno_dev, &adreno_dev->lpac_enabled, 2233: enable); 2234: } 2235: 2236: static void gen7_remove(struct adreno_device *adreno_dev) 2237: { 2238: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 2239: 2240: /* Make sure timer is initialized, otherwise WARN_ON is generated */ 2241: if (adreno_preemption_feature_set(adreno_dev) && 2242: (test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags))) 2243: kgsl_delete_timer(&adreno_dev->preempt.timer); 2244: } 2245: 2246: static void gen7_read_bus_stats(struct kgsl_device *device, 2247: struct kgsl_power_stats *stats, 2248: struct adreno_busy_data *busy) 2249: { 2250: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 2251: u64 ram_cycles, starved_ram; 2252: 2253: ram_cycles = counter_delta(device, adreno_dev->ram_cycles_lo, 2254: &busy->bif_ram_cycles); 2255: 2256: starved_ram = counter_delta(device, adreno_dev->starved_ram_lo, 2257: &busy->bif_starved_ram); 2258: 2259: ram_cycles += counter_delta(device, 2260: adreno_dev->ram_cycles_lo_ch1_read, 2261: &busy->bif_ram_cycles_read_ch1); 2262: 2263: ram_cycles += counter_delta(device, 2264: adreno_dev->ram_cycles_lo_ch0_write, 2265: &busy->bif_ram_cycles_write_ch0); 2266: MATCH LINES: 2286, 2297, 2300, 2303, 2311, 2329 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: 2422 2410: struct adreno_context *drawctxt_lpac; 2411: u32 status = 0, lpac_rptr = 0, lpac_wptr = 0, lpac_ib1sz = 0, lpac_ib2sz = 0; 2412: u64 lpac_ib1base = 0, lpac_ib2base = 0; 2413: bool gx_on = adreno_gx_is_on(adreno_dev); 2414: 2415: drawctxt_lpac = ADRENO_CONTEXT(drawobj_lpac->context); 2416: drawobj_lpac->context->last_faulted_cmd_ts = drawobj_lpac->timestamp; 2417: drawobj_lpac->context->total_fault_count++; 2418: 2419: pr_context(device, drawobj_lpac->context, 2420: "LPAC ctx %d ctx_type %s ts %d dispatch_queue=%d\n", 2421: drawobj_lpac->context->id, kgsl_context_type(drawctxt_lpac->type), 2422: drawobj_lpac->timestamp, drawobj_lpac->context->gmu_dispatch_queue); 2423: 2424: pr_context(device, drawobj_lpac->context, "lpac cmdline: %s\n", 2425: drawctxt_lpac->base.proc_priv->cmdline); 2426: if (!gx_on) 2427: goto done; 2428: 2429: kgsl_regread(device, GEN7_RBBM_STATUS, &status); 2430: kgsl_regread(device, GEN7_CP_LPAC_RB_RPTR, &lpac_rptr); 2431: kgsl_regread(device, GEN7_CP_LPAC_RB_WPTR, &lpac_wptr); 2432: gen7_periph_regread64(device, GEN7_CP_PERIPH_IB1_BASE_LO(adreno_dev), 2433: GEN7_CP_PERIPH_IB1_BASE_HI(adreno_dev), &lpac_ib1base, PIPE_LPAC); 2434: gen7_periph_regread(device, GEN7_CP_PERIPH_IB1_OFFSET(adreno_dev), &lpac_ib1sz, PIPE_LPAC); 2435: gen7_periph_regread64(device, GEN7_CP_PERIPH_IB2_BASE_LO(adreno_dev), 2436: GEN7_CP_PERIPH_IB2_BASE_HI(adreno_dev), &lpac_ib2base, PIPE_LPAC); 2437: gen7_periph_regread(device, GEN7_CP_PERIPH_IB2_OFFSET(adreno_dev), &lpac_ib2sz, PIPE_LPAC); 2438: 2439: pr_context(device, drawobj_lpac->context, 2440: "LPAC: status %8.8X rb %4.4x/%4.4x ib1 %16.16llX/%4.4x ib2 %16.16llX/%4.4x\n", 2441: status, lpac_rptr, lpac_wptr, lpac_ib1base, 2442: lpac_ib1sz, lpac_ib2base, lpac_ib2sz); 2443: 2444: done: 2445: trace_adreno_gpu_fault(drawobj_lpac->context->id, drawobj_lpac->timestamp, status, 2446: lpac_rptr, lpac_wptr, lpac_ib1base, lpac_ib1sz, lpac_ib2base, lpac_ib2sz, MATCH LINES: 2473 2461: if (drawobj) { 2462: drawctxt = ADRENO_CONTEXT(drawobj->context); 2463: drawobj->context->last_faulted_cmd_ts = drawobj->timestamp; 2464: drawobj->context->total_fault_count++; 2465: ctxt_id = drawobj->context->id; 2466: ts = drawobj->timestamp; 2467: rb_id = adreno_get_level(drawobj->context); 2468: 2469: pr_context(device, drawobj->context, 2470: "ctx %u ctx_type %s ts %u policy %lX dispatch_queue=%d\n", 2471: drawobj->context->id, kgsl_context_type(drawctxt->type), 2472: drawobj->timestamp, CMDOBJ(drawobj)->fault_recovery, 2473: drawobj->context->gmu_dispatch_queue); 2474: 2475: pr_context(device, drawobj->context, "cmdline: %s\n", 2476: drawctxt->base.proc_priv->cmdline); 2477: } 2478: 2479: if (!gx_on) 2480: goto done; 2481: 2482: kgsl_regread(device, GEN7_RBBM_STATUS, &status); 2483: kgsl_regread(device, GEN7_CP_RB_RPTR, &rptr); 2484: kgsl_regread(device, GEN7_CP_RB_WPTR, &wptr); 2485: gen7_periph_regread64(device, GEN7_CP_PERIPH_IB1_BASE_LO(adreno_dev), 2486: GEN7_CP_PERIPH_IB1_BASE_HI(adreno_dev), &ib1base, PIPE_BR); 2487: gen7_periph_regread(device, GEN7_CP_PERIPH_IB1_OFFSET(adreno_dev), &ib1sz, PIPE_BR); 2488: gen7_periph_regread64(device, GEN7_CP_PERIPH_IB2_BASE_LO(adreno_dev), 2489: GEN7_CP_PERIPH_IB2_BASE_HI(adreno_dev), &ib2base, PIPE_BR); 2490: gen7_periph_regread(device, GEN7_CP_PERIPH_IB2_OFFSET(adreno_dev), &ib2sz, PIPE_BR); 2491: 2492: dev_err(device->dev, 2493: "status %8.8X rb %4.4x/%4.4x ib1 %16.16llX/%4.4x ib2 %16.16llX/%4.4x\n", 2494: status, rptr, wptr, ib1base, ib1sz, ib2base, ib2sz); 2495: done: 2496: trace_adreno_gpu_fault(ctxt_id, ts, status, 2497: rptr, wptr, ib1base, ib1sz, ib2base, ib2sz, rb_id); MATCH LINES: 2514, 2527, 2528, 2546, 2558, 2559, 2563, 2566, 2567, 2573, 2576, 2580, 2581, 2590, 2591 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: 14 --- MATCH LINES: 18, 27, 28, 32, 41 6: 7: #ifndef _ADRENO_GEN7_H_ 8: #define _ADRENO_GEN7_H_ 9: 10: #include 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; 44: /** @aperture: The last value that the host aperture register was programmed to */ 45: u32 aperture; 46: /** @ext_pwrup_list_len: External pwrup reglist length */ 47: u16 ext_pwrup_list_len; 48: }; 49: 50: /** 51: * struct gen7_pwrup_extlist - container for powerup external reglist 52: */ 53: struct gen7_pwrup_extlist { 54: /** offset: Dword offset of the register to write */ 55: u32 offset; 56: /** pipelines: pipelines to write */ 57: u32 pipelines; 58: }; 59: 60: /** 61: * struct gen7_protected_regs - container for a protect register span 62: */ 63: struct gen7_protected_regs { 64: /** @reg: Physical protected mode register to write to */ 65: u32 reg; MATCH LINES: 86, 87, 121, 122, 147, 148, 151 74: * @noaccess: 1 if the register should not be accessible from 75: * userspace, 0 if it can be read (but not written) 76: */ 77: u32 noaccess; 78: }; 79: 80: /** 81: * struct adreno_gen7_core - gen7 specific GPU core definitions 82: */ 83: struct adreno_gen7_core { 84: /** @base: Container for the generic GPU definitions */ 85: struct adreno_gpu_core base; 86: /** @gmu_fw_version: Minimum firmware version required to support this core */ 87: u32 gmu_fw_version; 88: /** @sqefw_name: Name of the SQE microcode file */ 89: const char *sqefw_name; 90: /** @aqefw_name: Name of the AQE microcode file */ 91: const char *aqefw_name; 92: /** @gmufw_name: Name of the GMU firmware file */ 93: const char *gmufw_name; 94: /** @gmufw_name: Name of the backup GMU firmware file */ 95: const char *gmufw_bak_name; 96: /** 97: * @zap_name: Specifies the name of the CPZ zap file. This field is deprecated. 98: * Use the 'firmware-name' device tree property instead. 99: */ 100: const char *zap_name; 101: /** @hwcg: List of registers and values to write for HWCG */ 102: const struct kgsl_regmap_list *hwcg; 103: /** @hwcg_count: Number of registers in @hwcg */ 104: u32 hwcg_count; 105: /** @ao_hwcg: List of registers and values to write for HWCG in AO block */ 106: const struct kgsl_regmap_list *ao_hwcg; 107: /** @ao_hwcg_count: Number of registers in @ao_hwcg */ 108: u32 ao_hwcg_count; 109: /** @gbif: List of registers and values to write for GBIF */ 110: const struct kgsl_regmap_list *gbif; 111: /** @gbif_count: Number of registers in @gbif */ 112: u32 gbif_count; 113: /** @hang_detect_cycles: Hang detect counter timeout value */ 114: u32 hang_detect_cycles; 115: /** @protected_regs: Array of protected registers for the target */ 116: const struct gen7_protected_regs *protected_regs; 117: /** @ctxt_record_size: Size of the preemption record in bytes */ 118: u64 ctxt_record_size; 119: /** @gen7_snapshot_block_list: Device-specific blocks dumped in the snapshot */ 120: const struct gen7_snapshot_block_list *gen7_snapshot_block_list; 121: /** @gmu_hub_clk_freq: Gmu hub interface clock frequency */ 122: u64 gmu_hub_clk_freq; 123: /** 124: * @bcl_data: bit 0 contains response type for bcl alarms and bits 1:21 controls sid vals 125: * to configure throttle levels for bcl alarm levels 0-2. If sid vals are not set, 126: * gmu fw sets default throttle levels. 127: */ 128: u32 bcl_data; 129: /** @preempt_level: Preemption level valid ranges [0 to 2] */ 130: u32 preempt_level; 131: /** @qos_value: GPU qos value to set for each RB. */ 132: const u32 *qos_value; 133: /** 134: * @acv_perfmode_ddr_freq: Vote perfmode when DDR frequency >= acv_perfmode_ddr_freq. 135: * If not specified, vote perfmode for highest DDR level only. 136: */ 137: u32 acv_perfmode_ddr_freq; 138: /** @acv_perfmode_vote: ACV vote for GPU perfmode */ 139: u32 acv_perfmode_vote; 140: /** @rt_bus_hint: IB level hint for real time clients i.e. RB-0 */ 141: const u32 rt_bus_hint; 142: /** @fast_bus_hint: Whether or not to increase IB vote on high ddr stall */ 143: bool fast_bus_hint; 144: /** @noc_timeout_us: GPU config NOC port timeout in usec */ 145: u32 noc_timeout_us; 146: /** 147: * @gmu_chipid: If non-zero, the exact value programmed into 148: * GEN7_GMU_GENERAL_10 to tell the GMU firmware which chip it is 149: * running on. 150: */ 151: u32 gmu_chipid; 152: }; 153: 154: /** 155: * struct gen7_cp_preemption_record - CP context record for 156: * preemption. 157: * @magic: (00) Value at this offset must be equal to 158: * GEN7_CP_CTXRECORD_MAGIC_REF. 159: * @info: (04) Type of record. Written non-zero (usually) by CP. 160: * we must set to zero for all ringbuffers. 161: * @errno: (08) Error code. Initialize this to GEN7_CP_CTXRECORD_ERROR_NONE. 162: * CP will update to another value if a preemption error occurs. 163: * @data: (12) DATA field in YIELD and SET_MARKER packets. 164: * Written by CP when switching out. Not used on switch-in. Initialized to 0. 165: * @cntl: (16) RB_CNTL, saved and restored by CP. We must initialize this. 166: * @rptr: (20) RB_RPTR, saved and restored by CP. We must initialize this. 167: * @wptr: (24) RB_WPTR, saved and restored by CP. We must initialize this. 168: * @_pad28: (28) Reserved/padding. 169: * @rptr_addr: (32) RB_RPTR_ADDR_LO|HI saved and restored. We must initialize. 170: * rbase: (40) RB_BASE_LO|HI saved and restored. 171: * counter: (48) Pointer to preemption counter. 172: * @bv_rptr_addr: (56) BV_RB_RPTR_ADDR_LO|HI save and restored. We must initialize. 173: */ 174: struct gen7_cp_preemption_record { 175: u32 magic; MATCH LINES: 463, 468 451: struct adreno_ringbuffer *rb, struct adreno_context *drawctxt, 452: u32 flags, u32 *in, u32 dwords, u32 timestamp, 453: struct adreno_submit_time *time); 454: 455: /** 456: * gen7_cp_init_cmds - Create the CP_INIT commands 457: * @adreno_dev: An Adreno GPU handle 458: * @cmd: Buffer to write the CP_INIT commands into 459: */ 460: void gen7_cp_init_cmds(struct adreno_device *adreno_dev, u32 *cmds); 461: 462: /** 463: * gen7_gmu_hfi_probe - Probe Gen7 HFI specific data 464: * @adreno_dev: An Adreno GPU handle 465: * 466: * Return: 0 on success or negative on failure 467: */ 468: int gen7_gmu_hfi_probe(struct adreno_device *adreno_dev); 469: 470: static inline const struct gen7_gpudev * 471: to_gen7_gpudev(const struct adreno_gpudev *gpudev) 472: { 473: return container_of(gpudev, struct gen7_gpudev, base); 474: } 475: 476: /** 477: * gen7_reset_preempt_records - Reset the preemption buffers 478: * @adreno_dev: Handle to the adreno device 479: * 480: * Reset the preemption records at the time of hard reset 481: */ 482: void gen7_reset_preempt_records(struct adreno_device *adreno_dev); 483: 484: /** 485: * gen7_enable_ahb_timeout_detection - Program AHB control registers 486: * @adreno_dev: An Adreno GPU handle 487: * 488: * Program AHB control registers to enable AHB timeout detection. 489: */ 490: void gen7_enable_ahb_timeout_detection(struct adreno_device *adreno_dev); 491: 492: /** --- FILE: \adreno_gen7_0_0_snapshot.h | HITS: 3 --- MATCH LINES: 35 23: DEBUGBUS_VPC_BR, 24: DEBUGBUS_VPC_BV, 25: DEBUGBUS_TSE_BR, 26: DEBUGBUS_TSE_BV, 27: DEBUGBUS_RAS_BR, 28: DEBUGBUS_RAS_BV, 29: DEBUGBUS_VSC, 30: DEBUGBUS_COM_0, 31: DEBUGBUS_LRZ_BR, 32: DEBUGBUS_LRZ_BV, 33: DEBUGBUS_UFC_0, 34: DEBUGBUS_UFC_1, 35: DEBUGBUS_GMU_GX, 36: DEBUGBUS_DBGC, 37: DEBUGBUS_GPC_BR, 38: DEBUGBUS_GPC_BV, 39: DEBUGBUS_LARC, 40: DEBUGBUS_HLSQ_SPTP, 41: DEBUGBUS_RB_0, 42: DEBUGBUS_RB_1, 43: DEBUGBUS_RB_2, 44: DEBUGBUS_RB_3, 45: DEBUGBUS_UCHE_WRAPPER, 46: DEBUGBUS_CCU_0, 47: DEBUGBUS_CCU_1, 48: DEBUGBUS_CCU_2, 49: DEBUGBUS_CCU_3, 50: DEBUGBUS_VFD_BR_0, 51: DEBUGBUS_VFD_BR_1, 52: DEBUGBUS_VFD_BR_2, 53: DEBUGBUS_VFD_BR_3, 54: DEBUGBUS_VFD_BR_4, 55: DEBUGBUS_VFD_BR_5, 56: DEBUGBUS_VFD_BR_6, 57: DEBUGBUS_VFD_BR_7, 58: DEBUGBUS_VFD_BV_0, 59: DEBUGBUS_VFD_BV_1, MATCH LINES: 210, 241 198: 0x00928, 0x0093e, 0x00942, 0x0094d, 0x00980, 0x00984, 0x0098d, 0x0098f, 199: 0x009b0, 0x009b4, 0x009c2, 0x009c9, 0x009ce, 0x009d7, 0x009e0, 0x009e7, 200: 0x00a00, 0x00a00, 0x00a02, 0x00a03, 0x00a10, 0x00a4f, 0x00a61, 0x00a9f, 201: 0x00ad0, 0x00adb, 0x00b00, 0x00b31, 0x00b35, 0x00b3c, 0x00b40, 0x00b40, 202: 0x00c00, 0x00c00, 0x00c02, 0x00c04, 0x00c06, 0x00c06, 0x00c10, 0x00cd9, 203: 0x00ce0, 0x00d0c, 0x00df0, 0x00df4, 0x00e01, 0x00e02, 0x00e07, 0x00e0e, 204: 0x00e10, 0x00e13, 0x00e17, 0x00e19, 0x00e1b, 0x00e2b, 0x00e30, 0x00e32, 205: 0x00e38, 0x00e3c, 206: UINT_MAX, UINT_MAX, 207: }; 208: static_assert(IS_ALIGNED(sizeof(gen7_0_0_gpu_registers), 8)); 209: 210: static const u32 gen7_0_0_gmu_registers[] = { 211: 0x10001, 0x10001, 0x10003, 0x10003, 0x10401, 0x10401, 0x10403, 0x10403, 212: 0x10801, 0x10801, 0x10803, 0x10803, 0x10c01, 0x10c01, 0x10c03, 0x10c03, 213: 0x11001, 0x11001, 0x11003, 0x11003, 0x11401, 0x11401, 0x11403, 0x11403, 214: 0x11801, 0x11801, 0x11803, 0x11803, 0x11c01, 0x11c01, 0x11c03, 0x11c03, 215: 0x1f400, 0x1f40d, 0x1f40f, 0x1f411, 0x1f500, 0x1f500, 0x1f507, 0x1f507, 216: 0x1f509, 0x1f50b, 0x1f800, 0x1f804, 0x1f807, 0x1f808, 0x1f80b, 0x1f80c, 217: 0x1f80f, 0x1f80f, 0x1f811, 0x1f811, 0x1f813, 0x1f817, 0x1f819, 0x1f81c, 218: 0x1f824, 0x1f82a, 0x1f82d, 0x1f830, 0x1f840, 0x1f853, 0x1f860, 0x1f860, 219: 0x1f870, 0x1f879, 0x1f87f, 0x1f87f, 0x1f888, 0x1f889, 0x1f8a0, 0x1f8a2, 220: 0x1f8a4, 0x1f8af, 0x1f8c0, 0x1f8c1, 0x1f8c3, 0x1f8c4, 0x1f8d0, 0x1f8d0, 221: 0x1f8ec, 0x1f8ec, 0x1f8f0, 0x1f8f1, 0x1f910, 0x1f914, 0x1f920, 0x1f921, 222: 0x1f924, 0x1f925, 0x1f928, 0x1f929, 0x1f92c, 0x1f92d, 0x1f940, 0x1f940, 223: 0x1f942, 0x1f944, 0x1f948, 0x1f94a, 0x1f94f, 0x1f951, 0x1f958, 0x1f95a, 224: 0x1f95d, 0x1f95d, 0x1f962, 0x1f962, 0x1f964, 0x1f96b, 0x1f970, 0x1f979, 225: 0x1f980, 0x1f981, 0x1f984, 0x1f986, 0x1f992, 0x1f993, 0x1f996, 0x1f99e, 226: 0x1f9c0, 0x1f9c0, 0x1f9c5, 0x1f9d4, 0x1f9f0, 0x1f9f1, 0x1f9f8, 0x1f9fa, 227: 0x1fa00, 0x1fa03, 0x20000, 0x20005, 0x20008, 0x2000c, 0x20010, 0x20012, 228: 0x20018, 0x20018, 0x20020, 0x20023, 0x20030, 0x20031, 0x23801, 0x23801, 229: 0x23803, 0x23803, 0x23805, 0x23805, 0x23807, 0x23807, 0x23809, 0x23809, 230: 0x2380b, 0x2380b, 0x2380d, 0x2380d, 0x2380f, 0x2380f, 0x23811, 0x23811, 231: 0x23813, 0x23813, 0x23815, 0x23815, 0x23817, 0x23817, 0x23819, 0x23819, 232: 0x2381b, 0x2381b, 0x2381d, 0x2381d, 0x2381f, 0x23820, 0x23822, 0x23822, 233: 0x23824, 0x23824, 0x23826, 0x23826, 0x23828, 0x23828, 0x2382a, 0x2382a, 234: 0x2382c, 0x2382c, 0x2382e, 0x2382e, 0x23830, 0x23830, 0x23832, 0x23832, 235: 0x23834, 0x23834, 0x23836, 0x23836, 0x23838, 0x23838, 0x2383a, 0x2383a, 236: 0x2383c, 0x2383c, 0x2383e, 0x2383e, 0x23840, 0x23847, 0x23b00, 0x23b01, 237: 0x23b03, 0x23b03, 0x23b05, 0x23b0e, 0x23b10, 0x23b13, 0x23b15, 0x23b16, 238: 0x23b20, 0x23b20, 0x23b28, 0x23b28, 0x23b30, 0x23b30, 239: UINT_MAX, UINT_MAX, 240: }; 241: static_assert(IS_ALIGNED(sizeof(gen7_0_0_gmu_registers), 8)); 242: 243: static const u32 gen7_0_0_gmugx_registers[] = { 244: 0x1a400, 0x1a41f, 0x1a440, 0x1a45f, 0x1a480, 0x1a49f, 0x1a4c0, 0x1a4df, 245: 0x1a500, 0x1a51f, 0x1a540, 0x1a55f, 0x1a580, 0x1a59f, 0x1a5c0, 0x1a5df, 246: 0x1a780, 0x1a781, 0x1a783, 0x1a785, 0x1a787, 0x1a789, 0x1a78b, 0x1a78d, 247: 0x1a78f, 0x1a791, 0x1a793, 0x1a795, 0x1a797, 0x1a799, 0x1a79b, 0x1a79b, 248: 0x1a7c0, 0x1a7c1, 0x1a7c4, 0x1a7c5, 0x1a7c8, 0x1a7c9, 0x1a7cc, 0x1a7cd, 249: 0x1a7d0, 0x1a7d1, 0x1a7d4, 0x1a7d5, 0x1a7d8, 0x1a7d9, 0x1a7fc, 0x1a7fd, 250: 0x1a800, 0x1a802, 0x1a804, 0x1a804, 0x1a816, 0x1a816, 0x1a81e, 0x1a81e, 251: 0x1a826, 0x1a826, 0x1a82e, 0x1a82e, 0x1a836, 0x1a836, 0x1a83e, 0x1a83e, 252: 0x1a846, 0x1a846, 0x1a860, 0x1a862, 0x1a864, 0x1a867, 0x1a870, 0x1a870, 253: 0x1a883, 0x1a884, 0x1a8c0, 0x1a8c2, 0x1a8c4, 0x1a8c7, 0x1a8d0, 0x1a8d3, 254: 0x1a900, 0x1a92b, 0x1a940, 0x1a940, 255: UINT_MAX, UINT_MAX, 256: }; 257: static_assert(IS_ALIGNED(sizeof(gen7_0_0_gmugx_registers), 8)); 258: 259: static const u32 gen7_0_0_noncontext_pipe_br_registers[] = { 260: 0x00887, 0x0088c, 0x08600, 0x08600, 0x08602, 0x08602, 0x08610, 0x0861b, 261: 0x08620, 0x08620, 0x08630, 0x08630, 0x08637, 0x08639, 0x08640, 0x08640, 262: 0x09600, 0x09600, 0x09602, 0x09603, 0x0960a, 0x09616, 0x09624, 0x0963a, 263: 0x09640, 0x09640, 0x09e00, 0x09e00, 0x09e02, 0x09e07, 0x09e0a, 0x09e16, 264: 0x09e19, 0x09e19, 0x09e1c, 0x09e1c, 0x09e20, 0x09e25, 0x09e30, 0x09e31, 265: 0x09e40, 0x09e51, 0x09e64, 0x09e64, 0x09e70, 0x09e72, 0x09e78, 0x09e79, --- FILE: \adreno_gen7_11_0_snapshot.h | HITS: 6 --- MATCH LINES: 34 22: DEBUGBUS_VPC_BR, 23: DEBUGBUS_VPC_BV, 24: DEBUGBUS_TSE_BR, 25: DEBUGBUS_TSE_BV, 26: DEBUGBUS_RAS_BR, 27: DEBUGBUS_RAS_BV, 28: DEBUGBUS_VSC, 29: DEBUGBUS_COM_0, 30: DEBUGBUS_LRZ_BR, 31: DEBUGBUS_LRZ_BV, 32: DEBUGBUS_UFC_0, 33: DEBUGBUS_UFC_1, 34: DEBUGBUS_GMU_GX, 35: DEBUGBUS_DBGC, 36: DEBUGBUS_GPC_BR, 37: DEBUGBUS_GPC_BV, 38: DEBUGBUS_LARC, 39: DEBUGBUS_HLSQ_SPTP, 40: DEBUGBUS_RB_0, 41: DEBUGBUS_RB_1, 42: DEBUGBUS_RB_2, 43: DEBUGBUS_UCHE_WRAPPER, 44: DEBUGBUS_CCU_0, 45: DEBUGBUS_CCU_1, 46: DEBUGBUS_CCU_2, 47: DEBUGBUS_VFD_BR_0, 48: DEBUGBUS_VFD_BR_1, 49: DEBUGBUS_VFD_BR_2, 50: DEBUGBUS_VFD_BV_0, 51: DEBUGBUS_USP_0, 52: DEBUGBUS_USP_1, 53: DEBUGBUS_USP_2, 54: DEBUGBUS_TP_0, 55: DEBUGBUS_TP_1, 56: DEBUGBUS_TP_2, 57: DEBUGBUS_TP_3, 58: DEBUGBUS_TP_4, MATCH LINES: 74 62: DEBUGBUS_USPTP_2, 63: DEBUGBUS_USPTP_3, 64: DEBUGBUS_USPTP_4, 65: DEBUGBUS_USPTP_5, 66: }; 67: 68: static const u32 gen7_11_0_gbif_debugbus_blocks[] = { 69: DEBUGBUS_GBIF_GX, 70: }; 71: 72: static const u32 gen7_11_0_cx_debugbus_blocks[] = { 73: DEBUGBUS_CX, 74: DEBUGBUS_GMU_CX, 75: DEBUGBUS_GBIF_CX, 76: }; 77: 78: static struct gen7_shader_block gen7_11_0_shader_blocks[] = { 79: { TP0_TMO_DATA, 0x0200, 3, 2, PIPE_BR, USPTP }, 80: { TP0_SMO_DATA, 0x0080, 3, 2, PIPE_BR, USPTP }, 81: { TP0_MIPMAP_BASE_DATA, 0x03C0, 3, 2, PIPE_BR, USPTP }, 82: { SP_INST_DATA, 0x0800, 3, 2, PIPE_BR, USPTP }, 83: { SP_INST_DATA_1, 0x0800, 3, 2, PIPE_BR, USPTP }, 84: { SP_LB_0_DATA, 0x0800, 3, 2, PIPE_BR, USPTP }, 85: { SP_LB_1_DATA, 0x0800, 3, 2, PIPE_BR, USPTP }, 86: { SP_LB_2_DATA, 0x0800, 3, 2, PIPE_BR, USPTP }, 87: { SP_LB_3_DATA, 0x0800, 3, 2, PIPE_BR, USPTP }, 88: { SP_LB_4_DATA, 0x0800, 3, 2, PIPE_BR, USPTP }, 89: { SP_LB_5_DATA, 0x0800, 3, 2, PIPE_BR, USPTP }, 90: { SP_LB_6_DATA, 0x0800, 3, 2, PIPE_BR, USPTP }, 91: { SP_LB_7_DATA, 0x0800, 3, 2, PIPE_BR, USPTP }, 92: { SP_CB_RAM, 0x0390, 3, 2, PIPE_BR, USPTP }, 93: { SP_LB_13_DATA, 0x0800, 3, 2, PIPE_BR, USPTP }, 94: { SP_LB_14_DATA, 0x0800, 3, 2, PIPE_BR, USPTP }, 95: { SP_INST_TAG, 0x00C0, 3, 2, PIPE_BR, USPTP }, 96: { SP_INST_DATA_2, 0x0800, 3, 2, PIPE_BR, USPTP }, 97: { SP_TMO_TAG, 0x0080, 3, 2, PIPE_BR, USPTP }, 98: { SP_SMO_TAG, 0x0080, 3, 2, PIPE_BR, USPTP }, MATCH LINES: 220, 250, 252, 259 208: 0x0ed6f, 0x0ed6f, 0x0ed80, 0x0ed81, 0x0ed85, 0x0ed85, 0x0ed87, 0x0ed87, 209: 0x0ed8a, 0x0ed8a, 0x0ed92, 0x0ed92, 0x0eda6, 0x0eda8, 0x0edab, 0x0edad, 210: 0x0edaf, 0x0edaf, 211: UINT_MAX, UINT_MAX, 212: }; 213: static_assert(IS_ALIGNED(sizeof(gen7_11_0_gpu_registers), 8)); 214: 215: /* 216: * Block : ['GMUAO', 'GMUCX', 'GMUCX_RAM'] 217: * Pipeline: PIPE_NONE 218: * pairs : 126 (Regs:334) 219: */ 220: static const u32 gen7_11_0_gmu_registers[] = { 221: 0x1f400, 0x1f40b, 0x1f40f, 0x1f411, 0x1f500, 0x1f500, 0x1f507, 0x1f507, 222: 0x1f509, 0x1f50b, 0x1f705, 0x1f705, 0x1f710, 0x1f711, 0x1f713, 0x1f716, 223: 0x1f720, 0x1f724, 0x1f729, 0x1f729, 0x1f730, 0x1f747, 0x1f800, 0x1f804, 224: 0x1f807, 0x1f808, 0x1f80b, 0x1f80c, 0x1f80f, 0x1f80f, 0x1f811, 0x1f811, 225: 0x1f813, 0x1f817, 0x1f819, 0x1f81c, 0x1f824, 0x1f82a, 0x1f82d, 0x1f830, 226: 0x1f840, 0x1f853, 0x1f860, 0x1f860, 0x1f862, 0x1f864, 0x1f868, 0x1f868, 227: 0x1f870, 0x1f879, 0x1f87f, 0x1f87f, 0x1f888, 0x1f889, 0x1f890, 0x1f892, 228: 0x1f894, 0x1f896, 0x1f8a0, 0x1f8a2, 0x1f8a4, 0x1f8af, 0x1f8b8, 0x1f8b9, 229: 0x1f8c0, 0x1f8c1, 0x1f8c3, 0x1f8c4, 0x1f8d0, 0x1f8d0, 0x1f8ec, 0x1f8ec, 230: 0x1f8f0, 0x1f8f1, 0x1f910, 0x1f913, 0x1f920, 0x1f921, 0x1f924, 0x1f925, 231: 0x1f928, 0x1f929, 0x1f92c, 0x1f92d, 0x1f940, 0x1f940, 0x1f942, 0x1f944, 232: 0x1f948, 0x1f94a, 0x1f951, 0x1f951, 0x1f95d, 0x1f95d, 0x1f962, 0x1f962, 233: 0x1f973, 0x1f973, 0x1f980, 0x1f981, 0x1f984, 0x1f986, 0x1f992, 0x1f993, 234: 0x1f996, 0x1f99e, 0x1f9c0, 0x1f9c0, 0x1f9c5, 0x1f9d4, 0x1f9f0, 0x1f9f1, 235: 0x1f9f8, 0x1f9fa, 0x1f9fc, 0x1f9fc, 0x1fa00, 0x1fa03, 0x20000, 0x2000b, 236: 0x20010, 0x20012, 0x20018, 0x20018, 0x2001a, 0x2001a, 0x20020, 0x20021, 237: 0x20024, 0x20024, 0x20030, 0x20031, 0x20034, 0x20036, 0x23801, 0x23801, 238: 0x23803, 0x23803, 0x23805, 0x23805, 0x23807, 0x23807, 0x23809, 0x23809, 239: 0x2380b, 0x2380b, 0x2380d, 0x2380d, 0x2380f, 0x2380f, 0x23811, 0x23811, 240: 0x23813, 0x23813, 0x23815, 0x23815, 0x23817, 0x23817, 0x23819, 0x23819, 241: 0x2381b, 0x2381b, 0x2381d, 0x2381d, 0x2381f, 0x23820, 0x23822, 0x23822, 242: 0x23824, 0x23824, 0x23826, 0x23826, 0x23828, 0x23828, 0x2382a, 0x2382a, 243: 0x2382c, 0x2382c, 0x2382e, 0x2382e, 0x23830, 0x23830, 0x23832, 0x23832, 244: 0x23834, 0x23834, 0x23836, 0x23836, 0x23838, 0x23838, 0x2383a, 0x2383a, 245: 0x2383c, 0x2383c, 0x2383e, 0x2383e, 0x23840, 0x23847, 0x23b00, 0x23b01, 246: 0x23b03, 0x23b03, 0x23b05, 0x23b0e, 0x23b10, 0x23b13, 0x23b15, 0x23b16, 247: 0x23b28, 0x23b28, 0x23b30, 0x23b30, 248: UINT_MAX, UINT_MAX, 249: }; 250: static_assert(IS_ALIGNED(sizeof(gen7_11_0_gmu_registers), 8)); 251: 252: static const u32 gen7_11_0_gmu_ao_registers[] = { 253: 0x10001, 0x10001, 0x10003, 0x10003, 0x10401, 0x10401, 0x10403, 0x10403, 254: 0x10801, 0x10801, 0x10803, 0x10803, 0x10c01, 0x10c01, 0x10c03, 0x10c03, 255: 0x11001, 0x11001, 0x11003, 0x11003, 0x11401, 0x11401, 0x11403, 0x11403, 256: 0x11801, 0x11801, 0x11803, 0x11803, 0x11c01, 0x11c01, 0x11c03, 0x11c03, 257: UINT_MAX, UINT_MAX, 258: }; 259: static_assert(IS_ALIGNED(sizeof(gen7_11_0_gmu_ao_registers), 8)); 260: 261: /* 262: * Block : ['GMUGX'] 263: * Pipeline: PIPE_NONE 264: * pairs : 4 (Regs:48) 265: */ 266: static const u32 gen7_11_0_gmugx_registers[] = { 267: 0x1a802, 0x1a802, 0x1a883, 0x1a884, 0x1a900, 0x1a92b, 0x1a940, 0x1a940, 268: UINT_MAX, UINT_MAX, 269: }; 270: static_assert(IS_ALIGNED(sizeof(gen7_11_0_gmugx_registers), 8)); 271: 272: /* 273: * Block : ['CX_MISC'] 274: * Pipeline: PIPE_NONE 275: * pairs : 5 (Regs:52) 276: */ 277: static const u32 gen7_11_0_cx_misc_registers[] = { 278: 0x27800, 0x27800, 0x27810, 0x27814, 0x27820, 0x27824, 0x27828, 0x2782a, 279: 0x27832, 0x27857, 280: UINT_MAX, UINT_MAX, 281: }; 282: static_assert(IS_ALIGNED(sizeof(gen7_11_0_cx_misc_registers), 8)); 283: --- FILE: \adreno_gen7_14_0_snapshot.h | HITS: 5 --- MATCH LINES: 27 15: DEBUGBUS_UCHE_0, 16: DEBUGBUS_TESS_BR, 17: DEBUGBUS_PC_BR, 18: DEBUGBUS_VFDP_BR, 19: DEBUGBUS_VPC_BR, 20: DEBUGBUS_TSE_BR, 21: DEBUGBUS_RAS_BR, 22: DEBUGBUS_VSC, 23: DEBUGBUS_COM_0, 24: DEBUGBUS_LRZ_BR, 25: DEBUGBUS_UFC_0, 26: DEBUGBUS_UFC_1, 27: DEBUGBUS_GMU_GX, 28: DEBUGBUS_DBGC, 29: DEBUGBUS_GPC_BR, 30: DEBUGBUS_LARC, 31: DEBUGBUS_HLSQ_SPTP, 32: DEBUGBUS_RB_0, 33: DEBUGBUS_RB_1, 34: DEBUGBUS_UCHE_WRAPPER, 35: DEBUGBUS_CCU_0, 36: DEBUGBUS_CCU_1, 37: DEBUGBUS_VFD_BR_0, 38: DEBUGBUS_VFD_BR_1, 39: DEBUGBUS_VFD_BR_2, 40: DEBUGBUS_VFD_BR_3, 41: DEBUGBUS_USP_0, 42: DEBUGBUS_USP_1, 43: DEBUGBUS_TP_0, 44: DEBUGBUS_TP_1, 45: DEBUGBUS_TP_2, 46: DEBUGBUS_TP_3, 47: DEBUGBUS_USPTP_0, 48: DEBUGBUS_USPTP_1, 49: DEBUGBUS_USPTP_2, 50: DEBUGBUS_USPTP_3, 51: }; MATCH LINES: 115, 145, 147, 151 103: 0x18440, 0x1845c, 0x18479, 0x1847c, 0x18580, 0x18581, 104: UINT_MAX, UINT_MAX, 105: }; 106: static_assert(IS_ALIGNED(sizeof(gen7_14_0_dbgc_registers), 8)); 107: 108: static const u32 gen7_14_0_cx_misc_registers[] = { 109: 0x27800, 0x27800, 0x27810, 0x27814, 0x27820, 0x27824, 0x27828, 0x2782a, 110: 0x27832, 0x27857, 111: UINT_MAX, UINT_MAX, 112: }; 113: static_assert(IS_ALIGNED(sizeof(gen7_14_0_cx_misc_registers), 8)); 114: 115: static const u32 gen7_14_0_gmu_registers[] = { 116: 0x10001, 0x10001, 0x10003, 0x10003, 0x10401, 0x10401, 0x10403, 0x10403, 117: 0x10801, 0x10801, 0x10803, 0x10803, 0x10c01, 0x10c01, 0x10c03, 0x10c03, 118: 0x11001, 0x11001, 0x11003, 0x11003, 0x11401, 0x11401, 0x11403, 0x11403, 119: 0x11801, 0x11801, 0x11803, 0x11803, 0x11c01, 0x11c01, 0x11c03, 0x11c03, 120: 0x1f400, 0x1f40b, 0x1f40f, 0x1f411, 0x1f500, 0x1f500, 0x1f507, 0x1f507, 121: 0x1f509, 0x1f50b, 0x1f800, 0x1f804, 0x1f807, 0x1f808, 0x1f80b, 0x1f80c, 122: 0x1f80f, 0x1f80f, 0x1f811, 0x1f811, 0x1f813, 0x1f817, 0x1f819, 0x1f81c, 123: 0x1f824, 0x1f82a, 0x1f82d, 0x1f830, 0x1f840, 0x1f853, 0x1f860, 0x1f860, 124: 0x1f870, 0x1f879, 0x1f87f, 0x1f87f, 0x1f888, 0x1f889, 0x1f8a0, 0x1f8a2, 125: 0x1f8a4, 0x1f8af, 0x1f8c0, 0x1f8c1, 0x1f8c3, 0x1f8c4, 0x1f8d0, 0x1f8d0, 126: 0x1f8ec, 0x1f8ec, 0x1f8f0, 0x1f8f1, 0x1f910, 0x1f911, 0x1f920, 0x1f921, 127: 0x1f924, 0x1f925, 0x1f928, 0x1f929, 0x1f92c, 0x1f92d, 0x1f940, 0x1f940, 128: 0x1f942, 0x1f944, 0x1f948, 0x1f94a, 0x1f980, 0x1f981, 0x1f984, 0x1f986, 129: 0x1f992, 0x1f993, 0x1f996, 0x1f99e, 0x1f9c0, 0x1f9c0, 0x1f9c5, 0x1f9d4, 130: 0x1f9f1, 0x1f9f1, 0x1f9f8, 0x1f9fa, 0x1fa00, 0x1fa03, 0x20000, 0x20005, 131: 0x20008, 0x20009, 0x20010, 0x20012, 0x20018, 0x20018, 0x20020, 0x20024, 132: 0x20030, 0x20031, 0x23801, 0x23801, 0x23803, 0x23803, 0x23805, 0x23805, 133: 0x23807, 0x23807, 0x23809, 0x23809, 0x2380b, 0x2380b, 0x2380d, 0x2380d, 134: 0x2380f, 0x2380f, 0x23811, 0x23811, 0x23813, 0x23813, 0x23815, 0x23815, 135: 0x23817, 0x23817, 0x23819, 0x23819, 0x2381b, 0x2381b, 0x2381d, 0x2381d, 136: 0x2381f, 0x23820, 0x23822, 0x23822, 0x23824, 0x23824, 0x23826, 0x23826, 137: 0x23828, 0x23828, 0x2382a, 0x2382a, 0x2382c, 0x2382c, 0x2382e, 0x2382e, 138: 0x23830, 0x23830, 0x23832, 0x23832, 0x23834, 0x23834, 0x23836, 0x23836, 139: 0x23838, 0x23838, 0x2383a, 0x2383a, 0x2383c, 0x2383c, 0x2383e, 0x2383e, 140: 0x23840, 0x23847, 0x23b00, 0x23b01, 0x23b03, 0x23b03, 0x23b05, 0x23b0e, 141: 0x23b10, 0x23b13, 0x23b15, 0x23b16, 0x23b20, 0x23b20, 0x23b28, 0x23b28, 142: 0x23b30, 0x23b30, 143: UINT_MAX, UINT_MAX, 144: }; 145: static_assert(IS_ALIGNED(sizeof(gen7_14_0_gmu_registers), 8)); 146: 147: static const u32 gen7_14_0_gmu_gx_registers[] = { 148: 0x1a802, 0x1a802, 0x1a883, 0x1a884, 0x1a900, 0x1a92b, 0x1a940, 0x1a940, 149: UINT_MAX, UINT_MAX, 150: }; 151: static_assert(IS_ALIGNED(sizeof(gen7_14_0_gmu_gx_registers), 8)); 152: 153: static const u32 gen7_14_0_rscc_registers[] = { 154: 0x14000, 0x14034, 0x14036, 0x14036, 0x14040, 0x14042, 0x14044, 0x14045, 155: 0x14047, 0x14047, 0x14080, 0x14084, 0x14089, 0x1408c, 0x14091, 0x14094, 156: 0x14099, 0x1409c, 0x140a1, 0x140a4, 0x140a9, 0x140ac, 0x14100, 0x14104, 157: 0x14114, 0x14119, 0x14124, 0x14132, 0x14154, 0x1416b, 0x14340, 0x14341, 158: 0x14344, 0x14344, 0x14346, 0x1437c, 0x143f0, 0x143f8, 0x143fa, 0x143fe, 159: 0x14400, 0x14404, 0x14406, 0x1440a, 0x1440c, 0x14410, 0x14412, 0x14416, 160: 0x14418, 0x1441c, 0x1441e, 0x14422, 0x14424, 0x14424, 0x14498, 0x144a0, 161: 0x144a2, 0x144a6, 0x144a8, 0x144ac, 0x144ae, 0x144b2, 0x144b4, 0x144b8, 162: 0x144ba, 0x144be, 0x144c0, 0x144c4, 0x144c6, 0x144ca, 0x144cc, 0x144cc, 163: 0x14540, 0x14548, 0x1454a, 0x1454e, 0x14550, 0x14554, 0x14556, 0x1455a, 164: 0x1455c, 0x14560, 0x14562, 0x14566, 0x14568, 0x1456c, 0x1456e, 0x14572, 165: 0x14574, 0x14574, 0x145e8, 0x145f0, 0x145f2, 0x145f6, 0x145f8, 0x145fc, 166: 0x145fe, 0x14602, 0x14604, 0x14608, 0x1460a, 0x1460e, 0x14610, 0x14614, 167: 0x14616, 0x1461a, 0x1461c, 0x1461c, 0x14690, 0x14698, 0x1469a, 0x1469e, 168: 0x146a0, 0x146a4, 0x146a6, 0x146aa, 0x146ac, 0x146b0, 0x146b2, 0x146b6, 169: 0x146b8, 0x146bc, 0x146be, 0x146c2, 0x146c4, 0x146c4, 0x14738, 0x14740, 170: 0x14742, 0x14746, 0x14748, 0x1474c, 0x1474e, 0x14752, 0x14754, 0x14758, 171: 0x1475a, 0x1475e, 0x14760, 0x14764, 0x14766, 0x1476a, 0x1476c, 0x1476c, 172: 0x147e0, 0x147e8, 0x147ea, 0x147ee, 0x147f0, 0x147f4, 0x147f6, 0x147fa, 173: 0x147fc, 0x14800, 0x14802, 0x14806, 0x14808, 0x1480c, 0x1480e, 0x14812, 174: 0x14814, 0x14814, 0x14888, 0x14890, 0x14892, 0x14896, 0x14898, 0x1489c, 175: 0x1489e, 0x148a2, 0x148a4, 0x148a8, 0x148aa, 0x148ae, 0x148b0, 0x148b4, --- FILE: \adreno_gen7_2_0_snapshot.h | HITS: 3 --- MATCH LINES: 36 24: DEBUGBUS_VPC_BR, 25: DEBUGBUS_VPC_BV, 26: DEBUGBUS_TSE_BR, 27: DEBUGBUS_TSE_BV, 28: DEBUGBUS_RAS_BR, 29: DEBUGBUS_RAS_BV, 30: DEBUGBUS_VSC, 31: DEBUGBUS_COM_0, 32: DEBUGBUS_LRZ_BR, 33: DEBUGBUS_LRZ_BV, 34: DEBUGBUS_UFC_0, 35: DEBUGBUS_UFC_1, 36: DEBUGBUS_GMU_GX, 37: DEBUGBUS_DBGC, 38: DEBUGBUS_GPC_BR, 39: DEBUGBUS_GPC_BV, 40: DEBUGBUS_LARC, 41: DEBUGBUS_HLSQ_SPTP, 42: DEBUGBUS_RB_0, 43: DEBUGBUS_RB_1, 44: DEBUGBUS_RB_2, 45: DEBUGBUS_RB_3, 46: DEBUGBUS_RB_4, 47: DEBUGBUS_RB_5, 48: DEBUGBUS_UCHE_WRAPPER, 49: DEBUGBUS_CCU_0, 50: DEBUGBUS_CCU_1, 51: DEBUGBUS_CCU_2, 52: DEBUGBUS_CCU_3, 53: DEBUGBUS_CCU_4, 54: DEBUGBUS_CCU_5, 55: DEBUGBUS_VFD_BR_0, 56: DEBUGBUS_VFD_BR_1, 57: DEBUGBUS_VFD_BR_2, 58: DEBUGBUS_VFD_BR_3, 59: DEBUGBUS_VFD_BR_4, 60: DEBUGBUS_VFD_BR_5, MATCH LINES: 227, 265 215: 0x0ecc0, 0x0ecc1, 0x0ecc5, 0x0ecc5, 0x0ecc7, 0x0ecc7, 0x0ecca, 0x0ecca, 216: 0x0ecd2, 0x0ecd2, 0x0ece6, 0x0ece8, 0x0eceb, 0x0eced, 0x0ecef, 0x0ecef, 217: 0x0ed00, 0x0ed01, 0x0ed05, 0x0ed05, 0x0ed07, 0x0ed07, 0x0ed0a, 0x0ed0a, 218: 0x0ed12, 0x0ed12, 0x0ed26, 0x0ed28, 0x0ed2b, 0x0ed2d, 0x0ed2f, 0x0ed2f, 219: 0x0ed40, 0x0ed41, 0x0ed45, 0x0ed45, 0x0ed47, 0x0ed47, 0x0ed4a, 0x0ed4a, 220: 0x0ed52, 0x0ed52, 0x0ed66, 0x0ed68, 0x0ed6b, 0x0ed6d, 0x0ed6f, 0x0ed6f, 221: 0x0ed80, 0x0ed81, 0x0ed85, 0x0ed85, 0x0ed87, 0x0ed87, 0x0ed8a, 0x0ed8a, 222: 0x0ed92, 0x0ed92, 0x0eda6, 0x0eda8, 0x0edab, 0x0edad, 0x0edaf, 0x0edaf, 223: UINT_MAX, UINT_MAX, 224: }; 225: static_assert(IS_ALIGNED(sizeof(gen7_2_0_gpu_registers), 8)); 226: 227: static const u32 gen7_2_0_gmu_registers[] = { 228: 0x10001, 0x10001, 0x10003, 0x10003, 0x10401, 0x10401, 0x10403, 0x10403, 229: 0x10801, 0x10801, 0x10803, 0x10803, 0x10c01, 0x10c01, 0x10c03, 0x10c03, 230: 0x11001, 0x11001, 0x11003, 0x11003, 0x11401, 0x11401, 0x11403, 0x11403, 231: 0x11801, 0x11801, 0x11803, 0x11803, 0x11c01, 0x11c01, 0x11c03, 0x11c03, 232: 0x1a79b, 0x1a79b, 0x1a7ac, 0x1a7b9, 0x1a7dc, 0x1a7dd, 0x1a7e0, 0x1a7e1, 233: 0x1a803, 0x1a803, 0x1a805, 0x1a806, 0x1a84e, 0x1a84e, 0x1a856, 0x1a856, 234: 0x1f400, 0x1f40d, 0x1f40f, 0x1f411, 0x1f500, 0x1f500, 0x1f507, 0x1f507, 235: 0x1f509, 0x1f50b, 0x1f700, 0x1f701, 0x1f704, 0x1f706, 0x1f708, 0x1f709, 236: 0x1f70c, 0x1f70d, 0x1f710, 0x1f711, 0x1f713, 0x1f716, 0x1f720, 0x1f724, 237: 0x1f729, 0x1f729, 0x1f730, 0x1f747, 0x1f760, 0x1f761, 0x1f764, 0x1f76b, 238: 0x1f800, 0x1f804, 0x1f807, 0x1f808, 0x1f80b, 0x1f80c, 0x1f80f, 0x1f80f, 239: 0x1f811, 0x1f811, 0x1f813, 0x1f817, 0x1f819, 0x1f81c, 0x1f824, 0x1f82a, 240: 0x1f82d, 0x1f830, 0x1f840, 0x1f853, 0x1f860, 0x1f860, 0x1f862, 0x1f864, 241: 0x1f868, 0x1f868, 0x1f870, 0x1f879, 0x1f87f, 0x1f87f, 0x1f888, 0x1f889, 242: 0x1f8a0, 0x1f8a2, 0x1f890, 0x1f892, 0x1f894, 0x1f896, 0x1f8a4, 0x1f8af, 243: 0x1f8b8, 0x1f8b9, 0x1f8c0, 0x1f8c1, 0x1f8c3, 0x1f8c4, 0x1f8d0, 0x1f8d0, 244: 0x1f8ec, 0x1f8ec, 0x1f8f0, 0x1f8f1, 0x1f910, 0x1f917, 0x1f920, 0x1f921, 245: 0x1f924, 0x1f925, 0x1f928, 0x1f929, 0x1f92c, 0x1f92d, 0x1f940, 0x1f940, 246: 0x1f942, 0x1f944, 0x1f948, 0x1f94a, 0x1f94f, 0x1f951, 0x1f954, 0x1f955, 247: 0x1f958, 0x1f95a, 0x1f95d, 0x1f95d, 0x1f962, 0x1f96b, 0x1f970, 0x1f979, 248: 0x1f97c, 0x1f97c, 0x1f980, 0x1f981, 0x1f984, 0x1f986, 0x1f992, 0x1f993, 249: 0x1f996, 0x1f99e, 0x1f9c0, 0x1f9c0, 0x1f9c5, 0x1f9d4, 0x1f9f0, 0x1f9f1, 250: 0x1f9f8, 0x1f9fa, 0x1f9fc, 0x1f9fc, 0x1fa00, 0x1fa03, 0x20000, 0x20012, 251: 0x20018, 0x20018, 0x2001a, 0x2001a, 0x20020, 0x20024, 0x20030, 0x20031, 252: 0x20034, 0x20036, 0x23801, 0x23801, 0x23803, 0x23803, 0x23805, 0x23805, 253: 0x23807, 0x23807, 0x23809, 0x23809, 0x2380b, 0x2380b, 0x2380d, 0x2380d, 254: 0x2380f, 0x2380f, 0x23811, 0x23811, 0x23813, 0x23813, 0x23815, 0x23815, 255: 0x23817, 0x23817, 0x23819, 0x23819, 0x2381b, 0x2381b, 0x2381d, 0x2381d, 256: 0x2381f, 0x23820, 0x23822, 0x23822, 0x23824, 0x23824, 0x23826, 0x23826, 257: 0x23828, 0x23828, 0x2382a, 0x2382a, 0x2382c, 0x2382c, 0x2382e, 0x2382e, 258: 0x23830, 0x23830, 0x23832, 0x23832, 0x23834, 0x23834, 0x23836, 0x23836, 259: 0x23838, 0x23838, 0x2383a, 0x2383a, 0x2383c, 0x2383c, 0x2383e, 0x2383e, 260: 0x23840, 0x23847, 0x23b00, 0x23b01, 0x23b03, 0x23b03, 0x23b05, 0x23b0e, 261: 0x23b10, 0x23b13, 0x23b15, 0x23b16, 0x23b20, 0x23b20, 0x23b28, 0x23b28, 262: 0x23b30, 0x23b30, 263: UINT_MAX, UINT_MAX, 264: }; 265: static_assert(IS_ALIGNED(sizeof(gen7_2_0_gmu_registers), 8)); 266: 267: static const u32 gen7_2_0_gmugx_registers[] = { 268: 0x1a400, 0x1a41f, 0x1a440, 0x1a45f, 0x1a480, 0x1a49f, 0x1a4c0, 0x1a4df, 269: 0x1a500, 0x1a51f, 0x1a540, 0x1a55f, 0x1a580, 0x1a59f, 0x1a5c0, 0x1a5df, 270: 0x1a600, 0x1a61f, 0x1a640, 0x1a65f, 0x1a780, 0x1a781, 0x1a783, 0x1a785, 271: 0x1a787, 0x1a789, 0x1a78b, 0x1a78d, 0x1a78f, 0x1a791, 0x1a793, 0x1a795, 272: 0x1a797, 0x1a799, 0x1a79c, 0x1a79d, 0x1a79f, 0x1a79f, 0x1a7a0, 0x1a7a1, 273: 0x1a7a3, 0x1a7a3, 0x1a7a8, 0x1a7ab, 0x1a7c0, 0x1a7c1, 0x1a7c4, 0x1a7c5, 274: 0x1a7c8, 0x1a7c9, 0x1a7cc, 0x1a7cd, 0x1a7d0, 0x1a7d1, 0x1a7d4, 0x1a7d5, 275: 0x1a7d8, 0x1a7d9, 0x1a7fc, 0x1a7fd, 0x1a800, 0x1a802, 0x1a804, 0x1a804, 276: 0x1a816, 0x1a816, 0x1a81e, 0x1a81e, 0x1a826, 0x1a826, 0x1a82e, 0x1a82e, 277: 0x1a836, 0x1a836, 0x1a83e, 0x1a83e, 0x1a846, 0x1a846, 0x1a860, 0x1a862, 278: 0x1a864, 0x1a867, 0x1a870, 0x1a870, 0x1a883, 0x1a884, 0x1a8c0, 0x1a8c2, 279: 0x1a8c4, 0x1a8c7, 0x1a8d0, 0x1a8d3, 0x1a900, 0x1a92b, 0x1a940, 0x1a940, 280: UINT_MAX, UINT_MAX, 281: }; 282: static_assert(IS_ALIGNED(sizeof(gen7_2_0_gmugx_registers), 8)); 283: 284: static const u32 gen7_2_0_noncontext_pipe_br_registers[] = { 285: 0x00887, 0x0088c, 0x08600, 0x08600, 0x08602, 0x08602, 0x08610, 0x0861b, 286: 0x08620, 0x08620, 0x08630, 0x08630, 0x08637, 0x08639, 0x08640, 0x08640, 287: 0x09600, 0x09600, 0x09602, 0x09603, 0x0960a, 0x09616, 0x09624, 0x0963a, 288: 0x09640, 0x09640, 0x09e00, 0x09e00, 0x09e02, 0x09e07, 0x09e0a, 0x09e16, 289: 0x09e19, 0x09e19, 0x09e1c, 0x09e1c, 0x09e20, 0x09e25, 0x09e30, 0x09e31, --- FILE: \adreno_gen7_3_0_snapshot.h | HITS: 5 --- MATCH LINES: 29 17: DEBUGBUS_UCHE_0, 18: DEBUGBUS_TESS_BR, 19: DEBUGBUS_PC_BR, 20: DEBUGBUS_VFDP_BR, 21: DEBUGBUS_VPC_BR, 22: DEBUGBUS_TSE_BR, 23: DEBUGBUS_RAS_BR, 24: DEBUGBUS_VSC, 25: DEBUGBUS_COM_0, 26: DEBUGBUS_LRZ_BR, 27: DEBUGBUS_UFC_0, 28: DEBUGBUS_UFC_1, 29: DEBUGBUS_GMU_GX, 30: DEBUGBUS_DBGC, 31: DEBUGBUS_GPC_BR, 32: DEBUGBUS_LARC, 33: DEBUGBUS_HLSQ_SPTP, 34: DEBUGBUS_RB_0, 35: DEBUGBUS_UCHE_WRAPPER, 36: DEBUGBUS_CCU_0, 37: DEBUGBUS_VFD_BR_0, 38: DEBUGBUS_VFD_BR_1, 39: DEBUGBUS_USP_0, 40: DEBUGBUS_TP_0, 41: DEBUGBUS_TP_1, 42: DEBUGBUS_USPTP_0, 43: DEBUGBUS_USPTP_1, 44: }; 45: 46: static struct gen7_shader_block gen7_3_0_shader_blocks[] = { 47: {HLSQ_CPS_MISC_RAM_1, 0x200, 1, 1, PIPE_BR, HLSQ_STATE}, 48: {SP_LB_0_DATA, 0x800, 1, 2, PIPE_BR, USPTP}, 49: {SP_LB_1_DATA, 0x800, 1, 2, PIPE_BR, USPTP}, 50: {SP_LB_2_DATA, 0x800, 1, 2, PIPE_BR, USPTP}, 51: {SP_LB_3_DATA, 0x800, 1, 2, PIPE_BR, USPTP}, 52: {SP_LB_4_DATA, 0x800, 1, 2, PIPE_BR, USPTP}, 53: {SP_LB_5_DATA, 0x800, 1, 2, PIPE_BR, USPTP}, MATCH LINES: 124, 154, 156, 160 112: 0x008c0, 0x008c0, 0x008c4, 0x008c5, 0x008d0, 0x008dd, 0x008f0, 0x008f3, 113: 0x00900, 0x00903, 0x00908, 0x00911, 0x00928, 0x0093e, 0x00942, 0x0094d, 114: 0x00980, 0x00984, 0x0098d, 0x0098f, 0x009b0, 0x009b4, 0x009c2, 0x009c9, 115: 0x009ce, 0x009d7, 0x00a00, 0x00a00, 0x00a02, 0x00a03, 0x00a10, 0x00a4f, 116: 0x00a67, 0x00a6c, 0x00a9c, 0x00a9f, 0x00c00, 0x00c00, 0x00c02, 0x00c04, 117: 0x00c06, 0x00c06, 0x00c10, 0x00cd9, 0x00ce0, 0x00d0c, 0x00df0, 0x00df4, 118: 0x00e01, 0x00e02, 0x00e07, 0x00e0e, 0x00e10, 0x00e12, 0x00e17, 0x00e17, 119: 0x00e19, 0x00e19, 0x00e1b, 0x00e2b, 0x00e30, 0x00e32, 0x00e38, 0x00e3c, 120: UINT_MAX, UINT_MAX, 121: }; 122: static_assert(IS_ALIGNED(sizeof(gen7_3_0_gpu_registers), 8)); 123: 124: static const u32 gen7_3_0_gmu_registers[] = { 125: 0x10001, 0x10001, 0x10003, 0x10003, 0x10401, 0x10401, 0x10403, 0x10403, 126: 0x10801, 0x10801, 0x10803, 0x10803, 0x10c01, 0x10c01, 0x10c03, 0x10c03, 127: 0x11001, 0x11001, 0x11003, 0x11003, 0x11401, 0x11401, 0x11403, 0x11403, 128: 0x11801, 0x11801, 0x11803, 0x11803, 0x11c01, 0x11c01, 0x11c03, 0x11c03, 129: 0x1f400, 0x1f40b, 0x1f40f, 0x1f411, 0x1f500, 0x1f500, 0x1f507, 0x1f507, 130: 0x1f509, 0x1f50b, 0x1f800, 0x1f804, 0x1f807, 0x1f808, 0x1f80b, 0x1f80c, 131: 0x1f80f, 0x1f80f, 0x1f811, 0x1f811, 0x1f813, 0x1f817, 0x1f819, 0x1f81c, 132: 0x1f824, 0x1f82a, 0x1f82d, 0x1f830, 0x1f840, 0x1f853, 0x1f860, 0x1f860, 133: 0x1f870, 0x1f879, 0x1f87f, 0x1f87f, 0x1f888, 0x1f889, 0x1f8a0, 0x1f8a2, 134: 0x1f8a4, 0x1f8af, 0x1f8c0, 0x1f8c1, 0x1f8c3, 0x1f8c4, 0x1f8d0, 0x1f8d0, 135: 0x1f8ec, 0x1f8ec, 0x1f8f0, 0x1f8f1, 0x1f910, 0x1f911, 0x1f920, 0x1f921, 136: 0x1f924, 0x1f925, 0x1f928, 0x1f929, 0x1f92c, 0x1f92d, 0x1f940, 0x1f940, 137: 0x1f942, 0x1f944, 0x1f948, 0x1f94a, 0x1f980, 0x1f981, 0x1f984, 0x1f986, 138: 0x1f992, 0x1f993, 0x1f996, 0x1f99e, 0x1f9c0, 0x1f9c0, 0x1f9c5, 0x1f9d4, 139: 0x1f9f1, 0x1f9f1, 0x1f9f8, 0x1f9fa, 0x1fa00, 0x1fa03, 0x20000, 0x20005, 140: 0x20008, 0x20009, 0x20010, 0x20012, 0x20018, 0x20018, 0x20020, 0x20023, 141: 0x20030, 0x20031, 0x23801, 0x23801, 0x23803, 0x23803, 0x23805, 0x23805, 142: 0x23807, 0x23807, 0x23809, 0x23809, 0x2380b, 0x2380b, 0x2380d, 0x2380d, 143: 0x2380f, 0x2380f, 0x23811, 0x23811, 0x23813, 0x23813, 0x23815, 0x23815, 144: 0x23817, 0x23817, 0x23819, 0x23819, 0x2381b, 0x2381b, 0x2381d, 0x2381d, 145: 0x2381f, 0x23820, 0x23822, 0x23822, 0x23824, 0x23824, 0x23826, 0x23826, 146: 0x23828, 0x23828, 0x2382a, 0x2382a, 0x2382c, 0x2382c, 0x2382e, 0x2382e, 147: 0x23830, 0x23830, 0x23832, 0x23832, 0x23834, 0x23834, 0x23836, 0x23836, 148: 0x23838, 0x23838, 0x2383a, 0x2383a, 0x2383c, 0x2383c, 0x2383e, 0x2383e, 149: 0x23840, 0x23847, 0x23b00, 0x23b01, 0x23b03, 0x23b03, 0x23b05, 0x23b0e, 150: 0x23b10, 0x23b13, 0x23b15, 0x23b16, 0x23b20, 0x23b20, 0x23b28, 0x23b28, 151: 0x23b30, 0x23b30, 152: UINT_MAX, UINT_MAX, 153: }; 154: static_assert(IS_ALIGNED(sizeof(gen7_3_0_gmu_registers), 8)); 155: 156: static const u32 gen7_3_0_gmu_gx_registers[] = { 157: 0x1a802, 0x1a802, 0x1a883, 0x1a884, 0x1a900, 0x1a92b, 0x1a940, 0x1a940, 158: UINT_MAX, UINT_MAX, 159: }; 160: static_assert(IS_ALIGNED(sizeof(gen7_3_0_gmu_gx_registers), 8)); 161: 162: static const u32 gen7_3_0_noncontext_pipe_bv_registers[] = { 163: 0x00887, 0x0088c, 0x08600, 0x08600, 0x08602, 0x08602, 0x08610, 0x0861b, 164: 0x08620, 0x08620, 0x08630, 0x08630, 0x08637, 0x08639, 0x08640, 0x08640, 165: 0x09600, 0x09600, 0x09602, 0x09603, 0x0960a, 0x09616, 0x09624, 0x0963a, 166: 0x09640, 0x09640, 0x0a600, 0x0a600, 0x0a603, 0x0a603, 0x0a610, 0x0a61f, 167: 0x0a630, 0x0a631, 0x0a638, 0x0a638, 168: UINT_MAX, UINT_MAX, 169: }; 170: static_assert(IS_ALIGNED(sizeof(gen7_3_0_noncontext_pipe_bv_registers), 8)); 171: 172: static const u32 gen7_3_0_noncontext_rb_rac_pipe_br_registers[] = { 173: 0x08e10, 0x08e1c, 0x08e20, 0x08e25, 0x08e51, 0x08e54, 174: UINT_MAX, UINT_MAX, 175: }; 176: static_assert(IS_ALIGNED(sizeof(gen7_3_0_noncontext_rb_rac_pipe_br_registers), 8)); 177: 178: /* Block: SP Cluster: CLUSTER_SP_PS Pipeline: PIPE_LPAC Location: HLSQ_STATE */ 179: static const u32 gen7_3_0_sp_cluster_sp_ps_pipe_lpac_hlsq_state_registers[] = { 180: 0x0aa40, 0x0aabf, 181: UINT_MAX, UINT_MAX, 182: }; 183: static_assert(IS_ALIGNED(sizeof(gen7_3_0_sp_cluster_sp_ps_pipe_lpac_hlsq_state_registers), 8)); 184: --- FILE: \adreno_gen7_5_0_snapshot.h | HITS: 4 --- MATCH LINES: 11, 43, 45, 52 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 4: */ 5: #ifndef __ADRENO_GEN7_5_0_SNAPSHOT_H 6: #define __ADRENO_GEN7_5_0_SNAPSHOT_H 7: 8: #include "adreno_gen7_15_0_snapshot.h" 9: #include "adreno_gen7_2_0_snapshot.h" 10: 11: static const u32 gen7_5_0_gmu_registers[] = { 12: 0x1a803, 0x1a803, 0x1a805, 0x1a806, 0x1a84e, 0x1a84e, 0x1a856, 0x1a856, 13: 0x1f400, 0x1f40d, 0x1f40f, 0x1f411, 0x1f500, 0x1f500, 0x1f507, 0x1f507, 14: 0x1f509, 0x1f50b, 0x1f700, 0x1f701, 0x1f704, 0x1f706, 0x1f708, 0x1f709, 15: 0x1f70c, 0x1f70d, 0x1f710, 0x1f711, 0x1f713, 0x1f716, 0x1f720, 0x1f724, 16: 0x1f729, 0x1f729, 0x1f730, 0x1f747, 0x1f760, 0x1f761, 0x1f764, 0x1f76b, 17: 0x1f800, 0x1f804, 0x1f807, 0x1f808, 0x1f80b, 0x1f80c, 0x1f80f, 0x1f80f, 18: 0x1f811, 0x1f811, 0x1f813, 0x1f817, 0x1f819, 0x1f81c, 0x1f824, 0x1f82a, 19: 0x1f82d, 0x1f830, 0x1f840, 0x1f853, 0x1f860, 0x1f860, 0x1f862, 0x1f864, 20: 0x1f868, 0x1f868, 0x1f870, 0x1f879, 0x1f87f, 0x1f87f, 0x1f888, 0x1f889, 21: 0x1f8a0, 0x1f8a2, 0x1f890, 0x1f892, 0x1f894, 0x1f896, 0x1f8a4, 0x1f8af, 22: 0x1f8b8, 0x1f8b9, 0x1f8c0, 0x1f8c1, 0x1f8c3, 0x1f8c4, 0x1f8d0, 0x1f8d0, 23: 0x1f8ec, 0x1f8ec, 0x1f8f0, 0x1f8f1, 0x1f910, 0x1f917, 0x1f920, 0x1f921, 24: 0x1f924, 0x1f925, 0x1f928, 0x1f929, 0x1f92c, 0x1f92d, 0x1f940, 0x1f940, 25: 0x1f942, 0x1f944, 0x1f948, 0x1f94a, 0x1f94f, 0x1f951, 0x1f954, 0x1f955, 26: 0x1f958, 0x1f95a, 0x1f95d, 0x1f95d, 0x1f962, 0x1f96b, 0x1f970, 0x1f979, 27: 0x1f97c, 0x1f97c, 0x1f980, 0x1f981, 0x1f984, 0x1f986, 0x1f992, 0x1f993, 28: 0x1f996, 0x1f99e, 0x1f9c0, 0x1f9c0, 0x1f9c5, 0x1f9d4, 0x1f9f0, 0x1f9f1, 29: 0x1f9f8, 0x1f9fa, 0x1f9fc, 0x1f9fc, 0x1fa00, 0x1fa03, 0x20000, 0x20012, 30: 0x20018, 0x20018, 0x2001a, 0x2001a, 0x20020, 0x20024, 0x20030, 0x20031, 31: 0x20034, 0x20036, 0x23801, 0x23801, 0x23803, 0x23803, 0x23805, 0x23805, 32: 0x23807, 0x23807, 0x23809, 0x23809, 0x2380b, 0x2380b, 0x2380d, 0x2380d, 33: 0x2380f, 0x2380f, 0x23811, 0x23811, 0x23813, 0x23813, 0x23815, 0x23815, 34: 0x23817, 0x23817, 0x23819, 0x23819, 0x2381b, 0x2381b, 0x2381d, 0x2381d, 35: 0x2381f, 0x23820, 0x23822, 0x23822, 0x23824, 0x23824, 0x23826, 0x23826, 36: 0x23828, 0x23828, 0x2382a, 0x2382a, 0x2382c, 0x2382c, 0x2382e, 0x2382e, 37: 0x23830, 0x23830, 0x23832, 0x23832, 0x23834, 0x23834, 0x23836, 0x23836, 38: 0x23838, 0x23838, 0x2383a, 0x2383a, 0x2383c, 0x2383c, 0x2383e, 0x2383e, 39: 0x23840, 0x23847, 0x23b00, 0x23b01, 0x23b03, 0x23b03, 0x23b05, 0x23b0e, 40: 0x23b10, 0x23b13, 0x23b15, 0x23b16, 0x23b20, 0x23b20, 0x23b28, 0x23b28, 41: 0x23b30, 0x23b30, UINT_MAX, UINT_MAX, 42: }; 43: static_assert(IS_ALIGNED(sizeof(gen7_5_0_gmu_registers), 8)); 44: 45: static const u32 gen7_5_0_gmu_ao_registers[] = { 46: 0x10001, 0x10001, 0x10003, 0x10003, 0x10401, 0x10401, 0x10403, 0x10403, 47: 0x10801, 0x10801, 0x10803, 0x10803, 0x10c01, 0x10c01, 0x10c03, 0x10c03, 48: 0x11001, 0x11001, 0x11003, 0x11003, 0x11401, 0x11401, 0x11403, 0x11403, 49: 0x11801, 0x11801, 0x11803, 0x11803, 0x11c01, 0x11c01, 0x11c03, 0x11c03, 50: UINT_MAX, UINT_MAX, 51: }; 52: static_assert(IS_ALIGNED(sizeof(gen7_5_0_gmu_ao_registers), 8)); 53: 54: static const u32 gen7_5_0_gmugx_registers[] = { 55: 0x1a800, 0x1a802, 0x1a804, 0x1a804, 0x1a816, 0x1a816, 0x1a81e, 0x1a81e, 56: 0x1a826, 0x1a826, 0x1a82e, 0x1a82e, 0x1a836, 0x1a836, 0x1a83e, 0x1a83e, 57: 0x1a846, 0x1a846, 0x1a860, 0x1a862, 0x1a864, 0x1a867, 0x1a870, 0x1a870, 58: 0x1a883, 0x1a884, 0x1a8c0, 0x1a8c2, 0x1a8c4, 0x1a8c7, 0x1a8d0, 0x1a8d3, 59: 0x1a900, 0x1a92b, 0x1a940, 0x1a940, UINT_MAX, UINT_MAX, 60: }; 61: static_assert(IS_ALIGNED(sizeof(gen7_5_0_gmugx_registers), 8)); 62: 63: static const u32 gen7_5_0_gmugx_blk_dec0_dec1_registers[] = { 64: 0x1a400, 0x1a41f, 0x1a440, 0x1a45f, 0x1a480, 0x1a49f, 0x1a4c0, 0x1a4df, 65: 0x1a500, 0x1a51f, 0x1a540, 0x1a55f, 0x1a580, 0x1a59f, 0x1a5c0, 0x1a5df, 66: 0x1a600, 0x1a61f, 0x1a640, 0x1a65f, 0x1a780, 0x1a781, 0x1a783, 0x1a785, 67: 0x1a787, 0x1a789, 0x1a78b, 0x1a78d, 0x1a78f, 0x1a791, 0x1a793, 0x1a795, 68: 0x1a797, 0x1a799, 0x1a79b, 0x1a79d, 0x1a79f, 0x1a79f, 0x1a7a0, 0x1a7a1, 69: 0x1a7a3, 0x1a7a3, 0x1a7a8, 0x1a7ab, 0x1a7ac, 0x1a7b9, 0x1a7c0, 0x1a7c1, 70: 0x1a7c4, 0x1a7c5, 0x1a7c8, 0x1a7c9, 0x1a7cc, 0x1a7cd, 0x1a7d0, 0x1a7d1, 71: 0x1a7d4, 0x1a7d5, 0x1a7d8, 0x1a7d9, 0x1a7dc, 0x1a7dd, 0x1a7e0, 0x1a7e1, 72: 0x1a7fc, 0x1a7fd, UINT_MAX, UINT_MAX, 73: }; 74: static_assert(IS_ALIGNED(sizeof(gen7_5_0_gmugx_blk_dec0_dec1_registers), 8)); 75: 76: /* --- FILE: \adreno_gen7_9_0_snapshot.h | HITS: 4 --- MATCH LINES: 36 24: DEBUGBUS_VPC_BR, 25: DEBUGBUS_VPC_BV, 26: DEBUGBUS_TSE_BR, 27: DEBUGBUS_TSE_BV, 28: DEBUGBUS_RAS_BR, 29: DEBUGBUS_RAS_BV, 30: DEBUGBUS_VSC, 31: DEBUGBUS_COM_0, 32: DEBUGBUS_LRZ_BR, 33: DEBUGBUS_LRZ_BV, 34: DEBUGBUS_UFC_0, 35: DEBUGBUS_UFC_1, 36: DEBUGBUS_GMU_GX, 37: DEBUGBUS_DBGC, 38: DEBUGBUS_GPC_BR, 39: DEBUGBUS_GPC_BV, 40: DEBUGBUS_LARC, 41: DEBUGBUS_HLSQ_SPTP, 42: DEBUGBUS_RB_0, 43: DEBUGBUS_RB_1, 44: DEBUGBUS_RB_2, 45: DEBUGBUS_RB_3, 46: DEBUGBUS_RB_4, 47: DEBUGBUS_RB_5, 48: DEBUGBUS_UCHE_WRAPPER, 49: DEBUGBUS_CCU_0, 50: DEBUGBUS_CCU_1, 51: DEBUGBUS_CCU_2, 52: DEBUGBUS_CCU_3, 53: DEBUGBUS_CCU_4, 54: DEBUGBUS_CCU_5, 55: DEBUGBUS_VFD_BR_0, 56: DEBUGBUS_VFD_BR_1, 57: DEBUGBUS_VFD_BR_2, 58: DEBUGBUS_VFD_BV_0, 59: DEBUGBUS_VFD_BV_1, 60: DEBUGBUS_VFD_BV_2, MATCH LINES: 116 104: DEBUGBUS_UFC_DSTR_1, 105: DEBUGBUS_UFC_DSTR_2, 106: DEBUGBUS_CGC_SUBCORE, 107: DEBUGBUS_CGC_CORE, 108: }; 109: 110: static const u32 gen7_9_0_gbif_debugbus_blocks[] = { 111: DEBUGBUS_GBIF_GX, 112: }; 113: 114: static const u32 gen7_9_0_cx_debugbus_blocks[] = { 115: DEBUGBUS_CX, 116: DEBUGBUS_GMU_CX, 117: DEBUGBUS_GBIF_CX, 118: }; 119: 120: static struct gen7_shader_block gen7_9_0_shader_blocks[] = { 121: { TP0_TMO_DATA, 0x0200, 6, 2, PIPE_BR, USPTP }, 122: { TP0_SMO_DATA, 0x0080, 6, 2, PIPE_BR, USPTP }, 123: { TP0_MIPMAP_BASE_DATA, 0x03C0, 6, 2, PIPE_BR, USPTP }, 124: { SP_INST_DATA, 0x0800, 6, 2, PIPE_BR, USPTP }, 125: { SP_INST_DATA_1, 0x0800, 6, 2, PIPE_BR, USPTP }, 126: { SP_LB_0_DATA, 0x0800, 6, 2, PIPE_BR, USPTP }, 127: { SP_LB_1_DATA, 0x0800, 6, 2, PIPE_BR, USPTP }, 128: { SP_LB_2_DATA, 0x0800, 6, 2, PIPE_BR, USPTP }, 129: { SP_LB_3_DATA, 0x0800, 6, 2, PIPE_BR, USPTP }, 130: { SP_LB_4_DATA, 0x0800, 6, 2, PIPE_BR, USPTP }, 131: { SP_LB_5_DATA, 0x0800, 6, 2, PIPE_BR, USPTP }, 132: { SP_LB_6_DATA, 0x0800, 6, 2, PIPE_BR, USPTP }, 133: { SP_LB_7_DATA, 0x0800, 6, 2, PIPE_BR, USPTP }, 134: { SP_CB_RAM, 0x0390, 6, 2, PIPE_BR, USPTP }, 135: { SP_LB_13_DATA, 0x0800, 6, 2, PIPE_BR, USPTP }, 136: { SP_LB_14_DATA, 0x0800, 6, 2, PIPE_BR, USPTP }, 137: { SP_INST_TAG, 0x00C0, 6, 2, PIPE_BR, USPTP }, 138: { SP_INST_DATA_2, 0x0800, 6, 2, PIPE_BR, USPTP }, 139: { SP_TMO_TAG, 0x0080, 6, 2, PIPE_BR, USPTP }, 140: { SP_SMO_TAG, 0x0080, 6, 2, PIPE_BR, USPTP }, MATCH LINES: 296, 333 284: static const u32 gen7_9_0_gxclkctl_registers[] = { 285: 0x18800, 0x18800, 0x18808, 0x1880b, 0x18820, 0x18822, 0x18830, 0x18830, 286: 0x18834, 0x1883b, 287: UINT_MAX, UINT_MAX, 288: }; 289: static_assert(IS_ALIGNED(sizeof(gen7_9_0_gxclkctl_registers), 8)); 290: 291: /* 292: * Block : ['GMUAO', 'GMUCX', 'GMUCX_RAM'] 293: * Pipeline: PIPE_NONE 294: * pairs : 134 (Regs:429) 295: */ 296: static const u32 gen7_9_0_gmu_registers[] = { 297: 0x10001, 0x10001, 0x10003, 0x10003, 0x10401, 0x10401, 0x10403, 0x10403, 298: 0x10801, 0x10801, 0x10803, 0x10803, 0x10c01, 0x10c01, 0x10c03, 0x10c03, 299: 0x11001, 0x11001, 0x11003, 0x11003, 0x11401, 0x11401, 0x11403, 0x11403, 300: 0x11801, 0x11801, 0x11803, 0x11803, 0x11c01, 0x11c01, 0x11c03, 0x11c03, 301: 0x1f400, 0x1f40b, 0x1f40f, 0x1f411, 0x1f500, 0x1f500, 0x1f507, 0x1f507, 302: 0x1f509, 0x1f50b, 0x1f700, 0x1f701, 0x1f704, 0x1f706, 0x1f708, 0x1f709, 303: 0x1f70c, 0x1f70d, 0x1f710, 0x1f711, 0x1f713, 0x1f716, 0x1f718, 0x1f71d, 304: 0x1f720, 0x1f724, 0x1f729, 0x1f729, 0x1f730, 0x1f747, 0x1f750, 0x1f756, 305: 0x1f758, 0x1f759, 0x1f75c, 0x1f75c, 0x1f760, 0x1f761, 0x1f764, 0x1f76b, 306: 0x1f770, 0x1f775, 0x1f780, 0x1f785, 0x1f790, 0x1f798, 0x1f7a0, 0x1f7a8, 307: 0x1f7b0, 0x1f7b3, 0x1f800, 0x1f804, 0x1f807, 0x1f808, 0x1f80b, 0x1f80c, 308: 0x1f80f, 0x1f80f, 0x1f811, 0x1f811, 0x1f813, 0x1f817, 0x1f819, 0x1f81c, 309: 0x1f824, 0x1f82a, 0x1f82d, 0x1f830, 0x1f840, 0x1f853, 0x1f860, 0x1f860, 310: 0x1f862, 0x1f866, 0x1f868, 0x1f869, 0x1f870, 0x1f879, 0x1f87f, 0x1f881, 311: 0x1f890, 0x1f896, 0x1f8a0, 0x1f8a2, 0x1f8a4, 0x1f8af, 0x1f8b8, 0x1f8b9, 312: 0x1f8c0, 0x1f8c1, 0x1f8c3, 0x1f8c4, 0x1f8d0, 0x1f8d0, 0x1f8ec, 0x1f8ec, 313: 0x1f8f0, 0x1f8f1, 0x1f910, 0x1f917, 0x1f920, 0x1f921, 0x1f924, 0x1f925, 314: 0x1f928, 0x1f929, 0x1f92c, 0x1f92d, 0x1f942, 0x1f944, 0x1f948, 0x1f94a, 315: 0x1f94f, 0x1f951, 0x1f954, 0x1f955, 0x1f95d, 0x1f95d, 0x1f962, 0x1f96b, 316: 0x1f970, 0x1f971, 0x1f973, 0x1f977, 0x1f97c, 0x1f97c, 0x1f980, 0x1f981, 317: 0x1f984, 0x1f986, 0x1f992, 0x1f993, 0x1f996, 0x1f99e, 0x1f9c5, 0x1f9d4, 318: 0x1f9f0, 0x1f9f1, 0x1f9f8, 0x1f9fa, 0x1f9fc, 0x1f9fc, 0x1fa00, 0x1fa03, 319: 0x20000, 0x20013, 0x20018, 0x2001a, 0x20020, 0x20021, 0x20024, 0x20025, 320: 0x2002a, 0x2002c, 0x20030, 0x20031, 0x20034, 0x20036, 0x23801, 0x23801, 321: 0x23803, 0x23803, 0x23805, 0x23805, 0x23807, 0x23807, 0x23809, 0x23809, 322: 0x2380b, 0x2380b, 0x2380d, 0x2380d, 0x2380f, 0x2380f, 0x23811, 0x23811, 323: 0x23813, 0x23813, 0x23815, 0x23815, 0x23817, 0x23817, 0x23819, 0x23819, 324: 0x2381b, 0x2381b, 0x2381d, 0x2381d, 0x2381f, 0x23820, 0x23822, 0x23822, 325: 0x23824, 0x23824, 0x23826, 0x23826, 0x23828, 0x23828, 0x2382a, 0x2382a, 326: 0x2382c, 0x2382c, 0x2382e, 0x2382e, 0x23830, 0x23830, 0x23832, 0x23832, 327: 0x23834, 0x23834, 0x23836, 0x23836, 0x23838, 0x23838, 0x2383a, 0x2383a, 328: 0x2383c, 0x2383c, 0x2383e, 0x2383e, 0x23840, 0x23847, 0x23b00, 0x23b01, 329: 0x23b03, 0x23b03, 0x23b05, 0x23b0e, 0x23b10, 0x23b13, 0x23b15, 0x23b16, 330: 0x23b28, 0x23b28, 0x23b30, 0x23b30, 331: UINT_MAX, UINT_MAX, 332: }; 333: static_assert(IS_ALIGNED(sizeof(gen7_9_0_gmu_registers), 8)); 334: 335: /* 336: * Block : ['GMUGX'] 337: * Pipeline: PIPE_NONE 338: * pairs : 44 (Regs:454) 339: */ 340: static const u32 gen7_9_0_gmugx_registers[] = { 341: 0x1a400, 0x1a41f, 0x1a440, 0x1a45f, 0x1a480, 0x1a49f, 0x1a4c0, 0x1a4df, 342: 0x1a500, 0x1a51f, 0x1a540, 0x1a55f, 0x1a580, 0x1a59f, 0x1a600, 0x1a61f, 343: 0x1a640, 0x1a65f, 0x1a780, 0x1a781, 0x1a783, 0x1a785, 0x1a787, 0x1a789, 344: 0x1a78b, 0x1a78d, 0x1a78f, 0x1a791, 0x1a793, 0x1a795, 0x1a797, 0x1a799, 345: 0x1a79b, 0x1a79d, 0x1a79f, 0x1a7a1, 0x1a7a3, 0x1a7a3, 0x1a7a8, 0x1a7b9, 346: 0x1a7c0, 0x1a7c1, 0x1a7c4, 0x1a7c5, 0x1a7c8, 0x1a7c9, 0x1a7cc, 0x1a7cd, 347: 0x1a7d0, 0x1a7d1, 0x1a7d4, 0x1a7d5, 0x1a7d8, 0x1a7d9, 0x1a7dc, 0x1a7dd, 348: 0x1a7e0, 0x1a7e1, 0x1a7fc, 0x1a7fd, 0x1a800, 0x1a808, 0x1a816, 0x1a816, 349: 0x1a81e, 0x1a81e, 0x1a826, 0x1a826, 0x1a82e, 0x1a82e, 0x1a836, 0x1a836, 350: 0x1a83e, 0x1a83e, 0x1a846, 0x1a846, 0x1a84e, 0x1a84e, 0x1a856, 0x1a856, 351: 0x1a883, 0x1a884, 0x1a890, 0x1a8b3, 0x1a900, 0x1a92b, 0x1a940, 0x1a940, 352: UINT_MAX, UINT_MAX, 353: }; 354: static_assert(IS_ALIGNED(sizeof(gen7_9_0_gmugx_registers), 8)); 355: 356: /* 357: * Block : ['CX_MISC'] --- FILE: \adreno_gen7_gmu.c | HITS: 577 --- MATCH LINES: 24, 28, 29, 33, 38, 42, 46, 51, 59, 63, 72, 81, 87, 95, 104, 110, 136, 145, 151, 159, 168, 174, 182, 191, 197, 224, 234, 242, 264, 298, 299, 300, 305, 306, 309, 313, 324, 332, 337, 338, 339, 342, 359, 364, 368, 370, 373, 378, 380, 382, 390, 393, 397, 399, 401, 402, 412, 415, 419, 424, 426, 432, 437, 439, 447, 450, 453, 456, 460, 462, 469, 473, 475, 481, 490, 493, 497, 498, 507, 510, 516, 518, 519, 520, 522, 523, 526, 528, 531, 537, 550, 553, 554, 555, 556, 557, 558, 559, 560, 567, 570, 571, 573, 576, 579, 580, 583, 587, 590, 591, 592, 593, 600, 602, 604, 605, 607, 608, 612, 614, 618, 619, 622, 625, 628, 629, 630, 634, 635, 638, 641, 645, 646, 648, 649, 650, 651, 658, 661, 669, 670, 672, 673, 676, 678, 685, 714, 717, 733, 743, 747, 748, 752, 756, 770, 773, 774, 784, 785, 786, 801, 802, 815, 816, 817, 819, 821, 824, 825, 827, 829, 830, 836, 839, 840, 841, 845, 851, 859, 861, 862, 863, 867, 874, 877, 881, 883, 885, 887, 889, 893, 894, 896, 902, 905, 911, 917, 918, 919, 924, 926, 935, 936, 939, 940, 942, 943, 944, 946, 955, 976, 977, 980, 984, 985, 986, 987, 989, 990, 993, 994, 995, 998, 1009, 1015, 1017, 1018, 1020, 1037, 1042, 1056, 1059, 1069, 1070, 1071, 1081, 1084, 1087, 1088, 1089, 1091, 1094, 1098, 1102, 1106, 1143, 1145, 1154, 1160, 1161, 1166, 1169, 1186, 1200, 1210, 1211, 1215, 1218, 1222, 1226, 1232, 1235, 1241, 1244, 1250, 1255, 1262, 1264, 1268, 1270, 1275, 1280, 1282, 1289, 1303, 1313, 1315, 1323, 1324, 1325, 1329, 1334, 1336, 1339, 1343, 1362, 1364, 1370, 1371, 1376, 1383, 1384, 1406, 1413, 1419, 1427, 1430, 1434, 1435, 1441, 1445, 1446, 1452, 1454, 1456, 1460, 1464, 1466, 1467, 1477, 1482, 1488, 1489, 1490, 1492, 1494, 1498, 1501, 1507, 1508, 1510, 1511, 1514, 1517, 1520, 1522, 1526, 1527, 1529, 1534, 1536, 1562, 1567, 1570, 1575, 1582, 1584, 1588, 1589, 1594, 1598, 1603, 1609, 1623, 1627, 1631, 1639, 1641, 1650, 1654, 1660, 1663, 1669, 1673, 1674, 1677, 1679, 1680, 1685, 1692, 1694, 1695, 1700, 1705, 1710, 1721, 1739, 1743, 1745, 1750, 1754, 1758, 1762, 1769, 1771, 1772, 1777, 1782, 1789, 1792, 1795, 1798 12: #include 13: #include 14: #include 15: #include 16: #include 17: #include 18: 19: #include "adreno.h" 20: #include "adreno_gen7.h" 21: #include "adreno_trace.h" 22: #include "kgsl_bus.h" 23: #include "kgsl_device.h" 24: #include "kgsl_gmu_core.h" 25: #include "kgsl_trace.h" 26: #include "kgsl_util.h" 27: 28: static struct gmu_vma_entry gen7_gmu_vma[] = { 29: [GMU_ITCM] = { 30: .start = 0x00000000, 31: .size = SZ_16K, 32: }, 33: [GMU_CACHE] = { 34: .start = SZ_16K, 35: .size = (SZ_16M - SZ_16K), 36: .next_va = SZ_16K, 37: }, 38: [GMU_DTCM] = { 39: .start = SZ_256M + SZ_16K, 40: .size = SZ_16K, 41: }, 42: [GMU_DCACHE] = { 43: .start = 0x0, 44: .size = 0x0, 45: }, 46: [GMU_NONCACHED_KERNEL] = { 47: .start = 0x60000000, 48: .size = SZ_512M, 49: .next_va = 0x60000000, 50: }, 51: [GMU_NONCACHED_KERNEL_EXTENDED] = { 52: .start = 0xc0000000, 53: .size = SZ_512M, 54: .next_va = 0xc0000000, 55: }, 56: }; 57: 58: /** 59: * adreno_gmu_chipid_based() - Return true for targets where Chipid 60: * should be passed to GMU instead of GPU REV 61: * @adreno_dev: A pointer to the adreno_device 62: */ 63: static inline int adreno_gmu_chipid_based(struct adreno_device *adreno_dev) 64: { 65: return adreno_is_gen7_0_0(adreno_dev) || adreno_is_gen7_0_1(adreno_dev) || 66: adreno_is_gen7_4_0(adreno_dev) || adreno_is_gen7_3_0(adreno_dev); 67: } 68: 69: static ssize_t log_stream_enable_store(struct kobject *kobj, 70: struct kobj_attribute *attr, const char *buf, size_t count) 71: { 72: struct gen7_gmu_device *gmu = container_of(kobj, struct gen7_gmu_device, log_kobj); 73: bool val; 74: int ret; 75: 76: ret = kstrtobool(buf, &val); 77: if (ret) 78: return ret; 79: 80: gmu->log_stream_enable = val; 81: gmu_core_mark_for_coldboot(KGSL_DEVICE(gen7_gmu_to_adreno(gmu))); 82: return count; 83: } 84: 85: static ssize_t log_stream_enable_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) 86: { 87: struct gen7_gmu_device *gmu = container_of(kobj, struct gen7_gmu_device, log_kobj); 88: 89: return scnprintf(buf, PAGE_SIZE, "%d\n", gmu->log_stream_enable); 90: } 91: 92: static ssize_t log_group_mask_store(struct kobject *kobj, 93: struct kobj_attribute *attr, const char *buf, size_t count) 94: { 95: struct gen7_gmu_device *gmu = container_of(kobj, struct gen7_gmu_device, log_kobj); 96: u32 val; 97: int ret; 98: 99: ret = kstrtou32(buf, 0, &val); 100: if (ret) 101: return ret; 102: 103: gmu->log_group_mask = val; 104: gmu_core_mark_for_coldboot(KGSL_DEVICE(gen7_gmu_to_adreno(gmu))); 105: return count; 106: } 107: 108: static ssize_t log_group_mask_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) 109: { 110: struct gen7_gmu_device *gmu = container_of(kobj, struct gen7_gmu_device, log_kobj); 111: 112: return scnprintf(buf, PAGE_SIZE, "%x\n", gmu->log_group_mask); 113: } 114: 115: static struct kobj_attribute log_stream_enable_attr = 116: __ATTR(log_stream_enable, 0644, log_stream_enable_show, log_stream_enable_store); 117: 118: static struct kobj_attribute log_group_mask_attr = 119: __ATTR(log_group_mask, 0644, log_group_mask_show, log_group_mask_store); 120: 121: static struct attribute *log_attrs[] = { 122: &log_stream_enable_attr.attr, 123: &log_group_mask_attr.attr, 124: NULL, 125: }; 126: ATTRIBUTE_GROUPS(log); 127: 128: static struct kobj_type log_kobj_type = { 129: .sysfs_ops = &kobj_sysfs_ops, 130: .default_groups = log_groups, 131: }; 132: 133: static ssize_t stats_enable_store(struct kobject *kobj, 134: struct kobj_attribute *attr, const char *buf, size_t count) 135: { 136: struct gen7_gmu_device *gmu = container_of(kobj, struct gen7_gmu_device, stats_kobj); 137: bool val; 138: int ret; 139: 140: ret = kstrtobool(buf, &val); 141: if (ret) 142: return ret; 143: 144: gmu->stats_enable = val; 145: gmu_core_mark_for_coldboot(KGSL_DEVICE(gen7_gmu_to_adreno(gmu))); 146: return count; 147: } 148: 149: static ssize_t stats_enable_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) 150: { 151: struct gen7_gmu_device *gmu = container_of(kobj, struct gen7_gmu_device, stats_kobj); 152: 153: return scnprintf(buf, PAGE_SIZE, "%d\n", gmu->stats_enable); 154: } 155: 156: static ssize_t stats_mask_store(struct kobject *kobj, 157: struct kobj_attribute *attr, const char *buf, size_t count) 158: { 159: struct gen7_gmu_device *gmu = container_of(kobj, struct gen7_gmu_device, stats_kobj); 160: u32 val; 161: int ret; 162: 163: ret = kstrtou32(buf, 0, &val); 164: if (ret) 165: return ret; 166: 167: gmu->stats_mask = val; 168: gmu_core_mark_for_coldboot(KGSL_DEVICE(gen7_gmu_to_adreno(gmu))); 169: return count; 170: } 171: 172: static ssize_t stats_mask_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) 173: { 174: struct gen7_gmu_device *gmu = container_of(kobj, struct gen7_gmu_device, stats_kobj); 175: 176: return scnprintf(buf, PAGE_SIZE, "%x\n", gmu->stats_mask); 177: } 178: 179: static ssize_t stats_interval_store(struct kobject *kobj, 180: struct kobj_attribute *attr, const char *buf, size_t count) 181: { 182: struct gen7_gmu_device *gmu = container_of(kobj, struct gen7_gmu_device, stats_kobj); 183: u32 val; 184: int ret; 185: 186: ret = kstrtou32(buf, 0, &val); 187: if (ret) 188: return ret; 189: 190: gmu->stats_interval = val; 191: gmu_core_mark_for_coldboot(KGSL_DEVICE(gen7_gmu_to_adreno(gmu))); 192: return count; 193: } 194: 195: static ssize_t stats_interval_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) 196: { 197: struct gen7_gmu_device *gmu = container_of(kobj, struct gen7_gmu_device, stats_kobj); 198: 199: return scnprintf(buf, PAGE_SIZE, "%x\n", gmu->stats_interval); 200: } 201: 202: static struct kobj_attribute stats_enable_attr = 203: __ATTR(stats_enable, 0644, stats_enable_show, stats_enable_store); 204: 205: static struct kobj_attribute stats_mask_attr = 206: __ATTR(stats_mask, 0644, stats_mask_show, stats_mask_store); 207: 208: static struct kobj_attribute stats_interval_attr = 209: __ATTR(stats_interval, 0644, stats_interval_show, stats_interval_store); 210: 211: static struct attribute *stats_attrs[] = { 212: &stats_enable_attr.attr, 213: &stats_mask_attr.attr, 214: &stats_interval_attr.attr, 215: NULL, 216: }; 217: ATTRIBUTE_GROUPS(stats); 218: 219: static struct kobj_type stats_kobj_type = { 220: .sysfs_ops = &kobj_sysfs_ops, 221: .default_groups = stats_groups, 222: }; 223: 224: static int gen7_timed_poll_check_rscc(struct gen7_gmu_device *gmu, 225: unsigned int offset, unsigned int expected_ret, 226: unsigned int timeout, unsigned int mask) 227: { 228: u32 value; 229: 230: return readl_poll_timeout(gmu->rscc_virt + (offset << 2), value, 231: (value & mask) == expected_ret, 100, timeout * 1000); 232: } 233: 234: struct gen7_gmu_device *to_gen7_gmu(struct adreno_device *adreno_dev) 235: { 236: struct gen7_device *gen7_dev = container_of(adreno_dev, 237: struct gen7_device, adreno_dev); 238: 239: return &gen7_dev->gmu; 240: } 241: 242: struct adreno_device *gen7_gmu_to_adreno(struct gen7_gmu_device *gmu) 243: { 244: struct gen7_device *gen7_dev = 245: container_of(gmu, struct gen7_device, gmu); 246: 247: return &gen7_dev->adreno_dev; 248: } 249: 250: #define RSC_CMD_OFFSET 2 251: #define GEN7_PDC_ENABLE_REG_VALUE 0x80000001 252: 253: static void _regwrite(void __iomem *regbase, 254: unsigned int offsetwords, unsigned int value) 255: { 256: void __iomem *reg; 257: 258: reg = regbase + (offsetwords << 2); 259: __raw_writel(value, reg); 260: } 261: 262: void gen7_load_rsc_ucode(struct adreno_device *adreno_dev) 263: { 264: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 265: void __iomem *rscc = gmu->rscc_virt; 266: unsigned int seq_offset = GEN7_RSCC_SEQ_MEM_0_DRV0; 267: 268: /* Disable SDE clock gating */ 269: _regwrite(rscc, GEN7_GPU_RSCC_RSC_STATUS0_DRV0, BIT(24)); 270: 271: /* Setup RSC PDC handshake for sleep and wakeup */ 272: _regwrite(rscc, GEN7_RSCC_PDC_SLAVE_ID_DRV0, 1); 273: _regwrite(rscc, GEN7_RSCC_HIDDEN_TCS_CMD0_DATA, 0); 274: _regwrite(rscc, GEN7_RSCC_HIDDEN_TCS_CMD0_ADDR, 0); 275: _regwrite(rscc, GEN7_RSCC_HIDDEN_TCS_CMD0_DATA + RSC_CMD_OFFSET, 0); 276: _regwrite(rscc, GEN7_RSCC_HIDDEN_TCS_CMD0_ADDR + RSC_CMD_OFFSET, 0); 277: _regwrite(rscc, GEN7_RSCC_HIDDEN_TCS_CMD0_DATA + RSC_CMD_OFFSET * 2, 278: adreno_is_gen7_2_x_family(adreno_dev) ? 0x80000021 : 0x80000000); 279: _regwrite(rscc, GEN7_RSCC_HIDDEN_TCS_CMD0_ADDR + RSC_CMD_OFFSET * 2, 0); 280: _regwrite(rscc, GEN7_RSCC_OVERRIDE_START_ADDR, 0); 281: _regwrite(rscc, GEN7_RSCC_PDC_SEQ_START_ADDR, 0x4520); 282: _regwrite(rscc, GEN7_RSCC_PDC_MATCH_VALUE_LO, 0x4510); 283: _regwrite(rscc, GEN7_RSCC_PDC_MATCH_VALUE_HI, 0x4514); 284: 285: if (adreno_is_gen7_2_x_family(adreno_dev)) 286: seq_offset = GEN7_2_0_RSCC_SEQ_MEM_0_DRV0; 287: 288: /* Load RSC sequencer uCode for sleep and wakeup */ 289: _regwrite(rscc, seq_offset, 0xeaaae5a0); 290: _regwrite(rscc, seq_offset + 1, 0xe1a1ebab); 291: _regwrite(rscc, seq_offset + 2, 0xa2e0a581); 292: _regwrite(rscc, seq_offset + 3, 0xecac82e2); 293: _regwrite(rscc, seq_offset + 4, 0x0020edad); 294: } 295: 296: int gen7_load_pdc_ucode(struct adreno_device *adreno_dev) 297: { 298: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 299: struct platform_device *gmu_pdev = GMU_PDEV(KGSL_DEVICE(adreno_dev)); 300: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)); 301: 302: if (gmu->pdc_cfg_base == NULL) { 303: struct resource *res_cfg; 304: 305: res_cfg = platform_get_resource_byname(gmu_pdev, 306: IORESOURCE_MEM, "gmu_pdc"); 307: 308: if (res_cfg) 309: gmu->pdc_cfg_base = devm_ioremap(gmu_pdev_dev, 310: res_cfg->start, resource_size(res_cfg)); 311: 312: if (!gmu->pdc_cfg_base) { 313: dev_err(gmu_pdev_dev, "Failed to map PDC CFG\n"); 314: return -ENODEV; 315: } 316: } 317: 318: /* Setup GPU PDC */ 319: _regwrite(gmu->pdc_cfg_base, GEN7_PDC_GPU_SEQ_START_ADDR, 0); 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: 357: ticks = gpudev->read_alwayson(adreno_dev); 358: 359: trace_gmu_ao_sync(ticks); 360: 361: local_irq_restore(flags); 362: } 363: 364: int gen7_gmu_device_start(struct adreno_device *adreno_dev) 365: { 366: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 367: 368: gmu_core_reset_trace_header(&device->gmu_core.trace); 369: 370: gmu_ao_sync_event(adreno_dev); 371: 372: /* Bring GMU out of reset */ 373: gmu_core_regwrite(device, GEN7_GMU_CM3_SYSRESET, 0); 374: 375: /* Make sure the write is posted before moving ahead */ 376: wmb(); 377: 378: if (gmu_core_timed_poll_check(device, GEN7_GMU_CM3_FW_INIT_RESULT, 379: BIT(8), 100, GENMASK(8, 0))) { 380: dev_err(GMU_PDEV_DEV(device), 381: "GMU failed to come out of reset\n"); 382: gmu_core_fault_snapshot(device, GMU_FAULT_DEVICE_START); 383: return -ETIMEDOUT; 384: } 385: 386: return 0; 387: } 388: 389: /* 390: * gen7_gmu_hfi_start() - Write registers and start HFI. 391: * @device: Pointer to KGSL device 392: */ 393: int gen7_gmu_hfi_start(struct adreno_device *adreno_dev) 394: { 395: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 396: 397: gmu_core_regwrite(device, GEN7_GMU_HFI_CTRL_INIT, 1); 398: 399: if (gmu_core_timed_poll_check(device, GEN7_GMU_HFI_CTRL_STATUS, 400: BIT(0), 100, BIT(0))) { 401: dev_err(GMU_PDEV_DEV(device), "GMU HFI init failed\n"); 402: gmu_core_fault_snapshot(device, GMU_FAULT_HFI_INIT); 403: return -ETIMEDOUT; 404: } 405: 406: return 0; 407: } 408: 409: int gen7_rscc_wakeup_sequence(struct adreno_device *adreno_dev) 410: { 411: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 412: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 413: 414: /* Skip wakeup sequence if we didn't do the sleep sequence */ 415: if (!test_bit(GMU_PRIV_RSCC_SLEEP_DONE, &gmu->flags)) 416: return 0; 417: 418: /* RSC wake sequence */ 419: gmu_core_regwrite(device, GEN7_GMU_RSCC_CONTROL_REQ, BIT(1)); 420: 421: /* Write request before polling */ 422: wmb(); 423: 424: if (gmu_core_timed_poll_check(device, GEN7_GMU_RSCC_CONTROL_ACK, 425: BIT(1), 100, BIT(1))) { 426: dev_err(GMU_PDEV_DEV(device), "Failed to do GPU RSC power on\n"); 427: return -ETIMEDOUT; 428: } 429: 430: if (gen7_timed_poll_check_rscc(gmu, GEN7_RSCC_SEQ_BUSY_DRV0, 431: 0x0, 100, UINT_MAX)) { 432: dev_err(GMU_PDEV_DEV(device), 433: "GPU RSC sequence stuck in waking up GPU\n"); 434: return -ETIMEDOUT; 435: } 436: 437: gmu_core_regwrite(device, GEN7_GMU_RSCC_CONTROL_REQ, 0); 438: 439: clear_bit(GMU_PRIV_RSCC_SLEEP_DONE, &gmu->flags); 440: 441: return 0; 442: } 443: 444: int gen7_rscc_sleep_sequence(struct adreno_device *adreno_dev) 445: { 446: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 447: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 448: int ret; 449: 450: if (!test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags)) 451: return 0; 452: 453: if (test_bit(GMU_PRIV_RSCC_SLEEP_DONE, &gmu->flags)) 454: return 0; 455: 456: gmu_core_regwrite(device, GEN7_GMU_CM3_SYSRESET, 1); 457: /* Make sure M3 is in reset before going on */ 458: wmb(); 459: 460: gmu_core_regread(device, GEN7_GMU_GENERAL_9, &gmu->log_wptr_retention); 461: 462: gmu_core_regwrite(device, GEN7_GMU_RSCC_CONTROL_REQ, BIT(0)); 463: /* Make sure the request completes before continuing */ 464: wmb(); 465: 466: ret = gen7_timed_poll_check_rscc(gmu, GEN7_GPU_RSCC_RSC_STATUS0_DRV0, 467: BIT(16), 100, BIT(16)); 468: if (ret) { 469: dev_err(GMU_PDEV_DEV(device), "GPU RSC power off fail\n"); 470: return -ETIMEDOUT; 471: } 472: 473: gmu_core_regwrite(device, GEN7_GMU_RSCC_CONTROL_REQ, 0); 474: 475: set_bit(GMU_PRIV_RSCC_SLEEP_DONE, &gmu->flags); 476: 477: return 0; 478: } 479: 480: static void load_tcm(struct adreno_device *adreno_dev, const u8 *src, 481: u32 tcm_start, u32 base, const struct gmu_block_header *blk) 482: { 483: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 484: u32 tcm_offset = tcm_start + ((blk->addr - base)/sizeof(u32)); 485: 486: kgsl_regmap_bulk_write(&device->regmap, tcm_offset, src, 487: blk->size >> 2); 488: } 489: 490: int gen7_gmu_load_fw(struct adreno_device *adreno_dev) 491: { 492: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 493: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 494: const u8 *fw = (const u8 *)gmu->fw_image->data; 495: 496: while (fw < gmu->fw_image->data + gmu->fw_image->size) { 497: const struct gmu_block_header *blk = 498: (const struct gmu_block_header *)fw; 499: int id; 500: 501: fw += sizeof(*blk); 502: 503: /* Don't deal with zero size blocks */ 504: if (blk->size == 0) 505: continue; 506: 507: id = gmu_core_find_vma_block(device, blk->addr, blk->size); 508: 509: if (id < 0) { 510: dev_err(GMU_PDEV_DEV(device), 511: "Unknown block in GMU FW addr:0x%x size:0x%x\n", 512: blk->addr, blk->size); 513: return -EINVAL; 514: } 515: 516: if (id == GMU_ITCM) { 517: load_tcm(adreno_dev, fw, 518: GEN7_GMU_CM3_ITCM_START, 519: device->gmu_core.vma[GMU_ITCM].start, blk); 520: } else if (id == GMU_DTCM) { 521: load_tcm(adreno_dev, fw, 522: GEN7_GMU_CM3_DTCM_START, 523: device->gmu_core.vma[GMU_DTCM].start, blk); 524: } else { 525: /* The firmware block for memory needs to be copied on first boot only */ 526: if (!test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags)) { 527: struct kgsl_memdesc *md = 528: gmu_core_find_memdesc(device, blk->addr, blk->size); 529: 530: if (!md) { 531: dev_err(GMU_PDEV_DEV(device), 532: "No backing memory for GMU FW block addr:0x%x size:0x%x\n", 533: blk->addr, blk->size); 534: return -EINVAL; 535: } 536: 537: memcpy(md->hostptr + (blk->addr - md->gmuaddr), fw, 538: blk->size); 539: } 540: } 541: 542: fw += blk->size; 543: } 544: 545: /* Proceed only after the FW is written */ 546: wmb(); 547: return 0; 548: } 549: 550: static const char *oob_to_str(enum oob_request req) 551: { 552: switch (req) { 553: case oob_gpu: 554: return "oob_gpu"; 555: case oob_perfcntr: 556: return "oob_perfcntr"; 557: case oob_boot_slumber: 558: return "oob_boot_slumber"; 559: case oob_dcvs: 560: return "oob_dcvs"; 561: default: 562: return "unknown"; 563: } 564: } 565: 566: static void trigger_reset_recovery(struct adreno_device *adreno_dev, 567: enum oob_request req) 568: { 569: /* 570: * Trigger recovery for perfcounter oob only since only 571: * perfcounter oob can happen alongside an actively rendering gpu. 572: */ 573: if (req != oob_perfcntr) 574: return; 575: 576: adreno_scheduler_fault(adreno_dev, ADRENO_GMU_FAULT_SKIP_SNAPSHOT); 577: } 578: 579: int gen7_gmu_oob_set(struct kgsl_device *device, 580: enum oob_request req) 581: { 582: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 583: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 584: int ret = 0; 585: int set, check; 586: 587: if (req == oob_perfcntr && gmu->num_oob_perfcntr++) 588: return 0; 589: 590: if (req >= oob_boot_slumber) { 591: dev_err(GMU_PDEV_DEV(device), 592: "Unsupported OOB request %s\n", 593: oob_to_str(req)); 594: return -EINVAL; 595: } 596: 597: set = BIT(30 - req * 2); 598: check = BIT(31 - req); 599: 600: gmu_core_regwrite(device, GEN7_GMU_HOST2GMU_INTR_SET, set); 601: 602: if (gmu_core_timed_poll_check(device, GEN7_GMU_GMU2HOST_INTR_INFO, check, 603: 100, check)) { 604: if (req == oob_perfcntr) 605: gmu->num_oob_perfcntr--; 606: ret = -ETIMEDOUT; 607: WARN(1, "OOB request %s timed out\n", oob_to_str(req)); 608: gmu_core_fault_snapshot(device, GMU_FAULT_OOB_SET); 609: trigger_reset_recovery(adreno_dev, req); 610: } 611: 612: gmu_core_regwrite(device, GEN7_GMU_GMU2HOST_INTR_CLR, check); 613: 614: trace_kgsl_gmu_oob_set(set); 615: return ret; 616: } 617: 618: void gen7_gmu_oob_clear(struct kgsl_device *device, 619: enum oob_request req) 620: { 621: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 622: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 623: int clear = BIT(31 - req * 2); 624: 625: if (req == oob_perfcntr && --gmu->num_oob_perfcntr) 626: return; 627: 628: if (req >= oob_boot_slumber) { 629: dev_err(GMU_PDEV_DEV(device), "Unsupported OOB clear %s\n", 630: oob_to_str(req)); 631: return; 632: } 633: 634: gmu_core_regwrite(device, GEN7_GMU_HOST2GMU_INTR_SET, clear); 635: trace_kgsl_gmu_oob_clear(clear); 636: } 637: 638: void gen7_gmu_irq_enable(struct adreno_device *adreno_dev) 639: { 640: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 641: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 642: struct gen7_hfi *hfi = &gmu->hfi; 643: 644: /* Clear pending IRQs and Unmask needed IRQs */ 645: gmu_core_regwrite(device, GEN7_GMU_GMU2HOST_INTR_CLR, UINT_MAX); 646: gmu_core_regwrite(device, GEN7_GMU_AO_HOST_INTERRUPT_CLR, UINT_MAX); 647: 648: gmu_core_regwrite(device, GEN7_GMU_GMU2HOST_INTR_MASK, 649: (unsigned int)~HFI_IRQ_MASK); 650: gmu_core_regwrite(device, GEN7_GMU_AO_HOST_INTERRUPT_MASK, 651: (unsigned int)~GMU_AO_INT_MASK); 652: 653: /* Enable all IRQs on host */ 654: enable_irq(hfi->irq); 655: enable_irq(gmu->irq); 656: } 657: 658: void gen7_gmu_irq_disable(struct adreno_device *adreno_dev) 659: { 660: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 661: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 662: struct gen7_hfi *hfi = &gmu->hfi; 663: 664: /* Disable all IRQs on host */ 665: disable_irq(gmu->irq); 666: disable_irq(hfi->irq); 667: 668: /* Mask all IRQs and clear pending IRQs */ 669: gmu_core_regwrite(device, GEN7_GMU_GMU2HOST_INTR_MASK, UINT_MAX); 670: gmu_core_regwrite(device, GEN7_GMU_AO_HOST_INTERRUPT_MASK, UINT_MAX); 671: 672: gmu_core_regwrite(device, GEN7_GMU_GMU2HOST_INTR_CLR, UINT_MAX); 673: gmu_core_regwrite(device, GEN7_GMU_AO_HOST_INTERRUPT_CLR, UINT_MAX); 674: } 675: 676: static int gen7_gmu_hfi_start_msg(struct adreno_device *adreno_dev) 677: { 678: struct hfi_start_cmd req; 679: int ret; 680: 681: ret = CMD_MSG_HDR(req, H2F_MSG_START); 682: if (ret) 683: return ret; 684: 685: return gen7_hfi_send_generic_req(adreno_dev, &req, sizeof(req)); 686: } 687: 688: static u32 gen7_rscc_tcsm_drv0_status_reglist[] = { 689: GEN7_RSCC_TCS0_DRV0_STATUS, 690: GEN7_RSCC_TCS1_DRV0_STATUS, 691: GEN7_RSCC_TCS2_DRV0_STATUS, 692: GEN7_RSCC_TCS3_DRV0_STATUS, 693: GEN7_RSCC_TCS4_DRV0_STATUS, 694: GEN7_RSCC_TCS5_DRV0_STATUS, 695: GEN7_RSCC_TCS6_DRV0_STATUS, 696: GEN7_RSCC_TCS7_DRV0_STATUS, 697: GEN7_RSCC_TCS8_DRV0_STATUS, 698: GEN7_RSCC_TCS9_DRV0_STATUS, 699: }; 700: 701: static u32 gen7_2_0_rscc_tcsm_drv0_status_reglist[] = { 702: GEN7_2_0_RSCC_TCS0_DRV0_STATUS, 703: GEN7_2_0_RSCC_TCS1_DRV0_STATUS, 704: GEN7_2_0_RSCC_TCS2_DRV0_STATUS, 705: GEN7_2_0_RSCC_TCS3_DRV0_STATUS, 706: GEN7_2_0_RSCC_TCS4_DRV0_STATUS, 707: GEN7_2_0_RSCC_TCS5_DRV0_STATUS, 708: GEN7_2_0_RSCC_TCS6_DRV0_STATUS, 709: GEN7_2_0_RSCC_TCS7_DRV0_STATUS, 710: GEN7_2_0_RSCC_TCS8_DRV0_STATUS, 711: GEN7_2_0_RSCC_TCS9_DRV0_STATUS, 712: }; 713: 714: static int gen7_complete_rpmh_votes(struct gen7_gmu_device *gmu, 715: u32 timeout) 716: { 717: struct adreno_device *adreno_dev = gen7_gmu_to_adreno(gmu); 718: int i, ret = 0; 719: 720: if (adreno_is_gen7_2_x_family(adreno_dev)) { 721: for (i = 0; i < ARRAY_SIZE(gen7_2_0_rscc_tcsm_drv0_status_reglist); i++) 722: ret |= gen7_timed_poll_check_rscc(gmu, 723: gen7_2_0_rscc_tcsm_drv0_status_reglist[i], BIT(0), timeout, 724: BIT(0)); 725: } else { 726: for (i = 0; i < ARRAY_SIZE(gen7_rscc_tcsm_drv0_status_reglist); i++) 727: ret |= gen7_timed_poll_check_rscc(gmu, 728: gen7_rscc_tcsm_drv0_status_reglist[i], BIT(0), timeout, 729: BIT(0)); 730: } 731: 732: if (ret) 733: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)), 734: "RPMH votes timedout: %d\n", ret); 735: 736: return ret; 737: } 738: 739: #define GX_GDSC_POWER_OFF BIT(0) 740: #define GX_CLK_OFF BIT(1) 741: #define is_on(val) (!(val & (GX_GDSC_POWER_OFF | GX_CLK_OFF))) 742: 743: bool gen7_gmu_gx_is_on(struct adreno_device *adreno_dev) 744: { 745: unsigned int val; 746: 747: gmu_core_regread(KGSL_DEVICE(adreno_dev), 748: GEN7_GMU_GFX_PWR_CLK_STATUS, &val); 749: return is_on(val); 750: } 751: 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; 856: u64 ts1; 857: 858: ts1 = gpudev->read_alwayson(adreno_dev); 859: if (gmu_core_timed_poll_check(device, GEN7_GPU_GMU_AO_GPU_CX_BUSY_STATUS, 860: 0, 100, CXGXCPUBUSYIGNAHB)) { 861: gmu_core_regread(device, 862: GEN7_GPU_GMU_AO_GPU_CX_BUSY_STATUS2, &status2); 863: dev_err(GMU_PDEV_DEV(device), 864: "GMU not idling: status2=0x%x %llx %llx\n", 865: status2, ts1, 866: gpudev->read_alwayson(adreno_dev)); 867: gmu_core_fault_snapshot(device, GMU_FAULT_WAIT_FOR_IDLE); 868: return -ETIMEDOUT; 869: } 870: 871: return 0; 872: } 873: 874: int gen7_gmu_version_info(struct adreno_device *adreno_dev) 875: { 876: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 877: struct gmu_core_device *gmu = &device->gmu_core; 878: const struct adreno_gen7_core *gen7_core = to_gen7_core(adreno_dev); 879: 880: /* GMU version info is at a fixed offset in the DTCM */ 881: gmu_core_regread(device, GEN7_GMU_CM3_DTCM_START + 0xff8, 882: &gmu->ver.core); 883: gmu_core_regread(device, GEN7_GMU_CM3_DTCM_START + 0xff9, 884: &gmu->ver.core_dev); 885: gmu_core_regread(device, GEN7_GMU_CM3_DTCM_START + 0xffa, 886: &gmu->ver.pwr); 887: gmu_core_regread(device, GEN7_GMU_CM3_DTCM_START + 0xffb, 888: &gmu->ver.pwr_dev); 889: gmu_core_regread(device, GEN7_GMU_CM3_DTCM_START + 0xffc, 890: &gmu->ver.hfi); 891: 892: /* Check if gmu fw version on device is compatible with kgsl driver */ 893: if (gmu->ver.core < gen7_core->gmu_fw_version) { 894: dev_err_once(GMU_PDEV_DEV(device), 895: "GMU FW version 0x%x error (expected 0x%x)\n", 896: gmu->ver.core, gen7_core->gmu_fw_version); 897: return -EINVAL; 898: } 899: return 0; 900: } 901: 902: int gen7_gmu_itcm_shadow(struct adreno_device *adreno_dev) 903: { 904: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 905: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 906: u32 i, *dest; 907: 908: if (gmu->itcm_shadow) 909: return 0; 910: 911: gmu->itcm_shadow = vzalloc(device->gmu_core.vma[GMU_ITCM].size); 912: if (!gmu->itcm_shadow) 913: return -ENOMEM; 914: 915: dest = (u32 *)gmu->itcm_shadow; 916: 917: for (i = 0; i < (device->gmu_core.vma[GMU_ITCM].size >> 2); i++) 918: gmu_core_regread(KGSL_DEVICE(adreno_dev), 919: GEN7_GMU_CM3_ITCM_START + i, dest++); 920: 921: return 0; 922: } 923: 924: void gen7_gmu_register_config(struct adreno_device *adreno_dev) 925: { 926: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 927: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 928: const struct adreno_gen7_core *gen7_core = to_gen7_core(adreno_dev); 929: u32 val; 930: 931: /* Clear any previously set cm3 fault */ 932: atomic_set(&gmu->cm3_fault, 0); 933: 934: /* Vote veto for FAL10 */ 935: gmu_core_regwrite(device, GEN7_GPU_GMU_CX_GMU_CX_FALNEXT_INTF, 0x1); 936: gmu_core_regwrite(device, GEN7_GPU_GMU_CX_GMU_CX_FAL_INTF, 0x1); 937: 938: /* Clear init result to make sure we are getting fresh value */ 939: gmu_core_regwrite(device, GEN7_GMU_CM3_FW_INIT_RESULT, 0); 940: gmu_core_regwrite(device, GEN7_GMU_CM3_BOOT_CONFIG, 0x2); 941: 942: gmu_core_regwrite(device, GEN7_GMU_HFI_QTBL_ADDR, 943: gmu->hfi.hfi_mem->gmuaddr); 944: gmu_core_regwrite(device, GEN7_GMU_HFI_QTBL_INFO, 1); 945: 946: gmu_core_regwrite(device, GEN7_GMU_AHB_FENCE_RANGE_0, BIT(31) | 947: FIELD_PREP(GENMASK(30, 18), 0x32) | 948: FIELD_PREP(GENMASK(17, 0), GEN7_CP_CONTEXT_SWITCH_CNTL)); 949: 950: /* 951: * Make sure that CM3 state is at reset value. Snapshot is changing 952: * NMI bit and if we boot up GMU with NMI bit set GMU will boot 953: * straight in to NMI handler without executing __main code 954: */ 955: gmu_core_regwrite(device, GEN7_GMU_CM3_CFG, 0x4052); 956: 957: /* Set up GBIF registers from the GPU core definition */ 958: kgsl_regmap_multi_write(&device->regmap, gen7_core->gbif, 959: gen7_core->gbif_count); 960: 961: if (adreno_is_gen7_13_0(adreno_dev) || adreno_is_gen7_9_x(adreno_dev)) 962: kgsl_regrmw(device, GEN7_GBIF_CX_CONFIG, GENMASK(31, 29), 963: FIELD_PREP(GENMASK(31, 29), 1)); 964: else if (adreno_is_gen7_14_0_family(adreno_dev)) 965: kgsl_regrmw(device, GEN7_GBIF_CX_CONFIG, GENMASK(31, 29), 966: FIELD_PREP(GENMASK(31, 29), 2)); 967: 968: /** 969: * We may have asserted gbif halt as part of reset sequence which may 970: * not get cleared if the gdsc was not reset. So clear it before 971: * attempting GMU boot. 972: */ 973: kgsl_regwrite(device, GEN7_GBIF_HALT, 0x0); 974: 975: /* Set vrb address before starting GMU */ 976: if (!IS_ERR_OR_NULL(device->gmu_core.vrb)) 977: gmu_core_regwrite(device, GEN7_GMU_GENERAL_11, device->gmu_core.vrb->gmuaddr); 978: 979: /* Set the log wptr index */ 980: gmu_core_regwrite(device, GEN7_GMU_GENERAL_9, 981: gmu->log_wptr_retention); 982: 983: /* Pass chipid to GMU FW, must happen before starting GMU */ 984: if (gen7_core->gmu_chipid) 985: val = gen7_core->gmu_chipid; 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) 1034: return -EINVAL; 1035: 1036: ret = adreno_request_firmware(&gmu->fw_image, gmufw_name, 1037: gmu_pdev_dev, false); 1038: if (ret) { 1039: if (gen7_core->gmufw_bak_name) { 1040: gmufw_name = gen7_core->gmufw_bak_name; 1041: ret = adreno_request_firmware(&gmu->fw_image, gmufw_name, 1042: gmu_pdev_dev, true); 1043: } 1044: 1045: if (ret) 1046: return ret; 1047: } 1048: } 1049: 1050: /* 1051: * Zero payload fw blocks contain metadata and are 1052: * guaranteed to precede fw load data. Parse the 1053: * metadata blocks. 1054: */ 1055: while (offset < gmu->fw_image->size) { 1056: blk = (struct gmu_block_header *)&gmu->fw_image->data[offset]; 1057: 1058: if (offset + sizeof(*blk) > gmu->fw_image->size) { 1059: dev_err(gmu_pdev_dev, "Invalid FW Block\n"); 1060: return -EINVAL; 1061: } 1062: 1063: /* Done with zero length blocks so return */ 1064: if (blk->size) 1065: break; 1066: 1067: offset += sizeof(*blk); 1068: 1069: if (blk->type == GMU_BLK_TYPE_PREALLOC_REQ || 1070: blk->type == GMU_BLK_TYPE_PREALLOC_PERSIST_REQ) { 1071: ret = gmu_core_process_prealloc(KGSL_DEVICE(adreno_dev), blk); 1072: 1073: if (ret) 1074: return ret; 1075: } 1076: } 1077: 1078: return 0; 1079: } 1080: 1081: int gen7_gmu_memory_init(struct adreno_device *adreno_dev) 1082: { 1083: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1084: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1085: 1086: /* GMU master log */ 1087: if (IS_ERR_OR_NULL(gmu->gmu_log)) 1088: gmu->gmu_log = gmu_core_reserve_kernel_block(device, 0, 1089: GMU_LOG_SIZE, GMU_NONCACHED_KERNEL, 0); 1090: 1091: return PTR_ERR_OR_ZERO(gmu->gmu_log); 1092: } 1093: 1094: static int gen7_gmu_init(struct adreno_device *adreno_dev) 1095: { 1096: int ret; 1097: 1098: ret = gen7_gmu_parse_fw(adreno_dev); 1099: if (ret) 1100: return ret; 1101: 1102: ret = gen7_gmu_memory_init(adreno_dev); 1103: if (ret) 1104: return ret; 1105: 1106: return gen7_hfi_init(adreno_dev); 1107: } 1108: 1109: static void _do_gbif_halt(struct kgsl_device *device, u32 reg, u32 ack_reg, 1110: u32 mask, const char *client) 1111: { 1112: u32 ack; 1113: unsigned long t; 1114: 1115: kgsl_regwrite(device, reg, mask); 1116: 1117: t = jiffies + msecs_to_jiffies(100); 1118: do { 1119: kgsl_regread(device, ack_reg, &ack); 1120: if ((ack & mask) == mask) 1121: return; 1122: 1123: /* 1124: * If we are attempting recovery in case of stall-on-fault 1125: * then the halt sequence will not complete as long as SMMU 1126: * is stalled. 1127: */ 1128: kgsl_mmu_pagefault_resume(&device->mmu, false); 1129: 1130: usleep_range(10, 100); 1131: } while (!time_after(jiffies, t)); 1132: 1133: /* Check one last time */ 1134: kgsl_mmu_pagefault_resume(&device->mmu, false); 1135: 1136: kgsl_regread(device, ack_reg, &ack); 1137: if ((ack & mask) == mask) 1138: return; 1139: 1140: dev_err(device->dev, "%s GBIF halt timed out\n", client); 1141: } 1142: 1143: static void gen7_gmu_pwrctrl_suspend(struct adreno_device *adreno_dev) 1144: { 1145: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1146: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1147: 1148: /* Disconnect GPU from BUS is not needed if CX GDSC goes off later */ 1149: 1150: /* 1151: * GEMNOC can enter power collapse state during GPU power down sequence. 1152: * This could abort CX GDSC collapse. Assert Qactive to avoid this. 1153: */ 1154: gmu_core_regwrite(device, GEN7_GPU_GMU_CX_GMU_CX_FALNEXT_INTF, 0x1); 1155: 1156: /* Check no outstanding RPMh voting */ 1157: gen7_complete_rpmh_votes(gmu, 1); 1158: 1159: /* Clear the WRITEDROPPED fields and set fence to allow mode */ 1160: gmu_core_regwrite(device, GEN7_GMU_AHB_FENCE_STATUS_CLR, 0x7); 1161: gmu_core_regwrite(device, GEN7_GMU_AO_AHB_FENCE_CTRL, 0); 1162: 1163: /* Make sure above writes are committed before we proceed to recovery */ 1164: wmb(); 1165: 1166: gmu_core_regwrite(device, GEN7_GMU_CM3_SYSRESET, 1); 1167: 1168: /* Halt GX traffic */ 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); 1209: 1210: if (gen7_gmu_gx_is_on(adreno_dev)) 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)) 1260: return; 1261: 1262: gen7_gmu_pwrctrl_suspend(adreno_dev); 1263: 1264: gmu_core_disable_clks(device); 1265: 1266: kgsl_pwrctrl_disable_cx_gdsc(device); 1267: 1268: gmu_core_rdpm_cx_freq_update(device, 0); 1269: 1270: dev_err(GMU_PDEV_DEV(device), "Suspended GMU\n"); 1271: 1272: kgsl_pwrctrl_set_state(device, KGSL_STATE_NONE); 1273: } 1274: 1275: static int gen7_gmu_dcvs_set(struct adreno_device *adreno_dev, 1276: int gpu_pwrlevel, int bus_level, u32 ab) 1277: { 1278: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1279: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1280: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1281: struct gen7_dcvs_table *table = &gmu->dcvs_table; 1282: struct hfi_gx_bw_perf_vote_cmd req = { 1283: .ack_type = DCVS_ACK_BLOCK, 1284: .freq = INVALID_DCVS_IDX, 1285: .bw = INVALID_DCVS_IDX, 1286: }; 1287: int ret = 0; 1288: 1289: if (!test_bit(GMU_PRIV_HFI_STARTED, &gmu->flags)) 1290: return 0; 1291: 1292: /* Do not set to XO and lower GPU clock vote from GMU */ 1293: if ((gpu_pwrlevel != INVALID_DCVS_IDX) && 1294: (gpu_pwrlevel >= table->gpu_level_num - 1)) 1295: return -EINVAL; 1296: 1297: if (gpu_pwrlevel < table->gpu_level_num - 1) 1298: req.freq = table->gpu_level_num - gpu_pwrlevel - 1; 1299: 1300: if (bus_level < pwr->ddr_table_count && bus_level > 0) 1301: req.bw = bus_level; 1302: 1303: req.bw |= adreno_gmu_bus_ab_quantize(adreno_dev, ab); 1304: 1305: /* GMU will vote for slumber levels through the sleep sequence */ 1306: if ((req.freq == INVALID_DCVS_IDX) && (req.bw == INVALID_BW_VOTE)) 1307: return 0; 1308: 1309: ret = CMD_MSG_HDR(req, H2F_MSG_GX_BW_PERF_VOTE); 1310: if (ret) 1311: return ret; 1312: 1313: ret = gen7_hfi_send_generic_req(adreno_dev, &req, sizeof(req)); 1314: if (ret) { 1315: dev_err_ratelimited(GMU_PDEV_DEV(device), 1316: "Failed to set GPU perf idx %u, bw idx %u\n", 1317: req.freq, req.bw); 1318: 1319: /* 1320: * If this was a dcvs request along side an active gpu, request 1321: * dispatcher based reset and recovery. 1322: */ 1323: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 1324: adreno_scheduler_fault(adreno_dev, ADRENO_GMU_FAULT | 1325: ADRENO_GMU_FAULT_SKIP_SNAPSHOT); 1326: } 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; 1391: 1392: /* 1393: * We should not send NMI if there was a CM3 fault reported because we 1394: * don't want to overwrite the critical CM3 state captured by gmu before 1395: * it sent the CM3 fault interrupt. Also don't send NMI if GMU reset is 1396: * already active. We could have hit a GMU assert and NMI might have 1397: * already been triggered. 1398: */ 1399: 1400: /* make sure we're reading the latest cm3_fault */ 1401: smp_rmb(); 1402: 1403: if (atomic_read(&gmu->cm3_fault)) 1404: return; 1405: 1406: gmu_core_regread(device, GEN7_GMU_CM3_FW_INIT_RESULT, &result); 1407: 1408: if (result & 0xE00) 1409: return; 1410: 1411: nmi: 1412: /* Mask so there's no interrupt caused by NMI */ 1413: gmu_core_regwrite(device, GEN7_GMU_GMU2HOST_INTR_MASK, UINT_MAX); 1414: 1415: /* Make sure the interrupt is masked before causing it */ 1416: wmb(); 1417: 1418: /* This will cause the GMU to save it's internal state to ddr */ 1419: gmu_core_regrmw(device, GEN7_GMU_CM3_CFG, BIT(9), BIT(9)); 1420: 1421: /* Make sure the NMI is invoked before we proceed*/ 1422: wmb(); 1423: 1424: /* Wait for the NMI to be handled */ 1425: udelay(200); 1426: done: 1427: KGSL_GMU_CORE_FORCE_PANIC(device->gmu_core.gf_panic, GMU_PDEV(device), ticks, gf_policy); 1428: } 1429: 1430: static void gen7_gmu_cooperative_reset(struct kgsl_device *device) 1431: { 1432: unsigned int result; 1433: 1434: gmu_core_regwrite(device, GEN7_GMU_CX_GMU_WDOG_CTRL, 0); 1435: gmu_core_regwrite(device, GEN7_GMU_HOST2GMU_INTR_SET, BIT(17)); 1436: 1437: /* 1438: * After triggering graceful death wait for snapshot ready 1439: * indication from GMU. 1440: */ 1441: if (!gmu_core_timed_poll_check(device, GEN7_GMU_CM3_FW_INIT_RESULT, 1442: 0x800, 2, 0x800)) 1443: return; 1444: 1445: gmu_core_regread(device, GEN7_GMU_CM3_FW_INIT_RESULT, &result); 1446: dev_err(GMU_PDEV_DEV(device), 1447: "GMU cooperative reset timed out 0x%x\n", result); 1448: /* 1449: * If we dont get a snapshot ready from GMU, trigger NMI 1450: * and if we still timeout then we just continue with reset. 1451: */ 1452: gen7_gmu_send_nmi(device, true, GMU_FAULT_PANIC_NONE); 1453: 1454: gmu_core_regread(device, GEN7_GMU_CM3_FW_INIT_RESULT, &result); 1455: if ((result & 0x800) != 0x800) 1456: dev_err(GMU_PDEV_DEV(device), 1457: "GMU cooperative reset NMI timed out 0x%x\n", result); 1458: } 1459: 1460: static int gen7_gmu_wait_for_active_transition(struct kgsl_device *device) 1461: { 1462: unsigned int reg; 1463: 1464: if (gmu_core_timed_poll_check(device, GEN7_GPU_GMU_CX_GMU_RPMH_POWER_STATE, 1465: GPU_HW_ACTIVE, 100, GENMASK(3, 0))) { 1466: gmu_core_regread(device, GEN7_GPU_GMU_CX_GMU_RPMH_POWER_STATE, ®); 1467: dev_err(GMU_PDEV_DEV(device), 1468: "GMU failed to move to ACTIVE state, Current state: 0x%x\n", 1469: reg); 1470: 1471: return -ETIMEDOUT; 1472: } 1473: 1474: return 0; 1475: } 1476: 1477: static bool gen7_gmu_scales_bandwidth(struct kgsl_device *device) 1478: { 1479: return true; 1480: } 1481: 1482: void gen7_gmu_handle_watchdog(struct adreno_device *adreno_dev) 1483: { 1484: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1485: u32 mask; 1486: 1487: /* Temporarily mask the watchdog interrupt to prevent a storm */ 1488: gmu_core_regread(device, GEN7_GMU_AO_HOST_INTERRUPT_MASK, &mask); 1489: gmu_core_regwrite(device, GEN7_GMU_AO_HOST_INTERRUPT_MASK, 1490: (mask | GMU_INT_WDOG_BITE)); 1491: 1492: gen7_gmu_send_nmi(device, false, GMU_FAULT_PANIC_NONE); 1493: 1494: dev_err_ratelimited(GMU_PDEV_DEV(device), 1495: "GMU watchdog expired interrupt received\n"); 1496: } 1497: 1498: static irqreturn_t gen7_gmu_irq_handler(int irq, void *data) 1499: { 1500: struct kgsl_device *device = data; 1501: struct device *gmu_pdev_dev = GMU_PDEV_DEV(device); 1502: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1503: const struct gen7_gpudev *gen7_gpudev = 1504: to_gen7_gpudev(ADRENO_GPU_DEVICE(adreno_dev)); 1505: unsigned int status = 0; 1506: 1507: gmu_core_regread(device, GEN7_GMU_AO_HOST_INTERRUPT_STATUS, &status); 1508: gmu_core_regwrite(device, GEN7_GMU_AO_HOST_INTERRUPT_CLR, status); 1509: 1510: if (status & GMU_INT_HOST_AHB_BUS_ERR) 1511: dev_err_ratelimited(gmu_pdev_dev, 1512: "AHB bus error interrupt received\n"); 1513: 1514: if (status & GMU_INT_WDOG_BITE) 1515: gen7_gpudev->handle_watchdog(adreno_dev); 1516: 1517: if (status & GMU_INT_FENCE_ERR) { 1518: unsigned int fence_status; 1519: 1520: gmu_core_regread(device, GEN7_GMU_AHB_FENCE_STATUS, 1521: &fence_status); 1522: dev_err_ratelimited(gmu_pdev_dev, 1523: "FENCE error interrupt received %x\n", fence_status); 1524: } 1525: 1526: if (status & ~GMU_AO_INT_MASK) 1527: dev_err_ratelimited(gmu_pdev_dev, 1528: "Unhandled GMU interrupts 0x%lx\n", 1529: status & ~GMU_AO_INT_MASK); 1530: 1531: return IRQ_HANDLED; 1532: } 1533: 1534: void gen7_gmu_aop_send_acd_state(struct gen7_gmu_device *gmu, bool flag) 1535: { 1536: struct kgsl_device *device = KGSL_DEVICE(gen7_gmu_to_adreno(gmu)); 1537: char msg_buf[36]; 1538: u32 size; 1539: int ret; 1540: 1541: if (IS_ERR_OR_NULL(gmu->qmp) && IS_ERR_OR_NULL(gmu->mailbox.channel)) 1542: return; 1543: 1544: size = scnprintf(msg_buf, sizeof(msg_buf), 1545: "{class: gpu, res: acd, val: %d}", flag); 1546: 1547: /* mailbox controller expects 4-byte aligned buffer */ 1548: size = ALIGN((size + 1), SZ_4); 1549: 1550: if (gmu->qmp) { 1551: ret = qmp_send(gmu->qmp, msg_buf, size); 1552: } else { 1553: struct qmp_pkt msg; 1554: 1555: msg.size = size; 1556: msg.data = msg_buf; 1557: 1558: ret = mbox_send_message(gmu->mailbox.channel, &msg); 1559: } 1560: 1561: if (ret < 0) 1562: dev_err(GMU_PDEV_DEV(device), 1563: "AOP send message failed: %d\n", ret); 1564: } 1565: 1566: #if IS_ENABLED(CONFIG_QCOM_KGSL_HIBERNATION) 1567: static void gen7_gmu_force_first_boot(struct kgsl_device *device) 1568: { 1569: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1570: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1571: u32 val = 0; 1572: 1573: if (gmu->pdc_cfg_base) { 1574: kgsl_pwrctrl_enable_cx_gdsc(device); 1575: gmu_core_enable_clks(device, 0); 1576: 1577: val = __raw_readl(gmu->pdc_cfg_base + (GEN7_PDC_GPU_ENABLE_PDC << 2)); 1578: 1579: /* Make sure we read val before disabling clks. */ 1580: mb(); 1581: 1582: gmu_core_disable_clks(device); 1583: kgsl_pwrctrl_disable_cx_gdsc(device); 1584: gmu_core_rdpm_cx_freq_update(device, 0); 1585: } 1586: 1587: if (val != GEN7_PDC_ENABLE_REG_VALUE) { 1588: clear_bit(GMU_PRIV_RSCC_SLEEP_DONE, &gmu->flags); 1589: clear_bit(GMU_PRIV_PDC_RSC_LOADED, &gmu->flags); 1590: } 1591: } 1592: #endif 1593: 1594: static int gen7_gmu_first_boot(struct adreno_device *adreno_dev) 1595: { 1596: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1597: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1598: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1599: int level, ret; 1600: 1601: kgsl_pwrctrl_request_state(device, KGSL_STATE_AWARE); 1602: 1603: gen7_gmu_aop_send_acd_state(gmu, adreno_dev->acd_enabled); 1604: 1605: ret = kgsl_pwrctrl_enable_cx_gdsc(device); 1606: if (ret) 1607: return ret; 1608: 1609: ret = gmu_core_enable_clks(device, 0); 1610: if (ret) 1611: goto gdsc_off; 1612: 1613: /* 1614: * Enable AHB timeout detection to catch any register access taking longer 1615: * time before NOC timeout gets detected. Enable this logic before any 1616: * register access which happens to be just after enabling clocks. 1617: */ 1618: gen7_enable_ahb_timeout_detection(adreno_dev); 1619: 1620: /* Initialize the CX timer */ 1621: gen7_cx_timer_init(adreno_dev); 1622: 1623: ret = gen7_gmu_load_fw(adreno_dev); 1624: if (ret) 1625: goto clks_gdsc_off; 1626: 1627: ret = gen7_gmu_version_info(adreno_dev); 1628: if (ret) 1629: goto clks_gdsc_off; 1630: 1631: ret = gen7_gmu_itcm_shadow(adreno_dev); 1632: if (ret) 1633: goto clks_gdsc_off; 1634: 1635: ret = gen7_scm_gpu_init_cx_regs(adreno_dev); 1636: if (ret) 1637: goto clks_gdsc_off; 1638: 1639: gen7_gmu_register_config(adreno_dev); 1640: 1641: gen7_gmu_irq_enable(adreno_dev); 1642: 1643: /* Vote for minimal DDR BW for GMU to init */ 1644: level = pwr->pwrlevels[pwr->default_pwrlevel].bus_min; 1645: icc_set_bw(pwr->icc_path, 0, kBps_to_icc(pwr->ddr_table[level])); 1646: 1647: /* Clear any GPU faults that might have been left over */ 1648: adreno_clear_gpu_fault(adreno_dev); 1649: 1650: ret = gen7_gmu_device_start(adreno_dev); 1651: if (ret) 1652: goto err; 1653: 1654: if (!test_bit(GMU_PRIV_PDC_RSC_LOADED, &gmu->flags)) { 1655: ret = gen7_load_pdc_ucode(adreno_dev); 1656: if (ret) 1657: goto err; 1658: 1659: gen7_load_rsc_ucode(adreno_dev); 1660: set_bit(GMU_PRIV_PDC_RSC_LOADED, &gmu->flags); 1661: } 1662: 1663: ret = gen7_gmu_hfi_start(adreno_dev); 1664: if (ret) 1665: goto err; 1666: 1667: gen7_get_gpu_feature_info(adreno_dev); 1668: 1669: ret = gen7_hfi_start(adreno_dev); 1670: if (ret) 1671: goto err; 1672: 1673: if (adreno_dev->gmu_ab && 1674: gen7_hfi_send_get_value(adreno_dev, HFI_VALUE_GMU_AB_VOTE, 0) == 1 && 1675: !WARN_ONCE(!adreno_dev->gpucore->num_ddr_channels, 1676: "Number of DDR channel is not specified in gpu core")) { 1677: set_bit(ADRENO_DEVICE_GMU_AB, &adreno_dev->priv); 1678: } else { 1679: /* If gmu_ab feature flag is enabled but GMU doesn't support it, set it to false */ 1680: adreno_dev->gmu_ab = false; 1681: } 1682: 1683: icc_set_bw(pwr->icc_path, 0, 0); 1684: 1685: device->gmu_fault = false; 1686: 1687: kgsl_pwrctrl_set_state(device, KGSL_STATE_AWARE); 1688: 1689: return 0; 1690: 1691: err: 1692: gen7_gmu_irq_disable(adreno_dev); 1693: 1694: if (device->gmu_fault) { 1695: gen7_gmu_suspend(adreno_dev, false); 1696: return ret; 1697: } 1698: 1699: clks_gdsc_off: 1700: gmu_core_disable_clks(device); 1701: 1702: gdsc_off: 1703: kgsl_pwrctrl_disable_cx_gdsc(device); 1704: 1705: gmu_core_rdpm_cx_freq_update(device, 0); 1706: 1707: return ret; 1708: } 1709: 1710: static int gen7_gmu_boot(struct adreno_device *adreno_dev) 1711: { 1712: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1713: int ret = 0; 1714: 1715: kgsl_pwrctrl_request_state(device, KGSL_STATE_AWARE); 1716: 1717: ret = kgsl_pwrctrl_enable_cx_gdsc(device); 1718: if (ret) 1719: return ret; 1720: 1721: ret = gmu_core_enable_clks(device, 0); 1722: if (ret) 1723: goto gdsc_off; 1724: 1725: /* 1726: * Enable AHB timeout detection to catch any register access taking longer 1727: * time before NOC timeout gets detected. Enable this logic before any 1728: * register access which happens to be just after enabling clocks. 1729: */ 1730: gen7_enable_ahb_timeout_detection(adreno_dev); 1731: 1732: /* Initialize the CX timer */ 1733: gen7_cx_timer_init(adreno_dev); 1734: 1735: ret = gen7_rscc_wakeup_sequence(adreno_dev); 1736: if (ret) 1737: goto clks_gdsc_off; 1738: 1739: ret = gen7_gmu_load_fw(adreno_dev); 1740: if (ret) 1741: goto clks_gdsc_off; 1742: 1743: gen7_gmu_register_config(adreno_dev); 1744: 1745: gen7_gmu_irq_enable(adreno_dev); 1746: 1747: /* Clear any GPU faults that might have been left over */ 1748: adreno_clear_gpu_fault(adreno_dev); 1749: 1750: ret = gen7_gmu_device_start(adreno_dev); 1751: if (ret) 1752: goto err; 1753: 1754: ret = gen7_gmu_hfi_start(adreno_dev); 1755: if (ret) 1756: goto err; 1757: 1758: ret = gen7_hfi_start(adreno_dev); 1759: if (ret) 1760: goto err; 1761: 1762: device->gmu_fault = false; 1763: 1764: kgsl_pwrctrl_set_state(device, KGSL_STATE_AWARE); 1765: 1766: return 0; 1767: 1768: err: 1769: gen7_gmu_irq_disable(adreno_dev); 1770: 1771: if (device->gmu_fault) { 1772: gen7_gmu_suspend(adreno_dev, false); 1773: return ret; 1774: } 1775: 1776: clks_gdsc_off: 1777: gmu_core_disable_clks(device); 1778: 1779: gdsc_off: 1780: kgsl_pwrctrl_disable_cx_gdsc(device); 1781: 1782: gmu_core_rdpm_cx_freq_update(device, 0); 1783: 1784: return ret; 1785: } 1786: 1787: static void set_acd(struct adreno_device *adreno_dev, void *priv) 1788: { 1789: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1790: 1791: adreno_dev->acd_enabled = *((bool *)priv); 1792: gen7_gmu_aop_send_acd_state(gmu, adreno_dev->acd_enabled); 1793: } 1794: 1795: static int gen7_gmu_acd_set(struct kgsl_device *device, bool val) 1796: { 1797: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1798: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1799: 1800: if (!gmu->qmp && !gmu->mailbox.channel) 1801: return -EINVAL; 1802: 1803: /* Don't do any unneeded work if ACD is already in the correct state */ 1804: if (adreno_dev->acd_enabled == val) 1805: return 0; 1806: 1807: /* Power cycle the GPU for changes to take effect */ 1808: return adreno_power_cycle(adreno_dev, set_acd, &val); 1809: } 1810: 1811: #define BCL_RESP_TYPE_MASK BIT(0) 1812: #define BCL_SID0_MASK GENMASK(7, 1) 1813: #define BCL_SID1_MASK GENMASK(14, 8) 1814: #define BCL_SID2_MASK GENMASK(21, 15) 1815: 1816: static int gen7_bcl_sid_set(struct kgsl_device *device, u32 sid_id, u64 sid_val) 1817: { 1818: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1819: u32 bcl_data, val = (u32) sid_val; 1820: 1821: if (!ADRENO_FEATURE(adreno_dev, ADRENO_BCL) || 1822: !FIELD_GET(BCL_RESP_TYPE_MASK, adreno_dev->bcl_data)) MATCH LINES: 1865, 1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1876, 1878, 1882, 1896, 1902, 1911, 1920, 1921, 1924, 1927, 1928, 1938, 1956, 1957, 1963, 1969, 1993, 1996, 2007, 2013, 2016, 2019, 2020, 2022, 2023, 2028, 2031, 2044, 2054, 2057, 2063, 2068, 2070, 2074, 2076, 2078, 2079, 2088, 2092, 2095, 2100, 2102, 2103, 2110, 2115, 2119, 2120, 2122, 2123, 2130, 2134, 2135, 2145, 2146, 2151, 2155, 2157, 2164, 2169, 2171, 2184, 2185, 2193, 2218, 2220, 2224, 2228, 2236, 2240, 2248, 2255, 2257, 2259, 2263, 2270, 2271, 2272, 2290, 2306, 2308, 2310, 2312, 2337, 2353, 2357, 2358, 2361, 2366, 2376, 2381, 2387, 2398, 2400, 2413, 2428, 2431, 2432, 2450, 2456, 2471, 2472 1853: switch (sid_id) { 1854: case 0: 1855: return ((u64) FIELD_GET(BCL_SID0_MASK, adreno_dev->bcl_data)); 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) 1894: buslevel = INVALID_DCVS_IDX; 1895: 1896: if ((ab == pwr->cur_ab) || ((ab == 0) && (adreno_dev->gmu_ab))) 1897: ab = INVALID_AB_VALUE; 1898: 1899: if ((ab == INVALID_AB_VALUE) && (buslevel == INVALID_DCVS_IDX)) 1900: return 0; 1901: 1902: ret = gen7_gmu_dcvs_set(adreno_dev, INVALID_DCVS_IDX, 1903: buslevel, ab); 1904: if (ret) 1905: return ret; 1906: 1907: if (buslevel != INVALID_DCVS_IDX) 1908: pwr->cur_buslevel = buslevel; 1909: 1910: if (ab != INVALID_AB_VALUE) { 1911: if (!adreno_dev->gmu_ab) 1912: icc_set_bw(pwr->icc_path, MBps_to_icc(ab), 0); 1913: pwr->cur_ab = ab; 1914: } 1915: 1916: trace_kgsl_buslevel(device, pwr->active_pwrlevel, pwr->cur_buslevel, pwr->cur_ab, 0); 1917: return ret; 1918: } 1919: 1920: static int gen7_gmu_aop_messaging_init(struct adreno_device *adreno_dev, 1921: struct gen7_gmu_device *gmu) 1922: { 1923: struct kgsl_mailbox *mailbox = &gmu->mailbox; 1924: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)); 1925: int ret; 1926: 1927: if (of_find_property(gmu_pdev_dev->of_node, "qcom,qmp", NULL)) { 1928: gmu->qmp = qmp_get(gmu_pdev_dev); 1929: ret = PTR_ERR_OR_ZERO(gmu->qmp); 1930: if (ret) { 1931: /* Clear the error pointer to ensure a clean state */ 1932: gmu->qmp = NULL; 1933: return ret; 1934: } 1935: goto done; 1936: } 1937: 1938: mailbox->client.dev = gmu_pdev_dev; 1939: mailbox->client.tx_block = true; 1940: mailbox->client.tx_tout = 1000; 1941: mailbox->client.knows_txdone = false; 1942: 1943: mailbox->channel = mbox_request_channel(&mailbox->client, 0); 1944: ret = PTR_ERR_OR_ZERO(mailbox->channel); 1945: if (ret) { 1946: mailbox->channel = NULL; 1947: return ret; 1948: } 1949: 1950: done: 1951: adreno_dev->acd_enabled = true; 1952: 1953: return 0; 1954: } 1955: 1956: static int gen7_gmu_acd_probe(struct kgsl_device *device, 1957: struct gen7_gmu_device *gmu, struct device_node *node) 1958: { 1959: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1960: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1961: struct kgsl_pwrlevel *pwrlevel = 1962: &pwr->pwrlevels[pwr->num_pwrlevels - 1]; 1963: struct hfi_acd_table_cmd *cmd = &gmu->hfi.acd_table; 1964: int ret, i, cmd_idx = 0; 1965: 1966: if (!ADRENO_FEATURE(adreno_dev, ADRENO_ACD)) 1967: return 0; 1968: 1969: cmd->hdr = CREATE_MSG_HDR(H2F_MSG_ACD_TBL, HFI_MSG_CMD); 1970: 1971: cmd->version = 1; 1972: cmd->stride = 1; 1973: cmd->enable_by_level = 0; 1974: 1975: /* 1976: * Iterate through each gpu power level and generate a mask for GMU 1977: * firmware for ACD enabled levels and store the corresponding control 1978: * register configurations to the acd_table structure. 1979: */ 1980: for (i = 0; i < pwr->num_pwrlevels; i++) { 1981: if (pwrlevel->acd_level) { 1982: cmd->enable_by_level |= (1 << (i + 1)); 1983: cmd->data[cmd_idx++] = pwrlevel->acd_level; 1984: } 1985: pwrlevel--; 1986: } 1987: 1988: if (!cmd->enable_by_level) 1989: return 0; 1990: 1991: cmd->num_levels = cmd_idx; 1992: 1993: ret = gen7_gmu_aop_messaging_init(adreno_dev, gmu); 1994: 1995: if (ret) 1996: dev_err_probe(GMU_PDEV_DEV(device), ret, 1997: "AOP messaging init failed\n"); 1998: 1999: /* 2000: * Only fail probe for -EPROBE_DEFER; ignore other errors to avoid 2001: * failing probe if ACD init fails. 2002: */ 2003: 2004: return ret == -EPROBE_DEFER ? ret : 0; 2005: } 2006: 2007: static int gen7_gmu_reg_probe(struct adreno_device *adreno_dev) 2008: { 2009: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2010: int ret; 2011: 2012: ret = kgsl_regmap_add_region(&device->regmap, 2013: GMU_PDEV(device), "gmu", -EINVAL, NULL, NULL); 2014: 2015: if (ret) 2016: dev_err(GMU_PDEV_DEV(device), 2017: "Unable to map the GMU registers\n"); 2018: /* 2019: * gmu_ao_blk_dec1 and gmu_ao_blk_dec2 are contiguous and contained within the gmu region 2020: * mapped above. gmu_ao_blk_dec0 is not within the gmu region and is mapped separately. 2021: */ 2022: kgsl_regmap_add_region(&device->regmap, GMU_PDEV(device), 2023: "gmu_ao_blk_dec0", -EINVAL, NULL, NULL); 2024: 2025: return ret; 2026: } 2027: 2028: void gen7_gmu_remove(struct kgsl_device *device) 2029: { 2030: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 2031: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 2032: 2033: if (gmu->qmp) 2034: qmp_put(gmu->qmp); 2035: 2036: if (gmu->mailbox.channel) 2037: mbox_free_channel(gmu->mailbox.channel); 2038: 2039: adreno_dev->acd_enabled = false; 2040: 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 */ 2082: res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rscc"); 2083: if (!res) 2084: res = platform_get_resource_byname(device->pdev, 2085: IORESOURCE_MEM, "rscc"); 2086: 2087: if (!res) { 2088: dev_err(GMU_PDEV_DEV(device), "Failed to get rscc resource\n"); 2089: return -ENODEV; 2090: } 2091: 2092: gmu->rscc_virt = devm_ioremap(GMU_PDEV_DEV(device), res->start, 2093: resource_size(res)); 2094: if (!gmu->rscc_virt) { 2095: dev_err(GMU_PDEV_DEV(device), "rscc ioremap failed\n"); 2096: return -ENOMEM; 2097: } 2098: 2099: /* Setup any rdpm register ranges */ 2100: gmu_core_rdpm_probe(device); 2101: 2102: device->gmu_core.rdpm_cx_offset = GEN7_RDPM_CX_OFFSET; 2103: device->gmu_core.rdpm_mx_offset = GEN7_RDPM_MX_OFFSET; 2104: 2105: /* Set up GMU gdscs */ 2106: ret = kgsl_pwrctrl_probe_gdscs(device, pdev); 2107: if (ret) 2108: return ret; 2109: 2110: ret = gmu_core_clk_probe(device); 2111: if (ret) 2112: return ret; 2113: 2114: /* Set up GMU IOMMU and shared memory with GMU */ 2115: ret = gmu_core_iommu_init(device); 2116: if (ret) 2117: goto error; 2118: 2119: device->gmu_core.vma = gen7_gmu_vma; 2120: device->gmu_core.num_vmas = ARRAY_SIZE(gen7_gmu_vma); 2121: 2122: for (i = 0; i < device->gmu_core.num_vmas; i++) { 2123: struct gmu_vma_entry *vma = &gen7_gmu_vma[i]; 2124: 2125: vma->vma_root = RB_ROOT; 2126: spin_lock_init(&vma->lock); 2127: } 2128: 2129: /* Map and reserve GMU CSRs registers */ 2130: ret = gen7_gmu_reg_probe(adreno_dev); 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 */ 2171: gmu->stats_interval = HFI_FEATURE_GMU_STATS_INTERVAL; 2172: 2173: /* GMU sysfs nodes setup */ 2174: ret = kobject_init_and_add(&gmu->log_kobj, &log_kobj_type, &dev->kobj, "log"); 2175: if (ret) 2176: dev_err(dev, "Failed to add log_kobj: %d\n", ret); 2177: 2178: ret = kobject_init_and_add(&gmu->stats_kobj, &stats_kobj_type, &dev->kobj, "stats"); 2179: if (ret) 2180: dev_err(dev, "Failed to add stats_kobj: %d\n", ret); 2181: 2182: spin_lock_init(&gmu->hfi.cmdq_lock); 2183: 2184: gmu->irq = kgsl_request_irq(GMU_PDEV(device), "gmu", NULL, -EINVAL, 2185: gen7_gmu_irq_handler, device); 2186: 2187: if (gmu->irq >= 0) 2188: return 0; 2189: 2190: ret = gmu->irq; 2191: 2192: error: 2193: gen7_gmu_remove(device); 2194: return ret; 2195: } 2196: 2197: int gen7_halt_gbif(struct adreno_device *adreno_dev) 2198: { 2199: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2200: int ret; 2201: 2202: /* Halt new client requests */ 2203: kgsl_regwrite(device, GEN7_GBIF_HALT, GEN7_GBIF_CLIENT_HALT_MASK); 2204: ret = adreno_wait_for_halt_ack(device, 2205: GEN7_GBIF_HALT_ACK, GEN7_GBIF_CLIENT_HALT_MASK); 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; 2243: 2244: ret = gen7_rscc_sleep_sequence(adreno_dev); 2245: if (ret) 2246: goto error; 2247: 2248: gmu_core_rdpm_mx_freq_update(device, 0); 2249: 2250: /* Now that we are done with GMU and GPU, Clear the GBIF */ 2251: ret = gen7_halt_gbif(adreno_dev); 2252: if (ret) 2253: goto error; 2254: 2255: gen7_gmu_irq_disable(adreno_dev); 2256: 2257: gen7_hfi_stop(adreno_dev); 2258: 2259: gmu_core_disable_clks(device); 2260: 2261: kgsl_pwrctrl_disable_cx_gdsc(device); 2262: 2263: gmu_core_rdpm_cx_freq_update(device, 0); 2264: 2265: kgsl_pwrctrl_set_state(device, KGSL_STATE_NONE); 2266: 2267: return 0; 2268: 2269: error: 2270: gen7_gmu_irq_disable(adreno_dev); 2271: gen7_hfi_stop(adreno_dev); 2272: gen7_gmu_suspend(adreno_dev, false); 2273: 2274: return ret; 2275: } 2276: 2277: void gen7_enable_gpu_irq(struct adreno_device *adreno_dev) 2278: { 2279: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2280: 2281: kgsl_pwrctrl_irq(device, true); 2282: 2283: adreno_irqctrl(adreno_dev, 1); 2284: } 2285: 2286: void gen7_disable_gpu_irq(struct adreno_device *adreno_dev) 2287: { 2288: kgsl_pwrctrl_irq(KGSL_DEVICE(adreno_dev), false); 2289: 2290: if (gen7_gmu_gx_is_on(adreno_dev)) 2291: adreno_irqctrl(adreno_dev, 0); 2292: } 2293: 2294: static int gen7_gpu_boot(struct adreno_device *adreno_dev) 2295: { 2296: const struct adreno_gen7_core *gen7_core = to_gen7_core(adreno_dev); 2297: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2298: int ret; 2299: 2300: adreno_set_active_ctxs_null(adreno_dev); 2301: 2302: ret = kgsl_mmu_start(device); 2303: if (ret) 2304: goto err; 2305: 2306: ret = gen7_gmu_oob_set(device, oob_gpu); 2307: if (ret) 2308: goto oob_clear; 2309: 2310: ret = gen7_gmu_hfi_start_msg(adreno_dev); 2311: if (ret) 2312: goto oob_clear; 2313: 2314: /* Clear the busy_data stats - we're starting over from scratch */ 2315: memset(&adreno_dev->busy_data, 0, sizeof(adreno_dev->busy_data)); 2316: 2317: gen7_start(adreno_dev); 2318: 2319: if (gen7_core->qos_value && adreno_is_preemption_enabled(adreno_dev)) 2320: kgsl_regwrite(device, GEN7_RBBM_GBIF_CLIENT_QOS_CNTL, 2321: gen7_core->qos_value[adreno_dev->cur_rb->id]); 2322: 2323: /* Re-initialize the coresight registers if applicable */ 2324: adreno_coresight_start(adreno_dev); 2325: 2326: adreno_perfcounter_start(adreno_dev); 2327: 2328: /* Clear FSR here in case it is set from a previous pagefault */ 2329: kgsl_mmu_clear_fsr(&device->mmu); 2330: 2331: gen7_enable_gpu_irq(adreno_dev); 2332: 2333: ret = gen7_rb_start(adreno_dev); 2334: if (ret) { 2335: gen7_disable_gpu_irq(adreno_dev); 2336: adreno_llcc_slice_deactivate(adreno_dev); 2337: goto oob_clear; 2338: } 2339: 2340: /* 2341: * At this point it is safe to assume that we recovered. Setting 2342: * this field allows us to take a new snapshot for the next failure 2343: * if we are prioritizing the first unrecoverable snapshot. 2344: */ 2345: if (device->snapshot) 2346: device->snapshot->recovered = true; 2347: 2348: /* Start the dispatcher */ 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: 2386: if (IS_ENABLED(CONFIG_QCOM_KGSL_HIBERNATION) && 2387: !test_bit(GMU_PRIV_PDC_RSC_LOADED, &gmu->flags)) { 2388: /* 2389: * During hibernation entry ZAP was unloaded and 2390: * CBCAST BCL register is in reset state. 2391: * Set bcl_enabled to false to skip KMD's HFI request 2392: * to GMU for BCL feature, send BCL feature request to 2393: * GMU after ZAP load at GPU boot. This ensures that 2394: * Central Broadcast register was programmed before 2395: * enabling BCL. 2396: */ 2397: adreno_dev->bcl_enabled = false; 2398: ret = gen7_gmu_first_boot(adreno_dev); 2399: } else { 2400: ret = gen7_gmu_boot(adreno_dev); 2401: } 2402: 2403: if (ret) 2404: return ret; 2405: 2406: ret = gen7_gpu_boot(adreno_dev); 2407: if (ret) 2408: return ret; 2409: 2410: kgsl_start_idle_timer(device); 2411: kgsl_pwrscale_wake(device); 2412: 2413: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 2414: 2415: if (IS_ENABLED(CONFIG_QCOM_KGSL_HIBERNATION)) 2416: adreno_dev->bcl_enabled = bcl_state; 2417: 2418: device->pwrctrl.last_stat_updated = ktime_get(); 2419: 2420: kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE); 2421: 2422: return ret; 2423: } 2424: 2425: static int gen7_first_boot(struct adreno_device *adreno_dev) 2426: { 2427: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2428: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 2429: int ret; 2430: 2431: if (test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags)) { 2432: if (!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 2433: return gen7_boot(adreno_dev); 2434: 2435: return 0; 2436: } 2437: 2438: ret = gen7_ringbuffer_init(adreno_dev); 2439: if (ret) 2440: return ret; 2441: 2442: ret = gen7_microcode_read(adreno_dev); 2443: if (ret) 2444: return ret; 2445: 2446: ret = gen7_init(adreno_dev); 2447: if (ret) 2448: return ret; 2449: 2450: ret = gen7_gmu_init(adreno_dev); 2451: if (ret) 2452: return ret; 2453: 2454: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE); 2455: 2456: ret = gen7_gmu_first_boot(adreno_dev); 2457: if (ret) 2458: return ret; 2459: 2460: ret = gen7_gpu_boot(adreno_dev); 2461: if (ret) 2462: return ret; 2463: 2464: adreno_get_bus_counters(adreno_dev); 2465: 2466: adreno_dev->cooperative_reset = ADRENO_FEATURE(adreno_dev, 2467: ADRENO_COOP_RESET); 2468: 2469: adreno_create_profile_buffer(adreno_dev); 2470: 2471: set_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags); 2472: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 2473: 2474: /* 2475: * BCL needs respective Central Broadcast register to 2476: * be programed from TZ. For kernel version prior to 6.1, this 2477: * programing happens only when zap shader firmware load is successful. 2478: * Zap firmware load can fail in boot up path hence enable BCL only 2479: * after we successfully complete first boot to ensure that Central 2480: * Broadcast register was programed before enabling BCL. 2481: */ 2482: if (ADRENO_FEATURE(adreno_dev, ADRENO_BCL)) 2483: adreno_dev->bcl_enabled = true; 2484: 2485: /* 2486: * There is a possible deadlock scenario during kgsl firmware reading 2487: * (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl 2488: * device mutex is held and then firmware_request_nowarn is called for reading 2489: * firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock. 2490: * Whereas in case of devfreq update calls triggered by thermal/bcl or 2491: * devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then 2492: * tries to take kgsl device mutex as part of get_dev_status/target 2493: * calls. This results in deadlock when both thread are unable to acquire 2494: * the mutex held by other thread. Enable devfreq updates now as we are 2495: * done reading all firmware files. 2496: */ MATCH LINES: 2523, 2526, 2532, 2537, 2549, 2553, 2563, 2583, 2588, 2593, 2601, 2626, 2650, 2652, 2654, 2660, 2663, 2669, 2673, 2685, 2688, 2691, 2700, 2703, 2715, 2718, 2720, 2728, 2731, 2734, 2741, 2742, 2745, 2750, 2760, 2777, 2778, 2779, 2780, 2781, 2782, 2783, 2784, 2785, 2788, 2817, 2819, 2829, 2831, 2835, 2837, 2840, 2846, 2852, 2854, 2855, 2858, 2859, 2864, 2875, 2876, 2881, 2886, 2894, 2898, 2899, 2902, 2910, 2918, 2919, 2921, 2924, 2925, 2926, 2929, 2941, 2945, 2947, 2950, 2952, 2957, 2963, 2964, 2965, 2968 2511: u32 status; 2512: 2513: kgsl_regread(device, GEN7_RBBM_INT_0_STATUS, &status); 2514: 2515: /* Return busy if a interrupt is pending */ 2516: return ((status & adreno_dev->irq_mask) || 2517: atomic_read(&adreno_dev->pending_irq_refcnt)); 2518: } 2519: 2520: static int gen7_power_off(struct adreno_device *adreno_dev) 2521: { 2522: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2523: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 2524: int ret; 2525: 2526: WARN_ON(!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)); 2527: 2528: adreno_check_idle(device); 2529: 2530: kgsl_pwrctrl_request_state(device, KGSL_STATE_SLUMBER); 2531: 2532: ret = gen7_gmu_oob_set(device, oob_gpu); 2533: if (ret) 2534: goto no_gx_power; 2535: 2536: if (gen7_irq_pending(adreno_dev)) { 2537: gen7_gmu_oob_clear(device, oob_gpu); 2538: return -EBUSY; 2539: } 2540: 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: 2578: kgsl_pwrctrl_set_state(device, KGSL_STATE_SLUMBER); 2579: 2580: return ret; 2581: } 2582: 2583: static void gmu_idle_check(struct work_struct *work) 2584: { 2585: struct kgsl_device *device = container_of(work, 2586: struct kgsl_device, idle_check_ws); 2587: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 2588: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 2589: int ret; 2590: 2591: kgsl_mutex_lock(&device->mutex); 2592: 2593: if (test_bit(GMU_DISABLE_SLUMBER, &device->gmu_core.flags)) 2594: goto done; 2595: 2596: if (atomic_read(&device->active_cnt) || time_is_after_jiffies(device->idle_jiffies)) { 2597: kgsl_pwrscale_update(device); 2598: goto done; 2599: } 2600: 2601: if (!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 2602: goto done; 2603: 2604: spin_lock(&device->submit_lock); 2605: 2606: if (device->submit_now) { 2607: spin_unlock(&device->submit_lock); 2608: kgsl_pwrscale_update(device); 2609: kgsl_start_idle_timer(device); 2610: goto done; 2611: } 2612: 2613: device->skip_inline_submit = true; 2614: spin_unlock(&device->submit_lock); 2615: 2616: ret = gen7_power_off(adreno_dev); 2617: if (ret == -EBUSY) { 2618: kgsl_pwrscale_update(device); 2619: kgsl_start_idle_timer(device); 2620: } 2621: 2622: done: 2623: kgsl_mutex_unlock(&device->mutex); 2624: } 2625: 2626: static int gen7_gmu_first_open(struct adreno_device *adreno_dev) 2627: { 2628: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2629: int ret; 2630: 2631: /* 2632: * Do the one time settings that need to happen when we 2633: * attempt to boot the gpu the very first time 2634: */ 2635: ret = gen7_first_boot(adreno_dev); 2636: if (ret) 2637: return ret; 2638: 2639: /* 2640: * A client that does a first_open but never closes the device 2641: * may prevent us from going back to SLUMBER. So trigger the idle 2642: * check by incrementing the active count and immediately releasing it. 2643: */ 2644: atomic_inc(&device->active_cnt); 2645: adreno_active_count_put(adreno_dev); 2646: 2647: return 0; 2648: } 2649: 2650: static int gen7_gmu_last_close(struct adreno_device *adreno_dev) 2651: { 2652: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 2653: 2654: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 2655: return gen7_power_off(adreno_dev); 2656: 2657: return 0; 2658: } 2659: 2660: static int gen7_gmu_active_count_get(struct adreno_device *adreno_dev) 2661: { 2662: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2663: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 2664: int ret = 0; 2665: 2666: if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex))) 2667: return -EINVAL; 2668: 2669: if (test_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags)) 2670: return -EINVAL; 2671: 2672: if ((atomic_read(&device->active_cnt) == 0) && 2673: !test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 2674: ret = gen7_boot(adreno_dev); 2675: 2676: if (ret == 0) 2677: atomic_inc(&device->active_cnt); 2678: 2679: trace_kgsl_active_count(device, 2680: (unsigned long) __builtin_return_address(0)); 2681: 2682: return ret; 2683: } 2684: 2685: static int gen7_gmu_pm_suspend(struct adreno_device *adreno_dev) 2686: { 2687: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2688: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 2689: int ret; 2690: 2691: if (test_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags)) 2692: return 0; 2693: 2694: kgsl_pwrctrl_request_state(device, KGSL_STATE_SUSPEND); 2695: 2696: ret = adreno_drain_and_idle(device); 2697: if (ret) 2698: goto err; 2699: 2700: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 2701: gen7_power_off(adreno_dev); 2702: 2703: set_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags); 2704: 2705: adreno_get_gpu_halt(adreno_dev); 2706: 2707: kgsl_pwrctrl_set_state(device, KGSL_STATE_SUSPEND); 2708: 2709: return 0; 2710: err: 2711: adreno_dispatcher_start(device); 2712: return ret; 2713: } 2714: 2715: static void gen7_gmu_pm_resume(struct adreno_device *adreno_dev) 2716: { 2717: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2718: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 2719: 2720: if (WARN(!test_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags), 2721: "resume invoked without a suspend\n")) 2722: return; 2723: 2724: adreno_put_gpu_halt(adreno_dev); 2725: 2726: adreno_dispatcher_start(device); 2727: 2728: clear_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags); 2729: } 2730: 2731: static void gen7_gmu_touch_wakeup(struct adreno_device *adreno_dev) 2732: { 2733: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2734: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 2735: int ret; 2736: 2737: /* 2738: * Do not wake up a suspended device or until the first boot sequence 2739: * has been completed. 2740: */ 2741: if (test_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags) || 2742: !test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags)) 2743: return; 2744: 2745: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 2746: goto done; 2747: 2748: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE); 2749: 2750: ret = gen7_gmu_boot(adreno_dev); 2751: if (ret) 2752: return; 2753: 2754: ret = gen7_gpu_boot(adreno_dev); 2755: if (ret) 2756: return; 2757: 2758: kgsl_pwrscale_wake(device); 2759: 2760: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 2761: 2762: device->pwrctrl.last_stat_updated = ktime_get(); 2763: 2764: kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE); 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; 2802: 2803: adreno_dev->irq_mask = GEN7_INT_MASK; 2804: 2805: ret = gen7_probe_common(pdev, adreno_dev, chipid, gpucore); 2806: if (ret) 2807: return ret; 2808: 2809: ret = adreno_dispatcher_init(adreno_dev); 2810: if (ret) { 2811: dev_err(&pdev->dev, "adreno dispatcher init failed ret %d\n", ret); 2812: return ret; 2813: } 2814: 2815: device = KGSL_DEVICE(adreno_dev); 2816: 2817: INIT_WORK(&device->idle_check_ws, gmu_idle_check); 2818: 2819: timer_setup(&device->idle_timer, gmu_idle_timer, 0); 2820: 2821: if (ADRENO_FEATURE(adreno_dev, ADRENO_DMS)) { 2822: set_bit(ADRENO_DEVICE_DMS, &adreno_dev->priv); 2823: adreno_dev->dms_enabled = true; 2824: } 2825: 2826: return 0; 2827: } 2828: 2829: int gen7_gmu_reset(struct adreno_device *adreno_dev) 2830: { 2831: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 2832: 2833: gen7_disable_gpu_irq(adreno_dev); 2834: 2835: gen7_gmu_irq_disable(adreno_dev); 2836: 2837: gen7_hfi_stop(adreno_dev); 2838: 2839: /* Hard reset the gmu and gpu */ 2840: gen7_gmu_suspend(adreno_dev, true); 2841: 2842: gen7_reset_preempt_records(adreno_dev); 2843: 2844: adreno_llcc_slice_deactivate(adreno_dev); 2845: 2846: clear_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 2847: 2848: /* Attempt to reboot the gmu and gpu */ 2849: return gen7_boot(adreno_dev); 2850: } 2851: 2852: int gen7_gmu_hfi_probe(struct adreno_device *adreno_dev) 2853: { 2854: struct platform_device *gmu_pdev = GMU_PDEV(KGSL_DEVICE(adreno_dev)); 2855: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 2856: struct gen7_hfi *hfi = &gmu->hfi; 2857: 2858: hfi->irq = kgsl_request_irq(gmu_pdev, "hfi", NULL, -EINVAL, 2859: gen7_hfi_irq_handler, KGSL_DEVICE(adreno_dev)); 2860: 2861: return hfi->irq < 0 ? hfi->irq : 0; 2862: } 2863: 2864: int gen7_gmu_add_to_minidump(struct adreno_device *adreno_dev) 2865: { 2866: struct gen7_device *gen7_dev = container_of(adreno_dev, 2867: struct gen7_device, adreno_dev); 2868: int ret; 2869: 2870: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, KGSL_GEN7_DEVICE, 2871: (void *)(gen7_dev), sizeof(struct gen7_device)); 2872: if (ret) 2873: return ret; 2874: 2875: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, KGSL_GMU_LOG_ENTRY, 2876: gen7_dev->gmu.gmu_log->hostptr, gen7_dev->gmu.gmu_log->size); 2877: if (ret) 2878: return ret; 2879: 2880: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, KGSL_HFIMEM_ENTRY, 2881: gen7_dev->gmu.hfi.hfi_mem->hostptr, gen7_dev->gmu.hfi.hfi_mem->size); 2882: 2883: return ret; 2884: } 2885: 2886: static int gen7_gmu_bind(struct device *dev, struct device *master, void *data) 2887: { 2888: struct kgsl_device *device = dev_get_drvdata(master); 2889: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 2890: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 2891: const struct gen7_gpudev *gen7_gpudev = to_gen7_gpudev(gpudev); 2892: int ret; 2893: 2894: ret = gen7_gmu_probe(device, to_platform_device(dev)); 2895: if (ret) 2896: return ret; 2897: 2898: if (gen7_gpudev->hfi_probe) { 2899: ret = gen7_gpudev->hfi_probe(adreno_dev); 2900: 2901: if (ret) { 2902: gen7_gmu_remove(device); 2903: return ret; 2904: } 2905: } 2906: 2907: return 0; 2908: } 2909: 2910: static void gen7_gmu_unbind(struct device *dev, struct device *master, 2911: void *data) 2912: { 2913: struct kgsl_device *device = dev_get_drvdata(master); 2914: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 2915: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 2916: const struct gen7_gpudev *gen7_gpudev = to_gen7_gpudev(gpudev); 2917: 2918: if (gen7_gpudev->hfi_remove) 2919: gen7_gpudev->hfi_remove(adreno_dev); 2920: 2921: gen7_gmu_remove(device); 2922: } 2923: 2924: static const struct component_ops gen7_gmu_component_ops = { 2925: .bind = gen7_gmu_bind, 2926: .unbind = gen7_gmu_unbind, 2927: }; 2928: 2929: static int gen7_gmu_probe_dev(struct platform_device *pdev) 2930: { 2931: /* 2932: * Let us say there are two devices. One with "qcom,adreno-gmu" compatible 2933: * and one with "qcom,gpu-gmu" compatible. In this case probe only the 2934: * device with legacy compatible string and return error for the device 2935: * with "qcom,adreno-gmu". 2936: */ 2937: if (of_device_is_compatible(pdev->dev.of_node, "qcom,adreno-gmu") && 2938: kgsl_is_compatible_node_available("qcom,gpu-gmu")) 2939: return -ENODEV; 2940: 2941: return component_add(&pdev->dev, &gen7_gmu_component_ops); 2942: } 2943: 2944: #if (KERNEL_VERSION(6, 10, 0) <= LINUX_VERSION_CODE) 2945: static void gen7_gmu_remove_dev(struct platform_device *pdev) 2946: { 2947: component_del(&pdev->dev, &gen7_gmu_component_ops); 2948: } 2949: #else 2950: static int gen7_gmu_remove_dev(struct platform_device *pdev) 2951: { 2952: component_del(&pdev->dev, &gen7_gmu_component_ops); 2953: return 0; 2954: } 2955: #endif 2956: 2957: static const struct of_device_id gen7_gmu_match_table[] = { 2958: { .compatible = "qcom,gen7-gmu" }, 2959: { .compatible = "qcom,adreno-gmu" }, 2960: { }, 2961: }; 2962: 2963: struct platform_driver gen7_gmu_driver = { 2964: .probe = gen7_gmu_probe_dev, 2965: .remove = gen7_gmu_remove_dev, 2966: .driver = { 2967: .name = "adreno-gen7-gmu", 2968: .of_match_table = gen7_gmu_match_table, 2969: }, 2970: }; --- FILE: \adreno_gen7_gmu.h | HITS: 69 --- MATCH LINES: 6, 7, 13, 17, 23, 27, 33, 36, 37, 38, 65, 66, 86, 89, 102, 108, 111, 118, 122, 127, 142, 149, 153, 161, 165, 170, 173, 180, 183, 189, 192, 199, 202, 207, 210, 215, 218, 223, 226, 231, 234, 239, 242, 245, 248, 251, 254, 261, 264, 266, 268, 272, 275, 277, 279, 282, 285, 292, 295, 300 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) 2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: #ifndef __ADRENO_GEN7_GMU_H 7: #define __ADRENO_GEN7_GMU_H 8: 9: #include 10: #include 11: 12: #include "adreno_gen7_hfi.h" 13: #include "kgsl_gmu_core.h" 14: 15: struct gen7_dcvs_table { 16: u32 gpu_level_num; 17: u32 gmu_level_num; 18: struct opp_gx_desc gx_votes[MAX_GX_LEVELS]; 19: struct opp_desc cx_votes[MAX_CX_LEVELS_LEGACY]; 20: }; 21: 22: /** 23: * struct gen7_gmu_device - GMU device structure 24: * @ver: GMU Version information 25: * @irq: GMU interrupt number 26: * @fw_image: GMU FW image 27: * @gmu_log: gmu event log memory 28: * @hfi: HFI controller 29: * @idle_level: Minimal GPU idle power level 30: * @mailbox: Messages to AOP for ACD enable/disable go through this 31: * @log_wptr_retention: Store the log wptr offset on slumber 32: */ 33: struct gen7_gmu_device { 34: int irq; 35: const struct firmware *fw_image; 36: struct kgsl_memdesc *gmu_log; 37: /** @gmu_init_scratch: Memory to store the initial HFI messages */ 38: struct kgsl_memdesc *gmu_init_scratch; 39: /** @gpu_boot_scratch: Memory to store the bootup HFI messages */ 40: struct kgsl_memdesc *gpu_boot_scratch; 41: struct gen7_hfi hfi; 42: unsigned int idle_level; 43: /** @qmp: Pointer to qmp struct used for AOP messages*/ 44: struct qmp *qmp; 45: struct kgsl_mailbox mailbox; 46: unsigned int log_wptr_retention; 47: /** @cm3_fault: whether gmu received a cm3 fault interrupt */ 48: atomic_t cm3_fault; 49: /** 50: * @itcm_shadow: Copy of the itcm block in firmware binary used for 51: * snapshot 52: */ 53: void *itcm_shadow; 54: /** @flags: Internal gmu flags */ 55: unsigned long flags; 56: /** @rscc_virt: Pointer where RSCC block is mapped */ 57: void __iomem *rscc_virt; 58: /** @log_stream_enable: GMU log streaming enable. Disabled by default */ 59: bool log_stream_enable; 60: /** @log_group_mask: Allows overriding default GMU log group mask */ 61: u32 log_group_mask; 62: struct kobject log_kobj; 63: /** @pdc_cfg_base: Base address of PDC cfg registers */ 64: void __iomem *pdc_cfg_base; 65: /** @num_oob_perfcntr: Number of active oob_perfcntr requests */ 66: u32 num_oob_perfcntr; 67: /** @acd_debug_val: DVM value to calibrate ACD for a level */ 68: u32 acd_debug_val; 69: /** @stats_enable: GMU stats feature enable */ 70: bool stats_enable; 71: /** @stats_mask: GMU performance countables to enable */ 72: u32 stats_mask; 73: /** @stats_interval: GMU performance counters sampling interval */ 74: u32 stats_interval; 75: /** @stats_kobj: kernel object for GMU stats directory in sysfs */ 76: struct kobject stats_kobj; 77: /** @cp_init_hdr: raw command header for cp_init */ 78: u32 cp_init_hdr; 79: /** @switch_to_unsec_hdr: raw command header for switch to unsecure packet */ 80: u32 switch_to_unsec_hdr; 81: /** @dcvs_table: Table for gpu dcvs levels */ 82: struct gen7_dcvs_table dcvs_table; 83: }; 84: 85: /* Helper function to get to gen7 gmu device from adreno device */ 86: struct gen7_gmu_device *to_gen7_gmu(struct adreno_device *adreno_dev); 87: 88: /* Helper function to get to adreno device from gen7 gmu device */ 89: struct adreno_device *gen7_gmu_to_adreno(struct gen7_gmu_device *gmu); 90: 91: /** 92: * gen7_build_rpmh_tables - Build the rpmh tables 93: * @adreno_dev: Pointer to the adreno device 94: * 95: * This function creates the gpu dcvs and bw tables 96: * 97: * Return: 0 on success and negative error on failure 98: */ 99: int gen7_build_rpmh_tables(struct adreno_device *adreno_dev); 100: 101: /** 102: * gen7_gmu_gx_is_on - Check if GX is on 103: * @adreno_dev: Pointer to the adreno device 104: * 105: * This function reads pwr status registers to check if GX 106: * is on or off 107: */ 108: bool gen7_gmu_gx_is_on(struct adreno_device *adreno_dev); 109: 110: /** 111: * gen7_gmu_device_probe - GEN7 GMU snapshot function 112: * @pdev: Pointer to the platform device 113: * @chipid: Chipid of the target 114: * @gpucore: Pointer to the gpucore 115: * 116: * The target specific probe function for gmu based gen7 targets. 117: */ 118: int gen7_gmu_device_probe(struct platform_device *pdev, 119: u32 chipid, const struct adreno_gpu_core *gpucore); 120: 121: /** 122: * gen7_gmu_reset - Reset and restart the gmu 123: * @adreno_dev: Pointer to the adreno device 124: * 125: * Return: 0 on success or negative error on failure 126: */ 127: int gen7_gmu_reset(struct adreno_device *adreno_dev); 128: 129: /** 130: * gen7_enable_gpu_irq - Enable gpu interrupt 131: * @adreno_dev: Pointer to the adreno device 132: */ 133: void gen7_enable_gpu_irq(struct adreno_device *adreno_dev); 134: 135: /** 136: * gen7_disable_gpu_irq - Disable gpu interrupt 137: * @adreno_dev: Pointer to the adreno device 138: */ 139: void gen7_disable_gpu_irq(struct adreno_device *adreno_dev); 140: 141: /** 142: * gen7_gmu_snapshot- Take snapshot for gmu targets 143: * @adreno_dev: Pointer to the adreno device 144: * @snapshot: Pointer to the snapshot structure 145: * 146: * Send an NMI to gmu if we hit a gmu fault. Then take gmu 147: * snapshot and carry on with rest of the gen7 snapshot 148: */ 149: void gen7_gmu_snapshot(struct adreno_device *adreno_dev, 150: struct kgsl_snapshot *snapshot); 151: 152: /** 153: * gen7_gmu_probe - Probe gen7 gmu resources 154: * @device: Pointer to the kgsl device 155: * @pdev: Pointer to the gmu platform device 156: * 157: * Probe the gmu and hfi resources 158: * 159: * Return: 0 on success or negative error on failure 160: */ 161: int gen7_gmu_probe(struct kgsl_device *device, 162: struct platform_device *pdev); 163: 164: /** 165: * gen7_gmu_parse_fw - Parse the gmu fw binary 166: * @adreno_dev: Pointer to the adreno device 167: * 168: * Return: 0 on success or negative error on failure 169: */ 170: int gen7_gmu_parse_fw(struct adreno_device *adreno_dev); 171: 172: /** 173: * gen7_gmu_memory_init - Allocate gmu memory 174: * @adreno_dev: Pointer to the adreno device 175: * 176: * Allocates the gmu log buffer and others if ndeeded. 177: * 178: * Return: 0 on success or negative error on failure 179: */ 180: int gen7_gmu_memory_init(struct adreno_device *adreno_dev); 181: 182: /** 183: * gen7_gmu_aop_send_acd_state - Enable or disable acd feature in aop 184: * @gmu: Pointer to the gen7 gmu device 185: * @flag: Boolean to enable or disable acd in aop 186: * 187: * This function enables or disables gpu acd feature using mailbox or qmp 188: */ 189: void gen7_gmu_aop_send_acd_state(struct gen7_gmu_device *gmu, bool flag); 190: 191: /** 192: * gen7_gmu_load_fw - Load gmu firmware 193: * @adreno_dev: Pointer to the adreno device 194: * 195: * Loads the gmu firmware binary into TCMs and memory 196: * 197: * Return: 0 on success or negative error on failure 198: */ 199: int gen7_gmu_load_fw(struct adreno_device *adreno_dev); 200: 201: /** 202: * gen7_gmu_device_start - Bring gmu out of reset 203: * @adreno_dev: Pointer to the adreno device 204: * 205: * Return: 0 on success or negative error on failure 206: */ 207: int gen7_gmu_device_start(struct adreno_device *adreno_dev); 208: 209: /** 210: * gen7_gmu_hfi_start - Indicate hfi start to gmu 211: * @device: Pointer to the kgsl device 212: * 213: * Return: 0 on success or negative error on failure 214: */ 215: int gen7_gmu_hfi_start(struct adreno_device *adreno_dev); 216: 217: /** 218: * gen7_gmu_itcm_shadow - Create itcm shadow copy for snapshot 219: * @adreno_dev: Pointer to the adreno device 220: * 221: * Return: 0 on success or negative error on failure 222: */ 223: int gen7_gmu_itcm_shadow(struct adreno_device *adreno_dev); 224: 225: /** 226: * gen7_gmu_register_config - gmu register configuration 227: * @adreno_dev: Pointer to the adreno device 228: * 229: * Program gmu regsiters based on features 230: */ 231: void gen7_gmu_register_config(struct adreno_device *adreno_dev); 232: 233: /** 234: * gen7_gmu_version_info - Get gmu firmware version 235: * @adreno_dev: Pointer to the adreno device 236: * 237: * Return: 0 on success or negative error on failure 238: */ 239: int gen7_gmu_version_info(struct adreno_device *adreno_dev); 240: 241: /** 242: * gen7_gmu_irq_enable - Enable gmu interrupts 243: * @adreno_dev: Pointer to the adreno device 244: */ 245: void gen7_gmu_irq_enable(struct adreno_device *adreno_dev); 246: 247: /** 248: * gen7_gmu_irq_disable - Disaable gmu interrupts 249: * @adreno_dev: Pointer to the adreno device 250: */ 251: void gen7_gmu_irq_disable(struct adreno_device *adreno_dev); 252: 253: /** 254: * gen7_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 gen7_gmu_suspend(struct adreno_device *adreno_dev, bool force); 262: 263: /** 264: * gen7_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 gen7_gmu_oob_set(struct kgsl_device *device, enum oob_request oob); 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 313: * 314: * Return: 0 on success or negative error on failure 315: */ 316: int gen7_rscc_wakeup_sequence(struct adreno_device *adreno_dev); 317: 318: /** 319: * gen7_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: * MATCH LINES: 344, 347, 350, 353, 356, 361, 362, 365, 368 332: * 333: * Return: 0 on success or negative error on failure 334: */ 335: int gen7_load_pdc_ucode(struct adreno_device *adreno_dev); 336: 337: /** 338: * gen7_load_rsc_ucode - Load rscc sequence 339: * @adreno_dev: Pointer to the adreno device 340: */ 341: void gen7_load_rsc_ucode(struct adreno_device *adreno_dev); 342: 343: /** 344: * gen7_gmu_remove - Clean up gmu probed resources 345: * @device: Pointer to the kgsl device 346: */ 347: void gen7_gmu_remove(struct kgsl_device *device); 348: 349: /** 350: * gen7_gmu_handle_watchdog - Handle watchdog interrupt 351: * @adreno_dev: Pointer to the adreno device 352: */ 353: void gen7_gmu_handle_watchdog(struct adreno_device *adreno_dev); 354: 355: /** 356: * gen7_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 gen7_gmu_send_nmi(struct kgsl_device *device, bool force, 362: enum gmu_fault_panic_policy gf_policy); 363: 364: /** 365: * gen7_gmu_add_to_minidump - Register gen7_device with va minidump 366: * @adreno_dev: Pointer to the adreno device 367: */ 368: int gen7_gmu_add_to_minidump(struct adreno_device *adreno_dev); 369: #endif --- FILE: \adreno_gen7_gmu_snapshot.c | HITS: 65 --- MATCH LINES: 16, 18, 21, 22, 23, 28, 33, 35, 50, 53, 54, 57, 60, 63, 64, 65, 67, 70, 75, 80, 82, 85, 87, 90, 91, 93, 95, 98, 100, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 116, 119, 120, 133, 164, 171, 175, 179, 181, 182, 184, 186, 189, 193, 199, 203, 208, 210, 214, 222, 228, 229, 232, 244, 248, 249 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #include "gen7_reg.h" 8: #include "adreno.h" 9: #include "adreno_gen7.h" 10: #include "adreno_gen7_gmu.h" 11: #include "adreno_snapshot.h" 12: #include "adreno_gen7_0_0_snapshot.h" 13: #include "adreno_gen7_2_0_snapshot.h" 14: #include "adreno_gen7_6_0_snapshot.h" 15: #include "kgsl_device.h" 16: #include "kgsl_gmu_core.h" 17: 18: static size_t gen7_gmu_snapshot_dtcm(struct kgsl_device *device, 19: u8 *buf, size_t remain, void *priv) 20: { 21: struct gmu_core_device *gmu_core = &device->gmu_core; 22: struct kgsl_snapshot_gmu_mem *mem_hdr = 23: (struct kgsl_snapshot_gmu_mem *)buf; 24: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 25: u32 *data = (u32 *)(buf + sizeof(*mem_hdr)); 26: u32 i; 27: 28: if (remain < gmu_core->vma[GMU_DTCM].size + sizeof(*mem_hdr)) { 29: SNAPSHOT_ERR_NOMEM(device, "GMU DTCM Memory"); 30: return 0; 31: } 32: 33: mem_hdr->type = SNAPSHOT_GMU_MEM_BIN_BLOCK; 34: mem_hdr->hostaddr = 0; 35: mem_hdr->gmuaddr = gmu_core->vma[GMU_DTCM].start; 36: mem_hdr->gpuaddr = 0; 37: 38: /* 39: * Read of GMU TCMs over side-band debug controller interface is 40: * supported on gen7_2_x family 41: */ 42: if (adreno_is_gen7_2_x_family(adreno_dev)) { 43: /* 44: * region [20]: Dump ITCM/DTCM. Select 1 for DTCM. 45: * autoInc [31]: Autoincrement the address field after each 46: * access to TCM_DBG_DATA 47: */ 48: kgsl_regwrite(device, GEN7_CX_DBGC_TCM_DBG_ADDR, BIT(20) | BIT(31)); 49: 50: for (i = 0; i < (gmu_core->vma[GMU_DTCM].size >> 2); i++) 51: kgsl_regread(device, GEN7_CX_DBGC_TCM_DBG_DATA, data++); 52: } else { 53: for (i = 0; i < (gmu_core->vma[GMU_DTCM].size >> 2); i++) 54: gmu_core_regread(device, GEN7_GMU_CM3_DTCM_START + i, data++); 55: } 56: 57: return gmu_core->vma[GMU_DTCM].size + sizeof(*mem_hdr); 58: } 59: 60: static size_t gen7_gmu_snapshot_itcm(struct kgsl_device *device, 61: u8 *buf, size_t remain, void *priv) 62: { 63: struct gmu_core_device *gmu_core = &device->gmu_core; 64: struct kgsl_snapshot_gmu_mem *mem_hdr = 65: (struct kgsl_snapshot_gmu_mem *)buf; 66: void *dest = buf + sizeof(*mem_hdr); 67: struct gen7_gmu_device *gmu = (struct gen7_gmu_device *)priv; 68: 69: if (!gmu->itcm_shadow) { 70: dev_err(GMU_PDEV_DEV(device), 71: "No memory allocated for ITCM shadow capture\n"); 72: return 0; 73: } 74: 75: if (remain < gmu_core->vma[GMU_ITCM].size + sizeof(*mem_hdr)) { 76: SNAPSHOT_ERR_NOMEM(device, "GMU ITCM Memory"); 77: return 0; 78: } 79: 80: mem_hdr->type = SNAPSHOT_GMU_MEM_BIN_BLOCK; 81: mem_hdr->hostaddr = 0; 82: mem_hdr->gmuaddr = gmu_core->vma[GMU_ITCM].start; 83: mem_hdr->gpuaddr = 0; 84: 85: memcpy(dest, gmu->itcm_shadow, gmu_core->vma[GMU_ITCM].size); 86: 87: return gmu_core->vma[GMU_ITCM].size + sizeof(*mem_hdr); 88: } 89: 90: static void gen7_gmu_snapshot_memories(struct kgsl_device *device, 91: struct gen7_gmu_device *gmu, struct kgsl_snapshot *snapshot) 92: { 93: struct gmu_mem_type_desc desc; 94: struct kgsl_memdesc *md; 95: struct gmu_core_device *gmu_core = &device->gmu_core; 96: int i; 97: 98: for (i = 0; i < ARRAY_SIZE(gmu_core->gmu_globals); i++) { 99: 100: md = &gmu_core->gmu_globals[i]; 101: if (!md->size) 102: continue; 103: 104: desc.memdesc = md; 105: if (md == gmu->hfi.hfi_mem) 106: desc.type = SNAPSHOT_GMU_MEM_HFI; 107: else if (md == gmu->gmu_log) 108: desc.type = SNAPSHOT_GMU_MEM_LOG; 109: else if ((md == gmu->gmu_init_scratch) || (md == gmu->gpu_boot_scratch)) 110: desc.type = SNAPSHOT_GMU_MEM_WARMBOOT; 111: else if (md == gmu_core->vrb) 112: desc.type = SNAPSHOT_GMU_MEM_VRB; 113: else if (md == gmu_core->trace.md) 114: desc.type = SNAPSHOT_GMU_MEM_TRACE; 115: else 116: desc.type = SNAPSHOT_GMU_MEM_BIN_BLOCK; 117: 118: kgsl_snapshot_add_section(device, 119: KGSL_SNAPSHOT_SECTION_GMU_MEMORY, 120: snapshot, adreno_snapshot_gmu_mem, &desc); 121: } 122: } 123: 124: #define RSCC_OFFSET_DWORDS 0x14000 125: 126: static size_t gen7_snapshot_rscc_registers(struct kgsl_device *device, u8 *buf, 127: size_t remain, void *priv) 128: { 129: const u32 *regs = priv; 130: unsigned int *data = (unsigned int *)buf; 131: int count = 0, k; 132: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 133: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 134: 135: /* Figure out how many registers we are going to dump */ 136: count = adreno_snapshot_regs_count(regs); 137: 138: if (remain < (count * 4)) { 139: SNAPSHOT_ERR_NOMEM(device, "RSCC REGISTERS"); 140: return 0; 141: } 142: 143: for (regs = priv; regs[0] != UINT_MAX; regs += 2) { 144: unsigned int cnt = REG_COUNT(regs); 145: 146: if (cnt == 1) { 147: *data++ = BIT(31) | regs[0]; 148: *data++ = __raw_readl(gmu->rscc_virt + 149: ((regs[0] - RSCC_OFFSET_DWORDS) << 2)); 150: continue; 151: } 152: *data++ = regs[0]; 153: *data++ = cnt; 154: for (k = regs[0]; k <= regs[1]; k++) 155: *data++ = __raw_readl(gmu->rscc_virt + 156: ((k - RSCC_OFFSET_DWORDS) << 2)); 157: } 158: 159: /* Return the size of the section */ 160: return (count * 4); 161: } 162: 163: /* 164: * gen7_gmu_device_snapshot() - GEN7 GMU snapshot function 165: * @device: Device being snapshotted 166: * @snapshot: Pointer to the snapshot instance 167: * 168: * This is where all of the GEN7 GMU specific bits and pieces are grabbed 169: * into the snapshot memory 170: */ 171: static void gen7_gmu_device_snapshot(struct kgsl_device *device, 172: struct kgsl_snapshot *snapshot) 173: { 174: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 175: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 176: const struct adreno_gen7_core *gpucore = to_gen7_core(ADRENO_DEVICE(device)); 177: const struct gen7_snapshot_block_list *gen7_snapshot_block_list = 178: gpucore->gen7_snapshot_block_list; 179: const u32 *regs_ptr = (const u32 *)gen7_snapshot_block_list->gmu_ao_regs; 180: 181: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_GMU_MEMORY, 182: snapshot, gen7_gmu_snapshot_itcm, gmu); 183: 184: adreno_snapshot_gmu_versions(device, snapshot); 185: 186: gen7_gmu_snapshot_memories(device, gmu, snapshot); 187: 188: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, snapshot, 189: adreno_snapshot_registers_v2, (void *) gen7_snapshot_block_list->gmu_regs); 190: 191: if (regs_ptr && kgsl_regmap_valid_offset(&device->regmap, regs_ptr[0])) { 192: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, snapshot, 193: adreno_snapshot_registers_v2, (void *) gen7_snapshot_block_list->gmu_ao_regs); 194: } 195: 196: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, snapshot, 197: gen7_snapshot_rscc_registers, (void *) gen7_snapshot_block_list->rscc_regs); 198: 199: if (!gen7_gmu_gx_is_on(adreno_dev)) 200: goto dtcm; 201: 202: /* Set fence to ALLOW mode so registers can be read */ 203: kgsl_regwrite(device, GEN7_GMU_AO_AHB_FENCE_CTRL, 0); 204: /* Make sure the previous write posted before reading */ 205: wmb(); 206: 207: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, snapshot, 208: adreno_snapshot_registers_v2, (void *) gen7_snapshot_block_list->gmu_gx_regs); 209: 210: regs_ptr = (const u32 *)gen7_snapshot_block_list->gmu_gx_blk_dec0_dec1_regs; 211: if (regs_ptr && kgsl_regmap_valid_offset(&device->regmap, regs_ptr[0])) { 212: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, snapshot, 213: adreno_snapshot_registers_v2, 214: (void *) gen7_snapshot_block_list->gmu_gx_blk_dec0_dec1_regs); 215: } 216: 217: /* 218: * A stalled SMMU can lead to NoC timeouts when host accesses DTCM. 219: * DTCM can be read through side-band DBGC interface on gen7_2_x family. 220: */ 221: if (adreno_smmu_is_stalled(adreno_dev) && !adreno_is_gen7_2_x_family(adreno_dev)) { 222: dev_err(GMU_PDEV_DEV(device), 223: "Not dumping dtcm because SMMU is stalled\n"); 224: return; 225: } 226: 227: dtcm: 228: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_GMU_MEMORY, 229: snapshot, gen7_gmu_snapshot_dtcm, gmu); 230: } 231: 232: void gen7_gmu_snapshot(struct adreno_device *adreno_dev, 233: struct kgsl_snapshot *snapshot) 234: { 235: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 236: 237: /* 238: * Dump external register first to have GPUCC and other external 239: * register in snapshot to analyze the system state even in partial 240: * snapshot dump 241: */ 242: gen7_snapshot_external_core_regs(device, snapshot); 243: 244: gen7_gmu_device_snapshot(device, snapshot); 245: 246: gen7_snapshot(adreno_dev, snapshot); 247: 248: gmu_core_regwrite(device, GEN7_GMU_GMU2HOST_INTR_CLR, UINT_MAX); 249: gmu_core_regwrite(device, GEN7_GMU_GMU2HOST_INTR_MASK, HFI_IRQ_MASK); 250: } --- FILE: \adreno_gen7_hfi.c | HITS: 190 --- MATCH LINES: 18, 21, 22, 24, 25, 29, 35, 38, 39, 40, 41, 48, 62, 79, 87, 90, 91, 95, 102, 105, 106, 107, 114, 117, 140, 142, 147, 149, 158, 174, 175, 185, 186, 188, 189, 194, 195, 196, 197, 203, 204, 205, 206, 207, 212, 214, 217, 221, 224, 228, 229, 230, 231, 235, 238, 241, 250, 256, 260, 265, 275, 282, 287, 297, 301, 309, 312, 322, 326, 330, 331, 334, 337, 342, 343, 345, 350, 357, 364, 368, 375, 377, 386, 390, 396, 397, 399, 404, 407, 411, 415, 419, 426, 430, 441, 443, 444, 448, 451, 461, 463, 470, 474, 485, 487, 493, 495, 498, 500, 505, 506, 509, 511, 512, 514, 518, 521, 524, 526, 543, 553, 565, 568, 571, 581, 598, 603, 605, 609, 610, 614, 619, 626, 628, 631, 632, 636, 638, 639, 640, 641, 645, 647, 655, 666, 669, 673, 679, 680, 685, 688, 691, 692, 696, 701, 702, 705, 708, 710, 714, 717, 725, 729, 731, 737, 739, 743, 745, 749, 754, 758, 762, 766, 770, 774, 780, 786, 788, 793, 797, 800, 803, 804, 806, 807, 808, 809, 816, 817, 819 6: 7: #include 8: #include 9: 10: #include "adreno.h" 11: #include "adreno_gen7.h" 12: #include "adreno_gen7_gmu.h" 13: #include "adreno_gen7_hfi.h" 14: #include "kgsl_device.h" 15: #include "kgsl_trace.h" 16: 17: /* Below section is for all structures related to HFI queues */ 18: #define HFI_QUEUE_MAX HFI_QUEUE_DEFAULT_CNT 19: 20: /* Total header sizes + queue sizes + 16 for alignment */ 21: #define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \ 22: (HFI_QUEUE_SIZE * HFI_QUEUE_MAX)) 23: 24: #define HOST_QUEUE_START_ADDR(hfi_mem, i) \ 25: ((hfi_mem)->hostptr + HFI_QUEUE_OFFSET(i)) 26: 27: struct gen7_hfi *to_gen7_hfi(struct adreno_device *adreno_dev) 28: { 29: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 30: 31: return &gmu->hfi; 32: } 33: 34: /* Size in below functions are in unit of dwords */ 35: int gen7_hfi_queue_read(struct gen7_gmu_device *gmu, u32 queue_idx, 36: unsigned int *output, unsigned int max_size) 37: { 38: struct kgsl_device *device = KGSL_DEVICE(gen7_gmu_to_adreno(gmu)); 39: struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem; 40: struct hfi_queue_table *tbl = mem_addr->hostptr; 41: struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx]; 42: u32 *queue; 43: u32 msg_hdr; 44: u32 i, read; 45: u32 size; 46: int result = 0; 47: 48: if (hdr->status == HFI_QUEUE_STATUS_DISABLED) 49: return -EINVAL; 50: 51: if (hdr->read_index == hdr->write_index) 52: return -ENODATA; 53: 54: /* Clear the output data before populating */ 55: memset(output, 0, max_size); 56: 57: queue = HOST_QUEUE_START_ADDR(mem_addr, queue_idx); 58: msg_hdr = queue[hdr->read_index]; 59: size = MSG_HDR_GET_SIZE(msg_hdr); 60: 61: if (size > (max_size >> 2)) { 62: dev_err(GMU_PDEV_DEV(device), 63: "HFI message too big: hdr:0x%x rd idx=%d\n", 64: msg_hdr, hdr->read_index); 65: result = -EMSGSIZE; 66: goto done; 67: } 68: 69: read = hdr->read_index; 70: 71: if (read < hdr->queue_size) { 72: for (i = 0; i < size && i < (max_size >> 2); i++) { 73: output[i] = queue[read]; 74: read = (read + 1)%hdr->queue_size; 75: } 76: result = size; 77: } else { 78: /* In case FW messed up */ 79: dev_err(GMU_PDEV_DEV(device), 80: "Read index %d greater than queue size %d\n", 81: hdr->read_index, hdr->queue_size); 82: result = -ENODATA; 83: } 84: 85: read = ALIGN(read, SZ_4) % hdr->queue_size; 86: 87: hfi_update_read_idx(hdr, read); 88: 89: /* For acks, trace the packet for which this ack was sent */ 90: if (MSG_HDR_GET_TYPE(msg_hdr) == HFI_MSG_ACK) 91: trace_kgsl_hfi_receive(MSG_HDR_GET_ID(output[1]), 92: MSG_HDR_GET_SIZE(output[1]), 93: MSG_HDR_GET_SEQNUM(output[1])); 94: else 95: trace_kgsl_hfi_receive(MSG_HDR_GET_ID(msg_hdr), 96: MSG_HDR_GET_SIZE(msg_hdr), MSG_HDR_GET_SEQNUM(msg_hdr)); 97: 98: done: 99: return result; 100: } 101: 102: int gen7_hfi_queue_write(struct adreno_device *adreno_dev, u32 queue_idx, 103: u32 *msg, u32 size_bytes) 104: { 105: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 106: struct hfi_queue_table *tbl = gmu->hfi.hfi_mem->hostptr; 107: struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx]; 108: u32 *queue; 109: u32 i, write_idx, read_idx, empty_space; 110: u32 size_dwords = size_bytes >> 2; 111: u32 align_size = ALIGN(size_dwords, SZ_4); 112: u32 id = MSG_HDR_GET_ID(*msg); 113: 114: if (hdr->status == HFI_QUEUE_STATUS_DISABLED || !IS_ALIGNED(size_bytes, sizeof(u32))) 115: return -EINVAL; 116: 117: queue = HOST_QUEUE_START_ADDR(gmu->hfi.hfi_mem, queue_idx); 118: 119: write_idx = hdr->write_index; 120: read_idx = hdr->read_index; 121: 122: empty_space = (write_idx >= read_idx) ? 123: (hdr->queue_size - (write_idx - read_idx)) 124: : (read_idx - write_idx); 125: 126: if (empty_space <= align_size) 127: return -ENOSPC; 128: 129: for (i = 0; i < size_dwords; i++) { 130: queue[write_idx] = msg[i]; 131: write_idx = (write_idx + 1) % hdr->queue_size; 132: } 133: 134: /* Cookify any non used data at the end of the write buffer */ 135: for (; i < align_size; i++) { 136: queue[write_idx] = 0xfafafafa; 137: write_idx = (write_idx + 1) % hdr->queue_size; 138: } 139: 140: trace_kgsl_hfi_send(id, size_dwords, MSG_HDR_GET_SEQNUM(*msg)); 141: 142: hfi_update_write_idx(&hdr->write_index, write_idx); 143: 144: return 0; 145: } 146: 147: int gen7_hfi_cmdq_write(struct adreno_device *adreno_dev, u32 *msg, u32 size_bytes) 148: { 149: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 150: struct gen7_hfi *hfi = &gmu->hfi; 151: int ret; 152: 153: spin_lock(&hfi->cmdq_lock); 154: 155: if (test_bit(MSG_HDR_GET_ID(msg[0]), hfi->wb_set_record_bitmask)) 156: *msg = RECORD_MSG_HDR(*msg); 157: 158: ret = gen7_hfi_queue_write(adreno_dev, HFI_CMD_ID, msg, size_bytes); 159: 160: /* 161: * Some messages like ACD table and perf table are saved in memory, so we need 162: * to reset the header to make sure we do not send a record enabled bit incase 163: * we change the warmboot setting from debugfs 164: */ 165: *msg = CLEAR_RECORD_MSG_HDR(*msg); 166: /* 167: * Memory barrier to make sure packet and write index are written before 168: * an interrupt is raised 169: */ 170: wmb(); 171: 172: /* Send interrupt to GMU to receive the message */ 173: if (!ret) 174: gmu_core_regwrite(KGSL_DEVICE(adreno_dev), 175: GEN7_GMU_HOST2GMU_INTR_SET, 0x1); 176: 177: spin_unlock(&hfi->cmdq_lock); 178: 179: return ret; 180: } 181: 182: /* Sizes of the queue and message are in unit of dwords */ 183: static void init_queues(struct adreno_device *adreno_dev) 184: { 185: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 186: struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem; 187: int i; 188: struct hfi_queue_table *tbl; 189: struct hfi_queue_header *hdr; 190: struct { 191: unsigned int idx; 192: unsigned int pri; 193: unsigned int status; 194: } queue[HFI_QUEUE_MAX] = { 195: { HFI_CMD_ID, HFI_CMD_PRI, HFI_QUEUE_STATUS_ENABLED }, 196: { HFI_MSG_ID, HFI_MSG_PRI, HFI_QUEUE_STATUS_ENABLED }, 197: { HFI_DBG_ID, HFI_DBG_PRI, HFI_QUEUE_STATUS_ENABLED }, 198: }; 199: 200: /* Fill Table Header */ 201: tbl = mem_addr->hostptr; 202: tbl->qtbl_hdr.version = 0; 203: tbl->qtbl_hdr.size = sizeof(struct hfi_queue_table) >> 2; 204: tbl->qtbl_hdr.qhdr0_offset = sizeof(struct hfi_queue_table_header) >> 2; 205: tbl->qtbl_hdr.qhdr_size = sizeof(struct hfi_queue_header) >> 2; 206: tbl->qtbl_hdr.num_q = HFI_QUEUE_MAX; 207: tbl->qtbl_hdr.num_active_q = HFI_QUEUE_MAX; 208: 209: memset(&tbl->qhdr[0], 0, sizeof(tbl->qhdr)); 210: 211: /* Fill Individual Queue Headers */ 212: for (i = 0; i < HFI_QUEUE_MAX; i++) { 213: hdr = &tbl->qhdr[i]; 214: hdr->start_addr = GMU_QUEUE_START_ADDR(mem_addr->gmuaddr, i); 215: hdr->type = QUEUE_HDR_TYPE(queue[i].idx, queue[i].pri, 0, 0); 216: hdr->status = queue[i].status; 217: hdr->queue_size = HFI_QUEUE_SIZE >> 2; /* convert to dwords */ 218: } 219: } 220: 221: int gen7_hfi_init(struct adreno_device *adreno_dev) 222: { 223: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 224: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 225: struct gen7_hfi *hfi = &gmu->hfi; 226: 227: /* Allocates & maps memory for HFI */ 228: if (IS_ERR_OR_NULL(hfi->hfi_mem)) { 229: hfi->hfi_mem = gmu_core_reserve_kernel_block(device, 0, 230: HFIMEM_SIZE, GMU_NONCACHED_KERNEL, 0); 231: if (!IS_ERR(hfi->hfi_mem)) 232: init_queues(adreno_dev); 233: } 234: 235: return PTR_ERR_OR_ZERO(hfi->hfi_mem); 236: } 237: 238: int gen7_receive_ack_cmd(struct gen7_gmu_device *gmu, void *rcvd, 239: struct pending_cmd *ret_cmd) 240: { 241: struct adreno_device *adreno_dev = gen7_gmu_to_adreno(gmu); 242: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 243: u32 *ack = rcvd; 244: u32 hdr = ack[0]; 245: u32 req_hdr = ack[1]; 246: 247: if (ret_cmd == NULL) 248: return -EINVAL; 249: 250: if (CMP_HFI_ACK_HDR(ret_cmd->sent_hdr, req_hdr)) { 251: memcpy(&ret_cmd->results, ack, MSG_HDR_GET_SIZE(hdr) << 2); 252: return 0; 253: } 254: 255: /* Didn't find the sender, list the waiter */ 256: dev_err_ratelimited(GMU_PDEV_DEV(device), 257: "HFI ACK: Cannot find sender for 0x%8.8x Waiter: 0x%8.8x\n", 258: req_hdr, ret_cmd->sent_hdr); 259: 260: gmu_core_fault_snapshot(device, GMU_FAULT_HFI_RECIVE_ACK); 261: 262: return -ENODEV; 263: } 264: 265: static int poll_gmu_reg(struct adreno_device *adreno_dev, 266: u32 offsetdwords, unsigned int expected_val, 267: unsigned int mask, unsigned int timeout_ms) 268: { 269: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 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; 307: } 308: 309: static int gen7_hfi_send_cmd_wait_inline(struct adreno_device *adreno_dev, 310: void *data, u32 size_bytes, struct pending_cmd *ret_cmd) 311: { 312: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 313: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 314: int rc; 315: u32 *cmd = data; 316: struct gen7_hfi *hfi = &gmu->hfi; 317: unsigned int seqnum = atomic_inc_return(&hfi->seqnum); 318: 319: *cmd = MSG_HDR_SET_SEQNUM_SIZE(*cmd, seqnum, size_bytes >> 2); 320: 321: if (ret_cmd == NULL) 322: return gen7_hfi_cmdq_write(adreno_dev, cmd, size_bytes); 323: 324: ret_cmd->sent_hdr = cmd[0]; 325: 326: rc = gen7_hfi_cmdq_write(adreno_dev, cmd, size_bytes); 327: if (rc) 328: return rc; 329: 330: rc = poll_gmu_reg(adreno_dev, GEN7_GMU_GMU2HOST_INTR_INFO, 331: HFI_IRQ_MSGQ_MASK, HFI_IRQ_MSGQ_MASK, HFI_RSP_TIMEOUT); 332: 333: if (rc) { 334: dev_err(GMU_PDEV_DEV(device), 335: "Timed out waiting on ack for 0x%8.8x (id %d, sequence %d)\n", 336: cmd[0], MSG_HDR_GET_ID(*cmd), MSG_HDR_GET_SEQNUM(*cmd)); 337: gmu_core_fault_snapshot(device, GMU_FAULT_SEND_CMD_WAIT_INLINE); 338: return rc; 339: } 340: 341: /* Clear the interrupt */ 342: gmu_core_regwrite(device, GEN7_GMU_GMU2HOST_INTR_CLR, 343: HFI_IRQ_MSGQ_MASK); 344: 345: rc = gen7_hfi_process_queue(gmu, HFI_MSG_ID, ret_cmd); 346: 347: return rc; 348: } 349: 350: int gen7_hfi_send_generic_req(struct adreno_device *adreno_dev, void *cmd, u32 size_bytes) 351: { 352: struct pending_cmd ret_cmd; 353: int rc; 354: 355: memset(&ret_cmd, 0, sizeof(ret_cmd)); 356: 357: rc = gen7_hfi_send_cmd_wait_inline(adreno_dev, cmd, size_bytes, &ret_cmd); 358: if (rc) 359: return rc; 360: 361: if (ret_cmd.results[2]) { 362: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 363: 364: dev_err(GMU_PDEV_DEV(device), 365: "HFI ACK failure: Req=0x%8.8X, Result=0x%8.8X\n", 366: ret_cmd.results[1], 367: ret_cmd.results[2]); 368: gmu_core_fault_snapshot(device, GMU_FAULT_HFI_SEND_GENERIC_REQ); 369: return -EINVAL; 370: } 371: 372: return 0; 373: } 374: 375: int gen7_hfi_send_core_fw_start(struct adreno_device *adreno_dev) 376: { 377: struct hfi_core_fw_start_cmd cmd = { 378: .handle = 0x0, 379: }; 380: int ret; 381: 382: ret = CMD_MSG_HDR(cmd, H2F_MSG_CORE_FW_START); 383: if (ret) 384: return ret; 385: 386: return gen7_hfi_send_generic_req(adreno_dev, &cmd, sizeof(cmd)); 387: } 388: 389: /* For sending hfi message inline to handle GMU return type error */ 390: int gen7_hfi_send_generic_req_v5(struct adreno_device *adreno_dev, void *cmd, 391: struct pending_cmd *ret_cmd, u32 size_bytes) 392: { 393: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 394: int rc; 395: 396: if (GMU_VER_MINOR(device->gmu_core.ver.hfi) <= 4) 397: return gen7_hfi_send_generic_req(adreno_dev, cmd, size_bytes); 398: 399: rc = gen7_hfi_send_cmd_wait_inline(adreno_dev, cmd, size_bytes, ret_cmd); 400: if (rc) 401: return rc; 402: 403: switch (ret_cmd->results[3]) { 404: case GMU_SUCCESS: 405: rc = ret_cmd->results[2]; 406: break; 407: case GMU_ERROR_NO_ENTRY: 408: /* Unique error to handle undefined HFI msgs by caller */ 409: rc = -ENOENT; 410: break; 411: case GMU_ERROR_TIMEOUT: 412: rc = -EINVAL; 413: break; 414: default: 415: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)), 416: "HFI ACK: Req=0x%8.8X, Result=0x%8.8X Error:0x%8.8X\n", 417: ret_cmd->results[1], ret_cmd->results[2], ret_cmd->results[3]); 418: rc = -EINVAL; 419: gmu_core_fault_snapshot(KGSL_DEVICE(adreno_dev), GMU_FAULT_HFI_SEND_GENERIC_REQ); 420: break; 421: } 422: 423: return rc; 424: } 425: 426: int gen7_hfi_send_feature_ctrl(struct adreno_device *adreno_dev, 427: u32 feature, u32 enable, u32 data) 428: { 429: struct pending_cmd ret_cmd = {0}; 430: struct hfi_feature_ctrl_cmd cmd = { 431: .feature = feature, 432: .enable = enable, 433: .data = data, 434: }; 435: int ret; 436: 437: ret = CMD_MSG_HDR(cmd, H2F_MSG_FEATURE_CTRL); 438: if (ret) 439: return ret; 440: 441: ret = gen7_hfi_send_generic_req_v5(adreno_dev, &cmd, &ret_cmd, sizeof(cmd)); 442: if (ret < 0) 443: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)), "Unable to %s feature %s (%d)\n", 444: enable ? "enable" : "disable", hfi_feature_to_string(feature), feature); 445: return ret; 446: } 447: 448: int gen7_hfi_send_get_value(struct adreno_device *adreno_dev, u32 type, u32 subtype) 449: { 450: struct pending_cmd ret_cmd = {0}; 451: struct hfi_get_value_cmd cmd = { 452: .type = type, 453: .subtype = subtype, 454: }; 455: int ret; 456: 457: ret = CMD_MSG_HDR(cmd, H2F_MSG_GET_VALUE); 458: if (ret) 459: return ret; 460: 461: ret = gen7_hfi_send_generic_req_v5(adreno_dev, &cmd, &ret_cmd, sizeof(cmd)); 462: if (ret < 0) 463: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)), 464: "Unable to get HFI Value type: %d, subtype: %d, error = %d\n", 465: type, subtype, ret); 466: 467: return ret; 468: } 469: 470: int gen7_hfi_send_set_value(struct adreno_device *adreno_dev, 471: u32 type, u32 subtype, u32 data) 472: { 473: struct pending_cmd ret_cmd = {0}; 474: struct hfi_set_value_cmd cmd = { 475: .type = type, 476: .subtype = subtype, 477: .data = data, 478: }; 479: int ret; 480: 481: ret = CMD_MSG_HDR(cmd, H2F_MSG_SET_VALUE); 482: if (ret) 483: return ret; 484: 485: ret = gen7_hfi_send_generic_req_v5(adreno_dev, &cmd, &ret_cmd, sizeof(cmd)); 486: if (ret < 0) 487: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)), 488: "Unable to set HFI Value %d, %d to %d, error = %d\n", 489: type, subtype, data, ret); 490: return ret; 491: } 492: 493: void adreno_gen7_receive_err_req(struct gen7_gmu_device *gmu, void *rcvd) 494: { 495: struct kgsl_device *device = KGSL_DEVICE(gen7_gmu_to_adreno(gmu)); 496: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(ADRENO_DEVICE(device)); 497: u64 ticks = gpudev->read_alwayson(ADRENO_DEVICE(device)); 498: struct hfi_err_cmd *cmd = rcvd; 499: 500: dev_err(GMU_PDEV_DEV(device), "HFI Error Received: %d %d %.16s\n", 501: ((cmd->error_code >> 16) & 0xffff), 502: (cmd->error_code & 0xffff), 503: (char *) cmd->data); 504: 505: KGSL_GMU_CORE_FORCE_PANIC(device->gmu_core.gf_panic, 506: GMU_PDEV(device), ticks, GMU_FAULT_F2H_MSG_ERR); 507: } 508: 509: void adreno_gen7_receive_debug_req(struct gen7_gmu_device *gmu, void *rcvd) 510: { 511: struct kgsl_device *device = KGSL_DEVICE(gen7_gmu_to_adreno(gmu)); 512: struct hfi_debug_cmd *cmd = rcvd; 513: 514: dev_dbg(GMU_PDEV_DEV(device), "HFI Debug Received: %d %d %d\n", 515: cmd->type, cmd->timestamp, cmd->data); 516: } 517: 518: int gen7_hfi_process_queue(struct gen7_gmu_device *gmu, 519: u32 queue_idx, struct pending_cmd *ret_cmd) 520: { 521: struct kgsl_device *device = KGSL_DEVICE(gen7_gmu_to_adreno(gmu)); 522: u32 rcvd[MAX_RCVD_SIZE]; 523: 524: while (gen7_hfi_queue_read(gmu, queue_idx, rcvd, sizeof(rcvd)) > 0) { 525: /* ACK Handler */ 526: if (MSG_HDR_GET_TYPE(rcvd[0]) == HFI_MSG_ACK) { 527: int ret = gen7_receive_ack_cmd(gmu, rcvd, ret_cmd); 528: 529: if (ret) 530: return ret; 531: continue; 532: } 533: 534: /* Request Handler */ 535: switch (MSG_HDR_GET_ID(rcvd[0])) { 536: case F2H_MSG_ERR: /* No Reply */ 537: adreno_gen7_receive_err_req(gmu, rcvd); 538: break; 539: case F2H_MSG_DEBUG: /* No Reply */ 540: adreno_gen7_receive_debug_req(gmu, rcvd); 541: break; 542: default: /* No Reply */ 543: dev_err(GMU_PDEV_DEV(device), 544: "HFI request %d not supported\n", 545: MSG_HDR_GET_ID(rcvd[0])); 546: break; 547: } 548: } 549: 550: return 0; 551: } 552: 553: int gen7_hfi_send_bcl_feature_ctrl(struct adreno_device *adreno_dev) 554: { 555: if (!adreno_dev->bcl_enabled) 556: return 0; 557: 558: /* 559: * BCL data is expected by gmu in below format 560: * BIT[0] - response type 561: * BIT[1:7] - Throttle level 1 (optional) 562: * BIT[8:14] - Throttle level 2 (optional) 563: * BIT[15:21] - Throttle level 3 (optional) 564: */ 565: return gen7_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_BCL, 1, adreno_dev->bcl_data); 566: } 567: 568: int gen7_hfi_send_clx_feature_ctrl(struct adreno_device *adreno_dev) 569: { 570: int ret = 0; 571: struct hfi_clx_table_v2_cmd cmd = {0}; 572: 573: if (!adreno_dev->clx_enabled) 574: return 0; 575: 576: /* Make sure the table is valid before enabling feature */ 577: ret = CMD_MSG_HDR(cmd, H2F_MSG_CLX_TBL); 578: if (ret) 579: return ret; 580: 581: ret = gen7_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_CLX, 1, 0); 582: if (ret) 583: return ret; 584: 585: cmd.version = FIELD_PREP(GENMASK(31, 16), 0x2) | FIELD_PREP(GENMASK(15, 0), 0x1); 586: /* cmd.domain[0] is never used but needed per hfi spec */ 587: cmd.domain[1].data0 = FIELD_PREP(GENMASK(31, 29), 1) | 588: FIELD_PREP(GENMASK(28, 28), 1) | 589: FIELD_PREP(GENMASK(27, 22), 1) | 590: FIELD_PREP(GENMASK(21, 16), 40) | 591: FIELD_PREP(GENMASK(15, 0), 0); 592: cmd.domain[1].clxt = 0; 593: cmd.domain[1].clxh = 0; 594: cmd.domain[1].urgmode = 1; 595: cmd.domain[1].lkgen = 0; 596: cmd.domain[1].currbudget = 50; 597: 598: return gen7_hfi_send_generic_req(adreno_dev, &cmd, sizeof(cmd)); 599: } 600: 601: #define EVENT_PWR_ACD_THROTTLE_PROF 44 602: 603: int gen7_hfi_send_acd_feature_ctrl(struct adreno_device *adreno_dev) 604: { 605: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 606: int ret = 0; 607: 608: if (adreno_dev->acd_enabled) { 609: ret = gen7_hfi_send_feature_ctrl(adreno_dev, 610: HFI_FEATURE_ACD, 1, 0); 611: if (ret) 612: return ret; 613: 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) 657: { 658: entry->count = count; 659: entry->stride = stride_bytes >> 2; /* entry->stride is in dwords */ 660: memcpy(entry->data, data, stride_bytes * count); 661: 662: /* Return total dword count of entry + data */ 663: return (sizeof(*entry) >> 2) + (entry->count * entry->stride); 664: } 665: 666: int gen7_hfi_send_gpu_perf_table(struct adreno_device *adreno_dev) 667: { 668: /* 669: * Buffer to store either hfi_table_cmd or hfi_dcvstable_cmd. 670: * Current max size for either is 165 dwords. 671: */ 672: static u32 cmd_buf[200]; 673: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 674: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 675: struct gen7_dcvs_table *tbl = &gmu->dcvs_table; 676: int ret = 0; 677: 678: /* Starting with GMU HFI Version 2.6.1, use H2F_MSG_TABLE */ 679: if (device->gmu_core.ver.hfi >= HFI_VERSION(2, 6, 1)) { 680: struct hfi_table_cmd *cmd = (struct hfi_table_cmd *)&cmd_buf[0]; 681: u32 dword_off; 682: 683: /* Already setup, so just send cmd */ 684: if (cmd->hdr) 685: return gen7_hfi_send_generic_req(adreno_dev, cmd, 686: MSG_HDR_GET_SIZE(cmd->hdr) << 2); 687: 688: if (tbl->gpu_level_num > MAX_GX_LEVELS || tbl->gmu_level_num > MAX_CX_LEVELS_LEGACY) 689: return -EINVAL; 690: 691: /* CMD starts with struct hfi_table_cmd data */ 692: cmd->type = HFI_TABLE_GPU_PERF; 693: dword_off = sizeof(*cmd) >> 2; 694: 695: /* Fill in the table entry and data starting at dword_off */ 696: dword_off += _fill_table_entry((struct hfi_table_entry *)&cmd_buf[dword_off], 697: tbl->gpu_level_num, sizeof(struct opp_gx_desc), 698: (u32 *)tbl->gx_votes); 699: 700: /* Fill in the table entry and data starting at dword_off */ 701: dword_off += _fill_table_entry((struct hfi_table_entry *)&cmd_buf[dword_off], 702: tbl->gmu_level_num, sizeof(struct opp_desc), 703: (u32 *)tbl->cx_votes); 704: 705: cmd->hdr = CREATE_MSG_HDR(H2F_MSG_TABLE, HFI_MSG_CMD); 706: cmd->hdr = MSG_HDR_SET_SIZE(cmd->hdr, dword_off); 707: 708: ret = gen7_hfi_send_generic_req(adreno_dev, cmd, dword_off << 2); 709: } else { 710: struct hfi_dcvstable_cmd *cmd = (struct hfi_dcvstable_cmd *)&cmd_buf[0]; 711: 712: /* Already setup, so just send cmd */ 713: if (cmd->hdr) 714: return gen7_hfi_send_generic_req(adreno_dev, cmd, sizeof(*cmd)); 715: 716: if (tbl->gpu_level_num > MAX_GX_LEVELS_LEGACY || 717: tbl->gmu_level_num > MAX_CX_LEVELS_LEGACY) 718: return -EINVAL; 719: 720: ret = CMD_MSG_HDR(*cmd, H2F_MSG_PERF_TBL); 721: if (ret) 722: return ret; 723: 724: cmd->gpu_level_num = tbl->gpu_level_num; 725: cmd->gmu_level_num = tbl->gmu_level_num; 726: memcpy(&cmd->gx_votes, tbl->gx_votes, 727: sizeof(struct opp_gx_desc) * cmd->gpu_level_num); 728: memcpy(&cmd->cx_votes, tbl->cx_votes, 729: sizeof(struct opp_desc) * cmd->gmu_level_num); 730: 731: ret = gen7_hfi_send_generic_req(adreno_dev, cmd, sizeof(*cmd)); 732: } 733: 734: return ret; 735: } 736: 737: int gen7_hfi_start(struct adreno_device *adreno_dev) 738: { 739: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 740: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 741: int result; 742: 743: reset_hfi_queues(adreno_dev); 744: 745: result = gen7_hfi_send_gpu_perf_table(adreno_dev); 746: if (result) 747: goto err; 748: 749: result = gen7_hfi_send_generic_req(adreno_dev, &gmu->hfi.bw_table, 750: sizeof(gmu->hfi.bw_table)); 751: if (result) 752: goto err; 753: 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: 791: kgsl_pwrctrl_axi(device, false); 792: 793: clear_bit(GMU_PRIV_HFI_STARTED, &gmu->flags); 794: } 795: 796: /* HFI interrupt handler */ 797: irqreturn_t gen7_hfi_irq_handler(int irq, void *data) 798: { 799: struct kgsl_device *device = data; 800: struct gen7_gmu_device *gmu = to_gen7_gmu(ADRENO_DEVICE(device)); 801: unsigned int status = 0; 802: 803: gmu_core_regread(device, GEN7_GMU_GMU2HOST_INTR_INFO, &status); 804: gmu_core_regwrite(device, GEN7_GMU_GMU2HOST_INTR_CLR, HFI_IRQ_MASK); 805: 806: if (status & HFI_IRQ_DBGQ_MASK) 807: gen7_hfi_process_queue(gmu, HFI_DBG_ID, NULL); 808: if (status & HFI_IRQ_CM3_FAULT_MASK) { 809: dev_err_ratelimited(GMU_PDEV_DEV(device), 810: "GMU CM3 fault interrupt received\n"); 811: atomic_set(&gmu->cm3_fault, 1); 812: 813: /* make sure other CPUs see the update */ 814: smp_wmb(); 815: } 816: if (status & ~HFI_IRQ_MASK) 817: dev_err_ratelimited(GMU_PDEV_DEV(device), 818: "Unhandled HFI interrupts 0x%lx\n", 819: status & ~HFI_IRQ_MASK); 820: 821: return IRQ_HANDLED; 822: } --- FILE: \adreno_gen7_hfi.h | HITS: 49 --- MATCH LINES: 6, 7, 21, 22, 24, 26, 33, 36, 38, 39, 42, 47, 50, 55, 58, 66, 72, 80, 84, 92, 103, 107, 115, 119, 126, 129, 137, 141, 146, 149, 154, 157, 164, 167, 175, 179, 184, 187, 192, 195, 200, 203, 208, 211, 218, 222, 231, 232, 233 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) 2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: #ifndef __ADRENO_GEN7_HFI_H 7: #define __ADRENO_GEN7_HFI_H 8: 9: #include "adreno_hfi.h" 10: 11: /** 12: * struct gen7_hfi - HFI control structure 13: */ 14: struct gen7_hfi { 15: /** @irq: HFI interrupt line */ 16: int irq; 17: /** @seqnum: atomic counter that is incremented for each message sent. 18: * The value of the counter is used as sequence number for HFI message. 19: */ 20: atomic_t seqnum; 21: /** @hfi_mem: Memory descriptor for the hfi memory */ 22: struct kgsl_memdesc *hfi_mem; 23: /** @bw_table: HFI BW table buffer */ 24: struct hfi_bwtable_cmd bw_table; 25: /** @acd_table: HFI table for ACD data */ 26: struct hfi_acd_table_cmd acd_table; 27: /** @cmdq_lock: Spinlock for accessing the cmdq */ 28: spinlock_t cmdq_lock; 29: /** 30: * @wb_set_record_bitmask: Bitmask to enable or disable the recording 31: * of messages in the GMU scratch. 32: */ 33: unsigned long wb_set_record_bitmask[BITS_TO_LONGS(HFI_MAX_ID)]; 34: }; 35: 36: struct gen7_gmu_device; 37: 38: /* gen7_hfi_irq_handler - IRQ handler for HFI interripts */ 39: irqreturn_t gen7_hfi_irq_handler(int irq, void *data); 40: 41: /** 42: * gen7_hfi_start - Send the various HFIs during device boot up 43: * @adreno_dev: Pointer to the adreno device 44: * 45: * Return: 0 on success or negative error on failure 46: */ 47: int gen7_hfi_start(struct adreno_device *adreno_dev); 48: 49: /** 50: * gen7_hfi_start - Send the various HFIs during device boot up 51: * @adreno_dev: Pointer to the adreno device 52: * 53: * Return: 0 on success or negative error on failure 54: */ 55: void gen7_hfi_stop(struct adreno_device *adreno_dev); 56: 57: /** 58: * gen7_hfi_init - Initialize hfi resources 59: * @adreno_dev: Pointer to the adreno device 60: * 61: * This function allocates and sets up hfi queues 62: * when a process creates the very first kgsl instance 63: * 64: * Return: 0 on success or negative error on failure 65: */ 66: int gen7_hfi_init(struct adreno_device *adreno_dev); 67: 68: /* Helper function to get to gen7 hfi struct from adreno device */ 69: struct gen7_hfi *to_gen7_hfi(struct adreno_device *adreno_dev); 70: 71: /** 72: * gen7_hfi_queue_write - Write a command to hfi queue 73: * @adreno_dev: Pointer to the adreno device 74: * @queue_idx: destination queue id 75: * @msg: Data to be written to the queue 76: * @size_bytes: Size of the command in bytes 77: * 78: * Return: 0 on success or negative error on failure 79: */ 80: int gen7_hfi_queue_write(struct adreno_device *adreno_dev, u32 queue_idx, 81: u32 *msg, u32 size_bytes); 82: 83: /** 84: * gen7_hfi_queue_read - Read data from hfi queue 85: * @gmu: Pointer to the gen7 gmu device 86: * @queue_idx: queue id to read from 87: * @output: Pointer to read the data into 88: * @max_size: Number of bytes to read from the queue 89: * 90: * Return: Size of the message read on success or negative error on failure 91: */ 92: int gen7_hfi_queue_read(struct gen7_gmu_device *gmu, u32 queue_idx, 93: u32 *output, u32 max_size); 94: 95: /** 96: * gen7_receive_ack_cmd - Process ack type packets 97: * @gmu: Pointer to the gen7 gmu device 98: * @rcvd: Pointer to the data read from hfi queue 99: * @ret_cmd: Container for the hfi packet for which this ack is received 100: * 101: * Return: 0 on success or negative error on failure 102: */ 103: int gen7_receive_ack_cmd(struct gen7_gmu_device *gmu, void *rcvd, 104: struct pending_cmd *ret_cmd); 105: 106: /** 107: * gen7_hfi_send_feature_ctrl - Enable gmu feature via hfi 108: * @adreno_dev: Pointer to the adreno device 109: * @feature: feature to be enabled or disabled 110: * enable: Set 1 to enable or 0 to disable a feature 111: * @data: payload for the send feature hfi packet 112: * 113: * Return: 0 on success or negative error on failure 114: */ 115: int gen7_hfi_send_feature_ctrl(struct adreno_device *adreno_dev, 116: u32 feature, u32 enable, u32 data); 117: 118: /** 119: * gen7_hfi_send_get_value - Send gmu get_values via hfi 120: * @adreno_dev: Pointer to the adreno device 121: * @type: GMU get_value type 122: * @subtype: GMU get_value subtype 123: * 124: * Return: 0 on success or negative error on failure 125: */ 126: int gen7_hfi_send_get_value(struct adreno_device *adreno_dev, u32 type, u32 subtype); 127: 128: /** 129: * gen7_hfi_send_set_value - Send gmu set_values via hfi 130: * @adreno_dev: Pointer to the adreno device 131: * @type: GMU set_value type 132: * @subtype: GMU set_value subtype 133: * @data: Value to set 134: * 135: * Return: 0 on success or negative error on failure 136: */ 137: int gen7_hfi_send_set_value(struct adreno_device *adreno_dev, 138: u32 type, u32 subtype, u32 data); 139: 140: /** 141: * gen7_hfi_send_core_fw_start - Send the core fw start hfi 142: * @adreno_dev: Pointer to the adreno device 143: * 144: * Return: 0 on success or negative error on failure 145: */ 146: int gen7_hfi_send_core_fw_start(struct adreno_device *adreno_dev); 147: 148: /** 149: * gen7_hfi_send_acd_feature_ctrl - Send the acd table and acd feature 150: * @adreno_dev: Pointer to the adreno device 151: * 152: * Return: 0 on success or negative error on failure 153: */ 154: int gen7_hfi_send_acd_feature_ctrl(struct adreno_device *adreno_dev); 155: 156: /** 157: * gen7_hfi_send_generic_req - Send a generic hfi packet 158: * @adreno_dev: Pointer to the adreno device 159: * @cmd: Pointer to the hfi packet header and data 160: * @size_bytes: Size of the packet in bytes 161: * 162: * Return: 0 on success or negative error on failure 163: */ 164: int gen7_hfi_send_generic_req(struct adreno_device *adreno_dev, void *cmd, u32 size_bytes); 165: 166: /** 167: * gen7_hfi_send_generic_req_v5 - Send a generic hfi packet with additional error handling 168: * @adreno_dev: Pointer to the adreno device 169: * @cmd: Pointer to the hfi packet header and data 170: * @ret_cmd: Ack for the command we just sent 171: * @size_bytes: Size of the packet in bytes 172: * 173: * Return: 0 on success or negative error on failure 174: */ 175: int gen7_hfi_send_generic_req_v5(struct adreno_device *adreno_dev, void *cmd, 176: struct pending_cmd *ret_cmd, u32 size_bytes); 177: 178: /** 179: * gen7_hfi_send_bcl_feature_ctrl - Send the bcl feature hfi packet 180: * @adreno_dev: Pointer to the adreno device 181: * 182: * Return: 0 on success or negative error on failure 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 225: * @size_bytes: Size of the command in bytes 226: * 227: * This function takes the cmdq lock before writing data to the queue 228: 229: * Return: 0 on success or negative error on failure 230: */ 231: int gen7_hfi_cmdq_write(struct adreno_device *adreno_dev, u32 *msg, u32 size_bytes); 232: void adreno_gen7_receive_err_req(struct gen7_gmu_device *gmu, void *rcvd); 233: void adreno_gen7_receive_debug_req(struct gen7_gmu_device *gmu, void *rcvd); 234: #endif --- FILE: \adreno_gen7_hwsched.c | HITS: 203 --- MATCH LINES: 15 3: * Copyright (c) 2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #include 8: 9: #include "adreno.h" 10: #include "adreno_gen7.h" 11: #include "adreno_gen7_hwsched.h" 12: #include "adreno_snapshot.h" 13: #include "kgsl_bus.h" 14: #include "kgsl_device.h" 15: #include "kgsl_gmu_core.h" 16: #include "kgsl_trace.h" 17: #include "kgsl_util.h" 18: 19: static void _wakeup_hw_fence_waiters(struct adreno_device *adreno_dev, u32 fault) 20: { 21: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev); 22: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 23: bool lock = !in_interrupt(); 24: 25: if (!test_bit(ADRENO_HWSCHED_HW_FENCE, &adreno_dev->hwsched.flags)) 26: return; 27: 28: /* 29: * We could be in interrupt context here, which means we need to use spin_lock_irqsave 30: * (which disables interrupts) everywhere we take this lock. Instead of that, simply 31: * avoid taking this lock if we are recording a fault from an interrupt handler. 32: */ 33: if (lock) 34: spin_lock(&hwf->lock); 35: 36: clear_bit(GEN7_HWSCHED_HW_FENCE_SLEEP_BIT, &hwf->flags); 37: 38: /* Avoid creating new hardware fences until recovery is complete */ 39: set_bit(GEN7_HWSCHED_HW_FENCE_ABORT_BIT, &hwf->flags); MATCH LINES: 74, 84, 93, 95, 101, 107, 113, 119, 123, 129, 135, 136, 139, 142, 143, 152, 154, 155, 158, 162, 167, 173, 187, 191, 195, 201, 208, 210, 214, 217, 223, 227, 236, 242, 246, 248, 252, 253, 256, 258, 259, 264, 271, 273, 274, 278, 281, 286, 291, 302, 320, 324, 326, 331, 335, 339, 341, 345, 351, 353, 354, 358, 361, 366, 375, 376, 386, 388, 390, 396, 400, 405, 409, 417, 423, 428, 430, 432, 436, 440, 445, 446, 447 62: adreno_scheduler_fault(adreno_dev, fault); 63: } 64: 65: void gen7_hwsched_snapshot(struct adreno_device *adreno_dev, 66: struct kgsl_snapshot *snapshot) 67: { 68: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 69: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 70: bool skip_memkind_rb = false; 71: u32 i; 72: bool parse_payload; 73: 74: gen7_gmu_snapshot(adreno_dev, snapshot); 75: 76: adreno_hwsched_parse_fault_cmdobj(adreno_dev, snapshot); 77: 78: /* 79: * First try to dump ringbuffers using context bad HFI payloads 80: * because they have all the ringbuffer parameters. If ringbuffer 81: * payloads are not present, fall back to dumping ringbuffers 82: * based on MEMKIND_RB 83: */ 84: if (GMU_VER_MINOR(device->gmu_core.ver.hfi) < 2) 85: parse_payload = adreno_hwsched_parse_payload_rb_legacy(adreno_dev, snapshot); 86: else 87: parse_payload = adreno_hwsched_parse_payload_rb(adreno_dev, snapshot); 88: 89: if (parse_payload) 90: skip_memkind_rb = true; 91: 92: for (i = 0; i < hwsched->mem_alloc_entries; i++) { 93: struct hfi_mem_alloc_entry *entry = &hwsched->mem_alloc_table[i]; 94: 95: if (entry->desc.mem_kind == HFI_MEMKIND_RB && !skip_memkind_rb) 96: kgsl_snapshot_add_section(device, 97: KGSL_SNAPSHOT_SECTION_RB_V2, 98: snapshot, adreno_hwsched_snapshot_rb, 99: entry->md); 100: 101: if (entry->desc.mem_kind == HFI_MEMKIND_SCRATCH) 102: kgsl_snapshot_add_section(device, 103: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 104: snapshot, adreno_snapshot_global, 105: entry->md); 106: 107: if (entry->desc.mem_kind == HFI_MEMKIND_PROFILE) 108: kgsl_snapshot_add_section(device, 109: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 110: snapshot, adreno_snapshot_global, 111: entry->md); 112: 113: if (entry->desc.mem_kind == HFI_MEMKIND_CSW_SMMU_INFO) 114: kgsl_snapshot_add_section(device, 115: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 116: snapshot, adreno_snapshot_global, 117: entry->md); 118: 119: if (entry->desc.mem_kind == HFI_MEMKIND_CSW_PRIV_NON_SECURE) 120: adreno_hwsched_snapshot_preemption_records(device, snapshot, 121: entry->md); 122: 123: if (entry->desc.mem_kind == HFI_MEMKIND_PREEMPT_SCRATCH) 124: kgsl_snapshot_add_section(device, 125: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 126: snapshot, adreno_snapshot_global, 127: entry->md); 128: 129: if (entry->desc.mem_kind == HFI_MEMKIND_AQE_BUFFER) 130: kgsl_snapshot_add_section(device, 131: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 132: snapshot, adreno_hwsched_snapshot_aqe_buffer, 133: entry->md); 134: 135: if (entry->desc.mem_kind == HFI_MEMKIND_HW_FENCE) { 136: struct gmu_mem_type_desc desc; 137: 138: desc.memdesc = entry->md; 139: desc.type = SNAPSHOT_GMU_MEM_HW_FENCE; 140: 141: kgsl_snapshot_add_section(device, 142: KGSL_SNAPSHOT_SECTION_GMU_MEMORY, 143: snapshot, adreno_snapshot_gmu_mem, &desc); 144: } 145: 146: } 147: 148: if (adreno_hwsched_context_queue_enabled(adreno_dev)) 149: adreno_hwsched_snapshot_context_queue(device, snapshot); 150: } 151: 152: static void gen7_hwsched_gmu_suspend(struct adreno_device *adreno_dev, bool force) 153: { 154: gen7_gmu_suspend(adreno_dev, force); 155: adreno_hwsched_reset_hfi_mem(adreno_dev); 156: } 157: 158: static int gen7_hwsched_gmu_first_boot(struct adreno_device *adreno_dev) 159: { 160: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 161: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 162: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 163: int level, ret = 0; 164: 165: kgsl_pwrctrl_request_state(device, KGSL_STATE_AWARE); 166: 167: gen7_gmu_aop_send_acd_state(gmu, adreno_dev->acd_enabled); 168: 169: ret = kgsl_pwrctrl_enable_cx_gdsc(device); 170: if (ret) 171: return ret; 172: 173: ret = gmu_core_enable_clks(device, device->gmu_core.num_freqs - 1); 174: if (ret) 175: goto gdsc_off; 176: 177: /* 178: * Enable AHB timeout detection to catch any register access taking longer 179: * time before NOC timeout gets detected. Enable this logic before any 180: * register access which happens to be just after enabling clocks. 181: */ 182: gen7_enable_ahb_timeout_detection(adreno_dev); 183: 184: /* Initialize the CX timer */ 185: gen7_cx_timer_init(adreno_dev); 186: 187: ret = gen7_gmu_load_fw(adreno_dev); 188: if (ret) 189: goto clks_gdsc_off; 190: 191: ret = gen7_gmu_itcm_shadow(adreno_dev); 192: if (ret) 193: goto clks_gdsc_off; 194: 195: if (!test_bit(GMU_PRIV_PDC_RSC_LOADED, &gmu->flags)) { 196: ret = gen7_load_pdc_ucode(adreno_dev); 197: if (ret) 198: goto clks_gdsc_off; 199: 200: gen7_load_rsc_ucode(adreno_dev); 201: set_bit(GMU_PRIV_PDC_RSC_LOADED, &gmu->flags); 202: } 203: 204: ret = gen7_scm_gpu_init_cx_regs(adreno_dev); 205: if (ret) 206: goto clks_gdsc_off; 207: 208: gen7_gmu_register_config(adreno_dev); 209: 210: ret = gen7_gmu_version_info(adreno_dev); 211: if (ret) 212: goto clks_gdsc_off; 213: 214: if (GMU_VER_MINOR(device->gmu_core.ver.hfi) < 2) 215: set_bit(ADRENO_HWSCHED_CTX_BAD_LEGACY, &adreno_dev->hwsched.flags); 216: 217: gen7_gmu_irq_enable(adreno_dev); 218: 219: /* Vote for minimal DDR BW for GMU to init */ 220: level = pwr->pwrlevels[pwr->default_pwrlevel].bus_min; 221: 222: /* From this GMU FW all RBBM interrupts are handled at GMU */ 223: if (device->gmu_core.ver.core >= GMU_VERSION(5, 01, 06)) 224: adreno_irq_free(adreno_dev); 225: 226: /* GMU supports force retire command from this GMU FW */ 227: if (gmu_core_capabilities_enabled(&device->gmu_core.common_caps, 228: FAC_FORCE_RETIRE_COMMAND)) 229: set_bit(ADRENO_HWSCHED_FORCE_RETIRE_GMU, &adreno_dev->hwsched.flags); 230: 231: icc_set_bw(pwr->icc_path, 0, kBps_to_icc(pwr->ddr_table[level])); 232: 233: /* Clear any hwsched faults that might have been left over */ 234: adreno_clear_gpu_fault(adreno_dev); 235: 236: ret = gen7_gmu_device_start(adreno_dev); 237: if (ret) 238: goto err; 239: 240: gen7_get_gpu_feature_info(adreno_dev); 241: 242: ret = gen7_hwsched_hfi_start(adreno_dev); 243: if (ret) 244: goto err; 245: 246: ret = gmu_core_clock_set_rate(device, 0); 247: if (ret) { 248: gen7_hwsched_hfi_stop(adreno_dev); 249: goto err; 250: } 251: 252: if (adreno_dev->gmu_ab && 253: gen7_hwsched_hfi_get_value(adreno_dev, HFI_VALUE_GMU_AB_VOTE) == 1 && 254: !WARN_ONCE(!adreno_dev->gpucore->num_ddr_channels, 255: "Number of DDR channel is not specified in gpu core")) { 256: set_bit(ADRENO_DEVICE_GMU_AB, &adreno_dev->priv); 257: } else { 258: /* If gmu_ab feature flag is enabled but GMU doesn't support it, set it to false */ 259: adreno_dev->gmu_ab = false; 260: } 261: 262: icc_set_bw(pwr->icc_path, 0, 0); 263: 264: device->gmu_fault = false; 265: 266: kgsl_pwrctrl_set_state(device, KGSL_STATE_AWARE); 267: 268: return 0; 269: 270: err: 271: gen7_gmu_irq_disable(adreno_dev); 272: 273: if (device->gmu_fault) { 274: gen7_hwsched_gmu_suspend(adreno_dev, false); 275: return ret; 276: } 277: 278: adreno_hwsched_reset_hfi_mem(adreno_dev); 279: 280: clks_gdsc_off: 281: gmu_core_disable_clks(device); 282: 283: gdsc_off: 284: kgsl_pwrctrl_disable_cx_gdsc(device); 285: 286: gmu_core_rdpm_cx_freq_update(device, 0); 287: 288: return ret; 289: } 290: 291: static int gen7_hwsched_gmu_boot(struct adreno_device *adreno_dev) 292: { 293: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 294: int ret = 0; 295: 296: kgsl_pwrctrl_request_state(device, KGSL_STATE_AWARE); 297: 298: ret = kgsl_pwrctrl_enable_cx_gdsc(device); 299: if (ret) 300: return ret; 301: 302: ret = gmu_core_enable_clks(device, device->gmu_core.num_freqs - 1); 303: if (ret) 304: goto gdsc_off; 305: 306: /* 307: * Enable AHB timeout detection to catch any register access taking longer 308: * time before NOC timeout gets detected. Enable this logic before any 309: * register access which happens to be just after enabling clocks. 310: */ 311: gen7_enable_ahb_timeout_detection(adreno_dev); 312: 313: /* Initialize the CX timer */ 314: gen7_cx_timer_init(adreno_dev); 315: 316: ret = gen7_rscc_wakeup_sequence(adreno_dev); 317: if (ret) 318: goto clks_gdsc_off; 319: 320: ret = gen7_gmu_load_fw(adreno_dev); 321: if (ret) 322: goto clks_gdsc_off; 323: 324: gen7_gmu_register_config(adreno_dev); 325: 326: gen7_gmu_irq_enable(adreno_dev); 327: 328: /* Clear any hwsched faults that might have been left over */ 329: adreno_clear_gpu_fault(adreno_dev); 330: 331: ret = gen7_gmu_device_start(adreno_dev); 332: if (ret) 333: goto err; 334: 335: ret = gen7_hwsched_hfi_start(adreno_dev); 336: if (ret) 337: goto err; 338: 339: ret = gmu_core_clock_set_rate(device, 0); 340: if (ret) { 341: gen7_hwsched_hfi_stop(adreno_dev); 342: goto err; 343: } 344: 345: device->gmu_fault = false; 346: 347: kgsl_pwrctrl_set_state(device, KGSL_STATE_AWARE); 348: 349: return 0; 350: err: 351: gen7_gmu_irq_disable(adreno_dev); 352: 353: if (device->gmu_fault) { 354: gen7_hwsched_gmu_suspend(adreno_dev, false); 355: return ret; 356: } 357: 358: adreno_hwsched_reset_hfi_mem(adreno_dev); 359: 360: clks_gdsc_off: 361: gmu_core_disable_clks(device); 362: 363: gdsc_off: 364: kgsl_pwrctrl_disable_cx_gdsc(device); 365: 366: gmu_core_rdpm_cx_freq_update(device, 0); 367: 368: return ret; 369: } 370: 371: static int gen7_hwsched_notify_slumber(struct adreno_device *adreno_dev) 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: 425: /* Now that we are done with GMU and GPU, Clear the GBIF */ 426: ret = gen7_halt_gbif(adreno_dev); 427: 428: gen7_gmu_irq_disable(adreno_dev); 429: 430: gen7_hwsched_hfi_stop(adreno_dev); 431: 432: gmu_core_disable_clks(device); 433: 434: kgsl_pwrctrl_disable_cx_gdsc(device); 435: 436: gmu_core_rdpm_cx_freq_update(device, 0); 437: 438: kgsl_pwrctrl_set_state(device, KGSL_STATE_NONE); 439: 440: adreno_hwsched_reset_hfi_mem(adreno_dev); 441: 442: return ret; 443: 444: error: 445: gen7_gmu_irq_disable(adreno_dev); 446: gen7_hwsched_hfi_stop(adreno_dev); 447: gen7_hwsched_gmu_suspend(adreno_dev, false); 448: 449: return ret; 450: } 451: 452: static void gen7_hwsched_init_ucode_regs(struct adreno_device *adreno_dev) 453: { 454: struct adreno_firmware *fw = ADRENO_FW(adreno_dev, ADRENO_FW_SQE); 455: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 456: 457: /* Program the ucode base for CP */ 458: kgsl_regwrite(device, GEN7_CP_SQE_INSTR_BASE_LO, 459: lower_32_bits(fw->memdesc->gpuaddr)); 460: kgsl_regwrite(device, GEN7_CP_SQE_INSTR_BASE_HI, 461: upper_32_bits(fw->memdesc->gpuaddr)); 462: 463: if (ADRENO_FEATURE(adreno_dev, ADRENO_AQE)) { 464: fw = ADRENO_FW(adreno_dev, ADRENO_FW_AQE); 465: 466: /* Program the ucode base for AQE0 (BV coprocessor) */ 467: kgsl_regwrite(device, GEN7_CP_AQE_INSTR_BASE_LO_0, 468: lower_32_bits(fw->memdesc->gpuaddr)); 469: kgsl_regwrite(device, GEN7_CP_AQE_INSTR_BASE_HI_0, 470: upper_32_bits(fw->memdesc->gpuaddr)); 471: MATCH LINES: 491 479: } 480: } 481: 482: static int gen7_hwsched_gpu_boot(struct adreno_device *adreno_dev) 483: { 484: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 485: int ret; 486: 487: ret = kgsl_mmu_start(device); 488: if (ret) 489: goto err; 490: 491: ret = gen7_gmu_oob_set(device, oob_gpu); 492: if (ret) 493: goto err; 494: 495: /* Clear the busy_data stats - we're starting over from scratch */ 496: memset(&adreno_dev->busy_data, 0, sizeof(adreno_dev->busy_data)); 497: 498: gen7_start(adreno_dev); 499: 500: /* Re-initialize the coresight registers if applicable */ 501: adreno_coresight_start(adreno_dev); 502: 503: adreno_perfcounter_start(adreno_dev); 504: 505: /* Clear FSR here in case it is set from a previous pagefault */ 506: kgsl_mmu_clear_fsr(&device->mmu); 507: 508: gen7_enable_gpu_irq(adreno_dev); 509: 510: gen7_hwsched_init_ucode_regs(adreno_dev); 511: 512: ret = gen7_hwsched_boot_gpu(adreno_dev); 513: if (ret) { 514: adreno_llcc_slice_deactivate(adreno_dev); 515: goto err; MATCH LINES: 533, 535, 538, 551, 554, 557, 560, 561, 562, 563, 569, 570, 577, 582, 586, 590, 594, 598, 604, 611, 612, 615, 620, 630, 649, 654, 662, 673, 675, 688, 714, 717, 734, 740, 753, 754 521: * if we are prioritizing the first unrecoverable snapshot. 522: */ 523: if (device->snapshot) 524: device->snapshot->recovered = true; 525: 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); 563: ret = PTR_ERR_OR_ZERO(gmu->gmu_init_scratch); 564: if (ret) 565: return ret; 566: } 567: 568: if (IS_ERR_OR_NULL(gmu->gpu_boot_scratch)) { 569: gmu->gpu_boot_scratch = gmu_core_reserve_kernel_block(device, 0, 570: SZ_4K, GMU_CACHE, 0); 571: ret = PTR_ERR_OR_ZERO(gmu->gpu_boot_scratch); 572: } 573: 574: return ret; 575: } 576: 577: static int gen7_hwsched_gmu_init(struct adreno_device *adreno_dev) 578: { 579: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 580: int ret; 581: 582: ret = gen7_gmu_parse_fw(adreno_dev); 583: if (ret) 584: return ret; 585: 586: ret = gen7_gmu_memory_init(adreno_dev); 587: if (ret) 588: return ret; 589: 590: ret = gen7_gmu_warmboot_init(adreno_dev); 591: if (ret) 592: return ret; 593: 594: ret = gmu_core_hwsched_memory_init(device); 595: if (ret) 596: return ret; 597: 598: return gen7_hwsched_hfi_init(adreno_dev); 599: } 600: 601: static void gen7_hwsched_touch_wakeup(struct adreno_device *adreno_dev) 602: { 603: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 604: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 605: int ret; 606: 607: /* 608: * Do not wake up a suspended device or until the first boot sequence 609: * has been completed. 610: */ 611: if (test_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags) || 612: !test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags)) 613: return; 614: 615: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 616: goto done; 617: 618: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE); 619: 620: ret = gen7_hwsched_gmu_boot(adreno_dev); 621: if (ret) 622: return; 623: 624: ret = gen7_hwsched_gpu_boot(adreno_dev); 625: if (ret) 626: return; 627: 628: kgsl_pwrscale_wake(device); 629: 630: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 631: 632: device->pwrctrl.last_stat_updated = ktime_get(); 633: 634: kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE); 635: 636: done: 637: /* 638: * When waking up from a touch event we want to stay active long enough 639: * for the user to send a draw command. The default idle timer timeout 640: * is shorter than we want so go ahead and push the idle timer out 641: * further for this special case 642: */ 643: mod_timer(&device->idle_timer, jiffies + 644: msecs_to_jiffies(adreno_wake_timeout)); 645: } 646: 647: static int gen7_hwsched_boot(struct adreno_device *adreno_dev) 648: { 649: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 650: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 651: bool bcl_state = adreno_dev->bcl_enabled; 652: int ret; 653: 654: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 655: return 0; 656: 657: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE); 658: 659: adreno_hwsched_start(adreno_dev); 660: 661: if (IS_ENABLED(CONFIG_QCOM_KGSL_HIBERNATION) && 662: !test_bit(GMU_PRIV_PDC_RSC_LOADED, &gmu->flags)) { 663: /* 664: * During hibernation entry ZAP was unloaded and 665: * CBCAST BCL register is in reset state. 666: * Set bcl_enabled to false to skip KMD's HFI request 667: * to GMU for BCL feature, send BCL feature request to 668: * GMU after ZAP load at GPU boot. This ensures that 669: * Central Broadcast register was programmed before 670: * enabling BCL. 671: */ 672: adreno_dev->bcl_enabled = false; 673: ret = gen7_hwsched_gmu_first_boot(adreno_dev); 674: } else { 675: ret = gen7_hwsched_gmu_boot(adreno_dev); 676: } 677: 678: if (ret) 679: return ret; 680: 681: ret = gen7_hwsched_gpu_boot(adreno_dev); 682: if (ret) 683: return ret; 684: 685: kgsl_start_idle_timer(device); 686: kgsl_pwrscale_wake(device); 687: 688: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 689: 690: if (IS_ENABLED(CONFIG_QCOM_KGSL_HIBERNATION)) 691: adreno_dev->bcl_enabled = bcl_state; 692: 693: device->pwrctrl.last_stat_updated = ktime_get(); 694: 695: kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE); 696: 697: return ret; 698: } 699: 700: static int gen7_aqe_microcode_read(struct adreno_device *adreno_dev) 701: { 702: struct adreno_firmware *aqe_fw = ADRENO_FW(adreno_dev, ADRENO_FW_AQE); 703: const struct adreno_gen7_core *gen7_core = to_gen7_core(adreno_dev); 704: 705: if (!ADRENO_FEATURE(adreno_dev, ADRENO_AQE)) 706: return 0; 707: 708: return adreno_get_firmware(adreno_dev, gen7_core->aqefw_name, aqe_fw); 709: } 710: 711: static int gen7_hwsched_first_boot(struct adreno_device *adreno_dev) 712: { 713: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 714: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 715: int ret; 716: 717: if (test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags)) 718: return gen7_hwsched_boot(adreno_dev); 719: 720: adreno_hwsched_start(adreno_dev); 721: 722: ret = gen7_microcode_read(adreno_dev); 723: if (ret) 724: return ret; 725: 726: ret = gen7_aqe_microcode_read(adreno_dev); 727: if (ret) 728: return ret; 729: 730: ret = gen7_init(adreno_dev); 731: if (ret) 732: return ret; 733: 734: ret = gen7_hwsched_gmu_init(adreno_dev); 735: if (ret) 736: return ret; 737: 738: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE); 739: 740: ret = gen7_hwsched_gmu_first_boot(adreno_dev); 741: if (ret) 742: return ret; 743: 744: ret = gen7_hwsched_gpu_boot(adreno_dev); 745: if (ret) 746: return ret; 747: 748: adreno_get_bus_counters(adreno_dev); 749: 750: adreno_dev->cooperative_reset = ADRENO_FEATURE(adreno_dev, 751: ADRENO_COOP_RESET); 752: 753: set_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags); 754: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 755: 756: /* 757: * BCL needs respective Central Broadcast register to 758: * be programed from TZ. This programing happens only 759: * when zap shader firmware load is successful. Zap firmware 760: * load can fail in boot up path hence enable BCL only after we 761: * successfully complete first boot to ensure that Central 762: * Broadcast register was programed before enabling BCL. 763: */ 764: if (ADRENO_FEATURE(adreno_dev, ADRENO_BCL)) 765: adreno_dev->bcl_enabled = true; 766: 767: /* 768: * There is a possible deadlock scenario during kgsl firmware reading 769: * (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl 770: * device mutex is held and then firmware_request_nowarn is called for reading 771: * firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock. 772: * Whereas in case of devfreq update calls triggered by thermal/bcl or 773: * devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then 774: * tries to take kgsl device mutex as part of get_dev_status/target 775: * calls. This results in deadlock when both thread are unable to acquire 776: * the mutex held by other thread. Enable devfreq updates now as we are 777: * done reading all firmware files. 778: */ MATCH LINES: 815, 838, 848, 856, 860, 865, 867, 878, 887, 897, 928, 931, 943, 964, 1002, 1008, 1028, 1030, 1037, 1043, 1054, 1064, 1067, 1075, 1076, 1080, 1105, 1117, 1123, 1135, 1138, 1151, 1161, 1175, 1177, 1185, 1194, 1196, 1197, 1199, 1201, 1204, 1236, 1249 803: } 804: spin_unlock(&drawctxt->lock); 805: } 806: 807: static void drain_hw_fences_cpu(struct adreno_device *adreno_dev) 808: { 809: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 810: struct kgsl_context *context; 811: int id; 812: 813: read_lock(&device->context_lock); 814: idr_for_each_entry(&device->context_idr, context, id) { 815: if (context->gmu_registered) 816: drain_ctx_hw_fences_cpu(adreno_dev, ADRENO_CONTEXT(context)); 817: } 818: read_unlock(&device->context_lock); 819: } 820: 821: /** 822: * check_inflight_hw_fences - During SLUMBER entry, we must make sure all hardware fences across 823: * all registered contexts have been sent to TxQueue. If not, take a snapshot 824: */ 825: static int check_inflight_hw_fences(struct adreno_device *adreno_dev) 826: { 827: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 828: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 829: struct kgsl_context *context; 830: int id, ret = 0; 831: 832: if (!test_bit(ADRENO_HWSCHED_HW_FENCE, &hwsched->flags)) 833: return 0; 834: 835: read_lock(&device->context_lock); 836: idr_for_each_entry(&device->context_idr, context, id) { 837: 838: if (context->gmu_registered) { 839: ret = gen7_hwsched_check_context_inflight_hw_fences(adreno_dev, 840: ADRENO_CONTEXT(context)); 841: if (ret) 842: break; 843: } 844: } 845: read_unlock(&device->context_lock); 846: 847: if (ret) 848: gmu_core_fault_snapshot(device, GMU_FAULT_HW_FENCE); 849: 850: return ret; 851: } 852: 853: static int gen7_hwsched_power_off(struct adreno_device *adreno_dev) 854: { 855: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 856: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 857: int ret = 0; 858: bool drain_cpu = false; 859: 860: if (!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 861: return 0; 862: 863: kgsl_pwrctrl_request_state(device, KGSL_STATE_SLUMBER); 864: 865: ret = gen7_gmu_oob_set(device, oob_gpu); 866: if (ret) { 867: gen7_gmu_oob_clear(device, oob_gpu); 868: goto no_gx_power; 869: } 870: 871: kgsl_pwrscale_update_stats(device); 872: 873: /* Save active coresight registers if applicable */ 874: adreno_coresight_stop(adreno_dev); 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: { 912: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 913: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 914: u32 unack_count; 915: 916: if (!test_bit(ADRENO_HWSCHED_HW_FENCE, &adreno_dev->hwsched.flags)) 917: return; 918: 919: gen7_hwsched_process_msgq(adreno_dev); 920: 921: spin_lock(&hwf->lock); 922: unack_count = hwf->unack_count; 923: spin_unlock(&hwf->lock); 924: 925: if (!unack_count) 926: return; 927: 928: dev_err(GMU_PDEV_DEV(device), 929: "hardware fence unack_count(%d) isn't zero before SLUMBER\n", 930: unack_count); 931: gmu_core_fault_snapshot(device, GMU_FAULT_HW_FENCE); 932: } 933: 934: static void hwsched_idle_check(struct work_struct *work) 935: { 936: struct kgsl_device *device = container_of(work, 937: struct kgsl_device, idle_check_ws); 938: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 939: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 940: 941: kgsl_mutex_lock(&device->mutex); 942: 943: if (test_bit(GMU_DISABLE_SLUMBER, &device->gmu_core.flags)) 944: goto done; 945: 946: if (atomic_read(&device->active_cnt) || time_is_after_jiffies(device->idle_jiffies)) { 947: kgsl_pwrscale_update(device); 948: goto done; 949: } 950: 951: spin_lock(&device->submit_lock); 952: if (device->submit_now) { 953: spin_unlock(&device->submit_lock); 954: kgsl_pwrscale_update(device); 955: kgsl_start_idle_timer(device); 956: goto done; 957: } 958: 959: device->skip_inline_submit = true; 960: spin_unlock(&device->submit_lock); 961: 962: if (!gpudev->hw_isidle(adreno_dev)) { 963: dev_err(device->dev, "GPU isn't idle before SLUMBER\n"); 964: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE); 965: } 966: 967: check_hw_fence_unack_count(adreno_dev); 968: 969: gen7_hwsched_power_off(adreno_dev); 970: 971: done: 972: kgsl_mutex_unlock(&device->mutex); 973: } 974: 975: static int gen7_hwsched_first_open(struct adreno_device *adreno_dev) 976: { 977: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 978: int ret; 979: 980: /* 981: * Do the one time settings that need to happen when we 982: * attempt to boot the gpu the very first time 983: */ 984: ret = gen7_hwsched_first_boot(adreno_dev); 985: if (ret) 986: return ret; 987: 988: /* 989: * A client that does a first_open but never closes the device 990: * may prevent us from going back to SLUMBER. So trigger the idle 991: * check by incrementing the active count and immediately releasing it. 992: */ 993: atomic_inc(&device->active_cnt); 994: adreno_active_count_put(adreno_dev); 995: 996: return 0; 997: } 998: 999: static int gen7_hwsched_active_count_get(struct adreno_device *adreno_dev) 1000: { 1001: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1002: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1003: int ret = 0; 1004: 1005: if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex))) 1006: return -EINVAL; 1007: 1008: if (test_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags)) 1009: return -EINVAL; 1010: 1011: if ((atomic_read(&device->active_cnt) == 0)) 1012: ret = gen7_hwsched_boot(adreno_dev); 1013: 1014: if (ret == 0) 1015: atomic_inc(&device->active_cnt); 1016: 1017: trace_kgsl_active_count(device, 1018: (unsigned long) __builtin_return_address(0)); 1019: 1020: return ret; 1021: } 1022: 1023: static int gen7_hwsched_dcvs_set(struct adreno_device *adreno_dev, 1024: int gpu_pwrlevel, int bus_level, u32 ab) 1025: { 1026: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1027: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1028: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1029: struct gen7_dcvs_table *table = &gmu->dcvs_table; 1030: struct hfi_gx_bw_perf_vote_cmd req = { 1031: .ack_type = DCVS_ACK_BLOCK, 1032: .freq = INVALID_DCVS_IDX, 1033: .bw = INVALID_DCVS_IDX, 1034: }; 1035: int ret; 1036: 1037: if (!test_bit(GMU_PRIV_HFI_STARTED, &gmu->flags)) 1038: return 0; 1039: 1040: /* Do not set to XO and lower GPU clock vote from GMU */ 1041: if ((gpu_pwrlevel != INVALID_DCVS_IDX) && 1042: (gpu_pwrlevel >= table->gpu_level_num - 1)) { 1043: dev_err(GMU_PDEV_DEV(device), "Invalid gpu dcvs request: %d\n", 1044: gpu_pwrlevel); 1045: return -EINVAL; 1046: } 1047: 1048: if (gpu_pwrlevel < table->gpu_level_num - 1) 1049: req.freq = table->gpu_level_num - gpu_pwrlevel - 1; 1050: 1051: if (bus_level < pwr->ddr_table_count && bus_level > 0) 1052: req.bw = bus_level; 1053: 1054: req.bw |= adreno_gmu_bus_ab_quantize(adreno_dev, ab); 1055: 1056: /* GMU will vote for slumber levels through the sleep sequence */ 1057: if ((req.freq == INVALID_DCVS_IDX) && (req.bw == INVALID_BW_VOTE)) 1058: return 0; 1059: 1060: ret = CMD_MSG_HDR(req, H2F_MSG_GX_BW_PERF_VOTE); 1061: if (ret) 1062: return ret; 1063: 1064: ret = gen7_hfi_send_cmd_async(adreno_dev, &req, sizeof(req)); 1065: 1066: if (ret) { 1067: dev_err_ratelimited(GMU_PDEV_DEV(device), 1068: "Failed to set GPU perf idx %u, bw idx %u\n", 1069: req.freq, req.bw); 1070: 1071: /* 1072: * If this was a dcvs request along side an active gpu, request 1073: * dispatcher based reset and recovery. 1074: */ 1075: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 1076: gen7_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 1077: } 1078: 1079: if (req.freq != INVALID_DCVS_IDX) 1080: gmu_core_rdpm_mx_freq_update(device, table->gx_votes[req.freq].freq); 1081: 1082: return ret; 1083: } 1084: 1085: static int gen7_hwsched_clock_set(struct adreno_device *adreno_dev, 1086: u32 pwrlevel) 1087: { 1088: return gen7_hwsched_dcvs_set(adreno_dev, pwrlevel, INVALID_DCVS_IDX, INVALID_AB_VALUE); 1089: } 1090: 1091: static int gen7_hwsched_bus_set(struct adreno_device *adreno_dev, int buslevel, 1092: u32 ab) 1093: { 1094: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1095: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1096: int ret = 0; 1097: 1098: /* Target gen7_9_x votes for perfmode through ACV. Skip icc path for same */ 1099: if (!adreno_is_gen7_9_x(adreno_dev)) 1100: kgsl_icc_set_tag(pwr, buslevel); 1101: 1102: if (buslevel == pwr->cur_buslevel) 1103: buslevel = INVALID_DCVS_IDX; 1104: 1105: if ((ab == pwr->cur_ab) || ((ab == 0) && (adreno_dev->gmu_ab))) 1106: ab = INVALID_AB_VALUE; 1107: 1108: if ((ab == INVALID_AB_VALUE) && (buslevel == INVALID_DCVS_IDX)) 1109: return 0; 1110: 1111: ret = gen7_hwsched_dcvs_set(adreno_dev, INVALID_DCVS_IDX, 1112: buslevel, ab); 1113: if (ret) 1114: return ret; 1115: 1116: if (buslevel != INVALID_DCVS_IDX) { 1117: gmu_core_scale_gmu_frequency(device, buslevel); 1118: 1119: pwr->cur_buslevel = buslevel; 1120: } 1121: 1122: if (ab != INVALID_AB_VALUE) { 1123: if (!adreno_dev->gmu_ab) 1124: icc_set_bw(pwr->icc_path, MBps_to_icc(ab), 0); 1125: pwr->cur_ab = ab; 1126: } 1127: 1128: trace_kgsl_buslevel(device, pwr->active_pwrlevel, pwr->cur_buslevel, pwr->cur_ab, 0); 1129: return ret; 1130: } 1131: 1132: static int gen7_hwsched_pm_suspend(struct adreno_device *adreno_dev) 1133: { 1134: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1135: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1136: int ret, active_count; 1137: 1138: if (test_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags)) 1139: return 0; 1140: 1141: kgsl_pwrctrl_request_state(device, KGSL_STATE_SUSPEND); 1142: 1143: ret = adreno_hwsched_drain_and_idle(adreno_dev); 1144: if (ret) 1145: goto err; 1146: 1147: active_count = atomic_read(&device->active_cnt); 1148: 1149: if (active_count > 0) { 1150: ret = -ETIMEDOUT; 1151: dev_err_ratelimited(GMU_PDEV_DEV(device), 1152: "Aborting suspend because of active count:%d\n", 1153: active_count); 1154: goto err; 1155: } 1156: 1157: gen7_hwsched_power_off(adreno_dev); 1158: 1159: adreno_get_gpu_halt(adreno_dev); 1160: 1161: set_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags); 1162: 1163: kgsl_pwrctrl_set_state(device, KGSL_STATE_SUSPEND); 1164: 1165: return 0; 1166: 1167: err: 1168: adreno_hwsched_start(adreno_dev); 1169: 1170: return ret; 1171: } 1172: 1173: static void gen7_hwsched_pm_resume(struct adreno_device *adreno_dev) 1174: { 1175: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1176: 1177: if (WARN(!test_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags), 1178: "resume invoked without a suspend\n")) 1179: return; 1180: 1181: adreno_put_gpu_halt(adreno_dev); 1182: 1183: adreno_hwsched_start(adreno_dev); 1184: 1185: clear_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags); 1186: } 1187: 1188: void gen7_hwsched_handle_watchdog(struct adreno_device *adreno_dev) 1189: { 1190: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1191: u32 mask; 1192: 1193: /* Temporarily mask the watchdog interrupt to prevent a storm */ 1194: gmu_core_regread(device, GEN7_GMU_AO_HOST_INTERRUPT_MASK, 1195: &mask); 1196: gmu_core_regwrite(device, GEN7_GMU_AO_HOST_INTERRUPT_MASK, 1197: (mask | GMU_INT_WDOG_BITE)); 1198: 1199: gen7_gmu_send_nmi(device, false, GMU_FAULT_PANIC_NONE); 1200: 1201: dev_err_ratelimited(GMU_PDEV_DEV(device), 1202: "GMU watchdog expired interrupt received\n"); 1203: 1204: gen7_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 1205: } 1206: 1207: static void gen7_hwsched_drain_ctxt_unregister(struct adreno_device *adreno_dev) 1208: { 1209: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev); 1210: struct pending_cmd *cmd = NULL; 1211: 1212: read_lock(&hfi->msglock); 1213: 1214: list_for_each_entry(cmd, &hfi->msglist, node) { 1215: if (MSG_HDR_GET_ID(cmd->sent_hdr) == H2F_MSG_UNREGISTER_CONTEXT) 1216: complete(&cmd->complete); 1217: } 1218: 1219: read_unlock(&hfi->msglock); 1220: } 1221: 1222: /** 1223: * process_context_hw_fences_after_reset - This function processes all hardware fences that were 1224: * sent to GMU prior to recovery. If a fence is not retired by the GPU, and the context is still 1225: * good, then move them to the reset list. 1226: */ 1227: static void process_context_hw_fences_after_reset(struct adreno_device *adreno_dev, 1228: struct adreno_context *drawctxt, struct list_head *reset_list) 1229: { 1230: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1231: struct adreno_hw_fence_entry *entry, *tmp; 1232: 1233: spin_lock(&drawctxt->lock); 1234: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_inflight_list, node) { 1235: struct adreno_context *drawctxt = entry->drawctxt; 1236: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr; 1237: bool retired = kgsl_check_timestamp(device, &drawctxt->base, (u32)entry->cmd.ts); 1238: 1239: /* Delete the fences that GMU has sent to the TxQueue */ 1240: if (timestamp_cmp(hdr->out_fence_ts, (u32)entry->cmd.ts) >= 0) { 1241: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 1242: continue; 1243: } 1244: 1245: /* 1246: * Force retire the fences if the ts is retired and context is not 1247: * registered with GMU, or if the context is gone bad. 1248: */ 1249: if ((retired && !drawctxt->base.gmu_registered) || 1250: kgsl_context_is_bad(&drawctxt->base)) 1251: entry->cmd.flags |= HW_FENCE_FLAG_SKIP_MEMSTORE; 1252: 1253: list_add_tail(&entry->reset_node, reset_list); 1254: } 1255: spin_unlock(&drawctxt->lock); 1256: } 1257: 1258: /** 1259: * process_inflight_hw_fences_after_reset - Send hardware fences from all contexts back to the GMU 1260: * after fault recovery. We must wait for ack when sending each of these fences to GMU so as to 1261: * avoid sending a large number of hardware fences in a short span of time. 1262: */ 1263: static int process_inflight_hw_fences_after_reset(struct adreno_device *adreno_dev) 1264: { 1265: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1266: struct kgsl_context *context = NULL; 1267: int id, ret = 0; 1268: struct list_head hw_fence_list; 1269: struct adreno_hw_fence_entry *entry, *tmp; 1270: bool update_out_fence_ts = false; 1271: 1272: /* 1273: * Since we need to wait for ack from GMU when sending each inflight fence back to GMU, we MATCH LINES: 1294, 1317 1282: process_context_hw_fences_after_reset(adreno_dev, ADRENO_CONTEXT(context), 1283: &hw_fence_list); 1284: } 1285: read_unlock(&device->context_lock); 1286: 1287: /* 1288: * Although we are not destroying the entries here, they can get destroyed concurrently 1289: * in f2h_main thread once they have been sent to GMU. Hence, to be safe against entry 1290: * destroy, use list_for_each_entry_safe. 1291: */ 1292: list_for_each_entry_safe(entry, tmp, &hw_fence_list, reset_node) { 1293: struct adreno_context *drawctxt = entry->drawctxt; 1294: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr; 1295: u32 entry_ts = (u32)entry->cmd.ts; 1296: 1297: /* 1298: * We must remove this entry from hw_fence_list before sending it to GMU to avoid 1299: * racing with the f2h_main thread 1300: */ 1301: list_del_init(&entry->reset_node); 1302: 1303: /* 1304: * We must access the hw fence entry before sending it to GMU as once it is 1305: * sent to GMU, it may be freed by f2h_main thread concurrently 1306: */ 1307: if (((entry->cmd.flags & HW_FENCE_FLAG_SKIP_MEMSTORE) != 0) && 1308: (timestamp_cmp(entry_ts, hdr->out_fence_ts) > 0)) { 1309: if (_kgsl_context_get(&drawctxt->base)) 1310: update_out_fence_ts = true; 1311: } 1312: 1313: /* 1314: * This is part of the reset sequence and any error in this path will be handled by 1315: * the caller. 1316: */ 1317: ret = gen7_send_hw_fence_hfi_wait_ack(adreno_dev, entry, 0); 1318: if (ret) 1319: break; 1320: /* 1321: * If HW_FENCE_FLAG_SKIP_MEMSTORE is set, then GMU context queue header will not be 1322: * updated for this fence. Hence, update it here. 1323: */ 1324: if (update_out_fence_ts) { 1325: hdr->out_fence_ts = entry_ts; 1326: kgsl_context_put(&drawctxt->base); 1327: update_out_fence_ts = false; 1328: } 1329: } 1330: 1331: /* Remove remaining entries from the list if we hit an error */ 1332: if (ret) { 1333: list_for_each_entry_safe(entry, tmp, &hw_fence_list, reset_node) { 1334: list_del_init(&entry->reset_node); 1335: } 1336: } 1337: 1338: return ret; 1339: } 1340: 1341: /** MATCH LINES: 1359, 1384 1347: { 1348: struct adreno_hw_fence_entry *entry, *tmp; 1349: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev); 1350: struct kgsl_context *context = NULL; 1351: int ret = 0; 1352: 1353: list_for_each_entry_safe(entry, tmp, &hfi->detached_hw_fence_list, node) { 1354: 1355: /* 1356: * This is part of the reset sequence and any error in this path will be handled by 1357: * the caller. 1358: */ 1359: ret = gen7_send_hw_fence_hfi_wait_ack(adreno_dev, entry, 1360: HW_FENCE_FLAG_SKIP_MEMSTORE); 1361: if (ret) 1362: return ret; 1363: 1364: context = &entry->drawctxt->base; 1365: 1366: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 1367: 1368: kgsl_context_put(context); 1369: } 1370: 1371: return ret; 1372: } 1373: 1374: static int gen7_hwsched_drain_context_hw_fences(struct adreno_device *adreno_dev, 1375: struct adreno_context *drawctxt) 1376: { 1377: struct adreno_hw_fence_entry *entry, *tmp; 1378: int ret = 0; 1379: 1380: /* We don't need the drawctxt lock here as this context has already been invalidated */ 1381: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_list, node) { 1382: 1383: /* Any error here is fatal */ 1384: ret = gen7_send_hw_fence_hfi_wait_ack(adreno_dev, entry, 1385: HW_FENCE_FLAG_SKIP_MEMSTORE); 1386: if (ret) 1387: break; 1388: 1389: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 1390: } 1391: 1392: return ret; 1393: } 1394: 1395: static struct adreno_context *_get_guilty_context(struct kgsl_device *device) 1396: { 1397: struct kgsl_context *context = NULL; 1398: struct adreno_context *guilty = NULL; 1399: int id; 1400: 1401: read_lock(&device->context_lock); 1402: idr_for_each_entry(&device->context_idr, context, id) { 1403: if (test_and_clear_bit(KGSL_CONTEXT_PRIV_INVALID_DRAIN_HW_FENCE, &context->priv) && 1404: _kgsl_context_get(context)) { 1405: guilty = ADRENO_CONTEXT(context); 1406: break; 1407: } 1408: } MATCH LINES: 1464, 1476, 1481, 1483, 1485, 1491, 1504, 1529, 1532 1452: if (ret) 1453: return ret; 1454: 1455: ret = process_detached_hw_fences_after_reset(adreno_dev); 1456: if (ret) 1457: return ret; 1458: 1459: return gen7_hwsched_disable_hw_fence_throttle(adreno_dev); 1460: } 1461: 1462: int gen7_hwsched_reset_replay(struct adreno_device *adreno_dev) 1463: { 1464: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1465: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 1466: int ret; 1467: 1468: /* 1469: * Any pending context unregister packets will be lost 1470: * since we hard reset the GMU. This means any threads waiting 1471: * for context unregister hfi ack will timeout. Wake them 1472: * to avoid false positive ack timeout messages later. 1473: */ 1474: gen7_hwsched_drain_ctxt_unregister(adreno_dev); 1475: 1476: if (!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 1477: return 0; 1478: 1479: gen7_disable_gpu_irq(adreno_dev); 1480: 1481: gen7_gmu_irq_disable(adreno_dev); 1482: 1483: gen7_hwsched_hfi_stop(adreno_dev); 1484: 1485: gen7_hwsched_gmu_suspend(adreno_dev, true); 1486: 1487: adreno_hwsched_unregister_contexts(adreno_dev); 1488: 1489: adreno_llcc_slice_deactivate(adreno_dev); 1490: 1491: clear_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 1492: 1493: spin_lock(&hwf->lock); 1494: 1495: /* Reset the unack count back to zero as we start afresh */ 1496: hwf->unack_count = 0; 1497: 1498: spin_unlock(&hwf->lock); 1499: 1500: /* 1501: * When we reset, we want to coldboot incase any scratch corruption 1502: * has occurred before we faulted. 1503: */ 1504: gmu_core_mark_for_coldboot(KGSL_DEVICE(adreno_dev)); 1505: 1506: ret = gen7_hwsched_boot(adreno_dev); 1507: if (ret) 1508: goto done; 1509: 1510: adreno_hwsched_replay(adreno_dev); 1511: 1512: ret = handle_hw_fences_after_reset(adreno_dev); 1513: done: 1514: BUG_ON(ret); 1515: 1516: return ret; 1517: } 1518: 1519: static void gen7_hwsched_set_thermal_index(struct adreno_device *adreno_dev) 1520: { 1521: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1522: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1523: int ret; 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: { MATCH LINES: 1594, 1609, 1621, 1623, 1624, 1625, 1630, 1633, 1634, 1639, 1641, 1642, 1643, 1648, 1650, 1651, 1652, 1659, 1660, 1664, 1665, 1666, 1667, 1679, 1688 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; 1620: 1621: if (!IS_ERR_OR_NULL(gen7_dev->gmu.gmu_log)) { 1622: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, 1623: KGSL_GMU_LOG_ENTRY, 1624: gen7_dev->gmu.gmu_log->hostptr, 1625: gen7_dev->gmu.gmu_log->size); 1626: if (ret) 1627: return ret; 1628: } 1629: 1630: if (!IS_ERR_OR_NULL(gen7_dev->gmu.hfi.hfi_mem)) { 1631: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, 1632: KGSL_HFIMEM_ENTRY, 1633: gen7_dev->gmu.hfi.hfi_mem->hostptr, 1634: gen7_dev->gmu.hfi.hfi_mem->size); 1635: if (ret) 1636: return ret; 1637: } 1638: 1639: if (!IS_ERR_OR_NULL(gmu_core->vrb)) { 1640: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, 1641: KGSL_GMU_VRB_ENTRY, 1642: gmu_core->vrb->hostptr, 1643: gmu_core->vrb->size); 1644: if (ret) 1645: return ret; 1646: } 1647: 1648: if (!IS_ERR_OR_NULL(gmu_core->trace.md)) { 1649: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, 1650: KGSL_GMU_TRACE_ENTRY, 1651: gmu_core->trace.md->hostptr, 1652: gmu_core->trace.md->size); 1653: if (ret) 1654: return ret; 1655: } 1656: 1657: /* Dump HFI hwsched global mem alloc entries */ 1658: for (i = 0; i < hwsched->mem_alloc_entries; i++) { 1659: struct hfi_mem_alloc_entry *entry = &hwsched->mem_alloc_table[i]; 1660: char hfi_minidump_str[MAX_VA_MINIDUMP_STR_LEN] = {0}; 1661: char name[MAX_VA_MINIDUMP_STR_LEN]; 1662: u32 rb_id = 0; 1663: 1664: if (!hfi_get_minidump_string(entry->desc.mem_kind, 1665: &hfi_minidump_str[0], 1666: sizeof(hfi_minidump_str), &rb_id)) { 1667: snprintf(name, sizeof(name), "kgsl_global_%s", hfi_minidump_str); 1668: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, 1669: name, 1670: entry->md->hostptr, 1671: entry->md->size); 1672: if (ret) 1673: return ret; 1674: } 1675: } 1676: 1677: if (!IS_ERR_OR_NULL(hw_hfi->big_ib)) { 1678: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, 1679: KGSL_HFI_BIG_IB_ENTRY, 1680: hw_hfi->big_ib->hostptr, 1681: hw_hfi->big_ib->size); 1682: if (ret) 1683: return ret; 1684: } 1685: 1686: if (!IS_ERR_OR_NULL(hw_hfi->big_ib_recurring)) 1687: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, 1688: KGSL_HFI_BIG_IB_REC_ENTRY, 1689: hw_hfi->big_ib_recurring->hostptr, 1690: hw_hfi->big_ib_recurring->size); 1691: 1692: return ret; 1693: } --- FILE: \adreno_gen7_hwsched_hfi.c | HITS: 604 --- MATCH LINES: 17, 23, 25, 28, 48, 53, 74, 79, 104, 114, 121, 137, 143, 153, 161, 182, 190, 205, 206, 208, 209, 210, 215, 220, 227, 231, 232, 247, 248, 256, 268, 276, 277, 280, 281, 283, 284, 287, 288, 293, 297, 303, 304, 306, 307, 309, 310, 315, 328, 333, 334, 336, 337, 342, 346, 352, 353, 358, 359, 361, 362, 364, 365, 369, 370, 374, 375, 377, 378, 382, 383, 385, 386, 390, 391, 393, 394, 398, 399, 401, 402, 406, 409, 419, 427, 445, 446, 449, 453, 454, 456, 457, 460, 461, 466, 470, 476, 477, 479, 480, 482, 483, 488, 501, 506, 507, 509, 510, 515, 519, 525, 526, 531, 532, 534, 535, 537, 538, 543, 547, 553, 554, 559, 560, 562, 563, 565, 566, 569, 570, 574, 575, 579, 580, 582, 583, 587, 588, 590, 591, 595, 596, 598, 599, 603, 604, 606, 607, 611, 614, 625, 626, 627, 628, 630, 645, 648, 649, 650, 665, 672, 683, 692, 694, 704, 717, 719, 733, 734, 737, 740, 745, 756, 773, 783, 791, 794, 795, 810, 816, 825 5: */ 6: 7: #include 8: 9: #include "adreno.h" 10: #include "adreno_gen7.h" 11: #include "adreno_gen7_hwsched.h" 12: #include "adreno_hfi.h" 13: #include "adreno_pm4types.h" 14: #include "adreno_trace.h" 15: #include "kgsl_device.h" 16: #include "kgsl_eventlog.h" 17: #include "kgsl_gmu_core.h" 18: #include "kgsl_pwrctrl.h" 19: #include "kgsl_timeline.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: } gen7_hfi_dqs[KGSL_PRIORITY_MAX_RB_LEVELS] = { 49: { 4, 0, }, /* RB0 */ 50: { 4, 4, }, /* RB1 */ 51: { 3, 8, }, /* RB2 */ 52: { 3, 11, }, /* RB3 */ 53: }, gen7_hfi_dqs_lpac[KGSL_PRIORITY_MAX_RB_LEVELS + 1] = { 54: { 4, 0, }, /* RB0 */ 55: { 4, 4, }, /* RB1 */ 56: { 3, 8, }, /* RB2 */ 57: { 2, 11, }, /* RB3 */ 58: { 1, 13, }, /* RB LPAC */ 59: }; 60: 61: struct pending_cmd hw_fence_ack; 62: 63: struct gen7_hwsched_hfi *to_gen7_hwsched_hfi( 64: struct adreno_device *adreno_dev) 65: { 66: struct gen7_device *gen7_dev = container_of(adreno_dev, 67: struct gen7_device, adreno_dev); 68: struct gen7_hwsched_device *gen7_hwsched = container_of(gen7_dev, 69: struct gen7_hwsched_device, gen7_dev); 70: 71: return &gen7_hwsched->hwsched_hfi; 72: } 73: 74: int gen7_hfi_send_lpac_feature_ctrl(struct adreno_device *adreno_dev) 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; 112: 113: if (size_bytes > sizeof(cmd->results)) 114: dev_err_ratelimited(gmu_pdev_dev, 115: "Ack result too big: %d Truncating to: %ld\n", 116: size_bytes, sizeof(cmd->results)); 117: 118: read_lock(&hfi->msglock); 119: 120: list_for_each_entry(cmd, &hfi->msglist, node) { 121: if (CMP_HFI_ACK_HDR(cmd->sent_hdr, req_hdr)) { 122: memcpy(cmd->results, ack, 123: min_t(u32, size_bytes, 124: sizeof(cmd->results))); 125: complete(&cmd->complete); 126: read_unlock(&hfi->msglock); 127: return; 128: } 129: 130: if (num_waiters < ARRAY_SIZE(waiters)) 131: waiters[num_waiters++] = cmd->sent_hdr; 132: } 133: 134: read_unlock(&hfi->msglock); 135: 136: /* Didn't find the sender, list the waiter */ 137: dev_err_ratelimited(gmu_pdev_dev, 138: "Unexpectedly got id %d seqnum %d. Total waiters: %d Top %d Waiters:\n", 139: MSG_HDR_GET_ID(req_hdr), MSG_HDR_GET_SEQNUM(req_hdr), 140: num_waiters, min_t(u32, num_waiters, 5)); 141: 142: for (i = 0; i < num_waiters && i < 5; i++) 143: dev_err_ratelimited(gmu_pdev_dev, 144: " id %d seqnum %d\n", 145: MSG_HDR_GET_ID(waiters[i]), 146: MSG_HDR_GET_SEQNUM(waiters[i])); 147: } 148: 149: /* Look up a particular key's value for a given type of payload */ 150: static u32 gen7_hwsched_lookup_key_value_legacy(struct adreno_device *adreno_dev, 151: u32 type, u32 key) 152: { 153: struct hfi_context_bad_cmd_legacy *cmd = adreno_dev->hwsched.ctxt_bad; 154: u32 i = 0, payload_bytes; 155: void *start; 156: 157: if (!cmd->hdr) 158: return 0; 159: 160: payload_bytes = (MSG_HDR_GET_SIZE(cmd->hdr) << 2) - 161: offsetof(struct hfi_context_bad_cmd_legacy, payload); 162: 163: start = &cmd->payload[0]; 164: 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; 293: case GMU_CP_PROTECTED_ERROR: { 294: u32 status = gen7_hwsched_lookup_key_value_legacy(adreno_dev, PAYLOAD_FAULT_REGS, 295: KEY_CP_PROTECTED_ERROR); 296: 297: dev_crit_ratelimited(gmu_pdev_dev, 298: "CP | Protected mode error | %s | addr=0x%5.5x | status=0x%8.8x\n", 299: status & (1 << 20) ? "READ" : "WRITE", 300: status & 0x3FFFF, status); 301: } 302: break; 303: case GMU_CP_ILLEGAL_INST_ERROR: 304: dev_crit_ratelimited(gmu_pdev_dev, "CP Illegal instruction error\n"); 305: break; 306: case GMU_CP_UCODE_ERROR: 307: dev_crit_ratelimited(gmu_pdev_dev, "CP ucode error interrupt\n"); 308: break; 309: case GMU_CP_HW_FAULT_ERROR: 310: dev_crit_ratelimited(gmu_pdev_dev, 311: "CP | Ringbuffer HW fault | status=0x%8.8x\n", 312: gen7_hwsched_lookup_key_value_legacy(adreno_dev, PAYLOAD_FAULT_REGS, 313: KEY_CP_HW_FAULT)); 314: break; 315: case GMU_GPU_PREEMPT_TIMEOUT: { 316: u32 cur, next, cur_rptr, cur_wptr, next_rptr, next_wptr; 317: 318: cur = gen7_hwsched_lookup_key_value_legacy(adreno_dev, 319: PAYLOAD_PREEMPT_TIMEOUT, KEY_PREEMPT_TIMEOUT_CUR_RB_ID); 320: next = gen7_hwsched_lookup_key_value_legacy(adreno_dev, 321: PAYLOAD_PREEMPT_TIMEOUT, 322: KEY_PREEMPT_TIMEOUT_NEXT_RB_ID); 323: cur_rptr = adreno_hwsched_get_payload_rb_key_legacy(adreno_dev, cur, KEY_RB_RPTR); 324: cur_wptr = adreno_hwsched_get_payload_rb_key_legacy(adreno_dev, cur, KEY_RB_WPTR); 325: next_rptr = adreno_hwsched_get_payload_rb_key_legacy(adreno_dev, next, KEY_RB_RPTR); 326: next_wptr = adreno_hwsched_get_payload_rb_key_legacy(adreno_dev, next, KEY_RB_WPTR); 327: 328: dev_crit_ratelimited(gmu_pdev_dev, 329: "Preemption Fault: cur=%d R/W=0x%x/0x%x, next=%d R/W=0x%x/0x%x\n", 330: cur, cur_rptr, cur_wptr, next, next_rptr, next_wptr); 331: } 332: break; 333: case GMU_CP_GPC_ERROR: 334: dev_crit_ratelimited(gmu_pdev_dev, "RBBM: GPC error\n"); 335: break; 336: case GMU_CP_BV_OPCODE_ERROR: 337: dev_crit_ratelimited(gmu_pdev_dev, 338: "CP BV opcode error | opcode=0x%8.8x\n", 339: gen7_hwsched_lookup_key_value_legacy(adreno_dev, PAYLOAD_FAULT_REGS, 340: KEY_CP_BV_OPCODE_ERROR)); 341: break; 342: case GMU_CP_BV_PROTECTED_ERROR: { 343: u32 status = gen7_hwsched_lookup_key_value_legacy(adreno_dev, PAYLOAD_FAULT_REGS, 344: KEY_CP_BV_PROTECTED_ERROR); 345: 346: dev_crit_ratelimited(gmu_pdev_dev, 347: "CP BV | Protected mode error | %s | addr=0x%5.5x | status=0x%8.8x\n", 348: status & (1 << 20) ? "READ" : "WRITE", 349: status & 0x3FFFF, status); 350: } 351: break; 352: case GMU_CP_BV_HW_FAULT_ERROR: 353: dev_crit_ratelimited(gmu_pdev_dev, 354: "CP BV | Ringbuffer HW fault | status=0x%8.8x\n", 355: gen7_hwsched_lookup_key_value_legacy(adreno_dev, PAYLOAD_FAULT_REGS, 356: KEY_CP_BV_HW_FAULT)); 357: break; 358: case GMU_CP_BV_ILLEGAL_INST_ERROR: 359: dev_crit_ratelimited(gmu_pdev_dev, "CP BV Illegal instruction error\n"); 360: break; 361: case GMU_CP_BV_UCODE_ERROR: 362: dev_crit_ratelimited(gmu_pdev_dev, "CP BV ucode error interrupt\n"); 363: break; 364: case GMU_GPU_SW_FUSE_VIOLATION: 365: dev_crit_ratelimited(gmu_pdev_dev, "RBBM: SW Feature Fuse violation status=0x%8.8x\n", 366: gen7_hwsched_lookup_key_value_legacy(adreno_dev, PAYLOAD_FAULT_REGS, 367: KEY_SWFUSE_VIOLATION_FAULT)); 368: break; 369: case GMU_GPU_AQE0_OPCODE_ERROR: 370: dev_crit_ratelimited(gmu_pdev_dev, "AQE0 opcode error | opcode=0x%8.8x\n", 371: gen7_hwsched_lookup_key_value_legacy(adreno_dev, 372: PAYLOAD_FAULT_REGS, KEY_AQE0_OPCODE_ERROR)); 373: break; 374: case GMU_GPU_AQE0_UCODE_ERROR: 375: dev_crit_ratelimited(gmu_pdev_dev, "AQE0 ucode error interrupt\n"); 376: break; 377: case GMU_GPU_AQE0_HW_FAULT_ERROR: 378: dev_crit_ratelimited(gmu_pdev_dev, "AQE0 HW fault | status=0x%8.8x\n", 379: gen7_hwsched_lookup_key_value_legacy(adreno_dev, 380: PAYLOAD_FAULT_REGS, KEY_AQE0_HW_FAULT)); 381: break; 382: case GMU_GPU_AQE0_ILLEGAL_INST_ERROR: 383: dev_crit_ratelimited(gmu_pdev_dev, "AQE0 Illegal instruction error\n"); 384: break; 385: case GMU_GPU_AQE1_OPCODE_ERROR: 386: dev_crit_ratelimited(gmu_pdev_dev, "AQE1 opcode error | opcode=0x%8.8x\n", 387: gen7_hwsched_lookup_key_value_legacy(adreno_dev, 388: PAYLOAD_FAULT_REGS, KEY_AQE1_OPCODE_ERROR)); 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: 429: start = &cmd->payload[0]; 430: 431: while (i < payload_bytes) { 432: struct payload_section *payload = start + i; 433: 434: if (payload->type == type) 435: return adreno_hwsched_parse_payload(payload, key); 436: 437: i += struct_size(payload, data, payload->dwords); 438: } 439: 440: return 0; 441: } 442: 443: static bool log_gpu_fault(struct adreno_device *adreno_dev) 444: { 445: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)); 446: struct hfi_context_bad_cmd *cmd = adreno_dev->hwsched.ctxt_bad; 447: 448: /* Return false for non fatal errors */ 449: if (adreno_hwsched_log_nonfatal_gpu_fault(adreno_dev, gmu_pdev_dev, cmd->error)) 450: return false; 451: 452: switch (cmd->error) { 453: case GMU_GPU_HW_HANG: 454: dev_crit_ratelimited(gmu_pdev_dev, "MISC: GPU hang detected\n"); 455: break; 456: case GMU_GPU_SW_HANG: 457: dev_crit_ratelimited(gmu_pdev_dev, "gpu timeout ctx %u ts %u\n", 458: cmd->gc.ctxt_id, cmd->gc.ts); 459: break; 460: case GMU_CP_OPCODE_ERROR: 461: dev_crit_ratelimited(gmu_pdev_dev, 462: "CP opcode error interrupt | opcode=0x%8.8x\n", 463: gen7_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 464: KEY_CP_OPCODE_ERROR)); 465: break; 466: case GMU_CP_PROTECTED_ERROR: { 467: u32 status = gen7_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 468: KEY_CP_PROTECTED_ERROR); 469: 470: dev_crit_ratelimited(gmu_pdev_dev, 471: "CP | Protected mode error | %s | addr=0x%5.5x | status=0x%8.8x\n", 472: status & (1 << 20) ? "READ" : "WRITE", 473: status & 0x3FFFF, status); 474: } 475: break; 476: case GMU_CP_ILLEGAL_INST_ERROR: 477: dev_crit_ratelimited(gmu_pdev_dev, "CP Illegal instruction error\n"); 478: break; 479: case GMU_CP_UCODE_ERROR: 480: dev_crit_ratelimited(gmu_pdev_dev, "CP ucode error interrupt\n"); 481: break; 482: case GMU_CP_HW_FAULT_ERROR: 483: dev_crit_ratelimited(gmu_pdev_dev, 484: "CP | Ringbuffer HW fault | status=0x%8.8x\n", 485: gen7_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 486: KEY_CP_HW_FAULT)); 487: break; 488: case GMU_GPU_PREEMPT_TIMEOUT: { 489: u32 cur, next, cur_rptr, cur_wptr, next_rptr, next_wptr; 490: 491: cur = gen7_hwsched_lookup_key_value(adreno_dev, 492: PAYLOAD_PREEMPT_TIMEOUT, KEY_PREEMPT_TIMEOUT_CUR_RB_ID); 493: next = gen7_hwsched_lookup_key_value(adreno_dev, 494: PAYLOAD_PREEMPT_TIMEOUT, 495: KEY_PREEMPT_TIMEOUT_NEXT_RB_ID); 496: cur_rptr = adreno_hwsched_get_payload_rb_key(adreno_dev, cur, KEY_RB_RPTR); 497: cur_wptr = adreno_hwsched_get_payload_rb_key(adreno_dev, cur, KEY_RB_WPTR); 498: next_rptr = adreno_hwsched_get_payload_rb_key(adreno_dev, next, KEY_RB_RPTR); 499: next_wptr = adreno_hwsched_get_payload_rb_key(adreno_dev, next, KEY_RB_WPTR); 500: 501: dev_crit_ratelimited(gmu_pdev_dev, 502: "Preemption Fault: cur=%d R/W=0x%x/0x%x, next=%d R/W=0x%x/0x%x\n", 503: cur, cur_rptr, cur_wptr, next, next_rptr, next_wptr); 504: } 505: break; 506: case GMU_CP_GPC_ERROR: 507: dev_crit_ratelimited(gmu_pdev_dev, "RBBM: GPC error\n"); 508: break; 509: case GMU_CP_BV_OPCODE_ERROR: 510: dev_crit_ratelimited(gmu_pdev_dev, 511: "CP BV opcode error | opcode=0x%8.8x\n", 512: gen7_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 513: KEY_CP_BV_OPCODE_ERROR)); 514: break; 515: case GMU_CP_BV_PROTECTED_ERROR: { 516: u32 status = gen7_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 517: KEY_CP_BV_PROTECTED_ERROR); 518: 519: dev_crit_ratelimited(gmu_pdev_dev, 520: "CP BV | Protected mode error | %s | addr=0x%5.5x | status=0x%8.8x\n", 521: status & (1 << 20) ? "READ" : "WRITE", 522: status & 0x3FFFF, status); 523: } 524: break; 525: case GMU_CP_BV_HW_FAULT_ERROR: 526: dev_crit_ratelimited(gmu_pdev_dev, 527: "CP BV | Ringbuffer HW fault | status=0x%8.8x\n", 528: gen7_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 529: KEY_CP_BV_HW_FAULT)); 530: break; 531: case GMU_CP_BV_ILLEGAL_INST_ERROR: 532: dev_crit_ratelimited(gmu_pdev_dev, "CP BV Illegal instruction error\n"); 533: break; 534: case GMU_CP_BV_UCODE_ERROR: 535: dev_crit_ratelimited(gmu_pdev_dev, "CP BV ucode error interrupt\n"); 536: break; 537: case GMU_CP_LPAC_OPCODE_ERROR: 538: dev_crit_ratelimited(gmu_pdev_dev, 539: "CP LPAC opcode error | opcode=0x%8.8x\n", 540: gen7_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 541: KEY_CP_LPAC_OPCODE_ERROR)); 542: break; 543: case GMU_CP_LPAC_PROTECTED_ERROR: { 544: u32 status = gen7_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 545: KEY_CP_LPAC_PROTECTED_ERROR); 546: 547: dev_crit_ratelimited(gmu_pdev_dev, 548: "CP LPAC | Protected mode error | %s | addr=0x%5.5x | status=0x%8.8x\n", 549: status & (1 << 20) ? "READ" : "WRITE", 550: status & 0x3FFFF, status); 551: } 552: break; 553: case GMU_CP_LPAC_HW_FAULT_ERROR: 554: dev_crit_ratelimited(gmu_pdev_dev, 555: "CP LPAC | Ringbuffer HW fault | status=0x%8.8x\n", 556: gen7_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 557: KEY_CP_LPAC_HW_FAULT)); 558: break; 559: case GMU_CP_LPAC_ILLEGAL_INST_ERROR: 560: dev_crit_ratelimited(gmu_pdev_dev, "CP LPAC Illegal instruction error\n"); 561: break; 562: case GMU_CP_LPAC_UCODE_ERROR: 563: dev_crit_ratelimited(gmu_pdev_dev, "CP LPAC ucode error interrupt\n"); 564: break; 565: case GMU_GPU_LPAC_SW_HANG: 566: dev_crit_ratelimited(gmu_pdev_dev, "LPAC: gpu timeout ctx %u ts %u\n", 567: cmd->lpac.ctxt_id, cmd->lpac.ts); 568: break; 569: case GMU_GPU_SW_FUSE_VIOLATION: 570: dev_crit_ratelimited(gmu_pdev_dev, "RBBM: SW Feature Fuse violation status=0x%8.8x\n", 571: gen7_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 572: KEY_SWFUSE_VIOLATION_FAULT)); 573: break; 574: case GMU_GPU_AQE0_OPCODE_ERROR: 575: dev_crit_ratelimited(gmu_pdev_dev, "AQE0 opcode error | opcode=0x%8.8x\n", 576: gen7_hwsched_lookup_key_value(adreno_dev, 577: PAYLOAD_FAULT_REGS, KEY_AQE0_OPCODE_ERROR)); 578: break; 579: case GMU_GPU_AQE0_UCODE_ERROR: 580: dev_crit_ratelimited(gmu_pdev_dev, "AQE0 ucode error interrupt\n"); 581: break; 582: case GMU_GPU_AQE0_HW_FAULT_ERROR: 583: dev_crit_ratelimited(gmu_pdev_dev, "AQE0 HW fault | status=0x%8.8x\n", 584: gen7_hwsched_lookup_key_value(adreno_dev, 585: PAYLOAD_FAULT_REGS, KEY_AQE0_HW_FAULT)); 586: break; 587: case GMU_GPU_AQE0_ILLEGAL_INST_ERROR: 588: dev_crit_ratelimited(gmu_pdev_dev, "AQE0 Illegal instruction error\n"); 589: break; 590: case GMU_GPU_AQE1_OPCODE_ERROR: 591: dev_crit_ratelimited(gmu_pdev_dev, "AQE1 opcode error | opcode=0x%8.8x\n", 592: gen7_hwsched_lookup_key_value(adreno_dev, 593: PAYLOAD_FAULT_REGS, KEY_AQE1_OPCODE_ERROR)); 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) 634: return true; 635: 636: /* 637: * This is to ensure that the queue is not read speculatively before the queue empty 638: * condition is evaluated 639: */ 640: rmb(); 641: 642: return false; 643: } 644: 645: static u32 peek_next_header(struct adreno_device *adreno_dev, struct gen7_gmu_device *gmu, 646: u32 queue_idx) 647: { 648: struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem; 649: struct hfi_queue_table *tbl = mem_addr->hostptr; 650: struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx]; 651: u32 *queue; 652: 653: if (is_queue_empty(adreno_dev, queue_idx)) 654: return 0; 655: 656: queue = HOST_QUEUE_START_ADDR(mem_addr, queue_idx); 657: 658: return queue[hdr->read_index]; 659: } 660: 661: static void process_ctx_bad(struct adreno_device *adreno_dev) 662: { 663: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 664: 665: if (GMU_VER_MINOR(device->gmu_core.ver.hfi) < 2) { 666: log_gpu_fault_legacy(adreno_dev); 667: goto done; 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: */ MATCH LINES: 905 893: */ 894: static int _send_hw_fence_no_ack(struct adreno_device *adreno_dev, 895: struct adreno_hw_fence_entry *entry) 896: { 897: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 898: u32 seqnum; 899: int ret; 900: 901: 902: seqnum = atomic_inc_return(&hwf->seqnum); 903: entry->cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(entry->cmd.hdr, seqnum, sizeof(entry->cmd) >> 2); 904: 905: ret = gen7_hfi_cmdq_write(adreno_dev, (u32 *)&entry->cmd, sizeof(entry->cmd)); 906: if (!ret) 907: _increment_hw_fence_unack_count(adreno_dev); 908: 909: return ret; 910: } 911: 912: static struct adreno_hw_fence_entry *_get_deferred_hw_fence(struct adreno_context *drawctxt, u32 ts) 913: { 914: struct adreno_hw_fence_entry *entry = NULL, *next, *deferred_hw_fence_entry = NULL; 915: 916: spin_lock(&drawctxt->lock); 917: list_for_each_entry_safe(entry, next, &drawctxt->hw_fence_list, node) { 918: 919: if (timestamp_cmp((u32)entry->cmd.ts, ts) > 0) 920: break; 921: 922: /* We found a deferred hardware fence */ 923: deferred_hw_fence_entry = entry; 924: break; 925: } 926: spin_unlock(&drawctxt->lock); 927: 928: /* 929: * This path executes in isolation from any paths that may release this entry. So, it is MATCH LINES: 946 934: 935: static int _send_deferred_hw_fence(struct adreno_device *adreno_dev, 936: struct adreno_context *drawctxt, struct adreno_hw_fence_entry *entry, u32 ts) 937: { 938: bool retired = kgsl_check_timestamp(KGSL_DEVICE(adreno_dev), &drawctxt->base, ts) || 939: kgsl_context_is_bad(&drawctxt->base); 940: int ret = 0; 941: u32 flags = 0; 942: 943: if (retired) 944: flags |= HW_FENCE_FLAG_SKIP_MEMSTORE; 945: 946: ret = gen7_send_hw_fence_hfi_wait_ack(adreno_dev, entry, flags); 947: if (ret) 948: return ret; 949: 950: spin_lock(&drawctxt->lock); 951: if (!retired) 952: list_move_tail(&entry->node, &drawctxt->hw_fence_inflight_list); 953: else 954: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 955: spin_unlock(&drawctxt->lock); 956: 957: return 0; 958: } 959: 960: /** 961: * process_hw_fence_deferred_ctxt - This function sends hardware fences to GMU (from the 962: * deferred drawctxt) which couldn't be sent earlier 963: */ 964: static int process_hw_fence_deferred_ctxt(struct adreno_device *adreno_dev, 965: struct adreno_context *drawctxt, u32 ts) 966: { 967: struct adreno_hw_fence_entry *deferred_hw_fence_entry = NULL; 968: int ret = 0; 969: 970: do { MATCH LINES: 1043, 1066, 1083, 1093, 1099, 1131, 1135, 1141, 1146, 1147, 1152, 1157, 1169, 1171, 1182, 1183, 1184, 1189, 1199, 1200, 1201, 1209, 1217, 1221, 1243, 1247, 1250, 1256, 1259, 1260, 1267, 1268, 1270, 1274, 1280, 1283, 1286, 1287, 1290, 1297, 1309, 1314, 1315, 1319, 1322, 1334, 1339, 1353, 1354, 1357, 1359, 1360, 1361, 1362, 1365, 1366, 1367, 1369, 1370, 1371, 1372, 1374, 1375, 1376, 1377, 1379, 1380, 1381, 1383, 1384, 1386, 1390, 1394, 1395, 1397, 1399, 1406, 1407, 1408, 1415, 1416, 1417, 1422, 1423, 1424, 1425, 1426, 1431, 1441, 1442, 1443, 1447, 1462, 1465, 1467, 1468, 1469, 1479, 1489, 1495, 1497, 1499, 1508, 1513, 1515, 1518, 1531, 1536, 1539, 1542, 1546, 1548, 1551, 1559, 1560, 1564, 1567, 1574, 1578, 1589, 1598, 1600, 1601, 1605, 1606, 1608, 1615, 1617, 1620, 1634, 1641, 1643, 1666, 1678, 1679, 1687, 1690, 1696, 1699, 1710, 1716, 1718, 1731, 1734, 1743, 1744, 1749, 1751, 1752, 1753, 1770, 1774, 1790, 1791, 1798, 1801, 1806, 1821, 1825, 1838, 1846, 1848, 1857, 1864, 1866 1031: 1032: spin_lock(&hwf->lock); 1033: drawctxt = hwf->defer_drawctxt; 1034: ts = hwf->defer_ts; 1035: spin_unlock(&hwf->lock); 1036: 1037: if (!drawctxt) 1038: goto unlock; 1039: 1040: ret = process_hw_fence_deferred_ctxt(adreno_dev, drawctxt, ts); 1041: if (ret) { 1042: /* the deferred drawctxt will be handled post fault recovery */ 1043: gen7_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 1044: goto unlock; 1045: } 1046: 1047: /* 1048: * Put back the context reference which was incremented when hw_fence.defer_drawctxt was set 1049: */ 1050: kgsl_context_put(&drawctxt->base); 1051: 1052: adreno_active_count_put(adreno_dev); 1053: 1054: _disable_hw_fence_throttle(adreno_dev, false); 1055: 1056: unlock: 1057: kgsl_mutex_unlock(&device->mutex); 1058: mutex_unlock(&adreno_dev->hwsched.mutex); 1059: } 1060: 1061: static int _check_hw_fence_ack_failure(struct kgsl_device *device, u32 *result) 1062: { 1063: if (!result[2]) 1064: return 0; 1065: 1066: dev_err(GMU_PDEV_DEV(device), 1067: "HFI ACK failure: Req=0x%8.8X, Result=0x%8.8X\n", 1068: result[1], result[2]); 1069: 1070: return -EINVAL; 1071: } 1072: 1073: static void process_hw_fence_ack(struct adreno_device *adreno_dev, u32 *rcvd) 1074: { 1075: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev); 1076: struct adreno_context *drawctxt = NULL; 1077: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 1078: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1079: 1080: spin_lock(&hwf->lock); 1081: 1082: /* If this ack is being waited on, we don't need to touch the unack count */ 1083: if (hw_fence_ack.sent_hdr && CMP_HFI_ACK_HDR(hw_fence_ack.sent_hdr, rcvd[1])) { 1084: spin_unlock(&hwf->lock); 1085: complete(&hw_fence_ack.complete); 1086: return; 1087: } 1088: 1089: hwf->unack_count--; 1090: 1091: /* The unack count should never be greater than MAX_HW_FENCE_UNACK_COUNT */ 1092: if (hwf->unack_count > MAX_HW_FENCE_UNACK_COUNT) 1093: dev_err(GMU_PDEV_DEV(device), 1094: "unexpected hardware fence unack count:%d\n", 1095: hwf->unack_count); 1096: 1097: if (_check_hw_fence_ack_failure(device, rcvd)) { 1098: spin_unlock(&hwf->lock); 1099: gen7_hwsched_fault(adreno_dev, GMU_FAULT_HW_FENCE); 1100: return; 1101: } 1102: 1103: if (!test_bit(GEN7_HWSCHED_HW_FENCE_MAX_BIT, &hwf->flags) || 1104: (hwf->unack_count != MIN_HW_FENCE_UNACK_COUNT)) { 1105: spin_unlock(&hwf->lock); 1106: return; 1107: } 1108: 1109: drawctxt = hwf->defer_drawctxt; 1110: 1111: spin_unlock(&hwf->lock); 1112: 1113: kgsl_delete_timer_sync(&hfi->hw_fence_timer); 1114: 1115: /* 1116: * We need to handle the deferred context in another thread so that we can unblock the f2h 1117: * daemon here as it will need to process the acks for the hardware fences belonging to the 1118: * deferred context 1119: */ 1120: if (drawctxt) { 1121: kthread_init_work(&hfi->defer_hw_fence_work, gen7_defer_hw_fence_work); 1122: kthread_queue_work(adreno_dev->scheduler_worker, &hfi->defer_hw_fence_work); 1123: return; 1124: } 1125: 1126: _disable_hw_fence_throttle(adreno_dev, false); 1127: } 1128: 1129: void gen7_hwsched_process_msgq(struct adreno_device *adreno_dev) 1130: { 1131: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1132: struct gen7_hwsched_hfi *hw_hfi = to_gen7_hwsched_hfi(adreno_dev); 1133: u32 rcvd[MAX_RCVD_SIZE], next_hdr, type; 1134: 1135: if (!(hw_hfi->irq_mask & HFI_IRQ_MSGQ_MASK)) 1136: return; 1137: 1138: mutex_lock(&hw_hfi->msgq_mutex); 1139: 1140: for (;;) { 1141: next_hdr = peek_next_header(adreno_dev, gmu, HFI_MSG_ID); 1142: 1143: if (!next_hdr) 1144: break; 1145: 1146: if (MSG_HDR_GET_TYPE(next_hdr) == HFI_MSG_ACK) 1147: type = HFI_MSG_ACK; 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; 1205: end = cmd->stop_index; 1206: 1207: log_event += start * 4; 1208: while (start != end) { 1209: trace_gmu_event(log_event); 1210: log_event += 4; 1211: start++; 1212: } 1213: } 1214: 1215: static void gen7_hwsched_process_dbgq(struct adreno_device *adreno_dev, bool limited) 1216: { 1217: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1218: u32 rcvd[MAX_RCVD_SIZE]; 1219: bool recovery = false; 1220: 1221: while (gen7_hfi_queue_read(gmu, HFI_DBG_ID, rcvd, sizeof(rcvd)) > 0) { 1222: 1223: if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_ERR) { 1224: adreno_gen7_receive_err_req(gmu, rcvd); 1225: recovery = true; 1226: break; 1227: } 1228: 1229: if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_DEBUG) 1230: adreno_gen7_receive_debug_req(gmu, rcvd); 1231: 1232: if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_LOG_BLOCK) 1233: process_log_block(adreno_dev, rcvd); 1234: 1235: /* Process one debug queue message and return to not delay msgq processing */ 1236: if (limited) 1237: break; 1238: } 1239: 1240: if (!recovery) 1241: return; 1242: 1243: gen7_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 1244: } 1245: 1246: /* HFI interrupt handler */ 1247: static irqreturn_t gen7_hwsched_hfi_handler(int irq, void *data) 1248: { 1249: struct adreno_device *adreno_dev = data; 1250: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1251: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev); 1252: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1253: u32 status = 0; 1254: 1255: /* 1256: * GEN7_GMU_GMU2HOST_INTR_INFO may have bits set not specified in hfi->irq_mask. 1257: * Read and clear only those irq bits that we are processing here. 1258: */ 1259: gmu_core_regread(device, GEN7_GMU_GMU2HOST_INTR_INFO, &status); 1260: gmu_core_regwrite(device, GEN7_GMU_GMU2HOST_INTR_CLR, status & hfi->irq_mask); 1261: 1262: /* 1263: * If interrupts are not enabled on the HFI message queue, 1264: * the inline message processing loop will process it, 1265: * else, process it here. 1266: */ 1267: if (!(hfi->irq_mask & HFI_IRQ_MSGQ_MASK)) 1268: status &= ~HFI_IRQ_MSGQ_MASK; 1269: 1270: if (status & (HFI_IRQ_MSGQ_MASK | HFI_IRQ_DBGQ_MASK)) { 1271: wake_up_interruptible(&hfi->f2h_wq); 1272: adreno_scheduler_queue(adreno_dev); 1273: } 1274: if (status & HFI_IRQ_CM3_FAULT_MASK) { 1275: atomic_set(&gmu->cm3_fault, 1); 1276: 1277: /* make sure other CPUs see the update */ 1278: smp_wmb(); 1279: 1280: dev_err_ratelimited(GMU_PDEV_DEV(device), 1281: "GMU CM3 fault interrupt received\n"); 1282: 1283: gen7_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 1284: } 1285: 1286: /* Ignore OOB bits */ 1287: status &= GENMASK(31 - (oob_max - 1), 0); 1288: 1289: if (status & ~hfi->irq_mask) 1290: dev_err_ratelimited(GMU_PDEV_DEV(device), 1291: "Unhandled HFI interrupts 0x%x\n", 1292: status & ~hfi->irq_mask); 1293: 1294: return IRQ_HANDLED; 1295: } 1296: 1297: #define HFI_IRQ_MSGQ_MASK BIT(0) 1298: 1299: static int check_ack_failure(struct adreno_device *adreno_dev, 1300: struct pending_cmd *ack) 1301: { 1302: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 1303: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1304: u64 ticks = gpudev->read_alwayson(adreno_dev); 1305: 1306: if (ack->results[2] != 0xffffffff) 1307: return 0; 1308: 1309: dev_err(GMU_PDEV_DEV(device), 1310: "ACK error: sender id %d seqnum %d\n", 1311: MSG_HDR_GET_ID(ack->sent_hdr), 1312: MSG_HDR_GET_SEQNUM(ack->sent_hdr)); 1313: 1314: KGSL_GMU_CORE_FORCE_PANIC(device->gmu_core.gf_panic, 1315: GMU_PDEV(device), ticks, GMU_FAULT_HFI_ACK); 1316: return -EINVAL; 1317: } 1318: 1319: int gen7_hfi_send_cmd_async(struct adreno_device *adreno_dev, void *data, u32 size_bytes) 1320: { 1321: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1322: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1323: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev); 1324: u32 *cmd = data; 1325: u32 seqnum; 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, 1363: }, 1364: .qhdr = { 1365: DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0), 1366: DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0), 1367: DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0), 1368: /* 4 DQs for RB priority 0 */ 1369: DEFINE_QHDR(gmuaddr, 3, 0), 1370: DEFINE_QHDR(gmuaddr, 4, 0), 1371: DEFINE_QHDR(gmuaddr, 5, 0), 1372: DEFINE_QHDR(gmuaddr, 6, 0), 1373: /* 4 DQs for RB priority 1 */ 1374: DEFINE_QHDR(gmuaddr, 7, 1), 1375: DEFINE_QHDR(gmuaddr, 8, 1), 1376: DEFINE_QHDR(gmuaddr, 9, 1), 1377: DEFINE_QHDR(gmuaddr, 10, 1), 1378: /* 3 DQs for RB priority 2 */ 1379: DEFINE_QHDR(gmuaddr, 11, 2), 1380: DEFINE_QHDR(gmuaddr, 12, 2), 1381: DEFINE_QHDR(gmuaddr, 13, 2), 1382: /* 2 DQs for RB priority 3 */ 1383: DEFINE_QHDR(gmuaddr, 14, 3), 1384: DEFINE_QHDR(gmuaddr, 15, 3), 1385: /* 1 DQ for LPAC RB priority 4 */ 1386: DEFINE_QHDR(gmuaddr, 16, 4), 1387: }, 1388: }; 1389: 1390: memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table)); 1391: } 1392: 1393: /* Total header sizes + queue sizes + 16 for alignment */ 1394: #define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \ 1395: (SZ_4K * HFI_QUEUE_MAX)) 1396: 1397: static int hfi_f2h_main(void *arg); 1398: 1399: int gen7_hwsched_hfi_init(struct adreno_device *adreno_dev) 1400: { 1401: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1402: struct gen7_hwsched_hfi *hw_hfi = to_gen7_hwsched_hfi(adreno_dev); 1403: struct gen7_hfi *hfi = to_gen7_hfi(adreno_dev); 1404: 1405: if (IS_ERR_OR_NULL(hw_hfi->big_ib)) { 1406: hw_hfi->big_ib = gmu_core_reserve_kernel_block( 1407: device, 0, HWSCHED_MAX_IBS * sizeof(struct hfi_issue_ib), 1408: GMU_NONCACHED_KERNEL, 0); 1409: if (IS_ERR(hw_hfi->big_ib)) 1410: return PTR_ERR(hw_hfi->big_ib); 1411: } 1412: 1413: if (ADRENO_FEATURE(adreno_dev, ADRENO_LSR) && 1414: IS_ERR_OR_NULL(hw_hfi->big_ib_recurring)) { 1415: hw_hfi->big_ib_recurring = gmu_core_reserve_kernel_block( 1416: device, 0, HWSCHED_MAX_IBS * sizeof(struct hfi_issue_ib), 1417: GMU_NONCACHED_KERNEL, 0); 1418: if (IS_ERR(hw_hfi->big_ib_recurring)) 1419: return PTR_ERR(hw_hfi->big_ib_recurring); 1420: } 1421: 1422: if (IS_ERR_OR_NULL(hfi->hfi_mem)) { 1423: hfi->hfi_mem = gmu_core_reserve_kernel_block( 1424: device, 0, HFIMEM_SIZE, GMU_NONCACHED_KERNEL, 0); 1425: if (IS_ERR(hfi->hfi_mem)) 1426: return PTR_ERR(hfi->hfi_mem); 1427: init_queues(hfi); 1428: } 1429: 1430: if (IS_ERR_OR_NULL(hw_hfi->f2h_task)) { 1431: hw_hfi->f2h_task = kthread_run(hfi_f2h_main, adreno_dev, "gmu_f2h"); 1432: if (!IS_ERR(hw_hfi->f2h_task)) 1433: sched_set_fifo(hw_hfi->f2h_task); 1434: } 1435: 1436: return PTR_ERR_OR_ZERO(hw_hfi->f2h_task); 1437: } 1438: 1439: static int mem_alloc_reply(struct adreno_device *adreno_dev, void *rcvd) 1440: { 1441: struct hfi_mem_alloc_desc desc = {0}; 1442: struct hfi_mem_alloc_reply_cmd out = {0}; 1443: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1444: u32 seqnum; 1445: int ret; 1446: 1447: hfi_get_mem_alloc_desc(rcvd, &desc); 1448: 1449: ret = adreno_hwsched_process_mem_alloc(adreno_dev, &desc); 1450: if (ret) 1451: return ret; 1452: 1453: memcpy(&out.desc, &desc, sizeof(out.desc)); 1454: 1455: out.hdr = ACK_MSG_HDR(F2H_MSG_MEM_ALLOC); 1456: 1457: seqnum = atomic_inc_return(&gmu->hfi.seqnum); 1458: out.hdr = MSG_HDR_SET_SEQNUM_SIZE(out.hdr, seqnum, sizeof(out) >> 2); 1459: 1460: out.req_hdr = *(u32 *)rcvd; 1461: 1462: return gen7_hfi_cmdq_write(adreno_dev, (u32 *)&out, sizeof(out)); 1463: } 1464: 1465: static int gmu_cntr_register_reply(struct adreno_device *adreno_dev, void *rcvd) 1466: { 1467: struct hfi_gmu_cntr_register_cmd *in = (struct hfi_gmu_cntr_register_cmd *)rcvd; 1468: struct hfi_gmu_cntr_register_reply_cmd out = {0}; 1469: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1470: u32 lo = 0, hi = 0, seqnum; 1471: 1472: /* 1473: * Failure to allocate counter is not fatal. Sending lo = 0, hi = 0 1474: * indicates to GMU that counter allocation failed. 1475: */ 1476: adreno_perfcounter_get(adreno_dev, 1477: in->group_id, in->countable, &lo, &hi, PERFCOUNTER_FLAG_KERNEL); 1478: 1479: out.hdr = ACK_MSG_HDR(F2H_MSG_GMU_CNTR_REGISTER); 1480: seqnum = atomic_inc_return(&gmu->hfi.seqnum); 1481: out.hdr = MSG_HDR_SET_SEQNUM_SIZE(out.hdr, seqnum, sizeof(out) >> 2); 1482: out.req_hdr = in->hdr; 1483: out.group_id = in->group_id; 1484: out.countable = in->countable; 1485: /* Fill in byte offset of counter */ 1486: out.cntr_lo = lo << 2; 1487: out.cntr_hi = hi << 2; 1488: 1489: return gen7_hfi_cmdq_write(adreno_dev, (u32 *)&out, sizeof(out)); 1490: } 1491: 1492: static int send_warmboot_start_msg(struct adreno_device *adreno_dev) 1493: { 1494: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1495: struct gmu_core_device *gmu_core = &device->gmu_core; 1496: int ret = 0; 1497: struct hfi_start_cmd cmd; 1498: 1499: if (!gmu_core->warmboot_enabled) 1500: return ret; 1501: 1502: ret = CMD_MSG_HDR(cmd, H2F_MSG_START); 1503: if (ret) 1504: return ret; 1505: 1506: cmd.hdr = RECORD_NOP_MSG_HDR(cmd.hdr); 1507: 1508: return gen7_hfi_send_generic_req(adreno_dev, &cmd, sizeof(cmd)); 1509: } 1510: 1511: static int send_start_msg(struct adreno_device *adreno_dev) 1512: { 1513: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1514: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1515: struct device *gmu_pdev_dev = GMU_PDEV_DEV(device); 1516: u32 seqnum; 1517: int ret, rc = 0; 1518: struct hfi_start_cmd cmd; 1519: u32 rcvd[MAX_RCVD_SIZE]; 1520: struct pending_cmd pending_ack = {0}; 1521: 1522: ret = CMD_MSG_HDR(cmd, H2F_MSG_START); 1523: if (ret) 1524: return ret; 1525: 1526: seqnum = atomic_inc_return(&gmu->hfi.seqnum); 1527: cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2); 1528: 1529: pending_ack.sent_hdr = cmd.hdr; 1530: 1531: rc = gen7_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd)); 1532: if (rc) 1533: return rc; 1534: 1535: poll: 1536: rc = adreno_hwsched_poll_msg_queue_write_index(gmu->hfi.hfi_mem); 1537: 1538: if (rc) { 1539: dev_err(gmu_pdev_dev, 1540: "Timed out processing MSG_START seqnum: %d\n", 1541: seqnum); 1542: gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START); 1543: goto done; 1544: } 1545: 1546: rc = gen7_hfi_queue_read(gmu, HFI_MSG_ID, rcvd, sizeof(rcvd)); 1547: if (rc <= 0) { 1548: dev_err(gmu_pdev_dev, 1549: "MSG_START: payload error: %d\n", 1550: rc); 1551: gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START); 1552: goto done; 1553: } 1554: 1555: switch (MSG_HDR_GET_ID(rcvd[0])) { 1556: case F2H_MSG_MEM_ALLOC: 1557: rc = mem_alloc_reply(adreno_dev, rcvd); 1558: break; 1559: case F2H_MSG_GMU_CNTR_REGISTER: 1560: rc = gmu_cntr_register_reply(adreno_dev, rcvd); 1561: break; 1562: case F2H_MSG_PROCESS_TRACE: 1563: rc = 0; 1564: gmu_core_process_trace_data(device, GMU_PDEV_DEV(device), &device->gmu_core.trace); 1565: break; 1566: default: 1567: if (MSG_HDR_GET_TYPE(rcvd[0]) == HFI_MSG_ACK) { 1568: rc = gen7_receive_ack_cmd(gmu, rcvd, &pending_ack); 1569: /* Check ack failure if we received an expected ack */ 1570: if (!rc) 1571: rc = check_ack_failure(adreno_dev, &pending_ack); 1572: goto done; 1573: } else { 1574: dev_err(gmu_pdev_dev, 1575: "MSG_START: unexpected response id:%d, type:%d\n", 1576: MSG_HDR_GET_ID(rcvd[0]), 1577: MSG_HDR_GET_TYPE(rcvd[0])); 1578: gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START); 1579: rc = -EINVAL; 1580: goto done; 1581: } 1582: } 1583: 1584: if (!rc) 1585: goto poll; 1586: 1587: done: 1588: /* Clear the interrupt */ 1589: gmu_core_regwrite(device, GEN7_GMU_GMU2HOST_INTR_CLR, HFI_IRQ_MSGQ_MASK); 1590: /* 1591: * Add a write barrier to post the interrupt clear so that we dont have a 1592: * pending interrupt. 1593: */ 1594: wmb(); 1595: return rc; 1596: } 1597: 1598: static void reset_hfi_queues(struct adreno_device *adreno_dev) 1599: { 1600: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1601: struct hfi_queue_table *tbl = gmu->hfi.hfi_mem->hostptr; 1602: u32 i; 1603: 1604: /* Flush HFI queues */ 1605: for (i = 0; i < HFI_QUEUE_MAX; i++) { 1606: struct hfi_queue_header *hdr = &tbl->qhdr[i]; 1607: 1608: if (hdr->status == HFI_QUEUE_STATUS_DISABLED) 1609: continue; 1610: 1611: hdr->read_index = hdr->write_index; 1612: } 1613: } 1614: 1615: void gen7_hwsched_hfi_stop(struct adreno_device *adreno_dev) 1616: { 1617: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1618: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev); 1619: 1620: hfi->irq_mask &= ~HFI_IRQ_MSGQ_MASK; 1621: 1622: /* 1623: * In some corner cases, it is possible that GMU put TS_RETIRE 1624: * on the msgq after we have turned off gmu interrupts. Hence, 1625: * drain the queue one last time before we reset HFI queues. 1626: */ 1627: gen7_hwsched_process_msgq(adreno_dev); 1628: 1629: /* Drain the debug queue before we reset HFI queues */ 1630: gen7_hwsched_process_dbgq(adreno_dev, false); 1631: 1632: kgsl_pwrctrl_axi(KGSL_DEVICE(adreno_dev), false); 1633: 1634: clear_bit(GMU_PRIV_HFI_STARTED, &gmu->flags); 1635: } 1636: 1637: static void gen7_hwsched_enable_async_hfi(struct adreno_device *adreno_dev) 1638: { 1639: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev); 1640: 1641: hfi->irq_mask |= HFI_IRQ_MSGQ_MASK; 1642: 1643: gmu_core_regwrite(KGSL_DEVICE(adreno_dev), GEN7_GMU_GMU2HOST_INTR_MASK, 1644: (u32)~hfi->irq_mask); 1645: } 1646: 1647: static int enable_preemption(struct adreno_device *adreno_dev) 1648: { 1649: const struct adreno_gen7_core *gen7_core = to_gen7_core(adreno_dev); 1650: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1651: u32 data; 1652: int ret; 1653: 1654: if (!adreno_is_preemption_enabled(adreno_dev)) 1655: return 0; 1656: 1657: /* 1658: * Bits [0:1] contains the preemption level 1659: * Bit 2 is to enable/disable gmem save/restore 1660: * Bit 3 is to enable/disable skipsaverestore 1661: */ 1662: data = FIELD_PREP(GENMASK(1, 0), adreno_dev->preempt.preempt_level) | 1663: FIELD_PREP(BIT(2), adreno_dev->preempt.usesgmem) | 1664: FIELD_PREP(BIT(3), adreno_dev->preempt.skipsaverestore); 1665: 1666: ret = gen7_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_PREEMPTION, 1, 1667: data); 1668: if (ret) 1669: return ret; 1670: 1671: if (gen7_core->qos_value) { 1672: int i; 1673: 1674: for (i = 0; i < KGSL_PRIORITY_MAX_RB_LEVELS; i++) { 1675: if (!gen7_core->qos_value[i]) 1676: continue; 1677: 1678: gen7_hfi_send_set_value(adreno_dev, 1679: HFI_VALUE_RB_GPU_QOS, i, 1680: gen7_core->qos_value[i]); 1681: } 1682: } 1683: if (ADRENO_FEATURE(adreno_dev, ADRENO_RT_HINT)) { 1684: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1685: 1686: if (pwr->rt_bus_hint) { 1687: ret = gen7_hfi_send_set_value(adreno_dev, HFI_VALUE_RB_IB_RULE, 0, 1688: pwr->rt_bus_hint); 1689: if (ret) { 1690: dev_err(GMU_PDEV_DEV(device), "Failed to set rt bus hint %u, ret: %d\n", 1691: pwr->rt_bus_hint, ret); 1692: pwr->rt_bus_hint = 0; 1693: } 1694: } 1695: if (pwr->rt_pwrlevel_hint != INVALID_DCVS_IDX) { 1696: ret = gen7_hfi_send_set_value(adreno_dev, HFI_VALUE_RB_GPULEVEL_RULE, 0, 1697: pwr->num_pwrlevels - pwr->rt_pwrlevel_hint); 1698: if (ret) { 1699: dev_err(GMU_PDEV_DEV(device), "Failed to set rt pwrlevel hint %u, ret: %d\n", 1700: pwr->rt_pwrlevel_hint, ret); 1701: pwr->rt_pwrlevel_hint = INVALID_DCVS_IDX; 1702: } 1703: } 1704: } 1705: 1706: /* 1707: * Bits[3:0] contain the preemption timeout enable bit per ringbuffer 1708: * Bits[31:4] contain the timeout in ms 1709: */ 1710: return gen7_hfi_send_set_value(adreno_dev, HFI_VALUE_BIN_TIME, 1, 1711: FIELD_PREP(GENMASK(31, 4), ADRENO_PREEMPT_TIMEOUT) | 1712: FIELD_PREP(GENMASK(3, 0), 0xf)); 1713: 1714: } 1715: 1716: static int enable_gmu_stats(struct adreno_device *adreno_dev) 1717: { 1718: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1719: u32 data; 1720: 1721: if (!gmu->stats_enable) 1722: return 0; 1723: 1724: /* 1725: * Bits [23:0] contains the countables mask 1726: * Bits [31:24] is the sampling interval 1727: */ 1728: data = FIELD_PREP(GENMASK(23, 0), gmu->stats_mask) | 1729: FIELD_PREP(GENMASK(31, 24), gmu->stats_interval); 1730: 1731: return gen7_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_GMU_STATS, 1, data); 1732: } 1733: 1734: static int gen7_hfi_send_perfcounter_feature_ctrl(struct adreno_device *adreno_dev) 1735: { 1736: /* 1737: * Perfcounter retention is disabled by default in GMU firmware. 1738: * In case perfcounter retention behaviour is overwritten by sysfs 1739: * setting dynmaically, send this HFI feature with 'enable = 0' to 1740: * disable this feature in GMU firmware. 1741: */ 1742: if (adreno_dev->perfcounter) 1743: return gen7_hfi_send_feature_ctrl(adreno_dev, 1744: HFI_FEATURE_PERF_NORETAIN, 0, 0); 1745: 1746: return 0; 1747: } 1748: 1749: u32 gen7_hwsched_hfi_get_value(struct adreno_device *adreno_dev, u32 prop) 1750: { 1751: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)); 1752: struct hfi_get_value_cmd cmd; 1753: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1754: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev); 1755: struct pending_cmd pending_ack; 1756: int rc; 1757: u32 seqnum; 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 = 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) 1799: { 1800: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1801: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1802: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev); 1803: struct pending_cmd pending_ack; 1804: int rc; 1805: u32 seqnum; 1806: struct hfi_set_value_cmd cmd = { 1807: .type = type, 1808: .subtype = subtype, 1809: .data = data, 1810: }; 1811: 1812: rc = CMD_MSG_HDR(cmd, H2F_MSG_SET_VALUE); 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"); 1850: adreno_hwsched_deregister_hw_fence(adreno_dev); 1851: return 0; 1852: } 1853: 1854: return ret; 1855: } 1856: 1857: static int gen7_hfi_send_dms_feature_ctrl(struct adreno_device *adreno_dev) 1858: { 1859: int ret; 1860: 1861: if (!test_bit(ADRENO_DEVICE_DMS, &adreno_dev->priv)) 1862: return 0; 1863: 1864: ret = gen7_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_DMS, 1, 0); 1865: if (ret == -ENOENT) { 1866: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)), 1867: "GMU doesn't support DMS feature\n"); 1868: clear_bit(ADRENO_DEVICE_DMS, &adreno_dev->priv); 1869: adreno_dev->dms_enabled = false; 1870: return 0; 1871: } 1872: 1873: return ret; 1874: } 1875: 1876: static void gen7_spin_idle_debug_lpac(struct adreno_device *adreno_dev, 1877: const char *str) 1878: { 1879: struct kgsl_device *device = &adreno_dev->dev; 1880: u32 rptr, wptr, status, status3, intstatus, hwfault; 1881: bool val = adreno_is_preemption_enabled(adreno_dev); 1882: 1883: dev_err(device->dev, str); 1884: 1885: kgsl_regread(device, GEN7_CP_LPAC_RB_RPTR, &rptr); 1886: kgsl_regread(device, GEN7_CP_LPAC_RB_WPTR, &wptr); 1887: 1888: kgsl_regread(device, GEN7_RBBM_STATUS, &status); 1889: kgsl_regread(device, GEN7_RBBM_STATUS3, &status3); 1890: kgsl_regread(device, GEN7_RBBM_INT_0_STATUS, &intstatus); MATCH LINES: 1905, 1907, 1909, 1910, 1911, 1917, 1920, 1922, 1925, 1928, 1937, 1939, 1942, 1946, 1947, 1949, 1950, 1952, 1957, 1969, 1974, 1983, 1987, 2011, 2019, 2020, 2025, 2026, 2038, 2039, 2043, 2044, 2067, 2071, 2072, 2078, 2085, 2086, 2087, 2096, 2099, 2112, 2115, 2116, 2120, 2122, 2129, 2130, 2131, 2132, 2138, 2139, 2141, 2142, 2146, 2150, 2154, 2158, 2162, 2166, 2170, 2174, 2179, 2185, 2189, 2195, 2196, 2201, 2204, 2205, 2208, 2209, 2211, 2216, 2217, 2219, 2222, 2230, 2235, 2255, 2258, 2259, 2263, 2264, 2270, 2280, 2284, 2285, 2297, 2301, 2302, 2311, 2315, 2330, 2334 1893: dev_err(device->dev, 1894: "LPAC rb=%d pos=%X/%X rbbm_status=%8.8X/%8.8X int_0_status=%8.8X\n", 1895: val ? KGSL_LPAC_RB_ID : 1, rptr, wptr, 1896: status, status3, intstatus); 1897: 1898: dev_err(device->dev, " hwfault=%8.8X\n", hwfault); 1899: 1900: kgsl_device_snapshot(device, NULL, NULL, false); 1901: } 1902: 1903: static bool gen7_hwsched_warmboot_possible(struct adreno_device *adreno_dev) 1904: { 1905: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1906: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1907: struct gmu_core_device *gmu_core = &device->gmu_core; 1908: 1909: if (gmu_core->warmboot_enabled && test_bit(GMU_PRIV_WARMBOOT_GMU_INIT_DONE, &gmu->flags) 1910: && test_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags) && 1911: !test_bit(GMU_FORCE_COLDBOOT, &device->gmu_core.flags)) 1912: return true; 1913: 1914: return false; 1915: } 1916: 1917: static int gen7_hwsched_hfi_send_warmboot_cmd(struct adreno_device *adreno_dev, 1918: struct kgsl_memdesc *desc, u32 flag, bool async, struct pending_cmd *ack) 1919: { 1920: struct hfi_warmboot_scratch_cmd cmd = {0}; 1921: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1922: struct gmu_core_device *gmu_core = &device->gmu_core; 1923: int ret; 1924: 1925: if (!gmu_core->warmboot_enabled) 1926: return 0; 1927: 1928: cmd.scratch_addr = desc->gmuaddr; 1929: cmd.scratch_size = desc->size; 1930: cmd.flags = flag; 1931: 1932: ret = CMD_MSG_HDR(cmd, H2F_MSG_WARMBOOT_CMD); 1933: if (ret) 1934: return ret; 1935: 1936: if (async) 1937: return gen7_hfi_send_cmd_async(adreno_dev, &cmd, sizeof(cmd)); 1938: 1939: return gen7_hfi_send_generic_req_v5(adreno_dev, &cmd, ack, sizeof(cmd)); 1940: } 1941: 1942: static int gen7_hwsched_hfi_warmboot_gpu_cmd(struct adreno_device *adreno_dev, 1943: struct pending_cmd *ret_cmd) 1944: { 1945: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1946: struct gmu_core_device *gmu_core = &device->gmu_core; 1947: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1948: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev); 1949: struct hfi_warmboot_scratch_cmd cmd = { 1950: .scratch_addr = gmu->gpu_boot_scratch->gmuaddr, 1951: .scratch_size = gmu->gpu_boot_scratch->size, 1952: .flags = HFI_WARMBOOT_EXEC_SCRATCH, 1953: }; 1954: int ret = 0; 1955: u32 seqnum; 1956: 1957: if (!gmu_core->warmboot_enabled) 1958: return 0; 1959: 1960: ret = CMD_MSG_HDR(cmd, H2F_MSG_WARMBOOT_CMD); 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, 1998: "CP initialization failed to idle\n"); 1999: else if (ret_cmd.results[2] == gmu->switch_to_unsec_hdr) 2000: gen7_spin_idle_debug(adreno_dev, 2001: "Switch to unsecure failed to idle\n"); 2002: } 2003: break; 2004: case H2F_MSG_ISSUE_LPAC_CMD_RAW: 2005: gen7_spin_idle_debug_lpac(adreno_dev, 2006: "LPAC CP initialization failed to idle\n"); 2007: break; 2008: } 2009: err: 2010: /* Clear the bit on error so that in the next slumber exit we coldboot */ 2011: clear_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags); 2012: gen7_disable_gpu_irq(adreno_dev); 2013: return ret; 2014: } 2015: 2016: static int gen7_hwsched_coldboot_gpu(struct adreno_device *adreno_dev) 2017: { 2018: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2019: struct gmu_core_device *gmu_core = &device->gmu_core; 2020: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 2021: struct gen7_hfi *hfi = to_gen7_hfi(adreno_dev); 2022: struct pending_cmd ack = {0}; 2023: int ret = 0; 2024: 2025: ret = gen7_hwsched_hfi_send_warmboot_cmd(adreno_dev, gmu->gpu_boot_scratch, 2026: HFI_WARMBOOT_SET_SCRATCH, true, &ack); 2027: if (ret) 2028: goto done; 2029: 2030: ret = gen7_hwsched_cp_init(adreno_dev); 2031: if (ret) 2032: goto done; 2033: 2034: ret = gen7_hwsched_lpac_cp_init(adreno_dev); 2035: if (ret) 2036: goto done; 2037: 2038: ret = gen7_hwsched_hfi_send_warmboot_cmd(adreno_dev, gmu->gpu_boot_scratch, 2039: HFI_WARMBOOT_QUERY_SCRATCH, true, &ack); 2040: if (ret) 2041: goto done; 2042: 2043: if (gmu_core->warmboot_enabled) 2044: set_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags); 2045: 2046: done: 2047: /* Clear the bitmask so that we don't send record bit with future HFI messages */ 2048: memset(hfi->wb_set_record_bitmask, 0x0, sizeof(hfi->wb_set_record_bitmask)); 2049: 2050: if (ret) 2051: gen7_disable_gpu_irq(adreno_dev); 2052: 2053: return ret; 2054: } 2055: 2056: int gen7_hwsched_boot_gpu(struct adreno_device *adreno_dev) 2057: { 2058: /* If warmboot is possible just send the warmboot command else coldboot */ 2059: if (gen7_hwsched_warmboot_possible(adreno_dev)) 2060: return gen7_hwsched_warmboot_gpu(adreno_dev); 2061: else 2062: return gen7_hwsched_coldboot_gpu(adreno_dev); 2063: } 2064: 2065: int gen7_hwsched_warmboot_init_gmu(struct adreno_device *adreno_dev) 2066: { 2067: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 2068: struct pending_cmd ack = {0}; 2069: int ret = 0; 2070: 2071: ret = gen7_hwsched_hfi_send_warmboot_cmd(adreno_dev, gmu->gmu_init_scratch, 2072: HFI_WARMBOOT_EXEC_SCRATCH, false, &ack); 2073: if (ret) 2074: goto err; 2075: 2076: gen7_hwsched_enable_async_hfi(adreno_dev); 2077: 2078: set_bit(GMU_PRIV_HFI_STARTED, &gmu->flags); 2079: 2080: ret = kgsl_pwrctrl_setup_default_votes(KGSL_DEVICE(adreno_dev)); 2081: 2082: err: 2083: if (ret) { 2084: /* Clear the bit in case of an error so next boot will be coldboot */ 2085: clear_bit(GMU_PRIV_WARMBOOT_GMU_INIT_DONE, &gmu->flags); 2086: clear_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags); 2087: gen7_hwsched_hfi_stop(adreno_dev); 2088: } 2089: 2090: return ret; 2091: } 2092: 2093: static void warmboot_init_message_record_bitmask(struct adreno_device *adreno_dev) 2094: { 2095: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2096: struct gmu_core_device *gmu_core = &device->gmu_core; 2097: struct gen7_hfi *hfi = to_gen7_hfi(adreno_dev); 2098: 2099: if (!gmu_core->warmboot_enabled) 2100: return; 2101: 2102: /* Set the record bit for all the messages */ 2103: memset(hfi->wb_set_record_bitmask, 0xFF, sizeof(hfi->wb_set_record_bitmask)); 2104: 2105: /* These messages should not be recorded */ 2106: clear_bit(H2F_MSG_WARMBOOT_CMD, hfi->wb_set_record_bitmask); 2107: clear_bit(H2F_MSG_START, hfi->wb_set_record_bitmask); 2108: clear_bit(H2F_MSG_GET_VALUE, hfi->wb_set_record_bitmask); 2109: clear_bit(H2F_MSG_GX_BW_PERF_VOTE, hfi->wb_set_record_bitmask); 2110: } 2111: 2112: int gen7_hwsched_hfi_start(struct adreno_device *adreno_dev) 2113: { 2114: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2115: struct gmu_core_device *gmu_core = &device->gmu_core; 2116: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 2117: struct pending_cmd ack = {0}; 2118: int ret; 2119: 2120: reset_hfi_queues(adreno_dev); 2121: 2122: ret = gen7_gmu_hfi_start(adreno_dev); 2123: if (ret) 2124: goto err; 2125: 2126: if (gen7_hwsched_warmboot_possible(adreno_dev)) 2127: return gen7_hwsched_warmboot_init_gmu(adreno_dev); 2128: 2129: if (ADRENO_FEATURE(adreno_dev, ADRENO_GMU_WARMBOOT) && 2130: (!test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags))) { 2131: if (gen7_hfi_send_get_value(adreno_dev, HFI_VALUE_GMU_WARMBOOT, 0) == 1) 2132: gmu_core->warmboot_enabled = true; 2133: } 2134: 2135: warmboot_init_message_record_bitmask(adreno_dev); 2136: 2137: /* Reset the variable here and set it when we successfully record the scratch */ 2138: clear_bit(GMU_PRIV_WARMBOOT_GMU_INIT_DONE, &gmu->flags); 2139: clear_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags); 2140: 2141: ret = gen7_hwsched_hfi_send_warmboot_cmd(adreno_dev, gmu->gmu_init_scratch, 2142: HFI_WARMBOOT_SET_SCRATCH, false, &ack); 2143: if (ret) 2144: goto err; 2145: 2146: ret = gen7_hfi_send_gpu_perf_table(adreno_dev); 2147: if (ret) 2148: goto err; 2149: 2150: ret = gen7_hfi_send_generic_req(adreno_dev, &gmu->hfi.bw_table, sizeof(gmu->hfi.bw_table)); 2151: if (ret) 2152: goto err; 2153: 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) 2191: goto err; 2192: 2193: /* Enable the long ib timeout detection */ 2194: if (adreno_long_ib_detect(adreno_dev)) { 2195: ret = gen7_hfi_send_feature_ctrl(adreno_dev, 2196: HFI_FEATURE_BAIL_OUT_TIMER, 1, 0); 2197: if (ret) 2198: goto err; 2199: } 2200: 2201: enable_gmu_stats(adreno_dev); 2202: 2203: if (gmu->log_stream_enable) 2204: gen7_hfi_send_set_value(adreno_dev, 2205: HFI_VALUE_LOG_STREAM_ENABLE, 0, 1); 2206: 2207: if (gmu->log_group_mask) 2208: gen7_hfi_send_set_value(adreno_dev, 2209: HFI_VALUE_LOG_GROUP, 0, gmu->log_group_mask); 2210: 2211: ret = gen7_hfi_send_core_fw_start(adreno_dev); 2212: if (ret) 2213: goto err; 2214: 2215: /* 2216: * HFI_VALUE_CONTEXT_QUEUE can only be queried after GMU has initialized some of the 2217: * required resources as part of handling gen7_hfi_send_core_fw_start() 2218: */ 2219: if (!test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags)) 2220: _context_queue_hw_fence_enable(adreno_dev); 2221: 2222: ret = gen7_hfi_send_hw_fence_feature_ctrl(adreno_dev); 2223: if (ret) 2224: goto err; 2225: 2226: ret = enable_preemption(adreno_dev); 2227: if (ret) 2228: goto err; 2229: 2230: ret = gen7_hfi_send_lpac_feature_ctrl(adreno_dev); 2231: if (ret) 2232: goto err; 2233: 2234: if (ADRENO_FEATURE(adreno_dev, ADRENO_AQE)) { 2235: ret = gen7_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_AQE, 1, 0); 2236: if (ret) 2237: goto err; 2238: } 2239: 2240: ret = send_start_msg(adreno_dev); 2241: if (ret) 2242: goto err; 2243: 2244: /* 2245: * Send this additional start message on cold boot if warmboot is enabled. 2246: * This message will be recorded and on a warmboot this will trigger the 2247: * sequence to replay memory allocation requests and ECP task setup 2248: */ 2249: ret = send_warmboot_start_msg(adreno_dev); 2250: if (ret) 2251: goto err; 2252: 2253: gen7_hwsched_enable_async_hfi(adreno_dev); 2254: 2255: set_bit(GMU_PRIV_HFI_STARTED, &gmu->flags); 2256: 2257: /* Send this message only on cold boot */ 2258: ret = gen7_hwsched_hfi_send_warmboot_cmd(adreno_dev, gmu->gmu_init_scratch, 2259: HFI_WARMBOOT_QUERY_SCRATCH, true, &ack); 2260: if (ret) 2261: goto err; 2262: 2263: if (gmu_core->warmboot_enabled) 2264: set_bit(GMU_PRIV_WARMBOOT_GMU_INIT_DONE, &gmu->flags); 2265: 2266: ret = kgsl_pwrctrl_setup_default_votes(KGSL_DEVICE(adreno_dev)); 2267: 2268: err: 2269: if (ret) 2270: gen7_hwsched_hfi_stop(adreno_dev); 2271: 2272: return ret; 2273: } 2274: 2275: static int submit_raw_cmds(struct adreno_device *adreno_dev, void *cmds, u32 size_bytes, 2276: const char *str) 2277: { 2278: int ret; 2279: 2280: ret = gen7_hfi_send_cmd_async(adreno_dev, cmds, size_bytes); 2281: if (ret) 2282: return ret; 2283: 2284: ret = gmu_core_timed_poll_check(KGSL_DEVICE(adreno_dev), 2285: GEN7_GPU_GMU_AO_GPU_CX_BUSY_STATUS, 0, 200, BIT(23)); 2286: if (ret) 2287: gen7_spin_idle_debug(adreno_dev, str); 2288: 2289: return ret; 2290: } 2291: 2292: static int submit_lpac_raw_cmds(struct adreno_device *adreno_dev, void *cmds, u32 size_bytes, 2293: const char *str) 2294: { 2295: int ret; 2296: 2297: ret = gen7_hfi_send_cmd_async(adreno_dev, cmds, size_bytes); 2298: if (ret) 2299: return ret; 2300: 2301: ret = gmu_core_timed_poll_check(KGSL_DEVICE(adreno_dev), 2302: GEN7_GPU_GMU_AO_GPU_LPAC_BUSY_STATUS, 0, 200, BIT(23)); 2303: if (ret) 2304: gen7_spin_idle_debug_lpac(adreno_dev, str); 2305: 2306: return ret; 2307: } 2308: 2309: static int cp_init(struct adreno_device *adreno_dev) 2310: { 2311: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 2312: u32 cmds[GEN7_CP_INIT_DWORDS + 1]; 2313: int ret = 0; 2314: 2315: cmds[0] = CREATE_MSG_HDR(H2F_MSG_ISSUE_CMD_RAW, HFI_MSG_CMD); 2316: 2317: gen7_cp_init_cmds(adreno_dev, &cmds[1]); 2318: 2319: ret = submit_raw_cmds(adreno_dev, cmds, sizeof(cmds), 2320: "CP initialization failed to idle\n"); 2321: 2322: /* Save the header incase we need a warmboot debug */ 2323: gmu->cp_init_hdr = cmds[0]; 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) MATCH LINES: 2377, 2385, 2394, 2395, 2397, 2399, 2405, 2406, 2444, 2450, 2454, 2464, 2467, 2470, 2471, 2476, 2494, 2502, 2504, 2505, 2507, 2509, 2510, 2520, 2522, 2541, 2542, 2543, 2544, 2547, 2548, 2553, 2554, 2555, 2556, 2559, 2560, 2563, 2573, 2589, 2601, 2608, 2624, 2626, 2629, 2635, 2640, 2644, 2645, 2652, 2656, 2657, 2662, 2664, 2666, 2672, 2674, 2688, 2692, 2704, 2706, 2712, 2742, 2748, 2753, 2770, 2771, 2775, 2777, 2780, 2786, 2806, 2827, 2830, 2842, 2845, 2872, 2901, 2911, 2912, 2935, 2943, 2957, 2958, 2977, 2987, 2991, 3017, 3025, 3032, 3040 2365: ret = send_switch_to_unsecure(adreno_dev); 2366: 2367: return ret; 2368: } 2369: 2370: int gen7_hwsched_lpac_cp_init(struct adreno_device *adreno_dev) 2371: { 2372: u32 cmds[GEN7_CP_INIT_DWORDS + 1]; 2373: 2374: if (!adreno_dev->lpac_enabled) 2375: return 0; 2376: 2377: cmds[0] = CREATE_MSG_HDR(H2F_MSG_ISSUE_LPAC_CMD_RAW, HFI_MSG_CMD); 2378: 2379: gen7_cp_init_cmds(adreno_dev, &cmds[1]); 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, 2417: hwsched_hfi); 2418: struct adreno_device *adreno_dev = &gen7_hw_dev->gen7_dev.adreno_dev; 2419: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2420: u32 unack_count, ts; 2421: struct adreno_context *drawctxt = NULL; 2422: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 2423: bool fault; 2424: 2425: /* Check msgq one last time before recording a fault */ 2426: gen7_hwsched_process_msgq(adreno_dev); 2427: 2428: spin_lock(&hwf->lock); 2429: 2430: unack_count = hwf->unack_count; 2431: 2432: fault = test_bit(GEN7_HWSCHED_HW_FENCE_SLEEP_BIT, &hwf->flags) && 2433: test_bit(GEN7_HWSCHED_HW_FENCE_MAX_BIT, &hwf->flags) && 2434: (unack_count > MIN_HW_FENCE_UNACK_COUNT); 2435: 2436: drawctxt = hwf->defer_drawctxt; 2437: ts = hwf->defer_ts; 2438: 2439: spin_unlock(&hwf->lock); 2440: 2441: if (!fault) 2442: return; 2443: 2444: dev_err(GMU_PDEV_DEV(device), 2445: "Hardware fence unack(%d) timeout\n", unack_count); 2446: 2447: if (drawctxt) { 2448: struct kgsl_process_private *proc_priv = drawctxt->base.proc_priv; 2449: 2450: dev_err(GMU_PDEV_DEV(device), 2451: "Hardware fence got deferred for ctx:%d ts:%d pid:%d proc:%s\n", 2452: drawctxt->base.id, ts, pid_nr(proc_priv->pid), proc_priv->comm); 2453: } 2454: gen7_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 2455: } 2456: 2457: static void gen7_hwsched_hw_fence_timer(struct timer_list *t) 2458: { 2459: struct gen7_hwsched_hfi *hfi = kgsl_timer_container_of(hfi, t, hw_fence_timer); 2460: 2461: kgsl_schedule_work(&hfi->hw_fence_ws); 2462: } 2463: 2464: int gen7_hwsched_hfi_probe(struct adreno_device *adreno_dev) 2465: { 2466: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2467: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 2468: struct gen7_hwsched_hfi *hw_hfi = to_gen7_hwsched_hfi(adreno_dev); 2469: 2470: gmu->hfi.irq = kgsl_request_irq(GMU_PDEV(device), "hfi", NULL, -EINVAL, 2471: gen7_hwsched_hfi_handler, adreno_dev); 2472: 2473: if (gmu->hfi.irq < 0) 2474: return gmu->hfi.irq; 2475: 2476: hw_hfi->irq_mask = HFI_IRQ_MASK; 2477: 2478: rwlock_init(&hw_hfi->msglock); 2479: 2480: INIT_LIST_HEAD(&hw_hfi->msglist); 2481: INIT_LIST_HEAD(&hw_hfi->detached_hw_fence_list); 2482: 2483: init_waitqueue_head(&hw_hfi->f2h_wq); 2484: 2485: mutex_init(&hw_hfi->msgq_mutex); 2486: 2487: INIT_WORK(&hw_hfi->hw_fence_ws, gen7_hwsched_hw_fence_timeout); 2488: 2489: timer_setup(&hw_hfi->hw_fence_timer, gen7_hwsched_hw_fence_timer, 0); 2490: 2491: return 0; 2492: } 2493: 2494: void gen7_hwsched_hfi_remove(struct adreno_device *adreno_dev) 2495: { 2496: struct gen7_hwsched_hfi *hw_hfi = to_gen7_hwsched_hfi(adreno_dev); 2497: 2498: if (hw_hfi->f2h_task) 2499: kthread_stop(hw_hfi->f2h_task); 2500: } 2501: 2502: static void init_gmu_context_queue(struct adreno_context *drawctxt) 2503: { 2504: struct kgsl_memdesc *md = &drawctxt->gmu_context_queue; 2505: struct gmu_context_queue_header *hdr = md->hostptr; 2506: 2507: hdr->start_addr = md->gmuaddr + sizeof(*hdr); 2508: hdr->queue_size = (md->size - sizeof(*hdr)) >> 2; 2509: hdr->hw_fence_buffer_va = drawctxt->gmu_hw_fence_queue.gmuaddr; 2510: hdr->hw_fence_buffer_size = drawctxt->gmu_hw_fence_queue.size; 2511: } 2512: 2513: static u32 get_dq_id(struct adreno_device *adreno_dev, struct kgsl_context *context) 2514: { 2515: struct dq_info *info; 2516: u32 next; 2517: u32 priority = adreno_get_level(context); 2518: 2519: if (adreno_dev->lpac_enabled) 2520: info = &gen7_hfi_dqs_lpac[priority]; 2521: else 2522: info = &gen7_hfi_dqs[priority]; 2523: 2524: next = info->base_dq_id + info->offset; 2525: 2526: info->offset = (info->offset + 1) % info->max_dq; 2527: 2528: return next; 2529: } 2530: 2531: static int allocate_context_queues(struct adreno_device *adreno_dev, 2532: struct adreno_context *drawctxt) 2533: { 2534: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2535: int ret = 0; 2536: 2537: if (!adreno_hwsched_context_queue_enabled(adreno_dev)) 2538: return 0; 2539: 2540: if (test_bit(ADRENO_HWSCHED_HW_FENCE, &adreno_dev->hwsched.flags) && 2541: !drawctxt->gmu_hw_fence_queue.gmuaddr) { 2542: ret = gmu_core_alloc_kernel_block( 2543: device, &drawctxt->gmu_hw_fence_queue, 2544: HW_FENCE_QUEUE_SIZE, GMU_NONCACHED_KERNEL, 2545: IOMMU_READ | IOMMU_WRITE | IOMMU_PRIV); 2546: if (ret) { 2547: memset(&drawctxt->gmu_hw_fence_queue, 0x0, 2548: sizeof(drawctxt->gmu_hw_fence_queue)); 2549: return ret; 2550: } 2551: } 2552: 2553: if (!drawctxt->gmu_context_queue.gmuaddr) { 2554: ret = gmu_core_alloc_kernel_block( 2555: device, &drawctxt->gmu_context_queue, 2556: SZ_4K, GMU_NONCACHED_KERNEL, 2557: IOMMU_READ | IOMMU_WRITE | IOMMU_PRIV); 2558: if (ret) { 2559: memset(&drawctxt->gmu_context_queue, 0x0, 2560: sizeof(drawctxt->gmu_context_queue)); 2561: return ret; 2562: } 2563: init_gmu_context_queue(drawctxt); 2564: } 2565: 2566: return 0; 2567: } 2568: 2569: static int send_context_register(struct adreno_device *adreno_dev, 2570: struct kgsl_context *context) 2571: { 2572: struct adreno_context *drawctxt = ADRENO_CONTEXT(context); 2573: struct hfi_register_ctxt_cmd cmd; 2574: struct kgsl_pagetable *pt = context->proc_priv->pagetable; 2575: int ret, asid = kgsl_mmu_pagetable_get_asid(pt, context); 2576: 2577: if (asid < 0) 2578: return asid; 2579: 2580: ret = CMD_MSG_HDR(cmd, H2F_MSG_REGISTER_CONTEXT); 2581: if (ret) 2582: return ret; 2583: 2584: ret = allocate_context_queues(adreno_dev, drawctxt); 2585: if (ret) 2586: return ret; 2587: 2588: cmd.ctxt_id = context->id; 2589: cmd.flags = HFI_CTXT_FLAG_NOTIFY | context->flags; 2590: /* 2591: * HLOS SMMU driver programs context bank to look up ASID from TTBR0 during a page 2592: * table walk. So the TLB entries are tagged with the ASID from TTBR0. TLBIASID 2593: * invalidates TLB entries whose ASID matches the value that was written to the 2594: * CBn_TLBIASID register. Set ASID along with PT address. 2595: */ 2596: cmd.pt_addr = kgsl_mmu_pagetable_get_ttbr0(pt) | 2597: FIELD_PREP(GENMASK_ULL(63, KGSL_IOMMU_ASID_START_BIT), asid); 2598: cmd.ctxt_idr = context->id; 2599: cmd.ctxt_bank = kgsl_mmu_pagetable_get_context_bank(pt, context); 2600: 2601: return gen7_hfi_send_cmd_async(adreno_dev, &cmd, sizeof(cmd)); 2602: } 2603: 2604: static int send_context_pointers(struct adreno_device *adreno_dev, 2605: struct kgsl_context *context) 2606: { 2607: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2608: struct hfi_context_pointers_cmd cmd = {0}; 2609: struct adreno_context *drawctxt = ADRENO_CONTEXT(context); 2610: int ret; 2611: 2612: ret = CMD_MSG_HDR(cmd, H2F_MSG_CONTEXT_POINTERS); 2613: if (ret) 2614: return ret; 2615: 2616: cmd.ctxt_id = context->id; 2617: cmd.sop_addr = MEMSTORE_ID_GPU_ADDR(device, context->id, soptimestamp); 2618: cmd.eop_addr = MEMSTORE_ID_GPU_ADDR(device, context->id, eoptimestamp); 2619: if (context->user_ctxt_record) 2620: cmd.user_ctxt_record_addr = 2621: context->user_ctxt_record->memdesc.gpuaddr; 2622: 2623: if (adreno_hwsched_context_queue_enabled(adreno_dev)) 2624: cmd.gmu_context_queue_addr = drawctxt->gmu_context_queue.gmuaddr; 2625: 2626: return gen7_hfi_send_cmd_async(adreno_dev, &cmd, sizeof(cmd)); 2627: } 2628: 2629: static int hfi_context_register(struct adreno_device *adreno_dev, 2630: struct kgsl_context *context) 2631: { 2632: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2633: int ret; 2634: 2635: if (context->gmu_registered) 2636: return 0; 2637: 2638: ret = send_context_register(adreno_dev, context); 2639: if (ret) { 2640: dev_err(GMU_PDEV_DEV(device), 2641: "Unable to register context %u: %d\n", 2642: context->id, ret); 2643: 2644: if (device->gmu_fault) 2645: gen7_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 2646: 2647: return ret; 2648: } 2649: 2650: ret = send_context_pointers(adreno_dev, context); 2651: if (ret) { 2652: dev_err(GMU_PDEV_DEV(device), 2653: "Unable to register context %u pointers: %d\n", 2654: context->id, ret); 2655: 2656: if (device->gmu_fault) 2657: gen7_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 2658: 2659: return ret; 2660: } 2661: 2662: context->gmu_registered = true; 2663: if (adreno_hwsched_context_queue_enabled(adreno_dev)) 2664: context->gmu_dispatch_queue = UINT_MAX; 2665: else 2666: context->gmu_dispatch_queue = get_dq_id(adreno_dev, context); 2667: 2668: return 0; 2669: } 2670: 2671: static void populate_ibs(struct adreno_device *adreno_dev, 2672: struct hfi_submit_cmd *cmd, struct kgsl_drawobj_cmd *cmdobj) 2673: { 2674: struct hfi_issue_ib *issue_ib; 2675: struct kgsl_memobj_node *ib; 2676: 2677: if (cmdobj->numibs > HWSCHED_MAX_DISPATCH_NUMIBS) { 2678: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev); 2679: struct kgsl_memdesc *big_ib; 2680: 2681: if (test_bit(CMDOBJ_RECURRING_START, &cmdobj->priv)) 2682: big_ib = hfi->big_ib_recurring; 2683: else 2684: big_ib = hfi->big_ib; 2685: /* 2686: * The dispatcher ensures that there is only one big IB inflight 2687: */ 2688: cmd->big_ib_gmu_va = big_ib->gmuaddr; 2689: cmd->flags |= CMDBATCH_INDIRECT; 2690: issue_ib = big_ib->hostptr; 2691: } else { 2692: issue_ib = (struct hfi_issue_ib *)&cmd[1]; 2693: } 2694: 2695: list_for_each_entry(ib, &cmdobj->cmdlist, node) { 2696: issue_ib->addr = ib->gpuaddr; 2697: issue_ib->size = ib->size; 2698: issue_ib++; 2699: } 2700: 2701: cmd->numibs = cmdobj->numibs; 2702: } 2703: 2704: #define HFI_DSP_IRQ_BASE 2 2705: 2706: #define DISPQ_IRQ_BIT(_idx) BIT((_idx) + HFI_DSP_IRQ_BASE) 2707: #define DISPQ_SYNC_IRQ_BIT(_idx) ((DISPQ_IRQ_BIT(_idx) << (KGSL_PRIORITY_MAX_RB_LEVELS + 1))) 2708: 2709: static u32 get_irq_bit(struct adreno_device *adreno_dev, struct kgsl_drawobj *drawobj) 2710: { 2711: if (!adreno_hwsched_context_queue_enabled(adreno_dev)) 2712: return drawobj->context->gmu_dispatch_queue; 2713: 2714: if (adreno_is_preemption_enabled(adreno_dev)) 2715: return adreno_get_level(drawobj->context); 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: 2852: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 2853: } 2854: spin_unlock(&drawctxt->lock); 2855: 2856: return ret; 2857: } 2858: 2859: /** 2860: * move_detached_context_hardware_fences - Move all pending hardware fences belonging to this 2861: * context to the detached hardware fence list so as to send them to TxQueue after fault recovery. 2862: * This is needed because this context may get destroyed before fault recovery gets executed. 2863: */ 2864: static void move_detached_context_hardware_fences(struct adreno_device *adreno_dev, 2865: struct adreno_context *drawctxt) 2866: { 2867: struct adreno_hw_fence_entry *entry, *tmp; 2868: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev); 2869: 2870: spin_lock(&drawctxt->lock); 2871: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_inflight_list, node) { 2872: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr; 2873: 2874: if ((timestamp_cmp((u32)entry->cmd.ts, hdr->out_fence_ts) > 0)) { 2875: _kgsl_context_get(&drawctxt->base); 2876: list_move_tail(&entry->node, &hfi->detached_hw_fence_list); 2877: continue; 2878: } 2879: 2880: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 2881: } 2882: 2883: spin_unlock(&drawctxt->lock); 2884: 2885: /* Also grab all the hardware fences which were never sent to GMU */ 2886: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_list, node) { 2887: _kgsl_context_get(&drawctxt->base); 2888: list_move_tail(&entry->node, &hfi->detached_hw_fence_list); 2889: } 2890: } 2891: 2892: static int drain_context_hw_fence_gmu(struct adreno_device *adreno_dev, 2893: struct adreno_context *drawctxt) 2894: { 2895: struct adreno_hw_fence_entry *entry, *tmp; 2896: int ret = 0; 2897: 2898: /* Send hardware fences (to TxQueue) that were not dispatched to GMU */ 2899: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_list, node) { 2900: 2901: ret = gen7_send_hw_fence_hfi_wait_ack(adreno_dev, entry, 2902: HW_FENCE_FLAG_SKIP_MEMSTORE); 2903: if (ret) 2904: break; 2905: 2906: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 2907: } 2908: 2909: if (ret) { 2910: move_detached_context_hardware_fences(adreno_dev, drawctxt); 2911: gmu_core_fault_snapshot(KGSL_DEVICE(adreno_dev), GMU_FAULT_HW_FENCE); 2912: gen7_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 2913: } 2914: 2915: return ret; 2916: } 2917: 2918: /** 2919: * check_detached_context_hardware_fences - When this context has been un-registered with the GMU, 2920: * make sure all the hardware fences(that were sent to GMU) for this context have been sent to 2921: * TxQueue. Also, send any hardware fences (to GMU) that were not yet dispatched to the GMU. In case 2922: * of an error, move the pending hardware fences to detached hardware fence list, log the error, 2923: * take a snapshot and trigger recovery. 2924: */ 2925: static int check_detached_context_hardware_fences(struct adreno_device *adreno_dev, 2926: struct adreno_context *drawctxt) 2927: { 2928: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2929: struct adreno_hw_fence_entry *entry, *tmp; 2930: int ret = 0; 2931: u32 id, ts, fence_ts; 2932: 2933: spin_lock(&drawctxt->lock); 2934: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_inflight_list, node) { 2935: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr; 2936: 2937: if ((timestamp_cmp((u32)entry->cmd.ts, hdr->out_fence_ts) > 0)) { 2938: id = drawctxt->base.id; 2939: ts = (u32)entry->cmd.ts; 2940: fence_ts = hdr->out_fence_ts; 2941: 2942: spin_unlock(&drawctxt->lock); 2943: dev_err(GMU_PDEV_DEV(device), 2944: "detached ctx:%d has unsignaled fence ts:%d retired:%d\n", 2945: id, ts, fence_ts); 2946: ret = -EINVAL; 2947: goto fault; 2948: } 2949: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 2950: } 2951: 2952: spin_unlock(&drawctxt->lock); 2953: return drain_context_hw_fence_gmu(adreno_dev, drawctxt); 2954: 2955: fault: 2956: move_detached_context_hardware_fences(adreno_dev, drawctxt); 2957: gmu_core_fault_snapshot(device, GMU_FAULT_HW_FENCE); 2958: gen7_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 2959: 2960: return ret; 2961: } 2962: 2963: static inline int setup_hw_fence_info_cmd(struct adreno_device *adreno_dev, 2964: struct adreno_hw_fence_entry *entry) 2965: { 2966: struct kgsl_sync_fence *kfence = entry->kfence; 2967: int ret; 2968: 2969: ret = CMD_MSG_HDR(entry->cmd, H2F_MSG_HW_FENCE_INFO); 2970: if (ret) 2971: return ret; 2972: 2973: ret = kgsl_hw_fence_create(KGSL_DEVICE(adreno_dev), kfence); 2974: if (ret) 2975: return ret; 2976: 2977: entry->cmd.gmu_ctxt_id = entry->drawctxt->base.id; 2978: entry->cmd.ctxt_id = kfence->fence.context; 2979: entry->cmd.ts = kfence->fence.seqno; 2980: 2981: entry->cmd.hash_index = kfence->hw_fence_index; 2982: 2983: return 0; 2984: } 2985: 2986: /* 2987: * gen7_send_hw_fence_hfi_wait_ack - This function is used in cases where multiple hardware fences 2988: * are to be sent to GMU. Hence, we must send them one by one to avoid overwhelming the GMU with 2989: * mutliple fences in a short span of time. 2990: */ 2991: int gen7_send_hw_fence_hfi_wait_ack(struct adreno_device *adreno_dev, 2992: struct adreno_hw_fence_entry *entry, u64 flags) 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: { 3049: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 3050: struct adreno_hw_fence_entry *entry; 3051: 3052: if (!kgsl_hw_fence_tx_slot_available(KGSL_DEVICE(adreno_dev), 3053: hwsched->hw_fence.pending_count)) 3054: return NULL; 3055: 3056: if (!DRAWCTXT_SLOT_AVAILABLE(drawctxt->hw_fence_count)) 3057: return NULL; 3058: 3059: if (!_kgsl_context_get(&drawctxt->base)) 3060: return NULL; 3061: 3062: entry = kmem_cache_zalloc(hwsched->hw_fence_cache, GFP_ATOMIC); 3063: if (!entry) { 3064: kgsl_context_put_deferred(&drawctxt->base); MATCH LINES: 3216, 3245 3204: /* If recovery is imminent, then do not create a hardware fence */ 3205: if (test_bit(GEN7_HWSCHED_HW_FENCE_ABORT_BIT, &hwf->flags)) 3206: goto done; 3207: 3208: ret = _hw_fence_sleep(adreno_dev, drawctxt); 3209: if (ret) 3210: goto done; 3211: 3212: /* 3213: * If this ts hasn't been submitted yet, then store it in the drawctxt hardware fence 3214: * list and return. This fence will be sent to GMU when this ts is dispatched to GMU. 3215: */ 3216: if (timestamp_cmp(kfence->timestamp, drawctxt->gmu_hw_fence_ready_ts) > 0) { 3217: drawctxt_queue_hw_fence(adreno_dev, drawctxt, kfence); 3218: goto done; 3219: } 3220: 3221: kgsl_readtimestamp(device, context, KGSL_TIMESTAMP_RETIRED, &retired); 3222: 3223: /* 3224: * Check if timestamp is retired. If we are in SLUMBER at this point, the timestamp is 3225: * guaranteed to be retired. This way, we don't need the device mutex to check the device 3226: * state explicitly. 3227: */ 3228: if (timestamp_cmp(retired, kfence->timestamp) >= 0) { 3229: kgsl_sync_timeline_signal(ktimeline, kfence->timestamp); 3230: goto done; 3231: } 3232: 3233: entry = allocate_hw_fence_entry(adreno_dev, drawctxt, kfence); 3234: if (!entry) 3235: goto done; 3236: 3237: /* 3238: * If timestamp is not retired then GMU must already be powered up. This is because SLUMBER 3239: * thread has to wait for hardware fence spinlock to make sure the hardware fence unack 3240: * count is zero. 3241: */ 3242: ret = _send_hw_fence_no_ack(adreno_dev, entry); 3243: if (ret) { 3244: if (__ratelimit(&_rs)) 3245: dev_err(GMU_PDEV_DEV(device), "hw fence for ctx:%d ts:%d ret:%d may not be destroyed\n", 3246: kfence->context_id, kfence->timestamp, ret); 3247: kgsl_hw_fence_destroy(kfence); 3248: destroy = true; 3249: drawctxt->hw_fence_last_ts = hw_fence_last_ts; 3250: goto done; 3251: } 3252: 3253: list_add_tail(&entry->node, &drawctxt->hw_fence_inflight_list); 3254: 3255: done: 3256: spin_unlock(&hwf->lock); 3257: if (destroy) 3258: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 3259: spin_unlock(&drawctxt->lock); 3260: } 3261: 3262: /** 3263: * setup_hw_fence_deferred_ctxt - The hardware fence(s) from this context couldn't be sent to the 3264: * GMU because the hardware fence unack count reached a threshold. Hence, setup this context such 3265: * that these hardware fences are sent to the GMU when the unack count drops to a desired threshold. 3266: */ 3267: static void setup_hw_fence_deferred_ctxt(struct adreno_device *adreno_dev, 3268: struct adreno_context *drawctxt, u32 ts) 3269: { MATCH LINES: 3326, 3329, 3330, 3331, 3338, 3341, 3373, 3380, 3382, 3392, 3396, 3401, 3407, 3433, 3435, 3443, 3475, 3479, 3480, 3482, 3483, 3488, 3492, 3495, 3503, 3507, 3518, 3541, 3543, 3566, 3574, 3576, 3614, 3617, 3643, 3650, 3659, 3663, 3670, 3674, 3679, 3680, 3708, 3715 3314: if (ret) 3315: return; 3316: 3317: /* 3318: * A fence that is sent to GMU must be added to the drawctxt->hw_fence_inflight_list 3319: * so that we can keep track of when GMU sends it to the TxQueue 3320: */ 3321: list_move_tail(&entry->node, &drawctxt->hw_fence_inflight_list); 3322: } 3323: } 3324: 3325: /* Size in below functions are in unit of dwords */ 3326: static int gen7_hfi_dispatch_queue_write(struct adreno_device *adreno_dev, u32 queue_idx, 3327: u32 *msg, u32 size_bytes, struct kgsl_drawobj_cmd *cmdobj, struct adreno_submit_time *time) 3328: { 3329: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 3330: struct hfi_queue_table *tbl = gmu->hfi.hfi_mem->hostptr; 3331: struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx]; 3332: u32 *queue; 3333: u32 i, write, empty_space; 3334: u32 size_dwords = size_bytes >> 2; 3335: u32 align_size = ALIGN(size_dwords, SZ_4); 3336: u32 id = MSG_HDR_GET_ID(*msg); 3337: 3338: if (hdr->status == HFI_QUEUE_STATUS_DISABLED || !IS_ALIGNED(size_bytes, sizeof(u32))) 3339: return -EINVAL; 3340: 3341: queue = HOST_QUEUE_START_ADDR(gmu->hfi.hfi_mem, queue_idx); 3342: 3343: empty_space = (hdr->write_index >= hdr->read_index) ? 3344: (hdr->queue_size - (hdr->write_index - hdr->read_index)) 3345: : (hdr->read_index - hdr->write_index); 3346: 3347: if (empty_space <= align_size) 3348: return -ENOSPC; 3349: 3350: write = hdr->write_index; 3351: 3352: for (i = 0; i < size_dwords; i++) { 3353: queue[write] = msg[i]; 3354: write = (write + 1) % hdr->queue_size; 3355: } 3356: 3357: /* Cookify any non used data at the end of the write buffer */ 3358: for (; i < align_size; i++) { 3359: queue[write] = 0xfafafafa; 3360: write = (write + 1) % hdr->queue_size; 3361: } 3362: 3363: /* Ensure packet is written out before proceeding */ 3364: wmb(); 3365: 3366: if (!cmdobj) 3367: goto done; 3368: 3369: adreno_hwsched_add_profile_events(adreno_dev, cmdobj, time); 3370: 3371: /* 3372: * Put the profiling information in the user profiling buffer. 3373: * The hfi_update_write_idx below has a wmb() before the actual 3374: * write index update to ensure that the GMU does not see the 3375: * packet before the profile data is written out. 3376: */ 3377: adreno_profile_submit_time(time); 3378: 3379: done: 3380: trace_kgsl_hfi_send(id, size_dwords, MSG_HDR_GET_SEQNUM(*msg)); 3381: 3382: hfi_update_write_idx(&hdr->write_index, write); 3383: 3384: return 0; 3385: } 3386: 3387: int gen7_hwsched_submit_drawobj(struct adreno_device *adreno_dev, struct kgsl_drawobj *drawobj) 3388: { 3389: int ret = 0; 3390: u32 cmd_sizebytes, seqnum; 3391: struct kgsl_drawobj_cmd *cmdobj = NULL; 3392: struct hfi_submit_cmd *cmd; 3393: struct adreno_submit_time time = {0}; 3394: struct adreno_context *drawctxt = ADRENO_CONTEXT(drawobj->context); 3395: static void *cmdbuf; 3396: struct gmu_context_queue_header *hdr = NULL; 3397: 3398: if (cmdbuf == NULL) { 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)) 3436: return -EMSGSIZE; 3437: 3438: memset(cmdbuf, 0x0, cmd_sizebytes); 3439: 3440: cmd = cmdbuf; 3441: 3442: cmd->ctxt_id = drawobj->context->id; 3443: cmd->flags = HFI_CTXT_FLAG_NOTIFY; 3444: if (drawobj->flags & KGSL_DRAWOBJ_END_OF_FRAME) 3445: cmd->flags |= CMDBATCH_EOF; 3446: 3447: cmd->ts = drawobj->timestamp; 3448: 3449: if (test_bit(CMDOBJ_SKIP, &cmdobj->priv)) 3450: goto skipib; 3451: 3452: populate_ibs(adreno_dev, cmd, cmdobj); 3453: 3454: if ((drawobj->flags & KGSL_DRAWOBJ_PROFILING) && 3455: cmdobj->profiling_buf_entry) { 3456: 3457: time.drawobj = drawobj; 3458: 3459: cmd->profile_gpuaddr_lo = 3460: lower_32_bits(cmdobj->profiling_buffer_gpuaddr); 3461: cmd->profile_gpuaddr_hi = 3462: upper_32_bits(cmdobj->profiling_buffer_gpuaddr); 3463: 3464: /* Indicate to GMU to do user profiling for this submission */ 3465: cmd->flags |= CMDBATCH_PROFILING; 3466: } 3467: 3468: if (test_and_clear_bit(CMDOBJ_NOP_SUBMISSION, &cmdobj->priv)) 3469: cmd->flags |= CMDBATCH_NOP_SUBMISSION; 3470: 3471: skipib: 3472: adreno_drawobj_set_constraint(KGSL_DEVICE(adreno_dev), drawobj); 3473: 3474: seqnum = atomic_inc_return(&adreno_dev->hwsched.submission_seqnum); 3475: cmd->hdr = CREATE_MSG_HDR(H2F_MSG_ISSUE_CMD, HFI_MSG_CMD); 3476: cmd->hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd->hdr, seqnum, cmd_sizebytes >> 2); 3477: 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) 3515: { 3516: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 3517: struct kgsl_drawobj *drawobj = DRAWOBJ(cmdobj); 3518: struct hfi_submit_cmd *cmd; 3519: struct kgsl_memobj_node *ib; 3520: u32 cmd_sizebytes; 3521: int ret; 3522: static bool active; 3523: 3524: if (adreno_gpu_halt(adreno_dev) || adreno_gpu_fault(adreno_dev)) 3525: return -EBUSY; 3526: 3527: if (test_bit(CMDOBJ_RECURRING_STOP, &cmdobj->priv)) { 3528: cmdobj->numibs = 0; 3529: } else { 3530: list_for_each_entry(ib, &cmdobj->cmdlist, node) 3531: cmdobj->numibs++; 3532: } 3533: 3534: if (cmdobj->numibs > HWSCHED_MAX_IBS) 3535: return -EINVAL; 3536: 3537: if (cmdobj->numibs > HWSCHED_MAX_DISPATCH_NUMIBS) 3538: cmd_sizebytes = sizeof(*cmd); 3539: else 3540: cmd_sizebytes = sizeof(*cmd) + 3541: (sizeof(struct hfi_issue_ib) * cmdobj->numibs); 3542: 3543: if (WARN_ON(cmd_sizebytes > HFI_MAX_MSG_SIZE)) 3544: return -EMSGSIZE; 3545: 3546: cmd = kzalloc(cmd_sizebytes, GFP_KERNEL); 3547: if (cmd == NULL) 3548: return -ENOMEM; 3549: 3550: if (test_bit(CMDOBJ_RECURRING_START, &cmdobj->priv)) { 3551: if (!active) { 3552: ret = adreno_active_count_get(adreno_dev); 3553: if (ret) { 3554: kfree(cmd); 3555: return ret; 3556: } 3557: active = true; 3558: } 3559: cmd->flags |= CMDBATCH_RECURRING_START; 3560: populate_ibs(adreno_dev, cmd, cmdobj); 3561: } else 3562: cmd->flags |= CMDBATCH_RECURRING_STOP; 3563: 3564: cmd->ctxt_id = drawobj->context->id; 3565: 3566: ret = hfi_context_register(adreno_dev, drawobj->context); 3567: if (ret) { 3568: adreno_active_count_put(adreno_dev); 3569: active = false; 3570: kfree(cmd); 3571: return ret; 3572: } 3573: 3574: cmd->hdr = CREATE_MSG_HDR(H2F_MSG_ISSUE_RECURRING_CMD, HFI_MSG_CMD); 3575: 3576: ret = gen7_hfi_send_cmd_async(adreno_dev, cmd, sizeof(*cmd)); 3577: 3578: kfree(cmd); 3579: 3580: if (ret) { 3581: adreno_active_count_put(adreno_dev); 3582: active = false; 3583: return ret; 3584: } 3585: 3586: if (test_bit(CMDOBJ_RECURRING_STOP, &cmdobj->priv)) { 3587: adreno_hwsched_retire_cmdobj(hwsched, hwsched->recurring_cmdobj); 3588: kgsl_delete_timer_sync(&hwsched->lsr_timer); 3589: hwsched->recurring_cmdobj = NULL; 3590: if (active) 3591: adreno_active_count_put(adreno_dev); 3592: active = false; 3593: return ret; 3594: } 3595: 3596: hwsched->recurring_cmdobj = cmdobj; 3597: /* Star LSR timer for power stats collection */ 3598: mod_timer(&hwsched->lsr_timer, jiffies + msecs_to_jiffies(10)); 3599: return ret; 3600: } 3601: 3602: /* 3603: * destroy_detached_context_inflight_hw_fences - Destroy context's hardware fences that were 3604: * dispatched to GMU 3605: */ 3606: static void destroy_detached_context_inflight_hw_fences(struct adreno_device *adreno_dev, 3607: struct adreno_context *drawctxt) 3608: { 3609: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 3610: struct adreno_hw_fence_entry *entry, *tmp; 3611: 3612: spin_lock(&drawctxt->lock); 3613: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_inflight_list, node) { 3614: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr; 3615: 3616: if ((timestamp_cmp((u32)entry->cmd.ts, hdr->out_fence_ts) > 0)) { 3617: dev_err_ratelimited(GMU_PDEV_DEV(device), 3618: "destroying detached ctx:%d unsignaled hw fence ts:%d retired:%d\n", 3619: drawctxt->base.id, (u32)entry->cmd.ts, hdr->out_fence_ts); 3620: } 3621: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 3622: } 3623: spin_unlock(&drawctxt->lock); 3624: } 3625: 3626: /* We don't want to unnecessarily wake the GMU to trigger hardware fences */ 3627: static void drain_context_hw_fence_cpu(struct adreno_device *adreno_dev, 3628: struct adreno_context *drawctxt) 3629: { 3630: struct adreno_hw_fence_entry *entry, *tmp; 3631: 3632: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_list, node) { 3633: 3634: kgsl_hw_fence_trigger_cpu(KGSL_DEVICE(adreno_dev), entry->kfence); 3635: 3636: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 3637: } 3638: } 3639: 3640: static void drain_context_hw_fences(struct adreno_device *adreno_dev, 3641: struct adreno_context *drawctxt) 3642: { 3643: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 3644: 3645: destroy_detached_context_inflight_hw_fences(adreno_dev, drawctxt); 3646: 3647: if (list_empty(&drawctxt->hw_fence_list)) 3648: return; 3649: 3650: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 3651: drain_context_hw_fence_gmu(adreno_dev, drawctxt); 3652: else 3653: drain_context_hw_fence_cpu(adreno_dev, drawctxt); 3654: } 3655: 3656: static void trigger_context_unregister_fault(struct adreno_device *adreno_dev, 3657: struct adreno_context *drawctxt) 3658: { 3659: gmu_core_fault_snapshot(KGSL_DEVICE(adreno_dev), GMU_FAULT_CTX_UNREGISTER); 3660: 3661: /* Make sure we send all fences from this context to the TxQueue after recovery */ 3662: move_detached_context_hardware_fences(adreno_dev, drawctxt); 3663: gen7_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 3664: } 3665: 3666: static int send_context_unregister_hfi(struct adreno_device *adreno_dev, 3667: struct kgsl_context *context, u32 ts) 3668: { 3669: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 3670: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 3671: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev); 3672: struct adreno_context *drawctxt = ADRENO_CONTEXT(context); 3673: struct pending_cmd pending_ack; 3674: struct hfi_unregister_ctxt_cmd cmd; 3675: u32 seqnum; 3676: int ret; 3677: 3678: /* Only send HFI if device is not in SLUMBER */ 3679: if (!context->gmu_registered || 3680: !test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) { 3681: drain_context_hw_fences(adreno_dev, drawctxt); 3682: return 0; 3683: } 3684: 3685: ret = CMD_MSG_HDR(cmd, H2F_MSG_UNREGISTER_CONTEXT); 3686: if (ret) 3687: return ret; 3688: 3689: cmd.ctxt_id = context->id, 3690: cmd.ts = ts, 3691: 3692: /* 3693: * Although we know device is powered on, we can still enter SLUMBER 3694: * because the wait for ack below is done without holding the mutex. So 3695: * take an active count before releasing the mutex so as to avoid a 3696: * concurrent SLUMBER sequence while GMU is un-registering this context. 3697: */ 3698: ret = adreno_active_count_get(adreno_dev); 3699: if (ret) { 3700: trigger_context_unregister_fault(adreno_dev, drawctxt); 3701: return ret; 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: 3739: kgsl_mutex_lock(&device->mutex); MATCH LINES: 3754, 3772, 3783, 3784, 3786, 3787, 3794, 3795, 3798, 3802, 3804, 3805, 3812, 3823, 3836, 3838, 3840, 3850, 3851, 3865, 3869, 3872, 3877 3742: drawctxt->internal_timestamp); 3743: 3744: if (ret) 3745: goto out; 3746: 3747: kgsl_sharedmem_writel(device->memstore, 3748: KGSL_MEMSTORE_OFFSET(context->id, soptimestamp), drawctxt->timestamp); 3749: 3750: kgsl_sharedmem_writel(device->memstore, 3751: KGSL_MEMSTORE_OFFSET(context->id, eoptimestamp), drawctxt->timestamp); 3752: 3753: adreno_profile_process_results(adreno_dev); 3754: context->gmu_registered = false; 3755: 3756: out: 3757: WARN_RATELIMIT(!list_empty(&drawctxt->hw_fence_list) || 3758: !list_empty(&drawctxt->hw_fence_inflight_list), 3759: "detached ctx:%u has active hw fences\n", 3760: context->id); 3761: 3762: kgsl_mutex_unlock(&device->mutex); 3763: } 3764: 3765: u32 gen7_hwsched_preempt_count_get(struct adreno_device *adreno_dev) 3766: { 3767: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 3768: 3769: if (device->state != KGSL_STATE_ACTIVE) 3770: return 0; 3771: 3772: return gen7_hwsched_hfi_get_value(adreno_dev, HFI_VALUE_PREEMPT_COUNT); 3773: } 3774: 3775: void gen7_hwsched_context_destroy(struct adreno_device *adreno_dev, 3776: struct adreno_context *drawctxt) 3777: { 3778: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 3779: 3780: if (!adreno_hwsched_context_queue_enabled(adreno_dev)) 3781: return; 3782: 3783: if (drawctxt->gmu_context_queue.gmuaddr) 3784: gmu_core_free_block(device, &drawctxt->gmu_context_queue); 3785: 3786: if (drawctxt->gmu_hw_fence_queue.gmuaddr) 3787: gmu_core_free_block(device, &drawctxt->gmu_hw_fence_queue); 3788: } 3789: 3790: static int register_global_ctxt(struct adreno_device *adreno_dev) 3791: { 3792: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 3793: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 3794: struct hfi_register_ctxt_cmd rcmd = {0}; 3795: struct hfi_context_pointers_cmd pcmd = {0}; 3796: int ret; 3797: 3798: if (hwsched->global_ctxt_gmu_registered) 3799: return 0; 3800: 3801: if (adreno_hwsched_context_queue_enabled(adreno_dev) && !hwsched->global_ctxtq.hostptr) { 3802: struct gmu_context_queue_header *hdr; 3803: 3804: ret = gmu_core_alloc_kernel_block(device, &hwsched->global_ctxtq, 3805: SZ_4K, GMU_NONCACHED_KERNEL, IOMMU_READ | IOMMU_WRITE | IOMMU_PRIV); 3806: if (ret) { 3807: memset(&hwsched->global_ctxtq, 0x0, sizeof(hwsched->global_ctxtq)); 3808: return ret; 3809: } 3810: 3811: hdr = hwsched->global_ctxtq.hostptr; 3812: hdr->start_addr = hwsched->global_ctxtq.gmuaddr + sizeof(*hdr); 3813: hdr->queue_size = (hwsched->global_ctxtq.size - sizeof(*hdr)) >> 2; 3814: } 3815: 3816: ret = CMD_MSG_HDR(rcmd, H2F_MSG_REGISTER_CONTEXT); 3817: if (ret) 3818: return ret; 3819: 3820: rcmd.ctxt_id = KGSL_GLOBAL_CTXT_ID; 3821: rcmd.flags = (KGSL_CONTEXT_PRIORITY_HIGH << KGSL_CONTEXT_PRIORITY_SHIFT); 3822: 3823: ret = gen7_hfi_send_cmd_async(adreno_dev, &rcmd, sizeof(rcmd)); 3824: if (ret) 3825: return ret; 3826: 3827: ret = CMD_MSG_HDR(pcmd, H2F_MSG_CONTEXT_POINTERS); 3828: if (ret) 3829: return ret; 3830: 3831: pcmd.ctxt_id = KGSL_GLOBAL_CTXT_ID; 3832: pcmd.sop_addr = MEMSTORE_ID_GPU_ADDR(device, KGSL_GLOBAL_CTXT_ID, soptimestamp); 3833: pcmd.eop_addr = MEMSTORE_ID_GPU_ADDR(device, KGSL_GLOBAL_CTXT_ID, eoptimestamp); 3834: 3835: if (adreno_hwsched_context_queue_enabled(adreno_dev)) 3836: pcmd.gmu_context_queue_addr = hwsched->global_ctxtq.gmuaddr; 3837: 3838: ret = gen7_hfi_send_cmd_async(adreno_dev, &pcmd, sizeof(pcmd)); 3839: if (!ret) 3840: hwsched->global_ctxt_gmu_registered = true; 3841: 3842: return ret; 3843: } 3844: 3845: static int submit_global_ctxt_cmd(struct adreno_device *adreno_dev, u64 gpuaddr, u32 size) 3846: { 3847: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 3848: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 3849: struct { 3850: struct hfi_submit_cmd submit_cmd; 3851: struct hfi_issue_ib issue_ib; 3852: } cmd = {0}; 3853: u32 seqnum, cmd_size = sizeof(cmd); 3854: static u32 ts; 3855: int ret; 3856: 3857: cmd.submit_cmd.ctxt_id = KGSL_GLOBAL_CTXT_ID; 3858: cmd.submit_cmd.ts = ++ts; 3859: cmd.submit_cmd.numibs = 1; 3860: 3861: cmd.issue_ib.addr = gpuaddr; 3862: cmd.issue_ib.size = size; 3863: 3864: seqnum = atomic_inc_return(&hwsched->submission_seqnum); 3865: cmd.submit_cmd.hdr = CREATE_MSG_HDR(H2F_MSG_ISSUE_CMD, HFI_MSG_CMD); 3866: cmd.submit_cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.submit_cmd.hdr, seqnum, cmd_size >> 2); 3867: 3868: if (adreno_hwsched_context_queue_enabled(adreno_dev)) 3869: ret = adreno_gmu_context_queue_write(adreno_dev, 3870: &hwsched->global_ctxtq, (u32 *)&cmd, cmd_size, NULL, NULL); 3871: else 3872: ret = gen7_hfi_dispatch_queue_write(adreno_dev, HFI_DSP_ID_0, 3873: (u32 *)&cmd, cmd_size, NULL, NULL); 3874: 3875: /* Send interrupt to GMU to receive the message */ 3876: if (!ret) 3877: gmu_core_regwrite(device, GEN7_GMU_HOST2GMU_INTR_SET, DISPQ_IRQ_BIT(0)); 3878: 3879: return ret; 3880: } 3881: 3882: int gen7_hwsched_counter_inline_enable(struct adreno_device *adreno_dev, 3883: const struct adreno_perfcount_group *group, 3884: u32 counter, u32 countable) 3885: { 3886: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev); 3887: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 3888: struct adreno_perfcount_register *reg = &group->regs[counter]; 3889: u32 val, *cmds, count = 0; 3890: int ret; 3891: 3892: ret = register_global_ctxt(adreno_dev); 3893: if (ret) 3894: goto err; 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) MATCH LINES: 3953 3941: 3942: drawctxt = hwf->defer_drawctxt; 3943: ts = hwf->defer_ts; 3944: 3945: spin_unlock(&hwf->lock); 3946: 3947: if (!drawctxt) 3948: goto done; 3949: 3950: ret = process_hw_fence_deferred_ctxt(adreno_dev, drawctxt, ts); 3951: if (ret) { 3952: /* the deferred drawctxt will be handled post fault recovery */ 3953: gen7_hwsched_fault(adreno_dev, GMU_FAULT_HW_FENCE); 3954: return ret; 3955: } 3956: 3957: kgsl_context_put(&drawctxt->base); 3958: adreno_active_count_put(adreno_dev); 3959: 3960: done: 3961: _disable_hw_fence_throttle(adreno_dev, true); 3962: 3963: return ret; 3964: } --- FILE: \adreno_gen7_hwsched_hfi.h | HITS: 24 --- MATCH LINES: 7, 8, 12, 13 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) 2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #ifndef _ADRENO_GEN7_HWSCHED_HFI_H_ 8: #define _ADRENO_GEN7_HWSCHED_HFI_H_ 9: 10: /* Maximum number of IBs in a submission */ 11: #define HWSCHED_MAX_NUMIBS \ 12: ((HFI_MAX_MSG_SIZE - offsetof(struct hfi_issue_cmd_cmd, ibs)) \ 13: / sizeof(struct hfi_issue_ib)) 14: 15: /* 16: * This is used to put userspace threads to sleep when hardware fence unack count reaches a 17: * threshold. This bit is cleared in two scenarios: 18: * 1. If the hardware fence unack count drops to a desired threshold. 19: * 2. If there is a GMU/GPU fault. Because we don't want the threads to keep sleeping through fault 20: * recovery, which can easily take 100s of milliseconds to complete. 21: */ 22: #define GEN7_HWSCHED_HW_FENCE_SLEEP_BIT 0x0 23: 24: /* 25: * This is used to avoid creating any more hardware fences until the hardware fence unack count 26: * drops to a desired threshold. This bit is required in cases where GEN7_HWSCHED_HW_FENCE_SLEEP_BIT 27: * will be cleared, but we still want to avoid creating any more hardware fences. For example, if 28: * hardware fence unack count reaches a maximum threshold, both GEN7_HWSCHED_HW_FENCE_SLEEP_BIT and 29: * GEN7_HWSCHED_HW_FENCE_MAX_BIT will be set. Say, a GMU/GPU fault happens and 30: * GEN7_HWSCHED_HW_FENCE_SLEEP_BIT will be cleared to wake up any sleeping threads. But, 31: * GEN7_HWSCHED_HW_FENCE_MAX_BIT will remain set to avoid creating any new hardware fences until 32: * recovery is complete and deferred drawctxt (if any) is handled. 33: */ 34: #define GEN7_HWSCHED_HW_FENCE_MAX_BIT 0x1 35: 36: /* 37: * This is used to avoid creating any more hardware fences until concurrent reset/recovery completes MATCH LINES: 78, 83, 86, 89, 92, 100, 103, 110, 113, 118, 146, 156 66: * @hw_fence_ws: Work struct that gets scheduled when hw_fence_timer expires 67: */ 68: struct work_struct hw_fence_ws; 69: /** @detached_hw_fences_list: List of hardware fences belonging to detached contexts */ 70: struct list_head detached_hw_fence_list; 71: /** @defer_hw_fence_work: The work structure to send deferred hardware fences to GMU */ 72: struct kthread_work defer_hw_fence_work; 73: }; 74: 75: struct kgsl_drawobj_cmd; 76: 77: /** 78: * gen7_hwsched_hfi_probe - Probe hwsched hfi resources 79: * @adreno_dev: Pointer to adreno device structure 80: * 81: * Return: 0 on success and negative error on failure. 82: */ 83: int gen7_hwsched_hfi_probe(struct adreno_device *adreno_dev); 84: 85: /** 86: * gen7_hwsched_hfi_remove - Release hwsched hfi resources 87: * @adreno_dev: Pointer to adreno device structure 88: */ 89: void gen7_hwsched_hfi_remove(struct adreno_device *adreno_dev); 90: 91: /** 92: * gen7_hwsched_hfi_init - Initialize hfi resources 93: * @adreno_dev: Pointer to adreno device structure 94: * 95: * This function is used to initialize hfi resources 96: * once before the very first gmu boot 97: * 98: * Return: 0 on success and negative error on failure. 99: */ 100: int gen7_hwsched_hfi_init(struct adreno_device *adreno_dev); 101: 102: /** 103: * gen7_hwsched_hfi_start - Start hfi resources 104: * @adreno_dev: Pointer to adreno device structure 105: * 106: * Send the various hfi packets before booting the gpu 107: * 108: * Return: 0 on success and negative error on failure. 109: */ 110: int gen7_hwsched_hfi_start(struct adreno_device *adreno_dev); 111: 112: /** 113: * gen7_hwsched_hfi_stop - Stop the hfi resources 114: * @adreno_dev: Pointer to the adreno device 115: * 116: * This function does the hfi cleanup when powering down the gmu 117: */ 118: void gen7_hwsched_hfi_stop(struct adreno_device *adreno_dev); 119: 120: /** 121: * gen7_hwched_cp_init - Send CP_INIT via HFI 122: * @adreno_dev: Pointer to adreno device structure 123: * 124: * This function is used to send CP INIT packet and bring 125: * GPU out of secure mode using hfi raw packets. 126: * 127: * Return: 0 on success and negative error on failure. 128: */ 129: int gen7_hwsched_cp_init(struct adreno_device *adreno_dev); 130: 131: /** 132: * gen7_hwsched_counter_inline_enable - Configure a performance counter for a countable 133: * @adreno_dev - Adreno device to configure 134: * @group - Desired performance counter group 135: * @counter - Desired performance counter in the group 136: * @countable - Desired countable 137: * 138: * Physically set up a counter within a group with the desired countable 139: * Return 0 on success or negative error on failure. 140: */ 141: int gen7_hwsched_counter_inline_enable(struct adreno_device *adreno_dev, 142: const struct adreno_perfcount_group *group, 143: u32 counter, u32 countable); 144: 145: /** 146: * gen7_hfi_send_cmd_async - Send an hfi packet 147: * @adreno_dev: Pointer to adreno device structure 148: * @data: Data to be sent in the hfi packet 149: * @size_bytes: Size of the packet in bytes 150: * 151: * Send data in the form of an HFI packet to gmu and wait for 152: * it's ack asynchronously 153: * 154: * Return: 0 on success and negative error on failure. 155: */ 156: int gen7_hfi_send_cmd_async(struct adreno_device *adreno_dev, void *data, u32 size_bytes); 157: 158: /** 159: * gen7_hwsched_submit_drawobj - Dispatch IBs to dispatch queues 160: * @adreno_dev: Pointer to adreno device structure 161: * @drawobj: The command draw object which needs to be submitted 162: * 163: * This function is used to register the context if needed and submit 164: * IBs to the hfi dispatch queues. 165: 166: * Return: 0 on success and negative error on failure 167: */ 168: int gen7_hwsched_submit_drawobj(struct adreno_device *adreno_dev, 169: struct kgsl_drawobj *drawobj); 170: 171: /** 172: * gen7_hwsched_context_detach - Unregister a context with GMU 173: * @drawctxt: Pointer to the adreno context 174: * 175: * This function sends context unregister HFI and waits for the ack 176: * to ensure all submissions from this context have retired 177: */ 178: void gen7_hwsched_context_detach(struct adreno_context *drawctxt); 179: 180: /* Helper function to get to gen7 hwsched hfi device from adreno device */ MATCH LINES: 206, 216, 219, 224, 237, 245, 248, 257 194: /** 195: * gen7_hwsched_lpac_cp_init - Send CP_INIT to LPAC via HFI 196: * @adreno_dev: Pointer to adreno device structure 197: * 198: * This function is used to send CP INIT packet to LPAC and 199: * enable submission to LPAC queue. 200: * 201: * Return: 0 on success and negative error on failure. 202: */ 203: int gen7_hwsched_lpac_cp_init(struct adreno_device *adreno_dev); 204: 205: /** 206: * gen7_hwsched_hfi_set_value - Send SET_VALUE packet to GMU to set the value of a property 207: * @adreno_dev: Pointer to adreno device 208: * @type: Type of the property to set 209: * @subtype: Sub type of the property to set 210: * @data: Value to be set to the property 211: * 212: * This functions sends SET_VALUE HFI packet to set value of a property 213: * 214: * Return: On success, return 0. On failure, return error code 215: */ 216: int gen7_hwsched_hfi_set_value(struct adreno_device *adreno_dev, u32 type, u32 subtype, u32 data); 217: 218: /** 219: * gen7_hfi_send_lpac_feature_ctrl - Send the lpac feature hfi packet 220: * @adreno_dev: Pointer to the adreno device 221: * 222: * Return: 0 on success or negative error on failure 223: */ 224: int gen7_hfi_send_lpac_feature_ctrl(struct adreno_device *adreno_dev); 225: 226: /** 227: * gen7_hwsched_context_destroy - Destroy any hwsched related resources during context destruction 228: * @adreno_dev: Pointer to adreno device 229: * @drawctxt: Pointer to the adreno context 230: * 231: * This functions destroys any hwsched related resources when this context is destroyed 232: */ 233: void gen7_hwsched_context_destroy(struct adreno_device *adreno_dev, 234: struct adreno_context *drawctxt); 235: 236: /** 237: * gen7_hwsched_hfi_get_value - Send GET_VALUE packet to GMU to get the value of a property 238: * @adreno_dev: Pointer to adreno device 239: * @prop: property to get from GMU 240: * 241: * This functions sends GET_VALUE HFI packet to query value of a property 242: * 243: * Return: On success, return the value in the GMU response. On failure, return 0 244: */ 245: u32 gen7_hwsched_hfi_get_value(struct adreno_device *adreno_dev, u32 prop); 246: 247: /** 248: * gen7_send_hw_fence_hfi_wait_ack - Send hardware fence info to GMU 249: * @adreno_dev: Pointer to adreno device 250: * @entry: Pointer to the adreno hardware fence entry 251: * @flags: Flags for this hardware fence 252: * 253: * Send the hardware fence info to the GMU and wait for the ack 254: * 255: * Return: 0 on success or negative error on failure 256: */ 257: int gen7_send_hw_fence_hfi_wait_ack(struct adreno_device *adreno_dev, 258: struct adreno_hw_fence_entry *entry, u64 flags); 259: 260: /** 261: * gen7_hwsched_create_hw_fence - Create a hardware fence 262: * @adreno_dev: Pointer to adreno device 263: * @kfence: Pointer to the kgsl fence 264: * 265: * Create a hardware fence, set up hardware fence info and send it to GMU if required 266: */ 267: void gen7_hwsched_create_hw_fence(struct adreno_device *adreno_dev, 268: struct kgsl_sync_fence *kfence); 269: 270: /** 271: * gen7_hwsched_check_context_inflight_hw_fences - Check whether all hardware fences 272: * from a context have been sent to the TxQueue or not 273: * @adreno_dev: Pointer to adreno device 274: * @drawctxt: Pointer to the adreno context which is to be flushed 275: * 276: * Check if all hardware fences from this context have been sent to the 277: * TxQueue. If not, log an error and return error code. 278: * 279: * Return: Zero on success or negative error on failure 280: */ 281: int gen7_hwsched_check_context_inflight_hw_fences(struct adreno_device *adreno_dev, --- FILE: \adreno_gen7_perfcounter.c | HITS: 97 --- MATCH LINES: 243, 249, 273, 277, 282, 293, 296, 299, 305, 323, 325 231: } 232: 233: static u64 gen7_counter_alwayson_read(struct adreno_device *adreno_dev, 234: const struct adreno_perfcount_group *group, 235: unsigned int counter) 236: { 237: struct adreno_perfcount_register *reg = &group->regs[counter]; 238: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 239: 240: return gpudev->read_alwayson(adreno_dev) + reg->value; 241: } 242: 243: static void gen7_write_gmu_counter_enable(struct kgsl_device *device, 244: struct adreno_perfcount_register *reg, u32 bit, u32 countable) 245: { 246: kgsl_regrmw(device, reg->select, 0xff << bit, countable << bit); 247: } 248: 249: static int gen7_counter_gmu_xoclk_enable(struct adreno_device *adreno_dev, 250: const struct adreno_perfcount_group *group, 251: unsigned int counter, unsigned int countable) 252: { 253: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 254: struct adreno_perfcount_register *reg = &group->regs[counter]; 255: 256: if (countable > 0xff) 257: return -EINVAL; 258: 259: /* 260: * Counters [0:3] are in select 0 bit offsets 0, 8, 16 and 24 261: * Counters [4:5] are in select 1 bit offset 0, 8 262: * Counters [6:9] are in select 2 bit offset 0, 8, 16 and 24 263: * Counters [10] is in select 3 bit offset 0 264: */ 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); 324: 325: kgsl_regwrite(device, GEN7_GMU_CX_GMU_PERF_COUNTER_ENABLE, 1); 326: 327: reg->value = 0; 328: return 0; 329: } 330: 331: static struct adreno_perfcount_register gen7_perfcounters_cp[] = { 332: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, GEN7_RBBM_PERFCTR_CP_0_LO, 333: GEN7_RBBM_PERFCTR_CP_0_HI, -1, GEN7_CP_PERFCTR_CP_SEL_0 }, 334: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, GEN7_RBBM_PERFCTR_CP_1_LO, 335: GEN7_RBBM_PERFCTR_CP_1_HI, -1, GEN7_CP_PERFCTR_CP_SEL_1 }, 336: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, GEN7_RBBM_PERFCTR_CP_2_LO, 337: GEN7_RBBM_PERFCTR_CP_2_HI, -1, GEN7_CP_PERFCTR_CP_SEL_2 }, 338: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, GEN7_RBBM_PERFCTR_CP_3_LO, 339: GEN7_RBBM_PERFCTR_CP_3_HI, -1, GEN7_CP_PERFCTR_CP_SEL_3 }, 340: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, GEN7_RBBM_PERFCTR_CP_4_LO, 341: GEN7_RBBM_PERFCTR_CP_4_HI, -1, GEN7_CP_PERFCTR_CP_SEL_4 }, 342: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, GEN7_RBBM_PERFCTR_CP_5_LO, 343: GEN7_RBBM_PERFCTR_CP_5_HI, -1, GEN7_CP_PERFCTR_CP_SEL_5 }, 344: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, GEN7_RBBM_PERFCTR_CP_6_LO, 345: GEN7_RBBM_PERFCTR_CP_6_HI, -1, GEN7_CP_PERFCTR_CP_SEL_6 }, 346: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, GEN7_RBBM_PERFCTR_CP_7_LO, 347: GEN7_RBBM_PERFCTR_CP_7_HI, -1, GEN7_CP_PERFCTR_CP_SEL_7 }, 348: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, GEN7_RBBM_PERFCTR_CP_8_LO, 349: GEN7_RBBM_PERFCTR_CP_8_HI, -1, GEN7_CP_PERFCTR_CP_SEL_8 }, MATCH LINES: 929, 933, 937, 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, 978, 979, 980, 981, 982, 983, 984, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005 917: GEN7_GBIF_PERF_CNT_HIGH3, -1, GEN7_GBIF_PERF_CNT_SEL }, 918: }; 919: 920: static struct adreno_perfcount_register gen7_perfcounters_gbif_pwr[] = { 921: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, GEN7_GBIF_PWR_CNT_LOW0, 922: GEN7_GBIF_PWR_CNT_HIGH0, -1, GEN7_GBIF_PERF_PWR_CNT_SEL }, 923: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, GEN7_GBIF_PWR_CNT_LOW1, 924: GEN7_GBIF_PWR_CNT_HIGH1, -1, GEN7_GBIF_PERF_PWR_CNT_SEL }, 925: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, GEN7_GBIF_PWR_CNT_LOW2, 926: GEN7_GBIF_PWR_CNT_HIGH2, -1, GEN7_GBIF_PERF_PWR_CNT_SEL }, 927: }; 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) MATCH LINES: 1070, 1071, 1072, 1073, 1074, 1075 1058: GEN7_PERFCOUNTER_GROUP(TP, tp, gen7_counter_inline_enable, gen7_counter_read), 1059: GEN7_PERFCOUNTER_GROUP(SP, sp, gen7_counter_inline_enable, gen7_counter_read), 1060: GEN7_REGULAR_PERFCOUNTER_GROUP(RB, rb), 1061: GEN7_REGULAR_PERFCOUNTER_GROUP(VSC, vsc), 1062: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, VBIF, gbif, 0, 1063: gen7_counter_gbif_enable, gen7_counter_read_norestore), 1064: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, VBIF_PWR, gbif_pwr, 1065: ADRENO_PERFCOUNTER_GROUP_FIXED, 1066: gen7_counter_gbif_pwr_enable, gen7_counter_read_norestore), 1067: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, ALWAYSON, alwayson, 1068: ADRENO_PERFCOUNTER_GROUP_FIXED, 1069: gen7_counter_alwayson_enable, gen7_counter_alwayson_read), 1070: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, GMU_XOCLK, gmu_xoclk, 0, 1071: gen7_counter_gmu_xoclk_enable, gen7_counter_read_norestore), 1072: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, GMU_GMUCLK, gmu_gmuclk, 0, 1073: gen7_counter_gmu_gmuclk_enable, gen7_counter_read_norestore), 1074: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, GMU_PERF, gmu_perf, 0, 1075: gen7_counter_gmu_perf_enable, gen7_counter_read_norestore), 1076: GEN7_REGULAR_PERFCOUNTER_GROUP(UFC, ufc), 1077: GEN7_BV_REGULAR_PERFCOUNTER_GROUP(CP, cp), 1078: GEN7_BV_PERFCOUNTER_GROUP(PC, pc, gen7_counter_bv_enable, gen7_counter_read), 1079: GEN7_BV_REGULAR_PERFCOUNTER_GROUP(VFD, vfd), 1080: GEN7_BV_PERFCOUNTER_GROUP(VPC, vpc, gen7_counter_bv_enable, gen7_counter_read), 1081: GEN7_BV_REGULAR_PERFCOUNTER_GROUP(TP, tp), 1082: GEN7_BV_REGULAR_PERFCOUNTER_GROUP(SP, sp), 1083: GEN7_BV_REGULAR_PERFCOUNTER_GROUP(UFC, ufc), 1084: GEN7_BV_PERFCOUNTER_GROUP(TSE, tse, gen7_counter_bv_enable, gen7_counter_read), 1085: GEN7_BV_PERFCOUNTER_GROUP(RAS, ras, gen7_counter_bv_enable, gen7_counter_read), 1086: GEN7_BV_PERFCOUNTER_GROUP(LRZ, lrz, gen7_counter_bv_enable, gen7_counter_read), 1087: GEN7_BV_PERFCOUNTER_GROUP(HLSQ, hlsq, gen7_counter_bv_enable, gen7_counter_read), 1088: }; 1089: 1090: static const struct adreno_perfcount_group gen7_9_0_perfcounter_groups 1091: [KGSL_PERFCOUNTER_GROUP_MAX] = { 1092: GEN7_REGULAR_PERFCOUNTER_GROUP(CP, cp), 1093: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, RBBM, rbbm, 0, 1094: gen7_counter_enable, gen7_counter_read), 1095: GEN7_PERFCOUNTER_GROUP(PC, pc, gen7_counter_br_enable, gen7_counter_read), 1096: GEN7_PERFCOUNTER_GROUP(VFD, vfd, gen7_counter_inline_enable, gen7_counter_read), 1097: GEN7_PERFCOUNTER_GROUP(HLSQ, hlsq, gen7_counter_br_enable, gen7_counter_read), 1098: GEN7_PERFCOUNTER_GROUP(VPC, vpc, gen7_counter_br_enable, gen7_counter_read), 1099: GEN7_REGULAR_PERFCOUNTER_GROUP(CCU, ccu), MATCH LINES: 1117, 1118, 1119, 1120, 1121, 1122 1105: GEN7_PERFCOUNTER_GROUP(TP, tp, gen7_counter_inline_enable, gen7_counter_read), 1106: GEN7_PERFCOUNTER_GROUP(SP, sp, gen7_counter_inline_enable, gen7_counter_read), 1107: GEN7_REGULAR_PERFCOUNTER_GROUP(RB, rb), 1108: GEN7_REGULAR_PERFCOUNTER_GROUP(VSC, vsc), 1109: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, VBIF, gbif, 0, 1110: gen7_counter_gbif_enable, gen7_counter_read_norestore), 1111: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, VBIF_PWR, gbif_pwr, 1112: ADRENO_PERFCOUNTER_GROUP_FIXED, 1113: gen7_counter_gbif_pwr_enable, gen7_counter_read_norestore), 1114: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, ALWAYSON, alwayson, 1115: ADRENO_PERFCOUNTER_GROUP_FIXED, 1116: gen7_counter_alwayson_enable, gen7_counter_alwayson_read), 1117: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, GMU_XOCLK, gmu_xoclk, 0, 1118: gen7_counter_gmu_xoclk_enable, gen7_counter_read_norestore), 1119: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, GMU_GMUCLK, gmu_gmuclk, 0, 1120: gen7_counter_gmu_gmuclk_enable, gen7_counter_read_norestore), 1121: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, GMU_PERF, gmu_perf, 0, 1122: gen7_counter_gmu_perf_enable, gen7_counter_read_norestore), 1123: GEN7_REGULAR_PERFCOUNTER_GROUP(UFC, ufc), 1124: GEN7_BV_REGULAR_PERFCOUNTER_GROUP(CP, cp), 1125: GEN7_BV_PERFCOUNTER_GROUP(PC, pc, gen7_counter_bv_enable, gen7_counter_read), 1126: GEN7_BV_REGULAR_PERFCOUNTER_GROUP(VFD, vfd), 1127: GEN7_BV_PERFCOUNTER_GROUP(VPC, vpc, gen7_counter_bv_enable, gen7_counter_read), 1128: GEN7_BV_REGULAR_PERFCOUNTER_GROUP(TP, tp), 1129: GEN7_BV_REGULAR_PERFCOUNTER_GROUP(SP, sp), 1130: GEN7_BV_REGULAR_PERFCOUNTER_GROUP(UFC, ufc), 1131: GEN7_BV_PERFCOUNTER_GROUP(TSE, tse, gen7_counter_bv_enable, gen7_counter_read), 1132: GEN7_BV_PERFCOUNTER_GROUP(RAS, ras, gen7_counter_bv_enable, gen7_counter_read), 1133: GEN7_BV_PERFCOUNTER_GROUP(LRZ, lrz, gen7_counter_bv_enable, gen7_counter_read), 1134: GEN7_BV_PERFCOUNTER_GROUP(HLSQ, hlsq, gen7_counter_bv_enable, gen7_counter_read), 1135: }; 1136: 1137: static const struct adreno_perfcount_group gen7_perfcounter_groups 1138: [KGSL_PERFCOUNTER_GROUP_MAX] = { 1139: GEN7_REGULAR_PERFCOUNTER_GROUP(CP, cp), 1140: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, RBBM, rbbm, 0, 1141: gen7_counter_enable, gen7_counter_read), 1142: GEN7_PERFCOUNTER_GROUP(PC, pc, gen7_counter_br_enable, gen7_counter_read), 1143: GEN7_PERFCOUNTER_GROUP(VFD, vfd, gen7_counter_inline_enable, gen7_counter_read), 1144: GEN7_PERFCOUNTER_GROUP(HLSQ, hlsq, gen7_counter_br_enable, gen7_counter_read), 1145: GEN7_PERFCOUNTER_GROUP(VPC, vpc, gen7_counter_br_enable, gen7_counter_read), 1146: GEN7_REGULAR_PERFCOUNTER_GROUP(CCU, ccu), MATCH LINES: 1164, 1165, 1166, 1167, 1168, 1169 1152: GEN7_PERFCOUNTER_GROUP(TP, tp, gen7_counter_inline_enable, gen7_counter_read), 1153: GEN7_PERFCOUNTER_GROUP(SP, sp, gen7_counter_inline_enable, gen7_counter_read), 1154: GEN7_REGULAR_PERFCOUNTER_GROUP(RB, rb), 1155: GEN7_REGULAR_PERFCOUNTER_GROUP(VSC, vsc), 1156: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, VBIF, gbif, 0, 1157: gen7_counter_gbif_enable, gen7_counter_read_norestore), 1158: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, VBIF_PWR, gbif_pwr, 1159: ADRENO_PERFCOUNTER_GROUP_FIXED, 1160: gen7_counter_gbif_pwr_enable, gen7_counter_read_norestore), 1161: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, ALWAYSON, alwayson, 1162: ADRENO_PERFCOUNTER_GROUP_FIXED, 1163: gen7_counter_alwayson_enable, gen7_counter_alwayson_read), 1164: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, GMU_XOCLK, gmu_xoclk, 0, 1165: gen7_counter_gmu_xoclk_enable, gen7_counter_read_norestore), 1166: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, GMU_GMUCLK, gmu_gmuclk, 0, 1167: gen7_counter_gmu_gmuclk_enable, gen7_counter_read_norestore), 1168: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, GMU_PERF, gmu_perf, 0, 1169: gen7_counter_gmu_perf_enable, gen7_counter_read_norestore), 1170: GEN7_REGULAR_PERFCOUNTER_GROUP(UFC, ufc), 1171: GEN7_BV_REGULAR_PERFCOUNTER_GROUP(CP, cp), 1172: GEN7_BV_PERFCOUNTER_GROUP(PC, pc, gen7_counter_bv_enable, gen7_counter_read), 1173: GEN7_BV_REGULAR_PERFCOUNTER_GROUP(VFD, vfd), 1174: GEN7_BV_PERFCOUNTER_GROUP(VPC, vpc, gen7_counter_bv_enable, gen7_counter_read), 1175: GEN7_BV_REGULAR_PERFCOUNTER_GROUP(TP, tp), 1176: GEN7_BV_REGULAR_PERFCOUNTER_GROUP(SP, sp), 1177: GEN7_BV_REGULAR_PERFCOUNTER_GROUP(UFC, ufc), 1178: GEN7_BV_PERFCOUNTER_GROUP(TSE, tse, gen7_counter_bv_enable, gen7_counter_read), 1179: GEN7_BV_PERFCOUNTER_GROUP(RAS, ras, gen7_counter_bv_enable, gen7_counter_read), 1180: GEN7_BV_PERFCOUNTER_GROUP(LRZ, lrz, gen7_counter_bv_enable, gen7_counter_read), 1181: GEN7_BV_PERFCOUNTER_GROUP(HLSQ, hlsq, gen7_counter_bv_enable, gen7_counter_read), 1182: }; 1183: 1184: /* These perfcounter groups are applicable to gen7 targets with concurrent binning disabled.*/ 1185: static const struct adreno_perfcount_group gen7_no_cb_perfcounter_groups 1186: [KGSL_PERFCOUNTER_GROUP_MAX] = { 1187: GEN7_REGULAR_PERFCOUNTER_GROUP(CP, cp), 1188: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, RBBM, rbbm, 0, 1189: gen7_counter_enable, gen7_counter_read), 1190: GEN7_PERFCOUNTER_GROUP(PC, pc, gen7_counter_enable, gen7_counter_read), 1191: GEN7_PERFCOUNTER_GROUP(VFD, vfd, gen7_counter_inline_enable, gen7_counter_read), 1192: GEN7_PERFCOUNTER_GROUP(HLSQ, hlsq, gen7_counter_enable, gen7_counter_read), 1193: GEN7_PERFCOUNTER_GROUP(VPC, vpc, gen7_counter_enable, gen7_counter_read), MATCH LINES: 1212, 1213, 1214, 1215, 1216, 1217 1200: GEN7_PERFCOUNTER_GROUP(TP, tp, gen7_counter_inline_enable, gen7_counter_read), 1201: GEN7_PERFCOUNTER_GROUP(SP, sp, gen7_counter_inline_enable, gen7_counter_read), 1202: GEN7_REGULAR_PERFCOUNTER_GROUP(RB, rb), 1203: GEN7_REGULAR_PERFCOUNTER_GROUP(VSC, vsc), 1204: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, VBIF, gbif, 0, 1205: gen7_counter_gbif_enable, gen7_counter_read_norestore), 1206: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, VBIF_PWR, gbif_pwr, 1207: ADRENO_PERFCOUNTER_GROUP_FIXED, 1208: gen7_counter_gbif_pwr_enable, gen7_counter_read_norestore), 1209: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, ALWAYSON, alwayson, 1210: ADRENO_PERFCOUNTER_GROUP_FIXED, 1211: gen7_counter_alwayson_enable, gen7_counter_alwayson_read), 1212: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, GMU_XOCLK, gmu_xoclk, 0, 1213: gen7_counter_gmu_xoclk_enable, gen7_counter_read_norestore), 1214: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, GMU_GMUCLK, gmu_gmuclk, 0, 1215: gen7_counter_gmu_gmuclk_enable, gen7_counter_read_norestore), 1216: GEN7_PERFCOUNTER_GROUP_FLAGS(gen7, GMU_PERF, gmu_perf, 0, 1217: gen7_counter_gmu_perf_enable, gen7_counter_read_norestore), 1218: GEN7_REGULAR_PERFCOUNTER_GROUP(UFC, ufc), 1219: }; 1220: 1221: const struct adreno_perfcounters adreno_gen7_perfcounters = { 1222: gen7_perfcounter_groups, 1223: ARRAY_SIZE(gen7_perfcounter_groups), 1224: }; 1225: 1226: const struct adreno_perfcounters adreno_gen7_2_0_perfcounters = { 1227: gen7_2_0_perfcounter_groups, 1228: ARRAY_SIZE(gen7_2_0_perfcounter_groups), 1229: }; 1230: 1231: const struct adreno_perfcounters adreno_gen7_no_cb_perfcounters = { 1232: gen7_no_cb_perfcounter_groups, 1233: ARRAY_SIZE(gen7_no_cb_perfcounter_groups), 1234: }; 1235: 1236: const struct adreno_perfcounters adreno_gen7_9_0_perfcounters = { 1237: gen7_9_0_perfcounter_groups, 1238: ARRAY_SIZE(gen7_9_0_perfcounter_groups), 1239: }; --- FILE: \adreno_gen7_preempt.c | HITS: 10 --- MATCH LINES: 62, 64, 73, 74 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: 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: 286, 287, 311 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: 334: if (gen7_fenced_write(adreno_dev, 335: GEN7_CP_CONTEXT_SWITCH_NON_PRIV_RESTORE_ADDR_LO, MATCH LINES: 384, 386, 388 372: /* Trigger the preemption */ 373: if (gen7_fenced_write(adreno_dev, GEN7_CP_CONTEXT_SWITCH_CNTL, cntl, 374: FENCE_STATUS_WRITEDROPPED1_MASK)) { 375: adreno_dev->next_rb = NULL; 376: kgsl_delete_timer(&adreno_dev->preempt.timer); 377: goto err; 378: } 379: 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: /* --- FILE: \adreno_gen7_ringbuffer.c | HITS: 2 --- MATCH LINES: 206, 208 194: if (adreno_dev->cur_rb == rb) 195: rb->skip_inline_wptr = true; 196: } 197: 198: rb->wptr = rb->_wptr; 199: spin_unlock_irqrestore(&rb->preempt_lock, flags); 200: 201: if (ret) { 202: /* 203: * If WPTR update fails, take inline snapshot and trigger 204: * recovery. 205: */ 206: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE); 207: adreno_scheduler_fault(adreno_dev, 208: ADRENO_GMU_FAULT_SKIP_SNAPSHOT); 209: } 210: 211: return ret; 212: } 213: 214: int gen7_ringbuffer_init(struct adreno_device *adreno_dev) 215: { 216: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 217: int i, ret; 218: 219: ret = adreno_allocate_global(device, &device->scratch, PAGE_SIZE, 220: 0, 0, KGSL_MEMDESC_RANDOM | KGSL_MEMDESC_PRIVILEGED, 221: "scratch"); 222: if (ret) 223: return ret; 224: 225: adreno_dev->cur_rb = &(adreno_dev->ringbuffers[0]); 226: 227: if (!adreno_preemption_feature_set(adreno_dev)) { 228: adreno_dev->num_ringbuffers = 1; 229: return adreno_ringbuffer_setup(adreno_dev, 230: &adreno_dev->ringbuffers[0], 0); 231: } 232: --- FILE: \adreno_gen7_rpmh.c | HITS: 17 --- MATCH LINES: 14, 22, 25, 27, 30, 31, 34, 35, 36, 38, 45, 47, 68 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 "adreno.h" 8: #include "adreno_gen7.h" 9: #include "adreno_rpmh.h" 10: #include "kgsl_bus.h" 11: #include "kgsl_device.h" 12: 13: /* 14: * setup_gmu_arc_votes - Build the gmu voting table 15: * @gmu: Pointer to gmu device 16: * @pri_rail: Pointer to primary power rail vlvl table 17: * @sec_rail: Pointer to second/dependent power rail vlvl table 18: * 19: * This function initializes the cx votes for all gmu frequencies 20: * for gmu dcvs 21: */ 22: static int setup_cx_arc_votes(struct gen7_gmu_device *gmu, 23: struct rpmh_arc_vals *pri_rail, struct rpmh_arc_vals *sec_rail) 24: { 25: struct kgsl_device *device = KGSL_DEVICE(gen7_gmu_to_adreno(gmu)); 26: /* Hardcoded values of GMU CX voltage levels */ 27: u16 gmu_cx_vlvl[MAX_CX_LEVELS_LEGACY]; 28: u32 cx_votes[MAX_CX_LEVELS_LEGACY]; 29: struct gen7_dcvs_table *table = &gmu->dcvs_table; 30: u32 *freqs = device->gmu_core.freqs; 31: u32 *vlvls = device->gmu_core.vlvls; 32: int ret, i; 33: 34: gmu_cx_vlvl[0] = 0; 35: gmu_cx_vlvl[1] = vlvls[0]; 36: gmu_cx_vlvl[2] = vlvls[1]; 37: 38: table->gmu_level_num = 3; 39: 40: table->cx_votes[0].freq = 0; 41: table->cx_votes[1].freq = freqs[0] / 1000; 42: table->cx_votes[2].freq = freqs[1] / 1000; 43: 44: ret = adreno_rpmh_setup_volt_dependency_tbl(cx_votes, pri_rail, 45: sec_rail, gmu_cx_vlvl, table->gmu_level_num); 46: if (!ret) { 47: for (i = 0; i < table->gmu_level_num; i++) 48: table->cx_votes[i].vote = cx_votes[i]; 49: } 50: 51: return ret; 52: } 53: 54: /* 55: * setup_gx_arc_votes - Build the gpu dcvs voting table 56: * @hfi: Pointer to hfi device 57: * @pri_rail: Pointer to primary power rail vlvl table 58: * @sec_rail: Pointer to second/dependent power rail vlvl table 59: * 60: * This function initializes the gx votes for all gpu frequencies 61: * for gpu dcvs 62: */ 63: static int setup_gx_arc_votes(struct adreno_device *adreno_dev, 64: struct rpmh_arc_vals *pri_rail, struct rpmh_arc_vals *sec_rail, 65: struct rpmh_arc_vals *cx_rail) 66: { 67: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 68: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 69: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 70: struct gen7_dcvs_table *table = &gmu->dcvs_table; 71: u32 index; 72: u16 vlvl_tbl[MAX_GX_LEVELS]; 73: u32 gx_votes[MAX_GX_LEVELS]; 74: int ret, i; 75: 76: if (pwr->num_pwrlevels + 1 > ARRAY_SIZE(vlvl_tbl)) { 77: dev_err(device->dev, 78: "Defined more GPU DCVS levels than RPMh can support\n"); 79: return -ERANGE; 80: } 81: 82: /* Add the zero powerlevel for the perf table */ 83: table->gpu_level_num = pwr->num_pwrlevels + 1; 84: 85: memset(vlvl_tbl, 0, sizeof(vlvl_tbl)); 86: 87: table->gx_votes[0].freq = 0; 88: table->gx_votes[0].dep_vote = 0; 89: /* Disable cx vote in gmu dcvs table if it is not supported in DT */ 90: if (pwr->pwrlevels[0].cx_level == 0xffffffff) 91: table->gx_votes[0].dep_vote = 0xffffffff; 92: MATCH LINES: 122, 153, 171, 186 110: sec_rail, vlvl_tbl, table->gpu_level_num); 111: if (!ret) { 112: for (i = 0; i < table->gpu_level_num; i++) 113: table->gx_votes[i].vote = gx_votes[i]; 114: } 115: 116: return ret; 117: 118: } 119: 120: static int build_dcvs_table(struct adreno_device *adreno_dev) 121: { 122: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 123: struct rpmh_arc_vals gx_arc, cx_arc, mx_arc; 124: int ret; 125: 126: ret = adreno_rpmh_arc_cmds(&gx_arc, "gfx.lvl"); 127: if (ret) 128: return ret; 129: 130: ret = adreno_rpmh_arc_cmds(&cx_arc, "cx.lvl"); 131: if (ret) 132: return ret; 133: 134: ret = adreno_rpmh_arc_cmds(&mx_arc, "mx.lvl"); 135: if (ret) 136: return ret; 137: 138: ret = setup_cx_arc_votes(gmu, &cx_arc, &mx_arc); 139: if (ret) 140: return ret; 141: 142: return setup_gx_arc_votes(adreno_dev, &gx_arc, &mx_arc, &cx_arc); 143: } 144: 145: /* Use hardcoded CNOC table when not defined in device tree */ 146: static const u32 default_cnoc_table[] = { 147: 0, /* Off */ 148: 100, /* On */ 149: }; 150: 151: static int build_bw_table(struct adreno_device *adreno_dev) 152: { 153: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 154: const struct adreno_gen7_core *gen7_core = to_gen7_core(adreno_dev); 155: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 156: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 157: struct rpmh_bw_votes *ddr, *cnoc = NULL; 158: u32 perfmode_vote = gen7_core->acv_perfmode_vote; 159: u32 perfmode_lvl = perfmode_vote ? kgsl_pwrctrl_get_acv_perfmode_lvl(device, 160: gen7_core->acv_perfmode_ddr_freq) : 1; 161: u32 *cnoc_table; 162: u32 count = 0; 163: int ret; 164: 165: /* If perfmode vote is not defined, use default value as 0x8 */ 166: if (!perfmode_vote) 167: perfmode_vote = BIT(3); 168: 169: ddr = adreno_rpmh_build_bw_votes(adreno_ddr_bcms, ARRAY_SIZE(adreno_ddr_bcms), 170: pwr->ddr_table, pwr->ddr_table_count, perfmode_vote, perfmode_lvl, 171: adreno_dev->gmu_ab); 172: if (IS_ERR(ddr)) 173: return PTR_ERR(ddr); 174: 175: cnoc_table = kgsl_bus_get_table(device->pdev, "qcom,bus-table-cnoc", 176: &count); 177: 178: /* Use hardcoded CNOC table */ 179: if (!count) { 180: cnoc_table = (u32 *)default_cnoc_table; 181: count = ARRAY_SIZE(default_cnoc_table); 182: } 183: 184: cnoc = adreno_rpmh_build_bw_votes(adreno_cnoc_bcms, 185: ARRAY_SIZE(adreno_cnoc_bcms), cnoc_table, count, 0, 0, 186: adreno_dev->gmu_ab); 187: 188: if (cnoc_table != default_cnoc_table) 189: kfree(cnoc_table); 190: 191: if (IS_ERR(cnoc)) { 192: adreno_rpmh_free_bw_votes(ddr); 193: return PTR_ERR(cnoc); 194: } 195: 196: ret = CMD_MSG_HDR(gmu->hfi.bw_table, H2F_MSG_BW_VOTE_TBL); 197: if (ret) 198: return ret; 199: 200: adreno_rpmh_build_bw_table_cmd(&gmu->hfi.bw_table, ddr, cnoc); 201: 202: adreno_rpmh_free_bw_votes(ddr); 203: adreno_rpmh_free_bw_votes(cnoc); 204: 205: return 0; 206: } 207: 208: int gen7_build_rpmh_tables(struct adreno_device *adreno_dev) 209: { 210: int ret; --- FILE: \adreno_gen7_snapshot.c | HITS: 27 --- MATCH LINES: 39, 40, 65, 66, 91, 92, 117, 118, 119, 120, 145, 146, 171, 172, 195, 196, 221, 222, 247, 248, 249, 274, 275, 276, 301, 302 27: static void __iomem *tmc_virt; 28: 29: const struct gen7_snapshot_block_list gen7_0_0_snapshot_block_list = { 30: .pre_crashdumper_regs = gen7_0_0_pre_crashdumper_gpu_registers, 31: .debugbus_blocks = gen7_0_0_debugbus_blocks, 32: .debugbus_blocks_len = ARRAY_SIZE(gen7_0_0_debugbus_blocks), 33: .gbif_debugbus_blocks = gen7_gbif_debugbus_blocks, 34: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen7_gbif_debugbus_blocks), 35: .cx_debugbus_blocks = gen7_cx_dbgc_debugbus_blocks, 36: .cx_debugbus_blocks_len = ARRAY_SIZE(gen7_cx_dbgc_debugbus_blocks), 37: .external_core_regs = gen7_0_0_external_core_regs, 38: .num_external_core_regs = ARRAY_SIZE(gen7_0_0_external_core_regs), 39: .gmu_regs = gen7_0_0_gmu_registers, 40: .gmu_gx_regs = gen7_0_0_gmugx_registers, 41: .rscc_regs = gen7_0_0_rscc_registers, 42: .reg_list = gen7_0_0_reg_list, 43: .cx_misc_regs = gen7_0_0_cx_misc_registers, 44: .shader_blocks = gen7_0_0_shader_blocks, 45: .num_shader_blocks = ARRAY_SIZE(gen7_0_0_shader_blocks), 46: .clusters = gen7_0_0_clusters, 47: .num_clusters = ARRAY_SIZE(gen7_0_0_clusters), 48: .sptp_clusters = gen7_0_0_sptp_clusters, 49: .num_sptp_clusters = ARRAY_SIZE(gen7_0_0_sptp_clusters), 50: .post_crashdumper_regs = gen7_0_0_post_crashdumper_registers, 51: .index_registers = gen7_cp_indexed_reg_list, 52: .index_registers_len = ARRAY_SIZE(gen7_cp_indexed_reg_list), 53: }; 54: 55: const struct gen7_snapshot_block_list gen7_2_0_snapshot_block_list = { 56: .pre_crashdumper_regs = gen7_0_0_pre_crashdumper_gpu_registers, 57: .debugbus_blocks = gen7_2_0_debugbus_blocks, 58: .debugbus_blocks_len = ARRAY_SIZE(gen7_2_0_debugbus_blocks), 59: .gbif_debugbus_blocks = gen7_gbif_debugbus_blocks, 60: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen7_gbif_debugbus_blocks), 61: .cx_debugbus_blocks = gen7_cx_dbgc_debugbus_blocks, 62: .cx_debugbus_blocks_len = ARRAY_SIZE(gen7_cx_dbgc_debugbus_blocks), 63: .external_core_regs = gen7_2_0_external_core_regs, 64: .num_external_core_regs = ARRAY_SIZE(gen7_2_0_external_core_regs), 65: .gmu_regs = gen7_2_0_gmu_registers, 66: .gmu_gx_regs = gen7_2_0_gmugx_registers, 67: .rscc_regs = gen7_2_0_rscc_registers, 68: .reg_list = gen7_2_0_reg_list, 69: .cx_misc_regs = gen7_0_0_cx_misc_registers, 70: .shader_blocks = gen7_2_0_shader_blocks, 71: .num_shader_blocks = ARRAY_SIZE(gen7_2_0_shader_blocks), 72: .clusters = gen7_2_0_clusters, 73: .num_clusters = ARRAY_SIZE(gen7_2_0_clusters), 74: .sptp_clusters = gen7_2_0_sptp_clusters, 75: .num_sptp_clusters = ARRAY_SIZE(gen7_2_0_sptp_clusters), 76: .post_crashdumper_regs = gen7_0_0_post_crashdumper_registers, 77: .index_registers = gen7_cp_indexed_reg_list, 78: .index_registers_len = ARRAY_SIZE(gen7_cp_indexed_reg_list), 79: }; 80: 81: const struct gen7_snapshot_block_list gen7_3_0_snapshot_block_list = { 82: .pre_crashdumper_regs = gen7_0_0_pre_crashdumper_gpu_registers, 83: .debugbus_blocks = gen7_3_0_debugbus_blocks, 84: .debugbus_blocks_len = ARRAY_SIZE(gen7_3_0_debugbus_blocks), 85: .gbif_debugbus_blocks = gen7_gbif_debugbus_blocks, 86: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen7_gbif_debugbus_blocks), 87: .cx_debugbus_blocks = gen7_cx_dbgc_debugbus_blocks, 88: .cx_debugbus_blocks_len = ARRAY_SIZE(gen7_cx_dbgc_debugbus_blocks), 89: .external_core_regs = gen7_3_0_external_core_regs, 90: .num_external_core_regs = ARRAY_SIZE(gen7_3_0_external_core_regs), 91: .gmu_regs = gen7_3_0_gmu_registers, 92: .gmu_gx_regs = gen7_3_0_gmu_gx_registers, 93: .rscc_regs = gen7_0_0_rscc_registers, 94: .reg_list = gen7_3_0_reg_list, 95: .cx_misc_regs = gen7_0_0_cx_misc_registers, 96: .shader_blocks = gen7_3_0_shader_blocks, 97: .num_shader_blocks = ARRAY_SIZE(gen7_3_0_shader_blocks), 98: .clusters = gen7_3_0_clusters, 99: .num_clusters = ARRAY_SIZE(gen7_3_0_clusters), 100: .sptp_clusters = gen7_3_0_sptp_clusters, 101: .num_sptp_clusters = ARRAY_SIZE(gen7_3_0_sptp_clusters), 102: .post_crashdumper_regs = gen7_0_0_post_crashdumper_registers, 103: .index_registers = gen7_3_0_cp_indexed_reg_list, 104: .index_registers_len = ARRAY_SIZE(gen7_3_0_cp_indexed_reg_list), 105: }; 106: 107: const struct gen7_snapshot_block_list gen7_5_0_snapshot_block_list = { 108: .pre_crashdumper_regs = gen7_0_0_pre_crashdumper_gpu_registers, 109: .debugbus_blocks = gen7_2_0_debugbus_blocks, 110: .debugbus_blocks_len = ARRAY_SIZE(gen7_2_0_debugbus_blocks), 111: .gbif_debugbus_blocks = gen7_gbif_debugbus_blocks, 112: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen7_gbif_debugbus_blocks), 113: .cx_debugbus_blocks = gen7_cx_dbgc_debugbus_blocks, 114: .cx_debugbus_blocks_len = ARRAY_SIZE(gen7_cx_dbgc_debugbus_blocks), 115: .external_core_regs = gen7_5_0_external_core_regs, 116: .num_external_core_regs = ARRAY_SIZE(gen7_5_0_external_core_regs), 117: .gmu_regs = gen7_5_0_gmu_registers, 118: .gmu_ao_regs = gen7_5_0_gmu_ao_registers, 119: .gmu_gx_regs = gen7_5_0_gmugx_registers, 120: .gmu_gx_blk_dec0_dec1_regs = gen7_5_0_gmugx_blk_dec0_dec1_registers, 121: .rscc_regs = gen7_2_0_rscc_registers, 122: .reg_list = gen7_2_0_reg_list, 123: .cx_misc_regs = gen7_0_0_cx_misc_registers, 124: .shader_blocks = gen7_2_0_shader_blocks, 125: .num_shader_blocks = ARRAY_SIZE(gen7_2_0_shader_blocks), 126: .clusters = gen7_2_0_clusters, 127: .num_clusters = ARRAY_SIZE(gen7_2_0_clusters), 128: .sptp_clusters = gen7_2_0_sptp_clusters, 129: .num_sptp_clusters = ARRAY_SIZE(gen7_2_0_sptp_clusters), 130: .post_crashdumper_regs = gen7_0_0_post_crashdumper_registers, 131: .index_registers = gen7_cp_indexed_reg_list, 132: .index_registers_len = ARRAY_SIZE(gen7_cp_indexed_reg_list), 133: }; 134: 135: const struct gen7_snapshot_block_list gen7_6_0_snapshot_block_list = { 136: .pre_crashdumper_regs = gen7_0_0_pre_crashdumper_gpu_registers, 137: .debugbus_blocks = gen7_2_0_debugbus_blocks, 138: .debugbus_blocks_len = ARRAY_SIZE(gen7_2_0_debugbus_blocks), 139: .gbif_debugbus_blocks = gen7_gbif_debugbus_blocks, 140: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen7_gbif_debugbus_blocks), 141: .cx_debugbus_blocks = gen7_cx_dbgc_debugbus_blocks, 142: .cx_debugbus_blocks_len = ARRAY_SIZE(gen7_cx_dbgc_debugbus_blocks), 143: .external_core_regs = gen7_6_0_external_core_regs, 144: .num_external_core_regs = ARRAY_SIZE(gen7_6_0_external_core_regs), 145: .gmu_regs = gen7_2_0_gmu_registers, 146: .gmu_gx_regs = gen7_2_0_gmugx_registers, 147: .rscc_regs = gen7_2_0_rscc_registers, 148: .reg_list = gen7_2_0_reg_list, 149: .cx_misc_regs = gen7_0_0_cx_misc_registers, 150: .shader_blocks = gen7_2_0_shader_blocks, 151: .num_shader_blocks = ARRAY_SIZE(gen7_2_0_shader_blocks), 152: .clusters = gen7_2_0_clusters, 153: .num_clusters = ARRAY_SIZE(gen7_2_0_clusters), 154: .sptp_clusters = gen7_2_0_sptp_clusters, 155: .num_sptp_clusters = ARRAY_SIZE(gen7_2_0_sptp_clusters), 156: .post_crashdumper_regs = gen7_0_0_post_crashdumper_registers, 157: .index_registers = gen7_cp_indexed_reg_list, 158: .index_registers_len = ARRAY_SIZE(gen7_cp_indexed_reg_list), 159: }; 160: 161: const struct gen7_snapshot_block_list gen7_9_0_snapshot_block_list = { 162: .pre_crashdumper_regs = gen7_9_0_pre_crashdumper_gpu_registers, 163: .debugbus_blocks = gen7_9_0_debugbus_blocks, 164: .debugbus_blocks_len = ARRAY_SIZE(gen7_9_0_debugbus_blocks), 165: .gbif_debugbus_blocks = gen7_9_0_gbif_debugbus_blocks, 166: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen7_9_0_gbif_debugbus_blocks), 167: .cx_debugbus_blocks = gen7_9_0_cx_debugbus_blocks, 168: .cx_debugbus_blocks_len = ARRAY_SIZE(gen7_9_0_cx_debugbus_blocks), 169: .external_core_regs = gen7_9_0_external_core_regs, 170: .num_external_core_regs = ARRAY_SIZE(gen7_9_0_external_core_regs), 171: .gmu_regs = gen7_9_0_gmu_registers, 172: .gmu_gx_regs = gen7_9_0_gmugx_registers, 173: .rscc_regs = gen7_9_0_rscc_registers, 174: .reg_list = gen7_9_0_reg_list, 175: .cx_misc_regs = gen7_9_0_cx_misc_registers, 176: .shader_blocks = gen7_9_0_shader_blocks, 177: .num_shader_blocks = ARRAY_SIZE(gen7_9_0_shader_blocks), 178: .clusters = gen7_9_0_clusters, 179: .num_clusters = ARRAY_SIZE(gen7_9_0_clusters), 180: .sptp_clusters = gen7_9_0_sptp_clusters, 181: .num_sptp_clusters = ARRAY_SIZE(gen7_9_0_sptp_clusters), 182: .post_crashdumper_regs = gen7_0_0_post_crashdumper_registers, 183: .index_registers = gen7_9_0_cp_indexed_reg_list, 184: .index_registers_len = ARRAY_SIZE(gen7_9_0_cp_indexed_reg_list), 185: }; 186: 187: const struct gen7_snapshot_block_list gen7_13_0_snapshot_block_list = { 188: .pre_crashdumper_regs = gen7_9_0_pre_crashdumper_gpu_registers, 189: .debugbus_blocks = gen7_9_0_debugbus_blocks, 190: .debugbus_blocks_len = ARRAY_SIZE(gen7_9_0_debugbus_blocks), 191: .gbif_debugbus_blocks = gen7_9_0_gbif_debugbus_blocks, 192: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen7_9_0_gbif_debugbus_blocks), 193: .cx_debugbus_blocks = gen7_9_0_cx_debugbus_blocks, 194: .cx_debugbus_blocks_len = ARRAY_SIZE(gen7_9_0_cx_debugbus_blocks), 195: .gmu_regs = gen7_9_0_gmu_registers, 196: .gmu_gx_regs = gen7_9_0_gmugx_registers, 197: .rscc_regs = gen7_9_0_rscc_registers, 198: .reg_list = gen7_9_0_reg_list, 199: .cx_misc_regs = gen7_9_0_cx_misc_registers, 200: .shader_blocks = gen7_9_0_shader_blocks, 201: .num_shader_blocks = ARRAY_SIZE(gen7_9_0_shader_blocks), 202: .clusters = gen7_9_0_clusters, 203: .num_clusters = ARRAY_SIZE(gen7_9_0_clusters), 204: .sptp_clusters = gen7_9_0_sptp_clusters, 205: .num_sptp_clusters = ARRAY_SIZE(gen7_9_0_sptp_clusters), 206: .post_crashdumper_regs = gen7_0_0_post_crashdumper_registers, 207: .index_registers = gen7_9_0_cp_indexed_reg_list, 208: .index_registers_len = ARRAY_SIZE(gen7_9_0_cp_indexed_reg_list), 209: }; 210: 211: const struct gen7_snapshot_block_list gen7_14_0_snapshot_block_list = { 212: .pre_crashdumper_regs = gen7_9_0_pre_crashdumper_gpu_registers, 213: .debugbus_blocks = gen7_14_0_debugbus_blocks, 214: .debugbus_blocks_len = ARRAY_SIZE(gen7_14_0_debugbus_blocks), 215: .gbif_debugbus_blocks = gen7_gbif_debugbus_blocks, 216: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen7_gbif_debugbus_blocks), 217: .cx_debugbus_blocks = gen7_cx_dbgc_debugbus_blocks, 218: .cx_debugbus_blocks_len = ARRAY_SIZE(gen7_cx_dbgc_debugbus_blocks), 219: .external_core_regs = gen7_14_0_external_core_regs, 220: .num_external_core_regs = ARRAY_SIZE(gen7_14_0_external_core_regs), 221: .gmu_regs = gen7_14_0_gmu_registers, 222: .gmu_gx_regs = gen7_14_0_gmu_gx_registers, 223: .rscc_regs = gen7_14_0_rscc_registers, 224: .reg_list = gen7_14_0_reg_list, 225: .cx_misc_regs = gen7_14_0_cx_misc_registers, 226: .shader_blocks = gen7_14_0_shader_blocks, 227: .num_shader_blocks = ARRAY_SIZE(gen7_14_0_shader_blocks), 228: .clusters = gen7_14_0_clusters, 229: .num_clusters = ARRAY_SIZE(gen7_14_0_clusters), 230: .sptp_clusters = gen7_14_0_sptp_clusters, 231: .num_sptp_clusters = ARRAY_SIZE(gen7_14_0_sptp_clusters), 232: .post_crashdumper_regs = gen7_14_0_post_crashdumper_registers, 233: .index_registers = gen7_14_0_cp_indexed_reg_list, 234: .index_registers_len = ARRAY_SIZE(gen7_14_0_cp_indexed_reg_list), 235: }; 236: 237: const struct gen7_snapshot_block_list gen7_11_0_snapshot_block_list = { 238: .pre_crashdumper_regs = gen7_0_0_pre_crashdumper_gpu_registers, 239: .debugbus_blocks = gen7_11_0_debugbus_blocks, 240: .debugbus_blocks_len = ARRAY_SIZE(gen7_11_0_debugbus_blocks), 241: .gbif_debugbus_blocks = gen7_11_0_gbif_debugbus_blocks, 242: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen7_11_0_gbif_debugbus_blocks), 243: .cx_debugbus_blocks = gen7_11_0_cx_debugbus_blocks, 244: .cx_debugbus_blocks_len = ARRAY_SIZE(gen7_11_0_cx_debugbus_blocks), 245: .external_core_regs = gen7_11_0_external_core_regs, 246: .num_external_core_regs = ARRAY_SIZE(gen7_11_0_external_core_regs), 247: .gmu_regs = gen7_11_0_gmu_registers, 248: .gmu_ao_regs = gen7_11_0_gmu_ao_registers, 249: .gmu_gx_regs = gen7_11_0_gmugx_registers, 250: .rscc_regs = gen7_11_0_rscc_registers, 251: .reg_list = gen7_11_0_reg_list, 252: .cx_misc_regs = gen7_11_0_cx_misc_registers, 253: .shader_blocks = gen7_11_0_shader_blocks, 254: .num_shader_blocks = ARRAY_SIZE(gen7_11_0_shader_blocks), 255: .clusters = gen7_11_0_clusters, 256: .num_clusters = ARRAY_SIZE(gen7_11_0_clusters), 257: .sptp_clusters = gen7_11_0_sptp_clusters, 258: .num_sptp_clusters = ARRAY_SIZE(gen7_11_0_sptp_clusters), 259: .post_crashdumper_regs = gen7_0_0_post_crashdumper_registers, 260: .index_registers = gen7_11_0_cp_indexed_reg_list, 261: .index_registers_len = ARRAY_SIZE(gen7_11_0_cp_indexed_reg_list), 262: }; 263: 264: const struct gen7_snapshot_block_list gen7_15_0_snapshot_block_list = { 265: .pre_crashdumper_regs = gen7_0_0_pre_crashdumper_gpu_registers, 266: .debugbus_blocks = gen7_11_0_debugbus_blocks, 267: .debugbus_blocks_len = ARRAY_SIZE(gen7_11_0_debugbus_blocks), 268: .gbif_debugbus_blocks = gen7_11_0_gbif_debugbus_blocks, 269: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen7_11_0_gbif_debugbus_blocks), 270: .cx_debugbus_blocks = gen7_11_0_cx_debugbus_blocks, 271: .cx_debugbus_blocks_len = ARRAY_SIZE(gen7_11_0_cx_debugbus_blocks), 272: .external_core_regs = gen7_15_0_external_core_regs, 273: .num_external_core_regs = ARRAY_SIZE(gen7_15_0_external_core_regs), 274: .gmu_regs = gen7_11_0_gmu_registers, 275: .gmu_ao_regs = gen7_11_0_gmu_ao_registers, 276: .gmu_gx_regs = gen7_11_0_gmugx_registers, 277: .rscc_regs = gen7_11_0_rscc_registers, 278: .reg_list = gen7_11_0_reg_list, 279: .cx_misc_regs = gen7_11_0_cx_misc_registers, 280: .shader_blocks = gen7_11_0_shader_blocks, 281: .num_shader_blocks = ARRAY_SIZE(gen7_11_0_shader_blocks), 282: .clusters = gen7_11_0_clusters, 283: .num_clusters = ARRAY_SIZE(gen7_11_0_clusters), 284: .sptp_clusters = gen7_11_0_sptp_clusters, 285: .num_sptp_clusters = ARRAY_SIZE(gen7_11_0_sptp_clusters), 286: .post_crashdumper_regs = gen7_0_0_post_crashdumper_registers, 287: .index_registers = gen7_11_0_cp_indexed_reg_list, 288: .index_registers_len = ARRAY_SIZE(gen7_11_0_cp_indexed_reg_list), 289: }; 290: 291: const struct gen7_snapshot_block_list gen7_17_0_snapshot_block_list = { 292: .pre_crashdumper_regs = gen7_9_0_pre_crashdumper_gpu_registers, 293: .debugbus_blocks = gen7_14_0_debugbus_blocks, 294: .debugbus_blocks_len = ARRAY_SIZE(gen7_14_0_debugbus_blocks), 295: .gbif_debugbus_blocks = gen7_gbif_debugbus_blocks, 296: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen7_gbif_debugbus_blocks), 297: .cx_debugbus_blocks = gen7_cx_dbgc_debugbus_blocks, 298: .cx_debugbus_blocks_len = ARRAY_SIZE(gen7_cx_dbgc_debugbus_blocks), 299: .external_core_regs = gen7_17_0_external_core_regs, 300: .num_external_core_regs = ARRAY_SIZE(gen7_17_0_external_core_regs), 301: .gmu_regs = gen7_14_0_gmu_registers, 302: .gmu_gx_regs = gen7_14_0_gmu_gx_registers, 303: .rscc_regs = gen7_17_0_rscc_registers, 304: .reg_list = gen7_14_0_reg_list, 305: .cx_misc_regs = gen7_14_0_cx_misc_registers, 306: .shader_blocks = gen7_14_0_shader_blocks, 307: .num_shader_blocks = ARRAY_SIZE(gen7_14_0_shader_blocks), 308: .clusters = gen7_14_0_clusters, 309: .num_clusters = ARRAY_SIZE(gen7_14_0_clusters), 310: .sptp_clusters = gen7_14_0_sptp_clusters, 311: .num_sptp_clusters = ARRAY_SIZE(gen7_14_0_sptp_clusters), 312: .post_crashdumper_regs = gen7_14_0_post_crashdumper_registers, 313: .index_registers = gen7_14_0_cp_indexed_reg_list, 314: .index_registers_len = ARRAY_SIZE(gen7_14_0_cp_indexed_reg_list), 315: }; 316: 317: #define GEN7_SP_READ_SEL_VAL(_location, _pipe, _statetype, _usptp, _sptp) \ 318: (FIELD_PREP(GENMASK(19, 18), _location) | \ 319: FIELD_PREP(GENMASK(17, 16), _pipe) | \ 320: FIELD_PREP(GENMASK(15, 8), _statetype) | \ 321: FIELD_PREP(GENMASK(7, 4), _usptp) | \ 322: FIELD_PREP(GENMASK(3, 0), _sptp)) 323: 324: #define GEN7_CP_APERTURE_REG_VAL(_pipe, _cluster, _context) \ 325: (FIELD_PREP(GENMASK(13, 12), _pipe) | \ 326: FIELD_PREP(GENMASK(10, 8), _cluster) | \ MATCH LINES: 1765 1753: struct kgsl_snapshot *snapshot) 1754: { 1755: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1756: unsigned int i; 1757: u32 cgc = 0, cgc1 = 0, cgc2 = 0; 1758: const struct adreno_gen7_core *gpucore = to_gen7_core(ADRENO_DEVICE(device)); 1759: int is_current_rt; 1760: 1761: gen7_crashdump_timedout = false; 1762: gen7_snapshot_block_list = gpucore->gen7_snapshot_block_list; 1763: 1764: /* External registers are dumped in the beginning of gmu snapshot */ 1765: if (!gmu_core_isenabled(device)) 1766: gen7_snapshot_external_core_regs(device, snapshot); 1767: 1768: gen7_snapshot_trace_buffer(device, snapshot); 1769: 1770: /* 1771: * Dump debugbus data here to capture it for both 1772: * GMU and GPU snapshot. Debugbus data can be accessed 1773: * even if the gx headswitch is off. If gx 1774: * headswitch is off, data for gx blocks will show as 1775: * 0x5c00bd00. Disable clock gating for SP and TP to capture 1776: * debugbus data. 1777: */ 1778: if (!adreno_is_gen7_9_x(adreno_dev) && device->ftbl->is_hwcg_on(device)) { 1779: kgsl_regread(device, GEN7_RBBM_CLOCK_CNTL2_SP0, &cgc); 1780: kgsl_regread(device, GEN7_RBBM_CLOCK_CNTL_TP0, &cgc1); 1781: kgsl_regread(device, GEN7_RBBM_CLOCK_CNTL3_TP0, &cgc2); 1782: kgsl_regrmw(device, GEN7_RBBM_CLOCK_CNTL2_SP0, GENMASK(22, 20), 0); 1783: kgsl_regrmw(device, GEN7_RBBM_CLOCK_CNTL_TP0, GENMASK(2, 0), 0); 1784: kgsl_regrmw(device, GEN7_RBBM_CLOCK_CNTL3_TP0, GENMASK(14, 12), 0); 1785: } 1786: 1787: gen7_snapshot_debugbus(adreno_dev, snapshot); 1788: 1789: /* Restore the value of the clockgating registers */ --- FILE: \adreno_gen7_snapshot.h | HITS: 11 --- MATCH LINES: 131, 132, 133, 134, 135, 136, 137, 138 119: /* gbif_debugbus_blocks : List of GBIF debugbus blocks */ 120: const u32 *gbif_debugbus_blocks; 121: /* gbif_debugbus_blocks_len : Length of GBIF debugbus list */ 122: size_t gbif_debugbus_blocks_len; 123: /* cx_debugbus_blocks : List of CX debugbus blocks */ 124: const u32 *cx_debugbus_blocks; 125: /* cx_debugbus_blocks_len : Length of the CX debugbus list */ 126: size_t cx_debugbus_blocks_len; 127: /* external_core_regs : List of external core registers */ 128: const u32 **external_core_regs; 129: /* num_external_core_regs : length of external core registers list */ 130: size_t num_external_core_regs; 131: /* gmu_regs : List of GMU registers */ 132: const u32 *gmu_regs; 133: /* gmu_ao_regs : List of GMU registers for ao areas */ 134: const u32 *gmu_ao_regs; 135: /* gmu_gx_regs : List of GMU GX registers */ 136: const u32 *gmu_gx_regs; 137: /* gmu_gx_blk_dec0_dec1_regs : List of GMU GX registers for blk dec0 and dec1 areas*/ 138: const u32 *gmu_gx_blk_dec0_dec1_regs; 139: /* rscc_regs : List of RSCC registers */ 140: const u32 *rscc_regs; 141: /* reg_list : List of GPU internal registers */ 142: struct gen7_reg_list *reg_list; 143: /* reg_list : List of cx_misc registers */ 144: const u32 *cx_misc_regs; 145: /* shader_blocks : List of GPU shader memory */ 146: struct gen7_shader_block *shader_blocks; 147: /* num_shader_blocks : Length of the shader memory list */ 148: size_t num_shader_blocks; 149: /* cluster_registers : List of GPU cluster registers */ 150: struct gen7_cluster_registers *clusters; 151: /* num_clusters : Length of GPU cluster registers list */ 152: size_t num_clusters; 153: /* spstp_cluster_registers : List of GPU SPTP cluster registers */ 154: struct gen7_sptp_cluster_registers *sptp_clusters; 155: /* num_sptp_clusters : Length of GPU SPTP cluster registers list */ 156: size_t num_sptp_clusters; 157: /* post_crashdumper_regs : Registers which need to be dumped after CD runs */ 158: const u32 *post_crashdumper_regs; 159: /* index_registers : List of index_registers */ 160: struct gen7_cp_indexed_reg *index_registers; 161: /* index_registers_len : Length of the index registers */ 162: size_t index_registers_len; MATCH LINES: 200, 203 188: DEBUGBUS_VPC_BR = 25, 189: DEBUGBUS_VPC_BV = 26, 190: DEBUGBUS_TSE_BR = 29, 191: DEBUGBUS_TSE_BV = 30, 192: DEBUGBUS_RAS_BR = 33, 193: DEBUGBUS_RAS_BV = 34, 194: DEBUGBUS_VSC = 37, 195: DEBUGBUS_COM_0 = 39, 196: DEBUGBUS_LRZ_BR = 43, 197: DEBUGBUS_LRZ_BV = 44, 198: DEBUGBUS_UFC_0 = 47, 199: DEBUGBUS_UFC_1 = 48, 200: DEBUGBUS_GMU_GX = 55, 201: DEBUGBUS_DBGC = 59, 202: DEBUGBUS_CX = 60, 203: DEBUGBUS_GMU_CX = 61, 204: DEBUGBUS_GPC_BR = 62, 205: DEBUGBUS_GPC_BV = 63, 206: DEBUGBUS_LARC = 66, 207: DEBUGBUS_HLSQ_SPTP = 68, 208: DEBUGBUS_RB_0 = 70, 209: DEBUGBUS_RB_1 = 71, 210: DEBUGBUS_RB_2 = 72, 211: DEBUGBUS_RB_3 = 73, 212: DEBUGBUS_RB_4 = 74, 213: DEBUGBUS_RB_5 = 75, 214: DEBUGBUS_UCHE_WRAPPER = 102, 215: DEBUGBUS_CCU_0 = 106, 216: DEBUGBUS_CCU_1 = 107, 217: DEBUGBUS_CCU_2 = 108, 218: DEBUGBUS_CCU_3 = 109, 219: DEBUGBUS_CCU_4 = 110, 220: DEBUGBUS_CCU_5 = 111, 221: DEBUGBUS_VFD_BR_0 = 138, 222: DEBUGBUS_VFD_BR_1 = 139, 223: DEBUGBUS_VFD_BR_2 = 140, 224: DEBUGBUS_VFD_BR_3 = 141, 225: DEBUGBUS_VFD_BR_4 = 142, 226: DEBUGBUS_VFD_BR_5 = 143, 227: DEBUGBUS_VFD_BR_6 = 144, MATCH LINES: 288 276: DEBUGBUS_UFC_DSTR_1 = 444, 277: DEBUGBUS_UFC_DSTR_2 = 445, 278: DEBUGBUS_CGC_SUBCORE = 446, 279: DEBUGBUS_CGC_CORE = 447, 280: }; 281: 282: static const u32 gen7_gbif_debugbus_blocks[] = { 283: DEBUGBUS_GBIF_CX, 284: DEBUGBUS_GBIF_GX, 285: }; 286: 287: static const u32 gen7_cx_dbgc_debugbus_blocks[] = { 288: DEBUGBUS_GMU_CX, 289: DEBUGBUS_CX, 290: DEBUGBUS_GBIF_CX, 291: }; 292: 293: enum gen7_statetype_ids { 294: TP0_NCTX_REG = 0, 295: TP0_CTX0_3D_CVS_REG = 1, 296: TP0_CTX0_3D_CPS_REG = 2, 297: TP0_CTX1_3D_CVS_REG = 3, 298: TP0_CTX1_3D_CPS_REG = 4, 299: TP0_CTX2_3D_CPS_REG = 5, 300: TP0_CTX3_3D_CPS_REG = 6, 301: TP0_TMO_DATA = 9, 302: TP0_SMO_DATA = 10, 303: TP0_MIPMAP_BASE_DATA = 11, 304: SP_NCTX_REG = 32, 305: SP_CTX0_3D_CVS_REG = 33, 306: SP_CTX0_3D_CPS_REG = 34, 307: SP_CTX1_3D_CVS_REG = 35, 308: SP_CTX1_3D_CPS_REG = 36, 309: SP_CTX2_3D_CPS_REG = 37, 310: SP_CTX3_3D_CPS_REG = 38, 311: SP_INST_DATA = 39, 312: SP_INST_DATA_1 = 40, --- FILE: \adreno_gen8.c | HITS: 41 --- MATCH LINES: 955, 964, 979 943: { GEN8_SP_L0_PERF_TUNE, BIT(PIPE_NONE), 0, 0, 1, }, 944: { GEN8_SP_DBG_CNTL, BIT(PIPE_NONE), 0, 0, 1, }, 945: { GEN8_TPL1_NC_MODE_CNTL, BIT(PIPE_NONE), 0, 0, 0, }, 946: { GEN8_TPL1_DBG_ECO_CNTL, BIT(PIPE_NONE), 0, 0, 0, }, 947: { GEN8_TPL1_DBG_ECO_CNTL1, BIT(PIPE_NONE), 0, 0, 0, }, 948: { 0 } 949: }; 950: 951: static int acd_calibrate_set(void *data, u64 val) 952: { 953: struct kgsl_device *device = data; 954: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 955: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 956: u32 debug_val = (u32) val; 957: int ret; 958: 959: kgsl_mutex_lock(&device->mutex); 960: ret = adreno_active_count_get(adreno_dev); 961: if (ret) 962: goto err; 963: 964: ret = gen8_hfi_send_set_value(adreno_dev, HFI_VALUE_DBG, 965: F_PWR_ACD_CALIBRATE, debug_val); 966: if (!ret) 967: gmu->acd_debug_val = debug_val; 968: 969: adreno_active_count_put(adreno_dev); 970: err: 971: kgsl_mutex_unlock(&device->mutex); 972: return ret; 973: } 974: 975: static int acd_calibrate_get(void *data, u64 *val) 976: { 977: struct kgsl_device *device = data; 978: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 979: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 980: 981: *val = (u64) gmu->acd_debug_val; 982: 983: return 0; 984: } 985: 986: DEFINE_DEBUGFS_ATTRIBUTE(acd_cal_fops, acd_calibrate_get, acd_calibrate_set, "%llu\n"); 987: 988: static ssize_t nc_override_get(struct file *filep, 989: char __user *user_buf, size_t len, loff_t *off) 990: { 991: struct kgsl_device *device = (struct kgsl_device *) filep->private_data; 992: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 993: struct gen8_device *gen8_dev = container_of(adreno_dev, 994: struct gen8_device, adreno_dev); 995: struct gen8_nonctxt_overrides *nc_overrides = gen8_dev->nc_overrides; 996: u32 i, max_size = PAGE_SIZE; 997: char *buf, *pos; 998: ssize_t size = 0; 999: 1000: if (!gen8_dev->nc_overrides_enabled || !nc_overrides) 1001: return 0; 1002: 1003: buf = kzalloc(max_size, GFP_KERNEL); MATCH LINES: 1160, 1167, 1177, 1183, 1186, 1190, 1196 1148: } 1149: 1150: int gen8_fenced_write(struct adreno_device *adreno_dev, u32 offset, 1151: u32 value, u32 mask) 1152: { 1153: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1154: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 1155: u32 status, i; 1156: u64 ts1, ts2; 1157: 1158: kgsl_regwrite(device, offset, value); 1159: ts1 = gpudev->read_alwayson(adreno_dev); 1160: for (i = 0; i < GMU_CORE_LONG_WAKEUP_RETRY_LIMIT; i++) { 1161: /* 1162: * Make sure the previous register write is posted before 1163: * checking the fence status 1164: */ 1165: mb(); 1166: 1167: gmu_core_regread(device, GEN8_GMUAO_AHB_FENCE_STATUS, &status); 1168: 1169: /* 1170: * If !writedropped0/1, then the write to fenced register 1171: * was successful 1172: */ 1173: if (!(status & mask)) 1174: break; 1175: 1176: /* Wait a small amount of time before trying again */ 1177: udelay(GMU_CORE_WAKEUP_DELAY_US); 1178: 1179: /* Try to write the fenced register again */ 1180: kgsl_regwrite(device, offset, value); 1181: } 1182: 1183: if (i < GMU_CORE_SHORT_WAKEUP_RETRY_LIMIT) 1184: return 0; 1185: 1186: if (i == GMU_CORE_LONG_WAKEUP_RETRY_LIMIT) { 1187: ts2 = gpudev->read_alwayson(adreno_dev); 1188: dev_err(device->dev, 1189: "Timed out waiting %d usecs to write fenced register 0x%x, timestamps: %llx %llx\n", 1190: i * GMU_CORE_WAKEUP_DELAY_US, offset, ts1, ts2); 1191: return -ETIMEDOUT; 1192: } 1193: 1194: dev_info(device->dev, 1195: "Waited %d usecs to write fenced register 0x%x\n", 1196: i * GMU_CORE_WAKEUP_DELAY_US, offset); 1197: 1198: return 0; 1199: } 1200: 1201: #define MIN_HBB 13 1202: 1203: static void gen8_calc_ubwc_config_legacy(struct adreno_device *adreno_dev) 1204: { 1205: struct adreno_ubwc_props *ubwc_props = &adreno_dev->ubwc_props; 1206: 1207: switch (adreno_dev->ubwc_mode) { 1208: case KGSL_UBWC_6_0: 1209: ubwc_props->yuvnotcomptofc = true; 1210: ubwc_props->mode2 = 5; 1211: break; 1212: case KGSL_UBWC_5_0: 1213: ubwc_props->amsbc = true; 1214: ubwc_props->rgb565_predicator = true; 1215: ubwc_props->mode2 = 4; 1216: break; 1217: case KGSL_UBWC_4_0: 1218: ubwc_props->amsbc = true; 1219: ubwc_props->rgb565_predicator = true; 1220: ubwc_props->fp16compoptdis = true; MATCH LINES: 1690 1678: 1679: /* 1680: * Increase clock keep-on hysteresis from 5 cycles to 8 cycles 1681: * for adreno_is_gen8_0_x_family. 1682: */ 1683: if ((adreno_is_gen8_0_x_family(adreno_dev)) && on) 1684: kgsl_regwrite(device, GEN8_RBBM_CGC_0_PC, 0x00000702); 1685: 1686: if (!adreno_dev->hwcg_enabled) 1687: on = false; 1688: 1689: for (i = 0; i < gen8_core->ao_hwcg_count; i++) 1690: gmu_core_regwrite(device, gen8_core->ao_hwcg[i].offset, 1691: on ? gen8_core->ao_hwcg[i].val : 0); 1692: 1693: kgsl_regwrite(device, GEN8_RBBM_CLOCK_CNTL_GLOBAL, 1); 1694: kgsl_regwrite(device, GEN8_RBBM_CGC_GLOBAL_LOAD_CMD, on ? 1 : 0); 1695: 1696: if (on) { 1697: u32 retry = 3; 1698: 1699: kgsl_regwrite(device, GEN8_RBBM_CGC_P2S_TRIG_CMD, 1); 1700: /* Poll for the TXDONE:BIT(0) status */ 1701: do { 1702: /* Wait for small amount of time for TXDONE status*/ 1703: udelay(1); 1704: kgsl_regread(device, GEN8_RBBM_CGC_P2S_STATUS, &value); 1705: } while (!(value & BIT(0)) && --retry); 1706: 1707: if (!(value & BIT(0))) { 1708: dev_err(device->dev, "RBBM_CGC_P2S_STATUS:TXDONE Poll failed\n"); 1709: kgsl_device_snapshot(device, NULL, NULL, false); 1710: return; 1711: } 1712: kgsl_regwrite(device, GEN8_RBBM_CLOCK_CNTL_GLOBAL, 0); 1713: } else { 1714: /* MATCH LINES: 2049 2037: 2038: void gen8_enable_ahb_timeout_detection(struct adreno_device *adreno_dev) 2039: { 2040: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2041: u32 val; 2042: 2043: if (!adreno_dev->ahb_timeout_val) 2044: return; 2045: 2046: val = (ADRENO_AHB_CNTL_DEFAULT | FIELD_PREP(GENMASK(4, 0), 2047: adreno_dev->ahb_timeout_val)); 2048: kgsl_regwrite(device, GEN8_GPU_CX_MISC_CX_AHB_AON_CNTL, val); 2049: kgsl_regwrite(device, GEN8_GPU_CX_MISC_CX_AHB_GMU_CNTL, val); 2050: kgsl_regwrite(device, GEN8_GPU_CX_MISC_CX_AHB_CP_CNTL, val); 2051: kgsl_regwrite(device, GEN8_GPU_CX_MISC_CX_AHB_VBIF_SMMU_CNTL, val); 2052: kgsl_regwrite(device, GEN8_GPU_CX_MISC_CX_AHB_HOST_CNTL, val); 2053: } 2054: 2055: int gen8_start(struct adreno_device *adreno_dev) 2056: { 2057: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2058: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev); 2059: u32 pipe_id; 2060: struct adreno_ubwc_props *ubwc_props = &adreno_dev->ubwc_props; 2061: u32 mal = adreno_dev->mal; 2062: 2063: struct gen8_device *gen8_dev = container_of(adreno_dev, 2064: struct gen8_device, adreno_dev); 2065: /* 2066: * HBB values 13 to 16 can represented LSB of HBB from 0 to 3. 2067: * Any HBB value beyond 16 needs programming MSB of HBB. 2068: * By default highest bank bit is 14, Hence set default HBB LSB 2069: * to "1" and MSB to "0". 2070: */ 2071: u32 hbb_lo = 1, hbb_hi = 0, hbb = 1; 2072: struct cpu_gpu_lock *pwrup_lock = adreno_dev->pwrup_reglist->hostptr; 2073: u64 uche_trap_base = gen8_get_uche_trap_base(); MATCH LINES: 2198 2186: FIELD_PREP(GENMASK(2, 1), hbb_lo)); 2187: 2188: /* Configure TP bicubic registers */ 2189: kgsl_regmap_multi_write(&device->regmap, gen8_0_0_bicubic_regs, 2190: ARRAY_SIZE(gen8_0_0_bicubic_regs)); 2191: 2192: kgsl_regwrite(device, GEN8_UCHE_CLIENT_PF, BIT(7) | 2193: FIELD_PREP(GENMASK(6, 0), adreno_dev->uche_client_pf)); 2194: 2195: /* Program noncontext registers */ 2196: gen8_nonctxt_regconfig(adreno_dev); 2197: 2198: /* Read GPU registers with the GMU OOB set to update adreno props */ 2199: gen8_setup_adreno_props(adreno_dev); 2200: 2201: /* Enable hardware hang detection */ 2202: kgsl_regwrite(device, GEN8_RBBM_INTERFACE_HANG_INT_CNTL, BIT(30) | 2203: FIELD_PREP(GENMASK(27, 0), gen8_core->hang_detect_cycles)); 2204: kgsl_regwrite(device, GEN8_RBBM_SLICE_INTERFACE_HANG_INT_CNTL, BIT(30)); 2205: 2206: /* Enable the GMEM save/restore feature for preemption */ 2207: if (adreno_is_preemption_enabled(adreno_dev)) { 2208: gen8_regwrite_aperture(device, 2209: GEN8_RB_CONTEXT_SWITCH_GMEM_SAVE_RESTORE, 2210: 0x1, PIPE_BR, 0, 0); 2211: /* Clear aperture register */ 2212: gen8_host_aperture_set(adreno_dev, 0, 0, 0); 2213: } 2214: 2215: /* Enable GMU power counter 0 to count GPU busy */ 2216: kgsl_regwrite(device, GEN8_GMUAO_GPU_CX_BUSY_MASK, 0xff000000); 2217: kgsl_regrmw(device, GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_0, 0xFF, 0x20); 2218: kgsl_regwrite(device, GEN8_GMUCX_POWER_COUNTER_ENABLE, 0x1); 2219: 2220: gen8_protect_init(adreno_dev); 2221: 2222: /* Configure LLCC */ MATCH LINES: 2573, 2582 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); 2599: u32 hw_status; 2600: u32 pipe_id = PIPE_NONE; 2601: const char * const table[] = { 2602: [CP_HW_RBFAULT] = "RBFAULT", 2603: [CP_HW_IB1FAULT] = "IB1FAULT", 2604: [CP_HW_IB2FAULT] = "IB2FAULT", 2605: [CP_HW_SDSFAULT] = "SDSFAULT", 2606: [CP_HW_MRBFAULT] = "MRGFAULT", MATCH LINES: 2803, 2827, 2836 2791: static const char *const uche_client[] = { 2792: "BR_VFD", "BR_SP", "BR_VSC", "BR_VPC", 2793: "BR_HLSQ", "BR_PC", "BR_LRZ", "BR_TP", 2794: "BV_VFD", "BV_SP", "BV_VSC", "BV_VPC", 2795: "BV_HLSQ", "BV_PC", "BV_LRZ", "BV_TP", 2796: "STCHE", 2797: }; 2798: 2799: static const char *const uche_lpac_client[] = { 2800: "-", "SP_LPAC", "-", "-", "HLSQ_LPAC", "-", "-", "TP_LPAC" 2801: }; 2802: 2803: #define SCOOBYDOO 0x5c00bd00 2804: 2805: static const char *gen8_fault_block_uche(struct kgsl_device *device, 2806: char *str, int size, bool lpac) 2807: { 2808: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 2809: u32 uche_client_id = adreno_dev->uche_client_pf; 2810: const char *uche_client_str, *fault_block; 2811: 2812: /* 2813: * Smmu driver takes a vote on CX gdsc before calling the kgsl 2814: * pagefault handler. If there is contention for device mutex in this 2815: * path and the dispatcher fault handler is holding this lock, trying 2816: * to turn off CX gdsc will fail during the reset. So to avoid blocking 2817: * here, try to lock device mutex and return if it fails. 2818: */ 2819: if (!kgsl_mutex_trylock(&device->mutex)) 2820: goto regread_fail; 2821: 2822: if (!kgsl_state_is_awake(device)) { 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: 2860: fail: MATCH LINES: 3009 2997: ADRENO_IRQ_CALLBACK(NULL), /* 12 - CP_CCU_RESOLVE_TS */ 2998: ADRENO_IRQ_CALLBACK(NULL), /* 13 - UNUSED */ 2999: ADRENO_IRQ_CALLBACK(NULL), /* 14 - UNUSED */ 3000: ADRENO_IRQ_CALLBACK(adreno_cp_callback), /* 15 - CP_RB_INT */ 3001: ADRENO_IRQ_CALLBACK(NULL), /* 16 - CP_RB_INT_LPAC*/ 3002: ADRENO_IRQ_CALLBACK(NULL), /* 17 - CP_RB_DONE_TS */ 3003: ADRENO_IRQ_CALLBACK(NULL), /* 18 - UNUSED */ 3004: ADRENO_IRQ_CALLBACK(NULL), /* 19 - UNUSED */ 3005: ADRENO_IRQ_CALLBACK(gen8_cp_callback), /* 20 - CP_CACHE_FLUSH_TS */ 3006: ADRENO_IRQ_CALLBACK(NULL), /* 21 - CP_CACHE_TS_LPAC */ 3007: ADRENO_IRQ_CALLBACK(gen8_err_callback), /* 22 - RBBM_ATB_BUS_OVERFLOW */ 3008: ADRENO_IRQ_CALLBACK(adreno_hang_int_callback), /* 23 - MISHANGDETECT */ 3009: ADRENO_IRQ_CALLBACK(gen8_err_callback), /* 24 - UCHE_OOB_ACCESS */ 3010: ADRENO_IRQ_CALLBACK(gen8_err_callback), /* 25 - UCHE_TRAP_INTR */ 3011: ADRENO_IRQ_CALLBACK(gen8_dbgc_intr_callback), /* 26 - DEBUG_BUS_INTR_0 */ 3012: ADRENO_IRQ_CALLBACK(gen8_dbgc_intr_callback), /* 27 - DEBUG_BUS_INTR_1 */ 3013: ADRENO_IRQ_CALLBACK(gen8_err_callback), /* 28 - TSBWRITEERROR */ 3014: ADRENO_IRQ_CALLBACK(gen8_swfuse_violation_callback), /* 29 - SWFUSEVIOLATION */ 3015: ADRENO_IRQ_CALLBACK(NULL), /* 30 - ISDB_CPU_IRQ */ 3016: ADRENO_IRQ_CALLBACK(NULL), /* 31 - ISDB_UNDER_DEBUG */ 3017: }; 3018: 3019: /* 3020: * If the AHB fence is not in ALLOW mode when we receive an RBBM 3021: * interrupt, something went wrong. This means that we cannot proceed 3022: * since the IRQ status and clear registers are not accessible. 3023: * This is usually harmless because the GMU will abort power collapse 3024: * and change the fence back to ALLOW. Poll so that this can happen. 3025: */ 3026: static int gen8_irq_poll_fence(struct adreno_device *adreno_dev) 3027: { 3028: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 3029: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 3030: u32 status, fence, fence_retries = 0; 3031: u64 a, b, c; 3032: 3033: a = gpudev->read_alwayson(adreno_dev); MATCH LINES: 3105 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: MATCH LINES: 3214, 3216 3202: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_RPTR, GEN8_CP_RB_RPTR_BR), 3203: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_WPTR, GEN8_CP_RB_WPTR_GC), 3204: ADRENO_REG_DEFINE(ADRENO_REG_CP_ME_CNTL, GEN8_CP_SQE_CNTL), 3205: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BASE, GEN8_CP_IB1_BASE_LO_PIPE), 3206: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BASE_HI, GEN8_CP_IB1_BASE_HI_PIPE), 3207: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BUFSZ, GEN8_CP_IB1_REM_SIZE_PIPE), 3208: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BASE, GEN8_CP_IB2_BASE_LO_PIPE), 3209: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BASE_HI, GEN8_CP_IB2_BASE_HI_PIPE), 3210: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BUFSZ, GEN8_CP_IB2_REM_SIZE_PIPE), 3211: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_STATUS, GEN8_RBBM_STATUS), 3212: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_INT_0_MASK, GEN8_RBBM_INT_0_MASK), 3213: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_SW_RESET_CMD, GEN8_RBBM_SW_RESET_CMD), 3214: ADRENO_REG_DEFINE(ADRENO_REG_GMU_AO_HOST_INTERRUPT_MASK, 3215: GEN8_GMUAO_AO_HOST_INTERRUPT_MASK), 3216: ADRENO_REG_DEFINE(ADRENO_REG_GMU_GMU2HOST_INTR_MASK, 3217: GEN8_GMUCX_GMU2HOST_INTR_MASK), 3218: }; 3219: 3220: static u32 _get_pipeid(u32 groupid) 3221: { 3222: switch (groupid) { 3223: case KGSL_PERFCOUNTER_GROUP_BV_PC: 3224: fallthrough; 3225: case KGSL_PERFCOUNTER_GROUP_BV_VFD: 3226: fallthrough; 3227: case KGSL_PERFCOUNTER_GROUP_BV_VPC: 3228: fallthrough; 3229: case KGSL_PERFCOUNTER_GROUP_BV_TSE: 3230: fallthrough; 3231: case KGSL_PERFCOUNTER_GROUP_BV_RAS: 3232: fallthrough; 3233: case KGSL_PERFCOUNTER_GROUP_BV_LRZ: 3234: fallthrough; 3235: case KGSL_PERFCOUNTER_GROUP_BV_HLSQ: 3236: return PIPE_BV; 3237: case KGSL_PERFCOUNTER_GROUP_PC: 3238: fallthrough; 3239: case KGSL_PERFCOUNTER_GROUP_VFD: 3240: fallthrough; MATCH LINES: 3497, 3498, 3501, 3504 3485: 3486: err: 3487: ADRENO_RELEASE_CP_SEMAPHORE(adreno_dev, irq_flags); 3488: return ret; 3489: } 3490: 3491: static u64 gen8_read_alwayson(struct adreno_device *adreno_dev) 3492: { 3493: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 3494: u32 lo = 0, hi = 0, tmp = 0; 3495: 3496: /* Always use the GMU AO counter when doing a AHB read */ 3497: gmu_core_regread(device, GEN8_GMUCX_AO_COUNTER_HI, &hi); 3498: gmu_core_regread(device, GEN8_GMUCX_AO_COUNTER_LO, &lo); 3499: 3500: /* Check for overflow */ 3501: gmu_core_regread(device, GEN8_GMUCX_AO_COUNTER_HI, &tmp); 3502: 3503: if (hi != tmp) { 3504: gmu_core_regread(device, GEN8_GMUCX_AO_COUNTER_LO, 3505: &lo); 3506: hi = tmp; 3507: } 3508: 3509: return (((u64) hi) << 32) | lo; 3510: } 3511: 3512: static int gen8_lpac_store(struct adreno_device *adreno_dev, bool enable) 3513: { 3514: if (!ADRENO_FEATURE(adreno_dev, ADRENO_LPAC)) 3515: return -EINVAL; 3516: 3517: if (!(adreno_dev->feature_fuse & BIT(GEN8_LPAC_SW_FUSE)) || 3518: (adreno_dev->lpac_enabled == enable)) 3519: return 0; 3520: 3521: /* Power down the GPU before changing the lpac setting */ 3522: return adreno_power_cycle_bool(adreno_dev, &adreno_dev->lpac_enabled, enable); 3523: } 3524: 3525: static void gen8_remove(struct adreno_device *adreno_dev) 3526: { 3527: if (adreno_preemption_feature_set(adreno_dev)) 3528: kgsl_delete_timer(&adreno_dev->preempt.timer); MATCH LINES: 3707, 3712 3695: u32 status = 0, rptr = 0, wptr = 0, ib1sz = 0, ib2sz = 0, ib3sz = 0; 3696: u64 ib1base = 0, ib2base = 0, ib3base = 0; 3697: bool gx_on = adreno_gx_is_on(adreno_dev); 3698: 3699: drawctxt = ADRENO_CONTEXT(drawobj->context); 3700: drawobj->context->last_faulted_cmd_ts = drawobj->timestamp; 3701: drawobj->context->total_fault_count++; 3702: 3703: pr_context(device, drawobj->context, 3704: "LPAC ctx %u ctx_type %s ts %u policy %lX dispatch_queue=%d\n", 3705: drawobj->context->id, kgsl_context_type(drawctxt->type), 3706: drawobj->timestamp, CMDOBJ(drawobj)->fault_recovery, 3707: drawobj->context->gmu_dispatch_queue); 3708: 3709: pr_context(device, drawobj->context, "lpac cmdline: %s\n", 3710: drawctxt->base.proc_priv->cmdline); 3711: 3712: if (!gen8_gmu_rpmh_pwr_state_is_active(device) || !gx_on) 3713: goto done; 3714: 3715: kgsl_regread(device, GEN8_RBBM_LPAC_STATUS, &status); 3716: kgsl_regread(device, GEN8_CP_RB_RPTR_LPAC, &rptr); 3717: kgsl_regread(device, GEN8_CP_RB_WPTR_LPAC, &wptr); 3718: gen8_periph_regread64(device, GEN8_CP_PERIPH_IB1_BASE_LO, 3719: GEN8_CP_PERIPH_IB1_BASE_HI, &ib1base, PIPE_LPAC); 3720: gen8_periph_regread(device, GEN8_CP_PERIPH_IB1_OFFSET, &ib1sz, PIPE_LPAC); 3721: gen8_periph_regread64(device, GEN8_CP_PERIPH_IB2_BASE_LO, 3722: GEN8_CP_PERIPH_IB2_BASE_HI, &ib2base, PIPE_LPAC); 3723: gen8_periph_regread(device, GEN8_CP_PERIPH_IB2_OFFSET, &ib2sz, PIPE_LPAC); 3724: gen8_periph_regread64(device, GEN8_CP_PERIPH_IB3_BASE_LO, 3725: GEN8_CP_PERIPH_IB3_BASE_HI, &ib3base, PIPE_LPAC); 3726: gen8_periph_regread(device, GEN8_CP_PERIPH_IB3_OFFSET, &ib3sz, PIPE_LPAC); 3727: gen8_host_aperture_set(adreno_dev, 0, 0, 0); 3728: 3729: pr_context(device, drawobj->context, 3730: "LPAC: status %8.8X rb %4.4x/%4.4x ib1 %16.16llX/%4.4x ib2 %16.16llX/%4.4x ib3 %16.16llX/%4.4x\n", 3731: status, rptr, wptr, ib1base, ib1sz, ib2base, ib2sz, ib3base, ib3sz); 3732: 3733: done: 3734: trace_adreno_gpu_fault(drawobj->context->id, drawobj->timestamp, status, 3735: rptr, wptr, ib1base, ib1sz, ib2base, ib2sz, 3736: adreno_get_level(drawobj->context)); MATCH LINES: 3768 3756: ctxt_id = drawobj->context->id; 3757: ts = drawobj->timestamp; 3758: rb_id = adreno_get_level(drawobj->context); 3759: 3760: pr_context(device, drawobj->context, "ctx %u ctx_type %s ts %u policy %lX\n", 3761: drawobj->context->id, kgsl_context_type(drawctxt->type), 3762: drawobj->timestamp, CMDOBJ(drawobj)->fault_recovery); 3763: 3764: pr_context(device, drawobj->context, "cmdline: %s\n", 3765: drawctxt->base.proc_priv->cmdline); 3766: } 3767: 3768: if (!gen8_gmu_rpmh_pwr_state_is_active(device) || !gx_on) 3769: goto done; 3770: 3771: kgsl_regread(device, GEN8_RBBM_STATUS, &status); 3772: kgsl_regread(device, GEN8_RBBM_GFX_STATUS, &gfx_status); 3773: kgsl_regread(device, GEN8_RBBM_GFX_BV_STATUS, &gfx_bv_status); 3774: kgsl_regread(device, GEN8_RBBM_GFX_BR_STATUS, &gfx_br_status); 3775: kgsl_regread(device, GEN8_CP_RB_RPTR_BR, &rptr); 3776: kgsl_regread(device, GEN8_CP_RB_WPTR_GC, &wptr); 3777: kgsl_regread(device, GEN8_CP_RB_RPTR_BV, &rptr_bv); 3778: gen8_periph_regread64(device, GEN8_CP_PERIPH_IB1_BASE_LO, 3779: GEN8_CP_PERIPH_IB1_BASE_HI, &ib1base, PIPE_BR); 3780: gen8_periph_regread(device, GEN8_CP_PERIPH_IB1_OFFSET, &ib1sz, PIPE_BR); 3781: gen8_periph_regread64(device, GEN8_CP_PERIPH_IB2_BASE_LO, 3782: GEN8_CP_PERIPH_IB2_BASE_HI, &ib2base, PIPE_BR); 3783: gen8_periph_regread(device, GEN8_CP_PERIPH_IB2_OFFSET, &ib2sz, PIPE_BR); 3784: gen8_periph_regread64(device, GEN8_CP_PERIPH_IB3_BASE_LO, 3785: GEN8_CP_PERIPH_IB3_BASE_HI, &ib3base, PIPE_BR); 3786: gen8_periph_regread(device, GEN8_CP_PERIPH_IB3_OFFSET, &ib3sz, PIPE_BR); 3787: gen8_periph_regread64(device, GEN8_CP_PERIPH_IB1_BASE_LO, 3788: GEN8_CP_PERIPH_IB1_BASE_HI, &ib1base_bv, PIPE_BV); 3789: gen8_periph_regread(device, GEN8_CP_PERIPH_IB1_OFFSET, &ib1sz_bv, PIPE_BV); 3790: gen8_periph_regread64(device, GEN8_CP_PERIPH_IB2_BASE_LO, 3791: GEN8_CP_PERIPH_IB2_BASE_HI, &ib2base_bv, PIPE_BV); 3792: gen8_periph_regread(device, GEN8_CP_PERIPH_IB2_OFFSET, &ib2sz_bv, PIPE_BV); MATCH LINES: 3861, 3876, 3877, 3881, 3884, 3885, 3891, 3894, 3898, 3899, 3910, 3911 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: 16 --- MATCH LINES: 30, 37, 38, 42, 68 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; 82: /** @nc_overrides_enabled: Set through debugfs path when any override is enabled */ 83: bool nc_overrides_enabled; 84: /** @slice_mask: The bitmask of active GPU slices */ 85: u32 slice_mask; 86: /** @tsense_work: Work struct for TSENSE suspend in parallel with GPU suspend */ 87: struct work_struct tsense_work; 88: }; 89: 90: /** 91: * struct gen8_pwrup_extlist - container for a powerup external reglist 92: */ MATCH LINES: 134, 154, 165, 166, 196, 197, 226, 227, 228 122: u32 offset; 123: /** @val: Value to write */ 124: u32 val; 125: /** @pipelines: pipelines to write */ 126: u32 pipelines; 127: }; 128: 129: /** 130: * struct gen8_limits_mit_cfg - Container for GPU limits mitigation configuration 131: */ 132: struct gen8_limits_mit_cfg { 133: /** @limits_mit_tbl: Table for GPU limits mitigation features */ 134: const struct hfi_limits_mit_tbl *limits_mit_tbl; 135: /** @len: Number of entries in the table */ 136: u32 len; 137: }; 138: 139: /** 140: * struct therm_tsens_en_cfg - Container for thermal tsense configuration 141: */ 142: struct therm_tsens_en_cfg { 143: /** @tsens_sl_cnt: Temperature sensor count per GPU slice */ 144: u32 tsens_sl_cnt; 145: /** @tsens_us_cnt: Temperature sensor count per GPU unslice */ 146: u32 tsens_us_cnt; 147: }; 148: 149: /** 150: * struct gen8_thermal_mit_cfg - Container for GPU thermal mitigation configuration 151: */ 152: struct gen8_thermal_mit_cfg { 153: /** @therm: Config for GPU thermal mitigation features */ 154: struct hfi_therm_profile_ctrl *therm; 155: /** @tsens_en_cfg: Config for GPU thermal mitigation features */ 156: const struct therm_tsens_en_cfg *tsens_en_cfg; 157: }; 158: 159: /** 160: * struct adreno_gen8_core - gen8 specific GPU core definitions 161: */ 162: struct adreno_gen8_core { 163: /** @base: Container for the generic GPU definitions */ 164: struct adreno_gpu_core base; 165: /** @gmu_fw_version: Minimum firmware version required to support this core */ 166: u32 gmu_fw_version; 167: /** @sqefw_name: Name of the SQE microcode file */ 168: const char *sqefw_name; 169: /** @aqefw_name: Name of the AQE microcode file */ 170: const char *aqefw_name; 171: /** @gmufw_name: Name of the GMU firmware file */ 172: const char *gmufw_name; 173: /** 174: * @zap_name: Specifies the name of the CPZ zap file. This field is deprecated. 175: * Use the 'firmware-name' device tree property instead. 176: */ 177: const char *zap_name; 178: /** @ao_hwcg: List of registers and values to write for HWCG in AO block */ 179: const struct kgsl_regmap_list *ao_hwcg; 180: /** @ao_hwcg_count: Number of registers in @ao_hwcg */ 181: u32 ao_hwcg_count; 182: /** @gbif: List of registers and values to write for GBIF */ 183: const struct kgsl_regmap_list *gbif; 184: /** @gbif_count: Number of registers in @gbif */ 185: u32 gbif_count; 186: /** @hang_detect_cycles: Hang detect counter timeout value */ 187: u32 hang_detect_cycles; 188: /** @protected_regs: Array of protected registers for the target */ 189: const struct gen8_protected_regs *protected_regs; 190: /** @nonctxt_regs: Array of non context register list */ 191: const struct gen8_nonctxt_regs *nonctxt_regs; 192: /** @ctxt_record_size: Size of the preemption record in bytes */ 193: u64 ctxt_record_size; 194: /** @gen8_snapshot_block_list: Device-specific blocks dumped in the snapshot */ 195: const struct gen8_snapshot_block_list *gen8_snapshot_block_list; 196: /** @gmu_hub_clk_freq: Gmu hub interface clock frequency */ 197: u64 gmu_hub_clk_freq; 198: /** 199: * @bcl_data: bit 0 contains response type for bcl alarms and bits 1:21 controls sid vals 200: * to configure throttle levels for bcl alarm levels 0-2. If sid vals are not set, 201: * gmu fw sets default throttle levels. 202: */ 203: u32 bcl_data; 204: /** @preempt_level: Preemption level valid ranges [0 to 2] */ 205: u32 preempt_level; 206: /** @qos_value: GPU qos value to set for each RB. */ 207: const u32 *qos_value; 208: /** 209: * @acv_perfmode_ddr_freq: Vote perfmode when DDR frequency >= acv_perfmode_ddr_freq. 210: * If not specified, vote perfmode for highest DDR level only. 211: */ 212: u32 acv_perfmode_ddr_freq; 213: /** @rt_bus_hint: IB level hint for real time clients i.e. RB-0 */ 214: const u32 rt_bus_hint; 215: /** @fast_bus_hint: Whether or not to increase IB vote on high ddr stall */ 216: bool fast_bus_hint; 217: /** @noc_timeout_us: GPU config NOC port timeout in usec */ 218: u32 noc_timeout_us; 219: /** @cl_no_ft_timeout_ms: Use this timeout for CL NO_FT instead of infinite */ 220: u32 cl_no_ft_timeout_ms; 221: /** @therm_profile: GMU thermal mitigation profile */ 222: struct gen8_thermal_mit_cfg *therm_cfg; 223: /** @limits_mit_cfg: GPU limits mitigation configuration */ 224: const struct gen8_limits_mit_cfg *limits_mit_cfg; 225: /** @clx_tbl: GPU CLX table */ 226: const struct hfi_clx_table_v2_cmd *clx_tbl; 227: /** @gmu_mx_gdsc: This target has separate MX GDSC for the GMU */ 228: bool gmu_mx_gdsc; 229: /** @three_rail_memory: This target has BX rail in addition to GX and MX */ 230: bool three_rail_memory; 231: /** @malu: This target has MALU */ 232: bool malu; 233: }; 234: 235: /** 236: * struct gen8_cp_preemption_record - CP context record for 237: * preemption. 238: * @magic: (00) Value at this offset must be equal to 239: * GEN8_CP_CTXRECORD_MAGIC_REF. 240: * @info: (04) Type of record. Written non-zero (usually) by CP. 241: * we must set to zero for all ringbuffers. 242: * @errno: (08) Error code. Initialize this to GEN8_CP_CTXRECORD_ERROR_NONE. 243: * CP will update to another value if a preemption error occurs. 244: * @data: (12) DATA field in YIELD and SET_MARKER packets. 245: * Written by CP when switching out. Not used on switch-in. Initialized to 0. 246: * @cntl: (16) RB_CNTL, saved and restored by CP. We must initialize this. 247: * @rptr: (20) RB_RPTR, saved and restored by CP. We must initialize this. 248: * @wptr: (24) RB_WPTR, saved and restored by CP. We must initialize this. 249: * @_pad28: (28) Reserved/padding. 250: * @rptr_addr: (32) RB_RPTR_ADDR_LO|HI saved and restored. We must initialize. 251: * rbase: (40) RB_BASE_LO|HI saved and restored. 252: * counter: (48) Pointer to preemption counter. MATCH LINES: 569, 574 557: struct adreno_ringbuffer *rb, struct adreno_context *drawctxt, 558: u32 flags, u32 *in, u32 dwords, u32 timestamp, 559: struct adreno_submit_time *time); 560: 561: /** 562: * gen8_cp_init_cmds - Create the CP_INIT commands 563: * @adreno_dev: An Adreno GPU handle 564: * @cmd: Buffer to write the CP_INIT commands into 565: */ 566: void gen8_cp_init_cmds(struct adreno_device *adreno_dev, u32 *cmds); 567: 568: /** 569: * gen8_gmu_hfi_probe - Probe Gen8 HFI specific data 570: * @adreno_dev: An Adreno GPU handle 571: * 572: * Return: 0 on success or negative on failure 573: */ 574: int gen8_gmu_hfi_probe(struct adreno_device *adreno_dev); 575: 576: static inline const struct gen8_gpudev * 577: to_gen8_gpudev(const struct adreno_gpudev *gpudev) 578: { 579: return container_of(gpudev, struct gen8_gpudev, base); 580: } 581: 582: /** 583: * gen8_reset_preempt_records - Reset the preemption buffers 584: * @adreno_dev: Handle to the adreno device 585: * 586: * Reset the preemption records at the time of hard reset 587: */ 588: void gen8_reset_preempt_records(struct adreno_device *adreno_dev); 589: 590: /** 591: * gen8_scm_gpu_init_cx_regs - Program gpu regs for feature support 592: * @adreno_dev: Handle to the adreno device 593: * 594: * Program gpu regs for feature support. Scm call for the same 595: * is added from kernel version 6.0 onwards. 596: * 597: * Return: 0 on success or negative on failure 598: */ --- FILE: \adreno_gen8_0_0_snapshot.h | HITS: 3 --- MATCH LINES: 222 210: 0x005a0, 0x005b3, 0x005c0, 0x005c0, 0x005c2, 0x005c6, 0x005e0, 0x005e3, 211: 0x005ec, 0x005ec, 0x00f01, 0x00f02, 0x00f04, 0x00f0c, 0x00f20, 0x00f37, 212: UINT_MAX, UINT_MAX, 213: }; 214: static_assert(IS_ALIGNED(sizeof(gen8_0_0_gpu_slice_registers), 8)); 215: 216: /* 217: * Block : ['GMUAO', 'GMUCX', 'GMUCX_RAM'] 218: * REGION : UNSLICE 219: * Pipeline: PIPE_NONE 220: * pairs : 161 (Regs:614) 221: */ 222: static const u32 gen8_0_0_gmu_registers[] = { 223: 0x10001, 0x10001, 0x10003, 0x10003, 0x10401, 0x10401, 0x10403, 0x10403, 224: 0x10801, 0x10801, 0x10803, 0x10803, 0x10c01, 0x10c01, 0x10c03, 0x10c03, 225: 0x11001, 0x11001, 0x11003, 0x11003, 0x11401, 0x11401, 0x11403, 0x11403, 226: 0x11801, 0x11801, 0x11803, 0x11803, 0x11c01, 0x11c01, 0x11c03, 0x11c03, 227: 0x1f400, 0x1f40b, 0x1f40f, 0x1f411, 0x1f500, 0x1f500, 0x1f507, 0x1f507, 228: 0x1f509, 0x1f50b, 0x1f700, 0x1f701, 0x1f704, 0x1f706, 0x1f708, 0x1f709, 229: 0x1f70c, 0x1f70d, 0x1f710, 0x1f711, 0x1f713, 0x1f716, 0x1f718, 0x1f71d, 230: 0x1f720, 0x1f725, 0x1f729, 0x1f729, 0x1f730, 0x1f747, 0x1f750, 0x1f75a, 231: 0x1f75c, 0x1f75c, 0x1f780, 0x1f781, 0x1f784, 0x1f78b, 0x1f790, 0x1f797, 232: 0x1f7a0, 0x1f7a7, 0x1f7b0, 0x1f7b7, 0x1f7e0, 0x1f7e1, 0x1f7e4, 0x1f7e5, 233: 0x1f7e8, 0x1f7e9, 0x1f7ec, 0x1f7ed, 0x1f800, 0x1f804, 0x1f807, 0x1f808, 234: 0x1f80b, 0x1f80c, 0x1f80f, 0x1f80f, 0x1f811, 0x1f811, 0x1f813, 0x1f817, 235: 0x1f819, 0x1f81c, 0x1f824, 0x1f830, 0x1f840, 0x1f842, 0x1f848, 0x1f848, 236: 0x1f84c, 0x1f84c, 0x1f850, 0x1f850, 0x1f858, 0x1f859, 0x1f868, 0x1f869, 237: 0x1f878, 0x1f883, 0x1f930, 0x1f931, 0x1f934, 0x1f935, 0x1f938, 0x1f939, 238: 0x1f93c, 0x1f93d, 0x1f940, 0x1f941, 0x1f943, 0x1f943, 0x1f948, 0x1f94a, 239: 0x1f94f, 0x1f951, 0x1f954, 0x1f955, 0x1f95d, 0x1f95d, 0x1f962, 0x1f96b, 240: 0x1f970, 0x1f970, 0x1f97c, 0x1f97e, 0x1f980, 0x1f981, 0x1f984, 0x1f986, 241: 0x1f992, 0x1f993, 0x1f996, 0x1f99e, 0x1f9c0, 0x1f9cf, 0x1f9f0, 0x1f9f1, 242: 0x1f9f8, 0x1f9fa, 0x1f9fc, 0x1f9fc, 0x1fa00, 0x1fa03, 0x1fc00, 0x1fc01, 243: 0x1fc04, 0x1fc07, 0x1fc10, 0x1fc10, 0x1fc14, 0x1fc14, 0x1fc18, 0x1fc19, 244: 0x1fc20, 0x1fc20, 0x1fc24, 0x1fc26, 0x1fc30, 0x1fc33, 0x1fc38, 0x1fc3b, 245: 0x1fc40, 0x1fc49, 0x1fc50, 0x1fc59, 0x1fc60, 0x1fc7f, 0x1fca0, 0x1fcef, 246: 0x20000, 0x20007, 0x20010, 0x20015, 0x20018, 0x2001a, 0x2001c, 0x2001d, MATCH LINES: 264 252: 0x20370, 0x20377, 0x23801, 0x23801, 0x23803, 0x23803, 0x23805, 0x23805, 253: 0x23807, 0x23807, 0x23809, 0x23809, 0x2380b, 0x2380b, 0x2380d, 0x2380d, 254: 0x2380f, 0x2380f, 0x23811, 0x23811, 0x23813, 0x23813, 0x23815, 0x23815, 255: 0x23817, 0x23817, 0x23819, 0x23819, 0x2381b, 0x2381b, 0x2381d, 0x2381d, 256: 0x2381f, 0x23820, 0x23822, 0x23822, 0x23824, 0x23824, 0x23826, 0x23826, 257: 0x23828, 0x23828, 0x2382a, 0x2382a, 0x2382c, 0x2382c, 0x2382e, 0x2382e, 258: 0x23830, 0x23830, 0x23832, 0x23832, 0x23834, 0x23834, 0x23836, 0x23836, 259: 0x23838, 0x23838, 0x2383a, 0x2383a, 0x2383c, 0x2383c, 0x2383e, 0x2383e, 260: 0x23840, 0x23847, 0x23b00, 0x23b01, 0x23b03, 0x23b03, 0x23b05, 0x23b0e, 261: 0x23b10, 0x23b13, 0x23b15, 0x23b16, 0x23b28, 0x23b28, 0x23b30, 0x23b30, 262: UINT_MAX, UINT_MAX, 263: }; 264: static_assert(IS_ALIGNED(sizeof(gen8_0_0_gmu_registers), 8)); 265: 266: /* 267: * Block : ['GMUGX'] 268: * REGION : UNSLICE 269: * Pipeline: PIPE_NONE 270: * pairs : 15 (Regs:174) 271: */ 272: static const u32 gen8_0_0_gmugx_registers[] = { 273: 0x0dc00, 0x0dc0d, 0x0dc10, 0x0dc11, 0x0dc13, 0x0dc15, 0x0dc18, 0x0dc1a, 274: 0x0dc1c, 0x0dc2f, 0x0dc40, 0x0dc42, 0x0dc60, 0x0dc7f, 0x0dc88, 0x0dc90, 275: 0x0dc98, 0x0dc99, 0x0dca0, 0x0dcbf, 0x0dcc8, 0x0dcd0, 0x0dcd8, 0x0dcd9, 276: 0x0dce0, 0x0dcff, 0x0dd08, 0x0dd10, 0x0dd18, 0x0dd19, 277: UINT_MAX, UINT_MAX, 278: }; 279: static_assert(IS_ALIGNED(sizeof(gen8_0_0_gmugx_registers), 8)); 280: 281: /* 282: * Block : ['GMUGX'] 283: * REGION : SLICE 284: * Pipeline: PIPE_NONE 285: * pairs : 23 (Regs:312) 286: */ 287: static const u32 gen8_0_0_gmugx_slice_registers[] = { 288: 0x0e400, 0x0e401, 0x0e404, 0x0e40a, 0x0e40e, 0x0e42f, 0x0e438, 0x0e440, MATCH LINES: 2079 2067: }; 2068: static_assert(IS_ALIGNED(sizeof(gen8_0_0_cpr_registers), 8)); 2069: 2070: static const u32 *gen8_0_0_external_core_regs[] = { 2071: gen8_0_0_gdpm_lkg_registers, 2072: gen8_0_0_gpu_cc_ahb2phy_broadcast_swman_registers, 2073: gen8_0_0_gpu_cc_ahb2phy_swman_registers, 2074: gen8_0_0_gpu_cc_gpu_cc_reg_registers, 2075: gen8_0_0_gpu_cc_pll0_cm_pll_taycan_common_registers, 2076: gen8_0_0_cpr_registers, 2077: }; 2078: 2079: static struct gen8_reg_list gen8_gmu_gx_registers[] = { 2080: { UNSLICE, gen8_0_0_gmugx_registers }, 2081: { UNSLICE, gen8_0_0_gx_clkctl_ahb2phy_broadcast_swman_registers }, 2082: { UNSLICE, gen8_0_0_gx_clkctl_ahb2phy_swman_registers }, 2083: { UNSLICE, gen8_0_0_gx_clkctl_pll0_cm_pll_taycan_common_registers }, 2084: { UNSLICE, gen8_0_0_gx_clkctl_gx_clkctl_reg_registers }, 2085: { UNSLICE, gen8_0_0_acd_acd_mnd_registers }, 2086: { SLICE, gen8_0_0_gmugx_slice_registers }, 2087: }; 2088: 2089: #endif /*_ADRENO_GEN8_0_0_SNAPSHOT_H */ --- FILE: \adreno_gen8_10_0_snapshot.h | HITS: 4 --- MATCH LINES: 19 7: #define __ADRENO_GEN8_10_0_SNAPSHOT_H 8: 9: #include "adreno_gen8_snapshot.h" 10: 11: /* 12: * Debugbus blocks for gen8_10_0. 13: * Same as gen8_1_0_debugbus_blocks but with Slice 3 (S_3) entries removed. 14: * gen8_10_0 has 3 GPU slices (S_0 through S_2) vs gen8_1_0's 4 slices. 15: */ 16: static const u32 gen8_10_0_debugbus_blocks[] = { 17: /* GBIF_GX block */ 18: DEBUGBUS_GBIF_GX_GC_US_I_0, 19: DEBUGBUS_GMU_GX_GC_US_I_0, 20: DEBUGBUS_DBGC_GC_US_I_0, 21: DEBUGBUS_RBBM_GC_US_I_0, 22: DEBUGBUS_LARC_GC_US_I_0, 23: DEBUGBUS_COM_GC_US_I_0, 24: DEBUGBUS_HLSQ_GC_US_I_0, 25: DEBUGBUS_CGC_GC_US_I_0, 26: DEBUGBUS_VSC_GC_US_I_0_0, 27: DEBUGBUS_VSC_GC_US_I_0_1, 28: DEBUGBUS_UFC_GC_US_I_0, 29: DEBUGBUS_UFC_GC_US_I_1, 30: DEBUGBUS_CP_GC_US_I_0_0, 31: DEBUGBUS_CP_GC_US_I_0_1, 32: DEBUGBUS_CP_GC_US_I_0_2, 33: DEBUGBUS_PC_BR_US_I_0, 34: DEBUGBUS_PC_BV_US_I_0, 35: DEBUGBUS_GPC_BR_US_I_0, 36: DEBUGBUS_GPC_BV_US_I_0, 37: DEBUGBUS_VPC_BR_US_I_0, 38: DEBUGBUS_VPC_BV_US_I_0, 39: DEBUGBUS_UCHE_WRAPPER_GC_US_I_0, 40: DEBUGBUS_UCHE_GC_US_I_0, 41: DEBUGBUS_UCHE_GC_US_I_1, 42: DEBUGBUS_UCHE_GC_US_I_0_1, 43: DEBUGBUS_UCHE_GC_US_I_1_1, MATCH LINES: 67 55: DEBUGBUS_GPC_BR_S_0_I_0, 56: DEBUGBUS_GPC_BV_S_0_I_0, 57: DEBUGBUS_VPCFE_BR_S_0_I_0, 58: DEBUGBUS_VPCFE_BV_S_0_I_0, 59: DEBUGBUS_VPCBE_BR_S_0_I_0, 60: DEBUGBUS_VPCBE_BV_S_0_I_0, 61: DEBUGBUS_CCHE_GC_S_0_I_0, 62: DEBUGBUS_DBGC_GC_S_0_I_0, 63: DEBUGBUS_LARC_GC_S_0_I_0, 64: DEBUGBUS_RBBM_GC_S_0_I_0, 65: DEBUGBUS_CCRE_GC_S_0_I_0, 66: DEBUGBUS_CGC_GC_S_0_I_0, 67: DEBUGBUS_GMU_GC_S_0_I_0, 68: DEBUGBUS_SLICE_GC_S_0_I_0, 69: DEBUGBUS_HLSQ_SPTP_STAR_GC_S_0_I_0, 70: DEBUGBUS_USP_GC_S_0_I_0, 71: DEBUGBUS_USP_GC_S_0_I_1, 72: DEBUGBUS_USPTP_GC_S_0_I_0, 73: DEBUGBUS_USPTP_GC_S_0_I_1, 74: DEBUGBUS_USPTP_GC_S_0_I_2, 75: DEBUGBUS_USPTP_GC_S_0_I_3, 76: DEBUGBUS_TP_GC_S_0_I_0, 77: DEBUGBUS_TP_GC_S_0_I_1, 78: DEBUGBUS_TP_GC_S_0_I_2, 79: DEBUGBUS_TP_GC_S_0_I_3, 80: DEBUGBUS_RB_GC_S_0_I_0, 81: DEBUGBUS_RB_GC_S_0_I_1, 82: DEBUGBUS_CCU_GC_S_0_I_0, 83: DEBUGBUS_CCU_GC_S_0_I_1, 84: DEBUGBUS_HLSQ_GC_S_0_I_0, 85: DEBUGBUS_HLSQ_GC_S_0_I_1, 86: DEBUGBUS_VFD_GC_S_0_I_0, 87: DEBUGBUS_VFD_GC_S_0_I_1, 88: /* Slice 1 */ 89: DEBUGBUS_CP_GC_S_1_I_0, 90: DEBUGBUS_PC_BR_S_1_I_0, 91: DEBUGBUS_PC_BV_S_1_I_0, MATCH LINES: 111 99: DEBUGBUS_GPC_BR_S_1_I_0, 100: DEBUGBUS_GPC_BV_S_1_I_0, 101: DEBUGBUS_VPCFE_BR_S_1_I_0, 102: DEBUGBUS_VPCFE_BV_S_1_I_0, 103: DEBUGBUS_VPCBE_BR_S_1_I_0, 104: DEBUGBUS_VPCBE_BV_S_1_I_0, 105: DEBUGBUS_CCHE_GC_S_1_I_0, 106: DEBUGBUS_DBGC_GC_S_1_I_0, 107: DEBUGBUS_LARC_GC_S_1_I_0, 108: DEBUGBUS_RBBM_GC_S_1_I_0, 109: DEBUGBUS_CCRE_GC_S_1_I_0, 110: DEBUGBUS_CGC_GC_S_1_I_0, 111: DEBUGBUS_GMU_GC_S_1_I_0, 112: DEBUGBUS_SLICE_GC_S_1_I_0, 113: DEBUGBUS_HLSQ_SPTP_STAR_GC_S_1_I_0, 114: DEBUGBUS_USP_GC_S_1_I_0, 115: DEBUGBUS_USP_GC_S_1_I_1, 116: DEBUGBUS_USPTP_GC_S_1_I_0, 117: DEBUGBUS_USPTP_GC_S_1_I_1, 118: DEBUGBUS_USPTP_GC_S_1_I_2, 119: DEBUGBUS_USPTP_GC_S_1_I_3, 120: DEBUGBUS_TP_GC_S_1_I_0, 121: DEBUGBUS_TP_GC_S_1_I_1, 122: DEBUGBUS_TP_GC_S_1_I_2, 123: DEBUGBUS_TP_GC_S_1_I_3, 124: DEBUGBUS_RB_GC_S_1_I_0, 125: DEBUGBUS_RB_GC_S_1_I_1, 126: DEBUGBUS_CCU_GC_S_1_I_0, 127: DEBUGBUS_CCU_GC_S_1_I_1, 128: DEBUGBUS_HLSQ_GC_S_1_I_0, 129: DEBUGBUS_HLSQ_GC_S_1_I_1, 130: DEBUGBUS_VFD_GC_S_1_I_0, 131: DEBUGBUS_VFD_GC_S_1_I_1, 132: /* Slice 2 */ 133: DEBUGBUS_CP_GC_S_2_I_0, 134: DEBUGBUS_PC_BR_S_2_I_0, 135: DEBUGBUS_PC_BV_S_2_I_0, MATCH LINES: 155 143: DEBUGBUS_GPC_BR_S_2_I_0, 144: DEBUGBUS_GPC_BV_S_2_I_0, 145: DEBUGBUS_VPCFE_BR_S_2_I_0, 146: DEBUGBUS_VPCFE_BV_S_2_I_0, 147: DEBUGBUS_VPCBE_BR_S_2_I_0, 148: DEBUGBUS_VPCBE_BV_S_2_I_0, 149: DEBUGBUS_CCHE_GC_S_2_I_0, 150: DEBUGBUS_DBGC_GC_S_2_I_0, 151: DEBUGBUS_LARC_GC_S_2_I_0, 152: DEBUGBUS_RBBM_GC_S_2_I_0, 153: DEBUGBUS_CCRE_GC_S_2_I_0, 154: DEBUGBUS_CGC_GC_S_2_I_0, 155: DEBUGBUS_GMU_GC_S_2_I_0, 156: DEBUGBUS_SLICE_GC_S_2_I_0, 157: DEBUGBUS_HLSQ_SPTP_STAR_GC_S_2_I_0, 158: DEBUGBUS_USP_GC_S_2_I_0, 159: DEBUGBUS_USP_GC_S_2_I_1, 160: DEBUGBUS_USPTP_GC_S_2_I_0, 161: DEBUGBUS_USPTP_GC_S_2_I_1, 162: DEBUGBUS_USPTP_GC_S_2_I_2, 163: DEBUGBUS_USPTP_GC_S_2_I_3, 164: DEBUGBUS_TP_GC_S_2_I_0, 165: DEBUGBUS_TP_GC_S_2_I_1, 166: DEBUGBUS_TP_GC_S_2_I_2, 167: DEBUGBUS_TP_GC_S_2_I_3, 168: DEBUGBUS_RB_GC_S_2_I_0, 169: DEBUGBUS_RB_GC_S_2_I_1, 170: DEBUGBUS_CCU_GC_S_2_I_0, 171: DEBUGBUS_CCU_GC_S_2_I_1, 172: DEBUGBUS_HLSQ_GC_S_2_I_0, 173: DEBUGBUS_HLSQ_GC_S_2_I_1, 174: DEBUGBUS_VFD_GC_S_2_I_0, 175: DEBUGBUS_VFD_GC_S_2_I_1, 176: }; 177: 178: #endif /* __ADRENO_GEN8_10_0_SNAPSHOT_H */ --- FILE: \adreno_gen8_11_0_snapshot.h | HITS: 10 --- MATCH LINES: 11 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 4: */ 5: #ifndef __ADRENO_GEN8_11_0_SNAPSHOT_H 6: #define __ADRENO_GEN8_11_0_SNAPSHOT_H 7: 8: #include "adreno_gen8_snapshot.h" 9: 10: static const u32 gen8_11_0_debugbus_blocks[] = { 11: DEBUGBUS_GMU_GX_GC_US_I_0, 12: DEBUGBUS_DBGC_GC_US_I_0, 13: DEBUGBUS_RBBM_GC_US_I_0, 14: DEBUGBUS_LARC_GC_US_I_0, 15: DEBUGBUS_COM_GC_US_I_0, 16: DEBUGBUS_HLSQ_GC_US_I_0, 17: DEBUGBUS_CGC_GC_US_I_0, 18: DEBUGBUS_VSC_GC_US_I_0_0, 19: DEBUGBUS_VSC_GC_US_I_0_1, 20: DEBUGBUS_UFC_GC_US_I_0, 21: DEBUGBUS_UFC_GC_US_I_1, 22: DEBUGBUS_CP_GC_US_I_0_0, 23: DEBUGBUS_CP_GC_US_I_0_1, 24: DEBUGBUS_CP_GC_US_I_0_2, 25: DEBUGBUS_PC_BR_US_I_0, 26: DEBUGBUS_PC_BV_US_I_0, 27: DEBUGBUS_GPC_BR_US_I_0, 28: DEBUGBUS_GPC_BV_US_I_0, 29: DEBUGBUS_VPC_BR_US_I_0, 30: DEBUGBUS_VPC_BV_US_I_0, 31: DEBUGBUS_UCHE_WRAPPER_GC_US_I_0, 32: DEBUGBUS_UCHE_GC_US_I_0, 33: DEBUGBUS_UCHE_GC_US_I_1, 34: DEBUGBUS_UCHE_GC_US_I_0_1, 35: DEBUGBUS_UCHE_GC_US_I_1_1, MATCH LINES: 58 46: DEBUGBUS_GPC_BR_S_0_I_0, 47: DEBUGBUS_GPC_BV_S_0_I_0, 48: DEBUGBUS_VPCFE_BR_S_0_I_0, 49: DEBUGBUS_VPCFE_BV_S_0_I_0, 50: DEBUGBUS_VPCBE_BR_S_0_I_0, 51: DEBUGBUS_VPCBE_BV_S_0_I_0, 52: DEBUGBUS_CCHE_GC_S_0_I_0, 53: DEBUGBUS_DBGC_GC_S_0_I_0, 54: DEBUGBUS_LARC_GC_S_0_I_0, 55: DEBUGBUS_RBBM_GC_S_0_I_0, 56: DEBUGBUS_CCRE_GC_S_0_I_0, 57: DEBUGBUS_CGC_GC_S_0_I_0, 58: DEBUGBUS_GMU_GC_S_0_I_0, 59: DEBUGBUS_SLICE_GC_S_0_I_0, 60: DEBUGBUS_HLSQ_SPTP_STAR_GC_S_0_I_0, 61: DEBUGBUS_SLICE_HM1_S_0_I_0, 62: DEBUGBUS_SLICE_HM1_S_0_I_1, 63: DEBUGBUS_USP_GC_S_0_I_0, 64: DEBUGBUS_USP_GC_S_0_I_1, 65: DEBUGBUS_USPTP_GC_S_0_I_0, 66: DEBUGBUS_USPTP_GC_S_0_I_1, 67: DEBUGBUS_USPTP_GC_S_0_I_2, 68: DEBUGBUS_USPTP_GC_S_0_I_3, 69: DEBUGBUS_TP_GC_S_0_I_0, 70: DEBUGBUS_TP_GC_S_0_I_1, 71: DEBUGBUS_TP_GC_S_0_I_2, 72: DEBUGBUS_TP_GC_S_0_I_3, 73: DEBUGBUS_RB_GC_S_0_I_0, 74: DEBUGBUS_RB_GC_S_0_I_1, 75: DEBUGBUS_CCU_GC_S_0_I_0, 76: DEBUGBUS_CCU_GC_S_0_I_1, 77: DEBUGBUS_HLSQ_GC_S_0_I_0, 78: DEBUGBUS_HLSQ_GC_S_0_I_1, 79: DEBUGBUS_VFD_GC_S_0_I_0, 80: DEBUGBUS_VFD_GC_S_0_I_1, 81: DEBUGBUS_NSP_S_0_I_0, 82: DEBUGBUS_NSP_S_0_I_1, MATCH LINES: 115 103: DEBUGBUS_GPC_BR_S_1_I_0, 104: DEBUGBUS_GPC_BV_S_1_I_0, 105: DEBUGBUS_VPCFE_BR_S_1_I_0, 106: DEBUGBUS_VPCFE_BV_S_1_I_0, 107: DEBUGBUS_VPCBE_BR_S_1_I_0, 108: DEBUGBUS_VPCBE_BV_S_1_I_0, 109: DEBUGBUS_CCHE_GC_S_1_I_0, 110: DEBUGBUS_DBGC_GC_S_1_I_0, 111: DEBUGBUS_LARC_GC_S_1_I_0, 112: DEBUGBUS_RBBM_GC_S_1_I_0, 113: DEBUGBUS_CCRE_GC_S_1_I_0, 114: DEBUGBUS_CGC_GC_S_1_I_0, 115: DEBUGBUS_GMU_GC_S_1_I_0, 116: DEBUGBUS_SLICE_GC_S_1_I_0, 117: DEBUGBUS_HLSQ_SPTP_STAR_GC_S_1_I_0, 118: DEBUGBUS_SLICE_HM1_S_1_I_0, 119: DEBUGBUS_SLICE_HM1_S_1_I_1, 120: DEBUGBUS_USP_GC_S_1_I_0, 121: DEBUGBUS_USP_GC_S_1_I_1, 122: DEBUGBUS_USPTP_GC_S_1_I_0, 123: DEBUGBUS_USPTP_GC_S_1_I_1, 124: DEBUGBUS_USPTP_GC_S_1_I_2, 125: DEBUGBUS_USPTP_GC_S_1_I_3, 126: DEBUGBUS_TP_GC_S_1_I_0, 127: DEBUGBUS_TP_GC_S_1_I_1, 128: DEBUGBUS_TP_GC_S_1_I_2, 129: DEBUGBUS_TP_GC_S_1_I_3, 130: DEBUGBUS_RB_GC_S_1_I_0, 131: DEBUGBUS_RB_GC_S_1_I_1, 132: DEBUGBUS_CCU_GC_S_1_I_0, 133: DEBUGBUS_CCU_GC_S_1_I_1, 134: DEBUGBUS_HLSQ_GC_S_1_I_0, 135: DEBUGBUS_HLSQ_GC_S_1_I_1, 136: DEBUGBUS_VFD_GC_S_1_I_0, 137: DEBUGBUS_VFD_GC_S_1_I_1, 138: DEBUGBUS_NSP_S_1_I_0, 139: DEBUGBUS_NSP_S_1_I_1, MATCH LINES: 172 160: DEBUGBUS_GPC_BR_S_2_I_0, 161: DEBUGBUS_GPC_BV_S_2_I_0, 162: DEBUGBUS_VPCFE_BR_S_2_I_0, 163: DEBUGBUS_VPCFE_BV_S_2_I_0, 164: DEBUGBUS_VPCBE_BR_S_2_I_0, 165: DEBUGBUS_VPCBE_BV_S_2_I_0, 166: DEBUGBUS_CCHE_GC_S_2_I_0, 167: DEBUGBUS_DBGC_GC_S_2_I_0, 168: DEBUGBUS_LARC_GC_S_2_I_0, 169: DEBUGBUS_RBBM_GC_S_2_I_0, 170: DEBUGBUS_CCRE_GC_S_2_I_0, 171: DEBUGBUS_CGC_GC_S_2_I_0, 172: DEBUGBUS_GMU_GC_S_2_I_0, 173: DEBUGBUS_SLICE_GC_S_2_I_0, 174: DEBUGBUS_HLSQ_SPTP_STAR_GC_S_2_I_0, 175: DEBUGBUS_SLICE_HM1_S_2_I_0, 176: DEBUGBUS_SLICE_HM1_S_2_I_1, 177: DEBUGBUS_USP_GC_S_2_I_0, 178: DEBUGBUS_USP_GC_S_2_I_1, 179: DEBUGBUS_USPTP_GC_S_2_I_0, 180: DEBUGBUS_USPTP_GC_S_2_I_1, 181: DEBUGBUS_USPTP_GC_S_2_I_2, 182: DEBUGBUS_USPTP_GC_S_2_I_3, 183: DEBUGBUS_TP_GC_S_2_I_0, 184: DEBUGBUS_TP_GC_S_2_I_1, 185: DEBUGBUS_TP_GC_S_2_I_2, 186: DEBUGBUS_TP_GC_S_2_I_3, 187: DEBUGBUS_RB_GC_S_2_I_0, 188: DEBUGBUS_RB_GC_S_2_I_1, 189: DEBUGBUS_CCU_GC_S_2_I_0, 190: DEBUGBUS_CCU_GC_S_2_I_1, 191: DEBUGBUS_HLSQ_GC_S_2_I_0, 192: DEBUGBUS_HLSQ_GC_S_2_I_1, 193: DEBUGBUS_VFD_GC_S_2_I_0, 194: DEBUGBUS_VFD_GC_S_2_I_1, 195: DEBUGBUS_NSP_S_2_I_0, 196: DEBUGBUS_NSP_S_2_I_1, MATCH LINES: 211, 217 199: DEBUGBUS_NSP_S_2_I_4, 200: DEBUGBUS_NSP_S_2_I_5, 201: DEBUGBUS_NSP_S_2_I_6, 202: DEBUGBUS_NSP_S_2_I_7, 203: DEBUGBUS_MALU_S_2_I_0, 204: DEBUGBUS_MALU_S_2_I_1, 205: DEBUGBUS_MALU_S_2_I_2, 206: DEBUGBUS_MALU_S_2_I_3, 207: }; 208: 209: static struct gen8_debugbus_info gen8_11_0_cx_debugbus_blocks_sized[] = { 210: { DEBUGBUS_GBIF_CX_GC_US_I_0, 31 }, 211: { DEBUGBUS_GMU_CX_GC_US_I_0, 127 }, 212: { DEBUGBUS_CX_GC_US_I_0, 132 }, 213: }; 214: 215: static struct gen8_debugbus_info gen8_11_0_gx_debugbus_blocks_sized[] = { 216: { DEBUGBUS_GBIF_GX_GC_US_I_0, 31 }, 217: { DEBUGBUS_GMU_GX_GC_US_I_0, 63 }, 218: { DEBUGBUS_DBGC_GC_US_I_0, 127 }, 219: { DEBUGBUS_RBBM_GC_US_I_0, 63 }, 220: { DEBUGBUS_LARC_GC_US_I_0, 15 }, 221: { DEBUGBUS_COM_GC_US_I_0, 63 }, 222: { DEBUGBUS_HLSQ_GC_US_I_0, 254 }, 223: { DEBUGBUS_CGC_GC_US_I_0, 0 }, 224: { DEBUGBUS_VSC_GC_US_I_0_0, 201 }, 225: { DEBUGBUS_VSC_GC_US_I_0_1, 230 }, 226: { DEBUGBUS_UFC_GC_US_I_0, 63 }, 227: { DEBUGBUS_UFC_GC_US_I_1, 63 }, 228: { DEBUGBUS_CP_GC_US_I_0_0, 205 }, 229: { DEBUGBUS_CP_GC_US_I_0_1, 251 }, 230: { DEBUGBUS_CP_GC_US_I_0_2, 185 }, 231: { DEBUGBUS_PC_BR_US_I_0, 164 }, 232: { DEBUGBUS_PC_BV_US_I_0, 127 }, 233: { DEBUGBUS_GPC_BR_US_I_0, 3 }, 234: { DEBUGBUS_GPC_BV_US_I_0, 3 }, 235: { DEBUGBUS_VPC_BR_US_I_0, 127 }, 236: { DEBUGBUS_VPC_BV_US_I_0, 127 }, 237: { DEBUGBUS_UCHE_WRAPPER_GC_US_I_0, 127 }, 238: { DEBUGBUS_UCHE_GC_US_I_0, 237 }, 239: { DEBUGBUS_UCHE_GC_US_I_1, 237 }, 240: { DEBUGBUS_UCHE_GC_US_I_0_1, 13 }, 241: { DEBUGBUS_UCHE_GC_US_I_1_1, 13 }, MATCH LINES: 264 252: { DEBUGBUS_GPC_BR_S_0_I_0, 3 }, 253: { DEBUGBUS_GPC_BV_S_0_I_0, 3 }, 254: { DEBUGBUS_VPCFE_BR_S_0_I_0, 127 }, 255: { DEBUGBUS_VPCFE_BV_S_0_I_0, 127 }, 256: { DEBUGBUS_VPCBE_BR_S_0_I_0, 127 }, 257: { DEBUGBUS_VPCBE_BV_S_0_I_0, 127 }, 258: { DEBUGBUS_CCHE_GC_S_0_I_0, 253 }, 259: { DEBUGBUS_DBGC_GC_S_0_I_0, 15 }, 260: { DEBUGBUS_LARC_GC_S_0_I_0, 31 }, 261: { DEBUGBUS_RBBM_GC_S_0_I_0, 63 }, 262: { DEBUGBUS_CCRE_GC_S_0_I_0, 79 }, 263: { DEBUGBUS_CGC_GC_S_0_I_0, 15 }, 264: { DEBUGBUS_GMU_GC_S_0_I_0, 63 }, 265: { DEBUGBUS_SLICE_GC_S_0_I_0, 7 }, 266: { DEBUGBUS_HLSQ_SPTP_STAR_GC_S_0_I_0, 7 }, 267: { DEBUGBUS_SLICE_HM1_S_0_I_0, 31 }, 268: { DEBUGBUS_SLICE_HM1_S_0_I_1, 31 }, 269: { DEBUGBUS_USP_GC_S_0_I_0, 239 }, 270: { DEBUGBUS_USP_GC_S_0_I_1, 239 }, 271: { DEBUGBUS_USPTP_GC_S_0_I_0, 249 }, 272: { DEBUGBUS_USPTP_GC_S_0_I_1, 249 }, 273: { DEBUGBUS_USPTP_GC_S_0_I_2, 249 }, 274: { DEBUGBUS_USPTP_GC_S_0_I_3, 249 }, 275: { DEBUGBUS_TP_GC_S_0_I_0, 254 }, 276: { DEBUGBUS_TP_GC_S_0_I_1, 254 }, 277: { DEBUGBUS_TP_GC_S_0_I_2, 254 }, 278: { DEBUGBUS_TP_GC_S_0_I_3, 254 }, 279: { DEBUGBUS_RB_GC_S_0_I_0, 188 }, 280: { DEBUGBUS_RB_GC_S_0_I_1, 188 }, 281: { DEBUGBUS_CCU_GC_S_0_I_0, 127 }, 282: { DEBUGBUS_CCU_GC_S_0_I_1, 127 }, 283: { DEBUGBUS_HLSQ_GC_S_0_I_0, 63 }, 284: { DEBUGBUS_HLSQ_GC_S_0_I_1, 63 }, 285: { DEBUGBUS_VFD_GC_S_0_I_0, 127 }, 286: { DEBUGBUS_VFD_GC_S_0_I_1, 127 }, 287: { DEBUGBUS_NSP_S_0_I_0, 127 }, 288: { DEBUGBUS_NSP_S_0_I_1, 127 }, MATCH LINES: 321 309: { DEBUGBUS_GPC_BR_S_1_I_0, 3 }, 310: { DEBUGBUS_GPC_BV_S_1_I_0, 3 }, 311: { DEBUGBUS_VPCFE_BR_S_1_I_0, 127 }, 312: { DEBUGBUS_VPCFE_BV_S_1_I_0, 127 }, 313: { DEBUGBUS_VPCBE_BR_S_1_I_0, 127 }, 314: { DEBUGBUS_VPCBE_BV_S_1_I_0, 127 }, 315: { DEBUGBUS_CCHE_GC_S_1_I_0, 253 }, 316: { DEBUGBUS_DBGC_GC_S_1_I_0, 15 }, 317: { DEBUGBUS_LARC_GC_S_1_I_0, 31 }, 318: { DEBUGBUS_RBBM_GC_S_1_I_0, 63 }, 319: { DEBUGBUS_CCRE_GC_S_1_I_0, 79 }, 320: { DEBUGBUS_CGC_GC_S_1_I_0, 15 }, 321: { DEBUGBUS_GMU_GC_S_1_I_0, 63 }, 322: { DEBUGBUS_SLICE_GC_S_1_I_0, 7 }, 323: { DEBUGBUS_HLSQ_SPTP_STAR_GC_S_1_I_0, 7 }, 324: { DEBUGBUS_SLICE_HM1_S_1_I_0, 31 }, 325: { DEBUGBUS_SLICE_HM1_S_1_I_1, 31 }, 326: { DEBUGBUS_USP_GC_S_1_I_0, 239 }, 327: { DEBUGBUS_USP_GC_S_1_I_1, 239 }, 328: { DEBUGBUS_USPTP_GC_S_1_I_0, 249 }, 329: { DEBUGBUS_USPTP_GC_S_1_I_1, 249 }, 330: { DEBUGBUS_USPTP_GC_S_1_I_2, 249 }, 331: { DEBUGBUS_USPTP_GC_S_1_I_3, 249 }, 332: { DEBUGBUS_TP_GC_S_1_I_0, 254 }, 333: { DEBUGBUS_TP_GC_S_1_I_1, 254 }, 334: { DEBUGBUS_TP_GC_S_1_I_2, 254 }, 335: { DEBUGBUS_TP_GC_S_1_I_3, 254 }, 336: { DEBUGBUS_RB_GC_S_1_I_0, 188 }, 337: { DEBUGBUS_RB_GC_S_1_I_1, 188 }, 338: { DEBUGBUS_CCU_GC_S_1_I_0, 127 }, 339: { DEBUGBUS_CCU_GC_S_1_I_1, 127 }, 340: { DEBUGBUS_HLSQ_GC_S_1_I_0, 63 }, 341: { DEBUGBUS_HLSQ_GC_S_1_I_1, 63 }, 342: { DEBUGBUS_VFD_GC_S_1_I_0, 127 }, 343: { DEBUGBUS_VFD_GC_S_1_I_1, 127 }, 344: { DEBUGBUS_NSP_S_1_I_0, 127 }, 345: { DEBUGBUS_NSP_S_1_I_1, 127 }, MATCH LINES: 378 366: { DEBUGBUS_GPC_BR_S_2_I_0, 3 }, 367: { DEBUGBUS_GPC_BV_S_2_I_0, 3 }, 368: { DEBUGBUS_VPCFE_BR_S_2_I_0, 127 }, 369: { DEBUGBUS_VPCFE_BV_S_2_I_0, 127 }, 370: { DEBUGBUS_VPCBE_BR_S_2_I_0, 127 }, 371: { DEBUGBUS_VPCBE_BV_S_2_I_0, 127 }, 372: { DEBUGBUS_CCHE_GC_S_2_I_0, 253 }, 373: { DEBUGBUS_DBGC_GC_S_2_I_0, 15 }, 374: { DEBUGBUS_LARC_GC_S_2_I_0, 31 }, 375: { DEBUGBUS_RBBM_GC_S_2_I_0, 63 }, 376: { DEBUGBUS_CCRE_GC_S_2_I_0, 79 }, 377: { DEBUGBUS_CGC_GC_S_2_I_0, 15 }, 378: { DEBUGBUS_GMU_GC_S_2_I_0, 63 }, 379: { DEBUGBUS_SLICE_GC_S_2_I_0, 7 }, 380: { DEBUGBUS_HLSQ_SPTP_STAR_GC_S_2_I_0, 7 }, 381: { DEBUGBUS_SLICE_HM1_S_2_I_0, 31 }, 382: { DEBUGBUS_SLICE_HM1_S_2_I_1, 31 }, 383: { DEBUGBUS_USP_GC_S_2_I_0, 239 }, 384: { DEBUGBUS_USP_GC_S_2_I_1, 239 }, 385: { DEBUGBUS_USPTP_GC_S_2_I_0, 249 }, 386: { DEBUGBUS_USPTP_GC_S_2_I_1, 249 }, 387: { DEBUGBUS_USPTP_GC_S_2_I_2, 249 }, 388: { DEBUGBUS_USPTP_GC_S_2_I_3, 249 }, 389: { DEBUGBUS_TP_GC_S_2_I_0, 254 }, 390: { DEBUGBUS_TP_GC_S_2_I_1, 254 }, 391: { DEBUGBUS_TP_GC_S_2_I_2, 254 }, 392: { DEBUGBUS_TP_GC_S_2_I_3, 254 }, 393: { DEBUGBUS_RB_GC_S_2_I_0, 188 }, 394: { DEBUGBUS_RB_GC_S_2_I_1, 188 }, 395: { DEBUGBUS_CCU_GC_S_2_I_0, 127 }, 396: { DEBUGBUS_CCU_GC_S_2_I_1, 127 }, 397: { DEBUGBUS_HLSQ_GC_S_2_I_0, 63 }, 398: { DEBUGBUS_HLSQ_GC_S_2_I_1, 63 }, 399: { DEBUGBUS_VFD_GC_S_2_I_0, 127 }, 400: { DEBUGBUS_VFD_GC_S_2_I_1, 127 }, 401: { DEBUGBUS_NSP_S_2_I_0, 127 }, 402: { DEBUGBUS_NSP_S_2_I_1, 127 }, MATCH LINES: 2506 2494: { SLICE, gen8_11_0_dbgc_slice_registers }, 2495: { UNSLICE, gen8_11_0_cx_dbgc_registers }, 2496: { UNSLICE, NULL }, 2497: }; 2498: 2499: static struct gen8_reg_list gen8_11_0_ahb_registers[] = { 2500: { UNSLICE, gen8_11_0_gbif_registers }, 2501: { UNSLICE, gen8_11_0_ahb_precd_gpu_registers }, 2502: { SLICE, gen8_11_0_ahb_precd_gpu_slice_registers }, 2503: { UNSLICE, gen8_11_0_ahb_secure_gpu_registers }, 2504: }; 2505: 2506: static struct gen8_reg_list gen8_11_0_gmu_registers[] = { 2507: { UNSLICE, gen8_11_0_gmugx_registers }, 2508: { SLICE, gen8_11_0_gmugx_slice_registers }, 2509: { UNSLICE, gen8_11_0_gmuao_registers }, 2510: { UNSLICE, gen8_11_0_gmucx_registers }, 2511: }; 2512: 2513: /* 2514: * Block : ['GDPM_LKG'] 2515: * REGION : UNSLICE 2516: * Pipeline: PIPE_NONE 2517: * pairs : 11 (Regs:131) 2518: */ 2519: static const u32 gen8_11_0_gdpm_lkg_registers[] = { 2520: 0x21c00, 0x21c00, 0x21c08, 0x21c09, 0x21c0c, 0x21c0d, 0x21c40, 0x21c41, 2521: 0x21c44, 0x21c4b, 0x21c80, 0x21c88, 0x21ca0, 0x21ca7, 0x21cc0, 0x21cc0, 2522: 0x21ce0, 0x21ce0, 2523: UINT_MAX, UINT_MAX, 2524: }; 2525: static_assert(IS_ALIGNED(sizeof(gen8_11_0_gdpm_lkg_registers), 8)); 2526: 2527: /* 2528: * Block : ['GDPM_LKG_GMXC'] 2529: * REGION : UNSLICE 2530: * Pipeline: PIPE_NONE --- FILE: \adreno_gen8_1_0_snapshot.h | HITS: 11 --- MATCH LINES: 15, 24, 25 3: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 4: */ 5: 6: #ifndef __ADRENO_GEN8_1_0_SNAPSHOT_H 7: #define __ADRENO_GEN8_1_0_SNAPSHOT_H 8: 9: #include "adreno_gen8_snapshot.h" 10: 11: /* 12: * gen8_1_0 specific GBIF debugbus blocks. 13: * The data file puts DEBUGBUS_GBIF_GX_GC_US_I_0 in the main debugbus_blocks list, 14: * so we use an empty list here and include it in gen8_1_0_debugbus_blocks instead. 15: * CX blocks (GBIF_CX, GMU_CX, CX) are handled by gen8_cx_debugbus_blocks. 16: */ 17: static const u32 gen8_1_0_gbif_debugbus_blocks[] = { 18: /* Empty - GBIF_GX is included in gen8_1_0_debugbus_blocks per data file */ 19: }; 20: 21: static const u32 gen8_1_0_debugbus_blocks[] = { 22: /* GBIF_GX block - included here per android_DXX_gen8_1_0_data.h */ 23: DEBUGBUS_GBIF_GX_GC_US_I_0, 24: /* Note: CX blocks (GBIF_CX, GMU_CX, CX) are handled by gen8_cx_debugbus_blocks */ 25: DEBUGBUS_GMU_GX_GC_US_I_0, 26: DEBUGBUS_DBGC_GC_US_I_0, 27: DEBUGBUS_RBBM_GC_US_I_0, 28: DEBUGBUS_LARC_GC_US_I_0, 29: DEBUGBUS_COM_GC_US_I_0, 30: DEBUGBUS_HLSQ_GC_US_I_0, 31: DEBUGBUS_CGC_GC_US_I_0, 32: DEBUGBUS_VSC_GC_US_I_0_0, 33: DEBUGBUS_VSC_GC_US_I_0_1, 34: DEBUGBUS_UFC_GC_US_I_0, 35: DEBUGBUS_UFC_GC_US_I_1, 36: DEBUGBUS_CP_GC_US_I_0_0, 37: DEBUGBUS_CP_GC_US_I_0_1, 38: DEBUGBUS_CP_GC_US_I_0_2, 39: DEBUGBUS_PC_BR_US_I_0, 40: DEBUGBUS_PC_BV_US_I_0, 41: DEBUGBUS_GPC_BR_US_I_0, 42: DEBUGBUS_GPC_BV_US_I_0, 43: DEBUGBUS_VPC_BR_US_I_0, 44: DEBUGBUS_VPC_BV_US_I_0, 45: DEBUGBUS_UCHE_WRAPPER_GC_US_I_0, 46: DEBUGBUS_UCHE_GC_US_I_0, 47: DEBUGBUS_UCHE_GC_US_I_1, 48: DEBUGBUS_UCHE_GC_US_I_0_1, 49: DEBUGBUS_UCHE_GC_US_I_1_1, MATCH LINES: 73 61: DEBUGBUS_GPC_BR_S_0_I_0, 62: DEBUGBUS_GPC_BV_S_0_I_0, 63: DEBUGBUS_VPCFE_BR_S_0_I_0, 64: DEBUGBUS_VPCFE_BV_S_0_I_0, 65: DEBUGBUS_VPCBE_BR_S_0_I_0, 66: DEBUGBUS_VPCBE_BV_S_0_I_0, 67: DEBUGBUS_CCHE_GC_S_0_I_0, 68: DEBUGBUS_DBGC_GC_S_0_I_0, 69: DEBUGBUS_LARC_GC_S_0_I_0, 70: DEBUGBUS_RBBM_GC_S_0_I_0, 71: DEBUGBUS_CCRE_GC_S_0_I_0, 72: DEBUGBUS_CGC_GC_S_0_I_0, 73: DEBUGBUS_GMU_GC_S_0_I_0, 74: DEBUGBUS_SLICE_GC_S_0_I_0, 75: DEBUGBUS_HLSQ_SPTP_STAR_GC_S_0_I_0, 76: DEBUGBUS_USP_GC_S_0_I_0, 77: DEBUGBUS_USP_GC_S_0_I_1, 78: DEBUGBUS_USPTP_GC_S_0_I_0, 79: DEBUGBUS_USPTP_GC_S_0_I_1, 80: DEBUGBUS_USPTP_GC_S_0_I_2, 81: DEBUGBUS_USPTP_GC_S_0_I_3, 82: DEBUGBUS_TP_GC_S_0_I_0, 83: DEBUGBUS_TP_GC_S_0_I_1, 84: DEBUGBUS_TP_GC_S_0_I_2, 85: DEBUGBUS_TP_GC_S_0_I_3, 86: DEBUGBUS_RB_GC_S_0_I_0, 87: DEBUGBUS_RB_GC_S_0_I_1, 88: DEBUGBUS_CCU_GC_S_0_I_0, 89: DEBUGBUS_CCU_GC_S_0_I_1, 90: DEBUGBUS_HLSQ_GC_S_0_I_0, 91: DEBUGBUS_HLSQ_GC_S_0_I_1, 92: DEBUGBUS_VFD_GC_S_0_I_0, 93: DEBUGBUS_VFD_GC_S_0_I_1, 94: /* Slice 1 */ 95: DEBUGBUS_CP_GC_S_1_I_0, 96: DEBUGBUS_PC_BR_S_1_I_0, 97: DEBUGBUS_PC_BV_S_1_I_0, MATCH LINES: 117 105: DEBUGBUS_GPC_BR_S_1_I_0, 106: DEBUGBUS_GPC_BV_S_1_I_0, 107: DEBUGBUS_VPCFE_BR_S_1_I_0, 108: DEBUGBUS_VPCFE_BV_S_1_I_0, 109: DEBUGBUS_VPCBE_BR_S_1_I_0, 110: DEBUGBUS_VPCBE_BV_S_1_I_0, 111: DEBUGBUS_CCHE_GC_S_1_I_0, 112: DEBUGBUS_DBGC_GC_S_1_I_0, 113: DEBUGBUS_LARC_GC_S_1_I_0, 114: DEBUGBUS_RBBM_GC_S_1_I_0, 115: DEBUGBUS_CCRE_GC_S_1_I_0, 116: DEBUGBUS_CGC_GC_S_1_I_0, 117: DEBUGBUS_GMU_GC_S_1_I_0, 118: DEBUGBUS_SLICE_GC_S_1_I_0, 119: DEBUGBUS_HLSQ_SPTP_STAR_GC_S_1_I_0, 120: DEBUGBUS_USP_GC_S_1_I_0, 121: DEBUGBUS_USP_GC_S_1_I_1, 122: DEBUGBUS_USPTP_GC_S_1_I_0, 123: DEBUGBUS_USPTP_GC_S_1_I_1, 124: DEBUGBUS_USPTP_GC_S_1_I_2, 125: DEBUGBUS_USPTP_GC_S_1_I_3, 126: DEBUGBUS_TP_GC_S_1_I_0, 127: DEBUGBUS_TP_GC_S_1_I_1, 128: DEBUGBUS_TP_GC_S_1_I_2, 129: DEBUGBUS_TP_GC_S_1_I_3, 130: DEBUGBUS_RB_GC_S_1_I_0, 131: DEBUGBUS_RB_GC_S_1_I_1, 132: DEBUGBUS_CCU_GC_S_1_I_0, 133: DEBUGBUS_CCU_GC_S_1_I_1, 134: DEBUGBUS_HLSQ_GC_S_1_I_0, 135: DEBUGBUS_HLSQ_GC_S_1_I_1, 136: DEBUGBUS_VFD_GC_S_1_I_0, 137: DEBUGBUS_VFD_GC_S_1_I_1, 138: /* Slice 2 */ 139: DEBUGBUS_CP_GC_S_2_I_0, 140: DEBUGBUS_PC_BR_S_2_I_0, 141: DEBUGBUS_PC_BV_S_2_I_0, MATCH LINES: 161 149: DEBUGBUS_GPC_BR_S_2_I_0, 150: DEBUGBUS_GPC_BV_S_2_I_0, 151: DEBUGBUS_VPCFE_BR_S_2_I_0, 152: DEBUGBUS_VPCFE_BV_S_2_I_0, 153: DEBUGBUS_VPCBE_BR_S_2_I_0, 154: DEBUGBUS_VPCBE_BV_S_2_I_0, 155: DEBUGBUS_CCHE_GC_S_2_I_0, 156: DEBUGBUS_DBGC_GC_S_2_I_0, 157: DEBUGBUS_LARC_GC_S_2_I_0, 158: DEBUGBUS_RBBM_GC_S_2_I_0, 159: DEBUGBUS_CCRE_GC_S_2_I_0, 160: DEBUGBUS_CGC_GC_S_2_I_0, 161: DEBUGBUS_GMU_GC_S_2_I_0, 162: DEBUGBUS_SLICE_GC_S_2_I_0, 163: DEBUGBUS_HLSQ_SPTP_STAR_GC_S_2_I_0, 164: DEBUGBUS_USP_GC_S_2_I_0, 165: DEBUGBUS_USP_GC_S_2_I_1, 166: DEBUGBUS_USPTP_GC_S_2_I_0, 167: DEBUGBUS_USPTP_GC_S_2_I_1, 168: DEBUGBUS_USPTP_GC_S_2_I_2, 169: DEBUGBUS_USPTP_GC_S_2_I_3, 170: DEBUGBUS_TP_GC_S_2_I_0, 171: DEBUGBUS_TP_GC_S_2_I_1, 172: DEBUGBUS_TP_GC_S_2_I_2, 173: DEBUGBUS_TP_GC_S_2_I_3, 174: DEBUGBUS_RB_GC_S_2_I_0, 175: DEBUGBUS_RB_GC_S_2_I_1, 176: DEBUGBUS_CCU_GC_S_2_I_0, 177: DEBUGBUS_CCU_GC_S_2_I_1, 178: DEBUGBUS_HLSQ_GC_S_2_I_0, 179: DEBUGBUS_HLSQ_GC_S_2_I_1, 180: DEBUGBUS_VFD_GC_S_2_I_0, 181: DEBUGBUS_VFD_GC_S_2_I_1, 182: /* Slice 3 - gen8_1_0 has 4 slices */ 183: DEBUGBUS_CP_GC_S_3_I_0, 184: DEBUGBUS_PC_BR_S_3_I_0, 185: DEBUGBUS_PC_BV_S_3_I_0, MATCH LINES: 205 193: DEBUGBUS_GPC_BR_S_3_I_0, 194: DEBUGBUS_GPC_BV_S_3_I_0, 195: DEBUGBUS_VPCFE_BR_S_3_I_0, 196: DEBUGBUS_VPCFE_BV_S_3_I_0, 197: DEBUGBUS_VPCBE_BR_S_3_I_0, 198: DEBUGBUS_VPCBE_BV_S_3_I_0, 199: DEBUGBUS_CCHE_GC_S_3_I_0, 200: DEBUGBUS_DBGC_GC_S_3_I_0, 201: DEBUGBUS_LARC_GC_S_3_I_0, 202: DEBUGBUS_RBBM_GC_S_3_I_0, 203: DEBUGBUS_CCRE_GC_S_3_I_0, 204: DEBUGBUS_CGC_GC_S_3_I_0, 205: DEBUGBUS_GMU_GC_S_3_I_0, 206: DEBUGBUS_SLICE_GC_S_3_I_0, 207: DEBUGBUS_HLSQ_SPTP_STAR_GC_S_3_I_0, 208: DEBUGBUS_USP_GC_S_3_I_0, 209: DEBUGBUS_USP_GC_S_3_I_1, 210: DEBUGBUS_USPTP_GC_S_3_I_0, 211: DEBUGBUS_USPTP_GC_S_3_I_1, 212: DEBUGBUS_USPTP_GC_S_3_I_2, 213: DEBUGBUS_USPTP_GC_S_3_I_3, 214: DEBUGBUS_TP_GC_S_3_I_0, 215: DEBUGBUS_TP_GC_S_3_I_1, 216: DEBUGBUS_TP_GC_S_3_I_2, 217: DEBUGBUS_TP_GC_S_3_I_3, 218: DEBUGBUS_RB_GC_S_3_I_0, 219: DEBUGBUS_RB_GC_S_3_I_1, 220: DEBUGBUS_CCU_GC_S_3_I_0, 221: DEBUGBUS_CCU_GC_S_3_I_1, 222: DEBUGBUS_HLSQ_GC_S_3_I_0, 223: DEBUGBUS_HLSQ_GC_S_3_I_1, 224: DEBUGBUS_VFD_GC_S_3_I_0, 225: DEBUGBUS_VFD_GC_S_3_I_1, 226: }; 227: 228: /* 229: * Shader blocks for gen8_1_0. MATCH LINES: 2037, 2039, 2055, 2057 2025: * Note: This is the GCC PLL register block (external to GPU CC) 2026: */ 2027: static const u32 gen8_1_0_gcc_gpll0_cm_pll_taycan_common_registers[] = { 2028: 0x00000, 0x0000d, 2029: UINT_MAX, UINT_MAX, 2030: }; 2031: static_assert(IS_ALIGNED(sizeof(gen8_1_0_gcc_gpll0_cm_pll_taycan_common_registers), 8)); 2032: 2033: /* 2034: * External core registers. 2035: * These are registers outside the GPU core (clock controllers, CPR, etc.) 2036: * Organized to match the kernel's gen8_snapshot_block_list structure: 2037: * - gx_clkctl registers go into gmu_gx_regs (not here) 2038: * - rscc registers go into rscc_regs field (not here) 2039: * - gmucx registers go into gmu_cx_unsliced_regs field (not here) 2040: */ 2041: static const u32 *gen8_1_0_external_core_regs[] = { 2042: gen8_1_0_gdpm_lkg_registers, 2043: gen8_1_0_gpu_cc_ahb2phy_swman_registers, 2044: gen8_1_0_cpr_registers, 2045: gen8_1_0_cpr_gmxc_registers, 2046: gen8_1_0_gpu_cc_ahb2phy_broadcast_swman_registers, 2047: gen8_1_0_gpu_cc_pll0_cm_pll_taycan_common_registers, 2048: gen8_1_0_gpu_cc_gpu_cc_reg_registers, 2049: gen8_1_0_gcc_gpll0_cm_pll_taycan_common_registers, 2050: }; 2051: 2052: /* 2053: * GMU GX registers. 2054: * Includes GX domain GMU registers and GX clock controller registers. 2055: * The gmucx (CX domain) registers are handled separately via gmu_cx_unsliced_regs. 2056: */ 2057: static struct gen8_reg_list gen8_1_0_gmu_gx_registers[] = { 2058: { UNSLICE, gen8_1_0_gmugx_registers }, 2059: { SLICE, gen8_1_0_gmugx_slice_registers }, 2060: { UNSLICE, gen8_1_0_gmuao_registers }, 2061: { UNSLICE, gen8_1_0_gx_clkctl_gx_clkctl_reg_registers }, 2062: { UNSLICE, gen8_1_0_gx_clkctl_ahb2phy_broadcast_swman_registers }, 2063: { UNSLICE, gen8_1_0_gx_clkctl_ahb2phy_swman_registers }, 2064: }; 2065: 2066: #endif /* __ADRENO_GEN8_1_0_SNAPSHOT_H */ --- FILE: \adreno_gen8_2_0_snapshot.h | HITS: 5 --- MATCH LINES: 12 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 4: */ 5: 6: #ifndef __ADRENO_GEN8_2_0_SNAPSHOT_H 7: #define __ADRENO_GEN8_2_0_SNAPSHOT_H 8: 9: #include "adreno_gen8_snapshot.h" 10: 11: static const u32 gen8_2_0_debugbus_blocks[] = { 12: DEBUGBUS_GMU_GX_GC_US_I_0, 13: DEBUGBUS_DBGC_GC_US_I_0, 14: DEBUGBUS_RBBM_GC_US_I_0, 15: DEBUGBUS_LARC_GC_US_I_0, 16: DEBUGBUS_COM_GC_US_I_0, 17: DEBUGBUS_HLSQ_GC_US_I_0, 18: DEBUGBUS_CGC_GC_US_I_0, 19: DEBUGBUS_VSC_GC_US_I_0_0, 20: DEBUGBUS_VSC_GC_US_I_0_1, 21: DEBUGBUS_UFC_GC_US_I_0, 22: DEBUGBUS_UFC_GC_US_I_1, 23: DEBUGBUS_CP_GC_US_I_0_0, 24: DEBUGBUS_CP_GC_US_I_0_1, 25: DEBUGBUS_CP_GC_US_I_0_2, 26: DEBUGBUS_PC_BR_US_I_0, 27: DEBUGBUS_PC_BV_US_I_0, 28: DEBUGBUS_GPC_BR_US_I_0, 29: DEBUGBUS_GPC_BV_US_I_0, 30: DEBUGBUS_VPC_BR_US_I_0, 31: DEBUGBUS_VPC_BV_US_I_0, 32: DEBUGBUS_UCHE_WRAPPER_GC_US_I_0, 33: DEBUGBUS_UCHE_GC_US_I_0, 34: DEBUGBUS_UCHE_GC_US_I_1, 35: DEBUGBUS_UCHE_GC_US_I_0_1, 36: DEBUGBUS_UCHE_GC_US_I_1_1, MATCH LINES: 59 47: DEBUGBUS_GPC_BR_S_0_I_0, 48: DEBUGBUS_GPC_BV_S_0_I_0, 49: DEBUGBUS_VPCFE_BR_S_0_I_0, 50: DEBUGBUS_VPCFE_BV_S_0_I_0, 51: DEBUGBUS_VPCBE_BR_S_0_I_0, 52: DEBUGBUS_VPCBE_BV_S_0_I_0, 53: DEBUGBUS_CCHE_GC_S_0_I_0, 54: DEBUGBUS_DBGC_GC_S_0_I_0, 55: DEBUGBUS_LARC_GC_S_0_I_0, 56: DEBUGBUS_RBBM_GC_S_0_I_0, 57: DEBUGBUS_CCRE_GC_S_0_I_0, 58: DEBUGBUS_CGC_GC_S_0_I_0, 59: DEBUGBUS_GMU_GC_S_0_I_0, 60: DEBUGBUS_SLICE_GC_S_0_I_0, 61: DEBUGBUS_HLSQ_SPTP_STAR_GC_S_0_I_0, 62: DEBUGBUS_USP_GC_S_0_I_0, 63: DEBUGBUS_USP_GC_S_0_I_1, 64: DEBUGBUS_USPTP_GC_S_0_I_0, 65: DEBUGBUS_USPTP_GC_S_0_I_1, 66: DEBUGBUS_USPTP_GC_S_0_I_2, 67: DEBUGBUS_USPTP_GC_S_0_I_3, 68: DEBUGBUS_TP_GC_S_0_I_0, 69: DEBUGBUS_TP_GC_S_0_I_1, 70: DEBUGBUS_TP_GC_S_0_I_2, 71: DEBUGBUS_TP_GC_S_0_I_3, 72: DEBUGBUS_RB_GC_S_0_I_0, 73: DEBUGBUS_RB_GC_S_0_I_1, 74: DEBUGBUS_CCU_GC_S_0_I_0, 75: DEBUGBUS_CCU_GC_S_0_I_1, 76: DEBUGBUS_HLSQ_GC_S_0_I_0, 77: DEBUGBUS_HLSQ_GC_S_0_I_1, 78: DEBUGBUS_VFD_GC_S_0_I_0, 79: DEBUGBUS_VFD_GC_S_0_I_1, 80: DEBUGBUS_CP_GC_S_1_I_0, 81: DEBUGBUS_PC_BR_S_1_I_0, 82: DEBUGBUS_PC_BV_S_1_I_0, 83: DEBUGBUS_TESS_GC_S_1_I_0, MATCH LINES: 102 90: DEBUGBUS_GPC_BR_S_1_I_0, 91: DEBUGBUS_GPC_BV_S_1_I_0, 92: DEBUGBUS_VPCFE_BR_S_1_I_0, 93: DEBUGBUS_VPCFE_BV_S_1_I_0, 94: DEBUGBUS_VPCBE_BR_S_1_I_0, 95: DEBUGBUS_VPCBE_BV_S_1_I_0, 96: DEBUGBUS_CCHE_GC_S_1_I_0, 97: DEBUGBUS_DBGC_GC_S_1_I_0, 98: DEBUGBUS_LARC_GC_S_1_I_0, 99: DEBUGBUS_RBBM_GC_S_1_I_0, 100: DEBUGBUS_CCRE_GC_S_1_I_0, 101: DEBUGBUS_CGC_GC_S_1_I_0, 102: DEBUGBUS_GMU_GC_S_1_I_0, 103: DEBUGBUS_SLICE_GC_S_1_I_0, 104: DEBUGBUS_HLSQ_SPTP_STAR_GC_S_1_I_0, 105: DEBUGBUS_USP_GC_S_1_I_0, 106: DEBUGBUS_USP_GC_S_1_I_1, 107: DEBUGBUS_USPTP_GC_S_1_I_0, 108: DEBUGBUS_USPTP_GC_S_1_I_1, 109: DEBUGBUS_USPTP_GC_S_1_I_2, 110: DEBUGBUS_USPTP_GC_S_1_I_3, 111: DEBUGBUS_TP_GC_S_1_I_0, 112: DEBUGBUS_TP_GC_S_1_I_1, 113: DEBUGBUS_TP_GC_S_1_I_2, 114: DEBUGBUS_TP_GC_S_1_I_3, 115: DEBUGBUS_RB_GC_S_1_I_0, 116: DEBUGBUS_RB_GC_S_1_I_1, 117: DEBUGBUS_CCU_GC_S_1_I_0, 118: DEBUGBUS_CCU_GC_S_1_I_1, 119: DEBUGBUS_HLSQ_GC_S_1_I_0, 120: DEBUGBUS_HLSQ_GC_S_1_I_1, 121: DEBUGBUS_VFD_GC_S_1_I_0, 122: DEBUGBUS_VFD_GC_S_1_I_1, 123: DEBUGBUS_CP_GC_S_2_I_0, 124: DEBUGBUS_PC_BR_S_2_I_0, 125: DEBUGBUS_PC_BV_S_2_I_0, 126: DEBUGBUS_TESS_GC_S_2_I_0, MATCH LINES: 145 133: DEBUGBUS_GPC_BR_S_2_I_0, 134: DEBUGBUS_GPC_BV_S_2_I_0, 135: DEBUGBUS_VPCFE_BR_S_2_I_0, 136: DEBUGBUS_VPCFE_BV_S_2_I_0, 137: DEBUGBUS_VPCBE_BR_S_2_I_0, 138: DEBUGBUS_VPCBE_BV_S_2_I_0, 139: DEBUGBUS_CCHE_GC_S_2_I_0, 140: DEBUGBUS_DBGC_GC_S_2_I_0, 141: DEBUGBUS_LARC_GC_S_2_I_0, 142: DEBUGBUS_RBBM_GC_S_2_I_0, 143: DEBUGBUS_CCRE_GC_S_2_I_0, 144: DEBUGBUS_CGC_GC_S_2_I_0, 145: DEBUGBUS_GMU_GC_S_2_I_0, 146: DEBUGBUS_SLICE_GC_S_2_I_0, 147: DEBUGBUS_HLSQ_SPTP_STAR_GC_S_2_I_0, 148: DEBUGBUS_USP_GC_S_2_I_0, 149: DEBUGBUS_USP_GC_S_2_I_1, 150: DEBUGBUS_USPTP_GC_S_2_I_0, 151: DEBUGBUS_USPTP_GC_S_2_I_1, 152: DEBUGBUS_USPTP_GC_S_2_I_2, 153: DEBUGBUS_USPTP_GC_S_2_I_3, 154: DEBUGBUS_TP_GC_S_2_I_0, 155: DEBUGBUS_TP_GC_S_2_I_1, 156: DEBUGBUS_TP_GC_S_2_I_2, 157: DEBUGBUS_TP_GC_S_2_I_3, 158: DEBUGBUS_RB_GC_S_2_I_0, 159: DEBUGBUS_RB_GC_S_2_I_1, 160: DEBUGBUS_CCU_GC_S_2_I_0, 161: DEBUGBUS_CCU_GC_S_2_I_1, 162: DEBUGBUS_HLSQ_GC_S_2_I_0, 163: DEBUGBUS_HLSQ_GC_S_2_I_1, 164: DEBUGBUS_VFD_GC_S_2_I_0, 165: DEBUGBUS_VFD_GC_S_2_I_1, 166: }; 167: 168: static struct gen8_shader_block gen8_2_0_shader_blocks[] = { 169: { TP0_TMO_DATA, 0x0200, 2, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, MATCH LINES: 2447 2435: static_assert(IS_ALIGNED(sizeof(gen8_2_0_gx_clkctl_ahb2phy_swman_registers), 8)); 2436: 2437: static const u32 *gen8_2_0_external_core_regs[] = { 2438: gen8_2_0_gdpm_lkg_registers, 2439: gen8_2_0_gpu_cc_ahb2phy_swman_registers, 2440: gen8_2_0_cpr_registers, 2441: gen8_2_0_cpr_gmxc_registers, 2442: gen8_2_0_gpu_cc_ahb2phy_broadcast_swman_registers, 2443: gen8_2_0_gpu_cc_pll0_cm_pll_taycan_common_registers, 2444: gen8_2_0_gpu_cc_gpu_cc_reg_registers, 2445: }; 2446: 2447: static struct gen8_reg_list gen8_2_0_gmu_gx_registers[] = { 2448: { UNSLICE, gen8_2_0_gmugx_registers }, 2449: { SLICE, gen8_2_0_gmugx_slice_registers }, 2450: { UNSLICE, gen8_2_0_gmuao_registers }, 2451: { UNSLICE, gen8_2_0_gx_clkctl_gx_clkctl_reg_registers }, 2452: { UNSLICE, gen8_2_0_gx_clkctl_ahb2phy_broadcast_swman_registers }, 2453: { UNSLICE, gen8_2_0_gx_clkctl_pll0_cm_pll_taycan_common_registers }, 2454: { UNSLICE, gen8_2_0_gx_clkctl_ahb2phy_swman_registers }, 2455: { UNSLICE, gen8_2_0_acd_acd_mnd_registers }, 2456: }; 2457: 2458: #endif /* __ADRENO_GEN8_2_0_SNAPSHOT_H */ --- FILE: \adreno_gen8_3_0_snapshot.h | HITS: 5 --- MATCH LINES: 12 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 4: */ 5: #ifndef __ADRENO_GEN8_3_0_SNAPSHOT_H 6: #define __ADRENO_GEN8_3_0_SNAPSHOT_H 7: 8: #include "adreno_gen8_snapshot.h" 9: #include "adreno_gen8_0_0_snapshot.h" 10: 11: static const u32 gen8_3_0_debugbus_blocks[] = { 12: DEBUGBUS_GMU_GX_GC_US_I_0, 13: DEBUGBUS_DBGC_GC_US_I_0, 14: DEBUGBUS_RBBM_GC_US_I_0, 15: DEBUGBUS_LARC_GC_US_I_0, 16: DEBUGBUS_COM_GC_US_I_0, 17: DEBUGBUS_HLSQ_GC_US_I_0, 18: DEBUGBUS_CGC_GC_US_I_0, 19: DEBUGBUS_VSC_GC_US_I_0_0, 20: DEBUGBUS_VSC_GC_US_I_0_1, 21: DEBUGBUS_UFC_GC_US_I_0, 22: DEBUGBUS_UFC_GC_US_I_1, 23: DEBUGBUS_CP_GC_US_I_0_0, 24: DEBUGBUS_CP_GC_US_I_0_1, 25: DEBUGBUS_CP_GC_US_I_0_2, 26: DEBUGBUS_PC_BR_US_I_0, 27: DEBUGBUS_PC_BV_US_I_0, 28: DEBUGBUS_GPC_BR_US_I_0, 29: DEBUGBUS_GPC_BV_US_I_0, 30: DEBUGBUS_VPC_BR_US_I_0, 31: DEBUGBUS_VPC_BV_US_I_0, 32: DEBUGBUS_UCHE_WRAPPER_GC_US_I_0, 33: DEBUGBUS_UCHE_GC_US_I_0, 34: DEBUGBUS_CP_GC_S_0_I_0, 35: DEBUGBUS_PC_BR_S_0_I_0, 36: DEBUGBUS_PC_BV_S_0_I_0, MATCH LINES: 54 42: DEBUGBUS_VFDP_GC_S_0_I_0, 43: DEBUGBUS_GPC_BR_S_0_I_0, 44: DEBUGBUS_GPC_BV_S_0_I_0, 45: DEBUGBUS_VPCFE_BR_S_0_I_0, 46: DEBUGBUS_VPCFE_BV_S_0_I_0, 47: DEBUGBUS_VPCBE_BR_S_0_I_0, 48: DEBUGBUS_VPCBE_BV_S_0_I_0, 49: DEBUGBUS_DBGC_GC_S_0_I_0, 50: DEBUGBUS_LARC_GC_S_0_I_0, 51: DEBUGBUS_RBBM_GC_S_0_I_0, 52: DEBUGBUS_CCRE_GC_S_0_I_0, 53: DEBUGBUS_CGC_GC_S_0_I_0, 54: DEBUGBUS_GMU_GC_S_0_I_0, 55: DEBUGBUS_SLICE_GC_S_0_I_0, 56: DEBUGBUS_HLSQ_SPTP_STAR_GC_S_0_I_0, 57: DEBUGBUS_USP_GC_S_0_I_0, 58: DEBUGBUS_USPTP_GC_S_0_I_0, 59: DEBUGBUS_USPTP_GC_S_0_I_1, 60: DEBUGBUS_TP_GC_S_0_I_0, 61: DEBUGBUS_TP_GC_S_0_I_1, 62: DEBUGBUS_RB_GC_S_0_I_0, 63: DEBUGBUS_CCU_GC_S_0_I_0, 64: DEBUGBUS_HLSQ_GC_S_0_I_0, 65: DEBUGBUS_VFD_GC_S_0_I_0, 66: }; 67: 68: static struct gen8_shader_block gen8_3_0_shader_blocks[] = { 69: { TP0_TMO_DATA, 0x0200, 1, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 70: { TP0_SMO_DATA, 0x0080, 1, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 71: { TP0_MIPMAP_BASE_DATA, 0x0080, 1, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 72: { SP_INST_DATA_3, 0x0800, 1, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 73: { SP_INST_DATA, 0x0800, 1, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 74: { SP_INST_DATA_1, 0x0800, 1, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 75: { SP_LB_0_DATA, 0x0800, 1, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 76: { SP_LB_1_DATA, 0x0800, 1, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 77: { SP_LB_2_DATA, 0x0800, 1, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 78: { SP_LB_3_DATA, 0x0800, 1, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, MATCH LINES: 173 161: { HLSQ_INDIRECT_META, 0x0010, 1, uSPTP0, PIPE_BR, HLSQ_STATE, UNSLICE, 1}, 162: { HLSQ_BACKEND_META, 0x0034, 1, uSPTP0, PIPE_BR, HLSQ_STATE, UNSLICE, 1}, 163: { HLSQ_BACKEND_META, 0x0034, 1, uSPTP0, PIPE_BV, HLSQ_STATE, UNSLICE, 1}, 164: { HLSQ_BACKEND_META, 0x0020, 1, uSPTP0, PIPE_LPAC, HLSQ_STATE, UNSLICE, 1}, 165: }; 166: 167: /* 168: * Block : ['GMUAO', 'GMUCX', 'GMUCX_RAM'] 169: * REGION : UNSLICE 170: * Pipeline: PIPE_NONE 171: * pairs : 160 (Regs:616) 172: */ 173: static const u32 gen8_3_0_gmu_registers[] = { 174: 0x10001, 0x10001, 0x10003, 0x10003, 0x10401, 0x10401, 0x10403, 0x10403, 175: 0x10801, 0x10801, 0x10803, 0x10803, 0x10c01, 0x10c01, 0x10c03, 0x10c03, 176: 0x11001, 0x11001, 0x11003, 0x11003, 0x11401, 0x11401, 0x11403, 0x11403, 177: 0x11801, 0x11801, 0x11803, 0x11803, 0x11c01, 0x11c01, 0x11c03, 0x11c03, 178: 0x1f400, 0x1f40b, 0x1f40f, 0x1f411, 0x1f500, 0x1f500, 0x1f507, 0x1f507, 179: 0x1f509, 0x1f50b, 0x1f700, 0x1f701, 0x1f704, 0x1f706, 0x1f708, 0x1f709, 180: 0x1f70c, 0x1f70d, 0x1f710, 0x1f711, 0x1f713, 0x1f716, 0x1f718, 0x1f71d, 181: 0x1f720, 0x1f725, 0x1f729, 0x1f729, 0x1f730, 0x1f747, 0x1f750, 0x1f75a, 182: 0x1f75c, 0x1f75c, 0x1f780, 0x1f781, 0x1f784, 0x1f78b, 0x1f790, 0x1f797, 183: 0x1f7a0, 0x1f7a7, 0x1f7b0, 0x1f7b7, 0x1f7e0, 0x1f7e1, 0x1f7e4, 0x1f7e5, 184: 0x1f7e8, 0x1f7e9, 0x1f7ec, 0x1f7ed, 0x1f800, 0x1f804, 0x1f807, 0x1f808, 185: 0x1f80b, 0x1f80c, 0x1f80f, 0x1f80f, 0x1f811, 0x1f811, 0x1f813, 0x1f817, 186: 0x1f819, 0x1f81c, 0x1f824, 0x1f830, 0x1f840, 0x1f842, 0x1f848, 0x1f848, 187: 0x1f84c, 0x1f84c, 0x1f850, 0x1f850, 0x1f858, 0x1f859, 0x1f868, 0x1f869, 188: 0x1f878, 0x1f883, 0x1f930, 0x1f931, 0x1f934, 0x1f935, 0x1f938, 0x1f939, 189: 0x1f93c, 0x1f93d, 0x1f940, 0x1f941, 0x1f943, 0x1f943, 0x1f948, 0x1f94a, 190: 0x1f94f, 0x1f951, 0x1f954, 0x1f955, 0x1f95d, 0x1f95d, 0x1f962, 0x1f96b, 191: 0x1f970, 0x1f970, 0x1f97c, 0x1f97e, 0x1f980, 0x1f981, 0x1f984, 0x1f986, 192: 0x1f992, 0x1f993, 0x1f996, 0x1f99e, 0x1f9c0, 0x1f9cf, 0x1f9f0, 0x1f9f1, 193: 0x1f9f8, 0x1f9fa, 0x1f9fc, 0x1f9fc, 0x1fa00, 0x1fa03, 0x1fc00, 0x1fc01, 194: 0x1fc04, 0x1fc07, 0x1fc10, 0x1fc10, 0x1fc14, 0x1fc14, 0x1fc18, 0x1fc19, 195: 0x1fc20, 0x1fc20, 0x1fc24, 0x1fc26, 0x1fc30, 0x1fc33, 0x1fc38, 0x1fc3b, 196: 0x1fc40, 0x1fc49, 0x1fc50, 0x1fc59, 0x1fc60, 0x1fc7f, 0x1fca0, 0x1fcef, 197: 0x20000, 0x20007, 0x20010, 0x20015, 0x20018, 0x2001a, 0x2001c, 0x2001d, MATCH LINES: 215 203: 0x23801, 0x23801, 0x23803, 0x23803, 0x23805, 0x23805, 0x23807, 0x23807, 204: 0x23809, 0x23809, 0x2380b, 0x2380b, 0x2380d, 0x2380d, 0x2380f, 0x2380f, 205: 0x23811, 0x23811, 0x23813, 0x23813, 0x23815, 0x23815, 0x23817, 0x23817, 206: 0x23819, 0x23819, 0x2381b, 0x2381b, 0x2381d, 0x2381d, 0x2381f, 0x23820, 207: 0x23822, 0x23822, 0x23824, 0x23824, 0x23826, 0x23826, 0x23828, 0x23828, 208: 0x2382a, 0x2382a, 0x2382c, 0x2382c, 0x2382e, 0x2382e, 0x23830, 0x23830, 209: 0x23832, 0x23832, 0x23834, 0x23834, 0x23836, 0x23836, 0x23838, 0x23838, 210: 0x2383a, 0x2383a, 0x2383c, 0x2383c, 0x2383e, 0x2383e, 0x23840, 0x23847, 211: 0x23b00, 0x23b01, 0x23b03, 0x23b03, 0x23b05, 0x23b0e, 0x23b10, 0x23b13, 212: 0x23b15, 0x23b16, 0x23b28, 0x23b28, 0x23b30, 0x23b30, 213: UINT_MAX, UINT_MAX, 214: }; 215: static_assert(IS_ALIGNED(sizeof(gen8_3_0_gmu_registers), 8)); 216: 217: /* 218: * Block : ['GMUGX'] 219: * REGION : UNSLICE 220: * Pipeline: PIPE_NONE 221: * pairs : 17 (Regs:170) 222: */ 223: static const u32 gen8_3_0_gmugx_registers[] = { 224: 0x0dc00, 0x0dc0d, 0x0dc10, 0x0dc11, 0x0dc13, 0x0dc15, 0x0dc18, 0x0dc1a, 225: 0x0dc1c, 0x0dc23, 0x0dc26, 0x0dc2b, 0x0dc2e, 0x0dc2f, 0x0dc40, 0x0dc42, 226: 0x0dc60, 0x0dc7f, 0x0dc88, 0x0dc90, 0x0dc98, 0x0dc99, 0x0dca0, 0x0dcbf, 227: 0x0dcc8, 0x0dcd0, 0x0dcd8, 0x0dcd9, 0x0dce0, 0x0dcff, 0x0dd08, 0x0dd10, 228: 0x0dd18, 0x0dd19, 229: UINT_MAX, UINT_MAX, 230: }; 231: static_assert(IS_ALIGNED(sizeof(gen8_3_0_gmugx_registers), 8)); 232: 233: /* 234: * Block : ['GMUGX'] 235: * REGION : SLICE 236: * Pipeline: PIPE_NONE 237: * pairs : 19 (Regs:224) 238: */ 239: static const u32 gen8_3_0_gmugx_slice_registers[] = { MATCH LINES: 688 676: { GEN8_CP_SQE_UCODE_DBG_ADDR_PIPE, GEN8_CP_SQE_UCODE_DBG_DATA_PIPE, 677: UNSLICE, PIPE_BR, 0x08000}, 678: { GEN8_CP_SQE_UCODE_DBG_ADDR_PIPE, GEN8_CP_SQE_UCODE_DBG_DATA_PIPE, 679: UNSLICE, PIPE_BV, 0x08000}, 680: { GEN8_CP_RESOURCE_TABLE_DBG_ADDR_BV, GEN8_CP_RESOURCE_TABLE_DBG_DATA_BV, 681: UNSLICE, PIPE_NONE, 0x04100}, 682: { GEN8_CP_FIFO_DBG_ADDR_DDE_PIPE, GEN8_CP_FIFO_DBG_DATA_DDE_PIPE, 683: UNSLICE, PIPE_DDE_BR, 0x01100}, 684: { GEN8_CP_FIFO_DBG_ADDR_DDE_PIPE, GEN8_CP_FIFO_DBG_DATA_DDE_PIPE, 685: UNSLICE, PIPE_DDE_BV, 0x01100}, 686: }; 687: 688: static struct gen8_reg_list gen8_3_0_gmu_gx_regs[] = { 689: { UNSLICE, gen8_3_0_gmugx_registers }, 690: { SLICE, gen8_3_0_gmugx_slice_registers }, 691: }; 692: 693: /* 694: * Block : ['GDPM_LKG'] 695: * REGION : UNSLICE 696: * Pipeline: PIPE_NONE 697: * pairs : 9 (Regs:26) 698: */ 699: static const u32 gen8_3_0_gdpm_lkg_registers[] = { 700: 0x21c00, 0x21c00, 0x21c08, 0x21c09, 0x21c0e, 0x21c0f, 0x21c4f, 0x21c50, 701: 0x21c52, 0x21c52, 0x21c54, 0x21c56, 0x21c58, 0x21c5a, 0x21c5c, 0x21c60, 702: UINT_MAX, UINT_MAX, 703: }; 704: static_assert(IS_ALIGNED(sizeof(gen8_3_0_gdpm_lkg_registers), 8)); 705: 706: /* 707: * Block : ['GPU_CC_GPU_CC_REG'] 708: * REGION : UNSLICE 709: * Pipeline: PIPE_NONE 710: * pairs : 28 (Regs:130) 711: */ 712: static const u32 gen8_3_0_gpu_cc_gpu_cc_reg_registers[] = { --- FILE: \adreno_gen8_6_0_snapshot.h | HITS: 6 --- MATCH LINES: 12 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 4: */ 5: #ifndef __ADRENO_GEN8_6_0_SNAPSHOT_H 6: #define __ADRENO_GEN8_6_0_SNAPSHOT_H 7: 8: #include "adreno_gen8_snapshot.h" 9: #include "adreno_gen8_0_0_snapshot.h" 10: 11: static const u32 gen8_6_0_debugbus_blocks[] = { 12: DEBUGBUS_GMU_GX_GC_US_I_0, 13: DEBUGBUS_DBGC_GC_US_I_0, 14: DEBUGBUS_RBBM_GC_US_I_0, 15: DEBUGBUS_LARC_GC_US_I_0, 16: DEBUGBUS_COM_GC_US_I_0, 17: DEBUGBUS_HLSQ_GC_US_I_0, 18: DEBUGBUS_CGC_GC_US_I_0, 19: DEBUGBUS_VSC_GC_US_I_0_0, 20: DEBUGBUS_VSC_GC_US_I_0_1, 21: DEBUGBUS_UFC_GC_US_I_0, 22: DEBUGBUS_UFC_GC_US_I_1, 23: DEBUGBUS_CP_GC_US_I_0_0, 24: DEBUGBUS_CP_GC_US_I_0_1, 25: DEBUGBUS_CP_GC_US_I_0_2, 26: DEBUGBUS_PC_BR_US_I_0, 27: DEBUGBUS_PC_BV_US_I_0, 28: DEBUGBUS_GPC_BR_US_I_0, 29: DEBUGBUS_GPC_BV_US_I_0, 30: DEBUGBUS_VPC_BR_US_I_0, 31: DEBUGBUS_VPC_BV_US_I_0, 32: DEBUGBUS_UCHE_WRAPPER_GC_US_I_0, 33: DEBUGBUS_UCHE_GC_US_I_0, 34: DEBUGBUS_UCHE_GC_US_I_1, 35: DEBUGBUS_CP_GC_S_0_I_0, 36: DEBUGBUS_PC_BR_S_0_I_0, MATCH LINES: 57 45: DEBUGBUS_GPC_BR_S_0_I_0, 46: DEBUGBUS_GPC_BV_S_0_I_0, 47: DEBUGBUS_VPCFE_BR_S_0_I_0, 48: DEBUGBUS_VPCFE_BV_S_0_I_0, 49: DEBUGBUS_VPCBE_BR_S_0_I_0, 50: DEBUGBUS_VPCBE_BV_S_0_I_0, 51: DEBUGBUS_CCHE_GC_S_0_I_0, 52: DEBUGBUS_DBGC_GC_S_0_I_0, 53: DEBUGBUS_LARC_GC_S_0_I_0, 54: DEBUGBUS_RBBM_GC_S_0_I_0, 55: DEBUGBUS_CCRE_GC_S_0_I_0, 56: DEBUGBUS_CGC_GC_S_0_I_0, 57: DEBUGBUS_GMU_GC_S_0_I_0, 58: DEBUGBUS_SLICE_GC_S_0_I_0, 59: DEBUGBUS_HLSQ_SPTP_STAR_GC_S_0_I_0, 60: DEBUGBUS_USP_GC_S_0_I_0, 61: DEBUGBUS_USP_GC_S_0_I_1, 62: DEBUGBUS_USPTP_GC_S_0_I_0, 63: DEBUGBUS_USPTP_GC_S_0_I_1, 64: DEBUGBUS_USPTP_GC_S_0_I_2, 65: DEBUGBUS_USPTP_GC_S_0_I_3, 66: DEBUGBUS_TP_GC_S_0_I_0, 67: DEBUGBUS_TP_GC_S_0_I_1, 68: DEBUGBUS_TP_GC_S_0_I_2, 69: DEBUGBUS_TP_GC_S_0_I_3, 70: DEBUGBUS_RB_GC_S_0_I_0, 71: DEBUGBUS_RB_GC_S_0_I_1, 72: DEBUGBUS_CCU_GC_S_0_I_0, 73: DEBUGBUS_CCU_GC_S_0_I_1, 74: DEBUGBUS_HLSQ_GC_S_0_I_0, 75: DEBUGBUS_HLSQ_GC_S_0_I_1, 76: DEBUGBUS_VFD_GC_S_0_I_0, 77: DEBUGBUS_VFD_GC_S_0_I_1, 78: DEBUGBUS_CP_GC_S_1_I_0, 79: DEBUGBUS_PC_BR_S_1_I_0, 80: DEBUGBUS_PC_BV_S_1_I_0, 81: DEBUGBUS_TESS_GC_S_1_I_0, MATCH LINES: 100 88: DEBUGBUS_GPC_BR_S_1_I_0, 89: DEBUGBUS_GPC_BV_S_1_I_0, 90: DEBUGBUS_VPCFE_BR_S_1_I_0, 91: DEBUGBUS_VPCFE_BV_S_1_I_0, 92: DEBUGBUS_VPCBE_BR_S_1_I_0, 93: DEBUGBUS_VPCBE_BV_S_1_I_0, 94: DEBUGBUS_CCHE_GC_S_1_I_0, 95: DEBUGBUS_DBGC_GC_S_1_I_0, 96: DEBUGBUS_LARC_GC_S_1_I_0, 97: DEBUGBUS_RBBM_GC_S_1_I_0, 98: DEBUGBUS_CCRE_GC_S_1_I_0, 99: DEBUGBUS_CGC_GC_S_1_I_0, 100: DEBUGBUS_GMU_GC_S_1_I_0, 101: DEBUGBUS_SLICE_GC_S_1_I_0, 102: DEBUGBUS_HLSQ_SPTP_STAR_GC_S_1_I_0, 103: DEBUGBUS_USP_GC_S_1_I_0, 104: DEBUGBUS_USP_GC_S_1_I_1, 105: DEBUGBUS_USPTP_GC_S_1_I_0, 106: DEBUGBUS_USPTP_GC_S_1_I_1, 107: DEBUGBUS_USPTP_GC_S_1_I_2, 108: DEBUGBUS_USPTP_GC_S_1_I_3, 109: DEBUGBUS_TP_GC_S_1_I_0, 110: DEBUGBUS_TP_GC_S_1_I_1, 111: DEBUGBUS_TP_GC_S_1_I_2, 112: DEBUGBUS_TP_GC_S_1_I_3, 113: DEBUGBUS_RB_GC_S_1_I_0, 114: DEBUGBUS_RB_GC_S_1_I_1, 115: DEBUGBUS_CCU_GC_S_1_I_0, 116: DEBUGBUS_CCU_GC_S_1_I_1, 117: DEBUGBUS_HLSQ_GC_S_1_I_0, 118: DEBUGBUS_HLSQ_GC_S_1_I_1, 119: DEBUGBUS_VFD_GC_S_1_I_0, 120: DEBUGBUS_VFD_GC_S_1_I_1, 121: }; 122: 123: static struct gen8_shader_block gen8_6_0_shader_blocks[] = { 124: { TP0_TMO_DATA, 0x0200, 2, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, MATCH LINES: 319 307: 0x005a0, 0x005b3, 0x005c0, 0x005c0, 0x005c2, 0x005c6, 0x005e0, 0x005e3, 308: 0x005ec, 0x005ec, 0x00f01, 0x00f02, 0x00f04, 0x00f0c, 0x00f20, 0x00f37, 309: UINT_MAX, UINT_MAX, 310: }; 311: static_assert(IS_ALIGNED(sizeof(gen8_6_0_gpu_slice_registers), 8)); 312: 313: /* 314: * Block : ['GMUGX'] 315: * REGION : UNSLICE 316: * Pipeline: PIPE_NONE 317: * pairs : 160 (Regs:616) 318: */ 319: static const u32 gen8_6_0_gmu_registers[] = { 320: 0x10001, 0x10001, 0x10003, 0x10003, 0x10401, 0x10401, 0x10403, 0x10403, 321: 0x10801, 0x10801, 0x10803, 0x10803, 0x10c01, 0x10c01, 0x10c03, 0x10c03, 322: 0x11001, 0x11001, 0x11003, 0x11003, 0x11401, 0x11401, 0x11403, 0x11403, 323: 0x11801, 0x11801, 0x11803, 0x11803, 0x11c01, 0x11c01, 0x11c03, 0x11c03, 324: 0x1f400, 0x1f40b, 0x1f40f, 0x1f411, 0x1f500, 0x1f500, 0x1f507, 0x1f507, 325: 0x1f509, 0x1f50b, 0x1f700, 0x1f701, 0x1f704, 0x1f706, 0x1f708, 0x1f709, 326: 0x1f70c, 0x1f70d, 0x1f710, 0x1f711, 0x1f713, 0x1f716, 0x1f718, 0x1f71d, 327: 0x1f720, 0x1f725, 0x1f729, 0x1f729, 0x1f730, 0x1f747, 0x1f750, 0x1f75a, 328: 0x1f75c, 0x1f75c, 0x1f780, 0x1f781, 0x1f784, 0x1f78b, 0x1f790, 0x1f797, 329: 0x1f7a0, 0x1f7a7, 0x1f7b0, 0x1f7b7, 0x1f7e0, 0x1f7e1, 0x1f7e4, 0x1f7e5, 330: 0x1f7e8, 0x1f7e9, 0x1f7ec, 0x1f7ed, 0x1f800, 0x1f804, 0x1f807, 0x1f808, 331: 0x1f80b, 0x1f80c, 0x1f80f, 0x1f80f, 0x1f811, 0x1f811, 0x1f813, 0x1f817, 332: 0x1f819, 0x1f81c, 0x1f824, 0x1f830, 0x1f840, 0x1f842, 0x1f848, 0x1f848, 333: 0x1f84c, 0x1f84c, 0x1f850, 0x1f850, 0x1f858, 0x1f859, 0x1f868, 0x1f869, 334: 0x1f878, 0x1f883, 0x1f930, 0x1f931, 0x1f934, 0x1f935, 0x1f938, 0x1f939, 335: 0x1f93c, 0x1f93d, 0x1f940, 0x1f941, 0x1f943, 0x1f943, 0x1f948, 0x1f94a, 336: 0x1f94f, 0x1f951, 0x1f954, 0x1f955, 0x1f95d, 0x1f95d, 0x1f962, 0x1f96b, 337: 0x1f970, 0x1f970, 0x1f97c, 0x1f97e, 0x1f980, 0x1f981, 0x1f984, 0x1f986, 338: 0x1f992, 0x1f993, 0x1f996, 0x1f99e, 0x1f9c0, 0x1f9cf, 0x1f9f0, 0x1f9f1, 339: 0x1f9f8, 0x1f9fa, 0x1f9fc, 0x1f9fc, 0x1fa00, 0x1fa03, 0x1fc00, 0x1fc01, 340: 0x1fc04, 0x1fc07, 0x1fc10, 0x1fc10, 0x1fc14, 0x1fc14, 0x1fc18, 0x1fc19, 341: 0x1fc20, 0x1fc20, 0x1fc24, 0x1fc26, 0x1fc30, 0x1fc33, 0x1fc38, 0x1fc3b, 342: 0x1fc40, 0x1fc49, 0x1fc50, 0x1fc59, 0x1fc60, 0x1fc7f, 0x1fca0, 0x1fcef, 343: 0x20000, 0x20007, 0x20010, 0x20015, 0x20018, 0x2001a, 0x2001c, 0x2001d, MATCH LINES: 361 349: 0x23801, 0x23801, 0x23803, 0x23803, 0x23805, 0x23805, 0x23807, 0x23807, 350: 0x23809, 0x23809, 0x2380b, 0x2380b, 0x2380d, 0x2380d, 0x2380f, 0x2380f, 351: 0x23811, 0x23811, 0x23813, 0x23813, 0x23815, 0x23815, 0x23817, 0x23817, 352: 0x23819, 0x23819, 0x2381b, 0x2381b, 0x2381d, 0x2381d, 0x2381f, 0x23820, 353: 0x23822, 0x23822, 0x23824, 0x23824, 0x23826, 0x23826, 0x23828, 0x23828, 354: 0x2382a, 0x2382a, 0x2382c, 0x2382c, 0x2382e, 0x2382e, 0x23830, 0x23830, 355: 0x23832, 0x23832, 0x23834, 0x23834, 0x23836, 0x23836, 0x23838, 0x23838, 356: 0x2383a, 0x2383a, 0x2383c, 0x2383c, 0x2383e, 0x2383e, 0x23840, 0x23847, 357: 0x23b00, 0x23b01, 0x23b03, 0x23b03, 0x23b05, 0x23b0e, 0x23b10, 0x23b13, 358: 0x23b15, 0x23b16, 0x23b28, 0x23b28, 0x23b30, 0x23b30, 359: UINT_MAX, UINT_MAX, 360: }; 361: static_assert(IS_ALIGNED(sizeof(gen8_6_0_gmu_registers), 8)); 362: 363: /* 364: * Block : ['BROADCAST', 'CX_DBGC', 'CX_MISC', 'DBGC', 'GBIF', 'GMUAO'] 365: * Block : ['GMUCX', 'GMUGX', 'GRAS', 'PC', 'RBBM'] 366: * Block : ['RDVM', 'UCHE', 'VFD', 'VPC', 'VSC'] 367: * REGION : SLICE 368: * Pipeline: PIPE_BR 369: * Cluster : CLUSTER_NONE 370: * pairs : 21 (Regs:301) 371: */ 372: static const u32 gen8_6_0_non_context_slice_pipe_br_registers[] = { 373: 0x08600, 0x08602, 0x08610, 0x08613, 0x08700, 0x08704, 0x08710, 0x08713, 374: 0x08720, 0x08723, 0x08730, 0x08733, 0x08740, 0x08744, 0x09680, 0x09681, 375: 0x09690, 0x0969b, 0x09740, 0x09745, 0x09750, 0x0975b, 0x09770, 0x097ef, 376: 0x09f00, 0x09f0f, 0x09f20, 0x09f23, 0x09f30, 0x09f31, 0x0a600, 0x0a600, 377: 0x0a603, 0x0a603, 0x0a610, 0x0a61f, 0x0a630, 0x0a632, 0x0a638, 0x0a63c, 378: 0x0a640, 0x0a67f, 379: UINT_MAX, UINT_MAX, 380: }; 381: static_assert(IS_ALIGNED(sizeof(gen8_6_0_non_context_slice_pipe_br_registers), 8)); 382: 383: /* 384: * Block : ['BROADCAST', 'CX_DBGC', 'CX_MISC', 'DBGC', 'GBIF', 'GMUAO'] 385: * Block : ['GMUCX', 'GMUGX', 'GRAS', 'PC', 'RBBM'] MATCH LINES: 607 595: }; 596: static_assert(IS_ALIGNED(sizeof(gen8_6_0_cpr_registers), 8)); 597: 598: static const u32 *gen8_6_0_external_core_regs[] = { 599: gen8_0_0_gdpm_lkg_registers, 600: gen8_0_0_gpu_cc_ahb2phy_broadcast_swman_registers, 601: gen8_0_0_gpu_cc_ahb2phy_swman_registers, 602: gen8_6_0_gpu_cc_gpu_cc_reg_registers, 603: gen8_6_0_gpu_cc_pll0_cm_pll_lucid_ole_registers, 604: gen8_6_0_cpr_registers, 605: }; 606: 607: static struct gen8_reg_list gen8_6_0_gmu_gx_registers[] = { 608: { UNSLICE, gen8_0_0_gmugx_registers }, 609: { UNSLICE, gen8_0_0_gx_clkctl_ahb2phy_broadcast_swman_registers }, 610: { UNSLICE, gen8_0_0_gx_clkctl_ahb2phy_swman_registers }, 611: { UNSLICE, gen8_6_0_gx_clkctl_pll0_cm_pll_lucid_ole_registers }, 612: { UNSLICE, gen8_6_0_gx_clkctl_gx_clkctl_reg_registers }, 613: { UNSLICE, gen8_6_0_acd_acd_registers }, 614: { SLICE, gen8_0_0_gmugx_slice_registers }, 615: }; 616: #endif /*_ADRENO_GEN8_6_0_SNAPSHOT_H */ --- FILE: \adreno_gen8_9_0_snapshot.h | HITS: 3 --- MATCH LINES: 12 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 4: */ 5: #ifndef __ADRENO_GEN8_9_0_SNAPSHOT_H 6: #define __ADRENO_GEN8_9_0_SNAPSHOT_H 7: 8: #include "adreno_gen8_snapshot.h" 9: #include "adreno_gen8_2_0_snapshot.h" 10: 11: static const u32 gen8_9_0_debugbus_blocks[] = { 12: DEBUGBUS_GMU_GX_GC_US_I_0, 13: DEBUGBUS_DBGC_GC_US_I_0, 14: DEBUGBUS_RBBM_GC_US_I_0, 15: DEBUGBUS_LARC_GC_US_I_0, 16: DEBUGBUS_COM_GC_US_I_0, 17: DEBUGBUS_HLSQ_GC_US_I_0, 18: DEBUGBUS_CGC_GC_US_I_0, 19: DEBUGBUS_VSC_GC_US_I_0_0, 20: DEBUGBUS_VSC_GC_US_I_0_1, 21: DEBUGBUS_UFC_GC_US_I_0, 22: DEBUGBUS_UFC_GC_US_I_1, 23: DEBUGBUS_CP_GC_US_I_0_0, 24: DEBUGBUS_CP_GC_US_I_0_1, 25: DEBUGBUS_CP_GC_US_I_0_2, 26: DEBUGBUS_PC_BR_US_I_0, 27: DEBUGBUS_PC_BV_US_I_0, 28: DEBUGBUS_GPC_BR_US_I_0, 29: DEBUGBUS_GPC_BV_US_I_0, 30: DEBUGBUS_VPC_BR_US_I_0, 31: DEBUGBUS_VPC_BV_US_I_0, 32: DEBUGBUS_UCHE_WRAPPER_GC_US_I_0, 33: DEBUGBUS_UCHE_GC_US_I_0, 34: DEBUGBUS_UCHE_GC_US_I_1, 35: DEBUGBUS_CP_GC_S_0_I_0, 36: DEBUGBUS_PC_BR_S_0_I_0, MATCH LINES: 57 45: DEBUGBUS_GPC_BR_S_0_I_0, 46: DEBUGBUS_GPC_BV_S_0_I_0, 47: DEBUGBUS_VPCFE_BR_S_0_I_0, 48: DEBUGBUS_VPCFE_BV_S_0_I_0, 49: DEBUGBUS_VPCBE_BR_S_0_I_0, 50: DEBUGBUS_VPCBE_BV_S_0_I_0, 51: DEBUGBUS_CCHE_GC_S_0_I_0, 52: DEBUGBUS_DBGC_GC_S_0_I_0, 53: DEBUGBUS_LARC_GC_S_0_I_0, 54: DEBUGBUS_RBBM_GC_S_0_I_0, 55: DEBUGBUS_CCRE_GC_S_0_I_0, 56: DEBUGBUS_CGC_GC_S_0_I_0, 57: DEBUGBUS_GMU_GC_S_0_I_0, 58: DEBUGBUS_SLICE_GC_S_0_I_0, 59: DEBUGBUS_HLSQ_SPTP_STAR_GC_S_0_I_0, 60: DEBUGBUS_USP_GC_S_0_I_0, 61: DEBUGBUS_USP_GC_S_0_I_1, 62: DEBUGBUS_USPTP_GC_S_0_I_0, 63: DEBUGBUS_USPTP_GC_S_0_I_1, 64: DEBUGBUS_USPTP_GC_S_0_I_2, 65: DEBUGBUS_USPTP_GC_S_0_I_3, 66: DEBUGBUS_TP_GC_S_0_I_0, 67: DEBUGBUS_TP_GC_S_0_I_1, 68: DEBUGBUS_TP_GC_S_0_I_2, 69: DEBUGBUS_TP_GC_S_0_I_3, 70: DEBUGBUS_RB_GC_S_0_I_0, 71: DEBUGBUS_RB_GC_S_0_I_1, 72: DEBUGBUS_CCU_GC_S_0_I_0, 73: DEBUGBUS_CCU_GC_S_0_I_1, 74: DEBUGBUS_HLSQ_GC_S_0_I_0, 75: DEBUGBUS_HLSQ_GC_S_0_I_1, 76: DEBUGBUS_VFD_GC_S_0_I_0, 77: DEBUGBUS_VFD_GC_S_0_I_1, 78: DEBUGBUS_CP_GC_S_1_I_0, 79: DEBUGBUS_PC_BR_S_1_I_0, 80: DEBUGBUS_PC_BV_S_1_I_0, 81: DEBUGBUS_TESS_GC_S_1_I_0, MATCH LINES: 100 88: DEBUGBUS_GPC_BR_S_1_I_0, 89: DEBUGBUS_GPC_BV_S_1_I_0, 90: DEBUGBUS_VPCFE_BR_S_1_I_0, 91: DEBUGBUS_VPCFE_BV_S_1_I_0, 92: DEBUGBUS_VPCBE_BR_S_1_I_0, 93: DEBUGBUS_VPCBE_BV_S_1_I_0, 94: DEBUGBUS_CCHE_GC_S_1_I_0, 95: DEBUGBUS_DBGC_GC_S_1_I_0, 96: DEBUGBUS_LARC_GC_S_1_I_0, 97: DEBUGBUS_RBBM_GC_S_1_I_0, 98: DEBUGBUS_CCRE_GC_S_1_I_0, 99: DEBUGBUS_CGC_GC_S_1_I_0, 100: DEBUGBUS_GMU_GC_S_1_I_0, 101: DEBUGBUS_SLICE_GC_S_1_I_0, 102: DEBUGBUS_HLSQ_SPTP_STAR_GC_S_1_I_0, 103: DEBUGBUS_USP_GC_S_1_I_0, 104: DEBUGBUS_USP_GC_S_1_I_1, 105: DEBUGBUS_USPTP_GC_S_1_I_0, 106: DEBUGBUS_USPTP_GC_S_1_I_1, 107: DEBUGBUS_USPTP_GC_S_1_I_2, 108: DEBUGBUS_USPTP_GC_S_1_I_3, 109: DEBUGBUS_TP_GC_S_1_I_0, 110: DEBUGBUS_TP_GC_S_1_I_1, 111: DEBUGBUS_TP_GC_S_1_I_2, 112: DEBUGBUS_TP_GC_S_1_I_3, 113: DEBUGBUS_RB_GC_S_1_I_0, 114: DEBUGBUS_RB_GC_S_1_I_1, 115: DEBUGBUS_CCU_GC_S_1_I_0, 116: DEBUGBUS_CCU_GC_S_1_I_1, 117: DEBUGBUS_HLSQ_GC_S_1_I_0, 118: DEBUGBUS_HLSQ_GC_S_1_I_1, 119: DEBUGBUS_VFD_GC_S_1_I_0, 120: DEBUGBUS_VFD_GC_S_1_I_1, 121: }; 122: 123: /* 124: * Block : ['CPR'] --- FILE: \adreno_gen8_gmu.c | HITS: 583 --- MATCH LINES: 25, 28, 29, 33, 38, 42, 46, 51, 61, 70, 76, 84, 93, 99, 125, 134, 140, 148, 157, 163, 171, 180, 186, 213, 223, 231, 240, 245, 246, 247, 250, 267, 272, 276, 278, 281, 286, 288, 290, 298, 301, 305, 307, 309, 310, 320, 323, 327, 332, 334, 340, 345, 347, 355, 360, 363, 366, 370, 372, 379, 383, 385, 391, 400, 403, 404, 408, 409, 418, 421, 427, 429, 430, 431, 433, 434, 437, 440, 446, 458, 461, 462, 463, 464, 465, 466, 467, 468, 475, 478, 479, 481, 484, 487, 488, 491, 495, 498, 499, 500, 501, 508, 510, 512, 513, 514, 516, 520, 522, 526, 527, 530, 533, 536, 537, 538, 542, 543, 546, 549, 553, 554, 556, 557, 558, 559, 574, 577, 585, 586, 588, 589, 600, 602, 609, 625, 628, 637, 653, 663, 667, 676, 680, 696, 699, 700, 711, 713, 728, 729, 742, 743, 744, 746, 748, 751, 752, 754, 756, 757, 766, 769, 771, 772, 776, 782, 790, 792, 794, 798, 805, 808, 811, 816, 818, 820, 822, 824, 829, 830, 832, 838, 841, 847, 853, 854, 855, 860, 862, 871, 874, 875, 878, 879, 881, 882, 883, 885, 894, 908, 909, 912, 916, 917, 920, 921, 922, 925, 936, 943, 944, 952, 953, 954, 955, 972, 973, 975, 979, 980, 981, 983, 986, 989, 992, 995, 999, 1005, 1008, 1009, 1011, 1029, 1040, 1043, 1051, 1055, 1065, 1067, 1068, 1071, 1072, 1073, 1075, 1078, 1082, 1086, 1090 13: #include 14: #include 15: #include 16: #include 17: #include 18: 19: #include "adreno.h" 20: #include "adreno_gen8.h" 21: #include "adreno_trace.h" 22: #include "kgsl_bus.h" 23: #include "kgsl_device.h" 24: #include "kgsl_trace.h" 25: #include "kgsl_gmu_core.h" 26: #include "kgsl_util.h" 27: 28: static struct gmu_vma_entry gen8_gmu_vma[] = { 29: [GMU_ITCM] = { 30: .start = 0x00000000, 31: .size = SZ_16K, 32: }, 33: [GMU_CACHE] = { 34: .start = SZ_16K, 35: .size = (SZ_16M - SZ_16K), 36: .next_va = SZ_16K, 37: }, 38: [GMU_DTCM] = { 39: .start = SZ_256M + SZ_16K, 40: .size = SZ_16K, 41: }, 42: [GMU_DCACHE] = { 43: .start = 0x0, 44: .size = 0x0, 45: }, 46: [GMU_NONCACHED_KERNEL] = { 47: .start = 0x60000000, 48: .size = SZ_512M, 49: .next_va = 0x60000000, 50: }, 51: [GMU_NONCACHED_KERNEL_EXTENDED] = { 52: .start = 0xc0000000, 53: .size = SZ_512M, 54: .next_va = 0xc0000000, 55: }, 56: }; 57: 58: static ssize_t log_stream_enable_store(struct kobject *kobj, 59: struct kobj_attribute *attr, const char *buf, size_t count) 60: { 61: struct gen8_gmu_device *gmu = container_of(kobj, struct gen8_gmu_device, log_kobj); 62: bool val; 63: int ret; 64: 65: ret = kstrtobool(buf, &val); 66: if (ret) 67: return ret; 68: 69: gmu->log_stream_enable = val; 70: gmu_core_mark_for_coldboot(KGSL_DEVICE(gen8_gmu_to_adreno(gmu))); 71: return count; 72: } 73: 74: static ssize_t log_stream_enable_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) 75: { 76: struct gen8_gmu_device *gmu = container_of(kobj, struct gen8_gmu_device, log_kobj); 77: 78: return scnprintf(buf, PAGE_SIZE, "%d\n", gmu->log_stream_enable); 79: } 80: 81: static ssize_t log_group_mask_store(struct kobject *kobj, 82: struct kobj_attribute *attr, const char *buf, size_t count) 83: { 84: struct gen8_gmu_device *gmu = container_of(kobj, struct gen8_gmu_device, log_kobj); 85: u32 val; 86: int ret; 87: 88: ret = kstrtou32(buf, 0, &val); 89: if (ret) 90: return ret; 91: 92: gmu->log_group_mask = val; 93: gmu_core_mark_for_coldboot(KGSL_DEVICE(gen8_gmu_to_adreno(gmu))); 94: return count; 95: } 96: 97: static ssize_t log_group_mask_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) 98: { 99: struct gen8_gmu_device *gmu = container_of(kobj, struct gen8_gmu_device, log_kobj); 100: 101: return scnprintf(buf, PAGE_SIZE, "%x\n", gmu->log_group_mask); 102: } 103: 104: static struct kobj_attribute log_stream_enable_attr = 105: __ATTR(log_stream_enable, 0644, log_stream_enable_show, log_stream_enable_store); 106: 107: static struct kobj_attribute log_group_mask_attr = 108: __ATTR(log_group_mask, 0644, log_group_mask_show, log_group_mask_store); 109: 110: static struct attribute *log_attrs[] = { 111: &log_stream_enable_attr.attr, 112: &log_group_mask_attr.attr, 113: NULL, 114: }; 115: ATTRIBUTE_GROUPS(log); 116: 117: static const struct kobj_type log_kobj_type = { 118: .sysfs_ops = &kobj_sysfs_ops, 119: .default_groups = log_groups, 120: }; 121: 122: static ssize_t stats_enable_store(struct kobject *kobj, 123: struct kobj_attribute *attr, const char *buf, size_t count) 124: { 125: struct gen8_gmu_device *gmu = container_of(kobj, struct gen8_gmu_device, stats_kobj); 126: bool val; 127: int ret; 128: 129: ret = kstrtobool(buf, &val); 130: if (ret) 131: return ret; 132: 133: gmu->stats_enable = val; 134: gmu_core_mark_for_coldboot(KGSL_DEVICE(gen8_gmu_to_adreno(gmu))); 135: return count; 136: } 137: 138: static ssize_t stats_enable_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) 139: { 140: struct gen8_gmu_device *gmu = container_of(kobj, struct gen8_gmu_device, stats_kobj); 141: 142: return scnprintf(buf, PAGE_SIZE, "%d\n", gmu->stats_enable); 143: } 144: 145: static ssize_t stats_mask_store(struct kobject *kobj, 146: struct kobj_attribute *attr, const char *buf, size_t count) 147: { 148: struct gen8_gmu_device *gmu = container_of(kobj, struct gen8_gmu_device, stats_kobj); 149: u32 val; 150: int ret; 151: 152: ret = kstrtou32(buf, 0, &val); 153: if (ret) 154: return ret; 155: 156: gmu->stats_mask = val; 157: gmu_core_mark_for_coldboot(KGSL_DEVICE(gen8_gmu_to_adreno(gmu))); 158: return count; 159: } 160: 161: static ssize_t stats_mask_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) 162: { 163: struct gen8_gmu_device *gmu = container_of(kobj, struct gen8_gmu_device, stats_kobj); 164: 165: return scnprintf(buf, PAGE_SIZE, "%x\n", gmu->stats_mask); 166: } 167: 168: static ssize_t stats_interval_store(struct kobject *kobj, 169: struct kobj_attribute *attr, const char *buf, size_t count) 170: { 171: struct gen8_gmu_device *gmu = container_of(kobj, struct gen8_gmu_device, stats_kobj); 172: u32 val; 173: int ret; 174: 175: ret = kstrtou32(buf, 0, &val); 176: if (ret) 177: return ret; 178: 179: gmu->stats_interval = val; 180: gmu_core_mark_for_coldboot(KGSL_DEVICE(gen8_gmu_to_adreno(gmu))); 181: return count; 182: } 183: 184: static ssize_t stats_interval_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) 185: { 186: struct gen8_gmu_device *gmu = container_of(kobj, struct gen8_gmu_device, stats_kobj); 187: 188: return scnprintf(buf, PAGE_SIZE, "%x\n", gmu->stats_interval); 189: } 190: 191: static struct kobj_attribute stats_enable_attr = 192: __ATTR(stats_enable, 0644, stats_enable_show, stats_enable_store); 193: 194: static struct kobj_attribute stats_mask_attr = 195: __ATTR(stats_mask, 0644, stats_mask_show, stats_mask_store); 196: 197: static struct kobj_attribute stats_interval_attr = 198: __ATTR(stats_interval, 0644, stats_interval_show, stats_interval_store); 199: 200: static struct attribute *stats_attrs[] = { 201: &stats_enable_attr.attr, 202: &stats_mask_attr.attr, 203: &stats_interval_attr.attr, 204: NULL, 205: }; 206: ATTRIBUTE_GROUPS(stats); 207: 208: static const struct kobj_type stats_kobj_type = { 209: .sysfs_ops = &kobj_sysfs_ops, 210: .default_groups = stats_groups, 211: }; 212: 213: static int gen8_timed_poll_check_rscc(struct gen8_gmu_device *gmu, 214: u32 offset, u32 expected_ret, 215: u32 timeout, u32 mask) 216: { 217: u32 value; 218: 219: return readl_poll_timeout(gmu->rscc_virt + (offset << 2), value, 220: (value & mask) == expected_ret, 100, timeout * 1000); 221: } 222: 223: struct gen8_gmu_device *to_gen8_gmu(struct adreno_device *adreno_dev) 224: { 225: struct gen8_device *gen8_dev = container_of(adreno_dev, 226: struct gen8_device, adreno_dev); 227: 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: 265: ticks = gpudev->read_alwayson(adreno_dev); 266: 267: trace_gmu_ao_sync(ticks); 268: 269: local_irq_restore(flags); 270: } 271: 272: int gen8_gmu_device_start(struct adreno_device *adreno_dev) 273: { 274: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 275: 276: gmu_core_reset_trace_header(&device->gmu_core.trace); 277: 278: gmu_ao_sync_event(adreno_dev); 279: 280: /* Bring GMU out of reset */ 281: gmu_core_regwrite(device, GEN8_GMUCX_CM3_SYSRESET, 0); 282: 283: /* Make sure the write is posted before moving ahead */ 284: wmb(); 285: 286: if (gmu_core_timed_poll_check(device, GEN8_GMUCX_CM3_FW_INIT_RESULT, 287: BIT(8), 100, GENMASK(8, 0))) { 288: dev_err(GMU_PDEV_DEV(device), 289: "GMU failed to come out of reset\n"); 290: gmu_core_fault_snapshot(device, GMU_FAULT_DEVICE_START); 291: return -ETIMEDOUT; 292: } 293: 294: return 0; 295: } 296: 297: /* 298: * gen8_gmu_hfi_start() - Write registers and start HFI. 299: * @device: Pointer to KGSL device 300: */ 301: int gen8_gmu_hfi_start(struct adreno_device *adreno_dev) 302: { 303: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 304: 305: gmu_core_regwrite(device, GEN8_GMUCX_HFI_CTRL_INIT, 1); 306: 307: if (gmu_core_timed_poll_check(device, GEN8_GMUCX_HFI_CTRL_STATUS, 308: BIT(0), 100, BIT(0))) { 309: dev_err(GMU_PDEV_DEV(device), "GMU HFI init failed\n"); 310: gmu_core_fault_snapshot(device, GMU_FAULT_HFI_INIT); 311: return -ETIMEDOUT; 312: } 313: 314: return 0; 315: } 316: 317: int gen8_rscc_wakeup_sequence(struct adreno_device *adreno_dev) 318: { 319: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 320: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 321: 322: /* Skip wakeup sequence if we didn't do the sleep sequence */ 323: if (!test_bit(GMU_PRIV_RSCC_SLEEP_DONE, &gmu->flags)) 324: return 0; 325: 326: /* RSC wake sequence */ 327: gmu_core_regwrite(device, GEN8_GMUAO_RSCC_CONTROL_REQ, BIT(1)); 328: 329: /* Write request before polling */ 330: wmb(); 331: 332: if (gmu_core_timed_poll_check(device, GEN8_GMUAO_RSCC_CONTROL_ACK, 333: BIT(1), 100, BIT(1))) { 334: dev_err(GMU_PDEV_DEV(device), "Failed to do GPU RSC power on\n"); 335: return -ETIMEDOUT; 336: } 337: 338: if (gen8_timed_poll_check_rscc(gmu, GEN8_RSCC_SEQ_BUSY_DRV0, 339: 0x0, 100, UINT_MAX)) { 340: dev_err(GMU_PDEV_DEV(device), 341: "GPU RSC sequence stuck in waking up GPU\n"); 342: return -ETIMEDOUT; 343: } 344: 345: gmu_core_regwrite(device, GEN8_GMUAO_RSCC_CONTROL_REQ, 0); 346: 347: clear_bit(GMU_PRIV_RSCC_SLEEP_DONE, &gmu->flags); 348: 349: return 0; 350: } 351: 352: int gen8_rscc_sleep_sequence(struct adreno_device *adreno_dev) 353: { 354: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 355: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 356: int ret; 357: u32 bitmask = (adreno_is_gen8_2_x(adreno_dev) || adreno_is_gen8_11_x(adreno_dev)) ? 358: BIT(30) : BIT(16); 359: 360: if (!test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags)) 361: return 0; 362: 363: if (test_bit(GMU_PRIV_RSCC_SLEEP_DONE, &gmu->flags)) 364: return 0; 365: 366: gmu_core_regwrite(device, GEN8_GMUCX_CM3_SYSRESET, 1); 367: /* Make sure M3 is in reset before going on */ 368: wmb(); 369: 370: gmu_core_regread(device, GEN8_GMUCX_GENERAL_9, &gmu->log_wptr_retention); 371: 372: gmu_core_regwrite(device, GEN8_GMUAO_RSCC_CONTROL_REQ, BIT(0)); 373: /* Make sure the request completes before continuing */ 374: wmb(); 375: 376: ret = gen8_timed_poll_check_rscc(gmu, GEN8_GPU_RSCC_RSC_STATUS0_DRV0, 377: bitmask, 100, bitmask); 378: if (ret) { 379: dev_err(GMU_PDEV_DEV(device), "GPU RSC power off fail\n"); 380: return -ETIMEDOUT; 381: } 382: 383: gmu_core_regwrite(device, GEN8_GMUAO_RSCC_CONTROL_REQ, 0); 384: 385: set_bit(GMU_PRIV_RSCC_SLEEP_DONE, &gmu->flags); 386: 387: return 0; 388: } 389: 390: static void load_tcm(struct adreno_device *adreno_dev, const u8 *src, 391: u32 tcm_start, u32 base, const struct gmu_block_header *blk) 392: { 393: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 394: u32 tcm_offset = tcm_start + ((blk->addr - base)/sizeof(u32)); 395: 396: kgsl_regmap_bulk_write(&device->regmap, tcm_offset, src, 397: blk->size >> 2); 398: } 399: 400: int gen8_gmu_load_fw(struct adreno_device *adreno_dev) 401: { 402: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 403: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 404: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)); 405: const u8 *fw = (const u8 *)gmu->fw_image->data; 406: 407: while (fw < gmu->fw_image->data + gmu->fw_image->size) { 408: const struct gmu_block_header *blk = 409: (const struct gmu_block_header *)fw; 410: int id; 411: 412: fw += sizeof(*blk); 413: 414: /* Don't deal with zero size blocks */ 415: if (blk->size == 0) 416: continue; 417: 418: id = gmu_core_find_vma_block(device, blk->addr, blk->size); 419: 420: if (id < 0) { 421: dev_err(gmu_pdev_dev, 422: "Unknown block in GMU FW addr:0x%x size:0x%x\n", 423: blk->addr, blk->size); 424: return -EINVAL; 425: } 426: 427: if (id == GMU_ITCM) { 428: load_tcm(adreno_dev, fw, 429: GEN8_GMU_CM3_ITCM_START, 430: device->gmu_core.vma[GMU_ITCM].start, blk); 431: } else if (id == GMU_DTCM) { 432: load_tcm(adreno_dev, fw, 433: GEN8_GMU_CM3_DTCM_START, 434: device->gmu_core.vma[GMU_DTCM].start, blk); 435: } else { 436: struct kgsl_memdesc *md = 437: gmu_core_find_memdesc(device, blk->addr, blk->size); 438: 439: if (!md) { 440: dev_err(gmu_pdev_dev, 441: "No backing memory for GMU FW block addr:0x%x size:0x%x\n", 442: blk->addr, blk->size); 443: return -EINVAL; 444: } 445: 446: memcpy(md->hostptr + (blk->addr - md->gmuaddr), fw, 447: blk->size); 448: } 449: 450: fw += blk->size; 451: } 452: 453: /* Proceed only after the FW is written */ 454: wmb(); 455: return 0; 456: } 457: 458: static const char *oob_to_str(enum oob_request req) 459: { 460: switch (req) { 461: case oob_gpu: 462: return "oob_gpu"; 463: case oob_perfcntr: 464: return "oob_perfcntr"; 465: case oob_boot_slumber: 466: return "oob_boot_slumber"; 467: case oob_dcvs: 468: return "oob_dcvs"; 469: default: 470: return "unknown"; 471: } 472: } 473: 474: static void trigger_reset_recovery(struct adreno_device *adreno_dev, 475: enum oob_request req) 476: { 477: /* 478: * Trigger recovery for perfcounter oob only since only 479: * perfcounter oob can happen alongside an actively rendering gpu. 480: */ 481: if (req != oob_perfcntr) 482: return; 483: 484: adreno_scheduler_fault(adreno_dev, ADRENO_GMU_FAULT_SKIP_SNAPSHOT); 485: } 486: 487: int gen8_gmu_oob_set(struct kgsl_device *device, 488: enum oob_request req) 489: { 490: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 491: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 492: int ret = 0; 493: int set, check; 494: 495: if (req == oob_perfcntr && gmu->num_oob_perfcntr++) 496: return 0; 497: 498: if (req >= oob_boot_slumber) { 499: dev_err(GMU_PDEV_DEV(device), 500: "Unsupported OOB request %s\n", 501: oob_to_str(req)); 502: return -EINVAL; 503: } 504: 505: set = BIT(30 - req * 2); 506: check = BIT(31 - req); 507: 508: gmu_core_regwrite(device, GEN8_GMUCX_HOST2GMU_INTR_SET, set); 509: 510: if (gmu_core_timed_poll_check(device, GEN8_GMUCX_GMU2HOST_INTR_INFO, check, 511: 100, check)) { 512: if (req == oob_perfcntr) 513: gmu->num_oob_perfcntr--; 514: WARN(1, "OOB request %s timed out\n", oob_to_str(req)); 515: ret = -ETIMEDOUT; 516: gmu_core_fault_snapshot(device, GMU_FAULT_OOB_SET); 517: trigger_reset_recovery(adreno_dev, req); 518: } 519: 520: gmu_core_regwrite(device, GEN8_GMUCX_GMU2HOST_INTR_CLR, check); 521: 522: trace_kgsl_gmu_oob_set(set); 523: return ret; 524: } 525: 526: void gen8_gmu_oob_clear(struct kgsl_device *device, 527: enum oob_request req) 528: { 529: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 530: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 531: int clear = BIT(31 - req * 2); 532: 533: if (req == oob_perfcntr && --gmu->num_oob_perfcntr) 534: return; 535: 536: if (req >= oob_boot_slumber) { 537: dev_err(GMU_PDEV_DEV(device), "Unsupported OOB clear %s\n", 538: oob_to_str(req)); 539: return; 540: } 541: 542: gmu_core_regwrite(device, GEN8_GMUCX_HOST2GMU_INTR_SET, clear); 543: trace_kgsl_gmu_oob_clear(clear); 544: } 545: 546: void gen8_gmu_irq_enable(struct adreno_device *adreno_dev) 547: { 548: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 549: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 550: struct gen8_hfi *hfi = &gmu->hfi; 551: 552: /* Clear pending IRQs and Unmask needed IRQs */ 553: gmu_core_regwrite(device, GEN8_GMUCX_GMU2HOST_INTR_CLR, UINT_MAX); 554: gmu_core_regwrite(device, GEN8_GMUAO_AO_HOST_INTERRUPT_CLR, UINT_MAX); 555: 556: gmu_core_regwrite(device, GEN8_GMUCX_GMU2HOST_INTR_MASK, 557: (u32)~HFI_IRQ_MASK); 558: gmu_core_regwrite(device, GEN8_GMUAO_AO_HOST_INTERRUPT_MASK, 559: (u32)~GMU_AO_INT_MASK); 560: 561: /* Enable all IRQs on host */ 562: enable_irq(hfi->irq); 563: enable_irq(gmu->irq); 564: 565: if (device->cx_host_irq_num <= 0) 566: return; 567: 568: /* Clear pending IRQs, unmask needed interrupts and enable CX host IRQ */ 569: kgsl_regwrite(device, GEN8_GPU_CX_MISC_INT_CLEAR_CMD, UINT_MAX); 570: kgsl_regwrite(device, GEN8_GPU_CX_MISC_INT_0_MASK, GEN8_CX_MISC_INT_MASK); 571: enable_irq(device->cx_host_irq_num); 572: } 573: 574: void gen8_gmu_irq_disable(struct adreno_device *adreno_dev) 575: { 576: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 577: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 578: struct gen8_hfi *hfi = &gmu->hfi; 579: 580: /* Disable all IRQs on host */ 581: disable_irq(gmu->irq); 582: disable_irq(hfi->irq); 583: 584: /* Mask all IRQs and clear pending IRQs */ 585: gmu_core_regwrite(device, GEN8_GMUCX_GMU2HOST_INTR_MASK, UINT_MAX); 586: gmu_core_regwrite(device, GEN8_GMUAO_AO_HOST_INTERRUPT_MASK, UINT_MAX); 587: 588: gmu_core_regwrite(device, GEN8_GMUCX_GMU2HOST_INTR_CLR, UINT_MAX); 589: gmu_core_regwrite(device, GEN8_GMUAO_AO_HOST_INTERRUPT_CLR, UINT_MAX); 590: 591: if (device->cx_host_irq_num <= 0) 592: return; 593: 594: /* Disable CX host IRQ, mask all interrupts and clear pending IRQs */ 595: disable_irq(device->cx_host_irq_num); 596: kgsl_regwrite(device, GEN8_GPU_CX_MISC_INT_0_MASK, UINT_MAX); 597: kgsl_regwrite(device, GEN8_GPU_CX_MISC_INT_CLEAR_CMD, UINT_MAX); 598: } 599: 600: static int gen8_gmu_hfi_start_msg(struct adreno_device *adreno_dev) 601: { 602: struct hfi_start_cmd req; 603: int ret; 604: 605: ret = CMD_MSG_HDR(req, H2F_MSG_START); 606: if (ret) 607: return ret; 608: 609: return gen8_hfi_send_generic_req(adreno_dev, &req, sizeof(req)); 610: } 611: 612: static u32 gen8_rscc_tcsm_drv0_status_reglist[] = { 613: GEN8_RSCC_TCS0_DRV0_STATUS, 614: GEN8_RSCC_TCS1_DRV0_STATUS, 615: GEN8_RSCC_TCS2_DRV0_STATUS, 616: GEN8_RSCC_TCS3_DRV0_STATUS, 617: GEN8_RSCC_TCS4_DRV0_STATUS, 618: GEN8_RSCC_TCS5_DRV0_STATUS, 619: GEN8_RSCC_TCS6_DRV0_STATUS, 620: GEN8_RSCC_TCS7_DRV0_STATUS, 621: GEN8_RSCC_TCS8_DRV0_STATUS, 622: GEN8_RSCC_TCS9_DRV0_STATUS, 623: }; 624: 625: static int gen8_complete_rpmh_votes(struct gen8_gmu_device *gmu, 626: u32 timeout) 627: { 628: struct kgsl_device *device = KGSL_DEVICE(gen8_gmu_to_adreno(gmu)); 629: int i, ret = 0; 630: 631: for (i = 0; i < ARRAY_SIZE(gen8_rscc_tcsm_drv0_status_reglist); i++) 632: ret |= gen8_timed_poll_check_rscc(gmu, 633: gen8_rscc_tcsm_drv0_status_reglist[i], BIT(0), timeout, 634: BIT(0)); 635: 636: if (ret) 637: dev_err(GMU_PDEV_DEV(device), "RPMH votes timedout: %d\n", ret); 638: 639: return ret; 640: } 641: 642: #define GX_GDSC_POWER_OFF BIT(0) 643: #define GX_CLK_OFF BIT(1) 644: #define MALU_GDSC_POWER_OFF BIT(9) 645: #define MALU_CLK_OFF BIT(10) 646: #define CX_MISC_GX_GDSC_POWER_OFF BIT(3) 647: #define CX_MISC_GX_CLK_OFF BIT(4) 648: 649: #define is_on(val) (!(val & (GX_GDSC_POWER_OFF | GX_CLK_OFF))) 650: #define is_cx_misc_gx_on(val) (!(val & (CX_MISC_GX_GDSC_POWER_OFF | CX_MISC_GX_CLK_OFF))) 651: #define is_malu_on(val) (!(val & (MALU_GDSC_POWER_OFF | MALU_CLK_OFF))) 652: 653: bool gen8_gmu_gx_is_on(struct adreno_device *adreno_dev) 654: { 655: u32 val = 0; 656: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 657: 658: if (adreno_is_gen8_11_x(adreno_dev)) { 659: kgsl_regread(device, GEN8_GPU_CX_MISC_GFX_PWR_CLK_STATUS, &val); 660: return is_cx_misc_gx_on(val); 661: } 662: 663: gmu_core_regread(device, GEN8_GMUCX_GFX_PWR_CLK_STATUS, &val); 664: return is_on(val); 665: } 666: 667: bool gen8_gmu_malu_is_on(struct adreno_device *adreno_dev) 668: { 669: u32 val; 670: 671: kgsl_regread(KGSL_DEVICE(adreno_dev), 672: GEN8_GPU_CX_MISC_GFX_PWR_CLK_STATUS, &val); 673: return is_malu_on(val); 674: } 675: 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) 783: { 784: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 785: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 786: u32 status2; 787: u64 ts1; 788: 789: ts1 = gpudev->read_alwayson(adreno_dev); 790: if (gmu_core_timed_poll_check(device, GEN8_GMUAO_GPU_CX_BUSY_STATUS, 791: 0, 100, CXGXCPUBUSYIGNAHB)) { 792: gmu_core_regread(device, 793: GEN8_GMUAO_GPU_CX_BUSY_STATUS2, &status2); 794: dev_err(GMU_PDEV_DEV(device), 795: "GMU not idling: status2=0x%x %llx %llx\n", 796: status2, ts1, 797: gpudev->read_alwayson(adreno_dev)); 798: gmu_core_fault_snapshot(device, GMU_FAULT_WAIT_FOR_IDLE); 799: return -ETIMEDOUT; 800: } 801: 802: return 0; 803: } 804: 805: int gen8_gmu_version_info(struct adreno_device *adreno_dev) 806: { 807: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 808: struct gmu_core_device *gmu = &device->gmu_core; 809: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev); 810: 811: if (gmu_core_capabilities_enabled(&device->gmu_core.common_caps, 812: FCC_VERSION_INFO)) 813: goto done; 814: 815: /* GMU version info is at a fixed offset in the DTCM */ 816: gmu_core_regread(device, GEN8_GMU_CM3_DTCM_START + 0xff8, 817: &gmu->ver.core); 818: gmu_core_regread(device, GEN8_GMU_CM3_DTCM_START + 0xff9, 819: &gmu->ver.core_dev); 820: gmu_core_regread(device, GEN8_GMU_CM3_DTCM_START + 0xffa, 821: &gmu->ver.pwr); 822: gmu_core_regread(device, GEN8_GMU_CM3_DTCM_START + 0xffb, 823: &gmu->ver.pwr_dev); 824: gmu_core_regread(device, GEN8_GMU_CM3_DTCM_START + 0xffc, 825: &gmu->ver.hfi); 826: 827: done: 828: /* Check if gmu fw version on device is compatible with kgsl driver */ 829: if (gmu->ver.core < gen8_core->gmu_fw_version) { 830: dev_err_once(GMU_PDEV_DEV(device), 831: "GMU FW version 0x%x error (expected 0x%x)\n", 832: gmu->ver.core, gen8_core->gmu_fw_version); 833: return -EINVAL; 834: } 835: return 0; 836: } 837: 838: int gen8_gmu_itcm_shadow(struct adreno_device *adreno_dev) 839: { 840: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 841: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 842: u32 i, *dest; 843: 844: if (gmu->itcm_shadow) 845: return 0; 846: 847: gmu->itcm_shadow = vzalloc(device->gmu_core.vma[GMU_ITCM].size); 848: if (!gmu->itcm_shadow) 849: return -ENOMEM; 850: 851: dest = (u32 *)gmu->itcm_shadow; 852: 853: for (i = 0; i < (device->gmu_core.vma[GMU_ITCM].size >> 2); i++) 854: gmu_core_regread(KGSL_DEVICE(adreno_dev), 855: GEN8_GMU_CM3_ITCM_START + i, dest++); 856: 857: return 0; 858: } 859: 860: void gen8_gmu_register_config(struct adreno_device *adreno_dev) 861: { 862: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 863: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev); 864: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 865: u32 val; 866: 867: /* Clear any previously set cm3 fault */ 868: atomic_set(&gmu->cm3_fault, 0); 869: 870: /* Init the power state register before GMU turns on GX */ 871: gmu_core_regwrite(device, GEN8_GMUCX_RPMH_POWER_STATE, 0xF); 872: 873: /* Vote veto for FAL10 */ 874: gmu_core_regwrite(device, GEN8_GMUCX_CX_FALNEXT_INTF, 0x1); 875: gmu_core_regwrite(device, GEN8_GMUCX_CX_FAL_INTF, 0x1); 876: 877: /* Clear init result to make sure we are getting fresh value */ 878: gmu_core_regwrite(device, GEN8_GMUCX_CM3_FW_INIT_RESULT, 0); 879: gmu_core_regwrite(device, GEN8_GMUCX_CM3_BOOT_CONFIG, 0x2); 880: 881: gmu_core_regwrite(device, GEN8_GMUCX_HFI_QTBL_ADDR, 882: gmu->hfi.hfi_mem->gmuaddr); 883: gmu_core_regwrite(device, GEN8_GMUCX_HFI_QTBL_INFO, 1); 884: 885: gmu_core_regwrite(device, GEN8_GMUAO_AHB_FENCE_RANGE_0, BIT(31) | 886: FIELD_PREP(GENMASK(30, 18), 0x32) | 887: FIELD_PREP(GENMASK(17, 0), GEN8_CP_CONTEXT_SWITCH_CNTL)); 888: 889: /* 890: * Make sure that CM3 state is at reset value. Snapshot is changing 891: * NMI bit and if we boot up GMU with NMI bit set GMU will boot 892: * straight in to NMI handler without executing __main code 893: */ 894: gmu_core_regwrite(device, GEN8_GMUCX_CM3_CFG, 0x4052); 895: 896: /* Set up GBIF registers from the GPU core definition */ 897: kgsl_regmap_multi_write(&device->regmap, gen8_core->gbif, 898: gen8_core->gbif_count); 899: 900: /** 901: * We may have asserted gbif halt as part of reset sequence which may 902: * not get cleared if the gdsc was not reset. So clear it before 903: * attempting GMU boot. 904: */ 905: kgsl_regwrite(device, GEN8_GBIF_HALT, BIT(3)); 906: 907: /* Set vrb address before starting GMU */ 908: if (!IS_ERR_OR_NULL(device->gmu_core.vrb)) 909: gmu_core_regwrite(device, GEN8_GMUCX_GENERAL_11, device->gmu_core.vrb->gmuaddr); 910: 911: /* Set the log wptr index */ 912: gmu_core_regwrite(device, GEN8_GMUCX_GENERAL_9, 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) 950: return 0; 951: 952: if (blk->type == GMU_BLOCK_ID_COMMON_CAPS) 953: caps = &gmu_core->common_caps; 954: else if (blk->type == GMU_BLOCK_ID_PLATFORM_CAPS) 955: caps = &gmu_core->platform_caps; 956: else 957: return 0; 958: 959: if (caps->data) 960: return 0; 961: 962: caps->length = blk->size; 963: caps->data = kmalloc_array(caps->length, sizeof(u8), GFP_KERNEL); 964: if (!caps->data) 965: return -ENOMEM; 966: 967: memcpy(caps->data, payload, caps->length); 968: 969: return 0; 970: } 971: 972: static int gen8_gmu_process_zero_length_block(struct kgsl_device *device, 973: struct gmu_block_header *blk) 974: { 975: struct gmu_core_device *gmu = &device->gmu_core; 976: int ret = 0; 977: 978: switch (blk->type) { 979: case GMU_FIELD_PREALLOC: 980: case GMU_FIELD_PREALLOC_PERSISTENT: 981: ret = gmu_core_process_prealloc(device, blk); 982: break; 983: case GMU_FIELD_CORE_VERSION: 984: gmu->ver.core = blk->value; 985: break; 986: case GMU_FIELD_CORE_DEV_VERSION: 987: gmu->ver.core_dev = blk->value; 988: break; 989: case GMU_FIELD_PWR_VERSION: 990: gmu->ver.pwr = blk->value; 991: break; 992: case GMU_FIELD_PWR_DEV_VERSION: 993: gmu->ver.pwr_dev = blk->value; 994: break; 995: case GMU_FIELD_HFI_VERSION: 996: gmu->ver.hfi = blk->value; 997: break; 998: default: 999: dev_err(GMU_PDEV_DEV(device), "Unknown FW block type:%d\n", blk->type); 1000: } 1001: 1002: return ret; 1003: } 1004: 1005: int gen8_gmu_parse_fw(struct adreno_device *adreno_dev) 1006: { 1007: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1008: struct device *gmu_pdev_dev = GMU_PDEV_DEV(device); 1009: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1010: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev); 1011: struct gmu_block_header *blk; 1012: const char *gmufw_name = gen8_core->gmufw_name; 1013: int ret = 0; 1014: u32 offset = 0; 1015: 1016: /* 1017: * If GMU fw already saved and verified, do nothing new. 1018: * Skip only requesting firmware and allow preallocation to 1019: * ensure in scenario where GMU request firmware succeeded 1020: * but preallocation fails, we don't return early without 1021: * successful preallocations on next open call. 1022: */ 1023: if (!gmu->fw_image) { 1024: 1025: if (gen8_core->gmufw_name == NULL) 1026: return -EINVAL; 1027: 1028: ret = adreno_request_firmware(&gmu->fw_image, gmufw_name, 1029: gmu_pdev_dev, true); 1030: if (ret) 1031: return ret; 1032: } 1033: 1034: /* 1035: * Zero payload fw blocks contain metadata and are 1036: * guaranteed to precede fw load data. Parse the 1037: * metadata blocks. 1038: */ 1039: while (offset < gmu->fw_image->size) { 1040: blk = (struct gmu_block_header *)&gmu->fw_image->data[offset]; 1041: 1042: if (offset + sizeof(*blk) > gmu->fw_image->size) { 1043: dev_err(gmu_pdev_dev, "Invalid FW Block\n"); 1044: return -EINVAL; 1045: } 1046: 1047: offset += sizeof(*blk); 1048: 1049: /* process zero length blocks */ 1050: if (!blk->size) { 1051: ret = gen8_gmu_process_zero_length_block(device, blk); 1052: if (ret) 1053: return ret; 1054: } else { 1055: ret = gen8_gmu_process_caps(gmu, &device->gmu_core, blk, offset); 1056: if (ret) 1057: return ret; 1058: offset += blk->size; 1059: } 1060: } 1061: 1062: return ret; 1063: } 1064: 1065: int gen8_gmu_memory_init(struct adreno_device *adreno_dev) 1066: { 1067: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1068: struct kgsl_device *device = KGSL_DEVICE(gen8_gmu_to_adreno(gmu)); 1069: 1070: /* GMU master log */ 1071: if (IS_ERR_OR_NULL(gmu->gmu_log)) 1072: gmu->gmu_log = gmu_core_reserve_kernel_block(device, 0, 1073: GMU_LOG_SIZE, GMU_NONCACHED_KERNEL, 0); 1074: 1075: return PTR_ERR_OR_ZERO(gmu->gmu_log); 1076: } 1077: 1078: static int gen8_gmu_init(struct adreno_device *adreno_dev) 1079: { 1080: int ret; 1081: 1082: ret = gen8_gmu_parse_fw(adreno_dev); 1083: if (ret) 1084: return ret; 1085: 1086: ret = gen8_gmu_memory_init(adreno_dev); 1087: if (ret) 1088: return ret; 1089: 1090: return gen8_hfi_init(adreno_dev); 1091: } 1092: 1093: static void _do_gbif_halt(struct kgsl_device *device, u32 reg, u32 ack_reg, 1094: u32 mask, const char *client) 1095: { 1096: u32 ack; 1097: unsigned long t; 1098: 1099: kgsl_regwrite(device, reg, mask); 1100: 1101: t = jiffies + msecs_to_jiffies(100); 1102: do { 1103: kgsl_regread(device, ack_reg, &ack); 1104: if ((ack & mask) == mask) 1105: return; 1106: 1107: /* 1108: * If we are attempting recovery in case of stall-on-fault 1109: * then the halt sequence will not complete as long as SMMU 1110: * is stalled. 1111: */ 1112: kgsl_mmu_pagefault_resume(&device->mmu, false); 1113: 1114: usleep_range(10, 100); MATCH LINES: 1173, 1179, 1183, 1184, 1188, 1191, 1192, 1196, 1198, 1207, 1213, 1214, 1219, 1234, 1251, 1252, 1256, 1259, 1263, 1267, 1273, 1276, 1282, 1285, 1291, 1296, 1303, 1305, 1311, 1313, 1318, 1323, 1325, 1332, 1346, 1356, 1358, 1366, 1367, 1368, 1372, 1377, 1379, 1382, 1386, 1412, 1415, 1428, 1430, 1436, 1437, 1442, 1449, 1450, 1472, 1479, 1485, 1494, 1495, 1498, 1502, 1503, 1509, 1513, 1514, 1520, 1522, 1524, 1528, 1532, 1534, 1535, 1545, 1550, 1556, 1557, 1558, 1560, 1562, 1566, 1574, 1575, 1577, 1578, 1581, 1584, 1587, 1589, 1593, 1594, 1596, 1601, 1603, 1616, 1620, 1624, 1629, 1639, 1659, 1663, 1667, 1671, 1673, 1682, 1686, 1692, 1696, 1697, 1700, 1702, 1703, 1708, 1715, 1717, 1718, 1723, 1729, 1734, 1749, 1767, 1771, 1773, 1778, 1782, 1786, 1790, 1797, 1799, 1800, 1805, 1811, 1818, 1821, 1824, 1827 1161: 1162: #define GDSC_SW_COLLAPSE BIT(0) 1163: #define GDSC_CFG_POWER_DOWN_COMPLETE BIT(15) 1164: 1165: static void _disable_malu_gdsc(struct adreno_device *adreno_dev) 1166: { 1167: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1168: u32 reg; 1169: 1170: if (!adreno_dev->malu_enabled) 1171: return; 1172: 1173: if (!gen8_gmu_malu_is_on(adreno_dev)) 1174: return; 1175: 1176: /* Make sure we turn off the MALU if it was on */ 1177: kgsl_regwrite(device, GEN8_GPU_GX_CLKCTL_GX_MALU_GDSCR, GDSC_SW_COLLAPSE); 1178: 1179: if (gmu_core_timed_poll_check(device, GEN8_GPU_GX_CLKCTL_GX_MALU_CFG_GDSCR, 1180: GDSC_CFG_POWER_DOWN_COMPLETE, MALU_GDSC_TIMEOUT_MS, 1181: GDSC_CFG_POWER_DOWN_COMPLETE)) { 1182: 1183: gmu_core_regread(device, GEN8_GPU_GX_CLKCTL_GX_MALU_CFG_GDSCR, ®); 1184: dev_err(GMU_PDEV_DEV(device), "malu cfg gdsc stuck on:0x%x\n", reg); 1185: return; 1186: } 1187: 1188: if (gmu_core_timed_poll_check(device, GEN8_GPU_CX_MISC_GFX_PWR_CLK_STATUS, 1189: MALU_GDSC_POWER_OFF | MALU_CLK_OFF, MALU_GDSC_TIMEOUT_MS, 1190: MALU_GDSC_POWER_OFF | MALU_CLK_OFF)) { 1191: gmu_core_regread(device, GEN8_GPU_CX_MISC_GFX_PWR_CLK_STATUS, ®); 1192: dev_err(GMU_PDEV_DEV(device), "malu gdsc stuck on:0x%x\n", reg); 1193: } 1194: } 1195: 1196: static void gen8_gmu_pwrctrl_suspend(struct adreno_device *adreno_dev) 1197: { 1198: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1199: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1200: 1201: /* Disconnect GPU from BUS is not needed if CX GDSC goes off later */ 1202: 1203: /* 1204: * GEMNOC can enter power collapse state during GPU power down sequence. 1205: * This could abort CX GDSC collapse. Assert Qactive to avoid this. 1206: */ 1207: gmu_core_regwrite(device, GEN8_GMUCX_CX_FALNEXT_INTF, 0x1); 1208: 1209: /* Check no outstanding RPMh voting */ 1210: gen8_complete_rpmh_votes(gmu, 1); 1211: 1212: /* Clear the WRITEDROPPED fields and set fence to allow mode */ 1213: gmu_core_regwrite(device, GEN8_GMUAO_AHB_FENCE_STATUS_CLR, 0x7); 1214: gmu_core_regwrite(device, GEN8_GMUAO_AHB_FENCE_CTRL, 0); 1215: 1216: /* Make sure above writes are committed before we proceed to recovery */ 1217: wmb(); 1218: 1219: gmu_core_regwrite(device, GEN8_GMUCX_CM3_SYSRESET, 1); 1220: 1221: /* Flush out pending GX transactions using GBIF reinit mechanism */ 1222: gen8_gbif_gx_reinit(device); 1223: 1224: /* Halt CX traffic */ 1225: _do_gbif_halt(device, GEN8_GBIF_HALT, GEN8_GBIF_HALT_ACK, 1226: GEN8_GBIF_ARB_HALT_MASK, "CX"); 1227: 1228: _disable_malu_gdsc(adreno_dev); 1229: 1230: /* 1231: * Switch gx gdsc control from GMU to CPU force non-zero reference 1232: * count in clk driver so next disable call will turn off the GDSC 1233: */ 1234: if (gen8_gmu_gx_is_on(adreno_dev)) { 1235: kgsl_pwrctrl_enable_gx_gdsc(device); 1236: /* 1237: * The gxclkctl driver implements a custom disable callback that prevents 1238: * the OS from collapsing GX GDSC unless the GenPD synced_poweroff flag 1239: * is set. 1240: */ 1241: gen8_genpd_synced_poweroff(device->pwrctrl.gx_pd); 1242: kgsl_pwrctrl_disable_gx_gdsc(device); 1243: } 1244: 1245: /* 1246: * Trigger RSC slumber sequence to turn off GMU controlled domains 1247: * (GX, MXC) and remove GPU bus votes 1248: */ 1249: gen8_rscc_sleep_sequence(adreno_dev); 1250: 1251: if (gen8_gmu_gx_is_on(adreno_dev)) 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. 1289: * This could abort CX GDSC collapse. Assert Qactive to avoid this. 1290: */ 1291: gmu_core_regwrite(device, GEN8_GMUCX_CX_FALNEXT_INTF, 0x1); 1292: 1293: return ret; 1294: } 1295: 1296: void gen8_gmu_suspend(struct adreno_device *adreno_dev, bool force) 1297: { 1298: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1299: 1300: if (!force && test_bit(ADRENO_DEVICE_RESET_RECOVERY, &adreno_dev->priv)) 1301: return; 1302: 1303: gen8_gmu_pwrctrl_suspend(adreno_dev); 1304: 1305: gmu_core_disable_clks(device); 1306: 1307: kgsl_pwrctrl_disable_mx_gdsc(device); 1308: 1309: kgsl_pwrctrl_disable_cx_gdsc(device); 1310: 1311: gmu_core_rdpm_cx_freq_update(device, 0); 1312: 1313: dev_err(GMU_PDEV_DEV(device), "Suspended GMU\n"); 1314: 1315: kgsl_pwrctrl_set_state(device, KGSL_STATE_NONE); 1316: } 1317: 1318: static int gen8_gmu_dcvs_set(struct adreno_device *adreno_dev, 1319: int gpu_pwrlevel, int bus_level, u32 ab) 1320: { 1321: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1322: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1323: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1324: struct gen8_dcvs_table *table = &gmu->dcvs_table; 1325: struct hfi_gx_bw_perf_vote_cmd req = { 1326: .ack_type = DCVS_ACK_BLOCK, 1327: .freq = INVALID_DCVS_IDX, 1328: .bw = INVALID_DCVS_IDX, 1329: }; 1330: int ret = 0; 1331: 1332: if (!test_bit(GMU_PRIV_HFI_STARTED, &gmu->flags)) 1333: return 0; 1334: 1335: /* Do not set to XO and lower GPU clock vote from GMU */ 1336: if ((gpu_pwrlevel != INVALID_DCVS_IDX) && 1337: (gpu_pwrlevel >= table->gpu_level_num - 1)) 1338: return -EINVAL; 1339: 1340: if (gpu_pwrlevel < table->gpu_level_num - 1) 1341: req.freq = table->gpu_level_num - gpu_pwrlevel - 1; 1342: 1343: if (bus_level < pwr->ddr_table_count && bus_level > 0) 1344: req.bw = bus_level; 1345: 1346: req.bw |= adreno_gmu_bus_ab_quantize(adreno_dev, ab); 1347: 1348: /* GMU will vote for slumber levels through the sleep sequence */ 1349: if ((req.freq == INVALID_DCVS_IDX) && (req.bw == INVALID_BW_VOTE)) 1350: return 0; 1351: 1352: ret = CMD_MSG_HDR(req, H2F_MSG_GX_BW_PERF_VOTE); 1353: if (ret) 1354: return ret; 1355: 1356: ret = gen8_hfi_send_generic_req(adreno_dev, &req, sizeof(req)); 1357: if (ret) { 1358: dev_err_ratelimited(GMU_PDEV_DEV(device), 1359: "Failed to set GPU perf idx %u, bw idx %u\n", 1360: req.freq, req.bw); 1361: 1362: /* 1363: * If this was a dcvs request along side an active gpu, request 1364: * dispatcher based reset and recovery. 1365: */ 1366: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 1367: adreno_scheduler_fault(adreno_dev, ADRENO_GMU_FAULT | 1368: ADRENO_GMU_FAULT_SKIP_SNAPSHOT); 1369: } 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; 1457: 1458: /* 1459: * We should not send NMI if there was a CM3 fault reported because we 1460: * don't want to overwrite the critical CM3 state captured by gmu before 1461: * it sent the CM3 fault interrupt. Also don't send NMI if GMU reset is 1462: * already active. We could have hit a GMU assert and NMI might have 1463: * already been triggered. 1464: */ 1465: 1466: /* make sure we're reading the latest cm3_fault */ 1467: smp_rmb(); 1468: 1469: if (atomic_read(&gmu->cm3_fault)) 1470: return; 1471: 1472: gmu_core_regread(device, GEN8_GMUCX_CM3_FW_INIT_RESULT, &result); 1473: 1474: if (result & 0xE00) 1475: return; 1476: 1477: nmi: 1478: /* Mask so there's no interrupt caused by NMI */ 1479: gmu_core_regwrite(device, GEN8_GMUCX_GMU2HOST_INTR_MASK, UINT_MAX); 1480: 1481: /* Make sure the interrupt is masked before causing it */ 1482: wmb(); 1483: 1484: /* This will cause the GMU to save it's internal state to ddr */ 1485: gmu_core_regrmw(device, GEN8_GMUCX_CM3_CFG, BIT(9), BIT(9)); 1486: 1487: /* Make sure the NMI is invoked before we proceed*/ 1488: wmb(); 1489: 1490: /* Wait for the NMI to be handled */ 1491: udelay(200); 1492: 1493: done: 1494: KGSL_GMU_CORE_FORCE_PANIC(device->gmu_core.gf_panic, 1495: GMU_PDEV(device), ticks, gf_policy); 1496: } 1497: 1498: static void gen8_gmu_cooperative_reset(struct kgsl_device *device) 1499: { 1500: u32 result; 1501: 1502: gmu_core_regwrite(device, GEN8_GMUCX_WDOG_CTRL, 0); 1503: gmu_core_regwrite(device, GEN8_GMUCX_HOST2GMU_INTR_SET, BIT(17)); 1504: 1505: /* 1506: * After triggering graceful death wait for snapshot ready 1507: * indication from GMU. 1508: */ 1509: if (!gmu_core_timed_poll_check(device, GEN8_GMUCX_CM3_FW_INIT_RESULT, 1510: 0x800, 2, 0x800)) 1511: return; 1512: 1513: gmu_core_regread(device, GEN8_GMUCX_CM3_FW_INIT_RESULT, &result); 1514: dev_err(GMU_PDEV_DEV(device), 1515: "GMU cooperative reset timed out 0x%x\n", result); 1516: /* 1517: * If we dont get a snapshot ready from GMU, trigger NMI 1518: * and if we still timeout then we just continue with reset. 1519: */ 1520: gen8_gmu_send_nmi(device, true, GMU_FAULT_PANIC_NONE); 1521: 1522: gmu_core_regread(device, GEN8_GMUCX_CM3_FW_INIT_RESULT, &result); 1523: if ((result & 0x800) != 0x800) 1524: dev_err(GMU_PDEV_DEV(device), 1525: "GMU cooperative reset NMI timed out 0x%x\n", result); 1526: } 1527: 1528: static int gen8_gmu_wait_for_active_transition(struct kgsl_device *device) 1529: { 1530: u32 reg; 1531: 1532: if (gmu_core_timed_poll_check(device, GEN8_GMUCX_RPMH_POWER_STATE, 1533: GPU_HW_ACTIVE, 100, GENMASK(3, 0))) { 1534: gmu_core_regread(device, GEN8_GMUCX_RPMH_POWER_STATE, ®); 1535: dev_err(GMU_PDEV_DEV(device), 1536: "GMU failed to move to ACTIVE state, Current state: 0x%x\n", 1537: reg); 1538: 1539: return -ETIMEDOUT; 1540: } 1541: 1542: return 0; 1543: } 1544: 1545: static bool gen8_gmu_scales_bandwidth(struct kgsl_device *device) 1546: { 1547: return true; 1548: } 1549: 1550: void gen8_gmu_handle_watchdog(struct adreno_device *adreno_dev) 1551: { 1552: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1553: u32 mask; 1554: 1555: /* Temporarily mask the watchdog interrupt to prevent a storm */ 1556: gmu_core_regread(device, GEN8_GMUAO_AO_HOST_INTERRUPT_MASK, &mask); 1557: gmu_core_regwrite(device, GEN8_GMUAO_AO_HOST_INTERRUPT_MASK, 1558: (mask | GMU_INT_WDOG_BITE)); 1559: 1560: gen8_gmu_send_nmi(device, false, GMU_FAULT_PANIC_NONE); 1561: 1562: dev_err_ratelimited(GMU_PDEV_DEV(device), 1563: "GMU watchdog expired interrupt received\n"); 1564: } 1565: 1566: static irqreturn_t gen8_gmu_irq_handler(int irq, void *data) 1567: { 1568: struct kgsl_device *device = data; 1569: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1570: const struct gen8_gpudev *gen8_gpudev = 1571: to_gen8_gpudev(ADRENO_GPU_DEVICE(adreno_dev)); 1572: u32 status = 0; 1573: 1574: gmu_core_regread(device, GEN8_GMUAO_AO_HOST_INTERRUPT_STATUS, &status); 1575: gmu_core_regwrite(device, GEN8_GMUAO_AO_HOST_INTERRUPT_CLR, status); 1576: 1577: if (status & GMU_INT_HOST_AHB_BUS_ERR) 1578: dev_err_ratelimited(GMU_PDEV_DEV(device), 1579: "AHB bus error interrupt received\n"); 1580: 1581: if (status & GMU_INT_WDOG_BITE) 1582: gen8_gpudev->handle_watchdog(adreno_dev); 1583: 1584: if (status & GMU_INT_FENCE_ERR) { 1585: u32 fence_status; 1586: 1587: gmu_core_regread(device, GEN8_GMUAO_AHB_FENCE_STATUS, 1588: &fence_status); 1589: dev_err_ratelimited(GMU_PDEV_DEV(device), 1590: "FENCE error interrupt received %x\n", fence_status); 1591: } 1592: 1593: if (status & ~GMU_AO_INT_MASK) 1594: dev_err_ratelimited(GMU_PDEV_DEV(device), 1595: "Unhandled GMU interrupts 0x%lx\n", 1596: status & ~GMU_AO_INT_MASK); 1597: 1598: return IRQ_HANDLED; 1599: } 1600: 1601: void gen8_gmu_aop_send_acd_state(struct gen8_gmu_device *gmu, bool flag) 1602: { 1603: struct kgsl_device *device = KGSL_DEVICE(gen8_gmu_to_adreno(gmu)); 1604: char msg_buf[36]; 1605: u32 size; 1606: int ret; 1607: 1608: if (IS_ERR_OR_NULL(gmu->qmp)) 1609: return; 1610: 1611: size = scnprintf(msg_buf, sizeof(msg_buf), 1612: "{class: gpu, res: acd, val: %d}", flag); 1613: 1614: ret = qmp_send(gmu->qmp, msg_buf, ALIGN((size + 1), SZ_4)); 1615: if (ret < 0) 1616: dev_err(GMU_PDEV_DEV(device), 1617: "AOP qmp send message failed: %d\n", ret); 1618: } 1619: 1620: static int gen8_gmu_first_boot(struct adreno_device *adreno_dev) 1621: { 1622: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1623: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1624: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1625: int level, ret; 1626: 1627: kgsl_pwrctrl_request_state(device, KGSL_STATE_AWARE); 1628: 1629: gen8_gmu_aop_send_acd_state(gmu, adreno_dev->acd_enabled); 1630: 1631: ret = kgsl_pwrctrl_enable_cx_gdsc(device); 1632: if (ret) 1633: return ret; 1634: 1635: ret = kgsl_pwrctrl_enable_mx_gdsc(device); 1636: if (ret) 1637: goto cx_gdsc_off; 1638: 1639: ret = gmu_core_enable_clks(device, 0); 1640: if (ret) 1641: goto gdsc_off; 1642: 1643: ret = gen8_scm_gpu_init_cx_regs(adreno_dev); 1644: if (ret) 1645: goto clks_gdsc_off; 1646: 1647: gen8_get_gpu_slice_info(adreno_dev); 1648: 1649: /* 1650: * Enable AHB timeout detection to catch any register access taking longer 1651: * time before NOC timeout gets detected. Enable this logic before any 1652: * register access which happens to be just after enabling clocks. 1653: */ 1654: gen8_enable_ahb_timeout_detection(adreno_dev); 1655: 1656: /* Initialize the CX timer */ 1657: gen8_cx_timer_init(adreno_dev); 1658: 1659: ret = gen8_gmu_load_fw(adreno_dev); 1660: if (ret) 1661: goto clks_gdsc_off; 1662: 1663: ret = gen8_gmu_version_info(adreno_dev); 1664: if (ret) 1665: goto clks_gdsc_off; 1666: 1667: ret = gen8_gmu_itcm_shadow(adreno_dev); 1668: if (ret) 1669: goto clks_gdsc_off; 1670: 1671: gen8_gmu_register_config(adreno_dev); 1672: 1673: gen8_gmu_irq_enable(adreno_dev); 1674: 1675: /* Vote for minimal DDR BW for GMU to init */ 1676: level = pwr->pwrlevels[pwr->default_pwrlevel].bus_min; 1677: icc_set_bw(pwr->icc_path, 0, kBps_to_icc(pwr->ddr_table[level])); 1678: 1679: /* Clear any GPU faults that might have been left over */ 1680: adreno_clear_gpu_fault(adreno_dev); 1681: 1682: ret = gen8_gmu_device_start(adreno_dev); 1683: if (ret) 1684: goto err; 1685: 1686: ret = gen8_gmu_hfi_start(adreno_dev); 1687: if (ret) 1688: goto err; 1689: 1690: gen8_get_gpu_feature_info(adreno_dev); 1691: 1692: ret = gen8_hfi_start(adreno_dev); 1693: if (ret) 1694: goto err; 1695: 1696: if (adreno_dev->gmu_ab && 1697: gen8_hfi_send_get_value(adreno_dev, HFI_VALUE_GMU_AB_VOTE, 0) == 1 && 1698: !WARN_ONCE(!adreno_dev->gpucore->num_ddr_channels, 1699: "Number of DDR channel is not specified in gpu core")) { 1700: set_bit(ADRENO_DEVICE_GMU_AB, &adreno_dev->priv); 1701: } else { 1702: /* If gmu_ab feature flag is enabled but GMU doesn't support it, set it to false */ 1703: adreno_dev->gmu_ab = false; 1704: } 1705: 1706: icc_set_bw(pwr->icc_path, 0, 0); 1707: 1708: device->gmu_fault = false; 1709: 1710: kgsl_pwrctrl_set_state(device, KGSL_STATE_AWARE); 1711: 1712: return 0; 1713: 1714: err: 1715: gen8_gmu_irq_disable(adreno_dev); 1716: 1717: if (device->gmu_fault) { 1718: gen8_gmu_suspend(adreno_dev, false); 1719: return ret; 1720: } 1721: 1722: clks_gdsc_off: 1723: gmu_core_disable_clks(device); 1724: gdsc_off: 1725: kgsl_pwrctrl_disable_mx_gdsc(device); 1726: cx_gdsc_off: 1727: kgsl_pwrctrl_disable_cx_gdsc(device); 1728: 1729: gmu_core_rdpm_cx_freq_update(device, 0); 1730: 1731: return ret; 1732: } 1733: 1734: static int gen8_gmu_boot(struct adreno_device *adreno_dev) 1735: { 1736: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1737: int ret = 0; 1738: 1739: kgsl_pwrctrl_request_state(device, KGSL_STATE_AWARE); 1740: 1741: ret = kgsl_pwrctrl_enable_cx_gdsc(device); 1742: if (ret) 1743: return ret; 1744: 1745: ret = kgsl_pwrctrl_enable_mx_gdsc(device); 1746: if (ret) 1747: goto cx_gdsc_off; 1748: 1749: ret = gmu_core_enable_clks(device, 0); 1750: if (ret) 1751: goto gdsc_off; 1752: 1753: /* 1754: * Enable AHB timeout detection to catch any register access taking longer 1755: * time before NOC timeout gets detected. Enable this logic before any 1756: * register access which happens to be just after enabling clocks. 1757: */ 1758: gen8_enable_ahb_timeout_detection(adreno_dev); 1759: 1760: /* Initialize the CX timer */ 1761: gen8_cx_timer_init(adreno_dev); 1762: 1763: ret = gen8_rscc_wakeup_sequence(adreno_dev); 1764: if (ret) 1765: goto clks_gdsc_off; 1766: 1767: ret = gen8_gmu_load_fw(adreno_dev); 1768: if (ret) 1769: goto clks_gdsc_off; 1770: 1771: gen8_gmu_register_config(adreno_dev); 1772: 1773: gen8_gmu_irq_enable(adreno_dev); 1774: 1775: /* Clear any GPU faults that might have been left over */ 1776: adreno_clear_gpu_fault(adreno_dev); 1777: 1778: ret = gen8_gmu_device_start(adreno_dev); 1779: if (ret) 1780: goto err; 1781: 1782: ret = gen8_gmu_hfi_start(adreno_dev); 1783: if (ret) 1784: goto err; 1785: 1786: ret = gen8_hfi_start(adreno_dev); 1787: if (ret) 1788: goto err; 1789: 1790: device->gmu_fault = false; 1791: 1792: kgsl_pwrctrl_set_state(device, KGSL_STATE_AWARE); 1793: 1794: return 0; 1795: 1796: err: 1797: gen8_gmu_irq_disable(adreno_dev); 1798: 1799: if (device->gmu_fault) { 1800: gen8_gmu_suspend(adreno_dev, false); 1801: return ret; 1802: } 1803: 1804: clks_gdsc_off: 1805: gmu_core_disable_clks(device); 1806: gdsc_off: 1807: kgsl_pwrctrl_disable_mx_gdsc(device); 1808: cx_gdsc_off: 1809: kgsl_pwrctrl_disable_cx_gdsc(device); 1810: 1811: gmu_core_rdpm_cx_freq_update(device, 0); 1812: 1813: return ret; 1814: } 1815: 1816: static void set_acd(struct adreno_device *adreno_dev, void *priv) 1817: { 1818: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1819: 1820: adreno_dev->acd_enabled = *((bool *)priv); 1821: gen8_gmu_aop_send_acd_state(gmu, adreno_dev->acd_enabled); 1822: } 1823: 1824: static int gen8_gmu_acd_set(struct kgsl_device *device, bool val) 1825: { 1826: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1827: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1828: 1829: if (IS_ERR_OR_NULL(gmu->qmp)) 1830: return -EINVAL; 1831: 1832: /* Don't do any unneeded work if ACD is already in the correct state */ 1833: if (adreno_dev->acd_enabled == val) 1834: return 0; 1835: 1836: /* Power cycle the GPU for changes to take effect */ 1837: return adreno_power_cycle(adreno_dev, set_acd, &val); 1838: } 1839: 1840: #define BCL_RESP_TYPE_MASK BIT(0) 1841: #define BCL_SID0_MASK GENMASK(7, 1) 1842: #define BCL_SID1_MASK GENMASK(14, 8) 1843: #define BCL_SID2_MASK GENMASK(21, 15) 1844: 1845: static int gen8_bcl_sid_set(struct kgsl_device *device, u32 sid_id, u64 sid_val) 1846: { 1847: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1848: u32 bcl_data, val = (u32) sid_val; 1849: 1850: if (!ADRENO_FEATURE(adreno_dev, ADRENO_BCL) || 1851: !FIELD_GET(BCL_RESP_TYPE_MASK, adreno_dev->bcl_data)) MATCH LINES: 1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1902, 1905, 1909, 1919, 1925, 1934, 1943, 1944, 1946, 1948, 1956, 1957, 1963, 1969, 1993, 1995, 2003, 2006, 2011, 2014, 2016, 2017, 2019, 2023, 2040, 2051, 2058, 2061, 2070, 2071, 2074, 2080, 2084, 2087, 2093, 2098, 2099, 2100, 2104, 2106, 2107, 2108, 2109, 2111, 2112, 2115, 2117, 2118, 2125, 2131, 2136, 2140, 2141, 2143, 2144, 2151, 2155, 2156, 2165, 2168, 2171, 2172, 2177, 2179, 2181, 2182, 2189, 2194, 2196, 2209, 2210, 2218, 2243, 2245, 2249, 2253, 2261, 2265, 2273, 2280, 2282, 2284, 2290, 2297, 2298, 2299, 2317, 2333, 2335, 2337, 2339, 2364, 2380, 2384, 2385, 2388, 2393, 2403, 2407, 2412, 2423, 2435, 2438, 2439, 2457, 2463, 2482, 2483 1882: switch (sid_id) { 1883: case 0: 1884: return ((u64) FIELD_GET(BCL_SID0_MASK, adreno_dev->bcl_data)); 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)) 1923: return 0; 1924: 1925: ret = gen8_gmu_dcvs_set(adreno_dev, INVALID_DCVS_IDX, 1926: buslevel, ab); 1927: if (ret) 1928: return ret; 1929: 1930: if (buslevel != INVALID_DCVS_IDX) 1931: pwr->cur_buslevel = buslevel; 1932: 1933: if (ab != INVALID_AB_VALUE) { 1934: if (!adreno_dev->gmu_ab) 1935: icc_set_bw(pwr->icc_path, MBps_to_icc(ab), 0); 1936: pwr->cur_ab = ab; 1937: } 1938: 1939: trace_kgsl_buslevel(device, pwr->active_pwrlevel, pwr->cur_buslevel, pwr->cur_ab, 0); 1940: return ret; 1941: } 1942: 1943: static int gen8_gmu_qmp_aoss_init(struct adreno_device *adreno_dev, 1944: struct gen8_gmu_device *gmu) 1945: { 1946: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)); 1947: 1948: gmu->qmp = qmp_get(gmu_pdev_dev); 1949: if (IS_ERR(gmu->qmp)) 1950: return PTR_ERR(gmu->qmp); 1951: 1952: adreno_dev->acd_enabled = true; 1953: return 0; 1954: } 1955: 1956: static void gen8_gmu_acd_probe(struct kgsl_device *device, 1957: struct gen8_gmu_device *gmu, struct device_node *node) 1958: { 1959: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1960: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1961: struct kgsl_pwrlevel *pwrlevel = 1962: &pwr->pwrlevels[pwr->num_pwrlevels - 1]; 1963: struct hfi_acd_table_cmd *cmd = &gmu->hfi.acd_table; 1964: int ret, i, cmd_idx = 0; 1965: 1966: if (!ADRENO_FEATURE(adreno_dev, ADRENO_ACD)) 1967: return; 1968: 1969: cmd->hdr = CREATE_MSG_HDR(H2F_MSG_ACD_TBL, HFI_MSG_CMD); 1970: 1971: cmd->version = 1; 1972: cmd->stride = 1; 1973: cmd->enable_by_level = 0; 1974: 1975: /* 1976: * Iterate through each gpu power level and generate a mask for GMU 1977: * firmware for ACD enabled levels and store the corresponding control 1978: * register configurations to the acd_table structure. 1979: */ 1980: for (i = 0; i < pwr->num_pwrlevels; i++) { 1981: if (pwrlevel->acd_level) { 1982: cmd->enable_by_level |= (1 << (i + 1)); 1983: cmd->data[cmd_idx++] = pwrlevel->acd_level; 1984: } 1985: pwrlevel--; 1986: } 1987: 1988: if (!cmd->enable_by_level) 1989: return; 1990: 1991: cmd->num_levels = cmd_idx; 1992: 1993: ret = gen8_gmu_qmp_aoss_init(adreno_dev, gmu); 1994: if (ret) 1995: dev_err(GMU_PDEV_DEV(device), 1996: "AOP qmp init failed: %d\n", ret); 1997: } 1998: 1999: /* Byte offset of RSCC from GPU (kgsl_3d0_reg_memory) base */ 2000: #define GEN8_RSCC_OFFSET_FROM_KGSL_3D0 0x50000 2001: #define GEN8_RSCC_SIZE 0x10000 2002: 2003: static int gen8_gmu_reg_probe(struct adreno_device *adreno_dev) 2004: { 2005: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2006: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2007: struct resource *res; 2008: int ret; 2009: 2010: ret = kgsl_regmap_add_region(&device->regmap, 2011: GMU_PDEV(device), "gmu", -EINVAL, NULL, NULL); 2012: 2013: if (ret) 2014: dev_err(GMU_PDEV_DEV(device), "Unable to map the GMU registers\n"); 2015: /* 2016: * gmu_ao_blk_dec1 and gmu_ao_blk_dec2 are contiguous and contained within the gmu region 2017: * mapped above. gmu_ao_blk_dec0 is not within the gmu region and is mapped separately. 2018: */ 2019: kgsl_regmap_add_region(&device->regmap, GMU_PDEV(device), "gmu_ao_blk_dec0", -EINVAL, 2020: NULL, NULL); 2021: 2022: /* In standard device tree bindings, rscc range is part of GMU pdev */ 2023: res = platform_get_resource_byname(GMU_PDEV(device), IORESOURCE_MEM, "rscc"); 2024: if (!res) 2025: res = platform_get_resource_byname(device->pdev, 2026: IORESOURCE_MEM, "rscc"); 2027: if (res) { 2028: gmu->rscc_virt = devm_ioremap(&device->pdev->dev, res->start, 2029: resource_size(res)); 2030: } else { 2031: /* 2032: * RSCC lives at GPU base + 0x50000, inside the 2033: * kgsl_3d0_reg_memory range. Derive from GPU base. 2034: */ 2035: struct resource *kgsl_res; 2036: 2037: kgsl_res = platform_get_resource_byname(device->pdev, 2038: IORESOURCE_MEM, "kgsl_3d0_reg_memory"); 2039: if (!kgsl_res) { 2040: dev_err(GMU_PDEV_DEV(device), 2041: "Failed to get kgsl_3d0_reg_memory for RSCC\n"); 2042: return -ENODEV; 2043: } 2044: 2045: gmu->rscc_virt = devm_ioremap(&device->pdev->dev, 2046: kgsl_res->start + GEN8_RSCC_OFFSET_FROM_KGSL_3D0, 2047: GEN8_RSCC_SIZE); 2048: } 2049: 2050: if (!gmu->rscc_virt) { 2051: dev_err(GMU_PDEV_DEV(device), "rscc ioremap failed\n"); 2052: return -ENOMEM; 2053: } 2054: 2055: return ret; 2056: } 2057: 2058: void gen8_gmu_remove(struct kgsl_device *device) 2059: { 2060: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 2061: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2062: 2063: if (!IS_ERR_OR_NULL(gmu->qmp)) 2064: qmp_put(gmu->qmp); 2065: 2066: adreno_dev->acd_enabled = false; 2067: 2068: if (gmu->fw_image) { 2069: release_firmware(gmu->fw_image); 2070: kfree(device->gmu_core.common_caps.data); 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)); 2112: set_dma_ops(GMU_PDEV_DEV(device), NULL); 2113: 2114: /* Setup any rdpm register ranges */ 2115: gmu_core_rdpm_probe(device); 2116: 2117: device->gmu_core.rdpm_cx_offset = GEN8_RDPM_CX_OFFSET; 2118: device->gmu_core.rdpm_mx_offset = GEN8_RDPM_MX_OFFSET; 2119: 2120: /* Set up GMU gdscs */ 2121: ret = kgsl_pwrctrl_probe_gdscs(device, pdev); 2122: if (ret) 2123: return ret; 2124: 2125: if (gen8_core->gmu_mx_gdsc) { 2126: ret = kgsl_pwrctrl_probe_mx_gdsc(device, pdev); 2127: if (ret) 2128: return ret; 2129: } 2130: 2131: ret = gmu_core_clk_probe(device); 2132: if (ret) 2133: return ret; 2134: 2135: /* Set up GMU IOMMU and shared memory with GMU */ 2136: ret = gmu_core_iommu_init(device); 2137: if (ret) 2138: goto error; 2139: 2140: gmu_core->vma = gen8_gmu_vma; 2141: gmu_core->num_vmas = ARRAY_SIZE(gen8_gmu_vma); 2142: 2143: for (i = 0; i < gmu_core->num_vmas; i++) { 2144: struct gmu_vma_entry *vma = &gen8_gmu_vma[i]; 2145: 2146: vma->vma_root = RB_ROOT; 2147: spin_lock_init(&vma->lock); 2148: } 2149: 2150: /* Map and reserve GMU CSRs registers */ 2151: ret = gen8_gmu_reg_probe(adreno_dev); 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; 2197: 2198: /* GMU sysfs nodes setup */ 2199: ret = kobject_init_and_add(&gmu->log_kobj, &log_kobj_type, &dev->kobj, "log"); 2200: if (ret) 2201: dev_err(dev, "Failed to add log_kobj: %d\n", ret); 2202: 2203: ret = kobject_init_and_add(&gmu->stats_kobj, &stats_kobj_type, &dev->kobj, "stats"); 2204: if (ret) 2205: dev_err(dev, "Failed to add stats_kobj: %d\n", ret); 2206: 2207: spin_lock_init(&gmu->hfi.cmdq_lock); 2208: 2209: gmu->irq = kgsl_request_irq(GMU_PDEV(device), "gmu", NULL, -EINVAL, 2210: gen8_gmu_irq_handler, device); 2211: 2212: if (gmu->irq >= 0) 2213: return 0; 2214: 2215: ret = gmu->irq; 2216: 2217: error: 2218: gen8_gmu_remove(device); 2219: return ret; 2220: } 2221: 2222: int gen8_halt_gbif(struct adreno_device *adreno_dev) 2223: { 2224: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2225: int ret; 2226: 2227: /* Halt new client requests */ 2228: kgsl_regwrite(device, GEN8_GBIF_HALT, GEN8_GBIF_CLIENT_HALT_MASK); 2229: ret = adreno_wait_for_halt_ack(device, 2230: GEN8_GBIF_HALT_ACK, GEN8_GBIF_CLIENT_HALT_MASK); 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; 2268: 2269: ret = gen8_rscc_sleep_sequence(adreno_dev); 2270: if (ret) 2271: goto error; 2272: 2273: gmu_core_rdpm_mx_freq_update(device, 0); 2274: 2275: /* Now that we are done with GMU and GPU, Clear the GBIF */ 2276: ret = gen8_halt_gbif(adreno_dev); 2277: if (ret) 2278: goto error; 2279: 2280: gen8_gmu_irq_disable(adreno_dev); 2281: 2282: gen8_hfi_stop(adreno_dev); 2283: 2284: gmu_core_disable_clks(device); 2285: 2286: kgsl_pwrctrl_disable_mx_gdsc(device); 2287: 2288: kgsl_pwrctrl_disable_cx_gdsc(device); 2289: 2290: gmu_core_rdpm_cx_freq_update(device, 0); 2291: 2292: kgsl_pwrctrl_set_state(device, KGSL_STATE_NONE); 2293: 2294: return 0; 2295: 2296: error: 2297: gen8_gmu_irq_disable(adreno_dev); 2298: gen8_hfi_stop(adreno_dev); 2299: gen8_gmu_suspend(adreno_dev, false); 2300: 2301: return ret; 2302: } 2303: 2304: void gen8_enable_gpu_irq(struct adreno_device *adreno_dev) 2305: { 2306: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2307: 2308: kgsl_pwrctrl_irq(device, true); 2309: 2310: adreno_irqctrl(adreno_dev, 1); 2311: } 2312: 2313: void gen8_disable_gpu_irq(struct adreno_device *adreno_dev) 2314: { 2315: kgsl_pwrctrl_irq(KGSL_DEVICE(adreno_dev), false); 2316: 2317: if (gen8_gmu_gx_is_on(adreno_dev)) 2318: adreno_irqctrl(adreno_dev, 0); 2319: } 2320: 2321: static int gen8_gpu_boot(struct adreno_device *adreno_dev) 2322: { 2323: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev); 2324: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2325: int ret; 2326: 2327: adreno_set_active_ctxs_null(adreno_dev); 2328: 2329: ret = kgsl_mmu_start(device); 2330: if (ret) 2331: goto err; 2332: 2333: ret = gen8_gmu_oob_set(device, oob_gpu); 2334: if (ret) 2335: goto oob_clear; 2336: 2337: ret = gen8_gmu_hfi_start_msg(adreno_dev); 2338: if (ret) 2339: goto oob_clear; 2340: 2341: /* Clear the busy_data stats - we're starting over from scratch */ 2342: memset(&adreno_dev->busy_data, 0, sizeof(adreno_dev->busy_data)); 2343: 2344: gen8_start(adreno_dev); 2345: 2346: if (gen8_core->qos_value && adreno_is_preemption_enabled(adreno_dev)) 2347: kgsl_regwrite(device, GEN8_RBBM_GBIF_CLIENT_QOS_CNTL, 2348: gen8_core->qos_value[adreno_dev->cur_rb->id]); 2349: 2350: /* Re-initialize the coresight registers if applicable */ 2351: adreno_coresight_start(adreno_dev); 2352: 2353: adreno_perfcounter_start(adreno_dev); 2354: 2355: /* Clear FSR here in case it is set from a previous pagefault */ 2356: kgsl_mmu_clear_fsr(&device->mmu); 2357: 2358: gen8_enable_gpu_irq(adreno_dev); 2359: 2360: ret = gen8_rb_start(adreno_dev); 2361: if (ret) { 2362: gen8_disable_gpu_irq(adreno_dev); 2363: adreno_llcc_slice_deactivate(adreno_dev); 2364: goto oob_clear; 2365: } 2366: 2367: /* 2368: * At this point it is safe to assume that we recovered. Setting 2369: * this field allows us to take a new snapshot for the next failure 2370: * if we are prioritizing the first unrecoverable snapshot. 2371: */ 2372: if (device->snapshot) 2373: device->snapshot->recovered = true; 2374: 2375: /* Start the dispatcher */ 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); 2413: if (ret) 2414: return ret; 2415: 2416: ret = gen8_gpu_boot(adreno_dev); 2417: if (ret) 2418: return ret; 2419: 2420: kgsl_start_idle_timer(device); 2421: kgsl_pwrscale_wake(device); 2422: 2423: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 2424: 2425: device->pwrctrl.last_stat_updated = ktime_get(); 2426: 2427: kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE); 2428: 2429: return ret; 2430: } 2431: 2432: static int gen8_first_boot(struct adreno_device *adreno_dev) 2433: { 2434: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2435: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2436: int ret; 2437: 2438: if (test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags)) { 2439: if (!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 2440: return gen8_boot(adreno_dev); 2441: 2442: return 0; 2443: } 2444: 2445: ret = gen8_ringbuffer_init(adreno_dev); 2446: if (ret) 2447: return ret; 2448: 2449: ret = gen8_microcode_read(adreno_dev); 2450: if (ret) 2451: return ret; 2452: 2453: ret = gen8_init(adreno_dev); 2454: if (ret) 2455: return ret; 2456: 2457: ret = gen8_gmu_init(adreno_dev); 2458: if (ret) 2459: return ret; 2460: 2461: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE); 2462: 2463: ret = gen8_gmu_first_boot(adreno_dev); 2464: if (ret) 2465: return ret; 2466: 2467: gen8_populate_ctxt_record_size(adreno_dev); 2468: 2469: gen8_preemption_init(adreno_dev); 2470: 2471: ret = gen8_gpu_boot(adreno_dev); 2472: if (ret) 2473: return ret; 2474: 2475: adreno_get_bus_counters(adreno_dev); 2476: 2477: adreno_dev->cooperative_reset = ADRENO_FEATURE(adreno_dev, 2478: ADRENO_COOP_RESET); 2479: 2480: adreno_create_profile_buffer(adreno_dev); 2481: 2482: set_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags); 2483: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 2484: 2485: /* 2486: * BCL needs respective Central Broadcast register to 2487: * be programed from TZ. For kernel version prior to 6.1, this 2488: * programing happens only when zap shader firmware load is successful. 2489: * Zap firmware load can fail in boot up path hence enable BCL only 2490: * after we successfully complete first boot to ensure that Central 2491: * Broadcast register was programed before enabling BCL. 2492: */ 2493: if (ADRENO_FEATURE(adreno_dev, ADRENO_BCL)) 2494: adreno_dev->bcl_enabled = true; 2495: 2496: /* 2497: * There is a possible deadlock scenario during kgsl firmware reading 2498: * (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl 2499: * device mutex is held and then firmware_request_nowarn is called for reading 2500: * firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock. 2501: * Whereas in case of devfreq update calls triggered by thermal/bcl or 2502: * devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then 2503: * tries to take kgsl device mutex as part of get_dev_status/target 2504: * calls. This results in deadlock when both thread are unable to acquire 2505: * the mutex held by other thread. Enable devfreq updates now as we are 2506: * done reading all firmware files. 2507: */ MATCH LINES: 2534, 2537, 2543, 2548, 2560, 2564, 2574, 2594, 2599, 2604, 2612, 2637, 2661, 2663, 2665, 2671, 2674, 2680, 2684, 2696, 2699, 2702, 2711, 2714, 2726, 2729, 2731, 2739, 2742, 2745, 2752, 2753, 2756, 2761, 2771, 2788, 2789, 2790, 2791, 2792, 2793, 2794, 2795, 2796, 2799, 2826, 2828, 2833, 2835, 2839, 2841, 2844, 2850, 2856, 2858, 2859, 2862, 2863, 2868, 2880, 2881, 2886, 2903, 2911, 2915, 2916, 2919, 2927, 2935, 2936, 2938, 2941, 2942, 2943, 2946, 2958, 2962, 2964, 2967, 2969, 2974, 2980, 2981, 2982, 2985 2522: u32 status; 2523: 2524: kgsl_regread(device, GEN8_RBBM_INT_0_STATUS, &status); 2525: 2526: /* Return busy if a interrupt is pending */ 2527: return ((status & adreno_dev->irq_mask) || 2528: atomic_read(&adreno_dev->pending_irq_refcnt)); 2529: } 2530: 2531: static int gen8_power_off(struct adreno_device *adreno_dev) 2532: { 2533: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2534: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2535: int ret; 2536: 2537: WARN_ON(!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)); 2538: 2539: adreno_check_idle(device); 2540: 2541: kgsl_pwrctrl_request_state(device, KGSL_STATE_SLUMBER); 2542: 2543: ret = gen8_gmu_oob_set(device, oob_gpu); 2544: if (ret) 2545: goto no_gx_power; 2546: 2547: if (gen8_irq_pending(adreno_dev)) { 2548: gen8_gmu_oob_clear(device, oob_gpu); 2549: return -EBUSY; 2550: } 2551: 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: 2589: kgsl_pwrctrl_set_state(device, KGSL_STATE_SLUMBER); 2590: 2591: return ret; 2592: } 2593: 2594: static void gmu_idle_check(struct work_struct *work) 2595: { 2596: struct kgsl_device *device = container_of(work, 2597: struct kgsl_device, idle_check_ws); 2598: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 2599: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2600: int ret; 2601: 2602: kgsl_mutex_lock(&device->mutex); 2603: 2604: if (test_bit(GMU_DISABLE_SLUMBER, &device->gmu_core.flags)) 2605: goto done; 2606: 2607: if (atomic_read(&device->active_cnt) || time_is_after_jiffies(device->idle_jiffies)) { 2608: kgsl_pwrscale_update(device); 2609: goto done; 2610: } 2611: 2612: if (!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 2613: goto done; 2614: 2615: spin_lock(&device->submit_lock); 2616: 2617: if (device->submit_now) { 2618: spin_unlock(&device->submit_lock); 2619: kgsl_pwrscale_update(device); 2620: kgsl_start_idle_timer(device); 2621: goto done; 2622: } 2623: 2624: device->skip_inline_submit = true; 2625: spin_unlock(&device->submit_lock); 2626: 2627: ret = gen8_power_off(adreno_dev); 2628: if (ret == -EBUSY) { 2629: kgsl_pwrscale_update(device); 2630: kgsl_start_idle_timer(device); 2631: } 2632: 2633: done: 2634: kgsl_mutex_unlock(&device->mutex); 2635: } 2636: 2637: static int gen8_gmu_first_open(struct adreno_device *adreno_dev) 2638: { 2639: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2640: int ret; 2641: 2642: /* 2643: * Do the one time settings that need to happen when we 2644: * attempt to boot the gpu the very first time 2645: */ 2646: ret = gen8_first_boot(adreno_dev); 2647: if (ret) 2648: return ret; 2649: 2650: /* 2651: * A client that does a first_open but never closes the device 2652: * may prevent us from going back to SLUMBER. So trigger the idle 2653: * check by incrementing the active count and immediately releasing it. 2654: */ 2655: atomic_inc(&device->active_cnt); 2656: adreno_active_count_put(adreno_dev); 2657: 2658: return 0; 2659: } 2660: 2661: static int gen8_gmu_last_close(struct adreno_device *adreno_dev) 2662: { 2663: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2664: 2665: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 2666: return gen8_power_off(adreno_dev); 2667: 2668: return 0; 2669: } 2670: 2671: static int gen8_gmu_active_count_get(struct adreno_device *adreno_dev) 2672: { 2673: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2674: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2675: int ret = 0; 2676: 2677: if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex))) 2678: return -EINVAL; 2679: 2680: if (test_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags)) 2681: return -EINVAL; 2682: 2683: if ((atomic_read(&device->active_cnt) == 0) && 2684: !test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 2685: ret = gen8_boot(adreno_dev); 2686: 2687: if (ret == 0) 2688: atomic_inc(&device->active_cnt); 2689: 2690: trace_kgsl_active_count(device, 2691: (unsigned long) __builtin_return_address(0)); 2692: 2693: return ret; 2694: } 2695: 2696: static int gen8_gmu_pm_suspend(struct adreno_device *adreno_dev) 2697: { 2698: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2699: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2700: int ret; 2701: 2702: if (test_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags)) 2703: return 0; 2704: 2705: kgsl_pwrctrl_request_state(device, KGSL_STATE_SUSPEND); 2706: 2707: ret = adreno_drain_and_idle(device); 2708: if (ret) 2709: goto err; 2710: 2711: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 2712: gen8_power_off(adreno_dev); 2713: 2714: set_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags); 2715: 2716: adreno_get_gpu_halt(adreno_dev); 2717: 2718: kgsl_pwrctrl_set_state(device, KGSL_STATE_SUSPEND); 2719: 2720: return 0; 2721: err: 2722: adreno_dispatcher_start(device); 2723: return ret; 2724: } 2725: 2726: static void gen8_gmu_pm_resume(struct adreno_device *adreno_dev) 2727: { 2728: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2729: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2730: 2731: if (WARN(!test_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags), 2732: "resume invoked without a suspend\n")) 2733: return; 2734: 2735: adreno_put_gpu_halt(adreno_dev); 2736: 2737: adreno_dispatcher_start(device); 2738: 2739: clear_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags); 2740: } 2741: 2742: static void gen8_gmu_touch_wakeup(struct adreno_device *adreno_dev) 2743: { 2744: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2745: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2746: int ret; 2747: 2748: /* 2749: * Do not wake up a suspended device or until the first boot sequence 2750: * has been completed. 2751: */ 2752: if (test_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags) || 2753: !test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags)) 2754: return; 2755: 2756: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 2757: goto done; 2758: 2759: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE); 2760: 2761: ret = gen8_gmu_boot(adreno_dev); 2762: if (ret) 2763: return; 2764: 2765: ret = gen8_gpu_boot(adreno_dev); 2766: if (ret) 2767: return; 2768: 2769: kgsl_pwrscale_wake(device); 2770: 2771: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 2772: 2773: device->pwrctrl.last_stat_updated = ktime_get(); 2774: 2775: kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE); 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; 2813: 2814: adreno_dev->irq_mask = GEN8_INT_MASK; 2815: 2816: ret = gen8_probe_common(pdev, adreno_dev, chipid, gpucore); 2817: if (ret) 2818: return ret; 2819: 2820: ret = adreno_dispatcher_init(adreno_dev); 2821: if (ret) 2822: return ret; 2823: 2824: device = KGSL_DEVICE(adreno_dev); 2825: 2826: INIT_WORK(&device->idle_check_ws, gmu_idle_check); 2827: 2828: timer_setup(&device->idle_timer, gmu_idle_timer, 0); 2829: 2830: return 0; 2831: } 2832: 2833: int gen8_gmu_reset(struct adreno_device *adreno_dev) 2834: { 2835: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2836: 2837: gen8_disable_gpu_irq(adreno_dev); 2838: 2839: gen8_gmu_irq_disable(adreno_dev); 2840: 2841: gen8_hfi_stop(adreno_dev); 2842: 2843: /* Hard reset the gmu and gpu */ 2844: gen8_gmu_suspend(adreno_dev, true); 2845: 2846: gen8_reset_preempt_records(adreno_dev); 2847: 2848: adreno_llcc_slice_deactivate(adreno_dev); 2849: 2850: clear_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 2851: 2852: /* Attempt to reboot the gmu and gpu */ 2853: return gen8_boot(adreno_dev); 2854: } 2855: 2856: int gen8_gmu_hfi_probe(struct adreno_device *adreno_dev) 2857: { 2858: struct platform_device *gmu_pdev = GMU_PDEV(KGSL_DEVICE(adreno_dev)); 2859: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2860: struct gen8_hfi *hfi = &gmu->hfi; 2861: 2862: hfi->irq = kgsl_request_irq(gmu_pdev, "hfi", NULL, -EINVAL, 2863: gen8_hfi_irq_handler, KGSL_DEVICE(adreno_dev)); 2864: 2865: return hfi->irq < 0 ? hfi->irq : 0; 2866: } 2867: 2868: int gen8_gmu_add_to_minidump(struct adreno_device *adreno_dev) 2869: { 2870: struct gen8_device *gen8_dev = container_of(adreno_dev, 2871: struct gen8_device, adreno_dev); 2872: struct gen8_nonctxt_overrides *nc_overrides = gen8_dev->nc_overrides; 2873: int ret; 2874: 2875: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, KGSL_GEN8_DEVICE, 2876: (void *)(gen8_dev), sizeof(struct gen8_device)); 2877: if (ret) 2878: return ret; 2879: 2880: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, KGSL_GMU_LOG_ENTRY, 2881: gen8_dev->gmu.gmu_log->hostptr, gen8_dev->gmu.gmu_log->size); 2882: if (ret) 2883: return ret; 2884: 2885: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, KGSL_HFIMEM_ENTRY, 2886: gen8_dev->gmu.hfi.hfi_mem->hostptr, gen8_dev->gmu.hfi.hfi_mem->size); 2887: if (ret) 2888: return ret; 2889: 2890: if (nc_overrides) { 2891: int len = 0; 2892: 2893: while (nc_overrides[len].offset) 2894: len++; 2895: 2896: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, KGSL_NC_OVERRIDES_ENTRY, 2897: (void *)(nc_overrides), len * sizeof(*nc_overrides)); 2898: } 2899: 2900: return ret; 2901: } 2902: 2903: static int gen8_gmu_bind(struct device *dev, struct device *master, void *data) 2904: { 2905: struct kgsl_device *device = dev_get_drvdata(master); 2906: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 2907: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 2908: const struct gen8_gpudev *gen8_gpudev = to_gen8_gpudev(gpudev); 2909: int ret; 2910: 2911: ret = gen8_gmu_probe(device, to_platform_device(dev)); 2912: if (ret) 2913: return ret; 2914: 2915: if (gen8_gpudev->hfi_probe) { 2916: ret = gen8_gpudev->hfi_probe(adreno_dev); 2917: 2918: if (ret) { 2919: gen8_gmu_remove(device); 2920: return ret; 2921: } 2922: } 2923: 2924: return 0; 2925: } 2926: 2927: static void gen8_gmu_unbind(struct device *dev, struct device *master, 2928: void *data) 2929: { 2930: struct kgsl_device *device = dev_get_drvdata(master); 2931: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 2932: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 2933: const struct gen8_gpudev *gen8_gpudev = to_gen8_gpudev(gpudev); 2934: 2935: if (gen8_gpudev->hfi_remove) 2936: gen8_gpudev->hfi_remove(adreno_dev); 2937: 2938: gen8_gmu_remove(device); 2939: } 2940: 2941: static const struct component_ops gen8_gmu_component_ops = { 2942: .bind = gen8_gmu_bind, 2943: .unbind = gen8_gmu_unbind, 2944: }; 2945: 2946: static int gen8_gmu_probe_dev(struct platform_device *pdev) 2947: { 2948: /* 2949: * Let us say there are two devices. One with "qcom,adreno-gmu" compatible 2950: * and one with "qcom,gpu-gmu" compatible. In this case probe only the 2951: * device with legacy compatible string and return error for the device 2952: * with "qcom,adreno-gmu". 2953: */ 2954: if (of_device_is_compatible(pdev->dev.of_node, "qcom,adreno-gmu") && 2955: kgsl_is_compatible_node_available("qcom,gpu-gmu")) 2956: return -ENODEV; 2957: 2958: return component_add(&pdev->dev, &gen8_gmu_component_ops); 2959: } 2960: 2961: #if (KERNEL_VERSION(6, 10, 0) <= LINUX_VERSION_CODE) 2962: static void gen8_gmu_remove_dev(struct platform_device *pdev) 2963: { 2964: component_del(&pdev->dev, &gen8_gmu_component_ops); 2965: } 2966: #else 2967: static int gen8_gmu_remove_dev(struct platform_device *pdev) 2968: { 2969: component_del(&pdev->dev, &gen8_gmu_component_ops); 2970: return 0; 2971: } 2972: #endif 2973: 2974: static const struct of_device_id gen8_gmu_match_table[] = { 2975: { .compatible = "qcom,gen8-gmu" }, 2976: { .compatible = "qcom,adreno-gmu" }, 2977: { }, 2978: }; 2979: 2980: struct platform_driver gen8_gmu_driver = { 2981: .probe = gen8_gmu_probe_dev, 2982: .remove = gen8_gmu_remove_dev, 2983: .driver = { 2984: .name = "adreno-gen8-gmu", 2985: .of_match_table = gen8_gmu_match_table, 2986: }, 2987: }; --- FILE: \adreno_gen8_gmu.h | HITS: 75 --- MATCH LINES: 7, 8, 13, 17, 23, 27, 32, 35, 36, 37, 61, 62, 81, 82, 86, 89, 102, 108, 111, 118, 122, 127, 142, 149, 153, 161, 165, 170, 173, 180, 183, 189, 192, 199, 202, 207, 210, 215, 218, 223, 226, 231, 234, 239, 242, 245, 248, 251, 254, 261, 264, 266, 268, 272, 275, 277, 279, 282, 285, 292, 295, 300, 330, 333, 336, 339, 342, 347, 348, 351, 354, 357, 362, 365, 370 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) 2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #ifndef __ADRENO_GEN8_GMU_H 8: #define __ADRENO_GEN8_GMU_H 9: 10: #include 11: 12: #include "adreno_gen8_hfi.h" 13: #include "kgsl_gmu_core.h" 14: 15: struct gen8_dcvs_table { 16: u32 gpu_level_num; 17: u32 gmu_level_num; 18: struct opp_gx_desc gx_votes[MAX_GX_LEVELS]; 19: struct opp_desc cx_votes[MAX_CX_LEVELS]; 20: }; 21: 22: /** 23: * struct gen8_gmu_device - GMU device structure 24: * @ver: GMU Version information 25: * @irq: GMU interrupt number 26: * @fw_image: GMU FW image 27: * @gmu_log: gmu event log memory 28: * @hfi: HFI controller 29: * @idle_level: Minimal GPU idle power level 30: * @log_wptr_retention: Store the log wptr offset on slumber 31: */ 32: struct gen8_gmu_device { 33: int irq; 34: const struct firmware *fw_image; 35: struct kgsl_memdesc *gmu_log; 36: /** @gmu_init_scratch: Memory to store the initial HFI messages */ 37: struct kgsl_memdesc *gmu_init_scratch; 38: /** @gpu_boot_scratch: Memory to store the bootup HFI messages */ 39: struct kgsl_memdesc *gpu_boot_scratch; 40: struct gen8_hfi hfi; 41: u32 idle_level; 42: /** @qmp: aoss_qmp handle */ 43: struct qmp *qmp; 44: u32 log_wptr_retention; 45: /** @cm3_fault: whether gmu received a cm3 fault interrupt */ 46: atomic_t cm3_fault; 47: /** 48: * @itcm_shadow: Copy of the itcm block in firmware binary used for 49: * snapshot 50: */ 51: void *itcm_shadow; 52: /** @flags: Internal gmu flags */ 53: unsigned long flags; 54: /** @rscc_virt: Pointer where RSCC block is mapped */ 55: void __iomem *rscc_virt; 56: /** @log_stream_enable: GMU log streaming enable. Disabled by default */ 57: bool log_stream_enable; 58: /** @log_group_mask: Allows overriding default GMU log group mask */ 59: u32 log_group_mask; 60: struct kobject log_kobj; 61: /** @num_oob_perfcntr: Number of active oob_perfcntr requests */ 62: u32 num_oob_perfcntr; 63: /** @acd_debug_val: DVM value to calibrate ACD for a level */ 64: u32 acd_debug_val; 65: /** @stats_enable: GMU stats feature enable */ 66: bool stats_enable; 67: /** @stats_mask: GMU performance countables to enable */ 68: u32 stats_mask; 69: /** @stats_interval: GMU performance counters sampling interval */ 70: u32 stats_interval; 71: /** @stats_kobj: kernel object for GMU stats directory in sysfs */ 72: struct kobject stats_kobj; 73: /** @cp_init_hdr: raw command header for cp_init */ 74: u32 cp_init_hdr; 75: /** @switch_to_unsec_hdr: raw command header for switch to unsecure packet */ 76: u32 switch_to_unsec_hdr; 77: /** @dcvs_table: Table for gpu dcvs levels */ 78: struct gen8_dcvs_table dcvs_table; 79: /** @dcvs_cmdbuf: Pointer to the table to pass DCVS data to GMU */ 80: u32 *dcvs_cmdbuf; 81: /** @gmu_scaling_cmdbuf: Pointer to the table to pass GMU power levels */ 82: u32 *gmu_scaling_cmdbuf; 83: }; 84: 85: /* Helper function to get to gen8 gmu device from adreno device */ 86: struct gen8_gmu_device *to_gen8_gmu(struct adreno_device *adreno_dev); 87: 88: /* Helper function to get to adreno device from gen8 gmu device */ 89: struct adreno_device *gen8_gmu_to_adreno(struct gen8_gmu_device *gmu); 90: 91: /** 92: * gen8_build_rpmh_tables - Build the rpmh tables 93: * @adreno_dev: Pointer to the adreno device 94: * 95: * This function creates the gpu dcvs and bw tables 96: * 97: * Return: 0 on success and negative error on failure 98: */ 99: int gen8_build_rpmh_tables(struct adreno_device *adreno_dev); 100: 101: /** 102: * gen8_gmu_gx_is_on - Check if GX is on 103: * @adreno_dev: Pointer to the adreno device 104: * 105: * This function reads pwr status registers to check if GX 106: * is on or off 107: */ 108: bool gen8_gmu_gx_is_on(struct adreno_device *adreno_dev); 109: 110: /** 111: * gen8_gmu_device_probe - GEN8 GMU snapshot function 112: * @pdev: Pointer to the platform device 113: * @chipid: Chipid of the target 114: * @gpucore: Pointer to the gpucore 115: * 116: * The target specific probe function for gmu based gen8 targets. 117: */ 118: int gen8_gmu_device_probe(struct platform_device *pdev, 119: u32 chipid, const struct adreno_gpu_core *gpucore); 120: 121: /** 122: * gen8_gmu_reset - Reset and restart the gmu 123: * @adreno_dev: Pointer to the adreno device 124: * 125: * Return: 0 on success or negative error on failure 126: */ 127: int gen8_gmu_reset(struct adreno_device *adreno_dev); 128: 129: /** 130: * gen8_enable_gpu_irq - Enable gpu interrupt 131: * @adreno_dev: Pointer to the adreno device 132: */ 133: void gen8_enable_gpu_irq(struct adreno_device *adreno_dev); 134: 135: /** 136: * gen8_disable_gpu_irq - Disable gpu interrupt 137: * @adreno_dev: Pointer to the adreno device 138: */ 139: void gen8_disable_gpu_irq(struct adreno_device *adreno_dev); 140: 141: /** 142: * gen8_gmu_snapshot- Take snapshot for gmu targets 143: * @adreno_dev: Pointer to the adreno device 144: * @snapshot: Pointer to the snapshot structure 145: * 146: * Send an NMI to gmu if we hit a gmu fault. Then take gmu 147: * snapshot and carry on with rest of the gen8 snapshot 148: */ 149: void gen8_gmu_snapshot(struct adreno_device *adreno_dev, 150: struct kgsl_snapshot *snapshot); 151: 152: /** 153: * gen8_gmu_probe - Probe gen8 gmu resources 154: * @device: Pointer to the kgsl device 155: * @pdev: Pointer to the gmu platform device 156: * 157: * Probe the gmu and hfi resources 158: * 159: * Return: 0 on success or negative error on failure 160: */ 161: int gen8_gmu_probe(struct kgsl_device *device, 162: struct platform_device *pdev); 163: 164: /** 165: * gen8_gmu_parse_fw - Parse the gmu fw binary 166: * @adreno_dev: Pointer to the adreno device 167: * 168: * Return: 0 on success or negative error on failure 169: */ 170: int gen8_gmu_parse_fw(struct adreno_device *adreno_dev); 171: 172: /** 173: * gen8_gmu_memory_init - Allocate gmu memory 174: * @adreno_dev: Pointer to the adreno device 175: * 176: * Allocates the gmu log buffer and others if ndeeded. 177: * 178: * Return: 0 on success or negative error on failure 179: */ 180: int gen8_gmu_memory_init(struct adreno_device *adreno_dev); 181: 182: /** 183: * gen8_gmu_aop_send_acd_state - Enable or disable acd feature in aop 184: * @gmu: Pointer to the gen8 gmu device 185: * @flag: Boolean to enable or disable acd in aop 186: * 187: * This function enables or disables gpu acd feature using qmp 188: */ 189: void gen8_gmu_aop_send_acd_state(struct gen8_gmu_device *gmu, bool flag); 190: 191: /** 192: * gen8_gmu_load_fw - Load gmu firmware 193: * @adreno_dev: Pointer to the adreno device 194: * 195: * Loads the gmu firmware binary into TCMs and memory 196: * 197: * Return: 0 on success or negative error on failure 198: */ 199: int gen8_gmu_load_fw(struct adreno_device *adreno_dev); 200: 201: /** 202: * gen8_gmu_device_start - Bring gmu out of reset 203: * @adreno_dev: Pointer to the adreno device 204: * 205: * Return: 0 on success or negative error on failure 206: */ 207: int gen8_gmu_device_start(struct adreno_device *adreno_dev); 208: 209: /** 210: * gen8_gmu_hfi_start - Indicate hfi start to gmu 211: * @device: Pointer to the kgsl device 212: * 213: * Return: 0 on success or negative error on failure 214: */ 215: int gen8_gmu_hfi_start(struct adreno_device *adreno_dev); 216: 217: /** 218: * gen8_gmu_itcm_shadow - Create itcm shadow copy for snapshot 219: * @adreno_dev: Pointer to the adreno device 220: * 221: * Return: 0 on success or negative error on failure 222: */ 223: int gen8_gmu_itcm_shadow(struct adreno_device *adreno_dev); 224: 225: /** 226: * gen8_gmu_register_config - gmu register configuration 227: * @adreno_dev: Pointer to the adreno device 228: * 229: * Program gmu regsiters based on features 230: */ 231: void gen8_gmu_register_config(struct adreno_device *adreno_dev); 232: 233: /** 234: * gen8_gmu_version_info - Get gmu firmware version 235: * @adreno_dev: Pointer to the adreno device 236: * 237: * Return: 0 on success or negative error on failure 238: */ 239: int gen8_gmu_version_info(struct adreno_device *adreno_dev); 240: 241: /** 242: * gen8_gmu_irq_enable - Enable gmu interrupts 243: * @adreno_dev: Pointer to the adreno device 244: */ 245: void gen8_gmu_irq_enable(struct adreno_device *adreno_dev); 246: 247: /** 248: * gen8_gmu_irq_disable - Disaable gmu interrupts 249: * @adreno_dev: Pointer to the adreno device 250: */ 251: void gen8_gmu_irq_disable(struct adreno_device *adreno_dev); 252: 253: /** 254: * gen8_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 gen8_gmu_suspend(struct adreno_device *adreno_dev, bool force); 262: 263: /** 264: * gen8_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 gen8_gmu_oob_set(struct kgsl_device *device, enum oob_request oob); 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 313: * 314: * Return: 0 on success or negative error on failure 315: */ 316: int gen8_rscc_wakeup_sequence(struct adreno_device *adreno_dev); 317: 318: /** 319: * gen8_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 gen8_halt_gbif(struct adreno_device *adreno_dev); 328: 329: /** 330: * gen8_gmu_remove - Clean up gmu probed resources 331: * @device: Pointer to the kgsl device 332: */ 333: void gen8_gmu_remove(struct kgsl_device *device); 334: 335: /** 336: * gen8_gmu_handle_watchdog - Handle watchdog interrupt 337: * @adreno_dev: Pointer to the adreno device 338: */ 339: void gen8_gmu_handle_watchdog(struct adreno_device *adreno_dev); 340: 341: /** 342: * gen8_gmu_send_nmi - Send NMI to GMU 343: * @device: Pointer to the kgsl device 344: * @gf_policy: GMU fault panic setting policy 345: * @force: Boolean to forcefully send NMI irrespective of GMU state 346: */ 347: void gen8_gmu_send_nmi(struct kgsl_device *device, bool force, 348: enum gmu_fault_panic_policy gf_policy); 349: 350: /** 351: * gen8_gmu_add_to_minidump - Register gen8_device with va minidump 352: * @adreno_dev: Pointer to the adreno device 353: */ 354: int gen8_gmu_add_to_minidump(struct adreno_device *adreno_dev); 355: 356: /** 357: * gen8_gmu_rpmh_pwr_state_is_active - Check the state of GPU HW 358: * @device: Pointer to the kgsl device 359: * 360: * Returns true on active or false otherwise 361: */ 362: bool gen8_gmu_rpmh_pwr_state_is_active(struct kgsl_device *device); 363: 364: /** 365: * gen8_gmu_malu_is_on - Check the state of MALU HW 366: * @adreno_dev: Pointer to the adreno device 367: * 368: * Returns true on active or false otherwise 369: */ 370: bool gen8_gmu_malu_is_on(struct adreno_device *adreno_dev); 371: 372: #endif --- FILE: \adreno_gen8_gmu_snapshot.c | HITS: 59 --- MATCH LINES: 14, 16, 19, 20, 21, 25, 30, 32, 44, 47, 50, 53, 54, 55, 57, 60, 65, 70, 72, 75, 77, 80, 81, 83, 85, 88, 90, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 106, 109, 110, 123, 154, 161, 165, 174, 175, 177, 179, 194, 195, 200, 202, 203, 210, 211, 222, 234, 238, 239 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 "adreno.h" 8: #include "adreno_gen8.h" 9: #include "adreno_gen8_gmu.h" 10: #include "adreno_gen8_0_0_snapshot.h" 11: #include "adreno_snapshot.h" 12: #include "gen8_reg.h" 13: #include "kgsl_device.h" 14: #include "kgsl_gmu_core.h" 15: 16: static size_t gen8_gmu_snapshot_dtcm(struct kgsl_device *device, 17: u8 *buf, size_t remain, void *priv) 18: { 19: struct gmu_core_device *gmu_core = &device->gmu_core; 20: struct kgsl_snapshot_gmu_mem *mem_hdr = 21: (struct kgsl_snapshot_gmu_mem *)buf; 22: u32 *data = (u32 *)(buf + sizeof(*mem_hdr)); 23: u32 i; 24: 25: if (remain < gmu_core->vma[GMU_DTCM].size + sizeof(*mem_hdr)) { 26: SNAPSHOT_ERR_NOMEM(device, "GMU DTCM Memory"); 27: return 0; 28: } 29: 30: mem_hdr->type = SNAPSHOT_GMU_MEM_BIN_BLOCK; 31: mem_hdr->hostaddr = 0; 32: mem_hdr->gmuaddr = gmu_core->vma[GMU_DTCM].start; 33: mem_hdr->gpuaddr = 0; 34: 35: /* 36: * Read of GMU TCMs over side-band debug controller interface is 37: * supported on gen8 family 38: * region [20]: Dump ITCM/DTCM. Select 1 for DTCM. 39: * autoInc [31]: Autoincrement the address field after each 40: * access to TCM_DBG_DATA 41: */ 42: kgsl_regwrite(device, GEN8_CX_DBGC_TCM_DBG_ADDR, BIT(20) | BIT(31)); 43: 44: for (i = 0; i < (gmu_core->vma[GMU_DTCM].size >> 2); i++) 45: kgsl_regread(device, GEN8_CX_DBGC_TCM_DBG_DATA, data++); 46: 47: return gmu_core->vma[GMU_DTCM].size + sizeof(*mem_hdr); 48: } 49: 50: static size_t gen8_gmu_snapshot_itcm(struct kgsl_device *device, 51: u8 *buf, size_t remain, void *priv) 52: { 53: struct gmu_core_device *gmu_core = &device->gmu_core; 54: struct kgsl_snapshot_gmu_mem *mem_hdr = 55: (struct kgsl_snapshot_gmu_mem *)buf; 56: void *dest = buf + sizeof(*mem_hdr); 57: struct gen8_gmu_device *gmu = (struct gen8_gmu_device *)priv; 58: 59: if (!gmu->itcm_shadow) { 60: dev_err(GMU_PDEV_DEV(device), 61: "No memory allocated for ITCM shadow capture\n"); 62: return 0; 63: } 64: 65: if (remain < gmu_core->vma[GMU_ITCM].size + sizeof(*mem_hdr)) { 66: SNAPSHOT_ERR_NOMEM(device, "GMU ITCM Memory"); 67: return 0; 68: } 69: 70: mem_hdr->type = SNAPSHOT_GMU_MEM_BIN_BLOCK; 71: mem_hdr->hostaddr = 0; 72: mem_hdr->gmuaddr = gmu_core->vma[GMU_ITCM].start; 73: mem_hdr->gpuaddr = 0; 74: 75: memcpy(dest, gmu->itcm_shadow, gmu_core->vma[GMU_ITCM].size); 76: 77: return gmu_core->vma[GMU_ITCM].size + sizeof(*mem_hdr); 78: } 79: 80: static void gen8_gmu_snapshot_memories(struct kgsl_device *device, 81: struct gen8_gmu_device *gmu, struct kgsl_snapshot *snapshot) 82: { 83: struct gmu_mem_type_desc desc; 84: struct kgsl_memdesc *md; 85: struct gmu_core_device *gmu_core = &device->gmu_core; 86: int i; 87: 88: for (i = 0; i < ARRAY_SIZE(gmu_core->gmu_globals); i++) { 89: 90: md = &gmu_core->gmu_globals[i]; 91: if (!md->size) 92: continue; 93: 94: desc.memdesc = md; 95: if (md == gmu->hfi.hfi_mem) 96: desc.type = SNAPSHOT_GMU_MEM_HFI; 97: else if (md == gmu->gmu_log) 98: desc.type = SNAPSHOT_GMU_MEM_LOG; 99: else if ((md == gmu->gmu_init_scratch) || (md == gmu->gpu_boot_scratch)) 100: desc.type = SNAPSHOT_GMU_MEM_WARMBOOT; 101: else if (md == gmu_core->vrb) 102: desc.type = SNAPSHOT_GMU_MEM_VRB; 103: else if (md == gmu_core->trace.md) 104: desc.type = SNAPSHOT_GMU_MEM_TRACE; 105: else 106: desc.type = SNAPSHOT_GMU_MEM_BIN_BLOCK; 107: 108: kgsl_snapshot_add_section(device, 109: KGSL_SNAPSHOT_SECTION_GMU_MEMORY, 110: snapshot, adreno_snapshot_gmu_mem, &desc); 111: } 112: } 113: 114: #define RSCC_OFFSET_DWORDS 0x14000 115: 116: static size_t gen8_snapshot_rscc_registers(struct kgsl_device *device, u8 *buf, 117: size_t remain, void *priv) 118: { 119: const u32 *regs = priv; 120: u32 *data = (u32 *)buf; 121: int count = 0, k; 122: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 123: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 124: 125: /* Figure out how many registers we are going to dump */ 126: count = adreno_snapshot_regs_count(regs); 127: 128: if (remain < (count * 4)) { 129: SNAPSHOT_ERR_NOMEM(device, "RSCC REGISTERS"); 130: return 0; 131: } 132: 133: for (regs = priv; regs[0] != UINT_MAX; regs += 2) { 134: u32 cnt = REG_COUNT(regs); 135: 136: if (cnt == 1) { 137: *data++ = BIT(31) | regs[0]; 138: *data++ = __raw_readl(gmu->rscc_virt + 139: ((regs[0] - RSCC_OFFSET_DWORDS) << 2)); 140: continue; 141: } 142: *data++ = regs[0]; 143: *data++ = cnt; 144: for (k = regs[0]; k <= regs[1]; k++) 145: *data++ = __raw_readl(gmu->rscc_virt + 146: ((k - RSCC_OFFSET_DWORDS) << 2)); 147: } 148: 149: /* Return the size of the section */ 150: return (count * 4); 151: } 152: 153: /* 154: * gen8_gmu_device_snapshot() - GEN8 GMU snapshot function 155: * @device: Device being snapshotted 156: * @snapshot: Pointer to the snapshot instance 157: * 158: * This is where all of the GEN8 GMU specific bits and pieces are grabbed 159: * into the snapshot memory 160: */ 161: static void gen8_gmu_device_snapshot(struct kgsl_device *device, 162: struct kgsl_snapshot *snapshot) 163: { 164: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 165: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 166: const struct adreno_gen8_core *gpucore = to_gen8_core(adreno_dev); 167: const struct gen8_snapshot_block_list *gen8_snapshot_block_list = 168: gpucore->gen8_snapshot_block_list; 169: const u32 *regs_ptr = (const u32 *)gen8_snapshot_block_list->cx_misc_regs; 170: u32 i, j; 171: struct gen8_reg_list_info info = {0}; 172: u32 slice_mask = gen8_get_slice_mask(adreno_dev); 173: 174: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_GMU_MEMORY, 175: snapshot, gen8_gmu_snapshot_itcm, gmu); 176: 177: adreno_snapshot_gmu_versions(device, snapshot); 178: 179: gen8_gmu_snapshot_memories(device, gmu, snapshot); 180: 181: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, snapshot, 182: gen8_snapshot_rscc_registers, (void *) gen8_snapshot_block_list->rscc_regs); 183: 184: /* 185: * We want to capture these through AHB path here because we might skip them 186: * in the crashdumper path if GX is OFF, and these are needed for debug. 187: */ 188: if (!kgsl_regmap_valid_offset(&device->regmap, regs_ptr[0])) 189: WARN_ONCE(1, "cx_misc registers are not defined in device tree"); 190: else 191: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, 192: snapshot, adreno_snapshot_registers_v2, (void *)regs_ptr); 193: 194: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_GMU_MEMORY, 195: snapshot, gen8_gmu_snapshot_dtcm, gmu); 196: 197: /* Capture GMU registers which are on CX domain and unsliced */ 198: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, snapshot, 199: adreno_snapshot_registers_v2, 200: (void *) gen8_snapshot_block_list->gmu_cx_unsliced_regs); 201: 202: if (!gen8_gmu_rpmh_pwr_state_is_active(device) || 203: !gen8_gmu_gx_is_on(adreno_dev)) 204: return; 205: 206: /* Set fence to ALLOW mode so registers can be read */ 207: kgsl_regwrite(device, GEN8_GMUAO_AHB_FENCE_CTRL, 0); 208: 209: /* Capture GMU registers which are on GX domain */ 210: for (i = 0 ; i < gen8_snapshot_block_list->num_gmu_gx_regs; i++) { 211: struct gen8_reg_list *regs = &gen8_snapshot_block_list->gmu_gx_regs[i]; 212: 213: FOR_EACH_SLICE(j, regs->slice_region, slice_mask) { 214: info.regs = regs; 215: info.slice_id = SLICE_ID(regs->slice_region, j); 216: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_MVC_V3, snapshot, 217: gen8_legacy_snapshot_registers, &info); 218: } 219: } 220: } 221: 222: void gen8_gmu_snapshot(struct adreno_device *adreno_dev, 223: struct kgsl_snapshot *snapshot) 224: { 225: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 226: 227: /* 228: * Dump external register first to have GPUCC and other external 229: * register in snapshot to analyze the system state even in partial 230: * snapshot dump 231: */ 232: gen8_snapshot_external_core_regs(device, snapshot); 233: 234: gen8_gmu_device_snapshot(device, snapshot); 235: 236: gen8_snapshot(adreno_dev, snapshot); 237: 238: gmu_core_regwrite(device, GEN8_GMUCX_GMU2HOST_INTR_CLR, UINT_MAX); 239: gmu_core_regwrite(device, GEN8_GMUCX_GMU2HOST_INTR_MASK, HFI_IRQ_MASK); 240: } --- FILE: \adreno_gen8_hfi.c | HITS: 204 --- MATCH LINES: 15, 19, 22, 23, 25, 26, 30, 36, 39, 40, 41, 42, 49, 63, 80, 88, 91, 92, 96, 103, 106, 107, 108, 115, 118, 141, 143, 148, 150, 159, 175, 176, 186, 187, 189, 190, 195, 196, 197, 198, 204, 205, 206, 207, 208, 213, 215, 218, 222, 225, 229, 230, 231, 232, 236, 239, 242, 251, 257, 260, 265, 275, 282, 287, 297, 301, 309, 312, 321, 325, 330, 331, 334, 337, 342, 343, 348, 357, 364, 371, 375, 382, 384, 393, 397, 403, 404, 406, 411, 414, 418, 422, 426, 433, 437, 448, 450, 452, 456, 459, 469, 471, 478, 482, 493, 495, 501, 503, 506, 508, 513, 514, 517, 519, 520, 522, 526, 529, 534, 536, 556, 557, 563, 571, 575, 581, 593, 596, 600, 601, 609, 617, 622, 624, 626, 630, 635, 638, 640, 649, 653, 656, 667, 674, 678, 682, 687, 689, 693, 694, 698, 703, 710, 712, 715, 716, 720, 722, 723, 724, 725, 729, 731, 739, 750, 753, 757, 759, 764, 767, 770, 771, 775, 780, 781, 784, 787, 790, 792, 796, 798, 802, 807, 811, 815, 819, 823, 827, 831, 837, 843, 845, 850, 854, 857, 860, 861, 863, 864, 865, 866, 873, 874, 876 3: * Copyright (c) 2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #include 8: #include 9: 10: #include "adreno.h" 11: #include "adreno_gen8.h" 12: #include "adreno_gen8_gmu.h" 13: #include "adreno_gen8_hfi.h" 14: #include "kgsl_device.h" 15: #include "kgsl_gmu_core.h" 16: #include "kgsl_trace.h" 17: 18: /* Below section is for all structures related to HFI queues */ 19: #define HFI_QUEUE_MAX HFI_QUEUE_DEFAULT_CNT 20: 21: /* Total header sizes + queue sizes + 16 for alignment */ 22: #define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \ 23: (HFI_QUEUE_SIZE * HFI_QUEUE_MAX)) 24: 25: #define HOST_QUEUE_START_ADDR(hfi_mem, i) \ 26: ((hfi_mem)->hostptr + HFI_QUEUE_OFFSET(i)) 27: 28: struct gen8_hfi *to_gen8_hfi(struct adreno_device *adreno_dev) 29: { 30: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 31: 32: return &gmu->hfi; 33: } 34: 35: /* Size in below functions are in unit of dwords */ 36: int gen8_hfi_queue_read(struct gen8_gmu_device *gmu, u32 queue_idx, 37: u32 *output, u32 max_size) 38: { 39: struct kgsl_device *device = KGSL_DEVICE(gen8_gmu_to_adreno(gmu)); 40: struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem; 41: struct hfi_queue_table *tbl = mem_addr->hostptr; 42: struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx]; 43: u32 *queue; 44: u32 msg_hdr; 45: u32 i, read; 46: u32 size; 47: int result = 0; 48: 49: if (hdr->status == HFI_QUEUE_STATUS_DISABLED) 50: return -EINVAL; 51: 52: if (hdr->read_index == hdr->write_index) 53: return -ENODATA; 54: 55: /* Clear the output data before populating */ 56: memset(output, 0, max_size); 57: 58: queue = HOST_QUEUE_START_ADDR(mem_addr, queue_idx); 59: msg_hdr = queue[hdr->read_index]; 60: size = MSG_HDR_GET_SIZE(msg_hdr); 61: 62: if (size > (max_size >> 2)) { 63: dev_err(GMU_PDEV_DEV(device), 64: "HFI message too big: hdr:0x%x rd idx=%d\n", 65: msg_hdr, hdr->read_index); 66: result = -EMSGSIZE; 67: goto done; 68: } 69: 70: read = hdr->read_index; 71: 72: if (read < hdr->queue_size) { 73: for (i = 0; i < size && i < (max_size >> 2); i++) { 74: output[i] = queue[read]; 75: read = (read + 1)%hdr->queue_size; 76: } 77: result = size; 78: } else { 79: /* In case FW messed up */ 80: dev_err(GMU_PDEV_DEV(device), 81: "Read index %d greater than queue size %d\n", 82: hdr->read_index, hdr->queue_size); 83: result = -ENODATA; 84: } 85: 86: read = ALIGN(read, SZ_4) % hdr->queue_size; 87: 88: hfi_update_read_idx(hdr, read); 89: 90: /* For acks, trace the packet for which this ack was sent */ 91: if (MSG_HDR_GET_TYPE(msg_hdr) == HFI_MSG_ACK) 92: trace_kgsl_hfi_receive(MSG_HDR_GET_ID(output[1]), 93: MSG_HDR_GET_SIZE(output[1]), 94: MSG_HDR_GET_SEQNUM(output[1])); 95: else 96: trace_kgsl_hfi_receive(MSG_HDR_GET_ID(msg_hdr), 97: MSG_HDR_GET_SIZE(msg_hdr), MSG_HDR_GET_SEQNUM(msg_hdr)); 98: 99: done: 100: return result; 101: } 102: 103: int gen8_hfi_queue_write(struct adreno_device *adreno_dev, u32 queue_idx, 104: u32 *msg, u32 size_bytes) 105: { 106: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 107: struct hfi_queue_table *tbl = gmu->hfi.hfi_mem->hostptr; 108: struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx]; 109: u32 *queue; 110: u32 i, write_idx, read_idx, empty_space; 111: u32 size_dwords = size_bytes >> 2; 112: u32 align_size = ALIGN(size_dwords, SZ_4); 113: u32 id = MSG_HDR_GET_ID(*msg); 114: 115: if (hdr->status == HFI_QUEUE_STATUS_DISABLED || !IS_ALIGNED(size_bytes, sizeof(u32))) 116: return -EINVAL; 117: 118: queue = HOST_QUEUE_START_ADDR(gmu->hfi.hfi_mem, queue_idx); 119: 120: write_idx = hdr->write_index; 121: read_idx = hdr->read_index; 122: 123: empty_space = (write_idx >= read_idx) ? 124: (hdr->queue_size - (write_idx - read_idx)) 125: : (read_idx - write_idx); 126: 127: if (empty_space <= align_size) 128: return -ENOSPC; 129: 130: for (i = 0; i < size_dwords; i++) { 131: queue[write_idx] = msg[i]; 132: write_idx = (write_idx + 1) % hdr->queue_size; 133: } 134: 135: /* Cookify any non used data at the end of the write buffer */ 136: for (; i < align_size; i++) { 137: queue[write_idx] = 0xfafafafa; 138: write_idx = (write_idx + 1) % hdr->queue_size; 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 gen8_hfi_cmdq_write(struct adreno_device *adreno_dev, u32 *msg, u32 size_bytes) 149: { 150: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 151: struct gen8_hfi *hfi = &gmu->hfi; 152: int ret; 153: 154: spin_lock(&hfi->cmdq_lock); 155: 156: if (test_bit(MSG_HDR_GET_ID(msg[0]), hfi->wb_set_record_bitmask)) 157: *msg = RECORD_MSG_HDR(*msg); 158: 159: ret = gen8_hfi_queue_write(adreno_dev, HFI_CMD_ID, msg, size_bytes); 160: 161: /* 162: * Some messages like ACD table and perf table are saved in memory, so we need 163: * to reset the header to make sure we do not send a record enabled bit incase 164: * we change the warmboot setting from debugfs 165: */ 166: *msg = CLEAR_RECORD_MSG_HDR(*msg); 167: /* 168: * Memory barrier to make sure packet and write index are written before 169: * an interrupt is raised 170: */ 171: wmb(); 172: 173: /* Send interrupt to GMU to receive the message */ 174: if (!ret) 175: gmu_core_regwrite(KGSL_DEVICE(adreno_dev), 176: GEN8_GMUCX_HOST2GMU_INTR_SET, 0x1); 177: 178: spin_unlock(&hfi->cmdq_lock); 179: 180: return ret; 181: } 182: 183: /* Sizes of the queue and message are in unit of dwords */ 184: static void init_queues(struct adreno_device *adreno_dev) 185: { 186: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 187: struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem; 188: int i; 189: struct hfi_queue_table *tbl; 190: struct hfi_queue_header *hdr; 191: struct { 192: u32 idx; 193: u32 pri; 194: u32 status; 195: } queue[HFI_QUEUE_MAX] = { 196: { HFI_CMD_ID, HFI_CMD_PRI, HFI_QUEUE_STATUS_ENABLED }, 197: { HFI_MSG_ID, HFI_MSG_PRI, HFI_QUEUE_STATUS_ENABLED }, 198: { HFI_DBG_ID, HFI_DBG_PRI, HFI_QUEUE_STATUS_ENABLED }, 199: }; 200: 201: /* Fill Table Header */ 202: tbl = mem_addr->hostptr; 203: tbl->qtbl_hdr.version = 0; 204: tbl->qtbl_hdr.size = sizeof(struct hfi_queue_table) >> 2; 205: tbl->qtbl_hdr.qhdr0_offset = sizeof(struct hfi_queue_table_header) >> 2; 206: tbl->qtbl_hdr.qhdr_size = sizeof(struct hfi_queue_header) >> 2; 207: tbl->qtbl_hdr.num_q = HFI_QUEUE_MAX; 208: tbl->qtbl_hdr.num_active_q = HFI_QUEUE_MAX; 209: 210: memset(&tbl->qhdr[0], 0, sizeof(tbl->qhdr)); 211: 212: /* Fill Individual Queue Headers */ 213: for (i = 0; i < HFI_QUEUE_MAX; i++) { 214: hdr = &tbl->qhdr[i]; 215: hdr->start_addr = GMU_QUEUE_START_ADDR(mem_addr->gmuaddr, i); 216: hdr->type = QUEUE_HDR_TYPE(queue[i].idx, queue[i].pri, 0, 0); 217: hdr->status = queue[i].status; 218: hdr->queue_size = HFI_QUEUE_SIZE >> 2; /* convert to dwords */ 219: } 220: } 221: 222: int gen8_hfi_init(struct adreno_device *adreno_dev) 223: { 224: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 225: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 226: struct gen8_hfi *hfi = &gmu->hfi; 227: 228: /* Allocates & maps memory for HFI */ 229: if (IS_ERR_OR_NULL(hfi->hfi_mem)) { 230: hfi->hfi_mem = gmu_core_reserve_kernel_block(device, 0, 231: HFIMEM_SIZE, GMU_NONCACHED_KERNEL, 0); 232: if (!IS_ERR(hfi->hfi_mem)) 233: init_queues(adreno_dev); 234: } 235: 236: return PTR_ERR_OR_ZERO(hfi->hfi_mem); 237: } 238: 239: int gen8_receive_ack_cmd(struct gen8_gmu_device *gmu, void *rcvd, 240: struct pending_cmd *ret_cmd) 241: { 242: struct adreno_device *adreno_dev = gen8_gmu_to_adreno(gmu); 243: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 244: u32 *ack = rcvd; 245: u32 hdr = ack[0]; 246: u32 req_hdr = ack[1]; 247: 248: if (ret_cmd == NULL) 249: return -EINVAL; 250: 251: if (CMP_HFI_ACK_HDR(ret_cmd->sent_hdr, req_hdr)) { 252: memcpy(&ret_cmd->results, ack, MSG_HDR_GET_SIZE(hdr) << 2); 253: return 0; 254: } 255: 256: /* Didn't find the sender, list the waiter */ 257: dev_err_ratelimited(GMU_PDEV_DEV(device), 258: "HFI ACK: Cannot find sender for 0x%8.8x Waiter: 0x%8.8x\n", 259: req_hdr, ret_cmd->sent_hdr); 260: gmu_core_fault_snapshot(device, GMU_FAULT_HFI_RECIVE_ACK); 261: 262: return -ENODEV; 263: } 264: 265: static int poll_gmu_reg(struct adreno_device *adreno_dev, 266: u32 offsetdwords, u32 expected_val, 267: u32 mask, u32 timeout_ms) 268: { 269: u32 val; 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; 307: } 308: 309: static int gen8_hfi_send_cmd_wait_inline(struct adreno_device *adreno_dev, 310: void *data, u32 size_bytes, struct pending_cmd *ret_cmd) 311: { 312: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 313: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 314: int rc; 315: u32 *cmd = data; 316: struct gen8_hfi *hfi = &gmu->hfi; 317: u32 seqnum = atomic_inc_return(&hfi->seqnum); 318: 319: *cmd = MSG_HDR_SET_SEQNUM_SIZE(*cmd, seqnum, size_bytes >> 2); 320: if (ret_cmd == NULL) 321: return gen8_hfi_cmdq_write(adreno_dev, cmd, size_bytes); 322: 323: ret_cmd->sent_hdr = cmd[0]; 324: 325: rc = gen8_hfi_cmdq_write(adreno_dev, cmd, size_bytes); 326: if (rc) 327: return rc; 328: 329: poll: 330: rc = poll_gmu_reg(adreno_dev, GEN8_GMUCX_GMU2HOST_INTR_INFO, 331: HFI_IRQ_MSGQ_MASK, HFI_IRQ_MSGQ_MASK, HFI_RSP_TIMEOUT); 332: 333: if (rc) { 334: dev_err(GMU_PDEV_DEV(device), 335: "Timed out waiting on ack for 0x%8.8x (id %d, sequence %d)\n", 336: cmd[0], MSG_HDR_GET_ID(*cmd), MSG_HDR_GET_SEQNUM(*cmd)); 337: gmu_core_fault_snapshot(device, GMU_FAULT_SEND_CMD_WAIT_INLINE); 338: return rc; 339: } 340: 341: /* Clear the interrupt */ 342: gmu_core_regwrite(device, GEN8_GMUCX_GMU2HOST_INTR_CLR, 343: HFI_IRQ_MSGQ_MASK); 344: 345: /* Add a barrier to ensure interrupt is cleared before reading queue and polling again */ 346: mb(); 347: 348: rc = gen8_hfi_process_queue(gmu, HFI_MSG_ID, ret_cmd); 349: 350: /* If ACK not received, try polling again */ 351: if (rc == -EAGAIN) 352: goto poll; 353: 354: return rc; 355: } 356: 357: int gen8_hfi_send_generic_req(struct adreno_device *adreno_dev, void *cmd, u32 size_bytes) 358: { 359: struct pending_cmd ret_cmd; 360: int rc; 361: 362: memset(&ret_cmd, 0, sizeof(ret_cmd)); 363: 364: rc = gen8_hfi_send_cmd_wait_inline(adreno_dev, cmd, size_bytes, &ret_cmd); 365: if (rc) 366: return rc; 367: 368: if (ret_cmd.results[2]) { 369: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 370: 371: dev_err(GMU_PDEV_DEV(device), 372: "HFI ACK failure: Req=0x%8.8X, Result=0x%8.8X\n", 373: ret_cmd.results[1], 374: ret_cmd.results[2]); 375: gmu_core_fault_snapshot(device, GMU_FAULT_HFI_SEND_GENERIC_REQ); 376: return -EINVAL; 377: } 378: 379: return 0; 380: } 381: 382: int gen8_hfi_send_core_fw_start(struct adreno_device *adreno_dev) 383: { 384: struct hfi_core_fw_start_cmd cmd = { 385: .handle = 0x0, 386: }; 387: int ret; 388: 389: ret = CMD_MSG_HDR(cmd, H2F_MSG_CORE_FW_START); 390: if (ret) 391: return ret; 392: 393: return gen8_hfi_send_generic_req(adreno_dev, &cmd, sizeof(cmd)); 394: } 395: 396: /* For sending hfi message inline to handle GMU return type error */ 397: int gen8_hfi_send_generic_req_v5(struct adreno_device *adreno_dev, void *cmd, 398: struct pending_cmd *ret_cmd, u32 size_bytes) 399: { 400: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 401: int rc; 402: 403: if (GMU_VER_MINOR(device->gmu_core.ver.hfi) <= 4) 404: return gen8_hfi_send_generic_req(adreno_dev, cmd, size_bytes); 405: 406: rc = gen8_hfi_send_cmd_wait_inline(adreno_dev, cmd, size_bytes, ret_cmd); 407: if (rc) 408: return rc; 409: 410: switch (ret_cmd->results[3]) { 411: case GMU_SUCCESS: 412: rc = ret_cmd->results[2]; 413: break; 414: case GMU_ERROR_NO_ENTRY: 415: /* Unique error to handle undefined HFI msgs by caller */ 416: rc = -ENOENT; 417: break; 418: case GMU_ERROR_TIMEOUT: 419: rc = -EINVAL; 420: break; 421: default: 422: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)), 423: "HFI ACK: Req=0x%8.8X, Result=0x%8.8X Error:0x%8.8X\n", 424: ret_cmd->results[1], ret_cmd->results[2], ret_cmd->results[3]); 425: rc = -EINVAL; 426: gmu_core_fault_snapshot(KGSL_DEVICE(adreno_dev), GMU_FAULT_HFI_SEND_GENERIC_REQ); 427: break; 428: } 429: 430: return rc; 431: } 432: 433: int gen8_hfi_send_feature_ctrl(struct adreno_device *adreno_dev, 434: u32 feature, u32 enable, u32 data) 435: { 436: struct pending_cmd ret_cmd = {0}; 437: struct hfi_feature_ctrl_cmd cmd = { 438: .feature = feature, 439: .enable = enable, 440: .data = data, 441: }; 442: int ret; 443: 444: ret = CMD_MSG_HDR(cmd, H2F_MSG_FEATURE_CTRL); 445: if (ret) 446: return ret; 447: 448: ret = gen8_hfi_send_generic_req_v5(adreno_dev, &cmd, &ret_cmd, sizeof(cmd)); 449: if (ret < 0) 450: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)), 451: "Unable to %s feature %s (%d)\n", 452: enable ? "enable" : "disable", hfi_feature_to_string(feature), feature); 453: return ret; 454: } 455: 456: int gen8_hfi_send_get_value(struct adreno_device *adreno_dev, u32 type, u32 subtype) 457: { 458: struct pending_cmd ret_cmd = {0}; 459: struct hfi_get_value_cmd cmd = { 460: .type = type, 461: .subtype = subtype, 462: }; 463: int ret; 464: 465: ret = CMD_MSG_HDR(cmd, H2F_MSG_GET_VALUE); 466: if (ret) 467: return ret; 468: 469: ret = gen8_hfi_send_generic_req_v5(adreno_dev, &cmd, &ret_cmd, sizeof(cmd)); 470: if (ret < 0) 471: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)), 472: "Unable to get HFI Value type: %d, subtype: %d, error = %d\n", 473: type, subtype, ret); 474: 475: return ret; 476: } 477: 478: int gen8_hfi_send_set_value(struct adreno_device *adreno_dev, 479: u32 type, u32 subtype, u32 data) 480: { 481: struct pending_cmd ret_cmd = {0}; 482: struct hfi_set_value_cmd cmd = { 483: .type = type, 484: .subtype = subtype, 485: .data = data, 486: }; 487: int ret; 488: 489: ret = CMD_MSG_HDR(cmd, H2F_MSG_SET_VALUE); 490: if (ret) 491: return ret; 492: 493: ret = gen8_hfi_send_generic_req_v5(adreno_dev, &cmd, &ret_cmd, sizeof(cmd)); 494: if (ret < 0) 495: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)), 496: "Unable to set HFI Value %d, %d to %d, error = %d\n", 497: type, subtype, data, ret); 498: return ret; 499: } 500: 501: void adreno_gen8_receive_err_req(struct gen8_gmu_device *gmu, void *rcvd) 502: { 503: struct kgsl_device *device = KGSL_DEVICE(gen8_gmu_to_adreno(gmu)); 504: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(ADRENO_DEVICE(device)); 505: u64 ticks = gpudev->read_alwayson(ADRENO_DEVICE(device)); 506: struct hfi_err_cmd *cmd = rcvd; 507: 508: dev_err(GMU_PDEV_DEV(device), "HFI Error Received: %d %d %.16s\n", 509: ((cmd->error_code >> 16) & 0xffff), 510: (cmd->error_code & 0xffff), 511: (char *) cmd->data); 512: 513: KGSL_GMU_CORE_FORCE_PANIC(device->gmu_core.gf_panic, 514: GMU_PDEV(device), ticks, GMU_FAULT_F2H_MSG_ERR); 515: } 516: 517: void adreno_gen8_receive_debug_req(struct gen8_gmu_device *gmu, void *rcvd) 518: { 519: struct kgsl_device *device = KGSL_DEVICE(gen8_gmu_to_adreno(gmu)); 520: struct hfi_debug_cmd *cmd = rcvd; 521: 522: dev_dbg(GMU_PDEV_DEV(device), "HFI Debug Received: %d %d %d\n", 523: cmd->type, cmd->timestamp, cmd->data); 524: } 525: 526: int gen8_hfi_process_queue(struct gen8_gmu_device *gmu, 527: u32 queue_idx, struct pending_cmd *ret_cmd) 528: { 529: struct kgsl_device *device = KGSL_DEVICE(gen8_gmu_to_adreno(gmu)); 530: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 531: u32 rcvd[MAX_RCVD_SIZE]; 532: bool retry_for_ack = true; 533: 534: while (gen8_hfi_queue_read(gmu, queue_idx, rcvd, sizeof(rcvd)) > 0) { 535: /* ACK Handler */ 536: if (MSG_HDR_GET_TYPE(rcvd[0]) == HFI_MSG_ACK) { 537: int ret = gen8_receive_ack_cmd(gmu, rcvd, ret_cmd); 538: 539: if (ret) 540: return ret; 541: 542: retry_for_ack = false; 543: continue; 544: } 545: 546: /* Request Handler */ 547: switch (MSG_HDR_GET_ID(rcvd[0])) { 548: case F2H_MSG_ERR: /* No Reply */ 549: adreno_gen8_receive_err_req(gmu, rcvd); 550: retry_for_ack = false; 551: break; 552: case F2H_MSG_DEBUG: /* No Reply */ 553: adreno_gen8_receive_debug_req(gmu, rcvd); 554: break; 555: case F2H_MSG_PROCESS_TRACE: 556: gmu_core_process_trace_data(device, 557: GMU_PDEV_DEV(device), &device->gmu_core.trace); 558: break; 559: case F2H_MSG_PLATFORM_LA: 560: gen8_hwsched_process_f2h_platform_msg(adreno_dev, rcvd); 561: break; 562: default: /* No Reply */ 563: dev_err(GMU_PDEV_DEV(device), 564: "HFI request %d not supported\n", 565: MSG_HDR_GET_ID(rcvd[0])); 566: break; 567: } 568: } 569: 570: /** 571: * gen8_hfi_process_queue with HFI_MSG_ID uses a synchronous HFI which expects 572: * an ACK. Poll again if we processed the queue but didn't receive the expected ACK. 573: * Return -EAGAIN to trigger another polling attempt. 574: */ 575: if ((retry_for_ack) && (queue_idx == HFI_MSG_ID)) 576: return -EAGAIN; 577: 578: return 0; 579: } 580: 581: int gen8_hfi_send_bcl_feature_ctrl(struct adreno_device *adreno_dev) 582: { 583: if (!adreno_dev->bcl_enabled) 584: return 0; 585: 586: /* 587: * BCL data is expected by gmu in below format 588: * BIT[0] - response type 589: * BIT[1:7] - Throttle level 1 (optional) 590: * BIT[8:14] - Throttle level 2 (optional) 591: * BIT[15:21] - Throttle level 3 (optional) 592: */ 593: return gen8_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_BCL, 1, adreno_dev->bcl_data); 594: } 595: 596: int gen8_hfi_send_iff_pclx_feature_ctrl(struct adreno_device *adreno_dev) 597: { 598: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev); 599: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 600: static struct hfi_table_cmd *tbl_cmd; 601: struct hfi_table_entry *entry; 602: u32 hdr_size, len; 603: int ret; 604: 605: if (!gen8_core->limits_mit_cfg) 606: return 0; 607: 608: len = gen8_core->limits_mit_cfg->len; 609: hdr_size = sizeof(*tbl_cmd) + sizeof(*entry) + (len * sizeof(struct hfi_limits_mit_tbl)); 610: 611: if (!tbl_cmd) { 612: tbl_cmd = devm_kzalloc(&device->pdev->dev, hdr_size, GFP_KERNEL); 613: if (!tbl_cmd) 614: return -ENOMEM; 615: } 616: 617: ret = gen8_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_IFF_PCLX, 1, 0); 618: if (ret) 619: return ret; 620: 621: if (tbl_cmd->hdr) 622: return gen8_hfi_send_generic_req(adreno_dev, tbl_cmd, hdr_size); 623: 624: tbl_cmd->hdr = CREATE_MSG_HDR(H2F_MSG_TABLE, HFI_MSG_CMD); 625: tbl_cmd->version = 0; 626: tbl_cmd->type = HFI_TABLE_LIMITS_MITIGATION; 627: 628: entry = tbl_cmd->entry; 629: entry->count = len; 630: entry->stride = sizeof(struct hfi_limits_mit_tbl) >> 2; 631: 632: memcpy(entry->data, gen8_core->limits_mit_cfg->limits_mit_tbl, 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 */ 670: ret = CMD_MSG_HDR(cmd, H2F_MSG_CLX_TBL); 671: if (ret) 672: return ret; 673: 674: ret = gen8_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_CLX, 1, 0); 675: if (ret) 676: return ret; 677: 678: ret = gen8_hfi_send_generic_req(adreno_dev, &cmd, sizeof(cmd)); 679: if (ret) 680: return ret; 681: 682: return gen8_hfi_send_iff_pclx_feature_ctrl(adreno_dev); 683: } 684: 685: #define EVENT_PWR_ACD_THROTTLE_PROF 44 686: 687: int gen8_hfi_send_acd_feature_ctrl(struct adreno_device *adreno_dev) 688: { 689: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 690: int ret = 0; 691: 692: if (adreno_dev->acd_enabled) { 693: ret = gen8_hfi_send_feature_ctrl(adreno_dev, 694: HFI_FEATURE_ACD, 1, 0); 695: if (ret) 696: return ret; 697: 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) 741: { 742: entry->count = count; 743: entry->stride = stride_bytes >> 2; /* entry->stride is in dwords */ 744: memcpy(entry->data, data, stride_bytes * count); 745: 746: /* Return total dword count of entry + data */ 747: return (sizeof(*entry) >> 2) + (entry->count * entry->stride); 748: } 749: 750: int gen8_hfi_send_gpu_perf_table(struct adreno_device *adreno_dev) 751: { 752: /* 753: * Buffer to store either hfi_table_cmd or hfi_dcvstable_cmd. 754: * Current max size for either is 165 dwords. 755: */ 756: static u32 cmd_buf[200]; 757: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 758: struct gen8_dcvs_table *tbl = &gmu->dcvs_table; 759: struct hfi_table_cmd *cmd = (struct hfi_table_cmd *)&cmd_buf[0]; 760: u32 dword_off; 761: 762: /* Already setup, so just send cmd */ 763: if (cmd->hdr) 764: return gen8_hfi_send_generic_req(adreno_dev, cmd, 765: MSG_HDR_GET_SIZE(cmd->hdr) << 2); 766: 767: if (tbl->gpu_level_num > MAX_GX_LEVELS || tbl->gmu_level_num > MAX_CX_LEVELS) 768: return -EINVAL; 769: 770: /* CMD starts with struct hfi_table_cmd data */ 771: cmd->type = HFI_TABLE_GPU_PERF; 772: dword_off = sizeof(*cmd) >> 2; 773: 774: /* Fill in the table entry and data starting at dword_off */ 775: dword_off += _fill_table_entry((struct hfi_table_entry *)&cmd_buf[dword_off], 776: tbl->gpu_level_num, sizeof(struct opp_gx_desc), 777: (u32 *)tbl->gx_votes); 778: 779: /* Fill in the table entry and data starting at dword_off */ 780: dword_off += _fill_table_entry((struct hfi_table_entry *)&cmd_buf[dword_off], 781: tbl->gmu_level_num, sizeof(struct opp_desc), 782: (u32 *)tbl->cx_votes); 783: 784: cmd->hdr = CREATE_MSG_HDR(H2F_MSG_TABLE, HFI_MSG_CMD); 785: cmd->hdr = MSG_HDR_SET_SIZE(cmd->hdr, dword_off); 786: 787: return gen8_hfi_send_generic_req(adreno_dev, cmd, dword_off << 2); 788: } 789: 790: int gen8_hfi_start(struct adreno_device *adreno_dev) 791: { 792: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 793: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 794: int result; 795: 796: reset_hfi_queues(adreno_dev); 797: 798: result = gen8_hfi_send_gpu_perf_table(adreno_dev); 799: if (result) 800: goto err; 801: 802: result = gen8_hfi_send_generic_req(adreno_dev, &gmu->hfi.bw_table, 803: sizeof(gmu->hfi.bw_table)); 804: if (result) 805: goto err; 806: 807: result = gen8_hfi_send_acd_feature_ctrl(adreno_dev); 808: if (result) 809: goto err; 810: 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: 848: kgsl_pwrctrl_axi(device, false); 849: 850: clear_bit(GMU_PRIV_HFI_STARTED, &gmu->flags); 851: } 852: 853: /* HFI interrupt handler */ 854: irqreturn_t gen8_hfi_irq_handler(int irq, void *data) 855: { 856: struct kgsl_device *device = data; 857: struct gen8_gmu_device *gmu = to_gen8_gmu(ADRENO_DEVICE(device)); 858: u32 status = 0; 859: 860: gmu_core_regread(device, GEN8_GMUCX_GMU2HOST_INTR_INFO, &status); 861: gmu_core_regwrite(device, GEN8_GMUCX_GMU2HOST_INTR_CLR, HFI_IRQ_MASK); 862: 863: if (status & HFI_IRQ_DBGQ_MASK) 864: gen8_hfi_process_queue(gmu, HFI_DBG_ID, NULL); 865: if (status & HFI_IRQ_CM3_FAULT_MASK) { 866: dev_err_ratelimited(GMU_PDEV_DEV(device), 867: "GMU CM3 fault interrupt received\n"); 868: atomic_set(&gmu->cm3_fault, 1); 869: 870: /* make sure other CPUs see the update */ 871: smp_wmb(); 872: } 873: if (status & ~HFI_IRQ_MASK) 874: dev_err_ratelimited(GMU_PDEV_DEV(device), 875: "Unhandled HFI interrupts 0x%lx\n", 876: status & ~HFI_IRQ_MASK); 877: 878: return IRQ_HANDLED; 879: } --- FILE: \adreno_gen8_hfi.h | HITS: 51 --- MATCH LINES: 7, 8, 22, 23, 25, 27, 34, 37, 39, 40, 43, 48, 51, 56, 59, 67, 73, 81, 85, 93, 104, 108, 116, 120, 127, 130, 138, 142, 147, 150, 155, 158, 165, 168, 176, 180, 185, 188, 193, 196, 201, 204, 209, 212, 217, 220, 227, 231, 240, 241, 242 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) 2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #ifndef __ADRENO_GEN8_HFI_H 8: #define __ADRENO_GEN8_HFI_H 9: 10: #include "adreno_hfi.h" 11: 12: /** 13: * struct gen8_hfi - HFI control structure 14: */ 15: struct gen8_hfi { 16: /** @irq: HFI interrupt line */ 17: int irq; 18: /** @seqnum: atomic counter that is incremented for each message sent. 19: * The value of the counter is used as sequence number for HFI message. 20: */ 21: atomic_t seqnum; 22: /** @hfi_mem: Memory descriptor for the hfi memory */ 23: struct kgsl_memdesc *hfi_mem; 24: /** @bw_table: HFI BW table buffer */ 25: struct hfi_bwtable_cmd bw_table; 26: /** @acd_table: HFI table for ACD data */ 27: struct hfi_acd_table_cmd acd_table; 28: /** @cmdq_lock: Spinlock for accessing the cmdq */ 29: spinlock_t cmdq_lock; 30: /** 31: * @wb_set_record_bitmask: Bitmask to enable or disable the recording 32: * of messages in the GMU scratch. 33: */ 34: unsigned long wb_set_record_bitmask[BITS_TO_LONGS(HFI_MAX_ID)]; 35: }; 36: 37: struct gen8_gmu_device; 38: 39: /* gen8_hfi_irq_handler - IRQ handler for HFI interripts */ 40: irqreturn_t gen8_hfi_irq_handler(int irq, void *data); 41: 42: /** 43: * gen8_hfi_start - Send the various HFIs during device boot up 44: * @adreno_dev: Pointer to the adreno device 45: * 46: * Return: 0 on success or negative error on failure 47: */ 48: int gen8_hfi_start(struct adreno_device *adreno_dev); 49: 50: /** 51: * gen8_hfi_start - Send the various HFIs during device boot up 52: * @adreno_dev: Pointer to the adreno device 53: * 54: * Return: 0 on success or negative error on failure 55: */ 56: void gen8_hfi_stop(struct adreno_device *adreno_dev); 57: 58: /** 59: * gen8_hfi_init - Initialize hfi resources 60: * @adreno_dev: Pointer to the adreno device 61: * 62: * This function allocates and sets up hfi queues 63: * when a process creates the very first kgsl instance 64: * 65: * Return: 0 on success or negative error on failure 66: */ 67: int gen8_hfi_init(struct adreno_device *adreno_dev); 68: 69: /* Helper function to get to gen8 hfi struct from adreno device */ 70: struct gen8_hfi *to_gen8_hfi(struct adreno_device *adreno_dev); 71: 72: /** 73: * gen8_hfi_queue_write - Write a command to hfi queue 74: * @adreno_dev: Pointer to the adreno device 75: * @queue_idx: destination queue id 76: * @msg: Data to be written to the queue 77: * @size_bytes: Size of the command in bytes 78: * 79: * Return: 0 on success or negative error on failure 80: */ 81: int gen8_hfi_queue_write(struct adreno_device *adreno_dev, u32 queue_idx, 82: u32 *msg, u32 size_bytes); 83: 84: /** 85: * gen8_hfi_queue_read - Read data from hfi queue 86: * @gmu: Pointer to the gen8 gmu device 87: * @queue_idx: queue id to read from 88: * @output: Pointer to read the data into 89: * @max_size: Number of bytes to read from the queue 90: * 91: * Return: Size of the message read on success or negative error on failure 92: */ 93: int gen8_hfi_queue_read(struct gen8_gmu_device *gmu, u32 queue_idx, 94: u32 *output, u32 max_size); 95: 96: /** 97: * gen8_receive_ack_cmd - Process ack type packets 98: * @gmu: Pointer to the gen8 gmu device 99: * @rcvd: Pointer to the data read from hfi queue 100: * @ret_cmd: Container for the hfi packet for which this ack is received 101: * 102: * Return: 0 on success or negative error on failure 103: */ 104: int gen8_receive_ack_cmd(struct gen8_gmu_device *gmu, void *rcvd, 105: struct pending_cmd *ret_cmd); 106: 107: /** 108: * gen8_hfi_send_feature_ctrl - Enable gmu feature via hfi 109: * @adreno_dev: Pointer to the adreno device 110: * @feature: feature to be enabled or disabled 111: * enable: Set 1 to enable or 0 to disable a feature 112: * @data: payload for the send feature hfi packet 113: * 114: * Return: 0 on success or negative error on failure 115: */ 116: int gen8_hfi_send_feature_ctrl(struct adreno_device *adreno_dev, 117: u32 feature, u32 enable, u32 data); 118: 119: /** 120: * gen8_hfi_send_get_value - Send gmu get_values via hfi 121: * @adreno_dev: Pointer to the adreno device 122: * @type: GMU get_value type 123: * @subtype: GMU get_value subtype 124: * 125: * Return: 0 on success or negative error on failure 126: */ 127: int gen8_hfi_send_get_value(struct adreno_device *adreno_dev, u32 type, u32 subtype); 128: 129: /** 130: * gen8_hfi_send_set_value - Send gmu set_values via hfi 131: * @adreno_dev: Pointer to the adreno device 132: * @type: GMU set_value type 133: * @subtype: GMU set_value subtype 134: * @data: Value to set 135: * 136: * Return: 0 on success or negative error on failure 137: */ 138: int gen8_hfi_send_set_value(struct adreno_device *adreno_dev, 139: u32 type, u32 subtype, u32 data); 140: 141: /** 142: * gen8_hfi_send_core_fw_start - Send the core fw start hfi 143: * @adreno_dev: Pointer to the adreno device 144: * 145: * Return: 0 on success or negative error on failure 146: */ 147: int gen8_hfi_send_core_fw_start(struct adreno_device *adreno_dev); 148: 149: /** 150: * gen8_hfi_send_acd_feature_ctrl - Send the acd table and acd feature 151: * @adreno_dev: Pointer to the adreno device 152: * 153: * Return: 0 on success or negative error on failure 154: */ 155: int gen8_hfi_send_acd_feature_ctrl(struct adreno_device *adreno_dev); 156: 157: /** 158: * gen8_hfi_send_generic_req - Send a generic hfi packet 159: * @adreno_dev: Pointer to the adreno device 160: * @cmd: Pointer to the hfi packet header and data 161: * @size_bytes: Size of the packet in bytes 162: * 163: * Return: 0 on success or negative error on failure 164: */ 165: int gen8_hfi_send_generic_req(struct adreno_device *adreno_dev, void *cmd, u32 size_bytes); 166: 167: /** 168: * gen8_hfi_send_generic_req_v5 - Send a generic hfi packet with additional error handling 169: * @adreno_dev: Pointer to the adreno device 170: * @cmd: Pointer to the hfi packet header and data 171: * @ret_cmd: Ack for the command we just sent 172: * @size_bytes: Size of the packet in bytes 173: * 174: * Return: 0 on success or negative error on failure 175: */ 176: int gen8_hfi_send_generic_req_v5(struct adreno_device *adreno_dev, void *cmd, 177: struct pending_cmd *ret_cmd, u32 size_bytes); 178: 179: /** 180: * gen8_hfi_send_bcl_feature_ctrl - Send the bcl feature hfi packet 181: * @adreno_dev: Pointer to the adreno device 182: * 183: * Return: 0 on success or negative error on failure 184: */ 185: int gen8_hfi_send_bcl_feature_ctrl(struct adreno_device *adreno_dev); 186: 187: /** 188: * gen8_hfi_send_minbw_feature_ctrl - Send the minbw feature hfi packet 189: * @adreno_dev: Pointer to the adreno device 190: * 191: * Return: 0 on success or negative error on failure 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 234: * @size_bytes: Size of the command in bytes 235: * 236: * This function takes the cmdq lock before writing data to the queue 237: 238: * Return: 0 on success or negative error on failure 239: */ 240: int gen8_hfi_cmdq_write(struct adreno_device *adreno_dev, u32 *msg, u32 size_bytes); 241: void adreno_gen8_receive_err_req(struct gen8_gmu_device *gmu, void *rcvd); 242: void adreno_gen8_receive_debug_req(struct gen8_gmu_device *gmu, void *rcvd); 243: #endif --- FILE: \adreno_gen8_hwsched.c | HITS: 235 --- MATCH LINES: 15 3: * Copyright (c) 2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #include 8: 9: #include "adreno.h" 10: #include "adreno_gen8.h" 11: #include "adreno_gen8_hwsched.h" 12: #include "adreno_snapshot.h" 13: #include "kgsl_bus.h" 14: #include "kgsl_device.h" 15: #include "kgsl_gmu_core.h" 16: #include "kgsl_trace.h" 17: #include "kgsl_util.h" 18: 19: static void _wakeup_hw_fence_waiters(struct adreno_device *adreno_dev, u32 fault) 20: { 21: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev); 22: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 23: bool lock = !in_interrupt(); 24: 25: if (!test_bit(ADRENO_HWSCHED_HW_FENCE, &adreno_dev->hwsched.flags)) 26: return; 27: 28: /* 29: * We could be in interrupt context here, which means we need to use spin_lock_irqsave 30: * (which disables interrupts) everywhere we take this lock. Instead of that, simply 31: * avoid taking this lock if we are recording a fault from an interrupt handler. 32: */ 33: if (lock) 34: spin_lock(&hwf->lock); 35: 36: clear_bit(GEN8_HWSCHED_HW_FENCE_SLEEP_BIT, &hwf->flags); 37: 38: /* Avoid creating new hardware fences until recovery is complete */ 39: set_bit(GEN8_HWSCHED_HW_FENCE_ABORT_BIT, &hwf->flags); MATCH LINES: 75, 91, 93, 99, 105, 111, 117, 121, 127, 133, 134, 137, 139, 140, 163, 174, 181, 187, 200, 201, 206, 208, 209, 216, 220, 222, 226, 238, 239, 244, 246, 252, 256, 262, 273, 301, 305, 311, 313, 317, 325, 329, 337, 343, 347, 348, 351, 353, 354, 361, 366, 374, 377, 378, 382, 385, 392, 409, 425, 445, 449, 451, 458, 462, 466, 472, 475, 476, 480, 483, 490, 523, 524, 534, 536, 540, 546, 550, 555, 559, 567, 573, 578, 580, 582, 588, 592, 597, 598, 599 63: adreno_scheduler_fault(adreno_dev, fault); 64: } 65: 66: void gen8_hwsched_snapshot(struct adreno_device *adreno_dev, 67: struct kgsl_snapshot *snapshot) 68: { 69: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 70: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 71: bool skip_memkind_rb = false; 72: u32 i; 73: bool parse_payload; 74: 75: gen8_gmu_snapshot(adreno_dev, snapshot); 76: 77: adreno_hwsched_parse_fault_cmdobj(adreno_dev, snapshot); 78: 79: /* 80: * First try to dump ringbuffers using context bad HFI payloads 81: * because they have all the ringbuffer parameters. If ringbuffer 82: * payloads are not present, fall back to dumping ringbuffers 83: * based on MEMKIND_RB 84: */ 85: parse_payload = adreno_hwsched_parse_payload_rb(adreno_dev, snapshot); 86: 87: if (parse_payload) 88: skip_memkind_rb = true; 89: 90: for (i = 0; i < hwsched->mem_alloc_entries; i++) { 91: struct hfi_mem_alloc_entry *entry = &hwsched->mem_alloc_table[i]; 92: 93: if (entry->desc.mem_kind == HFI_MEMKIND_RB && !skip_memkind_rb) 94: kgsl_snapshot_add_section(device, 95: KGSL_SNAPSHOT_SECTION_RB_V2, 96: snapshot, adreno_hwsched_snapshot_rb, 97: entry->md); 98: 99: if (entry->desc.mem_kind == HFI_MEMKIND_SCRATCH) 100: kgsl_snapshot_add_section(device, 101: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 102: snapshot, adreno_snapshot_global, 103: entry->md); 104: 105: if (entry->desc.mem_kind == HFI_MEMKIND_PROFILE) 106: kgsl_snapshot_add_section(device, 107: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 108: snapshot, adreno_snapshot_global, 109: entry->md); 110: 111: if (entry->desc.mem_kind == HFI_MEMKIND_CSW_SMMU_INFO) 112: kgsl_snapshot_add_section(device, 113: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 114: snapshot, adreno_snapshot_global, 115: entry->md); 116: 117: if (entry->desc.mem_kind == HFI_MEMKIND_CSW_PRIV_NON_SECURE) 118: adreno_hwsched_snapshot_preemption_records(device, snapshot, 119: entry->md); 120: 121: if (entry->desc.mem_kind == HFI_MEMKIND_PREEMPT_SCRATCH) 122: kgsl_snapshot_add_section(device, 123: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 124: snapshot, adreno_snapshot_global, 125: entry->md); 126: 127: if (entry->desc.mem_kind == HFI_MEMKIND_AQE_BUFFER) 128: kgsl_snapshot_add_section(device, 129: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 130: snapshot, adreno_hwsched_snapshot_aqe_buffer, 131: entry->md); 132: 133: if (entry->desc.mem_kind == HFI_MEMKIND_HW_FENCE) { 134: struct gmu_mem_type_desc desc; 135: 136: desc.memdesc = entry->md; 137: desc.type = SNAPSHOT_GMU_MEM_HW_FENCE; 138: kgsl_snapshot_add_section(device, 139: KGSL_SNAPSHOT_SECTION_GMU_MEMORY, 140: snapshot, adreno_snapshot_gmu_mem, &desc); 141: } 142: 143: } 144: 145: adreno_hwsched_snapshot_context_queue(device, snapshot); 146: } 147: 148: static void _get_hw_fence_entries(struct adreno_device *adreno_dev) 149: { 150: struct device_node *node = NULL; 151: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 152: u32 shadow_num_entries = 0; 153: 154: if (!ADRENO_FEATURE(adreno_dev, ADRENO_HW_FENCE)) 155: return; 156: 157: node = of_find_node_by_name(NULL, "qcom,hw-fence"); 158: if (!node) 159: return; 160: 161: if (of_property_read_u32(node, "qcom,hw-fence-table-entries", 162: &shadow_num_entries)) { 163: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)), 164: "qcom,hw-fence-table-entries property not found\n"); 165: shadow_num_entries = 8192; 166: } 167: 168: of_node_put(node); 169: 170: /* 171: * The return value is ignored as it does not need to be returned to the caller. 172: * Any errors are logged within the VRB set API if a failure occurs. 173: */ 174: gmu_core_set_vrb_register(device->gmu_core.vrb, 175: VRB_HW_FENCE_SHADOW_NUM_ENTRIES, shadow_num_entries); 176: } 177: 178: void gen8_hwsched_soccp_vote(struct adreno_device *adreno_dev, bool pwr_on) 179: { 180: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 181: struct device *gmu_pdev_dev = GMU_PDEV_DEV(device); 182: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 183: 184: if (!test_bit(ADRENO_HWSCHED_HW_FENCE, &adreno_dev->hwsched.flags)) 185: return; 186: 187: if (!gmu_core_soccp_vote(device, pwr_on)) 188: return; 189: 190: /* Make sure no more hardware fences are created */ 191: spin_lock(&hwf->lock); 192: set_bit(GEN8_HWSCHED_HW_FENCE_ABORT_BIT, &hwf->flags); 193: spin_unlock(&hwf->lock); 194: 195: /* 196: * It is possible that some hardware fences were created while we were in slumber. Since 197: * soccp power vote failed, these hardware fences may never be signaled. Hence, log them 198: * for debug purposes. 199: */ 200: adreno_hwsched_log_remove_pending_hw_fences(adreno_dev, gmu_pdev_dev); 201: gmu_core_mark_for_coldboot(KGSL_DEVICE(adreno_dev)); 202: 203: adreno_hwsched_deregister_hw_fence(adreno_dev); 204: } 205: 206: static void gen8_hwsched_gmu_suspend(struct adreno_device *adreno_dev, bool force) 207: { 208: gen8_gmu_suspend(adreno_dev, force); 209: adreno_hwsched_reset_hfi_mem(adreno_dev); 210: } 211: 212: static void gen8_hwsched_set_ctxt_record_vrb(struct adreno_device *adreno_dev) 213: { 214: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 215: 216: if (IS_ERR_OR_NULL(device->gmu_core.vrb)) 217: return; 218: 219: /* Populate context record sizes in VRB */ 220: gmu_core_set_vrb_register(device->gmu_core.vrb, VRB_CTXRECORD_TOTAL_SZ, 221: adreno_dev->total_ctxt_record_sz >> 10); 222: gmu_core_set_vrb_register(device->gmu_core.vrb, VRB_CTXRECORD_GMEM_SZ, 223: adreno_gmem_size(adreno_dev) >> 10); 224: 225: /* Populate size of AQE context record */ 226: gmu_core_set_vrb_register(device->gmu_core.vrb, VRB_CTXRECORD_AQE_SZ, 227: adreno_dev->aqe_ctxt_record_sz >> 10); 228: } 229: 230: static void _enable_malu_submissions(struct adreno_device *adreno_dev) 231: { 232: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 233: 234: if (!adreno_dev->malu_enabled) 235: return; 236: 237: /* Make sure GMU FW also supports mALU */ 238: if (gen8_hwsched_hfi_get_value(adreno_dev, HFI_VALUE_MALU, 0) != 1) { 239: dev_err_once(GMU_PDEV_DEV(device), "FW doesn't support mALU\n"); 240: adreno_dev->malu_enabled = false; 241: return; 242: } 243: 244: if (!gmu_core_capabilities_enabled(&KGSL_DEVICE(adreno_dev)->gmu_core.platform_caps, 245: FAC_POWER_CONTROL_WA)) { 246: dev_err_once(GMU_PDEV_DEV(device), "FW doesn't have mALU WA\n"); 247: adreno_dev->malu_enabled = false; 248: return; 249: } 250: } 251: 252: static int gen8_hwsched_gmu_first_boot(struct adreno_device *adreno_dev) 253: { 254: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 255: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 256: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 257: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 258: int level, ret = 0; 259: 260: kgsl_pwrctrl_request_state(device, KGSL_STATE_AWARE); 261: 262: gen8_gmu_aop_send_acd_state(gmu, adreno_dev->acd_enabled); 263: 264: ret = kgsl_pwrctrl_enable_cx_gdsc(device); 265: if (ret) 266: return ret; 267: 268: ret = kgsl_pwrctrl_enable_mx_gdsc(device); 269: if (ret) 270: goto cx_gdsc_off; 271: 272: /* Start the GMU at the lowest available frequency level */ 273: ret = gmu_core_enable_clks(device, 0); 274: if (ret) 275: goto gdsc_off; 276: 277: ret = gen8_scm_gpu_init_cx_regs(adreno_dev); 278: if (ret) 279: goto clks_gdsc_off; 280: 281: gen8_get_gpu_slice_info(adreno_dev); 282: 283: /* 284: * Set context record size after determining slice mask, 285: * as GMEM size depends on it. 286: */ 287: gen8_populate_ctxt_record_size(adreno_dev); 288: 289: gen8_hwsched_set_ctxt_record_vrb(adreno_dev); 290: 291: /* 292: * Enable AHB timeout detection to catch any register access taking longer 293: * time before NOC timeout gets detected. Enable this logic before any 294: * register access which happens to be just after enabling clocks. 295: */ 296: gen8_enable_ahb_timeout_detection(adreno_dev); 297: 298: /* Initialize the CX timer */ 299: gen8_cx_timer_init(adreno_dev); 300: 301: ret = gen8_gmu_load_fw(adreno_dev); 302: if (ret) 303: goto clks_gdsc_off; 304: 305: ret = gen8_gmu_itcm_shadow(adreno_dev); 306: if (ret) 307: goto clks_gdsc_off; 308: 309: _get_hw_fence_entries(adreno_dev); 310: 311: gen8_gmu_register_config(adreno_dev); 312: 313: ret = gen8_gmu_version_info(adreno_dev); 314: if (ret) 315: goto clks_gdsc_off; 316: 317: gen8_gmu_irq_enable(adreno_dev); 318: 319: /* Vote for minimal DDR BW for GMU to init */ 320: level = pwr->pwrlevels[pwr->default_pwrlevel].bus_min; 321: 322: icc_set_bw(pwr->icc_path, 0, kBps_to_icc(pwr->ddr_table[level])); 323: 324: /* This is the minimum GMU FW HFI version required to enable hw fences */ 325: if (GMU_VER_MINOR(device->gmu_core.ver.hfi) >= 7) 326: adreno_hwsched_register_hw_fence(adreno_dev); 327: 328: /* From this GMU FW all RBBM interrupts are handled at GMU */ 329: if (device->gmu_core.ver.core >= GMU_VERSION(5, 01, 06)) 330: adreno_irq_free(adreno_dev); 331: 332: gen8_hwsched_soccp_vote(adreno_dev, true); 333: 334: /* Clear any hwsched faults that might have been left over */ 335: adreno_clear_gpu_fault(adreno_dev); 336: 337: ret = gen8_gmu_device_start(adreno_dev); 338: if (ret) 339: goto err; 340: 341: gen8_get_gpu_feature_info(adreno_dev); 342: 343: ret = gen8_hwsched_hfi_start(adreno_dev); 344: if (ret) 345: goto err; 346: 347: if (adreno_dev->gmu_ab && 348: gen8_hwsched_hfi_get_value(adreno_dev, HFI_VALUE_GMU_AB_VOTE, 0) == 1 && 349: !WARN_ONCE(!adreno_dev->gpucore->num_ddr_channels, 350: "Number of DDR channel is not specified in gpu core")) { 351: set_bit(ADRENO_DEVICE_GMU_AB, &adreno_dev->priv); 352: } else { 353: /* If gmu_ab feature flag is enabled but GMU doesn't support it, set it to false */ 354: adreno_dev->gmu_ab = false; 355: } 356: 357: _enable_malu_submissions(adreno_dev); 358: 359: icc_set_bw(pwr->icc_path, 0, 0); 360: 361: device->gmu_fault = false; 362: 363: memset(hwsched->default_dcvs_tunables, 0xFF, sizeof(hwsched->default_dcvs_tunables)); 364: 365: if (!device->host_based_dcvs) 366: gen8_hwsched_hfi_get_dcvs_tuning_attrs(adreno_dev, HFI_DCVS_ATTRS_DEFAULT, 367: hwsched->default_dcvs_tunables); 368: 369: kgsl_pwrctrl_set_state(device, KGSL_STATE_AWARE); 370: 371: return 0; 372: 373: err: 374: gen8_gmu_irq_disable(adreno_dev); 375: gen8_hwsched_soccp_vote(adreno_dev, false); 376: 377: if (device->gmu_fault) { 378: gen8_hwsched_gmu_suspend(adreno_dev, false); 379: return ret; 380: } 381: 382: adreno_hwsched_reset_hfi_mem(adreno_dev); 383: 384: clks_gdsc_off: 385: gmu_core_disable_clks(device); 386: 387: gdsc_off: 388: kgsl_pwrctrl_disable_mx_gdsc(device); 389: cx_gdsc_off: 390: kgsl_pwrctrl_disable_cx_gdsc(device); 391: 392: gmu_core_rdpm_cx_freq_update(device, 0); 393: 394: return ret; 395: } 396: 397: static void gen8_scm_gpu_tsense_boot(struct adreno_device *adreno_dev) 398: { 399: struct gen8_device *gen8_dev = container_of(adreno_dev, 400: struct gen8_device, adreno_dev); 401: 402: /* Cancel any pending TSENSE work that didn't run */ 403: cancel_work_sync(&gen8_dev->tsense_work); 404: 405: /* Set default tsense measurement window */ 406: gen8_scm_gpu_tsense_default(adreno_dev, true); 407: } 408: 409: static int gen8_hwsched_gmu_boot(struct adreno_device *adreno_dev) 410: { 411: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 412: int ret = 0; 413: 414: kgsl_pwrctrl_request_state(device, KGSL_STATE_AWARE); 415: 416: ret = kgsl_pwrctrl_enable_cx_gdsc(device); 417: if (ret) 418: return ret; 419: 420: ret = kgsl_pwrctrl_enable_mx_gdsc(device); 421: if (ret) 422: goto cx_gdsc_off; 423: 424: /* Start the GMU at the lowest available frequency level */ 425: ret = gmu_core_enable_clks(device, 0); 426: if (ret) 427: goto gdsc_off; 428: 429: gen8_scm_gpu_tsense_boot(adreno_dev); 430: 431: /* 432: * Enable AHB timeout detection to catch any register access taking longer 433: * time before NOC timeout gets detected. Enable this logic before any 434: * register access which happens to be just after enabling clocks. 435: */ 436: gen8_enable_ahb_timeout_detection(adreno_dev); 437: 438: /* Initialize the CX timer */ 439: gen8_cx_timer_init(adreno_dev); 440: 441: ret = gen8_rscc_wakeup_sequence(adreno_dev); 442: if (ret) 443: goto clks_gdsc_off; 444: 445: ret = gen8_gmu_load_fw(adreno_dev); 446: if (ret) 447: goto clks_gdsc_off; 448: 449: gen8_gmu_register_config(adreno_dev); 450: 451: gen8_gmu_irq_enable(adreno_dev); 452: 453: gen8_hwsched_soccp_vote(adreno_dev, true); 454: 455: /* Clear any hwsched faults that might have been left over */ 456: adreno_clear_gpu_fault(adreno_dev); 457: 458: ret = gen8_gmu_device_start(adreno_dev); 459: if (ret) 460: goto err; 461: 462: ret = gen8_hwsched_hfi_start(adreno_dev); 463: if (ret) 464: goto err; 465: 466: device->gmu_fault = false; 467: 468: kgsl_pwrctrl_set_state(device, KGSL_STATE_AWARE); 469: 470: return 0; 471: err: 472: gen8_gmu_irq_disable(adreno_dev); 473: gen8_hwsched_soccp_vote(adreno_dev, false); 474: 475: if (device->gmu_fault) { 476: gen8_hwsched_gmu_suspend(adreno_dev, false); 477: return ret; 478: } 479: 480: adreno_hwsched_reset_hfi_mem(adreno_dev); 481: 482: clks_gdsc_off: 483: gmu_core_disable_clks(device); 484: 485: gdsc_off: 486: kgsl_pwrctrl_disable_mx_gdsc(device); 487: cx_gdsc_off: 488: kgsl_pwrctrl_disable_cx_gdsc(device); 489: 490: gmu_core_rdpm_cx_freq_update(device, 0); 491: 492: return ret; 493: } 494: 495: /* TSENSE suspend work can be done in parallel with GPU suspend */ 496: static void gen8_scm_gpu_tsense_suspend_work(struct work_struct *work) 497: { 498: struct gen8_device *gen8_dev = container_of(work, struct gen8_device, tsense_work); 499: 500: /* Set non-default tsense measurement window */ 501: gen8_scm_gpu_tsense_default(&gen8_dev->adreno_dev, false); 502: } 503: 504: static void gen8_scm_gpu_tsense_suspend(struct adreno_device *adreno_dev) 505: { 506: struct gen8_device *gen8_dev = container_of(adreno_dev, 507: struct gen8_device, adreno_dev); 508: 509: if (!ADRENO_FEATURE(adreno_dev, ADRENO_TSENSE_DYNAMIC_PERIOD)) 510: return; 511: 512: /* 513: * Schedule on the lockless workqueue instead of the kgsl workqueue 514: * to avoid deadlocks with the device mutex 515: */ 516: queue_work(kgsl_driver.lockless_workqueue, &gen8_dev->tsense_work); 517: } 518: 519: static int gen8_hwsched_notify_slumber(struct adreno_device *adreno_dev) 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: 575: /* Now that we are done with GMU and GPU, Clear the GBIF */ 576: ret = gen8_halt_gbif(adreno_dev); 577: 578: gen8_gmu_irq_disable(adreno_dev); 579: 580: gen8_hwsched_hfi_stop(adreno_dev); 581: 582: gmu_core_disable_clks(device); 583: 584: kgsl_pwrctrl_disable_mx_gdsc(device); 585: 586: kgsl_pwrctrl_disable_cx_gdsc(device); 587: 588: gmu_core_rdpm_cx_freq_update(device, 0); 589: 590: kgsl_pwrctrl_set_state(device, KGSL_STATE_NONE); 591: 592: adreno_hwsched_reset_hfi_mem(adreno_dev); 593: 594: return ret; 595: 596: error: 597: gen8_gmu_irq_disable(adreno_dev); 598: gen8_hwsched_hfi_stop(adreno_dev); 599: gen8_hwsched_gmu_suspend(adreno_dev, false); 600: 601: return ret; 602: } 603: 604: void gen8_hwsched_init_ucode_regs(struct adreno_device *adreno_dev) 605: { 606: struct adreno_firmware *fw = ADRENO_FW(adreno_dev, ADRENO_FW_SQE); 607: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 608: 609: /* Program the ucode base for CP */ 610: kgsl_regwrite(device, GEN8_CP_SQE_INSTR_BASE_LO, 611: lower_32_bits(fw->memdesc->gpuaddr)); 612: kgsl_regwrite(device, GEN8_CP_SQE_INSTR_BASE_HI, 613: upper_32_bits(fw->memdesc->gpuaddr)); 614: 615: if (ADRENO_FEATURE(adreno_dev, ADRENO_AQE)) { 616: fw = ADRENO_FW(adreno_dev, ADRENO_FW_AQE); 617: 618: /* Program the ucode base for AQE0 (BV coprocessor) */ 619: kgsl_regwrite(device, GEN8_CP_AQE_INSTR_BASE_LO_0, 620: lower_32_bits(fw->memdesc->gpuaddr)); 621: kgsl_regwrite(device, GEN8_CP_AQE_INSTR_BASE_HI_0, 622: upper_32_bits(fw->memdesc->gpuaddr)); 623: MATCH LINES: 643 631: } 632: } 633: 634: static int gen8_hwsched_gpu_boot(struct adreno_device *adreno_dev) 635: { 636: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 637: int ret; 638: 639: ret = kgsl_mmu_start(device); 640: if (ret) 641: goto err; 642: 643: ret = gen8_gmu_oob_set(device, oob_gpu); 644: if (ret) 645: goto err; 646: 647: /* Clear the busy_data stats - we're starting over from scratch */ 648: memset(&adreno_dev->busy_data, 0, sizeof(adreno_dev->busy_data)); 649: 650: gen8_start(adreno_dev); 651: 652: /* Re-initialize the coresight registers if applicable */ 653: adreno_coresight_start(adreno_dev); 654: 655: adreno_perfcounter_start(adreno_dev); 656: 657: /* Clear FSR here in case it is set from a previous pagefault */ 658: kgsl_mmu_clear_fsr(&device->mmu); 659: 660: gen8_enable_gpu_irq(adreno_dev); 661: 662: gen8_hwsched_init_ucode_regs(adreno_dev); 663: 664: ret = gen8_hwsched_boot_gpu(adreno_dev); 665: if (ret) { 666: adreno_llcc_slice_deactivate(adreno_dev); 667: goto err; MATCH LINES: 688, 690, 693, 706, 709, 712, 715, 716, 717, 718, 724, 725, 732, 735, 740, 746, 752, 756, 757, 759, 763, 767, 771, 775, 781, 788, 789, 792, 797, 807, 826, 830, 837, 848, 871, 874, 891, 897, 908, 909 676: * if we are prioritizing the first unrecoverable snapshot. 677: */ 678: if (device->snapshot) 679: device->snapshot->recovered = true; 680: 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); 718: ret = PTR_ERR_OR_ZERO(gmu->gmu_init_scratch); 719: if (ret) 720: return ret; 721: } 722: 723: if (IS_ERR_OR_NULL(gmu->gpu_boot_scratch)) { 724: gmu->gpu_boot_scratch = gmu_core_reserve_kernel_block(device, 0, 725: SZ_4K, GMU_CACHE, 0); 726: ret = PTR_ERR_OR_ZERO(gmu->gpu_boot_scratch); 727: } 728: 729: return ret; 730: } 731: 732: static int gen8_hwsched_gmu_memory_init(struct adreno_device *adreno_dev) 733: { 734: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 735: struct gmu_core_device *gmu_core = &device->gmu_core; 736: 737: int ret; 738: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev); 739: 740: ret = gmu_core_hwsched_memory_init(device); 741: if (ret) 742: return ret; 743: 744: /* Set the CL infinite timeout VRB override (if declared in gpulist) */ 745: if (gen8_core->cl_no_ft_timeout_ms) 746: gmu_core_set_vrb_register(gmu_core->vrb, VRB_CL_NO_FT_TIMEOUT, 747: gen8_core->cl_no_ft_timeout_ms); 748: 749: return 0; 750: } 751: 752: static int gen8_hwsched_gmu_init(struct adreno_device *adreno_dev) 753: { 754: int ret; 755: 756: if (ADRENO_FEATURE(adreno_dev, ADRENO_GMU_THERMAL_MITIGATION)) 757: set_bit(GMU_THERMAL_MITIGATION, &KGSL_DEVICE(adreno_dev)->gmu_core.flags); 758: 759: ret = gen8_gmu_parse_fw(adreno_dev); 760: if (ret) 761: return ret; 762: 763: ret = gen8_gmu_memory_init(adreno_dev); 764: if (ret) 765: return ret; 766: 767: ret = gen8_gmu_warmboot_init(adreno_dev); 768: if (ret) 769: return ret; 770: 771: ret = gen8_hwsched_gmu_memory_init(adreno_dev); 772: if (ret) 773: return ret; 774: 775: return gen8_hwsched_hfi_init(adreno_dev); 776: } 777: 778: static void gen8_hwsched_touch_wakeup(struct adreno_device *adreno_dev) 779: { 780: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 781: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 782: int ret; 783: 784: /* 785: * Do not wake up a suspended device or until the first boot sequence 786: * has been completed. 787: */ 788: if (test_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags) || 789: !test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags)) 790: return; 791: 792: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 793: goto done; 794: 795: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE); 796: 797: ret = gen8_hwsched_gmu_boot(adreno_dev); 798: if (ret) 799: return; 800: 801: ret = gen8_hwsched_gpu_boot(adreno_dev); 802: if (ret) 803: return; 804: 805: kgsl_pwrscale_wake(device); 806: 807: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 808: 809: device->pwrctrl.last_stat_updated = ktime_get(); 810: 811: kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE); 812: 813: done: 814: /* 815: * When waking up from a touch event we want to stay active long enough 816: * for the user to send a draw command. The default idle timer timeout 817: * is shorter than we want so go ahead and push the idle timer out 818: * further for this special case 819: */ 820: mod_timer(&device->idle_timer, jiffies + 821: msecs_to_jiffies(adreno_wake_timeout)); 822: } 823: 824: static int gen8_hwsched_boot(struct adreno_device *adreno_dev) 825: { 826: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 827: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 828: int ret; 829: 830: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 831: return 0; 832: 833: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE); 834: 835: adreno_hwsched_start(adreno_dev); 836: 837: ret = gen8_hwsched_gmu_boot(adreno_dev); 838: if (ret) 839: return ret; 840: 841: ret = gen8_hwsched_gpu_boot(adreno_dev); 842: if (ret) 843: return ret; 844: 845: kgsl_start_idle_timer(device); 846: kgsl_pwrscale_wake(device); 847: 848: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 849: 850: device->pwrctrl.last_stat_updated = ktime_get(); 851: 852: kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE); 853: 854: return ret; 855: } 856: 857: static int gen8_aqe_microcode_read(struct adreno_device *adreno_dev) 858: { 859: struct adreno_firmware *aqe_fw = ADRENO_FW(adreno_dev, ADRENO_FW_AQE); 860: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev); 861: 862: if (!ADRENO_FEATURE(adreno_dev, ADRENO_AQE)) 863: return 0; 864: 865: return adreno_get_firmware(adreno_dev, gen8_core->aqefw_name, aqe_fw); 866: } 867: 868: static int gen8_hwsched_first_boot(struct adreno_device *adreno_dev) 869: { 870: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 871: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 872: int ret; 873: 874: if (test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags)) 875: return gen8_hwsched_boot(adreno_dev); 876: 877: adreno_hwsched_start(adreno_dev); 878: 879: ret = gen8_microcode_read(adreno_dev); 880: if (ret) 881: return ret; 882: 883: ret = gen8_aqe_microcode_read(adreno_dev); 884: if (ret) 885: return ret; 886: 887: ret = gen8_init(adreno_dev); 888: if (ret) 889: return ret; 890: 891: ret = gen8_hwsched_gmu_init(adreno_dev); 892: if (ret) 893: return ret; 894: 895: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE); 896: 897: ret = gen8_hwsched_gmu_first_boot(adreno_dev); 898: if (ret) 899: return ret; 900: 901: ret = gen8_hwsched_gpu_boot(adreno_dev); 902: if (ret) 903: return ret; 904: 905: adreno_dev->cooperative_reset = ADRENO_FEATURE(adreno_dev, 906: ADRENO_COOP_RESET); 907: 908: set_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags); 909: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 910: 911: /* 912: * BCL needs respective Central Broadcast register to 913: * be programed from TZ. This programing happens only 914: * when zap shader firmware load is successful. Zap firmware 915: * load can fail in boot up path hence enable BCL only after we 916: * successfully complete first boot to ensure that Central 917: * Broadcast register was programed before enabling BCL. 918: */ 919: if (ADRENO_FEATURE(adreno_dev, ADRENO_BCL)) 920: adreno_dev->bcl_enabled = true; 921: 922: if (device->host_based_dcvs) { 923: /* 924: * There is a possible deadlock scenario during kgsl firmware reading 925: * (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl 926: * device mutex is held and then firmware_request_nowarn is called for reading 927: * firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock. 928: * Whereas in case of devfreq update calls triggered by thermal/bcl or 929: * devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then 930: * tries to take kgsl device mutex as part of get_dev_status/target 931: * calls. This results in deadlock when both thread are unable to acquire 932: * the mutex held by other thread. Enable devfreq updates now as we are 933: * done reading all firmware files. MATCH LINES: 971, 994, 1004, 1012, 1016, 1021, 1023, 1034, 1043, 1053, 1086, 1089, 1101, 1122, 1160, 1166, 1186, 1188, 1195, 1201, 1212, 1222, 1225, 1233, 1234, 1238, 1259, 1271, 1277, 1289, 1292, 1305, 1315, 1329, 1331, 1339, 1348, 1350, 1351, 1353, 1355, 1358, 1390, 1403 959: } 960: spin_unlock(&drawctxt->lock); 961: } 962: 963: static void drain_hw_fences_cpu(struct adreno_device *adreno_dev) 964: { 965: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 966: struct kgsl_context *context; 967: int id; 968: 969: read_lock(&device->context_lock); 970: idr_for_each_entry(&device->context_idr, context, id) { 971: if (context->gmu_registered) 972: drain_ctx_hw_fences_cpu(adreno_dev, ADRENO_CONTEXT(context)); 973: } 974: read_unlock(&device->context_lock); 975: } 976: 977: /** 978: * check_inflight_hw_fences - During SLUMBER entry, we must make sure all hardware fences across 979: * all registered contexts have been sent to TxQueue. If not, take a snapshot 980: */ 981: static int check_inflight_hw_fences(struct adreno_device *adreno_dev) 982: { 983: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 984: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 985: struct kgsl_context *context; 986: int id, ret = 0; 987: 988: if (!test_bit(ADRENO_HWSCHED_HW_FENCE, &hwsched->flags)) 989: return 0; 990: 991: read_lock(&device->context_lock); 992: idr_for_each_entry(&device->context_idr, context, id) { 993: 994: if (context->gmu_registered) { 995: ret = gen8_hwsched_check_context_inflight_hw_fences(adreno_dev, 996: ADRENO_CONTEXT(context)); 997: if (ret) 998: break; 999: } 1000: } 1001: read_unlock(&device->context_lock); 1002: 1003: if (ret) 1004: gmu_core_fault_snapshot(device, GMU_FAULT_HW_FENCE); 1005: 1006: return ret; 1007: } 1008: 1009: static int gen8_hwsched_power_off(struct adreno_device *adreno_dev) 1010: { 1011: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1012: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1013: int ret = 0; 1014: bool drain_cpu = false; 1015: 1016: if (!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 1017: return 0; 1018: 1019: kgsl_pwrctrl_request_state(device, KGSL_STATE_SLUMBER); 1020: 1021: ret = gen8_gmu_oob_set(device, oob_gpu); 1022: if (ret) { 1023: gen8_gmu_oob_clear(device, oob_gpu); 1024: goto no_gx_power; 1025: } 1026: 1027: kgsl_pwrscale_update_stats(device); 1028: 1029: /* Save active coresight registers if applicable */ 1030: adreno_coresight_stop(adreno_dev); 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: 1068: static void check_hw_fence_unack_count(struct adreno_device *adreno_dev) 1069: { 1070: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1071: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 1072: u32 unack_count; 1073: 1074: if (!test_bit(ADRENO_HWSCHED_HW_FENCE, &adreno_dev->hwsched.flags)) 1075: return; 1076: 1077: gen8_hwsched_process_msgq(adreno_dev); 1078: 1079: spin_lock(&hwf->lock); 1080: unack_count = hwf->unack_count; 1081: spin_unlock(&hwf->lock); 1082: 1083: if (!unack_count) 1084: return; 1085: 1086: dev_err(GMU_PDEV_DEV(device), 1087: "hardware fence unack_count(%d) isn't zero before SLUMBER\n", 1088: unack_count); 1089: gmu_core_fault_snapshot(device, GMU_FAULT_HW_FENCE); 1090: } 1091: 1092: static void hwsched_idle_check(struct work_struct *work) 1093: { 1094: struct kgsl_device *device = container_of(work, 1095: struct kgsl_device, idle_check_ws); 1096: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1097: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 1098: 1099: kgsl_mutex_lock(&device->mutex); 1100: 1101: if (test_bit(GMU_DISABLE_SLUMBER, &device->gmu_core.flags)) 1102: goto done; 1103: 1104: if (atomic_read(&device->active_cnt) || time_is_after_jiffies(device->idle_jiffies)) { 1105: kgsl_pwrscale_update(device); 1106: goto done; 1107: } 1108: 1109: spin_lock(&device->submit_lock); 1110: if (device->submit_now) { 1111: spin_unlock(&device->submit_lock); 1112: kgsl_pwrscale_update(device); 1113: kgsl_start_idle_timer(device); 1114: goto done; 1115: } 1116: 1117: device->skip_inline_submit = true; 1118: spin_unlock(&device->submit_lock); 1119: 1120: if (!gpudev->hw_isidle(adreno_dev)) { 1121: dev_err(device->dev, "GPU isn't idle before SLUMBER\n"); 1122: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE); 1123: } 1124: 1125: check_hw_fence_unack_count(adreno_dev); 1126: 1127: gen8_hwsched_power_off(adreno_dev); 1128: 1129: done: 1130: kgsl_mutex_unlock(&device->mutex); 1131: } 1132: 1133: static int gen8_hwsched_first_open(struct adreno_device *adreno_dev) 1134: { 1135: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1136: int ret; 1137: 1138: /* 1139: * Do the one time settings that need to happen when we 1140: * attempt to boot the gpu the very first time 1141: */ 1142: ret = gen8_hwsched_first_boot(adreno_dev); 1143: if (ret) 1144: return ret; 1145: 1146: /* 1147: * A client that does a first_open but never closes the device 1148: * may prevent us from going back to SLUMBER. So trigger the idle 1149: * check by incrementing the active count and immediately releasing it. 1150: */ 1151: atomic_inc(&device->active_cnt); 1152: adreno_active_count_put(adreno_dev); 1153: 1154: return 0; 1155: } 1156: 1157: static int gen8_hwsched_active_count_get(struct adreno_device *adreno_dev) 1158: { 1159: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1160: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1161: int ret = 0; 1162: 1163: if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex))) 1164: return -EINVAL; 1165: 1166: if (test_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags)) 1167: return -EINVAL; 1168: 1169: if ((atomic_read(&device->active_cnt) == 0)) 1170: ret = gen8_hwsched_boot(adreno_dev); 1171: 1172: if (ret == 0) 1173: atomic_inc(&device->active_cnt); 1174: 1175: trace_kgsl_active_count(device, 1176: (unsigned long) __builtin_return_address(0)); 1177: 1178: return ret; 1179: } 1180: 1181: static int gen8_hwsched_dcvs_set(struct adreno_device *adreno_dev, 1182: int gpu_pwrlevel, int bus_level, u32 ab) 1183: { 1184: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1185: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1186: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1187: struct gen8_dcvs_table *table = &gmu->dcvs_table; 1188: struct hfi_gx_bw_perf_vote_cmd req = { 1189: .ack_type = DCVS_ACK_BLOCK, 1190: .freq = INVALID_DCVS_IDX, 1191: .bw = INVALID_DCVS_IDX, 1192: }; 1193: int ret; 1194: 1195: if (!test_bit(GMU_PRIV_HFI_STARTED, &gmu->flags)) 1196: return 0; 1197: 1198: /* Do not set to XO and lower GPU clock vote from GMU */ 1199: if ((gpu_pwrlevel != INVALID_DCVS_IDX) && 1200: (gpu_pwrlevel >= table->gpu_level_num - 1)) { 1201: dev_err(GMU_PDEV_DEV(device), "Invalid gpu dcvs request: %d\n", 1202: gpu_pwrlevel); 1203: return -EINVAL; 1204: } 1205: 1206: if (gpu_pwrlevel < table->gpu_level_num - 1) 1207: req.freq = table->gpu_level_num - gpu_pwrlevel - 1; 1208: 1209: if (bus_level < pwr->ddr_table_count && bus_level > 0) 1210: req.bw = bus_level; 1211: 1212: req.bw |= adreno_gmu_bus_ab_quantize(adreno_dev, ab); 1213: 1214: /* GMU will vote for slumber levels through the sleep sequence */ 1215: if ((req.freq == INVALID_DCVS_IDX) && (req.bw == INVALID_BW_VOTE)) 1216: return 0; 1217: 1218: ret = CMD_MSG_HDR(req, H2F_MSG_GX_BW_PERF_VOTE); 1219: if (ret) 1220: return ret; 1221: 1222: ret = gen8_hfi_send_cmd_async(adreno_dev, &req, sizeof(req)); 1223: 1224: if (ret) { 1225: dev_err_ratelimited(GMU_PDEV_DEV(device), 1226: "Failed to set GPU perf idx %u, bw idx %u\n", 1227: req.freq, req.bw); 1228: 1229: /* 1230: * If this was a dcvs request along side an active gpu, request 1231: * dispatcher based reset and recovery. 1232: */ 1233: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 1234: gen8_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 1235: } 1236: 1237: if (req.freq != INVALID_DCVS_IDX) 1238: gmu_core_rdpm_mx_freq_update(device, table->gx_votes[req.freq].freq); 1239: 1240: return ret; 1241: } 1242: 1243: static int gen8_hwsched_clock_set(struct adreno_device *adreno_dev, 1244: u32 pwrlevel) 1245: { 1246: return gen8_hwsched_dcvs_set(adreno_dev, pwrlevel, INVALID_DCVS_IDX, INVALID_AB_VALUE); 1247: } 1248: 1249: static int gen8_hwsched_bus_set(struct adreno_device *adreno_dev, int buslevel, 1250: u32 ab) 1251: { 1252: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1253: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1254: int ret = 0; 1255: 1256: if (buslevel == pwr->cur_buslevel) 1257: buslevel = INVALID_DCVS_IDX; 1258: 1259: if ((ab == pwr->cur_ab) || ((ab == 0) && (adreno_dev->gmu_ab))) 1260: ab = INVALID_AB_VALUE; 1261: 1262: if ((ab == INVALID_AB_VALUE) && (buslevel == INVALID_DCVS_IDX)) 1263: return 0; 1264: 1265: ret = gen8_hwsched_dcvs_set(adreno_dev, INVALID_DCVS_IDX, 1266: buslevel, ab); 1267: if (ret) 1268: return ret; 1269: 1270: if (buslevel != INVALID_DCVS_IDX) { 1271: gmu_core_scale_gmu_frequency(device, buslevel); 1272: 1273: pwr->cur_buslevel = buslevel; 1274: } 1275: 1276: if (ab != INVALID_AB_VALUE) { 1277: if (!adreno_dev->gmu_ab) 1278: icc_set_bw(pwr->icc_path, MBps_to_icc(ab), 0); 1279: pwr->cur_ab = ab; 1280: } 1281: 1282: trace_kgsl_buslevel(device, pwr->active_pwrlevel, pwr->cur_buslevel, pwr->cur_ab, 0); 1283: return ret; 1284: } 1285: 1286: static int gen8_hwsched_pm_suspend(struct adreno_device *adreno_dev) 1287: { 1288: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1289: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1290: int ret, active_count; 1291: 1292: if (test_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags)) 1293: return 0; 1294: 1295: kgsl_pwrctrl_request_state(device, KGSL_STATE_SUSPEND); 1296: 1297: ret = adreno_hwsched_drain_and_idle(adreno_dev); 1298: if (ret) 1299: goto err; 1300: 1301: active_count = atomic_read(&device->active_cnt); 1302: 1303: if (active_count > 0) { 1304: ret = -ETIMEDOUT; 1305: dev_err_ratelimited(GMU_PDEV_DEV(device), 1306: "Aborting suspend because of active count:%d\n", 1307: active_count); 1308: goto err; 1309: } 1310: 1311: gen8_hwsched_power_off(adreno_dev); 1312: 1313: adreno_get_gpu_halt(adreno_dev); 1314: 1315: set_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags); 1316: 1317: kgsl_pwrctrl_set_state(device, KGSL_STATE_SUSPEND); 1318: 1319: return 0; 1320: 1321: err: 1322: adreno_hwsched_start(adreno_dev); 1323: 1324: return ret; 1325: } 1326: 1327: static void gen8_hwsched_pm_resume(struct adreno_device *adreno_dev) 1328: { 1329: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1330: 1331: if (WARN(!test_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags), 1332: "resume invoked without a suspend\n")) 1333: return; 1334: 1335: adreno_put_gpu_halt(adreno_dev); 1336: 1337: adreno_hwsched_start(adreno_dev); 1338: 1339: clear_bit(GMU_PRIV_PM_SUSPEND, &gmu->flags); 1340: } 1341: 1342: void gen8_hwsched_handle_watchdog(struct adreno_device *adreno_dev) 1343: { 1344: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1345: u32 mask; 1346: 1347: /* Temporarily mask the watchdog interrupt to prevent a storm */ 1348: gmu_core_regread(device, GEN8_GMUAO_AO_HOST_INTERRUPT_MASK, 1349: &mask); 1350: gmu_core_regwrite(device, GEN8_GMUAO_AO_HOST_INTERRUPT_MASK, 1351: (mask | GMU_INT_WDOG_BITE)); 1352: 1353: gen8_gmu_send_nmi(device, false, GMU_FAULT_PANIC_NONE); 1354: 1355: dev_err_ratelimited(GMU_PDEV_DEV(device), 1356: "GMU watchdog expired interrupt received\n"); 1357: 1358: gen8_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 1359: } 1360: 1361: static void gen8_hwsched_drain_ctxt_unregister(struct adreno_device *adreno_dev) 1362: { 1363: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev); 1364: struct pending_cmd *cmd = NULL; 1365: 1366: read_lock(&hfi->msglock); 1367: 1368: list_for_each_entry(cmd, &hfi->msglist, node) { 1369: if (MSG_HDR_GET_ID(cmd->sent_hdr) == H2F_MSG_UNREGISTER_CONTEXT) 1370: complete(&cmd->complete); 1371: } 1372: 1373: read_unlock(&hfi->msglock); 1374: } 1375: 1376: /** 1377: * process_context_hw_fences_after_reset - This function processes all hardware fences that were 1378: * sent to GMU prior to recovery. If a fence is not retired by the GPU, and the context is still 1379: * good, then move them to the reset list. 1380: */ 1381: static void process_context_hw_fences_after_reset(struct adreno_device *adreno_dev, 1382: struct adreno_context *drawctxt, struct list_head *reset_list) 1383: { 1384: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1385: struct adreno_hw_fence_entry *entry, *tmp; 1386: 1387: spin_lock(&drawctxt->lock); 1388: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_inflight_list, node) { 1389: struct adreno_context *drawctxt = entry->drawctxt; 1390: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr; 1391: bool retired = kgsl_check_timestamp(device, &drawctxt->base, (u32)entry->cmd.ts); 1392: 1393: /* Delete the fences that GMU has sent to the TxQueue */ 1394: if (timestamp_cmp(hdr->out_fence_ts, (u32)entry->cmd.ts) >= 0) { 1395: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 1396: continue; 1397: } 1398: 1399: /* 1400: * Force retire the fences if the ts is retired and context is not 1401: * registered with GMU, or if the context is gone bad. 1402: */ 1403: if ((retired && !drawctxt->base.gmu_registered) || 1404: kgsl_context_is_bad(&drawctxt->base)) 1405: entry->cmd.flags |= HW_FENCE_FLAG_SKIP_MEMSTORE; 1406: 1407: list_add_tail(&entry->reset_node, reset_list); 1408: } 1409: spin_unlock(&drawctxt->lock); 1410: } 1411: 1412: /** 1413: * process_inflight_hw_fences_after_reset - Send hardware fences from all contexts back to the GMU 1414: * after fault recovery. We must wait for ack when sending each of these fences to GMU so as to 1415: * avoid sending a large number of hardware fences in a short span of time. 1416: */ 1417: static int process_inflight_hw_fences_after_reset(struct adreno_device *adreno_dev) 1418: { 1419: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1420: struct kgsl_context *context = NULL; 1421: int id, ret = 0; 1422: struct list_head hw_fence_list; 1423: struct adreno_hw_fence_entry *entry, *tmp; 1424: bool update_out_fence_ts = false; 1425: 1426: /** 1427: * Since we need to wait for ack from GMU when sending each inflight fence back to GMU, we MATCH LINES: 1448, 1471, 1506 1436: process_context_hw_fences_after_reset(adreno_dev, ADRENO_CONTEXT(context), 1437: &hw_fence_list); 1438: } 1439: read_unlock(&device->context_lock); 1440: 1441: /* 1442: * Although we are not destroying the entries here, they can get destroyed concurrently 1443: * in f2h_main thread once they have been sent to GMU. Hence, to be safe against entry 1444: * destroy, use list_for_each_entry_safe. 1445: */ 1446: list_for_each_entry_safe(entry, tmp, &hw_fence_list, reset_node) { 1447: struct adreno_context *drawctxt = entry->drawctxt; 1448: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr; 1449: u32 entry_ts = (u32)entry->cmd.ts; 1450: 1451: /* 1452: * We must remove this entry from hw_fence_list before sending it to GMU to avoid 1453: * racing with the f2h_main thread 1454: */ 1455: list_del_init(&entry->reset_node); 1456: 1457: /* 1458: * We must access the hw fence entry before sending it to GMU as once it is 1459: * sent to GMU, it may be freed by f2h_main thread concurrently 1460: */ 1461: if (((entry->cmd.flags & HW_FENCE_FLAG_SKIP_MEMSTORE) != 0) && 1462: (timestamp_cmp(entry_ts, hdr->out_fence_ts) > 0)) { 1463: if (_kgsl_context_get(&drawctxt->base)) 1464: update_out_fence_ts = true; 1465: } 1466: 1467: /* 1468: * This is part of the reset sequence and any error in this path will be handled by 1469: * the caller. 1470: */ 1471: ret = gen8_send_hw_fence_hfi_wait_ack(adreno_dev, entry, 0); 1472: if (ret) 1473: break; 1474: 1475: /* 1476: * If HW_FENCE_FLAG_SKIP_MEMSTORE is set, then GMU context queue header will not be 1477: * updated for this fence. Hence, update it here. 1478: */ 1479: if (update_out_fence_ts) { 1480: hdr->out_fence_ts = entry_ts; 1481: kgsl_context_put(&drawctxt->base); 1482: update_out_fence_ts = false; 1483: } 1484: } 1485: 1486: /* Remove remaining entries from the list if we hit an error */ 1487: if (ret) { 1488: list_for_each_entry_safe(entry, tmp, &hw_fence_list, reset_node) { 1489: list_del_init(&entry->reset_node); 1490: } 1491: } 1492: 1493: return ret; 1494: } 1495: 1496: static int gen8_hwsched_drain_context_hw_fences(struct adreno_device *adreno_dev, 1497: struct adreno_context *drawctxt) 1498: { 1499: struct adreno_hw_fence_entry *entry, *tmp; 1500: int ret = 0; 1501: 1502: /* We don't need the drawctxt lock here as this context has already been invalidated */ 1503: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_list, node) { 1504: 1505: /* Any error here is fatal */ 1506: ret = gen8_send_hw_fence_hfi_wait_ack(adreno_dev, entry, 1507: HW_FENCE_FLAG_SKIP_MEMSTORE); 1508: if (ret) 1509: break; 1510: 1511: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 1512: } 1513: 1514: return ret; 1515: } 1516: 1517: static struct adreno_context *_get_guilty_context(struct kgsl_device *device) 1518: { 1519: struct kgsl_context *context = NULL; 1520: struct adreno_context *guilty = NULL; 1521: int id; 1522: 1523: read_lock(&device->context_lock); 1524: idr_for_each_entry(&device->context_idr, context, id) { 1525: if (test_and_clear_bit(KGSL_CONTEXT_PRIV_INVALID_DRAIN_HW_FENCE, &context->priv) && 1526: _kgsl_context_get(context)) { 1527: guilty = ADRENO_CONTEXT(context); 1528: break; 1529: } 1530: } MATCH LINES: 1586, 1598, 1603, 1605, 1607, 1613, 1626, 1648, 1650, 1652, 1673, 1676, 1680, 1681, 1692, 1695, 1707, 1710, 1725, 1744, 1760, 1772, 1784 1574: if (ret) 1575: return ret; 1576: 1577: ret = gen8_hwsched_process_detached_hw_fences(adreno_dev); 1578: if (ret) 1579: return ret; 1580: 1581: return gen8_hwsched_disable_hw_fence_throttle(adreno_dev); 1582: } 1583: 1584: int gen8_hwsched_reset_replay(struct adreno_device *adreno_dev) 1585: { 1586: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1587: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 1588: int ret; 1589: 1590: /* 1591: * Any pending context unregister packets will be lost 1592: * since we hard reset the GMU. This means any threads waiting 1593: * for context unregister hfi ack will timeout. Wake them 1594: * to avoid false positive ack timeout messages later. 1595: */ 1596: gen8_hwsched_drain_ctxt_unregister(adreno_dev); 1597: 1598: if (!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 1599: return 0; 1600: 1601: gen8_disable_gpu_irq(adreno_dev); 1602: 1603: gen8_gmu_irq_disable(adreno_dev); 1604: 1605: gen8_hwsched_hfi_stop(adreno_dev); 1606: 1607: gen8_hwsched_gmu_suspend(adreno_dev, true); 1608: 1609: adreno_hwsched_unregister_contexts(adreno_dev); 1610: 1611: adreno_llcc_slice_deactivate(adreno_dev); 1612: 1613: clear_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 1614: 1615: spin_lock(&hwf->lock); 1616: 1617: /* Reset the unack count back to zero as we start afresh */ 1618: hwf->unack_count = 0; 1619: 1620: spin_unlock(&hwf->lock); 1621: 1622: /* 1623: * When we reset, we want to coldboot incase any scratch corruption 1624: * has occurred before we faulted. 1625: */ 1626: gmu_core_mark_for_coldboot(KGSL_DEVICE(adreno_dev)); 1627: 1628: ret = gen8_hwsched_boot(adreno_dev); 1629: if (ret) 1630: goto done; 1631: 1632: adreno_hwsched_replay(adreno_dev); 1633: 1634: ret = handle_hw_fences_after_reset(adreno_dev); 1635: done: 1636: BUG_ON(ret); 1637: 1638: return ret; 1639: } 1640: 1641: ssize_t gen8_hwsched_preempt_info_get(struct adreno_device *adreno_dev, char *buf) 1642: { 1643: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1644: u32 preempt_count_l0, preempt_count_l1a, preempt_count_l1b; 1645: u32 count = 0, max_size = PAGE_SIZE; 1646: int ret; 1647: 1648: ret = gmu_core_get_vrb_register(device->gmu_core.vrb, 1649: VRB_PREEMPT_COUNT_L0, &preempt_count_l0); 1650: ret |= gmu_core_get_vrb_register(device->gmu_core.vrb, 1651: VRB_PREEMPT_COUNT_L1A, &preempt_count_l1a); 1652: ret |= gmu_core_get_vrb_register(device->gmu_core.vrb, 1653: VRB_PREEMPT_COUNT_L1B, &preempt_count_l1b); 1654: 1655: if (ret) 1656: return ret; 1657: 1658: count += scnprintf(buf + count, max_size - count, 1659: "%-8s %-8s\n", "Level:", "Count"); 1660: count += scnprintf(buf + count, max_size - count, 1661: "%-8s 0x%-8x\n", "L0:", preempt_count_l0); 1662: count += scnprintf(buf + count, max_size - count, 1663: "%-8s 0x%-8x\n", "L1A:", preempt_count_l1a); 1664: count += scnprintf(buf + count, max_size - count, 1665: "%-8s 0x%-8x\n", "L1B:", preempt_count_l1b); 1666: 1667: return count; 1668: } 1669: 1670: static void gen8_hwsched_set_dcvs_enable(struct adreno_device *adreno_dev, u32 enable) 1671: { 1672: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1673: struct gmu_core_device *gmu_core = &device->gmu_core; 1674: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 1675: 1676: gmu_core->gpu_pwrscale_enable = (enable >= 1) ? 1 : enable; 1677: 1678: if (device->state == KGSL_STATE_ACTIVE) { 1679: /* If GMU is up, send the HFI */ 1680: gen8_hwsched_set_gmu_based_dcvs_value(adreno_dev, HFI_VALUE_DCVS_ENABLE, 0, 1681: gmu_core->gpu_pwrscale_enable, false); 1682: } else { 1683: hwsched->dcvs_param_update = true; 1684: } 1685: } 1686: 1687: void gen8_hwsched_set_pwrconstraint(struct adreno_device *adreno_dev, 1688: u32 context_id) 1689: { 1690: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1691: struct kgsl_context *context = kgsl_context_get(device, context_id); 1692: struct hfi_context_rule_cmd cmd = {0}; 1693: int ret; 1694: 1695: if ((!context) || (!context->gmu_registered) || (device->state != KGSL_STATE_ACTIVE)) 1696: goto done; 1697: 1698: ret = CMD_MSG_HDR(cmd, H2F_MSG_CONTEXT_RULE); 1699: 1700: if (ret) 1701: goto done; 1702: 1703: cmd.ctxt_id = context->id; 1704: cmd.type = context->pwr_constraint.type; 1705: cmd.sub_type = context->pwr_constraint.sub_type; 1706: 1707: ret = gen8_hfi_send_cmd_async(adreno_dev, &cmd, sizeof(cmd)); 1708: 1709: if (ret) 1710: dev_err_ratelimited(GMU_PDEV_DEV(device), 1711: "Failed to set perf hint type %d, sub type %d for context %d, ret: %d\n", 1712: cmd.type, cmd.sub_type, cmd.ctxt_id, ret); 1713: done: 1714: kgsl_context_put(context); 1715: } 1716: 1717: static void gen8_hwsched_set_thermal_index(struct adreno_device *adreno_dev) 1718: { 1719: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1720: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1721: u32 thermal_pwrlevel = max_t(u32, pwr->thermal_pwrlevel, pwr->pmqos_max_pwrlevel); 1722: 1723: if (device->state == KGSL_STATE_ACTIVE) { 1724: /* If GMU is up, send the constraint to GMU */ 1725: gen8_hwsched_set_gmu_based_dcvs_value(adreno_dev, HFI_VALUE_MAX_GPU_THERMAL_INDEX, 1726: 0, (pwr->num_pwrlevels - thermal_pwrlevel), false); 1727: } else if (pwr->active_pwrlevel < thermal_pwrlevel) { 1728: /* 1729: * Max constraint can be updated through PM QOS and such requests can be made 1730: * when GPU is in slumber. Update the active_pwrlevel to reflect these 1731: * changes. 1732: */ 1733: pwr->active_pwrlevel = thermal_pwrlevel; 1734: } 1735: } 1736: 1737: static void gen8_hwsched_set_gpuclk(struct adreno_device *adreno_dev, u32 value) 1738: { 1739: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1740: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1741: 1742: if (device->state == KGSL_STATE_ACTIVE) { 1743: /* If GMU is up, send the HFI */ 1744: gen8_hwsched_set_gmu_based_dcvs_value(adreno_dev, HFI_VALUE_GPUCLK, 0, 1745: (pwr->num_pwrlevels - value), false); 1746: } else { 1747: /* If GPU is in slumber, update the active power level for bookkeeping */ 1748: pwr->previous_pwrlevel = pwr->active_pwrlevel; 1749: pwr->active_pwrlevel = value; 1750: } 1751: } 1752: 1753: static void gen8_hwsched_set_minpwrlevel(struct adreno_device *adreno_dev, u32 value) 1754: { 1755: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1756: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1757: 1758: if (device->state == KGSL_STATE_ACTIVE) { 1759: /* If GMU is up, send the HFI */ 1760: gen8_hwsched_set_gmu_based_dcvs_value(adreno_dev, HFI_VALUE_MIN_GPU_PERF_INDEX, 0, 1761: (pwr->num_pwrlevels - value), false); 1762: } 1763: } 1764: 1765: static void gen8_hwsched_set_maxpwrlevel(struct adreno_device *adreno_dev, u32 value) 1766: { 1767: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1768: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1769: 1770: if (device->state == KGSL_STATE_ACTIVE) { 1771: /* If GMU is up, send the HFI */ 1772: gen8_hwsched_set_gmu_based_dcvs_value(adreno_dev, HFI_VALUE_MAX_GPU_PERF_INDEX, 0, 1773: (pwr->num_pwrlevels - value), false); 1774: } 1775: } 1776: 1777: static void gen8_hwsched_set_tuning_param(struct adreno_device *adreno_dev, u32 attr) 1778: { 1779: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1780: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 1781: 1782: if (device->state == KGSL_STATE_ACTIVE) { 1783: /* If GMU is up, send the HFI */ 1784: gen8_hwsched_set_tuning_attrs(adreno_dev, HFI_VALUE_DCVS_TUNING_PARAM, 1785: attr, hwsched->sysfs_dcvs_tunables[attr].value); 1786: } else { 1787: /* Mark for updating GMU in the slumber exit path */ 1788: hwsched->sysfs_dcvs_tunables[attr].update = true; 1789: } 1790: } 1791: 1792: struct adreno_dcvs_tuning_attribute { 1793: struct kobj_attribute attr; 1794: u32 tuning_attr; 1795: }; 1796: 1797: #define DCVS_TUNABLES_SYSFS(_name, param) \ 1798: static struct adreno_dcvs_tuning_attribute dcvs_attr_##_name = \ 1799: { \ 1800: .attr = __ATTR(_name, 0644, dcvs_tuning_show, dcvs_tuning_store), \ 1801: .tuning_attr = param, \ 1802: } 1803: 1804: static ssize_t dcvs_tuning_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) 1805: { 1806: struct adreno_dcvs_tuning_attribute *pattr = container_of(attr, 1807: struct adreno_dcvs_tuning_attribute, attr); 1808: struct adreno_hwsched *hwsched = container_of(kobj, struct adreno_hwsched, tunables_kobj); MATCH LINES: 1840 1828: return ret; 1829: 1830: /* 1831: * To reset a tunable, a user can either write a -1 or UINT_MAX. Both values can be 1832: * represented as UINT_MAX in a u32 variable. Hence store the value as a u32 and 1833: * make sure the input is within allowed range. 1834: */ 1835: if ((val < -1) || (val > UINT_MAX)) 1836: return -ERANGE; 1837: 1838: kgsl_mutex_lock(&device->mutex); 1839: hwsched->sysfs_dcvs_tunables[pattr->tuning_attr].value = (u32)val; 1840: device->ftbl->gmu_based_dcvs_pwr_ops(device, pattr->tuning_attr, 1841: GPU_PWRLEVEL_OP_TUNING_ATTR); 1842: kgsl_mutex_unlock(&device->mutex); 1843: 1844: return count; 1845: } 1846: 1847: DCVS_TUNABLES_SYSFS(penalty_up, GPU_TUNING_KEY_BUSY_PENALTY_UP); 1848: DCVS_TUNABLES_SYSFS(penalty_down, GPU_TUNING_KEY_BUSY_PENALTY_DOWN); 1849: DCVS_TUNABLES_SYSFS(first_step_down, GPU_TUNING_KEY_FIRST_STEP_DOWN_COUNT); 1850: DCVS_TUNABLES_SYSFS(subsequent_step_down, GPU_TUNING_KEY_SUBSEQUENT_STEP_DOWN_COUNT); 1851: DCVS_TUNABLES_SYSFS(target_fps, GPU_TUNING_KEY_TARGET_FPS); 1852: DCVS_TUNABLES_SYSFS(num_samples_up, GPU_TUNING_KEY_NUM_SAMPLES_UP); 1853: DCVS_TUNABLES_SYSFS(num_samples_down, GPU_TUNING_KEY_NUM_SAMPLES_DOWN); 1854: DCVS_TUNABLES_SYSFS(strict_frame, GPU_TUNING_KEY_STRICT_FRAME); 1855: DCVS_TUNABLES_SYSFS(non_linear_ramp_up, GPU_TUNING_KEY_NON_LINEAR_RAMP_UP); 1856: DCVS_TUNABLES_SYSFS(non_linear_ramp_down, GPU_TUNING_KEY_NON_LINEAR_RAMP_DOWN); 1857: DCVS_TUNABLES_SYSFS(min_freq_mhz, GPU_TUNING_KEY_MIN_GPU_FREQUENCY); 1858: DCVS_TUNABLES_SYSFS(max_freq_mhz, GPU_TUNING_KEY_MAX_GPU_FREQUENCY); 1859: DCVS_TUNABLES_SYSFS(mod_percent, GPU_TUNING_KEY_MOD_PERCENT); 1860: DCVS_TUNABLES_SYSFS(bus_min_freq_mhz, GPU_TUNING_KEY_BUS_MIN_FREQUENCY); 1861: DCVS_TUNABLES_SYSFS(bus_max_freq_mhz, GPU_TUNING_KEY_BUS_MAX_FREQUENCY); 1862: 1863: static struct attribute *dcvs_tunables_attrs[] = { 1864: &dcvs_attr_penalty_up.attr.attr, MATCH LINES: 1962 1950: { 1951: struct adreno_hwsched *hwsched = container_of(kobj, struct adreno_hwsched, dcvs_kobj); 1952: struct adreno_device *adreno_dev = container_of(hwsched, struct adreno_device, hwsched); 1953: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1954: u32 cur_dcvs_tunables[GPU_TUNING_KEY_MAX]; 1955: ssize_t len = 0; 1956: const char *str = "Active"; 1957: u32 i; 1958: 1959: if (device->state == KGSL_STATE_ACTIVE) { 1960: /* If GMU is up, send the HFI */ 1961: memset(cur_dcvs_tunables, 0xFF, sizeof(cur_dcvs_tunables)); 1962: gen8_hwsched_hfi_get_dcvs_tuning_attrs(adreno_dev, HFI_DCVS_ATTRS_AGGREGATED, 1963: cur_dcvs_tunables); 1964: 1965: for (i = 0; i < GPU_TUNING_KEY_MAX; i++) { 1966: if (dcvs_tunables_strings[i]) 1967: len += scnprintf(buf + len, PAGE_SIZE - len, 1968: "%30s: %10d Status: %s\n", 1969: dcvs_tunables_strings[i], 1970: cur_dcvs_tunables[i], str); 1971: } 1972: } else { 1973: for (i = 0; i < GPU_TUNING_KEY_MAX; i++) { 1974: str = "Active"; 1975: if (dcvs_tunables_strings[i]) { 1976: /* If there is a valid sysfs tunable value, display that */ 1977: if (hwsched->sysfs_dcvs_tunables[i].value != 1978: GPU_DCVS_TUNING_INVALID_VALUE) { 1979: cur_dcvs_tunables[i] = 1980: hwsched->sysfs_dcvs_tunables[i].value; 1981: /* Update status if sysfs tunable not yet sent to GMU */ 1982: if (hwsched->sysfs_dcvs_tunables[i].update) 1983: str = "Pending"; 1984: } else { 1985: /* If no valid sysfs tunable value, display default value */ 1986: cur_dcvs_tunables[i] = hwsched->default_dcvs_tunables[i]; MATCH LINES: 2046 2034: &dcvs_attr_dcvs_tunables_cur.attr, 2035: &dcvs_attr_gpu_load.attr, 2036: NULL, 2037: }; 2038: 2039: ATTRIBUTE_GROUPS(dcvs); 2040: 2041: static const struct kobj_type ktype_dcvs = { 2042: .sysfs_ops = &kobj_sysfs_ops, 2043: .default_groups = dcvs_groups, 2044: }; 2045: 2046: static void gen8_hwsched_gmu_based_dcvs_pwr_ops(struct adreno_device *adreno_dev, u32 arg, 2047: enum gpu_pwrlevel_op op) 2048: { 2049: /* For all ops except GPU_PWRLEVEL_OP_PERF_HINT, caller must hold the device mutex */ 2050: switch (op) { 2051: case GPU_PWRLEVEL_OP_THERMAL: 2052: gen8_hwsched_set_thermal_index(adreno_dev); 2053: break; 2054: case GPU_PWRLEVEL_OP_MIN_PWRLEVEL: 2055: gen8_hwsched_set_minpwrlevel(adreno_dev, arg); 2056: break; 2057: case GPU_PWRLEVEL_OP_MAX_PWRLEVEL: 2058: gen8_hwsched_set_maxpwrlevel(adreno_dev, arg); 2059: break; 2060: case GPU_PWRLEVEL_OP_GPUCLK: 2061: gen8_hwsched_set_gpuclk(adreno_dev, arg); 2062: break; 2063: case GPU_PWRLEVEL_OP_PERF_HINT: { 2064: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2065: 2066: kgsl_mutex_lock(&device->mutex); 2067: gen8_hwsched_set_pwrconstraint(adreno_dev, arg); 2068: kgsl_mutex_unlock(&device->mutex); 2069: } 2070: break; MATCH LINES: 2089, 2107, 2139, 2153, 2155, 2158, 2168, 2181, 2183, 2184, 2185, 2190, 2193, 2194, 2199, 2201, 2202, 2203, 2208, 2210, 2211, 2212, 2219, 2220, 2224, 2225, 2226, 2227, 2239, 2248 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; 2105: struct gen8_hwsched_device *gen8_hwsched_dev; 2106: struct gen8_device *gen8_dev; 2107: struct device *gmu_dev; 2108: int ret; 2109: int i; 2110: 2111: gen8_hwsched_dev = devm_kzalloc(&pdev->dev, sizeof(*gen8_hwsched_dev), 2112: GFP_KERNEL); 2113: if (!gen8_hwsched_dev) 2114: return -ENOMEM; 2115: 2116: gen8_dev = &gen8_hwsched_dev->gen8_dev; 2117: adreno_dev = &gen8_dev->adreno_dev; 2118: 2119: adreno_dev->hwsched_enabled = true; 2120: 2121: adreno_dev->irq_mask = GEN8_HWSCHED_INT_MASK; 2122: 2123: ret = gen8_probe_common(pdev, adreno_dev, chipid, gpucore); 2124: if (ret) 2125: return ret; 2126: 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: { 2165: struct gen8_device *gen8_dev = container_of(adreno_dev, 2166: struct gen8_device, adreno_dev); 2167: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2168: struct gmu_core_device *gmu_core = &device->gmu_core; 2169: struct gen8_hwsched_device *gen8_hwsched = container_of(gen8_dev, 2170: struct gen8_hwsched_device, gen8_dev); 2171: struct gen8_hwsched_hfi *hw_hfi = &gen8_hwsched->hwsched_hfi; 2172: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 2173: struct gen8_nonctxt_overrides *nc_overrides = gen8_dev->nc_overrides; 2174: int ret, i; 2175: 2176: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, KGSL_HWSCHED_DEVICE, 2177: (void *)(gen8_hwsched), sizeof(struct gen8_hwsched_device)); 2178: if (ret) 2179: return ret; 2180: 2181: if (!IS_ERR_OR_NULL(gen8_dev->gmu.gmu_log)) { 2182: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, 2183: KGSL_GMU_LOG_ENTRY, 2184: gen8_dev->gmu.gmu_log->hostptr, 2185: gen8_dev->gmu.gmu_log->size); 2186: if (ret) 2187: return ret; 2188: } 2189: 2190: if (!IS_ERR_OR_NULL(gen8_dev->gmu.hfi.hfi_mem)) { 2191: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, 2192: KGSL_HFIMEM_ENTRY, 2193: gen8_dev->gmu.hfi.hfi_mem->hostptr, 2194: gen8_dev->gmu.hfi.hfi_mem->size); 2195: if (ret) 2196: return ret; 2197: } 2198: 2199: if (!IS_ERR_OR_NULL(gmu_core->vrb)) { 2200: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, 2201: KGSL_GMU_VRB_ENTRY, 2202: gmu_core->vrb->hostptr, 2203: gmu_core->vrb->size); 2204: if (ret) 2205: return ret; 2206: } 2207: 2208: if (!IS_ERR_OR_NULL(gmu_core->trace.md)) { 2209: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, 2210: KGSL_GMU_TRACE_ENTRY, 2211: gmu_core->trace.md->hostptr, 2212: gmu_core->trace.md->size); 2213: if (ret) 2214: return ret; 2215: } 2216: 2217: /* Dump HFI hwsched global mem alloc entries */ 2218: for (i = 0; i < hwsched->mem_alloc_entries; i++) { 2219: struct hfi_mem_alloc_entry *entry = &hwsched->mem_alloc_table[i]; 2220: char hfi_minidump_str[MAX_VA_MINIDUMP_STR_LEN] = {0}; 2221: char name[MAX_VA_MINIDUMP_STR_LEN]; 2222: u32 rb_id = 0; 2223: 2224: if (!hfi_get_minidump_string(entry->desc.mem_kind, 2225: &hfi_minidump_str[0], 2226: sizeof(hfi_minidump_str), &rb_id)) { 2227: snprintf(name, sizeof(name), "kgsl_global_%s", hfi_minidump_str); 2228: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, 2229: name, 2230: entry->md->hostptr, 2231: entry->md->size); 2232: if (ret) 2233: return ret; 2234: } 2235: } 2236: 2237: if (!IS_ERR_OR_NULL(hw_hfi->big_ib)) { 2238: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, 2239: KGSL_HFI_BIG_IB_ENTRY, 2240: hw_hfi->big_ib->hostptr, 2241: hw_hfi->big_ib->size); 2242: if (ret) 2243: return ret; 2244: } 2245: 2246: if (!IS_ERR_OR_NULL(hw_hfi->big_ib_recurring)) { 2247: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, 2248: KGSL_HFI_BIG_IB_REC_ENTRY, 2249: hw_hfi->big_ib_recurring->hostptr, 2250: hw_hfi->big_ib_recurring->size); 2251: if (ret) 2252: return ret; 2253: } 2254: 2255: if (nc_overrides) { 2256: int len = 0; 2257: 2258: while (nc_overrides[len].offset) 2259: len++; 2260: 2261: ret = kgsl_add_va_to_minidump(adreno_dev->dev.dev, 2262: KGSL_NC_OVERRIDES_ENTRY, 2263: (void *)(nc_overrides), 2264: len * sizeof(*nc_overrides)); 2265: } 2266: 2267: return ret; 2268: } --- FILE: \adreno_gen8_hwsched.h | HITS: 12 --- MATCH LINES: 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) 2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #ifndef _ADRENO_GEN8_HWSCHED_H_ 8: #define _ADRENO_GEN8_HWSCHED_H_ 9: 10: #include "adreno_gen8_hwsched_hfi.h" 11: 12: /** 13: * enum gen8_gmu_dcvs_obj - Type of DCVS object to be used for GMU based DCVS 14: * @GMU_GPU_DCVS_OBJ_OFF: DCVS disabled 15: * @GMU_GPU_DCVS_OBJ_DEPRECATED: Deprecated object 16: * @GMU_GPU_DCVS_OBJ_DOS: DCVS Old School algorithm 17: * @GMU_GPU_DCVS_OBJ_PARITY: Parity algorithm based on host based DCVS 18: * @GMU_GPU_DCVS_OBJ_MAX: enum to define max allowed object 19: */ 20: enum gen8_gmu_dcvs_obj { 21: GMU_GPU_DCVS_OBJ_OFF = 0, 22: GMU_GPU_DCVS_OBJ_DEPRECATED = 1, 23: GMU_GPU_DCVS_OBJ_DOS = 2, 24: GMU_GPU_DCVS_OBJ_PARITY = 3, 25: GMU_GPU_DCVS_OBJ_MAX, 26: }; 27: 28: /** 29: * struct gen8_hwsched_device - Container for the gen8 hwscheduling device 30: */ 31: struct gen8_hwsched_device { 32: /** @gen8_dev: Container for the gen8 device */ 33: struct gen8_device gen8_dev; 34: /** @hwsched_hfi: Container for hwscheduling specific hfi resources */ 35: struct gen8_hwsched_hfi hwsched_hfi; 36: }; 37: 38: /** 39: * gen8_hwsched_probe - Target specific probe for hwsched 40: * @pdev: Pointer to the platform device 41: * @chipid: Chipid of the target 42: * @gpucore: Pointer to the gpucore 43: * 44: * The target specific probe function for hwsched enabled gmu targets. 45: * 46: * Return: 0 on success or negative error on failure 47: */ 48: int gen8_hwsched_probe(struct platform_device *pdev, 49: u32 chipid, const struct adreno_gpu_core *gpucore); --- FILE: \adreno_gen8_hwsched_hfi.c | HITS: 656 --- MATCH LINES: 17, 22, 24, 27, 43, 58, 63, 88, 98, 105, 121, 127, 138, 145, 160, 161, 163, 164, 165, 170, 175, 182, 186, 187, 202, 203, 211, 223, 233, 241, 259, 262, 270, 271, 274, 278, 279, 281, 282, 285, 286, 291, 295, 301, 302, 304, 305, 307, 308, 313, 326, 331, 332, 334, 335, 340, 344, 350, 351, 356, 357, 359, 360, 362, 363, 368, 372, 378, 379, 384, 385, 387, 388, 390, 391, 394, 395, 399, 400, 404, 405, 407, 408, 412, 413, 415, 416, 420, 421, 423, 424, 428, 429, 431, 432, 436, 437, 442, 443, 448, 449, 451, 455, 461, 462, 464, 465, 470, 471, 476, 477, 479, 483, 489, 490, 492, 495, 498, 501, 504, 507, 511, 517, 521, 527, 530, 533, 534, 536, 539, 550, 551, 552, 553, 555, 570, 573, 574, 575, 590, 603, 612, 623, 635, 637, 651, 652, 655, 658, 663, 674, 691, 701, 709, 712, 713, 728, 734, 743 5: */ 6: 7: #include 8: 9: #include "adreno.h" 10: #include "adreno_gen8.h" 11: #include "adreno_gen8_hwsched.h" 12: #include "adreno_hfi.h" 13: #include "adreno_pm4types.h" 14: #include "adreno_trace.h" 15: #include "kgsl_device.h" 16: #include "kgsl_eventlog.h" 17: #include "kgsl_gmu_core.h" 18: #include "kgsl_pwrctrl.h" 19: #include "kgsl_timeline.h" 20: #include "kgsl_util.h" 21: 22: #define HFI_QUEUE_MAX (HFI_QUEUE_DEFAULT_CNT) 23: 24: #define DEFINE_QHDR(gmuaddr, id, prio) \ 25: {\ 26: .status = 1, \ 27: .start_addr = GMU_QUEUE_START_ADDR(gmuaddr, id), \ 28: .type = QUEUE_HDR_TYPE(id, prio, 0, 0), \ 29: .queue_size = SZ_4K >> 2, \ 30: .msg_size = 0, \ 31: .unused0 = 0, \ 32: .unused1 = 0, \ 33: .unused2 = 0, \ 34: .unused3 = 0, \ 35: .unused4 = 0, \ 36: .read_index = 0, \ 37: .write_index = 0, \ 38: } 39: 40: /* The GMU buffer address corresponds to the beginning of 41: * half the size of the shared buffer. 42: */ 43: #define GMU_BUF_ADDR(md) ((md.gmuaddr) + (md.size >> 1)) 44: 45: struct pending_cmd gen8_hw_fence_ack; 46: 47: struct gen8_hwsched_hfi *to_gen8_hwsched_hfi( 48: struct adreno_device *adreno_dev) 49: { 50: struct gen8_device *gen8_dev = container_of(adreno_dev, 51: struct gen8_device, adreno_dev); 52: struct gen8_hwsched_device *gen8_hwsched = container_of(gen8_dev, 53: struct gen8_hwsched_device, gen8_dev); 54: 55: return &gen8_hwsched->hwsched_hfi; 56: } 57: 58: int gen8_hfi_send_lpac_feature_ctrl(struct adreno_device *adreno_dev) 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; 96: 97: if (size_bytes > sizeof(cmd->results)) 98: dev_err_ratelimited(gmu_pdev_dev, 99: "Ack result too big: %d Truncating to: %ld\n", 100: size_bytes, sizeof(cmd->results)); 101: 102: read_lock(&hfi->msglock); 103: 104: list_for_each_entry(cmd, &hfi->msglist, node) { 105: if (CMP_HFI_ACK_HDR(cmd->sent_hdr, req_hdr)) { 106: memcpy(cmd->results, ack, 107: min_t(u32, size_bytes, 108: sizeof(cmd->results))); 109: complete(&cmd->complete); 110: read_unlock(&hfi->msglock); 111: return; 112: } 113: 114: if (num_waiters < ARRAY_SIZE(waiters)) 115: waiters[num_waiters++] = cmd->sent_hdr; 116: } 117: 118: read_unlock(&hfi->msglock); 119: 120: /* Didn't find the sender, list the waiter */ 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: 248: if (payload->type == type) 249: return adreno_hwsched_parse_payload(payload, key); 250: 251: i += struct_size(payload, data, payload->dwords); 252: } 253: 254: return 0; 255: } 256: 257: static void handle_sw_fault(struct adreno_device *adreno_dev, const char *str, u32 key) 258: { 259: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)); 260: u32 status = gen8_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, key); 261: 262: dev_crit_ratelimited(gmu_pdev_dev, "CP %s | SW fault | status=0x%8.8x\n", str, status); 263: /* BIT(12) - SMMU fault */ 264: if (status & BIT(12)) 265: adreno_scheduler_fault(adreno_dev, ADRENO_IOMMU_STALL_ON_PAGE_FAULT); 266: } 267: 268: static bool log_gpu_fault(struct adreno_device *adreno_dev) 269: { 270: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)); 271: struct hfi_context_bad_cmd *cmd = adreno_dev->hwsched.ctxt_bad; 272: 273: /* Return false for non fatal errors */ 274: if (adreno_hwsched_log_nonfatal_gpu_fault(adreno_dev, gmu_pdev_dev, cmd->error)) 275: return false; 276: 277: switch (cmd->error) { 278: case GMU_GPU_HW_HANG: 279: dev_crit_ratelimited(gmu_pdev_dev, "MISC: GPU hang detected\n"); 280: break; 281: case GMU_GPU_SW_HANG: 282: dev_crit_ratelimited(gmu_pdev_dev, "gpu timeout ctx %u ts %u\n", 283: cmd->gc.ctxt_id, cmd->gc.ts); 284: break; 285: case GMU_CP_OPCODE_ERROR: 286: dev_crit_ratelimited(gmu_pdev_dev, 287: "CP opcode error interrupt | opcode=0x%8.8x\n", 288: gen8_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 289: KEY_CP_OPCODE_ERROR)); 290: break; 291: case GMU_CP_PROTECTED_ERROR: { 292: u32 status = gen8_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 293: KEY_CP_PROTECTED_ERROR); 294: 295: dev_crit_ratelimited(gmu_pdev_dev, 296: "CP | Protected mode error | %s | addr=0x%5.5x | status=0x%8.8x\n", 297: status & (1 << 20) ? "READ" : "WRITE", 298: status & 0x3FFFF, status); 299: } 300: break; 301: case GMU_CP_ILLEGAL_INST_ERROR: 302: dev_crit_ratelimited(gmu_pdev_dev, "CP Illegal instruction error\n"); 303: break; 304: case GMU_CP_UCODE_ERROR: 305: dev_crit_ratelimited(gmu_pdev_dev, "CP ucode error interrupt\n"); 306: break; 307: case GMU_CP_HW_FAULT_ERROR: 308: dev_crit_ratelimited(gmu_pdev_dev, 309: "CP | Ringbuffer HW fault | status=0x%8.8x\n", 310: gen8_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 311: KEY_CP_HW_FAULT)); 312: break; 313: case GMU_GPU_PREEMPT_TIMEOUT: { 314: u32 cur, next, cur_rptr, cur_wptr, next_rptr, next_wptr; 315: 316: cur = gen8_hwsched_lookup_key_value(adreno_dev, 317: PAYLOAD_PREEMPT_TIMEOUT, KEY_PREEMPT_TIMEOUT_CUR_RB_ID); 318: next = gen8_hwsched_lookup_key_value(adreno_dev, 319: PAYLOAD_PREEMPT_TIMEOUT, 320: KEY_PREEMPT_TIMEOUT_NEXT_RB_ID); 321: cur_rptr = adreno_hwsched_get_payload_rb_key(adreno_dev, cur, KEY_RB_RPTR); 322: cur_wptr = adreno_hwsched_get_payload_rb_key(adreno_dev, cur, KEY_RB_WPTR); 323: next_rptr = adreno_hwsched_get_payload_rb_key(adreno_dev, next, KEY_RB_RPTR); 324: next_wptr = adreno_hwsched_get_payload_rb_key(adreno_dev, next, KEY_RB_WPTR); 325: 326: dev_crit_ratelimited(gmu_pdev_dev, 327: "Preemption Fault: cur=%d R/W=0x%x/0x%x, next=%d R/W=0x%x/0x%x\n", 328: cur, cur_rptr, cur_wptr, next, next_rptr, next_wptr); 329: } 330: break; 331: case GMU_CP_GPC_ERROR: 332: dev_crit_ratelimited(gmu_pdev_dev, "RBBM: GPC error\n"); 333: break; 334: case GMU_CP_BV_OPCODE_ERROR: 335: dev_crit_ratelimited(gmu_pdev_dev, 336: "CP BV opcode error | opcode=0x%8.8x\n", 337: gen8_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 338: KEY_CP_BV_OPCODE_ERROR)); 339: break; 340: case GMU_CP_BV_PROTECTED_ERROR: { 341: u32 status = gen8_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 342: KEY_CP_BV_PROTECTED_ERROR); 343: 344: dev_crit_ratelimited(gmu_pdev_dev, 345: "CP BV | Protected mode error | %s | addr=0x%5.5x | status=0x%8.8x\n", 346: status & (1 << 20) ? "READ" : "WRITE", 347: status & 0x3FFFF, status); 348: } 349: break; 350: case GMU_CP_BV_HW_FAULT_ERROR: 351: dev_crit_ratelimited(gmu_pdev_dev, 352: "CP BV | Ringbuffer HW fault | status=0x%8.8x\n", 353: gen8_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 354: KEY_CP_BV_HW_FAULT)); 355: break; 356: case GMU_CP_BV_ILLEGAL_INST_ERROR: 357: dev_crit_ratelimited(gmu_pdev_dev, "CP BV Illegal instruction error\n"); 358: break; 359: case GMU_CP_BV_UCODE_ERROR: 360: dev_crit_ratelimited(gmu_pdev_dev, "CP BV ucode error interrupt\n"); 361: break; 362: case GMU_CP_LPAC_OPCODE_ERROR: 363: dev_crit_ratelimited(gmu_pdev_dev, 364: "CP LPAC opcode error | opcode=0x%8.8x\n", 365: gen8_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 366: KEY_CP_LPAC_OPCODE_ERROR)); 367: break; 368: case GMU_CP_LPAC_PROTECTED_ERROR: { 369: u32 status = gen8_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 370: KEY_CP_LPAC_PROTECTED_ERROR); 371: 372: dev_crit_ratelimited(gmu_pdev_dev, 373: "CP LPAC | Protected mode error | %s | addr=0x%5.5x | status=0x%8.8x\n", 374: status & (1 << 20) ? "READ" : "WRITE", 375: status & 0x3FFFF, status); 376: } 377: break; 378: case GMU_CP_LPAC_HW_FAULT_ERROR: 379: dev_crit_ratelimited(gmu_pdev_dev, 380: "CP LPAC | Ringbuffer HW fault | status=0x%8.8x\n", 381: gen8_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 382: KEY_CP_LPAC_HW_FAULT)); 383: break; 384: case GMU_CP_LPAC_ILLEGAL_INST_ERROR: 385: dev_crit_ratelimited(gmu_pdev_dev, "CP LPAC Illegal instruction error\n"); 386: break; 387: case GMU_CP_LPAC_UCODE_ERROR: 388: dev_crit_ratelimited(gmu_pdev_dev, "CP LPAC ucode error interrupt\n"); 389: break; 390: case GMU_GPU_LPAC_SW_HANG: 391: dev_crit_ratelimited(gmu_pdev_dev, "LPAC: gpu timeout ctx %u ts %u\n", 392: cmd->lpac.ctxt_id, cmd->lpac.ts); 393: break; 394: case GMU_GPU_SW_FUSE_VIOLATION: 395: dev_crit_ratelimited(gmu_pdev_dev, "RBBM: SW Feature Fuse violation status=0x%8.8x\n", 396: gen8_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 397: KEY_SWFUSE_VIOLATION_FAULT)); 398: break; 399: case GMU_GPU_AQE0_OPCODE_ERROR: 400: dev_crit_ratelimited(gmu_pdev_dev, "AQE0 opcode error | opcode=0x%8.8x\n", 401: gen8_hwsched_lookup_key_value(adreno_dev, 402: PAYLOAD_FAULT_REGS, KEY_AQE0_OPCODE_ERROR)); 403: break; 404: case GMU_GPU_AQE0_UCODE_ERROR: 405: dev_crit_ratelimited(gmu_pdev_dev, "AQE0 ucode error interrupt\n"); 406: break; 407: case GMU_GPU_AQE0_HW_FAULT_ERROR: 408: dev_crit_ratelimited(gmu_pdev_dev, "AQE0 HW fault | status=0x%8.8x\n", 409: gen8_hwsched_lookup_key_value(adreno_dev, 410: PAYLOAD_FAULT_REGS, KEY_AQE0_HW_FAULT)); 411: break; 412: case GMU_GPU_AQE0_ILLEGAL_INST_ERROR: 413: dev_crit_ratelimited(gmu_pdev_dev, "AQE0 Illegal instruction error\n"); 414: break; 415: case GMU_GPU_AQE1_OPCODE_ERROR: 416: dev_crit_ratelimited(gmu_pdev_dev, "AQE1 opcode error | opcode=0x%8.8x\n", 417: gen8_hwsched_lookup_key_value(adreno_dev, 418: PAYLOAD_FAULT_REGS, KEY_AQE1_OPCODE_ERROR)); 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); 459: } 460: break; 461: case GMU_CP_DDEBR_ILLEGAL_INST_ERROR: 462: dev_crit_ratelimited(gmu_pdev_dev, "CP DDEBR Illegal instruction error\n"); 463: break; 464: case GMU_CP_DDEBV_HW_FAULT_ERROR: 465: dev_crit_ratelimited(gmu_pdev_dev, 466: "CP DDE BV | Ringbuffer HW fault | status=0x%8.8x\n", 467: gen8_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 468: KEY_CP_DDEBV_HW_FAULT)); 469: break; 470: case GMU_CP_DDEBV_OPCODE_ERROR: 471: dev_crit_ratelimited(gmu_pdev_dev, 472: "CP DDE BV opcode error | opcode=0x%8.8x\n", 473: gen8_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 474: KEY_CP_DDEBV_OPCODE_ERROR)); 475: break; 476: case GMU_CP_DDEBV_UCODE_ERROR: 477: dev_crit_ratelimited(gmu_pdev_dev, "CP DDE BV ucode error\n"); 478: break; 479: case GMU_CP_DDEBV_PROTECTED_ERROR: { 480: u32 status = gen8_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 481: KEY_CP_DDEBV_PROTECTED_ERROR); 482: 483: dev_crit_ratelimited(gmu_pdev_dev, 484: "CP DDE BV | Protected mode error | %s | addr=0x%5.5x | status=0x%8.8x\n", 485: status & (1 << 20) ? "READ" : "WRITE", 486: status & 0x3FFFF, status); 487: } 488: break; 489: case GMU_CP_DDEBV_ILLEGAL_INST_ERROR: 490: dev_crit_ratelimited(gmu_pdev_dev, "CP DDE BV Illegal instruction error\n"); 491: break; 492: case GMU_CP_BR_SW_FAULT_ERROR: 493: handle_sw_fault(adreno_dev, "BR", KEY_CP_BR_SW_FAULT); 494: break; 495: case GMU_CP_BV_SW_FAULT_ERROR: 496: handle_sw_fault(adreno_dev, "BV", KEY_CP_BV_SW_FAULT); 497: break; 498: case GMU_CP_LPAC_SW_FAULT_ERROR: 499: handle_sw_fault(adreno_dev, "LPAC", KEY_CP_LPAC_SW_FAULT); 500: break; 501: case GMU_CP_AQE0_SW_FAULT_ERROR: 502: handle_sw_fault(adreno_dev, "AQE0", KEY_CP_AQE0_SW_FAULT); 503: break; 504: case GMU_CP_AQE1_SW_FAULT_ERROR: 505: handle_sw_fault(adreno_dev, "AQE1", KEY_CP_AQE1_SW_FAULT); 506: break; 507: case GMU_CP_AQE0_PROTECTED_ERROR: { 508: u32 status = gen8_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 509: KEY_CP_AQE0_PROTECTED_ERROR); 510: 511: dev_crit_ratelimited(gmu_pdev_dev, 512: "CP AQE0 | Protected mode error | %s | addr=0x%5.5x | status=0x%8.8x\n", 513: status & (1 << 20) ? "READ" : "WRITE", 514: status & 0x3FFFF, status); 515: } 516: break; 517: case GMU_CP_AQE1_PROTECTED_ERROR: { 518: u32 status = gen8_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 519: KEY_CP_AQE1_PROTECTED_ERROR); 520: 521: dev_crit_ratelimited(gmu_pdev_dev, 522: "CP AQE1 | Protected mode error | %s | addr=0x%5.5x | status=0x%8.8x\n", 523: status & (1 << 20) ? "READ" : "WRITE", 524: status & 0x3FFFF, status); 525: } 526: break; 527: case GMU_CP_DDEBR_SW_FAULT_ERROR: 528: handle_sw_fault(adreno_dev, "DDE BR", KEY_CP_DDEBR_SW_FAULT); 529: break; 530: case GMU_CP_DDEBV_SW_FAULT_ERROR: 531: handle_sw_fault(adreno_dev, "DDE BV", KEY_CP_DDEBV_SW_FAULT); 532: break; 533: case GMU_DBGC_INTR_ERROR: 534: dev_crit_ratelimited(gmu_pdev_dev, "DBGC error interrupt\n"); 535: break; 536: case GMU_CP_UNKNOWN_ERROR: 537: fallthrough; 538: default: 539: dev_crit_ratelimited(gmu_pdev_dev, "Unknown GPU fault: %u\n", 540: cmd->error); 541: break; 542: } 543: 544: /* Return true for fatal errors to perform recovery sequence */ 545: return true; 546: } 547: 548: static bool is_queue_empty(struct adreno_device *adreno_dev, u32 queue_idx) 549: { 550: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 551: struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem; 552: struct hfi_queue_table *tbl = mem_addr->hostptr; 553: struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx]; 554: 555: if (hdr->status == HFI_QUEUE_STATUS_DISABLED) 556: return true; 557: 558: if (hdr->read_index == hdr->write_index) 559: return true; 560: 561: /* 562: * This is to ensure that the queue is not read speculatively before the queue empty 563: * condition is evaluated 564: */ 565: rmb(); 566: 567: return false; 568: } 569: 570: static u32 peek_next_header(struct adreno_device *adreno_dev, struct gen8_gmu_device *gmu, 571: u32 queue_idx) 572: { 573: struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem; 574: struct hfi_queue_table *tbl = mem_addr->hostptr; 575: struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx]; 576: u32 *queue; 577: 578: if (is_queue_empty(adreno_dev, queue_idx)) 579: return 0; 580: 581: queue = HOST_QUEUE_START_ADDR(mem_addr, queue_idx); 582: 583: return queue[hdr->read_index]; 584: } 585: 586: static void process_ctx_bad(struct adreno_device *adreno_dev) 587: { 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: */ MATCH LINES: 822 810: * Return: 0 on success or negative error on failure 811: */ 812: static int _send_hw_fence_no_ack(struct adreno_device *adreno_dev, 813: struct adreno_hw_fence_entry *entry) 814: { 815: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 816: u32 seqnum; 817: int ret; 818: 819: seqnum = atomic_inc_return(&hwf->seqnum); 820: entry->cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(entry->cmd.hdr, seqnum, sizeof(entry->cmd) >> 2); 821: 822: ret = gen8_hfi_cmdq_write(adreno_dev, (u32 *)&entry->cmd, sizeof(entry->cmd)); 823: if (!ret) 824: _increment_hw_fence_unack_count(adreno_dev); 825: 826: return ret; 827: } 828: 829: static struct adreno_hw_fence_entry *_get_deferred_hw_fence(struct adreno_context *drawctxt, u32 ts) 830: { 831: struct adreno_hw_fence_entry *entry = NULL, *next, *deferred_hw_fence_entry = NULL; 832: 833: spin_lock(&drawctxt->lock); 834: list_for_each_entry_safe(entry, next, &drawctxt->hw_fence_list, node) { 835: 836: if (timestamp_cmp((u32)entry->cmd.ts, ts) > 0) 837: break; 838: 839: /* We found a deferred hardware fence */ 840: deferred_hw_fence_entry = entry; 841: break; 842: } 843: spin_unlock(&drawctxt->lock); 844: 845: /* 846: * This path executes in isolation from any paths that may release this entry. So, it is MATCH LINES: 863 851: 852: static int _send_deferred_hw_fence(struct adreno_device *adreno_dev, 853: struct adreno_context *drawctxt, struct adreno_hw_fence_entry *entry, u32 ts) 854: { 855: bool retired = kgsl_check_timestamp(KGSL_DEVICE(adreno_dev), &drawctxt->base, ts) || 856: kgsl_context_is_bad(&drawctxt->base); 857: int ret = 0; 858: u32 flags = 0; 859: 860: if (retired) 861: flags |= HW_FENCE_FLAG_SKIP_MEMSTORE; 862: 863: ret = gen8_send_hw_fence_hfi_wait_ack(adreno_dev, entry, flags); 864: if (ret) 865: return ret; 866: 867: spin_lock(&drawctxt->lock); 868: if (!retired) 869: list_move_tail(&entry->node, &drawctxt->hw_fence_inflight_list); 870: else 871: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 872: spin_unlock(&drawctxt->lock); 873: 874: return 0; 875: } 876: 877: /** 878: * process_hw_fence_deferred_ctxt - This function sends hardware fences to GMU (from the 879: * deferred drawctxt) which couldn't be sent earlier 880: */ 881: static int process_hw_fence_deferred_ctxt(struct adreno_device *adreno_dev, 882: struct adreno_context *drawctxt, u32 ts) 883: { 884: struct adreno_hw_fence_entry *deferred_hw_fence_entry = NULL; 885: int ret = 0; 886: 887: do { MATCH LINES: 960, 983, 1001, 1011, 1017, 1049, 1053, 1054, 1056, 1057, 1065, 1069, 1075, 1080, 1081, 1086, 1091, 1103, 1105, 1116, 1117, 1118, 1123, 1136, 1137, 1138, 1146, 1154, 1158, 1180, 1184, 1187, 1198, 1199, 1206, 1207, 1209, 1213, 1219, 1222, 1223, 1225, 1228, 1229, 1232, 1239, 1251, 1256, 1257, 1261, 1264, 1276, 1281, 1295, 1296, 1299, 1301, 1302, 1303, 1304, 1307, 1308, 1309, 1313, 1317, 1318, 1320, 1322, 1329, 1330, 1331, 1338, 1339, 1340, 1345, 1346, 1347, 1348, 1349, 1354, 1364, 1365, 1366, 1370, 1385, 1388, 1390, 1391, 1392, 1402, 1412, 1418, 1420, 1422, 1431, 1436, 1438, 1440, 1453, 1458, 1461, 1464, 1468, 1470, 1473, 1481, 1482, 1486, 1492, 1499, 1503, 1514, 1523, 1525, 1526, 1530, 1531, 1533, 1540, 1542, 1545, 1559, 1566, 1568, 1591, 1603, 1604, 1610, 1620, 1626, 1628, 1641, 1644, 1653, 1654, 1659, 1661, 1662, 1663, 1680, 1685, 1696, 1698, 1703, 1718, 1722, 1735, 1738, 1744, 1746, 1755, 1762, 1765, 1769, 1772, 1780, 1813, 1815, 1817, 1818, 1819, 1825, 1829, 1830, 1833, 1836, 1845, 1847, 1850, 1854, 1855, 1856, 1858, 1859, 1861, 1866, 1877, 1882, 1898, 1899, 1903, 1915, 1918, 1932, 1938, 1944, 1952, 1953, 1958, 1959, 1971, 1972, 1976, 1977 948: 949: spin_lock(&hwf->lock); 950: drawctxt = hwf->defer_drawctxt; 951: ts = hwf->defer_ts; 952: spin_unlock(&hwf->lock); 953: 954: if (!drawctxt) 955: goto unlock; 956: 957: ret = process_hw_fence_deferred_ctxt(adreno_dev, drawctxt, ts); 958: if (ret) { 959: /* the deferred drawctxt will be handled post fault recovery */ 960: gen8_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 961: goto unlock; 962: } 963: 964: /* 965: * Put back the context reference which was incremented when hw_fence.defer_drawctxt was set 966: */ 967: kgsl_context_put(&drawctxt->base); 968: 969: adreno_active_count_put(adreno_dev); 970: 971: _disable_hw_fence_throttle(adreno_dev, false); 972: 973: unlock: 974: kgsl_mutex_unlock(&device->mutex); 975: mutex_unlock(&adreno_dev->hwsched.mutex); 976: } 977: 978: static int _check_hw_fence_ack_failure(struct kgsl_device *device, u32 *result) 979: { 980: if (!result[2]) 981: return 0; 982: 983: dev_err(GMU_PDEV_DEV(device), 984: "HFI ACK failure: Req=0x%8.8X, Result=0x%8.8X\n", 985: result[1], result[2]); 986: 987: return -EINVAL; 988: } 989: 990: static void process_hw_fence_ack(struct adreno_device *adreno_dev, u32 *rcvd) 991: { 992: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 993: struct adreno_context *drawctxt = NULL; 994: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev); 995: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 996: 997: spin_lock(&hwf->lock); 998: 999: /* If this ack is being waited on, we don't need to touch the unack count */ 1000: if (gen8_hw_fence_ack.sent_hdr && 1001: CMP_HFI_ACK_HDR(gen8_hw_fence_ack.sent_hdr, rcvd[1])) { 1002: spin_unlock(&hwf->lock); 1003: complete(&gen8_hw_fence_ack.complete); 1004: return; 1005: } 1006: 1007: hwf->unack_count--; 1008: 1009: /* The unack count should never be greater than MAX_HW_FENCE_UNACK_COUNT */ 1010: if (hwf->unack_count > MAX_HW_FENCE_UNACK_COUNT) 1011: dev_err(GMU_PDEV_DEV(device), 1012: "unexpected hardware fence unack count:%d\n", 1013: hwf->unack_count); 1014: 1015: if (_check_hw_fence_ack_failure(device, rcvd)) { 1016: spin_unlock(&hwf->lock); 1017: gen8_hwsched_fault(adreno_dev, GMU_FAULT_HW_FENCE); 1018: return; 1019: } 1020: 1021: if (!test_bit(GEN8_HWSCHED_HW_FENCE_MAX_BIT, &hwf->flags) || 1022: (hwf->unack_count != MIN_HW_FENCE_UNACK_COUNT)) { 1023: spin_unlock(&hwf->lock); 1024: return; 1025: } 1026: 1027: drawctxt = hwf->defer_drawctxt; 1028: 1029: spin_unlock(&hwf->lock); 1030: 1031: kgsl_delete_timer_sync(&hfi->hw_fence_timer); 1032: 1033: /* 1034: * We need to handle the deferred context in another thread so that we can unblock the f2h 1035: * daemon here as it will need to process the acks for the hardware fences belonging to the 1036: * deferred context 1037: */ 1038: if (drawctxt) { 1039: kthread_init_work(&hfi->defer_hw_fence_work, gen8_defer_hw_fence_work); 1040: kthread_queue_work(adreno_dev->scheduler_worker, &hfi->defer_hw_fence_work); 1041: return; 1042: } 1043: 1044: _disable_hw_fence_throttle(adreno_dev, false); 1045: } 1046: 1047: int gen8_hwsched_process_f2h_platform_msg(struct adreno_device *adreno_dev, u32 *rcvd) 1048: { 1049: struct hfi_msg_platform *msg = (struct hfi_msg_platform *)rcvd; 1050: 1051: if (msg->sub_type == F2H_ST_MSG_SCALE_GMU) { 1052: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1053: struct hfi_scale_gmu_cmd *cmd = (struct hfi_scale_gmu_cmd *)rcvd; 1054: u32 index = cmd->gmu_pwrlevel; 1055: 1056: if ((index > 0) && (index <= device->gmu_core.num_freqs)) 1057: return gmu_core_clock_set_rate(device, index - 1); 1058: } 1059: 1060: return 0; 1061: } 1062: 1063: void gen8_hwsched_process_msgq(struct adreno_device *adreno_dev) 1064: { 1065: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1066: struct gen8_hwsched_hfi *hw_hfi = to_gen8_hwsched_hfi(adreno_dev); 1067: u32 rcvd[MAX_RCVD_SIZE], next_hdr, type; 1068: 1069: if (!(hw_hfi->irq_mask & HFI_IRQ_MSGQ_MASK)) 1070: return; 1071: 1072: mutex_lock(&hw_hfi->msgq_mutex); 1073: 1074: for (;;) { 1075: next_hdr = peek_next_header(adreno_dev, gmu, HFI_MSG_ID); 1076: 1077: if (!next_hdr) 1078: break; 1079: 1080: if (MSG_HDR_GET_TYPE(next_hdr) == HFI_MSG_ACK) 1081: type = HFI_MSG_ACK; 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; 1139: u32 start, end; 1140: 1141: start = cmd->start_index; 1142: end = cmd->stop_index; 1143: 1144: log_event += start * 4; 1145: while (start != end) { 1146: trace_gmu_event(log_event); 1147: log_event += 4; 1148: start++; 1149: } 1150: } 1151: 1152: static void gen8_hwsched_process_dbgq(struct adreno_device *adreno_dev, bool limited) 1153: { 1154: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1155: u32 rcvd[MAX_RCVD_SIZE]; 1156: bool recovery = false; 1157: 1158: while (gen8_hfi_queue_read(gmu, HFI_DBG_ID, rcvd, sizeof(rcvd)) > 0) { 1159: 1160: if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_ERR) { 1161: adreno_gen8_receive_err_req(gmu, rcvd); 1162: recovery = true; 1163: break; 1164: } 1165: 1166: if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_DEBUG) 1167: adreno_gen8_receive_debug_req(gmu, rcvd); 1168: 1169: if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_LOG_BLOCK) 1170: process_log_block(adreno_dev, rcvd); 1171: 1172: /* Process one debug queue message and return to not delay msgq processing */ 1173: if (limited) 1174: break; 1175: } 1176: 1177: if (!recovery) 1178: return; 1179: 1180: gen8_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 1181: } 1182: 1183: /* HFI interrupt handler */ 1184: static irqreturn_t gen8_hwsched_hfi_handler(int irq, void *data) 1185: { 1186: struct adreno_device *adreno_dev = data; 1187: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1188: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev); 1189: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1190: u32 status = 0; 1191: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 1192: u64 ticks = gpudev->read_alwayson(adreno_dev); 1193: 1194: /* 1195: * GEN8_GMUCX_GMU2HOST_INTR_INFO may have bits set not specified in hfi->irq_mask. 1196: * Read and clear only those irq bits that we are processing here. 1197: */ 1198: gmu_core_regread(device, GEN8_GMUCX_GMU2HOST_INTR_INFO, &status); 1199: gmu_core_regwrite(device, GEN8_GMUCX_GMU2HOST_INTR_CLR, status & hfi->irq_mask); 1200: 1201: /* 1202: * If interrupts are not enabled on the HFI message queue, 1203: * the inline message processing loop will process it, 1204: * else, process it here. 1205: */ 1206: if (!(hfi->irq_mask & HFI_IRQ_MSGQ_MASK)) 1207: status &= ~HFI_IRQ_MSGQ_MASK; 1208: 1209: if (status & (HFI_IRQ_MSGQ_MASK | HFI_IRQ_DBGQ_MASK)) { 1210: wake_up_interruptible(&hfi->f2h_wq); 1211: adreno_scheduler_queue(adreno_dev); 1212: } 1213: if (status & HFI_IRQ_CM3_FAULT_MASK) { 1214: atomic_set(&gmu->cm3_fault, 1); 1215: 1216: /* make sure other CPUs see the update */ 1217: smp_wmb(); 1218: 1219: dev_err_ratelimited(GMU_PDEV_DEV(device), 1220: "GMU CM3 fault interrupt received\n"); 1221: 1222: KGSL_GMU_CORE_FORCE_PANIC(device->gmu_core.gf_panic, 1223: GMU_PDEV(device), ticks, GMU_FAULT_CM3); 1224: 1225: gen8_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 1226: } 1227: 1228: /* Ignore OOB bits */ 1229: status &= GENMASK(31 - (oob_max - 1), 0); 1230: 1231: if (status & ~hfi->irq_mask) 1232: dev_err_ratelimited(GMU_PDEV_DEV(device), 1233: "Unhandled HFI interrupts 0x%x\n", 1234: status & ~hfi->irq_mask); 1235: 1236: return IRQ_HANDLED; 1237: } 1238: 1239: #define HFI_IRQ_MSGQ_MASK BIT(0) 1240: 1241: static int check_ack_failure(struct adreno_device *adreno_dev, 1242: struct pending_cmd *ack) 1243: { 1244: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 1245: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1246: u64 ticks = gpudev->read_alwayson(adreno_dev); 1247: 1248: if (ack->results[2] != 0xffffffff) 1249: return 0; 1250: 1251: dev_err(GMU_PDEV_DEV(device), 1252: "ACK error: sender id %d seqnum %d\n", 1253: MSG_HDR_GET_ID(ack->sent_hdr), 1254: MSG_HDR_GET_SEQNUM(ack->sent_hdr)); 1255: 1256: KGSL_GMU_CORE_FORCE_PANIC(device->gmu_core.gf_panic, 1257: GMU_PDEV(device), ticks, GMU_FAULT_HFI_ACK); 1258: return -EINVAL; 1259: } 1260: 1261: int gen8_hfi_send_cmd_async(struct adreno_device *adreno_dev, void *data, u32 size_bytes) 1262: { 1263: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1264: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1265: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev); 1266: u32 *cmd = data; 1267: u32 seqnum; 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, 1305: }, 1306: .qhdr = { 1307: DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0), 1308: DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0), 1309: DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0), 1310: }, 1311: }; 1312: 1313: memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table)); 1314: } 1315: 1316: /* Total header sizes + queue sizes + 16 for alignment */ 1317: #define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \ 1318: (SZ_4K * HFI_QUEUE_MAX)) 1319: 1320: static int hfi_f2h_main(void *arg); 1321: 1322: int gen8_hwsched_hfi_init(struct adreno_device *adreno_dev) 1323: { 1324: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1325: struct gen8_hwsched_hfi *hw_hfi = to_gen8_hwsched_hfi(adreno_dev); 1326: struct gen8_hfi *hfi = to_gen8_hfi(adreno_dev); 1327: 1328: if (IS_ERR_OR_NULL(hw_hfi->big_ib)) { 1329: hw_hfi->big_ib = gmu_core_reserve_kernel_block( 1330: device, 0, HWSCHED_MAX_IBS * sizeof(struct hfi_issue_ib), 1331: GMU_NONCACHED_KERNEL, 0); 1332: if (IS_ERR(hw_hfi->big_ib)) 1333: return PTR_ERR(hw_hfi->big_ib); 1334: } 1335: 1336: if (ADRENO_FEATURE(adreno_dev, ADRENO_LSR) && 1337: IS_ERR_OR_NULL(hw_hfi->big_ib_recurring)) { 1338: hw_hfi->big_ib_recurring = gmu_core_reserve_kernel_block( 1339: device, 0, HWSCHED_MAX_IBS * sizeof(struct hfi_issue_ib), 1340: GMU_NONCACHED_KERNEL, 0); 1341: if (IS_ERR(hw_hfi->big_ib_recurring)) 1342: return PTR_ERR(hw_hfi->big_ib_recurring); 1343: } 1344: 1345: if (IS_ERR_OR_NULL(hfi->hfi_mem)) { 1346: hfi->hfi_mem = gmu_core_reserve_kernel_block( 1347: device, 0, HFIMEM_SIZE, GMU_NONCACHED_KERNEL, 0); 1348: if (IS_ERR(hfi->hfi_mem)) 1349: return PTR_ERR(hfi->hfi_mem); 1350: init_queues(hfi); 1351: } 1352: 1353: if (IS_ERR_OR_NULL(hw_hfi->f2h_task)) { 1354: hw_hfi->f2h_task = kthread_run(hfi_f2h_main, adreno_dev, "gmu_f2h"); 1355: if (!IS_ERR(hw_hfi->f2h_task)) 1356: sched_set_fifo(hw_hfi->f2h_task); 1357: } 1358: 1359: return PTR_ERR_OR_ZERO(hw_hfi->f2h_task); 1360: } 1361: 1362: static int mem_alloc_reply(struct adreno_device *adreno_dev, void *rcvd) 1363: { 1364: struct hfi_mem_alloc_desc desc = {0}; 1365: struct hfi_mem_alloc_reply_cmd out = {0}; 1366: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1367: u32 seqnum; 1368: int ret; 1369: 1370: hfi_get_mem_alloc_desc(rcvd, &desc); 1371: 1372: ret = adreno_hwsched_process_mem_alloc(adreno_dev, &desc); 1373: if (ret) 1374: return ret; 1375: 1376: memcpy(&out.desc, &desc, sizeof(out.desc)); 1377: 1378: out.hdr = ACK_MSG_HDR(F2H_MSG_MEM_ALLOC); 1379: 1380: seqnum = atomic_inc_return(&gmu->hfi.seqnum); 1381: out.hdr = MSG_HDR_SET_SEQNUM_SIZE(out.hdr, seqnum, sizeof(out) >> 2); 1382: 1383: out.req_hdr = *(u32 *)rcvd; 1384: 1385: return gen8_hfi_cmdq_write(adreno_dev, (u32 *)&out, sizeof(out)); 1386: } 1387: 1388: static int gmu_cntr_register_reply(struct adreno_device *adreno_dev, void *rcvd) 1389: { 1390: struct hfi_gmu_cntr_register_cmd *in = (struct hfi_gmu_cntr_register_cmd *)rcvd; 1391: struct hfi_gmu_cntr_register_reply_cmd out = {0}; 1392: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1393: u32 lo = 0, hi = 0, seqnum; 1394: 1395: /* 1396: * Failure to allocate counter is not fatal. Sending lo = 0, hi = 0 1397: * indicates to GMU that counter allocation failed. 1398: */ 1399: adreno_perfcounter_get(adreno_dev, 1400: in->group_id, in->countable, &lo, &hi, PERFCOUNTER_FLAG_KERNEL); 1401: 1402: out.hdr = ACK_MSG_HDR(F2H_MSG_GMU_CNTR_REGISTER); 1403: seqnum = atomic_inc_return(&gmu->hfi.seqnum); 1404: out.hdr = MSG_HDR_SET_SEQNUM_SIZE(out.hdr, seqnum, sizeof(out) >> 2); 1405: out.req_hdr = in->hdr; 1406: out.group_id = in->group_id; 1407: out.countable = in->countable; 1408: /* Fill in byte offset of counter */ 1409: out.cntr_lo = lo << 2; 1410: out.cntr_hi = hi << 2; 1411: 1412: return gen8_hfi_cmdq_write(adreno_dev, (u32 *)&out, sizeof(out)); 1413: } 1414: 1415: static int send_warmboot_start_msg(struct adreno_device *adreno_dev) 1416: { 1417: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1418: struct gmu_core_device *gmu_core = &device->gmu_core; 1419: int ret = 0; 1420: struct hfi_start_cmd cmd; 1421: 1422: if (!gmu_core->warmboot_enabled) 1423: return ret; 1424: 1425: ret = CMD_MSG_HDR(cmd, H2F_MSG_START); 1426: if (ret) 1427: return ret; 1428: 1429: cmd.hdr = RECORD_NOP_MSG_HDR(cmd.hdr); 1430: 1431: return gen8_hfi_send_generic_req(adreno_dev, &cmd, sizeof(cmd)); 1432: } 1433: 1434: static int send_start_msg(struct adreno_device *adreno_dev) 1435: { 1436: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1437: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1438: struct device *gmu_pdev_dev = GMU_PDEV_DEV(device); 1439: int ret, rc = 0; 1440: struct hfi_start_cmd cmd; 1441: u32 seqnum, rcvd[MAX_RCVD_SIZE]; 1442: struct pending_cmd pending_ack = {0}; 1443: 1444: ret = CMD_MSG_HDR(cmd, H2F_MSG_START); 1445: if (ret) 1446: return ret; 1447: 1448: seqnum = atomic_inc_return(&gmu->hfi.seqnum); 1449: cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2); 1450: 1451: pending_ack.sent_hdr = cmd.hdr; 1452: 1453: rc = gen8_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd)); 1454: if (rc) 1455: return rc; 1456: 1457: poll: 1458: rc = adreno_hwsched_poll_msg_queue_write_index(gmu->hfi.hfi_mem); 1459: 1460: if (rc) { 1461: dev_err(gmu_pdev_dev, 1462: "Timed out processing MSG_START seqnum: %d\n", 1463: seqnum); 1464: gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START); 1465: goto done; 1466: } 1467: 1468: rc = gen8_hfi_queue_read(gmu, HFI_MSG_ID, rcvd, sizeof(rcvd)); 1469: if (rc <= 0) { 1470: dev_err(gmu_pdev_dev, 1471: "MSG_START: payload error: %d\n", 1472: rc); 1473: gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START); 1474: goto done; 1475: } 1476: 1477: switch (MSG_HDR_GET_ID(rcvd[0])) { 1478: case F2H_MSG_MEM_ALLOC: 1479: rc = mem_alloc_reply(adreno_dev, rcvd); 1480: break; 1481: case F2H_MSG_GMU_CNTR_REGISTER: 1482: rc = gmu_cntr_register_reply(adreno_dev, rcvd); 1483: break; 1484: case F2H_MSG_PROCESS_TRACE: 1485: rc = 0; 1486: gmu_core_process_trace_data(device, GMU_PDEV_DEV(device), &device->gmu_core.trace); 1487: break; 1488: case F2H_MSG_PLATFORM_LA: 1489: rc = gen8_hwsched_process_f2h_platform_msg(adreno_dev, rcvd); 1490: break; 1491: default: 1492: if (MSG_HDR_GET_TYPE(rcvd[0]) == HFI_MSG_ACK) { 1493: rc = gen8_receive_ack_cmd(gmu, rcvd, &pending_ack); 1494: /* Check ack failure if we received an expected ack */ 1495: if (!rc) 1496: rc = check_ack_failure(adreno_dev, &pending_ack); 1497: goto done; 1498: } else { 1499: dev_err(gmu_pdev_dev, 1500: "MSG_START: unexpected response id:%d, type:%d\n", 1501: MSG_HDR_GET_ID(rcvd[0]), 1502: MSG_HDR_GET_TYPE(rcvd[0])); 1503: gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START); 1504: rc = -EINVAL; 1505: goto done; 1506: } 1507: } 1508: 1509: if (!rc) 1510: goto poll; 1511: 1512: done: 1513: /* Clear the interrupt */ 1514: gmu_core_regwrite(device, GEN8_GMUCX_GMU2HOST_INTR_CLR, HFI_IRQ_MSGQ_MASK); 1515: /* 1516: * Add a write barrier to post the interrupt clear so that we dont have a 1517: * pending interrupt. 1518: */ 1519: wmb(); 1520: return rc; 1521: } 1522: 1523: static void reset_hfi_queues(struct adreno_device *adreno_dev) 1524: { 1525: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1526: struct hfi_queue_table *tbl = gmu->hfi.hfi_mem->hostptr; 1527: u32 i; 1528: 1529: /* Flush HFI queues */ 1530: for (i = 0; i < HFI_QUEUE_MAX; i++) { 1531: struct hfi_queue_header *hdr = &tbl->qhdr[i]; 1532: 1533: if (hdr->status == HFI_QUEUE_STATUS_DISABLED) 1534: continue; 1535: 1536: hdr->read_index = hdr->write_index; 1537: } 1538: } 1539: 1540: void gen8_hwsched_hfi_stop(struct adreno_device *adreno_dev) 1541: { 1542: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1543: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev); 1544: 1545: hfi->irq_mask &= ~HFI_IRQ_MSGQ_MASK; 1546: 1547: /* 1548: * In some corner cases, it is possible that GMU put TS_RETIRE 1549: * on the msgq after we have turned off gmu interrupts. Hence, 1550: * drain the queue one last time before we reset HFI queues. 1551: */ 1552: gen8_hwsched_process_msgq(adreno_dev); 1553: 1554: /* Drain the debug queue before we reset HFI queues */ 1555: gen8_hwsched_process_dbgq(adreno_dev, false); 1556: 1557: kgsl_pwrctrl_axi(KGSL_DEVICE(adreno_dev), false); 1558: 1559: clear_bit(GMU_PRIV_HFI_STARTED, &gmu->flags); 1560: } 1561: 1562: static void gen8_hwsched_enable_async_hfi(struct adreno_device *adreno_dev) 1563: { 1564: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev); 1565: 1566: hfi->irq_mask |= HFI_IRQ_MSGQ_MASK; 1567: 1568: gmu_core_regwrite(KGSL_DEVICE(adreno_dev), GEN8_GMUCX_GMU2HOST_INTR_MASK, 1569: (u32)~hfi->irq_mask); 1570: } 1571: 1572: static int enable_preemption(struct adreno_device *adreno_dev) 1573: { 1574: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev); 1575: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1576: u32 data; 1577: int ret; 1578: 1579: if (!adreno_is_preemption_enabled(adreno_dev)) 1580: return 0; 1581: 1582: /* 1583: * Bits [0:1] contains the preemption level 1584: * Bit 2 is to enable/disable gmem save/restore 1585: * Bit 3 is to enable/disable skipsaverestore 1586: */ 1587: data = FIELD_PREP(GENMASK(1, 0), adreno_dev->preempt.preempt_level) | 1588: FIELD_PREP(BIT(2), adreno_dev->preempt.usesgmem) | 1589: FIELD_PREP(BIT(3), adreno_dev->preempt.skipsaverestore); 1590: 1591: ret = gen8_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_PREEMPTION, 1, 1592: data); 1593: if (ret) 1594: return ret; 1595: 1596: if (gen8_core->qos_value) { 1597: int i; 1598: 1599: for (i = 0; i < KGSL_PRIORITY_MAX_RB_LEVELS; i++) { 1600: if (!gen8_core->qos_value[i]) 1601: continue; 1602: 1603: gen8_hfi_send_set_value(adreno_dev, 1604: HFI_VALUE_RB_GPU_QOS, i, 1605: gen8_core->qos_value[i]); 1606: } 1607: } 1608: 1609: if (device->pwrctrl.rt_bus_hint) { 1610: ret = gen8_hfi_send_set_value(adreno_dev, HFI_VALUE_RB_IB_RULE, 0, 1611: device->pwrctrl.rt_bus_hint); 1612: if (ret) 1613: device->pwrctrl.rt_bus_hint = 0; 1614: } 1615: 1616: /* 1617: * Bits[3:0] contain the preemption timeout enable bit per ringbuffer 1618: * Bits[31:4] contain the timeout in ms 1619: */ 1620: return gen8_hfi_send_set_value(adreno_dev, HFI_VALUE_BIN_TIME, 1, 1621: FIELD_PREP(GENMASK(31, 4), ADRENO_PREEMPT_TIMEOUT) | 1622: FIELD_PREP(GENMASK(3, 0), 0xf)); 1623: 1624: } 1625: 1626: static int enable_gmu_stats(struct adreno_device *adreno_dev) 1627: { 1628: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1629: u32 data; 1630: 1631: if (!gmu->stats_enable) 1632: return 0; 1633: 1634: /* 1635: * Bits [23:0] contains the countables mask 1636: * Bits [31:24] is the sampling interval 1637: */ 1638: data = FIELD_PREP(GENMASK(23, 0), gmu->stats_mask) | 1639: FIELD_PREP(GENMASK(31, 24), gmu->stats_interval); 1640: 1641: return gen8_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_GMU_STATS, 1, data); 1642: } 1643: 1644: static int gen8_hfi_send_perfcounter_feature_ctrl(struct adreno_device *adreno_dev) 1645: { 1646: /* 1647: * Perfcounter retention is disabled by default in GMU firmware. 1648: * In case perfcounter retention behaviour is overwritten by sysfs 1649: * setting dynmaically, send this HFI feature with 'enable = 0' to 1650: * disable this feature in GMU firmware. 1651: */ 1652: if (adreno_dev->perfcounter) 1653: return gen8_hfi_send_feature_ctrl(adreno_dev, 1654: HFI_FEATURE_PERF_NORETAIN, 0, 0); 1655: 1656: return 0; 1657: } 1658: 1659: u32 gen8_hwsched_hfi_get_value(struct adreno_device *adreno_dev, u32 prop, u32 subtype) 1660: { 1661: struct hfi_get_value_cmd cmd; 1662: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)); 1663: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1664: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev); 1665: struct pending_cmd pending_ack; 1666: u32 seqnum; 1667: int rc; 1668: 1669: rc = CMD_MSG_HDR(cmd, H2F_MSG_GET_VALUE); 1670: if (rc) 1671: return 0; 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, 1747: "GMU doesn't support HW_FENCE feature\n"); 1748: adreno_hwsched_deregister_hw_fence(adreno_dev); 1749: return 0; 1750: } 1751: 1752: return ret; 1753: } 1754: 1755: static int gen8_hfi_send_soft_reset_feature_ctrl(struct adreno_device *adreno_dev) 1756: { 1757: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 1758: 1759: if (!test_bit(ADRENO_HWSCHED_GPU_SOFT_RESET, &hwsched->flags)) 1760: return 0; 1761: 1762: return gen8_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_SOFT_RESET, 1, 0); 1763: } 1764: 1765: static int gen8_hfi_send_fast_context_destroy_feature_ctrl(struct adreno_device *adreno_dev) 1766: { 1767: int ret; 1768: 1769: if (!ADRENO_FEATURE(adreno_dev, ADRENO_GMU_FAST_CONTEXT_DESTROY)) 1770: return 0; 1771: 1772: if (!gmu_core_capabilities_enabled(&KGSL_DEVICE(adreno_dev)->gmu_core.platform_caps, 1773: FAC_FAST_CONTEXT_DESTROY)) 1774: return 0; 1775: 1776: /* 1777: * Enable the fast context destroy optimization if requested by the static 1778: * feature flag and if the capability is supported by the GMU. 1779: */ 1780: ret = gen8_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_FAST_CONTEXT_DESTROY, 1, 0); 1781: if (!ret) 1782: set_bit(ADRENO_DEVICE_FAST_CONTEXT_DESTROY, &adreno_dev->priv); 1783: 1784: return ret; 1785: } 1786: 1787: static void gen8_spin_idle_debug_lpac(struct adreno_device *adreno_dev, 1788: const char *str) 1789: { 1790: struct kgsl_device *device = &adreno_dev->dev; 1791: u32 rptr, wptr, status, intstatus, global_status; 1792: bool val = adreno_is_preemption_enabled(adreno_dev); 1793: 1794: dev_err(device->dev, str); 1795: 1796: kgsl_regread(device, GEN8_CP_RB_RPTR_LPAC, &rptr); 1797: kgsl_regread(device, GEN8_CP_RB_WPTR_LPAC, &wptr); 1798: 1799: kgsl_regread(device, GEN8_RBBM_STATUS, &status); 1800: kgsl_regread(device, GEN8_RBBM_INT_0_STATUS, &intstatus); 1801: kgsl_regread(device, GEN8_CP_INTERRUPT_STATUS_GLOBAL, &global_status); 1802: 1803: dev_err(device->dev, 1804: "LPAC rb=%d pos=%X/%X rbbm_status=%8.8X int_0_status=%8.8X global_status=%8.8X\n", 1805: val ? KGSL_LPAC_RB_ID : 1, rptr, wptr, 1806: status, intstatus, global_status); 1807: 1808: kgsl_device_snapshot(device, NULL, NULL, false); 1809: } 1810: 1811: static bool gen8_hwsched_warmboot_possible(struct adreno_device *adreno_dev) 1812: { 1813: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1814: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1815: struct gmu_core_device *gmu_core = &device->gmu_core; 1816: 1817: if (gmu_core->warmboot_enabled && test_bit(GMU_PRIV_WARMBOOT_GMU_INIT_DONE, &gmu->flags) 1818: && test_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags) && 1819: !test_bit(GMU_FORCE_COLDBOOT, &device->gmu_core.flags)) 1820: return true; 1821: 1822: return false; 1823: } 1824: 1825: static int gen8_hwsched_hfi_send_warmboot_cmd(struct adreno_device *adreno_dev, 1826: struct kgsl_memdesc *desc, u32 flag, bool async, struct pending_cmd *ack) 1827: { 1828: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1829: struct gmu_core_device *gmu_core = &device->gmu_core; 1830: struct hfi_warmboot_scratch_cmd cmd = {0}; 1831: int ret; 1832: 1833: if (!gmu_core->warmboot_enabled) 1834: return 0; 1835: 1836: cmd.scratch_addr = desc->gmuaddr; 1837: cmd.scratch_size = desc->size; 1838: cmd.flags = flag; 1839: 1840: ret = CMD_MSG_HDR(cmd, H2F_MSG_WARMBOOT_CMD); 1841: if (ret) 1842: return ret; 1843: 1844: if (async) 1845: return gen8_hfi_send_cmd_async(adreno_dev, &cmd, sizeof(cmd)); 1846: 1847: return gen8_hfi_send_generic_req_v5(adreno_dev, &cmd, ack, sizeof(cmd)); 1848: } 1849: 1850: static int gen8_hwsched_hfi_warmboot_gpu_cmd(struct adreno_device *adreno_dev, 1851: struct pending_cmd *ret_cmd) 1852: { 1853: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1854: struct gmu_core_device *gmu_core = &device->gmu_core; 1855: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)); 1856: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1857: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev); 1858: struct hfi_warmboot_scratch_cmd cmd = { 1859: .scratch_addr = gmu->gpu_boot_scratch->gmuaddr, 1860: .scratch_size = gmu->gpu_boot_scratch->size, 1861: .flags = HFI_WARMBOOT_EXEC_SCRATCH, 1862: }; 1863: int ret = 0; 1864: u32 seqnum; 1865: 1866: if (!gmu_core->warmboot_enabled) 1867: return 0; 1868: 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; 1906: 1907: /* Check if the ack belongs to the warmboot command */ 1908: if (MSG_HDR_GET_ID(ret_cmd.results[0]) != H2F_MSG_WARMBOOT_CMD) { 1909: ret = -EINVAL; 1910: goto err; 1911: } 1912: 1913: switch (ret_cmd.results[3]) { 1914: /* If ack has no error code then GPU executed raw commands just fine */ 1915: case GMU_SUCCESS: 1916: return ret_cmd.results[2]; 1917: /* If GPU timedout processing raw commands, check which raw command failed */ 1918: case GMU_ERROR_TIMEOUT: { 1919: if (MSG_HDR_GET_ID(ret_cmd.results[1]) == H2F_MSG_ISSUE_CMD_RAW) { 1920: 1921: /* Based on sequence number we can differentiate which command failed */ 1922: if (ret_cmd.results[1] == gmu->cp_init_hdr) 1923: gen8_spin_idle_debug(adreno_dev, 1924: "CP initialization failed to idle\n"); 1925: else if (ret_cmd.results[1] == gmu->switch_to_unsec_hdr) 1926: gen8_spin_idle_debug(adreno_dev, 1927: "Switch to unsecure failed to idle\n"); 1928: } else if (MSG_HDR_GET_ID(ret_cmd.results[1]) == H2F_MSG_ISSUE_LPAC_CMD_RAW) { 1929: gen8_spin_idle_debug_lpac(adreno_dev, 1930: "LPAC CP initialization failed to idle\n"); 1931: } else { 1932: print_warmboot_gpu_error(gmu_pdev_dev, &ret_cmd); 1933: } 1934: ret = -EINVAL; 1935: break; 1936: } 1937: default: 1938: print_warmboot_gpu_error(gmu_pdev_dev, &ret_cmd); 1939: ret = -EINVAL; 1940: break; 1941: } 1942: err: 1943: /* Clear the bit on error so that in the next slumber exit we coldboot */ 1944: clear_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags); 1945: gen8_disable_gpu_irq(adreno_dev); 1946: return ret; 1947: } 1948: 1949: static int gen8_hwsched_coldboot_gpu(struct adreno_device *adreno_dev) 1950: { 1951: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1952: struct gmu_core_device *gmu_core = &device->gmu_core; 1953: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1954: struct gen8_hfi *hfi = to_gen8_hfi(adreno_dev); 1955: struct pending_cmd ack = {0}; 1956: int ret = 0; 1957: 1958: ret = gen8_hwsched_hfi_send_warmboot_cmd(adreno_dev, gmu->gpu_boot_scratch, 1959: HFI_WARMBOOT_SET_SCRATCH, true, &ack); 1960: if (ret) 1961: goto done; 1962: 1963: ret = gen8_hwsched_cp_init(adreno_dev); 1964: if (ret) 1965: goto done; 1966: 1967: ret = gen8_hwsched_lpac_cp_init(adreno_dev); 1968: if (ret) 1969: goto done; 1970: 1971: ret = gen8_hwsched_hfi_send_warmboot_cmd(adreno_dev, gmu->gpu_boot_scratch, 1972: HFI_WARMBOOT_QUERY_SCRATCH, true, &ack); 1973: if (ret) 1974: goto done; 1975: 1976: if (gmu_core->warmboot_enabled) 1977: set_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags); 1978: 1979: done: 1980: /* Clear the bitmask so that we don't send record bit with future HFI messages */ 1981: memset(hfi->wb_set_record_bitmask, 0x0, sizeof(hfi->wb_set_record_bitmask)); 1982: 1983: if (ret) 1984: gen8_disable_gpu_irq(adreno_dev); 1985: 1986: /* 1987: * Request counters for bus DCVS. This is only invoked in coldboot path as we 1988: * dont need to allocate it every boot and because we need to reallocate it 1989: * when switched to host based DCVS. If counters are already allocated, 1990: * we would return early 1991: */ 1992: adreno_get_bus_counters(adreno_dev); 1993: 1994: return ret; 1995: } 1996: 1997: int gen8_hwsched_boot_gpu(struct adreno_device *adreno_dev) 1998: { 1999: int ret; 2000: 2001: /* If warmboot is possible just send the warmboot command else coldboot */ MATCH LINES: 2029, 2032, 2038, 2053, 2057, 2068, 2085, 2090, 2093, 2107, 2110, 2128, 2135, 2138, 2139, 2140, 2155, 2160, 2165, 2183, 2188, 2199, 2200, 2201, 2204, 2205, 2209, 2210, 2214, 2215, 2235, 2240, 2244, 2245, 2251, 2258, 2259, 2260, 2269, 2272, 2285, 2288, 2291, 2295, 2315, 2328, 2335, 2336, 2337, 2364, 2366, 2377, 2394, 2415, 2428, 2435, 2438, 2440, 2441, 2442, 2447, 2452, 2460, 2461, 2462, 2465, 2467, 2471, 2479, 2491, 2503, 2505, 2509, 2510, 2517, 2525, 2531, 2534, 2535, 2536, 2548, 2549, 2553, 2558, 2561, 2565, 2566, 2571, 2574, 2578, 2582, 2586, 2590, 2594, 2598, 2602, 2607, 2613, 2619, 2620, 2625, 2628, 2629, 2632, 2633, 2635, 2639, 2647, 2652, 2657, 2661, 2666, 2675, 2678, 2679, 2683, 2685, 2692, 2693, 2694, 2695, 2701, 2702, 2704, 2705, 2709, 2713, 2717, 2740, 2743, 2744, 2748, 2749, 2755, 2765, 2769, 2782, 2786, 2796, 2800, 2815, 2819 2017: * miss any register programming when we patch the power up register 2018: * list. 2019: */ 2020: if (!adreno_dev->patch_reglist && 2021: (adreno_dev->pwrup_reglist->gpuaddr != 0)) { 2022: gen8_patch_pwrup_reglist(adreno_dev); 2023: adreno_dev->patch_reglist = true; 2024: } 2025: 2026: return ret; 2027: } 2028: 2029: static int gen8_hwsched_hfi_set_tunables(struct adreno_device *adreno_dev, u32 type, u32 subtype, 2030: u32 val, u32 *ret) 2031: { 2032: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2033: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2034: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev); 2035: struct pending_cmd pending_ack; 2036: int rc; 2037: u32 seqnum; 2038: struct hfi_set_value_cmd cmd = { 2039: .type = type, 2040: .subtype = subtype, 2041: .data = val, 2042: }; 2043: 2044: rc = CMD_MSG_HDR(cmd, H2F_MSG_SET_VALUE); 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: 2082: return rc; 2083: } 2084: 2085: int gen8_hwsched_set_gmu_based_dcvs_value(struct adreno_device *adreno_dev, u32 type, 2086: u32 subtype, u32 val, bool default_vote) 2087: { 2088: int ret; 2089: 2090: ret = gen8_hwsched_hfi_set_value(adreno_dev, type, subtype, val); 2091: 2092: if (ret) 2093: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)), 2094: "Failed to set %s for value %u for HFI type %u, ret: %d\n", 2095: (default_vote ? "default" : ""), val, type, ret); 2096: 2097: return ret; 2098: } 2099: 2100: void gen8_hwsched_set_tuning_attrs(struct adreno_device *adreno_dev, u32 type, 2101: u32 subtype, u32 val) 2102: { 2103: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 2104: int ret; 2105: u32 data = GPU_DCVS_TUNING_INVALID_VALUE; 2106: 2107: ret = gen8_hwsched_hfi_set_tunables(adreno_dev, type, subtype, val, &data); 2108: 2109: if (ret) { 2110: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)), 2111: "Failed to set value %u for HFI type %u, ret: %d\n", 2112: val, type, ret); 2113: return; 2114: } 2115: 2116: hwsched->sysfs_dcvs_tunables[subtype].value = data; 2117: hwsched->sysfs_dcvs_tunables[subtype].update = false; 2118: } 2119: 2120: static void gen8_hwsched_send_tuning_attrs(struct adreno_device *adreno_dev) 2121: { 2122: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 2123: u32 i; 2124: 2125: for (i = 0; i < GPU_TUNING_KEY_MAX; i++) { 2126: if (hwsched->sysfs_dcvs_tunables[i].update) { 2127: gen8_hwsched_set_tuning_attrs(adreno_dev, 2128: HFI_VALUE_DCVS_TUNING_PARAM, 2129: i, 2130: hwsched->sysfs_dcvs_tunables[i].value); 2131: } 2132: } 2133: } 2134: 2135: void gen8_hwsched_hfi_get_dcvs_tuning_attrs(struct adreno_device *adreno_dev, 2136: u32 subtype, u32 *data) 2137: { 2138: struct hfi_get_value_cmd cmd; 2139: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)); 2140: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2141: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev); 2142: struct pending_cmd pending_ack; 2143: u32 seqnum; 2144: u32 num_values; 2145: u32 total_dwords; 2146: u32 hdr_size_in_dwords = 2; 2147: int ret; 2148: 2149: ret = CMD_MSG_HDR(cmd, H2F_MSG_GET_VALUE); 2150: if (ret) 2151: return; 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; 2189: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 2190: u32 thermal_pwrlevel = max_t(u32, pwr->thermal_pwrlevel, pwr->pmqos_max_pwrlevel); 2191: int ret = 0; 2192: bool reset = false; 2193: 2194: /* Disable recording of these messages */ 2195: if (test_and_clear_bit(H2F_MSG_SET_VALUE, hfi->wb_set_record_bitmask)) 2196: reset = true; 2197: 2198: if (hwsched->dcvs_param_update) 2199: ret = gen8_hwsched_set_gmu_based_dcvs_value(adreno_dev, 2200: HFI_VALUE_DCVS_ENABLE, 0, 2201: gmu_core->gpu_pwrscale_enable, true); 2202: 2203: if (thermal_pwrlevel != 0) 2204: ret = gen8_hwsched_set_gmu_based_dcvs_value(adreno_dev, 2205: HFI_VALUE_MAX_GPU_THERMAL_INDEX, 0, 2206: (pwr->num_pwrlevels - thermal_pwrlevel), true); 2207: 2208: if (pwr->min_pwrlevel != (pwr->num_pwrlevels - 1)) 2209: ret = gen8_hwsched_set_gmu_based_dcvs_value(adreno_dev, 2210: HFI_VALUE_MIN_GPU_PERF_INDEX, 0, 2211: (pwr->num_pwrlevels - pwr->min_pwrlevel), true); 2212: 2213: if (pwr->max_pwrlevel != 0) 2214: ret = gen8_hwsched_set_gmu_based_dcvs_value(adreno_dev, 2215: HFI_VALUE_MAX_GPU_PERF_INDEX, 0, 2216: (pwr->num_pwrlevels - pwr->max_pwrlevel), true); 2217: 2218: gen8_hwsched_send_tuning_attrs(adreno_dev); 2219: 2220: if (reset) 2221: set_bit(H2F_MSG_SET_VALUE, hfi->wb_set_record_bitmask); 2222: 2223: hwsched->dcvs_param_update = false; 2224: 2225: return ret; 2226: } 2227: 2228: static int gen8_hwsched_setup_default_votes(struct adreno_device *adreno_dev) 2229: { 2230: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2231: 2232: if (device->host_based_dcvs) 2233: return kgsl_pwrctrl_setup_default_votes(device); 2234: 2235: return gen8_hwsched_set_gmu_based_dcvs_votes(adreno_dev); 2236: } 2237: 2238: int gen8_hwsched_warmboot_init_gmu(struct adreno_device *adreno_dev) 2239: { 2240: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2241: struct pending_cmd ack = {0}; 2242: int ret = 0; 2243: 2244: ret = gen8_hwsched_hfi_send_warmboot_cmd(adreno_dev, gmu->gmu_init_scratch, 2245: HFI_WARMBOOT_EXEC_SCRATCH, false, &ack); 2246: if (ret) 2247: goto err; 2248: 2249: gen8_hwsched_enable_async_hfi(adreno_dev); 2250: 2251: set_bit(GMU_PRIV_HFI_STARTED, &gmu->flags); 2252: 2253: ret = gen8_hwsched_setup_default_votes(adreno_dev); 2254: 2255: err: 2256: if (ret) { 2257: /* Clear the bit in case of an error so next boot will be coldboot */ 2258: clear_bit(GMU_PRIV_WARMBOOT_GMU_INIT_DONE, &gmu->flags); 2259: clear_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags); 2260: gen8_hwsched_hfi_stop(adreno_dev); 2261: } 2262: 2263: return ret; 2264: } 2265: 2266: static void warmboot_init_message_record_bitmask(struct adreno_device *adreno_dev) 2267: { 2268: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2269: struct gmu_core_device *gmu_core = &device->gmu_core; 2270: struct gen8_hfi *hfi = to_gen8_hfi(adreno_dev); 2271: 2272: if (!gmu_core->warmboot_enabled) 2273: return; 2274: 2275: /* Set the record bit for all the messages */ 2276: memset(hfi->wb_set_record_bitmask, 0xFF, sizeof(hfi->wb_set_record_bitmask)); 2277: 2278: /* These messages should not be recorded */ 2279: clear_bit(H2F_MSG_WARMBOOT_CMD, hfi->wb_set_record_bitmask); 2280: clear_bit(H2F_MSG_START, hfi->wb_set_record_bitmask); 2281: clear_bit(H2F_MSG_GET_VALUE, hfi->wb_set_record_bitmask); 2282: clear_bit(H2F_MSG_GX_BW_PERF_VOTE, hfi->wb_set_record_bitmask); 2283: } 2284: 2285: static int gen8_hfi_send_thermal_feature_ctrl(struct adreno_device *adreno_dev) 2286: { 2287: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev); 2288: struct hfi_therm_profile_ctrl *therm; 2289: const struct therm_tsens_en_cfg *tsens_en_cfg; 2290: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2291: static struct hfi_thermaltable_cmd cmd = {0}; 2292: u32 tsens_en_bits; 2293: int ret; 2294: 2295: if (!test_bit(GMU_THERMAL_MITIGATION, &device->gmu_core.flags) || 2296: !gen8_core->therm_cfg || !gen8_core->therm_cfg->therm || 2297: !gen8_core->therm_cfg->tsens_en_cfg) 2298: return 0; 2299: 2300: therm = gen8_core->therm_cfg->therm; 2301: tsens_en_cfg = gen8_core->therm_cfg->tsens_en_cfg; 2302: 2303: tsens_en_bits = (tsens_en_cfg->tsens_sl_cnt * 2304: gen8_get_num_slices(adreno_dev)) + tsens_en_cfg->tsens_us_cnt; 2305: 2306: /* Maximum temperature sensors supported */ 2307: if (tsens_en_bits >= 32) { 2308: dev_crit_ratelimited(device->dev, 2309: "Invalid temperature sensor count %u\n", tsens_en_bits); 2310: return -EINVAL; 2311: } 2312: /* Set a bit for each temperature sensor */ 2313: therm->tsens_en = BIT(tsens_en_bits) - 1; 2314: 2315: ret = gen8_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_THERMAL, 1, 0); 2316: if (ret) 2317: return ret; 2318: 2319: if (cmd.version == 0) { 2320: ret = CMD_MSG_HDR(cmd, H2F_MSG_THERM_TBL); 2321: if (ret) 2322: return ret; 2323: 2324: cmd.version = 1; 2325: memcpy(&cmd.ctrl, therm, sizeof(*therm)); 2326: } 2327: 2328: return gen8_hfi_send_generic_req(adreno_dev, &cmd, sizeof(cmd)); 2329: } 2330: 2331: static int gen8_hwsched_build_dcvs_table(struct adreno_device *adreno_dev) 2332: { 2333: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2334: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 2335: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2336: struct hfi_table_cmd *cmd; 2337: struct hfi_table_entry *entry; 2338: u32 size_config_entry_dwords = (sizeof(*entry) >> 2) + (1 * 4); 2339: u32 size_ddr_levels_dwords = (sizeof(*entry) >> 2) + ((pwr->num_pwrlevels + 1) * 3); 2340: u32 size_ddr_table_dwords = (sizeof(*entry) >> 2) + (1 * pwr->ddr_table_count); 2341: u32 size_table_dwords = (sizeof(*cmd) >> 2) + size_config_entry_dwords + 2342: size_ddr_levels_dwords + size_ddr_table_dwords; 2343: u32 index; 2344: int i, j = 0; 2345: 2346: /* If cmdbuf is not allocated, allocate it first */ 2347: if (!gmu->dcvs_cmdbuf) { 2348: /* 2349: * size_dwords is the total size of struct elements and data, which is 2350: * (count * stride) for each entry. Make sure the size is equal to the 2351: * total number of entries in the buffer (index) to avoid overflow. 2352: */ 2353: gmu->dcvs_cmdbuf = kcalloc(size_table_dwords, sizeof(*(gmu->dcvs_cmdbuf)), 2354: GFP_KERNEL); 2355: if (!gmu->dcvs_cmdbuf) 2356: return -ENOMEM; 2357: pwr->update_dcvs_table = true; 2358: } 2359: 2360: /* If there are no changes needed for the table, use the existing table */ 2361: if (!pwr->update_dcvs_table) 2362: return 0; 2363: 2364: cmd = (struct hfi_table_cmd *)gmu->dcvs_cmdbuf; 2365: cmd->version = 0; 2366: cmd->type = HFI_TABLE_DCVS_DATA; 2367: index = sizeof(*cmd) >> 2; 2368: 2369: /* 2370: * Fill up config entry 2371: * First entry table contains 4 data. 2372: * 1) Number of gpu power levels 2373: * 2) GMU index to default level 2374: * 3) Bus width for the target 2375: * 4) Max ddr bandwidth across 4 channels 2376: */ 2377: entry = (struct hfi_table_entry *)&gmu->dcvs_cmdbuf[index]; 2378: entry->count = 1; 2379: entry->stride = 4; 2380: /* Number of power levels */ 2381: entry->data[j++] = pwr->num_pwrlevels + 1; 2382: /* GMU index to default level */ 2383: entry->data[j++] = pwr->num_pwrlevels - pwr->default_pwrlevel; 2384: /* Bus width for the target */ 2385: entry->data[j++] = pwr->bus_width; 2386: /* Number of ddr channels for the target */ 2387: entry->data[j++] = adreno_dev->gpucore->num_ddr_channels; 2388: index += size_config_entry_dwords; 2389: 2390: /* 2391: * Fill up ddr levels entry 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); 2429: cmd->hdr = MSG_HDR_SET_SIZE(cmd->hdr, index); 2430: 2431: pwr->update_dcvs_table = false; 2432: return 0; 2433: } 2434: 2435: static int gen8_hwsched_build_gmu_scaling_table(struct adreno_device *adreno_dev) 2436: { 2437: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2438: struct gmu_core_device *gmu_core = &device->gmu_core; 2439: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 2440: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2441: struct hfi_table_cmd *cmd; 2442: struct hfi_table_entry *entry; 2443: u32 index, i; 2444: u32 ddr_index; 2445: u32 size_first_entry_dwords = (sizeof(*entry) >> 2) + (1 * 1); 2446: u32 size_second_entry_dwords = (sizeof(*entry) >> 2) + 2447: (1 * (device->gmu_core.num_freqs + 1)); 2448: u32 size_table_dwords = (sizeof(*cmd) >> 2) + size_first_entry_dwords + 2449: size_second_entry_dwords; 2450: 2451: /* Return early if the scaling table is already generated */ 2452: if (gmu->gmu_scaling_cmdbuf) 2453: return 0; 2454: 2455: /* 2456: * Total size of struct elements and data, which is (count * stride) for each 2457: * entry. Make sure the size is equal to the total number of entries in the 2458: * buffer (index) to avoid overflow. 2459: */ 2460: gmu->gmu_scaling_cmdbuf = kcalloc(size_table_dwords, 2461: sizeof(*(gmu->gmu_scaling_cmdbuf)), GFP_KERNEL); 2462: if (!gmu->gmu_scaling_cmdbuf) 2463: return -ENOMEM; 2464: 2465: cmd = (struct hfi_table_cmd *)gmu->gmu_scaling_cmdbuf; 2466: cmd->version = 0; 2467: cmd->type = HFI_TABLE_GMU_SCALING_DATA; 2468: index = sizeof(*cmd) >> 2; 2469: 2470: if ((index + size_first_entry_dwords) > size_table_dwords) { 2471: kfree(gmu->gmu_scaling_cmdbuf); 2472: return -ENOMEM; 2473: } 2474: 2475: /* 2476: * Fill up first entry 2477: * First entry table contains the initial gmu power level 2478: */ 2479: entry = (struct hfi_table_entry *)&gmu->gmu_scaling_cmdbuf[index]; 2480: entry->count = 1; 2481: entry->stride = 1; 2482: 2483: /* 2484: * If the ddr threshold is defined for the target, set the initial gmu level as the lowest 2485: * gmu power level which is 1. If not, gmu scaling will be disabled. 2486: */ 2487: entry->data[0] = 1; 2488: index += size_first_entry_dwords; 2489: 2490: if ((index + size_second_entry_dwords) > size_table_dwords) { 2491: kfree(gmu->gmu_scaling_cmdbuf); 2492: return -ENOMEM; 2493: } 2494: 2495: /* 2496: * Fill up second entry 2497: * Second entry table contains the ddr threshold level for each gmu power level from 2498: * index 0 to MAX_CX_LEVEL. The entry represents the threshold the corresponding 2499: * gmu power level index needs to cross to be scaled to a higher level. 0 represents 2500: * no scaling up on that level. To scale down, the ddr should be below the threshold 2501: * at the previos gmu power level index. 2502: */ 2503: entry = (struct hfi_table_entry *)&gmu->gmu_scaling_cmdbuf[index]; 2504: entry->count = 1; 2505: entry->stride = device->gmu_core.num_freqs + 1; 2506: 2507: entry->data[0] = 0; 2508: 2509: for (i = 0; i < device->gmu_core.num_freqs; i++) { 2510: if (!gmu_core->perf_ddr_bw[i]) { 2511: entry->data[i + 1] = 0; 2512: continue; 2513: } 2514: 2515: /* Find the ddr index for gmu level */ 2516: for (ddr_index = 0; ddr_index < pwr->ddr_table_count; ddr_index++) { 2517: if (pwr->ddr_table[ddr_index] >= gmu_core->perf_ddr_bw[i]) 2518: break; 2519: } 2520: entry->data[i + 1] = ddr_index; 2521: } 2522: 2523: index += size_second_entry_dwords; 2524: 2525: cmd->hdr = CREATE_MSG_HDR(H2F_MSG_TABLE, HFI_MSG_CMD); 2526: cmd->hdr = MSG_HDR_SET_SIZE(cmd->hdr, index); 2527: 2528: return 0; 2529: } 2530: 2531: static int gen8_hfi_send_gmu_dcvs_req(struct adreno_device *adreno_dev) 2532: { 2533: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2534: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2535: struct gmu_core_device *gmu_core = &device->gmu_core; 2536: struct hfi_table_cmd *cmd; 2537: int ret; 2538: 2539: /* If KGSL is performing pwrscale, just return */ 2540: if (device->host_based_dcvs) 2541: return 0; 2542: 2543: /* Build the table to be send to GMU for GMU based DCVS */ 2544: ret = gen8_hwsched_build_dcvs_table(adreno_dev); 2545: if (ret) 2546: return ret; 2547: 2548: cmd = (struct hfi_table_cmd *)gmu->dcvs_cmdbuf; 2549: ret = gen8_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_DCVS, 1, GMU_GPU_DCVS_OBJ_PARITY); 2550: if (ret) 2551: return ret; 2552: 2553: ret = gen8_hfi_send_generic_req(adreno_dev, cmd, MSG_HDR_GET_SIZE(cmd->hdr) << 2); 2554: if (ret) 2555: return ret; 2556: 2557: /* Do not scale gmu if perf_ddr_bw is not configured */ 2558: if (!gmu_core->perf_ddr_bw[0]) 2559: return 0; 2560: 2561: ret = gen8_hwsched_build_gmu_scaling_table(adreno_dev); 2562: if (ret) 2563: return ret; 2564: 2565: cmd = (struct hfi_table_cmd *)gmu->gmu_scaling_cmdbuf; 2566: return gen8_hfi_send_generic_req(adreno_dev, cmd, MSG_HDR_GET_SIZE(cmd->hdr) << 2); 2567: } 2568: 2569: static int gen8_hwsched_feature_ctrl(struct adreno_device *adreno_dev) 2570: { 2571: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2572: int ret; 2573: 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; 2611: } 2612: 2613: ret = gen8_hfi_send_perfcounter_feature_ctrl(adreno_dev); 2614: if (ret) 2615: goto err; 2616: 2617: /* Enable the long ib timeout detection */ 2618: if (adreno_long_ib_detect(adreno_dev)) { 2619: ret = gen8_hfi_send_feature_ctrl(adreno_dev, 2620: HFI_FEATURE_BAIL_OUT_TIMER, 1, 0); 2621: if (ret) 2622: goto err; 2623: } 2624: 2625: enable_gmu_stats(adreno_dev); 2626: 2627: if (gmu->log_stream_enable) 2628: gen8_hfi_send_set_value(adreno_dev, 2629: HFI_VALUE_LOG_STREAM_ENABLE, 0, 1); 2630: 2631: if (gmu->log_group_mask) 2632: gen8_hfi_send_set_value(adreno_dev, 2633: HFI_VALUE_LOG_GROUP, 0, gmu->log_group_mask); 2634: 2635: ret = gen8_hfi_send_core_fw_start(adreno_dev); 2636: if (ret) 2637: goto err; 2638: 2639: ret = gen8_hfi_send_hw_fence_feature_ctrl(adreno_dev); 2640: if (ret) 2641: goto err; 2642: 2643: ret = enable_preemption(adreno_dev); 2644: if (ret) 2645: goto err; 2646: 2647: ret = gen8_hfi_send_lpac_feature_ctrl(adreno_dev); 2648: if (ret) 2649: goto err; 2650: 2651: if (ADRENO_FEATURE(adreno_dev, ADRENO_AQE)) { 2652: ret = gen8_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_AQE, 1, 0); 2653: if (ret) 2654: goto err; 2655: } 2656: 2657: ret = gen8_hfi_send_soft_reset_feature_ctrl(adreno_dev); 2658: if (ret) 2659: goto err; 2660: 2661: ret = gen8_hfi_send_fast_context_destroy_feature_ctrl(adreno_dev); 2662: if (ret) 2663: goto err; 2664: 2665: if (adreno_dev->dcvs_profile_enabled) { 2666: ret = gen8_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_DCVS_PROFILE, 1, 0); 2667: if (ret) 2668: goto err; 2669: } 2670: 2671: err: 2672: return ret; 2673: } 2674: 2675: int gen8_hwsched_hfi_start(struct adreno_device *adreno_dev) 2676: { 2677: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2678: struct gmu_core_device *gmu_core = &device->gmu_core; 2679: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2680: struct pending_cmd ack = {0}; 2681: int ret; 2682: 2683: reset_hfi_queues(adreno_dev); 2684: 2685: ret = gen8_gmu_hfi_start(adreno_dev); 2686: if (ret) 2687: goto err; 2688: 2689: if (gen8_hwsched_warmboot_possible(adreno_dev)) 2690: return gen8_hwsched_warmboot_init_gmu(adreno_dev); 2691: 2692: if (ADRENO_FEATURE(adreno_dev, ADRENO_GMU_WARMBOOT) && 2693: (!test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags))) { 2694: if (gen8_hfi_send_get_value(adreno_dev, HFI_VALUE_GMU_WARMBOOT, 0) == 1) 2695: gmu_core->warmboot_enabled = true; 2696: } 2697: 2698: warmboot_init_message_record_bitmask(adreno_dev); 2699: 2700: /* Reset the variable here and set it when we successfully record the scratch */ 2701: clear_bit(GMU_PRIV_WARMBOOT_GMU_INIT_DONE, &gmu->flags); 2702: clear_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags); 2703: 2704: ret = gen8_hwsched_hfi_send_warmboot_cmd(adreno_dev, gmu->gmu_init_scratch, 2705: HFI_WARMBOOT_SET_SCRATCH, false, &ack); 2706: if (ret) 2707: goto err; 2708: 2709: ret = gen8_hfi_send_gpu_perf_table(adreno_dev); 2710: if (ret) 2711: goto err; 2712: 2713: ret = gen8_hfi_send_generic_req(adreno_dev, &gmu->hfi.bw_table, sizeof(gmu->hfi.bw_table)); 2714: if (ret) 2715: goto err; 2716: 2717: ret = gen8_hfi_send_gmu_dcvs_req(adreno_dev); 2718: if (ret) 2719: goto err; 2720: 2721: ret = gen8_hwsched_feature_ctrl(adreno_dev); 2722: if (ret) 2723: goto err; 2724: 2725: ret = send_start_msg(adreno_dev); 2726: if (ret) 2727: goto err; 2728: 2729: /* 2730: * Send this additional start message on cold boot if warmboot is enabled. 2731: * This message will be recorded and on a warmboot this will trigger the 2732: * sequence to replay memory allocation requests and ECP task setup 2733: */ 2734: ret = send_warmboot_start_msg(adreno_dev); 2735: if (ret) 2736: goto err; 2737: 2738: gen8_hwsched_enable_async_hfi(adreno_dev); 2739: 2740: set_bit(GMU_PRIV_HFI_STARTED, &gmu->flags); 2741: 2742: /* Send this message only on cold boot */ 2743: ret = gen8_hwsched_hfi_send_warmboot_cmd(adreno_dev, gmu->gmu_init_scratch, 2744: HFI_WARMBOOT_QUERY_SCRATCH, true, &ack); 2745: if (ret) 2746: goto err; 2747: 2748: if (gmu_core->warmboot_enabled) 2749: set_bit(GMU_PRIV_WARMBOOT_GMU_INIT_DONE, &gmu->flags); 2750: 2751: ret = gen8_hwsched_setup_default_votes(adreno_dev); 2752: 2753: err: 2754: if (ret) 2755: gen8_hwsched_hfi_stop(adreno_dev); 2756: 2757: return ret; 2758: } 2759: 2760: static int submit_raw_cmds(struct adreno_device *adreno_dev, void *cmds, u32 size_bytes, 2761: const char *str) 2762: { 2763: int ret; 2764: 2765: ret = gen8_hfi_send_cmd_async(adreno_dev, cmds, size_bytes); 2766: if (ret) 2767: return ret; 2768: 2769: ret = gmu_core_timed_poll_check(KGSL_DEVICE(adreno_dev), 2770: GEN8_GMUAO_GPU_CX_BUSY_STATUS, 0, 200, BIT(23)); 2771: if (ret) 2772: gen8_spin_idle_debug(adreno_dev, str); 2773: 2774: return ret; 2775: } 2776: 2777: static int submit_lpac_raw_cmds(struct adreno_device *adreno_dev, void *cmds, u32 size_bytes, 2778: const char *str) 2779: { 2780: int ret; 2781: 2782: ret = gen8_hfi_send_cmd_async(adreno_dev, cmds, size_bytes); 2783: if (ret) 2784: return ret; 2785: 2786: ret = gmu_core_timed_poll_check(KGSL_DEVICE(adreno_dev), 2787: GEN8_GMUAO_LPAC_BUSY_STATUS, 0, 200, BIT(23)); 2788: if (ret) 2789: gen8_spin_idle_debug_lpac(adreno_dev, str); 2790: 2791: return ret; 2792: } 2793: 2794: static int cp_init(struct adreno_device *adreno_dev) 2795: { 2796: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2797: u32 cmds[GEN8_CP_INIT_DWORDS + 1]; 2798: int ret = 0; 2799: 2800: cmds[0] = CREATE_MSG_HDR(H2F_MSG_ISSUE_CMD_RAW, HFI_MSG_CMD); 2801: 2802: gen8_cp_init_cmds(adreno_dev, &cmds[1]); 2803: 2804: ret = submit_raw_cmds(adreno_dev, cmds, sizeof(cmds), 2805: "CP initialization failed to idle\n"); 2806: 2807: /* Save the header incase we need a warmboot debug */ 2808: gmu->cp_init_hdr = cmds[0]; 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) MATCH LINES: 2862, 2870, 2873, 2880, 2881, 2883, 2885, 2891, 2892, 2905, 2930, 2935, 2939, 2949, 2951, 2952, 2956, 2957, 2962, 2983, 2991, 2993, 2994, 2996, 2998, 2999, 3009, 3010, 3011, 3012, 3015, 3016, 3021, 3022, 3023, 3024, 3027, 3028, 3031, 3041, 3057, 3069, 3076, 3090, 3095, 3097, 3100, 3108, 3113, 3117, 3118, 3126, 3131, 3135, 3136, 3141, 3142, 3153, 3155, 3169, 3173, 3185, 3187, 3221, 3227, 3232, 3249, 3250, 3253, 3255, 3258, 3264, 3285, 3307, 3311, 3323, 3326, 3353, 3381, 3391, 3392, 3415, 3423, 3438, 3439, 3458, 3468, 3472, 3498, 3506, 3513, 3521 2850: ret = send_switch_to_unsecure(adreno_dev); 2851: 2852: return ret; 2853: } 2854: 2855: int gen8_hwsched_lpac_cp_init(struct adreno_device *adreno_dev) 2856: { 2857: u32 cmds[GEN8_CP_INIT_DWORDS + 1]; 2858: 2859: if (!adreno_dev->lpac_enabled) 2860: return 0; 2861: 2862: cmds[0] = CREATE_MSG_HDR(H2F_MSG_ISSUE_LPAC_CMD_RAW, HFI_MSG_CMD); 2863: 2864: gen8_cp_init_cmds(adreno_dev, &cmds[1]); 2865: 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, 2903: hwsched_hfi); 2904: struct adreno_device *adreno_dev = &gen8_hw_dev->gen8_dev.adreno_dev; 2905: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)); 2906: u32 unack_count, ts; 2907: struct adreno_context *drawctxt = NULL; 2908: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 2909: bool fault; 2910: 2911: /* Check msgq one last time before recording a fault */ 2912: gen8_hwsched_process_msgq(adreno_dev); 2913: 2914: spin_lock(&hwf->lock); 2915: 2916: unack_count = hwf->unack_count; 2917: 2918: fault = test_bit(GEN8_HWSCHED_HW_FENCE_SLEEP_BIT, &hwf->flags) && 2919: test_bit(GEN8_HWSCHED_HW_FENCE_MAX_BIT, &hwf->flags) && 2920: (unack_count > MIN_HW_FENCE_UNACK_COUNT); 2921: 2922: drawctxt = hwf->defer_drawctxt; 2923: ts = hwf->defer_ts; 2924: 2925: spin_unlock(&hwf->lock); 2926: 2927: if (!fault) 2928: return; 2929: 2930: dev_err(gmu_pdev_dev, "Hardware fence unack(%d) timeout\n", unack_count); 2931: 2932: if (drawctxt) { 2933: struct kgsl_process_private *proc_priv = drawctxt->base.proc_priv; 2934: 2935: dev_err(gmu_pdev_dev, 2936: "Hardware fence got deferred for ctx:%d ts:%d pid:%d proc:%s\n", 2937: drawctxt->base.id, ts, pid_nr(proc_priv->pid), proc_priv->comm); 2938: } 2939: gen8_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 2940: } 2941: 2942: static void gen8_hwsched_hw_fence_timer(struct timer_list *t) 2943: { 2944: struct gen8_hwsched_hfi *hfi = kgsl_timer_container_of(hfi, t, hw_fence_timer); 2945: 2946: kgsl_schedule_work(&hfi->hw_fence_ws); 2947: } 2948: 2949: int gen8_hwsched_hfi_probe(struct adreno_device *adreno_dev) 2950: { 2951: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2952: struct platform_device *gmu_pdev = GMU_PDEV(KGSL_DEVICE(adreno_dev)); 2953: struct gen8_hwsched_hfi *hw_hfi = to_gen8_hwsched_hfi(adreno_dev); 2954: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 2955: 2956: gmu->hfi.irq = kgsl_request_irq(gmu_pdev, "hfi", NULL, -EINVAL, 2957: gen8_hwsched_hfi_handler, adreno_dev); 2958: 2959: if (gmu->hfi.irq < 0) 2960: return gmu->hfi.irq; 2961: 2962: hw_hfi->irq_mask = HFI_IRQ_MASK; 2963: 2964: rwlock_init(&hw_hfi->msglock); 2965: 2966: INIT_LIST_HEAD(&hw_hfi->msglist); 2967: INIT_LIST_HEAD(&hw_hfi->detached_hw_fence_list); 2968: 2969: init_waitqueue_head(&hw_hfi->f2h_wq); 2970: init_waitqueue_head(&hwf->unack_wq); 2971: 2972: spin_lock_init(&hwf->lock); 2973: 2974: mutex_init(&hw_hfi->msgq_mutex); 2975: 2976: INIT_WORK(&hw_hfi->hw_fence_ws, gen8_hwsched_hw_fence_timeout); 2977: 2978: timer_setup(&hw_hfi->hw_fence_timer, gen8_hwsched_hw_fence_timer, 0); 2979: 2980: return 0; 2981: } 2982: 2983: void gen8_hwsched_hfi_remove(struct adreno_device *adreno_dev) 2984: { 2985: struct gen8_hwsched_hfi *hw_hfi = to_gen8_hwsched_hfi(adreno_dev); 2986: 2987: if (hw_hfi->f2h_task) 2988: kthread_stop(hw_hfi->f2h_task); 2989: } 2990: 2991: static void init_gmu_context_queue(struct adreno_context *drawctxt) 2992: { 2993: struct kgsl_memdesc *md = &drawctxt->gmu_context_queue; 2994: struct gmu_context_queue_header *hdr = md->hostptr; 2995: 2996: hdr->start_addr = md->gmuaddr + sizeof(*hdr); 2997: hdr->queue_size = (md->size - sizeof(*hdr)) >> 2; 2998: hdr->hw_fence_buffer_va = drawctxt->gmu_hw_fence_queue.gmuaddr; 2999: hdr->hw_fence_buffer_size = drawctxt->gmu_hw_fence_queue.size; 3000: } 3001: 3002: static int allocate_context_queues(struct adreno_device *adreno_dev, 3003: struct adreno_context *drawctxt) 3004: { 3005: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 3006: int ret = 0; 3007: 3008: if (test_bit(ADRENO_HWSCHED_HW_FENCE, &adreno_dev->hwsched.flags) && 3009: !drawctxt->gmu_hw_fence_queue.gmuaddr) { 3010: ret = gmu_core_alloc_kernel_block( 3011: device, &drawctxt->gmu_hw_fence_queue, 3012: HW_FENCE_QUEUE_SIZE, GMU_NONCACHED_KERNEL, 3013: IOMMU_READ | IOMMU_WRITE | IOMMU_PRIV); 3014: if (ret) { 3015: memset(&drawctxt->gmu_hw_fence_queue, 0x0, 3016: sizeof(drawctxt->gmu_hw_fence_queue)); 3017: return ret; 3018: } 3019: } 3020: 3021: if (!drawctxt->gmu_context_queue.gmuaddr) { 3022: ret = gmu_core_alloc_kernel_block( 3023: device, &drawctxt->gmu_context_queue, 3024: SZ_4K, GMU_NONCACHED_KERNEL, 3025: IOMMU_READ | IOMMU_WRITE | IOMMU_PRIV); 3026: if (ret) { 3027: memset(&drawctxt->gmu_context_queue, 0x0, 3028: sizeof(drawctxt->gmu_context_queue)); 3029: return ret; 3030: } 3031: init_gmu_context_queue(drawctxt); 3032: } 3033: 3034: return 0; 3035: } 3036: 3037: static int send_context_register(struct adreno_device *adreno_dev, 3038: struct kgsl_context *context) 3039: { 3040: struct adreno_context *drawctxt = ADRENO_CONTEXT(context); 3041: struct hfi_register_ctxt_cmd cmd; 3042: struct kgsl_pagetable *pt = context->proc_priv->pagetable; 3043: int ret, asid = kgsl_mmu_pagetable_get_asid(pt, context); 3044: 3045: if (asid < 0) 3046: return asid; 3047: 3048: ret = CMD_MSG_HDR(cmd, H2F_MSG_REGISTER_CONTEXT); 3049: if (ret) 3050: return ret; 3051: 3052: ret = allocate_context_queues(adreno_dev, drawctxt); 3053: if (ret) 3054: return ret; 3055: 3056: cmd.ctxt_id = context->id; 3057: cmd.flags = HFI_CTXT_FLAG_NOTIFY | context->flags; 3058: /* 3059: * HLOS SMMU driver programs context bank to look up ASID from TTBR0 during a page 3060: * table walk. So the TLB entries are tagged with the ASID from TTBR0. TLBIASID 3061: * invalidates TLB entries whose ASID matches the value that was written to the 3062: * CBn_TLBIASID register. Set ASID along with PT address. 3063: */ 3064: cmd.pt_addr = kgsl_mmu_pagetable_get_ttbr0(pt) | 3065: FIELD_PREP(GENMASK_ULL(63, KGSL_IOMMU_ASID_START_BIT), asid); 3066: cmd.ctxt_idr = context->id; 3067: cmd.ctxt_bank = kgsl_mmu_pagetable_get_context_bank(pt, context); 3068: 3069: return gen8_hfi_send_cmd_async(adreno_dev, &cmd, sizeof(cmd)); 3070: } 3071: 3072: static int send_context_pointers(struct adreno_device *adreno_dev, 3073: struct kgsl_context *context) 3074: { 3075: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 3076: struct hfi_context_pointers_cmd cmd = {0}; 3077: struct adreno_context *drawctxt = ADRENO_CONTEXT(context); 3078: struct kgsl_process_private *proc_priv = drawctxt->base.proc_priv; 3079: struct kgsl_memdesc md = proc_priv->profile.md; 3080: int ret; 3081: 3082: ret = CMD_MSG_HDR(cmd, H2F_MSG_CONTEXT_POINTERS); 3083: if (ret) 3084: return ret; 3085: 3086: cmd.ctxt_id = context->id; 3087: cmd.sop_addr = MEMSTORE_ID_GPU_ADDR(device, context->id, soptimestamp); 3088: cmd.eop_addr = MEMSTORE_ID_GPU_ADDR(device, context->id, eoptimestamp); 3089: cmd.version = 1; 3090: cmd.dcvs_profile_addr = GMU_BUF_ADDR(md); 3091: if (context->user_ctxt_record) 3092: cmd.user_ctxt_record_addr = 3093: context->user_ctxt_record->memdesc.gpuaddr; 3094: 3095: cmd.gmu_context_queue_addr = drawctxt->gmu_context_queue.gmuaddr; 3096: 3097: return gen8_hfi_send_cmd_async(adreno_dev, &cmd, sizeof(cmd)); 3098: } 3099: 3100: static int hfi_context_register(struct adreno_device *adreno_dev, 3101: struct kgsl_context *context) 3102: { 3103: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 3104: struct adreno_context *drawctxt = ADRENO_CONTEXT(context); 3105: struct kgsl_process_private *proc_priv = drawctxt->base.proc_priv; 3106: int ret; 3107: 3108: if (context->gmu_registered) 3109: return 0; 3110: 3111: ret = send_context_register(adreno_dev, context); 3112: if (ret) { 3113: dev_err(GMU_PDEV_DEV(device), 3114: "Unable to register context %u: %d\n", 3115: context->id, ret); 3116: 3117: if (device->gmu_fault) 3118: gen8_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 3119: 3120: return ret; 3121: } 3122: 3123: /* Register DCVS profile after SLUMBER if UMD profile present */ 3124: if ((adreno_dev->dcvs_profile_enabled) && 3125: (proc_priv->profile.user_profile_registered) && 3126: (proc_priv->profile.gmu_registered)) 3127: gen8_hwsched_set_dcvs_profile(adreno_dev, proc_priv); 3128: 3129: ret = send_context_pointers(adreno_dev, context); 3130: if (ret) { 3131: dev_err(GMU_PDEV_DEV(device), 3132: "Unable to register context %u pointers: %d\n", 3133: context->id, ret); 3134: 3135: if (device->gmu_fault) 3136: gen8_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 3137: 3138: return ret; 3139: } 3140: 3141: context->gmu_registered = true; 3142: context->gmu_dispatch_queue = UINT_MAX; 3143: 3144: if ((!device->host_based_dcvs) && 3145: (context->pwr_constraint.type) && 3146: (context->flags & KGSL_CONTEXT_PWR_CONSTRAINT)) 3147: gen8_hwsched_set_pwrconstraint(adreno_dev, context->id); 3148: 3149: return 0; 3150: } 3151: 3152: static void populate_ibs(struct adreno_device *adreno_dev, 3153: struct hfi_submit_cmd *cmd, struct kgsl_drawobj_cmd *cmdobj) 3154: { 3155: struct hfi_issue_ib *issue_ib; 3156: struct kgsl_memobj_node *ib; 3157: 3158: if (cmdobj->numibs > HWSCHED_MAX_DISPATCH_NUMIBS) { 3159: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev); 3160: struct kgsl_memdesc *big_ib; 3161: 3162: if (test_bit(CMDOBJ_RECURRING_START, &cmdobj->priv)) 3163: big_ib = hfi->big_ib_recurring; 3164: else 3165: big_ib = hfi->big_ib; 3166: /* 3167: * The dispatcher ensures that there is only one big IB inflight 3168: */ 3169: cmd->big_ib_gmu_va = big_ib->gmuaddr; 3170: cmd->flags |= CMDBATCH_INDIRECT; 3171: issue_ib = big_ib->hostptr; 3172: } else { 3173: issue_ib = (struct hfi_issue_ib *)&cmd[1]; 3174: } 3175: 3176: list_for_each_entry(ib, &cmdobj->cmdlist, node) { 3177: issue_ib->addr = ib->gpuaddr; 3178: issue_ib->size = ib->size; 3179: issue_ib++; 3180: } 3181: 3182: cmd->numibs = cmdobj->numibs; 3183: } 3184: 3185: #define HFI_DSP_IRQ_BASE 2 3186: 3187: #define DISPQ_IRQ_BIT(_idx) BIT((_idx) + HFI_DSP_IRQ_BASE) 3188: #define DISPQ_SYNC_IRQ_BIT(_idx) ((DISPQ_IRQ_BIT(_idx) << (KGSL_PRIORITY_MAX_RB_LEVELS + 1))) 3189: 3190: 3191: static u32 get_irq_bit(struct adreno_device *adreno_dev, struct kgsl_context *context) 3192: { 3193: if (adreno_is_preemption_enabled(adreno_dev)) 3194: return adreno_get_level(context); 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: } 3332: 3333: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 3334: } 3335: spin_unlock(&drawctxt->lock); 3336: 3337: return ret; 3338: } 3339: 3340: /** 3341: * move_detached_context_hardware_fences - Move all pending hardware fences belonging to this 3342: * context to the detached hardware fence list so as to send them to TxQueue after fault recovery. 3343: * This is needed because this context may get destroyed before fault recovery gets executed. 3344: */ 3345: static void move_detached_context_hardware_fences(struct adreno_device *adreno_dev, 3346: struct adreno_context *drawctxt) 3347: { 3348: struct adreno_hw_fence_entry *entry, *tmp; 3349: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev); 3350: 3351: spin_lock(&drawctxt->lock); 3352: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_inflight_list, node) { 3353: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr; 3354: 3355: if ((timestamp_cmp((u32)entry->cmd.ts, hdr->out_fence_ts) > 0)) { 3356: _kgsl_context_get(&drawctxt->base); 3357: list_move_tail(&entry->node, &hfi->detached_hw_fence_list); 3358: continue; 3359: } 3360: 3361: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 3362: } 3363: 3364: spin_unlock(&drawctxt->lock); 3365: 3366: /* Also grab all the hardware fences which were never sent to GMU */ 3367: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_list, node) { 3368: _kgsl_context_get(&drawctxt->base); 3369: list_move_tail(&entry->node, &hfi->detached_hw_fence_list); 3370: } 3371: } 3372: 3373: static int drain_context_hw_fence_gmu(struct adreno_device *adreno_dev, 3374: struct adreno_context *drawctxt) 3375: { 3376: struct adreno_hw_fence_entry *entry, *tmp; 3377: int ret = 0; 3378: 3379: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_list, node) { 3380: 3381: ret = gen8_send_hw_fence_hfi_wait_ack(adreno_dev, entry, 3382: HW_FENCE_FLAG_SKIP_MEMSTORE); 3383: if (ret) 3384: break; 3385: 3386: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 3387: } 3388: 3389: if (ret) { 3390: move_detached_context_hardware_fences(adreno_dev, drawctxt); 3391: gmu_core_fault_snapshot(KGSL_DEVICE(adreno_dev), GMU_FAULT_HW_FENCE); 3392: gen8_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 3393: } 3394: 3395: return ret; 3396: } 3397: 3398: /** 3399: * check_detached_context_hardware_fences - When this context has been un-registered with the GMU, 3400: * make sure all the hardware fences(that were sent to GMU) for this context have been sent to 3401: * TxQueue. Also, send any hardware fences (to GMU) that were not yet dispatched to the GMU. In case 3402: * of an error, move the pending hardware fences to detached hardware fence list, log the error, 3403: * take a snapshot and trigger recovery. 3404: */ 3405: static int check_detached_context_hardware_fences(struct adreno_device *adreno_dev, 3406: struct adreno_context *drawctxt) 3407: { 3408: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 3409: struct adreno_hw_fence_entry *entry, *tmp; 3410: int ret = 0; 3411: u32 id, ts, fence_ts; 3412: 3413: spin_lock(&drawctxt->lock); 3414: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_inflight_list, node) { 3415: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr; 3416: 3417: if ((timestamp_cmp((u32)entry->cmd.ts, hdr->out_fence_ts) > 0)) { 3418: id = drawctxt->base.id; 3419: ts = (u32)entry->cmd.ts; 3420: fence_ts = hdr->out_fence_ts; 3421: spin_unlock(&drawctxt->lock); 3422: 3423: dev_err(GMU_PDEV_DEV(device), 3424: "detached ctx:%d has unsignaled fence ts:%d retired:%d\n", 3425: id, ts, fence_ts); 3426: ret = -EINVAL; 3427: goto fault; 3428: } 3429: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 3430: } 3431: 3432: spin_unlock(&drawctxt->lock); 3433: /* Send hardware fences (to TxQueue) that were not dispatched to GMU */ 3434: return drain_context_hw_fence_gmu(adreno_dev, drawctxt); 3435: 3436: fault: 3437: move_detached_context_hardware_fences(adreno_dev, drawctxt); 3438: gmu_core_fault_snapshot(device, GMU_FAULT_HW_FENCE); 3439: gen8_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 3440: 3441: return ret; 3442: } 3443: 3444: static inline int setup_hw_fence_info_cmd(struct adreno_device *adreno_dev, 3445: struct adreno_hw_fence_entry *entry) 3446: { 3447: struct kgsl_sync_fence *kfence = entry->kfence; 3448: int ret; 3449: 3450: ret = CMD_MSG_HDR(entry->cmd, H2F_MSG_HW_FENCE_INFO); 3451: if (ret) 3452: return ret; 3453: 3454: ret = kgsl_hw_fence_create(KGSL_DEVICE(adreno_dev), kfence); 3455: if (ret) 3456: return ret; 3457: 3458: entry->cmd.gmu_ctxt_id = entry->drawctxt->base.id; 3459: entry->cmd.ctxt_id = kfence->fence.context; 3460: entry->cmd.ts = kfence->fence.seqno; 3461: 3462: entry->cmd.hash_index = kfence->hw_fence_index; 3463: 3464: return 0; 3465: } 3466: 3467: /* 3468: * gen8_send_hw_fence_hfi_wait_ack - This function is used in cases where multiple hardware fences 3469: * are to be sent to GMU. Hence, we must send them one by one to avoid overwhelming the GMU with 3470: * mutliple fences in a short span of time. 3471: */ 3472: int gen8_send_hw_fence_hfi_wait_ack(struct adreno_device *adreno_dev, 3473: struct adreno_hw_fence_entry *entry, u64 flags) 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: { 3530: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 3531: struct adreno_hw_fence_entry *entry; 3532: 3533: if (!kgsl_hw_fence_tx_slot_available(KGSL_DEVICE(adreno_dev), 3534: hwsched->hw_fence.pending_count)) 3535: return NULL; 3536: 3537: if (!DRAWCTXT_SLOT_AVAILABLE(drawctxt->hw_fence_count)) 3538: return NULL; 3539: 3540: if (!_kgsl_context_get(&drawctxt->base)) 3541: return NULL; 3542: 3543: entry = kmem_cache_zalloc(hwsched->hw_fence_cache, GFP_ATOMIC); 3544: if (!entry) { 3545: kgsl_context_put_deferred(&drawctxt->base); MATCH LINES: 3696, 3725 3684: /* If recovery is imminent, then do not create a hardware fence */ 3685: if (test_bit(GEN8_HWSCHED_HW_FENCE_ABORT_BIT, &hwf->flags)) 3686: goto done; 3687: 3688: ret = _hw_fence_sleep(adreno_dev, drawctxt); 3689: if (ret) 3690: goto done; 3691: 3692: /* 3693: * If this ts hasn't been submitted yet, then store it in the drawctxt hardware fence 3694: * list and return. This fence will be sent to GMU when this ts is dispatched to GMU. 3695: */ 3696: if (timestamp_cmp(kfence->timestamp, drawctxt->gmu_hw_fence_ready_ts) > 0) { 3697: drawctxt_queue_hw_fence(adreno_dev, drawctxt, kfence); 3698: goto done; 3699: } 3700: 3701: kgsl_readtimestamp(device, context, KGSL_TIMESTAMP_RETIRED, &retired); 3702: 3703: /* 3704: * Check if timestamp is retired. If we are in SLUMBER at this point, the timestamp is 3705: * guaranteed to be retired. This way, we don't need the device mutex to check the device 3706: * state explicitly. 3707: */ 3708: if (timestamp_cmp(retired, kfence->timestamp) >= 0) { 3709: kgsl_sync_timeline_signal(ktimeline, kfence->timestamp); 3710: goto done; 3711: } 3712: 3713: entry = allocate_hw_fence_entry(adreno_dev, drawctxt, kfence); 3714: if (!entry) 3715: goto done; 3716: 3717: /* 3718: * If timestamp is not retired then GMU must already be powered up. This is because SLUMBER 3719: * thread has to wait for hardware fence spinlock to make sure the hardware fence unack 3720: * count is zero. 3721: */ 3722: ret = _send_hw_fence_no_ack(adreno_dev, entry); 3723: if (ret) { 3724: if (__ratelimit(&_rs)) 3725: dev_err(GMU_PDEV_DEV(device), 3726: "hw fence for ctx:%d ts:%d ret:%d may not be destroyed\n", 3727: kfence->context_id, kfence->timestamp, ret); 3728: kgsl_hw_fence_destroy(kfence); 3729: destroy = true; 3730: drawctxt->hw_fence_last_ts = hw_fence_last_ts; 3731: goto done; 3732: } 3733: 3734: list_add_tail(&entry->node, &drawctxt->hw_fence_inflight_list); 3735: 3736: done: 3737: spin_unlock(&hwf->lock); 3738: if (destroy) 3739: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 3740: spin_unlock(&drawctxt->lock); 3741: } 3742: 3743: /** 3744: * setup_hw_fence_deferred_ctxt - The hardware fence(s) from this context couldn't be sent to the 3745: * GMU because the hardware fence unack count reached a threshold. Hence, setup this context such 3746: * that these hardware fences are sent to the GMU when the unack count drops to a desired threshold. 3747: */ 3748: static void setup_hw_fence_deferred_ctxt(struct adreno_device *adreno_dev, 3749: struct adreno_context *drawctxt, u32 ts) MATCH LINES: 3811, 3815, 3820, 3826, 3852, 3854, 3862, 3895, 3899, 3904, 3908, 3911, 3919, 3923, 3934, 3957, 3959, 3982, 3990, 3992 3799: * A fence that is sent to GMU must be added to the drawctxt->hw_fence_inflight_list 3800: * so that we can keep track of when GMU sends it to the TxQueue 3801: */ 3802: list_move_tail(&entry->node, &drawctxt->hw_fence_inflight_list); 3803: } 3804: } 3805: 3806: int gen8_hwsched_submit_drawobj(struct adreno_device *adreno_dev, struct kgsl_drawobj *drawobj) 3807: { 3808: int ret = 0; 3809: u32 cmd_sizebytes, seqnum; 3810: struct kgsl_drawobj_cmd *cmdobj = NULL; 3811: struct hfi_submit_cmd *cmd; 3812: struct adreno_submit_time time = {0}; 3813: struct adreno_context *drawctxt = ADRENO_CONTEXT(drawobj->context); 3814: static void *cmdbuf; 3815: struct gmu_context_queue_header *hdr = NULL; 3816: 3817: if (cmdbuf == NULL) { 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)) 3855: return -EMSGSIZE; 3856: 3857: memset(cmdbuf, 0x0, cmd_sizebytes); 3858: 3859: cmd = cmdbuf; 3860: 3861: cmd->ctxt_id = drawobj->context->id; 3862: cmd->flags = HFI_CTXT_FLAG_NOTIFY; 3863: if (drawobj->flags & KGSL_DRAWOBJ_END_OF_FRAME) 3864: cmd->flags |= CMDBATCH_EOF; 3865: 3866: cmd->ts = drawobj->timestamp; 3867: 3868: if (test_bit(CMDOBJ_SKIP, &cmdobj->priv)) 3869: goto skipib; 3870: 3871: populate_ibs(adreno_dev, cmd, cmdobj); 3872: 3873: if ((drawobj->flags & KGSL_DRAWOBJ_PROFILING) && 3874: cmdobj->profiling_buf_entry) { 3875: 3876: time.drawobj = drawobj; 3877: 3878: cmd->profile_gpuaddr_lo = 3879: lower_32_bits(cmdobj->profiling_buffer_gpuaddr); 3880: cmd->profile_gpuaddr_hi = 3881: upper_32_bits(cmdobj->profiling_buffer_gpuaddr); 3882: 3883: /* Indicate to GMU to do user profiling for this submission */ 3884: cmd->flags |= CMDBATCH_PROFILING; 3885: } 3886: 3887: if (test_and_clear_bit(CMDOBJ_NOP_SUBMISSION, &cmdobj->priv)) 3888: cmd->flags |= CMDBATCH_NOP_SUBMISSION; 3889: 3890: if (drawobj->flags & KGSL_DRAWOBJ_USES_MALU) 3891: cmd->flags |= CMDBATCH_USES_MALU; 3892: skipib: 3893: adreno_drawobj_set_constraint(KGSL_DEVICE(adreno_dev), drawobj); 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) 3931: { 3932: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 3933: struct kgsl_drawobj *drawobj = DRAWOBJ(cmdobj); 3934: struct hfi_submit_cmd *cmd; 3935: struct kgsl_memobj_node *ib; 3936: u32 cmd_sizebytes; 3937: int ret; 3938: static bool active; 3939: 3940: if (adreno_gpu_halt(adreno_dev) || adreno_gpu_fault(adreno_dev)) 3941: return -EBUSY; 3942: 3943: if (test_bit(CMDOBJ_RECURRING_STOP, &cmdobj->priv)) { 3944: cmdobj->numibs = 0; 3945: } else { 3946: list_for_each_entry(ib, &cmdobj->cmdlist, node) 3947: cmdobj->numibs++; 3948: } 3949: 3950: if (cmdobj->numibs > HWSCHED_MAX_IBS) 3951: return -EINVAL; 3952: 3953: if (cmdobj->numibs > HWSCHED_MAX_DISPATCH_NUMIBS) 3954: cmd_sizebytes = sizeof(*cmd); 3955: else 3956: cmd_sizebytes = sizeof(*cmd) + 3957: (sizeof(struct hfi_issue_ib) * cmdobj->numibs); 3958: 3959: if (WARN_ON(cmd_sizebytes > HFI_MAX_MSG_SIZE)) 3960: return -EMSGSIZE; 3961: 3962: cmd = kzalloc(cmd_sizebytes, GFP_KERNEL); 3963: if (cmd == NULL) 3964: return -ENOMEM; 3965: 3966: if (test_bit(CMDOBJ_RECURRING_START, &cmdobj->priv)) { 3967: if (!active) { 3968: ret = adreno_active_count_get(adreno_dev); 3969: if (ret) { 3970: kfree(cmd); 3971: return ret; 3972: } 3973: active = true; 3974: } 3975: cmd->flags |= CMDBATCH_RECURRING_START; 3976: populate_ibs(adreno_dev, cmd, cmdobj); 3977: } else 3978: cmd->flags |= CMDBATCH_RECURRING_STOP; 3979: 3980: cmd->ctxt_id = drawobj->context->id; 3981: 3982: ret = hfi_context_register(adreno_dev, drawobj->context); 3983: if (ret) { 3984: adreno_active_count_put(adreno_dev); 3985: active = false; 3986: kfree(cmd); 3987: return ret; 3988: } 3989: 3990: cmd->hdr = CREATE_MSG_HDR(H2F_MSG_ISSUE_RECURRING_CMD, HFI_MSG_CMD); 3991: 3992: ret = gen8_hfi_send_cmd_async(adreno_dev, cmd, sizeof(*cmd)); 3993: 3994: kfree(cmd); 3995: 3996: if (ret) { 3997: adreno_active_count_put(adreno_dev); 3998: active = false; 3999: return ret; 4000: } 4001: 4002: if (test_bit(CMDOBJ_RECURRING_STOP, &cmdobj->priv)) { 4003: adreno_hwsched_retire_cmdobj(hwsched, hwsched->recurring_cmdobj); 4004: kgsl_delete_timer_sync(&hwsched->lsr_timer); 4005: hwsched->recurring_cmdobj = NULL; 4006: if (active) 4007: adreno_active_count_put(adreno_dev); 4008: active = false; 4009: return ret; 4010: } 4011: 4012: hwsched->recurring_cmdobj = cmdobj; 4013: /* Star LSR timer for power stats collection */ 4014: mod_timer(&hwsched->lsr_timer, jiffies + msecs_to_jiffies(10)); 4015: return ret; 4016: } MATCH LINES: 4052, 4055, 4067, 4074, 4083, 4087, 4103, 4121, 4122, 4126, 4132, 4133, 4135, 4163, 4170 4040: /* 4041: * destroy_detached_context_inflight_hw_fences - Destroy context's hardware fences that were 4042: * dispatched to GMU 4043: */ 4044: static void destroy_detached_context_inflight_hw_fences(struct adreno_device *adreno_dev, 4045: struct adreno_context *drawctxt) 4046: { 4047: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 4048: struct adreno_hw_fence_entry *entry, *tmp; 4049: 4050: spin_lock(&drawctxt->lock); 4051: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_inflight_list, node) { 4052: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr; 4053: 4054: if ((timestamp_cmp((u32)entry->cmd.ts, hdr->out_fence_ts) > 0)) { 4055: dev_err_ratelimited(GMU_PDEV_DEV(device), 4056: "destroying detached ctx:%d unsignaled hw fence ts:%d retired:%d\n", 4057: drawctxt->base.id, (u32)entry->cmd.ts, hdr->out_fence_ts); 4058: } 4059: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 4060: } 4061: spin_unlock(&drawctxt->lock); 4062: } 4063: 4064: static void drain_context_hw_fences(struct adreno_device *adreno_dev, 4065: struct adreno_context *drawctxt) 4066: { 4067: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 4068: 4069: destroy_detached_context_inflight_hw_fences(adreno_dev, drawctxt); 4070: 4071: if (list_empty(&drawctxt->hw_fence_list)) 4072: return; 4073: 4074: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 4075: drain_context_hw_fence_gmu(adreno_dev, drawctxt); 4076: else 4077: drain_context_hw_fence_cpu(adreno_dev, drawctxt); 4078: } 4079: 4080: static void trigger_context_unregister_fault(struct adreno_device *adreno_dev, 4081: struct adreno_context *drawctxt) 4082: { 4083: gmu_core_fault_snapshot(KGSL_DEVICE(adreno_dev), GMU_FAULT_CTX_UNREGISTER); 4084: 4085: /* Make sure we send all fences from this context to the TxQueue after recovery */ 4086: move_detached_context_hardware_fences(adreno_dev, drawctxt); 4087: gen8_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 4088: } 4089: 4090: int gen8_hwsched_process_detached_hw_fences(struct adreno_device *adreno_dev) 4091: { 4092: struct adreno_hw_fence_entry *entry, *tmp; 4093: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev); 4094: struct kgsl_context *context = NULL; 4095: int ret = 0; 4096: 4097: list_for_each_entry_safe(entry, tmp, &hfi->detached_hw_fence_list, node) { 4098: 4099: /* 4100: * This is part of the reset sequence and any error in this path will be handled by 4101: * the caller. 4102: */ 4103: ret = gen8_send_hw_fence_hfi_wait_ack(adreno_dev, entry, 4104: HW_FENCE_FLAG_SKIP_MEMSTORE); 4105: if (ret) 4106: return ret; 4107: 4108: context = &entry->drawctxt->base; 4109: 4110: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 4111: 4112: kgsl_context_put(context); 4113: } 4114: 4115: return ret; 4116: } 4117: 4118: static int send_context_unregister_hfi(struct adreno_device *adreno_dev, 4119: struct kgsl_context *context, u32 ts) 4120: { 4121: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)); 4122: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 4123: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev); 4124: struct adreno_context *drawctxt = ADRENO_CONTEXT(context); 4125: struct pending_cmd pending_ack; 4126: struct hfi_unregister_ctxt_cmd cmd; 4127: struct kgsl_process_private *proc_priv = drawctxt->base.proc_priv; 4128: u32 seqnum; 4129: int ret; 4130: 4131: /* Only send HFI if device is not in SLUMBER */ 4132: if (!context->gmu_registered || 4133: !test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) { 4134: drain_context_hw_fences(adreno_dev, drawctxt); 4135: proc_priv->profile.gmu_registered = false; 4136: 4137: return 0; 4138: } 4139: 4140: ret = CMD_MSG_HDR(cmd, H2F_MSG_UNREGISTER_CONTEXT); 4141: if (ret) 4142: return ret; 4143: 4144: cmd.ctxt_id = context->id, 4145: cmd.ts = ts, 4146: 4147: /* 4148: * Although we know device is powered on, we can still enter SLUMBER 4149: * because the wait for ack below is done without holding the mutex. So 4150: * take an active count before releasing the mutex so as to avoid a 4151: * concurrent SLUMBER sequence while GMU is un-registering this context. 4152: */ 4153: ret = adreno_active_count_get(adreno_dev); 4154: if (ret) { 4155: trigger_context_unregister_fault(adreno_dev, drawctxt); 4156: return ret; 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; 4194: MATCH LINES: 4210, 4236, 4237, 4239, 4240, 4246, 4249, 4285, 4296, 4297, 4303, 4306 4198: drawctxt->internal_timestamp); 4199: 4200: if (ret) 4201: goto out; 4202: 4203: kgsl_sharedmem_writel(device->memstore, 4204: KGSL_MEMSTORE_OFFSET(context->id, soptimestamp), drawctxt->timestamp); 4205: 4206: kgsl_sharedmem_writel(device->memstore, 4207: KGSL_MEMSTORE_OFFSET(context->id, eoptimestamp), drawctxt->timestamp); 4208: 4209: adreno_profile_process_results(adreno_dev); 4210: context->gmu_registered = false; 4211: 4212: out: 4213: WARN_RATELIMIT(!list_empty(&drawctxt->hw_fence_list) || 4214: !list_empty(&drawctxt->hw_fence_inflight_list), 4215: "detached ctx:%u has active hw fences\n", 4216: context->id); 4217: 4218: kgsl_mutex_unlock(&device->mutex); 4219: } 4220: 4221: static int handle_hw_fences_after_soft_reset(struct adreno_device *adreno_dev, 4222: struct adreno_context *drawctxt) 4223: { 4224: int ret = 0; 4225: 4226: if (!drawctxt) 4227: return ret; 4228: 4229: ret = gen8_hwsched_process_detached_hw_fences(adreno_dev); 4230: if (ret) 4231: return ret; 4232: 4233: return gen8_hwsched_disable_hw_fence_throttle(adreno_dev); 4234: } 4235: 4236: static int gen8_hwsched_hfi_msg_reply(struct adreno_device *adreno_dev, 4237: enum hfi_msg_type msg, u32 hdr) 4238: { 4239: struct hfi_msg_ret_cmd out = {0}; 4240: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 4241: u32 seqnum; 4242: 4243: out.hdr = ACK_MSG_HDR(msg); 4244: seqnum = atomic_inc_return(&gmu->hfi.seqnum); 4245: out.hdr = MSG_HDR_SET_SEQNUM_SIZE(out.hdr, seqnum, sizeof(out) >> 2); 4246: out.error = GMU_SUCCESS; 4247: out.req_hdr = hdr; 4248: 4249: return gen8_hfi_cmdq_write(adreno_dev, (u32 *)&out, sizeof(out)); 4250: } 4251: 4252: static void _do_gbif_halt(struct kgsl_device *device, u32 reg, u32 ack_reg, 4253: u32 mask, u32 ack_mask, const char *client) 4254: { 4255: u32 ack; 4256: unsigned long t; 4257: 4258: kgsl_regwrite(device, reg, mask); 4259: 4260: t = jiffies + msecs_to_jiffies(100); 4261: do { 4262: kgsl_regread(device, ack_reg, &ack); 4263: if ((ack & ack_mask) == ack_mask) 4264: return; 4265: usleep_range(10, 100); 4266: } while (!time_after(jiffies, t)); 4267: 4268: kgsl_regread(device, ack_reg, &ack); 4269: if ((ack & ack_mask) == ack_mask) 4270: return; 4271: 4272: dev_err(device->dev, "%s GBIF halt timed out\n", client); 4273: } 4274: 4275: static void gen8_hwsched_raise_dispatch_interrupt(struct adreno_device *adreno_dev) 4276: { 4277: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 4278: struct cmd_list_obj *obj, *tmp; 4279: 4280: list_for_each_entry_safe(obj, tmp, &hwsched->cmd_list, node) { 4281: struct kgsl_drawobj *drawobj = obj->drawobj; 4282: 4283: /* Raise dispatch interrupt for inflight commands */ 4284: if (adreno_hwsched_drawobj_replay(adreno_dev, drawobj)) 4285: gmu_core_regwrite(KGSL_DEVICE(adreno_dev), GEN8_GMUCX_HOST2GMU_INTR_SET, 4286: DISPQ_IRQ_BIT(get_irq_bit(adreno_dev, drawobj->context))); 4287: else 4288: adreno_hwsched_retire_cmdlist_obj(adreno_dev, obj); 4289: } 4290: } 4291: 4292: int gen8_hwsched_soft_reset(struct adreno_device *adreno_dev, 4293: struct kgsl_context *context, bool ctx_guilty) 4294: { 4295: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 4296: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 4297: struct hfi_context_bad_cmd *in = (struct hfi_context_bad_cmd *)adreno_dev->hwsched.ctxt_bad; 4298: int ret; 4299: 4300: if (!test_bit(ADRENO_HWSCHED_GPU_SOFT_RESET, &adreno_dev->hwsched.flags)) 4301: return -EOPNOTSUPP; 4302: 4303: if (adreno_dev->hwsched.reset_type != GMU_GPU_SOFT_RESET) 4304: return -EINVAL; 4305: 4306: if (!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 4307: return 0; 4308: 4309: gen8_disable_gpu_irq(adreno_dev); 4310: 4311: /* Halt GX traffic */ 4312: if (adreno_is_gen8_11_x(adreno_dev)) { 4313: /* 4314: * On gen8_11_x targets, RBBM_GBIF_HALT_ACK may be prematurely set. Use the updated 4315: * GX halt / acknowledgment sequence per recommendation. 4316: */ 4317: _do_gbif_halt(device, GEN8_RBBM_GBIF_GX_DBG_HALT_CTRL, 4318: GEN8_RBBM_GBIF_GX_DBG_HALT_STATUS, GEN8_GBIF_GX_HALT_CTRL_MASK, 4319: GEN8_GBIF_GX_HALT_STATUS_MASK, "GX"); 4320: } else { 4321: _do_gbif_halt(device, GEN8_RBBM_GBIF_HALT, GEN8_RBBM_GBIF_HALT_ACK, 4322: GEN8_GBIF_GX_HALT_MASK, GEN8_GBIF_GX_HALT_ACK_MASK, "GX"); 4323: } 4324: 4325: kgsl_regwrite(device, GEN8_RBBM_SW_RESET_CMD, 0x1); 4326: 4327: /* Make sure above writes are posted */ 4328: wmb(); 4329: 4330: /* Allow the software reset to complete */ MATCH LINES: 4349, 4354, 4391, 4415, 4423, 4431, 4432, 4434, 4435, 4461, 4477, 4478, 4479, 4484, 4491, 4492, 4494, 4496 4337: memset(&adreno_dev->busy_data, 0, sizeof(adreno_dev->busy_data)); 4338: 4339: gen8_start(adreno_dev); 4340: 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); 4378: if (ret) 4379: goto done; 4380: 4381: kgsl_sharedmem_writel(device->memstore, 4382: KGSL_MEMSTORE_OFFSET(context->id, soptimestamp), 4383: drawctxt->timestamp); 4384: 4385: kgsl_sharedmem_writel(device->memstore, 4386: KGSL_MEMSTORE_OFFSET(context->id, eoptimestamp), 4387: drawctxt->timestamp); 4388: 4389: adreno_profile_process_results(adreno_dev); 4390: 4391: context->gmu_registered = false; 4392: } 4393: 4394: /* 4395: * At this point it is safe to assume that we recovered. Setting 4396: * this field allows us to take a new snapshot for the next failure 4397: * if we are prioritizing the first unrecoverable snapshot. 4398: */ 4399: if (device->snapshot) 4400: device->snapshot->recovered = true; 4401: 4402: device->reset_counter++; 4403: done: 4404: if (ret) 4405: dev_err(device->dev, "GPU soft reset failed: %d\n", ret); 4406: 4407: return ret; 4408: } 4409: 4410: u32 gen8_hwsched_preempt_count_get(struct adreno_device *adreno_dev) 4411: { 4412: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 4413: int ret, preempt_count = 0; 4414: 4415: ret = gmu_core_get_vrb_register(device->gmu_core.vrb, 4416: VRB_PREEMPT_COUNT_TOTAL, &preempt_count); 4417: if (ret) 4418: return 0; 4419: 4420: if ((preempt_count != 0) || (device->state != KGSL_STATE_ACTIVE)) 4421: return preempt_count; 4422: 4423: return gen8_hwsched_hfi_get_value(adreno_dev, HFI_VALUE_PREEMPT_COUNT, 0); 4424: } 4425: 4426: void gen8_hwsched_context_destroy(struct adreno_device *adreno_dev, 4427: struct adreno_context *drawctxt) 4428: { 4429: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 4430: 4431: if (drawctxt->gmu_context_queue.gmuaddr) 4432: gmu_core_free_block(device, &drawctxt->gmu_context_queue); 4433: 4434: if (drawctxt->gmu_hw_fence_queue.gmuaddr) 4435: gmu_core_free_block(device, &drawctxt->gmu_hw_fence_queue); 4436: } 4437: 4438: int gen8_hwsched_disable_hw_fence_throttle(struct adreno_device *adreno_dev) 4439: { 4440: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 4441: struct adreno_context *drawctxt = NULL; 4442: u32 ts = 0; 4443: int ret = 0; 4444: 4445: if (!test_bit(ADRENO_HWSCHED_HW_FENCE, &adreno_dev->hwsched.flags)) 4446: return 0; 4447: 4448: spin_lock(&hwf->lock); 4449: 4450: drawctxt = hwf->defer_drawctxt; 4451: ts = hwf->defer_ts; 4452: 4453: spin_unlock(&hwf->lock); 4454: 4455: if (!drawctxt) 4456: goto done; 4457: 4458: ret = process_hw_fence_deferred_ctxt(adreno_dev, drawctxt, ts); 4459: if (ret) { 4460: /* the deferred drawctxt will be handled post fault recovery */ 4461: gen8_hwsched_fault(adreno_dev, GMU_FAULT_HW_FENCE); 4462: return ret; 4463: } 4464: 4465: kgsl_context_put(&drawctxt->base); 4466: adreno_active_count_put(adreno_dev); 4467: 4468: done: 4469: _disable_hw_fence_throttle(adreno_dev, true); 4470: 4471: return ret; 4472: } 4473: 4474: int gen8_hwsched_set_dcvs_profile(struct adreno_device *adreno_dev, 4475: struct kgsl_process_private *proc_priv) 4476: { 4477: struct hfi_profile_register cmd = {0}; 4478: struct hfi_msg_platform msg = {0}; 4479: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 4480: struct kgsl_memdesc md = proc_priv->profile.md; 4481: int ret; 4482: 4483: /* Only send HFI if device is not in SLUMBER */ 4484: if (!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 4485: return 0; 4486: 4487: msg.sub_type = H2F_ST_MSG_PROFILE_REGISTER; 4488: CMD_MSG_HDR(msg, H2F_MSG_PLATFORM_LA); 4489: cmd.header = msg; 4490: cmd.version = 2; 4491: cmd.gmu_addr = GMU_BUF_ADDR(md); 4492: cmd.attrs_addr = md.gmuaddr; 4493: 4494: ret = gen8_hfi_send_cmd_async(adreno_dev, &cmd, sizeof(cmd)); 4495: if (!ret) { 4496: proc_priv->profile.gmu_registered = true; 4497: proc_priv->profile.user_profile_registered = true; 4498: } 4499: 4500: return ret; 4501: } --- FILE: \adreno_gen8_hwsched_hfi.h | HITS: 37 --- MATCH LINES: 7, 8, 12, 13, 43, 54, 63, 79, 81, 85, 91, 129, 134, 137, 140, 143, 151, 154, 161, 164, 169, 183, 193 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) 2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #ifndef _ADRENO_GEN8_HWSCHED_HFI_H_ 8: #define _ADRENO_GEN8_HWSCHED_HFI_H_ 9: 10: /* Maximum number of IBs in a submission */ 11: #define HWSCHED_MAX_NUMIBS \ 12: ((HFI_MAX_MSG_SIZE - offsetof(struct hfi_issue_cmd_cmd, ibs)) \ 13: / sizeof(struct hfi_issue_ib)) 14: 15: /* 16: * This is used to put userspace threads to sleep when hardware fence unack count reaches a 17: * threshold. This bit is cleared in two scenarios: 18: * 1. If the hardware fence unack count drops to a desired threshold. 19: * 2. If there is a GMU/GPU fault. Because we don't want the threads to keep sleeping through fault 20: * recovery, which can easily take 100s of milliseconds to complete. 21: */ 22: #define GEN8_HWSCHED_HW_FENCE_SLEEP_BIT 0x0 23: 24: /* 25: * This is used to avoid creating any more hardware fences until the hardware fence unack count 26: * drops to a desired threshold. This bit is required in cases where GEN8_HWSCHED_HW_FENCE_SLEEP_BIT 27: * will be cleared, but we still want to avoid creating any more hardware fences. For example, if 28: * hardware fence unack count reaches a maximum threshold, both GEN8_HWSCHED_HW_FENCE_SLEEP_BIT and 29: * GEN8_HWSCHED_HW_FENCE_MAX_BIT will be set. Say, a GMU/GPU fault happens and 30: * GEN8_HWSCHED_HW_FENCE_SLEEP_BIT will be cleared to wake up any sleeping threads. But, 31: * GEN8_HWSCHED_HW_FENCE_MAX_BIT will remain set to avoid creating any new hardware fences until 32: * recovery is complete and deferred drawctxt (if any) is handled. 33: */ 34: #define GEN8_HWSCHED_HW_FENCE_MAX_BIT 0x1 35: 36: /* 37: * This is used to avoid creating any more hardware fences until concurrent reset/recovery completes 38: * or when soccp vote fails 39: */ 40: #define GEN8_HWSCHED_HW_FENCE_ABORT_BIT 0x2 41: 42: #define MAX_THROTTLE_LVLS 3 43: struct hfi_tsens_cfg { 44: /** @limit_u: deci-C value for upper trigger point */ 45: u32 limit_u; 46: /** @limit_l: deci-C value for lower trigger point */ 47: u32 limit_l; 48: /** @margin_u: deci-C value for upper trigger intercept margin */ 49: u32 margin_u; 50: /** @margin_l: deci-C value for lower trigger intercept margin */ 51: u32 margin_l; 52: } __packed; 53: 54: struct hfi_tsens_throttle_param { 55: /** @throttle_hyst: Microsecond wait between each throttle level */ 56: u32 throttle_hyst; 57: /** @num_throttle_cnt: Number of entries in throttle_levels */ 58: u32 num_throttle_cnt; 59: /** @throttle_lvls: Percent of original clock to throttle per level */ 60: u32 throttle_lvls[MAX_THROTTLE_LVLS]; 61: } __packed; 62: 63: struct hfi_therm_profile_ctrl { 64: /** @feature_en: Feature enable status */ 65: u16 feature_en; 66: /** @feature_rev: Feature revision */ 67: u16 feature_rev; 68: /** @tsens_en: tsens sensor enable status */ 69: u32 tsens_en; 70: /** @tj_limit: deci-C value for tj limit */ 71: u32 tj_limit; 72: /** @tskin_addr: unused */ 73: u32 tskin_addr; 74: /** @tskin_limit: unused */ 75: u32 tskin_limit; 76: /** @tsens_cfg_cnt: Count of tsens configuration structs */ 77: u32 tsens_cfg_cnt; 78: /** @tsens_cfg: Struct of tsens configurations */ 79: struct hfi_tsens_cfg tsens_cfg; 80: /** @throttle_cfg: Struct of throttle configurations */ 81: struct hfi_tsens_throttle_param throttle_cfg; 82: } __packed; 83: 84: /* H2F */ 85: struct hfi_thermaltable_cmd { 86: /** @hdr: HFI header message */ 87: u32 hdr; 88: /** @version: Version identifier for the format used for domains */ 89: u32 version; 90: /** @ctrl: Thermal profile control information */ 91: struct hfi_therm_profile_ctrl ctrl; 92: } __packed; 93: 94: struct gen8_hwsched_hfi { 95: /** @irq_mask: Store the hfi interrupt mask */ 96: u32 irq_mask; 97: /** @msglock: To protect the list of un-ACKed hfi packets */ 98: rwlock_t msglock; 99: /** @msglist: List of un-ACKed hfi packets */ 100: struct list_head msglist; 101: /** @f2h_task: Task for processing gmu fw to host packets */ 102: struct task_struct *f2h_task; 103: /** @f2h_wq: Waitqueue for the f2h_task */ 104: wait_queue_head_t f2h_wq; 105: /** @big_ib: GMU buffer to hold big IBs */ 106: struct kgsl_memdesc *big_ib; 107: /** @big_ib_recurring: GMU buffer to hold big recurring IBs */ 108: struct kgsl_memdesc *big_ib_recurring; 109: /** @msg_mutex: Mutex for accessing the msgq */ 110: struct mutex msgq_mutex; 111: /** 112: * @hw_fence_timer: Timer to trigger fault if unack'd hardware fence count does'nt drop 113: * to a desired threshold in given amount of time 114: */ 115: struct timer_list hw_fence_timer; 116: /** 117: * @hw_fence_ws: Work struct that gets scheduled when hw_fence_timer expires 118: */ 119: struct work_struct hw_fence_ws; 120: /** @detached_hw_fences_list: List of hardware fences belonging to detached contexts */ 121: struct list_head detached_hw_fence_list; 122: /** @defer_hw_fence_work: The work structure to send deferred hardware fences to GMU */ 123: struct kthread_work defer_hw_fence_work; 124: }; 125: 126: struct kgsl_drawobj_cmd; 127: 128: /** 129: * gen8_hwsched_hfi_probe - Probe hwsched hfi resources 130: * @adreno_dev: Pointer to adreno device structure 131: * 132: * Return: 0 on success and negative error on failure. 133: */ 134: int gen8_hwsched_hfi_probe(struct adreno_device *adreno_dev); 135: 136: /** 137: * gen8_hwsched_hfi_remove - Release hwsched hfi resources 138: * @adreno_dev: Pointer to adreno device structure 139: */ 140: void gen8_hwsched_hfi_remove(struct adreno_device *adreno_dev); 141: 142: /** 143: * gen8_hwsched_hfi_init - Initialize hfi resources 144: * @adreno_dev: Pointer to adreno device structure 145: * 146: * This function is used to initialize hfi resources 147: * once before the very first gmu boot 148: * 149: * Return: 0 on success and negative error on failure. 150: */ 151: int gen8_hwsched_hfi_init(struct adreno_device *adreno_dev); 152: 153: /** 154: * gen8_hwsched_hfi_start - Start hfi resources 155: * @adreno_dev: Pointer to adreno device structure 156: * 157: * Send the various hfi packets before booting the gpu 158: * 159: * Return: 0 on success and negative error on failure. 160: */ 161: int gen8_hwsched_hfi_start(struct adreno_device *adreno_dev); 162: 163: /** 164: * gen8_hwsched_hfi_stop - Stop the hfi resources 165: * @adreno_dev: Pointer to the adreno device 166: * 167: * This function does the hfi cleanup when powering down the gmu 168: */ 169: void gen8_hwsched_hfi_stop(struct adreno_device *adreno_dev); 170: 171: /** 172: * gen8_hwched_cp_init - Send CP_INIT via HFI 173: * @adreno_dev: Pointer to adreno device structure 174: * 175: * This function is used to send CP INIT packet and bring 176: * GPU out of secure mode using hfi raw packets. 177: * 178: * Return: 0 on success and negative error on failure. 179: */ 180: int gen8_hwsched_cp_init(struct adreno_device *adreno_dev); 181: 182: /** 183: * gen8_hfi_send_cmd_async - Send an hfi packet 184: * @adreno_dev: Pointer to adreno device structure 185: * @data: Data to be sent in the hfi packet 186: * @size_bytes: Size of the packet in bytes 187: * 188: * Send data in the form of an HFI packet to gmu and wait for 189: * it's ack asynchronously 190: * 191: * Return: 0 on success and negative error on failure. 192: */ 193: int gen8_hfi_send_cmd_async(struct adreno_device *adreno_dev, void *data, u32 size_bytes); 194: 195: /** 196: * gen8_hwsched_submit_drawobj - Dispatch IBs to dispatch queues 197: * @adreno_dev: Pointer to adreno device structure 198: * @drawobj: The command draw object which needs to be submitted 199: * 200: * This function is used to register the context if needed and submit 201: * IBs to the hfi dispatch queues. 202: 203: * Return: 0 on success and negative error on failure 204: */ 205: int gen8_hwsched_submit_drawobj(struct adreno_device *adreno_dev, 206: struct kgsl_drawobj *drawobj); 207: 208: /** 209: * gen8_hwsched_context_detach - Unregister a context with GMU 210: * @drawctxt: Pointer to the adreno context 211: * 212: * This function sends context unregister HFI and waits for the ack 213: * to ensure all submissions from this context have retired 214: */ 215: void gen8_hwsched_context_detach(struct adreno_context *drawctxt); 216: 217: /** MATCH LINES: 254, 259, 272, 281, 284, 294, 297, 306 242: /** 243: * gen8_hwsched_lpac_cp_init - Send CP_INIT to LPAC via HFI 244: * @adreno_dev: Pointer to adreno device structure 245: * 246: * This function is used to send CP INIT packet to LPAC and 247: * enable submission to LPAC queue. 248: * 249: * Return: 0 on success and negative error on failure. 250: */ 251: int gen8_hwsched_lpac_cp_init(struct adreno_device *adreno_dev); 252: 253: /** 254: * gen8_hfi_send_lpac_feature_ctrl - Send the lpac feature hfi packet 255: * @adreno_dev: Pointer to the adreno device 256: * 257: * Return: 0 on success or negative error on failure 258: */ 259: int gen8_hfi_send_lpac_feature_ctrl(struct adreno_device *adreno_dev); 260: 261: /** 262: * gen8_hwsched_context_destroy - Destroy any hwsched related resources during context destruction 263: * @adreno_dev: Pointer to adreno device 264: * @drawctxt: Pointer to the adreno context 265: * 266: * This functions destroys any hwsched related resources when this context is destroyed 267: */ 268: void gen8_hwsched_context_destroy(struct adreno_device *adreno_dev, 269: struct adreno_context *drawctxt); 270: 271: /** 272: * gen8_hwsched_hfi_get_value - Send GET_VALUE packet to GMU to get the value of a property 273: * @adreno_dev: Pointer to adreno device 274: * @prop: property to get from GMU 275: * @subtype: subtype to get from GMU 276: * 277: * This functions sends GET_VALUE HFI packet to query value of a property 278: * 279: * Return: On success, return the value in the GMU response. On failure, return 0 280: */ 281: u32 gen8_hwsched_hfi_get_value(struct adreno_device *adreno_dev, u32 prop, u32 subtype); 282: 283: /** 284: * gen8_hwsched_hfi_set_value - Send SET_VALUE packet to GMU to set the value of a property 285: * @adreno_dev: Pointer to adreno device 286: * @type: Type of the property to set 287: * @subtype: Sub type of the property to set 288: * @data: Value to be set to the property 289: * 290: * This functions sends SET_VALUE HFI packet to set value of a property 291: * 292: * Return: On success, return 0. On failure, return error code 293: */ 294: int gen8_hwsched_hfi_set_value(struct adreno_device *adreno_dev, u32 type, u32 subtype, u32 data); 295: 296: /** 297: * gen8_send_hw_fence_hfi_wait_ack - Send hardware fence info to GMU 298: * @adreno_dev: Pointer to adreno device 299: * @entry: Pointer to the adreno hardware fence entry 300: * @flags: Flags for this hardware fence 301: * 302: * Send the hardware fence info to the GMU and wait for the ack 303: * 304: * Return: 0 on success or negative error on failure 305: */ 306: int gen8_send_hw_fence_hfi_wait_ack(struct adreno_device *adreno_dev, 307: struct adreno_hw_fence_entry *entry, u64 flags); 308: 309: /** 310: * gen8_hwsched_create_hw_fence - Create a hardware fence 311: * @adreno_dev: Pointer to adreno device 312: * @kfence: Pointer to the kgsl fence 313: * 314: * Create a hardware fence, set up hardware fence info and send it to GMU if required 315: */ 316: void gen8_hwsched_create_hw_fence(struct adreno_device *adreno_dev, 317: struct kgsl_sync_fence *kfence); 318: 319: /** 320: * gen8_hwsched_process_detached_hw_fences - Send fences that couldn't be sent to GMU when a context 321: * got detached. We must wait for ack when sending each of these fences to GMU so as to avoid 322: * sending a large number of hardware fences in a short span of time. 323: * @adreno_dev: Pointer to adreno device 324: * 325: * Return: Zero on success or negative error on failure 326: * 327: */ 328: int gen8_hwsched_process_detached_hw_fences(struct adreno_device *adreno_dev); 329: 330: /** MATCH LINES: 375, 384, 412, 414, 418, 420 363: /** 364: * gen8_hwsched_boot_gpu - Send the command to boot GPU 365: * @adreno_dev: Pointer to adreno device 366: * 367: * Send the hfi to boot GPU, and check the ack, incase of a failure 368: * get a snapshot and capture registers of interest. 369: * 370: * Return: Zero on success or negative error on failure 371: */ 372: int gen8_hwsched_boot_gpu(struct adreno_device *adreno_dev); 373: 374: /** 375: * gen8_hwsched_set_gmu_based_dcvs_value - Set value for GMU based DCVS 376: * @adreno_dev: pointer to the adreno device 377: * @type: Type of HFI for set value 378: * @subtype: Sub type of HFI 379: * @val: Value to set 380: * @default_vote: True if this is a bootup default vote 381: * 382: * Return: Zero on success or negative error on failure 383: */ 384: int gen8_hwsched_set_gmu_based_dcvs_value(struct adreno_device *adreno_dev, u32 type, 385: u32 subtype, u32 val, bool default_vote); 386: 387: /** 388: * gen8_hwsched_set_dcvs_profile - Set profile for GMU based DCVS 389: * @adreno_dev: Pointer to the adreno device 390: * @proc_priv: Pointer to process private 391: * 392: * This function sends PROFILE_REGISTER hfi to set DCVS profile to GMU, 393: * and wait for the ack 394: * 395: * Return: Zero on success or negative error on failure 396: */ 397: int gen8_hwsched_set_dcvs_profile(struct adreno_device *adreno_dev, 398: struct kgsl_process_private *proc_priv); 399: 400: /** 401: * gen8_hwsched_set_tuning_attrs - Set value for GMU based DCVS tunables 402: * @adreno_dev: pointer to the adreno device 403: * @type: Type of HFI for set value 404: * @subtype: Sub type of HFI 405: * @val: Value to set 406: * 407: */ 408: void gen8_hwsched_set_tuning_attrs(struct adreno_device *adreno_dev, u32 type, 409: u32 subtype, u32 val); 410: 411: /** 412: * gen8_hwsched_hfi_get_dcvs_tuning_attrs - Get values for GMU based DCVS tuning attrs 413: * @adreno_dev: pointer to the adreno device 414: * @subtype: subtype to get from GMU for HFI_VALUE_DCVS_TUNING_PARAM property 415: * @data: Pointer to the data array to store the values 416: * 417: * This functions sends GET_VALUE HFI packet to query dcvs tuning attrs values for 418: * HFI_VALUE_DCVS_TUNING_PARAM property. 419: */ 420: void gen8_hwsched_hfi_get_dcvs_tuning_attrs(struct adreno_device *adreno_dev, u32 subtype, 421: u32 *data); 422: 423: /** 424: * gen8_hwsched_process_f2h_platform_msg - Handle F2H platform message 425: * @adreno_dev: Pointer to the adreno device 426: * @rcvd: Pointer to the message payload 427: * 428: * This function processes the payload in the received F2H_MSG_PLATFORM_LA message and executes 429: * the corresponding subtype-specific action. 430: * 431: * Return: Zero on success or negative error on failure 432: */ 433: int gen8_hwsched_process_f2h_platform_msg(struct adreno_device *adreno_dev, u32 *rcvd); 434: #endif --- FILE: \adreno_gen8_perfcounter.c | HITS: 84 --- MATCH LINES: 206, 212, 224, 232, 244 194: return 0; 195: } 196: 197: static u64 gen8_counter_alwayson_read(struct adreno_device *adreno_dev, 198: const struct adreno_perfcount_group *group, u32 counter) 199: { 200: struct adreno_perfcount_register *reg = &group->regs[counter]; 201: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 202: 203: return gpudev->read_alwayson(adreno_dev) + reg->value; 204: } 205: 206: static void gen8_write_gmu_counter_enable(struct kgsl_device *device, 207: struct adreno_perfcount_register *reg, u32 bit, u32 countable) 208: { 209: kgsl_regrmw(device, reg->select, 0xff << bit, countable << bit); 210: } 211: 212: static int gen8_counter_gmu_pwr_enable(struct adreno_device *adreno_dev, 213: const struct adreno_perfcount_group *group, 214: u32 counter, u32 countable) 215: { 216: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 217: struct adreno_perfcount_register *reg = &group->regs[counter]; 218: /* Four counters can be programmed per select register */ 219: int offset = counter % 4; 220: 221: if (countable > 0xff) 222: return -EINVAL; 223: 224: gen8_write_gmu_counter_enable(device, reg, offset << 3, countable); 225: 226: kgsl_regwrite(device, GEN8_GMUCX_POWER_COUNTER_ENABLE, 1); 227: 228: reg->value = 0; 229: return 0; 230: } 231: 232: static int gen8_counter_gmu_perf_enable(struct adreno_device *adreno_dev, 233: const struct adreno_perfcount_group *group, 234: u32 counter, u32 countable) 235: { 236: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 237: struct adreno_perfcount_register *reg = &group->regs[counter]; 238: /* Four counters can be programmed per select register */ 239: int offset = counter % 4; 240: 241: if (countable > 0xff) 242: return -EINVAL; 243: 244: gen8_write_gmu_counter_enable(device, reg, offset << 3, countable); 245: 246: kgsl_regwrite(device, GEN8_GMUCX_PERF_COUNTER_ENABLE, 1); 247: 248: reg->value = 0; 249: return 0; 250: } 251: 252: static struct adreno_perfcount_register gen8_perfcounters_cp[] = { 253: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, GEN8_RBBM_PERFCTR_CP_0_LO, 254: GEN8_RBBM_PERFCTR_CP_0_HI, -1, GEN8_CP_PERFCTR_CP_SEL_0 }, 255: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, GEN8_RBBM_PERFCTR_CP_1_LO, 256: GEN8_RBBM_PERFCTR_CP_1_HI, -1, GEN8_CP_PERFCTR_CP_SEL_1 }, 257: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, GEN8_RBBM_PERFCTR_CP_2_LO, 258: GEN8_RBBM_PERFCTR_CP_2_HI, -1, GEN8_CP_PERFCTR_CP_SEL_2 }, 259: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, GEN8_RBBM_PERFCTR_CP_3_LO, 260: GEN8_RBBM_PERFCTR_CP_3_HI, -1, GEN8_CP_PERFCTR_CP_SEL_3 }, 261: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, GEN8_RBBM_PERFCTR_CP_4_LO, 262: GEN8_RBBM_PERFCTR_CP_4_HI, -1, GEN8_CP_PERFCTR_CP_SEL_4 }, 263: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, GEN8_RBBM_PERFCTR_CP_5_LO, 264: GEN8_RBBM_PERFCTR_CP_5_HI, -1, GEN8_CP_PERFCTR_CP_SEL_5 }, 265: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, GEN8_RBBM_PERFCTR_CP_6_LO, 266: GEN8_RBBM_PERFCTR_CP_6_HI, -1, GEN8_CP_PERFCTR_CP_SEL_6 }, 267: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, GEN8_RBBM_PERFCTR_CP_7_LO, 268: GEN8_RBBM_PERFCTR_CP_7_HI, -1, GEN8_CP_PERFCTR_CP_SEL_7 }, MATCH LINES: 860, 864, 868, 874, 877, 880, 883, 886, 889, 892, 895, 898, 901, 904, 907, 910, 913, 916, 919, 922, 925, 928, 931, 934, 937, 940, 943, 946, 949, 952, 955, 958, 961, 964, 967, 970, 973, 976, 979, 982, 985, 988, 991, 996, 997, 1000, 1003, 1006, 1009, 1012, 1015, 1018, 1021, 1024, 1027, 1030, 1033, 1036, 1039, 1042, 1047, 1048, 1051, 1054, 1057, 1060, 1063 848: GEN8_GBIF_PERF_CNT_HI_7, -1, GEN8_GBIF_PERF_CNT_SEL_1 }, 849: }; 850: 851: static struct adreno_perfcount_register gen8_perfcounters_gbif_pwr[] = { 852: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, GEN8_GBIF_PWR_CNT_LO_0, 853: GEN8_GBIF_PWR_CNT_HI_0, -1, GEN8_GBIF_PWR_CNT_SEL }, 854: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, GEN8_GBIF_PWR_CNT_LO_1, 855: GEN8_GBIF_PWR_CNT_HI_1, -1, GEN8_GBIF_PWR_CNT_SEL }, 856: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, GEN8_GBIF_PWR_CNT_LO_2, 857: GEN8_GBIF_PWR_CNT_HI_2, -1, GEN8_GBIF_PWR_CNT_SEL }, 858: }; 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, 896: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_7, 897: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_1), 898: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_8, 899: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_8, 900: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_2), 901: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_9, 902: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_9, 903: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_2), 904: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_10, 905: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_10, 906: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_2), 907: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_11, 908: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_11, 909: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_2), 910: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_12, 911: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_12, 912: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_3), 913: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_13, 914: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_13, 915: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_3), 916: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_14, 917: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_14, 918: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_3), 919: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_15, 920: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_15, 921: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_3), 922: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_16, 923: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_16, 924: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_4), 925: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_17, 926: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_17, 927: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_4), 928: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_18, 929: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_18, 930: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_4), 931: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_19, 932: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_19, 933: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_4), 934: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_20, 935: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_20, 936: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_5), 937: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_21, 938: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_21, 939: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_5), 940: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_22, 941: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_22, 942: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_5), 943: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_23, 944: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_23, 945: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_5), 946: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_24, 947: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_24, 948: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_6), 949: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_25, 950: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_25, 951: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_6), 952: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_26, 953: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_26, 954: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_6), 955: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_27, 956: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_27, 957: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_6), 958: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_28, 959: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_28, 960: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_7), 961: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_29, 962: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_29, 963: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_7), 964: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_30, 965: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_30, 966: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_7), 967: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_31, 968: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_31, 969: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_7), 970: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_32, 971: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_32, 972: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_8), 973: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_33, 974: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_33, 975: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_8), 976: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_34, 977: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_34, 978: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_8), 979: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_35, 980: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_35, 981: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_8), 982: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_36, 983: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_36, 984: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_9), 985: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_37, 986: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_37, 987: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_9), 988: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_38, 989: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_38, 990: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_9), 991: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_XOCLK_L_39, 992: GEN8_GMUCX_POWER_COUNTER_XOCLK_H_39, 993: GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_9), 994: }; 995: 996: static struct adreno_perfcount_register gen8_perfcounters_gmu_gmuclk[] = { 997: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_GMUCLK_L_0, 998: GEN8_GMUCX_POWER_COUNTER_GMUCLK_H_0, 999: GEN8_GMUCX_POWER_COUNTER_SELECT_GMUCLK_0), 1000: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_GMUCLK_L_1, 1001: GEN8_GMUCX_POWER_COUNTER_GMUCLK_H_1, 1002: GEN8_GMUCX_POWER_COUNTER_SELECT_GMUCLK_0), 1003: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_GMUCLK_L_2, 1004: GEN8_GMUCX_POWER_COUNTER_GMUCLK_H_2, 1005: GEN8_GMUCX_POWER_COUNTER_SELECT_GMUCLK_0), 1006: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_GMUCLK_L_3, 1007: GEN8_GMUCX_POWER_COUNTER_GMUCLK_H_3, 1008: GEN8_GMUCX_POWER_COUNTER_SELECT_GMUCLK_0), 1009: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_GMUCLK_L_4, 1010: GEN8_GMUCX_POWER_COUNTER_GMUCLK_H_4, 1011: GEN8_GMUCX_POWER_COUNTER_SELECT_GMUCLK_1), 1012: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_GMUCLK_L_5, 1013: GEN8_GMUCX_POWER_COUNTER_GMUCLK_H_5, 1014: GEN8_GMUCX_POWER_COUNTER_SELECT_GMUCLK_1), 1015: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_GMUCLK_L_6, 1016: GEN8_GMUCX_POWER_COUNTER_GMUCLK_H_6, 1017: GEN8_GMUCX_POWER_COUNTER_SELECT_GMUCLK_1), 1018: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_GMUCLK_L_7, 1019: GEN8_GMUCX_POWER_COUNTER_GMUCLK_H_7, 1020: GEN8_GMUCX_POWER_COUNTER_SELECT_GMUCLK_1), 1021: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_GMUCLK_L_8, 1022: GEN8_GMUCX_POWER_COUNTER_GMUCLK_H_8, 1023: GEN8_GMUCX_POWER_COUNTER_SELECT_GMUCLK_2), 1024: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_GMUCLK_L_9, 1025: GEN8_GMUCX_POWER_COUNTER_GMUCLK_H_9, 1026: GEN8_GMUCX_POWER_COUNTER_SELECT_GMUCLK_2), 1027: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_GMUCLK_L_10, 1028: GEN8_GMUCX_POWER_COUNTER_GMUCLK_H_10, 1029: GEN8_GMUCX_POWER_COUNTER_SELECT_GMUCLK_2), 1030: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_GMUCLK_L_11, 1031: GEN8_GMUCX_POWER_COUNTER_GMUCLK_H_11, 1032: GEN8_GMUCX_POWER_COUNTER_SELECT_GMUCLK_2), 1033: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_GMUCLK_L_12, 1034: GEN8_GMUCX_POWER_COUNTER_GMUCLK_H_12, 1035: GEN8_GMUCX_POWER_COUNTER_SELECT_GMUCLK_3), 1036: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_GMUCLK_L_13, 1037: GEN8_GMUCX_POWER_COUNTER_GMUCLK_H_13, 1038: GEN8_GMUCX_POWER_COUNTER_SELECT_GMUCLK_3), 1039: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_GMUCLK_L_14, 1040: GEN8_GMUCX_POWER_COUNTER_GMUCLK_H_14, 1041: GEN8_GMUCX_POWER_COUNTER_SELECT_GMUCLK_3), 1042: GMU_COUNTER(GEN8_GMUCX_POWER_COUNTER_GMUCLK_L_15, 1043: GEN8_GMUCX_POWER_COUNTER_GMUCLK_H_15, 1044: GEN8_GMUCX_POWER_COUNTER_SELECT_GMUCLK_3), 1045: }; 1046: 1047: static struct adreno_perfcount_register gen8_perfcounters_gmu_perf[] = { 1048: GMU_COUNTER(GEN8_GMUCX_PERF_COUNTER_L_0, 1049: GEN8_GMUCX_PERF_COUNTER_H_0, 1050: GEN8_GMUCX_PERF_COUNTER_SELECT_0), 1051: GMU_COUNTER(GEN8_GMUCX_PERF_COUNTER_L_1, 1052: GEN8_GMUCX_PERF_COUNTER_H_1, 1053: GEN8_GMUCX_PERF_COUNTER_SELECT_0), 1054: GMU_COUNTER(GEN8_GMUCX_PERF_COUNTER_L_2, 1055: GEN8_GMUCX_PERF_COUNTER_H_2, 1056: GEN8_GMUCX_PERF_COUNTER_SELECT_0), 1057: GMU_COUNTER(GEN8_GMUCX_PERF_COUNTER_L_3, 1058: GEN8_GMUCX_PERF_COUNTER_H_3, 1059: GEN8_GMUCX_PERF_COUNTER_SELECT_0), 1060: GMU_COUNTER(GEN8_GMUCX_PERF_COUNTER_L_4, 1061: GEN8_GMUCX_PERF_COUNTER_H_4, 1062: GEN8_GMUCX_PERF_COUNTER_SELECT_1), 1063: GMU_COUNTER(GEN8_GMUCX_PERF_COUNTER_L_5, 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) \ MATCH LINES: 1130, 1131, 1132, 1133, 1134, 1135 1118: GEN8_REGULAR_PERFCOUNTER_GROUP(TP, tp), 1119: GEN8_REGULAR_PERFCOUNTER_GROUP(SP, sp), 1120: GEN8_PERFCOUNTER_GROUP(RB, rb, gen8_counter_br_enable, gen8_counter_read), 1121: GEN8_REGULAR_PERFCOUNTER_GROUP(VSC, vsc), 1122: GEN8_PERFCOUNTER_GROUP_FLAGS(gen8, VBIF, gbif, 0, 1123: gen8_counter_gbif_enable, gen8_counter_read_norestore), 1124: GEN8_PERFCOUNTER_GROUP_FLAGS(gen8, VBIF_PWR, gbif_pwr, 1125: ADRENO_PERFCOUNTER_GROUP_FIXED, 1126: gen8_counter_gbif_pwr_enable, gen8_counter_read_norestore), 1127: GEN8_PERFCOUNTER_GROUP_FLAGS(gen8, ALWAYSON, alwayson, 1128: ADRENO_PERFCOUNTER_GROUP_FIXED, 1129: gen8_counter_alwayson_enable, gen8_counter_alwayson_read), 1130: GEN8_PERFCOUNTER_GROUP_FLAGS(gen8, GMU_XOCLK, gmu_xoclk, 0, 1131: gen8_counter_gmu_pwr_enable, gen8_counter_read_norestore), 1132: GEN8_PERFCOUNTER_GROUP_FLAGS(gen8, GMU_GMUCLK, gmu_gmuclk, 0, 1133: gen8_counter_gmu_pwr_enable, gen8_counter_read_norestore), 1134: GEN8_PERFCOUNTER_GROUP_FLAGS(gen8, GMU_PERF, gmu_perf, 0, 1135: gen8_counter_gmu_perf_enable, gen8_counter_read_norestore), 1136: GEN8_REGULAR_PERFCOUNTER_GROUP(UFC, ufc), 1137: GEN8_BV_REGULAR_PERFCOUNTER_GROUP(CP, cp), 1138: GEN8_BV_PERFCOUNTER_GROUP(PC, pc, gen8_counter_bv_enable, gen8_counter_read), 1139: GEN8_BV_PERFCOUNTER_GROUP(VFD, vfd, gen8_counter_bv_enable, gen8_counter_read), 1140: GEN8_BV_PERFCOUNTER_GROUP(VPC, vpc, gen8_counter_bv_enable, gen8_counter_read), 1141: GEN8_BV_REGULAR_PERFCOUNTER_GROUP(TP, tp), 1142: GEN8_BV_REGULAR_PERFCOUNTER_GROUP(SP, sp), 1143: GEN8_BV_REGULAR_PERFCOUNTER_GROUP(UFC, ufc), 1144: GEN8_BV_PERFCOUNTER_GROUP(TSE, tse, gen8_counter_bv_enable, gen8_counter_read), 1145: GEN8_BV_PERFCOUNTER_GROUP(RAS, ras, gen8_counter_bv_enable, gen8_counter_read), 1146: GEN8_BV_PERFCOUNTER_GROUP(LRZ, lrz, gen8_counter_bv_enable, gen8_counter_read), 1147: GEN8_BV_PERFCOUNTER_GROUP(HLSQ, hlsq, gen8_counter_bv_enable, gen8_counter_read), 1148: }; 1149: 1150: static const struct adreno_perfcount_group gen8_2_x_perfcounter_groups 1151: [KGSL_PERFCOUNTER_GROUP_MAX] = { 1152: GEN8_REGULAR_PERFCOUNTER_GROUP(CP, cp), 1153: GEN8_PERFCOUNTER_GROUP_FLAGS(gen8, RBBM, rbbm, 0, 1154: gen8_counter_enable, gen8_counter_read), 1155: GEN8_PERFCOUNTER_GROUP(PC, pc, gen8_counter_br_enable, gen8_counter_read), 1156: GEN8_PERFCOUNTER_GROUP(VFD, vfd, gen8_counter_br_enable, gen8_counter_read), 1157: GEN8_PERFCOUNTER_GROUP(HLSQ, hlsq, gen8_counter_br_enable, gen8_counter_read), 1158: GEN8_PERFCOUNTER_GROUP(VPC, vpc, gen8_counter_br_enable, gen8_counter_read), 1159: GEN8_PERFCOUNTER_GROUP(CCU, ccu, gen8_counter_br_enable, gen8_counter_read), MATCH LINES: 1177, 1178, 1179, 1180, 1181, 1182 1165: GEN8_REGULAR_PERFCOUNTER_GROUP(TP, tp), 1166: GEN8_REGULAR_PERFCOUNTER_GROUP(SP, sp), 1167: GEN8_PERFCOUNTER_GROUP(RB, rb, gen8_counter_br_enable, gen8_counter_read), 1168: GEN8_REGULAR_PERFCOUNTER_GROUP(VSC, vsc), 1169: GEN8_PERFCOUNTER_GROUP_FLAGS(gen8, VBIF, gbif, 0, 1170: gen8_counter_gbif_enable, gen8_counter_read_norestore), 1171: GEN8_PERFCOUNTER_GROUP_FLAGS(gen8, VBIF_PWR, gbif_pwr, 1172: ADRENO_PERFCOUNTER_GROUP_FIXED, 1173: gen8_counter_gbif_pwr_enable, gen8_counter_read_norestore), 1174: GEN8_PERFCOUNTER_GROUP_FLAGS(gen8, ALWAYSON, alwayson, 1175: ADRENO_PERFCOUNTER_GROUP_FIXED, 1176: gen8_counter_alwayson_enable, gen8_counter_alwayson_read), 1177: GEN8_PERFCOUNTER_GROUP_FLAGS(gen8, GMU_XOCLK, gmu_xoclk, 0, 1178: gen8_counter_gmu_pwr_enable, gen8_counter_read_norestore), 1179: GEN8_PERFCOUNTER_GROUP_FLAGS(gen8, GMU_GMUCLK, gmu_gmuclk, 0, 1180: gen8_counter_gmu_pwr_enable, gen8_counter_read_norestore), 1181: GEN8_PERFCOUNTER_GROUP_FLAGS(gen8, GMU_PERF, gmu_perf, 0, 1182: gen8_counter_gmu_perf_enable, gen8_counter_read_norestore), 1183: GEN8_REGULAR_PERFCOUNTER_GROUP(UFC, ufc), 1184: GEN8_BV_REGULAR_PERFCOUNTER_GROUP(CP, cp), 1185: GEN8_BV_PERFCOUNTER_GROUP(PC, pc, gen8_counter_bv_enable, gen8_counter_read), 1186: GEN8_BV_PERFCOUNTER_GROUP(VFD, vfd, gen8_counter_bv_enable, gen8_counter_read), 1187: GEN8_BV_PERFCOUNTER_GROUP(VPC, vpc, gen8_counter_bv_enable, gen8_counter_read), 1188: GEN8_BV_REGULAR_PERFCOUNTER_GROUP(TP, tp), 1189: GEN8_BV_REGULAR_PERFCOUNTER_GROUP(SP, sp), 1190: GEN8_BV_REGULAR_PERFCOUNTER_GROUP(UFC, ufc), 1191: GEN8_BV_PERFCOUNTER_GROUP(TSE, tse, gen8_counter_bv_enable, gen8_counter_read), 1192: GEN8_BV_PERFCOUNTER_GROUP(RAS, ras, gen8_counter_bv_enable, gen8_counter_read), 1193: GEN8_BV_PERFCOUNTER_GROUP(LRZ, lrz, gen8_counter_bv_enable, gen8_counter_read), 1194: GEN8_BV_PERFCOUNTER_GROUP(HLSQ, hlsq, gen8_counter_bv_enable, gen8_counter_read), 1195: GEN8_BV_PERFCOUNTER_GROUP(CCU, ccu, gen8_counter_bv_enable, gen8_counter_read), 1196: GEN8_BV_PERFCOUNTER_GROUP(RB, rb, gen8_counter_bv_enable, gen8_counter_read), 1197: }; 1198: 1199: const struct adreno_perfcounters adreno_gen8_perfcounters = { 1200: gen8_perfcounter_groups, 1201: ARRAY_SIZE(gen8_perfcounter_groups), 1202: }; 1203: 1204: const struct adreno_perfcounters adreno_gen8_2_x_perfcounters = { 1205: gen8_2_x_perfcounter_groups, 1206: ARRAY_SIZE(gen8_2_x_perfcounter_groups), --- FILE: \adreno_gen8_preempt.c | HITS: 9 --- MATCH LINES: 62, 64, 73 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: 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, MATCH LINES: 286, 287, 311 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: 334: if (gen8_fenced_write(adreno_dev, 335: GEN8_CP_CONTEXT_SWITCH_NPR_ADDR_LO, MATCH LINES: 384, 386, 388 372: /* Trigger the preemption */ 373: if (gen8_fenced_write(adreno_dev, GEN8_CP_CONTEXT_SWITCH_CNTL, cntl, 374: FENCE_STATUS_WRITEDROPPED1_MASK)) { 375: adreno_dev->next_rb = NULL; 376: kgsl_delete_timer(&adreno_dev->preempt.timer); 377: goto err; 378: } 379: 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: /* --- FILE: \adreno_gen8_ringbuffer.c | HITS: 2 --- MATCH LINES: 208, 210 196: if (adreno_dev->cur_rb == rb) 197: rb->skip_inline_wptr = true; 198: } 199: 200: rb->wptr = rb->_wptr; 201: spin_unlock_irqrestore(&rb->preempt_lock, flags); 202: 203: if (ret) { 204: /* 205: * If WPTR update fails, take inline snapshot and trigger 206: * recovery. 207: */ 208: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE); 209: adreno_scheduler_fault(adreno_dev, 210: ADRENO_GMU_FAULT_SKIP_SNAPSHOT); 211: } 212: 213: return ret; 214: } 215: 216: int gen8_ringbuffer_init(struct adreno_device *adreno_dev) 217: { 218: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 219: int i, ret; 220: 221: ret = adreno_allocate_global(device, &device->scratch, PAGE_SIZE, 222: 0, 0, KGSL_MEMDESC_RANDOM | KGSL_MEMDESC_PRIVILEGED, 223: "scratch"); 224: if (ret) 225: return ret; 226: 227: adreno_dev->cur_rb = &(adreno_dev->ringbuffers[0]); 228: 229: if (!adreno_preemption_feature_set(adreno_dev)) { 230: adreno_dev->num_ringbuffers = 1; 231: return adreno_ringbuffer_setup(adreno_dev, 232: &adreno_dev->ringbuffers[0], 0); 233: } 234: --- FILE: \adreno_gen8_rpmh.c | HITS: 19 --- MATCH LINES: 26, 34, 37, 39, 42, 43, 46, 47, 48, 50, 53, 57, 59 14: 15: /* 16: * List of Bus Control Modules (BCMs) that need to be configured for the GPU 17: * to access DDR. For each bus level we will generate a vote each BCM. 18: */ 19: static struct bcm gen8_11_0_ddr_bcms[] = { 20: { .name = "SH0", .buswidth = 32 }, 21: { .name = "MC0", .buswidth = 4 }, 22: { .name = "ACV", .fixed = true }, 23: }; 24: 25: /* 26: * setup_gmu_arc_votes - Build the gmu voting table 27: * @gmu: Pointer to gmu device 28: * @pri_rail: Pointer to primary power rail vlvl table 29: * @sec_rail: Pointer to second/dependent power rail vlvl table 30: * 31: * This function initializes the cx votes for all gmu frequencies 32: * for gmu dcvs 33: */ 34: static int setup_cx_arc_votes(struct gen8_gmu_device *gmu, 35: struct rpmh_arc_vals *pri_rail, struct rpmh_arc_vals *sec_rail) 36: { 37: struct kgsl_device *device = KGSL_DEVICE(gen8_gmu_to_adreno(gmu)); 38: /* Hardcoded values of GMU CX voltage levels */ 39: u16 gmu_cx_vlvl[MAX_CX_LEVELS]; 40: u32 cx_votes[MAX_CX_LEVELS]; 41: struct gen8_dcvs_table *table = &gmu->dcvs_table; 42: u32 *freqs = device->gmu_core.freqs; 43: u32 *vlvls = device->gmu_core.vlvls; 44: int ret, i; 45: 46: gmu_cx_vlvl[0] = 0; 47: for (i = 0; i < device->gmu_core.num_freqs; i++) 48: gmu_cx_vlvl[i + 1] = vlvls[i]; 49: 50: table->gmu_level_num = device->gmu_core.num_freqs + 1; 51: 52: table->cx_votes[0].freq = 0; 53: for (i = 0; i < device->gmu_core.num_freqs; i++) 54: table->cx_votes[i + 1].freq = freqs[i] / 1000; 55: 56: ret = adreno_rpmh_setup_volt_dependency_tbl(cx_votes, pri_rail, 57: sec_rail, gmu_cx_vlvl, table->gmu_level_num); 58: if (!ret) { 59: for (i = 0; i < table->gmu_level_num; i++) 60: table->cx_votes[i].vote = cx_votes[i]; 61: } 62: 63: return ret; 64: } 65: 66: #define GEN8_DEP_VOTE_SET(cx, mx, bx) \ 67: (FIELD_PREP(GENMASK(31, 26), 0x3F) | \ 68: FIELD_PREP(GENMASK(25, 20), bx) | \ 69: FIELD_PREP(GENMASK(19, 14), 0x3F) | \ 70: FIELD_PREP(GENMASK(13, 8), mx) | \ 71: FIELD_PREP(GENMASK(7, 0), cx)) 72: 73: #define GEN8_DEP_VOTE_SET_BX(bx) (FIELD_PREP(GENMASK(25, 20), bx)) 74: 75: static int setup_dependency_domain_tbl(struct adreno_device *adreno_dev, u32 *votes, 76: struct rpmh_arc_vals *dep_rail, struct rpmh_arc_vals *cx_rail, 77: u16 *vlvl, u32 *cx_vlvl, u32 num_entries) 78: { 79: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev); 80: u32 cx_vote; 81: int i, j; 82: 83: for (i = 1; i < num_entries; i++) { MATCH LINES: 194 182: * @gmxc_rail: Pointer to MxG power rail vlvl table 183: * @gbx_rail: Pointer to BX power rail vlvl table 184: * 185: * This function initializes the gx votes for all gpu frequencies 186: * for gpu dcvs 187: */ 188: static int setup_gx_arc_votes(struct adreno_device *adreno_dev, 189: struct rpmh_arc_vals *pri_rail, struct rpmh_arc_vals *sec_rail, 190: struct rpmh_arc_vals *gmxc_rail, struct rpmh_arc_vals *cx_rail, 191: struct rpmh_arc_vals *gbx_rail) 192: { 193: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 194: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 195: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 196: struct gen8_dcvs_table *table = &gmu->dcvs_table; 197: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev); 198: u16 vlvl_tbl[MAX_GX_LEVELS]; 199: u32 cx_vlvl_tbl[MAX_GX_LEVELS]; 200: u32 gx_votes[MAX_GX_LEVELS]; 201: u32 dep_votes[MAX_GX_LEVELS]; 202: int ret, i; 203: 204: table->gpu_level_num = pwr->num_pwrlevels + 1; 205: 206: if (table->gpu_level_num > ARRAY_SIZE(vlvl_tbl)) { 207: dev_err(device->dev, 208: "Defined more GPU DCVS levels than RPMh can support\n"); 209: return -ERANGE; 210: } 211: 212: /* Initialize vlvl tables */ 213: memset(vlvl_tbl, 0, sizeof(vlvl_tbl)); 214: memset(cx_vlvl_tbl, 0, sizeof(cx_vlvl_tbl)); 215: 216: /* Fill the vlvl tables. GMU power levels are in ascending order */ 217: for (i = 1; i < table->gpu_level_num; i++) { 218: vlvl_tbl[i] = pwr->pwrlevels[pwr->num_pwrlevels - i].voltage_level; MATCH LINES: 261 249: } 250: 251: /* Add the zero powerlevel for the perf table */ 252: table->gx_votes[0].freq = 0; 253: table->gx_votes[0].vote = 0; 254: table->gx_votes[0].dep_vote = 0xFFFFFFFF; 255: 256: return ret; 257: } 258: 259: static int build_dcvs_table(struct adreno_device *adreno_dev) 260: { 261: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 262: struct rpmh_arc_vals gx_arc, cx_arc, mx_arc, gmxc_arc, gbx_arc; 263: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev); 264: int ret; 265: 266: ret = adreno_rpmh_arc_cmds(&gx_arc, "gfx.lvl"); 267: if (ret) 268: return ret; 269: 270: ret = adreno_rpmh_arc_cmds(&cx_arc, "cx.lvl"); 271: if (ret) 272: return ret; 273: 274: ret = adreno_rpmh_arc_cmds(&mx_arc, "mx.lvl"); 275: if (ret) 276: return ret; 277: 278: if (gen8_core->three_rail_memory) { 279: ret = adreno_rpmh_arc_cmds(&gbx_arc, "gbx.lvl"); 280: if (ret) 281: return ret; 282: } 283: 284: ret = setup_cx_arc_votes(gmu, &cx_arc, &mx_arc); 285: if (ret) MATCH LINES: 317, 331, 335, 351 305: 306: /* BIT(2) is used to vote for GPU performance mode through GMU */ 307: #define ACV_GPU_PERFMODE_VOTE BIT(2) 308: 309: /* Use hardcoded CNOC table when not defined in device tree */ 310: static const u32 default_cnoc_table[] = { 311: 0, /* Off */ 312: 100, /* On */ 313: }; 314: 315: static int build_bw_table(struct adreno_device *adreno_dev) 316: { 317: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 318: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev); 319: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 320: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 321: struct rpmh_bw_votes *ddr, *cnoc = NULL; 322: u32 perfmode_lvl = kgsl_pwrctrl_get_acv_perfmode_lvl(device, 323: gen8_core->acv_perfmode_ddr_freq); 324: u32 *cnoc_table; 325: u32 count = 0; 326: int ret; 327: 328: if (adreno_is_gen8_11_x(adreno_dev)) 329: ddr = adreno_rpmh_build_bw_votes(gen8_11_0_ddr_bcms, ARRAY_SIZE(gen8_11_0_ddr_bcms), 330: pwr->ddr_table, pwr->ddr_table_count, ACV_GPU_PERFMODE_VOTE, perfmode_lvl, 331: adreno_dev->gmu_ab); 332: else 333: ddr = adreno_rpmh_build_bw_votes(adreno_ddr_bcms, ARRAY_SIZE(adreno_ddr_bcms), 334: pwr->ddr_table, pwr->ddr_table_count, ACV_GPU_PERFMODE_VOTE, perfmode_lvl, 335: adreno_dev->gmu_ab); 336: 337: if (IS_ERR(ddr)) 338: return PTR_ERR(ddr); 339: 340: cnoc_table = kgsl_bus_get_table(device->pdev, "qcom,bus-table-cnoc", 341: &count); 342: 343: /* Use hardcoded CNOC table */ 344: if (!count) { 345: cnoc_table = (u32 *)default_cnoc_table; 346: count = ARRAY_SIZE(default_cnoc_table); 347: } 348: 349: cnoc = adreno_rpmh_build_bw_votes(adreno_cnoc_bcms, 350: ARRAY_SIZE(adreno_cnoc_bcms), cnoc_table, count, 0, 0, 351: adreno_dev->gmu_ab); 352: 353: if (cnoc_table != default_cnoc_table) 354: kfree(cnoc_table); 355: 356: if (IS_ERR(cnoc)) { 357: adreno_rpmh_free_bw_votes(ddr); 358: return PTR_ERR(cnoc); 359: } 360: 361: ret = CMD_MSG_HDR(gmu->hfi.bw_table, H2F_MSG_BW_VOTE_TBL); 362: if (ret) 363: return ret; 364: 365: adreno_rpmh_build_bw_table_cmd(&gmu->hfi.bw_table, ddr, cnoc); 366: 367: adreno_rpmh_free_bw_votes(ddr); 368: adreno_rpmh_free_bw_votes(cnoc); 369: 370: return 0; 371: } 372: 373: int gen8_build_rpmh_tables(struct adreno_device *adreno_dev) 374: { 375: int ret; --- FILE: \adreno_gen8_snapshot.c | HITS: 30 --- MATCH LINES: 38, 39, 40, 70, 71, 72, 101, 102, 103, 132, 133, 134, 163, 164, 165, 194, 195, 196, 225, 226, 227, 260, 261, 262 26: 27: const struct gen8_snapshot_block_list gen8_0_0_snapshot_block_list = { 28: .pre_crashdumper_regs = gen8_0_0_ahb_registers, 29: .num_pre_crashdumper_regs = ARRAY_SIZE(gen8_0_0_ahb_registers), 30: .debugbus_blocks = gen8_debugbus_blocks, 31: .debugbus_blocks_len = ARRAY_SIZE(gen8_debugbus_blocks), 32: .gbif_debugbus_blocks = gen8_gbif_debugbus_blocks, 33: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen8_gbif_debugbus_blocks), 34: .cx_debugbus_blocks = gen8_cx_debugbus_blocks, 35: .cx_debugbus_blocks_len = ARRAY_SIZE(gen8_cx_debugbus_blocks), 36: .external_core_regs = gen8_0_0_external_core_regs, 37: .num_external_core_regs = ARRAY_SIZE(gen8_0_0_external_core_regs), 38: .gmu_cx_unsliced_regs = gen8_0_0_gmu_registers, 39: .gmu_gx_regs = gen8_gmu_gx_registers, 40: .num_gmu_gx_regs = ARRAY_SIZE(gen8_gmu_gx_registers), 41: .rscc_regs = gen8_0_0_rscc_rsc_registers, 42: .reg_list = gen8_0_0_reg_list, 43: .cx_misc_regs = gen8_0_0_cx_misc_registers, 44: .shader_blocks = gen8_0_0_shader_blocks, 45: .num_shader_blocks = ARRAY_SIZE(gen8_0_0_shader_blocks), 46: .cp_clusters = gen8_0_0_cp_clusters, 47: .num_cp_clusters = ARRAY_SIZE(gen8_0_0_cp_clusters), 48: .clusters = gen8_0_0_mvc_clusters, 49: .num_clusters = ARRAY_SIZE(gen8_0_0_mvc_clusters), 50: .sptp_clusters = gen8_0_0_sptp_clusters, 51: .num_sptp_clusters = ARRAY_SIZE(gen8_0_0_sptp_clusters), 52: .index_registers = gen8_0_0_cp_indexed_reg_list, 53: .index_registers_len = ARRAY_SIZE(gen8_0_0_cp_indexed_reg_list), 54: .mempool_index_registers = gen8_0_0_cp_mempool_reg_list, 55: .mempool_index_registers_len = ARRAY_SIZE(gen8_0_0_cp_mempool_reg_list), 56: }; 57: 58: const struct gen8_snapshot_block_list gen8_1_0_snapshot_block_list = { 59: .pre_crashdumper_regs = gen8_1_0_ahb_registers, 60: .num_pre_crashdumper_regs = ARRAY_SIZE(gen8_1_0_ahb_registers), 61: .debugbus_blocks = gen8_1_0_debugbus_blocks, 62: .debugbus_blocks_len = ARRAY_SIZE(gen8_1_0_debugbus_blocks), 63: /* GBIF_GX is included in gen8_1_0_debugbus_blocks per data file */ 64: .gbif_debugbus_blocks = gen8_1_0_gbif_debugbus_blocks, 65: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen8_1_0_gbif_debugbus_blocks), 66: .cx_debugbus_blocks = gen8_cx_debugbus_blocks, 67: .cx_debugbus_blocks_len = ARRAY_SIZE(gen8_cx_debugbus_blocks), 68: .external_core_regs = gen8_1_0_external_core_regs, 69: .num_external_core_regs = ARRAY_SIZE(gen8_1_0_external_core_regs), 70: .gmu_cx_unsliced_regs = gen8_1_0_gmucx_registers, 71: .gmu_gx_regs = gen8_1_0_gmu_gx_registers, 72: .num_gmu_gx_regs = ARRAY_SIZE(gen8_1_0_gmu_gx_registers), 73: .rscc_regs = gen8_2_0_rscc_rsc_registers, 74: .reg_list = gen8_1_0_misc_registers, 75: .cx_misc_regs = gen8_1_0_cx_misc_registers, 76: .shader_blocks = gen8_1_0_shader_blocks, 77: .num_shader_blocks = ARRAY_SIZE(gen8_1_0_shader_blocks), 78: .cp_clusters = gen8_1_0_cp_clusters, 79: .num_cp_clusters = ARRAY_SIZE(gen8_1_0_cp_clusters), 80: .clusters = gen8_1_0_mvc_clusters, 81: .num_clusters = ARRAY_SIZE(gen8_1_0_mvc_clusters), 82: .sptp_clusters = gen8_1_0_sptp_clusters, 83: .num_sptp_clusters = ARRAY_SIZE(gen8_1_0_sptp_clusters), 84: .index_registers = gen8_1_0_cp_indexed_reg_list, 85: .index_registers_len = ARRAY_SIZE(gen8_1_0_cp_indexed_reg_list), 86: .mempool_index_registers = gen8_2_0_cp_mempool_reg_list, 87: .mempool_index_registers_len = ARRAY_SIZE(gen8_2_0_cp_mempool_reg_list), 88: }; 89: 90: const struct gen8_snapshot_block_list gen8_10_0_snapshot_block_list = { 91: .pre_crashdumper_regs = gen8_1_0_ahb_registers, 92: .num_pre_crashdumper_regs = ARRAY_SIZE(gen8_1_0_ahb_registers), 93: .debugbus_blocks = gen8_10_0_debugbus_blocks, 94: .debugbus_blocks_len = ARRAY_SIZE(gen8_10_0_debugbus_blocks), 95: .gbif_debugbus_blocks = gen8_1_0_gbif_debugbus_blocks, 96: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen8_1_0_gbif_debugbus_blocks), 97: .cx_debugbus_blocks = gen8_cx_debugbus_blocks, 98: .cx_debugbus_blocks_len = ARRAY_SIZE(gen8_cx_debugbus_blocks), 99: .external_core_regs = gen8_1_0_external_core_regs, 100: .num_external_core_regs = ARRAY_SIZE(gen8_1_0_external_core_regs), 101: .gmu_cx_unsliced_regs = gen8_1_0_gmucx_registers, 102: .gmu_gx_regs = gen8_1_0_gmu_gx_registers, 103: .num_gmu_gx_regs = ARRAY_SIZE(gen8_1_0_gmu_gx_registers), 104: .rscc_regs = gen8_2_0_rscc_rsc_registers, 105: .reg_list = gen8_1_0_misc_registers, 106: .cx_misc_regs = gen8_1_0_cx_misc_registers, 107: .shader_blocks = gen8_1_0_shader_blocks, 108: .num_shader_blocks = ARRAY_SIZE(gen8_1_0_shader_blocks), 109: .cp_clusters = gen8_1_0_cp_clusters, 110: .num_cp_clusters = ARRAY_SIZE(gen8_1_0_cp_clusters), 111: .clusters = gen8_1_0_mvc_clusters, 112: .num_clusters = ARRAY_SIZE(gen8_1_0_mvc_clusters), 113: .sptp_clusters = gen8_1_0_sptp_clusters, 114: .num_sptp_clusters = ARRAY_SIZE(gen8_1_0_sptp_clusters), 115: .index_registers = gen8_1_0_cp_indexed_reg_list, 116: .index_registers_len = ARRAY_SIZE(gen8_1_0_cp_indexed_reg_list), 117: .mempool_index_registers = gen8_2_0_cp_mempool_reg_list, 118: .mempool_index_registers_len = ARRAY_SIZE(gen8_2_0_cp_mempool_reg_list), 119: }; 120: 121: const struct gen8_snapshot_block_list gen8_2_0_snapshot_block_list = { 122: .pre_crashdumper_regs = gen8_2_0_ahb_registers, 123: .num_pre_crashdumper_regs = ARRAY_SIZE(gen8_2_0_ahb_registers), 124: .debugbus_blocks = gen8_2_0_debugbus_blocks, 125: .debugbus_blocks_len = ARRAY_SIZE(gen8_2_0_debugbus_blocks), 126: .gbif_debugbus_blocks = gen8_gbif_debugbus_blocks, 127: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen8_gbif_debugbus_blocks), 128: .cx_debugbus_blocks = gen8_cx_debugbus_blocks, 129: .cx_debugbus_blocks_len = ARRAY_SIZE(gen8_cx_debugbus_blocks), 130: .external_core_regs = gen8_2_0_external_core_regs, 131: .num_external_core_regs = ARRAY_SIZE(gen8_2_0_external_core_regs), 132: .gmu_cx_unsliced_regs = gen8_2_0_gmucx_registers, 133: .gmu_gx_regs = gen8_2_0_gmu_gx_registers, 134: .num_gmu_gx_regs = ARRAY_SIZE(gen8_2_0_gmu_gx_registers), 135: .rscc_regs = gen8_2_0_rscc_rsc_registers, 136: .reg_list = gen8_2_0_misc_registers, 137: .cx_misc_regs = gen8_2_0_cx_misc_registers, 138: .shader_blocks = gen8_2_0_shader_blocks, 139: .num_shader_blocks = ARRAY_SIZE(gen8_2_0_shader_blocks), 140: .cp_clusters = gen8_2_0_cp_clusters, 141: .num_cp_clusters = ARRAY_SIZE(gen8_2_0_cp_clusters), 142: .clusters = gen8_2_0_mvc_clusters, 143: .num_clusters = ARRAY_SIZE(gen8_2_0_mvc_clusters), 144: .sptp_clusters = gen8_2_0_sptp_clusters, 145: .num_sptp_clusters = ARRAY_SIZE(gen8_2_0_sptp_clusters), 146: .index_registers = gen8_2_0_cp_indexed_reg_list, 147: .index_registers_len = ARRAY_SIZE(gen8_2_0_cp_indexed_reg_list), 148: .mempool_index_registers = gen8_2_0_cp_mempool_reg_list, 149: .mempool_index_registers_len = ARRAY_SIZE(gen8_2_0_cp_mempool_reg_list), 150: }; 151: 152: const struct gen8_snapshot_block_list gen8_3_0_snapshot_block_list = { 153: .pre_crashdumper_regs = gen8_0_0_ahb_registers, 154: .num_pre_crashdumper_regs = ARRAY_SIZE(gen8_0_0_ahb_registers), 155: .debugbus_blocks = gen8_3_0_debugbus_blocks, 156: .debugbus_blocks_len = ARRAY_SIZE(gen8_3_0_debugbus_blocks), 157: .gbif_debugbus_blocks = gen8_gbif_debugbus_blocks, 158: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen8_gbif_debugbus_blocks), 159: .cx_debugbus_blocks = gen8_cx_debugbus_blocks, 160: .cx_debugbus_blocks_len = ARRAY_SIZE(gen8_cx_debugbus_blocks), 161: .external_core_regs = gen8_3_0_external_core_regs, 162: .num_external_core_regs = ARRAY_SIZE(gen8_3_0_external_core_regs), 163: .gmu_cx_unsliced_regs = gen8_3_0_gmu_registers, 164: .gmu_gx_regs = gen8_3_0_gmu_gx_regs, 165: .num_gmu_gx_regs = ARRAY_SIZE(gen8_3_0_gmu_gx_regs), 166: .rscc_regs = gen8_3_0_rscc_rsc_registers, 167: .reg_list = gen8_0_0_reg_list, 168: .cx_misc_regs = gen8_0_0_cx_misc_registers, 169: .shader_blocks = gen8_3_0_shader_blocks, 170: .num_shader_blocks = ARRAY_SIZE(gen8_3_0_shader_blocks), 171: .cp_clusters = gen8_3_0_cp_clusters, 172: .num_cp_clusters = ARRAY_SIZE(gen8_3_0_cp_clusters), 173: .clusters = gen8_3_0_mvc_clusters, 174: .num_clusters = ARRAY_SIZE(gen8_3_0_mvc_clusters), 175: .sptp_clusters = gen8_3_0_sptp_clusters, 176: .num_sptp_clusters = ARRAY_SIZE(gen8_3_0_sptp_clusters), 177: .index_registers = gen8_3_0_cp_indexed_reg_list, 178: .index_registers_len = ARRAY_SIZE(gen8_3_0_cp_indexed_reg_list), 179: .mempool_index_registers = gen8_0_0_cp_mempool_reg_list, 180: .mempool_index_registers_len = ARRAY_SIZE(gen8_0_0_cp_mempool_reg_list), 181: }; 182: 183: const struct gen8_snapshot_block_list gen8_6_0_snapshot_block_list = { 184: .pre_crashdumper_regs = gen8_0_0_ahb_registers, 185: .num_pre_crashdumper_regs = ARRAY_SIZE(gen8_0_0_ahb_registers), 186: .debugbus_blocks = gen8_6_0_debugbus_blocks, 187: .debugbus_blocks_len = ARRAY_SIZE(gen8_6_0_debugbus_blocks), 188: .gbif_debugbus_blocks = gen8_gbif_debugbus_blocks, 189: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen8_gbif_debugbus_blocks), 190: .cx_debugbus_blocks = gen8_cx_debugbus_blocks, 191: .cx_debugbus_blocks_len = ARRAY_SIZE(gen8_cx_debugbus_blocks), 192: .external_core_regs = gen8_6_0_external_core_regs, 193: .num_external_core_regs = ARRAY_SIZE(gen8_6_0_external_core_regs), 194: .gmu_cx_unsliced_regs = gen8_6_0_gmu_registers, 195: .gmu_gx_regs = gen8_6_0_gmu_gx_registers, 196: .num_gmu_gx_regs = ARRAY_SIZE(gen8_6_0_gmu_gx_registers), 197: .rscc_regs = gen8_0_0_rscc_rsc_registers, 198: .reg_list = gen8_6_0_reg_list, 199: .cx_misc_regs = gen8_0_0_cx_misc_registers, 200: .shader_blocks = gen8_6_0_shader_blocks, 201: .num_shader_blocks = ARRAY_SIZE(gen8_0_0_shader_blocks), 202: .cp_clusters = gen8_0_0_cp_clusters, 203: .num_cp_clusters = ARRAY_SIZE(gen8_0_0_cp_clusters), 204: .clusters = gen8_6_0_mvc_clusters, 205: .num_clusters = ARRAY_SIZE(gen8_6_0_mvc_clusters), 206: .sptp_clusters = gen8_0_0_sptp_clusters, 207: .num_sptp_clusters = ARRAY_SIZE(gen8_0_0_sptp_clusters), 208: .index_registers = gen8_0_0_cp_indexed_reg_list, 209: .index_registers_len = ARRAY_SIZE(gen8_0_0_cp_indexed_reg_list), 210: .mempool_index_registers = gen8_0_0_cp_mempool_reg_list, 211: .mempool_index_registers_len = ARRAY_SIZE(gen8_0_0_cp_mempool_reg_list), 212: }; 213: 214: const struct gen8_snapshot_block_list gen8_9_0_snapshot_block_list = { 215: .pre_crashdumper_regs = gen8_2_0_ahb_registers, 216: .num_pre_crashdumper_regs = ARRAY_SIZE(gen8_2_0_ahb_registers), 217: .debugbus_blocks = gen8_9_0_debugbus_blocks, 218: .debugbus_blocks_len = ARRAY_SIZE(gen8_9_0_debugbus_blocks), 219: .gbif_debugbus_blocks = gen8_gbif_debugbus_blocks, 220: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen8_gbif_debugbus_blocks), 221: .cx_debugbus_blocks = gen8_cx_debugbus_blocks, 222: .cx_debugbus_blocks_len = ARRAY_SIZE(gen8_cx_debugbus_blocks), 223: .external_core_regs = gen8_9_0_external_core_regs, 224: .num_external_core_regs = ARRAY_SIZE(gen8_9_0_external_core_regs), 225: .gmu_cx_unsliced_regs = gen8_2_0_gmucx_registers, 226: .gmu_gx_regs = gen8_2_0_gmu_gx_registers, 227: .num_gmu_gx_regs = ARRAY_SIZE(gen8_2_0_gmu_gx_registers), 228: .rscc_regs = gen8_2_0_rscc_rsc_registers, 229: .reg_list = gen8_2_0_misc_registers, 230: .cx_misc_regs = gen8_2_0_cx_misc_registers, 231: .shader_blocks = 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), 270: .clusters = gen8_11_0_mvc_clusters, 271: .num_clusters = ARRAY_SIZE(gen8_11_0_mvc_clusters), 272: .sptp_clusters = gen8_11_0_sptp_clusters, 273: .num_sptp_clusters = ARRAY_SIZE(gen8_11_0_sptp_clusters), 274: .index_registers = gen8_11_0_cp_indexed_reg_list, 275: .index_registers_len = ARRAY_SIZE(gen8_11_0_cp_indexed_reg_list), 276: .mempool_index_registers = gen8_11_0_cp_mempool_reg_list, 277: .mempool_index_registers_len = ARRAY_SIZE(gen8_11_0_cp_mempool_reg_list), 278: .pc_index_registers = gen8_11_0_pc_indexed_reg_list, 279: .pc_index_registers_len = ARRAY_SIZE(gen8_11_0_pc_indexed_reg_list), 280: }; 281: 282: #define GEN8_SP_READ_SEL_VAL(_contextid, _sliceid, _location, _pipe, _statetype, _usptp, _sptp) \ 283: ((FIELD_PREP(GENMASK(30, 26), _contextid)) | \ 284: (FIELD_PREP(GENMASK(25, 21), _sliceid)) | \ 285: (FIELD_PREP(GENMASK(20, 18), _location)) | \ 286: (FIELD_PREP(GENMASK(17, 16), _pipe)) | \ MATCH LINES: 957 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, MATCH LINES: 1989, 1990 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; MATCH LINES: 2109, 2131, 2132 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); --- FILE: \adreno_gen8_snapshot.h | HITS: 17 --- MATCH LINES: 237, 240 225: }; 226: 227: struct gen8_trace_buffer_info { 228: u16 dbgc_ctrl; 229: u16 segment; 230: u16 granularity; 231: u16 ping_blk[TRACE_BUF_NUM_SIG]; 232: u16 ping_idx[TRACE_BUF_NUM_SIG]; 233: }; 234: 235: enum gen8_debugbus_ids { 236: DEBUGBUS_GBIF_CX_GC_US_I_0 = 1, 237: DEBUGBUS_GMU_CX_GC_US_I_0 = 2, 238: DEBUGBUS_CX_GC_US_I_0 = 3, 239: DEBUGBUS_GBIF_GX_GC_US_I_0 = 8, 240: DEBUGBUS_GMU_GX_GC_US_I_0 = 9, 241: DEBUGBUS_DBGC_GC_US_I_0 = 10, 242: DEBUGBUS_RBBM_GC_US_I_0 = 11, 243: DEBUGBUS_LARC_GC_US_I_0 = 12, 244: DEBUGBUS_COM_GC_US_I_0 = 13, 245: DEBUGBUS_HLSQ_GC_US_I_0 = 14, 246: DEBUGBUS_CGC_GC_US_I_0 = 15, 247: DEBUGBUS_VSC_GC_US_I_0_0 = 20, 248: DEBUGBUS_VSC_GC_US_I_0_1 = 21, 249: DEBUGBUS_UFC_GC_US_I_0 = 24, 250: DEBUGBUS_UFC_GC_US_I_1 = 25, 251: DEBUGBUS_CP_GC_US_I_0_0 = 40, 252: DEBUGBUS_CP_GC_US_I_0_1 = 41, 253: DEBUGBUS_CP_GC_US_I_0_2 = 42, 254: DEBUGBUS_PC_BR_US_I_0 = 56, 255: DEBUGBUS_PC_BV_US_I_0 = 57, 256: DEBUGBUS_GPC_BR_US_I_0 = 58, 257: DEBUGBUS_GPC_BV_US_I_0 = 59, 258: DEBUGBUS_VPC_BR_US_I_0 = 60, 259: DEBUGBUS_VPC_BV_US_I_0 = 61, 260: DEBUGBUS_UCHE_WRAPPER_GC_US_I_0 = 80, 261: DEBUGBUS_UCHE_GC_US_I_0 = 81, 262: DEBUGBUS_UCHE_GC_US_I_1 = 82, 263: DEBUGBUS_UCHE_GC_US_I_0_1 = 83, 264: DEBUGBUS_UCHE_GC_US_I_1_1 = 84, MATCH LINES: 287 275: DEBUGBUS_GPC_BR_S_0_I_0 = 138, 276: DEBUGBUS_GPC_BV_S_0_I_0 = 139, 277: DEBUGBUS_VPCFE_BR_S_0_I_0 = 140, 278: DEBUGBUS_VPCFE_BV_S_0_I_0 = 141, 279: DEBUGBUS_VPCBE_BR_S_0_I_0 = 142, 280: DEBUGBUS_VPCBE_BV_S_0_I_0 = 143, 281: DEBUGBUS_CCHE_GC_S_0_I_0 = 144, 282: DEBUGBUS_DBGC_GC_S_0_I_0 = 145, 283: DEBUGBUS_LARC_GC_S_0_I_0 = 146, 284: DEBUGBUS_RBBM_GC_S_0_I_0 = 147, 285: DEBUGBUS_CCRE_GC_S_0_I_0 = 148, 286: DEBUGBUS_CGC_GC_S_0_I_0 = 149, 287: DEBUGBUS_GMU_GC_S_0_I_0 = 150, 288: DEBUGBUS_SLICE_GC_S_0_I_0 = 151, 289: DEBUGBUS_HLSQ_SPTP_STAR_GC_S_0_I_0 = 152, 290: DEBUGBUS_SLICE_HM1_S_0_I_0 = 154, 291: DEBUGBUS_SLICE_HM1_S_0_I_1 = 155, 292: DEBUGBUS_USP_GC_S_0_I_0 = 160, 293: DEBUGBUS_USP_GC_S_0_I_1 = 161, 294: DEBUGBUS_USPTP_GC_S_0_I_0 = 166, 295: DEBUGBUS_USPTP_GC_S_0_I_1 = 167, 296: DEBUGBUS_USPTP_GC_S_0_I_2 = 168, 297: DEBUGBUS_USPTP_GC_S_0_I_3 = 169, 298: DEBUGBUS_TP_GC_S_0_I_0 = 178, 299: DEBUGBUS_TP_GC_S_0_I_1 = 179, 300: DEBUGBUS_TP_GC_S_0_I_2 = 180, 301: DEBUGBUS_TP_GC_S_0_I_3 = 181, 302: DEBUGBUS_RB_GC_S_0_I_0 = 190, 303: DEBUGBUS_RB_GC_S_0_I_1 = 191, 304: DEBUGBUS_CCU_GC_S_0_I_0 = 196, 305: DEBUGBUS_CCU_GC_S_0_I_1 = 197, 306: DEBUGBUS_HLSQ_GC_S_0_I_0 = 202, 307: DEBUGBUS_HLSQ_GC_S_0_I_1 = 203, 308: DEBUGBUS_VFD_GC_S_0_I_0 = 208, 309: DEBUGBUS_VFD_GC_S_0_I_1 = 209, 310: DEBUGBUS_NSP_S_0_I_0 = 214, 311: DEBUGBUS_NSP_S_0_I_1 = 215, MATCH LINES: 344 332: DEBUGBUS_GPC_BR_S_1_I_0 = 266, 333: DEBUGBUS_GPC_BV_S_1_I_0 = 267, 334: DEBUGBUS_VPCFE_BR_S_1_I_0 = 268, 335: DEBUGBUS_VPCFE_BV_S_1_I_0 = 269, 336: DEBUGBUS_VPCBE_BR_S_1_I_0 = 270, 337: DEBUGBUS_VPCBE_BV_S_1_I_0 = 271, 338: DEBUGBUS_CCHE_GC_S_1_I_0 = 272, 339: DEBUGBUS_DBGC_GC_S_1_I_0 = 273, 340: DEBUGBUS_LARC_GC_S_1_I_0 = 274, 341: DEBUGBUS_RBBM_GC_S_1_I_0 = 275, 342: DEBUGBUS_CCRE_GC_S_1_I_0 = 276, 343: DEBUGBUS_CGC_GC_S_1_I_0 = 277, 344: DEBUGBUS_GMU_GC_S_1_I_0 = 278, 345: DEBUGBUS_SLICE_GC_S_1_I_0 = 279, 346: DEBUGBUS_HLSQ_SPTP_STAR_GC_S_1_I_0 = 280, 347: DEBUGBUS_SLICE_HM1_S_1_I_0 = 282, 348: DEBUGBUS_SLICE_HM1_S_1_I_1 = 283, 349: DEBUGBUS_USP_GC_S_1_I_0 = 288, 350: DEBUGBUS_USP_GC_S_1_I_1 = 289, 351: DEBUGBUS_USPTP_GC_S_1_I_0 = 294, 352: DEBUGBUS_USPTP_GC_S_1_I_1 = 295, 353: DEBUGBUS_USPTP_GC_S_1_I_2 = 296, 354: DEBUGBUS_USPTP_GC_S_1_I_3 = 297, 355: DEBUGBUS_TP_GC_S_1_I_0 = 306, 356: DEBUGBUS_TP_GC_S_1_I_1 = 307, 357: DEBUGBUS_TP_GC_S_1_I_2 = 308, 358: DEBUGBUS_TP_GC_S_1_I_3 = 309, 359: DEBUGBUS_RB_GC_S_1_I_0 = 318, 360: DEBUGBUS_RB_GC_S_1_I_1 = 319, 361: DEBUGBUS_CCU_GC_S_1_I_0 = 324, 362: DEBUGBUS_CCU_GC_S_1_I_1 = 325, 363: DEBUGBUS_HLSQ_GC_S_1_I_0 = 330, 364: DEBUGBUS_HLSQ_GC_S_1_I_1 = 331, 365: DEBUGBUS_VFD_GC_S_1_I_0 = 336, 366: DEBUGBUS_NSP_S_1_I_0 = 342, 367: DEBUGBUS_NSP_S_1_I_1 = 343, 368: DEBUGBUS_NSP_S_1_I_2 = 344, MATCH LINES: 401 389: DEBUGBUS_GPC_BR_S_2_I_0 = 394, 390: DEBUGBUS_GPC_BV_S_2_I_0 = 395, 391: DEBUGBUS_VPCFE_BR_S_2_I_0 = 396, 392: DEBUGBUS_VPCFE_BV_S_2_I_0 = 397, 393: DEBUGBUS_VPCBE_BR_S_2_I_0 = 398, 394: DEBUGBUS_VPCBE_BV_S_2_I_0 = 399, 395: DEBUGBUS_CCHE_GC_S_2_I_0 = 400, 396: DEBUGBUS_DBGC_GC_S_2_I_0 = 401, 397: DEBUGBUS_LARC_GC_S_2_I_0 = 402, 398: DEBUGBUS_RBBM_GC_S_2_I_0 = 403, 399: DEBUGBUS_CCRE_GC_S_2_I_0 = 404, 400: DEBUGBUS_CGC_GC_S_2_I_0 = 405, 401: DEBUGBUS_GMU_GC_S_2_I_0 = 406, 402: DEBUGBUS_SLICE_GC_S_2_I_0 = 407, 403: DEBUGBUS_HLSQ_SPTP_STAR_GC_S_2_I_0 = 408, 404: DEBUGBUS_SLICE_HM1_S_2_I_0 = 410, 405: DEBUGBUS_SLICE_HM1_S_2_I_1 = 411, 406: DEBUGBUS_USP_GC_S_2_I_0 = 416, 407: DEBUGBUS_USP_GC_S_2_I_1 = 417, 408: DEBUGBUS_USPTP_GC_S_2_I_0 = 422, 409: DEBUGBUS_USPTP_GC_S_2_I_1 = 423, 410: DEBUGBUS_USPTP_GC_S_2_I_2 = 424, 411: DEBUGBUS_USPTP_GC_S_2_I_3 = 425, 412: DEBUGBUS_TP_GC_S_2_I_0 = 434, 413: DEBUGBUS_TP_GC_S_2_I_1 = 435, 414: DEBUGBUS_TP_GC_S_2_I_2 = 436, 415: DEBUGBUS_TP_GC_S_2_I_3 = 437, 416: DEBUGBUS_RB_GC_S_2_I_0 = 446, 417: DEBUGBUS_RB_GC_S_2_I_1 = 447, 418: DEBUGBUS_CCU_GC_S_2_I_0 = 452, 419: DEBUGBUS_CCU_GC_S_2_I_1 = 453, 420: DEBUGBUS_HLSQ_GC_S_2_I_0 = 458, 421: DEBUGBUS_HLSQ_GC_S_2_I_1 = 459, 422: DEBUGBUS_VFD_GC_S_2_I_0 = 464, 423: DEBUGBUS_VFD_GC_S_2_I_1 = 465, 424: DEBUGBUS_NSP_S_2_I_0 = 470, 425: DEBUGBUS_NSP_S_2_I_1 = 471, MATCH LINES: 459, 483 447: DEBUGBUS_GPC_BR_S_3_I_0 = 522, 448: DEBUGBUS_GPC_BV_S_3_I_0 = 523, 449: DEBUGBUS_VPCFE_BR_S_3_I_0 = 524, 450: DEBUGBUS_VPCFE_BV_S_3_I_0 = 525, 451: DEBUGBUS_VPCBE_BR_S_3_I_0 = 526, 452: DEBUGBUS_VPCBE_BV_S_3_I_0 = 527, 453: DEBUGBUS_CCHE_GC_S_3_I_0 = 528, 454: DEBUGBUS_DBGC_GC_S_3_I_0 = 529, 455: DEBUGBUS_LARC_GC_S_3_I_0 = 530, 456: DEBUGBUS_RBBM_GC_S_3_I_0 = 531, 457: DEBUGBUS_CCRE_GC_S_3_I_0 = 532, 458: DEBUGBUS_CGC_GC_S_3_I_0 = 533, 459: DEBUGBUS_GMU_GC_S_3_I_0 = 534, 460: DEBUGBUS_SLICE_GC_S_3_I_0 = 535, 461: DEBUGBUS_HLSQ_SPTP_STAR_GC_S_3_I_0 = 536, 462: DEBUGBUS_USP_GC_S_3_I_0 = 544, 463: DEBUGBUS_USP_GC_S_3_I_1 = 545, 464: DEBUGBUS_USPTP_GC_S_3_I_0 = 550, 465: DEBUGBUS_USPTP_GC_S_3_I_1 = 551, 466: DEBUGBUS_USPTP_GC_S_3_I_2 = 552, 467: DEBUGBUS_USPTP_GC_S_3_I_3 = 553, 468: DEBUGBUS_TP_GC_S_3_I_0 = 562, 469: DEBUGBUS_TP_GC_S_3_I_1 = 563, 470: DEBUGBUS_TP_GC_S_3_I_2 = 564, 471: DEBUGBUS_TP_GC_S_3_I_3 = 565, 472: DEBUGBUS_RB_GC_S_3_I_0 = 574, 473: DEBUGBUS_RB_GC_S_3_I_1 = 575, 474: DEBUGBUS_CCU_GC_S_3_I_0 = 580, 475: DEBUGBUS_CCU_GC_S_3_I_1 = 581, 476: DEBUGBUS_HLSQ_GC_S_3_I_0 = 586, 477: DEBUGBUS_HLSQ_GC_S_3_I_1 = 587, 478: DEBUGBUS_VFD_GC_S_3_I_0 = 592, 479: DEBUGBUS_VFD_GC_S_3_I_1 = 593, 480: }; 481: 482: static const u32 gen8_debugbus_blocks[] = { 483: DEBUGBUS_GMU_GX_GC_US_I_0, 484: DEBUGBUS_DBGC_GC_US_I_0, 485: DEBUGBUS_RBBM_GC_US_I_0, 486: DEBUGBUS_LARC_GC_US_I_0, 487: DEBUGBUS_COM_GC_US_I_0, 488: DEBUGBUS_HLSQ_GC_US_I_0, 489: DEBUGBUS_CGC_GC_US_I_0, 490: DEBUGBUS_VSC_GC_US_I_0_0, 491: DEBUGBUS_VSC_GC_US_I_0_1, 492: DEBUGBUS_UFC_GC_US_I_0, 493: DEBUGBUS_UFC_GC_US_I_1, 494: DEBUGBUS_CP_GC_US_I_0_0, 495: DEBUGBUS_CP_GC_US_I_0_1, 496: DEBUGBUS_CP_GC_US_I_0_2, 497: DEBUGBUS_PC_BR_US_I_0, 498: DEBUGBUS_PC_BV_US_I_0, 499: DEBUGBUS_GPC_BR_US_I_0, 500: DEBUGBUS_GPC_BV_US_I_0, 501: DEBUGBUS_VPC_BR_US_I_0, 502: DEBUGBUS_VPC_BV_US_I_0, 503: DEBUGBUS_UCHE_WRAPPER_GC_US_I_0, 504: DEBUGBUS_UCHE_GC_US_I_0, 505: DEBUGBUS_UCHE_GC_US_I_1, 506: DEBUGBUS_CP_GC_S_0_I_0, 507: DEBUGBUS_PC_BR_S_0_I_0, MATCH LINES: 528 516: DEBUGBUS_GPC_BR_S_0_I_0, 517: DEBUGBUS_GPC_BV_S_0_I_0, 518: DEBUGBUS_VPCFE_BR_S_0_I_0, 519: DEBUGBUS_VPCFE_BV_S_0_I_0, 520: DEBUGBUS_VPCBE_BR_S_0_I_0, 521: DEBUGBUS_VPCBE_BV_S_0_I_0, 522: DEBUGBUS_CCHE_GC_S_0_I_0, 523: DEBUGBUS_DBGC_GC_S_0_I_0, 524: DEBUGBUS_LARC_GC_S_0_I_0, 525: DEBUGBUS_RBBM_GC_S_0_I_0, 526: DEBUGBUS_CCRE_GC_S_0_I_0, 527: DEBUGBUS_CGC_GC_S_0_I_0, 528: DEBUGBUS_GMU_GC_S_0_I_0, 529: DEBUGBUS_SLICE_GC_S_0_I_0, 530: DEBUGBUS_HLSQ_SPTP_STAR_GC_S_0_I_0, 531: DEBUGBUS_USP_GC_S_0_I_0, 532: DEBUGBUS_USP_GC_S_0_I_1, 533: DEBUGBUS_USPTP_GC_S_0_I_0, 534: DEBUGBUS_USPTP_GC_S_0_I_1, 535: DEBUGBUS_USPTP_GC_S_0_I_2, 536: DEBUGBUS_USPTP_GC_S_0_I_3, 537: DEBUGBUS_TP_GC_S_0_I_0, 538: DEBUGBUS_TP_GC_S_0_I_1, 539: DEBUGBUS_TP_GC_S_0_I_2, 540: DEBUGBUS_TP_GC_S_0_I_3, 541: DEBUGBUS_RB_GC_S_0_I_0, 542: DEBUGBUS_RB_GC_S_0_I_1, 543: DEBUGBUS_CCU_GC_S_0_I_0, 544: DEBUGBUS_CCU_GC_S_0_I_1, 545: DEBUGBUS_HLSQ_GC_S_0_I_0, 546: DEBUGBUS_HLSQ_GC_S_0_I_1, 547: DEBUGBUS_VFD_GC_S_0_I_0, 548: DEBUGBUS_VFD_GC_S_0_I_1, 549: DEBUGBUS_CP_GC_S_1_I_0, 550: DEBUGBUS_PC_BR_S_1_I_0, 551: DEBUGBUS_PC_BV_S_1_I_0, 552: DEBUGBUS_TESS_GC_S_1_I_0, MATCH LINES: 571 559: DEBUGBUS_GPC_BR_S_1_I_0, 560: DEBUGBUS_GPC_BV_S_1_I_0, 561: DEBUGBUS_VPCFE_BR_S_1_I_0, 562: DEBUGBUS_VPCFE_BV_S_1_I_0, 563: DEBUGBUS_VPCBE_BR_S_1_I_0, 564: DEBUGBUS_VPCBE_BV_S_1_I_0, 565: DEBUGBUS_CCHE_GC_S_1_I_0, 566: DEBUGBUS_DBGC_GC_S_1_I_0, 567: DEBUGBUS_LARC_GC_S_1_I_0, 568: DEBUGBUS_RBBM_GC_S_1_I_0, 569: DEBUGBUS_CCRE_GC_S_1_I_0, 570: DEBUGBUS_CGC_GC_S_1_I_0, 571: DEBUGBUS_GMU_GC_S_1_I_0, 572: DEBUGBUS_SLICE_GC_S_1_I_0, 573: DEBUGBUS_HLSQ_SPTP_STAR_GC_S_1_I_0, 574: DEBUGBUS_USP_GC_S_1_I_0, 575: DEBUGBUS_USP_GC_S_1_I_1, 576: DEBUGBUS_USPTP_GC_S_1_I_0, 577: DEBUGBUS_USPTP_GC_S_1_I_1, 578: DEBUGBUS_USPTP_GC_S_1_I_2, 579: DEBUGBUS_USPTP_GC_S_1_I_3, 580: DEBUGBUS_TP_GC_S_1_I_0, 581: DEBUGBUS_TP_GC_S_1_I_1, 582: DEBUGBUS_TP_GC_S_1_I_2, 583: DEBUGBUS_TP_GC_S_1_I_3, 584: DEBUGBUS_RB_GC_S_1_I_0, 585: DEBUGBUS_RB_GC_S_1_I_1, 586: DEBUGBUS_CCU_GC_S_1_I_0, 587: DEBUGBUS_CCU_GC_S_1_I_1, 588: DEBUGBUS_HLSQ_GC_S_1_I_0, 589: DEBUGBUS_HLSQ_GC_S_1_I_1, 590: DEBUGBUS_VFD_GC_S_1_I_0, 591: DEBUGBUS_VFD_GC_S_1_I_1, 592: DEBUGBUS_CP_GC_S_2_I_0, 593: DEBUGBUS_PC_BR_S_2_I_0, 594: DEBUGBUS_PC_BV_S_2_I_0, 595: DEBUGBUS_TESS_GC_S_2_I_0, MATCH LINES: 614, 643 602: DEBUGBUS_GPC_BR_S_2_I_0, 603: DEBUGBUS_GPC_BV_S_2_I_0, 604: DEBUGBUS_VPCFE_BR_S_2_I_0, 605: DEBUGBUS_VPCFE_BV_S_2_I_0, 606: DEBUGBUS_VPCBE_BR_S_2_I_0, 607: DEBUGBUS_VPCBE_BV_S_2_I_0, 608: DEBUGBUS_CCHE_GC_S_2_I_0, 609: DEBUGBUS_DBGC_GC_S_2_I_0, 610: DEBUGBUS_LARC_GC_S_2_I_0, 611: DEBUGBUS_RBBM_GC_S_2_I_0, 612: DEBUGBUS_CCRE_GC_S_2_I_0, 613: DEBUGBUS_CGC_GC_S_2_I_0, 614: DEBUGBUS_GMU_GC_S_2_I_0, 615: DEBUGBUS_SLICE_GC_S_2_I_0, 616: DEBUGBUS_HLSQ_SPTP_STAR_GC_S_2_I_0, 617: DEBUGBUS_USP_GC_S_2_I_0, 618: DEBUGBUS_USP_GC_S_2_I_1, 619: DEBUGBUS_USPTP_GC_S_2_I_0, 620: DEBUGBUS_USPTP_GC_S_2_I_1, 621: DEBUGBUS_USPTP_GC_S_2_I_2, 622: DEBUGBUS_USPTP_GC_S_2_I_3, 623: DEBUGBUS_TP_GC_S_2_I_0, 624: DEBUGBUS_TP_GC_S_2_I_1, 625: DEBUGBUS_TP_GC_S_2_I_2, 626: DEBUGBUS_TP_GC_S_2_I_3, 627: DEBUGBUS_RB_GC_S_2_I_0, 628: DEBUGBUS_RB_GC_S_2_I_1, 629: DEBUGBUS_CCU_GC_S_2_I_0, 630: DEBUGBUS_CCU_GC_S_2_I_1, 631: DEBUGBUS_HLSQ_GC_S_2_I_0, 632: DEBUGBUS_HLSQ_GC_S_2_I_1, 633: DEBUGBUS_VFD_GC_S_2_I_0, 634: DEBUGBUS_VFD_GC_S_2_I_1, 635: }; 636: 637: static const u32 gen8_gbif_debugbus_blocks[] = { 638: DEBUGBUS_GBIF_GX_GC_US_I_0, 639: }; 640: 641: static const u32 gen8_cx_debugbus_blocks[] = { 642: DEBUGBUS_GBIF_CX_GC_US_I_0, 643: DEBUGBUS_GMU_CX_GC_US_I_0, 644: DEBUGBUS_CX_GC_US_I_0, 645: }; 646: 647: struct gen8_debugbus_info { 648: u32 debugbus_id; 649: u32 debugbus_size; 650: }; 651: 652: enum gen8_statetype_ids { 653: TP0_NCTX_REG = 0, 654: TP0_CTX0_3D_CVS_REG = 1, 655: TP0_CTX0_3D_CPS_REG = 2, 656: TP0_CTX1_3D_CVS_REG = 3, 657: TP0_CTX1_3D_CPS_REG = 4, 658: TP0_CTX2_3D_CPS_REG = 5, 659: TP0_CTX3_3D_CPS_REG = 6, 660: TP0_TMO_DATA = 9, 661: TP0_SMO_DATA = 10, 662: TP0_MIPMAP_BASE_DATA = 11, 663: TP_3D_CVS_REG = 12, 664: TP_3D_CPS_REG = 13, 665: SP_3D_CVS_REG = 16, 666: SP_3D_CPS_REG = 17, 667: SP_LB_DATA_RAM = 22, MATCH LINES: 774, 775, 776, 777, 778, 779 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; 770: /* external_core_regs : List of external core registers */ 771: const u32 **external_core_regs; 772: /* num_external_core_regs : length of external core registers list */ 773: size_t num_external_core_regs; 774: /* gmu_cx_unsliced_regs : List of GMU CX unsliced registers */ 775: const u32 *gmu_cx_unsliced_regs; 776: /* gmu_gx_registers : List of GMU registers */ 777: struct gen8_reg_list *gmu_gx_regs; 778: /* num_gmu_gx_regs : Length of GMU registers list */ 779: size_t num_gmu_gx_regs; 780: /* rscc_regs : List of RSCC registers */ 781: const u32 *rscc_regs; 782: /* reg_list : List of GPU internal registers */ 783: struct gen8_reg_list *reg_list; 784: /* reg_list : List of cx_misc registers */ 785: const u32 *cx_misc_regs; 786: /* shader_blocks : List of GPU shader memory */ 787: struct gen8_shader_block *shader_blocks; 788: /* num_shader_blocks : Length of the shader memory list */ 789: size_t num_shader_blocks; 790: /* cp_cluster_registers : List of GPU CP cluster registers */ 791: struct gen8_cluster_registers *cp_clusters; 792: /* num_cp_clusters : Length of GPU CP cluster registers list */ 793: size_t num_cp_clusters; 794: /* cluster_registers : List of GPU cluster registers */ 795: struct gen8_cluster_registers *clusters; 796: /* num_clusters : Length of GPU cluster registers list */ 797: size_t num_clusters; 798: /* spstp_cluster_registers : List of GPU SPTP cluster registers */ 799: struct gen8_sptp_cluster_registers *sptp_clusters; 800: /* num_sptp_clusters : Length of GPU SPTP cluster registers list */ 801: size_t num_sptp_clusters; 802: /* index_registers : List of index_registers */ 803: struct gen8_cp_indexed_reg *index_registers; --- FILE: \adreno_hfi.h | HITS: 494 --- MATCH LINES: 6, 7, 12, 15, 17, 18, 19, 20, 22, 23, 24, 25, 26, 28, 29, 30, 31, 33, 34, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 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, 98, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 119, 120, 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, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 173, 175, 176, 177, 178, 179, 180, 181, 183, 186, 188, 191, 193, 196, 198, 201, 203, 206, 208, 211, 212, 213, 214, 215, 217, 220, 222, 225, 227, 230, 231, 232, 233, 234, 236, 238, 241, 242, 245, 250, 252, 257, 258, 259, 260, 261, 262, 263, 265, 268, 269, 270, 272, 275, 277, 280, 282, 285, 286, 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, 324, 327, 330, 333, 336, 339, 342, 345, 348, 351, 354, 357, 365, 375, 377, 408, 418, 433, 434, 437, 439, 441, 442, 450, 452, 453, 454, 456, 457, 458, 461, 462, 463, 465, 466, 468, 469, 476, 477, 492, 494, 496, 519, 520, 543, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 559, 563, 564, 565, 566, 569, 570, 571, 572, 576, 585, 591, 617, 620, 626, 629, 635, 641, 645, 652, 684, 719, 720, 722, 731, 737, 742, 750, 757, 758, 763, 770, 778, 783, 788, 789, 793, 798, 799, 809, 810, 815, 818, 821, 824, 828, 831, 835, 843, 849, 856, 863, 871, 878, 886, 893, 903, 910, 920, 926, 933, 939, 947, 967, 969, 971, 973, 975, 977, 978, 979, 980, 981, 982, 985, 999, 1006, 1011, 1025, 1035, 1045, 1052, 1060, 1064, 1073, 1089, 1097, 1098, 1099, 1101, 1102, 1103, 1105, 1112, 1113, 1114, 1115, 1118, 1134, 1139, 1140, 1158, 1171, 1176, 1177, 1181, 1199, 1206, 1208, 1209, 1210, 1219, 1221, 1224, 1225, 1232, 1235, 1243, 1246, 1249, 1253, 1254 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_HFI_H 7: #define __ADRENO_HFI_H 8: 9: #include "kgsl_util.h" 10: 11: #define HW_FENCE_QUEUE_SIZE SZ_4K 12: #define HFI_QUEUE_SIZE SZ_4K /* bytes, must be base 4dw */ 13: #define MAX_RCVD_PAYLOAD_SIZE 32 /* dwords */ 14: #define MAX_RCVD_SIZE (MAX_RCVD_PAYLOAD_SIZE + 3) /* dwords */ 15: #define HFI_MAX_MSG_SIZE (SZ_1K) 16: 17: #define HFI_CMD_ID 0 18: #define HFI_MSG_ID 1 19: #define HFI_DBG_ID 2 20: #define HFI_DSP_ID_0 3 21: 22: #define HFI_CMD_IDX 0 23: #define HFI_MSG_IDX 1 24: #define HFI_DBG_IDX 2 25: #define HFI_DSP_IDX_BASE 3 26: #define HFI_DSP_IDX_0 3 27: 28: #define HFI_CMD_IDX_LEGACY 0 29: #define HFI_DSP_IDX_0_LEGACY 1 30: #define HFI_MSG_IDX_LEGACY 4 31: #define HFI_DBG_IDX_LEGACY 5 32: 33: #define HFI_QUEUE_STATUS_DISABLED 0 34: #define HFI_QUEUE_STATUS_ENABLED 1 35: 36: /* HTOF queue priority, 1 is highest priority */ 37: #define HFI_CMD_PRI 10 38: #define HFI_MSG_PRI 10 39: #define HFI_DBG_PRI 40 40: #define HFI_DSP_PRI_0 20 41: 42: #define HFI_IRQ_SIDEMSGQ_MASK BIT(1) 43: #define HFI_IRQ_DBGQ_MASK BIT(2) 44: #define HFI_IRQ_CM3_FAULT_MASK BIT(15) 45: #define HFI_IRQ_OOB_MASK GENMASK(31, 16) 46: #define HFI_IRQ_MASK (HFI_IRQ_SIDEMSGQ_MASK |\ 47: HFI_IRQ_DBGQ_MASK |\ 48: HFI_IRQ_CM3_FAULT_MASK) 49: 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 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, 110: HFI_TABLE_SYS_TIME_DATA = 8, 111: HFI_TABLE_GMU_SCALING_DATA = 9, 112: HFI_TABLE_LIMITS_MITIGATION = 10, 113: HFI_TABLE_MAX, 114: }; 115: 116: /* For Gen7 & Gen8 ACD */ 117: #define F_PWR_ACD_CALIBRATE 78 118: 119: #define HFI_VALUE_FT_POLICY 100 120: #define HFI_VALUE_RB_MAX_CMDS 101 121: #define HFI_VALUE_CTX_MAX_CMDS 102 122: #define HFI_VALUE_ADDRESS 103 123: #define HFI_VALUE_MAX_GPU_PERF_INDEX 104 124: #define HFI_VALUE_MIN_GPU_PERF_INDEX 105 125: #define HFI_VALUE_MAX_BW_PERF_INDEX 106 126: #define HFI_VALUE_MIN_BW_PERF_INDEX 107 127: #define HFI_VALUE_MAX_GPU_THERMAL_INDEX 108 128: #define HFI_VALUE_GPUCLK 109 129: #define HFI_VALUE_CLK_TIME 110 130: #define HFI_VALUE_LOG_GROUP 111 131: #define HFI_VALUE_LOG_EVENT_ON 112 132: #define HFI_VALUE_LOG_EVENT_OFF 113 133: #define HFI_VALUE_DCVS_OBJ 114 134: #define HFI_VALUE_LM_CS0 115 135: #define HFI_VALUE_DBG 116 136: #define HFI_VALUE_BIN_TIME 117 137: #define HFI_VALUE_LOG_STREAM_ENABLE 119 138: #define HFI_VALUE_PREEMPT_COUNT 120 139: #define HFI_VALUE_CONTEXT_QUEUE 121 140: #define HFI_VALUE_GMU_AB_VOTE 122 141: #define HFI_VALUE_RB_GPU_QOS 123 142: #define HFI_VALUE_RB_IB_RULE 124 143: #define HFI_VALUE_GMU_WARMBOOT 125 144: #define HFI_VALUE_DCVS_ENABLE 131 145: #define HFI_VALUE_DCVS_TUNING_PARAM 132 146: #define HFI_VALUE_RB_GPULEVEL_RULE 133 147: #define HFI_VALUE_MALU 135 148: #define HFI_VALUE_GLOBAL_TOKEN 0xFFFFFFFF 149: 150: #define HFI_CTXT_FLAG_PMODE BIT(0) 151: #define HFI_CTXT_FLAG_SWITCH_INTERNAL BIT(1) 152: #define HFI_CTXT_FLAG_SWITCH BIT(3) 153: #define HFI_CTXT_FLAG_NOTIFY BIT(5) 154: #define HFI_CTXT_FLAG_NO_FAULT_TOLERANCE BIT(9) 155: #define HFI_CTXT_FLAG_PWR_RULE BIT(11) 156: #define HFI_CTXT_FLAG_PRIORITY_MASK GENMASK(15, 12) 157: #define HFI_CTXT_FLAG_IFH_NOP BIT(16) 158: #define HFI_CTXT_FLAG_SECURE BIT(17) 159: #define HFI_CTXT_FLAG_TYPE_MASK GENMASK(24, 20) 160: #define HFI_CTXT_FLAG_TYPE_ANY 0 161: #define HFI_CTXT_FLAG_TYPE_GL 1 162: #define HFI_CTXT_FLAG_TYPE_CL 2 163: #define HFI_CTXT_FLAG_TYPE_C2D 3 164: #define HFI_CTXT_FLAG_TYPE_RS 4 165: #define HFI_CTXT_FLAG_TYPE_VK 5 166: #define HFI_CTXT_FLAG_TYPE_UNKNOWN 0x1e 167: #define HFI_CTXT_FLAG_PREEMPT_STYLE_MASK GENMASK(27, 25) 168: #define HFI_CTXT_FLAG_PREEMPT_STYLE_ANY 0 169: #define HFI_CTXT_FLAG_PREEMPT_STYLE_RB 1 170: #define HFI_CTXT_FLAG_PREEMPT_STYLE_FG 2 171: 172: /* Default sampling interval in units of 50 us */ 173: #define HFI_FEATURE_GMU_STATS_INTERVAL 4 174: 175: enum hfi_mem_kind { 176: /** @HFI_MEMKIND_GENERIC: Used for requesting generic memory */ 177: HFI_MEMKIND_GENERIC = 0, 178: /** @HFI_MEMKIND_RB: Used for requesting ringbuffer memory */ 179: HFI_MEMKIND_RB, 180: /** @HFI_MEMKIND_SCRATCH: Used for requesting scratch memory */ 181: HFI_MEMKIND_SCRATCH, 182: /** 183: * @HFI_MEMKIND_CSW_SMMU_INFO: Used for requesting SMMU record for 184: * preemption context switching 185: */ 186: HFI_MEMKIND_CSW_SMMU_INFO, 187: /** 188: * @HFI_MEMKIND_CSW_PRIV_NON_SECURE: Used for requesting privileged non 189: * secure preemption records 190: */ 191: HFI_MEMKIND_CSW_PRIV_NON_SECURE, 192: /** 193: * @HFI_MEMKIND_CSW_PRIV_SECURE: Used for requesting privileged secure 194: * preemption records 195: */ 196: HFI_MEMKIND_CSW_PRIV_SECURE, 197: /** 198: * @HFI_MEMKIND_CSW_NON_PRIV: Used for requesting non privileged per 199: * context preemption buffer 200: */ 201: HFI_MEMKIND_CSW_NON_PRIV, 202: /** 203: * @HFI_MEMKIND_CSW_COUNTER: Used for requesting preemption performance 204: * counter save/restore buffer 205: */ 206: HFI_MEMKIND_CSW_COUNTER, 207: /** 208: * @HFI_MEMKIND_CTXTREC_PREEMPT_CNTR: Used for requesting preemption 209: * counter buffer 210: */ 211: HFI_MEMKIND_CTXTREC_PREEMPT_CNTR, 212: /** @HFI_MEMKIND_SYSLOG: Used for requesting system log memory */ 213: HFI_MEMKIND_SYS_LOG, 214: /** @HFI_MEMKIND_CRASH_DUMP: Used for requesting carsh dumper memory */ 215: HFI_MEMKIND_CRASH_DUMP, 216: /** 217: * @HFI_MEMKIND_MMIO_DPU: Used for requesting Display processing unit's 218: * register space 219: */ 220: HFI_MEMKIND_MMIO_DPU, 221: /** 222: * @HFI_MEMKIND_MMIO_TCSR: Used for requesting Top CSR(contains SoC 223: * doorbells) register space 224: */ 225: HFI_MEMKIND_MMIO_TCSR, 226: /** 227: * @HFI_MEMKIND_MMIO_QDSS_STM: Used for requesting QDSS STM register 228: * space 229: */ 230: HFI_MEMKIND_MMIO_QDSS_STM, 231: /** @HFI_MEMKIND_PROFILE: Used for kernel profiling */ 232: HFI_MEMKIND_PROFILE, 233: /** @HFI_MEMKIND_USER_PROFILING_IBS: Used for user profiling */ 234: HFI_MEMKIND_USER_PROFILE_IBS, 235: /** @MEMKIND_CMD_BUFFER: Used for composing ringbuffer content */ 236: HFI_MEMKIND_CMD_BUFFER, 237: /** 238: * @HFI_MEMKIND_GPU_BUSY_DATA_BUFFER: Used for GPU busy buffer for 239: * all the contexts 240: */ 241: HFI_MEMKIND_GPU_BUSY_DATA_BUFFER, 242: /** @HFI_MEMKIND_GPU_BUSY_CMD_BUFFER: Used for GPU busy cmd buffer 243: * (Only readable to GPU) 244: */ 245: HFI_MEMKIND_GPU_BUSY_CMD_BUFFER, 246: /** 247: *@MEMKIND_MMIO_IPC_CORE: Used for IPC_core region mapping to GMU space 248: * for EVA to GPU communication. 249: */ 250: HFI_MEMKIND_MMIO_IPC_CORE, 251: /** @HFIMEMKIND_MMIO_IPCC_AOSS: Used for IPCC AOSS, second memory region */ 252: HFI_MEMKIND_MMIO_IPCC_AOSS, 253: /** 254: * @MEMKIND_CSW_LPAC_PRIV_NON_SECURE: Used for privileged nonsecure 255: * memory for LPAC context record 256: */ 257: HFI_MEMKIND_CSW_LPAC_PRIV_NON_SECURE, 258: /** @HFI_MEMKIND_MEMSTORE: Buffer used to query a context's GPU sop/eop timestamps */ 259: HFI_MEMKIND_MEMSTORE, 260: /** @HFI_MEMKIND_HW_FENCE: Hardware fence Tx/Rx headers and queues */ 261: HFI_MEMKIND_HW_FENCE, 262: /** @HFI_MEMKIND_PREEMPT_SCRATCH: Used for Preemption scratch memory */ 263: HFI_MEMKIND_PREEMPT_SCRATCH, 264: /** 265: * @HFI_MEMKIND_AQE_BUFFER: Sandbox memory used by AQE to switch 266: * between LPAC and GC 267: */ 268: HFI_MEMKIND_AQE_BUFFER, 269: /** @HFI_MEMKIND_HW_FENCE_SHADOW: Shadow memory used for caching external input fences */ 270: HFI_MEMKIND_HW_FENCE_SHADOW, 271: /** 272: * @HFI_MEMKIND_FREQMGR_SCRATCH: Scratch memory for FreqMgr task to retain information 273: * related to GMU based DCVS. 274: */ 275: HFI_MEMKIND_FREQMGR_SCRATCH, 276: /** 277: * @HFI_MEMKIND_DUMMY_CSW_PRIV_NON_SECURE: Used for requesting privileged non 278: * secure preemption records for the internal dummy buffer 279: */ 280: HFI_MEMKIND_DUMMY_CSW_PRIV_NON_SECURE, 281: /** 282: * @HFI_MEMKIND_DUMMY_CSW_COUNTER: Used for requesting preemption performance 283: * counter save/restore buffer for the internal dummy buffer 284: */ 285: HFI_MEMKIND_DUMMY_CSW_COUNTER, 286: HFI_MEMKIND_MAX, 287: }; 288: 289: static const char * const hfi_memkind_strings[] = { 290: [HFI_MEMKIND_GENERIC] = "GMU GENERIC", 291: [HFI_MEMKIND_RB] = "GMU RB", 292: [HFI_MEMKIND_SCRATCH] = "GMU SCRATCH", 293: [HFI_MEMKIND_CSW_SMMU_INFO] = "GMU SMMU INFO", 294: [HFI_MEMKIND_CSW_PRIV_NON_SECURE] = "GMU CSW PRIV NON SECURE", 295: [HFI_MEMKIND_CSW_PRIV_SECURE] = "GMU CSW PRIV SECURE", 296: [HFI_MEMKIND_CSW_NON_PRIV] = "GMU CSW NON PRIV", 297: [HFI_MEMKIND_CSW_COUNTER] = "GMU CSW COUNTER", 298: [HFI_MEMKIND_CTXTREC_PREEMPT_CNTR] = "GMU PREEMPT CNTR", 299: [HFI_MEMKIND_SYS_LOG] = "GMU SYS LOG", 300: [HFI_MEMKIND_CRASH_DUMP] = "GMU CRASHDUMP", 301: [HFI_MEMKIND_MMIO_DPU] = "GMU MMIO DPU", 302: [HFI_MEMKIND_MMIO_TCSR] = "GMU MMIO TCSR", 303: [HFI_MEMKIND_MMIO_QDSS_STM] = "GMU MMIO QDSS STM", 304: [HFI_MEMKIND_PROFILE] = "GMU KERNEL PROFILING", 305: [HFI_MEMKIND_USER_PROFILE_IBS] = "GMU USER PROFILING", 306: [HFI_MEMKIND_CMD_BUFFER] = "GMU CMD BUFFER", 307: [HFI_MEMKIND_GPU_BUSY_DATA_BUFFER] = "GMU BUSY DATA BUFFER", 308: [HFI_MEMKIND_GPU_BUSY_CMD_BUFFER] = "GMU BUSY CMD BUFFER", 309: [HFI_MEMKIND_MMIO_IPC_CORE] = "GMU MMIO IPC", 310: [HFI_MEMKIND_MMIO_IPCC_AOSS] = "GMU MMIO IPCC AOSS", 311: [HFI_MEMKIND_CSW_LPAC_PRIV_NON_SECURE] = "GMU CSW LPAC PRIV NON SECURE", 312: [HFI_MEMKIND_MEMSTORE] = "GMU MEMSTORE", 313: [HFI_MEMKIND_HW_FENCE] = "GMU HW FENCE", 314: [HFI_MEMKIND_PREEMPT_SCRATCH] = "GMU PREEMPTION", 315: [HFI_MEMKIND_AQE_BUFFER] = "GMU AQE BUFFER", 316: [HFI_MEMKIND_HW_FENCE_SHADOW] = "GMU HW FENCE SHADOW", 317: [HFI_MEMKIND_FREQMGR_SCRATCH] = "GMU FREQMGR SCRATCH", 318: [HFI_MEMKIND_DUMMY_CSW_PRIV_NON_SECURE] = "GMU DUMMY CSW PRIV NON SECURE", 319: [HFI_MEMKIND_DUMMY_CSW_COUNTER] = "GMU DUMMY CSW COUNTER", 320: [HFI_MEMKIND_MAX] = "GMU UNKNOWN", 321: }; 322: 323: /* CP/GFX pipeline can access */ 324: #define HFI_MEMFLAG_GFX_ACC BIT(0) 325: 326: /* Buffer has APRIV protection in GFX PTEs */ 327: #define HFI_MEMFLAG_GFX_PRIV BIT(1) 328: 329: /* Buffer is read-write for GFX PTEs. A 0 indicates read-only */ 330: #define HFI_MEMFLAG_GFX_WRITEABLE BIT(2) 331: 332: /* GMU can access */ 333: #define HFI_MEMFLAG_GMU_ACC BIT(3) 334: 335: /* Buffer has APRIV protection in GMU PTEs */ 336: #define HFI_MEMFLAG_GMU_PRIV BIT(4) 337: 338: /* Buffer is read-write for GMU PTEs. A 0 indicates read-only */ 339: #define HFI_MEMFLAG_GMU_WRITEABLE BIT(5) 340: 341: /* Buffer is located in GMU's non-cached bufferable VA range */ 342: #define HFI_MEMFLAG_GMU_BUFFERABLE BIT(6) 343: 344: /* Buffer is located in GMU's cacheable VA range */ 345: #define HFI_MEMFLAG_GMU_CACHEABLE BIT(7) 346: 347: /* Host can access */ 348: #define HFI_MEMFLAG_HOST_ACC BIT(8) 349: 350: /* Host initializes(zero-init) the buffer */ 351: #define HFI_MEMFLAG_HOST_INIT BIT(9) 352: 353: /* Gfx buffer needs to be secure */ 354: #define HFI_MEMFLAG_GFX_SECURE BIT(12) 355: 356: /** 357: * struct hfi_queue_table_header - HFI queue table structure 358: * @version: HFI protocol version 359: * @size: queue table size in dwords 360: * @qhdr0_offset: first queue header offset (dwords) in this table 361: * @qhdr_size: queue header size 362: * @num_q: number of queues defined in this table 363: * @num_active_q: number of active queues 364: */ 365: struct hfi_queue_table_header { 366: u32 version; 367: u32 size; 368: u32 qhdr0_offset; 369: u32 qhdr_size; 370: u32 num_q; 371: u32 num_active_q; 372: } __packed; 373: 374: /** 375: * struct gmu_context_queue_header - GMU context queue header structure 376: */ 377: struct gmu_context_queue_header { 378: /** @version: Version of the header */ 379: u32 version; 380: /** @start_addr: GMU VA of start of the queue */ 381: u32 start_addr; 382: /** @queue_size: queue size in dwords */ 383: u32 queue_size; 384: /** @out_fence_ts: Timestamp of last hardware fence sent to Tx Queue */ 385: volatile u32 out_fence_ts; 386: /** @sync_obj_ts: Timestamp of last sync object that GMU has digested */ 387: volatile u32 sync_obj_ts; 388: /** @read_index: Read index of the queue */ 389: volatile u32 read_index; 390: /** @write_index: Write index of the queue */ 391: volatile u32 write_index; 392: /** 393: * @hw_fence_buffer_va: GMU VA of the buffer to store output hardware fences for this 394: * context 395: */ 396: u32 hw_fence_buffer_va; 397: /** 398: * @hw_fence_buffer_size: Size of the buffer to store output hardware fences for this 399: * context 400: */ 401: u32 hw_fence_buffer_size; 402: u32 unused1; 403: u32 unused2; 404: u32 unused3; 405: } __packed; 406: 407: /** 408: * struct hfi_queue_header - HFI queue header structure 409: * @status: active: 1; inactive: 0 410: * @start_addr: starting address of the queue in GMU VA space 411: * @type: queue type encoded the priority, ID and send/recevie types 412: * @queue_size: size of the queue 413: * @msg_size: size of the message if each message has fixed size. 414: * Otherwise, 0 means variable size of message in the queue. 415: * @read_index: read index of the queue 416: * @write_index: write index of the queue 417: */ 418: struct hfi_queue_header { 419: u32 status; 420: u32 start_addr; 421: u32 type; 422: u32 queue_size; 423: u32 msg_size; 424: u32 unused0; 425: u32 unused1; 426: u32 unused2; 427: u32 unused3; 428: u32 unused4; 429: volatile u32 read_index; 430: volatile u32 write_index; 431: } __packed; 432: 433: #define HFI_MSG_CMD 0 /* V1 and V2 */ 434: #define HFI_MSG_ACK 1 /* V2 only */ 435: 436: /* Used to NOP a command when executing warmboot sequence */ 437: #define HFI_MSG_NOP BIT(18) 438: /* Used to record a command when executing coldboot sequence */ 439: #define HFI_MSG_RECORD BIT(19) 440: 441: #define HFI_V1_MSG_POST 1 /* V1 only */ 442: #define HFI_V1_MSG_ACK 2/* V1 only */ 443: 444: #define MSG_HDR_SET_SIZE(hdr, size) \ 445: (((size & 0xFF) << 8) | hdr) 446: 447: #define CREATE_MSG_HDR(id, type) \ 448: (((type) << 16) | ((id) & 0xFF)) 449: 450: #define ACK_MSG_HDR(id) CREATE_MSG_HDR(id, HFI_MSG_ACK) 451: 452: #define HFI_QUEUE_DEFAULT_CNT 3 453: #define HFI_QUEUE_DISPATCH_MAX_CNT 14 454: #define HFI_QUEUE_HDR_MAX (HFI_QUEUE_DEFAULT_CNT + HFI_QUEUE_DISPATCH_MAX_CNT) 455: 456: struct hfi_queue_table { 457: struct hfi_queue_table_header qtbl_hdr; 458: struct hfi_queue_header qhdr[HFI_QUEUE_HDR_MAX]; 459: } __packed; 460: 461: #define HFI_QUEUE_OFFSET(i) \ 462: (ALIGN(sizeof(struct hfi_queue_table), SZ_16) + \ 463: ((i) * HFI_QUEUE_SIZE)) 464: 465: #define GMU_QUEUE_START_ADDR(gmuaddr, i) \ 466: (gmuaddr + HFI_QUEUE_OFFSET(i)) 467: 468: #define HOST_QUEUE_START_ADDR(hfi_mem, i) \ 469: ((hfi_mem)->hostptr + HFI_QUEUE_OFFSET(i)) 470: 471: #define MSG_HDR_GET_ID(hdr) ((hdr) & 0xFF) 472: #define MSG_HDR_GET_SIZE(hdr) (((hdr) >> 8) & 0xFF) 473: #define MSG_HDR_GET_TYPE(hdr) (((hdr) >> 16) & 0xF) 474: #define MSG_HDR_GET_SEQNUM(hdr) (((hdr) >> 20) & 0xFFF) 475: 476: /* Clear the HFI_MSG_RECORD bit from both headers since some acks may have it set, and some not. */ 477: #define CMP_HFI_ACK_HDR(sent, rcvd) ((sent &= ~HFI_MSG_RECORD) == (rcvd &= ~HFI_MSG_RECORD)) 478: 479: #define MSG_HDR_SET_SEQNUM(hdr, num) \ 480: (((hdr) & 0xFFFFF) | ((num) << 20)) 481: 482: #define MSG_HDR_SET_SEQNUM_SIZE(hdr, seqnum, sizedwords) \ 483: (FIELD_PREP(GENMASK(31, 20), seqnum) | FIELD_PREP(GENMASK(15, 8), sizedwords) | hdr) 484: 485: #define MSG_HDR_SET_TYPE(hdr, type) \ 486: (((hdr) & 0xFFFFF) | ((type) << 16)) 487: 488: #define QUEUE_HDR_TYPE(id, prio, rtype, stype) \ 489: (((id) & 0xFF) | (((prio) & 0xFF) << 8) | \ 490: (((rtype) & 0xFF) << 16) | (((stype) & 0xFF) << 24)) 491: 492: #define HFI_RSP_TIMEOUT 1000 /* msec */ 493: 494: #define HFI_IRQ_MSGQ_MASK BIT(0) 495: 496: enum hfi_msg_type { 497: H2F_MSG_INIT = 0, 498: H2F_MSG_FW_VER = 1, 499: H2F_MSG_LM_CFG = 2, 500: H2F_MSG_BW_VOTE_TBL = 3, 501: H2F_MSG_PERF_TBL = 4, 502: H2F_MSG_TEST = 5, 503: H2F_MSG_ACD_TBL = 7, 504: H2F_MSG_CLX_TBL = 8, 505: H2F_MSG_THERM_TBL = 9, 506: H2F_MSG_START = 10, 507: H2F_MSG_FEATURE_CTRL = 11, 508: H2F_MSG_GET_VALUE = 12, 509: H2F_MSG_SET_VALUE = 13, 510: H2F_MSG_CORE_FW_START = 14, 511: H2F_MSG_TABLE = 15, 512: F2H_MSG_MEM_ALLOC = 20, 513: H2F_MSG_GX_BW_PERF_VOTE = 30, 514: H2F_MSG_FW_HALT = 32, 515: H2F_MSG_PREPARE_SLUMBER = 33, 516: F2H_MSG_ERR = 100, 517: F2H_MSG_DEBUG = 101, 518: F2H_MSG_LOG_BLOCK = 102, 519: F2H_MSG_GMU_CNTR_REGISTER = 110, 520: F2H_MSG_GMU_CNTR_RELEASE = 111, 521: F2H_MSG_ACK = 126, /* Deprecated for v2.0*/ 522: H2F_MSG_ACK = 127, /* Deprecated for v2.0*/ 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, 561: }; 562: 563: enum gmu_rail_domain { 564: GMU_GX_DOMAIN = 0, 565: GMU_MX_DOMAIN, 566: GMU_DOMAIN_MAX, 567: }; 568: 569: enum gmu_limits_mit_feature { 570: GMU_MIT_IFF = 0, 571: GMU_MIT_PCLX, 572: GMU_MIT_MAX, 573: }; 574: 575: /* H2F */ 576: struct hfi_gmu_init_cmd { 577: u32 hdr; 578: u32 seg_id; 579: u32 dbg_buffer_addr; 580: u32 dbg_buffer_size; 581: u32 boot_state; 582: } __packed; 583: 584: /* H2F */ 585: struct hfi_fw_version_cmd { 586: u32 hdr; 587: u32 supported_ver; 588: } __packed; 589: 590: /* H2F */ 591: struct hfi_bwtable_cmd { 592: u32 hdr; 593: u32 bw_level_num; 594: u32 cnoc_cmds_num; 595: u32 ddr_cmds_num; 596: u32 cnoc_wait_bitmask; 597: u32 ddr_wait_bitmask; 598: u32 cnoc_cmd_addrs[MAX_CNOC_CMDS]; 599: u32 cnoc_cmd_data[MAX_CNOC_LEVELS][MAX_CNOC_CMDS]; 600: u32 ddr_cmd_addrs[MAX_BW_CMDS]; 601: u32 ddr_cmd_data[MAX_BW_LEVELS][MAX_BW_CMDS]; 602: } __packed; 603: 604: struct opp_gx_desc { 605: u32 vote; 606: /* This is 'acdLvl' in gmu fw which is now repurposed for various dependency votes */ 607: u32 dep_vote; 608: u32 freq; 609: } __packed; 610: 611: struct opp_desc { 612: u32 vote; 613: u32 freq; 614: } __packed; 615: 616: /* H2F */ 617: struct hfi_dcvstable_v1_cmd { 618: u32 hdr; 619: u32 gpu_level_num; 620: u32 gmu_level_num; 621: struct opp_desc gx_votes[MAX_GX_LEVELS_LEGACY]; 622: struct opp_desc cx_votes[MAX_CX_LEVELS_LEGACY]; 623: } __packed; 624: 625: /* H2F */ 626: struct hfi_dcvstable_cmd { 627: u32 hdr; 628: u32 gpu_level_num; 629: u32 gmu_level_num; 630: struct opp_gx_desc gx_votes[MAX_GX_LEVELS_LEGACY]; 631: struct opp_desc cx_votes[MAX_CX_LEVELS_LEGACY]; 632: } __packed; 633: 634: /* H2F */ 635: struct hfi_table_entry { 636: u32 count; 637: u32 stride; 638: u32 data[]; 639: } __packed; 640: 641: struct hfi_table_cmd { 642: u32 hdr; 643: u32 version; 644: u32 type; 645: struct hfi_table_entry entry[]; 646: } __packed; 647: 648: #define MAX_ACD_STRIDE 2 649: #define MAX_ACD_NUM_LEVELS KGSL_MAX_PWRLEVELS 650: 651: /* H2F */ 652: struct hfi_acd_table_cmd { 653: u32 hdr; 654: u32 version; 655: u32 enable_by_level; 656: u32 stride; 657: u32 num_levels; 658: u32 data[MAX_ACD_NUM_LEVELS * MAX_ACD_STRIDE]; 659: } __packed; 660: 661: #define CLX_DOMAINS_V2 2 662: struct clx_domain_v2 { 663: /** 664: * @data0: bits[0:15] Migration time 665: * bits[16:21] Current rating 666: * bits[22:27] Phases for domain 667: * bits[28:28] Path notifications 668: * bits[29:31] Extra feature bits 669: */ 670: u32 data0; 671: /** @clxt: CLX time in microseconds */ 672: u32 clxt; 673: /** @clxh: CLH time in microseconds */ 674: u32 clxh; 675: /** @urgmode: Urgent HW throttle mode of operation */ 676: u32 urgmode; 677: /** @lkgen: Enable leakage current estimate */ 678: u32 lkgen; 679: /** @currbudget: Current Budget */ 680: u32 currbudget; 681: } __packed; 682: 683: /* H2F */ 684: struct hfi_clx_table_v2_cmd { 685: /** @hdr: HFI header message */ 686: u32 hdr; 687: /** @version: Version identifier for the format used for domains */ 688: u32 version; 689: /** @domain: GFX and MXC Domain information */ 690: struct clx_domain_v2 domain[CLX_DOMAINS_V2]; 691: } __packed; 692: 693: struct limits_mitigation_cfg { 694: /** @enable: Enable limits mitigation for this domain */ 695: u32 enable; 696: /** @msg_path: Message notification path */ 697: u32 msg_path; 698: /** 699: * @lkgen: bits[0:0] Static or dynamic leakage 700: * bits[1:31] Static leakage value 701: */ 702: u32 lkgen; 703: /** @mode: 704: * bit[0]: Static or dynamic throttle 705: * 0 = (static) throttle to fixed sid level 706: * 1 = (dynamic) throttle to sid lievel calculated by HW 707: * bit[1]: select Mx/Bx,Mx = 0 , Bx =1, unused field for gx 708: */ 709: u32 mode; 710: /** @sid_val: SID value for static throttle */ 711: u32 sid_val; 712: /** @mit_time: Mitigation time in microseconds */ 713: u32 mit_time; 714: /** @curr_limit: Max current in mA during mitigation */ 715: u32 curr_limit; 716: } __packed; 717: 718: /* H2F */ 719: struct hfi_limits_mit_tbl { 720: /** @feature_id: Value from enum gmu_limits_mit_feature */ 721: u8 feature_id; 722: /** @domain: Value from enum gmu_rail_domain */ 723: u8 domain; 724: /** @feature_rev: Feature revision */ 725: u16 feature_rev; 726: /** @mit_cfg: Mitigation config */ 727: struct limits_mitigation_cfg mit_cfg; 728: } __packed; 729: 730: /* H2F */ 731: struct hfi_test_cmd { 732: u32 hdr; 733: u32 data; 734: } __packed; 735: 736: /* H2F */ 737: struct hfi_start_cmd { 738: u32 hdr; 739: } __packed; 740: 741: /* H2F */ 742: struct hfi_feature_ctrl_cmd { 743: u32 hdr; 744: u32 feature; 745: u32 enable; 746: u32 data; 747: } __packed; 748: 749: /* H2F */ 750: struct hfi_get_value_cmd { 751: u32 hdr; 752: u32 type; 753: u32 subtype; 754: } __packed; 755: 756: /* Internal */ 757: struct hfi_get_value_req { 758: struct hfi_get_value_cmd cmd; 759: u32 data[16]; 760: } __packed; 761: 762: /* F2H */ 763: struct hfi_get_value_reply_cmd { 764: u32 hdr; 765: u32 req_hdr; 766: u32 data[16]; 767: } __packed; 768: 769: /* H2F */ 770: struct hfi_set_value_cmd { 771: u32 hdr; 772: u32 type; 773: u32 subtype; 774: u32 data; 775: } __packed; 776: 777: /* H2F */ 778: struct hfi_core_fw_start_cmd { 779: u32 hdr; 780: u32 handle; 781: } __packed; 782: 783: struct hfi_mem_alloc_desc_legacy { 784: u64 gpu_addr; 785: u32 flags; 786: u32 mem_kind; 787: u32 host_mem_handle; 788: u32 gmu_mem_handle; 789: u32 gmu_addr; 790: u32 size; /* Bytes */ 791: } __packed; 792: 793: struct hfi_mem_alloc_desc { 794: u64 gpu_addr; 795: u32 flags; 796: u32 mem_kind; 797: u32 host_mem_handle; 798: u32 gmu_mem_handle; 799: u32 gmu_addr; 800: u32 size; /* Bytes */ 801: /** 802: * @align: bits[0:7] specify alignment requirement of the GMU VA specified as a power of 803: * two. bits[8:15] specify alignment requirement for the size of the GMU mapping. For 804: * example, a decimal value of 20 = (1 << 20) = 1 MB alignment 805: */ 806: u32 align; 807: } __packed; 808: 809: struct hfi_mem_alloc_entry { 810: struct hfi_mem_alloc_desc desc; 811: struct kgsl_memdesc *md; 812: }; 813: 814: /* F2H */ 815: struct hfi_mem_alloc_cmd_legacy { 816: u32 hdr; 817: u32 reserved; /* Padding to ensure alignment of 'desc' below */ 818: struct hfi_mem_alloc_desc_legacy desc; 819: } __packed; 820: 821: struct hfi_mem_alloc_cmd { 822: u32 hdr; 823: u32 version; 824: struct hfi_mem_alloc_desc desc; 825: } __packed; 826: 827: /* H2F */ 828: struct hfi_mem_alloc_reply_cmd { 829: u32 hdr; 830: u32 req_hdr; 831: struct hfi_mem_alloc_desc desc; 832: } __packed; 833: 834: /* H2F */ 835: struct hfi_gx_bw_perf_vote_cmd { 836: u32 hdr; 837: u32 ack_type; 838: u32 freq; 839: u32 bw; 840: } __packed; 841: 842: /* H2F */ 843: struct hfi_fw_halt_cmd { 844: u32 hdr; 845: u32 en_halt; 846: } __packed; 847: 848: /* H2F */ 849: struct hfi_prep_slumber_cmd { 850: u32 hdr; 851: u32 bw; 852: u32 freq; 853: } __packed; 854: 855: /* F2H */ 856: struct hfi_err_cmd { 857: u32 hdr; 858: u32 error_code; 859: u32 data[16]; 860: } __packed; 861: 862: /* F2H */ 863: struct hfi_debug_cmd { 864: u32 hdr; 865: u32 type; 866: u32 timestamp; 867: u32 data; 868: } __packed; 869: 870: /* F2H */ 871: struct hfi_trace_cmd { 872: u32 hdr; 873: u32 version; 874: u64 identifier; 875: } __packed; 876: 877: /* Trace packet definition */ 878: struct gmu_trace_packet { 879: u32 hdr; 880: u32 trace_id; 881: u64 ticks; 882: u32 payload[]; 883: } __packed; 884: 885: /* F2H */ 886: struct hfi_gmu_cntr_register_cmd { 887: u32 hdr; 888: u32 group_id; 889: u32 countable; 890: } __packed; 891: 892: /* H2F */ 893: struct hfi_gmu_cntr_register_reply_cmd { 894: u32 hdr; 895: u32 req_hdr; 896: u32 group_id; 897: u32 countable; 898: u32 cntr_lo; 899: u32 cntr_hi; 900: } __packed; 901: 902: /* F2H */ 903: struct hfi_gmu_cntr_release_cmd { 904: u32 hdr; 905: u32 group_id; 906: u32 countable; 907: } __packed; 908: 909: /* H2F */ 910: struct hfi_register_ctxt_cmd { 911: u32 hdr; 912: u32 ctxt_id; 913: u32 flags; 914: u64 pt_addr; 915: u32 ctxt_idr; 916: u32 ctxt_bank; 917: } __packed; 918: 919: /* H2F */ 920: struct hfi_unregister_ctxt_cmd { 921: u32 hdr; 922: u32 ctxt_id; 923: u32 ts; 924: } __packed; 925: 926: struct hfi_issue_ib { 927: u64 addr; 928: u32 size; 929: } __packed; 930: 931: /* H2F */ 932: /* The length of *buf will be embedded in the hdr */ 933: struct hfi_issue_cmd_raw_cmd { 934: u32 hdr; 935: u32 *buf; 936: } __packed; 937: 938: /* Internal */ 939: struct hfi_issue_cmd_raw_req { 940: u32 queue; 941: u32 ctxt_id; 942: u32 len; 943: u32 *buf; 944: } __packed; 945: 946: /* H2F */ 947: struct hfi_ts_notify_cmd { 948: u32 hdr; 949: u32 ctxt_id; 950: u32 ts; 951: } __packed; 952: 953: #define CMDBATCH_SUCCESS 0 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; 1007: u32 dcvs_profile_addr; 1008: } __packed; 1009: 1010: /* H2F */ 1011: struct hfi_context_rule_cmd { 1012: u32 hdr; 1013: u32 ctxt_id; 1014: u32 type; 1015: u32 sub_type; 1016: } __packed; 1017: 1018: struct fault_info { 1019: u32 ctxt_id; 1020: u32 policy; 1021: u32 ts; 1022: } __packed; 1023: 1024: /* F2H */ 1025: struct hfi_context_bad_cmd { 1026: u32 hdr; 1027: u32 version; 1028: struct fault_info gc; 1029: struct fault_info lpac; 1030: u32 error; 1031: u32 payload[]; 1032: } __packed; 1033: 1034: /* F2H */ 1035: struct hfi_context_bad_cmd_legacy { 1036: u32 hdr; 1037: u32 ctxt_id; 1038: u32 policy; 1039: u32 ts; 1040: u32 error; 1041: u32 payload[]; 1042: } __packed; 1043: 1044: /* H2F */ 1045: struct hfi_msg_ret_cmd { 1046: u32 hdr; 1047: u32 req_hdr; 1048: u32 error; 1049: } __packed; 1050: 1051: /* H2F */ 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*/ 1128: u32 scratch_size; 1129: } __packed; 1130: 1131: /* Request GMU to add this fence to TxQueue without checking whether this is retired or not */ 1132: #define HW_FENCE_FLAG_SKIP_MEMSTORE 0x1 1133: 1134: struct hfi_hw_fence_info { 1135: /** @hdr: Header for the fence info packet */ 1136: u32 hdr; 1137: /** @version: Version of the fence info packet */ 1138: u32 version; 1139: /** @gmu_ctxt_id: GMU Context id to which this fence belongs */ 1140: u32 gmu_ctxt_id; 1141: /** @error: Any error code associated with this fence */ 1142: u32 error; 1143: /** @ctxt_id: Context id for which hw fence is to be triggered */ 1144: u64 ctxt_id; 1145: /** @ts: Timestamp for which hw fence is to be triggered */ 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 */ 1219: struct hfi_profile_register { 1220: /** @header: Header for the profile register packet */ 1221: struct hfi_msg_platform header; 1222: /** @version: Version of the profile register packet */ 1223: u32 version; 1224: /** @gmu_addr: Address of the GMU to store DCVS profile */ 1225: u32 gmu_addr; 1226: /** @attrs_addr: Address of the KGSL shared profile attrs */ 1227: u32 attrs_addr; 1228: } __packed; 1229: 1230: static inline int _CMD_MSG_HDR(u32 *hdr, int id, size_t size) 1231: { 1232: if (WARN_ON(size > HFI_MAX_MSG_SIZE)) 1233: return -EMSGSIZE; 1234: 1235: *hdr = CREATE_MSG_HDR(id, HFI_MSG_CMD); 1236: return 0; 1237: } 1238: 1239: #define CMD_MSG_HDR(cmd, id) \ 1240: _CMD_MSG_HDR(&(cmd).hdr, id, sizeof(cmd)) 1241: 1242: #define RECORD_MSG_HDR(hdr) \ 1243: ((hdr) | HFI_MSG_RECORD) 1244: 1245: #define CLEAR_RECORD_MSG_HDR(hdr) \ 1246: ((hdr) & (~(HFI_MSG_RECORD | HFI_MSG_NOP))) 1247: 1248: #define RECORD_NOP_MSG_HDR(hdr) \ 1249: ((hdr) | (HFI_MSG_RECORD | HFI_MSG_NOP)) 1250: 1251: /* Maximum number of IBs in a submission */ 1252: #define HWSCHED_MAX_DISPATCH_NUMIBS \ 1253: ((HFI_MAX_MSG_SIZE - sizeof(struct hfi_submit_cmd)) \ 1254: / sizeof(struct hfi_issue_ib)) 1255: 1256: /** 1257: * struct payload_section - Container of keys values 1258: * 1259: * There may be a variable number of payload sections appended 1260: * to the context bad HFI message. Each payload section contains 1261: * a variable number of key-value pairs, both key and value being 1262: * single dword each. 1263: */ 1264: struct payload_section { 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: MATCH LINES: 1332, 1334, 1336, 1338, 1340, 1342, 1344, 1346, 1348, 1350, 1352, 1354, 1356, 1358, 1360, 1362, 1364, 1366, 1368, 1370, 1372, 1374, 1376, 1377, 1378, 1379, 1380, 1381, 1382, 1383, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1406, 1407, 1408, 1409, 1410, 1411, 1413, 1416, 1446, 1447, 1448, 1451, 1452, 1453, 1457, 1466, 1478, 1488, 1506, 1513, 1515, 1516, 1525, 1533, 1541, 1549 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 */ 1352: #define GMU_CP_BV_OPCODE_ERROR 610 1353: /* GPU BV encountered protected mode error */ 1354: #define GMU_CP_BV_PROTECTED_ERROR 611 1355: /* GPU BV encountered a CP hw fault error */ 1356: #define GMU_CP_BV_HW_FAULT_ERROR 612 1357: /* GPU BV encountered a CP ucode error */ 1358: #define GMU_CP_BV_UCODE_ERROR 613 1359: /* GPU BV encountered an illegal instruction */ 1360: #define GMU_CP_BV_ILLEGAL_INST_ERROR 614 1361: /* GPU encountered a bad LPAC opcode */ 1362: #define GMU_CP_LPAC_OPCODE_ERROR 615 1363: /* GPU LPAC encountered a CP ucode error */ 1364: #define GMU_CP_LPAC_UCODE_ERROR 616 1365: /* GPU LPAC encountered a CP hw fault error */ 1366: #define GMU_CP_LPAC_HW_FAULT_ERROR 617 1367: /* GPU LPAC encountered protected mode error */ 1368: #define GMU_CP_LPAC_PROTECTED_ERROR 618 1369: /* GPU LPAC encountered an illegal instruction */ 1370: #define GMU_CP_LPAC_ILLEGAL_INST_ERROR 619 1371: /* Fault due to LPAC Long IB timeout */ 1372: #define GMU_GPU_LPAC_SW_HANG 620 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 1410: #define GMU_UCHE_TRAP_INTR 654 1411: #define GMU_TSB_WRITE_ERROR 655 1412: /* DBGC interrupt */ 1413: #define GMU_DBGC_INTR_ERROR 656 1414: 1415: /* GPU encountered an unknown CP error */ 1416: #define GMU_CP_UNKNOWN_ERROR 700 1417: 1418: #define GPU_DCVS_TUNING_INVALID_VALUE 0xffffffff 1419: #define GPU_DCVS_TUNING_INVALID_ACK_DATA 0xfffffffe 1420: 1421: /** 1422: * Keep this enum in sync with dcvs_tunables_strings[]. Each index in this enum must correspond 1423: * to the matching string entry. 1424: */ 1425: enum gpu_tuning_attr { 1426: GPU_TUNING_KEY_BUSY_PENALTY_UP = 0, 1427: GPU_TUNING_KEY_BUSY_PENALTY_DOWN = 1, 1428: GPU_TUNING_KEY_FIRST_STEP_DOWN_COUNT = 2, 1429: GPU_TUNING_KEY_SUBSEQUENT_STEP_DOWN_COUNT = 3, 1430: GPU_TUNING_KEY_MIN_GPU_FREQUENCY = 4, 1431: GPU_TUNING_KEY_MAX_GPU_FREQUENCY = 5, 1432: GPU_TUNING_KEY_TARGET_FPS = 6, 1433: GPU_TUNING_KEY_NUM_SAMPLES_UP = 7, 1434: GPU_TUNING_KEY_NUM_SAMPLES_DOWN = 8, 1435: GPU_TUNING_KEY_STRICT_FRAME = 9, 1436: GPU_TUNING_KEY_NON_LINEAR_RAMP_UP = 10, 1437: GPU_TUNING_KEY_NON_LINEAR_RAMP_DOWN = 11, 1438: GPU_TUNING_KEY_MOD_PERCENT = 12, 1439: GPU_TUNING_KEY_BUS_MIN_FREQUENCY = 13, 1440: GPU_TUNING_KEY_BUS_MAX_FREQUENCY = 14, 1441: GPU_TUNING_KEY_MIN_AB_MBPS = 15, 1442: GPU_TUNING_KEY_MAX_AB_MBPS = 16, 1443: GPU_TUNING_KEY_MAX, 1444: }; 1445: 1446: /* Macro for subtype of the HFI_VALUE_DCVS_TUNING_PARAM property */ 1447: #define HFI_DCVS_ATTRS_DEFAULT 0 1448: #define HFI_DCVS_ATTRS_AGGREGATED 1 1449: 1450: enum gpu_dcvs_profile_action { 1451: GMU_DCVS_PROFILE_REGISTER = 1, 1452: GMU_DCVS_PROFILE_ACTIVATE = 2, 1453: GMU_DCVS_PROFILE_DEACTIVATE = 3, 1454: }; 1455: 1456: /** 1457: * hfi_update_read_idx - Update the read index of an hfi queue 1458: * hdr: Pointer to the hfi queue header 1459: * index: New read index 1460: * 1461: * This function makes sure that kgsl has consumed f2h packets 1462: * before GMU sees the updated read index. This avoids a corner 1463: * case where GMU might over-write f2h packets that have not yet 1464: * been consumed by kgsl. 1465: */ 1466: static inline void hfi_update_read_idx(struct hfi_queue_header *hdr, u32 index) 1467: { 1468: /* 1469: * This is to make sure packets are consumed before gmu sees the updated 1470: * read index 1471: */ 1472: mb(); 1473: 1474: hdr->read_index = index; 1475: } 1476: 1477: /** 1478: * hfi_update_write_idx - Update the write index of a GMU queue 1479: * write_idx: Pointer to the write index 1480: * index: New write index 1481: * 1482: * This function makes sure that the h2f packets are written out 1483: * to memory before GMU sees the updated write index. This avoids 1484: * corner cases where GMU might fetch stale entries that can happen 1485: * if write index is updated before new packets have been written 1486: * out to memory. 1487: */ 1488: static inline void hfi_update_write_idx(volatile u32 *write_idx, u32 index) 1489: { 1490: /* 1491: * This is to make sure packets are written out before gmu sees the 1492: * updated write index 1493: */ 1494: wmb(); 1495: 1496: *write_idx = index; 1497: 1498: /* 1499: * Memory barrier to make sure write index is written before an 1500: * interrupt is raised 1501: */ 1502: wmb(); 1503: } 1504: 1505: /** 1506: * hfi_get_mem_alloc_desc - Get the descriptor from F2H_MSG_MEM_ALLOC packet 1507: * rcvd: Pointer to the F2H_MSG_MEM_ALLOC packet 1508: * out: Pointer to copy the descriptor data to 1509: * 1510: * This function checks for the F2H_MSG_MEM_ALLOC packet version and based on that gets the 1511: * descriptor data from the packet. 1512: */ 1513: static inline void hfi_get_mem_alloc_desc(void *rcvd, struct hfi_mem_alloc_desc *out) 1514: { 1515: struct hfi_mem_alloc_cmd_legacy *in_legacy = (struct hfi_mem_alloc_cmd_legacy *)rcvd; 1516: struct hfi_mem_alloc_cmd *in = (struct hfi_mem_alloc_cmd *)rcvd; 1517: 1518: if (in->version > 0) 1519: memcpy(out, &in->desc, sizeof(in->desc)); 1520: else 1521: memcpy(out, &in_legacy->desc, sizeof(in_legacy->desc)); 1522: } 1523: 1524: /** 1525: * hfi_get_gmu_va_alignment - Get the alignment (in bytes) for a GMU VA 1526: * align: Alignment specified as a power of two (2^n) in bits[0:7] 1527: * 1528: * This function derives the GMU VA alignment in bytes from bits[0:7] in the passed in value, which 1529: * is specified in terms of power of two (2^n). For example, va_align = 20 means (1 << 20) = 1MB 1530: * alignment. The minimum alignment (in bytes) is SZ_4K i.e. anything less than (or equal to) a 1531: * va_align value of ilog2(SZ_4K) will default to SZ_4K alignment. 1532: */ 1533: static inline u32 hfi_get_gmu_va_alignment(u32 align) 1534: { 1535: u32 va_align = FIELD_GET(GENMASK(7, 0), align); 1536: 1537: return (va_align > ilog2(SZ_4K)) ? (1 << va_align) : SZ_4K; 1538: } 1539: 1540: /** 1541: * hfi_get_gmu_sz_alignment - Get the alignment (in bytes) for GMU mapping size 1542: * align: Alignment specified as a power of two (2^n) in bits[8:15] 1543: * 1544: * This function derives the GMU VA size alignment in bytes from bits[8:15] in the passed in value, 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: /** MATCH LINES: 1593, 1596, 1598, 1599, 1603, 1605, 1610, 1611, 1613, 1614, 1616, 1617, 1619, 1620, 1622, 1623, 1625, 1626, 1636, 1643 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: 1614: snprintf(hfi_minidump_str, size, KGSL_SCRATCH_ENTRY); 1615: break; 1616: case HFI_MEMKIND_PROFILE: 1617: snprintf(hfi_minidump_str, size, KGSL_GMU_KERNEL_PROF_ENTRY); 1618: break; 1619: case HFI_MEMKIND_USER_PROFILE_IBS: 1620: snprintf(hfi_minidump_str, size, KGSL_GMU_USER_PROF_ENTRY); 1621: break; 1622: case HFI_MEMKIND_CMD_BUFFER: 1623: snprintf(hfi_minidump_str, size, KGSL_GMU_CMD_BUFFER_ENTRY); 1624: break; 1625: case HFI_MEMKIND_MEMSTORE: 1626: snprintf(hfi_minidump_str, size, KGSL_MEMSTORE_ENTRY); 1627: break; 1628: default: 1629: return -EINVAL; 1630: } 1631: 1632: return 0; 1633: } 1634: 1635: /** 1636: * hfi_feature_to_string - Convert an HFI feature value to its 1637: * string representation 1638: * @feature: HFI feature value to convert 1639: * 1640: * Return: Pointer to a string representing the given feature. 1641: * If the feature is unknown, the function returns "unknown". 1642: */ 1643: const char *hfi_feature_to_string(u32 feature); 1644: #endif --- FILE: \adreno_hwsched.c | HITS: 139 --- MATCH LINES: 53, 55, 60, 63, 66, 71, 74, 84, 87, 88, 89, 95, 101, 111, 120, 123, 126, 127, 128, 129, 133, 147, 163, 170, 172, 175, 188, 189, 195, 198, 205, 206, 209, 211, 215, 216, 221, 222, 227, 235, 239, 240, 241, 242, 244, 245, 248, 250, 260, 266, 267, 270, 273, 276, 277, 284, 286, 297, 318, 325, 327, 334, 352, 354, 362, 369, 374, 379, 383, 398, 431, 451, 454 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) 61: *priv |= KGSL_MEMDESC_PRIVILEGED; 62: 63: if (!(desc_flags & HFI_MEMFLAG_GFX_WRITEABLE)) 64: *flags |= KGSL_MEMFLAGS_GPUREADONLY; 65: 66: if (desc_flags & HFI_MEMFLAG_GFX_SECURE) 67: *flags |= KGSL_MEMFLAGS_SECURE; 68: } 69: 70: static int reserve_preempt_record_va(struct adreno_device *adreno_dev, 71: struct hfi_mem_alloc_entry *entry, u64 flags, u32 priv) 72: { 73: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 74: struct hfi_mem_alloc_desc *desc = &entry->desc; 75: int ret = 0; 76: 77: if (!entry->md->gpuaddr) { 78: ret = kgsl_get_global_gpuaddr(device, entry->md, 79: desc->size, flags, priv); 80: if (ret) 81: return ret; 82: } 83: 84: if (!(entry->desc.flags & HFI_MEMFLAG_GMU_ACC)) 85: return ret; 86: 87: if (!entry->md->gmuaddr) 88: ret = gmu_core_reserve_gmuaddr(device, entry->md, 89: get_gmu_vma_id(desc->flags), desc->align); 90: 91: return ret; 92: } 93: 94: static int alloc_map_preempt_record(struct adreno_device *adreno_dev, 95: struct kgsl_memdesc **md, struct hfi_mem_alloc_entry *entry, u64 offset, 96: u64 flags, u32 priv) 97: { 98: u64 ctxt_record_size = adreno_dev->total_ctxt_record_sz; 99: u64 curr_gmem_size = adreno_gmem_size(adreno_dev); 100: u64 md_size = ctxt_record_size - curr_gmem_size; 101: struct hfi_mem_alloc_desc *desc = &entry->desc; 102: 103: if (*md) 104: return 0; 105: 106: if (offset >= (entry->md->size)) 107: return -ENOSPC; 108: 109: *md = kgsl_alloc_map_gpu_global(KGSL_DEVICE(adreno_dev), 110: entry->md->gpuaddr + offset, md_size, 0, flags, priv, 111: (entry->desc.mem_kind == HFI_MEMKIND_CSW_PRIV_SECURE) ? 112: "sec_preempt_record_non_gmem" : "preempt_record_non_gmem"); 113: if (IS_ERR(*md)) { 114: int ret = PTR_ERR(*md); 115: 116: *md = NULL; 117: return ret; 118: } 119: 120: if (!(desc->flags & HFI_MEMFLAG_GMU_ACC)) 121: return 0; 122: 123: if ((*md)->gmuaddr) 124: return 0; 125: 126: return gmu_core_map_gmu(KGSL_DEVICE(adreno_dev), *md, 127: entry->md->gmuaddr + offset, 128: get_gmu_vma_id(desc->flags), 129: gmu_core_get_attrs(desc->flags), desc->align); 130: } 131: 132: static int alloc_map_non_gmem(struct adreno_device *adreno_dev, 133: struct hfi_mem_alloc_entry *entry, u64 flags, u32 priv) 134: { 135: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 136: u64 ctxt_record_sz = adreno_dev->total_ctxt_record_sz, offset = 0; 137: u64 curr_gmem_size = adreno_gmem_size(adreno_dev); 138: bool no_rb0_gmem = false; 139: int i; 140: 141: /* Check whether GMU has removed GMEM size from RB0 context record */ 142: if (entry->desc.size == ((ctxt_record_sz * KGSL_PRIORITY_MAX_RB_LEVELS) - 143: curr_gmem_size)) 144: no_rb0_gmem = true; 145: 146: for (i = 0; i < KGSL_PRIORITY_MAX_RB_LEVELS; i++) { 147: struct kgsl_memdesc **md = (entry->desc.mem_kind == HFI_MEMKIND_CSW_PRIV_SECURE) ? 148: &hwsched->secure_preempt_rec[i] : &hwsched->preempt_rec[i]; 149: int ret = alloc_map_preempt_record(adreno_dev, md, entry, offset, flags, priv); 150: 151: if (ret) 152: return ret; 153: 154: offset += ctxt_record_sz; 155: if ((i == 0) && no_rb0_gmem) 156: offset -= curr_gmem_size; 157: } 158: 159: return 0; 160: } 161: 162: static int process_preempt_record_mem_alloc(struct adreno_device *adreno_dev, 163: struct hfi_mem_alloc_entry *entry) 164: { 165: u64 flags = 0; 166: u32 priv = 0; 167: int ret; 168: 169: if (!entry->md) { 170: struct gmu_core_device *gmu = &KGSL_DEVICE(adreno_dev)->gmu_core; 171: 172: if (gmu->global_entries == ARRAY_SIZE(gmu->gmu_globals)) 173: return -ENOMEM; 174: 175: entry->md = &gmu->gmu_globals[gmu->global_entries]; 176: gmu->global_entries++; 177: } 178: 179: setup_gfx_flags_priv(entry->desc.flags, &flags, &priv); 180: 181: ret = reserve_preempt_record_va(adreno_dev, entry, flags, priv); 182: if (ret) 183: return ret; 184: 185: return alloc_map_non_gmem(adreno_dev, entry, flags, priv); 186: } 187: 188: static struct hfi_mem_alloc_entry *lookup_mem_alloc_table( 189: struct adreno_device *adreno_dev, struct hfi_mem_alloc_desc *desc) 190: { 191: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 192: int i; 193: 194: for (i = 0; i < hwsched->mem_alloc_entries; i++) { 195: struct hfi_mem_alloc_entry *entry = &hwsched->mem_alloc_table[i]; 196: 197: if ((entry->desc.mem_kind == desc->mem_kind) && 198: (entry->desc.gmu_mem_handle == desc->gmu_mem_handle)) 199: return entry; 200: } 201: 202: return NULL; 203: } 204: 205: static struct hfi_mem_alloc_entry *get_mem_alloc_entry( 206: struct adreno_device *adreno_dev, struct hfi_mem_alloc_desc *desc) 207: { 208: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 209: struct device *gmu_pdev_dev = GMU_PDEV_DEV(device); 210: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 211: struct hfi_mem_alloc_entry *entry = lookup_mem_alloc_table(adreno_dev, desc); 212: u64 flags = 0; 213: u32 priv = 0; 214: int ret; 215: const char *memkind_string = desc->mem_kind < HFI_MEMKIND_MAX ? 216: hfi_memkind_strings[desc->mem_kind] : "UNKNOWN"; 217: 218: if (entry) 219: return entry; 220: 221: if (desc->mem_kind >= HFI_MEMKIND_MAX) { 222: dev_err(gmu_pdev_dev, "Invalid mem kind: %d\n", desc->mem_kind); 223: return ERR_PTR(-EINVAL); 224: } 225: 226: if (hwsched->mem_alloc_entries == ARRAY_SIZE(hwsched->mem_alloc_table)) { 227: dev_err(gmu_pdev_dev, "Reached max mem alloc entries\n"); 228: return ERR_PTR(-ENOMEM); 229: } 230: 231: entry = &hwsched->mem_alloc_table[hwsched->mem_alloc_entries]; 232: 233: memcpy(&entry->desc, desc, sizeof(*desc)); 234: 235: entry->desc.host_mem_handle = desc->gmu_mem_handle; 236: 237: setup_gfx_flags_priv(desc->flags, &flags, &priv); 238: 239: if (!(desc->flags & HFI_MEMFLAG_GFX_ACC) && 240: (desc->mem_kind != HFI_MEMKIND_HW_FENCE)) { 241: if (desc->mem_kind == HFI_MEMKIND_MMIO_IPC_CORE) 242: entry->md = gmu_core_reserve_kernel_block_fixed(device, 0, 243: desc->size, 244: get_gmu_vma_id(desc->flags), 245: "qcom,ipc-core", gmu_core_get_attrs(desc->flags), 246: desc->align); 247: else 248: entry->md = gmu_core_reserve_kernel_block(device, 0, 249: desc->size, 250: get_gmu_vma_id(desc->flags), 251: desc->align); 252: 253: if (IS_ERR(entry->md)) { 254: ret = PTR_ERR(entry->md); 255: 256: memset(entry, 0, sizeof(*entry)); 257: return ERR_PTR(ret); 258: } 259: entry->desc.size = entry->md->size; 260: entry->desc.gmu_addr = entry->md->gmuaddr; 261: 262: goto done; 263: } 264: 265: /* 266: * Use pre-allocated memory descriptors to map the HFI_MEMKIND_HW_FENCE and 267: * HFI_MEMKIND_MEMSTORE 268: */ 269: switch (desc->mem_kind) { 270: case HFI_MEMKIND_HW_FENCE: 271: entry->md = &adreno_dev->hwsched.hw_fence.md; 272: break; 273: case HFI_MEMKIND_MEMSTORE: 274: entry->md = device->memstore; 275: break; 276: case HFI_MEMKIND_CSW_PRIV_NON_SECURE: 277: case HFI_MEMKIND_CSW_PRIV_SECURE: 278: /* 279: * Standard kernel does not support secure SIDs. But GMU FW 280: * always requests a secure preempt buffer regardless. Back it 281: * with a PAGE_SIZE non-secure dummy buffer to give CP a valid 282: * GPU VA to write to. 283: */ 284: if (desc->mem_kind == HFI_MEMKIND_CSW_PRIV_SECURE && 285: !kgsl_mmu_is_secured(&device->mmu)) { 286: entry->desc.flags &= ~HFI_MEMFLAG_GFX_SECURE; 287: flags &= ~KGSL_MEMFLAGS_SECURE; 288: entry->desc.size = PAGE_SIZE; 289: } 290: if (ADRENO_FEATURE(adreno_dev, ADRENO_DEFER_GMEM_ALLOC)) { 291: ret = process_preempt_record_mem_alloc(adreno_dev, entry); 292: if (ret) 293: return ERR_PTR(ret); 294: 295: entry->desc.size = entry->md->size; 296: entry->desc.gpu_addr = entry->md->gpuaddr; 297: entry->desc.gmu_addr = entry->md->gmuaddr; 298: 299: goto done; 300: } 301: /* Allocate global through legacy approach */ 302: fallthrough; 303: default: 304: entry->md = kgsl_allocate_global(device, entry->desc.size, 0, flags, 305: priv, memkind_string); 306: break; 307: } 308: if (IS_ERR(entry->md)) { 309: ret = PTR_ERR(entry->md); 310: 311: memset(entry, 0, sizeof(*entry)); 312: return ERR_PTR(ret); 313: } 314: 315: entry->desc.size = entry->md->size; 316: entry->desc.gpu_addr = entry->md->gpuaddr; 317: 318: if (!(desc->flags & HFI_MEMFLAG_GMU_ACC)) 319: goto done; 320: 321: /* 322: * If gmu mapping fails, then we have to live with 323: * leaking the gpu global buffer allocated above. 324: */ 325: ret = gmu_core_import_buffer(device, entry); 326: if (ret) { 327: dev_err(gmu_pdev_dev, 328: "gpuaddr: 0x%llx size: %lld bytes lost\n", 329: entry->md->gpuaddr, entry->md->size); 330: memset(entry, 0, sizeof(*entry)); 331: return ERR_PTR(ret); 332: } 333: 334: entry->desc.gmu_addr = entry->md->gmuaddr; 335: done: 336: hwsched->mem_alloc_entries++; 337: 338: return entry; 339: } 340: 341: void adreno_hwsched_retire_cmdlist_obj(struct adreno_device *adreno_dev, 342: struct cmd_list_obj *obj) 343: { 344: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 345: 346: list_del_init(&obj->node); 347: kmem_cache_free(obj_cache, obj); 348: hwsched->inflight--; 349: } 350: 351: int adreno_hwsched_process_mem_alloc(struct adreno_device *adreno_dev, 352: struct hfi_mem_alloc_desc *mad) 353: { 354: struct hfi_mem_alloc_entry *entry; 355: 356: entry = get_mem_alloc_entry(adreno_dev, mad); 357: if (IS_ERR(entry)) 358: return PTR_ERR(entry); 359: 360: if (entry->md) { 361: mad->gpu_addr = entry->md->gpuaddr; 362: mad->gmu_addr = entry->md->gmuaddr; 363: } 364: 365: /* 366: * GMU uses the host_mem_handle to check if this memalloc was 367: * successful 368: */ 369: mad->host_mem_handle = mad->gmu_mem_handle; 370: 371: return 0; 372: } 373: 374: static struct hfi_mem_alloc_entry *get_preempt_record_entry(struct adreno_device *adreno_dev, 375: unsigned long flags) 376: { 377: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 378: u32 mem_kind = flags & KGSL_CONTEXT_SECURE ? 379: HFI_MEMKIND_CSW_PRIV_SECURE : HFI_MEMKIND_CSW_PRIV_NON_SECURE; 380: u32 i; 381: 382: for (i = 0; i < hwsched->mem_alloc_entries; i++) { 383: struct hfi_mem_alloc_entry *entry = &hwsched->mem_alloc_table[i]; 384: 385: if (entry->desc.mem_kind == mem_kind) 386: return entry; 387: } 388: 389: return NULL; 390: } 391: 392: static int adreno_hwsched_alloc_preempt_record_gmem(struct adreno_device *adreno_dev, 393: struct adreno_context *drawctxt) 394: { 395: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 396: struct kgsl_context *context = &drawctxt->base; 397: struct kgsl_device *device = context->device; 398: struct hfi_mem_alloc_entry *entry = NULL; 399: struct kgsl_memdesc *pr_md, **md = NULL; 400: u32 priv = 0, level = adreno_get_level(context); 401: u64 curr_gmem_size = adreno_gmem_size(adreno_dev); 402: u64 flags = 0; 403: int ret = 0; 404: 405: if (context->flags & KGSL_CONTEXT_LPAC) 406: return 0; 407: 408: if (!ADRENO_FEATURE(adreno_dev, ADRENO_PREEMPTION) || 409: !ADRENO_FEATURE(adreno_dev, ADRENO_DEFER_GMEM_ALLOC)) 410: return 0; 411: 412: /* No need to allocate gmem for RB0 preemption record */ 413: if (!level) 414: return 0; 415: 416: md = context->flags & KGSL_CONTEXT_SECURE ? 417: &hwsched->secure_preempt_rec_gmem[level - 1] : 418: &hwsched->preempt_rec_gmem[level - 1]; 419: 420: /* Avoid device mutex if buffer is already allocated */ 421: if (*md) 422: return 0; 423: 424: kgsl_mutex_lock(&device->mutex); 425: 426: if (*md) 427: goto unlock; 428: 429: entry = get_preempt_record_entry(adreno_dev, context->flags); 430: if (!entry) { 431: dev_err_ratelimited(GMU_PDEV_DEV(device), 432: "preempt record entry not found\n"); 433: ret = -EINVAL; 434: goto unlock; 435: } 436: 437: pr_md = context->flags & KGSL_CONTEXT_SECURE ? 438: hwsched->secure_preempt_rec[level] : hwsched->preempt_rec[level]; 439: 440: if ((pr_md->gpuaddr + pr_md->size + curr_gmem_size) > 441: (entry->md->gpuaddr + entry->md->size)) { 442: ret = -ENOSPC; 443: goto unlock; 444: } 445: 446: setup_gfx_flags_priv(entry->desc.flags, &flags, &priv); 447: 448: /* gmem section only needs to be mapped to gpu */ 449: *md = kgsl_alloc_map_gpu_global(device, pr_md->gpuaddr + pr_md->size, 450: curr_gmem_size, 0, flags, priv, 451: (entry->desc.mem_kind == HFI_MEMKIND_CSW_PRIV_SECURE) ? 452: "sec_preempt_record_gmem" : "preempt_record_gmem"); 453: if (!*md) { 454: dev_err_ratelimited(GMU_PDEV_DEV(device), 455: "Failed to allocate gmem preempt record for rb:%d\n", level); 456: ret = PTR_ERR(*md); 457: kfree(*md); 458: } 459: unlock: 460: kgsl_mutex_unlock(&device->mutex); 461: return ret; 462: } 463: 464: static bool is_cmdobj(struct kgsl_drawobj *drawobj) 465: { 466: return (drawobj->type & CMDOBJ_TYPE); 467: } 468: 469: static bool _check_context_queue(struct adreno_context *drawctxt, u32 count) 470: { 471: bool ret; 472: 473: spin_lock(&drawctxt->lock); 474: 475: /* 476: * Wake up if there is room in the context or if the whole thing got 477: * invalidated while we were asleep 478: */ MATCH LINES: 1586 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); MATCH LINES: 1938 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: MATCH LINES: 2146, 2151, 2153, 2185, 2186, 2202, 2203, 2226, 2235, 2237, 2239, 2277, 2278, 2285, 2310, 2311, 2333, 2334, 2354, 2355 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. MATCH LINES: 2401 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: MATCH LINES: 2523 2511: } 2512: 2513: int adreno_hwsched_init(struct adreno_device *adreno_dev, 2514: const struct adreno_hwsched_ops *target_hwsched_ops) 2515: { 2516: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2517: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 2518: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 2519: int i; 2520: 2521: memset(hwsched, 0, sizeof(*hwsched)); 2522: 2523: hwsched->ctxt_bad = kzalloc(HFI_MAX_MSG_SIZE, GFP_KERNEL); 2524: if (!hwsched->ctxt_bad) 2525: return -ENOMEM; 2526: 2527: adreno_dev->scheduler_worker = kgsl_kthread_run_worker(0, "kgsl_hwsched"); 2528: if (IS_ERR(adreno_dev->scheduler_worker)) { 2529: kfree(hwsched->ctxt_bad); 2530: return PTR_ERR(adreno_dev->scheduler_worker); 2531: } 2532: 2533: mutex_init(&hwsched->mutex); 2534: 2535: kthread_init_work(&adreno_dev->scheduler_work, adreno_hwsched_work); 2536: 2537: jobs_cache = KMEM_CACHE(adreno_dispatch_job, 0); 2538: obj_cache = KMEM_CACHE(cmd_list_obj, 0); 2539: 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); MATCH LINES: 2612, 2613, 2626, 2654, 2661, 2664, 2667, 2668 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: 2682: return 0; 2683: } 2684: 2685: static int hwsched_idle(struct adreno_device *adreno_dev) 2686: { 2687: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2688: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 2689: int ret; 2690: 2691: /* Block any new submissions from being submitted */ 2692: adreno_get_gpu_halt(adreno_dev); MATCH LINES: 2822, 2855, 2863 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: */ MATCH LINES: 2925, 2933, 2955, 2963 2913: 2914: /* Each key-value pair is 2 dwords */ 2915: for (i = 0; i < payload->dwords; i += 2) { 2916: if (payload->data[i] == key) 2917: return payload->data[i + 1]; 2918: } 2919: 2920: return 0; 2921: } 2922: 2923: u32 adreno_hwsched_get_payload_rb_key_legacy(struct adreno_device *adreno_dev, u32 rb_id, u32 key) 2924: { 2925: struct hfi_context_bad_cmd_legacy *cmd = adreno_dev->hwsched.ctxt_bad; 2926: u32 i = 0, payload_bytes; 2927: void *start; 2928: 2929: if (!cmd->hdr) 2930: return 0; 2931: 2932: payload_bytes = (MSG_HDR_GET_SIZE(cmd->hdr) << 2) - 2933: offsetof(struct hfi_context_bad_cmd_legacy, payload); 2934: 2935: start = &cmd->payload[0]; 2936: 2937: while (i < payload_bytes) { 2938: struct payload_section *payload = start + i; 2939: 2940: if (payload->type == PAYLOAD_RB) { 2941: u32 id = adreno_hwsched_parse_payload(payload, KEY_RB_ID); 2942: 2943: if (id == rb_id) 2944: return adreno_hwsched_parse_payload(payload, key); 2945: } 2946: 2947: i += struct_size(payload, data, payload->dwords); 2948: } 2949: 2950: return 0; 2951: } 2952: 2953: u32 adreno_hwsched_get_payload_rb_key(struct adreno_device *adreno_dev, u32 rb_id, u32 key) 2954: { 2955: struct hfi_context_bad_cmd *cmd = adreno_dev->hwsched.ctxt_bad; 2956: u32 i = 0, payload_bytes; 2957: void *start; 2958: 2959: if (!cmd->hdr) 2960: return 0; 2961: 2962: payload_bytes = (MSG_HDR_GET_SIZE(cmd->hdr) << 2) - 2963: offsetof(struct hfi_context_bad_cmd, payload); 2964: 2965: start = &cmd->payload[0]; 2966: 2967: while (i < payload_bytes) { 2968: struct payload_section *payload = start + i; 2969: 2970: if (payload->type == PAYLOAD_RB) { 2971: u32 id = adreno_hwsched_parse_payload(payload, KEY_RB_ID); 2972: 2973: if (id == rb_id) 2974: return adreno_hwsched_parse_payload(payload, key); 2975: } 2976: 2977: i += struct_size(payload, data, payload->dwords); 2978: } 2979: 2980: return 0; 2981: } 2982: 2983: void adreno_hwsched_log_remove_pending_hw_fences(struct adreno_device *adreno_dev, 2984: struct device *dev) 2985: { 2986: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2987: struct adreno_hw_fence_entry entries[5]; MATCH LINES: 3024, 3032, 3060, 3070, 3073, 3076, 3079, 3082, 3100, 3102, 3103, 3104 3012: 3013: dev_err(dev, "%d hw fences may not be signaled. %s are:\n", count, 3014: count > 5 ? "First 5" : "They"); 3015: 3016: for (i = 0; (i < count) && (i < ARRAY_SIZE(entries)); i++) 3017: dev_err(dev, "%d: ctx=%llu seqno=%llu\n", i, entries[i].cmd.ctxt_id, 3018: entries[i].cmd.ts); 3019: } 3020: 3021: static void adreno_hwsched_lookup_key_value(struct adreno_device *adreno_dev, 3022: u32 type, u32 key, u32 *ptr, u32 num_values) 3023: { 3024: struct hfi_context_bad_cmd *cmd = adreno_dev->hwsched.ctxt_bad; 3025: u32 i = 0, payload_bytes; 3026: void *start; 3027: 3028: if (!cmd->hdr) 3029: return; 3030: 3031: payload_bytes = (MSG_HDR_GET_SIZE(cmd->hdr) << 2) - 3032: offsetof(struct hfi_context_bad_cmd, payload); 3033: 3034: start = &cmd->payload[0]; 3035: 3036: while (i < payload_bytes) { 3037: struct payload_section *payload = start + i; 3038: 3039: /* key-value pair is 'num_values + 1' dwords */ 3040: if ((payload->type == type) && (payload->data[i] == key)) { 3041: u32 j = 1; 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; 3079: case GMU_UCHE_TRAP_INTR: 3080: dev_crit_ratelimited(dev, "UCHE: Trap interrupt\n"); 3081: break; 3082: case GMU_TSB_WRITE_ERROR: { 3083: u32 addr[2]; 3084: 3085: adreno_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 3086: KEY_TSB_WRITE_ERROR, addr, 2); 3087: dev_crit_ratelimited(dev, "TSB: Write error interrupt: Address: 0x%lx MID: %lu\n", 3088: FIELD_GET(GENMASK(16, 0), addr[1]) << 32 | addr[0], 3089: FIELD_GET(GENMASK(31, 23), addr[1])); 3090: break; 3091: } 3092: default: 3093: non_fatal = false; 3094: break; 3095: } 3096: 3097: return non_fatal; 3098: } 3099: 3100: int adreno_hwsched_poll_msg_queue_write_index(struct kgsl_memdesc *hfi_mem) 3101: { 3102: struct hfi_queue_table *tbl = hfi_mem->hostptr; 3103: struct hfi_queue_header *hdr = &tbl->qhdr[HFI_MSG_ID]; 3104: unsigned long timeout = jiffies + msecs_to_jiffies(HFI_RSP_TIMEOUT); 3105: 3106: while (time_before(jiffies, timeout)) { 3107: if (hdr->write_index != hdr->read_index) 3108: goto done; 3109: 3110: /* Wait for up to 100 us before trying again */ 3111: usleep_range((POLL_SLEEP_US >> 2) + 1, POLL_SLEEP_US); 3112: cpu_relax(); 3113: } 3114: 3115: /* Check if the write index has advanced */ 3116: if (hdr->write_index == hdr->read_index) 3117: return -ETIMEDOUT; 3118: 3119: done: 3120: /* 3121: * This is to ensure that the queue is not read speculatively before the 3122: * polling condition is evaluated. 3123: */ 3124: rmb(); 3125: 3126: return 0; 3127: } 3128: MATCH LINES: 3196, 3211, 3212, 3215, 3217 3184: 3185: /* Get the timeofday for the wall time (for the user) */ 3186: ktime_get_real_ts64(&time->utime); 3187: 3188: local_irq_restore(flags); 3189: 3190: /* Return kernel clock time to the client if requested */ 3191: time_in_s = time->ktime; 3192: time_in_ns = do_div(time_in_s, 1000000000); 3193: 3194: info.inflight = hwsched->inflight; 3195: info.rb_id = adreno_get_level(context); 3196: info.gmu_dispatch_queue = context->gmu_dispatch_queue; 3197: 3198: cmdobj->submit_ticks = time->ticks; 3199: 3200: msm_perf_events_update(MSM_PERF_GFX, MSM_PERF_SUBMIT, 3201: pid_nr(context->proc_priv->pid), 3202: context->id, drawobj->timestamp, 3203: !!(drawobj->flags & KGSL_DRAWOBJ_END_OF_FRAME)); 3204: trace_adreno_cmdbatch_submitted(drawobj, &info, time->ticks, 3205: (unsigned long) time_in_s, time_in_ns / 1000, 0); 3206: 3207: log_kgsl_cmdbatch_submitted_event(context->id, drawobj->timestamp, 3208: context->priority, drawobj->flags); 3209: } 3210: 3211: int adreno_gmu_context_queue_write(struct adreno_device *adreno_dev, 3212: struct kgsl_memdesc *gmu_context_queue, u32 *msg, u32 size_bytes, 3213: struct kgsl_drawobj *drawobj, struct adreno_submit_time *time) 3214: { 3215: struct gmu_context_queue_header *hdr = gmu_context_queue->hostptr; 3216: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 3217: u32 *queue = gmu_context_queue->hostptr + sizeof(*hdr); 3218: u32 i, empty_space, write_idx = hdr->write_index, read_idx = hdr->read_index; 3219: u32 size_dwords = size_bytes >> 2; 3220: u32 align_size = ALIGN(size_dwords, SZ_4); 3221: u32 id = MSG_HDR_GET_ID(*msg); 3222: struct kgsl_drawobj_cmd *cmdobj = NULL; 3223: 3224: empty_space = (write_idx >= read_idx) ? 3225: (hdr->queue_size - (write_idx - read_idx)) 3226: : (read_idx - write_idx); 3227: 3228: if (empty_space <= align_size) 3229: return -ENOSPC; 3230: 3231: if (!IS_ALIGNED(size_bytes, sizeof(u32))) 3232: return -EINVAL; 3233: 3234: for (i = 0; i < size_dwords; i++) { 3235: queue[write_idx] = msg[i]; 3236: write_idx = (write_idx + 1) % hdr->queue_size; 3237: } 3238: 3239: /* Cookify any non used data at the end of the write buffer */ 3240: for (; i < align_size; i++) { 3241: queue[write_idx] = 0xfafafafa; MATCH LINES: 3265, 3272, 3274, 3303, 3319, 3330, 3334 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) 3280: { 3281: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 3282: int ret = adreno_drain(device, msecs_to_jiffies(100)); 3283: 3284: /* Make sure the dispatcher and hardware are idle */ 3285: if (!ret) 3286: ret = adreno_hwsched_idle(adreno_dev); 3287: 3288: return ret; 3289: } 3290: 3291: static void _retire_inflight_hw_fences(struct adreno_device *adreno_dev, 3292: struct kgsl_context *context) 3293: { 3294: struct adreno_context *drawctxt = ADRENO_CONTEXT(context); 3295: struct adreno_hw_fence_entry *entry, *tmp; 3296: 3297: if (!test_bit(ADRENO_HWSCHED_HW_FENCE, &adreno_dev->hwsched.flags)) 3298: return; 3299: 3300: spin_lock(&drawctxt->lock); 3301: 3302: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_inflight_list, node) { 3303: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr; 3304: 3305: /* 3306: * Since this list is sorted by timestamp, abort on the first fence that hasn't 3307: * yet been sent to TxQueue 3308: */ 3309: if (timestamp_cmp((u32)entry->cmd.ts, hdr->out_fence_ts) > 0) 3310: break; 3311: 3312: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 3313: } 3314: spin_unlock(&drawctxt->lock); 3315: } 3316: 3317: void adreno_hwsched_log_profiling_info(struct adreno_device *adreno_dev, u32 *rcvd) 3318: { 3319: struct hfi_ts_retire_cmd *cmd = (struct hfi_ts_retire_cmd *)rcvd; 3320: struct kgsl_context *context; 3321: struct retire_info info = {0}; 3322: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 3323: 3324: context = kgsl_context_get(device, cmd->ctxt_id); 3325: if (context == NULL) 3326: return; 3327: 3328: info.timestamp = cmd->ts; 3329: info.rb_id = adreno_get_level(context); 3330: info.gmu_dispatch_queue = context->gmu_dispatch_queue; 3331: info.submitted_to_rb = cmd->submitted_to_rb; 3332: info.sop = cmd->sop; 3333: info.eop = cmd->eop; 3334: if (GMU_VER_MINOR(device->gmu_core.ver.hfi) < 4) 3335: info.active = cmd->eop - cmd->sop; 3336: else 3337: info.active = cmd->active; 3338: info.retired_on_gmu = cmd->retired_on_gmu; 3339: 3340: /* protected GPU work must not be reported */ 3341: if (!(context->flags & KGSL_CONTEXT_SECURE)) 3342: kgsl_work_period_update(device, context->proc_priv->period, 3343: info.active); 3344: 3345: trace_adreno_cmdbatch_retired(context, &info, 0, 0, 0); 3346: 3347: log_kgsl_cmdbatch_retired_event(context->id, cmd->ts, 3348: context->priority, 0, cmd->sop, cmd->eop); 3349: 3350: _retire_inflight_hw_fences(adreno_dev, context); 3351: 3352: kgsl_context_put(context); 3353: } 3354: 3355: void *adreno_hwsched_get_rb_hostptr(struct adreno_device *adreno_dev, 3356: u64 gpuaddr, u32 size) 3357: { 3358: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; MATCH LINES: 3374, 3381, 3383 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: 21 --- MATCH LINES: 62 50: struct rproc *soccp_rproc; 51: /** @hw_fence_md: Kgsl memory descriptor for hardware fences queue */ 52: struct kgsl_memdesc md; 53: /** @pending_count: Number of hardware fences that haven't yet been sent to Tx Queue */ 54: u32 pending_count; 55: }; 56: 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); MATCH LINES: 104, 105, 106, 121, 159, 160 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 */ 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 */ 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 **/ MATCH LINES: 222, 254, 257 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: 375, 379, 390, 398, 402, 405, 413, 414 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 395: * 396: * Return: 0 on success or negative error on failure 397: */ 398: int adreno_gmu_context_queue_read(struct adreno_context *drawctxt, u32 *output, 399: u32 read_idx, u32 size); 400: 401: /** 402: * adreno_gmu_context_queue_write - Write data to context queue 403: * 404: * @adreno_dev: Pointer to adreno device structure 405: * @gmu_context_queue: Pointer to the memory descriptor for context queue 406: * @msg: Pointer to the message data to be written 407: * @size_bytes: Size of the message data in bytes 408: * @drawobj: Pointer to the draw object 409: * @time: Pointer to the submission time information 410: * 411: * Return: 0 on success or negative error on failure 412: */ 413: int adreno_gmu_context_queue_write(struct adreno_device *adreno_dev, 414: struct kgsl_memdesc *gmu_context_queue, u32 *msg, u32 size_bytes, 415: struct kgsl_drawobj *drawobj, struct adreno_submit_time *time); 416: 417: /** 418: * adreno_hwsched_add_profile_events - Add profiling events 419: * 420: * @adreno_dev: Pointer to the adreno device structure 421: * @cmdobj: Pointer to the command object 422: * @time: Pointer to the submission time information 423: */ 424: void adreno_hwsched_add_profile_events(struct adreno_device *adreno_dev, 425: struct kgsl_drawobj_cmd *cmdobj, struct adreno_submit_time *time); 426: 427: /** 428: * adreno_hwsched_log_profiling_info - Log profiling information for a retired 429: * command batch 430: * @adreno_dev: Pointer to the adreno device structure 431: * @rcvd: Pointer to the received HFI timestamp retire command 432: */ 433: void adreno_hwsched_log_profiling_info(struct adreno_device *adreno_dev, u32 *rcvd); 434: 435: /** 436: * adreno_hwsched_drawobj_replay - Check drawobj need to be replayed or not 437: * @adreno_dev: Pointer to the adreno device structure 438: * @drawobj: Pointer to the draw object MATCH LINES: 462, 467, 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: 10 --- MATCH LINES: 123, 133, 154, 164 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 = MATCH LINES: 216, 218, 221, 222, 224, 225 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); --- FILE: \adreno_ioctl.c | HITS: 2 --- MATCH LINES: 72, 91 60: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 61: struct kgsl_perfcounter_get *get = data; 62: int result; 63: 64: kgsl_mutex_lock(&device->mutex); 65: 66: /* 67: * adreno_perfcounter_get() is called by kernel clients 68: * during start(), so it is not safe to take an 69: * active count inside that function. 70: */ 71: 72: result = adreno_perfcntr_active_oob_get(adreno_dev); 73: if (result) { 74: kgsl_mutex_unlock(&device->mutex); 75: return (long)result; 76: } 77: 78: result = adreno_perfcounter_get(adreno_dev, 79: get->groupid, get->countable, &get->offset, 80: &get->offset_hi, PERFCOUNTER_FLAG_NONE); 81: 82: /* Add the perfcounter into the list */ 83: if (!result) { 84: result = adreno_process_perfcounter_add(dev_priv, get->groupid, 85: get->countable); 86: if (result) 87: adreno_perfcounter_put(adreno_dev, get->groupid, 88: get->countable, PERFCOUNTER_FLAG_NONE); 89: } 90: 91: adreno_perfcntr_active_oob_put(adreno_dev); 92: 93: kgsl_mutex_unlock(&device->mutex); 94: 95: return (long) result; 96: } 97: 98: long adreno_ioctl_perfcounter_put(struct kgsl_device_private *dev_priv, 99: unsigned int cmd, void *data) 100: { 101: struct kgsl_device *device = dev_priv->device; 102: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 103: struct kgsl_perfcounter_put *put = data; 104: int result; 105: 106: kgsl_mutex_lock(&device->mutex); 107: 108: /* Delete the perfcounter from the process list */ 109: result = adreno_process_perfcounter_del(dev_priv, put->groupid, 110: put->countable); 111: 112: /* Put the perfcounter refcount */ 113: if (!result) 114: adreno_perfcounter_put(adreno_dev, put->groupid, 115: put->countable, PERFCOUNTER_FLAG_NONE); --- FILE: \adreno_perfcounter.c | HITS: 3 --- MATCH LINES: 60 48: group->load(adreno_dev, &group->regs[counter]); 49: } 50: } 51: } 52: 53: /** 54: * adreno_perfcounter_save() - Save performance counters 55: * @adreno_dev: adreno device to configure 56: * 57: * Save the performance counter values before GPU power collapse. 58: * The saved values are restored on restart. 59: * This ensures physical counters are coherent across power-collapse. 60: * This function must be called with the oob_gpu set request. 61: */ 62: inline void adreno_perfcounter_save(struct adreno_device *adreno_dev) 63: { 64: const struct adreno_perfcounters *counters = 65: ADRENO_PERFCOUNTERS(adreno_dev); 66: const struct adreno_perfcount_group *group; 67: unsigned int counter, groupid; 68: 69: /* Do not save/restore if not requested */ 70: if (counters == NULL || !adreno_dev->perfcounter) 71: return; 72: 73: for (groupid = 0; groupid < counters->group_count; groupid++) { 74: group = &(counters->groups[groupid]); 75: 76: /* Save the counter values for the group */ 77: for (counter = 0; counter < group->reg_count; counter++) { 78: /* If not active or broken, skip this counter */ 79: if (!active_countable(group->regs[counter].countable)) 80: continue; 81: 82: /* accumulate values for non-loadable counters */ 83: if (group->regs[counter].load_bit >= 0) 84: group->regs[counter].value = 0; MATCH LINES: 179, 215 167: GFP_KERNEL); 168: if (!list) 169: return -ENOMEM; 170: 171: if (copy_from_user(list, reads, 172: sizeof(struct kgsl_perfcounter_read_group) * count)) { 173: ret = -EFAULT; 174: goto done; 175: } 176: 177: kgsl_mutex_lock(&device->mutex); 178: 179: ret = adreno_perfcntr_active_oob_get(adreno_dev); 180: if (ret) { 181: kgsl_mutex_unlock(&device->mutex); 182: goto done; 183: } 184: 185: /* list iterator */ 186: for (j = 0; j < count; j++) { 187: 188: list[j].value = 0; 189: 190: /* Verify that the group ID is within range */ 191: if (list[j].groupid >= counters->group_count) { 192: ret = -EINVAL; 193: break; 194: } 195: 196: group = &(counters->groups[list[j].groupid]); 197: 198: /* group/counter iterator */ 199: for (i = 0; i < group->reg_count; i++) { 200: if (group->regs[i].countable == list[j].countable) { 201: unsigned long irq_flags; 202: 203: if (!ADRENO_ACQUIRE_CP_SEMAPHORE(adreno_dev, irq_flags)) { 204: ret = -EAGAIN; 205: break; 206: } 207: list[j].value = adreno_perfcounter_read( 208: adreno_dev, list[j].groupid, i); 209: ADRENO_RELEASE_CP_SEMAPHORE(adreno_dev, irq_flags); 210: break; 211: } 212: } 213: } 214: 215: adreno_perfcntr_active_oob_put(adreno_dev); 216: 217: kgsl_mutex_unlock(&device->mutex); 218: 219: /* write the data */ 220: if (ret == 0) 221: if (copy_to_user(reads, list, 222: sizeof(struct kgsl_perfcounter_read_group) * count)) 223: ret = -EFAULT; 224: 225: done: 226: kfree(list); 227: return ret; 228: } 229: 230: /** 231: * adreno_perfcounter_get_groupid() - Get the performance counter ID 232: * @adreno_dev: Adreno device 233: * @name: Performance counter group name string 234: * 235: * Get the groupid based on the name and return this ID 236: */ 237: 238: int adreno_perfcounter_get_groupid(struct adreno_device *adreno_dev, 239: const char *name) --- FILE: \adreno_profile.c | HITS: 2 --- MATCH LINES: 689 677: if (copy_from_user(buf, user_buf, len)) { 678: size = -EFAULT; 679: goto error_free; 680: } 681: 682: kgsl_mutex_lock(&device->mutex); 683: 684: if (adreno_profile_enabled(profile)) { 685: size = -EINVAL; 686: goto error_unlock; 687: } 688: 689: ret = adreno_perfcntr_active_oob_get(adreno_dev); 690: if (ret) { 691: size = ret; 692: goto error_unlock; 693: } 694: 695: /* 696: * When adding/removing assignments, ensure that the GPU is done with 697: * all it's work. This helps to synchronize the work flow to the 698: * GPU and avoid racey conditions. 699: */ 700: ret = adreno_wait_idle(device); 701: if (ret) { 702: size = -ETIMEDOUT; 703: goto error_put; 704: } 705: 706: /* clear all shared buffer results */ 707: adreno_profile_process_results(adreno_dev); 708: 709: pbuf = buf; 710: 711: /* clear the log buffer */ 712: if (profile->log_buffer != NULL) { 713: profile->log_head = profile->log_buffer; MATCH LINES: 737 725: if (groupid < 0 || countable < 0) 726: break; 727: 728: if (remove_assignment) 729: _remove_assignment(adreno_dev, groupid, countable); 730: else 731: _add_assignment(adreno_dev, groupid, countable); 732: } 733: 734: size = len; 735: 736: error_put: 737: adreno_perfcntr_active_oob_put(adreno_dev); 738: error_unlock: 739: kgsl_mutex_unlock(&device->mutex); 740: error_free: 741: kfree(buf); 742: return size; 743: } 744: 745: static int _pipe_print_pending(char __user *ubuf, size_t max) 746: { 747: loff_t unused = 0; 748: char str[] = "Operation Would Block!"; 749: 750: return simple_read_from_buffer(ubuf, max, 751: &unused, str, strlen(str)); 752: } 753: 754: static int _pipe_print_results(struct adreno_device *adreno_dev, 755: char __user *ubuf, size_t max) 756: { 757: struct adreno_profile *profile = &adreno_dev->profile; 758: const char *grp_name; 759: char __user *usr_buf = ubuf; 760: unsigned int *log_ptr = NULL, *tmp_log_ptr = NULL; 761: int len, i; --- FILE: \adreno_rpmh.c | HITS: 3 --- MATCH LINES: 167 155: return; 156: 157: for (i = 0; votes->cmds && i < votes->num_levels; i++) 158: kfree(votes->cmds[i]); 159: 160: kfree(votes->cmds); 161: kfree(votes->addrs); 162: kfree(votes); 163: } 164: 165: struct rpmh_bw_votes *adreno_rpmh_build_bw_votes(struct bcm *bcms, int bcm_count, 166: u32 *levels, int levels_count, u32 perfmode_vote, u32 perfmode_lvl, 167: bool gmu_ab) 168: { 169: struct rpmh_bw_votes *votes; 170: int i; 171: 172: votes = kzalloc(sizeof(*votes), GFP_KERNEL); 173: if (!votes) 174: return ERR_PTR(-ENOMEM); 175: 176: votes->addrs = kcalloc(bcm_count, sizeof(*votes->cmds), GFP_KERNEL); 177: if (!votes->addrs) { 178: adreno_rpmh_free_bw_votes(votes); 179: return ERR_PTR(-ENOMEM); 180: } 181: 182: votes->cmds = kcalloc(levels_count, sizeof(*votes->cmds), GFP_KERNEL); 183: if (!votes->cmds) { 184: adreno_rpmh_free_bw_votes(votes); 185: return ERR_PTR(-ENOMEM); 186: } 187: 188: votes->num_cmds = bcm_count; 189: votes->num_levels = levels_count; 190: 191: /* Get the cmd-db information for each BCM */ MATCH LINES: 217, 248 205: for (i = 0; i < bcm_count; i++) { 206: if (i == (bcm_count - 1) || bcms[i].vcd != bcms[i + 1].vcd) 207: votes->wait_bitmask |= (1 << i); 208: } 209: 210: for (i = 0; i < levels_count; i++) { 211: votes->cmds[i] = kcalloc(bcm_count, sizeof(u32), GFP_KERNEL); 212: if (!votes->cmds[i]) { 213: adreno_rpmh_free_bw_votes(votes); 214: return ERR_PTR(-ENOMEM); 215: } 216: 217: tcs_cmd_data(bcms, bcm_count, gmu_ab ? levels[i] : 0x0, 218: levels[i], votes->cmds[i], 219: (i >= perfmode_lvl) ? perfmode_vote : 0x0); 220: } 221: 222: return votes; 223: } 224: 225: int adreno_rpmh_to_cx_hlvl(struct rpmh_arc_vals *cx_rail, u32 vlvl, u32 *hlvl) 226: { 227: u32 i; 228: 229: /* 230: * This means that the Gx level doesn't have a dependency on Cx level. 231: * Return the same value to disable cx voting at GMU. 232: */ 233: if (vlvl == 0xffffffff) { 234: *hlvl = vlvl; 235: return 0; 236: } 237: 238: for (i = 0; i < cx_rail->num; i++) { 239: if (cx_rail->val[i] >= vlvl) { 240: *hlvl = i; 241: return 0; 242: } 243: } 244: 245: return -EINVAL; 246: } 247: 248: void adreno_rpmh_build_bw_table_cmd(struct hfi_bwtable_cmd *cmd, struct rpmh_bw_votes *ddr, 249: struct rpmh_bw_votes *cnoc) 250: { 251: u32 i, j; 252: 253: cmd->bw_level_num = ddr->num_levels; 254: cmd->ddr_cmds_num = ddr->num_cmds; 255: cmd->ddr_wait_bitmask = ddr->wait_bitmask; 256: 257: for (i = 0; i < ddr->num_cmds; i++) 258: cmd->ddr_cmd_addrs[i] = ddr->addrs[i]; 259: 260: for (i = 0; i < ddr->num_levels; i++) 261: for (j = 0; j < ddr->num_cmds; j++) 262: cmd->ddr_cmd_data[i][j] = (u32) ddr->cmds[i][j]; 263: 264: if (!cnoc) 265: return; 266: 267: cmd->cnoc_cmds_num = cnoc->num_cmds; 268: cmd->cnoc_wait_bitmask = cnoc->wait_bitmask; 269: 270: for (i = 0; i < cnoc->num_cmds; i++) 271: cmd->cnoc_cmd_addrs[i] = cnoc->addrs[i]; 272: --- FILE: \adreno_rpmh.h | HITS: 6 --- MATCH LINES: 7, 8 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) 2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #ifndef _ADRENO_GMU_RPMH_H 8: #define _ADRENO_GMU_RPMH_H 9: 10: struct rpmh_arc_vals { 11: u32 num; 12: const u16 *val; 13: }; 14: 15: struct bcm { 16: const char *name; 17: u32 buswidth; 18: u32 channels; 19: u32 unit; 20: u16 width; 21: u8 vcd; 22: bool fixed; 23: }; 24: 25: struct bcm_data { 26: __le32 unit; 27: __le16 width; 28: u8 vcd; 29: u8 reserved; 30: }; 31: 32: struct rpmh_bw_votes { MATCH LINES: 97, 102, 116, 120 85: */ 86: void adreno_rpmh_free_bw_votes(struct rpmh_bw_votes *votes); 87: 88: /** 89: * adreno_rpmh_build_bw_votes - Build the votes table from the specified 90: * bandwidth levels 91: * @bcms: Array of BCM structures representing BCMs 92: * @bcm_count: Number of BCMs in the array 93: * @levels: Array of performance levels 94: * @levels_count: Number of performance levels 95: * @perfmode_vote: Performance mode vote 96: * @perfmode_lvl: Initial performance level for performance mode vote 97: * @gmu_ab: Indicate if GMU supports AB vote 98: * 99: * Return: Pointer to the rpmh_bw_votes structure on success, or an error pointer failure 100: */ 101: struct rpmh_bw_votes *adreno_rpmh_build_bw_votes(struct bcm *bcms, int bcm_count, 102: u32 *levels, int levels_count, u32 perfmode_vote, u32 perfmode_lvl, bool gmu_ab); 103: 104: /** 105: * adreno_rpmh_to_cx_hlvl - Convert RPMh VLVL to CX HLVL level 106: * @cx_rail: Pointer to the RPMh ARC values for the CX rail 107: * @vlvl: Voltage level to convert 108: * @hlvl: Pointer to store the resulting CX level 109: * 110: * Return: 0 on success or negative error on failure 111: */ 112: int adreno_rpmh_to_cx_hlvl(struct rpmh_arc_vals *cx_rail, u32 vlvl, u32 *hlvl); 113: 114: /** 115: * adreno_rpmh_build_bw_table_cmd - Build bandwidth table command 116: * @cmd: Pointer to the hfi_bwtable_cmd structure 117: * @ddr: Pointer to the DDR RPMh bandwidth votes 118: * @cnoc: Pointer to the CNOC RPMh bandwidth votes 119: */ 120: void adreno_rpmh_build_bw_table_cmd(struct hfi_bwtable_cmd *cmd, struct rpmh_bw_votes *ddr, 121: struct rpmh_bw_votes *cnoc); 122: #endif --- FILE: \adreno_snapshot.c | HITS: 18 --- MATCH LINES: 1350, 1355, 1370, 1374, 1375, 1376, 1378, 1380, 1382, 1384, 1388, 1390, 1393, 1396, 1397, 1399, 1413, 1417 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; --- FILE: \adreno_snapshot.h | HITS: 4 --- MATCH LINES: 155, 161, 165, 173 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: 15 --- MATCH LINES: 409, 414, 446, 449, 451, 454, 456, 457, 461 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 */ 461: return adreno_power_cycle_bool(adreno_dev, &adreno_dev->gmu_ab, val); 462: } 463: 464: static bool _bcl_show(struct adreno_device *adreno_dev) 465: { 466: return adreno_dev->bcl_enabled; 467: } 468: 469: static int _bcl_store(struct adreno_device *adreno_dev, bool val) 470: { 471: if (!ADRENO_FEATURE(adreno_dev, ADRENO_BCL) || 472: adreno_dev->bcl_enabled == val) 473: return 0; 474: 475: return adreno_power_cycle_bool(adreno_dev, &adreno_dev->bcl_enabled, 476: val); 477: } 478: 479: static bool _clx_show(struct adreno_device *adreno_dev) 480: { 481: return adreno_dev->clx_enabled; 482: } 483: 484: static int _clx_store(struct adreno_device *adreno_dev, bool val) 485: { MATCH LINES: 678, 715, 739, 753, 754, 755 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 731: * @adreno_dev: Pointer to the adreno device 732: * 733: * Initialize many of the adreno specific sysfs files especially for fault 734: * tolerance and power control 735: */ 736: int adreno_sysfs_init(struct adreno_device *adreno_dev) 737: { 738: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 739: struct device *gmu_dev; 740: int ret; 741: 742: ret = sysfs_create_files(&device->dev->kobj, _attr_list); 743: 744: if (!ret) { 745: /* Notify userspace */ 746: kobject_uevent(&device->dev->kobj, KOBJ_ADD); 747: 748: ret = sysfs_create_file(&device->gpu_sysfs_kobj, 749: &gpu_sysfs_attr_gpu_model.attr); 750: } 751: 752: /* Add a soft link for gmu device */ 753: if (gmu_core_isenabled(device)) { 754: gmu_dev = GMU_PDEV_DEV(device); 755: WARN_ON(sysfs_create_link(&device->dev->kobj, &gmu_dev->kobj, "gmu")); 756: } 757: return ret; 758: } 759: --- FILE: \adreno_trace.h | HITS: 18 --- MATCH LINES: 113 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), MATCH LINES: 224 212: __entry->id = drawobj->context->id; 213: __entry->timestamp = drawobj->timestamp; 214: __entry->inflight = info->inflight; 215: __entry->flags = drawobj->flags; 216: __entry->ticks = ticks; 217: __entry->secs = secs; 218: __entry->usecs = usecs; 219: __entry->prio = drawobj->context->priority; 220: __entry->rb_id = info->rb_id; 221: __entry->rptr = info->rptr; 222: __entry->wptr = info->wptr; 223: __entry->q_inflight = q_inflight; 224: __entry->dispatch_queue = info->gmu_dispatch_queue; 225: ), 226: TP_printk( 227: "ctx=%u ctx_prio=%d ts=%u inflight=%d flags=%s ticks=%lld time=%lu.%0lu rb_id=%d r/w=%x/%x, q_inflight=%d dq_id=%d", 228: __entry->id, __entry->prio, __entry->timestamp, 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) MATCH LINES: 275, 300, 314 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 311: ) 312: ); 313: 314: TRACE_EVENT(gmu_event, 315: TP_PROTO(u32 *event_info), 316: TP_ARGS(event_info), 317: TP_STRUCT__entry( 318: __field(u32, event) 319: __field(u32, ticks) 320: __field(u32, data1) 321: __field(u32, data2) 322: ), 323: TP_fast_assign( 324: __entry->event = event_info[0]; 325: __entry->ticks = event_info[1]; 326: __entry->data1 = event_info[2]; 327: __entry->data2 = event_info[3]; 328: ), 329: TP_printk( 330: "event=%08u ticks=%08u data1=0x%08x data2=0x%08x", 331: __entry->event, __entry->ticks, __entry->data1, __entry->data2 332: ) 333: ); 334: 335: TRACE_EVENT(adreno_cmdbatch_sync, 336: TP_PROTO(unsigned int ctx_id, unsigned int ctx_prio, 337: unsigned int timestamp, uint64_t ticks), 338: TP_ARGS(ctx_id, ctx_prio, timestamp, ticks), MATCH LINES: 656 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) 680: __field(unsigned int, status) MATCH LINES: 922, 923, 934, 943, 944, 955, 963, 964, 975 910: TP_printk( 911: "cur_rb_lvl=%d rptr=%x wptr_preempt_end=%x wptr=%x rbbase=%x new_rb_lvl=%d rptr=%x wptr=%x rbbase=%x", 912: __entry->cur_level, __entry->cur_rptr, 913: __entry->cur_wptr_end, __entry->cur_wptr, 914: __entry->cur_rbbase, 915: __entry->new_level, __entry->new_rptr, 916: __entry->new_wptr, __entry->new_rbbase 917: ) 918: ); 919: 920: TRACE_EVENT(adreno_preempt_trigger, 921: TP_PROTO(u32 cur_rb_id, u32 next_rb_id, 922: u32 cntl, u64 gmu_ticks), 923: TP_ARGS(cur_rb_id, next_rb_id, cntl, gmu_ticks), 924: TP_STRUCT__entry( 925: __field(u32, cur) 926: __field(u32, next) 927: __field(u32, cntl) 928: __field(u64, ticks) 929: ), 930: TP_fast_assign( 931: __entry->cur = cur_rb_id; 932: __entry->next = next_rb_id; 933: __entry->cntl = cntl; 934: __entry->ticks = gmu_ticks; 935: ), 936: TP_printk("trigger from id=%d to id=%d cntl=%x ticks=%llu", 937: __entry->cur, __entry->next, __entry->cntl, __entry->ticks 938: ) 939: ); 940: 941: TRACE_EVENT(adreno_preempt_done, 942: TP_PROTO(u32 cur_rb_id, u32 next_rb_id, 943: u32 level, u64 gmu_ticks), 944: TP_ARGS(cur_rb_id, next_rb_id, level, gmu_ticks), 945: TP_STRUCT__entry( 946: __field(u32, cur) 947: __field(u32, next) 948: __field(u32, level) 949: __field(u64, ticks) 950: ), 951: TP_fast_assign( 952: __entry->cur = cur_rb_id; 953: __entry->next = next_rb_id; 954: __entry->level = level; 955: __entry->ticks = gmu_ticks; 956: ), 957: TP_printk("done switch to id=%d from id=%d level=%x ticks=%llu", 958: __entry->next, __entry->cur, __entry->level, __entry->ticks 959: ) 960: ); 961: 962: TRACE_EVENT(adreno_ext_hw_fence_signal, 963: TP_PROTO(u64 context, u64 seq_no, u32 flags, u64 gmu_ticks), 964: TP_ARGS(context, seq_no, flags, gmu_ticks), 965: TP_STRUCT__entry( 966: __field(u64, context) 967: __field(u64, seq_no) 968: __field(u32, flags) 969: __field(u64, ticks) 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) MATCH LINES: 1117, 1118, 1119 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 --- FILE: \gen7_reg.h | HITS: 134 --- MATCH LINES: 47 35: #define GEN7_INT_ISDBCPUIRQ 30 36: #define GEN7_INT_ISDBUNDERDEBUG 31 37: 38: /* CP registers */ 39: #define GEN7_CP_RB_BASE 0x800 40: #define GEN7_CP_RB_BASE_HI 0x801 41: #define GEN7_CP_RB_CNTL 0x802 42: #define GEN7_CP_RB_RPTR_ADDR_LO 0x804 43: #define GEN7_CP_RB_RPTR_ADDR_HI 0x805 44: #define GEN7_CP_RB_RPTR 0x806 45: #define GEN7_CP_RB_WPTR 0x807 46: #define GEN7_CP_SQE_CNTL 0x808 47: #define GEN7_CP_CP2GMU_STATUS 0x812 48: #define GEN7_CP_HW_FAULT 0x821 49: #define GEN7_CP_INTERRUPT_STATUS 0x823 50: #define GEN7_CP_PROTECT_STATUS 0x824 51: #define GEN7_CP_STATUS_1 0x825 52: #define GEN7_CP_SQE_INSTR_BASE_LO 0x830 53: #define GEN7_CP_SQE_INSTR_BASE_HI 0x831 54: #define GEN7_CP_MISC_CNTL 0x840 55: #define GEN7_CP_CHICKEN_DBG 0x841 56: #define GEN7_CP_DBG_ECO_CNTL 0x843 57: #define GEN7_CP_APRIV_CNTL 0x844 58: #define GEN7_CP_SEMAPHORE_REG_0 0x846 59: #define GEN7_CP_PROTECT_CNTL 0x84f 60: #define GEN7_CP_PROTECT_REG 0x850 61: #define GEN7_CP_CONTEXT_SWITCH_CNTL 0x8a0 62: #define GEN7_CP_CONTEXT_SWITCH_SMMU_INFO_LO 0x8a1 63: #define GEN7_CP_CONTEXT_SWITCH_SMMU_INFO_HI 0x8a2 64: #define GEN7_CP_CONTEXT_SWITCH_PRIV_NON_SECURE_RESTORE_ADDR_LO 0x8a3 65: #define GEN7_CP_CONTEXT_SWITCH_PRIV_NON_SECURE_RESTORE_ADDR_HI 0x8a4 66: #define GEN7_CP_CONTEXT_SWITCH_PRIV_SECURE_RESTORE_ADDR_LO 0x8a5 67: #define GEN7_CP_CONTEXT_SWITCH_PRIV_SECURE_RESTORE_ADDR_HI 0x8a6 68: #define GEN7_CP_CONTEXT_SWITCH_NON_PRIV_RESTORE_ADDR_LO 0x8a7 69: #define GEN7_CP_CONTEXT_SWITCH_NON_PRIV_RESTORE_ADDR_HI 0x8a8 70: #define GEN7_CP_CONTEXT_SWITCH_LEVEL_STATUS 0x8ab 71: #define GEN7_CP_PERFCTR_CP_SEL_0 0x8d0 MATCH LINES: 693, 694, 695 681: #define GEN7_RBBM_CLOCK_HYST_TSE_RAS_RBBM 0x0010a 682: #define GEN7_RBBM_CLOCK_CNTL_UCHE 0x0010b 683: #define GEN7_RBBM_CLOCK_CNTL2_UCHE 0x0010c 684: #define GEN7_RBBM_CLOCK_DELAY_UCHE 0x0010f 685: #define GEN7_RBBM_CLOCK_HYST_UCHE 0x00110 686: #define GEN7_RBBM_CLOCK_MODE_VFD 0x00111 687: #define GEN7_RBBM_CLOCK_DELAY_VFD 0x00112 688: #define GEN7_RBBM_CLOCK_HYST_VFD 0x00113 689: #define GEN7_RBBM_CLOCK_MODE_GPC 0x00114 690: #define GEN7_RBBM_CLOCK_DELAY_GPC 0x00115 691: #define GEN7_RBBM_CLOCK_HYST_GPC 0x00116 692: #define GEN7_RBBM_CLOCK_DELAY_HLSQ_2 0x00117 693: #define GEN7_RBBM_CLOCK_CNTL_GMU_GX 0x00118 694: #define GEN7_RBBM_CLOCK_DELAY_GMU_GX 0x00119 695: #define GEN7_RBBM_CLOCK_HYST_GMU_GX 0x0011a 696: #define GEN7_RBBM_CLOCK_MODE_HLSQ 0x0011b 697: #define GEN7_RBBM_CLOCK_DELAY_HLSQ 0x0011c 698: #define GEN7_RBBM_CLOCK_HYST_HLSQ 0x0011d 699: #define GEN7_RBBM_CGC_GLOBAL_LOAD_CMD 0x0011e 700: #define GEN7_RBBM_CGC_P2S_TRIG_CMD 0x0011f 701: #define GEN7_RBBM_CGC_P2S_STATUS 0x00122 702: #define GEN7_RBBM_CLOCK_HYST2_VFD 0x0012f 703: #define GEN7_RBBM_CLOCK_MODE_CP 0x00260 704: #define GEN7_RBBM_CLOCK_MODE_BV_LRZ 0x00284 705: #define GEN7_RBBM_CLOCK_MODE_BV_GRAS 0x00285 706: #define GEN7_RBBM_CLOCK_MODE2_GRAS 0x00286 707: #define GEN7_RBBM_CLOCK_MODE_BV_VFD 0x00287 708: #define GEN7_RBBM_CLOCK_MODE_BV_GPC 0x00288 709: #define GEN7_RBBM_SW_FUSE_INT_STATUS 0x002c0 710: #define GEN7_RBBM_SW_FUSE_INT_MASK 0x002c1 711: 712: /* DBGC_CFG registers */ 713: #define GEN7_DBGC_CFG_DBGBUS_SEL_A 0x600 714: #define GEN7_DBGC_CFG_DBGBUS_SEL_B 0x601 715: #define GEN7_DBGC_CFG_DBGBUS_SEL_C 0x602 716: #define GEN7_DBGC_CFG_DBGBUS_SEL_D 0x603 717: #define GEN7_DBGC_CFG_DBGBUS_CNTLT 0x604 718: #define GEN7_DBGC_CFG_DBGBUS_CNTLM 0x605 719: #define GEN7_DBGC_CFG_DBGBUS_OPL 0x606 MATCH LINES: 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 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, 1192, 1193, 1194, 1195, 1196, 1197, 1198, 1199, 1200, 1201, 1202, 1203, 1204, 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, 1240, 1241, 1244, 1245, 1246, 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259, 1260, 1261, 1262, 1265, 1266, 1269, 1272 1119: #define GEN7_CX_DBGC_PERF_ATB_COUNTER_SEL_2 0x18446 1120: #define GEN7_CX_DBGC_PERF_ATB_COUNTER_SEL_3 0x18447 1121: #define GEN7_CX_DBGC_PERF_ATB_TRIG_INTF_SEL_0 0x18448 1122: #define GEN7_CX_DBGC_PERF_ATB_TRIG_INTF_SEL_1 0x18449 1123: #define GEN7_CX_DBGC_PERF_ATB_DRAIN_CMD 0x1844a 1124: #define GEN7_CX_DBGC_ECO_CNTL 0x18450 1125: #define GEN7_CX_DBGC_AHB_DBG_CNTL 0x18451 1126: #define GEN7_CX_DBGC_CFG_DBGBUS_MISC_MODE 0x18458 1127: #define GEN7_CX_DBGC_TCM_DBG_ADDR 0x18580 1128: #define GEN7_CX_DBGC_TCM_DBG_DATA 0x18581 1129: 1130: /* GMU control registers */ 1131: #define GEN7_GMU_CM3_ITCM_START 0x1b400 1132: #define GEN7_GMU_CM3_DTCM_START 0x1c400 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 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 1235: #define GEN7_GMU_GENERAL_9 0x1f9ce 1236: #define GEN7_GMU_GENERAL_10 0x1f9cf 1237: #define GEN7_GMU_GENERAL_11 0x1f9d0 1238: 1239: /* FAL10 veto register */ 1240: #define GEN7_GPU_GMU_CX_GMU_CX_FAL_INTF 0x1f8f0 1241: #define GEN7_GPU_GMU_CX_GMU_CX_FALNEXT_INTF 0x1f8f1 1242: 1243: /* CLX registers */ 1244: #define GEN7_GPU_GMU_CX_CBCAST_GENERIC_ID 0x20001 1245: #define GEN7_GPU_GMU_CX_PMIC_PAYLOAD 0x20003 1246: #define GEN7_GPU_GMU_CX_PMIC_PAYLOAD_1 0x20005 1247: 1248: #define GEN7_GMU_AO_INTERRUPT_EN 0x23b03 1249: #define GEN7_GMU_AO_HOST_INTERRUPT_CLR 0x23b04 1250: #define GEN7_GMU_AO_HOST_INTERRUPT_STATUS 0x23b05 1251: #define GEN7_GMU_AO_HOST_INTERRUPT_MASK 0x23b06 1252: #define GEN7_GPU_GMU_AO_GMU_CGC_MODE_CNTL 0x23b09 1253: #define GEN7_GPU_GMU_AO_GMU_CGC_DELAY_CNTL 0x23b0a 1254: #define GEN7_GPU_GMU_AO_GMU_CGC_HYST_CNTL 0x23b0b 1255: #define GEN7_GPU_GMU_AO_GPU_CX_BUSY_STATUS 0x23b0c 1256: #define GEN7_GPU_GMU_AO_GPU_CX_BUSY_STATUS2 0x23b0d 1257: #define GEN7_GPU_GMU_AO_GPU_CX_BUSY_MASK 0x23b0e 1258: #define GEN7_GMU_AO_AHB_FENCE_CTRL 0x23b10 1259: #define GEN7_GMU_AHB_FENCE_STATUS 0x23b13 1260: #define GEN7_GMU_AHB_FENCE_STATUS_CLR 0x23b14 1261: #define GEN7_GMU_RBBM_INT_UNMASKED_STATUS 0x23b15 1262: #define GEN7_GPU_GMU_AO_GPU_LPAC_BUSY_STATUS 0x23b30 1263: 1264: /* GMU RSC control registers */ 1265: #define GEN7_GMU_RSCC_CONTROL_REQ 0x23b07 1266: #define GEN7_GMU_RSCC_CONTROL_ACK 0x23b08 1267: 1268: /* FENCE control registers */ 1269: #define GEN7_GMU_AHB_FENCE_RANGE_0 0x23b11 1270: 1271: /* GMU countables */ 1272: #define GEN7_GMU_CM3_BUSY_CYCLES 0 1273: 1274: /* GPUCC registers */ 1275: #define GEN7_11_0_GPU_CC_CX_CFG_GDSCR 0x26424 1276: #define GEN7_13_0_GPU_CC_CX_CFG_GDSCR 0x2643b 1277: #define GEN7_GPU_CC_CX_CFG_GDSCR 0x26443 1278: #define GEN7_17_0_GPU_CC_CX_CFG_GDSCR 0x26445 1279: #define GEN7_GPU_CC_GX_DOMAIN_MISC3 0x26541 1280: 1281: /* GPU RSC sequencer registers */ 1282: #define GEN7_GPU_RSCC_RSC_STATUS0_DRV0 0x00004 1283: #define GEN7_RSCC_PDC_SEQ_START_ADDR 0x00008 1284: #define GEN7_RSCC_PDC_MATCH_VALUE_LO 0x00009 1285: #define GEN7_RSCC_PDC_MATCH_VALUE_HI 0x0000a 1286: #define GEN7_RSCC_PDC_SLAVE_ID_DRV0 0x0000b 1287: #define GEN7_RSCC_HIDDEN_TCS_CMD0_ADDR 0x0000d 1288: #define GEN7_RSCC_HIDDEN_TCS_CMD0_DATA 0x0000e 1289: #define GEN7_RSCC_TIMESTAMP_UNIT0_TIMESTAMP_L_DRV0 0x00082 1290: #define GEN7_RSCC_TIMESTAMP_UNIT0_TIMESTAMP_H_DRV0 0x00083 1291: #define GEN7_RSCC_TIMESTAMP_UNIT1_EN_DRV0 0x00089 1292: #define GEN7_RSCC_TIMESTAMP_UNIT1_OUTPUT_DRV0 0x0008c 1293: #define GEN7_RSCC_OVERRIDE_START_ADDR 0x00100 1294: #define GEN7_RSCC_SEQ_BUSY_DRV0 0x00101 1295: #define GEN7_RSCC_SEQ_MEM_0_DRV0 0x00180 1296: #define GEN7_RSCC_TCS0_DRV0_STATUS 0x00346 MATCH LINES: 1328 1316: #define GEN7_2_0_RSCC_TCS7_DRV0_STATUS 0x007e2 1317: #define GEN7_2_0_RSCC_TCS8_DRV0_STATUS 0x0088a 1318: #define GEN7_2_0_RSCC_TCS9_DRV0_STATUS 0x00932 1319: 1320: /* GPU PDC sequencer registers in AOSS.RPMh domain */ 1321: #define GEN7_PDC_GPU_ENABLE_PDC 0x1140 1322: #define GEN7_PDC_GPU_SEQ_START_ADDR 0x1148 1323: 1324: #define GEN7_SMMU_BASE 0x28000 1325: 1326: /* GPU CX_MISC registers */ 1327: #define GEN7_GPU_CX_MISC_CX_AHB_AON_CNTL 0x27810 1328: #define GEN7_GPU_CX_MISC_CX_AHB_GMU_CNTL 0x27811 1329: #define GEN7_GPU_CX_MISC_CX_AHB_CP_CNTL 0x27812 1330: #define GEN7_GPU_CX_MISC_CX_AHB_VBIF_SMMU_CNTL 0x27813 1331: #define GEN7_GPU_CX_MISC_CX_AHB_HOST_CNTL 0x27814 1332: #define GEN7_GPU_CX_MISC_AO_COUNTER_LO 0x27880 1333: #define GEN7_GPU_CX_MISC_AO_COUNTER_HI 0x27881 1334: #define GEN7_GPU_CX_MISC_SW_FUSE_VALUE 0x27C00 1335: 1336: /* GPU SW Fuse Feature bit fields */ 1337: #define GEN7_FASTBLEND_SW_FUSE 0 1338: #define GEN7_LPAC_SW_FUSE 1 1339: #define GEN7_RAYTRACING_SW_FUSE 2 1340: 1341: #define GEN7_SW_FUSE_INT_MASK \ 1342: ((1 << GEN7_FASTBLEND_SW_FUSE) | \ 1343: (1 << GEN7_LPAC_SW_FUSE) | \ 1344: (1 << GEN7_RAYTRACING_SW_FUSE)) 1345: 1346: /* QDSS register offsets */ 1347: #define QDSS_AOSS_APB_TMC_RSZ 0x04 1348: #define QDSS_AOSS_APB_TMC_RRD 0x10 1349: #define QDSS_AOSS_APB_TMC_RRP 0x14 1350: #define QDSS_AOSS_APB_TMC_RWP 0x18 1351: #define QDSS_AOSS_APB_TMC_CTRL 0x20 1352: #define QDSS_AOSS_APB_TMC_MODE 0x28 --- FILE: \gen8_reg.h | HITS: 12 --- MATCH LINES: 791 779: #define GEN8_CP_RB_WPTR_LPAC 0x812 780: #define GEN8_CP_SMMU_STREAM_ID_LPAC 0x814 781: #define GEN8_CP_SQE_CNTL 0x815 782: #define GEN8_CP_SQE_INSTR_BASE_LO 0x816 783: #define GEN8_CP_SQE_INSTR_BASE_HI 0x817 784: #define GEN8_CP_AQE_INSTR_BASE_LO_0 0x818 785: #define GEN8_CP_AQE_INSTR_BASE_HI_0 0x819 786: #define GEN8_CP_AQE_INSTR_BASE_LO_1 0x81a 787: #define GEN8_CP_AQE_INSTR_BASE_HI_1 0x81b 788: #define GEN8_CP_APERTURE_CNTL_HOST 0x81c 789: #define GEN8_CP_APERTURE_CNTL_GMU 0x81d 790: #define GEN8_CP_APERTURE_CNTL_CD 0x81e 791: #define GEN8_CP_CP2GMU_STATUS 0x822 792: #define GEN8_CP_SEMAPHORE_REG_0 0x825 793: #define GEN8_CP_RL_ERROR_DETAILS_0 0x840 794: #define GEN8_CP_RL_ERROR_DETAILS_1 0x841 795: #define GEN8_CP_CRASH_DUMP_SCRIPT_BASE_LO 0x842 796: #define GEN8_CP_CRASH_DUMP_SCRIPT_BASE_HI 0x843 797: #define GEN8_CP_CRASH_DUMP_CNTL 0x844 798: #define GEN8_CP_CRASH_DUMP_STATUS 0x845 799: #define GEN8_CP_MULTIDRAW_CNTL 0x84a 800: #define GEN8_CP_DBG_ECO_CNTL 0x84b 801: #define GEN8_CP_MISC_CNTL 0x84c 802: #define GEN8_CP_APRIV_CNTL_PIPE 0x84d 803: #define GEN8_CP_PROTECT_CNTL_PIPE 0x84e 804: #define GEN8_CP_PROTECT_STATUS_PIPE 0x84f 805: #define GEN8_CP_PROTECT_REG_GLOBAL 0x850 806: #define GEN8_CP_PROTECT_REG_PIPE 0x8a0 807: 808: #define GEN8_CP_SQE_ICACHE_CNTL_PIPE 0x8b0 809: #define GEN8_CP_SQE_DCACHE_CNTL_PIPE 0x8b1 810: #define GEN8_CP_CHICKEN_DBG_PIPE 0x8b2 811: #define GEN8_CP_HW_FAULT_STATUS_PIPE 0x8b3 812: #define GEN8_CP_HW_FAULT_STATUS_MASK_PIPE 0x8b4 813: #define GEN8_CP_INTERRUPT_STATUS_GLOBAL 0x8b5 814: #define GEN8_CP_INTERRUPT_STATUS_MASK_GLOBAL 0x8b6 815: #define GEN8_CP_INTERRUPT_STATUS_PIPE 0x8b7 MATCH LINES: 1416, 1417 1404: #define GEN8_CX_DBGC_EVT_INTF_SEL_1 0x18437 1405: #define GEN8_CX_DBGC_PERF_ATB_CFG 0x18438 1406: #define GEN8_CX_DBGC_ECO_CNTL 0x1843b 1407: #define GEN8_CX_DBGC_AHB_DBG_CNTL 0x1843c 1408: #define GEN8_CX_DBGC_CFG_DBGBUS_MISC_MODE 0x18444 1409: #define GEN8_CX_DBGC_TCM_DBG_ADDR 0x18580 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 MATCH LINES: 1601, 1602, 1603, 1604, 1609, 1610, 1611, 1643, 1667 1589: #define GEN8_GMUCX_POWER_COUNTER_XOCLK_L_35 0x1fce6 1590: #define GEN8_GMUCX_POWER_COUNTER_XOCLK_H_35 0x1fce7 1591: #define GEN8_GMUCX_POWER_COUNTER_XOCLK_L_36 0x1fce8 1592: #define GEN8_GMUCX_POWER_COUNTER_XOCLK_H_36 0x1fce9 1593: #define GEN8_GMUCX_POWER_COUNTER_XOCLK_L_37 0x1fcea 1594: #define GEN8_GMUCX_POWER_COUNTER_XOCLK_H_37 0x1fceb 1595: #define GEN8_GMUCX_POWER_COUNTER_XOCLK_L_38 0x1fcec 1596: #define GEN8_GMUCX_POWER_COUNTER_XOCLK_H_38 0x1fced 1597: #define GEN8_GMUCX_POWER_COUNTER_XOCLK_L_39 0x1fcee 1598: #define GEN8_GMUCX_POWER_COUNTER_XOCLK_H_39 0x1fcef 1599: 1600: /* HFI registers*/ 1601: #define GEN8_GMUCX_HFI_CTRL_STATUS 0x1f980 1602: #define GEN8_GMUCX_HFI_QTBL_INFO 0x1f984 1603: #define GEN8_GMUCX_HFI_QTBL_ADDR 0x1f985 1604: #define GEN8_GMUCX_HFI_CTRL_INIT 0x1f986 1605: #define GEN8_GMUCX_GMU2HOST_INTR_SET 0x1f990 1606: #define GEN8_GMUCX_GMU2HOST_INTR_CLR 0x1f991 1607: #define GEN8_GMUCX_GMU2HOST_INTR_INFO 0x1f992 1608: #define GEN8_GMUCX_GMU2HOST_INTR_MASK 0x1f993 1609: #define GEN8_GMUCX_HOST2GMU_INTR_SET 0x1f994 1610: #define GEN8_GMUCX_HOST2GMU_INTR_CLR 0x1f995 1611: #define GEN8_GMUCX_HOST2GMU_INTR_RAW_INFO 0x1f996 1612: #define GEN8_GMUCX_GENERAL_8 0x1f9c8 1613: #define GEN8_GMUCX_GENERAL_9 0x1f9c9 1614: #define GEN8_GMUCX_GENERAL_10 0x1f9ca 1615: #define GEN8_GMUCX_GENERAL_11 0x1f9cb 1616: 1617: /* Always on registers */ 1618: #define GEN8_GMUAO_AO_INTERRUPT_EN 0x23b03 1619: #define GEN8_GMUAO_AO_HOST_INTERRUPT_CLR 0x23b04 1620: #define GEN8_GMUAO_AO_HOST_INTERRUPT_STATUS 0x23b05 1621: #define GEN8_GMUAO_AO_HOST_INTERRUPT_MASK 0x23b06 1622: 1623: /* GMU RSC control registers */ 1624: #define GEN8_GMUAO_RSCC_CONTROL_REQ 0x23b07 1625: #define GEN8_GMUAO_RSCC_CONTROL_ACK 0x23b08 1626: 1627: #define GEN8_GMUAO_CGC_MODE_CNTL 0x23b09 1628: #define GEN8_GMUAO_CGC_DELAY_CNTL 0x23b0a 1629: #define GEN8_GMUAO_CGC_HYST_CNTL 0x23b0b 1630: #define GEN8_GMUAO_GPU_CX_BUSY_STATUS 0x23b0c 1631: #define GEN8_GMUAO_GPU_CX_BUSY_STATUS2 0x23b0d 1632: #define GEN8_GMUAO_GPU_CX_BUSY_MASK 0x23b0e 1633: 1634: /* FENCE control registers */ 1635: #define GEN8_GMUAO_AHB_FENCE_CTRL 0x23b10 1636: #define GEN8_GMUAO_AHB_FENCE_RANGE_0 0x23b11 1637: #define GEN8_GMUAO_AHB_FENCE_STATUS 0x23b13 1638: #define GEN8_GMUAO_AHB_FENCE_STATUS_CLR 0x23b14 1639: #define GEN8_GMUAO_RBBM_INT_UNMASKED_STATUS_SHADOW 0x23b15 1640: #define GEN8_GMUAO_LPAC_BUSY_STATUS 0x23b30 1641: 1642: /* GMU countables */ 1643: #define GEN8_GMU_CM3_BUSY_CYCLES 0 1644: 1645: /* GPUCC registers */ 1646: #define GEN8_GPU_CC_CX_CFG_GDSCR 0x26421 1647: #define GEN8_GPU_CC_GX_DOMAIN_MISC3 0x26541 1648: 1649: /* GPU RSC sequencer registers */ 1650: #define GEN8_GPU_RSCC_RSC_STATUS0_DRV0 0x00004 1651: #define GEN8_RSCC_SEQ_BUSY_DRV0 0x00101 1652: #define GEN8_RSCC_TCS0_DRV0_STATUS 0x0034a 1653: #define GEN8_RSCC_TCS1_DRV0_STATUS 0x003f2 1654: #define GEN8_RSCC_TCS2_DRV0_STATUS 0x0049a 1655: #define GEN8_RSCC_TCS3_DRV0_STATUS 0x00542 1656: #define GEN8_RSCC_TCS4_DRV0_STATUS 0x005ea 1657: #define GEN8_RSCC_TCS5_DRV0_STATUS 0x00692 1658: #define GEN8_RSCC_TCS6_DRV0_STATUS 0x0073a 1659: #define GEN8_RSCC_TCS7_DRV0_STATUS 0x007e2 1660: #define GEN8_RSCC_TCS8_DRV0_STATUS 0x0088a 1661: #define GEN8_RSCC_TCS9_DRV0_STATUS 0x00932 1662: 1663: #define GEN8_SMMU_BASE 0x28000 1664: 1665: /* GPU CX_MISC registers */ 1666: #define GEN8_GPU_CX_MISC_CX_AHB_AON_CNTL 0x27810 1667: #define GEN8_GPU_CX_MISC_CX_AHB_GMU_CNTL 0x27811 1668: #define GEN8_GPU_CX_MISC_CX_AHB_CP_CNTL 0x27812 1669: #define GEN8_GPU_CX_MISC_CX_AHB_VBIF_SMMU_CNTL 0x27813 1670: #define GEN8_GPU_CX_MISC_CX_AHB_HOST_CNTL 0x27814 1671: #define GEN8_GPU_CX_MISC_INT_CLEAR_CMD 0x27831 1672: #define GEN8_GPU_CX_MISC_INT_0_MASK 0x27833 1673: #define GEN8_GPU_CX_MISC_INT_0_STATUS 0x27834 1674: #define GEN8_GPU_CX_MISC_SMMU_INTR_MASK0 0x27846 1675: #define GEN8_GPU_CX_MISC_SMMU_INTR_MASK1 0x27847 1676: #define GEN8_GPU_CX_MISC_AO_COUNTER_LO 0x27880 1677: #define GEN8_GPU_CX_MISC_AO_COUNTER_HI 0x27881 1678: #define GEN8_GPU_CX_MISC_GFX_PWR_CLK_STATUS 0x27883 1679: #define GEN8_GPU_CX_MISC_SLICE_ENABLE_TEST 0x27886 1680: #define GEN8_GPU_CX_MISC_SLICE_ENABLE_FINAL 0x27887 1681: #define GEN8_GPU_CX_MISC_SW_FUSE_VALUE 0x27c00 1682: #define GEN8_GPU_CX_MISC_SW_FUSE_FREQ_LIMIT_STATUS 0x27c05 1683: 1684: /* GPU SW Fuse Feature bit fields */ 1685: #define GEN8_FASTBLEND_SW_FUSE 0 1686: #define GEN8_LPAC_SW_FUSE 1 1687: #define GEN8_RAYTRACING_SW_FUSE 2 1688: #define GEN8_MALU_SW_FUSE 3 1689: 1690: #define GEN8_SW_FUSE_INT_MASK \ 1691: ((1 << GEN8_FASTBLEND_SW_FUSE) | \ --- FILE: \kgsl.c | HITS: 3 --- MATCH LINES: 36 24: #include 25: #include 26: #include 27: #include 28: #include 29: 30: #include "adreno.h" 31: 32: #include "kgsl_compat.h" 33: #include "kgsl_debugfs.h" 34: #include "kgsl_device.h" 35: #include "kgsl_eventlog.h" 36: #include "kgsl_gmu_core.h" 37: #include "kgsl_mmu.h" 38: #include "kgsl_pool.h" 39: #include "kgsl_reclaim.h" 40: #include "kgsl_sync.h" 41: #include "kgsl_sysfs.h" 42: #include "kgsl_trace.h" 43: #include "kgsl_util.h" 44: /* Instantiate tracepoints */ 45: #define CREATE_TRACE_POINTS 46: #include "kgsl_power_trace.h" 47: 48: #ifndef arch_mmap_check 49: #define arch_mmap_check(addr, len, flags) (0) 50: #endif 51: 52: #ifndef pgprot_writebackcache 53: #define pgprot_writebackcache(_prot) (_prot) 54: #endif 55: 56: #ifndef pgprot_writethroughcache 57: #define pgprot_writethroughcache(_prot) (_prot) 58: #endif 59: 60: #if defined(CONFIG_ARM64) || defined(CONFIG_ARM_LPAE) MATCH LINES: 1021, 1027 1009: 1010: kfree(private->cmdline); 1011: put_pid(private->pid); 1012: mmdrop(private->mm); 1013: idr_destroy(&private->mem_idr); 1014: idr_destroy(&private->syncsource_idr); 1015: 1016: /* When using global pagetables, do not put global pagetable */ 1017: if (private->pagetable->name != KGSL_MMU_GLOBAL_PT) 1018: kgsl_mmu_putpagetable(private->pagetable); 1019: 1020: 1021: if (private->profile.md.gmuaddr) { 1022: /* 1023: * This calls iommu_unmap(), which may take variable amount of time to 1024: * complete. So do this at the very end of process private cleanup, so that 1025: * this doesn't delay the clean up of rest of the process private resources. 1026: */ 1027: gmu_core_free_block(device, &private->profile.md); 1028: } 1029: 1030: kfree(private); 1031: } 1032: 1033: void 1034: kgsl_process_private_put(struct kgsl_process_private *private) 1035: { 1036: if (private) 1037: kref_put(&private->refcount, kgsl_destroy_process_private); 1038: } 1039: 1040: /** 1041: * kgsl_process_private_find() - Find the process associated with the specified 1042: * name 1043: * @name: pid_t of the process to search for 1044: * Return the process struct for the given ID. 1045: */ 1046: struct kgsl_process_private *kgsl_process_private_find(pid_t pid) 1047: { 1048: struct kgsl_process_private *p, *private = NULL; 1049: 1050: read_lock(&kgsl_driver.proclist_lock); 1051: list_for_each_entry(p, &kgsl_driver.process_list, list) { --- FILE: \kgsl.h | HITS: 5 --- MATCH LINES: 18 6: #ifndef __KGSL_H 7: #define __KGSL_H 8: 9: #include 10: #include 11: #include 12: #include 13: #include 14: #include 15: #include 16: #include 17: 18: #include "kgsl_gmu_core.h" 19: #include "kgsl_pwrscale.h" 20: #include "kgsl_sharedmem.h" 21: 22: #define KGSL_L3_DEVICE "kgsl-l3" 23: 24: #if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)) 25: #include 26: #define KGSL_BOOT_MARKER(str) place_marker("M - DRIVER " str) 27: #else 28: #define KGSL_BOOT_MARKER(str) pr_info("boot_kpi: M - DRIVER " str) 29: #endif 30: 31: /* 32: * --- kgsl drawobj flags --- 33: * These flags are same as --- drawobj flags --- 34: * but renamed to reflect that cmdbatch is renamed to drawobj. 35: */ 36: #define KGSL_DRAWOBJ_MEMLIST KGSL_CMDBATCH_MEMLIST 37: #define KGSL_DRAWOBJ_MARKER KGSL_CMDBATCH_MARKER 38: #define KGSL_DRAWOBJ_SUBMIT_IB_LIST KGSL_CMDBATCH_SUBMIT_IB_LIST 39: #define KGSL_DRAWOBJ_CTX_SWITCH KGSL_CMDBATCH_CTX_SWITCH 40: #define KGSL_DRAWOBJ_PROFILING KGSL_CMDBATCH_PROFILING 41: #define KGSL_DRAWOBJ_PROFILING_KTIME KGSL_CMDBATCH_PROFILING_KTIME 42: #define KGSL_DRAWOBJ_END_OF_FRAME KGSL_CMDBATCH_END_OF_FRAME MATCH LINES: 297, 304, 313, 326 285: unsigned int processed; 286: char name[64]; 287: readtimestamp_func readtimestamp; 288: void *priv; 289: }; 290: 291: /** 292: * struct submission_info - Container for submission statistics 293: * @inflight: Number of commands that are inflight 294: * @rb_id: id of the ringbuffer to which this submission is made 295: * @rptr: Read pointer of the ringbuffer 296: * @wptr: Write pointer of the ringbuffer 297: * @gmu_dispatch_queue: GMU dispach queue to which this submission is made 298: */ 299: struct submission_info { 300: int inflight; 301: u32 rb_id; 302: u32 rptr; 303: u32 wptr; 304: u32 gmu_dispatch_queue; 305: }; 306: 307: /** 308: * struct retire_info - Container for retire statistics 309: * @inflight: NUmber of commands that are inflight 310: * @rb_id: id of the ringbuffer to which this submission is made 311: * @rptr: Read pointer of the ringbuffer 312: * @wptr: Write pointer of the ringbuffer 313: * @gmu_dispatch_queue: GMU dispach queue to which this submission is made 314: * @timestamp: Timestamp of submission that retired 315: * @submitted_to_rb: AO ticks when GMU put this submission on ringbuffer 316: * @sop: AO ticks when GPU started procssing this submission 317: * @eop: AO ticks when GPU finished this submission 318: * @retired_on_gmu: AO ticks when GMU retired this submission 319: * @active: Number AO of ticks taken by GPU to complete the command 320: */ 321: struct retire_info { 322: int inflight; 323: int rb_id; 324: u32 rptr; 325: u32 wptr; 326: u32 gmu_dispatch_queue; 327: u32 timestamp; 328: u64 submitted_to_rb; 329: u64 sop; 330: u64 eop; 331: u64 retired_on_gmu; 332: u64 active; 333: }; 334: 335: long kgsl_ioctl_device_getproperty(struct kgsl_device_private *dev_priv, 336: unsigned int cmd, void *data); 337: long kgsl_ioctl_device_setproperty(struct kgsl_device_private *dev_priv, 338: unsigned int cmd, void *data); 339: long kgsl_ioctl_device_waittimestamp_ctxtid(struct kgsl_device_private 340: *dev_priv, unsigned int cmd, void *data); 341: long kgsl_ioctl_rb_issueibcmds(struct kgsl_device_private *dev_priv, 342: unsigned int cmd, void *data); 343: long kgsl_ioctl_submit_commands(struct kgsl_device_private *dev_priv, 344: unsigned int cmd, void *data); 345: long kgsl_ioctl_cmdstream_readtimestamp_ctxtid(struct kgsl_device_private 346: *dev_priv, unsigned int cmd, 347: void *data); 348: long kgsl_ioctl_cmdstream_freememontimestamp_ctxtid( 349: struct kgsl_device_private 350: *dev_priv, unsigned int cmd, --- FILE: \kgsl_bus.c | HITS: 1 --- MATCH LINES: 239 227: done: 228: pwr->ddr_table_count = count; 229: 230: /* 231: * In standard device tree bindings, the interconnect path is named "gfx-mem", 232: * whereas downstream bindings use "gpu_icc_path". Since multiple GPU interconnect 233: * paths have not been maintained in gpu device-tree, invoke of_icc_get() with a NULL 234: * path name to default to index 0. This will work for both standard and downstream 235: * bindings. 236: */ 237: pwr->icc_path = of_icc_get(&pdev->dev, NULL); 238: 239: if (IS_ERR(pwr->icc_path) && !gmu_core_scales_bandwidth(device)) { 240: WARN(1, "The CPU has no way to set the GPU bus levels\n"); 241: 242: kfree(pwr->ddr_table); 243: pwr->ddr_table = NULL; 244: return PTR_ERR(pwr->icc_path); 245: } 246: 247: return 0; 248: } 249: 250: void kgsl_bus_close(struct kgsl_device *device) 251: { 252: kfree(device->pwrctrl.ddr_table); 253: device->pwrctrl.ddr_table = NULL; 254: icc_put(device->pwrctrl.icc_path); 255: device->pwrctrl.icc_path = NULL; 256: } --- FILE: \kgsl_device.h | HITS: 12 --- MATCH LINES: 205, 206 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); 203: /** @create_hw_fence: Create a hardware fence */ 204: void (*create_hw_fence)(struct kgsl_device *device, struct kgsl_sync_fence *kfence); 205: /** @gmu_based_dcvs_pwr_ops: Function ops for GMU based DCVS power operations */ 206: int (*gmu_based_dcvs_pwr_ops)(struct kgsl_device *device, u32 arg, 207: enum gpu_pwrlevel_op op); 208: /** @set_thermal_index: Target specific function to send thermal constraint to GMU */ 209: void (*set_thermal_index)(struct kgsl_device *device); 210: /** @alloc_dcvs_profile_memory: Function ops for GMU based DCVS profile operations */ 211: void (*alloc_dcvs_profile_memory)(struct kgsl_device *device, 212: struct kgsl_process_private *proc_priv); 213: /** @is_first_boot_done: Check if the ADRENO device first boot is done */ 214: bool (*is_first_boot_done)(struct kgsl_device *device); 215: /** @set_smmu_aperture: Target specific function to program the SMMU aperture registers */ 216: int (*set_smmu_aperture)(struct kgsl_device *device); 217: }; 218: 219: struct kgsl_ioctl { 220: unsigned int cmd; 221: long (*func)(struct kgsl_device_private *dev_priv, 222: unsigned int cmd, void *data); 223: }; 224: 225: long kgsl_ioctl_helper(struct file *filep, unsigned int cmd, unsigned long arg, 226: const struct kgsl_ioctl *cmds, int len); 227: 228: /* Flag to mark that the memobj_node should not go to the hadrware */ 229: #define MEMOBJ_SKIP BIT(1) 230: MATCH LINES: 290 278: void __iomem *shader_mem_virt; 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 */ MATCH LINES: 383, 384 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 */ 380: u32 debug_bus_bin; 381: /** @soc_code: Identifier containing product and feature code */ 382: u32 soc_code; 383: /** @gmu_fault: Set when a gmu or rgmu fault is encountered */ 384: bool gmu_fault; 385: /** @regmap: GPU register map */ 386: struct kgsl_regmap regmap; 387: /** @timelines: Iterator for assigning IDs to timelines */ 388: struct idr timelines; 389: /** @timelines_lock: Spinlock to protect the timelines idr */ 390: spinlock_t timelines_lock; 391: /** @fence_trace_array: A local trace array for fence debugging */ 392: struct trace_array *fence_trace_array; 393: /** @l3_vote: Enable/Disable l3 voting */ 394: bool l3_vote; 395: /** @pdev_loaded: Flag to test if platform driver is probed */ 396: bool pdev_loaded; 397: /** @nh: Pointer to head of the SRCU notifier chain */ 398: struct srcu_notifier_head nh; 399: /** @bcl_data_kobj: Kobj for bcl_data sysfs node */ 400: struct kobject bcl_data_kobj; 401: /** @work_period_timer: Timer to capture application GPU work stats */ 402: struct timer_list work_period_timer; 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; MATCH LINES: 505, 527, 529, 532, 556, 562 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: 541: #define _context_comm(_c) \ 542: (((_c) && (_c)->proc_priv) ? (_c)->proc_priv->comm : "unknown") 543: 544: /* 545: * Print log messages with the context process name/pid: 546: * [...] kgsl kgsl-3d0: kgsl-api-test[22182]: 547: */ 548: 549: #define pr_context(_d, _c, fmt, args...) \ 550: dev_err((_d)->dev, "%s[%d]: " fmt, \ 551: _context_comm((_c)), \ 552: pid_nr((_c)->proc_priv->pid), ##args) 553: 554: /** 555: * struct kgsl_dcvs_profile_private - Private structure for a KGSL DCVS profile 556: * @gmu_registered: True if DCVS profile is registered with GMU 557: * @user_profile_registered: True if user DCVS IOCTL profile is received 558: * @md: Memory descriptor for the DCVS profile region 559: * @profile_mutex: Mutex lock to protect kgsl_dcvs_profile_private 560: */ 561: struct kgsl_dcvs_profile_private { 562: bool gmu_registered; 563: bool user_profile_registered; 564: struct kgsl_memdesc md; 565: struct mutex profile_mutex; 566: }; 567: 568: /** 569: * struct kgsl_process_private - Private structure for a KGSL process (across 570: * all devices) 571: * @priv: Internal flags, use KGSL_PROCESS_* values 572: * @pid: Identification structure for the task owner of the process 573: * @comm: task name of the process 574: * @mm: mm_struct of the opening process, used to prevent other mm mmap 575: * @mem_lock: Spinlock to protect the process memory lists 576: * @refcount: kref object for reference counting the process 577: * @idr: Iterator for assigning IDs to memory allocations 578: * @pagetable: Pointer to the pagetable owned by this process 579: * @kobj: Pointer to a kobj for the sysfs directory for this process 580: * @debug_root: Pointer to the debugfs root for this process 581: * @stats: Memory allocation statistics for this process 582: * @gpumem_mapped: KGSL memory mapped in the process address space 583: * @syncsource_idr: sync sources created by this process 584: * @syncsource_lock: Spinlock to protect the syncsource idr 585: * @fd_count: Counter for the number of FDs for this process 586: * @ctxt_count: Count for the number of contexts for this process MATCH LINES: 820 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: --- FILE: \kgsl_gmu_core.c | HITS: 285 --- MATCH LINES: 16, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 44, 49, 58, 63, 72, 74, 77, 79, 82, 84, 92, 94, 102, 109, 115, 122, 129, 131, 133, 134, 139, 141, 143, 144, 147, 150, 156, 158, 166, 168, 176, 178, 186, 187, 189, 198, 208, 209, 214, 226, 236, 238, 242, 244, 245, 252, 254, 258, 268, 270, 273, 274, 276, 279, 296, 301, 316, 317, 320, 323, 333, 336, 355, 364, 381, 384, 385, 386, 387, 389, 397, 400, 409, 414, 416, 421, 426, 435, 438, 439, 441, 444, 446, 448, 453, 458, 462, 465, 466, 467, 471, 476, 482, 487, 492, 496, 497, 500, 504, 507, 513, 515, 516, 517, 524, 530, 533, 539, 543, 546, 562, 574, 579, 581, 584, 586, 590, 599, 608, 617, 624, 626, 627, 628, 629, 640, 644, 653, 656, 659, 666, 670, 674, 679, 700, 706, 712, 714, 717, 718, 719, 720, 729, 732, 733, 735, 736, 740, 741, 742, 747, 749, 755, 776, 794 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #include 8: #include 9: #include 10: #include 11: #include 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: 54: platform_driver_register((struct platform_driver *) match->data); 55: of_node_put(node); 56: } 57: 58: void gmu_core_unregister(void) 59: { 60: const struct of_device_id *match; 61: struct device_node *node; 62: 63: node = of_find_matching_node_and_match(NULL, gmu_match_table, 64: &match); 65: if (!node) 66: return; 67: 68: platform_driver_unregister((struct platform_driver *) match->data); 69: of_node_put(node); 70: } 71: 72: bool gmu_core_isenabled(struct kgsl_device *device) 73: { 74: return test_bit(GMU_ENABLED, &device->gmu_core.flags); 75: } 76: 77: bool gmu_core_gpmu_isenabled(struct kgsl_device *device) 78: { 79: return (device->gmu_core.dev_ops != NULL); 80: } 81: 82: bool gmu_core_scales_bandwidth(struct kgsl_device *device) 83: { 84: const struct gmu_dev_ops *ops = GMU_DEVICE_OPS(device); 85: 86: if (ops && ops->scales_bandwidth) 87: return ops->scales_bandwidth(device); 88: 89: return false; 90: } 91: 92: int gmu_core_dev_acd_set(struct kgsl_device *device, bool val) 93: { 94: const struct gmu_dev_ops *ops = GMU_DEVICE_OPS(device); 95: 96: if (ops && ops->acd_set) 97: return ops->acd_set(device, val); 98: 99: return -EINVAL; 100: } 101: 102: void gmu_core_regread(struct kgsl_device *device, unsigned int offsetwords, 103: unsigned int *value) 104: { 105: u32 val = kgsl_regmap_read(&device->regmap, offsetwords); 106: *value = val; 107: } 108: 109: void gmu_core_regwrite(struct kgsl_device *device, unsigned int offsetwords, 110: unsigned int value) 111: { 112: kgsl_regmap_write(&device->regmap, value, offsetwords); 113: } 114: 115: void gmu_core_blkwrite(struct kgsl_device *device, unsigned int offsetwords, 116: const void *buffer, size_t size) 117: { 118: kgsl_regmap_bulk_write(&device->regmap, offsetwords, 119: buffer, size >> 2); 120: } 121: 122: void gmu_core_regrmw(struct kgsl_device *device, 123: unsigned int offsetwords, 124: unsigned int mask, unsigned int bits) 125: { 126: kgsl_regmap_rmw(&device->regmap, offsetwords, mask, bits); 127: } 128: 129: int gmu_core_dev_oob_set(struct kgsl_device *device, enum oob_request req) 130: { 131: const struct gmu_dev_ops *ops = GMU_DEVICE_OPS(device); 132: 133: if (ops && ops->oob_set) 134: return ops->oob_set(device, req); 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: 220: ret = sg_alloc_table_from_pages(&sgt, memdesc->pages, 221: memdesc->page_count, 0, memdesc->size, GFP_KERNEL); 222: 223: if (ret) 224: return ret; 225: 226: mapped = kgsl_mmu_map_sg(domain, gmuaddr, sgt.sgl, sgt.nents, attrs); 227: sg_free_table(&sgt); 228: } 229: 230: if (!mapped) 231: mapped = -ENOMEM; 232: 233: return (mapped < 0) ? mapped : 0; 234: } 235: 236: struct kgsl_memdesc *gmu_core_find_memdesc(struct kgsl_device *device, u32 addr, u32 size) 237: { 238: struct gmu_core_device *gmu = &device->gmu_core; 239: int i; 240: 241: for (i = 0; i < gmu->global_entries; i++) { 242: struct kgsl_memdesc *md = &gmu->gmu_globals[i]; 243: 244: if ((addr >= md->gmuaddr) && 245: (((addr + size) <= (md->gmuaddr + md->size)))) 246: return md; 247: } 248: 249: return NULL; 250: } 251: 252: int gmu_core_find_vma_block(struct kgsl_device *device, u32 addr, u32 size) 253: { 254: struct gmu_core_device *gmu = &device->gmu_core; 255: int i; 256: 257: for (i = 0; i < gmu->num_vmas; i++) { 258: struct gmu_vma_entry *vma = &gmu->vma[i]; 259: 260: if ((addr >= vma->start) && 261: ((addr + size) <= (vma->start + vma->size))) 262: return i; 263: } 264: 265: return -ENOENT; 266: } 267: 268: void gmu_core_free_globals(struct kgsl_device *device) 269: { 270: struct gmu_core_device *gmu = &device->gmu_core; 271: int i; 272: 273: for (i = 0; i < gmu->global_entries && i < ARRAY_SIZE(gmu->gmu_globals); i++) { 274: struct kgsl_memdesc *md = &gmu->gmu_globals[i]; 275: 276: if (!md->gmuaddr) 277: continue; 278: 279: iommu_unmap(gmu->domain, md->gmuaddr, md->size); 280: 281: if (TEST_FLAG(KGSL_MEMDESC_SYSMEM, &md->priv)) 282: kgsl_sharedmem_free(md); 283: 284: memset(md, 0, sizeof(*md)); 285: } 286: 287: if (gmu->domain) { 288: kgsl_detach_iommu_group(gmu->domain, gmu->group); 289: iommu_domain_free(gmu->domain); 290: gmu->domain = NULL; 291: } 292: 293: gmu->global_entries = 0; 294: } 295: 296: static struct gmu_vma_node *find_va(struct gmu_vma_entry *vma, u32 addr, u32 size) 297: { 298: struct rb_node *node = vma->vma_root.rb_node; 299: 300: while (node != NULL) { 301: struct gmu_vma_node *data = rb_entry(node, struct gmu_vma_node, node); 302: 303: if (addr + size <= data->va) 304: node = node->rb_left; 305: else if (addr >= data->va + data->size) 306: node = node->rb_right; 307: else 308: return data; 309: } 310: return NULL; 311: } 312: 313: /* Return true if VMA supports dynamic allocations */ 314: static bool vma_is_dynamic(struct kgsl_device *device, int vma_id) 315: { 316: /* Dynamic allocations are done in the GMU_NONCACHED_KERNEL space */ 317: return (vma_id == GMU_NONCACHED_KERNEL) && (!adreno_is_a6xx(ADRENO_DEVICE(device))); 318: } 319: 320: static int insert_va(struct gmu_vma_entry *vma, u32 addr, u32 size) 321: { 322: struct rb_node **node, *parent = NULL; 323: struct gmu_vma_node *new = kzalloc(sizeof(*new), GFP_NOWAIT); 324: 325: if (new == NULL) 326: return -ENOMEM; 327: 328: new->va = addr; 329: new->size = size; 330: 331: node = &vma->vma_root.rb_node; 332: while (*node != NULL) { 333: struct gmu_vma_node *this; 334: 335: parent = *node; 336: this = rb_entry(parent, struct gmu_vma_node, node); 337: 338: if (addr + size <= this->va) 339: node = &parent->rb_left; 340: else if (addr >= this->va + this->size) 341: node = &parent->rb_right; 342: else { 343: kfree(new); 344: return -EEXIST; 345: } 346: } 347: 348: /* Add new node and rebalance tree */ 349: rb_link_node(&new->node, parent, node); 350: rb_insert_color(&new->node, &vma->vma_root); 351: 352: return 0; 353: } 354: 355: static u32 find_unmapped_va(struct gmu_vma_entry *vma, u32 size, u32 va_align) 356: { 357: struct rb_node *node = rb_first(&vma->vma_root); 358: u32 cur = vma->start; 359: bool found = false; 360: 361: cur = ALIGN(cur, va_align); 362: 363: while (node) { 364: struct gmu_vma_node *data = rb_entry(node, struct gmu_vma_node, node); 365: 366: if (cur + size <= data->va) { 367: found = true; 368: break; 369: } 370: 371: cur = ALIGN(data->va + data->size, va_align); 372: node = rb_next(node); 373: } 374: 375: /* Do we have space after the last node? */ 376: if (!found && (cur + size <= vma->start + vma->size)) 377: found = true; 378: return found ? cur : 0; 379: } 380: 381: static int _map_gmu_dynamic(struct kgsl_device *device, struct kgsl_memdesc *md, 382: u32 addr, u32 vma_id, int attrs, u32 align) 383: { 384: struct gmu_core_device *gmu = &device->gmu_core; 385: struct device *gmu_pdev_dev = GMU_PDEV_DEV(device); 386: struct gmu_vma_entry *vma = &gmu->vma[vma_id]; 387: struct gmu_vma_node *vma_node = NULL; 388: int ret; 389: u32 size = ALIGN(md->size, hfi_get_gmu_sz_alignment(align)); 390: 391: spin_lock(&vma->lock); 392: if (!addr) { 393: /* 394: * We will end up with a hole (GMU VA range not backed by physical mapping) if 395: * the aligned size is greater than the size of the physical mapping 396: */ 397: addr = find_unmapped_va(vma, size, hfi_get_gmu_va_alignment(align)); 398: if (addr == 0) { 399: spin_unlock(&vma->lock); 400: dev_err(gmu_pdev_dev, 401: "Insufficient VA space size: %x\n", size); 402: return -ENOMEM; 403: } 404: } 405: 406: ret = insert_va(vma, addr, size); 407: spin_unlock(&vma->lock); 408: if (ret < 0) { 409: dev_err(gmu_pdev_dev, 410: "Could not insert va: %x size %x\n", addr, size); 411: return ret; 412: } 413: 414: ret = gmu_core_map_memdesc(gmu->domain, md, addr, attrs); 415: if (!ret) { 416: md->gmuaddr = addr; 417: return 0; 418: } 419: 420: /* Failed to map to GMU */ 421: dev_err(gmu_pdev_dev, 422: "Unable to map GMU kernel block: addr:0x%08x size:0x%llx :%d\n", 423: addr, md->size, ret); 424: 425: spin_lock(&vma->lock); 426: vma_node = find_va(vma, md->gmuaddr, size); 427: if (vma_node) 428: rb_erase(&vma_node->node, &vma->vma_root); 429: spin_unlock(&vma->lock); 430: kfree(vma_node); 431: 432: return ret; 433: } 434: 435: static int _map_gmu_static(struct kgsl_device *device, struct kgsl_memdesc *md, 436: u32 addr, u32 vma_id, int attrs, u32 align) 437: { 438: struct gmu_core_device *gmu = &device->gmu_core; 439: struct gmu_vma_entry *vma = &gmu->vma[vma_id]; 440: int ret; 441: u32 size = ALIGN(md->size, hfi_get_gmu_sz_alignment(align)); 442: 443: if (!addr) 444: addr = ALIGN(vma->next_va, hfi_get_gmu_va_alignment(align)); 445: 446: ret = gmu_core_map_memdesc(device->gmu_core.domain, md, addr, attrs); 447: if (ret) { 448: dev_err(GMU_PDEV_DEV(device), 449: "Unable to map GMU kernel block: addr:0x%08x size:0x%llx :%d\n", 450: addr, md->size, ret); 451: return ret; 452: } 453: md->gmuaddr = addr; 454: /* 455: * We will end up with a hole (GMU VA range not backed by physical mapping) if the aligned 456: * size is greater than the size of the physical mapping 457: */ 458: vma->next_va = md->gmuaddr + size; 459: return 0; 460: } 461: 462: int gmu_core_reserve_gmuaddr(struct kgsl_device *device, struct kgsl_memdesc *md, u32 vma_id, 463: u32 align) 464: { 465: struct gmu_core_device *gmu = &device->gmu_core; 466: struct gmu_vma_entry *vma = &gmu->vma[vma_id]; 467: u32 addr, size = ALIGN(md->size, hfi_get_gmu_sz_alignment(align)); 468: 469: if (vma_is_dynamic(device, vma_id)) { 470: spin_lock(&vma->lock); 471: addr = find_unmapped_va(vma, size, hfi_get_gmu_va_alignment(align)); 472: spin_unlock(&vma->lock); 473: if (addr == 0) 474: goto error; 475: } else { 476: addr = ALIGN(vma->next_va, hfi_get_gmu_va_alignment(align)); 477: if ((addr + size) >= (vma->start + vma->size)) 478: goto error; 479: vma->next_va = addr + size; 480: } 481: 482: md->gmuaddr = addr; 483: 484: return 0; 485: 486: error: 487: dev_err_ratelimited(GMU_PDEV_DEV(device), 488: "Insufficient VA space size: %x in vma:%u\n", size, vma_id); 489: return -ENOMEM; 490: } 491: 492: int gmu_core_map_gmu(struct kgsl_device *device, struct kgsl_memdesc *md, 493: u32 addr, u32 vma_id, int attrs, u32 align) 494: { 495: return vma_is_dynamic(device, vma_id) ? 496: _map_gmu_dynamic(device, md, addr, vma_id, attrs, align) : 497: _map_gmu_static(device, md, addr, vma_id, attrs, align); 498: } 499: 500: int gmu_core_get_attrs(u32 flags) 501: { 502: int attrs = IOMMU_READ; 503: 504: if (flags & HFI_MEMFLAG_GMU_PRIV) 505: attrs |= IOMMU_PRIV; 506: 507: if (flags & HFI_MEMFLAG_GMU_WRITEABLE) 508: attrs |= IOMMU_WRITE; 509: 510: return attrs; 511: } 512: 513: int gmu_core_import_buffer(struct kgsl_device *device, struct hfi_mem_alloc_entry *entry) 514: { 515: struct hfi_mem_alloc_desc *desc = &entry->desc; 516: u32 attrs = gmu_core_get_attrs(desc->flags); 517: u32 vma_id = (desc->flags & HFI_MEMFLAG_GMU_CACHEABLE) ? GMU_CACHE : GMU_NONCACHED_KERNEL; 518: 519: /* 520: * GMU Tx/Rx queues are mapped as I/O-coherent on both SOCCP and CPU, 521: * mark the buffer I/O-coherent on GMU side as well to prevent stale 522: * data and immediate updates in DDR. 523: */ 524: if (desc->mem_kind == HFI_MEMKIND_HW_FENCE && 525: kgsl_mmu_has_feature(device, KGSL_MMU_IO_COHERENT)) { 526: entry->md->flags |= KGSL_MEMFLAGS_IOCOHERENT; 527: attrs |= IOMMU_CACHE; 528: } 529: 530: return gmu_core_map_gmu(device, entry->md, 0, vma_id, attrs, desc->align); 531: } 532: 533: struct kgsl_memdesc *gmu_core_reserve_kernel_block(struct kgsl_device *device, 534: u32 addr, u32 size, u32 vma_id, u32 align) 535: { 536: int ret; 537: u64 memflags = 0; 538: struct kgsl_memdesc *md; 539: struct gmu_core_device *gmu = &device->gmu_core; 540: int attrs = IOMMU_READ | IOMMU_WRITE | IOMMU_PRIV; 541: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 542: 543: if (gmu->global_entries == ARRAY_SIZE(gmu->gmu_globals)) 544: return ERR_PTR(-ENOMEM); 545: 546: md = &gmu->gmu_globals[gmu->global_entries]; 547: 548: /* 549: * Apply WB cache policy to fetch GMU FW successfully for A622. 550: * A622 has specific cache coherency requirements that can lead to data 551: * inconsistency if not using writeback cache policy. 552: */ 553: if (adreno_is_a622(adreno_dev)) 554: memflags = FIELD_PREP(KGSL_CACHEMODE_MASK, KGSL_CACHEMODE_WRITEBACK); 555: 556: ret = kgsl_allocate_kernel(device, md, size, memflags, KGSL_MEMDESC_SYSMEM); 557: if (ret) { 558: memset(md, 0x0, sizeof(*md)); 559: return ERR_PTR(-ENOMEM); 560: } 561: 562: ret = gmu_core_map_gmu(device, md, addr, vma_id, attrs, align); 563: if (ret) { 564: kgsl_sharedmem_free(md); 565: memset(md, 0x0, sizeof(*md)); 566: return ERR_PTR(ret); 567: } 568: 569: gmu->global_entries++; 570: 571: return md; 572: } 573: 574: struct kgsl_memdesc *gmu_core_reserve_kernel_block_fixed(struct kgsl_device *device, 575: u32 addr, u32 size, u32 vma_id, const char *resource, int attrs, u32 align) 576: { 577: int ret; 578: struct kgsl_memdesc *md; 579: struct gmu_core_device *gmu = &device->gmu_core; 580: 581: if (gmu->global_entries == ARRAY_SIZE(gmu->gmu_globals)) 582: return ERR_PTR(-ENOMEM); 583: 584: md = &gmu->gmu_globals[gmu->global_entries]; 585: 586: ret = kgsl_memdesc_init_fixed(device, GMU_PDEV(device), resource, md); 587: if (ret) 588: return ERR_PTR(ret); 589: 590: ret = gmu_core_map_gmu(device, md, addr, vma_id, attrs, align); 591: 592: sg_free_table(md->sgt); 593: kfree(md->sgt); 594: md->sgt = NULL; 595: 596: if (!ret) { 597: gmu->global_entries++; 598: } else { 599: dev_err(GMU_PDEV_DEV(device), 600: "Unable to map GMU kernel block: addr:0x%08x size:0x%llx :%d\n", 601: addr, md->size, ret); 602: memset(md, 0x0, sizeof(*md)); 603: md = ERR_PTR(ret); 604: } 605: return md; 606: } 607: 608: int gmu_core_alloc_kernel_block(struct kgsl_device *device, 609: struct kgsl_memdesc *md, u32 size, u32 vma_id, int attrs) 610: { 611: int ret; 612: 613: ret = kgsl_allocate_kernel(device, md, size, 0, KGSL_MEMDESC_SYSMEM); 614: if (ret) 615: return ret; 616: 617: ret = gmu_core_map_gmu(device, md, 0, vma_id, attrs, 0); 618: if (ret) 619: kgsl_sharedmem_free(md); 620: 621: return ret; 622: } 623: 624: void gmu_core_free_block(struct kgsl_device *device, struct kgsl_memdesc *md) 625: { 626: struct gmu_core_device *gmu = &device->gmu_core; 627: int vma_id = gmu_core_find_vma_block(device, md->gmuaddr, md->size); 628: struct gmu_vma_entry *vma; 629: struct gmu_vma_node *vma_node; 630: 631: if ((vma_id < 0) || !vma_is_dynamic(device, vma_id)) 632: return; 633: 634: vma = &gmu->vma[vma_id]; 635: 636: /* 637: * Do not remove the vma node if we failed to unmap the entire buffer. This is because the 638: * iommu driver considers remapping an already mapped iova as fatal. 639: */ 640: if (md->size != iommu_unmap(device->gmu_core.domain, md->gmuaddr, md->size)) 641: goto free; 642: 643: spin_lock(&vma->lock); 644: vma_node = find_va(vma, md->gmuaddr, md->size); 645: if (vma_node) 646: rb_erase(&vma_node->node, &vma->vma_root); 647: spin_unlock(&vma->lock); 648: kfree(vma_node); 649: free: 650: kgsl_sharedmem_free(md); 651: } 652: 653: int gmu_core_process_prealloc(struct kgsl_device *device, struct gmu_block_header *blk) 654: { 655: struct kgsl_memdesc *md; 656: int id = gmu_core_find_vma_block(device, blk->addr, blk->value); 657: 658: if (id < 0) { 659: dev_err(GMU_PDEV_DEV(device), 660: "Invalid prealloc block addr: 0x%x value:%d\n", 661: blk->addr, blk->value); 662: return id; 663: } 664: 665: /* Nothing to do for TCM blocks or user uncached */ 666: if (id == GMU_ITCM || id == GMU_DTCM || id == GMU_NONCACHED_USER) 667: return 0; 668: 669: /* Check if the block is already allocated */ 670: md = gmu_core_find_memdesc(device, blk->addr, blk->value); 671: if (md != NULL) 672: return 0; 673: 674: md = gmu_core_reserve_kernel_block(device, blk->addr, blk->value, id, 0); 675: 676: return PTR_ERR_OR_ZERO(md); 677: } 678: 679: static int gmu_core_iommu_fault_handler(struct iommu_domain *domain, 680: struct device *dev, unsigned long addr, int flags, void *token) 681: { 682: char *fault_type = "unknown"; 683: 684: if (flags & IOMMU_FAULT_TRANSLATION) 685: fault_type = "translation"; 686: else if (flags & IOMMU_FAULT_PERMISSION) 687: fault_type = "permission"; 688: else if (flags & IOMMU_FAULT_EXTERNAL) 689: fault_type = "external"; 690: else if (flags & IOMMU_FAULT_TRANSACTION_STALLED) 691: fault_type = "transaction stalled"; 692: 693: dev_err(dev, "GMU fault addr = %lX, context=kernel (%s %s fault)\n", 694: addr, (flags & IOMMU_FAULT_WRITE) ? "write" : "read", fault_type); 695: 696: return 0; 697: } 698: 699: #if (KERNEL_VERSION(6, 13, 0) <= LINUX_VERSION_CODE) 700: static struct iommu_domain *gmu_core_iommu_domain_alloc(struct device *dev) 701: { 702: return iommu_paging_domain_alloc(dev); 703: } 704: #else 705: #include 706: static struct iommu_domain *gmu_core_iommu_domain_alloc(struct device *dev) 707: { 708: return iommu_domain_alloc(&platform_bus_type); 709: } 710: #endif 711: 712: int gmu_core_iommu_init(struct kgsl_device *device) 713: { 714: struct device *gmu_pdev_dev = GMU_PDEV_DEV(device); 715: int ret; 716: 717: device->gmu_core.domain = gmu_core_iommu_domain_alloc(gmu_pdev_dev); 718: if (IS_ERR_OR_NULL(device->gmu_core.domain)) { 719: ret = (device->gmu_core.domain) ? PTR_ERR(device->gmu_core.domain) : -ENODEV; 720: dev_err(gmu_pdev_dev, "Unable to allocate GMU IOMMU domain: %d\n", ret); 721: return ret; 722: } 723: 724: /* 725: * Disable stall on fault for the GMU context bank. 726: * This sets SCTLR.CFCFG = 0. 727: * Also note that, the smmu driver sets SCTLR.HUPCF = 0 by default. 728: */ 729: qcom_iommu_set_fault_model(device->gmu_core.domain, 730: QCOM_IOMMU_FAULT_MODEL_NO_STALL); 731: 732: ret = kgsl_attach_iommu_group(gmu_pdev_dev, device->gmu_core.domain, 733: &device->gmu_core.group); 734: if (!ret) { 735: iommu_set_fault_handler(device->gmu_core.domain, 736: gmu_core_iommu_fault_handler, device); 737: return 0; 738: } 739: 740: dev_err(gmu_pdev_dev, "Unable to attach GMU IOMMU domain: %d\n", ret); 741: iommu_domain_free(device->gmu_core.domain); 742: device->gmu_core.domain = NULL; 743: 744: return ret; 745: } 746: 747: void gmu_core_dev_force_first_boot(struct kgsl_device *device) 748: { 749: const struct gmu_dev_ops *ops = GMU_DEVICE_OPS(device); 750: 751: if (ops && ops->force_first_boot) 752: return ops->force_first_boot(device); 753: } 754: 755: int gmu_core_set_vrb_register(struct kgsl_memdesc *vrb, u32 index, u32 val) 756: { 757: u32 *vrb_buf; 758: 759: if (WARN_ON(IS_ERR_OR_NULL(vrb))) 760: return -ENODEV; 761: 762: if (WARN_ON(index >= (vrb->size >> 2))) { 763: pr_err("kgsl: Unable to set VRB register for index %u\n", index); 764: return -EINVAL; 765: } 766: 767: vrb_buf = vrb->hostptr; 768: vrb_buf[index] = val; 769: 770: /* Make sure the vrb write is posted before moving ahead */ 771: wmb(); 772: 773: return 0; 774: } 775: 776: int gmu_core_get_vrb_register(struct kgsl_memdesc *vrb, u32 index, u32 *val) 777: { 778: u32 *vrb_buf; 779: 780: if (IS_ERR_OR_NULL(vrb)) 781: return -ENODEV; 782: 783: if (WARN_ON(index >= (vrb->size >> 2))) { 784: pr_err("kgsl: Unable to get VRB register for index %u\n", index); 785: return -EINVAL; 786: } 787: 788: vrb_buf = vrb->hostptr; 789: *val = vrb_buf[index]; 790: 791: return 0; 792: } 793: 794: static void _gmu_trace_dcvs_pwrlevel(struct kgsl_device *device, struct gmu_trace_packet *pkt) 795: { 796: struct trace_dcvs_pwrlvl *data = (struct trace_dcvs_pwrlvl *)pkt->payload; 797: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 798: 799: /* 800: * After a slumber, gmu will have the previous power level as num_pwrlevels. 801: * Set the previous power level as the current level for the trace to be 802: * accurate. 803: */ 804: if (data->prev_pwrlvl == pwr->num_pwrlevels) 805: data->prev_pwrlvl = pwr->active_pwrlevel; 806: 807: if (pwr->active_pwrlevel != data->new_pwrlvl) { 808: u32 penalty = FIELD_PREP(GENMASK(31, 16), data->penalty_down) | 809: FIELD_PREP(GENMASK(15, 0), data->penalty_up); 810: u32 step_down_cnt = FIELD_PREP(GENMASK(31, 16), data->subsequent_step_down_count) | 811: FIELD_PREP(GENMASK(15, 0), data->first_step_down_count); 812: u32 freq_cap = FIELD_PREP(GENMASK(31, 16), data->max_freq) | 813: FIELD_PREP(GENMASK(15, 0), data->min_freq); 814: u32 num_samples = FIELD_PREP(GENMASK(31, 16), data->num_samples_down) | 815: FIELD_PREP(GENMASK(15, 0), data->num_samples_up); 816: 817: trace_kgsl_pwrlevel(device, data->new_pwrlvl, 818: pwr->pwrlevels[data->new_pwrlvl].gpu_freq, MATCH LINES: 834, 846, 873, 876, 884, 892, 900, 904, 907, 908, 911, 912, 915, 916, 919, 926, 942, 943, 945, 947, 974 822: KGSL_TRACE_GPU_FREQ(pwr->pwrlevels[data->new_pwrlvl].gpu_freq/1000, 823: 0, pkt->ticks); 824: 825: trace_adreno_gpu_vote_params(data->new_pwrlvl, data->prev_pwrlvl, 826: data->avg_busy, data->flag, penalty, step_down_cnt, freq_cap, 827: num_samples, data->target_fps, data->mod_percent, pkt->ticks); 828: } 829: 830: pwr->active_pwrlevel = data->new_pwrlvl; 831: pwr->previous_pwrlevel = data->prev_pwrlvl; 832: } 833: 834: static void _gmu_trace_dcvs_buslevel(struct kgsl_device *device, struct gmu_trace_packet *pkt) 835: { 836: struct trace_dcvs_buslvl *data = (struct trace_dcvs_buslvl *)pkt->payload; 837: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 838: 839: trace_kgsl_buslevel(device, data->gpu_pwrlvl, data->buslvl, 840: data->cur_abmbps, pkt->ticks); 841: 842: pwr->cur_dcvs_buslevel = data->buslvl; 843: pwr->bus_ab_mbytes = data->cur_abmbps; 844: } 845: 846: static void _gmu_trace_dcvs_pwrstats(struct kgsl_device *device, struct gmu_trace_packet *pkt) 847: { 848: struct trace_dcvs_pwrstats *data = (struct trace_dcvs_pwrstats *)pkt->payload; 849: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 850: struct kgsl_power_stats stats; 851: 852: kgsl_pwrctrl_busy_time(device, data->total_time, data->gpu_time, pkt->ticks); 853: 854: stats.busy_time = data->gpu_time; 855: stats.ram_time = data->ram_time; 856: stats.ram_wait = data->ram_wait; 857: trace_kgsl_pwrstats(device, data->total_time, &stats, 858: device->active_context_count, pkt->ticks); 859: 860: pwr->clock_times[pwr->active_pwrlevel] += data->gpu_time; 861: pwr->time_in_pwrlevel[pwr->active_pwrlevel] += data->total_time; 862: if (pwr->thermal_pwrlevel) 863: pwr->thermal_time += data->gpu_time; 864: 865: pwr->aggr_max_pwrlevel = data->aggr_max_pwrlevel; 866: 867: spin_lock(&pwr->stats_lock); 868: pwr->accum_busy_stats += data->gpu_time; 869: pwr->accum_total_time += data->total_time; 870: spin_unlock(&pwr->stats_lock); 871: } 872: 873: static void stream_trace_data(struct kgsl_device *device, struct gmu_trace_packet *pkt) 874: { 875: switch (pkt->trace_id) { 876: case GMU_TRACE_PREEMPT_TRIGGER: { 877: struct trace_preempt_trigger *data = 878: (struct trace_preempt_trigger *)pkt->payload; 879: 880: trace_adreno_preempt_trigger(data->cur_rb, data->next_rb, 881: data->ctx_switch_cntl, pkt->ticks); 882: break; 883: } 884: case GMU_TRACE_PREEMPT_DONE: { 885: struct trace_preempt_done *data = 886: (struct trace_preempt_done *)pkt->payload; 887: 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; 929: trace_adreno_gpu_dcvs_profile(data, pkt->ticks); 930: break; 931: } 932: default: { 933: char str[64]; 934: 935: snprintf(str, sizeof(str), 936: "Unsupported GMU trace id %d\n", pkt->trace_id); 937: trace_kgsl_msg(str); 938: } 939: } 940: } 941: 942: void gmu_core_process_trace_data(struct kgsl_device *device, 943: struct device *dev, struct kgsl_gmu_trace *trace) 944: { 945: struct gmu_trace_header *trace_hdr; 946: u32 size, *buffer; 947: struct gmu_trace_packet *pkt; 948: u16 seq_num, num_pkts = 0; 949: u32 ridx, widx; 950: 951: if (IS_ERR_OR_NULL(trace->md)) 952: return; 953: 954: trace_hdr = trace->md->hostptr; 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: MATCH LINES: 1022, 1027, 1029, 1035, 1040, 1045, 1048, 1052, 1056, 1061, 1065, 1071, 1083, 1085, 1087, 1090, 1093, 1095, 1109, 1111, 1122, 1124, 1138, 1164, 1168, 1169, 1171, 1174, 1175, 1180, 1201, 1203, 1207, 1210, 1213, 1216, 1218, 1220, 1224, 1228, 1231, 1232, 1235, 1242, 1244, 1246, 1259, 1276, 1284, 1286, 1288, 1290, 1292, 1294, 1298, 1300, 1302, 1305, 1307, 1313, 1319, 1328, 1330, 1335, 1337, 1339, 1347, 1350, 1351, 1355, 1360, 1361, 1362, 1364, 1365, 1368, 1369, 1375, 1376, 1377, 1379, 1380, 1383, 1384, 1389, 1395, 1414, 1416 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: 1018: ridx = (ridx + size) % trace_hdr->payload_size; 1019: writel(ridx, &trace_hdr->read_index); 1020: } 1021: 1022: bool gmu_core_is_trace_empty(struct gmu_trace_header *hdr) 1023: { 1024: return (readl(&hdr->read_index) == readl(&hdr->write_index)) ? true : false; 1025: } 1026: 1027: void gmu_core_trace_header_init(struct kgsl_gmu_trace *trace) 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) 1074: return false; 1075: 1076: /* Capabilities payload data stored in 1 byte */ 1077: if (caps->data[field / BITS_PER_BYTE] & BIT(field % BITS_PER_BYTE)) 1078: return true; 1079: 1080: return false; 1081: } 1082: 1083: void gmu_core_mark_for_coldboot(struct kgsl_device *device) 1084: { 1085: struct gmu_core_device *gmu_core = &device->gmu_core; 1086: 1087: if (!gmu_core->warmboot_enabled) 1088: return; 1089: 1090: set_bit(GMU_FORCE_COLDBOOT, &gmu_core->flags); 1091: } 1092: 1093: void gmu_core_rdpm_probe(struct kgsl_device *device) 1094: { 1095: struct gmu_core_device *gmu = &device->gmu_core; 1096: struct resource *res; 1097: 1098: res = platform_get_resource_byname(device->pdev, IORESOURCE_MEM, "rdpm_cx"); 1099: if (res) 1100: gmu->rdpm_cx_virt = devm_ioremap(&device->pdev->dev, 1101: res->start, resource_size(res)); 1102: 1103: res = platform_get_resource_byname(device->pdev, IORESOURCE_MEM, "rdpm_mx"); 1104: if (res) 1105: gmu->rdpm_mx_virt = devm_ioremap(&device->pdev->dev, 1106: res->start, resource_size(res)); 1107: } 1108: 1109: void gmu_core_rdpm_mx_freq_update(struct kgsl_device *device, u32 freq) 1110: { 1111: struct gmu_core_device *gmu = &device->gmu_core; 1112: 1113: if (!gmu->rdpm_mx_virt) 1114: return; 1115: 1116: writel_relaxed(freq / 1000, (gmu->rdpm_mx_virt + gmu->rdpm_mx_offset)); 1117: 1118: /* Ensure previous writes post before this one, i.e. act like normal writel() */ 1119: wmb(); 1120: } 1121: 1122: void gmu_core_rdpm_cx_freq_update(struct kgsl_device *device, u32 freq) 1123: { 1124: struct gmu_core_device *gmu = &device->gmu_core; 1125: 1126: if (!gmu->rdpm_cx_virt) 1127: return; 1128: 1129: writel_relaxed(freq / 1000, (gmu->rdpm_cx_virt + gmu->rdpm_cx_offset)); 1130: 1131: /* Ensure previous writes post before this one, i.e. act like normal writel() */ 1132: wmb(); 1133: } 1134: 1135: static void build_hub_opp_table(struct kgsl_device *device) 1136: { 1137: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1138: struct gmu_core_device *gmu = &device->gmu_core; 1139: struct device_node *opp_table, *opp; 1140: int i = 0; 1141: 1142: opp_table = of_find_node_by_name(NULL, "hub_opp_table"); 1143: if (!opp_table) 1144: goto err; 1145: 1146: for_each_child_of_node(opp_table, opp) { 1147: if (of_property_read_u64(opp, "opp-hz", (u64 *)&gmu->hub_freqs[i])) 1148: goto err; 1149: 1150: if (of_property_read_u32(opp, "opp-level", &gmu->hub_vlvls[i])) 1151: goto err; 1152: 1153: i++; 1154: } 1155: 1156: gmu->num_hub_freqs = i; 1157: of_node_put(opp_table); 1158: return; 1159: 1160: err: 1161: if (opp_table) 1162: of_node_put(opp_table); 1163: 1164: gmu->hub_freqs[0] = adreno_dev->gmu_hub_clk_freq; 1165: gmu->num_hub_freqs = 1; 1166: } 1167: 1168: #define GMU_FREQ_MIN 200000000 1169: #define GMU_FREQ_MAX 500000000 1170: 1171: int gmu_core_clk_probe(struct kgsl_device *device) 1172: { 1173: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1174: struct platform_device *gmu_pdev = GMU_PDEV(device); 1175: struct gmu_core_device *gmu = &device->gmu_core; 1176: int tbl_size, num_freqs, num_perf_ddr_bw, offset, ret, i; 1177: 1178: build_hub_opp_table(device); 1179: 1180: ret = devm_clk_bulk_get_all(GMU_PDEV_DEV(device), &gmu->clks); 1181: if (ret < 0) 1182: return ret; 1183: 1184: /* 1185: * Voting for apb_pclk will enable power and clocks required for 1186: * QDSS path to function. However, if QCOM_KGSL_QDSS_STM is not enabled, 1187: * QDSS is essentially unusable. Hence, if QDSS cannot be used, 1188: * don't vote for this clock. 1189: */ 1190: if (!IS_ENABLED(CONFIG_QCOM_KGSL_QDSS_STM)) { 1191: for (i = 0; i < ret; i++) { 1192: if (!strcmp(gmu->clks[i].id, "apb_pclk")) { 1193: gmu->clks[i].clk = NULL; 1194: break; 1195: } 1196: } 1197: } 1198: 1199: gmu->num_clks = ret; 1200: 1201: if (of_get_property(gmu_pdev->dev.of_node, 1202: "qcom,gmu-perf-ddr-bw", &tbl_size) == NULL) 1203: goto read_gmu_freq; 1204: 1205: num_perf_ddr_bw = (tbl_size / sizeof(u32)); 1206: if (num_perf_ddr_bw >= ARRAY_SIZE(gmu->perf_ddr_bw)) 1207: goto read_gmu_freq; 1208: 1209: for (i = 0; i < num_perf_ddr_bw; i++) { 1210: ret = of_property_read_u32_index(gmu_pdev->dev.of_node, 1211: "qcom,gmu-perf-ddr-bw", i, &gmu->perf_ddr_bw[i]); 1212: if (ret) 1213: goto read_gmu_freq; 1214: } 1215: 1216: read_gmu_freq: 1217: /* Read the optional list of GMU frequencies */ 1218: if (of_get_property(gmu_pdev->dev.of_node, 1219: "qcom,gmu-freq-table", &tbl_size) == NULL) 1220: goto default_gmu_freq; 1221: 1222: num_freqs = (tbl_size / sizeof(u32)) / 2; 1223: if (num_freqs >= ARRAY_SIZE(gmu->freqs)) 1224: goto default_gmu_freq; 1225: 1226: for (i = 0; i < num_freqs; i++) { 1227: offset = i * 2; 1228: ret = of_property_read_u32_index(gmu_pdev->dev.of_node, 1229: "qcom,gmu-freq-table", offset, &gmu->freqs[i]); 1230: if (ret) 1231: goto default_gmu_freq; 1232: ret = of_property_read_u32_index(gmu_pdev->dev.of_node, 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: 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: 1335: void gmu_core_scale_gmu_frequency(struct kgsl_device *device, int buslevel) 1336: { 1337: struct gmu_core_device *gmu = &device->gmu_core; 1338: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1339: u32 i, gmu_level = 0; 1340: 1341: if (!gmu->perf_ddr_bw[0]) 1342: return; 1343: 1344: /* Check if IB threshold has been breached to scale gmu */ 1345: for (i = 0; i < MAX_CX_LEVELS; i++) { 1346: if ((pwr->ddr_table[buslevel] >= gmu->perf_ddr_bw[i]) && (gmu->perf_ddr_bw[i] != 0)) 1347: gmu_level = (i + 1); 1348: } 1349: 1350: if ((gmu_level < MAX_CX_LEVELS) && (gmu->cur_level != gmu_level)) 1351: gmu_core_clock_set_rate(device, gmu_level); 1352: 1353: } 1354: 1355: int gmu_core_hwsched_memory_init(struct kgsl_device *device) 1356: { 1357: int ret; 1358: 1359: /* GMU Virtual register bank */ 1360: if (IS_ERR_OR_NULL(device->gmu_core.vrb)) { 1361: device->gmu_core.vrb = gmu_core_reserve_kernel_block(device, 0, GMU_VRB_SIZE, 1362: GMU_NONCACHED_KERNEL, 0); 1363: 1364: if (IS_ERR(device->gmu_core.vrb)) 1365: return PTR_ERR(device->gmu_core.vrb); 1366: 1367: /* Populate size of the virtual register bank */ 1368: ret = gmu_core_set_vrb_register(device->gmu_core.vrb, VRB_SIZE_IDX, 1369: device->gmu_core.vrb->size >> 2); 1370: if (ret) 1371: return ret; 1372: } 1373: 1374: /* GMU trace log */ 1375: if (IS_ERR_OR_NULL(device->gmu_core.trace.md)) { 1376: device->gmu_core.trace.md = gmu_core_reserve_kernel_block(device, 0, 1377: GMU_TRACE_SIZE, GMU_NONCACHED_KERNEL, 0); 1378: 1379: if (IS_ERR(device->gmu_core.trace.md)) 1380: return PTR_ERR(device->gmu_core.trace.md); 1381: 1382: /* Pass trace buffer address to GMU through the VRB */ 1383: ret = gmu_core_set_vrb_register(device->gmu_core.vrb, VRB_TRACE_BUFFER_ADDR_IDX, 1384: device->gmu_core.trace.md->gmuaddr); 1385: if (ret) 1386: return ret; 1387: 1388: /* Initialize the GMU trace buffer header */ 1389: gmu_core_trace_header_init(&device->gmu_core.trace); 1390: } 1391: 1392: return 0; 1393: } 1394: 1395: struct platform_device *get_gmu_wrapper_pdev(void) 1396: { 1397: struct device_node *node; 1398: struct platform_device *pdev = NULL; 1399: 1400: node = of_find_compatible_node(NULL, NULL, "qcom,adreno-gmu-wrapper"); 1401: if (!node) 1402: return NULL; 1403: 1404: if (!of_device_is_available(node)) { 1405: of_node_put(node); 1406: return NULL; 1407: } 1408: 1409: pdev = of_find_device_by_node(node); 1410: of_node_put(node); 1411: return pdev; 1412: } 1413: 1414: bool is_gmu_wrapper_available(void) 1415: { 1416: struct platform_device *pdev = get_gmu_wrapper_pdev(); 1417: 1418: platform_device_put(pdev); 1419: 1420: return pdev != NULL; 1421: } --- FILE: \kgsl_gmu_core.h | HITS: 254 --- MATCH LINES: 6, 7, 14, 15, 17, 18, 20, 21, 40, 44, 57, 58, 61, 62, 63, 64, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 82, 88, 89, 90, 91, 92, 93, 107, 115, 116, 121, 126, 127, 128, 129, 132, 133, 134, 135, 136, 137, 138, 139, 140, 160, 161, 162, 165, 173, 174, 175, 176, 177, 178, 179, 180, 183, 184, 185, 186, 189, 190, 191, 192, 193, 194, 195, 196, 199, 202, 208, 240 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: #ifndef __KGSL_GMU_CORE_H 7: #define __KGSL_GMU_CORE_H 8: 9: #include 10: #include 11: 12: #include "kgsl_sharedmem.h" 13: 14: /* GMU_DEVICE - Given an KGSL device return the GMU specific struct */ 15: #define GMU_DEVICE_OPS(_a) ((_a)->gmu_core.dev_ops) 16: 17: /* GMU_PDEV - Given a KGSL device return the GMU platform device struct */ 18: #define GMU_PDEV(device) ((device)->gmu_core.pdev) 19: 20: /* GMU_PDEV_DEV - Given a KGSL device return pointer to struct dev for GMU platform device */ 21: #define GMU_PDEV_DEV(device) (&((GMU_PDEV(device))->dev)) 22: 23: #define MAX_GX_LEVELS 32 24: #define MAX_GX_LEVELS_LEGACY 16 25: #define MAX_CX_LEVELS 16 26: #define MAX_CX_LEVELS_LEGACY 4 27: #define MAX_BW_LEVELS 16 28: #define MAX_CNOC_LEVELS 2 29: #define MAX_CNOC_CMDS 6 30: #define MAX_BW_CMDS 8 31: #define INVALID_DCVS_IDX 0xFF 32: #define INVALID_AB_VALUE 0xFFFF 33: #define MAX_AB_VALUE (0xFFFF - 1) 34: #define INVALID_BW_VOTE (INVALID_DCVS_IDX | \ 35: (FIELD_PREP(GENMASK(31, 16), INVALID_AB_VALUE))) 36: #if MAX_CNOC_LEVELS > MAX_GX_LEVELS 37: #error "CNOC levels cannot exceed GX levels" 38: #endif 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 { 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; 169: u32 value; 170: }; 171: 172: /* GMU Block types */ 173: #define GMU_BLK_TYPE_DATA 0 174: #define GMU_BLK_TYPE_PREALLOC_REQ 1 175: #define GMU_BLK_TYPE_CORE_VER 2 176: #define GMU_BLK_TYPE_CORE_DEV_VER 3 177: #define GMU_BLK_TYPE_PWR_VER 4 178: #define GMU_BLK_TYPE_PWR_DEV_VER 5 179: #define GMU_BLK_TYPE_HFI_VER 6 180: #define GMU_BLK_TYPE_PREALLOC_PERSIST_REQ 7 181: 182: /* GMU Block IDs */ 183: #define GMU_BLOCK_ID_REGISTER 0 184: #define GMU_BLOCK_ID_ALLOCATION 1 185: #define GMU_BLOCK_ID_COMMON_CAPS 2 186: #define GMU_BLOCK_ID_PLATFORM_CAPS 3 187: 188: /* GMU Field IDs */ 189: #define GMU_FIELD_DATA GMU_BLK_TYPE_DATA 190: #define GMU_FIELD_PREALLOC GMU_BLK_TYPE_PREALLOC_REQ 191: #define GMU_FIELD_CORE_VERSION GMU_BLK_TYPE_CORE_VER 192: #define GMU_FIELD_CORE_DEV_VERSION GMU_BLK_TYPE_CORE_DEV_VER 193: #define GMU_FIELD_PWR_VERSION GMU_BLK_TYPE_PWR_VER 194: #define GMU_FIELD_PWR_DEV_VERSION GMU_BLK_TYPE_PWR_DEV_VER 195: #define GMU_FIELD_HFI_VERSION GMU_BLK_TYPE_HFI_VER 196: #define GMU_FIELD_PREALLOC_PERSISTENT GMU_BLK_TYPE_PREALLOC_PERSIST_REQ 197: 198: /* For GMU Logs*/ 199: #define GMU_LOG_SIZE SZ_64K 200: 201: /* For GMU virtual register bank */ 202: #define GMU_VRB_SIZE SZ_4K 203: 204: /* 205: * GMU Virtual Register Definitions 206: * These values are dword offsets into the GMU Virtual Register Bank 207: */ 208: enum gmu_vrb_idx { 209: /* Number of dwords supported by VRB */ 210: VRB_SIZE_IDX = 0, 211: /* Contains the address of warmboot scratch buffer */ 212: VRB_WARMBOOT_SCRATCH_IDX = 1, 213: /* Contains the address of GMU trace buffer */ 214: VRB_TRACE_BUFFER_ADDR_IDX = 2, 215: /* Contains the number of hw fence shadow table entries */ 216: VRB_HW_FENCE_SHADOW_NUM_ENTRIES = 3, 217: /* Contains OpenCL no fault tolerance timeout in ms */ 218: VRB_CL_NO_FT_TIMEOUT = 4, 219: /* Contains the total number of GPU preemptions */ 220: VRB_PREEMPT_COUNT_TOTAL = 5, 221: /* Contains the number of L0 GPU preemptions */ 222: VRB_PREEMPT_COUNT_L0 = 6, 223: /* Contains the number of L1A GPU preemptions */ 224: VRB_PREEMPT_COUNT_L1A = 7, 225: /* Contains the number of L1B GPU preemptions */ 226: VRB_PREEMPT_COUNT_L1B = 8, 227: /* Contains the GMU VA for power limits trace buffer */ 228: VRB_PWR_LIMITS_TRACE_BUF = 9, 229: /* Contains the total size of context record in KB */ 230: VRB_CTXRECORD_TOTAL_SZ = 10, 231: /* Contains the size of AQE context record in KB */ 232: VRB_CTXRECORD_AQE_SZ = 11, 233: /* Contains the size of GMEM inside context record in KB */ 234: VRB_CTXRECORD_GMEM_SZ = 12, 235: /* Contains whether to enable fault on DBGC interrupts */ 236: VRB_DBGC_FAULT_ENABLE = 17, 237: }; 238: 239: /* For GMU Trace */ 240: #define GMU_TRACE_SIZE SZ_16K 241: 242: /* Trace header defines */ 243: /* Logtype to decode the trace pkt data */ 244: #define TRACE_LOGTYPE_HWSCHED 1 245: /* Trace buffer threshold for GMU to send F2H message */ 246: #define TRACE_BUFFER_THRESHOLD 80 247: /* 248: * GMU Trace timer value to check trace packet consumption. GMU timer handler tracks the 249: * readindex, If it's not moved since last timer fired, GMU will send the f2h message to 250: * drain trace packets. GMU Trace Timer will be restarted if the readindex is moving. 251: */ 252: #define TRACE_TIMEOUT_MSEC 5 253: 254: /* Trace metadata defines */ 255: /* Trace drop mode hint for GMU to drop trace packets when trace buffer is full */ 256: #define TRACE_MODE_DROP 1 257: /* Trace buffer header version */ 258: #define TRACE_HEADER_VERSION_1 1 259: 260: /* Trace packet defines */ 261: #define TRACE_PKT_VALID 1 262: #define TRACE_PKT_SEQ_MASK GENMASK(15, 0) 263: #define TRACE_PKT_SZ_MASK GENMASK(27, 16) 264: #define TRACE_PKT_SZ_SHIFT 16 MATCH LINES: 285 273: #define TRACE_PKT_GET_SKIP_FIELD(hdr) (((hdr) & TRACE_PKT_SKIP_MASK) >> TRACE_PKT_SKIP_SHIFT) 274: 275: /* 276: * Trace buffer header definition 277: * Trace buffer header fields initialized/updated by KGSL and GMU 278: * GMU input: Following header fields are initialized by KGSL 279: * - @metadata, @threshold, @size, @cookie, @timeout, @log_type 280: * - @readIndex updated by kgsl when traces messages are consumed. 281: * GMU output: Following header fields are initialized by GMU only 282: * - @magic, @payload_offset, @payload_size 283: * - @write_index updated by GMU upon filling the trace messages 284: */ 285: struct gmu_trace_header { 286: /** @magic: Initialized by GMU to check header is valid or not */ 287: u32 magic; 288: /** 289: * @metadata: Trace buffer metadata.Bit(31) Trace Mode to log tracepoints 290: * messages, Bits [3:0] Version for header format changes. 291: */ 292: u32 metadata; 293: /** 294: * @threshold: % at which GMU to send f2h message to wakeup KMD to consume 295: * tracepoints data. Set it to zero to disable thresholding. Threshold is % 296: * of buffer full condition not the trace packet count. If GMU is continuously 297: * writing to trace buffer makes it buffer full condition when KMD is not 298: * consuming it. So GMU check the how much trace buffer % space is full based 299: * on the threshold % value.If the trace packets are filling over % buffer full 300: * condition GMU will send the f2h message for KMD to drain the trace messages. 301: */ 302: u32 threshold; 303: /** @size: trace buffer allocation size in bytes */ 304: u32 size; 305: /** @read_index: trace buffer read index in dwords */ 306: u32 read_index; 307: /** @write_index: trace buffer write index in dwords */ 308: u32 write_index; 309: /** @payload_offset: trace buffer payload dword offset */ MATCH LINES: 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 357 313: /** cookie: cookie data sent through F2H_PROCESS_MESSAGE */ 314: u64 cookie; 315: /** 316: * timeout: GMU Trace Timer value in msec - zero to disable trace timer else 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; 381: u16 padding; MATCH LINES: 412, 414, 424, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 439, 441, 445, 447, 459, 465, 479, 480, 481, 482, 483, 484, 486, 488, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 517, 526, 527, 528, 539, 549, 554, 556, 559, 566, 567, 571 400: u32 type; 401: u32 value; 402: u32 status; 403: } __packed; 404: 405: struct trace_dcvs_profile { 406: u32 action; 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: */ 445: struct gmu_memdesc { 446: void *hostptr; 447: u32 gmuaddr; 448: phys_addr_t physaddr; 449: u32 size; 450: }; 451: 452: struct kgsl_mailbox { 453: struct mbox_client client; 454: struct mbox_chan *channel; 455: }; 456: 457: struct icc_path; 458: 459: struct gmu_vma_node { 460: struct rb_node node; 461: u32 va; 462: u32 size; 463: }; 464: 465: struct gmu_vma_entry { 466: /** @start: Starting virtual address of the vma */ 467: u32 start; 468: /** @size: Size of this vma */ 469: u32 size; 470: /** @next_va: Next available virtual address in this vma */ 471: u32 next_va; 472: /** @lock: Spinlock for synchronization */ 473: spinlock_t lock; 474: /** @vma_root: RB tree root that keeps track of dynamic allocations */ 475: struct rb_root vma_root; 476: }; 477: 478: enum { 479: GMU_PRIV_FIRST_BOOT_DONE = 0, 480: GMU_PRIV_GPU_STARTED, 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; 556: const struct gmu_dev_ops *dev_ops; 557: unsigned long flags; 558: /** @gf_panic: GMU fault panic policy */ 559: enum gmu_fault_panic_policy gf_panic; 560: /** @pdev: platform device for the gmu */ 561: struct platform_device *pdev; 562: /** @domain: IOMMU domain for the gmu context */ 563: struct iommu_domain *domain; 564: /** @group: IOMMU group for the gmu context */ 565: struct iommu_group *group; 566: /** @gmu_globals: Array to store gmu global buffers */ 567: struct kgsl_memdesc gmu_globals[GMU_KERNEL_ENTRIES]; 568: /** @global_entries: To keep track of number of gmu buffers */ 569: u32 global_entries; 570: /** @vma: VMA entry for GMU */ 571: struct gmu_vma_entry *vma; 572: /** @num_vmas: Number of entries in the @vma array */ 573: u32 num_vmas; 574: /** @common_caps: GMU firmware common capabilities */ 575: struct firmware_capabilities common_caps; 576: /** @platform_caps: GMU firmware platform capabilities */ 577: struct firmware_capabilities platform_caps; 578: /* @ver: GMU Version information */ 579: struct { 580: u32 core; 581: u32 core_dev; 582: u32 pwr; 583: u32 pwr_dev; 584: u32 hfi; 585: } ver; 586: /** @warmboot_enabled: True if warmboot is enabled */ 587: bool warmboot_enabled; 588: /** @rdpm_cx_virt: Pointer where the RDPM CX block is mapped */ 589: void __iomem *rdpm_cx_virt; 590: /** @rdpm_mx_virt: Pointer where the RDPM MX block is mapped */ 591: void __iomem *rdpm_mx_virt; 592: /** @rdpm_cx_offset: Offset of RDPM CX register */ 593: u32 rdpm_cx_offset; 594: /** @rdpm_mx_offset: Offset of RDPM MX register */ 595: u32 rdpm_mx_offset; MATCH LINES: 626, 629, 630, 631, 632, 636, 637, 639, 640, 641, 642, 643, 645, 649, 660, 662, 664, 665, 666, 667, 668, 669, 672, 678, 679, 682, 693, 699, 701, 709, 712, 717, 718, 721, 731, 735, 742, 745, 752, 755, 758, 761, 766, 769, 776, 779, 790, 794, 807, 811, 822, 826, 830, 833, 839, 842, 847, 849, 852, 859, 862, 869, 872, 877, 878, 881, 886, 889, 892, 895, 898, 901, 907, 910, 916, 919, 923, 926, 936, 940, 943, 946, 952, 955, 961, 964, 969, 972, 974, 978, 981, 987, 990, 993, 996, 1000, 1003, 1011, 1015, 1019, 1022, 1026, 1028 614: u32 hub_freqs[MAX_CX_LEVELS]; 615: /** @hub_vlvls: Array of GMU hub voltage levels */ 616: u32 hub_vlvls[MAX_CX_LEVELS]; 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: * 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 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 */ 703: struct kgsl_memdesc *memdesc; 704: /** @type: Type of the memory descriptor */ 705: u32 type; 706: }; 707: 708: /** 709: * gmu_core_map_memdesc - Map the memdesc into the GMU IOMMU domain 710: * @domain: Domain to map the memory into 711: * @memdesc: Memory descriptor to map 712: * @gmuaddr: Virtual GMU address to map the memory into 713: * @attrs: Attributes for the mapping 714: * 715: * Return: 0 on success or -ENOMEM on failure 716: */ 717: int gmu_core_map_memdesc(struct iommu_domain *domain, struct kgsl_memdesc *memdesc, 718: u64 gmuaddr, int attrs); 719: 720: /** 721: * gmu_core_map_gmu - Map a kgsl memdesc to GMU 722: * @device: Pointer to kgsl device 723: * @md: Pointer to the kgsl memdesc 724: * @addr: Address where to map this memdesc 725: * @vma_id: VMA id to which this memdesc needs to be mapped 726: * @attrs: mapping attributes 727: * @align: Alignment request for this memdesc 728: 729: * Return: Zero on success or negative error on failure. 730: */ 731: int gmu_core_map_gmu(struct kgsl_device *device, struct kgsl_memdesc *md, 732: u32 addr, u32 vma_id, int attrs, u32 align); 733: 734: /** 735: * gmu_core_find_memdesc - Find the GMU memory descriptor for a given address and size 736: * @device: Pointer to KGSL device 737: * @addr: Address of the memory region 738: * @size: Size of the memory region 739: * 740: * Return: Pointer to the matching kgsl_memdesc structure if found, NULL otherwise. 741: */ 742: struct kgsl_memdesc *gmu_core_find_memdesc(struct kgsl_device *device, u32 addr, u32 size); 743: 744: /** 745: * gmu_core_find_vma_block - Find the VMA block for a given address and size 746: * @device: Pointer to KGSL device 747: * @addr: Address of the memory region 748: * @size: Size of the memory region 749: * 750: * Return: The index of the matching VMA entry if found, -ENOENT otherwise. 751: */ 752: int gmu_core_find_vma_block(struct kgsl_device *device, u32 addr, u32 size); 753: 754: /** 755: * gmu_core_free_globals - Free the GMU global memory descriptors 756: * @device: Pointer to KGSL device 757: */ 758: void gmu_core_free_globals(struct kgsl_device *device); 759: 760: /** 761: * gmu_core_get_attrs - Get the IOMMU attributes based on flags 762: * @flags: The memory flags indicating the attributes 763: * 764: * Return: IOMMU attributes. 765: */ 766: int gmu_core_get_attrs(u32 flags); 767: 768: /** 769: * gmu_core_import_buffer - Import a gmu buffer 770: * @device: Pointer to KGSL device 771: * @entry: GMU memory entry 772: * This function imports and maps a buffer to a gmu vma 773: * 774: * Return: 0 on success or error code on failure 775: */ 776: int gmu_core_import_buffer(struct kgsl_device *device, struct hfi_mem_alloc_entry *entry); 777: 778: /** 779: * gmu_core_reserve_kernel_block - Allocate a gmu buffer 780: * @device: Pointer to KGSL device 781: * @addr: Desired gmu virtual address 782: * @size: Size of the buffer in bytes 783: * @vma_id: Target gmu vma where this buffer should be mapped 784: * @align: Alignment as a power of two(2^n) bytes for the GMU VA 785: * 786: * This function allocates a buffer and maps it in the desired gmu vma 787: * 788: * Return: Pointer to the memory descriptor or error pointer on failure 789: */ 790: struct kgsl_memdesc *gmu_core_reserve_kernel_block(struct kgsl_device *device, 791: u32 addr, u32 size, u32 vma_id, u32 align); 792: 793: /** 794: * gmu_core_reserve_kernel_block_fixed - Maps phyical resource address to gmu 795: * @device: Pointer to KGSL device 796: * @addr: Desired gmu virtual address 797: * @size: Size of the buffer in bytes 798: * @vma_id: Target gmu vma where this buffer should be mapped 799: * @resource: Name of the resource to get the size and address to allocate 800: * @attrs: Attributes for the mapping 801: * @align: Alignment as a power of two(2^n) bytes for the GMU VA 802: * 803: * This function maps the physcial resource address to desired gmu vma 804: * 805: * Return: Pointer to the memory descriptor or error pointer on failure 806: */ 807: struct kgsl_memdesc *gmu_core_reserve_kernel_block_fixed(struct kgsl_device *device, 808: u32 addr, u32 size, u32 vma_id, const char *resource, int attrs, u32 align); 809: 810: /** 811: * gmu_core_alloc_kernel_block - Allocate a gmu buffer 812: * @device: Pointer to KGSL device 813: * @md: Pointer to the memdesc 814: * @size: Size of the buffer in bytes 815: * @vma_id: Target gmu vma where this buffer should be mapped 816: * @attrs: Attributes for the mapping 817: * 818: * This function allocates a buffer and maps it in the desired gmu vma 819: * 820: * Return: 0 on success or error code on failure 821: */ 822: int gmu_core_alloc_kernel_block(struct kgsl_device *device, 823: struct kgsl_memdesc *md, u32 size, u32 vma_id, int attrs); 824: 825: /** 826: * gmu_core_free_block - Free a gmu buffer 827: * @device: Pointer to KGSL device 828: * @md: Pointer to the memdesc that is to be freed 829: */ 830: void gmu_core_free_block(struct kgsl_device *device, struct kgsl_memdesc *md); 831: 832: /** 833: * gmu_core_process_prealloc - Process preallocate GMU blocks 834: * @device: Pointer to the KGSL device structure 835: * @blk: Pointer to the GMU block header structure 836: * 837: * Return: 0 on success, negative error code on failure. 838: */ 839: int gmu_core_process_prealloc(struct kgsl_device *device, struct gmu_block_header *blk); 840: 841: /** 842: * gmu_core_iommu_init - Set up GMU IOMMU and shared memory with GMU 843: * @device: Pointer to KGSL device 844: * 845: * Return: 0 on success or error value on failure 846: */ 847: int gmu_core_iommu_init(struct kgsl_device *device); 848: 849: void gmu_core_dev_force_first_boot(struct kgsl_device *device); 850: 851: /** 852: * gmu_core_set_vrb_register - set vrb register value at specified index 853: * @vrb: GMU virtual register bank memory 854: * @index: vrb index to write the value 855: * @val: value to be writen into vrb 856: * 857: * Return: Negative error on failure and zero on success. 858: */ 859: int gmu_core_set_vrb_register(struct kgsl_memdesc *vrb, u32 index, u32 val); 860: 861: /** 862: * gmu_core_get_vrb_register - get vrb register value at specified index 863: * @vrb: GMU virtual register bank memory 864: * @index: vrb index to write the value 865: * @val: Pointer to update the data after reading from vrb 866: * 867: * Return: Negative error on failure and zero on success. 868: */ 869: int gmu_core_get_vrb_register(struct kgsl_memdesc *vrb, u32 index, u32 *val); 870: 871: /** 872: * gmu_core_process_trace_data - Process gmu trace buffer data writes to default linux trace buffer 873: * @device: Pointer to KGSL device 874: * @dev: GMU device instance 875: * @trace: GMU trace memory pointer 876: */ 877: void gmu_core_process_trace_data(struct kgsl_device *device, 878: struct device *dev, struct kgsl_gmu_trace *trace); 879: 880: /** 881: * gmu_core_is_trace_empty - Check for trace buffer empty/full status 882: * @hdr: Pointer to gmu trace header 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: */ 923: void gmu_core_mark_for_coldboot(struct kgsl_device *device); 924: 925: /** 926: * gmu_core_reserve_gmuaddr() - Reserve a gmuaddr in the GMU VA space 927: * @device: Pointer to the kgsl device 928: * @md: Pointer to the memdesc 929: * @vma_id: Target gmu vma where this buffer should be mapped 930: * @align: Alignment for the GMU VA and GMU mapping size 931: * 932: * This function reserves a gmu address based on the input parameters 933: * 934: * Return: 0 on success or negative error on failure 935: */ 936: int gmu_core_reserve_gmuaddr(struct kgsl_device *device, struct kgsl_memdesc *md, 937: u32 vma_id, u32 align); 938: 939: /** 940: * gmu_core_rdpm_probe - Probe GMU RDPM resources 941: * @device: Pointer to KGSL device 942: */ 943: void gmu_core_rdpm_probe(struct kgsl_device *device); 944: 945: /** 946: * gmu_core_rdpm_mx_freq_update - Update the mx frequency 947: * @device: Pointer to KGSL device 948: * @freq: Frequency in KHz 949: * 950: * This function communicates GPU mx frequency(in Mhz) changes to rdpm. 951: */ 952: void gmu_core_rdpm_mx_freq_update(struct kgsl_device *device, u32 freq); 953: 954: /** 955: * gmu_core_rdpm_cx_freq_update - Update the cx frequency 956: * @device: Pointer to KGSL device 957: * @freq: Frequency in KHz 958: * 959: * This function communicates GPU cx frequency(in Mhz) changes to rdpm. 960: */ 961: void gmu_core_rdpm_cx_freq_update(struct kgsl_device *device, u32 freq); 962: 963: /** 964: * gmu_core_clk_probe - Probe gmu clocks 965: * @device: Pointer to KGSL device 966: * 967: * Return: 0 on success or negative error on failure 968: */ 969: int gmu_core_clk_probe(struct kgsl_device *device); 970: 971: /** 972: * gmu_core_clock_set_rate - Set the gmu clock rate 973: * @device: Pointer to KGSL device 974: * @gmu_level: Requested gmu power level 975: * 976: * Returns 0 on success or error on clock set rate failure 977: */ 978: int gmu_core_clock_set_rate(struct kgsl_device *device, u32 gmu_level); 979: 980: /** 981: * gmu_core_enable_clks - Enable gmu clocks 982: * @device: Pointer to KGSL device 983: * @level: GMU frequency level 984: * 985: * Return: 0 on success or negative error on failure 986: */ 987: int gmu_core_enable_clks(struct kgsl_device *device, u32 level); 988: 989: /** 990: * gmu_core_disable_clks - Disable gmu clocks 991: * @device: Pointer to KGSL device 992: */ 993: void gmu_core_disable_clks(struct kgsl_device *device); 994: 995: /** 996: * gmu_core_scale_gmu_frequency - Scale GMU frequency based on DDR bus level 997: * @device: Pointer to KGSL device 998: * @buslevel: DDR bus level to determine the required GMU frequency 999: */ 1000: void gmu_core_scale_gmu_frequency(struct kgsl_device *device, int buslevel); 1001: 1002: /** 1003: * gmu_core_hwsched_memory_init() - Initialize GMU hardware-scheduler memory 1004: * @device: Pointer to the kgsl device 1005: * 1006: * This function initializes the GMU hardware-scheduler memory 1007: * by setting up the GMU virtual bank and GMU trace log. 1008: * 1009: * Return: 0 on success or negative error on failure. 1010: */ 1011: int gmu_core_hwsched_memory_init(struct kgsl_device *device); 1012: 1013: 1014: /** 1015: * get_gmu_wrapper_pdev() - Get the GMU wrapper platform device 1016: * 1017: * Return: pointer to the GMU wrapper pdev if found, NULL otherwise. 1018: */ 1019: struct platform_device *get_gmu_wrapper_pdev(void); 1020: 1021: /** 1022: * is_gmu_wrapper_available() - Check for the GMU wrapper device 1023: * 1024: * Returns: true if GMU wrapper device exists and available in the DT, false otherwise. 1025: */ 1026: bool is_gmu_wrapper_available(void); 1027: 1028: #endif /* __KGSL_GMU_CORE_H */ --- FILE: \kgsl_iommu.c | HITS: 5 --- MATCH LINES: 269, 270 257: static void kgsl_iommu_flush_tlb(struct kgsl_mmu *mmu) 258: { 259: struct kgsl_device *device = KGSL_MMU_DEVICE(mmu); 260: struct kgsl_iommu *iommu = &mmu->iommu; 261: 262: iommu_flush_iotlb_all(to_iommu_domain(&iommu->user_context)); 263: 264: /* As LPAC is optional, check LPAC domain is present before flush */ 265: if (iommu->lpac_context.domain) 266: iommu_flush_iotlb_all(to_iommu_domain(&iommu->lpac_context)); 267: 268: /* Flush iotbl for GMU domian */ 269: if (device->gmu_core.domain) 270: iommu_flush_iotlb_all(device->gmu_core.domain); 271: } 272: 273: static int _iopgtbl_unmap(struct kgsl_iommu_pt *pt, u64 gpuaddr, size_t size) 274: { 275: struct io_pgtable_ops *ops = pt->pgtbl_ops; 276: size_t unmapped = 0; 277: 278: while (unmapped < size) { 279: size_t ret, size_to_unmap, remaining, pgcount; 280: 281: remaining = (size - unmapped); 282: size_to_unmap = iommu_pgsize(pt->cfg.pgsize_bitmap, 283: gpuaddr, gpuaddr, remaining, &pgcount); 284: if (size_to_unmap == 0) 285: break; 286: 287: ret = ops->unmap_pages(ops, gpuaddr, size_to_unmap, 288: pgcount, NULL); 289: 290: if (ret == 0) 291: break; 292: 293: gpuaddr += ret; 294: unmapped += ret; MATCH LINES: 376, 377 364: { 365: struct kgsl_device *device = KGSL_MMU_DEVICE(mmu); 366: struct kgsl_iommu *iommu = &mmu->iommu; 367: 368: /* 369: * Send skip TLB hints for user context, LPAC context, and GMU domains 370: * to the SMMU driver to skip TLB operations during slumber. This will 371: * help avoid unnecessary CX GDSC toggling. 372: */ 373: qcom_skip_tlb_management(&iommu->user_context.pdev->dev, hint); 374: if (iommu->lpac_context.domain) 375: qcom_skip_tlb_management(&iommu->lpac_context.pdev->dev, hint); 376: if (device->gmu_core.domain) 377: qcom_skip_tlb_management(&device->gmu_core.pdev->dev, hint); 378: /* 379: * TLB operations are skipped during slumber. Incase CX doesn't 380: * go down, it can result in incorrect translations due to stale 381: * TLB entries. Flush TLB before boot up to ensure fresh start. 382: */ 383: if (!hint) 384: kgsl_iommu_flush_tlb(mmu); 385: } 386: 387: static int 388: kgsl_iopgtbl_map_child(struct kgsl_pagetable *pt, struct kgsl_memdesc *memdesc, 389: u64 offset, struct kgsl_memdesc *child, u64 child_offset, u64 length) 390: { 391: struct kgsl_iommu_pt *iommu_pt = to_iommu_pt(pt); 392: struct sg_table sgt; 393: u32 flags; 394: size_t mapped; 395: int ret; 396: 397: ret = get_sg_from_child(&sgt, child, child_offset, length); 398: if (ret) 399: return ret; 400: 401: /* Inherit the flags from the child for this mapping */ MATCH LINES: 1193 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: --- FILE: \kgsl_pwrctrl.c | HITS: 52 --- MATCH LINES: 26, 55 14: #include 15: #include 16: #include 17: #include 18: #include 19: #include 20: #include 21: #include 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 */ 40: static const char * const clocks[KGSL_MAX_CLKS] = { 41: "src_clk", 42: "core_clk", 43: "iface_clk", 44: "mem_clk", 45: "mem_iface_clk", 46: "alt_mem_iface_clk", 47: "rbbmtimer_clk", 48: "gtcu_clk", 49: "gtbu_clk", 50: "gtcu_iface_clk", 51: "alwayson_clk", 52: "isense_clk", 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: * MATCH LINES: 398, 434 386: ret = kstrtou32(buf, 0, &level); 387: if (ret) 388: return ret; 389: 390: kgsl_mutex_lock(&device->mutex); 391: 392: /* You can't set a maximum power level lower than the minimum */ 393: if (level > pwr->min_pwrlevel) 394: level = pwr->min_pwrlevel; 395: 396: pwr->max_pwrlevel = level; 397: 398: if (device->ftbl->gmu_based_dcvs_pwr_ops(device, level, GPU_PWRLEVEL_OP_MAX_PWRLEVEL)) { 399: /* Update the current level using the new limit */ 400: kgsl_pwrctrl_pwrlevel_change(device, pwr->active_pwrlevel); 401: } 402: 403: kgsl_mutex_unlock(&device->mutex); 404: 405: return count; 406: } 407: 408: static ssize_t max_pwrlevel_show(struct device *dev, 409: struct device_attribute *attr, char *buf) 410: { 411: 412: struct kgsl_device *device = dev_get_drvdata(dev); 413: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 414: 415: return scnprintf(buf, PAGE_SIZE, "%u\n", pwr->max_pwrlevel); 416: } 417: 418: static void kgsl_pwrctrl_min_pwrlevel_set(struct kgsl_device *device, 419: int level) 420: { 421: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 422: 423: if (level > pwr->min_render_pwrlevel) 424: level = pwr->min_render_pwrlevel; 425: 426: kgsl_mutex_lock(&device->mutex); 427: 428: /* You can't set a minimum power level lower than the maximum */ 429: if (level < pwr->max_pwrlevel) 430: level = pwr->max_pwrlevel; 431: 432: pwr->min_pwrlevel = level; 433: 434: if (device->ftbl->gmu_based_dcvs_pwr_ops(device, level, GPU_PWRLEVEL_OP_MIN_PWRLEVEL)) { 435: /* Update the current level using the new limit */ 436: kgsl_pwrctrl_pwrlevel_change(device, pwr->active_pwrlevel); 437: } 438: 439: kgsl_mutex_unlock(&device->mutex); 440: } 441: 442: static ssize_t min_pwrlevel_store(struct device *dev, 443: struct device_attribute *attr, const char *buf, 444: size_t count) 445: { 446: struct kgsl_device *device = dev_get_drvdata(dev); 447: int ret; 448: unsigned int level = 0; 449: 450: ret = kstrtou32(buf, 0, &level); 451: if (ret) 452: return ret; 453: 454: kgsl_pwrctrl_min_pwrlevel_set(device, level); 455: 456: return count; 457: } 458: MATCH LINES: 551 539: int ret, level; 540: 541: ret = kstrtou32(buf, 0, &val); 542: if (ret) 543: return ret; 544: 545: level = _get_nearest_pwrlevel(pwr, val); 546: if (level < 0) 547: return count; 548: 549: kgsl_mutex_lock(&device->mutex); 550: 551: if (device->ftbl->gmu_based_dcvs_pwr_ops(device, level, GPU_PWRLEVEL_OP_GPUCLK)) 552: kgsl_pwrctrl_pwrlevel_change(device, (unsigned int) level); 553: 554: kgsl_mutex_unlock(&device->mutex); 555: return count; 556: } 557: 558: static ssize_t gpuclk_show(struct device *dev, 559: struct device_attribute *attr, 560: char *buf) 561: { 562: struct kgsl_device *device = dev_get_drvdata(dev); 563: 564: return scnprintf(buf, PAGE_SIZE, "%ld\n", 565: kgsl_pwrctrl_active_freq(&device->pwrctrl)); 566: } 567: 568: static ssize_t idle_timer_store(struct device *dev, struct device_attribute *attr, 569: const char *buf, size_t count) 570: { 571: unsigned int val = 0; 572: struct kgsl_device *device = dev_get_drvdata(dev); 573: int ret; 574: 575: ret = kstrtou32(buf, 0, &val); MATCH LINES: 727 715: test_bit(flag, &device->pwrctrl.ctrl_flags)); 716: } 717: 718: static ssize_t __force_on_store(struct device *dev, 719: struct device_attribute *attr, 720: const char *buf, size_t count, 721: int flag) 722: { 723: unsigned int val = 0; 724: struct kgsl_device *device = dev_get_drvdata(dev); 725: int ret; 726: 727: if (gmu_core_gpmu_isenabled(device)) 728: return -EOPNOTSUPP; 729: 730: ret = kstrtou32(buf, 0, &val); 731: if (ret) 732: return ret; 733: 734: kgsl_mutex_lock(&device->mutex); 735: __force_on(device, flag, val); 736: kgsl_mutex_unlock(&device->mutex); 737: 738: return count; 739: } 740: 741: static ssize_t force_clk_on_show(struct device *dev, 742: struct device_attribute *attr, char *buf) 743: { 744: return __force_on_show(dev, attr, buf, KGSL_PWRFLAGS_CLK_ON); 745: } 746: 747: static ssize_t force_clk_on_store(struct device *dev, 748: struct device_attribute *attr, 749: const char *buf, size_t count) 750: { 751: return __force_on_store(dev, attr, buf, count, KGSL_PWRFLAGS_CLK_ON); MATCH LINES: 865 853: return count; 854: 855: kgsl_mutex_lock(&device->mutex); 856: 857: /* 858: * If GMU based DCVS is enabled, mark the DCVS table for update and force 859: * a coldboot for the next boot so that the updated default pwrlevel is 860: * send to GMU 861: */ 862: if (!device->host_based_dcvs) { 863: pwr->update_dcvs_table = true; 864: pwr->default_pwrlevel = level; 865: gmu_core_mark_for_coldboot(device); 866: } else { 867: pwr->default_pwrlevel = level; 868: pwrscale->gpu_profile.profile.initial_freq 869: = pwr->pwrlevels[level].gpu_freq; 870: } 871: 872: kgsl_mutex_unlock(&device->mutex); 873: return count; 874: } 875: 876: static ssize_t popp_show(struct device *dev, 877: struct device_attribute *attr, 878: char *buf) 879: { 880: /* POPP is deprecated, so return it as always disabled */ 881: return scnprintf(buf, PAGE_SIZE, "0\n"); 882: } 883: 884: static ssize_t _gpu_busy_show(struct kgsl_device *device, 885: char *buf) 886: { 887: int ret; 888: struct kgsl_clk_stats *stats = &device->pwrctrl.clk_stats; 889: struct kgsl_pwrctrl *pwr = &device->pwrctrl; MATCH LINES: 1109, 1126, 1131 1097: const char *buf, size_t count) 1098: { 1099: struct kgsl_device *device = dev_get_drvdata(dev); 1100: int ret; 1101: unsigned int enable = 0; 1102: 1103: ret = kstrtou32(buf, 0, &enable); 1104: if (ret) 1105: return ret; 1106: 1107: kgsl_mutex_lock(&device->mutex); 1108: 1109: if (device->ftbl->gmu_based_dcvs_pwr_ops(device, enable, GPU_PWRLEVEL_OP_DCVS_ENABLE)) { 1110: if (enable) 1111: kgsl_pwrscale_governor_enable(device); 1112: else 1113: kgsl_pwrscale_governor_disable(device, false); 1114: } 1115: 1116: kgsl_mutex_unlock(&device->mutex); 1117: 1118: return count; 1119: } 1120: 1121: static ssize_t pwrscale_show(struct device *dev, 1122: struct device_attribute *attr, char *buf) 1123: { 1124: struct kgsl_device *device = dev_get_drvdata(dev); 1125: struct kgsl_pwrscale *psc = &device->pwrscale; 1126: struct gmu_core_device *gmu_core = &device->gmu_core; 1127: 1128: if (device->host_based_dcvs) 1129: return scnprintf(buf, PAGE_SIZE, "%u\n", psc->enabled); 1130: else 1131: return scnprintf(buf, PAGE_SIZE, "%u\n", (u32)gmu_core->gpu_pwrscale_enable); 1132: } 1133: 1134: static DEVICE_ATTR_RO(temp); 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); MATCH LINES: 1258 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, 1267: kgsl_pwrctrl_active_freq(pwr)); 1268: /* Disable gpu-bimc-interface clocks */ 1269: if (pwr->gpu_bimc_int_clk && 1270: pwr->gpu_bimc_interface_enabled) { 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); MATCH LINES: 1407, 1408, 1416, 1419, 1431, 1443, 1444, 1453, 1486, 1496 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: MATCH LINES: 1603, 1607, 1609, 1634, 1635, 1638, 1639 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; 1602: 1603: if (!IS_ERR_OR_NULL(pwr->gmu_mx_pd)) 1604: return 0; 1605: 1606: if (of_property_read_bool(pdev->dev.of_node, "power-domains")) { 1607: pwr->gmu_mx_pd = dev_pm_domain_attach_by_name(&pdev->dev, "gmu_mx"); 1608: 1609: if (IS_ERR_OR_NULL(pwr->gmu_mx_pd)) { 1610: dev_err(device->dev, 1611: "Failed to attach GMU mx power domain\n"); 1612: return -EINVAL; 1613: } 1614: } 1615: 1616: return 0; 1617: } 1618: 1619: static int kgsl_pwrctrl_probe_cx_gdsc(struct kgsl_device *device, struct platform_device *pdev) 1620: { 1621: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1622: 1623: if (of_property_read_bool(pdev->dev.of_node, "power-domains")) { 1624: /* Get virtual device handle for CX GDSC to control it */ 1625: struct device *cx_pd = dev_pm_domain_attach_by_name(&pdev->dev, "cx"); 1626: 1627: if (IS_ERR_OR_NULL(cx_pd)) { 1628: dev_err_probe(&pdev->dev, PTR_ERR(cx_pd), 1629: "Failed to attach cx power domain\n"); 1630: return IS_ERR(cx_pd) ? PTR_ERR(cx_pd) : -EINVAL; 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: MATCH LINES: 1699, 1700, 1705, 1732, 1733, 1762 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); 1704: 1705: pwr->gmu_cx_pd = NULL; 1706: pwr->cx_pd = NULL; 1707: 1708: return ret; 1709: } 1710: 1711: static int kgsl_cx_gdsc_event(struct notifier_block *nb, 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: MATCH LINES: 1985, 2007 1973: return NOTIFY_OK; 1974: 1975: pwr->pmqos_max_pwrlevel = level; 1976: 1977: trace_kgsl_thermal_constraint(max_freq); 1978: 1979: /* Apply the constraints only if first boot is done */ 1980: if (!device->ftbl->is_first_boot_done(device)) 1981: return NOTIFY_OK; 1982: 1983: kgsl_mutex_lock(&device->mutex); 1984: 1985: if (!device->ftbl->gmu_based_dcvs_pwr_ops(device, 0, GPU_PWRLEVEL_OP_THERMAL)) 1986: goto done; 1987: 1988: /* If RT hint is active, send thermal constraint to GMU */ 1989: if (pwr->rt_pwrlevel_hint != INVALID_DCVS_IDX) 1990: device->ftbl->set_thermal_index(device); 1991: 1992: /* Update the current level using the new limit */ 1993: kgsl_pwrctrl_pwrlevel_change(device, pwr->active_pwrlevel); 1994: 1995: done: 1996: kgsl_mutex_unlock(&device->mutex); 1997: return NOTIFY_OK; 1998: } 1999: 2000: static void kgsl_set_thermal_constraint(struct kthread_work *work) 2001: { 2002: struct kgsl_pwrctrl *pwr = container_of(work, struct kgsl_pwrctrl, cooling_work); 2003: struct kgsl_device *device = container_of(pwr, struct kgsl_device, pwrctrl); 2004: 2005: kgsl_mutex_lock(&device->mutex); 2006: 2007: if (!device->ftbl->gmu_based_dcvs_pwr_ops(device, 0, GPU_PWRLEVEL_OP_THERMAL)) 2008: goto done; 2009: 2010: /* If RT hint is active, send thermal constraint to GMU */ 2011: if (pwr->rt_pwrlevel_hint != INVALID_DCVS_IDX) 2012: device->ftbl->set_thermal_index(device); 2013: 2014: /* Update the current level using the new limit */ 2015: if (device->state == KGSL_STATE_ACTIVE) 2016: kgsl_pwrctrl_pwrlevel_change(device, pwr->active_pwrlevel); 2017: 2018: done: 2019: kgsl_mutex_unlock(&device->mutex); 2020: } 2021: 2022: static int kgsl_cooling_get_max_state(struct thermal_cooling_device *cooling_dev, 2023: unsigned long *state) 2024: { 2025: struct kgsl_device *device = cooling_dev->devdata; 2026: 2027: *state = device->pwrctrl.num_pwrlevels - 1; 2028: return 0; 2029: } 2030: 2031: static int kgsl_cooling_get_cur_state(struct thermal_cooling_device *cooling_dev, MATCH LINES: 2116 2104: 2105: return 0; 2106: 2107: err: 2108: dev_err(device->dev, "Unable to register thermal cooling device: %d\n", ret); 2109: return ret; 2110: } 2111: 2112: int kgsl_pwrctrl_init(struct kgsl_device *device) 2113: { 2114: int i, result, freq; 2115: struct platform_device *pdev = device->pdev; 2116: struct platform_device *gmu_wrapper_pdev = get_gmu_wrapper_pdev(); 2117: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 2118: 2119: result = _get_clocks(device); 2120: if (result) 2121: return result; 2122: 2123: /* Make sure we have a source clk for freq setting */ 2124: if (pwr->grp_clks[0] == NULL) 2125: pwr->grp_clks[0] = pwr->grp_clks[1]; 2126: 2127: /* Getting gfx-bimc-interface-clk frequency */ 2128: if (!of_property_read_u32(pdev->dev.of_node, 2129: "qcom,gpu-bimc-interface-clk-freq", 2130: &pwr->gpu_bimc_int_clk_freq)) 2131: pwr->gpu_bimc_int_clk = devm_clk_get(&pdev->dev, 2132: "bimc_gpu_clk"); 2133: 2134: if (pwr->num_pwrlevels == 0) { 2135: dev_err(device->dev, "No power levels are defined\n"); 2136: return -EINVAL; 2137: } 2138: 2139: spin_lock_init(&pwr->stats_lock); 2140: MATCH LINES: 2167, 2168, 2170, 2176, 2177, 2179, 2181 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); MATCH LINES: 2290, 2291, 2301, 2302, 2304, 2307 2278: DEV_PM_QOS_MAX_FREQUENCY); 2279: thermal_cooling_device_unregister(pwr->cooling_dev); 2280: } 2281: 2282: if (!IS_ERR_OR_NULL(pwr->cooling_worker)) 2283: kthread_destroy_worker(pwr->cooling_worker); 2284: 2285: if (dev_pm_qos_request_active(&pwr->sysfs_thermal_req)) 2286: dev_pm_qos_remove_request(&pwr->sysfs_thermal_req); 2287: 2288: pm_runtime_disable(&device->pdev->dev); 2289: 2290: if (pwr->gmu_cx_pd && (pwr->gmu_cx_pd != pwr->cx_pd)) 2291: dev_pm_domain_detach(pwr->gmu_cx_pd, false); 2292: 2293: if (pwr->cx_pd) { 2294: dev_pm_genpd_remove_notifier(pwr->cx_pd); 2295: dev_pm_domain_detach(pwr->cx_pd, false); 2296: } 2297: 2298: if (pwr->gx_pd) 2299: dev_pm_domain_detach(pwr->gx_pd, false); 2300: 2301: if (pwr->gmu_mx_pd) 2302: dev_pm_domain_detach(pwr->gmu_mx_pd, false); 2303: 2304: pwr->gmu_cx_pd = NULL; 2305: pwr->cx_pd = NULL; 2306: pwr->gx_pd = NULL; 2307: pwr->gmu_mx_pd = NULL; 2308: } 2309: 2310: void kgsl_idle_check(struct work_struct *work) 2311: { 2312: struct kgsl_device *device = container_of(work, struct kgsl_device, 2313: idle_check_ws); 2314: int ret = 0; 2315: unsigned int requested_state; 2316: 2317: kgsl_mutex_lock(&device->mutex); 2318: 2319: /* 2320: * After scheduling idle work for transitioning to SLUMBER, it's 2321: * possbile that requested state can change to NONE if any new workload 2322: * comes before kgsl_idle_check is executed or it gets the device mutex. 2323: * In such case, no need to change state to NONE. 2324: */ 2325: if (device->requested_state == KGSL_STATE_NONE) { 2326: kgsl_mutex_unlock(&device->mutex); 2327: return; 2328: } 2329: 2330: requested_state = device->requested_state; 2331: MATCH LINES: 2413 2401: * must be accessed during device start and stop, when the active_cnt 2402: * may legitimately be 0. 2403: */ 2404: void kgsl_pre_hwaccess(struct kgsl_device *device) 2405: { 2406: /* In order to touch a register you must hold the device mutex */ 2407: WARN_ON(!kgsl_mutex_is_locked(&device->mutex)); 2408: 2409: /* 2410: * A register access without device power will cause a fatal timeout. 2411: * This is not valid for targets with a GMU. 2412: */ 2413: if (!gmu_core_gpmu_isenabled(device)) 2414: WARN_ON(!kgsl_pwrctrl_isenabled(device)); 2415: } 2416: 2417: static int kgsl_pwrctrl_enable(struct kgsl_device *device) 2418: { 2419: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 2420: int level, status; 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: { MATCH LINES: 2466 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) { 2485: case KGSL_STATE_ACTIVE: 2486: kgsl_pwrctrl_irq(device, false); 2487: kgsl_delete_timer_sync(&device->idle_timer); 2488: device->ftbl->stop(device); 2489: fallthrough; 2490: case KGSL_STATE_AWARE: --- FILE: \kgsl_pwrctrl.h | HITS: 5 --- MATCH LINES: 122, 126, 127, 128, 129 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; --- FILE: \kgsl_pwrscale.c | HITS: 1 --- MATCH LINES: 686 674: * kgsl_pwrscale_passive_init - Initialize the passive governor for gmu based DCVS targets 675: * @device: Pointer to KGSL device 676: * @pdev: Pointer to the GPU platform device 677: */ 678: static void kgsl_pwrscale_passive_init(struct kgsl_device *device, struct platform_device *pdev) 679: { 680: struct kgsl_pwrscale *pwrscale = &device->pwrscale; 681: struct devfreq_dev_profile *profile = &pwrscale->gpu_profile.profile; 682: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 683: struct device *dev; 684: int ret, i; 685: 686: device->gmu_core.gpu_pwrscale_enable = true; 687: profile->target = kgsl_passive_devfreq_target; 688: profile->get_dev_status = kgsl_passive_devfreq_get_dev_status; 689: profile->get_cur_freq = kgsl_devfreq_get_cur_freq; 690: profile->initial_freq = pwr->pwrlevels[pwr->default_pwrlevel].gpu_freq; 691: profile->max_state = pwr->num_pwrlevels; 692: 693: for (i = 0; i < pwr->num_pwrlevels; i++) 694: pwrscale->freq_table[i] = pwr->pwrlevels[i].gpu_freq; 695: profile->freq_table = pwrscale->freq_table; 696: 697: pwrscale->gpu_ro_df = devfreq_add_device(&pdev->dev, profile, 698: KGSL_PASSIVE_GOVERNOR_NAME, NULL); 699: if (IS_ERR_OR_NULL(pwrscale->gpu_ro_df)) { 700: ret = PTR_ERR(pwrscale->gpu_ro_df); 701: pwrscale->gpu_ro_df = NULL; 702: dev_err(device->dev, "Failed to add devfreq device for %s governor: %d\n", 703: KGSL_PASSIVE_GOVERNOR_NAME, ret); 704: return; 705: } 706: 707: /* Passive governor does not need qos notifiers */ 708: dev_pm_qos_remove_notifier(&device->pdev->dev, &pwrscale->gpu_ro_df->nb_max, 709: DEV_PM_QOS_MAX_FREQUENCY); 710: dev_pm_qos_remove_notifier(&device->pdev->dev, &pwrscale->gpu_ro_df->nb_min, --- FILE: \kgsl_sharedmem.h | HITS: 2 --- MATCH LINES: 108, 109 96: u32 page_count; 97: /** 98: * @lock: Spinlock to protect the gpuaddr from being accessed by 99: * multiple entities trying to map the same SVM region at once 100: */ 101: spinlock_t lock; 102: /** @shmem_filp: Pointer to the shmem file backing this memdesc */ 103: struct file *shmem_filp; 104: /** @ranges: rbtree base for the interval list of vbo ranges */ 105: struct rb_root_cached ranges; 106: /** @ranges_lock: Mutex to protect the range database */ 107: struct mutex ranges_lock; 108: /** @gmuaddr: GMU VA if this is mapped in GMU */ 109: u32 gmuaddr; 110: /*@shmem_page_list: shmem pages list */ 111: struct list_head shmem_page_list; 112: }; 113: 114: /* 115: * struct kgsl_mem_entry - a userspace memory allocation 116: * @refcount: reference count. Currently userspace can only 117: * hold a single reference count, but the kernel may hold more. 118: * @memdesc: description of the memory 119: * @priv_data: type-specific data, such as the dma-buf attachment pointer. 120: * @node: rb_node for the gpu address lookup rb tree 121: * @id: idr index for this entry, can be used to find memory that does not have 122: * a valid GPU address. 123: * @priv: back pointer to the process that owns this memory 124: * @pending_free: if !0, userspace requested that his memory be freed, but there 125: * are still references to it. 126: * @dev_priv: back pointer to the device file that created this entry. 127: * @metadata: String containing user specified metadata for the entry 128: * @work: Work struct used to schedule kgsl_mem_entry_destroy() 129: */ 130: struct kgsl_mem_entry { 131: struct kref refcount; 132: struct kgsl_memdesc memdesc; 133: void *priv_data; --- FILE: \kgsl_snapshot.c | HITS: 9 --- MATCH LINES: 628, 635, 655, 670 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; MATCH LINES: 718 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 { MATCH LINES: 1106 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 MATCH LINES: 1326, 1327 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: MATCH LINES: 1377 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: 20 --- MATCH LINES: 60 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 */ MATCH LINES: 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 150, 153 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; MATCH LINES: 214, 215, 216, 217, 218 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 */ MATCH LINES: 324 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_sync.c | HITS: 6 --- MATCH LINES: 13 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 8: #include 9: #include 10: #include 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 MATCH LINES: 147, 148, 185 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) 145: { 146: void *ptr = kgsl_synx.mem_descriptor.vaddr; 147: struct synx_hw_fence_hfi_queue_header *hdr = (struct synx_hw_fence_hfi_queue_header *) 148: (ptr + sizeof(struct synx_hw_fence_hfi_queue_table_header)); 149: u32 queue_size_dwords = hdr->queue_size / sizeof(u32); 150: u32 payload_size_dwords = hdr->pkt_size / sizeof(u32); 151: u32 free_entries, write_idx = hdr->write_index, read_idx = hdr->read_index; 152: 153: free_entries = read_idx <= write_idx ? 154: queue_size_dwords - (write_idx - read_idx) : 155: read_idx - write_idx; 156: 157: free_entries /= payload_size_dwords; 158: 159: /* Ensure free_entries does not become negative */ 160: if (free_entries == 0) 161: return false; 162: 163: free_entries -= 1; 164: 165: if (free_entries > pending_hw_fence_count) 166: return true; 167: 168: return false; 169: } 170: 171: void _hw_fence_destroy(struct kgsl_sync_fence *kfence) 172: { 173: synx_release(kgsl_synx.handle, kfence->hw_fence_index); 174: 175: /* 176: * synx_release() doesn't have a way to get to the dma fence. Hence, the client must clear 177: * this bit from the dma fence flags. 178: */ 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) MATCH LINES: 301, 302 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); 305: u32 free_entries, write_idx = hdr->write_index, read_idx = hdr->read_index; 306: 307: free_entries = read_idx <= write_idx ? 308: queue_size_dwords - (write_idx - read_idx) : 309: read_idx - write_idx; 310: 311: free_entries /= payload_size_dwords; 312: 313: /* Ensure free_entries does not become negative */ 314: if (free_entries == 0) 315: return false; 316: 317: free_entries -= 1; 318: 319: if (free_entries > pending_hw_fence_count) 320: return true; 321: 322: return false; 323: } 324: 325: void _hw_fence_destroy(struct kgsl_sync_fence *kfence) 326: { --- FILE: \kgsl_trace.h | HITS: 8 --- MATCH LINES: 268, 286 256: __entry->on = on; 257: __entry->freq = freq; 258: ), 259: 260: TP_printk( 261: "d_name=%s flag=%s active_freq=%d", 262: __get_str(device_name), 263: __entry->on ? "on" : "off", 264: __entry->freq 265: ) 266: ); 267: 268: TRACE_EVENT(kgsl_gmu_pwrlevel, 269: 270: TP_PROTO(unsigned long freq, 271: unsigned long prev_freq), 272: 273: TP_ARGS(freq, prev_freq), 274: 275: TP_STRUCT__entry( 276: __field(unsigned long, freq) 277: __field(unsigned long, prev_freq) 278: ), 279: 280: TP_fast_assign( 281: __entry->freq = freq; 282: __entry->prev_freq = prev_freq; 283: ), 284: 285: TP_printk( 286: "gmu_freq=%ld gmu_prev_freq=%ld", 287: __entry->freq, 288: __entry->prev_freq 289: ) 290: ); 291: 292: TRACE_EVENT(kgsl_pwrlevel, 293: 294: TP_PROTO(struct kgsl_device *device, 295: unsigned int pwrlevel, 296: unsigned int freq, 297: unsigned int prev_pwrlevel, 298: unsigned int prev_freq, 299: u64 ticks), 300: 301: TP_ARGS(device, pwrlevel, freq, prev_pwrlevel, prev_freq, ticks), 302: 303: TP_STRUCT__entry( 304: __string(device_name, device->name) 305: __field(unsigned int, pwrlevel) 306: __field(unsigned int, freq) 307: __field(unsigned int, prev_pwrlevel) 308: __field(unsigned int, prev_freq) 309: __field(u64, ticks) 310: ), MATCH LINES: 1237, 1249, 1254, 1259, 1276, 1281 1225: ), 1226: TP_fast_assign( 1227: __entry->crc_25pct = crc_25pct; 1228: __entry->crc_58pct = crc_58pct; 1229: __entry->crc_75pct = crc_75pct; 1230: ), 1231: TP_printk("crc_25=%d crc_58=%d crc_75=%d", 1232: __entry->crc_25pct, __entry->crc_58pct, 1233: __entry->crc_75pct 1234: ) 1235: ); 1236: 1237: DECLARE_EVENT_CLASS(gmu_oob_template, 1238: TP_PROTO(unsigned int mask), 1239: TP_ARGS(mask), 1240: TP_STRUCT__entry( 1241: __field(unsigned int, mask) 1242: ), 1243: TP_fast_assign( 1244: __entry->mask = mask; 1245: ), 1246: TP_printk("mask=0x%08x", __entry->mask) 1247: ); 1248: 1249: DEFINE_EVENT(gmu_oob_template, kgsl_gmu_oob_set, 1250: TP_PROTO(unsigned int mask), 1251: TP_ARGS(mask) 1252: ); 1253: 1254: DEFINE_EVENT(gmu_oob_template, kgsl_gmu_oob_clear, 1255: TP_PROTO(unsigned int mask), 1256: TP_ARGS(mask) 1257: ); 1258: 1259: DECLARE_EVENT_CLASS(hfi_msg_template, 1260: TP_PROTO(unsigned int id, unsigned int size, unsigned int seqnum), 1261: TP_ARGS(id, size, seqnum), 1262: TP_STRUCT__entry( 1263: __field(unsigned int, id) 1264: __field(unsigned int, size) 1265: __field(unsigned int, seq) 1266: ), 1267: TP_fast_assign( 1268: __entry->id = id; 1269: __entry->size = size; 1270: __entry->seq = seqnum; 1271: ), 1272: TP_printk("id=0x%x size=0x%x seqnum=0x%x", 1273: __entry->id, __entry->size, __entry->seq) 1274: ); 1275: 1276: DEFINE_EVENT(hfi_msg_template, kgsl_hfi_send, 1277: TP_PROTO(unsigned int id, unsigned int size, unsigned int seqnum), 1278: TP_ARGS(id, size, seqnum) 1279: ); 1280: 1281: DEFINE_EVENT(hfi_msg_template, kgsl_hfi_receive, 1282: TP_PROTO(unsigned int id, unsigned int size, unsigned int seqnum), 1283: TP_ARGS(id, size, seqnum) 1284: ); 1285: 1286: TRACE_EVENT(kgsl_timeline_alloc, 1287: TP_PROTO( 1288: u32 id, 1289: u64 seqno 1290: ), 1291: TP_ARGS( 1292: id, 1293: seqno 1294: ), 1295: TP_STRUCT__entry( 1296: __field(u32, id) 1297: __field(u64, seqno) 1298: ), 1299: TP_fast_assign( 1300: __entry->id = id; 1301: __entry->seqno = seqno; 1302: ), 1303: TP_printk("id=%u initial=%llu", 1304: __entry->id, __entry->seqno 1305: ) --- FILE: \kgsl_util.c | HITS: 1 --- MATCH LINES: 405 393: char name[MAX_VA_MINIDUMP_STR_LEN]; 394: struct kgsl_pagetable *pt; 395: struct adreno_context *ctxt; 396: struct kgsl_process_private *p; 397: struct kgsl_global_memdesc *md; 398: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 399: 400: ret = kgsl_add_va_to_minidump(device->dev, KGSL_DRIVER, 401: (void *)(&kgsl_driver), sizeof(struct kgsl_driver)); 402: if (ret) 403: return ret; 404: 405: if (!ADRENO_FEATURE(adreno_dev, ADRENO_GMU_BASED_DCVS) && 406: device->pwrscale.enabled) { 407: struct msm_busmon_extended_profile bus_profile = device->pwrscale.bus_profile; 408: 409: ret = kgsl_add_va_to_minidump(device->dev, KGSL_ADRENO_TZ_DATA_ENTRY, 410: (void *)bus_profile.private_data, 411: sizeof(*bus_profile.private_data)); 412: if (ret) 413: return ret; 414: } 415: 416: ret = kgsl_add_page_pools_to_va_minidump(device); 417: if (ret) 418: return ret; 419: 420: list_for_each_entry(ctxt, &adreno_dev->active_list, active_node) { 421: snprintf(name, sizeof(name), KGSL_ADRENO_CTX_ENTRY"_%d", ctxt->base.id); 422: ret = kgsl_add_va_to_minidump(device->dev, name, 423: (void *)(ctxt), sizeof(struct adreno_context)); 424: if (ret) 425: break; 426: } 427: 428: list_for_each_entry(p, &kgsl_driver.process_list, list) { 429: snprintf(name, sizeof(name), KGSL_PROC_PRIV_ENTRY "_%d", pid_nr(p->pid)); --- FILE: \kgsl_util.h | HITS: 11 --- MATCH LINES: 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 34 9: 10: #include 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" 39: #define KGSL_NC_OVERRIDES_ENTRY "kgsl_nc_overrides" 40: 41: #define MAX_VA_MINIDUMP_STR_LEN 48 42: 43: 44: /** 45: * Request TZ to program set of access controlled registers that KGSL needs 46: * irrespective of any features 47: */ 48: #define GPU_ALWAYS_EN_REQ BIT(0) 49: /** 50: * Request TZ to program BCL id to access controlled register when BCL is 51: * enabled 52: */ 53: #define GPU_BCL_EN_REQ BIT(1) 54: /** 55: * Request TZ to program set of access controlled register for CLX feature 56: * when enabled 57: */ 58: #define GPU_CLX_EN_REQ BIT(2) --- FILE: \downstream_dependencies\msm_hw_fence.h | HITS: 4 --- MATCH LINES: 52, 60, 70, 90 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; 47: void *fence; 48: u32 flags; 49: }; 50: 51: /** 52: * struct msm_hw_fence_hfi_queue_table_header - HFI queue table structure. 53: * @version: HFI protocol version. 54: * @size: Queue table size in dwords. 55: * @qhdr0_offset: First queue header offset (dwords) in this table. 56: * @qhdr_size: Queue header size. 57: * @num_q: Number of queues defined in this table. 58: * @num_active_q: Number of active queues. 59: */ 60: struct msm_hw_fence_hfi_queue_table_header { 61: u32 version; 62: u32 size; 63: u32 qhdr0_offset; 64: u32 qhdr_size; 65: u32 num_q; 66: u32 num_active_q; 67: }; 68: 69: /** 70: * struct msm_hw_fence_hfi_queue_header - HFI queue header structure. 71: * @status: Active = 1, Inactive = 0. 72: * @start_addr: Starting address of the queue. 73: * @type: Queue type (rx/tx). 74: * @queue_size: Size of the queue. 75: * @pkt_size: Size of the queue packet entries, 76: * 0 - means variable size of message in the queue, 77: * non-zero - size of the packet, fixed. 78: * @pkt_drop_cnt: Number of packets drop by sender. 79: * @rx_wm: Receiver watermark, applicable in event driven mode. 80: * @tx_wm: Sender watermark, applicable in event driven mode. 81: * @rx_req: Receiver sets this bit if queue is empty. 82: * @tx_req: Sender sets this bit if queue is full. 83: * @rx_irq_status: Receiver sets this bit and triggers an interrupt to the 84: * sender after packets are dequeued. Sender clears this bit. 85: * @tx_irq_status: Sender sets this bit and triggers an interrupt to the 86: * receiver after packets are queued. Receiver clears this bit. 87: * @read_index: read index of the queue. 88: * @write_index: write index of the queue. 89: */ 90: struct msm_hw_fence_hfi_queue_header { 91: u32 status; 92: u32 start_addr; 93: u32 type; 94: u32 queue_size; 95: u32 pkt_size; 96: u32 pkt_drop_cnt; 97: u32 rx_wm; 98: u32 tx_wm; 99: u32 rx_req; 100: u32 tx_req; 101: u32 rx_irq_status; 102: u32 tx_irq_status; 103: u32 read_index; 104: u32 write_index; 105: }; 106: 107: /** 108: * struct msm_hw_fence_mem_addr - Memory descriptor of the queue allocated by 109: * the fence driver for each client during 110: * register. 111: * @virtual_addr: Kernel virtual address of the queue. 112: * @device_addr: Physical address of the memory object. 113: * @size: Size of the memory. 114: * @mem_data: Internal pointer with the attributes of the allocation. --- FILE: \include\linux\msm_kgsl.h | HITS: 4 --- MATCH LINES: 54, 55, 61, 62 42: /** 43: * kgsl_gpu_frame_count - Get number of frames already processed by GPU 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: */ 82: int kgsl_del_rcu_notifier(struct notifier_block *nb); 83: 84: #endif /* _MSM_KGSL_H */ 85: --- FILE: \include\uapi\linux\msm_kgsl.h | HITS: 3 --- MATCH LINES: 500, 501, 502 488: #define KGSL_PERFCOUNTER_GROUP_ALWAYSON 0x1B 489: #define KGSL_PERFCOUNTER_GROUP_SP_PWR 0x1C 490: #define KGSL_PERFCOUNTER_GROUP_TP_PWR 0x1D 491: #define KGSL_PERFCOUNTER_GROUP_RB_PWR 0x1E 492: #define KGSL_PERFCOUNTER_GROUP_CCU_PWR 0x1F 493: #define KGSL_PERFCOUNTER_GROUP_UCHE_PWR 0x20 494: #define KGSL_PERFCOUNTER_GROUP_CP_PWR 0x21 495: #define KGSL_PERFCOUNTER_GROUP_GPMU_PWR 0x22 496: #define KGSL_PERFCOUNTER_GROUP_ALWAYSON_PWR 0x23 497: #define KGSL_PERFCOUNTER_GROUP_GLC 0x24 498: #define KGSL_PERFCOUNTER_GROUP_FCHE 0x25 499: #define KGSL_PERFCOUNTER_GROUP_MHUB 0x26 500: #define KGSL_PERFCOUNTER_GROUP_GMU_XOCLK 0x27 501: #define KGSL_PERFCOUNTER_GROUP_GMU_GMUCLK 0x28 502: #define KGSL_PERFCOUNTER_GROUP_GMU_PERF 0x29 503: #define KGSL_PERFCOUNTER_GROUP_SW 0x2a 504: #define KGSL_PERFCOUNTER_GROUP_UFC 0x2b 505: #define KGSL_PERFCOUNTER_GROUP_BV_CP 0x2c 506: #define KGSL_PERFCOUNTER_GROUP_BV_PC 0x2d 507: #define KGSL_PERFCOUNTER_GROUP_BV_VFD 0x2e 508: #define KGSL_PERFCOUNTER_GROUP_BV_VPC 0x2f 509: #define KGSL_PERFCOUNTER_GROUP_BV_TP 0x30 510: #define KGSL_PERFCOUNTER_GROUP_BV_SP 0x31 511: #define KGSL_PERFCOUNTER_GROUP_BV_UFC 0x32 512: #define KGSL_PERFCOUNTER_GROUP_BV_TSE 0x33 513: #define KGSL_PERFCOUNTER_GROUP_BV_RAS 0x34 514: #define KGSL_PERFCOUNTER_GROUP_BV_LRZ 0x35 515: #define KGSL_PERFCOUNTER_GROUP_BV_HLSQ 0x36 516: #define KGSL_PERFCOUNTER_GROUP_BV_CCU 0x37 517: #define KGSL_PERFCOUNTER_GROUP_BV_RB 0x38 518: #define KGSL_PERFCOUNTER_GROUP_MAX 0x39 519: 520: #define KGSL_PERFCOUNTER_NOT_USED 0xFFFFFFFF 521: #define KGSL_PERFCOUNTER_BROKEN 0xFFFFFFFE 522: 523: /* structure holds list of ibs */ 524: struct kgsl_ibdesc { 525: unsigned long gpuaddr; 526: unsigned long __pad; TOTAL MATCHES: 8536 ========================================================================================== SUBSYSTEM: FIRMWARE ========================================================================================== --- FILE: \a5xx_reg.h | HITS: 1 --- MATCH LINES: 40 28: #define A5XX_INT_CP_RB_DONE_TS 17 29: #define A5XX_INT_CP_WT_DONE_TS 18 30: #define A5XX_INT_UNKNOWN_1 19 31: #define A5XX_INT_CP_CACHE_FLUSH_TS 20 32: #define A5XX_INT_UNUSED_2 21 33: #define A5XX_INT_RBBM_ATB_BUS_OVERFLOW 22 34: #define A5XX_INT_MISC_HANG_DETECT 23 35: #define A5XX_INT_UCHE_OOB_ACCESS 24 36: #define A5XX_INT_UCHE_TRAP_INTR 25 37: #define A5XX_INT_DEBBUS_INTR_0 26 38: #define A5XX_INT_DEBBUS_INTR_1 27 39: #define A5XX_INT_GPMU_VOLTAGE_DROOP 28 40: #define A5XX_INT_GPMU_FIRMWARE 29 41: #define A5XX_INT_ISDB_CPU_IRQ 30 42: #define A5XX_INT_ISDB_UNDER_DEBUG 31 43: 44: /* CP Interrupt bits */ 45: #define A5XX_CP_OPCODE_ERROR 0 46: #define A5XX_CP_RESERVED_BIT_ERROR 1 47: #define A5XX_CP_HW_FAULT_ERROR 2 48: #define A5XX_CP_DMA_ERROR 3 49: #define A5XX_CP_REGISTER_PROTECTION_ERROR 4 50: #define A5XX_CP_AHB_ERROR 5 51: 52: /* CP registers */ 53: #define A5XX_CP_RB_BASE 0x800 54: #define A5XX_CP_RB_BASE_HI 0x801 55: #define A5XX_CP_RB_CNTL 0x802 56: #define A5XX_CP_RB_RPTR_ADDR_LO 0x804 57: #define A5XX_CP_RB_RPTR_ADDR_HI 0x805 58: #define A5XX_CP_RB_RPTR 0x806 59: #define A5XX_CP_RB_WPTR 0x807 60: #define A5XX_CP_PFP_STAT_ADDR 0x808 61: #define A5XX_CP_PFP_STAT_DATA 0x809 62: #define A5XX_CP_DRAW_STATE_ADDR 0x80B 63: #define A5XX_CP_DRAW_STATE_DATA 0x80C 64: #define A5XX_CP_CRASH_SCRIPT_BASE_LO 0x817 --- FILE: \adreno-gpulist.h | HITS: 174 --- MATCH LINES: 153, 180 141: .uche_gmem_alignment = SZ_1M, 142: .gmem_size = SZ_1M, 143: .bus_width = 32, 144: .snapshot_size = SZ_1M, 145: .highest_bank_bit = 15, 146: }, 147: .gpmu_tsens = 0x00060007, 148: .max_power = 5448, 149: .pm4fw_name = "a530_pm4.fw", 150: .pfpfw_name = "a530_pfp.fw", 151: .gpmufw_name = "a530_gpmu.fw2", 152: .regfw_name = "a530v2_seq.fw2", 153: .zap_name = "a530_zap.mdt", 154: .hwcg = a530_hwcg_regs, 155: .hwcg_count = ARRAY_SIZE(a530_hwcg_regs), 156: .vbif = a530_vbif_regs, 157: .vbif_count = ARRAY_SIZE(a530_vbif_regs), 158: }; 159: 160: static const struct adreno_a5xx_core adreno_gpu_core_a530v3 = { 161: .base = { 162: DEFINE_ADRENO_REV(ADRENO_REV_A530, 5, 3, 0, ANY_ID), 163: .features = ADRENO_SPTP_PC | ADRENO_LM | 164: ADRENO_PREEMPTION | 165: ADRENO_CONTENT_PROTECTION, 166: .gpudev = &adreno_a5xx_gpudev, 167: .perfcounters = &adreno_a5xx_perfcounters, 168: .uche_gmem_alignment = SZ_1M, 169: .gmem_size = SZ_1M, 170: .bus_width = 32, 171: .snapshot_size = SZ_1M, 172: .highest_bank_bit = 15, 173: }, 174: .gpmu_tsens = 0x00060007, 175: .max_power = 5448, 176: .pm4fw_name = "a530_pm4.fw", 177: .pfpfw_name = "a530_pfp.fw", 178: .gpmufw_name = "a530v3_gpmu.fw2", 179: .regfw_name = "a530v3_seq.fw2", 180: .zap_name = "a530_zap.mdt", 181: .hwcg = a530_hwcg_regs, 182: .hwcg_count = ARRAY_SIZE(a530_hwcg_regs), 183: .vbif = a530_vbif_regs, 184: .vbif_count = ARRAY_SIZE(a530_vbif_regs), 185: }; 186: 187: /* For a505, a506 and a508 */ 188: static const struct kgsl_regmap_list a50x_hwcg_regs[] = { 189: {A5XX_RBBM_CLOCK_CNTL_SP0, 0x02222222}, 190: {A5XX_RBBM_CLOCK_CNTL2_SP0, 0x02222220}, 191: {A5XX_RBBM_CLOCK_HYST_SP0, 0x0000F3CF}, 192: {A5XX_RBBM_CLOCK_DELAY_SP0, 0x00000080}, 193: {A5XX_RBBM_CLOCK_CNTL_TP0, 0x22222222}, 194: {A5XX_RBBM_CLOCK_CNTL2_TP0, 0x22222222}, 195: {A5XX_RBBM_CLOCK_CNTL3_TP0, 0x00002222}, 196: {A5XX_RBBM_CLOCK_HYST_TP0, 0x77777777}, 197: {A5XX_RBBM_CLOCK_HYST2_TP0, 0x77777777}, 198: {A5XX_RBBM_CLOCK_HYST3_TP0, 0x00007777}, 199: {A5XX_RBBM_CLOCK_DELAY_TP0, 0x11111111}, 200: {A5XX_RBBM_CLOCK_DELAY2_TP0, 0x11111111}, 201: {A5XX_RBBM_CLOCK_DELAY3_TP0, 0x00001111}, 202: {A5XX_RBBM_CLOCK_CNTL2_UCHE, 0x22222222}, 203: {A5XX_RBBM_CLOCK_CNTL3_UCHE, 0x22222222}, 204: {A5XX_RBBM_CLOCK_CNTL4_UCHE, 0x00222222}, MATCH LINES: 263 251: .features = ADRENO_PREEMPTION | 252: ADRENO_CONTENT_PROTECTION | ADRENO_CPZ_RETENTION, 253: .gpudev = &adreno_a5xx_gpudev, 254: .perfcounters = &adreno_a5xx_perfcounters, 255: .uche_gmem_alignment = SZ_1M, 256: .gmem_size = (SZ_128K + SZ_8K), 257: .bus_width = 16, 258: .snapshot_size = SZ_1M, 259: .highest_bank_bit = 14, 260: }, 261: .pm4fw_name = "a530_pm4.fw", 262: .pfpfw_name = "a530_pfp.fw", 263: .zap_name = "a506_zap.mdt", 264: .hwcg = a50x_hwcg_regs, 265: .hwcg_count = ARRAY_SIZE(a50x_hwcg_regs), 266: .vbif = a530_vbif_regs, 267: .vbif_count = ARRAY_SIZE(a530_vbif_regs), 268: }; 269: 270: static const struct kgsl_regmap_list a510_hwcg_regs[] = { 271: {A5XX_RBBM_CLOCK_CNTL_SP0, 0x02222222}, 272: {A5XX_RBBM_CLOCK_CNTL_SP1, 0x02222222}, 273: {A5XX_RBBM_CLOCK_CNTL2_SP0, 0x02222220}, 274: {A5XX_RBBM_CLOCK_CNTL2_SP1, 0x02222220}, 275: {A5XX_RBBM_CLOCK_HYST_SP0, 0x0000F3CF}, 276: {A5XX_RBBM_CLOCK_HYST_SP1, 0x0000F3CF}, 277: {A5XX_RBBM_CLOCK_DELAY_SP0, 0x00000080}, 278: {A5XX_RBBM_CLOCK_DELAY_SP1, 0x00000080}, 279: {A5XX_RBBM_CLOCK_CNTL_TP0, 0x22222222}, 280: {A5XX_RBBM_CLOCK_CNTL_TP1, 0x22222222}, 281: {A5XX_RBBM_CLOCK_CNTL2_TP0, 0x22222222}, 282: {A5XX_RBBM_CLOCK_CNTL2_TP1, 0x22222222}, 283: {A5XX_RBBM_CLOCK_CNTL3_TP0, 0x00002222}, 284: {A5XX_RBBM_CLOCK_CNTL3_TP1, 0x00002222}, 285: {A5XX_RBBM_CLOCK_HYST_TP0, 0x77777777}, 286: {A5XX_RBBM_CLOCK_HYST_TP1, 0x77777777}, 287: {A5XX_RBBM_CLOCK_HYST2_TP0, 0x77777777}, MATCH LINES: 471 459: .perfcounters = &adreno_a5xx_perfcounters, 460: .uche_gmem_alignment = SZ_1M, 461: .gmem_size = SZ_1M, 462: .bus_width = 32, 463: .snapshot_size = SZ_1M, 464: .highest_bank_bit = 15, 465: }, 466: .gpmu_tsens = 0x000c000d, 467: .max_power = 5448, 468: .pm4fw_name = "a530_pm4.fw", 469: .pfpfw_name = "a530_pfp.fw", 470: .gpmufw_name = "a540_gpmu.fw2", 471: .zap_name = "a540_zap.mdt", 472: .hwcg = a540_hwcg_regs, 473: .hwcg_count = ARRAY_SIZE(a540_hwcg_regs), 474: .vbif = a540_vbif_regs, 475: .vbif_count = ARRAY_SIZE(a540_vbif_regs), 476: }; 477: 478: static const struct kgsl_regmap_list a512_hwcg_regs[] = { 479: {A5XX_RBBM_CLOCK_CNTL_SP0, 0x02222222}, 480: {A5XX_RBBM_CLOCK_CNTL_SP1, 0x02222222}, 481: {A5XX_RBBM_CLOCK_CNTL2_SP0, 0x02222220}, 482: {A5XX_RBBM_CLOCK_CNTL2_SP1, 0x02222220}, 483: {A5XX_RBBM_CLOCK_HYST_SP0, 0x0000F3CF}, 484: {A5XX_RBBM_CLOCK_HYST_SP1, 0x0000F3CF}, 485: {A5XX_RBBM_CLOCK_DELAY_SP0, 0x00000080}, 486: {A5XX_RBBM_CLOCK_DELAY_SP1, 0x00000080}, 487: {A5XX_RBBM_CLOCK_CNTL_TP0, 0x22222222}, 488: {A5XX_RBBM_CLOCK_CNTL_TP1, 0x22222222}, 489: {A5XX_RBBM_CLOCK_CNTL2_TP0, 0x22222222}, 490: {A5XX_RBBM_CLOCK_CNTL2_TP1, 0x22222222}, 491: {A5XX_RBBM_CLOCK_CNTL3_TP0, 0x00002222}, 492: {A5XX_RBBM_CLOCK_CNTL3_TP1, 0x00002222}, 493: {A5XX_RBBM_CLOCK_HYST_TP0, 0x77777777}, 494: {A5XX_RBBM_CLOCK_HYST_TP1, 0x77777777}, 495: {A5XX_RBBM_CLOCK_HYST2_TP0, 0x77777777}, MATCH LINES: 552, 572 540: .features = ADRENO_PREEMPTION | 541: ADRENO_CONTENT_PROTECTION | ADRENO_CPZ_RETENTION, 542: .gpudev = &adreno_a5xx_gpudev, 543: .perfcounters = &adreno_a5xx_perfcounters, 544: .uche_gmem_alignment = SZ_1M, 545: .gmem_size = (SZ_256K + SZ_16K), 546: .bus_width = 32, 547: .snapshot_size = SZ_1M, 548: .highest_bank_bit = 14, 549: }, 550: .pm4fw_name = "a530_pm4.fw", 551: .pfpfw_name = "a530_pfp.fw", 552: .zap_name = "a512_zap.mdt", 553: .hwcg = a512_hwcg_regs, 554: .hwcg_count = ARRAY_SIZE(a512_hwcg_regs), 555: }; 556: 557: static const struct adreno_a5xx_core adreno_gpu_core_a508 = { 558: .base = { 559: DEFINE_ADRENO_REV(ADRENO_REV_A508, 5, 0, 8, ANY_ID), 560: .features = ADRENO_PREEMPTION | 561: ADRENO_CONTENT_PROTECTION | ADRENO_CPZ_RETENTION, 562: .gpudev = &adreno_a5xx_gpudev, 563: .perfcounters = &adreno_a5xx_perfcounters, 564: .uche_gmem_alignment = SZ_1M, 565: .gmem_size = (SZ_128K + SZ_8K), 566: .bus_width = 32, 567: .snapshot_size = SZ_1M, 568: .highest_bank_bit = 14, 569: }, 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}, MATCH LINES: 748, 749, 750 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}, MATCH LINES: 848, 849, 850, 876, 877, 878, 904, 905, 906, 929, 930 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}, MATCH LINES: 1063, 1064, 1065, 1094, 1095, 1096, 1127, 1128, 1129 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}, MATCH LINES: 1271, 1272, 1273 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}, MATCH LINES: 1351, 1352, 1353, 1382, 1383, 1384, 1412, 1413, 1414 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}, MATCH LINES: 1490, 1491, 1492, 1518, 1519, 1520, 1543, 1544, 1568, 1569 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}, MATCH LINES: 1694, 1695, 1696, 1727, 1728, 1729, 1760, 1761, 1762, 1792, 1793, 1794 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, MATCH LINES: 1835, 1836, 1837, 1868, 1869, 1870, 1898, 1899 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}, MATCH LINES: 1997, 1998, 2032, 2033 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 }, 2044: { GEN7_RBBM_CLOCK_CNTL2_SP0, 0x02022222 }, 2045: { GEN7_RBBM_CLOCK_HYST_SP0, 0x0000f3cf }, 2046: { GEN7_RBBM_CLOCK_DELAY_SP0, 0x00000080 }, 2047: { GEN7_RBBM_CLOCK_CNTL_TP0, 0x22222220 }, 2048: { GEN7_RBBM_CLOCK_CNTL2_TP0, 0x22222222 }, 2049: { GEN7_RBBM_CLOCK_CNTL3_TP0, 0x22220222 }, 2050: { GEN7_RBBM_CLOCK_CNTL4_TP0, 0x00222222 }, 2051: { GEN7_RBBM_CLOCK_HYST_TP0, 0x77777777 }, 2052: { GEN7_RBBM_CLOCK_HYST2_TP0, 0x77777777 }, 2053: { GEN7_RBBM_CLOCK_HYST3_TP0, 0x77777777 }, 2054: { GEN7_RBBM_CLOCK_HYST4_TP0, 0x00077777 }, 2055: { GEN7_RBBM_CLOCK_DELAY_TP0, 0x11111111 }, 2056: { GEN7_RBBM_CLOCK_DELAY2_TP0, 0x11111111 }, 2057: { GEN7_RBBM_CLOCK_DELAY3_TP0, 0x11111111 }, MATCH LINES: 2173, 2174, 2175, 2176, 2209, 2210, 2211, 2212 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, 2222: .preempt_level = 1, 2223: .ctxt_record_size = (2860 * SZ_1K), 2224: .fast_bus_hint = true, 2225: }; 2226: 2227: extern const struct gen7_snapshot_block_list gen7_2_0_snapshot_block_list; 2228: extern const struct gen7_snapshot_block_list gen7_6_0_snapshot_block_list; 2229: 2230: static const struct kgsl_regmap_list gen7_2_0_gbif_cx_regs[] = { 2231: { GEN7_GBIF_QSB_SIDE0, 0x00071e20 }, 2232: { GEN7_GBIF_QSB_SIDE1, 0x00071e20 }, 2233: { GEN7_GBIF_QSB_SIDE2, 0x00071e20 }, 2234: { GEN7_GBIF_QSB_SIDE3, 0x00071e20 }, 2235: { GEN7_GMU_CX_MRC_GBIF_QOS_CTRL, 0x33 }, 2236: }; MATCH LINES: 2429, 2430, 2431, 2466, 2467, 2468, 2502, 2503, 2504, 2536, 2537, 2538, 2539 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, 2550: .ctxt_record_size = (2860 * SZ_1K), 2551: .fast_bus_hint = true, 2552: }; 2553: 2554: static const struct kgsl_regmap_list gen7_9_0_ao_hwcg_regs[] = { 2555: { GEN7_GPU_GMU_AO_GMU_CGC_MODE_CNTL, 0x00020222 }, 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 = { MATCH LINES: 2590, 2591, 2592, 2626, 2627, 2628 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", 2593: .hwcg = gen7_2_0_hwcg_regs, 2594: .hwcg_count = ARRAY_SIZE(gen7_2_0_hwcg_regs), 2595: .ao_hwcg = gen7_9_0_ao_hwcg_regs, 2596: .ao_hwcg_count = ARRAY_SIZE(gen7_9_0_ao_hwcg_regs), 2597: .gbif = gen7_2_0_gbif_cx_regs, 2598: .gbif_count = ARRAY_SIZE(gen7_2_0_gbif_cx_regs), 2599: .hang_detect_cycles = 0xcfffff, 2600: .protected_regs = gen7_2_0_protected_regs, 2601: .gmu_hub_clk_freq = 200000000, 2602: .gen7_snapshot_block_list = &gen7_5_0_snapshot_block_list, 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, 2640: .qos_value = gen7_6_0_gbif_client_qos_values, 2641: .preempt_level = 1, 2642: .ctxt_record_size = (4192 * SZ_1K), 2643: }; 2644: 2645: extern const struct gen7_snapshot_block_list gen7_9_0_snapshot_block_list; 2646: 2647: /* GEN7_9_0 protected register list */ 2648: static const struct gen7_protected_regs gen7_9_0_protected_regs[] = { 2649: { GEN7_CP_PROTECT_REG + 0, 0x00000, 0x004ff, 0 }, 2650: { GEN7_CP_PROTECT_REG + 1, 0x0050b, 0x00563, 0 }, 2651: { GEN7_CP_PROTECT_REG + 2, 0x00584, 0x006c1, 0 }, 2652: { GEN7_CP_PROTECT_REG + 3, 0x00706, 0x00706, 0 }, MATCH LINES: 2720, 2721, 2722, 2759, 2760, 2761 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, 2731: .bcl_data = 1, 2732: .acv_perfmode_vote = BIT(2), 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, 2770: .bcl_data = 1, 2771: .acv_perfmode_vote = BIT(2), 2772: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 2773: .ctxt_record_size = (4208 * SZ_1K), 2774: .preempt_level = 1, 2775: .fast_bus_hint = true, 2776: }; 2777: 2778: extern const struct gen7_snapshot_block_list gen7_13_0_snapshot_block_list; 2779: 2780: /* SMMU aperture registers: GC to context bank 0, LPAC to context bank 1 */ 2781: static const struct kgsl_regmap_list gen7_13_0_smmu_aperture_regs[] = { 2782: { 0x0, 0x000c0000 }, /* GC: CB0 */ 2783: { 0x1, 0x000c1000 }, /* LPAC: CB1 */ 2784: { 0x2, 0x00000002 }, /* CTRL: GC + LPAC */ 2785: }; MATCH LINES: 2804, 2805, 2806, 2837, 2838, 2839, 2873, 2874, 2875 2792: .gpudev = &adreno_gen7_gmu_gpudev.base, 2793: .perfcounters = &adreno_gen7_9_0_perfcounters, 2794: .uche_gmem_alignment = SZ_16M, 2795: .gmem_size = 3 * SZ_1M, 2796: .bus_width = 32, 2797: .snapshot_size = SZ_8M, 2798: .num_ddr_channels = 4, 2799: .highest_bank_bit = 16, 2800: .chipid = 0x43051701, 2801: .smmu_aperture = gen7_13_0_smmu_aperture_regs, 2802: .smmu_aperture_count = ARRAY_SIZE(gen7_13_0_smmu_aperture_regs), 2803: }, 2804: .sqefw_name = "gen71300_sqe.fw", 2805: .gmufw_name = "gen71300_gmu.bin", 2806: .zap_name = "gen71300_zap.mbn", 2807: .gmu_chipid = 0x70D0000, 2808: .ao_hwcg = gen7_9_0_ao_hwcg_regs, 2809: .ao_hwcg_count = ARRAY_SIZE(gen7_9_0_ao_hwcg_regs), 2810: .gbif = gen7_2_0_gbif_cx_regs, 2811: .gbif_count = ARRAY_SIZE(gen7_2_0_gbif_cx_regs), 2812: .hang_detect_cycles = 0xcfffff, 2813: .protected_regs = gen7_9_0_protected_regs, 2814: .gmu_hub_clk_freq = 200000000, 2815: .gen7_snapshot_block_list = &gen7_13_0_snapshot_block_list, 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, MATCH LINES: 2919, 2920, 2921, 2956, 2957, 2958 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", 2922: .hwcg = gen7_2_0_hwcg_regs, 2923: .hwcg_count = ARRAY_SIZE(gen7_2_0_hwcg_regs), 2924: .ao_hwcg = gen7_9_0_ao_hwcg_regs, 2925: .ao_hwcg_count = ARRAY_SIZE(gen7_9_0_ao_hwcg_regs), 2926: .gbif = gen7_2_0_gbif_cx_regs, 2927: .gbif_count = ARRAY_SIZE(gen7_2_0_gbif_cx_regs), 2928: .hang_detect_cycles = 0xcfffff, 2929: .protected_regs = gen7_2_0_protected_regs, 2930: .gmu_hub_clk_freq = 200000000, 2931: .gen7_snapshot_block_list = &gen7_15_0_snapshot_block_list, 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, 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}, MATCH LINES: 3053, 3054, 3055 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, 3061: .veto_fal10 = true, 3062: .protected_regs = a660_protected_regs, 3063: .disable_tseskip = true, 3064: .pdc_in_aop = true, 3065: .ctxt_record_size = 2496 * 1024, 3066: }; 3067: 3068: extern const struct gen8_snapshot_block_list gen8_0_0_snapshot_block_list; 3069: 3070: static const struct kgsl_regmap_list gen8_0_0_gbif_cx_regs[] = { 3071: { GEN8_GBIF_QSB_SIDE0, 0x00071e20 }, 3072: { GEN8_GBIF_QSB_SIDE1, 0x00071e20 }, 3073: { GEN8_GBIF_QSB_SIDE2, 0x00071e20 }, 3074: { GEN8_GBIF_QSB_SIDE3, 0x00071e20 }, 3075: { GEN8_GBIF_CX_CONFIG, 0x20023000 }, 3076: { GEN8_GMUCX_MRC_GBIF_QOS_CTRL, 0x33 }, 3077: }; 3078: 3079: /* GEN8_0_0 noncontext register list */ MATCH LINES: 3278, 3279, 3280 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, 3290: .fast_bus_hint = true, 3291: .bcl_data = 1, 3292: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 3293: .noc_timeout_us = 3410, /* 3.41 msec */ 3294: .ctxt_record_size = (13536 * SZ_1K), 3295: .preempt_level = 1, 3296: .cl_no_ft_timeout_ms = 6500, 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), MATCH LINES: 3336, 3337, 3338 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", 3338: .zap_name = "gen80000_zap.mbn", 3339: .ao_hwcg = gen8_ao_hwcg_regs, 3340: .ao_hwcg_count = ARRAY_SIZE(gen8_ao_hwcg_regs), 3341: .gbif = gen8_0_0_gbif_cx_regs, 3342: .gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs), 3343: .hang_detect_cycles = 0xcfffff, 3344: .protected_regs = gen8_0_0_protected_regs, 3345: .nonctxt_regs = gen8_0_0_nonctxt_regs, 3346: .gmu_hub_clk_freq = 200000000, 3347: .gen8_snapshot_block_list = &gen8_0_0_snapshot_block_list, 3348: .fast_bus_hint = true, 3349: .bcl_data = 1, 3350: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 3351: .noc_timeout_us = 3410, /* 3.41 msec */ 3352: .ctxt_record_size = (13536 * SZ_1K), 3353: .preempt_level = 1, 3354: .cl_no_ft_timeout_ms = 6500, 3355: .therm_cfg = &therm_mit_cfg_8_0_0, 3356: .clx_tbl = &gen8_0_0_clx_table, 3357: }; 3358: 3359: extern const struct gen8_snapshot_block_list gen8_2_0_snapshot_block_list; 3360: 3361: static const struct hfi_clx_table_v2_cmd gen8_2_0_clx_table = { 3362: .version = (2 << 16) | 1, MATCH LINES: 3633, 3634, 3635 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, 3643: .gmu_hub_clk_freq = 150000000, 3644: .gen8_snapshot_block_list = &gen8_2_0_snapshot_block_list, 3645: .fast_bus_hint = true, 3646: .bcl_data = GEN8_2_X_BCL_DATA, 3647: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 3648: .noc_timeout_us = 3410, /* 3.41 msec */ 3649: .cl_no_ft_timeout_ms = 6500, 3650: .ctxt_record_size = (19708 * SZ_1K), 3651: .therm_cfg = &therm_mit_cfg_8_2_0, 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, MATCH LINES: 3691, 3692, 3693 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, 3695: .ao_hwcg_count = ARRAY_SIZE(gen8_2_0_ao_hwcg_regs), 3696: .gbif = gen8_0_0_gbif_cx_regs, 3697: .gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs), 3698: .hang_detect_cycles = 0xcfffff, 3699: .protected_regs = gen8_2_0_protected_regs, 3700: .nonctxt_regs = gen8_2_0_nonctxt_regs, 3701: .gmu_hub_clk_freq = 150000000, 3702: .gen8_snapshot_block_list = &gen8_2_0_snapshot_block_list, 3703: .fast_bus_hint = true, 3704: .bcl_data = GEN8_2_X_BCL_DATA, 3705: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 3706: .noc_timeout_us = 3410, /* 3.41 msec */ 3707: .cl_no_ft_timeout_ms = 6500, 3708: .ctxt_record_size = (19708 * SZ_1K), 3709: .therm_cfg = &therm_mit_cfg_8_2_0, 3710: .limits_mit_cfg = &gen8_2_0_limits_mit_cfg, 3711: .preempt_level = 1, 3712: .clx_tbl = &gen8_2_0_clx_table, 3713: }; 3714: 3715: static const struct gen8_nonctxt_regs gen8_1_0_nonctxt_regs[] = { 3716: { GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) }, 3717: { GEN8_GRAS_DBG_ECO_CNTL, 0x00000800, BIT(PIPE_BV) | BIT(PIPE_BR) }, MATCH LINES: 3851, 3852, 3853, 3891, 3892, 3893 3839: .speedbins = KGSL_SPEEDBINS( 3840: { 0, 0 }, 3841: { 388, 1 }, 3842: { 357, 2 }, 3843: { 284, 3 }, 3844: ), 3845: .ubwc_mode = 5, 3846: .mal = 32, 3847: .highest_bank_bit = 16, 3848: .gpu_model = "Adreno X2-90", 3849: }, 3850: .aqefw_name = "gen80100_aqe.fw", 3851: .sqefw_name = "gen80100_sqe.fw", 3852: .gmufw_name = "gen80100_gmu.bin", 3853: .zap_name = "gen80100_zap.mbn", 3854: .ao_hwcg = gen8_1_0_ao_hwcg_regs, 3855: .ao_hwcg_count = ARRAY_SIZE(gen8_1_0_ao_hwcg_regs), 3856: .gbif = gen8_0_0_gbif_cx_regs, 3857: .gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs), 3858: .hang_detect_cycles = 0xcfffff, 3859: .protected_regs = gen8_1_0_protected_regs, 3860: .nonctxt_regs = gen8_1_0_nonctxt_regs, 3861: .gmu_hub_clk_freq = 200000000, 3862: .gen8_snapshot_block_list = &gen8_1_0_snapshot_block_list, 3863: .fast_bus_hint = true, 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, 3901: .gmu_hub_clk_freq = 150000000, 3902: .gen8_snapshot_block_list = &gen8_2_0_snapshot_block_list, 3903: .fast_bus_hint = true, 3904: .bcl_data = GEN8_2_X_BCL_DATA, 3905: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 3906: .noc_timeout_us = 3410, /* 3.41 msec */ 3907: .cl_no_ft_timeout_ms = 6500, 3908: .ctxt_record_size = (19708 * SZ_1K), 3909: .therm_cfg = &therm_mit_cfg_8_2_0, 3910: .limits_mit_cfg = &gen8_2_0_limits_mit_cfg, 3911: .preempt_level = 1, 3912: .clx_tbl = &gen8_2_0_clx_table, 3913: }; 3914: 3915: /* GEN8_4_0 noncontext register list */ 3916: static const struct gen8_nonctxt_regs gen8_4_0_nonctxt_regs[] = { 3917: { GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) }, MATCH LINES: 4004, 4005, 4006 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, 4016: .qos_value = gen8_4_0_gbif_client_qos_values, 4017: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 4018: .bcl_data = 1, 4019: .preempt_level = 1, 4020: .ctxt_record_size = (13536 * SZ_1K), 4021: .noc_timeout_us = 3410, /* 3.41 msec */ 4022: .cl_no_ft_timeout_ms = 10000, 4023: }; 4024: 4025: extern const struct gen8_snapshot_block_list gen8_3_0_snapshot_block_list; 4026: 4027: static const struct kgsl_regmap_list gen8_3_0_gbif_cx_regs[] = { 4028: { GEN8_GBIF_QSB_SIDE0, 0x00071e20 }, 4029: { GEN8_GBIF_QSB_SIDE1, 0x00071e20 }, 4030: { GEN8_GBIF_QSB_SIDE2, 0x00071e20 }, MATCH LINES: 4105, 4106, 4107 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, 4119: }; 4120: 4121: /* GEN8_6_0 noncontext register list */ 4122: static const struct gen8_nonctxt_regs gen8_6_0_nonctxt_regs[] = { 4123: { GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) }, 4124: { GEN8_GRAS_DBG_ECO_CNTL, 0x00000800, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4125: { GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4126: { GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4127: { GEN8_PC_CONTEXT_SWITCH_STABILIZE_CNTL_1, 0x00000002, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4128: { GEN8_PC_CHICKEN_BITS_1, 0x00000003, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4129: { GEN8_PC_CHICKEN_BITS_2, 0x00000200, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4130: { GEN8_PC_CHICKEN_BITS_3, 0x00500000, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4131: { GEN8_PC_CHICKEN_BITS_4, 0x00500050, BIT(PIPE_BR) | BIT(PIPE_BV) }, MATCH LINES: 4206, 4207, 4208, 4242, 4243, 4244 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, 4256: .noc_timeout_us = 3410, /* 3.41 msec */ 4257: .bcl_data = 1, 4258: }; 4259: 4260: /* GEN8_9_0 noncontext register list */ 4261: static const struct gen8_nonctxt_regs gen8_9_0_nonctxt_regs[] = { 4262: { GEN8_RBBM_GBIF_CLIENT_QOS_CNTL, 0x22122212, BIT(PIPE_NONE) }, 4263: { GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL, 0x00000030, BIT(PIPE_NONE) }, 4264: { GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL2, 0x00000030, BIT(PIPE_NONE) }, 4265: /* Disable Dead Draw Merge scheme on RB-HLSQ */ 4266: { GEN8_RB_RBP_CNTL, BIT(5), BIT(PIPE_BV) | BIT(PIPE_BR) }, 4267: { GEN8_RBBM_INTERFACE_HANG_INT_CNTL, 0x0fffffff, BIT(PIPE_NONE) }, 4268: { GEN8_RBBM_POWER_UP_RESET_SW_OVERRIDE, 0x70809060, BIT(PIPE_NONE) }, MATCH LINES: 4342, 4343, 4344 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, 4351: .nonctxt_regs = gen8_9_0_nonctxt_regs, 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 | MATCH LINES: 4389, 4390, 4391 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), 4396: .hang_detect_cycles = 0xc3ffff, 4397: .veto_fal10 = true, 4398: .protected_regs = a620_protected_regs, 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, MATCH LINES: 4435, 4436, 4437 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", 4436: .gmufw_name = "gen80100_gmu.bin", 4437: .zap_name = "gen80100_zap.mbn", 4438: .ao_hwcg = gen8_1_0_ao_hwcg_regs, 4439: .ao_hwcg_count = ARRAY_SIZE(gen8_1_0_ao_hwcg_regs), 4440: .gbif = gen8_0_0_gbif_cx_regs, 4441: .gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs), 4442: .hang_detect_cycles = 0xcfffff, 4443: .protected_regs = gen8_1_0_protected_regs, 4444: .nonctxt_regs = gen8_1_0_nonctxt_regs, 4445: .gmu_hub_clk_freq = 200000000, 4446: .fast_bus_hint = true, 4447: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 4448: .noc_timeout_us = 3410, /* 3.41 msec */ 4449: .cl_no_ft_timeout_ms = 6500, 4450: .ctxt_record_size = (23088 * SZ_1K), 4451: .bcl_data = 1, 4452: .gen8_snapshot_block_list = &gen8_10_0_snapshot_block_list, 4453: .preempt_level = 1, 4454: }; 4455: 4456: static const struct hfi_clx_table_v2_cmd gen8_11_0_clx_table = { 4457: .version = (2 << 16) | 1, 4458: .domain = { 4459: /* GFX domain */ 4460: { 4461: .data0 = CLX_DATA(60, 5, 0, 1), MATCH LINES: 4743, 4744, 4745 4731: .compatible = "qcom,adreno-gpu-gen8-11-0", 4732: .features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_CLX, 4733: .gpudev = &adreno_gen8_hwsched_gpudev.base, 4734: .perfcounters = &adreno_gen8_2_x_perfcounters, 4735: .uche_gmem_alignment = SZ_64M, 4736: .gmem_size = 18 * SZ_1M, 4737: .bus_width = 32, 4738: .snapshot_size = SZ_8M, 4739: .num_ddr_channels = 4, 4740: .highest_bank_bit = 16, 4741: }, 4742: .aqefw_name = "gen81100_aqe.fw", 4743: .sqefw_name = "gen81100_sqe.fw", 4744: .gmufw_name = "gen81100_gmu.bin", 4745: .zap_name = "gen81100_zap.mbn", 4746: .ao_hwcg = gen8_2_0_ao_hwcg_regs, 4747: .ao_hwcg_count = ARRAY_SIZE(gen8_2_0_ao_hwcg_regs), 4748: .gbif = gen8_11_0_gbif_cx_regs, 4749: .gbif_count = ARRAY_SIZE(gen8_11_0_gbif_cx_regs), 4750: .hang_detect_cycles = 0xcfffff, 4751: .protected_regs = gen8_11_0_protected_regs, 4752: .nonctxt_regs = gen8_11_0_nonctxt_regs, 4753: .gmu_hub_clk_freq = 150000000, 4754: .gen8_snapshot_block_list = &gen8_11_0_snapshot_block_list, 4755: .fast_bus_hint = true, 4756: .bcl_data = 1, 4757: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 4758: .noc_timeout_us = 3410, /* 3.41 msec */ 4759: .cl_no_ft_timeout_ms = 6500, 4760: .ctxt_record_size = (19708 * SZ_1K), 4761: .limits_mit_cfg = &gen8_11_0_limits_mit_cfg, 4762: .preempt_level = 1, 4763: .gmu_mx_gdsc = true, 4764: .three_rail_memory = true, 4765: .malu = true, 4766: .clx_tbl = &gen8_11_0_clx_table, 4767: }; 4768: 4769: /* GEN8_11_1 noncontext register list */ MATCH LINES: 4890, 4891, 4892 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), 4895: .gbif = gen8_11_0_gbif_cx_regs, 4896: .gbif_count = ARRAY_SIZE(gen8_11_0_gbif_cx_regs), 4897: .hang_detect_cycles = 0xcfffff, 4898: .protected_regs = gen8_11_0_protected_regs, 4899: .nonctxt_regs = gen8_11_1_nonctxt_regs, 4900: .gmu_hub_clk_freq = 150000000, 4901: .gen8_snapshot_block_list = &gen8_11_0_snapshot_block_list, 4902: .fast_bus_hint = true, 4903: .bcl_data = GEN8_2_X_BCL_DATA, 4904: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(4224, 4), 4905: .noc_timeout_us = 3410, /* 3.41 msec */ 4906: .cl_no_ft_timeout_ms = 6500, 4907: .ctxt_record_size = (19708 * SZ_1K), 4908: .limits_mit_cfg = &gen8_11_0_limits_mit_cfg, 4909: .preempt_level = 1, 4910: .gmu_mx_gdsc = true, 4911: .three_rail_memory = true, 4912: .malu = true, 4913: .clx_tbl = &gen8_11_0_clx_table, 4914: }; 4915: 4916: static const struct gen8_nonctxt_regs gen8_14_0_nonctxt_regs[] = { MATCH LINES: 5034, 5035, 5036 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), 5039: .gbif = gen8_11_0_gbif_cx_regs, 5040: .gbif_count = ARRAY_SIZE(gen8_11_0_gbif_cx_regs), 5041: .hang_detect_cycles = 0xcfffff, 5042: .protected_regs = gen8_11_0_protected_regs, 5043: .nonctxt_regs = gen8_14_0_nonctxt_regs, 5044: .gmu_hub_clk_freq = 150000000, 5045: .gen8_snapshot_block_list = &gen8_11_0_snapshot_block_list, 5046: .fast_bus_hint = true, 5047: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(4224, 4), 5048: .noc_timeout_us = 3410, /* 3.41 msec */ 5049: .cl_no_ft_timeout_ms = 6500, 5050: .ctxt_record_size = (13564 * SZ_1K), 5051: .limits_mit_cfg = &gen8_11_0_limits_mit_cfg, 5052: .preempt_level = 1, 5053: .gmu_mx_gdsc = true, 5054: .three_rail_memory = true, 5055: .malu = false, 5056: .clx_tbl = &gen8_14_0_clx_table, 5057: }; 5058: 5059: static const struct adreno_gpu_core *adreno_gpulist[] = { 5060: &adreno_gpu_core_a306, /* Deprecated */ --- FILE: \adreno.c | HITS: 42 --- MATCH LINES: 9 1: // SPDX-License-Identifier: GPL-2.0-only 2: /* 3: * Copyright (c) 2002,2007-2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: #include 7: #include 8: #include 9: #include 10: #include 11: #include 12: #include 13: #include 14: #include 15: #include 16: #include 17: #include 18: #include 19: #include 20: #include 21: #include 22: #include 23: #include 24: #include 25: #include 26: #include 27: #include 28: #include 29: #if (KERNEL_VERSION(6, 10, 0) <= LINUX_VERSION_CODE) 30: #include 31: #endif 32: #if (KERNEL_VERSION(6, 17, 0) <= LINUX_VERSION_CODE) 33: #include MATCH LINES: 143 131: { 132: struct kgsl_memdesc *memdesc = ADRENO_FW(adreno_dev, ADRENO_FW_SQE)->memdesc; 133: struct ctxt_record_info *info; 134: u32 *hostptr; 135: int i; 136: 137: if (!memdesc) 138: return -ENODEV; 139: 140: hostptr = (u32 *)memdesc->hostptr; 141: 142: /* 143: * SQE firmware inserts context record magic at offset 5. 144: * The pointer to context record table is stored at offset 6. 145: * The values are stored at [23:0]. 146: */ 147: if ((hostptr[CTXT_RECORD_MAGIC_OFFSET] & 148: CTXT_RECORD_PAYLOAD_MASK) != CTXT_RECORD_TBL_MAGIC) 149: return -ENODEV; 150: 151: /* Calculate the address of the context record table */ 152: hostptr += (hostptr[CTXT_TBL_OFFSET] & CTXT_RECORD_PAYLOAD_MASK); 153: info = (struct ctxt_record_info *) hostptr; 154: hostptr += (sizeof(*info) >> 2); 155: 156: /* Validate that the entire context record table is within mapped range */ 157: if (!HOSTADDR_IN_MEMDESC((void *)(hostptr + 158: ((u64) info->num_gpus * (u64) info->dwords_per_gpu)), memdesc)) 159: return -EACCES; 160: 161: for (i = 0; i < info->num_gpus; i++) { 162: struct gpu_ctxt_record *record = (struct gpu_ctxt_record *) hostptr; 163: u32 major, minor; 164: 165: /* Compare the GPU revision to determine context record size */ 166: major = FIELD_GET(GENMASK(31, 28), record->hw_version); 167: minor = FIELD_GET(GENMASK(27, 16), record->hw_version); MATCH LINES: 189, 200, 211, 212, 214, 216, 217, 219, 222, 243, 253, 254, 257, 260, 263, 268, 272, 274, 275, 276, 279, 306, 307, 323, 324, 325, 326, 331, 332, 334, 357, 380, 393 177: adreno_dev->aqe_ctxt_record_sz = record->aqe_size * SZ_1K; 178: return 0; 179: } 180: 181: hostptr += info->dwords_per_gpu; 182: } 183: 184: return -ENOENT; 185: } 186: 187: struct adreno_fw_work { 188: struct work_struct work; 189: const struct firmware **fw; 190: const char *name; 191: struct device *device; 192: int ret; 193: }; 194: 195: static void adreno_fw_load_worker(struct work_struct *work) 196: { 197: struct adreno_fw_work *fw_work = 198: container_of(work, struct adreno_fw_work, work); 199: 200: fw_work->ret = firmware_request_nowarn(fw_work->fw, fw_work->name, fw_work->device); 201: } 202: 203: static int adreno_fw_dispatch(struct adreno_fw_work *work) 204: { 205: queue_work(kgsl_driver.lockless_workqueue, &work->work); 206: flush_work(&work->work); 207: return work->ret; 208: } 209: 210: /* 211: * Dispatch firmware_request_nowarn() to a workqueue thread rather than calling 212: * it directly. When the GPU device is first opened, request_firmware() would 213: * otherwise be called from within the path_openat() call chain 214: * (open -> kgsl_open -> ... -> adreno_request_firmware). The kernel tracks 215: * symlink traversal depth in current->nameidata->total_link_count, which is 216: * never reset between nested path_openat() calls. With multiple firmware files, 217: * compressed variants, and symlinks in the firmware search paths (e.g. 218: * /lib -> /usr/lib), total_link_count can reach MAXSYMLINKS (40), causing 219: * request_firmware() to fail with -ELOOP. A workqueue thread has 220: * current->nameidata == NULL, so total_link_count is reset for every lookup. 221: */ 222: int adreno_request_firmware(const struct firmware **fw, const char *name, 223: struct device *device, bool log_error) 224: { 225: struct adreno_fw_work work = { 226: .fw = fw, .name = name, .device = device, 227: }; 228: int ret; 229: 230: INIT_WORK_ONSTACK(&work.work, adreno_fw_load_worker); 231: ret = adreno_fw_dispatch(&work); 232: if (!ret) 233: goto out; 234: 235: work.name = kasprintf(GFP_KERNEL, "qcom/%s", name); 236: if (!work.name) { 237: ret = -ENOMEM; 238: goto out; 239: } 240: 241: ret = adreno_fw_dispatch(&work); 242: if (ret && log_error) 243: dev_err(device, "Firmware request for %s failed with error %d\n", 244: name, ret); 245: kfree(work.name); 246: 247: out: 248: destroy_work_on_stack(&work.work); 249: 250: return ret; 251: } 252: 253: int adreno_get_firmware(struct adreno_device *adreno_dev, 254: const char *fwfile, struct adreno_firmware *firmware) 255: { 256: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 257: const struct firmware *fw = NULL; 258: int ret; 259: 260: if (!IS_ERR_OR_NULL(firmware->memdesc)) 261: return 0; 262: 263: ret = adreno_request_firmware(&fw, fwfile, &device->pdev->dev, true); 264: 265: if (ret) 266: return ret; 267: 268: firmware->memdesc = kgsl_allocate_global(device, fw->size - 4, 0, 269: KGSL_MEMFLAGS_GPUREADONLY, KGSL_MEMDESC_UCODE, 270: "ucode"); 271: 272: ret = PTR_ERR_OR_ZERO(firmware->memdesc); 273: if (!ret) { 274: memcpy(firmware->memdesc->hostptr, &fw->data[4], fw->size - 4); 275: firmware->size = (fw->size - 4) / sizeof(u32); 276: firmware->version = get_ucode_version((u32 *)fw->data); 277: } 278: 279: release_firmware(fw); 280: return ret; 281: } 282: 283: /* 284: * The PASID has stayed consistent across all targets thus far so we are 285: * cautiously optimistic that we can hard code it 286: */ 287: #define GPU_PASID 13 288: 289: /* True when zap-shader is present */ 290: static bool adreno_check_zap_enabled(struct kgsl_device *device) 291: { 292: struct device_node *np = of_get_child_by_name(device->pdev->dev.of_node, 293: "zap-shader"); 294: bool present = of_device_is_available(np); 295: 296: of_node_put(np); 297: return present; 298: } 299: 300: int adreno_zap_shader_load(struct adreno_device *adreno_dev, 301: const char *name) 302: { 303: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 304: struct device_node *np, *mem_np; 305: struct device *dev = &device->pdev->dev; 306: const char *firmware_name = NULL; 307: const struct firmware *fw; 308: void *mem_region = NULL; 309: phys_addr_t mem_phys; 310: struct resource res; 311: ssize_t mem_size; 312: int ret; 313: 314: if (adreno_dev->zap_loaded || IS_ENABLED(CONFIG_QCOM_KVM_ENABLED) || 315: !adreno_dev->zap_enabled) 316: return 0; 317: 318: np = of_get_child_by_name(dev->of_node, "zap-shader"); 319: if (!np) 320: return -ENODEV; 321: 322: /* 323: * While loading the zap firmware, follow the priority order below to determine 324: * the firmware name: 325: * 1. Check the "firmware-name" property in the device tree to identify the 326: * firmware path. 327: * 2. If not specified, fall back to the zap entry defined in the GPU list. 328: * 3. If both are missing, skip zap fw loading and use direct register write 329: * to switch secure state. 330: */ 331: of_property_read_string(np, "firmware-name", &firmware_name); 332: firmware_name = firmware_name ?: name; 333: 334: if (!firmware_name) { 335: of_node_put(np); 336: return 0; 337: } 338: 339: if (!np) { 340: dev_err(device->dev, "zap-shader node not found. Please update the device tree\n"); 341: of_node_put(np); 342: return -ENODEV; 343: } 344: 345: mem_np = of_parse_phandle(np, "memory-region", 0); 346: of_node_put(np); 347: if (!mem_np) { 348: dev_err(dev, "Couldn't parse the mem-region from the zap-shader node\n"); 349: return -EINVAL; 350: } 351: 352: ret = of_address_to_resource(mem_np, 0, &res); 353: of_node_put(mem_np); 354: if (ret) 355: return ret; 356: 357: ret = adreno_request_firmware(&fw, firmware_name, dev, true); 358: if (ret) 359: return ret; 360: 361: mem_size = qcom_mdt_get_size(fw); 362: if (mem_size < 0) { 363: ret = mem_size; 364: goto out; 365: } 366: 367: if (mem_size > resource_size(&res)) { 368: ret = -E2BIG; 369: goto out; 370: } 371: 372: mem_phys = res.start; 373: 374: mem_region = memremap(mem_phys, mem_size, MEMREMAP_WC); 375: if (!mem_region) { 376: ret = -ENOMEM; 377: goto out; 378: } 379: 380: ret = qcom_mdt_load(dev, fw, firmware_name, GPU_PASID, mem_region, 381: mem_phys, mem_size, NULL); 382: if (ret) { 383: dev_err(dev, "Error %d while loading the MDT\n", ret); 384: goto out; 385: } 386: 387: ret = kgsl_pas_auth_and_reset(GPU_PASID); 388: 389: out: 390: if (mem_region) 391: memunmap(mem_region); 392: 393: release_firmware(fw); 394: 395: if (!ret) 396: adreno_dev->zap_loaded = true; 397: 398: return ret; 399: } 400: 401: #if (IS_ENABLED(CONFIG_QCOM_KGSL_HIBERNATION) || IS_ENABLED(CONFIG_DEEPSLEEP)) 402: static void adreno_zap_shader_unload(struct adreno_device *adreno_dev) 403: { 404: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 405: int ret; 406: 407: if (adreno_dev->zap_loaded) { 408: ret = kgsl_pas_shutdown(GPU_PASID); 409: if (ret) 410: dev_err(&device->pdev->dev, "Error %d while PAS shutdown\n", ret); 411: else 412: adreno_dev->zap_loaded = false; 413: } 414: } 415: #endif 416: 417: /** MATCH LINES: 2490 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; MATCH LINES: 2532 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: */ 2547: clear_bit(ADRENO_DEVICE_CX_TIMER_INITIALIZED, &adreno_dev->priv); 2548: kgsl_reclaim_close(); 2549: kthread_flush_worker(device->events_worker); 2550: flush_workqueue(kgsl_driver.lockless_workqueue); 2551: 2552: return status; 2553: } 2554: 2555: void adreno_create_profile_buffer(struct adreno_device *adreno_dev) 2556: { MATCH LINES: 2938, 2939, 2940, 2941, 2947 2926: */ 2927: if (device->snapshot) 2928: device->snapshot->recovered = true; 2929: 2930: /* Start the dispatcher */ 2931: adreno_dispatcher_start(device); 2932: 2933: device->reset_counter++; 2934: 2935: set_bit(ADRENO_DEVICE_STARTED, &adreno_dev->priv); 2936: 2937: /* 2938: * There is a possible deadlock scenario during kgsl firmware reading 2939: * (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl 2940: * device mutex is held and then firmware_request_nowarn is called for reading 2941: * firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock. 2942: * Whereas in case of devfreq update calls triggered by thermal/bcl or 2943: * devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then 2944: * tries to take kgsl device mutex as part of get_dev_status/target 2945: * calls. This results in deadlock when both thread are unable to acquire 2946: * the mutex held by other thread. Enable devfreq updates now as we are 2947: * done reading all firmware files. 2948: */ 2949: device->pwrscale.devfreq_enabled = true; 2950: 2951: return 0; 2952: 2953: error_pwr_off: 2954: /* set the state back to original state */ 2955: kgsl_pwrctrl_change_state(device, state); 2956: 2957: return status; 2958: } 2959: 2960: /** 2961: * adreno_start() - Power up and initialize the GPU 2962: * @device: Pointer to the KGSL device to power up 2963: * @priority: Boolean flag to specify of the start should be scheduled in a low 2964: * latency work queue 2965: * 2966: * Power up the GPU and initialize it. If priority is specified then elevate 2967: * the thread priority for the duration of the start operation 2968: */ 2969: int adreno_start(struct kgsl_device *device, int priority) 2970: { 2971: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); --- FILE: \adreno.h | HITS: 19 --- MATCH LINES: 9 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) 2008-2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: #ifndef __ADRENO_H 7: #define __ADRENO_H 8: 9: #include 10: #include 11: #include 12: #include 13: #include "adreno_coresight.h" 14: #include "adreno_dispatch.h" 15: #include "adreno_drawctxt.h" 16: #include "adreno_hwsched.h" 17: #include "adreno_perfcounter.h" 18: #include "adreno_profile.h" 19: #include "adreno_ringbuffer.h" 20: #include "kgsl_sharedmem.h" 21: 22: /* Used to point CP to the SMMU record during preemption */ 23: #define SET_PSEUDO_SMMU_INFO 0 24: /* Used to inform CP where to save preemption data at the time of switch out */ 25: #define SET_PSEUDO_PRIV_NON_SECURE_SAVE_ADDR 1 26: /* Used to inform CP where to save secure preemption data at the time of switch out */ 27: #define SET_PSEUDO_PRIV_SECURE_SAVE_ADDR 2 28: /* Used to inform CP where to save per context non-secure data at the time of switch out */ 29: #define SET_PSEUDO_NON_PRIV_SAVE_ADDR 3 30: /* Used to inform CP where to save preemption counter data at the time of switch out */ 31: #define SET_PSEUDO_COUNTER 4 32: 33: /* Index to preemption scratch buffer to store current QOS value */ MATCH LINES: 463, 469 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 482: */ 483: struct adreno_perfcounter_list_node { 484: unsigned int groupid; 485: unsigned int countable; 486: struct list_head node; 487: }; 488: 489: /** 490: * struct adreno_device_private - Adreno private structure per fd 491: * @dev_priv: the kgsl device private structure 492: * @perfcounter_list: list of perfcounters used by the process 493: */ MATCH LINES: 727 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]; 731: int num_ringbuffers; 732: struct adreno_ringbuffer *cur_rb; 733: struct adreno_ringbuffer *next_rb; 734: struct adreno_ringbuffer *prev_rb; 735: unsigned long ft_policy; 736: bool long_ib_detect; 737: bool cooperative_reset; 738: struct adreno_profile profile; 739: struct adreno_dispatcher dispatcher; 740: struct kgsl_memdesc *pwron_fixup; 741: unsigned int pwron_fixup_dwords; 742: struct work_struct input_work; 743: struct adreno_busy_data busy_data; 744: unsigned int ram_cycles_lo; 745: unsigned int ram_cycles_lo_ch1_read; 746: unsigned int ram_cycles_lo_ch0_write; 747: unsigned int ram_cycles_lo_ch1_write; 748: unsigned int starved_ram_lo; 749: unsigned int starved_ram_lo_ch1; 750: atomic_t halt; 751: atomic_t pending_irq_refcnt; MATCH LINES: 962 950: /** 951: * enum adreno_device_flags - Private flags for the adreno_device 952: * @ADRENO_DEVICE_PWRON - Set during init after a power collapse 953: * @ADRENO_DEVICE_PWRON_FIXUP - Set if the target requires the shader fixup 954: * after power collapse 955: * @ADRENO_DEVICE_STARTED - Set if the device start sequence is in progress 956: * @ADRENO_DEVICE_FAULT - Set if the device is currently in fault (and shouldn't 957: * send any more commands to the ringbuffer) 958: * @ADRENO_DEVICE_DRAWOBJ_PROFILE - Set if the device supports drawobj 959: * profiling via the ALWAYSON counter 960: * @ADRENO_DEVICE_PREEMPTION - Turn on/off preemption 961: * @ADRENO_DEVICE_SOFT_FAULT_DETECT - Set if soft fault detect is enabled 962: * @ADRENO_DEVICE_GPMU_INITIALIZED - Set if GPMU firmware initialization succeed 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, MATCH LINES: 2085, 2086, 2087, 2088, 2091, 2092, 2093, 2097, 2101, 2103, 2104, 2106, 2111, 2112 2073: { 2074: u32 level; 2075: 2076: if (kgsl_context_is_lpac(context)) 2077: return KGSL_LPAC_RB_ID; 2078: 2079: level = context->priority / KGSL_PRIORITY_MAX_RB_LEVELS; 2080: 2081: return min_t(u32, level, KGSL_PRIORITY_MAX_RB_LEVELS - 1); 2082: } 2083: 2084: /** 2085: * adreno_request_firmware - Helper function for requesting firmware 2086: * @fw: Pointer to firmware image 2087: * @name: Name of firmware file 2088: * @device: Device for which firmware is being loaded 2089: * @log_error: If true, logs an error message on failure 2090: * 2091: * Request for firmware with the name passed. If firmware is not 2092: * available at /lib/firmware/, try /lib/firmware/qcom path by 2093: * adding qcom/ prefix to the firmware name. 2094: * 2095: * Return: 0 on success or negative on failure 2096: */ 2097: int adreno_request_firmware(const struct firmware **fw, 2098: const char *name, struct device *device, bool log_error); 2099: 2100: /** 2101: * adreno_get_firwmare - Load firmware into a adreno_firmware struct 2102: * @adreno_dev: An Adreno GPU device handle 2103: * @fwfile: Firmware file to load 2104: * @firmware: A &struct adreno_firmware container for the firmware. 2105: * 2106: * Load the specified firmware file into the memdesc in &struct adreno_firmware 2107: * and get the size and version from the data. 2108: * 2109: * Return: 0 on success or negative on failure 2110: */ 2111: int adreno_get_firmware(struct adreno_device *adreno_dev, 2112: const char *fwfile, struct adreno_firmware *firmware); 2113: /** 2114: * adreno_zap_shader_load - Helper function for loading the zap shader 2115: * adreno_dev: A handle to an Adreno GPU device 2116: * name: Name of the zap shader to load 2117: * 2118: * A target indepedent helper function for loading the zap shader. 2119: * 2120: * Return: 0 on success or negative on failure. 2121: */ 2122: int adreno_zap_shader_load(struct adreno_device *adreno_dev, 2123: const char *name); 2124: 2125: /** 2126: * adreno_irq_callbacks - Helper function to handle IRQ callbacks 2127: * @adreno_dev: Adreno GPU device handle 2128: * @funcs: List of callback functions 2129: * @status: Interrupt status 2130: * 2131: * Walk the bits in the interrupt status and call any applicable callbacks. 2132: * Return: IRQ_HANDLED if one or more interrupt callbacks were called. 2133: */ 2134: irqreturn_t adreno_irq_callbacks(struct adreno_device *adreno_dev, 2135: const struct adreno_irq_funcs *funcs, u32 status); 2136: --- FILE: \adreno_a5xx.c | HITS: 32 --- MATCH LINES: 9, 14, 43, 66 1: // SPDX-License-Identifier: GPL-2.0-only 2: /* 3: * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #include 8: #include 9: #include 10: #include 11: #include 12: #include 13: #if IS_ENABLED(CONFIG_QCOM_SCM_ADDON) 14: #include 15: #endif 16: #include 17: 18: #include "adreno.h" 19: #include "adreno_a5xx.h" 20: #include "adreno_a5xx_packets.h" 21: #include "adreno_pm4types.h" 22: #include "adreno_trace.h" 23: #include "kgsl_trace.h" 24: #include "kgsl_util.h" 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) | \ 62: (1 << A5XX_INT_MISC_HANG_DETECT) | \ 63: (1 << A5XX_INT_UCHE_OOB_ACCESS) | \ 64: (1 << A5XX_INT_UCHE_TRAP_INTR) | \ 65: (1 << A5XX_INT_CP_SW) | \ 66: (1 << A5XX_INT_GPMU_FIRMWARE) | \ 67: (1 << A5XX_INT_GPMU_VOLTAGE_DROOP)) 68: 69: static int a5xx_probe(struct platform_device *pdev, 70: u32 chipid, const struct adreno_gpu_core *gpucore) 71: { 72: struct adreno_device *adreno_dev; 73: struct kgsl_device *device; 74: int ret; 75: 76: adreno_dev = (struct adreno_device *) 77: of_device_get_match_data(&pdev->dev); 78: 79: memset(adreno_dev, 0, sizeof(*adreno_dev)); 80: 81: adreno_dev->gpucore = gpucore; 82: adreno_dev->chipid = chipid; 83: 84: adreno_reg_offset_init(gpucore->gpudev->reg_offsets); 85: 86: adreno_dev->sptp_pc_enabled = 87: ADRENO_FEATURE(adreno_dev, ADRENO_SPTP_PC); 88: 89: if (adreno_is_a540(adreno_dev)) 90: adreno_dev->throttling_enabled = true; MATCH LINES: 438, 446 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, ®); 440: if (reg & BIT(20)) 441: dev_warn(device->dev, "SPTP GDSC is not disabled\n"); 442: kgsl_regread(device, A5XX_GPMU_RBCCU_PWR_CLK_STATUS, ®); 443: if (reg & BIT(20)) 444: dev_warn(device->dev, "RBCCU GDSC is not disabled\n"); 445: /* 446: * GPMU firmware is supposed to set GMEM to non-retention. 447: * Bit 14 is the memory core force on bit. 448: */ 449: kgsl_regread(device, A5XX_GPMU_RBCCU_CLOCK_CNTL, ®); 450: if (reg & BIT(14)) 451: dev_warn(device->dev, "GMEM is forced on\n"); 452: } 453: 454: if (adreno_is_a530(adreno_dev)) { 455: /* Reset VBIF before PC to avoid popping bogus FIFO entries */ 456: kgsl_regwrite(device, A5XX_RBBM_BLOCK_SW_RESET_CMD, 457: 0x003C0000); 458: kgsl_regwrite(device, A5XX_RBBM_BLOCK_SW_RESET_CMD, 0); 459: } 460: } 461: 462: /* 463: * a5xx_enable_pc() - Enable the GPMU based power collapse of the SPTP and RAC 464: * blocks 465: * @adreno_dev: The adreno device pointer 466: */ 467: static void a5xx_enable_pc(struct adreno_device *adreno_dev) 468: { 469: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 470: MATCH LINES: 518, 547, 550, 553, 574, 584, 587, 600, 608 506: cmds_size << 2, GFP_KERNEL); 507: if (adreno_dev->gpmu_cmds == NULL) 508: return -ENOMEM; 509: 510: cmds = adreno_dev->gpmu_cmds; 511: start = cmds; 512: 513: /* Turn CP protection OFF */ 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) 551: { 552: uint32_t *data; 553: const struct firmware *fw = NULL; 554: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 555: const struct adreno_a5xx_core *a5xx_core = to_a5xx_core(adreno_dev); 556: uint32_t *cmds, cmd_size; 557: int ret = -EINVAL; 558: u32 gmu_major = 1; 559: 560: if (!a5xx_has_gpmu(adreno_dev)) 561: return 0; 562: 563: /* a530 used GMU major 1 and A540 used GMU major 3 */ 564: if (adreno_is_a540(adreno_dev)) 565: gmu_major = 3; 566: 567: /* gpmu fw already saved and verified so do nothing new */ 568: if (adreno_dev->gpmu_cmds_size != 0) 569: return 0; 570: 571: if (a5xx_core->gpmufw_name == NULL) 572: return 0; 573: 574: ret = adreno_request_firmware(&fw, a5xx_core->gpmufw_name, 575: &device->pdev->dev, true); 576: if (ret || fw == NULL) 577: return ret; 578: 579: data = (uint32_t *)fw->data; 580: 581: if (data[0] >= (fw->size / sizeof(uint32_t)) || data[0] < 2) 582: goto err; 583: 584: if (data[1] != GPMU_FIRMWARE_ID) 585: goto err; 586: ret = _read_fw2_block_header(device, &data[2], 587: data[0] - 2, GPMU_FIRMWARE_ID, gmu_major, 0); 588: if (ret) 589: goto err; 590: 591: /* Integer overflow check for cmd_size */ 592: if (data[2] > (data[0] - 2)) 593: goto err; 594: 595: cmds = data + data[2] + 3; 596: cmd_size = data[0] - data[2] - 2; 597: 598: if (cmd_size > GPMU_INST_RAM_SIZE) { 599: dev_err(device->dev, 600: "GPMU firmware block size is larger than RAM size\n"); 601: goto err; 602: } 603: 604: /* Everything is cool, so create some commands */ 605: ret = _gpmu_create_load_cmds(adreno_dev, cmds, cmd_size); 606: err: 607: if (fw) 608: release_firmware(fw); 609: 610: return ret; 611: } 612: 613: static void a5xx_spin_idle_debug(struct adreno_device *adreno_dev, 614: const char *str) 615: { 616: struct kgsl_device *device = &adreno_dev->dev; 617: unsigned int rptr, wptr; 618: unsigned int status, status3, intstatus; 619: unsigned int hwfault; 620: 621: dev_err(device->dev, str); 622: 623: kgsl_regread(device, A5XX_CP_RB_RPTR, &rptr); 624: kgsl_regread(device, A5XX_CP_RB_WPTR, &wptr); 625: 626: kgsl_regread(device, A5XX_RBBM_STATUS, &status); 627: kgsl_regread(device, A5XX_RBBM_STATUS3, &status3); 628: kgsl_regread(device, A5XX_RBBM_INT_0_STATUS, &intstatus); 629: kgsl_regread(device, A5XX_CP_HW_FAULT, &hwfault); 630: 631: 632: dev_err(device->dev, MATCH LINES: 694, 697, 707, 716, 735 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: */ 700: do { 701: udelay(1); 702: kgsl_regread(device, A5XX_GPMU_GENERAL_0, ®); 703: } while ((reg != 0xBABEFACE) && retry--); 704: 705: if (reg != 0xBABEFACE) { 706: dev_err(device->dev, 707: "GPMU firmware initialization timed out\n"); 708: return -ETIMEDOUT; 709: } 710: 711: if (!adreno_is_a530(adreno_dev)) { 712: kgsl_regread(device, A5XX_GPMU_GENERAL_1, ®); 713: 714: if (reg) { 715: dev_err(device->dev, 716: "GPMU firmware initialization failed: %d\n", 717: reg); 718: return -EIO; 719: } 720: } 721: set_bit(ADRENO_DEVICE_GPMU_INITIALIZED, &adreno_dev->priv); 722: /* 723: * We are in AWARE state and IRQ line from GPU to host is 724: * disabled. 725: * Read pending GPMU interrupts and clear GPMU_RBBM_INTR_INFO. 726: */ 727: kgsl_regread(device, A5XX_GPMU_RBBM_INTR_INFO, ®); 728: /* 729: * Clear RBBM interrupt mask if any of GPMU interrupts 730: * are pending. 731: */ 732: if (reg) 733: kgsl_regwrite(device, 734: A5XX_RBBM_INT_CLEAR_CMD, 735: 1 << A5XX_INT_GPMU_FIRMWARE); 736: return ret; 737: } 738: 739: void a5xx_hwcg_set(struct adreno_device *adreno_dev, bool on) 740: { 741: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 742: const struct adreno_a5xx_core *a5xx_core = to_a5xx_core(adreno_dev); 743: int i; 744: 745: if (!adreno_dev->hwcg_enabled) 746: return; 747: 748: for (i = 0; i < a5xx_core->hwcg_count; i++) 749: kgsl_regwrite(device, a5xx_core->hwcg[i].offset, 750: on ? a5xx_core->hwcg[i].val : 0); 751: 752: /* enable top level HWCG */ 753: kgsl_regwrite(device, A5XX_RBBM_CLOCK_CNTL, on ? 0xAAA8AA00 : 0); 754: kgsl_regwrite(device, A5XX_RBBM_ISDB_CNT, on ? 0x00000182 : 0x00000180); 755: } 756: 757: static int _read_fw2_block_header(struct kgsl_device *device, 758: uint32_t *header, uint32_t remain, 759: uint32_t id, uint32_t major, uint32_t minor) MATCH LINES: 834, 843 822: * Opcode 0 data M words 823: * Opcode 1 ID 824: * Opcode 1 data N words 825: * ... 826: * Opcode X ID 827: * Opcode X data O words 828: * Block 2 length... 829: */ 830: static void _load_regfile(struct adreno_device *adreno_dev) 831: { 832: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 833: const struct adreno_a5xx_core *a5xx_core = to_a5xx_core(adreno_dev); 834: const struct firmware *fw; 835: uint64_t block_size = 0, block_total = 0; 836: uint32_t fw_size, *block; 837: int ret = -EINVAL; 838: u32 lm_major = 1; 839: 840: if (!a5xx_core->regfw_name) 841: return; 842: 843: ret = adreno_request_firmware(&fw, a5xx_core->regfw_name, 844: &device->pdev->dev, true); 845: if (ret) 846: return; 847: 848: /* a530v2 lm_major was 3. a530v3 lm_major was 1 */ 849: if (adreno_is_a530v2(adreno_dev)) 850: lm_major = 3; 851: 852: fw_size = fw->size / sizeof(uint32_t); 853: /* Min valid file of size 6, see file description */ 854: if (fw_size < 6) 855: goto err; 856: block = (uint32_t *)fw->data; 857: /* All offset numbers calculated from file description */ 858: while (block_total < fw_size) { 859: block_size = block[0]; 860: if (((block_total + block_size) >= fw_size) 861: || block_size < 5) 862: goto err; 863: if (block[1] != GPMU_SEQUENCE_ID) 864: goto err; 865: 866: /* For now ignore blocks other than the LM sequence */ 867: if (block[4] == LM_SEQUENCE_ID) { MATCH LINES: 886 874: if (block[2] > (block_size - 2)) 875: goto err; 876: adreno_dev->lm_sequence = block + block[2] + 3; 877: adreno_dev->lm_size = block_size - block[2] - 2; 878: } 879: block_total += (block_size + 1); 880: block += (block_size + 1); 881: } 882: if (adreno_dev->lm_sequence) 883: return; 884: 885: err: 886: release_firmware(fw); 887: dev_err(device->dev, 888: "Register file failed to load sz=%d bsz=%llu header=%d\n", 889: fw_size, block_size, ret); 890: } 891: 892: static int _execute_reg_sequence(struct adreno_device *adreno_dev, 893: uint32_t *opcode, uint32_t length) 894: { 895: uint32_t *cur = opcode; 896: uint64_t reg, val; 897: 898: /* todo double check the reg writes */ 899: while ((cur - opcode) < length) { 900: if (cur[0] == 1 && (length - (cur - opcode) >= 4)) { 901: /* Write a 32 bit value to a 64 bit reg */ 902: reg = cur[2]; 903: reg = (reg << 32) | cur[1]; 904: kgsl_regwrite(KGSL_DEVICE(adreno_dev), reg, cur[3]); 905: cur += 4; 906: } else if (cur[0] == 2 && (length - (cur - opcode) >= 5)) { 907: /* Write a 64 bit value to a 64 bit reg */ 908: reg = cur[2]; 909: reg = (reg << 32) | cur[1]; 910: val = cur[4]; MATCH LINES: 1642, 1643, 1670 1630: "zap resume call failed: %d\n", ret); 1631: 1632: return ret; 1633: } 1634: 1635: /* 1636: * a5xx_microcode_load() - Load microcode 1637: * @adreno_dev: Pointer to adreno device 1638: */ 1639: static int a5xx_microcode_load(struct adreno_device *adreno_dev) 1640: { 1641: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1642: struct adreno_firmware *pm4_fw = ADRENO_FW(adreno_dev, ADRENO_FW_PM4); 1643: struct adreno_firmware *pfp_fw = ADRENO_FW(adreno_dev, ADRENO_FW_PFP); 1644: const struct adreno_a5xx_core *a5xx_core = to_a5xx_core(adreno_dev); 1645: uint64_t gpuaddr; 1646: 1647: gpuaddr = pm4_fw->memdesc->gpuaddr; 1648: kgsl_regwrite(device, A5XX_CP_PM4_INSTR_BASE_LO, 1649: lower_32_bits(gpuaddr)); 1650: kgsl_regwrite(device, A5XX_CP_PM4_INSTR_BASE_HI, 1651: upper_32_bits(gpuaddr)); 1652: 1653: gpuaddr = pfp_fw->memdesc->gpuaddr; 1654: kgsl_regwrite(device, A5XX_CP_PFP_INSTR_BASE_LO, 1655: lower_32_bits(gpuaddr)); 1656: kgsl_regwrite(device, A5XX_CP_PFP_INSTR_BASE_HI, 1657: upper_32_bits(gpuaddr)); 1658: 1659: /* 1660: * Do not invoke to load zap shader if MMU does 1661: * not support secure mode. 1662: */ 1663: if (!device->mmu.secured) 1664: return 0; 1665: 1666: if (adreno_dev->zap_loaded && !(ADRENO_FEATURE(adreno_dev, 1667: ADRENO_CPZ_RETENTION))) 1668: return a5xx_zap_shader_resume(device); 1669: 1670: return adreno_zap_shader_load(adreno_dev, a5xx_core->zap_name); 1671: } 1672: 1673: static int _me_init_ucode_workarounds(struct adreno_device *adreno_dev) 1674: { 1675: switch (ADRENO_GPUREV(adreno_dev)) { 1676: case ADRENO_REV_A510: 1677: return 0x00000001; /* Ucode workaround for token end syncs */ 1678: case ADRENO_REV_A505: 1679: case ADRENO_REV_A506: 1680: case ADRENO_REV_A530: 1681: /* 1682: * Ucode workarounds for token end syncs, 1683: * WFI after every direct-render 3D mode draw and 1684: * WFI after every 2D Mode 3 draw. 1685: */ 1686: return 0x0000000B; 1687: default: 1688: return 0x00000000; /* No ucode workarounds enabled */ 1689: } 1690: } 1691: 1692: /* 1693: * CP_INIT_MAX_CONTEXT bit tells if the multiple hardware contexts can 1694: * be used at once of if they should be serialized MATCH LINES: 1908, 1909, 1912, 1916, 1920 1896: a5xx_post_start(adreno_dev); 1897: 1898: return 0; 1899: } 1900: 1901: /* 1902: * a5xx_microcode_read() - Read microcode 1903: * @adreno_dev: Pointer to adreno device 1904: */ 1905: static int a5xx_microcode_read(struct adreno_device *adreno_dev) 1906: { 1907: int ret; 1908: struct adreno_firmware *pm4_fw = ADRENO_FW(adreno_dev, ADRENO_FW_PM4); 1909: struct adreno_firmware *pfp_fw = ADRENO_FW(adreno_dev, ADRENO_FW_PFP); 1910: const struct adreno_a5xx_core *a5xx_core = to_a5xx_core(adreno_dev); 1911: 1912: ret = adreno_get_firmware(adreno_dev, a5xx_core->pm4fw_name, pm4_fw); 1913: if (ret) 1914: return ret; 1915: 1916: ret = adreno_get_firmware(adreno_dev, a5xx_core->pfpfw_name, pfp_fw); 1917: if (ret) 1918: return ret; 1919: 1920: ret = _load_gpmu_firmware(adreno_dev); 1921: if (ret) 1922: return ret; 1923: 1924: _load_regfile(adreno_dev); 1925: 1926: return ret; 1927: } 1928: 1929: /* Register offset defines for A5XX, in order of enum adreno_regs */ 1930: static unsigned int a5xx_register_offsets[ADRENO_REG_REGISTER_MAX] = { 1931: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_BASE, A5XX_CP_RB_BASE), 1932: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_BASE_HI, A5XX_CP_RB_BASE_HI), 1933: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_RPTR, A5XX_CP_RB_RPTR), 1934: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_WPTR, A5XX_CP_RB_WPTR), 1935: ADRENO_REG_DEFINE(ADRENO_REG_CP_ME_CNTL, A5XX_CP_ME_CNTL), 1936: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_CNTL, A5XX_CP_RB_CNTL), 1937: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BASE, A5XX_CP_IB1_BASE), 1938: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BASE_HI, A5XX_CP_IB1_BASE_HI), 1939: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BUFSZ, A5XX_CP_IB1_BUFSZ), 1940: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BASE, A5XX_CP_IB2_BASE), 1941: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BASE_HI, A5XX_CP_IB2_BASE_HI), 1942: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BUFSZ, A5XX_CP_IB2_BUFSZ), 1943: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_STATUS, A5XX_RBBM_STATUS), 1944: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_STATUS3, A5XX_RBBM_STATUS3), MATCH LINES: 2274 2262: ADRENO_IRQ_CALLBACK(NULL), /* 19 - UNKNOWN_1 */ 2263: ADRENO_IRQ_CALLBACK(a5xx_cp_callback), /* 20 - CP_CACHE_FLUSH_TS */ 2264: /* 21 - UNUSED_2 */ 2265: ADRENO_IRQ_CALLBACK(NULL), 2266: ADRENO_IRQ_CALLBACK(a5xx_err_callback), /* 22 - RBBM_ATB_BUS_OVERFLOW */ 2267: /* 23 - MISC_HANG_DETECT */ 2268: ADRENO_IRQ_CALLBACK(adreno_hang_int_callback), 2269: ADRENO_IRQ_CALLBACK(a5xx_err_callback), /* 24 - UCHE_OOB_ACCESS */ 2270: ADRENO_IRQ_CALLBACK(a5xx_err_callback), /* 25 - UCHE_TRAP_INTR */ 2271: ADRENO_IRQ_CALLBACK(NULL), /* 26 - DEBBUS_INTR_0 */ 2272: ADRENO_IRQ_CALLBACK(NULL), /* 27 - DEBBUS_INTR_1 */ 2273: ADRENO_IRQ_CALLBACK(a5xx_err_callback), /* 28 - GPMU_VOLTAGE_DROOP */ 2274: ADRENO_IRQ_CALLBACK(a5xx_gpmu_int_callback), /* 29 - GPMU_FIRMWARE */ 2275: ADRENO_IRQ_CALLBACK(NULL), /* 30 - ISDB_CPU_IRQ */ 2276: ADRENO_IRQ_CALLBACK(NULL), /* 31 - ISDB_UNDER_DEBUG */ 2277: }; 2278: 2279: static irqreturn_t a5xx_irq_handler(struct adreno_device *adreno_dev) 2280: { 2281: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2282: irqreturn_t ret; 2283: u32 status; 2284: 2285: kgsl_regread(device, A5XX_RBBM_INT_0_STATUS, &status); 2286: 2287: /* 2288: * Clear all the interrupt bits except A5XX_INT_RBBM_AHB_ERROR. 2289: * The interrupt will stay asserted until it is cleared by the handler 2290: * so don't touch it yet to avoid a storm 2291: */ 2292: kgsl_regwrite(device, A5XX_RBBM_INT_CLEAR_CMD, 2293: status & ~A5XX_INT_RBBM_AHB_ERROR); 2294: 2295: /* Call the helper function for callbacks */ 2296: ret = adreno_irq_callbacks(adreno_dev, a5xx_irq_funcs, status); 2297: 2298: trace_kgsl_a5xx_irq_status(adreno_dev, status); --- FILE: \adreno_a5xx.h | HITS: 4 --- MATCH LINES: 31, 32, 34 19: unsigned int gpmu_tsens; 20: /** @max_power: Max possible power draw of a core */ 21: unsigned int max_power; 22: /** pm4fw_name: Name of the PM4 microcode file */ 23: const char *pm4fw_name; 24: /** pfpfw_name: Name of the PFP microcode file */ 25: const char *pfpfw_name; 26: /** gpmufw_name: Name of the GPMU microcode file */ 27: const char *gpmufw_name; 28: /** @regfw_name: Filename for the LM registers if applicable */ 29: const char *regfw_name; 30: /** 31: * @zap_name: Specifies the name of the CPZ zap file. This field is deprecated. 32: * Use the 'firmware-name' device tree property instead. 33: */ 34: const char *zap_name; 35: /** @hwcg: List of registers and values to write for HWCG */ 36: const struct kgsl_regmap_list *hwcg; 37: /** @hwcg_count: Number of registers in @hwcg */ 38: u32 hwcg_count; 39: /** @vbif: List of registers and values to write for VBIF */ 40: const struct kgsl_regmap_list *vbif; 41: /** @vbif_count: Number of registers in @vbif */ 42: u32 vbif_count; 43: }; 44: 45: #define A5XX_CP_CTXRECORD_MAGIC_REF 0x27C4BAFCUL 46: /* Size of each CP preemption record */ 47: #define A5XX_CP_CTXRECORD_SIZE_IN_BYTES 0x10000 48: /* Size of the preemption counter block (in bytes) */ 49: #define A5XX_CP_CTXRECORD_PREEMPTION_COUNTER_SIZE (16 * 4) 50: 51: /** 52: * struct a5xx_cp_preemption_record - CP context record for 53: * preemption. 54: * @magic: (00) Value at this offset must be equal to 55: * A5XX_CP_CTXRECORD_MAGIC_REF. 56: * @info: (04) Type of record. Written non-zero (usually) by CP. 57: * we must set to zero for all ringbuffers. 58: * @data: (08) DATA field in SET_RENDER_MODE or checkpoint packets. MATCH LINES: 190 178: 179: 180: #define AGC_LLM_ENABLED (1 << 16) 181: #define AGC_GPU_VERSION_MASK GENMASK(18, 17) 182: #define AGC_GPU_VERSION_SHIFT 17 183: #define AGC_BCL_DISABLED (1 << 24) 184: 185: 186: #define AGC_LEVEL_CONFIG (140/4) 187: 188: #define LM_DCVS_LIMIT 1 189: /* FW file tages */ 190: #define GPMU_FIRMWARE_ID 2 191: #define GPMU_SEQUENCE_ID 3 192: #define GPMU_INST_RAM_SIZE 0xFFF 193: 194: #define HEADER_MAJOR 1 195: #define HEADER_MINOR 2 196: #define HEADER_DATE 3 197: #define HEADER_TIME 4 198: #define HEADER_SEQUENCE 5 199: 200: #define MAX_HEADER_SIZE 10 201: 202: #define LM_SEQUENCE_ID 1 203: #define MAX_SEQUENCE_ID 3 204: 205: #define GPMU_ISENSE_SAVE (A5XX_GPMU_DATA_RAM_BASE + 200/4) 206: /* LM defaults */ 207: #define LM_DEFAULT_LIMIT 6000 208: #define A530_DEFAULT_LEAKAGE 0x004E001A 209: 210: /** 211: * to_a5xx_core - return the a5xx specific GPU core struct 212: * @adreno_dev: An Adreno GPU device handle 213: * 214: * Returns: --- FILE: \adreno_a5xx_snapshot.c | HITS: 2 --- MATCH LINES: 130, 153 118: #define A5XX_NUM_XIN_BLOCKS 4 119: 120: /* Width of A5XX_CP_DRAW_STATE_ADDR is 8 bits */ 121: #define A5XX_CP_DRAW_STATE_ADDR_WIDTH 8 122: 123: /* a5xx_snapshot_cp_pm4() - Dump PM4 data in snapshot */ 124: static size_t a5xx_snapshot_cp_pm4(struct kgsl_device *device, u8 *buf, 125: size_t remain, void *priv) 126: { 127: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 128: struct kgsl_snapshot_debug *header = (struct kgsl_snapshot_debug *)buf; 129: unsigned int *data = (unsigned int *)(buf + sizeof(*header)); 130: struct adreno_firmware *fw = ADRENO_FW(adreno_dev, ADRENO_FW_PM4); 131: size_t size = fw->size; 132: 133: if (remain < DEBUG_SECTION_SZ(size)) { 134: SNAPSHOT_ERR_NOMEM(device, "CP PM4 RAM DEBUG"); 135: return 0; 136: } 137: 138: header->type = SNAPSHOT_DEBUG_CP_PM4_RAM; 139: header->size = size; 140: 141: memcpy(data, fw->memdesc->hostptr, size * sizeof(uint32_t)); 142: 143: return DEBUG_SECTION_SZ(size); 144: } 145: 146: /* a5xx_snapshot_cp_pfp() - Dump the PFP data on snapshot */ 147: static size_t a5xx_snapshot_cp_pfp(struct kgsl_device *device, u8 *buf, 148: size_t remain, void *priv) 149: { 150: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 151: struct kgsl_snapshot_debug *header = (struct kgsl_snapshot_debug *)buf; 152: unsigned int *data = (unsigned int *)(buf + sizeof(*header)); 153: struct adreno_firmware *fw = ADRENO_FW(adreno_dev, ADRENO_FW_PFP); 154: int size = fw->size; 155: 156: if (remain < DEBUG_SECTION_SZ(size)) { 157: SNAPSHOT_ERR_NOMEM(device, "CP PFP RAM DEBUG"); 158: return 0; 159: } 160: 161: header->type = SNAPSHOT_DEBUG_CP_PFP_RAM; 162: header->size = size; 163: 164: memcpy(data, fw->memdesc->hostptr, size * sizeof(uint32_t)); 165: 166: return DEBUG_SECTION_SZ(size); 167: } 168: 169: /* a5xx_rbbm_debug_bus_read() - Read data from trace bus */ 170: static void a5xx_rbbm_debug_bus_read(struct kgsl_device *device, 171: unsigned int block_id, unsigned int index, unsigned int *val) 172: { 173: unsigned int reg; 174: 175: reg = (block_id << A5XX_RBBM_CFG_DBGBUS_SEL_PING_BLK_SEL_SHIFT) | 176: (index << A5XX_RBBM_CFG_DBGBUS_SEL_PING_INDEX_SHIFT); 177: kgsl_regwrite(device, A5XX_RBBM_CFG_DBGBUS_SEL_A, reg); --- FILE: \adreno_a6xx.c | HITS: 5 --- MATCH LINES: 1156 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)); MATCH LINES: 1207 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; MATCH LINES: 1338, 1341 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. MATCH LINES: 2525 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: 9 --- MATCH LINES: 18, 56, 57, 58, 59, 61, 62, 64 6: 7: #ifndef _ADRENO_A6XX_H_ 8: #define _ADRENO_A6XX_H_ 9: 10: #include 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 */ 72: u32 vbif_count; 73: /** @veto_fal10: veto status for fal10 feature */ 74: bool veto_fal10; 75: /** @pdc_in_aop: True if PDC programmed in AOP */ 76: bool pdc_in_aop; 77: /** @hang_detect_cycles: Hang detect counter timeout value */ 78: u32 hang_detect_cycles; 79: /** @protected_regs: Array of protected registers for the target */ 80: const struct adreno_protected_regs *protected_regs; 81: /** @disable_tseskip: True if TSESkip logic is disabled */ 82: bool disable_tseskip; 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; MATCH LINES: 292 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: * --- FILE: \adreno_a6xx_gmu.c | HITS: 19 --- MATCH LINES: 10 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 8: #include 9: #include 10: #include 11: #include 12: #include 13: #include 14: #include 15: #include 16: #include 17: #include 18: #include 19: #include 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) \ MATCH LINES: 792, 797, 799 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); MATCH LINES: 1023, 1025 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 MATCH LINES: 1563, 1567 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: MATCH LINES: 1681, 1684 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: MATCH LINES: 2604 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. MATCH LINES: 2666 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; MATCH LINES: 3111, 3120, 3121, 3122, 3123, 3129 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: 3119: /* 3120: * There is a possible deadlock scenario during kgsl firmware reading 3121: * (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl 3122: * device mutex is held and then firmware_request_nowarn is called for reading 3123: * firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock. 3124: * Whereas in case of devfreq update calls triggered by thermal/bcl or 3125: * devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then 3126: * tries to take kgsl device mutex as part of get_dev_status/target 3127: * calls. This results in deadlock when both thread are unable to acquire 3128: * the mutex held by other thread. Enable devfreq updates now as we are 3129: * done reading all firmware files. 3130: */ 3131: device->pwrscale.devfreq_enabled = true; 3132: 3133: device->pwrctrl.last_stat_updated = ktime_get(); 3134: 3135: set_bit(ADRENO_DEVICE_FIRST_BOOT_DONE, &adreno_dev->priv); 3136: 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); MATCH LINES: 3433 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: 5 --- MATCH LINES: 28, 41 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; 56: /** @pdc_cfg_base: Base address of PDC cfg registers */ 57: void __iomem *pdc_cfg_base; 58: /** @pdc_seq_base: Base address of PDC seq registers */ 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; MATCH LINES: 194, 197 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 MATCH LINES: 236 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: */ --- FILE: \adreno_a6xx_hfi.c | HITS: 2 --- MATCH LINES: 189 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: } 197: 198: /* Fill Table Header */ 199: tbl = mem_addr->hostptr; 200: tbl->qtbl_hdr.version = 0; 201: tbl->qtbl_hdr.size = sizeof(struct hfi_queue_table) >> 2; 202: tbl->qtbl_hdr.qhdr0_offset = sizeof(struct hfi_queue_table_header) >> 2; 203: tbl->qtbl_hdr.qhdr_size = sizeof(struct hfi_queue_header) >> 2; 204: tbl->qtbl_hdr.num_q = HFI_QUEUE_MAX; 205: tbl->qtbl_hdr.num_active_q = HFI_QUEUE_MAX; 206: 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); MATCH LINES: 690 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: /* --- FILE: \adreno_a6xx_hwsched.c | HITS: 6 --- MATCH LINES: 575, 584, 585, 586, 587, 593 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 585: * (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl 586: * device mutex is held and then firmware_request_nowarn is called for reading 587: * firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock. 588: * Whereas in case of devfreq update calls triggered by thermal/bcl or 589: * devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then 590: * tries to take kgsl device mutex as part of get_dev_status/target 591: * calls. This results in deadlock when both thread are unable to acquire 592: * the mutex held by other thread. Enable devfreq updates now as we are 593: * done reading all firmware files. 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); --- FILE: \adreno_a6xx_hwsched_hfi.c | HITS: 4 --- MATCH LINES: 884, 887 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; MATCH LINES: 1035, 1049 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); --- FILE: \adreno_a6xx_rgmu.c | HITS: 13 --- MATCH LINES: 10 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 8: #include 9: #include 10: #include 11: #include 12: #include 13: #include 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 */ MATCH LINES: 441 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 MATCH LINES: 564, 567, 569, 578, 589 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); MATCH LINES: 1002, 1024, 1025, 1026, 1027, 1033 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 --- FILE: \adreno_a6xx_rgmu.h | HITS: 3 --- MATCH LINES: 30, 33, 34 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 */ --- FILE: \adreno_gen7.c | HITS: 4 --- MATCH LINES: 1261 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 */ 1269: FOR_EACH_RINGBUFFER(adreno_dev, rb, i) { 1270: memset(rb->buffer_desc->hostptr, 0xaa, KGSL_RB_SIZE); 1271: kgsl_sharedmem_writel(device->scratch, 1272: SCRATCH_RB_OFFSET(rb->id, rptr), 0); 1273: kgsl_sharedmem_writel(device->scratch, 1274: SCRATCH_RB_OFFSET(rb->id, bv_rptr), 0); 1275: 1276: rb->wptr = 0; 1277: rb->_wptr = 0; 1278: rb->wptr_preempt_end = UINT_MAX; 1279: } 1280: 1281: gen7_preemption_start(adreno_dev); 1282: 1283: /* Set up the current ringbuffer */ 1284: rb = ADRENO_CURRENT_RINGBUFFER(adreno_dev); 1285: MATCH LINES: 1317 1305: kgsl_regwrite(device, GEN7_CP_SQE_INSTR_BASE_LO, 1306: lower_32_bits(fw->memdesc->gpuaddr)); 1307: kgsl_regwrite(device, GEN7_CP_SQE_INSTR_BASE_HI, 1308: upper_32_bits(fw->memdesc->gpuaddr)); 1309: 1310: /* Clear the SQE_HALT to start the CP engine */ 1311: kgsl_regwrite(device, GEN7_CP_SQE_CNTL, 1); 1312: 1313: ret = gen7_send_cp_init(adreno_dev, rb); 1314: if (ret) 1315: return ret; 1316: 1317: ret = adreno_zap_shader_load(adreno_dev, gen7_core->zap_name); 1318: if (ret) 1319: return ret; 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; MATCH LINES: 1374, 1377 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 1383: #define CP_INT_CPHWFAULT 2 1384: #define CP_INT_REGISTERPROTECTION 4 1385: #define CP_INT_VSDPARITYERROR 6 1386: #define CP_INT_ILLEGALINSTRUCTION 7 1387: #define CP_INT_OPCODEERRORLPAC 8 1388: #define CP_INT_UCODEERRORLPAC 9 1389: #define CP_INT_CPHWFAULTLPAC 10 1390: #define CP_INT_REGISTERPROTECTIONLPAC 11 1391: #define CP_INT_ILLEGALINSTRUCTIONLPAC 12 1392: #define CP_INT_OPCODEERRORBV 13 1393: #define CP_INT_UCODEERRORBV 14 1394: #define CP_INT_CPHWFAULTBV 15 1395: #define CP_INT_REGISTERPROTECTIONBV 16 1396: #define CP_INT_ILLEGALINSTRUCTIONBV 17 1397: 1398: static void gen7_cp_hw_err_callback(struct adreno_device *adreno_dev, int bit) 1399: { 1400: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1401: unsigned int status1, status2; --- FILE: \adreno_gen7.h | HITS: 12 --- MATCH LINES: 86, 88, 89, 92, 93, 94, 95, 97, 98, 100 74: * @noaccess: 1 if the register should not be accessible from 75: * userspace, 0 if it can be read (but not written) 76: */ 77: u32 noaccess; 78: }; 79: 80: /** 81: * struct adreno_gen7_core - gen7 specific GPU core definitions 82: */ 83: struct adreno_gen7_core { 84: /** @base: Container for the generic GPU definitions */ 85: struct adreno_gpu_core base; 86: /** @gmu_fw_version: Minimum firmware version required to support this core */ 87: u32 gmu_fw_version; 88: /** @sqefw_name: Name of the SQE microcode file */ 89: const char *sqefw_name; 90: /** @aqefw_name: Name of the AQE microcode file */ 91: const char *aqefw_name; 92: /** @gmufw_name: Name of the GMU firmware file */ 93: const char *gmufw_name; 94: /** @gmufw_name: Name of the backup GMU firmware file */ 95: const char *gmufw_bak_name; 96: /** 97: * @zap_name: Specifies the name of the CPZ zap file. This field is deprecated. 98: * Use the 'firmware-name' device tree property instead. 99: */ 100: const char *zap_name; 101: /** @hwcg: List of registers and values to write for HWCG */ 102: const struct kgsl_regmap_list *hwcg; 103: /** @hwcg_count: Number of registers in @hwcg */ 104: u32 hwcg_count; 105: /** @ao_hwcg: List of registers and values to write for HWCG in AO block */ 106: const struct kgsl_regmap_list *ao_hwcg; 107: /** @ao_hwcg_count: Number of registers in @ao_hwcg */ 108: u32 ao_hwcg_count; 109: /** @gbif: List of registers and values to write for GBIF */ 110: const struct kgsl_regmap_list *gbif; 111: /** @gbif_count: Number of registers in @gbif */ 112: u32 gbif_count; 113: /** @hang_detect_cycles: Hang detect counter timeout value */ 114: u32 hang_detect_cycles; 115: /** @protected_regs: Array of protected registers for the target */ 116: const struct gen7_protected_regs *protected_regs; 117: /** @ctxt_record_size: Size of the preemption record in bytes */ 118: u64 ctxt_record_size; 119: /** @gen7_snapshot_block_list: Device-specific blocks dumped in the snapshot */ 120: const struct gen7_snapshot_block_list *gen7_snapshot_block_list; 121: /** @gmu_hub_clk_freq: Gmu hub interface clock frequency */ 122: u64 gmu_hub_clk_freq; 123: /** 124: * @bcl_data: bit 0 contains response type for bcl alarms and bits 1:21 controls sid vals MATCH LINES: 148 136: */ 137: u32 acv_perfmode_ddr_freq; 138: /** @acv_perfmode_vote: ACV vote for GPU perfmode */ 139: u32 acv_perfmode_vote; 140: /** @rt_bus_hint: IB level hint for real time clients i.e. RB-0 */ 141: const u32 rt_bus_hint; 142: /** @fast_bus_hint: Whether or not to increase IB vote on high ddr stall */ 143: bool fast_bus_hint; 144: /** @noc_timeout_us: GPU config NOC port timeout in usec */ 145: u32 noc_timeout_us; 146: /** 147: * @gmu_chipid: If non-zero, the exact value programmed into 148: * GEN7_GMU_GENERAL_10 to tell the GMU firmware which chip it is 149: * running on. 150: */ 151: u32 gmu_chipid; 152: }; 153: 154: /** 155: * struct gen7_cp_preemption_record - CP context record for 156: * preemption. 157: * @magic: (00) Value at this offset must be equal to 158: * GEN7_CP_CTXRECORD_MAGIC_REF. 159: * @info: (04) Type of record. Written non-zero (usually) by CP. 160: * we must set to zero for all ringbuffers. 161: * @errno: (08) Error code. Initialize this to GEN7_CP_CTXRECORD_ERROR_NONE. 162: * CP will update to another value if a preemption error occurs. 163: * @data: (12) DATA field in YIELD and SET_MARKER packets. 164: * Written by CP when switching out. Not used on switch-in. Initialized to 0. 165: * @cntl: (16) RB_CNTL, saved and restored by CP. We must initialize this. 166: * @rptr: (20) RB_RPTR, saved and restored by CP. We must initialize this. 167: * @wptr: (24) RB_WPTR, saved and restored by CP. We must initialize this. 168: * @_pad28: (28) Reserved/padding. 169: * @rptr_addr: (32) RB_RPTR_ADDR_LO|HI saved and restored. We must initialize. 170: * rbase: (40) RB_BASE_LO|HI saved and restored. 171: * counter: (48) Pointer to preemption counter. 172: * @bv_rptr_addr: (56) BV_RB_RPTR_ADDR_LO|HI save and restored. We must initialize. MATCH LINES: 348 336: * 337: * This function does gen7 specific ringbuffer setup and 338: * attempts to submit CP INIT and bring GPU out of secure mode 339: * 340: * Return: Zero on success and negative error on failure 341: */ 342: int gen7_rb_start(struct adreno_device *adreno_dev); 343: 344: /** 345: * gen7_microcode_read - Get the cp microcode from the filesystem 346: * @adreno_dev: An Adreno GPU handle 347: * 348: * This function gets the firmware from filesystem and sets up 349: * the micorocode global buffer 350: * 351: * Return: Zero on success and negative error on failure 352: */ 353: int gen7_microcode_read(struct adreno_device *adreno_dev); 354: 355: /** 356: * gen7_probe_common - Probe common gen7 resources 357: * @pdev: Pointer to the platform device 358: * @adreno_dev: Pointer to the adreno device 359: * @chipid: Chipid of the target 360: * @gpucore: Pointer to the gpucore strucure 361: * 362: * This function sets up the gen7 resources common across all 363: * gen7 targets 364: */ 365: int gen7_probe_common(struct platform_device *pdev, 366: struct adreno_device *adreno_dev, u32 chipid, 367: const struct adreno_gpu_core *gpucore); 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 --- FILE: \adreno_gen7_gmu.c | HITS: 19 --- MATCH LINES: 10 1: // SPDX-License-Identifier: GPL-2.0-only 2: /* 3: * Copyright (c) 2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #include 8: #include 9: #include 10: #include 11: #include 12: #include 13: #include 14: #include 15: #include 16: #include 17: #include 18: 19: #include "adreno.h" 20: #include "adreno_gen7.h" 21: #include "adreno_trace.h" 22: #include "kgsl_bus.h" 23: #include "kgsl_device.h" 24: #include "kgsl_gmu_core.h" 25: #include "kgsl_trace.h" 26: #include "kgsl_util.h" 27: 28: static struct gmu_vma_entry gen7_gmu_vma[] = { 29: [GMU_ITCM] = { 30: .start = 0x00000000, 31: .size = SZ_16K, 32: }, 33: [GMU_CACHE] = { 34: .start = SZ_16K, MATCH LINES: 525 513: return -EINVAL; 514: } 515: 516: if (id == GMU_ITCM) { 517: load_tcm(adreno_dev, fw, 518: GEN7_GMU_CM3_ITCM_START, 519: device->gmu_core.vma[GMU_ITCM].start, blk); 520: } else if (id == GMU_DTCM) { 521: load_tcm(adreno_dev, fw, 522: GEN7_GMU_CM3_DTCM_START, 523: device->gmu_core.vma[GMU_DTCM].start, blk); 524: } else { 525: /* The firmware block for memory needs to be copied on first boot only */ 526: if (!test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags)) { 527: struct kgsl_memdesc *md = 528: gmu_core_find_memdesc(device, blk->addr, blk->size); 529: 530: if (!md) { 531: dev_err(GMU_PDEV_DEV(device), 532: "No backing memory for GMU FW block addr:0x%x size:0x%x\n", 533: blk->addr, blk->size); 534: return -EINVAL; 535: } 536: 537: memcpy(md->hostptr + (blk->addr - md->gmuaddr), fw, 538: blk->size); 539: } 540: } 541: 542: fw += blk->size; 543: } 544: 545: /* Proceed only after the FW is written */ 546: wmb(); 547: return 0; 548: } 549: MATCH LINES: 1022, 1026, 1027, 1033, 1036, 1039, 1040, 1041 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) 1034: return -EINVAL; 1035: 1036: ret = adreno_request_firmware(&gmu->fw_image, gmufw_name, 1037: gmu_pdev_dev, false); 1038: if (ret) { 1039: if (gen7_core->gmufw_bak_name) { 1040: gmufw_name = gen7_core->gmufw_bak_name; 1041: ret = adreno_request_firmware(&gmu->fw_image, gmufw_name, 1042: gmu_pdev_dev, true); 1043: } 1044: 1045: if (ret) 1046: return ret; 1047: } 1048: } 1049: 1050: /* 1051: * Zero payload fw blocks contain metadata and are 1052: * guaranteed to precede fw load data. Parse the 1053: * metadata blocks. 1054: */ 1055: while (offset < gmu->fw_image->size) { 1056: blk = (struct gmu_block_header *)&gmu->fw_image->data[offset]; 1057: 1058: if (offset + sizeof(*blk) > gmu->fw_image->size) { 1059: dev_err(gmu_pdev_dev, "Invalid FW Block\n"); 1060: return -EINVAL; 1061: } 1062: 1063: /* Done with zero length blocks so return */ 1064: if (blk->size) 1065: break; MATCH LINES: 1977 1965: 1966: if (!ADRENO_FEATURE(adreno_dev, ADRENO_ACD)) 1967: return 0; 1968: 1969: cmd->hdr = CREATE_MSG_HDR(H2F_MSG_ACD_TBL, HFI_MSG_CMD); 1970: 1971: cmd->version = 1; 1972: cmd->stride = 1; 1973: cmd->enable_by_level = 0; 1974: 1975: /* 1976: * Iterate through each gpu power level and generate a mask for GMU 1977: * firmware for ACD enabled levels and store the corresponding control 1978: * register configurations to the acd_table structure. 1979: */ 1980: for (i = 0; i < pwr->num_pwrlevels; i++) { 1981: if (pwrlevel->acd_level) { 1982: cmd->enable_by_level |= (1 << (i + 1)); 1983: cmd->data[cmd_idx++] = pwrlevel->acd_level; 1984: } 1985: pwrlevel--; 1986: } 1987: 1988: if (!cmd->enable_by_level) 1989: return 0; 1990: 1991: cmd->num_levels = cmd_idx; 1992: 1993: ret = gen7_gmu_aop_messaging_init(adreno_dev, gmu); 1994: 1995: if (ret) 1996: dev_err_probe(GMU_PDEV_DEV(device), ret, 1997: "AOP messaging init failed\n"); 1998: 1999: /* 2000: * Only fail probe for -EPROBE_DEFER; ignore other errors to avoid 2001: * failing probe if ACD init fails. MATCH LINES: 2042 2030: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 2031: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 2032: 2033: if (gmu->qmp) 2034: qmp_put(gmu->qmp); 2035: 2036: if (gmu->mailbox.channel) 2037: mbox_free_channel(gmu->mailbox.channel); 2038: 2039: adreno_dev->acd_enabled = false; 2040: 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); MATCH LINES: 2477, 2478, 2486, 2487, 2488, 2489, 2495 2465: 2466: adreno_dev->cooperative_reset = ADRENO_FEATURE(adreno_dev, 2467: ADRENO_COOP_RESET); 2468: 2469: adreno_create_profile_buffer(adreno_dev); 2470: 2471: set_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags); 2472: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 2473: 2474: /* 2475: * BCL needs respective Central Broadcast register to 2476: * be programed from TZ. For kernel version prior to 6.1, this 2477: * programing happens only when zap shader firmware load is successful. 2478: * Zap firmware load can fail in boot up path hence enable BCL only 2479: * after we successfully complete first boot to ensure that Central 2480: * Broadcast register was programed before enabling BCL. 2481: */ 2482: if (ADRENO_FEATURE(adreno_dev, ADRENO_BCL)) 2483: adreno_dev->bcl_enabled = true; 2484: 2485: /* 2486: * There is a possible deadlock scenario during kgsl firmware reading 2487: * (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl 2488: * device mutex is held and then firmware_request_nowarn is called for reading 2489: * firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock. 2490: * Whereas in case of devfreq update calls triggered by thermal/bcl or 2491: * devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then 2492: * tries to take kgsl device mutex as part of get_dev_status/target 2493: * calls. This results in deadlock when both thread are unable to acquire 2494: * the mutex held by other thread. Enable devfreq updates now as we are 2495: * done reading all firmware files. 2496: */ 2497: device->pwrscale.devfreq_enabled = true; 2498: 2499: device->pwrctrl.last_stat_updated = ktime_get(); 2500: 2501: set_bit(ADRENO_DEVICE_FIRST_BOOT_DONE, &adreno_dev->priv); 2502: 2503: kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE); 2504: 2505: return 0; 2506: } 2507: 2508: static bool gen7_irq_pending(struct adreno_device *adreno_dev) 2509: { 2510: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2511: u32 status; 2512: 2513: kgsl_regread(device, GEN7_RBBM_INT_0_STATUS, &status); 2514: 2515: /* Return busy if a interrupt is pending */ 2516: return ((status & adreno_dev->irq_mask) || 2517: atomic_read(&adreno_dev->pending_irq_refcnt)); 2518: } 2519: --- FILE: \adreno_gen7_gmu.h | HITS: 5 --- MATCH LINES: 35, 50 23: * struct gen7_gmu_device - GMU device structure 24: * @ver: GMU Version information 25: * @irq: GMU interrupt number 26: * @fw_image: GMU FW image 27: * @gmu_log: gmu event log memory 28: * @hfi: HFI controller 29: * @idle_level: Minimal GPU idle power level 30: * @mailbox: Messages to AOP for ACD enable/disable go through this 31: * @log_wptr_retention: Store the log wptr offset on slumber 32: */ 33: struct gen7_gmu_device { 34: int irq; 35: const struct firmware *fw_image; 36: struct kgsl_memdesc *gmu_log; 37: /** @gmu_init_scratch: Memory to store the initial HFI messages */ 38: struct kgsl_memdesc *gmu_init_scratch; 39: /** @gpu_boot_scratch: Memory to store the bootup HFI messages */ 40: struct kgsl_memdesc *gpu_boot_scratch; 41: struct gen7_hfi hfi; 42: unsigned int idle_level; 43: /** @qmp: Pointer to qmp struct used for AOP messages*/ 44: struct qmp *qmp; 45: struct kgsl_mailbox mailbox; 46: unsigned int log_wptr_retention; 47: /** @cm3_fault: whether gmu received a cm3 fault interrupt */ 48: atomic_t cm3_fault; 49: /** 50: * @itcm_shadow: Copy of the itcm block in firmware binary used for 51: * snapshot 52: */ 53: void *itcm_shadow; 54: /** @flags: Internal gmu flags */ 55: unsigned long flags; 56: /** @rscc_virt: Pointer where RSCC block is mapped */ 57: void __iomem *rscc_virt; 58: /** @log_stream_enable: GMU log streaming enable. Disabled by default */ 59: bool log_stream_enable; 60: /** @log_group_mask: Allows overriding default GMU log group mask */ 61: u32 log_group_mask; 62: struct kobject log_kobj; 63: /** @pdc_cfg_base: Base address of PDC cfg registers */ 64: void __iomem *pdc_cfg_base; 65: /** @num_oob_perfcntr: Number of active oob_perfcntr requests */ 66: u32 num_oob_perfcntr; 67: /** @acd_debug_val: DVM value to calibrate ACD for a level */ 68: u32 acd_debug_val; 69: /** @stats_enable: GMU stats feature enable */ 70: bool stats_enable; 71: /** @stats_mask: GMU performance countables to enable */ 72: u32 stats_mask; 73: /** @stats_interval: GMU performance counters sampling interval */ 74: u32 stats_interval; MATCH LINES: 192, 195 180: int gen7_gmu_memory_init(struct adreno_device *adreno_dev); 181: 182: /** 183: * gen7_gmu_aop_send_acd_state - Enable or disable acd feature in aop 184: * @gmu: Pointer to the gen7 gmu device 185: * @flag: Boolean to enable or disable acd in aop 186: * 187: * This function enables or disables gpu acd feature using mailbox or qmp 188: */ 189: void gen7_gmu_aop_send_acd_state(struct gen7_gmu_device *gmu, bool flag); 190: 191: /** 192: * gen7_gmu_load_fw - Load gmu firmware 193: * @adreno_dev: Pointer to the adreno device 194: * 195: * Loads the gmu firmware binary into TCMs and memory 196: * 197: * Return: 0 on success or negative error on failure 198: */ 199: int gen7_gmu_load_fw(struct adreno_device *adreno_dev); 200: 201: /** 202: * gen7_gmu_device_start - Bring gmu out of reset 203: * @adreno_dev: Pointer to the adreno device 204: * 205: * Return: 0 on success or negative error on failure 206: */ 207: int gen7_gmu_device_start(struct adreno_device *adreno_dev); 208: 209: /** 210: * gen7_gmu_hfi_start - Indicate hfi start to gmu 211: * @device: Pointer to the kgsl device 212: * 213: * Return: 0 on success or negative error on failure 214: */ 215: int gen7_gmu_hfi_start(struct adreno_device *adreno_dev); 216: 217: /** 218: * gen7_gmu_itcm_shadow - Create itcm shadow copy for snapshot 219: * @adreno_dev: Pointer to the adreno device MATCH LINES: 234 222: */ 223: int gen7_gmu_itcm_shadow(struct adreno_device *adreno_dev); 224: 225: /** 226: * gen7_gmu_register_config - gmu register configuration 227: * @adreno_dev: Pointer to the adreno device 228: * 229: * Program gmu regsiters based on features 230: */ 231: void gen7_gmu_register_config(struct adreno_device *adreno_dev); 232: 233: /** 234: * gen7_gmu_version_info - Get gmu firmware version 235: * @adreno_dev: Pointer to the adreno device 236: * 237: * Return: 0 on success or negative error on failure 238: */ 239: int gen7_gmu_version_info(struct adreno_device *adreno_dev); 240: 241: /** 242: * gen7_gmu_irq_enable - Enable gmu interrupts 243: * @adreno_dev: Pointer to the adreno device 244: */ 245: void gen7_gmu_irq_enable(struct adreno_device *adreno_dev); 246: 247: /** 248: * gen7_gmu_irq_disable - Disaable gmu interrupts 249: * @adreno_dev: Pointer to the adreno device 250: */ 251: void gen7_gmu_irq_disable(struct adreno_device *adreno_dev); 252: 253: /** 254: * gen7_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 --- FILE: \adreno_gen7_hfi.c | HITS: 1 --- MATCH LINES: 280 268: { 269: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 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); --- FILE: \adreno_gen7_hwsched.c | HITS: 9 --- MATCH LINES: 454 442: return ret; 443: 444: error: 445: gen7_gmu_irq_disable(adreno_dev); 446: gen7_hwsched_hfi_stop(adreno_dev); 447: gen7_hwsched_gmu_suspend(adreno_dev, false); 448: 449: return ret; 450: } 451: 452: static void gen7_hwsched_init_ucode_regs(struct adreno_device *adreno_dev) 453: { 454: struct adreno_firmware *fw = ADRENO_FW(adreno_dev, ADRENO_FW_SQE); 455: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 456: 457: /* Program the ucode base for CP */ 458: kgsl_regwrite(device, GEN7_CP_SQE_INSTR_BASE_LO, 459: lower_32_bits(fw->memdesc->gpuaddr)); 460: kgsl_regwrite(device, GEN7_CP_SQE_INSTR_BASE_HI, 461: upper_32_bits(fw->memdesc->gpuaddr)); 462: 463: if (ADRENO_FEATURE(adreno_dev, ADRENO_AQE)) { 464: fw = ADRENO_FW(adreno_dev, ADRENO_FW_AQE); 465: 466: /* Program the ucode base for AQE0 (BV coprocessor) */ 467: kgsl_regwrite(device, GEN7_CP_AQE_INSTR_BASE_LO_0, 468: lower_32_bits(fw->memdesc->gpuaddr)); 469: kgsl_regwrite(device, GEN7_CP_AQE_INSTR_BASE_HI_0, 470: upper_32_bits(fw->memdesc->gpuaddr)); 471: 472: /* Program the ucode base for AQE1 (LPAC coprocessor) */ 473: if (adreno_dev->lpac_enabled) { 474: kgsl_regwrite(device, GEN7_CP_AQE_INSTR_BASE_LO_1, 475: lower_32_bits(fw->memdesc->gpuaddr)); 476: kgsl_regwrite(device, GEN7_CP_AQE_INSTR_BASE_HI_1, 477: upper_32_bits(fw->memdesc->gpuaddr)); 478: } MATCH LINES: 702, 708 690: if (IS_ENABLED(CONFIG_QCOM_KGSL_HIBERNATION)) 691: adreno_dev->bcl_enabled = bcl_state; 692: 693: device->pwrctrl.last_stat_updated = ktime_get(); 694: 695: kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE); 696: 697: return ret; 698: } 699: 700: static int gen7_aqe_microcode_read(struct adreno_device *adreno_dev) 701: { 702: struct adreno_firmware *aqe_fw = ADRENO_FW(adreno_dev, ADRENO_FW_AQE); 703: const struct adreno_gen7_core *gen7_core = to_gen7_core(adreno_dev); 704: 705: if (!ADRENO_FEATURE(adreno_dev, ADRENO_AQE)) 706: return 0; 707: 708: return adreno_get_firmware(adreno_dev, gen7_core->aqefw_name, aqe_fw); 709: } 710: 711: static int gen7_hwsched_first_boot(struct adreno_device *adreno_dev) 712: { 713: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 714: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 715: int ret; 716: 717: if (test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags)) 718: return gen7_hwsched_boot(adreno_dev); 719: 720: adreno_hwsched_start(adreno_dev); 721: 722: ret = gen7_microcode_read(adreno_dev); 723: if (ret) 724: return ret; 725: 726: ret = gen7_aqe_microcode_read(adreno_dev); 727: if (ret) 728: return ret; 729: 730: ret = gen7_init(adreno_dev); 731: if (ret) 732: return ret; MATCH LINES: 759, 768, 769, 770, 771, 777 747: 748: adreno_get_bus_counters(adreno_dev); 749: 750: adreno_dev->cooperative_reset = ADRENO_FEATURE(adreno_dev, 751: ADRENO_COOP_RESET); 752: 753: set_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags); 754: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 755: 756: /* 757: * BCL needs respective Central Broadcast register to 758: * be programed from TZ. This programing happens only 759: * when zap shader firmware load is successful. Zap firmware 760: * load can fail in boot up path hence enable BCL only after we 761: * successfully complete first boot to ensure that Central 762: * Broadcast register was programed before enabling BCL. 763: */ 764: if (ADRENO_FEATURE(adreno_dev, ADRENO_BCL)) 765: adreno_dev->bcl_enabled = true; 766: 767: /* 768: * There is a possible deadlock scenario during kgsl firmware reading 769: * (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl 770: * device mutex is held and then firmware_request_nowarn is called for reading 771: * firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock. 772: * Whereas in case of devfreq update calls triggered by thermal/bcl or 773: * devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then 774: * tries to take kgsl device mutex as part of get_dev_status/target 775: * calls. This results in deadlock when both thread are unable to acquire 776: * the mutex held by other thread. Enable devfreq updates now as we are 777: * done reading all firmware files. 778: */ 779: device->pwrscale.devfreq_enabled = true; 780: 781: device->pwrctrl.last_stat_updated = ktime_get(); 782: 783: set_bit(ADRENO_DEVICE_FIRST_BOOT_DONE, &adreno_dev->priv); 784: 785: kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE); 786: 787: return 0; 788: } 789: 790: /** 791: * drain_ctx_hw_fences_cpu - Force trigger the hardware fences that 792: * were not sent to TxQueue by the GMU 793: */ 794: static void drain_ctx_hw_fences_cpu(struct adreno_device *adreno_dev, 795: struct adreno_context *drawctxt) 796: { 797: struct adreno_hw_fence_entry *entry, *tmp; 798: 799: spin_lock(&drawctxt->lock); 800: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_inflight_list, node) { 801: kgsl_hw_fence_trigger_cpu(KGSL_DEVICE(adreno_dev), entry->kfence); --- FILE: \adreno_gen7_hwsched_hfi.c | HITS: 3 --- MATCH LINES: 1737, 1740 1725: * Bits [23:0] contains the countables mask 1726: * Bits [31:24] is the sampling interval 1727: */ 1728: data = FIELD_PREP(GENMASK(23, 0), gmu->stats_mask) | 1729: FIELD_PREP(GENMASK(31, 24), gmu->stats_interval); 1730: 1731: return gen7_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_GMU_STATS, 1, data); 1732: } 1733: 1734: static int gen7_hfi_send_perfcounter_feature_ctrl(struct adreno_device *adreno_dev) 1735: { 1736: /* 1737: * Perfcounter retention is disabled by default in GMU firmware. 1738: * In case perfcounter retention behaviour is overwritten by sysfs 1739: * setting dynmaically, send this HFI feature with 'enable = 0' to 1740: * disable this feature in GMU firmware. 1741: */ 1742: if (adreno_dev->perfcounter) 1743: return gen7_hfi_send_feature_ctrl(adreno_dev, 1744: HFI_FEATURE_PERF_NORETAIN, 0, 0); 1745: 1746: return 0; 1747: } 1748: 1749: u32 gen7_hwsched_hfi_get_value(struct adreno_device *adreno_dev, u32 prop) 1750: { 1751: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)); 1752: struct hfi_get_value_cmd cmd; 1753: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1754: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev); 1755: struct pending_cmd pending_ack; 1756: int rc; 1757: u32 seqnum; 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); MATCH LINES: 2357 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: 2361: if (!adreno_dev->zap_loaded) 2362: kgsl_regwrite(KGSL_DEVICE(adreno_dev), 2363: GEN7_RBBM_SECVID_TRUST_CNTL, 0x0); 2364: else 2365: ret = send_switch_to_unsecure(adreno_dev); 2366: 2367: return ret; 2368: } 2369: 2370: int gen7_hwsched_lpac_cp_init(struct adreno_device *adreno_dev) 2371: { 2372: u32 cmds[GEN7_CP_INIT_DWORDS + 1]; 2373: 2374: if (!adreno_dev->lpac_enabled) 2375: return 0; 2376: 2377: cmds[0] = CREATE_MSG_HDR(H2F_MSG_ISSUE_LPAC_CMD_RAW, HFI_MSG_CMD); 2378: 2379: gen7_cp_init_cmds(adreno_dev, &cmds[1]); 2380: 2381: return submit_lpac_raw_cmds(adreno_dev, cmds, sizeof(cmds), --- FILE: \adreno_gen8.c | HITS: 4 --- MATCH LINES: 2457 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 */ 2465: FOR_EACH_RINGBUFFER(adreno_dev, rb, i) { 2466: memset(rb->buffer_desc->hostptr, 0xaa, KGSL_RB_SIZE); 2467: kgsl_sharedmem_writel(device->scratch, 2468: SCRATCH_RB_OFFSET(rb->id, rptr), 0); 2469: kgsl_sharedmem_writel(device->scratch, 2470: SCRATCH_RB_OFFSET(rb->id, bv_rptr), 0); 2471: 2472: rb->wptr = 0; 2473: rb->_wptr = 0; 2474: rb->wptr_preempt_end = UINT_MAX; 2475: } 2476: 2477: gen8_preemption_start(adreno_dev); 2478: 2479: /* Set up the current ringbuffer */ 2480: rb = ADRENO_CURRENT_RINGBUFFER(adreno_dev); 2481: MATCH LINES: 2510 2498: kgsl_regwrite(device, GEN8_CP_SQE_INSTR_BASE_LO, 2499: lower_32_bits(fw->memdesc->gpuaddr)); 2500: kgsl_regwrite(device, GEN8_CP_SQE_INSTR_BASE_HI, 2501: upper_32_bits(fw->memdesc->gpuaddr)); 2502: 2503: /* Clear the SQE_HALT to start the CP engine */ 2504: kgsl_regwrite(device, GEN8_CP_SQE_CNTL, 1); 2505: 2506: ret = gen8_send_cp_init(adreno_dev, rb); 2507: if (ret) 2508: return ret; 2509: 2510: ret = adreno_zap_shader_load(adreno_dev, gen8_core->zap_name); 2511: if (ret) 2512: return ret; 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; MATCH LINES: 2590, 2593 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); 2599: u32 hw_status; 2600: u32 pipe_id = PIPE_NONE; 2601: const char * const table[] = { 2602: [CP_HW_RBFAULT] = "RBFAULT", 2603: [CP_HW_IB1FAULT] = "IB1FAULT", 2604: [CP_HW_IB2FAULT] = "IB2FAULT", 2605: [CP_HW_SDSFAULT] = "SDSFAULT", 2606: [CP_HW_MRBFAULT] = "MRGFAULT", 2607: [CP_HW_VSDFAULT] = "VSDFAULT", 2608: [CP_HW_SQEREADBRUSTOVF] = "SQEREADBRUSTOVF", 2609: [CP_HW_EVENTENGINEOVF] = "EVENTENGINEOVF", 2610: [CP_HW_UCODEERROR] = "UCODEERROR", 2611: }; 2612: 2613: switch (status) { 2614: case BIT(GEN8_CP_GLOBAL_INT_HWFAULTBR): 2615: pipe_id = PIPE_BR; 2616: break; 2617: case BIT(GEN8_CP_GLOBAL_INT_HWFAULTBV): --- FILE: \adreno_gen8.h | HITS: 9 --- MATCH LINES: 165, 167, 168, 171, 172, 174, 175, 177 153: /** @therm: Config for GPU thermal mitigation features */ 154: struct hfi_therm_profile_ctrl *therm; 155: /** @tsens_en_cfg: Config for GPU thermal mitigation features */ 156: const struct therm_tsens_en_cfg *tsens_en_cfg; 157: }; 158: 159: /** 160: * struct adreno_gen8_core - gen8 specific GPU core definitions 161: */ 162: struct adreno_gen8_core { 163: /** @base: Container for the generic GPU definitions */ 164: struct adreno_gpu_core base; 165: /** @gmu_fw_version: Minimum firmware version required to support this core */ 166: u32 gmu_fw_version; 167: /** @sqefw_name: Name of the SQE microcode file */ 168: const char *sqefw_name; 169: /** @aqefw_name: Name of the AQE microcode file */ 170: const char *aqefw_name; 171: /** @gmufw_name: Name of the GMU firmware file */ 172: const char *gmufw_name; 173: /** 174: * @zap_name: Specifies the name of the CPZ zap file. This field is deprecated. 175: * Use the 'firmware-name' device tree property instead. 176: */ 177: const char *zap_name; 178: /** @ao_hwcg: List of registers and values to write for HWCG in AO block */ 179: const struct kgsl_regmap_list *ao_hwcg; 180: /** @ao_hwcg_count: Number of registers in @ao_hwcg */ 181: u32 ao_hwcg_count; 182: /** @gbif: List of registers and values to write for GBIF */ 183: const struct kgsl_regmap_list *gbif; 184: /** @gbif_count: Number of registers in @gbif */ 185: u32 gbif_count; 186: /** @hang_detect_cycles: Hang detect counter timeout value */ 187: u32 hang_detect_cycles; 188: /** @protected_regs: Array of protected registers for the target */ 189: const struct gen8_protected_regs *protected_regs; 190: /** @nonctxt_regs: Array of non context register list */ 191: const struct gen8_nonctxt_regs *nonctxt_regs; 192: /** @ctxt_record_size: Size of the preemption record in bytes */ 193: u64 ctxt_record_size; 194: /** @gen8_snapshot_block_list: Device-specific blocks dumped in the snapshot */ 195: const struct gen8_snapshot_block_list *gen8_snapshot_block_list; 196: /** @gmu_hub_clk_freq: Gmu hub interface clock frequency */ 197: u64 gmu_hub_clk_freq; 198: /** 199: * @bcl_data: bit 0 contains response type for bcl alarms and bits 1:21 controls sid vals 200: * to configure throttle levels for bcl alarm levels 0-2. If sid vals are not set, 201: * gmu fw sets default throttle levels. MATCH LINES: 455 443: * 444: * This function does gen8 specific ringbuffer setup and 445: * attempts to submit CP INIT and bring GPU out of secure mode 446: * 447: * Return: Zero on success and negative error on failure 448: */ 449: int gen8_rb_start(struct adreno_device *adreno_dev); 450: 451: /** 452: * gen8_microcode_read - Get the cp microcode from the filesystem 453: * @adreno_dev: An Adreno GPU handle 454: * 455: * This function gets the firmware from filesystem and sets up 456: * the micorocode global buffer 457: * 458: * Return: Zero on success and negative error on failure 459: */ 460: int gen8_microcode_read(struct adreno_device *adreno_dev); 461: 462: /** 463: * gen8_probe_common - Probe common gen8 resources 464: * @pdev: Pointer to the platform device 465: * @adreno_dev: Pointer to the adreno device 466: * @chipid: Chipid of the target 467: * @gpucore: Pointer to the gpucore strucure 468: * 469: * This function sets up the gen8 resources common across all 470: * gen8 targets 471: */ 472: int gen8_probe_common(struct platform_device *pdev, 473: struct adreno_device *adreno_dev, u32 chipid, 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: * --- FILE: \adreno_gen8_gmu.c | HITS: 18 --- MATCH LINES: 10 1: // SPDX-License-Identifier: GPL-2.0-only 2: /* 3: * Copyright (c) 2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #include 8: #include 9: #include 10: #include 11: #include 12: #include 13: #include 14: #include 15: #include 16: #include 17: #include 18: 19: #include "adreno.h" 20: #include "adreno_gen8.h" 21: #include "adreno_trace.h" 22: #include "kgsl_bus.h" 23: #include "kgsl_device.h" 24: #include "kgsl_trace.h" 25: #include "kgsl_gmu_core.h" 26: #include "kgsl_util.h" 27: 28: static struct gmu_vma_entry gen8_gmu_vma[] = { 29: [GMU_ITCM] = { 30: .start = 0x00000000, 31: .size = SZ_16K, 32: }, 33: [GMU_CACHE] = { 34: .start = SZ_16K, MATCH LINES: 946 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) 950: return 0; 951: 952: if (blk->type == GMU_BLOCK_ID_COMMON_CAPS) 953: caps = &gmu_core->common_caps; 954: else if (blk->type == GMU_BLOCK_ID_PLATFORM_CAPS) 955: caps = &gmu_core->platform_caps; 956: else 957: return 0; 958: 959: if (caps->data) 960: return 0; 961: 962: caps->length = blk->size; 963: caps->data = kmalloc_array(caps->length, sizeof(u8), GFP_KERNEL); 964: if (!caps->data) 965: return -ENOMEM; 966: 967: memcpy(caps->data, payload, caps->length); 968: 969: return 0; 970: } MATCH LINES: 1012, 1018, 1019, 1025, 1028 1000: } 1001: 1002: return ret; 1003: } 1004: 1005: int gen8_gmu_parse_fw(struct adreno_device *adreno_dev) 1006: { 1007: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1008: struct device *gmu_pdev_dev = GMU_PDEV_DEV(device); 1009: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1010: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev); 1011: struct gmu_block_header *blk; 1012: const char *gmufw_name = gen8_core->gmufw_name; 1013: int ret = 0; 1014: u32 offset = 0; 1015: 1016: /* 1017: * If GMU fw already saved and verified, do nothing new. 1018: * Skip only requesting firmware and allow preallocation to 1019: * ensure in scenario where GMU request firmware succeeded 1020: * but preallocation fails, we don't return early without 1021: * successful preallocations on next open call. 1022: */ 1023: if (!gmu->fw_image) { 1024: 1025: if (gen8_core->gmufw_name == NULL) 1026: return -EINVAL; 1027: 1028: ret = adreno_request_firmware(&gmu->fw_image, gmufw_name, 1029: gmu_pdev_dev, true); 1030: if (ret) 1031: return ret; 1032: } 1033: 1034: /* 1035: * Zero payload fw blocks contain metadata and are 1036: * guaranteed to precede fw load data. Parse the 1037: * metadata blocks. 1038: */ 1039: while (offset < gmu->fw_image->size) { 1040: blk = (struct gmu_block_header *)&gmu->fw_image->data[offset]; 1041: 1042: if (offset + sizeof(*blk) > gmu->fw_image->size) { 1043: dev_err(gmu_pdev_dev, "Invalid FW Block\n"); 1044: return -EINVAL; 1045: } 1046: 1047: offset += sizeof(*blk); 1048: 1049: /* process zero length blocks */ 1050: if (!blk->size) { 1051: ret = gen8_gmu_process_zero_length_block(device, blk); 1052: if (ret) MATCH LINES: 1977 1965: 1966: if (!ADRENO_FEATURE(adreno_dev, ADRENO_ACD)) 1967: return; 1968: 1969: cmd->hdr = CREATE_MSG_HDR(H2F_MSG_ACD_TBL, HFI_MSG_CMD); 1970: 1971: cmd->version = 1; 1972: cmd->stride = 1; 1973: cmd->enable_by_level = 0; 1974: 1975: /* 1976: * Iterate through each gpu power level and generate a mask for GMU 1977: * firmware for ACD enabled levels and store the corresponding control 1978: * register configurations to the acd_table structure. 1979: */ 1980: for (i = 0; i < pwr->num_pwrlevels; i++) { 1981: if (pwrlevel->acd_level) { 1982: cmd->enable_by_level |= (1 << (i + 1)); 1983: cmd->data[cmd_idx++] = pwrlevel->acd_level; 1984: } 1985: pwrlevel--; 1986: } 1987: 1988: if (!cmd->enable_by_level) 1989: return; 1990: 1991: cmd->num_levels = cmd_idx; 1992: 1993: ret = gen8_gmu_qmp_aoss_init(adreno_dev, gmu); 1994: if (ret) 1995: dev_err(GMU_PDEV_DEV(device), 1996: "AOP qmp init failed: %d\n", ret); 1997: } 1998: 1999: /* Byte offset of RSCC from GPU (kgsl_3d0_reg_memory) base */ 2000: #define GEN8_RSCC_OFFSET_FROM_KGSL_3D0 0x50000 2001: #define GEN8_RSCC_SIZE 0x10000 MATCH LINES: 2069, 2107, 2108 2057: 2058: void gen8_gmu_remove(struct kgsl_device *device) 2059: { 2060: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 2061: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2062: 2063: if (!IS_ERR_OR_NULL(gmu->qmp)) 2064: qmp_put(gmu->qmp); 2065: 2066: adreno_dev->acd_enabled = false; 2067: 2068: if (gmu->fw_image) { 2069: release_firmware(gmu->fw_image); 2070: kfree(device->gmu_core.common_caps.data); 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)); 2112: set_dma_ops(GMU_PDEV_DEV(device), NULL); 2113: 2114: /* Setup any rdpm register ranges */ 2115: gmu_core_rdpm_probe(device); 2116: 2117: device->gmu_core.rdpm_cx_offset = GEN8_RDPM_CX_OFFSET; 2118: device->gmu_core.rdpm_mx_offset = GEN8_RDPM_MX_OFFSET; 2119: 2120: /* Set up GMU gdscs */ 2121: ret = kgsl_pwrctrl_probe_gdscs(device, pdev); 2122: if (ret) 2123: return ret; 2124: 2125: if (gen8_core->gmu_mx_gdsc) { 2126: ret = kgsl_pwrctrl_probe_mx_gdsc(device, pdev); 2127: if (ret) 2128: return ret; 2129: } 2130: 2131: ret = gmu_core_clk_probe(device); 2132: if (ret) MATCH LINES: 2488, 2489, 2497, 2498, 2499, 2500, 2506 2476: 2477: adreno_dev->cooperative_reset = ADRENO_FEATURE(adreno_dev, 2478: ADRENO_COOP_RESET); 2479: 2480: adreno_create_profile_buffer(adreno_dev); 2481: 2482: set_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags); 2483: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 2484: 2485: /* 2486: * BCL needs respective Central Broadcast register to 2487: * be programed from TZ. For kernel version prior to 6.1, this 2488: * programing happens only when zap shader firmware load is successful. 2489: * Zap firmware load can fail in boot up path hence enable BCL only 2490: * after we successfully complete first boot to ensure that Central 2491: * Broadcast register was programed before enabling BCL. 2492: */ 2493: if (ADRENO_FEATURE(adreno_dev, ADRENO_BCL)) 2494: adreno_dev->bcl_enabled = true; 2495: 2496: /* 2497: * There is a possible deadlock scenario during kgsl firmware reading 2498: * (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl 2499: * device mutex is held and then firmware_request_nowarn is called for reading 2500: * firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock. 2501: * Whereas in case of devfreq update calls triggered by thermal/bcl or 2502: * devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then 2503: * tries to take kgsl device mutex as part of get_dev_status/target 2504: * calls. This results in deadlock when both thread are unable to acquire 2505: * the mutex held by other thread. Enable devfreq updates now as we are 2506: * done reading all firmware files. 2507: */ 2508: device->pwrscale.devfreq_enabled = true; 2509: 2510: device->pwrctrl.last_stat_updated = ktime_get(); 2511: 2512: set_bit(ADRENO_DEVICE_FIRST_BOOT_DONE, &adreno_dev->priv); 2513: 2514: kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE); 2515: 2516: return 0; 2517: } 2518: 2519: static bool gen8_irq_pending(struct adreno_device *adreno_dev) 2520: { 2521: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2522: u32 status; 2523: 2524: kgsl_regread(device, GEN8_RBBM_INT_0_STATUS, &status); 2525: 2526: /* Return busy if a interrupt is pending */ 2527: return ((status & adreno_dev->irq_mask) || 2528: atomic_read(&adreno_dev->pending_irq_refcnt)); 2529: } 2530: --- FILE: \adreno_gen8_gmu.h | HITS: 5 --- MATCH LINES: 34, 48 22: /** 23: * struct gen8_gmu_device - GMU device structure 24: * @ver: GMU Version information 25: * @irq: GMU interrupt number 26: * @fw_image: GMU FW image 27: * @gmu_log: gmu event log memory 28: * @hfi: HFI controller 29: * @idle_level: Minimal GPU idle power level 30: * @log_wptr_retention: Store the log wptr offset on slumber 31: */ 32: struct gen8_gmu_device { 33: int irq; 34: const struct firmware *fw_image; 35: struct kgsl_memdesc *gmu_log; 36: /** @gmu_init_scratch: Memory to store the initial HFI messages */ 37: struct kgsl_memdesc *gmu_init_scratch; 38: /** @gpu_boot_scratch: Memory to store the bootup HFI messages */ 39: struct kgsl_memdesc *gpu_boot_scratch; 40: struct gen8_hfi hfi; 41: u32 idle_level; 42: /** @qmp: aoss_qmp handle */ 43: struct qmp *qmp; 44: u32 log_wptr_retention; 45: /** @cm3_fault: whether gmu received a cm3 fault interrupt */ 46: atomic_t cm3_fault; 47: /** 48: * @itcm_shadow: Copy of the itcm block in firmware binary used for 49: * snapshot 50: */ 51: void *itcm_shadow; 52: /** @flags: Internal gmu flags */ 53: unsigned long flags; 54: /** @rscc_virt: Pointer where RSCC block is mapped */ 55: void __iomem *rscc_virt; 56: /** @log_stream_enable: GMU log streaming enable. Disabled by default */ 57: bool log_stream_enable; 58: /** @log_group_mask: Allows overriding default GMU log group mask */ 59: u32 log_group_mask; 60: struct kobject log_kobj; 61: /** @num_oob_perfcntr: Number of active oob_perfcntr requests */ 62: u32 num_oob_perfcntr; 63: /** @acd_debug_val: DVM value to calibrate ACD for a level */ 64: u32 acd_debug_val; 65: /** @stats_enable: GMU stats feature enable */ 66: bool stats_enable; 67: /** @stats_mask: GMU performance countables to enable */ 68: u32 stats_mask; 69: /** @stats_interval: GMU performance counters sampling interval */ 70: u32 stats_interval; 71: /** @stats_kobj: kernel object for GMU stats directory in sysfs */ 72: struct kobject stats_kobj; MATCH LINES: 192, 195 180: int gen8_gmu_memory_init(struct adreno_device *adreno_dev); 181: 182: /** 183: * gen8_gmu_aop_send_acd_state - Enable or disable acd feature in aop 184: * @gmu: Pointer to the gen8 gmu device 185: * @flag: Boolean to enable or disable acd in aop 186: * 187: * This function enables or disables gpu acd feature using qmp 188: */ 189: void gen8_gmu_aop_send_acd_state(struct gen8_gmu_device *gmu, bool flag); 190: 191: /** 192: * gen8_gmu_load_fw - Load gmu firmware 193: * @adreno_dev: Pointer to the adreno device 194: * 195: * Loads the gmu firmware binary into TCMs and memory 196: * 197: * Return: 0 on success or negative error on failure 198: */ 199: int gen8_gmu_load_fw(struct adreno_device *adreno_dev); 200: 201: /** 202: * gen8_gmu_device_start - Bring gmu out of reset 203: * @adreno_dev: Pointer to the adreno device 204: * 205: * Return: 0 on success or negative error on failure 206: */ 207: int gen8_gmu_device_start(struct adreno_device *adreno_dev); 208: 209: /** 210: * gen8_gmu_hfi_start - Indicate hfi start to gmu 211: * @device: Pointer to the kgsl device 212: * 213: * Return: 0 on success or negative error on failure 214: */ 215: int gen8_gmu_hfi_start(struct adreno_device *adreno_dev); 216: 217: /** 218: * gen8_gmu_itcm_shadow - Create itcm shadow copy for snapshot 219: * @adreno_dev: Pointer to the adreno device MATCH LINES: 234 222: */ 223: int gen8_gmu_itcm_shadow(struct adreno_device *adreno_dev); 224: 225: /** 226: * gen8_gmu_register_config - gmu register configuration 227: * @adreno_dev: Pointer to the adreno device 228: * 229: * Program gmu regsiters based on features 230: */ 231: void gen8_gmu_register_config(struct adreno_device *adreno_dev); 232: 233: /** 234: * gen8_gmu_version_info - Get gmu firmware version 235: * @adreno_dev: Pointer to the adreno device 236: * 237: * Return: 0 on success or negative error on failure 238: */ 239: int gen8_gmu_version_info(struct adreno_device *adreno_dev); 240: 241: /** 242: * gen8_gmu_irq_enable - Enable gmu interrupts 243: * @adreno_dev: Pointer to the adreno device 244: */ 245: void gen8_gmu_irq_enable(struct adreno_device *adreno_dev); 246: 247: /** 248: * gen8_gmu_irq_disable - Disaable gmu interrupts 249: * @adreno_dev: Pointer to the adreno device 250: */ 251: void gen8_gmu_irq_disable(struct adreno_device *adreno_dev); 252: 253: /** 254: * gen8_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 --- FILE: \adreno_gen8_hfi.c | HITS: 1 --- MATCH LINES: 280 268: { 269: u32 val; 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); --- FILE: \adreno_gen8_hwsched.c | HITS: 9 --- MATCH LINES: 606 594: return ret; 595: 596: error: 597: gen8_gmu_irq_disable(adreno_dev); 598: gen8_hwsched_hfi_stop(adreno_dev); 599: gen8_hwsched_gmu_suspend(adreno_dev, false); 600: 601: return ret; 602: } 603: 604: void gen8_hwsched_init_ucode_regs(struct adreno_device *adreno_dev) 605: { 606: struct adreno_firmware *fw = ADRENO_FW(adreno_dev, ADRENO_FW_SQE); 607: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 608: 609: /* Program the ucode base for CP */ 610: kgsl_regwrite(device, GEN8_CP_SQE_INSTR_BASE_LO, 611: lower_32_bits(fw->memdesc->gpuaddr)); 612: kgsl_regwrite(device, GEN8_CP_SQE_INSTR_BASE_HI, 613: upper_32_bits(fw->memdesc->gpuaddr)); 614: 615: if (ADRENO_FEATURE(adreno_dev, ADRENO_AQE)) { 616: fw = ADRENO_FW(adreno_dev, ADRENO_FW_AQE); 617: 618: /* Program the ucode base for AQE0 (BV coprocessor) */ 619: kgsl_regwrite(device, GEN8_CP_AQE_INSTR_BASE_LO_0, 620: lower_32_bits(fw->memdesc->gpuaddr)); 621: kgsl_regwrite(device, GEN8_CP_AQE_INSTR_BASE_HI_0, 622: upper_32_bits(fw->memdesc->gpuaddr)); 623: 624: /* Program the ucode base for AQE1 (LPAC coprocessor) */ 625: if (adreno_dev->lpac_enabled) { 626: kgsl_regwrite(device, GEN8_CP_AQE_INSTR_BASE_LO_1, 627: lower_32_bits(fw->memdesc->gpuaddr)); 628: kgsl_regwrite(device, GEN8_CP_AQE_INSTR_BASE_HI_1, 629: upper_32_bits(fw->memdesc->gpuaddr)); 630: } MATCH LINES: 859, 865 847: 848: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 849: 850: device->pwrctrl.last_stat_updated = ktime_get(); 851: 852: kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE); 853: 854: return ret; 855: } 856: 857: static int gen8_aqe_microcode_read(struct adreno_device *adreno_dev) 858: { 859: struct adreno_firmware *aqe_fw = ADRENO_FW(adreno_dev, ADRENO_FW_AQE); 860: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev); 861: 862: if (!ADRENO_FEATURE(adreno_dev, ADRENO_AQE)) 863: return 0; 864: 865: return adreno_get_firmware(adreno_dev, gen8_core->aqefw_name, aqe_fw); 866: } 867: 868: static int gen8_hwsched_first_boot(struct adreno_device *adreno_dev) 869: { 870: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 871: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 872: int ret; 873: 874: if (test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags)) 875: return gen8_hwsched_boot(adreno_dev); 876: 877: adreno_hwsched_start(adreno_dev); 878: 879: ret = gen8_microcode_read(adreno_dev); 880: if (ret) 881: return ret; 882: 883: ret = gen8_aqe_microcode_read(adreno_dev); 884: if (ret) 885: return ret; 886: 887: ret = gen8_init(adreno_dev); 888: if (ret) 889: return ret; MATCH LINES: 914, 924, 925, 926, 927, 933 902: if (ret) 903: return ret; 904: 905: adreno_dev->cooperative_reset = ADRENO_FEATURE(adreno_dev, 906: ADRENO_COOP_RESET); 907: 908: set_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags); 909: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 910: 911: /* 912: * BCL needs respective Central Broadcast register to 913: * be programed from TZ. This programing happens only 914: * when zap shader firmware load is successful. Zap firmware 915: * load can fail in boot up path hence enable BCL only after we 916: * successfully complete first boot to ensure that Central 917: * Broadcast register was programed before enabling BCL. 918: */ 919: if (ADRENO_FEATURE(adreno_dev, ADRENO_BCL)) 920: adreno_dev->bcl_enabled = true; 921: 922: if (device->host_based_dcvs) { 923: /* 924: * There is a possible deadlock scenario during kgsl firmware reading 925: * (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl 926: * device mutex is held and then firmware_request_nowarn is called for reading 927: * firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock. 928: * Whereas in case of devfreq update calls triggered by thermal/bcl or 929: * devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then 930: * tries to take kgsl device mutex as part of get_dev_status/target 931: * calls. This results in deadlock when both thread are unable to acquire 932: * the mutex held by other thread. Enable devfreq updates now as we are 933: * done reading all firmware files. 934: */ 935: device->pwrscale.devfreq_enabled = true; 936: device->pwrctrl.last_stat_updated = ktime_get(); 937: } 938: 939: set_bit(ADRENO_DEVICE_FIRST_BOOT_DONE, &adreno_dev->priv); 940: 941: kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE); 942: 943: return 0; 944: } 945: 946: /** 947: * drain_ctx_hw_fences_cpu - Force trigger the hardware fences that 948: * were not sent to TxQueue by the GMU 949: */ 950: static void drain_ctx_hw_fences_cpu(struct adreno_device *adreno_dev, 951: struct adreno_context *drawctxt) 952: { 953: struct adreno_hw_fence_entry *entry, *tmp; 954: 955: spin_lock(&drawctxt->lock); 956: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_inflight_list, node) { 957: kgsl_hw_fence_trigger_cpu(KGSL_DEVICE(adreno_dev), entry->kfence); --- FILE: \adreno_gen8_hwsched_hfi.c | HITS: 3 --- MATCH LINES: 1647, 1650 1635: * Bits [23:0] contains the countables mask 1636: * Bits [31:24] is the sampling interval 1637: */ 1638: data = FIELD_PREP(GENMASK(23, 0), gmu->stats_mask) | 1639: FIELD_PREP(GENMASK(31, 24), gmu->stats_interval); 1640: 1641: return gen8_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_GMU_STATS, 1, data); 1642: } 1643: 1644: static int gen8_hfi_send_perfcounter_feature_ctrl(struct adreno_device *adreno_dev) 1645: { 1646: /* 1647: * Perfcounter retention is disabled by default in GMU firmware. 1648: * In case perfcounter retention behaviour is overwritten by sysfs 1649: * setting dynmaically, send this HFI feature with 'enable = 0' to 1650: * disable this feature in GMU firmware. 1651: */ 1652: if (adreno_dev->perfcounter) 1653: return gen8_hfi_send_feature_ctrl(adreno_dev, 1654: HFI_FEATURE_PERF_NORETAIN, 0, 0); 1655: 1656: return 0; 1657: } 1658: 1659: u32 gen8_hwsched_hfi_get_value(struct adreno_device *adreno_dev, u32 prop, u32 subtype) 1660: { 1661: struct hfi_get_value_cmd cmd; 1662: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)); 1663: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1664: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev); 1665: struct pending_cmd pending_ack; 1666: u32 seqnum; 1667: int rc; 1668: 1669: rc = CMD_MSG_HDR(cmd, H2F_MSG_GET_VALUE); 1670: if (rc) 1671: return 0; 1672: 1673: seqnum = atomic_inc_return(&gmu->hfi.seqnum); 1674: cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2); MATCH LINES: 2842 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: 2846: if (!adreno_dev->zap_loaded) 2847: kgsl_regwrite(KGSL_DEVICE(adreno_dev), 2848: GEN8_RBBM_SECVID_TRUST_CNTL, 0x0); 2849: else 2850: ret = send_switch_to_unsecure(adreno_dev); 2851: 2852: return ret; 2853: } 2854: 2855: int gen8_hwsched_lpac_cp_init(struct adreno_device *adreno_dev) 2856: { 2857: u32 cmds[GEN8_CP_INIT_DWORDS + 1]; 2858: 2859: if (!adreno_dev->lpac_enabled) 2860: return 0; 2861: 2862: cmds[0] = CREATE_MSG_HDR(H2F_MSG_ISSUE_LPAC_CMD_RAW, HFI_MSG_CMD); 2863: 2864: gen8_cp_init_cmds(adreno_dev, &cmds[1]); 2865: 2866: return submit_lpac_raw_cmds(adreno_dev, cmds, sizeof(cmds), --- FILE: \adreno_snapshot.c | HITS: 11 --- MATCH LINES: 1077, 1091, 1098, 1113, 1116, 1128, 1136, 1140, 1144 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 */ MATCH LINES: 1189, 1190 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; --- FILE: \adreno_sysfs.c | HITS: 1 --- MATCH LINES: 10 1: // SPDX-License-Identifier: GPL-2.0-only 2: /* 3: * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #include 8: #include 9: #if (KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE) 10: #include 11: #else 12: #include 13: #endif 14: 15: #include "adreno.h" 16: #include "adreno_sysfs.h" 17: #include "adreno_trace.h" 18: #include "kgsl_pwrscale.h" 19: #include "kgsl_sysfs.h" 20: 21: static ssize_t _gpu_model_show(struct kgsl_device *device, char *buf) 22: { 23: return scnprintf(buf, PAGE_SIZE, adreno_get_gpu_model(device)); 24: } 25: 26: static ssize_t gpu_model_show(struct device *dev, 27: struct device_attribute *attr, char *buf) 28: { 29: struct kgsl_device *device = dev_get_drvdata(dev); 30: 31: return _gpu_model_show(device, buf); 32: } 33: 34: static int _l3_vote_store(struct adreno_device *adreno_dev, bool val) --- FILE: \adreno_trace.h | HITS: 1 --- MATCH LINES: 662 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) 680: __field(unsigned int, status) 681: ), 682: 683: TP_fast_assign( 684: adreno_assign_str(device_name, adreno_dev->dev.name); 685: __entry->status = status; 686: ), --- FILE: \governor_msm_adreno_tz.c | HITS: 3 --- MATCH LINES: 19, 24 7: #include 8: #include 9: #include 10: #include 11: #include 12: #include 13: #include 14: #include 15: #include 16: #include 17: #include 18: #if (KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE) 19: #include 20: #else 21: #include 22: #endif 23: #if IS_ENABLED(CONFIG_QCOM_SCM_ADDON) 24: #include 25: #endif 26: 27: #if (KERNEL_VERSION(6, 19, 0) <= LINUX_VERSION_CODE) 28: #include 29: #else 30: #include "governor.h" 31: #endif 32: 33: #include "msm_adreno_devfreq.h" 34: 35: static DEFINE_SPINLOCK(tz_lock); 36: static DEFINE_SPINLOCK(sample_lock); 37: static DEFINE_SPINLOCK(suspend_lock); 38: /* 39: * FLOOR is 5msec to capture up to 3 re-draws 40: * per frame for 60fps content. 41: */ 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: MATCH LINES: 239 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; 236: } 237: 238: #if IS_ENABLED(CONFIG_QCOM_TZMEM) 239: #include 240: 241: static int tz_init(struct device *dev, struct devfreq_msm_adreno_tz_data *priv, 242: unsigned int *tz_pwrlevels, u32 size_pwrlevels, 243: unsigned int *version, u32 size_version) 244: { 245: int ret; 246: phys_addr_t paddr; 247: struct qcom_tzmem_pool_config pool_config; 248: static struct qcom_tzmem_pool *tzmem_pool; 249: 250: if (!qcom_scm_dcvs_core_available()) 251: return -EINVAL; 252: 253: memset(&pool_config, 0, sizeof(pool_config)); 254: pool_config.initial_size = PAGE_ALIGN(size_pwrlevels); 255: pool_config.policy = QCOM_TZMEM_POLICY_STATIC; 256: pool_config.max_size = PAGE_ALIGN(size_pwrlevels); 257: 258: tzmem_pool = qcom_tzmem_pool_new(&pool_config); 259: if (IS_ERR(tzmem_pool)) { 260: pr_err(TAG "tz: Failed to create qcom_tzmem_pool %pe\n", tzmem_pool); 261: return PTR_ERR(tzmem_pool); 262: } 263: --- FILE: \kgsl_gmu_core.c | HITS: 1 --- MATCH LINES: 1071 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) 1074: return false; 1075: 1076: /* Capabilities payload data stored in 1 byte */ 1077: if (caps->data[field / BITS_PER_BYTE] & BIT(field % BITS_PER_BYTE)) 1078: return true; 1079: 1080: return false; 1081: } 1082: 1083: void gmu_core_mark_for_coldboot(struct kgsl_device *device) 1084: { 1085: struct gmu_core_device *gmu_core = &device->gmu_core; 1086: 1087: if (!gmu_core->warmboot_enabled) 1088: return; 1089: 1090: set_bit(GMU_FORCE_COLDBOOT, &gmu_core->flags); 1091: } 1092: 1093: void gmu_core_rdpm_probe(struct kgsl_device *device) 1094: { 1095: struct gmu_core_device *gmu = &device->gmu_core; --- FILE: \kgsl_gmu_core.h | HITS: 7 --- MATCH LINES: 543, 574, 575, 576, 577 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; 556: const struct gmu_dev_ops *dev_ops; 557: unsigned long flags; 558: /** @gf_panic: GMU fault panic policy */ 559: enum gmu_fault_panic_policy gf_panic; 560: /** @pdev: platform device for the gmu */ 561: struct platform_device *pdev; 562: /** @domain: IOMMU domain for the gmu context */ 563: struct iommu_domain *domain; 564: /** @group: IOMMU group for the gmu context */ 565: struct iommu_group *group; 566: /** @gmu_globals: Array to store gmu global buffers */ 567: struct kgsl_memdesc gmu_globals[GMU_KERNEL_ENTRIES]; 568: /** @global_entries: To keep track of number of gmu buffers */ 569: u32 global_entries; 570: /** @vma: VMA entry for GMU */ 571: struct gmu_vma_entry *vma; 572: /** @num_vmas: Number of entries in the @vma array */ 573: u32 num_vmas; 574: /** @common_caps: GMU firmware common capabilities */ 575: struct firmware_capabilities common_caps; 576: /** @platform_caps: GMU firmware platform capabilities */ 577: struct firmware_capabilities platform_caps; 578: /* @ver: GMU Version information */ 579: struct { 580: u32 core; 581: u32 core_dev; 582: u32 pwr; 583: u32 pwr_dev; 584: u32 hfi; 585: } ver; 586: /** @warmboot_enabled: True if warmboot is enabled */ 587: bool warmboot_enabled; 588: /** @rdpm_cx_virt: Pointer where the RDPM CX block is mapped */ 589: void __iomem *rdpm_cx_virt; 590: /** @rdpm_mx_virt: Pointer where the RDPM MX block is mapped */ 591: void __iomem *rdpm_mx_virt; 592: /** @rdpm_cx_offset: Offset of RDPM CX register */ 593: u32 rdpm_cx_offset; 594: /** @rdpm_mx_offset: Offset of RDPM MX register */ 595: u32 rdpm_mx_offset; 596: /** @clks: GPU subsystem clocks required for GMU functionality */ 597: struct clk_bulk_data *clks; 598: /** @num_clks: Number of entries in the @clks array */ 599: int num_clks; 600: /** @freqs: Array of GMU frequencies */ 601: u32 freqs[MAX_CX_LEVELS]; MATCH LINES: 911, 916 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: */ 923: void gmu_core_mark_for_coldboot(struct kgsl_device *device); 924: 925: /** 926: * gmu_core_reserve_gmuaddr() - Reserve a gmuaddr in the GMU VA space 927: * @device: Pointer to the kgsl device 928: * @md: Pointer to the memdesc 929: * @vma_id: Target gmu vma where this buffer should be mapped 930: * @align: Alignment for the GMU VA and GMU mapping size 931: * 932: * This function reserves a gmu address based on the input parameters 933: * 934: * Return: 0 on success or negative error on failure 935: */ 936: int gmu_core_reserve_gmuaddr(struct kgsl_device *device, struct kgsl_memdesc *md, 937: u32 vma_id, u32 align); 938: 939: /** 940: * gmu_core_rdpm_probe - Probe GMU RDPM resources --- FILE: \kgsl_iommu.c | HITS: 2 --- MATCH LINES: 21, 26 9: #include 10: #include 11: #include 12: #include 13: #include 14: #include 15: #include 16: #include 17: #include 18: #include 19: #include 20: #if (KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE) 21: #include 22: #else 23: #include 24: #endif 25: #if IS_ENABLED(CONFIG_QCOM_SCM_ADDON) 26: #include 27: #endif 28: #include 29: #include 30: #include 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 */ --- FILE: \kgsl_util.c | HITS: 3 --- MATCH LINES: 12, 17, 22 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: 8: #include 9: #include 10: #include 11: #include 12: #include 13: #include 14: #include 15: #include 16: #if (KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE) 17: #include 18: #else 19: #include 20: #endif 21: #if IS_ENABLED(CONFIG_QCOM_SCM_ADDON) 22: #include 23: #endif 24: #include 25: #include 26: #include 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: --- FILE: \kgsl_util.h | HITS: 2 --- MATCH LINES: 299, 317 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 300: 301: static inline int kgsl_pas_auth_and_reset(u32 pas_id) 302: { 303: return qcom_pas_auth_and_reset(pas_id); 304: } 305: 306: static inline int kgsl_pas_shutdown(u32 pas_id) 307: { 308: return qcom_pas_shutdown(pas_id); 309: } 310: 311: static inline int kgsl_pas_set_remote_state(u32 state, u32 pas_id) 312: { 313: return qcom_pas_set_remote_state(state, pas_id); 314: } 315: #else 316: #if (KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE) 317: #include 318: #else 319: #include 320: #endif 321: 322: static inline int kgsl_pas_auth_and_reset(u32 pas_id) 323: { 324: return qcom_scm_pas_auth_and_reset(pas_id); 325: } 326: 327: static inline int kgsl_pas_shutdown(u32 pas_id) 328: { 329: return qcom_scm_pas_shutdown_retry(pas_id); 330: } 331: 332: static inline int kgsl_pas_set_remote_state(u32 state, u32 pas_id) 333: { 334: return qcom_scm_set_remote_state(state, pas_id); 335: } 336: #endif 337: 338: /** 339: * isdb_write - Program isdb registers to issue break commands to SP 340: * @base: Base address of qdss registers to be programmed 341: * @offset: offset to the SP block TOTAL MATCHES: 473 ========================================================================================== SUBSYSTEM: FAULT_AND_RECOVERY ========================================================================================== --- FILE: \a5xx_reg.h | HITS: 6 --- MATCH LINES: 34 22: #define A5XX_INT_CP_CCU_FLUSH_COLOR_TS 11 23: #define A5XX_INT_CP_CCU_RESOLVE_TS 12 24: #define A5XX_INT_CP_IB2 13 25: #define A5XX_INT_CP_IB1 14 26: #define A5XX_INT_CP_RB 15 27: #define A5XX_INT_CP_UNUSED_1 16 28: #define A5XX_INT_CP_RB_DONE_TS 17 29: #define A5XX_INT_CP_WT_DONE_TS 18 30: #define A5XX_INT_UNKNOWN_1 19 31: #define A5XX_INT_CP_CACHE_FLUSH_TS 20 32: #define A5XX_INT_UNUSED_2 21 33: #define A5XX_INT_RBBM_ATB_BUS_OVERFLOW 22 34: #define A5XX_INT_MISC_HANG_DETECT 23 35: #define A5XX_INT_UCHE_OOB_ACCESS 24 36: #define A5XX_INT_UCHE_TRAP_INTR 25 37: #define A5XX_INT_DEBBUS_INTR_0 26 38: #define A5XX_INT_DEBBUS_INTR_1 27 39: #define A5XX_INT_GPMU_VOLTAGE_DROOP 28 40: #define A5XX_INT_GPMU_FIRMWARE 29 41: #define A5XX_INT_ISDB_CPU_IRQ 30 42: #define A5XX_INT_ISDB_UNDER_DEBUG 31 43: 44: /* CP Interrupt bits */ 45: #define A5XX_CP_OPCODE_ERROR 0 46: #define A5XX_CP_RESERVED_BIT_ERROR 1 47: #define A5XX_CP_HW_FAULT_ERROR 2 48: #define A5XX_CP_DMA_ERROR 3 49: #define A5XX_CP_REGISTER_PROTECTION_ERROR 4 50: #define A5XX_CP_AHB_ERROR 5 51: 52: /* CP registers */ 53: #define A5XX_CP_RB_BASE 0x800 54: #define A5XX_CP_RB_BASE_HI 0x801 55: #define A5XX_CP_RB_CNTL 0x802 56: #define A5XX_CP_RB_RPTR_ADDR_LO 0x804 57: #define A5XX_CP_RB_RPTR_ADDR_HI 0x805 58: #define A5XX_CP_RB_RPTR 0x806 MATCH LINES: 172, 173, 174 160: #define A5XX_RBBM_CFG_DBGBUS_NIBBLEE 0x1E 161: #define A5XX_RBBM_CFG_DBGBUS_PTRC0 0x1F 162: #define A5XX_RBBM_CFG_DBGBUS_PTRC1 0x20 163: #define A5XX_RBBM_CFG_DBGBUS_LOADREG 0x21 164: #define A5XX_RBBM_CFG_DBGBUS_IDX 0x22 165: #define A5XX_RBBM_CFG_DBGBUS_CLRC 0x23 166: #define A5XX_RBBM_CFG_DBGBUS_LOADIVT 0x24 167: #define A5XX_RBBM_INTERFACE_HANG_INT_CNTL 0x2F 168: #define A5XX_RBBM_INT_CLEAR_CMD 0x37 169: #define A5XX_RBBM_INT_0_MASK 0x38 170: #define A5XX_RBBM_AHB_DBG_CNTL 0x3F 171: #define A5XX_RBBM_EXT_VBIF_DBG_CNTL 0x41 172: #define A5XX_RBBM_SW_RESET_CMD 0x43 173: #define A5XX_RBBM_BLOCK_SW_RESET_CMD 0x45 174: #define A5XX_RBBM_BLOCK_SW_RESET_CMD2 0x46 175: #define A5XX_RBBM_DBG_LO_HI_GPIO 0x48 176: #define A5XX_RBBM_EXT_TRACE_BUS_CNTL 0x49 177: #define A5XX_RBBM_CLOCK_CNTL_TP0 0x4A 178: #define A5XX_RBBM_CLOCK_CNTL_TP1 0x4B 179: #define A5XX_RBBM_CLOCK_CNTL_TP2 0x4C 180: #define A5XX_RBBM_CLOCK_CNTL_TP3 0x4D 181: #define A5XX_RBBM_CLOCK_CNTL2_TP0 0x4E 182: #define A5XX_RBBM_CLOCK_CNTL2_TP1 0x4F 183: #define A5XX_RBBM_CLOCK_CNTL2_TP2 0x50 184: #define A5XX_RBBM_CLOCK_CNTL2_TP3 0x51 185: #define A5XX_RBBM_CLOCK_CNTL3_TP0 0x52 186: #define A5XX_RBBM_CLOCK_CNTL3_TP1 0x53 187: #define A5XX_RBBM_CLOCK_CNTL3_TP2 0x54 188: #define A5XX_RBBM_CLOCK_CNTL3_TP3 0x55 189: #define A5XX_RBBM_READ_AHB_THROUGH_DBG 0x59 190: #define A5XX_RBBM_CLOCK_CNTL_UCHE 0x5A 191: #define A5XX_RBBM_CLOCK_CNTL2_UCHE 0x5B 192: #define A5XX_RBBM_CLOCK_CNTL3_UCHE 0x5C 193: #define A5XX_RBBM_CLOCK_CNTL4_UCHE 0x5D 194: #define A5XX_RBBM_CLOCK_HYST_UCHE 0x5E 195: #define A5XX_RBBM_CLOCK_DELAY_UCHE 0x5F 196: #define A5XX_RBBM_CLOCK_MODE_GPC 0x60 197: #define A5XX_RBBM_CLOCK_DELAY_GPC 0x61 198: #define A5XX_RBBM_CLOCK_HYST_GPC 0x62 MATCH LINES: 775 763: #define A5XX_GPMU_SP_POWER_CNTL 0xA881 764: #define A5XX_GPMU_RBCCU_CLOCK_CNTL 0xA886 765: #define A5XX_GPMU_RBCCU_POWER_CNTL 0xA887 766: #define A5XX_GPMU_SP_PWR_CLK_STATUS 0xA88B 767: #define A5XX_GPMU_RBCCU_PWR_CLK_STATUS 0xA88D 768: #define A5XX_GPMU_PWR_COL_STAGGER_DELAY 0xA891 769: #define A5XX_GPMU_PWR_COL_INTER_FRAME_CTRL 0xA892 770: #define A5XX_GPMU_PWR_COL_INTER_FRAME_HYST 0xA893 771: #define A5XX_GPMU_PWR_COL_BINNING_CTRL 0xA894 772: #define A5XX_GPMU_CLOCK_THROTTLE_CTRL 0xA8A3 773: #define A5XX_GPMU_WFI_CONFIG 0xA8C1 774: #define A5XX_GPMU_RBBM_INTR_INFO 0xA8D6 775: #define A5XX_GPMU_CM3_SYSRESET 0xA8D8 776: #define A5XX_GPMU_GENERAL_0 0xA8E0 777: #define A5XX_GPMU_GENERAL_1 0xA8E1 778: 779: /* COUNTABLE FOR SP PERFCOUNTER */ 780: #define A5XX_SP_ALU_ACTIVE_CYCLES 0x1 781: #define A5XX_SP0_ICL1_MISSES 0x35 782: #define A5XX_SP_FS_CFLOW_INSTRUCTIONS 0x27 783: 784: /* COUNTABLE FOR TSE PERFCOUNTER */ 785: #define A5XX_TSE_INPUT_PRIM_NUM 0x6 786: 787: /* COUNTABLE FOR RBBM PERFCOUNTER */ 788: #define A5XX_RBBM_ALWAYS_COUNT 0x0 789: 790: /* GPMU POWER COUNTERS */ 791: #define A5XX_SP_POWER_COUNTER_0_LO 0xA840 792: #define A5XX_SP_POWER_COUNTER_0_HI 0xA841 793: #define A5XX_SP_POWER_COUNTER_1_LO 0xA842 794: #define A5XX_SP_POWER_COUNTER_1_HI 0xA843 795: #define A5XX_SP_POWER_COUNTER_2_LO 0xA844 796: #define A5XX_SP_POWER_COUNTER_2_HI 0xA845 797: #define A5XX_SP_POWER_COUNTER_3_LO 0xA846 798: #define A5XX_SP_POWER_COUNTER_3_HI 0xA847 799: MATCH LINES: 857 845: #define A5XX_GPMU_POWER_COUNTER_2_LO 0xA870 846: #define A5XX_GPMU_POWER_COUNTER_2_HI 0xA871 847: #define A5XX_GPMU_POWER_COUNTER_3_LO 0xA872 848: #define A5XX_GPMU_POWER_COUNTER_3_HI 0xA873 849: #define A5XX_GPMU_POWER_COUNTER_4_LO 0xA874 850: #define A5XX_GPMU_POWER_COUNTER_4_HI 0xA875 851: #define A5XX_GPMU_POWER_COUNTER_5_LO 0xA876 852: #define A5XX_GPMU_POWER_COUNTER_5_HI 0xA877 853: 854: #define A5XX_GPMU_POWER_COUNTER_ENABLE 0xA878 855: #define A5XX_GPMU_ALWAYS_ON_COUNTER_LO 0xA879 856: #define A5XX_GPMU_ALWAYS_ON_COUNTER_HI 0xA87A 857: #define A5XX_GPMU_ALWAYS_ON_COUNTER_RESET 0xA87B 858: #define A5XX_GPMU_POWER_COUNTER_SELECT_0 0xA87C 859: #define A5XX_GPMU_POWER_COUNTER_SELECT_1 0xA87D 860: #define A5XX_GPMU_GPMU_SP_CLOCK_CONTROL 0xA880 861: 862: #define A5XX_GPMU_CLOCK_THROTTLE_CTRL 0xA8A3 863: #define A5XX_GPMU_THROTTLE_UNMASK_FORCE_CTRL 0xA8A8 864: 865: #define A5XX_GPMU_TEMP_SENSOR_ID 0xAC00 866: #define A5XX_GPMU_TEMP_SENSOR_CONFIG 0xAC01 867: #define A5XX_GPMU_DELTA_TEMP_THRESHOLD 0xAC03 868: #define A5XX_GPMU_TEMP_THRESHOLD_INTR_EN_MASK 0xAC06 869: 870: #define A5XX_GPMU_LEAKAGE_TEMP_COEFF_0_1 0xAC40 871: #define A5XX_GPMU_LEAKAGE_TEMP_COEFF_2_3 0xAC41 872: #define A5XX_GPMU_LEAKAGE_VTG_COEFF_0_1 0xAC42 873: #define A5XX_GPMU_LEAKAGE_VTG_COEFF_2_3 0xAC43 874: #define A5XX_GPMU_BASE_LEAKAGE 0xAC46 875: 876: #define A5XX_GPMU_GPMU_VOLTAGE 0xAC60 877: #define A5XX_GPMU_GPMU_VOLTAGE_INTR_STATUS 0xAC61 878: #define A5XX_GPMU_GPMU_VOLTAGE_INTR_EN_MASK 0xAC62 879: #define A5XX_GPMU_GPMU_PWR_THRESHOLD 0xAC80 880: #define A5XX_GPMU_GPMU_LLM_GLM_SLEEP_CTRL 0xACC4 881: #define A5XX_GPMU_GPMU_LLM_GLM_SLEEP_STATUS 0xACC5 --- FILE: \a6xx_reg.h | HITS: 7 --- MATCH LINES: 27 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 MATCH LINES: 143 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 MATCH LINES: 417, 437, 439, 440 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 MATCH LINES: 988 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 --- FILE: \adreno-gpulist.h | HITS: 182 --- MATCH LINES: 144, 171 132: 133: static const struct adreno_a5xx_core adreno_gpu_core_a530v2 = { 134: .base = { 135: DEFINE_ADRENO_REV(ADRENO_REV_A530, 5, 3, 0, 1), 136: .features = ADRENO_SPTP_PC | ADRENO_LM | 137: ADRENO_PREEMPTION | 138: ADRENO_CONTENT_PROTECTION, 139: .gpudev = &adreno_a5xx_gpudev, 140: .perfcounters = &adreno_a5xx_perfcounters, 141: .uche_gmem_alignment = SZ_1M, 142: .gmem_size = SZ_1M, 143: .bus_width = 32, 144: .snapshot_size = SZ_1M, 145: .highest_bank_bit = 15, 146: }, 147: .gpmu_tsens = 0x00060007, 148: .max_power = 5448, 149: .pm4fw_name = "a530_pm4.fw", 150: .pfpfw_name = "a530_pfp.fw", 151: .gpmufw_name = "a530_gpmu.fw2", 152: .regfw_name = "a530v2_seq.fw2", 153: .zap_name = "a530_zap.mdt", 154: .hwcg = a530_hwcg_regs, 155: .hwcg_count = ARRAY_SIZE(a530_hwcg_regs), 156: .vbif = a530_vbif_regs, 157: .vbif_count = ARRAY_SIZE(a530_vbif_regs), 158: }; 159: 160: static const struct adreno_a5xx_core adreno_gpu_core_a530v3 = { 161: .base = { 162: DEFINE_ADRENO_REV(ADRENO_REV_A530, 5, 3, 0, ANY_ID), 163: .features = ADRENO_SPTP_PC | ADRENO_LM | 164: ADRENO_PREEMPTION | 165: ADRENO_CONTENT_PROTECTION, 166: .gpudev = &adreno_a5xx_gpudev, 167: .perfcounters = &adreno_a5xx_perfcounters, 168: .uche_gmem_alignment = SZ_1M, 169: .gmem_size = SZ_1M, 170: .bus_width = 32, 171: .snapshot_size = SZ_1M, 172: .highest_bank_bit = 15, 173: }, 174: .gpmu_tsens = 0x00060007, 175: .max_power = 5448, 176: .pm4fw_name = "a530_pm4.fw", 177: .pfpfw_name = "a530_pfp.fw", 178: .gpmufw_name = "a530v3_gpmu.fw2", 179: .regfw_name = "a530v3_seq.fw2", 180: .zap_name = "a530_zap.mdt", 181: .hwcg = a530_hwcg_regs, 182: .hwcg_count = ARRAY_SIZE(a530_hwcg_regs), 183: .vbif = a530_vbif_regs, 184: .vbif_count = ARRAY_SIZE(a530_vbif_regs), 185: }; 186: 187: /* For a505, a506 and a508 */ 188: static const struct kgsl_regmap_list a50x_hwcg_regs[] = { 189: {A5XX_RBBM_CLOCK_CNTL_SP0, 0x02222222}, 190: {A5XX_RBBM_CLOCK_CNTL2_SP0, 0x02222220}, 191: {A5XX_RBBM_CLOCK_HYST_SP0, 0x0000F3CF}, 192: {A5XX_RBBM_CLOCK_DELAY_SP0, 0x00000080}, 193: {A5XX_RBBM_CLOCK_CNTL_TP0, 0x22222222}, 194: {A5XX_RBBM_CLOCK_CNTL2_TP0, 0x22222222}, 195: {A5XX_RBBM_CLOCK_CNTL3_TP0, 0x00002222}, MATCH LINES: 238, 258 226: {A5XX_RBBM_CLOCK_DELAY_VFD, 0x00002222} 227: }; 228: 229: static const struct adreno_a5xx_core adreno_gpu_core_a505 = { 230: .base = { 231: DEFINE_ADRENO_REV(ADRENO_REV_A505, 5, 0, 5, ANY_ID), 232: .features = ADRENO_PREEMPTION, 233: .gpudev = &adreno_a5xx_gpudev, 234: .perfcounters = &adreno_a5xx_perfcounters, 235: .uche_gmem_alignment = SZ_1M, 236: .gmem_size = (SZ_128K + SZ_8K), 237: .bus_width = 16, 238: .snapshot_size = SZ_1M, 239: }, 240: .pm4fw_name = "a530_pm4.fw", 241: .pfpfw_name = "a530_pfp.fw", 242: .hwcg = a50x_hwcg_regs, 243: .hwcg_count = ARRAY_SIZE(a50x_hwcg_regs), 244: .vbif = a530_vbif_regs, 245: .vbif_count = ARRAY_SIZE(a530_vbif_regs), 246: }; 247: 248: static const struct adreno_a5xx_core adreno_gpu_core_a506 = { 249: .base = { 250: DEFINE_ADRENO_REV(ADRENO_REV_A506, 5, 0, 6, ANY_ID), 251: .features = ADRENO_PREEMPTION | 252: ADRENO_CONTENT_PROTECTION | ADRENO_CPZ_RETENTION, 253: .gpudev = &adreno_a5xx_gpudev, 254: .perfcounters = &adreno_a5xx_perfcounters, 255: .uche_gmem_alignment = SZ_1M, 256: .gmem_size = (SZ_128K + SZ_8K), 257: .bus_width = 16, 258: .snapshot_size = SZ_1M, 259: .highest_bank_bit = 14, 260: }, 261: .pm4fw_name = "a530_pm4.fw", 262: .pfpfw_name = "a530_pfp.fw", 263: .zap_name = "a506_zap.mdt", 264: .hwcg = a50x_hwcg_regs, 265: .hwcg_count = ARRAY_SIZE(a50x_hwcg_regs), 266: .vbif = a530_vbif_regs, 267: .vbif_count = ARRAY_SIZE(a530_vbif_regs), 268: }; 269: 270: static const struct kgsl_regmap_list a510_hwcg_regs[] = { 271: {A5XX_RBBM_CLOCK_CNTL_SP0, 0x02222222}, 272: {A5XX_RBBM_CLOCK_CNTL_SP1, 0x02222222}, 273: {A5XX_RBBM_CLOCK_CNTL2_SP0, 0x02222220}, 274: {A5XX_RBBM_CLOCK_CNTL2_SP1, 0x02222220}, 275: {A5XX_RBBM_CLOCK_HYST_SP0, 0x0000F3CF}, 276: {A5XX_RBBM_CLOCK_HYST_SP1, 0x0000F3CF}, 277: {A5XX_RBBM_CLOCK_DELAY_SP0, 0x00000080}, 278: {A5XX_RBBM_CLOCK_DELAY_SP1, 0x00000080}, 279: {A5XX_RBBM_CLOCK_CNTL_TP0, 0x22222222}, 280: {A5XX_RBBM_CLOCK_CNTL_TP1, 0x22222222}, 281: {A5XX_RBBM_CLOCK_CNTL2_TP0, 0x22222222}, 282: {A5XX_RBBM_CLOCK_CNTL2_TP1, 0x22222222}, MATCH LINES: 337 325: {A5XX_RBBM_CLOCK_DELAY_GPC, 0x00000200}, 326: {A5XX_RBBM_CLOCK_DELAY_VFD, 0x00002222}, 327: }; 328: 329: static const struct adreno_a5xx_core adreno_gpu_core_a510 = { 330: .base = { 331: DEFINE_ADRENO_REV(ADRENO_REV_A510, 5, 1, 0, ANY_ID), 332: .gpudev = &adreno_a5xx_gpudev, 333: .perfcounters = &adreno_a5xx_perfcounters, 334: .uche_gmem_alignment = SZ_1M, 335: .gmem_size = SZ_256K, 336: .bus_width = 16, 337: .snapshot_size = SZ_1M, 338: }, 339: .pm4fw_name = "a530_pm4.fw", 340: .pfpfw_name = "a530_pfp.fw", 341: .hwcg = a510_hwcg_regs, 342: .hwcg_count = ARRAY_SIZE(a510_hwcg_regs), 343: .vbif = a530_vbif_regs, 344: .vbif_count = ARRAY_SIZE(a530_vbif_regs), 345: }; 346: 347: DEFINE_DEPRECATED_CORE(a540v1, ADRENO_REV_A540, 5, 4, 0, 0); 348: 349: static const struct kgsl_regmap_list a540_hwcg_regs[] = { 350: {A5XX_RBBM_CLOCK_CNTL_SP0, 0x02222222}, 351: {A5XX_RBBM_CLOCK_CNTL_SP1, 0x02222222}, 352: {A5XX_RBBM_CLOCK_CNTL_SP2, 0x02222222}, 353: {A5XX_RBBM_CLOCK_CNTL_SP3, 0x02222222}, 354: {A5XX_RBBM_CLOCK_CNTL2_SP0, 0x02222220}, 355: {A5XX_RBBM_CLOCK_CNTL2_SP1, 0x02222220}, 356: {A5XX_RBBM_CLOCK_CNTL2_SP2, 0x02222220}, 357: {A5XX_RBBM_CLOCK_CNTL2_SP3, 0x02222220}, 358: {A5XX_RBBM_CLOCK_HYST_SP0, 0x0000F3CF}, 359: {A5XX_RBBM_CLOCK_HYST_SP1, 0x0000F3CF}, 360: {A5XX_RBBM_CLOCK_HYST_SP2, 0x0000F3CF}, 361: {A5XX_RBBM_CLOCK_HYST_SP3, 0x0000F3CF}, MATCH LINES: 463 451: 452: static const struct adreno_a5xx_core adreno_gpu_core_a540v2 = { 453: .base = { 454: DEFINE_ADRENO_REV(ADRENO_REV_A540, 5, 4, 0, ANY_ID), 455: .features = ADRENO_PREEMPTION | 456: ADRENO_CONTENT_PROTECTION | 457: ADRENO_SPTP_PC, 458: .gpudev = &adreno_a5xx_gpudev, 459: .perfcounters = &adreno_a5xx_perfcounters, 460: .uche_gmem_alignment = SZ_1M, 461: .gmem_size = SZ_1M, 462: .bus_width = 32, 463: .snapshot_size = SZ_1M, 464: .highest_bank_bit = 15, 465: }, 466: .gpmu_tsens = 0x000c000d, 467: .max_power = 5448, 468: .pm4fw_name = "a530_pm4.fw", 469: .pfpfw_name = "a530_pfp.fw", 470: .gpmufw_name = "a540_gpmu.fw2", 471: .zap_name = "a540_zap.mdt", 472: .hwcg = a540_hwcg_regs, 473: .hwcg_count = ARRAY_SIZE(a540_hwcg_regs), 474: .vbif = a540_vbif_regs, 475: .vbif_count = ARRAY_SIZE(a540_vbif_regs), 476: }; 477: 478: static const struct kgsl_regmap_list a512_hwcg_regs[] = { 479: {A5XX_RBBM_CLOCK_CNTL_SP0, 0x02222222}, 480: {A5XX_RBBM_CLOCK_CNTL_SP1, 0x02222222}, 481: {A5XX_RBBM_CLOCK_CNTL2_SP0, 0x02222220}, 482: {A5XX_RBBM_CLOCK_CNTL2_SP1, 0x02222220}, 483: {A5XX_RBBM_CLOCK_HYST_SP0, 0x0000F3CF}, 484: {A5XX_RBBM_CLOCK_HYST_SP1, 0x0000F3CF}, 485: {A5XX_RBBM_CLOCK_DELAY_SP0, 0x00000080}, 486: {A5XX_RBBM_CLOCK_DELAY_SP1, 0x00000080}, 487: {A5XX_RBBM_CLOCK_CNTL_TP0, 0x22222222}, MATCH LINES: 547, 567 535: }; 536: 537: static const struct adreno_a5xx_core adreno_gpu_core_a512 = { 538: .base = { 539: DEFINE_ADRENO_REV(ADRENO_REV_A512, 5, 1, 2, ANY_ID), 540: .features = ADRENO_PREEMPTION | 541: ADRENO_CONTENT_PROTECTION | ADRENO_CPZ_RETENTION, 542: .gpudev = &adreno_a5xx_gpudev, 543: .perfcounters = &adreno_a5xx_perfcounters, 544: .uche_gmem_alignment = SZ_1M, 545: .gmem_size = (SZ_256K + SZ_16K), 546: .bus_width = 32, 547: .snapshot_size = SZ_1M, 548: .highest_bank_bit = 14, 549: }, 550: .pm4fw_name = "a530_pm4.fw", 551: .pfpfw_name = "a530_pfp.fw", 552: .zap_name = "a512_zap.mdt", 553: .hwcg = a512_hwcg_regs, 554: .hwcg_count = ARRAY_SIZE(a512_hwcg_regs), 555: }; 556: 557: static const struct adreno_a5xx_core adreno_gpu_core_a508 = { 558: .base = { 559: DEFINE_ADRENO_REV(ADRENO_REV_A508, 5, 0, 8, ANY_ID), 560: .features = ADRENO_PREEMPTION | 561: ADRENO_CONTENT_PROTECTION | ADRENO_CPZ_RETENTION, 562: .gpudev = &adreno_a5xx_gpudev, 563: .perfcounters = &adreno_a5xx_perfcounters, 564: .uche_gmem_alignment = SZ_1M, 565: .gmem_size = (SZ_128K + SZ_8K), 566: .bus_width = 32, 567: .snapshot_size = SZ_1M, 568: .highest_bank_bit = 14, 569: }, 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}, MATCH LINES: 742, 755 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}, MATCH LINES: 842, 855, 870, 883, 898, 911, 925, 935 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}, MATCH LINES: 1057, 1071, 1088, 1103, 1121, 1136 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}, MATCH LINES: 1265, 1278 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}, MATCH LINES: 1345, 1360, 1376, 1391, 1406, 1419 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}, MATCH LINES: 1483, 1497, 1512, 1525, 1539, 1549, 1564, 1574 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}, MATCH LINES: 1688, 1701, 1721, 1734, 1754, 1767, 1786, 1799, 1819, 1842, 1862, 1875, 1894, 1904, 1908 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}, MATCH LINES: 1984, 2003, 2022, 2038 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 }, 2044: { GEN7_RBBM_CLOCK_CNTL2_SP0, 0x02022222 }, 2045: { GEN7_RBBM_CLOCK_HYST_SP0, 0x0000f3cf }, 2046: { GEN7_RBBM_CLOCK_DELAY_SP0, 0x00000080 }, 2047: { GEN7_RBBM_CLOCK_CNTL_TP0, 0x22222220 }, 2048: { GEN7_RBBM_CLOCK_CNTL2_TP0, 0x22222222 }, 2049: { GEN7_RBBM_CLOCK_CNTL3_TP0, 0x22220222 }, 2050: { GEN7_RBBM_CLOCK_CNTL4_TP0, 0x00222222 }, 2051: { GEN7_RBBM_CLOCK_HYST_TP0, 0x77777777 }, 2052: { GEN7_RBBM_CLOCK_HYST2_TP0, 0x77777777 }, 2053: { GEN7_RBBM_CLOCK_HYST3_TP0, 0x77777777 }, 2054: { GEN7_RBBM_CLOCK_HYST4_TP0, 0x00077777 }, 2055: { GEN7_RBBM_CLOCK_DELAY_TP0, 0x11111111 }, 2056: { GEN7_RBBM_CLOCK_DELAY2_TP0, 0x11111111 }, 2057: { GEN7_RBBM_CLOCK_DELAY3_TP0, 0x11111111 }, 2058: { GEN7_RBBM_CLOCK_DELAY4_TP0, 0x00011111 }, 2059: { GEN7_RBBM_CLOCK_CNTL_UCHE, 0x22222222 }, 2060: { GEN7_RBBM_CLOCK_HYST_UCHE, 0x00000004 }, 2061: { GEN7_RBBM_CLOCK_DELAY_UCHE, 0x00000002 }, 2062: { GEN7_RBBM_CLOCK_CNTL_RB0, 0x22222222 }, MATCH LINES: 2169, 2183, 2185, 2205, 2219, 2221, 2227, 2228, 2238 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, 2222: .preempt_level = 1, 2223: .ctxt_record_size = (2860 * SZ_1K), 2224: .fast_bus_hint = true, 2225: }; 2226: 2227: extern const struct gen7_snapshot_block_list gen7_2_0_snapshot_block_list; 2228: extern const struct gen7_snapshot_block_list gen7_6_0_snapshot_block_list; 2229: 2230: static const struct kgsl_regmap_list gen7_2_0_gbif_cx_regs[] = { 2231: { GEN7_GBIF_QSB_SIDE0, 0x00071e20 }, 2232: { GEN7_GBIF_QSB_SIDE1, 0x00071e20 }, 2233: { GEN7_GBIF_QSB_SIDE2, 0x00071e20 }, 2234: { GEN7_GBIF_QSB_SIDE3, 0x00071e20 }, 2235: { GEN7_GMU_CX_MRC_GBIF_QOS_CTRL, 0x33 }, 2236: }; 2237: 2238: extern const struct gen7_snapshot_block_list gen7_3_0_snapshot_block_list; 2239: 2240: static const u32 gen7_6_0_gbif_client_qos_values[KGSL_PRIORITY_MAX_RB_LEVELS] = { 2241: 0x03230323, 2242: }; 2243: 2244: static const struct kgsl_regmap_list gen7_2_0_hwcg_regs[] = { 2245: { GEN7_RBBM_CLOCK_CNTL_SP0, 0x02222222 }, 2246: { GEN7_RBBM_CLOCK_CNTL2_SP0, 0x22022222 }, 2247: { GEN7_RBBM_CLOCK_HYST_SP0, 0x003cf3cf }, 2248: { GEN7_RBBM_CLOCK_DELAY_SP0, 0x00000080 }, 2249: { GEN7_RBBM_CLOCK_CNTL_TP0, 0x22222220 }, 2250: { GEN7_RBBM_CLOCK_CNTL2_TP0, 0x22222222 }, 2251: { GEN7_RBBM_CLOCK_CNTL3_TP0, 0x22220222 }, 2252: { GEN7_RBBM_CLOCK_CNTL4_TP0, 0x00222222 }, 2253: { GEN7_RBBM_CLOCK_HYST_TP0, 0x77777777 }, 2254: { GEN7_RBBM_CLOCK_HYST2_TP0, 0x77777777 }, 2255: { GEN7_RBBM_CLOCK_HYST3_TP0, 0x77777777 }, 2256: { GEN7_RBBM_CLOCK_HYST4_TP0, 0x00077777 }, 2257: { GEN7_RBBM_CLOCK_DELAY_TP0, 0x11111111 }, 2258: { GEN7_RBBM_CLOCK_DELAY2_TP0, 0x11111111 }, 2259: { GEN7_RBBM_CLOCK_DELAY3_TP0, 0x11111111 }, 2260: { GEN7_RBBM_CLOCK_DELAY4_TP0, 0x00011111 }, 2261: { GEN7_RBBM_CLOCK_CNTL_UCHE, 0x22222222 }, 2262: { GEN7_RBBM_CLOCK_CNTL2_UCHE, 0x00222222 }, MATCH LINES: 2425, 2438, 2441, 2462, 2475, 2478, 2498, 2511, 2513, 2532, 2546, 2548, 2561, 2575, 2599, 2602, 2622, 2635, 2639, 2645 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, 2550: .ctxt_record_size = (2860 * SZ_1K), 2551: .fast_bus_hint = true, 2552: }; 2553: 2554: static const struct kgsl_regmap_list gen7_9_0_ao_hwcg_regs[] = { 2555: { GEN7_GPU_GMU_AO_GMU_CGC_MODE_CNTL, 0x00020222 }, 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", 2593: .hwcg = gen7_2_0_hwcg_regs, 2594: .hwcg_count = ARRAY_SIZE(gen7_2_0_hwcg_regs), 2595: .ao_hwcg = gen7_9_0_ao_hwcg_regs, 2596: .ao_hwcg_count = ARRAY_SIZE(gen7_9_0_ao_hwcg_regs), 2597: .gbif = gen7_2_0_gbif_cx_regs, 2598: .gbif_count = ARRAY_SIZE(gen7_2_0_gbif_cx_regs), 2599: .hang_detect_cycles = 0xcfffff, 2600: .protected_regs = gen7_2_0_protected_regs, 2601: .gmu_hub_clk_freq = 200000000, 2602: .gen7_snapshot_block_list = &gen7_5_0_snapshot_block_list, 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, 2640: .qos_value = gen7_6_0_gbif_client_qos_values, 2641: .preempt_level = 1, 2642: .ctxt_record_size = (4192 * SZ_1K), 2643: }; 2644: 2645: extern const struct gen7_snapshot_block_list gen7_9_0_snapshot_block_list; 2646: 2647: /* GEN7_9_0 protected register list */ 2648: static const struct gen7_protected_regs gen7_9_0_protected_regs[] = { 2649: { GEN7_CP_PROTECT_REG + 0, 0x00000, 0x004ff, 0 }, 2650: { GEN7_CP_PROTECT_REG + 1, 0x0050b, 0x00563, 0 }, 2651: { GEN7_CP_PROTECT_REG + 2, 0x00584, 0x006c1, 0 }, 2652: { GEN7_CP_PROTECT_REG + 3, 0x00706, 0x00706, 0 }, 2653: { GEN7_CP_PROTECT_REG + 4, 0x00720, 0x0073f, 0 }, 2654: { GEN7_CP_PROTECT_REG + 5, 0x00760, 0x007ff, 0 }, 2655: { GEN7_CP_PROTECT_REG + 6, 0x00800, 0x00882, 1 }, 2656: { GEN7_CP_PROTECT_REG + 7, 0x008a0, 0x008a8, 1 }, 2657: { GEN7_CP_PROTECT_REG + 8, 0x008ab, 0x00a40, 0 }, 2658: { GEN7_CP_PROTECT_REG + 9, 0x00900, 0x0094d, 1 }, 2659: { GEN7_CP_PROTECT_REG + 10, 0x0098d, 0x00a3f, 1 }, 2660: { GEN7_CP_PROTECT_REG + 11, 0x00a41, 0x00bff, 1 }, 2661: { GEN7_CP_PROTECT_REG + 12, 0x00df0, 0x00df1, 1 }, 2662: { GEN7_CP_PROTECT_REG + 13, 0x00e01, 0x00e01, 1 }, 2663: { GEN7_CP_PROTECT_REG + 14, 0x00e07, 0x00e0f, 1 }, 2664: { GEN7_CP_PROTECT_REG + 15, 0x02840, 0x03cc3, 1 }, 2665: { GEN7_CP_PROTECT_REG + 16, 0x03cc4, 0x05cc3, 0 }, 2666: { GEN7_CP_PROTECT_REG + 17, 0x08630, 0x087ff, 1 }, 2667: { GEN7_CP_PROTECT_REG + 18, 0x08e00, 0x08e00, 1 }, 2668: { GEN7_CP_PROTECT_REG + 19, 0x08e08, 0x08e08, 1 }, 2669: { GEN7_CP_PROTECT_REG + 20, 0x08e50, 0x08e6f, 1 }, MATCH LINES: 2715, 2727, 2730, 2754, 2766, 2769, 2778, 2797, 2812, 2815, 2820, 2834, 2846, 2848, 2853, 2868, 2882, 2885, 2890, 2904, 2928, 2931, 2936, 2950, 2965, 2967 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, 2731: .bcl_data = 1, 2732: .acv_perfmode_vote = BIT(2), 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, 2770: .bcl_data = 1, 2771: .acv_perfmode_vote = BIT(2), 2772: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 2773: .ctxt_record_size = (4208 * SZ_1K), 2774: .preempt_level = 1, 2775: .fast_bus_hint = true, 2776: }; 2777: 2778: extern const struct gen7_snapshot_block_list gen7_13_0_snapshot_block_list; 2779: 2780: /* SMMU aperture registers: GC to context bank 0, LPAC to context bank 1 */ 2781: static const struct kgsl_regmap_list gen7_13_0_smmu_aperture_regs[] = { 2782: { 0x0, 0x000c0000 }, /* GC: CB0 */ 2783: { 0x1, 0x000c1000 }, /* LPAC: CB1 */ 2784: { 0x2, 0x00000002 }, /* CTRL: GC + LPAC */ 2785: }; 2786: 2787: static const struct adreno_gen7_core adreno_gpu_core_gen7_13_0 = { 2788: .base = { 2789: DEFINE_ADRENO_REV(ADRENO_REV_GEN7_13_0, 2790: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID), 2791: .features = ADRENO_APRIV | ADRENO_IOCOHERENT, 2792: .gpudev = &adreno_gen7_gmu_gpudev.base, 2793: .perfcounters = &adreno_gen7_9_0_perfcounters, 2794: .uche_gmem_alignment = SZ_16M, 2795: .gmem_size = 3 * SZ_1M, 2796: .bus_width = 32, 2797: .snapshot_size = SZ_8M, 2798: .num_ddr_channels = 4, 2799: .highest_bank_bit = 16, 2800: .chipid = 0x43051701, 2801: .smmu_aperture = gen7_13_0_smmu_aperture_regs, 2802: .smmu_aperture_count = ARRAY_SIZE(gen7_13_0_smmu_aperture_regs), 2803: }, 2804: .sqefw_name = "gen71300_sqe.fw", 2805: .gmufw_name = "gen71300_gmu.bin", 2806: .zap_name = "gen71300_zap.mbn", 2807: .gmu_chipid = 0x70D0000, 2808: .ao_hwcg = gen7_9_0_ao_hwcg_regs, 2809: .ao_hwcg_count = ARRAY_SIZE(gen7_9_0_ao_hwcg_regs), 2810: .gbif = gen7_2_0_gbif_cx_regs, 2811: .gbif_count = ARRAY_SIZE(gen7_2_0_gbif_cx_regs), 2812: .hang_detect_cycles = 0xcfffff, 2813: .protected_regs = gen7_9_0_protected_regs, 2814: .gmu_hub_clk_freq = 200000000, 2815: .gen7_snapshot_block_list = &gen7_13_0_snapshot_block_list, 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", 2922: .hwcg = gen7_2_0_hwcg_regs, 2923: .hwcg_count = ARRAY_SIZE(gen7_2_0_hwcg_regs), 2924: .ao_hwcg = gen7_9_0_ao_hwcg_regs, 2925: .ao_hwcg_count = ARRAY_SIZE(gen7_9_0_ao_hwcg_regs), 2926: .gbif = gen7_2_0_gbif_cx_regs, 2927: .gbif_count = ARRAY_SIZE(gen7_2_0_gbif_cx_regs), 2928: .hang_detect_cycles = 0xcfffff, 2929: .protected_regs = gen7_2_0_protected_regs, 2930: .gmu_hub_clk_freq = 200000000, 2931: .gen7_snapshot_block_list = &gen7_15_0_snapshot_block_list, 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, 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}, MATCH LINES: 3039, 3060, 3068 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, 3061: .veto_fal10 = true, 3062: .protected_regs = a660_protected_regs, 3063: .disable_tseskip = true, 3064: .pdc_in_aop = true, 3065: .ctxt_record_size = 2496 * 1024, 3066: }; 3067: 3068: extern const struct gen8_snapshot_block_list gen8_0_0_snapshot_block_list; 3069: 3070: static const struct kgsl_regmap_list gen8_0_0_gbif_cx_regs[] = { 3071: { GEN8_GBIF_QSB_SIDE0, 0x00071e20 }, 3072: { GEN8_GBIF_QSB_SIDE1, 0x00071e20 }, 3073: { GEN8_GBIF_QSB_SIDE2, 0x00071e20 }, 3074: { GEN8_GBIF_QSB_SIDE3, 0x00071e20 }, 3075: { GEN8_GBIF_CX_CONFIG, 0x20023000 }, 3076: { GEN8_GMUCX_MRC_GBIF_QOS_CTRL, 0x33 }, 3077: }; 3078: 3079: /* GEN8_0_0 noncontext register list */ 3080: static const struct gen8_nonctxt_regs gen8_0_0_nonctxt_regs[] = { 3081: { GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) }, 3082: { GEN8_GRAS_DBG_ECO_CNTL, 0x00000800, BIT(PIPE_BR) | BIT(PIPE_BV) }, 3083: { GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BR) | BIT(PIPE_BV) }, 3084: { GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BR) | BIT(PIPE_BV) }, 3085: { GEN8_PC_CONTEXT_SWITCH_STABILIZE_CNTL_1, 0x00000002, BIT(PIPE_BR) | BIT(PIPE_BV) }, 3086: { GEN8_PC_CHICKEN_BITS_1, 0x00000003, BIT(PIPE_BR) | BIT(PIPE_BV) }, 3087: { GEN8_PC_CHICKEN_BITS_2, 0x00000200, BIT(PIPE_BR) | BIT(PIPE_BV) }, 3088: /* Disable BR throttling */ 3089: { GEN8_PC_CHICKEN_BITS_3, 0x00400000, BIT(PIPE_BR) | BIT(PIPE_BV) }, 3090: { GEN8_PC_CHICKEN_BITS_4, 0x00500050, BIT(PIPE_BR) | BIT(PIPE_BV) }, 3091: /* Configure GBIF GX registers */ 3092: { GEN8_UCHE_GBIF_GX_CONFIG, 0x010240e0, BIT(PIPE_NONE) }, MATCH LINES: 3273, 3285, 3289, 3319, 3343, 3347, 3359 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, 3290: .fast_bus_hint = true, 3291: .bcl_data = 1, 3292: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 3293: .noc_timeout_us = 3410, /* 3.41 msec */ 3294: .ctxt_record_size = (13536 * SZ_1K), 3295: .preempt_level = 1, 3296: .cl_no_ft_timeout_ms = 6500, 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", 3338: .zap_name = "gen80000_zap.mbn", 3339: .ao_hwcg = gen8_ao_hwcg_regs, 3340: .ao_hwcg_count = ARRAY_SIZE(gen8_ao_hwcg_regs), 3341: .gbif = gen8_0_0_gbif_cx_regs, 3342: .gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs), 3343: .hang_detect_cycles = 0xcfffff, 3344: .protected_regs = gen8_0_0_protected_regs, 3345: .nonctxt_regs = gen8_0_0_nonctxt_regs, 3346: .gmu_hub_clk_freq = 200000000, 3347: .gen8_snapshot_block_list = &gen8_0_0_snapshot_block_list, 3348: .fast_bus_hint = true, 3349: .bcl_data = 1, 3350: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 3351: .noc_timeout_us = 3410, /* 3.41 msec */ 3352: .ctxt_record_size = (13536 * SZ_1K), 3353: .preempt_level = 1, 3354: .cl_no_ft_timeout_ms = 6500, 3355: .therm_cfg = &therm_mit_cfg_8_0_0, 3356: .clx_tbl = &gen8_0_0_clx_table, 3357: }; 3358: 3359: extern const struct gen8_snapshot_block_list gen8_2_0_snapshot_block_list; 3360: 3361: static const struct hfi_clx_table_v2_cmd gen8_2_0_clx_table = { 3362: .version = (2 << 16) | 1, 3363: .domain = { 3364: /* GFX domain */ 3365: { 3366: .data0 = CLX_DATA(60, 5, 1, 1), 3367: .clxt = 0, 3368: .clxh = 0, 3369: .urgmode = 1, 3370: .lkgen = 0, 3371: .currbudget = 100, 3372: }, 3373: /* MxG domain */ 3374: { 3375: .data0 = CLX_DATA(60, 1, 1, 1), 3376: .clxt = 0, 3377: .clxh = 0, 3378: .urgmode = 1, 3379: .lkgen = 0, 3380: .currbudget = 50, 3381: }, 3382: }, 3383: }; MATCH LINES: 3536, 3537 3524: { GEN8_PC_CHICKEN_BITS_3, 0x00500000, BIT(PIPE_BV) | BIT(PIPE_BR) }, 3525: { GEN8_PC_CHICKEN_BITS_4, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) }, 3526: /* Disable Dead Draw Merge scheme on RB-HLSQ */ 3527: { GEN8_RB_RBP_CNTL, BIT(5), BIT(PIPE_BV) | BIT(PIPE_BR) }, 3528: { GEN8_RB_CCU_CNTL, 0x00000068, BIT(PIPE_BR) }, 3529: /* Partially enable perf clear, Disable DINT to c/z be data forwarding */ 3530: { GEN8_RB_CCU_DBG_ECO_CNTL, 0x00002200, BIT(PIPE_BR) }, 3531: { GEN8_RB_GC_GMEM_PROTECT, 0x12000000, BIT(PIPE_BR) }, 3532: { GEN8_RB_RESOLVE_PREFETCH_CNTL, 0x00000007, BIT(PIPE_BR) }, 3533: { GEN8_RB_CMP_DBG_ECO_CNTL, 0x00004000, BIT(PIPE_BR) }, 3534: { GEN8_RBBM_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) }, 3535: { GEN8_RBBM_SLICE_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) }, 3536: { GEN8_RBBM_POWER_UP_RESET_SW_OVERRIDE, 0x70809060, BIT(PIPE_NONE) }, 3537: { GEN8_RBBM_POWER_UP_RESET_SW_BV_OVERRIDE, 0x30000000, BIT(PIPE_NONE) }, 3538: { GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL, 0x00000030, BIT(PIPE_NONE) }, 3539: { GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL2, 0x00000030, BIT(PIPE_NONE) }, 3540: { GEN8_RBBM_INTERFACE_HANG_INT_CNTL, 0x0fffffff, BIT(PIPE_NONE) }, 3541: { GEN8_RBBM_GBIF_CLIENT_QOS_CNTL, 0x22122212, BIT(PIPE_NONE) }, 3542: { GEN8_RBBM_CGC_P2S_CNTL, 0x00000040, BIT(PIPE_NONE) }, 3543: /* Disable mode_switch optimization in UMAS */ 3544: { GEN8_SP_CHICKEN_BITS, BIT(26), BIT(PIPE_NONE) }, 3545: /* Disable LPAC large-LM mode */ 3546: { GEN8_SP_SS_CHICKEN_BITS_0, BIT(3), BIT(PIPE_NONE) }, 3547: /* Disable PS out of order retire */ 3548: { GEN8_SP_CHICKEN_BITS_2, 0xc20800, BIT(PIPE_NONE) }, 3549: { GEN8_SP_CHICKEN_BITS_3, 0x00300000, BIT(PIPE_NONE) }, 3550: { GEN8_SP_PERFCTR_SHADER_MASK, 0x0000003f, BIT(PIPE_NONE) }, 3551: /* Ignore HLSQ shared constant feedback from SP */ 3552: { GEN8_SP_HLSQ_DBG_ECO_CNTL_1, BIT(17), BIT(PIPE_NONE) }, 3553: /* Disable CS dead batch merge */ 3554: { GEN8_SP_HLSQ_DBG_ECO_CNTL_2, BIT(24), BIT(PIPE_NONE) }, 3555: /* Disable HLSQ stproc stc_buf_mode */ 3556: { GEN8_SP_HLSQ_DBG_ECO_CNTL_3, BIT(7), BIT(PIPE_NONE) }, 3557: { GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080, BIT(PIPE_NONE) }, 3558: { GEN8_SP_READ_SEL, 0x0001ff00, BIT(PIPE_NONE) }, 3559: /* Bit(20): Disable alphaOnly feature */ 3560: { GEN8_TPL1_DBG_ECO_CNTL, 0x10100000, BIT(PIPE_NONE) }, 3561: /* BIT(26): Disable final clamp for bicubic filtering */ MATCH LINES: 3628, 3640, 3644, 3676, 3698, 3702 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, 3643: .gmu_hub_clk_freq = 150000000, 3644: .gen8_snapshot_block_list = &gen8_2_0_snapshot_block_list, 3645: .fast_bus_hint = true, 3646: .bcl_data = GEN8_2_X_BCL_DATA, 3647: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 3648: .noc_timeout_us = 3410, /* 3.41 msec */ 3649: .cl_no_ft_timeout_ms = 6500, 3650: .ctxt_record_size = (19708 * SZ_1K), 3651: .therm_cfg = &therm_mit_cfg_8_2_0, 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, 3695: .ao_hwcg_count = ARRAY_SIZE(gen8_2_0_ao_hwcg_regs), 3696: .gbif = gen8_0_0_gbif_cx_regs, 3697: .gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs), 3698: .hang_detect_cycles = 0xcfffff, 3699: .protected_regs = gen8_2_0_protected_regs, 3700: .nonctxt_regs = gen8_2_0_nonctxt_regs, 3701: .gmu_hub_clk_freq = 150000000, 3702: .gen8_snapshot_block_list = &gen8_2_0_snapshot_block_list, 3703: .fast_bus_hint = true, 3704: .bcl_data = GEN8_2_X_BCL_DATA, 3705: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 3706: .noc_timeout_us = 3410, /* 3.41 msec */ 3707: .cl_no_ft_timeout_ms = 6500, 3708: .ctxt_record_size = (19708 * SZ_1K), 3709: .therm_cfg = &therm_mit_cfg_8_2_0, 3710: .limits_mit_cfg = &gen8_2_0_limits_mit_cfg, 3711: .preempt_level = 1, 3712: .clx_tbl = &gen8_2_0_clx_table, 3713: }; 3714: 3715: static const struct gen8_nonctxt_regs gen8_1_0_nonctxt_regs[] = { 3716: { GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) }, 3717: { GEN8_GRAS_DBG_ECO_CNTL, 0x00000800, BIT(PIPE_BV) | BIT(PIPE_BR) }, 3718: { GEN8_GRAS_TSEFE_DBG_ECO_CNTL, 0x00200000, BIT(PIPE_BV) | BIT(PIPE_BR) }, 3719: { GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) }, 3720: { GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BV) | BIT(PIPE_BR) }, 3721: { GEN8_PC_CONTEXT_SWITCH_STABILIZE_CNTL_1, 0x00000002, BIT(PIPE_BV) | BIT(PIPE_BR) }, 3722: { GEN8_PC_CHICKEN_BITS_1, 0x00000003, BIT(PIPE_BV) | BIT(PIPE_BR) }, 3723: { GEN8_PC_CHICKEN_BITS_2, 0x00000200, BIT(PIPE_BV) | BIT(PIPE_BR) }, 3724: { GEN8_PC_CHICKEN_BITS_3, 0x00500000, BIT(PIPE_BV) | BIT(PIPE_BR) }, 3725: { GEN8_PC_CHICKEN_BITS_4, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) }, 3726: { GEN8_RB_GC_GMEM_PROTECT, 0x15000000, BIT(PIPE_BR) }, MATCH LINES: 3822, 3835, 3858, 3862, 3886, 3898, 3902, 3929 3810: { GEN8_CP_PROTECT_REG_GLOBAL + 49, 0x27880, 0x27c05, 0 }, 3811: { GEN8_CP_PROTECT_REG_GLOBAL + 50, 0x27882, 0x2788b, 1 }, 3812: { GEN8_CP_PROTECT_REG_GLOBAL + 63, 0x27c06, 0x27c06, 1 }, 3813: { 0 }, 3814: }; 3815: 3816: static const struct kgsl_regmap_list gen8_1_0_ao_hwcg_regs[] = { 3817: { GEN8_GMUAO_CGC_MODE_CNTL, 0x00020202 }, 3818: { GEN8_GMUAO_CGC_DELAY_CNTL, 0x00110111 }, 3819: { GEN8_GMUAO_CGC_HYST_CNTL, 0x00055555 }, 3820: }; 3821: 3822: extern const struct gen8_snapshot_block_list gen8_1_0_snapshot_block_list; 3823: 3824: static const struct adreno_gen8_core adreno_gpu_core_gen8_1_0 = { 3825: .base = { 3826: DEFINE_ADRENO_REV(ADRENO_REV_GEN8_1_0, 3827: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID), 3828: .features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_CONTENT_PROTECTION | 3829: ADRENO_SOFTFUSE | ADRENO_ACD | ADRENO_PREEMPTION | ADRENO_AQE, 3830: .gpudev = &adreno_gen8_hwsched_gpudev.base, 3831: .perfcounters = &adreno_gen8_perfcounters, 3832: .uche_gmem_alignment = SZ_64M, 3833: .gmem_size = 21 * SZ_1M, 3834: .bus_width = 32, 3835: .snapshot_size = SZ_8M, 3836: .num_ddr_channels = 4, 3837: /* bits[7:4] patched at runtime with active slice count */ 3838: .chipid = 0x44070001, 3839: .speedbins = KGSL_SPEEDBINS( 3840: { 0, 0 }, 3841: { 388, 1 }, 3842: { 357, 2 }, 3843: { 284, 3 }, 3844: ), 3845: .ubwc_mode = 5, 3846: .mal = 32, 3847: .highest_bank_bit = 16, 3848: .gpu_model = "Adreno X2-90", 3849: }, 3850: .aqefw_name = "gen80100_aqe.fw", 3851: .sqefw_name = "gen80100_sqe.fw", 3852: .gmufw_name = "gen80100_gmu.bin", 3853: .zap_name = "gen80100_zap.mbn", 3854: .ao_hwcg = gen8_1_0_ao_hwcg_regs, 3855: .ao_hwcg_count = ARRAY_SIZE(gen8_1_0_ao_hwcg_regs), 3856: .gbif = gen8_0_0_gbif_cx_regs, 3857: .gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs), 3858: .hang_detect_cycles = 0xcfffff, 3859: .protected_regs = gen8_1_0_protected_regs, 3860: .nonctxt_regs = gen8_1_0_nonctxt_regs, 3861: .gmu_hub_clk_freq = 200000000, 3862: .gen8_snapshot_block_list = &gen8_1_0_snapshot_block_list, 3863: .fast_bus_hint = true, 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, 3901: .gmu_hub_clk_freq = 150000000, 3902: .gen8_snapshot_block_list = &gen8_2_0_snapshot_block_list, 3903: .fast_bus_hint = true, 3904: .bcl_data = GEN8_2_X_BCL_DATA, 3905: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 3906: .noc_timeout_us = 3410, /* 3.41 msec */ 3907: .cl_no_ft_timeout_ms = 6500, 3908: .ctxt_record_size = (19708 * SZ_1K), 3909: .therm_cfg = &therm_mit_cfg_8_2_0, 3910: .limits_mit_cfg = &gen8_2_0_limits_mit_cfg, 3911: .preempt_level = 1, 3912: .clx_tbl = &gen8_2_0_clx_table, 3913: }; 3914: 3915: /* GEN8_4_0 noncontext register list */ 3916: static const struct gen8_nonctxt_regs gen8_4_0_nonctxt_regs[] = { 3917: { GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) }, 3918: { GEN8_GRAS_DBG_ECO_CNTL, 0x00000800, BIT(PIPE_BR) | BIT(PIPE_BV) }, 3919: { GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BR) | BIT(PIPE_BV) }, 3920: { GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BR) | BIT(PIPE_BV) }, 3921: { GEN8_PC_CONTEXT_SWITCH_STABILIZE_CNTL_1, 0x00000002, BIT(PIPE_BR) | BIT(PIPE_BV) }, 3922: { GEN8_PC_CHICKEN_BITS_1, 0x00000003, BIT(PIPE_BR) | BIT(PIPE_BV) }, 3923: { GEN8_PC_CHICKEN_BITS_2, 0x00000200, BIT(PIPE_BR) | BIT(PIPE_BV) }, 3924: /* Disable BR throttling */ 3925: { GEN8_PC_CHICKEN_BITS_3, 0x00400000, BIT(PIPE_BR) | BIT(PIPE_BV) }, 3926: { GEN8_PC_CHICKEN_BITS_4, 0x00500050, BIT(PIPE_BR) | BIT(PIPE_BV) }, 3927: /* Configure GBIF GX registers */ 3928: { GEN8_UCHE_GBIF_GX_CONFIG, 0x010240e0, BIT(PIPE_NONE) }, 3929: /* Reset value of RBBM_GBIF_CLIENT_QOS_CNTL is 0. So, no need to program explicitly. */ 3930: /* Enable full concurrent resolve and unresolves */ 3931: { GEN8_RB_CCU_CNTL, 0x00000068, BIT(PIPE_BR) }, 3932: { GEN8_RB_GC_GMEM_PROTECT, 0x0c000000, BIT(PIPE_BR) }, 3933: /* Configure number of outstanding transactions to 32 */ 3934: { GEN8_RB_RESOLVE_PREFETCH_CNTL, 0x00000007, BIT(PIPE_BR) }, 3935: /* Configure UCHE request time out to 16 cycles for CCU/UCHE arbitration */ 3936: { GEN8_RB_CMP_DBG_ECO_CNTL, 0x00004000, BIT(PIPE_BR) }, 3937: { GEN8_RBBM_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) }, 3938: { GEN8_RBBM_SLICE_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) }, 3939: { GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL, 0x00000030, BIT(PIPE_NONE) }, 3940: { GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL2, 0x00000030, BIT(PIPE_NONE) }, 3941: { GEN8_RBBM_CGC_P2S_CNTL, 0x00000040, BIT(PIPE_NONE) }, 3942: /* Enable contribution of all shader stages to SP perfcounters */ 3943: { GEN8_SP_PERFCTR_SHADER_MASK, 0x0000003f, BIT(PIPE_NONE) }, 3944: /* 3945: * BIT(26): Limit the number of wave-slots for Eviction buffer to 1 per ALU GRP 3946: * BIT(30): Disable LPAC auto-promotion 3947: */ 3948: { GEN8_SP_CHICKEN_BITS_1, BIT(26) | BIT(30), BIT(PIPE_NONE) }, 3949: /* 3950: * BIT(22): Disable PS out of order retire 3951: * BIT(23): Enable half wave mode and MM instruction src&dst is half precision 3952: */ 3953: { GEN8_SP_CHICKEN_BITS_2, BIT(22) | BIT(23), BIT(PIPE_NONE) }, MATCH LINES: 3999, 4011, 4015, 4025 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, 4016: .qos_value = gen8_4_0_gbif_client_qos_values, 4017: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 4018: .bcl_data = 1, 4019: .preempt_level = 1, 4020: .ctxt_record_size = (13536 * SZ_1K), 4021: .noc_timeout_us = 3410, /* 3.41 msec */ 4022: .cl_no_ft_timeout_ms = 10000, 4023: }; 4024: 4025: extern const struct gen8_snapshot_block_list gen8_3_0_snapshot_block_list; 4026: 4027: static const struct kgsl_regmap_list gen8_3_0_gbif_cx_regs[] = { 4028: { GEN8_GBIF_QSB_SIDE0, 0x00071e20 }, 4029: { GEN8_GBIF_QSB_SIDE1, 0x00071e20 }, 4030: { GEN8_GBIF_QSB_SIDE2, 0x00071e20 }, 4031: { GEN8_GBIF_QSB_SIDE3, 0x00071e20 }, 4032: { GEN8_GBIF_CX_CONFIG, 0x20023000 }, 4033: }; 4034: 4035: static const struct kgsl_regmap_list gen8_8_0_gbif_cx_regs[] = { 4036: { GEN8_GBIF_QSB_SIDE0, 0x00071e20 }, 4037: { GEN8_GBIF_QSB_SIDE1, 0x00071e20 }, 4038: { GEN8_GBIF_QSB_SIDE2, 0x00071e20 }, 4039: { GEN8_GBIF_QSB_SIDE3, 0x00071e20 }, 4040: { GEN8_GBIF_CX_CONFIG, 0x40023000 }, 4041: }; 4042: 4043: /* GEN8_3_0 noncontext register list */ 4044: static const struct gen8_nonctxt_regs gen8_3_0_nonctxt_regs[] = { 4045: { GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) }, 4046: { GEN8_GRAS_DBG_ECO_CNTL, 0x00f80800, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4047: { GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4048: { GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4049: { GEN8_PC_CONTEXT_SWITCH_STABILIZE_CNTL_1, 0x00000002, BIT(PIPE_BV) | BIT(PIPE_BR) }, MATCH LINES: 4101, 4112, 4116 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, 4119: }; 4120: 4121: /* GEN8_6_0 noncontext register list */ 4122: static const struct gen8_nonctxt_regs gen8_6_0_nonctxt_regs[] = { 4123: { GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) }, 4124: { GEN8_GRAS_DBG_ECO_CNTL, 0x00000800, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4125: { GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4126: { GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4127: { GEN8_PC_CONTEXT_SWITCH_STABILIZE_CNTL_1, 0x00000002, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4128: { GEN8_PC_CHICKEN_BITS_1, 0x00000003, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4129: { GEN8_PC_CHICKEN_BITS_2, 0x00000200, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4130: { GEN8_PC_CHICKEN_BITS_3, 0x00500000, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4131: { GEN8_PC_CHICKEN_BITS_4, 0x00500050, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4132: /* Configure GBIF GX registers */ 4133: { GEN8_UCHE_GBIF_GX_CONFIG, 0x010240e0, BIT(PIPE_NONE) }, 4134: { GEN8_RBBM_GBIF_CLIENT_QOS_CNTL, 0x22122212, BIT(PIPE_NONE) }, 4135: /* Enable full concurrent resolve and unresolves */ 4136: { GEN8_RB_CCU_CNTL, 0x00000068, BIT(PIPE_BR) }, 4137: { GEN8_RB_GC_GMEM_PROTECT, 0x02600000, BIT(PIPE_BR) }, 4138: /* Configure number of outstanding transactions to 32 */ 4139: { GEN8_RB_RESOLVE_PREFETCH_CNTL, 0x00000007, BIT(PIPE_BR) }, 4140: /* Configure UCHE request time out to 16 cycles for CCU/UCHE arbitration */ MATCH LINES: 4185, 4201, 4213, 4217, 4238, 4249, 4253, 4268, 4269 4173: { GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) }, 4174: { GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4175: { GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4176: { GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4177: { GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4178: { GEN8_VFD_CB_LP_REQ_CNT, 0x00000020, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4179: { GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4180: /* Disable redundant tile data optimization */ 4181: { GEN8_VSC_KMD_DBG_ECO_CNTL, BIT(11), BIT(PIPE_NONE)}, 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, 4256: .noc_timeout_us = 3410, /* 3.41 msec */ 4257: .bcl_data = 1, 4258: }; 4259: 4260: /* GEN8_9_0 noncontext register list */ 4261: static const struct gen8_nonctxt_regs gen8_9_0_nonctxt_regs[] = { 4262: { GEN8_RBBM_GBIF_CLIENT_QOS_CNTL, 0x22122212, BIT(PIPE_NONE) }, 4263: { GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL, 0x00000030, BIT(PIPE_NONE) }, 4264: { GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL2, 0x00000030, BIT(PIPE_NONE) }, 4265: /* Disable Dead Draw Merge scheme on RB-HLSQ */ 4266: { GEN8_RB_RBP_CNTL, BIT(5), BIT(PIPE_BV) | BIT(PIPE_BR) }, 4267: { GEN8_RBBM_INTERFACE_HANG_INT_CNTL, 0x0fffffff, BIT(PIPE_NONE) }, 4268: { GEN8_RBBM_POWER_UP_RESET_SW_OVERRIDE, 0x70809060, BIT(PIPE_NONE) }, 4269: { GEN8_RBBM_POWER_UP_RESET_SW_BV_OVERRIDE, 0x30000000, BIT(PIPE_NONE) }, 4270: { GEN8_RBBM_CGC_P2S_CNTL, 0x00000040, BIT(PIPE_NONE) }, 4271: /* Disable mode_switch optimization in UMAS */ 4272: { GEN8_SP_CHICKEN_BITS, BIT(26), BIT(PIPE_NONE) }, 4273: /* Disable LPAC large-LM mode */ 4274: { GEN8_SP_SS_CHICKEN_BITS_0, BIT(3), BIT(PIPE_NONE) }, 4275: /* Disable PS out of order retire */ 4276: { GEN8_SP_CHICKEN_BITS_2, 0xc21800, BIT(PIPE_NONE) }, 4277: { GEN8_RBBM_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) }, 4278: { GEN8_RBBM_SLICE_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) }, 4279: { GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) }, 4280: { GEN8_UCHE_MODE_CNTL, 0x80080000, BIT(PIPE_NONE) }, 4281: { GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) }, 4282: { GEN8_UCHE_GBIF_GX_CONFIG, 0x010240e0, BIT(PIPE_NONE) }, 4283: { GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) }, 4284: { GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE) }, 4285: { GEN8_GRAS_TSEFE_DBG_ECO_CNTL, 0x00200000, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4286: { GEN8_GRAS_DBG_ECO_CNTL, 0x00000800, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4287: { GEN8_RB_CCU_CNTL, 0x00000068, BIT(PIPE_BR) }, 4288: { GEN8_RB_CCU_DBG_ECO_CNTL, 0x00002200, BIT(PIPE_BR) }, 4289: { GEN8_RB_GC_GMEM_PROTECT, 0x02600000, BIT(PIPE_BR) }, 4290: { GEN8_RB_RESOLVE_PREFETCH_CNTL, 0x00000007, BIT(PIPE_BR) }, 4291: { GEN8_RB_CMP_DBG_ECO_CNTL, 0x00004000, BIT(PIPE_BR) }, 4292: { GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BR) | BIT(PIPE_BV) }, 4293: { GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BR) | BIT(PIPE_BV) }, MATCH LINES: 4318, 4337, 4349, 4353, 4375, 4396, 4404, 4420, 4442, 4452 4306: { GEN8_SP_PERFCTR_SHADER_MASK, 0x0000003f, BIT(PIPE_NONE) }, 4307: /* Ignore HLSQ shared constant feedback from SP */ 4308: { GEN8_SP_HLSQ_DBG_ECO_CNTL_1, BIT(17), BIT(PIPE_NONE) }, 4309: /* Disable CS dead batch merge */ 4310: { GEN8_SP_HLSQ_DBG_ECO_CNTL_2, BIT(24), BIT(PIPE_NONE) }, 4311: { GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080, BIT(PIPE_NONE) }, 4312: { GEN8_SP_READ_SEL, 0x0001ff00, BIT(PIPE_NONE) }, 4313: { GEN8_TPL1_DBG_ECO_CNTL, 0x10100000, BIT(PIPE_NONE) }, 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, 4351: .nonctxt_regs = gen8_9_0_nonctxt_regs, 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), 4396: .hang_detect_cycles = 0xc3ffff, 4397: .veto_fal10 = true, 4398: .protected_regs = a620_protected_regs, 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", 4436: .gmufw_name = "gen80100_gmu.bin", 4437: .zap_name = "gen80100_zap.mbn", 4438: .ao_hwcg = gen8_1_0_ao_hwcg_regs, 4439: .ao_hwcg_count = ARRAY_SIZE(gen8_1_0_ao_hwcg_regs), 4440: .gbif = gen8_0_0_gbif_cx_regs, 4441: .gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs), 4442: .hang_detect_cycles = 0xcfffff, 4443: .protected_regs = gen8_1_0_protected_regs, 4444: .nonctxt_regs = gen8_1_0_nonctxt_regs, 4445: .gmu_hub_clk_freq = 200000000, 4446: .fast_bus_hint = true, 4447: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 4448: .noc_timeout_us = 3410, /* 3.41 msec */ 4449: .cl_no_ft_timeout_ms = 6500, 4450: .ctxt_record_size = (23088 * SZ_1K), 4451: .bcl_data = 1, 4452: .gen8_snapshot_block_list = &gen8_10_0_snapshot_block_list, 4453: .preempt_level = 1, 4454: }; 4455: 4456: static const struct hfi_clx_table_v2_cmd gen8_11_0_clx_table = { 4457: .version = (2 << 16) | 1, 4458: .domain = { 4459: /* GFX domain */ 4460: { 4461: .data0 = CLX_DATA(60, 5, 0, 1), 4462: .clxt = 0, 4463: .clxh = 0, 4464: .urgmode = 1, 4465: .lkgen = 0, 4466: .currbudget = 100, 4467: }, 4468: /* MxG domain */ 4469: { 4470: .data0 = CLX_DATA(30, 1, 1, 1), 4471: .clxt = 0, 4472: .clxh = 0, 4473: .urgmode = 1, 4474: .lkgen = 0, 4475: .currbudget = 100, 4476: }, MATCH LINES: 4669, 4670 4657: { GEN8_RB_CMP_NC_MODE_CNTL, 0x00028000, BIT(PIPE_BR) }, 4658: /* Disable early EOBlk return */ 4659: { GEN8_RB_DBG_ECO_CNTL, BIT(17), BIT(PIPE_BV) | BIT(PIPE_BR) }, 4660: { GEN8_RB_GC_GMEM_PROTECT, 0x12000000, BIT(PIPE_BR) }, 4661: /* Disable pre-mvcc dead draw merge scheme on LRZ-RB */ 4662: { GEN8_RB_RBP_CNTL, BIT(6), BIT(PIPE_BV) | BIT(PIPE_BR) }, 4663: { GEN8_RB_RESOLVE_PREFETCH_CNTL, 0x00000007, BIT(PIPE_BR) }, 4664: { GEN8_RB_CMP_DBG_ECO_CNTL, 0x00004000, BIT(PIPE_BR) }, 4665: { GEN8_RBBM_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) }, 4666: { GEN8_RBBM_SLICE_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) }, 4667: /* Enable RB BAC strobes */ 4668: { GEN8_RBBM_SLICE_PERFCTR_CNTL, BIT(0), BIT(PIPE_NONE) }, 4669: { GEN8_RBBM_POWER_UP_RESET_SW_OVERRIDE, 0x70809060, BIT(PIPE_NONE) }, 4670: { GEN8_RBBM_POWER_UP_RESET_SW_BV_OVERRIDE, 0x30000000, BIT(PIPE_NONE) }, 4671: { GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL, 0x00000030, BIT(PIPE_NONE) }, 4672: { GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL2, 0x00000030, BIT(PIPE_NONE) }, 4673: { GEN8_RBBM_INTERFACE_HANG_INT_CNTL, 0x0fffffff, BIT(PIPE_NONE) }, 4674: { GEN8_RBBM_GBIF_CLIENT_QOS_CNTL, 0x22122212, BIT(PIPE_NONE) }, 4675: { GEN8_RBBM_CGC_P2S_CNTL, 0x00000040, BIT(PIPE_NONE) }, 4676: /* Disable VS delay resource optimization */ 4677: { GEN8_SP_CHICKEN_BITS, BIT(24), BIT(PIPE_NONE) }, 4678: { GEN8_SP_CHICKEN_BITS_2, 0x00820800, BIT(PIPE_NONE) }, 4679: { GEN8_SP_CHICKEN_BITS_3, 0x00300000, BIT(PIPE_NONE) }, 4680: /* Disable last-use skip for gpr ALU Write Enable */ 4681: { GEN8_SP_CHICKEN_BITS_5, BIT(3), BIT(PIPE_NONE) }, 4682: { GEN8_SP_NC_MODE_CNTL, 0x00000002, BIT(PIPE_NONE) }, 4683: { GEN8_SP_PERFCTR_SHADER_MASK, 0x0000003f, BIT(PIPE_NONE) }, 4684: { GEN8_SP_HLSQ_DBG_ECO_CNTL, 0x04000000, BIT(PIPE_NONE) }, 4685: /* HLSQ ignores the shared constant feedback from SP:MAS */ 4686: { GEN8_SP_HLSQ_DBG_ECO_CNTL_1, BIT(17), BIT(PIPE_NONE) }, 4687: /* Disable HLSQ large instruction async mode check */ 4688: { GEN8_SP_HLSQ_DBG_ECO_CNTL_3, BIT(1), BIT(PIPE_NONE) }, 4689: { GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080, BIT(PIPE_NONE) }, 4690: { GEN8_SP_READ_SEL, 0x0001ff00, BIT(PIPE_NONE) }, 4691: { GEN8_SP_L0_PERF_TUNE, 0x00000024, BIT(PIPE_NONE) }, 4692: /* BIT(20): Disable alpha only optimization in TP */ 4693: { GEN8_TPL1_DBG_ECO_CNTL, 0x10100000, BIT(PIPE_NONE) }, 4694: { GEN8_TPL1_DBG_ECO_CNTL1, 0x00000720, BIT(PIPE_NONE) }, MATCH LINES: 4716, 4738, 4750, 4754 4704: { GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) }, 4705: /* Disable VFD sideband compression */ 4706: { GEN8_VFD_DBG_ECO_CNTL, 0x00008400, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4707: { GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4708: { GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4709: { GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4710: { GEN8_VFD_CB_LP_REQ_CNT, 0x00080020, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4711: { GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4712: { GEN8_VSC_VISIBILITY_FLUSH_CNTL, 0x00080004, BIT(PIPE_NONE) }, 4713: { 0 }, 4714: }; 4715: 4716: extern const struct gen8_snapshot_block_list gen8_11_0_snapshot_block_list; 4717: 4718: static const struct kgsl_regmap_list gen8_11_0_gbif_cx_regs[] = { 4719: { GEN8_GBIF_QSB_SIDE0, 0x00071e20 }, 4720: { GEN8_GBIF_QSB_SIDE1, 0x00071e20 }, 4721: { GEN8_GBIF_QSB_SIDE2, 0x00071e20 }, 4722: { GEN8_GBIF_QSB_SIDE3, 0x00071e20 }, 4723: { GEN8_GBIF_CX_CONFIG, 0x20023020 }, 4724: { GEN8_GMUCX_MRC_GBIF_QOS_CTRL, 0x33 }, 4725: }; 4726: 4727: static const struct adreno_gen8_core adreno_gpu_core_gen8_11_0 = { 4728: .base = { 4729: DEFINE_ADRENO_REV(ADRENO_REV_GEN8_11_0, 4730: UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID), 4731: .compatible = "qcom,adreno-gpu-gen8-11-0", 4732: .features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_CLX, 4733: .gpudev = &adreno_gen8_hwsched_gpudev.base, 4734: .perfcounters = &adreno_gen8_2_x_perfcounters, 4735: .uche_gmem_alignment = SZ_64M, 4736: .gmem_size = 18 * SZ_1M, 4737: .bus_width = 32, 4738: .snapshot_size = SZ_8M, 4739: .num_ddr_channels = 4, 4740: .highest_bank_bit = 16, 4741: }, 4742: .aqefw_name = "gen81100_aqe.fw", 4743: .sqefw_name = "gen81100_sqe.fw", 4744: .gmufw_name = "gen81100_gmu.bin", 4745: .zap_name = "gen81100_zap.mbn", 4746: .ao_hwcg = gen8_2_0_ao_hwcg_regs, 4747: .ao_hwcg_count = ARRAY_SIZE(gen8_2_0_ao_hwcg_regs), 4748: .gbif = gen8_11_0_gbif_cx_regs, 4749: .gbif_count = ARRAY_SIZE(gen8_11_0_gbif_cx_regs), 4750: .hang_detect_cycles = 0xcfffff, 4751: .protected_regs = gen8_11_0_protected_regs, 4752: .nonctxt_regs = gen8_11_0_nonctxt_regs, 4753: .gmu_hub_clk_freq = 150000000, 4754: .gen8_snapshot_block_list = &gen8_11_0_snapshot_block_list, 4755: .fast_bus_hint = true, 4756: .bcl_data = 1, 4757: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4), 4758: .noc_timeout_us = 3410, /* 3.41 msec */ 4759: .cl_no_ft_timeout_ms = 6500, 4760: .ctxt_record_size = (19708 * SZ_1K), 4761: .limits_mit_cfg = &gen8_11_0_limits_mit_cfg, 4762: .preempt_level = 1, 4763: .gmu_mx_gdsc = true, 4764: .three_rail_memory = true, 4765: .malu = true, 4766: .clx_tbl = &gen8_11_0_clx_table, 4767: }; 4768: 4769: /* GEN8_11_1 noncontext register list */ 4770: static const struct gen8_nonctxt_regs gen8_11_1_nonctxt_regs[] = { 4771: { GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) }, 4772: { GEN8_CP_MULTIDRAW_CNTL, 0x00000001, BIT(PIPE_NONE) }, 4773: /* Keep the raster direction as topleft */ 4774: { GEN8_GRAS_DBG_ECO_CNTL, 0x01000800, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4775: { GEN8_GRAS_TSEFE_DBG_ECO_CNTL, 0x00200000, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4776: /* GEN8_GRAS_NC_MODE_CNTL explicitly set elsewhere */ 4777: { GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4778: { GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BV) | BIT(PIPE_BR) }, MATCH LINES: 4812, 4813 4800: { GEN8_RB_GC_GMEM_PROTECT, 0x12000000, BIT(PIPE_BR) }, 4801: /* 4802: * BIT(5): Disable dead draw merge scheme on RB-HLSQ 4803: * BIT(6): Disable pre-mvcc dead draw merge scheme on LRZ-RB 4804: */ 4805: { GEN8_RB_RBP_CNTL, BIT(5) | BIT(6), BIT(PIPE_BV) | BIT(PIPE_BR) }, 4806: { GEN8_RB_RESOLVE_PREFETCH_CNTL, 0x00000007, BIT(PIPE_BR) }, 4807: { GEN8_RB_CMP_DBG_ECO_CNTL, 0x00004000, BIT(PIPE_BR) }, 4808: { GEN8_RBBM_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) }, 4809: { GEN8_RBBM_SLICE_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) }, 4810: /* Enable RB BAC strobes */ 4811: { GEN8_RBBM_SLICE_PERFCTR_CNTL, BIT(0), BIT(PIPE_NONE) }, 4812: { GEN8_RBBM_POWER_UP_RESET_SW_OVERRIDE, 0x70809060, BIT(PIPE_NONE) }, 4813: { GEN8_RBBM_POWER_UP_RESET_SW_BV_OVERRIDE, 0x30000000, BIT(PIPE_NONE) }, 4814: { GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL, 0x00000030, BIT(PIPE_NONE) }, 4815: { GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL2, 0x00000030, BIT(PIPE_NONE) }, 4816: /* GEN8_RBBM_INTERFACE_HANG_INT_CNTL explicitly set elsewhere */ 4817: { GEN8_RBBM_GBIF_CLIENT_QOS_CNTL, 0x22122212, BIT(PIPE_NONE) }, 4818: { GEN8_RBBM_CGC_P2S_CNTL, 0x00000040, BIT(PIPE_NONE) }, 4819: /* Disable VS delay resource optimization */ 4820: { GEN8_SP_CHICKEN_BITS, BIT(24), BIT(PIPE_NONE) }, 4821: { GEN8_SP_CHICKEN_BITS_2, 0x00820800, BIT(PIPE_NONE) }, 4822: { GEN8_SP_CHICKEN_BITS_3, 0x00300000, BIT(PIPE_NONE) }, 4823: /* Disable last-use skip for gpr ALU Write Enable */ 4824: { GEN8_SP_CHICKEN_BITS_5, BIT(3), BIT(PIPE_NONE) }, 4825: /* GEN8_SP_NC_MODE_CNTL explicitly set elsewhere */ 4826: { GEN8_SP_PERFCTR_SHADER_MASK, 0x0000003f, BIT(PIPE_NONE) }, 4827: { GEN8_SP_HLSQ_DBG_ECO_CNTL, 0x04000000, BIT(PIPE_NONE) }, 4828: /* HLSQ ignores the shared constant feedback from SP:MAS */ 4829: { GEN8_SP_HLSQ_DBG_ECO_CNTL_1, BIT(17), BIT(PIPE_NONE) }, 4830: /* Disable HLSQ large instruction async mode check */ 4831: { GEN8_SP_HLSQ_DBG_ECO_CNTL_3, BIT(1), BIT(PIPE_NONE) }, 4832: { GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080, BIT(PIPE_NONE) }, 4833: { GEN8_SP_READ_SEL, 0x0001ff00, BIT(PIPE_NONE) }, 4834: { GEN8_SP_L0_PERF_TUNE, 0x00000024, BIT(PIPE_NONE) }, 4835: /* BIT(20): Disable alpha only optimization in TP */ 4836: { GEN8_TPL1_DBG_ECO_CNTL, 0x10100000, BIT(PIPE_NONE) }, 4837: { GEN8_TPL1_DBG_ECO_CNTL1, 0x00000720, BIT(PIPE_NONE) }, MATCH LINES: 4877, 4897, 4901 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), 4895: .gbif = gen8_11_0_gbif_cx_regs, 4896: .gbif_count = ARRAY_SIZE(gen8_11_0_gbif_cx_regs), 4897: .hang_detect_cycles = 0xcfffff, 4898: .protected_regs = gen8_11_0_protected_regs, 4899: .nonctxt_regs = gen8_11_1_nonctxt_regs, 4900: .gmu_hub_clk_freq = 150000000, 4901: .gen8_snapshot_block_list = &gen8_11_0_snapshot_block_list, 4902: .fast_bus_hint = true, 4903: .bcl_data = GEN8_2_X_BCL_DATA, 4904: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(4224, 4), 4905: .noc_timeout_us = 3410, /* 3.41 msec */ 4906: .cl_no_ft_timeout_ms = 6500, 4907: .ctxt_record_size = (19708 * SZ_1K), 4908: .limits_mit_cfg = &gen8_11_0_limits_mit_cfg, 4909: .preempt_level = 1, 4910: .gmu_mx_gdsc = true, 4911: .three_rail_memory = true, 4912: .malu = true, 4913: .clx_tbl = &gen8_11_0_clx_table, 4914: }; 4915: 4916: static const struct gen8_nonctxt_regs gen8_14_0_nonctxt_regs[] = { 4917: { GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) }, 4918: { GEN8_CP_MULTIDRAW_CNTL, 0x00000001, BIT(PIPE_NONE) }, 4919: /* Keep the raster direction as topleft */ 4920: { GEN8_GRAS_DBG_ECO_CNTL, 0x01000800, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4921: { GEN8_GRAS_TSEFE_DBG_ECO_CNTL, 0x00200000, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4922: /* GEN8_GRAS_NC_MODE_CNTL explicitly set elsewhere */ 4923: { GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4924: { GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BV) | BIT(PIPE_BR) }, 4925: { GEN8_PC_CONTEXT_SWITCH_STABILIZE_CNTL_1, 0x00000002, BIT(PIPE_BV) | BIT(PIPE_BR) }, MATCH LINES: 4956, 4957 4944: /* Disable early EOBlk return */ 4945: { GEN8_RB_DBG_ECO_CNTL, BIT(17), BIT(PIPE_BV) | BIT(PIPE_BR) }, 4946: { GEN8_RB_GC_GMEM_PROTECT, 0xC000000, BIT(PIPE_BR) }, 4947: /* 4948: * BIT(5): Disable dead draw merge scheme on RB-HLSQ 4949: * BIT(6): Disable pre-mvcc dead draw merge scheme on LRZ-RB 4950: */ 4951: { GEN8_RB_RBP_CNTL, BIT(5) | BIT(6), BIT(PIPE_BV) | BIT(PIPE_BR) }, 4952: { GEN8_RB_RESOLVE_PREFETCH_CNTL, 0x00000007, BIT(PIPE_BR) }, 4953: { GEN8_RB_CMP_DBG_ECO_CNTL, 0x00004000, BIT(PIPE_BR) }, 4954: { GEN8_RBBM_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) }, 4955: { GEN8_RBBM_SLICE_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) }, 4956: { GEN8_RBBM_POWER_UP_RESET_SW_OVERRIDE, 0x70809060, BIT(PIPE_NONE) }, 4957: { GEN8_RBBM_POWER_UP_RESET_SW_BV_OVERRIDE, 0x30000000, BIT(PIPE_NONE) }, 4958: { GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL, 0x00000030, BIT(PIPE_NONE) }, 4959: { GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL2, 0x00000030, BIT(PIPE_NONE) }, 4960: /* GEN8_RBBM_INTERFACE_HANG_INT_CNTL explicitly set elsewhere */ 4961: { GEN8_RBBM_GBIF_CLIENT_QOS_CNTL, 0x22122212, BIT(PIPE_NONE) }, 4962: { GEN8_RBBM_CGC_P2S_CNTL, 0x00000040, BIT(PIPE_NONE) }, 4963: /* Disable VS delay resource optimization */ 4964: { GEN8_SP_CHICKEN_BITS, BIT(24), BIT(PIPE_NONE) }, 4965: { GEN8_SP_CHICKEN_BITS_2, 0x00820800, BIT(PIPE_NONE) }, 4966: { GEN8_SP_CHICKEN_BITS_3, 0x00300000, BIT(PIPE_NONE) }, 4967: /* Disable last-use skip for gpr ALU Write Enable */ 4968: { GEN8_SP_CHICKEN_BITS_5, BIT(3), BIT(PIPE_NONE) }, 4969: /* GEN8_SP_NC_MODE_CNTL explicitly set elsewhere */ 4970: { GEN8_SP_PERFCTR_SHADER_MASK, 0x0000003f, BIT(PIPE_NONE) }, 4971: { GEN8_SP_HLSQ_DBG_ECO_CNTL, 0x04000000, BIT(PIPE_NONE) }, 4972: /* HLSQ ignores the shared constant feedback from SP:MAS */ 4973: { GEN8_SP_HLSQ_DBG_ECO_CNTL_1, BIT(17), BIT(PIPE_NONE) }, 4974: /* Disable HLSQ large instruction async mode check */ 4975: { GEN8_SP_HLSQ_DBG_ECO_CNTL_3, BIT(1), BIT(PIPE_NONE) }, 4976: { GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080, BIT(PIPE_NONE) }, 4977: { GEN8_SP_READ_SEL, 0x0001ff00, BIT(PIPE_NONE) }, 4978: { GEN8_SP_L0_PERF_TUNE, 0x00000024, BIT(PIPE_NONE) }, 4979: /* BIT(20): Disable alpha only optimization in TP */ 4980: { GEN8_TPL1_DBG_ECO_CNTL, 0x10100000, BIT(PIPE_NONE) }, 4981: { GEN8_TPL1_DBG_ECO_CNTL1, 0x00000720, BIT(PIPE_NONE) }, MATCH LINES: 5021, 5041, 5045 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), 5039: .gbif = gen8_11_0_gbif_cx_regs, 5040: .gbif_count = ARRAY_SIZE(gen8_11_0_gbif_cx_regs), 5041: .hang_detect_cycles = 0xcfffff, 5042: .protected_regs = gen8_11_0_protected_regs, 5043: .nonctxt_regs = gen8_14_0_nonctxt_regs, 5044: .gmu_hub_clk_freq = 150000000, 5045: .gen8_snapshot_block_list = &gen8_11_0_snapshot_block_list, 5046: .fast_bus_hint = true, 5047: .acv_perfmode_ddr_freq = MHZ_TO_KBPS(4224, 4), 5048: .noc_timeout_us = 3410, /* 3.41 msec */ 5049: .cl_no_ft_timeout_ms = 6500, 5050: .ctxt_record_size = (13564 * SZ_1K), 5051: .limits_mit_cfg = &gen8_11_0_limits_mit_cfg, 5052: .preempt_level = 1, 5053: .gmu_mx_gdsc = true, 5054: .three_rail_memory = true, 5055: .malu = false, 5056: .clx_tbl = &gen8_14_0_clx_table, 5057: }; 5058: 5059: static const struct adreno_gpu_core *adreno_gpulist[] = { 5060: &adreno_gpu_core_a306, /* Deprecated */ 5061: &adreno_gpu_core_a306a, /* Deprecated */ 5062: &adreno_gpu_core_a304, /* Deprecated */ 5063: &adreno_gpu_core_a405, /* Deprecated */ 5064: &adreno_gpu_core_a418, /* Deprecated */ 5065: &adreno_gpu_core_a420, /* Deprecated */ 5066: &adreno_gpu_core_a430, /* Deprecated */ 5067: &adreno_gpu_core_a530v1, /* Deprecated */ 5068: &adreno_gpu_core_a530v2.base, 5069: &adreno_gpu_core_a530v3.base, --- FILE: \adreno.c | HITS: 78 --- MATCH LINES: 21 9: #include 10: #include 11: #include 12: #include 13: #include 14: #include 15: #include 16: #include 17: #include 18: #include 19: #include 20: #include 21: #include 22: #include 23: #include 24: #include 25: #include 26: #include 27: #include 28: #include 29: #if (KERNEL_VERSION(6, 10, 0) <= LINUX_VERSION_CODE) 30: #include 31: #endif 32: #if (KERNEL_VERSION(6, 17, 0) <= LINUX_VERSION_CODE) 33: #include 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" 43: #include "kgsl_power_trace.h" 44: #include "kgsl_reclaim.h" 45: #include "kgsl_trace.h" MATCH LINES: 99 87: */ 88: u32 version; 89: /** @dwords_per_gpu: DWORD size of struct gpu_ctxt_record */ 90: u16 dwords_per_gpu; 91: /** @num_gpus: For targets that share same ucode binary, num_gpus > 1, otherwise 1 */ 92: u16 num_gpus; 93: /** @reserved: for future use */ 94: u32 reserved[2]; 95: } __packed; 96: 97: static void adreno_unbind(struct device *dev); 98: static void adreno_input_work(struct work_struct *work); 99: static int adreno_soft_reset(struct kgsl_device *device); 100: static unsigned int counter_delta(struct kgsl_device *device, 101: unsigned int reg, unsigned int *counter); 102: static struct device_node * 103: adreno_get_gpu_model_node(struct platform_device *pdev); 104: 105: static struct adreno_device device_3d0; 106: static bool adreno_preemption_enable; 107: static u32 kgsl_gpu_sku_override = U32_MAX; 108: static u32 kgsl_gpu_speed_bin_override = U32_MAX; 109: u32 adreno_slice_mask_override = U32_MAX; 110: 111: /* Nice level for the higher priority GPU start thread */ 112: int adreno_wake_nice = -7; 113: 114: /* Number of milliseconds to stay active after a wake on touch */ 115: unsigned int adreno_wake_timeout = 100; 116: 117: static u32 get_ucode_version(const u32 *data) 118: { 119: u32 version; 120: 121: version = data[1]; 122: 123: if ((version & 0xf) != 0xa) MATCH LINES: 216, 220 204: { 205: queue_work(kgsl_driver.lockless_workqueue, &work->work); 206: flush_work(&work->work); 207: return work->ret; 208: } 209: 210: /* 211: * Dispatch firmware_request_nowarn() to a workqueue thread rather than calling 212: * it directly. When the GPU device is first opened, request_firmware() would 213: * otherwise be called from within the path_openat() call chain 214: * (open -> kgsl_open -> ... -> adreno_request_firmware). The kernel tracks 215: * symlink traversal depth in current->nameidata->total_link_count, which is 216: * never reset between nested path_openat() calls. With multiple firmware files, 217: * compressed variants, and symlinks in the firmware search paths (e.g. 218: * /lib -> /usr/lib), total_link_count can reach MAXSYMLINKS (40), causing 219: * request_firmware() to fail with -ELOOP. A workqueue thread has 220: * current->nameidata == NULL, so total_link_count is reset for every lookup. 221: */ 222: int adreno_request_firmware(const struct firmware **fw, const char *name, 223: struct device *device, bool log_error) 224: { 225: struct adreno_fw_work work = { 226: .fw = fw, .name = name, .device = device, 227: }; 228: int ret; 229: 230: INIT_WORK_ONSTACK(&work.work, adreno_fw_load_worker); 231: ret = adreno_fw_dispatch(&work); 232: if (!ret) 233: goto out; 234: 235: work.name = kasprintf(GFP_KERNEL, "qcom/%s", name); 236: if (!work.name) { 237: ret = -ENOMEM; 238: goto out; 239: } 240: 241: ret = adreno_fw_dispatch(&work); 242: if (ret && log_error) 243: dev_err(device, "Firmware request for %s failed with error %d\n", 244: name, ret); MATCH LINES: 387 375: if (!mem_region) { 376: ret = -ENOMEM; 377: goto out; 378: } 379: 380: ret = qcom_mdt_load(dev, fw, firmware_name, GPU_PASID, mem_region, 381: mem_phys, mem_size, NULL); 382: if (ret) { 383: dev_err(dev, "Error %d while loading the MDT\n", ret); 384: goto out; 385: } 386: 387: ret = kgsl_pas_auth_and_reset(GPU_PASID); 388: 389: out: 390: if (mem_region) 391: memunmap(mem_region); 392: 393: release_firmware(fw); 394: 395: if (!ret) 396: adreno_dev->zap_loaded = true; 397: 398: return ret; 399: } 400: 401: #if (IS_ENABLED(CONFIG_QCOM_KGSL_HIBERNATION) || IS_ENABLED(CONFIG_DEEPSLEEP)) 402: static void adreno_zap_shader_unload(struct adreno_device *adreno_dev) 403: { 404: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 405: int ret; 406: 407: if (adreno_dev->zap_loaded) { 408: ret = kgsl_pas_shutdown(GPU_PASID); 409: if (ret) 410: dev_err(&device->pdev->dev, "Error %d while PAS shutdown\n", ret); 411: else MATCH LINES: 603, 606, 607, 608, 612, 617, 620, 622, 623, 625 591: { }, 592: }; 593: 594: static struct input_handler adreno_input_handler = { 595: .event = adreno_input_event, 596: .connect = adreno_input_connect, 597: .disconnect = adreno_input_disconnect, 598: .name = "kgsl", 599: .id_table = adreno_input_ids, 600: }; 601: 602: /* 603: * _soft_reset() - Soft reset GPU 604: * @adreno_dev: Pointer to adreno device 605: * 606: * Soft reset the GPU by doing a AHB write of value 1 to RBBM_SW_RESET 607: * register. This is used when we want to reset the GPU without 608: * turning off GFX power rail. The reset when asserted resets 609: * all the HW logic, restores GPU registers to default state and 610: * flushes out pending VBIF transactions. 611: */ 612: static void _soft_reset(struct adreno_device *adreno_dev) 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) MATCH LINES: 708 696: /* Ensure other CPUs see the decrement */ 697: smp_mb__after_atomic(); 698: 699: return ret; 700: } 701: 702: static irqreturn_t adreno_freq_limiter_irq_handler(int irq, void *data) 703: { 704: struct kgsl_device *device = data; 705: 706: KGSL_PWRCTRL_LOG_FREQLIM(device); 707: 708: reset_control_reset(device->freq_limiter_irq_clear); 709: 710: return IRQ_HANDLED; 711: } 712: 713: irqreturn_t adreno_irq_callbacks(struct adreno_device *adreno_dev, 714: const struct adreno_irq_funcs *funcs, u32 status) 715: { 716: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 717: irqreturn_t ret = IRQ_NONE; 718: 719: /* Loop through all set interrupts and call respective handlers */ 720: while (status) { 721: int i = fls(status) - 1; 722: 723: if (funcs[i].func) { 724: if (adreno_dev->irq_mask & BIT(i)) 725: funcs[i].func(adreno_dev, i); 726: } else 727: dev_crit_ratelimited(device->dev, 728: "Unhandled interrupt bit %x\n", i); 729: 730: ret = IRQ_HANDLED; 731: 732: status &= ~BIT(i); MATCH LINES: 1795, 1799, 1818, 1819, 1825 1783: return "AQE"; 1784: case HFI_FEATURE_FAST_CONTEXT_DESTROY: 1785: return "FAST_CONTEXT_DESTROY"; 1786: } 1787: return "unknown"; 1788: } 1789: 1790: static void adreno_regmap_op_preaccess(struct kgsl_regmap_region *region) 1791: { 1792: struct kgsl_device *device = region->priv; 1793: /* 1794: * kgsl panic notifier will be called in atomic context to get 1795: * GPU snapshot. Also panic handler will skip snapshot dumping 1796: * incase GPU is in SLUMBER state. So we can safely ignore the 1797: * kgsl_pre_hwaccess(). 1798: */ 1799: if (!device->snapshot_atomic && !in_interrupt()) 1800: kgsl_pre_hwaccess(device); 1801: } 1802: 1803: static const struct kgsl_regmap_ops adreno_regmap_ops = { 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++) { 1843: struct adreno_ringbuffer *rb = &adreno_dev->ringbuffers[i]; 1844: 1845: INIT_LIST_HEAD(&rb->events.group); 1846: } 1847: 1848: /* 1849: * Some GPUs needs specific alignment for UCHE GMEM base address. MATCH LINES: 1928, 1930, 1932, 1937, 1945, 1948, 1950 1916: if (pd->prepared_count) { 1917: dev_err_ratelimited(device->dev, 1918: "unexpected cx pd prepared_count:%d event:%lu\n", 1919: pd->prepared_count, event); 1920: return NOTIFY_BAD; 1921: } 1922: } 1923: 1924: if (event == PM_SUSPEND_PREPARE) { 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; 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", MATCH LINES: 2230 2218: goto err_remove_llcc; 2219: 2220: status = adreno_irq_setup(pdev, adreno_dev); 2221: if (status < 0) 2222: goto err_unbind; 2223: 2224: device->pwrctrl.interrupt_num = status; 2225: 2226: device->freq_limiter_intr_num = kgsl_request_irq_optional(pdev, "freq_limiter_irq", 2227: adreno_freq_limiter_irq_handler, device); 2228: 2229: device->freq_limiter_irq_clear = 2230: devm_reset_control_get(&pdev->dev, "freq_limiter_irq_clear"); 2231: 2232: status = kgsl_device_platform_probe(device); 2233: if (status) 2234: goto err_unbind; 2235: 2236: adreno_fence_trace_array_init(device); 2237: 2238: /* Add CX_DBGC block to the regmap*/ 2239: kgsl_regmap_add_region(&device->regmap, pdev, "cx_dbgc", -EINVAL, NULL, NULL); 2240: 2241: res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "aperture"); 2242: if (res) { 2243: device->smmu_aperture_virt = devm_ioremap(dev, res->start, 2244: resource_size(res)); 2245: if (!device->smmu_aperture_virt) 2246: dev_warn(dev, "aperture ioremap failed\n"); 2247: } 2248: 2249: if (kgsl_regmap_add_region(&device->regmap, pdev, "isense_cntl", -EINVAL, NULL, NULL) == 0) 2250: adreno_dev->isense_reg_mapped = true; 2251: 2252: /* Allocate the memstore for storing timestamps and other useful info */ 2253: 2254: if (ADRENO_FEATURE(adreno_dev, ADRENO_APRIV)) MATCH LINES: 2278, 2279, 2286, 2289, 2325, 2329 2266: kgsl_device_platform_remove(device); 2267: goto err_unbind; 2268: } 2269: 2270: /* Initialize UBWC mode and HBB */ 2271: status = adreno_init_ubwc(adreno_dev); 2272: if (status) { 2273: trace_array_put(device->fence_trace_array); 2274: kgsl_device_platform_remove(device); 2275: goto err_unbind; 2276: } 2277: 2278: /* Initialize the snapshot engine */ 2279: size = adreno_dev->gpucore->snapshot_size; 2280: 2281: /* 2282: * Use a default size if one wasn't specified, but print a warning so 2283: * the developer knows to fix it 2284: */ 2285: 2286: if (WARN(!size, "The snapshot size was not specified in the gpucore\n")) 2287: size = SZ_1M; 2288: 2289: kgsl_device_snapshot_probe(device, size); 2290: 2291: adreno_debugfs_init(adreno_dev); 2292: 2293: adreno_dev->perfcounter = false; 2294: 2295: adreno_sysfs_init(adreno_dev); 2296: 2297: if (!ADRENO_FEATURE(adreno_dev, ADRENO_GMU_BASED_DCVS)) 2298: device->host_based_dcvs = true; 2299: else if (ADRENO_FEATURE(adreno_dev, ADRENO_DCVS_PROFILE)) 2300: adreno_dev->dcvs_profile_enabled = true; 2301: 2302: kgsl_pwrscale_init(device, pdev); 2303: 2304: if (ADRENO_FEATURE(adreno_dev, ADRENO_L3_VOTE)) 2305: device->l3_vote = true; 2306: 2307: #ifdef CONFIG_INPUT 2308: 2309: if (!of_property_read_bool(pdev->dev.of_node, 2310: "qcom,disable-wake-on-touch")) { 2311: adreno_input_handler.private = device; 2312: /* 2313: * It isn't fatal if we cannot register the input handler. Sad, 2314: * perhaps, but not fatal 2315: */ 2316: if (input_register_handler(&adreno_input_handler)) { 2317: adreno_input_handler.private = NULL; 2318: dev_err(device->dev, 2319: "Unable to register the input handler\n"); 2320: } 2321: } 2322: #endif 2323: 2324: /* 2325: * With power domains, we cannot perform recovery during a concurrent system suspend because 2326: * system suspend path increments power domain prepared_count, which prevents successful 2327: * toggling of the power domain gdsc while system is in suspend path. Hence, get 2328: * notifications when system has come out of suspend completely, so that we can perform 2329: * fault recovery. 2330: */ 2331: if (device->pwrctrl.gx_pd || device->pwrctrl.gmu_cx_pd) { 2332: adreno_dev->pm_nb.notifier_call = adreno_pm_notifier; 2333: register_pm_notifier(&adreno_dev->pm_nb); 2334: } 2335: 2336: kgsl_qcom_va_md_register(device); 2337: 2338: KGSL_BOOT_MARKER("GPU Ready"); 2339: 2340: return 0; 2341: 2342: err_unbind: 2343: component_unbind_all(dev, NULL); 2344: 2345: err_remove_llcc: 2346: if (!IS_ERR_OR_NULL(adreno_dev->gpu_llc_slice)) 2347: llcc_slice_putd(adreno_dev->gpu_llc_slice); 2348: 2349: if (!IS_ERR_OR_NULL(adreno_dev->gpuhtw_llc_slice)) 2350: llcc_slice_putd(adreno_dev->gpuhtw_llc_slice); 2351: 2352: err_bus_close: 2353: kgsl_bus_close(device); MATCH LINES: 2524, 2525, 2537 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: */ 2547: clear_bit(ADRENO_DEVICE_CX_TIMER_INITIALIZED, &adreno_dev->priv); 2548: kgsl_reclaim_close(); 2549: kthread_flush_worker(device->events_worker); 2550: flush_workqueue(kgsl_driver.lockless_workqueue); 2551: 2552: return status; 2553: } 2554: 2555: void adreno_create_profile_buffer(struct adreno_device *adreno_dev) 2556: { 2557: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2558: unsigned int priv = 0; 2559: 2560: if (ADRENO_FEATURE(adreno_dev, ADRENO_APRIV)) 2561: priv = KGSL_MEMDESC_PRIVILEGED; MATCH LINES: 2883, 2899, 2901, 2915, 2923, 2924, 2925, 2927, 2928, 2933 2871: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2872: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 2873: int status; 2874: unsigned int state = device->state; 2875: bool gdsc_left_on; 2876: 2877: /* make sure ADRENO_DEVICE_STARTED is not set here */ 2878: WARN_ON(test_bit(ADRENO_DEVICE_STARTED, &adreno_dev->priv)); 2879: 2880: gdsc_left_on = gdscs_left_on(device); 2881: 2882: /* Clear any GPU faults that might have been left over */ 2883: adreno_clear_gpu_fault(adreno_dev); 2884: 2885: /* Put the GPU in a responsive state */ 2886: status = kgsl_pwrctrl_change_state(device, KGSL_STATE_AWARE); 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 2924: * this field allows us to take a new snapshot for the next failure 2925: * if we are prioritizing the first unrecoverable snapshot. 2926: */ 2927: if (device->snapshot) 2928: device->snapshot->recovered = true; 2929: 2930: /* Start the dispatcher */ 2931: adreno_dispatcher_start(device); 2932: 2933: device->reset_counter++; 2934: 2935: set_bit(ADRENO_DEVICE_STARTED, &adreno_dev->priv); 2936: 2937: /* 2938: * There is a possible deadlock scenario during kgsl firmware reading 2939: * (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl 2940: * device mutex is held and then firmware_request_nowarn is called for reading 2941: * firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock. 2942: * Whereas in case of devfreq update calls triggered by thermal/bcl or 2943: * devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then 2944: * tries to take kgsl device mutex as part of get_dev_status/target 2945: * calls. This results in deadlock when both thread are unable to acquire 2946: * the mutex held by other thread. Enable devfreq updates now as we are 2947: * done reading all firmware files. 2948: */ 2949: device->pwrscale.devfreq_enabled = true; 2950: 2951: return 0; 2952: 2953: error_pwr_off: 2954: /* set the state back to original state */ 2955: kgsl_pwrctrl_change_state(device, state); 2956: 2957: return status; MATCH LINES: 3022, 3024, 3026, 3027, 3030, 3037, 3038, 3041, 3042, 3046, 3049, 3054, 3067, 3072 3010: adreno_ringbuffer_stop(adreno_dev); 3011: 3012: adreno_llcc_slice_deactivate(adreno_dev); 3013: 3014: adreno_set_active_ctxs_null(adreno_dev); 3015: 3016: clear_bit(ADRENO_DEVICE_STARTED, &adreno_dev->priv); 3017: 3018: return error; 3019: } 3020: 3021: /** 3022: * adreno_reset() - Helper function to reset the GPU 3023: * @device: Pointer to the KGSL device structure for the GPU 3024: * @fault: Type of fault. Needed to skip soft reset for MMU fault 3025: * 3026: * Try to reset the GPU to recover from a fault. First, try to do a low latency 3027: * soft reset. If the soft reset fails for some reason, then bring out the big 3028: * guns and toggle the footswitch. 3029: */ 3030: int adreno_reset(struct kgsl_device *device, int fault) 3031: { 3032: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 3033: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 3034: int ret = -EINVAL; 3035: int i; 3036: 3037: if (gpudev->reset) 3038: return adreno_gpudev_reset(adreno_dev); 3039: 3040: /* 3041: * Try soft reset first Do not do soft reset for a IOMMU fault (because 3042: * the IOMMU hardware needs a reset too) 3043: */ 3044: 3045: if (!(fault & ADRENO_IOMMU_STALL_ON_PAGE_FAULT)) 3046: ret = adreno_soft_reset(device); 3047: 3048: if (ret) { 3049: /* If soft reset failed/skipped, then pull the power */ 3050: kgsl_pwrctrl_change_state(device, KGSL_STATE_INIT); 3051: /* since device is officially off now clear start bit */ 3052: clear_bit(ADRENO_DEVICE_STARTED, &adreno_dev->priv); 3053: 3054: /* Try to reset the device */ 3055: ret = adreno_start(device, 0); 3056: 3057: for (i = 0; ret && i < 4; i++) { 3058: msleep(20); 3059: ret = adreno_start(device, 0); 3060: } 3061: 3062: if (ret) 3063: return ret; 3064: 3065: if (i != 0) 3066: dev_warn(device->dev, 3067: "Device hard reset tried %d tries\n", i); 3068: } 3069: 3070: /* 3071: * If active_cnt is non-zero then the system was active before 3072: * going into a reset - put it back in that state 3073: */ 3074: 3075: if (atomic_read(&device->active_cnt)) 3076: kgsl_pwrctrl_change_state(device, KGSL_STATE_ACTIVE); 3077: 3078: return ret; 3079: } 3080: 3081: static int copy_prop(struct kgsl_device_getproperty *param, 3082: void *src, size_t size) 3083: { 3084: if (copy_to_user(param->value, src, 3085: min_t(u32, size, param->sizebytes))) 3086: return -EFAULT; 3087: 3088: return 0; 3089: } 3090: 3091: static int adreno_prop_device_info(struct kgsl_device *device, 3092: struct kgsl_device_getproperty *param) 3093: { 3094: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 3095: struct kgsl_devinfo devinfo = { 3096: .device_id = device->id + 1, MATCH LINES: 3638, 3639, 3641, 3642, 3645, 3662, 3666, 3669, 3695, 3699, 3703 3626: case KGSL_PROP_DCVS_PROFILE: 3627: status = adreno_set_dcvs_profile(dev_priv, value, sizebytes); 3628: break; 3629: default: 3630: status = adreno_default_setproperty(dev_priv, type, value, sizebytes); 3631: break; 3632: } 3633: 3634: return status; 3635: } 3636: 3637: /* 3638: * adreno_soft_reset - Do a soft reset of the GPU hardware 3639: * @device: KGSL device to soft reset 3640: * 3641: * "soft reset" the GPU hardware - this is a fast path GPU reset 3642: * The GPU hardware is reset but we never pull power so we can skip 3643: * a lot of the standard adreno_stop/adreno_start sequence 3644: */ 3645: static int adreno_soft_reset(struct kgsl_device *device) 3646: { 3647: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 3648: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 3649: int ret; 3650: 3651: if (gpudev->clear_pending_transactions) { 3652: ret = gpudev->clear_pending_transactions(adreno_dev); 3653: if (ret) 3654: return ret; 3655: } 3656: 3657: kgsl_pwrctrl_change_state(device, KGSL_STATE_AWARE); 3658: adreno_set_active_ctxs_null(adreno_dev); 3659: 3660: adreno_irqctrl(adreno_dev, 0); 3661: 3662: adreno_clear_gpu_fault(adreno_dev); 3663: /* since device is oficially off now clear start bit */ 3664: clear_bit(ADRENO_DEVICE_STARTED, &adreno_dev->priv); 3665: 3666: /* save physical performance counter values before GPU soft reset */ 3667: adreno_perfcounter_save(adreno_dev); 3668: 3669: _soft_reset(adreno_dev); 3670: 3671: /* Clear the busy_data stats - we're starting over from scratch */ 3672: adreno_dev->busy_data.gpu_busy = 0; 3673: adreno_dev->busy_data.bif_ram_cycles = 0; 3674: adreno_dev->busy_data.bif_ram_cycles_read_ch1 = 0; 3675: adreno_dev->busy_data.bif_ram_cycles_write_ch0 = 0; 3676: adreno_dev->busy_data.bif_ram_cycles_write_ch1 = 0; 3677: adreno_dev->busy_data.bif_starved_ram = 0; 3678: adreno_dev->busy_data.bif_starved_ram_ch1 = 0; 3679: 3680: /* Reinitialize the GPU */ 3681: gpudev->start(adreno_dev); 3682: 3683: /* Re-initialize the coresight registers if applicable */ 3684: adreno_coresight_start(adreno_dev); 3685: 3686: /* Enable IRQ */ 3687: adreno_irqctrl(adreno_dev, 1); 3688: 3689: /* stop all ringbuffers to cancel RB events */ 3690: adreno_ringbuffer_stop(adreno_dev); 3691: 3692: /* Start the ringbuffer(s) again */ 3693: ret = gpudev->rb_start(adreno_dev); 3694: if (ret == 0) { 3695: device->reset_counter++; 3696: set_bit(ADRENO_DEVICE_STARTED, &adreno_dev->priv); 3697: } 3698: 3699: /* Restore physical performance counter values after soft reset */ 3700: adreno_perfcounter_restore(adreno_dev); 3701: 3702: if (ret) 3703: dev_err(device->dev, "Device soft reset failed: %d\n", ret); 3704: 3705: return ret; 3706: } 3707: 3708: bool adreno_isidle(struct adreno_device *adreno_dev) 3709: { 3710: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 3711: struct adreno_ringbuffer *rb; 3712: int i; 3713: 3714: if (!kgsl_state_is_awake(KGSL_DEVICE(adreno_dev))) 3715: return true; 3716: 3717: /* 3718: * wptr is updated when we add commands to ringbuffer, add a barrier 3719: * to make sure updated wptr is compared to rptr 3720: */ 3721: smp_mb(); 3722: 3723: /* 3724: * ringbuffer is truly idle when all ringbuffers read and write 3725: * pointers are equal 3726: */ 3727: MATCH LINES: 3755, 3768 3743: int adreno_spin_idle(struct adreno_device *adreno_dev, unsigned int timeout) 3744: { 3745: unsigned long wait = jiffies + msecs_to_jiffies(timeout); 3746: 3747: do { 3748: /* 3749: * If we fault, stop waiting and return an error. The dispatcher 3750: * will clean up the fault from the work queue, but we need to 3751: * make sure we don't block it by waiting for an idle that 3752: * will never come. 3753: */ 3754: 3755: if (adreno_gpu_fault(adreno_dev) != 0) 3756: return -EDEADLK; 3757: 3758: if (adreno_isidle(adreno_dev)) 3759: return 0; 3760: 3761: } while (time_before(jiffies, wait)); 3762: 3763: /* 3764: * Under rare conditions, preemption can cause the while loop to exit 3765: * without checking if the gpu is idle. check one last time before we 3766: * return failure. 3767: */ 3768: if (adreno_gpu_fault(adreno_dev) != 0) 3769: return -EDEADLK; 3770: 3771: if (adreno_isidle(adreno_dev)) 3772: return 0; 3773: 3774: return -ETIMEDOUT; 3775: } 3776: 3777: /** 3778: * adreno_wait_idle() - wait for the GPU hardware to go idle 3779: * @device: Pointer to the KGSL device structure for the GPU 3780: * 3781: * Wait up to ADRENO_IDLE_TIMEOUT milliseconds for the GPU hardware to go quiet. 3782: * Caller must hold the device mutex, and must not hold the dispatcher mutex. 3783: */ 3784: 3785: int adreno_wait_idle(struct kgsl_device *device) 3786: { 3787: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 3788: int ret; 3789: 3790: /* 3791: * Make sure the device mutex is held so the dispatcher can't send any 3792: * more commands to the hardware MATCH LINES: 4350, 4358 4338: return; 4339: 4340: adreno_dev->dispatch_ops->queue_context(adreno_dev, 4341: ADRENO_CONTEXT(context)); 4342: } 4343: 4344: bool adreno_smmu_is_stalled(struct adreno_device *adreno_dev) 4345: { 4346: u32 fault, val; 4347: 4348: /* 4349: * RBBM_STATUS3:SMMU_STALLED_ON_FAULT (BIT 24) to tells if GPU 4350: * encountered a pagefault. Gen8 page fault status checked from 4351: * the software condition as RBBM_STATUS3 is not available. 4352: */ 4353: if (ADRENO_GPUREV(adreno_dev) < ADRENO_REV_GEN8_0_0) { 4354: adreno_readreg(adreno_dev, ADRENO_REG_RBBM_STATUS3, &val); 4355: return (val & BIT(24)); 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; MATCH LINES: 4726 4714: .first_open = adreno_first_open, 4715: .start = adreno_start, 4716: .stop = adreno_stop, 4717: .last_close = adreno_last_close, 4718: .getproperty = adreno_getproperty, 4719: .getproperty_compat = adreno_getproperty_compat, 4720: .waittimestamp = adreno_waittimestamp, 4721: .readtimestamp = adreno_readtimestamp, 4722: .queue_cmds = adreno_queue_cmds, 4723: .ioctl = adreno_ioctl, 4724: .compat_ioctl = adreno_compat_ioctl, 4725: .power_stats = adreno_power_stats, 4726: .snapshot = adreno_snapshot, 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, --- FILE: \adreno.h | HITS: 41 --- MATCH LINES: 157, 158 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 */ 174: #define ADRENO_DMS BIT(17) 175: /* AQE supported on this target */ 176: #define ADRENO_AQE BIT(18) 177: /* Warm Boot supported on this target */ 178: #define ADRENO_GMU_WARMBOOT BIT(19) 179: /* The GPU supports CLX */ 180: #define ADRENO_CLX BIT(20) 181: /* Enable GMU support for GMU based thermal mitigation */ 182: #define ADRENO_GMU_THERMAL_MITIGATION BIT(21) MATCH LINES: 344 332: ADRENO_REV_GEN8_11_0 = ADRENO_GPUREV_VALUE(8, 11, 0), 333: ADRENO_REV_GEN8_11_1 = ADRENO_GPUREV_VALUE(8, 11, 1), 334: ADRENO_REV_GEN8_14_0 = ADRENO_GPUREV_VALUE(8, 14, 0), 335: }; 336: 337: #define ADRENO_SOFT_FAULT BIT(0) 338: #define ADRENO_HARD_FAULT BIT(1) 339: #define ADRENO_TIMEOUT_FAULT BIT(2) 340: #define ADRENO_IOMMU_STALL_ON_PAGE_FAULT BIT(3) 341: #define ADRENO_PREEMPT_FAULT BIT(4) 342: #define ADRENO_GMU_FAULT BIT(5) 343: #define ADRENO_CTX_DETATCH_TIMEOUT_FAULT BIT(6) 344: #define ADRENO_GMU_FAULT_SKIP_SNAPSHOT BIT(7) 345: #define ADRENO_FAULT_TYPES 8 346: 347: /** 348: * Bit fields for GPU_CX_MISC_CX_AHB_*_CNTL registers 349: * AHB_TXFRTIMEOUTRELEASE [8:8] 350: * AHB_TXFRTIMEOUTENABLE [9:9] 351: * AHB_RESPONDERROR [11:11] 352: * AHB_ERRORSTATUSENABLE [12:12] 353: */ 354: #define ADRENO_AHB_CNTL_DEFAULT (BIT(12) | BIT(11) | BIT(9) | BIT(8)) 355: 356: enum adreno_pipe_type { 357: PIPE_NONE = 0, 358: PIPE_BR = 1, 359: PIPE_BV = 2, 360: PIPE_LPAC = 3, 361: PIPE_AQE0 = 4, 362: PIPE_AQE1 = 5, 363: PIPE_DDE_BR = 6, 364: PIPE_DDE_BV = 7, 365: }; 366: 367: /* number of throttle counters for DCVS adjustment */ 368: #define ADRENO_GPMU_THROTTLE_COUNTERS 4 MATCH LINES: 598, 599 586: * @compatible: If specified, use the compatible string to match the 587: * device 588: */ 589: const char *compatible; 590: u64 features; 591: /** @features_standard: Features only supported on standard kernel */ 592: u64 features_standard; 593: const struct adreno_gpudev *gpudev; 594: const struct adreno_perfcounters *perfcounters; 595: u32 uche_gmem_alignment; 596: size_t gmem_size; 597: u32 bus_width; 598: /** @snapshot_size: Size of the static snapshot region in bytes */ 599: u32 snapshot_size; 600: /** @num_ddr_channels: Number of DDR channels */ 601: u32 num_ddr_channels; 602: /** 603: * @chipid: Optional GPU chip ID for publically released chipsets; required when 604: * using standard devicetree bindings. 605: */ 606: u32 chipid; 607: /** 608: * @speedbins: Optional table of fuse to speedbin mappings 609: * 610: * Consists of pairs of fuse, index mappings, terminated with 611: * {SHRT_MAX, 0} sentinel. 612: */ 613: struct kgsl_speedbin *speedbins; 614: /** @ubwc_mode: Supported UBWC mode */ 615: u32 ubwc_mode; 616: /** @mal: Minimum access length */ 617: u32 mal; 618: /** @highest_bank_bit: The bit of the highest DDR bank */ 619: u32 highest_bank_bit; 620: /** @gpu_model: Gpu model name */ 621: const char *gpu_model; 622: /** @smmu_aperture: List of registers and values to write for SMMU aperture */ 623: const struct kgsl_regmap_list *smmu_aperture; MATCH LINES: 674 662: * @priv: Holds the private flags specific to the adreno_device 663: * @chipid: Chip ID specific to the GPU 664: * @gpucore: Pointer to the adreno_gpu_core structure 665: * @gpmu_cmds_size: Length of gpmu cmd stream 666: * @gpmu_cmds: gpmu cmd stream 667: * @ringbuffers: Array of pointers to adreno_ringbuffers 668: * @num_ringbuffers: Number of ringbuffers for the GPU 669: * @cur_rb: Pointer to the current ringbuffer 670: * @next_rb: Ringbuffer we are switching to during preemption 671: * @prev_rb: Ringbuffer we are switching from during preemption 672: * @ft_policy: Defines the fault tolerance policy 673: * @long_ib_detect: Long IB detection availability 674: * @cooperative_reset: Indicates if graceful death handshake is enabled 675: * between GMU and GPU 676: * @profile: Container for adreno profiler information 677: * @dispatcher: Container for adreno GPU dispatcher 678: * @pwron_fixup: Command buffer to run a post-power collapse shader workaround 679: * @pwron_fixup_dwords: Number of dwords in the command buffer 680: * @input_work: Work struct for turning on the GPU after a touch event 681: * @busy_data: Struct holding GPU VBIF busy stats 682: * @ram_cycles_lo: Number of DDR clock cycles for the monitor session (Only 683: * DDR channel 0 read cycles in case of GBIF) 684: * @ram_cycles_lo_ch1_read: Number of DDR channel 1 Read clock cycles for 685: * the monitor session 686: * @ram_cycles_lo_ch0_write: Number of DDR channel 0 Write clock cycles for 687: * the monitor session 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 MATCH LINES: 737 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]; 731: int num_ringbuffers; 732: struct adreno_ringbuffer *cur_rb; 733: struct adreno_ringbuffer *next_rb; 734: struct adreno_ringbuffer *prev_rb; 735: unsigned long ft_policy; 736: bool long_ib_detect; 737: bool cooperative_reset; 738: struct adreno_profile profile; 739: struct adreno_dispatcher dispatcher; 740: struct kgsl_memdesc *pwron_fixup; 741: unsigned int pwron_fixup_dwords; 742: struct work_struct input_work; 743: struct adreno_busy_data busy_data; 744: unsigned int ram_cycles_lo; 745: unsigned int ram_cycles_lo_ch1_read; 746: unsigned int ram_cycles_lo_ch0_write; 747: unsigned int ram_cycles_lo_ch1_write; 748: unsigned int starved_ram_lo; 749: unsigned int starved_ram_lo_ch1; 750: atomic_t halt; 751: atomic_t pending_irq_refcnt; 752: struct dentry *ctx_d_debugfs; 753: /** @lm_enabled: True if limits management is enabled for this target */ 754: bool lm_enabled; 755: /** @acd_enabled: True if acd is enabled for this target */ 756: bool acd_enabled; 757: /** @hwcg_enabled: True if hardware clock gating is enabled */ 758: bool hwcg_enabled; 759: /** @throttling_enabled: True if LM throttling is enabled on a5xx */ 760: bool throttling_enabled; 761: /** @sptp_pc_enabled: True if SPTP power collapse is enabled on a5xx */ MATCH LINES: 905, 906, 909, 910, 915, 947, 948 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 */ 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; 935: /** @adreno_ubwc_props: Container of all UBWC props required to program NC_MODE_CNTL 936: * registers 937: */ 938: struct adreno_ubwc_props ubwc_props; 939: /** @multidraw_mode: Whether PC unroll is enabled for multidraw **/ 940: u32 multidraw_mode; 941: /** @viz_flush_draw_count: Draw count to flush visibility stream **/ 942: u32 viz_flush_draw_count; 943: /** @viz_flush_prim_count: Prim count to flush visibility stream **/ 944: u32 viz_flush_prim_count; 945: }; 946: 947: /* Time to wait for suspend recovery gate to complete */ 948: #define ADRENO_SUSPEND_RECOVERY_GATE_TIMEOUT_MS 5000 949: 950: /** 951: * enum adreno_device_flags - Private flags for the adreno_device 952: * @ADRENO_DEVICE_PWRON - Set during init after a power collapse 953: * @ADRENO_DEVICE_PWRON_FIXUP - Set if the target requires the shader fixup 954: * after power collapse 955: * @ADRENO_DEVICE_STARTED - Set if the device start sequence is in progress 956: * @ADRENO_DEVICE_FAULT - Set if the device is currently in fault (and shouldn't 957: * send any more commands to the ringbuffer) 958: * @ADRENO_DEVICE_DRAWOBJ_PROFILE - Set if the device supports drawobj 959: * profiling via the ALWAYSON counter 960: * @ADRENO_DEVICE_PREEMPTION - Turn on/off preemption 961: * @ADRENO_DEVICE_SOFT_FAULT_DETECT - Set if soft fault detect is enabled 962: * @ADRENO_DEVICE_GPMU_INITIALIZED - Set if GPMU firmware initialization succeed 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, MATCH LINES: 987, 988 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 1000: * @started: Number of GPU ticks at start of the drawobj 1001: * @retired: Number of GPU ticks at the end of the drawobj 1002: * @ctx_start: CP_ALWAYS_ON_CONTEXT tick at start of the drawobj 1003: * @ctx_end: CP_ALWAYS_ON_CONTEXT tick at end of the drawobj 1004: */ 1005: struct adreno_drawobj_profile_entry { 1006: uint64_t started; 1007: uint64_t retired; 1008: uint64_t ctx_start; 1009: uint64_t ctx_end; 1010: }; 1011: 1012: #define ADRENO_DRAWOBJ_PROFILE_OFFSET(_index, _member) \ MATCH LINES: 1055, 1090, 1091, 1104, 1108, 1110, 1111, 1112 1043: ADRENO_REG_CP_RB_WPTR, 1044: ADRENO_REG_CP_ME_CNTL, 1045: ADRENO_REG_CP_RB_CNTL, 1046: ADRENO_REG_CP_IB1_BASE, 1047: ADRENO_REG_CP_IB1_BASE_HI, 1048: ADRENO_REG_CP_IB1_BUFSZ, 1049: ADRENO_REG_CP_IB2_BASE, 1050: ADRENO_REG_CP_IB2_BASE_HI, 1051: ADRENO_REG_CP_IB2_BUFSZ, 1052: ADRENO_REG_RBBM_STATUS, 1053: ADRENO_REG_RBBM_STATUS3, 1054: ADRENO_REG_RBBM_INT_0_MASK, 1055: ADRENO_REG_RBBM_SW_RESET_CMD, 1056: ADRENO_REG_GMU_AO_HOST_INTERRUPT_MASK, 1057: ADRENO_REG_GMU_GMU2HOST_INTR_MASK, 1058: ADRENO_REG_REGISTER_MAX, 1059: }; 1060: 1061: #define ADRENO_REG_UNUSED 0xFFFFFFFF 1062: #define ADRENO_REG_SKIP 0xFFFFFFFE 1063: #define ADRENO_REG_DEFINE(_offset, _reg)[_offset] = _reg 1064: 1065: struct adreno_irq_funcs { 1066: void (*func)(struct adreno_device *adreno_dev, int mask); 1067: }; 1068: #define ADRENO_IRQ_CALLBACK(_c) { .func = _c } 1069: 1070: /* 1071: * struct adreno_debugbus_block - Holds info about debug buses of a chip 1072: * @block_id: Bus identifier 1073: * @dwords: Number of dwords of data that this block holds 1074: */ 1075: struct adreno_debugbus_block { 1076: unsigned int block_id; 1077: unsigned int dwords; 1078: }; 1079: 1080: struct adreno_gpudev { 1081: /* 1082: * These registers are in a different location on different devices, 1083: * so define them in the structure and use them as variables. 1084: */ 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); MATCH LINES: 1260, 1261, 1264 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); 1263: 1264: int adreno_reset(struct kgsl_device *device, int fault); 1265: 1266: void adreno_fault_skipcmd_detached(struct adreno_device *adreno_dev, 1267: struct adreno_context *drawctxt, 1268: struct kgsl_drawobj *drawobj); 1269: 1270: void adreno_hang_int_callback(struct adreno_device *adreno_dev, int bit); 1271: void adreno_cp_callback(struct adreno_device *adreno_dev, int bit); 1272: 1273: int adreno_sysfs_init(struct adreno_device *adreno_dev); 1274: 1275: void adreno_irqctrl(struct adreno_device *adreno_dev, int state); 1276: 1277: long adreno_ioctl_perfcounter_get(struct kgsl_device_private *dev_priv, 1278: unsigned int cmd, void *data); 1279: 1280: long adreno_ioctl_perfcounter_put(struct kgsl_device_private *dev_priv, 1281: unsigned int cmd, void *data); 1282: 1283: bool adreno_gx_is_on(struct adreno_device *adreno_dev); 1284: 1285: u64 adreno_read_cx_timer(struct adreno_device *adreno_dev); 1286: 1287: /** 1288: * adreno_active_count_get - Wrapper for target specific active count get MATCH LINES: 1684, 1690, 1698, 1703, 1714, 1719, 1737, 1744 1672: */ 1673: static inline void adreno_write_gmureg(struct adreno_device *adreno_dev, 1674: enum adreno_regs offset_name, unsigned int val) 1675: { 1676: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 1677: 1678: if (adreno_checkreg_off(adreno_dev, offset_name)) 1679: gmu_core_regwrite(KGSL_DEVICE(adreno_dev), 1680: gpudev->reg_offsets[offset_name], val); 1681: } 1682: 1683: /** 1684: * adreno_gpu_fault() - Return the current state of the GPU 1685: * @adreno_dev: A pointer to the adreno_device to query 1686: * 1687: * Return 0 if there is no fault or positive with the last type of fault that 1688: * occurred 1689: */ 1690: static inline unsigned int adreno_gpu_fault(struct adreno_device *adreno_dev) 1691: { 1692: /* make sure we're reading the latest value */ 1693: smp_rmb(); 1694: return atomic_read(&adreno_dev->scheduler_fault); 1695: } 1696: 1697: /** 1698: * adreno_set_gpu_fault() - Set the current fault status of the GPU 1699: * @adreno_dev: A pointer to the adreno_device to set 1700: * @state: fault state to set 1701: * 1702: */ 1703: static inline void adreno_set_gpu_fault(struct adreno_device *adreno_dev, 1704: int state) 1705: { 1706: /* only set the fault bit w/o overwriting other bits */ 1707: atomic_or(state, &adreno_dev->scheduler_fault); 1708: 1709: /* make sure other CPUs see the update */ 1710: smp_wmb(); 1711: } 1712: 1713: /** 1714: * adreno_clear_gpu_fault() - Clear the GPU fault register 1715: * @adreno_dev: A pointer to an adreno_device structure 1716: * 1717: * Clear the GPU fault status for the adreno device 1718: */ 1719: static inline void adreno_clear_gpu_fault(struct adreno_device *adreno_dev) 1720: { 1721: atomic_set(&adreno_dev->scheduler_fault, 0); 1722: 1723: /* make sure other CPUs see the update */ 1724: smp_wmb(); 1725: } 1726: 1727: /** 1728: * adreno_scheduler_queue - Queue the scheduler kthread 1729: * @adreno_dev: Adreno device handle 1730: */ 1731: static inline void adreno_scheduler_queue(struct adreno_device *adreno_dev) 1732: { 1733: kthread_queue_work(adreno_dev->scheduler_worker, &adreno_dev->scheduler_work); 1734: } 1735: 1736: /** 1737: * adreno_scheduler_fault() - Set GPU fault and trigger fault recovery 1738: * @adreno_dev: A pointer to an adreno_device structure 1739: * @fault: Type of fault 1740: */ 1741: static inline void adreno_scheduler_fault(struct adreno_device *adreno_dev, 1742: u32 fault) 1743: { 1744: adreno_set_gpu_fault(adreno_dev, fault); 1745: adreno_scheduler_queue(adreno_dev); 1746: } 1747: 1748: /** 1749: * adreno_gpu_halt() - Return the GPU halt refcount 1750: * @adreno_dev: A pointer to the adreno_device 1751: */ 1752: static inline int adreno_gpu_halt(struct adreno_device *adreno_dev) 1753: { 1754: /* make sure we're reading the latest value */ 1755: smp_rmb(); 1756: return atomic_read(&adreno_dev->halt); 1757: } 1758: 1759: 1760: /** 1761: * adreno_clear_gpu_halt() - Clear the GPU halt refcount 1762: * @adreno_dev: A pointer to the adreno_device 1763: */ 1764: static inline void adreno_clear_gpu_halt(struct adreno_device *adreno_dev) 1765: { 1766: atomic_set(&adreno_dev->halt, 0); 1767: 1768: /* make sure other CPUs see the update */ MATCH LINES: 2397, 2400, 2405, 2406, 2407, 2408 2385: { 2386: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2387: 2388: if (!(adreno_dev->irq_mask || device->pwrctrl.interrupt_num)) 2389: return; 2390: 2391: devm_free_irq(&device->pdev->dev, device->pwrctrl.interrupt_num, device); 2392: adreno_dev->irq_mask = 0; 2393: device->pwrctrl.interrupt_num = 0; 2394: } 2395: 2396: /** 2397: * adreno_gpudev_reset - Adreno gpu device reset 2398: * @adreno_dev: Adreno device handle 2399: */ 2400: static inline int adreno_gpudev_reset(struct adreno_device *adreno_dev) 2401: { 2402: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 2403: int ret = -ENODEV; 2404: 2405: if (gpudev->reset) { 2406: set_bit(ADRENO_DEVICE_RESET_RECOVERY, &adreno_dev->priv); 2407: ret = gpudev->reset(adreno_dev); 2408: clear_bit(ADRENO_DEVICE_RESET_RECOVERY, &adreno_dev->priv); 2409: } 2410: 2411: return ret; 2412: } 2413: 2414: /** 2415: * adreno_gmem_size - Returns the GMEM size 2416: * @adreno_dev Adreno device handle 2417: * 2418: * Return: Size of GMEM in bytes 2419: */ 2420: static inline u32 adreno_gmem_size(struct adreno_device *adreno_dev) 2421: { 2422: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 2423: 2424: if (gpudev->get_gmem_size) 2425: return gpudev->get_gmem_size(adreno_dev); 2426: 2427: return adreno_dev->gpucore->gmem_size; 2428: } 2429: #endif /*__ADRENO_H */ --- FILE: \adreno_a5xx.c | HITS: 24 --- MATCH LINES: 33, 62 21: #include "adreno_pm4types.h" 22: #include "adreno_trace.h" 23: #include "kgsl_trace.h" 24: #include "kgsl_util.h" 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) | \ 62: (1 << A5XX_INT_MISC_HANG_DETECT) | \ 63: (1 << A5XX_INT_UCHE_OOB_ACCESS) | \ 64: (1 << A5XX_INT_UCHE_TRAP_INTR) | \ 65: (1 << A5XX_INT_CP_SW) | \ 66: (1 << A5XX_INT_GPMU_FIRMWARE) | \ 67: (1 << A5XX_INT_GPMU_VOLTAGE_DROOP)) 68: 69: static int a5xx_probe(struct platform_device *pdev, 70: u32 chipid, const struct adreno_gpu_core *gpucore) 71: { 72: struct adreno_device *adreno_dev; 73: struct kgsl_device *device; 74: int ret; 75: 76: adreno_dev = (struct adreno_device *) 77: of_device_get_match_data(&pdev->dev); 78: 79: memset(adreno_dev, 0, sizeof(*adreno_dev)); 80: 81: adreno_dev->gpucore = gpucore; 82: adreno_dev->chipid = chipid; 83: 84: adreno_reg_offset_init(gpucore->gpudev->reg_offsets); 85: 86: adreno_dev->sptp_pc_enabled = MATCH LINES: 196 184: { 185: int ret; 186: 187: ret = a5xx_ringbuffer_init(adreno_dev); 188: if (ret) 189: return ret; 190: 191: ret = a5xx_microcode_read(adreno_dev); 192: if (ret) 193: return ret; 194: 195: if (a5xx_has_gpmu(adreno_dev)) 196: INIT_WORK(&adreno_dev->gpmu_work, a5xx_gpmu_reset); 197: 198: INIT_WORK(&adreno_dev->irq_storm_work, a5xx_irq_storm_worker); 199: 200: if (ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_CRITICAL_PACKETS)) 201: a5xx_critical_packet_construct(adreno_dev); 202: 203: adreno_create_profile_buffer(adreno_dev); 204: a5xx_crashdump_init(adreno_dev); 205: 206: return 0; 207: } 208: 209: static const struct { 210: u32 reg; 211: u32 base; 212: u32 count; 213: } a5xx_protected_blocks[] = { 214: /* RBBM */ 215: { A5XX_CP_PROTECT_REG_0, 0x004, 2 }, 216: { A5XX_CP_PROTECT_REG_0 + 1, 0x008, 3 }, 217: { A5XX_CP_PROTECT_REG_0 + 2, 0x010, 4 }, 218: { A5XX_CP_PROTECT_REG_0 + 3, 0x020, 5 }, 219: { A5XX_CP_PROTECT_REG_0 + 4, 0x040, 6 }, 220: { A5XX_CP_PROTECT_REG_0 + 5, 0x080, 6 }, MATCH LINES: 455, 456, 458 443: if (reg & BIT(20)) 444: dev_warn(device->dev, "RBCCU GDSC is not disabled\n"); 445: /* 446: * GPMU firmware is supposed to set GMEM to non-retention. 447: * Bit 14 is the memory core force on bit. 448: */ 449: kgsl_regread(device, A5XX_GPMU_RBCCU_CLOCK_CNTL, ®); 450: if (reg & BIT(14)) 451: dev_warn(device->dev, "GMEM is forced on\n"); 452: } 453: 454: if (adreno_is_a530(adreno_dev)) { 455: /* Reset VBIF before PC to avoid popping bogus FIFO entries */ 456: kgsl_regwrite(device, A5XX_RBBM_BLOCK_SW_RESET_CMD, 457: 0x003C0000); 458: kgsl_regwrite(device, A5XX_RBBM_BLOCK_SW_RESET_CMD, 0); 459: } 460: } 461: 462: /* 463: * a5xx_enable_pc() - Enable the GPMU based power collapse of the SPTP and RAC 464: * blocks 465: * @adreno_dev: The adreno device pointer 466: */ 467: static void a5xx_enable_pc(struct adreno_device *adreno_dev) 468: { 469: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 470: 471: if (!adreno_dev->sptp_pc_enabled) 472: return; 473: 474: kgsl_regwrite(device, A5XX_GPMU_PWR_COL_INTER_FRAME_CTRL, 0x0000007F); 475: kgsl_regwrite(device, A5XX_GPMU_PWR_COL_BINNING_CTRL, 0); 476: kgsl_regwrite(device, A5XX_GPMU_PWR_COL_INTER_FRAME_HYST, 0x000A0080); 477: kgsl_regwrite(device, A5XX_GPMU_PWR_COL_STAGGER_DELAY, 0x00600040); 478: 479: trace_adreno_sp_tp((unsigned long) __builtin_return_address(0)); 480: }; 481: 482: /* MATCH LINES: 638, 675, 695 626: kgsl_regread(device, A5XX_RBBM_STATUS, &status); 627: kgsl_regread(device, A5XX_RBBM_STATUS3, &status3); 628: kgsl_regread(device, A5XX_RBBM_INT_0_STATUS, &intstatus); 629: kgsl_regread(device, A5XX_CP_HW_FAULT, &hwfault); 630: 631: 632: dev_err(device->dev, 633: "rb=%d pos=%X/%X rbbm_status=%8.8X/%8.8X int_0_status=%8.8X\n", 634: adreno_dev->cur_rb->id, rptr, wptr, status, status3, intstatus); 635: 636: dev_err(device->dev, " hwfault=%8.8X\n", hwfault); 637: 638: kgsl_device_snapshot(device, NULL, NULL, false); 639: } 640: 641: static int _gpmu_send_init_cmds(struct adreno_device *adreno_dev) 642: { 643: struct adreno_ringbuffer *rb = adreno_dev->cur_rb; 644: uint32_t *cmds; 645: uint32_t size = adreno_dev->gpmu_cmds_size; 646: int ret; 647: 648: if (size == 0 || adreno_dev->gpmu_cmds == NULL) 649: return -EINVAL; 650: 651: cmds = adreno_ringbuffer_allocspace(rb, size); 652: if (IS_ERR(cmds)) 653: return PTR_ERR(cmds); 654: if (cmds == NULL) 655: return -ENOSPC; 656: 657: /* Copy to the RB the predefined fw sequence cmds */ 658: memcpy(cmds, adreno_dev->gpmu_cmds, size << 2); 659: 660: ret = a5xx_ringbuffer_submit(rb, NULL, true); 661: if (!ret) { 662: ret = adreno_spin_idle(adreno_dev, 2000); 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: */ 700: do { 701: udelay(1); 702: kgsl_regread(device, A5XX_GPMU_GENERAL_0, ®); 703: } while ((reg != 0xBABEFACE) && retry--); 704: 705: if (reg != 0xBABEFACE) { 706: dev_err(device->dev, 707: "GPMU firmware initialization timed out\n"); 708: return -ETIMEDOUT; 709: } 710: 711: if (!adreno_is_a530(adreno_dev)) { 712: kgsl_regread(device, A5XX_GPMU_GENERAL_1, ®); 713: 714: if (reg) { 715: dev_err(device->dev, 716: "GPMU firmware initialization failed: %d\n", 717: reg); 718: return -EIO; 719: } MATCH LINES: 1192, 1193, 1196, 1198, 1209, 1220, 1221, 1242 1180: } 1181: adj = th[CRC_MORE50PCT] - th[IDLE_10PCT]; 1182: adj = th[CRC_50PCT] + th[CRC_LESS50PCT] / 3 + (adj < 0 ? 0 : adj) * 3; 1183: 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++) { 1242: /* reset throttled cycles ivalue */ 1243: adreno_dev->busy_data.throttle_cycles[i] = 0; 1244: 1245: /* Throttle countables start at off set 43 */ 1246: ret |= adreno_perfcounter_kernel_get(adreno_dev, 1247: KGSL_PERFCOUNTER_GROUP_GPMU_PWR, 43 + i, 1248: &adreno_dev->gpmu_throttle_counters[i], NULL); 1249: } 1250: 1251: WARN_ONCE(ret, "Unable to get one or more clock throttling registers\n"); 1252: } 1253: 1254: /* 1255: * a5xx_start() - Device start 1256: * @adreno_dev: Pointer to adreno device 1257: * 1258: * a5xx device start 1259: */ 1260: static int a5xx_start(struct adreno_device *adreno_dev) 1261: { 1262: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1263: const struct adreno_a5xx_core *a5xx_core = to_a5xx_core(adreno_dev); 1264: unsigned int bit; 1265: int ret; 1266: MATCH LINES: 1704, 1705, 1716 1692: /* 1693: * CP_INIT_MAX_CONTEXT bit tells if the multiple hardware contexts can 1694: * be used at once of if they should be serialized 1695: */ 1696: #define CP_INIT_MAX_CONTEXT BIT(0) 1697: 1698: /* Enables register protection mode */ 1699: #define CP_INIT_ERROR_DETECTION_CONTROL BIT(1) 1700: 1701: /* Header dump information */ 1702: #define CP_INIT_HEADER_DUMP BIT(2) /* Reserved */ 1703: 1704: /* Default Reset states enabled for PFP and ME */ 1705: #define CP_INIT_DEFAULT_RESET_STATE BIT(3) 1706: 1707: /* Drawcall filter range */ 1708: #define CP_INIT_DRAWCALL_FILTER_RANGE BIT(4) 1709: 1710: /* Ucode workaround masks */ 1711: #define CP_INIT_UCODE_WORKAROUND_MASK BIT(5) 1712: 1713: #define CP_INIT_MASK (CP_INIT_MAX_CONTEXT | \ 1714: CP_INIT_ERROR_DETECTION_CONTROL | \ 1715: CP_INIT_HEADER_DUMP | \ 1716: CP_INIT_DEFAULT_RESET_STATE | \ 1717: CP_INIT_UCODE_WORKAROUND_MASK) 1718: 1719: static int a5xx_critical_packet_submit(struct adreno_device *adreno_dev, 1720: struct adreno_ringbuffer *rb) 1721: { 1722: unsigned int *cmds; 1723: int ret; 1724: 1725: if (!critical_packet_constructed) 1726: return 0; 1727: 1728: cmds = adreno_ringbuffer_allocspace(rb, 4); 1729: if (IS_ERR(cmds)) 1730: return PTR_ERR(cmds); 1731: 1732: *cmds++ = cp_mem_packet(adreno_dev, CP_INDIRECT_BUFFER_PFE, 2, 1); 1733: cmds += cp_gpuaddr(adreno_dev, cmds, adreno_dev->critpkts->gpuaddr); 1734: *cmds++ = crit_pkts_dwords; 1735: 1736: ret = a5xx_ringbuffer_submit(rb, NULL, true); 1737: if (!ret) { 1738: ret = adreno_spin_idle(adreno_dev, 20); 1739: if (ret) 1740: a5xx_spin_idle_debug(adreno_dev, MATCH LINES: 1946 1934: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_WPTR, A5XX_CP_RB_WPTR), 1935: ADRENO_REG_DEFINE(ADRENO_REG_CP_ME_CNTL, A5XX_CP_ME_CNTL), 1936: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_CNTL, A5XX_CP_RB_CNTL), 1937: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BASE, A5XX_CP_IB1_BASE), 1938: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BASE_HI, A5XX_CP_IB1_BASE_HI), 1939: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BUFSZ, A5XX_CP_IB1_BUFSZ), 1940: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BASE, A5XX_CP_IB2_BASE), 1941: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BASE_HI, A5XX_CP_IB2_BASE_HI), 1942: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BUFSZ, A5XX_CP_IB2_BUFSZ), 1943: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_STATUS, A5XX_RBBM_STATUS), 1944: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_STATUS3, A5XX_RBBM_STATUS3), 1945: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_INT_0_MASK, A5XX_RBBM_INT_0_MASK), 1946: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_SW_RESET_CMD, A5XX_RBBM_SW_RESET_CMD), 1947: }; 1948: 1949: static void a5xx_cp_hw_err_callback(struct adreno_device *adreno_dev, int bit) 1950: { 1951: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1952: unsigned int status1, status2; 1953: 1954: kgsl_regread(device, A5XX_CP_INTERRUPT_STATUS, &status1); 1955: 1956: if (status1 & BIT(A5XX_CP_OPCODE_ERROR)) { 1957: unsigned int val; 1958: 1959: kgsl_regwrite(device, A5XX_CP_PFP_STAT_ADDR, 0); 1960: 1961: /* 1962: * A5XX_CP_PFP_STAT_DATA is indexed, so read it twice to get the 1963: * value we want 1964: */ 1965: kgsl_regread(device, A5XX_CP_PFP_STAT_DATA, &val); 1966: kgsl_regread(device, A5XX_CP_PFP_STAT_DATA, &val); 1967: 1968: dev_crit_ratelimited(device->dev, 1969: "ringbuffer opcode error | possible opcode=0x%8.8X\n", 1970: val); MATCH LINES: 2174 2162: dev_crit_ratelimited(device->dev, 2163: "GPMU: Unknown IRQ mask 0x%08lx in 0x%08x\n", 2164: reg & (~VALID_GPMU_IRQ), reg); 2165: } 2166: 2167: for (i = 0; i < 32; i++) 2168: switch (reg & BIT(i)) { 2169: case BIT(WDOG_EXPITED): 2170: if (test_and_clear_bit(ADRENO_DEVICE_GPMU_INITIALIZED, 2171: &adreno_dev->priv)) { 2172: /* Stop GPMU */ 2173: kgsl_regwrite(device, 2174: A5XX_GPMU_CM3_SYSRESET, 1); 2175: kgsl_schedule_work(&adreno_dev->gpmu_work); 2176: } 2177: fallthrough; 2178: case BIT(FW_INTR_INFO): 2179: fallthrough; 2180: case BIT(LLM_ACK_ERR_INTR): 2181: fallthrough; 2182: case BIT(ISENS_TRIM_ERR_INTR): 2183: fallthrough; 2184: case BIT(ISENS_ERR_INTR): 2185: fallthrough; 2186: case BIT(ISENS_IDLE_ERR_INTR): 2187: fallthrough; 2188: case BIT(ISENS_PWR_ON_ERR_INTR): 2189: dev_crit_ratelimited(device->dev, 2190: "GPMU: interrupt %s(%08lx)\n", 2191: gpmu_int_msg[i], 2192: BIT(i)); 2193: break; 2194: } 2195: } 2196: 2197: /* 2198: * a5x_gpc_err_int_callback() - Isr for GPC error interrupts MATCH LINES: 2267 2255: ADRENO_IRQ_CALLBACK(NULL), /* 13 - CP_IB2_INT */ 2256: ADRENO_IRQ_CALLBACK(NULL), /* 14 - CP_IB1_INT */ 2257: ADRENO_IRQ_CALLBACK(NULL), /* 15 - CP_RB_INT */ 2258: /* 16 - CCP_UNUSED_1 */ 2259: ADRENO_IRQ_CALLBACK(NULL), 2260: ADRENO_IRQ_CALLBACK(NULL), /* 17 - CP_RB_DONE_TS */ 2261: ADRENO_IRQ_CALLBACK(NULL), /* 18 - CP_WT_DONE_TS */ 2262: ADRENO_IRQ_CALLBACK(NULL), /* 19 - UNKNOWN_1 */ 2263: ADRENO_IRQ_CALLBACK(a5xx_cp_callback), /* 20 - CP_CACHE_FLUSH_TS */ 2264: /* 21 - UNUSED_2 */ 2265: ADRENO_IRQ_CALLBACK(NULL), 2266: ADRENO_IRQ_CALLBACK(a5xx_err_callback), /* 22 - RBBM_ATB_BUS_OVERFLOW */ 2267: /* 23 - MISC_HANG_DETECT */ 2268: ADRENO_IRQ_CALLBACK(adreno_hang_int_callback), 2269: ADRENO_IRQ_CALLBACK(a5xx_err_callback), /* 24 - UCHE_OOB_ACCESS */ 2270: ADRENO_IRQ_CALLBACK(a5xx_err_callback), /* 25 - UCHE_TRAP_INTR */ 2271: ADRENO_IRQ_CALLBACK(NULL), /* 26 - DEBBUS_INTR_0 */ 2272: ADRENO_IRQ_CALLBACK(NULL), /* 27 - DEBBUS_INTR_1 */ 2273: ADRENO_IRQ_CALLBACK(a5xx_err_callback), /* 28 - GPMU_VOLTAGE_DROOP */ 2274: ADRENO_IRQ_CALLBACK(a5xx_gpmu_int_callback), /* 29 - GPMU_FIRMWARE */ 2275: ADRENO_IRQ_CALLBACK(NULL), /* 30 - ISDB_CPU_IRQ */ 2276: ADRENO_IRQ_CALLBACK(NULL), /* 31 - ISDB_UNDER_DEBUG */ 2277: }; 2278: 2279: static irqreturn_t a5xx_irq_handler(struct adreno_device *adreno_dev) 2280: { 2281: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2282: irqreturn_t ret; 2283: u32 status; 2284: 2285: kgsl_regread(device, A5XX_RBBM_INT_0_STATUS, &status); 2286: 2287: /* 2288: * Clear all the interrupt bits except A5XX_INT_RBBM_AHB_ERROR. 2289: * The interrupt will stay asserted until it is cleared by the handler 2290: * so don't touch it yet to avoid a storm 2291: */ MATCH LINES: 2432 2420: 2421: stats->ram_time = counter_delta(device, adreno_dev->ram_cycles_lo, 2422: &busy->bif_ram_cycles); 2423: 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_a5xx.h | HITS: 2 --- MATCH LINES: 99, 100 87: * @ttbr0: (08) Base address of the page table for the 88: * incoming context. 89: * @context_idr: (16) Context Identification Register value. 90: */ 91: struct a5xx_cp_smmu_info { 92: uint32_t magic; 93: uint32_t _pad4; 94: uint64_t ttbr0; 95: uint32_t asid; 96: uint32_t context_idr; 97: }; 98: 99: void a5xx_snapshot(struct adreno_device *adreno_dev, 100: struct kgsl_snapshot *snapshot); 101: unsigned int a5xx_num_registers(void); 102: 103: void a5xx_crashdump_init(struct adreno_device *adreno_dev); 104: 105: void a5xx_hwcg_set(struct adreno_device *adreno_dev, bool on); 106: 107: #define A5XX_CP_RB_CNTL_DEFAULT ((1 << 27) | ((ilog2(4) << 8) & 0x1F00) | \ 108: (ilog2(KGSL_RB_DWORDS >> 1) & 0x3F)) 109: /* GPMU interrupt multiplexor */ 110: #define FW_INTR_INFO (0) 111: #define LLM_ACK_ERR_INTR (1) 112: #define ISENS_TRIM_ERR_INTR (2) 113: #define ISENS_ERR_INTR (3) 114: #define ISENS_IDLE_ERR_INTR (4) 115: #define ISENS_PWR_ON_ERR_INTR (5) 116: #define WDOG_EXPITED (31) 117: 118: #define VALID_GPMU_IRQ (\ 119: BIT(FW_INTR_INFO) | \ 120: BIT(LLM_ACK_ERR_INTR) | \ 121: BIT(ISENS_TRIM_ERR_INTR) | \ 122: BIT(ISENS_ERR_INTR) | \ 123: BIT(ISENS_IDLE_ERR_INTR) | \ 124: BIT(ISENS_PWR_ON_ERR_INTR) | \ --- FILE: \adreno_a5xx_perfcounter.c | HITS: 3 --- MATCH LINES: 104, 107 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 104: * either due to soft reset or adreno_stop, ignore the 105: * error and return 0 here. The perfcounter is already 106: * set up in software and it will be programmed in 107: * hardware when we wake up or come up after soft reset, 108: * by adreno_perfcounter_restore. 109: */ 110: if (ret == -EAGAIN) 111: ret = 0; 112: else 113: dev_err(device->dev, 114: "Perfcounter %s/%u/%u start via commands failed %d\n", 115: group->name, counter, countable, ret); 116: } 117: 118: if (!ret) 119: reg->value = 0; 120: 121: return ret; 122: } 123: 124: static int a5xx_counter_rbbm_enable(struct adreno_device *adreno_dev, 125: const struct adreno_perfcount_group *group, 126: unsigned int counter, unsigned int countable) 127: { 128: if (adreno_is_a540(adreno_dev) && countable == A5XX_RBBM_ALWAYS_COUNT) 129: return -EINVAL; 130: 131: return a5xx_counter_inline_enable(adreno_dev, group, counter, MATCH LINES: 261 249: 250: reg->value = 0; 251: return 0; 252: } 253: 254: static int a5xx_counter_pwr_alwayson_enable(struct adreno_device *adreno_dev, 255: const struct adreno_perfcount_group *group, 256: unsigned int counter, unsigned int countable) 257: { 258: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 259: struct adreno_perfcount_register *reg = &group->regs[counter]; 260: 261: kgsl_regwrite(device, A5XX_GPMU_ALWAYS_ON_COUNTER_RESET, 1); 262: 263: reg->value = 0; 264: return 0; 265: } 266: 267: static struct adreno_perfcount_register a5xx_perfcounters_cp[] = { 268: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A5XX_RBBM_PERFCTR_CP_0_LO, 269: A5XX_RBBM_PERFCTR_CP_0_HI, 0, A5XX_CP_PERFCTR_CP_SEL_0 }, 270: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A5XX_RBBM_PERFCTR_CP_1_LO, 271: A5XX_RBBM_PERFCTR_CP_1_HI, 1, A5XX_CP_PERFCTR_CP_SEL_1 }, 272: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A5XX_RBBM_PERFCTR_CP_2_LO, 273: A5XX_RBBM_PERFCTR_CP_2_HI, 2, A5XX_CP_PERFCTR_CP_SEL_2 }, 274: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A5XX_RBBM_PERFCTR_CP_3_LO, 275: A5XX_RBBM_PERFCTR_CP_3_HI, 3, A5XX_CP_PERFCTR_CP_SEL_3 }, 276: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A5XX_RBBM_PERFCTR_CP_4_LO, 277: A5XX_RBBM_PERFCTR_CP_4_HI, 4, A5XX_CP_PERFCTR_CP_SEL_4 }, 278: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A5XX_RBBM_PERFCTR_CP_5_LO, 279: A5XX_RBBM_PERFCTR_CP_5_HI, 5, A5XX_CP_PERFCTR_CP_SEL_5 }, 280: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A5XX_RBBM_PERFCTR_CP_6_LO, 281: A5XX_RBBM_PERFCTR_CP_6_HI, 6, A5XX_CP_PERFCTR_CP_SEL_6 }, 282: { KGSL_PERFCOUNTER_NOT_USED, 0, 0, A5XX_RBBM_PERFCTR_CP_7_LO, 283: A5XX_RBBM_PERFCTR_CP_7_HI, 7, A5XX_CP_PERFCTR_CP_SEL_7 }, 284: }; 285: --- FILE: \adreno_a5xx_preempt.c | HITS: 5 --- MATCH LINES: 19, 34, 36, 39, 53 7: #include "adreno.h" 8: #include "adreno_a5xx.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 a5xx_cp_preemption_record, _field) 15: 16: #define PREEMPT_SMMU_RECORD(_field) \ 17: offsetof(struct a5xx_cp_smmu_info, _field) 18: 19: static void _update_wptr(struct adreno_device *adreno_dev, bool reset_timer) 20: { 21: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 22: struct adreno_ringbuffer *rb = adreno_dev->cur_rb; 23: unsigned int wptr; 24: unsigned long flags; 25: 26: spin_lock_irqsave(&rb->preempt_lock, flags); 27: 28: kgsl_regread(device, A5XX_CP_RB_WPTR, &wptr); 29: 30: if (wptr != rb->wptr) { 31: kgsl_regwrite(device, A5XX_CP_RB_WPTR, rb->wptr); 32: /* 33: * In case something got submitted while preemption was on 34: * going, reset the timer. 35: */ 36: reset_timer = true; 37: } 38: 39: if (reset_timer) 40: rb->dispatch_q.expires = jiffies + 41: msecs_to_jiffies(adreno_drawobj_timeout); 42: 43: spin_unlock_irqrestore(&rb->preempt_lock, flags); 44: } 45: 46: static void _a5xx_preemption_done(struct adreno_device *adreno_dev) 47: { 48: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 49: unsigned int status; 50: 51: /* 52: * In the very unlikely case that the power is off, do nothing - the 53: * state will be reset on power up and everybody will be happy 54: */ 55: 56: if (!kgsl_state_is_awake(device)) 57: return; 58: 59: kgsl_regread(device, A5XX_CP_CONTEXT_SWITCH_CNTL, &status); 60: 61: if (status != 0) { 62: dev_err(device->dev, 63: "Preemption not complete: status=%X cur=%d R/W=%X/%X next=%d R/W=%X/%X\n", 64: status, adreno_dev->cur_rb->id, 65: adreno_get_rptr(adreno_dev->cur_rb), 66: adreno_dev->cur_rb->wptr, 67: adreno_dev->next_rb->id, 68: adreno_get_rptr(adreno_dev->next_rb), 69: adreno_dev->next_rb->wptr); 70: 71: /* Set a fault and restart */ 72: adreno_scheduler_fault(adreno_dev, ADRENO_PREEMPT_FAULT); 73: 74: return; 75: } 76: 77: kgsl_delete_timer_sync(&adreno_dev->preempt.timer); --- FILE: \adreno_a5xx_ringbuffer.c | HITS: 2 --- MATCH LINES: 151 139: struct adreno_submit_time *time) 140: { 141: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 142: static u32 sequence; 143: u32 size = A5XX_SUBMIT_MAX + dwords; 144: u32 *cmds, index = 0; 145: u64 profile_gpuaddr; 146: u32 profile_dwords; 147: 148: if (adreno_drawctxt_detached(drawctxt)) 149: return -ENOENT; 150: 151: if (adreno_gpu_fault(adreno_dev) != 0) 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); MATCH LINES: 225 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)); --- FILE: \adreno_a5xx_snapshot.c | HITS: 107 --- MATCH LINES: 9 1: // SPDX-License-Identifier: GPL-2.0-only 2: /* 3: * Copyright (c) 2015-2020, 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_a5xx.h" 9: #include "adreno_snapshot.h" 10: 11: enum a5xx_rbbm_debbus_id { 12: A5XX_RBBM_DBGBUS_CP = 0x1, 13: A5XX_RBBM_DBGBUS_RBBM = 0x2, 14: A5XX_RBBM_DBGBUS_VBIF = 0x3, 15: A5XX_RBBM_DBGBUS_HLSQ = 0x4, 16: A5XX_RBBM_DBGBUS_UCHE = 0x5, 17: A5XX_RBBM_DBGBUS_DPM = 0x6, 18: A5XX_RBBM_DBGBUS_TESS = 0x7, 19: A5XX_RBBM_DBGBUS_PC = 0x8, 20: A5XX_RBBM_DBGBUS_VFDP = 0x9, 21: A5XX_RBBM_DBGBUS_VPC = 0xa, 22: A5XX_RBBM_DBGBUS_TSE = 0xb, 23: A5XX_RBBM_DBGBUS_RAS = 0xc, 24: A5XX_RBBM_DBGBUS_VSC = 0xd, 25: A5XX_RBBM_DBGBUS_COM = 0xe, 26: A5XX_RBBM_DBGBUS_DCOM = 0xf, 27: A5XX_RBBM_DBGBUS_LRZ = 0x10, 28: A5XX_RBBM_DBGBUS_A2D_DSP = 0x11, 29: A5XX_RBBM_DBGBUS_CCUFCHE = 0x12, 30: A5XX_RBBM_DBGBUS_GPMU = 0x13, 31: A5XX_RBBM_DBGBUS_RBP = 0x14, 32: A5XX_RBBM_DBGBUS_HM = 0x15, 33: A5XX_RBBM_DBGBUS_RBBM_CFG = 0x16, MATCH LINES: 123, 124, 128, 134, 138, 146, 147, 151, 157, 161, 188, 189, 192, 193, 211 111: { A5XX_RBBM_DBGBUS_TPL1_0, 0x100, }, 112: { A5XX_RBBM_DBGBUS_TPL1_1, 0x100, }, 113: { A5XX_RBBM_DBGBUS_TPL1_2, 0x100, }, 114: { A5XX_RBBM_DBGBUS_TPL1_3, 0x100, }, 115: }; 116: 117: #define A5XX_NUM_AXI_ARB_BLOCKS 2 118: #define A5XX_NUM_XIN_BLOCKS 4 119: 120: /* Width of A5XX_CP_DRAW_STATE_ADDR is 8 bits */ 121: #define A5XX_CP_DRAW_STATE_ADDR_WIDTH 8 122: 123: /* a5xx_snapshot_cp_pm4() - Dump PM4 data in snapshot */ 124: static size_t a5xx_snapshot_cp_pm4(struct kgsl_device *device, u8 *buf, 125: size_t remain, void *priv) 126: { 127: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 128: struct kgsl_snapshot_debug *header = (struct kgsl_snapshot_debug *)buf; 129: unsigned int *data = (unsigned int *)(buf + sizeof(*header)); 130: struct adreno_firmware *fw = ADRENO_FW(adreno_dev, ADRENO_FW_PM4); 131: size_t size = fw->size; 132: 133: if (remain < DEBUG_SECTION_SZ(size)) { 134: SNAPSHOT_ERR_NOMEM(device, "CP PM4 RAM DEBUG"); 135: return 0; 136: } 137: 138: header->type = SNAPSHOT_DEBUG_CP_PM4_RAM; 139: header->size = size; 140: 141: memcpy(data, fw->memdesc->hostptr, size * sizeof(uint32_t)); 142: 143: return DEBUG_SECTION_SZ(size); 144: } 145: 146: /* a5xx_snapshot_cp_pfp() - Dump the PFP data on snapshot */ 147: static size_t a5xx_snapshot_cp_pfp(struct kgsl_device *device, u8 *buf, 148: size_t remain, void *priv) 149: { 150: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 151: struct kgsl_snapshot_debug *header = (struct kgsl_snapshot_debug *)buf; 152: unsigned int *data = (unsigned int *)(buf + sizeof(*header)); 153: struct adreno_firmware *fw = ADRENO_FW(adreno_dev, ADRENO_FW_PFP); 154: int size = fw->size; 155: 156: if (remain < DEBUG_SECTION_SZ(size)) { 157: SNAPSHOT_ERR_NOMEM(device, "CP PFP RAM DEBUG"); 158: return 0; 159: } 160: 161: header->type = SNAPSHOT_DEBUG_CP_PFP_RAM; 162: header->size = size; 163: 164: memcpy(data, fw->memdesc->hostptr, size * sizeof(uint32_t)); 165: 166: return DEBUG_SECTION_SZ(size); 167: } 168: 169: /* a5xx_rbbm_debug_bus_read() - Read data from trace bus */ 170: static void a5xx_rbbm_debug_bus_read(struct kgsl_device *device, 171: unsigned int block_id, unsigned int index, unsigned int *val) 172: { 173: unsigned int reg; 174: 175: reg = (block_id << A5XX_RBBM_CFG_DBGBUS_SEL_PING_BLK_SEL_SHIFT) | 176: (index << A5XX_RBBM_CFG_DBGBUS_SEL_PING_INDEX_SHIFT); 177: kgsl_regwrite(device, A5XX_RBBM_CFG_DBGBUS_SEL_A, reg); 178: kgsl_regwrite(device, A5XX_RBBM_CFG_DBGBUS_SEL_B, reg); 179: kgsl_regwrite(device, A5XX_RBBM_CFG_DBGBUS_SEL_C, reg); 180: kgsl_regwrite(device, A5XX_RBBM_CFG_DBGBUS_SEL_D, reg); 181: 182: kgsl_regread(device, A5XX_RBBM_CFG_DBGBUS_TRACE_BUF2, val); 183: val++; 184: kgsl_regread(device, A5XX_RBBM_CFG_DBGBUS_TRACE_BUF1, val); 185: 186: } 187: 188: /* a5xx_snapshot_vbif_debugbus() - Dump the VBIF debug data */ 189: static size_t a5xx_snapshot_vbif_debugbus(struct kgsl_device *device, 190: u8 *buf, size_t remain, void *priv) 191: { 192: struct kgsl_snapshot_debugbus *header = 193: (struct kgsl_snapshot_debugbus *)buf; 194: struct adreno_debugbus_block *block = priv; 195: int i, j; 196: /* 197: * Total number of VBIF data words considering 3 sections: 198: * 2 arbiter blocks of 16 words 199: * 4 AXI XIN blocks of 18 dwords each 200: * 4 core clock side XIN blocks of 12 dwords each 201: */ 202: unsigned int dwords = (16 * A5XX_NUM_AXI_ARB_BLOCKS) + 203: (18 * A5XX_NUM_XIN_BLOCKS) + (12 * A5XX_NUM_XIN_BLOCKS); 204: unsigned int *data = (unsigned int *)(buf + sizeof(*header)); 205: size_t size; 206: unsigned int reg_clk; 207: 208: size = (dwords * sizeof(unsigned int)) + sizeof(*header); 209: 210: if (remain < size) { 211: SNAPSHOT_ERR_NOMEM(device, "DEBUGBUS"); 212: return 0; 213: } 214: header->id = block->block_id; 215: header->count = dwords; 216: 217: kgsl_regread(device, A5XX_VBIF_CLKON, ®_clk); 218: kgsl_regwrite(device, A5XX_VBIF_CLKON, reg_clk | 219: (A5XX_VBIF_CLKON_FORCE_ON_TESTBUS_MASK << 220: A5XX_VBIF_CLKON_FORCE_ON_TESTBUS_SHIFT)); 221: kgsl_regwrite(device, A5XX_VBIF_TEST_BUS1_CTRL0, 0); 222: kgsl_regwrite(device, A5XX_VBIF_TEST_BUS_OUT_CTRL, 223: (A5XX_VBIF_TEST_BUS_OUT_CTRL_EN_MASK << 224: A5XX_VBIF_TEST_BUS_OUT_CTRL_EN_SHIFT)); 225: for (i = 0; i < A5XX_NUM_AXI_ARB_BLOCKS; i++) { 226: kgsl_regwrite(device, A5XX_VBIF_TEST_BUS2_CTRL0, 227: (1 << (i + 16))); 228: for (j = 0; j < 16; j++) { 229: kgsl_regwrite(device, A5XX_VBIF_TEST_BUS2_CTRL1, 230: ((j & A5XX_VBIF_TEST_BUS2_CTRL1_DATA_SEL_MASK) 231: << A5XX_VBIF_TEST_BUS2_CTRL1_DATA_SEL_SHIFT)); 232: kgsl_regread(device, A5XX_VBIF_TEST_BUS_OUT, 233: data); 234: data++; 235: } MATCH LINES: 268, 269, 272, 273, 286, 300, 301, 302, 311, 312, 313, 316, 317, 318, 336 256: ((j & A5XX_VBIF_TEST_BUS1_CTRL1_DATA_SEL_MASK) 257: << A5XX_VBIF_TEST_BUS1_CTRL1_DATA_SEL_SHIFT)); 258: kgsl_regread(device, A5XX_VBIF_TEST_BUS_OUT, 259: data); 260: data++; 261: } 262: } 263: /* restore the clock of VBIF */ 264: kgsl_regwrite(device, A5XX_VBIF_CLKON, reg_clk); 265: return size; 266: } 267: 268: /* a5xx_snapshot_debugbus_block() - Capture debug data for a gpu block */ 269: static size_t a5xx_snapshot_debugbus_block(struct kgsl_device *device, 270: u8 *buf, size_t remain, void *priv) 271: { 272: struct kgsl_snapshot_debugbus *header = 273: (struct kgsl_snapshot_debugbus *)buf; 274: struct adreno_debugbus_block *block = priv; 275: int i; 276: unsigned int *data = (unsigned int *)(buf + sizeof(*header)); 277: unsigned int dwords; 278: size_t size; 279: 280: dwords = block->dwords; 281: 282: /* For a5xx each debug bus data unit is 2 DWRODS */ 283: size = (dwords * sizeof(unsigned int) * 2) + sizeof(*header); 284: 285: if (remain < size) { 286: SNAPSHOT_ERR_NOMEM(device, "DEBUGBUS"); 287: return 0; 288: } 289: 290: header->id = block->block_id; 291: header->count = dwords * 2; 292: 293: for (i = 0; i < dwords; i++) 294: a5xx_rbbm_debug_bus_read(device, block->block_id, i, 295: &data[i*2]); 296: 297: return size; 298: } 299: 300: /* a5xx_snapshot_debugbus() - Capture debug bus data */ 301: static void a5xx_snapshot_debugbus(struct kgsl_device *device, 302: struct kgsl_snapshot *snapshot) 303: { 304: int i; 305: 306: kgsl_regwrite(device, A5XX_RBBM_CFG_DBGBUS_CNTLM, 307: 0xf << A5XX_RBBM_CFG_DEBBUS_CTLTM_ENABLE_SHIFT); 308: 309: for (i = 0; i < ARRAY_SIZE(a5xx_debugbus_blocks); i++) { 310: if (a5xx_debugbus_blocks[i].block_id == A5XX_RBBM_DBGBUS_VBIF) 311: kgsl_snapshot_add_section(device, 312: KGSL_SNAPSHOT_SECTION_DEBUGBUS, 313: snapshot, a5xx_snapshot_vbif_debugbus, 314: (void *) &a5xx_debugbus_blocks[i]); 315: else 316: kgsl_snapshot_add_section(device, 317: KGSL_SNAPSHOT_SECTION_DEBUGBUS, 318: snapshot, a5xx_snapshot_debugbus_block, 319: (void *) &a5xx_debugbus_blocks[i]); 320: } 321: } 322: 323: static const unsigned int a5xx_vbif_registers[] = { 324: 0x3000, 0x3007, 0x300C, 0x3014, 0x3018, 0x302C, 0x3030, 0x3030, 325: 0x3034, 0x3036, 0x3038, 0x3038, 0x303C, 0x303D, 0x3040, 0x3040, 326: 0x3042, 0x3042, 0x3049, 0x3049, 0x3058, 0x3058, 0x305A, 0x3061, 327: 0x3064, 0x3068, 0x306C, 0x306D, 0x3080, 0x3088, 0x308C, 0x308C, 328: 0x3090, 0x3094, 0x3098, 0x3098, 0x309C, 0x309C, 0x30C0, 0x30C0, 329: 0x30C8, 0x30C8, 0x30D0, 0x30D0, 0x30D8, 0x30D8, 0x30E0, 0x30E0, 330: 0x3100, 0x3100, 0x3108, 0x3108, 0x3110, 0x3110, 0x3118, 0x3118, 331: 0x3120, 0x3120, 0x3124, 0x3125, 0x3129, 0x3129, 0x3131, 0x3131, 332: 0x340C, 0x340C, 0x3410, 0x3410, 0x3800, 0x3801, 333: }; 334: 335: /* 336: * Set of registers to dump for A5XX on snapshot. 337: * Registers in pairs - first value is the start offset, second 338: * is the stop offset (inclusive) 339: */ 340: 341: static const unsigned int a5xx_registers[] = { 342: /* RBBM */ 343: 0x0000, 0x0002, 0x0004, 0x0020, 0x0022, 0x0026, 0x0029, 0x002B, 344: 0x002E, 0x0035, 0x0038, 0x0042, 0x0044, 0x0044, 0x0047, 0x0095, 345: 0x0097, 0x00BB, 0x03A0, 0x0464, 0x0469, 0x046F, 0x04D2, 0x04D3, 346: 0x04E0, 0x04F4, 0X04F8, 0x0529, 0x0531, 0x0533, 0x0540, 0x0555, 347: 0xF400, 0xF400, 0xF800, 0xF807, 348: /* CP */ 349: 0x0800, 0x0803, 0x0806, 0x081A, 0x081F, 0x0841, 0x0860, 0x0860, 350: 0x0880, 0x08A0, 0x0B00, 0x0B12, 0x0B15, 0X0B1C, 0X0B1E, 0x0B28, 351: 0x0B78, 0x0B7F, 0x0BB0, 0x0BBD, 352: /* VSC */ 353: 0x0BC0, 0x0BC6, 0x0BD0, 0x0C53, 0x0C60, 0x0C61, 354: /* GRAS */ 355: 0x0C80, 0x0C82, 0x0C84, 0x0C85, 0x0C90, 0x0C98, 0x0CA0, 0x0CA0, 356: 0x0CB0, 0x0CB2, 0x2180, 0x2185, 0x2580, 0x2585, 357: /* RB */ 358: 0x0CC1, 0x0CC1, 0x0CC4, 0x0CC7, 0x0CCC, 0x0CCC, 0x0CD0, 0x0CD8, 359: 0x0CE0, 0x0CE5, 0x0CE8, 0x0CE8, 0x0CEC, 0x0CF1, 0x0CFB, 0x0D0E, 360: 0x2100, 0x211E, 0x2140, 0x2145, 0x2500, 0x251E, 0x2540, 0x2545, MATCH LINES: 401 389: /* GRAS CTX 1 */ 390: 0xE800, 0xE806, 0xE810, 0xE89A, 0xE8A0, 0xE8A4, 0xE8AA, 0xE8EB, 391: 0xE900, 0xE905, 392: /* PC CTX 1 */ 393: 0xEB80, 0xEB8F, 0xEBB0, 0xEBB0, 394: /* VFD CTX 1 */ 395: 0xEC00, 0xEC05, 0xEC08, 0xECE9, 0xECF0, 0xECF0, 396: /* VPC CTX 1 */ 397: 0xEA80, 0xEA80, 0xEA82, 0xEAA3, 0xEAA5, 0xEAC2, 398: }; 399: 400: /* 401: * GPMU registers to dump for A5XX on snapshot. 402: * Registers in pairs - first value is the start offset, second 403: * is the stop offset (inclusive) 404: */ 405: 406: static const unsigned int a5xx_gpmu_registers[] = { 407: /* GPMU */ 408: 0xA800, 0xA8FF, 0xAC60, 0xAC60, 409: }; 410: 411: /* 412: * Set of registers to dump for A5XX before actually triggering crash dumper. 413: * Registers in pairs - first value is the start offset, second 414: * is the stop offset (inclusive) 415: */ 416: static const unsigned int a5xx_pre_crashdumper_registers[] = { 417: /* RBBM: RBBM_STATUS - RBBM_STATUS3 */ 418: 0x04F5, 0x04F7, 0x0530, 0x0530, 419: /* CP: CP_STATUS_1 */ 420: 0x0B1D, 0x0B1D, 421: }; 422: 423: 424: struct a5xx_hlsq_sp_tp_regs { 425: unsigned int statetype; MATCH LINES: 597, 600, 601, 608, 622, 623, 640, 641, 642, 648, 651, 656, 664, 667, 672, 673, 679, 682, 690, 694, 705, 731 585: {A5XX_SP_S_CS_CB_BASE_DIRTY, 0x1}, 586: {A5XX_SP_S_CS_UAV_BASE_DIRTY, 0x2}, 587: {A5XX_HLSQ_ICB, 0x200}, 588: {A5XX_HLSQ_ICB_CB_BASE_DIRTY, 0x4}, 589: {A5XX_SP_POWER_RESTORE_RAM, 0x140}, 590: {A5XX_TP_POWER_RESTORE_RAM, 0x40}, 591: }; 592: 593: static struct kgsl_memdesc *capturescript; 594: static struct kgsl_memdesc *registers; 595: static bool crash_dump_valid; 596: 597: static size_t a5xx_snapshot_shader_memory(struct kgsl_device *device, 598: u8 *buf, size_t remain, void *priv) 599: { 600: struct kgsl_snapshot_shader *header = 601: (struct kgsl_snapshot_shader *) buf; 602: struct a5xx_shader_block_info *info = 603: (struct a5xx_shader_block_info *) priv; 604: struct a5xx_shader_block *block = info->block; 605: unsigned int *data = (unsigned int *) (buf + sizeof(*header)); 606: 607: if (remain < SHADER_SECTION_SZ(block->sz)) { 608: SNAPSHOT_ERR_NOMEM(device, "SHADER MEMORY"); 609: return 0; 610: } 611: 612: header->type = block->statetype; 613: header->index = info->bank; 614: header->size = block->sz; 615: 616: memcpy(data, registers->hostptr + info->offset, 617: block->sz * sizeof(unsigned int)); 618: 619: return SHADER_SECTION_SZ(block->sz); 620: } 621: 622: static void a5xx_snapshot_shader(struct kgsl_device *device, 623: struct kgsl_snapshot *snapshot) 624: { 625: unsigned int i, j; 626: struct a5xx_shader_block_info info; 627: 628: /* Shader blocks can only be read by the crash dumper */ 629: if (!crash_dump_valid) 630: return; 631: 632: for (i = 0; i < ARRAY_SIZE(a5xx_shader_blocks); i++) { 633: for (j = 0; j < A5XX_NUM_SHADER_BANKS; j++) { 634: info.block = &a5xx_shader_blocks[i]; 635: info.bank = j; 636: info.offset = a5xx_shader_blocks[i].offset + 637: (j * a5xx_shader_blocks[i].sz); 638: 639: /* Shader working/shadow memory */ 640: kgsl_snapshot_add_section(device, 641: KGSL_SNAPSHOT_SECTION_SHADER, 642: snapshot, a5xx_snapshot_shader_memory, &info); 643: } 644: } 645: } 646: 647: /* Dump registers which get affected by crash dumper trigger */ 648: static size_t a5xx_snapshot_pre_crashdump_regs(struct kgsl_device *device, 649: u8 *buf, size_t remain, void *priv) 650: { 651: struct kgsl_snapshot_registers pre_cdregs = { 652: .regs = a5xx_pre_crashdumper_registers, 653: .count = ARRAY_SIZE(a5xx_pre_crashdumper_registers)/2, 654: }; 655: 656: return kgsl_snapshot_dump_registers(device, buf, remain, &pre_cdregs); 657: } 658: 659: struct registers { 660: const unsigned int *regs; 661: size_t size; 662: }; 663: 664: static size_t a5xx_legacy_snapshot_registers(struct kgsl_device *device, 665: u8 *buf, size_t remain, const unsigned int *regs, size_t size) 666: { 667: struct kgsl_snapshot_registers snapshot_regs = { 668: .regs = regs, 669: .count = size / 2, 670: }; 671: 672: return kgsl_snapshot_dump_registers(device, buf, remain, 673: &snapshot_regs); 674: } 675: 676: #define REG_PAIR_COUNT(_a, _i) \ 677: (((_a)[(2 * (_i)) + 1] - (_a)[2 * (_i)]) + 1) 678: 679: static size_t a5xx_snapshot_registers(struct kgsl_device *device, u8 *buf, 680: size_t remain, void *priv) 681: { 682: struct kgsl_snapshot_regs *header = (struct kgsl_snapshot_regs *)buf; 683: unsigned int *data = (unsigned int *)(buf + sizeof(*header)); 684: unsigned int *src = (unsigned int *) registers->hostptr; 685: struct registers *regs = (struct registers *)priv; 686: unsigned int j, k; 687: unsigned int count = 0; 688: 689: if (!crash_dump_valid) 690: return a5xx_legacy_snapshot_registers(device, buf, remain, 691: regs->regs, regs->size); 692: 693: if (remain < sizeof(*header)) { 694: SNAPSHOT_ERR_NOMEM(device, "REGISTERS"); 695: return 0; 696: } 697: 698: remain -= sizeof(*header); 699: 700: for (j = 0; j < regs->size / 2; j++) { 701: unsigned int start = regs->regs[2 * j]; 702: unsigned int end = regs->regs[(2 * j) + 1]; 703: 704: if (remain < ((end - start) + 1) * 8) { 705: SNAPSHOT_ERR_NOMEM(device, "REGISTERS"); 706: goto out; 707: } 708: 709: remain -= ((end - start) + 1) * 8; 710: 711: for (k = start; k <= end; k++, count++) { 712: *data++ = k; 713: *data++ = *src++; 714: } 715: } 716: 717: out: 718: header->count = count; 719: 720: /* Return the size of the section */ 721: return (count * 8) + sizeof(*header); 722: } 723: 724: static void _a5xx_do_crashdump(struct kgsl_device *device) 725: { 726: unsigned long wait_time; 727: unsigned int reg = 0; 728: 729: crash_dump_valid = false; 730: 731: if (!device->snapshot_crashdumper) 732: return; 733: 734: if (IS_ERR_OR_NULL(capturescript) || IS_ERR_OR_NULL(registers)) 735: return; 736: 737: /* IF the SMMU is stalled we cannot do a crash dump */ 738: if (adreno_smmu_is_stalled(ADRENO_DEVICE(device))) 739: return; 740: 741: /* Turn on APRIV so we can access the buffers */ 742: kgsl_regwrite(device, A5XX_CP_CNTL, 1); 743: 744: kgsl_regwrite(device, A5XX_CP_CRASH_SCRIPT_BASE_LO, 745: lower_32_bits(capturescript->gpuaddr)); 746: kgsl_regwrite(device, A5XX_CP_CRASH_SCRIPT_BASE_HI, 747: upper_32_bits(capturescript->gpuaddr)); 748: kgsl_regwrite(device, A5XX_CP_CRASH_DUMP_CNTL, 1); 749: 750: wait_time = jiffies + msecs_to_jiffies(CP_CRASH_DUMPER_TIMEOUT); 751: while (!time_after(jiffies, wait_time)) { 752: kgsl_regread(device, A5XX_CP_CRASH_DUMP_CNTL, ®); 753: if (reg & 0x4) 754: break; 755: cpu_relax(); MATCH LINES: 782, 785, 794, 808, 812, 828, 832, 847, 851, 861, 865, 874, 878, 888, 892, 902, 903, 904, 907, 909, 910, 919, 923, 928, 930, 931, 934, 935, 938, 946, 947, 953, 954, 959, 960, 963, 967, 971, 976, 981, 986, 987, 991, 992, 994, 995, 998, 999, 1001, 1002, 1005, 1008, 1011 770: { 771: unsigned int i; 772: unsigned int *src = registers->hostptr + regs->offset; 773: 774: for (i = 0; i < regs->size; i++) { 775: *data++ = regs->ahbaddr + i; 776: *data++ = *(src + i); 777: } 778: 779: return (2 * regs->size); 780: } 781: 782: static size_t a5xx_snapshot_dump_hlsq_sp_tp_regs(struct kgsl_device *device, 783: u8 *buf, size_t remain, void *priv) 784: { 785: struct kgsl_snapshot_regs *header = (struct kgsl_snapshot_regs *)buf; 786: unsigned int *data = (unsigned int *)(buf + sizeof(*header)); 787: int count = 0, i; 788: 789: /* Figure out how many registers we are going to dump */ 790: for (i = 0; i < ARRAY_SIZE(a5xx_hlsq_sp_tp_registers); i++) 791: count += a5xx_hlsq_sp_tp_registers[i].size; 792: 793: if (remain < (count * 8) + sizeof(*header)) { 794: SNAPSHOT_ERR_NOMEM(device, "REGISTERS"); 795: return 0; 796: } 797: 798: for (i = 0; i < ARRAY_SIZE(a5xx_hlsq_sp_tp_registers); i++) 799: data += get_hlsq_registers(device, 800: &a5xx_hlsq_sp_tp_registers[i], data); 801: 802: header->count = count; 803: 804: /* Return the size of the section */ 805: return (count * 8) + sizeof(*header); 806: } 807: 808: static size_t a5xx_snapshot_cp_merciu(struct kgsl_device *device, u8 *buf, 809: size_t remain, void *priv) 810: { 811: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 812: struct kgsl_snapshot_debug *header = (struct kgsl_snapshot_debug *)buf; 813: unsigned int *data = (unsigned int *)(buf + sizeof(*header)); 814: int i, size; 815: 816: if (adreno_is_a505_or_a506(adreno_dev) || adreno_is_a508(adreno_dev) || 817: adreno_is_a540(adreno_dev) || adreno_is_a512(adreno_dev)) 818: size = 1024; 819: else if (adreno_is_a510(adreno_dev)) 820: size = 32; 821: else 822: size = 64; 823: 824: /* The MERCIU data is two dwords per entry */ 825: size = size << 1; 826: 827: if (remain < DEBUG_SECTION_SZ(size)) { 828: SNAPSHOT_ERR_NOMEM(device, "CP MERCIU DEBUG"); 829: return 0; 830: } 831: 832: header->type = SNAPSHOT_DEBUG_CP_MERCIU; 833: header->size = size; 834: 835: kgsl_regwrite(device, A5XX_CP_MERCIU_DBG_ADDR, 0); 836: 837: for (i = 0; i < size; i++) { 838: kgsl_regread(device, A5XX_CP_MERCIU_DBG_DATA_1, 839: &data[(i * 2)]); 840: kgsl_regread(device, A5XX_CP_MERCIU_DBG_DATA_2, 841: &data[(i * 2) + 1]); 842: } 843: 844: return DEBUG_SECTION_SZ(size); 845: } 846: 847: static size_t a5xx_snapshot_cp_roq(struct kgsl_device *device, u8 *buf, 848: size_t remain, void *priv) 849: { 850: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 851: struct kgsl_snapshot_debug *header = (struct kgsl_snapshot_debug *) buf; 852: u32 size, *data = (u32 *) (buf + sizeof(*header)); 853: 854: if (adreno_is_a505_or_a506(adreno_dev) || adreno_is_a508(adreno_dev) || 855: adreno_is_a510(adreno_dev)) 856: size = 256; 857: else 858: size = 512; 859: 860: if (remain < DEBUG_SECTION_SZ(size)) { 861: SNAPSHOT_ERR_NOMEM(device, "CP ROQ DEBUG"); 862: return 0; 863: } 864: 865: header->type = SNAPSHOT_DEBUG_CP_ROQ; 866: header->size = size; 867: 868: kgsl_regmap_read_indexed(&device->regmap, A5XX_CP_ROQ_DBG_ADDR, 869: A5XX_CP_ROQ_DBG_DATA, data, size); 870: 871: return DEBUG_SECTION_SZ(size); 872: } 873: 874: static size_t a5xx_snapshot_cp_meq(struct kgsl_device *device, u8 *buf, 875: size_t remain, void *priv) 876: { 877: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 878: struct kgsl_snapshot_debug *header = (struct kgsl_snapshot_debug *) buf; 879: u32 size, *data = (u32 *) (buf + sizeof(*header)); 880: 881: if (adreno_is_a505_or_a506(adreno_dev) || adreno_is_a508(adreno_dev) || 882: adreno_is_a510(adreno_dev)) 883: size = 32; 884: else 885: size = 64; 886: 887: if (remain < DEBUG_SECTION_SZ(size)) { 888: SNAPSHOT_ERR_NOMEM(device, "CP MEQ DEBUG"); 889: return 0; 890: } 891: 892: header->type = SNAPSHOT_DEBUG_CP_MEQ; 893: header->size = size; 894: 895: kgsl_regmap_read_indexed(&device->regmap, A5XX_CP_MEQ_DBG_ADDR, 896: A5XX_CP_MEQ_DBG_DATA, data, size); 897: 898: return DEBUG_SECTION_SZ(size); 899: } 900: 901: /* 902: * a5xx_snapshot() - A5XX GPU snapshot function 903: * @adreno_dev: Device being snapshotted 904: * @snapshot: Pointer to the snapshot instance 905: * 906: * This is where all of the A5XX specific bits and pieces are grabbed 907: * into the snapshot memory 908: */ 909: void a5xx_snapshot(struct adreno_device *adreno_dev, 910: struct kgsl_snapshot *snapshot) 911: { 912: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 913: u32 hi, lo; 914: struct registers regs; 915: 916: /* Disable Clock gating temporarily for the debug bus to work */ 917: a5xx_hwcg_set(adreno_dev, false); 918: 919: /* Save some CP information that the generic snapshot uses */ 920: kgsl_regread(device, A5XX_CP_IB1_BASE, &lo); 921: kgsl_regread(device, A5XX_CP_IB1_BASE_HI, &hi); 922: 923: snapshot->ib1base = (((u64) hi) << 32) | lo; 924: 925: kgsl_regread(device, A5XX_CP_IB2_BASE, &lo); 926: kgsl_regread(device, A5XX_CP_IB2_BASE_HI, &hi); 927: 928: snapshot->ib2base = (((u64) hi) << 32) | lo; 929: 930: kgsl_regread(device, A5XX_CP_IB1_BUFSZ, &snapshot->ib1size); 931: kgsl_regread(device, A5XX_CP_IB2_BUFSZ, &snapshot->ib2size); 932: 933: /* Dump the registers which get affected by crash dumper trigger */ 934: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS, 935: snapshot, a5xx_snapshot_pre_crashdump_regs, NULL); 936: 937: /* Dump vbif registers as well which get affected by crash dumper */ 938: SNAPSHOT_REGISTERS(device, snapshot, a5xx_vbif_registers); 939: 940: /* Try to run the crash dumper */ 941: _a5xx_do_crashdump(device); 942: 943: regs.regs = a5xx_registers; 944: regs.size = ARRAY_SIZE(a5xx_registers); 945: 946: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS, snapshot, 947: a5xx_snapshot_registers, ®s); 948: 949: if (a5xx_has_gpmu(adreno_dev)) { 950: regs.regs = a5xx_gpmu_registers; 951: regs.size = ARRAY_SIZE(a5xx_gpmu_registers); 952: 953: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS, 954: snapshot, a5xx_snapshot_registers, ®s); 955: } 956: 957: 958: /* Dump SP TP HLSQ registers */ 959: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS, snapshot, 960: a5xx_snapshot_dump_hlsq_sp_tp_regs, NULL); 961: 962: /* CP_PFP indexed registers */ 963: kgsl_snapshot_indexed_registers(device, snapshot, 964: A5XX_CP_PFP_STAT_ADDR, A5XX_CP_PFP_STAT_DATA, 0, 36); 965: 966: /* CP_ME indexed registers */ 967: kgsl_snapshot_indexed_registers(device, snapshot, 968: A5XX_CP_ME_STAT_ADDR, A5XX_CP_ME_STAT_DATA, 0, 29); 969: 970: /* CP_DRAW_STATE */ 971: kgsl_snapshot_indexed_registers(device, snapshot, 972: A5XX_CP_DRAW_STATE_ADDR, A5XX_CP_DRAW_STATE_DATA, 973: 0, 1 << A5XX_CP_DRAW_STATE_ADDR_WIDTH); 974: 975: /* ME_UCODE Cache */ 976: kgsl_snapshot_indexed_registers(device, snapshot, 977: A5XX_CP_ME_UCODE_DBG_ADDR, A5XX_CP_ME_UCODE_DBG_DATA, 978: 0, 0x53F); 979: 980: /* PFP_UCODE Cache */ 981: kgsl_snapshot_indexed_registers(device, snapshot, 982: A5XX_CP_PFP_UCODE_DBG_ADDR, A5XX_CP_PFP_UCODE_DBG_DATA, 983: 0, 0x53F); 984: 985: /* CP MEQ */ 986: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_DEBUG, 987: snapshot, a5xx_snapshot_cp_meq, NULL); 988: 989: /* CP ROQ */ 990: 991: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_DEBUG, 992: snapshot, a5xx_snapshot_cp_roq, NULL); 993: 994: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_DEBUG, 995: snapshot, a5xx_snapshot_cp_merciu, NULL); 996: 997: /* CP PFP and PM4 */ 998: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_DEBUG, 999: snapshot, a5xx_snapshot_cp_pfp, NULL); 1000: 1001: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_DEBUG, 1002: snapshot, a5xx_snapshot_cp_pm4, NULL); 1003: 1004: /* Debug bus */ 1005: a5xx_snapshot_debugbus(device, snapshot); 1006: 1007: /* Shader memory */ 1008: a5xx_snapshot_shader(device, snapshot); 1009: 1010: /* Preemption record */ 1011: adreno_snapshot_preemption_record(device, snapshot); 1012: } 1013: 1014: static int _a5xx_crashdump_init_shader(struct a5xx_shader_block *block, 1015: uint64_t *ptr, uint64_t *offset) 1016: { 1017: int qwords = 0; 1018: unsigned int j; 1019: 1020: /* Capture each bank in the block */ 1021: for (j = 0; j < A5XX_NUM_SHADER_BANKS; j++) { 1022: /* Program the aperture */ 1023: ptr[qwords++] = 1024: (block->statetype << A5XX_SHADER_STATETYPE_SHIFT) | j; 1025: ptr[qwords++] = (((uint64_t) A5XX_HLSQ_DBG_READ_SEL << 44)) | 1026: (1 << 21) | 1; 1027: 1028: /* Read all the data in one chunk */ 1029: ptr[qwords++] = registers->gpuaddr + *offset; 1030: ptr[qwords++] = 1031: (((uint64_t) A5XX_HLSQ_DBG_AHB_READ_APERTURE << 44)) | 1032: block->sz; 1033: 1034: /* Remember the offset of the first bank for easy access */ 1035: if (j == 0) --- FILE: \adreno_a6xx.c | HITS: 43 --- MATCH LINES: 257, 258 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: MATCH LINES: 426 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, MATCH LINES: 792 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)); MATCH LINES: 942, 943, 968 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: 951: /* 952: * Operation mode mask 953: * 954: * This ordinal provides the option to disable the 955: * save/restore of performance counters across preemption. 956: */ 957: #define CP_INIT_OPERATION_MODE_MASK BIT(6) 958: 959: /* Register initialization list */ 960: #define CP_INIT_REGISTER_INIT_LIST BIT(7) 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; MATCH LINES: 1036 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); MATCH LINES: 1269, 1272 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: MATCH LINES: 1424, 1453, 1468, 1471, 1474, 1492 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: { MATCH LINES: 1732, 1734 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"; MATCH LINES: 1778 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: { MATCH LINES: 1856 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: MATCH LINES: 1935, 1936, 1969, 1970 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: MATCH LINES: 2109 2097: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_WPTR, A6XX_CP_RB_WPTR), 2098: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_CNTL, A6XX_CP_RB_CNTL), 2099: ADRENO_REG_DEFINE(ADRENO_REG_CP_ME_CNTL, A6XX_CP_SQE_CNTL), 2100: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BASE, A6XX_CP_IB1_BASE), 2101: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BASE_HI, A6XX_CP_IB1_BASE_HI), 2102: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BUFSZ, A6XX_CP_IB1_REM_SIZE), 2103: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BASE, A6XX_CP_IB2_BASE), 2104: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BASE_HI, A6XX_CP_IB2_BASE_HI), 2105: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BUFSZ, A6XX_CP_IB2_REM_SIZE), 2106: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_STATUS, A6XX_RBBM_STATUS), 2107: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_STATUS3, A6XX_RBBM_STATUS3), 2108: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_INT_0_MASK, A6XX_RBBM_INT_0_MASK), 2109: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_SW_RESET_CMD, A6XX_RBBM_SW_RESET_CMD), 2110: ADRENO_REG_DEFINE(ADRENO_REG_GMU_AO_HOST_INTERRUPT_MASK, 2111: A6XX_GMU_AO_HOST_INTERRUPT_MASK), 2112: ADRENO_REG_DEFINE(ADRENO_REG_GMU_GMU2HOST_INTR_MASK, 2113: A6XX_GMU_GMU2HOST_INTR_MASK), 2114: }; 2115: 2116: int a6xx_perfcounter_update(struct adreno_device *adreno_dev, 2117: struct adreno_perfcount_register *reg, bool update_reg) 2118: { 2119: void *ptr = adreno_dev->pwrup_reglist->hostptr; 2120: struct cpu_gpu_lock *lock = ptr; 2121: u32 *data = ptr + sizeof(*lock); 2122: u64 reglist_size_dwords = adreno_dev->pwrup_reglist->size / sizeof(u32); 2123: u64 lock_size_dwords = sizeof(*lock) / sizeof(u32); 2124: int i, offset = 0; 2125: bool select_reg_present = false; 2126: u32 pending_pairs = 2; /* No of pairs to add: and */ 2127: 2128: for (i = 0; i < lock->list_length >> 1; i++) { 2129: if (data[offset] == reg->select) { 2130: select_reg_present = true; 2131: break; 2132: } 2133: MATCH LINES: 2388, 2395, 2396, 2414, 2416, 2419, 2437, 2444, 2445, 2463, 2470, 2471, 2487, 2495, 2496, 2514, 2521, 2522 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: 9 --- MATCH LINES: 77, 78 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 */ 72: u32 vbif_count; 73: /** @veto_fal10: veto status for fal10 feature */ 74: bool veto_fal10; 75: /** @pdc_in_aop: True if PDC programmed in AOP */ 76: bool pdc_in_aop; 77: /** @hang_detect_cycles: Hang detect counter timeout value */ 78: u32 hang_detect_cycles; 79: /** @protected_regs: Array of protected registers for the target */ 80: const struct adreno_protected_regs *protected_regs; 81: /** @disable_tseskip: True if TSESkip logic is disabled */ 82: bool disable_tseskip; 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 MATCH LINES: 180 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: MATCH LINES: 240, 241 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: /** MATCH LINES: 317 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: MATCH LINES: 396, 399, 401 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_gmu.c | HITS: 57 --- MATCH LINES: 549, 550 537: _regwrite(cfg, PDC_GPU_SEQ_START_ADDR, 0); 538: _regwrite(cfg, PDC_GPU_ENABLE_PDC, PDC_ENABLE_REG_VALUE); 539: 540: /* ensure no writes happen before the uCode is fully written */ 541: wmb(); 542: return 0; 543: } 544: 545: /* GMU timeouts */ 546: #define GMU_IDLE_TIMEOUT 100 /* ms */ 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: MATCH LINES: 641, 650, 651, 661, 684 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); MATCH LINES: 760, 761 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); MATCH LINES: 893, 897, 903 881: { 882: if (req == oob_gpu) 883: return "oob_gpu"; 884: else if (req == oob_perfcntr) 885: return "oob_perfcntr"; 886: else if (req == oob_boot_slumber) 887: return "oob_boot_slumber"; 888: else if (req == oob_dcvs) 889: return "oob_dcvs"; 890: return "unknown"; 891: } 892: 893: static void trigger_reset_recovery(struct adreno_device *adreno_dev, 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)); MATCH LINES: 943, 944 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", MATCH LINES: 1153 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 */ MATCH LINES: 1382, 1403 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, MATCH LINES: 1537, 1544, 1545 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 MATCH LINES: 1586 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; MATCH LINES: 1783, 1789, 1792, 1810, 1813, 1817, 1822 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); MATCH LINES: 1930 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, MATCH LINES: 1996, 2000 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) MATCH LINES: 2070 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); MATCH LINES: 2111, 2119, 2128, 2130, 2131, 2138 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) MATCH LINES: 2220, 2221, 2225, 2227 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: MATCH LINES: 2332 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); MATCH LINES: 2431 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); MATCH LINES: 2513 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: MATCH LINES: 2967, 2980, 2981, 2982, 2984, 2985, 2990 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); MATCH LINES: 3100, 3101 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: 3119: /* 3120: * There is a possible deadlock scenario during kgsl firmware reading 3121: * (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl 3122: * device mutex is held and then firmware_request_nowarn is called for reading 3123: * firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock. 3124: * Whereas in case of devfreq update calls triggered by thermal/bcl or 3125: * devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then MATCH LINES: 3477, 3487, 3490 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: { --- FILE: \adreno_a6xx_gmu.h | HITS: 21 --- MATCH LINES: 42 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; 56: /** @pdc_cfg_base: Base address of PDC cfg registers */ 57: void __iomem *pdc_cfg_base; 58: /** @pdc_seq_base: Base address of PDC seq registers */ 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 */ MATCH LINES: 96, 97, 98, 101, 103, 104, 107, 118, 123, 138, 140, 143, 145, 146 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 MATCH LINES: 204, 220, 254, 256, 258, 259 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: --- FILE: \adreno_a6xx_gmu_snapshot.c | HITS: 61 --- MATCH LINES: 11 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, MATCH LINES: 90, 99 78: 79: static const unsigned int a663_gmu_gpucc_registers[] = { 80: /* GPU CC */ 81: 0x24000, 0x2400e, 0x24400, 0x2440e, 0x25800, 0x25804, 0x25c00, 0x25c04, 82: 0x26000, 0x26004, 0x26400, 0x26405, 0x26414, 0x2641d, 0x2642a, 0x26430, 83: 0x26432, 0x26432, 0x26441, 0x26455, 0x26466, 0x26468, 0x26478, 0x2647a, 84: 0x26489, 0x2648a, 0x2649c, 0x2649e, 0x264a0, 0x264a3, 0x264b3, 0x264b5, 85: 0x264c5, 0x264c7, 0x264d6, 0x264d8, 0x264e8, 0x264e9, 0x264f9, 0x264fc, 86: 0x2650b, 0x2650c, 0x2651c, 0x2651e, 0x26540, 0x26570, 0x26600, 0x26616, 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, 162, 163, 168, 172, 184, 188, 189, 199, 203, 213, 214, 229, 231, 233, 235, 237, 239, 241, 242, 243, 249, 252, 253, 268, 292, 293, 299, 304, 305, 308, 309, 310, 312, 313, 314, 319, 320, 321, 324, 326, 327, 332, 333, 335, 337, 339, 342, 346, 351, 355, 359, 363, 365, 368, 378, 390, 391 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; 282: *data++ = val; 283: } 284: } 285: 286: header->count = count; 287: 288: /* Return the size of the section */ 289: return (count * 8) + sizeof(*header); 290: } 291: 292: static void snapshot_rscc_registers(struct adreno_device *adreno_dev, 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: 5 --- MATCH LINES: 257, 289, 320 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: MATCH LINES: 663, 688 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; --- FILE: \adreno_a6xx_hwsched.c | HITS: 43 --- MATCH LINES: 13, 20, 21, 29, 31, 40, 42, 51, 52, 53, 57, 58, 59, 63, 64, 65, 69, 70, 71, 75, 79, 80, 81, 89 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 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, 54: entry->md); 55: 56: if (entry->desc.mem_kind == HFI_MEMKIND_SCRATCH) 57: kgsl_snapshot_add_section(device, 58: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 59: snapshot, adreno_snapshot_global, 60: entry->md); 61: 62: if (entry->desc.mem_kind == HFI_MEMKIND_PROFILE) 63: kgsl_snapshot_add_section(device, 64: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 65: snapshot, adreno_snapshot_global, 66: entry->md); 67: 68: if (entry->desc.mem_kind == HFI_MEMKIND_CSW_SMMU_INFO) 69: kgsl_snapshot_add_section(device, 70: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 71: snapshot, adreno_snapshot_global, 72: entry->md); 73: 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; MATCH LINES: 143, 176 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); MATCH LINES: 217, 247 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: MATCH LINES: 333, 371, 384, 385, 386, 388, 389, 391 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) MATCH LINES: 493 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: MATCH LINES: 566, 567 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 585: * (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl 586: * device mutex is held and then firmware_request_nowarn is called for reading 587: * firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock. 588: * Whereas in case of devfreq update calls triggered by thermal/bcl or 589: * devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then 590: * tries to take kgsl device mutex as part of get_dev_status/target 591: * calls. This results in deadlock when both thread are unable to acquire MATCH LINES: 687 675: if (device->submit_now) { 676: spin_unlock(&device->submit_lock); 677: kgsl_pwrscale_update(device); 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 MATCH LINES: 792 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: MATCH LINES: 929, 936 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: --- FILE: \adreno_a6xx_hwsched.h | HITS: 7 --- MATCH LINES: 36, 43, 46, 48, 50, 52, 53 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: */ --- FILE: \adreno_a6xx_hwsched_hfi.c | HITS: 18 --- MATCH LINES: 165 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; 163: } 164: 165: static void log_gpu_fault_legacy(struct adreno_device *adreno_dev) 166: { 167: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)); 168: struct hfi_context_bad_cmd_legacy *cmd = adreno_dev->hwsched.ctxt_bad; 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", MATCH LINES: 262 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; 260: } 261: 262: static void log_gpu_fault(struct adreno_device *adreno_dev) 263: { 264: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)); 265: struct hfi_context_bad_cmd *cmd = adreno_dev->hwsched.ctxt_bad; 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", MATCH LINES: 336, 338 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: { MATCH LINES: 431, 437, 452 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, MATCH LINES: 731, 740, 763, 783, 810, 814 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; MATCH LINES: 902 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) MATCH LINES: 1563 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) 1577: cmd_sizebytes = sizeof(*cmd); 1578: else 1579: cmd_sizebytes = sizeof(*cmd) + 1580: (sizeof(struct hfi_issue_ib) * cmdobj->numibs); 1581: 1582: if (WARN_ON(cmd_sizebytes > HFI_MAX_MSG_SIZE)) 1583: return -EMSGSIZE; 1584: 1585: cmd = kzalloc(cmd_sizebytes, GFP_KERNEL); 1586: if (cmd == NULL) 1587: return -ENOMEM; MATCH LINES: 1646, 1649, 1651 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: } 1640: 1641: static void trigger_context_unregister_fault(struct adreno_device *adreno_dev, 1642: struct kgsl_context *context) 1643: { 1644: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1645: 1646: gmu_core_fault_snapshot(device, GMU_FAULT_CTX_UNREGISTER); 1647: 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; --- FILE: \adreno_a6xx_perfcounter.c | HITS: 2 --- MATCH LINES: 131, 134 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. 136: */ 137: if (ret == -EAGAIN) 138: ret = 0; 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, --- FILE: \adreno_a6xx_preempt.c | HITS: 15 --- MATCH LINES: 19, 40, 49, 53, 60, 62, 64, 102 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++; MATCH LINES: 406, 408, 410 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); MATCH LINES: 627, 646, 655, 691 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) --- FILE: \adreno_a6xx_rgmu.c | HITS: 24 --- MATCH LINES: 18 6: 7: #include 8: #include 9: #include 10: #include 11: #include 12: #include 13: #include 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: }; MATCH LINES: 147 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: } MATCH LINES: 349 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) MATCH LINES: 423, 426, 429, 437 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); MATCH LINES: 489, 490, 495, 498 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); MATCH LINES: 622, 628 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); MATCH LINES: 765, 778, 779, 780, 782, 783, 788, 823 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) MATCH LINES: 1143, 1149, 1152 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); --- FILE: \adreno_a6xx_rgmu.h | HITS: 7 --- MATCH LINES: 74, 79, 82, 84, 87, 89, 90 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: 6 --- MATCH LINES: 166, 167, 169, 171 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: MATCH LINES: 228 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, MATCH LINES: 310 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)); --- FILE: \adreno_a6xx_snapshot.c | HITS: 176 --- MATCH LINES: 9 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: MATCH LINES: 257 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, MATCH LINES: 596, 599, 607, 608, 611, 614, 622, 626, 638, 657, 660, 665, 668, 671, 672, 680, 684, 691, 721, 724, 725, 732, 735, 749, 750, 763, 764, 765, 770, 771, 779, 786, 787, 790, 796, 805, 809, 810, 831, 834, 835, 844, 848, 871, 894, 897, 898, 909, 913, 933, 949, 952, 953, 961, 973, 998, 1001, 1002, 1011, 1015, 1031, 1049, 1050, 1063, 1064, 1065, 1070, 1071, 1072, 1076, 1079, 1080, 1090, 1115, 1135, 1138, 1139, 1150, 1153, 1170, 1188, 1189, 1206, 1207, 1208, 1238, 1239, 1243, 1244, 1258, 1279, 1280, 1283, 1284, 1303 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++; MATCH LINES: 1388, 1391, 1394, 1395, 1408, 1422, 1423, 1424 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) | MATCH LINES: 1507, 1508, 1509, 1515, 1516, 1517, 1528, 1529, 1530, 1533, 1534, 1535, 1541, 1542, 1543, 1552, 1553, 1554, 1555, 1567, 1590, 1603, 1620, 1623, 1631, 1635, 1657, 1658, 1659, 1662, 1664, 1665, 1674, 1679, 1683, 1688, 1689, 1694, 1698, 1711, 1716, 1718, 1719, 1721, 1723, 1726, 1727, 1731, 1733, 1737, 1751, 1752, 1756, 1760, 1765, 1773, 1776, 1779, 1785, 1789, 1798, 1799, 1803, 1805, 1809, 1812, 1815, 1825, 1829, 1831, 1835 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; --- FILE: \adreno_coresight.c | HITS: 1 --- MATCH LINES: 191 179: struct adreno_coresight_device *adreno_csdev = dev_get_drvdata(&csdev->dev); 180: const struct adreno_coresight *coresight = adreno_csdev->coresight; 181: struct kgsl_device *device = adreno_csdev->device; 182: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 183: int ret = 0; 184: 185: kgsl_mutex_lock(&device->mutex); 186: if (!adreno_csdev->enabled) { 187: int i; 188: 189: adreno_csdev->enabled = true; 190: 191: /* Reset all the debug registers to their default values */ 192: for (i = 0; i < coresight->count; i++) 193: coresight->registers[i].value = 194: coresight->registers[i].initial; 195: 196: adreno_dev->coresight_en_cnt++; 197: 198: /* GMU takes care of DBGC interrupt mask for HWSCHED */ 199: if (adreno_dev->coresight_en_cnt == 1) { 200: if (adreno_dev->hwsched_enabled) 201: gmu_core_set_vrb_register(device->gmu_core.vrb, 202: VRB_DBGC_FAULT_ENABLE, 1); 203: else 204: adreno_dev->irq_mask |= ADRENO_DEBUG_BUS_INT_MASK; 205: } 206: 207: ret = adreno_active_count_get(adreno_dev); 208: if (!ret) { 209: _adreno_coresight_set(adreno_dev, adreno_csdev); 210: adreno_active_count_put(adreno_dev); 211: } 212: 213: } 214: kgsl_mutex_unlock(&device->mutex); 215: return ret; --- FILE: \adreno_cp_parser.c | HITS: 15 --- MATCH LINES: 13, 21 1: // SPDX-License-Identifier: GPL-2.0-only 2: /* 3: * Copyright (c) 2013-2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #include 8: #include 9: 10: #include "adreno.h" 11: #include "adreno_cp_parser.h" 12: #include "adreno_pm4types.h" 13: #include "adreno_snapshot.h" 14: 15: #define MAX_IB_OBJS 1000 16: #define NUM_SET_DRAW_GROUPS 32 17: #define IB_LEVEL_1 1 18: #define IB_LEVEL_2 2 19: #define IB_LEVEL_3 3 20: 21: struct snapshot_ib_meta metadata; 22: 23: struct set_draw_state { 24: uint64_t cmd_stream_addr; 25: uint64_t cmd_stream_dwords; 26: }; 27: 28: /* List of variables used when parsing an IB */ 29: struct ib_parser_variables { 30: /* List of registers containing addresses and their sizes */ 31: unsigned int cp_addr_regs[ADRENO_CP_ADDR_MAX]; 32: /* 32 groups of command streams in set draw state packets */ 33: struct set_draw_state set_draw_groups[NUM_SET_DRAW_GROUPS]; 34: }; 35: 36: static int adreno_ib_find_objs(struct kgsl_device *device, 37: struct kgsl_process_private *process, 38: uint64_t gpuaddr, uint64_t dwords, 39: uint64_t ib2base, int obj_type, 40: struct adreno_ib_object_list *ib_obj_list, 41: int ib_level); 42: 43: static int ib_parse_type7_set_draw_state(struct kgsl_device *device, 44: unsigned int *ptr, int size, 45: struct kgsl_process_private *process, MATCH LINES: 88 76: * Checks if an address range overlaps with a list of address ranges 77: * Returns the entry from list which overlaps else NULL 78: */ 79: static struct adreno_ib_object *adreno_ib_check_overlap(uint64_t gpuaddr, 80: uint64_t size, int type, 81: struct adreno_ib_object_list *ib_obj_list) 82: { 83: struct adreno_ib_object *ib_obj; 84: int i; 85: 86: for (i = 0; i < ib_obj_list->num_objs; i++) { 87: ib_obj = &(ib_obj_list->obj_list[i]); 88: if ((type == ib_obj->snapshot_obj_type) && 89: kgsl_addr_range_overlap(ib_obj->gpuaddr, ib_obj->size, 90: gpuaddr, size)) 91: /* regions overlap */ 92: return ib_obj; 93: } 94: return NULL; 95: } 96: 97: /* 98: * adreno_ib_add() - Add a gpuaddress range to list 99: * @process: Process in which the gpuaddress is mapped 100: * @type: The type of address range 101: * @ib_obj_list: List of the address ranges in which the given range is to be 102: * added 103: * 104: * Add a gpuaddress range as an ib object to a given list after checking if it 105: * overlaps with another entry on the list. If it conflicts then change the 106: * existing entry to incorporate this range 107: * 108: * Returns 0 on success else error code 109: */ 110: static int adreno_ib_add(struct kgsl_process_private *process, 111: uint64_t gpuaddr, int type, 112: struct adreno_ib_object_list *ib_obj_list) MATCH LINES: 173, 189, 201, 212 161: { 162: int ret = 0; 163: int i; 164: int vfd_end; 165: unsigned int mask; 166: /* First up the visiblity stream buffer */ 167: mask = 0xFFFFFFFF; 168: for (i = ADRENO_CP_ADDR_VSC_PIPE_DATA_ADDRESS_0; 169: i < ADRENO_CP_ADDR_VSC_PIPE_DATA_LENGTH_7; i++) { 170: if (ib_parse_vars->cp_addr_regs[i]) { 171: ret = adreno_ib_add(process, 172: ib_parse_vars->cp_addr_regs[i] & mask, 173: SNAPSHOT_GPU_OBJECT_GENERIC, 174: ib_obj_list); 175: if (ret) 176: return ret; 177: ib_parse_vars->cp_addr_regs[i] = 0; 178: ib_parse_vars->cp_addr_regs[i + 1] = 0; 179: i++; 180: } 181: } 182: 183: vfd_end = ADRENO_CP_ADDR_VFD_FETCH_INSTR_1_15; 184: for (i = ADRENO_CP_ADDR_VFD_FETCH_INSTR_1_0; 185: i <= vfd_end; i++) { 186: if (ib_parse_vars->cp_addr_regs[i]) { 187: ret = adreno_ib_add(process, 188: ib_parse_vars->cp_addr_regs[i], 189: SNAPSHOT_GPU_OBJECT_GENERIC, 190: ib_obj_list); 191: if (ret) 192: return ret; 193: ib_parse_vars->cp_addr_regs[i] = 0; 194: } 195: } 196: 197: if (ib_parse_vars->cp_addr_regs[ADRENO_CP_ADDR_VSC_SIZE_ADDRESS]) { 198: ret = adreno_ib_add(process, 199: ib_parse_vars->cp_addr_regs[ 200: ADRENO_CP_ADDR_VSC_SIZE_ADDRESS] & mask, 201: SNAPSHOT_GPU_OBJECT_GENERIC, ib_obj_list); 202: if (ret) 203: return ret; 204: ib_parse_vars->cp_addr_regs[ 205: ADRENO_CP_ADDR_VSC_SIZE_ADDRESS] = 0; 206: } 207: mask = 0xFFFFFFE0; 208: for (i = ADRENO_CP_ADDR_SP_VS_PVT_MEM_ADDR; 209: i <= ADRENO_CP_ADDR_SP_FS_OBJ_START_REG; i++) { 210: ret = adreno_ib_add(process, 211: ib_parse_vars->cp_addr_regs[i] & mask, 212: SNAPSHOT_GPU_OBJECT_GENERIC, ib_obj_list); 213: if (ret) 214: return ret; 215: ib_parse_vars->cp_addr_regs[i] = 0; 216: } 217: return ret; 218: } 219: 220: /* 221: * Parse all the type7 opcode packets that may contain important information, 222: * such as additional GPU buffers to grab or a draw initator 223: */ 224: 225: static int ib_parse_type7(struct kgsl_device *device, unsigned int *ptr, 226: int pktsize, 227: struct kgsl_process_private *process, 228: struct adreno_ib_object_list *ib_obj_list, 229: struct ib_parser_variables *ib_parse_vars) 230: { 231: int opcode = cp_type7_opcode(*ptr); 232: 233: switch (opcode) { 234: case CP_SET_DRAW_STATE: 235: return ib_parse_type7_set_draw_state(device, ptr, pktsize, 236: process, ib_obj_list); MATCH LINES: 281, 294 269: /* 270: * dirty flag or no flags both mean we need to load it for 271: * next draw. No flags is used when the group is activated 272: * or initialized for the first time in the IB 273: */ 274: if (flags & 0x1 || !flags) { 275: cmd_stream_dwords = ptr[i] & 0x0000FFFF; 276: cmd_stream_addr = ptr[i + 2]; 277: cmd_stream_addr = cmd_stream_addr << 32 | ptr[i + 1]; 278: if (cmd_stream_dwords) 279: ret = adreno_ib_find_objs(device, process, 280: cmd_stream_addr, cmd_stream_dwords, 281: 0, SNAPSHOT_GPU_OBJECT_DRAW, 282: ib_obj_list, IB_LEVEL_2); 283: if (ret) 284: break; 285: continue; 286: } 287: /* load immediate */ 288: if (flags & 0x8) { 289: uint64_t gpuaddr = ptr[i + 2]; 290: 291: gpuaddr = gpuaddr << 32 | ptr[i + 1]; 292: ret = adreno_ib_find_objs(device, process, 293: gpuaddr, (ptr[i] & 0x0000FFFF), 294: 0, SNAPSHOT_GPU_OBJECT_IB, 295: ib_obj_list, IB_LEVEL_2); 296: if (ret) 297: break; 298: } 299: } 300: return ret; 301: } 302: 303: /* 304: * adreno_cp_parse_ibn() - Wrapper function around IBn parsing 305: * @device: Device pointer 306: * @process: Process in which the IB is allocated 307: * @gpuaddr: IB gpuaddr 308: * @dwords: IB size in dwords 309: * @ibbase: Base address of active IB 310: * @ib_obj_list: List of objects found in IB 311: * @ib_level: The level from which function is called from IBn-1 312: * 313: * Function does some checks to ensure that IBn parsing is called from IBn-1 314: * and then calls the function to find objects in IBn. 315: */ 316: static int adreno_cp_parse_ibn(struct kgsl_device *device, 317: struct kgsl_process_private *process, 318: u64 gpuaddr, u64 dwords, u64 ibbase, MATCH LINES: 333, 341, 349 321: { 322: int i; 323: 324: /* 325: * We can only expect an IBn in IBn-1, if we are 326: * already processing an IBn then return error 327: */ 328: if (ib_level >= IB_LEVEL_3) 329: return -EINVAL; 330: 331: /* Save current IBn statically */ 332: if (ibbase == gpuaddr) 333: kgsl_snapshot_push_object(device, process, gpuaddr, dwords); 334: /* 335: * Only try to find sub objects if this IBn has 336: * not been processed already 337: */ 338: for (i = 0; i < ib_obj_list->num_objs; i++) { 339: struct adreno_ib_object *ib_obj = &(ib_obj_list->obj_list[i]); 340: 341: if ((ib_obj->snapshot_obj_type == SNAPSHOT_GPU_OBJECT_IB) && 342: (gpuaddr >= ib_obj->gpuaddr) && 343: (gpuaddr + dwords * sizeof(unsigned int) <= 344: ib_obj->gpuaddr + ib_obj->size)) 345: return 0; 346: } 347: 348: return adreno_ib_find_objs(device, process, gpuaddr, dwords, ibbase, 349: SNAPSHOT_GPU_OBJECT_IB, ib_obj_list, ib_level + 1); 350: } 351: 352: static s64 get_ib_base(struct adreno_device *adreno_dev, int ib_level) 353: { 354: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 355: s64 ibbase = 0; 356: 357: switch (ib_level) { 358: case IB_LEVEL_2: 359: ibbase = metadata.ib2base; 360: break; 361: case IB_LEVEL_3: 362: if (!adreno_is_a5xx(adreno_dev) && !adreno_is_a6xx(adreno_dev)) 363: ibbase = metadata.ib3base; 364: break; 365: default: 366: /* Invalid IB level */ 367: dev_err(device->dev, "Invalid IB level %d\n", ib_level); 368: return -EINVAL; 369: } 370: 371: return ibbase; 372: } 373: MATCH LINES: 408 396: int ret = 0; 397: uint64_t rem = dwords; 398: int i; 399: struct ib_parser_variables ib_parse_vars; 400: unsigned int *src; 401: struct adreno_ib_object *ib_obj; 402: struct kgsl_mem_entry *entry; 403: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 404: 405: /* check that this IB is not already on list */ 406: for (i = 0; i < ib_obj_list->num_objs; i++) { 407: ib_obj = &(ib_obj_list->obj_list[i]); 408: if ((obj_type == ib_obj->snapshot_obj_type) && 409: (ib_obj->gpuaddr <= gpuaddr) && 410: ((ib_obj->gpuaddr + ib_obj->size) >= 411: (gpuaddr + (dwords << 2)))) 412: return 0; 413: } 414: 415: entry = kgsl_sharedmem_find(process, gpuaddr); 416: if (!entry) 417: return -EINVAL; 418: 419: if (!kgsl_gpuaddr_in_memdesc(&entry->memdesc, gpuaddr, (dwords << 2))) { 420: kgsl_mem_entry_put(entry); 421: return -EINVAL; 422: } 423: 424: src = kgsl_gpuaddr_to_vaddr(&entry->memdesc, gpuaddr); 425: if (!src) { 426: kgsl_mem_entry_put(entry); 427: return -EINVAL; 428: } 429: 430: memset(&ib_parse_vars, 0, sizeof(struct ib_parser_variables)); 431: 432: ret = adreno_ib_add(process, gpuaddr, obj_type, ib_obj_list); MATCH LINES: 487 475: } 476: 477: i += pktsize; 478: rem -= pktsize; 479: } 480: 481: done: 482: /* 483: * For set draw objects there may not be a draw_indx packet at its end 484: * to signal that we need to save the found objects in it, so just save 485: * it here. 486: */ 487: if (!ret && SNAPSHOT_GPU_OBJECT_DRAW == obj_type) 488: ret = ib_add_type0_entries(device, process, ib_obj_list, 489: &ib_parse_vars); 490: 491: kgsl_memdesc_unmap(&entry->memdesc); 492: kgsl_mem_entry_put(entry); 493: return ret; 494: } 495: 496: 497: /* 498: * adreno_ib_create_object_list() - Find all the memory objects in IB 499: * @device: The device pointer on which the IB executes 500: * @process: The process in which the IB and all contained objects are mapped 501: * @gpuaddr: The gpu address of the IB 502: * @dwords: Size of ib in dwords 503: * @ib2base: Base address of active IB2 504: * @ib_obj_list: The list in which the IB and the objects in it are added. 505: * 506: * Find all the memory objects that an IB needs for execution and place 507: * them in a list including the IB. 508: * Returns the ib object list. On success 0 is returned, on failure error 509: * code is returned along with number of objects that was saved before 510: * error occurred. If no objects found then the list pointer is set to 511: * NULL. MATCH LINES: 539 527: if (!ib_obj_list) 528: return -ENOMEM; 529: 530: ib_obj_list->obj_list = vmalloc(MAX_IB_OBJS * 531: sizeof(struct adreno_ib_object)); 532: 533: if (!ib_obj_list->obj_list) { 534: kfree(ib_obj_list); 535: return -ENOMEM; 536: } 537: 538: ret = adreno_ib_find_objs(device, process, gpuaddr, dwords, ib2base, 539: SNAPSHOT_GPU_OBJECT_IB, ib_obj_list, IB_LEVEL_1); 540: 541: /* Even if there was an error return the remaining objects found */ 542: if (ib_obj_list->num_objs) 543: *out_ib_obj_list = ib_obj_list; 544: 545: return ret; 546: } 547: 548: /* 549: * adreno_ib_destroy_obj_list() - Destroy an ib object list 550: * @ib_obj_list: List to destroy 551: * 552: * Free up all resources used by an ib_obj_list 553: */ 554: void adreno_ib_destroy_obj_list(struct adreno_ib_object_list *ib_obj_list) 555: { 556: int i; 557: 558: if (!ib_obj_list) 559: return; 560: 561: for (i = 0; i < ib_obj_list->num_objs; i++) { 562: if (ib_obj_list->obj_list[i].entry) 563: kgsl_mem_entry_put(ib_obj_list->obj_list[i].entry); --- FILE: \adreno_cp_parser.h | HITS: 4 --- MATCH LINES: 17, 23 5: */ 6: 7: #ifndef __ADRENO_IB_PARSER__ 8: #define __ADRENO_IB_PARSER__ 9: 10: #include "adreno.h" 11: 12: /* 13: * struct adreno_ib_object - Structure containing information about an 14: * address range found in an IB 15: * @gpuaddr: The starting gpuaddress of the range 16: * @size: Size of the range 17: * @snapshot_obj_type - Type of range used in snapshot 18: * @entry: The memory entry in which this range is found 19: */ 20: struct adreno_ib_object { 21: uint64_t gpuaddr; 22: uint64_t size; 23: int snapshot_obj_type; 24: struct kgsl_mem_entry *entry; 25: }; 26: 27: /* 28: * struct adreno_ib_object_list - List of address ranges found in IB 29: * @obj_list: The address range list 30: * @num_objs: Number of objects in list 31: */ 32: struct adreno_ib_object_list { 33: struct adreno_ib_object *obj_list; 34: int num_objs; 35: }; 36: 37: /* 38: * adreno registers used during IB parsing, there contain addresses 39: * and sizes of the addresses that present in an IB 40: */ 41: enum adreno_cp_addr_regs { 42: ADRENO_CP_ADDR_VSC_PIPE_DATA_ADDRESS_0 = 0, 43: ADRENO_CP_ADDR_VSC_PIPE_DATA_LENGTH_0, 44: ADRENO_CP_ADDR_VSC_PIPE_DATA_ADDRESS_1, 45: ADRENO_CP_ADDR_VSC_PIPE_DATA_LENGTH_1, 46: ADRENO_CP_ADDR_VSC_PIPE_DATA_ADDRESS_2, 47: ADRENO_CP_ADDR_VSC_PIPE_DATA_LENGTH_2, MATCH LINES: 103, 114 91: ADRENO_CP_ADDR_SP_VS_PVT_MEM_ADDR, 92: ADRENO_CP_ADDR_SP_FS_PVT_MEM_ADDR, 93: ADRENO_CP_ADDR_SP_VS_OBJ_START_REG, 94: ADRENO_CP_ADDR_SP_FS_OBJ_START_REG, 95: ADRENO_CP_ADDR_MAX, 96: }; 97: 98: /* 99: * adreno_ib_init_ib_obj() - Create an ib object structure and initialize it 100: * with gpuaddress and size 101: * @gpuaddr: gpuaddr with which to initialize the object with 102: * @size: Size in bytes with which the object is initialized 103: * @ib_type: The IB type used by snapshot 104: * 105: * Returns the object pointer on success else error code in the pointer 106: */ 107: static inline void adreno_ib_init_ib_obj(uint64_t gpuaddr, 108: uint64_t size, int obj_type, 109: struct kgsl_mem_entry *entry, 110: struct adreno_ib_object *ib_obj) 111: { 112: ib_obj->gpuaddr = gpuaddr; 113: ib_obj->size = size; 114: ib_obj->snapshot_obj_type = obj_type; 115: ib_obj->entry = entry; 116: } 117: 118: int adreno_ib_create_object_list( 119: struct kgsl_device *device, 120: struct kgsl_process_private *process, 121: uint64_t gpuaddr, uint64_t dwords, uint64_t ib2base, 122: struct adreno_ib_object_list **out_ib_obj_list); 123: 124: void adreno_ib_destroy_obj_list(struct adreno_ib_object_list *ib_obj_list); 125: 126: #endif --- FILE: \adreno_debugfs.c | HITS: 33 --- MATCH LINES: 50, 59 38: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 39: 40: *val = (u64) test_bit(ADRENO_DEVICE_ISDB_ENABLED, &adreno_dev->priv); 41: return 0; 42: } 43: 44: DEFINE_DEBUGFS_ATTRIBUTE(_isdb_fops, _isdb_get, _isdb_set, "%llu\n"); 45: 46: static int _ctxt_record_size_set(void *data, u64 val) 47: { 48: struct kgsl_device *device = data; 49: 50: device->snapshot_ctxt_record_size = val; 51: 52: return 0; 53: } 54: 55: static int _ctxt_record_size_get(void *data, u64 *val) 56: { 57: struct kgsl_device *device = data; 58: 59: *val = device->snapshot_ctxt_record_size; 60: return 0; 61: } 62: 63: DEFINE_DEBUGFS_ATTRIBUTE(_ctxt_record_size_fops, _ctxt_record_size_get, 64: _ctxt_record_size_set, "%llu\n"); 65: 66: static int _lm_limit_set(void *data, u64 val) 67: { 68: struct kgsl_device *device = data; 69: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 70: 71: if (!ADRENO_FEATURE(adreno_dev, ADRENO_LM)) 72: return 0; 73: 74: /* assure value is between 3A and 10A */ 75: if (val > 10000) 76: val = 10000; 77: else if (val < 3000) 78: val = 3000; 79: 80: if (adreno_dev->lm_enabled) 81: return adreno_power_cycle_u32(adreno_dev, 82: &adreno_dev->lm_limit, val); 83: MATCH LINES: 128, 133, 134, 138, 143, 146, 147, 179, 180, 185, 190, 191, 194, 196, 201, 202, 205, 207, 220, 224 116: 117: static int _active_count_get(void *data, u64 *val) 118: { 119: struct kgsl_device *device = data; 120: unsigned int i = atomic_read(&device->active_cnt); 121: 122: *val = (u64) i; 123: return 0; 124: } 125: 126: DEFINE_DEBUGFS_ATTRIBUTE(_active_count_fops, _active_count_get, NULL, "%llu\n"); 127: 128: static int _coop_reset_set(void *data, u64 val) 129: { 130: struct kgsl_device *device = data; 131: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 132: 133: if (ADRENO_FEATURE(adreno_dev, ADRENO_COOP_RESET)) 134: adreno_dev->cooperative_reset = val ? true : false; 135: return 0; 136: } 137: 138: static int _coop_reset_get(void *data, u64 *val) 139: { 140: struct kgsl_device *device = data; 141: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 142: 143: *val = (u64) adreno_dev->cooperative_reset; 144: return 0; 145: } 146: DEFINE_DEBUGFS_ATTRIBUTE(_coop_reset_fops, _coop_reset_get, 147: _coop_reset_set, "%llu\n"); 148: 149: static void set_gpu_client_pf(struct adreno_device *adreno_dev, void *priv) 150: { 151: adreno_dev->uche_client_pf = *((u32 *)priv); 152: adreno_dev->patch_reglist = false; 153: } 154: 155: static int _gpu_client_pf_set(void *data, u64 val) 156: { 157: struct kgsl_device *device = data; 158: 159: return adreno_power_cycle(ADRENO_DEVICE(device), set_gpu_client_pf, &val); 160: } 161: 162: static int _gpu_client_pf_get(void *data, u64 *val) 163: { 164: struct kgsl_device *device = data; 165: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 166: 167: *val = (u64) adreno_dev->uche_client_pf; 168: return 0; 169: } 170: DEFINE_DEBUGFS_ATTRIBUTE(_gpu_client_pf_fops, _gpu_client_pf_get, 171: _gpu_client_pf_set, "%llu\n"); 172: 173: static int _prealloc_atomic_snap_mem_set(void *data, u64 val) 174: { 175: struct kgsl_device *device = data; 176: 177: kgsl_mutex_lock(&device->mutex); 178: 179: /* Allocate atomic snapshot memory if it's not allocated yet */ 180: if (!val || device->snapshot_memory_atomic.ptr) { 181: kgsl_mutex_unlock(&device->mutex); 182: return 0; 183: } 184: 185: device->snapshot_memory_atomic.size = device->snapshot_memory.size; 186: 187: /* Ensure size is visible to other threads before setting address */ 188: smp_wmb(); 189: 190: device->snapshot_memory_atomic.ptr = dma_alloc_coherent(&device->pdev->dev, 191: device->snapshot_memory_atomic.size, &device->snapshot_memory_atomic.dma_handle, 192: GFP_KERNEL); 193: 194: if (WARN_ON((!device->snapshot_memory_atomic.ptr))) { 195: /* Fallback to slab allocator if DMA allocation fails */ 196: device->snapshot_memory_atomic.size = (SZ_2M + SZ_1M); 197: 198: /* Ensure size is visible to other threads before setting address */ 199: smp_wmb(); 200: 201: device->snapshot_memory_atomic.ptr = devm_kzalloc(&device->pdev->dev, 202: device->snapshot_memory_atomic.size, GFP_KERNEL); 203: } 204: 205: if (!device->snapshot_memory_atomic.ptr) { 206: kgsl_mutex_unlock(&device->mutex); 207: dev_err(device->dev, "Failed to allocate memory for atomic snapshot\n"); 208: return -ENOMEM; 209: } 210: 211: kgsl_mutex_unlock(&device->mutex); 212: 213: return 0; 214: } 215: 216: static int _prealloc_atomic_snap_mem_get(void *data, u64 *val) 217: { 218: struct kgsl_device *device = data; 219: 220: *val = device->snapshot_memory_atomic.ptr ? 1 : 0; 221: return 0; 222: } 223: 224: DEFINE_DEBUGFS_ATTRIBUTE(_prealloc_atomic_snapshot_mem_fops, _prealloc_atomic_snap_mem_get, 225: _prealloc_atomic_snap_mem_set, "%llu\n"); 226: 227: typedef void (*reg_read_init_t)(struct kgsl_device *device); 228: typedef void (*reg_read_fill_t)(struct kgsl_device *device, int i, 229: unsigned int *vals, int linec); 230: 231: 232: static void sync_event_print(struct seq_file *s, 233: struct kgsl_drawobj_sync_event *sync_event) 234: { 235: switch (sync_event->type) { 236: case KGSL_CMD_SYNCPOINT_TYPE_TIMESTAMP: { 237: seq_printf(s, "sync: ctx: %u ts: %u", 238: sync_event->context->id, sync_event->timestamp); 239: break; 240: } 241: case KGSL_CMD_SYNCPOINT_TYPE_FENCE: { 242: int i; 243: struct event_fence_info *info = sync_event->priv; 244: 245: for (i = 0; info && i < info->num_fences; i++) 246: seq_printf(s, "sync: %s", 247: info->fences[i].name); 248: break; MATCH LINES: 377 365: drawctxt->base.proc_priv->comm, 366: pid_nr(drawctxt->base.proc_priv->pid), 367: drawctxt->base.tid); 368: 369: seq_puts(s, "flags: "); 370: print_flags(s, drawctxt->base.flags & ~(KGSL_CONTEXT_PRIORITY_MASK 371: | KGSL_CONTEXT_TYPE_MASK), KGSL_CONTEXT_FLAGS); 372: seq_puts(s, " priv: "); 373: print_flags(s, drawctxt->base.priv, 374: { BIT(KGSL_CONTEXT_PRIV_SUBMITTED), "submitted"}, 375: { BIT(KGSL_CONTEXT_PRIV_DETACHED), "detached"}, 376: { BIT(KGSL_CONTEXT_PRIV_INVALID), "invalid"}, 377: { BIT(KGSL_CONTEXT_PRIV_PAGEFAULT), "pagefault"}, 378: { BIT(ADRENO_CONTEXT_FAULT), "fault"}, 379: { BIT(ADRENO_CONTEXT_GPU_HANG), "gpu_hang"}, 380: { BIT(ADRENO_CONTEXT_GPU_HANG_FT), "gpu_hang_ft"}, 381: { BIT(ADRENO_CONTEXT_SKIP_EOF), "skip_end_of_frame" }, 382: { BIT(ADRENO_CONTEXT_FORCE_PREAMBLE), "force_preamble"}); 383: seq_puts(s, "\n"); 384: 385: seq_puts(s, "timestamps: "); 386: kgsl_readtimestamp(drawctxt->base.device, &drawctxt->base, 387: KGSL_TIMESTAMP_QUEUED, &queued); 388: kgsl_readtimestamp(drawctxt->base.device, &drawctxt->base, 389: KGSL_TIMESTAMP_CONSUMED, &consumed); 390: kgsl_readtimestamp(drawctxt->base.device, &drawctxt->base, 391: KGSL_TIMESTAMP_RETIRED, &retired); 392: seq_printf(s, "queued: %u consumed: %u retired: %u global:%u\n", 393: queued, consumed, retired, 394: drawctxt->internal_timestamp); 395: 396: seq_puts(s, "drawqueue:\n"); 397: 398: spin_lock(&drawctxt->lock); 399: for (i = drawctxt->drawqueue_head; 400: i != drawctxt->drawqueue_tail; 401: i = DRAWQUEUE_NEXT(i, ADRENO_CONTEXT_DRAWQUEUE_SIZE)) MATCH LINES: 803, 812, 814, 815, 816, 844, 846, 848, 850, 851 791: return 0; 792: 793: host_based_dcvs = (bool)val; 794: return adreno_power_cycle(adreno_dev, _toggle_host_based_dcvs, &host_based_dcvs); 795: } 796: 797: DEFINE_DEBUGFS_ATTRIBUTE(host_based_dcvs_fops, _host_based_dcvs_show, 798: _host_based_dcvs_store, "%llu\n"); 799: 800: void adreno_debugfs_init(struct adreno_device *adreno_dev) 801: { 802: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 803: struct dentry *snapshot_dir; 804: 805: if (IS_ERR_OR_NULL(device->d_debugfs)) 806: return; 807: 808: debugfs_create_file("active_cnt", 0444, device->d_debugfs, device, 809: &_active_count_fops); 810: adreno_dev->ctx_d_debugfs = debugfs_create_dir("ctx", 811: device->d_debugfs); 812: snapshot_dir = debugfs_lookup("snapshot", kgsl_debugfs_dir); 813: 814: if (!IS_ERR_OR_NULL(snapshot_dir)) 815: debugfs_create_file("coop_reset", 0644, snapshot_dir, device, 816: &_coop_reset_fops); 817: 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); 856: debugfs_create_file("sid1", 0644, adreno_dev->bcl_debugfs_dir, device, &_sid1_fops); 857: debugfs_create_file("sid2", 0644, adreno_dev->bcl_debugfs_dir, device, &_sid2_fops); 858: debugfs_create_file("bcl_throttle_time_us", 0444, adreno_dev->bcl_debugfs_dir, 859: device, &_bcl_throttle_fops); 860: } 861: 862: adreno_dev->preemption_debugfs_dir = debugfs_create_dir("preemption", device->d_debugfs); 863: if (!IS_ERR_OR_NULL(adreno_dev->preemption_debugfs_dir)) { 864: debugfs_create_file("preempt_level", 0644, adreno_dev->preemption_debugfs_dir, 865: device, &preempt_level_fops); 866: debugfs_create_file("usesgmem", 0644, adreno_dev->preemption_debugfs_dir, device, 867: &usesgmem_fops); 868: debugfs_create_file("skipsaverestore", 0644, adreno_dev->preemption_debugfs_dir, 869: device, &skipsaverestore_fops); 870: } 871: 872: if (ADRENO_FEATURE(adreno_dev, ADRENO_GMU_BASED_DCVS)) 873: debugfs_create_file("host_based_dcvs", 0644, device->d_debugfs, 874: device, &host_based_dcvs_fops); 875: } --- FILE: \adreno_dispatch.c | HITS: 78 --- MATCH LINES: 30, 31 18: #define DRAWQUEUE_NEXT(_i, _s) (((_i) + 1) % (_s)) 19: 20: /* Number of commands that can be queued in a context before it sleeps */ 21: static unsigned int _context_drawqueue_size = 50; 22: 23: /* Number of milliseconds to wait for the context queue to clear */ 24: static unsigned int _context_queue_wait = 10000; 25: 26: /* Number of drawobjs sent at a time from a single context */ 27: static unsigned int _context_drawobj_burst = 5; 28: 29: /* 30: * GFT throttle parameters. If GFT recovered more than 31: * X times in Y ms invalidate the context and do not attempt recovery. 32: * X -> _fault_throttle_burst 33: * Y -> _fault_throttle_time 34: */ 35: static unsigned int _fault_throttle_time = 3000; 36: static unsigned int _fault_throttle_burst = 3; 37: 38: /* 39: * Maximum ringbuffer inflight for the single submitting context case - this 40: * should be sufficiently high to keep the GPU loaded 41: */ 42: static unsigned int _dispatcher_q_inflight_hi = 15; 43: 44: /* 45: * Minimum inflight for the multiple context case - this should sufficiently low 46: * to allow for lower latency context switching 47: */ 48: static unsigned int _dispatcher_q_inflight_lo = 4; 49: 50: /* Command batch timeout (in milliseconds) */ 51: unsigned int adreno_drawobj_timeout = 2000; 52: 53: /* Interval for reading and comparing fault detection registers */ 54: static unsigned int _fault_timer_interval = 200; 55: MATCH LINES: 373 361: (drawctxt->drawqueue_head - 1); 362: 363: /* 364: * The maximum queue size always needs to be one less then the size of 365: * the ringbuffer queue so there is "room" to put the drawobj back in 366: */ 367: 368: WARN_ON(prev == drawctxt->drawqueue_tail); 369: 370: drawctxt->drawqueue[prev] = drawobj; 371: drawctxt->queued++; 372: 373: /* Reset the command queue head to reflect the newly requeued change */ 374: drawctxt->drawqueue_head = prev; 375: cmdobj->requeue_cnt++; 376: spin_unlock(&drawctxt->lock); 377: return 0; 378: } 379: 380: /** 381: * dispatcher_queue_context() - Queue a context in the dispatcher pending list 382: * @dispatcher: Pointer to the adreno dispatcher struct 383: * @drawctxt: Pointer to the adreno draw context 384: * 385: * Add a context to the dispatcher pending list. 386: */ 387: static int dispatcher_queue_context(struct adreno_device *adreno_dev, 388: struct adreno_context *drawctxt) 389: { 390: struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher; 391: struct adreno_dispatch_job *job; 392: 393: /* Refuse to queue a detached context */ 394: if (kgsl_context_detached(&drawctxt->base)) 395: return 0; 396: 397: if (!_kgsl_context_get(&drawctxt->base)) MATCH LINES: 641 629: return -EBUSY; 630: } 631: 632: /* 633: * Each context can send a specific number of drawobjs per cycle 634: */ 635: while ((count < _context_drawobj_burst) && 636: (dispatch_q->inflight < inflight)) { 637: struct kgsl_drawobj *drawobj; 638: struct kgsl_drawobj_cmd *cmdobj; 639: struct kgsl_context *context; 640: 641: if (adreno_gpu_fault(adreno_dev) != 0) 642: break; 643: 644: spin_lock(&drawctxt->lock); 645: drawobj = _process_drawqueue_get_next_drawobj(drawctxt); 646: 647: /* 648: * adreno_context_get_drawobj returns -EAGAIN if the current 649: * drawobj has pending sync points so no more to do here. 650: * When the sync points are satisfied then the context will get 651: * reqeueued 652: */ 653: 654: if (IS_ERR_OR_NULL(drawobj)) { 655: if (IS_ERR(drawobj)) 656: ret = PTR_ERR(drawobj); 657: spin_unlock(&drawctxt->lock); 658: break; 659: } 660: _pop_drawobj(drawctxt); 661: spin_unlock(&drawctxt->lock); 662: 663: timestamp = drawobj->timestamp; 664: cmdobj = CMDOBJ(drawobj); 665: context = drawobj->context; MATCH LINES: 715 703: if (_check_context_queue(drawctxt, 0)) 704: wake_up_all(&drawctxt->wq); 705: 706: if (!ret) 707: ret = count; 708: 709: /* Return error or the number of commands queued */ 710: return ret; 711: } 712: 713: static bool adreno_gpu_stopped(struct adreno_device *adreno_dev) 714: { 715: return (adreno_gpu_fault(adreno_dev) || adreno_gpu_halt(adreno_dev)); 716: } 717: 718: static void dispatcher_handle_jobs_list(struct adreno_device *adreno_dev, 719: int id, unsigned long *map, struct llist_node *list) 720: { 721: struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher; 722: struct adreno_dispatch_job *job, *next; 723: 724: if (!list) 725: return; 726: 727: /* Reverse the order so the oldest context is considered first */ 728: list = llist_reverse_order(list); 729: 730: llist_for_each_entry_safe(job, next, list, node) { 731: int ret; 732: 733: if (kgsl_context_is_bad(&job->drawctxt->base)) { 734: kgsl_context_put(&job->drawctxt->base); 735: kmem_cache_free(jobs_cache, job); 736: continue; 737: } 738: 739: /* MATCH LINES: 755 743: * consumer side we only want each context to be considered 744: * once. Use a bitmap to remember which contexts we've already 745: * seen and quietly discard duplicate jobs 746: */ 747: if (test_and_set_bit(job->drawctxt->base.id, map)) { 748: kgsl_context_put(&job->drawctxt->base); 749: kmem_cache_free(jobs_cache, job); 750: continue; 751: } 752: 753: /* 754: * If gpu is in fault or dispatcher is halted, add back the jobs 755: * so that they are processed after recovery or when dispatcher 756: * is resumed. 757: */ 758: if (adreno_gpu_stopped(adreno_dev)) { 759: llist_add(&job->node, &dispatcher->jobs[id]); 760: continue; 761: } 762: 763: ret = dispatcher_context_sendcmds(adreno_dev, job->drawctxt); 764: 765: /* 766: * If the context had nothing queued or the context has been 767: * destroyed then drop the job 768: */ 769: if (!ret || ret == -ENOENT) { 770: kgsl_context_put(&job->drawctxt->base); 771: kmem_cache_free(jobs_cache, job); 772: continue; 773: } 774: 775: /* 776: * If the ringbuffer is full then requeue the job to be 777: * considered first next time. Otherwise the context 778: * either successfully submmitted to the GPU or another error 779: * happened and it should go back on the regular queue MATCH LINES: 816 804: * _adreno_dispatcher_issuecmds() - Issue commmands from pending contexts 805: * @adreno_dev: Pointer to the adreno device struct 806: * 807: * Issue as many commands as possible (up to inflight) from the pending contexts 808: * This function assumes the dispatcher mutex has been locked. 809: */ 810: static void _adreno_dispatcher_issuecmds(struct adreno_device *adreno_dev) 811: { 812: struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher; 813: int i; 814: 815: /* Leave early if the dispatcher isn't in a happy state */ 816: if (adreno_gpu_fault(adreno_dev) != 0) 817: return; 818: 819: for (i = 0; i < ARRAY_SIZE(dispatcher->jobs); i++) 820: dispatcher_handle_jobs(adreno_dev, i); 821: } 822: 823: /* Update the dispatcher timers */ 824: static void _dispatcher_update_timers(struct adreno_device *adreno_dev) 825: { 826: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 827: struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher; 828: 829: /* Kick the idle timer */ 830: kgsl_mutex_lock(&device->mutex); 831: kgsl_pwrscale_update(device); 832: process_rt_bus_hint(device, false); 833: kgsl_start_idle_timer(device); 834: kgsl_mutex_unlock(&device->mutex); 835: 836: /* Check to see if we need to update the command timer */ 837: if (adreno_in_preempt_state(adreno_dev, ADRENO_PREEMPT_NONE)) { 838: struct adreno_dispatcher_drawqueue *drawqueue = 839: DRAWQUEUE(adreno_dev->cur_rb); 840: MATCH LINES: 949 937: */ 938: else if (drawctxt->base.flags & KGSL_CONTEXT_INVALIDATE_ON_FAULT) 939: set_bit(KGSL_FT_REPLAY, &cmdobj->fault_policy); 940: else 941: cmdobj->fault_policy = adreno_dev->ft_policy; 942: } 943: 944: static void _cmdobj_set_flags(struct adreno_context *drawctxt, 945: struct kgsl_drawobj_cmd *cmdobj) 946: { 947: /* 948: * Force the preamble for this submission only - this is usually 949: * requested by the dispatcher as part of fault recovery 950: */ 951: if (test_and_clear_bit(ADRENO_CONTEXT_FORCE_PREAMBLE, 952: &drawctxt->base.priv)) 953: set_bit(CMDOBJ_FORCE_PREAMBLE, &cmdobj->priv); 954: 955: /* 956: * Force the premable if set from userspace in the context or 957: * command obj flags 958: */ 959: if ((drawctxt->base.flags & KGSL_CONTEXT_CTX_SWITCH) || 960: (cmdobj->base.flags & KGSL_DRAWOBJ_CTX_SWITCH)) 961: set_bit(CMDOBJ_FORCE_PREAMBLE, &cmdobj->priv); 962: 963: /* Skip this ib if IFH_NOP is enabled */ 964: if (drawctxt->base.flags & KGSL_CONTEXT_IFH_NOP) 965: set_bit(CMDOBJ_SKIP, &cmdobj->priv); 966: 967: /* 968: * If we are waiting for the end of frame and it hasn't appeared yet, 969: * then mark the command obj as skipped. It will still progress 970: * through the pipeline but it won't actually send any commands 971: */ 972: 973: if (test_bit(ADRENO_CONTEXT_SKIP_EOF, &drawctxt->base.priv)) { MATCH LINES: 1363, 1381 1351: * we mark GFT as a success. 1352: * 1353: * Find next commandbatch for the faulting context 1354: * If commandbatch is found 1355: * a) store the current commandbatch fault_policy in context's next 1356: * commandbatch fault_policy 1357: * b) force preamble for next commandbatch 1358: */ 1359: for (i = 1; i < count; i++) { 1360: if (DRAWOBJ(replay[i])->context->id == drawobj->context->id) { 1361: replay[i]->fault_policy = replay[0]->fault_policy; 1362: set_bit(CMDOBJ_FORCE_PREAMBLE, &replay[i]->priv); 1363: set_bit(KGSL_FT_SKIPCMD, &replay[i]->fault_recovery); 1364: break; 1365: } 1366: } 1367: 1368: /* 1369: * If we did not find the next cmd then 1370: * a) set a flag for next command issued in this context 1371: * b) store the fault_policy, this fault_policy becomes the policy of 1372: * next command issued in this context 1373: */ 1374: if ((i == count) && drawctxt) { 1375: set_bit(ADRENO_CONTEXT_SKIP_CMD, &drawctxt->base.priv); 1376: drawctxt->fault_policy = replay[0]->fault_policy; 1377: } 1378: 1379: /* set the flags to skip this cmdobj */ 1380: set_bit(CMDOBJ_SKIP, &cmdobj->priv); 1381: cmdobj->fault_recovery = 0; 1382: } 1383: 1384: static void _skip_frame(struct kgsl_drawobj_cmd *cmdobj, 1385: struct kgsl_drawobj_cmd **replay, int count) 1386: { 1387: struct kgsl_drawobj *drawobj = DRAWOBJ(cmdobj); 1388: struct adreno_context *drawctxt = ADRENO_CONTEXT(drawobj->context); 1389: int skip = 1; 1390: int i; 1391: 1392: for (i = 0; i < count; i++) { 1393: 1394: struct kgsl_drawobj *replay_obj = DRAWOBJ(replay[i]); 1395: 1396: /* 1397: * Only operate on drawobj's that belong to the 1398: * faulting context 1399: */ 1400: 1401: if (replay_obj->context->id != drawobj->context->id) 1402: continue; 1403: 1404: /* 1405: * Skip all the drawobjs in this context until MATCH LINES: 1514 1502: adreno_readreg(adreno_dev, ADRENO_REG_CP_RB_WPTR, &wptr); 1503: adreno_readreg64(adreno_dev, ADRENO_REG_CP_IB1_BASE, 1504: ADRENO_REG_CP_IB1_BASE_HI, &ib1base); 1505: adreno_readreg(adreno_dev, ADRENO_REG_CP_IB1_BUFSZ, &ib1sz); 1506: adreno_readreg64(adreno_dev, ADRENO_REG_CP_IB2_BASE, 1507: ADRENO_REG_CP_IB2_BASE_HI, &ib2base); 1508: adreno_readreg(adreno_dev, ADRENO_REG_CP_IB2_BUFSZ, &ib2sz); 1509: 1510: if (drawobj != NULL) { 1511: drawctxt->base.total_fault_count++; 1512: drawctxt->base.last_faulted_cmd_ts = drawobj->timestamp; 1513: 1514: trace_adreno_gpu_fault(drawobj->context->id, 1515: drawobj->timestamp, 1516: status, rptr, wptr, ib1base, ib1sz, 1517: ib2base, ib2sz, drawctxt->rb->id); 1518: 1519: pr_fault(device, drawobj, 1520: "%s fault ctx %u ctx_type %s ts %u status %8.8X rb %4.4x/%4.4x ib1 %16.16llX/%4.4x ib2 %16.16llX/%4.4x\n", 1521: type, drawobj->context->id, 1522: kgsl_context_type(drawctxt->type), 1523: drawobj->timestamp, status, 1524: rptr, wptr, ib1base, ib1sz, ib2base, ib2sz); 1525: 1526: pr_fault(device, drawobj, "cmdline: %s\n", 1527: drawctxt->base.proc_priv->cmdline); 1528: 1529: if (rb != NULL) 1530: pr_fault(device, drawobj, 1531: "%s fault rb %d rb sw r/w %4.4x/%4.4x\n", 1532: type, rb->id, rptr, rb->wptr); 1533: } else { 1534: dev_err(device->dev, 1535: "RB[%d] : %s fault status %8.8X rb %4.4x/%4.4x ib1 %16.16llX/%4.4x ib2 %16.16llX/%4.4x\n", 1536: id, type, status, rptr, wptr, ib1base, ib1sz, ib2base, 1537: ib2sz); 1538: if (rb != NULL) MATCH LINES: 1579, 1580, 1584 1567: */ 1568: static void process_cmdobj_fault(struct kgsl_device *device, 1569: struct kgsl_drawobj_cmd **replay, int count, 1570: unsigned int base, 1571: int fault) 1572: { 1573: struct kgsl_drawobj_cmd *cmdobj = replay[0]; 1574: struct kgsl_drawobj *drawobj = DRAWOBJ(cmdobj); 1575: int i; 1576: char *state = "failed"; 1577: 1578: /* 1579: * If GFT recovered more than X times in Y ms invalidate the context 1580: * and do not attempt recovery. 1581: * Example: X==3 and Y==3000 ms, GPU hung at 500ms, 1700ms, 25000ms and 1582: * 3000ms for the same context, we will not try FT and invalidate the 1583: * context @3000ms because context triggered GFT more than 3 times in 1584: * last 3 seconds. If a context caused recoverable GPU hangs 1585: * where 1st and 4th gpu hang are more than 3 seconds apart we 1586: * won't disable GFT and invalidate the context. 1587: */ 1588: if (test_bit(KGSL_FT_THROTTLE, &cmdobj->fault_policy)) { 1589: if (ktime_ms_delta(ktime_get(), drawobj->context->fault_time) > 1590: _fault_throttle_time) { 1591: drawobj->context->fault_time = ktime_get(); 1592: drawobj->context->fault_count = 1; 1593: } else { 1594: drawobj->context->fault_count++; 1595: if (drawobj->context->fault_count > 1596: _fault_throttle_burst) { 1597: set_bit(KGSL_FT_DISABLE, 1598: &cmdobj->fault_policy); 1599: pr_context(device, drawobj->context, 1600: "gpu fault threshold exceeded %d faults in %d msecs\n", 1601: _fault_throttle_burst, 1602: _fault_throttle_time); 1603: } 1604: } 1605: } 1606: 1607: /* 1608: * If FT is disabled for this cmdobj invalidate immediately MATCH LINES: 1654, 1658, 1673, 1674, 1687, 1688, 1702, 1711, 1713, 1733, 1735, 1736, 1740, 1758, 1773 1642: * because we won't see this cmdobj again 1643: */ 1644: 1645: if ((fault & ADRENO_TIMEOUT_FAULT) || 1646: (fault & ADRENO_CTX_DETATCH_TIMEOUT_FAULT)) 1647: bitmap_zero(&cmdobj->fault_policy, BITS_PER_LONG); 1648: 1649: /* 1650: * If the context had a GPU page fault then it is likely it would fault 1651: * again if replayed 1652: */ 1653: 1654: if (test_bit(KGSL_CONTEXT_PRIV_PAGEFAULT, 1655: &drawobj->context->priv)) { 1656: /* we'll need to resume the mmu later... */ 1657: clear_bit(KGSL_FT_REPLAY, &cmdobj->fault_policy); 1658: clear_bit(KGSL_CONTEXT_PRIV_PAGEFAULT, 1659: &drawobj->context->priv); 1660: } 1661: 1662: /* 1663: * Execute the fault tolerance policy. Each cmdobj stores the 1664: * current fault policy that was set when it was queued. 1665: * As the options are tried in descending priority 1666: * (REPLAY -> SKIPIBS -> SKIPFRAME -> NOTHING) the bits are cleared 1667: * from the cmdobj policy so the next thing can be tried if the 1668: * change comes around again 1669: */ 1670: 1671: /* Replay the hanging cmdobj again */ 1672: if (test_and_clear_bit(KGSL_FT_REPLAY, &cmdobj->fault_policy)) { 1673: trace_adreno_cmdbatch_recovery(cmdobj, BIT(KGSL_FT_REPLAY)); 1674: set_bit(KGSL_FT_REPLAY, &cmdobj->fault_recovery); 1675: return; 1676: } 1677: 1678: /* 1679: * Skip the last IB1 that was played but replay everything else. 1680: * Note that the last IB1 might not be in the "hung" cmdobj 1681: * because the CP may have caused a page-fault while it was prefetching 1682: * the next IB1/IB2. walk all outstanding commands and zap the 1683: * supposedly bad IB1 where ever it lurks. 1684: */ 1685: 1686: if (test_and_clear_bit(KGSL_FT_SKIPIB, &cmdobj->fault_policy)) { 1687: trace_adreno_cmdbatch_recovery(cmdobj, BIT(KGSL_FT_SKIPIB)); 1688: set_bit(KGSL_FT_SKIPIB, &cmdobj->fault_recovery); 1689: 1690: for (i = 0; i < count; i++) { 1691: if (replay[i] != NULL && 1692: DRAWOBJ(replay[i])->context->id == 1693: drawobj->context->id) 1694: _skip_ib(replay[i], base); 1695: } 1696: 1697: return; 1698: } 1699: 1700: /* Skip the faulted cmdobj submission */ 1701: if (test_and_clear_bit(KGSL_FT_SKIPCMD, &cmdobj->fault_policy)) { 1702: trace_adreno_cmdbatch_recovery(cmdobj, BIT(KGSL_FT_SKIPCMD)); 1703: 1704: /* Skip faulting cmdobj */ 1705: _skip_cmd(cmdobj, replay, count); 1706: 1707: return; 1708: } 1709: 1710: if (test_and_clear_bit(KGSL_FT_SKIPFRAME, &cmdobj->fault_policy)) { 1711: trace_adreno_cmdbatch_recovery(cmdobj, 1712: BIT(KGSL_FT_SKIPFRAME)); 1713: set_bit(KGSL_FT_SKIPFRAME, &cmdobj->fault_recovery); 1714: 1715: /* 1716: * Skip all the pending cmdobj's for this context until 1717: * the EOF frame is seen 1718: */ 1719: _skip_frame(cmdobj, replay, count); 1720: return; 1721: } 1722: 1723: /* If we get here then all the policies failed */ 1724: 1725: pr_context(device, drawobj->context, "gpu %s ctx %d ts %u\n", 1726: state, drawobj->context->id, drawobj->timestamp); 1727: 1728: /* Mark the context as failed and invalidate it */ 1729: adreno_drawctxt_set_guilty(device, drawobj->context); 1730: } 1731: 1732: /** 1733: * recover_dispatch_q() - Recover all commands in a dispatch queue by 1734: * resubmitting the commands 1735: * @device: Device on which recovery is performed 1736: * @dispatch_q: The command queue to recover 1737: * @fault: Faults caused by the command in the dispatch q 1738: * @base: The IB1 base during the fault 1739: */ 1740: static void recover_dispatch_q(struct kgsl_device *device, 1741: struct adreno_dispatcher_drawqueue *dispatch_q, 1742: int fault, 1743: unsigned int base) 1744: { 1745: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1746: struct kgsl_drawobj_cmd **replay; 1747: unsigned int ptr; 1748: int first = 0; 1749: int count = 0; 1750: int i; 1751: 1752: /* Allocate memory to store the inflight commands */ 1753: replay = kcalloc(dispatch_q->inflight, sizeof(*replay), GFP_KERNEL); 1754: 1755: if (replay == NULL) { 1756: unsigned int ptr = dispatch_q->head; 1757: 1758: /* Recovery failed - mark everybody on this q guilty */ 1759: while (ptr != dispatch_q->tail) { 1760: struct kgsl_drawobj_cmd *cmdobj = 1761: dispatch_q->cmd_q[ptr]; 1762: struct kgsl_drawobj *drawobj = DRAWOBJ(cmdobj); 1763: 1764: adreno_drawctxt_set_guilty(device, drawobj->context); 1765: kgsl_drawobj_destroy(drawobj); 1766: 1767: ptr = DRAWQUEUE_NEXT(ptr, 1768: ADRENO_DISPATCH_DRAWQUEUE_SIZE); 1769: } 1770: 1771: /* 1772: * Set the replay count to zero - this will ensure that the 1773: * hardware gets reset but nothing else gets played 1774: */ 1775: 1776: count = 0; 1777: goto replay; 1778: } 1779: 1780: /* Copy the inflight cmdobj's into the temporary storage */ 1781: ptr = dispatch_q->head; 1782: 1783: while (ptr != dispatch_q->tail) { 1784: replay[count++] = dispatch_q->cmd_q[ptr]; 1785: ptr = DRAWQUEUE_NEXT(ptr, ADRENO_DISPATCH_DRAWQUEUE_SIZE); 1786: } 1787: 1788: if (fault && count) 1789: process_cmdobj_fault(device, replay, 1790: count, base, fault); 1791: replay: 1792: dispatch_q->inflight = 0; 1793: dispatch_q->head = dispatch_q->tail = 0; 1794: /* Remove any pending cmdobj's that have been invalidated */ 1795: remove_invalidated_cmdobjs(device, replay, count); 1796: 1797: /* Replay the pending command buffers */ MATCH LINES: 1825, 1831, 1835, 1848, 1853, 1857, 1859, 1861, 1872, 1873, 1893, 1901, 1908, 1909, 1910, 1912, 1920, 1924, 1941, 1948, 1950, 1981, 2006, 2007, 2008, 2010, 2011, 2021, 2023, 2029, 2052, 2054, 2057, 2058, 2062, 2064, 2066, 2070, 2107, 2110, 2116, 2150, 2152, 2184 1813: } 1814: 1815: /* 1816: * Force each cmdobj to wait for idle - this avoids weird 1817: * CP parse issues 1818: */ 1819: 1820: set_bit(CMDOBJ_WFI, &replay[i]->priv); 1821: 1822: ret = sendcmd(adreno_dev, replay[i]); 1823: 1824: /* 1825: * If sending the command fails, then try to recover by 1826: * invalidating the context 1827: */ 1828: 1829: if (ret) { 1830: pr_context(device, replay[i]->base.context, 1831: "gpu reset failed ctx %u ts %u\n", 1832: replay[i]->base.context->id, 1833: replay[i]->base.timestamp); 1834: 1835: /* Mark this context as guilty (failed recovery) */ 1836: adreno_drawctxt_set_guilty(device, replay[i]->base.context); 1837: remove_invalidated_cmdobjs(device, &replay[i], 1838: count - i); 1839: } 1840: } 1841: 1842: /* Clear the fault bit */ 1843: clear_bit(ADRENO_DEVICE_FAULT, &adreno_dev->priv); 1844: 1845: kfree(replay); 1846: } 1847: 1848: static void do_header_and_snapshot(struct kgsl_device *device, int fault, 1849: struct adreno_ringbuffer *rb, struct kgsl_drawobj_cmd *cmdobj) 1850: { 1851: struct kgsl_drawobj *drawobj = DRAWOBJ(cmdobj); 1852: 1853: /* Always dump the snapshot on a non-drawobj failure */ 1854: if (cmdobj == NULL) { 1855: adreno_fault_header(device, rb, NULL, fault); 1856: 1857: /* GMU snapshot will also pull a full device snapshot */ 1858: if (fault & ADRENO_GMU_FAULT) 1859: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE); 1860: else 1861: kgsl_device_snapshot(device, NULL, NULL, false); 1862: return; 1863: } 1864: 1865: /* Skip everything if the PMDUMP flag is set */ 1866: if (test_bit(KGSL_FT_SKIP_PMDUMP, &cmdobj->fault_policy)) 1867: return; 1868: 1869: /* Print the fault header */ 1870: adreno_fault_header(device, rb, cmdobj, fault); 1871: 1872: if (!(drawobj->context->flags & KGSL_CONTEXT_NO_SNAPSHOT)) 1873: kgsl_device_snapshot(device, drawobj->context, NULL, 1874: fault & ADRENO_GMU_FAULT); 1875: } 1876: 1877: static int dispatcher_do_fault(struct adreno_device *adreno_dev) 1878: { 1879: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1880: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 1881: struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher; 1882: struct adreno_dispatcher_drawqueue *dispatch_q = NULL, *dispatch_q_temp; 1883: struct adreno_ringbuffer *rb; 1884: struct adreno_ringbuffer *hung_rb = NULL; 1885: unsigned int reg; 1886: uint64_t base = 0; 1887: struct kgsl_drawobj_cmd *cmdobj = NULL; 1888: int ret, i; 1889: int fault; 1890: int halt; 1891: bool gx_on; 1892: 1893: fault = adreno_gpu_fault(adreno_dev); 1894: if (fault == 0) 1895: return 0; 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); 1933: adreno_write_gmureg(adreno_dev, 1934: ADRENO_REG_GMU_GMU2HOST_INTR_MASK, 1935: 0xFFFFFFFF); 1936: } 1937: 1938: gx_on = adreno_gx_is_on(adreno_dev); 1939: 1940: /* 1941: * Check if this function was entered after a pagefault. If so, only 1942: * proceed if the fault handler has already run in the IRQ thread, 1943: * else return early to give the fault handler a chance to run. 1944: */ 1945: if (!(fault & ADRENO_IOMMU_STALL_ON_PAGE_FAULT) && gx_on) { 1946: if (adreno_smmu_is_stalled(adreno_dev)) { 1947: kgsl_mutex_unlock(&device->mutex); 1948: mutex_unlock(&adreno_dev->fault_recovery_mutex); 1949: dev_err(device->dev, 1950: "SMMU is stalled without a pagefault\n"); 1951: return -EBUSY; 1952: } 1953: } 1954: 1955: /* Turn off all the timers */ 1956: kgsl_delete_timer_sync(&dispatcher->timer); 1957: 1958: /* 1959: * Deleting uninitialized timer will block for ever on kernel debug 1960: * disable build. Hence skip del timer if it is not initialized. 1961: */ 1962: if (adreno_is_preemption_enabled(adreno_dev)) 1963: kgsl_delete_timer_sync(&adreno_dev->preempt.timer); 1964: 1965: if (gx_on) 1966: adreno_readreg64(adreno_dev, ADRENO_REG_CP_RB_BASE, 1967: ADRENO_REG_CP_RB_BASE_HI, &base); 1968: 1969: /* Force the CP off for all faults to make sure it is good and stopped */ 1970: if (gx_on) { 1971: adreno_readreg(adreno_dev, ADRENO_REG_CP_ME_CNTL, ®); 1972: 1973: if (adreno_is_a5xx(adreno_dev) || adreno_is_a6xx(adreno_dev)) 1974: reg |= 1 | (1 << 1); 1975: else 1976: reg = 0x0; 1977: 1978: adreno_writereg(adreno_dev, ADRENO_REG_CP_ME_CNTL, reg); 1979: } 1980: /* 1981: * retire cmdobj's from all the dispatch_q's before starting recovery 1982: */ 1983: FOR_EACH_RINGBUFFER(adreno_dev, rb, i) { 1984: adreno_dispatch_retire_drawqueue(adreno_dev, 1985: &(rb->dispatch_q)); 1986: /* Select the active dispatch_q */ 1987: if (base == rb->buffer_desc->gpuaddr) { 1988: dispatch_q = &(rb->dispatch_q); 1989: hung_rb = rb; 1990: if (adreno_dev->cur_rb != hung_rb) { 1991: adreno_dev->prev_rb = adreno_dev->cur_rb; 1992: adreno_dev->cur_rb = hung_rb; 1993: } 1994: } 1995: } 1996: 1997: if (dispatch_q && !adreno_drawqueue_is_empty(dispatch_q)) { 1998: cmdobj = dispatch_q->cmd_q[dispatch_q->head]; 1999: trace_adreno_cmdbatch_fault(cmdobj, fault); 2000: } 2001: 2002: if (gx_on) 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), 2042: hung_rb->timestamp); 2043: 2044: kgsl_sharedmem_writel(device->memstore, 2045: MEMSTORE_RB_OFFSET(hung_rb, eoptimestamp), 2046: hung_rb->timestamp); 2047: 2048: /* Schedule any pending events to be run */ 2049: kgsl_process_event_group(device, &hung_rb->events); 2050: } 2051: 2052: ret = adreno_reset(device, fault); 2053: 2054: /* If adreno_reset() fails then what hope do we have for the future? */ 2055: BUG_ON(ret); 2056: 2057: /* if any other fault got in until reset then ignore */ 2058: adreno_clear_gpu_fault(adreno_dev); 2059: 2060: kgsl_mutex_unlock(&device->mutex); 2061: 2062: mutex_unlock(&adreno_dev->fault_recovery_mutex); 2063: 2064: /* recover all the dispatch_q's starting with the one that hung */ 2065: if (dispatch_q) 2066: recover_dispatch_q(device, dispatch_q, fault, base); 2067: FOR_EACH_RINGBUFFER(adreno_dev, rb, i) { 2068: dispatch_q_temp = &(rb->dispatch_q); 2069: if (dispatch_q_temp != dispatch_q) 2070: recover_dispatch_q(device, dispatch_q_temp, 0, base); 2071: } 2072: 2073: atomic_add(halt, &adreno_dev->halt); 2074: 2075: return 1; 2076: } 2077: 2078: static inline int drawobj_consumed(struct kgsl_drawobj *drawobj, 2079: unsigned int consumed, unsigned int retired) 2080: { 2081: return ((timestamp_cmp(drawobj->timestamp, consumed) >= 0) && 2082: (timestamp_cmp(retired, drawobj->timestamp) < 0)); 2083: } 2084: 2085: static const char *_ft_type(enum kgsl_ft_policy_bits nr) 2086: { 2087: if (nr == KGSL_FT_OFF) 2088: return "off"; 2089: else if (nr == KGSL_FT_REPLAY) 2090: return "replay"; 2091: else if (nr == KGSL_FT_SKIPIB) 2092: return "skipib"; 2093: else if (nr == KGSL_FT_SKIPFRAME) 2094: return "skipfame"; 2095: else if (nr == KGSL_FT_DISABLE) 2096: return "disable"; 2097: else if (nr == KGSL_FT_TEMP_DISABLE) 2098: return "temp"; 2099: else if (nr == KGSL_FT_THROTTLE) 2100: return "throttle"; 2101: else if (nr == KGSL_FT_SKIPCMD) 2102: return "skipcmd"; 2103: 2104: return ""; 2105: } 2106: 2107: static void _print_recovery(struct kgsl_device *device, 2108: struct kgsl_drawobj_cmd *cmdobj) 2109: { 2110: int nr = find_first_bit(&cmdobj->fault_recovery, BITS_PER_LONG); 2111: struct kgsl_drawobj *drawobj = DRAWOBJ(cmdobj); 2112: 2113: pr_context(device, drawobj->context, 2114: "gpu %s ctx %u ts %u policy %lX\n", 2115: _ft_type(nr), drawobj->context->id, drawobj->timestamp, 2116: cmdobj->fault_recovery); 2117: } 2118: 2119: static void cmdobj_profile_ticks(struct adreno_device *adreno_dev, 2120: struct kgsl_drawobj_cmd *cmdobj, uint64_t *start, uint64_t *retire, 2121: uint64_t *active) 2122: { 2123: void *ptr = adreno_dev->profile_buffer->hostptr; 2124: struct adreno_drawobj_profile_entry *entry; 2125: 2126: entry = (struct adreno_drawobj_profile_entry *) 2127: (ptr + (cmdobj->profile_index * sizeof(*entry))); 2128: 2129: /* get updated values of started and retired */ 2130: rmb(); 2131: *start = entry->started; 2132: *retire = entry->retired; 2133: if (ADRENO_GPUREV(adreno_dev) < 600) 2134: *active = entry->retired - entry->started; 2135: else 2136: *active = entry->ctx_end - entry->ctx_start; 2137: } 2138: 2139: static void retire_cmdobj(struct adreno_device *adreno_dev, 2140: struct kgsl_drawobj_cmd *cmdobj) 2141: { 2142: struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher; 2143: struct kgsl_drawobj *drawobj = DRAWOBJ(cmdobj); 2144: struct adreno_context *drawctxt = ADRENO_CONTEXT(drawobj->context); 2145: struct adreno_ringbuffer *rb = drawctxt->rb; 2146: struct kgsl_context *context = drawobj->context; 2147: uint64_t start = 0, end = 0, active = 0; 2148: struct retire_info info = {0}; 2149: 2150: if (cmdobj->fault_recovery != 0) { 2151: set_bit(ADRENO_CONTEXT_FAULT, &drawobj->context->priv); 2152: _print_recovery(KGSL_DEVICE(adreno_dev), cmdobj); 2153: } 2154: 2155: if (test_bit(CMDOBJ_PROFILE, &cmdobj->priv)) 2156: cmdobj_profile_ticks(adreno_dev, cmdobj, &start, &end, &active); 2157: 2158: info.inflight = (int)dispatcher->inflight; 2159: info.rb_id = rb->id; 2160: info.wptr = rb->wptr; 2161: info.timestamp = drawobj->timestamp; 2162: info.sop = start; 2163: info.eop = end; 2164: info.active = active; 2165: 2166: /* protected GPU work must not be reported */ 2167: if (!(context->flags & KGSL_CONTEXT_SECURE)) 2168: kgsl_work_period_update(KGSL_DEVICE(adreno_dev), 2169: context->proc_priv->period, active); 2170: 2171: msm_perf_events_update(MSM_PERF_GFX, MSM_PERF_RETIRED, 2172: pid_nr(context->proc_priv->pid), 2173: context->id, drawobj->timestamp, 2174: !!(drawobj->flags & KGSL_DRAWOBJ_END_OF_FRAME)); 2175: 2176: if (drawobj->flags & KGSL_DRAWOBJ_END_OF_FRAME) { 2177: atomic64_inc(&context->proc_priv->frame_count); 2178: atomic_inc(&context->proc_priv->period->frames); 2179: } 2180: 2181: info.rptr = adreno_get_rptr(rb); 2182: trace_adreno_cmdbatch_retired(drawobj->context, &info, 2183: drawobj->flags, rb->dispatch_q.inflight, 2184: cmdobj->fault_recovery); 2185: 2186: log_kgsl_cmdbatch_retired_event(context->id, drawobj->timestamp, 2187: context->priority, drawobj->flags, start, end); 2188: 2189: drawctxt->submit_retire_ticks[drawctxt->ticks_index] = 2190: end - cmdobj->submit_ticks; 2191: 2192: drawctxt->ticks_index = (drawctxt->ticks_index + 1) % 2193: SUBMIT_RETIRE_TICKS_SIZE; 2194: 2195: trace_adreno_cmdbatch_done(drawobj->context->id, 2196: drawobj->context->priority, drawobj->timestamp); 2197: kgsl_drawobj_destroy(drawobj); 2198: } 2199: 2200: static int adreno_dispatch_retire_drawqueue(struct adreno_device *adreno_dev, 2201: struct adreno_dispatcher_drawqueue *drawqueue) 2202: { 2203: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2204: struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher; 2205: int count = 0; 2206: 2207: while (!adreno_drawqueue_is_empty(drawqueue)) { 2208: struct kgsl_drawobj_cmd *cmdobj = MATCH LINES: 2254, 2258, 2278 2242: 2243: /* Don't timeout if the IB timeout is disabled globally */ 2244: if (!adreno_long_ib_detect(adreno_dev)) 2245: return; 2246: 2247: /* Don't time out if the context has disabled it */ 2248: if (drawobj->context->flags & KGSL_CONTEXT_NO_FAULT_TOLERANCE) 2249: return; 2250: 2251: pr_context(device, drawobj->context, "gpu timeout ctx %u ts %u\n", 2252: drawobj->context->id, drawobj->timestamp); 2253: 2254: adreno_set_gpu_fault(adreno_dev, ADRENO_TIMEOUT_FAULT); 2255: 2256: /* 2257: * This makes sure dispatcher doesn't run endlessly in cases where 2258: * we couldn't run recovery 2259: */ 2260: drawqueue->expires = jiffies + msecs_to_jiffies(adreno_drawobj_timeout); 2261: } 2262: 2263: static int adreno_dispatch_process_drawqueue(struct adreno_device *adreno_dev, 2264: struct adreno_dispatcher_drawqueue *drawqueue) 2265: { 2266: int count = adreno_dispatch_retire_drawqueue(adreno_dev, drawqueue); 2267: 2268: /* Nothing to do if there are no pending commands */ 2269: if (adreno_drawqueue_is_empty(drawqueue)) 2270: return count; 2271: 2272: /* Don't update the drawqueue timeout if it isn't active */ 2273: if (!drawqueue_is_current(drawqueue)) 2274: return count; 2275: 2276: /* 2277: * If the current ringbuffer retired any commands then universally 2278: * reset the timeout 2279: */ 2280: 2281: if (count) { 2282: drawqueue->expires = jiffies + 2283: msecs_to_jiffies(adreno_drawobj_timeout); 2284: return count; 2285: } 2286: 2287: /* 2288: * If we get here then 1) the ringbuffer is current and 2) we haven't 2289: * retired anything. Check to see if the timeout if valid for the 2290: * current drawobj and fault if it has expired 2291: */ 2292: _adreno_dispatch_check_timeout(adreno_dev, drawqueue); 2293: return 0; 2294: } 2295: 2296: /* Take down the dispatcher and release any power states */ 2297: static void _dispatcher_power_down(struct adreno_device *adreno_dev) 2298: { 2299: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2300: struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher; 2301: 2302: kgsl_mutex_lock(&device->mutex); MATCH LINES: 2788, 2802 2776: 2777: adreno_get_gpu_halt(adreno_dev); 2778: 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: 2816: int adreno_drain_and_idle(struct kgsl_device *device) 2817: { 2818: int ret = adreno_drain(device, HZ); 2819: 2820: /* Make sure the dispatcher and hardware are idle */ 2821: if (!ret) 2822: ret = adreno_wait_idle(device); 2823: 2824: return ret; 2825: } --- FILE: \adreno_drawctxt.c | HITS: 6 --- MATCH LINES: 309 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: 314: u32 adreno_prepare_preib_preempt_scratch(struct adreno_device *adreno_dev, 315: struct adreno_context *drawctxt, u32 *cmds) 316: { 317: struct adreno_ringbuffer *rb = drawctxt->rb; 318: u32 *cmds_orig = cmds; 319: u64 gpuaddr, dest; 320: 321: if (!drawctxt->base.user_ctxt_record) 322: return 0; 323: 324: dest = PREEMPT_SCRATCH_ADDR(adreno_dev, rb->id); 325: gpuaddr = drawctxt->base.user_ctxt_record->memdesc.gpuaddr; 326: 327: *cmds++ = cp_mem_packet(adreno_dev, CP_MEM_WRITE, 2, 2); 328: cmds += cp_gpuaddr(adreno_dev, cmds, dest); 329: *cmds++ = lower_32_bits(gpuaddr); 330: *cmds++ = upper_32_bits(gpuaddr); 331: 332: return (u32) (cmds - cmds_orig); 333: } MATCH LINES: 424 412: KGSL_CONTEXT_PER_CONTEXT_TS | 413: KGSL_CONTEXT_USER_GENERATED_TS | 414: KGSL_CONTEXT_NO_FAULT_TOLERANCE | 415: KGSL_CONTEXT_INVALIDATE_ON_FAULT | 416: KGSL_CONTEXT_CTX_SWITCH | 417: KGSL_CONTEXT_PRIORITY_MASK | 418: KGSL_CONTEXT_TYPE_MASK | 419: KGSL_CONTEXT_PWR_CONSTRAINT | 420: KGSL_CONTEXT_IFH_NOP | 421: KGSL_CONTEXT_SECURE | 422: KGSL_CONTEXT_PREEMPT_STYLE_MASK | 423: KGSL_CONTEXT_LPAC | 424: KGSL_CONTEXT_NO_SNAPSHOT | 425: KGSL_CONTEXT_FAULT_INFO); 426: 427: /* Check for errors before trying to initialize */ 428: 429: /* If preemption is not supported, ignore preemption request */ 430: if (!adreno_preemption_feature_set(adreno_dev)) 431: local &= ~KGSL_CONTEXT_PREEMPT_STYLE_MASK; 432: 433: /* We no longer support legacy context switching */ 434: if ((local & KGSL_CONTEXT_PREAMBLE) == 0 || 435: (local & KGSL_CONTEXT_NO_GMEM_ALLOC) == 0) { 436: dev_err_once(device->dev, 437: "legacy context switch not supported\n"); 438: return ERR_PTR(-EINVAL); 439: } 440: 441: /* Make sure that our target can support secure contexts if requested */ 442: if (!kgsl_mmu_is_secured(&device->mmu) && 443: (local & KGSL_CONTEXT_SECURE)) { 444: dev_err_once(device->dev, "Secure context not supported\n"); 445: return ERR_PTR(-EOPNOTSUPP); 446: } 447: 448: if ((local & KGSL_CONTEXT_LPAC) && MATCH LINES: 561, 563, 573, 577 549: * Wait for the last global timestamp to pass before continuing. 550: * The maxumum wait time is 30s, some large IB's can take longer 551: * than 10s and if hang happens then the time for the context's 552: * commands to retire will be greater than 10s. 30s should be sufficient 553: * time to wait for the commands even if a hang happens. 554: */ 555: ret = adreno_drawctxt_wait_rb(adreno_dev, &drawctxt->base, 556: drawctxt->internal_timestamp, 30 * 1000); 557: 558: /* 559: * If the wait for global fails due to timeout then mark it as 560: * context detach timeout fault and schedule dispatcher to kick 561: * in GPU recovery. For a ADRENO_CTX_DETATCH_TIMEOUT_FAULT we clear 562: * the policy and invalidate the context. If EAGAIN error is returned 563: * then recovery will kick in and there will be no more commands in the 564: * RB pipe from this context which is what we are waiting for, so ignore 565: * -EAGAIN error. 566: */ 567: if (ret && ret != -EAGAIN) { 568: dev_err(device->dev, 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: { --- FILE: \adreno_drawctxt.h | HITS: 2 --- MATCH LINES: 96, 110 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 115: * marker. 116: * @ADRENO_CONTEXT_FORCE_PREAMBLE - Force the preamble for the next submission. 117: * @ADRENO_CONTEXT_SKIP_CMD - Context's drawobj's skipped during 118: fault tolerance. 119: * @ADRENO_CONTEXT_FENCE_LOG - Dump fences on this context. 120: */ 121: enum adreno_context_priv { 122: ADRENO_CONTEXT_FAULT = KGSL_CONTEXT_PRIV_DEVICE_SPECIFIC, 123: ADRENO_CONTEXT_GPU_HANG, 124: ADRENO_CONTEXT_GPU_HANG_FT, 125: ADRENO_CONTEXT_SKIP_EOF, 126: ADRENO_CONTEXT_FORCE_PREAMBLE, 127: ADRENO_CONTEXT_SKIP_CMD, 128: ADRENO_CONTEXT_FENCE_LOG, 129: }; 130: 131: struct kgsl_context *adreno_drawctxt_create( 132: struct kgsl_device_private *dev_priv, 133: uint32_t *flags); 134: --- FILE: \adreno_gen7.c | HITS: 27 --- MATCH LINES: 264 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: /* MATCH LINES: 385, 386 373: } 374: #endif 375: 376: int gen7_init(struct adreno_device *adreno_dev) 377: { 378: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 379: const struct adreno_gen7_core *gen7_core = to_gen7_core(adreno_dev); 380: 381: adreno_dev->ahb_timeout_val = adreno_get_ahb_timeout_val(adreno_dev, 382: gen7_core->noc_timeout_us); 383: adreno_dev->bcl_data = gen7_core->bcl_data; 384: 385: adreno_dev->cooperative_reset = ADRENO_FEATURE(adreno_dev, 386: ADRENO_COOP_RESET); 387: 388: gen7_calc_ubwc_config(adreno_dev); 389: 390: gen7_crashdump_init(adreno_dev); 391: 392: return adreno_allocate_global(device, &adreno_dev->pwrup_reglist, 393: PAGE_SIZE, 0, 0, KGSL_MEMDESC_PRIVILEGED, 394: "powerup_register_list"); 395: } 396: 397: #define CX_TIMER_INIT_SAMPLES 16 398: void gen7_cx_timer_init(struct adreno_device *adreno_dev) 399: { 400: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 401: u64 seed_val, tmr, skew = 0; 402: int i; 403: unsigned long flags; 404: 405: /* 406: * Only gen7_9_x has the CX timer. Set it up during first boot or 407: * after suspend resume. 408: */ 409: if (!adreno_is_gen7_9_x(adreno_dev) || 410: test_bit(ADRENO_DEVICE_CX_TIMER_INITIALIZED, &adreno_dev->priv)) MATCH LINES: 633 621: u32 retry = 3; 622: 623: kgsl_regwrite(device, GEN7_RBBM_CGC_P2S_TRIG_CMD, 1); 624: /* Poll for the TXDONE:BIT(0) status */ 625: do { 626: /* Wait for small amount of time for TXDONE status*/ 627: udelay(1); 628: kgsl_regread(device, GEN7_RBBM_CGC_P2S_STATUS, &value); 629: } while (!(value & BIT(0)) && --retry); 630: 631: if (!(value & BIT(0))) { 632: dev_err(device->dev, "RBBM_CGC_P2S_STATUS:TXDONE Poll failed\n"); 633: kgsl_device_snapshot(device, NULL, NULL, false); 634: return; 635: } 636: kgsl_regwrite(device, GEN7_RBBM_CLOCK_CNTL_GLOBAL, 0); 637: } 638: return; 639: } 640: 641: kgsl_regread(device, GEN7_RBBM_CLOCK_CNTL, &value); 642: 643: if (value == RBBM_CLOCK_CNTL_ON && on) 644: return; 645: 646: if (value == 0 && !on) 647: return; 648: 649: for (i = 0; i < gen7_core->hwcg_count; i++) 650: kgsl_regwrite(device, gen7_core->hwcg[i].offset, 651: on ? gen7_core->hwcg[i].val : 0); 652: 653: if (adreno_is_gen7_15_0(adreno_dev) || adreno_is_gen7_11_0(adreno_dev)) 654: kgsl_regwrite(device, GEN7_RBBM_CLOCK_MODE_GPC, 0x02222222); 655: 656: /* enable top level HWCG */ 657: kgsl_regwrite(device, GEN7_RBBM_CLOCK_CNTL, MATCH LINES: 1004 992: gen7_host_aperture_set(adreno_dev, 0); 993: } else { 994: kgsl_regwrite(device, GEN7_GRAS_NC_MODE_CNTL, FIELD_PREP(GENMASK(8, 5), 995: (adreno_dev->highest_bank_bit - 13))); 996: } 997: 998: kgsl_regwrite(device, GEN7_UCHE_MODE_CNTL, 999: ((mal == 64) ? BIT(23) : 0) | 1000: FIELD_PREP(GENMASK(22, 21), hbb_lo)); 1001: 1002: kgsl_regwrite(device, GEN7_RBBM_INTERFACE_HANG_INT_CNTL, BIT(30) | 1003: FIELD_PREP(GENMASK(27, 0), 1004: gen7_core->hang_detect_cycles)); 1005: kgsl_regwrite(device, GEN7_UCHE_CLIENT_PF, BIT(7) | 1006: FIELD_PREP(GENMASK(3, 0), adreno_dev->uche_client_pf)); 1007: 1008: /* Enable the GMEM save/restore feature for preemption */ 1009: if (adreno_is_preemption_enabled(adreno_dev)) 1010: kgsl_regwrite(device, GEN7_RB_CONTEXT_SWITCH_GMEM_SAVE_RESTORE, 1011: 0x1); 1012: 1013: if (adreno_is_gen7_9_x(adreno_dev)) { 1014: /* Disable ubwc merged UFC request feature */ 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); MATCH LINES: 1158 1146: kgsl_regread(device, GEN7_RBBM_STATUS, &status); 1147: kgsl_regread(device, GEN7_RBBM_STATUS3, &status3); 1148: kgsl_regread(device, GEN7_RBBM_INT_0_STATUS, &intstatus); 1149: kgsl_regread(device, GEN7_CP_HW_FAULT, &hwfault); 1150: 1151: dev_err(device->dev, 1152: "rb=%d pos=%X/%X rbbm_status=%8.8X/%8.8X int_0_status=%8.8X\n", 1153: adreno_dev->cur_rb ? adreno_dev->cur_rb->id : -1, rptr, wptr, 1154: status, status3, intstatus); 1155: 1156: dev_err(device->dev, " hwfault=%8.8X\n", hwfault); 1157: 1158: kgsl_device_snapshot(device, NULL, NULL, false); 1159: } 1160: 1161: /* 1162: * gen7_send_cp_init() - Initialize ringbuffer 1163: * @adreno_dev: Pointer to adreno device 1164: * @rb: Pointer to the ringbuffer of device 1165: * 1166: * Submit commands for ME initialization, 1167: */ 1168: static int gen7_send_cp_init(struct adreno_device *adreno_dev, 1169: struct adreno_ringbuffer *rb) 1170: { 1171: unsigned int *cmds; 1172: int ret; 1173: 1174: cmds = adreno_ringbuffer_allocspace(rb, GEN7_CP_INIT_DWORDS); 1175: if (IS_ERR(cmds)) 1176: return PTR_ERR(cmds); 1177: 1178: gen7_cp_init_cmds(adreno_dev, cmds); 1179: 1180: ret = gen7_ringbuffer_submit(rb, NULL); 1181: if (!ret) { 1182: ret = adreno_spin_idle(adreno_dev, 2000); MATCH LINES: 1551, 1553 1539: 1540: #define SCOOBYDOO 0x5c00bd00 1541: 1542: static const char *gen7_fault_block_uche(struct kgsl_device *device, 1543: char *str, int size, bool lpac) 1544: { 1545: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1546: unsigned int uche_client_id = adreno_dev->uche_client_pf; 1547: const char *uche_client_str, *fault_block; 1548: 1549: /* 1550: * Smmu driver takes a vote on CX gdsc before calling the kgsl 1551: * pagefault handler. If there is contention for device mutex in this 1552: * path and the dispatcher fault handler is holding this lock, trying 1553: * to turn off CX gdsc will fail during the reset. So to avoid blocking 1554: * here, try to lock device mutex and return if it fails. 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) { MATCH LINES: 1598 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: 1592: fail: 1593: snprintf(str, size, "%s: Unknown (client_id: %u)", 1594: fault_block, uche_client_id); 1595: return str; 1596: } 1597: 1598: static const char *gen7_iommu_fault_block(struct kgsl_device *device, 1599: unsigned int fsynr1) 1600: { 1601: unsigned int mid = fsynr1 & 0xff; 1602: static char str[36]; 1603: 1604: switch (mid) { 1605: case 0x0: 1606: return "CP"; 1607: case 0x1: 1608: return "UCHE: Unknown"; 1609: case 0x2: 1610: return "UCHE_LPAC: Unknown"; 1611: case 0x3: 1612: return gen7_fault_block_uche(device, str, sizeof(str), false); 1613: case 0x4: 1614: return "CCU"; 1615: case 0x5: 1616: return "Flag cache"; 1617: case 0x6: 1618: return "PREFETCH"; 1619: case 0x7: 1620: return "GMU"; 1621: case 0x8: 1622: return gen7_fault_block_uche(device, str, sizeof(str), true); MATCH LINES: 1796, 1797, 1830, 1831 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: MATCH LINES: 1891, 1915 1879: adreno_dev->preempt.preempt_level = gen7_core->preempt_level; 1880: adreno_dev->preempt.skipsaverestore = true; 1881: adreno_dev->preempt.usesgmem = true; 1882: set_bit(ADRENO_DEVICE_PREEMPTION, &adreno_dev->priv); 1883: } 1884: 1885: /* debugfs node for ACD calibration */ 1886: debugfs_create_file("acd_calibrate", 0644, device->d_debugfs, device, &acd_cal_fops); 1887: 1888: gen7_coresight_init(adreno_dev); 1889: 1890: /* Dump additional AQE 16KB data on top of default 96KB(48(BR)+48(BV)) */ 1891: device->snapshot_ctxt_record_size = ADRENO_FEATURE(adreno_dev, ADRENO_AQE) ? 1892: 112 * SZ_1K : 96 * SZ_1K; 1893: 1894: return 0; 1895: } 1896: 1897: /* Register offset defines for Gen7, in order of enum adreno_regs */ 1898: static unsigned int gen7_register_offsets[ADRENO_REG_REGISTER_MAX] = { 1899: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_BASE, GEN7_CP_RB_BASE), 1900: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_BASE_HI, GEN7_CP_RB_BASE_HI), 1901: ADRENO_REG_DEFINE(ADRENO_REG_CP_LPAC_RB_BASE, GEN7_CP_LPAC_RB_BASE), 1902: ADRENO_REG_DEFINE(ADRENO_REG_CP_LPAC_RB_BASE_HI, GEN7_CP_LPAC_RB_BASE_HI), 1903: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_RPTR, GEN7_CP_RB_RPTR), 1904: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_WPTR, GEN7_CP_RB_WPTR), 1905: ADRENO_REG_DEFINE(ADRENO_REG_CP_ME_CNTL, GEN7_CP_SQE_CNTL), 1906: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BASE, GEN7_CP_IB1_BASE), 1907: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BASE_HI, GEN7_CP_IB1_BASE_HI), 1908: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BUFSZ, GEN7_CP_IB1_REM_SIZE), 1909: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BASE, GEN7_CP_IB2_BASE), 1910: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BASE_HI, GEN7_CP_IB2_BASE_HI), 1911: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BUFSZ, GEN7_CP_IB2_REM_SIZE), 1912: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_STATUS, GEN7_RBBM_STATUS), 1913: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_STATUS3, GEN7_RBBM_STATUS3), 1914: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_INT_0_MASK, GEN7_RBBM_INT_0_MASK), 1915: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_SW_RESET_CMD, GEN7_RBBM_SW_RESET_CMD), 1916: ADRENO_REG_DEFINE(ADRENO_REG_GMU_AO_HOST_INTERRUPT_MASK, 1917: GEN7_GMU_AO_HOST_INTERRUPT_MASK), 1918: ADRENO_REG_DEFINE(ADRENO_REG_GMU_GMU2HOST_INTR_MASK, 1919: GEN7_GMU_GMU2HOST_INTR_MASK), 1920: }; 1921: 1922: 1923: static u32 _get_pipeid(u32 groupid) 1924: { 1925: switch (groupid) { 1926: case KGSL_PERFCOUNTER_GROUP_BV_PC: 1927: fallthrough; 1928: case KGSL_PERFCOUNTER_GROUP_BV_VPC: 1929: fallthrough; 1930: case KGSL_PERFCOUNTER_GROUP_BV_TSE: 1931: fallthrough; 1932: case KGSL_PERFCOUNTER_GROUP_BV_RAS: 1933: fallthrough; 1934: case KGSL_PERFCOUNTER_GROUP_BV_LRZ: 1935: fallthrough; 1936: case KGSL_PERFCOUNTER_GROUP_BV_HLSQ: 1937: return PIPE_BV; 1938: case KGSL_PERFCOUNTER_GROUP_PC: 1939: fallthrough; MATCH LINES: 2445, 2472, 2496, 2504, 2506, 2509, 2536, 2538, 2541, 2567, 2572, 2573 2433: GEN7_CP_PERIPH_IB1_BASE_HI(adreno_dev), &lpac_ib1base, PIPE_LPAC); 2434: gen7_periph_regread(device, GEN7_CP_PERIPH_IB1_OFFSET(adreno_dev), &lpac_ib1sz, PIPE_LPAC); 2435: gen7_periph_regread64(device, GEN7_CP_PERIPH_IB2_BASE_LO(adreno_dev), 2436: GEN7_CP_PERIPH_IB2_BASE_HI(adreno_dev), &lpac_ib2base, PIPE_LPAC); 2437: gen7_periph_regread(device, GEN7_CP_PERIPH_IB2_OFFSET(adreno_dev), &lpac_ib2sz, PIPE_LPAC); 2438: 2439: pr_context(device, drawobj_lpac->context, 2440: "LPAC: status %8.8X rb %4.4x/%4.4x ib1 %16.16llX/%4.4x ib2 %16.16llX/%4.4x\n", 2441: status, lpac_rptr, lpac_wptr, lpac_ib1base, 2442: lpac_ib1sz, lpac_ib2base, lpac_ib2sz); 2443: 2444: done: 2445: trace_adreno_gpu_fault(drawobj_lpac->context->id, drawobj_lpac->timestamp, status, 2446: lpac_rptr, lpac_wptr, lpac_ib1base, lpac_ib1sz, lpac_ib2base, lpac_ib2sz, 2447: adreno_get_level(drawobj_lpac->context)); 2448: } 2449: 2450: static void gen7_fault_header(struct adreno_device *adreno_dev, 2451: struct kgsl_drawobj *drawobj) 2452: { 2453: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2454: struct adreno_context *drawctxt; 2455: u32 status = 0, rptr = 0, wptr = 0, ib1sz = 0, ib2sz = 0; 2456: u64 ib1base = 0, ib2base = 0; 2457: u32 ctxt_id = 0, ts = 0; 2458: int rb_id = -1; 2459: bool gx_on = adreno_gx_is_on(adreno_dev); 2460: 2461: if (drawobj) { 2462: drawctxt = ADRENO_CONTEXT(drawobj->context); 2463: drawobj->context->last_faulted_cmd_ts = drawobj->timestamp; 2464: drawobj->context->total_fault_count++; 2465: ctxt_id = drawobj->context->id; 2466: ts = drawobj->timestamp; 2467: rb_id = adreno_get_level(drawobj->context); 2468: 2469: pr_context(device, drawobj->context, 2470: "ctx %u ctx_type %s ts %u policy %lX dispatch_queue=%d\n", 2471: drawobj->context->id, kgsl_context_type(drawctxt->type), 2472: drawobj->timestamp, CMDOBJ(drawobj)->fault_recovery, 2473: drawobj->context->gmu_dispatch_queue); 2474: 2475: pr_context(device, drawobj->context, "cmdline: %s\n", 2476: drawctxt->base.proc_priv->cmdline); 2477: } 2478: 2479: if (!gx_on) 2480: goto done; 2481: 2482: kgsl_regread(device, GEN7_RBBM_STATUS, &status); 2483: kgsl_regread(device, GEN7_CP_RB_RPTR, &rptr); 2484: kgsl_regread(device, GEN7_CP_RB_WPTR, &wptr); 2485: gen7_periph_regread64(device, GEN7_CP_PERIPH_IB1_BASE_LO(adreno_dev), 2486: GEN7_CP_PERIPH_IB1_BASE_HI(adreno_dev), &ib1base, PIPE_BR); 2487: gen7_periph_regread(device, GEN7_CP_PERIPH_IB1_OFFSET(adreno_dev), &ib1sz, PIPE_BR); 2488: gen7_periph_regread64(device, GEN7_CP_PERIPH_IB2_BASE_LO(adreno_dev), 2489: GEN7_CP_PERIPH_IB2_BASE_HI(adreno_dev), &ib2base, PIPE_BR); 2490: gen7_periph_regread(device, GEN7_CP_PERIPH_IB2_OFFSET(adreno_dev), &ib2sz, PIPE_BR); 2491: 2492: dev_err(device->dev, 2493: "status %8.8X rb %4.4x/%4.4x ib1 %16.16llX/%4.4x ib2 %16.16llX/%4.4x\n", 2494: status, rptr, wptr, ib1base, ib1sz, ib2base, ib2sz); 2495: done: 2496: trace_adreno_gpu_fault(ctxt_id, ts, status, 2497: rptr, wptr, ib1base, ib1sz, ib2base, ib2sz, rb_id); 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: 16 --- MATCH LINES: 16 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #ifndef _ADRENO_GEN7_H_ 8: #define _ADRENO_GEN7_H_ 9: 10: #include 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 */ MATCH LINES: 113, 114, 119, 120 101: /** @hwcg: List of registers and values to write for HWCG */ 102: const struct kgsl_regmap_list *hwcg; 103: /** @hwcg_count: Number of registers in @hwcg */ 104: u32 hwcg_count; 105: /** @ao_hwcg: List of registers and values to write for HWCG in AO block */ 106: const struct kgsl_regmap_list *ao_hwcg; 107: /** @ao_hwcg_count: Number of registers in @ao_hwcg */ 108: u32 ao_hwcg_count; 109: /** @gbif: List of registers and values to write for GBIF */ 110: const struct kgsl_regmap_list *gbif; 111: /** @gbif_count: Number of registers in @gbif */ 112: u32 gbif_count; 113: /** @hang_detect_cycles: Hang detect counter timeout value */ 114: u32 hang_detect_cycles; 115: /** @protected_regs: Array of protected registers for the target */ 116: const struct gen7_protected_regs *protected_regs; 117: /** @ctxt_record_size: Size of the preemption record in bytes */ 118: u64 ctxt_record_size; 119: /** @gen7_snapshot_block_list: Device-specific blocks dumped in the snapshot */ 120: const struct gen7_snapshot_block_list *gen7_snapshot_block_list; 121: /** @gmu_hub_clk_freq: Gmu hub interface clock frequency */ 122: u64 gmu_hub_clk_freq; 123: /** 124: * @bcl_data: bit 0 contains response type for bcl alarms and bits 1:21 controls sid vals 125: * to configure throttle levels for bcl alarm levels 0-2. If sid vals are not set, 126: * gmu fw sets default throttle levels. 127: */ 128: u32 bcl_data; 129: /** @preempt_level: Preemption level valid ranges [0 to 2] */ 130: u32 preempt_level; 131: /** @qos_value: GPU qos value to set for each RB. */ 132: const u32 *qos_value; 133: /** 134: * @acv_perfmode_ddr_freq: Vote perfmode when DDR frequency >= acv_perfmode_ddr_freq. 135: * If not specified, vote perfmode for highest DDR level only. 136: */ 137: u32 acv_perfmode_ddr_freq; 138: /** @acv_perfmode_vote: ACV vote for GPU perfmode */ 139: u32 acv_perfmode_vote; 140: /** @rt_bus_hint: IB level hint for real time clients i.e. RB-0 */ 141: const u32 rt_bus_hint; 142: /** @fast_bus_hint: Whether or not to increase IB vote on high ddr stall */ 143: bool fast_bus_hint; 144: /** @noc_timeout_us: GPU config NOC port timeout in usec */ MATCH LINES: 280, 281, 285, 287, 289, 291, 292 268: u32 gen7_preemption_post_ibsubmit(struct adreno_device *adreno_dev, 269: unsigned int *cmds); 270: u32 gen7_preemption_pre_ibsubmit(struct adreno_device *adreno_dev, 271: struct adreno_ringbuffer *rb, struct adreno_context *drawctxt, 272: u32 *cmds); 273: 274: void gen7_preemption_callback(struct adreno_device *adreno_dev, int bit); 275: 276: void gen7_preemption_context_destroy(struct kgsl_context *context); 277: 278: void gen7_preemption_prepare_postamble(struct adreno_device *adreno_dev); 279: 280: void gen7_snapshot(struct adreno_device *adreno_dev, 281: struct kgsl_snapshot *snapshot); 282: void gen7_crashdump_init(struct adreno_device *adreno_dev); 283: 284: /** 285: * gen7_snapshot_external_core_regs - Dump external registers into snapshot 286: * @device: Pointer to KGSL device 287: * @snapshot: Pointer to the snapshot 288: * 289: * Dump external core registers like GPUCC, CPR into GPU snapshot. 290: */ 291: void gen7_snapshot_external_core_regs(struct kgsl_device *device, 292: struct kgsl_snapshot *snapshot); 293: 294: /** 295: * gen7_start - Program gen7 registers 296: * @adreno_dev: An Adreno GPU handle 297: * 298: * This function does all gen7 register programming every 299: * time we boot the gpu 300: * 301: * Return: 0 on success or negative on failure 302: */ 303: int gen7_start(struct adreno_device *adreno_dev); 304: 305: /** 306: * gen7_init - Initialize gen7 resources 307: * @adreno_dev: An Adreno GPU handle 308: * 309: * This function does gen7 specific one time initialization 310: * and is invoked when the very first client opens a 311: * kgsl instance 312: * 313: * Return: Zero on success and negative error on failure 314: */ 315: int gen7_init(struct adreno_device *adreno_dev); 316: MATCH LINES: 374 362: * This function sets up the gen7 resources common across all 363: * gen7 targets 364: */ 365: int gen7_probe_common(struct platform_device *pdev, 366: struct adreno_device *adreno_dev, u32 chipid, 367: const struct adreno_gpu_core *gpucore); 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 MATCH LINES: 477, 480, 482 465: * 466: * Return: 0 on success or negative on failure 467: */ 468: int gen7_gmu_hfi_probe(struct adreno_device *adreno_dev); 469: 470: static inline const struct gen7_gpudev * 471: to_gen7_gpudev(const struct adreno_gpudev *gpudev) 472: { 473: return container_of(gpudev, struct gen7_gpudev, base); 474: } 475: 476: /** 477: * gen7_reset_preempt_records - Reset the preemption buffers 478: * @adreno_dev: Handle to the adreno device 479: * 480: * Reset the preemption records at the time of hard reset 481: */ 482: void gen7_reset_preempt_records(struct adreno_device *adreno_dev); 483: 484: /** 485: * gen7_enable_ahb_timeout_detection - Program AHB control registers 486: * @adreno_dev: An Adreno GPU handle 487: * 488: * Program AHB control registers to enable AHB timeout detection. 489: */ 490: void gen7_enable_ahb_timeout_detection(struct adreno_device *adreno_dev); 491: 492: /** 493: * gen7_scm_gpu_init_cx_regs - Program gpu regs for feature support 494: * @adreno_dev: Handle to the adreno device 495: * 496: * Program gpu regs for feature support. Scm call for the same 497: * is added from kernel version 6.0 onwards. 498: * 499: * Return: 0 on success or negative on failure 500: */ 501: int gen7_scm_gpu_init_cx_regs(struct adreno_device *adreno_dev); 502: 503: /** 504: * gen7_host_aperture_set - Program CP aperture register 505: * @adreno_dev: Handle to the adreno device 506: * @pipe_id: Pipe for which the register is to be set --- FILE: \adreno_gen7_0_0_snapshot.h | HITS: 4 --- MATCH LINES: 6, 7, 9 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_GEN7_0_0_SNAPSHOT_H 7: #define __ADRENO_GEN7_0_0_SNAPSHOT_H 8: 9: #include "adreno_gen7_snapshot.h" 10: 11: static const u32 gen7_0_0_debugbus_blocks[] = { 12: DEBUGBUS_CP_0_0, 13: DEBUGBUS_CP_0_1, 14: DEBUGBUS_RBBM, 15: DEBUGBUS_HLSQ, 16: DEBUGBUS_UCHE_0, 17: DEBUGBUS_TESS_BR, 18: DEBUGBUS_TESS_BV, 19: DEBUGBUS_PC_BR, 20: DEBUGBUS_PC_BV, 21: DEBUGBUS_VFDP_BR, 22: DEBUGBUS_VFDP_BV, 23: DEBUGBUS_VPC_BR, 24: DEBUGBUS_VPC_BV, 25: DEBUGBUS_TSE_BR, 26: DEBUGBUS_TSE_BV, 27: DEBUGBUS_RAS_BR, 28: DEBUGBUS_RAS_BV, 29: DEBUGBUS_VSC, 30: DEBUGBUS_COM_0, 31: DEBUGBUS_LRZ_BR, 32: DEBUGBUS_LRZ_BV, 33: DEBUGBUS_UFC_0, MATCH LINES: 927 915: static_assert(IS_ALIGNED(sizeof(gen7_0_0_dpm_registers), 8)); 916: 917: static struct gen7_reg_list gen7_0_0_reg_list[] = { 918: { gen7_0_0_gpu_registers, NULL }, 919: { gen7_0_0_dpm_registers, NULL }, 920: { NULL, NULL }, 921: }; 922: 923: static const u32 *gen7_0_0_external_core_regs[] = { 924: gen7_0_0_gpucc_registers, 925: gen7_0_0_cpr_registers, 926: }; 927: #endif /*_ADRENO_GEN7_0_0_SNAPSHOT_H */ --- FILE: \adreno_gen7_11_0_snapshot.h | HITS: 3 --- MATCH LINES: 5, 6, 8 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 4: */ 5: #ifndef __ADRENO_GEN7_11_0_SNAPSHOT_H 6: #define __ADRENO_GEN7_11_0_SNAPSHOT_H 7: 8: #include "adreno_gen7_snapshot.h" 9: 10: static const u32 gen7_11_0_debugbus_blocks[] = { 11: DEBUGBUS_CP_0_0, 12: DEBUGBUS_CP_0_1, 13: DEBUGBUS_RBBM, 14: DEBUGBUS_HLSQ, 15: DEBUGBUS_UCHE_0, 16: DEBUGBUS_TESS_BR, 17: DEBUGBUS_TESS_BV, 18: DEBUGBUS_PC_BR, 19: DEBUGBUS_PC_BV, 20: DEBUGBUS_VFDP_BR, 21: DEBUGBUS_VFDP_BV, 22: DEBUGBUS_VPC_BR, 23: DEBUGBUS_VPC_BV, 24: DEBUGBUS_TSE_BR, 25: DEBUGBUS_TSE_BV, 26: DEBUGBUS_RAS_BR, 27: DEBUGBUS_RAS_BV, 28: DEBUGBUS_VSC, 29: DEBUGBUS_COM_0, 30: DEBUGBUS_LRZ_BR, 31: DEBUGBUS_LRZ_BV, 32: DEBUGBUS_UFC_0, --- FILE: \adreno_gen7_14_0_snapshot.h | HITS: 4 --- MATCH LINES: 5, 6, 8 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 4: */ 5: #ifndef __ADRENO_GEN7_14_0_SNAPSHOT_H 6: #define __ADRENO_GEN7_14_0_SNAPSHOT_H 7: 8: #include "adreno_gen7_snapshot.h" 9: 10: static const u32 gen7_14_0_debugbus_blocks[] = { 11: DEBUGBUS_CP_0_0, 12: DEBUGBUS_CP_0_1, 13: DEBUGBUS_RBBM, 14: DEBUGBUS_HLSQ, 15: DEBUGBUS_UCHE_0, 16: DEBUGBUS_TESS_BR, 17: DEBUGBUS_PC_BR, 18: DEBUGBUS_VFDP_BR, 19: DEBUGBUS_VPC_BR, 20: DEBUGBUS_TSE_BR, 21: DEBUGBUS_RAS_BR, 22: DEBUGBUS_VSC, 23: DEBUGBUS_COM_0, 24: DEBUGBUS_LRZ_BR, 25: DEBUGBUS_UFC_0, 26: DEBUGBUS_UFC_1, 27: DEBUGBUS_GMU_GX, 28: DEBUGBUS_DBGC, 29: DEBUGBUS_GPC_BR, 30: DEBUGBUS_LARC, 31: DEBUGBUS_HLSQ_SPTP, 32: DEBUGBUS_RB_0, MATCH LINES: 461 449: 450: static struct gen7_cp_indexed_reg gen7_14_0_cp_indexed_reg_list[] = { 451: { GEN7_CP_SQE_STAT_ADDR, GEN7_CP_SQE_STAT_DATA, 0x40}, 452: { GEN7_CP_DRAW_STATE_ADDR, GEN7_CP_DRAW_STATE_DATA, 0x100}, 453: { GEN7_CP_ROQ_DBG_ADDR, GEN7_CP_ROQ_DBG_DATA, 0x800}, 454: { GEN7_CP_SQE_UCODE_DBG_ADDR, GEN7_CP_SQE_UCODE_DBG_DATA, 0x8000}, 455: }; 456: 457: static const u32 *gen7_14_0_external_core_regs[] = { 458: gen7_14_0_gpucc_registers, 459: gen7_14_0_cpr_registers, 460: }; 461: #endif /*_ADRENO_GEN7_14_0_SNAPSHOT_H */ --- FILE: \adreno_gen7_15_0_snapshot.h | HITS: 4 --- MATCH LINES: 5, 6, 8 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 4: */ 5: #ifndef __ADRENO_GEN7_15_0_SNAPSHOT_H 6: #define __ADRENO_GEN7_15_0_SNAPSHOT_H 7: 8: #include "adreno_gen7_11_0_snapshot.h" 9: 10: /* 11: * Block : ['CPR'] 12: * Pipeline: PIPE_NONE 13: * pairs : 20 (Regs:448) 14: */ 15: static const u32 gen7_15_0_cpr_registers[] = { 16: 0x26800, 0x26805, 0x26808, 0x2680c, 0x26814, 0x26814, 0x2681c, 0x2681c, 17: 0x26820, 0x26838, 0x26840, 0x26840, 0x26848, 0x26848, 0x26850, 0x26850, 18: 0x26880, 0x26897, 0x26980, 0x269b0, 0x269c0, 0x269c8, 0x269e0, 0x269ee, 19: 0x269fb, 0x269ff, 0x26a02, 0x26a07, 0x26a09, 0x26a0b, 0x26a10, 0x26b0f, 20: 0x27440, 0x27441, 0x27444, 0x27444, 0x27480, 0x274a2, 0x274ac, 0x274ad, 21: UINT_MAX, UINT_MAX, 22: }; 23: static_assert(IS_ALIGNED(sizeof(gen7_15_0_cpr_registers), 8)); 24: 25: /* 26: * Block : ['GPU_CC_ACD_ACD'] 27: * Pipeline: PIPE_NONE 28: * pairs : 10 (Regs:53) 29: */ 30: static const u32 gen7_15_0_gpu_cc_acd_acd_registers[] = { 31: 0x26600, 0x26616, 0x26620, 0x2662d, 0x26630, 0x26631, 0x26635, 0x26635, 32: 0x26637, 0x26637, 0x2663a, 0x2663a, 0x26642, 0x26642, 0x26656, 0x26658, MATCH LINES: 108 96: static_assert(IS_ALIGNED(sizeof(gen7_15_0_gpu_cc_pll1_cm_pll_lucid_ole_registers), 8)); 97: 98: static const u32 *gen7_15_0_external_core_regs[] = { 99: gen7_15_0_gpu_cc_acd_acd_registers, 100: gen7_15_0_gpu_cc_ahb2phy_broadcast_swman_registers, 101: gen7_15_0_gpu_cc_ahb2phy_swman_registers, 102: gen7_15_0_gpu_cc_gpu_cc_reg_registers, 103: gen7_15_0_gpu_cc_pll0_cm_pll_lucid_ole_registers, 104: gen7_15_0_gpu_cc_pll1_cm_pll_lucid_ole_registers, 105: gen7_15_0_cpr_registers, 106: gen7_11_0_dpm_lkg_registers, 107: }; 108: #endif /*_ADRENO_GEN7_15_0_SNAPSHOT_H */ --- FILE: \adreno_gen7_17_0_snapshot.h | HITS: 4 --- MATCH LINES: 5, 6, 8 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 4: */ 5: #ifndef __ADRENO_GEN7_17_0_SNAPSHOT_H 6: #define __ADRENO_GEN7_17_0_SNAPSHOT_H 7: 8: #include "adreno_gen7_snapshot.h" 9: 10: /* 11: * Block : ['RSCC_RSC'] 12: * REGION : UNSLICE 13: * Pipeline: PIPE_NONE 14: * pairs : 101 (Regs:606) 15: */ 16: static const u32 gen7_17_0_rscc_registers[] = { 17: 0x14000, 0x14034, 0x14036, 0x14036, 0x14040, 0x14042, 0x14044, 0x14045, 18: 0x14047, 0x14047, 0x14080, 0x14084, 0x14089, 0x1408c, 0x14091, 0x14094, 19: 0x14099, 0x1409c, 0x140a1, 0x140a4, 0x140a9, 0x140ac, 0x140b1, 0x140b4, 20: 0x140b9, 0x140bc, 0x14100, 0x14104, 0x14114, 0x14119, 0x14124, 0x14132, 21: 0x14154, 0x1416b, 0x14340, 0x14341, 0x14344, 0x14344, 0x14346, 0x1437c, 22: 0x143f0, 0x143f8, 0x143fa, 0x143fe, 0x14400, 0x14404, 0x14406, 0x1440a, 23: 0x1440c, 0x14410, 0x14412, 0x14416, 0x14418, 0x1441c, 0x1441e, 0x14422, 24: 0x14424, 0x14424, 0x14498, 0x144a0, 0x144a2, 0x144a6, 0x144a8, 0x144ac, 25: 0x144ae, 0x144b2, 0x144b4, 0x144b8, 0x144ba, 0x144be, 0x144c0, 0x144c4, 26: 0x144c6, 0x144ca, 0x144cc, 0x144cc, 0x14540, 0x14548, 0x1454a, 0x1454e, 27: 0x14550, 0x14554, 0x14556, 0x1455a, 0x1455c, 0x14560, 0x14562, 0x14566, 28: 0x14568, 0x1456c, 0x1456e, 0x14572, 0x14574, 0x14574, 0x145e8, 0x145f0, 29: 0x145f2, 0x145f6, 0x145f8, 0x145fc, 0x145fe, 0x14602, 0x14604, 0x14608, 30: 0x1460a, 0x1460e, 0x14610, 0x14614, 0x14616, 0x1461a, 0x1461c, 0x1461c, 31: 0x14690, 0x14698, 0x1469a, 0x1469e, 0x146a0, 0x146a4, 0x146a6, 0x146aa, 32: 0x146ac, 0x146b0, 0x146b2, 0x146b6, 0x146b8, 0x146bc, 0x146be, 0x146c2, MATCH LINES: 91 79: 0x26540, 0x2654e, 0x26554, 0x26573, 0x26576, 0x26576, 0x26593, 0x26593, 80: 0x26600, 0x26616, 0x26620, 0x2662d, 0x26630, 0x26631, 0x26635, 0x26635, 81: 0x26637, 0x26637, 0x2663a, 0x2663a, 0x26642, 0x26642, 0x26656, 0x26658, 82: 0x2665b, 0x2665d, 0x2665f, 0x26662, 83: UINT_MAX, UINT_MAX, 84: }; 85: static_assert(IS_ALIGNED(sizeof(gen7_17_0_gpucc_registers), 8)); 86: 87: static const u32 *gen7_17_0_external_core_regs[] = { 88: gen7_17_0_gpucc_registers, 89: gen7_17_0_cpr_registers, 90: }; 91: #endif /*_ADRENO_GEN7_17_0_SNAPSHOT_H */ --- FILE: \adreno_gen7_2_0_snapshot.h | HITS: 4 --- MATCH LINES: 6, 7, 9 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. 5: */ 6: #ifndef __ADRENO_GEN7_2_0_SNAPSHOT_H 7: #define __ADRENO_GEN7_2_0_SNAPSHOT_H 8: 9: #include "adreno_gen7_snapshot.h" 10: 11: static const u32 gen7_2_0_debugbus_blocks[] = { 12: DEBUGBUS_CP_0_0, 13: DEBUGBUS_CP_0_1, 14: DEBUGBUS_RBBM, 15: DEBUGBUS_HLSQ, 16: DEBUGBUS_UCHE_0, 17: DEBUGBUS_UCHE_1, 18: DEBUGBUS_TESS_BR, 19: DEBUGBUS_TESS_BV, 20: DEBUGBUS_PC_BR, 21: DEBUGBUS_PC_BV, 22: DEBUGBUS_VFDP_BR, 23: DEBUGBUS_VFDP_BV, 24: DEBUGBUS_VPC_BR, 25: DEBUGBUS_VPC_BV, 26: DEBUGBUS_TSE_BR, 27: DEBUGBUS_TSE_BV, 28: DEBUGBUS_RAS_BR, 29: DEBUGBUS_RAS_BV, 30: DEBUGBUS_VSC, 31: DEBUGBUS_COM_0, 32: DEBUGBUS_LRZ_BR, 33: DEBUGBUS_LRZ_BV, MATCH LINES: 752 740: static struct gen7_reg_list gen7_2_0_reg_list[] = { 741: { gen7_2_0_gpu_registers, NULL }, 742: { gen7_2_0_dpm_registers, NULL }, 743: { gen7_2_0_dbgc_registers, NULL }, 744: { NULL, NULL }, 745: }; 746: 747: static const u32 *gen7_2_0_external_core_regs[] = { 748: gen7_2_0_gpucc_registers, 749: gen7_2_0_cpr_registers, 750: gen7_2_0_dpm_lkg_registers, 751: }; 752: #endif /*_ADRENO_GEN7_2_0_SNAPSHOT_H */ --- FILE: \adreno_gen7_3_0_snapshot.h | HITS: 5 --- MATCH LINES: 6, 7, 9, 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: #ifndef __ADRENO_GEN7_3_0_SNAPSHOT_H 7: #define __ADRENO_GEN7_3_0_SNAPSHOT_H 8: 9: #include "adreno_gen7_snapshot.h" 10: #include "adreno_gen7_0_0_snapshot.h" 11: 12: static const u32 gen7_3_0_debugbus_blocks[] = { 13: DEBUGBUS_CP_0_0, 14: DEBUGBUS_CP_0_1, 15: DEBUGBUS_RBBM, 16: DEBUGBUS_HLSQ, 17: DEBUGBUS_UCHE_0, 18: DEBUGBUS_TESS_BR, 19: DEBUGBUS_PC_BR, 20: DEBUGBUS_VFDP_BR, 21: DEBUGBUS_VPC_BR, 22: DEBUGBUS_TSE_BR, 23: DEBUGBUS_RAS_BR, 24: DEBUGBUS_VSC, 25: DEBUGBUS_COM_0, 26: DEBUGBUS_LRZ_BR, 27: DEBUGBUS_UFC_0, 28: DEBUGBUS_UFC_1, 29: DEBUGBUS_GMU_GX, 30: DEBUGBUS_DBGC, 31: DEBUGBUS_GPC_BR, 32: DEBUGBUS_LARC, 33: DEBUGBUS_HLSQ_SPTP, 34: DEBUGBUS_RB_0, MATCH LINES: 342 330: 331: static const u32 *gen7_3_0_external_core_regs[] = { 332: gen7_0_0_gpucc_registers, 333: gen7_3_0_cpr_registers, 334: }; 335: 336: static struct gen7_cp_indexed_reg gen7_3_0_cp_indexed_reg_list[] = { 337: { GEN7_CP_SQE_STAT_ADDR, GEN7_CP_SQE_STAT_DATA, 0x33}, 338: { GEN7_CP_DRAW_STATE_ADDR, GEN7_CP_DRAW_STATE_DATA, 0x100}, 339: { GEN7_CP_SQE_UCODE_DBG_ADDR, GEN7_CP_SQE_UCODE_DBG_DATA, 0x8000}, 340: }; 341: 342: #endif /*_ADRENO_GEN7_3_0_SNAPSHOT_H */ --- FILE: \adreno_gen7_5_0_snapshot.h | HITS: 5 --- MATCH LINES: 5, 6, 8, 9 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 4: */ 5: #ifndef __ADRENO_GEN7_5_0_SNAPSHOT_H 6: #define __ADRENO_GEN7_5_0_SNAPSHOT_H 7: 8: #include "adreno_gen7_15_0_snapshot.h" 9: #include "adreno_gen7_2_0_snapshot.h" 10: 11: static const u32 gen7_5_0_gmu_registers[] = { 12: 0x1a803, 0x1a803, 0x1a805, 0x1a806, 0x1a84e, 0x1a84e, 0x1a856, 0x1a856, 13: 0x1f400, 0x1f40d, 0x1f40f, 0x1f411, 0x1f500, 0x1f500, 0x1f507, 0x1f507, 14: 0x1f509, 0x1f50b, 0x1f700, 0x1f701, 0x1f704, 0x1f706, 0x1f708, 0x1f709, 15: 0x1f70c, 0x1f70d, 0x1f710, 0x1f711, 0x1f713, 0x1f716, 0x1f720, 0x1f724, 16: 0x1f729, 0x1f729, 0x1f730, 0x1f747, 0x1f760, 0x1f761, 0x1f764, 0x1f76b, 17: 0x1f800, 0x1f804, 0x1f807, 0x1f808, 0x1f80b, 0x1f80c, 0x1f80f, 0x1f80f, 18: 0x1f811, 0x1f811, 0x1f813, 0x1f817, 0x1f819, 0x1f81c, 0x1f824, 0x1f82a, 19: 0x1f82d, 0x1f830, 0x1f840, 0x1f853, 0x1f860, 0x1f860, 0x1f862, 0x1f864, 20: 0x1f868, 0x1f868, 0x1f870, 0x1f879, 0x1f87f, 0x1f87f, 0x1f888, 0x1f889, 21: 0x1f8a0, 0x1f8a2, 0x1f890, 0x1f892, 0x1f894, 0x1f896, 0x1f8a4, 0x1f8af, 22: 0x1f8b8, 0x1f8b9, 0x1f8c0, 0x1f8c1, 0x1f8c3, 0x1f8c4, 0x1f8d0, 0x1f8d0, 23: 0x1f8ec, 0x1f8ec, 0x1f8f0, 0x1f8f1, 0x1f910, 0x1f917, 0x1f920, 0x1f921, 24: 0x1f924, 0x1f925, 0x1f928, 0x1f929, 0x1f92c, 0x1f92d, 0x1f940, 0x1f940, 25: 0x1f942, 0x1f944, 0x1f948, 0x1f94a, 0x1f94f, 0x1f951, 0x1f954, 0x1f955, 26: 0x1f958, 0x1f95a, 0x1f95d, 0x1f95d, 0x1f962, 0x1f96b, 0x1f970, 0x1f979, 27: 0x1f97c, 0x1f97c, 0x1f980, 0x1f981, 0x1f984, 0x1f986, 0x1f992, 0x1f993, 28: 0x1f996, 0x1f99e, 0x1f9c0, 0x1f9c0, 0x1f9c5, 0x1f9d4, 0x1f9f0, 0x1f9f1, 29: 0x1f9f8, 0x1f9fa, 0x1f9fc, 0x1f9fc, 0x1fa00, 0x1fa03, 0x20000, 0x20012, 30: 0x20018, 0x20018, 0x2001a, 0x2001a, 0x20020, 0x20024, 0x20030, 0x20031, 31: 0x20034, 0x20036, 0x23801, 0x23801, 0x23803, 0x23803, 0x23805, 0x23805, 32: 0x23807, 0x23807, 0x23809, 0x23809, 0x2380b, 0x2380b, 0x2380d, 0x2380d, 33: 0x2380f, 0x2380f, 0x23811, 0x23811, 0x23813, 0x23813, 0x23815, 0x23815, MATCH LINES: 131 119: static_assert(IS_ALIGNED(sizeof(gen7_5_0_gpu_cc_pll0_cm_pll_zonda_ole_registers), 8)); 120: 121: static const u32 *gen7_5_0_external_core_regs[] = { 122: gen7_15_0_gpu_cc_acd_acd_registers, 123: gen7_15_0_gpu_cc_ahb2phy_broadcast_swman_registers, 124: gen7_15_0_gpu_cc_ahb2phy_swman_registers, 125: gen7_5_0_gpu_cc_gpu_cc_reg_registers, 126: gen7_5_0_gpu_cc_pll0_cm_pll_zonda_ole_registers, 127: gen7_15_0_gpu_cc_pll1_cm_pll_lucid_ole_registers, 128: gen7_5_0_cpr_registers, 129: gen7_2_0_dpm_lkg_registers, 130: }; 131: #endif /*_ADRENO_GEN7_5_0_SNAPSHOT_H */ --- FILE: \adreno_gen7_6_0_snapshot.h | HITS: 4 --- MATCH LINES: 5, 6, 8, 46 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 4: */ 5: #ifndef __ADRENO_GEN7_6_0_SNAPSHOT_H 6: #define __ADRENO_GEN7_6_0_SNAPSHOT_H 7: 8: #include "adreno_gen7_snapshot.h" 9: 10: static const u32 gen7_6_0_gpucc_registers[] = { 11: 0x24000, 0x2400f, 0x24400, 0x2440f, 0x24800, 0x24805, 0x24c00, 0x24cff, 12: 0x25400, 0x25404, 0x25800, 0x25804, 0x25c00, 0x25c04, 0x26000, 0x26004, 13: 0x26400, 0x26405, 0x26414, 0x2641d, 0x2642a, 0x26430, 0x26432, 0x26432, 14: 0x26441, 0x2644b, 0x2644d, 0x26455, 0x26466, 0x26468, 0x26478, 0x2647a, 15: 0x26489, 0x2648a, 0x2649c, 0x2649e, 0x264a0, 0x264a3, 0x264c5, 0x264c7, 16: 0x264d6, 0x264d8, 0x264e8, 0x264e9, 0x264f9, 0x264fc, 0x2651c, 0x2651e, 17: 0x26540, 0x26573, 0x26576, 0x26576, 0x26600, 0x26616, 0x26620, 0x2662d, 18: 0x26630, 0x26631, 0x26635, 0x26635, 0x26637, 0x26637, 0x2663a, 0x2663a, 19: 0x26642, 0x26642, 0x26656, 0x26658, 0x2665b, 0x2665d, 0x2665f, 0x26662, 20: UINT_MAX, UINT_MAX, 21: }; 22: static_assert(IS_ALIGNED(sizeof(gen7_6_0_gpucc_registers), 8)); 23: 24: static const u32 gen7_6_0_cpr_registers[] = { 25: 0x26800, 0x26805, 0x26808, 0x2680c, 0x26814, 0x26814, 0x2681c, 0x2681c, 26: 0x26820, 0x26838, 0x26840, 0x26840, 0x26848, 0x26848, 0x26850, 0x26850, 27: 0x26880, 0x2689e, 0x26980, 0x269b0, 0x269c0, 0x269c8, 0x269e0, 0x269ee, 28: 0x269fb, 0x269ff, 0x26a02, 0x26a07, 0x26a09, 0x26a0b, 0x26a10, 0x26b0f, 29: 0x27440, 0x27441, 0x27444, 0x27444, 0x27480, 0x274a2, 0x274ac, 0x274ac, 30: UINT_MAX, UINT_MAX, 31: }; 32: static_assert(IS_ALIGNED(sizeof(gen7_6_0_cpr_registers), 8)); 33: 34: static const u32 gen7_6_0_dpm_lkg_registers[] = { 35: 0x21c00, 0x21c00, 0x21c08, 0x21c09, 0x21c0e, 0x21c0f, 0x21c4f, 0x21c50, 36: 0x21c52, 0x21c52, 0x21c54, 0x21c56, 0x21c58, 0x21c5a, 0x21c5c, 0x21c60, 37: UINT_MAX, UINT_MAX, 38: }; 39: static_assert(IS_ALIGNED(sizeof(gen7_6_0_dpm_lkg_registers), 8)); 40: 41: static const u32 *gen7_6_0_external_core_regs[] = { 42: gen7_6_0_gpucc_registers, 43: gen7_6_0_cpr_registers, 44: gen7_6_0_dpm_lkg_registers, 45: }; 46: #endif /*_ADRENO_GEN7_6_0_SNAPSHOT_H */ --- FILE: \adreno_gen7_9_0_snapshot.h | HITS: 4 --- MATCH LINES: 6, 7, 9 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_GEN7_9_0_SNAPSHOT_H 7: #define __ADRENO_GEN7_9_0_SNAPSHOT_H 8: 9: #include "adreno_gen7_snapshot.h" 10: 11: static const u32 gen7_9_0_debugbus_blocks[] = { 12: DEBUGBUS_CP_0_0, 13: DEBUGBUS_CP_0_1, 14: DEBUGBUS_RBBM, 15: DEBUGBUS_HLSQ, 16: DEBUGBUS_UCHE_0, 17: DEBUGBUS_UCHE_1, 18: DEBUGBUS_TESS_BR, 19: DEBUGBUS_TESS_BV, 20: DEBUGBUS_PC_BR, 21: DEBUGBUS_PC_BV, 22: DEBUGBUS_VFDP_BR, 23: DEBUGBUS_VFDP_BV, 24: DEBUGBUS_VPC_BR, 25: DEBUGBUS_VPC_BV, 26: DEBUGBUS_TSE_BR, 27: DEBUGBUS_TSE_BV, 28: DEBUGBUS_RAS_BR, 29: DEBUGBUS_RAS_BV, 30: DEBUGBUS_VSC, 31: DEBUGBUS_COM_0, 32: DEBUGBUS_LRZ_BR, 33: DEBUGBUS_LRZ_BV, MATCH LINES: 1409 1397: UINT_MAX, UINT_MAX, 1398: }; 1399: static_assert(IS_ALIGNED(sizeof(gen7_9_0_rscc_registers), 8)); 1400: 1401: static const u32 *gen7_9_0_external_core_regs[] = { 1402: gen7_9_0_gpucc_registers, 1403: gen7_9_0_gxclkctl_registers, 1404: gen7_9_0_cpr_registers, 1405: gen7_9_0_dpm_registers, 1406: gen7_9_0_dpm_leakage_registers, 1407: gen7_9_0_gfx_gpu_acd_registers, 1408: }; 1409: #endif /*_ADRENO_GEN7_9_0_SNAPSHOT_H */ --- FILE: \adreno_gen7_gmu.c | HITS: 56 --- MATCH LINES: 368, 372, 373, 381, 382, 402 356: 357: ticks = gpudev->read_alwayson(adreno_dev); 358: 359: trace_gmu_ao_sync(ticks); 360: 361: local_irq_restore(flags); 362: } 363: 364: int gen7_gmu_device_start(struct adreno_device *adreno_dev) 365: { 366: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 367: 368: gmu_core_reset_trace_header(&device->gmu_core.trace); 369: 370: gmu_ao_sync_event(adreno_dev); 371: 372: /* Bring GMU out of reset */ 373: gmu_core_regwrite(device, GEN7_GMU_CM3_SYSRESET, 0); 374: 375: /* Make sure the write is posted before moving ahead */ 376: wmb(); 377: 378: if (gmu_core_timed_poll_check(device, GEN7_GMU_CM3_FW_INIT_RESULT, 379: BIT(8), 100, GENMASK(8, 0))) { 380: dev_err(GMU_PDEV_DEV(device), 381: "GMU failed to come out of reset\n"); 382: gmu_core_fault_snapshot(device, GMU_FAULT_DEVICE_START); 383: return -ETIMEDOUT; 384: } 385: 386: return 0; 387: } 388: 389: /* 390: * gen7_gmu_hfi_start() - Write registers and start HFI. 391: * @device: Pointer to KGSL device 392: */ 393: int gen7_gmu_hfi_start(struct adreno_device *adreno_dev) 394: { 395: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 396: 397: gmu_core_regwrite(device, GEN7_GMU_HFI_CTRL_INIT, 1); 398: 399: if (gmu_core_timed_poll_check(device, GEN7_GMU_HFI_CTRL_STATUS, 400: BIT(0), 100, BIT(0))) { 401: dev_err(GMU_PDEV_DEV(device), "GMU HFI init failed\n"); 402: gmu_core_fault_snapshot(device, GMU_FAULT_HFI_INIT); 403: return -ETIMEDOUT; 404: } 405: 406: return 0; 407: } 408: 409: int gen7_rscc_wakeup_sequence(struct adreno_device *adreno_dev) 410: { 411: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 412: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 413: 414: /* Skip wakeup sequence if we didn't do the sleep sequence */ 415: if (!test_bit(GMU_PRIV_RSCC_SLEEP_DONE, &gmu->flags)) 416: return 0; 417: 418: /* RSC wake sequence */ 419: gmu_core_regwrite(device, GEN7_GMU_RSCC_CONTROL_REQ, BIT(1)); 420: 421: /* Write request before polling */ 422: wmb(); 423: 424: if (gmu_core_timed_poll_check(device, GEN7_GMU_RSCC_CONTROL_ACK, 425: BIT(1), 100, BIT(1))) { 426: dev_err(GMU_PDEV_DEV(device), "Failed to do GPU RSC power on\n"); MATCH LINES: 456, 457 444: int gen7_rscc_sleep_sequence(struct adreno_device *adreno_dev) 445: { 446: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 447: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 448: int ret; 449: 450: if (!test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags)) 451: return 0; 452: 453: if (test_bit(GMU_PRIV_RSCC_SLEEP_DONE, &gmu->flags)) 454: return 0; 455: 456: gmu_core_regwrite(device, GEN7_GMU_CM3_SYSRESET, 1); 457: /* Make sure M3 is in reset before going on */ 458: wmb(); 459: 460: gmu_core_regread(device, GEN7_GMU_GENERAL_9, &gmu->log_wptr_retention); 461: 462: gmu_core_regwrite(device, GEN7_GMU_RSCC_CONTROL_REQ, BIT(0)); 463: /* Make sure the request completes before continuing */ 464: wmb(); 465: 466: ret = gen7_timed_poll_check_rscc(gmu, GEN7_GPU_RSCC_RSC_STATUS0_DRV0, 467: BIT(16), 100, BIT(16)); 468: if (ret) { 469: dev_err(GMU_PDEV_DEV(device), "GPU RSC power off fail\n"); 470: return -ETIMEDOUT; 471: } 472: 473: gmu_core_regwrite(device, GEN7_GMU_RSCC_CONTROL_REQ, 0); 474: 475: set_bit(GMU_PRIV_RSCC_SLEEP_DONE, &gmu->flags); 476: 477: return 0; 478: } 479: 480: static void load_tcm(struct adreno_device *adreno_dev, const u8 *src, 481: u32 tcm_start, u32 base, const struct gmu_block_header *blk) MATCH LINES: 566, 570, 576, 608, 609 554: return "oob_gpu"; 555: case oob_perfcntr: 556: return "oob_perfcntr"; 557: case oob_boot_slumber: 558: return "oob_boot_slumber"; 559: case oob_dcvs: 560: return "oob_dcvs"; 561: default: 562: return "unknown"; 563: } 564: } 565: 566: static void trigger_reset_recovery(struct adreno_device *adreno_dev, 567: enum oob_request req) 568: { 569: /* 570: * Trigger recovery for perfcounter oob only since only 571: * perfcounter oob can happen alongside an actively rendering gpu. 572: */ 573: if (req != oob_perfcntr) 574: return; 575: 576: adreno_scheduler_fault(adreno_dev, ADRENO_GMU_FAULT_SKIP_SNAPSHOT); 577: } 578: 579: int gen7_gmu_oob_set(struct kgsl_device *device, 580: enum oob_request req) 581: { 582: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 583: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 584: int ret = 0; 585: int set, check; 586: 587: if (req == oob_perfcntr && gmu->num_oob_perfcntr++) 588: return 0; 589: 590: if (req >= oob_boot_slumber) { 591: dev_err(GMU_PDEV_DEV(device), 592: "Unsupported OOB request %s\n", 593: oob_to_str(req)); 594: return -EINVAL; 595: } 596: 597: set = BIT(30 - req * 2); 598: check = BIT(31 - req); 599: 600: gmu_core_regwrite(device, GEN7_GMU_HOST2GMU_INTR_SET, set); 601: 602: if (gmu_core_timed_poll_check(device, GEN7_GMU_GMU2HOST_INTR_INFO, check, 603: 100, check)) { 604: if (req == oob_perfcntr) 605: gmu->num_oob_perfcntr--; 606: ret = -ETIMEDOUT; 607: WARN(1, "OOB request %s timed out\n", oob_to_str(req)); 608: gmu_core_fault_snapshot(device, GMU_FAULT_OOB_SET); 609: trigger_reset_recovery(adreno_dev, req); 610: } 611: 612: gmu_core_regwrite(device, GEN7_GMU_GMU2HOST_INTR_CLR, check); 613: 614: trace_kgsl_gmu_oob_set(set); 615: return ret; 616: } 617: 618: void gen7_gmu_oob_clear(struct kgsl_device *device, 619: enum oob_request req) 620: { 621: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 622: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 623: int clear = BIT(31 - req * 2); 624: 625: if (req == oob_perfcntr && --gmu->num_oob_perfcntr) 626: return; 627: 628: if (req >= oob_boot_slumber) { 629: dev_err(GMU_PDEV_DEV(device), "Unsupported OOB clear %s\n", 630: oob_to_str(req)); 631: return; 632: } 633: MATCH LINES: 845, 867 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; 856: u64 ts1; 857: 858: ts1 = gpudev->read_alwayson(adreno_dev); 859: if (gmu_core_timed_poll_check(device, GEN7_GPU_GMU_AO_GPU_CX_BUSY_STATUS, 860: 0, 100, CXGXCPUBUSYIGNAHB)) { 861: gmu_core_regread(device, 862: GEN7_GPU_GMU_AO_GPU_CX_BUSY_STATUS2, &status2); 863: dev_err(GMU_PDEV_DEV(device), 864: "GMU not idling: status2=0x%x %llx %llx\n", 865: status2, ts1, 866: gpudev->read_alwayson(adreno_dev)); 867: gmu_core_fault_snapshot(device, GMU_FAULT_WAIT_FOR_IDLE); 868: return -ETIMEDOUT; 869: } 870: 871: return 0; 872: } 873: 874: int gen7_gmu_version_info(struct adreno_device *adreno_dev) 875: { 876: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 877: struct gmu_core_device *gmu = &device->gmu_core; 878: const struct adreno_gen7_core *gen7_core = to_gen7_core(adreno_dev); 879: 880: /* GMU version info is at a fixed offset in the DTCM */ 881: gmu_core_regread(device, GEN7_GMU_CM3_DTCM_START + 0xff8, 882: &gmu->ver.core); 883: gmu_core_regread(device, GEN7_GMU_CM3_DTCM_START + 0xff9, 884: &gmu->ver.core_dev); 885: gmu_core_regread(device, GEN7_GMU_CM3_DTCM_START + 0xffa, 886: &gmu->ver.pwr); 887: gmu_core_regread(device, GEN7_GMU_CM3_DTCM_START + 0xffb, 888: &gmu->ver.pwr_dev); 889: gmu_core_regread(device, GEN7_GMU_CM3_DTCM_START + 0xffc, 890: &gmu->ver.hfi); 891: MATCH LINES: 951, 969, 970, 997 939: gmu_core_regwrite(device, GEN7_GMU_CM3_FW_INIT_RESULT, 0); 940: gmu_core_regwrite(device, GEN7_GMU_CM3_BOOT_CONFIG, 0x2); 941: 942: gmu_core_regwrite(device, GEN7_GMU_HFI_QTBL_ADDR, 943: gmu->hfi.hfi_mem->gmuaddr); 944: gmu_core_regwrite(device, GEN7_GMU_HFI_QTBL_INFO, 1); 945: 946: gmu_core_regwrite(device, GEN7_GMU_AHB_FENCE_RANGE_0, BIT(31) | 947: FIELD_PREP(GENMASK(30, 18), 0x32) | 948: FIELD_PREP(GENMASK(17, 0), GEN7_CP_CONTEXT_SWITCH_CNTL)); 949: 950: /* 951: * Make sure that CM3 state is at reset value. Snapshot is changing 952: * NMI bit and if we boot up GMU with NMI bit set GMU will boot 953: * straight in to NMI handler without executing __main code 954: */ 955: gmu_core_regwrite(device, GEN7_GMU_CM3_CFG, 0x4052); 956: 957: /* Set up GBIF registers from the GPU core definition */ 958: kgsl_regmap_multi_write(&device->regmap, gen7_core->gbif, 959: gen7_core->gbif_count); 960: 961: if (adreno_is_gen7_13_0(adreno_dev) || adreno_is_gen7_9_x(adreno_dev)) 962: kgsl_regrmw(device, GEN7_GBIF_CX_CONFIG, GENMASK(31, 29), 963: FIELD_PREP(GENMASK(31, 29), 1)); 964: else if (adreno_is_gen7_14_0_family(adreno_dev)) 965: kgsl_regrmw(device, GEN7_GBIF_CX_CONFIG, GENMASK(31, 29), 966: FIELD_PREP(GENMASK(31, 29), 2)); 967: 968: /** 969: * We may have asserted gbif halt as part of reset sequence which may 970: * not get cleared if the gdsc was not reset. So clear it before 971: * attempting GMU boot. 972: */ 973: kgsl_regwrite(device, GEN7_GBIF_HALT, 0x0); 974: 975: /* Set vrb address before starting GMU */ 976: if (!IS_ERR_OR_NULL(device->gmu_core.vrb)) 977: gmu_core_regwrite(device, GEN7_GMU_GENERAL_11, device->gmu_core.vrb->gmuaddr); 978: 979: /* Set the log wptr index */ 980: gmu_core_regwrite(device, GEN7_GMU_GENERAL_9, 981: gmu->log_wptr_retention); 982: 983: /* Pass chipid to GMU FW, must happen before starting GMU */ 984: if (gen7_core->gmu_chipid) 985: val = gen7_core->gmu_chipid; 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; MATCH LINES: 1124, 1128, 1134, 1163, 1166, 1180, 1183, 1187, 1192 1112: u32 ack; 1113: unsigned long t; 1114: 1115: kgsl_regwrite(device, reg, mask); 1116: 1117: t = jiffies + msecs_to_jiffies(100); 1118: do { 1119: kgsl_regread(device, ack_reg, &ack); 1120: if ((ack & mask) == mask) 1121: return; 1122: 1123: /* 1124: * If we are attempting recovery in case of stall-on-fault 1125: * then the halt sequence will not complete as long as SMMU 1126: * is stalled. 1127: */ 1128: kgsl_mmu_pagefault_resume(&device->mmu, false); 1129: 1130: usleep_range(10, 100); 1131: } while (!time_after(jiffies, t)); 1132: 1133: /* Check one last time */ 1134: kgsl_mmu_pagefault_resume(&device->mmu, false); 1135: 1136: kgsl_regread(device, ack_reg, &ack); 1137: if ((ack & mask) == mask) 1138: return; 1139: 1140: dev_err(device->dev, "%s GBIF halt timed out\n", client); 1141: } 1142: 1143: static void gen7_gmu_pwrctrl_suspend(struct adreno_device *adreno_dev) 1144: { 1145: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1146: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1147: 1148: /* Disconnect GPU from BUS is not needed if CX GDSC goes off later */ 1149: 1150: /* 1151: * GEMNOC can enter power collapse state during GPU power down sequence. 1152: * This could abort CX GDSC collapse. Assert Qactive to avoid this. 1153: */ 1154: gmu_core_regwrite(device, GEN7_GPU_GMU_CX_GMU_CX_FALNEXT_INTF, 0x1); 1155: 1156: /* Check no outstanding RPMh voting */ 1157: gen7_complete_rpmh_votes(gmu, 1); 1158: 1159: /* Clear the WRITEDROPPED fields and set fence to allow mode */ 1160: gmu_core_regwrite(device, GEN7_GMU_AHB_FENCE_STATUS_CLR, 0x7); 1161: gmu_core_regwrite(device, GEN7_GMU_AO_AHB_FENCE_CTRL, 0); 1162: 1163: /* Make sure above writes are committed before we proceed to recovery */ 1164: wmb(); 1165: 1166: gmu_core_regwrite(device, GEN7_GMU_CM3_SYSRESET, 1); 1167: 1168: /* Halt GX traffic */ 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); 1209: 1210: if (gen7_gmu_gx_is_on(adreno_dev)) 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 MATCH LINES: 1259 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)) 1260: return; 1261: 1262: gen7_gmu_pwrctrl_suspend(adreno_dev); 1263: 1264: gmu_core_disable_clks(device); 1265: 1266: kgsl_pwrctrl_disable_cx_gdsc(device); 1267: 1268: gmu_core_rdpm_cx_freq_update(device, 0); 1269: 1270: dev_err(GMU_PDEV_DEV(device), "Suspended GMU\n"); 1271: 1272: kgsl_pwrctrl_set_state(device, KGSL_STATE_NONE); 1273: } 1274: 1275: static int gen7_gmu_dcvs_set(struct adreno_device *adreno_dev, 1276: int gpu_pwrlevel, int bus_level, u32 ab) 1277: { 1278: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1279: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1280: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1281: struct gen7_dcvs_table *table = &gmu->dcvs_table; 1282: struct hfi_gx_bw_perf_vote_cmd req = { 1283: .ack_type = DCVS_ACK_BLOCK, MATCH LINES: 1321, 1325 1309: ret = CMD_MSG_HDR(req, H2F_MSG_GX_BW_PERF_VOTE); 1310: if (ret) 1311: return ret; 1312: 1313: ret = gen7_hfi_send_generic_req(adreno_dev, &req, sizeof(req)); 1314: if (ret) { 1315: dev_err_ratelimited(GMU_PDEV_DEV(device), 1316: "Failed to set GPU perf idx %u, bw idx %u\n", 1317: req.freq, req.bw); 1318: 1319: /* 1320: * If this was a dcvs request along side an active gpu, request 1321: * dispatcher based reset and recovery. 1322: */ 1323: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 1324: adreno_scheduler_fault(adreno_dev, ADRENO_GMU_FAULT | 1325: ADRENO_GMU_FAULT_SKIP_SNAPSHOT); 1326: } 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) MATCH LINES: 1395, 1430, 1438, 1447, 1449, 1450, 1457 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; 1391: 1392: /* 1393: * We should not send NMI if there was a CM3 fault reported because we 1394: * don't want to overwrite the critical CM3 state captured by gmu before 1395: * it sent the CM3 fault interrupt. Also don't send NMI if GMU reset is 1396: * already active. We could have hit a GMU assert and NMI might have 1397: * already been triggered. 1398: */ 1399: 1400: /* make sure we're reading the latest cm3_fault */ 1401: smp_rmb(); 1402: 1403: if (atomic_read(&gmu->cm3_fault)) 1404: return; 1405: 1406: gmu_core_regread(device, GEN7_GMU_CM3_FW_INIT_RESULT, &result); 1407: 1408: if (result & 0xE00) 1409: return; 1410: 1411: nmi: 1412: /* Mask so there's no interrupt caused by NMI */ 1413: gmu_core_regwrite(device, GEN7_GMU_GMU2HOST_INTR_MASK, UINT_MAX); 1414: 1415: /* Make sure the interrupt is masked before causing it */ 1416: wmb(); 1417: 1418: /* This will cause the GMU to save it's internal state to ddr */ 1419: gmu_core_regrmw(device, GEN7_GMU_CM3_CFG, BIT(9), BIT(9)); 1420: 1421: /* Make sure the NMI is invoked before we proceed*/ 1422: wmb(); 1423: 1424: /* Wait for the NMI to be handled */ 1425: udelay(200); 1426: done: 1427: KGSL_GMU_CORE_FORCE_PANIC(device->gmu_core.gf_panic, GMU_PDEV(device), ticks, gf_policy); 1428: } 1429: 1430: static void gen7_gmu_cooperative_reset(struct kgsl_device *device) 1431: { 1432: unsigned int result; 1433: 1434: gmu_core_regwrite(device, GEN7_GMU_CX_GMU_WDOG_CTRL, 0); 1435: gmu_core_regwrite(device, GEN7_GMU_HOST2GMU_INTR_SET, BIT(17)); 1436: 1437: /* 1438: * After triggering graceful death wait for snapshot ready 1439: * indication from GMU. 1440: */ 1441: if (!gmu_core_timed_poll_check(device, GEN7_GMU_CM3_FW_INIT_RESULT, 1442: 0x800, 2, 0x800)) 1443: return; 1444: 1445: gmu_core_regread(device, GEN7_GMU_CM3_FW_INIT_RESULT, &result); 1446: dev_err(GMU_PDEV_DEV(device), 1447: "GMU cooperative reset timed out 0x%x\n", result); 1448: /* 1449: * If we dont get a snapshot ready from GMU, trigger NMI 1450: * and if we still timeout then we just continue with reset. 1451: */ 1452: gen7_gmu_send_nmi(device, true, GMU_FAULT_PANIC_NONE); 1453: 1454: gmu_core_regread(device, GEN7_GMU_CM3_FW_INIT_RESULT, &result); 1455: if ((result & 0x800) != 0x800) 1456: dev_err(GMU_PDEV_DEV(device), 1457: "GMU cooperative reset NMI timed out 0x%x\n", result); 1458: } 1459: 1460: static int gen7_gmu_wait_for_active_transition(struct kgsl_device *device) 1461: { 1462: unsigned int reg; 1463: 1464: if (gmu_core_timed_poll_check(device, GEN7_GPU_GMU_CX_GMU_RPMH_POWER_STATE, 1465: GPU_HW_ACTIVE, 100, GENMASK(3, 0))) { 1466: gmu_core_regread(device, GEN7_GPU_GMU_CX_GMU_RPMH_POWER_STATE, ®); 1467: dev_err(GMU_PDEV_DEV(device), 1468: "GMU failed to move to ACTIVE state, Current state: 0x%x\n", 1469: reg); 1470: 1471: return -ETIMEDOUT; 1472: } 1473: 1474: return 0; 1475: } 1476: 1477: static bool gen7_gmu_scales_bandwidth(struct kgsl_device *device) 1478: { 1479: return true; 1480: } 1481: MATCH LINES: 1648 1636: if (ret) 1637: goto clks_gdsc_off; 1638: 1639: gen7_gmu_register_config(adreno_dev); 1640: 1641: gen7_gmu_irq_enable(adreno_dev); 1642: 1643: /* Vote for minimal DDR BW for GMU to init */ 1644: level = pwr->pwrlevels[pwr->default_pwrlevel].bus_min; 1645: icc_set_bw(pwr->icc_path, 0, kBps_to_icc(pwr->ddr_table[level])); 1646: 1647: /* Clear any GPU faults that might have been left over */ 1648: adreno_clear_gpu_fault(adreno_dev); 1649: 1650: ret = gen7_gmu_device_start(adreno_dev); 1651: if (ret) 1652: goto err; 1653: 1654: if (!test_bit(GMU_PRIV_PDC_RSC_LOADED, &gmu->flags)) { 1655: ret = gen7_load_pdc_ucode(adreno_dev); 1656: if (ret) 1657: goto err; 1658: 1659: gen7_load_rsc_ucode(adreno_dev); 1660: set_bit(GMU_PRIV_PDC_RSC_LOADED, &gmu->flags); 1661: } 1662: 1663: ret = gen7_gmu_hfi_start(adreno_dev); 1664: if (ret) 1665: goto err; 1666: 1667: gen7_get_gpu_feature_info(adreno_dev); 1668: 1669: ret = gen7_hfi_start(adreno_dev); 1670: if (ret) 1671: goto err; 1672: MATCH LINES: 1748 1736: if (ret) 1737: goto clks_gdsc_off; 1738: 1739: ret = gen7_gmu_load_fw(adreno_dev); 1740: if (ret) 1741: goto clks_gdsc_off; 1742: 1743: gen7_gmu_register_config(adreno_dev); 1744: 1745: gen7_gmu_irq_enable(adreno_dev); 1746: 1747: /* Clear any GPU faults that might have been left over */ 1748: adreno_clear_gpu_fault(adreno_dev); 1749: 1750: ret = gen7_gmu_device_start(adreno_dev); 1751: if (ret) 1752: goto err; 1753: 1754: ret = gen7_gmu_hfi_start(adreno_dev); 1755: if (ret) 1756: goto err; 1757: 1758: ret = gen7_hfi_start(adreno_dev); 1759: if (ret) 1760: goto err; 1761: 1762: device->gmu_fault = false; 1763: 1764: kgsl_pwrctrl_set_state(device, KGSL_STATE_AWARE); 1765: 1766: return 0; 1767: 1768: err: 1769: gen7_gmu_irq_disable(adreno_dev); 1770: 1771: if (device->gmu_fault) { 1772: gen7_gmu_suspend(adreno_dev, false); MATCH LINES: 1870 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) 1894: buslevel = INVALID_DCVS_IDX; MATCH LINES: 2328, 2341, 2342, 2343, 2345, 2346, 2351 2316: 2317: gen7_start(adreno_dev); 2318: 2319: if (gen7_core->qos_value && adreno_is_preemption_enabled(adreno_dev)) 2320: kgsl_regwrite(device, GEN7_RBBM_GBIF_CLIENT_QOS_CNTL, 2321: gen7_core->qos_value[adreno_dev->cur_rb->id]); 2322: 2323: /* Re-initialize the coresight registers if applicable */ 2324: adreno_coresight_start(adreno_dev); 2325: 2326: adreno_perfcounter_start(adreno_dev); 2327: 2328: /* Clear FSR here in case it is set from a previous pagefault */ 2329: kgsl_mmu_clear_fsr(&device->mmu); 2330: 2331: gen7_enable_gpu_irq(adreno_dev); 2332: 2333: ret = gen7_rb_start(adreno_dev); 2334: if (ret) { 2335: gen7_disable_gpu_irq(adreno_dev); 2336: adreno_llcc_slice_deactivate(adreno_dev); 2337: goto oob_clear; 2338: } 2339: 2340: /* 2341: * At this point it is safe to assume that we recovered. Setting 2342: * this field allows us to take a new snapshot for the next failure 2343: * if we are prioritizing the first unrecoverable snapshot. 2344: */ 2345: if (device->snapshot) 2346: device->snapshot->recovered = true; 2347: 2348: /* Start the dispatcher */ 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: { MATCH LINES: 2390 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: 2386: if (IS_ENABLED(CONFIG_QCOM_KGSL_HIBERNATION) && 2387: !test_bit(GMU_PRIV_PDC_RSC_LOADED, &gmu->flags)) { 2388: /* 2389: * During hibernation entry ZAP was unloaded and 2390: * CBCAST BCL register is in reset state. 2391: * Set bcl_enabled to false to skip KMD's HFI request 2392: * to GMU for BCL feature, send BCL feature request to 2393: * GMU after ZAP load at GPU boot. This ensures that 2394: * Central Broadcast register was programmed before 2395: * enabling BCL. 2396: */ 2397: adreno_dev->bcl_enabled = false; 2398: ret = gen7_gmu_first_boot(adreno_dev); 2399: } else { 2400: ret = gen7_gmu_boot(adreno_dev); 2401: } 2402: 2403: if (ret) 2404: return ret; 2405: 2406: ret = gen7_gpu_boot(adreno_dev); 2407: if (ret) 2408: return ret; 2409: 2410: kgsl_start_idle_timer(device); 2411: kgsl_pwrscale_wake(device); 2412: 2413: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 2414: MATCH LINES: 2466, 2467 2454: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE); 2455: 2456: ret = gen7_gmu_first_boot(adreno_dev); 2457: if (ret) 2458: return ret; 2459: 2460: ret = gen7_gpu_boot(adreno_dev); 2461: if (ret) 2462: return ret; 2463: 2464: adreno_get_bus_counters(adreno_dev); 2465: 2466: adreno_dev->cooperative_reset = ADRENO_FEATURE(adreno_dev, 2467: ADRENO_COOP_RESET); 2468: 2469: adreno_create_profile_buffer(adreno_dev); 2470: 2471: set_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags); 2472: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 2473: 2474: /* 2475: * BCL needs respective Central Broadcast register to 2476: * be programed from TZ. For kernel version prior to 6.1, this 2477: * programing happens only when zap shader firmware load is successful. 2478: * Zap firmware load can fail in boot up path hence enable BCL only 2479: * after we successfully complete first boot to ensure that Central 2480: * Broadcast register was programed before enabling BCL. 2481: */ 2482: if (ADRENO_FEATURE(adreno_dev, ADRENO_BCL)) 2483: adreno_dev->bcl_enabled = true; 2484: 2485: /* 2486: * There is a possible deadlock scenario during kgsl firmware reading 2487: * (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl 2488: * device mutex is held and then firmware_request_nowarn is called for reading 2489: * firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock. 2490: * Whereas in case of devfreq update calls triggered by thermal/bcl or 2491: * devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then MATCH LINES: 2572, 2576 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: 2578: kgsl_pwrctrl_set_state(device, KGSL_STATE_SLUMBER); 2579: 2580: return ret; 2581: } 2582: 2583: static void gmu_idle_check(struct work_struct *work) 2584: { 2585: struct kgsl_device *device = container_of(work, 2586: struct kgsl_device, idle_check_ws); 2587: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 2588: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 2589: int ret; 2590: 2591: kgsl_mutex_lock(&device->mutex); 2592: 2593: if (test_bit(GMU_DISABLE_SLUMBER, &device->gmu_core.flags)) 2594: goto done; 2595: 2596: if (atomic_read(&device->active_cnt) || time_is_after_jiffies(device->idle_jiffies)) { 2597: kgsl_pwrscale_update(device); 2598: goto done; 2599: } 2600: MATCH LINES: 2829, 2839, 2842 2817: INIT_WORK(&device->idle_check_ws, gmu_idle_check); 2818: 2819: timer_setup(&device->idle_timer, gmu_idle_timer, 0); 2820: 2821: if (ADRENO_FEATURE(adreno_dev, ADRENO_DMS)) { 2822: set_bit(ADRENO_DEVICE_DMS, &adreno_dev->priv); 2823: adreno_dev->dms_enabled = true; 2824: } 2825: 2826: return 0; 2827: } 2828: 2829: int gen7_gmu_reset(struct adreno_device *adreno_dev) 2830: { 2831: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 2832: 2833: gen7_disable_gpu_irq(adreno_dev); 2834: 2835: gen7_gmu_irq_disable(adreno_dev); 2836: 2837: gen7_hfi_stop(adreno_dev); 2838: 2839: /* Hard reset the gmu and gpu */ 2840: gen7_gmu_suspend(adreno_dev, true); 2841: 2842: gen7_reset_preempt_records(adreno_dev); 2843: 2844: adreno_llcc_slice_deactivate(adreno_dev); 2845: 2846: clear_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 2847: 2848: /* Attempt to reboot the gmu and gpu */ 2849: return gen7_boot(adreno_dev); 2850: } 2851: 2852: int gen7_gmu_hfi_probe(struct adreno_device *adreno_dev) 2853: { 2854: struct platform_device *gmu_pdev = GMU_PDEV(KGSL_DEVICE(adreno_dev)); 2855: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 2856: struct gen7_hfi *hfi = &gmu->hfi; 2857: 2858: hfi->irq = kgsl_request_irq(gmu_pdev, "hfi", NULL, -EINVAL, 2859: gen7_hfi_irq_handler, KGSL_DEVICE(adreno_dev)); 2860: 2861: return hfi->irq < 0 ? hfi->irq : 0; 2862: } 2863: 2864: int gen7_gmu_add_to_minidump(struct adreno_device *adreno_dev) 2865: { 2866: struct gen7_device *gen7_dev = container_of(adreno_dev, --- FILE: \adreno_gen7_gmu.h | HITS: 15 --- MATCH LINES: 51 39: /** @gpu_boot_scratch: Memory to store the bootup HFI messages */ 40: struct kgsl_memdesc *gpu_boot_scratch; 41: struct gen7_hfi hfi; 42: unsigned int idle_level; 43: /** @qmp: Pointer to qmp struct used for AOP messages*/ 44: struct qmp *qmp; 45: struct kgsl_mailbox mailbox; 46: unsigned int log_wptr_retention; 47: /** @cm3_fault: whether gmu received a cm3 fault interrupt */ 48: atomic_t cm3_fault; 49: /** 50: * @itcm_shadow: Copy of the itcm block in firmware binary used for 51: * snapshot 52: */ 53: void *itcm_shadow; 54: /** @flags: Internal gmu flags */ 55: unsigned long flags; 56: /** @rscc_virt: Pointer where RSCC block is mapped */ 57: void __iomem *rscc_virt; 58: /** @log_stream_enable: GMU log streaming enable. Disabled by default */ 59: bool log_stream_enable; 60: /** @log_group_mask: Allows overriding default GMU log group mask */ 61: u32 log_group_mask; 62: struct kobject log_kobj; 63: /** @pdc_cfg_base: Base address of PDC cfg registers */ 64: void __iomem *pdc_cfg_base; 65: /** @num_oob_perfcntr: Number of active oob_perfcntr requests */ 66: u32 num_oob_perfcntr; 67: /** @acd_debug_val: DVM value to calibrate ACD for a level */ 68: u32 acd_debug_val; 69: /** @stats_enable: GMU stats feature enable */ 70: bool stats_enable; 71: /** @stats_mask: GMU performance countables to enable */ 72: u32 stats_mask; 73: /** @stats_interval: GMU performance counters sampling interval */ 74: u32 stats_interval; 75: /** @stats_kobj: kernel object for GMU stats directory in sysfs */ MATCH LINES: 111, 122, 127, 142, 144, 147, 149, 150 99: int gen7_build_rpmh_tables(struct adreno_device *adreno_dev); 100: 101: /** 102: * gen7_gmu_gx_is_on - Check if GX is on 103: * @adreno_dev: Pointer to the adreno device 104: * 105: * This function reads pwr status registers to check if GX 106: * is on or off 107: */ 108: bool gen7_gmu_gx_is_on(struct adreno_device *adreno_dev); 109: 110: /** 111: * gen7_gmu_device_probe - GEN7 GMU snapshot function 112: * @pdev: Pointer to the platform device 113: * @chipid: Chipid of the target 114: * @gpucore: Pointer to the gpucore 115: * 116: * The target specific probe function for gmu based gen7 targets. 117: */ 118: int gen7_gmu_device_probe(struct platform_device *pdev, 119: u32 chipid, const struct adreno_gpu_core *gpucore); 120: 121: /** 122: * gen7_gmu_reset - Reset and restart the gmu 123: * @adreno_dev: Pointer to the adreno device 124: * 125: * Return: 0 on success or negative error on failure 126: */ 127: int gen7_gmu_reset(struct adreno_device *adreno_dev); 128: 129: /** 130: * gen7_enable_gpu_irq - Enable gpu interrupt 131: * @adreno_dev: Pointer to the adreno device 132: */ 133: void gen7_enable_gpu_irq(struct adreno_device *adreno_dev); 134: 135: /** 136: * gen7_disable_gpu_irq - Disable gpu interrupt 137: * @adreno_dev: Pointer to the adreno device 138: */ 139: void gen7_disable_gpu_irq(struct adreno_device *adreno_dev); 140: 141: /** 142: * gen7_gmu_snapshot- Take snapshot for gmu targets 143: * @adreno_dev: Pointer to the adreno device 144: * @snapshot: Pointer to the snapshot structure 145: * 146: * Send an NMI to gmu if we hit a gmu fault. Then take gmu 147: * snapshot and carry on with rest of the gen7 snapshot 148: */ 149: void gen7_gmu_snapshot(struct adreno_device *adreno_dev, 150: struct kgsl_snapshot *snapshot); 151: 152: /** 153: * gen7_gmu_probe - Probe gen7 gmu resources 154: * @device: Pointer to the kgsl device 155: * @pdev: Pointer to the gmu platform device 156: * 157: * Probe the gmu and hfi resources 158: * 159: * Return: 0 on success or negative error on failure 160: */ 161: int gen7_gmu_probe(struct kgsl_device *device, 162: struct platform_device *pdev); 163: 164: /** 165: * gen7_gmu_parse_fw - Parse the gmu fw binary 166: * @adreno_dev: Pointer to the adreno device 167: * 168: * Return: 0 on success or negative error on failure 169: */ 170: int gen7_gmu_parse_fw(struct adreno_device *adreno_dev); 171: 172: /** 173: * gen7_gmu_memory_init - Allocate gmu memory 174: * @adreno_dev: Pointer to the adreno device MATCH LINES: 202, 218, 254, 256, 258, 259 190: 191: /** 192: * gen7_gmu_load_fw - Load gmu firmware 193: * @adreno_dev: Pointer to the adreno device 194: * 195: * Loads the gmu firmware binary into TCMs and memory 196: * 197: * Return: 0 on success or negative error on failure 198: */ 199: int gen7_gmu_load_fw(struct adreno_device *adreno_dev); 200: 201: /** 202: * gen7_gmu_device_start - Bring gmu out of reset 203: * @adreno_dev: Pointer to the adreno device 204: * 205: * Return: 0 on success or negative error on failure 206: */ 207: int gen7_gmu_device_start(struct adreno_device *adreno_dev); 208: 209: /** 210: * gen7_gmu_hfi_start - Indicate hfi start to gmu 211: * @device: Pointer to the kgsl device 212: * 213: * Return: 0 on success or negative error on failure 214: */ 215: int gen7_gmu_hfi_start(struct adreno_device *adreno_dev); 216: 217: /** 218: * gen7_gmu_itcm_shadow - Create itcm shadow copy for snapshot 219: * @adreno_dev: Pointer to the adreno device 220: * 221: * Return: 0 on success or negative error on failure 222: */ 223: int gen7_gmu_itcm_shadow(struct adreno_device *adreno_dev); 224: 225: /** 226: * gen7_gmu_register_config - gmu register configuration 227: * @adreno_dev: Pointer to the adreno device 228: * 229: * Program gmu regsiters based on features 230: */ 231: void gen7_gmu_register_config(struct adreno_device *adreno_dev); 232: 233: /** 234: * gen7_gmu_version_info - Get gmu firmware version 235: * @adreno_dev: Pointer to the adreno device 236: * 237: * Return: 0 on success or negative error on failure 238: */ 239: int gen7_gmu_version_info(struct adreno_device *adreno_dev); 240: 241: /** 242: * gen7_gmu_irq_enable - Enable gmu interrupts 243: * @adreno_dev: Pointer to the adreno device 244: */ 245: void gen7_gmu_irq_enable(struct adreno_device *adreno_dev); 246: 247: /** 248: * gen7_gmu_irq_disable - Disaable gmu interrupts 249: * @adreno_dev: Pointer to the adreno device 250: */ 251: void gen7_gmu_irq_disable(struct adreno_device *adreno_dev); 252: 253: /** 254: * gen7_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 gen7_gmu_suspend(struct adreno_device *adreno_dev, bool force); 262: 263: /** 264: * gen7_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 gen7_gmu_oob_set(struct kgsl_device *device, enum oob_request oob); 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: --- FILE: \adreno_gen7_gmu_snapshot.c | HITS: 62 --- MATCH LINES: 11, 12, 13, 14, 18, 22, 23, 29, 33, 60, 64, 65, 76, 80, 90, 91, 106, 108, 110, 112, 114, 116, 118, 119, 120, 126, 136, 139, 164, 165, 166, 169, 171, 172, 177, 178, 179, 181, 182, 184, 186, 188, 189, 192, 193, 196, 197, 207, 208, 210, 212, 213, 214, 228, 229, 232, 233, 239, 240, 242, 244, 246 1: // SPDX-License-Identifier: GPL-2.0-only 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 "gen7_reg.h" 8: #include "adreno.h" 9: #include "adreno_gen7.h" 10: #include "adreno_gen7_gmu.h" 11: #include "adreno_snapshot.h" 12: #include "adreno_gen7_0_0_snapshot.h" 13: #include "adreno_gen7_2_0_snapshot.h" 14: #include "adreno_gen7_6_0_snapshot.h" 15: #include "kgsl_device.h" 16: #include "kgsl_gmu_core.h" 17: 18: static size_t gen7_gmu_snapshot_dtcm(struct kgsl_device *device, 19: u8 *buf, size_t remain, void *priv) 20: { 21: struct gmu_core_device *gmu_core = &device->gmu_core; 22: struct kgsl_snapshot_gmu_mem *mem_hdr = 23: (struct kgsl_snapshot_gmu_mem *)buf; 24: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 25: u32 *data = (u32 *)(buf + sizeof(*mem_hdr)); 26: u32 i; 27: 28: if (remain < gmu_core->vma[GMU_DTCM].size + sizeof(*mem_hdr)) { 29: SNAPSHOT_ERR_NOMEM(device, "GMU DTCM Memory"); 30: return 0; 31: } 32: 33: mem_hdr->type = SNAPSHOT_GMU_MEM_BIN_BLOCK; 34: mem_hdr->hostaddr = 0; 35: mem_hdr->gmuaddr = gmu_core->vma[GMU_DTCM].start; 36: mem_hdr->gpuaddr = 0; 37: 38: /* 39: * Read of GMU TCMs over side-band debug controller interface is 40: * supported on gen7_2_x family 41: */ 42: if (adreno_is_gen7_2_x_family(adreno_dev)) { 43: /* 44: * region [20]: Dump ITCM/DTCM. Select 1 for DTCM. 45: * autoInc [31]: Autoincrement the address field after each 46: * access to TCM_DBG_DATA 47: */ 48: kgsl_regwrite(device, GEN7_CX_DBGC_TCM_DBG_ADDR, BIT(20) | BIT(31)); 49: 50: for (i = 0; i < (gmu_core->vma[GMU_DTCM].size >> 2); i++) 51: kgsl_regread(device, GEN7_CX_DBGC_TCM_DBG_DATA, data++); 52: } else { 53: for (i = 0; i < (gmu_core->vma[GMU_DTCM].size >> 2); i++) 54: gmu_core_regread(device, GEN7_GMU_CM3_DTCM_START + i, data++); 55: } 56: 57: return gmu_core->vma[GMU_DTCM].size + sizeof(*mem_hdr); 58: } 59: 60: static size_t gen7_gmu_snapshot_itcm(struct kgsl_device *device, 61: u8 *buf, size_t remain, void *priv) 62: { 63: struct gmu_core_device *gmu_core = &device->gmu_core; 64: struct kgsl_snapshot_gmu_mem *mem_hdr = 65: (struct kgsl_snapshot_gmu_mem *)buf; 66: void *dest = buf + sizeof(*mem_hdr); 67: struct gen7_gmu_device *gmu = (struct gen7_gmu_device *)priv; 68: 69: if (!gmu->itcm_shadow) { 70: dev_err(GMU_PDEV_DEV(device), 71: "No memory allocated for ITCM shadow capture\n"); 72: return 0; 73: } 74: 75: if (remain < gmu_core->vma[GMU_ITCM].size + sizeof(*mem_hdr)) { 76: SNAPSHOT_ERR_NOMEM(device, "GMU ITCM Memory"); 77: return 0; 78: } 79: 80: mem_hdr->type = SNAPSHOT_GMU_MEM_BIN_BLOCK; 81: mem_hdr->hostaddr = 0; 82: mem_hdr->gmuaddr = gmu_core->vma[GMU_ITCM].start; 83: mem_hdr->gpuaddr = 0; 84: 85: memcpy(dest, gmu->itcm_shadow, gmu_core->vma[GMU_ITCM].size); 86: 87: return gmu_core->vma[GMU_ITCM].size + sizeof(*mem_hdr); 88: } 89: 90: static void gen7_gmu_snapshot_memories(struct kgsl_device *device, 91: struct gen7_gmu_device *gmu, struct kgsl_snapshot *snapshot) 92: { 93: struct gmu_mem_type_desc desc; 94: struct kgsl_memdesc *md; 95: struct gmu_core_device *gmu_core = &device->gmu_core; 96: int i; 97: 98: for (i = 0; i < ARRAY_SIZE(gmu_core->gmu_globals); i++) { 99: 100: md = &gmu_core->gmu_globals[i]; 101: if (!md->size) 102: continue; 103: 104: desc.memdesc = md; 105: if (md == gmu->hfi.hfi_mem) 106: desc.type = SNAPSHOT_GMU_MEM_HFI; 107: else if (md == gmu->gmu_log) 108: desc.type = SNAPSHOT_GMU_MEM_LOG; 109: else if ((md == gmu->gmu_init_scratch) || (md == gmu->gpu_boot_scratch)) 110: desc.type = SNAPSHOT_GMU_MEM_WARMBOOT; 111: else if (md == gmu_core->vrb) 112: desc.type = SNAPSHOT_GMU_MEM_VRB; 113: else if (md == gmu_core->trace.md) 114: desc.type = SNAPSHOT_GMU_MEM_TRACE; 115: else 116: desc.type = SNAPSHOT_GMU_MEM_BIN_BLOCK; 117: 118: kgsl_snapshot_add_section(device, 119: KGSL_SNAPSHOT_SECTION_GMU_MEMORY, 120: snapshot, adreno_snapshot_gmu_mem, &desc); 121: } 122: } 123: 124: #define RSCC_OFFSET_DWORDS 0x14000 125: 126: static size_t gen7_snapshot_rscc_registers(struct kgsl_device *device, u8 *buf, 127: size_t remain, void *priv) 128: { 129: const u32 *regs = priv; 130: unsigned int *data = (unsigned int *)buf; 131: int count = 0, k; 132: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 133: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 134: 135: /* Figure out how many registers we are going to dump */ 136: count = adreno_snapshot_regs_count(regs); 137: 138: if (remain < (count * 4)) { 139: SNAPSHOT_ERR_NOMEM(device, "RSCC REGISTERS"); 140: return 0; 141: } 142: 143: for (regs = priv; regs[0] != UINT_MAX; regs += 2) { 144: unsigned int cnt = REG_COUNT(regs); 145: 146: if (cnt == 1) { 147: *data++ = BIT(31) | regs[0]; 148: *data++ = __raw_readl(gmu->rscc_virt + 149: ((regs[0] - RSCC_OFFSET_DWORDS) << 2)); 150: continue; 151: } 152: *data++ = regs[0]; 153: *data++ = cnt; 154: for (k = regs[0]; k <= regs[1]; k++) 155: *data++ = __raw_readl(gmu->rscc_virt + 156: ((k - RSCC_OFFSET_DWORDS) << 2)); 157: } 158: 159: /* Return the size of the section */ 160: return (count * 4); 161: } 162: 163: /* 164: * gen7_gmu_device_snapshot() - GEN7 GMU snapshot function 165: * @device: Device being snapshotted 166: * @snapshot: Pointer to the snapshot instance 167: * 168: * This is where all of the GEN7 GMU specific bits and pieces are grabbed 169: * into the snapshot memory 170: */ 171: static void gen7_gmu_device_snapshot(struct kgsl_device *device, 172: struct kgsl_snapshot *snapshot) 173: { 174: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 175: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 176: const struct adreno_gen7_core *gpucore = to_gen7_core(ADRENO_DEVICE(device)); 177: const struct gen7_snapshot_block_list *gen7_snapshot_block_list = 178: gpucore->gen7_snapshot_block_list; 179: const u32 *regs_ptr = (const u32 *)gen7_snapshot_block_list->gmu_ao_regs; 180: 181: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_GMU_MEMORY, 182: snapshot, gen7_gmu_snapshot_itcm, gmu); 183: 184: adreno_snapshot_gmu_versions(device, snapshot); 185: 186: gen7_gmu_snapshot_memories(device, gmu, snapshot); 187: 188: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, snapshot, 189: adreno_snapshot_registers_v2, (void *) gen7_snapshot_block_list->gmu_regs); 190: 191: if (regs_ptr && kgsl_regmap_valid_offset(&device->regmap, regs_ptr[0])) { 192: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, snapshot, 193: adreno_snapshot_registers_v2, (void *) gen7_snapshot_block_list->gmu_ao_regs); 194: } 195: 196: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, snapshot, 197: gen7_snapshot_rscc_registers, (void *) gen7_snapshot_block_list->rscc_regs); 198: 199: if (!gen7_gmu_gx_is_on(adreno_dev)) 200: goto dtcm; 201: 202: /* Set fence to ALLOW mode so registers can be read */ 203: kgsl_regwrite(device, GEN7_GMU_AO_AHB_FENCE_CTRL, 0); 204: /* Make sure the previous write posted before reading */ 205: wmb(); 206: 207: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, snapshot, 208: adreno_snapshot_registers_v2, (void *) gen7_snapshot_block_list->gmu_gx_regs); 209: 210: regs_ptr = (const u32 *)gen7_snapshot_block_list->gmu_gx_blk_dec0_dec1_regs; 211: if (regs_ptr && kgsl_regmap_valid_offset(&device->regmap, regs_ptr[0])) { 212: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, snapshot, 213: adreno_snapshot_registers_v2, 214: (void *) gen7_snapshot_block_list->gmu_gx_blk_dec0_dec1_regs); 215: } 216: 217: /* 218: * A stalled SMMU can lead to NoC timeouts when host accesses DTCM. 219: * DTCM can be read through side-band DBGC interface on gen7_2_x family. 220: */ 221: if (adreno_smmu_is_stalled(adreno_dev) && !adreno_is_gen7_2_x_family(adreno_dev)) { 222: dev_err(GMU_PDEV_DEV(device), 223: "Not dumping dtcm because SMMU is stalled\n"); 224: return; 225: } 226: 227: dtcm: 228: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_GMU_MEMORY, 229: snapshot, gen7_gmu_snapshot_dtcm, gmu); 230: } 231: 232: void gen7_gmu_snapshot(struct adreno_device *adreno_dev, 233: struct kgsl_snapshot *snapshot) 234: { 235: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 236: 237: /* 238: * Dump external register first to have GPUCC and other external 239: * register in snapshot to analyze the system state even in partial 240: * snapshot dump 241: */ 242: gen7_snapshot_external_core_regs(device, snapshot); 243: 244: gen7_gmu_device_snapshot(device, snapshot); 245: 246: gen7_snapshot(adreno_dev, snapshot); 247: 248: gmu_core_regwrite(device, GEN7_GMU_GMU2HOST_INTR_CLR, UINT_MAX); 249: gmu_core_regwrite(device, GEN7_GMU_GMU2HOST_INTR_MASK, HFI_IRQ_MASK); 250: } --- FILE: \adreno_gen7_hfi.c | HITS: 10 --- MATCH LINES: 162 150: struct gen7_hfi *hfi = &gmu->hfi; 151: int ret; 152: 153: spin_lock(&hfi->cmdq_lock); 154: 155: if (test_bit(MSG_HDR_GET_ID(msg[0]), hfi->wb_set_record_bitmask)) 156: *msg = RECORD_MSG_HDR(*msg); 157: 158: ret = gen7_hfi_queue_write(adreno_dev, HFI_CMD_ID, msg, size_bytes); 159: 160: /* 161: * Some messages like ACD table and perf table are saved in memory, so we need 162: * to reset the header to make sure we do not send a record enabled bit incase 163: * we change the warmboot setting from debugfs 164: */ 165: *msg = CLEAR_RECORD_MSG_HDR(*msg); 166: /* 167: * Memory barrier to make sure packet and write index are written before 168: * an interrupt is raised 169: */ 170: wmb(); 171: 172: /* Send interrupt to GMU to receive the message */ 173: if (!ret) 174: gmu_core_regwrite(KGSL_DEVICE(adreno_dev), 175: GEN7_GMU_HOST2GMU_INTR_SET, 0x1); 176: 177: spin_unlock(&hfi->cmdq_lock); 178: 179: return ret; 180: } 181: 182: /* Sizes of the queue and message are in unit of dwords */ 183: static void init_queues(struct adreno_device *adreno_dev) 184: { 185: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 186: struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem; MATCH LINES: 260, 283, 284, 285 248: return -EINVAL; 249: 250: if (CMP_HFI_ACK_HDR(ret_cmd->sent_hdr, req_hdr)) { 251: memcpy(&ret_cmd->results, ack, MSG_HDR_GET_SIZE(hdr) << 2); 252: return 0; 253: } 254: 255: /* Didn't find the sender, list the waiter */ 256: dev_err_ratelimited(GMU_PDEV_DEV(device), 257: "HFI ACK: Cannot find sender for 0x%8.8x Waiter: 0x%8.8x\n", 258: req_hdr, ret_cmd->sent_hdr); 259: 260: gmu_core_fault_snapshot(device, GMU_FAULT_HFI_RECIVE_ACK); 261: 262: return -ENODEV; 263: } 264: 265: static int poll_gmu_reg(struct adreno_device *adreno_dev, 266: u32 offsetdwords, unsigned int expected_val, 267: unsigned int mask, unsigned int timeout_ms) 268: { 269: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 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; 307: } 308: 309: static int gen7_hfi_send_cmd_wait_inline(struct adreno_device *adreno_dev, MATCH LINES: 337, 368 325: 326: rc = gen7_hfi_cmdq_write(adreno_dev, cmd, size_bytes); 327: if (rc) 328: return rc; 329: 330: rc = poll_gmu_reg(adreno_dev, GEN7_GMU_GMU2HOST_INTR_INFO, 331: HFI_IRQ_MSGQ_MASK, HFI_IRQ_MSGQ_MASK, HFI_RSP_TIMEOUT); 332: 333: if (rc) { 334: dev_err(GMU_PDEV_DEV(device), 335: "Timed out waiting on ack for 0x%8.8x (id %d, sequence %d)\n", 336: cmd[0], MSG_HDR_GET_ID(*cmd), MSG_HDR_GET_SEQNUM(*cmd)); 337: gmu_core_fault_snapshot(device, GMU_FAULT_SEND_CMD_WAIT_INLINE); 338: return rc; 339: } 340: 341: /* Clear the interrupt */ 342: gmu_core_regwrite(device, GEN7_GMU_GMU2HOST_INTR_CLR, 343: HFI_IRQ_MSGQ_MASK); 344: 345: rc = gen7_hfi_process_queue(gmu, HFI_MSG_ID, ret_cmd); 346: 347: return rc; 348: } 349: 350: int gen7_hfi_send_generic_req(struct adreno_device *adreno_dev, void *cmd, u32 size_bytes) 351: { 352: struct pending_cmd ret_cmd; 353: int rc; 354: 355: memset(&ret_cmd, 0, sizeof(ret_cmd)); 356: 357: rc = gen7_hfi_send_cmd_wait_inline(adreno_dev, cmd, size_bytes, &ret_cmd); 358: if (rc) 359: return rc; 360: 361: if (ret_cmd.results[2]) { 362: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 363: 364: dev_err(GMU_PDEV_DEV(device), 365: "HFI ACK failure: Req=0x%8.8X, Result=0x%8.8X\n", 366: ret_cmd.results[1], 367: ret_cmd.results[2]); 368: gmu_core_fault_snapshot(device, GMU_FAULT_HFI_SEND_GENERIC_REQ); 369: return -EINVAL; 370: } 371: 372: return 0; 373: } 374: 375: int gen7_hfi_send_core_fw_start(struct adreno_device *adreno_dev) 376: { 377: struct hfi_core_fw_start_cmd cmd = { 378: .handle = 0x0, 379: }; 380: int ret; 381: 382: ret = CMD_MSG_HDR(cmd, H2F_MSG_CORE_FW_START); 383: if (ret) 384: return ret; 385: 386: return gen7_hfi_send_generic_req(adreno_dev, &cmd, sizeof(cmd)); 387: } 388: 389: /* For sending hfi message inline to handle GMU return type error */ 390: int gen7_hfi_send_generic_req_v5(struct adreno_device *adreno_dev, void *cmd, 391: struct pending_cmd *ret_cmd, u32 size_bytes) 392: { MATCH LINES: 419 407: case GMU_ERROR_NO_ENTRY: 408: /* Unique error to handle undefined HFI msgs by caller */ 409: rc = -ENOENT; 410: break; 411: case GMU_ERROR_TIMEOUT: 412: rc = -EINVAL; 413: break; 414: default: 415: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)), 416: "HFI ACK: Req=0x%8.8X, Result=0x%8.8X Error:0x%8.8X\n", 417: ret_cmd->results[1], ret_cmd->results[2], ret_cmd->results[3]); 418: rc = -EINVAL; 419: gmu_core_fault_snapshot(KGSL_DEVICE(adreno_dev), GMU_FAULT_HFI_SEND_GENERIC_REQ); 420: break; 421: } 422: 423: return rc; 424: } 425: 426: int gen7_hfi_send_feature_ctrl(struct adreno_device *adreno_dev, 427: u32 feature, u32 enable, u32 data) 428: { 429: struct pending_cmd ret_cmd = {0}; 430: struct hfi_feature_ctrl_cmd cmd = { 431: .feature = feature, 432: .enable = enable, 433: .data = data, 434: }; 435: int ret; 436: 437: ret = CMD_MSG_HDR(cmd, H2F_MSG_FEATURE_CTRL); 438: if (ret) 439: return ret; 440: 441: ret = gen7_hfi_send_generic_req_v5(adreno_dev, &cmd, &ret_cmd, sizeof(cmd)); 442: if (ret < 0) 443: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)), "Unable to %s feature %s (%d)\n", MATCH LINES: 636 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) 657: { 658: entry->count = count; 659: entry->stride = stride_bytes >> 2; /* entry->stride is in dwords */ 660: memcpy(entry->data, data, stride_bytes * count); MATCH LINES: 743 731: ret = gen7_hfi_send_generic_req(adreno_dev, cmd, sizeof(*cmd)); 732: } 733: 734: return ret; 735: } 736: 737: int gen7_hfi_start(struct adreno_device *adreno_dev) 738: { 739: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 740: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 741: int result; 742: 743: reset_hfi_queues(adreno_dev); 744: 745: result = gen7_hfi_send_gpu_perf_table(adreno_dev); 746: if (result) 747: goto err; 748: 749: result = gen7_hfi_send_generic_req(adreno_dev, &gmu->hfi.bw_table, 750: sizeof(gmu->hfi.bw_table)); 751: if (result) 752: goto err; 753: 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) --- FILE: \adreno_gen7_hwsched.c | HITS: 81 --- MATCH LINES: 12, 38, 65, 66, 74, 76, 85, 87, 96, 97, 98, 102, 103, 104, 108, 109, 110, 114, 115, 116, 120, 124, 125, 126, 130, 131, 132, 139, 141, 142, 143, 149, 155 1: // SPDX-License-Identifier: GPL-2.0-only 2: /* 3: * Copyright (c) 2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #include 8: 9: #include "adreno.h" 10: #include "adreno_gen7.h" 11: #include "adreno_gen7_hwsched.h" 12: #include "adreno_snapshot.h" 13: #include "kgsl_bus.h" 14: #include "kgsl_device.h" 15: #include "kgsl_gmu_core.h" 16: #include "kgsl_trace.h" 17: #include "kgsl_util.h" 18: 19: static void _wakeup_hw_fence_waiters(struct adreno_device *adreno_dev, u32 fault) 20: { 21: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev); 22: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 23: bool lock = !in_interrupt(); 24: 25: if (!test_bit(ADRENO_HWSCHED_HW_FENCE, &adreno_dev->hwsched.flags)) 26: return; 27: 28: /* 29: * We could be in interrupt context here, which means we need to use spin_lock_irqsave 30: * (which disables interrupts) everywhere we take this lock. Instead of that, simply 31: * avoid taking this lock if we are recording a fault from an interrupt handler. 32: */ 33: if (lock) 34: spin_lock(&hwf->lock); 35: 36: clear_bit(GEN7_HWSCHED_HW_FENCE_SLEEP_BIT, &hwf->flags); 37: 38: /* Avoid creating new hardware fences until recovery is complete */ 39: set_bit(GEN7_HWSCHED_HW_FENCE_ABORT_BIT, &hwf->flags); 40: 41: if (!lock) 42: /* 43: * This barrier ensures that the above bitops complete before we wake up the waiters 44: */ 45: smp_wmb(); 46: else 47: spin_unlock(&hwf->lock); 48: 49: wake_up_all(&hwf->unack_wq); 50: 51: kgsl_delete_timer(&hfi->hw_fence_timer); 52: } 53: 54: void gen7_hwsched_fault(struct adreno_device *adreno_dev, u32 fault) 55: { 56: /* 57: * Wake up any threads that may be sleeping waiting for the hardware fence unack count to 58: * drop to a desired threshold. 59: */ 60: _wakeup_hw_fence_waiters(adreno_dev, fault); 61: 62: adreno_scheduler_fault(adreno_dev, fault); 63: } 64: 65: void gen7_hwsched_snapshot(struct adreno_device *adreno_dev, 66: struct kgsl_snapshot *snapshot) 67: { 68: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 69: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 70: bool skip_memkind_rb = false; 71: u32 i; 72: bool parse_payload; 73: 74: gen7_gmu_snapshot(adreno_dev, snapshot); 75: 76: adreno_hwsched_parse_fault_cmdobj(adreno_dev, snapshot); 77: 78: /* 79: * First try to dump ringbuffers using context bad HFI payloads 80: * because they have all the ringbuffer parameters. If ringbuffer 81: * payloads are not present, fall back to dumping ringbuffers 82: * based on MEMKIND_RB 83: */ 84: if (GMU_VER_MINOR(device->gmu_core.ver.hfi) < 2) 85: parse_payload = adreno_hwsched_parse_payload_rb_legacy(adreno_dev, snapshot); 86: else 87: parse_payload = adreno_hwsched_parse_payload_rb(adreno_dev, snapshot); 88: 89: if (parse_payload) 90: skip_memkind_rb = true; 91: 92: for (i = 0; i < hwsched->mem_alloc_entries; i++) { 93: struct hfi_mem_alloc_entry *entry = &hwsched->mem_alloc_table[i]; 94: 95: if (entry->desc.mem_kind == HFI_MEMKIND_RB && !skip_memkind_rb) 96: kgsl_snapshot_add_section(device, 97: KGSL_SNAPSHOT_SECTION_RB_V2, 98: snapshot, adreno_hwsched_snapshot_rb, 99: entry->md); 100: 101: if (entry->desc.mem_kind == HFI_MEMKIND_SCRATCH) 102: kgsl_snapshot_add_section(device, 103: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 104: snapshot, adreno_snapshot_global, 105: entry->md); 106: 107: if (entry->desc.mem_kind == HFI_MEMKIND_PROFILE) 108: kgsl_snapshot_add_section(device, 109: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 110: snapshot, adreno_snapshot_global, 111: entry->md); 112: 113: if (entry->desc.mem_kind == HFI_MEMKIND_CSW_SMMU_INFO) 114: kgsl_snapshot_add_section(device, 115: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 116: snapshot, adreno_snapshot_global, 117: entry->md); 118: 119: if (entry->desc.mem_kind == HFI_MEMKIND_CSW_PRIV_NON_SECURE) 120: adreno_hwsched_snapshot_preemption_records(device, snapshot, 121: entry->md); 122: 123: if (entry->desc.mem_kind == HFI_MEMKIND_PREEMPT_SCRATCH) 124: kgsl_snapshot_add_section(device, 125: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 126: snapshot, adreno_snapshot_global, 127: entry->md); 128: 129: if (entry->desc.mem_kind == HFI_MEMKIND_AQE_BUFFER) 130: kgsl_snapshot_add_section(device, 131: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 132: snapshot, adreno_hwsched_snapshot_aqe_buffer, 133: entry->md); 134: 135: if (entry->desc.mem_kind == HFI_MEMKIND_HW_FENCE) { 136: struct gmu_mem_type_desc desc; 137: 138: desc.memdesc = entry->md; 139: desc.type = SNAPSHOT_GMU_MEM_HW_FENCE; 140: 141: kgsl_snapshot_add_section(device, 142: KGSL_SNAPSHOT_SECTION_GMU_MEMORY, 143: snapshot, adreno_snapshot_gmu_mem, &desc); 144: } 145: 146: } 147: 148: if (adreno_hwsched_context_queue_enabled(adreno_dev)) 149: adreno_hwsched_snapshot_context_queue(device, snapshot); 150: } 151: 152: static void gen7_hwsched_gmu_suspend(struct adreno_device *adreno_dev, bool force) 153: { 154: gen7_gmu_suspend(adreno_dev, force); 155: adreno_hwsched_reset_hfi_mem(adreno_dev); 156: } 157: 158: static int gen7_hwsched_gmu_first_boot(struct adreno_device *adreno_dev) 159: { 160: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 161: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 162: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 163: int level, ret = 0; 164: 165: kgsl_pwrctrl_request_state(device, KGSL_STATE_AWARE); 166: 167: gen7_gmu_aop_send_acd_state(gmu, adreno_dev->acd_enabled); 168: 169: ret = kgsl_pwrctrl_enable_cx_gdsc(device); 170: if (ret) 171: return ret; 172: 173: ret = gmu_core_enable_clks(device, device->gmu_core.num_freqs - 1); 174: if (ret) 175: goto gdsc_off; 176: 177: /* 178: * Enable AHB timeout detection to catch any register access taking longer 179: * time before NOC timeout gets detected. Enable this logic before any MATCH LINES: 234 222: /* From this GMU FW all RBBM interrupts are handled at GMU */ 223: if (device->gmu_core.ver.core >= GMU_VERSION(5, 01, 06)) 224: adreno_irq_free(adreno_dev); 225: 226: /* GMU supports force retire command from this GMU FW */ 227: if (gmu_core_capabilities_enabled(&device->gmu_core.common_caps, 228: FAC_FORCE_RETIRE_COMMAND)) 229: set_bit(ADRENO_HWSCHED_FORCE_RETIRE_GMU, &adreno_dev->hwsched.flags); 230: 231: icc_set_bw(pwr->icc_path, 0, kBps_to_icc(pwr->ddr_table[level])); 232: 233: /* Clear any hwsched faults that might have been left over */ 234: adreno_clear_gpu_fault(adreno_dev); 235: 236: ret = gen7_gmu_device_start(adreno_dev); 237: if (ret) 238: goto err; 239: 240: gen7_get_gpu_feature_info(adreno_dev); 241: 242: ret = gen7_hwsched_hfi_start(adreno_dev); 243: if (ret) 244: goto err; 245: 246: ret = gmu_core_clock_set_rate(device, 0); 247: if (ret) { 248: gen7_hwsched_hfi_stop(adreno_dev); 249: goto err; 250: } 251: 252: if (adreno_dev->gmu_ab && 253: gen7_hwsched_hfi_get_value(adreno_dev, HFI_VALUE_GMU_AB_VOTE) == 1 && 254: !WARN_ONCE(!adreno_dev->gpucore->num_ddr_channels, 255: "Number of DDR channel is not specified in gpu core")) { 256: set_bit(ADRENO_DEVICE_GMU_AB, &adreno_dev->priv); 257: } else { 258: /* If gmu_ab feature flag is enabled but GMU doesn't support it, set it to false */ MATCH LINES: 278 266: kgsl_pwrctrl_set_state(device, KGSL_STATE_AWARE); 267: 268: return 0; 269: 270: err: 271: gen7_gmu_irq_disable(adreno_dev); 272: 273: if (device->gmu_fault) { 274: gen7_hwsched_gmu_suspend(adreno_dev, false); 275: return ret; 276: } 277: 278: adreno_hwsched_reset_hfi_mem(adreno_dev); 279: 280: clks_gdsc_off: 281: gmu_core_disable_clks(device); 282: 283: gdsc_off: 284: kgsl_pwrctrl_disable_cx_gdsc(device); 285: 286: gmu_core_rdpm_cx_freq_update(device, 0); 287: 288: return ret; 289: } 290: 291: static int gen7_hwsched_gmu_boot(struct adreno_device *adreno_dev) 292: { 293: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 294: int ret = 0; 295: 296: kgsl_pwrctrl_request_state(device, KGSL_STATE_AWARE); 297: 298: ret = kgsl_pwrctrl_enable_cx_gdsc(device); 299: if (ret) 300: return ret; 301: 302: ret = gmu_core_enable_clks(device, device->gmu_core.num_freqs - 1); MATCH LINES: 329, 358 317: if (ret) 318: goto clks_gdsc_off; 319: 320: ret = gen7_gmu_load_fw(adreno_dev); 321: if (ret) 322: goto clks_gdsc_off; 323: 324: gen7_gmu_register_config(adreno_dev); 325: 326: gen7_gmu_irq_enable(adreno_dev); 327: 328: /* Clear any hwsched faults that might have been left over */ 329: adreno_clear_gpu_fault(adreno_dev); 330: 331: ret = gen7_gmu_device_start(adreno_dev); 332: if (ret) 333: goto err; 334: 335: ret = gen7_hwsched_hfi_start(adreno_dev); 336: if (ret) 337: goto err; 338: 339: ret = gmu_core_clock_set_rate(device, 0); 340: if (ret) { 341: gen7_hwsched_hfi_stop(adreno_dev); 342: goto err; 343: } 344: 345: device->gmu_fault = false; 346: 347: kgsl_pwrctrl_set_state(device, KGSL_STATE_AWARE); 348: 349: return 0; 350: err: 351: gen7_gmu_irq_disable(adreno_dev); 352: 353: if (device->gmu_fault) { 354: gen7_hwsched_gmu_suspend(adreno_dev, false); 355: return ret; 356: } 357: 358: adreno_hwsched_reset_hfi_mem(adreno_dev); 359: 360: clks_gdsc_off: 361: gmu_core_disable_clks(device); 362: 363: gdsc_off: 364: kgsl_pwrctrl_disable_cx_gdsc(device); 365: 366: gmu_core_rdpm_cx_freq_update(device, 0); 367: 368: return ret; 369: } 370: 371: static int gen7_hwsched_notify_slumber(struct adreno_device *adreno_dev) 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: MATCH LINES: 440 428: gen7_gmu_irq_disable(adreno_dev); 429: 430: gen7_hwsched_hfi_stop(adreno_dev); 431: 432: gmu_core_disable_clks(device); 433: 434: kgsl_pwrctrl_disable_cx_gdsc(device); 435: 436: gmu_core_rdpm_cx_freq_update(device, 0); 437: 438: kgsl_pwrctrl_set_state(device, KGSL_STATE_NONE); 439: 440: adreno_hwsched_reset_hfi_mem(adreno_dev); 441: 442: return ret; 443: 444: error: 445: gen7_gmu_irq_disable(adreno_dev); 446: gen7_hwsched_hfi_stop(adreno_dev); 447: gen7_hwsched_gmu_suspend(adreno_dev, false); 448: 449: return ret; 450: } 451: 452: static void gen7_hwsched_init_ucode_regs(struct adreno_device *adreno_dev) 453: { 454: struct adreno_firmware *fw = ADRENO_FW(adreno_dev, ADRENO_FW_SQE); 455: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 456: 457: /* Program the ucode base for CP */ 458: kgsl_regwrite(device, GEN7_CP_SQE_INSTR_BASE_LO, 459: lower_32_bits(fw->memdesc->gpuaddr)); 460: kgsl_regwrite(device, GEN7_CP_SQE_INSTR_BASE_HI, 461: upper_32_bits(fw->memdesc->gpuaddr)); 462: 463: if (ADRENO_FEATURE(adreno_dev, ADRENO_AQE)) { 464: fw = ADRENO_FW(adreno_dev, ADRENO_FW_AQE); MATCH LINES: 505, 519, 520, 521, 523, 524, 526 493: goto err; 494: 495: /* Clear the busy_data stats - we're starting over from scratch */ 496: memset(&adreno_dev->busy_data, 0, sizeof(adreno_dev->busy_data)); 497: 498: gen7_start(adreno_dev); 499: 500: /* Re-initialize the coresight registers if applicable */ 501: adreno_coresight_start(adreno_dev); 502: 503: adreno_perfcounter_start(adreno_dev); 504: 505: /* Clear FSR here in case it is set from a previous pagefault */ 506: kgsl_mmu_clear_fsr(&device->mmu); 507: 508: gen7_enable_gpu_irq(adreno_dev); 509: 510: gen7_hwsched_init_ucode_regs(adreno_dev); 511: 512: ret = gen7_hwsched_boot_gpu(adreno_dev); 513: if (ret) { 514: adreno_llcc_slice_deactivate(adreno_dev); 515: goto err; 516: } 517: 518: /* 519: * At this point it is safe to assume that we recovered. Setting 520: * this field allows us to take a new snapshot for the next failure 521: * if we are prioritizing the first unrecoverable snapshot. 522: */ 523: if (device->snapshot) 524: device->snapshot->recovered = true; 525: 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: MATCH LINES: 665 653: 654: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 655: return 0; 656: 657: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE); 658: 659: adreno_hwsched_start(adreno_dev); 660: 661: if (IS_ENABLED(CONFIG_QCOM_KGSL_HIBERNATION) && 662: !test_bit(GMU_PRIV_PDC_RSC_LOADED, &gmu->flags)) { 663: /* 664: * During hibernation entry ZAP was unloaded and 665: * CBCAST BCL register is in reset state. 666: * Set bcl_enabled to false to skip KMD's HFI request 667: * to GMU for BCL feature, send BCL feature request to 668: * GMU after ZAP load at GPU boot. This ensures that 669: * Central Broadcast register was programmed before 670: * enabling BCL. 671: */ 672: adreno_dev->bcl_enabled = false; 673: ret = gen7_hwsched_gmu_first_boot(adreno_dev); 674: } else { 675: ret = gen7_hwsched_gmu_boot(adreno_dev); 676: } 677: 678: if (ret) 679: return ret; 680: 681: ret = gen7_hwsched_gpu_boot(adreno_dev); 682: if (ret) 683: return ret; 684: 685: kgsl_start_idle_timer(device); 686: kgsl_pwrscale_wake(device); 687: 688: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 689: MATCH LINES: 750, 751 738: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE); 739: 740: ret = gen7_hwsched_gmu_first_boot(adreno_dev); 741: if (ret) 742: return ret; 743: 744: ret = gen7_hwsched_gpu_boot(adreno_dev); 745: if (ret) 746: return ret; 747: 748: adreno_get_bus_counters(adreno_dev); 749: 750: adreno_dev->cooperative_reset = ADRENO_FEATURE(adreno_dev, 751: ADRENO_COOP_RESET); 752: 753: set_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags); 754: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 755: 756: /* 757: * BCL needs respective Central Broadcast register to 758: * be programed from TZ. This programing happens only 759: * when zap shader firmware load is successful. Zap firmware 760: * load can fail in boot up path hence enable BCL only after we 761: * successfully complete first boot to ensure that Central 762: * Broadcast register was programed before enabling BCL. 763: */ 764: if (ADRENO_FEATURE(adreno_dev, ADRENO_BCL)) 765: adreno_dev->bcl_enabled = true; 766: 767: /* 768: * There is a possible deadlock scenario during kgsl firmware reading 769: * (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl 770: * device mutex is held and then firmware_request_nowarn is called for reading 771: * firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock. 772: * Whereas in case of devfreq update calls triggered by thermal/bcl or 773: * devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then 774: * tries to take kgsl device mutex as part of get_dev_status/target 775: * calls. This results in deadlock when both thread are unable to acquire MATCH LINES: 823, 848 811: int id; 812: 813: read_lock(&device->context_lock); 814: idr_for_each_entry(&device->context_idr, context, id) { 815: if (context->gmu_registered) 816: drain_ctx_hw_fences_cpu(adreno_dev, ADRENO_CONTEXT(context)); 817: } 818: read_unlock(&device->context_lock); 819: } 820: 821: /** 822: * check_inflight_hw_fences - During SLUMBER entry, we must make sure all hardware fences across 823: * all registered contexts have been sent to TxQueue. If not, take a snapshot 824: */ 825: static int check_inflight_hw_fences(struct adreno_device *adreno_dev) 826: { 827: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 828: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 829: struct kgsl_context *context; 830: int id, ret = 0; 831: 832: if (!test_bit(ADRENO_HWSCHED_HW_FENCE, &hwsched->flags)) 833: return 0; 834: 835: read_lock(&device->context_lock); 836: idr_for_each_entry(&device->context_idr, context, id) { 837: 838: if (context->gmu_registered) { 839: ret = gen7_hwsched_check_context_inflight_hw_fences(adreno_dev, 840: ADRENO_CONTEXT(context)); 841: if (ret) 842: break; 843: } 844: } 845: read_unlock(&device->context_lock); 846: 847: if (ret) 848: gmu_core_fault_snapshot(device, GMU_FAULT_HW_FENCE); 849: 850: return ret; 851: } 852: 853: static int gen7_hwsched_power_off(struct adreno_device *adreno_dev) 854: { 855: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 856: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 857: int ret = 0; 858: bool drain_cpu = false; 859: 860: if (!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 861: return 0; 862: 863: kgsl_pwrctrl_request_state(device, KGSL_STATE_SLUMBER); 864: 865: ret = gen7_gmu_oob_set(device, oob_gpu); 866: if (ret) { 867: gen7_gmu_oob_clear(device, oob_gpu); 868: goto no_gx_power; 869: } 870: 871: kgsl_pwrscale_update_stats(device); 872: MATCH LINES: 931, 964 919: gen7_hwsched_process_msgq(adreno_dev); 920: 921: spin_lock(&hwf->lock); 922: unack_count = hwf->unack_count; 923: spin_unlock(&hwf->lock); 924: 925: if (!unack_count) 926: return; 927: 928: dev_err(GMU_PDEV_DEV(device), 929: "hardware fence unack_count(%d) isn't zero before SLUMBER\n", 930: unack_count); 931: gmu_core_fault_snapshot(device, GMU_FAULT_HW_FENCE); 932: } 933: 934: static void hwsched_idle_check(struct work_struct *work) 935: { 936: struct kgsl_device *device = container_of(work, 937: struct kgsl_device, idle_check_ws); 938: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 939: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 940: 941: kgsl_mutex_lock(&device->mutex); 942: 943: if (test_bit(GMU_DISABLE_SLUMBER, &device->gmu_core.flags)) 944: goto done; 945: 946: if (atomic_read(&device->active_cnt) || time_is_after_jiffies(device->idle_jiffies)) { 947: kgsl_pwrscale_update(device); 948: goto done; 949: } 950: 951: spin_lock(&device->submit_lock); 952: if (device->submit_now) { 953: spin_unlock(&device->submit_lock); 954: kgsl_pwrscale_update(device); 955: kgsl_start_idle_timer(device); 956: goto done; 957: } 958: 959: device->skip_inline_submit = true; 960: spin_unlock(&device->submit_lock); 961: 962: if (!gpudev->hw_isidle(adreno_dev)) { 963: dev_err(device->dev, "GPU isn't idle before SLUMBER\n"); 964: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE); 965: } 966: 967: check_hw_fence_unack_count(adreno_dev); 968: 969: gen7_hwsched_power_off(adreno_dev); 970: 971: done: 972: kgsl_mutex_unlock(&device->mutex); 973: } 974: 975: static int gen7_hwsched_first_open(struct adreno_device *adreno_dev) 976: { 977: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 978: int ret; 979: 980: /* 981: * Do the one time settings that need to happen when we 982: * attempt to boot the gpu the very first time 983: */ 984: ret = gen7_hwsched_first_boot(adreno_dev); 985: if (ret) 986: return ret; 987: 988: /* MATCH LINES: 1073 1061: if (ret) 1062: return ret; 1063: 1064: ret = gen7_hfi_send_cmd_async(adreno_dev, &req, sizeof(req)); 1065: 1066: if (ret) { 1067: dev_err_ratelimited(GMU_PDEV_DEV(device), 1068: "Failed to set GPU perf idx %u, bw idx %u\n", 1069: req.freq, req.bw); 1070: 1071: /* 1072: * If this was a dcvs request along side an active gpu, request 1073: * dispatcher based reset and recovery. 1074: */ 1075: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 1076: gen7_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 1077: } 1078: 1079: if (req.freq != INVALID_DCVS_IDX) 1080: gmu_core_rdpm_mx_freq_update(device, table->gx_votes[req.freq].freq); 1081: 1082: return ret; 1083: } 1084: 1085: static int gen7_hwsched_clock_set(struct adreno_device *adreno_dev, 1086: u32 pwrlevel) 1087: { 1088: return gen7_hwsched_dcvs_set(adreno_dev, pwrlevel, INVALID_DCVS_IDX, INVALID_AB_VALUE); 1089: } 1090: 1091: static int gen7_hwsched_bus_set(struct adreno_device *adreno_dev, int buslevel, 1092: u32 ab) 1093: { 1094: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1095: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1096: int ret = 0; 1097: MATCH LINES: 1223, 1224, 1225, 1227, 1228, 1253, 1259, 1260, 1263, 1282, 1292, 1301, 1314, 1333, 1334, 1342, 1346, 1356 1211: 1212: read_lock(&hfi->msglock); 1213: 1214: list_for_each_entry(cmd, &hfi->msglist, node) { 1215: if (MSG_HDR_GET_ID(cmd->sent_hdr) == H2F_MSG_UNREGISTER_CONTEXT) 1216: complete(&cmd->complete); 1217: } 1218: 1219: read_unlock(&hfi->msglock); 1220: } 1221: 1222: /** 1223: * process_context_hw_fences_after_reset - This function processes all hardware fences that were 1224: * sent to GMU prior to recovery. If a fence is not retired by the GPU, and the context is still 1225: * good, then move them to the reset list. 1226: */ 1227: static void process_context_hw_fences_after_reset(struct adreno_device *adreno_dev, 1228: struct adreno_context *drawctxt, struct list_head *reset_list) 1229: { 1230: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1231: struct adreno_hw_fence_entry *entry, *tmp; 1232: 1233: spin_lock(&drawctxt->lock); 1234: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_inflight_list, node) { 1235: struct adreno_context *drawctxt = entry->drawctxt; 1236: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr; 1237: bool retired = kgsl_check_timestamp(device, &drawctxt->base, (u32)entry->cmd.ts); 1238: 1239: /* Delete the fences that GMU has sent to the TxQueue */ 1240: if (timestamp_cmp(hdr->out_fence_ts, (u32)entry->cmd.ts) >= 0) { 1241: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 1242: continue; 1243: } 1244: 1245: /* 1246: * Force retire the fences if the ts is retired and context is not 1247: * registered with GMU, or if the context is gone bad. 1248: */ 1249: if ((retired && !drawctxt->base.gmu_registered) || 1250: kgsl_context_is_bad(&drawctxt->base)) 1251: entry->cmd.flags |= HW_FENCE_FLAG_SKIP_MEMSTORE; 1252: 1253: list_add_tail(&entry->reset_node, reset_list); 1254: } 1255: spin_unlock(&drawctxt->lock); 1256: } 1257: 1258: /** 1259: * process_inflight_hw_fences_after_reset - Send hardware fences from all contexts back to the GMU 1260: * after fault recovery. We must wait for ack when sending each of these fences to GMU so as to 1261: * avoid sending a large number of hardware fences in a short span of time. 1262: */ 1263: static int process_inflight_hw_fences_after_reset(struct adreno_device *adreno_dev) 1264: { 1265: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1266: struct kgsl_context *context = NULL; 1267: int id, ret = 0; 1268: struct list_head hw_fence_list; 1269: struct adreno_hw_fence_entry *entry, *tmp; 1270: bool update_out_fence_ts = false; 1271: 1272: /* 1273: * Since we need to wait for ack from GMU when sending each inflight fence back to GMU, we 1274: * cannot send them from within atomic context. Hence, walk list of such hardware fences 1275: * for each context and add it to this local list and then walk this list to send all these 1276: * fences to GMU. 1277: */ 1278: INIT_LIST_HEAD(&hw_fence_list); 1279: 1280: read_lock(&device->context_lock); 1281: idr_for_each_entry(&device->context_idr, context, id) { 1282: process_context_hw_fences_after_reset(adreno_dev, ADRENO_CONTEXT(context), 1283: &hw_fence_list); 1284: } 1285: read_unlock(&device->context_lock); 1286: 1287: /* 1288: * Although we are not destroying the entries here, they can get destroyed concurrently 1289: * in f2h_main thread once they have been sent to GMU. Hence, to be safe against entry 1290: * destroy, use list_for_each_entry_safe. 1291: */ 1292: list_for_each_entry_safe(entry, tmp, &hw_fence_list, reset_node) { 1293: struct adreno_context *drawctxt = entry->drawctxt; 1294: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr; 1295: u32 entry_ts = (u32)entry->cmd.ts; 1296: 1297: /* 1298: * We must remove this entry from hw_fence_list before sending it to GMU to avoid 1299: * racing with the f2h_main thread 1300: */ 1301: list_del_init(&entry->reset_node); 1302: 1303: /* 1304: * We must access the hw fence entry before sending it to GMU as once it is 1305: * sent to GMU, it may be freed by f2h_main thread concurrently 1306: */ 1307: if (((entry->cmd.flags & HW_FENCE_FLAG_SKIP_MEMSTORE) != 0) && 1308: (timestamp_cmp(entry_ts, hdr->out_fence_ts) > 0)) { 1309: if (_kgsl_context_get(&drawctxt->base)) 1310: update_out_fence_ts = true; 1311: } 1312: 1313: /* 1314: * This is part of the reset sequence and any error in this path will be handled by 1315: * the caller. 1316: */ 1317: ret = gen7_send_hw_fence_hfi_wait_ack(adreno_dev, entry, 0); 1318: if (ret) 1319: break; 1320: /* 1321: * If HW_FENCE_FLAG_SKIP_MEMSTORE is set, then GMU context queue header will not be 1322: * updated for this fence. Hence, update it here. 1323: */ 1324: if (update_out_fence_ts) { 1325: hdr->out_fence_ts = entry_ts; 1326: kgsl_context_put(&drawctxt->base); 1327: update_out_fence_ts = false; 1328: } 1329: } 1330: 1331: /* Remove remaining entries from the list if we hit an error */ 1332: if (ret) { 1333: list_for_each_entry_safe(entry, tmp, &hw_fence_list, reset_node) { 1334: list_del_init(&entry->reset_node); 1335: } 1336: } 1337: 1338: return ret; 1339: } 1340: 1341: /** 1342: * process_detached_hw_fences_after_reset - Send fences that couldn't be sent to GMU when a context 1343: * got detached. We must wait for ack when sending each of these fences to GMU so as to avoid 1344: * sending a large number of hardware fences in a short span of time. 1345: */ 1346: static int process_detached_hw_fences_after_reset(struct adreno_device *adreno_dev) 1347: { 1348: struct adreno_hw_fence_entry *entry, *tmp; 1349: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev); 1350: struct kgsl_context *context = NULL; 1351: int ret = 0; 1352: 1353: list_for_each_entry_safe(entry, tmp, &hfi->detached_hw_fence_list, node) { 1354: 1355: /* 1356: * This is part of the reset sequence and any error in this path will be handled by 1357: * the caller. 1358: */ 1359: ret = gen7_send_hw_fence_hfi_wait_ack(adreno_dev, entry, 1360: HW_FENCE_FLAG_SKIP_MEMSTORE); 1361: if (ret) 1362: return ret; 1363: 1364: context = &entry->drawctxt->base; 1365: 1366: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 1367: 1368: kgsl_context_put(context); 1369: } 1370: 1371: return ret; 1372: } 1373: 1374: static int gen7_hwsched_drain_context_hw_fences(struct adreno_device *adreno_dev, 1375: struct adreno_context *drawctxt) 1376: { 1377: struct adreno_hw_fence_entry *entry, *tmp; 1378: int ret = 0; 1379: 1380: /* We don't need the drawctxt lock here as this context has already been invalidated */ MATCH LINES: 1423, 1439, 1451, 1455, 1462, 1470, 1495, 1501, 1512 1411: return guilty; 1412: } 1413: 1414: static int drain_guilty_context_hw_fences(struct adreno_device *adreno_dev) 1415: { 1416: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1417: struct adreno_context *guilty = _get_guilty_context(device); 1418: int ret = 0; 1419: 1420: /* 1421: * We don't need drawctxt spinlock to signal these fences since the only other place 1422: * which can access these fences is the context detach path and device mutex 1423: * ensures mutual exclusion between recovery thread and detach thread. 1424: */ 1425: while (guilty) { 1426: ret = gen7_hwsched_drain_context_hw_fences(adreno_dev, guilty); 1427: 1428: kgsl_context_put(&guilty->base); 1429: 1430: if (ret) 1431: break; 1432: 1433: guilty = _get_guilty_context(device); 1434: } 1435: 1436: return ret; 1437: } 1438: 1439: static int handle_hw_fences_after_reset(struct adreno_device *adreno_dev) 1440: { 1441: int ret; 1442: 1443: ret = drain_guilty_context_hw_fences(adreno_dev); 1444: if (ret) 1445: return ret; 1446: 1447: /* 1448: * We must do this after adreno_hwsched_replay() so that context registration 1449: * is done before we re-send the un-retired hardware fences to the GMU 1450: */ 1451: ret = process_inflight_hw_fences_after_reset(adreno_dev); 1452: if (ret) 1453: return ret; 1454: 1455: ret = process_detached_hw_fences_after_reset(adreno_dev); 1456: if (ret) 1457: return ret; 1458: 1459: return gen7_hwsched_disable_hw_fence_throttle(adreno_dev); 1460: } 1461: 1462: int gen7_hwsched_reset_replay(struct adreno_device *adreno_dev) 1463: { 1464: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1465: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 1466: int ret; 1467: 1468: /* 1469: * Any pending context unregister packets will be lost 1470: * since we hard reset the GMU. This means any threads waiting 1471: * for context unregister hfi ack will timeout. Wake them 1472: * to avoid false positive ack timeout messages later. 1473: */ 1474: gen7_hwsched_drain_ctxt_unregister(adreno_dev); 1475: 1476: if (!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 1477: return 0; 1478: 1479: gen7_disable_gpu_irq(adreno_dev); 1480: 1481: gen7_gmu_irq_disable(adreno_dev); 1482: 1483: gen7_hwsched_hfi_stop(adreno_dev); 1484: 1485: gen7_hwsched_gmu_suspend(adreno_dev, true); 1486: 1487: adreno_hwsched_unregister_contexts(adreno_dev); 1488: 1489: adreno_llcc_slice_deactivate(adreno_dev); 1490: 1491: clear_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 1492: 1493: spin_lock(&hwf->lock); 1494: 1495: /* Reset the unack count back to zero as we start afresh */ 1496: hwf->unack_count = 0; 1497: 1498: spin_unlock(&hwf->lock); 1499: 1500: /* 1501: * When we reset, we want to coldboot incase any scratch corruption 1502: * has occurred before we faulted. 1503: */ 1504: gmu_core_mark_for_coldboot(KGSL_DEVICE(adreno_dev)); 1505: 1506: ret = gen7_hwsched_boot(adreno_dev); 1507: if (ret) 1508: goto done; 1509: 1510: adreno_hwsched_replay(adreno_dev); 1511: 1512: ret = handle_hw_fences_after_reset(adreno_dev); 1513: done: 1514: BUG_ON(ret); 1515: 1516: return ret; 1517: } 1518: 1519: static void gen7_hwsched_set_thermal_index(struct adreno_device *adreno_dev) 1520: { 1521: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1522: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1523: int ret; 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 = { MATCH LINES: 1591 1579: INIT_WORK(&device->idle_check_ws, hwsched_idle_check); 1580: 1581: timer_setup(&device->idle_timer, hwsched_idle_timer, 0); 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: --- FILE: \adreno_gen7_hwsched.h | HITS: 8 --- MATCH LINES: 36, 41, 44, 46, 48, 50, 51, 80 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 gen7_hwsched_probe(struct platform_device *pdev, 33: u32 chipid, const struct adreno_gpu_core *gpucore); 34: 35: /** 36: * gen7_hwsched_reset_replay - Restart the gmu and gpu and replay inflight cmdbatches 37: * @adreno_dev: Pointer to the adreno device 38: * 39: * Return: 0 on success or negative error on failure 40: */ 41: int gen7_hwsched_reset_replay(struct adreno_device *adreno_dev); 42: 43: /** 44: * gen7_hwsched_snapshot - take gen7 hwsched snapshot 45: * @adreno_dev: Pointer to the adreno device 46: * @snapshot: Pointer to the snapshot instance 47: * 48: * Snapshot the faulty ib and then snapshot rest of gen7 gmu things 49: */ 50: void gen7_hwsched_snapshot(struct adreno_device *adreno_dev, 51: struct kgsl_snapshot *snapshot); 52: 53: /** 54: * gen7_hwsched_handle_watchdog - Handle watchdog interrupt 55: * @adreno_dev: Pointer to the adreno device 56: */ 57: void gen7_hwsched_handle_watchdog(struct adreno_device *adreno_dev); 58: 59: /** 60: * gen7_hwsched_add_to_minidump - Register hwsched_device with va minidump 61: * @adreno_dev: Pointer to the adreno device 62: */ 63: int gen7_hwsched_add_to_minidump(struct adreno_device *adreno_dev); 64: 65: /** 66: * gen7_hwsched_send_recurring_cmdobj - Dispatch IBs to GMU 67: * @adreno_dev: Pointer to adreno device structure 68: * @cmdobj: The command object which needs to be submitted 69: * 70: * This function is used to register the context if needed and submit 71: * recurring IBs to the GMU. Upon receiving ipc interrupt GMU will submit 72: * recurring IBs to GPU. 73: 74: * Return: 0 on success and negative error on failure 75: */ 76: int gen7_hwsched_send_recurring_cmdobj(struct adreno_device *adreno_dev, 77: struct kgsl_drawobj_cmd *cmdobj); 78: 79: /** 80: * gen7_hwsched_fault - Set hwsched fault to request recovery 81: * @adreno_dev: A handle to adreno device 82: * @fault: The type of fault 83: */ 84: void gen7_hwsched_fault(struct adreno_device *adreno_dev, u32 fault); 85: 86: #endif --- FILE: \adreno_gen7_hwsched_hfi.c | HITS: 38 --- MATCH LINES: 274 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; 293: case GMU_CP_PROTECTED_ERROR: { 294: u32 status = gen7_hwsched_lookup_key_value_legacy(adreno_dev, PAYLOAD_FAULT_REGS, 295: KEY_CP_PROTECTED_ERROR); 296: 297: dev_crit_ratelimited(gmu_pdev_dev, 298: "CP | Protected mode error | %s | addr=0x%5.5x | status=0x%8.8x\n", MATCH LINES: 443, 449 431: while (i < payload_bytes) { 432: struct payload_section *payload = start + i; 433: 434: if (payload->type == type) 435: return adreno_hwsched_parse_payload(payload, key); 436: 437: i += struct_size(payload, data, payload->dwords); 438: } 439: 440: return 0; 441: } 442: 443: static bool log_gpu_fault(struct adreno_device *adreno_dev) 444: { 445: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)); 446: struct hfi_context_bad_cmd *cmd = adreno_dev->hwsched.ctxt_bad; 447: 448: /* Return false for non fatal errors */ 449: if (adreno_hwsched_log_nonfatal_gpu_fault(adreno_dev, gmu_pdev_dev, cmd->error)) 450: return false; 451: 452: switch (cmd->error) { 453: case GMU_GPU_HW_HANG: 454: dev_crit_ratelimited(gmu_pdev_dev, "MISC: GPU hang detected\n"); 455: break; 456: case GMU_GPU_SW_HANG: 457: dev_crit_ratelimited(gmu_pdev_dev, "gpu timeout ctx %u ts %u\n", 458: cmd->gc.ctxt_id, cmd->gc.ts); 459: break; 460: case GMU_CP_OPCODE_ERROR: 461: dev_crit_ratelimited(gmu_pdev_dev, 462: "CP opcode error interrupt | opcode=0x%8.8x\n", 463: gen7_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 464: KEY_CP_OPCODE_ERROR)); 465: break; 466: case GMU_CP_PROTECTED_ERROR: { 467: u32 status = gen7_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 468: KEY_CP_PROTECTED_ERROR); 469: 470: dev_crit_ratelimited(gmu_pdev_dev, 471: "CP | Protected mode error | %s | addr=0x%5.5x | status=0x%8.8x\n", 472: status & (1 << 20) ? "READ" : "WRITE", 473: status & 0x3FFFF, status); MATCH LINES: 619 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) 634: return true; 635: 636: /* 637: * This is to ensure that the queue is not read speculatively before the queue empty 638: * condition is evaluated 639: */ 640: rmb(); 641: 642: return false; 643: } MATCH LINES: 666, 670, 671 654: return 0; 655: 656: queue = HOST_QUEUE_START_ADDR(mem_addr, queue_idx); 657: 658: return queue[hdr->read_index]; 659: } 660: 661: static void process_ctx_bad(struct adreno_device *adreno_dev) 662: { 663: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 664: 665: if (GMU_VER_MINOR(device->gmu_core.ver.hfi) < 2) { 666: log_gpu_fault_legacy(adreno_dev); 667: goto done; 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); MATCH LINES: 794 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: MATCH LINES: 862 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. 863: */ 864: #define HW_FENCE_SLEEP_MS 200 865: 866: static void _enable_hw_fence_throttle(struct adreno_device *adreno_dev) 867: { 868: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev); 869: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 870: 871: set_bit(GEN7_HWSCHED_HW_FENCE_SLEEP_BIT, &hwf->flags); 872: set_bit(GEN7_HWSCHED_HW_FENCE_MAX_BIT, &hwf->flags); 873: 874: /* Avoid submitting new work to gpu until the unack count drops to a desired threshold */ 875: adreno_get_gpu_halt(adreno_dev); 876: 877: mod_timer(&hfi->hw_fence_timer, jiffies + msecs_to_jiffies(HW_FENCE_SLEEP_MS)); 878: } 879: 880: static void _increment_hw_fence_unack_count(struct adreno_device *adreno_dev) 881: { 882: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 883: 884: if ((++hwf->unack_count) == MAX_HW_FENCE_UNACK_COUNT) 885: _enable_hw_fence_throttle(adreno_dev); 886: } MATCH LINES: 1027, 1042 1015: struct gen7_hwsched_hfi, defer_hw_fence_work); 1016: struct gen7_hwsched_device *gen7_hwsched = container_of(hfi, struct gen7_hwsched_device, 1017: hwsched_hfi); 1018: struct adreno_context *drawctxt; 1019: struct adreno_device *adreno_dev = &gen7_hwsched->gen7_dev.adreno_dev; 1020: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1021: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 1022: u32 ts; 1023: int ret; 1024: 1025: /* 1026: * Grab the dispatcher and device mutex as we don't want to race with concurrent fault 1027: * recovery 1028: */ 1029: mutex_lock(&adreno_dev->hwsched.mutex); 1030: kgsl_mutex_lock(&device->mutex); 1031: 1032: spin_lock(&hwf->lock); 1033: drawctxt = hwf->defer_drawctxt; 1034: ts = hwf->defer_ts; 1035: spin_unlock(&hwf->lock); 1036: 1037: if (!drawctxt) 1038: goto unlock; 1039: 1040: ret = process_hw_fence_deferred_ctxt(adreno_dev, drawctxt, ts); 1041: if (ret) { 1042: /* the deferred drawctxt will be handled post fault recovery */ 1043: gen7_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 1044: goto unlock; 1045: } 1046: 1047: /* 1048: * Put back the context reference which was incremented when hw_fence.defer_drawctxt was set 1049: */ 1050: kgsl_context_put(&drawctxt->base); 1051: 1052: adreno_active_count_put(adreno_dev); 1053: 1054: _disable_hw_fence_throttle(adreno_dev, false); 1055: 1056: unlock: 1057: kgsl_mutex_unlock(&device->mutex); 1058: mutex_unlock(&adreno_dev->hwsched.mutex); 1059: } 1060: 1061: static int _check_hw_fence_ack_failure(struct kgsl_device *device, u32 *result) 1062: { 1063: if (!result[2]) 1064: return 0; 1065: 1066: dev_err(GMU_PDEV_DEV(device), MATCH LINES: 1219, 1225, 1240 1207: log_event += start * 4; 1208: while (start != end) { 1209: trace_gmu_event(log_event); 1210: log_event += 4; 1211: start++; 1212: } 1213: } 1214: 1215: static void gen7_hwsched_process_dbgq(struct adreno_device *adreno_dev, bool limited) 1216: { 1217: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1218: u32 rcvd[MAX_RCVD_SIZE]; 1219: bool recovery = false; 1220: 1221: while (gen7_hfi_queue_read(gmu, HFI_DBG_ID, rcvd, sizeof(rcvd)) > 0) { 1222: 1223: if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_ERR) { 1224: adreno_gen7_receive_err_req(gmu, rcvd); 1225: recovery = true; 1226: break; 1227: } 1228: 1229: if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_DEBUG) 1230: adreno_gen7_receive_debug_req(gmu, rcvd); 1231: 1232: if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_LOG_BLOCK) 1233: process_log_block(adreno_dev, rcvd); 1234: 1235: /* Process one debug queue message and return to not delay msgq processing */ 1236: if (limited) 1237: break; 1238: } 1239: 1240: if (!recovery) 1241: return; 1242: 1243: gen7_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 1244: } 1245: 1246: /* HFI interrupt handler */ 1247: static irqreturn_t gen7_hwsched_hfi_handler(int irq, void *data) 1248: { 1249: struct adreno_device *adreno_dev = data; 1250: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1251: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev); 1252: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1253: u32 status = 0; 1254: 1255: /* 1256: * GEN7_GMU_GMU2HOST_INTR_INFO may have bits set not specified in hfi->irq_mask. 1257: * Read and clear only those irq bits that we are processing here. 1258: */ 1259: gmu_core_regread(device, GEN7_GMU_GMU2HOST_INTR_INFO, &status); 1260: gmu_core_regwrite(device, GEN7_GMU_GMU2HOST_INTR_CLR, status & hfi->irq_mask); 1261: 1262: /* 1263: * If interrupts are not enabled on the HFI message queue, 1264: * the inline message processing loop will process it, MATCH LINES: 1542, 1551, 1578, 1598, 1625, 1629 1530: 1531: rc = gen7_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd)); 1532: if (rc) 1533: return rc; 1534: 1535: poll: 1536: rc = adreno_hwsched_poll_msg_queue_write_index(gmu->hfi.hfi_mem); 1537: 1538: if (rc) { 1539: dev_err(gmu_pdev_dev, 1540: "Timed out processing MSG_START seqnum: %d\n", 1541: seqnum); 1542: gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START); 1543: goto done; 1544: } 1545: 1546: rc = gen7_hfi_queue_read(gmu, HFI_MSG_ID, rcvd, sizeof(rcvd)); 1547: if (rc <= 0) { 1548: dev_err(gmu_pdev_dev, 1549: "MSG_START: payload error: %d\n", 1550: rc); 1551: gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START); 1552: goto done; 1553: } 1554: 1555: switch (MSG_HDR_GET_ID(rcvd[0])) { 1556: case F2H_MSG_MEM_ALLOC: 1557: rc = mem_alloc_reply(adreno_dev, rcvd); 1558: break; 1559: case F2H_MSG_GMU_CNTR_REGISTER: 1560: rc = gmu_cntr_register_reply(adreno_dev, rcvd); 1561: break; 1562: case F2H_MSG_PROCESS_TRACE: 1563: rc = 0; 1564: gmu_core_process_trace_data(device, GMU_PDEV_DEV(device), &device->gmu_core.trace); 1565: break; 1566: default: 1567: if (MSG_HDR_GET_TYPE(rcvd[0]) == HFI_MSG_ACK) { 1568: rc = gen7_receive_ack_cmd(gmu, rcvd, &pending_ack); 1569: /* Check ack failure if we received an expected ack */ 1570: if (!rc) 1571: rc = check_ack_failure(adreno_dev, &pending_ack); 1572: goto done; 1573: } else { 1574: dev_err(gmu_pdev_dev, 1575: "MSG_START: unexpected response id:%d, type:%d\n", 1576: MSG_HDR_GET_ID(rcvd[0]), 1577: MSG_HDR_GET_TYPE(rcvd[0])); 1578: gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START); 1579: rc = -EINVAL; 1580: goto done; 1581: } 1582: } 1583: 1584: if (!rc) 1585: goto poll; 1586: 1587: done: 1588: /* Clear the interrupt */ 1589: gmu_core_regwrite(device, GEN7_GMU_GMU2HOST_INTR_CLR, HFI_IRQ_MSGQ_MASK); 1590: /* 1591: * Add a write barrier to post the interrupt clear so that we dont have a 1592: * pending interrupt. 1593: */ 1594: wmb(); 1595: return rc; 1596: } 1597: 1598: static void reset_hfi_queues(struct adreno_device *adreno_dev) 1599: { 1600: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1601: struct hfi_queue_table *tbl = gmu->hfi.hfi_mem->hostptr; 1602: u32 i; 1603: 1604: /* Flush HFI queues */ 1605: for (i = 0; i < HFI_QUEUE_MAX; i++) { 1606: struct hfi_queue_header *hdr = &tbl->qhdr[i]; 1607: 1608: if (hdr->status == HFI_QUEUE_STATUS_DISABLED) 1609: continue; 1610: 1611: hdr->read_index = hdr->write_index; 1612: } 1613: } 1614: 1615: void gen7_hwsched_hfi_stop(struct adreno_device *adreno_dev) 1616: { 1617: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1618: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev); 1619: 1620: hfi->irq_mask &= ~HFI_IRQ_MSGQ_MASK; 1621: 1622: /* 1623: * In some corner cases, it is possible that GMU put TS_RETIRE 1624: * on the msgq after we have turned off gmu interrupts. Hence, 1625: * drain the queue one last time before we reset HFI queues. 1626: */ 1627: gen7_hwsched_process_msgq(adreno_dev); 1628: 1629: /* Drain the debug queue before we reset HFI queues */ 1630: gen7_hwsched_process_dbgq(adreno_dev, false); 1631: 1632: kgsl_pwrctrl_axi(KGSL_DEVICE(adreno_dev), false); 1633: 1634: clear_bit(GMU_PRIV_HFI_STARTED, &gmu->flags); 1635: } 1636: 1637: static void gen7_hwsched_enable_async_hfi(struct adreno_device *adreno_dev) 1638: { 1639: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev); 1640: 1641: hfi->irq_mask |= HFI_IRQ_MSGQ_MASK; 1642: 1643: gmu_core_regwrite(KGSL_DEVICE(adreno_dev), GEN7_GMU_GMU2HOST_INTR_MASK, 1644: (u32)~hfi->irq_mask); 1645: } 1646: 1647: static int enable_preemption(struct adreno_device *adreno_dev) 1648: { 1649: const struct adreno_gen7_core *gen7_core = to_gen7_core(adreno_dev); 1650: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1651: u32 data; 1652: int ret; 1653: MATCH LINES: 1900 1888: kgsl_regread(device, GEN7_RBBM_STATUS, &status); 1889: kgsl_regread(device, GEN7_RBBM_STATUS3, &status3); 1890: kgsl_regread(device, GEN7_RBBM_INT_0_STATUS, &intstatus); 1891: kgsl_regread(device, GEN7_CP_HW_FAULT, &hwfault); 1892: 1893: dev_err(device->dev, 1894: "LPAC rb=%d pos=%X/%X rbbm_status=%8.8X/%8.8X int_0_status=%8.8X\n", 1895: val ? KGSL_LPAC_RB_ID : 1, rptr, wptr, 1896: status, status3, intstatus); 1897: 1898: dev_err(device->dev, " hwfault=%8.8X\n", hwfault); 1899: 1900: kgsl_device_snapshot(device, NULL, NULL, false); 1901: } 1902: 1903: static bool gen7_hwsched_warmboot_possible(struct adreno_device *adreno_dev) 1904: { 1905: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 1906: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1907: struct gmu_core_device *gmu_core = &device->gmu_core; 1908: 1909: if (gmu_core->warmboot_enabled && test_bit(GMU_PRIV_WARMBOOT_GMU_INIT_DONE, &gmu->flags) 1910: && test_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags) && 1911: !test_bit(GMU_FORCE_COLDBOOT, &device->gmu_core.flags)) 1912: return true; 1913: 1914: return false; 1915: } 1916: 1917: static int gen7_hwsched_hfi_send_warmboot_cmd(struct adreno_device *adreno_dev, 1918: struct kgsl_memdesc *desc, u32 flag, bool async, struct pending_cmd *ack) 1919: { 1920: struct hfi_warmboot_scratch_cmd cmd = {0}; 1921: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1922: struct gmu_core_device *gmu_core = &device->gmu_core; 1923: int ret; 1924: MATCH LINES: 2120, 2137 2108: clear_bit(H2F_MSG_GET_VALUE, hfi->wb_set_record_bitmask); 2109: clear_bit(H2F_MSG_GX_BW_PERF_VOTE, hfi->wb_set_record_bitmask); 2110: } 2111: 2112: int gen7_hwsched_hfi_start(struct adreno_device *adreno_dev) 2113: { 2114: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2115: struct gmu_core_device *gmu_core = &device->gmu_core; 2116: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 2117: struct pending_cmd ack = {0}; 2118: int ret; 2119: 2120: reset_hfi_queues(adreno_dev); 2121: 2122: ret = gen7_gmu_hfi_start(adreno_dev); 2123: if (ret) 2124: goto err; 2125: 2126: if (gen7_hwsched_warmboot_possible(adreno_dev)) 2127: return gen7_hwsched_warmboot_init_gmu(adreno_dev); 2128: 2129: if (ADRENO_FEATURE(adreno_dev, ADRENO_GMU_WARMBOOT) && 2130: (!test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags))) { 2131: if (gen7_hfi_send_get_value(adreno_dev, HFI_VALUE_GMU_WARMBOOT, 0) == 1) 2132: gmu_core->warmboot_enabled = true; 2133: } 2134: 2135: warmboot_init_message_record_bitmask(adreno_dev); 2136: 2137: /* Reset the variable here and set it when we successfully record the scratch */ 2138: clear_bit(GMU_PRIV_WARMBOOT_GMU_INIT_DONE, &gmu->flags); 2139: clear_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags); 2140: 2141: ret = gen7_hwsched_hfi_send_warmboot_cmd(adreno_dev, gmu->gmu_init_scratch, 2142: HFI_WARMBOOT_SET_SCRATCH, false, &ack); 2143: if (ret) 2144: goto err; 2145: 2146: ret = gen7_hfi_send_gpu_perf_table(adreno_dev); 2147: if (ret) 2148: goto err; 2149: 2150: ret = gen7_hfi_send_generic_req(adreno_dev, &gmu->hfi.bw_table, sizeof(gmu->hfi.bw_table)); 2151: if (ret) 2152: goto err; 2153: 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: MATCH LINES: 2861, 2862 2849: break; 2850: } 2851: 2852: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 2853: } 2854: spin_unlock(&drawctxt->lock); 2855: 2856: return ret; 2857: } 2858: 2859: /** 2860: * move_detached_context_hardware_fences - Move all pending hardware fences belonging to this 2861: * context to the detached hardware fence list so as to send them to TxQueue after fault recovery. 2862: * This is needed because this context may get destroyed before fault recovery gets executed. 2863: */ 2864: static void move_detached_context_hardware_fences(struct adreno_device *adreno_dev, 2865: struct adreno_context *drawctxt) 2866: { 2867: struct adreno_hw_fence_entry *entry, *tmp; 2868: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev); 2869: 2870: spin_lock(&drawctxt->lock); 2871: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_inflight_list, node) { 2872: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr; 2873: 2874: if ((timestamp_cmp((u32)entry->cmd.ts, hdr->out_fence_ts) > 0)) { 2875: _kgsl_context_get(&drawctxt->base); 2876: list_move_tail(&entry->node, &hfi->detached_hw_fence_list); 2877: continue; 2878: } 2879: 2880: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 2881: } 2882: 2883: spin_unlock(&drawctxt->lock); 2884: 2885: /* Also grab all the hardware fences which were never sent to GMU */ 2886: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_list, node) { MATCH LINES: 2911, 2923, 2957 2899: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_list, node) { 2900: 2901: ret = gen7_send_hw_fence_hfi_wait_ack(adreno_dev, entry, 2902: HW_FENCE_FLAG_SKIP_MEMSTORE); 2903: if (ret) 2904: break; 2905: 2906: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 2907: } 2908: 2909: if (ret) { 2910: move_detached_context_hardware_fences(adreno_dev, drawctxt); 2911: gmu_core_fault_snapshot(KGSL_DEVICE(adreno_dev), GMU_FAULT_HW_FENCE); 2912: gen7_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 2913: } 2914: 2915: return ret; 2916: } 2917: 2918: /** 2919: * check_detached_context_hardware_fences - When this context has been un-registered with the GMU, 2920: * make sure all the hardware fences(that were sent to GMU) for this context have been sent to 2921: * TxQueue. Also, send any hardware fences (to GMU) that were not yet dispatched to the GMU. In case 2922: * of an error, move the pending hardware fences to detached hardware fence list, log the error, 2923: * take a snapshot and trigger recovery. 2924: */ 2925: static int check_detached_context_hardware_fences(struct adreno_device *adreno_dev, 2926: struct adreno_context *drawctxt) 2927: { 2928: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2929: struct adreno_hw_fence_entry *entry, *tmp; 2930: int ret = 0; 2931: u32 id, ts, fence_ts; 2932: 2933: spin_lock(&drawctxt->lock); 2934: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_inflight_list, node) { 2935: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr; 2936: 2937: if ((timestamp_cmp((u32)entry->cmd.ts, hdr->out_fence_ts) > 0)) { 2938: id = drawctxt->base.id; 2939: ts = (u32)entry->cmd.ts; 2940: fence_ts = hdr->out_fence_ts; 2941: 2942: spin_unlock(&drawctxt->lock); 2943: dev_err(GMU_PDEV_DEV(device), 2944: "detached ctx:%d has unsignaled fence ts:%d retired:%d\n", 2945: id, ts, fence_ts); 2946: ret = -EINVAL; 2947: goto fault; 2948: } 2949: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 2950: } 2951: 2952: spin_unlock(&drawctxt->lock); 2953: return drain_context_hw_fence_gmu(adreno_dev, drawctxt); 2954: 2955: fault: 2956: move_detached_context_hardware_fences(adreno_dev, drawctxt); 2957: gmu_core_fault_snapshot(device, GMU_FAULT_HW_FENCE); 2958: gen7_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 2959: 2960: return ret; 2961: } 2962: 2963: static inline int setup_hw_fence_info_cmd(struct adreno_device *adreno_dev, 2964: struct adreno_hw_fence_entry *entry) 2965: { 2966: struct kgsl_sync_fence *kfence = entry->kfence; 2967: int ret; 2968: 2969: ret = CMD_MSG_HDR(entry->cmd, H2F_MSG_HW_FENCE_INFO); 2970: if (ret) 2971: return ret; 2972: 2973: ret = kgsl_hw_fence_create(KGSL_DEVICE(adreno_dev), kfence); 2974: if (ret) 2975: return ret; 2976: 2977: entry->cmd.gmu_ctxt_id = entry->drawctxt->base.id; 2978: entry->cmd.ctxt_id = kfence->fence.context; 2979: entry->cmd.ts = kfence->fence.seqno; 2980: 2981: entry->cmd.hash_index = kfence->hw_fence_index; MATCH LINES: 3032 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: { 3049: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 3050: struct adreno_hw_fence_entry *entry; 3051: 3052: if (!kgsl_hw_fence_tx_slot_available(KGSL_DEVICE(adreno_dev), 3053: hwsched->hw_fence.pending_count)) 3054: return NULL; 3055: 3056: if (!DRAWCTXT_SLOT_AVAILABLE(drawctxt->hw_fence_count)) MATCH LINES: 3083 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 */ 3102: list_for_each_entry_reverse(entry, &drawctxt->hw_fence_list, node) { 3103: if (timestamp_cmp(ts, (u32)entry->cmd.ts) > 0) 3104: break; 3105: } 3106: 3107: list_add(&new->node, &entry->node); MATCH LINES: 3128, 3157, 3158 3116: ret = !test_bit(GEN7_HWSCHED_HW_FENCE_SLEEP_BIT, &hwf->flags); 3117: spin_unlock(&hwf->lock); 3118: 3119: return ret; 3120: } 3121: 3122: /** 3123: * _hw_fence_sleep() - Check if the thread needs to sleep until the hardware fence unack count 3124: * drops to a desired threshold. 3125: * 3126: * Return: negative error code if the thread was woken up by a signal, or the context became bad in 3127: * the meanwhile, or the hardware fence unack count hasn't yet dropped to a desired threshold, or 3128: * if fault recovery is imminent. 3129: * Otherwise, return 0. 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, 3167: struct kgsl_sync_fence *kfence) 3168: { 3169: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 3170: struct kgsl_sync_timeline *ktimeline = kfence->parent; 3171: struct kgsl_context *context = ktimeline->context; 3172: struct adreno_context *drawctxt = ADRENO_CONTEXT(context); 3173: struct adreno_hw_fence_entry *entry = NULL; 3174: /* Only allow a single log in a second */ 3175: static DEFINE_RATELIMIT_STATE(_rs, HZ, 1); 3176: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 3177: u32 retired = 0; 3178: int ret = 0; 3179: bool destroy = false; 3180: u32 hw_fence_last_ts; 3181: 3182: spin_lock(&drawctxt->lock); MATCH LINES: 3204 3192: if (timestamp_cmp(hw_fence_last_ts, kfence->timestamp) >= 0) 3193: goto done; 3194: 3195: drawctxt->hw_fence_last_ts = kfence->timestamp; 3196: 3197: /* 3198: * If we create a hardware fence and this context is going away, we may never dispatch 3199: * this fence to the GMU. Hence, avoid creating a hardware fence if context is going away. 3200: */ 3201: if (kgsl_context_is_bad(context)) 3202: goto done; 3203: 3204: /* If recovery is imminent, then do not create a hardware fence */ 3205: if (test_bit(GEN7_HWSCHED_HW_FENCE_ABORT_BIT, &hwf->flags)) 3206: goto done; 3207: 3208: ret = _hw_fence_sleep(adreno_dev, drawctxt); 3209: if (ret) 3210: goto done; 3211: 3212: /* 3213: * If this ts hasn't been submitted yet, then store it in the drawctxt hardware fence 3214: * list and return. This fence will be sent to GMU when this ts is dispatched to GMU. 3215: */ 3216: if (timestamp_cmp(kfence->timestamp, drawctxt->gmu_hw_fence_ready_ts) > 0) { 3217: drawctxt_queue_hw_fence(adreno_dev, drawctxt, kfence); 3218: goto done; 3219: } 3220: 3221: kgsl_readtimestamp(device, context, KGSL_TIMESTAMP_RETIRED, &retired); 3222: 3223: /* 3224: * Check if timestamp is retired. If we are in SLUMBER at this point, the timestamp is 3225: * guaranteed to be retired. This way, we don't need the device mutex to check the device 3226: * state explicitly. 3227: */ 3228: if (timestamp_cmp(retired, kfence->timestamp) >= 0) { MATCH LINES: 3524 3512: 3513: int gen7_hwsched_send_recurring_cmdobj(struct adreno_device *adreno_dev, 3514: struct kgsl_drawobj_cmd *cmdobj) 3515: { 3516: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 3517: struct kgsl_drawobj *drawobj = DRAWOBJ(cmdobj); 3518: struct hfi_submit_cmd *cmd; 3519: struct kgsl_memobj_node *ib; 3520: u32 cmd_sizebytes; 3521: int ret; 3522: static bool active; 3523: 3524: if (adreno_gpu_halt(adreno_dev) || adreno_gpu_fault(adreno_dev)) 3525: return -EBUSY; 3526: 3527: if (test_bit(CMDOBJ_RECURRING_STOP, &cmdobj->priv)) { 3528: cmdobj->numibs = 0; 3529: } else { 3530: list_for_each_entry(ib, &cmdobj->cmdlist, node) 3531: cmdobj->numibs++; 3532: } 3533: 3534: if (cmdobj->numibs > HWSCHED_MAX_IBS) 3535: return -EINVAL; 3536: 3537: if (cmdobj->numibs > HWSCHED_MAX_DISPATCH_NUMIBS) 3538: cmd_sizebytes = sizeof(*cmd); 3539: else 3540: cmd_sizebytes = sizeof(*cmd) + 3541: (sizeof(struct hfi_issue_ib) * cmdobj->numibs); 3542: 3543: if (WARN_ON(cmd_sizebytes > HFI_MAX_MSG_SIZE)) 3544: return -EMSGSIZE; 3545: 3546: cmd = kzalloc(cmd_sizebytes, GFP_KERNEL); 3547: if (cmd == NULL) 3548: return -ENOMEM; MATCH LINES: 3659, 3661 3647: if (list_empty(&drawctxt->hw_fence_list)) 3648: return; 3649: 3650: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 3651: drain_context_hw_fence_gmu(adreno_dev, drawctxt); 3652: else 3653: drain_context_hw_fence_cpu(adreno_dev, drawctxt); 3654: } 3655: 3656: static void trigger_context_unregister_fault(struct adreno_device *adreno_dev, 3657: struct adreno_context *drawctxt) 3658: { 3659: gmu_core_fault_snapshot(KGSL_DEVICE(adreno_dev), GMU_FAULT_CTX_UNREGISTER); 3660: 3661: /* Make sure we send all fences from this context to the TxQueue after recovery */ 3662: move_detached_context_hardware_fences(adreno_dev, drawctxt); 3663: gen7_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 3664: } 3665: 3666: static int send_context_unregister_hfi(struct adreno_device *adreno_dev, 3667: struct kgsl_context *context, u32 ts) 3668: { 3669: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 3670: struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev); 3671: struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev); 3672: struct adreno_context *drawctxt = ADRENO_CONTEXT(context); 3673: struct pending_cmd pending_ack; 3674: struct hfi_unregister_ctxt_cmd cmd; 3675: u32 seqnum; 3676: int ret; 3677: 3678: /* Only send HFI if device is not in SLUMBER */ 3679: if (!context->gmu_registered || 3680: !test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) { 3681: drain_context_hw_fences(adreno_dev, drawctxt); 3682: return 0; 3683: } 3684: 3685: ret = CMD_MSG_HDR(cmd, H2F_MSG_UNREGISTER_CONTEXT); MATCH LINES: 3952 3940: spin_lock(&hwf->lock); 3941: 3942: drawctxt = hwf->defer_drawctxt; 3943: ts = hwf->defer_ts; 3944: 3945: spin_unlock(&hwf->lock); 3946: 3947: if (!drawctxt) 3948: goto done; 3949: 3950: ret = process_hw_fence_deferred_ctxt(adreno_dev, drawctxt, ts); 3951: if (ret) { 3952: /* the deferred drawctxt will be handled post fault recovery */ 3953: gen7_hwsched_fault(adreno_dev, GMU_FAULT_HW_FENCE); 3954: return ret; 3955: } 3956: 3957: kgsl_context_put(&drawctxt->base); 3958: adreno_active_count_put(adreno_dev); 3959: 3960: done: 3961: _disable_hw_fence_throttle(adreno_dev, true); 3962: 3963: return ret; 3964: } --- FILE: \adreno_gen7_hwsched_hfi.h | HITS: 7 --- MATCH LINES: 20, 32, 37 8: #define _ADRENO_GEN7_HWSCHED_HFI_H_ 9: 10: /* Maximum number of IBs in a submission */ 11: #define HWSCHED_MAX_NUMIBS \ 12: ((HFI_MAX_MSG_SIZE - offsetof(struct hfi_issue_cmd_cmd, ibs)) \ 13: / sizeof(struct hfi_issue_ib)) 14: 15: /* 16: * This is used to put userspace threads to sleep when hardware fence unack count reaches a 17: * threshold. This bit is cleared in two scenarios: 18: * 1. If the hardware fence unack count drops to a desired threshold. 19: * 2. If there is a GMU/GPU fault. Because we don't want the threads to keep sleeping through fault 20: * recovery, which can easily take 100s of milliseconds to complete. 21: */ 22: #define GEN7_HWSCHED_HW_FENCE_SLEEP_BIT 0x0 23: 24: /* 25: * This is used to avoid creating any more hardware fences until the hardware fence unack count 26: * drops to a desired threshold. This bit is required in cases where GEN7_HWSCHED_HW_FENCE_SLEEP_BIT 27: * will be cleared, but we still want to avoid creating any more hardware fences. For example, if 28: * hardware fence unack count reaches a maximum threshold, both GEN7_HWSCHED_HW_FENCE_SLEEP_BIT and 29: * GEN7_HWSCHED_HW_FENCE_MAX_BIT will be set. Say, a GMU/GPU fault happens and 30: * GEN7_HWSCHED_HW_FENCE_SLEEP_BIT will be cleared to wake up any sleeping threads. But, 31: * GEN7_HWSCHED_HW_FENCE_MAX_BIT will remain set to avoid creating any new hardware fences until 32: * recovery is complete and deferred drawctxt (if any) is handled. 33: */ 34: #define GEN7_HWSCHED_HW_FENCE_MAX_BIT 0x1 35: 36: /* 37: * This is used to avoid creating any more hardware fences until concurrent reset/recovery completes 38: */ 39: #define GEN7_HWSCHED_HW_FENCE_ABORT_BIT 0x2 40: 41: struct gen7_hwsched_hfi { 42: /** @irq_mask: Store the hfi interrupt mask */ 43: u32 irq_mask; 44: /** @msglock: To protect the list of un-ACKed hfi packets */ 45: rwlock_t msglock; 46: /** @msglist: List of un-ACKed hfi packets */ 47: struct list_head msglist; 48: /** @f2h_task: Task for processing gmu fw to host packets */ 49: struct task_struct *f2h_task; 50: /** @f2h_wq: Waitqueue for the f2h_task */ 51: wait_queue_head_t f2h_wq; 52: /** @big_ib: GMU buffer to hold big IBs */ 53: struct kgsl_memdesc *big_ib; 54: /** @big_ib_recurring: GMU buffer to hold big recurring IBs */ 55: struct kgsl_memdesc *big_ib_recurring; 56: /** @perfctr_scratch: Buffer to hold perfcounter PM4 commands */ 57: struct kgsl_memdesc *perfctr_scratch; 58: /** @msg_mutex: Mutex for accessing the msgq */ 59: struct mutex msgq_mutex; 60: /** 61: * @hw_fence_timer: Timer to trigger fault if unack'd hardware fence count does'nt drop MATCH LINES: 285, 288, 289, 308 273: * @adreno_dev: Pointer to adreno device 274: * @drawctxt: Pointer to the adreno context which is to be flushed 275: * 276: * Check if all hardware fences from this context have been sent to the 277: * TxQueue. If not, log an error and return error code. 278: * 279: * Return: Zero on success or negative error on failure 280: */ 281: int gen7_hwsched_check_context_inflight_hw_fences(struct adreno_device *adreno_dev, 282: struct adreno_context *drawctxt); 283: 284: /** 285: * gen7_hwsched_disable_hw_fence_throttle - Disable hardware fence throttling after reset 286: * @adreno_dev: pointer to the adreno device 287: * 288: * After device reset, clear hardware fence related data structures and send any hardware fences 289: * that got deferred (prior to reset) and re-open the gates for hardware fence creation 290: * 291: * Return: Zero on success or negative error on failure 292: */ 293: int gen7_hwsched_disable_hw_fence_throttle(struct adreno_device *adreno_dev); 294: 295: /** 296: * gen7_hwsched_process_msgq - Process msgq 297: * @adreno_dev: pointer to the adreno device 298: * 299: * This function grabs the msgq mutex and processes msgq for any outstanding hfi packets 300: */ 301: void gen7_hwsched_process_msgq(struct adreno_device *adreno_dev); 302: 303: /** 304: * gen7_hwsched_boot_gpu - Send the command to boot GPU 305: * @adreno_dev: Pointer to adreno device 306: * 307: * Send the hfi to boot GPU, and check the ack, incase of a failure 308: * get a snapshot and capture registers of interest. 309: * 310: * Return: Zero on success or negative error on failure 311: */ 312: int gen7_hwsched_boot_gpu(struct adreno_device *adreno_dev); 313: #endif --- FILE: \adreno_gen7_perfcounter.c | HITS: 2 --- MATCH LINES: 106, 109 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 107: * error and return 0 here. The perfcounter is already 108: * set up in software and it will be programmed in 109: * hardware when we wake up or come up after soft reset, 110: * by adreno_perfcounter_restore. 111: */ 112: if (ret == -EAGAIN) 113: ret = 0; 114: else 115: dev_err_ratelimited(KGSL_DEVICE(adreno_dev)->dev, 116: "Perfcounter %s/%u/%u start via commands failed %d\n", 117: group->name, counter, countable, ret); 118: } 119: 120: if (!ret) 121: reg->value = 0; 122: 123: return ret; 124: } 125: 126: 127: static int gen7_counter_inline_enable(struct adreno_device *adreno_dev, 128: const struct adreno_perfcount_group *group, u32 counter, u32 countable) 129: { 130: if (!(KGSL_DEVICE(adreno_dev)->state == KGSL_STATE_ACTIVE)) 131: return gen7_counter_enable(adreno_dev, group, counter, countable); 132: 133: if (adreno_dev->hwsched_enabled) --- FILE: \adreno_gen7_preempt.c | HITS: 15 --- MATCH LINES: 19, 40, 49, 53, 60, 62, 64, 84 7: #include "adreno.h" 8: #include "adreno_gen7.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 gen7_cp_preemption_record, _field) 15: 16: #define PREEMPT_SMMU_RECORD(_field) \ 17: offsetof(struct gen7_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 = gen7_fenced_write(adreno_dev, 37: GEN7_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, GEN7_CP_RB_WPTR, &wptr); 47: if (wptr != rb->wptr) { 48: kgsl_regwrite(device, GEN7_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: 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, 99: adreno_get_rptr(adreno_dev->next_rb), 100: adreno_dev->next_rb->wptr); 101: 102: /* Set a fault and restart */ 103: adreno_scheduler_fault(adreno_dev, ADRENO_PREEMPT_FAULT); 104: 105: return; 106: } 107: 108: adreno_dev->preempt.count++; MATCH LINES: 382, 384, 386 370: gen7_core->qos_value[next->id]); 371: 372: /* Trigger the preemption */ 373: if (gen7_fenced_write(adreno_dev, GEN7_CP_CONTEXT_SWITCH_CNTL, cntl, 374: FENCE_STATUS_WRITEDROPPED1_MASK)) { 375: adreno_dev->next_rb = NULL; 376: kgsl_delete_timer(&adreno_dev->preempt.timer); 377: goto err; 378: } 379: 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); MATCH LINES: 649, 668, 677, 714 637: kgsl_sharedmem_writel(rb->preemption_desc, 638: PREEMPT_RECORD(rptr), 0); 639: kgsl_sharedmem_writel(rb->preemption_desc, 640: PREEMPT_RECORD(wptr), 0); 641: 642: adreno_ringbuffer_set_pagetable(device, rb, 643: device->mmu.defaultpagetable); 644: 645: clear_bit(ADRENO_RB_SET_PSEUDO_DONE, &rb->flags); 646: } 647: } 648: 649: static void reset_rb_preempt_record(struct adreno_device *adreno_dev, 650: struct adreno_ringbuffer *rb) 651: { 652: memset(rb->preemption_desc->hostptr, 0x0, rb->preemption_desc->size); 653: 654: kgsl_sharedmem_writel(rb->preemption_desc, 655: PREEMPT_RECORD(magic), GEN7_CP_CTXRECORD_MAGIC_REF); 656: kgsl_sharedmem_writel(rb->preemption_desc, 657: PREEMPT_RECORD(cntl), GEN7_CP_RB_CNTL_DEFAULT); 658: kgsl_sharedmem_writeq(rb->preemption_desc, 659: PREEMPT_RECORD(rptr_addr), SCRATCH_RB_GPU_ADDR( 660: KGSL_DEVICE(adreno_dev), rb->id, rptr)); 661: kgsl_sharedmem_writeq(rb->preemption_desc, 662: PREEMPT_RECORD(rbase), rb->buffer_desc->gpuaddr); 663: kgsl_sharedmem_writeq(rb->preemption_desc, 664: PREEMPT_RECORD(bv_rptr_addr), SCRATCH_RB_GPU_ADDR( 665: KGSL_DEVICE(adreno_dev), rb->id, bv_rptr)); 666: } 667: 668: void gen7_reset_preempt_records(struct adreno_device *adreno_dev) 669: { 670: int i; 671: struct adreno_ringbuffer *rb; 672: 673: if (!adreno_is_preemption_enabled(adreno_dev)) 674: return; 675: 676: FOR_EACH_RINGBUFFER(adreno_dev, rb, i) { 677: reset_rb_preempt_record(adreno_dev, rb); 678: } 679: } 680: 681: static int gen7_preemption_ringbuffer_init(struct adreno_device *adreno_dev, 682: struct adreno_ringbuffer *rb) 683: { 684: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 685: const struct adreno_gen7_core *gen7_core = to_gen7_core(adreno_dev); 686: u64 ctxt_record_size = GEN7_CP_CTXRECORD_SIZE_IN_BYTES; 687: int ret; 688: 689: if (gen7_core->ctxt_record_size) 690: ctxt_record_size = gen7_core->ctxt_record_size; 691: 692: ret = adreno_allocate_global(device, &rb->preemption_desc, 693: ctxt_record_size, SZ_16K, 0, 694: KGSL_MEMDESC_PRIVILEGED, "preemption_desc"); 695: if (ret) 696: return ret; 697: 698: if (kgsl_mmu_is_secured(&device->mmu)) { 699: ret = adreno_allocate_global(device, &rb->secure_preemption_desc, 700: ctxt_record_size, 0, 701: KGSL_MEMFLAGS_SECURE, KGSL_MEMDESC_PRIVILEGED, 702: "secure_preemption_desc"); 703: if (ret) 704: return ret; 705: } 706: 707: ret = adreno_allocate_global(device, &rb->perfcounter_save_restore_desc, 708: GEN7_CP_PERFCOUNTER_SAVE_RESTORE_SIZE, 0, 0, 709: KGSL_MEMDESC_PRIVILEGED, 710: "perfcounter_save_restore_desc"); 711: if (ret) 712: return ret; 713: 714: reset_rb_preempt_record(adreno_dev, rb); 715: 716: return 0; 717: } 718: 719: int gen7_preemption_init(struct adreno_device *adreno_dev) 720: { 721: u32 flags = ADRENO_FEATURE(adreno_dev, ADRENO_APRIV) ? KGSL_MEMDESC_PRIVILEGED : 0; 722: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 723: struct kgsl_iommu *iommu = KGSL_IOMMU(device); 724: struct adreno_preemption *preempt = &adreno_dev->preempt; 725: struct adreno_ringbuffer *rb; 726: int ret; 727: unsigned int i; 728: 729: /* We are dependent on IOMMU to make preemption go on the CP side */ 730: if (kgsl_mmu_get_mmutype(device) != KGSL_MMU_TYPE_IOMMU) { 731: ret = -ENODEV; 732: goto done; 733: } 734: 735: INIT_WORK(&preempt->work, _gen7_preemption_worker); 736: 737: /* Allocate mem for storing preemption switch record */ 738: FOR_EACH_RINGBUFFER(adreno_dev, rb, i) { --- FILE: \adreno_gen7_ringbuffer.c | HITS: 10 --- MATCH LINES: 73, 74, 75 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) { MATCH LINES: 124 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); MATCH LINES: 203, 204, 206, 208 191: rb->skip_inline_wptr = false; 192: } 193: } else { 194: if (adreno_dev->cur_rb == rb) 195: rb->skip_inline_wptr = true; 196: } 197: 198: rb->wptr = rb->_wptr; 199: spin_unlock_irqrestore(&rb->preempt_lock, flags); 200: 201: if (ret) { 202: /* 203: * If WPTR update fails, take inline snapshot and trigger 204: * recovery. 205: */ 206: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE); 207: adreno_scheduler_fault(adreno_dev, 208: ADRENO_GMU_FAULT_SKIP_SNAPSHOT); 209: } 210: 211: return ret; 212: } 213: 214: int gen7_ringbuffer_init(struct adreno_device *adreno_dev) 215: { 216: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 217: int i, ret; 218: 219: ret = adreno_allocate_global(device, &device->scratch, PAGE_SIZE, 220: 0, 0, KGSL_MEMDESC_RANDOM | KGSL_MEMDESC_PRIVILEGED, 221: "scratch"); 222: if (ret) 223: return ret; 224: 225: adreno_dev->cur_rb = &(adreno_dev->ringbuffers[0]); 226: 227: if (!adreno_preemption_feature_set(adreno_dev)) { 228: adreno_dev->num_ringbuffers = 1; 229: return adreno_ringbuffer_setup(adreno_dev, 230: &adreno_dev->ringbuffers[0], 0); 231: } 232: MATCH LINES: 265 253: u32 flags, u32 *in, u32 dwords, u32 timestamp, 254: struct adreno_submit_time *time) 255: { 256: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 257: u32 size = GEN7_SUBMIT_MAX + dwords; 258: u32 *cmds, index = 0; 259: u64 profile_gpuaddr; 260: u32 profile_dwords; 261: 262: if (adreno_drawctxt_detached(drawctxt)) 263: return -ENOENT; 264: 265: if (adreno_gpu_fault(adreno_dev) != 0) 266: return -EPROTO; 267: 268: rb->timestamp++; 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; MATCH LINES: 342 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 --- FILE: \adreno_gen7_snapshot.c | HITS: 249 --- MATCH LINES: 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 23, 29, 55, 81, 107, 135, 161, 187, 211, 237, 264, 291, 329, 362, 384, 394, 401, 412, 425, 433, 436, 443, 446, 470, 474, 475, 483, 490, 524, 527, 528, 534 1: // SPDX-License-Identifier: GPL-2.0-only 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 "adreno.h" 8: #include "adreno_snapshot.h" 9: #include "adreno_gen7_0_0_snapshot.h" 10: #include "adreno_gen7_2_0_snapshot.h" 11: #include "adreno_gen7_3_0_snapshot.h" 12: #include "adreno_gen7_5_0_snapshot.h" 13: #include "adreno_gen7_6_0_snapshot.h" 14: #include "adreno_gen7_9_0_snapshot.h" 15: #include "adreno_gen7_11_0_snapshot.h" 16: #include "adreno_gen7_14_0_snapshot.h" 17: #include "adreno_gen7_15_0_snapshot.h" 18: #include "adreno_gen7_17_0_snapshot.h" 19: 20: static struct kgsl_memdesc *gen7_capturescript; 21: static struct kgsl_memdesc *gen7_crashdump_registers; 22: static u32 *gen7_cd_reg_end; 23: static const struct gen7_snapshot_block_list *gen7_snapshot_block_list; 24: static bool gen7_crashdump_timedout; 25: 26: /* Starting kernel virtual address for QDSS TMC register block */ 27: static void __iomem *tmc_virt; 28: 29: const struct gen7_snapshot_block_list gen7_0_0_snapshot_block_list = { 30: .pre_crashdumper_regs = gen7_0_0_pre_crashdumper_gpu_registers, 31: .debugbus_blocks = gen7_0_0_debugbus_blocks, 32: .debugbus_blocks_len = ARRAY_SIZE(gen7_0_0_debugbus_blocks), 33: .gbif_debugbus_blocks = gen7_gbif_debugbus_blocks, 34: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen7_gbif_debugbus_blocks), 35: .cx_debugbus_blocks = gen7_cx_dbgc_debugbus_blocks, 36: .cx_debugbus_blocks_len = ARRAY_SIZE(gen7_cx_dbgc_debugbus_blocks), 37: .external_core_regs = gen7_0_0_external_core_regs, 38: .num_external_core_regs = ARRAY_SIZE(gen7_0_0_external_core_regs), 39: .gmu_regs = gen7_0_0_gmu_registers, 40: .gmu_gx_regs = gen7_0_0_gmugx_registers, 41: .rscc_regs = gen7_0_0_rscc_registers, 42: .reg_list = gen7_0_0_reg_list, 43: .cx_misc_regs = gen7_0_0_cx_misc_registers, 44: .shader_blocks = gen7_0_0_shader_blocks, 45: .num_shader_blocks = ARRAY_SIZE(gen7_0_0_shader_blocks), 46: .clusters = gen7_0_0_clusters, 47: .num_clusters = ARRAY_SIZE(gen7_0_0_clusters), 48: .sptp_clusters = gen7_0_0_sptp_clusters, 49: .num_sptp_clusters = ARRAY_SIZE(gen7_0_0_sptp_clusters), 50: .post_crashdumper_regs = gen7_0_0_post_crashdumper_registers, 51: .index_registers = gen7_cp_indexed_reg_list, 52: .index_registers_len = ARRAY_SIZE(gen7_cp_indexed_reg_list), 53: }; 54: 55: const struct gen7_snapshot_block_list gen7_2_0_snapshot_block_list = { 56: .pre_crashdumper_regs = gen7_0_0_pre_crashdumper_gpu_registers, 57: .debugbus_blocks = gen7_2_0_debugbus_blocks, 58: .debugbus_blocks_len = ARRAY_SIZE(gen7_2_0_debugbus_blocks), 59: .gbif_debugbus_blocks = gen7_gbif_debugbus_blocks, 60: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen7_gbif_debugbus_blocks), 61: .cx_debugbus_blocks = gen7_cx_dbgc_debugbus_blocks, 62: .cx_debugbus_blocks_len = ARRAY_SIZE(gen7_cx_dbgc_debugbus_blocks), 63: .external_core_regs = gen7_2_0_external_core_regs, 64: .num_external_core_regs = ARRAY_SIZE(gen7_2_0_external_core_regs), 65: .gmu_regs = gen7_2_0_gmu_registers, 66: .gmu_gx_regs = gen7_2_0_gmugx_registers, 67: .rscc_regs = gen7_2_0_rscc_registers, 68: .reg_list = gen7_2_0_reg_list, 69: .cx_misc_regs = gen7_0_0_cx_misc_registers, 70: .shader_blocks = gen7_2_0_shader_blocks, 71: .num_shader_blocks = ARRAY_SIZE(gen7_2_0_shader_blocks), 72: .clusters = gen7_2_0_clusters, 73: .num_clusters = ARRAY_SIZE(gen7_2_0_clusters), 74: .sptp_clusters = gen7_2_0_sptp_clusters, 75: .num_sptp_clusters = ARRAY_SIZE(gen7_2_0_sptp_clusters), 76: .post_crashdumper_regs = gen7_0_0_post_crashdumper_registers, 77: .index_registers = gen7_cp_indexed_reg_list, 78: .index_registers_len = ARRAY_SIZE(gen7_cp_indexed_reg_list), 79: }; 80: 81: const struct gen7_snapshot_block_list gen7_3_0_snapshot_block_list = { 82: .pre_crashdumper_regs = gen7_0_0_pre_crashdumper_gpu_registers, 83: .debugbus_blocks = gen7_3_0_debugbus_blocks, 84: .debugbus_blocks_len = ARRAY_SIZE(gen7_3_0_debugbus_blocks), 85: .gbif_debugbus_blocks = gen7_gbif_debugbus_blocks, 86: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen7_gbif_debugbus_blocks), 87: .cx_debugbus_blocks = gen7_cx_dbgc_debugbus_blocks, 88: .cx_debugbus_blocks_len = ARRAY_SIZE(gen7_cx_dbgc_debugbus_blocks), 89: .external_core_regs = gen7_3_0_external_core_regs, 90: .num_external_core_regs = ARRAY_SIZE(gen7_3_0_external_core_regs), 91: .gmu_regs = gen7_3_0_gmu_registers, 92: .gmu_gx_regs = gen7_3_0_gmu_gx_registers, 93: .rscc_regs = gen7_0_0_rscc_registers, 94: .reg_list = gen7_3_0_reg_list, 95: .cx_misc_regs = gen7_0_0_cx_misc_registers, 96: .shader_blocks = gen7_3_0_shader_blocks, 97: .num_shader_blocks = ARRAY_SIZE(gen7_3_0_shader_blocks), 98: .clusters = gen7_3_0_clusters, 99: .num_clusters = ARRAY_SIZE(gen7_3_0_clusters), 100: .sptp_clusters = gen7_3_0_sptp_clusters, 101: .num_sptp_clusters = ARRAY_SIZE(gen7_3_0_sptp_clusters), 102: .post_crashdumper_regs = gen7_0_0_post_crashdumper_registers, 103: .index_registers = gen7_3_0_cp_indexed_reg_list, 104: .index_registers_len = ARRAY_SIZE(gen7_3_0_cp_indexed_reg_list), 105: }; 106: 107: const struct gen7_snapshot_block_list gen7_5_0_snapshot_block_list = { 108: .pre_crashdumper_regs = gen7_0_0_pre_crashdumper_gpu_registers, 109: .debugbus_blocks = gen7_2_0_debugbus_blocks, 110: .debugbus_blocks_len = ARRAY_SIZE(gen7_2_0_debugbus_blocks), 111: .gbif_debugbus_blocks = gen7_gbif_debugbus_blocks, 112: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen7_gbif_debugbus_blocks), 113: .cx_debugbus_blocks = gen7_cx_dbgc_debugbus_blocks, 114: .cx_debugbus_blocks_len = ARRAY_SIZE(gen7_cx_dbgc_debugbus_blocks), 115: .external_core_regs = gen7_5_0_external_core_regs, 116: .num_external_core_regs = ARRAY_SIZE(gen7_5_0_external_core_regs), 117: .gmu_regs = gen7_5_0_gmu_registers, 118: .gmu_ao_regs = gen7_5_0_gmu_ao_registers, 119: .gmu_gx_regs = gen7_5_0_gmugx_registers, 120: .gmu_gx_blk_dec0_dec1_regs = gen7_5_0_gmugx_blk_dec0_dec1_registers, 121: .rscc_regs = gen7_2_0_rscc_registers, 122: .reg_list = gen7_2_0_reg_list, 123: .cx_misc_regs = gen7_0_0_cx_misc_registers, 124: .shader_blocks = gen7_2_0_shader_blocks, 125: .num_shader_blocks = ARRAY_SIZE(gen7_2_0_shader_blocks), 126: .clusters = gen7_2_0_clusters, 127: .num_clusters = ARRAY_SIZE(gen7_2_0_clusters), 128: .sptp_clusters = gen7_2_0_sptp_clusters, 129: .num_sptp_clusters = ARRAY_SIZE(gen7_2_0_sptp_clusters), 130: .post_crashdumper_regs = gen7_0_0_post_crashdumper_registers, 131: .index_registers = gen7_cp_indexed_reg_list, 132: .index_registers_len = ARRAY_SIZE(gen7_cp_indexed_reg_list), 133: }; 134: 135: const struct gen7_snapshot_block_list gen7_6_0_snapshot_block_list = { 136: .pre_crashdumper_regs = gen7_0_0_pre_crashdumper_gpu_registers, 137: .debugbus_blocks = gen7_2_0_debugbus_blocks, 138: .debugbus_blocks_len = ARRAY_SIZE(gen7_2_0_debugbus_blocks), 139: .gbif_debugbus_blocks = gen7_gbif_debugbus_blocks, 140: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen7_gbif_debugbus_blocks), 141: .cx_debugbus_blocks = gen7_cx_dbgc_debugbus_blocks, 142: .cx_debugbus_blocks_len = ARRAY_SIZE(gen7_cx_dbgc_debugbus_blocks), 143: .external_core_regs = gen7_6_0_external_core_regs, 144: .num_external_core_regs = ARRAY_SIZE(gen7_6_0_external_core_regs), 145: .gmu_regs = gen7_2_0_gmu_registers, 146: .gmu_gx_regs = gen7_2_0_gmugx_registers, 147: .rscc_regs = gen7_2_0_rscc_registers, 148: .reg_list = gen7_2_0_reg_list, 149: .cx_misc_regs = gen7_0_0_cx_misc_registers, 150: .shader_blocks = gen7_2_0_shader_blocks, 151: .num_shader_blocks = ARRAY_SIZE(gen7_2_0_shader_blocks), 152: .clusters = gen7_2_0_clusters, 153: .num_clusters = ARRAY_SIZE(gen7_2_0_clusters), 154: .sptp_clusters = gen7_2_0_sptp_clusters, 155: .num_sptp_clusters = ARRAY_SIZE(gen7_2_0_sptp_clusters), 156: .post_crashdumper_regs = gen7_0_0_post_crashdumper_registers, 157: .index_registers = gen7_cp_indexed_reg_list, 158: .index_registers_len = ARRAY_SIZE(gen7_cp_indexed_reg_list), 159: }; 160: 161: const struct gen7_snapshot_block_list gen7_9_0_snapshot_block_list = { 162: .pre_crashdumper_regs = gen7_9_0_pre_crashdumper_gpu_registers, 163: .debugbus_blocks = gen7_9_0_debugbus_blocks, 164: .debugbus_blocks_len = ARRAY_SIZE(gen7_9_0_debugbus_blocks), 165: .gbif_debugbus_blocks = gen7_9_0_gbif_debugbus_blocks, 166: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen7_9_0_gbif_debugbus_blocks), 167: .cx_debugbus_blocks = gen7_9_0_cx_debugbus_blocks, 168: .cx_debugbus_blocks_len = ARRAY_SIZE(gen7_9_0_cx_debugbus_blocks), 169: .external_core_regs = gen7_9_0_external_core_regs, 170: .num_external_core_regs = ARRAY_SIZE(gen7_9_0_external_core_regs), 171: .gmu_regs = gen7_9_0_gmu_registers, 172: .gmu_gx_regs = gen7_9_0_gmugx_registers, 173: .rscc_regs = gen7_9_0_rscc_registers, 174: .reg_list = gen7_9_0_reg_list, 175: .cx_misc_regs = gen7_9_0_cx_misc_registers, 176: .shader_blocks = gen7_9_0_shader_blocks, 177: .num_shader_blocks = ARRAY_SIZE(gen7_9_0_shader_blocks), 178: .clusters = gen7_9_0_clusters, 179: .num_clusters = ARRAY_SIZE(gen7_9_0_clusters), 180: .sptp_clusters = gen7_9_0_sptp_clusters, 181: .num_sptp_clusters = ARRAY_SIZE(gen7_9_0_sptp_clusters), 182: .post_crashdumper_regs = gen7_0_0_post_crashdumper_registers, 183: .index_registers = gen7_9_0_cp_indexed_reg_list, 184: .index_registers_len = ARRAY_SIZE(gen7_9_0_cp_indexed_reg_list), 185: }; 186: 187: const struct gen7_snapshot_block_list gen7_13_0_snapshot_block_list = { 188: .pre_crashdumper_regs = gen7_9_0_pre_crashdumper_gpu_registers, 189: .debugbus_blocks = gen7_9_0_debugbus_blocks, 190: .debugbus_blocks_len = ARRAY_SIZE(gen7_9_0_debugbus_blocks), 191: .gbif_debugbus_blocks = gen7_9_0_gbif_debugbus_blocks, 192: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen7_9_0_gbif_debugbus_blocks), 193: .cx_debugbus_blocks = gen7_9_0_cx_debugbus_blocks, 194: .cx_debugbus_blocks_len = ARRAY_SIZE(gen7_9_0_cx_debugbus_blocks), 195: .gmu_regs = gen7_9_0_gmu_registers, 196: .gmu_gx_regs = gen7_9_0_gmugx_registers, 197: .rscc_regs = gen7_9_0_rscc_registers, 198: .reg_list = gen7_9_0_reg_list, 199: .cx_misc_regs = gen7_9_0_cx_misc_registers, 200: .shader_blocks = gen7_9_0_shader_blocks, 201: .num_shader_blocks = ARRAY_SIZE(gen7_9_0_shader_blocks), 202: .clusters = gen7_9_0_clusters, 203: .num_clusters = ARRAY_SIZE(gen7_9_0_clusters), 204: .sptp_clusters = gen7_9_0_sptp_clusters, 205: .num_sptp_clusters = ARRAY_SIZE(gen7_9_0_sptp_clusters), 206: .post_crashdumper_regs = gen7_0_0_post_crashdumper_registers, 207: .index_registers = gen7_9_0_cp_indexed_reg_list, 208: .index_registers_len = ARRAY_SIZE(gen7_9_0_cp_indexed_reg_list), 209: }; 210: 211: const struct gen7_snapshot_block_list gen7_14_0_snapshot_block_list = { 212: .pre_crashdumper_regs = gen7_9_0_pre_crashdumper_gpu_registers, 213: .debugbus_blocks = gen7_14_0_debugbus_blocks, 214: .debugbus_blocks_len = ARRAY_SIZE(gen7_14_0_debugbus_blocks), 215: .gbif_debugbus_blocks = gen7_gbif_debugbus_blocks, 216: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen7_gbif_debugbus_blocks), 217: .cx_debugbus_blocks = gen7_cx_dbgc_debugbus_blocks, 218: .cx_debugbus_blocks_len = ARRAY_SIZE(gen7_cx_dbgc_debugbus_blocks), 219: .external_core_regs = gen7_14_0_external_core_regs, 220: .num_external_core_regs = ARRAY_SIZE(gen7_14_0_external_core_regs), 221: .gmu_regs = gen7_14_0_gmu_registers, 222: .gmu_gx_regs = gen7_14_0_gmu_gx_registers, 223: .rscc_regs = gen7_14_0_rscc_registers, 224: .reg_list = gen7_14_0_reg_list, 225: .cx_misc_regs = gen7_14_0_cx_misc_registers, 226: .shader_blocks = gen7_14_0_shader_blocks, 227: .num_shader_blocks = ARRAY_SIZE(gen7_14_0_shader_blocks), 228: .clusters = gen7_14_0_clusters, 229: .num_clusters = ARRAY_SIZE(gen7_14_0_clusters), 230: .sptp_clusters = gen7_14_0_sptp_clusters, 231: .num_sptp_clusters = ARRAY_SIZE(gen7_14_0_sptp_clusters), 232: .post_crashdumper_regs = gen7_14_0_post_crashdumper_registers, 233: .index_registers = gen7_14_0_cp_indexed_reg_list, 234: .index_registers_len = ARRAY_SIZE(gen7_14_0_cp_indexed_reg_list), 235: }; 236: 237: const struct gen7_snapshot_block_list gen7_11_0_snapshot_block_list = { 238: .pre_crashdumper_regs = gen7_0_0_pre_crashdumper_gpu_registers, 239: .debugbus_blocks = gen7_11_0_debugbus_blocks, 240: .debugbus_blocks_len = ARRAY_SIZE(gen7_11_0_debugbus_blocks), 241: .gbif_debugbus_blocks = gen7_11_0_gbif_debugbus_blocks, 242: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen7_11_0_gbif_debugbus_blocks), 243: .cx_debugbus_blocks = gen7_11_0_cx_debugbus_blocks, 244: .cx_debugbus_blocks_len = ARRAY_SIZE(gen7_11_0_cx_debugbus_blocks), 245: .external_core_regs = gen7_11_0_external_core_regs, 246: .num_external_core_regs = ARRAY_SIZE(gen7_11_0_external_core_regs), 247: .gmu_regs = gen7_11_0_gmu_registers, 248: .gmu_ao_regs = gen7_11_0_gmu_ao_registers, 249: .gmu_gx_regs = gen7_11_0_gmugx_registers, 250: .rscc_regs = gen7_11_0_rscc_registers, 251: .reg_list = gen7_11_0_reg_list, 252: .cx_misc_regs = gen7_11_0_cx_misc_registers, 253: .shader_blocks = gen7_11_0_shader_blocks, 254: .num_shader_blocks = ARRAY_SIZE(gen7_11_0_shader_blocks), 255: .clusters = gen7_11_0_clusters, 256: .num_clusters = ARRAY_SIZE(gen7_11_0_clusters), 257: .sptp_clusters = gen7_11_0_sptp_clusters, 258: .num_sptp_clusters = ARRAY_SIZE(gen7_11_0_sptp_clusters), 259: .post_crashdumper_regs = gen7_0_0_post_crashdumper_registers, 260: .index_registers = gen7_11_0_cp_indexed_reg_list, 261: .index_registers_len = ARRAY_SIZE(gen7_11_0_cp_indexed_reg_list), 262: }; 263: 264: const struct gen7_snapshot_block_list gen7_15_0_snapshot_block_list = { 265: .pre_crashdumper_regs = gen7_0_0_pre_crashdumper_gpu_registers, 266: .debugbus_blocks = gen7_11_0_debugbus_blocks, 267: .debugbus_blocks_len = ARRAY_SIZE(gen7_11_0_debugbus_blocks), 268: .gbif_debugbus_blocks = gen7_11_0_gbif_debugbus_blocks, 269: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen7_11_0_gbif_debugbus_blocks), 270: .cx_debugbus_blocks = gen7_11_0_cx_debugbus_blocks, 271: .cx_debugbus_blocks_len = ARRAY_SIZE(gen7_11_0_cx_debugbus_blocks), 272: .external_core_regs = gen7_15_0_external_core_regs, 273: .num_external_core_regs = ARRAY_SIZE(gen7_15_0_external_core_regs), 274: .gmu_regs = gen7_11_0_gmu_registers, 275: .gmu_ao_regs = gen7_11_0_gmu_ao_registers, 276: .gmu_gx_regs = gen7_11_0_gmugx_registers, 277: .rscc_regs = gen7_11_0_rscc_registers, 278: .reg_list = gen7_11_0_reg_list, 279: .cx_misc_regs = gen7_11_0_cx_misc_registers, 280: .shader_blocks = gen7_11_0_shader_blocks, 281: .num_shader_blocks = ARRAY_SIZE(gen7_11_0_shader_blocks), 282: .clusters = gen7_11_0_clusters, 283: .num_clusters = ARRAY_SIZE(gen7_11_0_clusters), 284: .sptp_clusters = gen7_11_0_sptp_clusters, 285: .num_sptp_clusters = ARRAY_SIZE(gen7_11_0_sptp_clusters), 286: .post_crashdumper_regs = gen7_0_0_post_crashdumper_registers, 287: .index_registers = gen7_11_0_cp_indexed_reg_list, 288: .index_registers_len = ARRAY_SIZE(gen7_11_0_cp_indexed_reg_list), 289: }; 290: 291: const struct gen7_snapshot_block_list gen7_17_0_snapshot_block_list = { 292: .pre_crashdumper_regs = gen7_9_0_pre_crashdumper_gpu_registers, 293: .debugbus_blocks = gen7_14_0_debugbus_blocks, 294: .debugbus_blocks_len = ARRAY_SIZE(gen7_14_0_debugbus_blocks), 295: .gbif_debugbus_blocks = gen7_gbif_debugbus_blocks, 296: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen7_gbif_debugbus_blocks), 297: .cx_debugbus_blocks = gen7_cx_dbgc_debugbus_blocks, 298: .cx_debugbus_blocks_len = ARRAY_SIZE(gen7_cx_dbgc_debugbus_blocks), 299: .external_core_regs = gen7_17_0_external_core_regs, 300: .num_external_core_regs = ARRAY_SIZE(gen7_17_0_external_core_regs), 301: .gmu_regs = gen7_14_0_gmu_registers, 302: .gmu_gx_regs = gen7_14_0_gmu_gx_registers, 303: .rscc_regs = gen7_17_0_rscc_registers, 304: .reg_list = gen7_14_0_reg_list, 305: .cx_misc_regs = gen7_14_0_cx_misc_registers, 306: .shader_blocks = gen7_14_0_shader_blocks, 307: .num_shader_blocks = ARRAY_SIZE(gen7_14_0_shader_blocks), 308: .clusters = gen7_14_0_clusters, 309: .num_clusters = ARRAY_SIZE(gen7_14_0_clusters), 310: .sptp_clusters = gen7_14_0_sptp_clusters, 311: .num_sptp_clusters = ARRAY_SIZE(gen7_14_0_sptp_clusters), 312: .post_crashdumper_regs = gen7_14_0_post_crashdumper_registers, 313: .index_registers = gen7_14_0_cp_indexed_reg_list, 314: .index_registers_len = ARRAY_SIZE(gen7_14_0_cp_indexed_reg_list), 315: }; 316: 317: #define GEN7_SP_READ_SEL_VAL(_location, _pipe, _statetype, _usptp, _sptp) \ 318: (FIELD_PREP(GENMASK(19, 18), _location) | \ 319: FIELD_PREP(GENMASK(17, 16), _pipe) | \ 320: FIELD_PREP(GENMASK(15, 8), _statetype) | \ 321: FIELD_PREP(GENMASK(7, 4), _usptp) | \ 322: FIELD_PREP(GENMASK(3, 0), _sptp)) 323: 324: #define GEN7_CP_APERTURE_REG_VAL(_pipe, _cluster, _context) \ 325: (FIELD_PREP(GENMASK(13, 12), _pipe) | \ 326: FIELD_PREP(GENMASK(10, 8), _cluster) | \ 327: FIELD_PREP(GENMASK(5, 4), _context)) 328: 329: #define GEN7_DEBUGBUS_SECTION_SIZE (sizeof(struct kgsl_snapshot_debugbus) \ 330: + (GEN7_DEBUGBUS_BLOCK_SIZE << 3)) 331: 332: #define CD_REG_END 0xaaaaaaaa 333: 334: static int CD_WRITE(u64 *ptr, u32 offset, u64 val) 335: { 336: ptr[0] = val; 337: ptr[1] = FIELD_PREP(GENMASK(63, 44), offset) | BIT(21) | BIT(0); 338: 339: return 2; 340: } 341: 342: static int CD_READ(u64 *ptr, u32 offset, u32 size, u64 target) 343: { 344: ptr[0] = target; 345: ptr[1] = FIELD_PREP(GENMASK(63, 44), offset) | size; 346: 347: return 2; 348: } 349: 350: static void CD_FINISH(u64 *ptr, u32 offset) 351: { 352: gen7_cd_reg_end = gen7_crashdump_registers->hostptr + offset; 353: *gen7_cd_reg_end = CD_REG_END; 354: ptr[0] = gen7_crashdump_registers->gpuaddr + offset; 355: ptr[1] = FIELD_PREP(GENMASK(63, 44), GEN7_CP_CRASH_DUMP_STATUS) | BIT(0); 356: ptr[2] = 0; 357: ptr[3] = 0; 358: } 359: 360: static bool CD_SCRIPT_CHECK(struct kgsl_device *device) 361: { 362: return (adreno_smmu_is_stalled(ADRENO_DEVICE(device)) || (!device->snapshot_crashdumper) || 363: IS_ERR_OR_NULL(gen7_capturescript) || 364: IS_ERR_OR_NULL(gen7_crashdump_registers) || 365: gen7_crashdump_timedout); 366: } 367: 368: static bool _gen7_do_crashdump(struct kgsl_device *device) 369: { 370: unsigned int reg = 0; 371: ktime_t timeout; 372: 373: if (CD_SCRIPT_CHECK(device)) 374: return false; 375: 376: kgsl_regwrite(device, GEN7_CP_CRASH_SCRIPT_BASE_LO, 377: lower_32_bits(gen7_capturescript->gpuaddr)); 378: kgsl_regwrite(device, GEN7_CP_CRASH_SCRIPT_BASE_HI, 379: upper_32_bits(gen7_capturescript->gpuaddr)); 380: kgsl_regwrite(device, GEN7_CP_CRASH_DUMP_CNTL, 1); 381: 382: timeout = ktime_add_ms(ktime_get(), CP_CRASH_DUMPER_TIMEOUT); 383: 384: if (!device->snapshot_atomic) 385: might_sleep(); 386: for (;;) { 387: /* make sure we're reading the latest value */ 388: rmb(); 389: if ((*gen7_cd_reg_end) != CD_REG_END) 390: break; 391: if (ktime_compare(ktime_get(), timeout) > 0) 392: break; 393: /* Wait 50us to avoid unnecessary looping */ 394: if (!device->snapshot_atomic) 395: usleep_range(5, 50); 396: } 397: 398: kgsl_regread(device, GEN7_CP_CRASH_DUMP_STATUS, ®); 399: 400: /* 401: * Writing to the GEN7_CP_CRASH_DUMP_CNTL also resets the 402: * GEN7_CP_CRASH_DUMP_STATUS. Make sure the read above is 403: * complete before we change the value 404: */ 405: rmb(); 406: 407: kgsl_regwrite(device, GEN7_CP_CRASH_DUMP_CNTL, 0); 408: 409: if (WARN(!(reg & 0x2), "Crashdumper timed out\n")) { 410: /* 411: * Gen7 crash dumper script is broken down into multiple chunks 412: * and script will be invoked multiple times to capture snapshot 413: * of different sections of GPU. If crashdumper fails once, it is 414: * highly likely it will fail subsequently as well. Hence update 415: * gen7_crashdump_timedout variable to avoid running crashdumper 416: * after it fails once. 417: */ 418: gen7_crashdump_timedout = true; 419: return false; 420: } 421: 422: return true; 423: } 424: 425: static size_t gen7_legacy_snapshot_registers(struct kgsl_device *device, 426: u8 *buf, size_t remain, void *priv) 427: { 428: struct gen7_reg_list *regs = priv; 429: 430: if (regs->sel) 431: kgsl_regwrite(device, regs->sel->host_reg, regs->sel->val); 432: 433: return adreno_snapshot_registers_v2(device, buf, remain, (void *)regs->regs); 434: } 435: 436: static size_t gen7_snapshot_registers(struct kgsl_device *device, u8 *buf, 437: size_t remain, void *priv) 438: { 439: struct gen7_reg_list *regs = (struct gen7_reg_list *)priv; 440: const u32 *ptr = regs->regs; 441: unsigned int *data = (unsigned int *)buf; 442: unsigned int *src; 443: unsigned int size = adreno_snapshot_regs_count(ptr) * 4; 444: 445: if (remain < size) { 446: SNAPSHOT_ERR_NOMEM(device, "REGISTERS"); 447: return 0; 448: } 449: 450: src = gen7_crashdump_registers->hostptr + regs->offset; 451: 452: for (ptr = regs->regs; ptr[0] != UINT_MAX; ptr += 2) { 453: unsigned int cnt = REG_COUNT(ptr); 454: 455: if (cnt == 1) 456: *data++ = BIT(31) | ptr[0]; 457: else { 458: *data++ = ptr[0]; 459: *data++ = cnt; 460: } 461: memcpy(data, src, cnt << 2); 462: data += cnt; 463: src += cnt; 464: } 465: 466: /* Return the size of the section */ 467: return size; 468: } 469: 470: static size_t gen7_legacy_snapshot_shader(struct kgsl_device *device, 471: u8 *buf, size_t remain, void *priv) 472: { 473: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 474: struct kgsl_snapshot_shader_v2 *header = 475: (struct kgsl_snapshot_shader_v2 *) buf; 476: struct gen7_shader_block_info *info = (struct gen7_shader_block_info *) priv; 477: struct gen7_shader_block *block = info->block; 478: unsigned int *data = (unsigned int *)(buf + sizeof(*header)); 479: unsigned int read_sel; 480: int i; 481: 482: if (remain < (sizeof(*header) + (block->size << 2))) { 483: SNAPSHOT_ERR_NOMEM(device, "SHADER MEMORY"); 484: return 0; 485: } 486: 487: /* 488: * If crashdumper times out, accessing some readback states from 489: * AHB path might fail. Hence, skip SP_INST_TAG and SP_INST_DATA* 490: * state types during snapshot dump in legacy flow. 491: */ 492: if (adreno_is_gen7_0_x_family(adreno_dev) || adreno_is_gen7_14_0_family(adreno_dev)) { 493: if (block->statetype == SP_INST_TAG || 494: block->statetype == SP_INST_DATA || 495: block->statetype == SP_INST_DATA_1 || 496: block->statetype == SP_INST_DATA_2) 497: return 0; 498: } 499: 500: header->type = block->statetype; 501: header->index = info->sp_id; 502: header->size = block->size; 503: header->usptp = info->usptp; 504: header->location = block->location; 505: header->pipe_id = block->pipeid; 506: 507: read_sel = GEN7_SP_READ_SEL_VAL(block->location, block->pipeid, 508: block->statetype, info->usptp, info->sp_id); 509: 510: kgsl_regwrite(device, GEN7_SP_READ_SEL, read_sel); 511: 512: /* 513: * An explicit barrier is needed so that reads do not happen before 514: * the register write. 515: */ 516: mb(); 517: 518: for (i = 0; i < block->size; i++) 519: data[i] = kgsl_regmap_read(&device->regmap, GEN7_SP_AHB_READ_APERTURE + i); 520: 521: return (sizeof(*header) + (block->size << 2)); 522: } 523: 524: static size_t gen7_snapshot_shader_memory(struct kgsl_device *device, 525: u8 *buf, size_t remain, void *priv) 526: { 527: struct kgsl_snapshot_shader_v2 *header = 528: (struct kgsl_snapshot_shader_v2 *) buf; 529: struct gen7_shader_block_info *info = (struct gen7_shader_block_info *) priv; 530: struct gen7_shader_block *block = info->block; 531: unsigned int *data = (unsigned int *) (buf + sizeof(*header)); 532: 533: if (remain < (sizeof(*header) + (block->size << 2))) { 534: SNAPSHOT_ERR_NOMEM(device, "SHADER MEMORY"); 535: return 0; 536: } 537: 538: header->type = block->statetype; 539: header->index = info->sp_id; 540: header->size = block->size; 541: header->usptp = info->usptp; 542: header->location = block->location; 543: header->pipe_id = block->pipeid; 544: 545: memcpy(data, gen7_crashdump_registers->hostptr + info->offset, 546: (block->size << 2)); 547: 548: return (sizeof(*header) + (block->size << 2)); 549: } 550: 551: static void qdss_regwrite(void __iomem *regbase, u32 offsetbytes, u32 value) 552: { 553: void __iomem *reg; 554: 555: reg = regbase + offsetbytes; 556: 557: /* Ensure previous write is committed */ 558: wmb(); MATCH LINES: 575, 579, 580, 586 563: { 564: void __iomem *reg; 565: u32 val; 566: 567: reg = regbase + offsetbytes; 568: val = __raw_readl(reg); 569: 570: /* Make sure memory is updated before next access */ 571: rmb(); 572: return val; 573: } 574: 575: static size_t gen7_snapshot_trace_buffer_gfx_trace(struct kgsl_device *device, 576: u8 *buf, size_t remain, void *priv) 577: { 578: u32 start_idx = 0, status = 0, count = 0, wrap_count = 0, write_ptr = 0; 579: struct kgsl_snapshot_trace_buffer *header = 580: (struct kgsl_snapshot_trace_buffer *) buf; 581: u32 *data = (u32 *)(buf + sizeof(*header)); 582: struct gen7_trace_buffer_info *info = 583: (struct gen7_trace_buffer_info *) priv; 584: 585: if (remain < SZ_2K + sizeof(*header)) { 586: SNAPSHOT_ERR_NOMEM(device, "TRACE 2K BUFFER"); 587: return 0; 588: } 589: 590: memcpy(header->ping_blk, info->ping_blk, sizeof(header->ping_blk)); 591: memcpy(header->ping_idx, info->ping_idx, sizeof(header->ping_idx)); 592: header->granularity = info->granularity; 593: header->segment = info->segment; 594: header->dbgc_ctrl = info->dbgc_ctrl; 595: 596: /* Read the status of trace buffer to determine if it's full or empty */ 597: kgsl_regread(device, GEN7_DBGC_TRACE_BUFFER_STATUS, &status); 598: 599: /* 600: * wrap_count and write ptr are part of status. 601: * if status is 0 => wrap_count = 0 and write ptr = 0 buffer is empty. 602: * if status is non zero and wrap count is 0 read partial buffer. 603: * if wrap count in non zero read entier 2k buffer. 604: * Always read the oldest data available. 605: */ 606: 607: /* if status is 0 then buffer is empty */ 608: if (!status) { 609: header->size = 0; 610: return sizeof(*header); MATCH LINES: 637, 641, 676, 703, 704, 731, 732 625: start_idx = write_ptr + 1; 626: count = SZ_512; 627: header->size = SZ_2K; 628: } 629: 630: kgsl_regmap_read_indexed_interleaved(&device->regmap, 631: GEN7_DBGC_DBG_TRACE_BUFFER_RD_ADDR, GEN7_DBGC_DBG_TRACE_BUFFER_RD_DATA, data, 632: start_idx, count); 633: 634: return (sizeof(*header) + header->size); 635: } 636: 637: static size_t gen7_snapshot_trace_buffer_etb(struct kgsl_device *device, 638: u8 *buf, size_t remain, void *priv) 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)) { 676: SNAPSHOT_ERR_NOMEM(device, "ETB BUFFER"); 677: return 0; 678: } 679: 680: /* 681: * Read pointer is 4 byte aligned and write pointer is 2 byte aligned 682: * We read 4 bytes of data in one iteration below so aligin it down 683: * to 4 bytes. 684: */ 685: count = ALIGN_DOWN(count, 4); 686: 687: header->size = count; 688: header->dbgc_ctrl = info->dbgc_ctrl; 689: memcpy(header->ping_blk, info->ping_blk, sizeof(header->ping_blk)); 690: memcpy(header->ping_idx, info->ping_idx, sizeof(header->ping_idx)); 691: header->granularity = info->granularity; 692: header->segment = info->segment; 693: 694: while (count != 0) { 695: /* This indexed register auto increments index as we read */ 696: data[idx++] = qdss_regread(tmc_virt, QDSS_AOSS_APB_TMC_RRD); 697: count = count - 4; 698: } 699: 700: return (sizeof(*header) + header->size); 701: } 702: 703: static void gen7_snapshot_trace_buffer(struct kgsl_device *device, 704: struct kgsl_snapshot *snapshot) 705: { 706: u32 val_tmc_ctrl = 0, val_etr_ctrl = 0, val_etr1_ctrl = 0; 707: u32 i = 0, sel_gx = 0, sel_cx = 0, val_gx = 0, val_cx = 0, val = 0; 708: struct gen7_trace_buffer_info info; 709: struct resource *res1, *res2; 710: struct clk *clk; 711: int ret; 712: void __iomem *etr_virt; 713: 714: /* 715: * Data can be collected from CX_DBGC or DBGC and it's mutually exclusive. 716: * Read the necessary select registers and determine the source of data. 717: * This loop reads SEL_A to SEL_D of both CX_DBGC and DBGC and accordingly 718: * updates the header information of trace buffer section. 719: */ 720: for (i = 0; i < TRACE_BUF_NUM_SIG; i++) { 721: kgsl_regread(device, GEN7_DBGC_CFG_DBGBUS_SEL_A + i, &sel_gx); 722: kgsl_regread(device, GEN7_CX_DBGC_CFG_DBGBUS_SEL_A + i, &sel_cx); 723: val_gx |= sel_gx; 724: val_cx |= sel_cx; 725: info.ping_idx[i] = FIELD_GET(GENMASK(7, 0), (sel_gx | sel_cx)); 726: info.ping_blk[i] = FIELD_GET(GENMASK(24, 16), (sel_gx | sel_cx)); 727: } 728: 729: /* Zero the header if not programmed to export any buffer or QDSS is unavailable */ 730: if ((!val_gx && !val_cx) || !IS_ENABLED(CONFIG_QCOM_KGSL_QDSS_STM)) { 731: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_TRACE_BUFFER, 732: snapshot, NULL, &info); 733: return; 734: } 735: 736: /* Enable APB clock to read data from trace buffer */ 737: clk = clk_get(&device->pdev->dev, "apb_pclk"); 738: 739: if (IS_ERR(clk)) { 740: dev_err(device->dev, "Unable to get QDSS clock\n"); 741: return; 742: } 743: 744: ret = clk_prepare_enable(clk); 745: 746: if (ret) { 747: dev_err(device->dev, "QDSS Clock enable error: %d\n", ret); 748: clk_put(clk); 749: return; 750: } 751: 752: res1 = platform_get_resource_byname(device->pdev, IORESOURCE_MEM, "qdss_etr"); 753: res2 = platform_get_resource_byname(device->pdev, IORESOURCE_MEM, "qdss_tmc"); 754: 755: if (!res1 || !res2) 756: goto err_clk_put; MATCH LINES: 790, 791, 793, 794, 799, 800, 813, 814, 820, 821, 825, 844, 845, 877, 879, 891, 892, 902, 903, 908, 914, 932, 935, 936, 943, 946, 982, 985, 986, 992, 995, 1023, 1024, 1029, 1030, 1032, 1036, 1037, 1069, 1071, 1073, 1074, 1077, 1080, 1081, 1087, 1090, 1127, 1130, 1131, 1138, 1141, 1170, 1171, 1176, 1177, 1179, 1183, 1184, 1217, 1220, 1221, 1249, 1250, 1253, 1254, 1260, 1296, 1299, 1300, 1307 778: 779: val_tmc_ctrl = qdss_regread(tmc_virt, QDSS_AOSS_APB_TMC_CTRL); 780: 781: /* 782: * Incase TMC CTRL is 0 and val_cx is non zero dump empty buffer. 783: * Incase TMC CTRL is 0 and val_gx is non zero dump 2k gfx buffer. 784: * 2k buffer is not present for CX blocks. 785: * Incase both ETR's CTRL is 0 Dump ETB QDSS buffer and disable QDSS. 786: * Incase either ETR's CTRL is 1 Disable QDSS dumping ETB buffer to DDR. 787: */ 788: if (!val_tmc_ctrl) { 789: if (val_gx) 790: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_TRACE_BUFFER, 791: snapshot, gen7_snapshot_trace_buffer_gfx_trace, &info); 792: else 793: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_TRACE_BUFFER, 794: snapshot, NULL, &info); 795: } else { 796: val_etr_ctrl = qdss_regread(etr_virt, QDSS_AOSS_APB_ETR_CTRL); 797: val_etr1_ctrl = qdss_regread(etr_virt, QDSS_AOSS_APB_ETR1_CTRL); 798: if (!val_etr_ctrl && !val_etr1_ctrl) 799: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_TRACE_BUFFER, 800: snapshot, gen7_snapshot_trace_buffer_etb, &info); 801: qdss_regwrite(tmc_virt, QDSS_AOSS_APB_TMC_CTRL, 0); 802: } 803: 804: err_unmap: 805: iounmap(tmc_virt); 806: iounmap(etr_virt); 807: 808: err_clk_put: 809: clk_disable_unprepare(clk); 810: clk_put(clk); 811: } 812: 813: static void gen7_snapshot_shader(struct kgsl_device *device, 814: struct kgsl_snapshot *snapshot) 815: { 816: unsigned int i; 817: struct gen7_shader_block_info info; 818: u64 *ptr; 819: u32 offset = 0; 820: struct gen7_shader_block *shader_blocks = gen7_snapshot_block_list->shader_blocks; 821: size_t num_shader_blocks = gen7_snapshot_block_list->num_shader_blocks; 822: unsigned int sp; 823: unsigned int usptp; 824: size_t (*func)(struct kgsl_device *device, u8 *buf, size_t remain, 825: void *priv) = gen7_legacy_snapshot_shader; 826: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 827: 828: if (adreno_is_gen7_0_x_family(adreno_dev) || adreno_is_gen7_14_0_family(adreno_dev)) 829: kgsl_regrmw(device, GEN7_SP_DBG_CNTL, GENMASK(1, 0), 3); 830: 831: if (CD_SCRIPT_CHECK(device)) { 832: for (i = 0; i < num_shader_blocks; i++) { 833: struct gen7_shader_block *block = &shader_blocks[i]; 834: 835: for (sp = 0; sp < block->num_sps; sp++) { 836: for (usptp = 0; usptp < block->num_usptps; usptp++) { 837: info.block = block; 838: info.sp_id = sp; 839: info.usptp = usptp; 840: info.offset = offset; 841: offset += block->size << 2; 842: 843: /* Shader working/shadow memory */ 844: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_SHADER_V2, 845: snapshot, func, &info); 846: } 847: } 848: } 849: 850: goto done; 851: } 852: 853: for (i = 0; i < num_shader_blocks; i++) { 854: struct gen7_shader_block *block = &shader_blocks[i]; 855: 856: /* Build the crash script */ 857: ptr = gen7_capturescript->hostptr; 858: offset = 0; 859: 860: for (sp = 0; sp < block->num_sps; sp++) { 861: for (usptp = 0; usptp < block->num_usptps; usptp++) { 862: /* Program the aperture */ 863: ptr += CD_WRITE(ptr, GEN7_SP_READ_SEL, 864: GEN7_SP_READ_SEL_VAL(block->location, block->pipeid, 865: block->statetype, usptp, sp)); 866: 867: /* Read all the data in one chunk */ 868: ptr += CD_READ(ptr, GEN7_SP_AHB_READ_APERTURE, block->size, 869: gen7_crashdump_registers->gpuaddr + offset); 870: offset += block->size << 2; 871: } 872: } 873: /* Marker for end of script */ 874: CD_FINISH(ptr, offset); 875: 876: /* Try to run the crash dumper */ 877: func = gen7_legacy_snapshot_shader; 878: if (_gen7_do_crashdump(device)) 879: func = gen7_snapshot_shader_memory; 880: 881: offset = 0; 882: for (sp = 0; sp < block->num_sps; sp++) { 883: for (usptp = 0; usptp < block->num_usptps; usptp++) { 884: info.block = block; 885: info.sp_id = sp; 886: info.usptp = usptp; 887: info.offset = offset; 888: offset += block->size << 2; 889: 890: /* Shader working/shadow memory */ 891: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_SHADER_V2, 892: snapshot, func, &info); 893: } 894: } 895: } 896: 897: done: 898: if (adreno_is_gen7_0_x_family(adreno_dev) || adreno_is_gen7_14_0_family(adreno_dev)) 899: kgsl_regrmw(device, GEN7_SP_DBG_CNTL, GENMASK(1, 0), 0x0); 900: } 901: 902: static void gen7_snapshot_mempool(struct kgsl_device *device, 903: struct kgsl_snapshot *snapshot) 904: { 905: /* set CP_CHICKEN_DBG[StabilizeMVC] to stabilize it while dumping */ 906: kgsl_regrmw(device, GEN7_CP_CHICKEN_DBG, 0x4, 0x4); 907: 908: kgsl_snapshot_indexed_registers(device, snapshot, 909: GEN7_CP_MEM_POOL_DBG_ADDR, GEN7_CP_MEM_POOL_DBG_DATA, 910: 0, 0x2200); 911: 912: if (!adreno_is_gen7_no_cb_family(ADRENO_DEVICE(device))) { 913: kgsl_regrmw(device, GEN7_CP_BV_CHICKEN_DBG, 0x4, 0x4); 914: kgsl_snapshot_indexed_registers(device, snapshot, 915: GEN7_CP_BV_MEM_POOL_DBG_ADDR, GEN7_CP_BV_MEM_POOL_DBG_DATA, 916: 0, 0x2200); 917: kgsl_regrmw(device, GEN7_CP_BV_CHICKEN_DBG, 0x4, 0x0); 918: } 919: 920: kgsl_regrmw(device, GEN7_CP_CHICKEN_DBG, 0x4, 0x0); 921: } 922: 923: static unsigned int gen7_read_dbgahb(struct kgsl_device *device, 924: unsigned int regbase, unsigned int reg) 925: { 926: unsigned int val; 927: 928: kgsl_regread(device, (GEN7_SP_AHB_READ_APERTURE + reg - regbase), &val); 929: return val; 930: } 931: 932: static size_t gen7_legacy_snapshot_cluster_dbgahb(struct kgsl_device *device, 933: u8 *buf, size_t remain, void *priv) 934: { 935: struct kgsl_snapshot_mvc_regs_v2 *header = 936: (struct kgsl_snapshot_mvc_regs_v2 *)buf; 937: struct gen7_sptp_cluster_registers *cluster = 938: (struct gen7_sptp_cluster_registers *)priv; 939: const u32 *ptr = cluster->regs; 940: unsigned int read_sel; 941: unsigned int *data = (unsigned int *)(buf + sizeof(*header)); 942: int j; 943: unsigned int size = adreno_snapshot_regs_count(ptr) * 4; 944: 945: if (remain < (sizeof(*header) + size)) { 946: SNAPSHOT_ERR_NOMEM(device, "MVC REGISTERS"); 947: return 0; 948: } 949: 950: header->ctxt_id = cluster->context_id; 951: header->cluster_id = cluster->cluster_id; 952: header->pipe_id = cluster->pipe_id; 953: header->location_id = cluster->location_id; 954: 955: read_sel = GEN7_SP_READ_SEL_VAL(cluster->location_id, cluster->pipe_id, 956: cluster->statetype, 0, 0); 957: 958: kgsl_regwrite(device, GEN7_SP_READ_SEL, read_sel); 959: 960: /* 961: * An explicit barrier is needed so that reads do not happen before 962: * the register write. 963: */ 964: mb(); 965: 966: for (ptr = cluster->regs; ptr[0] != UINT_MAX; ptr += 2) { 967: unsigned int count = REG_COUNT(ptr); 968: 969: if (count == 1) 970: *data++ = ptr[0]; 971: else { 972: *data++ = ptr[0] | (1 << 31); 973: *data++ = ptr[1]; 974: } 975: for (j = ptr[0]; j <= ptr[1]; j++) 976: *data++ = gen7_read_dbgahb(device, cluster->regbase, j); 977: } 978: 979: return (size + sizeof(*header)); 980: } 981: 982: static size_t gen7_snapshot_cluster_dbgahb(struct kgsl_device *device, u8 *buf, 983: size_t remain, void *priv) 984: { 985: struct kgsl_snapshot_mvc_regs_v2 *header = 986: (struct kgsl_snapshot_mvc_regs_v2 *)buf; 987: struct gen7_sptp_cluster_registers *cluster = 988: (struct gen7_sptp_cluster_registers *)priv; 989: const u32 *ptr = cluster->regs; 990: unsigned int *data = (unsigned int *)(buf + sizeof(*header)); 991: unsigned int *src; 992: unsigned int size = adreno_snapshot_regs_count(ptr) * 4; 993: 994: if (remain < (sizeof(*header) + size)) { 995: SNAPSHOT_ERR_NOMEM(device, "REGISTERS"); 996: return 0; 997: } 998: 999: header->ctxt_id = cluster->context_id; 1000: header->cluster_id = cluster->cluster_id; 1001: header->pipe_id = cluster->pipe_id; 1002: header->location_id = cluster->location_id; 1003: 1004: src = gen7_crashdump_registers->hostptr + cluster->offset; 1005: 1006: for (ptr = cluster->regs; ptr[0] != UINT_MAX; ptr += 2) { 1007: unsigned int cnt = REG_COUNT(ptr); 1008: 1009: if (cnt == 1) 1010: *data++ = ptr[0]; 1011: else { 1012: *data++ = ptr[0] | (1 << 31); 1013: *data++ = ptr[1]; 1014: } 1015: memcpy(data, src, cnt << 2); 1016: data += cnt; 1017: src += cnt; 1018: } 1019: 1020: return (size + sizeof(*header)); 1021: } 1022: 1023: static void gen7_snapshot_dbgahb_regs(struct kgsl_device *device, 1024: struct kgsl_snapshot *snapshot) 1025: { 1026: int i; 1027: u64 *ptr, offset = 0; 1028: unsigned int count; 1029: struct gen7_sptp_cluster_registers *sptp_clusters = gen7_snapshot_block_list->sptp_clusters; 1030: size_t num_sptp_clusters = gen7_snapshot_block_list->num_sptp_clusters; 1031: size_t (*func)(struct kgsl_device *device, u8 *buf, size_t remain, 1032: void *priv) = gen7_legacy_snapshot_cluster_dbgahb; 1033: 1034: if (CD_SCRIPT_CHECK(device)) { 1035: for (i = 0; i < num_sptp_clusters; i++) 1036: kgsl_snapshot_add_section(device, 1037: KGSL_SNAPSHOT_SECTION_MVC_V2, snapshot, func, 1038: &sptp_clusters[i]); 1039: return; 1040: } 1041: 1042: /* Build the crash script */ 1043: ptr = gen7_capturescript->hostptr; 1044: 1045: for (i = 0; i < num_sptp_clusters; i++) { 1046: struct gen7_sptp_cluster_registers *cluster = &sptp_clusters[i]; 1047: const u32 *regs = cluster->regs; 1048: 1049: cluster->offset = offset; 1050: 1051: /* Program the aperture */ 1052: ptr += CD_WRITE(ptr, GEN7_SP_READ_SEL, GEN7_SP_READ_SEL_VAL 1053: (cluster->location_id, cluster->pipe_id, cluster->statetype, 0, 0)); 1054: 1055: for (; regs[0] != UINT_MAX; regs += 2) { 1056: count = REG_COUNT(regs); 1057: ptr += CD_READ(ptr, (GEN7_SP_AHB_READ_APERTURE + 1058: regs[0] - cluster->regbase), count, 1059: (gen7_crashdump_registers->gpuaddr + offset)); 1060: 1061: offset += count * sizeof(unsigned int); 1062: } 1063: } 1064: /* Marker for end of script */ 1065: CD_FINISH(ptr, offset); 1066: 1067: /* Try to run the crash dumper */ 1068: if (_gen7_do_crashdump(device)) 1069: func = gen7_snapshot_cluster_dbgahb; 1070: 1071: /* Capture the registers in snapshot */ 1072: for (i = 0; i < num_sptp_clusters; i++) 1073: kgsl_snapshot_add_section(device, 1074: KGSL_SNAPSHOT_SECTION_MVC_V2, snapshot, func, &sptp_clusters[i]); 1075: } 1076: 1077: static size_t gen7_legacy_snapshot_mvc(struct kgsl_device *device, u8 *buf, 1078: size_t remain, void *priv) 1079: { 1080: struct kgsl_snapshot_mvc_regs_v2 *header = 1081: (struct kgsl_snapshot_mvc_regs_v2 *)buf; 1082: unsigned int *data = (unsigned int *)(buf + sizeof(*header)); 1083: struct gen7_cluster_registers *cluster = 1084: (struct gen7_cluster_registers *)priv; 1085: const u32 *ptr = cluster->regs; 1086: unsigned int j; 1087: unsigned int size = adreno_snapshot_regs_count(ptr) * 4; 1088: 1089: if (remain < (sizeof(*header) + size)) { 1090: SNAPSHOT_ERR_NOMEM(device, "MVC REGISTERS"); 1091: return 0; 1092: } 1093: 1094: header->ctxt_id = (cluster->context_id == STATE_FORCE_CTXT_1) ? 1 : 0; 1095: header->cluster_id = cluster->cluster_id; 1096: header->pipe_id = cluster->pipe_id; 1097: header->location_id = UINT_MAX; 1098: 1099: /* 1100: * Set the AHB control for the Host to read from the 1101: * cluster/context for this iteration. 1102: */ 1103: kgsl_regwrite(device, GEN7_CP_APERTURE_CNTL_HOST, GEN7_CP_APERTURE_REG_VAL 1104: (cluster->pipe_id, cluster->cluster_id, cluster->context_id)); 1105: 1106: if (cluster->sel) 1107: kgsl_regwrite(device, cluster->sel->host_reg, cluster->sel->val); 1108: 1109: for (ptr = cluster->regs; ptr[0] != UINT_MAX; ptr += 2) { 1110: unsigned int count = REG_COUNT(ptr); 1111: 1112: if (count == 1) 1113: *data++ = ptr[0]; 1114: else { 1115: *data++ = ptr[0] | (1 << 31); 1116: *data++ = ptr[1]; 1117: } 1118: for (j = ptr[0]; j <= ptr[1]; j++) { 1119: kgsl_regread(device, j, data); 1120: data++; 1121: } 1122: } 1123: 1124: return (size + sizeof(*header)); 1125: } 1126: 1127: static size_t gen7_snapshot_mvc(struct kgsl_device *device, u8 *buf, 1128: size_t remain, void *priv) 1129: { 1130: struct kgsl_snapshot_mvc_regs_v2 *header = 1131: (struct kgsl_snapshot_mvc_regs_v2 *)buf; 1132: struct gen7_cluster_registers *cluster = 1133: (struct gen7_cluster_registers *)priv; 1134: const u32 *ptr = cluster->regs; 1135: unsigned int *data = (unsigned int *)(buf + sizeof(*header)); 1136: unsigned int *src; 1137: unsigned int cnt; 1138: unsigned int size = adreno_snapshot_regs_count(ptr) * 4; 1139: 1140: if (remain < (sizeof(*header) + size)) { 1141: SNAPSHOT_ERR_NOMEM(device, "MVC REGISTERS"); 1142: return 0; 1143: } 1144: 1145: header->ctxt_id = (cluster->context_id == STATE_FORCE_CTXT_1) ? 1 : 0; 1146: header->cluster_id = cluster->cluster_id; 1147: header->pipe_id = cluster->pipe_id; 1148: header->location_id = UINT_MAX; 1149: 1150: src = gen7_crashdump_registers->hostptr + cluster->offset; 1151: 1152: for (ptr = cluster->regs; ptr[0] != UINT_MAX; ptr += 2) { 1153: cnt = REG_COUNT(ptr); 1154: 1155: if (cnt == 1) 1156: *data++ = ptr[0]; 1157: else { 1158: *data++ = ptr[0] | (1 << 31); 1159: *data++ = ptr[1]; 1160: } 1161: memcpy(data, src, cnt << 2); 1162: src += cnt; 1163: data += cnt; 1164: } 1165: 1166: return (size + sizeof(*header)); 1167: 1168: } 1169: 1170: static void gen7_snapshot_mvc_regs(struct kgsl_device *device, 1171: struct kgsl_snapshot *snapshot) 1172: { 1173: int i; 1174: u64 *ptr, offset = 0; 1175: unsigned int count; 1176: struct gen7_cluster_registers *clusters = gen7_snapshot_block_list->clusters; 1177: size_t num_clusters = gen7_snapshot_block_list->num_clusters; 1178: size_t (*func)(struct kgsl_device *device, u8 *buf, 1179: size_t remain, void *priv) = gen7_legacy_snapshot_mvc; 1180: 1181: if (CD_SCRIPT_CHECK(device)) { 1182: for (i = 0; i < num_clusters; i++) 1183: kgsl_snapshot_add_section(device, 1184: KGSL_SNAPSHOT_SECTION_MVC_V2, snapshot, func, &clusters[i]); 1185: return; 1186: } 1187: 1188: /* Build the crash script */ 1189: ptr = gen7_capturescript->hostptr; 1190: 1191: for (i = 0; i < num_clusters; i++) { 1192: struct gen7_cluster_registers *cluster = &clusters[i]; 1193: const u32 *regs = cluster->regs; 1194: 1195: cluster->offset = offset; 1196: ptr += CD_WRITE(ptr, GEN7_CP_APERTURE_CNTL_CD, GEN7_CP_APERTURE_REG_VAL 1197: (cluster->pipe_id, cluster->cluster_id, cluster->context_id)); 1198: 1199: if (cluster->sel) 1200: ptr += CD_WRITE(ptr, cluster->sel->cd_reg, cluster->sel->val); 1201: 1202: for (; regs[0] != UINT_MAX; regs += 2) { 1203: count = REG_COUNT(regs); 1204: 1205: ptr += CD_READ(ptr, regs[0], 1206: count, (gen7_crashdump_registers->gpuaddr + offset)); 1207: 1208: offset += count * sizeof(unsigned int); 1209: } 1210: } 1211: 1212: /* Marker for end of script */ 1213: CD_FINISH(ptr, offset); 1214: 1215: /* Try to run the crash dumper */ 1216: if (_gen7_do_crashdump(device)) 1217: func = gen7_snapshot_mvc; 1218: 1219: for (i = 0; i < num_clusters; i++) 1220: kgsl_snapshot_add_section(device, 1221: KGSL_SNAPSHOT_SECTION_MVC_V2, snapshot, func, &clusters[i]); 1222: } 1223: 1224: /* gen7_dbgc_debug_bus_read() - Read data from trace bus */ 1225: static void gen7_dbgc_debug_bus_read(struct kgsl_device *device, 1226: unsigned int block_id, unsigned int index, unsigned int *val) 1227: { 1228: unsigned int reg; 1229: 1230: reg = FIELD_PREP(GENMASK(7, 0), index) | 1231: FIELD_PREP(GENMASK(24, 16), block_id); 1232: 1233: kgsl_regwrite(device, GEN7_DBGC_CFG_DBGBUS_SEL_A, reg); 1234: kgsl_regwrite(device, GEN7_DBGC_CFG_DBGBUS_SEL_B, reg); 1235: kgsl_regwrite(device, GEN7_DBGC_CFG_DBGBUS_SEL_C, reg); 1236: kgsl_regwrite(device, GEN7_DBGC_CFG_DBGBUS_SEL_D, reg); 1237: 1238: /* 1239: * There needs to be a delay of 1 us to ensure enough time for correct 1240: * data is funneled into the trace buffer 1241: */ 1242: udelay(1); 1243: 1244: kgsl_regread(device, GEN7_DBGC_CFG_DBGBUS_TRACE_BUF2, val); 1245: val++; 1246: kgsl_regread(device, GEN7_DBGC_CFG_DBGBUS_TRACE_BUF1, val); 1247: } 1248: 1249: /* gen7_snapshot_dbgc_debugbus_block() - Capture debug data for a gpu block */ 1250: static size_t gen7_snapshot_dbgc_debugbus_block(struct kgsl_device *device, 1251: u8 *buf, size_t remain, void *priv) 1252: { 1253: struct kgsl_snapshot_debugbus *header = 1254: (struct kgsl_snapshot_debugbus *)buf; 1255: const u32 *block = priv; 1256: int i; 1257: unsigned int *data = (unsigned int *)(buf + sizeof(*header)); 1258: 1259: if (remain < GEN7_DEBUGBUS_SECTION_SIZE) { 1260: SNAPSHOT_ERR_NOMEM(device, "DEBUGBUS"); 1261: return 0; 1262: } 1263: 1264: header->id = *block; 1265: header->count = GEN7_DEBUGBUS_BLOCK_SIZE * 2; 1266: 1267: for (i = 0; i < GEN7_DEBUGBUS_BLOCK_SIZE; i++) 1268: gen7_dbgc_debug_bus_read(device, *block, i, &data[i*2]); 1269: 1270: return GEN7_DEBUGBUS_SECTION_SIZE; 1271: } 1272: 1273: static u32 gen7_dbgc_side_debug_bus_read(struct kgsl_device *device, 1274: unsigned int block_id, unsigned int index) 1275: { 1276: u32 val; 1277: unsigned int reg = FIELD_PREP(GENMASK(7, 0), index) | 1278: FIELD_PREP(GENMASK(24, 16), block_id); 1279: 1280: kgsl_regwrite(device, GEN7_DBGC_CFG_DBGBUS_SEL_A, reg); 1281: kgsl_regwrite(device, GEN7_DBGC_CFG_DBGBUS_SEL_B, reg); 1282: kgsl_regwrite(device, GEN7_DBGC_CFG_DBGBUS_SEL_C, reg); 1283: kgsl_regwrite(device, GEN7_DBGC_CFG_DBGBUS_SEL_D, reg); 1284: 1285: /* 1286: * There needs to be a delay of 1 us to ensure enough time for correct 1287: * data is funneled into the trace buffer 1288: */ 1289: udelay(1); 1290: 1291: val = kgsl_regmap_read(&device->regmap, GEN7_DBGC_CFG_DBGBUS_OVER); 1292: 1293: return FIELD_GET(GENMASK(27, 24), val); 1294: } 1295: 1296: static size_t gen7_snapshot_dbgc_side_debugbus_block(struct kgsl_device *device, 1297: u8 *buf, size_t remain, void *priv) 1298: { 1299: struct kgsl_snapshot_side_debugbus *header = 1300: (struct kgsl_snapshot_side_debugbus *)buf; 1301: const u32 *block = priv; 1302: int i; 1303: unsigned int *data = (unsigned int *)(buf + sizeof(*header)); 1304: size_t size = (GEN7_DEBUGBUS_BLOCK_SIZE * sizeof(unsigned int)) + sizeof(*header); 1305: 1306: if (remain < size) { 1307: SNAPSHOT_ERR_NOMEM(device, "DEBUGBUS"); 1308: return 0; 1309: } 1310: 1311: header->id = *block; 1312: header->size = GEN7_DEBUGBUS_BLOCK_SIZE; 1313: header->valid_data = 0x4; 1314: 1315: for (i = 0; i < GEN7_DEBUGBUS_BLOCK_SIZE; i++) 1316: data[i] = gen7_dbgc_side_debug_bus_read(device, *block, i); 1317: 1318: return size; 1319: } 1320: 1321: /* gen7_cx_dbgc_debug_bus_read() - Read data from trace bus */ 1322: static void gen7_cx_debug_bus_read(struct kgsl_device *device, 1323: unsigned int block_id, unsigned int index, unsigned int *val) 1324: { 1325: unsigned int reg; 1326: 1327: reg = FIELD_PREP(GENMASK(7, 0), index) | 1328: FIELD_PREP(GENMASK(24, 16), block_id); 1329: 1330: kgsl_regwrite(device, GEN7_CX_DBGC_CFG_DBGBUS_SEL_A, reg); 1331: kgsl_regwrite(device, GEN7_CX_DBGC_CFG_DBGBUS_SEL_B, reg); MATCH LINES: 1347, 1350, 1353, 1354, 1360, 1396, 1399, 1402, 1403, 1410, 1424, 1425, 1426 1335: /* 1336: * There needs to be a delay of 1 us to ensure enough time for correct 1337: * data is funneled into the trace buffer 1338: */ 1339: udelay(1); 1340: 1341: kgsl_regread(device, GEN7_CX_DBGC_CFG_DBGBUS_TRACE_BUF2, val); 1342: val++; 1343: kgsl_regread(device, GEN7_CX_DBGC_CFG_DBGBUS_TRACE_BUF1, val); 1344: } 1345: 1346: /* 1347: * gen7_snapshot_cx_dbgc_debugbus_block() - Capture debug data for a gpu 1348: * block from the CX DBGC block 1349: */ 1350: static size_t gen7_snapshot_cx_dbgc_debugbus_block(struct kgsl_device *device, 1351: u8 *buf, size_t remain, void *priv) 1352: { 1353: struct kgsl_snapshot_debugbus *header = 1354: (struct kgsl_snapshot_debugbus *)buf; 1355: const u32 *block = priv; 1356: int i; 1357: unsigned int *data = (unsigned int *)(buf + sizeof(*header)); 1358: 1359: if (remain < GEN7_DEBUGBUS_SECTION_SIZE) { 1360: SNAPSHOT_ERR_NOMEM(device, "DEBUGBUS"); 1361: return 0; 1362: } 1363: 1364: header->id = *block; 1365: header->count = GEN7_DEBUGBUS_BLOCK_SIZE * 2; 1366: 1367: for (i = 0; i < GEN7_DEBUGBUS_BLOCK_SIZE; i++) 1368: gen7_cx_debug_bus_read(device, *block, i, &data[i*2]); 1369: 1370: return GEN7_DEBUGBUS_SECTION_SIZE; 1371: } 1372: 1373: /* gen7_cx_side_dbgc_debug_bus_read() - Read data from trace bus */ 1374: static void gen7_cx_side_debug_bus_read(struct kgsl_device *device, 1375: unsigned int block_id, unsigned int index, unsigned int *val) 1376: { 1377: unsigned int reg = FIELD_PREP(GENMASK(7, 0), index) | 1378: FIELD_PREP(GENMASK(24, 16), block_id); 1379: 1380: kgsl_regwrite(device, GEN7_CX_DBGC_CFG_DBGBUS_SEL_A, reg); 1381: kgsl_regwrite(device, GEN7_CX_DBGC_CFG_DBGBUS_SEL_B, reg); 1382: kgsl_regwrite(device, GEN7_CX_DBGC_CFG_DBGBUS_SEL_C, reg); 1383: kgsl_regwrite(device, GEN7_CX_DBGC_CFG_DBGBUS_SEL_D, reg); 1384: 1385: /* 1386: * There needs to be a delay of 1 us to ensure enough time for correct 1387: * data is funneled into the trace buffer 1388: */ 1389: udelay(1); 1390: 1391: kgsl_regread(device, GEN7_CX_DBGC_CFG_DBGBUS_OVER, ®); 1392: *val = FIELD_GET(GENMASK(27, 24), reg); 1393: } 1394: 1395: /* 1396: * gen7_snapshot_cx_dbgc_debugbus_block() - Capture debug data for a gpu 1397: * block from the CX DBGC block 1398: */ 1399: static size_t gen7_snapshot_cx_side_dbgc_debugbus_block(struct kgsl_device *device, 1400: u8 *buf, size_t remain, void *priv) 1401: { 1402: struct kgsl_snapshot_side_debugbus *header = 1403: (struct kgsl_snapshot_side_debugbus *)buf; 1404: const u32 *block = priv; 1405: int i; 1406: unsigned int *data = (unsigned int *)(buf + sizeof(*header)); 1407: size_t size = (GEN7_DEBUGBUS_BLOCK_SIZE * sizeof(unsigned int)) + sizeof(*header); 1408: 1409: if (remain < size) { 1410: SNAPSHOT_ERR_NOMEM(device, "DEBUGBUS"); 1411: return 0; 1412: } 1413: 1414: header->id = *block; 1415: header->size = GEN7_DEBUGBUS_BLOCK_SIZE; 1416: header->valid_data = 0x4; 1417: 1418: for (i = 0; i < GEN7_DEBUGBUS_BLOCK_SIZE; i++) 1419: gen7_cx_side_debug_bus_read(device, *block, i, &data[i]); 1420: 1421: return size; 1422: } 1423: 1424: /* gen7_snapshot_debugbus() - Capture debug bus data */ 1425: static void gen7_snapshot_debugbus(struct adreno_device *adreno_dev, 1426: struct kgsl_snapshot *snapshot) 1427: { 1428: int i; 1429: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1430: 1431: if (device->debug_bus_bin) 1432: return; 1433: 1434: kgsl_regwrite(device, GEN7_DBGC_CFG_DBGBUS_CNTLT, 1435: FIELD_PREP(GENMASK(31, 28), 0xf)); 1436: 1437: kgsl_regwrite(device, GEN7_DBGC_CFG_DBGBUS_CNTLM, 1438: FIELD_PREP(GENMASK(27, 24), 0xf)); 1439: 1440: kgsl_regwrite(device, GEN7_DBGC_CFG_DBGBUS_IVTL_0, 0); 1441: kgsl_regwrite(device, GEN7_DBGC_CFG_DBGBUS_IVTL_1, 0); 1442: kgsl_regwrite(device, GEN7_DBGC_CFG_DBGBUS_IVTL_2, 0); 1443: kgsl_regwrite(device, GEN7_DBGC_CFG_DBGBUS_IVTL_3, 0); 1444: 1445: kgsl_regwrite(device, GEN7_DBGC_CFG_DBGBUS_BYTEL_0, 1446: FIELD_PREP(GENMASK(3, 0), 0x0) | 1447: FIELD_PREP(GENMASK(7, 4), 0x1) | 1448: FIELD_PREP(GENMASK(11, 8), 0x2) | 1449: FIELD_PREP(GENMASK(15, 12), 0x3) | 1450: FIELD_PREP(GENMASK(19, 16), 0x4) | MATCH LINES: 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1515, 1516, 1517, 1518, 1519, 1520, 1521, 1522, 1523, 1528, 1529, 1530, 1531, 1532, 1533, 1534, 1535, 1536, 1541, 1542, 1547, 1549, 1553, 1554, 1584, 1587, 1588, 1591, 1596, 1599, 1623, 1624, 1627, 1648, 1649, 1650, 1655, 1662, 1663, 1666, 1667, 1681, 1685, 1686, 1700, 1704, 1705, 1719, 1723, 1724, 1731, 1732, 1733, 1738, 1739, 1745, 1746, 1747, 1750, 1752, 1753, 1762, 1764, 1766, 1768, 1772, 1787, 1796, 1807, 1810, 1813, 1816, 1818, 1820, 1823, 1826, 1829, 1831, 1833, 1834, 1837, 1838, 1839, 1841, 1851, 1860, 1861, 1862, 1863, 1864, 1867, 1871, 1875, 1878, 1881, 1884, 1887, 1889, 1890, 1891, 1893, 1896 1492: FIELD_PREP(GENMASK(11, 8), 0xa) | 1493: FIELD_PREP(GENMASK(15, 12), 0xb) | 1494: FIELD_PREP(GENMASK(19, 16), 0xc) | 1495: FIELD_PREP(GENMASK(23, 20), 0xd) | 1496: FIELD_PREP(GENMASK(27, 24), 0xe) | 1497: FIELD_PREP(GENMASK(31, 28), 0xf)); 1498: 1499: kgsl_regwrite(device, GEN7_CX_DBGC_CFG_DBGBUS_MASKL_0, 0); 1500: kgsl_regwrite(device, GEN7_CX_DBGC_CFG_DBGBUS_MASKL_1, 0); 1501: kgsl_regwrite(device, GEN7_CX_DBGC_CFG_DBGBUS_MASKL_2, 0); 1502: kgsl_regwrite(device, GEN7_CX_DBGC_CFG_DBGBUS_MASKL_3, 0); 1503: 1504: for (i = 0; i < gen7_snapshot_block_list->debugbus_blocks_len; i++) { 1505: kgsl_snapshot_add_section(device, 1506: KGSL_SNAPSHOT_SECTION_DEBUGBUS, 1507: snapshot, gen7_snapshot_dbgc_debugbus_block, 1508: (void *) &gen7_snapshot_block_list->debugbus_blocks[i]); 1509: kgsl_snapshot_add_section(device, 1510: KGSL_SNAPSHOT_SECTION_SIDE_DEBUGBUS, 1511: snapshot, gen7_snapshot_dbgc_side_debugbus_block, 1512: (void *) &gen7_snapshot_block_list->debugbus_blocks[i]); 1513: } 1514: 1515: for (i = 0; i < gen7_snapshot_block_list->gbif_debugbus_blocks_len; i++) { 1516: kgsl_snapshot_add_section(device, 1517: KGSL_SNAPSHOT_SECTION_DEBUGBUS, 1518: snapshot, gen7_snapshot_dbgc_debugbus_block, 1519: (void *) &gen7_snapshot_block_list->gbif_debugbus_blocks[i]); 1520: kgsl_snapshot_add_section(device, 1521: KGSL_SNAPSHOT_SECTION_SIDE_DEBUGBUS, 1522: snapshot, gen7_snapshot_dbgc_side_debugbus_block, 1523: (void *) &gen7_snapshot_block_list->gbif_debugbus_blocks[i]); 1524: } 1525: 1526: /* Dump the CX debugbus data if the block exists */ 1527: if (kgsl_regmap_valid_offset(&device->regmap, GEN7_CX_DBGC_CFG_DBGBUS_SEL_A)) { 1528: for (i = 0; i < gen7_snapshot_block_list->cx_debugbus_blocks_len; i++) { 1529: kgsl_snapshot_add_section(device, 1530: KGSL_SNAPSHOT_SECTION_DEBUGBUS, 1531: snapshot, gen7_snapshot_cx_dbgc_debugbus_block, 1532: (void *) &gen7_snapshot_block_list->cx_debugbus_blocks[i]); 1533: kgsl_snapshot_add_section(device, 1534: KGSL_SNAPSHOT_SECTION_SIDE_DEBUGBUS, 1535: snapshot, gen7_snapshot_cx_side_dbgc_debugbus_block, 1536: (void *) &gen7_snapshot_block_list->cx_debugbus_blocks[i]); 1537: } 1538: } 1539: } 1540: 1541: static void gen7_reglist_snapshot(struct kgsl_device *device, 1542: struct kgsl_snapshot *snapshot) 1543: { 1544: u64 *ptr, offset = 0; 1545: int i; 1546: u32 r; 1547: struct gen7_reg_list *reg_list = gen7_snapshot_block_list->reg_list; 1548: size_t (*func)(struct kgsl_device *device, u8 *buf, size_t remain, 1549: void *priv) = gen7_legacy_snapshot_registers; 1550: 1551: if (CD_SCRIPT_CHECK(device)) { 1552: for (i = 0; reg_list[i].regs; i++) 1553: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, 1554: snapshot, func, ®_list[i]); 1555: return; 1556: } 1557: 1558: /* Build the crash script */ 1559: ptr = (u64 *)gen7_capturescript->hostptr; 1560: 1561: for (i = 0; reg_list[i].regs; i++) { 1562: struct gen7_reg_list *regs = ®_list[i]; 1563: const u32 *regs_ptr = regs->regs; 1564: 1565: regs->offset = offset; 1566: 1567: /* Program the SEL_CNTL_CD register appropriately */ 1568: if (regs->sel) 1569: ptr += CD_WRITE(ptr, regs->sel->cd_reg, regs->sel->val); 1570: 1571: for (; regs_ptr[0] != UINT_MAX; regs_ptr += 2) { 1572: r = REG_COUNT(regs_ptr); 1573: ptr += CD_READ(ptr, regs_ptr[0], r, 1574: (gen7_crashdump_registers->gpuaddr + offset)); 1575: offset += r * sizeof(u32); 1576: } 1577: } 1578: 1579: /* Marker for end of script */ 1580: CD_FINISH(ptr, offset); 1581: 1582: /* Try to run the crash dumper */ 1583: if (_gen7_do_crashdump(device)) 1584: func = gen7_snapshot_registers; 1585: 1586: for (i = 0; reg_list[i].regs; i++) 1587: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, 1588: snapshot, func, ®_list[i]); 1589: } 1590: 1591: static size_t gen7_snapshot_cx_misc_registers(struct kgsl_device *device, u8 *buf, 1592: size_t remain, void *priv) 1593: { 1594: const u32 *ptr = (u32 *)priv; 1595: u32 *src, *data = (unsigned int *)buf; 1596: size_t size = adreno_snapshot_regs_count(ptr) * sizeof(u32); 1597: 1598: if (remain < size) { 1599: SNAPSHOT_ERR_NOMEM(device, "CX_MISC REGISTERS"); 1600: return 0; 1601: } 1602: 1603: src = gen7_crashdump_registers->hostptr; 1604: 1605: for (; ptr[0] != UINT_MAX; ptr += 2) { 1606: u32 cnt = REG_COUNT(ptr); 1607: 1608: if (cnt == 1) 1609: *data++ = BIT(31) | ptr[0]; 1610: else { 1611: *data++ = ptr[0]; 1612: *data++ = cnt; 1613: } 1614: memcpy(data, src, cnt << 2); 1615: data += cnt; 1616: src += cnt; 1617: } 1618: 1619: /* Return the size of the section */ 1620: return size; 1621: } 1622: 1623: static void gen7_cx_misc_regs_snapshot(struct kgsl_device *device, 1624: struct kgsl_snapshot *snapshot) 1625: { 1626: u64 *ptr, offset = 0; 1627: const u32 *regs_ptr = (const u32 *)gen7_snapshot_block_list->cx_misc_regs; 1628: 1629: if (CD_SCRIPT_CHECK(device) || !adreno_gx_is_on(ADRENO_DEVICE(device))) 1630: goto done; 1631: 1632: /* Build the crash script */ 1633: ptr = (u64 *)gen7_capturescript->hostptr; 1634: 1635: for (; regs_ptr[0] != UINT_MAX; regs_ptr += 2) { 1636: u32 r = REG_COUNT(regs_ptr); 1637: 1638: ptr += CD_READ(ptr, regs_ptr[0], r, 1639: (gen7_crashdump_registers->gpuaddr + offset)); 1640: offset += r * sizeof(u32); 1641: } 1642: 1643: /* Marker for end of script */ 1644: CD_FINISH(ptr, offset); 1645: 1646: /* Try to run the crash dumper */ 1647: if (_gen7_do_crashdump(device)) { 1648: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, 1649: snapshot, gen7_snapshot_cx_misc_registers, 1650: (void *)gen7_snapshot_block_list->cx_misc_regs); 1651: return; 1652: } 1653: 1654: done: 1655: regs_ptr = (const u32 *)gen7_snapshot_block_list->cx_misc_regs; 1656: 1657: if (!kgsl_regmap_valid_offset(&device->regmap, regs_ptr[0])) { 1658: WARN_ONCE(1, "cx_misc registers are not defined in device tree"); 1659: return; 1660: } 1661: 1662: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, 1663: snapshot, adreno_snapshot_registers_v2, (void *)regs_ptr); 1664: } 1665: 1666: static void gen7_snapshot_br_roq(struct kgsl_device *device, 1667: struct kgsl_snapshot *snapshot) 1668: { 1669: unsigned int roq_size; 1670: 1671: /* 1672: * CP ROQ dump units is 4 dwords. The number of units is stored 1673: * in CP_ROQ_THRESHOLDS_2[31:20], but it is not accessible to 1674: * host. Program the GEN7_CP_SQE_UCODE_DBG_ADDR with 0x70d3 offset 1675: * and read the value CP_ROQ_THRESHOLDS_2 from 1676: * GEN7_CP_SQE_UCODE_DBG_DATA 1677: */ 1678: kgsl_regwrite(device, GEN7_CP_SQE_UCODE_DBG_ADDR, 0x70d3); 1679: kgsl_regread(device, GEN7_CP_SQE_UCODE_DBG_DATA, &roq_size); 1680: roq_size = roq_size >> 20; 1681: kgsl_snapshot_indexed_registers(device, snapshot, 1682: GEN7_CP_ROQ_DBG_ADDR, GEN7_CP_ROQ_DBG_DATA, 0, (roq_size << 2)); 1683: } 1684: 1685: static void gen7_snapshot_bv_roq(struct kgsl_device *device, 1686: struct kgsl_snapshot *snapshot) 1687: { 1688: unsigned int roq_size; 1689: 1690: /* 1691: * CP ROQ dump units is 4 dwords. The number of units is stored 1692: * in CP_BV_ROQ_THRESHOLDS_2[31:20], but it is not accessible to 1693: * host. Program the GEN7_CP_BV_SQE_UCODE_DBG_ADDR with 0x70d3 offset 1694: * (at which CP stores the roq values) and read the value of 1695: * CP_BV_ROQ_THRESHOLDS_2 from GEN7_CP_BV_SQE_UCODE_DBG_DATA 1696: */ 1697: kgsl_regwrite(device, GEN7_CP_BV_SQE_UCODE_DBG_ADDR, 0x70d3); 1698: kgsl_regread(device, GEN7_CP_BV_SQE_UCODE_DBG_DATA, &roq_size); 1699: roq_size = roq_size >> 20; 1700: kgsl_snapshot_indexed_registers(device, snapshot, 1701: GEN7_CP_BV_ROQ_DBG_ADDR, GEN7_CP_BV_ROQ_DBG_DATA, 0, (roq_size << 2)); 1702: } 1703: 1704: static void gen7_snapshot_lpac_roq(struct kgsl_device *device, 1705: struct kgsl_snapshot *snapshot) 1706: { 1707: unsigned int roq_size; 1708: 1709: /* 1710: * CP ROQ dump units is 4 dwords. The number of units is stored 1711: * in CP_LPAC_ROQ_THRESHOLDS_2[31:20], but it is not accessible to 1712: * host. Program the GEN7_CP_SQE_AC_UCODE_DBG_ADDR with 0x70d3 offset 1713: * (at which CP stores the roq values) and read the value of 1714: * CP_LPAC_ROQ_THRESHOLDS_2 from GEN7_CP_SQE_AC_UCODE_DBG_DATA 1715: */ 1716: kgsl_regwrite(device, GEN7_CP_SQE_AC_UCODE_DBG_ADDR, 0x70d3); 1717: kgsl_regread(device, GEN7_CP_SQE_AC_UCODE_DBG_DATA, &roq_size); 1718: roq_size = roq_size >> 20; 1719: kgsl_snapshot_indexed_registers(device, snapshot, 1720: GEN7_CP_LPAC_ROQ_DBG_ADDR, GEN7_CP_LPAC_ROQ_DBG_DATA, 0, (roq_size << 2)); 1721: } 1722: 1723: void gen7_snapshot_external_core_regs(struct kgsl_device *device, 1724: struct kgsl_snapshot *snapshot) 1725: { 1726: size_t i; 1727: const u32 **external_core_regs; 1728: unsigned int num_external_core_regs; 1729: const struct adreno_gen7_core *gpucore = to_gen7_core(ADRENO_DEVICE(device)); 1730: 1731: gen7_snapshot_block_list = gpucore->gen7_snapshot_block_list; 1732: external_core_regs = gen7_snapshot_block_list->external_core_regs; 1733: num_external_core_regs = gen7_snapshot_block_list->num_external_core_regs; 1734: 1735: for (i = 0; i < num_external_core_regs; i++) { 1736: const u32 *regs = external_core_regs[i]; 1737: 1738: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, 1739: snapshot, adreno_snapshot_registers_v2, 1740: (void *) regs); 1741: } 1742: } 1743: 1744: /* 1745: * gen7_snapshot() - GEN7 GPU snapshot function 1746: * @adreno_dev: Device being snapshotted 1747: * @snapshot: Pointer to the snapshot instance 1748: * 1749: * This is where all of the GEN7 specific bits and pieces are grabbed 1750: * into the snapshot memory 1751: */ 1752: void gen7_snapshot(struct adreno_device *adreno_dev, 1753: struct kgsl_snapshot *snapshot) 1754: { 1755: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1756: unsigned int i; 1757: u32 cgc = 0, cgc1 = 0, cgc2 = 0; 1758: const struct adreno_gen7_core *gpucore = to_gen7_core(ADRENO_DEVICE(device)); 1759: int is_current_rt; 1760: 1761: gen7_crashdump_timedout = false; 1762: gen7_snapshot_block_list = gpucore->gen7_snapshot_block_list; 1763: 1764: /* External registers are dumped in the beginning of gmu snapshot */ 1765: if (!gmu_core_isenabled(device)) 1766: gen7_snapshot_external_core_regs(device, snapshot); 1767: 1768: gen7_snapshot_trace_buffer(device, snapshot); 1769: 1770: /* 1771: * Dump debugbus data here to capture it for both 1772: * GMU and GPU snapshot. Debugbus data can be accessed 1773: * even if the gx headswitch is off. If gx 1774: * headswitch is off, data for gx blocks will show as 1775: * 0x5c00bd00. Disable clock gating for SP and TP to capture 1776: * debugbus data. 1777: */ 1778: if (!adreno_is_gen7_9_x(adreno_dev) && device->ftbl->is_hwcg_on(device)) { 1779: kgsl_regread(device, GEN7_RBBM_CLOCK_CNTL2_SP0, &cgc); 1780: kgsl_regread(device, GEN7_RBBM_CLOCK_CNTL_TP0, &cgc1); 1781: kgsl_regread(device, GEN7_RBBM_CLOCK_CNTL3_TP0, &cgc2); 1782: kgsl_regrmw(device, GEN7_RBBM_CLOCK_CNTL2_SP0, GENMASK(22, 20), 0); 1783: kgsl_regrmw(device, GEN7_RBBM_CLOCK_CNTL_TP0, GENMASK(2, 0), 0); 1784: kgsl_regrmw(device, GEN7_RBBM_CLOCK_CNTL3_TP0, GENMASK(14, 12), 0); 1785: } 1786: 1787: gen7_snapshot_debugbus(adreno_dev, snapshot); 1788: 1789: /* Restore the value of the clockgating registers */ 1790: if (!adreno_is_gen7_9_x(adreno_dev) && device->ftbl->is_hwcg_on(device)) { 1791: kgsl_regwrite(device, GEN7_RBBM_CLOCK_CNTL2_SP0, cgc); 1792: kgsl_regwrite(device, GEN7_RBBM_CLOCK_CNTL_TP0, cgc1); 1793: kgsl_regwrite(device, GEN7_RBBM_CLOCK_CNTL3_TP0, cgc2); 1794: } 1795: 1796: gen7_cx_misc_regs_snapshot(device, snapshot); 1797: 1798: if (!adreno_gx_is_on(adreno_dev)) 1799: return; 1800: 1801: is_current_rt = rt_task(current); 1802: 1803: if (is_current_rt) 1804: sched_set_normal(current, 0); 1805: 1806: gen7_periph_regread64(device, GEN7_CP_PERIPH_IB1_BASE_LO(adreno_dev), 1807: GEN7_CP_PERIPH_IB1_BASE_HI(adreno_dev), &snapshot->ib1base, PIPE_BR); 1808: 1809: gen7_periph_regread64(device, GEN7_CP_PERIPH_IB2_BASE_LO(adreno_dev), 1810: GEN7_CP_PERIPH_IB2_BASE_HI(adreno_dev), &snapshot->ib2base, PIPE_BR); 1811: 1812: gen7_periph_regread64(device, GEN7_CP_PERIPH_IB3_BASE_LO(adreno_dev), 1813: GEN7_CP_PERIPH_IB3_BASE_HI(adreno_dev), &snapshot->ib3base, PIPE_BR); 1814: 1815: gen7_periph_regread(device, GEN7_CP_PERIPH_IB1_SIZE(adreno_dev), 1816: &snapshot->ib1size, PIPE_BR); 1817: gen7_periph_regread(device, GEN7_CP_PERIPH_IB2_SIZE(adreno_dev), 1818: &snapshot->ib2size, PIPE_BR); 1819: gen7_periph_regread(device, GEN7_CP_PERIPH_IB3_SIZE(adreno_dev), 1820: &snapshot->ib3size, PIPE_BR); 1821: 1822: gen7_periph_regread64(device, GEN7_CP_PERIPH_IB1_BASE_LO(adreno_dev), 1823: GEN7_CP_PERIPH_IB1_BASE_HI(adreno_dev), &snapshot->ib1base_lpac, PIPE_LPAC); 1824: 1825: gen7_periph_regread64(device, GEN7_CP_PERIPH_IB2_BASE_LO(adreno_dev), 1826: GEN7_CP_PERIPH_IB2_BASE_HI(adreno_dev), &snapshot->ib2base_lpac, PIPE_LPAC); 1827: 1828: gen7_periph_regread(device, GEN7_CP_PERIPH_IB1_SIZE(adreno_dev), 1829: &snapshot->ib1size_lpac, PIPE_LPAC); 1830: gen7_periph_regread(device, GEN7_CP_PERIPH_IB2_SIZE(adreno_dev), 1831: &snapshot->ib2size_lpac, PIPE_LPAC); 1832: 1833: /* Assert the isStatic bit before triggering snapshot */ 1834: kgsl_regwrite(device, GEN7_RBBM_SNAPSHOT_STATUS, 0x1); 1835: 1836: /* Dump the registers which get affected by crash dumper trigger */ 1837: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, 1838: snapshot, adreno_snapshot_registers_v2, 1839: (void *) gen7_snapshot_block_list->pre_crashdumper_regs); 1840: 1841: gen7_reglist_snapshot(device, snapshot); 1842: 1843: /* 1844: * Need to program and save this register before capturing resource table 1845: * to workaround a CGC issue 1846: */ 1847: if (device->ftbl->is_hwcg_on(device)) { 1848: kgsl_regread(device, GEN7_RBBM_CLOCK_MODE_CP, &cgc); 1849: kgsl_regrmw(device, GEN7_RBBM_CLOCK_MODE_CP, 0x7, 0); 1850: } 1851: kgsl_snapshot_indexed_registers(device, snapshot, 1852: GEN7_CP_RESOURCE_TABLE_DBG_ADDR, GEN7_CP_RESOURCE_TABLE_DBG_DATA, 1853: 0, 0x4100); 1854: 1855: /* Reprogram the register back to the original stored value */ 1856: if (device->ftbl->is_hwcg_on(device)) 1857: kgsl_regwrite(device, GEN7_RBBM_CLOCK_MODE_CP, cgc); 1858: 1859: 1860: for (i = 0; i < gen7_snapshot_block_list->index_registers_len; i++) 1861: kgsl_snapshot_indexed_registers(device, snapshot, 1862: gen7_snapshot_block_list->index_registers[i].addr, 1863: gen7_snapshot_block_list->index_registers[i].data, 0, 1864: gen7_snapshot_block_list->index_registers[i].size); 1865: 1866: if (!adreno_is_gen7_9_x(adreno_dev)) 1867: gen7_snapshot_br_roq(device, snapshot); 1868: 1869: if (!adreno_is_gen7_9_x(adreno_dev) && 1870: !adreno_is_gen7_no_cb_family(adreno_dev)) 1871: gen7_snapshot_bv_roq(device, snapshot); 1872: 1873: if (!adreno_is_gen7_9_x(adreno_dev) && 1874: ADRENO_FEATURE(adreno_dev, ADRENO_LPAC)) 1875: gen7_snapshot_lpac_roq(device, snapshot); 1876: 1877: /* Mempool debug data */ 1878: gen7_snapshot_mempool(device, snapshot); 1879: 1880: /* MVC register section */ 1881: gen7_snapshot_mvc_regs(device, snapshot); 1882: 1883: /* registers dumped through DBG AHB */ 1884: gen7_snapshot_dbgahb_regs(device, snapshot); 1885: 1886: /* Shader memory */ 1887: gen7_snapshot_shader(device, snapshot); 1888: 1889: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, 1890: snapshot, adreno_snapshot_registers_v2, 1891: (void *) gen7_snapshot_block_list->post_crashdumper_regs); 1892: 1893: kgsl_regwrite(device, GEN7_RBBM_SNAPSHOT_STATUS, 0x0); 1894: 1895: /* Preemption record */ 1896: adreno_snapshot_preemption_record(device, snapshot); 1897: 1898: if (is_current_rt) 1899: sched_set_fifo(current); 1900: } 1901: 1902: void gen7_crashdump_init(struct adreno_device *adreno_dev) 1903: { 1904: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1905: 1906: if (IS_ERR_OR_NULL(gen7_capturescript)) 1907: gen7_capturescript = kgsl_allocate_global(device, 1908: 3 * PAGE_SIZE, 0, KGSL_MEMFLAGS_GPUREADONLY, 1909: KGSL_MEMDESC_PRIVILEGED, "capturescript"); 1910: 1911: if (IS_ERR(gen7_capturescript)) 1912: return; 1913: 1914: if (IS_ERR_OR_NULL(gen7_crashdump_registers)) 1915: gen7_crashdump_registers = kgsl_allocate_global(device, 1916: 25 * PAGE_SIZE, 0, 0, KGSL_MEMDESC_PRIVILEGED, 1917: "capturescript_regs"); 1918: 1919: if (IS_ERR(gen7_crashdump_registers)) 1920: return; --- FILE: \adreno_gen7_snapshot.h | HITS: 4 --- MATCH LINES: 6, 7 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_GEN7_SNAPSHOT_H 7: #define __ADRENO_GEN7_SNAPSHOT_H 8: 9: #include "adreno.h" 10: #include "adreno_gen7.h" 11: #include "kgsl_regmap.h" 12: 13: #define CLUSTER_NONE 0 14: #define CLUSTER_FE 1 15: #define CLUSTER_SP_VS 2 16: #define CLUSTER_PC_VS 3 17: #define CLUSTER_GRAS 4 18: #define CLUSTER_SP_PS 5 19: #define CLUSTER_VPC_PS 6 20: #define CLUSTER_PS 7 21: 22: #define HLSQ_STATE 0 23: #define HLSQ_DP 1 24: #define SP_TOP 2 25: #define USPTP 3 26: #define HLSQ_DP_STR 4 27: 28: #define STATE_NON_CONTEXT 0 29: #define STATE_TOGGLE_CTXT 1 30: #define STATE_FORCE_CTXT_0 2 31: #define STATE_FORCE_CTXT_1 3 MATCH LINES: 112 100: /* pipe_id: Pipe Identifier */ 101: int pipe_id; 102: /* context_id: one of STATE_ that identifies the context to dump */ 103: int context_id; 104: /* regs: Pointer to an array of register pairs */ 105: const u32 *regs; 106: /* sel: Pointer to a selector register to write before reading */ 107: const struct gen7_sel_reg *sel; 108: /* offset: Internal variable to track the state of the crashdump */ 109: unsigned int offset; 110: }; 111: 112: struct gen7_snapshot_block_list { 113: /* pre_crashdumper_regs : Registers which need to be dumped before CD runs */ 114: const u32 *pre_crashdumper_regs; 115: /* debugbus_blocks : List of debugbus blocks */ 116: const u32 *debugbus_blocks; 117: /* debugbus_blocks_len : Length of the debugbus list */ 118: size_t debugbus_blocks_len; 119: /* gbif_debugbus_blocks : List of GBIF debugbus blocks */ 120: const u32 *gbif_debugbus_blocks; 121: /* gbif_debugbus_blocks_len : Length of GBIF debugbus list */ 122: size_t gbif_debugbus_blocks_len; 123: /* cx_debugbus_blocks : List of CX debugbus blocks */ 124: const u32 *cx_debugbus_blocks; 125: /* cx_debugbus_blocks_len : Length of the CX debugbus list */ 126: size_t cx_debugbus_blocks_len; 127: /* external_core_regs : List of external core registers */ 128: const u32 **external_core_regs; 129: /* num_external_core_regs : length of external core registers list */ 130: size_t num_external_core_regs; 131: /* gmu_regs : List of GMU registers */ 132: const u32 *gmu_regs; 133: /* gmu_ao_regs : List of GMU registers for ao areas */ 134: const u32 *gmu_ao_regs; 135: /* gmu_gx_regs : List of GMU GX registers */ 136: const u32 *gmu_gx_regs; MATCH LINES: 384 372: static struct gen7_cp_indexed_reg gen7_cp_indexed_reg_list[] = { 373: { GEN7_CP_SQE_STAT_ADDR, GEN7_CP_SQE_STAT_DATA, 0x40}, 374: { GEN7_CP_DRAW_STATE_ADDR, GEN7_CP_DRAW_STATE_DATA, 0x100}, 375: { GEN7_CP_SQE_UCODE_DBG_ADDR, GEN7_CP_SQE_UCODE_DBG_DATA, 0x8000}, 376: { GEN7_CP_BV_SQE_STAT_ADDR, GEN7_CP_BV_SQE_STAT_DATA, 0x40}, 377: { GEN7_CP_BV_DRAW_STATE_ADDR, GEN7_CP_BV_DRAW_STATE_DATA, 0x100}, 378: { GEN7_CP_BV_SQE_UCODE_DBG_ADDR, GEN7_CP_BV_SQE_UCODE_DBG_DATA, 0x8000}, 379: { GEN7_CP_SQE_AC_STAT_ADDR, GEN7_CP_SQE_AC_STAT_DATA, 0x40}, 380: { GEN7_CP_LPAC_DRAW_STATE_ADDR, GEN7_CP_LPAC_DRAW_STATE_DATA, 0x100}, 381: { GEN7_CP_SQE_AC_UCODE_DBG_ADDR, GEN7_CP_SQE_AC_UCODE_DBG_DATA, 0x8000}, 382: { GEN7_CP_LPAC_FIFO_DBG_ADDR, GEN7_CP_LPAC_FIFO_DBG_DATA, 0x40}, 383: }; 384: #endif /*_ADRENO_GEN7_SNAPSHOT_H */ --- FILE: \adreno_gen8.c | HITS: 29 --- MATCH LINES: 1119 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 MATCH LINES: 1284, 1285 1272: 1273: int gen8_init(struct adreno_device *adreno_dev) 1274: { 1275: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1276: struct gen8_device *gen8_dev = container_of(adreno_dev, 1277: struct gen8_device, adreno_dev); 1278: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev); 1279: 1280: adreno_dev->ahb_timeout_val = adreno_get_ahb_timeout_val(adreno_dev, 1281: gen8_core->noc_timeout_us); 1282: adreno_dev->bcl_data = gen8_core->bcl_data; 1283: 1284: adreno_dev->cooperative_reset = ADRENO_FEATURE(adreno_dev, 1285: ADRENO_COOP_RESET); 1286: 1287: gen8_calc_ubwc_config(adreno_dev); 1288: 1289: gen8_crashdump_init(adreno_dev); 1290: 1291: gen8_dev->nc_overrides = gen8_nc_overrides; 1292: mutex_init(&gen8_dev->nc_mutex); 1293: 1294: /* Debugfs node for noncontext registers override */ 1295: if (!debugfs_lookup("nc_override", device->d_debugfs)) 1296: debugfs_create_file("nc_override", 0644, 1297: device->d_debugfs, device, &nc_override_fops); 1298: 1299: return adreno_allocate_global(device, &adreno_dev->pwrup_reglist, 1300: PAGE_SIZE, 0, 0, KGSL_MEMDESC_PRIVILEGED, 1301: "powerup_register_list"); 1302: } 1303: 1304: #define CX_TIMER_INIT_SAMPLES 16 1305: void gen8_cx_timer_init(struct adreno_device *adreno_dev) 1306: { 1307: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1308: u64 seed_val, tmr, skew = 0; 1309: int i; MATCH LINES: 1709 1697: u32 retry = 3; 1698: 1699: kgsl_regwrite(device, GEN8_RBBM_CGC_P2S_TRIG_CMD, 1); 1700: /* Poll for the TXDONE:BIT(0) status */ 1701: do { 1702: /* Wait for small amount of time for TXDONE status*/ 1703: udelay(1); 1704: kgsl_regread(device, GEN8_RBBM_CGC_P2S_STATUS, &value); 1705: } while (!(value & BIT(0)) && --retry); 1706: 1707: if (!(value & BIT(0))) { 1708: dev_err(device->dev, "RBBM_CGC_P2S_STATUS:TXDONE Poll failed\n"); 1709: kgsl_device_snapshot(device, NULL, NULL, false); 1710: return; 1711: } 1712: kgsl_regwrite(device, GEN8_RBBM_CLOCK_CNTL_GLOBAL, 0); 1713: } else { 1714: /* 1715: * The CGC mode in GEN8_GBIF_CX_CONFIG register is set to off by default. 1716: * During GMU bootup, it is set to on by driver regardless of the on/off 1717: * setting. So, here override the register only for CGC off config. 1718: */ 1719: kgsl_regrmw(device, GEN8_GBIF_CX_CONFIG, GENMASK(18, 16), 1720: FIELD_PREP(GENMASK(18, 16), 0)); 1721: } 1722: } 1723: 1724: void gen8_patch_pwrup_reglist(struct adreno_device *adreno_dev) 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); MATCH LINES: 2077 2065: /* 2066: * HBB values 13 to 16 can represented LSB of HBB from 0 to 3. 2067: * Any HBB value beyond 16 needs programming MSB of HBB. 2068: * By default highest bank bit is 14, Hence set default HBB LSB 2069: * to "1" and MSB to "0". 2070: */ 2071: u32 hbb_lo = 1, hbb_hi = 0, hbb = 1; 2072: struct cpu_gpu_lock *pwrup_lock = adreno_dev->pwrup_reglist->hostptr; 2073: u64 uche_trap_base = gen8_get_uche_trap_base(); 2074: int is_current_rt = rt_task(current); 2075: int nice = task_nice(current); 2076: 2077: /* Reset aperture fields to go through first aperture write check */ 2078: gen8_dev->aperture = UINT_MAX; 2079: 2080: /* 2081: * Elevating the thread’s priority to FIFO to ensure sequential register access 2082: * on the same CPU, avoiding context switches to a different CPU or thread. 2083: */ 2084: if (!is_current_rt) 2085: sched_set_fifo(current); 2086: 2087: device->regmap.use_relaxed = false; 2088: 2089: /* Make all blocks contribute to the GPU BUSY perf counter */ 2090: kgsl_regwrite(device, GEN8_RBBM_PERFCTR_GPU_BUSY_MASKED, 0xffffffff); 2091: 2092: kgsl_regwrite(device, GEN8_UCHE_CCHE_GC_GMEM_RANGE_MIN_LO, 2093: lower_32_bits(adreno_dev->uche_gmem_base)); 2094: kgsl_regwrite(device, GEN8_UCHE_CCHE_GC_GMEM_RANGE_MIN_HI, 2095: upper_32_bits(adreno_dev->uche_gmem_base)); 2096: kgsl_regwrite(device, GEN8_SP_HLSQ_GC_GMEM_RANGE_MIN_LO, 2097: lower_32_bits(adreno_dev->uche_gmem_base)); 2098: kgsl_regwrite(device, GEN8_SP_HLSQ_GC_GMEM_RANGE_MIN_HI, 2099: upper_32_bits(adreno_dev->uche_gmem_base)); 2100: 2101: if (adreno_dev->lpac_enabled) { MATCH LINES: 2203 2191: 2192: kgsl_regwrite(device, GEN8_UCHE_CLIENT_PF, BIT(7) | 2193: FIELD_PREP(GENMASK(6, 0), adreno_dev->uche_client_pf)); 2194: 2195: /* Program noncontext registers */ 2196: gen8_nonctxt_regconfig(adreno_dev); 2197: 2198: /* Read GPU registers with the GMU OOB set to update adreno props */ 2199: gen8_setup_adreno_props(adreno_dev); 2200: 2201: /* Enable hardware hang detection */ 2202: kgsl_regwrite(device, GEN8_RBBM_INTERFACE_HANG_INT_CNTL, BIT(30) | 2203: FIELD_PREP(GENMASK(27, 0), gen8_core->hang_detect_cycles)); 2204: kgsl_regwrite(device, GEN8_RBBM_SLICE_INTERFACE_HANG_INT_CNTL, BIT(30)); 2205: 2206: /* Enable the GMEM save/restore feature for preemption */ 2207: if (adreno_is_preemption_enabled(adreno_dev)) { 2208: gen8_regwrite_aperture(device, 2209: GEN8_RB_CONTEXT_SWITCH_GMEM_SAVE_RESTORE, 2210: 0x1, PIPE_BR, 0, 0); 2211: /* Clear aperture register */ 2212: gen8_host_aperture_set(adreno_dev, 0, 0, 0); 2213: } 2214: 2215: /* Enable GMU power counter 0 to count GPU busy */ 2216: kgsl_regwrite(device, GEN8_GMUAO_GPU_CX_BUSY_MASK, 0xff000000); 2217: kgsl_regrmw(device, GEN8_GMUCX_POWER_COUNTER_SELECT_XOCLK_0, 0xFF, 0x20); 2218: kgsl_regwrite(device, GEN8_GMUCX_POWER_COUNTER_ENABLE, 0x1); 2219: 2220: gen8_protect_init(adreno_dev); 2221: 2222: /* Configure LLCC */ 2223: _llc_configure_gpu_scid(adreno_dev); 2224: _llc_gpuhtw_slice_activate(adreno_dev); 2225: 2226: for (pipe_id = PIPE_BR; pipe_id <= PIPE_DDE_BV; pipe_id++) { 2227: u32 val = CP_SW_FAULT_STATUS_MASK_PIPE; MATCH LINES: 2351 2339: kgsl_regread(device, GEN8_CP_RB_RPTR_BR, &rptr); 2340: kgsl_regread(device, GEN8_CP_RB_WPTR_GC, &wptr); 2341: 2342: kgsl_regread(device, GEN8_RBBM_STATUS, &status); 2343: kgsl_regread(device, GEN8_RBBM_INT_0_STATUS, &intstatus); 2344: kgsl_regread(device, GEN8_CP_INTERRUPT_STATUS_GLOBAL, &global_status); 2345: 2346: dev_err(device->dev, 2347: "rb=%d pos=%X/%X rbbm_status=%8.8X int_0_status=%8.8X global_status=%8.8X\n", 2348: adreno_dev->cur_rb ? adreno_dev->cur_rb->id : -1, rptr, wptr, 2349: status, intstatus, global_status); 2350: 2351: kgsl_device_snapshot(device, NULL, NULL, false); 2352: } 2353: 2354: /* 2355: * gen8_send_cp_init() - Initialize ringbuffer 2356: * @adreno_dev: Pointer to adreno device 2357: * @rb: Pointer to the ringbuffer of device 2358: * 2359: * Submit commands for ME initialization, 2360: */ 2361: static int gen8_send_cp_init(struct adreno_device *adreno_dev, 2362: struct adreno_ringbuffer *rb) 2363: { 2364: u32 *cmds; 2365: int ret; 2366: 2367: cmds = adreno_ringbuffer_allocspace(rb, GEN8_CP_INIT_DWORDS); 2368: if (IS_ERR(cmds)) 2369: return PTR_ERR(cmds); 2370: 2371: gen8_cp_init_cmds(adreno_dev, cmds); 2372: 2373: ret = gen8_ringbuffer_submit(rb, NULL); 2374: if (ret) 2375: return ret; MATCH LINES: 2814, 2816 2802: 2803: #define SCOOBYDOO 0x5c00bd00 2804: 2805: static const char *gen8_fault_block_uche(struct kgsl_device *device, 2806: char *str, int size, bool lpac) 2807: { 2808: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 2809: u32 uche_client_id = adreno_dev->uche_client_pf; 2810: const char *uche_client_str, *fault_block; 2811: 2812: /* 2813: * Smmu driver takes a vote on CX gdsc before calling the kgsl 2814: * pagefault handler. If there is contention for device mutex in this 2815: * path and the dispatcher fault handler is holding this lock, trying 2816: * to turn off CX gdsc will fail during the reset. So to avoid blocking 2817: * here, try to lock device mutex and return if it fails. 2818: */ 2819: if (!kgsl_mutex_trylock(&device->mutex)) 2820: goto regread_fail; 2821: 2822: if (!kgsl_state_is_awake(device)) { 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: MATCH LINES: 2866 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: 2860: fail: 2861: snprintf(str, size, "%s: Unknown (client_id: %u)", 2862: fault_block, uche_client_id); 2863: return str; 2864: } 2865: 2866: static const char *gen8_iommu_fault_block(struct kgsl_device *device, 2867: u32 fsynr1) 2868: { 2869: u32 mid = fsynr1 & 0xff; 2870: static char str[36]; 2871: 2872: switch (mid) { 2873: case 0x0: 2874: return "CP"; 2875: case 0x1: 2876: return "UCHE: Unknown"; 2877: case 0x2: 2878: return "UCHE_LPAC: Unknown"; 2879: case 0x3: 2880: return gen8_fault_block_uche(device, str, sizeof(str), false); 2881: case 0x4: 2882: return "CCU"; 2883: case 0x5: 2884: return "Flag cache"; 2885: case 0x6: 2886: return "PREFETCH"; 2887: case 0x7: 2888: return "GMU"; 2889: case 0x8: 2890: return gen8_fault_block_uche(device, str, sizeof(str), true); MATCH LINES: 3084, 3085, 3118, 3119 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, MATCH LINES: 3189, 3190, 3191, 3213 3177: adreno_dev->preempt.preempt_level = gen8_core->preempt_level; 3178: adreno_dev->preempt.skipsaverestore = true; 3179: adreno_dev->preempt.usesgmem = true; 3180: set_bit(ADRENO_DEVICE_PREEMPTION, &adreno_dev->priv); 3181: } 3182: 3183: /* debugfs node for ACD calibration */ 3184: debugfs_create_file("acd_calibrate", 0644, device->d_debugfs, device, &acd_cal_fops); 3185: 3186: gen8_coresight_init(adreno_dev); 3187: 3188: /* Dump additional AQE 16KB data on top of default 128KB(64(BR)+64(BV)) */ 3189: device->snapshot_ctxt_record_size = ADRENO_FEATURE(adreno_dev, ADRENO_AQE) ? 3190: (GEN8_SNAPSHOT_CTXRECORD_SIZE_IN_BYTES + GEN8_CP_AQE_CTXRECORD_SIZE_IN_BYTES) : 3191: GEN8_SNAPSHOT_CTXRECORD_SIZE_IN_BYTES; 3192: 3193: return 0; 3194: } 3195: 3196: /* Register offset defines for Gen8, in order of enum adreno_regs */ 3197: static u32 gen8_register_offsets[ADRENO_REG_REGISTER_MAX] = { 3198: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_BASE, GEN8_CP_RB_BASE_LO_GC), 3199: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_BASE_HI, GEN8_CP_RB_BASE_HI_GC), 3200: ADRENO_REG_DEFINE(ADRENO_REG_CP_LPAC_RB_BASE, GEN8_CP_RB_BASE_LO_LPAC), 3201: ADRENO_REG_DEFINE(ADRENO_REG_CP_LPAC_RB_BASE_HI, GEN8_CP_RB_BASE_HI_LPAC), 3202: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_RPTR, GEN8_CP_RB_RPTR_BR), 3203: ADRENO_REG_DEFINE(ADRENO_REG_CP_RB_WPTR, GEN8_CP_RB_WPTR_GC), 3204: ADRENO_REG_DEFINE(ADRENO_REG_CP_ME_CNTL, GEN8_CP_SQE_CNTL), 3205: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BASE, GEN8_CP_IB1_BASE_LO_PIPE), 3206: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BASE_HI, GEN8_CP_IB1_BASE_HI_PIPE), 3207: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB1_BUFSZ, GEN8_CP_IB1_REM_SIZE_PIPE), 3208: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BASE, GEN8_CP_IB2_BASE_LO_PIPE), 3209: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BASE_HI, GEN8_CP_IB2_BASE_HI_PIPE), 3210: ADRENO_REG_DEFINE(ADRENO_REG_CP_IB2_BUFSZ, GEN8_CP_IB2_REM_SIZE_PIPE), 3211: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_STATUS, GEN8_RBBM_STATUS), 3212: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_INT_0_MASK, GEN8_RBBM_INT_0_MASK), 3213: ADRENO_REG_DEFINE(ADRENO_REG_RBBM_SW_RESET_CMD, GEN8_RBBM_SW_RESET_CMD), 3214: ADRENO_REG_DEFINE(ADRENO_REG_GMU_AO_HOST_INTERRUPT_MASK, 3215: GEN8_GMUAO_AO_HOST_INTERRUPT_MASK), 3216: ADRENO_REG_DEFINE(ADRENO_REG_GMU_GMU2HOST_INTR_MASK, 3217: GEN8_GMUCX_GMU2HOST_INTR_MASK), 3218: }; 3219: 3220: static u32 _get_pipeid(u32 groupid) 3221: { 3222: switch (groupid) { 3223: case KGSL_PERFCOUNTER_GROUP_BV_PC: 3224: fallthrough; 3225: case KGSL_PERFCOUNTER_GROUP_BV_VFD: 3226: fallthrough; 3227: case KGSL_PERFCOUNTER_GROUP_BV_VPC: 3228: fallthrough; 3229: case KGSL_PERFCOUNTER_GROUP_BV_TSE: 3230: fallthrough; 3231: case KGSL_PERFCOUNTER_GROUP_BV_RAS: 3232: fallthrough; 3233: case KGSL_PERFCOUNTER_GROUP_BV_LRZ: 3234: fallthrough; 3235: case KGSL_PERFCOUNTER_GROUP_BV_HLSQ: 3236: return PIPE_BV; 3237: case KGSL_PERFCOUNTER_GROUP_PC: MATCH LINES: 3706, 3734, 3762 3694: struct adreno_context *drawctxt; 3695: u32 status = 0, rptr = 0, wptr = 0, ib1sz = 0, ib2sz = 0, ib3sz = 0; 3696: u64 ib1base = 0, ib2base = 0, ib3base = 0; 3697: bool gx_on = adreno_gx_is_on(adreno_dev); 3698: 3699: drawctxt = ADRENO_CONTEXT(drawobj->context); 3700: drawobj->context->last_faulted_cmd_ts = drawobj->timestamp; 3701: drawobj->context->total_fault_count++; 3702: 3703: pr_context(device, drawobj->context, 3704: "LPAC ctx %u ctx_type %s ts %u policy %lX dispatch_queue=%d\n", 3705: drawobj->context->id, kgsl_context_type(drawctxt->type), 3706: drawobj->timestamp, CMDOBJ(drawobj)->fault_recovery, 3707: drawobj->context->gmu_dispatch_queue); 3708: 3709: pr_context(device, drawobj->context, "lpac cmdline: %s\n", 3710: drawctxt->base.proc_priv->cmdline); 3711: 3712: if (!gen8_gmu_rpmh_pwr_state_is_active(device) || !gx_on) 3713: goto done; 3714: 3715: kgsl_regread(device, GEN8_RBBM_LPAC_STATUS, &status); 3716: kgsl_regread(device, GEN8_CP_RB_RPTR_LPAC, &rptr); 3717: kgsl_regread(device, GEN8_CP_RB_WPTR_LPAC, &wptr); 3718: gen8_periph_regread64(device, GEN8_CP_PERIPH_IB1_BASE_LO, 3719: GEN8_CP_PERIPH_IB1_BASE_HI, &ib1base, PIPE_LPAC); 3720: gen8_periph_regread(device, GEN8_CP_PERIPH_IB1_OFFSET, &ib1sz, PIPE_LPAC); 3721: gen8_periph_regread64(device, GEN8_CP_PERIPH_IB2_BASE_LO, 3722: GEN8_CP_PERIPH_IB2_BASE_HI, &ib2base, PIPE_LPAC); 3723: gen8_periph_regread(device, GEN8_CP_PERIPH_IB2_OFFSET, &ib2sz, PIPE_LPAC); 3724: gen8_periph_regread64(device, GEN8_CP_PERIPH_IB3_BASE_LO, 3725: GEN8_CP_PERIPH_IB3_BASE_HI, &ib3base, PIPE_LPAC); 3726: gen8_periph_regread(device, GEN8_CP_PERIPH_IB3_OFFSET, &ib3sz, PIPE_LPAC); 3727: gen8_host_aperture_set(adreno_dev, 0, 0, 0); 3728: 3729: pr_context(device, drawobj->context, 3730: "LPAC: status %8.8X rb %4.4x/%4.4x ib1 %16.16llX/%4.4x ib2 %16.16llX/%4.4x ib3 %16.16llX/%4.4x\n", 3731: status, rptr, wptr, ib1base, ib1sz, ib2base, ib2sz, ib3base, ib3sz); 3732: 3733: done: 3734: trace_adreno_gpu_fault(drawobj->context->id, drawobj->timestamp, status, 3735: rptr, wptr, ib1base, ib1sz, ib2base, ib2sz, 3736: adreno_get_level(drawobj->context)); 3737: 3738: } 3739: 3740: static void gen8_fault_header(struct adreno_device *adreno_dev, 3741: struct kgsl_drawobj *drawobj) 3742: { 3743: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 3744: struct adreno_context *drawctxt; 3745: u32 status = 0, rptr = 0, wptr = 0, ib1sz = 0, ib2sz = 0, ib3sz, rptr_bv = 0; 3746: u32 ib1sz_bv = 0, ib2sz_bv = 0, ib3sz_bv, gfx_status, gfx_br_status, gfx_bv_status; 3747: u64 ib1base = 0, ib2base = 0, ib3base, ib1base_bv = 0, ib2base_bv, ib3base_bv; 3748: u32 ctxt_id = 0, ts = 0; 3749: int rb_id = -1; 3750: bool gx_on = adreno_gx_is_on(adreno_dev); 3751: 3752: if (drawobj) { 3753: drawctxt = ADRENO_CONTEXT(drawobj->context); 3754: drawobj->context->last_faulted_cmd_ts = drawobj->timestamp; 3755: drawobj->context->total_fault_count++; 3756: ctxt_id = drawobj->context->id; 3757: ts = drawobj->timestamp; 3758: rb_id = adreno_get_level(drawobj->context); 3759: 3760: pr_context(device, drawobj->context, "ctx %u ctx_type %s ts %u policy %lX\n", 3761: drawobj->context->id, kgsl_context_type(drawctxt->type), 3762: drawobj->timestamp, CMDOBJ(drawobj)->fault_recovery); 3763: 3764: pr_context(device, drawobj->context, "cmdline: %s\n", 3765: drawctxt->base.proc_priv->cmdline); 3766: } 3767: 3768: if (!gen8_gmu_rpmh_pwr_state_is_active(device) || !gx_on) 3769: goto done; 3770: 3771: kgsl_regread(device, GEN8_RBBM_STATUS, &status); 3772: kgsl_regread(device, GEN8_RBBM_GFX_STATUS, &gfx_status); 3773: kgsl_regread(device, GEN8_RBBM_GFX_BV_STATUS, &gfx_bv_status); 3774: kgsl_regread(device, GEN8_RBBM_GFX_BR_STATUS, &gfx_br_status); 3775: kgsl_regread(device, GEN8_CP_RB_RPTR_BR, &rptr); 3776: kgsl_regread(device, GEN8_CP_RB_WPTR_GC, &wptr); 3777: kgsl_regread(device, GEN8_CP_RB_RPTR_BV, &rptr_bv); 3778: gen8_periph_regread64(device, GEN8_CP_PERIPH_IB1_BASE_LO, 3779: GEN8_CP_PERIPH_IB1_BASE_HI, &ib1base, PIPE_BR); 3780: gen8_periph_regread(device, GEN8_CP_PERIPH_IB1_OFFSET, &ib1sz, PIPE_BR); 3781: gen8_periph_regread64(device, GEN8_CP_PERIPH_IB2_BASE_LO, 3782: GEN8_CP_PERIPH_IB2_BASE_HI, &ib2base, PIPE_BR); 3783: gen8_periph_regread(device, GEN8_CP_PERIPH_IB2_OFFSET, &ib2sz, PIPE_BR); 3784: gen8_periph_regread64(device, GEN8_CP_PERIPH_IB3_BASE_LO, 3785: GEN8_CP_PERIPH_IB3_BASE_HI, &ib3base, PIPE_BR); 3786: gen8_periph_regread(device, GEN8_CP_PERIPH_IB3_OFFSET, &ib3sz, PIPE_BR); MATCH LINES: 3811 3799: "status %8.8X gfx_status %8.8X gfx_br_status %8.8X gfx_bv_status %8.8X\n", 3800: status, gfx_status, gfx_br_status, gfx_bv_status); 3801: 3802: dev_err(device->dev, 3803: "BR: rb %4.4x/%4.4x ib1 %16.16llX/%4.4x ib2 %16.16llX/%4.4x ib3 %16.16llX/%4.4x\n", 3804: rptr, wptr, ib1base, ib1sz, ib2base, ib2sz, ib3base, ib3sz); 3805: 3806: dev_err(device->dev, 3807: "BV: rb %4.4x/%4.4x ib1 %16.16llX/%4.4x ib2 %16.16llX/%4.4x ib3 %16.16llX/%4.4x\n", 3808: rptr_bv, wptr, ib1base_bv, ib1sz_bv, ib2base_bv, ib2sz_bv, ib3base_bv, ib3sz_bv); 3809: 3810: done: 3811: trace_adreno_gpu_fault(ctxt_id, ts, status, 3812: rptr, wptr, ib1base, ib1sz, ib2base, ib2sz, rb_id); 3813: } 3814: 3815: /** 3816: * gen8_get_gmem_size - Returns the GMEM size 3817: * @adreno_dev: Handle to the adreno device 3818: * 3819: * Return: GMEM size in bytes 3820: */ 3821: u32 gen8_get_gmem_size(struct adreno_device *adreno_dev) 3822: { 3823: if (adreno_is_gen8_1_0(adreno_dev)) 3824: return (adreno_dev->gpucore->gmem_size / GEN8_1_0_NUM_PHYSICAL_SLICES) * 3825: gen8_get_num_slices(adreno_dev); 3826: 3827: if (adreno_is_gen8_2_x(adreno_dev) || adreno_is_gen8_11_x(adreno_dev)) { 3828: if (adreno_is_gen8_9_0(adreno_dev)) 3829: return (adreno_dev->gpucore->gmem_size / GEN8_9_0_NUM_PHYSICAL_SLICES) * 3830: gen8_get_num_slices(adreno_dev); 3831: else if (adreno_is_gen8_11_x(adreno_dev)) 3832: return (adreno_dev->gpucore->gmem_size / GEN8_11_0_NUM_PHYSICAL_SLICES) * 3833: gen8_get_num_slices(adreno_dev); 3834: else 3835: return (adreno_dev->gpucore->gmem_size / GEN8_2_0_NUM_PHYSICAL_SLICES) * MATCH LINES: 3850, 3852, 3855, 3856, 3885, 3890, 3891 3838: 3839: if (adreno_is_gen8_10_0(adreno_dev)) 3840: return (adreno_dev->gpucore->gmem_size / GEN8_10_0_NUM_PHYSICAL_SLICES) * 3841: gen8_get_num_slices(adreno_dev); 3842: 3843: return adreno_dev->gpucore->gmem_size; 3844: } 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: 20 --- MATCH LINES: 28 16: #define GEN8_0_0_NUM_PHYSICAL_SLICES 3 17: #define GEN8_1_0_NUM_PHYSICAL_SLICES 4 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 */ MATCH LINES: 186, 187, 194, 195 174: * @zap_name: Specifies the name of the CPZ zap file. This field is deprecated. 175: * Use the 'firmware-name' device tree property instead. 176: */ 177: const char *zap_name; 178: /** @ao_hwcg: List of registers and values to write for HWCG in AO block */ 179: const struct kgsl_regmap_list *ao_hwcg; 180: /** @ao_hwcg_count: Number of registers in @ao_hwcg */ 181: u32 ao_hwcg_count; 182: /** @gbif: List of registers and values to write for GBIF */ 183: const struct kgsl_regmap_list *gbif; 184: /** @gbif_count: Number of registers in @gbif */ 185: u32 gbif_count; 186: /** @hang_detect_cycles: Hang detect counter timeout value */ 187: u32 hang_detect_cycles; 188: /** @protected_regs: Array of protected registers for the target */ 189: const struct gen8_protected_regs *protected_regs; 190: /** @nonctxt_regs: Array of non context register list */ 191: const struct gen8_nonctxt_regs *nonctxt_regs; 192: /** @ctxt_record_size: Size of the preemption record in bytes */ 193: u64 ctxt_record_size; 194: /** @gen8_snapshot_block_list: Device-specific blocks dumped in the snapshot */ 195: const struct gen8_snapshot_block_list *gen8_snapshot_block_list; 196: /** @gmu_hub_clk_freq: Gmu hub interface clock frequency */ 197: u64 gmu_hub_clk_freq; 198: /** 199: * @bcl_data: bit 0 contains response type for bcl alarms and bits 1:21 controls sid vals 200: * to configure throttle levels for bcl alarm levels 0-2. If sid vals are not set, 201: * gmu fw sets default throttle levels. 202: */ 203: u32 bcl_data; 204: /** @preempt_level: Preemption level valid ranges [0 to 2] */ 205: u32 preempt_level; 206: /** @qos_value: GPU qos value to set for each RB. */ 207: const u32 *qos_value; 208: /** 209: * @acv_perfmode_ddr_freq: Vote perfmode when DDR frequency >= acv_perfmode_ddr_freq. 210: * If not specified, vote perfmode for highest DDR level only. 211: */ 212: u32 acv_perfmode_ddr_freq; 213: /** @rt_bus_hint: IB level hint for real time clients i.e. RB-0 */ 214: const u32 rt_bus_hint; 215: /** @fast_bus_hint: Whether or not to increase IB vote on high ddr stall */ 216: bool fast_bus_hint; 217: /** @noc_timeout_us: GPU config NOC port timeout in usec */ 218: u32 noc_timeout_us; 219: /** @cl_no_ft_timeout_ms: Use this timeout for CL NO_FT instead of infinite */ MATCH LINES: 294, 295 282: u32 _pad4; 283: u64 ttbr0; 284: u32 asid; 285: u32 context_idr; 286: u32 context_bank; 287: }; 288: 289: #define GEN8_CP_SMMU_INFO_MAGIC_REF 0x241350d5UL 290: 291: #define GEN8_CP_CTXRECORD_MAGIC_REF 0xae399d6eUL 292: /* Size of each CP preemption record */ 293: #define GEN8_CP_CTXRECORD_SIZE_IN_BYTES (13536 * SZ_1K) 294: /* Size of preemption record to be dumped in snapshot */ 295: #define GEN8_SNAPSHOT_CTXRECORD_SIZE_IN_BYTES (128 * 1024) 296: /* Size of AQE context record */ 297: #define GEN8_CP_AQE_CTXRECORD_SIZE_IN_BYTES (16 * 1024) 298: /* Size of the performance counter save/restore block (in bytes) */ 299: #define GEN8_CP_PERFCOUNTER_SAVE_RESTORE_SIZE (4 * 1024) 300: 301: #define GEN8_CP_RB_CNTL_DEFAULT \ 302: (FIELD_PREP(GENMASK(7, 0), ilog2(KGSL_RB_DWORDS >> 1)) | \ 303: FIELD_PREP(GENMASK(12, 8), ilog2(4))) 304: 305: /* Size of the CP_INIT pm4 stream in dwords */ 306: #define GEN8_CP_INIT_DWORDS 10 307: 308: #define GEN8_INT_MASK \ 309: ((1 << GEN8_INT_AHBERROR) | \ 310: (1 << GEN8_INT_ATBASYNCFIFOOVERFLOW) | \ 311: (1 << GEN8_INT_GPCERROR) | \ 312: (1 << GEN8_INT_SWINTERRUPT) | \ 313: (1 << GEN8_INT_HWERROR) | \ 314: (1 << GEN8_INT_PM4CPINTERRUPT) | \ 315: (1 << GEN8_INT_RB_DONE_TS) | \ 316: (1 << GEN8_INT_CACHE_CLEAN_TS) | \ 317: (1 << GEN8_INT_ATBBUSOVERFLOW) | \ 318: (1 << GEN8_INT_HANGDETECTINTERRUPT) | \ 319: (1 << GEN8_INT_OUTOFBOUNDACCESS) | \ MATCH LINES: 370, 371, 375, 377, 379, 381, 382 358: u32 gen8_preemption_post_ibsubmit(struct adreno_device *adreno_dev, 359: u32 *cmds); 360: u32 gen8_preemption_pre_ibsubmit(struct adreno_device *adreno_dev, 361: struct adreno_ringbuffer *rb, struct adreno_context *drawctxt, 362: u32 *cmds); 363: 364: void gen8_preemption_callback(struct adreno_device *adreno_dev, int bit); 365: 366: void gen8_preemption_context_destroy(struct kgsl_context *context); 367: 368: void gen8_preemption_prepare_postamble(struct adreno_device *adreno_dev); 369: 370: void gen8_snapshot(struct adreno_device *adreno_dev, 371: struct kgsl_snapshot *snapshot); 372: void gen8_crashdump_init(struct adreno_device *adreno_dev); 373: 374: /** 375: * gen8_snapshot_external_core_regs - Dump external registers into snapshot 376: * @device: Pointer to KGSL device 377: * @snapshot: Pointer to the snapshot 378: * 379: * Dump external core registers like GPUCC, CPR into GPU snapshot. 380: */ 381: void gen8_snapshot_external_core_regs(struct kgsl_device *device, 382: struct kgsl_snapshot *snapshot); 383: 384: /** 385: * gen8_enable_ahb_timeout_detection - Program AHB control registers 386: * @adreno_dev: An Adreno GPU handle 387: * 388: * Program AHB control registers to enable AHB timeout detection. 389: * 390: */ 391: void gen8_enable_ahb_timeout_detection(struct adreno_device *adreno_dev); 392: 393: /** 394: * gen8_start - Program gen8 registers 395: * @adreno_dev: An Adreno GPU handle 396: * 397: * This function does all gen8 register programming every 398: * time we boot the gpu 399: * 400: * Return: 0 on success or negative on failure 401: */ 402: int gen8_start(struct adreno_device *adreno_dev); 403: 404: /** 405: * gen8_init - Initialize gen8 resources 406: * @adreno_dev: An Adreno GPU handle MATCH LINES: 480 468: * 469: * This function sets up the gen8 resources common across all 470: * gen8 targets 471: */ 472: int gen8_probe_common(struct platform_device *pdev, 473: struct adreno_device *adreno_dev, u32 chipid, 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 MATCH LINES: 583, 586, 588, 612, 620 571: * 572: * Return: 0 on success or negative on failure 573: */ 574: int gen8_gmu_hfi_probe(struct adreno_device *adreno_dev); 575: 576: static inline const struct gen8_gpudev * 577: to_gen8_gpudev(const struct adreno_gpudev *gpudev) 578: { 579: return container_of(gpudev, struct gen8_gpudev, base); 580: } 581: 582: /** 583: * gen8_reset_preempt_records - Reset the preemption buffers 584: * @adreno_dev: Handle to the adreno device 585: * 586: * Reset the preemption records at the time of hard reset 587: */ 588: void gen8_reset_preempt_records(struct adreno_device *adreno_dev); 589: 590: /** 591: * gen8_scm_gpu_init_cx_regs - Program gpu regs for feature support 592: * @adreno_dev: Handle to the adreno device 593: * 594: * Program gpu regs for feature support. Scm call for the same 595: * is added from kernel version 6.0 onwards. 596: * 597: * Return: 0 on success or negative on failure 598: */ 599: int gen8_scm_gpu_init_cx_regs(struct adreno_device *adreno_dev); 600: 601: /** 602: * gen8_scm_gpu_tsense_default - Program gpu tsense measurement interval 603: * @adreno_dev: Handle to the adreno device 604: * @default_req: Bool on if should update tsense with default or slow interval 605: * 606: * Program gpu tsense reg for measurement granularity. Scm call for the same 607: * is added from kernel version 6.0 onwards. 608: */ 609: void gen8_scm_gpu_tsense_default(struct adreno_device *adreno_dev, bool default_req); 610: 611: /** 612: * gen8_legacy_snapshot_registers - Dump registers for GPU/GMU 613: * @device: Handle to the KGSL device 614: * @buf: Target buffer to copy the data 615: * @remain: Buffer size remaining for dump 616: * @priv: Private data to dump the registers 617: * 618: * Return: Size of the section 619: */ 620: size_t gen8_legacy_snapshot_registers(struct kgsl_device *device, 621: u8 *buf, size_t remain, void *priv); 622: 623: /** 624: * gen8_regread64_aperture - Read 64 bit register values 625: * @device: Handle to the KGSL device 626: * @offsetwords_lo: Lower 32 bit address to read 627: * @offsetwords_hi: Higher 32 bit address to read 628: * @value: The value of register at offsetwords 629: * @pipe: Pipe for which the register is to be read 630: * @slice_id: Slice for which the register is to be read 631: * @use_slice_id: Set if the value to be read is from a sliced register 632: * 633: * This function reads the 64 bit value for registers 634: */ 635: void gen8_regread64_aperture(struct kgsl_device *device, 636: u32 offsetwords_lo, u32 offsetwords_hi, u64 *value, u32 pipe, 637: u32 slice_id, u32 use_slice_id); 638: 639: /** 640: * gen8_regread_aperture - Read 32 bit register values 641: * @device: Handle to the KGSL device 642: * @offsetwords: 32 bit address to read 643: * @value: The value of register at offsetwords 644: * @pipe: Pipe for which the register is to be read --- FILE: \adreno_gen8_0_0_snapshot.h | HITS: 4 --- MATCH LINES: 7, 8, 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: #ifndef __ADRENO_GEN8_0_0_SNAPSHOT_H 8: #define __ADRENO_GEN8_0_0_SNAPSHOT_H 9: 10: #include "adreno_gen8_snapshot.h" 11: 12: static struct gen8_shader_block gen8_0_0_shader_blocks[] = { 13: { TP0_TMO_DATA, 0x0200, 2, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 14: { TP0_SMO_DATA, 0x0080, 2, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 15: { TP0_MIPMAP_BASE_DATA, 0x0080, 2, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 16: { SP_INST_DATA_3, 0x0800, 2, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 17: { SP_INST_DATA, 0x0800, 2, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 18: { SP_INST_DATA_1, 0x0800, 2, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 19: { SP_LB_0_DATA, 0x0800, 2, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 20: { SP_LB_1_DATA, 0x0800, 2, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 21: { SP_LB_2_DATA, 0x0800, 2, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 22: { SP_LB_3_DATA, 0x0800, 2, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 23: { SP_LB_4_DATA, 0x0800, 2, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 24: { SP_LB_5_DATA, 0x0800, 2, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 25: { SP_LB_6_DATA, 0x0800, 2, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 26: { SP_LB_7_DATA, 0x0800, 2, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 27: { SP_CB_RAM, 0x0390, 2, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 28: { SP_LB_13_DATA, 0x0800, 2, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 29: { SP_LB_14_DATA, 0x0800, 2, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 30: { SP_INST_TAG, 0x0100, 2, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 31: { SP_INST_DATA_2, 0x0800, 2, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 32: { SP_TMO_TAG, 0x0080, 2, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 33: { SP_SMO_TAG, 0x0080, 2, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, 34: { SP_STATE_DATA, 0x0040, 2, uSPTP0, PIPE_BR, USPTP, SLICE, 1}, MATCH LINES: 2089 2077: }; 2078: 2079: static struct gen8_reg_list gen8_gmu_gx_registers[] = { 2080: { UNSLICE, gen8_0_0_gmugx_registers }, 2081: { UNSLICE, gen8_0_0_gx_clkctl_ahb2phy_broadcast_swman_registers }, 2082: { UNSLICE, gen8_0_0_gx_clkctl_ahb2phy_swman_registers }, 2083: { UNSLICE, gen8_0_0_gx_clkctl_pll0_cm_pll_taycan_common_registers }, 2084: { UNSLICE, gen8_0_0_gx_clkctl_gx_clkctl_reg_registers }, 2085: { UNSLICE, gen8_0_0_acd_acd_mnd_registers }, 2086: { SLICE, gen8_0_0_gmugx_slice_registers }, 2087: }; 2088: 2089: #endif /*_ADRENO_GEN8_0_0_SNAPSHOT_H */ --- FILE: \adreno_gen8_10_0_snapshot.h | HITS: 4 --- MATCH LINES: 6, 7, 9 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 4: */ 5: 6: #ifndef __ADRENO_GEN8_10_0_SNAPSHOT_H 7: #define __ADRENO_GEN8_10_0_SNAPSHOT_H 8: 9: #include "adreno_gen8_snapshot.h" 10: 11: /* 12: * Debugbus blocks for gen8_10_0. 13: * Same as gen8_1_0_debugbus_blocks but with Slice 3 (S_3) entries removed. 14: * gen8_10_0 has 3 GPU slices (S_0 through S_2) vs gen8_1_0's 4 slices. 15: */ 16: static const u32 gen8_10_0_debugbus_blocks[] = { 17: /* GBIF_GX block */ 18: DEBUGBUS_GBIF_GX_GC_US_I_0, 19: DEBUGBUS_GMU_GX_GC_US_I_0, 20: DEBUGBUS_DBGC_GC_US_I_0, 21: DEBUGBUS_RBBM_GC_US_I_0, 22: DEBUGBUS_LARC_GC_US_I_0, 23: DEBUGBUS_COM_GC_US_I_0, 24: DEBUGBUS_HLSQ_GC_US_I_0, 25: DEBUGBUS_CGC_GC_US_I_0, 26: DEBUGBUS_VSC_GC_US_I_0_0, 27: DEBUGBUS_VSC_GC_US_I_0_1, 28: DEBUGBUS_UFC_GC_US_I_0, 29: DEBUGBUS_UFC_GC_US_I_1, 30: DEBUGBUS_CP_GC_US_I_0_0, 31: DEBUGBUS_CP_GC_US_I_0_1, 32: DEBUGBUS_CP_GC_US_I_0_2, 33: DEBUGBUS_PC_BR_US_I_0, MATCH LINES: 178 166: DEBUGBUS_TP_GC_S_2_I_2, 167: DEBUGBUS_TP_GC_S_2_I_3, 168: DEBUGBUS_RB_GC_S_2_I_0, 169: DEBUGBUS_RB_GC_S_2_I_1, 170: DEBUGBUS_CCU_GC_S_2_I_0, 171: DEBUGBUS_CCU_GC_S_2_I_1, 172: DEBUGBUS_HLSQ_GC_S_2_I_0, 173: DEBUGBUS_HLSQ_GC_S_2_I_1, 174: DEBUGBUS_VFD_GC_S_2_I_0, 175: DEBUGBUS_VFD_GC_S_2_I_1, 176: }; 177: 178: #endif /* __ADRENO_GEN8_10_0_SNAPSHOT_H */ --- FILE: \adreno_gen8_11_0_snapshot.h | HITS: 4 --- MATCH LINES: 5, 6, 8 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 4: */ 5: #ifndef __ADRENO_GEN8_11_0_SNAPSHOT_H 6: #define __ADRENO_GEN8_11_0_SNAPSHOT_H 7: 8: #include "adreno_gen8_snapshot.h" 9: 10: static const u32 gen8_11_0_debugbus_blocks[] = { 11: DEBUGBUS_GMU_GX_GC_US_I_0, 12: DEBUGBUS_DBGC_GC_US_I_0, 13: DEBUGBUS_RBBM_GC_US_I_0, 14: DEBUGBUS_LARC_GC_US_I_0, 15: DEBUGBUS_COM_GC_US_I_0, 16: DEBUGBUS_HLSQ_GC_US_I_0, 17: DEBUGBUS_CGC_GC_US_I_0, 18: DEBUGBUS_VSC_GC_US_I_0_0, 19: DEBUGBUS_VSC_GC_US_I_0_1, 20: DEBUGBUS_UFC_GC_US_I_0, 21: DEBUGBUS_UFC_GC_US_I_1, 22: DEBUGBUS_CP_GC_US_I_0_0, 23: DEBUGBUS_CP_GC_US_I_0_1, 24: DEBUGBUS_CP_GC_US_I_0_2, 25: DEBUGBUS_PC_BR_US_I_0, 26: DEBUGBUS_PC_BV_US_I_0, 27: DEBUGBUS_GPC_BR_US_I_0, 28: DEBUGBUS_GPC_BV_US_I_0, 29: DEBUGBUS_VPC_BR_US_I_0, 30: DEBUGBUS_VPC_BV_US_I_0, 31: DEBUGBUS_UCHE_WRAPPER_GC_US_I_0, 32: DEBUGBUS_UCHE_GC_US_I_0, MATCH LINES: 2765 2753: gen8_11_0_gpu_cc_gpu_cc_reg_registers, 2754: gen8_11_0_gpu_cc_pll0_cm_pll_taycan_common_registers, 2755: gen8_11_0_acd_acd_mnd_registers, 2756: gen8_11_0_cpr_registers, 2757: gen8_11_0_gx_clkctl_ahb2phy_broadcast_swman_registers, 2758: gen8_11_0_gx_clkctl_ahb2phy_swman_registers, 2759: gen8_11_0_gx_clkctl_gx_clkctl_reg_registers, 2760: gen8_11_0_gx_clkctl_pll0_cm_pll_taycan_common_registers, 2761: gen8_11_0_cpr_gmxc_registers, 2762: gen8_11_0_rscc_rsc_registers, 2763: }; 2764: 2765: #endif /* __ADRENO_GEN8_11_0_SNAPSHOT_H */ --- FILE: \adreno_gen8_1_0_snapshot.h | HITS: 6 --- MATCH LINES: 6, 7, 9 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 4: */ 5: 6: #ifndef __ADRENO_GEN8_1_0_SNAPSHOT_H 7: #define __ADRENO_GEN8_1_0_SNAPSHOT_H 8: 9: #include "adreno_gen8_snapshot.h" 10: 11: /* 12: * gen8_1_0 specific GBIF debugbus blocks. 13: * The data file puts DEBUGBUS_GBIF_GX_GC_US_I_0 in the main debugbus_blocks list, 14: * so we use an empty list here and include it in gen8_1_0_debugbus_blocks instead. 15: * CX blocks (GBIF_CX, GMU_CX, CX) are handled by gen8_cx_debugbus_blocks. 16: */ 17: static const u32 gen8_1_0_gbif_debugbus_blocks[] = { 18: /* Empty - GBIF_GX is included in gen8_1_0_debugbus_blocks per data file */ 19: }; 20: 21: static const u32 gen8_1_0_debugbus_blocks[] = { 22: /* GBIF_GX block - included here per android_DXX_gen8_1_0_data.h */ 23: DEBUGBUS_GBIF_GX_GC_US_I_0, 24: /* Note: CX blocks (GBIF_CX, GMU_CX, CX) are handled by gen8_cx_debugbus_blocks */ 25: DEBUGBUS_GMU_GX_GC_US_I_0, 26: DEBUGBUS_DBGC_GC_US_I_0, 27: DEBUGBUS_RBBM_GC_US_I_0, 28: DEBUGBUS_LARC_GC_US_I_0, 29: DEBUGBUS_COM_GC_US_I_0, 30: DEBUGBUS_HLSQ_GC_US_I_0, 31: DEBUGBUS_CGC_GC_US_I_0, 32: DEBUGBUS_VSC_GC_US_I_0_0, 33: DEBUGBUS_VSC_GC_US_I_0_1, MATCH LINES: 1850 1838: PIPE_DDE_BV, 0x0a000}, 1839: { GEN8_CP_RESOURCE_TABLE_DBG_ADDR_BV, GEN8_CP_RESOURCE_TABLE_DBG_DATA_BV, UNSLICE, 1840: PIPE_NONE, 0x04100}, 1841: { GEN8_CP_FIFO_DBG_ADDR_LPAC, GEN8_CP_FIFO_DBG_DATA_LPAC, UNSLICE, PIPE_NONE, 0x00040}, 1842: { GEN8_CP_FIFO_DBG_ADDR_DDE_PIPE, GEN8_CP_FIFO_DBG_DATA_DDE_PIPE, UNSLICE, 1843: PIPE_DDE_BR, 0x01101}, 1844: { GEN8_CP_FIFO_DBG_ADDR_DDE_PIPE, GEN8_CP_FIFO_DBG_DATA_DDE_PIPE, UNSLICE, 1845: PIPE_DDE_BV, 0x01101}, 1846: }; 1847: 1848: /* 1849: * Misc registers list (GPU internal registers). 1850: * NULL-terminated - required by gen8_reglist_snapshot(). 1851: * cx_misc is included here AND referenced separately via cx_misc_regs field. 1852: */ 1853: static struct gen8_reg_list gen8_1_0_misc_registers[] = { 1854: { UNSLICE, gen8_1_0_gpu_registers }, 1855: { SLICE, gen8_1_0_gpu_slice_registers }, 1856: { UNSLICE, gen8_1_0_cx_misc_registers }, 1857: /* Right now for gen8_1_0 we dont have the QDDS debug support, so skip below regs*/ 1858: /* 1859: * { UNSLICE, gen8_1_0_dbgc_registers }, 1860: * { SLICE, gen8_1_0_dbgc_slice_registers }, 1861: * { UNSLICE, gen8_1_0_cx_dbgc_registers }, 1862: */ 1863: { UNSLICE, NULL }, 1864: }; 1865: 1866: /* 1867: * AHB registers (pre-crashdumper registers). 1868: * These are dumped before the crashdumper runs. 1869: * gen8_1_0 only has GBIF registers (no ahb_precd or ahb_secure separate arrays 1870: * since those are included in gen8_1_0_gpu_registers). 1871: */ 1872: static struct gen8_reg_list gen8_1_0_ahb_registers[] = { 1873: { UNSLICE, gen8_1_0_gbif_registers }, 1874: }; MATCH LINES: 2036, 2066 2024: * pairs : 1 (Regs:14) 2025: * Note: This is the GCC PLL register block (external to GPU CC) 2026: */ 2027: static const u32 gen8_1_0_gcc_gpll0_cm_pll_taycan_common_registers[] = { 2028: 0x00000, 0x0000d, 2029: UINT_MAX, UINT_MAX, 2030: }; 2031: static_assert(IS_ALIGNED(sizeof(gen8_1_0_gcc_gpll0_cm_pll_taycan_common_registers), 8)); 2032: 2033: /* 2034: * External core registers. 2035: * These are registers outside the GPU core (clock controllers, CPR, etc.) 2036: * Organized to match the kernel's gen8_snapshot_block_list structure: 2037: * - gx_clkctl registers go into gmu_gx_regs (not here) 2038: * - rscc registers go into rscc_regs field (not here) 2039: * - gmucx registers go into gmu_cx_unsliced_regs field (not here) 2040: */ 2041: static const u32 *gen8_1_0_external_core_regs[] = { 2042: gen8_1_0_gdpm_lkg_registers, 2043: gen8_1_0_gpu_cc_ahb2phy_swman_registers, 2044: gen8_1_0_cpr_registers, 2045: gen8_1_0_cpr_gmxc_registers, 2046: gen8_1_0_gpu_cc_ahb2phy_broadcast_swman_registers, 2047: gen8_1_0_gpu_cc_pll0_cm_pll_taycan_common_registers, 2048: gen8_1_0_gpu_cc_gpu_cc_reg_registers, 2049: gen8_1_0_gcc_gpll0_cm_pll_taycan_common_registers, 2050: }; 2051: 2052: /* 2053: * GMU GX registers. 2054: * Includes GX domain GMU registers and GX clock controller registers. 2055: * The gmucx (CX domain) registers are handled separately via gmu_cx_unsliced_regs. 2056: */ 2057: static struct gen8_reg_list gen8_1_0_gmu_gx_registers[] = { 2058: { UNSLICE, gen8_1_0_gmugx_registers }, 2059: { SLICE, gen8_1_0_gmugx_slice_registers }, 2060: { UNSLICE, gen8_1_0_gmuao_registers }, 2061: { UNSLICE, gen8_1_0_gx_clkctl_gx_clkctl_reg_registers }, 2062: { UNSLICE, gen8_1_0_gx_clkctl_ahb2phy_broadcast_swman_registers }, 2063: { UNSLICE, gen8_1_0_gx_clkctl_ahb2phy_swman_registers }, 2064: }; 2065: 2066: #endif /* __ADRENO_GEN8_1_0_SNAPSHOT_H */ --- FILE: \adreno_gen8_2_0_snapshot.h | HITS: 4 --- MATCH LINES: 6, 7, 9 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 4: */ 5: 6: #ifndef __ADRENO_GEN8_2_0_SNAPSHOT_H 7: #define __ADRENO_GEN8_2_0_SNAPSHOT_H 8: 9: #include "adreno_gen8_snapshot.h" 10: 11: static const u32 gen8_2_0_debugbus_blocks[] = { 12: DEBUGBUS_GMU_GX_GC_US_I_0, 13: DEBUGBUS_DBGC_GC_US_I_0, 14: DEBUGBUS_RBBM_GC_US_I_0, 15: DEBUGBUS_LARC_GC_US_I_0, 16: DEBUGBUS_COM_GC_US_I_0, 17: DEBUGBUS_HLSQ_GC_US_I_0, 18: DEBUGBUS_CGC_GC_US_I_0, 19: DEBUGBUS_VSC_GC_US_I_0_0, 20: DEBUGBUS_VSC_GC_US_I_0_1, 21: DEBUGBUS_UFC_GC_US_I_0, 22: DEBUGBUS_UFC_GC_US_I_1, 23: DEBUGBUS_CP_GC_US_I_0_0, 24: DEBUGBUS_CP_GC_US_I_0_1, 25: DEBUGBUS_CP_GC_US_I_0_2, 26: DEBUGBUS_PC_BR_US_I_0, 27: DEBUGBUS_PC_BV_US_I_0, 28: DEBUGBUS_GPC_BR_US_I_0, 29: DEBUGBUS_GPC_BV_US_I_0, 30: DEBUGBUS_VPC_BR_US_I_0, 31: DEBUGBUS_VPC_BV_US_I_0, 32: DEBUGBUS_UCHE_WRAPPER_GC_US_I_0, 33: DEBUGBUS_UCHE_GC_US_I_0, MATCH LINES: 2458 2446: 2447: static struct gen8_reg_list gen8_2_0_gmu_gx_registers[] = { 2448: { UNSLICE, gen8_2_0_gmugx_registers }, 2449: { SLICE, gen8_2_0_gmugx_slice_registers }, 2450: { UNSLICE, gen8_2_0_gmuao_registers }, 2451: { UNSLICE, gen8_2_0_gx_clkctl_gx_clkctl_reg_registers }, 2452: { UNSLICE, gen8_2_0_gx_clkctl_ahb2phy_broadcast_swman_registers }, 2453: { UNSLICE, gen8_2_0_gx_clkctl_pll0_cm_pll_taycan_common_registers }, 2454: { UNSLICE, gen8_2_0_gx_clkctl_ahb2phy_swman_registers }, 2455: { UNSLICE, gen8_2_0_acd_acd_mnd_registers }, 2456: }; 2457: 2458: #endif /* __ADRENO_GEN8_2_0_SNAPSHOT_H */ --- FILE: \adreno_gen8_3_0_snapshot.h | HITS: 5 --- MATCH LINES: 5, 6, 8, 9 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 4: */ 5: #ifndef __ADRENO_GEN8_3_0_SNAPSHOT_H 6: #define __ADRENO_GEN8_3_0_SNAPSHOT_H 7: 8: #include "adreno_gen8_snapshot.h" 9: #include "adreno_gen8_0_0_snapshot.h" 10: 11: static const u32 gen8_3_0_debugbus_blocks[] = { 12: DEBUGBUS_GMU_GX_GC_US_I_0, 13: DEBUGBUS_DBGC_GC_US_I_0, 14: DEBUGBUS_RBBM_GC_US_I_0, 15: DEBUGBUS_LARC_GC_US_I_0, 16: DEBUGBUS_COM_GC_US_I_0, 17: DEBUGBUS_HLSQ_GC_US_I_0, 18: DEBUGBUS_CGC_GC_US_I_0, 19: DEBUGBUS_VSC_GC_US_I_0_0, 20: DEBUGBUS_VSC_GC_US_I_0_1, 21: DEBUGBUS_UFC_GC_US_I_0, 22: DEBUGBUS_UFC_GC_US_I_1, 23: DEBUGBUS_CP_GC_US_I_0_0, 24: DEBUGBUS_CP_GC_US_I_0_1, 25: DEBUGBUS_CP_GC_US_I_0_2, 26: DEBUGBUS_PC_BR_US_I_0, 27: DEBUGBUS_PC_BV_US_I_0, 28: DEBUGBUS_GPC_BR_US_I_0, 29: DEBUGBUS_GPC_BV_US_I_0, 30: DEBUGBUS_VPC_BR_US_I_0, 31: DEBUGBUS_VPC_BV_US_I_0, 32: DEBUGBUS_UCHE_WRAPPER_GC_US_I_0, 33: DEBUGBUS_UCHE_GC_US_I_0, MATCH LINES: 824 812: static const u32 *gen8_3_0_external_core_regs[] = { 813: gen8_3_0_gdpm_lkg_registers, 814: gen8_0_0_gpu_cc_ahb2phy_broadcast_swman_registers, 815: gen8_0_0_gpu_cc_ahb2phy_swman_registers, 816: gen8_3_0_gpu_cc_gpu_cc_reg_registers, 817: gen8_3_0_gpu_cc_pll0_cm_pll_lucid_ole_registers, 818: gen8_3_0_acd_acd_mnd_registers, 819: gen8_0_0_gx_clkctl_ahb2phy_broadcast_swman_registers, 820: gen8_0_0_gx_clkctl_ahb2phy_swman_registers, 821: gen8_3_0_gx_clkctl_pll0_cm_pll_lucid_ole_registers, 822: gen8_3_0_gx_clkctl_gx_clkctl_reg_registers, 823: }; 824: #endif /*_ADRENO_GEN8_3_0_SNAPSHOT_H */ --- FILE: \adreno_gen8_6_0_snapshot.h | HITS: 5 --- MATCH LINES: 5, 6, 8, 9 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 4: */ 5: #ifndef __ADRENO_GEN8_6_0_SNAPSHOT_H 6: #define __ADRENO_GEN8_6_0_SNAPSHOT_H 7: 8: #include "adreno_gen8_snapshot.h" 9: #include "adreno_gen8_0_0_snapshot.h" 10: 11: static const u32 gen8_6_0_debugbus_blocks[] = { 12: DEBUGBUS_GMU_GX_GC_US_I_0, 13: DEBUGBUS_DBGC_GC_US_I_0, 14: DEBUGBUS_RBBM_GC_US_I_0, 15: DEBUGBUS_LARC_GC_US_I_0, 16: DEBUGBUS_COM_GC_US_I_0, 17: DEBUGBUS_HLSQ_GC_US_I_0, 18: DEBUGBUS_CGC_GC_US_I_0, 19: DEBUGBUS_VSC_GC_US_I_0_0, 20: DEBUGBUS_VSC_GC_US_I_0_1, 21: DEBUGBUS_UFC_GC_US_I_0, 22: DEBUGBUS_UFC_GC_US_I_1, 23: DEBUGBUS_CP_GC_US_I_0_0, 24: DEBUGBUS_CP_GC_US_I_0_1, 25: DEBUGBUS_CP_GC_US_I_0_2, 26: DEBUGBUS_PC_BR_US_I_0, 27: DEBUGBUS_PC_BV_US_I_0, 28: DEBUGBUS_GPC_BR_US_I_0, 29: DEBUGBUS_GPC_BV_US_I_0, 30: DEBUGBUS_VPC_BR_US_I_0, 31: DEBUGBUS_VPC_BV_US_I_0, 32: DEBUGBUS_UCHE_WRAPPER_GC_US_I_0, 33: DEBUGBUS_UCHE_GC_US_I_0, MATCH LINES: 616 604: gen8_6_0_cpr_registers, 605: }; 606: 607: static struct gen8_reg_list gen8_6_0_gmu_gx_registers[] = { 608: { UNSLICE, gen8_0_0_gmugx_registers }, 609: { UNSLICE, gen8_0_0_gx_clkctl_ahb2phy_broadcast_swman_registers }, 610: { UNSLICE, gen8_0_0_gx_clkctl_ahb2phy_swman_registers }, 611: { UNSLICE, gen8_6_0_gx_clkctl_pll0_cm_pll_lucid_ole_registers }, 612: { UNSLICE, gen8_6_0_gx_clkctl_gx_clkctl_reg_registers }, 613: { UNSLICE, gen8_6_0_acd_acd_registers }, 614: { SLICE, gen8_0_0_gmugx_slice_registers }, 615: }; 616: #endif /*_ADRENO_GEN8_6_0_SNAPSHOT_H */ --- FILE: \adreno_gen8_9_0_snapshot.h | HITS: 5 --- MATCH LINES: 5, 6, 8, 9 1: /* SPDX-License-Identifier: GPL-2.0-only */ 2: /* 3: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 4: */ 5: #ifndef __ADRENO_GEN8_9_0_SNAPSHOT_H 6: #define __ADRENO_GEN8_9_0_SNAPSHOT_H 7: 8: #include "adreno_gen8_snapshot.h" 9: #include "adreno_gen8_2_0_snapshot.h" 10: 11: static const u32 gen8_9_0_debugbus_blocks[] = { 12: DEBUGBUS_GMU_GX_GC_US_I_0, 13: DEBUGBUS_DBGC_GC_US_I_0, 14: DEBUGBUS_RBBM_GC_US_I_0, 15: DEBUGBUS_LARC_GC_US_I_0, 16: DEBUGBUS_COM_GC_US_I_0, 17: DEBUGBUS_HLSQ_GC_US_I_0, 18: DEBUGBUS_CGC_GC_US_I_0, 19: DEBUGBUS_VSC_GC_US_I_0_0, 20: DEBUGBUS_VSC_GC_US_I_0_1, 21: DEBUGBUS_UFC_GC_US_I_0, 22: DEBUGBUS_UFC_GC_US_I_1, 23: DEBUGBUS_CP_GC_US_I_0_0, 24: DEBUGBUS_CP_GC_US_I_0_1, 25: DEBUGBUS_CP_GC_US_I_0_2, 26: DEBUGBUS_PC_BR_US_I_0, 27: DEBUGBUS_PC_BV_US_I_0, 28: DEBUGBUS_GPC_BR_US_I_0, 29: DEBUGBUS_GPC_BV_US_I_0, 30: DEBUGBUS_VPC_BR_US_I_0, 31: DEBUGBUS_VPC_BV_US_I_0, 32: DEBUGBUS_UCHE_WRAPPER_GC_US_I_0, 33: DEBUGBUS_UCHE_GC_US_I_0, MATCH LINES: 168 156: }; 157: static_assert(IS_ALIGNED(sizeof(gen8_9_0_gpu_cc_gpu_cc_reg_registers), 8)); 158: 159: static const u32 *gen8_9_0_external_core_regs[] = { 160: gen8_2_0_gpu_cc_ahb2phy_broadcast_swman_registers, 161: gen8_2_0_gdpm_lkg_registers, 162: gen8_9_0_cpr_registers, 163: gen8_2_0_gpu_cc_ahb2phy_swman_registers, 164: gen8_9_0_gpu_cc_gpu_cc_reg_registers, 165: gen8_2_0_gpu_cc_pll0_cm_pll_taycan_common_registers, 166: }; 167: 168: #endif /* __ADRENO_GEN8_9_0_SNAPSHOT_H */ --- FILE: \adreno_gen8_gmu.c | HITS: 52 --- MATCH LINES: 276, 280, 281, 289, 290, 310 264: 265: ticks = gpudev->read_alwayson(adreno_dev); 266: 267: trace_gmu_ao_sync(ticks); 268: 269: local_irq_restore(flags); 270: } 271: 272: int gen8_gmu_device_start(struct adreno_device *adreno_dev) 273: { 274: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 275: 276: gmu_core_reset_trace_header(&device->gmu_core.trace); 277: 278: gmu_ao_sync_event(adreno_dev); 279: 280: /* Bring GMU out of reset */ 281: gmu_core_regwrite(device, GEN8_GMUCX_CM3_SYSRESET, 0); 282: 283: /* Make sure the write is posted before moving ahead */ 284: wmb(); 285: 286: if (gmu_core_timed_poll_check(device, GEN8_GMUCX_CM3_FW_INIT_RESULT, 287: BIT(8), 100, GENMASK(8, 0))) { 288: dev_err(GMU_PDEV_DEV(device), 289: "GMU failed to come out of reset\n"); 290: gmu_core_fault_snapshot(device, GMU_FAULT_DEVICE_START); 291: return -ETIMEDOUT; 292: } 293: 294: return 0; 295: } 296: 297: /* 298: * gen8_gmu_hfi_start() - Write registers and start HFI. 299: * @device: Pointer to KGSL device 300: */ 301: int gen8_gmu_hfi_start(struct adreno_device *adreno_dev) 302: { 303: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 304: 305: gmu_core_regwrite(device, GEN8_GMUCX_HFI_CTRL_INIT, 1); 306: 307: if (gmu_core_timed_poll_check(device, GEN8_GMUCX_HFI_CTRL_STATUS, 308: BIT(0), 100, BIT(0))) { 309: dev_err(GMU_PDEV_DEV(device), "GMU HFI init failed\n"); 310: gmu_core_fault_snapshot(device, GMU_FAULT_HFI_INIT); 311: return -ETIMEDOUT; 312: } 313: 314: return 0; 315: } 316: 317: int gen8_rscc_wakeup_sequence(struct adreno_device *adreno_dev) 318: { 319: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 320: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 321: 322: /* Skip wakeup sequence if we didn't do the sleep sequence */ 323: if (!test_bit(GMU_PRIV_RSCC_SLEEP_DONE, &gmu->flags)) 324: return 0; 325: 326: /* RSC wake sequence */ 327: gmu_core_regwrite(device, GEN8_GMUAO_RSCC_CONTROL_REQ, BIT(1)); 328: 329: /* Write request before polling */ 330: wmb(); 331: 332: if (gmu_core_timed_poll_check(device, GEN8_GMUAO_RSCC_CONTROL_ACK, 333: BIT(1), 100, BIT(1))) { 334: dev_err(GMU_PDEV_DEV(device), "Failed to do GPU RSC power on\n"); MATCH LINES: 366, 367 354: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 355: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 356: int ret; 357: u32 bitmask = (adreno_is_gen8_2_x(adreno_dev) || adreno_is_gen8_11_x(adreno_dev)) ? 358: BIT(30) : BIT(16); 359: 360: if (!test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags)) 361: return 0; 362: 363: if (test_bit(GMU_PRIV_RSCC_SLEEP_DONE, &gmu->flags)) 364: return 0; 365: 366: gmu_core_regwrite(device, GEN8_GMUCX_CM3_SYSRESET, 1); 367: /* Make sure M3 is in reset before going on */ 368: wmb(); 369: 370: gmu_core_regread(device, GEN8_GMUCX_GENERAL_9, &gmu->log_wptr_retention); 371: 372: gmu_core_regwrite(device, GEN8_GMUAO_RSCC_CONTROL_REQ, BIT(0)); 373: /* Make sure the request completes before continuing */ 374: wmb(); 375: 376: ret = gen8_timed_poll_check_rscc(gmu, GEN8_GPU_RSCC_RSC_STATUS0_DRV0, 377: bitmask, 100, bitmask); 378: if (ret) { 379: dev_err(GMU_PDEV_DEV(device), "GPU RSC power off fail\n"); 380: return -ETIMEDOUT; 381: } 382: 383: gmu_core_regwrite(device, GEN8_GMUAO_RSCC_CONTROL_REQ, 0); 384: 385: set_bit(GMU_PRIV_RSCC_SLEEP_DONE, &gmu->flags); 386: 387: return 0; 388: } 389: 390: static void load_tcm(struct adreno_device *adreno_dev, const u8 *src, 391: u32 tcm_start, u32 base, const struct gmu_block_header *blk) MATCH LINES: 474, 478, 484, 516, 517 462: return "oob_gpu"; 463: case oob_perfcntr: 464: return "oob_perfcntr"; 465: case oob_boot_slumber: 466: return "oob_boot_slumber"; 467: case oob_dcvs: 468: return "oob_dcvs"; 469: default: 470: return "unknown"; 471: } 472: } 473: 474: static void trigger_reset_recovery(struct adreno_device *adreno_dev, 475: enum oob_request req) 476: { 477: /* 478: * Trigger recovery for perfcounter oob only since only 479: * perfcounter oob can happen alongside an actively rendering gpu. 480: */ 481: if (req != oob_perfcntr) 482: return; 483: 484: adreno_scheduler_fault(adreno_dev, ADRENO_GMU_FAULT_SKIP_SNAPSHOT); 485: } 486: 487: int gen8_gmu_oob_set(struct kgsl_device *device, 488: enum oob_request req) 489: { 490: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 491: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 492: int ret = 0; 493: int set, check; 494: 495: if (req == oob_perfcntr && gmu->num_oob_perfcntr++) 496: return 0; 497: 498: if (req >= oob_boot_slumber) { 499: dev_err(GMU_PDEV_DEV(device), 500: "Unsupported OOB request %s\n", 501: oob_to_str(req)); 502: return -EINVAL; 503: } 504: 505: set = BIT(30 - req * 2); 506: check = BIT(31 - req); 507: 508: gmu_core_regwrite(device, GEN8_GMUCX_HOST2GMU_INTR_SET, set); 509: 510: if (gmu_core_timed_poll_check(device, GEN8_GMUCX_GMU2HOST_INTR_INFO, check, 511: 100, check)) { 512: if (req == oob_perfcntr) 513: gmu->num_oob_perfcntr--; 514: WARN(1, "OOB request %s timed out\n", oob_to_str(req)); 515: ret = -ETIMEDOUT; 516: gmu_core_fault_snapshot(device, GMU_FAULT_OOB_SET); 517: trigger_reset_recovery(adreno_dev, req); 518: } 519: 520: gmu_core_regwrite(device, GEN8_GMUCX_GMU2HOST_INTR_CLR, check); 521: 522: trace_kgsl_gmu_oob_set(set); 523: return ret; 524: } 525: 526: void gen8_gmu_oob_clear(struct kgsl_device *device, 527: enum oob_request req) 528: { 529: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 530: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 531: int clear = BIT(31 - req * 2); 532: 533: if (req == oob_perfcntr && --gmu->num_oob_perfcntr) 534: return; 535: 536: if (req >= oob_boot_slumber) { 537: dev_err(GMU_PDEV_DEV(device), "Unsupported OOB clear %s\n", 538: oob_to_str(req)); 539: return; 540: } 541: MATCH LINES: 776, 798 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) 783: { 784: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 785: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 786: u32 status2; 787: u64 ts1; 788: 789: ts1 = gpudev->read_alwayson(adreno_dev); 790: if (gmu_core_timed_poll_check(device, GEN8_GMUAO_GPU_CX_BUSY_STATUS, 791: 0, 100, CXGXCPUBUSYIGNAHB)) { 792: gmu_core_regread(device, 793: GEN8_GMUAO_GPU_CX_BUSY_STATUS2, &status2); 794: dev_err(GMU_PDEV_DEV(device), 795: "GMU not idling: status2=0x%x %llx %llx\n", 796: status2, ts1, 797: gpudev->read_alwayson(adreno_dev)); 798: gmu_core_fault_snapshot(device, GMU_FAULT_WAIT_FOR_IDLE); 799: return -ETIMEDOUT; 800: } 801: 802: return 0; 803: } 804: 805: int gen8_gmu_version_info(struct adreno_device *adreno_dev) 806: { 807: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 808: struct gmu_core_device *gmu = &device->gmu_core; 809: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev); 810: 811: if (gmu_core_capabilities_enabled(&device->gmu_core.common_caps, 812: FCC_VERSION_INFO)) 813: goto done; 814: 815: /* GMU version info is at a fixed offset in the DTCM */ 816: gmu_core_regread(device, GEN8_GMU_CM3_DTCM_START + 0xff8, 817: &gmu->ver.core); 818: gmu_core_regread(device, GEN8_GMU_CM3_DTCM_START + 0xff9, 819: &gmu->ver.core_dev); 820: gmu_core_regread(device, GEN8_GMU_CM3_DTCM_START + 0xffa, 821: &gmu->ver.pwr); 822: gmu_core_regread(device, GEN8_GMU_CM3_DTCM_START + 0xffb, MATCH LINES: 890, 901, 902, 924 878: gmu_core_regwrite(device, GEN8_GMUCX_CM3_FW_INIT_RESULT, 0); 879: gmu_core_regwrite(device, GEN8_GMUCX_CM3_BOOT_CONFIG, 0x2); 880: 881: gmu_core_regwrite(device, GEN8_GMUCX_HFI_QTBL_ADDR, 882: gmu->hfi.hfi_mem->gmuaddr); 883: gmu_core_regwrite(device, GEN8_GMUCX_HFI_QTBL_INFO, 1); 884: 885: gmu_core_regwrite(device, GEN8_GMUAO_AHB_FENCE_RANGE_0, BIT(31) | 886: FIELD_PREP(GENMASK(30, 18), 0x32) | 887: FIELD_PREP(GENMASK(17, 0), GEN8_CP_CONTEXT_SWITCH_CNTL)); 888: 889: /* 890: * Make sure that CM3 state is at reset value. Snapshot is changing 891: * NMI bit and if we boot up GMU with NMI bit set GMU will boot 892: * straight in to NMI handler without executing __main code 893: */ 894: gmu_core_regwrite(device, GEN8_GMUCX_CM3_CFG, 0x4052); 895: 896: /* Set up GBIF registers from the GPU core definition */ 897: kgsl_regmap_multi_write(&device->regmap, gen8_core->gbif, 898: gen8_core->gbif_count); 899: 900: /** 901: * We may have asserted gbif halt as part of reset sequence which may 902: * not get cleared if the gdsc was not reset. So clear it before 903: * attempting GMU boot. 904: */ 905: kgsl_regwrite(device, GEN8_GBIF_HALT, BIT(3)); 906: 907: /* Set vrb address before starting GMU */ 908: if (!IS_ERR_OR_NULL(device->gmu_core.vrb)) 909: gmu_core_regwrite(device, GEN8_GMUCX_GENERAL_11, device->gmu_core.vrb->gmuaddr); 910: 911: /* Set the log wptr index */ 912: gmu_core_regwrite(device, GEN8_GMUCX_GENERAL_9, 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: MATCH LINES: 1108, 1112, 1118, 1128 1096: u32 ack; 1097: unsigned long t; 1098: 1099: kgsl_regwrite(device, reg, mask); 1100: 1101: t = jiffies + msecs_to_jiffies(100); 1102: do { 1103: kgsl_regread(device, ack_reg, &ack); 1104: if ((ack & mask) == mask) 1105: return; 1106: 1107: /* 1108: * If we are attempting recovery in case of stall-on-fault 1109: * then the halt sequence will not complete as long as SMMU 1110: * is stalled. 1111: */ 1112: kgsl_mmu_pagefault_resume(&device->mmu, false); 1113: 1114: usleep_range(10, 100); 1115: } while (!time_after(jiffies, t)); 1116: 1117: /* Check one last time */ 1118: kgsl_mmu_pagefault_resume(&device->mmu, false); 1119: 1120: kgsl_regread(device, ack_reg, &ack); 1121: if ((ack & mask) == mask) 1122: return; 1123: 1124: dev_err(device->dev, "%s GBIF halt timed out\n", client); 1125: } 1126: 1127: /** 1128: * gen8_gbif_gx_reinit - Apply reinit sequence and wait for ack during GPU recovery 1129: * @device: Pointer to the KGSL device 1130: */ 1131: static inline void gen8_gbif_gx_reinit(struct kgsl_device *device) 1132: { 1133: u32 ack; 1134: int ret; 1135: 1136: kgsl_regwrite(device, GEN8_GBIF_REINIT_ENABLE, 0x1); 1137: /* Dummy write to take effect of reinit */ 1138: kgsl_regwrite(device, GEN8_GBIF_REINIT_DONE, 0x0); 1139: 1140: ret = kgsl_regmap_read_poll_timeout(&device->regmap, GEN8_GBIF_REINIT_DONE, 1141: ack, (ack & GEN8_GBIF_REINIT_GX_IDLE_MASK) == GEN8_GBIF_REINIT_GX_IDLE_MASK, 1142: 100, 100 * 1000); 1143: 1144: if (ret) 1145: dev_err(device->dev, "GBIF reinit timed out: ack = 0x%x\n", ack); 1146: } 1147: 1148: 1149: #if (KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE) 1150: static void gen8_genpd_synced_poweroff(struct device *dev) 1151: { 1152: dev_pm_genpd_synced_poweroff(dev); MATCH LINES: 1216, 1219 1204: * GEMNOC can enter power collapse state during GPU power down sequence. 1205: * This could abort CX GDSC collapse. Assert Qactive to avoid this. 1206: */ 1207: gmu_core_regwrite(device, GEN8_GMUCX_CX_FALNEXT_INTF, 0x1); 1208: 1209: /* Check no outstanding RPMh voting */ 1210: gen8_complete_rpmh_votes(gmu, 1); 1211: 1212: /* Clear the WRITEDROPPED fields and set fence to allow mode */ 1213: gmu_core_regwrite(device, GEN8_GMUAO_AHB_FENCE_STATUS_CLR, 0x7); 1214: gmu_core_regwrite(device, GEN8_GMUAO_AHB_FENCE_CTRL, 0); 1215: 1216: /* Make sure above writes are committed before we proceed to recovery */ 1217: wmb(); 1218: 1219: gmu_core_regwrite(device, GEN8_GMUCX_CM3_SYSRESET, 1); 1220: 1221: /* Flush out pending GX transactions using GBIF reinit mechanism */ 1222: gen8_gbif_gx_reinit(device); 1223: 1224: /* Halt CX traffic */ 1225: _do_gbif_halt(device, GEN8_GBIF_HALT, GEN8_GBIF_HALT_ACK, 1226: GEN8_GBIF_ARB_HALT_MASK, "CX"); 1227: 1228: _disable_malu_gdsc(adreno_dev); 1229: 1230: /* 1231: * Switch gx gdsc control from GMU to CPU force non-zero reference 1232: * count in clk driver so next disable call will turn off the GDSC 1233: */ 1234: if (gen8_gmu_gx_is_on(adreno_dev)) { 1235: kgsl_pwrctrl_enable_gx_gdsc(device); 1236: /* 1237: * The gxclkctl driver implements a custom disable callback that prevents 1238: * the OS from collapsing GX GDSC unless the GenPD synced_poweroff flag 1239: * is set. 1240: */ 1241: gen8_genpd_synced_poweroff(device->pwrctrl.gx_pd); 1242: kgsl_pwrctrl_disable_gx_gdsc(device); 1243: } MATCH LINES: 1300 1288: * GEMNOC can enter power collapse state during GPU power down sequence. 1289: * This could abort CX GDSC collapse. Assert Qactive to avoid this. 1290: */ 1291: gmu_core_regwrite(device, GEN8_GMUCX_CX_FALNEXT_INTF, 0x1); 1292: 1293: return ret; 1294: } 1295: 1296: void gen8_gmu_suspend(struct adreno_device *adreno_dev, bool force) 1297: { 1298: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1299: 1300: if (!force && test_bit(ADRENO_DEVICE_RESET_RECOVERY, &adreno_dev->priv)) 1301: return; 1302: 1303: gen8_gmu_pwrctrl_suspend(adreno_dev); 1304: 1305: gmu_core_disable_clks(device); 1306: 1307: kgsl_pwrctrl_disable_mx_gdsc(device); 1308: 1309: kgsl_pwrctrl_disable_cx_gdsc(device); 1310: 1311: gmu_core_rdpm_cx_freq_update(device, 0); 1312: 1313: dev_err(GMU_PDEV_DEV(device), "Suspended GMU\n"); 1314: 1315: kgsl_pwrctrl_set_state(device, KGSL_STATE_NONE); 1316: } 1317: 1318: static int gen8_gmu_dcvs_set(struct adreno_device *adreno_dev, 1319: int gpu_pwrlevel, int bus_level, u32 ab) 1320: { 1321: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1322: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1323: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1324: struct gen8_dcvs_table *table = &gmu->dcvs_table; MATCH LINES: 1364, 1368 1352: ret = CMD_MSG_HDR(req, H2F_MSG_GX_BW_PERF_VOTE); 1353: if (ret) 1354: return ret; 1355: 1356: ret = gen8_hfi_send_generic_req(adreno_dev, &req, sizeof(req)); 1357: if (ret) { 1358: dev_err_ratelimited(GMU_PDEV_DEV(device), 1359: "Failed to set GPU perf idx %u, bw idx %u\n", 1360: req.freq, req.bw); 1361: 1362: /* 1363: * If this was a dcvs request along side an active gpu, request 1364: * dispatcher based reset and recovery. 1365: */ 1366: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 1367: adreno_scheduler_fault(adreno_dev, ADRENO_GMU_FAULT | 1368: ADRENO_GMU_FAULT_SKIP_SNAPSHOT); 1369: } 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) { MATCH LINES: 1461, 1498, 1506, 1515, 1517, 1518, 1525 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; 1457: 1458: /* 1459: * We should not send NMI if there was a CM3 fault reported because we 1460: * don't want to overwrite the critical CM3 state captured by gmu before 1461: * it sent the CM3 fault interrupt. Also don't send NMI if GMU reset is 1462: * already active. We could have hit a GMU assert and NMI might have 1463: * already been triggered. 1464: */ 1465: 1466: /* make sure we're reading the latest cm3_fault */ 1467: smp_rmb(); 1468: 1469: if (atomic_read(&gmu->cm3_fault)) 1470: return; 1471: 1472: gmu_core_regread(device, GEN8_GMUCX_CM3_FW_INIT_RESULT, &result); 1473: 1474: if (result & 0xE00) 1475: return; 1476: 1477: nmi: 1478: /* Mask so there's no interrupt caused by NMI */ 1479: gmu_core_regwrite(device, GEN8_GMUCX_GMU2HOST_INTR_MASK, UINT_MAX); 1480: 1481: /* Make sure the interrupt is masked before causing it */ 1482: wmb(); 1483: 1484: /* This will cause the GMU to save it's internal state to ddr */ 1485: gmu_core_regrmw(device, GEN8_GMUCX_CM3_CFG, BIT(9), BIT(9)); 1486: 1487: /* Make sure the NMI is invoked before we proceed*/ 1488: wmb(); 1489: 1490: /* Wait for the NMI to be handled */ 1491: udelay(200); 1492: 1493: done: 1494: KGSL_GMU_CORE_FORCE_PANIC(device->gmu_core.gf_panic, 1495: GMU_PDEV(device), ticks, gf_policy); 1496: } 1497: 1498: static void gen8_gmu_cooperative_reset(struct kgsl_device *device) 1499: { 1500: u32 result; 1501: 1502: gmu_core_regwrite(device, GEN8_GMUCX_WDOG_CTRL, 0); 1503: gmu_core_regwrite(device, GEN8_GMUCX_HOST2GMU_INTR_SET, BIT(17)); 1504: 1505: /* 1506: * After triggering graceful death wait for snapshot ready 1507: * indication from GMU. 1508: */ 1509: if (!gmu_core_timed_poll_check(device, GEN8_GMUCX_CM3_FW_INIT_RESULT, 1510: 0x800, 2, 0x800)) 1511: return; 1512: 1513: gmu_core_regread(device, GEN8_GMUCX_CM3_FW_INIT_RESULT, &result); 1514: dev_err(GMU_PDEV_DEV(device), 1515: "GMU cooperative reset timed out 0x%x\n", result); 1516: /* 1517: * If we dont get a snapshot ready from GMU, trigger NMI 1518: * and if we still timeout then we just continue with reset. 1519: */ 1520: gen8_gmu_send_nmi(device, true, GMU_FAULT_PANIC_NONE); 1521: 1522: gmu_core_regread(device, GEN8_GMUCX_CM3_FW_INIT_RESULT, &result); 1523: if ((result & 0x800) != 0x800) 1524: dev_err(GMU_PDEV_DEV(device), 1525: "GMU cooperative reset NMI timed out 0x%x\n", result); 1526: } 1527: 1528: static int gen8_gmu_wait_for_active_transition(struct kgsl_device *device) 1529: { 1530: u32 reg; 1531: 1532: if (gmu_core_timed_poll_check(device, GEN8_GMUCX_RPMH_POWER_STATE, 1533: GPU_HW_ACTIVE, 100, GENMASK(3, 0))) { 1534: gmu_core_regread(device, GEN8_GMUCX_RPMH_POWER_STATE, ®); 1535: dev_err(GMU_PDEV_DEV(device), 1536: "GMU failed to move to ACTIVE state, Current state: 0x%x\n", 1537: reg); 1538: 1539: return -ETIMEDOUT; 1540: } 1541: 1542: return 0; 1543: } 1544: 1545: static bool gen8_gmu_scales_bandwidth(struct kgsl_device *device) 1546: { 1547: return true; 1548: } 1549: MATCH LINES: 1680 1668: if (ret) 1669: goto clks_gdsc_off; 1670: 1671: gen8_gmu_register_config(adreno_dev); 1672: 1673: gen8_gmu_irq_enable(adreno_dev); 1674: 1675: /* Vote for minimal DDR BW for GMU to init */ 1676: level = pwr->pwrlevels[pwr->default_pwrlevel].bus_min; 1677: icc_set_bw(pwr->icc_path, 0, kBps_to_icc(pwr->ddr_table[level])); 1678: 1679: /* Clear any GPU faults that might have been left over */ 1680: adreno_clear_gpu_fault(adreno_dev); 1681: 1682: ret = gen8_gmu_device_start(adreno_dev); 1683: if (ret) 1684: goto err; 1685: 1686: ret = gen8_gmu_hfi_start(adreno_dev); 1687: if (ret) 1688: goto err; 1689: 1690: gen8_get_gpu_feature_info(adreno_dev); 1691: 1692: ret = gen8_hfi_start(adreno_dev); 1693: if (ret) 1694: goto err; 1695: 1696: if (adreno_dev->gmu_ab && 1697: gen8_hfi_send_get_value(adreno_dev, HFI_VALUE_GMU_AB_VOTE, 0) == 1 && 1698: !WARN_ONCE(!adreno_dev->gpucore->num_ddr_channels, 1699: "Number of DDR channel is not specified in gpu core")) { 1700: set_bit(ADRENO_DEVICE_GMU_AB, &adreno_dev->priv); 1701: } else { 1702: /* If gmu_ab feature flag is enabled but GMU doesn't support it, set it to false */ 1703: adreno_dev->gmu_ab = false; 1704: } MATCH LINES: 1776 1764: if (ret) 1765: goto clks_gdsc_off; 1766: 1767: ret = gen8_gmu_load_fw(adreno_dev); 1768: if (ret) 1769: goto clks_gdsc_off; 1770: 1771: gen8_gmu_register_config(adreno_dev); 1772: 1773: gen8_gmu_irq_enable(adreno_dev); 1774: 1775: /* Clear any GPU faults that might have been left over */ 1776: adreno_clear_gpu_fault(adreno_dev); 1777: 1778: ret = gen8_gmu_device_start(adreno_dev); 1779: if (ret) 1780: goto err; 1781: 1782: ret = gen8_gmu_hfi_start(adreno_dev); 1783: if (ret) 1784: goto err; 1785: 1786: ret = gen8_hfi_start(adreno_dev); 1787: if (ret) 1788: goto err; 1789: 1790: device->gmu_fault = false; 1791: 1792: kgsl_pwrctrl_set_state(device, KGSL_STATE_AWARE); 1793: 1794: return 0; 1795: 1796: err: 1797: gen8_gmu_irq_disable(adreno_dev); 1798: 1799: if (device->gmu_fault) { 1800: gen8_gmu_suspend(adreno_dev, false); MATCH LINES: 1899 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)) 1923: return 0; MATCH LINES: 2355, 2368, 2369, 2370, 2372, 2373, 2378 2343: 2344: gen8_start(adreno_dev); 2345: 2346: if (gen8_core->qos_value && adreno_is_preemption_enabled(adreno_dev)) 2347: kgsl_regwrite(device, GEN8_RBBM_GBIF_CLIENT_QOS_CNTL, 2348: gen8_core->qos_value[adreno_dev->cur_rb->id]); 2349: 2350: /* Re-initialize the coresight registers if applicable */ 2351: adreno_coresight_start(adreno_dev); 2352: 2353: adreno_perfcounter_start(adreno_dev); 2354: 2355: /* Clear FSR here in case it is set from a previous pagefault */ 2356: kgsl_mmu_clear_fsr(&device->mmu); 2357: 2358: gen8_enable_gpu_irq(adreno_dev); 2359: 2360: ret = gen8_rb_start(adreno_dev); 2361: if (ret) { 2362: gen8_disable_gpu_irq(adreno_dev); 2363: adreno_llcc_slice_deactivate(adreno_dev); 2364: goto oob_clear; 2365: } 2366: 2367: /* 2368: * At this point it is safe to assume that we recovered. Setting 2369: * this field allows us to take a new snapshot for the next failure 2370: * if we are prioritizing the first unrecoverable snapshot. 2371: */ 2372: if (device->snapshot) 2373: device->snapshot->recovered = true; 2374: 2375: /* Start the dispatcher */ 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: { MATCH LINES: 2477, 2478 2465: return ret; 2466: 2467: gen8_populate_ctxt_record_size(adreno_dev); 2468: 2469: gen8_preemption_init(adreno_dev); 2470: 2471: ret = gen8_gpu_boot(adreno_dev); 2472: if (ret) 2473: return ret; 2474: 2475: adreno_get_bus_counters(adreno_dev); 2476: 2477: adreno_dev->cooperative_reset = ADRENO_FEATURE(adreno_dev, 2478: ADRENO_COOP_RESET); 2479: 2480: adreno_create_profile_buffer(adreno_dev); 2481: 2482: set_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags); 2483: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 2484: 2485: /* 2486: * BCL needs respective Central Broadcast register to 2487: * be programed from TZ. For kernel version prior to 6.1, this 2488: * programing happens only when zap shader firmware load is successful. 2489: * Zap firmware load can fail in boot up path hence enable BCL only 2490: * after we successfully complete first boot to ensure that Central 2491: * Broadcast register was programed before enabling BCL. 2492: */ 2493: if (ADRENO_FEATURE(adreno_dev, ADRENO_BCL)) 2494: adreno_dev->bcl_enabled = true; 2495: 2496: /* 2497: * There is a possible deadlock scenario during kgsl firmware reading 2498: * (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl 2499: * device mutex is held and then firmware_request_nowarn is called for reading 2500: * firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock. 2501: * Whereas in case of devfreq update calls triggered by thermal/bcl or 2502: * devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then MATCH LINES: 2583, 2587 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: 2589: kgsl_pwrctrl_set_state(device, KGSL_STATE_SLUMBER); 2590: 2591: return ret; 2592: } 2593: 2594: static void gmu_idle_check(struct work_struct *work) 2595: { 2596: struct kgsl_device *device = container_of(work, 2597: struct kgsl_device, idle_check_ws); 2598: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 2599: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2600: int ret; 2601: 2602: kgsl_mutex_lock(&device->mutex); 2603: 2604: if (test_bit(GMU_DISABLE_SLUMBER, &device->gmu_core.flags)) 2605: goto done; 2606: 2607: if (atomic_read(&device->active_cnt) || time_is_after_jiffies(device->idle_jiffies)) { 2608: kgsl_pwrscale_update(device); 2609: goto done; 2610: } 2611: MATCH LINES: 2833, 2843, 2846 2821: if (ret) 2822: return ret; 2823: 2824: device = KGSL_DEVICE(adreno_dev); 2825: 2826: INIT_WORK(&device->idle_check_ws, gmu_idle_check); 2827: 2828: timer_setup(&device->idle_timer, gmu_idle_timer, 0); 2829: 2830: return 0; 2831: } 2832: 2833: int gen8_gmu_reset(struct adreno_device *adreno_dev) 2834: { 2835: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2836: 2837: gen8_disable_gpu_irq(adreno_dev); 2838: 2839: gen8_gmu_irq_disable(adreno_dev); 2840: 2841: gen8_hfi_stop(adreno_dev); 2842: 2843: /* Hard reset the gmu and gpu */ 2844: gen8_gmu_suspend(adreno_dev, true); 2845: 2846: gen8_reset_preempt_records(adreno_dev); 2847: 2848: adreno_llcc_slice_deactivate(adreno_dev); 2849: 2850: clear_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 2851: 2852: /* Attempt to reboot the gmu and gpu */ 2853: return gen8_boot(adreno_dev); 2854: } 2855: 2856: int gen8_gmu_hfi_probe(struct adreno_device *adreno_dev) 2857: { 2858: struct platform_device *gmu_pdev = GMU_PDEV(KGSL_DEVICE(adreno_dev)); 2859: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2860: struct gen8_hfi *hfi = &gmu->hfi; 2861: 2862: hfi->irq = kgsl_request_irq(gmu_pdev, "hfi", NULL, -EINVAL, 2863: gen8_hfi_irq_handler, KGSL_DEVICE(adreno_dev)); 2864: 2865: return hfi->irq < 0 ? hfi->irq : 0; 2866: } 2867: 2868: int gen8_gmu_add_to_minidump(struct adreno_device *adreno_dev) 2869: { 2870: struct gen8_device *gen8_dev = container_of(adreno_dev, --- FILE: \adreno_gen8_gmu.h | HITS: 15 --- MATCH LINES: 49 37: struct kgsl_memdesc *gmu_init_scratch; 38: /** @gpu_boot_scratch: Memory to store the bootup HFI messages */ 39: struct kgsl_memdesc *gpu_boot_scratch; 40: struct gen8_hfi hfi; 41: u32 idle_level; 42: /** @qmp: aoss_qmp handle */ 43: struct qmp *qmp; 44: u32 log_wptr_retention; 45: /** @cm3_fault: whether gmu received a cm3 fault interrupt */ 46: atomic_t cm3_fault; 47: /** 48: * @itcm_shadow: Copy of the itcm block in firmware binary used for 49: * snapshot 50: */ 51: void *itcm_shadow; 52: /** @flags: Internal gmu flags */ 53: unsigned long flags; 54: /** @rscc_virt: Pointer where RSCC block is mapped */ 55: void __iomem *rscc_virt; 56: /** @log_stream_enable: GMU log streaming enable. Disabled by default */ 57: bool log_stream_enable; 58: /** @log_group_mask: Allows overriding default GMU log group mask */ 59: u32 log_group_mask; 60: struct kobject log_kobj; 61: /** @num_oob_perfcntr: Number of active oob_perfcntr requests */ 62: u32 num_oob_perfcntr; 63: /** @acd_debug_val: DVM value to calibrate ACD for a level */ 64: u32 acd_debug_val; 65: /** @stats_enable: GMU stats feature enable */ 66: bool stats_enable; 67: /** @stats_mask: GMU performance countables to enable */ 68: u32 stats_mask; 69: /** @stats_interval: GMU performance counters sampling interval */ 70: u32 stats_interval; 71: /** @stats_kobj: kernel object for GMU stats directory in sysfs */ 72: struct kobject stats_kobj; 73: /** @cp_init_hdr: raw command header for cp_init */ MATCH LINES: 111, 122, 127, 142, 144, 147, 149, 150 99: int gen8_build_rpmh_tables(struct adreno_device *adreno_dev); 100: 101: /** 102: * gen8_gmu_gx_is_on - Check if GX is on 103: * @adreno_dev: Pointer to the adreno device 104: * 105: * This function reads pwr status registers to check if GX 106: * is on or off 107: */ 108: bool gen8_gmu_gx_is_on(struct adreno_device *adreno_dev); 109: 110: /** 111: * gen8_gmu_device_probe - GEN8 GMU snapshot function 112: * @pdev: Pointer to the platform device 113: * @chipid: Chipid of the target 114: * @gpucore: Pointer to the gpucore 115: * 116: * The target specific probe function for gmu based gen8 targets. 117: */ 118: int gen8_gmu_device_probe(struct platform_device *pdev, 119: u32 chipid, const struct adreno_gpu_core *gpucore); 120: 121: /** 122: * gen8_gmu_reset - Reset and restart the gmu 123: * @adreno_dev: Pointer to the adreno device 124: * 125: * Return: 0 on success or negative error on failure 126: */ 127: int gen8_gmu_reset(struct adreno_device *adreno_dev); 128: 129: /** 130: * gen8_enable_gpu_irq - Enable gpu interrupt 131: * @adreno_dev: Pointer to the adreno device 132: */ 133: void gen8_enable_gpu_irq(struct adreno_device *adreno_dev); 134: 135: /** 136: * gen8_disable_gpu_irq - Disable gpu interrupt 137: * @adreno_dev: Pointer to the adreno device 138: */ 139: void gen8_disable_gpu_irq(struct adreno_device *adreno_dev); 140: 141: /** 142: * gen8_gmu_snapshot- Take snapshot for gmu targets 143: * @adreno_dev: Pointer to the adreno device 144: * @snapshot: Pointer to the snapshot structure 145: * 146: * Send an NMI to gmu if we hit a gmu fault. Then take gmu 147: * snapshot and carry on with rest of the gen8 snapshot 148: */ 149: void gen8_gmu_snapshot(struct adreno_device *adreno_dev, 150: struct kgsl_snapshot *snapshot); 151: 152: /** 153: * gen8_gmu_probe - Probe gen8 gmu resources 154: * @device: Pointer to the kgsl device 155: * @pdev: Pointer to the gmu platform device 156: * 157: * Probe the gmu and hfi resources 158: * 159: * Return: 0 on success or negative error on failure 160: */ 161: int gen8_gmu_probe(struct kgsl_device *device, 162: struct platform_device *pdev); 163: 164: /** 165: * gen8_gmu_parse_fw - Parse the gmu fw binary 166: * @adreno_dev: Pointer to the adreno device 167: * 168: * Return: 0 on success or negative error on failure 169: */ 170: int gen8_gmu_parse_fw(struct adreno_device *adreno_dev); 171: 172: /** 173: * gen8_gmu_memory_init - Allocate gmu memory 174: * @adreno_dev: Pointer to the adreno device MATCH LINES: 202, 218, 254, 256, 258, 259 190: 191: /** 192: * gen8_gmu_load_fw - Load gmu firmware 193: * @adreno_dev: Pointer to the adreno device 194: * 195: * Loads the gmu firmware binary into TCMs and memory 196: * 197: * Return: 0 on success or negative error on failure 198: */ 199: int gen8_gmu_load_fw(struct adreno_device *adreno_dev); 200: 201: /** 202: * gen8_gmu_device_start - Bring gmu out of reset 203: * @adreno_dev: Pointer to the adreno device 204: * 205: * Return: 0 on success or negative error on failure 206: */ 207: int gen8_gmu_device_start(struct adreno_device *adreno_dev); 208: 209: /** 210: * gen8_gmu_hfi_start - Indicate hfi start to gmu 211: * @device: Pointer to the kgsl device 212: * 213: * Return: 0 on success or negative error on failure 214: */ 215: int gen8_gmu_hfi_start(struct adreno_device *adreno_dev); 216: 217: /** 218: * gen8_gmu_itcm_shadow - Create itcm shadow copy for snapshot 219: * @adreno_dev: Pointer to the adreno device 220: * 221: * Return: 0 on success or negative error on failure 222: */ 223: int gen8_gmu_itcm_shadow(struct adreno_device *adreno_dev); 224: 225: /** 226: * gen8_gmu_register_config - gmu register configuration 227: * @adreno_dev: Pointer to the adreno device 228: * 229: * Program gmu regsiters based on features 230: */ 231: void gen8_gmu_register_config(struct adreno_device *adreno_dev); 232: 233: /** 234: * gen8_gmu_version_info - Get gmu firmware version 235: * @adreno_dev: Pointer to the adreno device 236: * 237: * Return: 0 on success or negative error on failure 238: */ 239: int gen8_gmu_version_info(struct adreno_device *adreno_dev); 240: 241: /** 242: * gen8_gmu_irq_enable - Enable gmu interrupts 243: * @adreno_dev: Pointer to the adreno device 244: */ 245: void gen8_gmu_irq_enable(struct adreno_device *adreno_dev); 246: 247: /** 248: * gen8_gmu_irq_disable - Disaable gmu interrupts 249: * @adreno_dev: Pointer to the adreno device 250: */ 251: void gen8_gmu_irq_disable(struct adreno_device *adreno_dev); 252: 253: /** 254: * gen8_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 gen8_gmu_suspend(struct adreno_device *adreno_dev, bool force); 262: 263: /** 264: * gen8_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 gen8_gmu_oob_set(struct kgsl_device *device, enum oob_request oob); 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: --- FILE: \adreno_gen8_gmu_snapshot.c | HITS: 59 --- MATCH LINES: 10, 11, 16, 20, 21, 26, 30, 50, 54, 55, 66, 70, 80, 81, 96, 98, 100, 102, 104, 106, 108, 109, 110, 116, 126, 129, 154, 155, 156, 159, 161, 162, 167, 168, 169, 174, 175, 177, 179, 181, 182, 191, 192, 194, 195, 198, 199, 200, 210, 211, 216, 217, 222, 223, 229, 230, 232, 234, 236 1: // SPDX-License-Identifier: GPL-2.0-only 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 "adreno.h" 8: #include "adreno_gen8.h" 9: #include "adreno_gen8_gmu.h" 10: #include "adreno_gen8_0_0_snapshot.h" 11: #include "adreno_snapshot.h" 12: #include "gen8_reg.h" 13: #include "kgsl_device.h" 14: #include "kgsl_gmu_core.h" 15: 16: static size_t gen8_gmu_snapshot_dtcm(struct kgsl_device *device, 17: u8 *buf, size_t remain, void *priv) 18: { 19: struct gmu_core_device *gmu_core = &device->gmu_core; 20: struct kgsl_snapshot_gmu_mem *mem_hdr = 21: (struct kgsl_snapshot_gmu_mem *)buf; 22: u32 *data = (u32 *)(buf + sizeof(*mem_hdr)); 23: u32 i; 24: 25: if (remain < gmu_core->vma[GMU_DTCM].size + sizeof(*mem_hdr)) { 26: SNAPSHOT_ERR_NOMEM(device, "GMU DTCM Memory"); 27: return 0; 28: } 29: 30: mem_hdr->type = SNAPSHOT_GMU_MEM_BIN_BLOCK; 31: mem_hdr->hostaddr = 0; 32: mem_hdr->gmuaddr = gmu_core->vma[GMU_DTCM].start; 33: mem_hdr->gpuaddr = 0; 34: 35: /* 36: * Read of GMU TCMs over side-band debug controller interface is 37: * supported on gen8 family 38: * region [20]: Dump ITCM/DTCM. Select 1 for DTCM. 39: * autoInc [31]: Autoincrement the address field after each 40: * access to TCM_DBG_DATA 41: */ 42: kgsl_regwrite(device, GEN8_CX_DBGC_TCM_DBG_ADDR, BIT(20) | BIT(31)); 43: 44: for (i = 0; i < (gmu_core->vma[GMU_DTCM].size >> 2); i++) 45: kgsl_regread(device, GEN8_CX_DBGC_TCM_DBG_DATA, data++); 46: 47: return gmu_core->vma[GMU_DTCM].size + sizeof(*mem_hdr); 48: } 49: 50: static size_t gen8_gmu_snapshot_itcm(struct kgsl_device *device, 51: u8 *buf, size_t remain, void *priv) 52: { 53: struct gmu_core_device *gmu_core = &device->gmu_core; 54: struct kgsl_snapshot_gmu_mem *mem_hdr = 55: (struct kgsl_snapshot_gmu_mem *)buf; 56: void *dest = buf + sizeof(*mem_hdr); 57: struct gen8_gmu_device *gmu = (struct gen8_gmu_device *)priv; 58: 59: if (!gmu->itcm_shadow) { 60: dev_err(GMU_PDEV_DEV(device), 61: "No memory allocated for ITCM shadow capture\n"); 62: return 0; 63: } 64: 65: if (remain < gmu_core->vma[GMU_ITCM].size + sizeof(*mem_hdr)) { 66: SNAPSHOT_ERR_NOMEM(device, "GMU ITCM Memory"); 67: return 0; 68: } 69: 70: mem_hdr->type = SNAPSHOT_GMU_MEM_BIN_BLOCK; 71: mem_hdr->hostaddr = 0; 72: mem_hdr->gmuaddr = gmu_core->vma[GMU_ITCM].start; 73: mem_hdr->gpuaddr = 0; 74: 75: memcpy(dest, gmu->itcm_shadow, gmu_core->vma[GMU_ITCM].size); 76: 77: return gmu_core->vma[GMU_ITCM].size + sizeof(*mem_hdr); 78: } 79: 80: static void gen8_gmu_snapshot_memories(struct kgsl_device *device, 81: struct gen8_gmu_device *gmu, struct kgsl_snapshot *snapshot) 82: { 83: struct gmu_mem_type_desc desc; 84: struct kgsl_memdesc *md; 85: struct gmu_core_device *gmu_core = &device->gmu_core; 86: int i; 87: 88: for (i = 0; i < ARRAY_SIZE(gmu_core->gmu_globals); i++) { 89: 90: md = &gmu_core->gmu_globals[i]; 91: if (!md->size) 92: continue; 93: 94: desc.memdesc = md; 95: if (md == gmu->hfi.hfi_mem) 96: desc.type = SNAPSHOT_GMU_MEM_HFI; 97: else if (md == gmu->gmu_log) 98: desc.type = SNAPSHOT_GMU_MEM_LOG; 99: else if ((md == gmu->gmu_init_scratch) || (md == gmu->gpu_boot_scratch)) 100: desc.type = SNAPSHOT_GMU_MEM_WARMBOOT; 101: else if (md == gmu_core->vrb) 102: desc.type = SNAPSHOT_GMU_MEM_VRB; 103: else if (md == gmu_core->trace.md) 104: desc.type = SNAPSHOT_GMU_MEM_TRACE; 105: else 106: desc.type = SNAPSHOT_GMU_MEM_BIN_BLOCK; 107: 108: kgsl_snapshot_add_section(device, 109: KGSL_SNAPSHOT_SECTION_GMU_MEMORY, 110: snapshot, adreno_snapshot_gmu_mem, &desc); 111: } 112: } 113: 114: #define RSCC_OFFSET_DWORDS 0x14000 115: 116: static size_t gen8_snapshot_rscc_registers(struct kgsl_device *device, u8 *buf, 117: size_t remain, void *priv) 118: { 119: const u32 *regs = priv; 120: u32 *data = (u32 *)buf; 121: int count = 0, k; 122: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 123: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 124: 125: /* Figure out how many registers we are going to dump */ 126: count = adreno_snapshot_regs_count(regs); 127: 128: if (remain < (count * 4)) { 129: SNAPSHOT_ERR_NOMEM(device, "RSCC REGISTERS"); 130: return 0; 131: } 132: 133: for (regs = priv; regs[0] != UINT_MAX; regs += 2) { 134: u32 cnt = REG_COUNT(regs); 135: 136: if (cnt == 1) { 137: *data++ = BIT(31) | regs[0]; 138: *data++ = __raw_readl(gmu->rscc_virt + 139: ((regs[0] - RSCC_OFFSET_DWORDS) << 2)); 140: continue; 141: } 142: *data++ = regs[0]; 143: *data++ = cnt; 144: for (k = regs[0]; k <= regs[1]; k++) 145: *data++ = __raw_readl(gmu->rscc_virt + 146: ((k - RSCC_OFFSET_DWORDS) << 2)); 147: } 148: 149: /* Return the size of the section */ 150: return (count * 4); 151: } 152: 153: /* 154: * gen8_gmu_device_snapshot() - GEN8 GMU snapshot function 155: * @device: Device being snapshotted 156: * @snapshot: Pointer to the snapshot instance 157: * 158: * This is where all of the GEN8 GMU specific bits and pieces are grabbed 159: * into the snapshot memory 160: */ 161: static void gen8_gmu_device_snapshot(struct kgsl_device *device, 162: struct kgsl_snapshot *snapshot) 163: { 164: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 165: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 166: const struct adreno_gen8_core *gpucore = to_gen8_core(adreno_dev); 167: const struct gen8_snapshot_block_list *gen8_snapshot_block_list = 168: gpucore->gen8_snapshot_block_list; 169: const u32 *regs_ptr = (const u32 *)gen8_snapshot_block_list->cx_misc_regs; 170: u32 i, j; 171: struct gen8_reg_list_info info = {0}; 172: u32 slice_mask = gen8_get_slice_mask(adreno_dev); 173: 174: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_GMU_MEMORY, 175: snapshot, gen8_gmu_snapshot_itcm, gmu); 176: 177: adreno_snapshot_gmu_versions(device, snapshot); 178: 179: gen8_gmu_snapshot_memories(device, gmu, snapshot); 180: 181: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, snapshot, 182: gen8_snapshot_rscc_registers, (void *) gen8_snapshot_block_list->rscc_regs); 183: 184: /* 185: * We want to capture these through AHB path here because we might skip them 186: * in the crashdumper path if GX is OFF, and these are needed for debug. 187: */ 188: if (!kgsl_regmap_valid_offset(&device->regmap, regs_ptr[0])) 189: WARN_ONCE(1, "cx_misc registers are not defined in device tree"); 190: else 191: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, 192: snapshot, adreno_snapshot_registers_v2, (void *)regs_ptr); 193: 194: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_GMU_MEMORY, 195: snapshot, gen8_gmu_snapshot_dtcm, gmu); 196: 197: /* Capture GMU registers which are on CX domain and unsliced */ 198: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_REGS_V2, snapshot, 199: adreno_snapshot_registers_v2, 200: (void *) gen8_snapshot_block_list->gmu_cx_unsliced_regs); 201: 202: if (!gen8_gmu_rpmh_pwr_state_is_active(device) || 203: !gen8_gmu_gx_is_on(adreno_dev)) 204: return; 205: 206: /* Set fence to ALLOW mode so registers can be read */ 207: kgsl_regwrite(device, GEN8_GMUAO_AHB_FENCE_CTRL, 0); 208: 209: /* Capture GMU registers which are on GX domain */ 210: for (i = 0 ; i < gen8_snapshot_block_list->num_gmu_gx_regs; i++) { 211: struct gen8_reg_list *regs = &gen8_snapshot_block_list->gmu_gx_regs[i]; 212: 213: FOR_EACH_SLICE(j, regs->slice_region, slice_mask) { 214: info.regs = regs; 215: info.slice_id = SLICE_ID(regs->slice_region, j); 216: kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_MVC_V3, snapshot, 217: gen8_legacy_snapshot_registers, &info); 218: } 219: } 220: } 221: 222: void gen8_gmu_snapshot(struct adreno_device *adreno_dev, 223: struct kgsl_snapshot *snapshot) 224: { 225: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 226: 227: /* 228: * Dump external register first to have GPUCC and other external 229: * register in snapshot to analyze the system state even in partial 230: * snapshot dump 231: */ 232: gen8_snapshot_external_core_regs(device, snapshot); 233: 234: gen8_gmu_device_snapshot(device, snapshot); 235: 236: gen8_snapshot(adreno_dev, snapshot); 237: 238: gmu_core_regwrite(device, GEN8_GMUCX_GMU2HOST_INTR_CLR, UINT_MAX); 239: gmu_core_regwrite(device, GEN8_GMUCX_GMU2HOST_INTR_MASK, HFI_IRQ_MASK); 240: } --- FILE: \adreno_gen8_hfi.c | HITS: 10 --- MATCH LINES: 163 151: struct gen8_hfi *hfi = &gmu->hfi; 152: int ret; 153: 154: spin_lock(&hfi->cmdq_lock); 155: 156: if (test_bit(MSG_HDR_GET_ID(msg[0]), hfi->wb_set_record_bitmask)) 157: *msg = RECORD_MSG_HDR(*msg); 158: 159: ret = gen8_hfi_queue_write(adreno_dev, HFI_CMD_ID, msg, size_bytes); 160: 161: /* 162: * Some messages like ACD table and perf table are saved in memory, so we need 163: * to reset the header to make sure we do not send a record enabled bit incase 164: * we change the warmboot setting from debugfs 165: */ 166: *msg = CLEAR_RECORD_MSG_HDR(*msg); 167: /* 168: * Memory barrier to make sure packet and write index are written before 169: * an interrupt is raised 170: */ 171: wmb(); 172: 173: /* Send interrupt to GMU to receive the message */ 174: if (!ret) 175: gmu_core_regwrite(KGSL_DEVICE(adreno_dev), 176: GEN8_GMUCX_HOST2GMU_INTR_SET, 0x1); 177: 178: spin_unlock(&hfi->cmdq_lock); 179: 180: return ret; 181: } 182: 183: /* Sizes of the queue and message are in unit of dwords */ 184: static void init_queues(struct adreno_device *adreno_dev) 185: { 186: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 187: struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem; MATCH LINES: 260, 283, 284, 285 248: if (ret_cmd == NULL) 249: return -EINVAL; 250: 251: if (CMP_HFI_ACK_HDR(ret_cmd->sent_hdr, req_hdr)) { 252: memcpy(&ret_cmd->results, ack, MSG_HDR_GET_SIZE(hdr) << 2); 253: return 0; 254: } 255: 256: /* Didn't find the sender, list the waiter */ 257: dev_err_ratelimited(GMU_PDEV_DEV(device), 258: "HFI ACK: Cannot find sender for 0x%8.8x Waiter: 0x%8.8x\n", 259: req_hdr, ret_cmd->sent_hdr); 260: gmu_core_fault_snapshot(device, GMU_FAULT_HFI_RECIVE_ACK); 261: 262: return -ENODEV; 263: } 264: 265: static int poll_gmu_reg(struct adreno_device *adreno_dev, 266: u32 offsetdwords, u32 expected_val, 267: u32 mask, u32 timeout_ms) 268: { 269: u32 val; 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; 307: } 308: 309: static int gen8_hfi_send_cmd_wait_inline(struct adreno_device *adreno_dev, MATCH LINES: 337, 375 325: rc = gen8_hfi_cmdq_write(adreno_dev, cmd, size_bytes); 326: if (rc) 327: return rc; 328: 329: poll: 330: rc = poll_gmu_reg(adreno_dev, GEN8_GMUCX_GMU2HOST_INTR_INFO, 331: HFI_IRQ_MSGQ_MASK, HFI_IRQ_MSGQ_MASK, HFI_RSP_TIMEOUT); 332: 333: if (rc) { 334: dev_err(GMU_PDEV_DEV(device), 335: "Timed out waiting on ack for 0x%8.8x (id %d, sequence %d)\n", 336: cmd[0], MSG_HDR_GET_ID(*cmd), MSG_HDR_GET_SEQNUM(*cmd)); 337: gmu_core_fault_snapshot(device, GMU_FAULT_SEND_CMD_WAIT_INLINE); 338: return rc; 339: } 340: 341: /* Clear the interrupt */ 342: gmu_core_regwrite(device, GEN8_GMUCX_GMU2HOST_INTR_CLR, 343: HFI_IRQ_MSGQ_MASK); 344: 345: /* Add a barrier to ensure interrupt is cleared before reading queue and polling again */ 346: mb(); 347: 348: rc = gen8_hfi_process_queue(gmu, HFI_MSG_ID, ret_cmd); 349: 350: /* If ACK not received, try polling again */ 351: if (rc == -EAGAIN) 352: goto poll; 353: 354: return rc; 355: } 356: 357: int gen8_hfi_send_generic_req(struct adreno_device *adreno_dev, void *cmd, u32 size_bytes) 358: { 359: struct pending_cmd ret_cmd; 360: int rc; 361: 362: memset(&ret_cmd, 0, sizeof(ret_cmd)); 363: 364: rc = gen8_hfi_send_cmd_wait_inline(adreno_dev, cmd, size_bytes, &ret_cmd); 365: if (rc) 366: return rc; 367: 368: if (ret_cmd.results[2]) { 369: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 370: 371: dev_err(GMU_PDEV_DEV(device), 372: "HFI ACK failure: Req=0x%8.8X, Result=0x%8.8X\n", 373: ret_cmd.results[1], 374: ret_cmd.results[2]); 375: gmu_core_fault_snapshot(device, GMU_FAULT_HFI_SEND_GENERIC_REQ); 376: return -EINVAL; 377: } 378: 379: return 0; 380: } 381: 382: int gen8_hfi_send_core_fw_start(struct adreno_device *adreno_dev) 383: { 384: struct hfi_core_fw_start_cmd cmd = { 385: .handle = 0x0, 386: }; 387: int ret; 388: 389: ret = CMD_MSG_HDR(cmd, H2F_MSG_CORE_FW_START); 390: if (ret) 391: return ret; 392: 393: return gen8_hfi_send_generic_req(adreno_dev, &cmd, sizeof(cmd)); 394: } 395: 396: /* For sending hfi message inline to handle GMU return type error */ 397: int gen8_hfi_send_generic_req_v5(struct adreno_device *adreno_dev, void *cmd, 398: struct pending_cmd *ret_cmd, u32 size_bytes) 399: { MATCH LINES: 426 414: case GMU_ERROR_NO_ENTRY: 415: /* Unique error to handle undefined HFI msgs by caller */ 416: rc = -ENOENT; 417: break; 418: case GMU_ERROR_TIMEOUT: 419: rc = -EINVAL; 420: break; 421: default: 422: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)), 423: "HFI ACK: Req=0x%8.8X, Result=0x%8.8X Error:0x%8.8X\n", 424: ret_cmd->results[1], ret_cmd->results[2], ret_cmd->results[3]); 425: rc = -EINVAL; 426: gmu_core_fault_snapshot(KGSL_DEVICE(adreno_dev), GMU_FAULT_HFI_SEND_GENERIC_REQ); 427: break; 428: } 429: 430: return rc; 431: } 432: 433: int gen8_hfi_send_feature_ctrl(struct adreno_device *adreno_dev, 434: u32 feature, u32 enable, u32 data) 435: { 436: struct pending_cmd ret_cmd = {0}; 437: struct hfi_feature_ctrl_cmd cmd = { 438: .feature = feature, 439: .enable = enable, 440: .data = data, 441: }; 442: int ret; 443: 444: ret = CMD_MSG_HDR(cmd, H2F_MSG_FEATURE_CTRL); 445: if (ret) 446: return ret; 447: 448: ret = gen8_hfi_send_generic_req_v5(adreno_dev, &cmd, &ret_cmd, sizeof(cmd)); 449: if (ret < 0) 450: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)), MATCH LINES: 720 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) 741: { 742: entry->count = count; 743: entry->stride = stride_bytes >> 2; /* entry->stride is in dwords */ 744: memcpy(entry->data, data, stride_bytes * count); MATCH LINES: 796 784: cmd->hdr = CREATE_MSG_HDR(H2F_MSG_TABLE, HFI_MSG_CMD); 785: cmd->hdr = MSG_HDR_SET_SIZE(cmd->hdr, dword_off); 786: 787: return gen8_hfi_send_generic_req(adreno_dev, cmd, dword_off << 2); 788: } 789: 790: int gen8_hfi_start(struct adreno_device *adreno_dev) 791: { 792: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 793: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 794: int result; 795: 796: reset_hfi_queues(adreno_dev); 797: 798: result = gen8_hfi_send_gpu_perf_table(adreno_dev); 799: if (result) 800: goto err; 801: 802: result = gen8_hfi_send_generic_req(adreno_dev, &gmu->hfi.bw_table, 803: sizeof(gmu->hfi.bw_table)); 804: if (result) 805: goto err; 806: 807: result = gen8_hfi_send_acd_feature_ctrl(adreno_dev); 808: if (result) 809: goto err; 810: 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) --- FILE: \adreno_gen8_hwsched.c | HITS: 77 --- MATCH LINES: 12, 38, 66, 67, 75, 77, 85, 94, 95, 96, 100, 101, 102, 106, 107, 108, 112, 113, 114, 118, 122, 123, 124, 128, 129, 130, 137, 138, 139, 140, 145 1: // SPDX-License-Identifier: GPL-2.0-only 2: /* 3: * Copyright (c) 2021, The Linux Foundation. All rights reserved. 4: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5: */ 6: 7: #include 8: 9: #include "adreno.h" 10: #include "adreno_gen8.h" 11: #include "adreno_gen8_hwsched.h" 12: #include "adreno_snapshot.h" 13: #include "kgsl_bus.h" 14: #include "kgsl_device.h" 15: #include "kgsl_gmu_core.h" 16: #include "kgsl_trace.h" 17: #include "kgsl_util.h" 18: 19: static void _wakeup_hw_fence_waiters(struct adreno_device *adreno_dev, u32 fault) 20: { 21: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev); 22: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 23: bool lock = !in_interrupt(); 24: 25: if (!test_bit(ADRENO_HWSCHED_HW_FENCE, &adreno_dev->hwsched.flags)) 26: return; 27: 28: /* 29: * We could be in interrupt context here, which means we need to use spin_lock_irqsave 30: * (which disables interrupts) everywhere we take this lock. Instead of that, simply 31: * avoid taking this lock if we are recording a fault from an interrupt handler. 32: */ 33: if (lock) 34: spin_lock(&hwf->lock); 35: 36: clear_bit(GEN8_HWSCHED_HW_FENCE_SLEEP_BIT, &hwf->flags); 37: 38: /* Avoid creating new hardware fences until recovery is complete */ 39: set_bit(GEN8_HWSCHED_HW_FENCE_ABORT_BIT, &hwf->flags); 40: 41: if (!lock) { 42: /* 43: * This barrier ensures that the above bitops complete before we wake up the waiters 44: */ 45: smp_wmb(); 46: } else { 47: spin_unlock(&hwf->lock); 48: } 49: 50: wake_up_all(&hwf->unack_wq); 51: 52: kgsl_delete_timer(&hfi->hw_fence_timer); 53: } 54: 55: void gen8_hwsched_fault(struct adreno_device *adreno_dev, u32 fault) 56: { 57: /* 58: * Wake up any threads that may be sleeping waiting for the hardware fence unack count to 59: * drop to a desired threshold. 60: */ 61: _wakeup_hw_fence_waiters(adreno_dev, fault); 62: 63: adreno_scheduler_fault(adreno_dev, fault); 64: } 65: 66: void gen8_hwsched_snapshot(struct adreno_device *adreno_dev, 67: struct kgsl_snapshot *snapshot) 68: { 69: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 70: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 71: bool skip_memkind_rb = false; 72: u32 i; 73: bool parse_payload; 74: 75: gen8_gmu_snapshot(adreno_dev, snapshot); 76: 77: adreno_hwsched_parse_fault_cmdobj(adreno_dev, snapshot); 78: 79: /* 80: * First try to dump ringbuffers using context bad HFI payloads 81: * because they have all the ringbuffer parameters. If ringbuffer 82: * payloads are not present, fall back to dumping ringbuffers 83: * based on MEMKIND_RB 84: */ 85: parse_payload = adreno_hwsched_parse_payload_rb(adreno_dev, snapshot); 86: 87: if (parse_payload) 88: skip_memkind_rb = true; 89: 90: for (i = 0; i < hwsched->mem_alloc_entries; i++) { 91: struct hfi_mem_alloc_entry *entry = &hwsched->mem_alloc_table[i]; 92: 93: if (entry->desc.mem_kind == HFI_MEMKIND_RB && !skip_memkind_rb) 94: kgsl_snapshot_add_section(device, 95: KGSL_SNAPSHOT_SECTION_RB_V2, 96: snapshot, adreno_hwsched_snapshot_rb, 97: entry->md); 98: 99: if (entry->desc.mem_kind == HFI_MEMKIND_SCRATCH) 100: kgsl_snapshot_add_section(device, 101: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 102: snapshot, adreno_snapshot_global, 103: entry->md); 104: 105: if (entry->desc.mem_kind == HFI_MEMKIND_PROFILE) 106: kgsl_snapshot_add_section(device, 107: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 108: snapshot, adreno_snapshot_global, 109: entry->md); 110: 111: if (entry->desc.mem_kind == HFI_MEMKIND_CSW_SMMU_INFO) 112: kgsl_snapshot_add_section(device, 113: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 114: snapshot, adreno_snapshot_global, 115: entry->md); 116: 117: if (entry->desc.mem_kind == HFI_MEMKIND_CSW_PRIV_NON_SECURE) 118: adreno_hwsched_snapshot_preemption_records(device, snapshot, 119: entry->md); 120: 121: if (entry->desc.mem_kind == HFI_MEMKIND_PREEMPT_SCRATCH) 122: kgsl_snapshot_add_section(device, 123: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 124: snapshot, adreno_snapshot_global, 125: entry->md); 126: 127: if (entry->desc.mem_kind == HFI_MEMKIND_AQE_BUFFER) 128: kgsl_snapshot_add_section(device, 129: KGSL_SNAPSHOT_SECTION_GPU_OBJECT_V2, 130: snapshot, adreno_hwsched_snapshot_aqe_buffer, 131: entry->md); 132: 133: if (entry->desc.mem_kind == HFI_MEMKIND_HW_FENCE) { 134: struct gmu_mem_type_desc desc; 135: 136: desc.memdesc = entry->md; 137: desc.type = SNAPSHOT_GMU_MEM_HW_FENCE; 138: kgsl_snapshot_add_section(device, 139: KGSL_SNAPSHOT_SECTION_GMU_MEMORY, 140: snapshot, adreno_snapshot_gmu_mem, &desc); 141: } 142: 143: } 144: 145: adreno_hwsched_snapshot_context_queue(device, snapshot); 146: } 147: 148: static void _get_hw_fence_entries(struct adreno_device *adreno_dev) 149: { 150: struct device_node *node = NULL; 151: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 152: u32 shadow_num_entries = 0; 153: 154: if (!ADRENO_FEATURE(adreno_dev, ADRENO_HW_FENCE)) 155: return; 156: 157: node = of_find_node_by_name(NULL, "qcom,hw-fence"); 158: if (!node) 159: return; 160: 161: if (of_property_read_u32(node, "qcom,hw-fence-table-entries", 162: &shadow_num_entries)) { 163: dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)), 164: "qcom,hw-fence-table-entries property not found\n"); 165: shadow_num_entries = 8192; 166: } 167: 168: of_node_put(node); 169: MATCH LINES: 209 197: * soccp power vote failed, these hardware fences may never be signaled. Hence, log them 198: * for debug purposes. 199: */ 200: adreno_hwsched_log_remove_pending_hw_fences(adreno_dev, gmu_pdev_dev); 201: gmu_core_mark_for_coldboot(KGSL_DEVICE(adreno_dev)); 202: 203: adreno_hwsched_deregister_hw_fence(adreno_dev); 204: } 205: 206: static void gen8_hwsched_gmu_suspend(struct adreno_device *adreno_dev, bool force) 207: { 208: gen8_gmu_suspend(adreno_dev, force); 209: adreno_hwsched_reset_hfi_mem(adreno_dev); 210: } 211: 212: static void gen8_hwsched_set_ctxt_record_vrb(struct adreno_device *adreno_dev) 213: { 214: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 215: 216: if (IS_ERR_OR_NULL(device->gmu_core.vrb)) 217: return; 218: 219: /* Populate context record sizes in VRB */ 220: gmu_core_set_vrb_register(device->gmu_core.vrb, VRB_CTXRECORD_TOTAL_SZ, 221: adreno_dev->total_ctxt_record_sz >> 10); 222: gmu_core_set_vrb_register(device->gmu_core.vrb, VRB_CTXRECORD_GMEM_SZ, 223: adreno_gmem_size(adreno_dev) >> 10); 224: 225: /* Populate size of AQE context record */ 226: gmu_core_set_vrb_register(device->gmu_core.vrb, VRB_CTXRECORD_AQE_SZ, 227: adreno_dev->aqe_ctxt_record_sz >> 10); 228: } 229: 230: static void _enable_malu_submissions(struct adreno_device *adreno_dev) 231: { 232: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 233: MATCH LINES: 335 323: 324: /* This is the minimum GMU FW HFI version required to enable hw fences */ 325: if (GMU_VER_MINOR(device->gmu_core.ver.hfi) >= 7) 326: adreno_hwsched_register_hw_fence(adreno_dev); 327: 328: /* From this GMU FW all RBBM interrupts are handled at GMU */ 329: if (device->gmu_core.ver.core >= GMU_VERSION(5, 01, 06)) 330: adreno_irq_free(adreno_dev); 331: 332: gen8_hwsched_soccp_vote(adreno_dev, true); 333: 334: /* Clear any hwsched faults that might have been left over */ 335: adreno_clear_gpu_fault(adreno_dev); 336: 337: ret = gen8_gmu_device_start(adreno_dev); 338: if (ret) 339: goto err; 340: 341: gen8_get_gpu_feature_info(adreno_dev); 342: 343: ret = gen8_hwsched_hfi_start(adreno_dev); 344: if (ret) 345: goto err; 346: 347: if (adreno_dev->gmu_ab && 348: gen8_hwsched_hfi_get_value(adreno_dev, HFI_VALUE_GMU_AB_VOTE, 0) == 1 && 349: !WARN_ONCE(!adreno_dev->gpucore->num_ddr_channels, 350: "Number of DDR channel is not specified in gpu core")) { 351: set_bit(ADRENO_DEVICE_GMU_AB, &adreno_dev->priv); 352: } else { 353: /* If gmu_ab feature flag is enabled but GMU doesn't support it, set it to false */ 354: adreno_dev->gmu_ab = false; 355: } 356: 357: _enable_malu_submissions(adreno_dev); 358: 359: icc_set_bw(pwr->icc_path, 0, 0); MATCH LINES: 382 370: 371: return 0; 372: 373: err: 374: gen8_gmu_irq_disable(adreno_dev); 375: gen8_hwsched_soccp_vote(adreno_dev, false); 376: 377: if (device->gmu_fault) { 378: gen8_hwsched_gmu_suspend(adreno_dev, false); 379: return ret; 380: } 381: 382: adreno_hwsched_reset_hfi_mem(adreno_dev); 383: 384: clks_gdsc_off: 385: gmu_core_disable_clks(device); 386: 387: gdsc_off: 388: kgsl_pwrctrl_disable_mx_gdsc(device); 389: cx_gdsc_off: 390: kgsl_pwrctrl_disable_cx_gdsc(device); 391: 392: gmu_core_rdpm_cx_freq_update(device, 0); 393: 394: return ret; 395: } 396: 397: static void gen8_scm_gpu_tsense_boot(struct adreno_device *adreno_dev) 398: { 399: struct gen8_device *gen8_dev = container_of(adreno_dev, 400: struct gen8_device, adreno_dev); 401: 402: /* Cancel any pending TSENSE work that didn't run */ 403: cancel_work_sync(&gen8_dev->tsense_work); 404: 405: /* Set default tsense measurement window */ 406: gen8_scm_gpu_tsense_default(adreno_dev, true); MATCH LINES: 456, 480 444: 445: ret = gen8_gmu_load_fw(adreno_dev); 446: if (ret) 447: goto clks_gdsc_off; 448: 449: gen8_gmu_register_config(adreno_dev); 450: 451: gen8_gmu_irq_enable(adreno_dev); 452: 453: gen8_hwsched_soccp_vote(adreno_dev, true); 454: 455: /* Clear any hwsched faults that might have been left over */ 456: adreno_clear_gpu_fault(adreno_dev); 457: 458: ret = gen8_gmu_device_start(adreno_dev); 459: if (ret) 460: goto err; 461: 462: ret = gen8_hwsched_hfi_start(adreno_dev); 463: if (ret) 464: goto err; 465: 466: device->gmu_fault = false; 467: 468: kgsl_pwrctrl_set_state(device, KGSL_STATE_AWARE); 469: 470: return 0; 471: err: 472: gen8_gmu_irq_disable(adreno_dev); 473: gen8_hwsched_soccp_vote(adreno_dev, false); 474: 475: if (device->gmu_fault) { 476: gen8_hwsched_gmu_suspend(adreno_dev, false); 477: return ret; 478: } 479: 480: adreno_hwsched_reset_hfi_mem(adreno_dev); 481: 482: clks_gdsc_off: 483: gmu_core_disable_clks(device); 484: 485: gdsc_off: 486: kgsl_pwrctrl_disable_mx_gdsc(device); 487: cx_gdsc_off: 488: kgsl_pwrctrl_disable_cx_gdsc(device); 489: 490: gmu_core_rdpm_cx_freq_update(device, 0); 491: 492: return ret; 493: } 494: 495: /* TSENSE suspend work can be done in parallel with GPU suspend */ 496: static void gen8_scm_gpu_tsense_suspend_work(struct work_struct *work) 497: { 498: struct gen8_device *gen8_dev = container_of(work, struct gen8_device, tsense_work); 499: 500: /* Set non-default tsense measurement window */ 501: gen8_scm_gpu_tsense_default(&gen8_dev->adreno_dev, false); 502: } 503: 504: static void gen8_scm_gpu_tsense_suspend(struct adreno_device *adreno_dev) MATCH LINES: 592 580: gen8_hwsched_hfi_stop(adreno_dev); 581: 582: gmu_core_disable_clks(device); 583: 584: kgsl_pwrctrl_disable_mx_gdsc(device); 585: 586: kgsl_pwrctrl_disable_cx_gdsc(device); 587: 588: gmu_core_rdpm_cx_freq_update(device, 0); 589: 590: kgsl_pwrctrl_set_state(device, KGSL_STATE_NONE); 591: 592: adreno_hwsched_reset_hfi_mem(adreno_dev); 593: 594: return ret; 595: 596: error: 597: gen8_gmu_irq_disable(adreno_dev); 598: gen8_hwsched_hfi_stop(adreno_dev); 599: gen8_hwsched_gmu_suspend(adreno_dev, false); 600: 601: return ret; 602: } 603: 604: void gen8_hwsched_init_ucode_regs(struct adreno_device *adreno_dev) 605: { 606: struct adreno_firmware *fw = ADRENO_FW(adreno_dev, ADRENO_FW_SQE); 607: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 608: 609: /* Program the ucode base for CP */ 610: kgsl_regwrite(device, GEN8_CP_SQE_INSTR_BASE_LO, 611: lower_32_bits(fw->memdesc->gpuaddr)); 612: kgsl_regwrite(device, GEN8_CP_SQE_INSTR_BASE_HI, 613: upper_32_bits(fw->memdesc->gpuaddr)); 614: 615: if (ADRENO_FEATURE(adreno_dev, ADRENO_AQE)) { 616: fw = ADRENO_FW(adreno_dev, ADRENO_FW_AQE); MATCH LINES: 657, 674, 675, 676, 678, 679, 681 645: goto err; 646: 647: /* Clear the busy_data stats - we're starting over from scratch */ 648: memset(&adreno_dev->busy_data, 0, sizeof(adreno_dev->busy_data)); 649: 650: gen8_start(adreno_dev); 651: 652: /* Re-initialize the coresight registers if applicable */ 653: adreno_coresight_start(adreno_dev); 654: 655: adreno_perfcounter_start(adreno_dev); 656: 657: /* Clear FSR here in case it is set from a previous pagefault */ 658: kgsl_mmu_clear_fsr(&device->mmu); 659: 660: gen8_enable_gpu_irq(adreno_dev); 661: 662: gen8_hwsched_init_ucode_regs(adreno_dev); 663: 664: ret = gen8_hwsched_boot_gpu(adreno_dev); 665: if (ret) { 666: adreno_llcc_slice_deactivate(adreno_dev); 667: goto err; 668: } 669: 670: if (adreno_is_gen8_2_x(adreno_dev)) 671: gen8_hwcg_set(adreno_dev, true); 672: 673: /* 674: * At this point it is safe to assume that we recovered. Setting 675: * this field allows us to take a new snapshot for the next failure 676: * if we are prioritizing the first unrecoverable snapshot. 677: */ 678: if (device->snapshot) 679: device->snapshot->recovered = true; 680: 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: MATCH LINES: 905, 906 893: return ret; 894: 895: kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE); 896: 897: ret = gen8_hwsched_gmu_first_boot(adreno_dev); 898: if (ret) 899: return ret; 900: 901: ret = gen8_hwsched_gpu_boot(adreno_dev); 902: if (ret) 903: return ret; 904: 905: adreno_dev->cooperative_reset = ADRENO_FEATURE(adreno_dev, 906: ADRENO_COOP_RESET); 907: 908: set_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags); 909: set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 910: 911: /* 912: * BCL needs respective Central Broadcast register to 913: * be programed from TZ. This programing happens only 914: * when zap shader firmware load is successful. Zap firmware 915: * load can fail in boot up path hence enable BCL only after we 916: * successfully complete first boot to ensure that Central 917: * Broadcast register was programed before enabling BCL. 918: */ 919: if (ADRENO_FEATURE(adreno_dev, ADRENO_BCL)) 920: adreno_dev->bcl_enabled = true; 921: 922: if (device->host_based_dcvs) { 923: /* 924: * There is a possible deadlock scenario during kgsl firmware reading 925: * (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl 926: * device mutex is held and then firmware_request_nowarn is called for reading 927: * firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock. 928: * Whereas in case of devfreq update calls triggered by thermal/bcl or 929: * devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then 930: * tries to take kgsl device mutex as part of get_dev_status/target MATCH LINES: 979, 1004 967: int id; 968: 969: read_lock(&device->context_lock); 970: idr_for_each_entry(&device->context_idr, context, id) { 971: if (context->gmu_registered) 972: drain_ctx_hw_fences_cpu(adreno_dev, ADRENO_CONTEXT(context)); 973: } 974: read_unlock(&device->context_lock); 975: } 976: 977: /** 978: * check_inflight_hw_fences - During SLUMBER entry, we must make sure all hardware fences across 979: * all registered contexts have been sent to TxQueue. If not, take a snapshot 980: */ 981: static int check_inflight_hw_fences(struct adreno_device *adreno_dev) 982: { 983: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 984: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 985: struct kgsl_context *context; 986: int id, ret = 0; 987: 988: if (!test_bit(ADRENO_HWSCHED_HW_FENCE, &hwsched->flags)) 989: return 0; 990: 991: read_lock(&device->context_lock); 992: idr_for_each_entry(&device->context_idr, context, id) { 993: 994: if (context->gmu_registered) { 995: ret = gen8_hwsched_check_context_inflight_hw_fences(adreno_dev, 996: ADRENO_CONTEXT(context)); 997: if (ret) 998: break; 999: } 1000: } 1001: read_unlock(&device->context_lock); 1002: 1003: if (ret) 1004: gmu_core_fault_snapshot(device, GMU_FAULT_HW_FENCE); 1005: 1006: return ret; 1007: } 1008: 1009: static int gen8_hwsched_power_off(struct adreno_device *adreno_dev) 1010: { 1011: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1012: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1013: int ret = 0; 1014: bool drain_cpu = false; 1015: 1016: if (!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 1017: return 0; 1018: 1019: kgsl_pwrctrl_request_state(device, KGSL_STATE_SLUMBER); 1020: 1021: ret = gen8_gmu_oob_set(device, oob_gpu); 1022: if (ret) { 1023: gen8_gmu_oob_clear(device, oob_gpu); 1024: goto no_gx_power; 1025: } 1026: 1027: kgsl_pwrscale_update_stats(device); 1028: MATCH LINES: 1089, 1122 1077: gen8_hwsched_process_msgq(adreno_dev); 1078: 1079: spin_lock(&hwf->lock); 1080: unack_count = hwf->unack_count; 1081: spin_unlock(&hwf->lock); 1082: 1083: if (!unack_count) 1084: return; 1085: 1086: dev_err(GMU_PDEV_DEV(device), 1087: "hardware fence unack_count(%d) isn't zero before SLUMBER\n", 1088: unack_count); 1089: gmu_core_fault_snapshot(device, GMU_FAULT_HW_FENCE); 1090: } 1091: 1092: static void hwsched_idle_check(struct work_struct *work) 1093: { 1094: struct kgsl_device *device = container_of(work, 1095: struct kgsl_device, idle_check_ws); 1096: struct adreno_device *adreno_dev = ADRENO_DEVICE(device); 1097: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 1098: 1099: kgsl_mutex_lock(&device->mutex); 1100: 1101: if (test_bit(GMU_DISABLE_SLUMBER, &device->gmu_core.flags)) 1102: goto done; 1103: 1104: if (atomic_read(&device->active_cnt) || time_is_after_jiffies(device->idle_jiffies)) { 1105: kgsl_pwrscale_update(device); 1106: goto done; 1107: } 1108: 1109: spin_lock(&device->submit_lock); 1110: if (device->submit_now) { 1111: spin_unlock(&device->submit_lock); 1112: kgsl_pwrscale_update(device); 1113: kgsl_start_idle_timer(device); 1114: goto done; 1115: } 1116: 1117: device->skip_inline_submit = true; 1118: spin_unlock(&device->submit_lock); 1119: 1120: if (!gpudev->hw_isidle(adreno_dev)) { 1121: dev_err(device->dev, "GPU isn't idle before SLUMBER\n"); 1122: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE); 1123: } 1124: 1125: check_hw_fence_unack_count(adreno_dev); 1126: 1127: gen8_hwsched_power_off(adreno_dev); 1128: 1129: done: 1130: kgsl_mutex_unlock(&device->mutex); 1131: } 1132: 1133: static int gen8_hwsched_first_open(struct adreno_device *adreno_dev) 1134: { 1135: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1136: int ret; 1137: 1138: /* 1139: * Do the one time settings that need to happen when we 1140: * attempt to boot the gpu the very first time 1141: */ 1142: ret = gen8_hwsched_first_boot(adreno_dev); 1143: if (ret) 1144: return ret; 1145: 1146: /* MATCH LINES: 1231 1219: if (ret) 1220: return ret; 1221: 1222: ret = gen8_hfi_send_cmd_async(adreno_dev, &req, sizeof(req)); 1223: 1224: if (ret) { 1225: dev_err_ratelimited(GMU_PDEV_DEV(device), 1226: "Failed to set GPU perf idx %u, bw idx %u\n", 1227: req.freq, req.bw); 1228: 1229: /* 1230: * If this was a dcvs request along side an active gpu, request 1231: * dispatcher based reset and recovery. 1232: */ 1233: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 1234: gen8_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 1235: } 1236: 1237: if (req.freq != INVALID_DCVS_IDX) 1238: gmu_core_rdpm_mx_freq_update(device, table->gx_votes[req.freq].freq); 1239: 1240: return ret; 1241: } 1242: 1243: static int gen8_hwsched_clock_set(struct adreno_device *adreno_dev, 1244: u32 pwrlevel) 1245: { 1246: return gen8_hwsched_dcvs_set(adreno_dev, pwrlevel, INVALID_DCVS_IDX, INVALID_AB_VALUE); 1247: } 1248: 1249: static int gen8_hwsched_bus_set(struct adreno_device *adreno_dev, int buslevel, 1250: u32 ab) 1251: { 1252: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1253: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 1254: int ret = 0; 1255: MATCH LINES: 1377, 1378, 1379, 1381, 1382, 1407, 1413, 1414, 1417, 1436, 1446, 1455, 1468, 1488, 1489 1365: 1366: read_lock(&hfi->msglock); 1367: 1368: list_for_each_entry(cmd, &hfi->msglist, node) { 1369: if (MSG_HDR_GET_ID(cmd->sent_hdr) == H2F_MSG_UNREGISTER_CONTEXT) 1370: complete(&cmd->complete); 1371: } 1372: 1373: read_unlock(&hfi->msglock); 1374: } 1375: 1376: /** 1377: * process_context_hw_fences_after_reset - This function processes all hardware fences that were 1378: * sent to GMU prior to recovery. If a fence is not retired by the GPU, and the context is still 1379: * good, then move them to the reset list. 1380: */ 1381: static void process_context_hw_fences_after_reset(struct adreno_device *adreno_dev, 1382: struct adreno_context *drawctxt, struct list_head *reset_list) 1383: { 1384: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1385: struct adreno_hw_fence_entry *entry, *tmp; 1386: 1387: spin_lock(&drawctxt->lock); 1388: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_inflight_list, node) { 1389: struct adreno_context *drawctxt = entry->drawctxt; 1390: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr; 1391: bool retired = kgsl_check_timestamp(device, &drawctxt->base, (u32)entry->cmd.ts); 1392: 1393: /* Delete the fences that GMU has sent to the TxQueue */ 1394: if (timestamp_cmp(hdr->out_fence_ts, (u32)entry->cmd.ts) >= 0) { 1395: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 1396: continue; 1397: } 1398: 1399: /* 1400: * Force retire the fences if the ts is retired and context is not 1401: * registered with GMU, or if the context is gone bad. 1402: */ 1403: if ((retired && !drawctxt->base.gmu_registered) || 1404: kgsl_context_is_bad(&drawctxt->base)) 1405: entry->cmd.flags |= HW_FENCE_FLAG_SKIP_MEMSTORE; 1406: 1407: list_add_tail(&entry->reset_node, reset_list); 1408: } 1409: spin_unlock(&drawctxt->lock); 1410: } 1411: 1412: /** 1413: * process_inflight_hw_fences_after_reset - Send hardware fences from all contexts back to the GMU 1414: * after fault recovery. We must wait for ack when sending each of these fences to GMU so as to 1415: * avoid sending a large number of hardware fences in a short span of time. 1416: */ 1417: static int process_inflight_hw_fences_after_reset(struct adreno_device *adreno_dev) 1418: { 1419: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1420: struct kgsl_context *context = NULL; 1421: int id, ret = 0; 1422: struct list_head hw_fence_list; 1423: struct adreno_hw_fence_entry *entry, *tmp; 1424: bool update_out_fence_ts = false; 1425: 1426: /** 1427: * Since we need to wait for ack from GMU when sending each inflight fence back to GMU, we 1428: * cannot send them from within atomic context. Hence, walk list of such hardware fences 1429: * for each context and add it to this local list and then walk this list to send all these 1430: * fences to GMU. 1431: */ 1432: INIT_LIST_HEAD(&hw_fence_list); 1433: 1434: read_lock(&device->context_lock); 1435: idr_for_each_entry(&device->context_idr, context, id) { 1436: process_context_hw_fences_after_reset(adreno_dev, ADRENO_CONTEXT(context), 1437: &hw_fence_list); 1438: } 1439: read_unlock(&device->context_lock); 1440: 1441: /* 1442: * Although we are not destroying the entries here, they can get destroyed concurrently 1443: * in f2h_main thread once they have been sent to GMU. Hence, to be safe against entry 1444: * destroy, use list_for_each_entry_safe. 1445: */ 1446: list_for_each_entry_safe(entry, tmp, &hw_fence_list, reset_node) { 1447: struct adreno_context *drawctxt = entry->drawctxt; 1448: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr; 1449: u32 entry_ts = (u32)entry->cmd.ts; 1450: 1451: /* 1452: * We must remove this entry from hw_fence_list before sending it to GMU to avoid 1453: * racing with the f2h_main thread 1454: */ 1455: list_del_init(&entry->reset_node); 1456: 1457: /* 1458: * We must access the hw fence entry before sending it to GMU as once it is 1459: * sent to GMU, it may be freed by f2h_main thread concurrently 1460: */ 1461: if (((entry->cmd.flags & HW_FENCE_FLAG_SKIP_MEMSTORE) != 0) && 1462: (timestamp_cmp(entry_ts, hdr->out_fence_ts) > 0)) { 1463: if (_kgsl_context_get(&drawctxt->base)) 1464: update_out_fence_ts = true; 1465: } 1466: 1467: /* 1468: * This is part of the reset sequence and any error in this path will be handled by 1469: * the caller. 1470: */ 1471: ret = gen8_send_hw_fence_hfi_wait_ack(adreno_dev, entry, 0); 1472: if (ret) 1473: break; 1474: 1475: /* 1476: * If HW_FENCE_FLAG_SKIP_MEMSTORE is set, then GMU context queue header will not be 1477: * updated for this fence. Hence, update it here. 1478: */ 1479: if (update_out_fence_ts) { 1480: hdr->out_fence_ts = entry_ts; 1481: kgsl_context_put(&drawctxt->base); 1482: update_out_fence_ts = false; 1483: } 1484: } 1485: 1486: /* Remove remaining entries from the list if we hit an error */ 1487: if (ret) { 1488: list_for_each_entry_safe(entry, tmp, &hw_fence_list, reset_node) { 1489: list_del_init(&entry->reset_node); 1490: } 1491: } 1492: 1493: return ret; 1494: } 1495: 1496: static int gen8_hwsched_drain_context_hw_fences(struct adreno_device *adreno_dev, 1497: struct adreno_context *drawctxt) 1498: { 1499: struct adreno_hw_fence_entry *entry, *tmp; 1500: int ret = 0; 1501: 1502: /* We don't need the drawctxt lock here as this context has already been invalidated */ 1503: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_list, node) { 1504: 1505: /* Any error here is fatal */ 1506: ret = gen8_send_hw_fence_hfi_wait_ack(adreno_dev, entry, 1507: HW_FENCE_FLAG_SKIP_MEMSTORE); 1508: if (ret) 1509: break; 1510: 1511: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 1512: } 1513: MATCH LINES: 1545, 1561, 1573, 1584, 1592, 1617, 1623, 1634 1533: return guilty; 1534: } 1535: 1536: static int drain_guilty_context_hw_fences(struct adreno_device *adreno_dev) 1537: { 1538: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1539: struct adreno_context *guilty = _get_guilty_context(device); 1540: int ret = 0; 1541: 1542: /* 1543: * We don't need drawctxt spinlock to signal these fences since the only other place 1544: * which can retire these fences is the context detach path and device mutex 1545: * ensures mutual exclusion between recovery thread and detach thread. 1546: */ 1547: while (guilty) { 1548: ret = gen8_hwsched_drain_context_hw_fences(adreno_dev, guilty); 1549: 1550: kgsl_context_put(&guilty->base); 1551: 1552: if (ret) 1553: break; 1554: 1555: guilty = _get_guilty_context(device); 1556: } 1557: 1558: return ret; 1559: } 1560: 1561: static int handle_hw_fences_after_reset(struct adreno_device *adreno_dev) 1562: { 1563: int ret; 1564: 1565: ret = drain_guilty_context_hw_fences(adreno_dev); 1566: if (ret) 1567: return ret; 1568: 1569: /* 1570: * We must do this after adreno_hwsched_replay() so that context registration 1571: * is done before we re-send the un-retired hardware fences to the GMU 1572: */ 1573: ret = process_inflight_hw_fences_after_reset(adreno_dev); 1574: if (ret) 1575: return ret; 1576: 1577: ret = gen8_hwsched_process_detached_hw_fences(adreno_dev); 1578: if (ret) 1579: return ret; 1580: 1581: return gen8_hwsched_disable_hw_fence_throttle(adreno_dev); 1582: } 1583: 1584: int gen8_hwsched_reset_replay(struct adreno_device *adreno_dev) 1585: { 1586: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1587: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 1588: int ret; 1589: 1590: /* 1591: * Any pending context unregister packets will be lost 1592: * since we hard reset the GMU. This means any threads waiting 1593: * for context unregister hfi ack will timeout. Wake them 1594: * to avoid false positive ack timeout messages later. 1595: */ 1596: gen8_hwsched_drain_ctxt_unregister(adreno_dev); 1597: 1598: if (!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 1599: return 0; 1600: 1601: gen8_disable_gpu_irq(adreno_dev); 1602: 1603: gen8_gmu_irq_disable(adreno_dev); 1604: 1605: gen8_hwsched_hfi_stop(adreno_dev); 1606: 1607: gen8_hwsched_gmu_suspend(adreno_dev, true); 1608: 1609: adreno_hwsched_unregister_contexts(adreno_dev); 1610: 1611: adreno_llcc_slice_deactivate(adreno_dev); 1612: 1613: clear_bit(GMU_PRIV_GPU_STARTED, &gmu->flags); 1614: 1615: spin_lock(&hwf->lock); 1616: 1617: /* Reset the unack count back to zero as we start afresh */ 1618: hwf->unack_count = 0; 1619: 1620: spin_unlock(&hwf->lock); 1621: 1622: /* 1623: * When we reset, we want to coldboot incase any scratch corruption 1624: * has occurred before we faulted. 1625: */ 1626: gmu_core_mark_for_coldboot(KGSL_DEVICE(adreno_dev)); 1627: 1628: ret = gen8_hwsched_boot(adreno_dev); 1629: if (ret) 1630: goto done; 1631: 1632: adreno_hwsched_replay(adreno_dev); 1633: 1634: ret = handle_hw_fences_after_reset(adreno_dev); 1635: done: 1636: BUG_ON(ret); 1637: 1638: return ret; 1639: } 1640: 1641: ssize_t gen8_hwsched_preempt_info_get(struct adreno_device *adreno_dev, char *buf) 1642: { 1643: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1644: u32 preempt_count_l0, preempt_count_l1a, preempt_count_l1b; 1645: u32 count = 0, max_size = PAGE_SIZE; 1646: int ret; 1647: 1648: ret = gmu_core_get_vrb_register(device->gmu_core.vrb, 1649: VRB_PREEMPT_COUNT_L0, &preempt_count_l0); 1650: ret |= gmu_core_get_vrb_register(device->gmu_core.vrb, 1651: VRB_PREEMPT_COUNT_L1A, &preempt_count_l1a); 1652: ret |= gmu_core_get_vrb_register(device->gmu_core.vrb, 1653: VRB_PREEMPT_COUNT_L1B, &preempt_count_l1b); 1654: 1655: if (ret) 1656: return ret; 1657: 1658: count += scnprintf(buf + count, max_size - count, MATCH LINES: 1831 1819: struct adreno_hwsched *hwsched = container_of(kobj, struct adreno_hwsched, tunables_kobj); 1820: struct adreno_device *adreno_dev = container_of(hwsched, struct adreno_device, hwsched); 1821: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1822: s64 val = 0; 1823: int ret; 1824: 1825: /* Since UINT_MAX and -1 can both be a valid input, parse in to s64 */ 1826: ret = kstrtos64(buf, 0, &val); 1827: if (ret) 1828: return ret; 1829: 1830: /* 1831: * To reset a tunable, a user can either write a -1 or UINT_MAX. Both values can be 1832: * represented as UINT_MAX in a u32 variable. Hence store the value as a u32 and 1833: * make sure the input is within allowed range. 1834: */ 1835: if ((val < -1) || (val > UINT_MAX)) 1836: return -ERANGE; 1837: 1838: kgsl_mutex_lock(&device->mutex); 1839: hwsched->sysfs_dcvs_tunables[pattr->tuning_attr].value = (u32)val; 1840: device->ftbl->gmu_based_dcvs_pwr_ops(device, pattr->tuning_attr, 1841: GPU_PWRLEVEL_OP_TUNING_ATTR); 1842: kgsl_mutex_unlock(&device->mutex); 1843: 1844: return count; 1845: } 1846: 1847: DCVS_TUNABLES_SYSFS(penalty_up, GPU_TUNING_KEY_BUSY_PENALTY_UP); 1848: DCVS_TUNABLES_SYSFS(penalty_down, GPU_TUNING_KEY_BUSY_PENALTY_DOWN); 1849: DCVS_TUNABLES_SYSFS(first_step_down, GPU_TUNING_KEY_FIRST_STEP_DOWN_COUNT); 1850: DCVS_TUNABLES_SYSFS(subsequent_step_down, GPU_TUNING_KEY_SUBSEQUENT_STEP_DOWN_COUNT); 1851: DCVS_TUNABLES_SYSFS(target_fps, GPU_TUNING_KEY_TARGET_FPS); 1852: DCVS_TUNABLES_SYSFS(num_samples_up, GPU_TUNING_KEY_NUM_SAMPLES_UP); 1853: DCVS_TUNABLES_SYSFS(num_samples_down, GPU_TUNING_KEY_NUM_SAMPLES_DOWN); 1854: DCVS_TUNABLES_SYSFS(strict_frame, GPU_TUNING_KEY_STRICT_FRAME); 1855: DCVS_TUNABLES_SYSFS(non_linear_ramp_up, GPU_TUNING_KEY_NON_LINEAR_RAMP_UP); MATCH LINES: 2018 2006: struct kgsl_pwrctrl *pwr = &device->pwrctrl; 2007: u32 busy_perc = 0; 2008: 2009: spin_lock(&pwr->stats_lock); 2010: 2011: /* 2012: * Average out the samples taken since last read. This will keep the average value in 2013: * sync with the client sampling duration. 2014: */ 2015: if (pwr->accum_total_time) 2016: busy_perc = (u32)((pwr->accum_busy_stats * 100) / pwr->accum_total_time); 2017: 2018: /* Reset the parameters */ 2019: pwr->accum_total_time = 0; 2020: pwr->accum_busy_stats = 0; 2021: spin_unlock(&pwr->stats_lock); 2022: 2023: return scnprintf(buf, PAGE_SIZE, "%u\n", busy_perc); 2024: } 2025: 2026: DCVS_SYSFS_RO(aggregated_max_gpuclk); 2027: DCVS_SYSFS_RO(dcvs_tunables_default); 2028: DCVS_SYSFS_RO(dcvs_tunables_cur); 2029: DCVS_SYSFS_RO(gpu_load); 2030: 2031: static struct attribute *dcvs_attrs[] = { 2032: &dcvs_attr_aggregated_max_gpuclk.attr, 2033: &dcvs_attr_dcvs_tunables_default.attr, 2034: &dcvs_attr_dcvs_tunables_cur.attr, 2035: &dcvs_attr_gpu_load.attr, 2036: NULL, 2037: }; 2038: 2039: ATTRIBUTE_GROUPS(dcvs); 2040: 2041: static const struct kobj_type ktype_dcvs = { 2042: .sysfs_ops = &kobj_sysfs_ops, MATCH LINES: 2136 2124: if (ret) 2125: return ret; 2126: 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; --- FILE: \adreno_gen8_hwsched.h | HITS: 8 --- MATCH LINES: 52, 57, 60, 62, 64, 66, 67, 96 40: * @pdev: Pointer to the platform device 41: * @chipid: Chipid of the target 42: * @gpucore: Pointer to the gpucore 43: * 44: * The target specific probe function for hwsched enabled gmu targets. 45: * 46: * Return: 0 on success or negative error on failure 47: */ 48: int gen8_hwsched_probe(struct platform_device *pdev, 49: u32 chipid, const struct adreno_gpu_core *gpucore); 50: 51: /** 52: * gen8_hwsched_reset_replay - Restart the gmu and gpu and replay inflight cmdbatches 53: * @adreno_dev: Pointer to the adreno device 54: * 55: * Return: 0 on success or negative error on failure 56: */ 57: int gen8_hwsched_reset_replay(struct adreno_device *adreno_dev); 58: 59: /** 60: * gen8_hwsched_snapshot - take gen8 hwsched snapshot 61: * @adreno_dev: Pointer to the adreno device 62: * @snapshot: Pointer to the snapshot instance 63: * 64: * Snapshot the faulty ib and then snapshot rest of gen8 gmu things 65: */ 66: void gen8_hwsched_snapshot(struct adreno_device *adreno_dev, 67: struct kgsl_snapshot *snapshot); 68: 69: /** 70: * gen8_hwsched_handle_watchdog - Handle watchdog interrupt 71: * @adreno_dev: Pointer to the adreno device 72: */ 73: void gen8_hwsched_handle_watchdog(struct adreno_device *adreno_dev); 74: 75: /** 76: * gen8_hwsched_add_to_minidump - Register hwsched_device with va minidump 77: * @adreno_dev: Pointer to the adreno device 78: */ 79: int gen8_hwsched_add_to_minidump(struct adreno_device *adreno_dev); 80: 81: /** 82: * gen8_hwsched_send_recurring_cmdobj - Dispatch IBs to GMU 83: * @adreno_dev: Pointer to adreno device structure 84: * @cmdobj: The command object which needs to be submitted 85: * 86: * This function is used to register the context if needed and submit 87: * recurring IBs to the GMU. Upon receiving ipc interrupt GMU will submit 88: * recurring IBs to GPU. 89: 90: * Return: 0 on success and negative error on failure 91: */ 92: int gen8_hwsched_send_recurring_cmdobj(struct adreno_device *adreno_dev, 93: struct kgsl_drawobj_cmd *cmdobj); 94: 95: /** 96: * gen8_hwsched_fault - Set hwsched fault to request recovery 97: * @adreno_dev: A handle to adreno device 98: * @fault: The type of fault 99: */ 100: void gen8_hwsched_fault(struct adreno_device *adreno_dev, u32 fault); 101: 102: /** 103: * gen8_hwsched_soccp_vote - Vote for soccp power 104: * @adreno_dev: A handle to adreno device 105: * @pwr_on: Boolean to turn soccp on/off 106: */ 107: void gen8_hwsched_soccp_vote(struct adreno_device *adreno_dev, bool pwr_on); 108: 109: /** 110: * gen8_hwsched_set_pwrconstraint - Send perf hint to GMU 111: * @adreno_dev: A handle to adreno device 112: * @context_id: Id for the context associated with hint 113: */ 114: void gen8_hwsched_set_pwrconstraint(struct adreno_device *adreno_dev, u32 context_id); 115: 116: /** 117: * gen8_hwsched_init_ucode_regs - Initializes CP ucode registers 118: * @adreno_dev: A handle to adreno device 119: */ 120: void gen8_hwsched_init_ucode_regs(struct adreno_device *adreno_dev); --- FILE: \adreno_gen8_hwsched_hfi.c | HITS: 63 --- MATCH LINES: 268, 274 256: 257: static void handle_sw_fault(struct adreno_device *adreno_dev, const char *str, u32 key) 258: { 259: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)); 260: u32 status = gen8_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, key); 261: 262: dev_crit_ratelimited(gmu_pdev_dev, "CP %s | SW fault | status=0x%8.8x\n", str, status); 263: /* BIT(12) - SMMU fault */ 264: if (status & BIT(12)) 265: adreno_scheduler_fault(adreno_dev, ADRENO_IOMMU_STALL_ON_PAGE_FAULT); 266: } 267: 268: static bool log_gpu_fault(struct adreno_device *adreno_dev) 269: { 270: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)); 271: struct hfi_context_bad_cmd *cmd = adreno_dev->hwsched.ctxt_bad; 272: 273: /* Return false for non fatal errors */ 274: if (adreno_hwsched_log_nonfatal_gpu_fault(adreno_dev, gmu_pdev_dev, cmd->error)) 275: return false; 276: 277: switch (cmd->error) { 278: case GMU_GPU_HW_HANG: 279: dev_crit_ratelimited(gmu_pdev_dev, "MISC: GPU hang detected\n"); 280: break; 281: case GMU_GPU_SW_HANG: 282: dev_crit_ratelimited(gmu_pdev_dev, "gpu timeout ctx %u ts %u\n", 283: cmd->gc.ctxt_id, cmd->gc.ts); 284: break; 285: case GMU_CP_OPCODE_ERROR: 286: dev_crit_ratelimited(gmu_pdev_dev, 287: "CP opcode error interrupt | opcode=0x%8.8x\n", 288: gen8_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 289: KEY_CP_OPCODE_ERROR)); 290: break; 291: case GMU_CP_PROTECTED_ERROR: { 292: u32 status = gen8_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS, 293: KEY_CP_PROTECTED_ERROR); 294: 295: dev_crit_ratelimited(gmu_pdev_dev, 296: "CP | Protected mode error | %s | addr=0x%5.5x | status=0x%8.8x\n", 297: status & (1 << 20) ? "READ" : "WRITE", 298: status & 0x3FFFF, status); MATCH LINES: 544 532: break; 533: case GMU_DBGC_INTR_ERROR: 534: dev_crit_ratelimited(gmu_pdev_dev, "DBGC error interrupt\n"); 535: break; 536: case GMU_CP_UNKNOWN_ERROR: 537: fallthrough; 538: default: 539: dev_crit_ratelimited(gmu_pdev_dev, "Unknown GPU fault: %u\n", 540: cmd->error); 541: break; 542: } 543: 544: /* Return true for fatal errors to perform recovery sequence */ 545: return true; 546: } 547: 548: static bool is_queue_empty(struct adreno_device *adreno_dev, u32 queue_idx) 549: { 550: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 551: struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem; 552: struct hfi_queue_table *tbl = mem_addr->hostptr; 553: struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx]; 554: 555: if (hdr->status == HFI_QUEUE_STATUS_DISABLED) 556: return true; 557: 558: if (hdr->read_index == hdr->write_index) 559: return true; 560: 561: /* 562: * This is to ensure that the queue is not read speculatively before the queue empty 563: * condition is evaluated 564: */ 565: rmb(); 566: 567: return false; 568: } MATCH LINES: 588, 589, 594, 595 576: u32 *queue; 577: 578: if (is_queue_empty(adreno_dev, queue_idx)) 579: return 0; 580: 581: queue = HOST_QUEUE_START_ADDR(mem_addr, queue_idx); 582: 583: return queue[hdr->read_index]; 584: } 585: 586: static void process_ctx_bad(struct adreno_device *adreno_dev) 587: { 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: MATCH LINES: 712 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: MATCH LINES: 780 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. 781: */ 782: #define HW_FENCE_SLEEP_MS 200 783: 784: static void _enable_hw_fence_throttle(struct adreno_device *adreno_dev) 785: { 786: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev); 787: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 788: 789: set_bit(GEN8_HWSCHED_HW_FENCE_SLEEP_BIT, &hwf->flags); 790: set_bit(GEN8_HWSCHED_HW_FENCE_MAX_BIT, &hwf->flags); 791: 792: /* Avoid submitting new work to gpu until the unack count drops to a desired threshold */ 793: adreno_get_gpu_halt(adreno_dev); 794: 795: mod_timer(&hfi->hw_fence_timer, jiffies + msecs_to_jiffies(HW_FENCE_SLEEP_MS)); 796: } 797: 798: static void _increment_hw_fence_unack_count(struct adreno_device *adreno_dev) 799: { 800: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 801: 802: if ((++hwf->unack_count) == MAX_HW_FENCE_UNACK_COUNT) 803: _enable_hw_fence_throttle(adreno_dev); 804: } MATCH LINES: 944, 959 932: struct gen8_hwsched_hfi, defer_hw_fence_work); 933: struct gen8_hwsched_device *gen8_hwsched = container_of(hfi, struct gen8_hwsched_device, 934: hwsched_hfi); 935: struct adreno_context *drawctxt; 936: struct adreno_device *adreno_dev = &gen8_hwsched->gen8_dev.adreno_dev; 937: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 938: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 939: u32 ts; 940: int ret; 941: 942: /* 943: * Grab the dispatcher and device mutex as we don't want to race with concurrent fault 944: * recovery 945: */ 946: mutex_lock(&adreno_dev->hwsched.mutex); 947: kgsl_mutex_lock(&device->mutex); 948: 949: spin_lock(&hwf->lock); 950: drawctxt = hwf->defer_drawctxt; 951: ts = hwf->defer_ts; 952: spin_unlock(&hwf->lock); 953: 954: if (!drawctxt) 955: goto unlock; 956: 957: ret = process_hw_fence_deferred_ctxt(adreno_dev, drawctxt, ts); 958: if (ret) { 959: /* the deferred drawctxt will be handled post fault recovery */ 960: gen8_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 961: goto unlock; 962: } 963: 964: /* 965: * Put back the context reference which was incremented when hw_fence.defer_drawctxt was set 966: */ 967: kgsl_context_put(&drawctxt->base); 968: 969: adreno_active_count_put(adreno_dev); 970: 971: _disable_hw_fence_throttle(adreno_dev, false); 972: 973: unlock: 974: kgsl_mutex_unlock(&device->mutex); 975: mutex_unlock(&adreno_dev->hwsched.mutex); 976: } 977: 978: static int _check_hw_fence_ack_failure(struct kgsl_device *device, u32 *result) 979: { 980: if (!result[2]) 981: return 0; 982: 983: dev_err(GMU_PDEV_DEV(device), MATCH LINES: 1156, 1162, 1177 1144: log_event += start * 4; 1145: while (start != end) { 1146: trace_gmu_event(log_event); 1147: log_event += 4; 1148: start++; 1149: } 1150: } 1151: 1152: static void gen8_hwsched_process_dbgq(struct adreno_device *adreno_dev, bool limited) 1153: { 1154: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1155: u32 rcvd[MAX_RCVD_SIZE]; 1156: bool recovery = false; 1157: 1158: while (gen8_hfi_queue_read(gmu, HFI_DBG_ID, rcvd, sizeof(rcvd)) > 0) { 1159: 1160: if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_ERR) { 1161: adreno_gen8_receive_err_req(gmu, rcvd); 1162: recovery = true; 1163: break; 1164: } 1165: 1166: if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_DEBUG) 1167: adreno_gen8_receive_debug_req(gmu, rcvd); 1168: 1169: if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_LOG_BLOCK) 1170: process_log_block(adreno_dev, rcvd); 1171: 1172: /* Process one debug queue message and return to not delay msgq processing */ 1173: if (limited) 1174: break; 1175: } 1176: 1177: if (!recovery) 1178: return; 1179: 1180: gen8_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 1181: } 1182: 1183: /* HFI interrupt handler */ 1184: static irqreturn_t gen8_hwsched_hfi_handler(int irq, void *data) 1185: { 1186: struct adreno_device *adreno_dev = data; 1187: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1188: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev); 1189: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1190: u32 status = 0; 1191: const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev); 1192: u64 ticks = gpudev->read_alwayson(adreno_dev); 1193: 1194: /* 1195: * GEN8_GMUCX_GMU2HOST_INTR_INFO may have bits set not specified in hfi->irq_mask. 1196: * Read and clear only those irq bits that we are processing here. 1197: */ 1198: gmu_core_regread(device, GEN8_GMUCX_GMU2HOST_INTR_INFO, &status); 1199: gmu_core_regwrite(device, GEN8_GMUCX_GMU2HOST_INTR_CLR, status & hfi->irq_mask); 1200: 1201: /* MATCH LINES: 1464, 1473, 1503, 1523, 1550, 1554 1452: 1453: rc = gen8_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd)); 1454: if (rc) 1455: return rc; 1456: 1457: poll: 1458: rc = adreno_hwsched_poll_msg_queue_write_index(gmu->hfi.hfi_mem); 1459: 1460: if (rc) { 1461: dev_err(gmu_pdev_dev, 1462: "Timed out processing MSG_START seqnum: %d\n", 1463: seqnum); 1464: gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START); 1465: goto done; 1466: } 1467: 1468: rc = gen8_hfi_queue_read(gmu, HFI_MSG_ID, rcvd, sizeof(rcvd)); 1469: if (rc <= 0) { 1470: dev_err(gmu_pdev_dev, 1471: "MSG_START: payload error: %d\n", 1472: rc); 1473: gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START); 1474: goto done; 1475: } 1476: 1477: switch (MSG_HDR_GET_ID(rcvd[0])) { 1478: case F2H_MSG_MEM_ALLOC: 1479: rc = mem_alloc_reply(adreno_dev, rcvd); 1480: break; 1481: case F2H_MSG_GMU_CNTR_REGISTER: 1482: rc = gmu_cntr_register_reply(adreno_dev, rcvd); 1483: break; 1484: case F2H_MSG_PROCESS_TRACE: 1485: rc = 0; 1486: gmu_core_process_trace_data(device, GMU_PDEV_DEV(device), &device->gmu_core.trace); 1487: break; 1488: case F2H_MSG_PLATFORM_LA: 1489: rc = gen8_hwsched_process_f2h_platform_msg(adreno_dev, rcvd); 1490: break; 1491: default: 1492: if (MSG_HDR_GET_TYPE(rcvd[0]) == HFI_MSG_ACK) { 1493: rc = gen8_receive_ack_cmd(gmu, rcvd, &pending_ack); 1494: /* Check ack failure if we received an expected ack */ 1495: if (!rc) 1496: rc = check_ack_failure(adreno_dev, &pending_ack); 1497: goto done; 1498: } else { 1499: dev_err(gmu_pdev_dev, 1500: "MSG_START: unexpected response id:%d, type:%d\n", 1501: MSG_HDR_GET_ID(rcvd[0]), 1502: MSG_HDR_GET_TYPE(rcvd[0])); 1503: gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START); 1504: rc = -EINVAL; 1505: goto done; 1506: } 1507: } 1508: 1509: if (!rc) 1510: goto poll; 1511: 1512: done: 1513: /* Clear the interrupt */ 1514: gmu_core_regwrite(device, GEN8_GMUCX_GMU2HOST_INTR_CLR, HFI_IRQ_MSGQ_MASK); 1515: /* 1516: * Add a write barrier to post the interrupt clear so that we dont have a 1517: * pending interrupt. 1518: */ 1519: wmb(); 1520: return rc; 1521: } 1522: 1523: static void reset_hfi_queues(struct adreno_device *adreno_dev) 1524: { 1525: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1526: struct hfi_queue_table *tbl = gmu->hfi.hfi_mem->hostptr; 1527: u32 i; 1528: 1529: /* Flush HFI queues */ 1530: for (i = 0; i < HFI_QUEUE_MAX; i++) { 1531: struct hfi_queue_header *hdr = &tbl->qhdr[i]; 1532: 1533: if (hdr->status == HFI_QUEUE_STATUS_DISABLED) 1534: continue; 1535: 1536: hdr->read_index = hdr->write_index; 1537: } 1538: } 1539: 1540: void gen8_hwsched_hfi_stop(struct adreno_device *adreno_dev) 1541: { 1542: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1543: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev); 1544: 1545: hfi->irq_mask &= ~HFI_IRQ_MSGQ_MASK; 1546: 1547: /* 1548: * In some corner cases, it is possible that GMU put TS_RETIRE 1549: * on the msgq after we have turned off gmu interrupts. Hence, 1550: * drain the queue one last time before we reset HFI queues. 1551: */ 1552: gen8_hwsched_process_msgq(adreno_dev); 1553: 1554: /* Drain the debug queue before we reset HFI queues */ 1555: gen8_hwsched_process_dbgq(adreno_dev, false); 1556: 1557: kgsl_pwrctrl_axi(KGSL_DEVICE(adreno_dev), false); 1558: 1559: clear_bit(GMU_PRIV_HFI_STARTED, &gmu->flags); 1560: } 1561: 1562: static void gen8_hwsched_enable_async_hfi(struct adreno_device *adreno_dev) 1563: { 1564: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev); 1565: 1566: hfi->irq_mask |= HFI_IRQ_MSGQ_MASK; 1567: 1568: gmu_core_regwrite(KGSL_DEVICE(adreno_dev), GEN8_GMUCX_GMU2HOST_INTR_MASK, 1569: (u32)~hfi->irq_mask); 1570: } 1571: 1572: static int enable_preemption(struct adreno_device *adreno_dev) 1573: { 1574: const struct adreno_gen8_core *gen8_core = to_gen8_core(adreno_dev); 1575: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1576: u32 data; 1577: int ret; 1578: MATCH LINES: 1755, 1759, 1762 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, 1747: "GMU doesn't support HW_FENCE feature\n"); 1748: adreno_hwsched_deregister_hw_fence(adreno_dev); 1749: return 0; 1750: } 1751: 1752: return ret; 1753: } 1754: 1755: static int gen8_hfi_send_soft_reset_feature_ctrl(struct adreno_device *adreno_dev) 1756: { 1757: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 1758: 1759: if (!test_bit(ADRENO_HWSCHED_GPU_SOFT_RESET, &hwsched->flags)) 1760: return 0; 1761: 1762: return gen8_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_SOFT_RESET, 1, 0); 1763: } 1764: 1765: static int gen8_hfi_send_fast_context_destroy_feature_ctrl(struct adreno_device *adreno_dev) 1766: { 1767: int ret; 1768: 1769: if (!ADRENO_FEATURE(adreno_dev, ADRENO_GMU_FAST_CONTEXT_DESTROY)) 1770: return 0; 1771: 1772: if (!gmu_core_capabilities_enabled(&KGSL_DEVICE(adreno_dev)->gmu_core.platform_caps, 1773: FAC_FAST_CONTEXT_DESTROY)) 1774: return 0; 1775: 1776: /* 1777: * Enable the fast context destroy optimization if requested by the static 1778: * feature flag and if the capability is supported by the GMU. 1779: */ 1780: ret = gen8_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_FAST_CONTEXT_DESTROY, 1, 0); 1781: if (!ret) 1782: set_bit(ADRENO_DEVICE_FAST_CONTEXT_DESTROY, &adreno_dev->priv); 1783: 1784: return ret; 1785: } 1786: MATCH LINES: 1808 1796: kgsl_regread(device, GEN8_CP_RB_RPTR_LPAC, &rptr); 1797: kgsl_regread(device, GEN8_CP_RB_WPTR_LPAC, &wptr); 1798: 1799: kgsl_regread(device, GEN8_RBBM_STATUS, &status); 1800: kgsl_regread(device, GEN8_RBBM_INT_0_STATUS, &intstatus); 1801: kgsl_regread(device, GEN8_CP_INTERRUPT_STATUS_GLOBAL, &global_status); 1802: 1803: dev_err(device->dev, 1804: "LPAC rb=%d pos=%X/%X rbbm_status=%8.8X int_0_status=%8.8X global_status=%8.8X\n", 1805: val ? KGSL_LPAC_RB_ID : 1, rptr, wptr, 1806: status, intstatus, global_status); 1807: 1808: kgsl_device_snapshot(device, NULL, NULL, false); 1809: } 1810: 1811: static bool gen8_hwsched_warmboot_possible(struct adreno_device *adreno_dev) 1812: { 1813: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 1814: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1815: struct gmu_core_device *gmu_core = &device->gmu_core; 1816: 1817: if (gmu_core->warmboot_enabled && test_bit(GMU_PRIV_WARMBOOT_GMU_INIT_DONE, &gmu->flags) 1818: && test_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags) && 1819: !test_bit(GMU_FORCE_COLDBOOT, &device->gmu_core.flags)) 1820: return true; 1821: 1822: return false; 1823: } 1824: 1825: static int gen8_hwsched_hfi_send_warmboot_cmd(struct adreno_device *adreno_dev, 1826: struct kgsl_memdesc *desc, u32 flag, bool async, struct pending_cmd *ack) 1827: { 1828: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 1829: struct gmu_core_device *gmu_core = &device->gmu_core; 1830: struct hfi_warmboot_scratch_cmd cmd = {0}; 1831: int ret; 1832: MATCH LINES: 2192, 2196, 2220 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; 2189: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 2190: u32 thermal_pwrlevel = max_t(u32, pwr->thermal_pwrlevel, pwr->pmqos_max_pwrlevel); 2191: int ret = 0; 2192: bool reset = false; 2193: 2194: /* Disable recording of these messages */ 2195: if (test_and_clear_bit(H2F_MSG_SET_VALUE, hfi->wb_set_record_bitmask)) 2196: reset = true; 2197: 2198: if (hwsched->dcvs_param_update) 2199: ret = gen8_hwsched_set_gmu_based_dcvs_value(adreno_dev, 2200: HFI_VALUE_DCVS_ENABLE, 0, 2201: gmu_core->gpu_pwrscale_enable, true); 2202: 2203: if (thermal_pwrlevel != 0) 2204: ret = gen8_hwsched_set_gmu_based_dcvs_value(adreno_dev, 2205: HFI_VALUE_MAX_GPU_THERMAL_INDEX, 0, 2206: (pwr->num_pwrlevels - thermal_pwrlevel), true); 2207: 2208: if (pwr->min_pwrlevel != (pwr->num_pwrlevels - 1)) 2209: ret = gen8_hwsched_set_gmu_based_dcvs_value(adreno_dev, 2210: HFI_VALUE_MIN_GPU_PERF_INDEX, 0, 2211: (pwr->num_pwrlevels - pwr->min_pwrlevel), true); 2212: 2213: if (pwr->max_pwrlevel != 0) 2214: ret = gen8_hwsched_set_gmu_based_dcvs_value(adreno_dev, 2215: HFI_VALUE_MAX_GPU_PERF_INDEX, 0, 2216: (pwr->num_pwrlevels - pwr->max_pwrlevel), true); 2217: 2218: gen8_hwsched_send_tuning_attrs(adreno_dev); 2219: 2220: if (reset) 2221: set_bit(H2F_MSG_SET_VALUE, hfi->wb_set_record_bitmask); 2222: 2223: hwsched->dcvs_param_update = false; 2224: 2225: return ret; 2226: } 2227: 2228: static int gen8_hwsched_setup_default_votes(struct adreno_device *adreno_dev) 2229: { 2230: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2231: 2232: if (device->host_based_dcvs) 2233: return kgsl_pwrctrl_setup_default_votes(device); 2234: 2235: return gen8_hwsched_set_gmu_based_dcvs_votes(adreno_dev); 2236: } 2237: 2238: int gen8_hwsched_warmboot_init_gmu(struct adreno_device *adreno_dev) 2239: { 2240: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2241: struct pending_cmd ack = {0}; 2242: int ret = 0; 2243: 2244: ret = gen8_hwsched_hfi_send_warmboot_cmd(adreno_dev, gmu->gmu_init_scratch, MATCH LINES: 2657, 2683, 2700 2645: goto err; 2646: 2647: ret = gen8_hfi_send_lpac_feature_ctrl(adreno_dev); 2648: if (ret) 2649: goto err; 2650: 2651: if (ADRENO_FEATURE(adreno_dev, ADRENO_AQE)) { 2652: ret = gen8_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_AQE, 1, 0); 2653: if (ret) 2654: goto err; 2655: } 2656: 2657: ret = gen8_hfi_send_soft_reset_feature_ctrl(adreno_dev); 2658: if (ret) 2659: goto err; 2660: 2661: ret = gen8_hfi_send_fast_context_destroy_feature_ctrl(adreno_dev); 2662: if (ret) 2663: goto err; 2664: 2665: if (adreno_dev->dcvs_profile_enabled) { 2666: ret = gen8_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_DCVS_PROFILE, 1, 0); 2667: if (ret) 2668: goto err; 2669: } 2670: 2671: err: 2672: return ret; 2673: } 2674: 2675: int gen8_hwsched_hfi_start(struct adreno_device *adreno_dev) 2676: { 2677: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 2678: struct gmu_core_device *gmu_core = &device->gmu_core; 2679: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 2680: struct pending_cmd ack = {0}; 2681: int ret; 2682: 2683: reset_hfi_queues(adreno_dev); 2684: 2685: ret = gen8_gmu_hfi_start(adreno_dev); 2686: if (ret) 2687: goto err; 2688: 2689: if (gen8_hwsched_warmboot_possible(adreno_dev)) 2690: return gen8_hwsched_warmboot_init_gmu(adreno_dev); 2691: 2692: if (ADRENO_FEATURE(adreno_dev, ADRENO_GMU_WARMBOOT) && 2693: (!test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags))) { 2694: if (gen8_hfi_send_get_value(adreno_dev, HFI_VALUE_GMU_WARMBOOT, 0) == 1) 2695: gmu_core->warmboot_enabled = true; 2696: } 2697: 2698: warmboot_init_message_record_bitmask(adreno_dev); 2699: 2700: /* Reset the variable here and set it when we successfully record the scratch */ 2701: clear_bit(GMU_PRIV_WARMBOOT_GMU_INIT_DONE, &gmu->flags); 2702: clear_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags); 2703: 2704: ret = gen8_hwsched_hfi_send_warmboot_cmd(adreno_dev, gmu->gmu_init_scratch, 2705: HFI_WARMBOOT_SET_SCRATCH, false, &ack); 2706: if (ret) 2707: goto err; 2708: 2709: ret = gen8_hfi_send_gpu_perf_table(adreno_dev); 2710: if (ret) 2711: goto err; 2712: 2713: ret = gen8_hfi_send_generic_req(adreno_dev, &gmu->hfi.bw_table, sizeof(gmu->hfi.bw_table)); 2714: if (ret) 2715: goto err; 2716: 2717: ret = gen8_hfi_send_gmu_dcvs_req(adreno_dev); 2718: if (ret) 2719: goto err; 2720: 2721: ret = gen8_hwsched_feature_ctrl(adreno_dev); 2722: if (ret) 2723: goto err; 2724: MATCH LINES: 3342, 3343 3330: break; 3331: } 3332: 3333: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 3334: } 3335: spin_unlock(&drawctxt->lock); 3336: 3337: return ret; 3338: } 3339: 3340: /** 3341: * move_detached_context_hardware_fences - Move all pending hardware fences belonging to this 3342: * context to the detached hardware fence list so as to send them to TxQueue after fault recovery. 3343: * This is needed because this context may get destroyed before fault recovery gets executed. 3344: */ 3345: static void move_detached_context_hardware_fences(struct adreno_device *adreno_dev, 3346: struct adreno_context *drawctxt) 3347: { 3348: struct adreno_hw_fence_entry *entry, *tmp; 3349: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev); 3350: 3351: spin_lock(&drawctxt->lock); 3352: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_inflight_list, node) { 3353: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr; 3354: 3355: if ((timestamp_cmp((u32)entry->cmd.ts, hdr->out_fence_ts) > 0)) { 3356: _kgsl_context_get(&drawctxt->base); 3357: list_move_tail(&entry->node, &hfi->detached_hw_fence_list); 3358: continue; 3359: } 3360: 3361: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 3362: } 3363: 3364: spin_unlock(&drawctxt->lock); 3365: 3366: /* Also grab all the hardware fences which were never sent to GMU */ 3367: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_list, node) { MATCH LINES: 3391, 3403, 3438 3379: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_list, node) { 3380: 3381: ret = gen8_send_hw_fence_hfi_wait_ack(adreno_dev, entry, 3382: HW_FENCE_FLAG_SKIP_MEMSTORE); 3383: if (ret) 3384: break; 3385: 3386: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 3387: } 3388: 3389: if (ret) { 3390: move_detached_context_hardware_fences(adreno_dev, drawctxt); 3391: gmu_core_fault_snapshot(KGSL_DEVICE(adreno_dev), GMU_FAULT_HW_FENCE); 3392: gen8_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 3393: } 3394: 3395: return ret; 3396: } 3397: 3398: /** 3399: * check_detached_context_hardware_fences - When this context has been un-registered with the GMU, 3400: * make sure all the hardware fences(that were sent to GMU) for this context have been sent to 3401: * TxQueue. Also, send any hardware fences (to GMU) that were not yet dispatched to the GMU. In case 3402: * of an error, move the pending hardware fences to detached hardware fence list, log the error, 3403: * take a snapshot and trigger recovery. 3404: */ 3405: static int check_detached_context_hardware_fences(struct adreno_device *adreno_dev, 3406: struct adreno_context *drawctxt) 3407: { 3408: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 3409: struct adreno_hw_fence_entry *entry, *tmp; 3410: int ret = 0; 3411: u32 id, ts, fence_ts; 3412: 3413: spin_lock(&drawctxt->lock); 3414: list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_inflight_list, node) { 3415: struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr; 3416: 3417: if ((timestamp_cmp((u32)entry->cmd.ts, hdr->out_fence_ts) > 0)) { 3418: id = drawctxt->base.id; 3419: ts = (u32)entry->cmd.ts; 3420: fence_ts = hdr->out_fence_ts; 3421: spin_unlock(&drawctxt->lock); 3422: 3423: dev_err(GMU_PDEV_DEV(device), 3424: "detached ctx:%d has unsignaled fence ts:%d retired:%d\n", 3425: id, ts, fence_ts); 3426: ret = -EINVAL; 3427: goto fault; 3428: } 3429: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 3430: } 3431: 3432: spin_unlock(&drawctxt->lock); 3433: /* Send hardware fences (to TxQueue) that were not dispatched to GMU */ 3434: return drain_context_hw_fence_gmu(adreno_dev, drawctxt); 3435: 3436: fault: 3437: move_detached_context_hardware_fences(adreno_dev, drawctxt); 3438: gmu_core_fault_snapshot(device, GMU_FAULT_HW_FENCE); 3439: gen8_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 3440: 3441: return ret; 3442: } 3443: 3444: static inline int setup_hw_fence_info_cmd(struct adreno_device *adreno_dev, 3445: struct adreno_hw_fence_entry *entry) 3446: { 3447: struct kgsl_sync_fence *kfence = entry->kfence; 3448: int ret; 3449: 3450: ret = CMD_MSG_HDR(entry->cmd, H2F_MSG_HW_FENCE_INFO); 3451: if (ret) 3452: return ret; 3453: 3454: ret = kgsl_hw_fence_create(KGSL_DEVICE(adreno_dev), kfence); 3455: if (ret) 3456: return ret; 3457: 3458: entry->cmd.gmu_ctxt_id = entry->drawctxt->base.id; 3459: entry->cmd.ctxt_id = kfence->fence.context; 3460: entry->cmd.ts = kfence->fence.seqno; 3461: 3462: entry->cmd.hash_index = kfence->hw_fence_index; MATCH LINES: 3513 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: { 3530: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 3531: struct adreno_hw_fence_entry *entry; 3532: 3533: if (!kgsl_hw_fence_tx_slot_available(KGSL_DEVICE(adreno_dev), 3534: hwsched->hw_fence.pending_count)) 3535: return NULL; 3536: 3537: if (!DRAWCTXT_SLOT_AVAILABLE(drawctxt->hw_fence_count)) MATCH LINES: 3564 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 */ 3583: list_for_each_entry_reverse(entry, &drawctxt->hw_fence_list, node) { 3584: if (timestamp_cmp(ts, (u32)entry->cmd.ts) > 0) 3585: break; 3586: } 3587: 3588: list_add(&new->node, &entry->node); MATCH LINES: 3609, 3637, 3638 3597: ret = !test_bit(GEN8_HWSCHED_HW_FENCE_SLEEP_BIT, &hwf->flags); 3598: spin_unlock(&hwf->lock); 3599: 3600: return ret; 3601: } 3602: 3603: /** 3604: * _hw_fence_sleep() - Check if the thread needs to sleep until the hardware fence unack count 3605: * drops to a desired threshold. 3606: * 3607: * Return: negative error code if the thread was woken up by a signal, or the context became bad in 3608: * the meanwhile, or the hardware fence unack count hasn't yet dropped to a desired threshold, or 3609: * if fault recovery is imminent. 3610: * Otherwise, return 0. 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) 3648: { 3649: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 3650: struct kgsl_sync_timeline *ktimeline = kfence->parent; 3651: struct kgsl_context *context = ktimeline->context; 3652: struct adreno_context *drawctxt = ADRENO_CONTEXT(context); 3653: struct adreno_hw_fence_entry *entry = NULL; 3654: /* Only allow a single log in a second */ 3655: static DEFINE_RATELIMIT_STATE(_rs, HZ, 1); 3656: struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence; 3657: u32 retired = 0; 3658: int ret = 0; 3659: bool destroy = false; 3660: u32 hw_fence_last_ts; 3661: 3662: spin_lock(&drawctxt->lock); MATCH LINES: 3684 3672: if (timestamp_cmp(hw_fence_last_ts, kfence->timestamp) >= 0) 3673: goto done; 3674: 3675: drawctxt->hw_fence_last_ts = kfence->timestamp; 3676: 3677: /* 3678: * If we create a hardware fence and this context is going away, we may never dispatch 3679: * this fence to the GMU. Hence, avoid creating a hardware fence if context is going away. 3680: */ 3681: if (kgsl_context_is_bad(context)) 3682: goto done; 3683: 3684: /* If recovery is imminent, then do not create a hardware fence */ 3685: if (test_bit(GEN8_HWSCHED_HW_FENCE_ABORT_BIT, &hwf->flags)) 3686: goto done; 3687: 3688: ret = _hw_fence_sleep(adreno_dev, drawctxt); 3689: if (ret) 3690: goto done; 3691: 3692: /* 3693: * If this ts hasn't been submitted yet, then store it in the drawctxt hardware fence 3694: * list and return. This fence will be sent to GMU when this ts is dispatched to GMU. 3695: */ 3696: if (timestamp_cmp(kfence->timestamp, drawctxt->gmu_hw_fence_ready_ts) > 0) { 3697: drawctxt_queue_hw_fence(adreno_dev, drawctxt, kfence); 3698: goto done; 3699: } 3700: 3701: kgsl_readtimestamp(device, context, KGSL_TIMESTAMP_RETIRED, &retired); 3702: 3703: /* 3704: * Check if timestamp is retired. If we are in SLUMBER at this point, the timestamp is 3705: * guaranteed to be retired. This way, we don't need the device mutex to check the device 3706: * state explicitly. 3707: */ 3708: if (timestamp_cmp(retired, kfence->timestamp) >= 0) { MATCH LINES: 3940 3928: 3929: int gen8_hwsched_send_recurring_cmdobj(struct adreno_device *adreno_dev, 3930: struct kgsl_drawobj_cmd *cmdobj) 3931: { 3932: struct adreno_hwsched *hwsched = &adreno_dev->hwsched; 3933: struct kgsl_drawobj *drawobj = DRAWOBJ(cmdobj); 3934: struct hfi_submit_cmd *cmd; 3935: struct kgsl_memobj_node *ib; 3936: u32 cmd_sizebytes; 3937: int ret; 3938: static bool active; 3939: 3940: if (adreno_gpu_halt(adreno_dev) || adreno_gpu_fault(adreno_dev)) 3941: return -EBUSY; 3942: 3943: if (test_bit(CMDOBJ_RECURRING_STOP, &cmdobj->priv)) { 3944: cmdobj->numibs = 0; 3945: } else { 3946: list_for_each_entry(ib, &cmdobj->cmdlist, node) 3947: cmdobj->numibs++; 3948: } 3949: 3950: if (cmdobj->numibs > HWSCHED_MAX_IBS) 3951: return -EINVAL; 3952: 3953: if (cmdobj->numibs > HWSCHED_MAX_DISPATCH_NUMIBS) 3954: cmd_sizebytes = sizeof(*cmd); 3955: else 3956: cmd_sizebytes = sizeof(*cmd) + 3957: (sizeof(struct hfi_issue_ib) * cmdobj->numibs); 3958: 3959: if (WARN_ON(cmd_sizebytes > HFI_MAX_MSG_SIZE)) 3960: return -EMSGSIZE; 3961: 3962: cmd = kzalloc(cmd_sizebytes, GFP_KERNEL); 3963: if (cmd == NULL) 3964: return -ENOMEM; MATCH LINES: 4083, 4085, 4100 4071: if (list_empty(&drawctxt->hw_fence_list)) 4072: return; 4073: 4074: if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 4075: drain_context_hw_fence_gmu(adreno_dev, drawctxt); 4076: else 4077: drain_context_hw_fence_cpu(adreno_dev, drawctxt); 4078: } 4079: 4080: static void trigger_context_unregister_fault(struct adreno_device *adreno_dev, 4081: struct adreno_context *drawctxt) 4082: { 4083: gmu_core_fault_snapshot(KGSL_DEVICE(adreno_dev), GMU_FAULT_CTX_UNREGISTER); 4084: 4085: /* Make sure we send all fences from this context to the TxQueue after recovery */ 4086: move_detached_context_hardware_fences(adreno_dev, drawctxt); 4087: gen8_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT); 4088: } 4089: 4090: int gen8_hwsched_process_detached_hw_fences(struct adreno_device *adreno_dev) 4091: { 4092: struct adreno_hw_fence_entry *entry, *tmp; 4093: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev); 4094: struct kgsl_context *context = NULL; 4095: int ret = 0; 4096: 4097: list_for_each_entry_safe(entry, tmp, &hfi->detached_hw_fence_list, node) { 4098: 4099: /* 4100: * This is part of the reset sequence and any error in this path will be handled by 4101: * the caller. 4102: */ 4103: ret = gen8_send_hw_fence_hfi_wait_ack(adreno_dev, entry, 4104: HW_FENCE_FLAG_SKIP_MEMSTORE); 4105: if (ret) 4106: return ret; 4107: 4108: context = &entry->drawctxt->base; 4109: 4110: adreno_hwsched_remove_hw_fence_entry(adreno_dev, entry); 4111: 4112: kgsl_context_put(context); 4113: } 4114: 4115: return ret; 4116: } 4117: 4118: static int send_context_unregister_hfi(struct adreno_device *adreno_dev, 4119: struct kgsl_context *context, u32 ts) 4120: { 4121: struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)); 4122: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 4123: struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev); 4124: struct adreno_context *drawctxt = ADRENO_CONTEXT(context); MATCH LINES: 4221 4209: adreno_profile_process_results(adreno_dev); 4210: context->gmu_registered = false; 4211: 4212: out: 4213: WARN_RATELIMIT(!list_empty(&drawctxt->hw_fence_list) || 4214: !list_empty(&drawctxt->hw_fence_inflight_list), 4215: "detached ctx:%u has active hw fences\n", 4216: context->id); 4217: 4218: kgsl_mutex_unlock(&device->mutex); 4219: } 4220: 4221: static int handle_hw_fences_after_soft_reset(struct adreno_device *adreno_dev, 4222: struct adreno_context *drawctxt) 4223: { 4224: int ret = 0; 4225: 4226: if (!drawctxt) 4227: return ret; 4228: 4229: ret = gen8_hwsched_process_detached_hw_fences(adreno_dev); 4230: if (ret) 4231: return ret; 4232: 4233: return gen8_hwsched_disable_hw_fence_throttle(adreno_dev); 4234: } 4235: 4236: static int gen8_hwsched_hfi_msg_reply(struct adreno_device *adreno_dev, 4237: enum hfi_msg_type msg, u32 hdr) 4238: { 4239: struct hfi_msg_ret_cmd out = {0}; 4240: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 4241: u32 seqnum; 4242: 4243: out.hdr = ACK_MSG_HDR(msg); 4244: seqnum = atomic_inc_return(&gmu->hfi.seqnum); 4245: out.hdr = MSG_HDR_SET_SEQNUM_SIZE(out.hdr, seqnum, sizeof(out) >> 2); MATCH LINES: 4292, 4300, 4303, 4325, 4330, 4334, 4346, 4353, 4372, 4395, 4396, 4397, 4399, 4400, 4402, 4405 4280: list_for_each_entry_safe(obj, tmp, &hwsched->cmd_list, node) { 4281: struct kgsl_drawobj *drawobj = obj->drawobj; 4282: 4283: /* Raise dispatch interrupt for inflight commands */ 4284: if (adreno_hwsched_drawobj_replay(adreno_dev, drawobj)) 4285: gmu_core_regwrite(KGSL_DEVICE(adreno_dev), GEN8_GMUCX_HOST2GMU_INTR_SET, 4286: DISPQ_IRQ_BIT(get_irq_bit(adreno_dev, drawobj->context))); 4287: else 4288: adreno_hwsched_retire_cmdlist_obj(adreno_dev, obj); 4289: } 4290: } 4291: 4292: int gen8_hwsched_soft_reset(struct adreno_device *adreno_dev, 4293: struct kgsl_context *context, bool ctx_guilty) 4294: { 4295: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 4296: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 4297: struct hfi_context_bad_cmd *in = (struct hfi_context_bad_cmd *)adreno_dev->hwsched.ctxt_bad; 4298: int ret; 4299: 4300: if (!test_bit(ADRENO_HWSCHED_GPU_SOFT_RESET, &adreno_dev->hwsched.flags)) 4301: return -EOPNOTSUPP; 4302: 4303: if (adreno_dev->hwsched.reset_type != GMU_GPU_SOFT_RESET) 4304: return -EINVAL; 4305: 4306: if (!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) 4307: return 0; 4308: 4309: gen8_disable_gpu_irq(adreno_dev); 4310: 4311: /* Halt GX traffic */ 4312: if (adreno_is_gen8_11_x(adreno_dev)) { 4313: /* 4314: * On gen8_11_x targets, RBBM_GBIF_HALT_ACK may be prematurely set. Use the updated 4315: * GX halt / acknowledgment sequence per recommendation. 4316: */ 4317: _do_gbif_halt(device, GEN8_RBBM_GBIF_GX_DBG_HALT_CTRL, 4318: GEN8_RBBM_GBIF_GX_DBG_HALT_STATUS, GEN8_GBIF_GX_HALT_CTRL_MASK, 4319: GEN8_GBIF_GX_HALT_STATUS_MASK, "GX"); 4320: } else { 4321: _do_gbif_halt(device, GEN8_RBBM_GBIF_HALT, GEN8_RBBM_GBIF_HALT_ACK, 4322: GEN8_GBIF_GX_HALT_MASK, GEN8_GBIF_GX_HALT_ACK_MASK, "GX"); 4323: } 4324: 4325: kgsl_regwrite(device, GEN8_RBBM_SW_RESET_CMD, 0x1); 4326: 4327: /* Make sure above writes are posted */ 4328: wmb(); 4329: 4330: /* Allow the software reset to complete */ 4331: udelay(100); 4332: 4333: /* Clear any GPU faults that might have been left over */ 4334: adreno_clear_gpu_fault(adreno_dev); 4335: 4336: /* Clear the busy_data stats - we're starting over from scratch */ 4337: memset(&adreno_dev->busy_data, 0, sizeof(adreno_dev->busy_data)); 4338: 4339: gen8_start(adreno_dev); 4340: 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); 4378: if (ret) 4379: goto done; 4380: 4381: kgsl_sharedmem_writel(device->memstore, 4382: KGSL_MEMSTORE_OFFSET(context->id, soptimestamp), 4383: drawctxt->timestamp); 4384: 4385: kgsl_sharedmem_writel(device->memstore, 4386: KGSL_MEMSTORE_OFFSET(context->id, eoptimestamp), 4387: drawctxt->timestamp); 4388: 4389: adreno_profile_process_results(adreno_dev); 4390: 4391: context->gmu_registered = false; 4392: } 4393: 4394: /* 4395: * At this point it is safe to assume that we recovered. Setting 4396: * this field allows us to take a new snapshot for the next failure 4397: * if we are prioritizing the first unrecoverable snapshot. 4398: */ 4399: if (device->snapshot) 4400: device->snapshot->recovered = true; 4401: 4402: device->reset_counter++; 4403: done: 4404: if (ret) 4405: dev_err(device->dev, "GPU soft reset failed: %d\n", ret); 4406: 4407: return ret; 4408: } 4409: 4410: u32 gen8_hwsched_preempt_count_get(struct adreno_device *adreno_dev) 4411: { 4412: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 4413: int ret, preempt_count = 0; 4414: 4415: ret = gmu_core_get_vrb_register(device->gmu_core.vrb, 4416: VRB_PREEMPT_COUNT_TOTAL, &preempt_count); 4417: if (ret) 4418: return 0; 4419: 4420: if ((preempt_count != 0) || (device->state != KGSL_STATE_ACTIVE)) 4421: return preempt_count; 4422: 4423: return gen8_hwsched_hfi_get_value(adreno_dev, HFI_VALUE_PREEMPT_COUNT, 0); 4424: } 4425: 4426: void gen8_hwsched_context_destroy(struct adreno_device *adreno_dev, 4427: struct adreno_context *drawctxt) 4428: { 4429: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); MATCH LINES: 4460 4448: spin_lock(&hwf->lock); 4449: 4450: drawctxt = hwf->defer_drawctxt; 4451: ts = hwf->defer_ts; 4452: 4453: spin_unlock(&hwf->lock); 4454: 4455: if (!drawctxt) 4456: goto done; 4457: 4458: ret = process_hw_fence_deferred_ctxt(adreno_dev, drawctxt, ts); 4459: if (ret) { 4460: /* the deferred drawctxt will be handled post fault recovery */ 4461: gen8_hwsched_fault(adreno_dev, GMU_FAULT_HW_FENCE); 4462: return ret; 4463: } 4464: 4465: kgsl_context_put(&drawctxt->base); 4466: adreno_active_count_put(adreno_dev); 4467: 4468: done: 4469: _disable_hw_fence_throttle(adreno_dev, true); 4470: 4471: return ret; 4472: } 4473: 4474: int gen8_hwsched_set_dcvs_profile(struct adreno_device *adreno_dev, 4475: struct kgsl_process_private *proc_priv) 4476: { 4477: struct hfi_profile_register cmd = {0}; 4478: struct hfi_msg_platform msg = {0}; 4479: struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev); 4480: struct kgsl_memdesc md = proc_priv->profile.md; 4481: int ret; 4482: 4483: /* Only send HFI if device is not in SLUMBER */ 4484: if (!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) --- FILE: \adreno_gen8_hwsched_hfi.h | HITS: 9 --- MATCH LINES: 20, 32, 37 8: #define _ADRENO_GEN8_HWSCHED_HFI_H_ 9: 10: /* Maximum number of IBs in a submission */ 11: #define HWSCHED_MAX_NUMIBS \ 12: ((HFI_MAX_MSG_SIZE - offsetof(struct hfi_issue_cmd_cmd, ibs)) \ 13: / sizeof(struct hfi_issue_ib)) 14: 15: /* 16: * This is used to put userspace threads to sleep when hardware fence unack count reaches a 17: * threshold. This bit is cleared in two scenarios: 18: * 1. If the hardware fence unack count drops to a desired threshold. 19: * 2. If there is a GMU/GPU fault. Because we don't want the threads to keep sleeping through fault 20: * recovery, which can easily take 100s of milliseconds to complete. 21: */ 22: #define GEN8_HWSCHED_HW_FENCE_SLEEP_BIT 0x0 23: 24: /* 25: * This is used to avoid creating any more hardware fences until the hardware fence unack count 26: * drops to a desired threshold. This bit is required in cases where GEN8_HWSCHED_HW_FENCE_SLEEP_BIT 27: * will be cleared, but we still want to avoid creating any more hardware fences. For example, if 28: * hardware fence unack count reaches a maximum threshold, both GEN8_HWSCHED_HW_FENCE_SLEEP_BIT and 29: * GEN8_HWSCHED_HW_FENCE_MAX_BIT will be set. Say, a GMU/GPU fault happens and 30: * GEN8_HWSCHED_HW_FENCE_SLEEP_BIT will be cleared to wake up any sleeping threads. But, 31: * GEN8_HWSCHED_HW_FENCE_MAX_BIT will remain set to avoid creating any new hardware fences until 32: * recovery is complete and deferred drawctxt (if any) is handled. 33: */ 34: #define GEN8_HWSCHED_HW_FENCE_MAX_BIT 0x1 35: 36: /* 37: * This is used to avoid creating any more hardware fences until concurrent reset/recovery completes 38: * or when soccp vote fails 39: */ 40: #define GEN8_HWSCHED_HW_FENCE_ABORT_BIT 0x2 41: 42: #define MAX_THROTTLE_LVLS 3 43: struct hfi_tsens_cfg { 44: /** @limit_u: deci-C value for upper trigger point */ 45: u32 limit_u; 46: /** @limit_l: deci-C value for lower trigger point */ 47: u32 limit_l; 48: /** @margin_u: deci-C value for upper trigger intercept margin */ 49: u32 margin_u; 50: /** @margin_l: deci-C value for lower trigger intercept margin */ 51: u32 margin_l; 52: } __packed; 53: 54: struct hfi_tsens_throttle_param { 55: /** @throttle_hyst: Microsecond wait between each throttle level */ 56: u32 throttle_hyst; 57: /** @num_throttle_cnt: Number of entries in throttle_levels */ 58: u32 num_throttle_cnt; 59: /** @throttle_lvls: Percent of original clock to throttle per level */ 60: u32 throttle_lvls[MAX_THROTTLE_LVLS]; 61: } __packed; MATCH LINES: 218, 225 206: struct kgsl_drawobj *drawobj); 207: 208: /** 209: * gen8_hwsched_context_detach - Unregister a context with GMU 210: * @drawctxt: Pointer to the adreno context 211: * 212: * This function sends context unregister HFI and waits for the ack 213: * to ensure all submissions from this context have retired 214: */ 215: void gen8_hwsched_context_detach(struct adreno_context *drawctxt); 216: 217: /** 218: * gen8_hwsched_soft_reset - Do a soft reset of the GPU hardware 219: * @adreno_dev: Pointer to adreno device structure 220: * @context: Pointer to the KGSL context 221: * @ctx_guilty: Set to true if context is invalidated on the fault 222: * 223: * Return: 0 on success and negative error on failure 224: */ 225: int gen8_hwsched_soft_reset(struct adreno_device *adreno_dev, 226: struct kgsl_context *context, bool ctx_guilty); 227: 228: /* Helper function to get to gen8 hwsched hfi device from adreno device */ 229: struct gen8_hwsched_hfi *to_gen8_hwsched_hfi(struct adreno_device *adreno_dev); 230: 231: /** 232: * gen8_hwsched_preempt_count_get - Get preemption count from GMU 233: * @adreno_dev: Pointer to adreno device 234: * 235: * This function sends a GET_VALUE HFI packet to get the number of 236: * preemptions completed since last SLUMBER exit. 237: * 238: * Return: Preemption count 239: */ 240: u32 gen8_hwsched_preempt_count_get(struct adreno_device *adreno_dev); 241: 242: /** 243: * gen8_hwsched_lpac_cp_init - Send CP_INIT to LPAC via HFI 244: * @adreno_dev: Pointer to adreno device structure 245: * 246: * This function is used to send CP INIT packet to LPAC and 247: * enable submission to LPAC queue. 248: * 249: * Return: 0 on success and negative error on failure. MATCH LINES: 345, 348, 349, 368 333: * @adreno_dev: Pointer to adreno device 334: * @drawctxt: Pointer to the adreno context which is to be flushed 335: * 336: * Check if all hardware fences from this context have been sent to the 337: * TxQueue. If not, log an error and return error code. 338: * 339: * Return: Zero on success or negative error on failure 340: */ 341: int gen8_hwsched_check_context_inflight_hw_fences(struct adreno_device *adreno_dev, 342: struct adreno_context *drawctxt); 343: 344: /** 345: * gen8_hwsched_disable_hw_fence_throttle - Disable hardware fence throttling after reset 346: * @adreno_dev: pointer to the adreno device 347: * 348: * After device reset, clear hardware fence related data structures and send any hardware fences 349: * that got deferred (prior to reset) and re-open the gates for hardware fence creation 350: * 351: * Return: Zero on success or negative error on failure 352: */ 353: int gen8_hwsched_disable_hw_fence_throttle(struct adreno_device *adreno_dev); 354: 355: /** 356: * gen8_hwsched_process_msgq - Process msgq 357: * @adreno_dev: pointer to the adreno device 358: * 359: * This function grabs the msgq mutex and processes msgq for any outstanding hfi packets 360: */ 361: void gen8_hwsched_process_msgq(struct adreno_device *adreno_dev); 362: 363: /** 364: * gen8_hwsched_boot_gpu - Send the command to boot GPU 365: * @adreno_dev: Pointer to adreno device 366: * 367: * Send the hfi to boot GPU, and check the ack, incase of a failure 368: * get a snapshot and capture registers of interest. 369: * 370: * Return: Zero on success or negative error on failure 371: */ 372: int gen8_hwsched_boot_gpu(struct adreno_device *adreno_dev); 373: 374: /** 375: * gen8_hwsched_set_gmu_based_dcvs_value - Set value for GMU based DCVS 376: * @adreno_dev: pointer to the adreno device 377: * @type: Type of HFI for set value 378: * @subtype: Sub type of HFI 379: * @val: Value to set 380: * @default_vote: True if this is a bootup default vote 381: * 382: * Return: Zero on success or negative error on failure 383: */ 384: int gen8_hwsched_set_gmu_based_dcvs_value(struct adreno_device *adreno_dev, u32 type, 385: u32 subtype, u32 val, bool default_vote); 386: 387: /** 388: * gen8_hwsched_set_dcvs_profile - Set profile for GMU based DCVS 389: * @adreno_dev: Pointer to the adreno device 390: * @proc_priv: Pointer to process private 391: * 392: * This function sends PROFILE_REGISTER hfi to set DCVS profile to GMU, --- FILE: \adreno_gen8_preempt.c | HITS: 15 --- MATCH LINES: 19, 40, 49, 53, 60, 62, 64, 84 7: #include "adreno.h" 8: #include "adreno_gen8.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 gen8_cp_preemption_record, _field) 15: 16: #define PREEMPT_SMMU_RECORD(_field) \ 17: offsetof(struct gen8_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 = gen8_fenced_write(adreno_dev, 37: GEN8_CP_RB_WPTR_GC, rb->wptr, 38: FENCE_STATUS_WRITEDROPPED0_MASK); 39: 40: reset_timer = true; 41: rb->skip_inline_wptr = false; 42: } 43: } else { 44: u32 wptr; 45: 46: kgsl_regread(device, GEN8_CP_RB_WPTR_GC, &wptr); 47: if (wptr != rb->wptr) { 48: kgsl_regwrite(device, GEN8_CP_RB_WPTR_GC, 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: 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, 99: adreno_get_rptr(adreno_dev->next_rb), 100: adreno_dev->next_rb->wptr); 101: 102: /* Set a fault and restart */ 103: adreno_scheduler_fault(adreno_dev, ADRENO_PREEMPT_FAULT); 104: 105: return; 106: } 107: 108: adreno_dev->preempt.count++; MATCH LINES: 382, 384, 386 370: gen8_core->qos_value[next->id]); 371: 372: /* Trigger the preemption */ 373: if (gen8_fenced_write(adreno_dev, GEN8_CP_CONTEXT_SWITCH_CNTL, cntl, 374: FENCE_STATUS_WRITEDROPPED1_MASK)) { 375: adreno_dev->next_rb = NULL; 376: kgsl_delete_timer(&adreno_dev->preempt.timer); 377: goto err; 378: } 379: 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); MATCH LINES: 651, 670, 679 639: kgsl_sharedmem_writel(rb->preemption_desc, 640: PREEMPT_RECORD(rptr), 0); 641: kgsl_sharedmem_writel(rb->preemption_desc, 642: PREEMPT_RECORD(wptr), 0); 643: 644: adreno_ringbuffer_set_pagetable(device, rb, 645: device->mmu.defaultpagetable); 646: 647: clear_bit(ADRENO_RB_SET_PSEUDO_DONE, &rb->flags); 648: } 649: } 650: 651: static void reset_rb_preempt_record(struct adreno_device *adreno_dev, 652: struct adreno_ringbuffer *rb) 653: { 654: memset(rb->preemption_desc->hostptr, 0x0, rb->preemption_desc->size); 655: 656: kgsl_sharedmem_writel(rb->preemption_desc, 657: PREEMPT_RECORD(magic), GEN8_CP_CTXRECORD_MAGIC_REF); 658: kgsl_sharedmem_writel(rb->preemption_desc, 659: PREEMPT_RECORD(cntl), GEN8_CP_RB_CNTL_DEFAULT); 660: kgsl_sharedmem_writeq(rb->preemption_desc, 661: PREEMPT_RECORD(rptr_addr), SCRATCH_RB_GPU_ADDR( 662: KGSL_DEVICE(adreno_dev), rb->id, rptr)); 663: kgsl_sharedmem_writeq(rb->preemption_desc, 664: PREEMPT_RECORD(rbase), rb->buffer_desc->gpuaddr); 665: kgsl_sharedmem_writeq(rb->preemption_desc, 666: PREEMPT_RECORD(bv_rptr_addr), SCRATCH_RB_GPU_ADDR( 667: KGSL_DEVICE(adreno_dev), rb->id, bv_rptr)); 668: } 669: 670: void gen8_reset_preempt_records(struct adreno_device *adreno_dev) 671: { 672: int i; 673: struct adreno_ringbuffer *rb; 674: 675: if (!adreno_is_preemption_enabled(adreno_dev)) 676: return; 677: 678: FOR_EACH_RINGBUFFER(adreno_dev, rb, i) { 679: reset_rb_preempt_record(adreno_dev, rb); 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: MATCH LINES: 720 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"); 717: if (ret) 718: return ret; 719: 720: reset_rb_preempt_record(adreno_dev, rb); 721: 722: return 0; 723: } 724: 725: int gen8_preemption_init(struct adreno_device *adreno_dev) 726: { 727: u32 flags = ADRENO_FEATURE(adreno_dev, ADRENO_APRIV) ? KGSL_MEMDESC_PRIVILEGED : 0; 728: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 729: struct kgsl_iommu *iommu = KGSL_IOMMU(device); 730: struct adreno_preemption *preempt = &adreno_dev->preempt; 731: struct adreno_ringbuffer *rb; 732: int ret; 733: u32 i; 734: 735: /* We are dependent on IOMMU to make preemption go on the CP side */ 736: if (kgsl_mmu_get_mmutype(device) != KGSL_MMU_TYPE_IOMMU) { 737: ret = -ENODEV; 738: goto done; 739: } 740: 741: INIT_WORK(&preempt->work, _gen8_preemption_worker); 742: 743: /* Allocate mem for storing preemption switch record */ 744: FOR_EACH_RINGBUFFER(adreno_dev, rb, i) { --- FILE: \adreno_gen8_ringbuffer.c | HITS: 10 --- MATCH LINES: 73, 74, 75 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) { MATCH LINES: 126 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); MATCH LINES: 205, 206, 208, 210 193: rb->skip_inline_wptr = false; 194: } 195: } else { 196: if (adreno_dev->cur_rb == rb) 197: rb->skip_inline_wptr = true; 198: } 199: 200: rb->wptr = rb->_wptr; 201: spin_unlock_irqrestore(&rb->preempt_lock, flags); 202: 203: if (ret) { 204: /* 205: * If WPTR update fails, take inline snapshot and trigger 206: * recovery. 207: */ 208: gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE); 209: adreno_scheduler_fault(adreno_dev, 210: ADRENO_GMU_FAULT_SKIP_SNAPSHOT); 211: } 212: 213: return ret; 214: } 215: 216: int gen8_ringbuffer_init(struct adreno_device *adreno_dev) 217: { 218: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 219: int i, ret; 220: 221: ret = adreno_allocate_global(device, &device->scratch, PAGE_SIZE, 222: 0, 0, KGSL_MEMDESC_RANDOM | KGSL_MEMDESC_PRIVILEGED, 223: "scratch"); 224: if (ret) 225: return ret; 226: 227: adreno_dev->cur_rb = &(adreno_dev->ringbuffers[0]); 228: 229: if (!adreno_preemption_feature_set(adreno_dev)) { 230: adreno_dev->num_ringbuffers = 1; 231: return adreno_ringbuffer_setup(adreno_dev, 232: &adreno_dev->ringbuffers[0], 0); 233: } 234: MATCH LINES: 266 254: u32 flags, u32 *in, u32 dwords, u32 timestamp, 255: struct adreno_submit_time *time) 256: { 257: struct kgsl_device *device = KGSL_DEVICE(adreno_dev); 258: u32 size = GEN8_SUBMIT_MAX + dwords; 259: u32 *cmds, index = 0; 260: u64 profile_gpuaddr; 261: u32 profile_dwords; 262: 263: if (adreno_drawctxt_detached(drawctxt)) 264: return -ENOENT; 265: 266: if (adreno_gpu_fault(adreno_dev) != 0) 267: return -EPROTO; 268: 269: rb->timestamp++; 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; MATCH LINES: 353 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 --- FILE: \adreno_gen8_snapshot.c | HITS: 279 --- MATCH LINES: 8, 9, 10, 11, 12, 13, 14, 15, 16, 21, 27, 58, 90, 121, 152, 183, 214, 245 1: // SPDX-License-Identifier: GPL-2.0-only 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 "adreno.h" 8: #include "adreno_gen8_0_0_snapshot.h" 9: #include "adreno_gen8_1_0_snapshot.h" 10: #include "adreno_gen8_10_0_snapshot.h" 11: #include "adreno_gen8_2_0_snapshot.h" 12: #include "adreno_gen8_3_0_snapshot.h" 13: #include "adreno_gen8_6_0_snapshot.h" 14: #include "adreno_gen8_9_0_snapshot.h" 15: #include "adreno_gen8_11_0_snapshot.h" 16: #include "adreno_snapshot.h" 17: 18: static struct kgsl_memdesc *gen8_capturescript; 19: static struct kgsl_memdesc *gen8_crashdump_registers; 20: static u32 *gen8_cd_reg_end; 21: static const struct gen8_snapshot_block_list *gen8_snapshot_block_list; 22: static bool gen8_crashdump_timedout; 23: 24: /* Starting kernel virtual address for QDSS TMC register block */ 25: static void __iomem *tmc_virt; 26: 27: const struct gen8_snapshot_block_list gen8_0_0_snapshot_block_list = { 28: .pre_crashdumper_regs = gen8_0_0_ahb_registers, 29: .num_pre_crashdumper_regs = ARRAY_SIZE(gen8_0_0_ahb_registers), 30: .debugbus_blocks = gen8_debugbus_blocks, 31: .debugbus_blocks_len = ARRAY_SIZE(gen8_debugbus_blocks), 32: .gbif_debugbus_blocks = gen8_gbif_debugbus_blocks, 33: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen8_gbif_debugbus_blocks), 34: .cx_debugbus_blocks = gen8_cx_debugbus_blocks, 35: .cx_debugbus_blocks_len = ARRAY_SIZE(gen8_cx_debugbus_blocks), 36: .external_core_regs = gen8_0_0_external_core_regs, 37: .num_external_core_regs = ARRAY_SIZE(gen8_0_0_external_core_regs), 38: .gmu_cx_unsliced_regs = gen8_0_0_gmu_registers, 39: .gmu_gx_regs = gen8_gmu_gx_registers, 40: .num_gmu_gx_regs = ARRAY_SIZE(gen8_gmu_gx_registers), 41: .rscc_regs = gen8_0_0_rscc_rsc_registers, 42: .reg_list = gen8_0_0_reg_list, 43: .cx_misc_regs = gen8_0_0_cx_misc_registers, 44: .shader_blocks = gen8_0_0_shader_blocks, 45: .num_shader_blocks = ARRAY_SIZE(gen8_0_0_shader_blocks), 46: .cp_clusters = gen8_0_0_cp_clusters, 47: .num_cp_clusters = ARRAY_SIZE(gen8_0_0_cp_clusters), 48: .clusters = gen8_0_0_mvc_clusters, 49: .num_clusters = ARRAY_SIZE(gen8_0_0_mvc_clusters), 50: .sptp_clusters = gen8_0_0_sptp_clusters, 51: .num_sptp_clusters = ARRAY_SIZE(gen8_0_0_sptp_clusters), 52: .index_registers = gen8_0_0_cp_indexed_reg_list, 53: .index_registers_len = ARRAY_SIZE(gen8_0_0_cp_indexed_reg_list), 54: .mempool_index_registers = gen8_0_0_cp_mempool_reg_list, 55: .mempool_index_registers_len = ARRAY_SIZE(gen8_0_0_cp_mempool_reg_list), 56: }; 57: 58: const struct gen8_snapshot_block_list gen8_1_0_snapshot_block_list = { 59: .pre_crashdumper_regs = gen8_1_0_ahb_registers, 60: .num_pre_crashdumper_regs = ARRAY_SIZE(gen8_1_0_ahb_registers), 61: .debugbus_blocks = gen8_1_0_debugbus_blocks, 62: .debugbus_blocks_len = ARRAY_SIZE(gen8_1_0_debugbus_blocks), 63: /* GBIF_GX is included in gen8_1_0_debugbus_blocks per data file */ 64: .gbif_debugbus_blocks = gen8_1_0_gbif_debugbus_blocks, 65: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen8_1_0_gbif_debugbus_blocks), 66: .cx_debugbus_blocks = gen8_cx_debugbus_blocks, 67: .cx_debugbus_blocks_len = ARRAY_SIZE(gen8_cx_debugbus_blocks), 68: .external_core_regs = gen8_1_0_external_core_regs, 69: .num_external_core_regs = ARRAY_SIZE(gen8_1_0_external_core_regs), 70: .gmu_cx_unsliced_regs = gen8_1_0_gmucx_registers, 71: .gmu_gx_regs = gen8_1_0_gmu_gx_registers, 72: .num_gmu_gx_regs = ARRAY_SIZE(gen8_1_0_gmu_gx_registers), 73: .rscc_regs = gen8_2_0_rscc_rsc_registers, 74: .reg_list = gen8_1_0_misc_registers, 75: .cx_misc_regs = gen8_1_0_cx_misc_registers, 76: .shader_blocks = gen8_1_0_shader_blocks, 77: .num_shader_blocks = ARRAY_SIZE(gen8_1_0_shader_blocks), 78: .cp_clusters = gen8_1_0_cp_clusters, 79: .num_cp_clusters = ARRAY_SIZE(gen8_1_0_cp_clusters), 80: .clusters = gen8_1_0_mvc_clusters, 81: .num_clusters = ARRAY_SIZE(gen8_1_0_mvc_clusters), 82: .sptp_clusters = gen8_1_0_sptp_clusters, 83: .num_sptp_clusters = ARRAY_SIZE(gen8_1_0_sptp_clusters), 84: .index_registers = gen8_1_0_cp_indexed_reg_list, 85: .index_registers_len = ARRAY_SIZE(gen8_1_0_cp_indexed_reg_list), 86: .mempool_index_registers = gen8_2_0_cp_mempool_reg_list, 87: .mempool_index_registers_len = ARRAY_SIZE(gen8_2_0_cp_mempool_reg_list), 88: }; 89: 90: const struct gen8_snapshot_block_list gen8_10_0_snapshot_block_list = { 91: .pre_crashdumper_regs = gen8_1_0_ahb_registers, 92: .num_pre_crashdumper_regs = ARRAY_SIZE(gen8_1_0_ahb_registers), 93: .debugbus_blocks = gen8_10_0_debugbus_blocks, 94: .debugbus_blocks_len = ARRAY_SIZE(gen8_10_0_debugbus_blocks), 95: .gbif_debugbus_blocks = gen8_1_0_gbif_debugbus_blocks, 96: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen8_1_0_gbif_debugbus_blocks), 97: .cx_debugbus_blocks = gen8_cx_debugbus_blocks, 98: .cx_debugbus_blocks_len = ARRAY_SIZE(gen8_cx_debugbus_blocks), 99: .external_core_regs = gen8_1_0_external_core_regs, 100: .num_external_core_regs = ARRAY_SIZE(gen8_1_0_external_core_regs), 101: .gmu_cx_unsliced_regs = gen8_1_0_gmucx_registers, 102: .gmu_gx_regs = gen8_1_0_gmu_gx_registers, 103: .num_gmu_gx_regs = ARRAY_SIZE(gen8_1_0_gmu_gx_registers), 104: .rscc_regs = gen8_2_0_rscc_rsc_registers, 105: .reg_list = gen8_1_0_misc_registers, 106: .cx_misc_regs = gen8_1_0_cx_misc_registers, 107: .shader_blocks = gen8_1_0_shader_blocks, 108: .num_shader_blocks = ARRAY_SIZE(gen8_1_0_shader_blocks), 109: .cp_clusters = gen8_1_0_cp_clusters, 110: .num_cp_clusters = ARRAY_SIZE(gen8_1_0_cp_clusters), 111: .clusters = gen8_1_0_mvc_clusters, 112: .num_clusters = ARRAY_SIZE(gen8_1_0_mvc_clusters), 113: .sptp_clusters = gen8_1_0_sptp_clusters, 114: .num_sptp_clusters = ARRAY_SIZE(gen8_1_0_sptp_clusters), 115: .index_registers = gen8_1_0_cp_indexed_reg_list, 116: .index_registers_len = ARRAY_SIZE(gen8_1_0_cp_indexed_reg_list), 117: .mempool_index_registers = gen8_2_0_cp_mempool_reg_list, 118: .mempool_index_registers_len = ARRAY_SIZE(gen8_2_0_cp_mempool_reg_list), 119: }; 120: 121: const struct gen8_snapshot_block_list gen8_2_0_snapshot_block_list = { 122: .pre_crashdumper_regs = gen8_2_0_ahb_registers, 123: .num_pre_crashdumper_regs = ARRAY_SIZE(gen8_2_0_ahb_registers), 124: .debugbus_blocks = gen8_2_0_debugbus_blocks, 125: .debugbus_blocks_len = ARRAY_SIZE(gen8_2_0_debugbus_blocks), 126: .gbif_debugbus_blocks = gen8_gbif_debugbus_blocks, 127: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen8_gbif_debugbus_blocks), 128: .cx_debugbus_blocks = gen8_cx_debugbus_blocks, 129: .cx_debugbus_blocks_len = ARRAY_SIZE(gen8_cx_debugbus_blocks), 130: .external_core_regs = gen8_2_0_external_core_regs, 131: .num_external_core_regs = ARRAY_SIZE(gen8_2_0_external_core_regs), 132: .gmu_cx_unsliced_regs = gen8_2_0_gmucx_registers, 133: .gmu_gx_regs = gen8_2_0_gmu_gx_registers, 134: .num_gmu_gx_regs = ARRAY_SIZE(gen8_2_0_gmu_gx_registers), 135: .rscc_regs = gen8_2_0_rscc_rsc_registers, 136: .reg_list = gen8_2_0_misc_registers, 137: .cx_misc_regs = gen8_2_0_cx_misc_registers, 138: .shader_blocks = gen8_2_0_shader_blocks, 139: .num_shader_blocks = ARRAY_SIZE(gen8_2_0_shader_blocks), 140: .cp_clusters = gen8_2_0_cp_clusters, 141: .num_cp_clusters = ARRAY_SIZE(gen8_2_0_cp_clusters), 142: .clusters = gen8_2_0_mvc_clusters, 143: .num_clusters = ARRAY_SIZE(gen8_2_0_mvc_clusters), 144: .sptp_clusters = gen8_2_0_sptp_clusters, 145: .num_sptp_clusters = ARRAY_SIZE(gen8_2_0_sptp_clusters), 146: .index_registers = gen8_2_0_cp_indexed_reg_list, 147: .index_registers_len = ARRAY_SIZE(gen8_2_0_cp_indexed_reg_list), 148: .mempool_index_registers = gen8_2_0_cp_mempool_reg_list, 149: .mempool_index_registers_len = ARRAY_SIZE(gen8_2_0_cp_mempool_reg_list), 150: }; 151: 152: const struct gen8_snapshot_block_list gen8_3_0_snapshot_block_list = { 153: .pre_crashdumper_regs = gen8_0_0_ahb_registers, 154: .num_pre_crashdumper_regs = ARRAY_SIZE(gen8_0_0_ahb_registers), 155: .debugbus_blocks = gen8_3_0_debugbus_blocks, 156: .debugbus_blocks_len = ARRAY_SIZE(gen8_3_0_debugbus_blocks), 157: .gbif_debugbus_blocks = gen8_gbif_debugbus_blocks, 158: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen8_gbif_debugbus_blocks), 159: .cx_debugbus_blocks = gen8_cx_debugbus_blocks, 160: .cx_debugbus_blocks_len = ARRAY_SIZE(gen8_cx_debugbus_blocks), 161: .external_core_regs = gen8_3_0_external_core_regs, 162: .num_external_core_regs = ARRAY_SIZE(gen8_3_0_external_core_regs), 163: .gmu_cx_unsliced_regs = gen8_3_0_gmu_registers, 164: .gmu_gx_regs = gen8_3_0_gmu_gx_regs, 165: .num_gmu_gx_regs = ARRAY_SIZE(gen8_3_0_gmu_gx_regs), 166: .rscc_regs = gen8_3_0_rscc_rsc_registers, 167: .reg_list = gen8_0_0_reg_list, 168: .cx_misc_regs = gen8_0_0_cx_misc_registers, 169: .shader_blocks = gen8_3_0_shader_blocks, 170: .num_shader_blocks = ARRAY_SIZE(gen8_3_0_shader_blocks), 171: .cp_clusters = gen8_3_0_cp_clusters, 172: .num_cp_clusters = ARRAY_SIZE(gen8_3_0_cp_clusters), 173: .clusters = gen8_3_0_mvc_clusters, 174: .num_clusters = ARRAY_SIZE(gen8_3_0_mvc_clusters), 175: .sptp_clusters = gen8_3_0_sptp_clusters, 176: .num_sptp_clusters = ARRAY_SIZE(gen8_3_0_sptp_clusters), 177: .index_registers = gen8_3_0_cp_indexed_reg_list, 178: .index_registers_len = ARRAY_SIZE(gen8_3_0_cp_indexed_reg_list), 179: .mempool_index_registers = gen8_0_0_cp_mempool_reg_list, 180: .mempool_index_registers_len = ARRAY_SIZE(gen8_0_0_cp_mempool_reg_list), 181: }; 182: 183: const struct gen8_snapshot_block_list gen8_6_0_snapshot_block_list = { 184: .pre_crashdumper_regs = gen8_0_0_ahb_registers, 185: .num_pre_crashdumper_regs = ARRAY_SIZE(gen8_0_0_ahb_registers), 186: .debugbus_blocks = gen8_6_0_debugbus_blocks, 187: .debugbus_blocks_len = ARRAY_SIZE(gen8_6_0_debugbus_blocks), 188: .gbif_debugbus_blocks = gen8_gbif_debugbus_blocks, 189: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen8_gbif_debugbus_blocks), 190: .cx_debugbus_blocks = gen8_cx_debugbus_blocks, 191: .cx_debugbus_blocks_len = ARRAY_SIZE(gen8_cx_debugbus_blocks), 192: .external_core_regs = gen8_6_0_external_core_regs, 193: .num_external_core_regs = ARRAY_SIZE(gen8_6_0_external_core_regs), 194: .gmu_cx_unsliced_regs = gen8_6_0_gmu_registers, 195: .gmu_gx_regs = gen8_6_0_gmu_gx_registers, 196: .num_gmu_gx_regs = ARRAY_SIZE(gen8_6_0_gmu_gx_registers), 197: .rscc_regs = gen8_0_0_rscc_rsc_registers, 198: .reg_list = gen8_6_0_reg_list, 199: .cx_misc_regs = gen8_0_0_cx_misc_registers, 200: .shader_blocks = gen8_6_0_shader_blocks, 201: .num_shader_blocks = ARRAY_SIZE(gen8_0_0_shader_blocks), 202: .cp_clusters = gen8_0_0_cp_clusters, 203: .num_cp_clusters = ARRAY_SIZE(gen8_0_0_cp_clusters), 204: .clusters = gen8_6_0_mvc_clusters, 205: .num_clusters = ARRAY_SIZE(gen8_6_0_mvc_clusters), 206: .sptp_clusters = gen8_0_0_sptp_clusters, 207: .num_sptp_clusters = ARRAY_SIZE(gen8_0_0_sptp_clusters), 208: .index_registers = gen8_0_0_cp_indexed_reg_list, 209: .index_registers_len = ARRAY_SIZE(gen8_0_0_cp_indexed_reg_list), 210: .mempool_index_registers = gen8_0_0_cp_mempool_reg_list, 211: .mempool_index_registers_len = ARRAY_SIZE(gen8_0_0_cp_mempool_reg_list), 212: }; 213: 214: const struct gen8_snapshot_block_list gen8_9_0_snapshot_block_list = { 215: .pre_crashdumper_regs = gen8_2_0_ahb_registers, 216: .num_pre_crashdumper_regs = ARRAY_SIZE(gen8_2_0_ahb_registers), 217: .debugbus_blocks = gen8_9_0_debugbus_blocks, 218: .debugbus_blocks_len = ARRAY_SIZE(gen8_9_0_debugbus_blocks), 219: .gbif_debugbus_blocks = gen8_gbif_debugbus_blocks, 220: .gbif_debugbus_blocks_len = ARRAY_SIZE(gen8_gbif_debugbus_blocks), 221: .cx_debugbus_blocks = gen8_cx_debugbus_blocks, 222: .cx_debugbus_blocks_len = ARRAY_SIZE(gen8_cx_debugbus_blocks), 223: .external_core_regs = gen8_9_0_external_core_regs, 224: .num_external_core_regs = ARRAY_SIZE(gen8_9_0_external_core_regs), 225: .gmu_cx_unsliced_regs = gen8_2_0_gmucx_registers, 226: .gmu_gx_regs = gen8_2_0_gmu_gx_registers, 227: .num_gmu_gx_regs = ARRAY_SIZE(gen8_2_0_gmu_gx_registers), 228: .rscc_regs = gen8_2_0_rscc_rsc_registers, 229: .reg_list = gen8_2_0_misc_registers, 230: .cx_misc_regs = gen8_2_0_cx_misc_registers, 231: .shader_blocks