From patchwork Fri May 24 18:26:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 799170 Received: from mail-wr1-f100.google.com (mail-wr1-f100.google.com [209.85.221.100]) (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 E79AF42058 for ; Fri, 24 May 2024 18:27:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575283; cv=none; b=K5NhWcotgYIPj4qfROwZQUrdnaU0u64/rR5R2RmuLSxpnLaQE8MR9x+CQPnCYpIzogi5xDqVLFuNyl3fMYLwo6fTJXKI6Fp8r6LL23+xzjgLHiXGXnO5VZFRQiQC0JChM9MQCmUjy8Mgye3mln0MvExJs+x2H3DrFt4pOaqqfLc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575283; c=relaxed/simple; bh=nfU4i7o8p143//pVAQIuLJreZUHivVRGYWOYdCfqYIA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tfuYzSERzNtS1QAUvo3mAnpl+Vo+S/yHVYqpKy2y1X2KfvnpxeqdkKMuUErNMxcHkVzU7bGkSxDhPqyAAzIpWjC+cpoiwo2z7AEF9izKrSmqNgUZsyR0RvlBonG/eh9UGV20Fk6pkGkqdBwmqz7qcCojxAUttO3t3uVwURM6DXg= 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.221.100 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="eZ6RhjaH" Received: by mail-wr1-f100.google.com with SMTP id ffacd0b85a97d-354f14bd80cso2166806f8f.1 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=Xtf95hAJExhImXmSMhyPEGq+/iNEs/2Yz74xB2EegCJFW3B2rfgwqajvFhdoioR2cJ b/eY6fiVQa5NRNeykQcdtoW+iPM/odi0qgV86/IaRNYQxRFe3dzP9dOOKf6JzOkaYX3B 0DhADGyi0ZcOIfuWfq+49UvDwJaiZY8Hr9fypoL0GMTrap2QdbTBIKHazpTmcTNnYRhb sb/Yr6wqmhuV+fDU4LAHgK76bsmDMW69DnX7k0Jw1NmBc/zwzM25gJ6LSJVMyZSHEH1v NuAxZ9MJAfkAbtA4ISTf0QKo3y4ZtbFJ227tru+4lSBbBqmNu4j9yAoHVj/z9YGlUNSg g/4w== X-Forwarded-Encrypted: i=1; AJvYcCWpUHOS2ilzJGzxJ6lmbXzVAjTVBQE1TTKlje28RyOSlcMmSKcYMggxeZEko9zIpfHfuVCLH/ElC0v4uG2rNTs0mGLLqgp2bZSE X-Gm-Message-State: AOJu0Yy2u4s0cKkLUhv+7KtPCCjrvU15MZ1gSRAqJQ9d2ZsAc4qFCmOe u9YgrbpufrpORV6EbynOl39mDo8+HJhJYMP7g8M+Yr95WmfJ+9CovUQW4NWvgS0lhunDqBG1t9P HHg7K7+WF8B7ChznHCROXmSnS+ep7BFvw X-Google-Smtp-Source: AGHT+IG7AwSKXGWwm3Jk0PS/jS/c6HEpbiqG3nmvQrlTW240Q10yveOxPP4at4VICqmuogqReFECxtmY3Gqc 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-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 */