2022-08-23 18:24:10

by Jerry Snitselaar

[permalink] [raw]
Subject: [PATCH] idxd: avoid deadlock in process_misc_interrupts()

idxd_device_clear_state() now grabs the idxd->dev_lock
itself, so don't grab the lock prior to calling it.

This was seen in testing after dmar fault occurred on system,
resulting in lockup stack traces.

Cc: Fenghua Yu <[email protected]>
Cc: Dave Jiang <[email protected]>
Cc: Vinod Koul <[email protected]>
Cc: [email protected]
Signed-off-by: Jerry Snitselaar <[email protected]>
---
drivers/dma/idxd/irq.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/dma/idxd/irq.c b/drivers/dma/idxd/irq.c
index 743ead5ebc57..5b9921475be6 100644
--- a/drivers/dma/idxd/irq.c
+++ b/drivers/dma/idxd/irq.c
@@ -324,13 +324,11 @@ static int process_misc_interrupts(struct idxd_device *idxd, u32 cause)
idxd->state = IDXD_DEV_HALTED;
idxd_wqs_quiesce(idxd);
idxd_wqs_unmap_portal(idxd);
- spin_lock(&idxd->dev_lock);
idxd_device_clear_state(idxd);
dev_err(&idxd->pdev->dev,
"idxd halted, need %s.\n",
gensts.reset_type == IDXD_DEVICE_RESET_FLR ?
"FLR" : "system reset");
- spin_unlock(&idxd->dev_lock);
return -ENXIO;
}
}
--
2.37.2


2022-08-23 19:05:17

by Jerry Snitselaar

[permalink] [raw]
Subject: [PATCH v2] dmaengine: idxd: avoid deadlock in process_misc_interrupts()

idxd_device_clear_state() now grabs the idxd->dev_lock
itself, so don't grab the lock prior to calling it.

This was seen in testing after dmar fault occurred on system,
resulting in lockup stack traces.

Cc: Fenghua Yu <[email protected]>
Cc: Dave Jiang <[email protected]>
Cc: Vinod Koul <[email protected]>
Cc: [email protected]
Fixes: cf4ac3fef338 ("dmaengine: idxd: fix lockdep warning on device driver removal")
Signed-off-by: Jerry Snitselaar <[email protected]>
---
v2: add Fixes tag, and add subsystem to summary

drivers/dma/idxd/irq.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/dma/idxd/irq.c b/drivers/dma/idxd/irq.c
index 743ead5ebc57..5b9921475be6 100644
--- a/drivers/dma/idxd/irq.c
+++ b/drivers/dma/idxd/irq.c
@@ -324,13 +324,11 @@ static int process_misc_interrupts(struct idxd_device *idxd, u32 cause)
idxd->state = IDXD_DEV_HALTED;
idxd_wqs_quiesce(idxd);
idxd_wqs_unmap_portal(idxd);
- spin_lock(&idxd->dev_lock);
idxd_device_clear_state(idxd);
dev_err(&idxd->pdev->dev,
"idxd halted, need %s.\n",
gensts.reset_type == IDXD_DEVICE_RESET_FLR ?
"FLR" : "system reset");
- spin_unlock(&idxd->dev_lock);
return -ENXIO;
}
}
--
2.37.2

2022-09-04 17:15:00

by Vinod Koul

[permalink] [raw]
Subject: Re: [PATCH v2] dmaengine: idxd: avoid deadlock in process_misc_interrupts()

On 23-08-22, 09:37, Jerry Snitselaar wrote:
> idxd_device_clear_state() now grabs the idxd->dev_lock
> itself, so don't grab the lock prior to calling it.
>
> This was seen in testing after dmar fault occurred on system,
> resulting in lockup stack traces.

Applied, thanks

--
~Vinod

2022-12-12 18:51:17

by Fenghua Yu

[permalink] [raw]
Subject: RE: [PATCH] idxd: avoid deadlock in process_misc_interrupts()

Hi, Jerry,

> idxd_device_clear_state() now grabs the idxd->dev_lock itself, so don't grab the
> lock prior to calling it.
>
> This was seen in testing after dmar fault occurred on system, resulting in lockup
> stack traces.
>

Please add Fixes: cf4ac3fef338 ...

> Cc: Fenghua Yu <[email protected]>
> Cc: Dave Jiang <[email protected]>
> Cc: Vinod Koul <[email protected]>
> Cc: [email protected]
> Signed-off-by: Jerry Snitselaar <[email protected]>
> ---
> drivers/dma/idxd/irq.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/drivers/dma/idxd/irq.c b/drivers/dma/idxd/irq.c index
> 743ead5ebc57..5b9921475be6 100644
> --- a/drivers/dma/idxd/irq.c
> +++ b/drivers/dma/idxd/irq.c
> @@ -324,13 +324,11 @@ static int process_misc_interrupts(struct idxd_device
> *idxd, u32 cause)
> idxd->state = IDXD_DEV_HALTED;
> idxd_wqs_quiesce(idxd);
> idxd_wqs_unmap_portal(idxd);
> - spin_lock(&idxd->dev_lock);
> idxd_device_clear_state(idxd);
> dev_err(&idxd->pdev->dev,
> "idxd halted, need %s.\n",
> gensts.reset_type == IDXD_DEVICE_RESET_FLR ?
> "FLR" : "system reset");
> - spin_unlock(&idxd->dev_lock);
> return -ENXIO;
> }
> }
> --
> 2.37.2

Thanks.

-Fenghua

2022-12-12 20:14:20

by Jerry Snitselaar

[permalink] [raw]
Subject: Re: [PATCH] idxd: avoid deadlock in process_misc_interrupts()



> On Dec 12, 2022, at 11:47 AM, Yu, Fenghua <[email protected]> wrote:
>
> Hi, Jerry,
>
>> idxd_device_clear_state() now grabs the idxd->dev_lock itself, so don't grab the
>> lock prior to calling it.
>>
>> This was seen in testing after dmar fault occurred on system, resulting in lockup
>> stack traces.
>>
>
> Please add Fixes: cf4ac3fef338 ...
>
>> Cc: Fenghua Yu <[email protected]>
>> Cc: Dave Jiang <[email protected]>
>> Cc: Vinod Koul <[email protected]>
>> Cc: [email protected]
>> Signed-off-by: Jerry Snitselaar <[email protected]>
>> ---
>> drivers/dma/idxd/irq.c | 2 --
>> 1 file changed, 2 deletions(-)
>>
>> diff --git a/drivers/dma/idxd/irq.c b/drivers/dma/idxd/irq.c index
>> 743ead5ebc57..5b9921475be6 100644
>> --- a/drivers/dma/idxd/irq.c
>> +++ b/drivers/dma/idxd/irq.c
>> @@ -324,13 +324,11 @@ static int process_misc_interrupts(struct idxd_device
>> *idxd, u32 cause)
>> idxd->state = IDXD_DEV_HALTED;
>> idxd_wqs_quiesce(idxd);
>> idxd_wqs_unmap_portal(idxd);
>> - spin_lock(&idxd->dev_lock);
>> idxd_device_clear_state(idxd);
>> dev_err(&idxd->pdev->dev,
>> "idxd halted, need %s.\n",
>> gensts.reset_type == IDXD_DEVICE_RESET_FLR ?
>> "FLR" : "system reset");
>> - spin_unlock(&idxd->dev_lock);
>> return -ENXIO;
>> }
>> }
>> --
>> 2.37.2
>
> Thanks.
>
> -Fenghua
>

Hi Fenghua,

I think this was merged back in August. Not at my system to get the exact date.

Regards,
Jerry