Skip to content

Commit 8a0c60a

Browse files
committed
Merge tag 'dmaengine-fix-6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine
Pull dmaengine fixes from Vinod Koul: "Core: - fix return value of is_slave_direction() for D2D dma Driver fixes for: - Documentaion fixes to resolve warnings for at_hdmac driver - bunch of fsl driver fixes for memory leaks, and useless kfree - TI edma and k3 fixes for packet error and null pointer checks" * tag 'dmaengine-fix-6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine: dmaengine: at_hdmac: add missing kernel-doc style description dmaengine: fix is_slave_direction() return false when DMA_DEV_TO_DEV dmaengine: fsl-qdma: Remove a useless devm_kfree() dmaengine: fsl-qdma: Fix a memory leak related to the queue command DMA dmaengine: fsl-qdma: Fix a memory leak related to the status queue DMA dmaengine: ti: k3-udma: Report short packet errors dmaengine: ti: edma: Add some null pointer checks to the edma_probe dmaengine: fsl-dpaa2-qdma: Fix the size of dma pools dmaengine: at_hdmac: fix some kernel-doc warnings
2 parents 843a33d + bd6081b commit 8a0c60a

File tree

6 files changed

+59
-39
lines changed

6 files changed

+59
-39
lines changed

drivers/dma/at_hdmac.c

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,14 @@ struct atdma_sg {
222222
* @vd: pointer to the virtual dma descriptor.
223223
* @atchan: pointer to the atmel dma channel.
224224
* @total_len: total transaction byte count
225-
* @sg_len: number of sg entries.
225+
* @sglen: number of sg entries.
226226
* @sg: array of sgs.
227+
* @boundary: number of transfers to perform before the automatic address increment operation
228+
* @dst_hole: value to add to the destination address when the boundary has been reached
229+
* @src_hole: value to add to the source address when the boundary has been reached
230+
* @memset_buffer: buffer used for the memset operation
231+
* @memset_paddr: physical address of the buffer used for the memset operation
232+
* @memset_vaddr: virtual address of the buffer used for the memset operation
227233
*/
228234
struct at_desc {
229235
struct virt_dma_desc vd;
@@ -245,7 +251,10 @@ struct at_desc {
245251
/*-- Channels --------------------------------------------------------*/
246252

247253
/**
248-
* atc_status - information bits stored in channel status flag
254+
* enum atc_status - information bits stored in channel status flag
255+
*
256+
* @ATC_IS_PAUSED: If channel is pauses
257+
* @ATC_IS_CYCLIC: If channel is cyclic
249258
*
250259
* Manipulated with atomic operations.
251260
*/
@@ -282,7 +291,6 @@ struct at_dma_chan {
282291
u32 save_cfg;
283292
u32 save_dscr;
284293
struct dma_slave_config dma_sconfig;
285-
bool cyclic;
286294
struct at_desc *desc;
287295
};
288296

@@ -328,12 +336,12 @@ static inline u8 convert_buswidth(enum dma_slave_buswidth addr_width)
328336
/**
329337
* struct at_dma - internal representation of an Atmel HDMA Controller
330338
* @dma_device: dmaengine dma_device object members
331-
* @atdma_devtype: identifier of DMA controller compatibility
332-
* @ch_regs: memory mapped register base
339+
* @regs: memory mapped register base
333340
* @clk: dma controller clock
334341
* @save_imr: interrupt mask register that is saved on suspend/resume cycle
335342
* @all_chan_mask: all channels availlable in a mask
336343
* @lli_pool: hw lli table
344+
* @memset_pool: hw memset pool
337345
* @chan: channels table to store at_dma_chan structures
338346
*/
339347
struct at_dma {
@@ -626,6 +634,9 @@ static inline u32 atc_calc_bytes_left(u32 current_len, u32 ctrla)
626634

627635
/**
628636
* atc_get_llis_residue - Get residue for a hardware linked list transfer
637+
* @atchan: pointer to an atmel hdmac channel.
638+
* @desc: pointer to the descriptor for which the residue is calculated.
639+
* @residue: residue to be set to dma_tx_state.
629640
*
630641
* Calculate the residue by removing the length of the Linked List Item (LLI)
631642
* already transferred from the total length. To get the current LLI we can use
@@ -661,10 +672,8 @@ static inline u32 atc_calc_bytes_left(u32 current_len, u32 ctrla)
661672
* two DSCR values are different, we read again the CTRLA then the DSCR till two
662673
* consecutive read values from DSCR are equal or till the maximum trials is
663674
* reach. This algorithm is very unlikely not to find a stable value for DSCR.
664-
* @atchan: pointer to an atmel hdmac channel.
665-
* @desc: pointer to the descriptor for which the residue is calculated.
666-
* @residue: residue to be set to dma_tx_state.
667-
* Returns 0 on success, -errno otherwise.
675+
*
676+
* Returns: %0 on success, -errno otherwise.
668677
*/
669678
static int atc_get_llis_residue(struct at_dma_chan *atchan,
670679
struct at_desc *desc, u32 *residue)
@@ -731,7 +740,8 @@ static int atc_get_llis_residue(struct at_dma_chan *atchan,
731740
* @chan: DMA channel
732741
* @cookie: transaction identifier to check status of
733742
* @residue: residue to be updated.
734-
* Return 0 on success, -errono otherwise.
743+
*
744+
* Return: %0 on success, -errno otherwise.
735745
*/
736746
static int atc_get_residue(struct dma_chan *chan, dma_cookie_t cookie,
737747
u32 *residue)
@@ -1710,7 +1720,7 @@ static void atc_issue_pending(struct dma_chan *chan)
17101720
* atc_alloc_chan_resources - allocate resources for DMA channel
17111721
* @chan: allocate descriptor resources for this channel
17121722
*
1713-
* return - the number of allocated descriptors
1723+
* Return: the number of allocated descriptors
17141724
*/
17151725
static int atc_alloc_chan_resources(struct dma_chan *chan)
17161726
{

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,17 @@ static int dpaa2_qdma_alloc_chan_resources(struct dma_chan *chan)
3838
if (!dpaa2_chan->fd_pool)
3939
goto err;
4040

41-
dpaa2_chan->fl_pool = dma_pool_create("fl_pool", dev,
42-
sizeof(struct dpaa2_fl_entry),
43-
sizeof(struct dpaa2_fl_entry), 0);
41+
dpaa2_chan->fl_pool =
42+
dma_pool_create("fl_pool", dev,
43+
sizeof(struct dpaa2_fl_entry) * 3,
44+
sizeof(struct dpaa2_fl_entry), 0);
45+
4446
if (!dpaa2_chan->fl_pool)
4547
goto err_fd;
4648

4749
dpaa2_chan->sdd_pool =
4850
dma_pool_create("sdd_pool", dev,
49-
sizeof(struct dpaa2_qdma_sd_d),
51+
sizeof(struct dpaa2_qdma_sd_d) * 2,
5052
sizeof(struct dpaa2_qdma_sd_d), 0);
5153
if (!dpaa2_chan->sdd_pool)
5254
goto err_fl;

drivers/dma/fsl-qdma.c

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -514,11 +514,11 @@ static struct fsl_qdma_queue
514514
queue_temp = queue_head + i + (j * queue_num);
515515

516516
queue_temp->cq =
517-
dma_alloc_coherent(&pdev->dev,
518-
sizeof(struct fsl_qdma_format) *
519-
queue_size[i],
520-
&queue_temp->bus_addr,
521-
GFP_KERNEL);
517+
dmam_alloc_coherent(&pdev->dev,
518+
sizeof(struct fsl_qdma_format) *
519+
queue_size[i],
520+
&queue_temp->bus_addr,
521+
GFP_KERNEL);
522522
if (!queue_temp->cq)
523523
return NULL;
524524
queue_temp->block_base = fsl_qdma->block_base +
@@ -563,15 +563,14 @@ static struct fsl_qdma_queue
563563
/*
564564
* Buffer for queue command
565565
*/
566-
status_head->cq = dma_alloc_coherent(&pdev->dev,
567-
sizeof(struct fsl_qdma_format) *
568-
status_size,
569-
&status_head->bus_addr,
570-
GFP_KERNEL);
571-
if (!status_head->cq) {
572-
devm_kfree(&pdev->dev, status_head);
566+
status_head->cq = dmam_alloc_coherent(&pdev->dev,
567+
sizeof(struct fsl_qdma_format) *
568+
status_size,
569+
&status_head->bus_addr,
570+
GFP_KERNEL);
571+
if (!status_head->cq)
573572
return NULL;
574-
}
573+
575574
status_head->n_cq = status_size;
576575
status_head->virt_head = status_head->cq;
577576
status_head->virt_tail = status_head->cq;
@@ -1268,21 +1267,13 @@ static void fsl_qdma_cleanup_vchan(struct dma_device *dmadev)
12681267

12691268
static void fsl_qdma_remove(struct platform_device *pdev)
12701269
{
1271-
int i;
1272-
struct fsl_qdma_queue *status;
12731270
struct device_node *np = pdev->dev.of_node;
12741271
struct fsl_qdma_engine *fsl_qdma = platform_get_drvdata(pdev);
12751272

12761273
fsl_qdma_irq_exit(pdev, fsl_qdma);
12771274
fsl_qdma_cleanup_vchan(&fsl_qdma->dma_dev);
12781275
of_dma_controller_free(np);
12791276
dma_async_device_unregister(&fsl_qdma->dma_dev);
1280-
1281-
for (i = 0; i < fsl_qdma->block_number; i++) {
1282-
status = fsl_qdma->status[i];
1283-
dma_free_coherent(&pdev->dev, sizeof(struct fsl_qdma_format) *
1284-
status->n_cq, status->cq, status->bus_addr);
1285-
}
12861277
}
12871278

12881279
static const struct of_device_id fsl_qdma_dt_ids[] = {

drivers/dma/ti/edma.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2404,6 +2404,11 @@ static int edma_probe(struct platform_device *pdev)
24042404
if (irq > 0) {
24052405
irq_name = devm_kasprintf(dev, GFP_KERNEL, "%s_ccint",
24062406
dev_name(dev));
2407+
if (!irq_name) {
2408+
ret = -ENOMEM;
2409+
goto err_disable_pm;
2410+
}
2411+
24072412
ret = devm_request_irq(dev, irq, dma_irq_handler, 0, irq_name,
24082413
ecc);
24092414
if (ret) {
@@ -2420,6 +2425,11 @@ static int edma_probe(struct platform_device *pdev)
24202425
if (irq > 0) {
24212426
irq_name = devm_kasprintf(dev, GFP_KERNEL, "%s_ccerrint",
24222427
dev_name(dev));
2428+
if (!irq_name) {
2429+
ret = -ENOMEM;
2430+
goto err_disable_pm;
2431+
}
2432+
24232433
ret = devm_request_irq(dev, irq, dma_ccerr_handler, 0, irq_name,
24242434
ecc);
24252435
if (ret) {

drivers/dma/ti/k3-udma.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3968,6 +3968,7 @@ static void udma_desc_pre_callback(struct virt_dma_chan *vc,
39683968
{
39693969
struct udma_chan *uc = to_udma_chan(&vc->chan);
39703970
struct udma_desc *d;
3971+
u8 status;
39713972

39723973
if (!vd)
39733974
return;
@@ -3977,12 +3978,12 @@ static void udma_desc_pre_callback(struct virt_dma_chan *vc,
39773978
if (d->metadata_size)
39783979
udma_fetch_epib(uc, d);
39793980

3980-
/* Provide residue information for the client */
39813981
if (result) {
39823982
void *desc_vaddr = udma_curr_cppi5_desc_vaddr(d, d->desc_idx);
39833983

39843984
if (cppi5_desc_get_type(desc_vaddr) ==
39853985
CPPI5_INFO0_DESC_TYPE_VAL_HOST) {
3986+
/* Provide residue information for the client */
39863987
result->residue = d->residue -
39873988
cppi5_hdesc_get_pktlen(desc_vaddr);
39883989
if (result->residue)
@@ -3991,7 +3992,12 @@ static void udma_desc_pre_callback(struct virt_dma_chan *vc,
39913992
result->result = DMA_TRANS_NOERROR;
39923993
} else {
39933994
result->residue = 0;
3994-
result->result = DMA_TRANS_NOERROR;
3995+
/* Propagate TR Response errors to the client */
3996+
status = d->hwdesc[0].tr_resp_base->status;
3997+
if (status)
3998+
result->result = DMA_TRANS_ABORTED;
3999+
else
4000+
result->result = DMA_TRANS_NOERROR;
39954001
}
39964002
}
39974003
}

include/linux/dmaengine.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,8 @@ static inline int dmaengine_slave_config(struct dma_chan *chan,
953953

954954
static inline bool is_slave_direction(enum dma_transfer_direction direction)
955955
{
956-
return (direction == DMA_MEM_TO_DEV) || (direction == DMA_DEV_TO_MEM);
956+
return (direction == DMA_MEM_TO_DEV) || (direction == DMA_DEV_TO_MEM) ||
957+
(direction == DMA_DEV_TO_DEV);
957958
}
958959

959960
static inline struct dma_async_tx_descriptor *dmaengine_prep_slave_single(

0 commit comments

Comments
 (0)