From: Vinod Koul <vkoul@kernel.org>
To: Kelvin Cao <kelvin.cao@microchip.com>
Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
logang@deltatee.com, George.Ge@microchip.com,
christophe.jaillet@wanadoo.fr, hch@infradead.org
Subject: Re: [PATCH v6 1/1] dmaengine: switchtec-dma: Introduce Switchtec DMA engine PCI driver
Date: Wed, 2 Aug 2023 00:12:53 +0530 [thread overview]
Message-ID: <ZMlSLXaYaMry7ioA@matsya> (raw)
In-Reply-To: <20230728200327.96496-2-kelvin.cao@microchip.com>
On 28-07-23, 13:03, Kelvin Cao wrote:
> +static struct dma_async_tx_descriptor *
> +switchtec_dma_prep_memcpy(struct dma_chan *c, dma_addr_t dma_dst,
> + dma_addr_t dma_src, size_t len, unsigned long flags)
> + __acquires(swdma_chan->submit_lock)
> +{
> + if (len > SWITCHTEC_DESC_MAX_SIZE) {
> + /*
> + * Keep sparse happy by restoring an even lock count on
> + * this lock.
> + */
> + __acquire(swdma_chan->submit_lock);
> + return NULL;
> + }
> +
> + return switchtec_dma_prep_desc(c, MEMCPY, SWITCHTEC_INVALID_HFID,
> + dma_dst, SWITCHTEC_INVALID_HFID, dma_src,
> + 0, len, flags);
> +}
> +
> +static struct dma_async_tx_descriptor *
> +switchtec_dma_prep_wimm_data(struct dma_chan *c, dma_addr_t dma_dst, u64 data,
> + unsigned long flags)
can you please explain what this wimm data refers to...
I think adding imm callback was a mistake, we need a better
justification for another user for this, who programs this, what gets
programmed here
> + __acquires(swdma_chan->submit_lock)
> +{
> + struct switchtec_dma_chan *swdma_chan = to_switchtec_dma_chan(c);
> + struct device *chan_dev = to_chan_dev(swdma_chan);
> + size_t len = sizeof(data);
> +
> + if (len == 8 && (dma_dst & ((1 << DMAENGINE_ALIGN_8_BYTES) - 1))) {
> + dev_err(chan_dev,
> + "QW WIMM dst addr 0x%08x_%08x not QW aligned!\n",
> + upper_32_bits(dma_dst), lower_32_bits(dma_dst));
> + /*
> + * Keep sparse happy by restoring an even lock count on
> + * this lock.
> + */
> + __acquire(swdma_chan->submit_lock);
> + return NULL;
> + }
> +
> + return switchtec_dma_prep_desc(c, WIMM, SWITCHTEC_INVALID_HFID, dma_dst,
> + SWITCHTEC_INVALID_HFID, 0, data, len,
> + flags);
> +}
> +
...
> +static int switchtec_dma_alloc_desc(struct switchtec_dma_chan *swdma_chan)
> +{
> + struct switchtec_dma_dev *swdma_dev = swdma_chan->swdma_dev;
> + struct chan_fw_regs __iomem *chan_fw = swdma_chan->mmio_chan_fw;
> + struct pci_dev *pdev;
> + struct switchtec_dma_desc *desc;
> + size_t size;
> + int rc;
> + int i;
> +
> + swdma_chan->head = 0;
> + swdma_chan->tail = 0;
> + swdma_chan->cq_tail = 0;
> +
> + size = SWITCHTEC_DMA_SQ_SIZE * sizeof(*swdma_chan->hw_sq);
> + swdma_chan->hw_sq = dma_alloc_coherent(swdma_dev->dma_dev.dev, size,
> + &swdma_chan->dma_addr_sq,
> + GFP_NOWAIT);
> + if (!swdma_chan->hw_sq) {
> + rc = -ENOMEM;
> + goto free_and_exit;
> + }
> +
> + size = SWITCHTEC_DMA_CQ_SIZE * sizeof(*swdma_chan->hw_cq);
> + swdma_chan->hw_cq = dma_alloc_coherent(swdma_dev->dma_dev.dev, size,
> + &swdma_chan->dma_addr_cq,
> + GFP_NOWAIT);
> + if (!swdma_chan->hw_cq) {
> + rc = -ENOMEM;
> + goto free_and_exit;
> + }
> +
> + /* reset host phase tag */
> + swdma_chan->phase_tag = 0;
> +
> + size = sizeof(*swdma_chan->desc_ring);
> + swdma_chan->desc_ring = kcalloc(SWITCHTEC_DMA_RING_SIZE, size,
> + GFP_NOWAIT);
> + if (!swdma_chan->desc_ring) {
> + rc = -ENOMEM;
> + goto free_and_exit;
> + }
> +
> + for (i = 0; i < SWITCHTEC_DMA_RING_SIZE; i++) {
> + desc = kzalloc(sizeof(*desc), GFP_NOWAIT);
> + if (!desc) {
> + rc = -ENOMEM;
> + goto free_and_exit;
> + }
> +
> + dma_async_tx_descriptor_init(&desc->txd, &swdma_chan->dma_chan);
> + desc->txd.tx_submit = switchtec_dma_tx_submit;
> + desc->hw = &swdma_chan->hw_sq[i];
> + desc->completed = true;
> +
> + swdma_chan->desc_ring[i] = desc;
> + }
> +
> + rcu_read_lock();
> + pdev = rcu_dereference(swdma_dev->pdev);
> + if (!pdev) {
> + rcu_read_unlock();
> + rc = -ENODEV;
> + goto free_and_exit;
> + }
> +
> + /* set sq/cq */
> + writel(lower_32_bits(swdma_chan->dma_addr_sq), &chan_fw->sq_base_lo);
> + writel(upper_32_bits(swdma_chan->dma_addr_sq), &chan_fw->sq_base_hi);
> + writel(lower_32_bits(swdma_chan->dma_addr_cq), &chan_fw->cq_base_lo);
> + writel(upper_32_bits(swdma_chan->dma_addr_cq), &chan_fw->cq_base_hi);
> +
> + writew(SWITCHTEC_DMA_SQ_SIZE, &swdma_chan->mmio_chan_fw->sq_size);
> + writew(SWITCHTEC_DMA_CQ_SIZE, &swdma_chan->mmio_chan_fw->cq_size);
what is write happening in the descriptor alloc callback, that does not
sound correct to me
--
~Vinod
next prev parent reply other threads:[~2023-08-01 18:43 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-28 20:03 [PATCH v6 0/1] Switchtec Switch DMA Engine Driver Kelvin Cao
2023-07-28 20:03 ` [PATCH v6 1/1] dmaengine: switchtec-dma: Introduce Switchtec DMA engine PCI driver Kelvin Cao
2023-07-31 7:08 ` Christoph Hellwig
2023-07-31 23:07 ` Kelvin.Cao
2023-08-01 18:42 ` Vinod Koul [this message]
2023-08-03 3:15 ` Kelvin.Cao
2023-08-21 23:44 ` Kelvin.Cao
2023-10-05 18:35 ` Kelvin.Cao
2023-10-06 10:30 ` Vinod Koul
2023-10-06 22:34 ` Kelvin.Cao
2023-10-09 5:38 ` Vinod Koul
2023-10-10 21:23 ` Kelvin.Cao
2023-10-11 11:48 ` Vinod Koul
2023-10-11 16:36 ` Kelvin.Cao
2023-10-23 17:14 ` Kelvin.Cao
2023-12-12 17:53 ` Kelvin.Cao
2023-12-21 16:17 ` Vinod Koul
2023-07-31 15:49 ` [PATCH v6 0/1] Switchtec Switch DMA Engine Driver Logan Gunthorpe
2023-07-31 23:07 ` Kelvin.Cao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZMlSLXaYaMry7ioA@matsya \
--to=vkoul@kernel.org \
--cc=George.Ge@microchip.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=dmaengine@vger.kernel.org \
--cc=hch@infradead.org \
--cc=kelvin.cao@microchip.com \
--cc=linux-kernel@vger.kernel.org \
--cc=logang@deltatee.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.