From patchwork Wed Apr 5 14:08:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13201807 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DBD4C76188 for ; Wed, 5 Apr 2023 14:10:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238079AbjDEOKr (ORCPT ); Wed, 5 Apr 2023 10:10:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232562AbjDEOK0 (ORCPT ); Wed, 5 Apr 2023 10:10:26 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 189AA6E93; Wed, 5 Apr 2023 07:09:52 -0700 (PDT) X-IronPort-AV: E=Sophos;i="5.98,319,1673881200"; d="scan'208";a="158393597" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 05 Apr 2023 23:08:58 +0900 Received: from localhost.localdomain (unknown [10.226.93.81]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 232F442D781B; Wed, 5 Apr 2023 23:08:55 +0900 (JST) From: Biju Das To: Vinod Koul Cc: Biju Das , Lad Prabhakar , Geert Uytterhoeven , dmaengine@vger.kernel.org, linux-renesas-soc@vger.kernel.org Subject: [PATCH v2 1/5] dmaengine: sh: rz-dmac: Add rz_dmac_invalidate_lmdesc() Date: Wed, 5 Apr 2023 15:08:38 +0100 Message-Id: <20230405140842.201883-2-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230405140842.201883-1-biju.das.jz@bp.renesas.com> References: <20230405140842.201883-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org rz_dmac_terminate_all() must invalidate lmdescriptor in order to reuse the hardware descriptors in rz_dmac_lmdesc_recycle(). Add rz_dmac_invalidate_lmdesc() so that the same code can be shared between rz_dmac_terminate_all() and rz_dmac_free_chan_resources(). Based on a patch in the BSP by Long Luu Signed-off-by: Biju Das --- v1->v2: * Introduced rz_dmac_invalidate_lmdesc(), so that same code is shared between rz_dmac_free_chan_resources() and rz_dmac_terminate_all() for invalidating hardware descriptors. * updated commit description. --- drivers/dma/sh/rz-dmac.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c index 9479f29692d3..81e72529f7d3 100644 --- a/drivers/dma/sh/rz-dmac.c +++ b/drivers/dma/sh/rz-dmac.c @@ -236,6 +236,16 @@ static void rz_lmdesc_setup(struct rz_dmac_chan *channel, * Descriptors preparation */ +static void rz_dmac_invalidate_lmdesc(struct rz_dmac_chan *channel) +{ + struct rz_lmdesc *lmdesc = channel->lmdesc.base; + + for (; lmdesc < channel->lmdesc.base + DMAC_NR_LMDESC; lmdesc++) { + if (lmdesc->header) + lmdesc->header = 0; + } +} + static void rz_dmac_lmdesc_recycle(struct rz_dmac_chan *channel) { struct rz_lmdesc *lmdesc = channel->lmdesc.head; @@ -437,16 +447,11 @@ static void rz_dmac_free_chan_resources(struct dma_chan *chan) { struct rz_dmac_chan *channel = to_rz_dmac_chan(chan); struct rz_dmac *dmac = to_rz_dmac(chan->device); - struct rz_lmdesc *lmdesc = channel->lmdesc.base; struct rz_dmac_desc *desc, *_desc; unsigned long flags; - unsigned int i; spin_lock_irqsave(&channel->vc.lock, flags); - - for (i = 0; i < DMAC_NR_LMDESC; i++) - lmdesc[i].header = 0; - + rz_dmac_invalidate_lmdesc(channel); rz_dmac_disable_hw(channel); list_splice_tail_init(&channel->ld_active, &channel->ld_free); list_splice_tail_init(&channel->ld_queue, &channel->ld_free); @@ -537,6 +542,7 @@ static int rz_dmac_terminate_all(struct dma_chan *chan) rz_dmac_disable_hw(channel); spin_lock_irqsave(&channel->vc.lock, flags); + rz_dmac_invalidate_lmdesc(channel); list_splice_tail_init(&channel->ld_active, &channel->ld_free); list_splice_tail_init(&channel->ld_queue, &channel->ld_free); spin_unlock_irqrestore(&channel->vc.lock, flags);