mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-22 20:53:00 +07: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 ...
148 lines
3.6 KiB
C
148 lines
3.6 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Virtual DMA channel support for DMAengine
|
|
*
|
|
* Copyright (C) 2012 Russell King
|
|
*/
|
|
#include <linux/device.h>
|
|
#include <linux/dmaengine.h>
|
|
#include <linux/module.h>
|
|
#include <linux/spinlock.h>
|
|
|
|
#include "virt-dma.h"
|
|
|
|
static struct virt_dma_desc *to_virt_desc(struct dma_async_tx_descriptor *tx)
|
|
{
|
|
return container_of(tx, struct virt_dma_desc, tx);
|
|
}
|
|
|
|
dma_cookie_t vchan_tx_submit(struct dma_async_tx_descriptor *tx)
|
|
{
|
|
struct virt_dma_chan *vc = to_virt_chan(tx->chan);
|
|
struct virt_dma_desc *vd = to_virt_desc(tx);
|
|
unsigned long flags;
|
|
dma_cookie_t cookie;
|
|
|
|
spin_lock_irqsave(&vc->lock, flags);
|
|
cookie = dma_cookie_assign(tx);
|
|
|
|
list_move_tail(&vd->node, &vc->desc_submitted);
|
|
spin_unlock_irqrestore(&vc->lock, flags);
|
|
|
|
dev_dbg(vc->chan.device->dev, "vchan %p: txd %p[%x]: submitted\n",
|
|
vc, vd, cookie);
|
|
|
|
return cookie;
|
|
}
|
|
EXPORT_SYMBOL_GPL(vchan_tx_submit);
|
|
|
|
/**
|
|
* vchan_tx_desc_free - free a reusable descriptor
|
|
* @tx: the transfer
|
|
*
|
|
* This function frees a previously allocated reusable descriptor. The only
|
|
* other way is to clear the DMA_CTRL_REUSE flag and submit one last time the
|
|
* transfer.
|
|
*
|
|
* Returns 0 upon success
|
|
*/
|
|
int vchan_tx_desc_free(struct dma_async_tx_descriptor *tx)
|
|
{
|
|
struct virt_dma_chan *vc = to_virt_chan(tx->chan);
|
|
struct virt_dma_desc *vd = to_virt_desc(tx);
|
|
unsigned long flags;
|
|
|
|
spin_lock_irqsave(&vc->lock, flags);
|
|
list_del(&vd->node);
|
|
spin_unlock_irqrestore(&vc->lock, flags);
|
|
|
|
dev_dbg(vc->chan.device->dev, "vchan %p: txd %p[%x]: freeing\n",
|
|
vc, vd, vd->tx.cookie);
|
|
vc->desc_free(vd);
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(vchan_tx_desc_free);
|
|
|
|
struct virt_dma_desc *vchan_find_desc(struct virt_dma_chan *vc,
|
|
dma_cookie_t cookie)
|
|
{
|
|
struct virt_dma_desc *vd;
|
|
|
|
list_for_each_entry(vd, &vc->desc_issued, node)
|
|
if (vd->tx.cookie == cookie)
|
|
return vd;
|
|
|
|
return NULL;
|
|
}
|
|
EXPORT_SYMBOL_GPL(vchan_find_desc);
|
|
|
|
/*
|
|
* This tasklet handles the completion of a DMA descriptor by
|
|
* calling its callback and freeing it.
|
|
*/
|
|
static void vchan_complete(unsigned long arg)
|
|
{
|
|
struct virt_dma_chan *vc = (struct virt_dma_chan *)arg;
|
|
struct virt_dma_desc *vd, *_vd;
|
|
struct dmaengine_desc_callback cb;
|
|
LIST_HEAD(head);
|
|
|
|
spin_lock_irq(&vc->lock);
|
|
list_splice_tail_init(&vc->desc_completed, &head);
|
|
vd = vc->cyclic;
|
|
if (vd) {
|
|
vc->cyclic = NULL;
|
|
dmaengine_desc_get_callback(&vd->tx, &cb);
|
|
} else {
|
|
memset(&cb, 0, sizeof(cb));
|
|
}
|
|
spin_unlock_irq(&vc->lock);
|
|
|
|
dmaengine_desc_callback_invoke(&cb, &vd->tx_result);
|
|
|
|
list_for_each_entry_safe(vd, _vd, &head, node) {
|
|
dmaengine_desc_get_callback(&vd->tx, &cb);
|
|
|
|
list_del(&vd->node);
|
|
vchan_vdesc_fini(vd);
|
|
|
|
dmaengine_desc_callback_invoke(&cb, &vd->tx_result);
|
|
}
|
|
}
|
|
|
|
void vchan_dma_desc_free_list(struct virt_dma_chan *vc, struct list_head *head)
|
|
{
|
|
struct virt_dma_desc *vd, *_vd;
|
|
|
|
list_for_each_entry_safe(vd, _vd, head, node) {
|
|
if (dmaengine_desc_test_reuse(&vd->tx)) {
|
|
list_move_tail(&vd->node, &vc->desc_allocated);
|
|
} else {
|
|
dev_dbg(vc->chan.device->dev, "txd %p: freeing\n", vd);
|
|
list_del(&vd->node);
|
|
vc->desc_free(vd);
|
|
}
|
|
}
|
|
}
|
|
EXPORT_SYMBOL_GPL(vchan_dma_desc_free_list);
|
|
|
|
void vchan_init(struct virt_dma_chan *vc, struct dma_device *dmadev)
|
|
{
|
|
dma_cookie_init(&vc->chan);
|
|
|
|
spin_lock_init(&vc->lock);
|
|
INIT_LIST_HEAD(&vc->desc_allocated);
|
|
INIT_LIST_HEAD(&vc->desc_submitted);
|
|
INIT_LIST_HEAD(&vc->desc_issued);
|
|
INIT_LIST_HEAD(&vc->desc_completed);
|
|
|
|
tasklet_init(&vc->task, vchan_complete, (unsigned long)vc);
|
|
|
|
vc->chan.device = dmadev;
|
|
list_add_tail(&vc->chan.device_node, &dmadev->channels);
|
|
}
|
|
EXPORT_SYMBOL_GPL(vchan_init);
|
|
|
|
MODULE_AUTHOR("Russell King");
|
|
MODULE_LICENSE("GPL");
|