Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1745953lql; Wed, 13 Mar 2024 07:11:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV2PvgU7R4zppM6i3jN9e6gG1WSsyHr2mGQmX6xdAY0XNCBDQO9uO0QoYPBnRqLnR7KhSBQdyKTMR4uAJfs/tnBuRIfAtTFPQNu2QAlYA== X-Google-Smtp-Source: AGHT+IEL8nojv7cqG7dsHj6NshGbQAZ060I09Ng6JBCgcG0Z/oU8kTVviXkghf1sG0xCNZSIbooj X-Received: by 2002:a67:ef90:0:b0:473:8be:5528 with SMTP id r16-20020a67ef90000000b0047308be5528mr3557300vsp.18.1710339065138; Wed, 13 Mar 2024 07:11:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710339065; cv=pass; d=google.com; s=arc-20160816; b=Y3MUVNkUDtdSpk5cz0pRRzteyUnTmr3bY6eqJ0P3LfNVIY5qaCVfvCvuN8fu6uBHcP 056FYJxPjmB5fh5Dl5PsZQ/20OafQOuUKOZO5Xv7bU+sFnihzRfjdMIda0WwZy67w1wH at9xknhRy6FX5PccO7JBkect+WPoQyJl8zcRCiA8hI2DLWKzPrx8TYWEvF3gpkx/dBoe OzyzGd0vF6fuF1hEPXYTfLVrc5OXSsSLmbzXtD2loKgLu9ZQaJYz34n6oX98DQi6SwLl vfuNlen2W9R0ecSP0Wyr9Li0MuYfQ8T5KyP1nsNFqUekMF2ZIcarT0zjdyi9whrolcMa kQiA== 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=aQCAxLcWayDk9E0aIZHof0VU6EySMCm0kMz7fVOHPV4=; fh=we1F3NxxPM/vUaz2CnE2P84HYxITgMjpDHxlKgjK5e4=; b=LwE1UDigr1D00L37ffJ+JJCqQ3BxPtEHESRdvzA/chiCeKzVQ0n92nPpmkSWbCrGRy sT2x/adVuu4UPs67WQolEijzquD5AX2BoY/3EPvrVI8QQTbjX7tObAUlpz+8naRyNtFJ Djhc2ZdMjTgUFDM3gBFy358ApvObWyTvFF6g3Y2McXgoRjInuhZ4MtfxTeYyTJMg8V2H MRHv5RYkv9kX5RAGQnJ1muzerzpIegoPHJ4k9Ooq3nZdHtFVfIJuY0Xbh37DUb9CXoYr izbXt9CE294d7lb0sbxi50pGxLH2MWbqn/BPINKkKCuKLL4Acen5YFzoDRWH07zKY/qL /6Zw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=QCikcQLC; 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-101598-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101598-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id x26-20020a05610207ba00b00472bce2b199si1081658vsg.589.2024.03.13.07.11.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 07:11:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101598-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=QCikcQLC; 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-101598-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101598-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 8A1B01C21E5E for ; Wed, 13 Mar 2024 14:11:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DB3A3537F0; Wed, 13 Mar 2024 14:09:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="QCikcQLC" Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (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 01BA14DA0F for ; Wed, 13 Mar 2024 14:09:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710338945; cv=none; b=PpSXLmWrByPD8LbYpbhP/AsIhaex+7H7MQ926auesgHcdteq9V9sFZaIGVfZwntgbYSH0FgWjcJs5qQIlrK0bze8vveP6SRE4Irfn/R4B3YHlMHfQ5FlYuhFq6C9cPPMjLLdV2VULV+vagXuH4Kcse7anF4nq7vwMMg3f2fgRLo= 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.49 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-f49.google.com with SMTP id a640c23a62f3a-a45c006ab82so145165266b.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=lQ652alA0A+sWgXuH2tKhcYuItxapGBUxCfHOIM+PKRm3FISA95YFBmjmGlKdGVT5X nHplLqrxT2TykusQ1E7HA787dk06nEyRB1IKrFXDrzJ4LcBglZFd7+uKYzMUAEUbCyse aP9OnBRMg+Xx0ty2LhpLYY00XHn1xpa3SdzI5Y5arax7M1Oxp4Q0pxz5ki5PfCeqxgv7 TOA/cz8570oOlB9KU8VQ9WrUlgsNfwZzX8q/cP6BADWXKLx5RZVPhgjUPrd1oveQM6iL sm3beV/hpissF1hNLAJi3mrOwWow7pQEwcHvcbdwVJKiILj0H57s664eJkamwxpWHabg mQkA== X-Forwarded-Encrypted: i=1; AJvYcCU29dy1pXeJdygCtanEZ/cTlrr7BL7YnR2pBxV9MRn85HBJVwwLXoqAd3+WJ3ubz+Je/bt04/7l5cKRv0pS2ucplY00h8i4q6S58Oun X-Gm-Message-State: AOJu0YxCGr3Mo8AsjLuLCpau0uBe0tSJxLmSlq5heqTyodtsCMr3h/Ed IffDuDwAEvAvJOUjMeuwyZoNf/sZJyQL0fUg4E3jTkFlUpxhXOktp0cKWSYvYrU= 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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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; -- 2.35.3