mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-16 16:54:20 +08:00
47ebe00b68
- Add support in dmaengine core to do device node checks for DT devices and update bunch of drivers to use that and remove open coding from drivers - New driver/driver support for new hardware, namely: - MediaTek UART APDMA - Freescale i.mx7ulp edma2 - Synopsys eDMA IP core version 0 - Allwinner H6 DMA - Updates to axi-dma and support for interleaved cyclic transfers - Greg's debugfs return value check removals on drivers - Updates to stm32-dma, hsu, dw, pl330, tegra drivers -----BEGIN PGP SIGNATURE----- iQIcBAABAgAGBQJdLKxYAAoJEHwUBw8lI4NHsH8P/AqYZpUlLthe5L4qItzM1Uf0 HqxsJYs0xworjSRml8uptx/TzjIgJnJfEk2PV5VA+0zJNz/HnH7lDH85wKDx1Ydl AatUuyAFRO3GZOup/hY0AEIPhoIMdg/3zS2aapjJmaEZCVK2eVKmcj0KMvO5g0cw tsmXm3O0xd2Na1ToslNyYgFfCn8ortuAeoKiXJxhivMbGjRfw4LW/RPgS17Vspvh mEuxNXFWAZ+DorgPF5BmDPZ+LXcGgCXGNIoj64W+VHaXU5yXnlky+6/0f7cEcFEd yl3hjXVwyAq5zIItIOmiuozZidi5yfoizXg4S2ZD3P4xXKZ5OZ9Gf/0SMyXUIErU pwGxo6ZgsBcEpAHtqySELQedttttID+jYYeWU6oDr2LOy3W3F7AHOEGg9l9ZllLh gRdIoz3PrMK1wy/9Ytl37xklZyBk+HJLkeoIAvjrNgNJ1YRKqcysUCwsmqO7SG3N HnIGx74sG8ChljT/yX5pElq3ip6qLdb4pJcsfxKJ9VSxsTZ3JNINGNQtvI19hKR/ 6sn/c1Rb5/S1WxINGr+2FxChxXF8OESCN6GIEu6mNYVBzQnNPzwgPxfAGCqdoOOH mqXXgYNePMaBGYXBkdgvP1CnqenRRmTYo/1L4QmI4Mve4xpd5zhx5cZt9FlQJ2Im /hVT8gZ6bIrutsVOy4rg =R+aC -----END PGP SIGNATURE----- Merge tag 'dmaengine-5.3-rc1' of git://git.infradead.org/users/vkoul/slave-dma Pull dmaengine updates from Vinod Koul: - Add support in dmaengine core to do device node checks for DT devices and update bunch of drivers to use that and remove open coding from drivers - New driver/driver support for new hardware, namely: - MediaTek UART APDMA - Freescale i.mx7ulp edma2 - Synopsys eDMA IP core version 0 - Allwinner H6 DMA - Updates to axi-dma and support for interleaved cyclic transfers - Greg's debugfs return value check removals on drivers - Updates to stm32-dma, hsu, dw, pl330, tegra drivers * tag 'dmaengine-5.3-rc1' of git://git.infradead.org/users/vkoul/slave-dma: (68 commits) dmaengine: Revert "dmaengine: fsl-edma: add i.mx7ulp edma2 version support" dmaengine: at_xdmac: check for non-empty xfers_list before invoking callback Documentation: dmaengine: clean up description of dmatest usage dmaengine: tegra210-adma: remove PM_CLK dependency dmaengine: fsl-edma: add i.mx7ulp edma2 version support dt-bindings: dma: fsl-edma: add new i.mx7ulp-edma dmaengine: fsl-edma-common: version check for v2 instead dmaengine: fsl-edma-common: move dmamux register to another single function dmaengine: fsl-edma: add drvdata for fsl-edma dmaengine: Revert "dmaengine: fsl-edma: support little endian for edma driver" dmaengine: rcar-dmac: Reject zero-length slave DMA requests dmaengine: dw: Enable iDMA 32-bit on Intel Elkhart Lake dmaengine: dw-edma: fix semicolon.cocci warnings dmaengine: sh: usb-dmac: Use [] to denote a flexible array member dmaengine: dmatest: timeout value of -1 should specify infinite wait dmaengine: dw: Distinguish ->remove() between DW and iDMA 32-bit dmaengine: fsl-edma: support little endian for edma driver dmaengine: hsu: Revert "set HSU_CH_MTSR to memory width" dmagengine: pl330: add code to get reset property dt-bindings: pl330: document the optional resets property ...
223 lines
5.8 KiB
C
223 lines
5.8 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Virtual DMA channel support for DMAengine
|
|
*
|
|
* Copyright (C) 2012 Russell King
|
|
*/
|
|
#ifndef VIRT_DMA_H
|
|
#define VIRT_DMA_H
|
|
|
|
#include <linux/dmaengine.h>
|
|
#include <linux/interrupt.h>
|
|
|
|
#include "dmaengine.h"
|
|
|
|
struct virt_dma_desc {
|
|
struct dma_async_tx_descriptor tx;
|
|
struct dmaengine_result tx_result;
|
|
/* protected by vc.lock */
|
|
struct list_head node;
|
|
};
|
|
|
|
struct virt_dma_chan {
|
|
struct dma_chan chan;
|
|
struct tasklet_struct task;
|
|
void (*desc_free)(struct virt_dma_desc *);
|
|
|
|
spinlock_t lock;
|
|
|
|
/* protected by vc.lock */
|
|
struct list_head desc_allocated;
|
|
struct list_head desc_submitted;
|
|
struct list_head desc_issued;
|
|
struct list_head desc_completed;
|
|
|
|
struct virt_dma_desc *cyclic;
|
|
struct virt_dma_desc *vd_terminated;
|
|
};
|
|
|
|
static inline struct virt_dma_chan *to_virt_chan(struct dma_chan *chan)
|
|
{
|
|
return container_of(chan, struct virt_dma_chan, chan);
|
|
}
|
|
|
|
void vchan_dma_desc_free_list(struct virt_dma_chan *vc, struct list_head *head);
|
|
void vchan_init(struct virt_dma_chan *vc, struct dma_device *dmadev);
|
|
struct virt_dma_desc *vchan_find_desc(struct virt_dma_chan *, dma_cookie_t);
|
|
extern dma_cookie_t vchan_tx_submit(struct dma_async_tx_descriptor *);
|
|
extern int vchan_tx_desc_free(struct dma_async_tx_descriptor *);
|
|
|
|
/**
|
|
* vchan_tx_prep - prepare a descriptor
|
|
* @vc: virtual channel allocating this descriptor
|
|
* @vd: virtual descriptor to prepare
|
|
* @tx_flags: flags argument passed in to prepare function
|
|
*/
|
|
static inline struct dma_async_tx_descriptor *vchan_tx_prep(struct virt_dma_chan *vc,
|
|
struct virt_dma_desc *vd, unsigned long tx_flags)
|
|
{
|
|
unsigned long flags;
|
|
|
|
dma_async_tx_descriptor_init(&vd->tx, &vc->chan);
|
|
vd->tx.flags = tx_flags;
|
|
vd->tx.tx_submit = vchan_tx_submit;
|
|
vd->tx.desc_free = vchan_tx_desc_free;
|
|
|
|
vd->tx_result.result = DMA_TRANS_NOERROR;
|
|
vd->tx_result.residue = 0;
|
|
|
|
spin_lock_irqsave(&vc->lock, flags);
|
|
list_add_tail(&vd->node, &vc->desc_allocated);
|
|
spin_unlock_irqrestore(&vc->lock, flags);
|
|
|
|
return &vd->tx;
|
|
}
|
|
|
|
/**
|
|
* vchan_issue_pending - move submitted descriptors to issued list
|
|
* @vc: virtual channel to update
|
|
*
|
|
* vc.lock must be held by caller
|
|
*/
|
|
static inline bool vchan_issue_pending(struct virt_dma_chan *vc)
|
|
{
|
|
list_splice_tail_init(&vc->desc_submitted, &vc->desc_issued);
|
|
return !list_empty(&vc->desc_issued);
|
|
}
|
|
|
|
/**
|
|
* vchan_cookie_complete - report completion of a descriptor
|
|
* @vd: virtual descriptor to update
|
|
*
|
|
* vc.lock must be held by caller
|
|
*/
|
|
static inline void vchan_cookie_complete(struct virt_dma_desc *vd)
|
|
{
|
|
struct virt_dma_chan *vc = to_virt_chan(vd->tx.chan);
|
|
dma_cookie_t cookie;
|
|
|
|
cookie = vd->tx.cookie;
|
|
dma_cookie_complete(&vd->tx);
|
|
dev_vdbg(vc->chan.device->dev, "txd %p[%x]: marked complete\n",
|
|
vd, cookie);
|
|
list_add_tail(&vd->node, &vc->desc_completed);
|
|
|
|
tasklet_schedule(&vc->task);
|
|
}
|
|
|
|
/**
|
|
* vchan_vdesc_fini - Free or reuse a descriptor
|
|
* @vd: virtual descriptor to free/reuse
|
|
*/
|
|
static inline void vchan_vdesc_fini(struct virt_dma_desc *vd)
|
|
{
|
|
struct virt_dma_chan *vc = to_virt_chan(vd->tx.chan);
|
|
|
|
if (dmaengine_desc_test_reuse(&vd->tx))
|
|
list_add(&vd->node, &vc->desc_allocated);
|
|
else
|
|
vc->desc_free(vd);
|
|
}
|
|
|
|
/**
|
|
* vchan_cyclic_callback - report the completion of a period
|
|
* @vd: virtual descriptor
|
|
*/
|
|
static inline void vchan_cyclic_callback(struct virt_dma_desc *vd)
|
|
{
|
|
struct virt_dma_chan *vc = to_virt_chan(vd->tx.chan);
|
|
|
|
vc->cyclic = vd;
|
|
tasklet_schedule(&vc->task);
|
|
}
|
|
|
|
/**
|
|
* vchan_terminate_vdesc - Disable pending cyclic callback
|
|
* @vd: virtual descriptor to be terminated
|
|
*
|
|
* vc.lock must be held by caller
|
|
*/
|
|
static inline void vchan_terminate_vdesc(struct virt_dma_desc *vd)
|
|
{
|
|
struct virt_dma_chan *vc = to_virt_chan(vd->tx.chan);
|
|
|
|
/* free up stuck descriptor */
|
|
if (vc->vd_terminated)
|
|
vchan_vdesc_fini(vc->vd_terminated);
|
|
|
|
vc->vd_terminated = vd;
|
|
if (vc->cyclic == vd)
|
|
vc->cyclic = NULL;
|
|
}
|
|
|
|
/**
|
|
* vchan_next_desc - peek at the next descriptor to be processed
|
|
* @vc: virtual channel to obtain descriptor from
|
|
*
|
|
* vc.lock must be held by caller
|
|
*/
|
|
static inline struct virt_dma_desc *vchan_next_desc(struct virt_dma_chan *vc)
|
|
{
|
|
return list_first_entry_or_null(&vc->desc_issued,
|
|
struct virt_dma_desc, node);
|
|
}
|
|
|
|
/**
|
|
* vchan_get_all_descriptors - obtain all submitted and issued descriptors
|
|
* @vc: virtual channel to get descriptors from
|
|
* @head: list of descriptors found
|
|
*
|
|
* vc.lock must be held by caller
|
|
*
|
|
* Removes all submitted and issued descriptors from internal lists, and
|
|
* provides a list of all descriptors found
|
|
*/
|
|
static inline void vchan_get_all_descriptors(struct virt_dma_chan *vc,
|
|
struct list_head *head)
|
|
{
|
|
list_splice_tail_init(&vc->desc_allocated, head);
|
|
list_splice_tail_init(&vc->desc_submitted, head);
|
|
list_splice_tail_init(&vc->desc_issued, head);
|
|
list_splice_tail_init(&vc->desc_completed, head);
|
|
}
|
|
|
|
static inline void vchan_free_chan_resources(struct virt_dma_chan *vc)
|
|
{
|
|
struct virt_dma_desc *vd;
|
|
unsigned long flags;
|
|
LIST_HEAD(head);
|
|
|
|
spin_lock_irqsave(&vc->lock, flags);
|
|
vchan_get_all_descriptors(vc, &head);
|
|
list_for_each_entry(vd, &head, node)
|
|
dmaengine_desc_clear_reuse(&vd->tx);
|
|
spin_unlock_irqrestore(&vc->lock, flags);
|
|
|
|
vchan_dma_desc_free_list(vc, &head);
|
|
}
|
|
|
|
/**
|
|
* vchan_synchronize() - synchronize callback execution to the current context
|
|
* @vc: virtual channel to synchronize
|
|
*
|
|
* Makes sure that all scheduled or active callbacks have finished running. For
|
|
* proper operation the caller has to ensure that no new callbacks are scheduled
|
|
* after the invocation of this function started.
|
|
* Free up the terminated cyclic descriptor to prevent memory leakage.
|
|
*/
|
|
static inline void vchan_synchronize(struct virt_dma_chan *vc)
|
|
{
|
|
unsigned long flags;
|
|
|
|
tasklet_kill(&vc->task);
|
|
|
|
spin_lock_irqsave(&vc->lock, flags);
|
|
if (vc->vd_terminated) {
|
|
vchan_vdesc_fini(vc->vd_terminated);
|
|
vc->vd_terminated = NULL;
|
|
}
|
|
spin_unlock_irqrestore(&vc->lock, flags);
|
|
}
|
|
|
|
#endif
|