Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3882078rwi; Sat, 22 Oct 2022 01:29:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM67Jd0MjML8aPJkpj1XSKh4C6Q0BKaorH6H3imQl7crNL72fgOAFSjCs+HDubvL/JRLbPou X-Received: by 2002:aa7:ca45:0:b0:458:d9a2:6164 with SMTP id j5-20020aa7ca45000000b00458d9a26164mr21716814edt.340.1666427374028; Sat, 22 Oct 2022 01:29:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666427374; cv=none; d=google.com; s=arc-20160816; b=k6fY2X8YuJf+vXKfIxW/Wx1AIIoAq2YYshiVis3VlTQveFtYKhXSJHGvVivTuZinLY dztrn/5klKCLzNawuLCOlTvADUlLiEzTVj/7L/8Suap/RRC8/UhYIgvx3DUDM8HuVnWJ lJ2CMOeCc1iim2n0qSQoCtwLEwGUCiSunfuA02KQ5p9T5f5w6Ge1fPQPG5U6Hu7LbuU4 9AZZMCTmfc98jP1lcN4ZgiY34uqrzwP231fLoNjF+Oi8XLuTMne1bJr3+2LpWqTiozX+ IAtcayrevKp3u5JqwmX7A8VsAyfTkXRwIh1NAYkNd6LQJd2glQxvedWNyMqQZkKFHn8B VPRg== 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=PrgHe7CX1UwWMIO4mMhjm7t1RjA3aOW7qy6jtVcGhNU=; b=y4WMqJxcRShxbPuxqMh2H4/Ffs0LtelGu2XJfhANv7qXfGrA0FQWAj2+GMNXF6XFiz 3vtIOwvhRKxs3VUjMYEfKThLQfp+lV9il1oBm0W9yVervhZhfvg2R5RIDLMq2Ptxc7Zp oE7CDp3wmmEUfNN8ITfmssit8WpBhpvuWnqnOIHKW8UZ8fVJISVAjJmDRYMoyhko+MnU RgnFrGZyaNAtWq2HyBzjx3KvthAuAUwww9rfyuB7Mpa7XTX+gPBkab4FT6sTEonfbE1r Px+iqeRthd2q0wC1fE5x+nNXe3XTtAwio8uDXLKxJFuPzEjxMS8OU9AVn9Wx0L4CNier lIbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rCdKbpT5; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb22-20020a170907961600b0072fc714c92fsi23793233ejc.902.2022.10.22.01.29.08; Sat, 22 Oct 2022 01:29: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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rCdKbpT5; 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 S233056AbiJVIK1 (ORCPT + 99 others); Sat, 22 Oct 2022 04:10:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232716AbiJVIGI (ORCPT ); Sat, 22 Oct 2022 04:06:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53F082D52CC; Sat, 22 Oct 2022 00:53:01 -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 24D59B82DB3; Sat, 22 Oct 2022 07:52:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73D98C4314B; Sat, 22 Oct 2022 07:52:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425169; bh=rMbA6/oW/i/Lu6KasqXn0fbJlBZXxf0bUD+LrqGkdqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rCdKbpT5vCmi73gFiF/r36ixxXHNYgA5NoQeBtioYP4Vgh5B8NGZWszkqEyQf0Pwt e4p0irRa33JQ9zXdC1DA6HpDPpd273Pv89pu++/LwLo4XYHdeE6KvMRuN+OUb7RE0I sfv/W7FaYHANr2qiMYDaBF9rgyM7SzJLYJHWiJD8= 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.19 413/717] dmaengine: hisilicon: Disable channels when unregister hisi_dma Date: Sat, 22 Oct 2022 09:24:52 +0200 Message-Id: <20221022072516.391491350@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.3 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 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 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.35.1