dmaengine: idxd: fix event log crash and memory leak on FLR
v2 cover dmaengine: idxd: fix event log crash and memory leak on FLR
v1->v2: add commit 52d2edea0d63c ("dmaengine: idxd: Fix crash when the event log is disabled")
Backport of two upstream fixes for the dmaengine idxd event log handling in drivers/dma/idxd/device.c. These fix a crash and a memory leak when the event log is disabled or a Function Level Reset (FLR) occurs.
Backport notes:
- Commit 8a5084ab3af8: The upstream fix also touches idxd_device_config_restore(), which does not exist in v6.6 (introduced in 6.14 via commit 6078a315aec1). Only the idxd_device_evl_free() NULL check portion was backported.
- Commit 2ea19af4a590: Clean cherry-pick, no conflicts.
Vinicius Costa Gomes (2):
dmaengine: idxd: Fix crash when the event log is disabled
dmaengine: idxd: Fix leaking event log memory
drivers/dma/idxd/device.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 1/2 dmaengine: idxd: Fix crash when the event log is disabled
From: Vinicius Costa Gomes <[email protected]>
[ Upstream commit 52d2edea0d63c935e82631e4b9e4a94eccf97b5b ]
If reporting errors to the event log is not supported by the hardware, and an error that causes Function Level Reset (FLR) is received, the driver will try to restore the event log even if it was not allocated.
Also, only try to free the event log if it was properly allocated.
[ Only the idxd_device_evl_free() NULL check portion was backported in v6.6. idxd_device_config_restore() does not exist in v6.6. It was introduced in 6.14. ]
--- drivers/dma/idxd/device.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/dma/idxd/device.c +3 -0
@@ -810,6 +810,9 @@ static void idxd_device_evl_free(struct idxd_device *idxd)struct device *dev = &idxd->pdev->dev;struct idxd_evl *evl = idxd->evl; +if (!evl) +return ; + gencfg.bits =ioread32 (idxd->reg_base +IDXD_GENCFG_OFFSET );if (!gencfg.evl_en)return ;
Signature · 1 line
2.43.0
PATCH v2 2/2 dmaengine: idxd: Fix leaking event log memory
In reply to Wenshan LanFrom: Vinicius Costa Gomes <[email protected]>
[ Upstream commit ee66bc29578391c9b48523dc9119af67bd5c7c0f ]
During the device remove process, the device is reset, causing the configuration registers to go back to their default state, which is zero. As the driver is checking if the event log support was enabled before deallocating, it will fail if a reset happened before.
Do not check if the support was enabled, the check for 'idxd->evl' being valid (only allocated if the HW capability is available) is enough.
--- drivers/dma/idxd/device.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/dma/idxd/device.c +0 -4
@@ -813,10 +813,6 @@ static void idxd_device_evl_free(struct idxd_device *idxd)if (!evl)return ; - gencfg.bits =ioread32 (idxd->reg_base +IDXD_GENCFG_OFFSET ); -if (!gencfg.evl_en) -return ; -mutex_lock (&evl->lock); gencfg.evl_en =0 ;iowrite32 (gencfg.bits, idxd->reg_base +IDXD_GENCFG_OFFSET );
Signature · 1 line
2.43.0
Sasha Levin
maintainerQuoted 8 lines
Changes since v1:
- Added prerequisite patch backporting52d2edea0d63("dmaengine:
idxd: Fix crash when the event log is disabled") so that theee66bc295783fix doesn't regress hardware without event-log support.
- Documented the partial backport of52d2edea0d63(theidxd_device_config_restore()hunk is dropped because that helper does not exist on 6.6).
Both patches queued for 6.6.y, thanks for the quick v2 turnaround.
--
Thanks,
Sasha