From patchwork Mon Oct 24 11:30:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9631 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp532171wru; Mon, 24 Oct 2022 09:07:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6OZ2WmPwoh893PXCpbBXBCbALSdFs+1usFNqRKxCCqRUCdaShQURdGupDTHMIhclBbjKo0 X-Received: by 2002:a05:6402:5419:b0:457:c955:a40f with SMTP id ev25-20020a056402541900b00457c955a40fmr30595152edb.391.1666627655152; Mon, 24 Oct 2022 09:07:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666627655; cv=none; d=google.com; s=arc-20160816; b=ctuNK7ESovCJaPTQvvSBLmElVwc54L4F+h79rdsFE3gyC2OcvztCrtQ5TZNY58lXpJ YsvbgYq+8Ilvw5qCWD/I4H+6Mgh56676perrym3o+1PdQoxFvIGD9DhKMOzP9nuaaQAZ xxrvQs08g8lT+vvQwmidrF+xeE9AIMEqCxuPZ974FjCFaOPxibEJCgCvtdTmIccO8gjH aq8XZZRiE+CANKCEVFNVsBPW1MD7LuIkKJfb1YTeuoQVztjqqNfcoSWVB+ex3vXnFidz WBiXAw9ENxMCCE628WZjX/cySmbfAkAecyY5rjHWiKHl6s4I2b7lo/cKeJVYNaBH70E8 KB2g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XCnTZVCL/tRlUarKbEA4PHValgDaMEEXLyV6WyQWB1o=; b=oyMMne57PREECY1mp6KrNF7myV9ngW5ugYoDuF+X4yw1TrxoDkPvjCFMLOxKY/9MI0 hKAwAzKvWh+JIMXWDdR/O+Yesk/TLz+nP9JCX6bZ/Zm7YXX6wQtoQpQ8u9AlwvqxFohQ 9sac09YBVM/uDM7SOnIhGcwQfqjdFVvLZ9lEok4B841eSMtZfDwewS/ybAnQLbqImp9a 6vp2jyNc2yT9FN2w9K+NG8FJtGXsWKlmyd06M1jhTmiizmhlxIQ1rxDY8yelDdb7VD/A pfm5Zs4MxTLRblDMoIUnlDfgIVOePvNntwBLskRypFaReB/h6p406T47F0D5G0TolyO+ zZ/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AvGFaQPk; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c6-20020a05640227c600b0045154775089si129411ede.625.2022.10.24.09.07.09; Mon, 24 Oct 2022 09:07:35 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AvGFaQPk; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233116AbiJXQGZ (ORCPT + 99 others); Mon, 24 Oct 2022 12:06:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232908AbiJXQEB (ORCPT ); Mon, 24 Oct 2022 12:04:01 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7CFE1E099D; Mon, 24 Oct 2022 07:56:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C0A60B81677; Mon, 24 Oct 2022 12:25:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2459BC433D7; Mon, 24 Oct 2022 12:25:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614318; bh=nO8K0tDmjNV/cilGMHR/bS4w7jvNmk5chRqtJRkf+B0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AvGFaQPkLEduBHKU/my3pZJktaUqCPJvbS2Jck8EiSaY46+oCV9zQeq2hZEBTJK1K OMHYoWXjtVB4OM3DE8whwP9IWSXDjA/3ulsdrdGw8hmz+sRNNrPykD2XyFesfWNKsP azoUFbOa/dHNQWxKCBnkjORGBNN6CKuP7MDubDDk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jie Hai , Zhou Wang , Vinod Koul , Sasha Levin Subject: [PATCH 5.10 214/390] dmaengine: hisilicon: Disable channels when unregister hisi_dma Date: Mon, 24 Oct 2022 13:30:11 +0200 Message-Id: <20221024113031.897937220@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747585759960309348?= X-GMAIL-MSGID: =?utf-8?q?1747585759960309348?= From: Jie Hai [ Upstream commit e3bdaa04ada31f46d0586df83a2789b8913053c5 ] 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 Link: https://lore.kernel.org/r/20220830062251.52993-2-haijie1@huawei.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- 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 3e83769615d1..7cedf91e86a9 100644 --- a/drivers/dma/hisi_dma.c +++ b/drivers/dma/hisi_dma.c @@ -185,7 +185,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; @@ -206,8 +207,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, @@ -223,7 +227,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); @@ -399,7 +403,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)