From patchwork Wed Mar 13 14:08:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea della Porta X-Patchwork-Id: 13591456 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0F3C0C54E58 for ; Wed, 13 Mar 2024 14:10:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EWCXPUKSzDGurwsk8IHpKtoo+nHlTv2UBJNZQnfsQUQ=; b=v+tkU/P+NVvKYL 1yhiKuGHTZOsuSeKNk45ak8nYH6+haKyDC4eUvd5k26R5c5Xb8Rb0dIIqKHWTMb4eTZxZAm220SPl VEuG1z8vrsGe7nzCl+2L+tCmg1T/O/TbT9Oc0ZBXLLWItJIHbrf/gLdJpnGHpK+Cmn4ixdXuwTQ61 bgux75VjudE30imTmsYHm0qKoVasDwTz1uoeuWACHq2L8u1IhYEMtTQeef+ISbRG9dYhdUTRiQO7j ikmgsSrqI4WxSnkpk2/P41wv66CJVCBNGhHg71Zbv5GZ/vIJBDgQNl+BpllE1Kv1opjyu9mnytFwa DY32Nppd0ul5RH4xTxIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPIq-0000000AMp9-0IMC; Wed, 13 Mar 2024 14:09:56 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPI3-0000000AMHa-0dPi for linux-arm-kernel@bombadil.infradead.org; Wed, 13 Mar 2024 14:09:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=9F0Go8/yyuHye8yt6k5vc23oD+JipLNS/6TGYAxgmkY=; b=AaUGttznvEqzWwlxbgjUlTzgkH ntn5HCaN+wnrs0UI5/5fFIJ7lgnpeqibh/j7EzqNnJE6QueQaEE0t3O0Zpe/ipn0fn7jny6w2uGTn jD4AZK1TqHcwAKiA33O84eVVh/7xRLngmqJJVnXQDs+iAWNGdjs+wTNFwqUL2MwlEGMsZdHLkI1Q2 /RmGCO8XO/Yq0UH5WH4uGLfohXEZOKDM57CFXzpBItJlfuhQTVr6phW4NGPty95Vvq7UPFa8G66zl TB5IJAGEKan5w5KkCBPl5FSiXWoR/t+Cc78V6/RvfmEvZuk5MN+Mh9s5g2JjcLZrVfuMbRBS4a54g EV6MC0yQ==; Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPHz-0000000A3Bx-2nkY for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2024 14:09:05 +0000 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a46644fee93so59362666b.2 for ; Wed, 13 Mar 2024 07:09:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1710338942; x=1710943742; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9F0Go8/yyuHye8yt6k5vc23oD+JipLNS/6TGYAxgmkY=; b=drM1OcGo0iKrKqlYkmj1CUu7liHGVYM9x0Ueb+Uk6o3pc+G/bldzRtIdcYDfDVc5mk q6PnOSNyIomqHD4wohQYXnmH2Ap556CtpqpxMjMddcRwpisRaH4OwsLtlbHZqgHcBxQ3 lurHYFCbXhacE9OPoS6UQXP1Finmtnp5fzREgviyOHdkhOeZe6bnszn7lddzrbRHXqKi QLN5//OEeBhkR2UaVZm4Umw1I6uaeg1e1hg08GM1KUFSnt/DDI3iJPVGvwnc4S6xvZZE 7xOvLf/la/+szC44vFtpxD41U1yLoC+M/+RCd6OUPLbbMHEiPLfcAc7Vl2LTmuPggZqi wJDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710338942; x=1710943742; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9F0Go8/yyuHye8yt6k5vc23oD+JipLNS/6TGYAxgmkY=; b=PnSf1bU6ny62/FXjo9+xaR8gikfDfisxfY4WVbldNXPz+kDfO1DU0Yiz58xgeaG9FH oOpP8TUqX6C7U4ay6FPW/F0LNcfF6aGUspLJtUMdX4GE6NZkwmWe8RNZQwOL58xVn66V NxO+NwdUSKf62fMvFTO9rzPl79Wa6U+j5tKnSfl5jx5IKoLIdLEe8DSL3qDhPYeJRspz SxdV/O5/yQbcfwS/gqmA+J4ZkVWWduXMcYE2xW1jWcZ2hPWYHxSChsj2hibD9+mI8XH2 h+ILYHZ92lmoc4KenvLYJwnslDeRyf+zBWCE7iI+Bvnzub0YTkOYTdHxXPDgnRf9yO6K SS0A== X-Forwarded-Encrypted: i=1; AJvYcCU6uHXHSrDyHS6w3z/Wp2/wRiN2dr8z/kbVgoV6769WSmEqLY35xPzkNNKewU5g4DMtUf8sbsl5UbFEiRwLyNQW6gI9EHMzASJHSwGpVRmWsH6d41Y= X-Gm-Message-State: AOJu0Yx9UKK6AmHjP9NZyqbn7YD/B4EMSibV4Z17ljaTIn28rdFhr3P0 sSG8EBSuSEKeY4FGabTSydZFdoROKX0Jb5QKyh3eDzr5mO6kMGOoE+qUSCH0mRg= X-Google-Smtp-Source: AGHT+IEGWqP8QxjwPa6JxODEFxxNSr59dthiRT8AGN4nj6MeDLalxq+7j6Caf6aztQx6EziAU4lTLw== X-Received: by 2002:a17:906:fb81:b0:a43:29e1:6db8 with SMTP id lr1-20020a170906fb8100b00a4329e16db8mr8168617ejb.9.1710338942448; Wed, 13 Mar 2024 07:09:02 -0700 (PDT) Received: from localhost (host-82-56-173-172.retail.telecomitalia.it. [82.56.173.172]) by smtp.gmail.com with ESMTPSA id t5-20020a170906064500b00a45ff821e09sm4778473ejb.150.2024.03.13.07.09.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 07:09:02 -0700 (PDT) From: Andrea della Porta To: Vinod Koul , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Ray Jui , Scott Branden , Broadcom internal kernel review list , Saenz Julienne , dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dave.stevenson@raspberrypi.com Cc: Phil Elwell , Maxime Ripard , Stefan Wahren , Dom Cobley , Andrea della Porta Subject: [PATCH v2 11/15] dmaengine: bcm2835: pass dma_chan to generic functions Date: Wed, 13 Mar 2024 15:08:36 +0100 Message-ID: <2dedf0428cbc5229ea563a571d297a64c8e09c03.1710226514.git.andrea.porta@suse.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240313_140903_831016_9A01A097 X-CRM114-Status: GOOD ( 16.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In preparation to support more platforms pass the dma_chan to the generic functions. This provides access to the DMA device and possible platform specific data. Signed-off-by: Stefan Wahren Signed-off-by: Andrea della Porta --- drivers/dma/bcm2835-dma.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index 03d97312a3f8..88ae5d05402e 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -308,13 +308,14 @@ static void bcm2835_dma_desc_free(struct virt_dma_desc *vd) bcm2835_dma_free_cb_chain(container_of(vd, struct bcm2835_desc, vd)); } -static bool bcm2835_dma_create_cb_set_length(struct bcm2835_chan *chan, +static bool bcm2835_dma_create_cb_set_length(struct dma_chan *chan, struct bcm2835_dma_cb *control_block, size_t len, size_t period_len, size_t *total_len) { - size_t max_len = bcm2835_dma_max_frame_length(chan); + struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); + size_t max_len = bcm2835_dma_max_frame_length(c); /* set the length taking lite-channel limitations into account */ control_block->length = min_t(u32, len, max_len); @@ -441,7 +442,7 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( if (buf_len) { /* calculate length honoring period_length */ if (bcm2835_dma_create_cb_set_length( - c, control_block, + chan, control_block, len, period_len, &total_len)) { /* add extrainfo bits in info */ control_block->info |= extrainfo; @@ -508,8 +509,9 @@ static void bcm2835_dma_fill_cb_chain_with_sg( } } -static void bcm2835_dma_abort(struct bcm2835_chan *c) +static void bcm2835_dma_abort(struct dma_chan *chan) { + struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); void __iomem *chan_base = c->chan_base; long timeout = 100; @@ -550,8 +552,9 @@ static void bcm2835_dma_abort(struct bcm2835_chan *c) writel(BCM2835_DMA_RESET, chan_base + BCM2835_DMA_CS); } -static void bcm2835_dma_start_desc(struct bcm2835_chan *c) +static void bcm2835_dma_start_desc(struct dma_chan *chan) { + struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct virt_dma_desc *vd = vchan_next_desc(&c->vc); if (!vd) { @@ -570,7 +573,8 @@ static void bcm2835_dma_start_desc(struct bcm2835_chan *c) static irqreturn_t bcm2835_dma_callback(int irq, void *data) { - struct bcm2835_chan *c = data; + struct dma_chan *chan = data; + struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; unsigned long flags; @@ -604,7 +608,7 @@ static irqreturn_t bcm2835_dma_callback(int irq, void *data) vchan_cyclic_callback(&d->vd); } else if (!readl(c->chan_base + BCM2835_DMA_ADDR)) { vchan_cookie_complete(&c->desc->vd); - bcm2835_dma_start_desc(c); + bcm2835_dma_start_desc(chan); } } @@ -632,7 +636,7 @@ static int bcm2835_dma_alloc_chan_resources(struct dma_chan *chan) } return request_irq(c->irq_number, bcm2835_dma_callback, - c->irq_flags, "DMA IRQ", c); + c->irq_flags, "DMA IRQ", chan); } static void bcm2835_dma_free_chan_resources(struct dma_chan *chan) @@ -721,7 +725,7 @@ static void bcm2835_dma_issue_pending(struct dma_chan *chan) spin_lock_irqsave(&c->vc.lock, flags); if (vchan_issue_pending(&c->vc) && !c->desc) - bcm2835_dma_start_desc(c); + bcm2835_dma_start_desc(chan); spin_unlock_irqrestore(&c->vc.lock, flags); } @@ -885,7 +889,7 @@ static int bcm2835_dma_terminate_all(struct dma_chan *chan) if (c->desc) { vchan_terminate_vdesc(&c->desc->vd); c->desc = NULL; - bcm2835_dma_abort(c); + bcm2835_dma_abort(chan); } vchan_get_all_descriptors(&c->vc, &head);