The test runs a worker thread and verifies that it did something.
However, the worker frees up the object that the 'did something' check
inspects.

The check is actually looking at a bool inside a different object (the
work queue) but using the work item object to get there. So just save
a pointer to the queue object and use that in the test.

Signed-off-by: John Harrison <[email protected]>
---
 .../drm/amd/display/amdgpu_dm/tests/amdgpu_dm_irq_test.c  | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_irq_test.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_irq_test.c
index 6e599657dac1..ee96ddb9669c 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_irq_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_irq_test.c
@@ -2363,6 +2363,7 @@ static void dm_test_hpd_rx_offload_work_in_reset(struct 
kunit *test)
  */
 static void dm_test_hpd_rx_offload_work_msg_rdy(struct kunit *test)
 {
+       struct hpd_rx_irq_offload_work_queue *offload_wq;
        struct hpd_rx_irq_offload_work *offload_work;
        struct amdgpu_dm_connector *aconn;
        struct link_service *link_srv;
@@ -2384,9 +2385,14 @@ static void dm_test_hpd_rx_offload_work_msg_rdy(struct 
kunit *test)
        offload_work->offload_wq->is_handling_mst_msg_rdy_event = true;
        offload_work->data.bytes.device_service_irq.bits.UP_REQ_MSG_RDY = 1;
 
+       /* NB: offload_work is freed by dm_handle_hpd_rx_offload_work so need to
+        * save a pointer to the wq to do the final KUNIT_EXPECT. This is safe
+        * because the wq is actually a kunit_alloc and is not freed along with
+        * the offload_work object. */
+       offload_wq = offload_work->offload_wq;
        dm_handle_hpd_rx_offload_work(&offload_work->work);
 
-       KUNIT_EXPECT_FALSE(test, 
offload_work->offload_wq->is_handling_mst_msg_rdy_event);
+       KUNIT_EXPECT_FALSE(test, offload_wq->is_handling_mst_msg_rdy_event);
 }
 
 /**
-- 
2.43.0

Reply via email to