Merge "msm: kgsl: Set the active context to null after MMU is stopped"
diff --git a/drivers/gpu/msm/adreno.c b/drivers/gpu/msm/adreno.c
index cd72043..8e5683f 100644
--- a/drivers/gpu/msm/adreno.c
+++ b/drivers/gpu/msm/adreno.c
@@ -1712,8 +1712,6 @@
 		}
 	}
 
-	adreno_set_active_ctxs_null(adreno_dev);
-
 	adreno_dispatcher_stop(adreno_dev);
 
 	adreno_ringbuffer_stop(adreno_dev);
@@ -1752,6 +1750,12 @@
 
 	kgsl_mmu_stop(&device->mmu);
 
+	/*
+	 * At this point, MMU is turned off so we can safely
+	 * destroy any pending contexts and their pagetables
+	 */
+	adreno_set_active_ctxs_null(adreno_dev);
+
 	clear_bit(ADRENO_DEVICE_STARTED, &adreno_dev->priv);
 
 	return 0;