Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp741336lqb; Fri, 24 May 2024 11:39:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXyBWIw4kmfcJ387FzsaIk1Z1ARTHLWS7u78wP8ryXjvNW/u5wbDOJbHuK8giLW/29L9t0V+cdbSChT6ejbQ1GSUlp7Voe90zRpAfmVQg== X-Google-Smtp-Source: AGHT+IHjxyLFVd89BxP89lKcUopSjOVb/12MS7MlHVvSZTyBkqd7Yb7ghDwj0NYLxoSR4Kqetvas X-Received: by 2002:a05:6a20:c6cd:b0:1af:a4bc:1f71 with SMTP id adf61e73a8af0-1b212dee298mr3625294637.26.1716575973929; Fri, 24 May 2024 11:39:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716575973; cv=pass; d=google.com; s=arc-20160816; b=dOyknmPAIluzGw3CzK4hC6TZv9+Zdle9vQvrmNhgbRnxuiGBw1Jzevn60GSg+5OliG UQnGfd/xeolmyJDfoIF5fXiqCYzeb7OhEDTjNVfQlLOD3wWqg35aHtm0ldyK3u7JUGyh m/qQMGRkgL04cYpFeIEpw66PcEqpMFO0N38B584ZqS7gj+Qo01olm6R8vNzLz/8e3MoN DvfCD4LRoaQAYmqob6JxmXD9D75xkdmrKEvmI0q0ilurMqn1rHppcV469mPZ4IbuY7hL S2MacS8UZAqZtODpKbAhinaK6pcjwzN+HAvd8pJnlBWmXmcSJWDCAiUOpXF4tpRdNhY1 +Q3g== 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=94Kgj4XNRFYduQRTRfIrQIcXqS9keoQhSCwvILhnmSs=; fh=2fasiaaD9gDWL16r9V+PBbGmGTKICqUGedq4ZK2vwNA=; b=FkRxZ3WaBE5vDVezEvDPV1JfdquF5r6+kH87IKv0GIoU6bB1Y3IkobGXSImuqUgHus EB7vyiD1en9Gj9CWD5k9qqVJEXFL2nQ0r5RoVrWVbCKRC+SYkKXCRBDJXtb+QMjJbrrm zPa+el9Q/O0CdH8BJlVFyNpynnbuTTwf5jswz6kJdvYiMGwYMROR6dVDjWRlhS7VLrrF JIX1VxLmCGrHVrJtjCSYsjl2PWJuRSV20iJRN9wPszE6uvTEFbNkVEuPMyE7odWVd1CK /cxB1vLXEaGPDX+U8ffqGJM88K+6+2t35M9BrOnGcINsNGC8jfTslJoJrsfRAbD7ULuc Kiew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@raspberrypi.com header.s=google header.b=iEOZDZFP; arc=pass (i=1 spf=pass spfdomain=raspberrypi.com dkim=pass dkdomain=raspberrypi.com dmarc=pass fromdomain=raspberrypi.com); spf=pass (google.com: domain of linux-kernel+bounces-189004-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189004-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=raspberrypi.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f8fd4d5b26si1871690b3a.246.2024.05.24.11.39.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:39:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-189004-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@raspberrypi.com header.s=google header.b=iEOZDZFP; arc=pass (i=1 spf=pass spfdomain=raspberrypi.com dkim=pass dkdomain=raspberrypi.com dmarc=pass fromdomain=raspberrypi.com); spf=pass (google.com: domain of linux-kernel+bounces-189004-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189004-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=raspberrypi.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 9C634B230F6 for ; Fri, 24 May 2024 18:31:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9572612EBEF; Fri, 24 May 2024 18:28:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="iEOZDZFP" Received: from mail-wr1-f98.google.com (mail-wr1-f98.google.com [209.85.221.98]) (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 C9E4E43ABD for ; Fri, 24 May 2024 18:27:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.98 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575282; cv=none; b=dAFiPy1kBmJUUn5nj93MosPo4kWxH0zo3mSpOKyH/59QpUp0Wsb9+OZZOnxs9duAi0/4C51s1oltOfpelViqIESaOLT+84wMZVB/O8GBkfsPa4wFcKHxaQ3Pue7wpSOzZTIB0jYvUh5v3Qg0A/UlLcqlTxwv4FOgnQamRS80aw4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575282; c=relaxed/simple; bh=q/vPvexOj8BorMyOQXoWhY2JPB5kWHRHIatWLRoYFL8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VUPSkjV2/eWpXWIuA5GhuWUx7jIuKRqvIXU+36UdXtXOiaDp/YJmwzv747HQPd2vb/rM3FXaslI+uaXqDwdXLDNKa370OPt4HZRrE6PAR1JRM32iuJxTEdeLsARgpce+ZYOiMaua3Dn8ZN0M0XM8rg5KQY/ymf2Y0KmHbdUhXjA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com; spf=pass smtp.mailfrom=raspberrypi.com; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b=iEOZDZFP; arc=none smtp.client-ip=209.85.221.98 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raspberrypi.com Received: by mail-wr1-f98.google.com with SMTP id ffacd0b85a97d-3550224b745so1275361f8f.0 for ; Fri, 24 May 2024 11:27:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575275; x=1717180075; 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=94Kgj4XNRFYduQRTRfIrQIcXqS9keoQhSCwvILhnmSs=; b=iEOZDZFPhCWfBwNhTss3azICVGcHfq3YdwuiFxHNXSYKe5RG62yeX2/HLJGcEETqE3 DeltBSFm60DNjff864htX9sXlwhdcSLoGQQjpTqFudGzUROcVjUNbSvcbRr3ngaREWKY wUFXYh5UrbK6mzaWMsDbSi2Ww01xc/j3vzRoQ/LijUsgKTjPyqm9MRzyFwdT6x1OlaAl dTxdTyduycLLrZt7J72H4iJR9EDsfvAUA/Ua9sHW8BgflLeHfOr4QwlI+E2fXZvc35cP OdD7q8PVTQb9RGjptftuRA9Iuq8N71mz9B64qtL7JnGaRd3atLxS0WlB1e7/BZJRjnLA QYqg== 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=94Kgj4XNRFYduQRTRfIrQIcXqS9keoQhSCwvILhnmSs=; b=gXCTVURj3Tid3SP3Zb+jxfouLfPZwwHujQSk5oBlcRssFL/UXIpnO8QWFtsvbCUDRl 40l/wa23Mqo4gHPTXVf+FOx31sILttyjLJVELUKFxdtKTNO2nFHd0N9179/HhXUUjKyU 4mNCNRuBLr2e/PVZeracyHT2lbmW8l5/DzaDpRY9ioQThwxoRI0OhFXGjH8l2epXaKqN OMXLzFw4t1twauO4OtnIfRKAzcGn+Oj07bNC9OWyoA7rrUsg6lCqw6EbhctINSm3+6J2 uZM1pSf6eNnvMqF6YpgQsBbadAxxGdM52BK67+lnYZdfL8Lrbn/pTuJKeX2xdODWKJsJ ZHSw== X-Forwarded-Encrypted: i=1; AJvYcCU0J/nirxgvXtfCu+cL2oCSeQc8Kg5kG7r/KkW4snWcbfDZUIMYObhBh0KQV0RPNB1FCpLyLx+2g0P54QKc1mxlXi+mLRYmIvRbLOCH X-Gm-Message-State: AOJu0YzCOJwiG8cKa87b6JXO3SNluhrRFel/jp+gsIrIfdH0TMBJCuO8 4emHipcvB31vAHspmtT/+KMb+F9jrNCX76JLdCURf5k8bAzWj7jj/UtOwhF4Voz35R9kcjgFwLQ jmtFh96q8E4yo8D34g3naSJLNufbyYSi0 X-Received: by 2002:a05:6000:248:b0:34d:b605:ec68 with SMTP id ffacd0b85a97d-35526c37d2emr2209418f8f.17.1716575275087; 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 ffacd0b85a97d-35579d7beacsm64758f8f.21.2024.05.24.11.27.54 (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 07/18] dmaengine: bcm2385: drop info parameters Date: Fri, 24 May 2024 19:26:51 +0100 Message-Id: <20240524182702.1317935-8-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Stefan Wahren 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: Dave Stevenson --- drivers/dma/bcm2835-dma.c | 83 +++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 43 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index d6c5a2762a46..e2f9c8692e6b 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -287,13 +287,11 @@ static void bcm2835_dma_desc_free(struct virt_dma_desc *vd) 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 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) { size_t max_len = bcm2835_dma_max_frame_length(chan); @@ -302,7 +300,7 @@ static void bcm2835_dma_create_cb_set_length( /* finished if we have no period_length */ if (!period_len) - return; + return false; /* * period_len means: that we need to generate @@ -316,7 +314,7 @@ static void bcm2835_dma_create_cb_set_length( 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 */ @@ -325,8 +323,7 @@ static void bcm2835_dma_create_cb_set_length( /* 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( @@ -352,7 +349,6 @@ static inline size_t bcm2835_dma_count_frames_for_sg( * @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 @@ -360,22 +356,24 @@ static inline size_t bcm2835_dma_count_frames_for_sg( * @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; @@ -389,6 +387,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. @@ -402,7 +408,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; @@ -410,10 +417,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; @@ -434,7 +443,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 missmatch */ if (buf_len && (d->size != buf_len)) @@ -682,9 +693,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; @@ -696,9 +704,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; @@ -714,8 +721,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)) { @@ -738,10 +743,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; @@ -757,13 +760,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; @@ -814,10 +813,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.34.1