Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp740674lqb; Fri, 24 May 2024 11:38:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV+VInmrXEPl8TfmEnTDDLQsdGJV4eQCJJumHYHhYyocxfh1bBTbolot0SOtHaSSKdkVLl7mzHuAgjfmIFfr29VL18syQYOUXY2l2L8/g== X-Google-Smtp-Source: AGHT+IGQVMr7cH7mFVJzfE2LoBlmv4Up87gI3tG+QZkl5q2Phu6P7qOreRJBVg7jrKELpSdO9E94 X-Received: by 2002:a05:6e02:1d0b:b0:36b:1e1:552f with SMTP id e9e14a558f8ab-3737b31e62fmr35159525ab.23.1716575891060; Fri, 24 May 2024 11:38:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716575891; cv=pass; d=google.com; s=arc-20160816; b=JQITVFdgjJP8BeJplQH4viUaELRI4C3bfsD7Fk0ZyeCe35aa/bS7IihH9TTP25DcFR w4QEV42PtxVaja8xV98vJunlSNjfYSEbpM2lrYh0iMXp5sfbi5WoDXsE2GSmP/ASIds4 MflRyZp1DYFHvCjpx/WofMKSsq1jWwchx0KeKvu5hcRaGtSHyw1cCEQc9jho4zg/6JZq ojf2R+y19X20DNODt6guECGVISuyNFsHP3KZXIXXBYv/aSupV1AwYAxJVMh0kEpC4mqa aeKbM25HnXCzy0A3AE5ucyBAr2Hq8TkSRqUvAFIJwAaDbxt+ke2jfeNp4Inr9yXJlYlY TT8g== 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=2dAf5h5XwHiWp+dmoS6JsUC+O9MVsTne143uCle/zUc=; fh=0qQ3eF34f3C2UCFH8CztbavM82iE2TNAtopDy47bgPs=; b=zEaLCWwsxIjBBs6u3QH7uK0hLtvpkAWqJuxRdvB5DLPO8KYBV0TOZeYontpdZjuIL2 O+TaEyq72J2i+LTCqkZvwulqgkSPkodNzbUbpAQv80Uo8qM+BtfRCFK32vyUBzBgN3lG +Oj1lnd3xknf6RW32xbobotBUFBDOXLNGL5rkhGy7U/LRxpxJUi+xCQyDrDbq5cBU7Id alorcAXwucgwJgVdbaQ4AKJdn+OwiUM7ek+8ZhNWTkcCj+rjaIaIZvGv9yk3i8OT3tPx bu26QelAj3hDFbcHOUtaKAlWnXjBKpojHrn3csDV+6LQPkB5k1GUpwyD5r1Z4Ei6hHdH 156w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@raspberrypi.com header.s=google header.b=eZ6RhjaH; 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-189001-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189001-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. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-682289de4f4si1654479a12.530.2024.05.24.11.38.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:38:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-189001-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@raspberrypi.com header.s=google header.b=eZ6RhjaH; 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-189001-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189001-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 398A3B222D4 for ; Fri, 24 May 2024 18:31:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D2FE86656; Fri, 24 May 2024 18:28:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="eZ6RhjaH" Received: from mail-wm1-f99.google.com (mail-wm1-f99.google.com [209.85.128.99]) (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 7E1483D3B8 for ; Fri, 24 May 2024 18:27:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.99 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575281; cv=none; b=Oym1dYqmw6jqUxkdoB6ii3DruSl22avzkvq0DQnIaPIFUAM6588B7CBqQQFcCBFTGrUtHh7bkY0H/a5DTQF5HoVFeeXpQv9lBB/GQBnCLvNEuAloQi4VO1LdGnDubSadAY8zOOaqx5ov4qfuAZMD98zLCJa0GLcz48p5Sfe7tm4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575281; c=relaxed/simple; bh=nfU4i7o8p143//pVAQIuLJreZUHivVRGYWOYdCfqYIA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qw5/SpWas7udHO2+p6xHCVeThaHeciV2igqreNYBbwf2QVWAi50tcC3aeZku+zzAxJ8g/ORJPGc9Vo/8J40i7hmM7LgMbV1RICQZllXRVEs15U5JBQHKjT6UVdo7t3Xw5fmrmzcv9jlwglz2Iv2KqZcu14ff2criT+Bal9tJKe8= 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=eZ6RhjaH; arc=none smtp.client-ip=209.85.128.99 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-wm1-f99.google.com with SMTP id 5b1f17b1804b1-4202cea9a2fso33253405e9.3 for ; Fri, 24 May 2024 11:27:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575274; x=1717180074; 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=2dAf5h5XwHiWp+dmoS6JsUC+O9MVsTne143uCle/zUc=; b=eZ6RhjaHWn7JAwBMH3CDTN9O3tUGAubZo3Q5rnemb2GnpUMXGD/J7rY/ho0nnrYRof fKYmq97Yai6JC7D/2b6suH3E+kY21hQr0DRSR4FnWZ76bWUmz3f+VMfdKdnRCd1qK/mo L9o2+IqFsf+9nRwq5s7lz3DpKsyaWJnpXl9rH1Zs+er9AFMTy7kwOhuDeb16qZAifCPj WAJGlvHghsGMY7fSWf5shWzjliTfD4uvH4Q15g9O5q//ZCvpFZ/i32ODtqcogCbT8Vvq JuhxQXUvIseKuZXb1pOpft7ohXUOW1Nn7NRCl5xkXtGQDJluYo0cCXHcXe3jsSqyllXy qfpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716575274; x=1717180074; 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=2dAf5h5XwHiWp+dmoS6JsUC+O9MVsTne143uCle/zUc=; b=SEUoJSZA1YgHFkCpLrGrARzSkExzFbEWPg7Dt4gz1vIP8epSLV+V3Ay6CH6qtr2sDx vw/1xheS25apSUgJvhe8GNwvKWMBUg6D5A45JOIPX4ZUhdwjjRv+5RzBW9dkB5w6W04I 0Pz3mE2HlqsNuONnKUkpjARRuZQsSfXBIXh+tMaTekoUsx85p87n7KPOjzer2kkgmOZe X0GUlCNXBw64sPsVwjgwNmG3X3IWFYhMXmIT+qsnT0s3vpvU0EQ4UNsFLvF32WKMM441 HwLVyuSIKauLpFUBlk9rl7eupGrWaHxmemWbQm67JBbKa4y9vHLYiNX1M/M/kXLKKYdE TsKA== X-Forwarded-Encrypted: i=1; AJvYcCXYZBdFI13FX4i3SgrICkO0HvWA2cfmC795f3cwmiPOZgB6F4JEsZXkg9t4RI0Gy1ND6nCJ9CEL0LwrzFnkwb6vYUxD43c7gzlHi+eo X-Gm-Message-State: AOJu0YwHO1g5PujIvM7Qp8TGKZ80lfAXExLBWdKrAlNNVLUqA2C512XR zzzLEJepcbhsIfpPm7IToYevJnC6orYqVzEZ/oDWXZF+EwO6Vd/ddS+7bF/+GABh4raj+mRG61M cZRe04ritEB5QRBu4HtpYLcIIER3SsKgr X-Received: by 2002:adf:f746:0:b0:34d:bab1:26eb with SMTP id ffacd0b85a97d-3552fe17476mr2052052f8f.68.1716575274538; Fri, 24 May 2024 11:27:54 -0700 (PDT) Received: from raspberrypi.com ([188.39.149.98]) by smtp-relay.gmail.com with ESMTPS id ffacd0b85a97d-35579d7c6bfsm65665f8f.22.2024.05.24.11.27.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:27:54 -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 06/18] dmaengine: bcm2835: make address increment platform independent Date: Fri, 24 May 2024 19:26:50 +0100 Message-Id: <20240524182702.1317935-7-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 Actually the criteria to increment source & destination address doesn't based on platform specific bits. It's just the DMA transfer direction which is translated into the info bits. So introduce two new helper functions and get the rid of these platform specifics. Signed-off-by: Stefan Wahren Signed-off-by: Dave Stevenson --- drivers/dma/bcm2835-dma.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index ef452ebb3c15..d6c5a2762a46 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -252,6 +252,24 @@ static u32 bcm2835_dma_prepare_cb_extra(struct bcm2835_chan *c, return result; } +static inline bool need_src_incr(enum dma_transfer_direction direction) +{ + return direction != DMA_DEV_TO_MEM; +} + +static inline bool need_dst_incr(enum dma_transfer_direction direction) +{ + switch (direction) { + case DMA_MEM_TO_MEM: + case DMA_DEV_TO_MEM: + return true; + default: + break; + } + + return false; +} + static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc) { size_t i; @@ -336,10 +354,8 @@ static inline size_t bcm2835_dma_count_frames_for_sg( * @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 (if the S_INC bit is set - * in @info, then it gets incremented) - * @dst: the dst address to assign (if the D_INC bit is set - * in @info, then it gets incremented) + * @src: the src address to assign + * @dst: the dst address to assign * @buf_len: the full buffer length (may also be 0) * @period_len: the period length when to apply @finalextrainfo * in addition to the last transfer @@ -408,9 +424,9 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( d->cb_list[frame - 1].cb->next = cb_entry->paddr; /* update src and dst and length */ - if (src && (info & BCM2835_DMA_S_INC)) + if (src && need_src_incr(direction)) src += control_block->length; - if (dst && (info & BCM2835_DMA_D_INC)) + if (dst && need_dst_incr(direction)) dst += control_block->length; /* Length of total transfer */ -- 2.34.1