Skip to content

Commit b05a568

Browse files
committed
Merge tag 'dmaengine-fix-5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine
Pull dmaengine fixes from Vinod Koul: "A bunch of driver fixes: - idxd device RO checks and device cleanup - dw-edma unaligned access and alignment - qcom: missing minItems in binding - mediatek pm usage fix - imx init script" * tag 'dmaengine-fix-5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine: dt-bindings: dmaengine: qcom: gpi: Add minItems for interrupts dmaengine: idxd: skip clearing device context when device is read-only dmaengine: idxd: add RO check for wq max_transfer_size write dmaengine: idxd: add RO check for wq max_batch_size write dmaengine: idxd: fix retry value to be constant for duration of function call dmaengine: idxd: match type for retries var in idxd_enqcmds() dmaengine: dw-edma: Fix inconsistent indenting dmaengine: dw-edma: Fix unaligned 64bit access dmaengine: mediatek:Fix PM usage reference leak of mtk_uart_apdma_alloc_chan_resources dmaengine: imx-sdma: Fix error checking in sdma_event_remap dma: at_xdmac: fix a missing check on list iterator dmaengine: imx-sdma: fix init of uart scripts dmaengine: idxd: fix device cleanup on disable
2 parents 59f0c24 + 7495a5b commit b05a568

File tree

8 files changed

+53
-34
lines changed

8 files changed

+53
-34
lines changed

Documentation/devicetree/bindings/dma/qcom,gpi.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ properties:
2929
interrupts:
3030
description:
3131
Interrupt lines for each GPI instance
32+
minItems: 1
3233
maxItems: 13
3334

3435
"#dma-cells":

drivers/dma/at_xdmac.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,7 +1453,7 @@ at_xdmac_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
14531453
{
14541454
struct at_xdmac_chan *atchan = to_at_xdmac_chan(chan);
14551455
struct at_xdmac *atxdmac = to_at_xdmac(atchan->chan.device);
1456-
struct at_xdmac_desc *desc, *_desc;
1456+
struct at_xdmac_desc *desc, *_desc, *iter;
14571457
struct list_head *descs_list;
14581458
enum dma_status ret;
14591459
int residue, retry;
@@ -1568,11 +1568,13 @@ at_xdmac_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
15681568
* microblock.
15691569
*/
15701570
descs_list = &desc->descs_list;
1571-
list_for_each_entry_safe(desc, _desc, descs_list, desc_node) {
1572-
dwidth = at_xdmac_get_dwidth(desc->lld.mbr_cfg);
1573-
residue -= (desc->lld.mbr_ubc & 0xffffff) << dwidth;
1574-
if ((desc->lld.mbr_nda & 0xfffffffc) == cur_nda)
1571+
list_for_each_entry_safe(iter, _desc, descs_list, desc_node) {
1572+
dwidth = at_xdmac_get_dwidth(iter->lld.mbr_cfg);
1573+
residue -= (iter->lld.mbr_ubc & 0xffffff) << dwidth;
1574+
if ((iter->lld.mbr_nda & 0xfffffffc) == cur_nda) {
1575+
desc = iter;
15751576
break;
1577+
}
15761578
}
15771579
residue += cur_ubc << dwidth;
15781580

drivers/dma/dw-edma/dw-edma-v0-core.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -414,14 +414,18 @@ void dw_edma_v0_core_start(struct dw_edma_chunk *chunk, bool first)
414414
SET_CH_32(dw, chan->dir, chan->id, ch_control1,
415415
(DW_EDMA_V0_CCS | DW_EDMA_V0_LLE));
416416
/* Linked list */
417+
417418
#ifdef CONFIG_64BIT
418-
SET_CH_64(dw, chan->dir, chan->id, llp.reg,
419-
chunk->ll_region.paddr);
419+
/* llp is not aligned on 64bit -> keep 32bit accesses */
420+
SET_CH_32(dw, chan->dir, chan->id, llp.lsb,
421+
lower_32_bits(chunk->ll_region.paddr));
422+
SET_CH_32(dw, chan->dir, chan->id, llp.msb,
423+
upper_32_bits(chunk->ll_region.paddr));
420424
#else /* CONFIG_64BIT */
421-
SET_CH_32(dw, chan->dir, chan->id, llp.lsb,
422-
lower_32_bits(chunk->ll_region.paddr));
423-
SET_CH_32(dw, chan->dir, chan->id, llp.msb,
424-
upper_32_bits(chunk->ll_region.paddr));
425+
SET_CH_32(dw, chan->dir, chan->id, llp.lsb,
426+
lower_32_bits(chunk->ll_region.paddr));
427+
SET_CH_32(dw, chan->dir, chan->id, llp.msb,
428+
upper_32_bits(chunk->ll_region.paddr));
425429
#endif /* CONFIG_64BIT */
426430
}
427431
/* Doorbell */

drivers/dma/idxd/device.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,6 @@ static void idxd_wq_device_reset_cleanup(struct idxd_wq *wq)
373373
{
374374
lockdep_assert_held(&wq->wq_lock);
375375

376-
idxd_wq_disable_cleanup(wq);
377376
wq->size = 0;
378377
wq->group = NULL;
379378
}
@@ -701,14 +700,17 @@ static void idxd_device_wqs_clear_state(struct idxd_device *idxd)
701700

702701
if (wq->state == IDXD_WQ_ENABLED) {
703702
idxd_wq_disable_cleanup(wq);
704-
idxd_wq_device_reset_cleanup(wq);
705703
wq->state = IDXD_WQ_DISABLED;
706704
}
705+
idxd_wq_device_reset_cleanup(wq);
707706
}
708707
}
709708

710709
void idxd_device_clear_state(struct idxd_device *idxd)
711710
{
711+
if (!test_bit(IDXD_FLAG_CONFIGURABLE, &idxd->flags))
712+
return;
713+
712714
idxd_groups_clear_state(idxd);
713715
idxd_engines_clear_state(idxd);
714716
idxd_device_wqs_clear_state(idxd);

drivers/dma/idxd/submit.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,15 @@ static void llist_abort_desc(struct idxd_wq *wq, struct idxd_irq_entry *ie,
150150
*/
151151
int idxd_enqcmds(struct idxd_wq *wq, void __iomem *portal, const void *desc)
152152
{
153-
int rc, retries = 0;
153+
unsigned int retries = wq->enqcmds_retries;
154+
int rc;
154155

155156
do {
156157
rc = enqcmds(portal, desc);
157158
if (rc == 0)
158159
break;
159160
cpu_relax();
160-
} while (retries++ < wq->enqcmds_retries);
161+
} while (retries--);
161162

162163
return rc;
163164
}

drivers/dma/idxd/sysfs.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,9 @@ static ssize_t wq_max_transfer_size_store(struct device *dev, struct device_attr
905905
u64 xfer_size;
906906
int rc;
907907

908+
if (!test_bit(IDXD_FLAG_CONFIGURABLE, &idxd->flags))
909+
return -EPERM;
910+
908911
if (wq->state != IDXD_WQ_DISABLED)
909912
return -EPERM;
910913

@@ -939,6 +942,9 @@ static ssize_t wq_max_batch_size_store(struct device *dev, struct device_attribu
939942
u64 batch_size;
940943
int rc;
941944

945+
if (!test_bit(IDXD_FLAG_CONFIGURABLE, &idxd->flags))
946+
return -EPERM;
947+
942948
if (wq->state != IDXD_WQ_DISABLED)
943949
return -EPERM;
944950

drivers/dma/imx-sdma.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,12 @@ struct sdma_script_start_addrs {
198198
s32 per_2_firi_addr;
199199
s32 mcu_2_firi_addr;
200200
s32 uart_2_per_addr;
201-
s32 uart_2_mcu_ram_addr;
201+
s32 uart_2_mcu_addr;
202202
s32 per_2_app_addr;
203203
s32 mcu_2_app_addr;
204204
s32 per_2_per_addr;
205205
s32 uartsh_2_per_addr;
206-
s32 uartsh_2_mcu_ram_addr;
206+
s32 uartsh_2_mcu_addr;
207207
s32 per_2_shp_addr;
208208
s32 mcu_2_shp_addr;
209209
s32 ata_2_mcu_addr;
@@ -232,8 +232,8 @@ struct sdma_script_start_addrs {
232232
s32 mcu_2_ecspi_addr;
233233
s32 mcu_2_sai_addr;
234234
s32 sai_2_mcu_addr;
235-
s32 uart_2_mcu_addr;
236-
s32 uartsh_2_mcu_addr;
235+
s32 uart_2_mcu_rom_addr;
236+
s32 uartsh_2_mcu_rom_addr;
237237
/* End of v3 array */
238238
s32 mcu_2_zqspi_addr;
239239
/* End of v4 array */
@@ -1796,17 +1796,17 @@ static void sdma_add_scripts(struct sdma_engine *sdma,
17961796
saddr_arr[i] = addr_arr[i];
17971797

17981798
/*
1799-
* get uart_2_mcu_addr/uartsh_2_mcu_addr rom script specially because
1800-
* they are now replaced by uart_2_mcu_ram_addr/uartsh_2_mcu_ram_addr
1801-
* to be compatible with legacy freescale/nxp sdma firmware, and they
1802-
* are located in the bottom part of sdma_script_start_addrs which are
1803-
* beyond the SDMA_SCRIPT_ADDRS_ARRAY_SIZE_V1.
1799+
* For compatibility with NXP internal legacy kernel before 4.19 which
1800+
* is based on uart ram script and mainline kernel based on uart rom
1801+
* script, both uart ram/rom scripts are present in newer sdma
1802+
* firmware. Use the rom versions if they are present (V3 or newer).
18041803
*/
1805-
if (addr->uart_2_mcu_addr)
1806-
sdma->script_addrs->uart_2_mcu_addr = addr->uart_2_mcu_addr;
1807-
if (addr->uartsh_2_mcu_addr)
1808-
sdma->script_addrs->uartsh_2_mcu_addr = addr->uartsh_2_mcu_addr;
1809-
1804+
if (sdma->script_number >= SDMA_SCRIPT_ADDRS_ARRAY_SIZE_V3) {
1805+
if (addr->uart_2_mcu_rom_addr)
1806+
sdma->script_addrs->uart_2_mcu_addr = addr->uart_2_mcu_rom_addr;
1807+
if (addr->uartsh_2_mcu_rom_addr)
1808+
sdma->script_addrs->uartsh_2_mcu_addr = addr->uartsh_2_mcu_rom_addr;
1809+
}
18101810
}
18111811

18121812
static void sdma_load_firmware(const struct firmware *fw, void *context)
@@ -1885,7 +1885,7 @@ static int sdma_event_remap(struct sdma_engine *sdma)
18851885
u32 reg, val, shift, num_map, i;
18861886
int ret = 0;
18871887

1888-
if (IS_ERR(np) || IS_ERR(gpr_np))
1888+
if (IS_ERR(np) || !gpr_np)
18891889
goto out;
18901890

18911891
event_remap = of_find_property(np, propname, NULL);
@@ -1933,7 +1933,7 @@ static int sdma_event_remap(struct sdma_engine *sdma)
19331933
}
19341934

19351935
out:
1936-
if (!IS_ERR(gpr_np))
1936+
if (gpr_np)
19371937
of_node_put(gpr_np);
19381938

19391939
return ret;

drivers/dma/mediatek/mtk-uart-apdma.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static int mtk_uart_apdma_alloc_chan_resources(struct dma_chan *chan)
274274
unsigned int status;
275275
int ret;
276276

277-
ret = pm_runtime_get_sync(mtkd->ddev.dev);
277+
ret = pm_runtime_resume_and_get(mtkd->ddev.dev);
278278
if (ret < 0) {
279279
pm_runtime_put_noidle(chan->device->dev);
280280
return ret;
@@ -288,18 +288,21 @@ static int mtk_uart_apdma_alloc_chan_resources(struct dma_chan *chan)
288288
ret = readx_poll_timeout(readl, c->base + VFF_EN,
289289
status, !status, 10, 100);
290290
if (ret)
291-
return ret;
291+
goto err_pm;
292292

293293
ret = request_irq(c->irq, mtk_uart_apdma_irq_handler,
294294
IRQF_TRIGGER_NONE, KBUILD_MODNAME, chan);
295295
if (ret < 0) {
296296
dev_err(chan->device->dev, "Can't request dma IRQ\n");
297-
return -EINVAL;
297+
ret = -EINVAL;
298+
goto err_pm;
298299
}
299300

300301
if (mtkd->support_33bits)
301302
mtk_uart_apdma_write(c, VFF_4G_SUPPORT, VFF_4G_SUPPORT_CLR_B);
302303

304+
err_pm:
305+
pm_runtime_put_noidle(mtkd->ddev.dev);
303306
return ret;
304307
}
305308

0 commit comments

Comments
 (0)