Skip to content

Commit cf84a4b

Browse files
davejiangvinodkoul
authored andcommitted
dmaengine: idxd: remove interrupt disable for dev_lock
The spinlock is not being used in hard interrupt context. There is no need to disable irq when acquiring the lock. The interrupt thread handler also is not in bottom half context, therefore we can also remove disabling of the bh. Convert all dev_lock acquisition to plain spin_lock() calls. Reviewed-by: Dan Williams <[email protected]> Signed-off-by: Dave Jiang <[email protected]> Link: https://lore.kernel.org/r/162984026772.1939166.11504067782824765879.stgit@djiang5-desk3.ch.intel.com Signed-off-by: Vinod Koul <[email protected]>
1 parent f9f4082 commit cf84a4b

File tree

4 files changed

+22
-32
lines changed

4 files changed

+22
-32
lines changed

drivers/dma/idxd/cdev.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,13 @@ static __poll_t idxd_cdev_poll(struct file *filp,
218218
struct idxd_user_context *ctx = filp->private_data;
219219
struct idxd_wq *wq = ctx->wq;
220220
struct idxd_device *idxd = wq->idxd;
221-
unsigned long flags;
222221
__poll_t out = 0;
223222

224223
poll_wait(filp, &wq->err_queue, wait);
225-
spin_lock_irqsave(&idxd->dev_lock, flags);
224+
spin_lock(&idxd->dev_lock);
226225
if (idxd->sw_err.valid)
227226
out = EPOLLIN | EPOLLRDNORM;
228-
spin_unlock_irqrestore(&idxd->dev_lock, flags);
227+
spin_unlock(&idxd->dev_lock);
229228

230229
return out;
231230
}

drivers/dma/idxd/device.c

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -341,19 +341,18 @@ int idxd_wq_set_pasid(struct idxd_wq *wq, int pasid)
341341
int rc;
342342
union wqcfg wqcfg;
343343
unsigned int offset;
344-
unsigned long flags;
345344

346345
rc = idxd_wq_disable(wq, false);
347346
if (rc < 0)
348347
return rc;
349348

350349
offset = WQCFG_OFFSET(idxd, wq->id, WQCFG_PASID_IDX);
351-
spin_lock_irqsave(&idxd->dev_lock, flags);
350+
spin_lock(&idxd->dev_lock);
352351
wqcfg.bits[WQCFG_PASID_IDX] = ioread32(idxd->reg_base + offset);
353352
wqcfg.pasid_en = 1;
354353
wqcfg.pasid = pasid;
355354
iowrite32(wqcfg.bits[WQCFG_PASID_IDX], idxd->reg_base + offset);
356-
spin_unlock_irqrestore(&idxd->dev_lock, flags);
355+
spin_unlock(&idxd->dev_lock);
357356

358357
rc = idxd_wq_enable(wq);
359358
if (rc < 0)
@@ -368,19 +367,18 @@ int idxd_wq_disable_pasid(struct idxd_wq *wq)
368367
int rc;
369368
union wqcfg wqcfg;
370369
unsigned int offset;
371-
unsigned long flags;
372370

373371
rc = idxd_wq_disable(wq, false);
374372
if (rc < 0)
375373
return rc;
376374

377375
offset = WQCFG_OFFSET(idxd, wq->id, WQCFG_PASID_IDX);
378-
spin_lock_irqsave(&idxd->dev_lock, flags);
376+
spin_lock(&idxd->dev_lock);
379377
wqcfg.bits[WQCFG_PASID_IDX] = ioread32(idxd->reg_base + offset);
380378
wqcfg.pasid_en = 0;
381379
wqcfg.pasid = 0;
382380
iowrite32(wqcfg.bits[WQCFG_PASID_IDX], idxd->reg_base + offset);
383-
spin_unlock_irqrestore(&idxd->dev_lock, flags);
381+
spin_unlock(&idxd->dev_lock);
384382

385383
rc = idxd_wq_enable(wq);
386384
if (rc < 0)
@@ -558,7 +556,6 @@ int idxd_device_disable(struct idxd_device *idxd)
558556
{
559557
struct device *dev = &idxd->pdev->dev;
560558
u32 status;
561-
unsigned long flags;
562559

563560
if (!idxd_is_enabled(idxd)) {
564561
dev_dbg(dev, "Device is not enabled\n");
@@ -574,22 +571,20 @@ int idxd_device_disable(struct idxd_device *idxd)
574571
return -ENXIO;
575572
}
576573

577-
spin_lock_irqsave(&idxd->dev_lock, flags);
574+
spin_lock(&idxd->dev_lock);
578575
idxd_device_clear_state(idxd);
579576
idxd->state = IDXD_DEV_DISABLED;
580-
spin_unlock_irqrestore(&idxd->dev_lock, flags);
577+
spin_unlock(&idxd->dev_lock);
581578
return 0;
582579
}
583580

584581
void idxd_device_reset(struct idxd_device *idxd)
585582
{
586-
unsigned long flags;
587-
588583
idxd_cmd_exec(idxd, IDXD_CMD_RESET_DEVICE, 0, NULL);
589-
spin_lock_irqsave(&idxd->dev_lock, flags);
584+
spin_lock(&idxd->dev_lock);
590585
idxd_device_clear_state(idxd);
591586
idxd->state = IDXD_DEV_DISABLED;
592-
spin_unlock_irqrestore(&idxd->dev_lock, flags);
587+
spin_unlock(&idxd->dev_lock);
593588
}
594589

595590
void idxd_device_drain_pasid(struct idxd_device *idxd, int pasid)
@@ -1164,7 +1159,6 @@ int __drv_enable_wq(struct idxd_wq *wq)
11641159
{
11651160
struct idxd_device *idxd = wq->idxd;
11661161
struct device *dev = &idxd->pdev->dev;
1167-
unsigned long flags;
11681162
int rc = -ENXIO;
11691163

11701164
lockdep_assert_held(&wq->wq_lock);
@@ -1216,10 +1210,10 @@ int __drv_enable_wq(struct idxd_wq *wq)
12161210
}
12171211

12181212
rc = 0;
1219-
spin_lock_irqsave(&idxd->dev_lock, flags);
1213+
spin_lock(&idxd->dev_lock);
12201214
if (test_bit(IDXD_FLAG_CONFIGURABLE, &idxd->flags))
12211215
rc = idxd_device_config(idxd);
1222-
spin_unlock_irqrestore(&idxd->dev_lock, flags);
1216+
spin_unlock(&idxd->dev_lock);
12231217
if (rc < 0) {
12241218
dev_dbg(dev, "Writing wq %d config failed: %d\n", wq->id, rc);
12251219
goto err;
@@ -1288,7 +1282,6 @@ void drv_disable_wq(struct idxd_wq *wq)
12881282
int idxd_device_drv_probe(struct idxd_dev *idxd_dev)
12891283
{
12901284
struct idxd_device *idxd = idxd_dev_to_idxd(idxd_dev);
1291-
unsigned long flags;
12921285
int rc = 0;
12931286

12941287
/*
@@ -1302,10 +1295,10 @@ int idxd_device_drv_probe(struct idxd_dev *idxd_dev)
13021295
}
13031296

13041297
/* Device configuration */
1305-
spin_lock_irqsave(&idxd->dev_lock, flags);
1298+
spin_lock(&idxd->dev_lock);
13061299
if (test_bit(IDXD_FLAG_CONFIGURABLE, &idxd->flags))
13071300
rc = idxd_device_config(idxd);
1308-
spin_unlock_irqrestore(&idxd->dev_lock, flags);
1301+
spin_unlock(&idxd->dev_lock);
13091302
if (rc < 0)
13101303
return -ENXIO;
13111304

drivers/dma/idxd/irq.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static int process_misc_interrupts(struct idxd_device *idxd, u32 cause)
6464
bool err = false;
6565

6666
if (cause & IDXD_INTC_ERR) {
67-
spin_lock_bh(&idxd->dev_lock);
67+
spin_lock(&idxd->dev_lock);
6868
for (i = 0; i < 4; i++)
6969
idxd->sw_err.bits[i] = ioread64(idxd->reg_base +
7070
IDXD_SWERR_OFFSET + i * sizeof(u64));
@@ -89,7 +89,7 @@ static int process_misc_interrupts(struct idxd_device *idxd, u32 cause)
8989
}
9090
}
9191

92-
spin_unlock_bh(&idxd->dev_lock);
92+
spin_unlock(&idxd->dev_lock);
9393
val |= IDXD_INTC_ERR;
9494

9595
for (i = 0; i < 4; i++)
@@ -133,15 +133,15 @@ static int process_misc_interrupts(struct idxd_device *idxd, u32 cause)
133133
INIT_WORK(&idxd->work, idxd_device_reinit);
134134
queue_work(idxd->wq, &idxd->work);
135135
} else {
136-
spin_lock_bh(&idxd->dev_lock);
136+
spin_lock(&idxd->dev_lock);
137137
idxd_wqs_quiesce(idxd);
138138
idxd_wqs_unmap_portal(idxd);
139139
idxd_device_clear_state(idxd);
140140
dev_err(&idxd->pdev->dev,
141141
"idxd halted, need %s.\n",
142142
gensts.reset_type == IDXD_DEVICE_RESET_FLR ?
143143
"FLR" : "system reset");
144-
spin_unlock_bh(&idxd->dev_lock);
144+
spin_unlock(&idxd->dev_lock);
145145
return -ENXIO;
146146
}
147147
}

drivers/dma/idxd/sysfs.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,16 +1099,15 @@ static ssize_t clients_show(struct device *dev,
10991099
struct device_attribute *attr, char *buf)
11001100
{
11011101
struct idxd_device *idxd = confdev_to_idxd(dev);
1102-
unsigned long flags;
11031102
int count = 0, i;
11041103

1105-
spin_lock_irqsave(&idxd->dev_lock, flags);
1104+
spin_lock(&idxd->dev_lock);
11061105
for (i = 0; i < idxd->max_wqs; i++) {
11071106
struct idxd_wq *wq = idxd->wqs[i];
11081107

11091108
count += wq->client_count;
11101109
}
1111-
spin_unlock_irqrestore(&idxd->dev_lock, flags);
1110+
spin_unlock(&idxd->dev_lock);
11121111

11131112
return sysfs_emit(buf, "%d\n", count);
11141113
}
@@ -1146,12 +1145,11 @@ static ssize_t errors_show(struct device *dev,
11461145
{
11471146
struct idxd_device *idxd = confdev_to_idxd(dev);
11481147
int i, out = 0;
1149-
unsigned long flags;
11501148

1151-
spin_lock_irqsave(&idxd->dev_lock, flags);
1149+
spin_lock(&idxd->dev_lock);
11521150
for (i = 0; i < 4; i++)
11531151
out += sysfs_emit_at(buf, out, "%#018llx ", idxd->sw_err.bits[i]);
1154-
spin_unlock_irqrestore(&idxd->dev_lock, flags);
1152+
spin_unlock(&idxd->dev_lock);
11551153
out--;
11561154
out += sysfs_emit_at(buf, out, "\n");
11571155
return out;

0 commit comments

Comments
 (0)