Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1745020lql; Wed, 13 Mar 2024 07:09:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWY6hjLuTzPsTEB+9BvjXfwPtlS2hn9H+aMWhl8R7Qm+xhuos4P61hvbYEVhMQDbBsX/Kva1290QAelQMAbUPv0MKixOkA/8fnjIM696g== X-Google-Smtp-Source: AGHT+IE9e8lpDRKFDbXe3nheZrGD0OhEfXNSkCiLit1T/UQ3iohxsOmF35fBfcxY0p8O3cBBOUO2 X-Received: by 2002:a05:6a21:3988:b0:1a1:4d0c:7de2 with SMTP id ad8-20020a056a21398800b001a14d0c7de2mr7293678pzc.56.1710338994420; Wed, 13 Mar 2024 07:09:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710338994; cv=pass; d=google.com; s=arc-20160816; b=szly0YcyarE/Ke059mxn7i7Ver0QSCjYwJ1Kwfz0TFdURayLtmrC6N8LJX0lVE7qtV tKO6FJnw06yeQBHPhnIuYmFNdKUh3io61ftJlTfClb8diB5AxgIP61B1ocvgeBVMcYDm Qd+koze/8SlwiebhCHNGDCoq5iSani2j5TGu6JHuMV+5bNTuCJqVkvPcwjC1DuI8JQpI SEaZhBwA+yNlc9/pK9lX+wg11eQT91RI78OHolhiKuL3Ho+lLYthxf20DLxGkeMfYeoA kq1O8zxVROZSwnCRS0xqe4CU3roaQNOJr5PDyMEGDopGtdxbYPiVS9RLVUhDagMPOGY2 y6Cw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Cdk6dXpjlqfTsKeP/epQp+Lh/qATka/VT0PX0aJnoDc=; fh=oVzU7880qH2JGn2azTXirgFRkN91LC1YbF3aXBsuSTI=; b=RRlVOsa+3ATQ/ZtRIHIJnbFqGY3hiJI2CKCBmiCyPVf8gZ9EObg2uGS3n/wSTDbNc4 2GvTLG9GgfzyhWLcANMQYEPkZzXg7FYTvL7YSsgh+X9vwm/QdTqgZ/F3ICXe1SP93QgP wzqTTvJGmFJE+noMkDSMLt0x6TM9dSfHpLM8+7EbiNvhb5kCOo9gJ0gFArUAb+JL9o1B 6Yn7Cy4rkQUDIHBywZgGf8m4FK3A53AiIo7o6sEdZLSWyRDGtDAVp7Kd7B+119zgSM7y C/QXrXRC2P8GDuyDeHndOzmnAH7f7Lz2IGRd3Liep0lQaHIY8ceH2ja6Nd0CTRnpnQPO R5uQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=II4BFqX6; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-101593-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101593-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id i6-20020a632206000000b005dc957fe128si9123898pgi.74.2024.03.13.07.09.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 07:09:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101593-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=II4BFqX6; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-101593-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101593-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 02941289105 for ; Wed, 13 Mar 2024 14:09:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D1DE84AEE1; Wed, 13 Mar 2024 14:08:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="II4BFqX6" Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B777E47A73 for ; Wed, 13 Mar 2024 14:08:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338937; cv=none; b=b05wkq6CbqxuTuGl38xtmGVZWkTC9V7xzocWqPv15TfoBaLrmHBdrf6V46W3t6JRMsX9YVeWquOuKlPUFRzLg7T3+sOVZQePoq1+B5+eX9oP+bAT4mqjB1uoBcT2GiNojWkMpfUEbEnaZY5pFr4dyohqvNNaD6P/knK3BDEQTfU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338937; c=relaxed/simple; bh=Ynq2F2bMfhoLu2FW/bFjh5jnZcIj/QLxPgEvfGRr8J8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AmR1xJLHHnJN88c/boFMYsMtFAzRaxUIpkPSDF72zqcxzGXOOIlG4Vdm1vzFrm6UEvytoSAT3fdaNitOehOf8u+VMDPSNmG9C3T1b4Qa0Or6+SzjFfTNJqpbNLHozR8opS5AKc5KLCZCufn3vZtBv2Tnl/6Ty6InuteGC6jgMx8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=II4BFqX6; arc=none smtp.client-ip=209.85.218.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a4429c556efso594533066b.0 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=vger.kernel.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=II4BFqX6+9qRW3LXpSuY8OgyNOWSMxaskfDkKvhoUsHAoz4c9fhNL9ZfTJHSP30mIU /wjYWHsuNYpUFNnJZxwYb78t1u7gZwItTnIx+tZTlx9xQdyMfRd6JAihjFfvTe19Cj1E Qr40/QcJsEKxTZWh3rgcQKwSZ8Hug0ie9EVKrrTFVkDMLS85Pykf/BKaXIu6dbVvtJ27 U/cL/2fAn0BCwG0ez5rf6MD4YM8dhXWnQw8GUhFo0z+v8MYt8vBzQfUnm8Rae1gmUxwy qtI1Sj9Q6NMqrsVloXTA2HJzFvgiJoEPJYOe6jXnRFSaQCTH0gpMClQmt8aF8Fw+UTCG +pyA== 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=CGROC8qkLlIxIPppp88XGoa4SzamVQKZloKEmvRlzHdv4rtcc5vUpb4LOZcRe7Jwdr I7e5XD85quhw5cC2wwzj56tQkFuEDVprqhcvfi4+B0zv7bRdiQDXz4cvHvTYez6rGGeA SFuyJZ4mtMsZNKPxks/wF2ng1LOHF894RSiZ84MQbGmueKCyijvydnPTvOk0eEB7sBTJ 9mn9l3zBKdzC54Mk/U9C64MkGKN1+HkaMwveQk0TnNwPedYXh4G54N+uahe9kJeZIAwx nF9+8fdgmZ/fqvmJ/reIiSe142CYzUcb+G4RGKdPKXeARO4lQdgIiuWdmKUNPNpDJjsh jy9g== X-Forwarded-Encrypted: i=1; AJvYcCWF+ALFIqzwj8zLrk/qVZLCIdozMTduLNz2t4UlOVh3VHp7gDcenDp+Iw75y4rQD1rMvbpk+8JnLhA4siXSlU4Xoaw7h8BkncJWvDl+ X-Gm-Message-State: AOJu0YxWpUkEwA+JTZYNmP6qYOd1lLAecdeUXj9PKWswoK+Z1kDni8Bs 9C4jwm4zt9emPyrzT44IAN4+oNZZ3WWCmvvj+Yk0jHbXQYZgF54kEiGaHBlgPzQ= 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: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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); } -- 2.35.3