Skip to content

Commit 53b2ee7

Browse files
davejiangvinodkoul
authored andcommitted
dmaengine: idxd: device cmd should use dedicated lock
Create a dedicated lock for device command operations. Put the device command operation under finer grained locking instead of using the idxd->dev_lock. Suggested-by: Sanjay Kumar <[email protected]> Signed-off-by: Dave Jiang <[email protected]> Link: https://lore.kernel.org/r/161894525685.3210132.16160045731436382560.stgit@djiang5-desk3.ch.intel.com Signed-off-by: Vinod Koul <[email protected]>
1 parent 5b0c68c commit 53b2ee7

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

drivers/dma/idxd/device.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -465,13 +465,13 @@ int idxd_device_init_reset(struct idxd_device *idxd)
465465
memset(&cmd, 0, sizeof(cmd));
466466
cmd.cmd = IDXD_CMD_RESET_DEVICE;
467467
dev_dbg(dev, "%s: sending reset for init.\n", __func__);
468-
spin_lock_irqsave(&idxd->dev_lock, flags);
468+
spin_lock_irqsave(&idxd->cmd_lock, flags);
469469
iowrite32(cmd.bits, idxd->reg_base + IDXD_CMD_OFFSET);
470470

471471
while (ioread32(idxd->reg_base + IDXD_CMDSTS_OFFSET) &
472472
IDXD_CMDSTS_ACTIVE)
473473
cpu_relax();
474-
spin_unlock_irqrestore(&idxd->dev_lock, flags);
474+
spin_unlock_irqrestore(&idxd->cmd_lock, flags);
475475
return 0;
476476
}
477477

@@ -494,10 +494,10 @@ static void idxd_cmd_exec(struct idxd_device *idxd, int cmd_code, u32 operand,
494494
cmd.operand = operand;
495495
cmd.int_req = 1;
496496

497-
spin_lock_irqsave(&idxd->dev_lock, flags);
497+
spin_lock_irqsave(&idxd->cmd_lock, flags);
498498
wait_event_lock_irq(idxd->cmd_waitq,
499499
!test_bit(IDXD_FLAG_CMD_RUNNING, &idxd->flags),
500-
idxd->dev_lock);
500+
idxd->cmd_lock);
501501

502502
dev_dbg(&idxd->pdev->dev, "%s: sending cmd: %#x op: %#x\n",
503503
__func__, cmd_code, operand);
@@ -511,9 +511,9 @@ static void idxd_cmd_exec(struct idxd_device *idxd, int cmd_code, u32 operand,
511511
* After command submitted, release lock and go to sleep until
512512
* the command completes via interrupt.
513513
*/
514-
spin_unlock_irqrestore(&idxd->dev_lock, flags);
514+
spin_unlock_irqrestore(&idxd->cmd_lock, flags);
515515
wait_for_completion(&done);
516-
spin_lock_irqsave(&idxd->dev_lock, flags);
516+
spin_lock_irqsave(&idxd->cmd_lock, flags);
517517
if (status) {
518518
*status = ioread32(idxd->reg_base + IDXD_CMDSTS_OFFSET);
519519
idxd->cmd_status = *status & GENMASK(7, 0);
@@ -522,7 +522,7 @@ static void idxd_cmd_exec(struct idxd_device *idxd, int cmd_code, u32 operand,
522522
__clear_bit(IDXD_FLAG_CMD_RUNNING, &idxd->flags);
523523
/* Wake up other pending commands */
524524
wake_up(&idxd->cmd_waitq);
525-
spin_unlock_irqrestore(&idxd->dev_lock, flags);
525+
spin_unlock_irqrestore(&idxd->cmd_lock, flags);
526526
}
527527

528528
int idxd_device_enable(struct idxd_device *idxd)
@@ -667,13 +667,13 @@ int idxd_device_release_int_handle(struct idxd_device *idxd, int handle,
667667

668668
dev_dbg(dev, "cmd: %u operand: %#x\n", IDXD_CMD_RELEASE_INT_HANDLE, operand);
669669

670-
spin_lock_irqsave(&idxd->dev_lock, flags);
670+
spin_lock_irqsave(&idxd->cmd_lock, flags);
671671
iowrite32(cmd.bits, idxd->reg_base + IDXD_CMD_OFFSET);
672672

673673
while (ioread32(idxd->reg_base + IDXD_CMDSTS_OFFSET) & IDXD_CMDSTS_ACTIVE)
674674
cpu_relax();
675675
status = ioread32(idxd->reg_base + IDXD_CMDSTS_OFFSET);
676-
spin_unlock_irqrestore(&idxd->dev_lock, flags);
676+
spin_unlock_irqrestore(&idxd->cmd_lock, flags);
677677

678678
if ((status & IDXD_CMDSTS_ERR_MASK) != IDXD_CMDSTS_SUCCESS) {
679679
dev_dbg(dev, "release int handle failed: %#x\n", status);

drivers/dma/idxd/idxd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ struct idxd_device {
204204
void __iomem *reg_base;
205205

206206
spinlock_t dev_lock; /* spinlock for device */
207+
spinlock_t cmd_lock; /* spinlock for device commands */
207208
struct completion *cmd_done;
208209
struct idxd_group **groups;
209210
struct idxd_wq **wqs;

drivers/dma/idxd/init.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ static struct idxd_device *idxd_alloc(struct pci_dev *pdev, struct idxd_driver_d
449449
}
450450

451451
spin_lock_init(&idxd->dev_lock);
452+
spin_lock_init(&idxd->cmd_lock);
452453

453454
return idxd;
454455
}

0 commit comments

Comments
 (0)