From patchwork Sun Mar 7 04:06:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12120415 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A53DC433DB for ; Sun, 7 Mar 2021 04:09:23 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3DED764DA3 for ; Sun, 7 Mar 2021 04:09:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3DED764DA3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=NudAWA1ju96qgylQDeLdjE+FT5WS6E/Vks++hVttNNQ=; b=Ejhsy9V/qmGF/3hLlS2p/w4N6 QhOYpubLc7k4oTPBvNj4fAVwslUHoPtyxOrtyKsHshn+grXOQ95EpEmVl5QsgzaWnq7677j7Qtitu 6/6p/4gAbF7Oj3G93Q7tIUmOmg0yyyBrKePc22daaEJ3TcZtML43EbFuV2sZbVFUaQAC9uOD9XAP+ 0/AzqpcNuActHJlp4c06ZVSrnuxIocfluUVw+07h6JxC/OIaarkZ6dZyI4MWvdZg2HiJi+Hvf8RqH 1fiLfn60MATxlsWHix9MAX6G2tWRk7vLp7g6aYgAPzWRrx3jo3B8fujX0PbzF9F3RWRBqvN9yhq4a LlGK2xNmg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lIkhe-007uhN-Az; Sun, 07 Mar 2021 04:07:38 +0000 Received: from perceval.ideasonboard.com ([2001:4b98:dc2:55:216:3eff:fef7:d647]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lIkh9-007uN6-0G for linux-arm-kernel@lists.infradead.org; Sun, 07 Mar 2021 04:07:09 +0000 Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 672213F5; Sun, 7 Mar 2021 05:07:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1615090025; bh=w1OG/ETIzAQ6bB7Dn+DCMdfkPhQRBsNRWVNAckwVagA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gPueyWGH103uncoydLtU4CRuQU7urP6ecYL/dql5TFvnMbAyXSSIzTgpUHq62b5Jt pSAeQlyZ+u/6XUTBxIZK9TwMNuTBoNTMUtQPAoGAFbs2BXDwDlX64LOy5A39SLhPOA RMB44aoBA+pOBgE7t1Wbr1FbNUbJrGYma92payQg= From: Laurent Pinchart To: dmaengine@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Vinod Koul , Michal Simek , Rohit Visavalia Subject: [PATCH 1/2] dmaengine: xilinx: dpdma: Fix descriptor issuing on video group Date: Sun, 7 Mar 2021 06:06:28 +0200 Message-Id: <20210307040629.29308-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210307040629.29308-1-laurent.pinchart@ideasonboard.com> References: <20210307040629.29308-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210307_040707_982328_AD1E80D0 X-CRM114-Status: GOOD ( 14.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When multiple channels are part of a video group, the transfer is triggered only when all channels in the group are ready. The logic to do so is incorrect, as it causes the descriptors for all channels but the last one in a group to not being pushed to the hardware. Fix it. Signed-off-by: Laurent Pinchart --- drivers/dma/xilinx/xilinx_dpdma.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/dma/xilinx/xilinx_dpdma.c b/drivers/dma/xilinx/xilinx_dpdma.c index 55df63dead8d..d504112c609e 100644 --- a/drivers/dma/xilinx/xilinx_dpdma.c +++ b/drivers/dma/xilinx/xilinx_dpdma.c @@ -839,6 +839,7 @@ static void xilinx_dpdma_chan_queue_transfer(struct xilinx_dpdma_chan *chan) struct xilinx_dpdma_tx_desc *desc; struct virt_dma_desc *vdesc; u32 reg, channels; + bool first_frame; lockdep_assert_held(&chan->lock); @@ -852,14 +853,6 @@ static void xilinx_dpdma_chan_queue_transfer(struct xilinx_dpdma_chan *chan) chan->running = true; } - if (chan->video_group) - channels = xilinx_dpdma_chan_video_group_ready(chan); - else - channels = BIT(chan->id); - - if (!channels) - return; - vdesc = vchan_next_desc(&chan->vchan); if (!vdesc) return; @@ -884,13 +877,26 @@ static void xilinx_dpdma_chan_queue_transfer(struct xilinx_dpdma_chan *chan) FIELD_PREP(XILINX_DPDMA_CH_DESC_START_ADDRE_MASK, upper_32_bits(sw_desc->dma_addr))); - if (chan->first_frame) + first_frame = chan->first_frame; + chan->first_frame = false; + + if (chan->video_group) { + channels = xilinx_dpdma_chan_video_group_ready(chan); + /* + * Trigger the transfer only when all channels in the group are + * ready. + */ + if (!channels) + return; + } else { + channels = BIT(chan->id); + } + + if (first_frame) reg = XILINX_DPDMA_GBL_TRIG_MASK(channels); else reg = XILINX_DPDMA_GBL_RETRIG_MASK(channels); - chan->first_frame = false; - dpdma_write(xdev->reg, XILINX_DPDMA_GBL, reg); } From patchwork Sun Mar 7 04:06:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12120417 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31B53C433E0 for ; Sun, 7 Mar 2021 04:09:24 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D0E3064D99 for ; Sun, 7 Mar 2021 04:09:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D0E3064D99 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Wk7G9todWUwDzqgR7S6kZMJMaOsbGi7lOqN+bYz+TqY=; b=L9wgsXuZPVT3hJ18Leg51/uSr YXWDU0BtNQBTUvDULdyUSvtRjZTlJMsVRzO9i5z98Zf4WF2IIeposIUPjsFZvpLr8mR+ZDCSLQLPx 5uF3cbaHCYC1vX5or3/HZz7uMKUiXR0lX7mK8QlfYD64wwhmj2fK/4PuOyUzi6Iz8o+8lD8OnwkOF yECb2XBV/OcHS0CNCm7NxnVHnt8OGL+ZIuFTyGR71F/EKrELWoztTUFo/ys4a/Mq6qpkN2hRYhjch g8iMTgqd+/SH09q3A+bwxBZe0u/TOn4YcfVZy+BH9XwxM5n5t9J207GVf1qflpx/u5/51PnqkWifx nPGFu3PGg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lIkhm-007umd-2e; Sun, 07 Mar 2021 04:07:46 +0000 Received: from perceval.ideasonboard.com ([2001:4b98:dc2:55:216:3eff:fef7:d647]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lIkhA-007uOE-EQ for linux-arm-kernel@lists.infradead.org; Sun, 07 Mar 2021 04:07:10 +0000 Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B3CA6E70; Sun, 7 Mar 2021 05:07:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1615090028; bh=y+jkPV1NC6KjMIukqojOkEVOMFibg3FcbMZJOGL8khc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XP8NYXq+uevazy6WihbWz7u1oqin15nOxhupJnF9tExpvV834QCO4IhtoxZ7P6rAh sGp7gPDtDnXLEGXD+kG5dgSREhwl9pxQFXN0DmtZWS5XElvsxZyC3UOFsHrB/qgD80 4LnQXtIRuMCmrJDVL57an4M6GMDYMmuaikuakwC8= From: Laurent Pinchart To: dmaengine@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Vinod Koul , Michal Simek , Rohit Visavalia Subject: [PATCH 2/2] dmaengine: xilinx: dpdma: Fix race condition in done IRQ Date: Sun, 7 Mar 2021 06:06:29 +0200 Message-Id: <20210307040629.29308-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210307040629.29308-1-laurent.pinchart@ideasonboard.com> References: <20210307040629.29308-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210307_040708_604988_552673D6 X-CRM114-Status: GOOD ( 10.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The active descriptor pointer is accessed from different contexts, including different interrupt handlers, and its access must be protected by the channel's lock. This wasn't done in the done IRQ handler. Fix it. Signed-off-by: Laurent Pinchart --- drivers/dma/xilinx/xilinx_dpdma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/dma/xilinx/xilinx_dpdma.c b/drivers/dma/xilinx/xilinx_dpdma.c index d504112c609e..70b29bd079c9 100644 --- a/drivers/dma/xilinx/xilinx_dpdma.c +++ b/drivers/dma/xilinx/xilinx_dpdma.c @@ -1048,13 +1048,14 @@ static int xilinx_dpdma_chan_stop(struct xilinx_dpdma_chan *chan) */ static void xilinx_dpdma_chan_done_irq(struct xilinx_dpdma_chan *chan) { - struct xilinx_dpdma_tx_desc *active = chan->desc.active; + struct xilinx_dpdma_tx_desc *active; unsigned long flags; spin_lock_irqsave(&chan->lock, flags); xilinx_dpdma_debugfs_desc_done_irq(chan); + active = chan->desc.active; if (active) vchan_cyclic_callback(&active->vdesc); else