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

Commit 1939da95 authored by Puranam V G Tejaswi's avatar Puranam V G Tejaswi
Browse files

msm: kgsl: correct per process stat maintenance



In functions like gpumem_alloc_entry(), per process
stats are updated after kgsl_mem_entry_attach_process()
returns success. But in case of failure, per process
stats are decremented, though they are not incremented.
Fix this by isolating stat updation from
kgsl_mem_entry_detach_process(). Also take into account
the memory from sparse allocations.

Change-Id: I6e2bc1880bdda15aa75d546d0dc3d34c63cd7dba
Signed-off-by: default avatarPuranam V G Tejaswi <pvgtejas@codeaurora.org>
parent 0ced5701
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -331,6 +331,10 @@ kgsl_mem_entry_destroy(struct kref *kref)
	/* pull out the memtype before the flags get cleared */
	memtype = kgsl_memdesc_usermem_type(&entry->memdesc);

	if (!(entry->memdesc.flags & KGSL_MEMFLAGS_SPARSE_VIRT))
		kgsl_process_sub_stats(entry->priv, memtype,
			entry->memdesc.size);

	/* Detach from process list */
	kgsl_mem_entry_detach_process(entry);

@@ -489,7 +493,6 @@ static void kgsl_mem_entry_detach_process(struct kgsl_mem_entry *entry)
	entry->id = 0;

	type = kgsl_memdesc_usermem_type(&entry->memdesc);
	entry->priv->stats[type].cur -= entry->memdesc.size;

	if (type != KGSL_MEM_ENTRY_ION)
		entry->priv->gpumem_mapped -= entry->memdesc.mapsize;
@@ -3675,6 +3678,10 @@ long kgsl_ioctl_sparse_phys_alloc(struct kgsl_device_private *dev_priv,
	param->id = entry->id;
	param->flags = entry->memdesc.flags;

	kgsl_process_add_stats(process,
			kgsl_memdesc_usermem_type(&entry->memdesc),
			entry->memdesc.size);

	trace_sparse_phys_alloc(entry->id, param->size, param->pagesize);
	kgsl_mem_entry_commit_process(entry);

+6 −0
Original line number Diff line number Diff line
@@ -550,6 +550,12 @@ static inline void kgsl_process_add_stats(struct kgsl_process_private *priv,
		priv->stats[type].max = priv->stats[type].cur;
}

static inline void kgsl_process_sub_stats(struct kgsl_process_private *priv,
	unsigned int type, uint64_t size)
{
	priv->stats[type].cur -= size;
}

static inline bool kgsl_is_register_offset(struct kgsl_device *device,
				unsigned int offsetwords)
{