Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1746013lql; Wed, 13 Mar 2024 07:11:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXpWOe1Azlk9VzmEJc85Bhfy471HSmqMu5bBHeFWDPjDbr87mZblgpI3VaWTnxCH39bAPIi0dLhP9T//kvWDIwwGnpluou0W3sTC0iiJg== X-Google-Smtp-Source: AGHT+IFBee70OTEiBDmMAWFDQB5rpeMJVmohvsPmaek/OKvL8OgDqyGpF5L3kYYD7qK3xs2gn5uu X-Received: by 2002:a17:903:2308:b0:1dc:df25:76c7 with SMTP id d8-20020a170903230800b001dcdf2576c7mr4241191plh.57.1710339069566; Wed, 13 Mar 2024 07:11:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710339069; cv=pass; d=google.com; s=arc-20160816; b=lkwSbAxWE9g3g/7fhDfuJ+QF4bt+o0rGkjeENcC31+ccLtQlY06exoCYkkokp/Q1mD w1hbUx1Klj2idwBINlyLaElqqop/8XWEk5GGkfz01NNJ8vANlZJfJPITu1V5GYtwXyG1 LcRc1hnewLGdYnHZsiFGqmD3rNCrbagaDjEI7OZGHKYTCPIDSpAMjZqxQrPboFnvwlId 3teNOX63cFZSDUj7LfYP3tpB470QRzJg+98WDeGrEKt3+TT3IwuFivRSI3V7R9kUsWSc QSa6kXKML76OcewHxtI5qCnZPSrK+NBxc6QKUamD166NEKQcwp8j623igYrITqbNuuIw wTwA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=9F0Go8/yyuHye8yt6k5vc23oD+JipLNS/6TGYAxgmkY=; fh=JDO2YKJQ/1gkJFOkd1uRg5QuspP8k412Urf/dd/xaSc=; b=H7t7GybkoMmE/OIsJInPbVJiut4hDDlaWiNPasH8n9GeGU5Rpe4/P5xYR7vI5bBxAF gNNBhmYzPzmDa86x3A63mcmJSJUtHgCqRbmeFnw4hgz5bUPAHrVtWcm4wwOnvm05Nh9+ QbE0y2796URgJsqrpgc99AYWZUTsIdWJ1U85Vj7/Rcat5SN3FzKZbHJgBNmxKbm6g4PB HdpyCuvHGYHjrwWn9ZHkFb72jgOLX/EyP8VgYmR7wQM3/Z72QOnzyz7uIwwVcNYETIpm Bz+nAx5eIoxnBnzicfVb4bop9gzqkaeKWTb6JJ/xpJ2zrIycIFxpXACerJ3urzbiMobB +z3g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=Yskxdo81; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-101599-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101599-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id u8-20020a170903124800b001dcd2fb74acsi9333341plh.5.2024.03.13.07.11.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 07:11:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101599-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=Yskxdo81; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-101599-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101599-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3D10F289126 for ; Wed, 13 Mar 2024 14:11:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A56AB53E11; Wed, 13 Mar 2024 14:09:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="Yskxdo81" 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 017894F8B1 for ; Wed, 13 Mar 2024 14:09:03 +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=1710338946; cv=none; b=rh3+JgxDHtAwdrmdQVlfEOTk852MXWfRNNLnlkpuoBxZo754kJhMCvqf8FgVl76CBeTIEvpDqy3g6zInXGXjkcIkv0jJVcWw/dDWgJjR2jtMk1B4pWJWWkmuOqy8dHUQu2hqrFG8J0dC7w+ifzKVPlqMwkyrqyhGzDBYIsWR+1s= 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.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 Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a4645485da6so262790066b.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=b/JH4LwzqSu6TOa20lUcoSmbziRFZjeu9IsZ+umJnTlljHLd7QPgfyOR/ZB8bxo9sh j1qM9lCtu/pGLcZHTZdT6jRAHCS10iHiqxR4F7STaqgGsZ8rGlrMgB+Lt7h8npEefwIJ uTq1YWsIrRr4IwUqYyG97WjBV4pOMJHPZeUSCDNkJRSFTkLmlbBnRsqGx/HjrKpbJeMK 7tWmS1K7hqkrcR3tLMZj5Pra65ja9fnPXjhxWDO8IKHu84U8jlJ9n8AQKFdBXgQ/tj5Y fHnkx5hbZExUZPGzW/dnSYccwUfCEkunJ9us0JVEMuo/2FUjCg5OenH5+Nfp1bh6o7hG U0Uw== X-Forwarded-Encrypted: i=1; AJvYcCV4COXxsv4i3cGs5v8BKcQHGJfxiTUgzWVbA974KlPc+uNTWy8offYRH0w+8rMAZpFNJ0H5BVG2Kjqx8Hja0+moAeok6Dxh9uYCs64D X-Gm-Message-State: AOJu0YxQI9Pc/cmpS3ap2AoNmugnm9VxJTR4M8cDyg/gV5o1UOzUV5/c 5pI2Y3Kl2smt8tWa20QpZi5h8SPUsNAKCUMc0AFzr1MHWPcBrdJTq2YFewTs5Hk= 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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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); -- 2.35.3