Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3867825rwe; Mon, 29 Aug 2022 23:21:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR4o4XTelgxLemT+ih86YlOlffh+2B/noz/5bBAtNSZZbNrAyMEJy8XyCXTuDxdYPSWKos19 X-Received: by 2002:a17:902:be12:b0:170:cc74:989b with SMTP id r18-20020a170902be1200b00170cc74989bmr19631344pls.88.1661840494544; Mon, 29 Aug 2022 23:21:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661840494; cv=none; d=google.com; s=arc-20160816; b=wHgtSKnEOUAyi+yxpRZ9sA9uwk3nHny3A2Cqq2F9EyTZznrjIO6ISti+vwFZEB1Psw B62yoP5NaGU7Y+tta6bf8zKj1enlkpE52WV6HSx9x15xm8OtZNNWFblmBhWyupVHAf4R hp7fnRd5m9NSOrmcBP1dNs6HGbGV5iaBvRQPPChvRqiNGKo1Jwge6wuJwn7Z+1Snbvz/ b13R3sttNSDygJl2LBoo+AiJgZlQDzgSevdJy2VzsXXYvtcIozVNPLggan+2K3fHl/Mg c0RXTQCUgelYid0Ja0FEIX0kaNIqmzcfRBr20BxBkXvtjOb0hJ1Qcy7dlapxQ1sKJR7I 64Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=jjCSiFq1mTAOO24jZzPAY81dx5HeFCPKHJd3+7OdxEc=; b=J4oAodvtYaMHStQu+TW/iIFu+Eii6TQZbc3G2o92UsfLdFcEa/4ehaLAPIk9U1gfyP JB5fumDo97Cm/EJAnvjYR6kKQsG9e3LLfCrI4lGIiur2pieYXKuEu8laAxxt+gPyQgZb UaTkISTTIn6OSKwN1aWxWdU3m5n76yQ48yECZ6VqIe73zWVathUI/uUjHbtuuIryonpR 8AgaEt3K94wkXklbbLc8JGdWLfMOJfj250NWGBwhgoIowCzMU1ctMzsxOEh1OvWCj5D3 00l5M3tPyStLhyfCE1OOyOgBe/o7INYekiwwAcT6h4qeL7OHl1Y6Jg/gOeyIvXIRYxN3 A0QQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id me1-20020a17090b17c100b001fdb1694973si6981103pjb.157.2022.08.29.23.21.24; Mon, 29 Aug 2022 23:21:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230029AbiH3GIt (ORCPT + 99 others); Tue, 30 Aug 2022 02:08:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229953AbiH3GIq (ORCPT ); Tue, 30 Aug 2022 02:08:46 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4FC4B69DB; Mon, 29 Aug 2022 23:08:44 -0700 (PDT) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MGxcJ0pLNzlWbN; Tue, 30 Aug 2022 14:05:20 +0800 (CST) Received: from kwepemm600007.china.huawei.com (7.193.23.208) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 30 Aug 2022 14:08:42 +0800 Received: from localhost.localdomain (10.69.192.56) by kwepemm600007.china.huawei.com (7.193.23.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 30 Aug 2022 14:08:42 +0800 From: Jie Hai To: , CC: , Subject: [RESENT PATCH v5 1/7] dmaengine: hisilicon: Disable channels when unregister hisi_dma Date: Tue, 30 Aug 2022 14:05:49 +0800 Message-ID: <20220830060555.50781-2-haijie1@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220830060555.50781-1-haijie1@huawei.com> References: <20220830060555.50781-1-haijie1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600007.china.huawei.com (7.193.23.208) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When hisi_dma is unloaded or unbinded, all of channels should be disabled. This patch disables DMA channels when driver is unloaded or unbinded. Fixes: e9f08b65250d ("dmaengine: hisilicon: Add Kunpeng DMA engine support") Signed-off-by: Jie Hai Acked-by: Zhou Wang --- drivers/dma/hisi_dma.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/dma/hisi_dma.c b/drivers/dma/hisi_dma.c index 43817ced3a3e..98bc488893cc 100644 --- a/drivers/dma/hisi_dma.c +++ b/drivers/dma/hisi_dma.c @@ -180,7 +180,8 @@ static void hisi_dma_reset_qp_point(struct hisi_dma_dev *hdma_dev, u32 index) hisi_dma_chan_write(hdma_dev->base, HISI_DMA_CQ_HEAD_PTR, index, 0); } -static void hisi_dma_reset_hw_chan(struct hisi_dma_chan *chan) +static void hisi_dma_reset_or_disable_hw_chan(struct hisi_dma_chan *chan, + bool disable) { struct hisi_dma_dev *hdma_dev = chan->hdma_dev; u32 index = chan->qp_num, tmp; @@ -201,8 +202,11 @@ static void hisi_dma_reset_hw_chan(struct hisi_dma_chan *chan) hisi_dma_do_reset(hdma_dev, index); hisi_dma_reset_qp_point(hdma_dev, index); hisi_dma_pause_dma(hdma_dev, index, false); - hisi_dma_enable_dma(hdma_dev, index, true); - hisi_dma_unmask_irq(hdma_dev, index); + + if (!disable) { + hisi_dma_enable_dma(hdma_dev, index, true); + hisi_dma_unmask_irq(hdma_dev, index); + } ret = readl_relaxed_poll_timeout(hdma_dev->base + HISI_DMA_Q_FSM_STS + index * HISI_DMA_OFFSET, tmp, @@ -218,7 +222,7 @@ static void hisi_dma_free_chan_resources(struct dma_chan *c) struct hisi_dma_chan *chan = to_hisi_dma_chan(c); struct hisi_dma_dev *hdma_dev = chan->hdma_dev; - hisi_dma_reset_hw_chan(chan); + hisi_dma_reset_or_disable_hw_chan(chan, false); vchan_free_chan_resources(&chan->vc); memset(chan->sq, 0, sizeof(struct hisi_dma_sqe) * hdma_dev->chan_depth); @@ -394,7 +398,7 @@ static void hisi_dma_enable_qp(struct hisi_dma_dev *hdma_dev, u32 qp_index) static void hisi_dma_disable_qp(struct hisi_dma_dev *hdma_dev, u32 qp_index) { - hisi_dma_reset_hw_chan(&hdma_dev->chan[qp_index]); + hisi_dma_reset_or_disable_hw_chan(&hdma_dev->chan[qp_index], true); } static void hisi_dma_enable_qps(struct hisi_dma_dev *hdma_dev) -- 2.33.0