From patchwork Fri May 24 18:26:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 13673523 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E0BECC41513 for ; Fri, 24 May 2024 18:29:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=eDDwS7j/E9qR5DC0pvfSgQvdRgqc49YmZGcR6i0Vork=; b=M0XoHz7LhpD7t4 loDUdbwziP/CTN6AkYVf9MerW5FRsvmVkrilenVvYwBl5E2vbhWsJJ/0fi0jN7gge5Q5Hj4ei21sJ /vMMy/Mtjja0oErPwTO201xa4nZJF0h8t4m7IgTP1t0W32bWwAtrVDLLl7ZwZYmZ5qN4Th0AVVq6P iWc9rKnHEcrjGzpTJgPQ8y0hIRspJx2dRsWt1o8ZIfF1mUGOg+goG+8HEfOYjNXJF/cwzDUl8N0nQ GweVIJp62Q8HRA1q6ddwa2RkzSSk0H9J6AmumitSHJZ9RO7vhVBwtBLbElB8xjvPvB9E6ZLOio0Zp DoZSgFyZeoStLLh2Omcg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZfJ-00000009a6K-2MRs; Fri, 24 May 2024 18:29:17 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZeC-00000009ZI5-2LEe for linux-arm-kernel@bombadil.infradead.org; Fri, 24 May 2024 18:28:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=wA8wcVcwFLmtvy2VP3x9io/V3+kH7xE00SpBiNM4hDU=; b=IdpIFvpAOe+p4DJCyeDBQ+tGYJ 9nnqYyJBkThvMlEbNHhx63ocUpozZlMmEZI3qdpCX1kB2iQJgUOu3SVriZ1yqYOM2s+JqIsOsZsLv z6p/HpT0TGbvHm677wMAMt0FC8ioJag5570NLS+dHjowX1DYwi3tng4A1bgsPPlUw4hDeqq5oPf63 fjy3yx+Izl9Nze0C2rzcw0H9/f+Y4BSw22wTGXgxtCJ3WcCD4tdvWQjy6UbOdIMuVQVV8oh2+bDvZ MLqfUZ9oaD6Yg8EFW6zxiTGqeQvq3kevTYafNWegUjWjRh1HTf5xcy2/jXrMJpLHE6vdEpbESBKmn h5b8I8ng==; Received: from mail-wm1-x364.google.com ([2a00:1450:4864:20::364]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZe4-00000009vJ3-1OIH for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 18:28:06 +0000 Received: by mail-wm1-x364.google.com with SMTP id 5b1f17b1804b1-4202ca70270so41001845e9.3 for ; Fri, 24 May 2024 11:27:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575275; x=1717180075; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wA8wcVcwFLmtvy2VP3x9io/V3+kH7xE00SpBiNM4hDU=; b=fvKyswU+mMFqUAXu1VsSR4Oc0GMywL16RQqAK3WFeZLDFktBWdAgZI893dBBVJnTk5 8Gu4H9E+Ik2pCWszxM8PgYJx6BSp3xUQsYgmMoCV/CaNsNS0lH5R4Xgj0TDHdgqQ/41W wsMHgI0igcYr0hDGOwVO2aedgQ2imfKWMCa4SbS+eUdHwMeDdbrbween5Drs6spHplbm M6y1LfxzE66n9YLyglX27VxKjIXSw098CdEHfXKgMs20KFe/0RfOKDzGWcg9J3SicfeQ 98tccb0t4dWAcVSZMVz7yX9ZkPDS582/eAw/S77l28m5KY49BOV51WTvaRfDDsAlB9RW bf7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716575275; x=1717180075; 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=wA8wcVcwFLmtvy2VP3x9io/V3+kH7xE00SpBiNM4hDU=; b=kkd6q0m5blSE8g4DAmhhduItaFaBnyRMwSXLmUpp3rdxHeZiTKoUsyrvsM4R4e7L6T pTjdbGZ2xfcOjD9bBAL5Ldax69J287ELxaW/ilF+QTlLFhEFho6Leev7utLV6RzG2axZ 79s8BpX5UGoUHfubyuABl/zF9x3Dqm+ehE9N+lDGbxZJGlFdIsRHTyjPMKq0UkzIO5ga kGIpnhyMBEV8zmVnz7JmmtfcBhrEaZ4NJYaKlmt+n/IMirE/B3W/wY44+mQVb63UitVu GMatT7jc7PBMKYUwbOUiC8OrAvmXWsbFcsIuHPzRnUMe/TPVbRqPHMVyGMMpRCrcNdMC fJRg== X-Forwarded-Encrypted: i=1; AJvYcCWUz/EK+n0Eo4RWMMkB3HqxWlGwe7UTiZp6fu8saBGik5uWOLX9+CFd+EW/Bgxxct7mOHpk+M75u2yM3IJ8MY3L+TUrLfv8PzzMEUUISVOBiphV7RQ= X-Gm-Message-State: AOJu0YxV1tgq10Hx7GGoJfhAsfg8JumZp3Uh7f2cT2SXp2VUMQ+cKpsx Uy4urIdkf9qUAdpyWgTQQw1cmblnKz8bGBgqPLkHj8JC+hvxEfVDeBw4QLpDyC8Ud9/chC0k9rv 1AxSJQKUeLZj+cfY3FBisN8hIsIRGuOXE X-Google-Smtp-Source: AGHT+IFDaLmabHJHQMgitln4OpgM8BEx4a9yXpbL9c/m5s+ybK8fzjM7KEITDWBXUomFqJVUNhNO7yZURk4G X-Received: by 2002:a05:600c:5746:b0:420:29dd:84f8 with SMTP id 5b1f17b1804b1-42108a99ba4mr30406535e9.32.1716575275682; Fri, 24 May 2024 11:27:55 -0700 (PDT) Received: from raspberrypi.com ([188.39.149.98]) by smtp-relay.gmail.com with ESMTPS id 5b1f17b1804b1-42108905a6dsm1244535e9.9.2024.05.24.11.27.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:27:55 -0700 (PDT) X-Relaying-Domain: raspberrypi.com From: Dave Stevenson To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Vinod Koul , Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Ulf Hansson , Mark Brown , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Vladimir Murzin , Phil Elwell , Stefan Wahren , Serge Semin Cc: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mmc@vger.kernel.org, linux-spi@vger.kernel.org, iommu@lists.linux.dev, linux-sound@vger.kernel.org, Stefan Wahren , Dave Stevenson Subject: [PATCH 08/18] dmaengine: bcm2835: pass dma_chan to generic functions Date: Fri, 24 May 2024 19:26:52 +0100 Message-Id: <20240524182702.1317935-9-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> References: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_192801_282275_B93DC220 X-CRM114-Status: GOOD ( 19.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Stefan Wahren 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: Dave Stevenson --- 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 e2f9c8692e6b..aefaa1f01d7f 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -288,12 +288,13 @@ static void bcm2835_dma_desc_free(struct virt_dma_desc *vd) } static bool -bcm2835_dma_create_cb_set_length(struct bcm2835_chan *chan, +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); @@ -417,7 +418,7 @@ 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 */ - if (bcm2835_dma_create_cb_set_length(c, control_block, + if (bcm2835_dma_create_cb_set_length(chan, control_block, len, period_len, &total_len)) { /* add extrainfo bits in info */ @@ -485,8 +486,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 int timeout = 10000; @@ -513,8 +515,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); struct bcm2835_desc *d; @@ -533,7 +536,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; @@ -566,7 +570,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); } } @@ -594,7 +598,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) @@ -682,7 +686,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); } @@ -846,7 +850,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);