Revert "Revert "msm: kgsl: Clear the interrupt immediately""

This reverts commit 9236e1d0b9c407aa02fcbbac10267690f66ad56a.

Change-Id: Ifd7609c8077832850ad94e59d959f9411e2440c9
diff --git a/drivers/gpu/msm/adreno.c b/drivers/gpu/msm/adreno.c
index 471b62d..886043c 100644
--- a/drivers/gpu/msm/adreno.c
+++ b/drivers/gpu/msm/adreno.c
@@ -593,6 +593,15 @@
 
 	adreno_readreg(adreno_dev, ADRENO_REG_RBBM_INT_0_STATUS, &status);
 
+	/*
+	 * Clear all the interrupt bits but A5XX_INT_RBBM_AHB_ERROR. Because
+	 * even if we clear it here, it will stay high until it is cleared
+	 * in its respective handler. Otherwise, the interrupt handler will
+	 * fire again.
+	 */
+	adreno_writereg(adreno_dev, ADRENO_REG_RBBM_INT_CLEAR_CMD,
+				status & ~BIT(A5XX_INT_RBBM_AHB_ERROR));
+
 	/* Loop through all set interrupts and call respective handlers */
 	for (tmp = status; tmp != 0;) {
 		i = fls(tmp) - 1;
@@ -611,9 +620,14 @@
 
 	gpudev->irq_trace(adreno_dev, status);
 
-	if (status)
+	/*
+	 * Clear A5XX_INT_RBBM_AHB_ERROR bit after this interrupt has been
+	 * cleared in its respective handler
+	 */
+	if (status & BIT(A5XX_INT_RBBM_AHB_ERROR))
 		adreno_writereg(adreno_dev, ADRENO_REG_RBBM_INT_CLEAR_CMD,
-				status);
+				BIT(A5XX_INT_RBBM_AHB_ERROR));
+
 	return ret;
 
 }