From patchwork Mon May 3 15:26:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Ranquet X-Patchwork-Id: 12236293 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MISSING_HEADERS,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63154C433ED for ; Mon, 3 May 2021 15:30:15 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AE35561073 for ; Mon, 3 May 2021 15:30:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE35561073 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Cc:Subject:Message-ID:Date:From:MIME-Version: Reply-To:To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=tXH2nONZ+6JWviTTMsykov4SVZbsJqnyULp/FT44CSs=; b=AluBxZOk5uE5jn Kg+0IkE2sjlOcsm5QlpiBmOUj+hxF+PMbPKPCTlgPDOm66wgv9tXoNAXYNwBQHYKC1D9f36jok0hq /g4woOT4pEf0Zv/iGRO7fqp+RPXzahYYQX2LnbySkv1foteeGZXIGeOxGRS5ACkuodbgklNHCrmUn 1saqKm7kpOrMoa/T12OjDq4tROALXxPMhnn70NkHX2rbvtrrnU/wrHG0OsciB+rrqRGhhWRkuDqWi +3cwB7E8bMc+BlOMOTWh/52XP7ZgvCzp9w24Y+vI3eOWseN8LcTcMmTLmJnJ5fXf0/o6gjKoLV2Pe 9DMT/GcKISzBGwPI7eig==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1ldaTc-00EECs-St; Mon, 03 May 2021 15:27:20 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ldaSz-00EE6k-7B for linux-arm-kernel@desiato.infradead.org; Mon, 03 May 2021 15:26:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type:Cc:Subject:Message-ID: Date:From:MIME-Version:Sender:Reply-To:To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To:References; bh=+0TCMPSPgNnKaQLcoOaFiNFXoz3PHgbrfotliZuGoqU=; b=Gv5l6T9OdC1EPFiPZouWCIwjCN dTzNVmvSn2w7TdVOUTnLME32skB9oEGmatWn2YovWUPSO+hZkFBxpkhGdWfioYilD7K2xtsSGD15+ VfA7LaS7vCQq+33cxgEkzQBeZQZNYE5tcf2F7PlhkaQA0BvqBY4/TR8pR2ICznaj7qLQUJB8R8dVO PFMobeWUaGL7z1E9xgIw3dtrVtnutQEBVMv7jte69J/8m3VYslKPv6+bHHk+S/LvI/XXUH++zMpt1 6onsNnGTsIVse9CU9ceqP4AWUWn+6rDmlUCDTdcXK7U5F/d2lQlyTsWvi4fl95ySNMBHpnaxIbWfc PikiLvZA==; Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ldaSu-003Aun-EY for linux-arm-kernel@lists.infradead.org; Mon, 03 May 2021 15:26:35 +0000 Received: by mail-oi1-x234.google.com with SMTP id t8so5772491oij.0 for ; Mon, 03 May 2021 08:26:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:cc; bh=+0TCMPSPgNnKaQLcoOaFiNFXoz3PHgbrfotliZuGoqU=; b=z7g3kLcgZlbrRBtb8CCRI1h9u/bLF74VDrbBqfM72Yarr8dimSBTyLlvUTL1zBDjYN lUG3Ju6NPYHf5r9ez9mmShBUiODfIb5zLctDXgickNqHAmb9FYvkTtbaOcAeSCmLL6RF g72P90/Eo9OBv9wMPqHUnoSlImhyJfoORfu6cs4gBVwqyJXzTp2GrVLfydcz2RZQVVPy X1wtYXCDqm3Ak2HWImonIZaWp9hRBpxduRgoVQttGQLnLOArw9nGHcD8De5dH1AqtumN QR7EGAOUt+E3AHUmsk8vYJC1ZN+G9VKPvxF6sHmUrxXfgZT/HGfEYUWIKp+TTwM6dhES kMBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:cc; bh=+0TCMPSPgNnKaQLcoOaFiNFXoz3PHgbrfotliZuGoqU=; b=In6BCKTnmta1Ok4z5I6BkuigYsx3DAVuf4RhTfMc7+WrMlipJ+sFl5N4vfkisY4Yln ogr95dZdtpEHhfjL3ZMQKkYXdGMw7qmYIXiFecgr9n1hyrHJ2CtuHP6VAEEccxOOjmB8 BxbHHL3vQmSfP7WyAURvIZLRBZ069uKQHn3BsarfE7W3Iu21LO+qFezjQ4aIZpGNYW7R 3H9GmOS3ddVtj84q0BhfUQBb02wVImpdvghhO3DPyEml2GMGJZybDPSIfttFoG5/Fh0K 1L/axzuXjcTKlH4xlazrRd6y2kSEDdcHka1Myrr3bdFXy1PFQree7yJGAimP73Stmzdu wn6Q== X-Gm-Message-State: AOAM530+fEW8exWgia7LRAjQO+H5Na0oY7d2YEzg/vlUO2jh97yqoT7I f31/NlpGBuD0M14o+vk2NENYEd6CE+76A0DHOilvww== MIME-Version: 1.0 X-Received: by 2002:a54:4f07:: with SMTP id e7mt10487613oiy.140.1620055590361; Mon, 03 May 2021 08:26:30 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 3 May 2021 08:26:29 -0700 From: Guillaume Ranquet Date: Mon, 3 May 2021 08:26:29 -0700 Message-ID: Subject: [PATCH 2/4] dmaengine: mediatek: do not issue a new desc if one is still current Cc: Sean Wang , Vinod Koul , Dan Williams , Matthias Brugger , dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210503_082632_520171_747ED90D X-CRM114-Status: UNSURE ( 9.92 ) X-CRM114-Notice: Please train this message. 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 Avoid issuing a new desc if one is still being processed as this can lead to some desc never being marked as completed. Signed-off-by: Guillaume Ranquet return IRQ_HANDLED; @@ -363,7 +367,7 @@ static void mtk_uart_apdma_issue_pending(struct dma_chan *chan) unsigned long flags; spin_lock_irqsave(&c->vc.lock, flags); - if (vchan_issue_pending(&c->vc)) { + if (vchan_issue_pending(&c->vc) && !c->desc) { vd = vchan_next_desc(&c->vc); c->desc = to_mtk_uart_apdma_desc(&vd->tx); diff --git a/drivers/dma/mediatek/mtk-uart-apdma.c b/drivers/dma/mediatek/mtk-uart-apdma.c index 4610dbdde75e..249cabddb7ee 100644 --- a/drivers/dma/mediatek/mtk-uart-apdma.c +++ b/drivers/dma/mediatek/mtk-uart-apdma.c @@ -204,14 +204,9 @@ static void mtk_uart_apdma_start_rx(struct mtk_chan *c) static void mtk_uart_apdma_tx_handler(struct mtk_chan *c) { - struct mtk_uart_apdma_desc *d = c->desc; - mtk_uart_apdma_write(c, VFF_INT_FLAG, VFF_TX_INT_CLR_B); mtk_uart_apdma_write(c, VFF_INT_EN, VFF_INT_EN_CLR_B); mtk_uart_apdma_write(c, VFF_EN, VFF_EN_CLR_B); - - list_del(&d->vd.node); - vchan_cookie_complete(&d->vd); } static void mtk_uart_apdma_rx_handler(struct mtk_chan *c) @@ -242,9 +237,17 @@ static void mtk_uart_apdma_rx_handler(struct mtk_chan *c) c->rx_status = d->avail_len - cnt; mtk_uart_apdma_write(c, VFF_RPT, wg); +} - list_del(&d->vd.node); - vchan_cookie_complete(&d->vd); +static void mtk_uart_apdma_chan_complete_handler(struct mtk_chan *c) +{ + struct mtk_uart_apdma_desc *d = c->desc; + + if (d) { + list_del(&d->vd.node); + vchan_cookie_complete(&d->vd); + c->desc = NULL; + } } static irqreturn_t mtk_uart_apdma_irq_handler(int irq, void *dev_id) @@ -258,6 +261,7 @@ static irqreturn_t mtk_uart_apdma_irq_handler(int irq, void *dev_id) mtk_uart_apdma_rx_handler(c); else if (c->dir == DMA_MEM_TO_DEV) mtk_uart_apdma_tx_handler(c); + mtk_uart_apdma_chan_complete_handler(c); spin_unlock_irqrestore(&c->vc.lock, flags);