Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2630758rdb; Fri, 8 Dec 2023 14:08:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IESSuSaADbKArioWq+rgHEhl6SKnE0Bx9e6C/PFa7TyOVTyEXy7G9I4cBGMxuk78IsrnPVB X-Received: by 2002:a17:90a:ca88:b0:286:b6c2:15d with SMTP id y8-20020a17090aca8800b00286b6c2015dmr788642pjt.80.1702073319408; Fri, 08 Dec 2023 14:08:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702073319; cv=none; d=google.com; s=arc-20160816; b=mSwdBgVOPljwXHT7dvI5ocIy9795PvybHKWnF53h5blhqgB6tYKZ/Yp8TgFYK4M379 HWAvscKZ2Rpi2bjlgXYylzjdpDuJoS6LDzsyPGGxwc58UAPdfHrd1hAUGSiujPhHjbdL FbUh0BXcQ7m4thDovPOP9a0+uZh8i3GJbpJe7mXERTpGZUoxsM8EB1TZox5JLT2q40Mm CSeQmGYSFZLXqr1m+ADhLfQO5FnTzFlpy8Ui4dF8Poz/obAfIb1MpgBpbIyKONrj1mJL cEkZnKg9/Z6hiOP6rPvJxQXeDuPXmu5JAarrVwe60vuCcxc0G5lCNe7c3lIzhPtuRd3Q t9OQ== 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=OqUf+5qMMYkf8m8dTkgiVgao04lPLCwTYIySk9A5NlY=; fh=1pmAyp3xZ8sWUV98t98q7URUgX68KjDmTZriOyZWZ/U=; b=HTxnBQ4i5woQPMAMoO/tN8L2cmxCpWAZrt5QdhhzI3jA2J3memNtql4L/5a2Sl8glA wMyLF6NLNlc1vnqx7yfP0kz6KiNIfuBmJu5hWqVJ1+VdgG7PlBd35AUxS0LWPd80kjM7 F+3xkvaJDHIR8eVnyKKAXd8LRESavX/xHR44d+n/m+eImYK0mft2uDiNA178lgpvpOAO DrUKkT+dqL9h0o+nOaDPXkKADSMTrOF9jN35pSPX+AInHh2ARsoXdAXC1CT2FKd3hFtp sldz3xl/Lrkv15t6Ou8mUQyOgFi36BN7YSDJkM/QmIWvofzfO0wU3/bOB1FkQekMgO8l hsyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@alatek.krakow.pl header.s=99EE5E86-D06A-11EC-BE24-DBCCD0A148D3 header.b=hmh5AfGb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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. [23.128.96.34]) by mx.google.com with ESMTPS id x64-20020a17090a6c4600b0028718591fc7si3481791pjj.136.2023.12.08.14.08.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 14:08:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=fail header.i=@alatek.krakow.pl header.s=99EE5E86-D06A-11EC-BE24-DBCCD0A148D3 header.b=hmh5AfGb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 0099584D5EB5; Fri, 8 Dec 2023 14:08:36 -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 S1574854AbjLHWIK (ORCPT + 99 others); Fri, 8 Dec 2023 17:08:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229687AbjLHWIJ (ORCPT ); Fri, 8 Dec 2023 17:08:09 -0500 Received: from helios.alatek.com.pl (helios.alatek.com.pl [85.14.123.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F5C21706; Fri, 8 Dec 2023 14:08:14 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by helios.alatek.com.pl (Postfix) with ESMTP id A745B2D00FCF; Fri, 8 Dec 2023 23:08:11 +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 Pm6PtbYcO1Xs; Fri, 8 Dec 2023 23:08:10 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by helios.alatek.com.pl (Postfix) with ESMTP id C4CD72D00FCE; Fri, 8 Dec 2023 23:08:10 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.10.3 helios.alatek.com.pl C4CD72D00FCE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alatek.krakow.pl; s=99EE5E86-D06A-11EC-BE24-DBCCD0A148D3; t=1702073290; bh=OqUf+5qMMYkf8m8dTkgiVgao04lPLCwTYIySk9A5NlY=; h=From:To:Date:Message-Id:MIME-Version; b=hmh5AfGbadyV6Y1sJdDJrvt+W6zrZhbGalxGYhz2woEeVgmT2A07pu1h8vdmYqZ4W sRQi+4cS3MzIPU47Qf5b6X6gZNCspXKZwsnsR4IIVR1Ay1iyfKJhye3L0b43mfWs7e UxHq3pLclgpbCv8riGhpNy3vggV8BHfKrMYVFeoj4mC+OzRNlQI73niTlklqH1HUv0 r4ediBNW66UcvTEeptVuH2MfE9jcK380BB2RQ7tIrdbLB/UAAJF2gksfvVB1ZhJeoO 27vjQpKdEzlCjC/I+ifMu5dav66kFCQwmvCJPzIzqQL1gcZ2xTWsiahTZ3beI/M9/H Leaq6fG5B1YmQ== 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 fAPQKYUSh1JW; Fri, 8 Dec 2023 23:08:10 +0100 (CET) Received: from localhost.localdomain (unknown [10.125.125.6]) by helios.alatek.com.pl (Postfix) with ESMTPSA id 249152D00FCC; Fri, 8 Dec 2023 23:08:10 +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: [FIXED PATCH v4 6/8] dmaengine: xilinx: xdma: Add transfer error reporting Date: Fri, 8 Dec 2023 23:08:02 +0100 Message-Id: <20231208220802.56458-1-jankul@alatek.krakow.pl> X-Mailer: git-send-email 2.34.1 In-Reply-To: <9d683987-53db-a53e-9215-3a29f0167183@amd.com> References: <9d683987-53db-a53e-9215-3a29f0167183@amd.com> 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 14:08:37 -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 | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/dma/xilinx/xdma.c b/drivers/dma/xilinx/xdma.c index d1bc36133a45..a7cd378b7e9a 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; } @@ -820,6 +823,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