mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-04 01:24:12 +08:00
143983e585
New drivers/devices - Intel LGM SoC DMA driver - Actions Semi S500 DMA controller - Renesas r8a779a0 dma controller - Ingenic JZ4760(B) dma controller - Intel KeemBay AxiDMA controller Removed - Coh901318 dma driver - Zte zx dma driver - Sirfsoc dma driver Updates: - mmp_pdma, mmp_tdma gained module support - imx-sdma become modern and dropped platform data support - dw-axi driver gained slave and cyclic dma support -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEE+vs47OPLdNbVcHzyfBQHDyUjg0cFAmA0gIEACgkQfBQHDyUj g0fLyw//bfIBqmyvN01QNmYV0qrud0nZGRAGHSEwZ1Nrw2CvK37+XphYzVYy/PGk Cg6ca+QXGJdIfqmQV/rnIEwrNx/GeNUAulVT5hxdHQw/HDPoZexU5S+Lyetr4g7l FaE2C5se4RBp07eGhcOWkneHE/fhC9fX23VdNGNM6Nzb1F0j4MTmzcJAlsdCq2Q+ 1UlJ2O4w/t/mdqgec4J+JGTsfb+BXxs0nWnuwVSy1SEkac3Gj0kqHlIHsQqLCiST /D2rs1I0Chscu+ChrPNaVXDEobQipxIEdkzO6623t8C5KqfSf5i8rLvZvRP5YKf1 U5ZAi3p0c/t5VgXvA6WD79pN6ZLPsEMFDxyKQAazGPgrEP4gmI4dteETiJyr6Ag6 j6WqiDJwkmdVyuTiFDJsN3pTOqvT+TeHlLbnygAiuyMeNaF9skc7kxtq0XtXQigT vLcwtGavFnmF7TZGjEVv4JTMdMFPfczE8y+fhM7ET/uF36gTrPHaoD3KIwgimwIt Cmfpe+Ij8R3tBwV80454hp4+Gb+cR83OUgwy+EcBCw9P0/Pf4t0NyTgim+wN02Kt X7tkkgxGkvziIkfbXQa4zdVqAbT6+WcRUjEDZY3/Lp7EFyVyM8APEVSAie9b/TWN UgQo3TDuB6SU7XQ3Ahj6Swra0+UoVztHtwOmgIqiVz5on6780lg= =0AE9 -----END PGP SIGNATURE----- Merge tag 'dmaengine-5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine Pull dmaengine updates from Vinod Koul: "We have couple of drivers removed a new driver and bunch of new device support and few updates to drivers for this round. New drivers/devices: - Intel LGM SoC DMA driver - Actions Semi S500 DMA controller - Renesas r8a779a0 dma controller - Ingenic JZ4760(B) dma controller - Intel KeemBay AxiDMA controller Removed: - Coh901318 dma driver - Zte zx dma driver - Sirfsoc dma driver Updates: - mmp_pdma, mmp_tdma gained module support - imx-sdma become modern and dropped platform data support - dw-axi driver gained slave and cyclic dma support" * tag 'dmaengine-5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine: (58 commits) dmaengine: dw-axi-dmac: remove redundant null check on desc dmaengine: xilinx_dma: Alloc tx descriptors GFP_NOWAIT dmaengine: dw-axi-dmac: Virtually split the linked-list dmaengine: dw-axi-dmac: Set constraint to the Max segment size dmaengine: dw-axi-dmac: Add Intel KeemBay AxiDMA BYTE and HALFWORD registers dmaengine: dw-axi-dmac: Add Intel KeemBay AxiDMA handshake dmaengine: dw-axi-dmac: Add Intel KeemBay AxiDMA support dmaengine: drivers: Kconfig: add HAS_IOMEM dependency to DW_AXI_DMAC dmaengine: dw-axi-dmac: Add Intel KeemBay DMA register fields dt-binding: dma: dw-axi-dmac: Add support for Intel KeemBay AxiDMA dmaengine: dw-axi-dmac: Support burst residue granularity dmaengine: dw-axi-dmac: Support of_dma_controller_register() dmaegine: dw-axi-dmac: Support device_prep_dma_cyclic() dmaengine: dw-axi-dmac: Support device_prep_slave_sg dmaengine: dw-axi-dmac: Add device_config operation dmaengine: dw-axi-dmac: Add device_synchronize() callback dmaengine: dw-axi-dmac: move dma_pool_create() to alloc_chan_resources() dmaengine: dw-axi-dmac: simplify descriptor management dt-bindings: dma: Add YAML schemas for dw-axi-dmac dmaengine: ti: k3-psil: optimize struct psil_endpoint_config for size ...
214 lines
5.1 KiB
C
214 lines
5.1 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/* Copyright(c) 2019 Intel Corporation. All rights rsvd. */
|
|
#include <linux/init.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
#include <linux/pci.h>
|
|
#include <linux/device.h>
|
|
#include <linux/io-64-nonatomic-lo-hi.h>
|
|
#include <linux/dmaengine.h>
|
|
#include <uapi/linux/idxd.h>
|
|
#include "../dmaengine.h"
|
|
#include "registers.h"
|
|
#include "idxd.h"
|
|
|
|
static inline struct idxd_wq *to_idxd_wq(struct dma_chan *c)
|
|
{
|
|
return container_of(c, struct idxd_wq, dma_chan);
|
|
}
|
|
|
|
void idxd_dma_complete_txd(struct idxd_desc *desc,
|
|
enum idxd_complete_type comp_type)
|
|
{
|
|
struct dma_async_tx_descriptor *tx;
|
|
struct dmaengine_result res;
|
|
int complete = 1;
|
|
|
|
if (desc->completion->status == DSA_COMP_SUCCESS)
|
|
res.result = DMA_TRANS_NOERROR;
|
|
else if (desc->completion->status)
|
|
res.result = DMA_TRANS_WRITE_FAILED;
|
|
else if (comp_type == IDXD_COMPLETE_ABORT)
|
|
res.result = DMA_TRANS_ABORTED;
|
|
else
|
|
complete = 0;
|
|
|
|
tx = &desc->txd;
|
|
if (complete && tx->cookie) {
|
|
dma_cookie_complete(tx);
|
|
dma_descriptor_unmap(tx);
|
|
dmaengine_desc_get_callback_invoke(tx, &res);
|
|
tx->callback = NULL;
|
|
tx->callback_result = NULL;
|
|
}
|
|
}
|
|
|
|
static void op_flag_setup(unsigned long flags, u32 *desc_flags)
|
|
{
|
|
*desc_flags = IDXD_OP_FLAG_CRAV | IDXD_OP_FLAG_RCR;
|
|
if (flags & DMA_PREP_INTERRUPT)
|
|
*desc_flags |= IDXD_OP_FLAG_RCI;
|
|
}
|
|
|
|
static inline void set_completion_address(struct idxd_desc *desc,
|
|
u64 *compl_addr)
|
|
{
|
|
*compl_addr = desc->compl_dma;
|
|
}
|
|
|
|
static inline void idxd_prep_desc_common(struct idxd_wq *wq,
|
|
struct dsa_hw_desc *hw, char opcode,
|
|
u64 addr_f1, u64 addr_f2, u64 len,
|
|
u64 compl, u32 flags)
|
|
{
|
|
hw->flags = flags;
|
|
hw->opcode = opcode;
|
|
hw->src_addr = addr_f1;
|
|
hw->dst_addr = addr_f2;
|
|
hw->xfer_size = len;
|
|
hw->priv = !!(wq->type == IDXD_WQT_KERNEL);
|
|
hw->completion_addr = compl;
|
|
}
|
|
|
|
static struct dma_async_tx_descriptor *
|
|
idxd_dma_submit_memcpy(struct dma_chan *c, dma_addr_t dma_dest,
|
|
dma_addr_t dma_src, size_t len, unsigned long flags)
|
|
{
|
|
struct idxd_wq *wq = to_idxd_wq(c);
|
|
u32 desc_flags;
|
|
struct idxd_device *idxd = wq->idxd;
|
|
struct idxd_desc *desc;
|
|
|
|
if (wq->state != IDXD_WQ_ENABLED)
|
|
return NULL;
|
|
|
|
if (len > idxd->max_xfer_bytes)
|
|
return NULL;
|
|
|
|
op_flag_setup(flags, &desc_flags);
|
|
desc = idxd_alloc_desc(wq, IDXD_OP_BLOCK);
|
|
if (IS_ERR(desc))
|
|
return NULL;
|
|
|
|
idxd_prep_desc_common(wq, desc->hw, DSA_OPCODE_MEMMOVE,
|
|
dma_src, dma_dest, len, desc->compl_dma,
|
|
desc_flags);
|
|
|
|
desc->txd.flags = flags;
|
|
|
|
return &desc->txd;
|
|
}
|
|
|
|
static int idxd_dma_alloc_chan_resources(struct dma_chan *chan)
|
|
{
|
|
struct idxd_wq *wq = to_idxd_wq(chan);
|
|
struct device *dev = &wq->idxd->pdev->dev;
|
|
|
|
idxd_wq_get(wq);
|
|
dev_dbg(dev, "%s: client_count: %d\n", __func__,
|
|
idxd_wq_refcount(wq));
|
|
return 0;
|
|
}
|
|
|
|
static void idxd_dma_free_chan_resources(struct dma_chan *chan)
|
|
{
|
|
struct idxd_wq *wq = to_idxd_wq(chan);
|
|
struct device *dev = &wq->idxd->pdev->dev;
|
|
|
|
idxd_wq_put(wq);
|
|
dev_dbg(dev, "%s: client_count: %d\n", __func__,
|
|
idxd_wq_refcount(wq));
|
|
}
|
|
|
|
static enum dma_status idxd_dma_tx_status(struct dma_chan *dma_chan,
|
|
dma_cookie_t cookie,
|
|
struct dma_tx_state *txstate)
|
|
{
|
|
return DMA_OUT_OF_ORDER;
|
|
}
|
|
|
|
/*
|
|
* issue_pending() does not need to do anything since tx_submit() does the job
|
|
* already.
|
|
*/
|
|
static void idxd_dma_issue_pending(struct dma_chan *dma_chan)
|
|
{
|
|
}
|
|
|
|
dma_cookie_t idxd_dma_tx_submit(struct dma_async_tx_descriptor *tx)
|
|
{
|
|
struct dma_chan *c = tx->chan;
|
|
struct idxd_wq *wq = to_idxd_wq(c);
|
|
dma_cookie_t cookie;
|
|
int rc;
|
|
struct idxd_desc *desc = container_of(tx, struct idxd_desc, txd);
|
|
|
|
cookie = dma_cookie_assign(tx);
|
|
|
|
rc = idxd_submit_desc(wq, desc);
|
|
if (rc < 0) {
|
|
idxd_free_desc(wq, desc);
|
|
return rc;
|
|
}
|
|
|
|
return cookie;
|
|
}
|
|
|
|
static void idxd_dma_release(struct dma_device *device)
|
|
{
|
|
}
|
|
|
|
int idxd_register_dma_device(struct idxd_device *idxd)
|
|
{
|
|
struct dma_device *dma = &idxd->dma_dev;
|
|
|
|
INIT_LIST_HEAD(&dma->channels);
|
|
dma->dev = &idxd->pdev->dev;
|
|
|
|
dma_cap_set(DMA_PRIVATE, dma->cap_mask);
|
|
dma_cap_set(DMA_COMPLETION_NO_ORDER, dma->cap_mask);
|
|
dma->device_release = idxd_dma_release;
|
|
|
|
if (idxd->hw.opcap.bits[0] & IDXD_OPCAP_MEMMOVE) {
|
|
dma_cap_set(DMA_MEMCPY, dma->cap_mask);
|
|
dma->device_prep_dma_memcpy = idxd_dma_submit_memcpy;
|
|
}
|
|
|
|
dma->device_tx_status = idxd_dma_tx_status;
|
|
dma->device_issue_pending = idxd_dma_issue_pending;
|
|
dma->device_alloc_chan_resources = idxd_dma_alloc_chan_resources;
|
|
dma->device_free_chan_resources = idxd_dma_free_chan_resources;
|
|
|
|
return dma_async_device_register(&idxd->dma_dev);
|
|
}
|
|
|
|
void idxd_unregister_dma_device(struct idxd_device *idxd)
|
|
{
|
|
dma_async_device_unregister(&idxd->dma_dev);
|
|
}
|
|
|
|
int idxd_register_dma_channel(struct idxd_wq *wq)
|
|
{
|
|
struct idxd_device *idxd = wq->idxd;
|
|
struct dma_device *dma = &idxd->dma_dev;
|
|
struct dma_chan *chan = &wq->dma_chan;
|
|
int rc;
|
|
|
|
memset(&wq->dma_chan, 0, sizeof(struct dma_chan));
|
|
chan->device = dma;
|
|
list_add_tail(&chan->device_node, &dma->channels);
|
|
rc = dma_async_device_channel_register(dma, chan);
|
|
if (rc < 0)
|
|
return rc;
|
|
|
|
return 0;
|
|
}
|
|
|
|
void idxd_unregister_dma_channel(struct idxd_wq *wq)
|
|
{
|
|
struct dma_chan *chan = &wq->dma_chan;
|
|
|
|
dma_async_device_channel_unregister(&wq->idxd->dma_dev, chan);
|
|
list_del(&chan->device_node);
|
|
}
|