Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 76518d99 authored by Akhil P Oommen's avatar Akhil P Oommen Committed by Harshitha Sai Neelati
Browse files

msm: kgsl: Mark the scratch buffer as privileged



Mark the scratch buffer as privileged so that it can only be accessed by
GPU through the ringbuffer. To accomplish this, we need to:

1. Move the preemption data out of the scratch buffer.
2. Disable the shadow rptr feature.
3. Trigger RPTR update from GPU using a WHERE_AM_I packet.
4. Add support for the new ucode.

Change-Id: I9b388f55f53b69028b9bbb2306cb43fd1297c52f
Signed-off-by: default avatarAkhil P Oommen <akhilpo@codeaurora.org>
Signed-off-by: default avatarArchana Sriram <apsrir@codeaurora.org>
Signed-off-by: default avatarHarshitha Sai Neelati <hsaine@codeaurora.org>
parent dce3eda4
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
/* Copyright (c) 2002,2007-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2002,2007-2018,2020, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -3818,6 +3818,19 @@ static void adreno_gpu_model(struct kgsl_device *device, char *str,
			 ADRENO_CHIPID_PATCH(adreno_dev->chipid) + 1);
}

u32 adreno_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);
}

static const struct kgsl_functable adreno_functable = {
	/* Mandatory functions */
	.regread = adreno_regread,
+5 −4
Original line number Diff line number Diff line
/* Copyright (c) 2008-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2008-2018,2020, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -277,8 +277,8 @@ enum adreno_preempt_states {
/**
 * struct adreno_preemption
 * @state: The current state of preemption
 * @counters: Memory descriptor for the memory where the GPU writes the
 * preemption counters on switch
 * @scratch: Memory descriptor for the memory where the GPU writes the
 * current ctxt record address and preemption counters on switch
 * @timer: A timer to make sure preemption doesn't stall
 * @work: A work struct for the preemption worker (for 5XX)
 * @token_submit: Indicates if a preempt token has been submitted in
@@ -290,7 +290,7 @@ enum adreno_preempt_states {
 */
struct adreno_preemption {
	atomic_t state;
	struct kgsl_memdesc counters;
	struct kgsl_memdesc scratch;
	struct timer_list timer;
	struct work_struct work;
	bool token_submit;
@@ -1178,6 +1178,7 @@ void adreno_cx_misc_regrmw(struct adreno_device *adreno_dev,
		unsigned int offsetwords,
		unsigned int mask, unsigned int bits);

u32 adreno_get_ucode_version(const u32 *data);

#define ADRENO_TARGET(_name, _id) \
static inline int adreno_is_##_name(struct adreno_device *adreno_dev) \
+9 −6
Original line number Diff line number Diff line
/* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2018,2020, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -2168,12 +2168,15 @@ static int a5xx_post_start(struct adreno_device *adreno_dev)
		*cmds++ = 0xF;
	}

	if (adreno_is_preemption_enabled(adreno_dev))
	if (adreno_is_preemption_enabled(adreno_dev)) {
		cmds += _preemption_init(adreno_dev, rb, cmds, NULL);

		rb->_wptr = rb->_wptr - (42 - (cmds - start));

		ret = adreno_ringbuffer_submit_spin_nosync(rb, NULL, 2000);
	} else {
		rb->_wptr = rb->_wptr - (42 - (cmds - start));
		ret = adreno_ringbuffer_submit_spin(rb, NULL, 2000);
	}

	if (ret)
		adreno_spin_idle_debug(adreno_dev,
				"hw initialization failed to idle\n");
@@ -2511,7 +2514,7 @@ static int _load_firmware(struct kgsl_device *device, const char *fwfile,

	memcpy(firmware->memdesc.hostptr, &fw->data[4], fw->size - 4);
	firmware->size = (fw->size - 4) / sizeof(uint32_t);
	firmware->version = *(unsigned int *)&fw->data[4];
	firmware->version = adreno_get_ucode_version((u32 *)fw->data);

done:
	release_firmware(fw);
+2 −2
Original line number Diff line number Diff line
/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2017,2020, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -112,7 +112,7 @@ void a5xx_crashdump_init(struct adreno_device *adreno_dev);

void a5xx_hwcg_set(struct adreno_device *adreno_dev, bool on);

#define A5XX_CP_RB_CNTL_DEFAULT (((ilog2(4) << 8) & 0x1F00) | \
#define A5XX_CP_RB_CNTL_DEFAULT ((1 << 27) | ((ilog2(4) << 8) & 0x1F00) | \
		(ilog2(KGSL_RB_DWORDS >> 1) & 0x3F))
/* GPMU interrupt multiplexor */
#define FW_INTR_INFO			(0)
+4 −4
Original line number Diff line number Diff line
/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2017,2020, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -575,7 +575,7 @@ static void a5xx_preemption_close(struct kgsl_device *device)
	unsigned int i;

	del_timer(&preempt->timer);
	kgsl_free_global(device, &preempt->counters);
	kgsl_free_global(device, &preempt->scratch);
	a5xx_preemption_iommu_close(adreno_dev);

	FOR_EACH_RINGBUFFER(adreno_dev, rb, i) {
@@ -602,14 +602,14 @@ int a5xx_preemption_init(struct adreno_device *adreno_dev)
		(unsigned long) adreno_dev);

	/* Allocate mem for storing preemption counters */
	ret = kgsl_allocate_global(device, &preempt->counters,
	ret = kgsl_allocate_global(device, &preempt->scratch,
		adreno_dev->num_ringbuffers *
		A5XX_CP_CTXRECORD_PREEMPTION_COUNTER_SIZE, 0, 0,
		"preemption_counters");
	if (ret)
		goto err;

	addr = preempt->counters.gpuaddr;
	addr = preempt->scratch.gpuaddr;

	/* Allocate mem for storing preemption switch record */
	FOR_EACH_RINGBUFFER(adreno_dev, rb, i) {
Loading