From patchwork Wed Mar 13 14:08:33 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: 13591457 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 AACA8C54791 for ; Wed, 13 Mar 2024 14:10:27 +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=NloihU7prmSn7ZCo+AfdozgHMAI+82iBfShQUdwndUg=; b=ICc2Xe68ZajqN0 ygU91ociRYypfuNTdXKFFSzRlOtEpSq0Fx2ySN9WZaSztXDvwSdbunirGFnBMta+GcwlH0ttElb49 iqZ8dDhLihS+WOodCb9mZLDY6uPzJRAFrkC15s7cFeoQ1+HCgMwOzZfQKfjS2iKunZcp/brsjqpsp Go3b420nbFwN21LdPQKOO8YhpgQine1Jqw7UoltZmoLiUvguE2D45FvyDrsn5YdxeBxwsJgy09crH XWvuFTDblrSCtgsFkW1VulrjMR7uoqWGqDQ7TB7LVYx+Nmwlwjdlng9L/ErGlAJTvuYrSuNUKqJvv abJi2uiMtBlQFD6bk0KA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPJ5-0000000AMzk-2lMs; Wed, 13 Mar 2024 14:10:11 +0000 Received: from mail-lj1-f174.google.com ([209.85.208.174]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkPI3-0000000AMDq-3Dig for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2024 14:09:10 +0000 Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2d094bc2244so101805281fa.1 for ; Wed, 13 Mar 2024 07:09:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1710338939; x=1710943739; 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=/xE94iw3mEagAF+/7KUdjRC+1ga8rdDd3hiFvVOScHQ=; b=WO7eOVFzGSLc/QRczd0cmTobP5baazUVGZV07L5fqGRiRjnGVMYCc/ryW9L/msTXQX oD88h/RPc2ha7ejzk9+2GP63wD1u6v8JcB6DSKK7Arnod9ZRp/bNH2QC5ZvS/SDSHuLh 2X6DxH2htZi1MCbVWlSsD20zU8Xcv7CNM3T6vDl5TE/LB6pBDkZTHm7hKIEKpPwfDY3+ BgA6S+hnfp022l0Rq7tmv/7xfo1oBvs+b45AM5Dg6pMoRffB9n5XG1V6UtP9eJQV+PKQ 0k7VQHs/G6MXH8tKscvSwYAk7jPZYHe+08Hp7OV/lBrqUitIGZCPXZnpeAlz8eTJgEVt R7jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710338939; x=1710943739; 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=/xE94iw3mEagAF+/7KUdjRC+1ga8rdDd3hiFvVOScHQ=; b=HDf7zVGnV2qCl6hIZABLVQ96WLM2MNq9KPTUtsB/2W98b56RS+GjmGZaHx4GrK9MjR abLArovMFuw6w7ZTJAN34CazrEz3a76EqySL4RIiJinguYQMnxYYbU+s0TZyY5bRRS69 zosjuQKAWQh/wjcP5cTJfTTJq6EvXbO8Io1JDMrqJ7v2lCCJ4i4pZ1KWuFNuMNJTQsdK zzla+urbb6g35lV+ZbGnFpvfmQ6qqelHF3aG889IG+JX4CQcHDRbjmKnl115chHpD0K3 A0vOdyBisWfSSQHPr74RZKtF3gfkTH8S1dGnhkKLhIzTtm+vlEXOytKWMURx7a5IjHNC vpVA== X-Forwarded-Encrypted: i=1; AJvYcCVdfo7SBd53vGYf+uVaNU7JjSAnabWXwfEsJ8Lc547i+V/pdLVEwboijWFTWwU1g5yAv+Ipw1rVVnQRUw8SBUMDsn6EWNJSFtuOrQJm8DNzHHemEPQ= X-Gm-Message-State: AOJu0YxtlDXDSic7TrpXQOkxQeZo9IQuYW/RLqpG04BB4NvpMIt22AfN uW2GKOWOTdQEs5C2LHTV9Z41XnbLOm0dkOsrijLYGpEtIcY2rjXnB4b7WUtyqZM= X-Google-Smtp-Source: AGHT+IGXCM0cKznBWGqJ434M1t+ZyGCueMZWhnfsJta91SqnLtQTo1W4zmpjpEXIYq8BRQy0a3lQ5w== X-Received: by 2002:a05:651c:222b:b0:2d2:751f:abb2 with SMTP id y43-20020a05651c222b00b002d2751fabb2mr4008668ljq.3.1710338938746; Wed, 13 Mar 2024 07:08:58 -0700 (PDT) Received: from localhost (host-82-56-173-172.retail.telecomitalia.it. [82.56.173.172]) by smtp.gmail.com with ESMTPSA id ck14-20020a0564021c0e00b0056857c89045sm3228556edb.60.2024.03.13.07.08.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 07:08:58 -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 08/15] dmaengine: bcm2835: move CB final extra info generation into function Date: Wed, 13 Mar 2024 15:08:33 +0100 Message-ID: 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_028559_2265CC3E X-CRM114-Status: GOOD ( 14.95 ) 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 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: Andrea della Porta --- drivers/dma/bcm2835-dma.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index c651aca363c2..b633c40142fe 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -254,6 +254,26 @@ 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; + } + + return result; +} + static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc) { size_t i; @@ -685,7 +705,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; + 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; @@ -716,7 +737,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)) { @@ -764,7 +785,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; @@ -780,9 +801,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; /*