public inbox for dmaengine@vger.kernel.org
 help / color / mirror / Atom feed
From: Lizhi Hou <lizhi.hou@amd.com>
To: Jan Kuliga <jankul@alatek.krakow.pl>, <brian.xu@amd.com>,
	<raj.kumar.rampelli@amd.com>, <vkoul@kernel.org>,
	<michal.simek@amd.com>, <dmaengine@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <miquel.raynal@bootlin.com>
Subject: Re: [PATCH v4 6/8] dmaengine: xilinx: xdma: Add transfer error reporting
Date: Fri, 8 Dec 2023 13:06:07 -0800	[thread overview]
Message-ID: <9d683987-53db-a53e-9215-3a29f0167183@amd.com> (raw)
In-Reply-To: <20231208134929.49523-7-jankul@alatek.krakow.pl>


On 12/8/23 05:49, Jan Kuliga wrote:
> Extend the capability of transfer status reporting. Introduce error flag,
> which allows to report error in case of a interrupt-reported error
> condition.
>
> Signed-off-by: Jan Kuliga <jankul@alatek.krakow.pl>
> ---
>   drivers/dma/xilinx/xdma.c | 27 ++++++++++++++++-----------
>   1 file changed, 16 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/dma/xilinx/xdma.c b/drivers/dma/xilinx/xdma.c
> index d1bc36133a45..dbde6905acc7 100644
> --- a/drivers/dma/xilinx/xdma.c
> +++ b/drivers/dma/xilinx/xdma.c
> @@ -85,6 +85,7 @@ struct xdma_chan {
>    * @cyclic: Cyclic transfer vs. scatter-gather
>    * @periods: Number of periods in the cyclic transfer
>    * @period_size: Size of a period in bytes in cyclic transfers
> + * @error: tx error flag
>    */
>   struct xdma_desc {
>   	struct virt_dma_desc		vdesc;
> @@ -97,6 +98,7 @@ struct xdma_desc {
>   	bool				cyclic;
>   	u32				periods;
>   	u32				period_size;
> +	bool				error;
>   };
>
>   #define XDMA_DEV_STATUS_REG_DMA		BIT(0)
> @@ -274,6 +276,7 @@ xdma_alloc_desc(struct xdma_chan *chan, u32 desc_num, bool cyclic)
>   	sw_desc->chan = chan;
>   	sw_desc->desc_num = desc_num;
>   	sw_desc->cyclic = cyclic;
> +	sw_desc->error = false;
>   	dblk_num = DIV_ROUND_UP(desc_num, XDMA_DESC_ADJACENT);
>   	sw_desc->desc_blocks = kcalloc(dblk_num, sizeof(*sw_desc->desc_blocks),
>   				       GFP_NOWAIT);
> @@ -770,20 +773,20 @@ static enum dma_status xdma_tx_status(struct dma_chan *chan, dma_cookie_t cookie
>   	spin_lock_irqsave(&xdma_chan->vchan.lock, flags);
>
>   	vd = vchan_find_desc(&xdma_chan->vchan, cookie);
> -	if (vd)
> -		desc = to_xdma_desc(vd);
> -	if (!desc || !desc->cyclic) {
> -		spin_unlock_irqrestore(&xdma_chan->vchan.lock, flags);
> -		return ret;
> -	}
> -
> -	period_idx = desc->completed_desc_num % desc->periods;
> -	residue = (desc->periods - period_idx) * desc->period_size;
> +	if (!vd)
> +		goto out;
>
> +	desc = to_xdma_desc(vd);
> +	if (desc->error) {
> +		ret = DMA_ERROR;
> +	} else if (desc->cyclic) {
> +		period_idx = desc->completed_desc_num % desc->periods;
> +		residue = (desc->periods - period_idx) * desc->period_size;
> +		dma_set_residue(state, residue);
> +	}
> +out:
>   	spin_unlock_irqrestore(&xdma_chan->vchan.lock, flags);
>
> -	dma_set_residue(state, residue);
> -
>   	return ret;
> }
>
> @@ -808,6 +811,7 @@ static irqreturn_t xdma_channel_isr(int irq, void *dev_id)
>   	vd = vchan_next_desc(&xchan->vchan);
>   	if (!vd)
>   		goto out;
> +	desc = to_xdma_desc(vd);
Duplicated line.
>
>   	desc = to_xdma_desc(vd);
>   	xdev = xchan->xdev_hdl;
> @@ -820,6 +824,7 @@ static irqreturn_t xdma_channel_isr(int irq, void *dev_id)
>   	st &= XDMA_CHAN_STATUS_MASK;
>   	if ((st & XDMA_CHAN_ERROR_MASK) ||
>   		!(st & (CHAN_CTRL_IE_DESC_COMPLETED | CHAN_CTRL_IE_DESC_STOPPED))) {
> +		desc->error = true;
>   		xdma_err(xdev, "channel error, status register value: 0x%x", st);
>   		goto out;
>   	}
> --
> 2.34.1
>

  reply	other threads:[~2023-12-08 21:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-08 13:48 [PATCH v4 0/8] Miscellaneous xdma driver enhancements Jan Kuliga
2023-12-08 13:49 ` [PATCH v4 1/8] dmaengine: xilinx: xdma: Get rid of unused code Jan Kuliga
2023-12-08 13:49 ` [PATCH v4 2/8] dmaengine: xilinx: xdma: Add necessary macro definitions Jan Kuliga
2023-12-08 13:49 ` [PATCH v4 3/8] dmaengine: xilinx: xdma: Ease dma_pool alignment requirements Jan Kuliga
2023-12-08 13:49 ` [PATCH v4 4/8] dmaengine: xilinx: xdma: Rework xdma_terminate_all() Jan Kuliga
2023-12-11 10:54   ` Vinod Koul
2023-12-18 11:52     ` Jan Kuliga
2023-12-08 13:49 ` [PATCH v4 5/8] dmaengine: xilinx: xdma: Add error checking in xdma_channel_isr() Jan Kuliga
2023-12-08 13:49 ` [PATCH v4 6/8] dmaengine: xilinx: xdma: Add transfer error reporting Jan Kuliga
2023-12-08 21:06   ` Lizhi Hou [this message]
2023-12-08 22:08     ` [FIXED PATCH " Jan Kuliga
2023-12-11 10:54       ` Vinod Koul
2023-12-08 13:49 ` [PATCH v4 7/8] dmaengine: xilinx: xdma: Prepare the introduction of interleaved DMA transfers Jan Kuliga
2023-12-08 13:49 ` [PATCH v4 8/8] dmaengine: xilinx: xdma: Introduce " Jan Kuliga

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=9d683987-53db-a53e-9215-3a29f0167183@amd.com \
    --to=lizhi.hou@amd.com \
    --cc=brian.xu@amd.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=jankul@alatek.krakow.pl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@amd.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=raj.kumar.rampelli@amd.com \
    --cc=vkoul@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox