From patchwork Wed Mar 13 14:08:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea della Porta X-Patchwork-Id: 13591459 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 94BC6C54791 for ; Wed, 13 Mar 2024 14:10:59 +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=B5XkrnOWA9TIMyk+gTZSy12gZIBKMXIhjliMH3Pk/q4=; b=QfWxy5WxRK2oxk tZBwVF5c4HSmfoUIErfdgEiftuXHkAdJqHhD3TU8EFbmLkkZiOhJfMGXvdwKMAuVSfiibx+qeMxKM mieCtGoR4NaX+8RCsKcNJjAuc0airNPfmUkP/AfLFyHQQgHx+Ue4ba0H8plHE3944cAtJk8qbhkFw 6+UlDhw797Np21L+XNZDvz7VTfKIibzZDj4RvHa/d5GKBH5weS1wo1mQ8C4B0q6oYZtpG75ezinD7 OGqiwJB5w+BsWz6O22SWVmBoIpkL+InO+KIfYiHITnyQY4y9byrFT9Vi+6PseFolkfVURoiA/TllN v13ftHvF6vSDAUD36Igw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPJY-0000000ANGR-0TNp; Wed, 13 Mar 2024 14:10:40 +0000 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPI4-0000000AME6-1N0c for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2024 14:09:12 +0000 Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a44f2d894b7so140309866b.1 for ; Wed, 13 Mar 2024 07:09:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1710338940; x=1710943740; 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=2aA326qloufGfA/9FJeIrf9CjXOtqN0+M89y+6rWqCo=; b=A5Ap//1URw+2ZfEpL0OOMvGBx2lEIL2Ld0VaAy/jaEEgkNZA50O4EMUpoxSPSvqhvC 8xZ9y0xJyDRnt3dHOZULzX37Pa+dAwMVKcKkteXBWOPLhDOu7dgkgZa0U2EqBY6z2iBU +HeK0f8mx3h5qCP2fCGWiZzX3VFYKRoKT9OzqAaSJW2gTCs9GIkx8pWMXk9ZFAlevxMQ /lGnynUaX3DV28SYvcrSqqG6Mo5ilAwMWqLIlZjaJGGxl/yeAaJ3Qi6NuPZn+ePvUFs9 dFI8jlxb3S9uE6+SMwZDqcKYG04ez8QDldY+HOcf4ORET+qzj+LNhULrhvvJSih25qAH simw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710338940; x=1710943740; 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=2aA326qloufGfA/9FJeIrf9CjXOtqN0+M89y+6rWqCo=; b=Qm7kLOSFytUHRIU+q7gmKUIQUVKMOWAiI3qPNzmIG6WYY4JkNf1+Ei0UFkYxvWichv jA6XznKlPNr8eGR7x4dFLuZp08cYVeXWQ6LlhIPid0MYCTuikHFnoC2gtyoGDCzs2rxa 2UTnkSvogWo1Q15SxkDv5XDaeu5BwvoxM5rkOKw/juvp11LrthRQUrGxKQJvhE2X+xTy byvUV0NKpath9gReYJ68fSZ8TRFvv0JGfUzWooRca16aV6lK8sae16SaJiYn327bPhre 2Z0J5K0yM2IAu+78ENpTjUfGLHblOvuMiGFd8ienGcq3TSrbNzh7MnZtFSgz6NV10+RG PAAw== X-Forwarded-Encrypted: i=1; AJvYcCU2rSOGJ7RZOvrSWgSjHdovv2/oe3EYahwGgu+9kJfpW9ELKJddnkUizlM9ZNEFtSISvfWwby5CcnFph3ztFFG7Jzxekmkl1TegAgFyDriUj4NGfvk= X-Gm-Message-State: AOJu0YwhGXS5XFZ1f6JTDtsIE8gE0f+bcZRKlYz+/hXWj7J2JaKx6oi1 Pi5Ksowmi26BaxzvZLaG3B9Pyu5DTQlbnD8bQT4S1d1rAi+ukhf1zmKN0mZSQVo= X-Google-Smtp-Source: AGHT+IEctktss/OIn1LKfmqGYndGaQjoPtQ3Zxp8D5LODaIB3jm5ZeIbTiROFzeL2/JTnhkfLCvRuQ== X-Received: by 2002:a17:907:94c1:b0:a46:181f:c1c3 with SMTP id dn1-20020a17090794c100b00a46181fc1c3mr5229468ejc.70.1710338939952; Wed, 13 Mar 2024 07:08:59 -0700 (PDT) Received: from localhost (host-82-56-173-172.retail.telecomitalia.it. [82.56.173.172]) by smtp.gmail.com with ESMTPSA id l23-20020a170906a41700b00a440ec600e3sm4885228ejz.121.2024.03.13.07.08.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 07:08:59 -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 09/15] dmaengine: bcm2835: make address increment platform independent Date: Wed, 13 Mar 2024 15:08:34 +0100 Message-ID: <0bf87ad0dc970c34199fd6bc6dbd19b47d382066.1710226514.git.andrea.porta@suse.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240313_070908_477106_770EE244 X-CRM114-Status: GOOD ( 15.89 ) 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 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: Andrea della Porta --- 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 b633c40142fe..6f896bb1a4fe 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -274,6 +274,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; @@ -355,10 +373,8 @@ static inline size_t bcm2835_dma_count_frames_for_sg(struct bcm2835_chan *c, * @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 @@ -430,9 +446,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 */