diff mbox series

[v4,3/6] drm/tests: managed: Remove the waitqueue usage

Message ID 20240105101324.26811-4-michal.winiarski@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/managed: Add drmm_release_action | expand

Commit Message

Michał Winiarski Jan. 5, 2024, 10:13 a.m. UTC
DRM managed release (drm_managed_release) is called as part of devres
release (devres_release_all), which is not async.
The release action should have already been executed once
drm_kunit_helper_free_device exits, meaning that there's no need to use
a waitqueue - we can just inspect the "action_done" state directly.

Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
---
 drivers/gpu/drm/tests/drm_managed_test.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

Comments

Maxime Ripard Jan. 8, 2024, 10:45 a.m. UTC | #1
On Fri, Jan 05, 2024 at 11:13:21AM +0100, Michał Winiarski wrote:
> DRM managed release (drm_managed_release) is called as part of devres
> release (devres_release_all), which is not async.
> The release action should have already been executed once
> drm_kunit_helper_free_device exits, meaning that there's no need to use
> a waitqueue - we can just inspect the "action_done" state directly.
> 
> Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>

I disagree, nothing guarantees in the API that it will be executed right
away. Since it might be asynchronous (if something else holds a
reference for example), we need the workqueue.

Fortunately, it turns out that it's actually done right away, which also
means we'll never hit the timeout and thus never stall the test run.

Maxime
diff mbox series

Patch

diff --git a/drivers/gpu/drm/tests/drm_managed_test.c b/drivers/gpu/drm/tests/drm_managed_test.c
index 659af5abb8014..e4790ae838ba7 100644
--- a/drivers/gpu/drm/tests/drm_managed_test.c
+++ b/drivers/gpu/drm/tests/drm_managed_test.c
@@ -8,12 +8,8 @@ 
 
 #include <linux/device.h>
 
-/* Ought to be enough for anybody */
-#define TEST_TIMEOUT_MS	100
-
 struct managed_test_priv {
 	bool action_done;
-	wait_queue_head_t action_wq;
 };
 
 static void drm_action(struct drm_device *drm, void *ptr)
@@ -21,7 +17,6 @@  static void drm_action(struct drm_device *drm, void *ptr)
 	struct managed_test_priv *priv = ptr;
 
 	priv->action_done = true;
-	wake_up_interruptible(&priv->action_wq);
 }
 
 static void drm_test_managed_run_action(struct kunit *test)
@@ -33,7 +28,6 @@  static void drm_test_managed_run_action(struct kunit *test)
 
 	priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL);
 	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv);
-	init_waitqueue_head(&priv->action_wq);
 
 	dev = drm_kunit_helper_alloc_device(test);
 	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev);
@@ -50,9 +44,7 @@  static void drm_test_managed_run_action(struct kunit *test)
 	drm_dev_unregister(drm);
 	drm_kunit_helper_free_device(test, dev);
 
-	ret = wait_event_interruptible_timeout(priv->action_wq, priv->action_done,
-					       msecs_to_jiffies(TEST_TIMEOUT_MS));
-	KUNIT_EXPECT_GT(test, ret, 0);
+	KUNIT_EXPECT_TRUE(test, priv->action_done);
 }
 
 static struct kunit_case drm_managed_tests[] = {