Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2349369rdb; Fri, 8 Dec 2023 05:51:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IFEgV8ZsVmNS3GEfrwHr+ClHfI3BriY92KISOhmHo9uGMH6cFchxnx1snB8I5XwjqBDzAPH X-Received: by 2002:a05:6a21:339b:b0:190:228e:4c2b with SMTP id yy27-20020a056a21339b00b00190228e4c2bmr13955pzb.71.1702043481445; Fri, 08 Dec 2023 05:51:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702043481; cv=none; d=google.com; s=arc-20160816; b=ugFBXPZRZLmncXcv3bluyUdaoC4JtCRphZ0b7MPlb2bAll0IdomkjFidS7LdbyksMm 5FtNIuY6u/qr/gEN7Ldr3NaRv/N/KjSBGxoYnZweUStKhXaGS9DbCzAS5Qlvh1uC46BD xEZJiz2t99b1h0+pybY4ELqIg+D4jaVkbzUyIfA6Yve1NHqFvLZYqd6cXtwk4dTz80aD vWpusG6Cyj4vSppxb2+zhtv8ZDWI1Le3whZjcSAD3VdysIoytJqQQihDfoMEtoOoX3Au 1Ea1WAFpshT855OcAizINcC5s2mhVEmVzmP72bo7u6m8u2LO6cpUO2QSrCDVr7p+Nxnm UjdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=TMsFFW9LzdDRNPZFkyLMJwFepjeLKvLoxofQXIKnXR8=; fh=1pmAyp3xZ8sWUV98t98q7URUgX68KjDmTZriOyZWZ/U=; b=yo2nVA6XY28UqaucrHLVRoBRIctbAqrkvGsnqljiIwu9OBUPfP/JZwEKTPNb8HUtqm zPpIhekhH/8ivBxc4v0wQYoWpARjy7UkRXOniOHLm0ZGi2OK5Sur7t1xcvlfrAvsF/yw 1EU92h5JPPxkkA22oakWmBeBB39sBwCR4wIUUDRBKEb9SQTkAe+R78vapnpTXFoMCIof j3gKkxYyzW7FR7b0UXrS8cMAyJPf13jkB4NEostwSrtFmDkfIdIGo8BI+LqCx8VgfdIt HHSD8QP0cTaKKIX5sWwmzP0e7MzzapzGHbMoUxDsnnUWwqCxW7D7OmL6Qr9NZJkEff9A 5JFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@alatek.krakow.pl header.s=99EE5E86-D06A-11EC-BE24-DBCCD0A148D3 header.b=SMP6CR80; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alatek.krakow.pl Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id g11-20020a056a0023cb00b006b9fd40d6cfsi1626474pfc.216.2023.12.08.05.51.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 05:51:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=fail header.i=@alatek.krakow.pl header.s=99EE5E86-D06A-11EC-BE24-DBCCD0A148D3 header.b=SMP6CR80; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alatek.krakow.pl Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id C960A8521370; Fri, 8 Dec 2023 05:51:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573875AbjLHNue (ORCPT + 99 others); Fri, 8 Dec 2023 08:50:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1573849AbjLHNuc (ORCPT ); Fri, 8 Dec 2023 08:50:32 -0500 Received: from helios.alatek.com.pl (helios.alatek.com.pl [85.14.123.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B971A1999; Fri, 8 Dec 2023 05:50:38 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by helios.alatek.com.pl (Postfix) with ESMTP id C433B2D00F5A; Fri, 8 Dec 2023 14:50:36 +0100 (CET) Received: from helios.alatek.com.pl ([127.0.0.1]) by localhost (helios.alatek.com.pl [127.0.0.1]) (amavis, port 10032) with ESMTP id hqSVR8pG3cOr; Fri, 8 Dec 2023 14:50:36 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by helios.alatek.com.pl (Postfix) with ESMTP id 19D592D00F59; Fri, 8 Dec 2023 14:50:36 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.10.3 helios.alatek.com.pl 19D592D00F59 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alatek.krakow.pl; s=99EE5E86-D06A-11EC-BE24-DBCCD0A148D3; t=1702043436; bh=TMsFFW9LzdDRNPZFkyLMJwFepjeLKvLoxofQXIKnXR8=; h=From:To:Date:Message-Id:MIME-Version; b=SMP6CR80fV67YC8RPgEkPpmIdHULiZBfL5bObh8es1TpK7E34SUBsV/vEjKGE+6e6 /CSHWrUl/XPEGhLkPlxLwtybtSwMEQ3bPo2A8X1Cd8qGPl+1pcz4lN0XbLfM1P48qk vZ3Ok12BW+qUPgirrmnPxHJSKwUhF1IDRRIQM+iLHIqyH6KW1ZrB/QcJsrPc3Z3tFD N5tH1ANpUilSw9vzeim6hDbYHmJPY0cksa7qKJqAj/Fw9l+uSzgl+feSx0CdFY84Fp Kxqf9Itwp1fG6OjC5M7le/WZI49oTSQ6GI5/0DBlmJfmMHH1IGFEkqleK88cyt2g3b olrcsbgJ3SvUw== X-Virus-Scanned: amavis at alatek.com.pl Received: from helios.alatek.com.pl ([127.0.0.1]) by localhost (helios.alatek.com.pl [127.0.0.1]) (amavis, port 10026) with ESMTP id 6O4CwPUEph3Z; Fri, 8 Dec 2023 14:50:36 +0100 (CET) Received: from localhost.localdomain (unknown [10.125.125.6]) by helios.alatek.com.pl (Postfix) with ESMTPSA id 809032D00F4D; Fri, 8 Dec 2023 14:50:35 +0100 (CET) From: Jan Kuliga To: lizhi.hou@amd.com, 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 Cc: jankul@alatek.krakow.pl Subject: [PATCH v4 6/8] dmaengine: xilinx: xdma: Add transfer error reporting Date: Fri, 8 Dec 2023 14:49:27 +0100 Message-Id: <20231208134929.49523-7-jankul@alatek.krakow.pl> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208134838.49500-1-jankul@alatek.krakow.pl> References: <20231208134838.49500-1-jankul@alatek.krakow.pl> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 08 Dec 2023 05:51:14 -0800 (PST) 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 --- 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 =3D chan; sw_desc->desc_num =3D desc_num; sw_desc->cyclic =3D cyclic; + sw_desc->error =3D false; dblk_num =3D DIV_ROUND_UP(desc_num, XDMA_DESC_ADJACENT); sw_desc->desc_blocks =3D kcalloc(dblk_num, sizeof(*sw_desc->desc_blocks= ), GFP_NOWAIT); @@ -770,20 +773,20 @@ static enum dma_status xdma_tx_status(struct dma_ch= an *chan, dma_cookie_t cookie spin_lock_irqsave(&xdma_chan->vchan.lock, flags); vd =3D vchan_find_desc(&xdma_chan->vchan, cookie); - if (vd) - desc =3D to_xdma_desc(vd); - if (!desc || !desc->cyclic) { - spin_unlock_irqrestore(&xdma_chan->vchan.lock, flags); - return ret; - } - - period_idx =3D desc->completed_desc_num % desc->periods; - residue =3D (desc->periods - period_idx) * desc->period_size; + if (!vd) + goto out; + desc =3D to_xdma_desc(vd); + if (desc->error) { + ret =3D DMA_ERROR; + } else if (desc->cyclic) { + period_idx =3D desc->completed_desc_num % desc->periods; + residue =3D (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 *de= v_id) vd =3D vchan_next_desc(&xchan->vchan); if (!vd) goto out; + desc =3D to_xdma_desc(vd); desc =3D to_xdma_desc(vd); xdev =3D xchan->xdev_hdl; @@ -820,6 +824,7 @@ static irqreturn_t xdma_channel_isr(int irq, void *de= v_id) st &=3D XDMA_CHAN_STATUS_MASK; if ((st & XDMA_CHAN_ERROR_MASK) || !(st & (CHAN_CTRL_IE_DESC_COMPLETED | CHAN_CTRL_IE_DESC_STOPPED))) { + desc->error =3D true; xdma_err(xdev, "channel error, status register value: 0x%x", st); goto out; } -- 2.34.1