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: 13591434 Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A92A045022 for ; Wed, 13 Mar 2024 14:08:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338932; cv=none; b=Cc7bkLldnYI3+TysZKO9Q6aBYPSS3oGWNdb1mVnIiMKLNTEcP9rz5WFGkVxSzR3vbIzJcO64B+YkOdaD8o28qEi9YL2fNvQ2xeuztpha1sx5rVC111fqC3IFALuGFS775p9kL3+Z9VSa7z3pHk89C74w2TTnmVdO9BmVNIT6QwI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338932; c=relaxed/simple; bh=TiV/x+MwIO7f4UmnRKt0r41hVI84TqUvspuBnnt5QWk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KzRhy/Ro7nBg3jbF5MCeKsYBD8/kr5jziL1qn920B1uVlZr0kG/kJGmyo0zJTDNZ+BvH7yujgDEknru2kJqLPbIm3yk53lvcpqmqjqhvkfMGNXETwk8Epbe2d1qIq3zBgUv0tbRDt7oFZBNvZ7Kr8EjwFWcAVXm4ZrzL2sseaOs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=PSoErHgR; arc=none smtp.client-ip=209.85.218.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="PSoErHgR" Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-a44665605f3so926208166b.2 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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DCjY7yma+RGAhMTh4u8gj7GTqPRw3rlJG0cUBmglS1Q=; b=PSoErHgRquG1TaVd3zofyHG2xgdk6ql+NlCYCN7r9W/Po7T48X3x3oyZYCX7d0HPKX a5a8yGAWvQgd0gJ9ItccnB8fSBAm4+7NP48TqAe6IKtvw9K3djJE+foTvIjKtXtyYscZ rVLXNh6Bbmag08XcfkOC66HLRofXiI3egEQZ2V/3dJajXW2BlvdsIpePXTeUNESB2zRk CiNIYqK11258EwIDiwsr4CEqJ6NGbALwMMqYJHTlByE6lWe2jpnTK9y7hBnELs3bu+K7 pXpEuEHs/K3OXrdmIV4/YbEV9krX4/ixuQyzbNlVNJSJdvVcQ0B5MnQoTJ9RKaCka9GI NPGA== 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=iuqtRG4TLw5ATMzmMCsbG3P8nQzY1x3mj9ik5MrPcy21Q5Fj1qYzFTIqqph4knddIw sSws7+mq2KXzKkqPMpcqevOYqELUXavjGQw66mq5Op2862n9b0BykN5SnGKV1AkkelE9 KZ2cfV7aol0gcQjsaSg4DZJkYyHDN+eprbQbQGAZayooxmoqcIFexXzZXZft7mjlPClY j9hgc0iu0KXc7pwJzFxWMCXvdnaKXXrcmoYe9HNN9b2bw+DFJYTksr9+7oPRoXhOZ4IH EH3V3g018oYswcBNO57TnUpFPv3F+0Spz+WN42ftskXt0SiZlWnisTB48moqSecwYl8c jYDg== X-Forwarded-Encrypted: i=1; AJvYcCWEgPawg9ryACZJZW8giM6HQNfHf+3bdJIoAWvqqjEQC4RGjG6MIIf0dKaj1QmBZHdnnbsq4ufqltB1vi1RLKb3p0GSM4deOtyt X-Gm-Message-State: AOJu0Yw7P1te/ttf0vH03UssBXHwiCVnMxzqnJNVou64StuKTbdM/8b2 i3A6hM35mARpkOOKTeOmSpzavgcSGk5jgp4aj5agzewEyv64MJoz6Tm+6/w3quM= 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: Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13591435 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 636FF45BE6 for ; Wed, 13 Mar 2024 14:08:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338933; cv=none; b=DrGpru+CU5Ss4rEXR6/OLophNQeiqnGb2u1E/1USL8PsZ/tKGYJles4FCGR0jM38ByIIl2T8A1j1ZzUYemU9kwPXlYsmP4CP99KmEypXzZsiSsWpUjTU4MgdEYnQC5uPQcCLcoz87XFJQeFy/y873+bDvDoq2kd5DZ1oZ+9lXrI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338933; c=relaxed/simple; bh=jjis7xsIFrLu1sl29w85XAmU74ruhJPA4C3PFk6UMzg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LKv4DyYg7pHBIzWXOTBJnSkwpivdKJvI7EElfUGRbV3+zkYEy8mI/8Kq7u2RbGeO/Kj+/jY4Wk91NY9MbURpAv6D3Gppj2zHWzvk/Av4EQOJ7YxWshzR/blPWMdk0siUY3eSWFczm050Hf5+pfAMQto8fqxBY5Jmb1PGiq62tnQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=NuC5oEb8; arc=none smtp.client-ip=209.85.208.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="NuC5oEb8" Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-56847d9b002so5679293a12.1 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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1+qHX7SxjysW+WBJacqKls7OusP1dBurz/GxAdGzZn4=; b=NuC5oEb8vzIMVS7FoXIilQf3/9z7y+Wul5g9pUQVPsZd9lxh4GMS9TB3VT3TQd1rJh 7rgjNPrmoRhOjMiZPjFpDvCA9y1HA2I0Esc9bqSzgJFSYpqSR9sreANzEsfXQ83MnClq DIBcIKcptvzlKzE1M5dCPm/+CHbHEe9cRh1BA0evQ45Tn2DPQMXIysrU8J9Rm4dL9xHi vE9KNa2D14rr9LSlcMPzj9G4jjQ8eKeWcHCMqS9yPIKaysFa+9swh5n3PZTTETatd3ER 1IkzPTxioeYUr/uw2hc7m+5DRHe6luqBzgxVCN0Vx9mQnmPNITc904h7HyzdgZCx4ePg qbpw== 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=T7cZAQ/hfwmUcIUxakcWH720BPgJ4jUeHGSnuA5opf0sOCpfTSKHhT5X2V29+RXOk8 eT/pm0tlw/wuZ3kHGHji7hAJq6aw3m2V6TWAz4XWDlN3rPaYRbiP3WZlIWe4F8ACUFr+ fTPlaQqQHIPH1e6D018xFO/Lfrbq2TaWGTN6YILJ1WktGmoFODEHM7SBsZe3R4uRaQjx WeJtqAI9pvUTISdotDkOyvaTX76E2mYgS9dJzOOHqDcbgiDshKyLtw65X4pf7pDuhHHO 6VKMcuH00HLI/2HCE+CmUgqTd39SQhxXpFYFA15i9/Bx8nwnTP2yaX20/UmalpAiZiOx A4qQ== X-Forwarded-Encrypted: i=1; AJvYcCVIbvt8osuOa4skbnTY7I/X9dHVLtKNqbfBt6dpCn7zCQ6dnl4qJ4dDUr6s34sgfokiEzn569XL2hIfKEDJY0WRTRH4FEQVQNPk X-Gm-Message-State: AOJu0YzfSadDp01aF2+nNhWfUFeYzjEAUixNBjJdUUXI4M69+a6MiY5+ IOqI1pGd82W2RKsJ7Gddl9vrYtF5ene7ACDriHZtvGHjv2npQ155TuRJ6EAHW0M= 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: Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13591436 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB47246447 for ; Wed, 13 Mar 2024 14:08:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338934; cv=none; b=IzWxD8m80sf85l9XLAcaj4ko9w6vrMxgCMF6X05ETRIo79UaKoqdjLNcloZWaES8dxT9IunCO+IG6sYylvmpDvPhJXnwcdcEvST9FccNpgHKRL0rtC53VKFCy3QueG14bPBUF/bb5SfEu4iJj5ZDZht/i+L3VnC6jrGweI5yIOU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338934; c=relaxed/simple; bh=VoefusMX7Ytod/wgz/c8WF/mjN+oMfRNOX8FE9P8irY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UlbRmdOemLiAzZckFHJ/oYXtv1ZayDvLUC97exzoA3uJjXU/KbpW1BmEbWu5Fmilyf3dnQlwWBNmt8uw/ENcXVBbzYqYemu9BaPof+p5BIhOeYfbUPHqDelcVWn/jP4gG1pN7azl3M/B1S3GBlsNe+pyZZoCqNWoA3Edq9Bq8k8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=ClGAc5JM; arc=none smtp.client-ip=209.85.218.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="ClGAc5JM" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a3122b70439so858814666b.3 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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7L2vUwfipr2gKOB26ZSV+Vf7Bi2o+2MhICmn4R7KPa0=; b=ClGAc5JMtY+aNJ6AxXFoanQBROAcg5+EYNSdibz3tFRSsRX1eyWyKcr+Fdp6HvxaXA a4Cyw5tVrzOlNXHvOQ8dv0z2gcF2/TRyMXSNE5HItLqwN6eF4wLz1Z+iY+1aY2NQh3bm S2q2I4Vjd06r4cP5Dp3zVVan+9AFJL6ZBLph8iXl+ZUlf07c1U4Dkn/yKmgHQLoh5HFk caFnJ07eZqF3DnAMAv54oFYvx7fGijrqgjEOBw7RPUoJPiwVlRyE+Gn1zv/sh1NZ9L2D SbrpliJnU2u8Y2AM/bae/9pXWmWnCLZq3JecfQfHSViV8g6En4MsnjW2Y6b8D4Lpcufd D7Kg== 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=nl9iYAswLJjJJVCZZq1ThDfqECuFYa8bs+55xCiXB/ahm+4gwX/JTRBQFAVClcUbZv Jwdo8ehw58w6eM8mjafbCqjpYDyZw1yn/uURaW9cxsL1pXa0seWvqldpRTx69dbCqH69 tmKncdCvm4c5XrBVOxQ1lakQG7sNw4g2Tsn106pn+aahQQIOWO+h213kh81LCtlTcEor Hmt47dWLL3lu0xGtOPRoJyKTbf6EuuRPy2JOudzsng1xQJNhMxfcoYj6sYeH183jQeRr J3Ds8f1JZVZS9Ucjlp/WneJEhTtDAvi6ARJW/+mqVQJ6WUy48PVKAZfyhXTJ45t8DEc1 fc8A== X-Forwarded-Encrypted: i=1; AJvYcCXFjuN7QURfN9+iyfzNSngPE/2hloP2THtbZP7bMf1mnVruduLsl9N8WGv3LFFbLMb/xaySGDyl9KKR/he1KWtpTJpedWXSyEaL X-Gm-Message-State: AOJu0YwPOivPeG5RpkaMxZvwSAk25NDpZpQMJAzDPxw7J3xsykyvE7Op UvL/WHmzF5gGQwJ8ykMKmbq1JHCgXqv7qBxDZP3gZil6IoCW7tj19QdPdkfbZ4g= 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: Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13591437 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6AEB347773 for ; Wed, 13 Mar 2024 14:08:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338936; cv=none; b=C8wd1HjMhmHPfm2CV5nC+VxWON+XK7p054PoRyKT7I3LdGPCGJpiSilU0Z2yR3BbOdmuCmtBc21JNzPW5nq40jr4ll8NzPDyiCLw1lDkegKcQKDbafihxgr5+UymRH0d+QJ7qpLvZqvMjlDkDD2pDo0QNLnZS6pHgtrm2EEWXw8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338936; c=relaxed/simple; bh=mJw+46Z541uz+efuQnIUyj6yNxXFxaa2MsAksiuK++o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a7UHngd3PdXVdQ6KbF1CIeqsXqBS0qW9OoV/JVEETzpLFaC+dt2vAwuWeLoaZ8pA4U4b2U7apNVedaGeAre5VuDFu/tDy9vn2MDy/m3woFh8wZDLcyWIPZh4kiwZUXUNKawIb6cVvtAji/omPhdHcpuieaFF8fSL6SUKj9R0WI4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=fF3e3cVY; arc=none smtp.client-ip=209.85.208.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="fF3e3cVY" Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-5684c3313cdso4681152a12.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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=I53kioFtQ9+NV3RahDpOPJUiNDTHamWrrm2d7gZ/rPs=; b=fF3e3cVY1Tu1XDBdM+Sqb/7j2yk4JeLRfz9BvbG5RGklo2y/TfQ0WZqczQR0zte0AX ZBF455QUcH+OfFSoBTCYsH8a+FL4CVGh7d3oeBiJcc0pu0+noYXBVHMMm4ity1uQw/m1 3ly0pgVnen51TbUXzOZspC93n3LMPB4kmGEQdQqiVJ2FikCh1Sm10cWxgmm6X59amc5g ke27mhk9eNlfyaVM+39C4xYkY9nMQeMfv5Xr4AX+W8fUzNuinypSeTAU3ZklmOEGQuZr SXmlbEd4SDw/4Nr+3/eA/DgOVnsdVQVU+hdrFmB7TDcfyMV6HQEOQH0fPcdJzgJb+UUy UVfQ== 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=SxZGN4+1eO8L1xRo8md8/lkvRzfMzThPP5OkmRw3U5AVWcwSdDyj3qqTEyAwvj8bJM 5iQaoBAuwgB9/2+bGTFQ8IqLXj90ti8y3BEMuSQX1KPOcsxLYgzmgA5md0VwbYmFoAyY MsSBW6H0cNT1CAlCs6lllOlsyiDtlv3bh0Az6EhqANlj1UKdMcdP8/Yb9BV939J4Cd2e HPmlAeK9ObtJkXxzrtixUO5UGdbyWkAQXJORjngH0QOXRfgc8XfapfGwozcu0MWlQ8I5 Du5yc07UT4FZb1uDUXaDGgT0uxe633EeA8OSddd/Mpc6VpnTjoJXFx5s4GbqJ+c7pnt1 en7g== X-Forwarded-Encrypted: i=1; AJvYcCV4d8AQFRa+M30oSOdqSkpL4UCq1PO61oj4jEaGuQ7MUuGUBc9KWfhl8jdGbGpqN2K+sbQjqdoZ0KvB+r4m7Z5haWkz/UGrvWJE X-Gm-Message-State: AOJu0YwBM2DYSH7rM4A5W9C+TgthWaj7rqzEuD7aKXDdbRtCIMc90s5S CFaAmgBY4LzW6UxmxmWOB4zoJAMdUUlU8gRvVTKMjTLzOBHomSnZaXbo4hnJ4+A= 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: Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13591439 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5DD847A6B for ; Wed, 13 Mar 2024 14:08:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338940; cv=none; b=nWFmjovgfGOX7ACY+7WbJc4XU6jOXIZczQuljpWuf7uxgJgsk5kzIOxet1nq2hp0EDXe8VP/J0YwB5mr1h911oIdvk+kzRee/SIqzjWoN1tE0h5r/A6W7obn14N4CFdiGGJJziYSuZgeCQ1pCDXInxF+EQ51hpiV/R4egtBLb3Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338940; c=relaxed/simple; bh=Ynq2F2bMfhoLu2FW/bFjh5jnZcIj/QLxPgEvfGRr8J8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lUc/A+0LgQLXVnYaIdxXE1CcCqJ9JmmboRTVKGHLbPzmf8M1A6YRltoSgiTzOrZialAtYhru6lnv6tEaFfYWsNI3ZppyqiTd/UtwClfdH0jKl+m13IfT2S+t4wtg/V9i1cX2FNOXLD2FVZgEndLfUmmmhISuIYoDeaytlKp2NOg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=II4BFqX6; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="II4BFqX6" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a3fb8b0b7acso626119666b.2 for ; Wed, 13 Mar 2024 07:08:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1710338934; x=1710943734; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Cdk6dXpjlqfTsKeP/epQp+Lh/qATka/VT0PX0aJnoDc=; b=II4BFqX6+9qRW3LXpSuY8OgyNOWSMxaskfDkKvhoUsHAoz4c9fhNL9ZfTJHSP30mIU /wjYWHsuNYpUFNnJZxwYb78t1u7gZwItTnIx+tZTlx9xQdyMfRd6JAihjFfvTe19Cj1E Qr40/QcJsEKxTZWh3rgcQKwSZ8Hug0ie9EVKrrTFVkDMLS85Pykf/BKaXIu6dbVvtJ27 U/cL/2fAn0BCwG0ez5rf6MD4YM8dhXWnQw8GUhFo0z+v8MYt8vBzQfUnm8Rae1gmUxwy qtI1Sj9Q6NMqrsVloXTA2HJzFvgiJoEPJYOe6jXnRFSaQCTH0gpMClQmt8aF8Fw+UTCG +pyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710338934; x=1710943734; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Cdk6dXpjlqfTsKeP/epQp+Lh/qATka/VT0PX0aJnoDc=; b=XqN//saG0Znxwhf8lrP7mNYf1Yg4Aw+mfnJs4zcNBvNXiwrLlIKqwmNtnBJPJPA3mK GL3QoHYltA7kqrYyZoLvfUuRbLq8kqnl9XdNNEUIo7VyLMq7lv9SnhP41bCtelWmVys7 LmFQBVN+4Gh0Mm20PnhTg+J7sVU407e9ltw7PVTtoOaXNxgoxRVovv3AwzWdAYq7TXyu tLpRi64UFDLp36coGGKs1RrU+/cwiymYf6vvW9GO7ZVogdTL1ZfUh7BqpHih/0S4pew5 evgLyo67/dK/NPFDqieQwBg4zJo76h7g7hBNaYJN4t4/Csygkc0JgOeZj663qwtsA+iu 2bHg== X-Forwarded-Encrypted: i=1; AJvYcCUgojpv+yzpk8WoOa6YQD5a+Xjj3XtdTbcgRr5O8c+CgyXH+UpKYxKiiUXwXEVa03T8SCI92+fG1z0M+BCbS/XVBykJHw4yieHx X-Gm-Message-State: AOJu0YyKj/dHXPcckRDYR3AJ5iH0eH6CnwmLLJiIVUKYkyxlRgpslxkJ DXU5jH8u5ZKFDGcBG3QQADHBm61/t5eMEeB74HY1x9C/ywHRNy2tf6uuhj7Jwf8= 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: Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13591438 Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DF8A482D3 for ; Wed, 13 Mar 2024 14:08:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338939; cv=none; b=pPLkKIqRevjmG2bhqjohSFiEN3Czxc3VbEnfEiv68fiSQvjLkVLuGb+AS+SdmqNj0qEz44Lj6eyboT29kNZH1QY/Nm0Wr/5fQKoTskLvkEOwj+1hKj6jETLIwhk7JPMDXMIOxZweE1Q0jW8XyGjiq1LUN9Rww8HD46XHoFGcSps= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338939; c=relaxed/simple; bh=xti/oKwQScDc9qv8BINO2ll3pJ6JN65BhusLnK1Mk28=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DSpM0RiTZP/gM4PV1FWn1+nmznd6uobAyBakN6CCVSb60JGCy/Q8OVO6pb2BBjec/iQxF7NTzI30qnUHy7NBYmVK+m+HgxmT5mZLUuEesqurJ1Y+ipOGg/rLgnRRSv1vnYycXdHtLHhvbUpEOsUmGUuNcKFKNg2xWE9MF5YbDIo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=ObjMiWsP; arc=none smtp.client-ip=209.85.218.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="ObjMiWsP" Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a46644fee93so59343366b.2 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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sxhFutbq+Y+6CXRWNL6/WkO0dcfzVUrgph3wJP5gbgo=; b=ObjMiWsPaucYxmbdOMzrpFDWzzoqeFdz1nl8qMn0KCwwZ8AFyg6ncUmYmzNV1IUnoA YnO9ni+W1BdgbXVTSW2XUBGrUMAqwj8SnY3ta2IgEBtPfgP8JHrbuK2uMiNj/yXBLNwA GgtMPVtzrHL/2kLsMYXwdUeKddxxqjkwVvbWap5zeZv3I4IwBjXUQ+Qr0QizrbD/YiJO jtZMomOESuwR/ZYrUG+IJdALR+t8DkV9ezds3j6MlCtjkmwPvls3o0QAWsfXoju3VZNi SsTl6upO+BVLAKsxmmGEGSXs5h5ln47zNqnZIOwnKqAL/aDO6zoSzuKiwYYJKwuU0LHG xsrA== 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=Yn2c5FgHM4pTm1VRLD9tPkw//LgBKexnuZdEwlPmIzaf/PCudcVRgKqPEfG9WHMbNR BEOI81KNfVLY+l3N6RtznNT1fhAXLl6klV9Zh79Bhw5E1h0LzOQ6wsyhwH08f8Z1STdV p+Rsbxg7K2FgA2SH+M4zh9BGUHQQaBovxhiZDHmGnshaQqJ8/XPHDz6E29rE0wTGxB92 2/pSUwWoBMAg2/gOXEeLOWx6ofGr8nolEGCaC3k/xAJ3yd6v3k1hQoTLwq6X3pg/JnuP 0UfcOPyAupLR3E/xE8QAPeLOrcMZf2Yqp3q+Yppt8T1BWH8WOzLMNZioEbQXExjMfniU wr5Q== X-Forwarded-Encrypted: i=1; AJvYcCW3lQLOiCit1HxfVQsriZOeYbPwD5fdAkj0m5yejBi9r1a7/gMe5Iik6ubxHh8shBD5GNCxNHvgdhmRu+DTLvvblt/5L2f5mIyE X-Gm-Message-State: AOJu0YzmbHVHmCrbRsoQJ4h2736FKRDc0cIwjE52Gn4ZDMaUr/g2w2ml iquRfAeJj+n7PTQK+9uSvGCAEJ46QHKqaGoO6G7v8tOlVJcSDXEkG/HRe9OKPVM= 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: Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13591440 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F6894B5A6 for ; Wed, 13 Mar 2024 14:08:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338941; cv=none; b=sBmCANvjxUsfjSa7rUfglALIm7jngRoUfi3apluXzAxtMfRuAxqUPg97+t9DcScn+PQUObNOC/3gByUDfVUpMj+9uxyZklnqVfBRdcekOIZD1caoSrMaOt3Zwh44waIwVSdaGYX3QqyX7aKlGqqlUl8K/+P1YgHVn35hrehzCrU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338941; c=relaxed/simple; bh=Q1WIk6CPB8+nC5PxADAz/f8d11T7ZlVqHzr3q9+xO00=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gm9lCNd1JpepsVcTKRpoTeQe5X8PskD9q+LzF3aSM2sWvcrU1IUBSy3eQHexXw7dZpWlZulJeq6U+w9soxcmJaQUqwuRL6LdgGS0055SlTjb+so95YzEkiTlseyTb6w6LHeRrkxSQhpfN0p3dSM/K278LjEqMPWZKPM5X74PDjY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=eJ6yNPuH; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="eJ6yNPuH" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a45bb2a9c20so130411466b.0 for ; Wed, 13 Mar 2024 07:08:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1710338937; x=1710943737; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3F4XzmOcl2eqQO65zKyWh9Neo+d3tuBvcb7/Ztq+tSY=; b=eJ6yNPuHNnWgZvjI2kfaGwKTrkeohWo2z1XUchPP0f+A3fGLiceAdsu2AwPBgXp7Wt TMeAlW+E9bEnETEu3Wqgq8x6CxexelTv5ru14h6soOWIbwfhn1V0Nu93JiHgOGBFzbmR SHK7CXByXVXFxrnS3vwXLc3TWLHo8UAZzCGMJVN7dAAt8PsAoQ/j5UxMy2gSIRdN8vix USt+TVN1JuWfr9uKd+IHCgKlbz6+3EQeRs6ym4xfJDnk36cue0/Sa4H/X8Jz3VmsTRfu y7Zvgo/4NBtrqAK/Si8Ettjj3EUC4q2tp7UaU8pkudM/OboAxBxIRDOot3OGHnLhvPf2 e7jQ== 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=d0iznAxxs6LA6zqywfjc45XFFGCRFmzXbL61V7pAYmY1urxlvrgKZFlyQmoz9W824U t8ucC7ZvadqTPCK210wGqjfzTzXvPnbfjVowVn/hz+aaFKnYNLgMKcWaJ9M/BxDmVJmw 5XvnaRmLnYRx+pjO81HYwjcfYo+kPRE1AR9aT7+Mp0WHmqyCm9NigGaUDBp7/bPLPgFu ticFFZ64QqZmY48pV4S9CaOfk7B5J1byNVuFcm1ust6Fpv7wRkm23N5+iApWW6CIusPh qWMTmXzDwz6GHszkKMSEPIR+1UtWzX+j++J7ZJC1HSDxPigXFHjrndhQQgjvTTpWl2Q7 Xt0A== X-Forwarded-Encrypted: i=1; AJvYcCVBzcFUhkE9Fczp8jh8MovtbmxXqX/mavgsDVxeTVl8t0US54KqWJAtNMCS0lR7lh83+6XTSQCGYkUVNyc8bhReS3tV9or/LQ8Q X-Gm-Message-State: AOJu0Ywo0sK1kHWJWcIgUkddFJvnPkbZg0gp8pUZGQeWAuwOLch7HhwA dPKuoaSxd6f7Jb7gUVBPYxneXvKe3NSReNSZGGHmCDDq5ENT92DGc8HRchhr4rY= 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: Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13591441 Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 998E54CB55 for ; Wed, 13 Mar 2024 14:09:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338942; cv=none; b=Mzu2RawhvsVXEIMpBUfh5JLcLZKWC4HQb81Ef8xY7QdMPRwBbVzz9WoB7cvf1SuuzIVAsJmthCHZrQLEl3Wqa9r6GLLfJgL+ZOJDsaEH5KwGPpMRb5P1ejf2S7FCwZFlp5X06RlHAZ/hi5+mhkIJnyv7cxXiNmwGkHTq8N6wJPw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338942; c=relaxed/simple; bh=4andNj366bp0pW3FwTiCNyJleT43bWmvqce9qbK9mVQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m5mSswbqjxno8DFEfyLgu1mz3i/YNSglbseAaZqidzKuQj21yBlrnbQ+5d0dhurWk3y/TkHQp3C6ID0oWPHJ0j49XQfM+4jReJnmCu4e092G0ORQ0GtuhCR5uUNXzohK1zH/dCs69t5ItwXdWT/r2KU+2SQB6ERm1VLew4e+vrQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=fKI9P0R6; arc=none smtp.client-ip=209.85.208.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="fKI9P0R6" Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2d46c44dcc0so9188021fa.2 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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/xE94iw3mEagAF+/7KUdjRC+1ga8rdDd3hiFvVOScHQ=; b=fKI9P0R6HbzhTRBfyWlx5THtNo7ELRPAK/a88LLFRYZmsfEDx2PUiatvESQw5U7H+P yyNSmvR7L14DcuLoqNxh51YH4yAShqmcgRFn7bkZlx1QrD0xJIphGLo075pZPMHRmJHJ UVUKyFGV4YFTX3tzRw3b6D6ABxQhYotEdNGmhXXM+FcQMsFABaeBH6vCRr+WduZ+jkKU JNhtN8u9xYle5GxScd2MJwZmv+md15fsts636/J1g7pCgkSHOz1YAgmt8GJpOMxvUTfE tZEFlPi1qGaNdmBk5k12DVb8GPEEtW8BMDZuXaD119bAMd9ZpioO2gpXhNQEY5ryAXl8 BVZQ== 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=q+zZeRNmuwIJNgXdtumMmlfzKXjFHYBYVhLBYC1zrI1ViEtjOwXI9S2Qi8BZpi3z/5 UsO3NYvqm44PYq5ivsdvCCyjt4B9lHzgVVPJKX2fclMD4Ne7SFeMMjD5Dq7uia60MHDV 9QarCYyzWX8Qa+QrUAOwhbnrWf3307V8Y2QfYg6rV4SbYcchlo6ymf+ODHj/mHtkJ33e 0TUAvrU4aKQVZDIW5JJyoiJI5ynjJpwIysNPKpEQRJAMllveiFSgHMFEhQdDy56ICJfn J8EwNtYTVGbTGDdASGb2ioOFE3AnB8WT8PnWhr9qeDCSAJ3CG4Va0iD3VlIqXM+aGpjT P5eA== X-Forwarded-Encrypted: i=1; AJvYcCWReYPZyciR4ST40s0sVOSxwjZAt5OHjs7ZtioEdHNXIO2iV1Ufm8f8AEGQUpEGTKqpQilSXRctAgXikVxV/QhMLIaUECNUJ9ap X-Gm-Message-State: AOJu0Yz6bL7cQXlSkb6Nq2Jxexuog6ZdJpDY2bC5XTiBnwNvv71vbSUY fAn81UCqt4t+PSVgFu8x2yZqcsXsEfgh8Y4W6RXqCYeBBv3JSimHHetdeH+wko0= 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: Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13591442 Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D4734BAA6 for ; Wed, 13 Mar 2024 14:09:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338943; cv=none; b=E8TjMELk4g1W7CpwfIQq8h/7RkgxK2DBnOhXd9m/94X7DVGkYGpJgguh//qH8URN3E8HnjDYmyNdtcfV6gM9MYjNj4iW7bnt1elofJ0hVfA4e442fLGr+2twpfsfr0jsF9ci1+Us03ZQ+dRPThEQR7iHtjrpvoX+faCpbCXaBYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338943; c=relaxed/simple; bh=cxjZSR8LRDYJ/W/QF37SUMynPidomrXSkI+hkRn0XJk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dfFP5MB21SH6XrgymHq4oXHv2hBOZgqItVDb2AQ1jNyNYzKF7MqueVi8zphc7Gtr3NEtDfhNe1aEBZNXgd8MrHnwT0D1rK8VBL6e0ApN2Xgv58fMLs46Na0f00UHaMKk/tto1xf6zwHU8KvapCHPHdkJnLW05/EzCPdgAGmtKS0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=CPdAylgc; arc=none smtp.client-ip=209.85.218.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="CPdAylgc" Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a44f2d894b7so140309766b.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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2aA326qloufGfA/9FJeIrf9CjXOtqN0+M89y+6rWqCo=; b=CPdAylgchuHZicfW3zJDNEgvIO3Z4iq+PaefWzT5AfmAnMWOP70oHgXi8J2rSqC6Xy LOkp22dpQhEmSCs0Dl+CYVZWQ2NHMIHZbJT8TsH7pEFIWR2ixgTO2bk1eKe6fMeYu/2i TIi+sAocolWuiVLCVD86rvJKm+ZxWtyiGNq2oTyxIqH/yo2vMI4rY5GsFzTLtbkWIsfd fS72wQGVgv7Pbk2As6TEf2+XPZvElAtSggs+vxXc1oHFzG9azCwBLbOzorc7vd5g3aVh GaQiC98UCZ4wwXnjopvQaKJ/8jc9Wif3eUsXu35u7vROZzfQCsUDoQ1n6BLWs6Nv6hC9 dqVg== 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=mbG4JH1flk7lirYu2/TDY7qLBeIdh+HDdF1WYohxouSGzpwOBglJozoAN7sKh5IboT bcYdvAHFNym2ZcHCkzPgco7qXz1cAn+9BJaqa/Wlcsyzf8z7RuOWewv8o1Sry+ZU9z27 ooyHwsCZr3+hVDgJUJdfguBrh9f1U9pNZGVRaWBInkprVoISbaIIEKWehtVfvGfTnys4 YroxGtw2+OMJWnDCTnhcQyVTy4fiSrOtHCWCDCEjuNnN2EC1qD10e2bd81NxRG7fHxm3 0NUyye28FRN27U+NPKov5vr7nQYjD5vrVdm9+axUWWIwtsMVKtdxX5czh89XCKEcm1gz Fz7w== X-Forwarded-Encrypted: i=1; AJvYcCV0iUPbalkMixNFhE4mXn0AwiAspozgtEXS+7vZ+QtBsY0QMT2/c/Tia6F4MijXTLV2Q3rAWw0zS6SmbryMaFEbXPwq/7LMxeik X-Gm-Message-State: AOJu0YyEzYUJW8ibaUhP/mC7maN73E/rDnn5vi16w4NrA9e8UvzQJ+Gi 6SEXXaWyxSGhYldQjTHI9alwD7rtx/CibRyU2Fnlpexzjm2W6TR7eCn4B/NWszg= 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: Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13591443 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF03F4DA05 for ; Wed, 13 Mar 2024 14:09:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338945; cv=none; b=FlX1GvkYRjpWSwxJ6Qqvs+38epCV/apS0XNxcjMPMu3egiRkzR/dY5zZegN8GeLZRPSiLua60EJ/h6bd7pKIdX8qxfx0XzkLYluGxIkBKg3veyQN/YtYZmwnxaqya6cV7mFP5dRFpMLNViR+ruryFaAZVdoCnW0qrFDtFBS8qdM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338945; c=relaxed/simple; bh=vIs76kYyjwJXw/ha/aHUzP99GhVmGXrKseYwAg7s1m4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ND2JZIIamy+2jBXHFdK8tWwxfRIxJQ0J3F+28I+DtpfZi29yW0xkP3yVsZz9Fe5BypIFnVEBnEu0mU5izD/lQBajvF45qHzIYqmmaZV8ss9K98/Oc+x6a036Jgbl8g86RVZc/dBDeUNJwSE5HVRFzs5FX08RpCrRqhyotJ/vbjw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=QCikcQLC; arc=none smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="QCikcQLC" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a45c006ab82so145164866b.3 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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aQCAxLcWayDk9E0aIZHof0VU6EySMCm0kMz7fVOHPV4=; b=QCikcQLCd2a5sr8cgtxc8d0dPTECENlYFLNq0EqvKr2awLoEV+/6TJ4dhDHowbr6O8 EJWNnBMI7AlFaw9SrnSgQ7tBfn74wr3KVdgZ5Z9MXgwUpapNpzLr770aoLgW6WOXmtTH hohwDCLp/wfq56g42jRtplc6QgO0JeYGQY8fpB4FYzteo5Kp89Wmq7w+71gGaHlY5RDt Wvhv8D7GHX4pkRgut1BOSqjVYeorAveGa5UHGbBSk1sCl2VkqngsYfw9ysV3a36Wg5P9 Y0KsJRSZH2EKFfqEmyk2keF1JdngdWjqFGN4WTTmsGPp9OWbFEgD80+yXeOmkSoEO3Uk UnaA== 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=TqTuKwrks/DdRmCpZkYKNuX/qHi8nnrpL64DfdqwLUEsgqKq21GDgjyWNgBudnUn8y fRoB3KSLvrqx9ylPZRToQ2SSkrjA3UTbzrIlai0uyS6KWBAG4AYfXiAko+wrO9peWQSI 3BKPSDl/ErsQECUltdxYiQO4AuG9eTg8epCo4ieUrBapNFyimAWlyEZi2LvyTX1mN1Yv iznZl4qrC1r5LMV7CRDashBAJbuq3mgYoexyHYYexmUw4FwJDTUle3aiY1rTv7sHpsIF OG+kRiJPn3R7qHAcD5nCSsKrBB4d4IaC4cG62uWwXP0o/lfPX3QO4jNpnhTl9et1G8fc KWew== X-Forwarded-Encrypted: i=1; AJvYcCU2YaoVmkbdkOlfHHPpU4rF3IeFwqTXeW3lPEoci9p0hM4PD5si077y3MdSwhjuhVZ17LlzUvrqQILP3yfw03L5WjmKeDkRzF0j X-Gm-Message-State: AOJu0YzqHkxh+jHnZxM1zrRDuD8BP0i+1SLWbg8bm+svBGMxLw4vF33v mO4ycFAqhoBXxKSfEdIsmRUMhJk7QOBcrTYuR8Fq8Dz62HG8/n2UqVyg/QeOHqI= 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: Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13591444 Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0447350255 for ; Wed, 13 Mar 2024 14:09:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338946; cv=none; b=lxRxmo+MgKHH18vK18Z53nqjJGvi3TG/3lutws1v9uEE9YqMIqNej3/FP4TVs1E5OHvF8CMBgpBqJFdfATRhj3/2D7GExKQNI0nNsK0kQpds4389Zv2Xo4caUG5tc02Y+FkkbC71cHoN+SwH6OELzzzF9HSI24vZ98w2rxhc7B8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338946; c=relaxed/simple; bh=9UBZzqJurtY0u7fZf0OUMVFrBl93Pr0uetCSdgjkIi4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IZFkUdoirAW0/hYwf8MVIQt7gz1jDFlMpfi8cIJ7TOpV6R7sKg6d+GLcSRjrG0YXei+lUsZB/NMrEm/NZIGEHj8gVBG0g4mevnQcywRIHu7nUW43dgErWSXj831ygfL4fJrrPvOAvW69GRuUogSGlHGvAYWdy2QEIg80qHWS/3I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=Yskxdo81; arc=none smtp.client-ip=209.85.218.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="Yskxdo81" Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-a4645485da6so262789966b.1 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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9F0Go8/yyuHye8yt6k5vc23oD+JipLNS/6TGYAxgmkY=; b=Yskxdo814Hx6Vpcvz0DpKkotdDA+kf3atgPONI2J3Gjpw+739QTFta39h/RfsdMRsv iscEMGZpHulS+xOgpLSwbgC7adw/3KcREq6ATsFJV2TgHRuEhNgD4LvO52lIyra1AQ9B F958Fs2Yo9JB/KlMrKWugdNyDh4SsTbtpqdRuGpCXvTCfHmarhcn4NNhi92IwS9OrXA5 9rGX2VJ+suIEa84uAu80FkwAJuXLzlS0dl+N+KfrNU7W8MBCc4CodaqKhkUwdBKT4A1l enD0KjzFSk6Kl31Zi/PBTacJ9Ss4ShZGEvZY8G9XKpcQIkfjI+jn0/AL0tvoVrjCL5P8 dMHg== 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=gFNLsuVUSlbI20LQwuj52dfLpsk9MjXbbMiw2LOojVIVB6+CSgW6QFC6TXckJqwJro Lnh+uNGE9txTCjOgVh7tAOf3xwd48udzEf7bQTUTZff01o85LFUHkusewnCY1CTW3TJz JJTRUgAxsIEXxna6pPGQqz9XZSFeoYLMWTzEDfWlPc7qC1ivk9ywer7/hmuLrGLMu0af WrUxYV3eK9AKuHoM6Gc0HTjE8nFm/JayKZhP1H60bFITBid8xLpNx2UGNCK/ioQFXbs3 c+vmP40P9v89nhlinOAXlbDmh94qiU/7kVRWg/c+ghq/pp/EzXzufB5TAWqjE83oVp1F rn/g== X-Forwarded-Encrypted: i=1; AJvYcCXXd4u5H0DK/e88XICYdNVfZsDZ8M7Qoq9DYbiGNl0Gc7cgXOBY0vhEGc5g9Wc250APqbt5lwj7BRXD+Eym9tYs2M1Nolk/YANf X-Gm-Message-State: AOJu0Yw1nyXmz+n6DHlLFcOVf4TSmMQV2nVeKyl4M/e5PD6VghtIJvlV g7//C2Mu8fiYEGKE7vD6MMvhLxWViVwELlw9CMy3wlPBItNv2j6IcF7vzlFFKjk= 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: Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13591445 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41CFC4D133 for ; Wed, 13 Mar 2024 14:09:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338948; cv=none; b=sXh1/E/dISjcs7Es2WYSmKzyTCqxYYGQZFMrV3y1lwa/9OMZeBAwPTCcRcSWsNmbSfKIEthgW1v/nRm+42WuBqThAE8Q8V7gB74LKwz9MyC2ysPzA5YtsOdC3gSaTkYL+QNOLMQNtpFiIgWHxdJF7Lftkw9obKgIgxpbQ9Lx6Qw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338948; c=relaxed/simple; bh=L37rUKFEbasMDg96hf5hsL3mh5NhUZlnllLeo3/S3Q0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o4nEt4wHAPCj/1EhuVSXo7ZCPd9JxAPcXRMBA6jAbsHhZ+1o3J6vrzG4bn0JBtbDxJY/h2VX15/B6V1DZLEyEQ/l5pFV5Tt42ep3m20BsX1uRP8lvouZbhNRI47R3+CWhXrl7/inoQ7qWDLq962CGE1gSV9JEMCIAT5sAlfvuTI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=THPZjIPt; arc=none smtp.client-ip=209.85.208.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="THPZjIPt" Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-565c6cf4819so1619944a12.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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mCm/hrhQ6mByy3ZheArz8BA+9C2P6vrL3jyQtBljgzk=; b=THPZjIPtVZ/Tq4iHJkCQLzSBuWFCrupabUZaz5WRtNgQQuZGhksboThTt5+47ywTmd EB0GFG6zKM4NR0YW45NDsgsqWR8HOPjElo067hdDtphKhxQSBaB4Q939m6mMci5gLIYU 1jzCh8aelhjlGsvVq1IXfy+cx2Ua/qn4HnbYgD8vnVrCij8OaXYpSCnW1TupF3kCHKrN whFTwKsRG3WoZuSG+PBG2rF3Q4OMtEw6DealPct1nyJWghv4OflrIr8uqmspQMNPgZRZ KaJFmwWWJDoDR1Ctw7ziNSYUbBvCNSBHSQW+U5XLeuQRYq8QzK/rSxEbywcYkUpNElQW BW0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710338944; x=1710943744; 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=pnlnERepdzdRnMcWJx0S5buVI3OPh7yxxpJ5vPodz9haP2MQNQn/q3X8BwwgFKtddK ainfuR29j/m3jYhgtH9YCiau13rwlXaT2raXYLjhTNYV3OhSm5/2SdU0DagPmR1p3WgW 8prUwir70vQQn8v92h4u0MihuDjE7PgKODQJOOTBdz0ocNYSub6Mn0mi3dIC5mWeYhhi MknIme1DtxJ+cSe6YXgr7dBcBHxLyLJ5zdDVaoxEwSZ2gtOon1CoJiOGNeGex5o3huZf 9q/IwSKhntlAFeS2XfvI/0dQkyOHjzkIoSTQ0YQe9R0ToqtX+Ct8YKLjTeDTlX7eIBhC Y1Dw== X-Forwarded-Encrypted: i=1; AJvYcCVNpDlgSNOEIylenC8kxsMeqGpEgJL8EahQpotJ9KACSQu8lcTUMyGd6ess7yq+FMsRUF36S9XZgK6ForZArWpuqsXliFwtsxjI X-Gm-Message-State: AOJu0YxfkgUW0Tda2kJf00V19m5uII/l4Ra8Cy5begk3Xfjf089dJe2N W5kbValSPx3wox4oKLqOziBHcX+7sx/EiD8r5LKpqPA+O6niuDtzdHW02FICySM= 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: Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13591446 Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D26DB535CE for ; Wed, 13 Mar 2024 14:09:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338949; cv=none; b=KDYvF1tDl+vxnqszJG7hSQEUzfjD6UABJLkzAzTlYFmCNKiFkoQwnNiiU4AImZLAq3tS0uvYGUtCHdJ8r9hkQWCmSD/DN5KMjfVopKa/5E2y3tQQKRr40V2o2I94YeEEWynyoAtcawuSG5IVBpFWAoF8suKDYn6XOLOKbEwLjUc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338949; c=relaxed/simple; bh=VqvyhpLImrEEWUqrm8LqdGsOX7rFQEk5APKWIx4SW5A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jVQMYBScP8c4g/gVk6ZN0pZ+oXLtFCl6dh/01fgzILrGBWduQSNseT+dw0re9f7XyjNLw/1RPUqU4t1tzIQxNPkt9tNytIC3VijGNlYEwxmVFI3LTF4PffLOngQ+zuCdyRxaGo88LRrakbv/H8MFFtXgNWXPFnAK9IjIDHZCRfM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=dqcKrQG6; arc=none smtp.client-ip=209.85.218.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="dqcKrQG6" Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-a3fb8b0b7acso626146366b.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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iC5hRkZE8XydpjuCjvZ54lBNe2FsAX8ONZyCD9caIGw=; b=dqcKrQG6GZlDHC94DESDNEXdZQmYsLRUlYwlrISa96pHNcvKqVf6z8njAV/JZ3w0o5 jDRnQUGz8IepZRJ23228wV25B9jgsIx6S3Wl500SWVzNsBUa5ATtSUtsuPyzp6TIyNz6 EvS9U55Jd59c2gv1A7q7/y4yPwPIqIbUQygpcz2RFsZhwuQHm1sD8gPUa25zCatAN2Sh fkWy1KoZvW1AboDh+reNltaEktPQPiK0SCmLK5bQZulr5HHkim/mVeSkHgazVOi/el1W L0tUk8s+tQ7oWcyuMbauvGl9oB4r8SjXoBiaRWDf6leQrm38ZyPHE7FRwlJQ6AVgZmjQ yYCQ== 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=VWozzsIaY8m1CFP4YFdjwFg/asDrDBlUMXYokFBRna9m7bTtn5J/0jyZJWzCgj1Yy/ C0RVPn75tP+fxjRoeL+iArKPggg8yHG9/Xw0XHLtHCxmjjrAjYHIqyFQ6A2Qyelj/a9s ASxf5w+9AK2hKe2YDe5SlZgQ46N/UvTEsGDfXW9osplTK5os+KZm4viv4zGW/uDxnpPA yc28BSmMW7n2LGmoDEBMJBBDbTfKDMEsWgVVFjyhZaFhrGO05CriLfZ95hqTg6Nq/PEs Z6JXt0SEfVCZJW6vYMIu30P933xG7MHfIRuVqI/KdNTV8WQ9RwkhahhqjchQK8lr2lQo 1U6g== X-Forwarded-Encrypted: i=1; AJvYcCUc0ftlaUKMgubt3IRy5pmGhdE5AFtVdtHLT89DlAxtYPuT/DjSBrrwZkTRzs831Kj29tdEYFR99ViG0kHHIMMipI5Hy7TxGcYB X-Gm-Message-State: AOJu0Yw4ai8IMZasa7UiaOEtX1t9icyigogFPOFEEcferNUyVTTAk2dX RnOCJNuex3ZaTzpQZY/4ZssL4n2jfxMDPiKt1t7mro6daTbfP0Mkd+0WQThjsDc= 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: Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13591448 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7FCE354676 for ; Wed, 13 Mar 2024 14:09:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338953; cv=none; b=JcqbxLaRpMVHztdNEkYgrM7CYLN5W/No5G0h5OZ3GSgD0JgOtckElQ6I64C5567GkwF1aIjOUGfkic6iSycigL+14ZlnG+0UkTq9Exeak/VZ8PqcosgaL+252V+uv7jYQzoJS9cIAS9kRiWNjotl4AVGaSxnziHwXkcV7WvlFDM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338953; c=relaxed/simple; bh=ydMyNKlgJjwenSdKz23pqgfrZw8hKMeYS+sXWLgsu20=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VdCcgEnL8de1EA+U8CfIn0Ln1QJzLky6cDHez+RisTGQUAjx7ZRteBRjxbV0uMk0yKf6P7acUC1t+7SqZcJFRprTA8idNTrHA2HBnjug7UySZHpC4uRPqMxkBO7ZIHv8ZigD1eJy1jtMxsrnz722jxBAWGHxHQJX9l3aXotiubU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=d0N9Wa5y; arc=none smtp.client-ip=209.85.208.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="d0N9Wa5y" Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-5684db9147dso1432385a12.2 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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FHhJLSPwlFyN1v47/5LFzL8wYfsbaOex6ckiVXFurW8=; b=d0N9Wa5y5sjTOnBo9sCYT1phDUcaKpF1yaHfxWy4wwBuqXtFlGheVHtvqyGXTR4PNB D+FCjmmuOq34D8weCwsVKKpkkKJ1K5ECSA/PBGd8VBPIJ1gZ1O21oHArHVy4mzuHRGE1 fkwWou+JMcUTadJ6ZV/ifbA7R4gRD58+BVowuPtXSRQJBMIqolCFKif1QOBOSaexukc1 VlHvLPOaHCZusSfvSiSHNCsiUe/wXOKLWCbPD/yPaZLdAzyc2FLqsceiUUeMlBAIgNEu Q9smUMvkwFgLvKqNYrQrbdeARsr+FfvIM93BUDd/tpNAT4e8wnGx88Kvgxg/1qj/vtQj /DXg== 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=llOEz0IJtiLWmRSyOdFQYviG62/kFZwbadGexyoTkFIHvUmt8JFO6rxXamOLfyso8w /f0ZhZIJP1EeO53h3ZvPb60q4/T80yDOBtpkqp1vNO0BOsJxtWe3lKo0sWI9v/VP4UP+ VQ0BL8CGpqa/jV3J+45CCNUPUJJ3YrSwbqsqvy2Qti/b0oHKGyi0rKCH9jv8VTzLa34Y ohKTyKayCbQg9x6sCcab/2fXWdaZ11oC1wCuWfaabb4XeifyYan8/2AxGsCtT1qNkGwU jK+uiShWCuimDiTD658MkVsL/qBEK5s1pd/44bntR27fKuyV1uGOfi+JoKxJqmRU4mtF j4LA== X-Forwarded-Encrypted: i=1; AJvYcCXDoKQYwxfi/+MfbN7+xgpwy3HvhPTeUeutN+7HlTPCyyV8x5zlR7G9MzCnVzvWGDKYvULr3A8xeA+UCxszkZ9KGsdLD4VngLmy X-Gm-Message-State: AOJu0YzJVs1O+4jr7J5v9NsLOPACqZh5/qoXgcmuTq/UKADhDqZByZ9q IEceqbJylsQ/+bClKa7HtIidUw2Fsq2KJD4VC3hAgOwYFZpoDVPPNYxNg3GQddc= 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: Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13591447 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BABC55C08 for ; Wed, 13 Mar 2024 14:09:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338951; cv=none; b=SY0YA2hcnGA1MWNWrE1JtT/CaVUIjVbNRSrWKMsh3qqSJvgcK5tzM2eqnGuaqSAr/KTlMFGkv1kI2w3Vq2hSHdUR9EJe2sMQqIOj4IRkvxBnPAP5z6+LV9Vl8mxjwtkARXOV44khTWkbaMKrudmWVROvUpAlneUXbXBYzIDMpIg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338951; c=relaxed/simple; bh=kVdZlNo+N/KnAT/Z2kOTskJN7eca2zSo5mLfoyTSMUY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sl4jbbDPZiwDiw0iZy9V3cUH2fdF/JyPNvFSHrWeujXzddSIeClAbXBjQJPjc1fgD0abh/ExsliN6Joobv+4XgGCerEAU5KNbVmK7wQGLjAZBAuMwOT5eVION8ob4ns25XaOxKaujAabhPq73l5B+TOwwoQeHjyCGEamYzJKiC0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=V30hA1Qa; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="V30hA1Qa" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a4663b29334so61999066b.0 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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GZRpUUNRnIq77pI2eAogF8VwCXAgFL/1g3LqDmhWq/Q=; b=V30hA1QaJl/pohCPP2spu8V8TnfLYQFGL9b5M9aaNJn6LFvmUsA9B6YAtWeBA/dpx7 Vgnay6FkJdGmznWb7C6LELOEq4djOfr/bORVf0z0Lxvu0kAS7Cbex0ToFx7BP9xlzq6k qlA/e706OyPG50TN2g/FJltK6NmkIXaQX73OqD8brHKlAuiLXi9WJ8o6hO2YYNRZlmsu wSxn5fxKAnwD/PE3LdxDv4R6qHoIaaO0niz0pt6dF4i9j/knuKyQHVj7G/zV1ypnEUgk C3XfUud7yj/AAOhUJBRuXmLs/TXr8ohGaMa+eh4R7oxRIaViMGFTWwqKWiywZLvbkDuJ BWLA== 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=NY/VTDoktsT0zgI5OY19udMMLGn9BBTDsDEn2wSWIDOzOYFzNx+6UHabLU0sQ1ouG2 5ovBrSl+vSf1J/An8mrE//LQVyFRiAMamDem1lcIifuM0IonIY5fOk3kmzaV2jWqLKdD evw2CXZ6hVQtatJjW08DiHoTpVu2hJK5hLQYQfYcoIUngSJPfj5RIOQ1ynAMnOI5MxWk nitsPNn7L7hYNHhUBzXx7/Aqmq4GkbDZp8MHnfHXBOoeh4gEQ1tfyEIPHSli8ueAVgVr j9aBmJHGOTvMq23X7h2x7f1d43Wv2IaRJ5ccj762lLJc9gr9URfy1P4ZndgU+dVBGczX QlDg== X-Forwarded-Encrypted: i=1; AJvYcCVQD/NZvfGVtGRAyCbe90gXVyKqj+qcwyMd76YojeCLFJIj7ev157/+ZWkrX/hHN0HDFsRYxIWHxg3ltS2JHmZCaK80COzdhhHE X-Gm-Message-State: AOJu0YxLZBpU+uwe/8nyKbu4X3qZHxtEZeabh7hNbPzzqAsTfPYhkXuP rjd988/knW0PpSGQgcatn8i81nTu7weyFzSPgoS6Bd1SSF5Y+k1TxfO8C2jx6Q0= 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: Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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>;