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

Commit 02f4f189 authored by Carter Cooper's avatar Carter Cooper
Browse files

msm: kgsl: Move GMU kmem inside GMU struct



Move kmem data so others outside of GMU can access easily.

Change-Id: Id2c61f1258099222903185232321e53d7f7f3e5e
Signed-off-by: default avatarCarter Cooper <ccooper@codeaurora.org>
parent a5fae981
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -503,7 +503,7 @@ static int load_gmu_fw(struct kgsl_device *device)
		if (blk->size == 0)
			continue;

		md = gmu_get_memdesc(blk->addr, blk->size);
		md = gmu_get_memdesc(gmu, blk->addr, blk->size);
		if (md == NULL) {
			dev_err(&gmu->pdev->dev,
					"No backing memory for 0x%8.8X\n",
+13 −15
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@

#define GMU_CONTEXT_USER		0
#define GMU_CONTEXT_KERNEL		1
#define GMU_KERNEL_ENTRIES		16

#define GMU_CM3_CFG_NONMASKINTR_SHIFT    9

@@ -65,8 +64,6 @@ struct gmu_iommu_context gmu_ctx[] = {
 * active SMMU entries of GMU kernel mode context. Each entry is assigned
 * a unique address inside GMU kernel mode address range.
 */
static struct gmu_memdesc gmu_kmem_entries[GMU_KERNEL_ENTRIES];
static unsigned long gmu_kmem_bitmap;
static unsigned int next_uncached_kernel_alloc;
static unsigned int next_uncached_user_alloc;

@@ -148,16 +145,17 @@ static int alloc_and_map(struct gmu_device *gmu, struct gmu_memdesc *md,
	return ret;
}

struct gmu_memdesc *gmu_get_memdesc(unsigned int addr, unsigned int size)
struct gmu_memdesc *gmu_get_memdesc(struct gmu_device *gmu,
		unsigned int addr, unsigned int size)
{
	int i;
	struct gmu_memdesc *mem;

	for (i = 0; i < GMU_KERNEL_ENTRIES; i++) {
		if (!test_bit(i, &gmu_kmem_bitmap))
		if (!test_bit(i, &gmu->kmem_bitmap))
			continue;

		mem = &gmu_kmem_entries[i];
		mem = &gmu->kmem_entries[i];

		if (addr >= mem->gmuaddr &&
				(addr + size <= mem->gmuaddr + mem->size))
@@ -180,7 +178,7 @@ static struct gmu_memdesc *allocate_gmu_kmem(struct gmu_device *gmu,
	struct gmu_memdesc *md;
	int ret;
	int entry_idx = find_first_zero_bit(
			&gmu_kmem_bitmap, GMU_KERNEL_ENTRIES);
			&gmu->kmem_bitmap, GMU_KERNEL_ENTRIES);

	if (entry_idx >= GMU_KERNEL_ENTRIES) {
		dev_err(&gmu->pdev->dev,
@@ -197,8 +195,8 @@ static struct gmu_memdesc *allocate_gmu_kmem(struct gmu_device *gmu,
		return ERR_PTR(-EINVAL);
	}

	md = &gmu_kmem_entries[entry_idx];
	set_bit(entry_idx, &gmu_kmem_bitmap);
	md = &gmu->kmem_entries[entry_idx];
	set_bit(entry_idx, &gmu->kmem_bitmap);

	memset(md, 0, sizeof(*md));

@@ -245,7 +243,7 @@ static struct gmu_memdesc *allocate_gmu_kmem(struct gmu_device *gmu,
		dev_err(&gmu->pdev->dev,
				"Invalid memory type (%d) requested\n",
				mem_type);
		clear_bit(entry_idx, &gmu_kmem_bitmap);
		clear_bit(entry_idx, &gmu->kmem_bitmap);
		return ERR_PTR(-EINVAL);
	}

@@ -255,7 +253,7 @@ static struct gmu_memdesc *allocate_gmu_kmem(struct gmu_device *gmu,

	ret = alloc_and_map(gmu, md, attrs);
	if (ret) {
		clear_bit(entry_idx, &gmu_kmem_bitmap);
		clear_bit(entry_idx, &gmu->kmem_bitmap);
		return ERR_PTR(ret);
	}

@@ -367,10 +365,10 @@ static void gmu_kmem_close(struct gmu_device *gmu)

	/* Unmap and free all memories in GMU kernel memory pool */
	for (i = 0; i < GMU_KERNEL_ENTRIES; i++) {
		if (!test_bit(i, &gmu_kmem_bitmap))
		if (!test_bit(i, &gmu->kmem_bitmap))
			continue;

		md = &gmu_kmem_entries[i];
		md = &gmu->kmem_entries[i];
		ctx = &gmu_ctx[md->ctx_idx];

		if (md->gmuaddr && md->mem_type != GMU_ITCM &&
@@ -379,7 +377,7 @@ static void gmu_kmem_close(struct gmu_device *gmu)

		free_gmu_mem(gmu, md);

		clear_bit(i, &gmu_kmem_bitmap);
		clear_bit(i, &gmu->kmem_bitmap);
	}

	/* Detach the device from SMMU context bank */
@@ -418,7 +416,7 @@ int gmu_prealloc_req(struct kgsl_device *device, struct gmu_block_header *blk)
	struct gmu_memdesc *md;

	/* Check to see if this memdesc is already around */
	md = gmu_get_memdesc(blk->addr, blk->value);
	md = gmu_get_memdesc(gmu, blk->addr, blk->value);
	if (md)
		return 0;

+7 −1
Original line number Diff line number Diff line
@@ -76,6 +76,9 @@ struct gmu_block_header {
/* For GMU Logs*/
#define LOGMEM_SIZE  SZ_4K

/* GMU memdesc entries */
#define GMU_KERNEL_ENTRIES		16

extern struct gmu_dev_ops adreno_a6xx_gmudev;
#define KGSL_GMU_DEVICE(_a)  ((struct gmu_device *)((_a)->gmu_core.ptr))

@@ -207,9 +210,12 @@ struct gmu_device {
	unsigned int fault_count;
	struct kgsl_mailbox mailbox;
	bool preallocations;
	struct gmu_memdesc kmem_entries[GMU_KERNEL_ENTRIES];
	unsigned long kmem_bitmap;
};

struct gmu_memdesc *gmu_get_memdesc(unsigned int addr, unsigned int size);
struct gmu_memdesc *gmu_get_memdesc(struct gmu_device *gmu,
		unsigned int addr, unsigned int size);
unsigned int gmu_get_memtype_base(enum gmu_mem_type type);

int gmu_prealloc_req(struct kgsl_device *device, struct gmu_block_header *blk);