From patchwork Wed Mar 13 14:08:26 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: 13591452 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 A7313C54791 for ; Wed, 13 Mar 2024 14:09:34 +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=6mHePudBSJdm4G9q9lruQ0Q5fBOnT6bSWQnXDfjzMLE=; b=yWYcnm35e68I95 JwDmQUfM+te6Gj8DQYkFL6YWDhu9moKg/1EV2eFJs+C0IzIEIsWfL+1xn9AK3ByevXmePGw9X1q+5 8dOFbrMQv0lQbrHN9Ab7DDeqCVh9uAuMk3Y1GZHu6R4Gx74I3VOet3mTPKP80ffQFEysR1poy1OFu qQQkMDd4yMzehDiCOrrYxKrp36K0SZAW+r6gZnQ7mRQlUNtwblAV7yzH3loLrak/9gPAUbBvbgMuA za5UWvpcXfW0q357Cn3ghoNhXhHZeCmGVYO+xZm+7w6ieYUti5c+AJ7LfQBEt1gVDPtUztleVBoyO iXgQuROSSA5K91HTtyHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPIG-0000000AMRG-3QA3; Wed, 13 Mar 2024 14:09:20 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPHo-0000000AM80-47tS for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2024 14:08:58 +0000 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a4663b29334so61946566b.0 for ; Wed, 13 Mar 2024 07:08:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1710338928; x=1710943728; 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=DCjY7yma+RGAhMTh4u8gj7GTqPRw3rlJG0cUBmglS1Q=; b=BhAzIYO7PFTvJs10/BYrXBoma63yZAd7TG+EYdxI/Bm7MddSbfeuBbCaUSC9z/LRXH yIoVlcPEuroNB/yxW/O+5KMCjHR8SmkkUp1ZU+CnY8XAQm2TjA0nq7Fnq+8LJylN2Zi+ pzkQe86QyTjpF8BwZDQySNLraOYchMhMT5d6YioJBQC9Fn9UNCKTP+nit5btoTJL/jhz IcUALaQPvwnzoiGH4MRjubsv00Xfb7fXwGcUukyEbgmZ09kGdrUX4Z3XqwnUQzyscmM7 JmprQgfsu+5WKmL58L5FNXv8LqqpRlq0CoQvOI93JlxTTlyKeyQVxkdcYRE1sKL81EwB YpnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710338928; x=1710943728; 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=DCjY7yma+RGAhMTh4u8gj7GTqPRw3rlJG0cUBmglS1Q=; b=UrLmqhHP5O6b2eXp6Pqz7CwNyXfvTEdeuyk8pLJxPZKubzW1vyGkjXO2w1PJABZxIo GvLbOu4aCWkJ18SN/gkaY8w5O3XJ0j3+lfoBWmDcM65FhX6i+OmEMq3q1l0aVYpG+kYO Dqc7XA7NHw6BCnbtGe7K9Lp+GhONH2UZv8CuZaPe2mFoN2AxIhf+alWQmXRF1PmuqoER DM2PSR5Rzqg1xI3decWl3LHFrgfkWrlRwx1BbzdDljKVK5bRp0RZFnOj7epEoUXYRwYz eopIhu0m9422sJpBEF9kOf2v6uxboIUuTjDXoOO8Q3QNdP9KlWlxV+1ObM4FPt2Qa8J1 pu0g== X-Forwarded-Encrypted: i=1; AJvYcCVbeaegJ3q5DKUE0UyTBmadLUvhF/WO9NcutMjKYX/LaLoF79mne9ehA21KuvbUpaXePDoOshMymacfD+rnRSdIIf8p4srR1I7fjezMXcrgsGJ7lrM= X-Gm-Message-State: AOJu0YxrvgrTg12vmEqWcpibeito4NKkO3obh5G7yOkC+at0PbXf0qFO IosrJ2d/l5RHpxR36/kPrfVqrWI9jQe4kUonAP6qGmpQx7XCkrQZWRJsH/F4va4= X-Google-Smtp-Source: AGHT+IFJLbfeGtbha0JVbIZTeiai8FTB/X6n+UdCuNQI1XT7w/ymHZH+kptfqSeAe/qiMeK3y/y/zQ== X-Received: by 2002:a17:906:b153:b0:a43:dae8:d43c with SMTP id bt19-20020a170906b15300b00a43dae8d43cmr8570426ejb.32.1710338927934; Wed, 13 Mar 2024 07:08:47 -0700 (PDT) Received: from localhost (host-82-56-173-172.retail.telecomitalia.it. [82.56.173.172]) by smtp.gmail.com with ESMTPSA id 1-20020a170906308100b00a458d52a5f7sm4848776ejv.28.2024.03.13.07.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 07:08:47 -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 01/15] dmaengine: bcm2835: Fix several spellos Date: Wed, 13 Mar 2024 15:08:26 +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_070853_105131_91292FF0 X-CRM114-Status: GOOD ( 23.79 ) 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 Fixed Codespell reported warnings about spelling and coding convention violations, among which there are also a couple potential operator precedence issue in macroes. Signed-off-by: Andrea della Porta --- drivers/dma/bcm2835-dma.c | 96 +++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index 9d74fe97452e..428253b468ac 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -51,13 +51,13 @@ struct bcm2835_dmadev { }; struct bcm2835_dma_cb { - uint32_t info; - uint32_t src; - uint32_t dst; - uint32_t length; - uint32_t stride; - uint32_t next; - uint32_t pad[2]; + u32 info; + u32 src; + u32 dst; + u32 length; + u32 stride; + u32 next; + u32 pad[2]; }; struct bcm2835_cb_entry { @@ -116,8 +116,8 @@ struct bcm2835_desc { * AXI-write to ack */ #define BCM2835_DMA_ERR BIT(8) -#define BCM2835_DMA_PRIORITY(x) ((x & 15) << 16) /* AXI priority */ -#define BCM2835_DMA_PANIC_PRIORITY(x) ((x & 15) << 20) /* panic priority */ +#define BCM2835_DMA_PRIORITY(x) (((x) & 15) << 16) /* AXI priority */ +#define BCM2835_DMA_PANIC_PRIORITY(x) (((x) & 15) << 20) /* panic priority */ /* current value of TI.BCM2835_DMA_WAIT_RESP */ #define BCM2835_DMA_WAIT_FOR_WRITES BIT(28) #define BCM2835_DMA_DIS_DEBUG BIT(29) /* disable debug pause signal */ @@ -136,9 +136,9 @@ struct bcm2835_desc { #define BCM2835_DMA_S_WIDTH BIT(9) /* 128bit writes if set */ #define BCM2835_DMA_S_DREQ BIT(10) /* enable SREQ for source */ #define BCM2835_DMA_S_IGNORE BIT(11) /* ignore source reads - read 0 */ -#define BCM2835_DMA_BURST_LENGTH(x) ((x & 15) << 12) -#define BCM2835_DMA_PER_MAP(x) ((x & 31) << 16) /* REQ source */ -#define BCM2835_DMA_WAIT(x) ((x & 31) << 21) /* add DMA-wait cycles */ +#define BCM2835_DMA_BURST_LENGTH(x) (((x) & 15) << 12) +#define BCM2835_DMA_PER_MAP(x) (((x) & 31) << 16) /* REQ source */ +#define BCM2835_DMA_WAIT(x) (((x) & 31) << 21) /* add DMA-wait cycles */ #define BCM2835_DMA_NO_WIDE_BURSTS BIT(26) /* no 2 beat write bursts */ /* debug register bits */ @@ -214,17 +214,15 @@ static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc) static void bcm2835_dma_desc_free(struct virt_dma_desc *vd) { - bcm2835_dma_free_cb_chain( - container_of(vd, struct bcm2835_desc, vd)); + bcm2835_dma_free_cb_chain(container_of(vd, struct bcm2835_desc, vd)); } -static void bcm2835_dma_create_cb_set_length( - struct bcm2835_chan *chan, - struct bcm2835_dma_cb *control_block, - size_t len, - size_t period_len, - size_t *total_len, - u32 finalextrainfo) +static void bcm2835_dma_create_cb_set_length(struct bcm2835_chan *chan, + struct bcm2835_dma_cb *control_block, + size_t len, + size_t period_len, + size_t *total_len, + u32 finalextrainfo) { size_t max_len = bcm2835_dma_max_frame_length(chan); @@ -260,10 +258,9 @@ static void bcm2835_dma_create_cb_set_length( control_block->info |= finalextrainfo; } -static inline size_t bcm2835_dma_count_frames_for_sg( - struct bcm2835_chan *c, - struct scatterlist *sgl, - unsigned int sg_len) +static inline size_t bcm2835_dma_count_frames_for_sg(struct bcm2835_chan *c, + struct scatterlist *sgl, + unsigned int sg_len) { size_t frames = 0; struct scatterlist *sgent; @@ -271,8 +268,8 @@ static inline size_t bcm2835_dma_count_frames_for_sg( size_t plength = bcm2835_dma_max_frame_length(c); for_each_sg(sgl, sgent, sg_len, i) - frames += bcm2835_dma_frames_for_length( - sg_dma_len(sgent), plength); + frames += bcm2835_dma_frames_for_length(sg_dma_len(sgent), + plength); return frames; } @@ -298,10 +295,13 @@ static inline size_t bcm2835_dma_count_frames_for_sg( * @gfp: the GFP flag to use for allocation */ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( - struct dma_chan *chan, enum dma_transfer_direction direction, - bool cyclic, u32 info, u32 finalextrainfo, size_t frames, - dma_addr_t src, dma_addr_t dst, size_t buf_len, - size_t period_len, gfp_t gfp) + struct dma_chan *chan, + enum dma_transfer_direction direction, + bool cyclic, u32 info, + u32 finalextrainfo, + size_t frames, dma_addr_t src, + dma_addr_t dst, size_t buf_len, + size_t period_len, gfp_t gfp) { struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); size_t len = buf_len, total_len; @@ -343,10 +343,10 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( /* set up length in control_block if requested */ if (buf_len) { /* calculate length honoring period_length */ - bcm2835_dma_create_cb_set_length( - c, control_block, - len, period_len, &total_len, - cyclic ? finalextrainfo : 0); + bcm2835_dma_create_cb_set_length(c, control_block, + len, period_len, + &total_len, + cyclic ? finalextrainfo : 0); /* calculate new remaining length */ len -= control_block->length; @@ -369,8 +369,8 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( /* the last frame requires extra flags */ d->cb_list[d->frames - 1].cb->info |= finalextrainfo; - /* detect a size missmatch */ - if (buf_len && (d->size != buf_len)) + /* detect a size mismatch */ + if (buf_len && d->size != buf_len) goto error_cb; return d; @@ -410,7 +410,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 int timeout = 10000; + long timeout = 10000; /* * A zero control block address means the channel is idle. @@ -438,7 +438,6 @@ static void bcm2835_dma_abort(struct bcm2835_chan *c) static void bcm2835_dma_start_desc(struct bcm2835_chan *c) { struct virt_dma_desc *vd = vchan_next_desc(&c->vc); - struct bcm2835_desc *d; if (!vd) { c->desc = NULL; @@ -447,9 +446,9 @@ static void bcm2835_dma_start_desc(struct bcm2835_chan *c) list_del(&vd->node); - c->desc = d = to_bcm2835_dma_desc(&vd->tx); + c->desc = to_bcm2835_dma_desc(&vd->tx); - writel(d->cb_list[0].paddr, c->chan_base + BCM2835_DMA_ADDR); + writel(c->desc->cb_list[0].paddr, c->chan_base + BCM2835_DMA_ADDR); writel(BCM2835_DMA_ACTIVE, c->chan_base + BCM2835_DMA_CS); } @@ -560,7 +559,8 @@ static size_t bcm2835_dma_desc_size_pos(struct bcm2835_desc *d, dma_addr_t addr) } static enum dma_status bcm2835_dma_tx_status(struct dma_chan *chan, - dma_cookie_t cookie, struct dma_tx_state *txstate) + dma_cookie_t cookie, + struct dma_tx_state *txstate) { struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct virt_dma_desc *vd; @@ -860,7 +860,7 @@ static const struct of_device_id bcm2835_dma_of_match[] = { MODULE_DEVICE_TABLE(of, bcm2835_dma_of_match); static struct dma_chan *bcm2835_dma_xlate(struct of_phandle_args *spec, - struct of_dma *ofdma) + struct of_dma *ofdma) { struct bcm2835_dmadev *d = ofdma->of_dma_data; struct dma_chan *chan; @@ -883,7 +883,7 @@ static int bcm2835_dma_probe(struct platform_device *pdev) int i, j; int irq[BCM2835_DMA_MAX_DMA_CHAN_SUPPORTED + 1]; int irq_flags; - uint32_t chans_available; + u32 chans_available; char chan_name[BCM2835_DMA_CHAN_NAME_SIZE]; if (!pdev->dev.dma_mask) @@ -942,8 +942,8 @@ static int bcm2835_dma_probe(struct platform_device *pdev) /* Request DMA channel mask from device tree */ if (of_property_read_u32(pdev->dev.of_node, - "brcm,dma-channel-mask", - &chans_available)) { + "brcm,dma-channel-mask", + &chans_available)) { dev_err(&pdev->dev, "Failed to get channel mask\n"); rc = -EINVAL; goto err_no_dma; @@ -982,7 +982,7 @@ static int bcm2835_dma_probe(struct platform_device *pdev) /* check if there are other channels that also use this irq */ irq_flags = 0; for (j = 0; j <= BCM2835_DMA_MAX_DMA_CHAN_SUPPORTED; j++) - if ((i != j) && (irq[j] == irq[i])) { + if (i != j && irq[j] == irq[i]) { irq_flags = IRQF_SHARED; break; } @@ -997,7 +997,7 @@ static int bcm2835_dma_probe(struct platform_device *pdev) /* Device-tree DMA controller registration */ rc = of_dma_controller_register(pdev->dev.of_node, - bcm2835_dma_xlate, od); + bcm2835_dma_xlate, od); if (rc) { dev_err(&pdev->dev, "Failed to register DMA controller\n"); goto err_no_dma; From patchwork Wed Mar 13 14:08:27 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: 13591450 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 8E349C54791 for ; Wed, 13 Mar 2024 14:09:32 +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=qxRl5qhBb0ai77OIzpGduPV12+BahAVZJuPHOCvP+NI=; b=Lu/f7Y7dO6YxaX p7ZTO2xyXE8RAGBK/54cHUwxD6WmDVwiQCI21p5vf9l5btAIGwUOLxqOo0ELuBJDPepdtMdn/qdVu Yt9lN7J7sYuxvFOskBkEceFPmP2e96GWGVkiJbI7SDMUr7eDGxh5/6hsQoSQpUUYxdmNZxEJIVI+G UH/zcLR5p3o73bbzpxlDMDgQlVU4YKVAlWZbXU6ZOrHSuT4RIftDYAsDU0ekjC3ReYesKoe8QiEN/ Jtzn281SKBPrtpKXFfTHeUry1s8DUAb6CkB7KjUFS3pJc60NBloRSw1HKZg9nNxJPy+nmoq8tDUB4 JxC80JpzH7KBrJ/oOpAg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPI8-0000000AMNX-3gfV; Wed, 13 Mar 2024 14:09:12 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPHo-0000000AM8F-1pWS for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2024 14:08:56 +0000 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a3fb8b0b7acso626109766b.2 for ; Wed, 13 Mar 2024 07:08:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1710338930; x=1710943730; 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=1+qHX7SxjysW+WBJacqKls7OusP1dBurz/GxAdGzZn4=; b=Wp51YLtXuI6zXdnggSXlZHWkRLU/142TZ98BKvOxu+NQtGNyMTydMZ59o5+uv0kyJj cFHaWnc3mjMhNEmL0JMQ7qPl3obWJ7stbNyuQ0DqnjVRsaCcYn0KDtfXSEiMIx66Ai/V 51JyPactFnYL3QqeQ5ATZdQP5k8SWIZ1Ac4W0h+Jzd7YuslI8vIY2WgI8w9eufNK7snK ZD+0fR1H8wBLBgjnVGA24lJWYqkTXk9Va+7cdltgvnh/9VN3V3xPtecuKJulXORiAtu3 V1zj+XMqQ6+4j8vHlwJwKKHqUwzaJbxnk7g+GkvF2uBhMmTGiy9Bo4YH5c5kk0KiZFs3 MliA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710338930; x=1710943730; 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=1+qHX7SxjysW+WBJacqKls7OusP1dBurz/GxAdGzZn4=; b=Nd0dBU346P5lZ3OnP3F8K/o7AHBUVTp17goF1zyflfGK8lC+WarhpjOe4RChdBLUxv 5VUUNZCPuZDfqnPsIhVFQeoJ2dTR7DPPlPLJlqj5279SU1RJghWMGFP1kPgpToLruKbU 8exuqE3hhzxWEH1SLBAcaiqJhHQ+RpeSnzrntKUIpmIg1n/s2cK7NYvHm1B0y/c6DQVF KBDR1cDThkEO5qa8t/RBnWqHfIt54zAx37CLaR+mBr0MHWqp7ZK0SoAXvB4GxEDz7qU8 OPKBo/jtf/e9kV8lqH3/XEgP/JtQKivF+LhW9C9jmi/n3xJpMVOJHsNv92sWAmcxoN+K cnTA== X-Forwarded-Encrypted: i=1; AJvYcCWhqiqmOqJMTdByIXmmqPaofyGxDsze3eGmT3CVeP7C7eyc+wTn+zXbJiFa+8T2ZzRRJHZF0W7Os4yhQHKI24euIKVaEMZkT68C14S5aESHrqPlfKg= X-Gm-Message-State: AOJu0YzDenwqfTxBta0c8alNPKUKCaW3AvlalM4JJcLLcyw1DTP/xBgV E3fdqeSoSx5m6qEnWwfhF5rOeQtDQwx3mKwhDk5+7Q6sS2rT56Uxhv0EU/ggYMk= X-Google-Smtp-Source: AGHT+IEQhY1LzZrqKG46nbukNSNTyWGekHoM+pNHxFUDfOcSbMTklqa6OdRjNge+Unwg8hREwyz0mg== X-Received: by 2002:a17:907:c30a:b0:a45:84e7:b265 with SMTP id tl10-20020a170907c30a00b00a4584e7b265mr2885296ejc.7.1710338929747; Wed, 13 Mar 2024 07:08:49 -0700 (PDT) Received: from localhost (host-82-56-173-172.retail.telecomitalia.it. [82.56.173.172]) by smtp.gmail.com with ESMTPSA id o13-20020a17090611cd00b00a45ff1fe8dasm4792514eja.115.2024.03.13.07.08.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 07:08:49 -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 02/15] dmaengine: bcm2835: Add support for per-channel flags Date: Wed, 13 Mar 2024 15:08:27 +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_070852_561664_20118514 X-CRM114-Status: GOOD ( 16.94 ) 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: Phil Elwell Add the ability to interpret the high bits of the dreq specifier as flags to be included in the DMA_CS register. The motivation for this change is the ability to set the DISDEBUG flag for SD card transfers to avoid corruption when using the VPU debugger. Signed-off-by: Phil Elwell Signed-off-by: Andrea della Porta --- drivers/dma/bcm2835-dma.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index 428253b468ac..3d9973dd041d 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -137,6 +137,10 @@ struct bcm2835_desc { #define BCM2835_DMA_S_DREQ BIT(10) /* enable SREQ for source */ #define BCM2835_DMA_S_IGNORE BIT(11) /* ignore source reads - read 0 */ #define BCM2835_DMA_BURST_LENGTH(x) (((x) & 15) << 12) +#define BCM2835_DMA_CS_FLAGS(x) ((x) & (BCM2835_DMA_PRIORITY(15) | \ + BCM2835_DMA_PANIC_PRIORITY(15) | \ + BCM2835_DMA_WAIT_FOR_WRITES | \ + BCM2835_DMA_DIS_DEBUG)) #define BCM2835_DMA_PER_MAP(x) (((x) & 31) << 16) /* REQ source */ #define BCM2835_DMA_WAIT(x) (((x) & 31) << 21) /* add DMA-wait cycles */ #define BCM2835_DMA_NO_WIDE_BURSTS BIT(26) /* no 2 beat write bursts */ @@ -449,7 +453,8 @@ static void bcm2835_dma_start_desc(struct bcm2835_chan *c) c->desc = to_bcm2835_dma_desc(&vd->tx); writel(c->desc->cb_list[0].paddr, c->chan_base + BCM2835_DMA_ADDR); - writel(BCM2835_DMA_ACTIVE, c->chan_base + BCM2835_DMA_CS); + writel(BCM2835_DMA_ACTIVE | BCM2835_DMA_CS_FLAGS(c->dreq), + c->chan_base + BCM2835_DMA_CS); } static irqreturn_t bcm2835_dma_callback(int irq, void *data) @@ -476,7 +481,8 @@ static irqreturn_t bcm2835_dma_callback(int irq, void *data) * if this IRQ handler is threaded.) If the channel is finished, it * will remain idle despite the ACTIVE flag being set. */ - writel(BCM2835_DMA_INT | BCM2835_DMA_ACTIVE, + writel(BCM2835_DMA_INT | BCM2835_DMA_ACTIVE | + BCM2835_DMA_CS_FLAGS(c->dreq), c->chan_base + BCM2835_DMA_CS); d = c->desc; From patchwork Wed Mar 13 14:08:28 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: 13591451 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 3DE24C54E58 for ; Wed, 13 Mar 2024 14:09:33 +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=DjCMG6AUgDPZKmCsffG5xdjtR2EBhY9HoZrNjaqFiuA=; b=cnSEvUHf2c2obA 2ALro/qgZsWwfSRNVY5RWNF9JFi/TMLtM25oqZU3ljSjijCxI7saIraDAgyRcMyDMTae1OySJEnnm MVy58ay0wqFg6IL22x0VKt2AePYIqBQtYia92hjKXjjvSKSMwraZmiv948qhu2bfeo8GdZqqE1trT 0QNJAUoBl3ZcXZ60VEOeb/VUqoKyPZipSEVxdNPFmDESSQP6LaxWJd9r8KjVYXlSbRFhyH3QnBIVN ISij6aUEfYQwOacjGvjWkL6vXMVvXaxcw9ZQb3DTwH9KPpICgqS8OlVWpS3nmbl8sMvuSNKD042XK eE4UROHwbOt8gt4IK2yQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPIH-0000000AMSR-3ye1; Wed, 13 Mar 2024 14:09:21 +0000 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPHp-0000000AM8J-38BL for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2024 14:08:58 +0000 Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a2f22bfb4e6so994054766b.0 for ; Wed, 13 Mar 2024 07:08:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1710338931; x=1710943731; 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=7L2vUwfipr2gKOB26ZSV+Vf7Bi2o+2MhICmn4R7KPa0=; b=KglAargy+iEW/a0NiEcZKHxAltmS3E6O5rDkIKEXaQhnBuOgnEmEgGgUroGwfzcfS9 nPvZrAGTunsISWiSIN51iYxK0TgxNB4pThU/I4BOSGW6jTg1kCbEWWS9/ckCyqCGiK4o pAYwACLeO9QcJVR1UxlDbFKjUH0AilywYMPvZ5kV+vJl/TUq0nUbFlkif7eih3Kygars gmIXs6a2DRzamKeoDrOX7CQR31SFyvwJEaBdhkBBZsGFTlztiCBPlRdU20KSH8XeGeG6 OlA2z2nDSQAdEPGFlUqFf/pkG3YwnlKPQiCpSyNwvfw+pT14X3uELSAeQmLOkS7zc84S oQ+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710338931; x=1710943731; 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=7L2vUwfipr2gKOB26ZSV+Vf7Bi2o+2MhICmn4R7KPa0=; b=IjTM4tBgtb0D8oQ4rGRDoStmXD5lRc4wx3Yea7jf3wqKat9Keb9956gOxv1EfHaTWX fUiHZC91R8BizjVzvQtGWgM+yGA0nUEFOxNKIRhoUE9GYm/HunYQ2MdsgqJqF2dvX9Mn MLBB6B7yNeDX25X++XinQG/mCx9PFSQaMWjVPZmnA1jo+BTJXNmSGDSmBpgTBF89zYmh GxZ/tBhYx1JAsWWAWD2C+mxBOxybTLdsqt43BZDw24q8EBgoof3RaJv8ciQ5qtdJpL+T P+FH6EQq4oWwAvpFtE1fuIc91Y0L4Qz/8v1Tm0Wrr8qRfWgF9hDUzeDi02z7rEttB5/3 mwfw== X-Forwarded-Encrypted: i=1; AJvYcCWa0+b9d/BhUSvpuGEDou+PLSEweumjQzdPgiV1g6rZVSTTVHlsAGpRj4gwP64EfcK94EGkZ/ZENFN40AOC62Dg5qZ8SPb4sBtlICXYDrX4+EUinCM= X-Gm-Message-State: AOJu0YyKGOoiS9p0x8Ejfi8g0n4UEV9FuldBOlR8h/q54sQMuk8TUDEV svy4O6pUx7xDBQUX3/6gXmkuM+/4Pliywn96MhQmiSWN3KNgucqJsl5rrnumOa8= X-Google-Smtp-Source: AGHT+IFuoxBmQfVemyQzXiLcXvQk5/Bj3gVOpZYZDujxntAraTAYvlG61Hp66sCW3jmCCSgQmgCMXA== X-Received: by 2002:a17:906:c784:b0:a46:61ef:2846 with SMTP id cw4-20020a170906c78400b00a4661ef2846mr871027ejb.66.1710338931040; Wed, 13 Mar 2024 07:08:51 -0700 (PDT) Received: from localhost (host-82-56-173-172.retail.telecomitalia.it. [82.56.173.172]) by smtp.gmail.com with ESMTPSA id a21-20020a170906469500b00a4667190a35sm88005ejr.37.2024.03.13.07.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 07:08:50 -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 , Phil Elwell , Andrea della Porta Subject: [PATCH v2 03/15] dmaengine: bcm2835: Add NO_WAIT_RESP, DMA_WIDE_SOURCE and DMA_WIDE_DEST flag Date: Wed, 13 Mar 2024 15:08:28 +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_070853_967102_6B2EC8D3 X-CRM114-Status: GOOD ( 15.80 ) 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: Phil Elwell Use bit 27 of the dreq value (the second cell of the DT DMA descriptor) to request that the WAIT_RESP bit is not set. Use (reserved) bits 24 and 25 of the dreq value (the second cell of the DT DMA descriptor) to request that wide source reads or wide dest writes are required Originally-by: Dom Cobley Originally-by: Phil Elwell Signed-off-by: Andrea della Porta --- drivers/dma/bcm2835-dma.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index 3d9973dd041d..69a77caf78cc 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -145,6 +145,21 @@ struct bcm2835_desc { #define BCM2835_DMA_WAIT(x) (((x) & 31) << 21) /* add DMA-wait cycles */ #define BCM2835_DMA_NO_WIDE_BURSTS BIT(26) /* no 2 beat write bursts */ +/* A fake bit to request that the driver doesn't set the WAIT_RESP bit. */ +#define BCM2835_DMA_NO_WAIT_RESP BIT(27) +#define WAIT_RESP(x) (((x) & BCM2835_DMA_NO_WAIT_RESP) ? \ + 0 : BCM2835_DMA_WAIT_RESP) + +/* A fake bit to request that the driver requires wide reads */ +#define BCM2835_DMA_WIDE_SOURCE BIT(24) +#define WIDE_SOURCE(x) (((x) & BCM2835_DMA_WIDE_SOURCE) ? \ + BCM2835_DMA_S_WIDTH : 0) + +/* A fake bit to request that the driver requires wide writes */ +#define BCM2835_DMA_WIDE_DEST BIT(25) +#define WIDE_DEST(x) (((x) & BCM2835_DMA_WIDE_DEST) ? \ + BCM2835_DMA_D_WIDTH : 0) + /* debug register bits */ #define BCM2835_DMA_DEBUG_LAST_NOT_SET_ERR BIT(0) #define BCM2835_DMA_DEBUG_FIFO_ERR BIT(1) @@ -621,8 +636,9 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_memcpy( { struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; - u32 info = BCM2835_DMA_D_INC | BCM2835_DMA_S_INC; - u32 extra = BCM2835_DMA_INT_EN | BCM2835_DMA_WAIT_RESP; + u32 info = BCM2835_DMA_D_INC | BCM2835_DMA_S_INC | + WAIT_RESP(c->dreq) | WIDE_SOURCE(c->dreq) | WIDE_DEST(c->dreq); + u32 extra = BCM2835_DMA_INT_EN; size_t max_len = bcm2835_dma_max_frame_length(c); size_t frames; @@ -652,7 +668,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg( struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; dma_addr_t src = 0, dst = 0; - u32 info = BCM2835_DMA_WAIT_RESP; + u32 info = WAIT_RESP(c->dreq) | + WIDE_SOURCE(c->dreq) | WIDE_DEST(c->dreq); u32 extra = BCM2835_DMA_INT_EN; size_t frames; @@ -704,7 +721,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; dma_addr_t src, dst; - u32 info = BCM2835_DMA_WAIT_RESP; + u32 info = WAIT_RESP(c->dreq) | WIDE_SOURCE(c->dreq) | WIDE_DEST(c->dreq); u32 extra = 0; size_t max_len = bcm2835_dma_max_frame_length(c); size_t frames; From patchwork Wed Mar 13 14:08:29 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: 13591458 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 16610C54E58 for ; Wed, 13 Mar 2024 14:10:55 +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=VOyP+pdjgznh+dGQJ/A0/J9F8WXem3SBgoOQTLOE0Oo=; b=ZbpIlp9Fdvk7hw 8Rbtkkl7Fc5eUF3MkMjdvFBEZ8DvwX9xoyw2iMaXujC1R36PuSmZQg3xACT0G482CIEyvdB2lO989 Y/O20QXYJ2k8aMnATXAAc/7u0q+7dISmskclkz3I5E9jESzVa6tPf9dZENIkKTEBTj2KUAwud/YEw wfQ9i+3cwvRODJECErm8GbDwVcRtffPpDHuxWtVl8PmahF8yjT33jy2md6amnv9+pqgznJh2mq5iJ UFh8cUaes7cJgQsK4YqDXvipcjuUEXML3r/9tDL4AgDQDB9frpusA1AmDN9rm5xeXUtgzjOpJ3HVt ZDtEEe0xeB8a4AoB5qpg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPJU-0000000ANEA-1Tl8; Wed, 13 Mar 2024 14:10:36 +0000 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPHq-0000000AM9z-0yWV for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2024 14:08:59 +0000 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-5684c3313cdso4681151a12.3 for ; Wed, 13 Mar 2024 07:08:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1710338933; x=1710943733; 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=I53kioFtQ9+NV3RahDpOPJUiNDTHamWrrm2d7gZ/rPs=; b=SCxYUiHeXzNMEMfJcIj/HnX+dhdmCDjxYwHaOJWivUttlObSwv3lZV22pPk+PHkB+L 1QTaI1mCIIOJdRedzWyIsFg/kAcCg7SQAYrkTAnECXHfqhZoJubN1lAu0r5FvJj2FLmP z2dli5mdKUA3zXWJGt+hVr3iQldawzPngHphepiHjCow33stvxYwS3RbRnQiclm5bvAP KWrjdMctzyVYjC4wTAgq1lvR8JCP4V2X/VIxo3lvanM5wgAbXA34EccAuQ+saiuhIVBW fD9ZSc+hst0ACcFDcIVxtCCqv1azM4vMcp8EqdV7uy8HF8quVxCB70l21Fdri3StpXVt CtMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710338933; x=1710943733; 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=I53kioFtQ9+NV3RahDpOPJUiNDTHamWrrm2d7gZ/rPs=; b=vJa+7G5cZ03LG95KNPQilXD0lXXYGwKXoMjRDuoXOWynyy1vI0ee0QSVRVQ/mu8t6i 2vWQxpEsyTwhYRZQG89UrqlhjLygIYqcxuFLTQK2Ab4CC2yO7XT5/GMRruui/Jv1I1xi daojNMDwsDOM1sohfnkvukuU4uh0yJACcU0hdf0wxfC2MQ8JTgEhTJ7NMG6/Z63raa5K St0BsraVdFaS0o7t1Y3CBWAIhWbsW60YCnxRQY3kg0pWSQkwktex1OaEhUAOIkENCbG1 rLF0SkVicDEkG/OBi8sfU9IEbPE0IZsxNubtUBHyv7ltw8wkl9sbuDeb8vPC3sdCel2w 0vtQ== X-Forwarded-Encrypted: i=1; AJvYcCXsgvtFBkzz3VRHvoNvKxrMwkJhh6M8L9HnFInsqbp9uOm6EVq/9gq7TO1oW1aqunpLcMtXwN5cXshKVeIYqgSvT3S9+uGt6yEC5FOAKQoGzqp/rNg= X-Gm-Message-State: AOJu0Yw8vfKPimGf0QnacwgKwz7ZElH27wtRiGPydqlwOfKglExTta9l JLeg8c+YBJ3LkeH0Dbo9eJmAgnsw3NvMvHxsIE5ho8q4Jc5tPgPeQm3JppyjWXM= X-Google-Smtp-Source: AGHT+IHCQaImo5LItH4gVnqRjfNB/SPNM2IFdvzY8VY0xNFroLrYEX7IIpdpQjosUbug1fHTnON4rw== X-Received: by 2002:a50:9ee2:0:b0:566:131b:5b5f with SMTP id a89-20020a509ee2000000b00566131b5b5fmr8554418edf.26.1710338932962; Wed, 13 Mar 2024 07:08:52 -0700 (PDT) Received: from localhost (host-82-56-173-172.retail.telecomitalia.it. [82.56.173.172]) by smtp.gmail.com with ESMTPSA id co25-20020a0564020c1900b00567f6310010sm5081840edb.59.2024.03.13.07.08.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 07:08:52 -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 04/15] dmaengine: bcm2835: Support dma flags for multi-beat burst Date: Wed, 13 Mar 2024 15:08:29 +0100 Message-ID: <897f4540ad1268f3a560a48de8667a6327ce6b7f.1710226514.git.andrea.porta@suse.com> 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_070854_718868_B57135C8 X-CRM114-Status: GOOD ( 14.07 ) 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 Add a control bit to enable a multi-beat burst on a DMA. This improves DMA performance and is required for HDMI audio. Signed-off-by: Dom Cobley Signed-off-by: Andrea della Porta --- drivers/dma/bcm2835-dma.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index 69a77caf78cc..d442f8728c05 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -137,6 +137,7 @@ struct bcm2835_desc { #define BCM2835_DMA_S_DREQ BIT(10) /* enable SREQ for source */ #define BCM2835_DMA_S_IGNORE BIT(11) /* ignore source reads - read 0 */ #define BCM2835_DMA_BURST_LENGTH(x) (((x) & 15) << 12) +#define BCM2835_DMA_GET_BURST_LENGTH(x) (((x) >> 12) & 15) #define BCM2835_DMA_CS_FLAGS(x) ((x) & (BCM2835_DMA_PRIORITY(15) | \ BCM2835_DMA_PANIC_PRIORITY(15) | \ BCM2835_DMA_WAIT_FOR_WRITES | \ @@ -160,6 +161,11 @@ struct bcm2835_desc { #define WIDE_DEST(x) (((x) & BCM2835_DMA_WIDE_DEST) ? \ BCM2835_DMA_D_WIDTH : 0) +/* A fake bit to request that the driver requires multi-beat burst */ +#define BCM2835_DMA_BURST BIT(30) +#define BURST_LENGTH(x) (((x) & BCM2835_DMA_BURST) ? \ + BCM2835_DMA_BURST_LENGTH(3) : 0) + /* debug register bits */ #define BCM2835_DMA_DEBUG_LAST_NOT_SET_ERR BIT(0) #define BCM2835_DMA_DEBUG_FIFO_ERR BIT(1) @@ -637,7 +643,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_memcpy( struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; u32 info = BCM2835_DMA_D_INC | BCM2835_DMA_S_INC | - WAIT_RESP(c->dreq) | WIDE_SOURCE(c->dreq) | WIDE_DEST(c->dreq); + WAIT_RESP(c->dreq) | WIDE_SOURCE(c->dreq) | + WIDE_DEST(c->dreq) | BURST_LENGTH(c->dreq); u32 extra = BCM2835_DMA_INT_EN; size_t max_len = bcm2835_dma_max_frame_length(c); size_t frames; @@ -668,8 +675,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg( struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; dma_addr_t src = 0, dst = 0; - u32 info = WAIT_RESP(c->dreq) | - WIDE_SOURCE(c->dreq) | WIDE_DEST(c->dreq); + u32 info = WAIT_RESP(c->dreq) | WIDE_SOURCE(c->dreq) | + WIDE_DEST(c->dreq) | BURST_LENGTH(c->dreq); u32 extra = BCM2835_DMA_INT_EN; size_t frames; @@ -721,7 +728,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; dma_addr_t src, dst; - u32 info = WAIT_RESP(c->dreq) | WIDE_SOURCE(c->dreq) | WIDE_DEST(c->dreq); + u32 info = WAIT_RESP(c->dreq) | WIDE_SOURCE(c->dreq) | + WIDE_DEST(c->dreq) | BURST_LENGTH(c->dreq); u32 extra = 0; size_t max_len = bcm2835_dma_max_frame_length(c); size_t frames; 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); } From patchwork Wed Mar 13 14:08:31 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: 13591455 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 BC172C54791 for ; Wed, 13 Mar 2024 14:10:08 +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=GJdD5VjoT8W9WmA5fbg1nGBum458DWCMZhOr3RggHbQ=; b=AIp9vm4zJikAEe RSirGacuVc9u0kFH4C7GX+BPxJhEMbDP1BR+EEAVg3LRogMNNBjV2DygGDoNq0CcGlDzjXL2jyaG5 iAEevspvBfF/4m/ye4ADEKduutdpeCiCppDb5GH+7bXn/kRrrGXCcmAfqYDS3vJY8t5T7XML79Mia rd4gcJSW6czFGqLjwfHjAQJEx8NwMVa9INhbyfxdeD5nxph0HKTssirml/cDqWVC8IRBv48qAhBMh flaRHL1w2MWG/c98SuembKx9fEvWFJRHLG3rFSkRwGSMiMUXYdIwWYPb9FkDuO53guSc5USQ4k9KG hSFd4ojvAtVJ2JW+6C5g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPIr-0000000AMpu-07as; Wed, 13 Mar 2024 14:09:57 +0000 Received: from mail-ed1-f45.google.com ([209.85.208.45]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPI2-0000000AMBw-1tyx for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2024 14:09:08 +0000 Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-563cb3ba9daso7937734a12.3 for ; Wed, 13 Mar 2024 07:08:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1710338936; x=1710943736; 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=sxhFutbq+Y+6CXRWNL6/WkO0dcfzVUrgph3wJP5gbgo=; b=QtGCWLNhOMBnyiG/ML/OHuM5WEnjLVFN9Ik7EwxVLtexLgE8MvJEU75xOERZKGk3VY VFkvvX0WeKwKFwqnWuoUhjiayEeLnue02T+7vp0j8iCAFZC3S3FoS3Jk9TInxCBKF0Rr BJIxzy43i4tVuIRoB1fAzlHVPqrViIcRWZ6ugr0HLM5JU8Gs6ZZs+0oDMY+0O+aWgwdE eBluvhZOiMK7xCdS8Pae/v8/m+AqqLNhYj52XRaI285U0idFyP1pJdaJ9lQqLp4hlRfO SroJWk/FK82wsQhiUi6nIINpZ7c6kpIhOK6XKMexSFRM3GO1wlgcB7geCyiS+sPt0CTu kh9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710338936; x=1710943736; 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=sxhFutbq+Y+6CXRWNL6/WkO0dcfzVUrgph3wJP5gbgo=; b=KjE0iIArS8sf26+PRwFWCGlId7dJJwoJqCfY/CQY/smkmdx8Ysjib3gcREhJBd9u8W FNJBJ0WfFg3Wmr7nY+mor6CE7gDKI0ydaNwNekvJRO4gfgAOdcoO1PSmuLaqBDW94DdL BKYjbQJYY6tmyL71ID0aZz9SuK5AGmha3o60+aq8HMcwjvDRiSTkMaGTmrclTuOCRaYM v3JFYlDp2XEFpZLppc0m9cYX64EosKJednLbG/yCwT+hMhKif6DDX0LoLjGxqrGBcszk 2LiWZzzPy6guGXoC4XmMwi76Wu1u++oBH0D/g3s8zr/16tWYxdey08hqTFdHpNlyBtHI lYdg== X-Forwarded-Encrypted: i=1; AJvYcCWzhM9E4a9HSJg6sh2ms2jmQ1jzw4MGE/HGmJjV8H7hpE60AWc/fJ/JD+kSyBA2sDVkBDBQDGxq2cCNt41YayavMfqApQZIOONthaQ7qTNmhJzFvNM= X-Gm-Message-State: AOJu0YziYpjh2N/TfBuJztB5Z2sNxbLqfsmIda5/FqSyPEhPht9Hqz6x oh5WAwQiuIvlC7+O2ecJxaudHQK3ltHPfL3thbvbMaJDTW8lV6NGZnnEtzr+GAk= X-Google-Smtp-Source: AGHT+IHGhXmShKjT2bgraHVp5n3iw9VUmNLl0npsFuV9YOWwmAyXpR7Lt4bTH+kxGpjAq2xtbLLcbw== X-Received: by 2002:a17:906:55cf:b0:a46:5fd2:f26a with SMTP id z15-20020a17090655cf00b00a465fd2f26amr1116133ejp.65.1710338935915; Wed, 13 Mar 2024 07:08:55 -0700 (PDT) Received: from localhost (host-82-56-173-172.retail.telecomitalia.it. [82.56.173.172]) by smtp.gmail.com with ESMTPSA id ku2-20020a170907788200b00a44936527b5sm4907081ejc.99.2024.03.13.07.08.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 07:08:55 -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 06/15] dmaengine: bcm2835: Support common dma-channel-mask Date: Wed, 13 Mar 2024 15:08:31 +0100 Message-ID: <33415530388855ba8964c1f32dd126cb173e191d.1710226514.git.andrea.porta@suse.com> 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_070906_649441_9608D579 X-CRM114-Status: GOOD ( 15.10 ) 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 Nowadays there is a generic property for dma-channel-mask in the DMA controller binding. So prefer this one instead of the old vendor specific one. Print a warning in case the old one is used. Btw use the result of of_property_read_u32() as return code in error case. Signed-off-by: Stefan Wahren Signed-off-by: Andrea della Porta --- drivers/dma/bcm2835-dma.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index 6b8e7461efaf..88aaf7769864 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -986,12 +986,19 @@ static int bcm2835_dma_probe(struct platform_device *pdev) } /* Request DMA channel mask from device tree */ - if (of_property_read_u32(pdev->dev.of_node, - "brcm,dma-channel-mask", - &chans_available)) { - dev_err(&pdev->dev, "Failed to get channel mask\n"); - rc = -EINVAL; - goto err_no_dma; + rc = of_property_read_u32(pdev->dev.of_node, "dma-channel-mask", + &chans_available); + + if (rc) { + /* Try deprecated property */ + if (of_property_read_u32(pdev->dev.of_node, + "brcm,dma-channel-mask", + &chans_available)) { + dev_err(&pdev->dev, "Failed to get channel mask\n"); + goto err_no_dma; + } + + dev_warn(&pdev->dev, "Please update DT blob\n"); } /* get irqs for each channel that we support */ From patchwork Wed Mar 13 14:08:32 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: 13591454 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 6CB5BC54E58 for ; Wed, 13 Mar 2024 14:09:58 +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=sF/eS5RwQ8zteGK/+S89Dw3YSoRsP1P+tMFU9DE1p8o=; b=Auefl+NEa1BLPI kQLzl6chibRyA3LjfzCygoHXH1nzYH4J+eaoRpwqR2jVaUUjW5lgod4QYa1+AM1OogdBQRw2/QyTj Cjp64XRlQ+kSYyisOJCoEgPLicr4YaHVyzmFF6OURy4uyryNL4Fqm+VN6tYzL4qMreYSe53zaqNwf N2GX+Y/funjAYvOIK48QTcxh9hvsuD+V0TR5GlecWvvWi4jTpB7/NNQdxo8nWVOPWfx8ryu0tfum2 TWJ0CU2aWobWqsxNbVLzlWUG4mVio+hpqvCb1Lz7uI7dVGc3LO0jZHzvvWhvCRTXbzMP0HwQrSuX6 N6E5hA8v8XyB+m26HqnQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPIe-0000000AMiH-41wr; Wed, 13 Mar 2024 14:09:44 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPI1-0000000AMGe-2fwP for linux-arm-kernel@bombadil.infradead.org; Wed, 13 Mar 2024 14:09:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=3F4XzmOcl2eqQO65zKyWh9Neo+d3tuBvcb7/Ztq+tSY=; b=p6fzNowowJkk3sLmHcRrMKfWLe o7D1AOxLwpGJRQEdSngtFfPGhNsf1jVlFjgRhEEezFxpYWPpTpz4GCR85+JiJQf0vEKhtUs5J1HS4 q69CvgSNzrjBrfW/h/zX4M2+trH8T/xl6tlqsyjEGDlGmnkoOent07VcHxRSZ/K8EwAsGGrj4Xg9m mVdusniVNjXaS4Q9W4Gn9HKTcFxt2/10X8GkDUGs4KFyD91ZZ0Z/FFh0AvFZ89fr96YNFDzpb4z+J emRpW3/eLmcPXuWvSpYasINnR2gTpNlylqho8R7GxEMPNMbTkioDBGDvSepmQZOPmnDxKOONdtpXa S7Kka67Q==; Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPHx-0000000A3BQ-3mWM for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2024 14:09:04 +0000 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a44cdb2d3a6so142439366b.2 for ; Wed, 13 Mar 2024 07:08:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1710338937; x=1710943737; 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=3F4XzmOcl2eqQO65zKyWh9Neo+d3tuBvcb7/Ztq+tSY=; b=BZstxep9N2O/xzhOxtutwhUp5KCaxmJ/yPKivV4F1J7Iq4tELg4QYRwZI1cX41JeuT NEN2AbJwsbF/qEFGOufhrABVxgHB3I9/CnTY7gFboUlEUL6nvWj5X1lU3jJnBz7gk4Us VgwlnV0wB6mXWYiBPlLbCZYt5jYObBU4aEhCBzCD8RQxsEgk7WpRrPz0f5a9JTSAnezw HOiJueKL46akk/+qGurmh5yASLg3+kyvZnDghoOwc9JNj4AeBGEckLCmYSzG5SdqVyN4 V9YmxamPpJYXH7xGcv01j8yZd7ppvOHeR/ZkGj8BGfH7y+pitIHSEAXsCr+1GU94ZCHI aqcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710338937; x=1710943737; 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=3F4XzmOcl2eqQO65zKyWh9Neo+d3tuBvcb7/Ztq+tSY=; b=ROaUioGMB23VDHYwzSNllmx34fs7jDIO6j9u7JZRlStsOSgE5qgMZMoZ6FveaBOuTs 1BDa+nFIk8lSLGoWgy7nMyrHdP2llOpMs/jGs5WrmDgWms9P2PokwcCJDD+UruDgHMQn Nl6wQ5C7meYMSGkCvlU/qUbgKnkSuDquvXy+ljjXFWP7eFpYXym1T+ABlfFGh3WKy5TV oAS0WmW+XSCXMyIV86+Ph3qWn2ZSaCrqtjT+dvQF5eQ72VPvU2BSc3dP9B5Cm4YEr+J1 2wwDqdBSRIaOAjZ1T4393fwmUswcUK4v07zpGM2eXRwvYVI+vEEeclWfoSxivS6mrUBR vZPQ== X-Forwarded-Encrypted: i=1; AJvYcCXGGTyQ/vt3A/Pb1WpxYD1xAdHYS5BUmFn72YKj2eJ9S4VBK1NE3qKU6+AlkdVdzebXV4P7wplp9UjAjlSeROGOLdzDGau1FZWhZUmeqsZssIJT7KA= X-Gm-Message-State: AOJu0Yw729/VbsfJRLGX1oIxg0eeclPwcLLz4S0MIb/ONxxydg0kkk2K LtGgn8lKlWtzOALpjekenQn4uR3qsTTV5txARLM/CqduTWFDyPcuCFCyy+Vrm74= X-Google-Smtp-Source: AGHT+IE8tL/2CfRwwCWl2jMt8A+KoeR6AlHoKDrFlsgIUe1IIcy432WK1cZ7EUwNcepsH6VYKsKJTQ== X-Received: by 2002:a17:907:94c1:b0:a46:181f:c1c3 with SMTP id dn1-20020a17090794c100b00a46181fc1c3mr5229336ejc.70.1710338937681; Wed, 13 Mar 2024 07:08:57 -0700 (PDT) Received: from localhost (host-82-56-173-172.retail.telecomitalia.it. [82.56.173.172]) by smtp.gmail.com with ESMTPSA id le13-20020a170906ae0d00b00a461d26713fsm3587962ejb.103.2024.03.13.07.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 07:08:57 -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 07/15] dmaengine: bcm2835: move CB info generation into separate function Date: Wed, 13 Mar 2024 15:08:32 +0100 Message-ID: <1336c1bc9d7076080f101e530068030640aff8e5.1710226514.git.andrea.porta@suse.com> 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_140902_190070_151EAA26 X-CRM114-Status: GOOD ( 16.63 ) 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 Actually the generation of the Control Block info follows some simple rules. So handle this with a separate function to avoid open coding for every DMA operation. Another advantage is that we can easier introduce other platforms with different info bits. Signed-off-by: Stefan Wahren Signed-off-by: Andrea della Porta --- drivers/dma/bcm2835-dma.c | 54 +++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index 88aaf7769864..c651aca363c2 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -226,6 +226,34 @@ static inline struct bcm2835_desc *to_bcm2835_dma_desc( return container_of(t, struct bcm2835_desc, vd.tx); } +static u32 bcm2835_dma_prepare_cb_info(struct bcm2835_chan *c, + enum dma_transfer_direction direction, + bool zero_page) +{ + u32 result = WAIT_RESP(c->dreq) | WIDE_SOURCE(c->dreq) | + WIDE_DEST(c->dreq) | BURST_LENGTH(c->dreq); + + if (direction == DMA_MEM_TO_MEM) + return result | BCM2835_DMA_D_INC | BCM2835_DMA_S_INC; + + /* Setup DREQ channel */ + if (c->dreq != 0) + result |= BCM2835_DMA_PER_MAP(c->dreq); + + if (direction == DMA_DEV_TO_MEM) { + result |= BCM2835_DMA_S_DREQ | BCM2835_DMA_D_INC; + } else { + result |= BCM2835_DMA_D_DREQ | BCM2835_DMA_S_INC; + + /* non-lite channels can write zeroes w/o accessing memory */ + if (zero_page && !c->is_lite_channel) { + result |= BCM2835_DMA_S_IGNORE; + } + } + + return result; +} + static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc) { size_t i; @@ -656,9 +684,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_memcpy( { struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; - u32 info = BCM2835_DMA_D_INC | BCM2835_DMA_S_INC | - WAIT_RESP(c->dreq) | WIDE_SOURCE(c->dreq) | - WIDE_DEST(c->dreq) | BURST_LENGTH(c->dreq); + u32 info = bcm2835_dma_prepare_cb_info(c, DMA_MEM_TO_MEM, false); u32 extra = BCM2835_DMA_INT_EN; size_t max_len = bcm2835_dma_max_frame_length(c); size_t frames; @@ -689,8 +715,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg( struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; dma_addr_t src = 0, dst = 0; - u32 info = WAIT_RESP(c->dreq) | WIDE_SOURCE(c->dreq) | - WIDE_DEST(c->dreq) | BURST_LENGTH(c->dreq); + u32 info = bcm2835_dma_prepare_cb_info(c, direction, false); u32 extra = BCM2835_DMA_INT_EN; size_t frames; @@ -700,19 +725,14 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg( return NULL; } - if (c->dreq != 0) - info |= BCM2835_DMA_PER_MAP(c->dreq); - if (direction == DMA_DEV_TO_MEM) { if (c->cfg.src_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES) return NULL; src = c->cfg.src_addr; - info |= BCM2835_DMA_S_DREQ | BCM2835_DMA_D_INC; } else { if (c->cfg.dst_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES) return NULL; dst = c->cfg.dst_addr; - info |= BCM2835_DMA_D_DREQ | BCM2835_DMA_S_INC; } /* count frames in sg list */ @@ -742,8 +762,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; dma_addr_t src, dst; - u32 info = WAIT_RESP(c->dreq) | WIDE_SOURCE(c->dreq) | - WIDE_DEST(c->dreq) | BURST_LENGTH(c->dreq); + u32 info = bcm2835_dma_prepare_cb_info(c, direction, + buf_addr == od->zero_page); u32 extra = 0; size_t max_len = bcm2835_dma_max_frame_length(c); size_t frames; @@ -774,26 +794,16 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( "%s: buffer_length (%zd) is not a multiple of period_len (%zd)\n", __func__, buf_len, period_len); - /* Setup DREQ channel */ - if (c->dreq != 0) - info |= BCM2835_DMA_PER_MAP(c->dreq); - if (direction == DMA_DEV_TO_MEM) { if (c->cfg.src_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES) return NULL; src = c->cfg.src_addr; dst = buf_addr; - info |= BCM2835_DMA_S_DREQ | BCM2835_DMA_D_INC; } else { if (c->cfg.dst_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES) return NULL; dst = c->cfg.dst_addr; src = buf_addr; - info |= BCM2835_DMA_D_DREQ | BCM2835_DMA_S_INC; - - /* non-lite channels can write zeroes w/o accessing memory */ - if (buf_addr == od->zero_page && !c->is_lite_channel) - info |= BCM2835_DMA_S_IGNORE; } /* calculate number of frames */ From patchwork Wed Mar 13 14:08:33 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: 13591457 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 AACA8C54791 for ; Wed, 13 Mar 2024 14:10:27 +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=NloihU7prmSn7ZCo+AfdozgHMAI+82iBfShQUdwndUg=; b=ICc2Xe68ZajqN0 ygU91ociRYypfuNTdXKFFSzRlOtEpSq0Fx2ySN9WZaSztXDvwSdbunirGFnBMta+GcwlH0ttElb49 iqZ8dDhLihS+WOodCb9mZLDY6uPzJRAFrkC15s7cFeoQ1+HCgMwOzZfQKfjS2iKunZcp/brsjqpsp Go3b420nbFwN21LdPQKOO8YhpgQine1Jqw7UoltZmoLiUvguE2D45FvyDrsn5YdxeBxwsJgy09crH XWvuFTDblrSCtgsFkW1VulrjMR7uoqWGqDQ7TB7LVYx+Nmwlwjdlng9L/ErGlAJTvuYrSuNUKqJvv abJi2uiMtBlQFD6bk0KA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPJ5-0000000AMzk-2lMs; Wed, 13 Mar 2024 14:10:11 +0000 Received: from mail-lj1-f174.google.com ([209.85.208.174]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPI3-0000000AMDq-3Dig for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2024 14:09:10 +0000 Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2d094bc2244so101805281fa.1 for ; Wed, 13 Mar 2024 07:09:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1710338939; x=1710943739; 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=/xE94iw3mEagAF+/7KUdjRC+1ga8rdDd3hiFvVOScHQ=; b=WO7eOVFzGSLc/QRczd0cmTobP5baazUVGZV07L5fqGRiRjnGVMYCc/ryW9L/msTXQX oD88h/RPc2ha7ejzk9+2GP63wD1u6v8JcB6DSKK7Arnod9ZRp/bNH2QC5ZvS/SDSHuLh 2X6DxH2htZi1MCbVWlSsD20zU8Xcv7CNM3T6vDl5TE/LB6pBDkZTHm7hKIEKpPwfDY3+ BgA6S+hnfp022l0Rq7tmv/7xfo1oBvs+b45AM5Dg6pMoRffB9n5XG1V6UtP9eJQV+PKQ 0k7VQHs/G6MXH8tKscvSwYAk7jPZYHe+08Hp7OV/lBrqUitIGZCPXZnpeAlz8eTJgEVt R7jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710338939; x=1710943739; 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=/xE94iw3mEagAF+/7KUdjRC+1ga8rdDd3hiFvVOScHQ=; b=HDf7zVGnV2qCl6hIZABLVQ96WLM2MNq9KPTUtsB/2W98b56RS+GjmGZaHx4GrK9MjR abLArovMFuw6w7ZTJAN34CazrEz3a76EqySL4RIiJinguYQMnxYYbU+s0TZyY5bRRS69 zosjuQKAWQh/wjcP5cTJfTTJq6EvXbO8Io1JDMrqJ7v2lCCJ4i4pZ1KWuFNuMNJTQsdK zzla+urbb6g35lV+ZbGnFpvfmQ6qqelHF3aG889IG+JX4CQcHDRbjmKnl115chHpD0K3 A0vOdyBisWfSSQHPr74RZKtF3gfkTH8S1dGnhkKLhIzTtm+vlEXOytKWMURx7a5IjHNC vpVA== X-Forwarded-Encrypted: i=1; AJvYcCVdfo7SBd53vGYf+uVaNU7JjSAnabWXwfEsJ8Lc547i+V/pdLVEwboijWFTWwU1g5yAv+Ipw1rVVnQRUw8SBUMDsn6EWNJSFtuOrQJm8DNzHHemEPQ= X-Gm-Message-State: AOJu0YxtlDXDSic7TrpXQOkxQeZo9IQuYW/RLqpG04BB4NvpMIt22AfN uW2GKOWOTdQEs5C2LHTV9Z41XnbLOm0dkOsrijLYGpEtIcY2rjXnB4b7WUtyqZM= X-Google-Smtp-Source: AGHT+IGXCM0cKznBWGqJ434M1t+ZyGCueMZWhnfsJta91SqnLtQTo1W4zmpjpEXIYq8BRQy0a3lQ5w== X-Received: by 2002:a05:651c:222b:b0:2d2:751f:abb2 with SMTP id y43-20020a05651c222b00b002d2751fabb2mr4008668ljq.3.1710338938746; Wed, 13 Mar 2024 07:08:58 -0700 (PDT) Received: from localhost (host-82-56-173-172.retail.telecomitalia.it. [82.56.173.172]) by smtp.gmail.com with ESMTPSA id ck14-20020a0564021c0e00b0056857c89045sm3228556edb.60.2024.03.13.07.08.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 07:08:58 -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 08/15] dmaengine: bcm2835: move CB final extra info generation into function Date: Wed, 13 Mar 2024 15:08:33 +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_070908_028559_2265CC3E X-CRM114-Status: GOOD ( 14.95 ) 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 Similar to the info generation, generate the final extra info with a separate function. This is necessary to introduce other platforms with different info bits. Signed-off-by: Stefan Wahren Signed-off-by: Andrea della Porta --- drivers/dma/bcm2835-dma.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index c651aca363c2..b633c40142fe 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -254,6 +254,26 @@ static u32 bcm2835_dma_prepare_cb_info(struct bcm2835_chan *c, return result; } +static u32 bcm2835_dma_prepare_cb_extra(struct bcm2835_chan *c, + enum dma_transfer_direction direction, + bool cyclic, bool final, + unsigned long flags) +{ + u32 result = 0; + + if (cyclic) { + if (flags & DMA_PREP_INTERRUPT) + result |= BCM2835_DMA_INT_EN; + } else { + if (!final) + return 0; + + result |= BCM2835_DMA_INT_EN; + } + + return result; +} + static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc) { size_t i; @@ -685,7 +705,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_memcpy( struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; u32 info = bcm2835_dma_prepare_cb_info(c, DMA_MEM_TO_MEM, false); - u32 extra = BCM2835_DMA_INT_EN; + u32 extra = bcm2835_dma_prepare_cb_extra(c, DMA_MEM_TO_MEM, false, + true, 0); size_t max_len = bcm2835_dma_max_frame_length(c); size_t frames; @@ -716,7 +737,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg( struct bcm2835_desc *d; dma_addr_t src = 0, dst = 0; u32 info = bcm2835_dma_prepare_cb_info(c, direction, false); - u32 extra = BCM2835_DMA_INT_EN; + u32 extra = bcm2835_dma_prepare_cb_extra(c, direction, false, true, 0); size_t frames; if (!is_slave_direction(direction)) { @@ -764,7 +785,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( dma_addr_t src, dst; u32 info = bcm2835_dma_prepare_cb_info(c, direction, buf_addr == od->zero_page); - u32 extra = 0; + u32 extra = bcm2835_dma_prepare_cb_extra(c, direction, true, true, 0); size_t max_len = bcm2835_dma_max_frame_length(c); size_t frames; @@ -780,9 +801,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( return NULL; } - if (flags & DMA_PREP_INTERRUPT) - extra |= BCM2835_DMA_INT_EN; - else + if (!(flags & DMA_PREP_INTERRUPT)) period_len = buf_len; /* From patchwork Wed Mar 13 14:08:34 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: 13591459 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 94BC6C54791 for ; Wed, 13 Mar 2024 14:10:59 +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=B5XkrnOWA9TIMyk+gTZSy12gZIBKMXIhjliMH3Pk/q4=; b=QfWxy5WxRK2oxk tZBwVF5c4HSmfoUIErfdgEiftuXHkAdJqHhD3TU8EFbmLkkZiOhJfMGXvdwKMAuVSfiibx+qeMxKM mieCtGoR4NaX+8RCsKcNJjAuc0airNPfmUkP/AfLFyHQQgHx+Ue4ba0H8plHE3944cAtJk8qbhkFw 6+UlDhw797Np21L+XNZDvz7VTfKIibzZDj4RvHa/d5GKBH5weS1wo1mQ8C4B0q6oYZtpG75ezinD7 OGqiwJB5w+BsWz6O22SWVmBoIpkL+InO+KIfYiHITnyQY4y9byrFT9Vi+6PseFolkfVURoiA/TllN v13ftHvF6vSDAUD36Igw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPJY-0000000ANGR-0TNp; Wed, 13 Mar 2024 14:10:40 +0000 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPI4-0000000AME6-1N0c for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2024 14:09:12 +0000 Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a44f2d894b7so140309866b.1 for ; Wed, 13 Mar 2024 07:09:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1710338940; x=1710943740; 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=2aA326qloufGfA/9FJeIrf9CjXOtqN0+M89y+6rWqCo=; b=A5Ap//1URw+2ZfEpL0OOMvGBx2lEIL2Ld0VaAy/jaEEgkNZA50O4EMUpoxSPSvqhvC 8xZ9y0xJyDRnt3dHOZULzX37Pa+dAwMVKcKkteXBWOPLhDOu7dgkgZa0U2EqBY6z2iBU +HeK0f8mx3h5qCP2fCGWiZzX3VFYKRoKT9OzqAaSJW2gTCs9GIkx8pWMXk9ZFAlevxMQ /lGnynUaX3DV28SYvcrSqqG6Mo5ilAwMWqLIlZjaJGGxl/yeAaJ3Qi6NuPZn+ePvUFs9 dFI8jlxb3S9uE6+SMwZDqcKYG04ez8QDldY+HOcf4ORET+qzj+LNhULrhvvJSih25qAH simw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710338940; x=1710943740; 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=2aA326qloufGfA/9FJeIrf9CjXOtqN0+M89y+6rWqCo=; b=Qm7kLOSFytUHRIU+q7gmKUIQUVKMOWAiI3qPNzmIG6WYY4JkNf1+Ei0UFkYxvWichv jA6XznKlPNr8eGR7x4dFLuZp08cYVeXWQ6LlhIPid0MYCTuikHFnoC2gtyoGDCzs2rxa 2UTnkSvogWo1Q15SxkDv5XDaeu5BwvoxM5rkOKw/juvp11LrthRQUrGxKQJvhE2X+xTy byvUV0NKpath9gReYJ68fSZ8TRFvv0JGfUzWooRca16aV6lK8sae16SaJiYn327bPhre 2Z0J5K0yM2IAu+78ENpTjUfGLHblOvuMiGFd8ienGcq3TSrbNzh7MnZtFSgz6NV10+RG PAAw== X-Forwarded-Encrypted: i=1; AJvYcCU2rSOGJ7RZOvrSWgSjHdovv2/oe3EYahwGgu+9kJfpW9ELKJddnkUizlM9ZNEFtSISvfWwby5CcnFph3ztFFG7Jzxekmkl1TegAgFyDriUj4NGfvk= X-Gm-Message-State: AOJu0YwhGXS5XFZ1f6JTDtsIE8gE0f+bcZRKlYz+/hXWj7J2JaKx6oi1 Pi5Ksowmi26BaxzvZLaG3B9Pyu5DTQlbnD8bQT4S1d1rAi+ukhf1zmKN0mZSQVo= X-Google-Smtp-Source: AGHT+IEctktss/OIn1LKfmqGYndGaQjoPtQ3Zxp8D5LODaIB3jm5ZeIbTiROFzeL2/JTnhkfLCvRuQ== X-Received: by 2002:a17:907:94c1:b0:a46:181f:c1c3 with SMTP id dn1-20020a17090794c100b00a46181fc1c3mr5229468ejc.70.1710338939952; Wed, 13 Mar 2024 07:08:59 -0700 (PDT) Received: from localhost (host-82-56-173-172.retail.telecomitalia.it. [82.56.173.172]) by smtp.gmail.com with ESMTPSA id l23-20020a170906a41700b00a440ec600e3sm4885228ejz.121.2024.03.13.07.08.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 07:08:59 -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 09/15] dmaengine: bcm2835: make address increment platform independent Date: Wed, 13 Mar 2024 15:08:34 +0100 Message-ID: <0bf87ad0dc970c34199fd6bc6dbd19b47d382066.1710226514.git.andrea.porta@suse.com> 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_070908_477106_770EE244 X-CRM114-Status: GOOD ( 15.89 ) 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 Actually the criteria to increment source & destination address doesn't based on platform specific bits. It's just the DMA transfer direction which is translated into the info bits. So introduce two new helper functions and get the rid of these platform specifics. Signed-off-by: Stefan Wahren Signed-off-by: Andrea della Porta --- drivers/dma/bcm2835-dma.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index b633c40142fe..6f896bb1a4fe 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -274,6 +274,24 @@ static u32 bcm2835_dma_prepare_cb_extra(struct bcm2835_chan *c, return result; } +static inline bool need_src_incr(enum dma_transfer_direction direction) +{ + return direction != DMA_DEV_TO_MEM; +} + +static inline bool need_dst_incr(enum dma_transfer_direction direction) +{ + switch (direction) { + case DMA_MEM_TO_MEM: + case DMA_DEV_TO_MEM: + return true; + default: + break; + } + + return false; +} + static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc) { size_t i; @@ -355,10 +373,8 @@ static inline size_t bcm2835_dma_count_frames_for_sg(struct bcm2835_chan *c, * @cyclic: it is a cyclic transfer * @info: the default info bits to apply per controlblock * @frames: number of controlblocks to allocate - * @src: the src address to assign (if the S_INC bit is set - * in @info, then it gets incremented) - * @dst: the dst address to assign (if the D_INC bit is set - * in @info, then it gets incremented) + * @src: the src address to assign + * @dst: the dst address to assign * @buf_len: the full buffer length (may also be 0) * @period_len: the period length when to apply @finalextrainfo * in addition to the last transfer @@ -430,9 +446,9 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( d->cb_list[frame - 1].cb->next = cb_entry->paddr; /* update src and dst and length */ - if (src && (info & BCM2835_DMA_S_INC)) + if (src && need_src_incr(direction)) src += control_block->length; - if (dst && (info & BCM2835_DMA_D_INC)) + if (dst && need_dst_incr(direction)) dst += control_block->length; /* Length of total transfer */ From patchwork Wed Mar 13 14:08:35 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: 13591463 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 39544C54E67 for ; Wed, 13 Mar 2024 14:11:10 +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=21uD1NopssPWFTthkusyFHPVp2Ogi3bzxwF5XoDck7U=; b=ZYNAmZF+vaoqzy IX7D+JxpLXQeBX60D37gAoQosIVYjcSxTQKT/ZVLY/DowvF2lMW/MV7wLdIMwwMNywCs2/zO3u/Jm Iu41Jgb14KZ6ONbW0v5SpDxJ9XYKu77i9aT6Eojt3FWb/ekQO7TPUwbBpk/pZVmvzg2MSLDCud+vG ydaLUgS/JPYu3bfy/K9v4f2NhwHLaD2g/B4zs95/X+cE1BVvDwGbddsTloRIQRDPfMdJHE8kkZLGw m6m7/Wnsx0ffpHKT78dAGv40ltp3f8ZFHqKjrBTntrUT/T0D8PHE7w0ZGsWgxfzsXNVCZLpCp4fKy Yr+CmXLE1yi0tRw7zdqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPJj-0000000ANPM-2l8z; Wed, 13 Mar 2024 14:10:51 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPI4-0000000AMEg-1MDA for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2024 14:09:13 +0000 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-a44cdb2d3a6so142448666b.2 for ; Wed, 13 Mar 2024 07:09:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1710338941; x=1710943741; 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=aQCAxLcWayDk9E0aIZHof0VU6EySMCm0kMz7fVOHPV4=; b=fBpfBqsHHAskIaeWgVWHOzqPqmQopuUUH4dLSSE6i0D7cbAUXzV35hP0/+CyH6yj48 A0Qi05BjlBuB5vs3a7AKzy+woy97oYVUEFmEq4Pl6P5Rr7SWOLLEUXAfkfadiJkFzhyZ pMctG/ikC13by8H9ueFDfdGCYqhvLvtocoansVw33/ASOA6MFvrmDaKMUYDGBR32u5Gz V7W1VnkNj5LbvGylBVYkTnf7L4yNXTm7rZ4HnDdkgze5kCrkR2h1YzWwQLlU3liAmTfo EAK1a6jPOHvbuxhwjI/4jC8Avr3El4qFD0H0by3Ox8WnYnuImvrpzeQMHNorDuyCXquS +VDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710338941; x=1710943741; 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=aQCAxLcWayDk9E0aIZHof0VU6EySMCm0kMz7fVOHPV4=; b=XHH/huWlgldrz8HAWXGfgf1vqZdLkKynXpOs/nC8nA5zzpxo0hYDm22JfewnuCY3Cu 6Sc+dNNbIgAgTz3YcbU7Hh/7YGVtGquOa+o8YN2arCUPjLjVWR+Nt1eug9x4H1p6u2co gJ+oZ9adx4CdVxwsuWurOrpFLkWHhBLpkf2X3LVOrq6+EY6CN61vZQuJTXMyoy+mt2wF dsk15oKxrFEgadEkirpi07aLNoNKphwSQCqMZA3Tfs6iE+A1Md13x+gIwLqSJe/l08nk wDojYm3WkOMnFnHUxuWvWS0iwNHMwxq/SQb8hRug4B1vBxp7lDxGkJmE/ljC7T0EN60u CKJg== X-Forwarded-Encrypted: i=1; AJvYcCXNaN+/hsLXDvlYO7rq7xYIiGZuLUlEoZsXajQ0Ya63K/CALBYHFucSFpWcJokWMMEjBGy0WE7/NQ94HXX+Ti2+HMTp+XivLmFT+1LPGUVhFXjKDWc= X-Gm-Message-State: AOJu0YyGKuXnGcBBcNRctzv1K0Iq8OplHOpiFAakY/vDyrQVLjVqRiZA TbkaFu9yhZuDyzTe2hI2N+67A6MwkA2BUOfUUKjjc8+9VZD7O5YQOkV5yvOAjeI= X-Google-Smtp-Source: AGHT+IGz+F3N9s1yqpgvtHwiw7lZ8mJ6jYatA61Yu9YqH5ShW7KVEDKZi1EDxzexoGOUe2u3CrXDzw== X-Received: by 2002:a17:907:c783:b0:a46:37db:b57d with SMTP id tz3-20020a170907c78300b00a4637dbb57dmr149485ejc.15.1710338941200; Wed, 13 Mar 2024 07:09:01 -0700 (PDT) Received: from localhost (host-82-56-173-172.retail.telecomitalia.it. [82.56.173.172]) by smtp.gmail.com with ESMTPSA id h10-20020a170906718a00b00a4658d3e405sm691966ejk.196.2024.03.13.07.09.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 07:09:00 -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 10/15] dmaengine: bcm2385: drop info parameters Date: Wed, 13 Mar 2024 15:08:35 +0100 Message-ID: <27e4028259c6c70b6439e198f62873bf12975b63.1710226514.git.andrea.porta@suse.com> 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_070908_545565_077996B0 X-CRM114-Status: GOOD ( 22.98 ) 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 parameters info and finalextrainfo are platform specific. So drop them by generating them within bcm2835_dma_create_cb_chain(). Signed-off-by: Stefan Wahren Signed-off-by: Andrea della Porta --- drivers/dma/bcm2835-dma.c | 80 +++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 41 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index 6f896bb1a4fe..03d97312a3f8 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -308,12 +308,11 @@ static void bcm2835_dma_desc_free(struct virt_dma_desc *vd) bcm2835_dma_free_cb_chain(container_of(vd, struct bcm2835_desc, vd)); } -static void bcm2835_dma_create_cb_set_length(struct bcm2835_chan *chan, +static bool bcm2835_dma_create_cb_set_length(struct bcm2835_chan *chan, struct bcm2835_dma_cb *control_block, size_t len, size_t period_len, - size_t *total_len, - u32 finalextrainfo) + size_t *total_len) { size_t max_len = bcm2835_dma_max_frame_length(chan); @@ -322,7 +321,7 @@ static void bcm2835_dma_create_cb_set_length(struct bcm2835_chan *chan, /* finished if we have no period_length */ if (!period_len) - return; + return false; /* * period_len means: that we need to generate @@ -336,7 +335,7 @@ static void bcm2835_dma_create_cb_set_length(struct bcm2835_chan *chan, if (*total_len + control_block->length < period_len) { /* update number of bytes in this period so far */ *total_len += control_block->length; - return; + return false; } /* calculate the length that remains to reach period_length */ @@ -345,8 +344,7 @@ static void bcm2835_dma_create_cb_set_length(struct bcm2835_chan *chan, /* reset total_length for next period */ *total_len = 0; - /* add extrainfo bits in info */ - control_block->info |= finalextrainfo; + return true; } static inline size_t bcm2835_dma_count_frames_for_sg(struct bcm2835_chan *c, @@ -371,7 +369,6 @@ static inline size_t bcm2835_dma_count_frames_for_sg(struct bcm2835_chan *c, * @chan: the @dma_chan for which we run this * @direction: the direction in which we transfer * @cyclic: it is a cyclic transfer - * @info: the default info bits to apply per controlblock * @frames: number of controlblocks to allocate * @src: the src address to assign * @dst: the dst address to assign @@ -379,25 +376,27 @@ static inline size_t bcm2835_dma_count_frames_for_sg(struct bcm2835_chan *c, * @period_len: the period length when to apply @finalextrainfo * in addition to the last transfer * this will also break some control-blocks early - * @finalextrainfo: additional bits in last controlblock - * (or when period_len is reached in case of cyclic) * @gfp: the GFP flag to use for allocation + * @flags */ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( struct dma_chan *chan, enum dma_transfer_direction direction, - bool cyclic, u32 info, - u32 finalextrainfo, - size_t frames, dma_addr_t src, - dma_addr_t dst, size_t buf_len, - size_t period_len, gfp_t gfp) + bool cyclic, size_t frames, + dma_addr_t src, dma_addr_t dst, + size_t buf_len, size_t period_len, + gfp_t gfp, unsigned long flags) { + struct bcm2835_dmadev *od = to_bcm2835_dma_dev(chan->device); struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); size_t len = buf_len, total_len; size_t frame; struct bcm2835_desc *d; struct bcm2835_cb_entry *cb_entry; struct bcm2835_dma_cb *control_block; + u32 extrainfo = bcm2835_dma_prepare_cb_extra(c, direction, cyclic, + false, flags); + bool zero_page = false; if (!frames) return NULL; @@ -411,6 +410,14 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( d->dir = direction; d->cyclic = cyclic; + switch (direction) { + case DMA_MEM_TO_MEM: + case DMA_DEV_TO_MEM: + break; + default: + zero_page = src == od->zero_page; + } + /* * Iterate over all frames, create a control block * for each frame and link them together. @@ -424,7 +431,8 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( /* fill in the control block */ control_block = cb_entry->cb; - control_block->info = info; + control_block->info = bcm2835_dma_prepare_cb_info(c, direction, + zero_page); control_block->src = src; control_block->dst = dst; control_block->stride = 0; @@ -432,10 +440,12 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( /* set up length in control_block if requested */ if (buf_len) { /* calculate length honoring period_length */ - bcm2835_dma_create_cb_set_length(c, control_block, - len, period_len, - &total_len, - cyclic ? finalextrainfo : 0); + if (bcm2835_dma_create_cb_set_length( + c, control_block, + len, period_len, &total_len)) { + /* add extrainfo bits in info */ + control_block->info |= extrainfo; + } /* calculate new remaining length */ len -= control_block->length; @@ -456,7 +466,9 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( } /* the last frame requires extra flags */ - d->cb_list[d->frames - 1].cb->info |= finalextrainfo; + extrainfo = bcm2835_dma_prepare_cb_extra(c, direction, cyclic, true, + flags); + d->cb_list[d->frames - 1].cb->info |= extrainfo; /* detect a size mismatch */ if (buf_len && d->size != buf_len) @@ -720,9 +732,6 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_memcpy( { struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; - u32 info = bcm2835_dma_prepare_cb_info(c, DMA_MEM_TO_MEM, false); - u32 extra = bcm2835_dma_prepare_cb_extra(c, DMA_MEM_TO_MEM, false, - true, 0); size_t max_len = bcm2835_dma_max_frame_length(c); size_t frames; @@ -734,9 +743,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_memcpy( frames = bcm2835_dma_frames_for_length(len, max_len); /* allocate the CB chain - this also fills in the pointers */ - d = bcm2835_dma_create_cb_chain(chan, DMA_MEM_TO_MEM, false, - info, extra, frames, - src, dst, len, 0, GFP_KERNEL); + d = bcm2835_dma_create_cb_chain(chan, DMA_MEM_TO_MEM, false, frames, + src, dst, len, 0, GFP_KERNEL, 0); if (!d) return NULL; @@ -752,8 +760,6 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg( struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; dma_addr_t src = 0, dst = 0; - u32 info = bcm2835_dma_prepare_cb_info(c, direction, false); - u32 extra = bcm2835_dma_prepare_cb_extra(c, direction, false, true, 0); size_t frames; if (!is_slave_direction(direction)) { @@ -776,10 +782,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg( frames = bcm2835_dma_count_frames_for_sg(c, sgl, sg_len); /* allocate the CB chain */ - d = bcm2835_dma_create_cb_chain(chan, direction, false, - info, extra, - frames, src, dst, 0, 0, - GFP_NOWAIT); + d = bcm2835_dma_create_cb_chain(chan, direction, false, frames, src, + dst, 0, 0, GFP_NOWAIT, 0); if (!d) return NULL; @@ -795,13 +799,9 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( size_t period_len, enum dma_transfer_direction direction, unsigned long flags) { - struct bcm2835_dmadev *od = to_bcm2835_dma_dev(chan->device); struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; dma_addr_t src, dst; - u32 info = bcm2835_dma_prepare_cb_info(c, direction, - buf_addr == od->zero_page); - u32 extra = bcm2835_dma_prepare_cb_extra(c, direction, true, true, 0); size_t max_len = bcm2835_dma_max_frame_length(c); size_t frames; @@ -852,10 +852,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( * note that we need to use GFP_NOWAIT, as the ALSA i2s dmaengine * implementation calls prep_dma_cyclic with interrupts disabled. */ - d = bcm2835_dma_create_cb_chain(chan, direction, true, - info, extra, - frames, src, dst, buf_len, - period_len, GFP_NOWAIT); + d = bcm2835_dma_create_cb_chain(chan, direction, true, frames, src, dst, + buf_len, period_len, GFP_NOWAIT, flags); if (!d) return NULL; From patchwork Wed Mar 13 14:08:36 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: 13591456 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 0F3C0C54E58 for ; Wed, 13 Mar 2024 14:10:13 +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=EWCXPUKSzDGurwsk8IHpKtoo+nHlTv2UBJNZQnfsQUQ=; b=v+tkU/P+NVvKYL 1yhiKuGHTZOsuSeKNk45ak8nYH6+haKyDC4eUvd5k26R5c5Xb8Rb0dIIqKHWTMb4eTZxZAm220SPl VEuG1z8vrsGe7nzCl+2L+tCmg1T/O/TbT9Oc0ZBXLLWItJIHbrf/gLdJpnGHpK+Cmn4ixdXuwTQ61 bgux75VjudE30imTmsYHm0qKoVasDwTz1uoeuWACHq2L8u1IhYEMtTQeef+ISbRG9dYhdUTRiQO7j ikmgsSrqI4WxSnkpk2/P41wv66CJVCBNGhHg71Zbv5GZ/vIJBDgQNl+BpllE1Kv1opjyu9mnytFwa DY32Nppd0ul5RH4xTxIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPIq-0000000AMp9-0IMC; Wed, 13 Mar 2024 14:09:56 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPI3-0000000AMHa-0dPi for linux-arm-kernel@bombadil.infradead.org; Wed, 13 Mar 2024 14:09:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=9F0Go8/yyuHye8yt6k5vc23oD+JipLNS/6TGYAxgmkY=; b=AaUGttznvEqzWwlxbgjUlTzgkH ntn5HCaN+wnrs0UI5/5fFIJ7lgnpeqibh/j7EzqNnJE6QueQaEE0t3O0Zpe/ipn0fn7jny6w2uGTn jD4AZK1TqHcwAKiA33O84eVVh/7xRLngmqJJVnXQDs+iAWNGdjs+wTNFwqUL2MwlEGMsZdHLkI1Q2 /RmGCO8XO/Yq0UH5WH4uGLfohXEZOKDM57CFXzpBItJlfuhQTVr6phW4NGPty95Vvq7UPFa8G66zl TB5IJAGEKan5w5KkCBPl5FSiXWoR/t+Cc78V6/RvfmEvZuk5MN+Mh9s5g2JjcLZrVfuMbRBS4a54g EV6MC0yQ==; Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPHz-0000000A3Bx-2nkY for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2024 14:09:05 +0000 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a46644fee93so59362666b.2 for ; Wed, 13 Mar 2024 07:09:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1710338942; x=1710943742; 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=9F0Go8/yyuHye8yt6k5vc23oD+JipLNS/6TGYAxgmkY=; b=drM1OcGo0iKrKqlYkmj1CUu7liHGVYM9x0Ueb+Uk6o3pc+G/bldzRtIdcYDfDVc5mk q6PnOSNyIomqHD4wohQYXnmH2Ap556CtpqpxMjMddcRwpisRaH4OwsLtlbHZqgHcBxQ3 lurHYFCbXhacE9OPoS6UQXP1Finmtnp5fzREgviyOHdkhOeZe6bnszn7lddzrbRHXqKi QLN5//OEeBhkR2UaVZm4Umw1I6uaeg1e1hg08GM1KUFSnt/DDI3iJPVGvwnc4S6xvZZE 7xOvLf/la/+szC44vFtpxD41U1yLoC+M/+RCd6OUPLbbMHEiPLfcAc7Vl2LTmuPggZqi wJDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710338942; x=1710943742; 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=9F0Go8/yyuHye8yt6k5vc23oD+JipLNS/6TGYAxgmkY=; b=PnSf1bU6ny62/FXjo9+xaR8gikfDfisxfY4WVbldNXPz+kDfO1DU0Yiz58xgeaG9FH oOpP8TUqX6C7U4ay6FPW/F0LNcfF6aGUspLJtUMdX4GE6NZkwmWe8RNZQwOL58xVn66V NxO+NwdUSKf62fMvFTO9rzPl79Wa6U+j5tKnSfl5jx5IKoLIdLEe8DSL3qDhPYeJRspz SxdV/O5/yQbcfwS/gqmA+J4ZkVWWduXMcYE2xW1jWcZ2hPWYHxSChsj2hibD9+mI8XH2 h+ILYHZ92lmoc4KenvLYJwnslDeRyf+zBWCE7iI+Bvnzub0YTkOYTdHxXPDgnRf9yO6K SS0A== X-Forwarded-Encrypted: i=1; AJvYcCU6uHXHSrDyHS6w3z/Wp2/wRiN2dr8z/kbVgoV6769WSmEqLY35xPzkNNKewU5g4DMtUf8sbsl5UbFEiRwLyNQW6gI9EHMzASJHSwGpVRmWsH6d41Y= X-Gm-Message-State: AOJu0Yx9UKK6AmHjP9NZyqbn7YD/B4EMSibV4Z17ljaTIn28rdFhr3P0 sSG8EBSuSEKeY4FGabTSydZFdoROKX0Jb5QKyh3eDzr5mO6kMGOoE+qUSCH0mRg= X-Google-Smtp-Source: AGHT+IEGWqP8QxjwPa6JxODEFxxNSr59dthiRT8AGN4nj6MeDLalxq+7j6Caf6aztQx6EziAU4lTLw== X-Received: by 2002:a17:906:fb81:b0:a43:29e1:6db8 with SMTP id lr1-20020a170906fb8100b00a4329e16db8mr8168617ejb.9.1710338942448; Wed, 13 Mar 2024 07:09:02 -0700 (PDT) Received: from localhost (host-82-56-173-172.retail.telecomitalia.it. [82.56.173.172]) by smtp.gmail.com with ESMTPSA id t5-20020a170906064500b00a45ff821e09sm4778473ejb.150.2024.03.13.07.09.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 07:09:02 -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 11/15] dmaengine: bcm2835: pass dma_chan to generic functions Date: Wed, 13 Mar 2024 15:08:36 +0100 Message-ID: <2dedf0428cbc5229ea563a571d297a64c8e09c03.1710226514.git.andrea.porta@suse.com> 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_140903_831016_9A01A097 X-CRM114-Status: GOOD ( 16.54 ) 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 In preparation to support more platforms pass the dma_chan to the generic functions. This provides access to the DMA device and possible platform specific data. Signed-off-by: Stefan Wahren Signed-off-by: Andrea della Porta --- drivers/dma/bcm2835-dma.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index 03d97312a3f8..88ae5d05402e 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -308,13 +308,14 @@ static void bcm2835_dma_desc_free(struct virt_dma_desc *vd) bcm2835_dma_free_cb_chain(container_of(vd, struct bcm2835_desc, vd)); } -static bool bcm2835_dma_create_cb_set_length(struct bcm2835_chan *chan, +static bool bcm2835_dma_create_cb_set_length(struct dma_chan *chan, struct bcm2835_dma_cb *control_block, size_t len, size_t period_len, size_t *total_len) { - size_t max_len = bcm2835_dma_max_frame_length(chan); + struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); + size_t max_len = bcm2835_dma_max_frame_length(c); /* set the length taking lite-channel limitations into account */ control_block->length = min_t(u32, len, max_len); @@ -441,7 +442,7 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( if (buf_len) { /* calculate length honoring period_length */ if (bcm2835_dma_create_cb_set_length( - c, control_block, + chan, control_block, len, period_len, &total_len)) { /* add extrainfo bits in info */ control_block->info |= extrainfo; @@ -508,8 +509,9 @@ static void bcm2835_dma_fill_cb_chain_with_sg( } } -static void bcm2835_dma_abort(struct bcm2835_chan *c) +static void bcm2835_dma_abort(struct dma_chan *chan) { + struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); void __iomem *chan_base = c->chan_base; long timeout = 100; @@ -550,8 +552,9 @@ static void bcm2835_dma_abort(struct bcm2835_chan *c) writel(BCM2835_DMA_RESET, chan_base + BCM2835_DMA_CS); } -static void bcm2835_dma_start_desc(struct bcm2835_chan *c) +static void bcm2835_dma_start_desc(struct dma_chan *chan) { + struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct virt_dma_desc *vd = vchan_next_desc(&c->vc); if (!vd) { @@ -570,7 +573,8 @@ static void bcm2835_dma_start_desc(struct bcm2835_chan *c) static irqreturn_t bcm2835_dma_callback(int irq, void *data) { - struct bcm2835_chan *c = data; + struct dma_chan *chan = data; + struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; unsigned long flags; @@ -604,7 +608,7 @@ static irqreturn_t bcm2835_dma_callback(int irq, void *data) vchan_cyclic_callback(&d->vd); } else if (!readl(c->chan_base + BCM2835_DMA_ADDR)) { vchan_cookie_complete(&c->desc->vd); - bcm2835_dma_start_desc(c); + bcm2835_dma_start_desc(chan); } } @@ -632,7 +636,7 @@ static int bcm2835_dma_alloc_chan_resources(struct dma_chan *chan) } return request_irq(c->irq_number, bcm2835_dma_callback, - c->irq_flags, "DMA IRQ", c); + c->irq_flags, "DMA IRQ", chan); } static void bcm2835_dma_free_chan_resources(struct dma_chan *chan) @@ -721,7 +725,7 @@ static void bcm2835_dma_issue_pending(struct dma_chan *chan) spin_lock_irqsave(&c->vc.lock, flags); if (vchan_issue_pending(&c->vc) && !c->desc) - bcm2835_dma_start_desc(c); + bcm2835_dma_start_desc(chan); spin_unlock_irqrestore(&c->vc.lock, flags); } @@ -885,7 +889,7 @@ static int bcm2835_dma_terminate_all(struct dma_chan *chan) if (c->desc) { vchan_terminate_vdesc(&c->desc->vd); c->desc = NULL; - bcm2835_dma_abort(c); + bcm2835_dma_abort(chan); } vchan_get_all_descriptors(&c->vc, &head); From patchwork Wed Mar 13 14:08:37 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: 13591461 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 65687C54E58 for ; Wed, 13 Mar 2024 14:11:04 +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=Th2k/THjSdEWjAdJlOM4pE+VygVPzWbfiE4xU+MVRio=; b=2pzRS1Hn8RcBk6 ci0Nv7r+534+iZRXmEYM2Lm7wqNe1lL6IyIw44f7SiyXxc2OQQ+muyh5gifCsbcj4cQdtRHYWomRW +YtbVCuO1r/YJcOcL8PVpJDUSGVTzKY9fJMOKjY19eVTmtMYa8Hqmm3IK6IGYft/E+JDnPWOwpe4q JmTD0X22smXJow05xra6x177c/P7mTCk4+RnNxJpDwHbVx8rBqPCxF7+uWMb21RsHwizxlxt5wt50 A6qZJ/nVDNa7YOlDonPs+aYvegNkWa/3ugHbUruXyE4BdR0nYWodRtZeCsqYQlDqcW3i5wgHtzgkg 5nBYnMvZp9kWr7WbnaJA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPJc-0000000ANJt-1Vy0; Wed, 13 Mar 2024 14:10:44 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPI5-0000000AMKz-3ik1 for linux-arm-kernel@bombadil.infradead.org; Wed, 13 Mar 2024 14:09:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=mCm/hrhQ6mByy3ZheArz8BA+9C2P6vrL3jyQtBljgzk=; b=WWsvAxPYv15cJZshhT1lhbCphW vzjk+08ueHdg9aNmbenDmeERzwsfyTDDqNKg+vXwi4zoY8PZZ0Q9JanT8ubP1EWeBts77zWBRHN5M KuQ9djteMYU+kv/4WpqqucBTTBgTNLnZr9CWdVMhDFCYL6UlfPxU1XEZ4jnjJoTy+H9XN6R2ojPBk TVsM4I1VVJd8/DTIVHBqiaN2RJQQ3MenY+GpedKTcqs0LGDzfikkjiWbQI/oV9kdInMbbfs9KhJTV rZ0rs+4wPOZk05k8MqtNz1FKMlt41d34uY+NCZQOA5H4CelacAIvUluWntOVN85OBDkSmCb64v02D 06WjH5Jw==; Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPI2-0000000A3Cr-2ZK9 for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2024 14:09:08 +0000 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-565c6cf4819so1619943a12.1 for ; Wed, 13 Mar 2024 07:09:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1710338943; x=1710943743; 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=mCm/hrhQ6mByy3ZheArz8BA+9C2P6vrL3jyQtBljgzk=; b=X7m4FSyG3GcF6qXef+4G7JV4od18N21To6zUixgv7AdP7JZxf6K3WMsMnTCo4oEFJH y59Qd4cJPDsf052kF8F3cEN6yxbBNwYN3X0WQ3vJhLWkDNklt/CFG2C3FtGsF7NAqvIX 8KYHBEXXcMjwCqXOcFV5DOMioM4Y4KRmJrDtyCk90I4kLGjSqDX8rh7/c6eQjXJoP/p6 lbHdc955MEHtJXgkL/kyNhKXMghWnWUj+O7iQNCjiorjkYOtnn9jLtdp3ueOUxuhmDUN dWR62xAYpInY0Vp9NYXJYF+XRhSyasG+L5oTn89OJkMnceEcafO2mOCoa4c14WR4Pn0s /b6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710338943; x=1710943743; 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=mCm/hrhQ6mByy3ZheArz8BA+9C2P6vrL3jyQtBljgzk=; b=LauQ9X0TCqS12LxIHcbOFb+ttDd5Q1a98T+qRKR6NnebABivyH+8L1Q9cHh7mznjfJ y+vzdXg0ofRbkv4bqlhO6BeDMBavEFccV/zIMvi9cMij7f0Th6Vrqaaa7Z8uu7HPfNZP H834Fv44On6VNF5zUl2SGb3Gf1TBNAMcGgdozMZaTX2t3t19uqvsrcU/amacc3P/Vgf9 G/1hqsCVuarI6jOh0ta2RhQV4u0cgXiGtcbki2UTPRznKYMpCHwQV75MS/WPmk2JrQMq /328lRAOIxn5c60r7vZjQrb3pyz2+leW8hG+h2cBsyiOzIYzkzi9AVbRT8PY6G0fU/ve GarQ== X-Forwarded-Encrypted: i=1; AJvYcCXLj/GDAH+7GUjVUqP97SXQFwfRX43/67UP4dQsUbjrt4mVbFz798B4VL1JLyM1LjgoPrHxN5HEPLKCsIxjlv+gu4ICLfy5Z3LiOq+jqoWTRsdtXPs= X-Gm-Message-State: AOJu0YzTsxNGcJDRiO6B/eDZBd322K9eWJwYy74IpHcoSYUc9R5jgZPX 75S4J8V5U0/gDxaUVHiTYrgqJUCzTocRX/4QzWsPmtGU+Ff4m8NfLsONeqde2sA= X-Google-Smtp-Source: AGHT+IHySWWWSB+Vk+u+Z/lfcofhEFncK/Fb/h9io/fpqSb/D9VRgNiFm/EFELA+fDnMdkYiPJmEWQ== X-Received: by 2002:a50:bb47:0:b0:566:abbd:c390 with SMTP id y65-20020a50bb47000000b00566abbdc390mr2643130ede.6.1710338943679; Wed, 13 Mar 2024 07:09:03 -0700 (PDT) Received: from localhost (host-82-56-173-172.retail.telecomitalia.it. [82.56.173.172]) by smtp.gmail.com with ESMTPSA id da17-20020a056402177100b005684fc23524sm3890492edb.49.2024.03.13.07.09.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 07:09:03 -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 12/15] dmaengine: bcm2835: introduce multi platform support Date: Wed, 13 Mar 2024 15:08:37 +0100 Message-ID: <5826eba6ab78b9cdba21c12853a85d5f9a6aab76.1710226514.git.andrea.porta@suse.com> 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_140906_887871_538BE253 X-CRM114-Status: GOOD ( 26.48 ) 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 This finally moves all platform specific stuff into a separate structure, which is initialized on the OF compatible during probing. Since the DMA control block is different on the BCM2711 platform, we introduce a common control block to reserve the necessary space and adequate methods for access. Signed-off-by: Stefan Wahren Signed-off-by: Andrea della Porta --- drivers/dma/bcm2835-dma.c | 336 +++++++++++++++++++++++++++++--------- 1 file changed, 260 insertions(+), 76 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index 88ae5d05402e..b015eae29b08 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -48,6 +48,11 @@ struct bcm2835_dmadev { struct dma_device ddev; void __iomem *base; dma_addr_t zero_page; + const struct bcm2835_dma_cfg *cfg; +}; + +struct bcm_dma_cb { + uint32_t rsvd[8]; }; struct bcm2835_dma_cb { @@ -61,7 +66,7 @@ struct bcm2835_dma_cb { }; struct bcm2835_cb_entry { - struct bcm2835_dma_cb *cb; + struct bcm_dma_cb *cb; dma_addr_t paddr; }; @@ -82,6 +87,44 @@ struct bcm2835_chan { bool is_lite_channel; }; +struct bcm2835_dma_cfg { + dma_addr_t addr_offset; + u32 cs_reg; + u32 cb_reg; + u32 next_reg; + u32 ti_reg; + + u32 wait_mask; + u32 reset_mask; + u32 int_mask; + u32 active_mask; + u32 abort_mask; + u32 s_dreq_mask; + u32 d_dreq_mask; + + u32 (*cb_get_length)(void *data); + dma_addr_t (*cb_get_addr)(void *data, enum dma_transfer_direction); + + void (*cb_init)(void *data, struct bcm2835_chan *c, + enum dma_transfer_direction, u32 src, u32 dst, + bool zero_page); + void (*cb_set_src)(void *data, enum dma_transfer_direction, u32 src); + void (*cb_set_dst)(void *data, enum dma_transfer_direction, u32 dst); + void (*cb_set_next)(void *data, u32 next); + void (*cb_set_length)(void *data, u32 length); + void (*cb_append_extra)(void *data, + struct bcm2835_chan *c, + enum dma_transfer_direction direction, + bool cyclic, bool final, unsigned long flags); + + dma_addr_t (*to_cb_addr)(dma_addr_t addr); + + void (*chan_plat_init)(struct bcm2835_chan *c); + dma_addr_t (*read_addr)(struct bcm2835_chan *c, + enum dma_transfer_direction); + u32 (*cs_flags)(struct bcm2835_chan *c); +}; + struct bcm2835_desc { struct bcm2835_chan *c; struct virt_dma_desc vd; @@ -215,6 +258,13 @@ static inline struct bcm2835_dmadev *to_bcm2835_dma_dev(struct dma_device *d) return container_of(d, struct bcm2835_dmadev, ddev); } +static inline const struct bcm2835_dma_cfg *to_bcm2835_cfg(struct dma_device *d) +{ + struct bcm2835_dmadev *od = container_of(d, struct bcm2835_dmadev, ddev); + + return od->cfg; +} + static inline struct bcm2835_chan *to_bcm2835_dma_chan(struct dma_chan *c) { return container_of(c, struct bcm2835_chan, vc.chan); @@ -292,6 +342,109 @@ static inline bool need_dst_incr(enum dma_transfer_direction direction) return false; } +static inline u32 bcm2835_dma_cb_get_length(void *data) +{ + struct bcm2835_dma_cb *cb = data; + + return cb->length; +} + +static inline dma_addr_t +bcm2835_dma_cb_get_addr(void *data, enum dma_transfer_direction direction) +{ + struct bcm2835_dma_cb *cb = data; + + if (direction == DMA_DEV_TO_MEM) + return cb->dst; + + return cb->src; +} + +static inline void +bcm2835_dma_cb_init(void *data, struct bcm2835_chan *c, + enum dma_transfer_direction direction, u32 src, u32 dst, + bool zero_page) +{ + struct bcm2835_dma_cb *cb = data; + + cb->info = bcm2835_dma_prepare_cb_info(c, direction, zero_page); + cb->src = src; + cb->dst = dst; + cb->stride = 0; + cb->next = 0; +} + +static inline void +bcm2835_dma_cb_set_src(void *data, enum dma_transfer_direction direction, + u32 src) +{ + struct bcm2835_dma_cb *cb = data; + + cb->src = src; +} + +static inline void +bcm2835_dma_cb_set_dst(void *data, enum dma_transfer_direction direction, + u32 dst) +{ + struct bcm2835_dma_cb *cb = data; + + cb->dst = dst; +} + +static inline void bcm2835_dma_cb_set_next(void *data, u32 next) +{ + struct bcm2835_dma_cb *cb = data; + + cb->next = next; +} + +static inline void bcm2835_dma_cb_set_length(void *data, u32 length) +{ + struct bcm2835_dma_cb *cb = data; + + cb->length = length; +} + +static inline void +bcm2835_dma_cb_append_extra(void *data, struct bcm2835_chan *c, + enum dma_transfer_direction direction, + bool cyclic, bool final, unsigned long flags) +{ + struct bcm2835_dma_cb *cb = data; + + cb->info |= bcm2835_dma_prepare_cb_extra(c, direction, cyclic, final, + flags); +} + +static inline dma_addr_t bcm2835_dma_to_cb_addr(dma_addr_t addr) +{ + return addr; +} + +static void bcm2835_dma_chan_plat_init(struct bcm2835_chan *c) +{ + /* check in DEBUG register if this is a LITE channel */ + if (readl(c->chan_base + BCM2835_DMA_DEBUG) & BCM2835_DMA_DEBUG_LITE) + c->is_lite_channel = true; +} + +static dma_addr_t bcm2835_dma_read_addr(struct bcm2835_chan *c, + enum dma_transfer_direction direction) +{ + if (direction == DMA_MEM_TO_DEV) + return readl(c->chan_base + BCM2835_DMA_SOURCE_AD); + else if (direction == DMA_DEV_TO_MEM) + return readl(c->chan_base + BCM2835_DMA_DEST_AD); + + return 0; +} + +static u32 bcm2835_dma_cs_flags(struct bcm2835_chan *c) +{ + return BCM2835_DMA_CS_FLAGS(c->dreq); +} + static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc) { size_t i; @@ -309,16 +462,19 @@ static void bcm2835_dma_desc_free(struct virt_dma_desc *vd) } static bool bcm2835_dma_create_cb_set_length(struct dma_chan *chan, - struct bcm2835_dma_cb *control_block, + void *data, size_t len, size_t period_len, size_t *total_len) { + const struct bcm2835_dma_cfg *cfg = to_bcm2835_cfg(chan->device); struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); size_t max_len = bcm2835_dma_max_frame_length(c); /* set the length taking lite-channel limitations into account */ - control_block->length = min_t(u32, len, max_len); + u32 length = min_t(u32, len, max_len); + + cfg->cb_set_length(data, length); /* finished if we have no period_length */ if (!period_len) @@ -333,14 +489,14 @@ static bool bcm2835_dma_create_cb_set_length(struct dma_chan *chan, */ /* have we filled in period_length yet? */ - if (*total_len + control_block->length < period_len) { + if (*total_len + length < period_len) { /* update number of bytes in this period so far */ - *total_len += control_block->length; + *total_len += length; return false; } /* calculate the length that remains to reach period_length */ - control_block->length = period_len - *total_len; + cfg->cb_set_length(data, period_len - *total_len); /* reset total_length for next period */ *total_len = 0; @@ -388,15 +544,14 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( size_t buf_len, size_t period_len, gfp_t gfp, unsigned long flags) { + const struct bcm2835_dma_cfg *cfg = to_bcm2835_cfg(chan->device); struct bcm2835_dmadev *od = to_bcm2835_dma_dev(chan->device); struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); size_t len = buf_len, total_len; size_t frame; struct bcm2835_desc *d; struct bcm2835_cb_entry *cb_entry; - struct bcm2835_dma_cb *control_block; - u32 extrainfo = bcm2835_dma_prepare_cb_extra(c, direction, cyclic, - false, flags); + struct bcm_dma_cb *control_block; bool zero_page = false; if (!frames) @@ -432,12 +587,7 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( /* fill in the control block */ control_block = cb_entry->cb; - control_block->info = bcm2835_dma_prepare_cb_info(c, direction, - zero_page); - control_block->src = src; - control_block->dst = dst; - control_block->stride = 0; - control_block->next = 0; + cfg->cb_init(control_block, c, src, dst, direction, zero_page); /* set up length in control_block if requested */ if (buf_len) { /* calculate length honoring period_length */ @@ -445,31 +595,33 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( chan, control_block, len, period_len, &total_len)) { /* add extrainfo bits in info */ - control_block->info |= extrainfo; + bcm2835_dma_cb_append_extra(control_block, c, + direction, cyclic, + false, flags); } /* calculate new remaining length */ - len -= control_block->length; + len -= cfg->cb_get_length(control_block); } /* link this the last controlblock */ if (frame) - d->cb_list[frame - 1].cb->next = cb_entry->paddr; + cfg->cb_set_next(d->cb_list[frame - 1].cb, + cb_entry->paddr); /* update src and dst and length */ if (src && need_src_incr(direction)) - src += control_block->length; + src += cfg->cb_get_length(control_block); if (dst && need_dst_incr(direction)) - dst += control_block->length; + dst += cfg->cb_get_length(control_block); /* Length of total transfer */ - d->size += control_block->length; + d->size += cfg->cb_get_length(control_block); } /* the last frame requires extra flags */ - extrainfo = bcm2835_dma_prepare_cb_extra(c, direction, cyclic, true, - flags); - d->cb_list[d->frames - 1].cb->info |= extrainfo; + cfg->cb_append_extra(d->cb_list[d->frames - 1].cb, c, direction, cyclic, + true, flags); /* detect a size mismatch */ if (buf_len && d->size != buf_len) @@ -489,6 +641,7 @@ static void bcm2835_dma_fill_cb_chain_with_sg( struct scatterlist *sgl, unsigned int sg_len) { + const struct bcm2835_dma_cfg *cfg = to_bcm2835_cfg(chan->device); struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); size_t len, max_len; unsigned int i; @@ -499,18 +652,19 @@ static void bcm2835_dma_fill_cb_chain_with_sg( for_each_sg(sgl, sgent, sg_len, i) { for (addr = sg_dma_address(sgent), len = sg_dma_len(sgent); len > 0; - addr += cb->cb->length, len -= cb->cb->length, cb++) { + addr += cfg->cb_get_length(cb->cb), len -= cfg->cb_get_length(cb->cb), cb++) { if (direction == DMA_DEV_TO_MEM) - cb->cb->dst = addr; + cfg->cb_set_dst(cb->cb, direction, addr); else - cb->cb->src = addr; - cb->cb->length = min(len, max_len); + cfg->cb_set_src(cb->cb, direction, addr); + cfg->cb_set_length(cb->cb, min(len, max_len)); } } } static void bcm2835_dma_abort(struct dma_chan *chan) { + const struct bcm2835_dma_cfg *cfg = to_bcm2835_cfg(chan->device); struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); void __iomem *chan_base = c->chan_base; long timeout = 100; @@ -519,41 +673,42 @@ static void bcm2835_dma_abort(struct dma_chan *chan) * A zero control block address means the channel is idle. * (The ACTIVE flag in the CS register is not a reliable indicator.) */ - if (!readl(chan_base + BCM2835_DMA_ADDR)) + if (!readl(chan_base + cfg->cb_reg)) return; /* We need to clear the next DMA block pending */ - writel(0, chan_base + BCM2835_DMA_NEXTCB); + writel(0, chan_base + cfg->next_reg); /* 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); + writel(readl(chan_base + cfg->cs_reg) | cfg->abort_mask | cfg->active_mask, + chan_base + cfg->cs_reg); /* wait for DMA to be aborted */ - while ((readl(chan_base + BCM2835_DMA_CS) & BCM2835_DMA_ABORT) && --timeout) + while ((readl(chan_base + cfg->cs_reg) & cfg->abort_mask) && --timeout) cpu_relax(); /* Write 0 to the active bit - Pause the DMA */ - writel(readl(chan_base + BCM2835_DMA_CS) & ~BCM2835_DMA_ACTIVE, - chan_base + BCM2835_DMA_CS); + writel(readl(chan_base + cfg->cs_reg) & ~cfg->active_mask, + chan_base + cfg->cs_reg); /* * 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))) + if (!timeout && !(readl(chan_base + cfg->ti_reg) & + (cfg->s_dreq_mask | cfg->d_dreq_mask))) dev_err(c->vc.chan.device->dev, "failed to complete pause on dma %d (CS:%08x)\n", c->ch, - readl(chan_base + BCM2835_DMA_CS)); + readl(chan_base + cfg->cs_reg)); /* Set CS back to default state and reset the DMA */ - writel(BCM2835_DMA_RESET, chan_base + BCM2835_DMA_CS); + writel(cfg->reset_mask, chan_base + cfg->cs_reg); } static void bcm2835_dma_start_desc(struct dma_chan *chan) { + const struct bcm2835_dma_cfg *cfg = to_bcm2835_cfg(chan->device); struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct virt_dma_desc *vd = vchan_next_desc(&c->vc); @@ -566,14 +721,15 @@ static void bcm2835_dma_start_desc(struct dma_chan *chan) c->desc = to_bcm2835_dma_desc(&vd->tx); - writel(c->desc->cb_list[0].paddr, c->chan_base + BCM2835_DMA_ADDR); - writel(BCM2835_DMA_ACTIVE | BCM2835_DMA_CS_FLAGS(c->dreq), - c->chan_base + BCM2835_DMA_CS); + writel(cfg->to_cb_addr(c->desc->cb_list[0].paddr), c->chan_base + cfg->cb_reg); + writel(cfg->active_mask | cfg->cs_flags(c), + c->chan_base + cfg->cs_reg); } static irqreturn_t bcm2835_dma_callback(int irq, void *data) { struct dma_chan *chan = data; + const struct bcm2835_dma_cfg *cfg = to_bcm2835_cfg(chan->device); struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; unsigned long flags; @@ -581,9 +737,9 @@ static irqreturn_t bcm2835_dma_callback(int irq, void *data) /* check the shared interrupt */ if (c->irq_flags & IRQF_SHARED) { /* check if the interrupt is enabled */ - flags = readl(c->chan_base + BCM2835_DMA_CS); + flags = readl(c->chan_base + cfg->cs_reg); /* if not set then we are not the reason for the irq */ - if (!(flags & BCM2835_DMA_INT)) + if (!(flags & cfg->int_mask)) return IRQ_NONE; } @@ -596,9 +752,7 @@ static irqreturn_t bcm2835_dma_callback(int irq, void *data) * if this IRQ handler is threaded.) If the channel is finished, it * will remain idle despite the ACTIVE flag being set. */ - writel(BCM2835_DMA_INT | BCM2835_DMA_ACTIVE | - BCM2835_DMA_CS_FLAGS(c->dreq), - c->chan_base + BCM2835_DMA_CS); + writel(cfg->int_mask | cfg->active_mask | cfg->cs_flags(c), c->chan_base + cfg->cs_reg); d = c->desc; @@ -606,7 +760,7 @@ static irqreturn_t bcm2835_dma_callback(int irq, void *data) if (d->cyclic) { /* call the cyclic callback */ vchan_cyclic_callback(&d->vd); - } else if (!readl(c->chan_base + BCM2835_DMA_ADDR)) { + } else if (!readl(c->chan_base + cfg->cb_reg)) { vchan_cookie_complete(&c->desc->vd); bcm2835_dma_start_desc(chan); } @@ -629,7 +783,7 @@ static int bcm2835_dma_alloc_chan_resources(struct dma_chan *chan) * (32 byte) aligned address (BCM2835 ARM Peripherals, sec. 4.2.1.1). */ c->cb_pool = dma_pool_create(dev_name(dev), dev, - sizeof(struct bcm2835_dma_cb), 32, 0); + sizeof(struct bcm_dma_cb), 32, 0); if (!c->cb_pool) { dev_err(dev, "unable to allocate descriptor pool\n"); return -ENOMEM; @@ -655,20 +809,16 @@ static size_t bcm2835_dma_desc_size(struct bcm2835_desc *d) return d->size; } -static size_t bcm2835_dma_desc_size_pos(struct bcm2835_desc *d, dma_addr_t addr) +static size_t bcm2835_dma_desc_size_pos(const struct bcm2835_dma_cfg *cfg, + struct bcm2835_desc *d, dma_addr_t addr) { unsigned int i; size_t size; for (size = i = 0; i < d->frames; i++) { - struct bcm2835_dma_cb *control_block = d->cb_list[i].cb; - size_t this_size = control_block->length; - dma_addr_t dma; - - if (d->dir == DMA_DEV_TO_MEM) - dma = control_block->dst; - else - dma = control_block->src; + struct bcm_dma_cb *control_block = d->cb_list[i].cb; + size_t this_size = cfg->cb_get_length(control_block); + dma_addr_t dma = cfg->cb_get_addr(control_block, d->dir); if (size) size += this_size; @@ -683,6 +833,7 @@ static enum dma_status bcm2835_dma_tx_status(struct dma_chan *chan, dma_cookie_t cookie, struct dma_tx_state *txstate) { + const struct bcm2835_dma_cfg *cfg = to_bcm2835_cfg(chan->device); struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct virt_dma_desc *vd; enum dma_status ret; @@ -701,14 +852,8 @@ static enum dma_status bcm2835_dma_tx_status(struct dma_chan *chan, struct bcm2835_desc *d = c->desc; dma_addr_t pos; - if (d->dir == DMA_MEM_TO_DEV) - pos = readl(c->chan_base + BCM2835_DMA_SOURCE_AD); - else if (d->dir == DMA_DEV_TO_MEM) - pos = readl(c->chan_base + BCM2835_DMA_DEST_AD); - else - pos = 0; - - txstate->residue = bcm2835_dma_desc_size_pos(d, pos); + pos = cfg->read_addr(c, d->dir); + txstate->residue = bcm2835_dma_desc_size_pos(cfg, d, pos); } else { txstate->residue = 0; } @@ -761,6 +906,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg( enum dma_transfer_direction direction, unsigned long flags, void *context) { + const struct bcm2835_dma_cfg *cfg = to_bcm2835_cfg(chan->device); struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; dma_addr_t src = 0, dst = 0; @@ -775,11 +921,11 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg( if (direction == DMA_DEV_TO_MEM) { if (c->cfg.src_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES) return NULL; - src = c->cfg.src_addr; + src = cfg->addr_offset + c->cfg.src_addr; } else { if (c->cfg.dst_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES) return NULL; - dst = c->cfg.dst_addr; + dst = cfg->addr_offset + c->cfg.dst_addr; } /* count frames in sg list */ @@ -803,6 +949,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( size_t period_len, enum dma_transfer_direction direction, unsigned long flags) { + const struct bcm2835_dma_cfg *cfg = to_bcm2835_cfg(chan->device); struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; dma_addr_t src, dst; @@ -836,12 +983,12 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( if (direction == DMA_DEV_TO_MEM) { if (c->cfg.src_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES) return NULL; - src = c->cfg.src_addr; + src = cfg->addr_offset + c->cfg.src_addr; dst = buf_addr; } else { if (c->cfg.dst_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES) return NULL; - dst = c->cfg.dst_addr; + dst = cfg->addr_offset + c->cfg.dst_addr; src = buf_addr; } @@ -862,7 +1009,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( return NULL; /* wrap around into a loop */ - d->cb_list[d->frames - 1].cb->next = d->cb_list[0].paddr; + cfg->cb_set_next(d->cb_list[d->frames - 1].cb, + cfg->to_cb_addr(d->cb_list[0].paddr)); return vchan_tx_prep(&c->vc, &d->vd, flags); } @@ -923,10 +1071,7 @@ static int bcm2835_dma_chan_init(struct bcm2835_dmadev *d, int chan_id, c->irq_number = irq; c->irq_flags = irq_flags; - /* check in DEBUG register if this is a LITE channel */ - if (readl(c->chan_base + BCM2835_DMA_DEBUG) & - BCM2835_DMA_DEBUG_LITE) - c->is_lite_channel = true; + d->cfg->chan_plat_init(c); return 0; } @@ -945,8 +1090,40 @@ static void bcm2835_dma_free(struct bcm2835_dmadev *od) DMA_TO_DEVICE, DMA_ATTR_SKIP_CPU_SYNC); } +static const struct bcm2835_dma_cfg bcm2835_data = { + .addr_offset = 0, + + .cs_reg = BCM2835_DMA_CS, + .cb_reg = BCM2835_DMA_ADDR, + .next_reg = BCM2835_DMA_NEXTCB, + .ti_reg = BCM2835_DMA_TI, + + .wait_mask = BCM2835_DMA_WAITING_FOR_WRITES, + .reset_mask = BCM2835_DMA_RESET, + .int_mask = BCM2835_DMA_INT, + .active_mask = BCM2835_DMA_ACTIVE, + .abort_mask = BCM2835_DMA_ABORT, + .s_dreq_mask = BCM2835_DMA_S_DREQ, + .d_dreq_mask = BCM2835_DMA_D_DREQ, + + .cb_get_length = bcm2835_dma_cb_get_length, + .cb_get_addr = bcm2835_dma_cb_get_addr, + .cb_init = bcm2835_dma_cb_init, + .cb_set_src = bcm2835_dma_cb_set_src, + .cb_set_dst = bcm2835_dma_cb_set_dst, + .cb_set_next = bcm2835_dma_cb_set_next, + .cb_set_length = bcm2835_dma_cb_set_length, + .cb_append_extra = bcm2835_dma_cb_append_extra, + + .to_cb_addr = bcm2835_dma_to_cb_addr, + + .chan_plat_init = bcm2835_dma_chan_plat_init, + .read_addr = bcm2835_dma_read_addr, + .cs_flags = bcm2835_dma_cs_flags, +}; + static const struct of_device_id bcm2835_dma_of_match[] = { - { .compatible = "brcm,bcm2835-dma", }, + { .compatible = "brcm,bcm2835-dma", .data = &bcm2835_data }, {}, }; MODULE_DEVICE_TABLE(of, bcm2835_dma_of_match); @@ -978,6 +1155,12 @@ static int bcm2835_dma_probe(struct platform_device *pdev) u32 chans_available; char chan_name[BCM2835_DMA_CHAN_NAME_SIZE]; + const void *cfg_data = device_get_match_data(&pdev->dev); + if (!cfg_data) { + dev_err(&pdev->dev, "Failed to match compatible string\n"); + return -EINVAL; + } + if (!pdev->dev.dma_mask) pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; @@ -998,6 +1181,7 @@ static int bcm2835_dma_probe(struct platform_device *pdev) return PTR_ERR(base); od->base = base; + od->cfg = cfg_data; dma_cap_set(DMA_SLAVE, od->ddev.cap_mask); dma_cap_set(DMA_PRIVATE, od->ddev.cap_mask); From patchwork Wed Mar 13 14:08:38 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: 13591460 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 A14E8C54E67 for ; Wed, 13 Mar 2024 14:11:04 +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=Ped+3vGv+AFhioCH6XO7v8oYgSSzAzbgdNPzn7p6jlo=; b=IVaOoojr5f87E3 DX8m4LXhp0N8LhrBlgOl6/Ma+SS5uPnDJzl/jnBGnnWoEiUBNTPg1Ql5oGG7RPg/OMWqx75Z/Kt4q 5Yd69i7KITnMaAp1mTOzq1xMvicqiopxxIaUibT4WSdk8hKy8wXRF5HWlzICcMJXIUnn2mG52ERTw P6+nvmSwphPi19yRndXOSaibdnb9ydsN2UsDgk8i+A5M3oWjBIorq24sOK8XX/YYdPeyuJtTLg1/7 1TAaDu7DhTYTy235U+jvTXssU5LGOwKPgadUwOd20X00ULsbrMwLZTD9lANeoclbWvsCzzm+25eaY UTjDyfcNlCjdC8A8pazA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPJf-0000000ANMG-19zo; Wed, 13 Mar 2024 14:10:47 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPI7-0000000AMMG-2Omr for linux-arm-kernel@bombadil.infradead.org; Wed, 13 Mar 2024 14:09:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=iC5hRkZE8XydpjuCjvZ54lBNe2FsAX8ONZyCD9caIGw=; b=fd4MuW4FbNnjB2XpDYeCHE0NkB FR0jDLKpJmiJAWO+y9pNRrf+lh36ZVdmu/xwC1UScWLx5Vj8my3soULeDUwv5YXu8uNVTz3GLiumZ gFBiL4SDd/h1I9SPNW5F6xSL/Lv/Y2i5FBA+UXBpc/uFbZ8Uwm5V3Z8OGEb30lC4tOsQJbrO8zZR3 jaNvEUlinV3l/EyBHwJbDcQMJLNwQFol9PeIdV4851srAVBndveRH+OqwZCwhfdXHvHBnml6LdPBE 0HNQJEOlfXHi5wTcJKPmrUqmcRSq90om+qoh9LTZzOueu1ItzEhatH0TH/qWwND6V2z9yt0VD1ItS O0Ro/jYA==; Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPI2-0000000A3Cz-3bQa for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2024 14:09:10 +0000 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a3fb8b0b7acso626146566b.2 for ; Wed, 13 Mar 2024 07:09:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1710338945; x=1710943745; 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=iC5hRkZE8XydpjuCjvZ54lBNe2FsAX8ONZyCD9caIGw=; b=TuFm8dudoQmS4xpJQYjlvIWA9QEv0xyTgjppFnilD1CyfHnNvWsRNks82TQZofV/g8 xE40x34l6Tu+oNoSJ9i0YdfTSPzNDo0HmvPq/EWBJhEre0Z3YmuLT6RRbt6GpTmHFj2P kgDk/NYzVM3f6XoXYwXJH0+Oq0gOxMJ7++F+Lw6fcgGAUmHJ3YZj6WcJPXn+5Mp0d/3J rtAd8/RK9rYt4O6VGt7YfymVFoJ5h0AzMSmcG63XQayd2CVkqSaHdDXDanEgr1rhP9FP 5stMoaa4ZOE1hWmikNnQ894/1x36ObXP+rKFdpnezZLoE16UAQSzm+CiWS7FuRZjFYBX tQdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710338945; x=1710943745; 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=iC5hRkZE8XydpjuCjvZ54lBNe2FsAX8ONZyCD9caIGw=; b=otlm9MNacHDRDy1nUsbBiyeuz496lN3oK+F6FVQzhpQMVGP/aC0m+NpJ+bPoV3QDHW PAo0Na0NEkcT8oO85mrE9OJv23CPh3TpHdZx1sIKR5x6AQ3O8DLiHdb1U61Z0NJGfqh8 1Ic78hU1OPf3984bMAunjzBwEcsL5PTC2y947ea/3FeTiBhgD9HZi1Yg1gGMZC0FARO4 dCMDRBzgVx8YhmtMhu+wfjFhUQkMIUYFlRYIDB6uif+jKNpbmtAH0sUR/GDJ+s3pejtN ZdHKroCzxNtvkKZfcnxmhMyO1hvGHNab6FyXaYKU9pdWAPaXwpwJj1FviD75TOwLE8b3 mYUA== X-Forwarded-Encrypted: i=1; AJvYcCX3/h06DzYzV519rDl3/i5VoEfjvV4OcOIeuozomOzxtsoKRIystGZ8VNBbGsEBTSphHpUaqe+qUp4mUcXeaLT8g9e0u/oG4n20lzzU71dVcbYx/VY= X-Gm-Message-State: AOJu0YyUBHtxgpV3dg19+nOy1/LiAlJetBVPw/qapBdBLD0Sp9FpKZ0c 3aA6WM8Dc4IlXNUiaUMrD2zmaHmC2hjblgeeIEc+fSrlZlciq1h1PpgHUWxDleA= X-Google-Smtp-Source: AGHT+IFyuIjwtvgpdhhj/173HsZkPpiyLzXxHYape6PR7U0HW2/2V4AAAxMeCUd7QbQujytsrNhvVg== X-Received: by 2002:a17:907:7e83:b0:a3e:792f:3955 with SMTP id qb3-20020a1709077e8300b00a3e792f3955mr3050129ejc.62.1710338945176; Wed, 13 Mar 2024 07:09:05 -0700 (PDT) Received: from localhost (host-82-56-173-172.retail.telecomitalia.it. [82.56.173.172]) by smtp.gmail.com with ESMTPSA id lg12-20020a170906f88c00b00a4432543b21sm4858324ejb.198.2024.03.13.07.09.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 07:09:04 -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 13/15] dt-bindings: dma: Added bcm2711-dma Date: Wed, 13 Mar 2024 15:08:38 +0100 Message-ID: <346611b3ec6f47cb10e538d6cbe52056f535f965.1710226514.git.andrea.porta@suse.com> 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_140907_046143_D2C03AF7 X-CRM114-Status: GOOD ( 10.12 ) 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 Add BCM2711 dma engine compatible. Signed-off-by: Andrea della Porta --- Documentation/devicetree/bindings/dma/brcm,bcm2835-dma.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/dma/brcm,bcm2835-dma.yaml b/Documentation/devicetree/bindings/dma/brcm,bcm2835-dma.yaml index c9b9a5490826..4271a6fedf54 100644 --- a/Documentation/devicetree/bindings/dma/brcm,bcm2835-dma.yaml +++ b/Documentation/devicetree/bindings/dma/brcm,bcm2835-dma.yaml @@ -20,7 +20,9 @@ allOf: properties: compatible: - const: brcm,bcm2835-dma + enum: + - brcm,bcm2835-dma + - brcm,bcm2711-dma reg: maxItems: 1 From patchwork Wed Mar 13 14:08:39 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: 13591464 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 5FEA2C54E58 for ; Wed, 13 Mar 2024 14:11:52 +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=i/xzpuP/y2pr1Aetk0mKhGjbUeQcbFBFH9Fgptjmzog=; b=V32FqvLU83rcN9 fz18FCVgA1mH7GWgbvkgM3kO+ziUondX0oH9QYkq+NP7+GM18cXxLn6FOsFkpGOSRlB+GeXyzyBVk YEg2PtW+39/qg+WLS+vkrpOgV4U2GKu7hCpqGl2zEMOUnhsY/bCTsNAdZkAX9MzkBGSNtaeuz7Qtg D2kh7xSadzEqH6iI3FnXyP8igCj+iGONNvWzR1dLDoIcrkMnl0lQ9KVziTTg04JMiMslat8j38X4L CerHDuSil8U6HaKGOgxDVZAA8M257nl1jm+Koa94mb0ddYyhX8zcIYdGnu9Ns8rx5NvvmdSkvO9aq ljFkWN+KxxoBmrI3FJ9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPKP-0000000ANso-0KHa; Wed, 13 Mar 2024 14:11:33 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPI5-0000000AMIM-23Af for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2024 14:09:17 +0000 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-568107a9ff2so1230572a12.3 for ; Wed, 13 Mar 2024 07:09:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1710338947; x=1710943747; 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=FHhJLSPwlFyN1v47/5LFzL8wYfsbaOex6ckiVXFurW8=; b=D9WwkSIIfeLdyninxoMLGaKkI3QpSfzyeyqQgw+k1rTr9ijWiVa89l8Xdbh6vLM7XF DhRcaAdZV0pXOAOdApjrn3kU4+u4CfN3HqXnior3G+VPmMntz6t7c8DQWw+ISsdbTqdj gPQNzJzHqwsS9ty2/Mq68uYPFWVrVsfvodEWA5IdAse5IcwsIkQahKq4mW6AtbGHvV7d lTlwwdiHuJpuUyNUggFx+jCbaCEkDbYVljbTGKH+swX+zqhwcRgE3+oBU2E231ZRHpxz S+dPcd9/limqbgAWxHo0IGsySRKaxU9PnLd3UDS0R4vyW7f81Jy1kMkHkP6dRsT1E91O MMrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710338947; x=1710943747; 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=FHhJLSPwlFyN1v47/5LFzL8wYfsbaOex6ckiVXFurW8=; b=r8KRRV0y8E949mSnRaOrbHNULc9JIT3afl5LywRVsO6dtl7KfqaDNNouhbD28Qx9mw JUwWqMUv/uYJuRx4br3BoSAR82UNpblApg4DKNiVoCRDwr7W8wZ2NoHLqcrTJ8l7uj+M YMQvt5vKTK/GrabC3JOVlM7WXsC3bWX8DmxiU4PNa/Tjw1qqd3ZhmkKisVX2Y9DyRqjW JYaFQu7ikJeUMYKRAlBbNIZs4ZTpTz8xWKBwk395jH/cutZnf+7fiSB6RkceAQ5cHhML 2QpOhKUrxsAEV7i29GXE9wZZSKOtyyCZ1KIHJIJ2V952qys6UolAhe6V8pLdul/CWM+3 WkhA== X-Forwarded-Encrypted: i=1; AJvYcCUk9MXBYLGAjCnB7rLKJu1W3accKwBfkotq/bZnOlLduW6trbdRx+i1AbEaCdRawbPBi7oX+wupVZ+2HwB8IPmsSYID7Eth4JUGXfqR2HZqVVbRAWM= X-Gm-Message-State: AOJu0YyQdw6wDIGju+oPC+Pu9/EL0wO9yH5COCQKEd9w6GeVpgtIEp/x 4dgS2l7lJqV/ViMOL9AujP+/f3xXUuQnCK5BwXodMTTIc8hG3g3h1F8ew11CW1U= X-Google-Smtp-Source: AGHT+IFZfUFO6ec8Hx97O9B1PZ+LLxyMeP2rh4T4+M4aVsshiF4u+OjXLBBsFevavT315MEjdHrngA== X-Received: by 2002:a50:ab19:0:b0:565:7edf:41b0 with SMTP id s25-20020a50ab19000000b005657edf41b0mr2660468edc.6.1710338946596; Wed, 13 Mar 2024 07:09:06 -0700 (PDT) Received: from localhost (host-82-56-173-172.retail.telecomitalia.it. [82.56.173.172]) by smtp.gmail.com with ESMTPSA id s21-20020a50ab15000000b00568699d4b83sm2404091edc.44.2024.03.13.07.09.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 07:09:06 -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 14/15] dmaengine: bcm2835: Add BCM2711 40-bit DMA support Date: Wed, 13 Mar 2024 15:08:39 +0100 Message-ID: <8e4dceada017ea4804d7dac16c2a4974807a2c01.1710226514.git.andrea.porta@suse.com> 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_070909_641647_0805F182 X-CRM114-Status: GOOD ( 21.25 ) 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 BCM2711 has 4 DMA channels with a 40-bit address range, allowing them to access the full 4GB of memory on a Pi 4. Assume every channel is capable of 40-bit address range. Originally-by: Phil Elwell Originally-by: Maxime Ripard Originally-by: Stefan Wahren Signed-off-by: Andrea della Porta --- drivers/dma/bcm2835-dma.c | 553 ++++++++++++++++++++++++++++++++------ 1 file changed, 466 insertions(+), 87 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index b015eae29b08..5c8dde8b07cd 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -36,13 +36,15 @@ #define BCM2835_DMA_MAX_DMA_CHAN_SUPPORTED 14 #define BCM2835_DMA_CHAN_NAME_SIZE 8 +#define BCM2711_DMA40_PHYS_ADDR 0x400000000ULL +#define BCM2835_DMA_ABORT_TIMEOUT 100 /** * struct bcm2835_dmadev - BCM2835 DMA controller * @ddev: DMA device * @base: base address of register map * @zero_page: bus address of zero page (to detect transactions copying from - * zero page and avoid accessing memory if so) + * zero page and avoid accessing memory if so) */ struct bcm2835_dmadev { struct dma_device ddev; @@ -52,7 +54,7 @@ struct bcm2835_dmadev { }; struct bcm_dma_cb { - uint32_t rsvd[8]; + u32 rsvd[8]; }; struct bcm2835_dma_cb { @@ -65,6 +67,17 @@ struct bcm2835_dma_cb { u32 pad[2]; }; +struct bcm2711_dma40_scb { + u32 ti; + u32 src; + u32 srci; + u32 dst; + u32 dsti; + u32 len; + u32 next_cb; + u32 rsvd; +}; + struct bcm2835_cb_entry { struct bcm_dma_cb *cb; dma_addr_t paddr; @@ -102,14 +115,16 @@ struct bcm2835_dma_cfg { u32 s_dreq_mask; u32 d_dreq_mask; + u64 dma_mask; + u32 (*cb_get_length)(void *data); dma_addr_t (*cb_get_addr)(void *data, enum dma_transfer_direction); void (*cb_init)(void *data, struct bcm2835_chan *c, - enum dma_transfer_direction, u32 src, u32 dst, + enum dma_transfer_direction, dma_addr_t src, dma_addr_t dst, bool zero_page); - void (*cb_set_src)(void *data, enum dma_transfer_direction, u32 src); - void (*cb_set_dst)(void *data, enum dma_transfer_direction, u32 dst); + void (*cb_set_src)(void *data, enum dma_transfer_direction, dma_addr_t src); + void (*cb_set_dst)(void *data, enum dma_transfer_direction, dma_addr_t dst); void (*cb_set_next)(void *data, u32 next); void (*cb_set_length)(void *data, u32 length); void (*cb_append_extra)(void *data, @@ -123,6 +138,7 @@ struct bcm2835_dma_cfg { dma_addr_t (*read_addr)(struct bcm2835_chan *c, enum dma_transfer_direction); u32 (*cs_flags)(struct bcm2835_chan *c); + void (*dma_abort)(struct bcm2835_chan *c, const struct bcm2835_dma_cfg *cfg); }; struct bcm2835_desc { @@ -233,13 +249,110 @@ struct bcm2835_desc { #define BCM2835_DMA_DATA_TYPE_S128 16 /* Valid only for channels 0 - 14, 15 has its own base address */ -#define BCM2835_DMA_CHAN(n) ((n) << 8) /* Base address */ +#define BCM2835_DMA_CHAN_SIZE 0x100 +#define BCM2835_DMA_CHAN(n) ((n) * BCM2835_DMA_CHAN_SIZE) /* Base address */ #define BCM2835_DMA_CHANIO(base, n) ((base) + BCM2835_DMA_CHAN(n)) +/* 40-bit DMA support */ +#define BCM2711_DMA40_CS 0x00 +#define BCM2711_DMA40_CB 0x04 +#define BCM2711_DMA40_DEBUG 0x0c +#define BCM2711_DMA40_TI 0x10 +#define BCM2711_DMA40_SRC 0x14 +#define BCM2711_DMA40_SRCI 0x18 +#define BCM2711_DMA40_DEST 0x1c +#define BCM2711_DMA40_DESTI 0x20 +#define BCM2711_DMA40_LEN 0x24 +#define BCM2711_DMA40_NEXT_CB 0x28 +#define BCM2711_DMA40_DEBUG2 0x2c + +#define BCM2711_DMA40_ACTIVE BIT(0) +#define BCM2711_DMA40_END BIT(1) +#define BCM2711_DMA40_INT BIT(2) +#define BCM2711_DMA40_DREQ BIT(3) /* DREQ state */ +#define BCM2711_DMA40_RD_PAUSED BIT(4) /* Reading is paused */ +#define BCM2711_DMA40_WR_PAUSED BIT(5) /* Writing is paused */ +#define BCM2711_DMA40_DREQ_PAUSED BIT(6) /* Is paused by DREQ flow control */ +#define BCM2711_DMA40_WAITING_FOR_WRITES BIT(7) /* Waiting for last write */ +#define BCM2711_DMA40_ERR BIT(10) +#define BCM2711_DMA40_QOS(x) FIELD_PREP(GENMASK(19, 16), x) +#define BCM2711_DMA40_PANIC_QOS(x) FIELD_PREP(GENMASK(23, 20), x) +#define BCM2711_DMA40_WAIT_FOR_WRITES BIT(28) +#define BCM2711_DMA40_DISDEBUG BIT(29) +#define BCM2711_DMA40_ABORT BIT(30) +#define BCM2711_DMA40_HALT BIT(31) +// we always want to run in supervisor mode +#define BCM2711_DMA40_PROT (BIT(8) | BIT(9)) +#define BCM2711_DMA40_TRANSACTIONS BIT(25) +#define BCM2711_DMA40_CS_FLAGS(x) ((x) & (BCM2711_DMA40_QOS(15) | \ + BCM2711_DMA40_PANIC_QOS(15) | \ + BCM2711_DMA40_WAIT_FOR_WRITES | \ + BCM2711_DMA40_DISDEBUG)) + +/* Transfer information bits */ +#define BCM2711_DMA40_INTEN BIT(0) +#define BCM2711_DMA40_TDMODE BIT(1) /* 2D-Mode */ +#define BCM2711_DMA40_WAIT_RESP BIT(2) /* wait for AXI write to be acked */ +#define BCM2711_DMA40_WAIT_RD_RESP BIT(3) /* wait for AXI read to complete */ +#define BCM2711_DMA40_PER_MAP(x) (((x) & 31) << 9) /* REQ source */ +#define BCM2711_DMA40_S_DREQ BIT(14) /* enable SREQ for source */ +#define BCM2711_DMA40_D_DREQ BIT(15) /* enable DREQ for destination */ +#define BCM2711_DMA40_S_WAIT(x) FIELD_PREP(GENMASK(23, 16), x) /* add DMA read-wait cycles */ +#define BCM2711_DMA40_D_WAIT(x) FIELD_PREP(GENMASK(31, 24), x) /* add DMA write-wait cycles */ + +#define BCM2711_DMA40_INC BIT(12) +#define BCM2711_DMA40_IGNORE BIT(15) + /* the max dma length for different channels */ #define MAX_DMA_LEN SZ_1G #define MAX_LITE_DMA_LEN (SZ_64K - 4) +/* debug register bits */ +#define BCM2711_DMA40_DEBUG_WRITE_ERR BIT(0) +#define BCM2711_DMA40_DEBUG_FIFO_ERR BIT(1) +#define BCM2711_DMA40_DEBUG_READ_ERR BIT(2) +#define BCM2711_DMA40_DEBUG_READ_CB_ERR BIT(3) +#define BCM2711_DMA40_DEBUG_IN_ON_ERR BIT(8) +#define BCM2711_DMA40_DEBUG_ABORT_ON_ERR BIT(9) +#define BCM2711_DMA40_DEBUG_HALT_ON_ERR BIT(10) +#define BCM2711_DMA40_DEBUG_DISABLE_CLK_GATE BIT(11) +#define BCM2711_DMA40_DEBUG_RSTATE_SHIFT 14 +#define BCM2711_DMA40_DEBUG_RSTATE_BITS 4 +#define BCM2711_DMA40_DEBUG_WSTATE_SHIFT 18 +#define BCM2711_DMA40_DEBUG_WSTATE_BITS 4 +#define BCM2711_DMA40_DEBUG_RESET BIT(23) +#define BCM2711_DMA40_DEBUG_ID_SHIFT 24 +#define BCM2711_DMA40_DEBUG_ID_BITS 4 +#define BCM2711_DMA40_DEBUG_VERSION_SHIFT 28 +#define BCM2711_DMA40_DEBUG_VERSION_BITS 4 + +/* Valid only for channels 0 - 3 (11 - 14) */ +#define BCM2711_DMA40_CHAN(n) (((n) + 11) << 8) /* Base address */ +#define BCM2711_DMA40_CHANIO(base, n) ((base) + BCM2711_DMA_CHAN(n)) + +/* the max dma length for different channels */ +#define MAX_DMA40_LEN SZ_1G + +#define BCM2711_DMA40_BURST_LEN(x) (((x) & 15) << 8) +#define BCM2711_DMA40_INC BIT(12) +#define BCM2711_DMA40_SIZE_32 (0 << 13) +#define BCM2711_DMA40_SIZE_64 (1 << 13) +#define BCM2711_DMA40_SIZE_128 (2 << 13) +#define BCM2711_DMA40_SIZE_256 (3 << 13) +#define BCM2711_DMA40_IGNORE BIT(15) +#define BCM2711_DMA40_STRIDE(x) ((x) << 16) /* For 2D mode */ + +#define BCM2711_DMA40_MEMCPY_FLAGS \ + (BCM2711_DMA40_QOS(0) | \ + BCM2711_DMA40_PANIC_QOS(0) | \ + BCM2711_DMA40_WAIT_FOR_WRITES | \ + BCM2711_DMA40_DISDEBUG) + +#define BCM2711_DMA40_MEMCPY_XFER_INFO \ + (BCM2711_DMA40_SIZE_128 | \ + BCM2711_DMA40_INC | \ + BCM2711_DMA40_BURST_LEN(16)) + static inline size_t bcm2835_dma_max_frame_length(struct bcm2835_chan *c) { /* lite and normal channels have different max frame length */ @@ -270,8 +383,7 @@ static inline struct bcm2835_chan *to_bcm2835_dma_chan(struct dma_chan *c) return container_of(c, struct bcm2835_chan, vc.chan); } -static inline struct bcm2835_desc *to_bcm2835_dma_desc( - struct dma_async_tx_descriptor *t) +static inline struct bcm2835_desc *to_bcm2835_dma_desc(struct dma_async_tx_descriptor *t) { return container_of(t, struct bcm2835_desc, vd.tx); } @@ -296,9 +408,8 @@ static u32 bcm2835_dma_prepare_cb_info(struct bcm2835_chan *c, result |= BCM2835_DMA_D_DREQ | BCM2835_DMA_S_INC; /* non-lite channels can write zeroes w/o accessing memory */ - if (zero_page && !c->is_lite_channel) { + if (zero_page && !c->is_lite_channel) result |= BCM2835_DMA_S_IGNORE; - } } return result; @@ -324,6 +435,66 @@ static u32 bcm2835_dma_prepare_cb_extra(struct bcm2835_chan *c, return result; } +static inline uint32_t to_bcm2711_ti(uint32_t info) +{ + return ((info & BCM2835_DMA_INT_EN) ? BCM2711_DMA40_INTEN : 0) | + ((info & BCM2835_DMA_WAIT_RESP) ? BCM2711_DMA40_WAIT_RESP : 0) | + ((info & BCM2835_DMA_S_DREQ) ? + (BCM2711_DMA40_S_DREQ | BCM2711_DMA40_WAIT_RD_RESP) : 0) | + ((info & BCM2835_DMA_D_DREQ) ? BCM2711_DMA40_D_DREQ : 0) | + BCM2711_DMA40_PER_MAP((info >> 16) & 0x1f); +} + +static inline uint32_t to_bcm2711_srci(uint32_t info) +{ + return ((info & BCM2835_DMA_S_INC) ? BCM2711_DMA40_INC : 0) | + ((info & BCM2835_DMA_S_WIDTH) ? BCM2711_DMA40_SIZE_128 : 0) | + BCM2711_DMA40_BURST_LEN(BCM2835_DMA_GET_BURST_LENGTH(info)); +} + +static inline uint32_t to_bcm2711_dsti(uint32_t info) +{ + return ((info & BCM2835_DMA_D_INC) ? BCM2711_DMA40_INC : 0) | + ((info & BCM2835_DMA_D_WIDTH) ? BCM2711_DMA40_SIZE_128 : 0) | + BCM2711_DMA40_BURST_LEN(BCM2835_DMA_GET_BURST_LENGTH(info)); +} + +static u32 bcm2711_dma_prepare_cb_info(struct bcm2835_chan *c, + enum dma_transfer_direction direction, + bool zero_page) +{ + u32 result = 0; + u32 info; + + info = bcm2835_dma_prepare_cb_info(c, direction, zero_page); + result = to_bcm2711_ti(info); + + return result; +} + +static u32 bcm2711_dma_prepare_cb_extra(struct bcm2835_chan *c, + enum dma_transfer_direction direction, + bool cyclic, bool final, + unsigned long flags) +{ + u32 result = 0; + + if (cyclic) { + if (flags & DMA_PREP_INTERRUPT) + result |= BCM2711_DMA40_INTEN; + } else { + if (!final) + return 0; + + result |= BCM2711_DMA40_INTEN; + + if (direction == DMA_MEM_TO_MEM) + result |= BCM2711_DMA40_WAIT_RESP; + } + + return result; +} + static inline bool need_src_incr(enum dma_transfer_direction direction) { return direction != DMA_DEV_TO_MEM; @@ -342,6 +513,12 @@ static inline bool need_dst_incr(enum dma_transfer_direction direction) return false; } +static inline uint32_t to_bcm2711_cbaddr(dma_addr_t addr) +{ + WARN_ON_ONCE(addr & 0x1f); + return (addr >> 5); +} + static inline u32 bcm2835_dma_cb_get_length(void *data) { struct bcm2835_dma_cb *cb = data; @@ -362,7 +539,7 @@ bcm2835_dma_cb_get_addr(void *data, enum dma_transfer_direction direction) static inline void bcm2835_dma_cb_init(void *data, struct bcm2835_chan *c, - enum dma_transfer_direction direction, u32 src, u32 dst, + enum dma_transfer_direction direction, dma_addr_t src, dma_addr_t dst, bool zero_page) { struct bcm2835_dma_cb *cb = data; @@ -376,7 +553,7 @@ bcm2835_dma_cb_init(void *data, struct bcm2835_chan *c, static inline void bcm2835_dma_cb_set_src(void *data, enum dma_transfer_direction direction, - u32 src) + dma_addr_t src) { struct bcm2835_dma_cb *cb = data; @@ -385,7 +562,7 @@ bcm2835_dma_cb_set_src(void *data, enum dma_transfer_direction direction, static inline void bcm2835_dma_cb_set_dst(void *data, enum dma_transfer_direction direction, - u32 dst) + dma_addr_t dst) { struct bcm2835_dma_cb *cb = data; @@ -445,6 +622,124 @@ static u32 bcm2835_dma_cs_flags(struct bcm2835_chan *c) return BCM2835_DMA_CS_FLAGS(c->dreq); } +static inline u32 bcm2711_dma_cb_get_length(void *data) +{ + struct bcm2711_dma40_scb *scb = data; + + return scb->len; +} + +static inline dma_addr_t +bcm2711_dma_cb_get_addr(void *data, enum dma_transfer_direction direction) +{ + struct bcm2711_dma40_scb *scb = data; + + if (direction == DMA_DEV_TO_MEM) + return (dma_addr_t)scb->dst + ((dma_addr_t)(scb->dsti & 0xff) << 32); + + return (dma_addr_t)scb->src + ((dma_addr_t)(scb->srci & 0xff) << 32); +} + +static inline void +bcm2711_dma_cb_init(void *data, struct bcm2835_chan *c, + enum dma_transfer_direction direction, dma_addr_t src, dma_addr_t dst, + bool zero_page) +{ + struct bcm2711_dma40_scb *scb = data; + u32 info = bcm2835_dma_prepare_cb_info(c, direction, zero_page); + + scb->ti = bcm2711_dma_prepare_cb_info(c, direction, zero_page); + + scb->src = lower_32_bits(src); + scb->srci = upper_32_bits(src); + scb->srci |= to_bcm2711_srci(info); + + scb->dst = lower_32_bits(dst); + scb->dsti = upper_32_bits(dst); + scb->dsti |= to_bcm2711_dsti(info); + + scb->next_cb = 0; +} + +static inline void +bcm2711_dma_cb_set_src(void *data, enum dma_transfer_direction direction, + dma_addr_t src) +{ + struct bcm2711_dma40_scb *scb = data; + + scb->src = lower_32_bits(src); + scb->srci = upper_32_bits(src); + + if (need_src_incr(direction)) + scb->srci |= BCM2711_DMA40_INC; +} + +static inline void +bcm2711_dma_cb_set_dst(void *data, enum dma_transfer_direction direction, + dma_addr_t dst) +{ + struct bcm2711_dma40_scb *scb = data; + + scb->dst = lower_32_bits(dst); + scb->dsti = upper_32_bits(dst); + + if (need_dst_incr(direction)) + scb->dsti |= BCM2711_DMA40_INC; +} + +static inline void bcm2711_dma_cb_set_next(void *data, u32 next) +{ + struct bcm2711_dma40_scb *scb = data; + + scb->next_cb = next; +} + +static inline void bcm2711_dma_cb_set_length(void *data, u32 length) +{ + struct bcm2711_dma40_scb *scb = data; + + scb->len = length; +} + +static inline void +bcm2711_dma_cb_append_extra(void *data, struct bcm2835_chan *c, + enum dma_transfer_direction direction, + bool cyclic, bool final, unsigned long flags) +{ + struct bcm2711_dma40_scb *scb = data; + + scb->ti |= bcm2711_dma_prepare_cb_extra(c, direction, cyclic, final, + flags); +} + +static inline dma_addr_t bcm2711_dma_to_cb_addr(dma_addr_t addr) +{ + WARN_ON_ONCE(addr & 0x1f); + return (addr >> 5); +} + +static void bcm2711_dma_chan_plat_init(struct bcm2835_chan *c) +{ +} + +static dma_addr_t bcm2711_dma_read_addr(struct bcm2835_chan *c, + enum dma_transfer_direction direction) +{ + if (direction == DMA_MEM_TO_DEV) + return (dma_addr_t)readl(c->chan_base + BCM2711_DMA40_SRC) + + ((dma_addr_t)(readl(c->chan_base + BCM2711_DMA40_SRCI) & 0xff) << 32); + else if (direction == DMA_DEV_TO_MEM) + return (dma_addr_t)readl(c->chan_base + BCM2711_DMA40_DEST) + + ((dma_addr_t)(readl(c->chan_base + BCM2711_DMA40_DESTI) & 0xff) << 32); + + return 0; +} + +static u32 bcm2711_dma_cs_flags(struct bcm2835_chan *c) +{ + return BCM2711_DMA40_CS_FLAGS(c->dreq) | BCM2711_DMA40_PROT; +} + static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc) { size_t i; @@ -470,36 +765,34 @@ static bool bcm2835_dma_create_cb_set_length(struct dma_chan *chan, const struct bcm2835_dma_cfg *cfg = to_bcm2835_cfg(chan->device); struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); size_t max_len = bcm2835_dma_max_frame_length(c); + u32 cb_len; /* set the length taking lite-channel limitations into account */ - u32 length = min_t(u32, len, max_len); + cb_len = min_t(u32, len, max_len); - cfg->cb_set_length(data, length); + if (period_len) { + /* + * period_len means: that we need to generate + * transfers that are terminating at every + * multiple of period_len - this is typically + * used to set the interrupt flag in info + * which is required during cyclic transfers + */ - /* finished if we have no period_length */ - if (!period_len) - return false; + /* have we filled in period_length yet? */ + if (*total_len + cb_len < period_len) { + /* update number of bytes in this period so far */ + *total_len += cb_len; + } else { + /* calculate the length that remains to reach period_len */ + cb_len = period_len - *total_len; - /* - * period_len means: that we need to generate - * transfers that are terminating at every - * multiple of period_len - this is typically - * used to set the interrupt flag in info - * which is required during cyclic transfers - */ - - /* have we filled in period_length yet? */ - if (*total_len + length < period_len) { - /* update number of bytes in this period so far */ - *total_len += length; - return false; + /* reset total_length for next period */ + *total_len = 0; + } } - /* calculate the length that remains to reach period_length */ - cfg->cb_set_length(data, period_len - *total_len); - - /* reset total_length for next period */ - *total_len = 0; + cfg->cb_set_length(data, cb_len); return true; } @@ -523,7 +816,7 @@ static inline size_t bcm2835_dma_count_frames_for_sg(struct bcm2835_chan *c, /** * bcm2835_dma_create_cb_chain - create a control block and fills data in * - * @chan: the @dma_chan for which we run this + * @c: the @bcm2835_chan for which we run this * @direction: the direction in which we transfer * @cyclic: it is a cyclic transfer * @frames: number of controlblocks to allocate @@ -587,17 +880,19 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( /* fill in the control block */ control_block = cb_entry->cb; - cfg->cb_init(control_block, c, src, dst, direction, zero_page); + + cfg->cb_init(control_block, c, direction, src, dst, zero_page); + /* set up length in control_block if requested */ if (buf_len) { /* calculate length honoring period_length */ - if (bcm2835_dma_create_cb_set_length( - chan, control_block, - len, period_len, &total_len)) { - /* add extrainfo bits in info */ - bcm2835_dma_cb_append_extra(control_block, c, - direction, cyclic, - false, flags); + if (bcm2835_dma_create_cb_set_length(chan, control_block, + len, period_len, + &total_len)) { + /* add extrainfo bits in info */ + bcm2835_dma_cb_append_extra(control_block, c, + direction, cyclic, + false, flags); } /* calculate new remaining length */ @@ -607,11 +902,12 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( /* link this the last controlblock */ if (frame) cfg->cb_set_next(d->cb_list[frame - 1].cb, - cb_entry->paddr); + cfg->to_cb_addr(cb_entry->paddr)); /* update src and dst and length */ if (src && need_src_incr(direction)) src += cfg->cb_get_length(control_block); + if (dst && need_dst_incr(direction)) dst += cfg->cb_get_length(control_block); @@ -621,7 +917,7 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( /* the last frame requires extra flags */ cfg->cb_append_extra(d->cb_list[d->frames - 1].cb, c, direction, cyclic, - true, flags); + true, flags); /* detect a size mismatch */ if (buf_len && d->size != buf_len) @@ -650,7 +946,8 @@ static void bcm2835_dma_fill_cb_chain_with_sg( max_len = bcm2835_dma_max_frame_length(c); for_each_sg(sgl, sgent, sg_len, i) { - for (addr = sg_dma_address(sgent), len = sg_dma_len(sgent); + for (addr = sg_dma_address(sgent), + len = sg_dma_len(sgent); len > 0; addr += cfg->cb_get_length(cb->cb), len -= cfg->cb_get_length(cb->cb), cb++) { if (direction == DMA_DEV_TO_MEM) @@ -662,48 +959,81 @@ static void bcm2835_dma_fill_cb_chain_with_sg( } } -static void bcm2835_dma_abort(struct dma_chan *chan) +static void bcm2835_abort(struct bcm2835_chan *c, const struct bcm2835_dma_cfg *cfg) { - const struct bcm2835_dma_cfg *cfg = to_bcm2835_cfg(chan->device); - struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); - void __iomem *chan_base = c->chan_base; - long timeout = 100; + long timeout = BCM2835_DMA_ABORT_TIMEOUT; - /* - * A zero control block address means the channel is idle. - * (The ACTIVE flag in the CS register is not a reliable indicator.) - */ - if (!readl(chan_base + cfg->cb_reg)) - return; + /* Pause the current DMA */ + writel(readl(c->chan_base + cfg->cs_reg) & ~cfg->active_mask, + c->chan_base + cfg->cs_reg); + + /* wait for outstanding transactions to complete */ + while ((readl(c->chan_base + cfg->cs_reg) & BCM2711_DMA40_TRANSACTIONS) && + --timeout) + cpu_relax(); + + /* Peripheral might be stuck and fail to complete */ + if (!timeout) + dev_err(c->vc.chan.device->dev, + "failed to complete pause on dma %d (CS:%08x)\n", c->ch, + readl(c->chan_base + cfg->cs_reg)); + + /* Set CS back to default state */ + writel(BCM2711_DMA40_PROT, c->chan_base + cfg->cs_reg); + + /* Reset the DMA */ + writel(readl(c->chan_base + BCM2711_DMA40_DEBUG) | BCM2711_DMA40_DEBUG_RESET, + c->chan_base + BCM2711_DMA40_DEBUG); +} + +static void bcm2711_abort(struct bcm2835_chan *c, const struct bcm2835_dma_cfg *cfg) +{ + long timeout = BCM2835_DMA_ABORT_TIMEOUT; /* We need to clear the next DMA block pending */ - writel(0, chan_base + cfg->next_reg); + writel(0, c->chan_base + cfg->next_reg); /* Abort the DMA, which needs to be enabled to complete */ - writel(readl(chan_base + cfg->cs_reg) | cfg->abort_mask | cfg->active_mask, - chan_base + cfg->cs_reg); + writel(readl(c->chan_base + cfg->cs_reg) | cfg->abort_mask | cfg->active_mask, + c->chan_base + cfg->cs_reg); /* wait for DMA to be aborted */ - while ((readl(chan_base + cfg->cs_reg) & cfg->abort_mask) && --timeout) + while ((readl(c->chan_base + cfg->cs_reg) & cfg->abort_mask) && --timeout) cpu_relax(); /* Write 0 to the active bit - Pause the DMA */ - writel(readl(chan_base + cfg->cs_reg) & ~cfg->active_mask, - chan_base + cfg->cs_reg); + writel(readl(c->chan_base + cfg->cs_reg) & ~cfg->active_mask, + c->chan_base + cfg->cs_reg); /* * 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 + cfg->ti_reg) & + if (!timeout && !(readl(c->chan_base + cfg->ti_reg) & (cfg->s_dreq_mask | cfg->d_dreq_mask))) dev_err(c->vc.chan.device->dev, "failed to complete pause on dma %d (CS:%08x)\n", c->ch, - readl(chan_base + cfg->cs_reg)); + readl(c->chan_base + cfg->cs_reg)); /* Set CS back to default state and reset the DMA */ - writel(cfg->reset_mask, chan_base + cfg->cs_reg); + writel(cfg->reset_mask, c->chan_base + cfg->cs_reg); +} + +static void bcm2835_dma_abort(struct dma_chan *chan) +{ + const struct bcm2835_dma_cfg *cfg = to_bcm2835_cfg(chan->device); + struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); + void __iomem *chan_base = c->chan_base; + + /* + * A zero control block address means the channel is idle. + * (The ACTIVE flag in the CS register is not a reliable indicator.) + */ + if (!readl(chan_base + cfg->cb_reg)) + return; + + cfg->dma_abort(c, cfg); } static void bcm2835_dma_start_desc(struct dma_chan *chan) @@ -722,8 +1052,7 @@ static void bcm2835_dma_start_desc(struct dma_chan *chan) c->desc = to_bcm2835_dma_desc(&vd->tx); writel(cfg->to_cb_addr(c->desc->cb_list[0].paddr), c->chan_base + cfg->cb_reg); - writel(cfg->active_mask | cfg->cs_flags(c), - c->chan_base + cfg->cs_reg); + writel(cfg->active_mask | cfg->cs_flags(c), c->chan_base + cfg->cs_reg); } static irqreturn_t bcm2835_dma_callback(int irq, void *data) @@ -1106,6 +1435,8 @@ static const struct bcm2835_dma_cfg bcm2835_data = { .s_dreq_mask = BCM2835_DMA_S_DREQ, .d_dreq_mask = BCM2835_DMA_D_DREQ, + .dma_mask = DMA_BIT_MASK(32), + .cb_get_length = bcm2835_dma_cb_get_length, .cb_get_addr = bcm2835_dma_cb_get_addr, .cb_init = bcm2835_dma_cb_init, @@ -1120,10 +1451,47 @@ static const struct bcm2835_dma_cfg bcm2835_data = { .chan_plat_init = bcm2835_dma_chan_plat_init, .read_addr = bcm2835_dma_read_addr, .cs_flags = bcm2835_dma_cs_flags, + .dma_abort = bcm2835_abort, +}; + +static const struct bcm2835_dma_cfg bcm2711_data = { + .addr_offset = BCM2711_DMA40_PHYS_ADDR, + + .cs_reg = BCM2711_DMA40_CS, + .cb_reg = BCM2711_DMA40_CB, + .next_reg = BCM2711_DMA40_NEXT_CB, + .ti_reg = BCM2711_DMA40_TI, + + .wait_mask = BCM2711_DMA40_WAITING_FOR_WRITES, + .reset_mask = BCM2711_DMA40_HALT, + .int_mask = BCM2711_DMA40_INTEN, + .active_mask = BCM2711_DMA40_ACTIVE, + .abort_mask = BCM2711_DMA40_ABORT, + .s_dreq_mask = BCM2711_DMA40_S_DREQ, + .d_dreq_mask = BCM2711_DMA40_D_DREQ, + + .dma_mask = DMA_BIT_MASK(36), + + .cb_get_length = bcm2711_dma_cb_get_length, + .cb_get_addr = bcm2711_dma_cb_get_addr, + .cb_init = bcm2711_dma_cb_init, + .cb_set_src = bcm2711_dma_cb_set_src, + .cb_set_dst = bcm2711_dma_cb_set_dst, + .cb_set_next = bcm2711_dma_cb_set_next, + .cb_set_length = bcm2711_dma_cb_set_length, + .cb_append_extra = bcm2711_dma_cb_append_extra, + + .to_cb_addr = bcm2711_dma_to_cb_addr, + + .chan_plat_init = bcm2711_dma_chan_plat_init, + .read_addr = bcm2711_dma_read_addr, + .cs_flags = bcm2711_dma_cs_flags, + .dma_abort = bcm2711_abort, }; static const struct of_device_id bcm2835_dma_of_match[] = { { .compatible = "brcm,bcm2835-dma", .data = &bcm2835_data }, + { .compatible = "brcm,bcm2711-dma", .data = &bcm2711_data }, {}, }; MODULE_DEVICE_TABLE(of, bcm2835_dma_of_match); @@ -1147,6 +1515,7 @@ static struct dma_chan *bcm2835_dma_xlate(struct of_phandle_args *spec, static int bcm2835_dma_probe(struct platform_device *pdev) { struct bcm2835_dmadev *od; + struct resource *res; void __iomem *base; int rc; int i, j; @@ -1154,34 +1523,38 @@ static int bcm2835_dma_probe(struct platform_device *pdev) int irq_flags; u32 chans_available; char chan_name[BCM2835_DMA_CHAN_NAME_SIZE]; + int chan_count, chan_start, chan_end; - const void *cfg_data = device_get_match_data(&pdev->dev); - if (!cfg_data) { - dev_err(&pdev->dev, "Failed to match compatible string\n"); - return -EINVAL; - } + od = devm_kzalloc(&pdev->dev, sizeof(*od), GFP_KERNEL); + if (!od) + return -ENOMEM; - if (!pdev->dev.dma_mask) - pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; + od->cfg = device_get_match_data(&pdev->dev); + if (!od->cfg) { + dev_err(&pdev->dev, "Failed to match compatible string\n"); + return -EINVAL; + } - rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); + rc = dma_set_mask_and_coherent(&pdev->dev, od->cfg->dma_mask); if (rc) { dev_err(&pdev->dev, "Unable to set DMA mask\n"); return rc; } - od = devm_kzalloc(&pdev->dev, sizeof(*od), GFP_KERNEL); - if (!od) - return -ENOMEM; - dma_set_max_seg_size(&pdev->dev, 0x3FFFFFFF); - base = devm_platform_ioremap_resource(pdev, 0); + base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); if (IS_ERR(base)) return PTR_ERR(base); + /* The set of channels can be split across multiple instances. */ + chan_start = ((u32)(uintptr_t)base / BCM2835_DMA_CHAN_SIZE) & 0xf; + base -= BCM2835_DMA_CHAN(chan_start); + chan_count = resource_size(res) / BCM2835_DMA_CHAN_SIZE; + chan_end = min(chan_start + chan_count, + BCM2835_DMA_MAX_DMA_CHAN_SUPPORTED + 1); + od->base = base; - od->cfg = cfg_data; dma_cap_set(DMA_SLAVE, od->ddev.cap_mask); dma_cap_set(DMA_PRIVATE, od->ddev.cap_mask); @@ -1233,7 +1606,7 @@ static int bcm2835_dma_probe(struct platform_device *pdev) } /* get irqs for each channel that we support */ - for (i = 0; i <= BCM2835_DMA_MAX_DMA_CHAN_SUPPORTED; i++) { + for (i = chan_start; i < chan_end; i++) { /* skip masked out channels */ if (!(chans_available & (1 << i))) { irq[i] = -1; @@ -1256,13 +1629,18 @@ static int bcm2835_dma_probe(struct platform_device *pdev) irq[i] = platform_get_irq(pdev, i < 11 ? i : 11); } + chan_count = 0; + /* get irqs for each channel */ - for (i = 0; i <= BCM2835_DMA_MAX_DMA_CHAN_SUPPORTED; i++) { + for (i = chan_start; i < chan_end; i++) { /* skip channels without irq */ if (irq[i] < 0) continue; /* check if there are other channels that also use this irq */ + /* FIXME: This will fail if interrupts are shared across + * instances + */ irq_flags = 0; for (j = 0; j <= BCM2835_DMA_MAX_DMA_CHAN_SUPPORTED; j++) if (i != j && irq[j] == irq[i]) { @@ -1274,9 +1652,10 @@ static int bcm2835_dma_probe(struct platform_device *pdev) rc = bcm2835_dma_chan_init(od, i, irq[i], irq_flags); if (rc) goto err_no_dma; + chan_count++; } - dev_dbg(&pdev->dev, "Initialized %i DMA channels\n", i); + dev_dbg(&pdev->dev, "Initialized %i DMA channels\n", chan_count); /* Device-tree DMA controller registration */ rc = of_dma_controller_register(pdev->dev.of_node, From patchwork Wed Mar 13 14:08:40 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: 13591462 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 2D564C54791 for ; Wed, 13 Mar 2024 14:11:09 +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=Cuecu6iNbyQ2zS1Wb+djrUdm7XIgrkgkYPwH8CcDarw=; b=DdfXg6ZpiJn/UP bH/ON9+NGJnElzOlHejqNxFv7eSH0Ly5cYts9i9bVWN6REBzTRPnMCOWPCAbOy1uT5S2PHpMdBxtT oTHq4645UVIMTHZ7L8+6NsLS7fysy+yDFKCMUdwOfQcQAhCwhTijmzGRc2LNsjm4FOOqbhpkBEnh+ pq8Ia1J2xtAgGzEmeGuG9VfoUVm1cxNXKjIV8X/kIUKxtaC5LwD8O42zUgCTUQzt3LAyt4I2LPJXc yxoCMEoB0d+2fXriarN6WZuuQ9uvCMPNPbbHyk1hRha2eisSDgrmGSE1vapUxaXkHgGBGEdLr66lV 7UP4QU4q3kJtdYth2jDw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPJh-0000000ANNq-31NR; Wed, 13 Mar 2024 14:10:49 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPI5-0000000AMKT-1XtC for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2024 14:09:13 +0000 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-a4644bde1d4so265388066b.3 for ; Wed, 13 Mar 2024 07:09:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1710338948; x=1710943748; 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=GZRpUUNRnIq77pI2eAogF8VwCXAgFL/1g3LqDmhWq/Q=; b=LA9bXPEgyrqsiFNh24qcONr35gI/JzROTKirkO4EO3JmsDytrrus+a+9d0xVihsZkH 9DQT6tDwvYfOjZsMhopTMyVIyuh+R8CR5pK1dMvyHXbnYg0ROQJa0gEtkgafpwvH5Cf0 CplmGfd3rfyzSDenwnny65wsbcYPSRlgkG7iqBiY3LbaM+rw2E4sTY5y4iWrVGebpPjq CWYmeKeXmuplqqqTT/MgCHZAY9BnJlhijoTCAWoJwCKxCWB44r1vaWVgC+U6AWCv47L9 omqtD530k54I98SxPxzZOn7zE6QjxH0ubKUv3kj80PwhqVMnqMwug+fsdlM7OZIILuMr CRFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710338948; x=1710943748; 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=GZRpUUNRnIq77pI2eAogF8VwCXAgFL/1g3LqDmhWq/Q=; b=ZUqEPHjj1VoVVeVPJcj86xbP70g03yW0HFUkIgd9ckoczXqCxL4Nhpx8pn7b9pkVe6 cwolrjJ1WWTmYL0UMTX+dJz/Ok0lhZjLGdCaid39ejX7tDo3RZduwkpHWlEZ6n+/2KX2 hcAXYRsyxHrW+MNHN0RqStIcaLuopxuojMcZikSpxSjKBlOawWVbIM11v2s82a+mfJ96 rXbz9Nse9Nhrqs5kDrphoIBIinefNybFlPs2MQbKVYFdskRvBEc4DxGK9lHpi0o1EgEJ fAMb19ZEOXzlzX2Q0HB4HQxC3aDRt+82pzwZWCFNBBQCYk2JKGJ403SWcOIrvpHGCfXy yOng== X-Forwarded-Encrypted: i=1; AJvYcCV9+cPQItsKJ+pUozjUDkT22EFnSxPdL0OsjX7L+W2YLjFAIzH/PIwVpfiNxOrUnd+Z4Oq3lkeYmWIL+zqN0yQtTOO1qXesv/aM/b89dRdK29aAyeA= X-Gm-Message-State: AOJu0Yx/ewzXLs45C51KQhnTmBZhwTQP3AvzOmL/LFnt1K04IkWCiarV P0y2XdM25wI5Y7kjiyayFCVL6Djzj1BmPRPvq6tDdS0Nci6lQv2zppbKBPNhj+E= X-Google-Smtp-Source: AGHT+IHXP//swNkKDNyDphpeA3YlUW8pirt81Yn5DGc/hQTDcD01ShGZgqiYGBU6e4PUzoyKglVJzQ== X-Received: by 2002:a17:907:1819:b0:a46:5941:8927 with SMTP id lg25-20020a170907181900b00a4659418927mr1199309ejc.68.1710338947965; Wed, 13 Mar 2024 07:09:07 -0700 (PDT) Received: from localhost (host-82-56-173-172.retail.telecomitalia.it. [82.56.173.172]) by smtp.gmail.com with ESMTPSA id lf8-20020a170906ae4800b00a4657cad7e8sm701392ejb.127.2024.03.13.07.09.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 07:09:07 -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 15/15] ARM: dts: bcm2711: add bcm2711-dma node Date: Wed, 13 Mar 2024 15:08:40 +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_070909_628072_9A257549 X-CRM114-Status: GOOD ( 10.93 ) 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 BCM2711 has 4 DMA channels with a 40-bit address range, allowing them to access the full 4GB of memory on a Pi 4. Adding a new node to make use of the DMA channels capable of 40 bit addressing. Signed-off-by: Stefan Wahren Signed-off-by: Andrea della Porta --- arch/arm/boot/dts/broadcom/bcm2711.dtsi | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/arm/boot/dts/broadcom/bcm2711.dtsi b/arch/arm/boot/dts/broadcom/bcm2711.dtsi index 22c7f1561344..d98e3cf0c569 100644 --- a/arch/arm/boot/dts/broadcom/bcm2711.dtsi +++ b/arch/arm/boot/dts/broadcom/bcm2711.dtsi @@ -552,6 +552,22 @@ scb { ranges = <0x0 0x7c000000 0x0 0xfc000000 0x03800000>, <0x6 0x00000000 0x6 0x00000000 0x40000000>; + dma40: dma-controller@7e007b00 { + compatible = "brcm,bcm2711-dma"; + reg = <0x0 0x7e007b00 0x400>; + interrupts = , /* dma4 11 */ + , /* dma4 12 */ + , /* dma4 13 */ + ; /* dma4 14 */ + interrupt-names = "dma11", + "dma12", + "dma13", + "dma14"; + #dma-cells = <1>; + /* The VPU firmware uses DMA channel 11 for VCHIQ */ + brcm,dma-channel-mask = <0x7000>; + }; + pcie0: pcie@7d500000 { compatible = "brcm,bcm2711-pcie"; reg = <0x0 0x7d500000 0x9310>;