summary refs log tree commit diff
path: root/drivers/gpu/drm/tiny
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2019-08-11 16:37:24 +0200
committerHans de Goede <hdegoede@redhat.com>2019-08-12 21:30:20 +0200
commit9b61db1aed5c62180a374ab4dd774d1625bdd8d4 (patch)
treeca8be2e79efbd0950489584c42d8547f97c93e63 /drivers/gpu/drm/tiny
parent4abfa2e4e74f22fff67d561d01f8e080b5b547be (diff)
downloadlinux-9b61db1aed5c62180a374ab4dd774d1625bdd8d4.tar.gz
drm: gm12u320: Do not take a mutex from a wait_event condition
I made the condition of the wait_event_timeout call in
gm12u320_fb_update_work a helper which takes a mutex to make sure
that any writes to fb_update.run or fb_update.fb from other CPU cores
are seen before the check is done.

This is not necessary as the wait_event helpers contain the necessary
barriers for this themselves.

More over it is harmfull since by the time the check is done the task
is no longer in the TASK_RUNNING state and calling mutex_lock while not
in task-running is not allowed, leading to this warning when the kernel
is build with some extra locking checks enabled:

[11947.450011] do not call blocking ops when !TASK_RUNNING; state=2 set at
               [<00000000e4306de6>] prepare_to_wait_event+0x61/0x190

This commit fixes this by dropping the helper and simply directly
checking the condition (without unnecessary locking) in the
wait_event_timeout call.

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190811143725.5951-1-hdegoede@redhat.com
Diffstat (limited to 'drivers/gpu/drm/tiny')
-rw-r--r--drivers/gpu/drm/tiny/gm12u320.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/drivers/gpu/drm/tiny/gm12u320.c b/drivers/gpu/drm/tiny/gm12u320.c
index 1fd6db52af92..aa4b46e47e19 100644
--- a/drivers/gpu/drm/tiny/gm12u320.c
+++ b/drivers/gpu/drm/tiny/gm12u320.c
@@ -342,17 +342,6 @@ unlock:
 	mutex_unlock(&gm12u320->fb_update.lock);
 }
 
-static int gm12u320_fb_update_ready(struct gm12u320_device *gm12u320)
-{
-	int ret;
-
-	mutex_lock(&gm12u320->fb_update.lock);
-	ret = !gm12u320->fb_update.run || gm12u320->fb_update.fb != NULL;
-	mutex_unlock(&gm12u320->fb_update.lock);
-
-	return ret;
-}
-
 static void gm12u320_fb_update_work(struct work_struct *work)
 {
 	struct gm12u320_device *gm12u320 =
@@ -426,7 +415,8 @@ static void gm12u320_fb_update_work(struct work_struct *work)
 		 * switches back to showing its logo.
 		 */
 		wait_event_timeout(gm12u320->fb_update.waitq,
-				   gm12u320_fb_update_ready(gm12u320),
+				   !gm12u320->fb_update.run ||
+					gm12u320->fb_update.fb != NULL,
 				   IDLE_TIMEOUT);
 	}
 	return;