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: 13673528 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B11B0C25B74 for ; Fri, 24 May 2024 18:30:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DtSJwB+o3IrlWmOUlv3jlWEYTojij8PyYwa/0EUp6MM=; b=fq1c+o4ydJvPar ZKbmrtIWm8DaFJZHhJz15b/2CsyDvwxs/9pMlqM26FG9dj39Wa6NW7V3a+hi0U/7sMX/iGSbYrX3m FgT8fPK5NjtVBkTiBY5804QZGXcexOsktyh9hPnt5zsL+/27Tq1ryuN0ootv0+wZj8vPGPU4J9fOG T3JN4ia8SWaoIhIBo5emROEmoud5EdSI/BznNVuHP3absGS9tv4gnOVgr6v/XhRmKQX29u23nTV36 iaQSBFu8s9bIUVwDVWd74AOJiErys5pGKF5mTTUJ71y0m+4OKsKPnLxplemcqZcSeiprg9C0QOuZs NPszYSM7KEuQs+myL11A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZgO-00000009apA-39ur; Fri, 24 May 2024 18:30:25 +0000 Received: from mail-wr1-x461.google.com ([2a00:1450:4864:20::461]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZe2-00000009Z8V-393W for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 18:28:04 +0000 Received: by mail-wr1-x461.google.com with SMTP id ffacd0b85a97d-35507fc2600so1076457f8f.0 for ; Fri, 24 May 2024 11:27:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575274; x=1717180074; darn=lists.infradead.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=ZaMBgqYECL3PX8hdKw9RaxFPiwzRNHtOab4H2Jq9KRW63Kn5Tkf+Z2SIprSF0B2tIO H8h3LBZ0FZCawHKZ41t1zU6yGkLk7q63+GNezrq/CmKL0JV87jUvLUDC3Bnlg81ZqV2D 3S6wazEDxLhH2+IMJ02PCqRbzItI0dYyIywnhkEP9Ms1y5L6L4oqlefF21jtP00exQJ0 5DYjytHBf3rYTD4N9daeVfwF1AUmAA3bbmRugb6HZBTj39vjNKqmivWD4sSyrh5iY5ph PAhpvGQTp+o8G0gJ3cYGvZoV/QbTCEmHsZMyAJx1OIBby2QN2DYon1tUmViX/pxxKNk+ 27eA== 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=bz3yq76Gce3H1hEyxFGjXZaUw843FWCSNPyl+z6uA6CpEDw4mE/vMeb2B6CRrHdtrd Zoyhq+Yb5skawQz86XrxAPKYlAAsZzt0BfmKPOd9vnMibd45+GUl9NG8CQg/w6Eutyb3 ngjN1TAxRNhPzOOfHvQd0LNuYUQB5QizBXTweEFCVMtzF95XhiM+LNpRJq52+iIoCQK+ yg6M2R+s8daXYAnxUdNXCmPykJFscouIIxaF1IgIIluSKELgOCiPeEG8hR82XW2qKUbK jALSAqyY3RjLJ1o/EwEp84LNnynqGFg27NgtOUH1ziDFDY/OmjiX/n6E8WCQpllrjKE6 Avtg== X-Forwarded-Encrypted: i=1; AJvYcCWNLyqAX5d5GFfuZfedfGshZH4+7aBtb6aBkLHWnLQPErPpdxKuypiRXiTx/n7iTrKH0AB4+f3P1DnwXr6ygdtYw6liJZIT0OpZuZm4Dd+1RpsEkEE= X-Gm-Message-State: AOJu0Yxk0dBpFxcC3+dOel7aCKYENjF72/XLNn5mj4SR6c/RWuYRXj9O BbY1p+wRp6BSSp5t+kfDw7cfhtitOtLgj/8l1M7Lh1IcTipnfUAq1eiubzt8bGhqM0Ajbp9wpWB ElspDyoh803LhvMgR7R4ZxvK9fLdf5kqs 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_112759_130398_308EDB0C X-CRM114-Status: GOOD ( 17.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 */