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

Commit 6b16d08c authored by Kamal Agrawal's avatar Kamal Agrawal Committed by Hareesh Gundu
Browse files

msm: kgsl: Remove sysfs entries after releasing memory



Consider a scenario when device is in OOM situation. Assume a process is
doing sysfs operation, grabs kernfs_mutex and wants to allocate memory.
LMKD tries to kill processes but kgsl processes will be blocked waiting
for kernfs_mutex in sysfs_remove_file.

kgsl_process_private_close > kgsl_process_uninit_sysfs > sysfs_remove_file

KGSL won't free up memory as it is done after sysfs removal leading to a
livelock. Fix it by releasing memory before removing sysfs entries.

Change-Id: I99640d7a653faffa671d5b035abb78e9473da12e
Signed-off-by: default avatarKamal Agrawal <kamaagra@codeaurora.org>
parent f9416d64
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -1057,11 +1057,14 @@ static void kgsl_process_private_close(struct kgsl_device_private *dev_priv,
	 * directories and garbage collect any outstanding resources
	 */

	kgsl_process_uninit_sysfs(private);
	process_release_memory(private);

	/* Release all syncsource objects from process private */
	kgsl_syncsource_process_release_syncsources(private);

	debugfs_remove_recursive(private->debug_root);
	kgsl_process_uninit_sysfs(private);

	/* When using global pagetables, do not detach global pagetable */
	if (private->pagetable->name != KGSL_MMU_GLOBAL_PT)
		kgsl_mmu_detach_pagetable(private->pagetable);
@@ -1071,15 +1074,8 @@ static void kgsl_process_private_close(struct kgsl_device_private *dev_priv,
	list_del(&private->list);
	spin_unlock(&kgsl_driver.proclist_lock);

	debugfs_remove_recursive(private->debug_root);

	/*
	 * Unlock the mutex before releasing the memory - this prevents a
	 * deadlock with the IOMMU mutex if a page fault occurs.
	 */
	mutex_unlock(&kgsl_driver.process_mutex);

	process_release_memory(private);
	kgsl_process_private_put(private);
}