drm/msm: block commits during system suspend

Prevent the driver from accepting any user mode commits
while suspended. This is needed because the user space
may still be briefly active after the driver has entered
its suspend state.

CRs-Fixed: 2019307
Change-Id: Id5142914fece4bcc432ca90cc4a470216dd85a9e
Signed-off-by: Clarence Ip <cip@codeaurora.org>
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index e4a073e..499b57b 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -474,6 +474,7 @@
 
 	/* saved atomic state during system suspend */
 	struct drm_atomic_state *suspend_state;
+	bool suspend_block;
 
 	/* list of clients waiting for events */
 	struct list_head client_event_list;
@@ -510,6 +511,17 @@
 	return ((struct msm_drm_private *)dev->dev_private)->suspend_state != 0;
 }
 
+static inline bool msm_is_suspend_blocked(struct drm_device *dev)
+{
+	if (!dev || !dev->dev_private)
+		return false;
+
+	if (!msm_is_suspend_state(dev))
+		return false;
+
+	return ((struct msm_drm_private *)dev->dev_private)->suspend_block != 0;
+}
+
 int msm_atomic_commit(struct drm_device *dev,
 		struct drm_atomic_state *state, bool nonblock);