From patchwork Wed Mar 13 14:08:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea della Porta X-Patchwork-Id: 13591453 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1D8EFC54E58 for ; Wed, 13 Mar 2024 14:09:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=wiVd6vOGFbm/UN+t8ZEJYiB+nHhN/0FiZh5X/geqslw=; b=mIlOO5hgewuygm 19S1VTp1nrIhu/w1tsBQ514JtvIdXLqloLFyxrhAtnfrO0P+tSqbnA4I7zwQK8dTCD7qo6+NJWhkh GnWj/FUzI0POPm2vIe2hiFK2q1fFikLfN+/gqw9i6/kmG5gaZ3MaKiMNdhI3nWWfTLv4568cwJf1e 9cQXnsXd3qeOtd3Z1v54CpyPLi6OakX7TwzBRRtzD4ZjpvkSyY4JRjiYPr7CEWbxJ3FIoW2R8/rif PrK6Tmravio+WvVouaZZxR6niO0UKVzNrfAxd6gUysxRZ1f5RTAyxE0jsFrB7OkgqyjWM/rQqM80E xh/WqPZmVXqSxjeQiv8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPIV-0000000AMbV-2ba5; Wed, 13 Mar 2024 14:09:35 +0000 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPHs-0000000AMAx-3hz9 for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2024 14:09:01 +0000 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-a44d084bfe1so645984766b.1 for ; Wed, 13 Mar 2024 07:08:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1710338934; x=1710943734; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Cdk6dXpjlqfTsKeP/epQp+Lh/qATka/VT0PX0aJnoDc=; b=LQOaWImTUjiYJA9NvA1tP3yok1FivQLs86KvGwwLSWmZmnAeFledd5Tqa125wcQuFN w6Q6R5rGw91OVAmLxE+YMrJDY3kuak6UOX9QV8KHx/Wl52Rm+/W9py2u0i6auO3ylnAO FmDa2HNnhuvtdDH2rZ7qUYS0ORtbxtZOxim1qEv2E+izw5CNXucrjBMixlaL0OGUsGN2 wbccIRn9rnmhLMFEtuAoPBKutuxiYVp4ZVpj69CZwmJ8GH4NClVvUPksltjxUWBl4K/f 7KhyoupI30CJ4+AOCzFXRtIbO8vsjzMVbP0ywVM+6PfMlBtKBr1SVyyUGP/NInQGrYVw xqCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710338934; x=1710943734; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Cdk6dXpjlqfTsKeP/epQp+Lh/qATka/VT0PX0aJnoDc=; b=FMARRfQ3I26srjk3zQsSjW66n3X0wHAAEvBl5OMZQByBM6IqOC3hI0GMVwCdr95gMS mJhYV6bpBoqoM1oSvt1RkodjzXNyCJshhMEb12efUgiZgPq3m48T+r7l1CaCxbeX5Ix7 /Ts1+euOi04wKANIRRXPU8ZzVNDi4fa/9Q2IFUuT22VZnn9LHvfUqQU4UKNQ54RRTfCN 8oKtAQlcWGCjM/IcMuask1R1CurEJptqBVTH7e39IIqTBrzoYl0X82MGb9rqHEM1G5cT NnuRC+FL2v32s4OGVvVqPl2vJ8Ix/FzLIUed4Z6q4BTr8LDplEHNtXcoTMcYrcm9RQ58 BhCg== X-Forwarded-Encrypted: i=1; AJvYcCUzC9Ty7RW+kuewGEkD+tIvFN7+dqu9FBZiF7aeI/Eyzj9/7gCeFrMxXfyZp8kClcazBuq3ihlr4oZWu/gxk2NdZqHfVRuPuy346h/aM4dXgoQ2fY0= X-Gm-Message-State: AOJu0YwhtOuzUMND11EbloJtWyrGlZvyfe0elsJB/XAurNofOcFwkzzU 3hrSBCJQB07XiKG2chM11vsYcO5+8L66mZbG5ZcDivs5mU6Znm1C4lDMK7uHV98= X-Google-Smtp-Source: AGHT+IGTRwgng8S9k6d0RlgfwcavmOY9mY6e0rpOTny7I0uyb3DtRPz/SPE6JA7TCCokGu/curyFDg== X-Received: by 2002:a17:906:40d4:b0:a46:63af:b1aa with SMTP id a20-20020a17090640d400b00a4663afb1aamr700791ejk.55.1710338934158; Wed, 13 Mar 2024 07:08:54 -0700 (PDT) Received: from localhost (host-82-56-173-172.retail.telecomitalia.it. [82.56.173.172]) by smtp.gmail.com with ESMTPSA id ku16-20020a170907789000b00a4655513f0bsm730365ejc.88.2024.03.13.07.08.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 07:08:53 -0700 (PDT) From: Andrea della Porta To: Vinod Koul , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Ray Jui , Scott Branden , Broadcom internal kernel review list , Saenz Julienne , dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dave.stevenson@raspberrypi.com Cc: Phil Elwell , Maxime Ripard , Stefan Wahren , Dom Cobley , Andrea della Porta Subject: [PATCH v2 05/15] dmaengine: bcm2835: Fixes for dma_abort Date: Wed, 13 Mar 2024 15:08:30 +0100 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240313_070857_478117_5F39562E X-CRM114-Status: GOOD ( 18.21 ) 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 From: Dom Cobley There is a problem with the current abort scheme when dma is blocked on a DREQ which prevents halting. This is triggered by SPI driver which aborts dma in this state and so leads to a halt timeout. We attempt to abort the channel, which will work if there is no blocked DREQ. It it times out, we can assume there is no AXI transfer in progress and reset anyway. The length of the timeout is observed at ~20us. Signed-off-by: Dom Cobley Signed-off-by: Andrea della Porta --- drivers/dma/bcm2835-dma.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index d442f8728c05..6b8e7461efaf 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -435,7 +435,7 @@ static void bcm2835_dma_fill_cb_chain_with_sg( static void bcm2835_dma_abort(struct bcm2835_chan *c) { void __iomem *chan_base = c->chan_base; - long timeout = 10000; + long timeout = 100; /* * A zero control block address means the channel is idle. @@ -444,19 +444,33 @@ static void bcm2835_dma_abort(struct bcm2835_chan *c) if (!readl(chan_base + BCM2835_DMA_ADDR)) return; - /* Write 0 to the active bit - Pause the DMA */ - writel(0, chan_base + BCM2835_DMA_CS); + /* We need to clear the next DMA block pending */ + writel(0, chan_base + BCM2835_DMA_NEXTCB); + + /* Abort the DMA, which needs to be enabled to complete */ + writel(readl(chan_base + BCM2835_DMA_CS) | BCM2835_DMA_ABORT | BCM2835_DMA_ACTIVE, + chan_base + BCM2835_DMA_CS); - /* Wait for any current AXI transfer to complete */ - while ((readl(chan_base + BCM2835_DMA_CS) & - BCM2835_DMA_WAITING_FOR_WRITES) && --timeout) + /* wait for DMA to be aborted */ + while ((readl(chan_base + BCM2835_DMA_CS) & BCM2835_DMA_ABORT) && --timeout) cpu_relax(); - /* Peripheral might be stuck and fail to signal AXI write responses */ - if (!timeout) + /* Write 0 to the active bit - Pause the DMA */ + writel(readl(chan_base + BCM2835_DMA_CS) & ~BCM2835_DMA_ACTIVE, + chan_base + BCM2835_DMA_CS); + + /* + * Peripheral might be stuck and fail to complete + * This is expected when dreqs are enabled but not asserted + * so only report error in non dreq case + */ + if (!timeout && !(readl(chan_base + BCM2835_DMA_TI) & + (BCM2835_DMA_S_DREQ | BCM2835_DMA_D_DREQ))) dev_err(c->vc.chan.device->dev, - "failed to complete outstanding writes\n"); + "failed to complete pause on dma %d (CS:%08x)\n", c->ch, + readl(chan_base + BCM2835_DMA_CS)); + /* Set CS back to default state and reset the DMA */ writel(BCM2835_DMA_RESET, chan_base + BCM2835_DMA_CS); }