From patchwork Fri May 24 18:26:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 13673532 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 D35BAC25B79 for ; Fri, 24 May 2024 18:30:42 +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=uavjb5KmyXJ/361zZoVk9DhM3qrkxPefb+RkdzVrRd0=; b=dUtuJAN4t5uWY1 PwsUiES4flMYVNESjQXsuyrsrT+bvw4J9WYt1o+2/A0ZehcKA+qs625T/lQ1ot2aV9SasLaK+/wfO MFTrJqctUO2r1TcVIoQ3y57x/xsV0NHtkyRzJSZgmE/0vpGlQWHxfUer8/D4Qq3CF1kdvBm2Xn76h oJQjLANDqmALj0dyDGiL7DkHGUcs1lp6Wrueh7b+5cpD+MhQj5aBTd03YPBNeo9AX09xDQBsK+vh9 DCVPbT4qOPZFFxFAjdkP/eGr3Ul5PWF5UYbYv0lCBt38mVS732fx1bXRvZXAfDHauTQvy8GM8rjbZ B8JP1XjtihPF0C5pGIRQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZgU-00000009at5-19rU; Fri, 24 May 2024 18:30:30 +0000 Received: from mail-wm1-x363.google.com ([2a00:1450:4864:20::363]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZe2-00000009Z8T-39lx for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 18:28:09 +0000 Received: by mail-wm1-x363.google.com with SMTP id 5b1f17b1804b1-420180b5897so31804645e9.3 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=iWDOi4FnuIg8+afcsNOQvw2Jh+B2uESuovEt5c+znUw=; b=oCCz9dJTHdxAWu1OiE+zHYd8/RLy1KzDf3/y/S594gYFKcwzy8eL0aHPoDgwUFSY+I RZUJNnWTB3Ucb59Ef5uT5TPO5lRgaqhE1rzAiSZbxww/H2AwZHOL9p3vWYNwcLEHzq1U L0RxTMx+FPj6k60AyAoOifAevBDAJXW6VxYhMvR9GxsGxtv6Z87oqlikkerxmdZ4H6h8 zBVd6YZN/QFpWR8nrQphicK4KEYmUaB0zixQa6iL7voR8LMlc2qBsnj/MUTDkD5mU7Pe Y2B49g90nyhSSNsfeDTSMZ+mmQTaKVfvsHamgvrH/ld69XFm9aiaRqhkFKn5rm2lN3UW sHww== 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=iWDOi4FnuIg8+afcsNOQvw2Jh+B2uESuovEt5c+znUw=; b=MQKnNp7FPsiaLpGPSIwT9sG5JIHSaepgUAr0rkvCJtxhTJvY6iHQo3hrtDcm2Xp3GP dOPEuNBv5NzOqGkQXZQjI89iM3lF2Vmc9JTGsDMgbXFa9GrL9OF5THNSzlAuJZ7SH7wx JWvj4UgbUmh1h9hJH0v0/yvt4wEGtJVijbubXB+4mj38BPF91w5t1p7sbCs8r91bVMHX Svj4a/Zg5g7jsKl2VmnPBE1U0/O7eGifw0MIe484dLNENp40WUp/x4rdNv0AHtzPYL8H BtHQojIw7sWux+S1wIu5Y/2PrRzA9mVu7Bqkt0MC22acQbWYTRgd80R7MRE7VgBbZUa9 ckYA== X-Forwarded-Encrypted: i=1; AJvYcCXomWKo99c0tuqgeOB03tVs7hh49WVfvuPSJdvD23NQj5QT0R1DBfvdceaXNrCKn+lqqkcaTs9UFcYSTaZqPlyWmtt8UvYVZR9/W1ANAgq5MepDEds= X-Gm-Message-State: AOJu0YyQKtzQ8T9V4mrfstV8lcgNjuG8xNQBMZDgTMbEnc1DxjVz4iN0 7lQ/e37YoGasvUtk/d/pBN5Reb/0RM8HDHxIdcvGSSsju/BQyP/04ckM+R4KuWlNo8kRACnY06c C0HXIuZdUKtDjnzSPQZYLRW18AUd8m78+ X-Google-Smtp-Source: AGHT+IGIsyeooWRqeftH29E3jxJT2At/nTJ1Uu/BdgAMBJJVRNDQOp3tq7uahyaHfy6aSgJSk6q/Wsrk7a1Y X-Received: by 2002:a05:600c:314c:b0:41c:5eb:4f8f with SMTP id 5b1f17b1804b1-421089d7c33mr24729315e9.15.1716575273960; Fri, 24 May 2024 11:27:53 -0700 (PDT) Received: from raspberrypi.com ([188.39.149.98]) by smtp-relay.gmail.com with ESMTPS id 5b1f17b1804b1-42100eeb86fsm5721785e9.4.2024.05.24.11.27.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:27:53 -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 05/18] dmaengine: bcm2835: move CB final extra info generation into function Date: Fri, 24 May 2024 19:26:49 +0100 Message-Id: <20240524182702.1317935-6-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_112804_090811_A75D7A52 X-CRM114-Status: GOOD ( 16.37 ) 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 Similar to the info generation, generate the final extra info with a separate function. This is necessary to introduce other platforms with different info bits. Signed-off-by: Stefan Wahren Signed-off-by: Dave Stevenson --- drivers/dma/bcm2835-dma.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index 7cef7ff89575..ef452ebb3c15 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -229,6 +229,29 @@ static u32 bcm2835_dma_prepare_cb_info(struct bcm2835_chan *c, return result; } +static u32 bcm2835_dma_prepare_cb_extra(struct bcm2835_chan *c, + enum dma_transfer_direction direction, + bool cyclic, bool final, + unsigned long flags) +{ + u32 result = 0; + + if (cyclic) { + if (flags & DMA_PREP_INTERRUPT) + result |= BCM2835_DMA_INT_EN; + } else { + if (!final) + return 0; + + result |= BCM2835_DMA_INT_EN; + + if (direction == DMA_MEM_TO_MEM) + result |= BCM2835_DMA_WAIT_RESP; + } + + return result; +} + static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc) { size_t i; @@ -644,7 +667,8 @@ 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_INT_EN | BCM2835_DMA_WAIT_RESP; + 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; @@ -675,7 +699,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg( 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_INT_EN; + u32 extra = bcm2835_dma_prepare_cb_extra(c, direction, false, true, 0); size_t frames; if (!is_slave_direction(direction)) { @@ -723,7 +747,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( dma_addr_t src, dst; u32 info = bcm2835_dma_prepare_cb_info(c, direction, buf_addr == od->zero_page); - u32 extra = 0; + 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; @@ -739,9 +763,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( return NULL; } - if (flags & DMA_PREP_INTERRUPT) - extra |= BCM2835_DMA_INT_EN; - else + if (!(flags & DMA_PREP_INTERRUPT)) period_len = buf_len; /*