[PATCH 5.15 050/124] dmaengine: idxd: skip clearing device context when device is read-only

From: Greg Kroah-Hartman
Date: Tue Apr 26 2022 - 05:07:54 EST

From: Dave Jiang <dave.jiang@xxxxxxxxx>

[ Upstream commit 1cd8e751d96c43ece3f6842ac2244a37d9332c3a ]

If the device shows up as read-only configuration, skip the clearing of the
state as the context must be preserved for device re-enable after being

Fixes: 0dcfe41e9a4c ("dmanegine: idxd: cleanup all device related bits after disabling device")
Reported-by: Tony Zhu <tony.zhu@xxxxxxxxx>
Tested-by: Tony Zhu <tony.zhu@xxxxxxxxx>
Signed-off-by: Dave Jiang <dave.jiang@xxxxxxxxx>
Link: https://lore.kernel.org/r/164971479479.2200566.13980022473526292759.stgit@xxxxxxxxxxxxxxxxxxxxxxxxxx
Signed-off-by: Vinod Koul <vkoul@xxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
drivers/dma/idxd/device.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/dma/idxd/device.c b/drivers/dma/idxd/device.c
index a67bafc596b7..e622245c9380 100644
--- a/drivers/dma/idxd/device.c
+++ b/drivers/dma/idxd/device.c
@@ -730,6 +730,9 @@ static void idxd_device_wqs_clear_state(struct idxd_device *idxd)

void idxd_device_clear_state(struct idxd_device *idxd)
+ if (!test_bit(IDXD_FLAG_CONFIGURABLE, &idxd->flags))
+ return;