Skip to content

Commit da32b28

Browse files
davejiangvinodkoul
authored andcommitted
dmaengine: idxd: cleanup workqueue config after disabling
After disabling a device, we should clean up the internal state for the wqs and zero out the configuration registers. Without doing so can cause issues when the user reprogram the wqs. Fixes: c52ca47 ("dmaengine: idxd: add configuration component of driver") Reported-by: Yixin Zhang <[email protected]> Signed-off-by: Dave Jiang <[email protected]> Tested-by: Yixin Zhang <[email protected]> Link: https://lore.kernel.org/r/159311264246.1198.11955791213681679428.stgit@djiang5-desk3.ch.intel.com Signed-off-by: Vinod Koul <[email protected]>
1 parent 5b78fac commit da32b28

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

drivers/dma/idxd/device.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,31 @@ void idxd_wq_unmap_portal(struct idxd_wq *wq)
320320
devm_iounmap(dev, wq->dportal);
321321
}
322322

323+
void idxd_wq_disable_cleanup(struct idxd_wq *wq)
324+
{
325+
struct idxd_device *idxd = wq->idxd;
326+
struct device *dev = &idxd->pdev->dev;
327+
int i, wq_offset;
328+
329+
lockdep_assert_held(&idxd->dev_lock);
330+
memset(&wq->wqcfg, 0, sizeof(wq->wqcfg));
331+
wq->type = IDXD_WQT_NONE;
332+
wq->size = 0;
333+
wq->group = NULL;
334+
wq->threshold = 0;
335+
wq->priority = 0;
336+
clear_bit(WQ_FLAG_DEDICATED, &wq->flags);
337+
memset(wq->name, 0, WQ_NAME_SIZE);
338+
339+
for (i = 0; i < 8; i++) {
340+
wq_offset = idxd->wqcfg_offset + wq->id * 32 + i * sizeof(u32);
341+
iowrite32(0, idxd->reg_base + wq_offset);
342+
dev_dbg(dev, "WQ[%d][%d][%#x]: %#x\n",
343+
wq->id, i, wq_offset,
344+
ioread32(idxd->reg_base + wq_offset));
345+
}
346+
}
347+
323348
/* Device control bits */
324349
static inline bool idxd_is_enabled(struct idxd_device *idxd)
325350
{

drivers/dma/idxd/idxd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ int idxd_wq_enable(struct idxd_wq *wq);
290290
int idxd_wq_disable(struct idxd_wq *wq);
291291
int idxd_wq_map_portal(struct idxd_wq *wq);
292292
void idxd_wq_unmap_portal(struct idxd_wq *wq);
293+
void idxd_wq_disable_cleanup(struct idxd_wq *wq);
293294

294295
/* submission */
295296
int idxd_submit_desc(struct idxd_wq *wq, struct idxd_desc *desc);

drivers/dma/idxd/sysfs.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,11 @@ static int idxd_config_bus_remove(struct device *dev)
315315
idxd_unregister_dma_device(idxd);
316316
spin_lock_irqsave(&idxd->dev_lock, flags);
317317
rc = idxd_device_disable(idxd);
318+
for (i = 0; i < idxd->max_wqs; i++) {
319+
struct idxd_wq *wq = &idxd->wqs[i];
320+
321+
idxd_wq_disable_cleanup(wq);
322+
}
318323
spin_unlock_irqrestore(&idxd->dev_lock, flags);
319324
module_put(THIS_MODULE);
320325
if (rc < 0)

0 commit comments

Comments
 (0)