From: Arun Iyengar <[email protected]>

panfrost_reset() masks the job interrupts without setting
PANFROST_COMP_BIT_JOB, so a running IRQ thread unmasks them. Use
panfrost_jm_suspend_irq() there.

Take job_lock around its mask and set_bit, and around the IRQ
thread's bit test and unmask: a thread that tested the bit before
could otherwise unmask after it, and the hard IRQ handler returns
IRQ_NONE without masking while the bit is set.

Fixes: 1d0cab5461d7 ("drm/panfrost: Make sure job interrupts are masked before 
resetting")
Cc: [email protected]
Reported-by: Sashiko <[email protected]>
Closes: 
https://sashiko.dev/#/patchset/[email protected]?part=8
Signed-off-by: Arun Iyengar <[email protected]>
---
v5: job_lock instead of a second mask write (Sashiko on v4). With a
test-only hold in the IRQ thread after its bit test and a job
interrupt pending, v4 unmasked after the reset's mask (100005
IRQ_NONE, IRQ disabled); v5 did not in 8 of 8 resets (3 IRQ_NONE in
all, at most one per reset).
v4: new (Sashiko on v3 08/14 and 13/14).
---
 drivers/gpu/drm/panfrost/panfrost_job.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c 
b/drivers/gpu/drm/panfrost/panfrost_job.c
index 74cc3dd02..ebdf16968 100644
--- a/drivers/gpu/drm/panfrost/panfrost_job.c
+++ b/drivers/gpu/drm/panfrost/panfrost_job.c
@@ -455,9 +455,11 @@ void panfrost_jm_enable_interrupts(struct panfrost_device 
*pfdev)
 
 void panfrost_jm_suspend_irq(struct panfrost_device *pfdev)
 {
+       spin_lock(&pfdev->js->job_lock);
+       job_write(pfdev, JOB_INT_MASK, 0);
        set_bit(PANFROST_COMP_BIT_JOB, pfdev->is_suspended);
+       spin_unlock(&pfdev->js->job_lock);
 
-       job_write(pfdev, JOB_INT_MASK, 0);
        synchronize_irq(pfdev->js->irq);
 }
 
@@ -696,8 +698,7 @@ panfrost_reset(struct panfrost_device *pfdev,
        /* Mask job interrupts and synchronize to make sure we won't be
         * interrupted during our reset.
         */
-       job_write(pfdev, JOB_INT_MASK, 0);
-       synchronize_irq(pfdev->js->irq);
+       panfrost_jm_suspend_irq(pfdev);
 
        spin_lock(&pfdev->js->job_lock);
        for (i = 0; i < NUM_JOB_SLOTS; i++) {
@@ -860,8 +861,10 @@ static irqreturn_t panfrost_jm_irq_handler_thread(int irq, 
void *data)
        panfrost_jm_handle_irqs(pfdev);
 
        /* Enable interrupts only if we're not about to get suspended */
+       spin_lock(&pfdev->js->job_lock);
        if (!test_bit(PANFROST_COMP_BIT_JOB, pfdev->is_suspended))
                job_write(pfdev, JOB_INT_MASK, ALL_JS_INT_MASK);
+       spin_unlock(&pfdev->js->job_lock);
 
        return IRQ_HANDLED;
 }

-- 
2.55.0


Reply via email to