	if (rc)
		return 0;

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
	cmd.type = prop;
	cmd.subtype = 0;

	add_waiter(hfi, cmd.hdr, &pending_ack);

	rc = gen7_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
	if (rc)
		goto done;

	rc = adreno_hwsched_wait_ack_completion(adreno_dev, gmu_pdev_dev, &pending_ack,
		gen7_hwsched_process_msgq);

done:
	del_waiter(hfi, &pending_ack);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1803 [MATCH: pending_cmd] ---
		if (gen7_hfi_send_get_value(adreno_dev, HFI_VALUE_CONTEXT_QUEUE, 0) == 1) {
			set_bit(ADRENO_HWSCHED_CONTEXT_QUEUE, &adreno_dev->hwsched.flags);
			adreno_hwsched_register_hw_fence(adreno_dev);
		}
	}
}

int gen7_hwsched_hfi_set_value(struct adreno_device *adreno_dev, u32 type, u32 subtype, u32 data)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
	struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev);
	struct pending_cmd pending_ack;
	int rc;
	u32 seqnum;
	struct hfi_set_value_cmd cmd = {
		.type = type,
		.subtype = subtype,
		.data = data,
	};

	rc = CMD_MSG_HDR(cmd, H2F_MSG_SET_VALUE);
	if (rc)
		return 0;

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);

	add_waiter(hfi, cmd.hdr, &pending_ack);

	rc = gen7_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
	if (rc)
		goto done;

	rc = adreno_hwsched_wait_ack_completion(adreno_dev, GMU_PDEV_DEV(device),
			&pending_ack, gen7_hwsched_process_msgq);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1918 [MATCH: pending_cmd] ---
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gmu_core_device *gmu_core = &device->gmu_core;

	if (gmu_core->warmboot_enabled && test_bit(GMU_PRIV_WARMBOOT_GMU_INIT_DONE, &gmu->flags)
		&& test_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags) &&
		!test_bit(GMU_FORCE_COLDBOOT, &device->gmu_core.flags))
		return true;

	return false;
}

static int gen7_hwsched_hfi_send_warmboot_cmd(struct adreno_device *adreno_dev,
		struct kgsl_memdesc *desc, u32 flag, bool async, struct pending_cmd *ack)
{
	struct hfi_warmboot_scratch_cmd cmd = {0};
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gmu_core_device *gmu_core = &device->gmu_core;
	int ret;

	if (!gmu_core->warmboot_enabled)
		return 0;

	cmd.scratch_addr = desc->gmuaddr;
	cmd.scratch_size =  desc->size;
	cmd.flags = flag;

	ret = CMD_MSG_HDR(cmd, H2F_MSG_WARMBOOT_CMD);
	if (ret)
		return ret;

	if (async)
		return gen7_hfi_send_cmd_async(adreno_dev, &cmd, sizeof(cmd));

	return gen7_hfi_send_generic_req_v5(adreno_dev, &cmd, ack, sizeof(cmd));
}

static int gen7_hwsched_hfi_warmboot_gpu_cmd(struct adreno_device *adreno_dev,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:2022 [MATCH: pending_cmd] ---
	/* Clear the bit on error so that in the next slumber exit we coldboot */
	clear_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags);
	gen7_disable_gpu_irq(adreno_dev);
	return ret;
}

static int gen7_hwsched_coldboot_gpu(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gmu_core_device *gmu_core = &device->gmu_core;
	struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
	struct gen7_hfi *hfi = to_gen7_hfi(adreno_dev);
	struct pending_cmd ack = {0};
	int ret = 0;

	ret = gen7_hwsched_hfi_send_warmboot_cmd(adreno_dev, gmu->gpu_boot_scratch,
		 HFI_WARMBOOT_SET_SCRATCH, true, &ack);
	if (ret)
		goto done;

	ret = gen7_hwsched_cp_init(adreno_dev);
	if (ret)
		goto done;

	ret = gen7_hwsched_lpac_cp_init(adreno_dev);
	if (ret)
		goto done;

	ret = gen7_hwsched_hfi_send_warmboot_cmd(adreno_dev, gmu->gpu_boot_scratch,
		HFI_WARMBOOT_QUERY_SCRATCH, true, &ack);
	if (ret)
		goto done;

	if (gmu_core->warmboot_enabled)
		set_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags);

done:

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:2068 [MATCH: pending_cmd] ---
int gen7_hwsched_boot_gpu(struct adreno_device *adreno_dev)
{
	/* If warmboot is possible just send the warmboot command else coldboot */
	if (gen7_hwsched_warmboot_possible(adreno_dev))
		return gen7_hwsched_warmboot_gpu(adreno_dev);
	else
		return gen7_hwsched_coldboot_gpu(adreno_dev);
}

int gen7_hwsched_warmboot_init_gmu(struct adreno_device *adreno_dev)
{
	struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
	struct pending_cmd ack = {0};
	int ret = 0;

	ret = gen7_hwsched_hfi_send_warmboot_cmd(adreno_dev, gmu->gmu_init_scratch,
		 HFI_WARMBOOT_EXEC_SCRATCH, false, &ack);
	if (ret)
		goto err;

	gen7_hwsched_enable_async_hfi(adreno_dev);

	set_bit(GMU_PRIV_HFI_STARTED, &gmu->flags);

	ret = kgsl_pwrctrl_setup_default_votes(KGSL_DEVICE(adreno_dev));

err:
	if (ret) {
		/* Clear the bit in case of an error so next boot will be coldboot */
		clear_bit(GMU_PRIV_WARMBOOT_GMU_INIT_DONE, &gmu->flags);
		clear_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags);
		gen7_hwsched_hfi_stop(adreno_dev);
	}

	return ret;
}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:2117 [MATCH: pending_cmd] ---
	/* These messages should not be recorded */
	clear_bit(H2F_MSG_WARMBOOT_CMD, hfi->wb_set_record_bitmask);
	clear_bit(H2F_MSG_START, hfi->wb_set_record_bitmask);
	clear_bit(H2F_MSG_GET_VALUE, hfi->wb_set_record_bitmask);
	clear_bit(H2F_MSG_GX_BW_PERF_VOTE, hfi->wb_set_record_bitmask);
}

int gen7_hwsched_hfi_start(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gmu_core_device *gmu_core = &device->gmu_core;
	struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
	struct pending_cmd ack = {0};
	int ret;

	reset_hfi_queues(adreno_dev);

	ret = gen7_gmu_hfi_start(adreno_dev);
	if (ret)
		goto err;

	if (gen7_hwsched_warmboot_possible(adreno_dev))
		return gen7_hwsched_warmboot_init_gmu(adreno_dev);

	if (ADRENO_FEATURE(adreno_dev, ADRENO_GMU_WARMBOOT) &&
		(!test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags))) {
		if (gen7_hfi_send_get_value(adreno_dev, HFI_VALUE_GMU_WARMBOOT, 0) == 1)
			gmu_core->warmboot_enabled = true;
	}

	warmboot_init_message_record_bitmask(adreno_dev);

	/* Reset the variable here and set it when we successfully record the scratch */
	clear_bit(GMU_PRIV_WARMBOOT_GMU_INIT_DONE, &gmu->flags);
	clear_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags);

	ret = gen7_hwsched_hfi_send_warmboot_cmd(adreno_dev, gmu->gmu_init_scratch,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:3673 [MATCH: pending_cmd] ---
	/* Make sure we send all fences from this context to the TxQueue after recovery */
	move_detached_context_hardware_fences(adreno_dev, drawctxt);
	gen7_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT);
}

static int send_context_unregister_hfi(struct adreno_device *adreno_dev,
	struct kgsl_context *context, u32 ts)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
	struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev);
	struct adreno_context *drawctxt = ADRENO_CONTEXT(context);
	struct pending_cmd pending_ack;
	struct hfi_unregister_ctxt_cmd cmd;
	u32 seqnum;
	int ret;

	/* Only send HFI if device is not in SLUMBER */
	if (!context->gmu_registered ||
		!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) {
		drain_context_hw_fences(adreno_dev, drawctxt);
		return 0;
	}

	ret = CMD_MSG_HDR(cmd, H2F_MSG_UNREGISTER_CONTEXT);
	if (ret)
		return ret;

	cmd.ctxt_id = context->id,
	cmd.ts = ts,

	/*
	 * Although we know device is powered on, we can still enter SLUMBER
	 * because the wait for ack below is done without holding the mutex. So
	 * take an active count before releasing the mutex so as to avoid a
	 * concurrent SLUMBER sequence while GMU is un-registering this context.
	 */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:514 [MATCH: F2H_MSG_ERR] ---
{
	struct kgsl_device *device = KGSL_DEVICE(gen8_gmu_to_adreno(gmu));
	const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(ADRENO_DEVICE(device));
	u64 ticks = gpudev->read_alwayson(ADRENO_DEVICE(device));
	struct hfi_err_cmd *cmd = rcvd;

	dev_err(GMU_PDEV_DEV(device), "HFI Error Received: %d %d %.16s\n",
			((cmd->error_code >> 16) & 0xffff),
			(cmd->error_code & 0xffff),
			(char *) cmd->data);

	KGSL_GMU_CORE_FORCE_PANIC(device->gmu_core.gf_panic,
				GMU_PDEV(device), ticks, GMU_FAULT_F2H_MSG_ERR);
}

void adreno_gen8_receive_debug_req(struct gen8_gmu_device *gmu, void *rcvd)
{
	struct kgsl_device *device = KGSL_DEVICE(gen8_gmu_to_adreno(gmu));
	struct hfi_debug_cmd *cmd = rcvd;

	dev_dbg(GMU_PDEV_DEV(device), "HFI Debug Received: %d %d %d\n",
			cmd->type, cmd->timestamp, cmd->data);
}

int gen8_hfi_process_queue(struct gen8_gmu_device *gmu,
		u32 queue_idx, struct pending_cmd *ret_cmd)
{
	struct kgsl_device *device = KGSL_DEVICE(gen8_gmu_to_adreno(gmu));
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	u32 rcvd[MAX_RCVD_SIZE];
	bool retry_for_ack = true;

	while (gen8_hfi_queue_read(gmu, queue_idx, rcvd, sizeof(rcvd)) > 0) {
		/* ACK Handler */
		if (MSG_HDR_GET_TYPE(rcvd[0]) == HFI_MSG_ACK) {
			int ret = gen8_receive_ack_cmd(gmu, rcvd, ret_cmd);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:548 [MATCH: F2H_MSG_ERR] ---
		if (MSG_HDR_GET_TYPE(rcvd[0]) == HFI_MSG_ACK) {
			int ret = gen8_receive_ack_cmd(gmu, rcvd, ret_cmd);

			if (ret)
				return ret;

			retry_for_ack = false;
			continue;
		}

		/* Request Handler */
		switch (MSG_HDR_GET_ID(rcvd[0])) {
		case F2H_MSG_ERR: /* No Reply */
			adreno_gen8_receive_err_req(gmu, rcvd);
			retry_for_ack = false;
			break;
		case F2H_MSG_DEBUG: /* No Reply */
			adreno_gen8_receive_debug_req(gmu, rcvd);
			break;
		case F2H_MSG_PROCESS_TRACE:
			gmu_core_process_trace_data(device,
					GMU_PDEV_DEV(device), &device->gmu_core.trace);
			break;
		case F2H_MSG_PLATFORM_LA:
			gen8_hwsched_process_f2h_platform_msg(adreno_dev, rcvd);
			break;
		default: /* No Reply */
			dev_err(GMU_PDEV_DEV(device),
				"HFI request %d not supported\n",
				MSG_HDR_GET_ID(rcvd[0]));
			break;
		}
	}

	/**
	 * gen8_hfi_process_queue with HFI_MSG_ID uses a synchronous HFI which expects
	 * an ACK. Poll again if we processed the queue but didn't receive the expected ACK.

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:552 [MATCH: F2H_MSG_DEBUG] ---
				return ret;

			retry_for_ack = false;
			continue;
		}

		/* Request Handler */
		switch (MSG_HDR_GET_ID(rcvd[0])) {
		case F2H_MSG_ERR: /* No Reply */
			adreno_gen8_receive_err_req(gmu, rcvd);
			retry_for_ack = false;
			break;
		case F2H_MSG_DEBUG: /* No Reply */
			adreno_gen8_receive_debug_req(gmu, rcvd);
			break;
		case F2H_MSG_PROCESS_TRACE:
			gmu_core_process_trace_data(device,
					GMU_PDEV_DEV(device), &device->gmu_core.trace);
			break;
		case F2H_MSG_PLATFORM_LA:
			gen8_hwsched_process_f2h_platform_msg(adreno_dev, rcvd);
			break;
		default: /* No Reply */
			dev_err(GMU_PDEV_DEV(device),
				"HFI request %d not supported\n",
				MSG_HDR_GET_ID(rcvd[0]));
			break;
		}
	}

	/**
	 * gen8_hfi_process_queue with HFI_MSG_ID uses a synchronous HFI which expects
	 * an ACK. Poll again if we processed the queue but didn't receive the expected ACK.
	 * Return -EAGAIN to trigger another polling attempt.
	 */
	if ((retry_for_ack) && (queue_idx == HFI_MSG_ID))
		return -EAGAIN;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:251 [MATCH: CMP_HFI_ACK_HDR] ---
int gen8_receive_ack_cmd(struct gen8_gmu_device *gmu, void *rcvd,
	struct pending_cmd *ret_cmd)
{
	struct adreno_device *adreno_dev = gen8_gmu_to_adreno(gmu);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	u32 *ack = rcvd;
	u32 hdr = ack[0];
	u32 req_hdr = ack[1];

	if (ret_cmd == NULL)
		return -EINVAL;

	if (CMP_HFI_ACK_HDR(ret_cmd->sent_hdr, req_hdr)) {
		memcpy(&ret_cmd->results, ack, MSG_HDR_GET_SIZE(hdr) << 2);
		return 0;
	}

	/* Didn't find the sender, list the waiter */
	dev_err_ratelimited(GMU_PDEV_DEV(device),
		"HFI ACK: Cannot find sender for 0x%8.8x Waiter: 0x%8.8x\n",
		req_hdr, ret_cmd->sent_hdr);
	gmu_core_fault_snapshot(device, GMU_FAULT_HFI_RECIVE_ACK);

	return -ENODEV;
}

static int poll_gmu_reg(struct adreno_device *adreno_dev,
	u32 offsetdwords, u32 expected_val,
	u32 mask, u32 timeout_ms)
{
	u32 val;
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
	bool nmi = false;

	while (time_is_after_jiffies(timeout)) {
		gmu_core_regread(device, offsetdwords, &val);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:240 [MATCH: ret_cmd] ---
	/* Allocates & maps memory for HFI */
	if (IS_ERR_OR_NULL(hfi->hfi_mem)) {
		hfi->hfi_mem = gmu_core_reserve_kernel_block(device, 0,
				HFIMEM_SIZE, GMU_NONCACHED_KERNEL, 0);
		if (!IS_ERR(hfi->hfi_mem))
			init_queues(adreno_dev);
	}

	return PTR_ERR_OR_ZERO(hfi->hfi_mem);
}

int gen8_receive_ack_cmd(struct gen8_gmu_device *gmu, void *rcvd,
	struct pending_cmd *ret_cmd)
{
	struct adreno_device *adreno_dev = gen8_gmu_to_adreno(gmu);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	u32 *ack = rcvd;
	u32 hdr = ack[0];
	u32 req_hdr = ack[1];

	if (ret_cmd == NULL)
		return -EINVAL;

	if (CMP_HFI_ACK_HDR(ret_cmd->sent_hdr, req_hdr)) {
		memcpy(&ret_cmd->results, ack, MSG_HDR_GET_SIZE(hdr) << 2);
		return 0;
	}

	/* Didn't find the sender, list the waiter */
	dev_err_ratelimited(GMU_PDEV_DEV(device),
		"HFI ACK: Cannot find sender for 0x%8.8x Waiter: 0x%8.8x\n",
		req_hdr, ret_cmd->sent_hdr);
	gmu_core_fault_snapshot(device, GMU_FAULT_HFI_RECIVE_ACK);

	return -ENODEV;
}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:248 [MATCH: ret_cmd] ---
	return PTR_ERR_OR_ZERO(hfi->hfi_mem);
}

int gen8_receive_ack_cmd(struct gen8_gmu_device *gmu, void *rcvd,
	struct pending_cmd *ret_cmd)
{
	struct adreno_device *adreno_dev = gen8_gmu_to_adreno(gmu);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	u32 *ack = rcvd;
	u32 hdr = ack[0];
	u32 req_hdr = ack[1];

	if (ret_cmd == NULL)
		return -EINVAL;

	if (CMP_HFI_ACK_HDR(ret_cmd->sent_hdr, req_hdr)) {
		memcpy(&ret_cmd->results, ack, MSG_HDR_GET_SIZE(hdr) << 2);
		return 0;
	}

	/* Didn't find the sender, list the waiter */
	dev_err_ratelimited(GMU_PDEV_DEV(device),
		"HFI ACK: Cannot find sender for 0x%8.8x Waiter: 0x%8.8x\n",
		req_hdr, ret_cmd->sent_hdr);
	gmu_core_fault_snapshot(device, GMU_FAULT_HFI_RECIVE_ACK);

	return -ENODEV;
}

static int poll_gmu_reg(struct adreno_device *adreno_dev,
	u32 offsetdwords, u32 expected_val,
	u32 mask, u32 timeout_ms)
{
	u32 val;
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
	bool nmi = false;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:252 [MATCH: ret_cmd] ---
	struct pending_cmd *ret_cmd)
{
	struct adreno_device *adreno_dev = gen8_gmu_to_adreno(gmu);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	u32 *ack = rcvd;
	u32 hdr = ack[0];
	u32 req_hdr = ack[1];

	if (ret_cmd == NULL)
		return -EINVAL;

	if (CMP_HFI_ACK_HDR(ret_cmd->sent_hdr, req_hdr)) {
		memcpy(&ret_cmd->results, ack, MSG_HDR_GET_SIZE(hdr) << 2);
		return 0;
	}

	/* Didn't find the sender, list the waiter */
	dev_err_ratelimited(GMU_PDEV_DEV(device),
		"HFI ACK: Cannot find sender for 0x%8.8x Waiter: 0x%8.8x\n",
		req_hdr, ret_cmd->sent_hdr);
	gmu_core_fault_snapshot(device, GMU_FAULT_HFI_RECIVE_ACK);

	return -ENODEV;
}

static int poll_gmu_reg(struct adreno_device *adreno_dev,
	u32 offsetdwords, u32 expected_val,
	u32 mask, u32 timeout_ms)
{
	u32 val;
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
	bool nmi = false;

	while (time_is_after_jiffies(timeout)) {
		gmu_core_regread(device, offsetdwords, &val);
		if ((val & mask) == expected_val)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:259 [MATCH: ret_cmd] ---

	if (ret_cmd == NULL)
		return -EINVAL;

	if (CMP_HFI_ACK_HDR(ret_cmd->sent_hdr, req_hdr)) {
		memcpy(&ret_cmd->results, ack, MSG_HDR_GET_SIZE(hdr) << 2);
		return 0;
	}

	/* Didn't find the sender, list the waiter */
	dev_err_ratelimited(GMU_PDEV_DEV(device),
		"HFI ACK: Cannot find sender for 0x%8.8x Waiter: 0x%8.8x\n",
		req_hdr, ret_cmd->sent_hdr);
	gmu_core_fault_snapshot(device, GMU_FAULT_HFI_RECIVE_ACK);

	return -ENODEV;
}

static int poll_gmu_reg(struct adreno_device *adreno_dev,
	u32 offsetdwords, u32 expected_val,
	u32 mask, u32 timeout_ms)
{
	u32 val;
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
	bool nmi = false;

	while (time_is_after_jiffies(timeout)) {
		gmu_core_regread(device, offsetdwords, &val);
		if ((val & mask) == expected_val)
			return 0;

		/*
		 * If GMU firmware fails any assertion, error message is sent
		 * to KMD and NMI is triggered. So check if GMU is in NMI and
		 * timeout early. Bits [11:9] of A6XX_GMU_CM3_FW_INIT_RESULT
		 * contain GMU reset status. Non zero value here indicates that

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:310 [MATCH: ret_cmd] ---
	if ((val & mask) == expected_val)
		return 0;

	dev_err(GMU_PDEV_DEV(device),
		"Reg poll %s: offset 0x%x, want 0x%x, got 0x%x\n",
		nmi ? "abort" : "timeout", offsetdwords, expected_val,
		val & mask);

	return -ETIMEDOUT;
}

static int gen8_hfi_send_cmd_wait_inline(struct adreno_device *adreno_dev,
	void *data, u32 size_bytes, struct pending_cmd *ret_cmd)
{
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int rc;
	u32 *cmd = data;
	struct gen8_hfi *hfi = &gmu->hfi;
	u32 seqnum = atomic_inc_return(&hfi->seqnum);

	*cmd = MSG_HDR_SET_SEQNUM_SIZE(*cmd, seqnum, size_bytes >> 2);
	if (ret_cmd == NULL)
		return gen8_hfi_cmdq_write(adreno_dev, cmd, size_bytes);

	ret_cmd->sent_hdr = cmd[0];

	rc = gen8_hfi_cmdq_write(adreno_dev, cmd, size_bytes);
	if (rc)
		return rc;

poll:
	rc = poll_gmu_reg(adreno_dev, GEN8_GMUCX_GMU2HOST_INTR_INFO,
		HFI_IRQ_MSGQ_MASK, HFI_IRQ_MSGQ_MASK, HFI_RSP_TIMEOUT);

	if (rc) {
		dev_err(GMU_PDEV_DEV(device),

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:320 [MATCH: ret_cmd] ---

static int gen8_hfi_send_cmd_wait_inline(struct adreno_device *adreno_dev,
	void *data, u32 size_bytes, struct pending_cmd *ret_cmd)
{
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int rc;
	u32 *cmd = data;
	struct gen8_hfi *hfi = &gmu->hfi;
	u32 seqnum = atomic_inc_return(&hfi->seqnum);

	*cmd = MSG_HDR_SET_SEQNUM_SIZE(*cmd, seqnum, size_bytes >> 2);
	if (ret_cmd == NULL)
		return gen8_hfi_cmdq_write(adreno_dev, cmd, size_bytes);

	ret_cmd->sent_hdr = cmd[0];

	rc = gen8_hfi_cmdq_write(adreno_dev, cmd, size_bytes);
	if (rc)
		return rc;

poll:
	rc = poll_gmu_reg(adreno_dev, GEN8_GMUCX_GMU2HOST_INTR_INFO,
		HFI_IRQ_MSGQ_MASK, HFI_IRQ_MSGQ_MASK, HFI_RSP_TIMEOUT);

	if (rc) {
		dev_err(GMU_PDEV_DEV(device),
		"Timed out waiting on ack for 0x%8.8x (id %d, sequence %d)\n",
		cmd[0], MSG_HDR_GET_ID(*cmd), MSG_HDR_GET_SEQNUM(*cmd));
		gmu_core_fault_snapshot(device, GMU_FAULT_SEND_CMD_WAIT_INLINE);
		return rc;
	}

	/* Clear the interrupt */
	gmu_core_regwrite(device, GEN8_GMUCX_GMU2HOST_INTR_CLR,
		HFI_IRQ_MSGQ_MASK);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:323 [MATCH: ret_cmd] ---
{
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int rc;
	u32 *cmd = data;
	struct gen8_hfi *hfi = &gmu->hfi;
	u32 seqnum = atomic_inc_return(&hfi->seqnum);

	*cmd = MSG_HDR_SET_SEQNUM_SIZE(*cmd, seqnum, size_bytes >> 2);
	if (ret_cmd == NULL)
		return gen8_hfi_cmdq_write(adreno_dev, cmd, size_bytes);

	ret_cmd->sent_hdr = cmd[0];

	rc = gen8_hfi_cmdq_write(adreno_dev, cmd, size_bytes);
	if (rc)
		return rc;

poll:
	rc = poll_gmu_reg(adreno_dev, GEN8_GMUCX_GMU2HOST_INTR_INFO,
		HFI_IRQ_MSGQ_MASK, HFI_IRQ_MSGQ_MASK, HFI_RSP_TIMEOUT);

	if (rc) {
		dev_err(GMU_PDEV_DEV(device),
		"Timed out waiting on ack for 0x%8.8x (id %d, sequence %d)\n",
		cmd[0], MSG_HDR_GET_ID(*cmd), MSG_HDR_GET_SEQNUM(*cmd));
		gmu_core_fault_snapshot(device, GMU_FAULT_SEND_CMD_WAIT_INLINE);
		return rc;
	}

	/* Clear the interrupt */
	gmu_core_regwrite(device, GEN8_GMUCX_GMU2HOST_INTR_CLR,
		HFI_IRQ_MSGQ_MASK);

	/* Add a barrier to ensure interrupt is cleared before reading queue and polling again */
	mb();


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:348 [MATCH: ret_cmd] ---
		cmd[0], MSG_HDR_GET_ID(*cmd), MSG_HDR_GET_SEQNUM(*cmd));
		gmu_core_fault_snapshot(device, GMU_FAULT_SEND_CMD_WAIT_INLINE);
		return rc;
	}

	/* Clear the interrupt */
	gmu_core_regwrite(device, GEN8_GMUCX_GMU2HOST_INTR_CLR,
		HFI_IRQ_MSGQ_MASK);

	/* Add a barrier to ensure interrupt is cleared before reading queue and polling again */
	mb();

	rc = gen8_hfi_process_queue(gmu, HFI_MSG_ID, ret_cmd);

	/* If ACK not received, try polling again */
	if (rc == -EAGAIN)
		goto poll;

	return rc;
}

int gen8_hfi_send_generic_req(struct adreno_device *adreno_dev, void *cmd, u32 size_bytes)
{
	struct pending_cmd ret_cmd;
	int rc;

	memset(&ret_cmd, 0, sizeof(ret_cmd));

	rc = gen8_hfi_send_cmd_wait_inline(adreno_dev, cmd, size_bytes, &ret_cmd);
	if (rc)
		return rc;

	if (ret_cmd.results[2]) {
		struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

		dev_err(GMU_PDEV_DEV(device),
				"HFI ACK failure: Req=0x%8.8X, Result=0x%8.8X\n",

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:359 [MATCH: ret_cmd] ---

	rc = gen8_hfi_process_queue(gmu, HFI_MSG_ID, ret_cmd);

	/* If ACK not received, try polling again */
	if (rc == -EAGAIN)
		goto poll;

	return rc;
}

int gen8_hfi_send_generic_req(struct adreno_device *adreno_dev, void *cmd, u32 size_bytes)
{
	struct pending_cmd ret_cmd;
	int rc;

	memset(&ret_cmd, 0, sizeof(ret_cmd));

	rc = gen8_hfi_send_cmd_wait_inline(adreno_dev, cmd, size_bytes, &ret_cmd);
	if (rc)
		return rc;

	if (ret_cmd.results[2]) {
		struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

		dev_err(GMU_PDEV_DEV(device),
				"HFI ACK failure: Req=0x%8.8X, Result=0x%8.8X\n",
				ret_cmd.results[1],
				ret_cmd.results[2]);
		gmu_core_fault_snapshot(device, GMU_FAULT_HFI_SEND_GENERIC_REQ);
		return -EINVAL;
	}

	return 0;
}

int gen8_hfi_send_core_fw_start(struct adreno_device *adreno_dev)
{

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:362 [MATCH: ret_cmd] ---
	/* If ACK not received, try polling again */
	if (rc == -EAGAIN)
		goto poll;

	return rc;
}

int gen8_hfi_send_generic_req(struct adreno_device *adreno_dev, void *cmd, u32 size_bytes)
{
	struct pending_cmd ret_cmd;
	int rc;

	memset(&ret_cmd, 0, sizeof(ret_cmd));

	rc = gen8_hfi_send_cmd_wait_inline(adreno_dev, cmd, size_bytes, &ret_cmd);
	if (rc)
		return rc;

	if (ret_cmd.results[2]) {
		struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

		dev_err(GMU_PDEV_DEV(device),
				"HFI ACK failure: Req=0x%8.8X, Result=0x%8.8X\n",
				ret_cmd.results[1],
				ret_cmd.results[2]);
		gmu_core_fault_snapshot(device, GMU_FAULT_HFI_SEND_GENERIC_REQ);
		return -EINVAL;
	}

	return 0;
}

int gen8_hfi_send_core_fw_start(struct adreno_device *adreno_dev)
{
	struct hfi_core_fw_start_cmd cmd = {
		.handle = 0x0,
	};

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:364 [MATCH: ret_cmd] ---
		goto poll;

	return rc;
}

int gen8_hfi_send_generic_req(struct adreno_device *adreno_dev, void *cmd, u32 size_bytes)
{
	struct pending_cmd ret_cmd;
	int rc;

	memset(&ret_cmd, 0, sizeof(ret_cmd));

	rc = gen8_hfi_send_cmd_wait_inline(adreno_dev, cmd, size_bytes, &ret_cmd);
	if (rc)
		return rc;

	if (ret_cmd.results[2]) {
		struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

		dev_err(GMU_PDEV_DEV(device),
				"HFI ACK failure: Req=0x%8.8X, Result=0x%8.8X\n",
				ret_cmd.results[1],
				ret_cmd.results[2]);
		gmu_core_fault_snapshot(device, GMU_FAULT_HFI_SEND_GENERIC_REQ);
		return -EINVAL;
	}

	return 0;
}

int gen8_hfi_send_core_fw_start(struct adreno_device *adreno_dev)
{
	struct hfi_core_fw_start_cmd cmd = {
		.handle = 0x0,
	};
	int ret;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:368 [MATCH: ret_cmd] ---

int gen8_hfi_send_generic_req(struct adreno_device *adreno_dev, void *cmd, u32 size_bytes)
{
	struct pending_cmd ret_cmd;
	int rc;

	memset(&ret_cmd, 0, sizeof(ret_cmd));

	rc = gen8_hfi_send_cmd_wait_inline(adreno_dev, cmd, size_bytes, &ret_cmd);
	if (rc)
		return rc;

	if (ret_cmd.results[2]) {
		struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

		dev_err(GMU_PDEV_DEV(device),
				"HFI ACK failure: Req=0x%8.8X, Result=0x%8.8X\n",
				ret_cmd.results[1],
				ret_cmd.results[2]);
		gmu_core_fault_snapshot(device, GMU_FAULT_HFI_SEND_GENERIC_REQ);
		return -EINVAL;
	}

	return 0;
}

int gen8_hfi_send_core_fw_start(struct adreno_device *adreno_dev)
{
	struct hfi_core_fw_start_cmd cmd = {
		.handle = 0x0,
	};
	int ret;

	ret = CMD_MSG_HDR(cmd, H2F_MSG_CORE_FW_START);
	if (ret)
		return ret;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:373 [MATCH: ret_cmd] ---

	memset(&ret_cmd, 0, sizeof(ret_cmd));

	rc = gen8_hfi_send_cmd_wait_inline(adreno_dev, cmd, size_bytes, &ret_cmd);
	if (rc)
		return rc;

	if (ret_cmd.results[2]) {
		struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

		dev_err(GMU_PDEV_DEV(device),
				"HFI ACK failure: Req=0x%8.8X, Result=0x%8.8X\n",
				ret_cmd.results[1],
				ret_cmd.results[2]);
		gmu_core_fault_snapshot(device, GMU_FAULT_HFI_SEND_GENERIC_REQ);
		return -EINVAL;
	}

	return 0;
}

int gen8_hfi_send_core_fw_start(struct adreno_device *adreno_dev)
{
	struct hfi_core_fw_start_cmd cmd = {
		.handle = 0x0,
	};
	int ret;

	ret = CMD_MSG_HDR(cmd, H2F_MSG_CORE_FW_START);
	if (ret)
		return ret;

	return gen8_hfi_send_generic_req(adreno_dev, &cmd, sizeof(cmd));
}

/* For sending hfi message inline to handle GMU return type error */
int gen8_hfi_send_generic_req_v5(struct adreno_device *adreno_dev, void *cmd,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:374 [MATCH: ret_cmd] ---
	memset(&ret_cmd, 0, sizeof(ret_cmd));

	rc = gen8_hfi_send_cmd_wait_inline(adreno_dev, cmd, size_bytes, &ret_cmd);
	if (rc)
		return rc;

	if (ret_cmd.results[2]) {
		struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

		dev_err(GMU_PDEV_DEV(device),
				"HFI ACK failure: Req=0x%8.8X, Result=0x%8.8X\n",
				ret_cmd.results[1],
				ret_cmd.results[2]);
		gmu_core_fault_snapshot(device, GMU_FAULT_HFI_SEND_GENERIC_REQ);
		return -EINVAL;
	}

	return 0;
}

int gen8_hfi_send_core_fw_start(struct adreno_device *adreno_dev)
{
	struct hfi_core_fw_start_cmd cmd = {
		.handle = 0x0,
	};
	int ret;

	ret = CMD_MSG_HDR(cmd, H2F_MSG_CORE_FW_START);
	if (ret)
		return ret;

	return gen8_hfi_send_generic_req(adreno_dev, &cmd, sizeof(cmd));
}

/* For sending hfi message inline to handle GMU return type error */
int gen8_hfi_send_generic_req_v5(struct adreno_device *adreno_dev, void *cmd,
		struct pending_cmd *ret_cmd, u32 size_bytes)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:398 [MATCH: ret_cmd] ---
	};
	int ret;

	ret = CMD_MSG_HDR(cmd, H2F_MSG_CORE_FW_START);
	if (ret)
		return ret;

	return gen8_hfi_send_generic_req(adreno_dev, &cmd, sizeof(cmd));
}

/* For sending hfi message inline to handle GMU return type error */
int gen8_hfi_send_generic_req_v5(struct adreno_device *adreno_dev, void *cmd,
		struct pending_cmd *ret_cmd, u32 size_bytes)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int rc;

	if (GMU_VER_MINOR(device->gmu_core.ver.hfi) <= 4)
		return gen8_hfi_send_generic_req(adreno_dev, cmd, size_bytes);

	rc = gen8_hfi_send_cmd_wait_inline(adreno_dev, cmd, size_bytes, ret_cmd);
	if (rc)
		return rc;

	switch (ret_cmd->results[3]) {
	case GMU_SUCCESS:
		rc = ret_cmd->results[2];
		break;
	case GMU_ERROR_NO_ENTRY:
		/* Unique error to handle undefined HFI msgs by caller */
		rc = -ENOENT;
		break;
	case GMU_ERROR_TIMEOUT:
		rc = -EINVAL;
		break;
	default:
		dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:406 [MATCH: ret_cmd] ---
}

/* For sending hfi message inline to handle GMU return type error */
int gen8_hfi_send_generic_req_v5(struct adreno_device *adreno_dev, void *cmd,
		struct pending_cmd *ret_cmd, u32 size_bytes)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int rc;

	if (GMU_VER_MINOR(device->gmu_core.ver.hfi) <= 4)
		return gen8_hfi_send_generic_req(adreno_dev, cmd, size_bytes);

	rc = gen8_hfi_send_cmd_wait_inline(adreno_dev, cmd, size_bytes, ret_cmd);
	if (rc)
		return rc;

	switch (ret_cmd->results[3]) {
	case GMU_SUCCESS:
		rc = ret_cmd->results[2];
		break;
	case GMU_ERROR_NO_ENTRY:
		/* Unique error to handle undefined HFI msgs by caller */
		rc = -ENOENT;
		break;
	case GMU_ERROR_TIMEOUT:
		rc = -EINVAL;
		break;
	default:
		dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),
			"HFI ACK: Req=0x%8.8X, Result=0x%8.8X Error:0x%8.8X\n",
			ret_cmd->results[1], ret_cmd->results[2], ret_cmd->results[3]);
		rc = -EINVAL;
		gmu_core_fault_snapshot(KGSL_DEVICE(adreno_dev), GMU_FAULT_HFI_SEND_GENERIC_REQ);
		break;
	}

	return rc;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:410 [MATCH: ret_cmd] ---
		struct pending_cmd *ret_cmd, u32 size_bytes)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int rc;

	if (GMU_VER_MINOR(device->gmu_core.ver.hfi) <= 4)
		return gen8_hfi_send_generic_req(adreno_dev, cmd, size_bytes);

	rc = gen8_hfi_send_cmd_wait_inline(adreno_dev, cmd, size_bytes, ret_cmd);
	if (rc)
		return rc;

	switch (ret_cmd->results[3]) {
	case GMU_SUCCESS:
		rc = ret_cmd->results[2];
		break;
	case GMU_ERROR_NO_ENTRY:
		/* Unique error to handle undefined HFI msgs by caller */
		rc = -ENOENT;
		break;
	case GMU_ERROR_TIMEOUT:
		rc = -EINVAL;
		break;
	default:
		dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),
			"HFI ACK: Req=0x%8.8X, Result=0x%8.8X Error:0x%8.8X\n",
			ret_cmd->results[1], ret_cmd->results[2], ret_cmd->results[3]);
		rc = -EINVAL;
		gmu_core_fault_snapshot(KGSL_DEVICE(adreno_dev), GMU_FAULT_HFI_SEND_GENERIC_REQ);
		break;
	}

	return rc;
}

int gen8_hfi_send_feature_ctrl(struct adreno_device *adreno_dev,
	u32 feature, u32 enable, u32 data)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:412 [MATCH: ret_cmd] ---
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int rc;

	if (GMU_VER_MINOR(device->gmu_core.ver.hfi) <= 4)
		return gen8_hfi_send_generic_req(adreno_dev, cmd, size_bytes);

	rc = gen8_hfi_send_cmd_wait_inline(adreno_dev, cmd, size_bytes, ret_cmd);
	if (rc)
		return rc;

	switch (ret_cmd->results[3]) {
	case GMU_SUCCESS:
		rc = ret_cmd->results[2];
		break;
	case GMU_ERROR_NO_ENTRY:
		/* Unique error to handle undefined HFI msgs by caller */
		rc = -ENOENT;
		break;
	case GMU_ERROR_TIMEOUT:
		rc = -EINVAL;
		break;
	default:
		dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),
			"HFI ACK: Req=0x%8.8X, Result=0x%8.8X Error:0x%8.8X\n",
			ret_cmd->results[1], ret_cmd->results[2], ret_cmd->results[3]);
		rc = -EINVAL;
		gmu_core_fault_snapshot(KGSL_DEVICE(adreno_dev), GMU_FAULT_HFI_SEND_GENERIC_REQ);
		break;
	}

	return rc;
}

int gen8_hfi_send_feature_ctrl(struct adreno_device *adreno_dev,
	u32 feature, u32 enable, u32 data)
{
	struct pending_cmd ret_cmd = {0};

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:424 [MATCH: ret_cmd] ---
		rc = ret_cmd->results[2];
		break;
	case GMU_ERROR_NO_ENTRY:
		/* Unique error to handle undefined HFI msgs by caller */
		rc = -ENOENT;
		break;
	case GMU_ERROR_TIMEOUT:
		rc = -EINVAL;
		break;
	default:
		dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),
			"HFI ACK: Req=0x%8.8X, Result=0x%8.8X Error:0x%8.8X\n",
			ret_cmd->results[1], ret_cmd->results[2], ret_cmd->results[3]);
		rc = -EINVAL;
		gmu_core_fault_snapshot(KGSL_DEVICE(adreno_dev), GMU_FAULT_HFI_SEND_GENERIC_REQ);
		break;
	}

	return rc;
}

int gen8_hfi_send_feature_ctrl(struct adreno_device *adreno_dev,
	u32 feature, u32 enable, u32 data)
{
	struct pending_cmd ret_cmd = {0};
	struct hfi_feature_ctrl_cmd cmd = {
		.feature = feature,
		.enable = enable,
		.data = data,
	};
	int ret;

	ret = CMD_MSG_HDR(cmd, H2F_MSG_FEATURE_CTRL);
	if (ret)
		return ret;

	ret = gen8_hfi_send_generic_req_v5(adreno_dev, &cmd, &ret_cmd, sizeof(cmd));

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:436 [MATCH: ret_cmd] ---
			ret_cmd->results[1], ret_cmd->results[2], ret_cmd->results[3]);
		rc = -EINVAL;
		gmu_core_fault_snapshot(KGSL_DEVICE(adreno_dev), GMU_FAULT_HFI_SEND_GENERIC_REQ);
		break;
	}

	return rc;
}

int gen8_hfi_send_feature_ctrl(struct adreno_device *adreno_dev,
	u32 feature, u32 enable, u32 data)
{
	struct pending_cmd ret_cmd = {0};
	struct hfi_feature_ctrl_cmd cmd = {
		.feature = feature,
		.enable = enable,
		.data = data,
	};
	int ret;

	ret = CMD_MSG_HDR(cmd, H2F_MSG_FEATURE_CTRL);
	if (ret)
		return ret;

	ret = gen8_hfi_send_generic_req_v5(adreno_dev, &cmd, &ret_cmd, sizeof(cmd));
	if (ret < 0)
		dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),
			"Unable to %s feature %s (%d)\n",
			enable ? "enable" : "disable", hfi_feature_to_string(feature), feature);
	return ret;
}

int gen8_hfi_send_get_value(struct adreno_device *adreno_dev, u32 type, u32 subtype)
{
	struct pending_cmd ret_cmd = {0};
	struct hfi_get_value_cmd cmd = {
		.type = type,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:448 [MATCH: ret_cmd] ---
	struct pending_cmd ret_cmd = {0};
	struct hfi_feature_ctrl_cmd cmd = {
		.feature = feature,
		.enable = enable,
		.data = data,
	};
	int ret;

	ret = CMD_MSG_HDR(cmd, H2F_MSG_FEATURE_CTRL);
	if (ret)
		return ret;

	ret = gen8_hfi_send_generic_req_v5(adreno_dev, &cmd, &ret_cmd, sizeof(cmd));
	if (ret < 0)
		dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),
			"Unable to %s feature %s (%d)\n",
			enable ? "enable" : "disable", hfi_feature_to_string(feature), feature);
	return ret;
}

int gen8_hfi_send_get_value(struct adreno_device *adreno_dev, u32 type, u32 subtype)
{
	struct pending_cmd ret_cmd = {0};
	struct hfi_get_value_cmd cmd = {
		.type = type,
		.subtype = subtype,
	};
	int ret;

	ret = CMD_MSG_HDR(cmd, H2F_MSG_GET_VALUE);
	if (ret)
		return ret;

	ret = gen8_hfi_send_generic_req_v5(adreno_dev, &cmd, &ret_cmd, sizeof(cmd));
	if (ret < 0)
		dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),
			"Unable to get HFI Value type: %d, subtype: %d, error = %d\n",

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:458 [MATCH: ret_cmd] ---
		return ret;

	ret = gen8_hfi_send_generic_req_v5(adreno_dev, &cmd, &ret_cmd, sizeof(cmd));
	if (ret < 0)
		dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),
			"Unable to %s feature %s (%d)\n",
			enable ? "enable" : "disable", hfi_feature_to_string(feature), feature);
	return ret;
}

int gen8_hfi_send_get_value(struct adreno_device *adreno_dev, u32 type, u32 subtype)
{
	struct pending_cmd ret_cmd = {0};
	struct hfi_get_value_cmd cmd = {
		.type = type,
		.subtype = subtype,
	};
	int ret;

	ret = CMD_MSG_HDR(cmd, H2F_MSG_GET_VALUE);
	if (ret)
		return ret;

	ret = gen8_hfi_send_generic_req_v5(adreno_dev, &cmd, &ret_cmd, sizeof(cmd));
	if (ret < 0)
		dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),
			"Unable to get HFI Value type: %d, subtype: %d, error = %d\n",
			type, subtype, ret);

	return ret;
}

int gen8_hfi_send_set_value(struct adreno_device *adreno_dev,
		u32 type, u32 subtype, u32 data)
{
	struct pending_cmd ret_cmd = {0};
	struct hfi_set_value_cmd cmd = {

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:469 [MATCH: ret_cmd] ---
{
	struct pending_cmd ret_cmd = {0};
	struct hfi_get_value_cmd cmd = {
		.type = type,
		.subtype = subtype,
	};
	int ret;

	ret = CMD_MSG_HDR(cmd, H2F_MSG_GET_VALUE);
	if (ret)
		return ret;

	ret = gen8_hfi_send_generic_req_v5(adreno_dev, &cmd, &ret_cmd, sizeof(cmd));
	if (ret < 0)
		dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),
			"Unable to get HFI Value type: %d, subtype: %d, error = %d\n",
			type, subtype, ret);

	return ret;
}

int gen8_hfi_send_set_value(struct adreno_device *adreno_dev,
		u32 type, u32 subtype, u32 data)
{
	struct pending_cmd ret_cmd = {0};
	struct hfi_set_value_cmd cmd = {
		.type = type,
		.subtype = subtype,
		.data = data,
	};
	int ret;

	ret = CMD_MSG_HDR(cmd, H2F_MSG_SET_VALUE);
	if (ret)
		return ret;

	ret = gen8_hfi_send_generic_req_v5(adreno_dev, &cmd, &ret_cmd, sizeof(cmd));

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:481 [MATCH: ret_cmd] ---
	ret = gen8_hfi_send_generic_req_v5(adreno_dev, &cmd, &ret_cmd, sizeof(cmd));
	if (ret < 0)
		dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),
			"Unable to get HFI Value type: %d, subtype: %d, error = %d\n",
			type, subtype, ret);

	return ret;
}

int gen8_hfi_send_set_value(struct adreno_device *adreno_dev,
		u32 type, u32 subtype, u32 data)
{
	struct pending_cmd ret_cmd = {0};
	struct hfi_set_value_cmd cmd = {
		.type = type,
		.subtype = subtype,
		.data = data,
	};
	int ret;

	ret = CMD_MSG_HDR(cmd, H2F_MSG_SET_VALUE);
	if (ret)
		return ret;

	ret = gen8_hfi_send_generic_req_v5(adreno_dev, &cmd, &ret_cmd, sizeof(cmd));
	if (ret < 0)
		dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),
			"Unable to set HFI Value %d, %d to %d, error = %d\n",
			type, subtype, data, ret);
	return ret;
}

void adreno_gen8_receive_err_req(struct gen8_gmu_device *gmu, void *rcvd)
{
	struct kgsl_device *device = KGSL_DEVICE(gen8_gmu_to_adreno(gmu));
	const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(ADRENO_DEVICE(device));
	u64 ticks = gpudev->read_alwayson(ADRENO_DEVICE(device));

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:493 [MATCH: ret_cmd] ---
	struct pending_cmd ret_cmd = {0};
	struct hfi_set_value_cmd cmd = {
		.type = type,
		.subtype = subtype,
		.data = data,
	};
	int ret;

	ret = CMD_MSG_HDR(cmd, H2F_MSG_SET_VALUE);
	if (ret)
		return ret;

	ret = gen8_hfi_send_generic_req_v5(adreno_dev, &cmd, &ret_cmd, sizeof(cmd));
	if (ret < 0)
		dev_err(GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),
			"Unable to set HFI Value %d, %d to %d, error = %d\n",
			type, subtype, data, ret);
	return ret;
}

void adreno_gen8_receive_err_req(struct gen8_gmu_device *gmu, void *rcvd)
{
	struct kgsl_device *device = KGSL_DEVICE(gen8_gmu_to_adreno(gmu));
	const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(ADRENO_DEVICE(device));
	u64 ticks = gpudev->read_alwayson(ADRENO_DEVICE(device));
	struct hfi_err_cmd *cmd = rcvd;

	dev_err(GMU_PDEV_DEV(device), "HFI Error Received: %d %d %.16s\n",
			((cmd->error_code >> 16) & 0xffff),
			(cmd->error_code & 0xffff),
			(char *) cmd->data);

	KGSL_GMU_CORE_FORCE_PANIC(device->gmu_core.gf_panic,
				GMU_PDEV(device), ticks, GMU_FAULT_F2H_MSG_ERR);
}

void adreno_gen8_receive_debug_req(struct gen8_gmu_device *gmu, void *rcvd)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:527 [MATCH: ret_cmd] ---
}

void adreno_gen8_receive_debug_req(struct gen8_gmu_device *gmu, void *rcvd)
{
	struct kgsl_device *device = KGSL_DEVICE(gen8_gmu_to_adreno(gmu));
	struct hfi_debug_cmd *cmd = rcvd;

	dev_dbg(GMU_PDEV_DEV(device), "HFI Debug Received: %d %d %d\n",
			cmd->type, cmd->timestamp, cmd->data);
}

int gen8_hfi_process_queue(struct gen8_gmu_device *gmu,
		u32 queue_idx, struct pending_cmd *ret_cmd)
{
	struct kgsl_device *device = KGSL_DEVICE(gen8_gmu_to_adreno(gmu));
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	u32 rcvd[MAX_RCVD_SIZE];
	bool retry_for_ack = true;

	while (gen8_hfi_queue_read(gmu, queue_idx, rcvd, sizeof(rcvd)) > 0) {
		/* ACK Handler */
		if (MSG_HDR_GET_TYPE(rcvd[0]) == HFI_MSG_ACK) {
			int ret = gen8_receive_ack_cmd(gmu, rcvd, ret_cmd);

			if (ret)
				return ret;

			retry_for_ack = false;
			continue;
		}

		/* Request Handler */
		switch (MSG_HDR_GET_ID(rcvd[0])) {
		case F2H_MSG_ERR: /* No Reply */
			adreno_gen8_receive_err_req(gmu, rcvd);
			retry_for_ack = false;
			break;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:537 [MATCH: ret_cmd] ---

int gen8_hfi_process_queue(struct gen8_gmu_device *gmu,
		u32 queue_idx, struct pending_cmd *ret_cmd)
{
	struct kgsl_device *device = KGSL_DEVICE(gen8_gmu_to_adreno(gmu));
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	u32 rcvd[MAX_RCVD_SIZE];
	bool retry_for_ack = true;

	while (gen8_hfi_queue_read(gmu, queue_idx, rcvd, sizeof(rcvd)) > 0) {
		/* ACK Handler */
		if (MSG_HDR_GET_TYPE(rcvd[0]) == HFI_MSG_ACK) {
			int ret = gen8_receive_ack_cmd(gmu, rcvd, ret_cmd);

			if (ret)
				return ret;

			retry_for_ack = false;
			continue;
		}

		/* Request Handler */
		switch (MSG_HDR_GET_ID(rcvd[0])) {
		case F2H_MSG_ERR: /* No Reply */
			adreno_gen8_receive_err_req(gmu, rcvd);
			retry_for_ack = false;
			break;
		case F2H_MSG_DEBUG: /* No Reply */
			adreno_gen8_receive_debug_req(gmu, rcvd);
			break;
		case F2H_MSG_PROCESS_TRACE:
			gmu_core_process_trace_data(device,
					GMU_PDEV_DEV(device), &device->gmu_core.trace);
			break;
		case F2H_MSG_PLATFORM_LA:
			gen8_hwsched_process_f2h_platform_msg(adreno_dev, rcvd);
			break;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.h:100 [MATCH: ret_cmd] ---
 * @output: Pointer to read the data into
 * @max_size: Number of bytes to read from the queue
 *
 * Return: Size of the message read on success or negative error on failure
 */
int gen8_hfi_queue_read(struct gen8_gmu_device *gmu, u32 queue_idx,
		u32 *output, u32 max_size);

/**
 * gen8_receive_ack_cmd - Process ack type packets
 * @gmu: Pointer to the gen8 gmu device
 * @rcvd: Pointer to the data read from hfi queue
 * @ret_cmd: Container for the hfi packet for which this ack is received
 *
 * Return: 0 on success or negative error on failure
 */
int gen8_receive_ack_cmd(struct gen8_gmu_device *gmu, void *rcvd,
		struct pending_cmd *ret_cmd);

/**
 * gen8_hfi_send_feature_ctrl - Enable gmu feature via hfi
 * @adreno_dev: Pointer to the adreno device
 * @feature: feature to be enabled or disabled
 * enable: Set 1 to enable or 0 to disable a feature
 * @data: payload for the send feature hfi packet
 *
 * Return: 0 on success or negative error on failure
 */
int gen8_hfi_send_feature_ctrl(struct adreno_device *adreno_dev,
		u32 feature, u32 enable, u32 data);

/**
 * gen8_hfi_send_get_value - Send gmu get_values via hfi
 * @adreno_dev: Pointer to the adreno device
 * @type: GMU get_value type
 * @subtype: GMU get_value subtype
 *

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.h:105 [MATCH: ret_cmd] ---
int gen8_hfi_queue_read(struct gen8_gmu_device *gmu, u32 queue_idx,
		u32 *output, u32 max_size);

/**
 * gen8_receive_ack_cmd - Process ack type packets
 * @gmu: Pointer to the gen8 gmu device
 * @rcvd: Pointer to the data read from hfi queue
 * @ret_cmd: Container for the hfi packet for which this ack is received
 *
 * Return: 0 on success or negative error on failure
 */
int gen8_receive_ack_cmd(struct gen8_gmu_device *gmu, void *rcvd,
		struct pending_cmd *ret_cmd);

/**
 * gen8_hfi_send_feature_ctrl - Enable gmu feature via hfi
 * @adreno_dev: Pointer to the adreno device
 * @feature: feature to be enabled or disabled
 * enable: Set 1 to enable or 0 to disable a feature
 * @data: payload for the send feature hfi packet
 *
 * Return: 0 on success or negative error on failure
 */
int gen8_hfi_send_feature_ctrl(struct adreno_device *adreno_dev,
		u32 feature, u32 enable, u32 data);

/**
 * gen8_hfi_send_get_value - Send gmu get_values via hfi
 * @adreno_dev: Pointer to the adreno device
 * @type: GMU get_value type
 * @subtype: GMU get_value subtype
 *
 * Return: 0 on success or negative error on failure
 */
int gen8_hfi_send_get_value(struct adreno_device *adreno_dev, u32 type, u32 subtype);

/**

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.h:171 [MATCH: ret_cmd] ---
 * @adreno_dev: Pointer to the adreno device
 * @cmd: Pointer to the hfi packet header and data
 * @size_bytes: Size of the packet in bytes
 *
 * Return: 0 on success or negative error on failure
 */
int gen8_hfi_send_generic_req(struct adreno_device *adreno_dev, void *cmd, u32 size_bytes);

/**
 * gen8_hfi_send_generic_req_v5 - Send a generic hfi packet with additional error handling
 * @adreno_dev: Pointer to the adreno device
 * @cmd: Pointer to the hfi packet header and data
 * @ret_cmd: Ack for the command we just sent
 * @size_bytes: Size of the packet in bytes
 *
 * Return: 0 on success or negative error on failure
 */
int gen8_hfi_send_generic_req_v5(struct adreno_device *adreno_dev, void *cmd,
		struct pending_cmd *ret_cmd, u32 size_bytes);

/**
 * gen8_hfi_send_bcl_feature_ctrl - Send the bcl feature hfi packet
 * @adreno_dev: Pointer to the adreno device
 *
 * Return: 0 on success or negative error on failure
 */
int gen8_hfi_send_bcl_feature_ctrl(struct adreno_device *adreno_dev);

/**
 * gen8_hfi_send_minbw_feature_ctrl - Send the minbw feature hfi packet
 * @adreno_dev: Pointer to the adreno device
 *
 * Return: 0 on success or negative error on failure
 */
int gen8_hfi_send_minbw_feature_ctrl(struct adreno_device *adreno_dev);

/**

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.h:177 [MATCH: ret_cmd] ---
int gen8_hfi_send_generic_req(struct adreno_device *adreno_dev, void *cmd, u32 size_bytes);

/**
 * gen8_hfi_send_generic_req_v5 - Send a generic hfi packet with additional error handling
 * @adreno_dev: Pointer to the adreno device
 * @cmd: Pointer to the hfi packet header and data
 * @ret_cmd: Ack for the command we just sent
 * @size_bytes: Size of the packet in bytes
 *
 * Return: 0 on success or negative error on failure
 */
int gen8_hfi_send_generic_req_v5(struct adreno_device *adreno_dev, void *cmd,
		struct pending_cmd *ret_cmd, u32 size_bytes);

/**
 * gen8_hfi_send_bcl_feature_ctrl - Send the bcl feature hfi packet
 * @adreno_dev: Pointer to the adreno device
 *
 * Return: 0 on success or negative error on failure
 */
int gen8_hfi_send_bcl_feature_ctrl(struct adreno_device *adreno_dev);

/**
 * gen8_hfi_send_minbw_feature_ctrl - Send the minbw feature hfi packet
 * @adreno_dev: Pointer to the adreno device
 *
 * Return: 0 on success or negative error on failure
 */
int gen8_hfi_send_minbw_feature_ctrl(struct adreno_device *adreno_dev);

/**
 * gen8_hfi_send_clx_feature_ctrl - Send the clx feature hfi packet
 * @adreno_dev: Pointer to the adreno device
 *
 * Return: 0 on success or negative error on failure
 */
int gen8_hfi_send_clx_feature_ctrl(struct adreno_device *adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.h:223 [MATCH: ret_cmd] ---
/**
 * gen8_hfi_send_gpu_perf_table - Send the gpu perf table hfi packet
 * @adreno_dev: Pointer to the adreno device
 *
 * Return: 0 on success or negative error on failure
 */
int gen8_hfi_send_gpu_perf_table(struct adreno_device *adreno_dev);

/*
 * gen8_hfi_process_queue - Check hfi queue for messages from gmu
 * @gmu: Pointer to the gen8 gmu device
 * @queue_idx: queue id to be processed
 * @ret_cmd: Container for data needed for waiting for the ack
 *
 * Return: 0 on success or negative error on failure
 */
int gen8_hfi_process_queue(struct gen8_gmu_device *gmu,
		u32 queue_idx, struct pending_cmd *ret_cmd);

/**
 * gen8_hfi_cmdq_write - Write a command to command queue
 * @adreno_dev: Pointer to the adreno device
 * @msg: Data to be written to the queue
 * @size_bytes: Size of the command in bytes
 *
 * This function takes the cmdq lock before writing data to the queue

 * Return: 0 on success or negative error on failure
 */
int gen8_hfi_cmdq_write(struct adreno_device *adreno_dev, u32 *msg, u32 size_bytes);
void adreno_gen8_receive_err_req(struct gen8_gmu_device *gmu, void *rcvd);
void adreno_gen8_receive_debug_req(struct gen8_gmu_device *gmu, void *rcvd);
#endif

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.h:228 [MATCH: ret_cmd] ---
 */
int gen8_hfi_send_gpu_perf_table(struct adreno_device *adreno_dev);

/*
 * gen8_hfi_process_queue - Check hfi queue for messages from gmu
 * @gmu: Pointer to the gen8 gmu device
 * @queue_idx: queue id to be processed
 * @ret_cmd: Container for data needed for waiting for the ack
 *
 * Return: 0 on success or negative error on failure
 */
int gen8_hfi_process_queue(struct gen8_gmu_device *gmu,
		u32 queue_idx, struct pending_cmd *ret_cmd);

/**
 * gen8_hfi_cmdq_write - Write a command to command queue
 * @adreno_dev: Pointer to the adreno device
 * @msg: Data to be written to the queue
 * @size_bytes: Size of the command in bytes
 *
 * This function takes the cmdq lock before writing data to the queue

 * Return: 0 on success or negative error on failure
 */
int gen8_hfi_cmdq_write(struct adreno_device *adreno_dev, u32 *msg, u32 size_bytes);
void adreno_gen8_receive_err_req(struct gen8_gmu_device *gmu, void *rcvd);
void adreno_gen8_receive_debug_req(struct gen8_gmu_device *gmu, void *rcvd);
#endif

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched.c:1364 [MATCH: pending_cmd] ---

	gen8_gmu_send_nmi(device, false, GMU_FAULT_PANIC_NONE);

	dev_err_ratelimited(GMU_PDEV_DEV(device),
			"GMU watchdog expired interrupt received\n");

	gen8_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT);
}

static void gen8_hwsched_drain_ctxt_unregister(struct adreno_device *adreno_dev)
{
	struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev);
	struct pending_cmd *cmd = NULL;

	read_lock(&hfi->msglock);

	list_for_each_entry(cmd, &hfi->msglist, node) {
		if (MSG_HDR_GET_ID(cmd->sent_hdr) == H2F_MSG_UNREGISTER_CONTEXT)
			complete(&cmd->complete);
	}

	read_unlock(&hfi->msglock);
}

/**
 * process_context_hw_fences_after_reset - This function processes all hardware fences that were
 * sent to GMU prior to recovery. If a fence is not retired by the GPU, and the context is still
 * good, then move them to the reset list.
 */
static void process_context_hw_fences_after_reset(struct adreno_device *adreno_dev,
	struct adreno_context *drawctxt, struct list_head *reset_list)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct adreno_hw_fence_entry *entry, *tmp;

	spin_lock(&drawctxt->lock);
	list_for_each_entry_safe(entry, tmp, &drawctxt->hw_fence_inflight_list, node) {

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1160 [MATCH: F2H_MSG_ERR] ---
		start++;
	}
}

static void gen8_hwsched_process_dbgq(struct adreno_device *adreno_dev, bool limited)
{
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	u32 rcvd[MAX_RCVD_SIZE];
	bool recovery = false;

	while (gen8_hfi_queue_read(gmu, HFI_DBG_ID, rcvd, sizeof(rcvd)) > 0) {

		if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_ERR) {
			adreno_gen8_receive_err_req(gmu, rcvd);
			recovery = true;
			break;
		}

		if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_DEBUG)
			adreno_gen8_receive_debug_req(gmu, rcvd);

		if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_LOG_BLOCK)
			process_log_block(adreno_dev, rcvd);

		/* Process one debug queue message and return to not delay msgq processing */
		if (limited)
			break;
	}

	if (!recovery)
		return;

	gen8_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT);
}

/* HFI interrupt handler */
static irqreturn_t gen8_hwsched_hfi_handler(int irq, void *data)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1166 [MATCH: F2H_MSG_DEBUG] ---
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	u32 rcvd[MAX_RCVD_SIZE];
	bool recovery = false;

	while (gen8_hfi_queue_read(gmu, HFI_DBG_ID, rcvd, sizeof(rcvd)) > 0) {

		if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_ERR) {
			adreno_gen8_receive_err_req(gmu, rcvd);
			recovery = true;
			break;
		}

		if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_DEBUG)
			adreno_gen8_receive_debug_req(gmu, rcvd);

		if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_LOG_BLOCK)
			process_log_block(adreno_dev, rcvd);

		/* Process one debug queue message and return to not delay msgq processing */
		if (limited)
			break;
	}

	if (!recovery)
		return;

	gen8_hwsched_fault(adreno_dev, ADRENO_GMU_FAULT);
}

/* HFI interrupt handler */
static irqreturn_t gen8_hwsched_hfi_handler(int irq, void *data)
{
	struct adreno_device *adreno_dev = data;
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	u32 status = 0;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:105 [MATCH: CMP_HFI_ACK_HDR] ---
	u32 hdr = ack[0];
	u32 req_hdr = ack[1];
	u32 size_bytes = MSG_HDR_GET_SIZE(hdr) << 2;

	if (size_bytes > sizeof(cmd->results))
		dev_err_ratelimited(gmu_pdev_dev,
			"Ack result too big: %d Truncating to: %ld\n",
			size_bytes, sizeof(cmd->results));

	read_lock(&hfi->msglock);

	list_for_each_entry(cmd, &hfi->msglist, node) {
		if (CMP_HFI_ACK_HDR(cmd->sent_hdr, req_hdr)) {
			memcpy(cmd->results, ack,
				min_t(u32, size_bytes,
					sizeof(cmd->results)));
			complete(&cmd->complete);
			read_unlock(&hfi->msglock);
			return;
		}

		if (num_waiters < ARRAY_SIZE(waiters))
			waiters[num_waiters++] = cmd->sent_hdr;
	}

	read_unlock(&hfi->msglock);

	/* Didn't find the sender, list the waiter */
	dev_err_ratelimited(gmu_pdev_dev,
		"Unexpectedly got id %d seqnum %d. Total waiters: %d Top %d Waiters:\n",
		MSG_HDR_GET_ID(req_hdr), MSG_HDR_GET_SEQNUM(req_hdr),
		num_waiters, min_t(u32, num_waiters, 5));

	for (i = 0; i < num_waiters && i < 5; i++)
		dev_err_ratelimited(gmu_pdev_dev,
			" id %d seqnum %d\n",
			MSG_HDR_GET_ID(waiters[i]),

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1001 [MATCH: CMP_HFI_ACK_HDR] ---

static void process_hw_fence_ack(struct adreno_device *adreno_dev, u32 *rcvd)
{
	struct adreno_hwsched_hw_fence *hwf = &adreno_dev->hwsched.hw_fence;
	struct adreno_context *drawctxt = NULL;
	struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	spin_lock(&hwf->lock);

	/* If this ack is being waited on, we don't need to touch the unack count */
	if (gen8_hw_fence_ack.sent_hdr &&
	    CMP_HFI_ACK_HDR(gen8_hw_fence_ack.sent_hdr, rcvd[1])) {
		spin_unlock(&hwf->lock);
		complete(&gen8_hw_fence_ack.complete);
		return;
	}

	hwf->unack_count--;

	/* The unack count should never be greater than MAX_HW_FENCE_UNACK_COUNT */
	if (hwf->unack_count > MAX_HW_FENCE_UNACK_COUNT)
		dev_err(GMU_PDEV_DEV(device),
			"unexpected hardware fence unack count:%d\n",
			hwf->unack_count);

	if (_check_hw_fence_ack_failure(device, rcvd)) {
		spin_unlock(&hwf->lock);
		gen8_hwsched_fault(adreno_dev, GMU_FAULT_HW_FENCE);
		return;
	}

	if (!test_bit(GEN8_HWSCHED_HW_FENCE_MAX_BIT, &hwf->flags) ||
		(hwf->unack_count != MIN_HW_FENCE_UNACK_COUNT)) {
		spin_unlock(&hwf->lock);
		return;
	}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1851 [MATCH: ret_cmd] ---

	ret = CMD_MSG_HDR(cmd, H2F_MSG_WARMBOOT_CMD);
	if (ret)
		return ret;

	if (async)
		return gen8_hfi_send_cmd_async(adreno_dev, &cmd, sizeof(cmd));

	return gen8_hfi_send_generic_req_v5(adreno_dev, &cmd, ack, sizeof(cmd));
}

static int gen8_hwsched_hfi_warmboot_gpu_cmd(struct adreno_device *adreno_dev,
		struct pending_cmd *ret_cmd)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gmu_core_device *gmu_core = &device->gmu_core;
	struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev);
	struct hfi_warmboot_scratch_cmd cmd = {
		.scratch_addr = gmu->gpu_boot_scratch->gmuaddr,
		.scratch_size = gmu->gpu_boot_scratch->size,
		.flags = HFI_WARMBOOT_EXEC_SCRATCH,
	};
	int ret = 0;
	u32 seqnum;

	if (!gmu_core->warmboot_enabled)
		return 0;

	ret = CMD_MSG_HDR(cmd, H2F_MSG_WARMBOOT_CMD);
	if (ret)
		return ret;

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
	add_waiter(hfi, cmd.hdr, ret_cmd);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1875 [MATCH: ret_cmd] ---
	int ret = 0;
	u32 seqnum;

	if (!gmu_core->warmboot_enabled)
		return 0;

	ret = CMD_MSG_HDR(cmd, H2F_MSG_WARMBOOT_CMD);
	if (ret)
		return ret;

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
	add_waiter(hfi, cmd.hdr, ret_cmd);

	ret = gen8_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
	if (ret)
		goto err;

	ret = adreno_hwsched_wait_ack_completion(adreno_dev,
		gmu_pdev_dev, ret_cmd, gen8_hwsched_process_msgq);
err:
	del_waiter(hfi, ret_cmd);

	return ret;
}

static void print_warmboot_gpu_error(struct device *dev, struct pending_cmd *ret_cmd)
{
	dev_err(dev,
		"HFI ACK: Req=0x%8.8X, Result=0x%8.8X Error:0x%8.8X\n",
		ret_cmd->results[1], ret_cmd->results[2], ret_cmd->results[3]);
}

static int gen8_hwsched_warmboot_gpu(struct adreno_device *adreno_dev)
{
	struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1882 [MATCH: ret_cmd] ---
	if (ret)
		return ret;

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
	add_waiter(hfi, cmd.hdr, ret_cmd);

	ret = gen8_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
	if (ret)
		goto err;

	ret = adreno_hwsched_wait_ack_completion(adreno_dev,
		gmu_pdev_dev, ret_cmd, gen8_hwsched_process_msgq);
err:
	del_waiter(hfi, ret_cmd);

	return ret;
}

static void print_warmboot_gpu_error(struct device *dev, struct pending_cmd *ret_cmd)
{
	dev_err(dev,
		"HFI ACK: Req=0x%8.8X, Result=0x%8.8X Error:0x%8.8X\n",
		ret_cmd->results[1], ret_cmd->results[2], ret_cmd->results[3]);
}

static int gen8_hwsched_warmboot_gpu(struct adreno_device *adreno_dev)
{
	struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct pending_cmd ret_cmd = {0};
	int ret = 0;

	ret = gen8_hwsched_hfi_warmboot_gpu_cmd(adreno_dev, &ret_cmd);
	if (ret)
		goto err;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1884 [MATCH: ret_cmd] ---

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
	add_waiter(hfi, cmd.hdr, ret_cmd);

	ret = gen8_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
	if (ret)
		goto err;

	ret = adreno_hwsched_wait_ack_completion(adreno_dev,
		gmu_pdev_dev, ret_cmd, gen8_hwsched_process_msgq);
err:
	del_waiter(hfi, ret_cmd);

	return ret;
}

static void print_warmboot_gpu_error(struct device *dev, struct pending_cmd *ret_cmd)
{
	dev_err(dev,
		"HFI ACK: Req=0x%8.8X, Result=0x%8.8X Error:0x%8.8X\n",
		ret_cmd->results[1], ret_cmd->results[2], ret_cmd->results[3]);
}

static int gen8_hwsched_warmboot_gpu(struct adreno_device *adreno_dev)
{
	struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct pending_cmd ret_cmd = {0};
	int ret = 0;

	ret = gen8_hwsched_hfi_warmboot_gpu_cmd(adreno_dev, &ret_cmd);
	if (ret)
		goto err;

	/* Check if the ack belongs to the warmboot command */
	if (MSG_HDR_GET_ID(ret_cmd.results[0]) != H2F_MSG_WARMBOOT_CMD) {

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1889 [MATCH: ret_cmd] ---
	ret = gen8_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
	if (ret)
		goto err;

	ret = adreno_hwsched_wait_ack_completion(adreno_dev,
		gmu_pdev_dev, ret_cmd, gen8_hwsched_process_msgq);
err:
	del_waiter(hfi, ret_cmd);

	return ret;
}

static void print_warmboot_gpu_error(struct device *dev, struct pending_cmd *ret_cmd)
{
	dev_err(dev,
		"HFI ACK: Req=0x%8.8X, Result=0x%8.8X Error:0x%8.8X\n",
		ret_cmd->results[1], ret_cmd->results[2], ret_cmd->results[3]);
}

static int gen8_hwsched_warmboot_gpu(struct adreno_device *adreno_dev)
{
	struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct pending_cmd ret_cmd = {0};
	int ret = 0;

	ret = gen8_hwsched_hfi_warmboot_gpu_cmd(adreno_dev, &ret_cmd);
	if (ret)
		goto err;

	/* Check if the ack belongs to the warmboot command */
	if (MSG_HDR_GET_ID(ret_cmd.results[0]) != H2F_MSG_WARMBOOT_CMD) {
		ret = -EINVAL;
		goto err;
	}

	switch (ret_cmd.results[3]) {

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1893 [MATCH: ret_cmd] ---
	ret = adreno_hwsched_wait_ack_completion(adreno_dev,
		gmu_pdev_dev, ret_cmd, gen8_hwsched_process_msgq);
err:
	del_waiter(hfi, ret_cmd);

	return ret;
}

static void print_warmboot_gpu_error(struct device *dev, struct pending_cmd *ret_cmd)
{
	dev_err(dev,
		"HFI ACK: Req=0x%8.8X, Result=0x%8.8X Error:0x%8.8X\n",
		ret_cmd->results[1], ret_cmd->results[2], ret_cmd->results[3]);
}

static int gen8_hwsched_warmboot_gpu(struct adreno_device *adreno_dev)
{
	struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct pending_cmd ret_cmd = {0};
	int ret = 0;

	ret = gen8_hwsched_hfi_warmboot_gpu_cmd(adreno_dev, &ret_cmd);
	if (ret)
		goto err;

	/* Check if the ack belongs to the warmboot command */
	if (MSG_HDR_GET_ID(ret_cmd.results[0]) != H2F_MSG_WARMBOOT_CMD) {
		ret = -EINVAL;
		goto err;
	}

	switch (ret_cmd.results[3]) {
	/* If ack has no error code then GPU executed raw commands just fine */
	case GMU_SUCCESS:
		return ret_cmd.results[2];
	/* If GPU timedout processing raw commands, check which raw command failed */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1900 [MATCH: ret_cmd] ---

static void print_warmboot_gpu_error(struct device *dev, struct pending_cmd *ret_cmd)
{
	dev_err(dev,
		"HFI ACK: Req=0x%8.8X, Result=0x%8.8X Error:0x%8.8X\n",
		ret_cmd->results[1], ret_cmd->results[2], ret_cmd->results[3]);
}

static int gen8_hwsched_warmboot_gpu(struct adreno_device *adreno_dev)
{
	struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct pending_cmd ret_cmd = {0};
	int ret = 0;

	ret = gen8_hwsched_hfi_warmboot_gpu_cmd(adreno_dev, &ret_cmd);
	if (ret)
		goto err;

	/* Check if the ack belongs to the warmboot command */
	if (MSG_HDR_GET_ID(ret_cmd.results[0]) != H2F_MSG_WARMBOOT_CMD) {
		ret = -EINVAL;
		goto err;
	}

	switch (ret_cmd.results[3]) {
	/* If ack has no error code then GPU executed raw commands just fine */
	case GMU_SUCCESS:
		return ret_cmd.results[2];
	/* If GPU timedout processing raw commands, check which raw command failed */
	case GMU_ERROR_TIMEOUT: {
		if (MSG_HDR_GET_ID(ret_cmd.results[1]) == H2F_MSG_ISSUE_CMD_RAW) {

			/* Based on sequence number we can differentiate which command failed */
			if (ret_cmd.results[1] == gmu->cp_init_hdr)
				gen8_spin_idle_debug(adreno_dev,
					"CP initialization failed to idle\n");

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1903 [MATCH: ret_cmd] ---
	dev_err(dev,
		"HFI ACK: Req=0x%8.8X, Result=0x%8.8X Error:0x%8.8X\n",
		ret_cmd->results[1], ret_cmd->results[2], ret_cmd->results[3]);
}

static int gen8_hwsched_warmboot_gpu(struct adreno_device *adreno_dev)
{
	struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct pending_cmd ret_cmd = {0};
	int ret = 0;

	ret = gen8_hwsched_hfi_warmboot_gpu_cmd(adreno_dev, &ret_cmd);
	if (ret)
		goto err;

	/* Check if the ack belongs to the warmboot command */
	if (MSG_HDR_GET_ID(ret_cmd.results[0]) != H2F_MSG_WARMBOOT_CMD) {
		ret = -EINVAL;
		goto err;
	}

	switch (ret_cmd.results[3]) {
	/* If ack has no error code then GPU executed raw commands just fine */
	case GMU_SUCCESS:
		return ret_cmd.results[2];
	/* If GPU timedout processing raw commands, check which raw command failed */
	case GMU_ERROR_TIMEOUT: {
		if (MSG_HDR_GET_ID(ret_cmd.results[1]) == H2F_MSG_ISSUE_CMD_RAW) {

			/* Based on sequence number we can differentiate which command failed */
			if (ret_cmd.results[1] == gmu->cp_init_hdr)
				gen8_spin_idle_debug(adreno_dev,
					"CP initialization failed to idle\n");
			else if (ret_cmd.results[1] == gmu->switch_to_unsec_hdr)
				gen8_spin_idle_debug(adreno_dev,
					"Switch to unsecure failed to idle\n");

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1908 [MATCH: ret_cmd] ---
static int gen8_hwsched_warmboot_gpu(struct adreno_device *adreno_dev)
{
	struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct pending_cmd ret_cmd = {0};
	int ret = 0;

	ret = gen8_hwsched_hfi_warmboot_gpu_cmd(adreno_dev, &ret_cmd);
	if (ret)
		goto err;

	/* Check if the ack belongs to the warmboot command */
	if (MSG_HDR_GET_ID(ret_cmd.results[0]) != H2F_MSG_WARMBOOT_CMD) {
		ret = -EINVAL;
		goto err;
	}

	switch (ret_cmd.results[3]) {
	/* If ack has no error code then GPU executed raw commands just fine */
	case GMU_SUCCESS:
		return ret_cmd.results[2];
	/* If GPU timedout processing raw commands, check which raw command failed */
	case GMU_ERROR_TIMEOUT: {
		if (MSG_HDR_GET_ID(ret_cmd.results[1]) == H2F_MSG_ISSUE_CMD_RAW) {

			/* Based on sequence number we can differentiate which command failed */
			if (ret_cmd.results[1] == gmu->cp_init_hdr)
				gen8_spin_idle_debug(adreno_dev,
					"CP initialization failed to idle\n");
			else if (ret_cmd.results[1] == gmu->switch_to_unsec_hdr)
				gen8_spin_idle_debug(adreno_dev,
					"Switch to unsecure failed to idle\n");
		} else if (MSG_HDR_GET_ID(ret_cmd.results[1]) == H2F_MSG_ISSUE_LPAC_CMD_RAW) {
			gen8_spin_idle_debug_lpac(adreno_dev,
				"LPAC CP initialization failed to idle\n");
		} else {
			print_warmboot_gpu_error(gmu_pdev_dev, &ret_cmd);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1913 [MATCH: ret_cmd] ---
	int ret = 0;

	ret = gen8_hwsched_hfi_warmboot_gpu_cmd(adreno_dev, &ret_cmd);
	if (ret)
		goto err;

	/* Check if the ack belongs to the warmboot command */
	if (MSG_HDR_GET_ID(ret_cmd.results[0]) != H2F_MSG_WARMBOOT_CMD) {
		ret = -EINVAL;
		goto err;
	}

	switch (ret_cmd.results[3]) {
	/* If ack has no error code then GPU executed raw commands just fine */
	case GMU_SUCCESS:
		return ret_cmd.results[2];
	/* If GPU timedout processing raw commands, check which raw command failed */
	case GMU_ERROR_TIMEOUT: {
		if (MSG_HDR_GET_ID(ret_cmd.results[1]) == H2F_MSG_ISSUE_CMD_RAW) {

			/* Based on sequence number we can differentiate which command failed */
			if (ret_cmd.results[1] == gmu->cp_init_hdr)
				gen8_spin_idle_debug(adreno_dev,
					"CP initialization failed to idle\n");
			else if (ret_cmd.results[1] == gmu->switch_to_unsec_hdr)
				gen8_spin_idle_debug(adreno_dev,
					"Switch to unsecure failed to idle\n");
		} else if (MSG_HDR_GET_ID(ret_cmd.results[1]) == H2F_MSG_ISSUE_LPAC_CMD_RAW) {
			gen8_spin_idle_debug_lpac(adreno_dev,
				"LPAC CP initialization failed to idle\n");
		} else {
			print_warmboot_gpu_error(gmu_pdev_dev, &ret_cmd);
		}
		ret = -EINVAL;
		break;
	}
	default:

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1916 [MATCH: ret_cmd] ---
	if (ret)
		goto err;

	/* Check if the ack belongs to the warmboot command */
	if (MSG_HDR_GET_ID(ret_cmd.results[0]) != H2F_MSG_WARMBOOT_CMD) {
		ret = -EINVAL;
		goto err;
	}

	switch (ret_cmd.results[3]) {
	/* If ack has no error code then GPU executed raw commands just fine */
	case GMU_SUCCESS:
		return ret_cmd.results[2];
	/* If GPU timedout processing raw commands, check which raw command failed */
	case GMU_ERROR_TIMEOUT: {
		if (MSG_HDR_GET_ID(ret_cmd.results[1]) == H2F_MSG_ISSUE_CMD_RAW) {

			/* Based on sequence number we can differentiate which command failed */
			if (ret_cmd.results[1] == gmu->cp_init_hdr)
				gen8_spin_idle_debug(adreno_dev,
					"CP initialization failed to idle\n");
			else if (ret_cmd.results[1] == gmu->switch_to_unsec_hdr)
				gen8_spin_idle_debug(adreno_dev,
					"Switch to unsecure failed to idle\n");
		} else if (MSG_HDR_GET_ID(ret_cmd.results[1]) == H2F_MSG_ISSUE_LPAC_CMD_RAW) {
			gen8_spin_idle_debug_lpac(adreno_dev,
				"LPAC CP initialization failed to idle\n");
		} else {
			print_warmboot_gpu_error(gmu_pdev_dev, &ret_cmd);
		}
		ret = -EINVAL;
		break;
	}
	default:
		print_warmboot_gpu_error(gmu_pdev_dev, &ret_cmd);
		ret = -EINVAL;
		break;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1919 [MATCH: ret_cmd] ---
	/* Check if the ack belongs to the warmboot command */
	if (MSG_HDR_GET_ID(ret_cmd.results[0]) != H2F_MSG_WARMBOOT_CMD) {
		ret = -EINVAL;
		goto err;
	}

	switch (ret_cmd.results[3]) {
	/* If ack has no error code then GPU executed raw commands just fine */
	case GMU_SUCCESS:
		return ret_cmd.results[2];
	/* If GPU timedout processing raw commands, check which raw command failed */
	case GMU_ERROR_TIMEOUT: {
		if (MSG_HDR_GET_ID(ret_cmd.results[1]) == H2F_MSG_ISSUE_CMD_RAW) {

			/* Based on sequence number we can differentiate which command failed */
			if (ret_cmd.results[1] == gmu->cp_init_hdr)
				gen8_spin_idle_debug(adreno_dev,
					"CP initialization failed to idle\n");
			else if (ret_cmd.results[1] == gmu->switch_to_unsec_hdr)
				gen8_spin_idle_debug(adreno_dev,
					"Switch to unsecure failed to idle\n");
		} else if (MSG_HDR_GET_ID(ret_cmd.results[1]) == H2F_MSG_ISSUE_LPAC_CMD_RAW) {
			gen8_spin_idle_debug_lpac(adreno_dev,
				"LPAC CP initialization failed to idle\n");
		} else {
			print_warmboot_gpu_error(gmu_pdev_dev, &ret_cmd);
		}
		ret = -EINVAL;
		break;
	}
	default:
		print_warmboot_gpu_error(gmu_pdev_dev, &ret_cmd);
		ret = -EINVAL;
		break;
	}
err:
	/* Clear the bit on error so that in the next slumber exit we coldboot */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1922 [MATCH: ret_cmd] ---
		goto err;
	}

	switch (ret_cmd.results[3]) {
	/* If ack has no error code then GPU executed raw commands just fine */
	case GMU_SUCCESS:
		return ret_cmd.results[2];
	/* If GPU timedout processing raw commands, check which raw command failed */
	case GMU_ERROR_TIMEOUT: {
		if (MSG_HDR_GET_ID(ret_cmd.results[1]) == H2F_MSG_ISSUE_CMD_RAW) {

			/* Based on sequence number we can differentiate which command failed */
			if (ret_cmd.results[1] == gmu->cp_init_hdr)
				gen8_spin_idle_debug(adreno_dev,
					"CP initialization failed to idle\n");
			else if (ret_cmd.results[1] == gmu->switch_to_unsec_hdr)
				gen8_spin_idle_debug(adreno_dev,
					"Switch to unsecure failed to idle\n");
		} else if (MSG_HDR_GET_ID(ret_cmd.results[1]) == H2F_MSG_ISSUE_LPAC_CMD_RAW) {
			gen8_spin_idle_debug_lpac(adreno_dev,
				"LPAC CP initialization failed to idle\n");
		} else {
			print_warmboot_gpu_error(gmu_pdev_dev, &ret_cmd);
		}
		ret = -EINVAL;
		break;
	}
	default:
		print_warmboot_gpu_error(gmu_pdev_dev, &ret_cmd);
		ret = -EINVAL;
		break;
	}
err:
	/* Clear the bit on error so that in the next slumber exit we coldboot */
	clear_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags);
	gen8_disable_gpu_irq(adreno_dev);
	return ret;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1925 [MATCH: ret_cmd] ---
	switch (ret_cmd.results[3]) {
	/* If ack has no error code then GPU executed raw commands just fine */
	case GMU_SUCCESS:
		return ret_cmd.results[2];
	/* If GPU timedout processing raw commands, check which raw command failed */
	case GMU_ERROR_TIMEOUT: {
		if (MSG_HDR_GET_ID(ret_cmd.results[1]) == H2F_MSG_ISSUE_CMD_RAW) {

			/* Based on sequence number we can differentiate which command failed */
			if (ret_cmd.results[1] == gmu->cp_init_hdr)
				gen8_spin_idle_debug(adreno_dev,
					"CP initialization failed to idle\n");
			else if (ret_cmd.results[1] == gmu->switch_to_unsec_hdr)
				gen8_spin_idle_debug(adreno_dev,
					"Switch to unsecure failed to idle\n");
		} else if (MSG_HDR_GET_ID(ret_cmd.results[1]) == H2F_MSG_ISSUE_LPAC_CMD_RAW) {
			gen8_spin_idle_debug_lpac(adreno_dev,
				"LPAC CP initialization failed to idle\n");
		} else {
			print_warmboot_gpu_error(gmu_pdev_dev, &ret_cmd);
		}
		ret = -EINVAL;
		break;
	}
	default:
		print_warmboot_gpu_error(gmu_pdev_dev, &ret_cmd);
		ret = -EINVAL;
		break;
	}
err:
	/* Clear the bit on error so that in the next slumber exit we coldboot */
	clear_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags);
	gen8_disable_gpu_irq(adreno_dev);
	return ret;
}

static int gen8_hwsched_coldboot_gpu(struct adreno_device *adreno_dev)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1928 [MATCH: ret_cmd] ---
		return ret_cmd.results[2];
	/* If GPU timedout processing raw commands, check which raw command failed */
	case GMU_ERROR_TIMEOUT: {
		if (MSG_HDR_GET_ID(ret_cmd.results[1]) == H2F_MSG_ISSUE_CMD_RAW) {

			/* Based on sequence number we can differentiate which command failed */
			if (ret_cmd.results[1] == gmu->cp_init_hdr)
				gen8_spin_idle_debug(adreno_dev,
					"CP initialization failed to idle\n");
			else if (ret_cmd.results[1] == gmu->switch_to_unsec_hdr)
				gen8_spin_idle_debug(adreno_dev,
					"Switch to unsecure failed to idle\n");
		} else if (MSG_HDR_GET_ID(ret_cmd.results[1]) == H2F_MSG_ISSUE_LPAC_CMD_RAW) {
			gen8_spin_idle_debug_lpac(adreno_dev,
				"LPAC CP initialization failed to idle\n");
		} else {
			print_warmboot_gpu_error(gmu_pdev_dev, &ret_cmd);
		}
		ret = -EINVAL;
		break;
	}
	default:
		print_warmboot_gpu_error(gmu_pdev_dev, &ret_cmd);
		ret = -EINVAL;
		break;
	}
err:
	/* Clear the bit on error so that in the next slumber exit we coldboot */
	clear_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags);
	gen8_disable_gpu_irq(adreno_dev);
	return ret;
}

static int gen8_hwsched_coldboot_gpu(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gmu_core_device *gmu_core = &device->gmu_core;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1932 [MATCH: ret_cmd] ---

			/* Based on sequence number we can differentiate which command failed */
			if (ret_cmd.results[1] == gmu->cp_init_hdr)
				gen8_spin_idle_debug(adreno_dev,
					"CP initialization failed to idle\n");
			else if (ret_cmd.results[1] == gmu->switch_to_unsec_hdr)
				gen8_spin_idle_debug(adreno_dev,
					"Switch to unsecure failed to idle\n");
		} else if (MSG_HDR_GET_ID(ret_cmd.results[1]) == H2F_MSG_ISSUE_LPAC_CMD_RAW) {
			gen8_spin_idle_debug_lpac(adreno_dev,
				"LPAC CP initialization failed to idle\n");
		} else {
			print_warmboot_gpu_error(gmu_pdev_dev, &ret_cmd);
		}
		ret = -EINVAL;
		break;
	}
	default:
		print_warmboot_gpu_error(gmu_pdev_dev, &ret_cmd);
		ret = -EINVAL;
		break;
	}
err:
	/* Clear the bit on error so that in the next slumber exit we coldboot */
	clear_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags);
	gen8_disable_gpu_irq(adreno_dev);
	return ret;
}

static int gen8_hwsched_coldboot_gpu(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gmu_core_device *gmu_core = &device->gmu_core;
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct gen8_hfi *hfi = to_gen8_hfi(adreno_dev);
	struct pending_cmd ack = {0};
	int ret = 0;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1938 [MATCH: ret_cmd] ---
				gen8_spin_idle_debug(adreno_dev,
					"Switch to unsecure failed to idle\n");
		} else if (MSG_HDR_GET_ID(ret_cmd.results[1]) == H2F_MSG_ISSUE_LPAC_CMD_RAW) {
			gen8_spin_idle_debug_lpac(adreno_dev,
				"LPAC CP initialization failed to idle\n");
		} else {
			print_warmboot_gpu_error(gmu_pdev_dev, &ret_cmd);
		}
		ret = -EINVAL;
		break;
	}
	default:
		print_warmboot_gpu_error(gmu_pdev_dev, &ret_cmd);
		ret = -EINVAL;
		break;
	}
err:
	/* Clear the bit on error so that in the next slumber exit we coldboot */
	clear_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags);
	gen8_disable_gpu_irq(adreno_dev);
	return ret;
}

static int gen8_hwsched_coldboot_gpu(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gmu_core_device *gmu_core = &device->gmu_core;
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct gen8_hfi *hfi = to_gen8_hfi(adreno_dev);
	struct pending_cmd ack = {0};
	int ret = 0;

	ret = gen8_hwsched_hfi_send_warmboot_cmd(adreno_dev, gmu->gpu_boot_scratch,
		 HFI_WARMBOOT_SET_SCRATCH, true, &ack);
	if (ret)
		goto done;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:4239 [MATCH: ret_cmd] ---
		return ret;

	ret = gen8_hwsched_process_detached_hw_fences(adreno_dev);
	if (ret)
		return ret;

	return gen8_hwsched_disable_hw_fence_throttle(adreno_dev);
}

static int gen8_hwsched_hfi_msg_reply(struct adreno_device *adreno_dev,
		enum hfi_msg_type msg, u32 hdr)
{
	struct hfi_msg_ret_cmd out = {0};
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	u32 seqnum;

	out.hdr = ACK_MSG_HDR(msg);
	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	out.hdr = MSG_HDR_SET_SEQNUM_SIZE(out.hdr, seqnum, sizeof(out) >> 2);
	out.error = GMU_SUCCESS;
	out.req_hdr = hdr;

	return gen8_hfi_cmdq_write(adreno_dev, (u32 *)&out, sizeof(out));
}

static void _do_gbif_halt(struct kgsl_device *device, u32 reg, u32 ack_reg,
			  u32 mask, u32 ack_mask, const char *client)
{
	u32 ack;
	unsigned long t;

	kgsl_regwrite(device, reg, mask);

	t = jiffies + msecs_to_jiffies(100);
	do {
		kgsl_regread(device, ack_reg, &ack);
		if ((ack & ack_mask) == ack_mask)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:45 [MATCH: pending_cmd] ---
		.unused2 = 0, \
		.unused3 = 0, \
		.unused4 = 0, \
		.read_index = 0, \
		.write_index = 0, \
}

/* The GMU buffer address corresponds to the beginning of
 * half the size of the shared buffer.
 */
#define GMU_BUF_ADDR(md) ((md.gmuaddr) + (md.size >> 1))

struct pending_cmd gen8_hw_fence_ack;

struct gen8_hwsched_hfi *to_gen8_hwsched_hfi(
	struct adreno_device *adreno_dev)
{
	struct gen8_device *gen8_dev = container_of(adreno_dev,
					struct gen8_device, adreno_dev);
	struct gen8_hwsched_device *gen8_hwsched = container_of(gen8_dev,
					struct gen8_hwsched_device, gen8_dev);

	return &gen8_hwsched->hwsched_hfi;
}

int gen8_hfi_send_lpac_feature_ctrl(struct adreno_device *adreno_dev)
{
	if (!adreno_dev->lpac_enabled)
		return 0;

	return gen8_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_LPAC, 1, 0);
}

static void add_waiter(struct gen8_hwsched_hfi *hfi, u32 hdr,
	struct pending_cmd *ack)
{
	memset(ack, 0x0, sizeof(*ack));

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:67 [MATCH: pending_cmd] ---
	return &gen8_hwsched->hwsched_hfi;
}

int gen8_hfi_send_lpac_feature_ctrl(struct adreno_device *adreno_dev)
{
	if (!adreno_dev->lpac_enabled)
		return 0;

	return gen8_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_LPAC, 1, 0);
}

static void add_waiter(struct gen8_hwsched_hfi *hfi, u32 hdr,
	struct pending_cmd *ack)
{
	memset(ack, 0x0, sizeof(*ack));

	init_completion(&ack->complete);
	write_lock_irq(&hfi->msglock);
	list_add_tail(&ack->node, &hfi->msglist);
	write_unlock_irq(&hfi->msglock);

	ack->sent_hdr = hdr;
}

static void del_waiter(struct gen8_hwsched_hfi *hfi, struct pending_cmd *ack)
{
	write_lock_irq(&hfi->msglock);
	list_del(&ack->node);
	write_unlock_irq(&hfi->msglock);
}

static void gen8_receive_ack_async(struct adreno_device *adreno_dev, void *rcvd)
{
	struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
	struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev);
	struct pending_cmd *cmd = NULL;
	u32 waiters[64], num_waiters = 0, i;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:79 [MATCH: pending_cmd] ---
	struct pending_cmd *ack)
{
	memset(ack, 0x0, sizeof(*ack));

	init_completion(&ack->complete);
	write_lock_irq(&hfi->msglock);
	list_add_tail(&ack->node, &hfi->msglist);
	write_unlock_irq(&hfi->msglock);

	ack->sent_hdr = hdr;
}

static void del_waiter(struct gen8_hwsched_hfi *hfi, struct pending_cmd *ack)
{
	write_lock_irq(&hfi->msglock);
	list_del(&ack->node);
	write_unlock_irq(&hfi->msglock);
}

static void gen8_receive_ack_async(struct adreno_device *adreno_dev, void *rcvd)
{
	struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
	struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev);
	struct pending_cmd *cmd = NULL;
	u32 waiters[64], num_waiters = 0, i;
	u32 *ack = rcvd;
	u32 hdr = ack[0];
	u32 req_hdr = ack[1];
	u32 size_bytes = MSG_HDR_GET_SIZE(hdr) << 2;

	if (size_bytes > sizeof(cmd->results))
		dev_err_ratelimited(gmu_pdev_dev,
			"Ack result too big: %d Truncating to: %ld\n",
			size_bytes, sizeof(cmd->results));

	read_lock(&hfi->msglock);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:90 [MATCH: pending_cmd] ---

static void del_waiter(struct gen8_hwsched_hfi *hfi, struct pending_cmd *ack)
{
	write_lock_irq(&hfi->msglock);
	list_del(&ack->node);
	write_unlock_irq(&hfi->msglock);
}

static void gen8_receive_ack_async(struct adreno_device *adreno_dev, void *rcvd)
{
	struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
	struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev);
	struct pending_cmd *cmd = NULL;
	u32 waiters[64], num_waiters = 0, i;
	u32 *ack = rcvd;
	u32 hdr = ack[0];
	u32 req_hdr = ack[1];
	u32 size_bytes = MSG_HDR_GET_SIZE(hdr) << 2;

	if (size_bytes > sizeof(cmd->results))
		dev_err_ratelimited(gmu_pdev_dev,
			"Ack result too big: %d Truncating to: %ld\n",
			size_bytes, sizeof(cmd->results));

	read_lock(&hfi->msglock);

	list_for_each_entry(cmd, &hfi->msglist, node) {
		if (CMP_HFI_ACK_HDR(cmd->sent_hdr, req_hdr)) {
			memcpy(cmd->results, ack,
				min_t(u32, size_bytes,
					sizeof(cmd->results)));
			complete(&cmd->complete);
			read_unlock(&hfi->msglock);
			return;
		}

		if (num_waiters < ARRAY_SIZE(waiters))

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1242 [MATCH: pending_cmd] ---

	if (status & ~hfi->irq_mask)
		dev_err_ratelimited(GMU_PDEV_DEV(device),
			"Unhandled HFI interrupts 0x%x\n",
			status & ~hfi->irq_mask);

	return IRQ_HANDLED;
}

#define HFI_IRQ_MSGQ_MASK BIT(0)

static int check_ack_failure(struct adreno_device *adreno_dev,
	struct pending_cmd *ack)
{
	const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	u64 ticks = gpudev->read_alwayson(adreno_dev);

	if (ack->results[2] != 0xffffffff)
		return 0;

	dev_err(GMU_PDEV_DEV(device),
		"ACK error: sender id %d seqnum %d\n",
		MSG_HDR_GET_ID(ack->sent_hdr),
		MSG_HDR_GET_SEQNUM(ack->sent_hdr));

	KGSL_GMU_CORE_FORCE_PANIC(device->gmu_core.gf_panic,
				GMU_PDEV(device), ticks, GMU_FAULT_HFI_ACK);
	return -EINVAL;
}

int gen8_hfi_send_cmd_async(struct adreno_device *adreno_dev, void *data, u32 size_bytes)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev);
	u32 *cmd = data;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1269 [MATCH: pending_cmd] ---
				GMU_PDEV(device), ticks, GMU_FAULT_HFI_ACK);
	return -EINVAL;
}

int gen8_hfi_send_cmd_async(struct adreno_device *adreno_dev, void *data, u32 size_bytes)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev);
	u32 *cmd = data;
	u32 seqnum;
	int rc;
	struct pending_cmd pending_ack;

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	*cmd = MSG_HDR_SET_SEQNUM_SIZE(*cmd, seqnum, size_bytes >> 2);

	add_waiter(hfi, *cmd, &pending_ack);

	rc = gen8_hfi_cmdq_write(adreno_dev, cmd, size_bytes);
	if (rc)
		goto done;

	rc = adreno_hwsched_wait_ack_completion(adreno_dev,
		GMU_PDEV_DEV(device), &pending_ack, gen8_hwsched_process_msgq);
	if (rc)
		goto done;

	rc = check_ack_failure(adreno_dev, &pending_ack);

done:
	del_waiter(hfi, &pending_ack);

	return rc;
}

static void init_queues(struct gen8_hfi *hfi)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1442 [MATCH: pending_cmd] ---

	return gen8_hfi_send_generic_req(adreno_dev, &cmd, sizeof(cmd));
}

static int send_start_msg(struct adreno_device *adreno_dev)
{
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct device *gmu_pdev_dev = GMU_PDEV_DEV(device);
	int ret, rc = 0;
	struct hfi_start_cmd cmd;
	u32 seqnum, rcvd[MAX_RCVD_SIZE];
	struct pending_cmd pending_ack = {0};

	ret = CMD_MSG_HDR(cmd, H2F_MSG_START);
	if (ret)
		return ret;

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);

	pending_ack.sent_hdr = cmd.hdr;

	rc = gen8_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
	if (rc)
		return rc;

poll:
	rc = adreno_hwsched_poll_msg_queue_write_index(gmu->hfi.hfi_mem);

	if (rc) {
		dev_err(gmu_pdev_dev,
			"Timed out processing MSG_START seqnum: %d\n",
			seqnum);
		gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START);
		goto done;
	}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1665 [MATCH: pending_cmd] ---
		return gen8_hfi_send_feature_ctrl(adreno_dev,
				HFI_FEATURE_PERF_NORETAIN, 0, 0);

	return 0;
}

u32 gen8_hwsched_hfi_get_value(struct adreno_device *adreno_dev, u32 prop, u32 subtype)
{
	struct hfi_get_value_cmd cmd;
	struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev);
	struct pending_cmd pending_ack;
	u32 seqnum;
	int rc;

	rc = CMD_MSG_HDR(cmd, H2F_MSG_GET_VALUE);
	if (rc)
		return 0;

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
	cmd.type = prop;
	cmd.subtype = subtype;

	add_waiter(hfi, cmd.hdr, &pending_ack);

	rc = gen8_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
	if (rc)
		goto done;

	rc = adreno_hwsched_wait_ack_completion(adreno_dev,
		gmu_pdev_dev, &pending_ack, gen8_hwsched_process_msgq);

done:
	del_waiter(hfi, &pending_ack);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1700 [MATCH: pending_cmd] ---
	del_waiter(hfi, &pending_ack);

	if (rc || (pending_ack.results[2] == UINT_MAX))
		return 0;

	return pending_ack.results[2];
}

int gen8_hwsched_hfi_set_value(struct adreno_device *adreno_dev, u32 type, u32 subtype, u32 data)
{
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev);
	struct pending_cmd pending_ack;
	int rc;
	u32 seqnum;
	struct hfi_set_value_cmd cmd = {
		.type = type,
		.subtype = subtype,
		.data = data,
	};

	rc = CMD_MSG_HDR(cmd, H2F_MSG_SET_VALUE);
	if (rc)
		return 0;

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);

	add_waiter(hfi, cmd.hdr, &pending_ack);

	rc = gen8_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
	if (rc)
		goto done;

	rc = adreno_hwsched_wait_ack_completion(adreno_dev, GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),
			&pending_ack, gen8_hwsched_process_msgq);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1826 [MATCH: pending_cmd] ---
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gmu_core_device *gmu_core = &device->gmu_core;

	if (gmu_core->warmboot_enabled && test_bit(GMU_PRIV_WARMBOOT_GMU_INIT_DONE, &gmu->flags)
		&& test_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags) &&
		!test_bit(GMU_FORCE_COLDBOOT, &device->gmu_core.flags))
		return true;

	return false;
}

static int gen8_hwsched_hfi_send_warmboot_cmd(struct adreno_device *adreno_dev,
		struct kgsl_memdesc *desc, u32 flag, bool async, struct pending_cmd *ack)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gmu_core_device *gmu_core = &device->gmu_core;
	struct hfi_warmboot_scratch_cmd cmd = {0};
	int ret;

	if (!gmu_core->warmboot_enabled)
		return 0;

	cmd.scratch_addr = desc->gmuaddr;
	cmd.scratch_size =  desc->size;
	cmd.flags = flag;

	ret = CMD_MSG_HDR(cmd, H2F_MSG_WARMBOOT_CMD);
	if (ret)
		return ret;

	if (async)
		return gen8_hfi_send_cmd_async(adreno_dev, &cmd, sizeof(cmd));

	return gen8_hfi_send_generic_req_v5(adreno_dev, &cmd, ack, sizeof(cmd));
}

static int gen8_hwsched_hfi_warmboot_gpu_cmd(struct adreno_device *adreno_dev,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1955 [MATCH: pending_cmd] ---
	/* Clear the bit on error so that in the next slumber exit we coldboot */
	clear_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags);
	gen8_disable_gpu_irq(adreno_dev);
	return ret;
}

static int gen8_hwsched_coldboot_gpu(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gmu_core_device *gmu_core = &device->gmu_core;
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct gen8_hfi *hfi = to_gen8_hfi(adreno_dev);
	struct pending_cmd ack = {0};
	int ret = 0;

	ret = gen8_hwsched_hfi_send_warmboot_cmd(adreno_dev, gmu->gpu_boot_scratch,
		 HFI_WARMBOOT_SET_SCRATCH, true, &ack);
	if (ret)
		goto done;

	ret = gen8_hwsched_cp_init(adreno_dev);
	if (ret)
		goto done;

	ret = gen8_hwsched_lpac_cp_init(adreno_dev);
	if (ret)
		goto done;

	ret = gen8_hwsched_hfi_send_warmboot_cmd(adreno_dev, gmu->gpu_boot_scratch,
		HFI_WARMBOOT_QUERY_SCRATCH, true, &ack);
	if (ret)
		goto done;

	if (gmu_core->warmboot_enabled)
		set_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags);

done:

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:2035 [MATCH: pending_cmd] ---
		adreno_dev->patch_reglist = true;
	}

	return ret;
}

static int gen8_hwsched_hfi_set_tunables(struct adreno_device *adreno_dev, u32 type, u32 subtype,
		u32 val, u32 *ret)
{
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev);
	struct pending_cmd pending_ack;
	int rc;
	u32 seqnum;
	struct hfi_set_value_cmd cmd = {
		.type = type,
		.subtype = subtype,
		.data = val,
	};

	rc = CMD_MSG_HDR(cmd, H2F_MSG_SET_VALUE);
	if (rc)
		return rc;

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);

	add_waiter(hfi, cmd.hdr, &pending_ack);

	rc = gen8_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
	if (rc)
		goto done;

	rc = adreno_hwsched_wait_ack_completion(adreno_dev, GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev)),
			&pending_ack, gen8_hwsched_process_msgq);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:2142 [MATCH: pending_cmd] ---
					hwsched->sysfs_dcvs_tunables[i].value);
		}
	}
}

void gen8_hwsched_hfi_get_dcvs_tuning_attrs(struct adreno_device *adreno_dev,
	u32 subtype, u32 *data)
{
	struct hfi_get_value_cmd cmd;
	struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev);
	struct pending_cmd pending_ack;
	u32 seqnum;
	u32 num_values;
	u32 total_dwords;
	u32 hdr_size_in_dwords = 2;
	int ret;

	ret = CMD_MSG_HDR(cmd, H2F_MSG_GET_VALUE);
	if (ret)
		return;

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
	cmd.type = HFI_VALUE_DCVS_TUNING_PARAM;
	cmd.subtype = subtype;

	add_waiter(hfi, cmd.hdr, &pending_ack);

	ret = gen8_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
	if (ret)
		goto done;

	ret = adreno_hwsched_wait_ack_completion(adreno_dev,
		gmu_pdev_dev, &pending_ack, gen8_hwsched_process_msgq);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:2241 [MATCH: pending_cmd] ---
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	if (device->host_based_dcvs)
		return kgsl_pwrctrl_setup_default_votes(device);

	return gen8_hwsched_set_gmu_based_dcvs_votes(adreno_dev);
}

int gen8_hwsched_warmboot_init_gmu(struct adreno_device *adreno_dev)
{
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct pending_cmd ack = {0};
	int ret = 0;

	ret = gen8_hwsched_hfi_send_warmboot_cmd(adreno_dev, gmu->gmu_init_scratch,
		 HFI_WARMBOOT_EXEC_SCRATCH, false, &ack);
	if (ret)
		goto err;

	gen8_hwsched_enable_async_hfi(adreno_dev);

	set_bit(GMU_PRIV_HFI_STARTED, &gmu->flags);

	ret = gen8_hwsched_setup_default_votes(adreno_dev);

err:
	if (ret) {
		/* Clear the bit in case of an error so next boot will be coldboot */
		clear_bit(GMU_PRIV_WARMBOOT_GMU_INIT_DONE, &gmu->flags);
		clear_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags);
		gen8_hwsched_hfi_stop(adreno_dev);
	}

	return ret;
}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:2680 [MATCH: pending_cmd] ---
			goto err;
	}

err:
	return ret;
}

int gen8_hwsched_hfi_start(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gmu_core_device *gmu_core = &device->gmu_core;
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct pending_cmd ack = {0};
	int ret;

	reset_hfi_queues(adreno_dev);

	ret = gen8_gmu_hfi_start(adreno_dev);
	if (ret)
		goto err;

	if (gen8_hwsched_warmboot_possible(adreno_dev))
		return gen8_hwsched_warmboot_init_gmu(adreno_dev);

	if (ADRENO_FEATURE(adreno_dev, ADRENO_GMU_WARMBOOT) &&
		(!test_bit(GMU_PRIV_FIRST_BOOT_DONE, &gmu->flags))) {
		if (gen8_hfi_send_get_value(adreno_dev, HFI_VALUE_GMU_WARMBOOT, 0) == 1)
			gmu_core->warmboot_enabled = true;
	}

	warmboot_init_message_record_bitmask(adreno_dev);

	/* Reset the variable here and set it when we successfully record the scratch */
	clear_bit(GMU_PRIV_WARMBOOT_GMU_INIT_DONE, &gmu->flags);
	clear_bit(GMU_PRIV_WARMBOOT_GPU_BOOT_DONE, &gmu->flags);

	ret = gen8_hwsched_hfi_send_warmboot_cmd(adreno_dev, gmu->gmu_init_scratch,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:4125 [MATCH: pending_cmd] ---
	}

	return ret;
}

static int send_context_unregister_hfi(struct adreno_device *adreno_dev,
	struct kgsl_context *context, u32 ts)
{
	struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev);
	struct adreno_context *drawctxt = ADRENO_CONTEXT(context);
	struct pending_cmd pending_ack;
	struct hfi_unregister_ctxt_cmd cmd;
	struct kgsl_process_private *proc_priv = drawctxt->base.proc_priv;
	u32 seqnum;
	int ret;

	/* Only send HFI if device is not in SLUMBER */
	if (!context->gmu_registered ||
		!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags)) {
		drain_context_hw_fences(adreno_dev, drawctxt);
		proc_priv->profile.gmu_registered = false;

		return 0;
	}

	ret = CMD_MSG_HDR(cmd, H2F_MSG_UNREGISTER_CONTEXT);
	if (ret)
		return ret;

	cmd.ctxt_id = context->id,
	cmd.ts = ts,

	/*
	 * Although we know device is powered on, we can still enter SLUMBER
	 * because the wait for ack below is done without holding the mutex. So

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:516 [MATCH: F2H_MSG_ERR] ---
	H2F_MSG_CLX_TBL			= 8,
	H2F_MSG_THERM_TBL		= 9,
	H2F_MSG_START			= 10,
	H2F_MSG_FEATURE_CTRL		= 11,
	H2F_MSG_GET_VALUE		= 12,
	H2F_MSG_SET_VALUE		= 13,
	H2F_MSG_CORE_FW_START		= 14,
	H2F_MSG_TABLE			= 15,
	F2H_MSG_MEM_ALLOC		= 20,
	H2F_MSG_GX_BW_PERF_VOTE		= 30,
	H2F_MSG_FW_HALT			= 32,
	H2F_MSG_PREPARE_SLUMBER		= 33,
	F2H_MSG_ERR			= 100,
	F2H_MSG_DEBUG			= 101,
	F2H_MSG_LOG_BLOCK		= 102,
	F2H_MSG_GMU_CNTR_REGISTER	= 110,
	F2H_MSG_GMU_CNTR_RELEASE	= 111,
	F2H_MSG_ACK			= 126, /* Deprecated for v2.0*/
	H2F_MSG_ACK			= 127, /* Deprecated for v2.0*/
	H2F_MSG_REGISTER_CONTEXT	= 128,
	H2F_MSG_UNREGISTER_CONTEXT	= 129,
	H2F_MSG_ISSUE_CMD		= 130,
	H2F_MSG_ISSUE_CMD_RAW		= 131,
	H2F_MSG_TS_NOTIFY		= 132,
	F2H_MSG_TS_RETIRE		= 133,
	H2F_MSG_CONTEXT_POINTERS	= 134,
	H2F_MSG_ISSUE_LPAC_CMD_RAW	= 135,
	H2F_MSG_CONTEXT_RULE		= 140, /* AKA constraint */
	H2F_MSG_ISSUE_RECURRING_CMD	= 141,
	F2H_MSG_CONTEXT_BAD		= 150,
	H2F_MSG_HW_FENCE_INFO		= 151,
	H2F_MSG_ISSUE_SYNCOBJ		= 152,
	F2H_MSG_SYNCOBJ_QUERY		= 153,
	H2F_MSG_WARMBOOT_CMD		= 154,
	F2H_MSG_PROCESS_TRACE		= 155,
	F2H_MSG_PLATFORM_LA		= 200,
	H2F_MSG_PLATFORM_LA		= 201,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:517 [MATCH: F2H_MSG_DEBUG] ---
	H2F_MSG_THERM_TBL		= 9,
	H2F_MSG_START			= 10,
	H2F_MSG_FEATURE_CTRL		= 11,
	H2F_MSG_GET_VALUE		= 12,
	H2F_MSG_SET_VALUE		= 13,
	H2F_MSG_CORE_FW_START		= 14,
	H2F_MSG_TABLE			= 15,
	F2H_MSG_MEM_ALLOC		= 20,
	H2F_MSG_GX_BW_PERF_VOTE		= 30,
	H2F_MSG_FW_HALT			= 32,
	H2F_MSG_PREPARE_SLUMBER		= 33,
	F2H_MSG_ERR			= 100,
	F2H_MSG_DEBUG			= 101,
	F2H_MSG_LOG_BLOCK		= 102,
	F2H_MSG_GMU_CNTR_REGISTER	= 110,
	F2H_MSG_GMU_CNTR_RELEASE	= 111,
	F2H_MSG_ACK			= 126, /* Deprecated for v2.0*/
	H2F_MSG_ACK			= 127, /* Deprecated for v2.0*/
	H2F_MSG_REGISTER_CONTEXT	= 128,
	H2F_MSG_UNREGISTER_CONTEXT	= 129,
	H2F_MSG_ISSUE_CMD		= 130,
	H2F_MSG_ISSUE_CMD_RAW		= 131,
	H2F_MSG_TS_NOTIFY		= 132,
	F2H_MSG_TS_RETIRE		= 133,
	H2F_MSG_CONTEXT_POINTERS	= 134,
	H2F_MSG_ISSUE_LPAC_CMD_RAW	= 135,
	H2F_MSG_CONTEXT_RULE		= 140, /* AKA constraint */
	H2F_MSG_ISSUE_RECURRING_CMD	= 141,
	F2H_MSG_CONTEXT_BAD		= 150,
	H2F_MSG_HW_FENCE_INFO		= 151,
	H2F_MSG_ISSUE_SYNCOBJ		= 152,
	F2H_MSG_SYNCOBJ_QUERY		= 153,
	H2F_MSG_WARMBOOT_CMD		= 154,
	F2H_MSG_PROCESS_TRACE		= 155,
	F2H_MSG_PLATFORM_LA		= 200,
	H2F_MSG_PLATFORM_LA		= 201,
	F2H_MSG_PLATFORM_WIN		= 202, /* Reserved */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:442 [MATCH: HFI_V1_MSG_ACK] ---
	volatile u32 write_index;
} __packed;

#define HFI_MSG_CMD 0 /* V1 and V2 */
#define HFI_MSG_ACK 1 /* V2 only */

 /* Used to NOP a command when executing warmboot sequence */
#define HFI_MSG_NOP BIT(18)
 /* Used to record a command when executing coldboot sequence */
#define HFI_MSG_RECORD BIT(19)

#define HFI_V1_MSG_POST 1 /* V1 only */
#define HFI_V1_MSG_ACK 2/* V1 only */

#define MSG_HDR_SET_SIZE(hdr, size) \
	(((size & 0xFF) << 8) | hdr)

#define CREATE_MSG_HDR(id, type) \
	(((type) << 16) | ((id) & 0xFF))

#define ACK_MSG_HDR(id) CREATE_MSG_HDR(id, HFI_MSG_ACK)

#define HFI_QUEUE_DEFAULT_CNT 3
#define HFI_QUEUE_DISPATCH_MAX_CNT 14
#define HFI_QUEUE_HDR_MAX (HFI_QUEUE_DEFAULT_CNT + HFI_QUEUE_DISPATCH_MAX_CNT)

struct hfi_queue_table {
	struct hfi_queue_table_header qtbl_hdr;
	struct hfi_queue_header qhdr[HFI_QUEUE_HDR_MAX];
} __packed;

#define HFI_QUEUE_OFFSET(i) \
		(ALIGN(sizeof(struct hfi_queue_table), SZ_16) + \
		((i) * HFI_QUEUE_SIZE))

#define GMU_QUEUE_START_ADDR(gmuaddr, i) \
	(gmuaddr + HFI_QUEUE_OFFSET(i))

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:439 [MATCH: HFI_MSG_RECORD] ---
	u32 unused3;
	u32 unused4;
	volatile u32 read_index;
	volatile u32 write_index;
} __packed;

#define HFI_MSG_CMD 0 /* V1 and V2 */
#define HFI_MSG_ACK 1 /* V2 only */

 /* Used to NOP a command when executing warmboot sequence */
#define HFI_MSG_NOP BIT(18)
 /* Used to record a command when executing coldboot sequence */
#define HFI_MSG_RECORD BIT(19)

#define HFI_V1_MSG_POST 1 /* V1 only */
#define HFI_V1_MSG_ACK 2/* V1 only */

#define MSG_HDR_SET_SIZE(hdr, size) \
	(((size & 0xFF) << 8) | hdr)

#define CREATE_MSG_HDR(id, type) \
	(((type) << 16) | ((id) & 0xFF))

#define ACK_MSG_HDR(id) CREATE_MSG_HDR(id, HFI_MSG_ACK)

#define HFI_QUEUE_DEFAULT_CNT 3
#define HFI_QUEUE_DISPATCH_MAX_CNT 14
#define HFI_QUEUE_HDR_MAX (HFI_QUEUE_DEFAULT_CNT + HFI_QUEUE_DISPATCH_MAX_CNT)

struct hfi_queue_table {
	struct hfi_queue_table_header qtbl_hdr;
	struct hfi_queue_header qhdr[HFI_QUEUE_HDR_MAX];
} __packed;

#define HFI_QUEUE_OFFSET(i) \
		(ALIGN(sizeof(struct hfi_queue_table), SZ_16) + \
		((i) * HFI_QUEUE_SIZE))

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:476 [MATCH: HFI_MSG_RECORD] ---

#define GMU_QUEUE_START_ADDR(gmuaddr, i) \
	(gmuaddr + HFI_QUEUE_OFFSET(i))

#define HOST_QUEUE_START_ADDR(hfi_mem, i) \
	((hfi_mem)->hostptr + HFI_QUEUE_OFFSET(i))

#define MSG_HDR_GET_ID(hdr) ((hdr) & 0xFF)
#define MSG_HDR_GET_SIZE(hdr) (((hdr) >> 8) & 0xFF)
#define MSG_HDR_GET_TYPE(hdr) (((hdr) >> 16) & 0xF)
#define MSG_HDR_GET_SEQNUM(hdr) (((hdr) >> 20) & 0xFFF)

/* Clear the HFI_MSG_RECORD bit from both headers since some acks may have it set, and some not. */
#define CMP_HFI_ACK_HDR(sent, rcvd) ((sent &= ~HFI_MSG_RECORD) == (rcvd &= ~HFI_MSG_RECORD))

#define MSG_HDR_SET_SEQNUM(hdr, num) \
	(((hdr) & 0xFFFFF) | ((num) << 20))

#define MSG_HDR_SET_SEQNUM_SIZE(hdr, seqnum, sizedwords) \
	(FIELD_PREP(GENMASK(31, 20), seqnum) | FIELD_PREP(GENMASK(15, 8), sizedwords) | hdr)

#define MSG_HDR_SET_TYPE(hdr, type) \
	(((hdr) & 0xFFFFF) | ((type) << 16))

#define QUEUE_HDR_TYPE(id, prio, rtype, stype) \
	(((id) & 0xFF) | (((prio) & 0xFF) << 8) | \
	(((rtype) & 0xFF) << 16) | (((stype) & 0xFF) << 24))

#define HFI_RSP_TIMEOUT 1000 /* msec */

#define HFI_IRQ_MSGQ_MASK BIT(0)

enum hfi_msg_type {
	H2F_MSG_INIT			= 0,
	H2F_MSG_FW_VER			= 1,
	H2F_MSG_LM_CFG			= 2,
	H2F_MSG_BW_VOTE_TBL		= 3,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:477 [MATCH: HFI_MSG_RECORD] ---
#define GMU_QUEUE_START_ADDR(gmuaddr, i) \
	(gmuaddr + HFI_QUEUE_OFFSET(i))

#define HOST_QUEUE_START_ADDR(hfi_mem, i) \
	((hfi_mem)->hostptr + HFI_QUEUE_OFFSET(i))

#define MSG_HDR_GET_ID(hdr) ((hdr) & 0xFF)
#define MSG_HDR_GET_SIZE(hdr) (((hdr) >> 8) & 0xFF)
#define MSG_HDR_GET_TYPE(hdr) (((hdr) >> 16) & 0xF)
#define MSG_HDR_GET_SEQNUM(hdr) (((hdr) >> 20) & 0xFFF)

/* Clear the HFI_MSG_RECORD bit from both headers since some acks may have it set, and some not. */
#define CMP_HFI_ACK_HDR(sent, rcvd) ((sent &= ~HFI_MSG_RECORD) == (rcvd &= ~HFI_MSG_RECORD))

#define MSG_HDR_SET_SEQNUM(hdr, num) \
	(((hdr) & 0xFFFFF) | ((num) << 20))

#define MSG_HDR_SET_SEQNUM_SIZE(hdr, seqnum, sizedwords) \
	(FIELD_PREP(GENMASK(31, 20), seqnum) | FIELD_PREP(GENMASK(15, 8), sizedwords) | hdr)

#define MSG_HDR_SET_TYPE(hdr, type) \
	(((hdr) & 0xFFFFF) | ((type) << 16))

#define QUEUE_HDR_TYPE(id, prio, rtype, stype) \
	(((id) & 0xFF) | (((prio) & 0xFF) << 8) | \
	(((rtype) & 0xFF) << 16) | (((stype) & 0xFF) << 24))

#define HFI_RSP_TIMEOUT 1000 /* msec */

#define HFI_IRQ_MSGQ_MASK BIT(0)

enum hfi_msg_type {
	H2F_MSG_INIT			= 0,
	H2F_MSG_FW_VER			= 1,
	H2F_MSG_LM_CFG			= 2,
	H2F_MSG_BW_VOTE_TBL		= 3,
	H2F_MSG_PERF_TBL		= 4,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:1243 [MATCH: HFI_MSG_RECORD] ---
{
	if (WARN_ON(size > HFI_MAX_MSG_SIZE))
		return -EMSGSIZE;

	*hdr = CREATE_MSG_HDR(id, HFI_MSG_CMD);
	return 0;
}

#define CMD_MSG_HDR(cmd, id) \
	_CMD_MSG_HDR(&(cmd).hdr, id, sizeof(cmd))

#define RECORD_MSG_HDR(hdr) \
	((hdr) | HFI_MSG_RECORD)

#define CLEAR_RECORD_MSG_HDR(hdr) \
	((hdr) & (~(HFI_MSG_RECORD | HFI_MSG_NOP)))

#define RECORD_NOP_MSG_HDR(hdr) \
	((hdr) | (HFI_MSG_RECORD | HFI_MSG_NOP))

/* Maximum number of IBs in a submission */
#define HWSCHED_MAX_DISPATCH_NUMIBS \
	((HFI_MAX_MSG_SIZE - sizeof(struct hfi_submit_cmd)) \
		/ sizeof(struct hfi_issue_ib))

/**
 * struct payload_section - Container of keys values
 *
 * There may be a variable number of payload sections appended
 * to the context bad HFI message. Each payload section contains
 * a variable number of key-value pairs, both key and value being
 * single dword each.
 */
struct payload_section {
	/** @type: Type of the payload */
	u16 type;
	/** @dwords: Number of dwords in the data array. */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:1246 [MATCH: HFI_MSG_RECORD] ---

	*hdr = CREATE_MSG_HDR(id, HFI_MSG_CMD);
	return 0;
}

#define CMD_MSG_HDR(cmd, id) \
	_CMD_MSG_HDR(&(cmd).hdr, id, sizeof(cmd))

#define RECORD_MSG_HDR(hdr) \
	((hdr) | HFI_MSG_RECORD)

#define CLEAR_RECORD_MSG_HDR(hdr) \
	((hdr) & (~(HFI_MSG_RECORD | HFI_MSG_NOP)))

#define RECORD_NOP_MSG_HDR(hdr) \
	((hdr) | (HFI_MSG_RECORD | HFI_MSG_NOP))

/* Maximum number of IBs in a submission */
#define HWSCHED_MAX_DISPATCH_NUMIBS \
	((HFI_MAX_MSG_SIZE - sizeof(struct hfi_submit_cmd)) \
		/ sizeof(struct hfi_issue_ib))

/**
 * struct payload_section - Container of keys values
 *
 * There may be a variable number of payload sections appended
 * to the context bad HFI message. Each payload section contains
 * a variable number of key-value pairs, both key and value being
 * single dword each.
 */
struct payload_section {
	/** @type: Type of the payload */
	u16 type;
	/** @dwords: Number of dwords in the data array. */
	u16 dwords;
	/** @data: A sequence of key-value pairs. Each pair is 2 dwords. */
	u32 data[];

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:1249 [MATCH: HFI_MSG_RECORD] ---
}

#define CMD_MSG_HDR(cmd, id) \
	_CMD_MSG_HDR(&(cmd).hdr, id, sizeof(cmd))

#define RECORD_MSG_HDR(hdr) \
	((hdr) | HFI_MSG_RECORD)

#define CLEAR_RECORD_MSG_HDR(hdr) \
	((hdr) & (~(HFI_MSG_RECORD | HFI_MSG_NOP)))

#define RECORD_NOP_MSG_HDR(hdr) \
	((hdr) | (HFI_MSG_RECORD | HFI_MSG_NOP))

/* Maximum number of IBs in a submission */
#define HWSCHED_MAX_DISPATCH_NUMIBS \
	((HFI_MAX_MSG_SIZE - sizeof(struct hfi_submit_cmd)) \
		/ sizeof(struct hfi_issue_ib))

/**
 * struct payload_section - Container of keys values
 *
 * There may be a variable number of payload sections appended
 * to the context bad HFI message. Each payload section contains
 * a variable number of key-value pairs, both key and value being
 * single dword each.
 */
struct payload_section {
	/** @type: Type of the payload */
	u16 type;
	/** @dwords: Number of dwords in the data array. */
	u16 dwords;
	/** @data: A sequence of key-value pairs. Each pair is 2 dwords. */
	u32 data[];
} __packed;

/* IDs for context bad hfi payloads */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:1045 [MATCH: ret_cmd] ---

/* F2H */
struct hfi_context_bad_cmd_legacy {
	u32 hdr;
	u32 ctxt_id;
	u32 policy;
	u32 ts;
	u32 error;
	u32 payload[];
} __packed;

/* H2F */
struct hfi_msg_ret_cmd {
	u32 hdr;
	u32 req_hdr;
	u32 error;
} __packed;

/* H2F */
struct hfi_submit_cmd {
	u32 hdr;
	u32 ctxt_id;
	u32 flags;
	u32 ts;
	u32 profile_gpuaddr_lo;
	u32 profile_gpuaddr_hi;
	u32 numibs;
	u32 big_ib_gmu_va;
} __packed;

/* This structure is only used for hw fence feature on gen7 hwsched targets */
struct hfi_syncobj_legacy {
	/** @ctxt_id: dma fence context id for external fence and gmu context id for kgsl fence */
	u64 ctxt_id;
	/** @seq_no: Sequence number (or timestamp) of this fence */
	u64 seq_no;
	/** @flags: Flags for this fence */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:1185 [MATCH: pending_cmd] ---
	u32 hdr;
	/** @version: Version of the fence info packet */
	u32 version;
	/** @gmu_ctxt_id: GMU Context id to which this SYNC object belongs */
	u32 gmu_ctxt_id;
	/** @sync_obj_ts: Timestamp of this SYNC object */
	u32 sync_obj_ts;
	/** @queries: Array of query bitmasks */
	struct hfi_syncobj_query queries[MAX_SYNCOBJ_QUERY_DWORDS];
} __packed;

/**
 * struct pending_cmd - data structure to track outstanding HFI
 *	command messages
 */
struct pending_cmd {
	/** @sent_hdr: Header of the un-ack'd hfi packet */
	u32 sent_hdr;
	/** @results: Array to store the ack packet */
	u32 results[MAX_RCVD_SIZE];
	/** @complete: Completion to signal hfi ack has been received */
	struct completion complete;
	/** @node: to add it to the list of hfi packets waiting for ack */
	struct list_head node;
};

struct hfi_msg_platform {
	/** @hdr: Header for the platform specific msg */
	u32 hdr;
	/** @sub_type: Sub type for the platform msg */
	u32 sub_type;
} __packed;

struct hfi_scale_gmu_cmd {
	/** @header: Header for the scale gmu packet */
	struct hfi_msg_platform header;
	/** @gmu_pwrlevel: Gmu index of gmu power level to scale to */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:1188 [MATCH: pending_cmd] ---
	/** @gmu_ctxt_id: GMU Context id to which this SYNC object belongs */
	u32 gmu_ctxt_id;
	/** @sync_obj_ts: Timestamp of this SYNC object */
	u32 sync_obj_ts;
	/** @queries: Array of query bitmasks */
	struct hfi_syncobj_query queries[MAX_SYNCOBJ_QUERY_DWORDS];
} __packed;

/**
 * struct pending_cmd - data structure to track outstanding HFI
 *	command messages
 */
struct pending_cmd {
	/** @sent_hdr: Header of the un-ack'd hfi packet */
	u32 sent_hdr;
	/** @results: Array to store the ack packet */
	u32 results[MAX_RCVD_SIZE];
	/** @complete: Completion to signal hfi ack has been received */
	struct completion complete;
	/** @node: to add it to the list of hfi packets waiting for ack */
	struct list_head node;
};

struct hfi_msg_platform {
	/** @hdr: Header for the platform specific msg */
	u32 hdr;
	/** @sub_type: Sub type for the platform msg */
	u32 sub_type;
} __packed;

struct hfi_scale_gmu_cmd {
	/** @header: Header for the scale gmu packet */
	struct hfi_msg_platform header;
	/** @gmu_pwrlevel: Gmu index of gmu power level to scale to */
	u32 gmu_pwrlevel;
} __packed;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:1570 [MATCH: pending_cmd] ---
 * adreno_dev: Pointer to the adreno device
 * dev: Pointer to the device structure
 * ack: Pointer to the pending ack
 * process_msgq: Function pointer to the msgq processing function
 *
 * This function waits for the completion structure, which gets signaled asynchronously. In case
 * there is a timeout, process the msgq one last time. If the ack is present, log an error and move
 * on. If the ack isn't present, log an error, take a snapshot and return -ETIMEDOUT.
 *
 * Return: 0 on success and -ETIMEDOUT on failure
 */
int adreno_hwsched_wait_ack_completion(struct adreno_device *adreno_dev,
	struct device *dev, struct pending_cmd *ack,
	void (*process_msgq)(struct adreno_device *adreno_dev));

/**
 * adreno_hwsched_ctxt_unregister_wait_completion - Wait for HFI ack for context unregister
 * adreno_dev: Pointer to the adreno device
 * dev: Pointer to the device structure
 * context: Pointer to the context structure
 * ack: Pointer to the pending ack
 * process_msgq: Function pointer to the msgq processing function
 * cmd: Pointer to the hfi packet header and data
 *
 * This function waits for the completion structure for context unregister hfi ack,
 * which gets signaled asynchronously. In case there is a timeout, process the msgq
 * one last time. If the ack is present, log an error and move on. If the ack isn't
 * present, log an error and return -ETIMEDOUT.
 *
 * Return: 0 on success and -ETIMEDOUT on failure
 */
int adreno_hwsched_ctxt_unregister_wait_completion(
	struct adreno_device *adreno_dev,
	struct device *dev, struct kgsl_context *context, struct pending_cmd *ack,
	void (*process_msgq)(struct adreno_device *adreno_dev),
	struct hfi_unregister_ctxt_cmd *cmd);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:1591 [MATCH: pending_cmd] ---
 * process_msgq: Function pointer to the msgq processing function
 * cmd: Pointer to the hfi packet header and data
 *
 * This function waits for the completion structure for context unregister hfi ack,
 * which gets signaled asynchronously. In case there is a timeout, process the msgq
 * one last time. If the ack is present, log an error and move on. If the ack isn't
 * present, log an error and return -ETIMEDOUT.
 *
 * Return: 0 on success and -ETIMEDOUT on failure
 */
int adreno_hwsched_ctxt_unregister_wait_completion(
	struct adreno_device *adreno_dev,
	struct device *dev, struct kgsl_context *context, struct pending_cmd *ack,
	void (*process_msgq)(struct adreno_device *adreno_dev),
	struct hfi_unregister_ctxt_cmd *cmd);

/**
 * hfi_get_minidump_string - Get the va-minidump string from entry
 * mem_kind: mem_kind type
 * hfi_minidump_str: Pointer to the output string
 * size: Max size of the hfi_minidump_str
 * rb_id: Pointer to the rb_id count
 *
 * This function return 0 on valid mem_kind and copies the VA-MINIDUMP string to
 * hfi_minidump_str else return error
 */
static inline int hfi_get_minidump_string(u32 mem_kind, char *hfi_minidump_str,
					   size_t size, u32 *rb_id)
{
	/* Extend this if the VA mindump need more hfi alloc entries */
	switch (mem_kind) {
	case HFI_MEMKIND_RB:
		snprintf(hfi_minidump_str, size, KGSL_GMU_RB_ENTRY"_%d", (*rb_id)++);
		break;
	case HFI_MEMKIND_SCRATCH:
		snprintf(hfi_minidump_str, size, KGSL_SCRATCH_ENTRY);
		break;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hwsched.c:2810 [MATCH: pending_cmd] ---
			ret);
		kgsl_hw_fence_close(device);
		memset(&hwsched->hw_fence.md, 0x0, sizeof(hwsched->hw_fence.md));
		return;
	}

	hwsched->hw_fence_cache = KMEM_CACHE(adreno_hw_fence_entry, 0);

	set_bit(ADRENO_HWSCHED_HW_FENCE, &hwsched->flags);
}

int adreno_hwsched_wait_ack_completion(struct adreno_device *adreno_dev,
	struct device *dev, struct pending_cmd *ack,
	void (*process_msgq)(struct adreno_device *adreno_dev))
{
	int rc;
	/* Only allow a single log in a second */
	static DEFINE_RATELIMIT_STATE(_rs, HZ, 1);
	static u32 unprocessed, processed;
	const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
	u64 start, end;

	start = gpudev->read_alwayson(adreno_dev);
	rc = wait_for_completion_timeout(&ack->complete,
		msecs_to_jiffies(HFI_RSP_TIMEOUT));
	/*
	 * A non-zero return value means the completion is complete, whereas zero indicates
	 * timeout
	 */
	if (rc) {
		/*
		 * If an ack goes unprocessed, keep track of processed and unprocessed acks
		 * because we may not log each unprocessed ack due to ratelimiting
		 */
		if (unprocessed)
			processed++;
		return 0;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hwsched.c:2861 [MATCH: pending_cmd] ---
				unprocessed, processed, start, end);
		return 0;
	}

	dev_err(dev, "Ack timeout for id:%d sequence=%d ticks=0x%llx/0x%llx\n",
		MSG_HDR_GET_ID(ack->sent_hdr), MSG_HDR_GET_SEQNUM(ack->sent_hdr), start, end);
	gmu_core_fault_snapshot(KGSL_DEVICE(adreno_dev), GMU_FAULT_WAIT_ACK_COMPLETION);
	return -ETIMEDOUT;
}

int adreno_hwsched_ctxt_unregister_wait_completion(
	struct adreno_device *adreno_dev,
	struct device *dev, struct kgsl_context *context, struct pending_cmd *ack,
	void (*process_msgq)(struct adreno_device *adreno_dev),
	struct hfi_unregister_ctxt_cmd *cmd)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
	struct adreno_context *drawctxt = ADRENO_CONTEXT(context);
	int rb = adreno_get_level(context);
	int ret;
	bool fast = adreno_is_fast_context_destroy_enabled(adreno_dev);
	u64 start, end;
	char prefix[60];

	start = gpudev->read_alwayson(adreno_dev);
	kgsl_mutex_unlock(&device->mutex);

	ret = wait_for_completion_timeout(&ack->complete, msecs_to_jiffies(30 * 1000));

	kgsl_mutex_lock(&device->mutex);
	if (ret)
		return 0;

	/*
	 * It is possible the ack came, but due to HLOS latencies in processing hfi interrupt
	 * and/or the f2h daemon, the ack isn't processed yet. Hence, process the msgq one last

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_gmu_core.h:503 [MATCH: F2H_MSG_ERR] ---
struct device_node;
struct kgsl_device;
struct kgsl_snapshot;

#define GMU_FAULT_PANIC_NONE 0
enum gmu_fault_panic_policy {
	GMU_FAULT_DEVICE_START = 1,
	GMU_FAULT_HFI_INIT,
	GMU_FAULT_OOB_SET,
	GMU_FAULT_HFI_RECIVE_ACK,
	GMU_FAULT_SEND_CMD_WAIT_INLINE,
	GMU_FAULT_HFI_SEND_GENERIC_REQ,
	GMU_FAULT_F2H_MSG_ERR,
	GMU_FAULT_H2F_MSG_START,
	GMU_FAULT_WAIT_ACK_COMPLETION,
	GMU_FAULT_HFI_ACK,
	GMU_FAULT_CTX_UNREGISTER,
	GMU_FAULT_WAIT_FOR_LOWEST_IDLE,
	GMU_FAULT_WAIT_FOR_IDLE,
	GMU_FAULT_HW_FENCE,
	GMU_FAULT_WAIT_FOR_CX,
	GMU_FAULT_CX_WAIT_TIMEOUT,
	GMU_FAULT_CM3,
	GMU_FAULT_MAX,
};

#define KGSL_GMU_CORE_FORCE_PANIC(gf_panic, pdev, ticks, policy) do { \
		if (gf_panic & BIT(policy)) { \
			dev_err(&pdev->dev, \
				"GMU always on ticks: %llx gf_policy: 0x%x gf_trigger: 0x%lx\n", \
				ticks, gf_panic, BIT(policy));\
			BUG();\
		} \
	} while (0)

struct gmu_dev_ops {
	int (*oob_set)(struct kgsl_device *device, enum oob_request req);

######## E: QUEUE / MEMORY / SYNCHRONIZATION ########

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:1427 [MATCH: READ_ONCE] ---

static int register_l3_voter(struct kgsl_device *device)
{
	int ret = 0;

	/*
	 * The L3 vote setup is performed only once. Once set up is done, it is
	 * safe to access num_l3_pwrlevels without acquiring the device mutex.
	 * Therefore, an early check can be added without taking the mutex.
	 */
	if (READ_ONCE(device->num_l3_pwrlevels))
		return ret;

	kgsl_mutex_lock(&device->mutex);

	if (!device->l3_vote)
		goto done;

	/* Verify again if the L3 vote is set up to handle races */
	if (device->num_l3_pwrlevels)
		goto done;

	memset(device->l3_freq, 0x0, sizeof(device->l3_freq));

	ret = qcom_dcvs_register_voter(KGSL_L3_DEVICE, DCVS_L3, DCVS_SLOW_PATH);
	if (ret) {
		dev_err_once(&device->pdev->dev,
			"Unable to register l3 dcvs voter: %d\n", ret);
		goto done;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:1459 [MATCH: WRITE_ONCE] ---
		&device->l3_freq[2]);
	if (ret) {
		dev_err_once(&device->pdev->dev,
			"Unable to get min/max for l3 dcvs: %d\n", ret);
		qcom_dcvs_unregister_voter(KGSL_L3_DEVICE, DCVS_L3,
			DCVS_SLOW_PATH);
		memset(device->l3_freq, 0x0, sizeof(device->l3_freq));
		goto done;
	}

	WRITE_ONCE(device->num_l3_pwrlevels, 3);

done:
	kgsl_mutex_unlock(&device->mutex);

	return ret;
}

static int adreno_of_get_power(struct adreno_device *adreno_dev,
		struct platform_device *pdev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct device_node *node;
	int ret;

	node = of_parse_phandle(pdev->dev.of_node, "operating-points-v2", 0);

	if (node && of_device_is_compatible(node, "operating-points-v2")) {
		ret = adreno_of_parse_pwrlevels(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:689 [MATCH: smp_mb] ---

static irqreturn_t adreno_irq_handler(int irq, void *data)
{
	struct kgsl_device *device = data;
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
	irqreturn_t ret;

	atomic_inc(&adreno_dev->pending_irq_refcnt);
	/* Ensure this increment is done before the IRQ status is updated */
	smp_mb__after_atomic();

	ret = gpudev->irq_handler(adreno_dev);

	/* Make sure the regwrites are done before the decrement */
	smp_mb__before_atomic();
	atomic_dec(&adreno_dev->pending_irq_refcnt);
	/* Ensure other CPUs see the decrement */
	smp_mb__after_atomic();

	return ret;
}

static irqreturn_t adreno_freq_limiter_irq_handler(int irq, void *data)
{
	struct kgsl_device *device = data;

	KGSL_PWRCTRL_LOG_FREQLIM(device);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:694 [MATCH: smp_mb] ---
	const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
	irqreturn_t ret;

	atomic_inc(&adreno_dev->pending_irq_refcnt);
	/* Ensure this increment is done before the IRQ status is updated */
	smp_mb__after_atomic();

	ret = gpudev->irq_handler(adreno_dev);

	/* Make sure the regwrites are done before the decrement */
	smp_mb__before_atomic();
	atomic_dec(&adreno_dev->pending_irq_refcnt);
	/* Ensure other CPUs see the decrement */
	smp_mb__after_atomic();

	return ret;
}

static irqreturn_t adreno_freq_limiter_irq_handler(int irq, void *data)
{
	struct kgsl_device *device = data;

	KGSL_PWRCTRL_LOG_FREQLIM(device);

	reset_control_reset(device->freq_limiter_irq_clear);

	return IRQ_HANDLED;
}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:697 [MATCH: smp_mb] ---
	atomic_inc(&adreno_dev->pending_irq_refcnt);
	/* Ensure this increment is done before the IRQ status is updated */
	smp_mb__after_atomic();

	ret = gpudev->irq_handler(adreno_dev);

	/* Make sure the regwrites are done before the decrement */
	smp_mb__before_atomic();
	atomic_dec(&adreno_dev->pending_irq_refcnt);
	/* Ensure other CPUs see the decrement */
	smp_mb__after_atomic();

	return ret;
}

static irqreturn_t adreno_freq_limiter_irq_handler(int irq, void *data)
{
	struct kgsl_device *device = data;

	KGSL_PWRCTRL_LOG_FREQLIM(device);

	reset_control_reset(device->freq_limiter_irq_clear);

	return IRQ_HANDLED;
}

irqreturn_t adreno_irq_callbacks(struct adreno_device *adreno_dev,
		const struct adreno_irq_funcs *funcs, u32 status)
{

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:3721 [MATCH: smp_mb] ---
	struct adreno_ringbuffer *rb;
	int i;

	if (!kgsl_state_is_awake(KGSL_DEVICE(adreno_dev)))
		return true;

	/*
	 * wptr is updated when we add commands to ringbuffer, add a barrier
	 * to make sure updated wptr is compared to rptr
	 */
	smp_mb();

	/*
	 * ringbuffer is truly idle when all ringbuffers read and write
	 * pointers are equal
	 */

	FOR_EACH_RINGBUFFER(adreno_dev, rb, i) {
		if (!adreno_rb_empty(rb))
			return false;
	}

	return gpudev->hw_isidle(adreno_dev);
}

/**
 * adreno_spin_idle() - Spin wait for the GPU to idle
 * @adreno_dev: Pointer to an adreno device
 * @timeout: milliseconds to wait before returning error

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx_snapshot.c:868 [MATCH: read_index] ---
		size = 512;

	if (remain < DEBUG_SECTION_SZ(size)) {
		SNAPSHOT_ERR_NOMEM(device, "CP ROQ DEBUG");
		return 0;
	}

	header->type = SNAPSHOT_DEBUG_CP_ROQ;
	header->size = size;

	kgsl_regmap_read_indexed(&device->regmap, A5XX_CP_ROQ_DBG_ADDR,
		A5XX_CP_ROQ_DBG_DATA, data, size);

	return DEBUG_SECTION_SZ(size);
}

static size_t a5xx_snapshot_cp_meq(struct kgsl_device *device, u8 *buf,
		size_t remain, void *priv)
{
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	struct kgsl_snapshot_debug *header = (struct kgsl_snapshot_debug *) buf;
	u32 size, *data = (u32 *) (buf + sizeof(*header));

	if (adreno_is_a505_or_a506(adreno_dev) || adreno_is_a508(adreno_dev) ||
		adreno_is_a510(adreno_dev))
		size = 32;
	else
		size = 64;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx_snapshot.c:895 [MATCH: read_index] ---
		size = 64;

	if (remain < DEBUG_SECTION_SZ(size)) {
		SNAPSHOT_ERR_NOMEM(device, "CP MEQ DEBUG");
		return 0;
	}

	header->type = SNAPSHOT_DEBUG_CP_MEQ;
	header->size = size;

	kgsl_regmap_read_indexed(&device->regmap, A5XX_CP_MEQ_DBG_ADDR,
		A5XX_CP_MEQ_DBG_DATA, data, size);

	return DEBUG_SECTION_SZ(size);
}

/*
 * a5xx_snapshot() - A5XX GPU snapshot function
 * @adreno_dev: Device being snapshotted
 * @snapshot: Pointer to the snapshot instance
 *
 * This is where all of the A5XX specific bits and pieces are grabbed
 * into the snapshot memory
 */
void a5xx_snapshot(struct adreno_device *adreno_dev,
		struct kgsl_snapshot *snapshot)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	u32 hi, lo;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hfi.c:207 [MATCH: qhdr] ---

	/* Fill Table Header */
	tbl = mem_addr->hostptr;
	tbl->qtbl_hdr.version = 0;
	tbl->qtbl_hdr.size = sizeof(struct hfi_queue_table) >> 2;
	tbl->qtbl_hdr.qhdr0_offset = sizeof(struct hfi_queue_table_header) >> 2;
	tbl->qtbl_hdr.qhdr_size = sizeof(struct hfi_queue_header) >> 2;
	tbl->qtbl_hdr.num_q = HFI_QUEUE_MAX;
	tbl->qtbl_hdr.num_active_q = HFI_QUEUE_MAX;

	memset(&tbl->qhdr[0], 0, sizeof(tbl->qhdr));

	/* Fill Individual Queue Headers */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		hdr = &tbl->qhdr[i];
		hdr->start_addr = GMU_QUEUE_START_ADDR(mem_addr->gmuaddr, i);
		hdr->type = QUEUE_HDR_TYPE(queue[i].idx, queue[i].pri, 0,  0);
		hdr->status = queue[i].status;
		hdr->queue_size = HFI_QUEUE_SIZE >> 2; /* convert to dwords */
	}
}

int a6xx_hfi_init(struct adreno_device *adreno_dev)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct a6xx_hfi *hfi = &gmu->hfi;

	/* Allocates & maps memory for HFI */
	if (IS_ERR_OR_NULL(hfi->hfi_mem)) {

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hfi.c:211 [MATCH: qhdr] ---
	tbl->qtbl_hdr.size = sizeof(struct hfi_queue_table) >> 2;
	tbl->qtbl_hdr.qhdr0_offset = sizeof(struct hfi_queue_table_header) >> 2;
	tbl->qtbl_hdr.qhdr_size = sizeof(struct hfi_queue_header) >> 2;
	tbl->qtbl_hdr.num_q = HFI_QUEUE_MAX;
	tbl->qtbl_hdr.num_active_q = HFI_QUEUE_MAX;

	memset(&tbl->qhdr[0], 0, sizeof(tbl->qhdr));

	/* Fill Individual Queue Headers */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		hdr = &tbl->qhdr[i];
		hdr->start_addr = GMU_QUEUE_START_ADDR(mem_addr->gmuaddr, i);
		hdr->type = QUEUE_HDR_TYPE(queue[i].idx, queue[i].pri, 0,  0);
		hdr->status = queue[i].status;
		hdr->queue_size = HFI_QUEUE_SIZE >> 2; /* convert to dwords */
	}
}

int a6xx_hfi_init(struct adreno_device *adreno_dev)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct a6xx_hfi *hfi = &gmu->hfi;

	/* Allocates & maps memory for HFI */
	if (IS_ERR_OR_NULL(hfi->hfi_mem)) {
		hfi->hfi_mem = gmu_core_reserve_kernel_block(KGSL_DEVICE(adreno_dev), 0,
			HFIMEM_SIZE, GMU_NONCACHED_KERNEL, 0);
		if (!IS_ERR(hfi->hfi_mem))
			init_queues(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hfi.c:673 [MATCH: qhdr] ---
static void reset_hfi_queues(struct adreno_device *adreno_dev)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
	struct hfi_queue_table *tbl = mem_addr->hostptr;
	struct hfi_queue_header *hdr;
	unsigned int i;

	/* Flush HFI queues */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		hdr = &tbl->qhdr[i];

		if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
			continue;

		hdr->read_index = hdr->write_index;
	}
}

int a6xx_hfi_start(struct adreno_device *adreno_dev)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int result;

	reset_hfi_queues(adreno_dev);

	/* This is legacy HFI message for A630 and A615 family firmware */
	if (adreno_is_a630(adreno_dev) || adreno_is_a615_family(adreno_dev)) {

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hfi.c:47 [MATCH: read_index] ---
	struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];
	uint32_t *queue;
	uint32_t msg_hdr;
	uint32_t i, read;
	uint32_t size;
	int result = 0;

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
		return -EINVAL;

	if (hdr->read_index == hdr->write_index)
		return -ENODATA;

	/* Clear the output data before populating */
	memset(output, 0, max_size);

	queue = HOST_QUEUE_START_ADDR(mem_addr, queue_idx);
	msg_hdr = queue[hdr->read_index];
	size = MSG_HDR_GET_SIZE(msg_hdr);

	if (size > (max_size >> 2)) {
		dev_err(GMU_PDEV_DEV(device),
		"HFI message too big: hdr:0x%x rd idx=%d\n",
			msg_hdr, hdr->read_index);
		result = -EMSGSIZE;
		goto done;
	}

	read = hdr->read_index;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hfi.c:54 [MATCH: read_index] ---
	if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
		return -EINVAL;

	if (hdr->read_index == hdr->write_index)
		return -ENODATA;

	/* Clear the output data before populating */
	memset(output, 0, max_size);

	queue = HOST_QUEUE_START_ADDR(mem_addr, queue_idx);
	msg_hdr = queue[hdr->read_index];
	size = MSG_HDR_GET_SIZE(msg_hdr);

	if (size > (max_size >> 2)) {
		dev_err(GMU_PDEV_DEV(device),
		"HFI message too big: hdr:0x%x rd idx=%d\n",
			msg_hdr, hdr->read_index);
		result = -EMSGSIZE;
		goto done;
	}

	read = hdr->read_index;

	if (read < hdr->queue_size) {
		for (i = 0; i < size && i < (max_size >> 2); i++) {
			output[i] = queue[read];
			read = (read + 1)%hdr->queue_size;
		}
		result = size;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hfi.c:60 [MATCH: read_index] ---
	/* Clear the output data before populating */
	memset(output, 0, max_size);

	queue = HOST_QUEUE_START_ADDR(mem_addr, queue_idx);
	msg_hdr = queue[hdr->read_index];
	size = MSG_HDR_GET_SIZE(msg_hdr);

	if (size > (max_size >> 2)) {
		dev_err(GMU_PDEV_DEV(device),
		"HFI message too big: hdr:0x%x rd idx=%d\n",
			msg_hdr, hdr->read_index);
		result = -EMSGSIZE;
		goto done;
	}

	read = hdr->read_index;

	if (read < hdr->queue_size) {
		for (i = 0; i < size && i < (max_size >> 2); i++) {
			output[i] = queue[read];
			read = (read + 1)%hdr->queue_size;
		}
		result = size;
	} else {
		/* In case FW messed up */
		dev_err(GMU_PDEV_DEV(device),
			"Read index %d greater than queue size %d\n",
			hdr->read_index, hdr->queue_size);
		result = -ENODATA;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hfi.c:65 [MATCH: read_index] ---
	size = MSG_HDR_GET_SIZE(msg_hdr);

	if (size > (max_size >> 2)) {
		dev_err(GMU_PDEV_DEV(device),
		"HFI message too big: hdr:0x%x rd idx=%d\n",
			msg_hdr, hdr->read_index);
		result = -EMSGSIZE;
		goto done;
	}

	read = hdr->read_index;

	if (read < hdr->queue_size) {
		for (i = 0; i < size && i < (max_size >> 2); i++) {
			output[i] = queue[read];
			read = (read + 1)%hdr->queue_size;
		}
		result = size;
	} else {
		/* In case FW messed up */
		dev_err(GMU_PDEV_DEV(device),
			"Read index %d greater than queue size %d\n",
			hdr->read_index, hdr->queue_size);
		result = -ENODATA;
	}

	if (GMU_VER_MAJOR(device->gmu_core.ver.hfi) >= 2)
		read = ALIGN(read, SZ_4) % hdr->queue_size;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hfi.c:77 [MATCH: read_index] ---
	if (read < hdr->queue_size) {
		for (i = 0; i < size && i < (max_size >> 2); i++) {
			output[i] = queue[read];
			read = (read + 1)%hdr->queue_size;
		}
		result = size;
	} else {
		/* In case FW messed up */
		dev_err(GMU_PDEV_DEV(device),
			"Read index %d greater than queue size %d\n",
			hdr->read_index, hdr->queue_size);
		result = -ENODATA;
	}

	if (GMU_VER_MAJOR(device->gmu_core.ver.hfi) >= 2)
		read = ALIGN(read, SZ_4) % hdr->queue_size;

	/* For acks, trace the packet for which this ack was sent */
	if (MSG_HDR_GET_TYPE(msg_hdr) == HFI_MSG_ACK)
		trace_kgsl_hfi_receive(MSG_HDR_GET_ID(output[1]),
			MSG_HDR_GET_SIZE(output[1]),
			MSG_HDR_GET_SEQNUM(output[1]));
	else
		trace_kgsl_hfi_receive(MSG_HDR_GET_ID(msg_hdr),
			MSG_HDR_GET_SIZE(msg_hdr), MSG_HDR_GET_SEQNUM(msg_hdr));

	hfi_update_read_idx(hdr, read);

done:

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hfi.c:119 [MATCH: read_index] ---
	uint32_t size_dwords = size_bytes >> 2;
	u32 align_size = ALIGN(size_dwords, SZ_4);
	uint32_t id = MSG_HDR_GET_ID(*msg);

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED || !IS_ALIGNED(size_bytes, sizeof(u32)))
		return -EINVAL;

	queue = HOST_QUEUE_START_ADDR(gmu->hfi.hfi_mem, queue_idx);

	write_idx = hdr->write_index;
	read_idx = hdr->read_index;

	empty_space = (write_idx >= read_idx) ?
			(hdr->queue_size - (write_idx - read_idx))
			: (read_idx - write_idx);

	if (empty_space <= align_size)
		return -ENOSPC;

	for (i = 0; i < size_dwords; i++) {
		queue[write_idx] = msg[i];
		write_idx = (write_idx + 1) % hdr->queue_size;
	}

	/* Cookify any non used data at the end of the write buffer */
	if (GMU_VER_MAJOR(device->gmu_core.ver.hfi) >= 2) {
		for (; i < align_size; i++) {
			queue[write_idx] = 0xFAFAFAFA;
			write_idx = (write_idx + 1) % hdr->queue_size;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hfi.c:678 [MATCH: read_index] ---
	struct hfi_queue_header *hdr;
	unsigned int i;

	/* Flush HFI queues */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		hdr = &tbl->qhdr[i];

		if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
			continue;

		hdr->read_index = hdr->write_index;
	}
}

int a6xx_hfi_start(struct adreno_device *adreno_dev)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int result;

	reset_hfi_queues(adreno_dev);

	/* This is legacy HFI message for A630 and A615 family firmware */
	if (adreno_is_a630(adreno_dev) || adreno_is_a615_family(adreno_dev)) {
		result = a6xx_hfi_send_gmu_init(adreno_dev);
		if (result)
			goto err;
	}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hfi.c:118 [MATCH: write_index] ---
	uint32_t i, write_idx, read_idx, empty_space;
	uint32_t size_dwords = size_bytes >> 2;
	u32 align_size = ALIGN(size_dwords, SZ_4);
	uint32_t id = MSG_HDR_GET_ID(*msg);

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED || !IS_ALIGNED(size_bytes, sizeof(u32)))
		return -EINVAL;

	queue = HOST_QUEUE_START_ADDR(gmu->hfi.hfi_mem, queue_idx);

	write_idx = hdr->write_index;
	read_idx = hdr->read_index;

	empty_space = (write_idx >= read_idx) ?
			(hdr->queue_size - (write_idx - read_idx))
			: (read_idx - write_idx);

	if (empty_space <= align_size)
		return -ENOSPC;

	for (i = 0; i < size_dwords; i++) {
		queue[write_idx] = msg[i];
		write_idx = (write_idx + 1) % hdr->queue_size;
	}

	/* Cookify any non used data at the end of the write buffer */
	if (GMU_VER_MAJOR(device->gmu_core.ver.hfi) >= 2) {
		for (; i < align_size; i++) {
			queue[write_idx] = 0xFAFAFAFA;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:25 [MATCH: qhdr] ---
#include "adreno_trace.h"
#include "kgsl_device.h"
#include "kgsl_eventlog.h"
#include "kgsl_gmu_core.h"
#include "kgsl_pwrctrl.h"
#include "kgsl_trace.h"
#include "kgsl_util.h"

#define HFI_QUEUE_MAX (HFI_QUEUE_DEFAULT_CNT + HFI_QUEUE_DISPATCH_MAX_CNT)

#define DEFINE_QHDR(gmuaddr, id, prio) \
	{\
		.status = 1, \
		.start_addr = GMU_QUEUE_START_ADDR(gmuaddr, id), \
		.type = QUEUE_HDR_TYPE(id, prio, 0, 0), \
		.queue_size = SZ_4K >> 2, \
		.msg_size = 0, \
		.unused0 = 0, \
		.unused1 = 0, \
		.unused2 = 0, \
		.unused3 = 0, \
		.unused4 = 0, \
		.read_index = 0, \
		.write_index = 0, \
}

static struct dq_info {
	/** @max_dq: Maximum number of dispatch queues per RB level */
	u32 max_dq;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:570 [MATCH: qhdr] ---
	return rc;
}

static void init_queues(struct a6xx_hfi *hfi)
{
	u32 gmuaddr = hfi->hfi_mem->gmuaddr;
	struct hfi_queue_table hfi_table = {
		.qtbl_hdr = {
			.version = 0,
			.size = sizeof(struct hfi_queue_table) >> 2,
			.qhdr0_offset =
				sizeof(struct hfi_queue_table_header) >> 2,
			.qhdr_size = sizeof(struct hfi_queue_header) >> 2,
			.num_q = HFI_QUEUE_MAX,
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:576 [MATCH: qhdr] ---
	struct hfi_queue_table hfi_table = {
		.qtbl_hdr = {
			.version = 0,
			.size = sizeof(struct hfi_queue_table) >> 2,
			.qhdr0_offset =
				sizeof(struct hfi_queue_table_header) >> 2,
			.qhdr_size = sizeof(struct hfi_queue_header) >> 2,
			.num_q = HFI_QUEUE_MAX,
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 3 DQs for RB priority 3 */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:581 [MATCH: qhdr] ---
				sizeof(struct hfi_queue_table_header) >> 2,
			.qhdr_size = sizeof(struct hfi_queue_header) >> 2,
			.num_q = HFI_QUEUE_MAX,
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 3 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			DEFINE_QHDR(gmuaddr, 16, 3),
		},
	};

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:582 [MATCH: qhdr] ---
			.qhdr_size = sizeof(struct hfi_queue_header) >> 2,
			.num_q = HFI_QUEUE_MAX,
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 3 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			DEFINE_QHDR(gmuaddr, 16, 3),
		},
	};


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:583 [MATCH: qhdr] ---
			.num_q = HFI_QUEUE_MAX,
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 3 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			DEFINE_QHDR(gmuaddr, 16, 3),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:584 [MATCH: qhdr] ---
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 3 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			DEFINE_QHDR(gmuaddr, 16, 3),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:586 [MATCH: qhdr] ---
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 3 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			DEFINE_QHDR(gmuaddr, 16, 3),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:587 [MATCH: qhdr] ---
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 3 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			DEFINE_QHDR(gmuaddr, 16, 3),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:588 [MATCH: qhdr] ---
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 3 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			DEFINE_QHDR(gmuaddr, 16, 3),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
	(SZ_4K * HFI_QUEUE_MAX))

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:589 [MATCH: qhdr] ---
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 3 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			DEFINE_QHDR(gmuaddr, 16, 3),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
	(SZ_4K * HFI_QUEUE_MAX))


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:591 [MATCH: qhdr] ---
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 3 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			DEFINE_QHDR(gmuaddr, 16, 3),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
	(SZ_4K * HFI_QUEUE_MAX))

static int hfi_f2h_main(void *arg);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:592 [MATCH: qhdr] ---
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 3 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			DEFINE_QHDR(gmuaddr, 16, 3),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
	(SZ_4K * HFI_QUEUE_MAX))

static int hfi_f2h_main(void *arg);

int a6xx_hwsched_hfi_init(struct adreno_device *adreno_dev)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:593 [MATCH: qhdr] ---
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 3 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			DEFINE_QHDR(gmuaddr, 16, 3),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
	(SZ_4K * HFI_QUEUE_MAX))

static int hfi_f2h_main(void *arg);

int a6xx_hwsched_hfi_init(struct adreno_device *adreno_dev)
{

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:595 [MATCH: qhdr] ---
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 3 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			DEFINE_QHDR(gmuaddr, 16, 3),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
	(SZ_4K * HFI_QUEUE_MAX))

static int hfi_f2h_main(void *arg);

int a6xx_hwsched_hfi_init(struct adreno_device *adreno_dev)
{
	struct a6xx_hwsched_hfi *hw_hfi = to_a6xx_hwsched_hfi(adreno_dev);
	struct a6xx_hfi *hfi = to_a6xx_hfi(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:596 [MATCH: qhdr] ---
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 3 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			DEFINE_QHDR(gmuaddr, 16, 3),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
	(SZ_4K * HFI_QUEUE_MAX))

static int hfi_f2h_main(void *arg);

int a6xx_hwsched_hfi_init(struct adreno_device *adreno_dev)
{
	struct a6xx_hwsched_hfi *hw_hfi = to_a6xx_hwsched_hfi(adreno_dev);
	struct a6xx_hfi *hfi = to_a6xx_hfi(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:597 [MATCH: qhdr] ---
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 3 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			DEFINE_QHDR(gmuaddr, 16, 3),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
	(SZ_4K * HFI_QUEUE_MAX))

static int hfi_f2h_main(void *arg);

int a6xx_hwsched_hfi_init(struct adreno_device *adreno_dev)
{
	struct a6xx_hwsched_hfi *hw_hfi = to_a6xx_hwsched_hfi(adreno_dev);
	struct a6xx_hfi *hfi = to_a6xx_hfi(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:37 [MATCH: read_index] ---
		.status = 1, \
		.start_addr = GMU_QUEUE_START_ADDR(gmuaddr, id), \
		.type = QUEUE_HDR_TYPE(id, prio, 0, 0), \
		.queue_size = SZ_4K >> 2, \
		.msg_size = 0, \
		.unused0 = 0, \
		.unused1 = 0, \
		.unused2 = 0, \
		.unused3 = 0, \
		.unused4 = 0, \
		.read_index = 0, \
		.write_index = 0, \
}

static struct dq_info {
	/** @max_dq: Maximum number of dispatch queues per RB level */
	u32 max_dq;
	/** @base_dq_id: Base dqid for level */
	u32 base_dq_id;
	/** @offset: Next dqid to use for roundrobin context assignment */
	u32 offset;
} a6xx_hfi_dqs[KGSL_PRIORITY_MAX_RB_LEVELS] = {
	{ 4, 0, }, /* RB0 */
	{ 4, 4, }, /* RB1 */
	{ 3, 8, }, /* RB2 */
	{ 3, 11, }, /* RB3 */
};

static int a6xx_hfi_dispatch_queue_write(struct adreno_device *adreno_dev, uint32_t queue_idx,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:353 [MATCH: read_index] ---
static u32 peek_next_header(struct a6xx_gmu_device *gmu, uint32_t queue_idx)
{
	struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
	struct hfi_queue_table *tbl = mem_addr->hostptr;
	struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];
	u32 *queue;

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
		return 0;

	if (hdr->read_index == hdr->write_index)
		return 0;

	queue = HOST_QUEUE_START_ADDR(mem_addr, queue_idx);

	return queue[hdr->read_index];
}

static void a6xx_hwsched_process_msgq(struct adreno_device *adreno_dev)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct a6xx_hwsched_hfi *hw_hfi = to_a6xx_hwsched_hfi(adreno_dev);
	u32 rcvd[MAX_RCVD_SIZE], next_hdr;

	if (!(hw_hfi->irq_mask & HFI_IRQ_MSGQ_MASK))
		return;

	mutex_lock(&hw_hfi->msgq_mutex);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:358 [MATCH: read_index] ---
	u32 *queue;

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
		return 0;

	if (hdr->read_index == hdr->write_index)
		return 0;

	queue = HOST_QUEUE_START_ADDR(mem_addr, queue_idx);

	return queue[hdr->read_index];
}

static void a6xx_hwsched_process_msgq(struct adreno_device *adreno_dev)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct a6xx_hwsched_hfi *hw_hfi = to_a6xx_hwsched_hfi(adreno_dev);
	u32 rcvd[MAX_RCVD_SIZE], next_hdr;

	if (!(hw_hfi->irq_mask & HFI_IRQ_MSGQ_MASK))
		return;

	mutex_lock(&hw_hfi->msgq_mutex);

	for (;;) {
		next_hdr = peek_next_header(gmu, HFI_MSG_ID);

		if (!next_hdr)
			break;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:796 [MATCH: read_index] ---
	struct hfi_queue_table *tbl = gmu->hfi.hfi_mem->hostptr;
	u32 i;

	/* Flush HFI queues */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		struct hfi_queue_header *hdr = &tbl->qhdr[i];

		if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
			continue;

		hdr->read_index = hdr->write_index;
	}
}

void a6xx_hwsched_hfi_stop(struct adreno_device *adreno_dev)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);

	hfi->irq_mask &= ~HFI_IRQ_MSGQ_MASK;

	/*
	 * In some corner cases, it is possible that GMU put TS_RETIRE
	 * on the msgq after we have turned off gmu interrupts. Hence,
	 * drain the queue one last time before we reset HFI queues.
	 */
	a6xx_hwsched_process_msgq(adreno_dev);

	/* Drain the debug queue before we reset HFI queues */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:1190 [MATCH: read_index] ---
static bool is_queue_empty(struct adreno_device *adreno_dev, u32 queue_idx)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
	struct hfi_queue_table *tbl = mem_addr->hostptr;
	struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
		return true;

	if (hdr->read_index == hdr->write_index)
		return true;

	return false;
}

static int hfi_f2h_main(void *arg)
{
	struct adreno_device *adreno_dev = arg;
	struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	while (!kthread_should_stop()) {
		wait_event_interruptible(hfi->f2h_wq, kthread_should_stop() ||
			/* If msgq irq is enabled and msgq has messages to process */
			(((hfi->irq_mask & HFI_IRQ_MSGQ_MASK) &&
			!is_queue_empty(adreno_dev, HFI_MSG_ID)) ||
			/* Trace buffer has messages to process */
			!gmu_core_is_trace_empty(device->gmu_core.trace.md->hostptr) ||

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:1419 [MATCH: read_index] ---
	uint32_t i, write, empty_space;
	uint32_t size_dwords = size_bytes >> 2;
	u32 align_size = ALIGN(size_dwords, SZ_4);
	uint32_t id = MSG_HDR_GET_ID(*msg);

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED || !IS_ALIGNED(size_bytes, sizeof(u32)))
		return -EINVAL;

	queue = HOST_QUEUE_START_ADDR(gmu->hfi.hfi_mem, queue_idx);

	empty_space = (hdr->write_index >= hdr->read_index) ?
			(hdr->queue_size - (hdr->write_index - hdr->read_index))
			: (hdr->read_index - hdr->write_index);

	if (empty_space <= align_size)
		return -ENOSPC;

	write = hdr->write_index;

	for (i = 0; i < size_dwords; i++) {
		queue[write] = msg[i];
		write = (write + 1) % hdr->queue_size;
	}

	/* Cookify any non used data at the end of the write buffer */
	if (GMU_VER_MAJOR(device->gmu_core.ver.hfi) >= 2) {
		for (; i < align_size; i++) {
			queue[write] = 0xFAFAFAFA;
			write = (write + 1) % hdr->queue_size;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:1420 [MATCH: read_index] ---
	uint32_t size_dwords = size_bytes >> 2;
	u32 align_size = ALIGN(size_dwords, SZ_4);
	uint32_t id = MSG_HDR_GET_ID(*msg);

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED || !IS_ALIGNED(size_bytes, sizeof(u32)))
		return -EINVAL;

	queue = HOST_QUEUE_START_ADDR(gmu->hfi.hfi_mem, queue_idx);

	empty_space = (hdr->write_index >= hdr->read_index) ?
			(hdr->queue_size - (hdr->write_index - hdr->read_index))
			: (hdr->read_index - hdr->write_index);

	if (empty_space <= align_size)
		return -ENOSPC;

	write = hdr->write_index;

	for (i = 0; i < size_dwords; i++) {
		queue[write] = msg[i];
		write = (write + 1) % hdr->queue_size;
	}

	/* Cookify any non used data at the end of the write buffer */
	if (GMU_VER_MAJOR(device->gmu_core.ver.hfi) >= 2) {
		for (; i < align_size; i++) {
			queue[write] = 0xFAFAFAFA;
			write = (write + 1) % hdr->queue_size;
		}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:1421 [MATCH: read_index] ---
	u32 align_size = ALIGN(size_dwords, SZ_4);
	uint32_t id = MSG_HDR_GET_ID(*msg);

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED || !IS_ALIGNED(size_bytes, sizeof(u32)))
		return -EINVAL;

	queue = HOST_QUEUE_START_ADDR(gmu->hfi.hfi_mem, queue_idx);

	empty_space = (hdr->write_index >= hdr->read_index) ?
			(hdr->queue_size - (hdr->write_index - hdr->read_index))
			: (hdr->read_index - hdr->write_index);

	if (empty_space <= align_size)
		return -ENOSPC;

	write = hdr->write_index;

	for (i = 0; i < size_dwords; i++) {
		queue[write] = msg[i];
		write = (write + 1) % hdr->queue_size;
	}

	/* Cookify any non used data at the end of the write buffer */
	if (GMU_VER_MAJOR(device->gmu_core.ver.hfi) >= 2) {
		for (; i < align_size; i++) {
			queue[write] = 0xFAFAFAFA;
			write = (write + 1) % hdr->queue_size;
		}
	}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:38 [MATCH: write_index] ---
		.start_addr = GMU_QUEUE_START_ADDR(gmuaddr, id), \
		.type = QUEUE_HDR_TYPE(id, prio, 0, 0), \
		.queue_size = SZ_4K >> 2, \
		.msg_size = 0, \
		.unused0 = 0, \
		.unused1 = 0, \
		.unused2 = 0, \
		.unused3 = 0, \
		.unused4 = 0, \
		.read_index = 0, \
		.write_index = 0, \
}

static struct dq_info {
	/** @max_dq: Maximum number of dispatch queues per RB level */
	u32 max_dq;
	/** @base_dq_id: Base dqid for level */
	u32 base_dq_id;
	/** @offset: Next dqid to use for roundrobin context assignment */
	u32 offset;
} a6xx_hfi_dqs[KGSL_PRIORITY_MAX_RB_LEVELS] = {
	{ 4, 0, }, /* RB0 */
	{ 4, 4, }, /* RB1 */
	{ 3, 8, }, /* RB2 */
	{ 3, 11, }, /* RB3 */
};

static int a6xx_hfi_dispatch_queue_write(struct adreno_device *adreno_dev, uint32_t queue_idx,
	uint32_t *msg, u32 size_bytes, struct kgsl_drawobj_cmd *cmdobj,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:1426 [MATCH: write_index] ---

	queue = HOST_QUEUE_START_ADDR(gmu->hfi.hfi_mem, queue_idx);

	empty_space = (hdr->write_index >= hdr->read_index) ?
			(hdr->queue_size - (hdr->write_index - hdr->read_index))
			: (hdr->read_index - hdr->write_index);

	if (empty_space <= align_size)
		return -ENOSPC;

	write = hdr->write_index;

	for (i = 0; i < size_dwords; i++) {
		queue[write] = msg[i];
		write = (write + 1) % hdr->queue_size;
	}

	/* Cookify any non used data at the end of the write buffer */
	if (GMU_VER_MAJOR(device->gmu_core.ver.hfi) >= 2) {
		for (; i < align_size; i++) {
			queue[write] = 0xFAFAFAFA;
			write = (write + 1) % hdr->queue_size;
		}
	}

	/* Ensure packet is written out before proceeding */
	wmb();

	if (!cmdobj)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hfi.c:18 [MATCH: HFI_QUEUE_MAX] ---
#include <linux/nvmem-consumer.h>

#include "adreno.h"
#include "adreno_gen7.h"
#include "adreno_gen7_gmu.h"
#include "adreno_gen7_hfi.h"
#include "kgsl_device.h"
#include "kgsl_trace.h"

/* Below section is for all structures related to HFI queues */
#define HFI_QUEUE_MAX HFI_QUEUE_DEFAULT_CNT

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
		(HFI_QUEUE_SIZE * HFI_QUEUE_MAX))

#define HOST_QUEUE_START_ADDR(hfi_mem, i) \
	((hfi_mem)->hostptr + HFI_QUEUE_OFFSET(i))

struct gen7_hfi *to_gen7_hfi(struct adreno_device *adreno_dev)
{
	struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);

	return &gmu->hfi;
}

/* Size in below functions are in unit of dwords */
int gen7_hfi_queue_read(struct gen7_gmu_device *gmu, u32 queue_idx,
		unsigned int *output, unsigned int max_size)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hfi.c:22 [MATCH: HFI_QUEUE_MAX] ---
#include "adreno_gen7_gmu.h"
#include "adreno_gen7_hfi.h"
#include "kgsl_device.h"
#include "kgsl_trace.h"

/* Below section is for all structures related to HFI queues */
#define HFI_QUEUE_MAX HFI_QUEUE_DEFAULT_CNT

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
		(HFI_QUEUE_SIZE * HFI_QUEUE_MAX))

#define HOST_QUEUE_START_ADDR(hfi_mem, i) \
	((hfi_mem)->hostptr + HFI_QUEUE_OFFSET(i))

struct gen7_hfi *to_gen7_hfi(struct adreno_device *adreno_dev)
{
	struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);

	return &gmu->hfi;
}

/* Size in below functions are in unit of dwords */
int gen7_hfi_queue_read(struct gen7_gmu_device *gmu, u32 queue_idx,
		unsigned int *output, unsigned int max_size)
{
	struct kgsl_device *device = KGSL_DEVICE(gen7_gmu_to_adreno(gmu));
	struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
	struct hfi_queue_table *tbl = mem_addr->hostptr;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hfi.c:194 [MATCH: HFI_QUEUE_MAX] ---
{
	struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
	struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
	int i;
	struct hfi_queue_table *tbl;
	struct hfi_queue_header *hdr;
	struct {
		unsigned int idx;
		unsigned int pri;
		unsigned int status;
	} queue[HFI_QUEUE_MAX] = {
		{ HFI_CMD_ID, HFI_CMD_PRI, HFI_QUEUE_STATUS_ENABLED },
		{ HFI_MSG_ID, HFI_MSG_PRI, HFI_QUEUE_STATUS_ENABLED },
		{ HFI_DBG_ID, HFI_DBG_PRI, HFI_QUEUE_STATUS_ENABLED },
	};

	/* Fill Table Header */
	tbl = mem_addr->hostptr;
	tbl->qtbl_hdr.version = 0;
	tbl->qtbl_hdr.size = sizeof(struct hfi_queue_table) >> 2;
	tbl->qtbl_hdr.qhdr0_offset = sizeof(struct hfi_queue_table_header) >> 2;
	tbl->qtbl_hdr.qhdr_size = sizeof(struct hfi_queue_header) >> 2;
	tbl->qtbl_hdr.num_q = HFI_QUEUE_MAX;
	tbl->qtbl_hdr.num_active_q = HFI_QUEUE_MAX;

	memset(&tbl->qhdr[0], 0, sizeof(tbl->qhdr));

	/* Fill Individual Queue Headers */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hfi.c:206 [MATCH: HFI_QUEUE_MAX] ---
		{ HFI_MSG_ID, HFI_MSG_PRI, HFI_QUEUE_STATUS_ENABLED },
		{ HFI_DBG_ID, HFI_DBG_PRI, HFI_QUEUE_STATUS_ENABLED },
	};

	/* Fill Table Header */
	tbl = mem_addr->hostptr;
	tbl->qtbl_hdr.version = 0;
	tbl->qtbl_hdr.size = sizeof(struct hfi_queue_table) >> 2;
	tbl->qtbl_hdr.qhdr0_offset = sizeof(struct hfi_queue_table_header) >> 2;
	tbl->qtbl_hdr.qhdr_size = sizeof(struct hfi_queue_header) >> 2;
	tbl->qtbl_hdr.num_q = HFI_QUEUE_MAX;
	tbl->qtbl_hdr.num_active_q = HFI_QUEUE_MAX;

	memset(&tbl->qhdr[0], 0, sizeof(tbl->qhdr));

	/* Fill Individual Queue Headers */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		hdr = &tbl->qhdr[i];
		hdr->start_addr = GMU_QUEUE_START_ADDR(mem_addr->gmuaddr, i);
		hdr->type = QUEUE_HDR_TYPE(queue[i].idx, queue[i].pri, 0, 0);
		hdr->status = queue[i].status;
		hdr->queue_size = HFI_QUEUE_SIZE >> 2; /* convert to dwords */
	}
}

int gen7_hfi_init(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hfi.c:207 [MATCH: HFI_QUEUE_MAX] ---
		{ HFI_DBG_ID, HFI_DBG_PRI, HFI_QUEUE_STATUS_ENABLED },
	};

	/* Fill Table Header */
	tbl = mem_addr->hostptr;
	tbl->qtbl_hdr.version = 0;
	tbl->qtbl_hdr.size = sizeof(struct hfi_queue_table) >> 2;
	tbl->qtbl_hdr.qhdr0_offset = sizeof(struct hfi_queue_table_header) >> 2;
	tbl->qtbl_hdr.qhdr_size = sizeof(struct hfi_queue_header) >> 2;
	tbl->qtbl_hdr.num_q = HFI_QUEUE_MAX;
	tbl->qtbl_hdr.num_active_q = HFI_QUEUE_MAX;

	memset(&tbl->qhdr[0], 0, sizeof(tbl->qhdr));

	/* Fill Individual Queue Headers */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		hdr = &tbl->qhdr[i];
		hdr->start_addr = GMU_QUEUE_START_ADDR(mem_addr->gmuaddr, i);
		hdr->type = QUEUE_HDR_TYPE(queue[i].idx, queue[i].pri, 0, 0);
		hdr->status = queue[i].status;
		hdr->queue_size = HFI_QUEUE_SIZE >> 2; /* convert to dwords */
	}
}

int gen7_hfi_init(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
	struct gen7_hfi *hfi = &gmu->hfi;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hfi.c:212 [MATCH: HFI_QUEUE_MAX] ---
	tbl->qtbl_hdr.version = 0;
	tbl->qtbl_hdr.size = sizeof(struct hfi_queue_table) >> 2;
	tbl->qtbl_hdr.qhdr0_offset = sizeof(struct hfi_queue_table_header) >> 2;
	tbl->qtbl_hdr.qhdr_size = sizeof(struct hfi_queue_header) >> 2;
	tbl->qtbl_hdr.num_q = HFI_QUEUE_MAX;
	tbl->qtbl_hdr.num_active_q = HFI_QUEUE_MAX;

	memset(&tbl->qhdr[0], 0, sizeof(tbl->qhdr));

	/* Fill Individual Queue Headers */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		hdr = &tbl->qhdr[i];
		hdr->start_addr = GMU_QUEUE_START_ADDR(mem_addr->gmuaddr, i);
		hdr->type = QUEUE_HDR_TYPE(queue[i].idx, queue[i].pri, 0, 0);
		hdr->status = queue[i].status;
		hdr->queue_size = HFI_QUEUE_SIZE >> 2; /* convert to dwords */
	}
}

int gen7_hfi_init(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
	struct gen7_hfi *hfi = &gmu->hfi;

	/* Allocates & maps memory for HFI */
	if (IS_ERR_OR_NULL(hfi->hfi_mem)) {
		hfi->hfi_mem = gmu_core_reserve_kernel_block(device, 0,
				HFIMEM_SIZE, GMU_NONCACHED_KERNEL, 0);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hfi.c:645 [MATCH: HFI_QUEUE_MAX] ---

static void reset_hfi_queues(struct adreno_device *adreno_dev)
{
	struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
	struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
	struct hfi_queue_table *tbl = mem_addr->hostptr;
	struct hfi_queue_header *hdr;
	unsigned int i;

	/* Flush HFI queues */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		hdr = &tbl->qhdr[i];
		if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
			continue;

		hdr->read_index = hdr->write_index;
	}
}

/* Fill the entry and return the dword count written */
static u32 _fill_table_entry(struct hfi_table_entry *entry, u32 count,
		u32 stride_bytes, u32 *data)
{
	entry->count = count;
	entry->stride = stride_bytes >> 2; /* entry->stride is in dwords */
	memcpy(entry->data, data, stride_bytes * count);

	/* Return total dword count of entry + data */
	return (sizeof(*entry) >> 2) + (entry->count * entry->stride);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hfi.c:41 [MATCH: qhdr] ---
	return &gmu->hfi;
}

/* Size in below functions are in unit of dwords */
int gen7_hfi_queue_read(struct gen7_gmu_device *gmu, u32 queue_idx,
		unsigned int *output, unsigned int max_size)
{
	struct kgsl_device *device = KGSL_DEVICE(gen7_gmu_to_adreno(gmu));
	struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
	struct hfi_queue_table *tbl = mem_addr->hostptr;
	struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];
	u32 *queue;
	u32 msg_hdr;
	u32 i, read;
	u32 size;
	int result = 0;

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
		return -EINVAL;

	if (hdr->read_index == hdr->write_index)
		return -ENODATA;

	/* Clear the output data before populating */
	memset(output, 0, max_size);

	queue = HOST_QUEUE_START_ADDR(mem_addr, queue_idx);
	msg_hdr = queue[hdr->read_index];
	size = MSG_HDR_GET_SIZE(msg_hdr);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hfi.c:107 [MATCH: qhdr] ---

done:
	return result;
}

int gen7_hfi_queue_write(struct adreno_device *adreno_dev, u32 queue_idx,
		u32 *msg, u32 size_bytes)
{
	struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
	struct hfi_queue_table *tbl = gmu->hfi.hfi_mem->hostptr;
	struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];
	u32 *queue;
	u32 i, write_idx, read_idx, empty_space;
	u32 size_dwords = size_bytes >> 2;
	u32 align_size = ALIGN(size_dwords, SZ_4);
	u32 id = MSG_HDR_GET_ID(*msg);

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED || !IS_ALIGNED(size_bytes, sizeof(u32)))
		return -EINVAL;

	queue = HOST_QUEUE_START_ADDR(gmu->hfi.hfi_mem, queue_idx);

	write_idx = hdr->write_index;
	read_idx = hdr->read_index;

	empty_space = (write_idx >= read_idx) ?
			(hdr->queue_size - (write_idx - read_idx))
			: (read_idx - write_idx);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hfi.c:204 [MATCH: qhdr] ---
	} queue[HFI_QUEUE_MAX] = {
		{ HFI_CMD_ID, HFI_CMD_PRI, HFI_QUEUE_STATUS_ENABLED },
		{ HFI_MSG_ID, HFI_MSG_PRI, HFI_QUEUE_STATUS_ENABLED },
		{ HFI_DBG_ID, HFI_DBG_PRI, HFI_QUEUE_STATUS_ENABLED },
	};

	/* Fill Table Header */
	tbl = mem_addr->hostptr;
	tbl->qtbl_hdr.version = 0;
	tbl->qtbl_hdr.size = sizeof(struct hfi_queue_table) >> 2;
	tbl->qtbl_hdr.qhdr0_offset = sizeof(struct hfi_queue_table_header) >> 2;
	tbl->qtbl_hdr.qhdr_size = sizeof(struct hfi_queue_header) >> 2;
	tbl->qtbl_hdr.num_q = HFI_QUEUE_MAX;
	tbl->qtbl_hdr.num_active_q = HFI_QUEUE_MAX;

	memset(&tbl->qhdr[0], 0, sizeof(tbl->qhdr));

	/* Fill Individual Queue Headers */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		hdr = &tbl->qhdr[i];
		hdr->start_addr = GMU_QUEUE_START_ADDR(mem_addr->gmuaddr, i);
		hdr->type = QUEUE_HDR_TYPE(queue[i].idx, queue[i].pri, 0, 0);
		hdr->status = queue[i].status;
		hdr->queue_size = HFI_QUEUE_SIZE >> 2; /* convert to dwords */
	}
}

int gen7_hfi_init(struct adreno_device *adreno_dev)
{

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hfi.c:205 [MATCH: qhdr] ---
		{ HFI_CMD_ID, HFI_CMD_PRI, HFI_QUEUE_STATUS_ENABLED },
		{ HFI_MSG_ID, HFI_MSG_PRI, HFI_QUEUE_STATUS_ENABLED },
		{ HFI_DBG_ID, HFI_DBG_PRI, HFI_QUEUE_STATUS_ENABLED },
	};

	/* Fill Table Header */
	tbl = mem_addr->hostptr;
	tbl->qtbl_hdr.version = 0;
	tbl->qtbl_hdr.size = sizeof(struct hfi_queue_table) >> 2;
	tbl->qtbl_hdr.qhdr0_offset = sizeof(struct hfi_queue_table_header) >> 2;
	tbl->qtbl_hdr.qhdr_size = sizeof(struct hfi_queue_header) >> 2;
	tbl->qtbl_hdr.num_q = HFI_QUEUE_MAX;
	tbl->qtbl_hdr.num_active_q = HFI_QUEUE_MAX;

	memset(&tbl->qhdr[0], 0, sizeof(tbl->qhdr));

	/* Fill Individual Queue Headers */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		hdr = &tbl->qhdr[i];
		hdr->start_addr = GMU_QUEUE_START_ADDR(mem_addr->gmuaddr, i);
		hdr->type = QUEUE_HDR_TYPE(queue[i].idx, queue[i].pri, 0, 0);
		hdr->status = queue[i].status;
		hdr->queue_size = HFI_QUEUE_SIZE >> 2; /* convert to dwords */
	}
}

int gen7_hfi_init(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hfi.c:209 [MATCH: qhdr] ---

	/* Fill Table Header */
	tbl = mem_addr->hostptr;
	tbl->qtbl_hdr.version = 0;
	tbl->qtbl_hdr.size = sizeof(struct hfi_queue_table) >> 2;
	tbl->qtbl_hdr.qhdr0_offset = sizeof(struct hfi_queue_table_header) >> 2;
	tbl->qtbl_hdr.qhdr_size = sizeof(struct hfi_queue_header) >> 2;
	tbl->qtbl_hdr.num_q = HFI_QUEUE_MAX;
	tbl->qtbl_hdr.num_active_q = HFI_QUEUE_MAX;

	memset(&tbl->qhdr[0], 0, sizeof(tbl->qhdr));

	/* Fill Individual Queue Headers */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		hdr = &tbl->qhdr[i];
		hdr->start_addr = GMU_QUEUE_START_ADDR(mem_addr->gmuaddr, i);
		hdr->type = QUEUE_HDR_TYPE(queue[i].idx, queue[i].pri, 0, 0);
		hdr->status = queue[i].status;
		hdr->queue_size = HFI_QUEUE_SIZE >> 2; /* convert to dwords */
	}
}

int gen7_hfi_init(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
	struct gen7_hfi *hfi = &gmu->hfi;

	/* Allocates & maps memory for HFI */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hfi.c:213 [MATCH: qhdr] ---
	tbl->qtbl_hdr.size = sizeof(struct hfi_queue_table) >> 2;
	tbl->qtbl_hdr.qhdr0_offset = sizeof(struct hfi_queue_table_header) >> 2;
	tbl->qtbl_hdr.qhdr_size = sizeof(struct hfi_queue_header) >> 2;
	tbl->qtbl_hdr.num_q = HFI_QUEUE_MAX;
	tbl->qtbl_hdr.num_active_q = HFI_QUEUE_MAX;

	memset(&tbl->qhdr[0], 0, sizeof(tbl->qhdr));

	/* Fill Individual Queue Headers */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		hdr = &tbl->qhdr[i];
		hdr->start_addr = GMU_QUEUE_START_ADDR(mem_addr->gmuaddr, i);
		hdr->type = QUEUE_HDR_TYPE(queue[i].idx, queue[i].pri, 0, 0);
		hdr->status = queue[i].status;
		hdr->queue_size = HFI_QUEUE_SIZE >> 2; /* convert to dwords */
	}
}

int gen7_hfi_init(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
	struct gen7_hfi *hfi = &gmu->hfi;

	/* Allocates & maps memory for HFI */
	if (IS_ERR_OR_NULL(hfi->hfi_mem)) {
		hfi->hfi_mem = gmu_core_reserve_kernel_block(device, 0,
				HFIMEM_SIZE, GMU_NONCACHED_KERNEL, 0);
		if (!IS_ERR(hfi->hfi_mem))

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hfi.c:646 [MATCH: qhdr] ---
static void reset_hfi_queues(struct adreno_device *adreno_dev)
{
	struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
	struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
	struct hfi_queue_table *tbl = mem_addr->hostptr;
	struct hfi_queue_header *hdr;
	unsigned int i;

	/* Flush HFI queues */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		hdr = &tbl->qhdr[i];
		if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
			continue;

		hdr->read_index = hdr->write_index;
	}
}

/* Fill the entry and return the dword count written */
static u32 _fill_table_entry(struct hfi_table_entry *entry, u32 count,
		u32 stride_bytes, u32 *data)
{
	entry->count = count;
	entry->stride = stride_bytes >> 2; /* entry->stride is in dwords */
	memcpy(entry->data, data, stride_bytes * count);

	/* Return total dword count of entry + data */
	return (sizeof(*entry) >> 2) + (entry->count * entry->stride);
}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hfi.c:51 [MATCH: read_index] ---
	struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];
	u32 *queue;
	u32 msg_hdr;
	u32 i, read;
	u32 size;
	int result = 0;

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
		return -EINVAL;

	if (hdr->read_index == hdr->write_index)
		return -ENODATA;

	/* Clear the output data before populating */
	memset(output, 0, max_size);

	queue = HOST_QUEUE_START_ADDR(mem_addr, queue_idx);
	msg_hdr = queue[hdr->read_index];
	size = MSG_HDR_GET_SIZE(msg_hdr);

	if (size > (max_size >> 2)) {
		dev_err(GMU_PDEV_DEV(device),
		"HFI message too big: hdr:0x%x rd idx=%d\n",
			msg_hdr, hdr->read_index);
		result = -EMSGSIZE;
		goto done;
	}

	read = hdr->read_index;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hfi.c:58 [MATCH: read_index] ---
	if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
		return -EINVAL;

	if (hdr->read_index == hdr->write_index)
		return -ENODATA;

	/* Clear the output data before populating */
	memset(output, 0, max_size);

	queue = HOST_QUEUE_START_ADDR(mem_addr, queue_idx);
	msg_hdr = queue[hdr->read_index];
	size = MSG_HDR_GET_SIZE(msg_hdr);

	if (size > (max_size >> 2)) {
		dev_err(GMU_PDEV_DEV(device),
		"HFI message too big: hdr:0x%x rd idx=%d\n",
			msg_hdr, hdr->read_index);
		result = -EMSGSIZE;
		goto done;
	}

	read = hdr->read_index;

	if (read < hdr->queue_size) {
		for (i = 0; i < size && i < (max_size >> 2); i++) {
			output[i] = queue[read];
			read = (read + 1)%hdr->queue_size;
		}
		result = size;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hfi.c:64 [MATCH: read_index] ---
	/* Clear the output data before populating */
	memset(output, 0, max_size);

	queue = HOST_QUEUE_START_ADDR(mem_addr, queue_idx);
	msg_hdr = queue[hdr->read_index];
	size = MSG_HDR_GET_SIZE(msg_hdr);

	if (size > (max_size >> 2)) {
		dev_err(GMU_PDEV_DEV(device),
		"HFI message too big: hdr:0x%x rd idx=%d\n",
			msg_hdr, hdr->read_index);
		result = -EMSGSIZE;
		goto done;
	}

	read = hdr->read_index;

	if (read < hdr->queue_size) {
		for (i = 0; i < size && i < (max_size >> 2); i++) {
			output[i] = queue[read];
			read = (read + 1)%hdr->queue_size;
		}
		result = size;
	} else {
		/* In case FW messed up */
		dev_err(GMU_PDEV_DEV(device),
			"Read index %d greater than queue size %d\n",
			hdr->read_index, hdr->queue_size);
		result = -ENODATA;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hfi.c:69 [MATCH: read_index] ---
	size = MSG_HDR_GET_SIZE(msg_hdr);

	if (size > (max_size >> 2)) {
		dev_err(GMU_PDEV_DEV(device),
		"HFI message too big: hdr:0x%x rd idx=%d\n",
			msg_hdr, hdr->read_index);
		result = -EMSGSIZE;
		goto done;
	}

	read = hdr->read_index;

	if (read < hdr->queue_size) {
		for (i = 0; i < size && i < (max_size >> 2); i++) {
			output[i] = queue[read];
			read = (read + 1)%hdr->queue_size;
		}
		result = size;
	} else {
		/* In case FW messed up */
		dev_err(GMU_PDEV_DEV(device),
			"Read index %d greater than queue size %d\n",
			hdr->read_index, hdr->queue_size);
		result = -ENODATA;
	}

	read = ALIGN(read, SZ_4) % hdr->queue_size;

	hfi_update_read_idx(hdr, read);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hfi.c:81 [MATCH: read_index] ---
	if (read < hdr->queue_size) {
		for (i = 0; i < size && i < (max_size >> 2); i++) {
			output[i] = queue[read];
			read = (read + 1)%hdr->queue_size;
		}
		result = size;
	} else {
		/* In case FW messed up */
		dev_err(GMU_PDEV_DEV(device),
			"Read index %d greater than queue size %d\n",
			hdr->read_index, hdr->queue_size);
		result = -ENODATA;
	}

	read = ALIGN(read, SZ_4) % hdr->queue_size;

	hfi_update_read_idx(hdr, read);

	/* For acks, trace the packet for which this ack was sent */
	if (MSG_HDR_GET_TYPE(msg_hdr) == HFI_MSG_ACK)
		trace_kgsl_hfi_receive(MSG_HDR_GET_ID(output[1]),
			MSG_HDR_GET_SIZE(output[1]),
			MSG_HDR_GET_SEQNUM(output[1]));
	else
		trace_kgsl_hfi_receive(MSG_HDR_GET_ID(msg_hdr),
			MSG_HDR_GET_SIZE(msg_hdr), MSG_HDR_GET_SEQNUM(msg_hdr));

done:
	return result;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hfi.c:120 [MATCH: read_index] ---
	u32 size_dwords = size_bytes >> 2;
	u32 align_size = ALIGN(size_dwords, SZ_4);
	u32 id = MSG_HDR_GET_ID(*msg);

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED || !IS_ALIGNED(size_bytes, sizeof(u32)))
		return -EINVAL;

	queue = HOST_QUEUE_START_ADDR(gmu->hfi.hfi_mem, queue_idx);

	write_idx = hdr->write_index;
	read_idx = hdr->read_index;

	empty_space = (write_idx >= read_idx) ?
			(hdr->queue_size - (write_idx - read_idx))
			: (read_idx - write_idx);

	if (empty_space <= align_size)
		return -ENOSPC;

	for (i = 0; i < size_dwords; i++) {
		queue[write_idx] = msg[i];
		write_idx = (write_idx + 1) % hdr->queue_size;
	}

	/* Cookify any non used data at the end of the write buffer */
	for (; i < align_size; i++) {
		queue[write_idx] = 0xfafafafa;
		write_idx = (write_idx + 1) % hdr->queue_size;
	}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hfi.c:650 [MATCH: read_index] ---
	struct hfi_queue_table *tbl = mem_addr->hostptr;
	struct hfi_queue_header *hdr;
	unsigned int i;

	/* Flush HFI queues */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		hdr = &tbl->qhdr[i];
		if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
			continue;

		hdr->read_index = hdr->write_index;
	}
}

/* Fill the entry and return the dword count written */
static u32 _fill_table_entry(struct hfi_table_entry *entry, u32 count,
		u32 stride_bytes, u32 *data)
{
	entry->count = count;
	entry->stride = stride_bytes >> 2; /* entry->stride is in dwords */
	memcpy(entry->data, data, stride_bytes * count);

	/* Return total dword count of entry + data */
	return (sizeof(*entry) >> 2) + (entry->count * entry->stride);
}

int gen7_hfi_send_gpu_perf_table(struct adreno_device *adreno_dev)
{
	/*

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hfi.c:119 [MATCH: write_index] ---
	u32 i, write_idx, read_idx, empty_space;
	u32 size_dwords = size_bytes >> 2;
	u32 align_size = ALIGN(size_dwords, SZ_4);
	u32 id = MSG_HDR_GET_ID(*msg);

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED || !IS_ALIGNED(size_bytes, sizeof(u32)))
		return -EINVAL;

	queue = HOST_QUEUE_START_ADDR(gmu->hfi.hfi_mem, queue_idx);

	write_idx = hdr->write_index;
	read_idx = hdr->read_index;

	empty_space = (write_idx >= read_idx) ?
			(hdr->queue_size - (write_idx - read_idx))
			: (read_idx - write_idx);

	if (empty_space <= align_size)
		return -ENOSPC;

	for (i = 0; i < size_dwords; i++) {
		queue[write_idx] = msg[i];
		write_idx = (write_idx + 1) % hdr->queue_size;
	}

	/* Cookify any non used data at the end of the write buffer */
	for (; i < align_size; i++) {
		queue[write_idx] = 0xfafafafa;
		write_idx = (write_idx + 1) % hdr->queue_size;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hfi.c:142 [MATCH: write_index] ---
	}

	/* Cookify any non used data at the end of the write buffer */
	for (; i < align_size; i++) {
		queue[write_idx] = 0xfafafafa;
		write_idx = (write_idx + 1) % hdr->queue_size;
	}

	trace_kgsl_hfi_send(id, size_dwords, MSG_HDR_GET_SEQNUM(*msg));

	hfi_update_write_idx(&hdr->write_index, write_idx);

	return 0;
}

int gen7_hfi_cmdq_write(struct adreno_device *adreno_dev, u32 *msg, u32 size_bytes)
{
	struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
	struct gen7_hfi *hfi = &gmu->hfi;
	int ret;

	spin_lock(&hfi->cmdq_lock);

	if (test_bit(MSG_HDR_GET_ID(msg[0]), hfi->wb_set_record_bitmask))
		*msg = RECORD_MSG_HDR(*msg);

	ret = gen7_hfi_queue_write(adreno_dev, HFI_CMD_ID, msg, size_bytes);

	/*

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:23 [MATCH: HFI_QUEUE_MAX] ---
#include "adreno_pm4types.h"
#include "adreno_trace.h"
#include "kgsl_device.h"
#include "kgsl_eventlog.h"
#include "kgsl_gmu_core.h"
#include "kgsl_pwrctrl.h"
#include "kgsl_timeline.h"
#include "kgsl_trace.h"
#include "kgsl_util.h"

#define HFI_QUEUE_MAX (HFI_QUEUE_DEFAULT_CNT + HFI_QUEUE_DISPATCH_MAX_CNT)

#define DEFINE_QHDR(gmuaddr, id, prio) \
	{\
		.status = 1, \
		.start_addr = GMU_QUEUE_START_ADDR(gmuaddr, id), \
		.type = QUEUE_HDR_TYPE(id, prio, 0, 0), \
		.queue_size = SZ_4K >> 2, \
		.msg_size = 0, \
		.unused0 = 0, \
		.unused1 = 0, \
		.unused2 = 0, \
		.unused3 = 0, \
		.unused4 = 0, \
		.read_index = 0, \
		.write_index = 0, \
}

static struct dq_info {

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1361 [MATCH: HFI_QUEUE_MAX] ---
static void init_queues(struct gen7_hfi *hfi)
{
	u32 gmuaddr = hfi->hfi_mem->gmuaddr;
	struct hfi_queue_table hfi_table = {
		.qtbl_hdr = {
			.version = 0,
			.size = sizeof(struct hfi_queue_table) >> 2,
			.qhdr0_offset =
				sizeof(struct hfi_queue_table_header) >> 2,
			.qhdr_size = sizeof(struct hfi_queue_header) >> 2,
			.num_q = HFI_QUEUE_MAX,
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1362 [MATCH: HFI_QUEUE_MAX] ---
{
	u32 gmuaddr = hfi->hfi_mem->gmuaddr;
	struct hfi_queue_table hfi_table = {
		.qtbl_hdr = {
			.version = 0,
			.size = sizeof(struct hfi_queue_table) >> 2,
			.qhdr0_offset =
				sizeof(struct hfi_queue_table_header) >> 2,
			.qhdr_size = sizeof(struct hfi_queue_header) >> 2,
			.num_q = HFI_QUEUE_MAX,
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1395 [MATCH: HFI_QUEUE_MAX] ---
			/* 1 DQ for LPAC RB priority 4 */
			DEFINE_QHDR(gmuaddr, 16, 4),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
	(SZ_4K * HFI_QUEUE_MAX))

static int hfi_f2h_main(void *arg);

int gen7_hwsched_hfi_init(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gen7_hwsched_hfi *hw_hfi = to_gen7_hwsched_hfi(adreno_dev);
	struct gen7_hfi *hfi = to_gen7_hfi(adreno_dev);

	if (IS_ERR_OR_NULL(hw_hfi->big_ib)) {
		hw_hfi->big_ib = gmu_core_reserve_kernel_block(
				device, 0, HWSCHED_MAX_IBS * sizeof(struct hfi_issue_ib),
				GMU_NONCACHED_KERNEL, 0);
		if (IS_ERR(hw_hfi->big_ib))
			return PTR_ERR(hw_hfi->big_ib);
	}

	if (ADRENO_FEATURE(adreno_dev, ADRENO_LSR) &&

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1605 [MATCH: HFI_QUEUE_MAX] ---
	return rc;
}

static void reset_hfi_queues(struct adreno_device *adreno_dev)
{
	struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
	struct hfi_queue_table *tbl = gmu->hfi.hfi_mem->hostptr;
	u32 i;

	/* Flush HFI queues */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		struct hfi_queue_header *hdr = &tbl->qhdr[i];

		if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
			continue;

		hdr->read_index = hdr->write_index;
	}
}

void gen7_hwsched_hfi_stop(struct adreno_device *adreno_dev)
{
	struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
	struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev);

	hfi->irq_mask &= ~HFI_IRQ_MSGQ_MASK;

	/*
	 * In some corner cases, it is possible that GMU put TS_RETIRE

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:25 [MATCH: qhdr] ---
#include "kgsl_device.h"
#include "kgsl_eventlog.h"
#include "kgsl_gmu_core.h"
#include "kgsl_pwrctrl.h"
#include "kgsl_timeline.h"
#include "kgsl_trace.h"
#include "kgsl_util.h"

#define HFI_QUEUE_MAX (HFI_QUEUE_DEFAULT_CNT + HFI_QUEUE_DISPATCH_MAX_CNT)

#define DEFINE_QHDR(gmuaddr, id, prio) \
	{\
		.status = 1, \
		.start_addr = GMU_QUEUE_START_ADDR(gmuaddr, id), \
		.type = QUEUE_HDR_TYPE(id, prio, 0, 0), \
		.queue_size = SZ_4K >> 2, \
		.msg_size = 0, \
		.unused0 = 0, \
		.unused1 = 0, \
		.unused2 = 0, \
		.unused3 = 0, \
		.unused4 = 0, \
		.read_index = 0, \
		.write_index = 0, \
}

static struct dq_info {
	/** @max_dq: Maximum number of dispatch queues per RB level */
	u32 max_dq;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:628 [MATCH: qhdr] ---

	/* Return true for fatal errors to perform recovery sequence */
	return true;
}

static bool is_queue_empty(struct adreno_device *adreno_dev, u32 queue_idx)
{
	struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
	struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
	struct hfi_queue_table *tbl = mem_addr->hostptr;
	struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
		return true;

	if (hdr->read_index == hdr->write_index)
		return true;

	/*
	 * This is to ensure that the queue is not read speculatively before the queue empty
	 * condition is evaluated
	 */
	rmb();

	return false;
}

static u32 peek_next_header(struct adreno_device *adreno_dev, struct gen7_gmu_device *gmu,
	u32 queue_idx)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:650 [MATCH: qhdr] ---
	rmb();

	return false;
}

static u32 peek_next_header(struct adreno_device *adreno_dev, struct gen7_gmu_device *gmu,
	u32 queue_idx)
{
	struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
	struct hfi_queue_table *tbl = mem_addr->hostptr;
	struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];
	u32 *queue;

	if (is_queue_empty(adreno_dev, queue_idx))
		return 0;

	queue = HOST_QUEUE_START_ADDR(mem_addr, queue_idx);

	return queue[hdr->read_index];
}

static void process_ctx_bad(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	if (GMU_VER_MINOR(device->gmu_core.ver.hfi) < 2) {
		log_gpu_fault_legacy(adreno_dev);
		goto done;
	}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1358 [MATCH: qhdr] ---
	return rc;
}

static void init_queues(struct gen7_hfi *hfi)
{
	u32 gmuaddr = hfi->hfi_mem->gmuaddr;
	struct hfi_queue_table hfi_table = {
		.qtbl_hdr = {
			.version = 0,
			.size = sizeof(struct hfi_queue_table) >> 2,
			.qhdr0_offset =
				sizeof(struct hfi_queue_table_header) >> 2,
			.qhdr_size = sizeof(struct hfi_queue_header) >> 2,
			.num_q = HFI_QUEUE_MAX,
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1360 [MATCH: qhdr] ---

static void init_queues(struct gen7_hfi *hfi)
{
	u32 gmuaddr = hfi->hfi_mem->gmuaddr;
	struct hfi_queue_table hfi_table = {
		.qtbl_hdr = {
			.version = 0,
			.size = sizeof(struct hfi_queue_table) >> 2,
			.qhdr0_offset =
				sizeof(struct hfi_queue_table_header) >> 2,
			.qhdr_size = sizeof(struct hfi_queue_header) >> 2,
			.num_q = HFI_QUEUE_MAX,
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1364 [MATCH: qhdr] ---
	struct hfi_queue_table hfi_table = {
		.qtbl_hdr = {
			.version = 0,
			.size = sizeof(struct hfi_queue_table) >> 2,
			.qhdr0_offset =
				sizeof(struct hfi_queue_table_header) >> 2,
			.qhdr_size = sizeof(struct hfi_queue_header) >> 2,
			.num_q = HFI_QUEUE_MAX,
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 2 DQs for RB priority 3 */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1365 [MATCH: qhdr] ---
		.qtbl_hdr = {
			.version = 0,
			.size = sizeof(struct hfi_queue_table) >> 2,
			.qhdr0_offset =
				sizeof(struct hfi_queue_table_header) >> 2,
			.qhdr_size = sizeof(struct hfi_queue_header) >> 2,
			.num_q = HFI_QUEUE_MAX,
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 2 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1366 [MATCH: qhdr] ---
			.version = 0,
			.size = sizeof(struct hfi_queue_table) >> 2,
			.qhdr0_offset =
				sizeof(struct hfi_queue_table_header) >> 2,
			.qhdr_size = sizeof(struct hfi_queue_header) >> 2,
			.num_q = HFI_QUEUE_MAX,
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 2 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1367 [MATCH: qhdr] ---
			.size = sizeof(struct hfi_queue_table) >> 2,
			.qhdr0_offset =
				sizeof(struct hfi_queue_table_header) >> 2,
			.qhdr_size = sizeof(struct hfi_queue_header) >> 2,
			.num_q = HFI_QUEUE_MAX,
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 2 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			/* 1 DQ for LPAC RB priority 4 */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1369 [MATCH: qhdr] ---
				sizeof(struct hfi_queue_table_header) >> 2,
			.qhdr_size = sizeof(struct hfi_queue_header) >> 2,
			.num_q = HFI_QUEUE_MAX,
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 2 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			/* 1 DQ for LPAC RB priority 4 */
			DEFINE_QHDR(gmuaddr, 16, 4),
		},

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1370 [MATCH: qhdr] ---
			.qhdr_size = sizeof(struct hfi_queue_header) >> 2,
			.num_q = HFI_QUEUE_MAX,
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 2 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			/* 1 DQ for LPAC RB priority 4 */
			DEFINE_QHDR(gmuaddr, 16, 4),
		},
	};

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1371 [MATCH: qhdr] ---
			.num_q = HFI_QUEUE_MAX,
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 2 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			/* 1 DQ for LPAC RB priority 4 */
			DEFINE_QHDR(gmuaddr, 16, 4),
		},
	};


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1372 [MATCH: qhdr] ---
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 2 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			/* 1 DQ for LPAC RB priority 4 */
			DEFINE_QHDR(gmuaddr, 16, 4),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1374 [MATCH: qhdr] ---
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 2 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			/* 1 DQ for LPAC RB priority 4 */
			DEFINE_QHDR(gmuaddr, 16, 4),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1375 [MATCH: qhdr] ---
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 2 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			/* 1 DQ for LPAC RB priority 4 */
			DEFINE_QHDR(gmuaddr, 16, 4),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1376 [MATCH: qhdr] ---
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 2 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			/* 1 DQ for LPAC RB priority 4 */
			DEFINE_QHDR(gmuaddr, 16, 4),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1377 [MATCH: qhdr] ---
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
			/* 4 DQs for RB priority 0 */
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 2 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			/* 1 DQ for LPAC RB priority 4 */
			DEFINE_QHDR(gmuaddr, 16, 4),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
	(SZ_4K * HFI_QUEUE_MAX))

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1379 [MATCH: qhdr] ---
			DEFINE_QHDR(gmuaddr, 3, 0),
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 2 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			/* 1 DQ for LPAC RB priority 4 */
			DEFINE_QHDR(gmuaddr, 16, 4),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
	(SZ_4K * HFI_QUEUE_MAX))

static int hfi_f2h_main(void *arg);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1380 [MATCH: qhdr] ---
			DEFINE_QHDR(gmuaddr, 4, 0),
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 2 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			/* 1 DQ for LPAC RB priority 4 */
			DEFINE_QHDR(gmuaddr, 16, 4),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
	(SZ_4K * HFI_QUEUE_MAX))

static int hfi_f2h_main(void *arg);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1381 [MATCH: qhdr] ---
			DEFINE_QHDR(gmuaddr, 5, 0),
			DEFINE_QHDR(gmuaddr, 6, 0),
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 2 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			/* 1 DQ for LPAC RB priority 4 */
			DEFINE_QHDR(gmuaddr, 16, 4),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
	(SZ_4K * HFI_QUEUE_MAX))

static int hfi_f2h_main(void *arg);

int gen7_hwsched_hfi_init(struct adreno_device *adreno_dev)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1383 [MATCH: qhdr] ---
			/* 4 DQs for RB priority 1 */
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 2 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			/* 1 DQ for LPAC RB priority 4 */
			DEFINE_QHDR(gmuaddr, 16, 4),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
	(SZ_4K * HFI_QUEUE_MAX))

static int hfi_f2h_main(void *arg);

int gen7_hwsched_hfi_init(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1384 [MATCH: qhdr] ---
			DEFINE_QHDR(gmuaddr, 7, 1),
			DEFINE_QHDR(gmuaddr, 8, 1),
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 2 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			/* 1 DQ for LPAC RB priority 4 */
			DEFINE_QHDR(gmuaddr, 16, 4),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
	(SZ_4K * HFI_QUEUE_MAX))

static int hfi_f2h_main(void *arg);

int gen7_hwsched_hfi_init(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gen7_hwsched_hfi *hw_hfi = to_gen7_hwsched_hfi(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1386 [MATCH: qhdr] ---
			DEFINE_QHDR(gmuaddr, 9, 1),
			DEFINE_QHDR(gmuaddr, 10, 1),
			/* 3 DQs for RB priority 2 */
			DEFINE_QHDR(gmuaddr, 11, 2),
			DEFINE_QHDR(gmuaddr, 12, 2),
			DEFINE_QHDR(gmuaddr, 13, 2),
			/* 2 DQs for RB priority 3 */
			DEFINE_QHDR(gmuaddr, 14, 3),
			DEFINE_QHDR(gmuaddr, 15, 3),
			/* 1 DQ for LPAC RB priority 4 */
			DEFINE_QHDR(gmuaddr, 16, 4),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
	(SZ_4K * HFI_QUEUE_MAX))

static int hfi_f2h_main(void *arg);

int gen7_hwsched_hfi_init(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gen7_hwsched_hfi *hw_hfi = to_gen7_hwsched_hfi(adreno_dev);
	struct gen7_hfi *hfi = to_gen7_hfi(adreno_dev);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1606 [MATCH: qhdr] ---
}

static void reset_hfi_queues(struct adreno_device *adreno_dev)
{
	struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
	struct hfi_queue_table *tbl = gmu->hfi.hfi_mem->hostptr;
	u32 i;

	/* Flush HFI queues */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		struct hfi_queue_header *hdr = &tbl->qhdr[i];

		if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
			continue;

		hdr->read_index = hdr->write_index;
	}
}

void gen7_hwsched_hfi_stop(struct adreno_device *adreno_dev)
{
	struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
	struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev);

	hfi->irq_mask &= ~HFI_IRQ_MSGQ_MASK;

	/*
	 * In some corner cases, it is possible that GMU put TS_RETIRE
	 * on the msgq after we have turned off gmu interrupts. Hence,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:3331 [MATCH: qhdr] ---
		list_move_tail(&entry->node, &drawctxt->hw_fence_inflight_list);
	}
}

/* Size in below functions are in unit of dwords */
static int gen7_hfi_dispatch_queue_write(struct adreno_device *adreno_dev, u32 queue_idx,
	u32 *msg, u32 size_bytes, struct kgsl_drawobj_cmd *cmdobj, struct adreno_submit_time *time)
{
	struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
	struct hfi_queue_table *tbl = gmu->hfi.hfi_mem->hostptr;
	struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];
	u32 *queue;
	u32 i, write, empty_space;
	u32 size_dwords = size_bytes >> 2;
	u32 align_size = ALIGN(size_dwords, SZ_4);
	u32 id = MSG_HDR_GET_ID(*msg);

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED || !IS_ALIGNED(size_bytes, sizeof(u32)))
		return -EINVAL;

	queue = HOST_QUEUE_START_ADDR(gmu->hfi.hfi_mem, queue_idx);

	empty_space = (hdr->write_index >= hdr->read_index) ?
			(hdr->queue_size - (hdr->write_index - hdr->read_index))
			: (hdr->read_index - hdr->write_index);

	if (empty_space <= align_size)
		return -ENOSPC;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:37 [MATCH: read_index] ---
		.status = 1, \
		.start_addr = GMU_QUEUE_START_ADDR(gmuaddr, id), \
		.type = QUEUE_HDR_TYPE(id, prio, 0, 0), \
		.queue_size = SZ_4K >> 2, \
		.msg_size = 0, \
		.unused0 = 0, \
		.unused1 = 0, \
		.unused2 = 0, \
		.unused3 = 0, \
		.unused4 = 0, \
		.read_index = 0, \
		.write_index = 0, \
}

static struct dq_info {
	/** @max_dq: Maximum number of dispatch queues per RB level */
	u32 max_dq;
	/** @base_dq_id: Base dqid for level */
	u32 base_dq_id;
	/** @offset: Next dqid to use for roundrobin context assignment */
	u32 offset;
} gen7_hfi_dqs[KGSL_PRIORITY_MAX_RB_LEVELS] = {
	{ 4, 0, }, /* RB0 */
	{ 4, 4, }, /* RB1 */
	{ 3, 8, }, /* RB2 */
	{ 3, 11, }, /* RB3 */
}, gen7_hfi_dqs_lpac[KGSL_PRIORITY_MAX_RB_LEVELS + 1] = {
	{ 4, 0, }, /* RB0 */
	{ 4, 4, }, /* RB1 */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:250 [MATCH: read_index] ---
	read_unlock(&device->context_lock);

	if (!ret)
		return;

	drawctxt = ADRENO_CONTEXT(context);

	hdr = drawctxt->gmu_context_queue.hostptr;
	queue = (u32 *)(drawctxt->gmu_context_queue.hostptr + sizeof(*hdr));

	for (i = hdr->read_index; i != hdr->write_index;) {
		if (MSG_HDR_GET_ID(queue[i]) != H2F_MSG_ISSUE_SYNCOBJ) {
			i = (i + MSG_HDR_GET_SIZE(queue[i])) % hdr->queue_size;
			continue;
		}

		if (adreno_gmu_context_queue_read(drawctxt, (u32 *) &cmd, i, sizeof(cmd) >> 2))
			break;

		if (cmd.timestamp == ts) {
			log_syncobj(gmu, drawctxt, &cmd,
				(i + (sizeof(cmd) >> 2)) % hdr->queue_size);
			break;
		}
		i = (i + MSG_HDR_GET_SIZE(queue[i])) % hdr->queue_size;
	}

	if (i == hdr->write_index)
		dev_err(GMU_PDEV_DEV(device), "Couldn't find unsignaled syncobj ctx:%d ts:%d\n",

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:633 [MATCH: read_index] ---
static bool is_queue_empty(struct adreno_device *adreno_dev, u32 queue_idx)
{
	struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
	struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
	struct hfi_queue_table *tbl = mem_addr->hostptr;
	struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
		return true;

	if (hdr->read_index == hdr->write_index)
		return true;

	/*
	 * This is to ensure that the queue is not read speculatively before the queue empty
	 * condition is evaluated
	 */
	rmb();

	return false;
}

static u32 peek_next_header(struct adreno_device *adreno_dev, struct gen7_gmu_device *gmu,
	u32 queue_idx)
{
	struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
	struct hfi_queue_table *tbl = mem_addr->hostptr;
	struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];
	u32 *queue;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:658 [MATCH: read_index] ---
	struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
	struct hfi_queue_table *tbl = mem_addr->hostptr;
	struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];
	u32 *queue;

	if (is_queue_empty(adreno_dev, queue_idx))
		return 0;

	queue = HOST_QUEUE_START_ADDR(mem_addr, queue_idx);

	return queue[hdr->read_index];
}

static void process_ctx_bad(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	if (GMU_VER_MINOR(device->gmu_core.ver.hfi) < 2) {
		log_gpu_fault_legacy(adreno_dev);
		goto done;
	}

	/* Non fatal RBBM error interrupts don't go through reset and recovery */
	if (!log_gpu_fault(adreno_dev)) {
		memset(adreno_dev->hwsched.ctxt_bad, 0x0, HFI_MAX_MSG_SIZE);
		return;
	}

done:

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1611 [MATCH: read_index] ---
	struct hfi_queue_table *tbl = gmu->hfi.hfi_mem->hostptr;
	u32 i;

	/* Flush HFI queues */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		struct hfi_queue_header *hdr = &tbl->qhdr[i];

		if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
			continue;

		hdr->read_index = hdr->write_index;
	}
}

void gen7_hwsched_hfi_stop(struct adreno_device *adreno_dev)
{
	struct gen7_gmu_device *gmu = to_gen7_gmu(adreno_dev);
	struct gen7_hwsched_hfi *hfi = to_gen7_hwsched_hfi(adreno_dev);

	hfi->irq_mask &= ~HFI_IRQ_MSGQ_MASK;

	/*
	 * In some corner cases, it is possible that GMU put TS_RETIRE
	 * on the msgq after we have turned off gmu interrupts. Hence,
	 * drain the queue one last time before we reset HFI queues.
	 */
	gen7_hwsched_process_msgq(adreno_dev);

	/* Drain the debug queue before we reset HFI queues */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:3343 [MATCH: read_index] ---
	u32 i, write, empty_space;
	u32 size_dwords = size_bytes >> 2;
	u32 align_size = ALIGN(size_dwords, SZ_4);
	u32 id = MSG_HDR_GET_ID(*msg);

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED || !IS_ALIGNED(size_bytes, sizeof(u32)))
		return -EINVAL;

	queue = HOST_QUEUE_START_ADDR(gmu->hfi.hfi_mem, queue_idx);

	empty_space = (hdr->write_index >= hdr->read_index) ?
			(hdr->queue_size - (hdr->write_index - hdr->read_index))
			: (hdr->read_index - hdr->write_index);

	if (empty_space <= align_size)
		return -ENOSPC;

	write = hdr->write_index;

	for (i = 0; i < size_dwords; i++) {
		queue[write] = msg[i];
		write = (write + 1) % hdr->queue_size;
	}

	/* Cookify any non used data at the end of the write buffer */
	for (; i < align_size; i++) {
		queue[write] = 0xfafafafa;
		write = (write + 1) % hdr->queue_size;
	}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:3344 [MATCH: read_index] ---
	u32 size_dwords = size_bytes >> 2;
	u32 align_size = ALIGN(size_dwords, SZ_4);
	u32 id = MSG_HDR_GET_ID(*msg);

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED || !IS_ALIGNED(size_bytes, sizeof(u32)))
		return -EINVAL;

	queue = HOST_QUEUE_START_ADDR(gmu->hfi.hfi_mem, queue_idx);

	empty_space = (hdr->write_index >= hdr->read_index) ?
			(hdr->queue_size - (hdr->write_index - hdr->read_index))
			: (hdr->read_index - hdr->write_index);

	if (empty_space <= align_size)
		return -ENOSPC;

	write = hdr->write_index;

	for (i = 0; i < size_dwords; i++) {
		queue[write] = msg[i];
		write = (write + 1) % hdr->queue_size;
	}

	/* Cookify any non used data at the end of the write buffer */
	for (; i < align_size; i++) {
		queue[write] = 0xfafafafa;
		write = (write + 1) % hdr->queue_size;
	}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:3345 [MATCH: read_index] ---
	u32 align_size = ALIGN(size_dwords, SZ_4);
	u32 id = MSG_HDR_GET_ID(*msg);

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED || !IS_ALIGNED(size_bytes, sizeof(u32)))
		return -EINVAL;

	queue = HOST_QUEUE_START_ADDR(gmu->hfi.hfi_mem, queue_idx);

	empty_space = (hdr->write_index >= hdr->read_index) ?
			(hdr->queue_size - (hdr->write_index - hdr->read_index))
			: (hdr->read_index - hdr->write_index);

	if (empty_space <= align_size)
		return -ENOSPC;

	write = hdr->write_index;

	for (i = 0; i < size_dwords; i++) {
		queue[write] = msg[i];
		write = (write + 1) % hdr->queue_size;
	}

	/* Cookify any non used data at the end of the write buffer */
	for (; i < align_size; i++) {
		queue[write] = 0xfafafafa;
		write = (write + 1) % hdr->queue_size;
	}

	/* Ensure packet is written out before proceeding */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:38 [MATCH: write_index] ---
		.start_addr = GMU_QUEUE_START_ADDR(gmuaddr, id), \
		.type = QUEUE_HDR_TYPE(id, prio, 0, 0), \
		.queue_size = SZ_4K >> 2, \
		.msg_size = 0, \
		.unused0 = 0, \
		.unused1 = 0, \
		.unused2 = 0, \
		.unused3 = 0, \
		.unused4 = 0, \
		.read_index = 0, \
		.write_index = 0, \
}

static struct dq_info {
	/** @max_dq: Maximum number of dispatch queues per RB level */
	u32 max_dq;
	/** @base_dq_id: Base dqid for level */
	u32 base_dq_id;
	/** @offset: Next dqid to use for roundrobin context assignment */
	u32 offset;
} gen7_hfi_dqs[KGSL_PRIORITY_MAX_RB_LEVELS] = {
	{ 4, 0, }, /* RB0 */
	{ 4, 4, }, /* RB1 */
	{ 3, 8, }, /* RB2 */
	{ 3, 11, }, /* RB3 */
}, gen7_hfi_dqs_lpac[KGSL_PRIORITY_MAX_RB_LEVELS + 1] = {
	{ 4, 0, }, /* RB0 */
	{ 4, 4, }, /* RB1 */
	{ 3, 8, }, /* RB2 */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:267 [MATCH: write_index] ---
			break;

		if (cmd.timestamp == ts) {
			log_syncobj(gmu, drawctxt, &cmd,
				(i + (sizeof(cmd) >> 2)) % hdr->queue_size);
			break;
		}
		i = (i + MSG_HDR_GET_SIZE(queue[i])) % hdr->queue_size;
	}

	if (i == hdr->write_index)
		dev_err(GMU_PDEV_DEV(device), "Couldn't find unsignaled syncobj ctx:%d ts:%d\n",
			ctxt_id, ts);

	kgsl_context_put(context);
}

static void log_gpu_fault_legacy(struct adreno_device *adreno_dev)
{
	struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
	struct hfi_context_bad_cmd_legacy *cmd = adreno_dev->hwsched.ctxt_bad;

	switch (cmd->error) {
	case GMU_GPU_HW_HANG:
		dev_crit_ratelimited(gmu_pdev_dev, "MISC: GPU hang detected\n");
		break;
	case GMU_GPU_SW_HANG:
		dev_crit_ratelimited(gmu_pdev_dev, "gpu timeout ctx %u ts %u\n",
			cmd->ctxt_id, cmd->ts);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:1536 [MATCH: write_index] ---
	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);

	pending_ack.sent_hdr = cmd.hdr;

	rc = gen7_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
	if (rc)
		return rc;

poll:
	rc = adreno_hwsched_poll_msg_queue_write_index(gmu->hfi.hfi_mem);

	if (rc) {
		dev_err(gmu_pdev_dev,
			"Timed out processing MSG_START seqnum: %d\n",
			seqnum);
		gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START);
		goto done;
	}

	rc = gen7_hfi_queue_read(gmu, HFI_MSG_ID, rcvd, sizeof(rcvd));
	if (rc <= 0) {
		dev_err(gmu_pdev_dev,
			"MSG_START: payload error: %d\n",
			rc);
		gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START);
		goto done;
	}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:3350 [MATCH: write_index] ---

	queue = HOST_QUEUE_START_ADDR(gmu->hfi.hfi_mem, queue_idx);

	empty_space = (hdr->write_index >= hdr->read_index) ?
			(hdr->queue_size - (hdr->write_index - hdr->read_index))
			: (hdr->read_index - hdr->write_index);

	if (empty_space <= align_size)
		return -ENOSPC;

	write = hdr->write_index;

	for (i = 0; i < size_dwords; i++) {
		queue[write] = msg[i];
		write = (write + 1) % hdr->queue_size;
	}

	/* Cookify any non used data at the end of the write buffer */
	for (; i < align_size; i++) {
		queue[write] = 0xfafafafa;
		write = (write + 1) % hdr->queue_size;
	}

	/* Ensure packet is written out before proceeding */
	wmb();

	if (!cmdobj)
		goto done;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_hwsched_hfi.c:3382 [MATCH: write_index] ---
	 * Put the profiling information in the user profiling buffer.
	 * The hfi_update_write_idx below has a wmb() before the actual
	 * write index update to ensure that the GMU does not see the
	 * packet before the profile data is written out.
	 */
	adreno_profile_submit_time(time);

done:
	trace_kgsl_hfi_send(id, size_dwords, MSG_HDR_GET_SEQNUM(*msg));

	hfi_update_write_idx(&hdr->write_index, write);

	return 0;
}

int gen7_hwsched_submit_drawobj(struct adreno_device *adreno_dev, struct kgsl_drawobj *drawobj)
{
	int ret = 0;
	u32 cmd_sizebytes, seqnum;
	struct kgsl_drawobj_cmd *cmdobj = NULL;
	struct hfi_submit_cmd *cmd;
	struct adreno_submit_time time = {0};
	struct adreno_context *drawctxt = ADRENO_CONTEXT(drawobj->context);
	static void *cmdbuf;
	struct gmu_context_queue_header *hdr = NULL;

	if (cmdbuf == NULL) {
		struct kgsl_device *device = KGSL_DEVICE(adreno_dev);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen7_snapshot.c:630 [MATCH: read_index] ---
		count = write_ptr;
		header->size = count << 2;
		start_idx = 0;
	} else {
		/* Read entire 2k buffer starting from write ptr */
		start_idx = write_ptr + 1;
		count = SZ_512;
		header->size = SZ_2K;
	}

	kgsl_regmap_read_indexed_interleaved(&device->regmap,
		GEN7_DBGC_DBG_TRACE_BUFFER_RD_ADDR, GEN7_DBGC_DBG_TRACE_BUFFER_RD_DATA, data,
			start_idx, count);

	return (sizeof(*header) + header->size);
}

static size_t gen7_snapshot_trace_buffer_etb(struct kgsl_device *device,
		u8 *buf, size_t remain, void *priv)
{
	u32 read_ptr, count, write_ptr, val, idx = 0;
	struct kgsl_snapshot_trace_buffer *header = (struct kgsl_snapshot_trace_buffer *) buf;
	u32 *data = (u32 *)(buf + sizeof(*header));
	struct gen7_trace_buffer_info *info = (struct gen7_trace_buffer_info *) priv;

	/* Unlock ETB buffer */
	qdss_regwrite(tmc_virt, QDSS_AOSS_APB_TMC_LAR, 0xC5ACCE55);

	/* Make sure unlock goes through before proceeding further */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:19 [MATCH: HFI_QUEUE_MAX] ---

#include "adreno.h"
#include "adreno_gen8.h"
#include "adreno_gen8_gmu.h"
#include "adreno_gen8_hfi.h"
#include "kgsl_device.h"
#include "kgsl_gmu_core.h"
#include "kgsl_trace.h"

/* Below section is for all structures related to HFI queues */
#define HFI_QUEUE_MAX HFI_QUEUE_DEFAULT_CNT

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
		(HFI_QUEUE_SIZE * HFI_QUEUE_MAX))

#define HOST_QUEUE_START_ADDR(hfi_mem, i) \
	((hfi_mem)->hostptr + HFI_QUEUE_OFFSET(i))

struct gen8_hfi *to_gen8_hfi(struct adreno_device *adreno_dev)
{
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);

	return &gmu->hfi;
}

/* Size in below functions are in unit of dwords */
int gen8_hfi_queue_read(struct gen8_gmu_device *gmu, u32 queue_idx,
		u32 *output, u32 max_size)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:23 [MATCH: HFI_QUEUE_MAX] ---
#include "adreno_gen8_hfi.h"
#include "kgsl_device.h"
#include "kgsl_gmu_core.h"
#include "kgsl_trace.h"

/* Below section is for all structures related to HFI queues */
#define HFI_QUEUE_MAX HFI_QUEUE_DEFAULT_CNT

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
		(HFI_QUEUE_SIZE * HFI_QUEUE_MAX))

#define HOST_QUEUE_START_ADDR(hfi_mem, i) \
	((hfi_mem)->hostptr + HFI_QUEUE_OFFSET(i))

struct gen8_hfi *to_gen8_hfi(struct adreno_device *adreno_dev)
{
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);

	return &gmu->hfi;
}

/* Size in below functions are in unit of dwords */
int gen8_hfi_queue_read(struct gen8_gmu_device *gmu, u32 queue_idx,
		u32 *output, u32 max_size)
{
	struct kgsl_device *device = KGSL_DEVICE(gen8_gmu_to_adreno(gmu));
	struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
	struct hfi_queue_table *tbl = mem_addr->hostptr;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:195 [MATCH: HFI_QUEUE_MAX] ---
{
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
	int i;
	struct hfi_queue_table *tbl;
	struct hfi_queue_header *hdr;
	struct {
		u32 idx;
		u32 pri;
		u32 status;
	} queue[HFI_QUEUE_MAX] = {
		{ HFI_CMD_ID, HFI_CMD_PRI, HFI_QUEUE_STATUS_ENABLED },
		{ HFI_MSG_ID, HFI_MSG_PRI, HFI_QUEUE_STATUS_ENABLED },
		{ HFI_DBG_ID, HFI_DBG_PRI, HFI_QUEUE_STATUS_ENABLED },
	};

	/* Fill Table Header */
	tbl = mem_addr->hostptr;
	tbl->qtbl_hdr.version = 0;
	tbl->qtbl_hdr.size = sizeof(struct hfi_queue_table) >> 2;
	tbl->qtbl_hdr.qhdr0_offset = sizeof(struct hfi_queue_table_header) >> 2;
	tbl->qtbl_hdr.qhdr_size = sizeof(struct hfi_queue_header) >> 2;
	tbl->qtbl_hdr.num_q = HFI_QUEUE_MAX;
	tbl->qtbl_hdr.num_active_q = HFI_QUEUE_MAX;

	memset(&tbl->qhdr[0], 0, sizeof(tbl->qhdr));

	/* Fill Individual Queue Headers */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:207 [MATCH: HFI_QUEUE_MAX] ---
		{ HFI_MSG_ID, HFI_MSG_PRI, HFI_QUEUE_STATUS_ENABLED },
		{ HFI_DBG_ID, HFI_DBG_PRI, HFI_QUEUE_STATUS_ENABLED },
	};

	/* Fill Table Header */
	tbl = mem_addr->hostptr;
	tbl->qtbl_hdr.version = 0;
	tbl->qtbl_hdr.size = sizeof(struct hfi_queue_table) >> 2;
	tbl->qtbl_hdr.qhdr0_offset = sizeof(struct hfi_queue_table_header) >> 2;
	tbl->qtbl_hdr.qhdr_size = sizeof(struct hfi_queue_header) >> 2;
	tbl->qtbl_hdr.num_q = HFI_QUEUE_MAX;
	tbl->qtbl_hdr.num_active_q = HFI_QUEUE_MAX;

	memset(&tbl->qhdr[0], 0, sizeof(tbl->qhdr));

	/* Fill Individual Queue Headers */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		hdr = &tbl->qhdr[i];
		hdr->start_addr = GMU_QUEUE_START_ADDR(mem_addr->gmuaddr, i);
		hdr->type = QUEUE_HDR_TYPE(queue[i].idx, queue[i].pri, 0, 0);
		hdr->status = queue[i].status;
		hdr->queue_size = HFI_QUEUE_SIZE >> 2; /* convert to dwords */
	}
}

int gen8_hfi_init(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:208 [MATCH: HFI_QUEUE_MAX] ---
		{ HFI_DBG_ID, HFI_DBG_PRI, HFI_QUEUE_STATUS_ENABLED },
	};

	/* Fill Table Header */
	tbl = mem_addr->hostptr;
	tbl->qtbl_hdr.version = 0;
	tbl->qtbl_hdr.size = sizeof(struct hfi_queue_table) >> 2;
	tbl->qtbl_hdr.qhdr0_offset = sizeof(struct hfi_queue_table_header) >> 2;
	tbl->qtbl_hdr.qhdr_size = sizeof(struct hfi_queue_header) >> 2;
	tbl->qtbl_hdr.num_q = HFI_QUEUE_MAX;
	tbl->qtbl_hdr.num_active_q = HFI_QUEUE_MAX;

	memset(&tbl->qhdr[0], 0, sizeof(tbl->qhdr));

	/* Fill Individual Queue Headers */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		hdr = &tbl->qhdr[i];
		hdr->start_addr = GMU_QUEUE_START_ADDR(mem_addr->gmuaddr, i);
		hdr->type = QUEUE_HDR_TYPE(queue[i].idx, queue[i].pri, 0, 0);
		hdr->status = queue[i].status;
		hdr->queue_size = HFI_QUEUE_SIZE >> 2; /* convert to dwords */
	}
}

int gen8_hfi_init(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct gen8_hfi *hfi = &gmu->hfi;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:213 [MATCH: HFI_QUEUE_MAX] ---
	tbl->qtbl_hdr.version = 0;
	tbl->qtbl_hdr.size = sizeof(struct hfi_queue_table) >> 2;
	tbl->qtbl_hdr.qhdr0_offset = sizeof(struct hfi_queue_table_header) >> 2;
	tbl->qtbl_hdr.qhdr_size = sizeof(struct hfi_queue_header) >> 2;
	tbl->qtbl_hdr.num_q = HFI_QUEUE_MAX;
	tbl->qtbl_hdr.num_active_q = HFI_QUEUE_MAX;

	memset(&tbl->qhdr[0], 0, sizeof(tbl->qhdr));

	/* Fill Individual Queue Headers */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		hdr = &tbl->qhdr[i];
		hdr->start_addr = GMU_QUEUE_START_ADDR(mem_addr->gmuaddr, i);
		hdr->type = QUEUE_HDR_TYPE(queue[i].idx, queue[i].pri, 0, 0);
		hdr->status = queue[i].status;
		hdr->queue_size = HFI_QUEUE_SIZE >> 2; /* convert to dwords */
	}
}

int gen8_hfi_init(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct gen8_hfi *hfi = &gmu->hfi;

	/* Allocates & maps memory for HFI */
	if (IS_ERR_OR_NULL(hfi->hfi_mem)) {
		hfi->hfi_mem = gmu_core_reserve_kernel_block(device, 0,
				HFIMEM_SIZE, GMU_NONCACHED_KERNEL, 0);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:729 [MATCH: HFI_QUEUE_MAX] ---

static void reset_hfi_queues(struct adreno_device *adreno_dev)
{
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
	struct hfi_queue_table *tbl = mem_addr->hostptr;
	struct hfi_queue_header *hdr;
	u32 i;

	/* Flush HFI queues */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		hdr = &tbl->qhdr[i];
		if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
			continue;

		hdr->read_index = hdr->write_index;
	}
}

/* Fill the entry and return the dword count written */
static u32 _fill_table_entry(struct hfi_table_entry *entry, u32 count,
		u32 stride_bytes, u32 *data)
{
	entry->count = count;
	entry->stride = stride_bytes >> 2; /* entry->stride is in dwords */
	memcpy(entry->data, data, stride_bytes * count);

	/* Return total dword count of entry + data */
	return (sizeof(*entry) >> 2) + (entry->count * entry->stride);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:42 [MATCH: qhdr] ---
	return &gmu->hfi;
}

/* Size in below functions are in unit of dwords */
int gen8_hfi_queue_read(struct gen8_gmu_device *gmu, u32 queue_idx,
		u32 *output, u32 max_size)
{
	struct kgsl_device *device = KGSL_DEVICE(gen8_gmu_to_adreno(gmu));
	struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
	struct hfi_queue_table *tbl = mem_addr->hostptr;
	struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];
	u32 *queue;
	u32 msg_hdr;
	u32 i, read;
	u32 size;
	int result = 0;

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
		return -EINVAL;

	if (hdr->read_index == hdr->write_index)
		return -ENODATA;

	/* Clear the output data before populating */
	memset(output, 0, max_size);

	queue = HOST_QUEUE_START_ADDR(mem_addr, queue_idx);
	msg_hdr = queue[hdr->read_index];
	size = MSG_HDR_GET_SIZE(msg_hdr);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:108 [MATCH: qhdr] ---

done:
	return result;
}

int gen8_hfi_queue_write(struct adreno_device *adreno_dev, u32 queue_idx,
		u32 *msg, u32 size_bytes)
{
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct hfi_queue_table *tbl = gmu->hfi.hfi_mem->hostptr;
	struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];
	u32 *queue;
	u32 i, write_idx, read_idx, empty_space;
	u32 size_dwords = size_bytes >> 2;
	u32 align_size = ALIGN(size_dwords, SZ_4);
	u32 id = MSG_HDR_GET_ID(*msg);

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED || !IS_ALIGNED(size_bytes, sizeof(u32)))
		return -EINVAL;

	queue = HOST_QUEUE_START_ADDR(gmu->hfi.hfi_mem, queue_idx);

	write_idx = hdr->write_index;
	read_idx = hdr->read_index;

	empty_space = (write_idx >= read_idx) ?
			(hdr->queue_size - (write_idx - read_idx))
			: (read_idx - write_idx);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:205 [MATCH: qhdr] ---
	} queue[HFI_QUEUE_MAX] = {
		{ HFI_CMD_ID, HFI_CMD_PRI, HFI_QUEUE_STATUS_ENABLED },
		{ HFI_MSG_ID, HFI_MSG_PRI, HFI_QUEUE_STATUS_ENABLED },
		{ HFI_DBG_ID, HFI_DBG_PRI, HFI_QUEUE_STATUS_ENABLED },
	};

	/* Fill Table Header */
	tbl = mem_addr->hostptr;
	tbl->qtbl_hdr.version = 0;
	tbl->qtbl_hdr.size = sizeof(struct hfi_queue_table) >> 2;
	tbl->qtbl_hdr.qhdr0_offset = sizeof(struct hfi_queue_table_header) >> 2;
	tbl->qtbl_hdr.qhdr_size = sizeof(struct hfi_queue_header) >> 2;
	tbl->qtbl_hdr.num_q = HFI_QUEUE_MAX;
	tbl->qtbl_hdr.num_active_q = HFI_QUEUE_MAX;

	memset(&tbl->qhdr[0], 0, sizeof(tbl->qhdr));

	/* Fill Individual Queue Headers */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		hdr = &tbl->qhdr[i];
		hdr->start_addr = GMU_QUEUE_START_ADDR(mem_addr->gmuaddr, i);
		hdr->type = QUEUE_HDR_TYPE(queue[i].idx, queue[i].pri, 0, 0);
		hdr->status = queue[i].status;
		hdr->queue_size = HFI_QUEUE_SIZE >> 2; /* convert to dwords */
	}
}

int gen8_hfi_init(struct adreno_device *adreno_dev)
{

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:206 [MATCH: qhdr] ---
		{ HFI_CMD_ID, HFI_CMD_PRI, HFI_QUEUE_STATUS_ENABLED },
		{ HFI_MSG_ID, HFI_MSG_PRI, HFI_QUEUE_STATUS_ENABLED },
		{ HFI_DBG_ID, HFI_DBG_PRI, HFI_QUEUE_STATUS_ENABLED },
	};

	/* Fill Table Header */
	tbl = mem_addr->hostptr;
	tbl->qtbl_hdr.version = 0;
	tbl->qtbl_hdr.size = sizeof(struct hfi_queue_table) >> 2;
	tbl->qtbl_hdr.qhdr0_offset = sizeof(struct hfi_queue_table_header) >> 2;
	tbl->qtbl_hdr.qhdr_size = sizeof(struct hfi_queue_header) >> 2;
	tbl->qtbl_hdr.num_q = HFI_QUEUE_MAX;
	tbl->qtbl_hdr.num_active_q = HFI_QUEUE_MAX;

	memset(&tbl->qhdr[0], 0, sizeof(tbl->qhdr));

	/* Fill Individual Queue Headers */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		hdr = &tbl->qhdr[i];
		hdr->start_addr = GMU_QUEUE_START_ADDR(mem_addr->gmuaddr, i);
		hdr->type = QUEUE_HDR_TYPE(queue[i].idx, queue[i].pri, 0, 0);
		hdr->status = queue[i].status;
		hdr->queue_size = HFI_QUEUE_SIZE >> 2; /* convert to dwords */
	}
}

int gen8_hfi_init(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:210 [MATCH: qhdr] ---

	/* Fill Table Header */
	tbl = mem_addr->hostptr;
	tbl->qtbl_hdr.version = 0;
	tbl->qtbl_hdr.size = sizeof(struct hfi_queue_table) >> 2;
	tbl->qtbl_hdr.qhdr0_offset = sizeof(struct hfi_queue_table_header) >> 2;
	tbl->qtbl_hdr.qhdr_size = sizeof(struct hfi_queue_header) >> 2;
	tbl->qtbl_hdr.num_q = HFI_QUEUE_MAX;
	tbl->qtbl_hdr.num_active_q = HFI_QUEUE_MAX;

	memset(&tbl->qhdr[0], 0, sizeof(tbl->qhdr));

	/* Fill Individual Queue Headers */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		hdr = &tbl->qhdr[i];
		hdr->start_addr = GMU_QUEUE_START_ADDR(mem_addr->gmuaddr, i);
		hdr->type = QUEUE_HDR_TYPE(queue[i].idx, queue[i].pri, 0, 0);
		hdr->status = queue[i].status;
		hdr->queue_size = HFI_QUEUE_SIZE >> 2; /* convert to dwords */
	}
}

int gen8_hfi_init(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct gen8_hfi *hfi = &gmu->hfi;

	/* Allocates & maps memory for HFI */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:214 [MATCH: qhdr] ---
	tbl->qtbl_hdr.size = sizeof(struct hfi_queue_table) >> 2;
	tbl->qtbl_hdr.qhdr0_offset = sizeof(struct hfi_queue_table_header) >> 2;
	tbl->qtbl_hdr.qhdr_size = sizeof(struct hfi_queue_header) >> 2;
	tbl->qtbl_hdr.num_q = HFI_QUEUE_MAX;
	tbl->qtbl_hdr.num_active_q = HFI_QUEUE_MAX;

	memset(&tbl->qhdr[0], 0, sizeof(tbl->qhdr));

	/* Fill Individual Queue Headers */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		hdr = &tbl->qhdr[i];
		hdr->start_addr = GMU_QUEUE_START_ADDR(mem_addr->gmuaddr, i);
		hdr->type = QUEUE_HDR_TYPE(queue[i].idx, queue[i].pri, 0, 0);
		hdr->status = queue[i].status;
		hdr->queue_size = HFI_QUEUE_SIZE >> 2; /* convert to dwords */
	}
}

int gen8_hfi_init(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct gen8_hfi *hfi = &gmu->hfi;

	/* Allocates & maps memory for HFI */
	if (IS_ERR_OR_NULL(hfi->hfi_mem)) {
		hfi->hfi_mem = gmu_core_reserve_kernel_block(device, 0,
				HFIMEM_SIZE, GMU_NONCACHED_KERNEL, 0);
		if (!IS_ERR(hfi->hfi_mem))

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:730 [MATCH: qhdr] ---
static void reset_hfi_queues(struct adreno_device *adreno_dev)
{
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
	struct hfi_queue_table *tbl = mem_addr->hostptr;
	struct hfi_queue_header *hdr;
	u32 i;

	/* Flush HFI queues */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		hdr = &tbl->qhdr[i];
		if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
			continue;

		hdr->read_index = hdr->write_index;
	}
}

/* Fill the entry and return the dword count written */
static u32 _fill_table_entry(struct hfi_table_entry *entry, u32 count,
		u32 stride_bytes, u32 *data)
{
	entry->count = count;
	entry->stride = stride_bytes >> 2; /* entry->stride is in dwords */
	memcpy(entry->data, data, stride_bytes * count);

	/* Return total dword count of entry + data */
	return (sizeof(*entry) >> 2) + (entry->count * entry->stride);
}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:52 [MATCH: read_index] ---
	struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];
	u32 *queue;
	u32 msg_hdr;
	u32 i, read;
	u32 size;
	int result = 0;

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
		return -EINVAL;

	if (hdr->read_index == hdr->write_index)
		return -ENODATA;

	/* Clear the output data before populating */
	memset(output, 0, max_size);

	queue = HOST_QUEUE_START_ADDR(mem_addr, queue_idx);
	msg_hdr = queue[hdr->read_index];
	size = MSG_HDR_GET_SIZE(msg_hdr);

	if (size > (max_size >> 2)) {
		dev_err(GMU_PDEV_DEV(device),
		"HFI message too big: hdr:0x%x rd idx=%d\n",
			msg_hdr, hdr->read_index);
		result = -EMSGSIZE;
		goto done;
	}

	read = hdr->read_index;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:59 [MATCH: read_index] ---
	if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
		return -EINVAL;

	if (hdr->read_index == hdr->write_index)
		return -ENODATA;

	/* Clear the output data before populating */
	memset(output, 0, max_size);

	queue = HOST_QUEUE_START_ADDR(mem_addr, queue_idx);
	msg_hdr = queue[hdr->read_index];
	size = MSG_HDR_GET_SIZE(msg_hdr);

	if (size > (max_size >> 2)) {
		dev_err(GMU_PDEV_DEV(device),
		"HFI message too big: hdr:0x%x rd idx=%d\n",
			msg_hdr, hdr->read_index);
		result = -EMSGSIZE;
		goto done;
	}

	read = hdr->read_index;

	if (read < hdr->queue_size) {
		for (i = 0; i < size && i < (max_size >> 2); i++) {
			output[i] = queue[read];
			read = (read + 1)%hdr->queue_size;
		}
		result = size;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:65 [MATCH: read_index] ---
	/* Clear the output data before populating */
	memset(output, 0, max_size);

	queue = HOST_QUEUE_START_ADDR(mem_addr, queue_idx);
	msg_hdr = queue[hdr->read_index];
	size = MSG_HDR_GET_SIZE(msg_hdr);

	if (size > (max_size >> 2)) {
		dev_err(GMU_PDEV_DEV(device),
		"HFI message too big: hdr:0x%x rd idx=%d\n",
			msg_hdr, hdr->read_index);
		result = -EMSGSIZE;
		goto done;
	}

	read = hdr->read_index;

	if (read < hdr->queue_size) {
		for (i = 0; i < size && i < (max_size >> 2); i++) {
			output[i] = queue[read];
			read = (read + 1)%hdr->queue_size;
		}
		result = size;
	} else {
		/* In case FW messed up */
		dev_err(GMU_PDEV_DEV(device),
			"Read index %d greater than queue size %d\n",
			hdr->read_index, hdr->queue_size);
		result = -ENODATA;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:70 [MATCH: read_index] ---
	size = MSG_HDR_GET_SIZE(msg_hdr);

	if (size > (max_size >> 2)) {
		dev_err(GMU_PDEV_DEV(device),
		"HFI message too big: hdr:0x%x rd idx=%d\n",
			msg_hdr, hdr->read_index);
		result = -EMSGSIZE;
		goto done;
	}

	read = hdr->read_index;

	if (read < hdr->queue_size) {
		for (i = 0; i < size && i < (max_size >> 2); i++) {
			output[i] = queue[read];
			read = (read + 1)%hdr->queue_size;
		}
		result = size;
	} else {
		/* In case FW messed up */
		dev_err(GMU_PDEV_DEV(device),
			"Read index %d greater than queue size %d\n",
			hdr->read_index, hdr->queue_size);
		result = -ENODATA;
	}

	read = ALIGN(read, SZ_4) % hdr->queue_size;

	hfi_update_read_idx(hdr, read);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:82 [MATCH: read_index] ---
	if (read < hdr->queue_size) {
		for (i = 0; i < size && i < (max_size >> 2); i++) {
			output[i] = queue[read];
			read = (read + 1)%hdr->queue_size;
		}
		result = size;
	} else {
		/* In case FW messed up */
		dev_err(GMU_PDEV_DEV(device),
			"Read index %d greater than queue size %d\n",
			hdr->read_index, hdr->queue_size);
		result = -ENODATA;
	}

	read = ALIGN(read, SZ_4) % hdr->queue_size;

	hfi_update_read_idx(hdr, read);

	/* For acks, trace the packet for which this ack was sent */
	if (MSG_HDR_GET_TYPE(msg_hdr) == HFI_MSG_ACK)
		trace_kgsl_hfi_receive(MSG_HDR_GET_ID(output[1]),
			MSG_HDR_GET_SIZE(output[1]),
			MSG_HDR_GET_SEQNUM(output[1]));
	else
		trace_kgsl_hfi_receive(MSG_HDR_GET_ID(msg_hdr),
			MSG_HDR_GET_SIZE(msg_hdr), MSG_HDR_GET_SEQNUM(msg_hdr));

done:
	return result;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:121 [MATCH: read_index] ---
	u32 size_dwords = size_bytes >> 2;
	u32 align_size = ALIGN(size_dwords, SZ_4);
	u32 id = MSG_HDR_GET_ID(*msg);

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED || !IS_ALIGNED(size_bytes, sizeof(u32)))
		return -EINVAL;

	queue = HOST_QUEUE_START_ADDR(gmu->hfi.hfi_mem, queue_idx);

	write_idx = hdr->write_index;
	read_idx = hdr->read_index;

	empty_space = (write_idx >= read_idx) ?
			(hdr->queue_size - (write_idx - read_idx))
			: (read_idx - write_idx);

	if (empty_space <= align_size)
		return -ENOSPC;

	for (i = 0; i < size_dwords; i++) {
		queue[write_idx] = msg[i];
		write_idx = (write_idx + 1) % hdr->queue_size;
	}

	/* Cookify any non used data at the end of the write buffer */
	for (; i < align_size; i++) {
		queue[write_idx] = 0xfafafafa;
		write_idx = (write_idx + 1) % hdr->queue_size;
	}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:734 [MATCH: read_index] ---
	struct hfi_queue_table *tbl = mem_addr->hostptr;
	struct hfi_queue_header *hdr;
	u32 i;

	/* Flush HFI queues */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		hdr = &tbl->qhdr[i];
		if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
			continue;

		hdr->read_index = hdr->write_index;
	}
}

/* Fill the entry and return the dword count written */
static u32 _fill_table_entry(struct hfi_table_entry *entry, u32 count,
		u32 stride_bytes, u32 *data)
{
	entry->count = count;
	entry->stride = stride_bytes >> 2; /* entry->stride is in dwords */
	memcpy(entry->data, data, stride_bytes * count);

	/* Return total dword count of entry + data */
	return (sizeof(*entry) >> 2) + (entry->count * entry->stride);
}

int gen8_hfi_send_gpu_perf_table(struct adreno_device *adreno_dev)
{
	/*

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:120 [MATCH: write_index] ---
	u32 i, write_idx, read_idx, empty_space;
	u32 size_dwords = size_bytes >> 2;
	u32 align_size = ALIGN(size_dwords, SZ_4);
	u32 id = MSG_HDR_GET_ID(*msg);

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED || !IS_ALIGNED(size_bytes, sizeof(u32)))
		return -EINVAL;

	queue = HOST_QUEUE_START_ADDR(gmu->hfi.hfi_mem, queue_idx);

	write_idx = hdr->write_index;
	read_idx = hdr->read_index;

	empty_space = (write_idx >= read_idx) ?
			(hdr->queue_size - (write_idx - read_idx))
			: (read_idx - write_idx);

	if (empty_space <= align_size)
		return -ENOSPC;

	for (i = 0; i < size_dwords; i++) {
		queue[write_idx] = msg[i];
		write_idx = (write_idx + 1) % hdr->queue_size;
	}

	/* Cookify any non used data at the end of the write buffer */
	for (; i < align_size; i++) {
		queue[write_idx] = 0xfafafafa;
		write_idx = (write_idx + 1) % hdr->queue_size;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hfi.c:143 [MATCH: write_index] ---
	}

	/* Cookify any non used data at the end of the write buffer */
	for (; i < align_size; i++) {
		queue[write_idx] = 0xfafafafa;
		write_idx = (write_idx + 1) % hdr->queue_size;
	}

	trace_kgsl_hfi_send(id, size_dwords, MSG_HDR_GET_SEQNUM(*msg));

	hfi_update_write_idx(&hdr->write_index, write_idx);

	return 0;
}

int gen8_hfi_cmdq_write(struct adreno_device *adreno_dev, u32 *msg, u32 size_bytes)
{
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct gen8_hfi *hfi = &gmu->hfi;
	int ret;

	spin_lock(&hfi->cmdq_lock);

	if (test_bit(MSG_HDR_GET_ID(msg[0]), hfi->wb_set_record_bitmask))
		*msg = RECORD_MSG_HDR(*msg);

	ret = gen8_hfi_queue_write(adreno_dev, HFI_CMD_ID, msg, size_bytes);

	/*

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:22 [MATCH: HFI_QUEUE_MAX] ---
#include "adreno_hfi.h"
#include "adreno_pm4types.h"
#include "adreno_trace.h"
#include "kgsl_device.h"
#include "kgsl_eventlog.h"
#include "kgsl_gmu_core.h"
#include "kgsl_pwrctrl.h"
#include "kgsl_timeline.h"
#include "kgsl_util.h"

#define HFI_QUEUE_MAX (HFI_QUEUE_DEFAULT_CNT)

#define DEFINE_QHDR(gmuaddr, id, prio) \
	{\
		.status = 1, \
		.start_addr = GMU_QUEUE_START_ADDR(gmuaddr, id), \
		.type = QUEUE_HDR_TYPE(id, prio, 0, 0), \
		.queue_size = SZ_4K >> 2, \
		.msg_size = 0, \
		.unused0 = 0, \
		.unused1 = 0, \
		.unused2 = 0, \
		.unused3 = 0, \
		.unused4 = 0, \
		.read_index = 0, \
		.write_index = 0, \
}

/* The GMU buffer address corresponds to the beginning of

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1303 [MATCH: HFI_QUEUE_MAX] ---
static void init_queues(struct gen8_hfi *hfi)
{
	u32 gmuaddr = hfi->hfi_mem->gmuaddr;
	struct hfi_queue_table hfi_table = {
		.qtbl_hdr = {
			.version = 0,
			.size = sizeof(struct hfi_queue_table) >> 2,
			.qhdr0_offset =
				sizeof(struct hfi_queue_table_header) >> 2,
			.qhdr_size = sizeof(struct hfi_queue_header) >> 2,
			.num_q = HFI_QUEUE_MAX,
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
	(SZ_4K * HFI_QUEUE_MAX))

static int hfi_f2h_main(void *arg);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1304 [MATCH: HFI_QUEUE_MAX] ---
{
	u32 gmuaddr = hfi->hfi_mem->gmuaddr;
	struct hfi_queue_table hfi_table = {
		.qtbl_hdr = {
			.version = 0,
			.size = sizeof(struct hfi_queue_table) >> 2,
			.qhdr0_offset =
				sizeof(struct hfi_queue_table_header) >> 2,
			.qhdr_size = sizeof(struct hfi_queue_header) >> 2,
			.num_q = HFI_QUEUE_MAX,
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
	(SZ_4K * HFI_QUEUE_MAX))

static int hfi_f2h_main(void *arg);

int gen8_hwsched_hfi_init(struct adreno_device *adreno_dev)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1318 [MATCH: HFI_QUEUE_MAX] ---
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
	(SZ_4K * HFI_QUEUE_MAX))

static int hfi_f2h_main(void *arg);

int gen8_hwsched_hfi_init(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gen8_hwsched_hfi *hw_hfi = to_gen8_hwsched_hfi(adreno_dev);
	struct gen8_hfi *hfi = to_gen8_hfi(adreno_dev);

	if (IS_ERR_OR_NULL(hw_hfi->big_ib)) {
		hw_hfi->big_ib = gmu_core_reserve_kernel_block(
				device, 0, HWSCHED_MAX_IBS * sizeof(struct hfi_issue_ib),
				GMU_NONCACHED_KERNEL, 0);
		if (IS_ERR(hw_hfi->big_ib))
			return PTR_ERR(hw_hfi->big_ib);
	}

	if (ADRENO_FEATURE(adreno_dev, ADRENO_LSR) &&

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1530 [MATCH: HFI_QUEUE_MAX] ---
	return rc;
}

static void reset_hfi_queues(struct adreno_device *adreno_dev)
{
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct hfi_queue_table *tbl = gmu->hfi.hfi_mem->hostptr;
	u32 i;

	/* Flush HFI queues */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		struct hfi_queue_header *hdr = &tbl->qhdr[i];

		if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
			continue;

		hdr->read_index = hdr->write_index;
	}
}

void gen8_hwsched_hfi_stop(struct adreno_device *adreno_dev)
{
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev);

	hfi->irq_mask &= ~HFI_IRQ_MSGQ_MASK;

	/*
	 * In some corner cases, it is possible that GMU put TS_RETIRE

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:24 [MATCH: qhdr] ---
#include "adreno_trace.h"
#include "kgsl_device.h"
#include "kgsl_eventlog.h"
#include "kgsl_gmu_core.h"
#include "kgsl_pwrctrl.h"
#include "kgsl_timeline.h"
#include "kgsl_util.h"

#define HFI_QUEUE_MAX (HFI_QUEUE_DEFAULT_CNT)

#define DEFINE_QHDR(gmuaddr, id, prio) \
	{\
		.status = 1, \
		.start_addr = GMU_QUEUE_START_ADDR(gmuaddr, id), \
		.type = QUEUE_HDR_TYPE(id, prio, 0, 0), \
		.queue_size = SZ_4K >> 2, \
		.msg_size = 0, \
		.unused0 = 0, \
		.unused1 = 0, \
		.unused2 = 0, \
		.unused3 = 0, \
		.unused4 = 0, \
		.read_index = 0, \
		.write_index = 0, \
}

/* The GMU buffer address corresponds to the beginning of
 * half the size of the shared buffer.
 */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:553 [MATCH: qhdr] ---

	/* Return true for fatal errors to perform recovery sequence */
	return true;
}

static bool is_queue_empty(struct adreno_device *adreno_dev, u32 queue_idx)
{
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
	struct hfi_queue_table *tbl = mem_addr->hostptr;
	struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
		return true;

	if (hdr->read_index == hdr->write_index)
		return true;

	/*
	 * This is to ensure that the queue is not read speculatively before the queue empty
	 * condition is evaluated
	 */
	rmb();

	return false;
}

static u32 peek_next_header(struct adreno_device *adreno_dev, struct gen8_gmu_device *gmu,
	u32 queue_idx)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:575 [MATCH: qhdr] ---
	rmb();

	return false;
}

static u32 peek_next_header(struct adreno_device *adreno_dev, struct gen8_gmu_device *gmu,
	u32 queue_idx)
{
	struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
	struct hfi_queue_table *tbl = mem_addr->hostptr;
	struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];
	u32 *queue;

	if (is_queue_empty(adreno_dev, queue_idx))
		return 0;

	queue = HOST_QUEUE_START_ADDR(mem_addr, queue_idx);

	return queue[hdr->read_index];
}

static void process_ctx_bad(struct adreno_device *adreno_dev)
{
	/* Non fatal RBBM error interrupts don't go through reset and recovery */
	if (!log_gpu_fault(adreno_dev)) {
		memset(adreno_dev->hwsched.ctxt_bad, 0x0, HFI_MAX_MSG_SIZE);
		return;
	}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1300 [MATCH: qhdr] ---
	return rc;
}

static void init_queues(struct gen8_hfi *hfi)
{
	u32 gmuaddr = hfi->hfi_mem->gmuaddr;
	struct hfi_queue_table hfi_table = {
		.qtbl_hdr = {
			.version = 0,
			.size = sizeof(struct hfi_queue_table) >> 2,
			.qhdr0_offset =
				sizeof(struct hfi_queue_table_header) >> 2,
			.qhdr_size = sizeof(struct hfi_queue_header) >> 2,
			.num_q = HFI_QUEUE_MAX,
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
	(SZ_4K * HFI_QUEUE_MAX))

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1302 [MATCH: qhdr] ---

static void init_queues(struct gen8_hfi *hfi)
{
	u32 gmuaddr = hfi->hfi_mem->gmuaddr;
	struct hfi_queue_table hfi_table = {
		.qtbl_hdr = {
			.version = 0,
			.size = sizeof(struct hfi_queue_table) >> 2,
			.qhdr0_offset =
				sizeof(struct hfi_queue_table_header) >> 2,
			.qhdr_size = sizeof(struct hfi_queue_header) >> 2,
			.num_q = HFI_QUEUE_MAX,
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
	(SZ_4K * HFI_QUEUE_MAX))

static int hfi_f2h_main(void *arg);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1306 [MATCH: qhdr] ---
	struct hfi_queue_table hfi_table = {
		.qtbl_hdr = {
			.version = 0,
			.size = sizeof(struct hfi_queue_table) >> 2,
			.qhdr0_offset =
				sizeof(struct hfi_queue_table_header) >> 2,
			.qhdr_size = sizeof(struct hfi_queue_header) >> 2,
			.num_q = HFI_QUEUE_MAX,
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
	(SZ_4K * HFI_QUEUE_MAX))

static int hfi_f2h_main(void *arg);

int gen8_hwsched_hfi_init(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1307 [MATCH: qhdr] ---
		.qtbl_hdr = {
			.version = 0,
			.size = sizeof(struct hfi_queue_table) >> 2,
			.qhdr0_offset =
				sizeof(struct hfi_queue_table_header) >> 2,
			.qhdr_size = sizeof(struct hfi_queue_header) >> 2,
			.num_q = HFI_QUEUE_MAX,
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
	(SZ_4K * HFI_QUEUE_MAX))

static int hfi_f2h_main(void *arg);

int gen8_hwsched_hfi_init(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gen8_hwsched_hfi *hw_hfi = to_gen8_hwsched_hfi(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1308 [MATCH: qhdr] ---
			.version = 0,
			.size = sizeof(struct hfi_queue_table) >> 2,
			.qhdr0_offset =
				sizeof(struct hfi_queue_table_header) >> 2,
			.qhdr_size = sizeof(struct hfi_queue_header) >> 2,
			.num_q = HFI_QUEUE_MAX,
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
	(SZ_4K * HFI_QUEUE_MAX))

static int hfi_f2h_main(void *arg);

int gen8_hwsched_hfi_init(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gen8_hwsched_hfi *hw_hfi = to_gen8_hwsched_hfi(adreno_dev);
	struct gen8_hfi *hfi = to_gen8_hfi(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1309 [MATCH: qhdr] ---
			.size = sizeof(struct hfi_queue_table) >> 2,
			.qhdr0_offset =
				sizeof(struct hfi_queue_table_header) >> 2,
			.qhdr_size = sizeof(struct hfi_queue_header) >> 2,
			.num_q = HFI_QUEUE_MAX,
			.num_active_q = HFI_QUEUE_MAX,
		},
		.qhdr = {
			DEFINE_QHDR(gmuaddr, HFI_CMD_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_MSG_ID, 0),
			DEFINE_QHDR(gmuaddr, HFI_DBG_ID, 0),
		},
	};

	memcpy(hfi->hfi_mem->hostptr, &hfi_table, sizeof(hfi_table));
}

/* Total header sizes + queue sizes + 16 for alignment */
#define HFIMEM_SIZE (sizeof(struct hfi_queue_table) + 16 + \
	(SZ_4K * HFI_QUEUE_MAX))

static int hfi_f2h_main(void *arg);

int gen8_hwsched_hfi_init(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct gen8_hwsched_hfi *hw_hfi = to_gen8_hwsched_hfi(adreno_dev);
	struct gen8_hfi *hfi = to_gen8_hfi(adreno_dev);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1531 [MATCH: qhdr] ---
}

static void reset_hfi_queues(struct adreno_device *adreno_dev)
{
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct hfi_queue_table *tbl = gmu->hfi.hfi_mem->hostptr;
	u32 i;

	/* Flush HFI queues */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		struct hfi_queue_header *hdr = &tbl->qhdr[i];

		if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
			continue;

		hdr->read_index = hdr->write_index;
	}
}

void gen8_hwsched_hfi_stop(struct adreno_device *adreno_dev)
{
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev);

	hfi->irq_mask &= ~HFI_IRQ_MSGQ_MASK;

	/*
	 * In some corner cases, it is possible that GMU put TS_RETIRE
	 * on the msgq after we have turned off gmu interrupts. Hence,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:36 [MATCH: read_index] ---
		.status = 1, \
		.start_addr = GMU_QUEUE_START_ADDR(gmuaddr, id), \
		.type = QUEUE_HDR_TYPE(id, prio, 0, 0), \
		.queue_size = SZ_4K >> 2, \
		.msg_size = 0, \
		.unused0 = 0, \
		.unused1 = 0, \
		.unused2 = 0, \
		.unused3 = 0, \
		.unused4 = 0, \
		.read_index = 0, \
		.write_index = 0, \
}

/* The GMU buffer address corresponds to the beginning of
 * half the size of the shared buffer.
 */
#define GMU_BUF_ADDR(md) ((md.gmuaddr) + (md.size >> 1))

struct pending_cmd gen8_hw_fence_ack;

struct gen8_hwsched_hfi *to_gen8_hwsched_hfi(
	struct adreno_device *adreno_dev)
{
	struct gen8_device *gen8_dev = container_of(adreno_dev,
					struct gen8_device, adreno_dev);
	struct gen8_hwsched_device *gen8_hwsched = container_of(gen8_dev,
					struct gen8_hwsched_device, gen8_dev);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:205 [MATCH: read_index] ---
	read_unlock(&device->context_lock);

	if (!ret)
		return;

	drawctxt = ADRENO_CONTEXT(context);

	hdr = drawctxt->gmu_context_queue.hostptr;
	queue = (u32 *)(drawctxt->gmu_context_queue.hostptr + sizeof(*hdr));

	for (i = hdr->read_index; i != hdr->write_index;) {
		if (MSG_HDR_GET_ID(queue[i]) != H2F_MSG_ISSUE_SYNCOBJ) {
			i = (i + MSG_HDR_GET_SIZE(queue[i])) % hdr->queue_size;
			continue;
		}

		if (adreno_gmu_context_queue_read(drawctxt, (u32 *) &cmd, i, sizeof(cmd) >> 2))
			break;

		if (cmd.timestamp == ts) {
			log_syncobj(gmu, drawctxt, &cmd,
				(i + (sizeof(cmd) >> 2)) % hdr->queue_size);
			break;
		}
		i = (i + MSG_HDR_GET_SIZE(queue[i])) % hdr->queue_size;
	}

	if (i == hdr->write_index)
		dev_err(GMU_PDEV_DEV(device), "Couldn't find unsignaled syncobj ctx:%d ts:%d\n",

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:558 [MATCH: read_index] ---
static bool is_queue_empty(struct adreno_device *adreno_dev, u32 queue_idx)
{
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
	struct hfi_queue_table *tbl = mem_addr->hostptr;
	struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];

	if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
		return true;

	if (hdr->read_index == hdr->write_index)
		return true;

	/*
	 * This is to ensure that the queue is not read speculatively before the queue empty
	 * condition is evaluated
	 */
	rmb();

	return false;
}

static u32 peek_next_header(struct adreno_device *adreno_dev, struct gen8_gmu_device *gmu,
	u32 queue_idx)
{
	struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
	struct hfi_queue_table *tbl = mem_addr->hostptr;
	struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];
	u32 *queue;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:583 [MATCH: read_index] ---
	struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
	struct hfi_queue_table *tbl = mem_addr->hostptr;
	struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];
	u32 *queue;

	if (is_queue_empty(adreno_dev, queue_idx))
		return 0;

	queue = HOST_QUEUE_START_ADDR(mem_addr, queue_idx);

	return queue[hdr->read_index];
}

static void process_ctx_bad(struct adreno_device *adreno_dev)
{
	/* Non fatal RBBM error interrupts don't go through reset and recovery */
	if (!log_gpu_fault(adreno_dev)) {
		memset(adreno_dev->hwsched.ctxt_bad, 0x0, HFI_MAX_MSG_SIZE);
		return;
	}

	adreno_dev->hwsched.reset_type = gen8_hwsched_lookup_key_value(adreno_dev,
				PAYLOAD_FAULT_RESET_POLICY, KEY_GPU_RESET_POLICY);

	gen8_hwsched_fault(adreno_dev, ADRENO_HARD_FAULT);
}

#define GET_QUERIED_FENCE_INDEX(x) (x / BITS_PER_SYNCOBJ_QUERY)
#define GET_QUERIED_FENCE_BIT(x) (x % BITS_PER_SYNCOBJ_QUERY)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1536 [MATCH: read_index] ---
	struct hfi_queue_table *tbl = gmu->hfi.hfi_mem->hostptr;
	u32 i;

	/* Flush HFI queues */
	for (i = 0; i < HFI_QUEUE_MAX; i++) {
		struct hfi_queue_header *hdr = &tbl->qhdr[i];

		if (hdr->status == HFI_QUEUE_STATUS_DISABLED)
			continue;

		hdr->read_index = hdr->write_index;
	}
}

void gen8_hwsched_hfi_stop(struct adreno_device *adreno_dev)
{
	struct gen8_gmu_device *gmu = to_gen8_gmu(adreno_dev);
	struct gen8_hwsched_hfi *hfi = to_gen8_hwsched_hfi(adreno_dev);

	hfi->irq_mask &= ~HFI_IRQ_MSGQ_MASK;

	/*
	 * In some corner cases, it is possible that GMU put TS_RETIRE
	 * on the msgq after we have turned off gmu interrupts. Hence,
	 * drain the queue one last time before we reset HFI queues.
	 */
	gen8_hwsched_process_msgq(adreno_dev);

	/* Drain the debug queue before we reset HFI queues */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:37 [MATCH: write_index] ---
		.start_addr = GMU_QUEUE_START_ADDR(gmuaddr, id), \
		.type = QUEUE_HDR_TYPE(id, prio, 0, 0), \
		.queue_size = SZ_4K >> 2, \
		.msg_size = 0, \
		.unused0 = 0, \
		.unused1 = 0, \
		.unused2 = 0, \
		.unused3 = 0, \
		.unused4 = 0, \
		.read_index = 0, \
		.write_index = 0, \
}

/* The GMU buffer address corresponds to the beginning of
 * half the size of the shared buffer.
 */
#define GMU_BUF_ADDR(md) ((md.gmuaddr) + (md.size >> 1))

struct pending_cmd gen8_hw_fence_ack;

struct gen8_hwsched_hfi *to_gen8_hwsched_hfi(
	struct adreno_device *adreno_dev)
{
	struct gen8_device *gen8_dev = container_of(adreno_dev,
					struct gen8_device, adreno_dev);
	struct gen8_hwsched_device *gen8_hwsched = container_of(gen8_dev,
					struct gen8_hwsched_device, gen8_dev);

	return &gen8_hwsched->hwsched_hfi;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:222 [MATCH: write_index] ---
			break;

		if (cmd.timestamp == ts) {
			log_syncobj(gmu, drawctxt, &cmd,
				(i + (sizeof(cmd) >> 2)) % hdr->queue_size);
			break;
		}
		i = (i + MSG_HDR_GET_SIZE(queue[i])) % hdr->queue_size;
	}

	if (i == hdr->write_index)
		dev_err(GMU_PDEV_DEV(device), "Couldn't find unsignaled syncobj ctx:%d ts:%d\n",
			ctxt_id, ts);

	kgsl_context_put(context);
}

/* Look up a particular key's value for a given type of payload */
static u32 gen8_hwsched_lookup_key_value(struct adreno_device *adreno_dev,
	u32 type, u32 key)
{
	struct hfi_context_bad_cmd *cmd = adreno_dev->hwsched.ctxt_bad;
	u32 i = 0, payload_bytes;
	void *start;

	if (!cmd->hdr)
		return 0;

	payload_bytes = (MSG_HDR_GET_SIZE(cmd->hdr) << 2) -

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_hwsched_hfi.c:1458 [MATCH: write_index] ---
	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);

	pending_ack.sent_hdr = cmd.hdr;

	rc = gen8_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
	if (rc)
		return rc;

poll:
	rc = adreno_hwsched_poll_msg_queue_write_index(gmu->hfi.hfi_mem);

	if (rc) {
		dev_err(gmu_pdev_dev,
			"Timed out processing MSG_START seqnum: %d\n",
			seqnum);
		gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START);
		goto done;
	}

	rc = gen8_hfi_queue_read(gmu, HFI_MSG_ID, rcvd, sizeof(rcvd));
	if (rc <= 0) {
		dev_err(gmu_pdev_dev,
			"MSG_START: payload error: %d\n",
			rc);
		gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START);
		goto done;
	}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_gen8_snapshot.c:741 [MATCH: read_index] ---
		count = write_ptr;
		header->size = count << 2;
		start_idx = 0;
	} else {
		/* Read entire 2k buffer starting from write ptr */
		start_idx = write_ptr + 1;
		count = SZ_512;
		header->size = SZ_2K;
	}

	kgsl_regmap_read_indexed_interleaved(&device->regmap,
		GEN8_DBGC_DBG_TRACE_BUFFER_RD_ADDR, GEN8_DBGC_DBG_TRACE_BUFFER_RD_DATA, data,
			start_idx, count);

	return (sizeof(*header) + header->size);
}

static size_t gen8_snapshot_trace_buffer_etb(struct kgsl_device *device,
		u8 *buf, size_t remain, void *priv)
{
	u32 read_ptr, count, write_ptr, val, idx = 0;
	struct kgsl_snapshot_trace_buffer *header = (struct kgsl_snapshot_trace_buffer *) buf;
	u32 *data = (u32 *)(buf + sizeof(*header));
	struct gen8_trace_buffer_info *info = (struct gen8_trace_buffer_info *) priv;

	/* Unlock ETB buffer */
	qdss_regwrite(tmc_virt, QDSS_AOSS_APB_TMC_LAR, 0xC5ACCE55);

	/* Make sure unlock goes through before proceeding further */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:452 [MATCH: HFI_QUEUE_DEFAULT_CNT] ---
#define HFI_V1_MSG_ACK 2/* V1 only */

#define MSG_HDR_SET_SIZE(hdr, size) \
	(((size & 0xFF) << 8) | hdr)

#define CREATE_MSG_HDR(id, type) \
	(((type) << 16) | ((id) & 0xFF))

#define ACK_MSG_HDR(id) CREATE_MSG_HDR(id, HFI_MSG_ACK)

#define HFI_QUEUE_DEFAULT_CNT 3
#define HFI_QUEUE_DISPATCH_MAX_CNT 14
#define HFI_QUEUE_HDR_MAX (HFI_QUEUE_DEFAULT_CNT + HFI_QUEUE_DISPATCH_MAX_CNT)

struct hfi_queue_table {
	struct hfi_queue_table_header qtbl_hdr;
	struct hfi_queue_header qhdr[HFI_QUEUE_HDR_MAX];
} __packed;

#define HFI_QUEUE_OFFSET(i) \
		(ALIGN(sizeof(struct hfi_queue_table), SZ_16) + \
		((i) * HFI_QUEUE_SIZE))

#define GMU_QUEUE_START_ADDR(gmuaddr, i) \
	(gmuaddr + HFI_QUEUE_OFFSET(i))

#define HOST_QUEUE_START_ADDR(hfi_mem, i) \
	((hfi_mem)->hostptr + HFI_QUEUE_OFFSET(i))


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:454 [MATCH: HFI_QUEUE_DEFAULT_CNT] ---
#define MSG_HDR_SET_SIZE(hdr, size) \
	(((size & 0xFF) << 8) | hdr)

#define CREATE_MSG_HDR(id, type) \
	(((type) << 16) | ((id) & 0xFF))

#define ACK_MSG_HDR(id) CREATE_MSG_HDR(id, HFI_MSG_ACK)

#define HFI_QUEUE_DEFAULT_CNT 3
#define HFI_QUEUE_DISPATCH_MAX_CNT 14
#define HFI_QUEUE_HDR_MAX (HFI_QUEUE_DEFAULT_CNT + HFI_QUEUE_DISPATCH_MAX_CNT)

struct hfi_queue_table {
	struct hfi_queue_table_header qtbl_hdr;
	struct hfi_queue_header qhdr[HFI_QUEUE_HDR_MAX];
} __packed;

#define HFI_QUEUE_OFFSET(i) \
		(ALIGN(sizeof(struct hfi_queue_table), SZ_16) + \
		((i) * HFI_QUEUE_SIZE))

#define GMU_QUEUE_START_ADDR(gmuaddr, i) \
	(gmuaddr + HFI_QUEUE_OFFSET(i))

#define HOST_QUEUE_START_ADDR(hfi_mem, i) \
	((hfi_mem)->hostptr + HFI_QUEUE_OFFSET(i))

#define MSG_HDR_GET_ID(hdr) ((hdr) & 0xFF)
#define MSG_HDR_GET_SIZE(hdr) (((hdr) >> 8) & 0xFF)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:458 [MATCH: HFI_QUEUE_HDR_MAX] ---
	(((type) << 16) | ((id) & 0xFF))

#define ACK_MSG_HDR(id) CREATE_MSG_HDR(id, HFI_MSG_ACK)

#define HFI_QUEUE_DEFAULT_CNT 3
#define HFI_QUEUE_DISPATCH_MAX_CNT 14
#define HFI_QUEUE_HDR_MAX (HFI_QUEUE_DEFAULT_CNT + HFI_QUEUE_DISPATCH_MAX_CNT)

struct hfi_queue_table {
	struct hfi_queue_table_header qtbl_hdr;
	struct hfi_queue_header qhdr[HFI_QUEUE_HDR_MAX];
} __packed;

#define HFI_QUEUE_OFFSET(i) \
		(ALIGN(sizeof(struct hfi_queue_table), SZ_16) + \
		((i) * HFI_QUEUE_SIZE))

#define GMU_QUEUE_START_ADDR(gmuaddr, i) \
	(gmuaddr + HFI_QUEUE_OFFSET(i))

#define HOST_QUEUE_START_ADDR(hfi_mem, i) \
	((hfi_mem)->hostptr + HFI_QUEUE_OFFSET(i))

#define MSG_HDR_GET_ID(hdr) ((hdr) & 0xFF)
#define MSG_HDR_GET_SIZE(hdr) (((hdr) >> 8) & 0xFF)
#define MSG_HDR_GET_TYPE(hdr) (((hdr) >> 16) & 0xF)
#define MSG_HDR_GET_SEQNUM(hdr) (((hdr) >> 20) & 0xFFF)

/* Clear the HFI_MSG_RECORD bit from both headers since some acks may have it set, and some not. */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:22 [MATCH: HFI_CMD_IDX] ---
#define HFI_QUEUE_SIZE			SZ_4K /* bytes, must be base 4dw */
#define MAX_RCVD_PAYLOAD_SIZE		32 /* dwords */
#define MAX_RCVD_SIZE			(MAX_RCVD_PAYLOAD_SIZE + 3) /* dwords */
#define HFI_MAX_MSG_SIZE		(SZ_1K)

#define HFI_CMD_ID 0
#define HFI_MSG_ID 1
#define HFI_DBG_ID 2
#define HFI_DSP_ID_0 3

#define HFI_CMD_IDX 0
#define HFI_MSG_IDX 1
#define HFI_DBG_IDX 2
#define HFI_DSP_IDX_BASE 3
#define HFI_DSP_IDX_0 3

#define HFI_CMD_IDX_LEGACY 0
#define HFI_DSP_IDX_0_LEGACY 1
#define HFI_MSG_IDX_LEGACY 4
#define HFI_DBG_IDX_LEGACY 5

#define HFI_QUEUE_STATUS_DISABLED 0
#define HFI_QUEUE_STATUS_ENABLED 1

/* HTOF queue priority, 1 is highest priority */
#define HFI_CMD_PRI 10
#define HFI_MSG_PRI 10
#define HFI_DBG_PRI 40
#define HFI_DSP_PRI_0 20

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:28 [MATCH: HFI_CMD_IDX] ---
#define HFI_MSG_ID 1
#define HFI_DBG_ID 2
#define HFI_DSP_ID_0 3

#define HFI_CMD_IDX 0
#define HFI_MSG_IDX 1
#define HFI_DBG_IDX 2
#define HFI_DSP_IDX_BASE 3
#define HFI_DSP_IDX_0 3

#define HFI_CMD_IDX_LEGACY 0
#define HFI_DSP_IDX_0_LEGACY 1
#define HFI_MSG_IDX_LEGACY 4
#define HFI_DBG_IDX_LEGACY 5

#define HFI_QUEUE_STATUS_DISABLED 0
#define HFI_QUEUE_STATUS_ENABLED 1

/* HTOF queue priority, 1 is highest priority */
#define HFI_CMD_PRI 10
#define HFI_MSG_PRI 10
#define HFI_DBG_PRI 40
#define HFI_DSP_PRI_0 20

#define HFI_IRQ_SIDEMSGQ_MASK		BIT(1)
#define HFI_IRQ_DBGQ_MASK		BIT(2)
#define HFI_IRQ_CM3_FAULT_MASK		BIT(15)
#define HFI_IRQ_OOB_MASK		GENMASK(31, 16)
#define HFI_IRQ_MASK			(HFI_IRQ_SIDEMSGQ_MASK |\

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:23 [MATCH: HFI_MSG_IDX] ---
#define MAX_RCVD_PAYLOAD_SIZE		32 /* dwords */
#define MAX_RCVD_SIZE			(MAX_RCVD_PAYLOAD_SIZE + 3) /* dwords */
#define HFI_MAX_MSG_SIZE		(SZ_1K)

#define HFI_CMD_ID 0
#define HFI_MSG_ID 1
#define HFI_DBG_ID 2
#define HFI_DSP_ID_0 3

#define HFI_CMD_IDX 0
#define HFI_MSG_IDX 1
#define HFI_DBG_IDX 2
#define HFI_DSP_IDX_BASE 3
#define HFI_DSP_IDX_0 3

#define HFI_CMD_IDX_LEGACY 0
#define HFI_DSP_IDX_0_LEGACY 1
#define HFI_MSG_IDX_LEGACY 4
#define HFI_DBG_IDX_LEGACY 5

#define HFI_QUEUE_STATUS_DISABLED 0
#define HFI_QUEUE_STATUS_ENABLED 1

/* HTOF queue priority, 1 is highest priority */
#define HFI_CMD_PRI 10
#define HFI_MSG_PRI 10
#define HFI_DBG_PRI 40
#define HFI_DSP_PRI_0 20


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:30 [MATCH: HFI_MSG_IDX] ---
#define HFI_DSP_ID_0 3

#define HFI_CMD_IDX 0
#define HFI_MSG_IDX 1
#define HFI_DBG_IDX 2
#define HFI_DSP_IDX_BASE 3
#define HFI_DSP_IDX_0 3

#define HFI_CMD_IDX_LEGACY 0
#define HFI_DSP_IDX_0_LEGACY 1
#define HFI_MSG_IDX_LEGACY 4
#define HFI_DBG_IDX_LEGACY 5

#define HFI_QUEUE_STATUS_DISABLED 0
#define HFI_QUEUE_STATUS_ENABLED 1

/* HTOF queue priority, 1 is highest priority */
#define HFI_CMD_PRI 10
#define HFI_MSG_PRI 10
#define HFI_DBG_PRI 40
#define HFI_DSP_PRI_0 20

#define HFI_IRQ_SIDEMSGQ_MASK		BIT(1)
#define HFI_IRQ_DBGQ_MASK		BIT(2)
#define HFI_IRQ_CM3_FAULT_MASK		BIT(15)
#define HFI_IRQ_OOB_MASK		GENMASK(31, 16)
#define HFI_IRQ_MASK			(HFI_IRQ_SIDEMSGQ_MASK |\
					HFI_IRQ_DBGQ_MASK |\
					HFI_IRQ_CM3_FAULT_MASK)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:24 [MATCH: HFI_DBG_IDX] ---
#define MAX_RCVD_SIZE			(MAX_RCVD_PAYLOAD_SIZE + 3) /* dwords */
#define HFI_MAX_MSG_SIZE		(SZ_1K)

#define HFI_CMD_ID 0
#define HFI_MSG_ID 1
#define HFI_DBG_ID 2
#define HFI_DSP_ID_0 3

#define HFI_CMD_IDX 0
#define HFI_MSG_IDX 1
#define HFI_DBG_IDX 2
#define HFI_DSP_IDX_BASE 3
#define HFI_DSP_IDX_0 3

#define HFI_CMD_IDX_LEGACY 0
#define HFI_DSP_IDX_0_LEGACY 1
#define HFI_MSG_IDX_LEGACY 4
#define HFI_DBG_IDX_LEGACY 5

#define HFI_QUEUE_STATUS_DISABLED 0
#define HFI_QUEUE_STATUS_ENABLED 1

/* HTOF queue priority, 1 is highest priority */
#define HFI_CMD_PRI 10
#define HFI_MSG_PRI 10
#define HFI_DBG_PRI 40
#define HFI_DSP_PRI_0 20

#define HFI_IRQ_SIDEMSGQ_MASK		BIT(1)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:31 [MATCH: HFI_DBG_IDX] ---

#define HFI_CMD_IDX 0
#define HFI_MSG_IDX 1
#define HFI_DBG_IDX 2
#define HFI_DSP_IDX_BASE 3
#define HFI_DSP_IDX_0 3

#define HFI_CMD_IDX_LEGACY 0
#define HFI_DSP_IDX_0_LEGACY 1
#define HFI_MSG_IDX_LEGACY 4
#define HFI_DBG_IDX_LEGACY 5

#define HFI_QUEUE_STATUS_DISABLED 0
#define HFI_QUEUE_STATUS_ENABLED 1

/* HTOF queue priority, 1 is highest priority */
#define HFI_CMD_PRI 10
#define HFI_MSG_PRI 10
#define HFI_DBG_PRI 40
#define HFI_DSP_PRI_0 20

#define HFI_IRQ_SIDEMSGQ_MASK		BIT(1)
#define HFI_IRQ_DBGQ_MASK		BIT(2)
#define HFI_IRQ_CM3_FAULT_MASK		BIT(15)
#define HFI_IRQ_OOB_MASK		GENMASK(31, 16)
#define HFI_IRQ_MASK			(HFI_IRQ_SIDEMSGQ_MASK |\
					HFI_IRQ_DBGQ_MASK |\
					HFI_IRQ_CM3_FAULT_MASK)


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:360 [MATCH: qhdr] ---
/* Host initializes(zero-init) the buffer */
#define HFI_MEMFLAG_HOST_INIT		BIT(9)

/* Gfx buffer needs to be secure */
#define HFI_MEMFLAG_GFX_SECURE		BIT(12)

/**
 * struct hfi_queue_table_header - HFI queue table structure
 * @version: HFI protocol version
 * @size: queue table size in dwords
 * @qhdr0_offset: first queue header offset (dwords) in this table
 * @qhdr_size: queue header size
 * @num_q: number of queues defined in this table
 * @num_active_q: number of active queues
 */
struct hfi_queue_table_header {
	u32 version;
	u32 size;
	u32 qhdr0_offset;
	u32 qhdr_size;
	u32 num_q;
	u32 num_active_q;
} __packed;

/**
 * struct gmu_context_queue_header - GMU context queue header structure
 */
struct gmu_context_queue_header {
	/** @version: Version of the header */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:361 [MATCH: qhdr] ---
#define HFI_MEMFLAG_HOST_INIT		BIT(9)

/* Gfx buffer needs to be secure */
#define HFI_MEMFLAG_GFX_SECURE		BIT(12)

/**
 * struct hfi_queue_table_header - HFI queue table structure
 * @version: HFI protocol version
 * @size: queue table size in dwords
 * @qhdr0_offset: first queue header offset (dwords) in this table
 * @qhdr_size: queue header size
 * @num_q: number of queues defined in this table
 * @num_active_q: number of active queues
 */
struct hfi_queue_table_header {
	u32 version;
	u32 size;
	u32 qhdr0_offset;
	u32 qhdr_size;
	u32 num_q;
	u32 num_active_q;
} __packed;

/**
 * struct gmu_context_queue_header - GMU context queue header structure
 */
struct gmu_context_queue_header {
	/** @version: Version of the header */
	u32 version;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:368 [MATCH: qhdr] ---
 * @version: HFI protocol version
 * @size: queue table size in dwords
 * @qhdr0_offset: first queue header offset (dwords) in this table
 * @qhdr_size: queue header size
 * @num_q: number of queues defined in this table
 * @num_active_q: number of active queues
 */
struct hfi_queue_table_header {
	u32 version;
	u32 size;
	u32 qhdr0_offset;
	u32 qhdr_size;
	u32 num_q;
	u32 num_active_q;
} __packed;

/**
 * struct gmu_context_queue_header - GMU context queue header structure
 */
struct gmu_context_queue_header {
	/** @version: Version of the header */
	u32 version;
	/** @start_addr: GMU VA of start of the queue */
	u32 start_addr;
	/** @queue_size: queue size in dwords */
	u32 queue_size;
	/** @out_fence_ts: Timestamp of last hardware fence sent to Tx Queue */
	volatile u32 out_fence_ts;
	/** @sync_obj_ts: Timestamp of last sync object that GMU has digested */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:369 [MATCH: qhdr] ---
 * @size: queue table size in dwords
 * @qhdr0_offset: first queue header offset (dwords) in this table
 * @qhdr_size: queue header size
 * @num_q: number of queues defined in this table
 * @num_active_q: number of active queues
 */
struct hfi_queue_table_header {
	u32 version;
	u32 size;
	u32 qhdr0_offset;
	u32 qhdr_size;
	u32 num_q;
	u32 num_active_q;
} __packed;

/**
 * struct gmu_context_queue_header - GMU context queue header structure
 */
struct gmu_context_queue_header {
	/** @version: Version of the header */
	u32 version;
	/** @start_addr: GMU VA of start of the queue */
	u32 start_addr;
	/** @queue_size: queue size in dwords */
	u32 queue_size;
	/** @out_fence_ts: Timestamp of last hardware fence sent to Tx Queue */
	volatile u32 out_fence_ts;
	/** @sync_obj_ts: Timestamp of last sync object that GMU has digested */
	volatile u32 sync_obj_ts;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:388 [MATCH: read_index] ---
	/** @version: Version of the header */
	u32 version;
	/** @start_addr: GMU VA of start of the queue */
	u32 start_addr;
	/** @queue_size: queue size in dwords */
	u32 queue_size;
	/** @out_fence_ts: Timestamp of last hardware fence sent to Tx Queue */
	volatile u32 out_fence_ts;
	/** @sync_obj_ts: Timestamp of last sync object that GMU has digested */
	volatile u32 sync_obj_ts;
	/** @read_index: Read index of the queue */
	volatile u32 read_index;
	/** @write_index: Write index of the queue */
	volatile u32 write_index;
	/**
	 * @hw_fence_buffer_va: GMU VA of the buffer to store output hardware fences for this
	 * context
	 */
	u32 hw_fence_buffer_va;
	/**
	 * @hw_fence_buffer_size: Size of the buffer to store output hardware fences for this
	 * context
	 */
	u32 hw_fence_buffer_size;
	u32 unused1;
	u32 unused2;
	u32 unused3;
} __packed;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:389 [MATCH: read_index] ---
	u32 version;
	/** @start_addr: GMU VA of start of the queue */
	u32 start_addr;
	/** @queue_size: queue size in dwords */
	u32 queue_size;
	/** @out_fence_ts: Timestamp of last hardware fence sent to Tx Queue */
	volatile u32 out_fence_ts;
	/** @sync_obj_ts: Timestamp of last sync object that GMU has digested */
	volatile u32 sync_obj_ts;
	/** @read_index: Read index of the queue */
	volatile u32 read_index;
	/** @write_index: Write index of the queue */
	volatile u32 write_index;
	/**
	 * @hw_fence_buffer_va: GMU VA of the buffer to store output hardware fences for this
	 * context
	 */
	u32 hw_fence_buffer_va;
	/**
	 * @hw_fence_buffer_size: Size of the buffer to store output hardware fences for this
	 * context
	 */
	u32 hw_fence_buffer_size;
	u32 unused1;
	u32 unused2;
	u32 unused3;
} __packed;

/**

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:415 [MATCH: read_index] ---
} __packed;

/**
 * struct hfi_queue_header - HFI queue header structure
 * @status: active: 1; inactive: 0
 * @start_addr: starting address of the queue in GMU VA space
 * @type: queue type encoded the priority, ID and send/recevie types
 * @queue_size: size of the queue
 * @msg_size: size of the message if each message has fixed size.
 *	Otherwise, 0 means variable size of message in the queue.
 * @read_index: read index of the queue
 * @write_index: write index of the queue
 */
struct hfi_queue_header {
	u32 status;
	u32 start_addr;
	u32 type;
	u32 queue_size;
	u32 msg_size;
	u32 unused0;
	u32 unused1;
	u32 unused2;
	u32 unused3;
	u32 unused4;
	volatile u32 read_index;
	volatile u32 write_index;
} __packed;

#define HFI_MSG_CMD 0 /* V1 and V2 */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:429 [MATCH: read_index] ---
	u32 status;
	u32 start_addr;
	u32 type;
	u32 queue_size;
	u32 msg_size;
	u32 unused0;
	u32 unused1;
	u32 unused2;
	u32 unused3;
	u32 unused4;
	volatile u32 read_index;
	volatile u32 write_index;
} __packed;

#define HFI_MSG_CMD 0 /* V1 and V2 */
#define HFI_MSG_ACK 1 /* V2 only */

 /* Used to NOP a command when executing warmboot sequence */
#define HFI_MSG_NOP BIT(18)
 /* Used to record a command when executing coldboot sequence */
#define HFI_MSG_RECORD BIT(19)

#define HFI_V1_MSG_POST 1 /* V1 only */
#define HFI_V1_MSG_ACK 2/* V1 only */

#define MSG_HDR_SET_SIZE(hdr, size) \
	(((size & 0xFF) << 8) | hdr)

#define CREATE_MSG_HDR(id, type) \

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:1474 [MATCH: read_index] ---
 * been consumed by kgsl.
 */
static inline void hfi_update_read_idx(struct hfi_queue_header *hdr, u32 index)
{
	/*
	 * This is to make sure packets are consumed before gmu sees the updated
	 * read index
	 */
	mb();

	hdr->read_index = index;
}

/**
 * hfi_update_write_idx - Update the write index of a GMU queue
 * write_idx: Pointer to the write index
 * index: New write index
 *
 * This function makes sure that the h2f packets are written out
 * to memory before GMU sees the updated write index. This avoids
 * corner cases where GMU might fetch stale entries that can happen
 * if write index is updated before new packets have been written
 * out to memory.
 */
static inline void hfi_update_write_idx(volatile u32 *write_idx, u32 index)
{
	/*
	 * This is to make sure packets are written out before gmu sees the
	 * updated write index

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:390 [MATCH: write_index] ---
	/** @start_addr: GMU VA of start of the queue */
	u32 start_addr;
	/** @queue_size: queue size in dwords */
	u32 queue_size;
	/** @out_fence_ts: Timestamp of last hardware fence sent to Tx Queue */
	volatile u32 out_fence_ts;
	/** @sync_obj_ts: Timestamp of last sync object that GMU has digested */
	volatile u32 sync_obj_ts;
	/** @read_index: Read index of the queue */
	volatile u32 read_index;
	/** @write_index: Write index of the queue */
	volatile u32 write_index;
	/**
	 * @hw_fence_buffer_va: GMU VA of the buffer to store output hardware fences for this
	 * context
	 */
	u32 hw_fence_buffer_va;
	/**
	 * @hw_fence_buffer_size: Size of the buffer to store output hardware fences for this
	 * context
	 */
	u32 hw_fence_buffer_size;
	u32 unused1;
	u32 unused2;
	u32 unused3;
} __packed;

/**
 * struct hfi_queue_header - HFI queue header structure

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:391 [MATCH: write_index] ---
	u32 start_addr;
	/** @queue_size: queue size in dwords */
	u32 queue_size;
	/** @out_fence_ts: Timestamp of last hardware fence sent to Tx Queue */
	volatile u32 out_fence_ts;
	/** @sync_obj_ts: Timestamp of last sync object that GMU has digested */
	volatile u32 sync_obj_ts;
	/** @read_index: Read index of the queue */
	volatile u32 read_index;
	/** @write_index: Write index of the queue */
	volatile u32 write_index;
	/**
	 * @hw_fence_buffer_va: GMU VA of the buffer to store output hardware fences for this
	 * context
	 */
	u32 hw_fence_buffer_va;
	/**
	 * @hw_fence_buffer_size: Size of the buffer to store output hardware fences for this
	 * context
	 */
	u32 hw_fence_buffer_size;
	u32 unused1;
	u32 unused2;
	u32 unused3;
} __packed;

/**
 * struct hfi_queue_header - HFI queue header structure
 * @status: active: 1; inactive: 0

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:416 [MATCH: write_index] ---

/**
 * struct hfi_queue_header - HFI queue header structure
 * @status: active: 1; inactive: 0
 * @start_addr: starting address of the queue in GMU VA space
 * @type: queue type encoded the priority, ID and send/recevie types
 * @queue_size: size of the queue
 * @msg_size: size of the message if each message has fixed size.
 *	Otherwise, 0 means variable size of message in the queue.
 * @read_index: read index of the queue
 * @write_index: write index of the queue
 */
struct hfi_queue_header {
	u32 status;
	u32 start_addr;
	u32 type;
	u32 queue_size;
	u32 msg_size;
	u32 unused0;
	u32 unused1;
	u32 unused2;
	u32 unused3;
	u32 unused4;
	volatile u32 read_index;
	volatile u32 write_index;
} __packed;

#define HFI_MSG_CMD 0 /* V1 and V2 */
#define HFI_MSG_ACK 1 /* V2 only */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hfi.h:430 [MATCH: write_index] ---
	u32 start_addr;
	u32 type;
	u32 queue_size;
	u32 msg_size;
	u32 unused0;
	u32 unused1;
	u32 unused2;
	u32 unused3;
	u32 unused4;
	volatile u32 read_index;
	volatile u32 write_index;
} __packed;

#define HFI_MSG_CMD 0 /* V1 and V2 */
#define HFI_MSG_ACK 1 /* V2 only */

 /* Used to NOP a command when executing warmboot sequence */
#define HFI_MSG_NOP BIT(18)
 /* Used to record a command when executing coldboot sequence */
#define HFI_MSG_RECORD BIT(19)

#define HFI_V1_MSG_POST 1 /* V1 only */
#define HFI_V1_MSG_ACK 2/* V1 only */

#define MSG_HDR_SET_SIZE(hdr, size) \
	(((size & 0xFF) << 8) | hdr)

#define CREATE_MSG_HDR(id, type) \
	(((type) << 16) | ((id) & 0xFF))

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hwsched.c:3103 [MATCH: qhdr] ---
		non_fatal = false;
		break;
	}

	return non_fatal;
}

int adreno_hwsched_poll_msg_queue_write_index(struct kgsl_memdesc *hfi_mem)
{
	struct hfi_queue_table *tbl = hfi_mem->hostptr;
	struct hfi_queue_header *hdr = &tbl->qhdr[HFI_MSG_ID];
	unsigned long timeout = jiffies + msecs_to_jiffies(HFI_RSP_TIMEOUT);

	while (time_before(jiffies, timeout)) {
		if (hdr->write_index != hdr->read_index)
			goto done;

		/* Wait for up to 100 us before trying again */
		usleep_range((POLL_SLEEP_US >> 2) + 1, POLL_SLEEP_US);
		cpu_relax();
	}

	/* Check if the write index has advanced */
	if (hdr->write_index == hdr->read_index)
		return -ETIMEDOUT;

done:
	/*
	 * This is to ensure that the queue is not read speculatively before the

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hwsched.c:2615 [MATCH: read_index] ---
}

static int unregister_context(int id, void *ptr, void *data)
{
	struct kgsl_context *context = ptr;
	struct adreno_context *drawctxt = ADRENO_CONTEXT(context);

	if (drawctxt->gmu_context_queue.gmuaddr != 0) {
		struct gmu_context_queue_header *header =  drawctxt->gmu_context_queue.hostptr;

		header->read_index = header->write_index;
		/* This is to make sure GMU sees the correct indices after recovery */
		mb();
	}

	/*
	 * We don't need to send the unregister hfi packet because
	 * we are anyway going to lose the gmu state of registered
	 * contexts. So just reset the flag so that the context
	 * registers with gmu on its first submission post slumber.
	 */
	context->gmu_registered = false;

	/*
	 * Consider the scenario where non-recurring submissions were made
	 * by a context. Here internal_timestamp of context would be non
	 * zero. After slumber, last retired timestamp is not held by GMU.
	 * If this context submits a recurring workload, the context is
	 * registered again, but the internal timestamp is not updated. When

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hwsched.c:2656 [MATCH: read_index] ---
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct adreno_hwsched *hwsched = &adreno_dev->hwsched;

	read_lock(&device->context_lock);
	idr_for_each(&device->context_idr, unregister_context, NULL);
	read_unlock(&device->context_lock);

	if (hwsched->global_ctxtq.hostptr) {
		struct gmu_context_queue_header *header = hwsched->global_ctxtq.hostptr;

		header->read_index = header->write_index;
		/* This is to make sure GMU sees the correct indices after recovery */
		mb();
	}

	hwsched->global_ctxt_gmu_registered = false;
}

int adreno_gmu_context_queue_read(struct adreno_context *drawctxt, u32 *output,
	u32 read_idx, u32 size_dwords)
{
	struct gmu_context_queue_header *hdr = drawctxt->gmu_context_queue.hostptr;
	u32 *queue = drawctxt->gmu_context_queue.hostptr + sizeof(*hdr);
	u32 i;

	if ((size_dwords > hdr->queue_size) || (read_idx >= hdr->queue_size))
		return -EINVAL;

	/* Clear the output data before populating */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hwsched.c:3107 [MATCH: read_index] ---
	return non_fatal;
}

int adreno_hwsched_poll_msg_queue_write_index(struct kgsl_memdesc *hfi_mem)
{
	struct hfi_queue_table *tbl = hfi_mem->hostptr;
	struct hfi_queue_header *hdr = &tbl->qhdr[HFI_MSG_ID];
	unsigned long timeout = jiffies + msecs_to_jiffies(HFI_RSP_TIMEOUT);

	while (time_before(jiffies, timeout)) {
		if (hdr->write_index != hdr->read_index)
			goto done;

		/* Wait for up to 100 us before trying again */
		usleep_range((POLL_SLEEP_US >> 2) + 1, POLL_SLEEP_US);
		cpu_relax();
	}

	/* Check if the write index has advanced */
	if (hdr->write_index == hdr->read_index)
		return -ETIMEDOUT;

done:
	/*
	 * This is to ensure that the queue is not read speculatively before the
	 * polling condition is evaluated.
	 */
	rmb();


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hwsched.c:3116 [MATCH: read_index] ---
	while (time_before(jiffies, timeout)) {
		if (hdr->write_index != hdr->read_index)
			goto done;

		/* Wait for up to 100 us before trying again */
		usleep_range((POLL_SLEEP_US >> 2) + 1, POLL_SLEEP_US);
		cpu_relax();
	}

	/* Check if the write index has advanced */
	if (hdr->write_index == hdr->read_index)
		return -ETIMEDOUT;

done:
	/*
	 * This is to ensure that the queue is not read speculatively before the
	 * polling condition is evaluated.
	 */
	rmb();

	return 0;
}

/* This function can be called while holding the drawctxt spinlock */
void adreno_hwsched_remove_hw_fence_entry(struct adreno_device *adreno_dev,
	struct adreno_hw_fence_entry *entry)
{
	struct adreno_hwsched *hwsched = &adreno_dev->hwsched;
	struct adreno_context *drawctxt = entry->drawctxt;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hwsched.c:3218 [MATCH: read_index] ---
			context->priority, drawobj->flags);
}

int adreno_gmu_context_queue_write(struct adreno_device *adreno_dev,
	struct kgsl_memdesc *gmu_context_queue, u32 *msg, u32 size_bytes,
	struct kgsl_drawobj *drawobj, struct adreno_submit_time *time)
{
	struct gmu_context_queue_header *hdr = gmu_context_queue->hostptr;
	const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
	u32 *queue = gmu_context_queue->hostptr + sizeof(*hdr);
	u32 i, empty_space, write_idx = hdr->write_index, read_idx = hdr->read_index;
	u32 size_dwords = size_bytes >> 2;
	u32 align_size = ALIGN(size_dwords, SZ_4);
	u32 id = MSG_HDR_GET_ID(*msg);
	struct kgsl_drawobj_cmd *cmdobj = NULL;

	empty_space = (write_idx >= read_idx) ?
			(hdr->queue_size - (write_idx - read_idx))
			: (read_idx - write_idx);

	if (empty_space <= align_size)
		return -ENOSPC;

	if (!IS_ALIGNED(size_bytes, sizeof(u32)))
		return -EINVAL;

	for (i = 0; i < size_dwords; i++) {
		queue[write_idx] = msg[i];
		write_idx = (write_idx + 1) % hdr->queue_size;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hwsched.c:3100 [MATCH: write_index] ---
		break;
	}
	default:
		non_fatal = false;
		break;
	}

	return non_fatal;
}

int adreno_hwsched_poll_msg_queue_write_index(struct kgsl_memdesc *hfi_mem)
{
	struct hfi_queue_table *tbl = hfi_mem->hostptr;
	struct hfi_queue_header *hdr = &tbl->qhdr[HFI_MSG_ID];
	unsigned long timeout = jiffies + msecs_to_jiffies(HFI_RSP_TIMEOUT);

	while (time_before(jiffies, timeout)) {
		if (hdr->write_index != hdr->read_index)
			goto done;

		/* Wait for up to 100 us before trying again */
		usleep_range((POLL_SLEEP_US >> 2) + 1, POLL_SLEEP_US);
		cpu_relax();
	}

	/* Check if the write index has advanced */
	if (hdr->write_index == hdr->read_index)
		return -ETIMEDOUT;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hwsched.c:3274 [MATCH: write_index] ---
	 * Put the profiling information in the user profiling buffer.
	 * The hfi_update_write_idx below has a wmb() before the actual
	 * write index update to ensure that the GMU does not see the
	 * packet before the profile data is written out.
	 */
	adreno_profile_submit_time(time);

done:
	trace_kgsl_hfi_send(id, size_dwords, MSG_HDR_GET_SEQNUM(*msg));

	hfi_update_write_idx(&hdr->write_index, write_idx);

	return 0;
}

int adreno_hwsched_drain_and_idle(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int ret = adreno_drain(device, msecs_to_jiffies(100));

	/* Make sure the dispatcher and hardware are idle */
	if (!ret)
		ret = adreno_hwsched_idle(adreno_dev);

	return ret;
}

static void _retire_inflight_hw_fences(struct adreno_device *adreno_dev,
	struct kgsl_context *context)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hwsched.h:374 [MATCH: write_index] ---
 * @error: Types of error that triggered from context bad HFI
 *
 * This function parses context bad hfi packet and logs error information.
 *
 * Return: True for non fatal error code else false.
 */
bool adreno_hwsched_log_nonfatal_gpu_fault(struct adreno_device *adreno_dev,
		struct device *dev, u32 error);

/**
 * adreno_hwsched_poll_msg_queue_write_index - Poll on write index of HFI message queue
 * @hfi_mem: Memory descriptor for HFI queue table
 *
 * Returns zero if write index advances or ETIMEDOUT if timed out polling
 */
int adreno_hwsched_poll_msg_queue_write_index(struct kgsl_memdesc *hfi_mem);

/**
 * adreno_hwsched_remove_hw_fence_entry - Remove hardware fence entry
 * @adreno_dev: pointer to the adreno device
 * @entry: Pointer to the hardware fence entry
 */
void adreno_hwsched_remove_hw_fence_entry(struct adreno_device *adreno_dev,
	struct adreno_hw_fence_entry *entry);

/**
 * adreno_gmu_context_queue_read - Read data from context queue
 * @drawctxt: Pointer to the adreno draw context
 * @output: Pointer to read the data into

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_hwsched.h:379 [MATCH: write_index] ---
 */
bool adreno_hwsched_log_nonfatal_gpu_fault(struct adreno_device *adreno_dev,
		struct device *dev, u32 error);

/**
 * adreno_hwsched_poll_msg_queue_write_index - Poll on write index of HFI message queue
 * @hfi_mem: Memory descriptor for HFI queue table
 *
 * Returns zero if write index advances or ETIMEDOUT if timed out polling
 */
int adreno_hwsched_poll_msg_queue_write_index(struct kgsl_memdesc *hfi_mem);

/**
 * adreno_hwsched_remove_hw_fence_entry - Remove hardware fence entry
 * @adreno_dev: pointer to the adreno device
 * @entry: Pointer to the hardware fence entry
 */
void adreno_hwsched_remove_hw_fence_entry(struct adreno_device *adreno_dev,
	struct adreno_hw_fence_entry *entry);

/**
 * adreno_gmu_context_queue_read - Read data from context queue
 * @drawctxt: Pointer to the adreno draw context
 * @output: Pointer to read the data into
 * @read_idx: Index to read the data from
 * @size: Number of dwords to read from the context queue
 *
 * Return: 0 on success or negative error on failure
 */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_gmu_core.c:957 [MATCH: read_index] ---
	struct gmu_trace_packet *pkt;
	u16 seq_num, num_pkts = 0;
	u32 ridx, widx;

	if (IS_ERR_OR_NULL(trace->md))
		return;

	trace_hdr = trace->md->hostptr;
	buffer = trace->md->hostptr;

	ridx = readl(&trace_hdr->read_index);
	widx = readl(&trace_hdr->write_index);

	if (ridx == widx)
		return;

	/*
	 * Don't process any traces and force set read_index to write_index if
	 * previously encountered invalid trace packet
	 */
	if (trace->reset_hdr) {
		/* update read index to let f2h daemon to go to sleep */
		writel(trace_hdr->write_index, &trace_hdr->read_index);
		return;
	}

	/* start reading trace buffer data */
	pkt = (struct gmu_trace_packet *)&buffer[trace_hdr->payload_offset + ridx];


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_gmu_core.c:964 [MATCH: read_index] ---
	trace_hdr = trace->md->hostptr;
	buffer = trace->md->hostptr;

	ridx = readl(&trace_hdr->read_index);
	widx = readl(&trace_hdr->write_index);

	if (ridx == widx)
		return;

	/*
	 * Don't process any traces and force set read_index to write_index if
	 * previously encountered invalid trace packet
	 */
	if (trace->reset_hdr) {
		/* update read index to let f2h daemon to go to sleep */
		writel(trace_hdr->write_index, &trace_hdr->read_index);
		return;
	}

	/* start reading trace buffer data */
	pkt = (struct gmu_trace_packet *)&buffer[trace_hdr->payload_offset + ridx];

	/* Validate packet header */
	if (TRACE_PKT_GET_VALID_FIELD(pkt->hdr) != TRACE_PKT_VALID) {
		char str[128];

		snprintf(str, sizeof(str),
			"Invalid trace packet found at read index: %d resetting trace header\n",
			trace_hdr->read_index);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_gmu_core.c:969 [MATCH: read_index] ---

	if (ridx == widx)
		return;

	/*
	 * Don't process any traces and force set read_index to write_index if
	 * previously encountered invalid trace packet
	 */
	if (trace->reset_hdr) {
		/* update read index to let f2h daemon to go to sleep */
		writel(trace_hdr->write_index, &trace_hdr->read_index);
		return;
	}

	/* start reading trace buffer data */
	pkt = (struct gmu_trace_packet *)&buffer[trace_hdr->payload_offset + ridx];

	/* Validate packet header */
	if (TRACE_PKT_GET_VALID_FIELD(pkt->hdr) != TRACE_PKT_VALID) {
		char str[128];

		snprintf(str, sizeof(str),
			"Invalid trace packet found at read index: %d resetting trace header\n",
			trace_hdr->read_index);
		/*
		 * GMU is not expected to write an invalid trace packet. This
		 * condition can be true in case there is memory corruption. In
		 * such scenario fastforward readindex to writeindex so the we
		 * don't process any trace packets until we reset the trace

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_gmu_core.c:982 [MATCH: read_index] ---

	/* start reading trace buffer data */
	pkt = (struct gmu_trace_packet *)&buffer[trace_hdr->payload_offset + ridx];

	/* Validate packet header */
	if (TRACE_PKT_GET_VALID_FIELD(pkt->hdr) != TRACE_PKT_VALID) {
		char str[128];

		snprintf(str, sizeof(str),
			"Invalid trace packet found at read index: %d resetting trace header\n",
			trace_hdr->read_index);
		/*
		 * GMU is not expected to write an invalid trace packet. This
		 * condition can be true in case there is memory corruption. In
		 * such scenario fastforward readindex to writeindex so the we
		 * don't process any trace packets until we reset the trace
		 * header in next slumber exit.
		 */
		dev_err_ratelimited(device->dev, "%s\n", str);
		trace_kgsl_msg(str);
		writel(trace_hdr->write_index, &trace_hdr->read_index);
		trace->reset_hdr = true;
		return;
	}

	size = TRACE_PKT_GET_SIZE(pkt->hdr);

	if (TRACE_PKT_GET_SKIP_FIELD(pkt->hdr))
		goto done;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_gmu_core.c:992 [MATCH: read_index] ---
			trace_hdr->read_index);
		/*
		 * GMU is not expected to write an invalid trace packet. This
		 * condition can be true in case there is memory corruption. In
		 * such scenario fastforward readindex to writeindex so the we
		 * don't process any trace packets until we reset the trace
		 * header in next slumber exit.
		 */
		dev_err_ratelimited(device->dev, "%s\n", str);
		trace_kgsl_msg(str);
		writel(trace_hdr->write_index, &trace_hdr->read_index);
		trace->reset_hdr = true;
		return;
	}

	size = TRACE_PKT_GET_SIZE(pkt->hdr);

	if (TRACE_PKT_GET_SKIP_FIELD(pkt->hdr))
		goto done;

	seq_num = TRACE_PKT_GET_SEQNUM(pkt->hdr);
	num_pkts = seq_num - trace->seq_num;

	/* Detect trace packet loss by tracking any gaps in the sequence number */
	if (num_pkts > 1) {
		char str[128];

		snprintf(str, sizeof(str),
			"%d GMU trace packets dropped from sequence number: %d\n",

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_gmu_core.c:1019 [MATCH: read_index] ---
		snprintf(str, sizeof(str),
			"%d GMU trace packets dropped from sequence number: %d\n",
			num_pkts - 1, trace->seq_num);
		trace_kgsl_msg(str);
	}

	trace->seq_num = seq_num;
	stream_trace_data(device, pkt);
done:
	ridx = (ridx + size) % trace_hdr->payload_size;
	writel(ridx, &trace_hdr->read_index);
}

bool gmu_core_is_trace_empty(struct gmu_trace_header *hdr)
{
	return (readl(&hdr->read_index) == readl(&hdr->write_index)) ? true : false;
}

void gmu_core_trace_header_init(struct kgsl_gmu_trace *trace)
{
	struct gmu_trace_header *hdr = trace->md->hostptr;

	hdr->threshold = TRACE_BUFFER_THRESHOLD;
	hdr->timeout = TRACE_TIMEOUT_MSEC;
	hdr->metadata = FIELD_PREP(GENMASK(31, 30), TRACE_MODE_DROP) |
			FIELD_PREP(GENMASK(3, 0), TRACE_HEADER_VERSION_1);
	hdr->cookie = trace->md->gmuaddr;
	hdr->size = trace->md->size;
	hdr->log_type = TRACE_LOGTYPE_HWSCHED;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_gmu_core.c:1024 [MATCH: read_index] ---

	trace->seq_num = seq_num;
	stream_trace_data(device, pkt);
done:
	ridx = (ridx + size) % trace_hdr->payload_size;
	writel(ridx, &trace_hdr->read_index);
}

bool gmu_core_is_trace_empty(struct gmu_trace_header *hdr)
{
	return (readl(&hdr->read_index) == readl(&hdr->write_index)) ? true : false;
}

void gmu_core_trace_header_init(struct kgsl_gmu_trace *trace)
{
	struct gmu_trace_header *hdr = trace->md->hostptr;

	hdr->threshold = TRACE_BUFFER_THRESHOLD;
	hdr->timeout = TRACE_TIMEOUT_MSEC;
	hdr->metadata = FIELD_PREP(GENMASK(31, 30), TRACE_MODE_DROP) |
			FIELD_PREP(GENMASK(3, 0), TRACE_HEADER_VERSION_1);
	hdr->cookie = trace->md->gmuaddr;
	hdr->size = trace->md->size;
	hdr->log_type = TRACE_LOGTYPE_HWSCHED;
}

void gmu_core_reset_trace_header(struct kgsl_gmu_trace *trace)
{
	if (!trace->reset_hdr || IS_ERR_OR_NULL(trace->md))

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_gmu_core.c:958 [MATCH: write_index] ---
	u16 seq_num, num_pkts = 0;
	u32 ridx, widx;

	if (IS_ERR_OR_NULL(trace->md))
		return;

	trace_hdr = trace->md->hostptr;
	buffer = trace->md->hostptr;

	ridx = readl(&trace_hdr->read_index);
	widx = readl(&trace_hdr->write_index);

	if (ridx == widx)
		return;

	/*
	 * Don't process any traces and force set read_index to write_index if
	 * previously encountered invalid trace packet
	 */
	if (trace->reset_hdr) {
		/* update read index to let f2h daemon to go to sleep */
		writel(trace_hdr->write_index, &trace_hdr->read_index);
		return;
	}

	/* start reading trace buffer data */
	pkt = (struct gmu_trace_packet *)&buffer[trace_hdr->payload_offset + ridx];

	/* Validate packet header */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_gmu_core.h:305 [MATCH: read_index] ---
	 * tracepoints data. Set it to zero to disable thresholding. Threshold is %
	 * of buffer full condition not the trace packet count. If GMU is continuously
	 * writing to trace buffer makes it buffer full condition when KMD is not
	 * consuming it. So GMU check the how much trace buffer % space is full based
	 * on the threshold % value.If the trace packets are filling over % buffer full
	 * condition GMU will send the f2h message for KMD to drain the trace messages.
	 */
	u32 threshold;
	/** @size: trace buffer allocation size in bytes */
	u32 size;
	/** @read_index: trace buffer read index in dwords */
	u32 read_index;
	/** @write_index: trace buffer write index in dwords */
	u32 write_index;
	/** @payload_offset: trace buffer payload dword offset */
	u32 payload_offset;
	/** @payload_size: trace buffer payload size in dword */
	u32 payload_size;
	/** cookie: cookie data sent through F2H_PROCESS_MESSAGE */
	u64 cookie;
	/**
	 * timeout: GMU Trace Timer value in msec - zero to disable trace timer else
	 * value for GMU trace timerhandler to send HFI msg.
	 */
	u32 timeout;
	/** @log_type: To decode the trace buffer data */
	u32 log_type;
} __packed;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_gmu_core.h:306 [MATCH: read_index] ---
	 * of buffer full condition not the trace packet count. If GMU is continuously
	 * writing to trace buffer makes it buffer full condition when KMD is not
	 * consuming it. So GMU check the how much trace buffer % space is full based
	 * on the threshold % value.If the trace packets are filling over % buffer full
	 * condition GMU will send the f2h message for KMD to drain the trace messages.
	 */
	u32 threshold;
	/** @size: trace buffer allocation size in bytes */
	u32 size;
	/** @read_index: trace buffer read index in dwords */
	u32 read_index;
	/** @write_index: trace buffer write index in dwords */
	u32 write_index;
	/** @payload_offset: trace buffer payload dword offset */
	u32 payload_offset;
	/** @payload_size: trace buffer payload size in dword */
	u32 payload_size;
	/** cookie: cookie data sent through F2H_PROCESS_MESSAGE */
	u64 cookie;
	/**
	 * timeout: GMU Trace Timer value in msec - zero to disable trace timer else
	 * value for GMU trace timerhandler to send HFI msg.
	 */
	u32 timeout;
	/** @log_type: To decode the trace buffer data */
	u32 log_type;
} __packed;

/* Trace ID definition */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_gmu_core.h:283 [MATCH: write_index] ---
#define TRACE_PKT_GET_SKIP_FIELD(hdr) (((hdr) & TRACE_PKT_SKIP_MASK) >> TRACE_PKT_SKIP_SHIFT)

/*
 * Trace buffer header definition
 * Trace buffer header fields initialized/updated by KGSL and GMU
 * GMU input: Following header fields are initialized by KGSL
 *           - @metadata, @threshold, @size, @cookie, @timeout, @log_type
 *           - @readIndex updated by kgsl when traces messages are consumed.
 * GMU output: Following header fields are initialized by GMU only
 *           - @magic, @payload_offset, @payload_size
 *           - @write_index updated by GMU upon filling the trace messages
 */
struct gmu_trace_header {
	/** @magic: Initialized by GMU to check header is valid or not */
	u32 magic;
	/**
	 * @metadata: Trace buffer metadata.Bit(31) Trace Mode to log tracepoints
	 * messages, Bits [3:0] Version for header format changes.
	 */
	u32 metadata;
	/**
	 * @threshold: % at which GMU to send f2h message to wakeup KMD to consume
	 * tracepoints data. Set it to zero to disable thresholding. Threshold is %
	 * of buffer full condition not the trace packet count. If GMU is continuously
	 * writing to trace buffer makes it buffer full condition when KMD is not
	 * consuming it. So GMU check the how much trace buffer % space is full based
	 * on the threshold % value.If the trace packets are filling over % buffer full
	 * condition GMU will send the f2h message for KMD to drain the trace messages.
	 */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_gmu_core.h:307 [MATCH: write_index] ---
	 * writing to trace buffer makes it buffer full condition when KMD is not
	 * consuming it. So GMU check the how much trace buffer % space is full based
	 * on the threshold % value.If the trace packets are filling over % buffer full
	 * condition GMU will send the f2h message for KMD to drain the trace messages.
	 */
	u32 threshold;
	/** @size: trace buffer allocation size in bytes */
	u32 size;
	/** @read_index: trace buffer read index in dwords */
	u32 read_index;
	/** @write_index: trace buffer write index in dwords */
	u32 write_index;
	/** @payload_offset: trace buffer payload dword offset */
	u32 payload_offset;
	/** @payload_size: trace buffer payload size in dword */
	u32 payload_size;
	/** cookie: cookie data sent through F2H_PROCESS_MESSAGE */
	u64 cookie;
	/**
	 * timeout: GMU Trace Timer value in msec - zero to disable trace timer else
	 * value for GMU trace timerhandler to send HFI msg.
	 */
	u32 timeout;
	/** @log_type: To decode the trace buffer data */
	u32 log_type;
} __packed;

/* Trace ID definition */
enum gmu_trace_id {

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_gmu_core.h:308 [MATCH: write_index] ---
	 * consuming it. So GMU check the how much trace buffer % space is full based
	 * on the threshold % value.If the trace packets are filling over % buffer full
	 * condition GMU will send the f2h message for KMD to drain the trace messages.
	 */
	u32 threshold;
	/** @size: trace buffer allocation size in bytes */
	u32 size;
	/** @read_index: trace buffer read index in dwords */
	u32 read_index;
	/** @write_index: trace buffer write index in dwords */
	u32 write_index;
	/** @payload_offset: trace buffer payload dword offset */
	u32 payload_offset;
	/** @payload_size: trace buffer payload size in dword */
	u32 payload_size;
	/** cookie: cookie data sent through F2H_PROCESS_MESSAGE */
	u64 cookie;
	/**
	 * timeout: GMU Trace Timer value in msec - zero to disable trace timer else
	 * value for GMU trace timerhandler to send HFI msg.
	 */
	u32 timeout;
	/** @log_type: To decode the trace buffer data */
	u32 log_type;
} __packed;

/* Trace ID definition */
enum gmu_trace_id {
	GMU_TRACE_PREEMPT_TRIGGER = 1,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pool.c:236 [MATCH: READ_ONCE] ---
		__free_pages(p, pool->pool_order);
		return;
	}

	if (__kgsl_pool_add_page(pool, p)) {
		__free_pages(p, pool->pool_order);
		trace_kgsl_pool_free_page(pool->pool_order);
		return;
	}

	/* Use READ_ONCE to read page_count without holding list_lock */
	trace_kgsl_pool_add_page(pool->pool_order, READ_ONCE(pool->page_count));
	mod_node_page_state(page_pgdat(p),  NR_KERNEL_MISC_RECLAIMABLE,
				(1 << pool->pool_order));
}

/* Returns a page from specified pool */
static struct page *
_kgsl_pool_get_page(struct kgsl_page_pool *pool)
{
	struct page *p = NULL;

	spin_lock(&pool->list_lock);
	p = __kgsl_pool_get_page(pool);
	spin_unlock(&pool->list_lock);
	if (p != NULL) {
		/* Use READ_ONCE to read page_count without holding list_lock */
		trace_kgsl_pool_get_page(pool->pool_order,
				READ_ONCE(pool->page_count));

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pool.c:237 [MATCH: READ_ONCE] ---
		return;
	}

	if (__kgsl_pool_add_page(pool, p)) {
		__free_pages(p, pool->pool_order);
		trace_kgsl_pool_free_page(pool->pool_order);
		return;
	}

	/* Use READ_ONCE to read page_count without holding list_lock */
	trace_kgsl_pool_add_page(pool->pool_order, READ_ONCE(pool->page_count));
	mod_node_page_state(page_pgdat(p),  NR_KERNEL_MISC_RECLAIMABLE,
				(1 << pool->pool_order));
}

/* Returns a page from specified pool */
static struct page *
_kgsl_pool_get_page(struct kgsl_page_pool *pool)
{
	struct page *p = NULL;

	spin_lock(&pool->list_lock);
	p = __kgsl_pool_get_page(pool);
	spin_unlock(&pool->list_lock);
	if (p != NULL) {
		/* Use READ_ONCE to read page_count without holding list_lock */
		trace_kgsl_pool_get_page(pool->pool_order,
				READ_ONCE(pool->page_count));
		mod_node_page_state(page_pgdat(p), NR_KERNEL_MISC_RECLAIMABLE,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pool.c:252 [MATCH: READ_ONCE] ---
/* Returns a page from specified pool */
static struct page *
_kgsl_pool_get_page(struct kgsl_page_pool *pool)
{
	struct page *p = NULL;

	spin_lock(&pool->list_lock);
	p = __kgsl_pool_get_page(pool);
	spin_unlock(&pool->list_lock);
	if (p != NULL) {
		/* Use READ_ONCE to read page_count without holding list_lock */
		trace_kgsl_pool_get_page(pool->pool_order,
				READ_ONCE(pool->page_count));
		mod_node_page_state(page_pgdat(p), NR_KERNEL_MISC_RECLAIMABLE,
				-(1 << pool->pool_order));
	}
	return p;
}

int kgsl_pool_size_total(void)
{
	int i;
	int total = 0;

	for (i = 0; i < kgsl_num_pools; i++) {
		struct kgsl_page_pool *kgsl_pool = &kgsl_pools[i];

		spin_lock(&kgsl_pool->list_lock);
		total += kgsl_pool->page_count * (1 << kgsl_pool->pool_order);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pool.c:254 [MATCH: READ_ONCE] ---
_kgsl_pool_get_page(struct kgsl_page_pool *pool)
{
	struct page *p = NULL;

	spin_lock(&pool->list_lock);
	p = __kgsl_pool_get_page(pool);
	spin_unlock(&pool->list_lock);
	if (p != NULL) {
		/* Use READ_ONCE to read page_count without holding list_lock */
		trace_kgsl_pool_get_page(pool->pool_order,
				READ_ONCE(pool->page_count));
		mod_node_page_state(page_pgdat(p), NR_KERNEL_MISC_RECLAIMABLE,
				-(1 << pool->pool_order));
	}
	return p;
}

int kgsl_pool_size_total(void)
{
	int i;
	int total = 0;

	for (i = 0; i < kgsl_num_pools; i++) {
		struct kgsl_page_pool *kgsl_pool = &kgsl_pools[i];

		spin_lock(&kgsl_pool->list_lock);
		total += kgsl_pool->page_count * (1 << kgsl_pool->pool_order);
		spin_unlock(&kgsl_pool->list_lock);
	}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pool.c:315 [MATCH: READ_ONCE] ---

	spin_lock(&pool->list_lock);
	if (pool->page_count <= pool->reserved_pages) {
		spin_unlock(&pool->list_lock);
		return NULL;
	}

	p = __kgsl_pool_get_page(pool);
	spin_unlock(&pool->list_lock);
	if (p != NULL) {
		/* Use READ_ONCE to read page_count without holding list_lock */
		trace_kgsl_pool_get_page(pool->pool_order,
					READ_ONCE(pool->page_count));
		mod_node_page_state(page_pgdat(p), NR_KERNEL_MISC_RECLAIMABLE,
				-(1 << pool->pool_order));
	}
	return p;
}

/*
 * This will shrink the specified pool by num_pages or by
 * (page_count - reserved_pages), whichever is smaller.
 */
static unsigned int
_kgsl_pool_shrink(struct kgsl_page_pool *pool,
			unsigned int num_pages, bool exit)
{
	int j;
	unsigned int pcount = 0;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pool.c:317 [MATCH: READ_ONCE] ---
	if (pool->page_count <= pool->reserved_pages) {
		spin_unlock(&pool->list_lock);
		return NULL;
	}

	p = __kgsl_pool_get_page(pool);
	spin_unlock(&pool->list_lock);
	if (p != NULL) {
		/* Use READ_ONCE to read page_count without holding list_lock */
		trace_kgsl_pool_get_page(pool->pool_order,
					READ_ONCE(pool->page_count));
		mod_node_page_state(page_pgdat(p), NR_KERNEL_MISC_RECLAIMABLE,
				-(1 << pool->pool_order));
	}
	return p;
}

/*
 * This will shrink the specified pool by num_pages or by
 * (page_count - reserved_pages), whichever is smaller.
 */
static unsigned int
_kgsl_pool_shrink(struct kgsl_page_pool *pool,
			unsigned int num_pages, bool exit)
{
	int j;
	unsigned int pcount = 0;
	struct page *(*get_page)(struct kgsl_page_pool *) =
		_kgsl_pool_get_nonreserved_page;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pool.c:551 [MATCH: READ_ONCE] ---
	int page_order;

	if (page == NULL)
		return;

	page_order = compound_order(page);

	if (!kgsl_pool_max_pages ||
			(kgsl_pool_size_total() < kgsl_pool_max_pages)) {
		pool = _kgsl_get_pool_from_order(page_order);
		/* Use READ_ONCE to read page_count without holding list_lock */
		if (pool && (READ_ONCE(pool->page_count) < pool->max_pages)) {
			_kgsl_pool_add_page(pool, page);
			return;
		}
	}

	/* Give back to system as not added to pool */
	__free_pages(page, page_order);
	trace_kgsl_pool_free_page(page_order);
}

/* Functions for the shrinker */

static unsigned long
kgsl_pool_shrink_scan_objects(struct shrinker *shrinker,
					struct shrink_control *sc)
{
	/* sc->nr_to_scan represents number of pages to be removed*/

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pool.c:552 [MATCH: READ_ONCE] ---

	if (page == NULL)
		return;

	page_order = compound_order(page);

	if (!kgsl_pool_max_pages ||
			(kgsl_pool_size_total() < kgsl_pool_max_pages)) {
		pool = _kgsl_get_pool_from_order(page_order);
		/* Use READ_ONCE to read page_count without holding list_lock */
		if (pool && (READ_ONCE(pool->page_count) < pool->max_pages)) {
			_kgsl_pool_add_page(pool, page);
			return;
		}
	}

	/* Give back to system as not added to pool */
	__free_pages(page, page_order);
	trace_kgsl_pool_free_page(page_order);
}

/* Functions for the shrinker */

static unsigned long
kgsl_pool_shrink_scan_objects(struct shrinker *shrinker,
					struct shrink_control *sc)
{
	/* sc->nr_to_scan represents number of pages to be removed*/
	unsigned long pcount = kgsl_pool_reduce(sc->nr_to_scan, false);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pool.c:599 [MATCH: READ_ONCE] ---
	struct kgsl_page_pool *pool = data;

	*val = (u64) pool->reserved_pages;
	return 0;
}

int kgsl_pool_page_count_get(void *data, u64 *val)
{
	struct kgsl_page_pool *pool = data;

	/* Use READ_ONCE to read page_count without holding list_lock */
	*val = (u64) READ_ONCE(pool->page_count);
	return 0;
}

static void kgsl_pool_reserve_pages(struct kgsl_page_pool *pool,
		struct device_node *node)
{
	u32 reserved = 0;
	int i;

	of_property_read_u32(node, "qcom,mempool-reserved", &reserved);

	reserved = min_t(u32, reserved, pool->max_pages);

	/* Limit the total number of reserved pages to 4096 */
	pool->reserved_pages = min_t(u32, reserved, 4096);

#if IS_ENABLED(CONFIG_QCOM_KGSL_SORT_POOL)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pool.c:600 [MATCH: READ_ONCE] ---

	*val = (u64) pool->reserved_pages;
	return 0;
}

int kgsl_pool_page_count_get(void *data, u64 *val)
{
	struct kgsl_page_pool *pool = data;

	/* Use READ_ONCE to read page_count without holding list_lock */
	*val = (u64) READ_ONCE(pool->page_count);
	return 0;
}

static void kgsl_pool_reserve_pages(struct kgsl_page_pool *pool,
		struct device_node *node)
{
	u32 reserved = 0;
	int i;

	of_property_read_u32(node, "qcom,mempool-reserved", &reserved);

	reserved = min_t(u32, reserved, pool->max_pages);

	/* Limit the total number of reserved pages to 4096 */
	pool->reserved_pages = min_t(u32, reserved, 4096);

#if IS_ENABLED(CONFIG_QCOM_KGSL_SORT_POOL)
	/*

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pool.c:73 [MATCH: WRITE_ONCE] ---
		if (new_page->physaddr < entry->physaddr)
			node = &parent->rb_left;
		else
			node = &parent->rb_right;
	}

	rb_link_node(&new_page->node, parent, node);
	rb_insert_color(&new_page->node, &pool->pool_rbtree);

	/*
	 * page_count may be read without the list_lock held. Use WRITE_ONCE
	 * to avoid compiler optimizations that may break consistency.
	 */
	ASSERT_EXCLUSIVE_WRITER(pool->page_count);
	WRITE_ONCE(pool->page_count, pool->page_count + 1);
	spin_unlock(&pool->list_lock);

	return 0;
}

static struct page *
__kgsl_pool_get_page(struct kgsl_page_pool *pool)
{
	struct rb_node *node;
	struct kgsl_pool_page_entry *entry;
	struct page *p;

	node = rb_first(&pool->pool_rbtree);
	if (!node)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pool.c:77 [MATCH: WRITE_ONCE] ---
	}

	rb_link_node(&new_page->node, parent, node);
	rb_insert_color(&new_page->node, &pool->pool_rbtree);

	/*
	 * page_count may be read without the list_lock held. Use WRITE_ONCE
	 * to avoid compiler optimizations that may break consistency.
	 */
	ASSERT_EXCLUSIVE_WRITER(pool->page_count);
	WRITE_ONCE(pool->page_count, pool->page_count + 1);
	spin_unlock(&pool->list_lock);

	return 0;
}

static struct page *
__kgsl_pool_get_page(struct kgsl_page_pool *pool)
{
	struct rb_node *node;
	struct kgsl_pool_page_entry *entry;
	struct page *p;

	node = rb_first(&pool->pool_rbtree);
	if (!node)
		return NULL;

	entry = rb_entry(node, struct kgsl_pool_page_entry, node);
	p = entry->page;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pool.c:103 [MATCH: WRITE_ONCE] ---

	entry = rb_entry(node, struct kgsl_pool_page_entry, node);
	p = entry->page;
	rb_erase(&entry->node, &pool->pool_rbtree);
	if (pool->mempool)
		mempool_free(entry, pool->mempool);
	else
		kmem_cache_free(addr_page_cache, entry);

	/*
	 * page_count may be read without the list_lock held. Use WRITE_ONCE
	 * to avoid compiler optimizations that may break consistency.
	 */
	ASSERT_EXCLUSIVE_WRITER(pool->page_count);
	WRITE_ONCE(pool->page_count, pool->page_count - 1);
	return p;
}

static void kgsl_pool_list_init(struct kgsl_page_pool *pool)
{
	pool->pool_rbtree = RB_ROOT;
}

static void kgsl_pool_cache_init(void)
{
	addr_page_cache =  KMEM_CACHE(kgsl_pool_page_entry, 0);
}

static void kgsl_pool_cache_destroy(void)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pool.c:107 [MATCH: WRITE_ONCE] ---
	if (pool->mempool)
		mempool_free(entry, pool->mempool);
	else
		kmem_cache_free(addr_page_cache, entry);

	/*
	 * page_count may be read without the list_lock held. Use WRITE_ONCE
	 * to avoid compiler optimizations that may break consistency.
	 */
	ASSERT_EXCLUSIVE_WRITER(pool->page_count);
	WRITE_ONCE(pool->page_count, pool->page_count - 1);
	return p;
}

static void kgsl_pool_list_init(struct kgsl_page_pool *pool)
{
	pool->pool_rbtree = RB_ROOT;
}

static void kgsl_pool_cache_init(void)
{
	addr_page_cache =  KMEM_CACHE(kgsl_pool_page_entry, 0);
}

static void kgsl_pool_cache_destroy(void)
{
	kmem_cache_destroy(addr_page_cache);
}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pool.c:140 [MATCH: WRITE_ONCE] ---

#else

static int
__kgsl_pool_add_page(struct kgsl_page_pool *pool, struct page *p)
{
	spin_lock(&pool->list_lock);
	list_add_tail(&p->lru, &pool->page_list);

	/*
	 * page_count may be read without the list_lock held. Use WRITE_ONCE
	 * to avoid compiler optimizations that may break consistency.
	 */
	ASSERT_EXCLUSIVE_WRITER(pool->page_count);
	WRITE_ONCE(pool->page_count, pool->page_count + 1);
	spin_unlock(&pool->list_lock);

	return 0;
}

static struct page *
__kgsl_pool_get_page(struct kgsl_page_pool *pool)
{
	struct page *p;

	p = list_first_entry_or_null(&pool->page_list, struct page, lru);
	if (p) {
		/*
		 * page_count may be read without the list_lock held. Use

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pool.c:144 [MATCH: WRITE_ONCE] ---
__kgsl_pool_add_page(struct kgsl_page_pool *pool, struct page *p)
{
	spin_lock(&pool->list_lock);
	list_add_tail(&p->lru, &pool->page_list);

	/*
	 * page_count may be read without the list_lock held. Use WRITE_ONCE
	 * to avoid compiler optimizations that may break consistency.
	 */
	ASSERT_EXCLUSIVE_WRITER(pool->page_count);
	WRITE_ONCE(pool->page_count, pool->page_count + 1);
	spin_unlock(&pool->list_lock);

	return 0;
}

static struct page *
__kgsl_pool_get_page(struct kgsl_page_pool *pool)
{
	struct page *p;

	p = list_first_entry_or_null(&pool->page_list, struct page, lru);
	if (p) {
		/*
		 * page_count may be read without the list_lock held. Use
		 * WRITE_ONCE to avoid compiler optimizations that may break
		 * consistency.
		 */
		ASSERT_EXCLUSIVE_WRITER(pool->page_count);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pool.c:159 [MATCH: WRITE_ONCE] ---

static struct page *
__kgsl_pool_get_page(struct kgsl_page_pool *pool)
{
	struct page *p;

	p = list_first_entry_or_null(&pool->page_list, struct page, lru);
	if (p) {
		/*
		 * page_count may be read without the list_lock held. Use
		 * WRITE_ONCE to avoid compiler optimizations that may break
		 * consistency.
		 */
		ASSERT_EXCLUSIVE_WRITER(pool->page_count);
		WRITE_ONCE(pool->page_count, pool->page_count - 1);
		list_del(&p->lru);
	}

	return p;
}

static void kgsl_pool_list_init(struct kgsl_page_pool *pool)
{
	INIT_LIST_HEAD(&pool->page_list);
}

static void kgsl_pool_cache_init(void)
{
}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pool.c:163 [MATCH: WRITE_ONCE] ---
	struct page *p;

	p = list_first_entry_or_null(&pool->page_list, struct page, lru);
	if (p) {
		/*
		 * page_count may be read without the list_lock held. Use
		 * WRITE_ONCE to avoid compiler optimizations that may break
		 * consistency.
		 */
		ASSERT_EXCLUSIVE_WRITER(pool->page_count);
		WRITE_ONCE(pool->page_count, pool->page_count - 1);
		list_del(&p->lru);
	}

	return p;
}

static void kgsl_pool_list_init(struct kgsl_page_pool *pool)
{
	INIT_LIST_HEAD(&pool->page_list);
}

static void kgsl_pool_cache_init(void)
{
}

static void kgsl_pool_cache_destroy(void)
{
}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pwrctrl.c:85 [MATCH: READ_ONCE] ---
 * constraints and return the nearest possible level
 * @pwr: kgsl_pwrctrl structure for the device
 * @level: Requested level
 * @pwrc: Pointer to the power constraint to be applied
 *
 * Apply thermal and max/min limits first. Then force the level with a
 * constraint if one exists.
 */
static u32 _adjust_pwrlevel(struct kgsl_pwrctrl *pwr, u32 level, struct kgsl_pwr_constraint *pwrc)
{
	u32 thermal_pwrlevel = max_t(u32, READ_ONCE(pwr->thermal_pwrlevel),
			READ_ONCE(pwr->pmqos_max_pwrlevel));
	/* Ensure that max pwrlevel is within pmqos max limit */
	u32 max_pwrlevel = max_t(u32, pwr->max_pwrlevel, thermal_pwrlevel);
	/* Ensure that min pwrlevel is within thermal limit */
	u32 min_pwrlevel = max_t(u32, pwr->min_pwrlevel, thermal_pwrlevel);

	switch (pwrc->type) {
	case KGSL_CONSTRAINT_PWRLEVEL: {
		switch (pwrc->sub_type) {
		case KGSL_CONSTRAINT_PWR_MAX:
			return max_pwrlevel;
		case KGSL_CONSTRAINT_PWR_MIN:
			return min_pwrlevel;
		default:
			break;
		}
	}
	break;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pwrctrl.c:86 [MATCH: READ_ONCE] ---
 * @pwr: kgsl_pwrctrl structure for the device
 * @level: Requested level
 * @pwrc: Pointer to the power constraint to be applied
 *
 * Apply thermal and max/min limits first. Then force the level with a
 * constraint if one exists.
 */
static u32 _adjust_pwrlevel(struct kgsl_pwrctrl *pwr, u32 level, struct kgsl_pwr_constraint *pwrc)
{
	u32 thermal_pwrlevel = max_t(u32, READ_ONCE(pwr->thermal_pwrlevel),
			READ_ONCE(pwr->pmqos_max_pwrlevel));
	/* Ensure that max pwrlevel is within pmqos max limit */
	u32 max_pwrlevel = max_t(u32, pwr->max_pwrlevel, thermal_pwrlevel);
	/* Ensure that min pwrlevel is within thermal limit */
	u32 min_pwrlevel = max_t(u32, pwr->min_pwrlevel, thermal_pwrlevel);

	switch (pwrc->type) {
	case KGSL_CONSTRAINT_PWRLEVEL: {
		switch (pwrc->sub_type) {
		case KGSL_CONSTRAINT_PWR_MAX:
			return max_pwrlevel;
		case KGSL_CONSTRAINT_PWR_MIN:
			return min_pwrlevel;
		default:
			break;
		}
	}
	break;
	}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pwrctrl.c:363 [MATCH: READ_ONCE] ---

	return count;
}

static ssize_t thermal_pwrlevel_show(struct device *dev,
			struct device_attribute *attr, char *buf)
{

	struct kgsl_device *device = dev_get_drvdata(dev);
	struct kgsl_pwrctrl *pwr = &device->pwrctrl;
	u32 thermal_pwrlevel = max_t(u32, READ_ONCE(pwr->thermal_pwrlevel),
					READ_ONCE(pwr->pmqos_max_pwrlevel));

	return scnprintf(buf, PAGE_SIZE, "%d\n", thermal_pwrlevel);
}

static ssize_t thermal_time_show(struct device *dev,
			struct device_attribute *attr, char *buf)
{
	struct kgsl_device *device = dev_get_drvdata(dev);

	return scnprintf(buf, PAGE_SIZE, "%llu\n", device->pwrctrl.thermal_time);
}

static ssize_t max_pwrlevel_store(struct device *dev,
				struct device_attribute *attr,
				const char *buf, size_t count)
{
	struct kgsl_device *device = dev_get_drvdata(dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pwrctrl.c:364 [MATCH: READ_ONCE] ---
	return count;
}

static ssize_t thermal_pwrlevel_show(struct device *dev,
			struct device_attribute *attr, char *buf)
{

	struct kgsl_device *device = dev_get_drvdata(dev);
	struct kgsl_pwrctrl *pwr = &device->pwrctrl;
	u32 thermal_pwrlevel = max_t(u32, READ_ONCE(pwr->thermal_pwrlevel),
					READ_ONCE(pwr->pmqos_max_pwrlevel));

	return scnprintf(buf, PAGE_SIZE, "%d\n", thermal_pwrlevel);
}

static ssize_t thermal_time_show(struct device *dev,
			struct device_attribute *attr, char *buf)
{
	struct kgsl_device *device = dev_get_drvdata(dev);

	return scnprintf(buf, PAGE_SIZE, "%llu\n", device->pwrctrl.thermal_time);
}

static ssize_t max_pwrlevel_store(struct device *dev,
				struct device_attribute *attr,
				const char *buf, size_t count)
{
	struct kgsl_device *device = dev_get_drvdata(dev);
	struct kgsl_pwrctrl *pwr = &device->pwrctrl;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pwrctrl.c:525 [MATCH: READ_ONCE] ---
		return ret;

	return count;
}

static ssize_t max_gpuclk_show(struct device *dev,
			struct device_attribute *attr, char *buf)
{
	struct kgsl_device *device = dev_get_drvdata(dev);
	struct kgsl_pwrctrl *pwr = &device->pwrctrl;
	u32 max_pwrlevel = max_t(u32, READ_ONCE(pwr->thermal_pwrlevel),
				READ_ONCE(pwr->pmqos_max_pwrlevel));

	return scnprintf(buf, PAGE_SIZE, "%d\n",
		device->pwrctrl.pwrlevels[max_pwrlevel].gpu_freq);
}

static ssize_t gpuclk_store(struct device *dev,
				     struct device_attribute *attr,
				     const char *buf, size_t count)
{
	struct kgsl_device *device = dev_get_drvdata(dev);
	struct kgsl_pwrctrl *pwr = &device->pwrctrl;
	unsigned int val = 0;
	int ret, level;

	ret = kstrtou32(buf, 0, &val);
	if (ret)
		return ret;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pwrctrl.c:526 [MATCH: READ_ONCE] ---

	return count;
}

static ssize_t max_gpuclk_show(struct device *dev,
			struct device_attribute *attr, char *buf)
{
	struct kgsl_device *device = dev_get_drvdata(dev);
	struct kgsl_pwrctrl *pwr = &device->pwrctrl;
	u32 max_pwrlevel = max_t(u32, READ_ONCE(pwr->thermal_pwrlevel),
				READ_ONCE(pwr->pmqos_max_pwrlevel));

	return scnprintf(buf, PAGE_SIZE, "%d\n",
		device->pwrctrl.pwrlevels[max_pwrlevel].gpu_freq);
}

static ssize_t gpuclk_store(struct device *dev,
				     struct device_attribute *attr,
				     const char *buf, size_t count)
{
	struct kgsl_device *device = dev_get_drvdata(dev);
	struct kgsl_pwrctrl *pwr = &device->pwrctrl;
	unsigned int val = 0;
	int ret, level;

	ret = kstrtou32(buf, 0, &val);
	if (ret)
		return ret;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pwrctrl.c:967 [MATCH: READ_ONCE] ---
				const char *buf, size_t count)
{
	struct kgsl_device *device = dev_get_drvdata(dev);

	return _min_clock_mhz_store(device, buf, count);
}

static ssize_t _max_clock_mhz_show(struct kgsl_device *device, char *buf)
{
	struct kgsl_pwrctrl *pwr = &device->pwrctrl;
	u32 max_pwrlevel = max_t(u32, READ_ONCE(pwr->thermal_pwrlevel),
				READ_ONCE(pwr->pmqos_max_pwrlevel));

	return scnprintf(buf, PAGE_SIZE, "%d\n",
		pwr->pwrlevels[max_pwrlevel].gpu_freq / 1000000);
}

static ssize_t max_clock_mhz_show(struct device *dev,
				struct device_attribute *attr, char *buf)
{
	struct kgsl_device *device = dev_get_drvdata(dev);

	return _max_clock_mhz_show(device, buf);
}

static ssize_t _max_clock_mhz_store(struct kgsl_device *device,
				const char *buf, size_t count)
{
	u32 freq;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pwrctrl.c:968 [MATCH: READ_ONCE] ---
{
	struct kgsl_device *device = dev_get_drvdata(dev);

	return _min_clock_mhz_store(device, buf, count);
}

static ssize_t _max_clock_mhz_show(struct kgsl_device *device, char *buf)
{
	struct kgsl_pwrctrl *pwr = &device->pwrctrl;
	u32 max_pwrlevel = max_t(u32, READ_ONCE(pwr->thermal_pwrlevel),
				READ_ONCE(pwr->pmqos_max_pwrlevel));

	return scnprintf(buf, PAGE_SIZE, "%d\n",
		pwr->pwrlevels[max_pwrlevel].gpu_freq / 1000000);
}

static ssize_t max_clock_mhz_show(struct device *dev,
				struct device_attribute *attr, char *buf)
{
	struct kgsl_device *device = dev_get_drvdata(dev);

	return _max_clock_mhz_show(device, buf);
}

static ssize_t _max_clock_mhz_store(struct kgsl_device *device,
				const char *buf, size_t count)
{
	u32 freq;
	int ret, level;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pwrctrl.c:2037 [MATCH: READ_ONCE] ---
	*state = device->pwrctrl.num_pwrlevels - 1;
	return 0;
}

static int kgsl_cooling_get_cur_state(struct thermal_cooling_device *cooling_dev,
		unsigned long *state)
{
	struct kgsl_device *device = cooling_dev->devdata;
	struct kgsl_pwrctrl *pwr = &device->pwrctrl;

	*state = READ_ONCE(pwr->thermal_pwrlevel);
	return 0;
}

static int kgsl_cooling_set_cur_state(struct thermal_cooling_device *cooling_dev,
		unsigned long state)
{
	struct kgsl_device *device = cooling_dev->devdata;
	struct kgsl_pwrctrl *pwr = &device->pwrctrl;
	u32 freq;

	if (state > (pwr->num_pwrlevels - 1))
		return -EINVAL;

	if (state == READ_ONCE(pwr->thermal_pwrlevel))
		return 0;

	freq = pwr->pwrlevels[state].gpu_freq;
	trace_kgsl_thermal_constraint(freq);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pwrctrl.c:2051 [MATCH: READ_ONCE] ---
static int kgsl_cooling_set_cur_state(struct thermal_cooling_device *cooling_dev,
		unsigned long state)
{
	struct kgsl_device *device = cooling_dev->devdata;
	struct kgsl_pwrctrl *pwr = &device->pwrctrl;
	u32 freq;

	if (state > (pwr->num_pwrlevels - 1))
		return -EINVAL;

	if (state == READ_ONCE(pwr->thermal_pwrlevel))
		return 0;

	freq = pwr->pwrlevels[state].gpu_freq;
	trace_kgsl_thermal_constraint(freq);
	WRITE_ONCE(pwr->thermal_pwrlevel, state);

	kthread_queue_work(pwr->cooling_worker, &pwr->cooling_work);
	return 0;
}

static const struct thermal_cooling_device_ops kgsl_cooling_ops = {
	.get_max_state = kgsl_cooling_get_max_state,
	.get_cur_state = kgsl_cooling_get_cur_state,
	.set_cur_state = kgsl_cooling_set_cur_state,
};

#if (KERNEL_VERSION(7, 2, 0) <= LINUX_VERSION_CODE)
static struct thermal_cooling_device *

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_pwrctrl.c:2056 [MATCH: WRITE_ONCE] ---
	u32 freq;

	if (state > (pwr->num_pwrlevels - 1))
		return -EINVAL;

	if (state == READ_ONCE(pwr->thermal_pwrlevel))
		return 0;

	freq = pwr->pwrlevels[state].gpu_freq;
	trace_kgsl_thermal_constraint(freq);
	WRITE_ONCE(pwr->thermal_pwrlevel, state);

	kthread_queue_work(pwr->cooling_worker, &pwr->cooling_work);
	return 0;
}

static const struct thermal_cooling_device_ops kgsl_cooling_ops = {
	.get_max_state = kgsl_cooling_get_max_state,
	.get_cur_state = kgsl_cooling_get_cur_state,
	.set_cur_state = kgsl_cooling_set_cur_state,
};

#if (KERNEL_VERSION(7, 2, 0) <= LINUX_VERSION_CODE)
static struct thermal_cooling_device *
kgsl_thermal_of_cooling_device_register(struct device_node *np,
		const char *type, void *devdata,
		const struct thermal_cooling_device_ops *ops)
{
	return thermal_of_cooling_device_register(np, 0, type, devdata, ops);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_regmap.c:285 [MATCH: read_index] ---
void __iomem *kgsl_regmap_virt(struct kgsl_regmap *regmap, u32 offset)
{
	struct kgsl_regmap_region *region = kgsl_regmap_get_region(regmap, offset);

	if (region)
		return region_addr(region, offset);

	return NULL;
}

void kgsl_regmap_read_indexed(struct kgsl_regmap *regmap, u32 addr,
		u32 data, u32 *dest, int count)
{
	struct kgsl_regmap_region *region = kgsl_regmap_get_region(regmap, addr);
	int i;

	if (!region)
		return;

	/* Make sure the offset is in the same region */
	if (kgsl_regmap_get_region(regmap, data) != region)
		return;

	if (region->ops && region->ops->preaccess)
		region->ops->preaccess(region);

	/* Write the address register */
	writel_relaxed(0, region_addr(region, addr));


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_regmap.c:314 [MATCH: read_index] ---
	/* Make sure the write finishes */
	wmb();

	for (i = 0; i < count; i++)
		dest[i] = readl_relaxed(region_addr(region, data));

	/* Do one barrier at the end to make sure all the data is posted */
	rmb();
}

void kgsl_regmap_read_indexed_interleaved(struct kgsl_regmap *regmap, u32 addr,
		u32 data, u32 *dest, u32 start, int count)
{
	struct kgsl_regmap_region *region = kgsl_regmap_get_region(regmap, addr);
	int i;

	if (!region)
		return;

	/* Make sure the offset is in the same region */
	if (kgsl_regmap_get_region(regmap, data) != region)
		return;

	if (region->ops && region->ops->preaccess)
		region->ops->preaccess(region);

	for (i = 0; i < count; i++) {
		/* Write the address register */
		writel_relaxed(start + i, region_addr(region, addr));

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_regmap.h:230 [MATCH: read_index] ---
/**
 * kgsl_regmap_virt - Return the kernel address for a offset
 * @regmap: The regmap to write to
 * @offset: The dword offset to map to a kernel address
 *
 * Return: The kernel address for @offset or NULL if out of range.
 */
void __iomem *kgsl_regmap_virt(struct kgsl_regmap *regmap, u32 offset);

/**
 * kgsl_regmap_read_indexed - Read a indexed pair of registers
 * @regmap: The regmap to read from
 * @addr: The offset of the address register for the index pair
 * @data: The offset of the data register for the index pair
 * @dest: An array to put the values
 * @count: Number of dwords to read from @data
 *
 * This function configures the address register once and then
 * reads from the data register in a loop.
 */
void kgsl_regmap_read_indexed(struct kgsl_regmap *regmap, u32 addr,
		u32 data, u32 *dest, int count);

/**
 * kgsl_regmap_read_indexed_interleaved - Dump an indexed pair of registers
 * @regmap: The regmap to read from
 * @addr: The offset of the address register for the index pair
 * @data: The offset of the data register for the index pair
 * @dest: An array to put the values

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_regmap.h:240 [MATCH: read_index] ---
 * kgsl_regmap_read_indexed - Read a indexed pair of registers
 * @regmap: The regmap to read from
 * @addr: The offset of the address register for the index pair
 * @data: The offset of the data register for the index pair
 * @dest: An array to put the values
 * @count: Number of dwords to read from @data
 *
 * This function configures the address register once and then
 * reads from the data register in a loop.
 */
void kgsl_regmap_read_indexed(struct kgsl_regmap *regmap, u32 addr,
		u32 data, u32 *dest, int count);

/**
 * kgsl_regmap_read_indexed_interleaved - Dump an indexed pair of registers
 * @regmap: The regmap to read from
 * @addr: The offset of the address register for the index pair
 * @data: The offset of the data register for the index pair
 * @dest: An array to put the values
 * @start: Starting value to be programmed in the address register
 * @count: Number of dwords to read from @data
 *
 * This function is slightly different than kgsl_regmap_read_indexed()
 * in that it takes as argument a start value that is to be programmed
 * in the address register and secondly, the address register is to be
 * configured before every read of the data register.
 */
void kgsl_regmap_read_indexed_interleaved(struct kgsl_regmap *regmap, u32 addr,
		u32 data, u32 *dest, u32 start, int count);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_regmap.h:244 [MATCH: read_index] ---
 * @dest: An array to put the values
 * @count: Number of dwords to read from @data
 *
 * This function configures the address register once and then
 * reads from the data register in a loop.
 */
void kgsl_regmap_read_indexed(struct kgsl_regmap *regmap, u32 addr,
		u32 data, u32 *dest, int count);

/**
 * kgsl_regmap_read_indexed_interleaved - Dump an indexed pair of registers
 * @regmap: The regmap to read from
 * @addr: The offset of the address register for the index pair
 * @data: The offset of the data register for the index pair
 * @dest: An array to put the values
 * @start: Starting value to be programmed in the address register
 * @count: Number of dwords to read from @data
 *
 * This function is slightly different than kgsl_regmap_read_indexed()
 * in that it takes as argument a start value that is to be programmed
 * in the address register and secondly, the address register is to be
 * configured before every read of the data register.
 */
void kgsl_regmap_read_indexed_interleaved(struct kgsl_regmap *regmap, u32 addr,
		u32 data, u32 *dest, u32 start, int count);

/**
 * kgsl_regmap_get_region - Return the region for the given offset
 * @regmap: The regmap to query

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_regmap.h:252 [MATCH: read_index] ---

/**
 * kgsl_regmap_read_indexed_interleaved - Dump an indexed pair of registers
 * @regmap: The regmap to read from
 * @addr: The offset of the address register for the index pair
 * @data: The offset of the data register for the index pair
 * @dest: An array to put the values
 * @start: Starting value to be programmed in the address register
 * @count: Number of dwords to read from @data
 *
 * This function is slightly different than kgsl_regmap_read_indexed()
 * in that it takes as argument a start value that is to be programmed
 * in the address register and secondly, the address register is to be
 * configured before every read of the data register.
 */
void kgsl_regmap_read_indexed_interleaved(struct kgsl_regmap *regmap, u32 addr,
		u32 data, u32 *dest, u32 start, int count);

/**
 * kgsl_regmap_get_region - Return the region for the given offset
 * @regmap: The regmap to query
 * @offset: The offset to query
 *
 * Return: The &struct kgsl_regmap_region that owns the offset or NULL
 */
struct kgsl_regmap_region *kgsl_regmap_get_region(struct kgsl_regmap *regmap,
		u32 offset);

/**

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_regmap.h:257 [MATCH: read_index] ---
 * @data: The offset of the data register for the index pair
 * @dest: An array to put the values
 * @start: Starting value to be programmed in the address register
 * @count: Number of dwords to read from @data
 *
 * This function is slightly different than kgsl_regmap_read_indexed()
 * in that it takes as argument a start value that is to be programmed
 * in the address register and secondly, the address register is to be
 * configured before every read of the data register.
 */
void kgsl_regmap_read_indexed_interleaved(struct kgsl_regmap *regmap, u32 addr,
		u32 data, u32 *dest, u32 start, int count);

/**
 * kgsl_regmap_get_region - Return the region for the given offset
 * @regmap: The regmap to query
 * @offset: The offset to query
 *
 * Return: The &struct kgsl_regmap_region that owns the offset or NULL
 */
struct kgsl_regmap_region *kgsl_regmap_get_region(struct kgsl_regmap *regmap,
		u32 offset);

/**
 * kgsl_regmap_poll_read - A helper function for kgsl_regmap_read_poll_timeout
 * @region: Pointer to a &struct kgsl_regmap_region
 * @offset: Offset to read
 * @val: Pointer for the result
 *

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_snapshot.c:360 [MATCH: read_index] ---
	if (remain < (iregs->count * 4) + sizeof(*header)) {
		SNAPSHOT_ERR_NOMEM(device, "INDEXED REGS");
		return 0;
	}

	header->index_reg = iregs->index;
	header->data_reg = iregs->data;
	header->count = iregs->count;
	header->start = iregs->start;

	kgsl_regmap_read_indexed_interleaved(&device->regmap, iregs->index,
		iregs->data, data, iregs->start, iregs->count);

	return (iregs->count * 4) + sizeof(*header);
}

/**
 * kgsl_snapshot_indexed_registers - Add a set of indexed registers to the
 * snapshot
 * @device: Pointer to the KGSL device being snapshotted
 * @snapshot: Snapshot instance
 * @index: Offset for the index register
 * @data: Offset for the data register
 * @start: Index to start reading
 * @count: Number of entries to read
 *
 * Dump the values from an indexed register group into the snapshot
 */
void kgsl_snapshot_indexed_registers(struct kgsl_device *device,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_snapshot.c:415 [MATCH: read_index] ---
		return 0;
	}

	header->index_reg = iregs->index;
	header->data_reg = iregs->data;
	header->count = iregs->count;
	header->start = iregs->start;
	header->pipe_id = iregs->pipe_id;
	header->slice_id = iregs->slice_id;

	kgsl_regmap_read_indexed_interleaved(&device->regmap, iregs->index,
		iregs->data, data, iregs->start, iregs->count);

	return (iregs->count * 4) + sizeof(*header);
}

void kgsl_snapshot_indexed_registers_v2(struct kgsl_device *device,
		struct kgsl_snapshot *snapshot,
		u32 index, u32 data, u32 start, u32 count,
		u32 pipe_id, u32 slice_id)
{
	struct kgsl_snapshot_indexed_registers_v2 iregs;

	iregs.index = index;
	iregs.data = data;
	iregs.start = start;
	iregs.count = count;
	iregs.pipe_id = pipe_id;
	iregs.slice_id = slice_id;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_sync.c:151 [MATCH: read_index] ---
	return ret;
}

bool kgsl_hw_fence_tx_slot_available(struct kgsl_device *device, u32 pending_hw_fence_count)
{
	void *ptr = kgsl_synx.mem_descriptor.vaddr;
	struct synx_hw_fence_hfi_queue_header *hdr = (struct synx_hw_fence_hfi_queue_header *)
		(ptr + sizeof(struct synx_hw_fence_hfi_queue_table_header));
	u32 queue_size_dwords = hdr->queue_size / sizeof(u32);
	u32 payload_size_dwords = hdr->pkt_size / sizeof(u32);
	u32 free_entries, write_idx = hdr->write_index, read_idx = hdr->read_index;

	free_entries = read_idx <= write_idx ?
		queue_size_dwords - (write_idx - read_idx) :
		read_idx - write_idx;

	free_entries /= payload_size_dwords;

	/* Ensure free_entries does not become negative */
	if (free_entries == 0)
		return false;

	free_entries -= 1;

	if (free_entries > pending_hw_fence_count)
		return true;

	return false;
}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_sync.c:305 [MATCH: read_index] ---
	return ret;
}

bool kgsl_hw_fence_tx_slot_available(struct kgsl_device *device, u32 pending_hw_fence_count)
{
	void *ptr = kgsl_msm_hw_fence.mem_descriptor.virtual_addr;
	struct msm_hw_fence_hfi_queue_header *hdr = (struct msm_hw_fence_hfi_queue_header *)
		(ptr + sizeof(struct msm_hw_fence_hfi_queue_table_header));
	u32 queue_size_dwords = hdr->queue_size / sizeof(u32);
	u32 payload_size_dwords = hdr->pkt_size / sizeof(u32);
	u32 free_entries, write_idx = hdr->write_index, read_idx = hdr->read_index;

	free_entries = read_idx <= write_idx ?
		queue_size_dwords - (write_idx - read_idx) :
		read_idx - write_idx;

	free_entries /= payload_size_dwords;

	/* Ensure free_entries does not become negative */
	if (free_entries == 0)
		return false;

	free_entries -= 1;

	if (free_entries > pending_hw_fence_count)
		return true;

	return false;
}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\kgsl_util.c:48 [MATCH: READ_ONCE] ---
}

bool kgsl_genpd_is_enabled(struct device *dev)
{
	struct generic_pm_domain *genpd;

	if (IS_ERR_OR_NULL(dev) || IS_ERR_OR_NULL(dev->pm_domain))
		return false;

	genpd = pd_to_genpd(dev->pm_domain);
	return (READ_ONCE(genpd->status) == GENPD_STATE_ON);
}

struct clk *kgsl_of_clk_by_name(struct clk_bulk_data *clks, int count,
		const char *id)
{
	int i;

	for (i = 0; clks && i < count; i++)
		if (!strcmp(clks[i].id, id))
			return clks[i].clk;

	return NULL;
}

int kgsl_regulator_set_voltage(struct device *dev,
		struct regulator *reg, u32 voltage)
{
	int ret;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\downstream_dependencies\msm_hw_fence.h:55 [MATCH: qhdr] ---
	const char *name;
	u64 *handle;
	void *fence;
	u32 flags;
};

/**
 * struct msm_hw_fence_hfi_queue_table_header - HFI queue table structure.
 * @version: HFI protocol version.
 * @size: Queue table size in dwords.
 * @qhdr0_offset: First queue header offset (dwords) in this table.
 * @qhdr_size: Queue header size.
 * @num_q: Number of queues defined in this table.
 * @num_active_q: Number of active queues.
 */
struct msm_hw_fence_hfi_queue_table_header {
	u32 version;
	u32 size;
	u32 qhdr0_offset;
	u32 qhdr_size;
	u32 num_q;
	u32 num_active_q;
};

/**
 * struct msm_hw_fence_hfi_queue_header - HFI queue header structure.
 * @status: Active = 1, Inactive = 0.
 * @start_addr: Starting address of the queue.
 * @type: Queue type (rx/tx).

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\downstream_dependencies\msm_hw_fence.h:56 [MATCH: qhdr] ---
	u64 *handle;
	void *fence;
	u32 flags;
};

/**
 * struct msm_hw_fence_hfi_queue_table_header - HFI queue table structure.
 * @version: HFI protocol version.
 * @size: Queue table size in dwords.
 * @qhdr0_offset: First queue header offset (dwords) in this table.
 * @qhdr_size: Queue header size.
 * @num_q: Number of queues defined in this table.
 * @num_active_q: Number of active queues.
 */
struct msm_hw_fence_hfi_queue_table_header {
	u32 version;
	u32 size;
	u32 qhdr0_offset;
	u32 qhdr_size;
	u32 num_q;
	u32 num_active_q;
};

/**
 * struct msm_hw_fence_hfi_queue_header - HFI queue header structure.
 * @status: Active = 1, Inactive = 0.
 * @start_addr: Starting address of the queue.
 * @type: Queue type (rx/tx).
 * @queue_size: Size of the queue.

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\downstream_dependencies\msm_hw_fence.h:63 [MATCH: qhdr] ---
 * @version: HFI protocol version.
 * @size: Queue table size in dwords.
 * @qhdr0_offset: First queue header offset (dwords) in this table.
 * @qhdr_size: Queue header size.
 * @num_q: Number of queues defined in this table.
 * @num_active_q: Number of active queues.
 */
struct msm_hw_fence_hfi_queue_table_header {
	u32 version;
	u32 size;
	u32 qhdr0_offset;
	u32 qhdr_size;
	u32 num_q;
	u32 num_active_q;
};

/**
 * struct msm_hw_fence_hfi_queue_header - HFI queue header structure.
 * @status: Active = 1, Inactive = 0.
 * @start_addr: Starting address of the queue.
 * @type: Queue type (rx/tx).
 * @queue_size: Size of the queue.
 * @pkt_size: Size of the queue packet entries,
 *            0 - means variable size of message in the queue,
 *            non-zero - size of the packet, fixed.
 * @pkt_drop_cnt: Number of packets drop by sender.
 * @rx_wm: Receiver watermark, applicable in event driven mode.
 * @tx_wm: Sender watermark, applicable in event driven mode.
 * @rx_req: Receiver sets this bit if queue is empty.

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\downstream_dependencies\msm_hw_fence.h:64 [MATCH: qhdr] ---
 * @size: Queue table size in dwords.
 * @qhdr0_offset: First queue header offset (dwords) in this table.
 * @qhdr_size: Queue header size.
 * @num_q: Number of queues defined in this table.
 * @num_active_q: Number of active queues.
 */
struct msm_hw_fence_hfi_queue_table_header {
	u32 version;
	u32 size;
	u32 qhdr0_offset;
	u32 qhdr_size;
	u32 num_q;
	u32 num_active_q;
};

/**
 * struct msm_hw_fence_hfi_queue_header - HFI queue header structure.
 * @status: Active = 1, Inactive = 0.
 * @start_addr: Starting address of the queue.
 * @type: Queue type (rx/tx).
 * @queue_size: Size of the queue.
 * @pkt_size: Size of the queue packet entries,
 *            0 - means variable size of message in the queue,
 *            non-zero - size of the packet, fixed.
 * @pkt_drop_cnt: Number of packets drop by sender.
 * @rx_wm: Receiver watermark, applicable in event driven mode.
 * @tx_wm: Sender watermark, applicable in event driven mode.
 * @rx_req: Receiver sets this bit if queue is empty.
 * @tx_req: Sender sets this bit if queue is full.

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\downstream_dependencies\msm_hw_fence.h:87 [MATCH: read_index] ---
 *            non-zero - size of the packet, fixed.
 * @pkt_drop_cnt: Number of packets drop by sender.
 * @rx_wm: Receiver watermark, applicable in event driven mode.
 * @tx_wm: Sender watermark, applicable in event driven mode.
 * @rx_req: Receiver sets this bit if queue is empty.
 * @tx_req: Sender sets this bit if queue is full.
 * @rx_irq_status: Receiver sets this bit and triggers an interrupt to the
 *                 sender after packets are dequeued. Sender clears this bit.
 * @tx_irq_status: Sender sets this bit and triggers an interrupt to the
 *                 receiver after packets are queued. Receiver clears this bit.
 * @read_index: read index of the queue.
 * @write_index: write index of the queue.
 */
struct msm_hw_fence_hfi_queue_header {
	u32 status;
	u32 start_addr;
	u32 type;
	u32 queue_size;
	u32 pkt_size;
	u32 pkt_drop_cnt;
	u32 rx_wm;
	u32 tx_wm;
	u32 rx_req;
	u32 tx_req;
	u32 rx_irq_status;
	u32 tx_irq_status;
	u32 read_index;
	u32 write_index;
};

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\downstream_dependencies\msm_hw_fence.h:103 [MATCH: read_index] ---
	u32 type;
	u32 queue_size;
	u32 pkt_size;
	u32 pkt_drop_cnt;
	u32 rx_wm;
	u32 tx_wm;
	u32 rx_req;
	u32 tx_req;
	u32 rx_irq_status;
	u32 tx_irq_status;
	u32 read_index;
	u32 write_index;
};

/**
 * struct msm_hw_fence_mem_addr - Memory descriptor of the queue allocated by
 *                           the fence driver for each client during
 *                           register.
 * @virtual_addr: Kernel virtual address of the queue.
 * @device_addr: Physical address of the memory object.
 * @size: Size of the memory.
 * @mem_data: Internal pointer with the attributes of the allocation.
 */
struct msm_hw_fence_mem_addr {
	void *virtual_addr;
	phys_addr_t device_addr;
	u64 size;
	void *mem_data;
};

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\downstream_dependencies\msm_hw_fence.h:88 [MATCH: write_index] ---
 * @pkt_drop_cnt: Number of packets drop by sender.
 * @rx_wm: Receiver watermark, applicable in event driven mode.
 * @tx_wm: Sender watermark, applicable in event driven mode.
 * @rx_req: Receiver sets this bit if queue is empty.
 * @tx_req: Sender sets this bit if queue is full.
 * @rx_irq_status: Receiver sets this bit and triggers an interrupt to the
 *                 sender after packets are dequeued. Sender clears this bit.
 * @tx_irq_status: Sender sets this bit and triggers an interrupt to the
 *                 receiver after packets are queued. Receiver clears this bit.
 * @read_index: read index of the queue.
 * @write_index: write index of the queue.
 */
struct msm_hw_fence_hfi_queue_header {
	u32 status;
	u32 start_addr;
	u32 type;
	u32 queue_size;
	u32 pkt_size;
	u32 pkt_drop_cnt;
	u32 rx_wm;
	u32 tx_wm;
	u32 rx_req;
	u32 tx_req;
	u32 rx_irq_status;
	u32 tx_irq_status;
	u32 read_index;
	u32 write_index;
};


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\downstream_dependencies\msm_hw_fence.h:104 [MATCH: write_index] ---
	u32 queue_size;
	u32 pkt_size;
	u32 pkt_drop_cnt;
	u32 rx_wm;
	u32 tx_wm;
	u32 rx_req;
	u32 tx_req;
	u32 rx_irq_status;
	u32 tx_irq_status;
	u32 read_index;
	u32 write_index;
};

/**
 * struct msm_hw_fence_mem_addr - Memory descriptor of the queue allocated by
 *                           the fence driver for each client during
 *                           register.
 * @virtual_addr: Kernel virtual address of the queue.
 * @device_addr: Physical address of the memory object.
 * @size: Size of the memory.
 * @mem_data: Internal pointer with the attributes of the allocation.
 */
struct msm_hw_fence_mem_addr {
	void *virtual_addr;
	phys_addr_t device_addr;
	u64 size;
	void *mem_data;
};


######## F: COMMAND TRANSACTION LIFECYCLE ########

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\a5xx_reg.h:13 [MATCH: timeout] ---
 * Copyright (c) 2014-2016,2019, The Linux Foundation. All rights reserved.
 * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
 */

#ifndef _A5XX_REG_H
#define _A5XX_REG_H

/* A5XX interrupt bits */
#define A5XX_INT_RBBM_GPU_IDLE           0
#define A5XX_INT_RBBM_AHB_ERROR          1
#define A5XX_INT_RBBM_TRANSFER_TIMEOUT   2
#define A5XX_INT_RBBM_ME_MS_TIMEOUT      3
#define A5XX_INT_RBBM_PFP_MS_TIMEOUT     4
#define A5XX_INT_RBBM_ETS_MS_TIMEOUT     5
#define A5XX_INT_RBBM_ATB_ASYNC_OVERFLOW 6
#define A5XX_INT_RBBM_GPC_ERROR          7
#define A5XX_INT_CP_SW                   8
#define A5XX_INT_CP_HW_ERROR             9
#define A5XX_INT_CP_CCU_FLUSH_DEPTH_TS   10
#define A5XX_INT_CP_CCU_FLUSH_COLOR_TS   11
#define A5XX_INT_CP_CCU_RESOLVE_TS       12
#define A5XX_INT_CP_IB2                  13
#define A5XX_INT_CP_IB1                  14
#define A5XX_INT_CP_RB                   15
#define A5XX_INT_CP_UNUSED_1             16
#define A5XX_INT_CP_RB_DONE_TS           17
#define A5XX_INT_CP_WT_DONE_TS           18
#define A5XX_INT_UNKNOWN_1               19
#define A5XX_INT_CP_CACHE_FLUSH_TS       20

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\a5xx_reg.h:14 [MATCH: timeout] ---
 * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
 */

#ifndef _A5XX_REG_H
#define _A5XX_REG_H

/* A5XX interrupt bits */
#define A5XX_INT_RBBM_GPU_IDLE           0
#define A5XX_INT_RBBM_AHB_ERROR          1
#define A5XX_INT_RBBM_TRANSFER_TIMEOUT   2
#define A5XX_INT_RBBM_ME_MS_TIMEOUT      3
#define A5XX_INT_RBBM_PFP_MS_TIMEOUT     4
#define A5XX_INT_RBBM_ETS_MS_TIMEOUT     5
#define A5XX_INT_RBBM_ATB_ASYNC_OVERFLOW 6
#define A5XX_INT_RBBM_GPC_ERROR          7
#define A5XX_INT_CP_SW                   8
#define A5XX_INT_CP_HW_ERROR             9
#define A5XX_INT_CP_CCU_FLUSH_DEPTH_TS   10
#define A5XX_INT_CP_CCU_FLUSH_COLOR_TS   11
#define A5XX_INT_CP_CCU_RESOLVE_TS       12
#define A5XX_INT_CP_IB2                  13
#define A5XX_INT_CP_IB1                  14
#define A5XX_INT_CP_RB                   15
#define A5XX_INT_CP_UNUSED_1             16
#define A5XX_INT_CP_RB_DONE_TS           17
#define A5XX_INT_CP_WT_DONE_TS           18
#define A5XX_INT_UNKNOWN_1               19
#define A5XX_INT_CP_CACHE_FLUSH_TS       20
#define A5XX_INT_UNUSED_2                21

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\a5xx_reg.h:15 [MATCH: timeout] ---
 */

#ifndef _A5XX_REG_H
#define _A5XX_REG_H

/* A5XX interrupt bits */
#define A5XX_INT_RBBM_GPU_IDLE           0
#define A5XX_INT_RBBM_AHB_ERROR          1
#define A5XX_INT_RBBM_TRANSFER_TIMEOUT   2
#define A5XX_INT_RBBM_ME_MS_TIMEOUT      3
#define A5XX_INT_RBBM_PFP_MS_TIMEOUT     4
#define A5XX_INT_RBBM_ETS_MS_TIMEOUT     5
#define A5XX_INT_RBBM_ATB_ASYNC_OVERFLOW 6
#define A5XX_INT_RBBM_GPC_ERROR          7
#define A5XX_INT_CP_SW                   8
#define A5XX_INT_CP_HW_ERROR             9
#define A5XX_INT_CP_CCU_FLUSH_DEPTH_TS   10
#define A5XX_INT_CP_CCU_FLUSH_COLOR_TS   11
#define A5XX_INT_CP_CCU_RESOLVE_TS       12
#define A5XX_INT_CP_IB2                  13
#define A5XX_INT_CP_IB1                  14
#define A5XX_INT_CP_RB                   15
#define A5XX_INT_CP_UNUSED_1             16
#define A5XX_INT_CP_RB_DONE_TS           17
#define A5XX_INT_CP_WT_DONE_TS           18
#define A5XX_INT_UNKNOWN_1               19
#define A5XX_INT_CP_CACHE_FLUSH_TS       20
#define A5XX_INT_UNUSED_2                21
#define A5XX_INT_RBBM_ATB_BUS_OVERFLOW   22

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\a5xx_reg.h:16 [MATCH: timeout] ---

#ifndef _A5XX_REG_H
#define _A5XX_REG_H

/* A5XX interrupt bits */
#define A5XX_INT_RBBM_GPU_IDLE           0
#define A5XX_INT_RBBM_AHB_ERROR          1
#define A5XX_INT_RBBM_TRANSFER_TIMEOUT   2
#define A5XX_INT_RBBM_ME_MS_TIMEOUT      3
#define A5XX_INT_RBBM_PFP_MS_TIMEOUT     4
#define A5XX_INT_RBBM_ETS_MS_TIMEOUT     5
#define A5XX_INT_RBBM_ATB_ASYNC_OVERFLOW 6
#define A5XX_INT_RBBM_GPC_ERROR          7
#define A5XX_INT_CP_SW                   8
#define A5XX_INT_CP_HW_ERROR             9
#define A5XX_INT_CP_CCU_FLUSH_DEPTH_TS   10
#define A5XX_INT_CP_CCU_FLUSH_COLOR_TS   11
#define A5XX_INT_CP_CCU_RESOLVE_TS       12
#define A5XX_INT_CP_IB2                  13
#define A5XX_INT_CP_IB1                  14
#define A5XX_INT_CP_RB                   15
#define A5XX_INT_CP_UNUSED_1             16
#define A5XX_INT_CP_RB_DONE_TS           17
#define A5XX_INT_CP_WT_DONE_TS           18
#define A5XX_INT_UNKNOWN_1               19
#define A5XX_INT_CP_CACHE_FLUSH_TS       20
#define A5XX_INT_UNUSED_2                21
#define A5XX_INT_RBBM_ATB_BUS_OVERFLOW   22
#define A5XX_INT_MISC_HANG_DETECT        23

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:3119 [MATCH: timeout] ---
	 * BIT(26): Limit the number of wave-slots for Eviction buffer to 1 per ALU GRP
	 * BIT(30): Disable LPAC auto-promotion
	 */
	{ GEN8_SP_CHICKEN_BITS_1, BIT(26) | BIT(30), BIT(PIPE_NONE) },
	/*
	 * BIT(22): Disable PS out of order retire
	 * BIT(23): Enable half wave mode and MM instruction src&dst is half precision
	 */
	{ GEN8_SP_CHICKEN_BITS_2, BIT(22) | BIT(23), BIT(PIPE_NONE) },
	{ GEN8_SP_CHICKEN_BITS_3, 0x00300000, BIT(PIPE_NONE) },
	{ GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080,  BIT(PIPE_NONE) },
	{ GEN8_TPL1_DBG_ECO_CNTL, 0x10000000, BIT(PIPE_NONE) },
	/* Enable cubemap small miplevel optimization settings */
	/* BIT(26): Disable final clamp for bicubic filtering */
	{ GEN8_TPL1_DBG_ECO_CNTL1, 0x04000724, BIT(PIPE_NONE) },
	/* Disable tag bank id hashing */
	{ GEN8_UCHE_MODE_CNTL, 0x00080000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
	/* Limit gmem number of ways for GMEM requests in each set */
	{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE)},
	/* Disable write slow pointer in data phase queue */
	{ GEN8_UCHE_HW_DBG_CNTL, BIT(8), BIT(PIPE_NONE) },
	/* Configure UCHE to CCU switchthreshold timeout cycles */
	{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
	{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_LP_REQ_CNT, 0x00100020, BIT(PIPE_BR) | BIT(PIPE_BV) },

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:3131 [MATCH: timeout] ---
	/* Enable cubemap small miplevel optimization settings */
	/* BIT(26): Disable final clamp for bicubic filtering */
	{ GEN8_TPL1_DBG_ECO_CNTL1, 0x04000724, BIT(PIPE_NONE) },
	/* Disable tag bank id hashing */
	{ GEN8_UCHE_MODE_CNTL, 0x00080000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
	/* Limit gmem number of ways for GMEM requests in each set */
	{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE)},
	/* Disable write slow pointer in data phase queue */
	{ GEN8_UCHE_HW_DBG_CNTL, BIT(8), BIT(PIPE_NONE) },
	/* Configure UCHE to CCU switchthreshold timeout cycles */
	{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
	{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_LP_REQ_CNT, 0x00100020, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BR) | BIT(PIPE_BV) },
	/* Disable redundant tile data optimization */
	{ GEN8_VSC_KMD_DBG_ECO_CNTL, BIT(11), BIT(PIPE_NONE)},
	{ 0 },
};

/* GEN8_0_0 protected register list */
static const struct gen8_protected_regs gen8_0_0_protected_regs[] = {
	{ GEN8_CP_PROTECT_REG_GLOBAL + 0, 0x00000, 0x003a3, 0 },
	{ GEN8_CP_PROTECT_REG_GLOBAL + 1, 0x003b4, 0x0043f, 0 },
	{ GEN8_CP_PROTECT_REG_GLOBAL + 2, 0x00440, 0x0045f, 1 },
	{ GEN8_CP_PROTECT_REG_GLOBAL + 3, 0x00580, 0x005df, 0 },

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:3132 [MATCH: timeout] ---
	/* BIT(26): Disable final clamp for bicubic filtering */
	{ GEN8_TPL1_DBG_ECO_CNTL1, 0x04000724, BIT(PIPE_NONE) },
	/* Disable tag bank id hashing */
	{ GEN8_UCHE_MODE_CNTL, 0x00080000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
	/* Limit gmem number of ways for GMEM requests in each set */
	{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE)},
	/* Disable write slow pointer in data phase queue */
	{ GEN8_UCHE_HW_DBG_CNTL, BIT(8), BIT(PIPE_NONE) },
	/* Configure UCHE to CCU switchthreshold timeout cycles */
	{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
	{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_LP_REQ_CNT, 0x00100020, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BR) | BIT(PIPE_BV) },
	/* Disable redundant tile data optimization */
	{ GEN8_VSC_KMD_DBG_ECO_CNTL, BIT(11), BIT(PIPE_NONE)},
	{ 0 },
};

/* GEN8_0_0 protected register list */
static const struct gen8_protected_regs gen8_0_0_protected_regs[] = {
	{ GEN8_CP_PROTECT_REG_GLOBAL + 0, 0x00000, 0x003a3, 0 },
	{ GEN8_CP_PROTECT_REG_GLOBAL + 1, 0x003b4, 0x0043f, 0 },
	{ GEN8_CP_PROTECT_REG_GLOBAL + 2, 0x00440, 0x0045f, 1 },
	{ GEN8_CP_PROTECT_REG_GLOBAL + 3, 0x00580, 0x005df, 0 },
	{ GEN8_CP_PROTECT_REG_GLOBAL + 4, 0x005e0, 0x006ff, 1 },

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:3293 [MATCH: timeout] ---
	.gbif = gen8_0_0_gbif_cx_regs,
	.gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs),
	.hang_detect_cycles = 0xcfffff,
	.protected_regs = gen8_0_0_protected_regs,
	.nonctxt_regs = gen8_0_0_nonctxt_regs,
	.gmu_hub_clk_freq = 200000000,
	.gen8_snapshot_block_list = &gen8_0_0_snapshot_block_list,
	.fast_bus_hint = true,
	.bcl_data = 1,
	.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
	.noc_timeout_us = 3410, /* 3.41 msec */
	.ctxt_record_size = (13536 * SZ_1K),
	.preempt_level = 1,
	.cl_no_ft_timeout_ms = 6500,
	.therm_cfg = &therm_mit_cfg_8_0_0,
	.clx_tbl = &gen8_0_0_clx_table,
};

static const struct adreno_gen8_core adreno_gpu_core_gen8_0_1 = {
	.base = {
		DEFINE_ADRENO_REV(ADRENO_REV_GEN8_0_1,
				  UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
		.compatible = "qcom,adreno-gpu-gen8-0-1",
		.features = ADRENO_APRIV | ADRENO_IOCOHERENT |
			ADRENO_CONTENT_PROTECTION | ADRENO_LPAC | ADRENO_AQE |
			ADRENO_GMU_WARMBOOT | ADRENO_L3_VOTE | ADRENO_BCL |
			ADRENO_IFPC | ADRENO_HW_FENCE | ADRENO_PREEMPTION |
			ADRENO_ACD | ADRENO_CLX | ADRENO_GMU_THERMAL_MITIGATION |
			ADRENO_GMU_AB,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:3296 [MATCH: timeout] ---
	.protected_regs = gen8_0_0_protected_regs,
	.nonctxt_regs = gen8_0_0_nonctxt_regs,
	.gmu_hub_clk_freq = 200000000,
	.gen8_snapshot_block_list = &gen8_0_0_snapshot_block_list,
	.fast_bus_hint = true,
	.bcl_data = 1,
	.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
	.noc_timeout_us = 3410, /* 3.41 msec */
	.ctxt_record_size = (13536 * SZ_1K),
	.preempt_level = 1,
	.cl_no_ft_timeout_ms = 6500,
	.therm_cfg = &therm_mit_cfg_8_0_0,
	.clx_tbl = &gen8_0_0_clx_table,
};

static const struct adreno_gen8_core adreno_gpu_core_gen8_0_1 = {
	.base = {
		DEFINE_ADRENO_REV(ADRENO_REV_GEN8_0_1,
				  UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
		.compatible = "qcom,adreno-gpu-gen8-0-1",
		.features = ADRENO_APRIV | ADRENO_IOCOHERENT |
			ADRENO_CONTENT_PROTECTION | ADRENO_LPAC | ADRENO_AQE |
			ADRENO_GMU_WARMBOOT | ADRENO_L3_VOTE | ADRENO_BCL |
			ADRENO_IFPC | ADRENO_HW_FENCE | ADRENO_PREEMPTION |
			ADRENO_ACD | ADRENO_CLX | ADRENO_GMU_THERMAL_MITIGATION |
			ADRENO_GMU_AB,
		.features_standard = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_PREEMPTION |
			ADRENO_IFPC | ADRENO_AQE | ADRENO_CONTENT_PROTECTION,
		.gpudev = &adreno_gen8_hwsched_gpudev.base,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:3351 [MATCH: timeout] ---
	.gbif = gen8_0_0_gbif_cx_regs,
	.gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs),
	.hang_detect_cycles = 0xcfffff,
	.protected_regs = gen8_0_0_protected_regs,
	.nonctxt_regs = gen8_0_0_nonctxt_regs,
	.gmu_hub_clk_freq = 200000000,
	.gen8_snapshot_block_list = &gen8_0_0_snapshot_block_list,
	.fast_bus_hint = true,
	.bcl_data = 1,
	.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
	.noc_timeout_us = 3410, /* 3.41 msec */
	.ctxt_record_size = (13536 * SZ_1K),
	.preempt_level = 1,
	.cl_no_ft_timeout_ms = 6500,
	.therm_cfg = &therm_mit_cfg_8_0_0,
	.clx_tbl = &gen8_0_0_clx_table,
};

extern const struct gen8_snapshot_block_list gen8_2_0_snapshot_block_list;

static const struct hfi_clx_table_v2_cmd gen8_2_0_clx_table = {
	.version = (2 << 16) | 1,
	.domain = {
		/* GFX domain */
		{
			.data0 = CLX_DATA(60, 5, 1, 1),
			.clxt = 0,
			.clxh = 0,
			.urgmode = 1,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:3354 [MATCH: timeout] ---
	.protected_regs = gen8_0_0_protected_regs,
	.nonctxt_regs = gen8_0_0_nonctxt_regs,
	.gmu_hub_clk_freq = 200000000,
	.gen8_snapshot_block_list = &gen8_0_0_snapshot_block_list,
	.fast_bus_hint = true,
	.bcl_data = 1,
	.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
	.noc_timeout_us = 3410, /* 3.41 msec */
	.ctxt_record_size = (13536 * SZ_1K),
	.preempt_level = 1,
	.cl_no_ft_timeout_ms = 6500,
	.therm_cfg = &therm_mit_cfg_8_0_0,
	.clx_tbl = &gen8_0_0_clx_table,
};

extern const struct gen8_snapshot_block_list gen8_2_0_snapshot_block_list;

static const struct hfi_clx_table_v2_cmd gen8_2_0_clx_table = {
	.version = (2 << 16) | 1,
	.domain = {
		/* GFX domain */
		{
			.data0 = CLX_DATA(60, 5, 1, 1),
			.clxt = 0,
			.clxh = 0,
			.urgmode = 1,
			.lkgen = 0,
			.currbudget = 100,
		},

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:3557 [MATCH: timeout] ---
	/* Disable PS out of order retire */
	{ GEN8_SP_CHICKEN_BITS_2, 0xc20800, BIT(PIPE_NONE) },
	{ GEN8_SP_CHICKEN_BITS_3, 0x00300000, BIT(PIPE_NONE) },
	{ GEN8_SP_PERFCTR_SHADER_MASK, 0x0000003f, BIT(PIPE_NONE) },
	/* Ignore HLSQ shared constant feedback from SP */
	{ GEN8_SP_HLSQ_DBG_ECO_CNTL_1, BIT(17), BIT(PIPE_NONE) },
	/* Disable CS dead batch merge */
	{ GEN8_SP_HLSQ_DBG_ECO_CNTL_2, BIT(24), BIT(PIPE_NONE) },
	/* Disable HLSQ stproc stc_buf_mode */
	{ GEN8_SP_HLSQ_DBG_ECO_CNTL_3, BIT(7), BIT(PIPE_NONE) },
	{ GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080, BIT(PIPE_NONE) },
	{ GEN8_SP_READ_SEL, 0x0001ff00, BIT(PIPE_NONE) },
	/* Bit(20): Disable alphaOnly feature */
	{ GEN8_TPL1_DBG_ECO_CNTL, 0x10100000, BIT(PIPE_NONE) },
	/* BIT(26): Disable final clamp for bicubic filtering */
	{ GEN8_TPL1_DBG_ECO_CNTL1, 0x04000720, BIT(PIPE_NONE) },
	{ GEN8_UCHE_MODE_CNTL, 0x80080000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE) },
	{ GEN8_UCHE_GBIF_GX_CONFIG, 0x010240e0, BIT(PIPE_NONE) },
	{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
	{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_LP_REQ_CNT, 0x00000020, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ 0 },
};

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:3567 [MATCH: timeout] ---
	{ GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080, BIT(PIPE_NONE) },
	{ GEN8_SP_READ_SEL, 0x0001ff00, BIT(PIPE_NONE) },
	/* Bit(20): Disable alphaOnly feature */
	{ GEN8_TPL1_DBG_ECO_CNTL, 0x10100000, BIT(PIPE_NONE) },
	/* BIT(26): Disable final clamp for bicubic filtering */
	{ GEN8_TPL1_DBG_ECO_CNTL1, 0x04000720, BIT(PIPE_NONE) },
	{ GEN8_UCHE_MODE_CNTL, 0x80080000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE) },
	{ GEN8_UCHE_GBIF_GX_CONFIG, 0x010240e0, BIT(PIPE_NONE) },
	{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
	{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_LP_REQ_CNT, 0x00000020, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ 0 },
};

static const struct therm_tsens_en_cfg tsens_en_cfg_8_2_0 = {
	/* 3 GPU slices, each with 3 tsens bits */
	.tsens_sl_cnt = 3,
	/* GPU unslice with 2 tsens bits */
	.tsens_us_cnt = 2,
};

static struct gen8_thermal_mit_cfg therm_mit_cfg_8_2_0 = {
	.therm = &therm_profile_8_0_0,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:3648 [MATCH: timeout] ---
	.gbif = gen8_0_0_gbif_cx_regs,
	.gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs),
	.hang_detect_cycles = 0xcfffff,
	.protected_regs = gen8_2_0_protected_regs,
	.nonctxt_regs = gen8_2_0_nonctxt_regs,
	.gmu_hub_clk_freq = 150000000,
	.gen8_snapshot_block_list = &gen8_2_0_snapshot_block_list,
	.fast_bus_hint = true,
	.bcl_data = GEN8_2_X_BCL_DATA,
	.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
	.noc_timeout_us = 3410, /* 3.41 msec */
	.cl_no_ft_timeout_ms = 6500,
	.ctxt_record_size = (19708 * SZ_1K),
	.therm_cfg = &therm_mit_cfg_8_2_0,
	.limits_mit_cfg = &gen8_2_0_limits_mit_cfg,
	.preempt_level = 1,
	.clx_tbl = &gen8_2_0_clx_table,
};

static const struct adreno_gen8_core adreno_gpu_core_gen8_2_1 = {
	.base = {
		DEFINE_ADRENO_REV(ADRENO_REV_GEN8_2_1,
				  UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
		.compatible = "qcom,adreno-gpu-gen8-2-1",
		.features = ADRENO_APRIV | ADRENO_IOCOHERENT |
			ADRENO_PREEMPTION | ADRENO_LPAC | ADRENO_AQE |
			ADRENO_GMU_WARMBOOT | ADRENO_IFPC | ADRENO_CONTENT_PROTECTION |
			ADRENO_HW_FENCE | ADRENO_BCL | ADRENO_ACD | ADRENO_GMU_BASED_DCVS |
			ADRENO_GMU_THERMAL_MITIGATION | ADRENO_CLX | ADRENO_DEFER_GMEM_ALLOC |

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:3649 [MATCH: timeout] ---
	.gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs),
	.hang_detect_cycles = 0xcfffff,
	.protected_regs = gen8_2_0_protected_regs,
	.nonctxt_regs = gen8_2_0_nonctxt_regs,
	.gmu_hub_clk_freq = 150000000,
	.gen8_snapshot_block_list = &gen8_2_0_snapshot_block_list,
	.fast_bus_hint = true,
	.bcl_data = GEN8_2_X_BCL_DATA,
	.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
	.noc_timeout_us = 3410, /* 3.41 msec */
	.cl_no_ft_timeout_ms = 6500,
	.ctxt_record_size = (19708 * SZ_1K),
	.therm_cfg = &therm_mit_cfg_8_2_0,
	.limits_mit_cfg = &gen8_2_0_limits_mit_cfg,
	.preempt_level = 1,
	.clx_tbl = &gen8_2_0_clx_table,
};

static const struct adreno_gen8_core adreno_gpu_core_gen8_2_1 = {
	.base = {
		DEFINE_ADRENO_REV(ADRENO_REV_GEN8_2_1,
				  UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
		.compatible = "qcom,adreno-gpu-gen8-2-1",
		.features = ADRENO_APRIV | ADRENO_IOCOHERENT |
			ADRENO_PREEMPTION | ADRENO_LPAC | ADRENO_AQE |
			ADRENO_GMU_WARMBOOT | ADRENO_IFPC | ADRENO_CONTENT_PROTECTION |
			ADRENO_HW_FENCE | ADRENO_BCL | ADRENO_ACD | ADRENO_GMU_BASED_DCVS |
			ADRENO_GMU_THERMAL_MITIGATION | ADRENO_CLX | ADRENO_DEFER_GMEM_ALLOC |
			ADRENO_GMU_MINBW | ADRENO_DCVS_PROFILE | ADRENO_TSENSE_DYNAMIC_PERIOD |

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:3706 [MATCH: timeout] ---
	.gbif = gen8_0_0_gbif_cx_regs,
	.gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs),
	.hang_detect_cycles = 0xcfffff,
	.protected_regs = gen8_2_0_protected_regs,
	.nonctxt_regs = gen8_2_0_nonctxt_regs,
	.gmu_hub_clk_freq = 150000000,
	.gen8_snapshot_block_list = &gen8_2_0_snapshot_block_list,
	.fast_bus_hint = true,
	.bcl_data = GEN8_2_X_BCL_DATA,
	.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
	.noc_timeout_us = 3410, /* 3.41 msec */
	.cl_no_ft_timeout_ms = 6500,
	.ctxt_record_size = (19708 * SZ_1K),
	.therm_cfg = &therm_mit_cfg_8_2_0,
	.limits_mit_cfg = &gen8_2_0_limits_mit_cfg,
	.preempt_level = 1,
	.clx_tbl = &gen8_2_0_clx_table,
};

static const struct gen8_nonctxt_regs gen8_1_0_nonctxt_regs[] = {
	{ GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) },
	{ GEN8_GRAS_DBG_ECO_CNTL, 0x00000800, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_GRAS_TSEFE_DBG_ECO_CNTL, 0x00200000, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_PC_CONTEXT_SWITCH_STABILIZE_CNTL_1, 0x00000002, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_PC_CHICKEN_BITS_1, 0x00000003, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_PC_CHICKEN_BITS_2, 0x00000200, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_PC_CHICKEN_BITS_3, 0x00500000, BIT(PIPE_BV) | BIT(PIPE_BR) },

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:3707 [MATCH: timeout] ---
	.gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs),
	.hang_detect_cycles = 0xcfffff,
	.protected_regs = gen8_2_0_protected_regs,
	.nonctxt_regs = gen8_2_0_nonctxt_regs,
	.gmu_hub_clk_freq = 150000000,
	.gen8_snapshot_block_list = &gen8_2_0_snapshot_block_list,
	.fast_bus_hint = true,
	.bcl_data = GEN8_2_X_BCL_DATA,
	.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
	.noc_timeout_us = 3410, /* 3.41 msec */
	.cl_no_ft_timeout_ms = 6500,
	.ctxt_record_size = (19708 * SZ_1K),
	.therm_cfg = &therm_mit_cfg_8_2_0,
	.limits_mit_cfg = &gen8_2_0_limits_mit_cfg,
	.preempt_level = 1,
	.clx_tbl = &gen8_2_0_clx_table,
};

static const struct gen8_nonctxt_regs gen8_1_0_nonctxt_regs[] = {
	{ GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) },
	{ GEN8_GRAS_DBG_ECO_CNTL, 0x00000800, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_GRAS_TSEFE_DBG_ECO_CNTL, 0x00200000, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_PC_CONTEXT_SWITCH_STABILIZE_CNTL_1, 0x00000002, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_PC_CHICKEN_BITS_1, 0x00000003, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_PC_CHICKEN_BITS_2, 0x00000200, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_PC_CHICKEN_BITS_3, 0x00500000, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_PC_CHICKEN_BITS_4, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) },

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:3741 [MATCH: timeout] ---
	{ GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL, 0x00000030, BIT(PIPE_NONE) },
	{ GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL2, 0x00000030, BIT(PIPE_NONE) },
	{ GEN8_RBBM_INTERFACE_HANG_INT_CNTL, 0x0fffffff, BIT(PIPE_NONE) },
	{ GEN8_RBBM_GBIF_CLIENT_QOS_CNTL, 0x22122212, BIT(PIPE_NONE) },
	{ GEN8_RBBM_CGC_P2S_CNTL, 0x00000040, BIT(PIPE_NONE) },
	{ GEN8_SP_CHICKEN_BITS_2, 0x00820800, BIT(PIPE_NONE) },
	{ GEN8_SP_CHICKEN_BITS_3, 0x00300000, BIT(PIPE_NONE) },
	{ GEN8_SP_PERFCTR_SHADER_MASK, 0x0000003f, BIT(PIPE_NONE) },
	/* Disable CS dead batch merge */
	{ GEN8_SP_HLSQ_DBG_ECO_CNTL_2, BIT(31), BIT(PIPE_NONE) },
	{ GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080, BIT(PIPE_NONE) },
	{ GEN8_SP_READ_SEL, 0x0001ff00, BIT(PIPE_NONE) },
	{ GEN8_TPL1_DBG_ECO_CNTL, 0x10000000, BIT(PIPE_NONE) },
	/* BIT(26): Disable final clamp for bicubic filtering */
	{ GEN8_TPL1_DBG_ECO_CNTL1, 0x04000720, BIT(PIPE_NONE) },
	{ GEN8_UCHE_MODE_CNTL, 0x80080000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE) },
	{ GEN8_UCHE_GBIF_GX_CONFIG, 0x010240e0, BIT(PIPE_NONE) },
	{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
	{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_LP_REQ_CNT, 0x00000020, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ 0 },
};


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:3750 [MATCH: timeout] ---
	{ GEN8_SP_HLSQ_DBG_ECO_CNTL_2, BIT(31), BIT(PIPE_NONE) },
	{ GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080, BIT(PIPE_NONE) },
	{ GEN8_SP_READ_SEL, 0x0001ff00, BIT(PIPE_NONE) },
	{ GEN8_TPL1_DBG_ECO_CNTL, 0x10000000, BIT(PIPE_NONE) },
	/* BIT(26): Disable final clamp for bicubic filtering */
	{ GEN8_TPL1_DBG_ECO_CNTL1, 0x04000720, BIT(PIPE_NONE) },
	{ GEN8_UCHE_MODE_CNTL, 0x80080000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE) },
	{ GEN8_UCHE_GBIF_GX_CONFIG, 0x010240e0, BIT(PIPE_NONE) },
	{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
	{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_LP_REQ_CNT, 0x00000020, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ 0 },
};

static const struct gen8_protected_regs gen8_1_0_protected_regs[] = {
	{ GEN8_CP_PROTECT_REG_GLOBAL + 0, 0x00008, 0x003a3, 0 },
	{ GEN8_CP_PROTECT_REG_GLOBAL + 1, 0x003b4, 0x0043f, 0 },
	{ GEN8_CP_PROTECT_REG_GLOBAL + 2, 0x00440, 0x0045f, 1 },
	{ GEN8_CP_PROTECT_REG_GLOBAL + 3, 0x00580, 0x005df, 0 },
	{ GEN8_CP_PROTECT_REG_GLOBAL + 4, 0x005e0, 0x006ff, 1 },
	{ GEN8_CP_PROTECT_REG_GLOBAL + 5, 0x0074a, 0x0074f, 0 },
	{ GEN8_CP_PROTECT_REG_GLOBAL + 6, 0x00759, 0x0077f, 0 },
	{ GEN8_CP_PROTECT_REG_GLOBAL + 7, 0x00789, 0x00789, 0 },

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:3865 [MATCH: timeout] ---
	.ao_hwcg_count = ARRAY_SIZE(gen8_1_0_ao_hwcg_regs),
	.gbif = gen8_0_0_gbif_cx_regs,
	.gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs),
	.hang_detect_cycles = 0xcfffff,
	.protected_regs = gen8_1_0_protected_regs,
	.nonctxt_regs = gen8_1_0_nonctxt_regs,
	.gmu_hub_clk_freq = 200000000,
	.gen8_snapshot_block_list = &gen8_1_0_snapshot_block_list,
	.fast_bus_hint = true,
	.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
	.noc_timeout_us = 3410, /* 3.41 msec */
	.ctxt_record_size = (23088 * SZ_1K),
	.preempt_level = 1,
};

static const struct adreno_gen8_core adreno_gpu_core_gen8_5_0 = {
	.base = {
		DEFINE_ADRENO_REV(ADRENO_REV_GEN8_5_0,
				  UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
		.compatible = "qcom,adreno-gpu-gen8-5-0",
		.features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_PREEMPTION |
			ADRENO_LPAC | ADRENO_AQE | ADRENO_GMU_WARMBOOT | ADRENO_IFPC |
			ADRENO_CONTENT_PROTECTION | ADRENO_HW_FENCE | ADRENO_BCL |
			ADRENO_GMU_AB | ADRENO_GMU_BASED_DCVS | ADRENO_GMU_THERMAL_MITIGATION |
			ADRENO_DEFER_GMEM_ALLOC | ADRENO_GMU_MINBW |
			ADRENO_TSENSE_DYNAMIC_PERIOD | ADRENO_DCVS_PROFILE,
		.gpudev = &adreno_gen8_hwsched_gpudev.base,
		.perfcounters = &adreno_gen8_2_x_perfcounters,
		.uche_gmem_alignment = SZ_64M,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:3906 [MATCH: timeout] ---
	.gbif = gen8_0_0_gbif_cx_regs,
	.gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs),
	.hang_detect_cycles = 0xcfffff,
	.protected_regs = gen8_2_0_protected_regs,
	.nonctxt_regs = gen8_2_0_nonctxt_regs,
	.gmu_hub_clk_freq = 150000000,
	.gen8_snapshot_block_list = &gen8_2_0_snapshot_block_list,
	.fast_bus_hint = true,
	.bcl_data = GEN8_2_X_BCL_DATA,
	.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
	.noc_timeout_us = 3410, /* 3.41 msec */
	.cl_no_ft_timeout_ms = 6500,
	.ctxt_record_size = (19708 * SZ_1K),
	.therm_cfg = &therm_mit_cfg_8_2_0,
	.limits_mit_cfg = &gen8_2_0_limits_mit_cfg,
	.preempt_level = 1,
	.clx_tbl = &gen8_2_0_clx_table,
};

/* GEN8_4_0 noncontext register list */
static const struct gen8_nonctxt_regs gen8_4_0_nonctxt_regs[] = {
	{ GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) },
	{ GEN8_GRAS_DBG_ECO_CNTL, 0x00000800, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_PC_CONTEXT_SWITCH_STABILIZE_CNTL_1, 0x00000002, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_PC_CHICKEN_BITS_1, 0x00000003, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_PC_CHICKEN_BITS_2, 0x00000200, BIT(PIPE_BR) | BIT(PIPE_BV) },
	/* Disable BR throttling */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:3907 [MATCH: timeout] ---
	.gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs),
	.hang_detect_cycles = 0xcfffff,
	.protected_regs = gen8_2_0_protected_regs,
	.nonctxt_regs = gen8_2_0_nonctxt_regs,
	.gmu_hub_clk_freq = 150000000,
	.gen8_snapshot_block_list = &gen8_2_0_snapshot_block_list,
	.fast_bus_hint = true,
	.bcl_data = GEN8_2_X_BCL_DATA,
	.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
	.noc_timeout_us = 3410, /* 3.41 msec */
	.cl_no_ft_timeout_ms = 6500,
	.ctxt_record_size = (19708 * SZ_1K),
	.therm_cfg = &therm_mit_cfg_8_2_0,
	.limits_mit_cfg = &gen8_2_0_limits_mit_cfg,
	.preempt_level = 1,
	.clx_tbl = &gen8_2_0_clx_table,
};

/* GEN8_4_0 noncontext register list */
static const struct gen8_nonctxt_regs gen8_4_0_nonctxt_regs[] = {
	{ GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) },
	{ GEN8_GRAS_DBG_ECO_CNTL, 0x00000800, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_PC_CONTEXT_SWITCH_STABILIZE_CNTL_1, 0x00000002, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_PC_CHICKEN_BITS_1, 0x00000003, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_PC_CHICKEN_BITS_2, 0x00000200, BIT(PIPE_BR) | BIT(PIPE_BV) },
	/* Disable BR throttling */
	{ GEN8_PC_CHICKEN_BITS_3, 0x00400000, BIT(PIPE_BR) | BIT(PIPE_BV) },

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:3955 [MATCH: timeout] ---
	 * BIT(26): Limit the number of wave-slots for Eviction buffer to 1 per ALU GRP
	 * BIT(30): Disable LPAC auto-promotion
	 */
	{ GEN8_SP_CHICKEN_BITS_1, BIT(26) | BIT(30), BIT(PIPE_NONE) },
	/*
	 * BIT(22): Disable PS out of order retire
	 * BIT(23): Enable half wave mode and MM instruction src&dst is half precision
	 */
	{ GEN8_SP_CHICKEN_BITS_2, BIT(22) | BIT(23), BIT(PIPE_NONE) },
	{ GEN8_SP_CHICKEN_BITS_3, 0x00300000, BIT(PIPE_NONE) },
	{ GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080,  BIT(PIPE_NONE) },
	{ GEN8_TPL1_DBG_ECO_CNTL, 0x10000000, BIT(PIPE_NONE) },
	/* Enable cubemap small miplevel optimization settings */
	/* BIT(26): Disable final clamp for bicubic filtering */
	{ GEN8_TPL1_DBG_ECO_CNTL1, 0x04000724, BIT(PIPE_NONE) },
	/* Disable tag bank id hashing */
	{ GEN8_UCHE_MODE_CNTL, 0x00080000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
	/* Limit gmem number of ways for GMEM requests in each set */
	{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE)},
	/* Disable write slow pointer in data phase queue */
	{ GEN8_UCHE_HW_DBG_CNTL, BIT(8), BIT(PIPE_NONE) },
	/* Configure UCHE to CCU switchthreshold timeout cycles */
	{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
	{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_LP_REQ_CNT, 0x00100020, BIT(PIPE_BR) | BIT(PIPE_BV) },

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:3967 [MATCH: timeout] ---
	/* Enable cubemap small miplevel optimization settings */
	/* BIT(26): Disable final clamp for bicubic filtering */
	{ GEN8_TPL1_DBG_ECO_CNTL1, 0x04000724, BIT(PIPE_NONE) },
	/* Disable tag bank id hashing */
	{ GEN8_UCHE_MODE_CNTL, 0x00080000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
	/* Limit gmem number of ways for GMEM requests in each set */
	{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE)},
	/* Disable write slow pointer in data phase queue */
	{ GEN8_UCHE_HW_DBG_CNTL, BIT(8), BIT(PIPE_NONE) },
	/* Configure UCHE to CCU switchthreshold timeout cycles */
	{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
	{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_LP_REQ_CNT, 0x00100020, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BR) | BIT(PIPE_BV) },
	/* Disable redundant tile data optimization */
	{ GEN8_VSC_KMD_DBG_ECO_CNTL, BIT(11), BIT(PIPE_NONE)},
	{ 0 },
};

static const u32 gen8_4_0_gbif_client_qos_values[KGSL_PRIORITY_MAX_RB_LEVELS] = {
	0x33233323,
};

static const struct adreno_gen8_core adreno_gpu_core_gen8_4_0 = {
	.base = {

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:3968 [MATCH: timeout] ---
	/* BIT(26): Disable final clamp for bicubic filtering */
	{ GEN8_TPL1_DBG_ECO_CNTL1, 0x04000724, BIT(PIPE_NONE) },
	/* Disable tag bank id hashing */
	{ GEN8_UCHE_MODE_CNTL, 0x00080000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
	/* Limit gmem number of ways for GMEM requests in each set */
	{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE)},
	/* Disable write slow pointer in data phase queue */
	{ GEN8_UCHE_HW_DBG_CNTL, BIT(8), BIT(PIPE_NONE) },
	/* Configure UCHE to CCU switchthreshold timeout cycles */
	{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
	{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_LP_REQ_CNT, 0x00100020, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BR) | BIT(PIPE_BV) },
	/* Disable redundant tile data optimization */
	{ GEN8_VSC_KMD_DBG_ECO_CNTL, BIT(11), BIT(PIPE_NONE)},
	{ 0 },
};

static const u32 gen8_4_0_gbif_client_qos_values[KGSL_PRIORITY_MAX_RB_LEVELS] = {
	0x33233323,
};

static const struct adreno_gen8_core adreno_gpu_core_gen8_4_0 = {
	.base = {
		DEFINE_ADRENO_REV(ADRENO_REV_GEN8_4_0,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:4021 [MATCH: timeout] ---
	.hang_detect_cycles = 0xcfffff,
	.protected_regs = gen8_0_0_protected_regs,
	.nonctxt_regs = gen8_4_0_nonctxt_regs,
	.gmu_hub_clk_freq = 200000000,
	.gen8_snapshot_block_list = &gen8_0_0_snapshot_block_list,
	.qos_value = gen8_4_0_gbif_client_qos_values,
	.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
	.bcl_data = 1,
	.preempt_level = 1,
	.ctxt_record_size = (13536 * SZ_1K),
	.noc_timeout_us = 3410, /* 3.41 msec */
	.cl_no_ft_timeout_ms = 10000,
};

extern const struct gen8_snapshot_block_list gen8_3_0_snapshot_block_list;

static const struct kgsl_regmap_list gen8_3_0_gbif_cx_regs[] = {
	{ GEN8_GBIF_QSB_SIDE0, 0x00071e20 },
	{ GEN8_GBIF_QSB_SIDE1, 0x00071e20 },
	{ GEN8_GBIF_QSB_SIDE2, 0x00071e20 },
	{ GEN8_GBIF_QSB_SIDE3, 0x00071e20 },
	{ GEN8_GBIF_CX_CONFIG, 0x20023000 },
};

static const struct kgsl_regmap_list gen8_8_0_gbif_cx_regs[] = {
	{ GEN8_GBIF_QSB_SIDE0, 0x00071e20 },
	{ GEN8_GBIF_QSB_SIDE1, 0x00071e20 },
	{ GEN8_GBIF_QSB_SIDE2, 0x00071e20 },
	{ GEN8_GBIF_QSB_SIDE3, 0x00071e20 },

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:4022 [MATCH: timeout] ---
	.protected_regs = gen8_0_0_protected_regs,
	.nonctxt_regs = gen8_4_0_nonctxt_regs,
	.gmu_hub_clk_freq = 200000000,
	.gen8_snapshot_block_list = &gen8_0_0_snapshot_block_list,
	.qos_value = gen8_4_0_gbif_client_qos_values,
	.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
	.bcl_data = 1,
	.preempt_level = 1,
	.ctxt_record_size = (13536 * SZ_1K),
	.noc_timeout_us = 3410, /* 3.41 msec */
	.cl_no_ft_timeout_ms = 10000,
};

extern const struct gen8_snapshot_block_list gen8_3_0_snapshot_block_list;

static const struct kgsl_regmap_list gen8_3_0_gbif_cx_regs[] = {
	{ GEN8_GBIF_QSB_SIDE0, 0x00071e20 },
	{ GEN8_GBIF_QSB_SIDE1, 0x00071e20 },
	{ GEN8_GBIF_QSB_SIDE2, 0x00071e20 },
	{ GEN8_GBIF_QSB_SIDE3, 0x00071e20 },
	{ GEN8_GBIF_CX_CONFIG, 0x20023000 },
};

static const struct kgsl_regmap_list gen8_8_0_gbif_cx_regs[] = {
	{ GEN8_GBIF_QSB_SIDE0, 0x00071e20 },
	{ GEN8_GBIF_QSB_SIDE1, 0x00071e20 },
	{ GEN8_GBIF_QSB_SIDE2, 0x00071e20 },
	{ GEN8_GBIF_QSB_SIDE3, 0x00071e20 },
	{ GEN8_GBIF_CX_CONFIG, 0x40023000 },

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:4068 [MATCH: timeout] ---
	{ GEN8_RBBM_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) },
	{ GEN8_RBBM_SLICE_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) },
	{ GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL, 0x00000030, BIT(PIPE_NONE) },
	{ GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL2, 0x00000030, BIT(PIPE_NONE) },
	{ GEN8_UCHE_GBIF_GX_CONFIG, 0x010240e0, BIT(PIPE_NONE) },
	{ GEN8_RBBM_GBIF_CLIENT_QOS_CNTL, 0x22122212, BIT(PIPE_NONE) },
	{ GEN8_RBBM_CGC_P2S_CNTL, 0x00000040, BIT(PIPE_NONE) },
	{ GEN8_SP_CHICKEN_BITS_2, BIT(22) | BIT(23), BIT(PIPE_NONE) },
	{ GEN8_SP_CHICKEN_BITS_3, 0x00300000, BIT(PIPE_NONE) },
	{ GEN8_SP_PERFCTR_SHADER_MASK, 0x0000003f, BIT(PIPE_NONE) },
	{ GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080, BIT(PIPE_NONE) },
	{ GEN8_TPL1_DBG_ECO_CNTL, 0x10000000, BIT(PIPE_NONE) },
	/* BIT(26): Disable final clamp for bicubic filtering */
	{ GEN8_TPL1_DBG_ECO_CNTL1, 0x04000724, BIT(PIPE_NONE) },
	{ GEN8_UCHE_MODE_CNTL, 0x00020000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE) },
	/* Disable write slow pointer in data phase queue */
	{ GEN8_UCHE_HW_DBG_CNTL, BIT(8), BIT(PIPE_NONE) },
	{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
	{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_LP_REQ_CNT, 0x00100020, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_RB_GC_GMEM_PROTECT, 0x00900000, BIT(PIPE_BR) },
	{ 0 },
};

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:4077 [MATCH: timeout] ---
	{ GEN8_SP_PERFCTR_SHADER_MASK, 0x0000003f, BIT(PIPE_NONE) },
	{ GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080, BIT(PIPE_NONE) },
	{ GEN8_TPL1_DBG_ECO_CNTL, 0x10000000, BIT(PIPE_NONE) },
	/* BIT(26): Disable final clamp for bicubic filtering */
	{ GEN8_TPL1_DBG_ECO_CNTL1, 0x04000724, BIT(PIPE_NONE) },
	{ GEN8_UCHE_MODE_CNTL, 0x00020000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE) },
	/* Disable write slow pointer in data phase queue */
	{ GEN8_UCHE_HW_DBG_CNTL, BIT(8), BIT(PIPE_NONE) },
	{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
	{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_LP_REQ_CNT, 0x00100020, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_RB_GC_GMEM_PROTECT, 0x00900000, BIT(PIPE_BR) },
	{ 0 },
};

static const struct adreno_gen8_core adreno_gpu_core_gen8_3_0 = {
	.base = {
		DEFINE_ADRENO_REV(ADRENO_REV_GEN8_3_0,
				  UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
		.compatible = "qcom,adreno-gpu-gen8-3-0",
		.features = ADRENO_APRIV | ADRENO_IOCOHERENT |
			ADRENO_CONTENT_PROTECTION | ADRENO_IFPC | ADRENO_PREEMPTION |
			ADRENO_GMU_AB,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:4160 [MATCH: timeout] ---
	 * BIT(26): Limit the number of wave-slots for Eviction buffer to 1 per ALU GRP
	 * BIT(30): Disable LPAC auto-promotion
	 */
	{ GEN8_SP_CHICKEN_BITS_1, BIT(26) | BIT(30), BIT(PIPE_NONE) },
	/*
	 * BIT(22): Disable PS out of order retire
	 * BIT(23): Enable half wave mode and MM instruction src&dst is half precision
	 */
	{ GEN8_SP_CHICKEN_BITS_2, BIT(22) | BIT(23), BIT(PIPE_NONE) },
	{ GEN8_SP_CHICKEN_BITS_3, 0x00300000, BIT(PIPE_NONE) },
	{ GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080,  BIT(PIPE_NONE) },
	{ GEN8_TPL1_DBG_ECO_CNTL, 0x10000000, BIT(PIPE_NONE) },
	/* Enable cubemap small miplevel optimization settings */
	/* BIT(26): Disable final clamp for bicubic filtering */
	{ GEN8_TPL1_DBG_ECO_CNTL1, 0x04000724, BIT(PIPE_NONE) },
	/* Disable tag bank id hashing */
	{ GEN8_UCHE_MODE_CNTL, 0x00080000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
	/* Limit gmem number of ways for GMEM requests in each set */
	{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE)},
	/* Disable write slow pointer in data phase queue */
	{ GEN8_UCHE_HW_DBG_CNTL, BIT(8), BIT(PIPE_NONE) },
	/* Configure UCHE to CCU switchthreshold timeout cycles */
	{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
	{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_LP_REQ_CNT, 0x00000020, BIT(PIPE_BR) | BIT(PIPE_BV) },

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:4172 [MATCH: timeout] ---
	/* Enable cubemap small miplevel optimization settings */
	/* BIT(26): Disable final clamp for bicubic filtering */
	{ GEN8_TPL1_DBG_ECO_CNTL1, 0x04000724, BIT(PIPE_NONE) },
	/* Disable tag bank id hashing */
	{ GEN8_UCHE_MODE_CNTL, 0x00080000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
	/* Limit gmem number of ways for GMEM requests in each set */
	{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE)},
	/* Disable write slow pointer in data phase queue */
	{ GEN8_UCHE_HW_DBG_CNTL, BIT(8), BIT(PIPE_NONE) },
	/* Configure UCHE to CCU switchthreshold timeout cycles */
	{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
	{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_LP_REQ_CNT, 0x00000020, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BR) | BIT(PIPE_BV) },
	/* Disable redundant tile data optimization */
	{ GEN8_VSC_KMD_DBG_ECO_CNTL, BIT(11), BIT(PIPE_NONE)},
	{ 0 },
};

extern const struct gen8_snapshot_block_list gen8_6_0_snapshot_block_list;

static const struct adreno_gen8_core adreno_gpu_core_gen8_6_0 = {
	.base = {
		DEFINE_ADRENO_REV(ADRENO_REV_GEN8_6_0,
				  UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:4173 [MATCH: timeout] ---
	/* BIT(26): Disable final clamp for bicubic filtering */
	{ GEN8_TPL1_DBG_ECO_CNTL1, 0x04000724, BIT(PIPE_NONE) },
	/* Disable tag bank id hashing */
	{ GEN8_UCHE_MODE_CNTL, 0x00080000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
	/* Limit gmem number of ways for GMEM requests in each set */
	{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE)},
	/* Disable write slow pointer in data phase queue */
	{ GEN8_UCHE_HW_DBG_CNTL, BIT(8), BIT(PIPE_NONE) },
	/* Configure UCHE to CCU switchthreshold timeout cycles */
	{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
	{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_LP_REQ_CNT, 0x00000020, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BR) | BIT(PIPE_BV) },
	/* Disable redundant tile data optimization */
	{ GEN8_VSC_KMD_DBG_ECO_CNTL, BIT(11), BIT(PIPE_NONE)},
	{ 0 },
};

extern const struct gen8_snapshot_block_list gen8_6_0_snapshot_block_list;

static const struct adreno_gen8_core adreno_gpu_core_gen8_6_0 = {
	.base = {
		DEFINE_ADRENO_REV(ADRENO_REV_GEN8_6_0,
				  UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
		.compatible = "qcom,adreno-gpu-gen8-6-0",

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:4218 [MATCH: timeout] ---
	.zap_name = "gen80000_zap.mbn",
	.ao_hwcg = gen8_ao_hwcg_regs,
	.ao_hwcg_count = ARRAY_SIZE(gen8_ao_hwcg_regs),
	.gbif = gen8_3_0_gbif_cx_regs,
	.gbif_count = ARRAY_SIZE(gen8_3_0_gbif_cx_regs),
	.hang_detect_cycles = 0xcfffff,
	.protected_regs = gen8_0_0_protected_regs,
	.nonctxt_regs = gen8_6_0_nonctxt_regs,
	.gmu_hub_clk_freq = 200000000,
	.gen8_snapshot_block_list = &gen8_6_0_snapshot_block_list,
	.noc_timeout_us = 6800, /* 6.8 msec */
	.ctxt_record_size = (3372 * SZ_1K),
	.preempt_level = 1,
	.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
	.bcl_data = 1,
};

static const struct adreno_gen8_core adreno_gpu_core_gen8_8_0 = {
	.base = {
		DEFINE_ADRENO_REV(ADRENO_REV_GEN8_8_0,
				  UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
		.compatible = "qcom,adreno-gpu-gen8-8-0",
		.features = ADRENO_APRIV | ADRENO_IOCOHERENT |
			ADRENO_CONTENT_PROTECTION | ADRENO_IFPC | ADRENO_PREEMPTION |
			ADRENO_HW_FENCE | ADRENO_BCL | ADRENO_GMU_AB,
		.gpudev = &adreno_gen8_hwsched_gpudev.base,
		.perfcounters = &adreno_gen8_perfcounters,
		.uche_gmem_alignment = SZ_64M,
		.gmem_size = (SZ_512K + SZ_64K),

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:4256 [MATCH: timeout] ---
	.ao_hwcg_count = ARRAY_SIZE(gen8_ao_hwcg_regs),
	.gbif = gen8_8_0_gbif_cx_regs,
	.gbif_count = ARRAY_SIZE(gen8_8_0_gbif_cx_regs),
	.hang_detect_cycles = 0xcfffff,
	.protected_regs = gen8_0_0_protected_regs, /* Reuse the protected regs list from Gen8_0_0 */
	.nonctxt_regs = gen8_3_0_nonctxt_regs,
	.gmu_hub_clk_freq = 200000000,
	.gen8_snapshot_block_list = &gen8_3_0_snapshot_block_list,
	.ctxt_record_size = (4558 * SZ_1K),
	.preempt_level = 1,
	.noc_timeout_us = 3410, /* 3.41 msec */
	.bcl_data = 1,
};

/* GEN8_9_0 noncontext register list */
static const struct gen8_nonctxt_regs gen8_9_0_nonctxt_regs[] = {
	{ GEN8_RBBM_GBIF_CLIENT_QOS_CNTL, 0x22122212, BIT(PIPE_NONE) },
	{ GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL, 0x00000030, BIT(PIPE_NONE) },
	{ GEN8_RBBM_WAIT_IDLE_CLOCKS_CNTL2, 0x00000030, BIT(PIPE_NONE) },
	/* Disable Dead Draw Merge scheme on RB-HLSQ */
	{ GEN8_RB_RBP_CNTL, BIT(5), BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_RBBM_INTERFACE_HANG_INT_CNTL, 0x0fffffff, BIT(PIPE_NONE) },
	{ GEN8_RBBM_POWER_UP_RESET_SW_OVERRIDE, 0x70809060, BIT(PIPE_NONE) },
	{ GEN8_RBBM_POWER_UP_RESET_SW_BV_OVERRIDE, 0x30000000, BIT(PIPE_NONE) },
	{ GEN8_RBBM_CGC_P2S_CNTL, 0x00000040, BIT(PIPE_NONE) },
	/* Disable mode_switch optimization in UMAS */
	{ GEN8_SP_CHICKEN_BITS, BIT(26), BIT(PIPE_NONE) },
	/* Disable LPAC large-LM mode */
	{ GEN8_SP_SS_CHICKEN_BITS_0, BIT(3), BIT(PIPE_NONE) },

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:4281 [MATCH: timeout] ---
	/* Disable mode_switch optimization in UMAS */
	{ GEN8_SP_CHICKEN_BITS, BIT(26), BIT(PIPE_NONE) },
	/* Disable LPAC large-LM mode */
	{ GEN8_SP_SS_CHICKEN_BITS_0, BIT(3), BIT(PIPE_NONE) },
	/* Disable PS out of order retire */
	{ GEN8_SP_CHICKEN_BITS_2, 0xc21800, BIT(PIPE_NONE) },
	{ GEN8_RBBM_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) },
	{ GEN8_RBBM_SLICE_NC_MODE_CNTL, 0x00000001, BIT(PIPE_NONE) },
	{ GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) },
	{ GEN8_UCHE_MODE_CNTL, 0x80080000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
	{ GEN8_UCHE_GBIF_GX_CONFIG, 0x010240e0, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE) },
	{ GEN8_GRAS_TSEFE_DBG_ECO_CNTL, 0x00200000, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_GRAS_DBG_ECO_CNTL, 0x00000800, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_RB_CCU_CNTL, 0x00000068, BIT(PIPE_BR) },
	{ GEN8_RB_CCU_DBG_ECO_CNTL, 0x00002200, BIT(PIPE_BR) },
	{ GEN8_RB_GC_GMEM_PROTECT, 0x02600000, BIT(PIPE_BR) },
	{ GEN8_RB_RESOLVE_PREFETCH_CNTL, 0x00000007, BIT(PIPE_BR) },
	{ GEN8_RB_CMP_DBG_ECO_CNTL, 0x00004000, BIT(PIPE_BR) },
	{ GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_PC_CHICKEN_BITS_3, 0x00500000, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_PC_CHICKEN_BITS_4, 0x00500050, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_PC_CHICKEN_BITS_1, 0x00000003, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_PC_CONTEXT_SWITCH_STABILIZE_CNTL_1, 0x00000002, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_PC_CHICKEN_BITS_2, 0x00000200, BIT(PIPE_BR) | BIT(PIPE_BV) },

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:4311 [MATCH: timeout] ---
	{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_VFD_CB_LP_REQ_CNT, 0x00000020, BIT(PIPE_BR) | BIT(PIPE_BV) },
	{ GEN8_SP_CHICKEN_BITS_3, 0x00300000, BIT(PIPE_NONE) },
	{ GEN8_SP_PERFCTR_SHADER_MASK, 0x0000003f, BIT(PIPE_NONE) },
	/* Ignore HLSQ shared constant feedback from SP */
	{ GEN8_SP_HLSQ_DBG_ECO_CNTL_1, BIT(17), BIT(PIPE_NONE) },
	/* Disable CS dead batch merge */
	{ GEN8_SP_HLSQ_DBG_ECO_CNTL_2, BIT(24), BIT(PIPE_NONE) },
	{ GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080, BIT(PIPE_NONE) },
	{ GEN8_SP_READ_SEL, 0x0001ff00, BIT(PIPE_NONE) },
	{ GEN8_TPL1_DBG_ECO_CNTL, 0x10100000, BIT(PIPE_NONE) },
	{ GEN8_TPL1_DBG_ECO_CNTL1, 0x04000720, BIT(PIPE_NONE) },
	{ 0 },
};

extern const struct gen8_snapshot_block_list gen8_9_0_snapshot_block_list;

static const struct adreno_gen8_core adreno_gpu_core_gen8_9_0 = {
	.base = {
		DEFINE_ADRENO_REV(ADRENO_REV_GEN8_9_0,
				  UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
		.compatible = "qcom,adreno-gpu-gen8-9-0",
		.features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_LPAC |
			ADRENO_GMU_WARMBOOT | ADRENO_AQE | ADRENO_IFPC |
			ADRENO_CONTENT_PROTECTION | ADRENO_GMU_BASED_DCVS |
			ADRENO_DEFER_GMEM_ALLOC | ADRENO_PREEMPTION | ADRENO_GMU_AB |
			ADRENO_GMU_THERMAL_MITIGATION | ADRENO_HW_FENCE |

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:4356 [MATCH: timeout] ---
	.ao_hwcg_count = ARRAY_SIZE(gen8_2_0_ao_hwcg_regs),
	.gbif = gen8_0_0_gbif_cx_regs,
	.gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs),
	.hang_detect_cycles = 0xcfffff,
	.protected_regs = gen8_2_0_protected_regs,
	.nonctxt_regs = gen8_9_0_nonctxt_regs,
	.gmu_hub_clk_freq = 200000000,
	.gen8_snapshot_block_list = &gen8_9_0_snapshot_block_list,
	.fast_bus_hint = true,
	.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
	.noc_timeout_us = 3410, /* 3.41 msec */
	.cl_no_ft_timeout_ms = 6500,
	.ctxt_record_size = (3708 * SZ_1K),
	.preempt_level = 1,
	.therm_cfg = &therm_mit_cfg_8_2_0,
	.bcl_data = 1,
};

static const struct adreno_a6xx_core adreno_gpu_core_a623 = {
	.base = {
		DEFINE_ADRENO_REV(ADRENO_REV_A623, 6, 2, 3, ANY_ID),
		.features = ADRENO_APRIV |
				ADRENO_IOCOHERENT | ADRENO_CONTENT_PROTECTION |
				ADRENO_PREEMPTION | ADRENO_ACD,
		.gpudev = &adreno_a6xx_gmu_gpudev.base,
		.perfcounters = &adreno_a6xx_perfcounters,
		.uche_gmem_alignment = SZ_1M + SZ_512K,
		.gmem_size = SZ_512K,
		.bus_width = 32,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:4357 [MATCH: timeout] ---
	.gbif = gen8_0_0_gbif_cx_regs,
	.gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs),
	.hang_detect_cycles = 0xcfffff,
	.protected_regs = gen8_2_0_protected_regs,
	.nonctxt_regs = gen8_9_0_nonctxt_regs,
	.gmu_hub_clk_freq = 200000000,
	.gen8_snapshot_block_list = &gen8_9_0_snapshot_block_list,
	.fast_bus_hint = true,
	.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
	.noc_timeout_us = 3410, /* 3.41 msec */
	.cl_no_ft_timeout_ms = 6500,
	.ctxt_record_size = (3708 * SZ_1K),
	.preempt_level = 1,
	.therm_cfg = &therm_mit_cfg_8_2_0,
	.bcl_data = 1,
};

static const struct adreno_a6xx_core adreno_gpu_core_a623 = {
	.base = {
		DEFINE_ADRENO_REV(ADRENO_REV_A623, 6, 2, 3, ANY_ID),
		.features = ADRENO_APRIV |
				ADRENO_IOCOHERENT | ADRENO_CONTENT_PROTECTION |
				ADRENO_PREEMPTION | ADRENO_ACD,
		.gpudev = &adreno_a6xx_gmu_gpudev.base,
		.perfcounters = &adreno_a6xx_perfcounters,
		.uche_gmem_alignment = SZ_1M + SZ_512K,
		.gmem_size = SZ_512K,
		.bus_width = 32,
		.snapshot_size = SZ_2M,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:4448 [MATCH: timeout] ---
	.ao_hwcg = gen8_1_0_ao_hwcg_regs,
	.ao_hwcg_count = ARRAY_SIZE(gen8_1_0_ao_hwcg_regs),
	.gbif = gen8_0_0_gbif_cx_regs,
	.gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs),
	.hang_detect_cycles = 0xcfffff,
	.protected_regs = gen8_1_0_protected_regs,
	.nonctxt_regs = gen8_1_0_nonctxt_regs,
	.gmu_hub_clk_freq = 200000000,
	.fast_bus_hint = true,
	.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
	.noc_timeout_us = 3410, /* 3.41 msec */
	.cl_no_ft_timeout_ms = 6500,
	.ctxt_record_size = (23088 * SZ_1K),
	.bcl_data = 1,
	.gen8_snapshot_block_list = &gen8_10_0_snapshot_block_list,
	.preempt_level = 1,
};

static const struct hfi_clx_table_v2_cmd gen8_11_0_clx_table = {
	.version = (2 << 16) | 1,
	.domain = {
		/* GFX domain */
		{
			.data0 = CLX_DATA(60, 5, 0, 1),
			.clxt = 0,
			.clxh = 0,
			.urgmode = 1,
			.lkgen = 0,
			.currbudget = 100,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:4449 [MATCH: timeout] ---
	.ao_hwcg_count = ARRAY_SIZE(gen8_1_0_ao_hwcg_regs),
	.gbif = gen8_0_0_gbif_cx_regs,
	.gbif_count = ARRAY_SIZE(gen8_0_0_gbif_cx_regs),
	.hang_detect_cycles = 0xcfffff,
	.protected_regs = gen8_1_0_protected_regs,
	.nonctxt_regs = gen8_1_0_nonctxt_regs,
	.gmu_hub_clk_freq = 200000000,
	.fast_bus_hint = true,
	.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
	.noc_timeout_us = 3410, /* 3.41 msec */
	.cl_no_ft_timeout_ms = 6500,
	.ctxt_record_size = (23088 * SZ_1K),
	.bcl_data = 1,
	.gen8_snapshot_block_list = &gen8_10_0_snapshot_block_list,
	.preempt_level = 1,
};

static const struct hfi_clx_table_v2_cmd gen8_11_0_clx_table = {
	.version = (2 << 16) | 1,
	.domain = {
		/* GFX domain */
		{
			.data0 = CLX_DATA(60, 5, 0, 1),
			.clxt = 0,
			.clxh = 0,
			.urgmode = 1,
			.lkgen = 0,
			.currbudget = 100,
		},

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:4689 [MATCH: timeout] ---
	{ GEN8_SP_CHICKEN_BITS_3, 0x00300000, BIT(PIPE_NONE) },
	/* Disable last-use skip for gpr ALU Write Enable */
	{ GEN8_SP_CHICKEN_BITS_5, BIT(3), BIT(PIPE_NONE) },
	{ GEN8_SP_NC_MODE_CNTL, 0x00000002, BIT(PIPE_NONE) },
	{ GEN8_SP_PERFCTR_SHADER_MASK, 0x0000003f, BIT(PIPE_NONE) },
	{ GEN8_SP_HLSQ_DBG_ECO_CNTL, 0x04000000, BIT(PIPE_NONE) },
	/* HLSQ ignores the shared constant feedback from SP:MAS */
	{ GEN8_SP_HLSQ_DBG_ECO_CNTL_1, BIT(17), BIT(PIPE_NONE) },
	/* Disable HLSQ large instruction async mode check */
	{ GEN8_SP_HLSQ_DBG_ECO_CNTL_3, BIT(1), BIT(PIPE_NONE) },
	{ GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080, BIT(PIPE_NONE) },
	{ GEN8_SP_READ_SEL, 0x0001ff00, BIT(PIPE_NONE) },
	{ GEN8_SP_L0_PERF_TUNE, 0x00000024, BIT(PIPE_NONE) },
	/* BIT(20): Disable alpha only optimization in TP */
	{ GEN8_TPL1_DBG_ECO_CNTL, 0x10100000, BIT(PIPE_NONE) },
	{ GEN8_TPL1_DBG_ECO_CNTL1, 0x00000720, BIT(PIPE_NONE) },
	/* GEN8_TPL1_NC_MODE_CNTL explicitly set elsewhere */
	{ GEN8_UCHE_MODE_CNTL, 0x80080000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
	/* Disable return data forwarding in UCHE */
	{ GEN8_UCHE_DBG_ECO_CNTL_0, BIT(31), BIT(PIPE_NONE) },
	/* BIT(22): Skip FullDirty flag during tag check in UCHE */
	{ GEN8_UCHE_HW_DBG_CNTL, 0x01410000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE) },
	{ GEN8_UCHE_GBIF_GX_CONFIG, 0x010240e0, BIT(PIPE_NONE) },
	{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
	/* Disable VFD sideband compression */
	{ GEN8_VFD_DBG_ECO_CNTL, 0x00008400, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) },

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:4704 [MATCH: timeout] ---
	{ GEN8_TPL1_DBG_ECO_CNTL1, 0x00000720, BIT(PIPE_NONE) },
	/* GEN8_TPL1_NC_MODE_CNTL explicitly set elsewhere */
	{ GEN8_UCHE_MODE_CNTL, 0x80080000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
	/* Disable return data forwarding in UCHE */
	{ GEN8_UCHE_DBG_ECO_CNTL_0, BIT(31), BIT(PIPE_NONE) },
	/* BIT(22): Skip FullDirty flag during tag check in UCHE */
	{ GEN8_UCHE_HW_DBG_CNTL, 0x01410000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE) },
	{ GEN8_UCHE_GBIF_GX_CONFIG, 0x010240e0, BIT(PIPE_NONE) },
	{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
	/* Disable VFD sideband compression */
	{ GEN8_VFD_DBG_ECO_CNTL, 0x00008400, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_LP_REQ_CNT, 0x00080020, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VSC_VISIBILITY_FLUSH_CNTL, 0x00080004, BIT(PIPE_NONE) },
	{ 0 },
};

extern const struct gen8_snapshot_block_list gen8_11_0_snapshot_block_list;

static const struct kgsl_regmap_list gen8_11_0_gbif_cx_regs[] = {
	{ GEN8_GBIF_QSB_SIDE0, 0x00071e20 },
	{ GEN8_GBIF_QSB_SIDE1, 0x00071e20 },
	{ GEN8_GBIF_QSB_SIDE2, 0x00071e20 },
	{ GEN8_GBIF_QSB_SIDE3, 0x00071e20 },

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:4758 [MATCH: timeout] ---
	.gbif = gen8_11_0_gbif_cx_regs,
	.gbif_count = ARRAY_SIZE(gen8_11_0_gbif_cx_regs),
	.hang_detect_cycles = 0xcfffff,
	.protected_regs = gen8_11_0_protected_regs,
	.nonctxt_regs = gen8_11_0_nonctxt_regs,
	.gmu_hub_clk_freq = 150000000,
	.gen8_snapshot_block_list = &gen8_11_0_snapshot_block_list,
	.fast_bus_hint = true,
	.bcl_data = 1,
	.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
	.noc_timeout_us = 3410, /* 3.41 msec */
	.cl_no_ft_timeout_ms = 6500,
	.ctxt_record_size = (19708 * SZ_1K),
	.limits_mit_cfg = &gen8_11_0_limits_mit_cfg,
	.preempt_level = 1,
	.gmu_mx_gdsc = true,
	.three_rail_memory = true,
	.malu = true,
	.clx_tbl = &gen8_11_0_clx_table,
};

/* GEN8_11_1 noncontext register list */
static const struct gen8_nonctxt_regs gen8_11_1_nonctxt_regs[] = {
	{ GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) },
	{ GEN8_CP_MULTIDRAW_CNTL, 0x00000001, BIT(PIPE_NONE) },
	/* Keep the raster direction as topleft */
	{ GEN8_GRAS_DBG_ECO_CNTL, 0x01000800, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_GRAS_TSEFE_DBG_ECO_CNTL, 0x00200000, BIT(PIPE_BV) | BIT(PIPE_BR) },
	/* GEN8_GRAS_NC_MODE_CNTL explicitly set elsewhere */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:4759 [MATCH: timeout] ---
	.gbif_count = ARRAY_SIZE(gen8_11_0_gbif_cx_regs),
	.hang_detect_cycles = 0xcfffff,
	.protected_regs = gen8_11_0_protected_regs,
	.nonctxt_regs = gen8_11_0_nonctxt_regs,
	.gmu_hub_clk_freq = 150000000,
	.gen8_snapshot_block_list = &gen8_11_0_snapshot_block_list,
	.fast_bus_hint = true,
	.bcl_data = 1,
	.acv_perfmode_ddr_freq = MHZ_TO_KBPS(2736, 4),
	.noc_timeout_us = 3410, /* 3.41 msec */
	.cl_no_ft_timeout_ms = 6500,
	.ctxt_record_size = (19708 * SZ_1K),
	.limits_mit_cfg = &gen8_11_0_limits_mit_cfg,
	.preempt_level = 1,
	.gmu_mx_gdsc = true,
	.three_rail_memory = true,
	.malu = true,
	.clx_tbl = &gen8_11_0_clx_table,
};

/* GEN8_11_1 noncontext register list */
static const struct gen8_nonctxt_regs gen8_11_1_nonctxt_regs[] = {
	{ GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) },
	{ GEN8_CP_MULTIDRAW_CNTL, 0x00000001, BIT(PIPE_NONE) },
	/* Keep the raster direction as topleft */
	{ GEN8_GRAS_DBG_ECO_CNTL, 0x01000800, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_GRAS_TSEFE_DBG_ECO_CNTL, 0x00200000, BIT(PIPE_BV) | BIT(PIPE_BR) },
	/* GEN8_GRAS_NC_MODE_CNTL explicitly set elsewhere */
	{ GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) },

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:4832 [MATCH: timeout] ---
	{ GEN8_SP_CHICKEN_BITS_3, 0x00300000, BIT(PIPE_NONE) },
	/* Disable last-use skip for gpr ALU Write Enable */
	{ GEN8_SP_CHICKEN_BITS_5, BIT(3), BIT(PIPE_NONE) },
	/* GEN8_SP_NC_MODE_CNTL explicitly set elsewhere */
	{ GEN8_SP_PERFCTR_SHADER_MASK, 0x0000003f, BIT(PIPE_NONE) },
	{ GEN8_SP_HLSQ_DBG_ECO_CNTL, 0x04000000, BIT(PIPE_NONE) },
	/* HLSQ ignores the shared constant feedback from SP:MAS */
	{ GEN8_SP_HLSQ_DBG_ECO_CNTL_1, BIT(17), BIT(PIPE_NONE) },
	/* Disable HLSQ large instruction async mode check */
	{ GEN8_SP_HLSQ_DBG_ECO_CNTL_3, BIT(1), BIT(PIPE_NONE) },
	{ GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080, BIT(PIPE_NONE) },
	{ GEN8_SP_READ_SEL, 0x0001ff00, BIT(PIPE_NONE) },
	{ GEN8_SP_L0_PERF_TUNE, 0x00000024, BIT(PIPE_NONE) },
	/* BIT(20): Disable alpha only optimization in TP */
	{ GEN8_TPL1_DBG_ECO_CNTL, 0x10100000, BIT(PIPE_NONE) },
	{ GEN8_TPL1_DBG_ECO_CNTL1, 0x00000720, BIT(PIPE_NONE) },
	/* GEN8_TPL1_NC_MODE_CNTL explicitly set elsewhere */
	{ GEN8_UCHE_MODE_CNTL, 0x80080000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
	/* Disable return data forwarding in UCHE */
	{ GEN8_UCHE_DBG_ECO_CNTL_0, BIT(31), BIT(PIPE_NONE) },
	/* BIT(22): Skip FullDirty flag during tag check in UCHE */
	{ GEN8_UCHE_HW_DBG_CNTL, 0x01410000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE) },
	{ GEN8_UCHE_GBIF_GX_CONFIG, 0x010240e0, BIT(PIPE_NONE) },
	{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
	{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BV) | BIT(PIPE_BR) },

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:4847 [MATCH: timeout] ---
	{ GEN8_TPL1_DBG_ECO_CNTL1, 0x00000720, BIT(PIPE_NONE) },
	/* GEN8_TPL1_NC_MODE_CNTL explicitly set elsewhere */
	{ GEN8_UCHE_MODE_CNTL, 0x80080000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
	/* Disable return data forwarding in UCHE */
	{ GEN8_UCHE_DBG_ECO_CNTL_0, BIT(31), BIT(PIPE_NONE) },
	/* BIT(22): Skip FullDirty flag during tag check in UCHE */
	{ GEN8_UCHE_HW_DBG_CNTL, 0x01410000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE) },
	{ GEN8_UCHE_GBIF_GX_CONFIG, 0x010240e0, BIT(PIPE_NONE) },
	{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
	{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_LP_REQ_CNT, 0x00080020, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VSC_VISIBILITY_FLUSH_CNTL, 0x00080004, BIT(PIPE_NONE) },
	{ 0 },
};

static const struct adreno_gen8_core adreno_gpu_core_gen8_11_1 = {
	.base = {
		DEFINE_ADRENO_REV(ADRENO_REV_GEN8_11_1,
				  UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
		.compatible = "qcom,adreno-gpu-gen8-11-1",
		.features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_LPAC | ADRENO_PREEMPTION |
			ADRENO_GMU_WARMBOOT | ADRENO_GMU_BASED_DCVS | ADRENO_CLX |
			ADRENO_GMU_THERMAL_MITIGATION | ADRENO_AQE | ADRENO_CONTENT_PROTECTION |

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:4905 [MATCH: timeout] ---
	.gbif = gen8_11_0_gbif_cx_regs,
	.gbif_count = ARRAY_SIZE(gen8_11_0_gbif_cx_regs),
	.hang_detect_cycles = 0xcfffff,
	.protected_regs = gen8_11_0_protected_regs,
	.nonctxt_regs = gen8_11_1_nonctxt_regs,
	.gmu_hub_clk_freq = 150000000,
	.gen8_snapshot_block_list = &gen8_11_0_snapshot_block_list,
	.fast_bus_hint = true,
	.bcl_data = GEN8_2_X_BCL_DATA,
	.acv_perfmode_ddr_freq = MHZ_TO_KBPS(4224, 4),
	.noc_timeout_us = 3410, /* 3.41 msec */
	.cl_no_ft_timeout_ms = 6500,
	.ctxt_record_size = (19708 * SZ_1K),
	.limits_mit_cfg = &gen8_11_0_limits_mit_cfg,
	.preempt_level = 1,
	.gmu_mx_gdsc = true,
	.three_rail_memory = true,
	.malu = true,
	.clx_tbl = &gen8_11_0_clx_table,
};

static const struct gen8_nonctxt_regs gen8_14_0_nonctxt_regs[] = {
	{ GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) },
	{ GEN8_CP_MULTIDRAW_CNTL, 0x00000001, BIT(PIPE_NONE) },
	/* Keep the raster direction as topleft */
	{ GEN8_GRAS_DBG_ECO_CNTL, 0x01000800, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_GRAS_TSEFE_DBG_ECO_CNTL, 0x00200000, BIT(PIPE_BV) | BIT(PIPE_BR) },
	/* GEN8_GRAS_NC_MODE_CNTL explicitly set elsewhere */
	{ GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) },

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:4906 [MATCH: timeout] ---
	.gbif_count = ARRAY_SIZE(gen8_11_0_gbif_cx_regs),
	.hang_detect_cycles = 0xcfffff,
	.protected_regs = gen8_11_0_protected_regs,
	.nonctxt_regs = gen8_11_1_nonctxt_regs,
	.gmu_hub_clk_freq = 150000000,
	.gen8_snapshot_block_list = &gen8_11_0_snapshot_block_list,
	.fast_bus_hint = true,
	.bcl_data = GEN8_2_X_BCL_DATA,
	.acv_perfmode_ddr_freq = MHZ_TO_KBPS(4224, 4),
	.noc_timeout_us = 3410, /* 3.41 msec */
	.cl_no_ft_timeout_ms = 6500,
	.ctxt_record_size = (19708 * SZ_1K),
	.limits_mit_cfg = &gen8_11_0_limits_mit_cfg,
	.preempt_level = 1,
	.gmu_mx_gdsc = true,
	.three_rail_memory = true,
	.malu = true,
	.clx_tbl = &gen8_11_0_clx_table,
};

static const struct gen8_nonctxt_regs gen8_14_0_nonctxt_regs[] = {
	{ GEN8_CP_SMMU_STREAM_ID_LPAC, 0x00000101, BIT(PIPE_NONE) },
	{ GEN8_CP_MULTIDRAW_CNTL, 0x00000001, BIT(PIPE_NONE) },
	/* Keep the raster direction as topleft */
	{ GEN8_GRAS_DBG_ECO_CNTL, 0x01000800, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_GRAS_TSEFE_DBG_ECO_CNTL, 0x00200000, BIT(PIPE_BV) | BIT(PIPE_BR) },
	/* GEN8_GRAS_NC_MODE_CNTL explicitly set elsewhere */
	{ GEN8_PC_AUTO_VERTEX_STRIDE, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_PC_VIS_STREAM_CNTL, 0x10010000, BIT(PIPE_BV) | BIT(PIPE_BR) },

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:4976 [MATCH: timeout] ---
	{ GEN8_SP_CHICKEN_BITS_3, 0x00300000, BIT(PIPE_NONE) },
	/* Disable last-use skip for gpr ALU Write Enable */
	{ GEN8_SP_CHICKEN_BITS_5, BIT(3), BIT(PIPE_NONE) },
	/* GEN8_SP_NC_MODE_CNTL explicitly set elsewhere */
	{ GEN8_SP_PERFCTR_SHADER_MASK, 0x0000003f, BIT(PIPE_NONE) },
	{ GEN8_SP_HLSQ_DBG_ECO_CNTL, 0x04000000, BIT(PIPE_NONE) },
	/* HLSQ ignores the shared constant feedback from SP:MAS */
	{ GEN8_SP_HLSQ_DBG_ECO_CNTL_1, BIT(17), BIT(PIPE_NONE) },
	/* Disable HLSQ large instruction async mode check */
	{ GEN8_SP_HLSQ_DBG_ECO_CNTL_3, BIT(1), BIT(PIPE_NONE) },
	{ GEN8_SP_HLSQ_TIMEOUT_THRESHOLD_DP, 0x00000080, BIT(PIPE_NONE) },
	{ GEN8_SP_READ_SEL, 0x0001ff00, BIT(PIPE_NONE) },
	{ GEN8_SP_L0_PERF_TUNE, 0x00000024, BIT(PIPE_NONE) },
	/* BIT(20): Disable alpha only optimization in TP */
	{ GEN8_TPL1_DBG_ECO_CNTL, 0x10100000, BIT(PIPE_NONE) },
	{ GEN8_TPL1_DBG_ECO_CNTL1, 0x00000720, BIT(PIPE_NONE) },
	/* GEN8_TPL1_NC_MODE_CNTL explicitly set elsewhere */
	{ GEN8_UCHE_MODE_CNTL, 0x80080000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
	/* Disable return data forwarding in UCHE */
	{ GEN8_UCHE_DBG_ECO_CNTL_0, BIT(31), BIT(PIPE_NONE) },
	/* BIT(22): Skip FullDirty flag during tag check in UCHE */
	{ GEN8_UCHE_HW_DBG_CNTL, 0x01410000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE) },
	{ GEN8_UCHE_GBIF_GX_CONFIG, 0x010240e0, BIT(PIPE_NONE) },
	{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
	{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BV) | BIT(PIPE_BR) },

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:4991 [MATCH: timeout] ---
	{ GEN8_TPL1_DBG_ECO_CNTL1, 0x00000720, BIT(PIPE_NONE) },
	/* GEN8_TPL1_NC_MODE_CNTL explicitly set elsewhere */
	{ GEN8_UCHE_MODE_CNTL, 0x80080000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_MODE_CNTL, 0x00001000, BIT(PIPE_NONE) },
	/* Disable return data forwarding in UCHE */
	{ GEN8_UCHE_DBG_ECO_CNTL_0, BIT(31), BIT(PIPE_NONE) },
	/* BIT(22): Skip FullDirty flag during tag check in UCHE */
	{ GEN8_UCHE_HW_DBG_CNTL, 0x01410000, BIT(PIPE_NONE) },
	{ GEN8_UCHE_CCHE_CACHE_WAYS, 0x00000800, BIT(PIPE_NONE) },
	{ GEN8_UCHE_GBIF_GX_CONFIG, 0x010240e0, BIT(PIPE_NONE) },
	{ GEN8_UCHE_VARB_IDLE_TIMEOUT, 0x00000020, BIT(PIPE_NONE) },
	{ GEN8_VFD_DBG_ECO_CNTL, 0x00008000, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BV_THRESHOLD, 0x00500050, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BR_THRESHOLD, 0x00600060, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_BUSY_REQ_CNT, 0x00200020, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VFD_CB_LP_REQ_CNT, 0x00080020, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VPC_FLATSHADE_MODE_CNTL, 0x00000001, BIT(PIPE_BV) | BIT(PIPE_BR) },
	{ GEN8_VSC_VISIBILITY_FLUSH_CNTL, 0x00080004, BIT(PIPE_NONE) },
	{ 0 },
};

static const struct adreno_gen8_core adreno_gpu_core_gen8_14_0 = {
	.base = {
		DEFINE_ADRENO_REV(ADRENO_REV_GEN8_14_0,
				UINT_MAX, UINT_MAX, UINT_MAX, ANY_ID),
		.compatible = "qcom,adreno-gpu-gen8-14-0",
		.features = ADRENO_APRIV | ADRENO_IOCOHERENT | ADRENO_LPAC | ADRENO_PREEMPTION |
			ADRENO_GMU_WARMBOOT | ADRENO_GMU_BASED_DCVS |
			ADRENO_GMU_THERMAL_MITIGATION | ADRENO_AQE | ADRENO_CONTENT_PROTECTION |

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:5048 [MATCH: timeout] ---
	.ao_hwcg_count = ARRAY_SIZE(gen8_2_0_ao_hwcg_regs),
	.gbif = gen8_11_0_gbif_cx_regs,
	.gbif_count = ARRAY_SIZE(gen8_11_0_gbif_cx_regs),
	.hang_detect_cycles = 0xcfffff,
	.protected_regs = gen8_11_0_protected_regs,
	.nonctxt_regs = gen8_14_0_nonctxt_regs,
	.gmu_hub_clk_freq = 150000000,
	.gen8_snapshot_block_list = &gen8_11_0_snapshot_block_list,
	.fast_bus_hint = true,
	.acv_perfmode_ddr_freq = MHZ_TO_KBPS(4224, 4),
	.noc_timeout_us = 3410, /* 3.41 msec */
	.cl_no_ft_timeout_ms = 6500,
	.ctxt_record_size = (13564 * SZ_1K),
	.limits_mit_cfg = &gen8_11_0_limits_mit_cfg,
	.preempt_level = 1,
	.gmu_mx_gdsc = true,
	.three_rail_memory = true,
	.malu = false,
	.clx_tbl = &gen8_14_0_clx_table,
};

static const struct adreno_gpu_core *adreno_gpulist[] = {
	&adreno_gpu_core_a306,		/* Deprecated */
	&adreno_gpu_core_a306a,		/* Deprecated */
	&adreno_gpu_core_a304,		/* Deprecated */
	&adreno_gpu_core_a405,		/* Deprecated */
	&adreno_gpu_core_a418,		/* Deprecated */
	&adreno_gpu_core_a420,		/* Deprecated */
	&adreno_gpu_core_a430,		/* Deprecated */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno-gpulist.h:5049 [MATCH: timeout] ---
	.gbif = gen8_11_0_gbif_cx_regs,
	.gbif_count = ARRAY_SIZE(gen8_11_0_gbif_cx_regs),
	.hang_detect_cycles = 0xcfffff,
	.protected_regs = gen8_11_0_protected_regs,
	.nonctxt_regs = gen8_14_0_nonctxt_regs,
	.gmu_hub_clk_freq = 150000000,
	.gen8_snapshot_block_list = &gen8_11_0_snapshot_block_list,
	.fast_bus_hint = true,
	.acv_perfmode_ddr_freq = MHZ_TO_KBPS(4224, 4),
	.noc_timeout_us = 3410, /* 3.41 msec */
	.cl_no_ft_timeout_ms = 6500,
	.ctxt_record_size = (13564 * SZ_1K),
	.limits_mit_cfg = &gen8_11_0_limits_mit_cfg,
	.preempt_level = 1,
	.gmu_mx_gdsc = true,
	.three_rail_memory = true,
	.malu = false,
	.clx_tbl = &gen8_14_0_clx_table,
};

static const struct adreno_gpu_core *adreno_gpulist[] = {
	&adreno_gpu_core_a306,		/* Deprecated */
	&adreno_gpu_core_a306a,		/* Deprecated */
	&adreno_gpu_core_a304,		/* Deprecated */
	&adreno_gpu_core_a405,		/* Deprecated */
	&adreno_gpu_core_a418,		/* Deprecated */
	&adreno_gpu_core_a420,		/* Deprecated */
	&adreno_gpu_core_a430,		/* Deprecated */
	&adreno_gpu_core_a530v1,	/* Deprecated */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2722 [MATCH: wait_for_completion] ---
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int ret = 0;

	if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex)))
		return -EINVAL;

	if ((atomic_read(&device->active_cnt) == 0) &&
		(device->state != KGSL_STATE_ACTIVE)) {
		kgsl_mutex_unlock(&device->mutex);
		wait_for_completion(&device->hwaccess_gate);
		kgsl_mutex_lock(&device->mutex);
		device->pwrctrl.superfast = true;
		ret = kgsl_pwrctrl_change_state(device, KGSL_STATE_ACTIVE);
	}
	if (ret == 0)
		atomic_inc(&device->active_cnt);
	trace_kgsl_active_count(device,
		(unsigned long) __builtin_return_address(0));
	return ret;
}

void adreno_active_count_put(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex)))
		return;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:1819 [MATCH: complete_all] ---
static void adreno_setup_device(struct adreno_device *adreno_dev)
{
	u32 i;

	adreno_dev->dev.name = "kgsl-3d0";
	adreno_dev->dev.ftbl = &adreno_functable;

	init_completion(&adreno_dev->dev.hwaccess_gate);
	init_completion(&adreno_dev->dev.halt_gate);
	init_completion(&adreno_dev->suspend_recovery_gate);
	complete_all(&adreno_dev->suspend_recovery_gate);

	idr_init(&adreno_dev->dev.context_idr);

	kgsl_mutex_init(&adreno_dev->dev.mutex);
	mutex_init(&adreno_dev->dev.file_mutex);
	mutex_init(&adreno_dev->fault_recovery_mutex);
	mutex_init(&adreno_dev->dcvs_tuning_mutex);
	INIT_LIST_HEAD(&adreno_dev->dev.globals);

	/* Set the fault tolerance policy to replay, skip, throttle */
	adreno_dev->ft_policy = BIT(KGSL_FT_REPLAY) |
		BIT(KGSL_FT_SKIPCMD) | BIT(KGSL_FT_THROTTLE);

	/* Enable command timeouts by default */
	adreno_dev->long_ib_detect = true;

	INIT_WORK(&adreno_dev->input_work, adreno_input_work);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:1932 [MATCH: complete_all] ---
	}

	if (event == PM_SUSPEND_PREPARE) {
		/*
		 * In presence of a hardware fault, cancel system suspend (by returning NOTIFY_BAD)
		 * here to make sure system suspend doesn't increment the pd prepared_count. This
		 * ensures that cx and gx gdscs can be toggled successfully during fault recovery.
		 */
		if (adreno_gpu_fault(adreno_dev)) {
			dev_err_ratelimited(device->dev, "cancelling suspend because of fault\n");
			complete_all(&adreno_dev->suspend_recovery_gate);
			adreno_scheduler_queue(adreno_dev);
			return NOTIFY_BAD;
		}

		reinit_completion(&adreno_dev->suspend_recovery_gate);
		return NOTIFY_DONE;
	}

	/*
	 * We get PM_POST_SUSPEND if we failed kgsl suspend in the presence of a hardware fault,
	 * or when system resume finishes. In either case, this means the system has come out of
	 * suspend and has put back the power domain prepared_count. This means we are safe to
	 * perform fault recovery.
	 */
	if (event == PM_POST_SUSPEND) {
		complete_all(&adreno_dev->suspend_recovery_gate);
		/*
		 * Queue the gpu scheduler to proceed with fault recovery in case there was a

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:1948 [MATCH: complete_all] ---
		return NOTIFY_DONE;
	}

	/*
	 * We get PM_POST_SUSPEND if we failed kgsl suspend in the presence of a hardware fault,
	 * or when system resume finishes. In either case, this means the system has come out of
	 * suspend and has put back the power domain prepared_count. This means we are safe to
	 * perform fault recovery.
	 */
	if (event == PM_POST_SUSPEND) {
		complete_all(&adreno_dev->suspend_recovery_gate);
		/*
		 * Queue the gpu scheduler to proceed with fault recovery in case there was a
		 * fault
		 */
		adreno_scheduler_queue(adreno_dev);
	}

	return NOTIFY_DONE;
}

static void validate_pwrlevels(struct kgsl_device *device)
{
	struct kgsl_pwrctrl *pwr = &device->pwrctrl;
	int i, count = pwr->ddr_table_count;

	for (i = 0; i < pwr->num_pwrlevels - 1; i++) {
		struct kgsl_pwrlevel *pwrlevel = &pwr->pwrlevels[i];


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2660 [MATCH: complete_all] ---
	memset(device->memstore->hostptr, 0, device->memstore->size);

	ret = adreno_init(device);
	if (ret)
		goto err;

	ret = adreno_start(device, 0);
	if (ret)
		goto err;

	complete_all(&device->hwaccess_gate);
	set_bit(ADRENO_DEVICE_FIRST_BOOT_DONE, &adreno_dev->priv);
	kgsl_pwrctrl_change_state(device, KGSL_STATE_ACTIVE);
	adreno_active_count_put(adreno_dev);

	return 0;
err:
	kgsl_pwrctrl_change_state(device, KGSL_STATE_INIT);
	atomic_dec(&device->active_cnt);

	return ret;
}

static int adreno_first_open(struct kgsl_device *device)
{
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	const struct adreno_power_ops *ops = ADRENO_POWER_OPS(adreno_dev);

	if (!device->pdev_loaded)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:115 [MATCH: timeout] ---
static struct adreno_device device_3d0;
static bool adreno_preemption_enable;
static u32 kgsl_gpu_sku_override = U32_MAX;
static u32 kgsl_gpu_speed_bin_override = U32_MAX;
u32 adreno_slice_mask_override = U32_MAX;

/* Nice level for the higher priority GPU start thread */
int adreno_wake_nice = -7;

/* Number of milliseconds to stay active after a wake on touch */
unsigned int adreno_wake_timeout = 100;

static u32 get_ucode_version(const u32 *data)
{
	u32 version;

	version = data[1];

	if ((version & 0xf) != 0xa)
		return version;

	version &= ~0xfff;
	return  version | ((data[3] & 0xfff000) >> 12);
}

int adreno_populate_ctxt_record_size(struct adreno_device *adreno_dev)
{
	struct kgsl_memdesc *memdesc = ADRENO_FW(adreno_dev, ADRENO_FW_SQE)->memdesc;
	struct ctxt_record_info *info;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:470 [MATCH: timeout] ---
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	/*
	 * Don't schedule adreno_start in a high priority workqueue, we are
	 * already in a workqueue which should be sufficient
	 */
	kgsl_pwrctrl_change_state(device, KGSL_STATE_ACTIVE);

	/*
	 * When waking up from a touch event we want to stay active long enough
	 * for the user to send a draw command.  The default idle timer timeout
	 * is shorter than we want so go ahead and push the idle timer out
	 * further for this special case
	 */
	mod_timer(&device->idle_timer,
		jiffies + msecs_to_jiffies(adreno_wake_timeout));

}

/*
 * A workqueue callback responsible for actually turning on the GPU after a
 * touch event. kgsl_pwrctrl_change_state(ACTIVE) is used without any
 * active_count protection to avoid the need to maintain state.  Either
 * somebody will start using the GPU or the idle timer will fire and put the
 * GPU back into slumber.
 */
static void adreno_input_work(struct work_struct *work)
{
	struct adreno_device *adreno_dev = container_of(work,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:475 [MATCH: timeout] ---
	 */
	kgsl_pwrctrl_change_state(device, KGSL_STATE_ACTIVE);

	/*
	 * When waking up from a touch event we want to stay active long enough
	 * for the user to send a draw command.  The default idle timer timeout
	 * is shorter than we want so go ahead and push the idle timer out
	 * further for this special case
	 */
	mod_timer(&device->idle_timer,
		jiffies + msecs_to_jiffies(adreno_wake_timeout));

}

/*
 * A workqueue callback responsible for actually turning on the GPU after a
 * touch event. kgsl_pwrctrl_change_state(ACTIVE) is used without any
 * active_count protection to avoid the need to maintain state.  Either
 * somebody will start using the GPU or the idle timer will fire and put the
 * GPU back into slumber.
 */
static void adreno_input_work(struct work_struct *work)
{
	struct adreno_device *adreno_dev = container_of(work,
			struct adreno_device, input_work);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	const struct adreno_power_ops *ops = ADRENO_POWER_OPS(adreno_dev);

	kgsl_mutex_lock(&device->mutex);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:1486 [MATCH: timeout] ---
	if (node && of_device_is_compatible(node, "operating-points-v2")) {
		ret = adreno_of_parse_pwrlevels(adreno_dev);
		if (!ret)
			adreno_of_get_limits(adreno_dev, node);
	} else
		ret = adreno_of_get_legacy_pwrlevels_bins(adreno_dev, pdev->dev.of_node);

	if (ret)
		return ret;

	atomic64_set(&device->pwrctrl.interval_timeout, CONFIG_QCOM_KGSL_IDLE_TIMEOUT);

	return 0;
}

/* Read the fuse through the new and fancy nvmem method */
static int adreno_read_fuse(struct platform_device *pdev, const char *fuse)
{
	struct nvmem_cell *cell = nvmem_cell_get(&pdev->dev, fuse);
	int ret = PTR_ERR_OR_ZERO(cell);
	void *buf;
	int val = 0;
	size_t len;

	if (ret) {
		if (ret == -ENOENT)
			return 0;

		return ret;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:1833 [MATCH: timeout] ---
	kgsl_mutex_init(&adreno_dev->dev.mutex);
	mutex_init(&adreno_dev->dev.file_mutex);
	mutex_init(&adreno_dev->fault_recovery_mutex);
	mutex_init(&adreno_dev->dcvs_tuning_mutex);
	INIT_LIST_HEAD(&adreno_dev->dev.globals);

	/* Set the fault tolerance policy to replay, skip, throttle */
	adreno_dev->ft_policy = BIT(KGSL_FT_REPLAY) |
		BIT(KGSL_FT_SKIPCMD) | BIT(KGSL_FT_THROTTLE);

	/* Enable command timeouts by default */
	adreno_dev->long_ib_detect = true;

	INIT_WORK(&adreno_dev->input_work, adreno_input_work);

	INIT_LIST_HEAD(&adreno_dev->active_list);
	spin_lock_init(&adreno_dev->active_list_lock);
	rwlock_init(&adreno_dev->fault_stats_lock);

	for (i = 0; i < ARRAY_SIZE(adreno_dev->ringbuffers); i++) {
		struct adreno_ringbuffer *rb = &adreno_dev->ringbuffers[i];

		INIT_LIST_HEAD(&rb->events.group);
	}

	/*
	 * Some GPUs needs specific alignment for UCHE GMEM base address.
	 * Configure UCHE GMEM base based on GMEM size and align it accordingly.
	 * This needs to be done based on GMEM size to avoid overlap between

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2821 [MATCH: timeout] ---
			KGSL_PERFCOUNTER_GROUP_VBIF,
			VBIF_AXI_TOTAL_BEATS,
			&adreno_dev->ram_cycles_lo, NULL);
	}

	if (ret)
		dev_err(KGSL_DEVICE(adreno_dev)->dev,
			"Unable to get perf counters for bus DCVS\n");
}

#define ADRENO_AHB_MIN_TIMEOUT_VAL_USEC 1000

u32 adreno_get_ahb_timeout_val(struct adreno_device *adreno_dev, u32 noc_timeout_us)
{
	u64 cycles, hub_clk_freq = adreno_dev->gmu_hub_clk_freq;
	u32 timeout_val;

	if (!noc_timeout_us)
		return 0;

	do_div(hub_clk_freq, HZ_PER_MHZ);
	cycles = hub_clk_freq * noc_timeout_us;

	/*
	 * Get max possible AHB timeout value which is less than the GPU NOC timeout value.
	 * When cycles are exact power of two, the calculated AHB timeout value will be same
	 * as GPU config NOC timeout. Just reduce one cycle to make sure we do not program AHB
	 * timeout same as GPU config NOC timeout.
	 */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2823 [MATCH: timeout] ---
			&adreno_dev->ram_cycles_lo, NULL);
	}

	if (ret)
		dev_err(KGSL_DEVICE(adreno_dev)->dev,
			"Unable to get perf counters for bus DCVS\n");
}

#define ADRENO_AHB_MIN_TIMEOUT_VAL_USEC 1000

u32 adreno_get_ahb_timeout_val(struct adreno_device *adreno_dev, u32 noc_timeout_us)
{
	u64 cycles, hub_clk_freq = adreno_dev->gmu_hub_clk_freq;
	u32 timeout_val;

	if (!noc_timeout_us)
		return 0;

	do_div(hub_clk_freq, HZ_PER_MHZ);
	cycles = hub_clk_freq * noc_timeout_us;

	/*
	 * Get max possible AHB timeout value which is less than the GPU NOC timeout value.
	 * When cycles are exact power of two, the calculated AHB timeout value will be same
	 * as GPU config NOC timeout. Just reduce one cycle to make sure we do not program AHB
	 * timeout same as GPU config NOC timeout.
	 */
	if (is_power_of_2(cycles))
		cycles -= 1;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2826 [MATCH: timeout] ---
	if (ret)
		dev_err(KGSL_DEVICE(adreno_dev)->dev,
			"Unable to get perf counters for bus DCVS\n");
}

#define ADRENO_AHB_MIN_TIMEOUT_VAL_USEC 1000

u32 adreno_get_ahb_timeout_val(struct adreno_device *adreno_dev, u32 noc_timeout_us)
{
	u64 cycles, hub_clk_freq = adreno_dev->gmu_hub_clk_freq;
	u32 timeout_val;

	if (!noc_timeout_us)
		return 0;

	do_div(hub_clk_freq, HZ_PER_MHZ);
	cycles = hub_clk_freq * noc_timeout_us;

	/*
	 * Get max possible AHB timeout value which is less than the GPU NOC timeout value.
	 * When cycles are exact power of two, the calculated AHB timeout value will be same
	 * as GPU config NOC timeout. Just reduce one cycle to make sure we do not program AHB
	 * timeout same as GPU config NOC timeout.
	 */
	if (is_power_of_2(cycles))
		cycles -= 1;

	timeout_val = ilog2(cycles);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2828 [MATCH: timeout] ---
			"Unable to get perf counters for bus DCVS\n");
}

#define ADRENO_AHB_MIN_TIMEOUT_VAL_USEC 1000

u32 adreno_get_ahb_timeout_val(struct adreno_device *adreno_dev, u32 noc_timeout_us)
{
	u64 cycles, hub_clk_freq = adreno_dev->gmu_hub_clk_freq;
	u32 timeout_val;

	if (!noc_timeout_us)
		return 0;

	do_div(hub_clk_freq, HZ_PER_MHZ);
	cycles = hub_clk_freq * noc_timeout_us;

	/*
	 * Get max possible AHB timeout value which is less than the GPU NOC timeout value.
	 * When cycles are exact power of two, the calculated AHB timeout value will be same
	 * as GPU config NOC timeout. Just reduce one cycle to make sure we do not program AHB
	 * timeout same as GPU config NOC timeout.
	 */
	if (is_power_of_2(cycles))
		cycles -= 1;

	timeout_val = ilog2(cycles);

	/*
	 * Make sure, AHB timeout value fits into bit fields and it is not too low

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2832 [MATCH: timeout] ---

u32 adreno_get_ahb_timeout_val(struct adreno_device *adreno_dev, u32 noc_timeout_us)
{
	u64 cycles, hub_clk_freq = adreno_dev->gmu_hub_clk_freq;
	u32 timeout_val;

	if (!noc_timeout_us)
		return 0;

	do_div(hub_clk_freq, HZ_PER_MHZ);
	cycles = hub_clk_freq * noc_timeout_us;

	/*
	 * Get max possible AHB timeout value which is less than the GPU NOC timeout value.
	 * When cycles are exact power of two, the calculated AHB timeout value will be same
	 * as GPU config NOC timeout. Just reduce one cycle to make sure we do not program AHB
	 * timeout same as GPU config NOC timeout.
	 */
	if (is_power_of_2(cycles))
		cycles -= 1;

	timeout_val = ilog2(cycles);

	/*
	 * Make sure, AHB timeout value fits into bit fields and it is not too low
	 * which can cause false timeouts.
	 */
	if ((timeout_val > GENMASK(4, 0)) ||
		((ADRENO_AHB_MIN_TIMEOUT_VAL_USEC * hub_clk_freq) > (1 << timeout_val))) {

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2835 [MATCH: timeout] ---
	u64 cycles, hub_clk_freq = adreno_dev->gmu_hub_clk_freq;
	u32 timeout_val;

	if (!noc_timeout_us)
		return 0;

	do_div(hub_clk_freq, HZ_PER_MHZ);
	cycles = hub_clk_freq * noc_timeout_us;

	/*
	 * Get max possible AHB timeout value which is less than the GPU NOC timeout value.
	 * When cycles are exact power of two, the calculated AHB timeout value will be same
	 * as GPU config NOC timeout. Just reduce one cycle to make sure we do not program AHB
	 * timeout same as GPU config NOC timeout.
	 */
	if (is_power_of_2(cycles))
		cycles -= 1;

	timeout_val = ilog2(cycles);

	/*
	 * Make sure, AHB timeout value fits into bit fields and it is not too low
	 * which can cause false timeouts.
	 */
	if ((timeout_val > GENMASK(4, 0)) ||
		((ADRENO_AHB_MIN_TIMEOUT_VAL_USEC * hub_clk_freq) > (1 << timeout_val))) {
		dev_warn(adreno_dev->dev.dev, "Invalid AHB timeout_val %u\n", timeout_val);
		return 0;
	}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2836 [MATCH: timeout] ---
	u32 timeout_val;

	if (!noc_timeout_us)
		return 0;

	do_div(hub_clk_freq, HZ_PER_MHZ);
	cycles = hub_clk_freq * noc_timeout_us;

	/*
	 * Get max possible AHB timeout value which is less than the GPU NOC timeout value.
	 * When cycles are exact power of two, the calculated AHB timeout value will be same
	 * as GPU config NOC timeout. Just reduce one cycle to make sure we do not program AHB
	 * timeout same as GPU config NOC timeout.
	 */
	if (is_power_of_2(cycles))
		cycles -= 1;

	timeout_val = ilog2(cycles);

	/*
	 * Make sure, AHB timeout value fits into bit fields and it is not too low
	 * which can cause false timeouts.
	 */
	if ((timeout_val > GENMASK(4, 0)) ||
		((ADRENO_AHB_MIN_TIMEOUT_VAL_USEC * hub_clk_freq) > (1 << timeout_val))) {
		dev_warn(adreno_dev->dev.dev, "Invalid AHB timeout_val %u\n", timeout_val);
		return 0;
	}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2837 [MATCH: timeout] ---

	if (!noc_timeout_us)
		return 0;

	do_div(hub_clk_freq, HZ_PER_MHZ);
	cycles = hub_clk_freq * noc_timeout_us;

	/*
	 * Get max possible AHB timeout value which is less than the GPU NOC timeout value.
	 * When cycles are exact power of two, the calculated AHB timeout value will be same
	 * as GPU config NOC timeout. Just reduce one cycle to make sure we do not program AHB
	 * timeout same as GPU config NOC timeout.
	 */
	if (is_power_of_2(cycles))
		cycles -= 1;

	timeout_val = ilog2(cycles);

	/*
	 * Make sure, AHB timeout value fits into bit fields and it is not too low
	 * which can cause false timeouts.
	 */
	if ((timeout_val > GENMASK(4, 0)) ||
		((ADRENO_AHB_MIN_TIMEOUT_VAL_USEC * hub_clk_freq) > (1 << timeout_val))) {
		dev_warn(adreno_dev->dev.dev, "Invalid AHB timeout_val %u\n", timeout_val);
		return 0;
	}

	/*

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2838 [MATCH: timeout] ---
	if (!noc_timeout_us)
		return 0;

	do_div(hub_clk_freq, HZ_PER_MHZ);
	cycles = hub_clk_freq * noc_timeout_us;

	/*
	 * Get max possible AHB timeout value which is less than the GPU NOC timeout value.
	 * When cycles are exact power of two, the calculated AHB timeout value will be same
	 * as GPU config NOC timeout. Just reduce one cycle to make sure we do not program AHB
	 * timeout same as GPU config NOC timeout.
	 */
	if (is_power_of_2(cycles))
		cycles -= 1;

	timeout_val = ilog2(cycles);

	/*
	 * Make sure, AHB timeout value fits into bit fields and it is not too low
	 * which can cause false timeouts.
	 */
	if ((timeout_val > GENMASK(4, 0)) ||
		((ADRENO_AHB_MIN_TIMEOUT_VAL_USEC * hub_clk_freq) > (1 << timeout_val))) {
		dev_warn(adreno_dev->dev.dev, "Invalid AHB timeout_val %u\n", timeout_val);
		return 0;
	}

	/*
	 * Return (timeout_val - 1). Based on timeout_val programmed, a timeout will occur if

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2843 [MATCH: timeout] ---

	/*
	 * Get max possible AHB timeout value which is less than the GPU NOC timeout value.
	 * When cycles are exact power of two, the calculated AHB timeout value will be same
	 * as GPU config NOC timeout. Just reduce one cycle to make sure we do not program AHB
	 * timeout same as GPU config NOC timeout.
	 */
	if (is_power_of_2(cycles))
		cycles -= 1;

	timeout_val = ilog2(cycles);

	/*
	 * Make sure, AHB timeout value fits into bit fields and it is not too low
	 * which can cause false timeouts.
	 */
	if ((timeout_val > GENMASK(4, 0)) ||
		((ADRENO_AHB_MIN_TIMEOUT_VAL_USEC * hub_clk_freq) > (1 << timeout_val))) {
		dev_warn(adreno_dev->dev.dev, "Invalid AHB timeout_val %u\n", timeout_val);
		return 0;
	}

	/*
	 * Return (timeout_val - 1). Based on timeout_val programmed, a timeout will occur if
	 * an AHB transaction is not completed in 2 ^ (timeout_val + 1) cycles.
	 */
	return (timeout_val - 1);
}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2846 [MATCH: timeout] ---
	 * When cycles are exact power of two, the calculated AHB timeout value will be same
	 * as GPU config NOC timeout. Just reduce one cycle to make sure we do not program AHB
	 * timeout same as GPU config NOC timeout.
	 */
	if (is_power_of_2(cycles))
		cycles -= 1;

	timeout_val = ilog2(cycles);

	/*
	 * Make sure, AHB timeout value fits into bit fields and it is not too low
	 * which can cause false timeouts.
	 */
	if ((timeout_val > GENMASK(4, 0)) ||
		((ADRENO_AHB_MIN_TIMEOUT_VAL_USEC * hub_clk_freq) > (1 << timeout_val))) {
		dev_warn(adreno_dev->dev.dev, "Invalid AHB timeout_val %u\n", timeout_val);
		return 0;
	}

	/*
	 * Return (timeout_val - 1). Based on timeout_val programmed, a timeout will occur if
	 * an AHB transaction is not completed in 2 ^ (timeout_val + 1) cycles.
	 */
	return (timeout_val - 1);
}

/**
 * _adreno_start - Power up the GPU and prepare to accept commands
 * @adreno_dev: Pointer to an adreno_device structure

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2847 [MATCH: timeout] ---
	 * as GPU config NOC timeout. Just reduce one cycle to make sure we do not program AHB
	 * timeout same as GPU config NOC timeout.
	 */
	if (is_power_of_2(cycles))
		cycles -= 1;

	timeout_val = ilog2(cycles);

	/*
	 * Make sure, AHB timeout value fits into bit fields and it is not too low
	 * which can cause false timeouts.
	 */
	if ((timeout_val > GENMASK(4, 0)) ||
		((ADRENO_AHB_MIN_TIMEOUT_VAL_USEC * hub_clk_freq) > (1 << timeout_val))) {
		dev_warn(adreno_dev->dev.dev, "Invalid AHB timeout_val %u\n", timeout_val);
		return 0;
	}

	/*
	 * Return (timeout_val - 1). Based on timeout_val programmed, a timeout will occur if
	 * an AHB transaction is not completed in 2 ^ (timeout_val + 1) cycles.
	 */
	return (timeout_val - 1);
}

/**
 * _adreno_start - Power up the GPU and prepare to accept commands
 * @adreno_dev: Pointer to an adreno_device structure
 *

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2849 [MATCH: timeout] ---
	 */
	if (is_power_of_2(cycles))
		cycles -= 1;

	timeout_val = ilog2(cycles);

	/*
	 * Make sure, AHB timeout value fits into bit fields and it is not too low
	 * which can cause false timeouts.
	 */
	if ((timeout_val > GENMASK(4, 0)) ||
		((ADRENO_AHB_MIN_TIMEOUT_VAL_USEC * hub_clk_freq) > (1 << timeout_val))) {
		dev_warn(adreno_dev->dev.dev, "Invalid AHB timeout_val %u\n", timeout_val);
		return 0;
	}

	/*
	 * Return (timeout_val - 1). Based on timeout_val programmed, a timeout will occur if
	 * an AHB transaction is not completed in 2 ^ (timeout_val + 1) cycles.
	 */
	return (timeout_val - 1);
}

/**
 * _adreno_start - Power up the GPU and prepare to accept commands
 * @adreno_dev: Pointer to an adreno_device structure
 *
 * The core function that powers up and initalizes the GPU.  This function is
 * called at init and after coming out of SLUMBER

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2850 [MATCH: timeout] ---
	if (is_power_of_2(cycles))
		cycles -= 1;

	timeout_val = ilog2(cycles);

	/*
	 * Make sure, AHB timeout value fits into bit fields and it is not too low
	 * which can cause false timeouts.
	 */
	if ((timeout_val > GENMASK(4, 0)) ||
		((ADRENO_AHB_MIN_TIMEOUT_VAL_USEC * hub_clk_freq) > (1 << timeout_val))) {
		dev_warn(adreno_dev->dev.dev, "Invalid AHB timeout_val %u\n", timeout_val);
		return 0;
	}

	/*
	 * Return (timeout_val - 1). Based on timeout_val programmed, a timeout will occur if
	 * an AHB transaction is not completed in 2 ^ (timeout_val + 1) cycles.
	 */
	return (timeout_val - 1);
}

/**
 * _adreno_start - Power up the GPU and prepare to accept commands
 * @adreno_dev: Pointer to an adreno_device structure
 *
 * The core function that powers up and initalizes the GPU.  This function is
 * called at init and after coming out of SLUMBER
 */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2851 [MATCH: timeout] ---
		cycles -= 1;

	timeout_val = ilog2(cycles);

	/*
	 * Make sure, AHB timeout value fits into bit fields and it is not too low
	 * which can cause false timeouts.
	 */
	if ((timeout_val > GENMASK(4, 0)) ||
		((ADRENO_AHB_MIN_TIMEOUT_VAL_USEC * hub_clk_freq) > (1 << timeout_val))) {
		dev_warn(adreno_dev->dev.dev, "Invalid AHB timeout_val %u\n", timeout_val);
		return 0;
	}

	/*
	 * Return (timeout_val - 1). Based on timeout_val programmed, a timeout will occur if
	 * an AHB transaction is not completed in 2 ^ (timeout_val + 1) cycles.
	 */
	return (timeout_val - 1);
}

/**
 * _adreno_start - Power up the GPU and prepare to accept commands
 * @adreno_dev: Pointer to an adreno_device structure
 *
 * The core function that powers up and initalizes the GPU.  This function is
 * called at init and after coming out of SLUMBER
 */
static int _adreno_start(struct adreno_device *adreno_dev)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2856 [MATCH: timeout] ---
	 * Make sure, AHB timeout value fits into bit fields and it is not too low
	 * which can cause false timeouts.
	 */
	if ((timeout_val > GENMASK(4, 0)) ||
		((ADRENO_AHB_MIN_TIMEOUT_VAL_USEC * hub_clk_freq) > (1 << timeout_val))) {
		dev_warn(adreno_dev->dev.dev, "Invalid AHB timeout_val %u\n", timeout_val);
		return 0;
	}

	/*
	 * Return (timeout_val - 1). Based on timeout_val programmed, a timeout will occur if
	 * an AHB transaction is not completed in 2 ^ (timeout_val + 1) cycles.
	 */
	return (timeout_val - 1);
}

/**
 * _adreno_start - Power up the GPU and prepare to accept commands
 * @adreno_dev: Pointer to an adreno_device structure
 *
 * The core function that powers up and initalizes the GPU.  This function is
 * called at init and after coming out of SLUMBER
 */
static int _adreno_start(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
	int status;
	unsigned int state = device->state;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2857 [MATCH: timeout] ---
	 * which can cause false timeouts.
	 */
	if ((timeout_val > GENMASK(4, 0)) ||
		((ADRENO_AHB_MIN_TIMEOUT_VAL_USEC * hub_clk_freq) > (1 << timeout_val))) {
		dev_warn(adreno_dev->dev.dev, "Invalid AHB timeout_val %u\n", timeout_val);
		return 0;
	}

	/*
	 * Return (timeout_val - 1). Based on timeout_val programmed, a timeout will occur if
	 * an AHB transaction is not completed in 2 ^ (timeout_val + 1) cycles.
	 */
	return (timeout_val - 1);
}

/**
 * _adreno_start - Power up the GPU and prepare to accept commands
 * @adreno_dev: Pointer to an adreno_device structure
 *
 * The core function that powers up and initalizes the GPU.  This function is
 * called at init and after coming out of SLUMBER
 */
static int _adreno_start(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
	int status;
	unsigned int state = device->state;
	bool gdsc_left_on;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2859 [MATCH: timeout] ---
	if ((timeout_val > GENMASK(4, 0)) ||
		((ADRENO_AHB_MIN_TIMEOUT_VAL_USEC * hub_clk_freq) > (1 << timeout_val))) {
		dev_warn(adreno_dev->dev.dev, "Invalid AHB timeout_val %u\n", timeout_val);
		return 0;
	}

	/*
	 * Return (timeout_val - 1). Based on timeout_val programmed, a timeout will occur if
	 * an AHB transaction is not completed in 2 ^ (timeout_val + 1) cycles.
	 */
	return (timeout_val - 1);
}

/**
 * _adreno_start - Power up the GPU and prepare to accept commands
 * @adreno_dev: Pointer to an adreno_device structure
 *
 * The core function that powers up and initalizes the GPU.  This function is
 * called at init and after coming out of SLUMBER
 */
static int _adreno_start(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
	int status;
	unsigned int state = device->state;
	bool gdsc_left_on;

	/* make sure ADRENO_DEVICE_STARTED is not set here */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:3739 [MATCH: timeout] ---
		if (!adreno_rb_empty(rb))
			return false;
	}

	return gpudev->hw_isidle(adreno_dev);
}

/**
 * adreno_spin_idle() - Spin wait for the GPU to idle
 * @adreno_dev: Pointer to an adreno device
 * @timeout: milliseconds to wait before returning error
 *
 * Spin the CPU waiting for the RBBM status to return idle
 */
int adreno_spin_idle(struct adreno_device *adreno_dev, unsigned int timeout)
{
	unsigned long wait = jiffies + msecs_to_jiffies(timeout);

	do {
		/*
		 * If we fault, stop waiting and return an error. The dispatcher
		 * will clean up the fault from the work queue, but we need to
		 * make sure we don't block it by waiting for an idle that
		 * will never come.
		 */

		if (adreno_gpu_fault(adreno_dev) != 0)
			return -EDEADLK;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:3743 [MATCH: timeout] ---
	return gpudev->hw_isidle(adreno_dev);
}

/**
 * adreno_spin_idle() - Spin wait for the GPU to idle
 * @adreno_dev: Pointer to an adreno device
 * @timeout: milliseconds to wait before returning error
 *
 * Spin the CPU waiting for the RBBM status to return idle
 */
int adreno_spin_idle(struct adreno_device *adreno_dev, unsigned int timeout)
{
	unsigned long wait = jiffies + msecs_to_jiffies(timeout);

	do {
		/*
		 * If we fault, stop waiting and return an error. The dispatcher
		 * will clean up the fault from the work queue, but we need to
		 * make sure we don't block it by waiting for an idle that
		 * will never come.
		 */

		if (adreno_gpu_fault(adreno_dev) != 0)
			return -EDEADLK;

		if (adreno_isidle(adreno_dev))
			return 0;

	} while (time_before(jiffies, wait));

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:3745 [MATCH: timeout] ---

/**
 * adreno_spin_idle() - Spin wait for the GPU to idle
 * @adreno_dev: Pointer to an adreno device
 * @timeout: milliseconds to wait before returning error
 *
 * Spin the CPU waiting for the RBBM status to return idle
 */
int adreno_spin_idle(struct adreno_device *adreno_dev, unsigned int timeout)
{
	unsigned long wait = jiffies + msecs_to_jiffies(timeout);

	do {
		/*
		 * If we fault, stop waiting and return an error. The dispatcher
		 * will clean up the fault from the work queue, but we need to
		 * make sure we don't block it by waiting for an idle that
		 * will never come.
		 */

		if (adreno_gpu_fault(adreno_dev) != 0)
			return -EDEADLK;

		if (adreno_isidle(adreno_dev))
			return 0;

	} while (time_before(jiffies, wait));

	/*

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:3781 [MATCH: timeout] ---
	if (adreno_isidle(adreno_dev))
		return 0;

	return -ETIMEDOUT;
}

/**
 * adreno_wait_idle() - wait for the GPU hardware to go idle
 * @device: Pointer to the KGSL device structure for the GPU
 *
 * Wait up to ADRENO_IDLE_TIMEOUT milliseconds for the GPU hardware to go quiet.
 * Caller must hold the device mutex, and must not hold the dispatcher mutex.
 */

int adreno_wait_idle(struct kgsl_device *device)
{
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	int ret;

	/*
	 * Make sure the device mutex is held so the dispatcher can't send any
	 * more commands to the hardware
	 */

	if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex)))
		return -EDEADLK;

	/* Check if we are already idle before idling dispatcher */
	if (adreno_isidle(adreno_dev))

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:3809 [MATCH: timeout] ---
	if (adreno_isidle(adreno_dev))
		return 0;
	/*
	 * Wait for dispatcher to finish completing commands
	 * already submitted
	 */
	ret = adreno_dispatcher_idle(adreno_dev);
	if (ret)
		return ret;

	return adreno_spin_idle(adreno_dev, ADRENO_IDLE_TIMEOUT);
}

int adreno_drain(struct kgsl_device *device, unsigned long wait_jiffies)
{
	int ret;

	/* Halt any new submissions */
	reinit_completion(&device->halt_gate);

	/**
	 * Wait for the dispatcher to retire everything by waiting
	 * for the active count to go to zero.
	 */
	ret = kgsl_active_count_wait(device, 0, wait_jiffies);
	if (ret)
		dev_err(device->dev, "Timed out waiting for the active count\n");

	return ret;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2945 [MATCH: results] ---
	set_bit(ADRENO_DEVICE_STARTED, &adreno_dev->priv);

	/*
	 * There is a possible deadlock scenario during kgsl firmware reading
	 * (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl
	 * device mutex is held and then firmware_request_nowarn is called for reading
	 * firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock.
	 * Whereas in case of devfreq update calls triggered by thermal/bcl or
	 * devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then
	 * tries to take kgsl device mutex as part of get_dev_status/target
	 * calls. This results in deadlock when both thread are unable to acquire
	 * the mutex held by other thread. Enable devfreq updates now as we are
	 * done reading all firmware files.
	 */
	device->pwrscale.devfreq_enabled = true;

	return 0;

error_pwr_off:
	/* set the state back to original state */
	kgsl_pwrctrl_change_state(device, state);

	return status;
}

/**
 * adreno_start() - Power up and initialize the GPU
 * @device: Pointer to the KGSL device to power up
 * @priority:  Boolean flag to specify of the start should be scheduled in a low

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:3835 [MATCH: results] ---
		dev_err(device->dev, "Timed out waiting for the active count\n");

	return ret;
}

/* Caller must hold the device mutex. */
void adreno_check_idle(struct kgsl_device *device)
{
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);

	/* process any profiling results that are available */
	adreno_profile_process_results(adreno_dev);

	/*
	 * Make sure the device mutex is held so the dispatcher can't send any
	 * more commands to the hardware
	 */
	if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex)))
		return;

	/* Make sure dispatcher is idle */
	if (!completion_done(&adreno_dev->dispatcher.idle_gate))
		dev_err_ratelimited(device->dev, "Dispatcher not idle before SLUMBER\n");

	/* Make sure the device is idle */
	if (!adreno_isidle(adreno_dev))
		dev_err_ratelimited(device->dev, "Device not idle before SLUMBER\n");
}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:3836 [MATCH: results] ---

	return ret;
}

/* Caller must hold the device mutex. */
void adreno_check_idle(struct kgsl_device *device)
{
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);

	/* process any profiling results that are available */
	adreno_profile_process_results(adreno_dev);

	/*
	 * Make sure the device mutex is held so the dispatcher can't send any
	 * more commands to the hardware
	 */
	if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex)))
		return;

	/* Make sure dispatcher is idle */
	if (!completion_done(&adreno_dev->dispatcher.idle_gate))
		dev_err_ratelimited(device->dev, "Dispatcher not idle before SLUMBER\n");

	/* Make sure the device is idle */
	if (!adreno_isidle(adreno_dev))
		dev_err_ratelimited(device->dev, "Device not idle before SLUMBER\n");
}

bool adreno_gx_is_on(struct adreno_device *adreno_dev)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:493 [MATCH: mutex_lock] ---
 * somebody will start using the GPU or the idle timer will fire and put the
 * GPU back into slumber.
 */
static void adreno_input_work(struct work_struct *work)
{
	struct adreno_device *adreno_dev = container_of(work,
			struct adreno_device, input_work);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	const struct adreno_power_ops *ops = ADRENO_POWER_OPS(adreno_dev);

	kgsl_mutex_lock(&device->mutex);

	device->pwrctrl.wake_on_touch = true;

	ops->touch_wakeup(adreno_dev);

	kgsl_mutex_unlock(&device->mutex);
}

/* Wake up the touch event kworker to initiate GPU wakeup */
void adreno_touch_wake(struct kgsl_device *device)
{
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);

	/*
	 * Don't do anything if anything hasn't been rendered since we've been
	 * here before
	 */


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:1430 [MATCH: mutex_lock] ---
	int ret = 0;

	/*
	 * The L3 vote setup is performed only once. Once set up is done, it is
	 * safe to access num_l3_pwrlevels without acquiring the device mutex.
	 * Therefore, an early check can be added without taking the mutex.
	 */
	if (READ_ONCE(device->num_l3_pwrlevels))
		return ret;

	kgsl_mutex_lock(&device->mutex);

	if (!device->l3_vote)
		goto done;

	/* Verify again if the L3 vote is set up to handle races */
	if (device->num_l3_pwrlevels)
		goto done;

	memset(device->l3_freq, 0x0, sizeof(device->l3_freq));

	ret = qcom_dcvs_register_voter(KGSL_L3_DEVICE, DCVS_L3, DCVS_SLOW_PATH);
	if (ret) {
		dev_err_once(&device->pdev->dev,
			"Unable to register l3 dcvs voter: %d\n", ret);
		goto done;
	}

	ret = qcom_dcvs_hw_minmax_get(DCVS_L3, &device->l3_freq[1],

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2257 [MATCH: mutex_lock] ---
	}

	if (kgsl_regmap_add_region(&device->regmap, pdev, "isense_cntl", -EINVAL, NULL, NULL) == 0)
		adreno_dev->isense_reg_mapped = true;

	/* Allocate the memstore for storing timestamps and other useful info */

	if (ADRENO_FEATURE(adreno_dev, ADRENO_APRIV))
		priv |= KGSL_MEMDESC_PRIVILEGED;

	kgsl_mutex_lock(&device->mutex);
	device->memstore = kgsl_allocate_global(device,
		KGSL_MEMSTORE_SIZE, 0, 0, priv, "memstore");
	adreno_profile_init(adreno_dev);
	kgsl_mutex_unlock(&device->mutex);

	status = PTR_ERR_OR_ZERO(device->memstore);
	if (status) {
		trace_array_put(device->fence_trace_array);
		kgsl_device_platform_remove(device);
		goto err_unbind;
	}

	/* Initialize UBWC mode and HBB */
	status = adreno_init_ubwc(adreno_dev);
	if (status) {
		trace_array_put(device->fence_trace_array);
		kgsl_device_platform_remove(device);
		goto err_unbind;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2488 [MATCH: mutex_lock] ---
	struct kgsl_device *device = dev_get_drvdata(dev);
	struct adreno_device *adreno_dev;
	const struct adreno_power_ops *ops;

	if (!device)
		return 0;

	adreno_dev = ADRENO_DEVICE(device);
	ops = ADRENO_POWER_OPS(adreno_dev);

	kgsl_mutex_lock(&device->mutex);
#if IS_ENABLED(CONFIG_DEEPSLEEP)
	if (pm_suspend_via_firmware())
		device->mmu.iommu.smmu_aperture_set = false;
#endif
	ops->pm_resume(adreno_dev);
	kgsl_mutex_unlock(&device->mutex);

	kgsl_reclaim_start();
	return 0;
}

static int adreno_suspend(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int status = kgsl_pwrctrl_change_state(device, KGSL_STATE_SUSPEND);

	if (!status && device->state == KGSL_STATE_SUSPEND)
		adreno_get_gpu_halt(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2528 [MATCH: mutex_lock] ---
	if (!device)
		return 0;

	adreno_dev = ADRENO_DEVICE(device);
	ops = ADRENO_POWER_OPS(adreno_dev);

	/* Return early if fault recovery is in progress */
	if (!mutex_trylock(&adreno_dev->fault_recovery_mutex))
		return -EDEADLK;

	kgsl_mutex_lock(&device->mutex);
	status = ops->pm_suspend(adreno_dev);

#if IS_ENABLED(CONFIG_DEEPSLEEP)
	if (!status && pm_suspend_via_firmware())
		adreno_zap_shader_unload(adreno_dev);
#endif

	kgsl_mutex_unlock(&device->mutex);
	mutex_unlock(&adreno_dev->fault_recovery_mutex);

	if (status)
		return status;

	/*
	 * When the device enters in suspend state, the CX can be collapsed causing
	 * the GPU CX timer to pause. Clear the ADRENO_DEVICE_CX_TIMER_INITIALIZED
	 * flag to ensure that the CX timer is reseeded during resume.
	 */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2723 [MATCH: mutex_lock] ---
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int ret = 0;

	if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex)))
		return -EINVAL;

	if ((atomic_read(&device->active_cnt) == 0) &&
		(device->state != KGSL_STATE_ACTIVE)) {
		kgsl_mutex_unlock(&device->mutex);
		wait_for_completion(&device->hwaccess_gate);
		kgsl_mutex_lock(&device->mutex);
		device->pwrctrl.superfast = true;
		ret = kgsl_pwrctrl_change_state(device, KGSL_STATE_ACTIVE);
	}
	if (ret == 0)
		atomic_inc(&device->active_cnt);
	trace_kgsl_active_count(device,
		(unsigned long) __builtin_return_address(0));
	return ret;
}

void adreno_active_count_put(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex)))
		return;

	if (WARN(atomic_read(&device->active_cnt) == 0,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:3471 [MATCH: mutex_lock] ---

	if (type != KGSL_PROP_PWRCTRL)
		return -ENODEV;

	if (sizebytes != sizeof(enable))
		return -EINVAL;

	if (copy_from_user(&enable, value, sizeof(enable)))
		return -EFAULT;

	kgsl_mutex_lock(&device->mutex);

	if (enable) {
		if (gmu_core_isenabled(device))
			clear_bit(GMU_DISABLE_SLUMBER, &device->gmu_core.flags);
		else
			device->pwrctrl.ctrl_flags = 0;

		if (device->host_based_dcvs)
			kgsl_pwrscale_governor_enable(device);
		else
			device->ftbl->gmu_based_dcvs_pwr_ops(device, enable,
					GPU_PWRLEVEL_OP_DCVS_ENABLE);
	} else {
		if (gmu_core_isenabled(device)) {
			set_bit(GMU_DISABLE_SLUMBER, &device->gmu_core.flags);

			if (!adreno_active_count_get(adreno_dev))
				adreno_active_count_put(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:3549 [MATCH: mutex_lock] ---
	struct kgsl_memdesc *md = &proc_priv->profile.md;
	struct kgsl_dcvs_profile param = {0};
	struct kgsl_dcvs_attrs attrs;
	u32 size;
	int ret = 0;

	if (!ADRENO_FEATURE(adreno_dev, ADRENO_DCVS_PROFILE))
		return -EOPNOTSUPP;

	/* Restrict to one profile per process */
	mutex_lock(&proc_priv->profile.profile_mutex);
	if (proc_priv->profile.user_profile_registered) {
		ret = -EINVAL;
		goto done;
	}

	/* Not enough allocated GMU memory */
	if ((!md->hostptr) || (sizeof(attrs) > (md->size >> 1))) {
		ret = -ENOMEM;
		goto done;
	}

	size = min_t(u32, sizeof(param), sizebytes);
	if (copy_from_user(&param, data, size)) {
		ret = -EFAULT;
		goto done;
	}

	/*

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:3581 [MATCH: mutex_lock] ---
	 */
	size = min_t(u32, sizeof(attrs), param.attrs_size);

	if (copy_from_user(md->hostptr, u64_to_user_ptr(param.attrs), size)) {
		memset(md->hostptr, KGSL_DCVS_ATTR_UNUSED, size);
		ret = -EFAULT;
		goto done;
	}

	if (hwsched_ops->set_dcvs_profile && adreno_dev->dcvs_profile_enabled) {
		kgsl_mutex_lock(&device->mutex);
		ret = hwsched_ops->set_dcvs_profile(adreno_dev, proc_priv);
		kgsl_mutex_unlock(&device->mutex);
	}

done:
	mutex_unlock(&proc_priv->profile.profile_mutex);
	return ret;
}

static int adreno_setproperty(struct kgsl_device_private *dev_priv,
				unsigned int type,
				void __user *value,
				unsigned int sizebytes)
{
	int status = -EINVAL;
	struct kgsl_device *device = dev_priv->device;

	switch (type) {

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:4072 [MATCH: mutex_lock] ---
 */
static void adreno_device_private_destroy(struct kgsl_device_private *dev_priv)
{
	struct kgsl_device *device = dev_priv->device;
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	struct adreno_device_private *adreno_priv =
		container_of(dev_priv, struct adreno_device_private,
		dev_priv);
	struct adreno_perfcounter_list_node *p, *tmp;

	kgsl_mutex_lock(&device->mutex);
	list_for_each_entry_safe(p, tmp, &adreno_priv->perfcounter_list, node) {
		adreno_perfcounter_put(adreno_dev, p->groupid,
					p->countable, PERFCOUNTER_FLAG_NONE);
		list_del(&p->node);
		kfree(p);
	}
	kgsl_mutex_unlock(&device->mutex);

	kfree(adreno_priv);
}

/**
 * adreno_power_stats() - Reads the counters needed for freq decisions
 * @device: Pointer to device whose counters are read
 * @stats: Pointer to stats set that needs updating
 * Power: The caller is expected to be in a clock enabled state as this
 * function does reg reads
 */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:4248 [MATCH: mutex_lock] ---
	if (!ADRENO_FEATURE(adreno_dev, ADRENO_LSR))
		return -EOPNOTSUPP;

	if (!gpudev->send_recurring_cmdobj)
		return -ENODEV;

	ret = adreno_verify_cmdobj(dev_priv, context, &drawobj, 1);
	if (ret)
		return ret;

	kgsl_mutex_lock(&device->mutex);

	/* Only one recurring command allowed */
	if (hwsched->recurring_cmdobj) {
		kgsl_mutex_unlock(&device->mutex);
		return -EINVAL;
	}

	ret = kgsl_check_context_state(context);
	if (ret) {
		kgsl_mutex_unlock(&device->mutex);
		return ret;
	}

	set_bit(CMDOBJ_RECURRING_START, &cmdobj->priv);

	ret = gpudev->send_recurring_cmdobj(adreno_dev, cmdobj);
	kgsl_mutex_unlock(&device->mutex);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:4288 [MATCH: mutex_lock] ---
	const struct adreno_gpudev *gpudev  = ADRENO_GPU_DEVICE(adreno_dev);
	struct kgsl_drawobj *recurring_drawobj;
	int ret;

	if (!ADRENO_FEATURE(adreno_dev, ADRENO_LSR))
		return -EOPNOTSUPP;

	if (!gpudev->send_recurring_cmdobj)
		return -ENODEV;

	kgsl_mutex_lock(&device->mutex);

	/* We can safely return here as recurring wokload is already untracked */
	if (hwsched->recurring_cmdobj == NULL) {
		kgsl_mutex_unlock(&device->mutex);
		return -EINVAL;
	}

	recurring_drawobj = DRAWOBJ(hwsched->recurring_cmdobj);

	/* Check if the recurring command is for same context or not*/
	if (recurring_drawobj->context != context) {
		kgsl_mutex_unlock(&device->mutex);
		return -EINVAL;
	}

	ret = kgsl_check_context_state(context);
	if (ret) {
		kgsl_mutex_unlock(&device->mutex);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:4371 [MATCH: mutex_lock] ---
}

int adreno_power_cycle(struct adreno_device *adreno_dev,
	void (*callback)(struct adreno_device *adreno_dev, void *priv),
	void *priv)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	const struct adreno_power_ops *ops = ADRENO_POWER_OPS(adreno_dev);
	int ret;

	kgsl_mutex_lock(&device->mutex);
	ret = ops->pm_suspend(adreno_dev);

	if (!ret) {
		callback(adreno_dev, priv);
		gmu_core_mark_for_coldboot(device);
		ops->pm_resume(adreno_dev);
	}

	kgsl_mutex_unlock(&device->mutex);

	return ret;
}

struct cycle_data {
	void *ptr;
	void *val;
};


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:4993 [MATCH: mutex_lock] ---
	struct adreno_device *adreno_dev;
	const struct adreno_power_ops *ops;
	int status;

	if (!device)
		return 0;

	adreno_dev = ADRENO_DEVICE(device);
	ops = ADRENO_POWER_OPS(adreno_dev);

	kgsl_mutex_lock(&device->mutex);

	status = ops->pm_suspend(adreno_dev);
	if (status)
		goto err;

	/*
	 * When the device enters in hibernation state, the CX will be collapsed causing
	 * the GPU CX timer to pause. Clear the ADRENO_DEVICE_CX_TIMER_INITIALIZED flag
	 * to ensure that the CX timer is reseeded during resume.
	 */
	clear_bit(ADRENO_DEVICE_CX_TIMER_INITIALIZED, &adreno_dev->priv);

	/*
	 * Unload zap shader during device hibernation and reload it
	 * during resume as there is possibility that TZ driver
	 * is not aware of the hibernation.
	 */
	adreno_zap_shader_unload(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:5044 [MATCH: mutex_lock] ---
	int ret;

	if (!device)
		return 0;

	iommu = &device->mmu.iommu;
	pwrscale = &device->pwrscale;
	adreno_dev = ADRENO_DEVICE(device);
	ops = ADRENO_POWER_OPS(adreno_dev);

	kgsl_mutex_lock(&device->mutex);

	ret = adreno_secure_pt_restore(adreno_dev);
	if (ret)
		goto err;

	iommu->smmu_aperture_set = false;

	gmu_core_dev_force_first_boot(device);

	governor_reinit(pwrscale->devfreqptr, CONFIG_QCOM_ADRENO_DEFAULT_GOVERNOR);

	ops->pm_resume(adreno_dev);

err:
	kgsl_mutex_unlock(&device->mutex);
	return ret;
}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:499 [MATCH: mutex_unlock] ---
			struct adreno_device, input_work);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	const struct adreno_power_ops *ops = ADRENO_POWER_OPS(adreno_dev);

	kgsl_mutex_lock(&device->mutex);

	device->pwrctrl.wake_on_touch = true;

	ops->touch_wakeup(adreno_dev);

	kgsl_mutex_unlock(&device->mutex);
}

/* Wake up the touch event kworker to initiate GPU wakeup */
void adreno_touch_wake(struct kgsl_device *device)
{
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);

	/*
	 * Don't do anything if anything hasn't been rendered since we've been
	 * here before
	 */

	if (device->pwrctrl.wake_on_touch)
		return;

	if (device->state == KGSL_STATE_SLUMBER)
		schedule_work(&adreno_dev->input_work);
}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:1462 [MATCH: mutex_unlock] ---
			"Unable to get min/max for l3 dcvs: %d\n", ret);
		qcom_dcvs_unregister_voter(KGSL_L3_DEVICE, DCVS_L3,
			DCVS_SLOW_PATH);
		memset(device->l3_freq, 0x0, sizeof(device->l3_freq));
		goto done;
	}

	WRITE_ONCE(device->num_l3_pwrlevels, 3);

done:
	kgsl_mutex_unlock(&device->mutex);

	return ret;
}

static int adreno_of_get_power(struct adreno_device *adreno_dev,
		struct platform_device *pdev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct device_node *node;
	int ret;

	node = of_parse_phandle(pdev->dev.of_node, "operating-points-v2", 0);

	if (node && of_device_is_compatible(node, "operating-points-v2")) {
		ret = adreno_of_parse_pwrlevels(adreno_dev);
		if (!ret)
			adreno_of_get_limits(adreno_dev, node);
	} else

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2261 [MATCH: mutex_unlock] ---

	/* Allocate the memstore for storing timestamps and other useful info */

	if (ADRENO_FEATURE(adreno_dev, ADRENO_APRIV))
		priv |= KGSL_MEMDESC_PRIVILEGED;

	kgsl_mutex_lock(&device->mutex);
	device->memstore = kgsl_allocate_global(device,
		KGSL_MEMSTORE_SIZE, 0, 0, priv, "memstore");
	adreno_profile_init(adreno_dev);
	kgsl_mutex_unlock(&device->mutex);

	status = PTR_ERR_OR_ZERO(device->memstore);
	if (status) {
		trace_array_put(device->fence_trace_array);
		kgsl_device_platform_remove(device);
		goto err_unbind;
	}

	/* Initialize UBWC mode and HBB */
	status = adreno_init_ubwc(adreno_dev);
	if (status) {
		trace_array_put(device->fence_trace_array);
		kgsl_device_platform_remove(device);
		goto err_unbind;
	}

	/* Initialize the snapshot engine */
	size = adreno_dev->gpucore->snapshot_size;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2494 [MATCH: mutex_unlock] ---

	adreno_dev = ADRENO_DEVICE(device);
	ops = ADRENO_POWER_OPS(adreno_dev);

	kgsl_mutex_lock(&device->mutex);
#if IS_ENABLED(CONFIG_DEEPSLEEP)
	if (pm_suspend_via_firmware())
		device->mmu.iommu.smmu_aperture_set = false;
#endif
	ops->pm_resume(adreno_dev);
	kgsl_mutex_unlock(&device->mutex);

	kgsl_reclaim_start();
	return 0;
}

static int adreno_suspend(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int status = kgsl_pwrctrl_change_state(device, KGSL_STATE_SUSPEND);

	if (!status && device->state == KGSL_STATE_SUSPEND)
		adreno_get_gpu_halt(adreno_dev);

	return status;
}

static int adreno_pm_suspend(struct device *dev)
{

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2536 [MATCH: mutex_unlock] ---
		return -EDEADLK;

	kgsl_mutex_lock(&device->mutex);
	status = ops->pm_suspend(adreno_dev);

#if IS_ENABLED(CONFIG_DEEPSLEEP)
	if (!status && pm_suspend_via_firmware())
		adreno_zap_shader_unload(adreno_dev);
#endif

	kgsl_mutex_unlock(&device->mutex);
	mutex_unlock(&adreno_dev->fault_recovery_mutex);

	if (status)
		return status;

	/*
	 * When the device enters in suspend state, the CX can be collapsed causing
	 * the GPU CX timer to pause. Clear the ADRENO_DEVICE_CX_TIMER_INITIALIZED
	 * flag to ensure that the CX timer is reseeded during resume.
	 */
	clear_bit(ADRENO_DEVICE_CX_TIMER_INITIALIZED, &adreno_dev->priv);
	kgsl_reclaim_close();
	kthread_flush_worker(device->events_worker);
	flush_workqueue(kgsl_driver.lockless_workqueue);

	return status;
}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2537 [MATCH: mutex_unlock] ---

	kgsl_mutex_lock(&device->mutex);
	status = ops->pm_suspend(adreno_dev);

#if IS_ENABLED(CONFIG_DEEPSLEEP)
	if (!status && pm_suspend_via_firmware())
		adreno_zap_shader_unload(adreno_dev);
#endif

	kgsl_mutex_unlock(&device->mutex);
	mutex_unlock(&adreno_dev->fault_recovery_mutex);

	if (status)
		return status;

	/*
	 * When the device enters in suspend state, the CX can be collapsed causing
	 * the GPU CX timer to pause. Clear the ADRENO_DEVICE_CX_TIMER_INITIALIZED
	 * flag to ensure that the CX timer is reseeded during resume.
	 */
	clear_bit(ADRENO_DEVICE_CX_TIMER_INITIALIZED, &adreno_dev->priv);
	kgsl_reclaim_close();
	kthread_flush_worker(device->events_worker);
	flush_workqueue(kgsl_driver.lockless_workqueue);

	return status;
}

void adreno_create_profile_buffer(struct adreno_device *adreno_dev)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:2721 [MATCH: mutex_unlock] ---
static int adreno_pwrctrl_active_count_get(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int ret = 0;

	if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex)))
		return -EINVAL;

	if ((atomic_read(&device->active_cnt) == 0) &&
		(device->state != KGSL_STATE_ACTIVE)) {
		kgsl_mutex_unlock(&device->mutex);
		wait_for_completion(&device->hwaccess_gate);
		kgsl_mutex_lock(&device->mutex);
		device->pwrctrl.superfast = true;
		ret = kgsl_pwrctrl_change_state(device, KGSL_STATE_ACTIVE);
	}
	if (ret == 0)
		atomic_inc(&device->active_cnt);
	trace_kgsl_active_count(device,
		(unsigned long) __builtin_return_address(0));
	return ret;
}

void adreno_active_count_put(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	if (WARN_ON(!kgsl_mutex_is_locked(&device->mutex)))
		return;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:3503 [MATCH: mutex_unlock] ---
		}
		if (device->host_based_dcvs) {
			kgsl_pwrscale_governor_disable(device, true);
		} else {
			device->ftbl->gmu_based_dcvs_pwr_ops(device, enable,
					GPU_PWRLEVEL_OP_DCVS_ENABLE);
			device->ftbl->gmu_based_dcvs_pwr_ops(device, 0, GPU_PWRLEVEL_OP_GPUCLK);
		}
	}

	kgsl_mutex_unlock(&device->mutex);

	return 0;
}

static void adreno_alloc_dcvs_profile_memory(struct kgsl_device *device,
		struct kgsl_process_private *proc_priv)
{
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	struct kgsl_memdesc *md = &proc_priv->profile.md;
	u32 sizebytes;

	if (!ADRENO_FEATURE(adreno_dev, ADRENO_DCVS_PROFILE))
		return;

	if (!gmu_core_alloc_kernel_block(device, md,
			SZ_4K, GMU_NONCACHED_KERNEL,
			IOMMU_READ | IOMMU_WRITE | IOMMU_PRIV)) {
		/* KMD need to initialize KGSL region to KGSL_DCVS_ATTR_UNUSED for

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:3583 [MATCH: mutex_unlock] ---

	if (copy_from_user(md->hostptr, u64_to_user_ptr(param.attrs), size)) {
		memset(md->hostptr, KGSL_DCVS_ATTR_UNUSED, size);
		ret = -EFAULT;
		goto done;
	}

	if (hwsched_ops->set_dcvs_profile && adreno_dev->dcvs_profile_enabled) {
		kgsl_mutex_lock(&device->mutex);
		ret = hwsched_ops->set_dcvs_profile(adreno_dev, proc_priv);
		kgsl_mutex_unlock(&device->mutex);
	}

done:
	mutex_unlock(&proc_priv->profile.profile_mutex);
	return ret;
}

static int adreno_setproperty(struct kgsl_device_private *dev_priv,
				unsigned int type,
				void __user *value,
				unsigned int sizebytes)
{
	int status = -EINVAL;
	struct kgsl_device *device = dev_priv->device;

	switch (type) {
	case KGSL_PROP_PWR_CONSTRAINT:
	case KGSL_PROP_L3_PWR_CONSTRAINT: {

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:3587 [MATCH: mutex_unlock] ---
		goto done;
	}

	if (hwsched_ops->set_dcvs_profile && adreno_dev->dcvs_profile_enabled) {
		kgsl_mutex_lock(&device->mutex);
		ret = hwsched_ops->set_dcvs_profile(adreno_dev, proc_priv);
		kgsl_mutex_unlock(&device->mutex);
	}

done:
	mutex_unlock(&proc_priv->profile.profile_mutex);
	return ret;
}

static int adreno_setproperty(struct kgsl_device_private *dev_priv,
				unsigned int type,
				void __user *value,
				unsigned int sizebytes)
{
	int status = -EINVAL;
	struct kgsl_device *device = dev_priv->device;

	switch (type) {
	case KGSL_PROP_PWR_CONSTRAINT:
	case KGSL_PROP_L3_PWR_CONSTRAINT: {
			struct kgsl_device_constraint constraint;
			struct kgsl_context *context;

			if (sizebytes != sizeof(constraint))

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:4079 [MATCH: mutex_unlock] ---
		dev_priv);
	struct adreno_perfcounter_list_node *p, *tmp;

	kgsl_mutex_lock(&device->mutex);
	list_for_each_entry_safe(p, tmp, &adreno_priv->perfcounter_list, node) {
		adreno_perfcounter_put(adreno_dev, p->groupid,
					p->countable, PERFCOUNTER_FLAG_NONE);
		list_del(&p->node);
		kfree(p);
	}
	kgsl_mutex_unlock(&device->mutex);

	kfree(adreno_priv);
}

/**
 * adreno_power_stats() - Reads the counters needed for freq decisions
 * @device: Pointer to device whose counters are read
 * @stats: Pointer to stats set that needs updating
 * Power: The caller is expected to be in a clock enabled state as this
 * function does reg reads
 */
static void adreno_power_stats(struct kgsl_device *device,
				struct kgsl_power_stats *stats)
{
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	const struct adreno_gpudev *gpudev  = ADRENO_GPU_DEVICE(adreno_dev);

	return gpudev->power_stats(adreno_dev, stats);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:4252 [MATCH: mutex_unlock] ---
		return -ENODEV;

	ret = adreno_verify_cmdobj(dev_priv, context, &drawobj, 1);
	if (ret)
		return ret;

	kgsl_mutex_lock(&device->mutex);

	/* Only one recurring command allowed */
	if (hwsched->recurring_cmdobj) {
		kgsl_mutex_unlock(&device->mutex);
		return -EINVAL;
	}

	ret = kgsl_check_context_state(context);
	if (ret) {
		kgsl_mutex_unlock(&device->mutex);
		return ret;
	}

	set_bit(CMDOBJ_RECURRING_START, &cmdobj->priv);

	ret = gpudev->send_recurring_cmdobj(adreno_dev, cmdobj);
	kgsl_mutex_unlock(&device->mutex);

	if (!ret)
		srcu_notifier_call_chain(&device->nh, GPU_GMU_READY, NULL);

	return ret;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:4258 [MATCH: mutex_unlock] ---
	kgsl_mutex_lock(&device->mutex);

	/* Only one recurring command allowed */
	if (hwsched->recurring_cmdobj) {
		kgsl_mutex_unlock(&device->mutex);
		return -EINVAL;
	}

	ret = kgsl_check_context_state(context);
	if (ret) {
		kgsl_mutex_unlock(&device->mutex);
		return ret;
	}

	set_bit(CMDOBJ_RECURRING_START, &cmdobj->priv);

	ret = gpudev->send_recurring_cmdobj(adreno_dev, cmdobj);
	kgsl_mutex_unlock(&device->mutex);

	if (!ret)
		srcu_notifier_call_chain(&device->nh, GPU_GMU_READY, NULL);

	return ret;
}

static int adreno_dequeue_recurring_cmd(struct kgsl_device *device,
	struct kgsl_context *context)
{
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:4265 [MATCH: mutex_unlock] ---

	ret = kgsl_check_context_state(context);
	if (ret) {
		kgsl_mutex_unlock(&device->mutex);
		return ret;
	}

	set_bit(CMDOBJ_RECURRING_START, &cmdobj->priv);

	ret = gpudev->send_recurring_cmdobj(adreno_dev, cmdobj);
	kgsl_mutex_unlock(&device->mutex);

	if (!ret)
		srcu_notifier_call_chain(&device->nh, GPU_GMU_READY, NULL);

	return ret;
}

static int adreno_dequeue_recurring_cmd(struct kgsl_device *device,
	struct kgsl_context *context)
{
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	struct adreno_hwsched *hwsched = &adreno_dev->hwsched;
	const struct adreno_gpudev *gpudev  = ADRENO_GPU_DEVICE(adreno_dev);
	struct kgsl_drawobj *recurring_drawobj;
	int ret;

	if (!ADRENO_FEATURE(adreno_dev, ADRENO_LSR))
		return -EOPNOTSUPP;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:4292 [MATCH: mutex_unlock] ---
	if (!ADRENO_FEATURE(adreno_dev, ADRENO_LSR))
		return -EOPNOTSUPP;

	if (!gpudev->send_recurring_cmdobj)
		return -ENODEV;

	kgsl_mutex_lock(&device->mutex);

	/* We can safely return here as recurring wokload is already untracked */
	if (hwsched->recurring_cmdobj == NULL) {
		kgsl_mutex_unlock(&device->mutex);
		return -EINVAL;
	}

	recurring_drawobj = DRAWOBJ(hwsched->recurring_cmdobj);

	/* Check if the recurring command is for same context or not*/
	if (recurring_drawobj->context != context) {
		kgsl_mutex_unlock(&device->mutex);
		return -EINVAL;
	}

	ret = kgsl_check_context_state(context);
	if (ret) {
		kgsl_mutex_unlock(&device->mutex);
		return ret;
	}

	clear_bit(CMDOBJ_RECURRING_START, &hwsched->recurring_cmdobj->priv);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:4300 [MATCH: mutex_unlock] ---
	/* We can safely return here as recurring wokload is already untracked */
	if (hwsched->recurring_cmdobj == NULL) {
		kgsl_mutex_unlock(&device->mutex);
		return -EINVAL;
	}

	recurring_drawobj = DRAWOBJ(hwsched->recurring_cmdobj);

	/* Check if the recurring command is for same context or not*/
	if (recurring_drawobj->context != context) {
		kgsl_mutex_unlock(&device->mutex);
		return -EINVAL;
	}

	ret = kgsl_check_context_state(context);
	if (ret) {
		kgsl_mutex_unlock(&device->mutex);
		return ret;
	}

	clear_bit(CMDOBJ_RECURRING_START, &hwsched->recurring_cmdobj->priv);
	set_bit(CMDOBJ_RECURRING_STOP, &hwsched->recurring_cmdobj->priv);

	ret = gpudev->send_recurring_cmdobj(adreno_dev, hwsched->recurring_cmdobj);

	kgsl_mutex_unlock(&device->mutex);

	if (!ret)
		srcu_notifier_call_chain(&device->nh, GPU_GMU_STOP, NULL);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:4306 [MATCH: mutex_unlock] ---
	recurring_drawobj = DRAWOBJ(hwsched->recurring_cmdobj);

	/* Check if the recurring command is for same context or not*/
	if (recurring_drawobj->context != context) {
		kgsl_mutex_unlock(&device->mutex);
		return -EINVAL;
	}

	ret = kgsl_check_context_state(context);
	if (ret) {
		kgsl_mutex_unlock(&device->mutex);
		return ret;
	}

	clear_bit(CMDOBJ_RECURRING_START, &hwsched->recurring_cmdobj->priv);
	set_bit(CMDOBJ_RECURRING_STOP, &hwsched->recurring_cmdobj->priv);

	ret = gpudev->send_recurring_cmdobj(adreno_dev, hwsched->recurring_cmdobj);

	kgsl_mutex_unlock(&device->mutex);

	if (!ret)
		srcu_notifier_call_chain(&device->nh, GPU_GMU_STOP, NULL);

	return ret;
}

static void adreno_set_isdb_breakpoint_registers(struct kgsl_device *device)
{

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:4315 [MATCH: mutex_unlock] ---
	if (ret) {
		kgsl_mutex_unlock(&device->mutex);
		return ret;
	}

	clear_bit(CMDOBJ_RECURRING_START, &hwsched->recurring_cmdobj->priv);
	set_bit(CMDOBJ_RECURRING_STOP, &hwsched->recurring_cmdobj->priv);

	ret = gpudev->send_recurring_cmdobj(adreno_dev, hwsched->recurring_cmdobj);

	kgsl_mutex_unlock(&device->mutex);

	if (!ret)
		srcu_notifier_call_chain(&device->nh, GPU_GMU_STOP, NULL);

	return ret;
}

static void adreno_set_isdb_breakpoint_registers(struct kgsl_device *device)
{
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	const struct adreno_gpudev *gpudev  = ADRENO_GPU_DEVICE(adreno_dev);

	if (gpudev->set_isdb_breakpoint_registers)
		gpudev->set_isdb_breakpoint_registers(adreno_dev);
}

static void adreno_drawctxt_sched(struct kgsl_device *device,
		struct kgsl_context *context)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:4380 [MATCH: mutex_unlock] ---

	kgsl_mutex_lock(&device->mutex);
	ret = ops->pm_suspend(adreno_dev);

	if (!ret) {
		callback(adreno_dev, priv);
		gmu_core_mark_for_coldboot(device);
		ops->pm_resume(adreno_dev);
	}

	kgsl_mutex_unlock(&device->mutex);

	return ret;
}

struct cycle_data {
	void *ptr;
	void *val;
};

static void cycle_set_bool(struct adreno_device *adreno_dev, void *priv)
{
	struct cycle_data *data = priv;

	*((bool *) data->ptr) = *((bool *) data->val);
}

int adreno_power_cycle_bool(struct adreno_device *adreno_dev,
	bool *flag, bool val)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:5015 [MATCH: mutex_unlock] ---

	/*
	 * Unload zap shader during device hibernation and reload it
	 * during resume as there is possibility that TZ driver
	 * is not aware of the hibernation.
	 */
	adreno_zap_shader_unload(adreno_dev);
	status = adreno_secure_pt_hibernate(adreno_dev);

err:
	kgsl_mutex_unlock(&device->mutex);
	return status;
}

static int governor_reinit(struct devfreq *devfreq, const char *governor)
{
	if (governor && !strcmp(governor, "msm-adreno-tz"))
		return msm_adreno_tz_reinit(devfreq);

	return 0;
}

static int adreno_hibernation_resume(struct device *dev)
{
	struct kgsl_device *device = dev_get_drvdata(dev);
	struct kgsl_iommu *iommu;
	struct kgsl_pwrscale *pwrscale;
	struct adreno_device *adreno_dev;
	const struct adreno_power_ops *ops;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:5059 [MATCH: mutex_unlock] ---

	iommu->smmu_aperture_set = false;

	gmu_core_dev_force_first_boot(device);

	governor_reinit(pwrscale->devfreqptr, CONFIG_QCOM_ADRENO_DEFAULT_GOVERNOR);

	ops->pm_resume(adreno_dev);

err:
	kgsl_mutex_unlock(&device->mutex);
	return ret;
}

static const struct dev_pm_ops adreno_pm_ops = {
	.suspend  = adreno_pm_suspend,
	.resume = adreno_pm_resume,
	.freeze = adreno_hibernation_suspend,
	.thaw = adreno_hibernation_resume,
	.poweroff = adreno_hibernation_suspend,
	.restore = adreno_hibernation_resume,
};
#else
static const struct dev_pm_ops adreno_pm_ops = {
	SET_SYSTEM_SLEEP_PM_OPS(adreno_pm_suspend, adreno_pm_resume)
};
#endif /* IS_ENABLED(CONFIG_QCOM_KGSL_HIBERNATION) */

static struct platform_driver adreno_platform_driver = {

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.c:1839 [MATCH: spin_lock] ---
	/* Set the fault tolerance policy to replay, skip, throttle */
	adreno_dev->ft_policy = BIT(KGSL_FT_REPLAY) |
		BIT(KGSL_FT_SKIPCMD) | BIT(KGSL_FT_THROTTLE);

	/* Enable command timeouts by default */
	adreno_dev->long_ib_detect = true;

	INIT_WORK(&adreno_dev->input_work, adreno_input_work);

	INIT_LIST_HEAD(&adreno_dev->active_list);
	spin_lock_init(&adreno_dev->active_list_lock);
	rwlock_init(&adreno_dev->fault_stats_lock);

	for (i = 0; i < ARRAY_SIZE(adreno_dev->ringbuffers); i++) {
		struct adreno_ringbuffer *rb = &adreno_dev->ringbuffers[i];

		INIT_LIST_HEAD(&rb->events.group);
	}

	/*
	 * Some GPUs needs specific alignment for UCHE GMEM base address.
	 * Configure UCHE GMEM base based on GMEM size and align it accordingly.
	 * This needs to be done based on GMEM size to avoid overlap between
	 * RB and UCHE GMEM range.
	 */
	if (adreno_dev->gpucore->uche_gmem_alignment)
		adreno_dev->uche_gmem_base =
			ALIGN(adreno_dev->gpucore->gmem_size,
				adreno_dev->gpucore->uche_gmem_alignment);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.h:244 [MATCH: timeout] ---
#define CMD_INTERNAL_IDENTIFIER		0x2EEDD00D
#define START_IB_IDENTIFIER		0x2EADEABE
#define END_IB_IDENTIFIER		0x2ABEDEAD
#define START_PROFILE_IDENTIFIER	0x2DEFADE1
#define END_PROFILE_IDENTIFIER		0x2DEFADE2
#define PWRON_FIXUP_IDENTIFIER		0x2AFAFAFA

/* One cannot wait forever for the core to idle, so set an upper limit to the
 * amount of time to wait for the core to go idle
 */
#define ADRENO_IDLE_TIMEOUT (20 * 1000)

#define ADRENO_FW_PFP 0
#define ADRENO_FW_SQE 0
#define ADRENO_FW_PM4 1
#define ADRENO_FW_AQE 1

#define ADRENO_GPUREV_VALUE(_major, _minor, _patchid) (((_major & 0xFF) << 16) | \
						       ((_minor & 0xFF) << 8) | \
						       (_patchid & 0xFF))
enum adreno_gpurev {
	ADRENO_REV_UNKNOWN = 0,
	ADRENO_REV_A304 = 304,
	ADRENO_REV_A305 = 305,
	ADRENO_REV_A305C = 306,
	ADRENO_REV_A306 = 307,
	ADRENO_REV_A306A = 308,
	ADRENO_REV_A310 = 310,
	ADRENO_REV_A320 = 320,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.h:339 [MATCH: timeout] ---
	ADRENO_REV_GEN8_8_0 = ADRENO_GPUREV_VALUE(8, 8, 0),
	ADRENO_REV_GEN8_9_0 = ADRENO_GPUREV_VALUE(8, 9, 0),
	ADRENO_REV_GEN8_10_0 = ADRENO_GPUREV_VALUE(8, 10, 0),
	ADRENO_REV_GEN8_11_0 = ADRENO_GPUREV_VALUE(8, 11, 0),
	ADRENO_REV_GEN8_11_1 = ADRENO_GPUREV_VALUE(8, 11, 1),
	ADRENO_REV_GEN8_14_0 = ADRENO_GPUREV_VALUE(8, 14, 0),
};

#define ADRENO_SOFT_FAULT BIT(0)
#define ADRENO_HARD_FAULT BIT(1)
#define ADRENO_TIMEOUT_FAULT BIT(2)
#define ADRENO_IOMMU_STALL_ON_PAGE_FAULT BIT(3)
#define ADRENO_PREEMPT_FAULT BIT(4)
#define ADRENO_GMU_FAULT BIT(5)
#define ADRENO_CTX_DETATCH_TIMEOUT_FAULT BIT(6)
#define ADRENO_GMU_FAULT_SKIP_SNAPSHOT BIT(7)
#define ADRENO_FAULT_TYPES 8

/**
 * Bit fields for GPU_CX_MISC_CX_AHB_*_CNTL registers
 * AHB_TXFRTIMEOUTRELEASE	[8:8]
 * AHB_TXFRTIMEOUTENABLE	[9:9]
 * AHB_RESPONDERROR		[11:11]
 * AHB_ERRORSTATUSENABLE	[12:12]
 */
#define ADRENO_AHB_CNTL_DEFAULT (BIT(12) | BIT(11) | BIT(9) | BIT(8))

enum adreno_pipe_type {
	PIPE_NONE = 0,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.h:343 [MATCH: timeout] ---
	ADRENO_REV_GEN8_11_1 = ADRENO_GPUREV_VALUE(8, 11, 1),
	ADRENO_REV_GEN8_14_0 = ADRENO_GPUREV_VALUE(8, 14, 0),
};

#define ADRENO_SOFT_FAULT BIT(0)
#define ADRENO_HARD_FAULT BIT(1)
#define ADRENO_TIMEOUT_FAULT BIT(2)
#define ADRENO_IOMMU_STALL_ON_PAGE_FAULT BIT(3)
#define ADRENO_PREEMPT_FAULT BIT(4)
#define ADRENO_GMU_FAULT BIT(5)
#define ADRENO_CTX_DETATCH_TIMEOUT_FAULT BIT(6)
#define ADRENO_GMU_FAULT_SKIP_SNAPSHOT BIT(7)
#define ADRENO_FAULT_TYPES 8

/**
 * Bit fields for GPU_CX_MISC_CX_AHB_*_CNTL registers
 * AHB_TXFRTIMEOUTRELEASE	[8:8]
 * AHB_TXFRTIMEOUTENABLE	[9:9]
 * AHB_RESPONDERROR		[11:11]
 * AHB_ERRORSTATUSENABLE	[12:12]
 */
#define ADRENO_AHB_CNTL_DEFAULT (BIT(12) | BIT(11) | BIT(9) | BIT(8))

enum adreno_pipe_type {
	PIPE_NONE = 0,
	PIPE_BR = 1,
	PIPE_BV = 2,
	PIPE_LPAC = 3,
	PIPE_AQE0 = 4,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.h:349 [MATCH: timeout] ---
#define ADRENO_TIMEOUT_FAULT BIT(2)
#define ADRENO_IOMMU_STALL_ON_PAGE_FAULT BIT(3)
#define ADRENO_PREEMPT_FAULT BIT(4)
#define ADRENO_GMU_FAULT BIT(5)
#define ADRENO_CTX_DETATCH_TIMEOUT_FAULT BIT(6)
#define ADRENO_GMU_FAULT_SKIP_SNAPSHOT BIT(7)
#define ADRENO_FAULT_TYPES 8

/**
 * Bit fields for GPU_CX_MISC_CX_AHB_*_CNTL registers
 * AHB_TXFRTIMEOUTRELEASE	[8:8]
 * AHB_TXFRTIMEOUTENABLE	[9:9]
 * AHB_RESPONDERROR		[11:11]
 * AHB_ERRORSTATUSENABLE	[12:12]
 */
#define ADRENO_AHB_CNTL_DEFAULT (BIT(12) | BIT(11) | BIT(9) | BIT(8))

enum adreno_pipe_type {
	PIPE_NONE = 0,
	PIPE_BR = 1,
	PIPE_BV = 2,
	PIPE_LPAC = 3,
	PIPE_AQE0 = 4,
	PIPE_AQE1 = 5,
	PIPE_DDE_BR = 6,
	PIPE_DDE_BV = 7,
};

/* number of throttle counters for DCVS adjustment */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.h:350 [MATCH: timeout] ---
#define ADRENO_IOMMU_STALL_ON_PAGE_FAULT BIT(3)
#define ADRENO_PREEMPT_FAULT BIT(4)
#define ADRENO_GMU_FAULT BIT(5)
#define ADRENO_CTX_DETATCH_TIMEOUT_FAULT BIT(6)
#define ADRENO_GMU_FAULT_SKIP_SNAPSHOT BIT(7)
#define ADRENO_FAULT_TYPES 8

/**
 * Bit fields for GPU_CX_MISC_CX_AHB_*_CNTL registers
 * AHB_TXFRTIMEOUTRELEASE	[8:8]
 * AHB_TXFRTIMEOUTENABLE	[9:9]
 * AHB_RESPONDERROR		[11:11]
 * AHB_ERRORSTATUSENABLE	[12:12]
 */
#define ADRENO_AHB_CNTL_DEFAULT (BIT(12) | BIT(11) | BIT(9) | BIT(8))

enum adreno_pipe_type {
	PIPE_NONE = 0,
	PIPE_BR = 1,
	PIPE_BV = 2,
	PIPE_LPAC = 3,
	PIPE_AQE0 = 4,
	PIPE_AQE1 = 5,
	PIPE_DDE_BR = 6,
	PIPE_DDE_BV = 7,
};

/* number of throttle counters for DCVS adjustment */
#define ADRENO_GPMU_THROTTLE_COUNTERS 4

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.h:373 [MATCH: timeout] ---
	PIPE_DDE_BR = 6,
	PIPE_DDE_BV = 7,
};

/* number of throttle counters for DCVS adjustment */
#define ADRENO_GPMU_THROTTLE_COUNTERS 4

struct adreno_gpudev;

/* Time to allow preemption to complete (in ms) */
#define ADRENO_PREEMPT_TIMEOUT 10000

#define PREEMPT_SCRATCH_OFFSET(id) (id * sizeof(u64))

#define PREEMPT_SCRATCH_ADDR(dev, id) \
	((dev)->preempt.scratch->gpuaddr + PREEMPT_SCRATCH_OFFSET(id))

/**
 * enum adreno_preempt_states
 * ADRENO_PREEMPT_NONE: No preemption is scheduled
 * ADRENO_PREEMPT_START: The S/W has started
 * ADRENO_PREEMPT_TRIGGERED: A preeempt has been triggered in the HW
 * ADRENO_PREEMPT_FAULTED: The preempt timer has fired
 * ADRENO_PREEMPT_PENDING: The H/W has signaled preemption complete
 * ADRENO_PREEMPT_COMPLETE: Preemption could not be finished in the IRQ handler,
 * worker has been scheduled
 */
enum adreno_preempt_states {
	ADRENO_PREEMPT_NONE = 0,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.h:892 [MATCH: timeout] ---
	/** @ifpc_hyst: IFPC long hysteresis value */
	u32 ifpc_hyst;
	/** @ifpc_hyst_floor: IFPC long hysteresis floor value */
	u32 ifpc_hyst_floor;
	/*
	 * @no_restore_count: Keep track of perfcounter requests that don't have
	 * ADRENO_PERFCOUNTER_GROUP_RESTORE flag set
	 */
	u32 no_restore_count;
	/*
	 * @ahb_timeout_val: AHB transaction timeout value.
	 * If set, a timeout will occur in 2 ^ (ahb_timeout_val + 1) cycles.
	 */
	u32 ahb_timeout_val;
	/** @fault_counts: Keep track of GPU faults */
	u32 fault_counts[ADRENO_FAULT_TYPES];
	/**
	 * @fault_procs: Array to keep track of per process GPU fault count sorted by the number
	 * of GPU faults
	 */
	struct adreno_fault_proc fault_procs[ADRENO_MAX_FAULTING_PROCS];
	/** @fault_stats_lock: A R/W lock to protect GPU fault statistics */
	rwlock_t fault_stats_lock;
	/** @fault_recovery_mutex: Mutex taken during fault handling in the dispatcher */
	struct mutex fault_recovery_mutex;
	/** @pm_nb: Notifier block for defining a callback that gets called during system suspend */
	struct notifier_block pm_nb;
	/** @suspend_recovery_gate: Gate to wait on for system to come out of suspend */
	struct completion suspend_recovery_gate;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.h:893 [MATCH: timeout] ---
	u32 ifpc_hyst;
	/** @ifpc_hyst_floor: IFPC long hysteresis floor value */
	u32 ifpc_hyst_floor;
	/*
	 * @no_restore_count: Keep track of perfcounter requests that don't have
	 * ADRENO_PERFCOUNTER_GROUP_RESTORE flag set
	 */
	u32 no_restore_count;
	/*
	 * @ahb_timeout_val: AHB transaction timeout value.
	 * If set, a timeout will occur in 2 ^ (ahb_timeout_val + 1) cycles.
	 */
	u32 ahb_timeout_val;
	/** @fault_counts: Keep track of GPU faults */
	u32 fault_counts[ADRENO_FAULT_TYPES];
	/**
	 * @fault_procs: Array to keep track of per process GPU fault count sorted by the number
	 * of GPU faults
	 */
	struct adreno_fault_proc fault_procs[ADRENO_MAX_FAULTING_PROCS];
	/** @fault_stats_lock: A R/W lock to protect GPU fault statistics */
	rwlock_t fault_stats_lock;
	/** @fault_recovery_mutex: Mutex taken during fault handling in the dispatcher */
	struct mutex fault_recovery_mutex;
	/** @pm_nb: Notifier block for defining a callback that gets called during system suspend */
	struct notifier_block pm_nb;
	/** @suspend_recovery_gate: Gate to wait on for system to come out of suspend */
	struct completion suspend_recovery_gate;
	/** @scheduler_worker: kthread worker for scheduling gpu commands */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.h:895 [MATCH: timeout] ---
	u32 ifpc_hyst_floor;
	/*
	 * @no_restore_count: Keep track of perfcounter requests that don't have
	 * ADRENO_PERFCOUNTER_GROUP_RESTORE flag set
	 */
	u32 no_restore_count;
	/*
	 * @ahb_timeout_val: AHB transaction timeout value.
	 * If set, a timeout will occur in 2 ^ (ahb_timeout_val + 1) cycles.
	 */
	u32 ahb_timeout_val;
	/** @fault_counts: Keep track of GPU faults */
	u32 fault_counts[ADRENO_FAULT_TYPES];
	/**
	 * @fault_procs: Array to keep track of per process GPU fault count sorted by the number
	 * of GPU faults
	 */
	struct adreno_fault_proc fault_procs[ADRENO_MAX_FAULTING_PROCS];
	/** @fault_stats_lock: A R/W lock to protect GPU fault statistics */
	rwlock_t fault_stats_lock;
	/** @fault_recovery_mutex: Mutex taken during fault handling in the dispatcher */
	struct mutex fault_recovery_mutex;
	/** @pm_nb: Notifier block for defining a callback that gets called during system suspend */
	struct notifier_block pm_nb;
	/** @suspend_recovery_gate: Gate to wait on for system to come out of suspend */
	struct completion suspend_recovery_gate;
	/** @scheduler_worker: kthread worker for scheduling gpu commands */
	struct kthread_worker *scheduler_worker;
	/** @scheduler_work: work_struct to put the gpu command scheduler in a work queue */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.h:948 [MATCH: timeout] ---
	struct adreno_ubwc_props ubwc_props;
	/** @multidraw_mode: Whether PC unroll is enabled for multidraw **/
	u32 multidraw_mode;
	/** @viz_flush_draw_count: Draw count to flush visibility stream **/
	u32 viz_flush_draw_count;
	/** @viz_flush_prim_count: Prim count to flush visibility stream **/
	u32 viz_flush_prim_count;
};

/* Time to wait for suspend recovery gate to complete */
#define ADRENO_SUSPEND_RECOVERY_GATE_TIMEOUT_MS 5000

/**
 * enum adreno_device_flags - Private flags for the adreno_device
 * @ADRENO_DEVICE_PWRON - Set during init after a power collapse
 * @ADRENO_DEVICE_PWRON_FIXUP - Set if the target requires the shader fixup
 * after power collapse
 * @ADRENO_DEVICE_STARTED - Set if the device start sequence is in progress
 * @ADRENO_DEVICE_FAULT - Set if the device is currently in fault (and shouldn't
 * send any more commands to the ringbuffer)
 * @ADRENO_DEVICE_DRAWOBJ_PROFILE - Set if the device supports drawobj
 * profiling via the ALWAYSON counter
 * @ADRENO_DEVICE_PREEMPTION - Turn on/off preemption
 * @ADRENO_DEVICE_SOFT_FAULT_DETECT - Set if soft fault detect is enabled
 * @ADRENO_DEVICE_GPMU_INITIALIZED - Set if GPMU firmware initialization succeed
 * @ADRENO_DEVICE_ISDB_ENABLED - Set if the Integrated Shader DeBugger is
 * attached and enabled
 * @ADRENO_DEVICE_CACHE_FLUSH_TS_SUSPENDED - Set if a CACHE_FLUSH_TS irq storm
 * is in progress

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.h:1243 [MATCH: timeout] ---

extern const struct adreno_power_ops adreno_power_operations;

extern const struct adreno_gpudev adreno_a5xx_gpudev;
extern const struct adreno_gpudev adreno_a6xx_gpudev;
extern const struct adreno_gpudev adreno_a6xx_rgmu_gpudev;
extern const struct adreno_gpudev adreno_a619_holi_gpudev;
extern const struct adreno_gpudev adreno_a611_gpudev;

extern int adreno_wake_nice;
extern unsigned int adreno_wake_timeout;

int adreno_start(struct kgsl_device *device, int priority);
long adreno_ioctl(struct kgsl_device_private *dev_priv,
		unsigned int cmd, unsigned long arg);

long adreno_ioctl_helper(struct kgsl_device_private *dev_priv,
		unsigned int cmd, unsigned long arg,
		const struct kgsl_ioctl *cmds, int len);

int adreno_spin_idle(struct adreno_device *device, unsigned int timeout);
int adreno_wait_idle(struct kgsl_device *device);

int adreno_set_constraint(struct kgsl_device *device,
				struct kgsl_context *context,
				struct kgsl_device_constraint *constraint);

void adreno_snapshot(struct kgsl_device *device,
		struct kgsl_snapshot *snapshot,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.h:1253 [MATCH: timeout] ---
extern unsigned int adreno_wake_timeout;

int adreno_start(struct kgsl_device *device, int priority);
long adreno_ioctl(struct kgsl_device_private *dev_priv,
		unsigned int cmd, unsigned long arg);

long adreno_ioctl_helper(struct kgsl_device_private *dev_priv,
		unsigned int cmd, unsigned long arg,
		const struct kgsl_ioctl *cmds, int len);

int adreno_spin_idle(struct adreno_device *device, unsigned int timeout);
int adreno_wait_idle(struct kgsl_device *device);

int adreno_set_constraint(struct kgsl_device *device,
				struct kgsl_context *context,
				struct kgsl_device_constraint *constraint);

void adreno_snapshot(struct kgsl_device *device,
		struct kgsl_snapshot *snapshot,
		struct kgsl_context *context, struct kgsl_context *context_lpac);

int adreno_reset(struct kgsl_device *device, int fault);

void adreno_fault_skipcmd_detached(struct adreno_device *adreno_dev,
					 struct adreno_context *drawctxt,
					 struct kgsl_drawobj *drawobj);

void adreno_hang_int_callback(struct adreno_device *adreno_dev, int bit);
void adreno_cp_callback(struct adreno_device *adreno_dev, int bit);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.h:2026 [MATCH: timeout] ---
 * adreno_wait_for_halt_ack - wait for acknowlegement for a bus halt request
 * @ack_reg: register offset to wait for acknowledge
 * @mask: A mask value to wait for
 *
 * Return: 0 on success or -ETIMEDOUT if the request timed out
 */
static inline int adreno_wait_for_halt_ack(struct kgsl_device *device,
	int ack_reg, unsigned int mask)
{
	u32 val;
	int ret = kgsl_regmap_read_poll_timeout(&device->regmap, ack_reg,
		val, (val & mask) == mask, 100, 100 * 1000);

	if (ret)
		dev_err(device->dev,
			"GBIF/VBIF Halt ack timeout: reg=%08x mask=%08x status=%08x\n",
			ack_reg, mask, val);

	return ret;
}

/**
 * adreno_move_preempt_state - Update the preemption state
 * @adreno_dev: An Adreno GPU device handle
 * @old: The current state of the preemption
 * @new: The new state of the preemption
 *
 * Return: True if the state was updated or false if not
 */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.h:2031 [MATCH: timeout] ---
 */
static inline int adreno_wait_for_halt_ack(struct kgsl_device *device,
	int ack_reg, unsigned int mask)
{
	u32 val;
	int ret = kgsl_regmap_read_poll_timeout(&device->regmap, ack_reg,
		val, (val & mask) == mask, 100, 100 * 1000);

	if (ret)
		dev_err(device->dev,
			"GBIF/VBIF Halt ack timeout: reg=%08x mask=%08x status=%08x\n",
			ack_reg, mask, val);

	return ret;
}

/**
 * adreno_move_preempt_state - Update the preemption state
 * @adreno_dev: An Adreno GPU device handle
 * @old: The current state of the preemption
 * @new: The new state of the preemption
 *
 * Return: True if the state was updated or false if not
 */
static inline bool adreno_move_preempt_state(struct adreno_device *adreno_dev,
	enum adreno_preempt_states old, enum adreno_preempt_states new)
{
	return (atomic_cmpxchg(&adreno_dev->preempt.state, old, new) == old);
}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.h:2295 [MATCH: timeout] ---
		const struct adreno_dispatch_ops *ops)
{
	adreno_dev->dispatch_ops = ops;
}

#ifdef CONFIG_QCOM_KGSL_FENCE_TRACE
/**
 * adreno_fence_trace_array_init - Initialize an always on trace array
 * @device: A GPU device handle
 *
 * Register an always-on trace array to for fence timeout debugging
 */
void adreno_fence_trace_array_init(struct kgsl_device *device);
#else
static inline void adreno_fence_trace_array_init(struct kgsl_device *device) {}
#endif

/*
 * adreno_drawobj_set_constraint - Set a power constraint
 * @device: Pointer to a KGSL device structure
 * @drawobj: Draw object for which constraint is to be set
 *
 * Set the power constraint if requested by this context
 */
void adreno_drawobj_set_constraint(struct kgsl_device *device,
		struct kgsl_drawobj *drawobj);

/**
 * adreno_get_gpu_model - Gets gpu model name from device tree (or) chipid

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.h:2333 [MATCH: timeout] ---

/**
 * adreno_smmu_is_stalled() - Check whether smmu is stalled or not
 * @device: Pointer to adreno device
 *
 * Return - True if smmu is stalled or false otherwise
 */
bool adreno_smmu_is_stalled(struct adreno_device *adreno_dev);

/**
 * adreno_get_ahb_timeout_val() - Get the ahb_timeout value
 * @adreno_dev: Adreno device handle
 * @noc_timeout_us: GPU config NOC timeout value in usec
 *
 * Return - AHB timeout value to be programmed in AHB CNTL registers
 */
u32 adreno_get_ahb_timeout_val(struct adreno_device *adreno_dev, u32 noc_timeout_us);

/**
 * adreno_llcc_slice_deactivate - Deactivate GPU and GPUHTW llcc slices
 * @adreno_dev: Adreno device handle
 */
static inline void adreno_llcc_slice_deactivate(struct adreno_device *adreno_dev)
{
	if (adreno_dev->gpu_llc_slice_enable && !IS_ERR_OR_NULL(adreno_dev->gpu_llc_slice))
		llcc_slice_deactivate(adreno_dev->gpu_llc_slice);

	if (adreno_dev->gpuhtw_llc_slice_enable && !IS_ERR_OR_NULL(adreno_dev->gpuhtw_llc_slice))
		llcc_slice_deactivate(adreno_dev->gpuhtw_llc_slice);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.h:2335 [MATCH: timeout] ---
 * adreno_smmu_is_stalled() - Check whether smmu is stalled or not
 * @device: Pointer to adreno device
 *
 * Return - True if smmu is stalled or false otherwise
 */
bool adreno_smmu_is_stalled(struct adreno_device *adreno_dev);

/**
 * adreno_get_ahb_timeout_val() - Get the ahb_timeout value
 * @adreno_dev: Adreno device handle
 * @noc_timeout_us: GPU config NOC timeout value in usec
 *
 * Return - AHB timeout value to be programmed in AHB CNTL registers
 */
u32 adreno_get_ahb_timeout_val(struct adreno_device *adreno_dev, u32 noc_timeout_us);

/**
 * adreno_llcc_slice_deactivate - Deactivate GPU and GPUHTW llcc slices
 * @adreno_dev: Adreno device handle
 */
static inline void adreno_llcc_slice_deactivate(struct adreno_device *adreno_dev)
{
	if (adreno_dev->gpu_llc_slice_enable && !IS_ERR_OR_NULL(adreno_dev->gpu_llc_slice))
		llcc_slice_deactivate(adreno_dev->gpu_llc_slice);

	if (adreno_dev->gpuhtw_llc_slice_enable && !IS_ERR_OR_NULL(adreno_dev->gpuhtw_llc_slice))
		llcc_slice_deactivate(adreno_dev->gpuhtw_llc_slice);

	if (adreno_dev->gpumv_llc_slice_enable && !IS_ERR_OR_NULL(adreno_dev->gpumv_llc_slice))

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.h:2337 [MATCH: timeout] ---
 *
 * Return - True if smmu is stalled or false otherwise
 */
bool adreno_smmu_is_stalled(struct adreno_device *adreno_dev);

/**
 * adreno_get_ahb_timeout_val() - Get the ahb_timeout value
 * @adreno_dev: Adreno device handle
 * @noc_timeout_us: GPU config NOC timeout value in usec
 *
 * Return - AHB timeout value to be programmed in AHB CNTL registers
 */
u32 adreno_get_ahb_timeout_val(struct adreno_device *adreno_dev, u32 noc_timeout_us);

/**
 * adreno_llcc_slice_deactivate - Deactivate GPU and GPUHTW llcc slices
 * @adreno_dev: Adreno device handle
 */
static inline void adreno_llcc_slice_deactivate(struct adreno_device *adreno_dev)
{
	if (adreno_dev->gpu_llc_slice_enable && !IS_ERR_OR_NULL(adreno_dev->gpu_llc_slice))
		llcc_slice_deactivate(adreno_dev->gpu_llc_slice);

	if (adreno_dev->gpuhtw_llc_slice_enable && !IS_ERR_OR_NULL(adreno_dev->gpuhtw_llc_slice))
		llcc_slice_deactivate(adreno_dev->gpuhtw_llc_slice);

	if (adreno_dev->gpumv_llc_slice_enable && !IS_ERR_OR_NULL(adreno_dev->gpumv_llc_slice))
		llcc_slice_deactivate(adreno_dev->gpumv_llc_slice);
}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.h:2339 [MATCH: timeout] ---
 */
bool adreno_smmu_is_stalled(struct adreno_device *adreno_dev);

/**
 * adreno_get_ahb_timeout_val() - Get the ahb_timeout value
 * @adreno_dev: Adreno device handle
 * @noc_timeout_us: GPU config NOC timeout value in usec
 *
 * Return - AHB timeout value to be programmed in AHB CNTL registers
 */
u32 adreno_get_ahb_timeout_val(struct adreno_device *adreno_dev, u32 noc_timeout_us);

/**
 * adreno_llcc_slice_deactivate - Deactivate GPU and GPUHTW llcc slices
 * @adreno_dev: Adreno device handle
 */
static inline void adreno_llcc_slice_deactivate(struct adreno_device *adreno_dev)
{
	if (adreno_dev->gpu_llc_slice_enable && !IS_ERR_OR_NULL(adreno_dev->gpu_llc_slice))
		llcc_slice_deactivate(adreno_dev->gpu_llc_slice);

	if (adreno_dev->gpuhtw_llc_slice_enable && !IS_ERR_OR_NULL(adreno_dev->gpuhtw_llc_slice))
		llcc_slice_deactivate(adreno_dev->gpuhtw_llc_slice);

	if (adreno_dev->gpumv_llc_slice_enable && !IS_ERR_OR_NULL(adreno_dev->gpumv_llc_slice))
		llcc_slice_deactivate(adreno_dev->gpumv_llc_slice);
}

/**

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.h:2228 [MATCH: results] ---
 * @ab: ab request that needs to be scaled in MBps
 *
 * Returns the AB value that needs to be prefixed to bandwidth vote in kbps
 */
u32 adreno_gmu_bus_ab_quantize(struct adreno_device *adreno_dev, u32 ab);

/**
 * adreno_check_idle - Make sure device is idle
 * @device: Pointer to the kgsl device
 *
 * This function processes the profiling results and log an error if
 * device is not idle
 */
void adreno_check_idle(struct kgsl_device *device);

/*
 * adreno_profile_submit_time - Populate profiling buffer with timestamps
 * @time: Container for the statistics
 *
 * Populate the draw object user profiling buffer with the timestamps
 * recored in the adreno_submit_time structure at the time of draw object
 * submission.
 */
void adreno_profile_submit_time(struct adreno_submit_time *time);

void adreno_preemption_timer(struct timer_list *t);

/**
 * adreno_create_profile_buffer - Create a buffer to store profiling data

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.h:1955 [MATCH: spin_lock] ---
	 * unsigned long is big enough for our purposes.
	 */
	return (BITS_PER_LONG > 32 && ADRENO_GPUREV(adreno_dev) >= 500);
}

static inline void adreno_ringbuffer_set_pagetable(struct kgsl_device *device,
	struct adreno_ringbuffer *rb, struct kgsl_pagetable *pt)
{
	unsigned long flags;

	spin_lock_irqsave(&rb->preempt_lock, flags);

	kgsl_sharedmem_writel(device->scratch,
		SCRATCH_RB_OFFSET(rb->id, current_rb_ptname), pt->name);

	kgsl_sharedmem_writeq(device->scratch,
		SCRATCH_RB_OFFSET(rb->id, ttbr0),
		kgsl_mmu_pagetable_get_ttbr0(pt));

	kgsl_sharedmem_writel(device->scratch,
		SCRATCH_RB_OFFSET(rb->id, contextidr), 0);

	spin_unlock_irqrestore(&rb->preempt_lock, flags);
}

static inline u32 counter_delta(struct kgsl_device *device,
			unsigned int reg, unsigned int *counter)
{
	u32 val, ret = 0;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno.h:1967 [MATCH: spin_unlock] ---
	kgsl_sharedmem_writel(device->scratch,
		SCRATCH_RB_OFFSET(rb->id, current_rb_ptname), pt->name);

	kgsl_sharedmem_writeq(device->scratch,
		SCRATCH_RB_OFFSET(rb->id, ttbr0),
		kgsl_mmu_pagetable_get_ttbr0(pt));

	kgsl_sharedmem_writel(device->scratch,
		SCRATCH_RB_OFFSET(rb->id, contextidr), 0);

	spin_unlock_irqrestore(&rb->preempt_lock, flags);
}

static inline u32 counter_delta(struct kgsl_device *device,
			unsigned int reg, unsigned int *counter)
{
	u32 val, ret = 0;

	if (!reg)
		return 0;

	kgsl_regread(device, reg, &val);

	if (*counter) {
		if (val >= *counter)
			ret = val - *counter;
		else
			ret = (UINT_MAX - *counter) + val;
	}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx.c:53 [MATCH: timeout] ---
 * Number of times to check if the GPMU firmware is initialized before
 * giving up and returning failure.
 */
#define GPMU_FW_INIT_RETRY 5000

#define A530_QFPROM_RAW_PTE_ROW0_MSB 0x134
#define A530_QFPROM_RAW_PTE_ROW2_MSB 0x144

#define A5XX_INT_MASK \
	((1 << A5XX_INT_RBBM_AHB_ERROR) |		\
	 (1 << A5XX_INT_RBBM_TRANSFER_TIMEOUT) |		\
	 (1 << A5XX_INT_RBBM_ME_MS_TIMEOUT) |		\
	 (1 << A5XX_INT_RBBM_PFP_MS_TIMEOUT) |		\
	 (1 << A5XX_INT_RBBM_ETS_MS_TIMEOUT) |		\
	 (1 << A5XX_INT_RBBM_ATB_ASYNC_OVERFLOW) |		\
	 (1 << A5XX_INT_RBBM_GPC_ERROR) |		\
	 (1 << A5XX_INT_CP_HW_ERROR) |	\
	 (1 << A5XX_INT_CP_CACHE_FLUSH_TS) |		\
	 (1 << A5XX_INT_RBBM_ATB_BUS_OVERFLOW) |	\
	 (1 << A5XX_INT_MISC_HANG_DETECT) |		\
	 (1 << A5XX_INT_UCHE_OOB_ACCESS) |		\
	 (1 << A5XX_INT_UCHE_TRAP_INTR) |		\
	 (1 << A5XX_INT_CP_SW) |			\
	 (1 << A5XX_INT_GPMU_FIRMWARE) |                \
	 (1 << A5XX_INT_GPMU_VOLTAGE_DROOP))

static int a5xx_probe(struct platform_device *pdev,
	u32 chipid, const struct adreno_gpu_core *gpucore)
{

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx.c:54 [MATCH: timeout] ---
 * giving up and returning failure.
 */
#define GPMU_FW_INIT_RETRY 5000

#define A530_QFPROM_RAW_PTE_ROW0_MSB 0x134
#define A530_QFPROM_RAW_PTE_ROW2_MSB 0x144

#define A5XX_INT_MASK \
	((1 << A5XX_INT_RBBM_AHB_ERROR) |		\
	 (1 << A5XX_INT_RBBM_TRANSFER_TIMEOUT) |		\
	 (1 << A5XX_INT_RBBM_ME_MS_TIMEOUT) |		\
	 (1 << A5XX_INT_RBBM_PFP_MS_TIMEOUT) |		\
	 (1 << A5XX_INT_RBBM_ETS_MS_TIMEOUT) |		\
	 (1 << A5XX_INT_RBBM_ATB_ASYNC_OVERFLOW) |		\
	 (1 << A5XX_INT_RBBM_GPC_ERROR) |		\
	 (1 << A5XX_INT_CP_HW_ERROR) |	\
	 (1 << A5XX_INT_CP_CACHE_FLUSH_TS) |		\
	 (1 << A5XX_INT_RBBM_ATB_BUS_OVERFLOW) |	\
	 (1 << A5XX_INT_MISC_HANG_DETECT) |		\
	 (1 << A5XX_INT_UCHE_OOB_ACCESS) |		\
	 (1 << A5XX_INT_UCHE_TRAP_INTR) |		\
	 (1 << A5XX_INT_CP_SW) |			\
	 (1 << A5XX_INT_GPMU_FIRMWARE) |                \
	 (1 << A5XX_INT_GPMU_VOLTAGE_DROOP))

static int a5xx_probe(struct platform_device *pdev,
	u32 chipid, const struct adreno_gpu_core *gpucore)
{
	struct adreno_device *adreno_dev;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx.c:55 [MATCH: timeout] ---
 */
#define GPMU_FW_INIT_RETRY 5000

#define A530_QFPROM_RAW_PTE_ROW0_MSB 0x134
#define A530_QFPROM_RAW_PTE_ROW2_MSB 0x144

#define A5XX_INT_MASK \
	((1 << A5XX_INT_RBBM_AHB_ERROR) |		\
	 (1 << A5XX_INT_RBBM_TRANSFER_TIMEOUT) |		\
	 (1 << A5XX_INT_RBBM_ME_MS_TIMEOUT) |		\
	 (1 << A5XX_INT_RBBM_PFP_MS_TIMEOUT) |		\
	 (1 << A5XX_INT_RBBM_ETS_MS_TIMEOUT) |		\
	 (1 << A5XX_INT_RBBM_ATB_ASYNC_OVERFLOW) |		\
	 (1 << A5XX_INT_RBBM_GPC_ERROR) |		\
	 (1 << A5XX_INT_CP_HW_ERROR) |	\
	 (1 << A5XX_INT_CP_CACHE_FLUSH_TS) |		\
	 (1 << A5XX_INT_RBBM_ATB_BUS_OVERFLOW) |	\
	 (1 << A5XX_INT_MISC_HANG_DETECT) |		\
	 (1 << A5XX_INT_UCHE_OOB_ACCESS) |		\
	 (1 << A5XX_INT_UCHE_TRAP_INTR) |		\
	 (1 << A5XX_INT_CP_SW) |			\
	 (1 << A5XX_INT_GPMU_FIRMWARE) |                \
	 (1 << A5XX_INT_GPMU_VOLTAGE_DROOP))

static int a5xx_probe(struct platform_device *pdev,
	u32 chipid, const struct adreno_gpu_core *gpucore)
{
	struct adreno_device *adreno_dev;
	struct kgsl_device *device;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx.c:56 [MATCH: timeout] ---
#define GPMU_FW_INIT_RETRY 5000

#define A530_QFPROM_RAW_PTE_ROW0_MSB 0x134
#define A530_QFPROM_RAW_PTE_ROW2_MSB 0x144

#define A5XX_INT_MASK \
	((1 << A5XX_INT_RBBM_AHB_ERROR) |		\
	 (1 << A5XX_INT_RBBM_TRANSFER_TIMEOUT) |		\
	 (1 << A5XX_INT_RBBM_ME_MS_TIMEOUT) |		\
	 (1 << A5XX_INT_RBBM_PFP_MS_TIMEOUT) |		\
	 (1 << A5XX_INT_RBBM_ETS_MS_TIMEOUT) |		\
	 (1 << A5XX_INT_RBBM_ATB_ASYNC_OVERFLOW) |		\
	 (1 << A5XX_INT_RBBM_GPC_ERROR) |		\
	 (1 << A5XX_INT_CP_HW_ERROR) |	\
	 (1 << A5XX_INT_CP_CACHE_FLUSH_TS) |		\
	 (1 << A5XX_INT_RBBM_ATB_BUS_OVERFLOW) |	\
	 (1 << A5XX_INT_MISC_HANG_DETECT) |		\
	 (1 << A5XX_INT_UCHE_OOB_ACCESS) |		\
	 (1 << A5XX_INT_UCHE_TRAP_INTR) |		\
	 (1 << A5XX_INT_CP_SW) |			\
	 (1 << A5XX_INT_GPMU_FIRMWARE) |                \
	 (1 << A5XX_INT_GPMU_VOLTAGE_DROOP))

static int a5xx_probe(struct platform_device *pdev,
	u32 chipid, const struct adreno_gpu_core *gpucore)
{
	struct adreno_device *adreno_dev;
	struct kgsl_device *device;
	int ret;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx.c:1209 [MATCH: timeout] ---
{
	struct adreno_device *adreno_dev = container_of(work,
			struct adreno_device, gpmu_work);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	if (test_bit(ADRENO_DEVICE_GPMU_INITIALIZED, &adreno_dev->priv))
		return;

	/*
	 * If GPMU has already experienced a restart or is in the process of it
	 * after the watchdog timeout, then there is no need to reset GPMU
	 * again.
	 */
	if (device->state != KGSL_STATE_AWARE && device->state != KGSL_STATE_ACTIVE)
		return;

	kgsl_mutex_lock(&device->mutex);

	if (a5xx_regulator_enable(adreno_dev))
		goto out;

	/* Soft reset of the GPMU block */
	kgsl_regwrite(device, A5XX_RBBM_BLOCK_SW_RESET_CMD, BIT(16));

	/* GPU comes up in secured mode, make it unsecured by default */
	if (!ADRENO_FEATURE(adreno_dev, ADRENO_CONTENT_PROTECTION))
		kgsl_regwrite(device, A5XX_RBBM_SECVID_TRUST_CNTL, 0x0);



--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx.c:1439 [MATCH: timeout] ---
	 * independently
	 */
	kgsl_regwrite(device, A5XX_UCHE_MODE_CNTL, BIT(29));
	/* Set the USE_RETENTION_FLOPS chicken bit */
	kgsl_regwrite(device, A5XX_CP_CHICKEN_DBG, 0x02000000);

	/* Enable ISDB mode if requested */
	if (test_bit(ADRENO_DEVICE_ISDB_ENABLED, &adreno_dev->priv)) {
		if (!adreno_active_count_get(adreno_dev)) {
			/*
			 * Disable ME/PFP split timeouts when the debugger is
			 * enabled because the CP doesn't know when a shader is
			 * in active debug
			 */
			kgsl_regwrite(device, A5XX_RBBM_AHB_CNTL1, 0x06FFFFFF);

			/* Force the SP0/SP1 clocks on to enable ISDB */
			kgsl_regwrite(device, A5XX_RBBM_CLOCK_CNTL_SP0, 0x0);
			kgsl_regwrite(device, A5XX_RBBM_CLOCK_CNTL_SP1, 0x0);
			kgsl_regwrite(device, A5XX_RBBM_CLOCK_CNTL_SP2, 0x0);
			kgsl_regwrite(device, A5XX_RBBM_CLOCK_CNTL_SP3, 0x0);
			kgsl_regwrite(device, A5XX_RBBM_CLOCK_CNTL2_SP0, 0x0);
			kgsl_regwrite(device, A5XX_RBBM_CLOCK_CNTL2_SP1, 0x0);
			kgsl_regwrite(device, A5XX_RBBM_CLOCK_CNTL2_SP2, 0x0);
			kgsl_regwrite(device, A5XX_RBBM_CLOCK_CNTL2_SP3, 0x0);

			/* disable HWCG */
			kgsl_regwrite(device, A5XX_RBBM_CLOCK_CNTL, 0x0);
			kgsl_regwrite(device, A5XX_RBBM_ISDB_CNT, 0x0);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx.c:2022 [MATCH: timeout] ---
					"RBBM | AHB bus error | %s | addr=%x | ports=%x:%x\n",
					reg & (1 << 28) ? "WRITE" : "READ",
					(reg & 0xFFFFF) >> 2,
					(reg >> 20) & 0x3,
					(reg >> 24) & 0xF);

		/* Clear the error */
		kgsl_regwrite(device, A5XX_RBBM_AHB_CMD, (1 << 4));
		break;
	}
	case A5XX_INT_RBBM_TRANSFER_TIMEOUT:
		dev_crit_ratelimited(device->dev,
					"RBBM: AHB transfer timeout\n");
		break;
	case A5XX_INT_RBBM_ME_MS_TIMEOUT:
		kgsl_regread(device, A5XX_RBBM_AHB_ME_SPLIT_STATUS, &reg);
		dev_crit_ratelimited(device->dev,
					"RBBM | ME master split timeout | status=%x\n",
					reg);
		break;
	case A5XX_INT_RBBM_PFP_MS_TIMEOUT:
		kgsl_regread(device, A5XX_RBBM_AHB_PFP_SPLIT_STATUS, &reg);
		dev_crit_ratelimited(device->dev,
					"RBBM | PFP master split timeout | status=%x\n",
					reg);
		break;
	case A5XX_INT_RBBM_ETS_MS_TIMEOUT:
		dev_crit_ratelimited(device->dev,
					"RBBM: ME master split timeout\n");

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx.c:2024 [MATCH: timeout] ---
					(reg & 0xFFFFF) >> 2,
					(reg >> 20) & 0x3,
					(reg >> 24) & 0xF);

		/* Clear the error */
		kgsl_regwrite(device, A5XX_RBBM_AHB_CMD, (1 << 4));
		break;
	}
	case A5XX_INT_RBBM_TRANSFER_TIMEOUT:
		dev_crit_ratelimited(device->dev,
					"RBBM: AHB transfer timeout\n");
		break;
	case A5XX_INT_RBBM_ME_MS_TIMEOUT:
		kgsl_regread(device, A5XX_RBBM_AHB_ME_SPLIT_STATUS, &reg);
		dev_crit_ratelimited(device->dev,
					"RBBM | ME master split timeout | status=%x\n",
					reg);
		break;
	case A5XX_INT_RBBM_PFP_MS_TIMEOUT:
		kgsl_regread(device, A5XX_RBBM_AHB_PFP_SPLIT_STATUS, &reg);
		dev_crit_ratelimited(device->dev,
					"RBBM | PFP master split timeout | status=%x\n",
					reg);
		break;
	case A5XX_INT_RBBM_ETS_MS_TIMEOUT:
		dev_crit_ratelimited(device->dev,
					"RBBM: ME master split timeout\n");
		break;
	case A5XX_INT_RBBM_ATB_ASYNC_OVERFLOW:

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx.c:2026 [MATCH: timeout] ---
					(reg >> 24) & 0xF);

		/* Clear the error */
		kgsl_regwrite(device, A5XX_RBBM_AHB_CMD, (1 << 4));
		break;
	}
	case A5XX_INT_RBBM_TRANSFER_TIMEOUT:
		dev_crit_ratelimited(device->dev,
					"RBBM: AHB transfer timeout\n");
		break;
	case A5XX_INT_RBBM_ME_MS_TIMEOUT:
		kgsl_regread(device, A5XX_RBBM_AHB_ME_SPLIT_STATUS, &reg);
		dev_crit_ratelimited(device->dev,
					"RBBM | ME master split timeout | status=%x\n",
					reg);
		break;
	case A5XX_INT_RBBM_PFP_MS_TIMEOUT:
		kgsl_regread(device, A5XX_RBBM_AHB_PFP_SPLIT_STATUS, &reg);
		dev_crit_ratelimited(device->dev,
					"RBBM | PFP master split timeout | status=%x\n",
					reg);
		break;
	case A5XX_INT_RBBM_ETS_MS_TIMEOUT:
		dev_crit_ratelimited(device->dev,
					"RBBM: ME master split timeout\n");
		break;
	case A5XX_INT_RBBM_ATB_ASYNC_OVERFLOW:
		dev_crit_ratelimited(device->dev,
					"RBBM: ATB ASYNC overflow\n");

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx.c:2029 [MATCH: timeout] ---
		kgsl_regwrite(device, A5XX_RBBM_AHB_CMD, (1 << 4));
		break;
	}
	case A5XX_INT_RBBM_TRANSFER_TIMEOUT:
		dev_crit_ratelimited(device->dev,
					"RBBM: AHB transfer timeout\n");
		break;
	case A5XX_INT_RBBM_ME_MS_TIMEOUT:
		kgsl_regread(device, A5XX_RBBM_AHB_ME_SPLIT_STATUS, &reg);
		dev_crit_ratelimited(device->dev,
					"RBBM | ME master split timeout | status=%x\n",
					reg);
		break;
	case A5XX_INT_RBBM_PFP_MS_TIMEOUT:
		kgsl_regread(device, A5XX_RBBM_AHB_PFP_SPLIT_STATUS, &reg);
		dev_crit_ratelimited(device->dev,
					"RBBM | PFP master split timeout | status=%x\n",
					reg);
		break;
	case A5XX_INT_RBBM_ETS_MS_TIMEOUT:
		dev_crit_ratelimited(device->dev,
					"RBBM: ME master split timeout\n");
		break;
	case A5XX_INT_RBBM_ATB_ASYNC_OVERFLOW:
		dev_crit_ratelimited(device->dev,
					"RBBM: ATB ASYNC overflow\n");
		break;
	case A5XX_INT_RBBM_ATB_BUS_OVERFLOW:
		dev_crit_ratelimited(device->dev,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx.c:2032 [MATCH: timeout] ---
	case A5XX_INT_RBBM_TRANSFER_TIMEOUT:
		dev_crit_ratelimited(device->dev,
					"RBBM: AHB transfer timeout\n");
		break;
	case A5XX_INT_RBBM_ME_MS_TIMEOUT:
		kgsl_regread(device, A5XX_RBBM_AHB_ME_SPLIT_STATUS, &reg);
		dev_crit_ratelimited(device->dev,
					"RBBM | ME master split timeout | status=%x\n",
					reg);
		break;
	case A5XX_INT_RBBM_PFP_MS_TIMEOUT:
		kgsl_regread(device, A5XX_RBBM_AHB_PFP_SPLIT_STATUS, &reg);
		dev_crit_ratelimited(device->dev,
					"RBBM | PFP master split timeout | status=%x\n",
					reg);
		break;
	case A5XX_INT_RBBM_ETS_MS_TIMEOUT:
		dev_crit_ratelimited(device->dev,
					"RBBM: ME master split timeout\n");
		break;
	case A5XX_INT_RBBM_ATB_ASYNC_OVERFLOW:
		dev_crit_ratelimited(device->dev,
					"RBBM: ATB ASYNC overflow\n");
		break;
	case A5XX_INT_RBBM_ATB_BUS_OVERFLOW:
		dev_crit_ratelimited(device->dev,
					"RBBM: ATB bus overflow\n");
		break;
	case A5XX_INT_UCHE_OOB_ACCESS:

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx.c:2035 [MATCH: timeout] ---
		break;
	case A5XX_INT_RBBM_ME_MS_TIMEOUT:
		kgsl_regread(device, A5XX_RBBM_AHB_ME_SPLIT_STATUS, &reg);
		dev_crit_ratelimited(device->dev,
					"RBBM | ME master split timeout | status=%x\n",
					reg);
		break;
	case A5XX_INT_RBBM_PFP_MS_TIMEOUT:
		kgsl_regread(device, A5XX_RBBM_AHB_PFP_SPLIT_STATUS, &reg);
		dev_crit_ratelimited(device->dev,
					"RBBM | PFP master split timeout | status=%x\n",
					reg);
		break;
	case A5XX_INT_RBBM_ETS_MS_TIMEOUT:
		dev_crit_ratelimited(device->dev,
					"RBBM: ME master split timeout\n");
		break;
	case A5XX_INT_RBBM_ATB_ASYNC_OVERFLOW:
		dev_crit_ratelimited(device->dev,
					"RBBM: ATB ASYNC overflow\n");
		break;
	case A5XX_INT_RBBM_ATB_BUS_OVERFLOW:
		dev_crit_ratelimited(device->dev,
					"RBBM: ATB bus overflow\n");
		break;
	case A5XX_INT_UCHE_OOB_ACCESS:
		dev_crit_ratelimited(device->dev,
					"UCHE: Out of bounds access\n");
		break;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx.c:2038 [MATCH: timeout] ---
		dev_crit_ratelimited(device->dev,
					"RBBM | ME master split timeout | status=%x\n",
					reg);
		break;
	case A5XX_INT_RBBM_PFP_MS_TIMEOUT:
		kgsl_regread(device, A5XX_RBBM_AHB_PFP_SPLIT_STATUS, &reg);
		dev_crit_ratelimited(device->dev,
					"RBBM | PFP master split timeout | status=%x\n",
					reg);
		break;
	case A5XX_INT_RBBM_ETS_MS_TIMEOUT:
		dev_crit_ratelimited(device->dev,
					"RBBM: ME master split timeout\n");
		break;
	case A5XX_INT_RBBM_ATB_ASYNC_OVERFLOW:
		dev_crit_ratelimited(device->dev,
					"RBBM: ATB ASYNC overflow\n");
		break;
	case A5XX_INT_RBBM_ATB_BUS_OVERFLOW:
		dev_crit_ratelimited(device->dev,
					"RBBM: ATB bus overflow\n");
		break;
	case A5XX_INT_UCHE_OOB_ACCESS:
		dev_crit_ratelimited(device->dev,
					"UCHE: Out of bounds access\n");
		break;
	case A5XX_INT_UCHE_TRAP_INTR:
		dev_crit_ratelimited(device->dev, "UCHE: Trap interrupt\n");
		break;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx.c:2040 [MATCH: timeout] ---
					reg);
		break;
	case A5XX_INT_RBBM_PFP_MS_TIMEOUT:
		kgsl_regread(device, A5XX_RBBM_AHB_PFP_SPLIT_STATUS, &reg);
		dev_crit_ratelimited(device->dev,
					"RBBM | PFP master split timeout | status=%x\n",
					reg);
		break;
	case A5XX_INT_RBBM_ETS_MS_TIMEOUT:
		dev_crit_ratelimited(device->dev,
					"RBBM: ME master split timeout\n");
		break;
	case A5XX_INT_RBBM_ATB_ASYNC_OVERFLOW:
		dev_crit_ratelimited(device->dev,
					"RBBM: ATB ASYNC overflow\n");
		break;
	case A5XX_INT_RBBM_ATB_BUS_OVERFLOW:
		dev_crit_ratelimited(device->dev,
					"RBBM: ATB bus overflow\n");
		break;
	case A5XX_INT_UCHE_OOB_ACCESS:
		dev_crit_ratelimited(device->dev,
					"UCHE: Out of bounds access\n");
		break;
	case A5XX_INT_UCHE_TRAP_INTR:
		dev_crit_ratelimited(device->dev, "UCHE: Trap interrupt\n");
		break;
	case A5XX_INT_GPMU_VOLTAGE_DROOP:
		dev_crit_ratelimited(device->dev, "GPMU: Voltage droop\n");

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx.c:2237 [MATCH: timeout] ---
	if (adreno_is_a540(adreno_dev))
		kgsl_regread(device, A5XX_RBBM_ALWAYSON_COUNTER_HI, &hi);

	return (((u64) hi) << 32) | lo;
}


static const struct adreno_irq_funcs a5xx_irq_funcs[32] = {
	ADRENO_IRQ_CALLBACK(NULL),              /* 0 - RBBM_GPU_IDLE */
	ADRENO_IRQ_CALLBACK(a5xx_err_callback), /* 1 - RBBM_AHB_ERROR */
	ADRENO_IRQ_CALLBACK(a5xx_err_callback), /* 2 - RBBM_TRANSFER_TIMEOUT */
	/* 3 - RBBM_ME_MASTER_SPLIT_TIMEOUT  */
	ADRENO_IRQ_CALLBACK(a5xx_err_callback),
	/* 4 - RBBM_PFP_MASTER_SPLIT_TIMEOUT */
	ADRENO_IRQ_CALLBACK(a5xx_err_callback),
	 /* 5 - RBBM_ETS_MASTER_SPLIT_TIMEOUT */
	ADRENO_IRQ_CALLBACK(a5xx_err_callback),
	/* 6 - RBBM_ATB_ASYNC_OVERFLOW */
	ADRENO_IRQ_CALLBACK(a5xx_err_callback),
	ADRENO_IRQ_CALLBACK(a5x_gpc_err_int_callback), /* 7 - GPC_ERR */
	ADRENO_IRQ_CALLBACK(a5xx_preempt_callback),/* 8 - CP_SW */
	ADRENO_IRQ_CALLBACK(a5xx_cp_hw_err_callback), /* 9 - CP_HW_ERROR */
	/* 10 - CP_CCU_FLUSH_DEPTH_TS */
	ADRENO_IRQ_CALLBACK(NULL),
	 /* 11 - CP_CCU_FLUSH_COLOR_TS */
	ADRENO_IRQ_CALLBACK(NULL),
	 /* 12 - CP_CCU_RESOLVE_TS */
	ADRENO_IRQ_CALLBACK(NULL),
	ADRENO_IRQ_CALLBACK(NULL), /* 13 - CP_IB2_INT */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx.c:2238 [MATCH: timeout] ---
		kgsl_regread(device, A5XX_RBBM_ALWAYSON_COUNTER_HI, &hi);

	return (((u64) hi) << 32) | lo;
}


static const struct adreno_irq_funcs a5xx_irq_funcs[32] = {
	ADRENO_IRQ_CALLBACK(NULL),              /* 0 - RBBM_GPU_IDLE */
	ADRENO_IRQ_CALLBACK(a5xx_err_callback), /* 1 - RBBM_AHB_ERROR */
	ADRENO_IRQ_CALLBACK(a5xx_err_callback), /* 2 - RBBM_TRANSFER_TIMEOUT */
	/* 3 - RBBM_ME_MASTER_SPLIT_TIMEOUT  */
	ADRENO_IRQ_CALLBACK(a5xx_err_callback),
	/* 4 - RBBM_PFP_MASTER_SPLIT_TIMEOUT */
	ADRENO_IRQ_CALLBACK(a5xx_err_callback),
	 /* 5 - RBBM_ETS_MASTER_SPLIT_TIMEOUT */
	ADRENO_IRQ_CALLBACK(a5xx_err_callback),
	/* 6 - RBBM_ATB_ASYNC_OVERFLOW */
	ADRENO_IRQ_CALLBACK(a5xx_err_callback),
	ADRENO_IRQ_CALLBACK(a5x_gpc_err_int_callback), /* 7 - GPC_ERR */
	ADRENO_IRQ_CALLBACK(a5xx_preempt_callback),/* 8 - CP_SW */
	ADRENO_IRQ_CALLBACK(a5xx_cp_hw_err_callback), /* 9 - CP_HW_ERROR */
	/* 10 - CP_CCU_FLUSH_DEPTH_TS */
	ADRENO_IRQ_CALLBACK(NULL),
	 /* 11 - CP_CCU_FLUSH_COLOR_TS */
	ADRENO_IRQ_CALLBACK(NULL),
	 /* 12 - CP_CCU_RESOLVE_TS */
	ADRENO_IRQ_CALLBACK(NULL),
	ADRENO_IRQ_CALLBACK(NULL), /* 13 - CP_IB2_INT */
	ADRENO_IRQ_CALLBACK(NULL), /* 14 - CP_IB1_INT */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx.c:2240 [MATCH: timeout] ---
	return (((u64) hi) << 32) | lo;
}


static const struct adreno_irq_funcs a5xx_irq_funcs[32] = {
	ADRENO_IRQ_CALLBACK(NULL),              /* 0 - RBBM_GPU_IDLE */
	ADRENO_IRQ_CALLBACK(a5xx_err_callback), /* 1 - RBBM_AHB_ERROR */
	ADRENO_IRQ_CALLBACK(a5xx_err_callback), /* 2 - RBBM_TRANSFER_TIMEOUT */
	/* 3 - RBBM_ME_MASTER_SPLIT_TIMEOUT  */
	ADRENO_IRQ_CALLBACK(a5xx_err_callback),
	/* 4 - RBBM_PFP_MASTER_SPLIT_TIMEOUT */
	ADRENO_IRQ_CALLBACK(a5xx_err_callback),
	 /* 5 - RBBM_ETS_MASTER_SPLIT_TIMEOUT */
	ADRENO_IRQ_CALLBACK(a5xx_err_callback),
	/* 6 - RBBM_ATB_ASYNC_OVERFLOW */
	ADRENO_IRQ_CALLBACK(a5xx_err_callback),
	ADRENO_IRQ_CALLBACK(a5x_gpc_err_int_callback), /* 7 - GPC_ERR */
	ADRENO_IRQ_CALLBACK(a5xx_preempt_callback),/* 8 - CP_SW */
	ADRENO_IRQ_CALLBACK(a5xx_cp_hw_err_callback), /* 9 - CP_HW_ERROR */
	/* 10 - CP_CCU_FLUSH_DEPTH_TS */
	ADRENO_IRQ_CALLBACK(NULL),
	 /* 11 - CP_CCU_FLUSH_COLOR_TS */
	ADRENO_IRQ_CALLBACK(NULL),
	 /* 12 - CP_CCU_RESOLVE_TS */
	ADRENO_IRQ_CALLBACK(NULL),
	ADRENO_IRQ_CALLBACK(NULL), /* 13 - CP_IB2_INT */
	ADRENO_IRQ_CALLBACK(NULL), /* 14 - CP_IB1_INT */
	ADRENO_IRQ_CALLBACK(NULL), /* 15 - CP_RB_INT */
	/* 16 - CCP_UNUSED_1 */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx.c:2242 [MATCH: timeout] ---


static const struct adreno_irq_funcs a5xx_irq_funcs[32] = {
	ADRENO_IRQ_CALLBACK(NULL),              /* 0 - RBBM_GPU_IDLE */
	ADRENO_IRQ_CALLBACK(a5xx_err_callback), /* 1 - RBBM_AHB_ERROR */
	ADRENO_IRQ_CALLBACK(a5xx_err_callback), /* 2 - RBBM_TRANSFER_TIMEOUT */
	/* 3 - RBBM_ME_MASTER_SPLIT_TIMEOUT  */
	ADRENO_IRQ_CALLBACK(a5xx_err_callback),
	/* 4 - RBBM_PFP_MASTER_SPLIT_TIMEOUT */
	ADRENO_IRQ_CALLBACK(a5xx_err_callback),
	 /* 5 - RBBM_ETS_MASTER_SPLIT_TIMEOUT */
	ADRENO_IRQ_CALLBACK(a5xx_err_callback),
	/* 6 - RBBM_ATB_ASYNC_OVERFLOW */
	ADRENO_IRQ_CALLBACK(a5xx_err_callback),
	ADRENO_IRQ_CALLBACK(a5x_gpc_err_int_callback), /* 7 - GPC_ERR */
	ADRENO_IRQ_CALLBACK(a5xx_preempt_callback),/* 8 - CP_SW */
	ADRENO_IRQ_CALLBACK(a5xx_cp_hw_err_callback), /* 9 - CP_HW_ERROR */
	/* 10 - CP_CCU_FLUSH_DEPTH_TS */
	ADRENO_IRQ_CALLBACK(NULL),
	 /* 11 - CP_CCU_FLUSH_COLOR_TS */
	ADRENO_IRQ_CALLBACK(NULL),
	 /* 12 - CP_CCU_RESOLVE_TS */
	ADRENO_IRQ_CALLBACK(NULL),
	ADRENO_IRQ_CALLBACK(NULL), /* 13 - CP_IB2_INT */
	ADRENO_IRQ_CALLBACK(NULL), /* 14 - CP_IB1_INT */
	ADRENO_IRQ_CALLBACK(NULL), /* 15 - CP_RB_INT */
	/* 16 - CCP_UNUSED_1 */
	ADRENO_IRQ_CALLBACK(NULL),
	ADRENO_IRQ_CALLBACK(NULL), /* 17 - CP_RB_DONE_TS */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx.c:1215 [MATCH: mutex_lock] ---
		return;

	/*
	 * If GPMU has already experienced a restart or is in the process of it
	 * after the watchdog timeout, then there is no need to reset GPMU
	 * again.
	 */
	if (device->state != KGSL_STATE_AWARE && device->state != KGSL_STATE_ACTIVE)
		return;

	kgsl_mutex_lock(&device->mutex);

	if (a5xx_regulator_enable(adreno_dev))
		goto out;

	/* Soft reset of the GPMU block */
	kgsl_regwrite(device, A5XX_RBBM_BLOCK_SW_RESET_CMD, BIT(16));

	/* GPU comes up in secured mode, make it unsecured by default */
	if (!ADRENO_FEATURE(adreno_dev, ADRENO_CONTENT_PROTECTION))
		kgsl_regwrite(device, A5XX_RBBM_SECVID_TRUST_CNTL, 0x0);


	a5xx_gpmu_init(adreno_dev);

out:
	kgsl_mutex_unlock(&device->mutex);
}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx.c:2073 [MATCH: mutex_lock] ---
	}
}

static void a5xx_irq_storm_worker(struct work_struct *work)
{
	struct adreno_device *adreno_dev = container_of(work,
			struct adreno_device, irq_storm_work);
	struct kgsl_device *device = &adreno_dev->dev;
	unsigned int status;

	kgsl_mutex_lock(&device->mutex);

	/* Wait for the storm to clear up */
	do {
		kgsl_regwrite(device, A5XX_RBBM_INT_CLEAR_CMD,
				BIT(A5XX_INT_CP_CACHE_FLUSH_TS));
		kgsl_regread(device, A5XX_RBBM_INT_0_STATUS, &status);
	} while (status & BIT(A5XX_INT_CP_CACHE_FLUSH_TS));

	/* Re-enable the interrupt bit in the mask */
	adreno_dev->irq_mask |= BIT(A5XX_INT_CP_CACHE_FLUSH_TS);
	kgsl_regwrite(device, A5XX_RBBM_INT_0_MASK, adreno_dev->irq_mask);
	clear_bit(ADRENO_DEVICE_CACHE_FLUSH_TS_SUSPENDED, &adreno_dev->priv);

	dev_warn(device->dev, "Re-enabled A5XX_INT_CP_CACHE_FLUSH_TS\n");
	kgsl_mutex_unlock(&device->mutex);

	/* Reschedule just to make sure everything retires */
	adreno_scheduler_queue(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx.c:1231 [MATCH: mutex_unlock] ---
	kgsl_regwrite(device, A5XX_RBBM_BLOCK_SW_RESET_CMD, BIT(16));

	/* GPU comes up in secured mode, make it unsecured by default */
	if (!ADRENO_FEATURE(adreno_dev, ADRENO_CONTENT_PROTECTION))
		kgsl_regwrite(device, A5XX_RBBM_SECVID_TRUST_CNTL, 0x0);


	a5xx_gpmu_init(adreno_dev);

out:
	kgsl_mutex_unlock(&device->mutex);
}

static void _setup_throttling_counters(struct adreno_device *adreno_dev)
{
	int i, ret = 0;

	if (!adreno_is_a540(adreno_dev))
		return;

	for (i = 0; i < ADRENO_GPMU_THROTTLE_COUNTERS; i++) {
		/* reset throttled cycles ivalue */
		adreno_dev->busy_data.throttle_cycles[i] = 0;

		/* Throttle countables start at off set 43 */
		ret |= adreno_perfcounter_kernel_get(adreno_dev,
			KGSL_PERFCOUNTER_GROUP_GPMU_PWR, 43 + i,
			&adreno_dev->gpmu_throttle_counters[i], NULL);
	}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx.c:2088 [MATCH: mutex_unlock] ---
				BIT(A5XX_INT_CP_CACHE_FLUSH_TS));
		kgsl_regread(device, A5XX_RBBM_INT_0_STATUS, &status);
	} while (status & BIT(A5XX_INT_CP_CACHE_FLUSH_TS));

	/* Re-enable the interrupt bit in the mask */
	adreno_dev->irq_mask |= BIT(A5XX_INT_CP_CACHE_FLUSH_TS);
	kgsl_regwrite(device, A5XX_RBBM_INT_0_MASK, adreno_dev->irq_mask);
	clear_bit(ADRENO_DEVICE_CACHE_FLUSH_TS_SUSPENDED, &adreno_dev->priv);

	dev_warn(device->dev, "Re-enabled A5XX_INT_CP_CACHE_FLUSH_TS\n");
	kgsl_mutex_unlock(&device->mutex);

	/* Reschedule just to make sure everything retires */
	adreno_scheduler_queue(adreno_dev);
}

static void a5xx_cp_callback(struct adreno_device *adreno_dev, int bit)
{
	struct kgsl_device *device = &adreno_dev->dev;
	unsigned int cur;
	static unsigned int count;
	static unsigned int prev;

	if (test_bit(ADRENO_DEVICE_CACHE_FLUSH_TS_SUSPENDED, &adreno_dev->priv))
		return;

	kgsl_sharedmem_readl(device->memstore, &cur,
			KGSL_MEMSTORE_OFFSET(KGSL_MEMSTORE_GLOBAL,
				ref_wait_ts));

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx.h:147 [MATCH: timeout] ---
/* A5XX_GPMU_GPMU_ISENSE_CTRL */
#define	ISENSE_CGC_EN_DISABLE		BIT(0)

/* A5XX_GPMU_TEMP_SENSOR_CONFIG */
#define GPMU_BCL_ENABLED		BIT(4)
#define GPMU_LLM_ENABLED		BIT(9)
#define GPMU_ISENSE_STATUS		GENMASK(3, 0)
#define GPMU_ISENSE_END_POINT_CAL_ERR	BIT(0)

#define AMP_CALIBRATION_RETRY_CNT	3
#define AMP_CALIBRATION_TIMEOUT		6

/* A5XX_GPMU_GPMU_VOLTAGE_INTR_EN_MASK */
#define VOLTAGE_INTR_EN			BIT(0)

/* A5XX_GPMU_GPMU_PWR_THRESHOLD */
#define PWR_THRESHOLD_VALID		0x80000000

/* A5XX_GPMU_GPMU_SP_CLOCK_CONTROL */
#define CNTL_IP_CLK_ENABLE		BIT(0)
/* AGC */
#define AGC_INIT_BASE			A5XX_GPMU_DATA_RAM_BASE
#define AGC_INIT_MSG_MAGIC		(AGC_INIT_BASE + 5)
#define AGC_MSG_BASE			(AGC_INIT_BASE + 7)

#define AGC_MSG_STATE			(AGC_MSG_BASE + 0)
#define AGC_MSG_COMMAND			(AGC_MSG_BASE + 1)
#define AGC_MSG_PAYLOAD_SIZE		(AGC_MSG_BASE + 3)
#define AGC_MSG_PAYLOAD			(AGC_MSG_BASE + 5)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx_packets.h:226 [MATCH: timeout] ---
	0x00000000, /* [0x00C8] A5X_VFD_MODE_CNTL (0x0E42)*/
	0x480D0201, /* [0x00C9] == TYPE4 == */
	0x0000001F, /* [0x00CA] A5X_PC_MODE_CNTL (0x0D02)*/
	0x480EC201, /* [0x00CB] == TYPE4 == */
	0x0000001E, /* [0x00CC] A5X_SP_MODE_CNTL (0x0EC2)*/
	0x400EC001, /* [0x00CD] == TYPE4 == */
	0x40000800, /* [0x00CE] A5X_SP_DBG_ECO_CNTL (0x0EC0)*/
	0x400F0201, /* [0x00CF] == TYPE4 == */
	0x00000544, /* [0x00D0] A5X_TPL1_MODE_CNTL (0x0F02)*/
	0x400E0002, /* [0x00D1] == TYPE4 == */
	0x00000080, /* [0x00D2] A5X_HLSQ_TIMEOUT_THRESHOLD_0 (0x0E00)*/
	0x00000000, /* [0x00D3] A5X_HLSQ_TIMEOUT_THRESHOLD_1 (0x0E01)*/
	0x400E6001, /* [0x00D4] == TYPE4 == */
	0x00000400, /* [0x00D5] A5X_VPC_DBG_ECO_CNTL (0x0E60)*/
	0x400E0601, /* [0x00D6] == TYPE4 == */
	0x00000001, /* [0x00D7] A5X_HLSQ_MODE_CNTL (0x0E06)*/
	0x480E6201, /* [0x00D8] == TYPE4 == */
	0x00000000, /* [0x00D9] A5X_VPC_MODE_CNTL (0x0E62)*/
	0x70EC8005, /* [0x00DA] == TYPE7: SET_RENDER_MODE (6C) == */
	0x00000002, /* [0x00DB] */
	0x00000000, /* [0x00DC] */
	0x00000000, /* [0x00DD] */
	0x00000008, /* [0x00DE] */
	0x00000001, /* [0x00DF] */
	0x40E14001, /* [0x00E0] == TYPE4 == */
	0x00000204, /* [0x00E1] A5X_RB_CNTL_CTX_0 (0xE140)*/
	0x709D0001, /* [0x00E2] == TYPE7: SKIP_IB2_ENABLE_GLOBAL (1D) == */
	0x00000000, /* [0x00E3] */
	0x48E0EA02, /* [0x00E4] == TYPE4 == */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx_packets.h:227 [MATCH: timeout] ---
	0x480D0201, /* [0x00C9] == TYPE4 == */
	0x0000001F, /* [0x00CA] A5X_PC_MODE_CNTL (0x0D02)*/
	0x480EC201, /* [0x00CB] == TYPE4 == */
	0x0000001E, /* [0x00CC] A5X_SP_MODE_CNTL (0x0EC2)*/
	0x400EC001, /* [0x00CD] == TYPE4 == */
	0x40000800, /* [0x00CE] A5X_SP_DBG_ECO_CNTL (0x0EC0)*/
	0x400F0201, /* [0x00CF] == TYPE4 == */
	0x00000544, /* [0x00D0] A5X_TPL1_MODE_CNTL (0x0F02)*/
	0x400E0002, /* [0x00D1] == TYPE4 == */
	0x00000080, /* [0x00D2] A5X_HLSQ_TIMEOUT_THRESHOLD_0 (0x0E00)*/
	0x00000000, /* [0x00D3] A5X_HLSQ_TIMEOUT_THRESHOLD_1 (0x0E01)*/
	0x400E6001, /* [0x00D4] == TYPE4 == */
	0x00000400, /* [0x00D5] A5X_VPC_DBG_ECO_CNTL (0x0E60)*/
	0x400E0601, /* [0x00D6] == TYPE4 == */
	0x00000001, /* [0x00D7] A5X_HLSQ_MODE_CNTL (0x0E06)*/
	0x480E6201, /* [0x00D8] == TYPE4 == */
	0x00000000, /* [0x00D9] A5X_VPC_MODE_CNTL (0x0E62)*/
	0x70EC8005, /* [0x00DA] == TYPE7: SET_RENDER_MODE (6C) == */
	0x00000002, /* [0x00DB] */
	0x00000000, /* [0x00DC] */
	0x00000000, /* [0x00DD] */
	0x00000008, /* [0x00DE] */
	0x00000001, /* [0x00DF] */
	0x40E14001, /* [0x00E0] == TYPE4 == */
	0x00000204, /* [0x00E1] A5X_RB_CNTL_CTX_0 (0xE140)*/
	0x709D0001, /* [0x00E2] == TYPE7: SKIP_IB2_ENABLE_GLOBAL (1D) == */
	0x00000000, /* [0x00E3] */
	0x48E0EA02, /* [0x00E4] == TYPE4 == */
	0x00000000, /* [0x00E5] A5X_GRAS_SC_WINDOW_SCISSOR_TL_CTX_0 (0xE0EA)*/

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx_perfcounter.c:99 [MATCH: timeout] ---
	/*
	 * schedule dispatcher to make sure rb[0] is run, because
	 * if the current RB is not rb[0] and gpu is idle then
	 * rb[0] will not get scheduled to run
	 */
	if (adreno_dev->cur_rb != rb)
		adreno_scheduler_queue(adreno_dev);

	/* wait for the above commands submitted to complete */
	ret = adreno_ringbuffer_waittimestamp(rb, rb->timestamp,
		ADRENO_IDLE_TIMEOUT);

	if (ret) {
		/*
		 * If we were woken up because of cancelling rb events
		 * either due to soft reset or adreno_stop, ignore the
		 * error and return 0 here. The perfcounter is already
		 * set up in software and it will be programmed in
		 * hardware when we wake up or come up after soft reset,
		 * by adreno_perfcounter_restore.
		 */
		if (ret == -EAGAIN)
			ret = 0;
		else
			dev_err(device->dev,
				     "Perfcounter %s/%u/%u start via commands failed %d\n",
				     group->name, counter, countable, ret);
	}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx_preempt.c:41 [MATCH: timeout] ---
		kgsl_regwrite(device, A5XX_CP_RB_WPTR, rb->wptr);
		/*
		 * In case something got submitted while preemption was on
		 * going, reset the timer.
		 */
		reset_timer = true;
	}

	if (reset_timer)
		rb->dispatch_q.expires = jiffies +
			msecs_to_jiffies(adreno_drawobj_timeout);

	spin_unlock_irqrestore(&rb->preempt_lock, flags);
}

static void _a5xx_preemption_done(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	unsigned int status;

	/*
	 * In the very unlikely case that the power is off, do nothing - the
	 * state will be reset on power up and everybody will be happy
	 */

	if (!kgsl_state_is_awake(device))
		return;

	kgsl_regread(device, A5XX_CP_CONTEXT_SWITCH_CNTL, &status);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx_preempt.c:245 [MATCH: timeout] ---

	kgsl_regwrite(device, A5XX_CP_CONTEXT_SWITCH_RESTORE_ADDR_LO,
		lower_32_bits(next->preemption_desc->gpuaddr));
	kgsl_regwrite(device, A5XX_CP_CONTEXT_SWITCH_RESTORE_ADDR_HI,
		upper_32_bits(next->preemption_desc->gpuaddr));

	adreno_dev->next_rb = next;

	/* Start the timer to detect a stuck preemption */
	mod_timer(&adreno_dev->preempt.timer,
		jiffies + msecs_to_jiffies(ADRENO_PREEMPT_TIMEOUT));

	trace_adreno_preempt_trigger(adreno_dev->cur_rb->id, adreno_dev->next_rb->id,
		1, 0);

	adreno_set_preempt_state(adreno_dev, ADRENO_PREEMPT_TRIGGERED);

	/* Trigger the preemption */
	kgsl_regwrite(device, A5XX_CP_CONTEXT_SWITCH_CNTL, 1);
}

void a5xx_preempt_callback(struct adreno_device *adreno_dev, int bit)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	unsigned int status;

	if (!adreno_move_preempt_state(adreno_dev,
		ADRENO_PREEMPT_TRIGGERED, ADRENO_PREEMPT_PENDING))
		return;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx_preempt.c:139 [MATCH: mutex_lock] ---

static void _a5xx_preemption_worker(struct work_struct *work)
{
	struct adreno_preemption *preempt = container_of(work,
		struct adreno_preemption, work);
	struct adreno_device *adreno_dev = container_of(preempt,
		struct adreno_device, preempt);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	/* Need to take the mutex to make sure that the power stays on */
	kgsl_mutex_lock(&device->mutex);

	if (adreno_in_preempt_state(adreno_dev, ADRENO_PREEMPT_FAULTED))
		_a5xx_preemption_fault(adreno_dev);

	kgsl_mutex_unlock(&device->mutex);
}

/* Find the highest priority active ringbuffer */
static struct adreno_ringbuffer *a5xx_next_ringbuffer(
		struct adreno_device *adreno_dev)
{
	struct adreno_ringbuffer *rb;
	unsigned long flags;
	unsigned int i;

	FOR_EACH_RINGBUFFER(adreno_dev, rb, i) {
		bool empty;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx_preempt.c:310 [MATCH: mutex_lock] ---
	a5xx_preemption_trigger(adreno_dev);
}

void a5xx_preemption_schedule(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	if (!adreno_is_preemption_enabled(adreno_dev))
		return;

	kgsl_mutex_lock(&device->mutex);

	if (adreno_in_preempt_state(adreno_dev, ADRENO_PREEMPT_COMPLETE))
		_a5xx_preemption_done(adreno_dev);

	a5xx_preemption_trigger(adreno_dev);

	kgsl_mutex_unlock(&device->mutex);
}

u32 a5xx_preemption_pre_ibsubmit(struct adreno_device *adreno_dev,
			struct adreno_ringbuffer *rb,
			struct adreno_context *drawctxt, u32 *cmds)
{
	unsigned int *cmds_orig = cmds;
	uint64_t gpuaddr = rb->preemption_desc->gpuaddr;
	unsigned int preempt_style = 0;

	if (!adreno_is_preemption_enabled(adreno_dev))

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx_preempt.c:144 [MATCH: mutex_unlock] ---
	struct adreno_device *adreno_dev = container_of(preempt,
		struct adreno_device, preempt);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	/* Need to take the mutex to make sure that the power stays on */
	kgsl_mutex_lock(&device->mutex);

	if (adreno_in_preempt_state(adreno_dev, ADRENO_PREEMPT_FAULTED))
		_a5xx_preemption_fault(adreno_dev);

	kgsl_mutex_unlock(&device->mutex);
}

/* Find the highest priority active ringbuffer */
static struct adreno_ringbuffer *a5xx_next_ringbuffer(
		struct adreno_device *adreno_dev)
{
	struct adreno_ringbuffer *rb;
	unsigned long flags;
	unsigned int i;

	FOR_EACH_RINGBUFFER(adreno_dev, rb, i) {
		bool empty;

		spin_lock_irqsave(&rb->preempt_lock, flags);
		empty = adreno_rb_empty(rb);
		spin_unlock_irqrestore(&rb->preempt_lock, flags);

		if (!empty)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx_preempt.c:317 [MATCH: mutex_unlock] ---
	if (!adreno_is_preemption_enabled(adreno_dev))
		return;

	kgsl_mutex_lock(&device->mutex);

	if (adreno_in_preempt_state(adreno_dev, ADRENO_PREEMPT_COMPLETE))
		_a5xx_preemption_done(adreno_dev);

	a5xx_preemption_trigger(adreno_dev);

	kgsl_mutex_unlock(&device->mutex);
}

u32 a5xx_preemption_pre_ibsubmit(struct adreno_device *adreno_dev,
			struct adreno_ringbuffer *rb,
			struct adreno_context *drawctxt, u32 *cmds)
{
	unsigned int *cmds_orig = cmds;
	uint64_t gpuaddr = rb->preemption_desc->gpuaddr;
	unsigned int preempt_style = 0;

	if (!adreno_is_preemption_enabled(adreno_dev))
		return 0;

	if (drawctxt) {
		/*
		 * Preemption from secure to unsecure needs Zap shader to be
		 * run to clear all secure content. CP does not know during
		 * preemption if it is switching between secure and unsecure

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx_preempt.c:26 [MATCH: spin_lock] ---
#define PREEMPT_SMMU_RECORD(_field) \
		offsetof(struct a5xx_cp_smmu_info, _field)

static void _update_wptr(struct adreno_device *adreno_dev, bool reset_timer)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct adreno_ringbuffer *rb = adreno_dev->cur_rb;
	unsigned int wptr;
	unsigned long flags;

	spin_lock_irqsave(&rb->preempt_lock, flags);

	kgsl_regread(device, A5XX_CP_RB_WPTR, &wptr);

	if (wptr != rb->wptr) {
		kgsl_regwrite(device, A5XX_CP_RB_WPTR, rb->wptr);
		/*
		 * In case something got submitted while preemption was on
		 * going, reset the timer.
		 */
		reset_timer = true;
	}

	if (reset_timer)
		rb->dispatch_q.expires = jiffies +
			msecs_to_jiffies(adreno_drawobj_timeout);

	spin_unlock_irqrestore(&rb->preempt_lock, flags);
}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx_preempt.c:158 [MATCH: spin_lock] ---
static struct adreno_ringbuffer *a5xx_next_ringbuffer(
		struct adreno_device *adreno_dev)
{
	struct adreno_ringbuffer *rb;
	unsigned long flags;
	unsigned int i;

	FOR_EACH_RINGBUFFER(adreno_dev, rb, i) {
		bool empty;

		spin_lock_irqsave(&rb->preempt_lock, flags);
		empty = adreno_rb_empty(rb);
		spin_unlock_irqrestore(&rb->preempt_lock, flags);

		if (!empty)
			return rb;
	}

	return NULL;
}

void a5xx_preemption_trigger(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct kgsl_iommu *iommu = KGSL_IOMMU(device);
	struct adreno_ringbuffer *next;
	uint64_t ttbr0;
	unsigned int contextidr;
	unsigned long flags;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx_preempt.c:215 [MATCH: spin_lock] ---
	}

	/* Turn off the dispatcher timer */
	kgsl_delete_timer(&adreno_dev->dispatcher.timer);

	/*
	 * This is the most critical section - we need to take care not to race
	 * until we have programmed the CP for the switch
	 */

	spin_lock_irqsave(&next->preempt_lock, flags);

	/* Get the pagetable from the pagetable info. */
	kgsl_sharedmem_readq(device->scratch, &ttbr0,
		SCRATCH_RB_OFFSET(next->id, ttbr0));
	kgsl_sharedmem_readl(device->scratch, &contextidr,
		SCRATCH_RB_OFFSET(next->id, contextidr));

	kgsl_sharedmem_writel(next->preemption_desc,
		PREEMPT_RECORD(wptr), next->wptr);

	spin_unlock_irqrestore(&next->preempt_lock, flags);

	/* And write it to the smmu info */
	if (kgsl_mmu_is_perprocess(&device->mmu)) {
		kgsl_sharedmem_writeq(iommu->smmu_info,
			PREEMPT_SMMU_RECORD(ttbr0), ttbr0);
		kgsl_sharedmem_writel(iommu->smmu_info,
			PREEMPT_SMMU_RECORD(context_idr), contextidr);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx_preempt.c:43 [MATCH: spin_unlock] ---
		 * In case something got submitted while preemption was on
		 * going, reset the timer.
		 */
		reset_timer = true;
	}

	if (reset_timer)
		rb->dispatch_q.expires = jiffies +
			msecs_to_jiffies(adreno_drawobj_timeout);

	spin_unlock_irqrestore(&rb->preempt_lock, flags);
}

static void _a5xx_preemption_done(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	unsigned int status;

	/*
	 * In the very unlikely case that the power is off, do nothing - the
	 * state will be reset on power up and everybody will be happy
	 */

	if (!kgsl_state_is_awake(device))
		return;

	kgsl_regread(device, A5XX_CP_CONTEXT_SWITCH_CNTL, &status);

	if (status != 0) {

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx_preempt.c:160 [MATCH: spin_unlock] ---
{
	struct adreno_ringbuffer *rb;
	unsigned long flags;
	unsigned int i;

	FOR_EACH_RINGBUFFER(adreno_dev, rb, i) {
		bool empty;

		spin_lock_irqsave(&rb->preempt_lock, flags);
		empty = adreno_rb_empty(rb);
		spin_unlock_irqrestore(&rb->preempt_lock, flags);

		if (!empty)
			return rb;
	}

	return NULL;
}

void a5xx_preemption_trigger(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct kgsl_iommu *iommu = KGSL_IOMMU(device);
	struct adreno_ringbuffer *next;
	uint64_t ttbr0;
	unsigned int contextidr;
	unsigned long flags;

	/* Put ourselves into a possible trigger state */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx_preempt.c:226 [MATCH: spin_unlock] ---

	/* Get the pagetable from the pagetable info. */
	kgsl_sharedmem_readq(device->scratch, &ttbr0,
		SCRATCH_RB_OFFSET(next->id, ttbr0));
	kgsl_sharedmem_readl(device->scratch, &contextidr,
		SCRATCH_RB_OFFSET(next->id, contextidr));

	kgsl_sharedmem_writel(next->preemption_desc,
		PREEMPT_RECORD(wptr), next->wptr);

	spin_unlock_irqrestore(&next->preempt_lock, flags);

	/* And write it to the smmu info */
	if (kgsl_mmu_is_perprocess(&device->mmu)) {
		kgsl_sharedmem_writeq(iommu->smmu_info,
			PREEMPT_SMMU_RECORD(ttbr0), ttbr0);
		kgsl_sharedmem_writel(iommu->smmu_info,
			PREEMPT_SMMU_RECORD(context_idr), contextidr);
	}

	kgsl_regwrite(device, A5XX_CP_CONTEXT_SWITCH_RESTORE_ADDR_LO,
		lower_32_bits(next->preemption_desc->gpuaddr));
	kgsl_regwrite(device, A5XX_CP_CONTEXT_SWITCH_RESTORE_ADDR_HI,
		upper_32_bits(next->preemption_desc->gpuaddr));

	adreno_dev->next_rb = next;

	/* Start the timer to detect a stuck preemption */
	mod_timer(&adreno_dev->preempt.timer,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx_ringbuffer.c:85 [MATCH: spin_lock] ---
		if (IS_ERR(cmds))
			return PTR_ERR(cmds);

		cmds[0] = cp_type7_packet(CP_WHERE_AM_I, 2);
		cmds[1] = lower_32_bits(SCRATCH_RB_GPU_ADDR(device, rb->id,
				rptr));
		cmds[2] = upper_32_bits(SCRATCH_RB_GPU_ADDR(device, rb->id,
				rptr));
	}

	spin_lock_irqsave(&rb->preempt_lock, flags);
	if (adreno_in_preempt_state(adreno_dev, ADRENO_PREEMPT_NONE)) {
		if (adreno_dev->cur_rb == rb)
			kgsl_regwrite(device, A5XX_CP_RB_WPTR, rb->_wptr);
	}

	rb->wptr = rb->_wptr;
	spin_unlock_irqrestore(&rb->preempt_lock, flags);

	return 0;
}

int a5xx_ringbuffer_init(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int i;

	if (IS_ERR_OR_NULL(device->scratch))
		device->scratch = kgsl_allocate_global(device, PAGE_SIZE,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx_ringbuffer.c:92 [MATCH: spin_unlock] ---
				rptr));
	}

	spin_lock_irqsave(&rb->preempt_lock, flags);
	if (adreno_in_preempt_state(adreno_dev, ADRENO_PREEMPT_NONE)) {
		if (adreno_dev->cur_rb == rb)
			kgsl_regwrite(device, A5XX_CP_RB_WPTR, rb->_wptr);
	}

	rb->wptr = rb->_wptr;
	spin_unlock_irqrestore(&rb->preempt_lock, flags);

	return 0;
}

int a5xx_ringbuffer_init(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int i;

	if (IS_ERR_OR_NULL(device->scratch))
		device->scratch = kgsl_allocate_global(device, PAGE_SIZE,
			0, 0, KGSL_MEMDESC_RANDOM | KGSL_MEMDESC_PRIVILEGED,
			"scratch");

	if (IS_ERR(device->scratch))
		return PTR_ERR(device->scratch);

	adreno_dev->cur_rb = &(adreno_dev->ringbuffers[0]);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a5xx_snapshot.c:750 [MATCH: timeout] ---

	/* Turn on APRIV so we can access the buffers */
	kgsl_regwrite(device, A5XX_CP_CNTL, 1);

	kgsl_regwrite(device, A5XX_CP_CRASH_SCRIPT_BASE_LO,
			lower_32_bits(capturescript->gpuaddr));
	kgsl_regwrite(device, A5XX_CP_CRASH_SCRIPT_BASE_HI,
			upper_32_bits(capturescript->gpuaddr));
	kgsl_regwrite(device, A5XX_CP_CRASH_DUMP_CNTL, 1);

	wait_time = jiffies + msecs_to_jiffies(CP_CRASH_DUMPER_TIMEOUT);
	while (!time_after(jiffies, wait_time)) {
		kgsl_regread(device, A5XX_CP_CRASH_DUMP_CNTL, &reg);
		if (reg & 0x4)
			break;
		cpu_relax();
	}

	kgsl_regwrite(device, A5XX_CP_CNTL, 0);

	if (!(reg & 0x4)) {
		dev_err(device->dev, "Crash dump timed out: 0x%X\n", reg);
		return;
	}

	crash_dump_valid = true;
}

static int get_hlsq_registers(struct kgsl_device *device,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx.c:2349 [MATCH: timeout] ---
	void __iomem *addr = kgsl_regmap_virt(&device->regmap,
		A6XX_GMU_SPTPRAC_PWR_CLK_STATUS);
	u32 val;

	if (test_bit(ADRENO_DEVICE_GPU_REGULATOR_ENABLED, &adreno_dev->priv))
		return 0;

	kgsl_regwrite(device, A6XX_GMU_GX_SPTPRAC_POWER_CONTROL,
		SPTPRAC_POWERON_CTRL_MASK);

	if (readl_poll_timeout(addr, val,
		(val & SPTPRAC_POWERON_STATUS_MASK) ==
		SPTPRAC_POWERON_STATUS_MASK, 10, 10 * 1000)) {
		dev_err(device->dev, "power on SPTPRAC fail\n");
		return -EINVAL;
	}

	set_bit(ADRENO_DEVICE_GPU_REGULATOR_ENABLED, &adreno_dev->priv);
	return 0;
}

static void a619_holi_sptprac_disable(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	void __iomem *addr = kgsl_regmap_virt(&device->regmap,
		A6XX_GMU_SPTPRAC_PWR_CLK_STATUS);
	u32 val;

	if (!test_and_clear_bit(ADRENO_DEVICE_GPU_REGULATOR_ENABLED,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx.c:2377 [MATCH: timeout] ---
	if (!test_and_clear_bit(ADRENO_DEVICE_GPU_REGULATOR_ENABLED,
		&adreno_dev->priv))
		return;

	/* Ensure that retention is on */
	kgsl_regrmw(device, A6XX_GPU_CC_GX_GDSCR, 0,
		A6XX_RETAIN_FF_ENABLE_ENABLE_MASK);

	kgsl_regwrite(device, A6XX_GMU_GX_SPTPRAC_POWER_CONTROL,
		SPTPRAC_POWEROFF_CTRL_MASK);
	if (readl_poll_timeout(addr, val,
		(val & SPTPRAC_POWEROFF_STATUS_MASK) ==
		SPTPRAC_POWEROFF_STATUS_MASK, 10, 10 * 1000))
		dev_err(device->dev, "power off SPTPRAC fail\n");
}

/* This is a non GMU/RGMU part */
const struct adreno_gpudev adreno_a6xx_gpudev = {
	.reg_offsets = a6xx_register_offsets,
	.probe = a6xx_probe,
	.start = a6xx_nogmu_start,
	.snapshot = a6xx_snapshot,
	.init = a6xx_nogmu_init,
	.irq_handler = a6xx_irq_handler,
	.rb_start = a6xx_rb_start,
	.regulator_disable = a6xx_prepare_for_regulator_disable,
	.gpu_keepalive = a6xx_gpu_keepalive,
	.hw_isidle = a6xx_hw_isidle,
	.iommu_fault_block = a6xx_iommu_fault_block,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx.c:1741 [MATCH: mutex_unlock] ---
	 * Smmu driver takes a vote on CX gdsc before calling the kgsl
	 * pagefault handler. If there is contention for device mutex in this
	 * path and the dispatcher fault handler is holding this lock, trying
	 * to turn off CX gdsc will fail during the reset. So to avoid blocking
	 * here, try to lock device mutex and return if it fails.
	 */
	if (!kgsl_mutex_trylock(&device->mutex))
		return "UCHE: unknown";

	if (!kgsl_state_is_awake(device)) {
		kgsl_mutex_unlock(&device->mutex);
		return "UCHE: unknown";
	}

	kgsl_regread(device, A6XX_UCHE_CLIENT_PF, &uche_client_id);
	kgsl_mutex_unlock(&device->mutex);

	/* Ignore the value if the gpu is in IFPC */
	if (uche_client_id == SCOOBYDOO)
		return "UCHE: unknown";

	if (adreno_is_a660(ADRENO_DEVICE(device))) {

		/* Mask is 7 bits for A660 */
		uche_client_id &= 0x7F;
		if (uche_client_id >= ARRAY_SIZE(uche_client_a660) ||
				(mid == 2))
			return "UCHE: Unknown";


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx.c:1746 [MATCH: mutex_unlock] ---
	 */
	if (!kgsl_mutex_trylock(&device->mutex))
		return "UCHE: unknown";

	if (!kgsl_state_is_awake(device)) {
		kgsl_mutex_unlock(&device->mutex);
		return "UCHE: unknown";
	}

	kgsl_regread(device, A6XX_UCHE_CLIENT_PF, &uche_client_id);
	kgsl_mutex_unlock(&device->mutex);

	/* Ignore the value if the gpu is in IFPC */
	if (uche_client_id == SCOOBYDOO)
		return "UCHE: unknown";

	if (adreno_is_a660(ADRENO_DEVICE(device))) {

		/* Mask is 7 bits for A660 */
		uche_client_id &= 0x7F;
		if (uche_client_id >= ARRAY_SIZE(uche_client_a660) ||
				(mid == 2))
			return "UCHE: Unknown";

		if (mid == 1)
			snprintf(str, sizeof(str), "UCHE: Not %s",
				uche_client_a660[uche_client_id]);
		else if (mid == 3)
			snprintf(str, sizeof(str), "UCHE: %s",

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx.h:77 [MATCH: timeout] ---
	/** @hwcg_count: Number of registers in @hwcg */
	u32 hwcg_count;
	/** @vbif: List of registers and values to write for VBIF */
	const struct kgsl_regmap_list *vbif;
	/** @vbif_count: Number of registers in @vbif */
	u32 vbif_count;
	/** @veto_fal10: veto status for fal10 feature */
	bool veto_fal10;
	/** @pdc_in_aop: True if PDC programmed in AOP */
	bool pdc_in_aop;
	/** @hang_detect_cycles: Hang detect counter timeout value */
	u32 hang_detect_cycles;
	/** @protected_regs: Array of protected registers for the target */
	const struct adreno_protected_regs *protected_regs;
	/** @disable_tseskip: True if TSESkip logic is disabled */
	bool disable_tseskip;
	/** @gx_cpr_toggle: True to toggle GX CPR FSM to avoid CPR stalls */
	bool gx_cpr_toggle;
	/** @ctxt_record_size: Size of the preemption record in bytes */
	u64 ctxt_record_size;
	/** @gmu_hub_clk_freq: Gmu hub interface clock frequency */
	u64 gmu_hub_clk_freq;
};

#define SPTPRAC_POWERON_CTRL_MASK	0x00778000
#define SPTPRAC_POWEROFF_CTRL_MASK	0x00778001
#define SPTPRAC_POWEROFF_STATUS_MASK	BIT(2)
#define SPTPRAC_POWERON_STATUS_MASK	BIT(3)
#define A6XX_RETAIN_FF_ENABLE_ENABLE_MASK BIT(11)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:260 [MATCH: timeout] ---
};
ATTRIBUTE_GROUPS(stats);

static struct kobj_type stats_kobj_type = {
	.sysfs_ops = &kobj_sysfs_ops,
	.default_groups = stats_groups,
};

static int timed_poll_check_rscc(struct kgsl_device *device,
		unsigned int offset, unsigned int expected_ret,
		unsigned int timeout, unsigned int mask)
{
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	u32 value;

	if (!adreno_is_a650_family(adreno_dev))
		return gmu_core_timed_poll_check(device,
				offset + RSCC_OFFSET_LEGACY,
				expected_ret, timeout, mask);

	return readl_poll_timeout(gmu->rscc_virt + (offset << 2), value,
		(value & mask) == expected_ret, 100, timeout * 1000);
}

struct a6xx_gmu_device *to_a6xx_gmu(struct adreno_device *adreno_dev)
{
	struct a6xx_device *a6xx_dev = container_of(adreno_dev,
					struct a6xx_device, adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:269 [MATCH: timeout] ---
		unsigned int offset, unsigned int expected_ret,
		unsigned int timeout, unsigned int mask)
{
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	u32 value;

	if (!adreno_is_a650_family(adreno_dev))
		return gmu_core_timed_poll_check(device,
				offset + RSCC_OFFSET_LEGACY,
				expected_ret, timeout, mask);

	return readl_poll_timeout(gmu->rscc_virt + (offset << 2), value,
		(value & mask) == expected_ret, 100, timeout * 1000);
}

struct a6xx_gmu_device *to_a6xx_gmu(struct adreno_device *adreno_dev)
{
	struct a6xx_device *a6xx_dev = container_of(adreno_dev,
					struct a6xx_device, adreno_dev);

	return &a6xx_dev->gmu;
}

struct adreno_device *a6xx_gmu_to_adreno(struct a6xx_gmu_device *gmu)
{
	struct a6xx_device *a6xx_dev =
			container_of(gmu, struct a6xx_device, gmu);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:271 [MATCH: timeout] ---
{
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	u32 value;

	if (!adreno_is_a650_family(adreno_dev))
		return gmu_core_timed_poll_check(device,
				offset + RSCC_OFFSET_LEGACY,
				expected_ret, timeout, mask);

	return readl_poll_timeout(gmu->rscc_virt + (offset << 2), value,
		(value & mask) == expected_ret, 100, timeout * 1000);
}

struct a6xx_gmu_device *to_a6xx_gmu(struct adreno_device *adreno_dev)
{
	struct a6xx_device *a6xx_dev = container_of(adreno_dev,
					struct a6xx_device, adreno_dev);

	return &a6xx_dev->gmu;
}

struct adreno_device *a6xx_gmu_to_adreno(struct a6xx_gmu_device *gmu)
{
	struct a6xx_device *a6xx_dev =
			container_of(gmu, struct a6xx_device, gmu);

	return &a6xx_dev->adreno_dev;
}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:272 [MATCH: timeout] ---
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	u32 value;

	if (!adreno_is_a650_family(adreno_dev))
		return gmu_core_timed_poll_check(device,
				offset + RSCC_OFFSET_LEGACY,
				expected_ret, timeout, mask);

	return readl_poll_timeout(gmu->rscc_virt + (offset << 2), value,
		(value & mask) == expected_ret, 100, timeout * 1000);
}

struct a6xx_gmu_device *to_a6xx_gmu(struct adreno_device *adreno_dev)
{
	struct a6xx_device *a6xx_dev = container_of(adreno_dev,
					struct a6xx_device, adreno_dev);

	return &a6xx_dev->gmu;
}

struct adreno_device *a6xx_gmu_to_adreno(struct a6xx_gmu_device *gmu)
{
	struct a6xx_device *a6xx_dev =
			container_of(gmu, struct a6xx_device, gmu);

	return &a6xx_dev->adreno_dev;
}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:545 [MATCH: timeout] ---
done:
	/* Setup GPU PDC */
	_regwrite(cfg, PDC_GPU_SEQ_START_ADDR, 0);
	_regwrite(cfg, PDC_GPU_ENABLE_PDC, PDC_ENABLE_REG_VALUE);

	/* ensure no writes happen before the uCode is fully written */
	wmb();
	return 0;
}

/* GMU timeouts */
#define GMU_IDLE_TIMEOUT	100	/* ms */
#define GMU_START_TIMEOUT	100	/* ms */
#define GPU_START_TIMEOUT	100	/* ms */
#define GPU_RESET_TIMEOUT	1	/* ms */
#define GPU_RESET_TIMEOUT_US	10	/* us */

/*
 * The lowest 16 bits of this value are the number of XO clock cycles
 * for main hysteresis. This is the first hysteresis. Here we set it
 * to 0x1680 cycles, or 300 us. The highest 16 bits of this value are
 * the number of XO clock cycles for short hysteresis. This happens
 * after main hysteresis. Here we set it to 0xA cycles, or 0.5 us.
 */
#define A6X_GMU_LONG_IFPC_HYST	FIELD_PREP(GENMASK(15, 0), 0x1680)
#define A6X_GMU_SHORT_IFPC_HYST	FIELD_PREP(GENMASK(31, 16), 0xA)

/* Minimum IFPC timer (200usec) allowed to override default value */
#define A6X_GMU_LONG_IFPC_HYST_FLOOR	FIELD_PREP(GENMASK(15, 0), 0x0F00)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:546 [MATCH: timeout] ---
	/* Setup GPU PDC */
	_regwrite(cfg, PDC_GPU_SEQ_START_ADDR, 0);
	_regwrite(cfg, PDC_GPU_ENABLE_PDC, PDC_ENABLE_REG_VALUE);

	/* ensure no writes happen before the uCode is fully written */
	wmb();
	return 0;
}

/* GMU timeouts */
#define GMU_IDLE_TIMEOUT	100	/* ms */
#define GMU_START_TIMEOUT	100	/* ms */
#define GPU_START_TIMEOUT	100	/* ms */
#define GPU_RESET_TIMEOUT	1	/* ms */
#define GPU_RESET_TIMEOUT_US	10	/* us */

/*
 * The lowest 16 bits of this value are the number of XO clock cycles
 * for main hysteresis. This is the first hysteresis. Here we set it
 * to 0x1680 cycles, or 300 us. The highest 16 bits of this value are
 * the number of XO clock cycles for short hysteresis. This happens
 * after main hysteresis. Here we set it to 0xA cycles, or 0.5 us.
 */
#define A6X_GMU_LONG_IFPC_HYST	FIELD_PREP(GENMASK(15, 0), 0x1680)
#define A6X_GMU_SHORT_IFPC_HYST	FIELD_PREP(GENMASK(31, 16), 0xA)

/* Minimum IFPC timer (200usec) allowed to override default value */
#define A6X_GMU_LONG_IFPC_HYST_FLOOR	FIELD_PREP(GENMASK(15, 0), 0x0F00)


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:548 [MATCH: timeout] ---
	_regwrite(cfg, PDC_GPU_ENABLE_PDC, PDC_ENABLE_REG_VALUE);

	/* ensure no writes happen before the uCode is fully written */
	wmb();
	return 0;
}

/* GMU timeouts */
#define GMU_IDLE_TIMEOUT	100	/* ms */
#define GMU_START_TIMEOUT	100	/* ms */
#define GPU_START_TIMEOUT	100	/* ms */
#define GPU_RESET_TIMEOUT	1	/* ms */
#define GPU_RESET_TIMEOUT_US	10	/* us */

/*
 * The lowest 16 bits of this value are the number of XO clock cycles
 * for main hysteresis. This is the first hysteresis. Here we set it
 * to 0x1680 cycles, or 300 us. The highest 16 bits of this value are
 * the number of XO clock cycles for short hysteresis. This happens
 * after main hysteresis. Here we set it to 0xA cycles, or 0.5 us.
 */
#define A6X_GMU_LONG_IFPC_HYST	FIELD_PREP(GENMASK(15, 0), 0x1680)
#define A6X_GMU_SHORT_IFPC_HYST	FIELD_PREP(GENMASK(31, 16), 0xA)

/* Minimum IFPC timer (200usec) allowed to override default value */
#define A6X_GMU_LONG_IFPC_HYST_FLOOR	FIELD_PREP(GENMASK(15, 0), 0x0F00)

/*
 * a6xx_gmu_power_config() - Configure and enable GMU's low power mode

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:549 [MATCH: timeout] ---

	/* ensure no writes happen before the uCode is fully written */
	wmb();
	return 0;
}

/* GMU timeouts */
#define GMU_IDLE_TIMEOUT	100	/* ms */
#define GMU_START_TIMEOUT	100	/* ms */
#define GPU_START_TIMEOUT	100	/* ms */
#define GPU_RESET_TIMEOUT	1	/* ms */
#define GPU_RESET_TIMEOUT_US	10	/* us */

/*
 * The lowest 16 bits of this value are the number of XO clock cycles
 * for main hysteresis. This is the first hysteresis. Here we set it
 * to 0x1680 cycles, or 300 us. The highest 16 bits of this value are
 * the number of XO clock cycles for short hysteresis. This happens
 * after main hysteresis. Here we set it to 0xA cycles, or 0.5 us.
 */
#define A6X_GMU_LONG_IFPC_HYST	FIELD_PREP(GENMASK(15, 0), 0x1680)
#define A6X_GMU_SHORT_IFPC_HYST	FIELD_PREP(GENMASK(31, 16), 0xA)

/* Minimum IFPC timer (200usec) allowed to override default value */
#define A6X_GMU_LONG_IFPC_HYST_FLOOR	FIELD_PREP(GENMASK(15, 0), 0x0F00)

/*
 * a6xx_gmu_power_config() - Configure and enable GMU's low power mode
 * setting based on ADRENO feature flags.

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:550 [MATCH: timeout] ---
	/* ensure no writes happen before the uCode is fully written */
	wmb();
	return 0;
}

/* GMU timeouts */
#define GMU_IDLE_TIMEOUT	100	/* ms */
#define GMU_START_TIMEOUT	100	/* ms */
#define GPU_START_TIMEOUT	100	/* ms */
#define GPU_RESET_TIMEOUT	1	/* ms */
#define GPU_RESET_TIMEOUT_US	10	/* us */

/*
 * The lowest 16 bits of this value are the number of XO clock cycles
 * for main hysteresis. This is the first hysteresis. Here we set it
 * to 0x1680 cycles, or 300 us. The highest 16 bits of this value are
 * the number of XO clock cycles for short hysteresis. This happens
 * after main hysteresis. Here we set it to 0xA cycles, or 0.5 us.
 */
#define A6X_GMU_LONG_IFPC_HYST	FIELD_PREP(GENMASK(15, 0), 0x1680)
#define A6X_GMU_SHORT_IFPC_HYST	FIELD_PREP(GENMASK(31, 16), 0xA)

/* Minimum IFPC timer (200usec) allowed to override default value */
#define A6X_GMU_LONG_IFPC_HYST_FLOOR	FIELD_PREP(GENMASK(15, 0), 0x0F00)

/*
 * a6xx_gmu_power_config() - Configure and enable GMU's low power mode
 * setting based on ADRENO feature flags.
 * @adreno_dev: Pointer to adreno device

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:723 [MATCH: timeout] ---

	/* RSC wake sequence */
	gmu_core_regwrite(device, A6XX_GMU_RSCC_CONTROL_REQ, BIT(1));

	/* Write request before polling */
	wmb();

	if (gmu_core_timed_poll_check(device,
			A6XX_GMU_RSCC_CONTROL_ACK,
			BIT(1),
			GPU_START_TIMEOUT,
			BIT(1))) {
		dev_err(GMU_PDEV_DEV(device), "Failed to do GPU RSC power on\n");
		return -ETIMEDOUT;
	}

	if (timed_poll_check_rscc(device,
			A6XX_RSCC_SEQ_BUSY_DRV0,
			0,
			GPU_START_TIMEOUT,
			0xFFFFFFFF))
		goto error_rsc;

	gmu_core_regwrite(device, A6XX_GMU_RSCC_CONTROL_REQ, 0);

	clear_bit(GMU_PRIV_RSCC_SLEEP_DONE, &gmu->flags);

	return 0;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:732 [MATCH: timeout] ---
			BIT(1),
			GPU_START_TIMEOUT,
			BIT(1))) {
		dev_err(GMU_PDEV_DEV(device), "Failed to do GPU RSC power on\n");
		return -ETIMEDOUT;
	}

	if (timed_poll_check_rscc(device,
			A6XX_RSCC_SEQ_BUSY_DRV0,
			0,
			GPU_START_TIMEOUT,
			0xFFFFFFFF))
		goto error_rsc;

	gmu_core_regwrite(device, A6XX_GMU_RSCC_CONTROL_REQ, 0);

	clear_bit(GMU_PRIV_RSCC_SLEEP_DONE, &gmu->flags);

	return 0;

error_rsc:
	dev_err(GMU_PDEV_DEV(device),
		"GPU RSC sequence stuck in waking up GPU\n");
	return -ETIMEDOUT;
}

int a6xx_rscc_sleep_sequence(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:774 [MATCH: timeout] ---
	gmu_core_regread(device, A6XX_GPU_GMU_CX_GMU_PWR_COL_CP_RESP,
			&gmu->log_wptr_retention);

	gmu_core_regwrite(device, A6XX_GMU_RSCC_CONTROL_REQ, 1);
	/* Make sure the request completes before continuing */
	wmb();

	ret = timed_poll_check_rscc(device,
			A6XX_GPU_RSCC_RSC_STATUS0_DRV0,
			BIT(16),
			GPU_START_TIMEOUT,
			BIT(16));

	if (ret) {
		dev_err(GMU_PDEV_DEV(device), "GPU RSC power off fail\n");
		return -ETIMEDOUT;
	}

	gmu_core_regwrite(device, A6XX_GMU_RSCC_CONTROL_REQ, 0);

	if (adreno_dev->lm_enabled)
		gmu_core_regwrite(device, A6XX_GMU_AO_SPARE_CNTL, 0);

	set_bit(GMU_PRIV_RSCC_SLEEP_DONE, &gmu->flags);

	return 0;
}

#define MAX_GMUFW_SIZE	0x8000	/* in bytes */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:938 [MATCH: timeout] ---
			return -EINVAL;
		}

		set = BIT(30 - req * 2);
		check = BIT(31 - req);
	}

	gmu_core_regwrite(device, A6XX_GMU_HOST2GMU_INTR_SET, set);

	if (gmu_core_timed_poll_check(device, A6XX_GMU_GMU2HOST_INTR_INFO,
				check, GPU_START_TIMEOUT, check)) {
		if (req == oob_perfcntr)
			gmu->num_oob_perfcntr--;
		ret = -ETIMEDOUT;
		WARN(1, "OOB request %s timed out\n", oob_to_str(req));
		gmu_core_fault_snapshot(device, GMU_FAULT_OOB_SET);
		trigger_reset_recovery(adreno_dev, req);
	}

	gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_CLR, check);

	trace_kgsl_gmu_oob_set(set);
	return ret;
}

void a6xx_gmu_oob_clear(struct kgsl_device *device,
		enum oob_request req)
{
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:1102 [MATCH: timeout] ---
	A622_RSCC_TCS3_DRV0_STATUS,
	A622_RSCC_TCS4_DRV0_STATUS,
	A622_RSCC_TCS5_DRV0_STATUS,
	A622_RSCC_TCS6_DRV0_STATUS,
	A622_RSCC_TCS7_DRV0_STATUS,
	A622_RSCC_TCS8_DRV0_STATUS,
	A622_RSCC_TCS9_DRV0_STATUS,
};

static int a6xx_complete_rpmh_votes(struct adreno_device *adreno_dev,
		unsigned int timeout)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	/* Number of TCS commands are increased to 10 from A650 family onwards */
	int count = adreno_is_a650_family(adreno_dev) ?
				ARRAY_SIZE(a6xx_rscc_tcsm_drv0_status_reglist) : 4;
	int i, ret = 0;

	if (adreno_is_a622(adreno_dev)) {
		for (i = 0; i < count; i++)
			ret |= timed_poll_check_rscc(device, a622_rscc_tcsm_drv0_status_reglist[i],
					BIT(0), timeout, BIT(0));
	} else {
		for (i = 0; i < count; i++)
			ret |= timed_poll_check_rscc(device, a6xx_rscc_tcsm_drv0_status_reglist[i],
					BIT(0), timeout, BIT(0));
	}

	if (ret)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:1113 [MATCH: timeout] ---
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	/* Number of TCS commands are increased to 10 from A650 family onwards */
	int count = adreno_is_a650_family(adreno_dev) ?
				ARRAY_SIZE(a6xx_rscc_tcsm_drv0_status_reglist) : 4;
	int i, ret = 0;

	if (adreno_is_a622(adreno_dev)) {
		for (i = 0; i < count; i++)
			ret |= timed_poll_check_rscc(device, a622_rscc_tcsm_drv0_status_reglist[i],
					BIT(0), timeout, BIT(0));
	} else {
		for (i = 0; i < count; i++)
			ret |= timed_poll_check_rscc(device, a6xx_rscc_tcsm_drv0_status_reglist[i],
					BIT(0), timeout, BIT(0));
	}

	if (ret)
		dev_err(device->dev, "RPMH votes timedout: %d\n", ret);

	return ret;
}

#define SPTPRAC_CTRL_TIMEOUT		10 /* ms */

/*
 * a6xx_gmu_sptprac_enable() - Power on SPTPRAC
 * @adreno_dev: Pointer to Adreno device
 */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:1117 [MATCH: timeout] ---
				ARRAY_SIZE(a6xx_rscc_tcsm_drv0_status_reglist) : 4;
	int i, ret = 0;

	if (adreno_is_a622(adreno_dev)) {
		for (i = 0; i < count; i++)
			ret |= timed_poll_check_rscc(device, a622_rscc_tcsm_drv0_status_reglist[i],
					BIT(0), timeout, BIT(0));
	} else {
		for (i = 0; i < count; i++)
			ret |= timed_poll_check_rscc(device, a6xx_rscc_tcsm_drv0_status_reglist[i],
					BIT(0), timeout, BIT(0));
	}

	if (ret)
		dev_err(device->dev, "RPMH votes timedout: %d\n", ret);

	return ret;
}

#define SPTPRAC_CTRL_TIMEOUT		10 /* ms */

/*
 * a6xx_gmu_sptprac_enable() - Power on SPTPRAC
 * @adreno_dev: Pointer to Adreno device
 */
int a6xx_gmu_sptprac_enable(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:1126 [MATCH: timeout] ---
			ret |= timed_poll_check_rscc(device, a6xx_rscc_tcsm_drv0_status_reglist[i],
					BIT(0), timeout, BIT(0));
	}

	if (ret)
		dev_err(device->dev, "RPMH votes timedout: %d\n", ret);

	return ret;
}

#define SPTPRAC_CTRL_TIMEOUT		10 /* ms */

/*
 * a6xx_gmu_sptprac_enable() - Power on SPTPRAC
 * @adreno_dev: Pointer to Adreno device
 */
int a6xx_gmu_sptprac_enable(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	/* Only certain targets have sptprac */
	if (!adreno_is_a630(adreno_dev) && !adreno_is_a615_family(adreno_dev))
		return 0;

	if (test_bit(ADRENO_DEVICE_GPU_REGULATOR_ENABLED, &adreno_dev->priv))
		return 0;

	/* GMU enabled a630 and a615 targets */
	gmu_core_regwrite(device, A6XX_GMU_GX_SPTPRAC_POWER_CONTROL,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:1150 [MATCH: timeout] ---
	if (test_bit(ADRENO_DEVICE_GPU_REGULATOR_ENABLED, &adreno_dev->priv))
		return 0;

	/* GMU enabled a630 and a615 targets */
	gmu_core_regwrite(device, A6XX_GMU_GX_SPTPRAC_POWER_CONTROL,
			SPTPRAC_POWERON_CTRL_MASK);

	if (gmu_core_timed_poll_check(device,
			A6XX_GMU_SPTPRAC_PWR_CLK_STATUS,
			SPTPRAC_POWERON_STATUS_MASK,
			SPTPRAC_CTRL_TIMEOUT,
			SPTPRAC_POWERON_STATUS_MASK)) {
		dev_err(GMU_PDEV_DEV(device), "power on SPTPRAC fail\n");
		gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
		return -ETIMEDOUT;
	}

	set_bit(ADRENO_DEVICE_GPU_REGULATOR_ENABLED, &adreno_dev->priv);
	return 0;
}

/*
 * a6xx_gmu_sptprac_disable() - Power of SPTPRAC
 * @adreno_dev: Pointer to Adreno device
 */
void a6xx_gmu_sptprac_disable(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:1189 [MATCH: timeout] ---
	/* Ensure that retention is on */
	gmu_core_regrmw(device, A6XX_GPU_CC_GX_GDSCR, 0,
			A6XX_RETAIN_FF_ENABLE_ENABLE_MASK);

	gmu_core_regwrite(device, A6XX_GMU_GX_SPTPRAC_POWER_CONTROL,
			SPTPRAC_POWEROFF_CTRL_MASK);

	if (gmu_core_timed_poll_check(device,
			A6XX_GMU_SPTPRAC_PWR_CLK_STATUS,
			SPTPRAC_POWEROFF_STATUS_MASK,
			SPTPRAC_CTRL_TIMEOUT,
			SPTPRAC_POWEROFF_STATUS_MASK))
		dev_err(GMU_PDEV_DEV(device), "power off SPTPRAC fail\n");
}

#define SPTPRAC_POWER_OFF	BIT(2)
#define SP_CLK_OFF		BIT(4)
#define GX_GDSC_POWER_OFF	BIT(6)
#define GX_CLK_OFF		BIT(7)
#define is_on(val)		(!(val & (GX_GDSC_POWER_OFF | GX_CLK_OFF)))

bool a6xx_gmu_gx_is_on(struct adreno_device *adreno_dev)
{
	unsigned int val;

	gmu_core_regread(KGSL_DEVICE(adreno_dev),
			A6XX_GMU_SPTPRAC_PWR_CLK_STATUS, &val);
	return is_on(val);
}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:1310 [MATCH: timeout] ---
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct device *gmu_pdev_dev = GMU_PDEV_DEV(device);
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	unsigned int reg, reg1, reg2, reg3, reg4, reg5, reg6, reg7, reg8;
	unsigned long t;
	uint64_t ts1, ts2, ts3;

	ts1 = a6xx_read_alwayson(adreno_dev);

	t = jiffies + msecs_to_jiffies(GMU_IDLE_TIMEOUT);
	do {
		gmu_core_regread(device,
			A6XX_GPU_GMU_CX_GMU_RPMH_POWER_STATE, &reg);
		gmu_core_regread(device,
			A6XX_GMU_SPTPRAC_PWR_CLK_STATUS, &reg1);

		if (idle_trandition_complete(gmu->idle_level, reg, reg1))
			return 0;
		/* Wait 100us to reduce unnecessary AHB bus traffic */
		usleep_range(10, 100);
	} while (!time_after(jiffies, t));

	ts2 = a6xx_read_alwayson(adreno_dev);
	/* Check one last time */

	gmu_core_regread(device, A6XX_GPU_GMU_CX_GMU_RPMH_POWER_STATE, &reg);
	gmu_core_regread(device, A6XX_GMU_SPTPRAC_PWR_CLK_STATUS, &reg1);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:1343 [MATCH: timeout] ---

	/* Collect abort data to help with debugging */
	gmu_core_regread(device, A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS, &reg2);
	gmu_core_regread(device, A6XX_GMU_RBBM_INT_UNMASKED_STATUS, &reg3);
	gmu_core_regread(device, A6XX_GMU_GMU_PWR_COL_KEEPALIVE, &reg4);
	gmu_core_regread(device, A6XX_GMU_AO_SPARE_CNTL, &reg5);

	dev_err(gmu_pdev_dev,
		"----------------------[ GMU error ]----------------------\n");
	dev_err(gmu_pdev_dev,
		"Timeout waiting for lowest idle level %s\n",
		idle_level_name(gmu->idle_level));
	dev_err(gmu_pdev_dev,
		"Start: %llx (absolute ticks)\n", ts1);
	dev_err(gmu_pdev_dev,
		"Poll: %llx (ticks relative to start)\n",
		ts2-ts1);
	dev_err(gmu_pdev_dev,
		"Retry: %llx (ticks relative to poll)\n",
		ts3-ts2);
	dev_err(gmu_pdev_dev,
		"RPMH_POWER_STATE=%x SPTPRAC_PWR_CLK_STATUS=%x\n", reg, reg1);
	dev_err(gmu_pdev_dev, "CX_BUSY_STATUS=%x\n", reg2);
	dev_err(gmu_pdev_dev,
		"RBBM_INT_UNMASKED_STATUS=%x PWR_COL_KEEPALIVE=%x\n",
		reg3, reg4);
	dev_err(gmu_pdev_dev, "A6XX_GMU_AO_SPARE_CNTL=%x\n", reg5);

	if (adreno_is_a660(adreno_dev)) {

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:1783 [MATCH: timeout] ---

	/*
	 * GEMNOC can enter power collapse state during GPU power down sequence.
	 * This could abort CX GDSC collapse. Assert Qactive to avoid this.
	 */
	if ((adreno_is_a662(adreno_dev) || adreno_is_a621(adreno_dev) ||
			adreno_is_a622(adreno_dev) || adreno_is_a642l(adreno_dev)))
		gmu_core_regwrite(device, A6XX_GPU_GMU_CX_GMU_CX_FALNEXT_INTF, 0x1);

	/* Check no outstanding RPMh voting */
	a6xx_complete_rpmh_votes(adreno_dev, GPU_RESET_TIMEOUT);

	/* Clear the WRITEDROPPED fields and set fence to allow mode */
	gmu_core_regwrite(device, A6XX_GMU_AHB_FENCE_STATUS_CLR, 0x7);
	gmu_core_regwrite(device, A6XX_GMU_AO_AHB_FENCE_CTRL, 0);

	/* Make sure above writes are committed before we proceed to recovery */
	wmb();

	gmu_core_regwrite(device, A6XX_GMU_CM3_SYSRESET, 1);

	if (!adreno_is_a630(adreno_dev)) {
		/* Halt GX traffic */
		if (a6xx_gmu_gx_is_on(adreno_dev)) {
			kgsl_regwrite(device, A6XX_RBBM_GBIF_HALT,
				A6XX_GBIF_GX_HALT_MASK);
			adreno_wait_for_halt_ack(device,
					A6XX_RBBM_GBIF_HALT_ACK,
					A6XX_GBIF_GX_HALT_MASK);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:2131 [MATCH: timeout] ---
	 */
	if (!gmu_core_timed_poll_check(device, A6XX_GMU_CM3_FW_INIT_RESULT,
				0x800, 2, 0x800))
		return;

	gmu_core_regread(device, A6XX_GMU_CM3_FW_INIT_RESULT, &result);
	dev_err(GMU_PDEV_DEV(device),
		"GMU cooperative reset timed out 0x%x\n", result);
	/*
	 * If we dont get a snapshot ready from GMU, trigger NMI
	 * and if we still timeout then we just continue with reset.
	 */
	a6xx_gmu_send_nmi(device, true, GMU_FAULT_PANIC_NONE);

	gmu_core_regread(device, A6XX_GMU_CM3_FW_INIT_RESULT, &result);
	if ((result & 0x800) != 0x800)
		dev_err(GMU_PDEV_DEV(device),
			"GMU cooperative reset NMI timed out 0x%x\n", result);
}

static int a6xx_gmu_wait_for_active_transition(
	struct kgsl_device *device)
{
	unsigned int reg;

	if (!gmu_core_isenabled(device))
		return 0;

	if (gmu_core_timed_poll_check(device, A6XX_GPU_GMU_CX_GMU_RPMH_POWER_STATE,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:2340 [MATCH: timeout] ---

	/* Clear any GPU faults that might have been left over */
	adreno_clear_gpu_fault(adreno_dev);

	ret = a6xx_gmu_device_start(adreno_dev);
	if (ret)
		goto err;

	/*
	 * Load PDC and RSC ucode before turning on
	 * GFX rail. This avoids oob set timeout
	 * for oob_boot_slumber request during
	 * GMU first boot
	 */
	if (!test_bit(GMU_PRIV_PDC_RSC_LOADED, &gmu->flags)) {
		ret = a6xx_load_pdc_ucode(adreno_dev);
		if (ret)
			goto err;

		a6xx_load_rsc_ucode(adreno_dev);
		set_bit(GMU_PRIV_PDC_RSC_LOADED, &gmu->flags);
	}

	if (ADRENO_QUIRK(adreno_dev, ADRENO_QUIRK_HFI_USE_REG)) {
		ret = a6xx_gmu_gfx_rail_on(adreno_dev);
		if (ret) {
			a6xx_gmu_oob_clear(device, oob_boot_slumber);
			goto err;
		}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:2831 [MATCH: timeout] ---
		A6XX_GBIF_HALT_ACK, A6XX_GBIF_CLIENT_HALT_MASK);

	/* Halt all AXI requests */
	kgsl_regwrite(device, A6XX_GBIF_HALT, A6XX_GBIF_ARB_HALT_MASK);
	ret = adreno_wait_for_halt_ack(device,
		A6XX_GBIF_HALT_ACK, A6XX_GBIF_ARB_HALT_MASK);

	return ret;
}

#define RPMH_VOTE_TIMEOUT		2 /* ms */

static int a6xx_gmu_power_off(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int ret = 0;

	if (device->gmu_fault)
		goto error;

	/* Wait for the lowest idle level we requested */
	ret = a6xx_gmu_wait_for_lowest_idle(adreno_dev);
	if (ret)
		goto error;

	ret = a6xx_complete_rpmh_votes(adreno_dev, RPMH_VOTE_TIMEOUT);
	if (ret)
		goto error;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:2846 [MATCH: timeout] ---
	int ret = 0;

	if (device->gmu_fault)
		goto error;

	/* Wait for the lowest idle level we requested */
	ret = a6xx_gmu_wait_for_lowest_idle(adreno_dev);
	if (ret)
		goto error;

	ret = a6xx_complete_rpmh_votes(adreno_dev, RPMH_VOTE_TIMEOUT);
	if (ret)
		goto error;

	ret = a6xx_gmu_notify_slumber(adreno_dev);
	if (ret)
		goto error;

	ret = a6xx_gmu_wait_for_idle(adreno_dev);
	if (ret)
		goto error;

	ret = a6xx_rscc_sleep_sequence(adreno_dev);

	gmu_core_rdpm_mx_freq_update(device, 0);

	/* Now that we are done with GMU and GPU, Clear the GBIF */
	if (!adreno_is_a630(adreno_dev)) {
		ret = a6xx_halt_gbif(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:3413 [MATCH: timeout] ---

	set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags);

	device->pwrctrl.last_stat_updated = ktime_get();

	kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE);

done:
	/*
	 * When waking up from a touch event we want to stay active long enough
	 * for the user to send a draw command.  The default idle timer timeout
	 * is shorter than we want so go ahead and push the idle timer out
	 * further for this special case
	 */
	mod_timer(&device->idle_timer, jiffies +
			msecs_to_jiffies(adreno_wake_timeout));

}

const struct adreno_power_ops a6xx_gmu_power_ops = {
	.first_open = a6xx_gmu_first_open,
	.last_close = a6xx_gmu_last_close,
	.active_count_get = a6xx_gmu_active_count_get,
	.pm_suspend = a6xx_gmu_pm_suspend,
	.pm_resume = a6xx_gmu_pm_resume,
	.touch_wakeup = a6xx_gmu_touch_wakeup,
	.gpu_clock_set = a6xx_gmu_clock_set,
	.gpu_bus_set = a6xx_gmu_bus_set,
};

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:3418 [MATCH: timeout] ---
	kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE);

done:
	/*
	 * When waking up from a touch event we want to stay active long enough
	 * for the user to send a draw command.  The default idle timer timeout
	 * is shorter than we want so go ahead and push the idle timer out
	 * further for this special case
	 */
	mod_timer(&device->idle_timer, jiffies +
			msecs_to_jiffies(adreno_wake_timeout));

}

const struct adreno_power_ops a6xx_gmu_power_ops = {
	.first_open = a6xx_gmu_first_open,
	.last_close = a6xx_gmu_last_close,
	.active_count_get = a6xx_gmu_active_count_get,
	.pm_suspend = a6xx_gmu_pm_suspend,
	.pm_resume = a6xx_gmu_pm_resume,
	.touch_wakeup = a6xx_gmu_touch_wakeup,
	.gpu_clock_set = a6xx_gmu_clock_set,
	.gpu_bus_set = a6xx_gmu_bus_set,
};

const struct adreno_power_ops a630_gmu_power_ops = {
	.first_open = a6xx_gmu_first_open,
	.last_close = a6xx_gmu_last_close,
	.active_count_get = a6xx_gmu_active_count_get,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:3127 [MATCH: results] ---
		adreno_dev->bcl_enabled = true;

	/*
	 * There is a possible deadlock scenario during kgsl firmware reading
	 * (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl
	 * device mutex is held and then firmware_request_nowarn is called for reading
	 * firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock.
	 * Whereas in case of devfreq update calls triggered by thermal/bcl or
	 * devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then
	 * tries to take kgsl device mutex as part of get_dev_status/target
	 * calls. This results in deadlock when both thread are unable to acquire
	 * the mutex held by other thread. Enable devfreq updates now as we are
	 * done reading all firmware files.
	 */
	device->pwrscale.devfreq_enabled = true;

	device->pwrctrl.last_stat_updated = ktime_get();

	set_bit(ADRENO_DEVICE_FIRST_BOOT_DONE, &adreno_dev->priv);

	kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE);

	KGSL_BOOT_MARKER("ADRENO Ready");

	return 0;
}

static int a630_vbif_halt(struct adreno_device *adreno_dev)
{

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:3235 [MATCH: mutex_lock] ---
}

static void gmu_idle_check(struct work_struct *work)
{
	struct kgsl_device *device = container_of(work,
					struct kgsl_device, idle_check_ws);
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	int ret;

	kgsl_mutex_lock(&device->mutex);

	if (test_bit(GMU_DISABLE_SLUMBER, &device->gmu_core.flags))
		goto done;

	if (atomic_read(&device->active_cnt) || time_is_after_jiffies(device->idle_jiffies)) {
		kgsl_pwrscale_update(device);
		goto done;
	}

	if (!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags))
		goto done;

	spin_lock(&device->submit_lock);

	if (device->submit_now) {
		spin_unlock(&device->submit_lock);
		kgsl_pwrscale_update(device);
		kgsl_start_idle_timer(device);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:3267 [MATCH: mutex_unlock] ---
	device->skip_inline_submit = true;
	spin_unlock(&device->submit_lock);

	ret = a6xx_power_off(adreno_dev);
	if (ret == -EBUSY) {
		kgsl_pwrscale_update(device);
		kgsl_start_idle_timer(device);
	}

done:
	kgsl_mutex_unlock(&device->mutex);
}

static int a6xx_gmu_first_open(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int ret;

	/*
	 * Do the one time settings that need to happen when we
	 * attempt to boot the gpu the very first time
	 */
	ret = a6xx_first_boot(adreno_dev);
	if (ret)
		return ret;

	/*
	 * A client that does a first_open but never closes the device
	 * may prevent us from going back to SLUMBER. So trigger the idle

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:3248 [MATCH: spin_lock] ---
		goto done;

	if (atomic_read(&device->active_cnt) || time_is_after_jiffies(device->idle_jiffies)) {
		kgsl_pwrscale_update(device);
		goto done;
	}

	if (!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags))
		goto done;

	spin_lock(&device->submit_lock);

	if (device->submit_now) {
		spin_unlock(&device->submit_lock);
		kgsl_pwrscale_update(device);
		kgsl_start_idle_timer(device);
		goto done;
	}

	device->skip_inline_submit = true;
	spin_unlock(&device->submit_lock);

	ret = a6xx_power_off(adreno_dev);
	if (ret == -EBUSY) {
		kgsl_pwrscale_update(device);
		kgsl_start_idle_timer(device);
	}

done:

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:3251 [MATCH: spin_unlock] ---
		kgsl_pwrscale_update(device);
		goto done;
	}

	if (!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags))
		goto done;

	spin_lock(&device->submit_lock);

	if (device->submit_now) {
		spin_unlock(&device->submit_lock);
		kgsl_pwrscale_update(device);
		kgsl_start_idle_timer(device);
		goto done;
	}

	device->skip_inline_submit = true;
	spin_unlock(&device->submit_lock);

	ret = a6xx_power_off(adreno_dev);
	if (ret == -EBUSY) {
		kgsl_pwrscale_update(device);
		kgsl_start_idle_timer(device);
	}

done:
	kgsl_mutex_unlock(&device->mutex);
}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu.c:3258 [MATCH: spin_unlock] ---
	spin_lock(&device->submit_lock);

	if (device->submit_now) {
		spin_unlock(&device->submit_lock);
		kgsl_pwrscale_update(device);
		kgsl_start_idle_timer(device);
		goto done;
	}

	device->skip_inline_submit = true;
	spin_unlock(&device->submit_lock);

	ret = a6xx_power_off(adreno_dev);
	if (ret == -EBUSY) {
		kgsl_pwrscale_update(device);
		kgsl_start_idle_timer(device);
	}

done:
	kgsl_mutex_unlock(&device->mutex);
}

static int a6xx_gmu_first_open(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int ret;

	/*
	 * Do the one time settings that need to happen when we

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_gmu_snapshot.c:382 [MATCH: timeout] ---

	/* Set fence to ALLOW mode so registers can be read */
	kgsl_regwrite(device, A6XX_GMU_AO_AHB_FENCE_CTRL, 0);
	/* Make sure the previous write posted before reading */
	wmb();

	adreno_snapshot_registers(device, snapshot,
			a6xx_gmu_gx_registers,
			ARRAY_SIZE(a6xx_gmu_gx_registers) / 2);

	/* A stalled SMMU can lead to NoC timeouts when host accesses DTCM */
	if (adreno_smmu_is_stalled(adreno_dev)) {
		dev_err(GMU_PDEV_DEV(device),
			"Not dumping dtcm because SMMU is stalled\n");
		return;
	}

dtcm:
	kgsl_snapshot_add_section(device, KGSL_SNAPSHOT_SECTION_GMU_MEMORY,
		snapshot, a6xx_gmu_snapshot_dtcm, gmu);
}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hfi.c:88 [MATCH: seqnum] ---
		result = -ENODATA;
	}

	if (GMU_VER_MAJOR(device->gmu_core.ver.hfi) >= 2)
		read = ALIGN(read, SZ_4) % hdr->queue_size;

	/* For acks, trace the packet for which this ack was sent */
	if (MSG_HDR_GET_TYPE(msg_hdr) == HFI_MSG_ACK)
		trace_kgsl_hfi_receive(MSG_HDR_GET_ID(output[1]),
			MSG_HDR_GET_SIZE(output[1]),
			MSG_HDR_GET_SEQNUM(output[1]));
	else
		trace_kgsl_hfi_receive(MSG_HDR_GET_ID(msg_hdr),
			MSG_HDR_GET_SIZE(msg_hdr), MSG_HDR_GET_SEQNUM(msg_hdr));

	hfi_update_read_idx(hdr, read);

done:
	return result;
}

/* Size in below functions are in unit of dwords */
int a6xx_hfi_queue_write(struct adreno_device *adreno_dev, uint32_t queue_idx,
		uint32_t *msg, u32 size_bytes)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct hfi_queue_table *tbl = gmu->hfi.hfi_mem->hostptr;
	struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hfi.c:91 [MATCH: seqnum] ---
	if (GMU_VER_MAJOR(device->gmu_core.ver.hfi) >= 2)
		read = ALIGN(read, SZ_4) % hdr->queue_size;

	/* For acks, trace the packet for which this ack was sent */
	if (MSG_HDR_GET_TYPE(msg_hdr) == HFI_MSG_ACK)
		trace_kgsl_hfi_receive(MSG_HDR_GET_ID(output[1]),
			MSG_HDR_GET_SIZE(output[1]),
			MSG_HDR_GET_SEQNUM(output[1]));
	else
		trace_kgsl_hfi_receive(MSG_HDR_GET_ID(msg_hdr),
			MSG_HDR_GET_SIZE(msg_hdr), MSG_HDR_GET_SEQNUM(msg_hdr));

	hfi_update_read_idx(hdr, read);

done:
	return result;
}

/* Size in below functions are in unit of dwords */
int a6xx_hfi_queue_write(struct adreno_device *adreno_dev, uint32_t queue_idx,
		uint32_t *msg, u32 size_bytes)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct hfi_queue_table *tbl = gmu->hfi.hfi_mem->hostptr;
	struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];
	uint32_t *queue;
	uint32_t i, write_idx, read_idx, empty_space;
	uint32_t size_dwords = size_bytes >> 2;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hfi.c:270 [MATCH: seqnum] ---
}

static int a6xx_hfi_send_cmd_wait_inline(struct adreno_device *adreno_dev,
	void *data, u32 size_bytes, struct pending_cmd *ret_cmd)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int rc;
	uint32_t *cmd = data;
	struct a6xx_hfi *hfi = &gmu->hfi;
	unsigned int seqnum = atomic_inc_return(&hfi->seqnum);

	*cmd = MSG_HDR_SET_SEQNUM_SIZE(*cmd, seqnum, size_bytes >> 2);
	if (ret_cmd == NULL)
		return a6xx_hfi_cmdq_write(adreno_dev, cmd, size_bytes);

	ret_cmd->sent_hdr = cmd[0];

	rc = a6xx_hfi_cmdq_write(adreno_dev, cmd, size_bytes);
	if (rc)
		return rc;

	rc = gmu_core_timed_poll_check(device, A6XX_GMU_GMU2HOST_INTR_INFO,
			HFI_IRQ_MSGQ_MASK, HFI_RSP_TIMEOUT, HFI_IRQ_MSGQ_MASK);

	if (rc) {
		dev_err(GMU_PDEV_DEV(device),
		"Timed out waiting on ack for 0x%8.8x (id %d, sequence %d)\n",
		cmd[0], MSG_HDR_GET_ID(*cmd), MSG_HDR_GET_SEQNUM(*cmd));

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hfi.c:272 [MATCH: seqnum] ---
static int a6xx_hfi_send_cmd_wait_inline(struct adreno_device *adreno_dev,
	void *data, u32 size_bytes, struct pending_cmd *ret_cmd)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int rc;
	uint32_t *cmd = data;
	struct a6xx_hfi *hfi = &gmu->hfi;
	unsigned int seqnum = atomic_inc_return(&hfi->seqnum);

	*cmd = MSG_HDR_SET_SEQNUM_SIZE(*cmd, seqnum, size_bytes >> 2);
	if (ret_cmd == NULL)
		return a6xx_hfi_cmdq_write(adreno_dev, cmd, size_bytes);

	ret_cmd->sent_hdr = cmd[0];

	rc = a6xx_hfi_cmdq_write(adreno_dev, cmd, size_bytes);
	if (rc)
		return rc;

	rc = gmu_core_timed_poll_check(device, A6XX_GMU_GMU2HOST_INTR_INFO,
			HFI_IRQ_MSGQ_MASK, HFI_RSP_TIMEOUT, HFI_IRQ_MSGQ_MASK);

	if (rc) {
		dev_err(GMU_PDEV_DEV(device),
		"Timed out waiting on ack for 0x%8.8x (id %d, sequence %d)\n",
		cmd[0], MSG_HDR_GET_ID(*cmd), MSG_HDR_GET_SEQNUM(*cmd));
		gmu_core_fault_snapshot(device, GMU_FAULT_SEND_CMD_WAIT_INLINE);
		return rc;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hfi.c:288 [MATCH: seqnum] ---
	rc = a6xx_hfi_cmdq_write(adreno_dev, cmd, size_bytes);
	if (rc)
		return rc;

	rc = gmu_core_timed_poll_check(device, A6XX_GMU_GMU2HOST_INTR_INFO,
			HFI_IRQ_MSGQ_MASK, HFI_RSP_TIMEOUT, HFI_IRQ_MSGQ_MASK);

	if (rc) {
		dev_err(GMU_PDEV_DEV(device),
		"Timed out waiting on ack for 0x%8.8x (id %d, sequence %d)\n",
		cmd[0], MSG_HDR_GET_ID(*cmd), MSG_HDR_GET_SEQNUM(*cmd));
		gmu_core_fault_snapshot(device, GMU_FAULT_SEND_CMD_WAIT_INLINE);
		return rc;
	}

	/* Clear the interrupt */
	gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_CLR,
		HFI_IRQ_MSGQ_MASK);

	rc = a6xx_hfi_process_queue(gmu, HFI_MSG_ID, ret_cmd);

	return rc;
}

int a6xx_hfi_send_generic_req(struct adreno_device *adreno_dev, void *cmd, u32 size_bytes)
{
	struct pending_cmd ret_cmd;
	int rc;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hfi.h:13 [MATCH: seqnum] ---
 * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
 * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
 */
#ifndef __ADRENO_A6XX_HFI_H
#define __ADRENO_A6XX_HFI_H

#include "adreno_hfi.h"

/**
 * struct a6xx_hfi - HFI control structure
 * @seqnum: atomic counter that is incremented for each message sent. The
 *	value of the counter is used as sequence number for HFI message
 * @bw_table: HFI BW table buffer
 * @acd_table: HFI table for ACD data
 */
struct a6xx_hfi {
	/** @irq: HFI interrupt line */
	int irq;
	atomic_t seqnum;
	/** @hfi_mem: Memory descriptor for the hfi memory */
	struct kgsl_memdesc *hfi_mem;
	struct hfi_bwtable_cmd bw_table;
	struct hfi_acd_table_cmd acd_table;
	/** @dcvs_table: HFI table for gpu dcvs levels */
	struct hfi_dcvstable_cmd dcvs_table;
};

struct a6xx_gmu_device;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hfi.h:21 [MATCH: seqnum] ---
/**
 * struct a6xx_hfi - HFI control structure
 * @seqnum: atomic counter that is incremented for each message sent. The
 *	value of the counter is used as sequence number for HFI message
 * @bw_table: HFI BW table buffer
 * @acd_table: HFI table for ACD data
 */
struct a6xx_hfi {
	/** @irq: HFI interrupt line */
	int irq;
	atomic_t seqnum;
	/** @hfi_mem: Memory descriptor for the hfi memory */
	struct kgsl_memdesc *hfi_mem;
	struct hfi_bwtable_cmd bw_table;
	struct hfi_acd_table_cmd acd_table;
	/** @dcvs_table: HFI table for gpu dcvs levels */
	struct hfi_dcvstable_cmd dcvs_table;
};

struct a6xx_gmu_device;

/* a6xx_hfi_irq_handler - IRQ handler for HFI interripts */
irqreturn_t a6xx_hfi_irq_handler(int irq, void *data);

/**
 * a6xx_hfi_start - Send the various HFIs during device boot up
 * @adreno_dev: Pointer to the adreno device
 *
 * Return: 0 on success or negative error on failure

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched.c:467 [MATCH: timeout] ---

	set_bit(GMU_PRIV_GPU_STARTED, &gmu->flags);

	device->pwrctrl.last_stat_updated = ktime_get();

	kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE);

done:
	/*
	 * When waking up from a touch event we want to stay active long enough
	 * for the user to send a draw command.  The default idle timer timeout
	 * is shorter than we want so go ahead and push the idle timer out
	 * further for this special case
	 */
	mod_timer(&device->idle_timer, jiffies +
		msecs_to_jiffies(adreno_wake_timeout));
}

static int a6xx_hwsched_boot(struct adreno_device *adreno_dev)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	bool bcl_state = adreno_dev->bcl_enabled;
	int ret;

	if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags))
		return 0;

	kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched.c:472 [MATCH: timeout] ---
	kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE);

done:
	/*
	 * When waking up from a touch event we want to stay active long enough
	 * for the user to send a draw command.  The default idle timer timeout
	 * is shorter than we want so go ahead and push the idle timer out
	 * further for this special case
	 */
	mod_timer(&device->idle_timer, jiffies +
		msecs_to_jiffies(adreno_wake_timeout));
}

static int a6xx_hwsched_boot(struct adreno_device *adreno_dev)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	bool bcl_state = adreno_dev->bcl_enabled;
	int ret;

	if (test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags))
		return 0;

	kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE);

	adreno_hwsched_start(adreno_dev);

	if (IS_ENABLED(CONFIG_QCOM_KGSL_HIBERNATION) &&
		!test_bit(GMU_PRIV_PDC_RSC_LOADED, &gmu->flags)) {

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched.c:937 [MATCH: timeout] ---
}

int a6xx_hwsched_reset_replay(struct adreno_device *adreno_dev)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	int ret;

	/*
	 * Any pending context unregister packets will be lost
	 * since we hard reset the GMU. This means any threads waiting
	 * for context unregister hfi ack will timeout. Wake them
	 * to avoid false positive ack timeout messages later.
	 */
	a6xx_hwsched_drain_ctxt_unregister(adreno_dev);

	adreno_hwsched_unregister_contexts(adreno_dev);

	if (!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags))
		return 0;

	a6xx_disable_gpu_irq(adreno_dev);

	a6xx_gmu_irq_disable(adreno_dev);

	a6xx_hwsched_hfi_stop(adreno_dev);

	a6xx_hwsched_gmu_suspend(adreno_dev, true);

	adreno_llcc_slice_deactivate(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched.c:938 [MATCH: timeout] ---

int a6xx_hwsched_reset_replay(struct adreno_device *adreno_dev)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	int ret;

	/*
	 * Any pending context unregister packets will be lost
	 * since we hard reset the GMU. This means any threads waiting
	 * for context unregister hfi ack will timeout. Wake them
	 * to avoid false positive ack timeout messages later.
	 */
	a6xx_hwsched_drain_ctxt_unregister(adreno_dev);

	adreno_hwsched_unregister_contexts(adreno_dev);

	if (!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags))
		return 0;

	a6xx_disable_gpu_irq(adreno_dev);

	a6xx_gmu_irq_disable(adreno_dev);

	a6xx_hwsched_hfi_stop(adreno_dev);

	a6xx_hwsched_gmu_suspend(adreno_dev, true);

	adreno_llcc_slice_deactivate(adreno_dev);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched.c:922 [MATCH: sent_hdr] ---
}

static void a6xx_hwsched_drain_ctxt_unregister(struct adreno_device *adreno_dev)
{
	struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
	struct pending_cmd *cmd = NULL;

	read_lock(&hfi->msglock);

	list_for_each_entry(cmd, &hfi->msglist, node) {
		if (MSG_HDR_GET_ID(cmd->sent_hdr) == H2F_MSG_UNREGISTER_CONTEXT)
			complete(&cmd->complete);
	}

	read_unlock(&hfi->msglock);
}

int a6xx_hwsched_reset_replay(struct adreno_device *adreno_dev)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	int ret;

	/*
	 * Any pending context unregister packets will be lost
	 * since we hard reset the GMU. This means any threads waiting
	 * for context unregister hfi ack will timeout. Wake them
	 * to avoid false positive ack timeout messages later.
	 */
	a6xx_hwsched_drain_ctxt_unregister(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched.c:591 [MATCH: results] ---
		adreno_dev->bcl_enabled = true;

	/*
	 * There is a possible deadlock scenario during kgsl firmware reading
	 * (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl
	 * device mutex is held and then firmware_request_nowarn is called for reading
	 * firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock.
	 * Whereas in case of devfreq update calls triggered by thermal/bcl or
	 * devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then
	 * tries to take kgsl device mutex as part of get_dev_status/target
	 * calls. This results in deadlock when both thread are unable to acquire
	 * the mutex held by other thread. Enable devfreq updates now as we are
	 * done reading all firmware files.
	 */
	device->pwrscale.devfreq_enabled = true;

	device->pwrctrl.last_stat_updated = ktime_get();

	set_bit(ADRENO_DEVICE_FIRST_BOOT_DONE, &adreno_dev->priv);

	kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE);

	return 0;
}

static int a6xx_hwsched_power_off(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched.c:664 [MATCH: mutex_lock] ---
	return ret;
}

static void hwsched_idle_check(struct work_struct *work)
{
	struct kgsl_device *device = container_of(work,
					struct kgsl_device, idle_check_ws);
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);

	kgsl_mutex_lock(&device->mutex);

	if (test_bit(GMU_DISABLE_SLUMBER, &device->gmu_core.flags))
		goto done;

	if (atomic_read(&device->active_cnt) || time_is_after_jiffies(device->idle_jiffies)) {
		kgsl_pwrscale_update(device);
		goto done;
	}

	spin_lock(&device->submit_lock);
	if (device->submit_now) {
		spin_unlock(&device->submit_lock);
		kgsl_pwrscale_update(device);
		kgsl_start_idle_timer(device);
		goto done;
	}

	device->skip_inline_submit = true;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched.c:693 [MATCH: mutex_unlock] ---
	spin_unlock(&device->submit_lock);

	if (!gpudev->hw_isidle(adreno_dev)) {
		dev_err(device->dev, "GPU isn't idle before SLUMBER\n");
		gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
	}

	a6xx_hwsched_power_off(adreno_dev);

done:
	kgsl_mutex_unlock(&device->mutex);
}

static int a6xx_hwsched_first_open(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int ret;

	/*
	 * Do the one time settings that need to happen when we
	 * attempt to boot the gpu the very first time
	 */
	ret = a6xx_hwsched_first_boot(adreno_dev);
	if (ret)
		return ret;

	/*
	 * A client that does a first_open but never closes the device
	 * may prevent us from going back to SLUMBER. So trigger the idle

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched.c:674 [MATCH: spin_lock] ---
	kgsl_mutex_lock(&device->mutex);

	if (test_bit(GMU_DISABLE_SLUMBER, &device->gmu_core.flags))
		goto done;

	if (atomic_read(&device->active_cnt) || time_is_after_jiffies(device->idle_jiffies)) {
		kgsl_pwrscale_update(device);
		goto done;
	}

	spin_lock(&device->submit_lock);
	if (device->submit_now) {
		spin_unlock(&device->submit_lock);
		kgsl_pwrscale_update(device);
		kgsl_start_idle_timer(device);
		goto done;
	}

	device->skip_inline_submit = true;
	spin_unlock(&device->submit_lock);

	if (!gpudev->hw_isidle(adreno_dev)) {
		dev_err(device->dev, "GPU isn't idle before SLUMBER\n");
		gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
	}

	a6xx_hwsched_power_off(adreno_dev);

done:

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched.c:676 [MATCH: spin_unlock] ---
	if (test_bit(GMU_DISABLE_SLUMBER, &device->gmu_core.flags))
		goto done;

	if (atomic_read(&device->active_cnt) || time_is_after_jiffies(device->idle_jiffies)) {
		kgsl_pwrscale_update(device);
		goto done;
	}

	spin_lock(&device->submit_lock);
	if (device->submit_now) {
		spin_unlock(&device->submit_lock);
		kgsl_pwrscale_update(device);
		kgsl_start_idle_timer(device);
		goto done;
	}

	device->skip_inline_submit = true;
	spin_unlock(&device->submit_lock);

	if (!gpudev->hw_isidle(adreno_dev)) {
		dev_err(device->dev, "GPU isn't idle before SLUMBER\n");
		gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
	}

	a6xx_hwsched_power_off(adreno_dev);

done:
	kgsl_mutex_unlock(&device->mutex);
}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched.c:683 [MATCH: spin_unlock] ---

	spin_lock(&device->submit_lock);
	if (device->submit_now) {
		spin_unlock(&device->submit_lock);
		kgsl_pwrscale_update(device);
		kgsl_start_idle_timer(device);
		goto done;
	}

	device->skip_inline_submit = true;
	spin_unlock(&device->submit_lock);

	if (!gpudev->hw_isidle(adreno_dev)) {
		dev_err(device->dev, "GPU isn't idle before SLUMBER\n");
		gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
	}

	a6xx_hwsched_power_off(adreno_dev);

done:
	kgsl_mutex_unlock(&device->mutex);
}

static int a6xx_hwsched_first_open(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int ret;

	/*

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:1203 [MATCH: wait_event] ---
	return false;
}

static int hfi_f2h_main(void *arg)
{
	struct adreno_device *adreno_dev = arg;
	struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	while (!kthread_should_stop()) {
		wait_event_interruptible(hfi->f2h_wq, kthread_should_stop() ||
			/* If msgq irq is enabled and msgq has messages to process */
			(((hfi->irq_mask & HFI_IRQ_MSGQ_MASK) &&
			!is_queue_empty(adreno_dev, HFI_MSG_ID)) ||
			/* Trace buffer has messages to process */
			!gmu_core_is_trace_empty(device->gmu_core.trace.md->hostptr) ||
			/* Dbgq has messages to process */
			!is_queue_empty(adreno_dev, HFI_DBG_ID)));

		if (kthread_should_stop())
			break;

		a6xx_hwsched_process_msgq(adreno_dev);
		gmu_core_process_trace_data(device,
				GMU_PDEV_DEV(device), &device->gmu_core.trace);
		a6xx_hwsched_process_dbgq(adreno_dev, true);
	}

	return 0;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:175 [MATCH: timeout] ---
static void log_gpu_fault_legacy(struct adreno_device *adreno_dev)
{
	struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
	struct hfi_context_bad_cmd_legacy *cmd = adreno_dev->hwsched.ctxt_bad;

	switch (cmd->error) {
	case GMU_GPU_HW_HANG:
		dev_crit_ratelimited(gmu_pdev_dev, "MISC: GPU hang detected\n");
		break;
	case GMU_GPU_SW_HANG:
		dev_crit_ratelimited(gmu_pdev_dev, "gpu timeout ctx %u ts %u\n",
			cmd->ctxt_id, cmd->ts);
		break;
	case GMU_CP_OPCODE_ERROR:
		dev_crit_ratelimited(gmu_pdev_dev,
			"CP opcode error interrupt | opcode=0x%8.8x\n",
			a6xx_hwsched_lookup_key_value_legacy(adreno_dev, PAYLOAD_FAULT_REGS,
			KEY_CP_OPCODE_ERROR));
		break;
	case GMU_CP_PROTECTED_ERROR: {
		u32 status = a6xx_hwsched_lookup_key_value_legacy(adreno_dev, PAYLOAD_FAULT_REGS,
				KEY_CP_PROTECTED_ERROR);

		dev_crit_ratelimited(gmu_pdev_dev,
			"CP | Protected mode error | %s | addr=0x%5.5x | status=0x%8.8x\n",
			status & (1 << 20) ? "READ" : "WRITE",
			status & 0x3FFFF, status);
		}
		break;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:206 [MATCH: timeout] ---
		break;
	case GMU_CP_UCODE_ERROR:
		dev_crit_ratelimited(gmu_pdev_dev, "CP ucode error interrupt\n");
		break;
	case GMU_CP_HW_FAULT_ERROR:
		dev_crit_ratelimited(gmu_pdev_dev,
			"CP | Ringbuffer HW fault | status=0x%8.8x\n",
			a6xx_hwsched_lookup_key_value_legacy(adreno_dev, PAYLOAD_FAULT_REGS,
				KEY_CP_HW_FAULT));
		break;
	case GMU_GPU_PREEMPT_TIMEOUT: {
		u32 cur, next, cur_rptr, cur_wptr, next_rptr, next_wptr;

		cur = a6xx_hwsched_lookup_key_value_legacy(adreno_dev,
			PAYLOAD_PREEMPT_TIMEOUT, KEY_PREEMPT_TIMEOUT_CUR_RB_ID);
		next = a6xx_hwsched_lookup_key_value_legacy(adreno_dev,
			PAYLOAD_PREEMPT_TIMEOUT,
			KEY_PREEMPT_TIMEOUT_NEXT_RB_ID);
		cur_rptr = adreno_hwsched_get_payload_rb_key_legacy(adreno_dev, cur, KEY_RB_RPTR);
		cur_wptr = adreno_hwsched_get_payload_rb_key_legacy(adreno_dev, cur, KEY_RB_WPTR);
		next_rptr = adreno_hwsched_get_payload_rb_key_legacy(adreno_dev, next, KEY_RB_RPTR);
		next_wptr = adreno_hwsched_get_payload_rb_key_legacy(adreno_dev, next, KEY_RB_WPTR);

		dev_crit_ratelimited(gmu_pdev_dev,
			"Preemption Fault: cur=%d R/W=0x%x/0x%x, next=%d R/W=0x%x/0x%x\n",
			cur, cur_rptr, cur_wptr, next, next_rptr, next_wptr);
		}
		break;
	case GMU_CP_GPC_ERROR:

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:210 [MATCH: timeout] ---
	case GMU_CP_HW_FAULT_ERROR:
		dev_crit_ratelimited(gmu_pdev_dev,
			"CP | Ringbuffer HW fault | status=0x%8.8x\n",
			a6xx_hwsched_lookup_key_value_legacy(adreno_dev, PAYLOAD_FAULT_REGS,
				KEY_CP_HW_FAULT));
		break;
	case GMU_GPU_PREEMPT_TIMEOUT: {
		u32 cur, next, cur_rptr, cur_wptr, next_rptr, next_wptr;

		cur = a6xx_hwsched_lookup_key_value_legacy(adreno_dev,
			PAYLOAD_PREEMPT_TIMEOUT, KEY_PREEMPT_TIMEOUT_CUR_RB_ID);
		next = a6xx_hwsched_lookup_key_value_legacy(adreno_dev,
			PAYLOAD_PREEMPT_TIMEOUT,
			KEY_PREEMPT_TIMEOUT_NEXT_RB_ID);
		cur_rptr = adreno_hwsched_get_payload_rb_key_legacy(adreno_dev, cur, KEY_RB_RPTR);
		cur_wptr = adreno_hwsched_get_payload_rb_key_legacy(adreno_dev, cur, KEY_RB_WPTR);
		next_rptr = adreno_hwsched_get_payload_rb_key_legacy(adreno_dev, next, KEY_RB_RPTR);
		next_wptr = adreno_hwsched_get_payload_rb_key_legacy(adreno_dev, next, KEY_RB_WPTR);

		dev_crit_ratelimited(gmu_pdev_dev,
			"Preemption Fault: cur=%d R/W=0x%x/0x%x, next=%d R/W=0x%x/0x%x\n",
			cur, cur_rptr, cur_wptr, next, next_rptr, next_wptr);
		}
		break;
	case GMU_CP_GPC_ERROR:
		dev_crit_ratelimited(gmu_pdev_dev, "RBBM: GPC error\n");
		break;
	default:
		dev_crit_ratelimited(gmu_pdev_dev, "Unknown GPU fault: %u\n",

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:212 [MATCH: timeout] ---
			"CP | Ringbuffer HW fault | status=0x%8.8x\n",
			a6xx_hwsched_lookup_key_value_legacy(adreno_dev, PAYLOAD_FAULT_REGS,
				KEY_CP_HW_FAULT));
		break;
	case GMU_GPU_PREEMPT_TIMEOUT: {
		u32 cur, next, cur_rptr, cur_wptr, next_rptr, next_wptr;

		cur = a6xx_hwsched_lookup_key_value_legacy(adreno_dev,
			PAYLOAD_PREEMPT_TIMEOUT, KEY_PREEMPT_TIMEOUT_CUR_RB_ID);
		next = a6xx_hwsched_lookup_key_value_legacy(adreno_dev,
			PAYLOAD_PREEMPT_TIMEOUT,
			KEY_PREEMPT_TIMEOUT_NEXT_RB_ID);
		cur_rptr = adreno_hwsched_get_payload_rb_key_legacy(adreno_dev, cur, KEY_RB_RPTR);
		cur_wptr = adreno_hwsched_get_payload_rb_key_legacy(adreno_dev, cur, KEY_RB_WPTR);
		next_rptr = adreno_hwsched_get_payload_rb_key_legacy(adreno_dev, next, KEY_RB_RPTR);
		next_wptr = adreno_hwsched_get_payload_rb_key_legacy(adreno_dev, next, KEY_RB_WPTR);

		dev_crit_ratelimited(gmu_pdev_dev,
			"Preemption Fault: cur=%d R/W=0x%x/0x%x, next=%d R/W=0x%x/0x%x\n",
			cur, cur_rptr, cur_wptr, next, next_rptr, next_wptr);
		}
		break;
	case GMU_CP_GPC_ERROR:
		dev_crit_ratelimited(gmu_pdev_dev, "RBBM: GPC error\n");
		break;
	default:
		dev_crit_ratelimited(gmu_pdev_dev, "Unknown GPU fault: %u\n",
			cmd->error);
		break;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:213 [MATCH: timeout] ---
			a6xx_hwsched_lookup_key_value_legacy(adreno_dev, PAYLOAD_FAULT_REGS,
				KEY_CP_HW_FAULT));
		break;
	case GMU_GPU_PREEMPT_TIMEOUT: {
		u32 cur, next, cur_rptr, cur_wptr, next_rptr, next_wptr;

		cur = a6xx_hwsched_lookup_key_value_legacy(adreno_dev,
			PAYLOAD_PREEMPT_TIMEOUT, KEY_PREEMPT_TIMEOUT_CUR_RB_ID);
		next = a6xx_hwsched_lookup_key_value_legacy(adreno_dev,
			PAYLOAD_PREEMPT_TIMEOUT,
			KEY_PREEMPT_TIMEOUT_NEXT_RB_ID);
		cur_rptr = adreno_hwsched_get_payload_rb_key_legacy(adreno_dev, cur, KEY_RB_RPTR);
		cur_wptr = adreno_hwsched_get_payload_rb_key_legacy(adreno_dev, cur, KEY_RB_WPTR);
		next_rptr = adreno_hwsched_get_payload_rb_key_legacy(adreno_dev, next, KEY_RB_RPTR);
		next_wptr = adreno_hwsched_get_payload_rb_key_legacy(adreno_dev, next, KEY_RB_WPTR);

		dev_crit_ratelimited(gmu_pdev_dev,
			"Preemption Fault: cur=%d R/W=0x%x/0x%x, next=%d R/W=0x%x/0x%x\n",
			cur, cur_rptr, cur_wptr, next, next_rptr, next_wptr);
		}
		break;
	case GMU_CP_GPC_ERROR:
		dev_crit_ratelimited(gmu_pdev_dev, "RBBM: GPC error\n");
		break;
	default:
		dev_crit_ratelimited(gmu_pdev_dev, "Unknown GPU fault: %u\n",
			cmd->error);
		break;
	}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:272 [MATCH: timeout] ---
static void log_gpu_fault(struct adreno_device *adreno_dev)
{
	struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
	struct hfi_context_bad_cmd *cmd = adreno_dev->hwsched.ctxt_bad;

	switch (cmd->error) {
	case GMU_GPU_HW_HANG:
		dev_crit_ratelimited(gmu_pdev_dev, "MISC: GPU hang detected\n");
		break;
	case GMU_GPU_SW_HANG:
		dev_crit_ratelimited(gmu_pdev_dev, "gpu timeout ctx %u ts %u\n",
			cmd->gc.ctxt_id, cmd->gc.ts);
		break;
	case GMU_CP_OPCODE_ERROR:
		dev_crit_ratelimited(gmu_pdev_dev,
			"CP opcode error interrupt | opcode=0x%8.8x\n",
			a6xx_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS,
			KEY_CP_OPCODE_ERROR));
		break;
	case GMU_CP_PROTECTED_ERROR: {
		u32 status = a6xx_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS,
				KEY_CP_PROTECTED_ERROR);

		dev_crit_ratelimited(gmu_pdev_dev,
			"CP | Protected mode error | %s | addr=0x%5.5x | status=0x%8.8x\n",
			status & (1 << 20) ? "READ" : "WRITE",
			status & 0x3FFFF, status);
		}
		break;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:303 [MATCH: timeout] ---
		break;
	case GMU_CP_UCODE_ERROR:
		dev_crit_ratelimited(gmu_pdev_dev, "CP ucode error interrupt\n");
		break;
	case GMU_CP_HW_FAULT_ERROR:
		dev_crit_ratelimited(gmu_pdev_dev,
			"CP | Ringbuffer HW fault | status=0x%8.8x\n",
			a6xx_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS,
				KEY_CP_HW_FAULT));
		break;
	case GMU_GPU_PREEMPT_TIMEOUT: {
		u32 cur, next, cur_rptr, cur_wptr, next_rptr, next_wptr;

		cur = a6xx_hwsched_lookup_key_value(adreno_dev,
			PAYLOAD_PREEMPT_TIMEOUT, KEY_PREEMPT_TIMEOUT_CUR_RB_ID);
		next = a6xx_hwsched_lookup_key_value(adreno_dev,
			PAYLOAD_PREEMPT_TIMEOUT,
			KEY_PREEMPT_TIMEOUT_NEXT_RB_ID);
		cur_rptr = adreno_hwsched_get_payload_rb_key(adreno_dev, cur, KEY_RB_RPTR);
		cur_wptr = adreno_hwsched_get_payload_rb_key(adreno_dev, cur, KEY_RB_WPTR);
		next_rptr = adreno_hwsched_get_payload_rb_key(adreno_dev, next, KEY_RB_RPTR);
		next_wptr = adreno_hwsched_get_payload_rb_key(adreno_dev, next, KEY_RB_WPTR);

		dev_crit_ratelimited(gmu_pdev_dev,
			"Preemption Fault: cur=%d R/W=0x%x/0x%x, next=%d R/W=0x%x/0x%x\n",
			cur, cur_rptr, cur_wptr, next, next_rptr, next_wptr);
		}
		break;
	case GMU_CP_GPC_ERROR:

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:307 [MATCH: timeout] ---
	case GMU_CP_HW_FAULT_ERROR:
		dev_crit_ratelimited(gmu_pdev_dev,
			"CP | Ringbuffer HW fault | status=0x%8.8x\n",
			a6xx_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS,
				KEY_CP_HW_FAULT));
		break;
	case GMU_GPU_PREEMPT_TIMEOUT: {
		u32 cur, next, cur_rptr, cur_wptr, next_rptr, next_wptr;

		cur = a6xx_hwsched_lookup_key_value(adreno_dev,
			PAYLOAD_PREEMPT_TIMEOUT, KEY_PREEMPT_TIMEOUT_CUR_RB_ID);
		next = a6xx_hwsched_lookup_key_value(adreno_dev,
			PAYLOAD_PREEMPT_TIMEOUT,
			KEY_PREEMPT_TIMEOUT_NEXT_RB_ID);
		cur_rptr = adreno_hwsched_get_payload_rb_key(adreno_dev, cur, KEY_RB_RPTR);
		cur_wptr = adreno_hwsched_get_payload_rb_key(adreno_dev, cur, KEY_RB_WPTR);
		next_rptr = adreno_hwsched_get_payload_rb_key(adreno_dev, next, KEY_RB_RPTR);
		next_wptr = adreno_hwsched_get_payload_rb_key(adreno_dev, next, KEY_RB_WPTR);

		dev_crit_ratelimited(gmu_pdev_dev,
			"Preemption Fault: cur=%d R/W=0x%x/0x%x, next=%d R/W=0x%x/0x%x\n",
			cur, cur_rptr, cur_wptr, next, next_rptr, next_wptr);
		}
		break;
	case GMU_CP_GPC_ERROR:
		dev_crit_ratelimited(gmu_pdev_dev, "RBBM: GPC error\n");
		break;
	default:
		dev_crit_ratelimited(gmu_pdev_dev, "Unknown GPU fault: %u\n",

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:309 [MATCH: timeout] ---
			"CP | Ringbuffer HW fault | status=0x%8.8x\n",
			a6xx_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS,
				KEY_CP_HW_FAULT));
		break;
	case GMU_GPU_PREEMPT_TIMEOUT: {
		u32 cur, next, cur_rptr, cur_wptr, next_rptr, next_wptr;

		cur = a6xx_hwsched_lookup_key_value(adreno_dev,
			PAYLOAD_PREEMPT_TIMEOUT, KEY_PREEMPT_TIMEOUT_CUR_RB_ID);
		next = a6xx_hwsched_lookup_key_value(adreno_dev,
			PAYLOAD_PREEMPT_TIMEOUT,
			KEY_PREEMPT_TIMEOUT_NEXT_RB_ID);
		cur_rptr = adreno_hwsched_get_payload_rb_key(adreno_dev, cur, KEY_RB_RPTR);
		cur_wptr = adreno_hwsched_get_payload_rb_key(adreno_dev, cur, KEY_RB_WPTR);
		next_rptr = adreno_hwsched_get_payload_rb_key(adreno_dev, next, KEY_RB_RPTR);
		next_wptr = adreno_hwsched_get_payload_rb_key(adreno_dev, next, KEY_RB_WPTR);

		dev_crit_ratelimited(gmu_pdev_dev,
			"Preemption Fault: cur=%d R/W=0x%x/0x%x, next=%d R/W=0x%x/0x%x\n",
			cur, cur_rptr, cur_wptr, next, next_rptr, next_wptr);
		}
		break;
	case GMU_CP_GPC_ERROR:
		dev_crit_ratelimited(gmu_pdev_dev, "RBBM: GPC error\n");
		break;
	default:
		dev_crit_ratelimited(gmu_pdev_dev, "Unknown GPU fault: %u\n",
			cmd->error);
		break;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:310 [MATCH: timeout] ---
			a6xx_hwsched_lookup_key_value(adreno_dev, PAYLOAD_FAULT_REGS,
				KEY_CP_HW_FAULT));
		break;
	case GMU_GPU_PREEMPT_TIMEOUT: {
		u32 cur, next, cur_rptr, cur_wptr, next_rptr, next_wptr;

		cur = a6xx_hwsched_lookup_key_value(adreno_dev,
			PAYLOAD_PREEMPT_TIMEOUT, KEY_PREEMPT_TIMEOUT_CUR_RB_ID);
		next = a6xx_hwsched_lookup_key_value(adreno_dev,
			PAYLOAD_PREEMPT_TIMEOUT,
			KEY_PREEMPT_TIMEOUT_NEXT_RB_ID);
		cur_rptr = adreno_hwsched_get_payload_rb_key(adreno_dev, cur, KEY_RB_RPTR);
		cur_wptr = adreno_hwsched_get_payload_rb_key(adreno_dev, cur, KEY_RB_WPTR);
		next_rptr = adreno_hwsched_get_payload_rb_key(adreno_dev, next, KEY_RB_RPTR);
		next_wptr = adreno_hwsched_get_payload_rb_key(adreno_dev, next, KEY_RB_WPTR);

		dev_crit_ratelimited(gmu_pdev_dev,
			"Preemption Fault: cur=%d R/W=0x%x/0x%x, next=%d R/W=0x%x/0x%x\n",
			cur, cur_rptr, cur_wptr, next, next_rptr, next_wptr);
		}
		break;
	case GMU_CP_GPC_ERROR:
		dev_crit_ratelimited(gmu_pdev_dev, "RBBM: GPC error\n");
		break;
	default:
		dev_crit_ratelimited(gmu_pdev_dev, "Unknown GPU fault: %u\n",
			cmd->error);
		break;
	}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:855 [MATCH: timeout] ---
	data = FIELD_PREP(GENMASK(1, 0), adreno_dev->preempt.preempt_level) |
			FIELD_PREP(BIT(2), adreno_dev->preempt.usesgmem) |
			FIELD_PREP(BIT(3), adreno_dev->preempt.skipsaverestore);

	ret = a6xx_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_PREEMPTION, 1,
			data);
	if (ret)
		return ret;

	/*
	 * Bits[3:0] contain the preemption timeout enable bit per ringbuffer
	 * Bits[31:4] contain the timeout in ms
	 */
	return a6xx_hfi_send_set_value(adreno_dev, HFI_VALUE_BIN_TIME, 1,
			FIELD_PREP(GENMASK(31, 4), ADRENO_PREEMPT_TIMEOUT) |
			FIELD_PREP(GENMASK(3, 0), 0xf));
}

static int enable_gmu_stats(struct adreno_device *adreno_dev)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	u32 data;

	if (!gmu->stats_enable)
		return 0;

	/*
	 * Bits [23:0] contains the countables mask
	 * Bits [31:24] is the sampling interval

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:856 [MATCH: timeout] ---
			FIELD_PREP(BIT(2), adreno_dev->preempt.usesgmem) |
			FIELD_PREP(BIT(3), adreno_dev->preempt.skipsaverestore);

	ret = a6xx_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_PREEMPTION, 1,
			data);
	if (ret)
		return ret;

	/*
	 * Bits[3:0] contain the preemption timeout enable bit per ringbuffer
	 * Bits[31:4] contain the timeout in ms
	 */
	return a6xx_hfi_send_set_value(adreno_dev, HFI_VALUE_BIN_TIME, 1,
			FIELD_PREP(GENMASK(31, 4), ADRENO_PREEMPT_TIMEOUT) |
			FIELD_PREP(GENMASK(3, 0), 0xf));
}

static int enable_gmu_stats(struct adreno_device *adreno_dev)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	u32 data;

	if (!gmu->stats_enable)
		return 0;

	/*
	 * Bits [23:0] contains the countables mask
	 * Bits [31:24] is the sampling interval
	 */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:859 [MATCH: timeout] ---
	ret = a6xx_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_PREEMPTION, 1,
			data);
	if (ret)
		return ret;

	/*
	 * Bits[3:0] contain the preemption timeout enable bit per ringbuffer
	 * Bits[31:4] contain the timeout in ms
	 */
	return a6xx_hfi_send_set_value(adreno_dev, HFI_VALUE_BIN_TIME, 1,
			FIELD_PREP(GENMASK(31, 4), ADRENO_PREEMPT_TIMEOUT) |
			FIELD_PREP(GENMASK(3, 0), 0xf));
}

static int enable_gmu_stats(struct adreno_device *adreno_dev)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	u32 data;

	if (!gmu->stats_enable)
		return 0;

	/*
	 * Bits [23:0] contains the countables mask
	 * Bits [31:24] is the sampling interval
	 */
	data = FIELD_PREP(GENMASK(23, 0), gmu->stats_mask) |
		FIELD_PREP(GENMASK(31, 24), gmu->stats_interval);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:948 [MATCH: timeout] ---
		ret = a6xx_hfi_send_feature_ctrl(adreno_dev, HFI_FEATURE_LSR,
				1, 0);
		if (ret)
			goto err;
	}

	ret = a6xx_hfi_send_perfcounter_feature_ctrl(adreno_dev);
	if (ret)
		goto err;

	/* Enable the long ib timeout detection */
	if (adreno_long_ib_detect(adreno_dev)) {
		ret = a6xx_hfi_send_feature_ctrl(adreno_dev,
			HFI_FEATURE_BAIL_OUT_TIMER, 1, 0);
		if (ret)
			goto err;
	}

	enable_gmu_stats(adreno_dev);

	if (gmu->log_stream_enable)
		a6xx_hfi_send_set_value(adreno_dev,
			HFI_VALUE_LOG_STREAM_ENABLE, 0, 1);

	if (gmu->log_group_mask)
		a6xx_hfi_send_set_value(adreno_dev, HFI_VALUE_LOG_GROUP, 0, gmu->log_group_mask);

	ret = a6xx_hfi_send_core_fw_start(adreno_dev);
	if (ret)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:1167 [MATCH: timeout] ---

	cmds[count++] = cp_type7_packet(CP_WAIT_FOR_IDLE, 0);
	cmds[count++] = cp_type4_packet(reg->select, 1);
	cmds[count++] = countable;

	ret = submit_global_ctxt_cmd(adreno_dev, hfi->perfctr_scratch->gpuaddr, count << 2);
	if (ret)
		goto err;

	/* Wait till the register is programmed with the countable */
	ret = kgsl_regmap_read_poll_timeout(&device->regmap, reg->select, val,
				val == countable, 100, ADRENO_IDLE_TIMEOUT * USEC_PER_MSEC);
	if (!ret) {
		reg->value = 0;
		return ret;
	}

err:
	dev_err(device->dev, "Perfcounter %s/%u/%u start via commands failed\n",
			group->name, counter, countable);
	return ret;
}

static bool is_queue_empty(struct adreno_device *adreno_dev, u32 queue_idx)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
	struct hfi_queue_table *tbl = mem_addr->hostptr;
	struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:1168 [MATCH: timeout] ---
	cmds[count++] = cp_type7_packet(CP_WAIT_FOR_IDLE, 0);
	cmds[count++] = cp_type4_packet(reg->select, 1);
	cmds[count++] = countable;

	ret = submit_global_ctxt_cmd(adreno_dev, hfi->perfctr_scratch->gpuaddr, count << 2);
	if (ret)
		goto err;

	/* Wait till the register is programmed with the countable */
	ret = kgsl_regmap_read_poll_timeout(&device->regmap, reg->select, val,
				val == countable, 100, ADRENO_IDLE_TIMEOUT * USEC_PER_MSEC);
	if (!ret) {
		reg->value = 0;
		return ret;
	}

err:
	dev_err(device->dev, "Perfcounter %s/%u/%u start via commands failed\n",
			group->name, counter, countable);
	return ret;
}

static bool is_queue_empty(struct adreno_device *adreno_dev, u32 queue_idx)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct kgsl_memdesc *mem_addr = gmu->hfi.hfi_mem;
	struct hfi_queue_table *tbl = mem_addr->hostptr;
	struct hfi_queue_header *hdr = &tbl->qhdr[queue_idx];


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:126 [MATCH: seqnum] ---
		}

		if (num_waiters < ARRAY_SIZE(waiters))
			waiters[num_waiters++] = cmd->sent_hdr;
	}

	read_unlock(&hfi->msglock);

	/* Didn't find the sender, list the waiter */
	dev_err_ratelimited(gmu_pdev_dev,
		"Unexpectedly got id %d seqnum %d. Total waiters: %d Top %d Waiters:\n",
		MSG_HDR_GET_ID(req_hdr), MSG_HDR_GET_SEQNUM(req_hdr),
		num_waiters, min_t(u32, num_waiters, 5));

	for (i = 0; i < num_waiters && i < 5; i++)
		dev_err_ratelimited(gmu_pdev_dev,
			" id %d seqnum %d\n",
			MSG_HDR_GET_ID(waiters[i]),
			MSG_HDR_GET_SEQNUM(waiters[i]));
}

/* Look up a particular key's value for a given type of payload */
static u32 a6xx_hwsched_lookup_key_value_legacy(struct adreno_device *adreno_dev,
	u32 type, u32 key)
{
	struct hfi_context_bad_cmd_legacy *cmd = adreno_dev->hwsched.ctxt_bad;
	u32 i = 0, payload_bytes;
	void *start;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:127 [MATCH: seqnum] ---

		if (num_waiters < ARRAY_SIZE(waiters))
			waiters[num_waiters++] = cmd->sent_hdr;
	}

	read_unlock(&hfi->msglock);

	/* Didn't find the sender, list the waiter */
	dev_err_ratelimited(gmu_pdev_dev,
		"Unexpectedly got id %d seqnum %d. Total waiters: %d Top %d Waiters:\n",
		MSG_HDR_GET_ID(req_hdr), MSG_HDR_GET_SEQNUM(req_hdr),
		num_waiters, min_t(u32, num_waiters, 5));

	for (i = 0; i < num_waiters && i < 5; i++)
		dev_err_ratelimited(gmu_pdev_dev,
			" id %d seqnum %d\n",
			MSG_HDR_GET_ID(waiters[i]),
			MSG_HDR_GET_SEQNUM(waiters[i]));
}

/* Look up a particular key's value for a given type of payload */
static u32 a6xx_hwsched_lookup_key_value_legacy(struct adreno_device *adreno_dev,
	u32 type, u32 key)
{
	struct hfi_context_bad_cmd_legacy *cmd = adreno_dev->hwsched.ctxt_bad;
	u32 i = 0, payload_bytes;
	void *start;

	if (!cmd->hdr)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:132 [MATCH: seqnum] ---
	read_unlock(&hfi->msglock);

	/* Didn't find the sender, list the waiter */
	dev_err_ratelimited(gmu_pdev_dev,
		"Unexpectedly got id %d seqnum %d. Total waiters: %d Top %d Waiters:\n",
		MSG_HDR_GET_ID(req_hdr), MSG_HDR_GET_SEQNUM(req_hdr),
		num_waiters, min_t(u32, num_waiters, 5));

	for (i = 0; i < num_waiters && i < 5; i++)
		dev_err_ratelimited(gmu_pdev_dev,
			" id %d seqnum %d\n",
			MSG_HDR_GET_ID(waiters[i]),
			MSG_HDR_GET_SEQNUM(waiters[i]));
}

/* Look up a particular key's value for a given type of payload */
static u32 a6xx_hwsched_lookup_key_value_legacy(struct adreno_device *adreno_dev,
	u32 type, u32 key)
{
	struct hfi_context_bad_cmd_legacy *cmd = adreno_dev->hwsched.ctxt_bad;
	u32 i = 0, payload_bytes;
	void *start;

	if (!cmd->hdr)
		return 0;

	payload_bytes = (MSG_HDR_GET_SIZE(cmd->hdr) << 2) -
			offsetof(struct hfi_context_bad_cmd_legacy, payload);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:134 [MATCH: seqnum] ---
	/* Didn't find the sender, list the waiter */
	dev_err_ratelimited(gmu_pdev_dev,
		"Unexpectedly got id %d seqnum %d. Total waiters: %d Top %d Waiters:\n",
		MSG_HDR_GET_ID(req_hdr), MSG_HDR_GET_SEQNUM(req_hdr),
		num_waiters, min_t(u32, num_waiters, 5));

	for (i = 0; i < num_waiters && i < 5; i++)
		dev_err_ratelimited(gmu_pdev_dev,
			" id %d seqnum %d\n",
			MSG_HDR_GET_ID(waiters[i]),
			MSG_HDR_GET_SEQNUM(waiters[i]));
}

/* Look up a particular key's value for a given type of payload */
static u32 a6xx_hwsched_lookup_key_value_legacy(struct adreno_device *adreno_dev,
	u32 type, u32 key)
{
	struct hfi_context_bad_cmd_legacy *cmd = adreno_dev->hwsched.ctxt_bad;
	u32 i = 0, payload_bytes;
	void *start;

	if (!cmd->hdr)
		return 0;

	payload_bytes = (MSG_HDR_GET_SIZE(cmd->hdr) << 2) -
			offsetof(struct hfi_context_bad_cmd_legacy, payload);

	start = &cmd->payload[0];


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:522 [MATCH: seqnum] ---
	struct pending_cmd *ack)
{
	const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	u64 ticks = gpudev->read_alwayson(adreno_dev);

	if (ack->results[2] != 0xffffffff)
		return 0;

	dev_err(GMU_PDEV_DEV(device),
		"ACK error: sender id %d seqnum %d\n",
		MSG_HDR_GET_ID(ack->sent_hdr),
		MSG_HDR_GET_SEQNUM(ack->sent_hdr));

	KGSL_GMU_CORE_FORCE_PANIC(device->gmu_core.gf_panic,
				GMU_PDEV(device), ticks, GMU_FAULT_HFI_ACK);
	return -EINVAL;
}

int a6xx_hfi_send_cmd_async(struct adreno_device *adreno_dev, void *data, u32 size_bytes)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	u32 *cmd = data;
	u32 seqnum;
	int rc;
	struct pending_cmd pending_ack;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:524 [MATCH: seqnum] ---
	const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	u64 ticks = gpudev->read_alwayson(adreno_dev);

	if (ack->results[2] != 0xffffffff)
		return 0;

	dev_err(GMU_PDEV_DEV(device),
		"ACK error: sender id %d seqnum %d\n",
		MSG_HDR_GET_ID(ack->sent_hdr),
		MSG_HDR_GET_SEQNUM(ack->sent_hdr));

	KGSL_GMU_CORE_FORCE_PANIC(device->gmu_core.gf_panic,
				GMU_PDEV(device), ticks, GMU_FAULT_HFI_ACK);
	return -EINVAL;
}

int a6xx_hfi_send_cmd_async(struct adreno_device *adreno_dev, void *data, u32 size_bytes)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	u32 *cmd = data;
	u32 seqnum;
	int rc;
	struct pending_cmd pending_ack;

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	*cmd = MSG_HDR_SET_SEQNUM_SIZE(*cmd, seqnum, size_bytes >> 2);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:537 [MATCH: seqnum] ---
				GMU_PDEV(device), ticks, GMU_FAULT_HFI_ACK);
	return -EINVAL;
}

int a6xx_hfi_send_cmd_async(struct adreno_device *adreno_dev, void *data, u32 size_bytes)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	u32 *cmd = data;
	u32 seqnum;
	int rc;
	struct pending_cmd pending_ack;

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	*cmd = MSG_HDR_SET_SEQNUM_SIZE(*cmd, seqnum, size_bytes >> 2);

	add_waiter(hfi, *cmd, &pending_ack);

	rc = a6xx_hfi_cmdq_write(adreno_dev, cmd, size_bytes);
	if (rc)
		goto done;

	rc = adreno_hwsched_wait_ack_completion(adreno_dev,
		GMU_PDEV_DEV(device), &pending_ack, a6xx_hwsched_process_msgq);
	if (rc)
		goto done;

	rc = check_ack_failure(adreno_dev, &pending_ack);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:541 [MATCH: seqnum] ---
int a6xx_hfi_send_cmd_async(struct adreno_device *adreno_dev, void *data, u32 size_bytes)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	u32 *cmd = data;
	u32 seqnum;
	int rc;
	struct pending_cmd pending_ack;

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	*cmd = MSG_HDR_SET_SEQNUM_SIZE(*cmd, seqnum, size_bytes >> 2);

	add_waiter(hfi, *cmd, &pending_ack);

	rc = a6xx_hfi_cmdq_write(adreno_dev, cmd, size_bytes);
	if (rc)
		goto done;

	rc = adreno_hwsched_wait_ack_completion(adreno_dev,
		GMU_PDEV_DEV(device), &pending_ack, a6xx_hwsched_process_msgq);
	if (rc)
		goto done;

	rc = check_ack_failure(adreno_dev, &pending_ack);

done:
	del_waiter(hfi, &pending_ack);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:542 [MATCH: seqnum] ---
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	u32 *cmd = data;
	u32 seqnum;
	int rc;
	struct pending_cmd pending_ack;

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	*cmd = MSG_HDR_SET_SEQNUM_SIZE(*cmd, seqnum, size_bytes >> 2);

	add_waiter(hfi, *cmd, &pending_ack);

	rc = a6xx_hfi_cmdq_write(adreno_dev, cmd, size_bytes);
	if (rc)
		goto done;

	rc = adreno_hwsched_wait_ack_completion(adreno_dev,
		GMU_PDEV_DEV(device), &pending_ack, a6xx_hwsched_process_msgq);
	if (rc)
		goto done;

	rc = check_ack_failure(adreno_dev, &pending_ack);

done:
	del_waiter(hfi, &pending_ack);

	return rc;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:654 [MATCH: seqnum] ---
		hw_hfi->f2h_task = kthread_run(hfi_f2h_main, adreno_dev, "gmu_f2h");

	return PTR_ERR_OR_ZERO(hw_hfi->f2h_task);
}

static int mem_alloc_reply(struct adreno_device *adreno_dev, void *rcvd)
{
	struct hfi_mem_alloc_desc desc = {0};
	struct hfi_mem_alloc_reply_cmd out = {0};
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	u32 seqnum;
	int ret;

	hfi_get_mem_alloc_desc(rcvd, &desc);

	ret = adreno_hwsched_process_mem_alloc(adreno_dev, &desc);
	if (ret)
		return ret;

	memcpy(&out.desc, &desc, sizeof(out.desc));

	out.hdr = ACK_MSG_HDR(F2H_MSG_MEM_ALLOC);
	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	out.hdr = MSG_HDR_SET_SEQNUM_SIZE(out.hdr, seqnum, sizeof(out) >> 2);
	out.req_hdr = *(u32 *)rcvd;

	return a6xx_hfi_cmdq_write(adreno_dev, (u32 *)&out, sizeof(out));
}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:666 [MATCH: seqnum] ---

	hfi_get_mem_alloc_desc(rcvd, &desc);

	ret = adreno_hwsched_process_mem_alloc(adreno_dev, &desc);
	if (ret)
		return ret;

	memcpy(&out.desc, &desc, sizeof(out.desc));

	out.hdr = ACK_MSG_HDR(F2H_MSG_MEM_ALLOC);
	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	out.hdr = MSG_HDR_SET_SEQNUM_SIZE(out.hdr, seqnum, sizeof(out) >> 2);
	out.req_hdr = *(u32 *)rcvd;

	return a6xx_hfi_cmdq_write(adreno_dev, (u32 *)&out, sizeof(out));
}

static int gmu_cntr_register_reply(struct adreno_device *adreno_dev, void *rcvd)
{
	struct hfi_gmu_cntr_register_cmd *in = (struct hfi_gmu_cntr_register_cmd *)rcvd;
	struct hfi_gmu_cntr_register_reply_cmd out = {0};
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	u32 lo = 0, hi = 0, seqnum;

	/*
	 * Failure to allocate counter is not fatal. Sending lo = 0, hi = 0
	 * indicates to GMU that counter allocation failed.
	 */
	adreno_perfcounter_get(adreno_dev,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:667 [MATCH: seqnum] ---
	hfi_get_mem_alloc_desc(rcvd, &desc);

	ret = adreno_hwsched_process_mem_alloc(adreno_dev, &desc);
	if (ret)
		return ret;

	memcpy(&out.desc, &desc, sizeof(out.desc));

	out.hdr = ACK_MSG_HDR(F2H_MSG_MEM_ALLOC);
	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	out.hdr = MSG_HDR_SET_SEQNUM_SIZE(out.hdr, seqnum, sizeof(out) >> 2);
	out.req_hdr = *(u32 *)rcvd;

	return a6xx_hfi_cmdq_write(adreno_dev, (u32 *)&out, sizeof(out));
}

static int gmu_cntr_register_reply(struct adreno_device *adreno_dev, void *rcvd)
{
	struct hfi_gmu_cntr_register_cmd *in = (struct hfi_gmu_cntr_register_cmd *)rcvd;
	struct hfi_gmu_cntr_register_reply_cmd out = {0};
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	u32 lo = 0, hi = 0, seqnum;

	/*
	 * Failure to allocate counter is not fatal. Sending lo = 0, hi = 0
	 * indicates to GMU that counter allocation failed.
	 */
	adreno_perfcounter_get(adreno_dev,
		in->group_id, in->countable, &lo, &hi, PERFCOUNTER_FLAG_KERNEL);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:678 [MATCH: seqnum] ---
	out.req_hdr = *(u32 *)rcvd;

	return a6xx_hfi_cmdq_write(adreno_dev, (u32 *)&out, sizeof(out));
}

static int gmu_cntr_register_reply(struct adreno_device *adreno_dev, void *rcvd)
{
	struct hfi_gmu_cntr_register_cmd *in = (struct hfi_gmu_cntr_register_cmd *)rcvd;
	struct hfi_gmu_cntr_register_reply_cmd out = {0};
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	u32 lo = 0, hi = 0, seqnum;

	/*
	 * Failure to allocate counter is not fatal. Sending lo = 0, hi = 0
	 * indicates to GMU that counter allocation failed.
	 */
	adreno_perfcounter_get(adreno_dev,
		in->group_id, in->countable, &lo, &hi, PERFCOUNTER_FLAG_KERNEL);

	out.hdr = ACK_MSG_HDR(F2H_MSG_GMU_CNTR_REGISTER);
	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	out.hdr = MSG_HDR_SET_SEQNUM_SIZE(out.hdr, seqnum, sizeof(out) >> 2);
	out.req_hdr = in->hdr;
	out.group_id = in->group_id;
	out.countable = in->countable;
	/* Fill in byte offset of counter */
	out.cntr_lo = lo << 2;
	out.cntr_hi = hi << 2;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:688 [MATCH: seqnum] ---
	u32 lo = 0, hi = 0, seqnum;

	/*
	 * Failure to allocate counter is not fatal. Sending lo = 0, hi = 0
	 * indicates to GMU that counter allocation failed.
	 */
	adreno_perfcounter_get(adreno_dev,
		in->group_id, in->countable, &lo, &hi, PERFCOUNTER_FLAG_KERNEL);

	out.hdr = ACK_MSG_HDR(F2H_MSG_GMU_CNTR_REGISTER);
	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	out.hdr = MSG_HDR_SET_SEQNUM_SIZE(out.hdr, seqnum, sizeof(out) >> 2);
	out.req_hdr = in->hdr;
	out.group_id = in->group_id;
	out.countable = in->countable;
	/* Fill in byte offset of counter */
	out.cntr_lo = lo << 2;
	out.cntr_hi = hi << 2;

	return a6xx_hfi_cmdq_write(adreno_dev, (u32 *)&out, sizeof(out));
}

static int send_start_msg(struct adreno_device *adreno_dev)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct device *gmu_pdev_dev = GMU_PDEV_DEV(device);
	u32 seqnum;
	int rc;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:689 [MATCH: seqnum] ---

	/*
	 * Failure to allocate counter is not fatal. Sending lo = 0, hi = 0
	 * indicates to GMU that counter allocation failed.
	 */
	adreno_perfcounter_get(adreno_dev,
		in->group_id, in->countable, &lo, &hi, PERFCOUNTER_FLAG_KERNEL);

	out.hdr = ACK_MSG_HDR(F2H_MSG_GMU_CNTR_REGISTER);
	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	out.hdr = MSG_HDR_SET_SEQNUM_SIZE(out.hdr, seqnum, sizeof(out) >> 2);
	out.req_hdr = in->hdr;
	out.group_id = in->group_id;
	out.countable = in->countable;
	/* Fill in byte offset of counter */
	out.cntr_lo = lo << 2;
	out.cntr_hi = hi << 2;

	return a6xx_hfi_cmdq_write(adreno_dev, (u32 *)&out, sizeof(out));
}

static int send_start_msg(struct adreno_device *adreno_dev)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct device *gmu_pdev_dev = GMU_PDEV_DEV(device);
	u32 seqnum;
	int rc;
	struct hfi_start_cmd cmd;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:705 [MATCH: seqnum] ---
	out.cntr_hi = hi << 2;

	return a6xx_hfi_cmdq_write(adreno_dev, (u32 *)&out, sizeof(out));
}

static int send_start_msg(struct adreno_device *adreno_dev)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct device *gmu_pdev_dev = GMU_PDEV_DEV(device);
	u32 seqnum;
	int rc;
	struct hfi_start_cmd cmd;
	u32 rcvd[MAX_RCVD_SIZE];
	struct pending_cmd pending_ack = {0};

	rc = CMD_MSG_HDR(cmd, H2F_MSG_START);
	if (rc)
		return rc;

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);

	pending_ack.sent_hdr = cmd.hdr;

	rc = a6xx_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
	if (rc)
		return rc;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:715 [MATCH: seqnum] ---
	u32 seqnum;
	int rc;
	struct hfi_start_cmd cmd;
	u32 rcvd[MAX_RCVD_SIZE];
	struct pending_cmd pending_ack = {0};

	rc = CMD_MSG_HDR(cmd, H2F_MSG_START);
	if (rc)
		return rc;

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);

	pending_ack.sent_hdr = cmd.hdr;

	rc = a6xx_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
	if (rc)
		return rc;

poll:
	rc = adreno_hwsched_poll_msg_queue_write_index(gmu->hfi.hfi_mem);

	if (rc) {
		dev_err(gmu_pdev_dev,
			"Timed out processing MSG_START seqnum: %d\n",
			seqnum);
		gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START);
		goto done;
	}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:716 [MATCH: seqnum] ---
	int rc;
	struct hfi_start_cmd cmd;
	u32 rcvd[MAX_RCVD_SIZE];
	struct pending_cmd pending_ack = {0};

	rc = CMD_MSG_HDR(cmd, H2F_MSG_START);
	if (rc)
		return rc;

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);

	pending_ack.sent_hdr = cmd.hdr;

	rc = a6xx_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
	if (rc)
		return rc;

poll:
	rc = adreno_hwsched_poll_msg_queue_write_index(gmu->hfi.hfi_mem);

	if (rc) {
		dev_err(gmu_pdev_dev,
			"Timed out processing MSG_START seqnum: %d\n",
			seqnum);
		gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START);
		goto done;
	}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:729 [MATCH: seqnum] ---

	rc = a6xx_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
	if (rc)
		return rc;

poll:
	rc = adreno_hwsched_poll_msg_queue_write_index(gmu->hfi.hfi_mem);

	if (rc) {
		dev_err(gmu_pdev_dev,
			"Timed out processing MSG_START seqnum: %d\n",
			seqnum);
		gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START);
		goto done;
	}

	rc = a6xx_hfi_queue_read(gmu, HFI_MSG_ID, rcvd, sizeof(rcvd));
	if (rc <= 0) {
		dev_err(gmu_pdev_dev,
			"MSG_START: payload error: %d\n",
			rc);
		gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START);
		goto done;
	}

	switch (MSG_HDR_GET_ID(rcvd[0])) {
	case F2H_MSG_MEM_ALLOC:
		rc = mem_alloc_reply(adreno_dev, rcvd);
		break;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:730 [MATCH: seqnum] ---
	rc = a6xx_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
	if (rc)
		return rc;

poll:
	rc = adreno_hwsched_poll_msg_queue_write_index(gmu->hfi.hfi_mem);

	if (rc) {
		dev_err(gmu_pdev_dev,
			"Timed out processing MSG_START seqnum: %d\n",
			seqnum);
		gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START);
		goto done;
	}

	rc = a6xx_hfi_queue_read(gmu, HFI_MSG_ID, rcvd, sizeof(rcvd));
	if (rc <= 0) {
		dev_err(gmu_pdev_dev,
			"MSG_START: payload error: %d\n",
			rc);
		gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START);
		goto done;
	}

	switch (MSG_HDR_GET_ID(rcvd[0])) {
	case F2H_MSG_MEM_ALLOC:
		rc = mem_alloc_reply(adreno_dev, rcvd);
		break;
	case F2H_MSG_GMU_CNTR_REGISTER:

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:1110 [MATCH: seqnum] ---

#define DISPQ_IRQ_BIT(_idx) BIT((_idx) + HFI_DSP_IRQ_BASE)

static int submit_global_ctxt_cmd(struct adreno_device *adreno_dev, u64 gpuaddr, u32 size)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct {
		struct hfi_submit_cmd submit_cmd;
		struct hfi_issue_ib issue_ib;
	} cmd = {0};
	u32 seqnum, cmd_size = sizeof(cmd);
	static u32 ts;
	int ret = 0;

	cmd.submit_cmd.ctxt_id = KGSL_GLOBAL_CTXT_ID;
	cmd.submit_cmd.ts = ++ts;
	cmd.submit_cmd.numibs = 1;

	cmd.issue_ib.addr = gpuaddr;
	cmd.issue_ib.size = size;

	seqnum = atomic_inc_return(&adreno_dev->hwsched.submission_seqnum);
	cmd.submit_cmd.hdr = CREATE_MSG_HDR(H2F_MSG_ISSUE_CMD, HFI_MSG_CMD);
	cmd.submit_cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.submit_cmd.hdr, seqnum, cmd_size >> 2);

	ret = a6xx_hfi_dispatch_queue_write(adreno_dev, HFI_DSP_ID_0,
			(u32 *)&cmd, cmd_size, NULL, NULL);
	/* Send interrupt to GMU to receive the message */
	if (!ret)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:1121 [MATCH: seqnum] ---
	static u32 ts;
	int ret = 0;

	cmd.submit_cmd.ctxt_id = KGSL_GLOBAL_CTXT_ID;
	cmd.submit_cmd.ts = ++ts;
	cmd.submit_cmd.numibs = 1;

	cmd.issue_ib.addr = gpuaddr;
	cmd.issue_ib.size = size;

	seqnum = atomic_inc_return(&adreno_dev->hwsched.submission_seqnum);
	cmd.submit_cmd.hdr = CREATE_MSG_HDR(H2F_MSG_ISSUE_CMD, HFI_MSG_CMD);
	cmd.submit_cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.submit_cmd.hdr, seqnum, cmd_size >> 2);

	ret = a6xx_hfi_dispatch_queue_write(adreno_dev, HFI_DSP_ID_0,
			(u32 *)&cmd, cmd_size, NULL, NULL);
	/* Send interrupt to GMU to receive the message */
	if (!ret)
		gmu_core_regwrite(device, A6XX_GMU_HOST2GMU_INTR_SET, DISPQ_IRQ_BIT(0));

	return ret;
}

int a6xx_hwsched_counter_inline_enable(struct adreno_device *adreno_dev,
		const struct adreno_perfcount_group *group,
		u32 counter, u32 countable)
{
	struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:1123 [MATCH: seqnum] ---

	cmd.submit_cmd.ctxt_id = KGSL_GLOBAL_CTXT_ID;
	cmd.submit_cmd.ts = ++ts;
	cmd.submit_cmd.numibs = 1;

	cmd.issue_ib.addr = gpuaddr;
	cmd.issue_ib.size = size;

	seqnum = atomic_inc_return(&adreno_dev->hwsched.submission_seqnum);
	cmd.submit_cmd.hdr = CREATE_MSG_HDR(H2F_MSG_ISSUE_CMD, HFI_MSG_CMD);
	cmd.submit_cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.submit_cmd.hdr, seqnum, cmd_size >> 2);

	ret = a6xx_hfi_dispatch_queue_write(adreno_dev, HFI_DSP_ID_0,
			(u32 *)&cmd, cmd_size, NULL, NULL);
	/* Send interrupt to GMU to receive the message */
	if (!ret)
		gmu_core_regwrite(device, A6XX_GMU_HOST2GMU_INTR_SET, DISPQ_IRQ_BIT(0));

	return ret;
}

int a6xx_hwsched_counter_inline_enable(struct adreno_device *adreno_dev,
		const struct adreno_perfcount_group *group,
		u32 counter, u32 countable)
{
	struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct adreno_perfcount_register *reg = &group->regs[counter];
	u32 val, *cmds, count = 0;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:1469 [MATCH: seqnum] ---

	hfi_update_write_idx(&hdr->write_index, write);

	return 0;
}

int a6xx_hwsched_submit_drawobj(struct adreno_device *adreno_dev,
	struct kgsl_drawobj *drawobj)
{
	int ret = 0;
	u32 cmd_sizebytes, seqnum;
	struct kgsl_drawobj_cmd *cmdobj = CMDOBJ(drawobj);
	struct hfi_submit_cmd *cmd;
	struct adreno_submit_time time = {0};
	static void *cmdbuf;
	struct adreno_context *drawctxt = ADRENO_CONTEXT(drawobj->context);

	if (cmdbuf == NULL) {
		struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

		cmdbuf = devm_kzalloc(&device->pdev->dev, HFI_MAX_MSG_SIZE,
			GFP_KERNEL);
		if (!cmdbuf)
			return -ENOMEM;
	}

	ret = hfi_context_register(adreno_dev, drawobj->context);
	if (ret)
		return ret;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:1533 [MATCH: seqnum] ---
		cmd->profile_gpuaddr_hi =
			upper_32_bits(cmdobj->profiling_buffer_gpuaddr);

		/* Indicate to GMU to do user profiling for this submission */
		cmd->flags |= CMDBATCH_PROFILING;
	}

skipib:
	adreno_drawobj_set_constraint(KGSL_DEVICE(adreno_dev), drawobj);

	seqnum = atomic_inc_return(&adreno_dev->hwsched.submission_seqnum);
	cmd->hdr = CREATE_MSG_HDR(H2F_MSG_ISSUE_CMD, HFI_MSG_CMD);
	cmd->hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd->hdr, seqnum, cmd_sizebytes >> 2);

	ret = a6xx_hfi_dispatch_queue_write(adreno_dev,
		HFI_DSP_ID_0 + drawobj->context->gmu_dispatch_queue,
		(u32 *)cmd, cmd_sizebytes, cmdobj, &time);
	if (ret)
		return ret;

	/* Send interrupt to GMU to receive the message */
	gmu_core_regwrite(KGSL_DEVICE(adreno_dev), A6XX_GMU_HOST2GMU_INTR_SET,
		DISPQ_IRQ_BIT(drawobj->context->gmu_dispatch_queue));

	drawctxt->internal_timestamp = drawobj->timestamp;

	return ret;
}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:1535 [MATCH: seqnum] ---

		/* Indicate to GMU to do user profiling for this submission */
		cmd->flags |= CMDBATCH_PROFILING;
	}

skipib:
	adreno_drawobj_set_constraint(KGSL_DEVICE(adreno_dev), drawobj);

	seqnum = atomic_inc_return(&adreno_dev->hwsched.submission_seqnum);
	cmd->hdr = CREATE_MSG_HDR(H2F_MSG_ISSUE_CMD, HFI_MSG_CMD);
	cmd->hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd->hdr, seqnum, cmd_sizebytes >> 2);

	ret = a6xx_hfi_dispatch_queue_write(adreno_dev,
		HFI_DSP_ID_0 + drawobj->context->gmu_dispatch_queue,
		(u32 *)cmd, cmd_sizebytes, cmdobj, &time);
	if (ret)
		return ret;

	/* Send interrupt to GMU to receive the message */
	gmu_core_regwrite(KGSL_DEVICE(adreno_dev), A6XX_GMU_HOST2GMU_INTR_SET,
		DISPQ_IRQ_BIT(drawobj->context->gmu_dispatch_queue));

	drawctxt->internal_timestamp = drawobj->timestamp;

	return ret;
}

int a6xx_hwsched_send_recurring_cmdobj(struct adreno_device *adreno_dev,
	struct kgsl_drawobj_cmd *cmdobj)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:1665 [MATCH: seqnum] ---
}

static int send_context_unregister_hfi(struct adreno_device *adreno_dev,
	struct kgsl_context *context, u32 ts)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct pending_cmd pending_ack;
	struct hfi_unregister_ctxt_cmd cmd;
	u32 seqnum;
	int ret;

	/* Only send HFI if device is not in SLUMBER */
	if (!context->gmu_registered ||
		!test_bit(GMU_PRIV_GPU_STARTED, &gmu->flags))
		return 0;

	ret = CMD_MSG_HDR(cmd, H2F_MSG_UNREGISTER_CONTEXT);
	if (ret)
		return ret;

	cmd.ctxt_id = context->id,
	cmd.ts = ts,

	/*
	 * Although we know device is powered on, we can still enter SLUMBER
	 * because the wait for ack below is done without holding the mutex. So
	 * take an active count before releasing the mutex so as to avoid a

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:1692 [MATCH: seqnum] ---
	 * because the wait for ack below is done without holding the mutex. So
	 * take an active count before releasing the mutex so as to avoid a
	 * concurrent SLUMBER sequence while GMU is un-registering this context.
	 */
	ret = adreno_active_count_get(adreno_dev);
	if (ret) {
		trigger_context_unregister_fault(adreno_dev, context);
		return ret;
	}

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
	add_waiter(hfi, cmd.hdr, &pending_ack);

	ret = a6xx_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
	if (ret) {
		trigger_context_unregister_fault(adreno_dev, context);
		goto done;
	}

	ret = adreno_hwsched_ctxt_unregister_wait_completion(adreno_dev,
		GMU_PDEV_DEV(device), context, &pending_ack, a6xx_hwsched_process_msgq, &cmd);
	if (ret) {
		trigger_context_unregister_fault(adreno_dev, context);
		goto done;
	}

	ret = check_ack_failure(adreno_dev, &pending_ack);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:1693 [MATCH: seqnum] ---
	 * take an active count before releasing the mutex so as to avoid a
	 * concurrent SLUMBER sequence while GMU is un-registering this context.
	 */
	ret = adreno_active_count_get(adreno_dev);
	if (ret) {
		trigger_context_unregister_fault(adreno_dev, context);
		return ret;
	}

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
	add_waiter(hfi, cmd.hdr, &pending_ack);

	ret = a6xx_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
	if (ret) {
		trigger_context_unregister_fault(adreno_dev, context);
		goto done;
	}

	ret = adreno_hwsched_ctxt_unregister_wait_completion(adreno_dev,
		GMU_PDEV_DEV(device), context, &pending_ack, a6xx_hwsched_process_msgq, &cmd);
	if (ret) {
		trigger_context_unregister_fault(adreno_dev, context);
		goto done;
	}

	ret = check_ack_failure(adreno_dev, &pending_ack);

done:

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:1754 [MATCH: seqnum] ---
}

u32 a6xx_hwsched_preempt_count_get(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct hfi_get_value_cmd cmd;
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
	struct pending_cmd pending_ack;
	int rc;
	u32 seqnum;

	if (device->state != KGSL_STATE_ACTIVE)
		return 0;

	rc = CMD_MSG_HDR(cmd, H2F_MSG_GET_VALUE);
	if (rc)
		return 0;

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
	cmd.type = HFI_VALUE_PREEMPT_COUNT;
	cmd.subtype = 0;

	add_waiter(hfi, cmd.hdr, &pending_ack);

	rc = a6xx_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
	if (rc)
		goto done;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:1763 [MATCH: seqnum] ---
	int rc;
	u32 seqnum;

	if (device->state != KGSL_STATE_ACTIVE)
		return 0;

	rc = CMD_MSG_HDR(cmd, H2F_MSG_GET_VALUE);
	if (rc)
		return 0;

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
	cmd.type = HFI_VALUE_PREEMPT_COUNT;
	cmd.subtype = 0;

	add_waiter(hfi, cmd.hdr, &pending_ack);

	rc = a6xx_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
	if (rc)
		goto done;

	rc = adreno_hwsched_wait_ack_completion(adreno_dev,
		GMU_PDEV_DEV(device), &pending_ack, a6xx_hwsched_process_msgq);
	if (rc)
		goto done;

	rc = check_ack_failure(adreno_dev, &pending_ack);

done:

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:1764 [MATCH: seqnum] ---
	u32 seqnum;

	if (device->state != KGSL_STATE_ACTIVE)
		return 0;

	rc = CMD_MSG_HDR(cmd, H2F_MSG_GET_VALUE);
	if (rc)
		return 0;

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);
	cmd.type = HFI_VALUE_PREEMPT_COUNT;
	cmd.subtype = 0;

	add_waiter(hfi, cmd.hdr, &pending_ack);

	rc = a6xx_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
	if (rc)
		goto done;

	rc = adreno_hwsched_wait_ack_completion(adreno_dev,
		GMU_PDEV_DEV(device), &pending_ack, a6xx_hwsched_process_msgq);
	if (rc)
		goto done;

	rc = check_ack_failure(adreno_dev, &pending_ack);

done:
	del_waiter(hfi, &pending_ack);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:80 [MATCH: sent_hdr] ---
static void add_waiter(struct a6xx_hwsched_hfi *hfi, u32 hdr,
	struct pending_cmd *ack)
{
	memset(ack, 0x0, sizeof(*ack));

	init_completion(&ack->complete);
	write_lock_irq(&hfi->msglock);
	list_add_tail(&ack->node, &hfi->msglist);
	write_unlock_irq(&hfi->msglock);

	ack->sent_hdr = hdr;
}

static void del_waiter(struct a6xx_hwsched_hfi *hfi, struct pending_cmd *ack)
{
	write_lock_irq(&hfi->msglock);
	list_del(&ack->node);
	write_unlock_irq(&hfi->msglock);
}

static void a6xx_receive_ack_async(struct adreno_device *adreno_dev, void *rcvd)
{
	struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
	struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
	struct pending_cmd *cmd = NULL;
	u32 waiters[64], num_waiters = 0, i;
	u32 *ack = rcvd;
	u32 hdr = ack[0];
	u32 req_hdr = ack[1];

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:119 [MATCH: sent_hdr] ---
		if (CMP_HFI_ACK_HDR(cmd->sent_hdr, req_hdr)) {
			memcpy(cmd->results, ack,
				min_t(u32, size_bytes,
					sizeof(cmd->results)));
			complete(&cmd->complete);
			read_unlock(&hfi->msglock);
			return;
		}

		if (num_waiters < ARRAY_SIZE(waiters))
			waiters[num_waiters++] = cmd->sent_hdr;
	}

	read_unlock(&hfi->msglock);

	/* Didn't find the sender, list the waiter */
	dev_err_ratelimited(gmu_pdev_dev,
		"Unexpectedly got id %d seqnum %d. Total waiters: %d Top %d Waiters:\n",
		MSG_HDR_GET_ID(req_hdr), MSG_HDR_GET_SEQNUM(req_hdr),
		num_waiters, min_t(u32, num_waiters, 5));

	for (i = 0; i < num_waiters && i < 5; i++)
		dev_err_ratelimited(gmu_pdev_dev,
			" id %d seqnum %d\n",
			MSG_HDR_GET_ID(waiters[i]),
			MSG_HDR_GET_SEQNUM(waiters[i]));
}

/* Look up a particular key's value for a given type of payload */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:523 [MATCH: sent_hdr] ---
{
	const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	u64 ticks = gpudev->read_alwayson(adreno_dev);

	if (ack->results[2] != 0xffffffff)
		return 0;

	dev_err(GMU_PDEV_DEV(device),
		"ACK error: sender id %d seqnum %d\n",
		MSG_HDR_GET_ID(ack->sent_hdr),
		MSG_HDR_GET_SEQNUM(ack->sent_hdr));

	KGSL_GMU_CORE_FORCE_PANIC(device->gmu_core.gf_panic,
				GMU_PDEV(device), ticks, GMU_FAULT_HFI_ACK);
	return -EINVAL;
}

int a6xx_hfi_send_cmd_async(struct adreno_device *adreno_dev, void *data, u32 size_bytes)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	u32 *cmd = data;
	u32 seqnum;
	int rc;
	struct pending_cmd pending_ack;

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:718 [MATCH: sent_hdr] ---
	u32 rcvd[MAX_RCVD_SIZE];
	struct pending_cmd pending_ack = {0};

	rc = CMD_MSG_HDR(cmd, H2F_MSG_START);
	if (rc)
		return rc;

	seqnum = atomic_inc_return(&gmu->hfi.seqnum);
	cmd.hdr = MSG_HDR_SET_SEQNUM_SIZE(cmd.hdr, seqnum, sizeof(cmd) >> 2);

	pending_ack.sent_hdr = cmd.hdr;

	rc = a6xx_hfi_cmdq_write(adreno_dev, (u32 *)&cmd, sizeof(cmd));
	if (rc)
		return rc;

poll:
	rc = adreno_hwsched_poll_msg_queue_write_index(gmu->hfi.hfi_mem);

	if (rc) {
		dev_err(gmu_pdev_dev,
			"Timed out processing MSG_START seqnum: %d\n",
			seqnum);
		gmu_core_fault_snapshot(device, GMU_FAULT_H2F_MSG_START);
		goto done;
	}

	rc = a6xx_hfi_queue_read(gmu, HFI_MSG_ID, rcvd, sizeof(rcvd));
	if (rc <= 0) {

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:101 [MATCH: results] ---
{
	struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
	struct device *gmu_pdev_dev = GMU_PDEV_DEV(KGSL_DEVICE(adreno_dev));
	struct pending_cmd *cmd = NULL;
	u32 waiters[64], num_waiters = 0, i;
	u32 *ack = rcvd;
	u32 hdr = ack[0];
	u32 req_hdr = ack[1];
	u32 size_bytes = MSG_HDR_GET_SIZE(hdr) << 2;

	if (size_bytes > sizeof(cmd->results))
		dev_err_ratelimited(gmu_pdev_dev,
			"Ack result too big: %d Truncating to: %ld\n",
			size_bytes, sizeof(cmd->results));

	read_lock(&hfi->msglock);

	list_for_each_entry(cmd, &hfi->msglist, node) {
		if (CMP_HFI_ACK_HDR(cmd->sent_hdr, req_hdr)) {
			memcpy(cmd->results, ack,
				min_t(u32, size_bytes,
					sizeof(cmd->results)));
			complete(&cmd->complete);
			read_unlock(&hfi->msglock);
			return;
		}

		if (num_waiters < ARRAY_SIZE(waiters))
			waiters[num_waiters++] = cmd->sent_hdr;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:104 [MATCH: results] ---
	struct pending_cmd *cmd = NULL;
	u32 waiters[64], num_waiters = 0, i;
	u32 *ack = rcvd;
	u32 hdr = ack[0];
	u32 req_hdr = ack[1];
	u32 size_bytes = MSG_HDR_GET_SIZE(hdr) << 2;

	if (size_bytes > sizeof(cmd->results))
		dev_err_ratelimited(gmu_pdev_dev,
			"Ack result too big: %d Truncating to: %ld\n",
			size_bytes, sizeof(cmd->results));

	read_lock(&hfi->msglock);

	list_for_each_entry(cmd, &hfi->msglist, node) {
		if (CMP_HFI_ACK_HDR(cmd->sent_hdr, req_hdr)) {
			memcpy(cmd->results, ack,
				min_t(u32, size_bytes,
					sizeof(cmd->results)));
			complete(&cmd->complete);
			read_unlock(&hfi->msglock);
			return;
		}

		if (num_waiters < ARRAY_SIZE(waiters))
			waiters[num_waiters++] = cmd->sent_hdr;
	}

	read_unlock(&hfi->msglock);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:110 [MATCH: results] ---

	if (size_bytes > sizeof(cmd->results))
		dev_err_ratelimited(gmu_pdev_dev,
			"Ack result too big: %d Truncating to: %ld\n",
			size_bytes, sizeof(cmd->results));

	read_lock(&hfi->msglock);

	list_for_each_entry(cmd, &hfi->msglist, node) {
		if (CMP_HFI_ACK_HDR(cmd->sent_hdr, req_hdr)) {
			memcpy(cmd->results, ack,
				min_t(u32, size_bytes,
					sizeof(cmd->results)));
			complete(&cmd->complete);
			read_unlock(&hfi->msglock);
			return;
		}

		if (num_waiters < ARRAY_SIZE(waiters))
			waiters[num_waiters++] = cmd->sent_hdr;
	}

	read_unlock(&hfi->msglock);

	/* Didn't find the sender, list the waiter */
	dev_err_ratelimited(gmu_pdev_dev,
		"Unexpectedly got id %d seqnum %d. Total waiters: %d Top %d Waiters:\n",
		MSG_HDR_GET_ID(req_hdr), MSG_HDR_GET_SEQNUM(req_hdr),
		num_waiters, min_t(u32, num_waiters, 5));

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:112 [MATCH: results] ---
		dev_err_ratelimited(gmu_pdev_dev,
			"Ack result too big: %d Truncating to: %ld\n",
			size_bytes, sizeof(cmd->results));

	read_lock(&hfi->msglock);

	list_for_each_entry(cmd, &hfi->msglist, node) {
		if (CMP_HFI_ACK_HDR(cmd->sent_hdr, req_hdr)) {
			memcpy(cmd->results, ack,
				min_t(u32, size_bytes,
					sizeof(cmd->results)));
			complete(&cmd->complete);
			read_unlock(&hfi->msglock);
			return;
		}

		if (num_waiters < ARRAY_SIZE(waiters))
			waiters[num_waiters++] = cmd->sent_hdr;
	}

	read_unlock(&hfi->msglock);

	/* Didn't find the sender, list the waiter */
	dev_err_ratelimited(gmu_pdev_dev,
		"Unexpectedly got id %d seqnum %d. Total waiters: %d Top %d Waiters:\n",
		MSG_HDR_GET_ID(req_hdr), MSG_HDR_GET_SEQNUM(req_hdr),
		num_waiters, min_t(u32, num_waiters, 5));

	for (i = 0; i < num_waiters && i < 5; i++)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:518 [MATCH: results] ---

#define HFI_IRQ_MSGQ_MASK BIT(0)

static int check_ack_failure(struct adreno_device *adreno_dev,
	struct pending_cmd *ack)
{
	const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	u64 ticks = gpudev->read_alwayson(adreno_dev);

	if (ack->results[2] != 0xffffffff)
		return 0;

	dev_err(GMU_PDEV_DEV(device),
		"ACK error: sender id %d seqnum %d\n",
		MSG_HDR_GET_ID(ack->sent_hdr),
		MSG_HDR_GET_SEQNUM(ack->sent_hdr));

	KGSL_GMU_CORE_FORCE_PANIC(device->gmu_core.gf_panic,
				GMU_PDEV(device), ticks, GMU_FAULT_HFI_ACK);
	return -EINVAL;
}

int a6xx_hfi_send_cmd_async(struct adreno_device *adreno_dev, void *data, u32 size_bytes)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	u32 *cmd = data;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:1739 [MATCH: results] ---

	if (ret)
		goto out;

	kgsl_sharedmem_writel(device->memstore,
		KGSL_MEMSTORE_OFFSET(context->id, soptimestamp), drawctxt->timestamp);

	kgsl_sharedmem_writel(device->memstore,
		KGSL_MEMSTORE_OFFSET(context->id, eoptimestamp), drawctxt->timestamp);

	adreno_profile_process_results(adreno_dev);
	context->gmu_registered = false;

out:
	kgsl_mutex_unlock(&device->mutex);
}

u32 a6xx_hwsched_preempt_count_get(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct hfi_get_value_cmd cmd;
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
	struct pending_cmd pending_ack;
	int rc;
	u32 seqnum;

	if (device->state != KGSL_STATE_ACTIVE)
		return 0;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:1784 [MATCH: results] ---
	rc = adreno_hwsched_wait_ack_completion(adreno_dev,
		GMU_PDEV_DEV(device), &pending_ack, a6xx_hwsched_process_msgq);
	if (rc)
		goto done;

	rc = check_ack_failure(adreno_dev, &pending_ack);

done:
	del_waiter(hfi, &pending_ack);

	return rc ? 0 : pending_ack.results[2];
}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:370 [MATCH: mutex_lock] ---

static void a6xx_hwsched_process_msgq(struct adreno_device *adreno_dev)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct a6xx_hwsched_hfi *hw_hfi = to_a6xx_hwsched_hfi(adreno_dev);
	u32 rcvd[MAX_RCVD_SIZE], next_hdr;

	if (!(hw_hfi->irq_mask & HFI_IRQ_MSGQ_MASK))
		return;

	mutex_lock(&hw_hfi->msgq_mutex);

	for (;;) {
		next_hdr = peek_next_header(gmu, HFI_MSG_ID);

		if (!next_hdr)
			break;

		if (MSG_HDR_GET_ID(next_hdr) == F2H_MSG_CONTEXT_BAD) {
			a6xx_hfi_queue_read(gmu, HFI_MSG_ID,
				(u32 *)adreno_dev->hwsched.ctxt_bad,
				HFI_MAX_MSG_SIZE);
			process_ctx_bad(adreno_dev);
			continue;
		}

		a6xx_hfi_queue_read(gmu, HFI_MSG_ID, rcvd, sizeof(rcvd));

		/*

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:1725 [MATCH: mutex_lock] ---
	return ret;
}

void a6xx_hwsched_context_detach(struct adreno_context *drawctxt)
{
	struct kgsl_context *context = &drawctxt->base;
	struct kgsl_device *device = context->device;
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	int ret = 0;

	kgsl_mutex_lock(&device->mutex);

	ret = send_context_unregister_hfi(adreno_dev, context,
		drawctxt->internal_timestamp);

	if (ret)
		goto out;

	kgsl_sharedmem_writel(device->memstore,
		KGSL_MEMSTORE_OFFSET(context->id, soptimestamp), drawctxt->timestamp);

	kgsl_sharedmem_writel(device->memstore,
		KGSL_MEMSTORE_OFFSET(context->id, eoptimestamp), drawctxt->timestamp);

	adreno_profile_process_results(adreno_dev);
	context->gmu_registered = false;

out:
	kgsl_mutex_unlock(&device->mutex);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:406 [MATCH: mutex_unlock] ---
			adreno_scheduler_queue(adreno_dev);
			adreno_hwsched_log_profiling_info(adreno_dev, rcvd);
		} else if (MSG_HDR_GET_ID(rcvd[0]) == F2H_MSG_GMU_CNTR_RELEASE) {
			struct hfi_gmu_cntr_release_cmd *cmd =
				(struct hfi_gmu_cntr_release_cmd *) rcvd;

			adreno_perfcounter_put(adreno_dev,
				cmd->group_id, cmd->countable, PERFCOUNTER_FLAG_KERNEL);
		}
	}
	mutex_unlock(&hw_hfi->msgq_mutex);
}

static void process_log_block(struct adreno_device *adreno_dev, void *data)
{
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct hfi_log_block *cmd = data;
	u32 *log_event = gmu->gmu_log->hostptr;
	u32 start, end;

	start = cmd->start_index;
	end = cmd->stop_index;

	log_event += start * 4;
	while (start != end) {
		trace_gmu_event(log_event);
		log_event += 4;
		start++;
	}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_hwsched_hfi.c:1743 [MATCH: mutex_unlock] ---
	kgsl_sharedmem_writel(device->memstore,
		KGSL_MEMSTORE_OFFSET(context->id, soptimestamp), drawctxt->timestamp);

	kgsl_sharedmem_writel(device->memstore,
		KGSL_MEMSTORE_OFFSET(context->id, eoptimestamp), drawctxt->timestamp);

	adreno_profile_process_results(adreno_dev);
	context->gmu_registered = false;

out:
	kgsl_mutex_unlock(&device->mutex);
}

u32 a6xx_hwsched_preempt_count_get(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct hfi_get_value_cmd cmd;
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	struct a6xx_hwsched_hfi *hfi = to_a6xx_hwsched_hfi(adreno_dev);
	struct pending_cmd pending_ack;
	int rc;
	u32 seqnum;

	if (device->state != KGSL_STATE_ACTIVE)
		return 0;

	rc = CMD_MSG_HDR(cmd, H2F_MSG_GET_VALUE);
	if (rc)
		return 0;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_perfcounter.c:126 [MATCH: timeout] ---
	/*
	 * schedule dispatcher to make sure rb[0] is run, because
	 * if the current RB is not rb[0] and gpu is idle then
	 * rb[0] will not get scheduled to run
	 */
	if (adreno_dev->cur_rb != rb)
		adreno_scheduler_queue(adreno_dev);

	/* wait for the above commands submitted to complete */
	ret = adreno_ringbuffer_waittimestamp(rb, rb->timestamp,
		ADRENO_IDLE_TIMEOUT);

	if (ret) {
		/*
		 * If we were woken up because of cancelling rb events
		 * either due to soft reset or adreno_stop, ignore the
		 * error and return 0 here. The perfcounter is already
		 * set up in software and it will be programmed in
		 * hardware when we wake up or come up after soft reset,
		 * by adreno_perfcounter_restore.
		 */
		if (ret == -EAGAIN)
			ret = 0;
		else
			dev_err(KGSL_DEVICE(adreno_dev)->dev,
				     "Perfcounter %s/%u/%u start via commands failed %d\n",
				     group->name, counter, countable, ret);
	}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_preempt.c:55 [MATCH: timeout] ---

		kgsl_regread(device, A6XX_CP_RB_WPTR, &wptr);
		if (wptr != rb->wptr) {
			kgsl_regwrite(device, A6XX_CP_RB_WPTR, rb->wptr);
			reset_timer = true;
		}
	}

	if (reset_timer)
		rb->dispatch_q.expires = jiffies +
			msecs_to_jiffies(adreno_drawobj_timeout);

	spin_unlock_irqrestore(&rb->preempt_lock, flags);

	if (!atomic) {
		/* If WPTR update fails, set the fault and trigger recovery */
		if (ret) {
			gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
			adreno_scheduler_fault(adreno_dev,
				ADRENO_GMU_FAULT_SKIP_SNAPSHOT);
		}
	}
}

static void _power_collapse_set(struct adreno_device *adreno_dev, bool val)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	if (!gmu_core_isenabled(device))

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_preempt.c:379 [MATCH: timeout] ---
	if (a6xx_fenced_write(adreno_dev,
		A6XX_CP_CONTEXT_SWITCH_NON_PRIV_RESTORE_ADDR_HI,
		upper_32_bits(gpuaddr),
		FENCE_STATUS_WRITEDROPPED1_MASK))
		goto err;

	adreno_dev->next_rb = next;

	/* Start the timer to detect a stuck preemption */
	mod_timer(&adreno_dev->preempt.timer,
		jiffies + msecs_to_jiffies(ADRENO_PREEMPT_TIMEOUT));

	cntl = (preempt->preempt_level << 6) | 0x01;

	/* Skip save/restore during L1 preemption */
	if (preempt->skipsaverestore)
		cntl |= (1 << 9);

	/* Enable GMEM save/restore across preemption */
	if (preempt->usesgmem)
		cntl |= (1 << 8);

	trace_adreno_preempt_trigger(adreno_dev->cur_rb->id, adreno_dev->next_rb->id,
		cntl, 0);

	adreno_set_preempt_state(adreno_dev, ADRENO_PREEMPT_TRIGGERED);

	/* Trigger the preemption */
	if (a6xx_fenced_write(adreno_dev, A6XX_CP_CONTEXT_SWITCH_CNTL, cntl,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_preempt.c:204 [MATCH: mutex_lock] ---

static void _a6xx_preemption_worker(struct work_struct *work)
{
	struct adreno_preemption *preempt = container_of(work,
		struct adreno_preemption, work);
	struct adreno_device *adreno_dev = container_of(preempt,
		struct adreno_device, preempt);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	/* Need to take the mutex to make sure that the power stays on */
	kgsl_mutex_lock(&device->mutex);

	if (adreno_in_preempt_state(adreno_dev, ADRENO_PREEMPT_FAULTED))
		_a6xx_preemption_fault(adreno_dev);

	kgsl_mutex_unlock(&device->mutex);
}

/* Find the highest priority active ringbuffer */
static struct adreno_ringbuffer *a6xx_next_ringbuffer(
		struct adreno_device *adreno_dev)
{
	struct adreno_ringbuffer *rb;
	unsigned long flags;
	unsigned int i;

	FOR_EACH_RINGBUFFER(adreno_dev, rb, i) {
		bool empty;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_preempt.c:485 [MATCH: mutex_lock] ---
	a6xx_preemption_trigger(adreno_dev, true);
}

void a6xx_preemption_schedule(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	if (!adreno_is_preemption_enabled(adreno_dev))
		return;

	kgsl_mutex_lock(&device->mutex);

	if (adreno_in_preempt_state(adreno_dev, ADRENO_PREEMPT_COMPLETE))
		_a6xx_preemption_done(adreno_dev);

	a6xx_preemption_trigger(adreno_dev, false);

	kgsl_mutex_unlock(&device->mutex);
}

u32 a6xx_preemption_pre_ibsubmit(struct adreno_device *adreno_dev,
		struct adreno_ringbuffer *rb, struct adreno_context *drawctxt,
		u32 *cmds)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	u32 count = kgsl_mmu_is_secured(&device->mmu) ? 12 : 9;
	unsigned int *cmds_orig = cmds;
	uint64_t gpuaddr = 0;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_preempt.c:209 [MATCH: mutex_unlock] ---
	struct adreno_device *adreno_dev = container_of(preempt,
		struct adreno_device, preempt);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	/* Need to take the mutex to make sure that the power stays on */
	kgsl_mutex_lock(&device->mutex);

	if (adreno_in_preempt_state(adreno_dev, ADRENO_PREEMPT_FAULTED))
		_a6xx_preemption_fault(adreno_dev);

	kgsl_mutex_unlock(&device->mutex);
}

/* Find the highest priority active ringbuffer */
static struct adreno_ringbuffer *a6xx_next_ringbuffer(
		struct adreno_device *adreno_dev)
{
	struct adreno_ringbuffer *rb;
	unsigned long flags;
	unsigned int i;

	FOR_EACH_RINGBUFFER(adreno_dev, rb, i) {
		bool empty;

		spin_lock_irqsave(&rb->preempt_lock, flags);
		empty = adreno_rb_empty(rb);
		spin_unlock_irqrestore(&rb->preempt_lock, flags);

		if (!empty)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_preempt.c:492 [MATCH: mutex_unlock] ---
	if (!adreno_is_preemption_enabled(adreno_dev))
		return;

	kgsl_mutex_lock(&device->mutex);

	if (adreno_in_preempt_state(adreno_dev, ADRENO_PREEMPT_COMPLETE))
		_a6xx_preemption_done(adreno_dev);

	a6xx_preemption_trigger(adreno_dev, false);

	kgsl_mutex_unlock(&device->mutex);
}

u32 a6xx_preemption_pre_ibsubmit(struct adreno_device *adreno_dev,
		struct adreno_ringbuffer *rb, struct adreno_context *drawctxt,
		u32 *cmds)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	u32 count = kgsl_mmu_is_secured(&device->mmu) ? 12 : 9;
	unsigned int *cmds_orig = cmds;
	uint64_t gpuaddr = 0;

	if (!adreno_is_preemption_enabled(adreno_dev))
		return 0;

	if (drawctxt && drawctxt->base.user_ctxt_record)
		gpuaddr = drawctxt->base.user_ctxt_record->memdesc.gpuaddr;

	if (gpuaddr)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_preempt.c:27 [MATCH: spin_lock] ---
		offsetof(struct a6xx_cp_smmu_info, _field)

static void _update_wptr(struct adreno_device *adreno_dev, bool reset_timer,
	bool atomic)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct adreno_ringbuffer *rb = adreno_dev->cur_rb;
	unsigned long flags;
	int ret = 0;

	spin_lock_irqsave(&rb->preempt_lock, flags);

	if (!atomic) {
		/*
		 * We might have skipped updating the wptr in case we are in
		 * dispatcher context. Do it now.
		 */
		if (rb->skip_inline_wptr) {

			ret = a6xx_fenced_write(adreno_dev,
				A6XX_CP_RB_WPTR, rb->wptr,
				FENCE_STATUS_WRITEDROPPED0_MASK);

			reset_timer = true;
			rb->skip_inline_wptr = false;
		}
	} else {
		unsigned int wptr;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_preempt.c:223 [MATCH: spin_lock] ---
static struct adreno_ringbuffer *a6xx_next_ringbuffer(
		struct adreno_device *adreno_dev)
{
	struct adreno_ringbuffer *rb;
	unsigned long flags;
	unsigned int i;

	FOR_EACH_RINGBUFFER(adreno_dev, rb, i) {
		bool empty;

		spin_lock_irqsave(&rb->preempt_lock, flags);
		empty = adreno_rb_empty(rb);
		spin_unlock_irqrestore(&rb->preempt_lock, flags);

		if (!empty)
			return rb;
	}

	return NULL;
}

void a6xx_preemption_trigger(struct adreno_device *adreno_dev, bool atomic)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct kgsl_iommu *iommu = KGSL_IOMMU(device);
	struct adreno_ringbuffer *next;
	uint64_t ttbr0, gpuaddr;
	unsigned int contextidr, cntl;
	unsigned long flags;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_preempt.c:281 [MATCH: spin_lock] ---
	}

	/* Turn off the dispatcher timer */
	kgsl_delete_timer(&adreno_dev->dispatcher.timer);

	/*
	 * This is the most critical section - we need to take care not to race
	 * until we have programmed the CP for the switch
	 */

	spin_lock_irqsave(&next->preempt_lock, flags);

	/* Get the pagetable from the pagetable info. */
	kgsl_sharedmem_readq(device->scratch, &ttbr0,
		SCRATCH_RB_OFFSET(next->id, ttbr0));
	kgsl_sharedmem_readl(device->scratch, &contextidr,
		SCRATCH_RB_OFFSET(next->id, contextidr));

	kgsl_sharedmem_writel(next->preemption_desc,
		PREEMPT_RECORD(wptr), next->wptr);

	spin_unlock_irqrestore(&next->preempt_lock, flags);

	/* And write it to the smmu info */

	if (kgsl_mmu_is_perprocess(&device->mmu)) {
		kgsl_sharedmem_writeq(iommu->smmu_info,
			PREEMPT_SMMU_RECORD(ttbr0), ttbr0);
		kgsl_sharedmem_writel(iommu->smmu_info,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_preempt.c:57 [MATCH: spin_unlock] ---
		if (wptr != rb->wptr) {
			kgsl_regwrite(device, A6XX_CP_RB_WPTR, rb->wptr);
			reset_timer = true;
		}
	}

	if (reset_timer)
		rb->dispatch_q.expires = jiffies +
			msecs_to_jiffies(adreno_drawobj_timeout);

	spin_unlock_irqrestore(&rb->preempt_lock, flags);

	if (!atomic) {
		/* If WPTR update fails, set the fault and trigger recovery */
		if (ret) {
			gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
			adreno_scheduler_fault(adreno_dev,
				ADRENO_GMU_FAULT_SKIP_SNAPSHOT);
		}
	}
}

static void _power_collapse_set(struct adreno_device *adreno_dev, bool val)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	if (!gmu_core_isenabled(device))
		return;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_preempt.c:225 [MATCH: spin_unlock] ---
{
	struct adreno_ringbuffer *rb;
	unsigned long flags;
	unsigned int i;

	FOR_EACH_RINGBUFFER(adreno_dev, rb, i) {
		bool empty;

		spin_lock_irqsave(&rb->preempt_lock, flags);
		empty = adreno_rb_empty(rb);
		spin_unlock_irqrestore(&rb->preempt_lock, flags);

		if (!empty)
			return rb;
	}

	return NULL;
}

void a6xx_preemption_trigger(struct adreno_device *adreno_dev, bool atomic)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct kgsl_iommu *iommu = KGSL_IOMMU(device);
	struct adreno_ringbuffer *next;
	uint64_t ttbr0, gpuaddr;
	unsigned int contextidr, cntl;
	unsigned long flags;
	struct adreno_preemption *preempt = &adreno_dev->preempt;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_preempt.c:292 [MATCH: spin_unlock] ---

	/* Get the pagetable from the pagetable info. */
	kgsl_sharedmem_readq(device->scratch, &ttbr0,
		SCRATCH_RB_OFFSET(next->id, ttbr0));
	kgsl_sharedmem_readl(device->scratch, &contextidr,
		SCRATCH_RB_OFFSET(next->id, contextidr));

	kgsl_sharedmem_writel(next->preemption_desc,
		PREEMPT_RECORD(wptr), next->wptr);

	spin_unlock_irqrestore(&next->preempt_lock, flags);

	/* And write it to the smmu info */

	if (kgsl_mmu_is_perprocess(&device->mmu)) {
		kgsl_sharedmem_writeq(iommu->smmu_info,
			PREEMPT_SMMU_RECORD(ttbr0), ttbr0);
		kgsl_sharedmem_writel(iommu->smmu_info,
			PREEMPT_SMMU_RECORD(context_idr), contextidr);
	}

	kgsl_sharedmem_readq(preempt->scratch, &gpuaddr,
		next->id * sizeof(u64));

	/*
	 * Set a keepalive bit before the first preemption register write.
	 * This is required since while each individual write to the context
	 * switch registers will wake the GPU from collapse, it will not in
	 * itself cause GPU activity. Thus, the GPU could technically be

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_rgmu.c:25 [MATCH: timeout] ---
#include "adreno.h"
#include "adreno_a6xx.h"
#include "adreno_a6xx_rgmu.h"
#include "adreno_snapshot.h"
#include "kgsl_bus.h"
#include "kgsl_trace.h"
#include "kgsl_util.h"

#define RGMU_CLK_FREQ 200000000

/* RGMU timeouts */
#define RGMU_IDLE_TIMEOUT		100	/* ms */
#define RGMU_START_TIMEOUT		100	/* ms */
#define GPU_START_TIMEOUT		100	/* ms */
#define GLM_SLEEP_TIMEOUT		10	/* ms */

static const unsigned int a6xx_rgmu_registers[] = {
	/* GMU CX */
	0x1F80F, 0x1F83D, 0x1F840, 0x1F8D8, 0x1F990, 0x1F99E, 0x1F9C0, 0x1F9CC,
	/* GMU AO */
	0x23B03, 0x23B16, 0x23B80, 0x23B82,
	/* GPU CC */
	0x24000, 0x24012, 0x24040, 0x24052, 0x24400, 0x24404, 0x24407, 0x2440B,
	0x24415, 0x2441C, 0x2441E, 0x2442D, 0x2443C, 0x2443D, 0x2443F, 0x24440,
	0x24442, 0x24449, 0x24458, 0x2445A, 0x24540, 0x2455E, 0x24800, 0x24802,
	0x24C00, 0x24C02, 0x25400, 0x25402, 0x25800, 0x25802, 0x25C00, 0x25C02,
	0x26000, 0x26002,
};


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_rgmu.c:26 [MATCH: timeout] ---
#include "adreno_a6xx.h"
#include "adreno_a6xx_rgmu.h"
#include "adreno_snapshot.h"
#include "kgsl_bus.h"
#include "kgsl_trace.h"
#include "kgsl_util.h"

#define RGMU_CLK_FREQ 200000000

/* RGMU timeouts */
#define RGMU_IDLE_TIMEOUT		100	/* ms */
#define RGMU_START_TIMEOUT		100	/* ms */
#define GPU_START_TIMEOUT		100	/* ms */
#define GLM_SLEEP_TIMEOUT		10	/* ms */

static const unsigned int a6xx_rgmu_registers[] = {
	/* GMU CX */
	0x1F80F, 0x1F83D, 0x1F840, 0x1F8D8, 0x1F990, 0x1F99E, 0x1F9C0, 0x1F9CC,
	/* GMU AO */
	0x23B03, 0x23B16, 0x23B80, 0x23B82,
	/* GPU CC */
	0x24000, 0x24012, 0x24040, 0x24052, 0x24400, 0x24404, 0x24407, 0x2440B,
	0x24415, 0x2441C, 0x2441E, 0x2442D, 0x2443C, 0x2443D, 0x2443F, 0x24440,
	0x24442, 0x24449, 0x24458, 0x2445A, 0x24540, 0x2455E, 0x24800, 0x24802,
	0x24C00, 0x24C02, 0x25400, 0x25402, 0x25800, 0x25802, 0x25C00, 0x25C02,
	0x26000, 0x26002,
};

static struct a6xx_rgmu_device *to_a6xx_rgmu(struct adreno_device *adreno_dev)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_rgmu.c:28 [MATCH: timeout] ---
#include "adreno_snapshot.h"
#include "kgsl_bus.h"
#include "kgsl_trace.h"
#include "kgsl_util.h"

#define RGMU_CLK_FREQ 200000000

/* RGMU timeouts */
#define RGMU_IDLE_TIMEOUT		100	/* ms */
#define RGMU_START_TIMEOUT		100	/* ms */
#define GPU_START_TIMEOUT		100	/* ms */
#define GLM_SLEEP_TIMEOUT		10	/* ms */

static const unsigned int a6xx_rgmu_registers[] = {
	/* GMU CX */
	0x1F80F, 0x1F83D, 0x1F840, 0x1F8D8, 0x1F990, 0x1F99E, 0x1F9C0, 0x1F9CC,
	/* GMU AO */
	0x23B03, 0x23B16, 0x23B80, 0x23B82,
	/* GPU CC */
	0x24000, 0x24012, 0x24040, 0x24052, 0x24400, 0x24404, 0x24407, 0x2440B,
	0x24415, 0x2441C, 0x2441E, 0x2442D, 0x2443C, 0x2443D, 0x2443F, 0x24440,
	0x24442, 0x24449, 0x24458, 0x2445A, 0x24540, 0x2455E, 0x24800, 0x24802,
	0x24C00, 0x24C02, 0x25400, 0x25402, 0x25800, 0x25802, 0x25C00, 0x25C02,
	0x26000, 0x26002,
};

static struct a6xx_rgmu_device *to_a6xx_rgmu(struct adreno_device *adreno_dev)
{
	struct a6xx_device *a6xx_dev = container_of(adreno_dev,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_rgmu.c:29 [MATCH: timeout] ---
#include "kgsl_bus.h"
#include "kgsl_trace.h"
#include "kgsl_util.h"

#define RGMU_CLK_FREQ 200000000

/* RGMU timeouts */
#define RGMU_IDLE_TIMEOUT		100	/* ms */
#define RGMU_START_TIMEOUT		100	/* ms */
#define GPU_START_TIMEOUT		100	/* ms */
#define GLM_SLEEP_TIMEOUT		10	/* ms */

static const unsigned int a6xx_rgmu_registers[] = {
	/* GMU CX */
	0x1F80F, 0x1F83D, 0x1F840, 0x1F8D8, 0x1F990, 0x1F99E, 0x1F9C0, 0x1F9CC,
	/* GMU AO */
	0x23B03, 0x23B16, 0x23B80, 0x23B82,
	/* GPU CC */
	0x24000, 0x24012, 0x24040, 0x24052, 0x24400, 0x24404, 0x24407, 0x2440B,
	0x24415, 0x2441C, 0x2441E, 0x2442D, 0x2443C, 0x2443D, 0x2443F, 0x24440,
	0x24442, 0x24449, 0x24458, 0x2445A, 0x24540, 0x2455E, 0x24800, 0x24802,
	0x24C00, 0x24C02, 0x25400, 0x25402, 0x25800, 0x25802, 0x25C00, 0x25C02,
	0x26000, 0x26002,
};

static struct a6xx_rgmu_device *to_a6xx_rgmu(struct adreno_device *adreno_dev)
{
	struct a6xx_device *a6xx_dev = container_of(adreno_dev,
					struct a6xx_device, adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_rgmu.c:135 [MATCH: timeout] ---
		return 0;

	set = BIT(req + 16);
	check = BIT(req + 16);

	gmu_core_regwrite(device, A6XX_GMU_HOST2GMU_INTR_SET, set);

	ret = gmu_core_timed_poll_check(device,
			A6XX_GMU_GMU2HOST_INTR_INFO,
			check,
			GPU_START_TIMEOUT,
			check);

	if (ret) {
		unsigned int status;

		if (req == oob_perfcntr)
			rgmu->num_oob_perfcntr--;
		gmu_core_regread(device, A6XX_RGMU_CX_PCC_DEBUG, &status);
		dev_err(&rgmu->pdev->dev,
				"Timed out while setting OOB req:%s status:0x%x\n",
				oob_to_str(req), status);
		gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
		return ret;
	}

	gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_CLR, check);
	trace_kgsl_gmu_oob_set(set);
	return 0;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_rgmu.c:189 [MATCH: timeout] ---
		gmu_core_regwrite(device,
				A6XX_GMU_AO_RGMU_GLM_HW_CRC_DISABLE, 0);
	} else {
		/* Disable CRC HW i/f */
		gmu_core_regwrite(device,
				A6XX_GMU_AO_RGMU_GLM_HW_CRC_DISABLE, 1);

		/* Wait for HW CRC disable ACK */
		if (gmu_core_timed_poll_check(device,
				A6XX_GMU_AO_RGMU_GLM_SLEEP_STATUS,
				BIT(1), GLM_SLEEP_TIMEOUT, BIT(1)))
			dev_err_ratelimited(&rgmu->pdev->dev,
				"Timed out waiting for HW CRC disable acknowledgment\n");

		/* Pull down the valid RGMU_GLM_SLEEP_CTRL[7] to 0 */
		gmu_core_regrmw(device, A6XX_GMU_AO_RGMU_GLM_SLEEP_CTRL,
				BIT(7), 0);

	}
}

static void a6xx_rgmu_irq_enable(struct adreno_device *adreno_dev)
{
	struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	/* Clear pending IRQs and Unmask needed IRQs */
	gmu_core_regwrite(device, A6XX_GMU_GMU2HOST_INTR_CLR, 0xffffffff);
	gmu_core_regwrite(device, A6XX_GMU_AO_HOST_INTERRUPT_CLR, 0xffffffff);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_rgmu.c:296 [MATCH: timeout] ---
	struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
	unsigned int reg[10] = {0};
	unsigned long t;
	uint64_t ts1, ts2, ts3;

	if (rgmu->idle_level != GPU_HW_IFPC)
		return 0;

	ts1 = a6xx_read_alwayson(adreno_dev);

	/* FIXME: readl_poll_timeout? */
	t = jiffies + msecs_to_jiffies(RGMU_IDLE_TIMEOUT);
	do {
		gmu_core_regread(device,
			A6XX_GMU_SPTPRAC_PWR_CLK_STATUS, &reg[0]);

		if (reg[0] & GX_GDSC_POWER_OFF)
			return 0;

		/* Wait 10us to reduce unnecessary AHB bus traffic */
		usleep_range(10, 100);
	} while (!time_after(jiffies, t));

	ts2 = a6xx_read_alwayson(adreno_dev);

	/* Do one last read incase it succeeds */
	gmu_core_regread(device,
		A6XX_GMU_SPTPRAC_PWR_CLK_STATUS, &reg[0]);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_rgmu.c:297 [MATCH: timeout] ---
	unsigned int reg[10] = {0};
	unsigned long t;
	uint64_t ts1, ts2, ts3;

	if (rgmu->idle_level != GPU_HW_IFPC)
		return 0;

	ts1 = a6xx_read_alwayson(adreno_dev);

	/* FIXME: readl_poll_timeout? */
	t = jiffies + msecs_to_jiffies(RGMU_IDLE_TIMEOUT);
	do {
		gmu_core_regread(device,
			A6XX_GMU_SPTPRAC_PWR_CLK_STATUS, &reg[0]);

		if (reg[0] & GX_GDSC_POWER_OFF)
			return 0;

		/* Wait 10us to reduce unnecessary AHB bus traffic */
		usleep_range(10, 100);
	} while (!time_after(jiffies, t));

	ts2 = a6xx_read_alwayson(adreno_dev);

	/* Do one last read incase it succeeds */
	gmu_core_regread(device,
		A6XX_GMU_SPTPRAC_PWR_CLK_STATUS, &reg[0]);

	if (reg[0] & GX_GDSC_POWER_OFF)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_rgmu.c:333 [MATCH: timeout] ---
	gmu_core_regread(device, A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS, &reg[3]);
	kgsl_regread(device, A6XX_CP_STATUS_1, &reg[4]);
	gmu_core_regread(device, A6XX_GMU_RBBM_INT_UNMASKED_STATUS, &reg[5]);
	gmu_core_regread(device, A6XX_GMU_GMU_PWR_COL_KEEPALIVE, &reg[6]);
	kgsl_regread(device, A6XX_CP_CP2GMU_STATUS, &reg[7]);
	kgsl_regread(device, A6XX_CP_CONTEXT_SWITCH_CNTL, &reg[8]);
	gmu_core_regread(device, A6XX_GMU_AO_SPARE_CNTL, &reg[9]);

	dev_err(&rgmu->pdev->dev,
		"----------------------[ RGMU error ]----------------------\n");
	dev_err(&rgmu->pdev->dev, "Timeout waiting for lowest idle level\n");
	dev_err(&rgmu->pdev->dev,
			"Timestamps: %llx %llx %llx\n", ts1, ts2, ts3);
	dev_err(&rgmu->pdev->dev,
			"SPTPRAC_PWR_CLK_STATUS=%x PCC_DEBUG=%x PCC_STATUS=%x\n",
			reg[0], reg[1], reg[2]);
	dev_err(&rgmu->pdev->dev,
			"CX_BUSY_STATUS=%x CP_STATUS_1=%x\n", reg[3], reg[4]);
	dev_err(&rgmu->pdev->dev,
			"RBBM_INT_UNMASKED_STATUS=%x PWR_COL_KEEPALIVE=%x\n",
			reg[5], reg[6]);
	dev_err(&rgmu->pdev->dev,
			"CP2GMU_STATUS=%x CONTEXT_SWITCH_CNTL=%x AO_SPARE_CNTL=%x\n",
			reg[7], reg[8], reg[9]);

	WARN_ON(1);
	gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
	return -ETIMEDOUT;
}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_rgmu.c:968 [MATCH: timeout] ---

	set_bit(RGMU_PRIV_GPU_STARTED, &rgmu->flags);

	device->pwrctrl.last_stat_updated = ktime_get();

	kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE);

done:
	/*
	 * When waking up from a touch event we want to stay active long enough
	 * for the user to send a draw command.  The default idle timer timeout
	 * is shorter than we want so go ahead and push the idle timer out
	 * further for this special case
	 */
	mod_timer(&device->idle_timer, jiffies +
			msecs_to_jiffies(adreno_wake_timeout));

}

static int a6xx_first_boot(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
	int ret;

	if (test_bit(RGMU_PRIV_FIRST_BOOT_DONE, &rgmu->flags)) {
		if (!test_bit(RGMU_PRIV_GPU_STARTED, &rgmu->flags))
			return a6xx_boot(adreno_dev);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_rgmu.c:973 [MATCH: timeout] ---
	kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE);

done:
	/*
	 * When waking up from a touch event we want to stay active long enough
	 * for the user to send a draw command.  The default idle timer timeout
	 * is shorter than we want so go ahead and push the idle timer out
	 * further for this special case
	 */
	mod_timer(&device->idle_timer, jiffies +
			msecs_to_jiffies(adreno_wake_timeout));

}

static int a6xx_first_boot(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
	int ret;

	if (test_bit(RGMU_PRIV_FIRST_BOOT_DONE, &rgmu->flags)) {
		if (!test_bit(RGMU_PRIV_GPU_STARTED, &rgmu->flags))
			return a6xx_boot(adreno_dev);

		return 0;
	}

	ret = a6xx_ringbuffer_init(adreno_dev);
	if (ret)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_rgmu.c:1031 [MATCH: results] ---
	set_bit(RGMU_PRIV_GPU_STARTED, &rgmu->flags);

	/*
	 * There is a possible deadlock scenario during kgsl firmware reading
	 * (firmware_request_nowarn) and devfreq update calls. During first boot, kgsl
	 * device mutex is held and then firmware_request_nowarn is called for reading
	 * firmware. firmware_request_nowarn internally takes dev_pm_qos_mtx lock.
	 * Whereas in case of devfreq update calls triggered by thermal/bcl or
	 * devfreq sysfs, it first takes the same dev_pm_qos_mtx lock and then
	 * tries to take kgsl device mutex as part of get_dev_status/target
	 * calls. This results in deadlock when both thread are unable to acquire
	 * the mutex held by other thread. Enable devfreq updates now as we are
	 * done reading all firmware files.
	 */
	device->pwrscale.devfreq_enabled = true;

	device->pwrctrl.last_stat_updated = ktime_get();

	set_bit(ADRENO_DEVICE_FIRST_BOOT_DONE, &adreno_dev->priv);

	kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE);

	return 0;
}

static int a6xx_rgmu_first_open(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int ret;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_rgmu.c:855 [MATCH: mutex_lock] ---
static int a6xx_power_off(struct adreno_device *adreno_dev);

static void rgmu_idle_check(struct work_struct *work)
{
	struct kgsl_device *device = container_of(work,
					struct kgsl_device, idle_check_ws);
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
	int ret;

	kgsl_mutex_lock(&device->mutex);

	if (test_bit(GMU_DISABLE_SLUMBER, &device->gmu_core.flags))
		goto done;

	if (atomic_read(&device->active_cnt) || time_is_after_jiffies(device->idle_jiffies)) {
		kgsl_pwrscale_update(device);
		goto done;
	}

	if (!test_bit(RGMU_PRIV_GPU_STARTED, &rgmu->flags))
		goto done;

	spin_lock(&device->submit_lock);

	if (device->submit_now) {
		spin_unlock(&device->submit_lock);
		kgsl_pwrscale_update(device);
		kgsl_start_idle_timer(device);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_rgmu.c:887 [MATCH: mutex_unlock] ---
	device->skip_inline_submit = true;
	spin_unlock(&device->submit_lock);

	ret = a6xx_power_off(adreno_dev);
	if (ret == -EBUSY) {
		kgsl_pwrscale_update(device);
		kgsl_start_idle_timer(device);
	}

done:
	kgsl_mutex_unlock(&device->mutex);
}

static void rgmu_idle_timer(struct timer_list *t)
{
	struct kgsl_device *device = container_of(t, struct kgsl_device,
					idle_timer);

	kgsl_schedule_work(&device->idle_check_ws);
}

static int a6xx_boot(struct adreno_device *adreno_dev)
{
	struct a6xx_rgmu_device *rgmu = to_a6xx_rgmu(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int ret;

	if (WARN_ON(test_bit(RGMU_PRIV_GPU_STARTED, &rgmu->flags)))
		return 0;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_rgmu.c:868 [MATCH: spin_lock] ---
		goto done;

	if (atomic_read(&device->active_cnt) || time_is_after_jiffies(device->idle_jiffies)) {
		kgsl_pwrscale_update(device);
		goto done;
	}

	if (!test_bit(RGMU_PRIV_GPU_STARTED, &rgmu->flags))
		goto done;

	spin_lock(&device->submit_lock);

	if (device->submit_now) {
		spin_unlock(&device->submit_lock);
		kgsl_pwrscale_update(device);
		kgsl_start_idle_timer(device);
		goto done;
	}

	device->skip_inline_submit = true;
	spin_unlock(&device->submit_lock);

	ret = a6xx_power_off(adreno_dev);
	if (ret == -EBUSY) {
		kgsl_pwrscale_update(device);
		kgsl_start_idle_timer(device);
	}

done:

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_rgmu.c:871 [MATCH: spin_unlock] ---
		kgsl_pwrscale_update(device);
		goto done;
	}

	if (!test_bit(RGMU_PRIV_GPU_STARTED, &rgmu->flags))
		goto done;

	spin_lock(&device->submit_lock);

	if (device->submit_now) {
		spin_unlock(&device->submit_lock);
		kgsl_pwrscale_update(device);
		kgsl_start_idle_timer(device);
		goto done;
	}

	device->skip_inline_submit = true;
	spin_unlock(&device->submit_lock);

	ret = a6xx_power_off(adreno_dev);
	if (ret == -EBUSY) {
		kgsl_pwrscale_update(device);
		kgsl_start_idle_timer(device);
	}

done:
	kgsl_mutex_unlock(&device->mutex);
}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_rgmu.c:878 [MATCH: spin_unlock] ---
	spin_lock(&device->submit_lock);

	if (device->submit_now) {
		spin_unlock(&device->submit_lock);
		kgsl_pwrscale_update(device);
		kgsl_start_idle_timer(device);
		goto done;
	}

	device->skip_inline_submit = true;
	spin_unlock(&device->submit_lock);

	ret = a6xx_power_off(adreno_dev);
	if (ret == -EBUSY) {
		kgsl_pwrscale_update(device);
		kgsl_start_idle_timer(device);
	}

done:
	kgsl_mutex_unlock(&device->mutex);
}

static void rgmu_idle_timer(struct timer_list *t)
{
	struct kgsl_device *device = container_of(t, struct kgsl_device,
					idle_timer);

	kgsl_schedule_work(&device->idle_check_ws);
}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_ringbuffer.c:148 [MATCH: spin_lock] ---
		if (IS_ERR(cmds))
			return PTR_ERR(cmds);

		cmds[0] = cp_type7_packet(CP_WHERE_AM_I, 2);
		cmds[1] = lower_32_bits(SCRATCH_RB_GPU_ADDR(device, rb->id,
				rptr));
		cmds[2] = upper_32_bits(SCRATCH_RB_GPU_ADDR(device, rb->id,
				rptr));
	}

	spin_lock_irqsave(&rb->preempt_lock, flags);
	if (adreno_in_preempt_state(adreno_dev, ADRENO_PREEMPT_NONE)) {
		if (adreno_dev->cur_rb == rb) {
			ret = a6xx_fenced_write(adreno_dev,
				A6XX_CP_RB_WPTR, rb->_wptr,
				FENCE_STATUS_WRITEDROPPED0_MASK);
			rb->skip_inline_wptr = false;
		}
	} else {
		if (adreno_dev->cur_rb == rb)
			rb->skip_inline_wptr = true;
	}

	rb->wptr = rb->_wptr;
	spin_unlock_irqrestore(&rb->preempt_lock, flags);

	if (ret) {
		/*
		 * If WPTR update fails, take inline snapshot and trigger

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_ringbuffer.c:162 [MATCH: spin_unlock] ---
				A6XX_CP_RB_WPTR, rb->_wptr,
				FENCE_STATUS_WRITEDROPPED0_MASK);
			rb->skip_inline_wptr = false;
		}
	} else {
		if (adreno_dev->cur_rb == rb)
			rb->skip_inline_wptr = true;
	}

	rb->wptr = rb->_wptr;
	spin_unlock_irqrestore(&rb->preempt_lock, flags);

	if (ret) {
		/*
		 * If WPTR update fails, take inline snapshot and trigger
		 * recovery.
		 */
		gmu_core_fault_snapshot(device, GMU_FAULT_PANIC_NONE);
		adreno_scheduler_fault(adreno_dev,
			ADRENO_GMU_FAULT_SKIP_SNAPSHOT);
	}

	return ret;
}

int a6xx_ringbuffer_init(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int i, ret;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_snapshot.c:1563 [MATCH: timeout] ---
				KGSL_SNAPSHOT_SECTION_DEBUGBUS,
				snapshot,
				a6xx_snapshot_cx_dbgc_debugbus_block,
				(void *) &a6xx_vbif_debugbus_blocks);
	}
}

static void _a6xx_do_crashdump(struct kgsl_device *device)
{
	u32 val = 0;
	ktime_t timeout;

	crash_dump_valid = false;

	if (!device->snapshot_crashdumper)
		return;

	if (IS_ERR_OR_NULL(a6xx_capturescript) ||
		IS_ERR_OR_NULL(a6xx_crashdump_registers))
		return;

	/* IF the SMMU is stalled we cannot do a crash dump */
	if (adreno_smmu_is_stalled(ADRENO_DEVICE(device)))
		return;

	/* Turn on APRIV for legacy targets so we can access the buffers */
	if (!ADRENO_FEATURE(ADRENO_DEVICE(device), ADRENO_APRIV))
		kgsl_regwrite(device, A6XX_CP_MISC_CNTL, 1);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_snapshot.c:1588 [MATCH: timeout] ---
	/* Turn on APRIV for legacy targets so we can access the buffers */
	if (!ADRENO_FEATURE(ADRENO_DEVICE(device), ADRENO_APRIV))
		kgsl_regwrite(device, A6XX_CP_MISC_CNTL, 1);

	kgsl_regwrite(device, A6XX_CP_CRASH_SCRIPT_BASE_LO,
			lower_32_bits(a6xx_capturescript->gpuaddr));
	kgsl_regwrite(device, A6XX_CP_CRASH_SCRIPT_BASE_HI,
			upper_32_bits(a6xx_capturescript->gpuaddr));
	kgsl_regwrite(device, A6XX_CP_CRASH_DUMP_CNTL, 1);

	timeout = ktime_add_ms(ktime_get(), CP_CRASH_DUMPER_TIMEOUT);

	if (!device->snapshot_atomic)
		might_sleep();

	for (;;) {
		/* make sure we're reading the latest value */
		rmb();
		if ((*a6xx_cd_reg_end) != 0xaaaaaaaa)
			break;

		if (ktime_compare(ktime_get(), timeout) > 0)
			break;

		/* Wait 1msec to avoid unnecessary looping */
		if (!device->snapshot_atomic)
			usleep_range(100, 1000);
	}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_a6xx_snapshot.c:1599 [MATCH: timeout] ---

	if (!device->snapshot_atomic)
		might_sleep();

	for (;;) {
		/* make sure we're reading the latest value */
		rmb();
		if ((*a6xx_cd_reg_end) != 0xaaaaaaaa)
			break;

		if (ktime_compare(ktime_get(), timeout) > 0)
			break;

		/* Wait 1msec to avoid unnecessary looping */
		if (!device->snapshot_atomic)
			usleep_range(100, 1000);
	}

	kgsl_regread(device, A6XX_CP_CRASH_DUMP_STATUS, &val);

	if (!ADRENO_FEATURE(ADRENO_DEVICE(device), ADRENO_APRIV))
		kgsl_regwrite(device, A6XX_CP_MISC_CNTL, 0);

	if (!(val & 0x2)) {
		dev_err(device->dev, "Crash dump timed out: 0x%X\n", val);
		return;
	}

	crash_dump_valid = true;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_coresight.c:30 [MATCH: mutex_lock] ---

ssize_t adreno_coresight_show_register(struct device *dev,
		struct device_attribute *attr, char *buf)
{
	struct adreno_coresight_device *adreno_csdev = dev_get_drvdata(dev);
	struct adreno_coresight_attr *cattr = TO_ADRENO_CORESIGHT_ATTR(attr);
	struct kgsl_device *device = adreno_csdev->device;
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	unsigned int val = 0;

	kgsl_mutex_lock(&device->mutex);
	/*
	 * Return the current value of the register if coresight is enabled,
	 * otherwise report 0
	 */

	if (!adreno_csdev->enabled)
		goto out;

	if (!adreno_active_count_get(adreno_dev)) {
		kgsl_regread(device, cattr->reg->offset, &cattr->reg->value);
		adreno_active_count_put(adreno_dev);
	}
	val = cattr->reg->value;

out:
	kgsl_mutex_unlock(&device->mutex);
	return scnprintf(buf, PAGE_SIZE, "0x%X\n", val);
}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_coresight.c:65 [MATCH: mutex_lock] ---
	struct adreno_coresight_device *adreno_csdev = dev_get_drvdata(dev);
	struct kgsl_device *device = adreno_csdev->device;
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	unsigned long val;
	int ret;

	ret = kstrtoul(buf, 0, &val);
	if (ret)
		return ret;

	kgsl_mutex_lock(&device->mutex);
	/* Ignore writes while coresight is off */
	if (!adreno_csdev->enabled) {
		kgsl_mutex_unlock(&device->mutex);
		return size;
	}
	adreno_dev->patch_reglist = false;
	kgsl_mutex_unlock(&device->mutex);

	adreno_power_cycle_u32(adreno_dev, &cattr->reg->value, val);
	return size;
}

/*
 * This is a generic function to disable coresight debug bus on Adreno
 * devices. This function in turn calls the device specific function
 * through the gpudev hook.
 */
static void adreno_coresight_disable(struct coresight_device *csdev,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_coresight.c:92 [MATCH: mutex_lock] ---
 */
static void adreno_coresight_disable(struct coresight_device *csdev,
					struct perf_event *event)
{
	struct adreno_coresight_device *adreno_csdev = dev_get_drvdata(&csdev->dev);
	struct kgsl_device *device = adreno_csdev->device;
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	const struct adreno_coresight *coresight = adreno_csdev->coresight;
	int i;

	kgsl_mutex_lock(&device->mutex);

	if (!adreno_csdev->enabled) {
		kgsl_mutex_unlock(&device->mutex);
		return;
	}

	adreno_dev->coresight_en_cnt--;

	/* GMU takes care of DBGC interrupt mask for HWSCHED */
	if (!adreno_dev->coresight_en_cnt) {
		if (adreno_dev->hwsched_enabled)
			gmu_core_set_vrb_register(device->gmu_core.vrb,
				VRB_DBGC_FAULT_ENABLE, 0);
		else
			adreno_dev->irq_mask &= ~ADRENO_DEBUG_BUS_INT_MASK;
	}

	if (!adreno_active_count_get(adreno_dev)) {

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_coresight.c:185 [MATCH: mutex_lock] ---
/* Generic function to enable coresight debug bus on adreno devices */
static int _adreno_coresight_enable(struct coresight_device *csdev,
				struct perf_event *event, u32 mode)
{
	struct adreno_coresight_device *adreno_csdev = dev_get_drvdata(&csdev->dev);
	const struct adreno_coresight *coresight = adreno_csdev->coresight;
	struct kgsl_device *device = adreno_csdev->device;
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	int ret = 0;

	kgsl_mutex_lock(&device->mutex);
	if (!adreno_csdev->enabled) {
		int i;

		adreno_csdev->enabled = true;

		/* Reset all the debug registers to their default values */
		for (i = 0; i < coresight->count; i++)
			coresight->registers[i].value =
				coresight->registers[i].initial;

		adreno_dev->coresight_en_cnt++;

		/* GMU takes care of DBGC interrupt mask for HWSCHED */
		if (adreno_dev->coresight_en_cnt == 1) {
			if (adreno_dev->hwsched_enabled)
				gmu_core_set_vrb_register(device->gmu_core.vrb,
					VRB_DBGC_FAULT_ENABLE, 1);
			else

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_coresight.c:289 [MATCH: mutex_lock] ---
		struct coresight_connection *outport)
#endif
{
	struct kgsl_device *device = kgsl_get_device(0);
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	int ret;

	if (!device)
		return -ENODEV;

	kgsl_mutex_lock(&device->mutex);

	ret = adreno_active_count_get(adreno_dev);
	if (ret)
		goto err;

	/* Now that GPU is up, Call into coresight driver to enable funnel */
	ret = adreno_dev->funnel_gfx.funnel_ops->link_ops->enable(csdev, inport, outport);

	adreno_active_count_put(adreno_dev);
err:
	kgsl_mutex_unlock(&device->mutex);
	return ret;
}

#if (KERNEL_VERSION(6, 4, 0) >= LINUX_VERSION_CODE)
static void funnel_gfx_disable(struct coresight_device *csdev, int inport,
			   int outport)
#else

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_coresight.c:319 [MATCH: mutex_lock] ---
		struct coresight_connection *outport)
#endif
{
	struct kgsl_device *device = kgsl_get_device(0);
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	int ret;

	if (!device)
		return;

	kgsl_mutex_lock(&device->mutex);

	ret = adreno_active_count_get(adreno_dev);
	if (ret)
		goto err;

	/* Now that GPU is up, Call into coresight driver to disable funnel */
	adreno_dev->funnel_gfx.funnel_ops->link_ops->disable(csdev, inport, outport);

	adreno_active_count_put(adreno_dev);
err:
	kgsl_mutex_unlock(&device->mutex);
}

struct coresight_ops_link funnel_link_gfx_ops = {
	.enable = funnel_gfx_enable,
	.disable = funnel_gfx_disable,
};


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_coresight.c:46 [MATCH: mutex_unlock] ---
	if (!adreno_csdev->enabled)
		goto out;

	if (!adreno_active_count_get(adreno_dev)) {
		kgsl_regread(device, cattr->reg->offset, &cattr->reg->value);
		adreno_active_count_put(adreno_dev);
	}
	val = cattr->reg->value;

out:
	kgsl_mutex_unlock(&device->mutex);
	return scnprintf(buf, PAGE_SIZE, "0x%X\n", val);
}

ssize_t adreno_coresight_store_register(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t size)
{

	struct adreno_coresight_attr *cattr = TO_ADRENO_CORESIGHT_ATTR(attr);
	struct adreno_coresight_device *adreno_csdev = dev_get_drvdata(dev);
	struct kgsl_device *device = adreno_csdev->device;
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	unsigned long val;
	int ret;

	ret = kstrtoul(buf, 0, &val);
	if (ret)
		return ret;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_coresight.c:68 [MATCH: mutex_unlock] ---
	unsigned long val;
	int ret;

	ret = kstrtoul(buf, 0, &val);
	if (ret)
		return ret;

	kgsl_mutex_lock(&device->mutex);
	/* Ignore writes while coresight is off */
	if (!adreno_csdev->enabled) {
		kgsl_mutex_unlock(&device->mutex);
		return size;
	}
	adreno_dev->patch_reglist = false;
	kgsl_mutex_unlock(&device->mutex);

	adreno_power_cycle_u32(adreno_dev, &cattr->reg->value, val);
	return size;
}

/*
 * This is a generic function to disable coresight debug bus on Adreno
 * devices. This function in turn calls the device specific function
 * through the gpudev hook.
 */
static void adreno_coresight_disable(struct coresight_device *csdev,
					struct perf_event *event)
{
	struct adreno_coresight_device *adreno_csdev = dev_get_drvdata(&csdev->dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_coresight.c:72 [MATCH: mutex_unlock] ---
	if (ret)
		return ret;

	kgsl_mutex_lock(&device->mutex);
	/* Ignore writes while coresight is off */
	if (!adreno_csdev->enabled) {
		kgsl_mutex_unlock(&device->mutex);
		return size;
	}
	adreno_dev->patch_reglist = false;
	kgsl_mutex_unlock(&device->mutex);

	adreno_power_cycle_u32(adreno_dev, &cattr->reg->value, val);
	return size;
}

/*
 * This is a generic function to disable coresight debug bus on Adreno
 * devices. This function in turn calls the device specific function
 * through the gpudev hook.
 */
static void adreno_coresight_disable(struct coresight_device *csdev,
					struct perf_event *event)
{
	struct adreno_coresight_device *adreno_csdev = dev_get_drvdata(&csdev->dev);
	struct kgsl_device *device = adreno_csdev->device;
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	const struct adreno_coresight *coresight = adreno_csdev->coresight;
	int i;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_coresight.c:95 [MATCH: mutex_unlock] ---
{
	struct adreno_coresight_device *adreno_csdev = dev_get_drvdata(&csdev->dev);
	struct kgsl_device *device = adreno_csdev->device;
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	const struct adreno_coresight *coresight = adreno_csdev->coresight;
	int i;

	kgsl_mutex_lock(&device->mutex);

	if (!adreno_csdev->enabled) {
		kgsl_mutex_unlock(&device->mutex);
		return;
	}

	adreno_dev->coresight_en_cnt--;

	/* GMU takes care of DBGC interrupt mask for HWSCHED */
	if (!adreno_dev->coresight_en_cnt) {
		if (adreno_dev->hwsched_enabled)
			gmu_core_set_vrb_register(device->gmu_core.vrb,
				VRB_DBGC_FAULT_ENABLE, 0);
		else
			adreno_dev->irq_mask &= ~ADRENO_DEBUG_BUS_INT_MASK;
	}

	if (!adreno_active_count_get(adreno_dev)) {
		for (i = 0; i < coresight->count; i++)
			kgsl_regwrite(device,
				coresight->registers[i].offset, 0);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_coresight.c:119 [MATCH: mutex_unlock] ---

	if (!adreno_active_count_get(adreno_dev)) {
		for (i = 0; i < coresight->count; i++)
			kgsl_regwrite(device,
				coresight->registers[i].offset, 0);
		adreno_active_count_put(adreno_dev);
	}

	adreno_csdev->enabled = false;

	kgsl_mutex_unlock(&device->mutex);
}

static void _adreno_coresight_get_and_clear(struct adreno_device *adreno_dev,
		struct adreno_coresight_device *adreno_csdev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	const struct adreno_coresight *coresight = adreno_csdev->coresight;
	int i;

	if (IS_ERR_OR_NULL(adreno_csdev->dev) || !adreno_csdev->enabled)
		return;

	/*
	 * Save the current value of each coresight register
	 * and then clear each register
	 */
	for (i = 0; i < coresight->count; i++) {
		kgsl_regread(device, coresight->registers[i].offset,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_coresight.c:214 [MATCH: mutex_unlock] ---
				adreno_dev->irq_mask |= ADRENO_DEBUG_BUS_INT_MASK;
		}

		ret = adreno_active_count_get(adreno_dev);
		if (!ret) {
			_adreno_coresight_set(adreno_dev, adreno_csdev);
			adreno_active_count_put(adreno_dev);
		}

	}
	kgsl_mutex_unlock(&device->mutex);
	return ret;
}

#if (KERNEL_VERSION(6, 4, 0) >= LINUX_VERSION_CODE)
static int adreno_coresight_enable(struct coresight_device *csdev,
				struct perf_event *event, u32 mode)
{
	return _adreno_coresight_enable(csdev, event, mode);
}
#else
static int adreno_coresight_enable(struct coresight_device *csdev,
				struct perf_event *event, enum cs_mode mode)
{
	return _adreno_coresight_enable(csdev, event, mode);
}
#endif

void adreno_coresight_stop(struct adreno_device *adreno_dev)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_coresight.c:300 [MATCH: mutex_unlock] ---

	ret = adreno_active_count_get(adreno_dev);
	if (ret)
		goto err;

	/* Now that GPU is up, Call into coresight driver to enable funnel */
	ret = adreno_dev->funnel_gfx.funnel_ops->link_ops->enable(csdev, inport, outport);

	adreno_active_count_put(adreno_dev);
err:
	kgsl_mutex_unlock(&device->mutex);
	return ret;
}

#if (KERNEL_VERSION(6, 4, 0) >= LINUX_VERSION_CODE)
static void funnel_gfx_disable(struct coresight_device *csdev, int inport,
			   int outport)
#else
static void funnel_gfx_disable(struct coresight_device *csdev, struct coresight_connection *inport,
		struct coresight_connection *outport)
#endif
{
	struct kgsl_device *device = kgsl_get_device(0);
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	int ret;

	if (!device)
		return;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_coresight.c:330 [MATCH: mutex_unlock] ---

	ret = adreno_active_count_get(adreno_dev);
	if (ret)
		goto err;

	/* Now that GPU is up, Call into coresight driver to disable funnel */
	adreno_dev->funnel_gfx.funnel_ops->link_ops->disable(csdev, inport, outport);

	adreno_active_count_put(adreno_dev);
err:
	kgsl_mutex_unlock(&device->mutex);
}

struct coresight_ops_link funnel_link_gfx_ops = {
	.enable = funnel_gfx_enable,
	.disable = funnel_gfx_disable,
};

struct coresight_ops funnel_gfx_ops = {
	.link_ops = &funnel_link_gfx_ops,
};

static void adreno_coresight_dev_probe(struct kgsl_device *device,
		const struct adreno_coresight *coresight,
		struct adreno_coresight_device *adreno_csdev,
		struct device_node *node)
{
	struct platform_device *pdev = of_find_device_by_node(node);
	struct coresight_desc desc;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_debugfs.c:177 [MATCH: mutex_lock] ---
	*val = (u64) adreno_dev->uche_client_pf;
	return 0;
}
DEFINE_DEBUGFS_ATTRIBUTE(_gpu_client_pf_fops, _gpu_client_pf_get,
				_gpu_client_pf_set, "%llu\n");

static int _prealloc_atomic_snap_mem_set(void *data, u64 val)
{
	struct kgsl_device *device = data;

	kgsl_mutex_lock(&device->mutex);

	/* Allocate atomic snapshot memory if it's not allocated yet */
	if (!val || device->snapshot_memory_atomic.ptr) {
		kgsl_mutex_unlock(&device->mutex);
		return 0;
	}

	device->snapshot_memory_atomic.size = device->snapshot_memory.size;

	/* Ensure size is visible to other threads before setting address */
	smp_wmb();

	device->snapshot_memory_atomic.ptr = dma_alloc_coherent(&device->pdev->dev,
		device->snapshot_memory_atomic.size, &device->snapshot_memory_atomic.dma_handle,
		GFP_KERNEL);

	if (WARN_ON((!device->snapshot_memory_atomic.ptr))) {
		/* Fallback to slab allocator if DMA allocation fails */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_debugfs.c:731 [MATCH: mutex_lock] ---
{
	struct adreno_device *adreno_dev = data;
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	/* Max allowed GMU fault settings are 9 bits */
	val = FIELD_GET(GENMASK(GMU_FAULT_MAX, 0), val);

	if (val == device->gmu_core.gf_panic)
		return 0;

	kgsl_mutex_lock(&device->mutex);
	device->gmu_core.gf_panic = val;
	kgsl_mutex_unlock(&device->mutex);

	return 0;
}

static int _gmu_fp_show(void *data, u64 *val)
{
	struct adreno_device *adreno_dev = data;

	*val = (u64) KGSL_DEVICE(adreno_dev)->gmu_core.gf_panic;
	return 0;
}

DEFINE_DEBUGFS_ATTRIBUTE(gmu_fp_fops, _gmu_fp_show, _gmu_fp_store, "%llu\n");

static void _toggle_host_based_dcvs(struct adreno_device *adreno_dev, void *priv)
{

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_debugfs.c:181 [MATCH: mutex_unlock] ---
				_gpu_client_pf_set, "%llu\n");

static int _prealloc_atomic_snap_mem_set(void *data, u64 val)
{
	struct kgsl_device *device = data;

	kgsl_mutex_lock(&device->mutex);

	/* Allocate atomic snapshot memory if it's not allocated yet */
	if (!val || device->snapshot_memory_atomic.ptr) {
		kgsl_mutex_unlock(&device->mutex);
		return 0;
	}

	device->snapshot_memory_atomic.size = device->snapshot_memory.size;

	/* Ensure size is visible to other threads before setting address */
	smp_wmb();

	device->snapshot_memory_atomic.ptr = dma_alloc_coherent(&device->pdev->dev,
		device->snapshot_memory_atomic.size, &device->snapshot_memory_atomic.dma_handle,
		GFP_KERNEL);

	if (WARN_ON((!device->snapshot_memory_atomic.ptr))) {
		/* Fallback to slab allocator if DMA allocation fails */
		device->snapshot_memory_atomic.size = (SZ_2M + SZ_1M);

		/* Ensure size is visible to other threads before setting address */
		smp_wmb();

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_debugfs.c:206 [MATCH: mutex_unlock] ---
		device->snapshot_memory_atomic.size = (SZ_2M + SZ_1M);

		/* Ensure size is visible to other threads before setting address */
		smp_wmb();

		device->snapshot_memory_atomic.ptr = devm_kzalloc(&device->pdev->dev,
			device->snapshot_memory_atomic.size, GFP_KERNEL);
	}

	if (!device->snapshot_memory_atomic.ptr) {
		kgsl_mutex_unlock(&device->mutex);
		dev_err(device->dev, "Failed to allocate memory for atomic snapshot\n");
		return -ENOMEM;
	}

	kgsl_mutex_unlock(&device->mutex);

	return 0;
}

static int _prealloc_atomic_snap_mem_get(void *data, u64 *val)
{
	struct kgsl_device *device = data;

	*val = device->snapshot_memory_atomic.ptr ? 1 : 0;
	return 0;
}

DEFINE_DEBUGFS_ATTRIBUTE(_prealloc_atomic_snapshot_mem_fops, _prealloc_atomic_snap_mem_get,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_debugfs.c:211 [MATCH: mutex_unlock] ---
		device->snapshot_memory_atomic.ptr = devm_kzalloc(&device->pdev->dev,
			device->snapshot_memory_atomic.size, GFP_KERNEL);
	}

	if (!device->snapshot_memory_atomic.ptr) {
		kgsl_mutex_unlock(&device->mutex);
		dev_err(device->dev, "Failed to allocate memory for atomic snapshot\n");
		return -ENOMEM;
	}

	kgsl_mutex_unlock(&device->mutex);

	return 0;
}

static int _prealloc_atomic_snap_mem_get(void *data, u64 *val)
{
	struct kgsl_device *device = data;

	*val = device->snapshot_memory_atomic.ptr ? 1 : 0;
	return 0;
}

DEFINE_DEBUGFS_ATTRIBUTE(_prealloc_atomic_snapshot_mem_fops, _prealloc_atomic_snap_mem_get,
				_prealloc_atomic_snap_mem_set, "%llu\n");

typedef void (*reg_read_init_t)(struct kgsl_device *device);
typedef void (*reg_read_fill_t)(struct kgsl_device *device, int i,
	unsigned int *vals, int linec);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_debugfs.c:733 [MATCH: mutex_unlock] ---
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	/* Max allowed GMU fault settings are 9 bits */
	val = FIELD_GET(GENMASK(GMU_FAULT_MAX, 0), val);

	if (val == device->gmu_core.gf_panic)
		return 0;

	kgsl_mutex_lock(&device->mutex);
	device->gmu_core.gf_panic = val;
	kgsl_mutex_unlock(&device->mutex);

	return 0;
}

static int _gmu_fp_show(void *data, u64 *val)
{
	struct adreno_device *adreno_dev = data;

	*val = (u64) KGSL_DEVICE(adreno_dev)->gmu_core.gf_panic;
	return 0;
}

DEFINE_DEBUGFS_ATTRIBUTE(gmu_fp_fops, _gmu_fp_show, _gmu_fp_store, "%llu\n");

static void _toggle_host_based_dcvs(struct adreno_device *adreno_dev, void *priv)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	bool val = *((bool *)priv);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_debugfs.c:398 [MATCH: spin_lock] ---
	kgsl_readtimestamp(drawctxt->base.device, &drawctxt->base,
				KGSL_TIMESTAMP_CONSUMED, &consumed);
	kgsl_readtimestamp(drawctxt->base.device, &drawctxt->base,
				KGSL_TIMESTAMP_RETIRED, &retired);
	seq_printf(s, "queued: %u consumed: %u retired: %u global:%u\n",
		   queued, consumed, retired,
		   drawctxt->internal_timestamp);

	seq_puts(s, "drawqueue:\n");

	spin_lock(&drawctxt->lock);
	for (i = drawctxt->drawqueue_head;
		i != drawctxt->drawqueue_tail;
		i = DRAWQUEUE_NEXT(i, ADRENO_CONTEXT_DRAWQUEUE_SIZE))
		drawobj_print(s, drawctxt->drawqueue[i]);
	spin_unlock(&drawctxt->lock);

	seq_puts(s, "events:\n");
	spin_lock(&drawctxt->base.events.lock);
	list_for_each_entry(event, &drawctxt->base.events.events, node)
		seq_printf(s, "\t%d: %pS created: %u\n", event->timestamp,
				event->func, event->created);
	spin_unlock(&drawctxt->base.events.lock);

	return 0;
}

static int ctx_open(struct inode *inode, struct file *file)
{

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_debugfs.c:406 [MATCH: spin_lock] ---
	seq_puts(s, "drawqueue:\n");

	spin_lock(&drawctxt->lock);
	for (i = drawctxt->drawqueue_head;
		i != drawctxt->drawqueue_tail;
		i = DRAWQUEUE_NEXT(i, ADRENO_CONTEXT_DRAWQUEUE_SIZE))
		drawobj_print(s, drawctxt->drawqueue[i]);
	spin_unlock(&drawctxt->lock);

	seq_puts(s, "events:\n");
	spin_lock(&drawctxt->base.events.lock);
	list_for_each_entry(event, &drawctxt->base.events.events, node)
		seq_printf(s, "\t%d: %pS created: %u\n", event->timestamp,
				event->func, event->created);
	spin_unlock(&drawctxt->base.events.lock);

	return 0;
}

static int ctx_open(struct inode *inode, struct file *file)
{
	int ret;
	struct adreno_context *ctx = inode->i_private;

	if (!_kgsl_context_get(&ctx->base))
		return -ENODEV;

	ret = single_open(file, ctx_print, &ctx->base);
	if (ret)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_debugfs.c:403 [MATCH: spin_unlock] ---
		   queued, consumed, retired,
		   drawctxt->internal_timestamp);

	seq_puts(s, "drawqueue:\n");

	spin_lock(&drawctxt->lock);
	for (i = drawctxt->drawqueue_head;
		i != drawctxt->drawqueue_tail;
		i = DRAWQUEUE_NEXT(i, ADRENO_CONTEXT_DRAWQUEUE_SIZE))
		drawobj_print(s, drawctxt->drawqueue[i]);
	spin_unlock(&drawctxt->lock);

	seq_puts(s, "events:\n");
	spin_lock(&drawctxt->base.events.lock);
	list_for_each_entry(event, &drawctxt->base.events.events, node)
		seq_printf(s, "\t%d: %pS created: %u\n", event->timestamp,
				event->func, event->created);
	spin_unlock(&drawctxt->base.events.lock);

	return 0;
}

static int ctx_open(struct inode *inode, struct file *file)
{
	int ret;
	struct adreno_context *ctx = inode->i_private;

	if (!_kgsl_context_get(&ctx->base))
		return -ENODEV;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_debugfs.c:410 [MATCH: spin_unlock] ---
		i != drawctxt->drawqueue_tail;
		i = DRAWQUEUE_NEXT(i, ADRENO_CONTEXT_DRAWQUEUE_SIZE))
		drawobj_print(s, drawctxt->drawqueue[i]);
	spin_unlock(&drawctxt->lock);

	seq_puts(s, "events:\n");
	spin_lock(&drawctxt->base.events.lock);
	list_for_each_entry(event, &drawctxt->base.events.events, node)
		seq_printf(s, "\t%d: %pS created: %u\n", event->timestamp,
				event->func, event->created);
	spin_unlock(&drawctxt->base.events.lock);

	return 0;
}

static int ctx_open(struct inode *inode, struct file *file)
{
	int ret;
	struct adreno_context *ctx = inode->i_private;

	if (!_kgsl_context_get(&ctx->base))
		return -ENODEV;

	ret = single_open(file, ctx_print, &ctx->base);
	if (ret)
		kgsl_context_put(&ctx->base);
	return ret;
}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1205 [MATCH: wait_for_completion] ---

	ret = kgsl_check_context_state(&drawctxt->base);
	if (ret)
		return ret;

	ret = adreno_verify_cmdobj(dev_priv, context, drawobj, count);
	if (ret)
		return ret;

	/* wait for the suspend gate */
	wait_for_completion(&device->halt_gate);

	job = kmem_cache_alloc(jobs_cache, GFP_KERNEL);
	if (!job)
		return -ENOMEM;

	job->drawctxt = drawctxt;

	spin_lock(&drawctxt->lock);

	ret = _check_context_state_to_queue_cmds(drawctxt, count);
	if (ret) {
		spin_unlock(&drawctxt->lock);
		kmem_cache_free(jobs_cache, job);
		return ret;
	}

	user_ts = *timestamp;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1908 [MATCH: wait_for_completion] ---
	 * Return early if there is a concurrent suspend in progress. The suspend thread will error
	 * out in the presence of this hwsched fault and requeue the dispatcher to handle this fault
	 */
	if (!mutex_trylock(&adreno_dev->fault_recovery_mutex))
		return 1;

	/*
	 * Wait long enough to allow the system to come out of suspend completely, which can take
	 * variable amount of time especially if it has to rewind suspend processes and devices.
	 */
	if (!wait_for_completion_timeout(&adreno_dev->suspend_recovery_gate,
			msecs_to_jiffies(ADRENO_SUSPEND_RECOVERY_GATE_TIMEOUT_MS))) {
		dev_err(device->dev, "suspend recovery gate timeout\n");
		adreno_scheduler_queue(adreno_dev);
		mutex_unlock(&adreno_dev->fault_recovery_mutex);
		return 1;
	}

	kgsl_mutex_lock(&device->mutex);

	/*
	 * In the very unlikely case that the power is off, do nothing - the
	 * state will be reset on power up and everybody will be happy
	 */
	if (!kgsl_state_is_awake(device)) {
		kgsl_mutex_unlock(&device->mutex);
		mutex_unlock(&adreno_dev->fault_recovery_mutex);
		return 0;
	}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2791 [MATCH: wait_for_completion] ---
	/*
	 * Flush the worker to make sure all executing
	 * or pending dispatcher works on worker are
	 * finished
	 */
	kthread_flush_worker(adreno_dev->scheduler_worker);

	if (adreno_gpu_fault(adreno_dev) != 0) {
		ret = -EDEADLK;
	} else {
		ret = wait_for_completion_timeout(&dispatcher->idle_gate,
				msecs_to_jiffies(ADRENO_IDLE_TIMEOUT));
		if (ret == 0) {
			ret = -ETIMEDOUT;
			WARN(1, "Dispatcher halt timeout\n");
		} else if (ret < 0) {
			dev_err(device->dev, "Dispatcher halt failed %d\n", ret);
		} else {
			ret = 0;
		}

		if (adreno_gpu_fault(adreno_dev) != 0)
			ret = -EDEADLK;
	}

	kgsl_mutex_lock(&device->mutex);
	adreno_put_gpu_halt(adreno_dev);
	/*
	 * requeue dispatcher work to resubmit pending commands

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2305 [MATCH: complete_all] ---

/* Take down the dispatcher and release any power states */
static void _dispatcher_power_down(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher;

	kgsl_mutex_lock(&device->mutex);

	if (test_and_clear_bit(ADRENO_DISPATCHER_ACTIVE, &dispatcher->priv))
		complete_all(&dispatcher->idle_gate);

	process_rt_bus_hint(device, false);

	if (test_bit(ADRENO_DISPATCHER_POWER, &dispatcher->priv)) {
		adreno_active_count_put(adreno_dev);
		clear_bit(ADRENO_DISPATCHER_POWER, &dispatcher->priv);
	}

	kgsl_mutex_unlock(&device->mutex);
}

static void adreno_dispatcher_work(struct kthread_work *work)
{
	struct adreno_device *adreno_dev =
		container_of(work, struct adreno_device, scheduler_work);
	struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher;
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2403 [MATCH: complete_all] ---
	adreno_scheduler_queue(adreno_dev);
}

/**
 * adreno_dispatcher_start() - activate the dispatcher
 * @adreno_dev: pointer to the adreno device structure
 *
 */
void adreno_dispatcher_start(struct kgsl_device *device)
{
	complete_all(&device->halt_gate);

	/* Schedule the work loop to get things going */
	adreno_scheduler_queue(ADRENO_DEVICE(device));
}

/**
 * adreno_dispatcher_stop() - stop the dispatcher
 * @adreno_dev: pointer to the adreno device structure
 *
 * Stop the dispatcher and close all the timers
 */
void adreno_dispatcher_stop(struct adreno_device *adreno_dev)
{
	struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher;

	kgsl_delete_timer_sync(&dispatcher->timer);
}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2733 [MATCH: complete_all] ---

	WARN_ON(sysfs_create_files(&device->dev->kobj, _dispatch_attr_list));

	mutex_init(&dispatcher->mutex);

	timer_setup(&dispatcher->timer, adreno_dispatcher_timer, 0);

	kthread_init_work(&adreno_dev->scheduler_work, adreno_dispatcher_work);

	init_completion(&dispatcher->idle_gate);
	complete_all(&dispatcher->idle_gate);

	jobs_cache = KMEM_CACHE(adreno_dispatch_job, 0);

	for (i = 0; i < ARRAY_SIZE(dispatcher->jobs); i++) {
		init_llist_head(&dispatcher->jobs[i]);
		init_llist_head(&dispatcher->requeue[i]);
	}

	adreno_set_dispatch_ops(adreno_dev, &swsched_ops);

	sched_set_fifo(adreno_dev->scheduler_worker->task);

	set_bit(ADRENO_DISPATCHER_INIT, &dispatcher->priv);

	return 0;
}

/*

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1010 [MATCH: wait_event] ---
	/*
	 * There is always a possibility that dispatcher may end up pushing
	 * the last popped draw object back to the context drawqueue. Hence,
	 * we can only queue up to _context_drawqueue_size - 1 here to make
	 * sure we never let drawqueue->queued exceed _context_drawqueue_size.
	 */
	if ((drawctxt->queued + count) > (_context_drawqueue_size - 1)) {
		trace_adreno_drawctxt_sleep(drawctxt);
		spin_unlock(&drawctxt->lock);

		ret = wait_event_interruptible_timeout(drawctxt->wq,
			_check_context_queue(drawctxt, count),
			msecs_to_jiffies(_context_queue_wait));

		spin_lock(&drawctxt->lock);
		trace_adreno_drawctxt_wake(drawctxt);

		/*
		 * Account for the possibility that the context got invalidated
		 * while we were sleeping
		 */
		if (ret > 0)
			ret = kgsl_check_context_state(&drawctxt->base);
		else if (ret == 0)
			ret = -ETIMEDOUT;
	}

	return ret;
}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:50 [MATCH: timeout] ---
 * should be sufficiently high to keep the GPU loaded
 */
static unsigned int _dispatcher_q_inflight_hi = 15;

/*
 * Minimum inflight for the multiple context case - this should sufficiently low
 * to allow for lower latency context switching
 */
static unsigned int _dispatcher_q_inflight_lo = 4;

/* Command batch timeout (in milliseconds) */
unsigned int adreno_drawobj_timeout = 2000;

/* Interval for reading and comparing fault detection registers */
static unsigned int _fault_timer_interval = 200;

/* Use a kmem cache to speed up allocations for dispatcher jobs */
static struct kmem_cache *jobs_cache;

#define DRAWQUEUE_RB(_drawqueue) \
	((struct adreno_ringbuffer *) \
		container_of((_drawqueue),\
		struct adreno_ringbuffer, dispatch_q))

#define DRAWQUEUE(_ringbuffer) (&(_ringbuffer)->dispatch_q)

static bool adreno_drawqueue_is_empty(struct adreno_dispatcher_drawqueue *drawqueue)
{
	return (drawqueue && drawqueue->head == drawqueue->tail);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:51 [MATCH: timeout] ---
 */
static unsigned int _dispatcher_q_inflight_hi = 15;

/*
 * Minimum inflight for the multiple context case - this should sufficiently low
 * to allow for lower latency context switching
 */
static unsigned int _dispatcher_q_inflight_lo = 4;

/* Command batch timeout (in milliseconds) */
unsigned int adreno_drawobj_timeout = 2000;

/* Interval for reading and comparing fault detection registers */
static unsigned int _fault_timer_interval = 200;

/* Use a kmem cache to speed up allocations for dispatcher jobs */
static struct kmem_cache *jobs_cache;

#define DRAWQUEUE_RB(_drawqueue) \
	((struct adreno_ringbuffer *) \
		container_of((_drawqueue),\
		struct adreno_ringbuffer, dispatch_q))

#define DRAWQUEUE(_ringbuffer) (&(_ringbuffer)->dispatch_q)

static bool adreno_drawqueue_is_empty(struct adreno_dispatcher_drawqueue *drawqueue)
{
	return (drawqueue && drawqueue->head == drawqueue->tail);
}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:237 [MATCH: timeout] ---
	if (!kgsl_drawobj_events_pending(syncobj)) {
		_pop_drawobj(drawctxt);
		kgsl_drawobj_destroy(drawobj);
		return 0;
	}

	/*
	 * If we got here, there are pending events for sync object.
	 * Start the canary timer if it hasnt been started already.
	 */
	if (!syncobj->timeout_jiffies) {
		syncobj->timeout_jiffies = jiffies + msecs_to_jiffies(5000);
			mod_timer(&syncobj->timer, syncobj->timeout_jiffies);
	}

	return -EAGAIN;
}

static int drawqueue_retire_timelineobj(struct kgsl_drawobj *drawobj,
		struct adreno_context *drawctxt)
{
	_pop_drawobj(drawctxt);
	kgsl_drawobj_destroy(drawobj);
	return 0;
}

static int drawqueue_retire_bindobj(struct kgsl_drawobj *drawobj,
		struct adreno_context *drawctxt)
{

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:238 [MATCH: timeout] ---
		_pop_drawobj(drawctxt);
		kgsl_drawobj_destroy(drawobj);
		return 0;
	}

	/*
	 * If we got here, there are pending events for sync object.
	 * Start the canary timer if it hasnt been started already.
	 */
	if (!syncobj->timeout_jiffies) {
		syncobj->timeout_jiffies = jiffies + msecs_to_jiffies(5000);
			mod_timer(&syncobj->timer, syncobj->timeout_jiffies);
	}

	return -EAGAIN;
}

static int drawqueue_retire_timelineobj(struct kgsl_drawobj *drawobj,
		struct adreno_context *drawctxt)
{
	_pop_drawobj(drawctxt);
	kgsl_drawobj_destroy(drawobj);
	return 0;
}

static int drawqueue_retire_bindobj(struct kgsl_drawobj *drawobj,
		struct adreno_context *drawctxt)
{
	struct kgsl_drawobj_bind *bindobj = BINDOBJ(drawobj);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:239 [MATCH: timeout] ---
		kgsl_drawobj_destroy(drawobj);
		return 0;
	}

	/*
	 * If we got here, there are pending events for sync object.
	 * Start the canary timer if it hasnt been started already.
	 */
	if (!syncobj->timeout_jiffies) {
		syncobj->timeout_jiffies = jiffies + msecs_to_jiffies(5000);
			mod_timer(&syncobj->timer, syncobj->timeout_jiffies);
	}

	return -EAGAIN;
}

static int drawqueue_retire_timelineobj(struct kgsl_drawobj *drawobj,
		struct adreno_context *drawctxt)
{
	_pop_drawobj(drawctxt);
	kgsl_drawobj_destroy(drawobj);
	return 0;
}

static int drawqueue_retire_bindobj(struct kgsl_drawobj *drawobj,
		struct adreno_context *drawctxt)
{
	struct kgsl_drawobj_bind *bindobj = BINDOBJ(drawobj);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:555 [MATCH: timeout] ---

	/*
	 * For the first submission in any given command queue update the
	 * expected expire time - this won't actually be used / updated until
	 * the command queue in question goes current, but universally setting
	 * it here avoids the possibilty of some race conditions with preempt
	 */

	if (dispatch_q->inflight == 1)
		dispatch_q->expires = jiffies +
			msecs_to_jiffies(adreno_drawobj_timeout);

	info.inflight = (int) dispatcher->inflight;
	info.rb_id = drawctxt->rb->id;
	info.rptr = adreno_get_rptr(drawctxt->rb);
	info.wptr = drawctxt->rb->wptr;
	info.gmu_dispatch_queue = -1;

	msm_perf_events_update(MSM_PERF_GFX, MSM_PERF_SUBMIT,
			       pid_nr(context->proc_priv->pid),
			       context->id, drawobj->timestamp,
			       !!(drawobj->flags & KGSL_DRAWOBJ_END_OF_FRAME));

	trace_adreno_cmdbatch_submitted(drawobj, &info,
			time.ticks, (unsigned long) secs, nsecs / 1000,
			dispatch_q->inflight);

	log_kgsl_cmdbatch_submitted_event(context->id, drawobj->timestamp,
		context->priority, drawobj->flags);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1640 [MATCH: timeout] ---
	/*
	 * A hardware fault generally means something was deterministically
	 * wrong with the cmdobj - no point in trying to replay it
	 * Clear the replay bit and move on to the next policy level
	 */

	if (fault & ADRENO_HARD_FAULT)
		clear_bit(KGSL_FT_REPLAY, &(cmdobj->fault_policy));

	/*
	 * A timeout fault means the IB timed out - clear the policy and
	 * invalidate - this will clear the FT_SKIP_PMDUMP bit but that is okay
	 * because we won't see this cmdobj again
	 */

	if ((fault & ADRENO_TIMEOUT_FAULT) ||
				(fault & ADRENO_CTX_DETATCH_TIMEOUT_FAULT))
		bitmap_zero(&cmdobj->fault_policy, BITS_PER_LONG);

	/*
	 * If the context had a GPU page fault then it is likely it would fault
	 * again if replayed
	 */

	if (test_bit(KGSL_CONTEXT_PRIV_PAGEFAULT,
		     &drawobj->context->priv)) {
		/* we'll need to resume the mmu later... */
		clear_bit(KGSL_FT_REPLAY, &cmdobj->fault_policy);
		clear_bit(KGSL_CONTEXT_PRIV_PAGEFAULT,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1645 [MATCH: timeout] ---

	if (fault & ADRENO_HARD_FAULT)
		clear_bit(KGSL_FT_REPLAY, &(cmdobj->fault_policy));

	/*
	 * A timeout fault means the IB timed out - clear the policy and
	 * invalidate - this will clear the FT_SKIP_PMDUMP bit but that is okay
	 * because we won't see this cmdobj again
	 */

	if ((fault & ADRENO_TIMEOUT_FAULT) ||
				(fault & ADRENO_CTX_DETATCH_TIMEOUT_FAULT))
		bitmap_zero(&cmdobj->fault_policy, BITS_PER_LONG);

	/*
	 * If the context had a GPU page fault then it is likely it would fault
	 * again if replayed
	 */

	if (test_bit(KGSL_CONTEXT_PRIV_PAGEFAULT,
		     &drawobj->context->priv)) {
		/* we'll need to resume the mmu later... */
		clear_bit(KGSL_FT_REPLAY, &cmdobj->fault_policy);
		clear_bit(KGSL_CONTEXT_PRIV_PAGEFAULT,
			  &drawobj->context->priv);
	}

	/*
	 * Execute the fault tolerance policy. Each cmdobj stores the

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1646 [MATCH: timeout] ---
	if (fault & ADRENO_HARD_FAULT)
		clear_bit(KGSL_FT_REPLAY, &(cmdobj->fault_policy));

	/*
	 * A timeout fault means the IB timed out - clear the policy and
	 * invalidate - this will clear the FT_SKIP_PMDUMP bit but that is okay
	 * because we won't see this cmdobj again
	 */

	if ((fault & ADRENO_TIMEOUT_FAULT) ||
				(fault & ADRENO_CTX_DETATCH_TIMEOUT_FAULT))
		bitmap_zero(&cmdobj->fault_policy, BITS_PER_LONG);

	/*
	 * If the context had a GPU page fault then it is likely it would fault
	 * again if replayed
	 */

	if (test_bit(KGSL_CONTEXT_PRIV_PAGEFAULT,
		     &drawobj->context->priv)) {
		/* we'll need to resume the mmu later... */
		clear_bit(KGSL_FT_REPLAY, &cmdobj->fault_policy);
		clear_bit(KGSL_CONTEXT_PRIV_PAGEFAULT,
			  &drawobj->context->priv);
	}

	/*
	 * Execute the fault tolerance policy. Each cmdobj stores the
	 * current fault policy that was set when it was queued.

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1909 [MATCH: timeout] ---
	 * out in the presence of this hwsched fault and requeue the dispatcher to handle this fault
	 */
	if (!mutex_trylock(&adreno_dev->fault_recovery_mutex))
		return 1;

	/*
	 * Wait long enough to allow the system to come out of suspend completely, which can take
	 * variable amount of time especially if it has to rewind suspend processes and devices.
	 */
	if (!wait_for_completion_timeout(&adreno_dev->suspend_recovery_gate,
			msecs_to_jiffies(ADRENO_SUSPEND_RECOVERY_GATE_TIMEOUT_MS))) {
		dev_err(device->dev, "suspend recovery gate timeout\n");
		adreno_scheduler_queue(adreno_dev);
		mutex_unlock(&adreno_dev->fault_recovery_mutex);
		return 1;
	}

	kgsl_mutex_lock(&device->mutex);

	/*
	 * In the very unlikely case that the power is off, do nothing - the
	 * state will be reset on power up and everybody will be happy
	 */
	if (!kgsl_state_is_awake(device)) {
		kgsl_mutex_unlock(&device->mutex);
		mutex_unlock(&adreno_dev->fault_recovery_mutex);
		return 0;
	}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1910 [MATCH: timeout] ---
	 */
	if (!mutex_trylock(&adreno_dev->fault_recovery_mutex))
		return 1;

	/*
	 * Wait long enough to allow the system to come out of suspend completely, which can take
	 * variable amount of time especially if it has to rewind suspend processes and devices.
	 */
	if (!wait_for_completion_timeout(&adreno_dev->suspend_recovery_gate,
			msecs_to_jiffies(ADRENO_SUSPEND_RECOVERY_GATE_TIMEOUT_MS))) {
		dev_err(device->dev, "suspend recovery gate timeout\n");
		adreno_scheduler_queue(adreno_dev);
		mutex_unlock(&adreno_dev->fault_recovery_mutex);
		return 1;
	}

	kgsl_mutex_lock(&device->mutex);

	/*
	 * In the very unlikely case that the power is off, do nothing - the
	 * state will be reset on power up and everybody will be happy
	 */
	if (!kgsl_state_is_awake(device)) {
		kgsl_mutex_unlock(&device->mutex);
		mutex_unlock(&adreno_dev->fault_recovery_mutex);
		return 0;
	}

	/* Mask all GMU interrupts */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2232 [MATCH: timeout] ---

		drawqueue->head = DRAWQUEUE_NEXT(drawqueue->head,
			ADRENO_DISPATCH_DRAWQUEUE_SIZE);

		count++;
	}

	return count;
}

static void _adreno_dispatch_check_timeout(struct adreno_device *adreno_dev,
		struct adreno_dispatcher_drawqueue *drawqueue)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct kgsl_drawobj *drawobj =
			DRAWOBJ(drawqueue->cmd_q[drawqueue->head]);

	/* Don't timeout if the timer hasn't expired yet (duh) */
	if (time_is_after_jiffies(drawqueue->expires))
		return;

	/* Don't timeout if the IB timeout is disabled globally */
	if (!adreno_long_ib_detect(adreno_dev))
		return;

	/* Don't time out if the context has disabled it */
	if (drawobj->context->flags & KGSL_CONTEXT_NO_FAULT_TOLERANCE)
		return;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2239 [MATCH: timeout] ---
	return count;
}

static void _adreno_dispatch_check_timeout(struct adreno_device *adreno_dev,
		struct adreno_dispatcher_drawqueue *drawqueue)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct kgsl_drawobj *drawobj =
			DRAWOBJ(drawqueue->cmd_q[drawqueue->head]);

	/* Don't timeout if the timer hasn't expired yet (duh) */
	if (time_is_after_jiffies(drawqueue->expires))
		return;

	/* Don't timeout if the IB timeout is disabled globally */
	if (!adreno_long_ib_detect(adreno_dev))
		return;

	/* Don't time out if the context has disabled it */
	if (drawobj->context->flags & KGSL_CONTEXT_NO_FAULT_TOLERANCE)
		return;

	pr_context(device, drawobj->context, "gpu timeout ctx %u ts %u\n",
		drawobj->context->id, drawobj->timestamp);

	adreno_set_gpu_fault(adreno_dev, ADRENO_TIMEOUT_FAULT);

	/*
	 * This makes sure dispatcher doesn't run endlessly in cases where

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2243 [MATCH: timeout] ---
		struct adreno_dispatcher_drawqueue *drawqueue)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct kgsl_drawobj *drawobj =
			DRAWOBJ(drawqueue->cmd_q[drawqueue->head]);

	/* Don't timeout if the timer hasn't expired yet (duh) */
	if (time_is_after_jiffies(drawqueue->expires))
		return;

	/* Don't timeout if the IB timeout is disabled globally */
	if (!adreno_long_ib_detect(adreno_dev))
		return;

	/* Don't time out if the context has disabled it */
	if (drawobj->context->flags & KGSL_CONTEXT_NO_FAULT_TOLERANCE)
		return;

	pr_context(device, drawobj->context, "gpu timeout ctx %u ts %u\n",
		drawobj->context->id, drawobj->timestamp);

	adreno_set_gpu_fault(adreno_dev, ADRENO_TIMEOUT_FAULT);

	/*
	 * This makes sure dispatcher doesn't run endlessly in cases where
	 * we couldn't run recovery
	 */
	drawqueue->expires = jiffies + msecs_to_jiffies(adreno_drawobj_timeout);
}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2251 [MATCH: timeout] ---
		return;

	/* Don't timeout if the IB timeout is disabled globally */
	if (!adreno_long_ib_detect(adreno_dev))
		return;

	/* Don't time out if the context has disabled it */
	if (drawobj->context->flags & KGSL_CONTEXT_NO_FAULT_TOLERANCE)
		return;

	pr_context(device, drawobj->context, "gpu timeout ctx %u ts %u\n",
		drawobj->context->id, drawobj->timestamp);

	adreno_set_gpu_fault(adreno_dev, ADRENO_TIMEOUT_FAULT);

	/*
	 * This makes sure dispatcher doesn't run endlessly in cases where
	 * we couldn't run recovery
	 */
	drawqueue->expires = jiffies + msecs_to_jiffies(adreno_drawobj_timeout);
}

static int adreno_dispatch_process_drawqueue(struct adreno_device *adreno_dev,
		struct adreno_dispatcher_drawqueue *drawqueue)
{
	int count = adreno_dispatch_retire_drawqueue(adreno_dev, drawqueue);

	/* Nothing to do if there are no pending commands */
	if (adreno_drawqueue_is_empty(drawqueue))

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2254 [MATCH: timeout] ---
	if (!adreno_long_ib_detect(adreno_dev))
		return;

	/* Don't time out if the context has disabled it */
	if (drawobj->context->flags & KGSL_CONTEXT_NO_FAULT_TOLERANCE)
		return;

	pr_context(device, drawobj->context, "gpu timeout ctx %u ts %u\n",
		drawobj->context->id, drawobj->timestamp);

	adreno_set_gpu_fault(adreno_dev, ADRENO_TIMEOUT_FAULT);

	/*
	 * This makes sure dispatcher doesn't run endlessly in cases where
	 * we couldn't run recovery
	 */
	drawqueue->expires = jiffies + msecs_to_jiffies(adreno_drawobj_timeout);
}

static int adreno_dispatch_process_drawqueue(struct adreno_device *adreno_dev,
		struct adreno_dispatcher_drawqueue *drawqueue)
{
	int count = adreno_dispatch_retire_drawqueue(adreno_dev, drawqueue);

	/* Nothing to do if there are no pending commands */
	if (adreno_drawqueue_is_empty(drawqueue))
		return count;

	/* Don't update the drawqueue timeout if it isn't active */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2260 [MATCH: timeout] ---

	pr_context(device, drawobj->context, "gpu timeout ctx %u ts %u\n",
		drawobj->context->id, drawobj->timestamp);

	adreno_set_gpu_fault(adreno_dev, ADRENO_TIMEOUT_FAULT);

	/*
	 * This makes sure dispatcher doesn't run endlessly in cases where
	 * we couldn't run recovery
	 */
	drawqueue->expires = jiffies + msecs_to_jiffies(adreno_drawobj_timeout);
}

static int adreno_dispatch_process_drawqueue(struct adreno_device *adreno_dev,
		struct adreno_dispatcher_drawqueue *drawqueue)
{
	int count = adreno_dispatch_retire_drawqueue(adreno_dev, drawqueue);

	/* Nothing to do if there are no pending commands */
	if (adreno_drawqueue_is_empty(drawqueue))
		return count;

	/* Don't update the drawqueue timeout if it isn't active */
	if (!drawqueue_is_current(drawqueue))
		return count;

	/*
	 * If the current ringbuffer retired any commands then universally
	 * reset the timeout

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2272 [MATCH: timeout] ---

static int adreno_dispatch_process_drawqueue(struct adreno_device *adreno_dev,
		struct adreno_dispatcher_drawqueue *drawqueue)
{
	int count = adreno_dispatch_retire_drawqueue(adreno_dev, drawqueue);

	/* Nothing to do if there are no pending commands */
	if (adreno_drawqueue_is_empty(drawqueue))
		return count;

	/* Don't update the drawqueue timeout if it isn't active */
	if (!drawqueue_is_current(drawqueue))
		return count;

	/*
	 * If the current ringbuffer retired any commands then universally
	 * reset the timeout
	 */

	if (count) {
		drawqueue->expires = jiffies +
			msecs_to_jiffies(adreno_drawobj_timeout);
		return count;
	}

	/*
	 * If we get here then 1) the ringbuffer is current and 2) we haven't
	 * retired anything.  Check to see if the timeout if valid for the
	 * current drawobj and fault if it has expired

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2278 [MATCH: timeout] ---
	/* Nothing to do if there are no pending commands */
	if (adreno_drawqueue_is_empty(drawqueue))
		return count;

	/* Don't update the drawqueue timeout if it isn't active */
	if (!drawqueue_is_current(drawqueue))
		return count;

	/*
	 * If the current ringbuffer retired any commands then universally
	 * reset the timeout
	 */

	if (count) {
		drawqueue->expires = jiffies +
			msecs_to_jiffies(adreno_drawobj_timeout);
		return count;
	}

	/*
	 * If we get here then 1) the ringbuffer is current and 2) we haven't
	 * retired anything.  Check to see if the timeout if valid for the
	 * current drawobj and fault if it has expired
	 */
	_adreno_dispatch_check_timeout(adreno_dev, drawqueue);
	return 0;
}

/* Take down the dispatcher and release any power states */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2283 [MATCH: timeout] ---
	if (!drawqueue_is_current(drawqueue))
		return count;

	/*
	 * If the current ringbuffer retired any commands then universally
	 * reset the timeout
	 */

	if (count) {
		drawqueue->expires = jiffies +
			msecs_to_jiffies(adreno_drawobj_timeout);
		return count;
	}

	/*
	 * If we get here then 1) the ringbuffer is current and 2) we haven't
	 * retired anything.  Check to see if the timeout if valid for the
	 * current drawobj and fault if it has expired
	 */
	_adreno_dispatch_check_timeout(adreno_dev, drawqueue);
	return 0;
}

/* Take down the dispatcher and release any power states */
static void _dispatcher_power_down(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2289 [MATCH: timeout] ---
	 */

	if (count) {
		drawqueue->expires = jiffies +
			msecs_to_jiffies(adreno_drawobj_timeout);
		return count;
	}

	/*
	 * If we get here then 1) the ringbuffer is current and 2) we haven't
	 * retired anything.  Check to see if the timeout if valid for the
	 * current drawobj and fault if it has expired
	 */
	_adreno_dispatch_check_timeout(adreno_dev, drawqueue);
	return 0;
}

/* Take down the dispatcher and release any power states */
static void _dispatcher_power_down(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher;

	kgsl_mutex_lock(&device->mutex);

	if (test_and_clear_bit(ADRENO_DISPATCHER_ACTIVE, &dispatcher->priv))
		complete_all(&dispatcher->idle_gate);

	process_rt_bus_hint(device, false);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2292 [MATCH: timeout] ---
		drawqueue->expires = jiffies +
			msecs_to_jiffies(adreno_drawobj_timeout);
		return count;
	}

	/*
	 * If we get here then 1) the ringbuffer is current and 2) we haven't
	 * retired anything.  Check to see if the timeout if valid for the
	 * current drawobj and fault if it has expired
	 */
	_adreno_dispatch_check_timeout(adreno_dev, drawqueue);
	return 0;
}

/* Take down the dispatcher and release any power states */
static void _dispatcher_power_down(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher;

	kgsl_mutex_lock(&device->mutex);

	if (test_and_clear_bit(ADRENO_DISPATCHER_ACTIVE, &dispatcher->priv))
		complete_all(&dispatcher->idle_gate);

	process_rt_bus_hint(device, false);

	if (test_bit(ADRENO_DISPATCHER_POWER, &dispatcher->priv)) {
		adreno_active_count_put(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2629 [MATCH: timeout] ---
/*
 * Our code that "puts back" a command from the context is much cleaner
 * if we are sure that there will always be enough room in the
 * ringbuffer so restrict the maximum size of the context queue to
 * ADRENO_CONTEXT_DRAWQUEUE_SIZE - 1
 */
static DISPATCHER_UINT_ATTR(context_drawqueue_size, 0644,
	ADRENO_CONTEXT_DRAWQUEUE_SIZE - 1, _context_drawqueue_size);
static DISPATCHER_UINT_ATTR(context_burst_count, 0644, 0,
	_context_drawobj_burst);
static DISPATCHER_UINT_ATTR(drawobj_timeout, 0644, 0,
	adreno_drawobj_timeout);
static DISPATCHER_UINT_ATTR(context_queue_wait, 0644, 0, _context_queue_wait);
static DISPATCHER_UINT_ATTR(fault_detect_interval, 0644, 0,
	_fault_timer_interval);
static DISPATCHER_UINT_ATTR(fault_throttle_time, 0644, 0,
	_fault_throttle_time);
static DISPATCHER_UINT_ATTR(fault_throttle_burst, 0644, 0,
	_fault_throttle_burst);

static struct attribute *dispatcher_attrs[] = {
	&dispatcher_attr_inflight.attr,
	&dispatcher_attr_inflight_low_latency.attr,
	&dispatcher_attr_context_drawqueue_size.attr,
	&dispatcher_attr_context_burst_count.attr,
	&dispatcher_attr_drawobj_timeout.attr,
	&dispatcher_attr_context_queue_wait.attr,
	&dispatcher_attr_fault_detect_interval.attr,
	&dispatcher_attr_fault_throttle_time.attr,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2630 [MATCH: timeout] ---
 * Our code that "puts back" a command from the context is much cleaner
 * if we are sure that there will always be enough room in the
 * ringbuffer so restrict the maximum size of the context queue to
 * ADRENO_CONTEXT_DRAWQUEUE_SIZE - 1
 */
static DISPATCHER_UINT_ATTR(context_drawqueue_size, 0644,
	ADRENO_CONTEXT_DRAWQUEUE_SIZE - 1, _context_drawqueue_size);
static DISPATCHER_UINT_ATTR(context_burst_count, 0644, 0,
	_context_drawobj_burst);
static DISPATCHER_UINT_ATTR(drawobj_timeout, 0644, 0,
	adreno_drawobj_timeout);
static DISPATCHER_UINT_ATTR(context_queue_wait, 0644, 0, _context_queue_wait);
static DISPATCHER_UINT_ATTR(fault_detect_interval, 0644, 0,
	_fault_timer_interval);
static DISPATCHER_UINT_ATTR(fault_throttle_time, 0644, 0,
	_fault_throttle_time);
static DISPATCHER_UINT_ATTR(fault_throttle_burst, 0644, 0,
	_fault_throttle_burst);

static struct attribute *dispatcher_attrs[] = {
	&dispatcher_attr_inflight.attr,
	&dispatcher_attr_inflight_low_latency.attr,
	&dispatcher_attr_context_drawqueue_size.attr,
	&dispatcher_attr_context_burst_count.attr,
	&dispatcher_attr_drawobj_timeout.attr,
	&dispatcher_attr_context_queue_wait.attr,
	&dispatcher_attr_fault_detect_interval.attr,
	&dispatcher_attr_fault_throttle_time.attr,
	&dispatcher_attr_fault_throttle_burst.attr,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2644 [MATCH: timeout] ---
static DISPATCHER_UINT_ATTR(fault_throttle_time, 0644, 0,
	_fault_throttle_time);
static DISPATCHER_UINT_ATTR(fault_throttle_burst, 0644, 0,
	_fault_throttle_burst);

static struct attribute *dispatcher_attrs[] = {
	&dispatcher_attr_inflight.attr,
	&dispatcher_attr_inflight_low_latency.attr,
	&dispatcher_attr_context_drawqueue_size.attr,
	&dispatcher_attr_context_burst_count.attr,
	&dispatcher_attr_drawobj_timeout.attr,
	&dispatcher_attr_context_queue_wait.attr,
	&dispatcher_attr_fault_detect_interval.attr,
	&dispatcher_attr_fault_throttle_time.attr,
	&dispatcher_attr_fault_throttle_burst.attr,
	NULL,
};

ATTRIBUTE_GROUPS(dispatcher);

static ssize_t dispatcher_sysfs_show(struct kobject *kobj,
				   struct attribute *attr, char *buf)
{
	struct adreno_dispatcher *dispatcher = to_dispatcher(kobj);
	struct dispatcher_attribute *pattr = to_dispatcher_attr(attr);
	ssize_t ret = -EIO;

	if (pattr->show)
		ret = pattr->show(dispatcher, pattr, buf);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2792 [MATCH: timeout] ---
	 * Flush the worker to make sure all executing
	 * or pending dispatcher works on worker are
	 * finished
	 */
	kthread_flush_worker(adreno_dev->scheduler_worker);

	if (adreno_gpu_fault(adreno_dev) != 0) {
		ret = -EDEADLK;
	} else {
		ret = wait_for_completion_timeout(&dispatcher->idle_gate,
				msecs_to_jiffies(ADRENO_IDLE_TIMEOUT));
		if (ret == 0) {
			ret = -ETIMEDOUT;
			WARN(1, "Dispatcher halt timeout\n");
		} else if (ret < 0) {
			dev_err(device->dev, "Dispatcher halt failed %d\n", ret);
		} else {
			ret = 0;
		}

		if (adreno_gpu_fault(adreno_dev) != 0)
			ret = -EDEADLK;
	}

	kgsl_mutex_lock(&device->mutex);
	adreno_put_gpu_halt(adreno_dev);
	/*
	 * requeue dispatcher work to resubmit pending commands
	 * that may have been blocked due to this idling request

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2795 [MATCH: timeout] ---
	 */
	kthread_flush_worker(adreno_dev->scheduler_worker);

	if (adreno_gpu_fault(adreno_dev) != 0) {
		ret = -EDEADLK;
	} else {
		ret = wait_for_completion_timeout(&dispatcher->idle_gate,
				msecs_to_jiffies(ADRENO_IDLE_TIMEOUT));
		if (ret == 0) {
			ret = -ETIMEDOUT;
			WARN(1, "Dispatcher halt timeout\n");
		} else if (ret < 0) {
			dev_err(device->dev, "Dispatcher halt failed %d\n", ret);
		} else {
			ret = 0;
		}

		if (adreno_gpu_fault(adreno_dev) != 0)
			ret = -EDEADLK;
	}

	kgsl_mutex_lock(&device->mutex);
	adreno_put_gpu_halt(adreno_dev);
	/*
	 * requeue dispatcher work to resubmit pending commands
	 * that may have been blocked due to this idling request
	 */
	adreno_scheduler_queue(adreno_dev);
	return ret;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:467 [MATCH: mutex_lock] ---
	struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher;
	struct adreno_context *drawctxt = ADRENO_CONTEXT(drawobj->context);
	struct kgsl_context *context = drawobj->context;
	struct adreno_dispatcher_drawqueue *dispatch_q = &drawctxt->rb->dispatch_q;
	struct adreno_submit_time time;
	uint64_t secs = 0;
	unsigned long nsecs = 0;
	int ret;
	struct submission_info info = {0};

	kgsl_mutex_lock(&device->mutex);

	if (adreno_gpu_halt(adreno_dev) != 0) {
		ret = -EBUSY;
		goto err;
	}

	memset(&time, 0x0, sizeof(time));

	dispatcher->inflight++;
	dispatch_q->inflight++;

	if (dispatcher->inflight == 1 &&
			!test_bit(ADRENO_DISPATCHER_POWER, &dispatcher->priv)) {
		/* Time to make the donuts.  Turn on the GPU */
		ret = adreno_active_count_get(adreno_dev);
		if (ret) {
			dispatcher->inflight--;
			dispatch_q->inflight--;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:830 [MATCH: mutex_lock] ---
		dispatcher_handle_jobs(adreno_dev, i);
}

/* Update the dispatcher timers */
static void _dispatcher_update_timers(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher;

	/* Kick the idle timer */
	kgsl_mutex_lock(&device->mutex);
	kgsl_pwrscale_update(device);
	process_rt_bus_hint(device, false);
	kgsl_start_idle_timer(device);
	kgsl_mutex_unlock(&device->mutex);

	/* Check to see if we need to update the command timer */
	if (adreno_in_preempt_state(adreno_dev, ADRENO_PREEMPT_NONE)) {
		struct adreno_dispatcher_drawqueue *drawqueue =
			DRAWQUEUE(adreno_dev->cur_rb);

		if (!adreno_drawqueue_is_empty(drawqueue))
			mod_timer(&dispatcher->timer, drawqueue->expires);
	}
}

static inline void _decrement_submit_now(struct kgsl_device *device)
{
	spin_lock(&device->submit_lock);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1453 [MATCH: mutex_lock] ---
	for (i = 0; i < count; i++) {
		struct kgsl_drawobj_cmd *cmdobj = replay[i];
		struct kgsl_drawobj *drawobj = DRAWOBJ(cmdobj);

		if (cmdobj == NULL)
			continue;

		if (kgsl_context_is_bad(drawobj->context)) {
			replay[i] = NULL;

			kgsl_mutex_lock(&device->mutex);
			kgsl_cancel_events_timestamp(device,
				&drawobj->context->events, drawobj->timestamp);
			kgsl_mutex_unlock(&device->mutex);

			kgsl_drawobj_destroy(drawobj);
		}
	}
}

#define pr_fault(_d, _c, fmt, args...) \
		pr_context(_d, (_c)->context, fmt, ##args)

static void adreno_fault_header(struct kgsl_device *device,
		struct adreno_ringbuffer *rb, struct kgsl_drawobj_cmd *cmdobj,
		int fault)
{
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	struct kgsl_drawobj *drawobj = DRAWOBJ(cmdobj);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1916 [MATCH: mutex_lock] ---
	 * variable amount of time especially if it has to rewind suspend processes and devices.
	 */
	if (!wait_for_completion_timeout(&adreno_dev->suspend_recovery_gate,
			msecs_to_jiffies(ADRENO_SUSPEND_RECOVERY_GATE_TIMEOUT_MS))) {
		dev_err(device->dev, "suspend recovery gate timeout\n");
		adreno_scheduler_queue(adreno_dev);
		mutex_unlock(&adreno_dev->fault_recovery_mutex);
		return 1;
	}

	kgsl_mutex_lock(&device->mutex);

	/*
	 * In the very unlikely case that the power is off, do nothing - the
	 * state will be reset on power up and everybody will be happy
	 */
	if (!kgsl_state_is_awake(device)) {
		kgsl_mutex_unlock(&device->mutex);
		mutex_unlock(&adreno_dev->fault_recovery_mutex);
		return 0;
	}

	/* Mask all GMU interrupts */
	if (gmu_core_isenabled(device)) {
		adreno_write_gmureg(adreno_dev,
			ADRENO_REG_GMU_AO_HOST_INTERRUPT_MASK,
			0xFFFFFFFF);
		adreno_write_gmureg(adreno_dev,
			ADRENO_REG_GMU_GMU2HOST_INTR_MASK,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2302 [MATCH: mutex_lock] ---
	_adreno_dispatch_check_timeout(adreno_dev, drawqueue);
	return 0;
}

/* Take down the dispatcher and release any power states */
static void _dispatcher_power_down(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher;

	kgsl_mutex_lock(&device->mutex);

	if (test_and_clear_bit(ADRENO_DISPATCHER_ACTIVE, &dispatcher->priv))
		complete_all(&dispatcher->idle_gate);

	process_rt_bus_hint(device, false);

	if (test_bit(ADRENO_DISPATCHER_POWER, &dispatcher->priv)) {
		adreno_active_count_put(adreno_dev);
		clear_bit(ADRENO_DISPATCHER_POWER, &dispatcher->priv);
	}

	kgsl_mutex_unlock(&device->mutex);
}

static void adreno_dispatcher_work(struct kthread_work *work)
{
	struct adreno_device *adreno_dev =
		container_of(work, struct adreno_device, scheduler_work);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2327 [MATCH: mutex_lock] ---
static void adreno_dispatcher_work(struct kthread_work *work)
{
	struct adreno_device *adreno_dev =
		container_of(work, struct adreno_device, scheduler_work);
	struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher;
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
	int count = 0;
	unsigned int i = 0;

	mutex_lock(&dispatcher->mutex);

	/*
	 * As long as there are inflight commands, process retired comamnds from
	 * all drawqueues
	 */
	for (i = 0; i < adreno_dev->num_ringbuffers; i++) {
		struct adreno_dispatcher_drawqueue *drawqueue =
			DRAWQUEUE(&adreno_dev->ringbuffers[i]);

		count += adreno_dispatch_process_drawqueue(adreno_dev,
			drawqueue);
		if (dispatcher->inflight == 0)
			break;
	}

	kgsl_process_event_groups(device);

	/*

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2537 [MATCH: mutex_lock] ---
	&adreno_attr_ft_long_ib_detect.attr.attr,
	NULL,
};

static void adreno_dispatcher_close(struct adreno_device *adreno_dev)
{
	struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher;
	int i;
	struct adreno_ringbuffer *rb;

	mutex_lock(&dispatcher->mutex);
	kgsl_delete_timer_sync(&dispatcher->timer);

	FOR_EACH_RINGBUFFER(adreno_dev, rb, i) {
		struct adreno_dispatcher_drawqueue *dispatch_q =
			&(rb->dispatch_q);
		while (!adreno_drawqueue_is_empty(dispatch_q)) {
			kgsl_drawobj_destroy(
				DRAWOBJ(dispatch_q->cmd_q[dispatch_q->head]));
			dispatch_q->head = (dispatch_q->head + 1)
				% ADRENO_DISPATCH_DRAWQUEUE_SIZE;
		}
	}

	mutex_unlock(&dispatcher->mutex);

	kthread_destroy_worker(adreno_dev->scheduler_worker);

	adreno_set_dispatch_ops(adreno_dev, NULL);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2806 [MATCH: mutex_lock] ---
		} else if (ret < 0) {
			dev_err(device->dev, "Dispatcher halt failed %d\n", ret);
		} else {
			ret = 0;
		}

		if (adreno_gpu_fault(adreno_dev) != 0)
			ret = -EDEADLK;
	}

	kgsl_mutex_lock(&device->mutex);
	adreno_put_gpu_halt(adreno_dev);
	/*
	 * requeue dispatcher work to resubmit pending commands
	 * that may have been blocked due to this idling request
	 */
	adreno_scheduler_queue(adreno_dev);
	return ret;
}

int adreno_drain_and_idle(struct kgsl_device *device)
{
	int ret = adreno_drain(device, HZ);

	/* Make sure the dispatcher and hardware are idle */
	if (!ret)
		ret = adreno_wait_idle(device);

	return ret;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:575 [MATCH: mutex_unlock] ---
			       context->id, drawobj->timestamp,
			       !!(drawobj->flags & KGSL_DRAWOBJ_END_OF_FRAME));

	trace_adreno_cmdbatch_submitted(drawobj, &info,
			time.ticks, (unsigned long) secs, nsecs / 1000,
			dispatch_q->inflight);

	log_kgsl_cmdbatch_submitted_event(context->id, drawobj->timestamp,
		context->priority, drawobj->flags);

	kgsl_mutex_unlock(&device->mutex);

	cmdobj->submit_ticks = time.ticks;

	dispatch_q->cmd_q[dispatch_q->tail] = cmdobj;
	dispatch_q->tail = (dispatch_q->tail + 1) %
		ADRENO_DISPATCH_DRAWQUEUE_SIZE;

	/*
	 * If we believe ourselves to be current and preemption isn't a thing,
	 * then set up the timer.  If this misses, then preemption is indeed a
	 * thing and the timer will be set up in due time
	 */
	if (adreno_in_preempt_state(adreno_dev, ADRENO_PREEMPT_NONE)) {
		if (drawqueue_is_current(dispatch_q))
			mod_timer(&dispatcher->timer, dispatch_q->expires);
	}



--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:602 [MATCH: mutex_unlock] ---


	/*
	 * we just submitted something, readjust ringbuffer
	 * execution level
	 */
	if (gpudev->preemption_schedule)
		gpudev->preemption_schedule(adreno_dev);
	return 0;
err:
	kgsl_mutex_unlock(&device->mutex);
	return ret;
}

/**
 * dispatcher_context_sendcmds() - Send commands from a context to the GPU
 * @adreno_dev: Pointer to the adreno device struct
 * @drawctxt: Pointer to the adreno context to dispatch commands from
 *
 * Dequeue and send a burst of commands from the specified context to the GPU
 * Returns postive if the context needs to be put back on the pending queue
 * 0 if the context is empty or detached and negative on error
 */
static int dispatcher_context_sendcmds(struct adreno_device *adreno_dev,
		struct adreno_context *drawctxt)
{
	struct adreno_dispatcher_drawqueue *dispatch_q =
					&(drawctxt->rb->dispatch_q);
	int count = 0;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:834 [MATCH: mutex_unlock] ---
static void _dispatcher_update_timers(struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher;

	/* Kick the idle timer */
	kgsl_mutex_lock(&device->mutex);
	kgsl_pwrscale_update(device);
	process_rt_bus_hint(device, false);
	kgsl_start_idle_timer(device);
	kgsl_mutex_unlock(&device->mutex);

	/* Check to see if we need to update the command timer */
	if (adreno_in_preempt_state(adreno_dev, ADRENO_PREEMPT_NONE)) {
		struct adreno_dispatcher_drawqueue *drawqueue =
			DRAWQUEUE(adreno_dev->cur_rb);

		if (!adreno_drawqueue_is_empty(drawqueue))
			mod_timer(&dispatcher->timer, drawqueue->expires);
	}
}

static inline void _decrement_submit_now(struct kgsl_device *device)
{
	spin_lock(&device->submit_lock);
	device->submit_now--;
	spin_unlock(&device->submit_lock);
}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:884 [MATCH: mutex_unlock] ---
	if (!mutex_trylock(&dispatcher->mutex)) {
		_decrement_submit_now(device);
		goto done;
	}

	_adreno_dispatcher_issuecmds(adreno_dev);

	if (dispatcher->inflight)
		_dispatcher_update_timers(adreno_dev);

	mutex_unlock(&dispatcher->mutex);
	_decrement_submit_now(device);
	return;
done:
	adreno_scheduler_queue(adreno_dev);
}

/**
 * get_timestamp() - Return the next timestamp for the context
 * @drawctxt - Pointer to an adreno draw context struct
 * @drawobj - Pointer to a drawobj
 * @timestamp - Pointer to a timestamp value possibly passed from the user
 * @user_ts - user generated timestamp
 *
 * Assign a timestamp based on the settings of the draw context and the command
 * batch.
 */
static int get_timestamp(struct adreno_context *drawctxt,
		struct kgsl_drawobj *drawobj, unsigned int *timestamp,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1456 [MATCH: mutex_unlock] ---

		if (cmdobj == NULL)
			continue;

		if (kgsl_context_is_bad(drawobj->context)) {
			replay[i] = NULL;

			kgsl_mutex_lock(&device->mutex);
			kgsl_cancel_events_timestamp(device,
				&drawobj->context->events, drawobj->timestamp);
			kgsl_mutex_unlock(&device->mutex);

			kgsl_drawobj_destroy(drawobj);
		}
	}
}

#define pr_fault(_d, _c, fmt, args...) \
		pr_context(_d, (_c)->context, fmt, ##args)

static void adreno_fault_header(struct kgsl_device *device,
		struct adreno_ringbuffer *rb, struct kgsl_drawobj_cmd *cmdobj,
		int fault)
{
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	struct kgsl_drawobj *drawobj = DRAWOBJ(cmdobj);
	struct adreno_context *drawctxt =
			drawobj ? ADRENO_CONTEXT(drawobj->context) : NULL;
	const struct adreno_gpudev *gpudev  = ADRENO_GPU_DEVICE(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1912 [MATCH: mutex_unlock] ---
		return 1;

	/*
	 * Wait long enough to allow the system to come out of suspend completely, which can take
	 * variable amount of time especially if it has to rewind suspend processes and devices.
	 */
	if (!wait_for_completion_timeout(&adreno_dev->suspend_recovery_gate,
			msecs_to_jiffies(ADRENO_SUSPEND_RECOVERY_GATE_TIMEOUT_MS))) {
		dev_err(device->dev, "suspend recovery gate timeout\n");
		adreno_scheduler_queue(adreno_dev);
		mutex_unlock(&adreno_dev->fault_recovery_mutex);
		return 1;
	}

	kgsl_mutex_lock(&device->mutex);

	/*
	 * In the very unlikely case that the power is off, do nothing - the
	 * state will be reset on power up and everybody will be happy
	 */
	if (!kgsl_state_is_awake(device)) {
		kgsl_mutex_unlock(&device->mutex);
		mutex_unlock(&adreno_dev->fault_recovery_mutex);
		return 0;
	}

	/* Mask all GMU interrupts */
	if (gmu_core_isenabled(device)) {
		adreno_write_gmureg(adreno_dev,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1923 [MATCH: mutex_unlock] ---
		return 1;
	}

	kgsl_mutex_lock(&device->mutex);

	/*
	 * In the very unlikely case that the power is off, do nothing - the
	 * state will be reset on power up and everybody will be happy
	 */
	if (!kgsl_state_is_awake(device)) {
		kgsl_mutex_unlock(&device->mutex);
		mutex_unlock(&adreno_dev->fault_recovery_mutex);
		return 0;
	}

	/* Mask all GMU interrupts */
	if (gmu_core_isenabled(device)) {
		adreno_write_gmureg(adreno_dev,
			ADRENO_REG_GMU_AO_HOST_INTERRUPT_MASK,
			0xFFFFFFFF);
		adreno_write_gmureg(adreno_dev,
			ADRENO_REG_GMU_GMU2HOST_INTR_MASK,
			0xFFFFFFFF);
	}

	gx_on = adreno_gx_is_on(adreno_dev);

	/*
	 * Check if this function was entered after a pagefault. If so, only

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1924 [MATCH: mutex_unlock] ---
	}

	kgsl_mutex_lock(&device->mutex);

	/*
	 * In the very unlikely case that the power is off, do nothing - the
	 * state will be reset on power up and everybody will be happy
	 */
	if (!kgsl_state_is_awake(device)) {
		kgsl_mutex_unlock(&device->mutex);
		mutex_unlock(&adreno_dev->fault_recovery_mutex);
		return 0;
	}

	/* Mask all GMU interrupts */
	if (gmu_core_isenabled(device)) {
		adreno_write_gmureg(adreno_dev,
			ADRENO_REG_GMU_AO_HOST_INTERRUPT_MASK,
			0xFFFFFFFF);
		adreno_write_gmureg(adreno_dev,
			ADRENO_REG_GMU_GMU2HOST_INTR_MASK,
			0xFFFFFFFF);
	}

	gx_on = adreno_gx_is_on(adreno_dev);

	/*
	 * Check if this function was entered after a pagefault. If so, only
	 * proceed if the fault handler has already run in the IRQ thread,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1947 [MATCH: mutex_unlock] ---

	gx_on = adreno_gx_is_on(adreno_dev);

	/*
	 * Check if this function was entered after a pagefault. If so, only
	 * proceed if the fault handler has already run in the IRQ thread,
	 * else return early to give the fault handler a chance to run.
	 */
	if (!(fault & ADRENO_IOMMU_STALL_ON_PAGE_FAULT) && gx_on) {
		if (adreno_smmu_is_stalled(adreno_dev)) {
			kgsl_mutex_unlock(&device->mutex);
			mutex_unlock(&adreno_dev->fault_recovery_mutex);
			dev_err(device->dev,
				"SMMU is stalled without a pagefault\n");
			return -EBUSY;
		}
	}

	/* Turn off all the timers */
	kgsl_delete_timer_sync(&dispatcher->timer);

	/*
	 * Deleting uninitialized timer will block for ever on kernel debug
	 * disable build. Hence skip del timer if it is not initialized.
	 */
	if (adreno_is_preemption_enabled(adreno_dev))
		kgsl_delete_timer_sync(&adreno_dev->preempt.timer);

	if (gx_on)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1948 [MATCH: mutex_unlock] ---
	gx_on = adreno_gx_is_on(adreno_dev);

	/*
	 * Check if this function was entered after a pagefault. If so, only
	 * proceed if the fault handler has already run in the IRQ thread,
	 * else return early to give the fault handler a chance to run.
	 */
	if (!(fault & ADRENO_IOMMU_STALL_ON_PAGE_FAULT) && gx_on) {
		if (adreno_smmu_is_stalled(adreno_dev)) {
			kgsl_mutex_unlock(&device->mutex);
			mutex_unlock(&adreno_dev->fault_recovery_mutex);
			dev_err(device->dev,
				"SMMU is stalled without a pagefault\n");
			return -EBUSY;
		}
	}

	/* Turn off all the timers */
	kgsl_delete_timer_sync(&dispatcher->timer);

	/*
	 * Deleting uninitialized timer will block for ever on kernel debug
	 * disable build. Hence skip del timer if it is not initialized.
	 */
	if (adreno_is_preemption_enabled(adreno_dev))
		kgsl_delete_timer_sync(&adreno_dev->preempt.timer);

	if (gx_on)
		adreno_readreg64(adreno_dev, ADRENO_REG_CP_RB_BASE,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2060 [MATCH: mutex_unlock] ---
	}

	ret = adreno_reset(device, fault);

	/* If adreno_reset() fails then what hope do we have for the future? */
	BUG_ON(ret);

	/* if any other fault got in until reset then ignore */
	adreno_clear_gpu_fault(adreno_dev);

	kgsl_mutex_unlock(&device->mutex);

	mutex_unlock(&adreno_dev->fault_recovery_mutex);

	/* recover all the dispatch_q's starting with the one that hung */
	if (dispatch_q)
		recover_dispatch_q(device, dispatch_q, fault, base);
	FOR_EACH_RINGBUFFER(adreno_dev, rb, i) {
		dispatch_q_temp = &(rb->dispatch_q);
		if (dispatch_q_temp != dispatch_q)
			recover_dispatch_q(device, dispatch_q_temp, 0, base);
	}

	atomic_add(halt, &adreno_dev->halt);

	return 1;
}

static inline int drawobj_consumed(struct kgsl_drawobj *drawobj,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2062 [MATCH: mutex_unlock] ---
	ret = adreno_reset(device, fault);

	/* If adreno_reset() fails then what hope do we have for the future? */
	BUG_ON(ret);

	/* if any other fault got in until reset then ignore */
	adreno_clear_gpu_fault(adreno_dev);

	kgsl_mutex_unlock(&device->mutex);

	mutex_unlock(&adreno_dev->fault_recovery_mutex);

	/* recover all the dispatch_q's starting with the one that hung */
	if (dispatch_q)
		recover_dispatch_q(device, dispatch_q, fault, base);
	FOR_EACH_RINGBUFFER(adreno_dev, rb, i) {
		dispatch_q_temp = &(rb->dispatch_q);
		if (dispatch_q_temp != dispatch_q)
			recover_dispatch_q(device, dispatch_q_temp, 0, base);
	}

	atomic_add(halt, &adreno_dev->halt);

	return 1;
}

static inline int drawobj_consumed(struct kgsl_drawobj *drawobj,
		unsigned int consumed, unsigned int retired)
{

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2314 [MATCH: mutex_unlock] ---
	if (test_and_clear_bit(ADRENO_DISPATCHER_ACTIVE, &dispatcher->priv))
		complete_all(&dispatcher->idle_gate);

	process_rt_bus_hint(device, false);

	if (test_bit(ADRENO_DISPATCHER_POWER, &dispatcher->priv)) {
		adreno_active_count_put(adreno_dev);
		clear_bit(ADRENO_DISPATCHER_POWER, &dispatcher->priv);
	}

	kgsl_mutex_unlock(&device->mutex);
}

static void adreno_dispatcher_work(struct kthread_work *work)
{
	struct adreno_device *adreno_dev =
		container_of(work, struct adreno_device, scheduler_work);
	struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher;
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	const struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
	int count = 0;
	unsigned int i = 0;

	mutex_lock(&dispatcher->mutex);

	/*
	 * As long as there are inflight commands, process retired comamnds from
	 * all drawqueues
	 */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2368 [MATCH: mutex_unlock] ---

	/*
	 * If there are commands pending, update the timers, otherwise release
	 * the power state to prepare for power down
	 */
	if (dispatcher->inflight > 0)
		_dispatcher_update_timers(adreno_dev);
	else
		_dispatcher_power_down(adreno_dev);

	mutex_unlock(&dispatcher->mutex);
}

/*
 * Put a draw context on the dispatcher pending queue and schedule the
 * dispatcher. This is used to reschedule changes that might have been blocked
 * for sync points or other concerns
 */
static void adreno_dispatcher_queue_context(struct adreno_device *adreno_dev,
	struct adreno_context *drawctxt)
{
	dispatcher_queue_context(adreno_dev, drawctxt);
	adreno_scheduler_queue(adreno_dev);
}

/*
 * This is called when the timer expires - it either means the GPU is hung or
 * the IB is taking too long to execute
 */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2551 [MATCH: mutex_unlock] ---
		struct adreno_dispatcher_drawqueue *dispatch_q =
			&(rb->dispatch_q);
		while (!adreno_drawqueue_is_empty(dispatch_q)) {
			kgsl_drawobj_destroy(
				DRAWOBJ(dispatch_q->cmd_q[dispatch_q->head]));
			dispatch_q->head = (dispatch_q->head + 1)
				% ADRENO_DISPATCH_DRAWQUEUE_SIZE;
		}
	}

	mutex_unlock(&dispatcher->mutex);

	kthread_destroy_worker(adreno_dev->scheduler_worker);

	adreno_set_dispatch_ops(adreno_dev, NULL);

	kobject_put(&dispatcher->kobj);

	kmem_cache_destroy(jobs_cache);

	clear_bit(ADRENO_DISPATCHER_INIT, &dispatcher->priv);
}

struct dispatcher_attribute {
	struct attribute attr;
	ssize_t (*show)(struct adreno_dispatcher *dispatcher,
			struct dispatcher_attribute *attr, char *buf);
	ssize_t (*store)(struct adreno_dispatcher *dispatcher,
			struct dispatcher_attribute *attr, const char *buf,

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:2779 [MATCH: mutex_unlock] ---
	/*
	 * Ensure that this function is not called when dispatcher
	 * mutex is held and device is started
	 */

	if (WARN_ON(mutex_is_locked(&dispatcher->mutex)))
		return -EDEADLK;

	adreno_get_gpu_halt(adreno_dev);

	kgsl_mutex_unlock(&device->mutex);

	/*
	 * Flush the worker to make sure all executing
	 * or pending dispatcher works on worker are
	 * finished
	 */
	kthread_flush_worker(adreno_dev->scheduler_worker);

	if (adreno_gpu_fault(adreno_dev) != 0) {
		ret = -EDEADLK;
	} else {
		ret = wait_for_completion_timeout(&dispatcher->idle_gate,
				msecs_to_jiffies(ADRENO_IDLE_TIMEOUT));
		if (ret == 0) {
			ret = -ETIMEDOUT;
			WARN(1, "Dispatcher halt timeout\n");
		} else if (ret < 0) {
			dev_err(device->dev, "Dispatcher halt failed %d\n", ret);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:162 [MATCH: spin_lock] ---
	log_kgsl_cmdbatch_retired_event(context->id, drawobj->timestamp,
		context->priority, drawobj->flags, 0, 0);

	kgsl_drawobj_destroy(drawobj);
}

static int _check_context_queue(struct adreno_context *drawctxt, u32 count)
{
	int ret;

	spin_lock(&drawctxt->lock);

	/*
	 * Wake up if there is room in the context or if the whole thing got
	 * invalidated while we were asleep
	 */

	if (kgsl_context_invalid(&drawctxt->base))
		ret = 1;
	else
		ret = ((drawctxt->queued + count) < _context_drawqueue_size) ? 1 : 0;

	spin_unlock(&drawctxt->lock);

	return ret;
}

/*
 * return true if this is a marker command and the dependent timestamp has

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:350 [MATCH: spin_lock] ---
 * being submitted so if a failure happens, push it back on the head of the
 * context queue to be reconsidered again unless the context got detached.
 */
static inline int adreno_dispatcher_requeue_cmdobj(
		struct adreno_context *drawctxt,
		struct kgsl_drawobj_cmd *cmdobj)
{
	unsigned int prev;
	struct kgsl_drawobj *drawobj = DRAWOBJ(cmdobj);

	spin_lock(&drawctxt->lock);

	if (kgsl_context_is_bad(&drawctxt->base)) {
		spin_unlock(&drawctxt->lock);
		/* get rid of this drawobj since the context is bad */
		kgsl_drawobj_destroy(drawobj);
		return -ENOENT;
	}

	prev = drawctxt->drawqueue_head == 0 ?
		(ADRENO_CONTEXT_DRAWQUEUE_SIZE - 1) :
		(drawctxt->drawqueue_head - 1);

	/*
	 * The maximum queue size always needs to be one less then the size of
	 * the ringbuffer queue so there is "room" to put the drawobj back in
	 */

	WARN_ON(prev == drawctxt->drawqueue_tail);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:626 [MATCH: spin_lock] ---
		struct adreno_context *drawctxt)
{
	struct adreno_dispatcher_drawqueue *dispatch_q =
					&(drawctxt->rb->dispatch_q);
	int count = 0;
	int ret = 0;
	int inflight = _drawqueue_inflight(dispatch_q);
	unsigned int timestamp;

	if (dispatch_q->inflight >= inflight) {
		spin_lock(&drawctxt->lock);
		_process_drawqueue_get_next_drawobj(drawctxt);
		spin_unlock(&drawctxt->lock);
		return -EBUSY;
	}

	/*
	 * Each context can send a specific number of drawobjs per cycle
	 */
	while ((count < _context_drawobj_burst) &&
		(dispatch_q->inflight < inflight)) {
		struct kgsl_drawobj *drawobj;
		struct kgsl_drawobj_cmd *cmdobj;
		struct kgsl_context *context;

		if (adreno_gpu_fault(adreno_dev) != 0)
			break;

		spin_lock(&drawctxt->lock);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:644 [MATCH: spin_lock] ---
	 */
	while ((count < _context_drawobj_burst) &&
		(dispatch_q->inflight < inflight)) {
		struct kgsl_drawobj *drawobj;
		struct kgsl_drawobj_cmd *cmdobj;
		struct kgsl_context *context;

		if (adreno_gpu_fault(adreno_dev) != 0)
			break;

		spin_lock(&drawctxt->lock);
		drawobj = _process_drawqueue_get_next_drawobj(drawctxt);

		/*
		 * adreno_context_get_drawobj returns -EAGAIN if the current
		 * drawobj has pending sync points so no more to do here.
		 * When the sync points are satisfied then the context will get
		 * reqeueued
		 */

		if (IS_ERR_OR_NULL(drawobj)) {
			if (IS_ERR(drawobj))
				ret = PTR_ERR(drawobj);
			spin_unlock(&drawctxt->lock);
			break;
		}
		_pop_drawobj(drawctxt);
		spin_unlock(&drawctxt->lock);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:848 [MATCH: spin_lock] ---
		struct adreno_dispatcher_drawqueue *drawqueue =
			DRAWQUEUE(adreno_dev->cur_rb);

		if (!adreno_drawqueue_is_empty(drawqueue))
			mod_timer(&dispatcher->timer, drawqueue->expires);
	}
}

static inline void _decrement_submit_now(struct kgsl_device *device)
{
	spin_lock(&device->submit_lock);
	device->submit_now--;
	spin_unlock(&device->submit_lock);
}

/**
 * adreno_dispatcher_issuecmds() - Issue commmands from pending contexts
 * @adreno_dev: Pointer to the adreno device struct
 *
 * Lock the dispatcher and call _adreno_dispatcher_issueibcmds
 */
static void adreno_dispatcher_issuecmds(struct adreno_device *adreno_dev)
{
	struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher;
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	spin_lock(&device->submit_lock);
	/* If state is not ACTIVE, schedule the work for later */
	if (device->skip_inline_submit) {

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:864 [MATCH: spin_lock] ---
 * adreno_dispatcher_issuecmds() - Issue commmands from pending contexts
 * @adreno_dev: Pointer to the adreno device struct
 *
 * Lock the dispatcher and call _adreno_dispatcher_issueibcmds
 */
static void adreno_dispatcher_issuecmds(struct adreno_device *adreno_dev)
{
	struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher;
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	spin_lock(&device->submit_lock);
	/* If state is not ACTIVE, schedule the work for later */
	if (device->skip_inline_submit) {
		spin_unlock(&device->submit_lock);
		goto done;
	}
	device->submit_now++;
	spin_unlock(&device->submit_lock);

	/* If the dispatcher is busy then schedule the work for later */
	if (!mutex_trylock(&dispatcher->mutex)) {
		_decrement_submit_now(device);
		goto done;
	}

	_adreno_dispatcher_issuecmds(adreno_dev);

	if (dispatcher->inflight)
		_dispatcher_update_timers(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1014 [MATCH: spin_lock] ---
	 * sure we never let drawqueue->queued exceed _context_drawqueue_size.
	 */
	if ((drawctxt->queued + count) > (_context_drawqueue_size - 1)) {
		trace_adreno_drawctxt_sleep(drawctxt);
		spin_unlock(&drawctxt->lock);

		ret = wait_event_interruptible_timeout(drawctxt->wq,
			_check_context_queue(drawctxt, count),
			msecs_to_jiffies(_context_queue_wait));

		spin_lock(&drawctxt->lock);
		trace_adreno_drawctxt_wake(drawctxt);

		/*
		 * Account for the possibility that the context got invalidated
		 * while we were sleeping
		 */
		if (ret > 0)
			ret = kgsl_check_context_state(&drawctxt->base);
		else if (ret == 0)
			ret = -ETIMEDOUT;
	}

	return ret;
}

static unsigned int _check_context_state_to_queue_cmds(
	struct adreno_context *drawctxt, u32 count)
{

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1213 [MATCH: spin_lock] ---

	/* wait for the suspend gate */
	wait_for_completion(&device->halt_gate);

	job = kmem_cache_alloc(jobs_cache, GFP_KERNEL);
	if (!job)
		return -ENOMEM;

	job->drawctxt = drawctxt;

	spin_lock(&drawctxt->lock);

	ret = _check_context_state_to_queue_cmds(drawctxt, count);
	if (ret) {
		spin_unlock(&drawctxt->lock);
		kmem_cache_free(jobs_cache, job);
		return ret;
	}

	user_ts = *timestamp;

	/*
	 * If there is only one drawobj in the array and it is of
	 * type SYNCOBJ_TYPE, skip comparing user_ts as it can be 0
	 */
	if (!(count == 1 && drawobj[0]->type == SYNCOBJ_TYPE) &&
		(drawctxt->base.flags & KGSL_CONTEXT_USER_GENERATED_TS)) {
		/*
		 * User specified timestamps need to be greater than the last

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:174 [MATCH: spin_unlock] ---
	/*
	 * Wake up if there is room in the context or if the whole thing got
	 * invalidated while we were asleep
	 */

	if (kgsl_context_invalid(&drawctxt->base))
		ret = 1;
	else
		ret = ((drawctxt->queued + count) < _context_drawqueue_size) ? 1 : 0;

	spin_unlock(&drawctxt->lock);

	return ret;
}

/*
 * return true if this is a marker command and the dependent timestamp has
 * retired
 */
static bool _marker_expired(struct kgsl_drawobj_cmd *markerobj)
{
	struct kgsl_drawobj *drawobj = DRAWOBJ(markerobj);

	return (drawobj->flags & KGSL_DRAWOBJ_MARKER) &&
		kgsl_check_timestamp(drawobj->device, drawobj->context,
			markerobj->marker_timestamp);
}

static inline void _pop_drawobj(struct adreno_context *drawctxt)

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:353 [MATCH: spin_unlock] ---
static inline int adreno_dispatcher_requeue_cmdobj(
		struct adreno_context *drawctxt,
		struct kgsl_drawobj_cmd *cmdobj)
{
	unsigned int prev;
	struct kgsl_drawobj *drawobj = DRAWOBJ(cmdobj);

	spin_lock(&drawctxt->lock);

	if (kgsl_context_is_bad(&drawctxt->base)) {
		spin_unlock(&drawctxt->lock);
		/* get rid of this drawobj since the context is bad */
		kgsl_drawobj_destroy(drawobj);
		return -ENOENT;
	}

	prev = drawctxt->drawqueue_head == 0 ?
		(ADRENO_CONTEXT_DRAWQUEUE_SIZE - 1) :
		(drawctxt->drawqueue_head - 1);

	/*
	 * The maximum queue size always needs to be one less then the size of
	 * the ringbuffer queue so there is "room" to put the drawobj back in
	 */

	WARN_ON(prev == drawctxt->drawqueue_tail);

	drawctxt->drawqueue[prev] = drawobj;
	drawctxt->queued++;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:376 [MATCH: spin_unlock] ---
	 */

	WARN_ON(prev == drawctxt->drawqueue_tail);

	drawctxt->drawqueue[prev] = drawobj;
	drawctxt->queued++;

	/* Reset the command queue head to reflect the newly requeued change */
	drawctxt->drawqueue_head = prev;
	cmdobj->requeue_cnt++;
	spin_unlock(&drawctxt->lock);
	return 0;
}

/**
 * dispatcher_queue_context() - Queue a context in the dispatcher pending list
 * @dispatcher: Pointer to the adreno dispatcher struct
 * @drawctxt: Pointer to the adreno draw context
 *
 * Add a context to the dispatcher pending list.
 */
static int dispatcher_queue_context(struct adreno_device *adreno_dev,
		struct adreno_context *drawctxt)
{
	struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher;
	struct adreno_dispatch_job *job;

	/* Refuse to queue a detached context */
	if (kgsl_context_detached(&drawctxt->base))

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:628 [MATCH: spin_unlock] ---
	struct adreno_dispatcher_drawqueue *dispatch_q =
					&(drawctxt->rb->dispatch_q);
	int count = 0;
	int ret = 0;
	int inflight = _drawqueue_inflight(dispatch_q);
	unsigned int timestamp;

	if (dispatch_q->inflight >= inflight) {
		spin_lock(&drawctxt->lock);
		_process_drawqueue_get_next_drawobj(drawctxt);
		spin_unlock(&drawctxt->lock);
		return -EBUSY;
	}

	/*
	 * Each context can send a specific number of drawobjs per cycle
	 */
	while ((count < _context_drawobj_burst) &&
		(dispatch_q->inflight < inflight)) {
		struct kgsl_drawobj *drawobj;
		struct kgsl_drawobj_cmd *cmdobj;
		struct kgsl_context *context;

		if (adreno_gpu_fault(adreno_dev) != 0)
			break;

		spin_lock(&drawctxt->lock);
		drawobj = _process_drawqueue_get_next_drawobj(drawctxt);


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:657 [MATCH: spin_unlock] ---
		/*
		 * adreno_context_get_drawobj returns -EAGAIN if the current
		 * drawobj has pending sync points so no more to do here.
		 * When the sync points are satisfied then the context will get
		 * reqeueued
		 */

		if (IS_ERR_OR_NULL(drawobj)) {
			if (IS_ERR(drawobj))
				ret = PTR_ERR(drawobj);
			spin_unlock(&drawctxt->lock);
			break;
		}
		_pop_drawobj(drawctxt);
		spin_unlock(&drawctxt->lock);

		timestamp = drawobj->timestamp;
		cmdobj = CMDOBJ(drawobj);
		context = drawobj->context;
		trace_adreno_cmdbatch_ready(context->id, context->priority,
			drawobj->timestamp, cmdobj->requeue_cnt);
		ret = sendcmd(adreno_dev, cmdobj);

		/*
		 * On error from sendcmd() try to requeue the cmdobj
		 * unless we got back -ENOENT which means that the context has
		 * been detached and there will be no more deliveries from here
		 */
		if (ret != 0) {

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:661 [MATCH: spin_unlock] ---
		 * reqeueued
		 */

		if (IS_ERR_OR_NULL(drawobj)) {
			if (IS_ERR(drawobj))
				ret = PTR_ERR(drawobj);
			spin_unlock(&drawctxt->lock);
			break;
		}
		_pop_drawobj(drawctxt);
		spin_unlock(&drawctxt->lock);

		timestamp = drawobj->timestamp;
		cmdobj = CMDOBJ(drawobj);
		context = drawobj->context;
		trace_adreno_cmdbatch_ready(context->id, context->priority,
			drawobj->timestamp, cmdobj->requeue_cnt);
		ret = sendcmd(adreno_dev, cmdobj);

		/*
		 * On error from sendcmd() try to requeue the cmdobj
		 * unless we got back -ENOENT which means that the context has
		 * been detached and there will be no more deliveries from here
		 */
		if (ret != 0) {
			/* Destroy the cmdobj on -ENOENT */
			if (ret == -ENOENT)
				kgsl_drawobj_destroy(drawobj);
			else {

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:850 [MATCH: spin_unlock] ---

		if (!adreno_drawqueue_is_empty(drawqueue))
			mod_timer(&dispatcher->timer, drawqueue->expires);
	}
}

static inline void _decrement_submit_now(struct kgsl_device *device)
{
	spin_lock(&device->submit_lock);
	device->submit_now--;
	spin_unlock(&device->submit_lock);
}

/**
 * adreno_dispatcher_issuecmds() - Issue commmands from pending contexts
 * @adreno_dev: Pointer to the adreno device struct
 *
 * Lock the dispatcher and call _adreno_dispatcher_issueibcmds
 */
static void adreno_dispatcher_issuecmds(struct adreno_device *adreno_dev)
{
	struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher;
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	spin_lock(&device->submit_lock);
	/* If state is not ACTIVE, schedule the work for later */
	if (device->skip_inline_submit) {
		spin_unlock(&device->submit_lock);
		goto done;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:867 [MATCH: spin_unlock] ---
 * Lock the dispatcher and call _adreno_dispatcher_issueibcmds
 */
static void adreno_dispatcher_issuecmds(struct adreno_device *adreno_dev)
{
	struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher;
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	spin_lock(&device->submit_lock);
	/* If state is not ACTIVE, schedule the work for later */
	if (device->skip_inline_submit) {
		spin_unlock(&device->submit_lock);
		goto done;
	}
	device->submit_now++;
	spin_unlock(&device->submit_lock);

	/* If the dispatcher is busy then schedule the work for later */
	if (!mutex_trylock(&dispatcher->mutex)) {
		_decrement_submit_now(device);
		goto done;
	}

	_adreno_dispatcher_issuecmds(adreno_dev);

	if (dispatcher->inflight)
		_dispatcher_update_timers(adreno_dev);

	mutex_unlock(&dispatcher->mutex);
	_decrement_submit_now(device);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:871 [MATCH: spin_unlock] ---
	struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher;
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	spin_lock(&device->submit_lock);
	/* If state is not ACTIVE, schedule the work for later */
	if (device->skip_inline_submit) {
		spin_unlock(&device->submit_lock);
		goto done;
	}
	device->submit_now++;
	spin_unlock(&device->submit_lock);

	/* If the dispatcher is busy then schedule the work for later */
	if (!mutex_trylock(&dispatcher->mutex)) {
		_decrement_submit_now(device);
		goto done;
	}

	_adreno_dispatcher_issuecmds(adreno_dev);

	if (dispatcher->inflight)
		_dispatcher_update_timers(adreno_dev);

	mutex_unlock(&dispatcher->mutex);
	_decrement_submit_now(device);
	return;
done:
	adreno_scheduler_queue(adreno_dev);
}

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1008 [MATCH: spin_unlock] ---
	int ret = 0;

	/*
	 * There is always a possibility that dispatcher may end up pushing
	 * the last popped draw object back to the context drawqueue. Hence,
	 * we can only queue up to _context_drawqueue_size - 1 here to make
	 * sure we never let drawqueue->queued exceed _context_drawqueue_size.
	 */
	if ((drawctxt->queued + count) > (_context_drawqueue_size - 1)) {
		trace_adreno_drawctxt_sleep(drawctxt);
		spin_unlock(&drawctxt->lock);

		ret = wait_event_interruptible_timeout(drawctxt->wq,
			_check_context_queue(drawctxt, count),
			msecs_to_jiffies(_context_queue_wait));

		spin_lock(&drawctxt->lock);
		trace_adreno_drawctxt_wake(drawctxt);

		/*
		 * Account for the possibility that the context got invalidated
		 * while we were sleeping
		 */
		if (ret > 0)
			ret = kgsl_check_context_state(&drawctxt->base);
		else if (ret == 0)
			ret = -ETIMEDOUT;
	}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1217 [MATCH: spin_unlock] ---
	job = kmem_cache_alloc(jobs_cache, GFP_KERNEL);
	if (!job)
		return -ENOMEM;

	job->drawctxt = drawctxt;

	spin_lock(&drawctxt->lock);

	ret = _check_context_state_to_queue_cmds(drawctxt, count);
	if (ret) {
		spin_unlock(&drawctxt->lock);
		kmem_cache_free(jobs_cache, job);
		return ret;
	}

	user_ts = *timestamp;

	/*
	 * If there is only one drawobj in the array and it is of
	 * type SYNCOBJ_TYPE, skip comparing user_ts as it can be 0
	 */
	if (!(count == 1 && drawobj[0]->type == SYNCOBJ_TYPE) &&
		(drawctxt->base.flags & KGSL_CONTEXT_USER_GENERATED_TS)) {
		/*
		 * User specified timestamps need to be greater than the last
		 * issued timestamp in the context
		 */
		if (timestamp_cmp(drawctxt->timestamp, user_ts) >= 0) {
			spin_unlock(&drawctxt->lock);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1235 [MATCH: spin_unlock] ---
	 * If there is only one drawobj in the array and it is of
	 * type SYNCOBJ_TYPE, skip comparing user_ts as it can be 0
	 */
	if (!(count == 1 && drawobj[0]->type == SYNCOBJ_TYPE) &&
		(drawctxt->base.flags & KGSL_CONTEXT_USER_GENERATED_TS)) {
		/*
		 * User specified timestamps need to be greater than the last
		 * issued timestamp in the context
		 */
		if (timestamp_cmp(drawctxt->timestamp, user_ts) >= 0) {
			spin_unlock(&drawctxt->lock);
			kmem_cache_free(jobs_cache, job);
			return -ERANGE;
		}
	}

	for (i = 0; i < count; i++) {

		switch (drawobj[i]->type) {
		case MARKEROBJ_TYPE:
			ret = drawctxt_queue_markerobj(adreno_dev, drawctxt,
				drawobj[i], timestamp, user_ts);
			if (ret) {
				spin_unlock(&drawctxt->lock);
				kmem_cache_free(jobs_cache, job);
			}

			if (ret == 1)
				goto done;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1248 [MATCH: spin_unlock] ---
		}
	}

	for (i = 0; i < count; i++) {

		switch (drawobj[i]->type) {
		case MARKEROBJ_TYPE:
			ret = drawctxt_queue_markerobj(adreno_dev, drawctxt,
				drawobj[i], timestamp, user_ts);
			if (ret) {
				spin_unlock(&drawctxt->lock);
				kmem_cache_free(jobs_cache, job);
			}

			if (ret == 1)
				goto done;
			else if (ret)
				return ret;
			break;
		case CMDOBJ_TYPE:
			ret = drawctxt_queue_cmdobj(adreno_dev, drawctxt,
				drawobj[i], timestamp, user_ts);
			if (ret) {
				spin_unlock(&drawctxt->lock);
				kmem_cache_free(jobs_cache, job);
				return ret;
			}
			break;
		case SYNCOBJ_TYPE:

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1261 [MATCH: spin_unlock] ---

			if (ret == 1)
				goto done;
			else if (ret)
				return ret;
			break;
		case CMDOBJ_TYPE:
			ret = drawctxt_queue_cmdobj(adreno_dev, drawctxt,
				drawobj[i], timestamp, user_ts);
			if (ret) {
				spin_unlock(&drawctxt->lock);
				kmem_cache_free(jobs_cache, job);
				return ret;
			}
			break;
		case SYNCOBJ_TYPE:
			drawctxt_queue_syncobj(drawctxt, drawobj[i], timestamp);
			break;
		case BINDOBJ_TYPE:
			ret = drawctxt_queue_bindobj(drawctxt, drawobj[i],
				timestamp, user_ts);
			if (ret) {
				spin_unlock(&drawctxt->lock);
				kmem_cache_free(jobs_cache, job);
				return ret;
			}
			break;
		case TIMELINEOBJ_TYPE:
			drawctxt_queue_timelineobj(drawctxt, drawobj[i]);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1273 [MATCH: spin_unlock] ---
				return ret;
			}
			break;
		case SYNCOBJ_TYPE:
			drawctxt_queue_syncobj(drawctxt, drawobj[i], timestamp);
			break;
		case BINDOBJ_TYPE:
			ret = drawctxt_queue_bindobj(drawctxt, drawobj[i],
				timestamp, user_ts);
			if (ret) {
				spin_unlock(&drawctxt->lock);
				kmem_cache_free(jobs_cache, job);
				return ret;
			}
			break;
		case TIMELINEOBJ_TYPE:
			drawctxt_queue_timelineobj(drawctxt, drawobj[i]);
			break;
		default:
			spin_unlock(&drawctxt->lock);
			kmem_cache_free(jobs_cache, job);
			return -EINVAL;
		}

	}

	dispatch_q = &(ADRENO_CONTEXT(drawobj[0]->context)->rb->dispatch_q);

	adreno_track_context(adreno_dev, dispatch_q, drawctxt);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1282 [MATCH: spin_unlock] ---
			if (ret) {
				spin_unlock(&drawctxt->lock);
				kmem_cache_free(jobs_cache, job);
				return ret;
			}
			break;
		case TIMELINEOBJ_TYPE:
			drawctxt_queue_timelineobj(drawctxt, drawobj[i]);
			break;
		default:
			spin_unlock(&drawctxt->lock);
			kmem_cache_free(jobs_cache, job);
			return -EINVAL;
		}

	}

	dispatch_q = &(ADRENO_CONTEXT(drawobj[0]->context)->rb->dispatch_q);

	adreno_track_context(adreno_dev, dispatch_q, drawctxt);

	spin_unlock(&drawctxt->lock);

	/* Add the context to the dispatcher pending list */
	if (_kgsl_context_get(&drawctxt->base)) {
		trace_dispatch_queue_context(drawctxt);
		llist_add(&job->node,
			&adreno_dev->dispatcher.jobs[drawctxt->base.priority]);
	} else {

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.c:1293 [MATCH: spin_unlock] ---
			kmem_cache_free(jobs_cache, job);
			return -EINVAL;
		}

	}

	dispatch_q = &(ADRENO_CONTEXT(drawobj[0]->context)->rb->dispatch_q);

	adreno_track_context(adreno_dev, dispatch_q, drawctxt);

	spin_unlock(&drawctxt->lock);

	/* Add the context to the dispatcher pending list */
	if (_kgsl_context_get(&drawctxt->base)) {
		trace_dispatch_queue_context(drawctxt);
		llist_add(&job->node,
			&adreno_dev->dispatcher.jobs[drawctxt->base.priority]);
	} else {
		kmem_cache_free(jobs_cache, job);
		goto done;
	}

	/*
	 * Only issue commands if inflight is less than burst -this prevents us
	 * from sitting around waiting for the mutex on a busy system - the work
	 * loop will schedule it for us. Inflight is mutex protected but the
	 * worse that can happen is that it will go to 0 after we check and if
	 * it goes to 0 it is because the work loop decremented it and the work
	 * queue will try to schedule new commands anyway.

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_dispatch.h:14 [MATCH: timeout] ---
 * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
 */

#ifndef ____ADRENO_DISPATCHER_H
#define ____ADRENO_DISPATCHER_H

#include <linux/kobject.h>
#include <linux/kthread.h>
#include <linux/llist.h>

extern unsigned int adreno_drawobj_timeout;

/*
 * Maximum size of the dispatcher ringbuffer - the actual inflight size will be
 * smaller then this but this size will allow for a larger range of inflight
 * sizes that can be chosen at runtime
 */

#define ADRENO_DISPATCH_DRAWQUEUE_SIZE 128

#define DRAWQUEUE_NEXT(_i, _s) (((_i) + 1) % (_s))

/**
 * struct adreno_dispatcher_drawqueue - List of commands for a RB level
 * @cmd_q: List of command obj's submitted to dispatcher
 * @inflight: Number of commands inflight in this q
 * @head: Head pointer to the q
 * @tail: Queues tail pointer
 * @active_context_count: Number of active contexts seen in this rb drawqueue

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_drawctxt.c:169 [MATCH: wait_event] ---
	if (ret)
		goto done;

	/*
	 * If timeout is 0, wait forever. msecs_to_jiffies will force
	 * values larger than INT_MAX to an infinite timeout.
	 */
	if (timeout == 0)
		timeout = UINT_MAX;

	ret_temp = wait_event_interruptible_timeout(drawctxt->waiting,
			_check_context_timestamp(device, context, timestamp),
			msecs_to_jiffies(timeout));

	if (ret_temp <= 0) {
		kgsl_cancel_event(device, &context->events, timestamp,
			wait_callback, (void *)drawctxt);

		ret = ret_temp ? (int)ret_temp : -ETIMEDOUT;
		goto done;
	}
	ret = 0;

	/* -EDEADLK if the context was invalidated while we were waiting */
	if (kgsl_context_invalid(context))
		ret = -EDEADLK;


	/* Return -EINVAL if the context was detached while we were waiting */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_drawctxt.c:581 [MATCH: wait_event] ---
				drawctxt->type, ret);

		adreno_set_gpu_fault(adreno_dev,
				ADRENO_CTX_DETATCH_TIMEOUT_FAULT);
		kgsl_mutex_unlock(&device->mutex);

		/* Schedule dispatcher to kick in recovery */
		adreno_scheduler_queue(adreno_dev);

		/* Wait for context to be invalidated and release context */
		wait_event_interruptible_timeout(drawctxt->timeout,
					kgsl_context_invalid(&drawctxt->base),
					msecs_to_jiffies(5000));
		return;
	}

	kgsl_sharedmem_writel(device->memstore,
			KGSL_MEMSTORE_OFFSET(context->id, soptimestamp),
			drawctxt->timestamp);

	kgsl_sharedmem_writel(device->memstore,
			KGSL_MEMSTORE_OFFSET(context->id, eoptimestamp),
			drawctxt->timestamp);

	adreno_profile_process_results(adreno_dev);

	kgsl_mutex_unlock(&device->mutex);
}


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_drawctxt.c:38 [MATCH: timeout] ---

	return kgsl_check_timestamp(device, context, timestamp);
}

/**
 * adreno_drawctxt_dump() - dump information about a draw context
 * @device: KGSL device that owns the context
 * @context: KGSL context to dump information about
 *
 * Dump specific information about the context to the kernel log.  Used for
 * fence timeout callbacks
 */
void adreno_drawctxt_dump(struct kgsl_device *device,
		struct kgsl_context *context)
{
	unsigned int queue, start, retire;
	struct adreno_context *drawctxt = ADRENO_CONTEXT(context);
	int index, pos;
	char buf[120];

	kgsl_readtimestamp(device, context, KGSL_TIMESTAMP_QUEUED, &queue);
	kgsl_readtimestamp(device, context, KGSL_TIMESTAMP_CONSUMED, &start);
	kgsl_readtimestamp(device, context, KGSL_TIMESTAMP_RETIRED, &retire);

	/*
	 * We may have kgsl sync obj timer running, which also uses same
	 * lock, take a lock with software interrupt disabled (bh)
	 * to avoid spin lock recursion.
	 *

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_drawctxt.c:134 [MATCH: timeout] ---
		context->id, buf);

	spin_unlock_bh(&drawctxt->lock);
}

/**
 * adreno_drawctxt_wait() - sleep until a timestamp expires
 * @adreno_dev: pointer to the adreno_device struct
 * @drawctxt: Pointer to the draw context to sleep for
 * @timetamp: Timestamp to wait on
 * @timeout: Number of jiffies to wait (0 for infinite)
 *
 * Register an event to wait for a timestamp on a context and sleep until it
 * has past.  Returns < 0 on error, -ETIMEDOUT if the timeout expires or 0
 * on success
 */
int adreno_drawctxt_wait(struct adreno_device *adreno_dev,
		struct kgsl_context *context,
		uint32_t timestamp, unsigned int timeout)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct adreno_context *drawctxt = ADRENO_CONTEXT(context);
	int ret;
	long ret_temp;

	if (kgsl_context_detached(context))
		return -ENOENT;

	if (kgsl_context_invalid(context))

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_drawctxt.c:137 [MATCH: timeout] ---
}

/**
 * adreno_drawctxt_wait() - sleep until a timestamp expires
 * @adreno_dev: pointer to the adreno_device struct
 * @drawctxt: Pointer to the draw context to sleep for
 * @timetamp: Timestamp to wait on
 * @timeout: Number of jiffies to wait (0 for infinite)
 *
 * Register an event to wait for a timestamp on a context and sleep until it
 * has past.  Returns < 0 on error, -ETIMEDOUT if the timeout expires or 0
 * on success
 */
int adreno_drawctxt_wait(struct adreno_device *adreno_dev,
		struct kgsl_context *context,
		uint32_t timestamp, unsigned int timeout)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct adreno_context *drawctxt = ADRENO_CONTEXT(context);
	int ret;
	long ret_temp;

	if (kgsl_context_detached(context))
		return -ENOENT;

	if (kgsl_context_invalid(context))
		return -EDEADLK;

	trace_adreno_drawctxt_wait_start(-1, context->id, timestamp);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_drawctxt.c:142 [MATCH: timeout] ---
 * @drawctxt: Pointer to the draw context to sleep for
 * @timetamp: Timestamp to wait on
 * @timeout: Number of jiffies to wait (0 for infinite)
 *
 * Register an event to wait for a timestamp on a context and sleep until it
 * has past.  Returns < 0 on error, -ETIMEDOUT if the timeout expires or 0
 * on success
 */
int adreno_drawctxt_wait(struct adreno_device *adreno_dev,
		struct kgsl_context *context,
		uint32_t timestamp, unsigned int timeout)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct adreno_context *drawctxt = ADRENO_CONTEXT(context);
	int ret;
	long ret_temp;

	if (kgsl_context_detached(context))
		return -ENOENT;

	if (kgsl_context_invalid(context))
		return -EDEADLK;

	trace_adreno_drawctxt_wait_start(-1, context->id, timestamp);

	ret = kgsl_add_event(device, &context->events, timestamp,
		wait_callback, (void *) drawctxt);
	if (ret)
		goto done;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_drawctxt.c:163 [MATCH: timeout] ---
		return -EDEADLK;

	trace_adreno_drawctxt_wait_start(-1, context->id, timestamp);

	ret = kgsl_add_event(device, &context->events, timestamp,
		wait_callback, (void *) drawctxt);
	if (ret)
		goto done;

	/*
	 * If timeout is 0, wait forever. msecs_to_jiffies will force
	 * values larger than INT_MAX to an infinite timeout.
	 */
	if (timeout == 0)
		timeout = UINT_MAX;

	ret_temp = wait_event_interruptible_timeout(drawctxt->waiting,
			_check_context_timestamp(device, context, timestamp),
			msecs_to_jiffies(timeout));

	if (ret_temp <= 0) {
		kgsl_cancel_event(device, &context->events, timestamp,
			wait_callback, (void *)drawctxt);

		ret = ret_temp ? (int)ret_temp : -ETIMEDOUT;
		goto done;
	}
	ret = 0;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_drawctxt.c:164 [MATCH: timeout] ---

	trace_adreno_drawctxt_wait_start(-1, context->id, timestamp);

	ret = kgsl_add_event(device, &context->events, timestamp,
		wait_callback, (void *) drawctxt);
	if (ret)
		goto done;

	/*
	 * If timeout is 0, wait forever. msecs_to_jiffies will force
	 * values larger than INT_MAX to an infinite timeout.
	 */
	if (timeout == 0)
		timeout = UINT_MAX;

	ret_temp = wait_event_interruptible_timeout(drawctxt->waiting,
			_check_context_timestamp(device, context, timestamp),
			msecs_to_jiffies(timeout));

	if (ret_temp <= 0) {
		kgsl_cancel_event(device, &context->events, timestamp,
			wait_callback, (void *)drawctxt);

		ret = ret_temp ? (int)ret_temp : -ETIMEDOUT;
		goto done;
	}
	ret = 0;

	/* -EDEADLK if the context was invalidated while we were waiting */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_drawctxt.c:166 [MATCH: timeout] ---

	ret = kgsl_add_event(device, &context->events, timestamp,
		wait_callback, (void *) drawctxt);
	if (ret)
		goto done;

	/*
	 * If timeout is 0, wait forever. msecs_to_jiffies will force
	 * values larger than INT_MAX to an infinite timeout.
	 */
	if (timeout == 0)
		timeout = UINT_MAX;

	ret_temp = wait_event_interruptible_timeout(drawctxt->waiting,
			_check_context_timestamp(device, context, timestamp),
			msecs_to_jiffies(timeout));

	if (ret_temp <= 0) {
		kgsl_cancel_event(device, &context->events, timestamp,
			wait_callback, (void *)drawctxt);

		ret = ret_temp ? (int)ret_temp : -ETIMEDOUT;
		goto done;
	}
	ret = 0;

	/* -EDEADLK if the context was invalidated while we were waiting */
	if (kgsl_context_invalid(context))
		ret = -EDEADLK;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_drawctxt.c:167 [MATCH: timeout] ---
	ret = kgsl_add_event(device, &context->events, timestamp,
		wait_callback, (void *) drawctxt);
	if (ret)
		goto done;

	/*
	 * If timeout is 0, wait forever. msecs_to_jiffies will force
	 * values larger than INT_MAX to an infinite timeout.
	 */
	if (timeout == 0)
		timeout = UINT_MAX;

	ret_temp = wait_event_interruptible_timeout(drawctxt->waiting,
			_check_context_timestamp(device, context, timestamp),
			msecs_to_jiffies(timeout));

	if (ret_temp <= 0) {
		kgsl_cancel_event(device, &context->events, timestamp,
			wait_callback, (void *)drawctxt);

		ret = ret_temp ? (int)ret_temp : -ETIMEDOUT;
		goto done;
	}
	ret = 0;

	/* -EDEADLK if the context was invalidated while we were waiting */
	if (kgsl_context_invalid(context))
		ret = -EDEADLK;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_drawctxt.c:171 [MATCH: timeout] ---

	/*
	 * If timeout is 0, wait forever. msecs_to_jiffies will force
	 * values larger than INT_MAX to an infinite timeout.
	 */
	if (timeout == 0)
		timeout = UINT_MAX;

	ret_temp = wait_event_interruptible_timeout(drawctxt->waiting,
			_check_context_timestamp(device, context, timestamp),
			msecs_to_jiffies(timeout));

	if (ret_temp <= 0) {
		kgsl_cancel_event(device, &context->events, timestamp,
			wait_callback, (void *)drawctxt);

		ret = ret_temp ? (int)ret_temp : -ETIMEDOUT;
		goto done;
	}
	ret = 0;

	/* -EDEADLK if the context was invalidated while we were waiting */
	if (kgsl_context_invalid(context))
		ret = -EDEADLK;


	/* Return -EINVAL if the context was detached while we were waiting */
	if (kgsl_context_detached(context))
		ret = -ENOENT;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_drawctxt.c:202 [MATCH: timeout] ---
	trace_adreno_drawctxt_wait_done(-1, context->id, timestamp, ret);
	return ret;
}

/**
 * adreno_drawctxt_wait_rb() - Wait for the last RB timestamp at which this
 * context submitted a command to the corresponding RB
 * @adreno_dev: The device on which the timestamp is active
 * @context: The context which subbmitted command to RB
 * @timestamp: The RB timestamp of last command submitted to RB by context
 * @timeout: Timeout value for the wait
 * Caller must hold the device mutex
 */
static int adreno_drawctxt_wait_rb(struct adreno_device *adreno_dev,
		struct kgsl_context *context,
		uint32_t timestamp, unsigned int timeout)
{
	struct adreno_context *drawctxt = ADRENO_CONTEXT(context);
	int ret = 0;

	/*
	 * If the context is invalid (OR) not submitted commands to GPU
	 * then return immediately - we may end up waiting for a timestamp
	 * that will never come
	 */
	if (kgsl_context_invalid(context) ||
			!test_bit(KGSL_CONTEXT_PRIV_SUBMITTED, &context->priv))
		goto done;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_drawctxt.c:207 [MATCH: timeout] ---
 * adreno_drawctxt_wait_rb() - Wait for the last RB timestamp at which this
 * context submitted a command to the corresponding RB
 * @adreno_dev: The device on which the timestamp is active
 * @context: The context which subbmitted command to RB
 * @timestamp: The RB timestamp of last command submitted to RB by context
 * @timeout: Timeout value for the wait
 * Caller must hold the device mutex
 */
static int adreno_drawctxt_wait_rb(struct adreno_device *adreno_dev,
		struct kgsl_context *context,
		uint32_t timestamp, unsigned int timeout)
{
	struct adreno_context *drawctxt = ADRENO_CONTEXT(context);
	int ret = 0;

	/*
	 * If the context is invalid (OR) not submitted commands to GPU
	 * then return immediately - we may end up waiting for a timestamp
	 * that will never come
	 */
	if (kgsl_context_invalid(context) ||
			!test_bit(KGSL_CONTEXT_PRIV_SUBMITTED, &context->priv))
		goto done;

	trace_adreno_drawctxt_wait_start(drawctxt->rb->id, context->id,
					timestamp);

	ret = adreno_ringbuffer_waittimestamp(drawctxt->rb, timestamp, timeout);
done:

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_drawctxt.c:224 [MATCH: timeout] ---
	 * then return immediately - we may end up waiting for a timestamp
	 * that will never come
	 */
	if (kgsl_context_invalid(context) ||
			!test_bit(KGSL_CONTEXT_PRIV_SUBMITTED, &context->priv))
		goto done;

	trace_adreno_drawctxt_wait_start(drawctxt->rb->id, context->id,
					timestamp);

	ret = adreno_ringbuffer_waittimestamp(drawctxt->rb, timestamp, timeout);
done:
	trace_adreno_drawctxt_wait_done(drawctxt->rb->id, context->id,
					timestamp, ret);
	return ret;
}

static int drawctxt_detach_drawobjs(struct adreno_context *drawctxt,
		struct kgsl_drawobj **list)
{
	int count = 0;

	while (drawctxt->drawqueue_head != drawctxt->drawqueue_tail) {
		struct kgsl_drawobj *drawobj =
			drawctxt->drawqueue[drawctxt->drawqueue_head];

		drawctxt->drawqueue_head = (drawctxt->drawqueue_head + 1) %
			ADRENO_CONTEXT_DRAWQUEUE_SIZE;


--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_drawctxt.c:300 [MATCH: timeout] ---
			list[i]->timestamp);
		kgsl_drawobj_destroy(list[i]);
	}

	/* Make sure all pending events are processed or cancelled */
	kgsl_flush_event_group(device, &context->events);

	/* Give the bad news to everybody waiting around */
	wake_up_all(&drawctxt->waiting);
	wake_up_all(&drawctxt->wq);
	wake_up_all(&drawctxt->timeout);
}

void adreno_drawctxt_set_guilty(struct kgsl_device *device,
		struct kgsl_context *context)
{
	if (!context)
		return;

	context->reset_status = KGSL_CTX_STAT_GUILTY_CONTEXT_RESET_EXT;

	adreno_drawctxt_invalidate(device, context);
}

u32 adreno_prepare_preib_preempt_scratch(struct adreno_device *adreno_dev,
		struct adreno_context *drawctxt, u32 *cmds)
{
	struct adreno_ringbuffer *rb = drawctxt->rb;
	u32 *cmds_orig = cmds;

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_drawctxt.c:475 [MATCH: timeout] ---

	drawctxt->base.flags = local;

	/* Always enable per-context timestamps */
	drawctxt->base.flags |= KGSL_CONTEXT_PER_CONTEXT_TS;
	drawctxt->type = (drawctxt->base.flags & KGSL_CONTEXT_TYPE_MASK)
		>> KGSL_CONTEXT_TYPE_SHIFT;
	spin_lock_init(&drawctxt->lock);
	init_waitqueue_head(&drawctxt->wq);
	init_waitqueue_head(&drawctxt->waiting);
	init_waitqueue_head(&drawctxt->timeout);

	/* If the priority is not set by user, set it for them */
	if ((drawctxt->base.flags & KGSL_CONTEXT_PRIORITY_MASK) ==
			KGSL_CONTEXT_PRIORITY_UNDEF)
		drawctxt->base.flags |= (KGSL_CONTEXT_PRIORITY_MED <<
				KGSL_CONTEXT_PRIORITY_SHIFT);

	/* Store the context priority */
	drawctxt->base.priority =
		(drawctxt->base.flags & KGSL_CONTEXT_PRIORITY_MASK) >>
		KGSL_CONTEXT_PRIORITY_SHIFT;

	/*
	 * Now initialize the common part of the context. This allocates the
	 * context id, and then possibly another thread could look it up.
	 * So we want all of our initializtion that doesn't require the context
	 * id to be done before this call.
	 */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_drawctxt.c:559 [MATCH: timeout] ---
	 * Wait for the last global timestamp to pass before continuing.
	 * The maxumum wait time is 30s, some large IB's can take longer
	 * than 10s and if hang happens then the time for the context's
	 * commands to retire will be greater than 10s. 30s should be sufficient
	 * time to wait for the commands even if a hang happens.
	 */
	ret = adreno_drawctxt_wait_rb(adreno_dev, &drawctxt->base,
		drawctxt->internal_timestamp, 30 * 1000);

	/*
	 * If the wait for global fails due to timeout then mark it as
	 * context detach timeout fault and schedule dispatcher to kick
	 * in GPU recovery. For a ADRENO_CTX_DETATCH_TIMEOUT_FAULT we clear
	 * the policy and invalidate the context. If EAGAIN error is returned
	 * then recovery will kick in and there will be no more commands in the
	 * RB pipe from this context which is what we are waiting for, so ignore
	 * -EAGAIN error.
	 */
	if (ret && ret != -EAGAIN) {
		dev_err(device->dev,
				"Wait for global ctx=%u ts=%u type=%d error=%d\n",
				drawctxt->base.id, drawctxt->internal_timestamp,
				drawctxt->type, ret);

		adreno_set_gpu_fault(adreno_dev,
				ADRENO_CTX_DETATCH_TIMEOUT_FAULT);
		kgsl_mutex_unlock(&device->mutex);

		/* Schedule dispatcher to kick in recovery */

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_drawctxt.c:560 [MATCH: timeout] ---
	 * The maxumum wait time is 30s, some large IB's can take longer
	 * than 10s and if hang happens then the time for the context's
	 * commands to retire will be greater than 10s. 30s should be sufficient
	 * time to wait for the commands even if a hang happens.
	 */
	ret = adreno_drawctxt_wait_rb(adreno_dev, &drawctxt->base,
		drawctxt->internal_timestamp, 30 * 1000);

	/*
	 * If the wait for global fails due to timeout then mark it as
	 * context detach timeout fault and schedule dispatcher to kick
	 * in GPU recovery. For a ADRENO_CTX_DETATCH_TIMEOUT_FAULT we clear
	 * the policy and invalidate the context. If EAGAIN error is returned
	 * then recovery will kick in and there will be no more commands in the
	 * RB pipe from this context which is what we are waiting for, so ignore
	 * -EAGAIN error.
	 */
	if (ret && ret != -EAGAIN) {
		dev_err(device->dev,
				"Wait for global ctx=%u ts=%u type=%d error=%d\n",
				drawctxt->base.id, drawctxt->internal_timestamp,
				drawctxt->type, ret);

		adreno_set_gpu_fault(adreno_dev,
				ADRENO_CTX_DETATCH_TIMEOUT_FAULT);
		kgsl_mutex_unlock(&device->mutex);

		/* Schedule dispatcher to kick in recovery */
		adreno_scheduler_queue(adreno_dev);

--- C:\Users\qwertyhorik\Desktop\Ios\GPU_TRANSFER_2026-11-26\external\qualcomm-kgsl\adreno_drawctxt.c:561 [MATCH: timeout] ---
	 * than 10s and if hang happens then the time for the context's
	 * commands to retire will be greater than 10s. 30s should be sufficient
	 * time to wait for the commands even if a hang happens.
	 */
	ret = adreno_drawctxt_wait_rb(adreno_dev, &drawctxt->base,
		drawctxt->internal_timestamp, 30 * 1000);

	/*
	 * If the wait for global fails due to timeout then mark it as
	 * context detach timeout fault and schedule dispatcher to kick
	 * in GPU recovery. For a ADRENO_CTX_DETATCH_TIMEOUT_FAULT we clear
	 * the policy and invalidate the context. If EAGAIN error is returned
	 * then recovery will kick in and there will be no more commands in the
	 * RB pipe from this context which is what we are waiting for, so ignore
	 * -EAGAIN error.
	 */
	if (ret && ret != -EAGAIN) {
		dev_err(device->dev,
				"Wait for global ctx=%u ts=%u type=%d error=%d\n",
				drawctxt->base.id, drawctxt->internal_timestamp,
				drawctxt->type, ret);

		adreno_set_gpu_fault(adreno_dev,
				ADRENO_CTX_DETATCH_TIMEOUT_FAULT);
		kgsl_mutex_unlock(&device->mutex);

		/* Schedule dispatcher to kick in recovery */
		adreno_scheduler_queue(adreno_dev);
