From patchwork Wed Oct 19 08:29:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 5090 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp249692wrs; Wed, 19 Oct 2022 03:46:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6XB5SRZBen9/V/LLumCm180LKx/SkBYTlK8E133RA6pBOOhKdpiyT5S2JGxVYo5AQUxPwu X-Received: by 2002:a17:90b:1184:b0:20c:c0f:7c43 with SMTP id gk4-20020a17090b118400b0020c0c0f7c43mr45103019pjb.236.1666176414377; Wed, 19 Oct 2022 03:46:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666176414; cv=none; d=google.com; s=arc-20160816; b=iXVb7PEKY4oHdI5emOMrhJi11LxXpXLhArNKNV9Cybmaadp1Xfjc7s1s0lmlzR0RIU ks+bbckHIoO5gowVHtKbzDvSSehVtGZZa6PeZtIy2qKzSDICyx4R2AFSLrp/2gf40yGG GbbtL86xE00PEcy9VJ40+lDLVVXEKTJ5c4O3o/B0E3a0UBhj5OMYTWE37f+hGcj7DHfB Zkgpg2OUIFAAsfMzJluBFXzdGWvskvJzmSS3qauF9cU+FXl8bpqdoLBJOjBKYSnQo9YE vxToF1TIo7Li3fEjJw2gnoNwOkPV7d9SO2gV2LayFDtZqN/OJyjJjATf0fO3wrYuqG7i 74bQ== 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=j/zH1Hj5lQZRr1RVHKtYNT4tiZSgTxagsDamiSWtjlqeuPzMK8SbcmLwL1Nn+4m8iC OFzrfIyfpEh5u9APaTZ9MuFNTnuR0j9ra+gaUNUwSc+ogUjFAaq0UUxtBwP5weUAcy+I Ri9Gh1gMFXcaxHJkLWqnxJAobPPZkHPtJu13HPtdEORog88giy0ik9jxNM7JxnB7J4JM jfkv/uap866h+hM6RONxoPaG9NPt2p5zWM6BgLsINgP4o0lq3ZuIWUeh3Xi3Cx3k0ajb BJeZtEKVs6WBtL9PJl7FJcuW6EwlNN/aDMPhgpXOCY6SW2gelXv52hXse0XvVuIE1emt JmWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="c/nm/tma"; 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 s16-20020a63e810000000b0046248881576si18453793pgh.157.2022.10.19.03.46.41; Wed, 19 Oct 2022 03:46:54 -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="c/nm/tma"; 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 S233126AbiJSKqU (ORCPT + 99 others); Wed, 19 Oct 2022 06:46:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233132AbiJSKo3 (ORCPT ); Wed, 19 Oct 2022 06:44:29 -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 B7933112AAC; Wed, 19 Oct 2022 03:21:02 -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 5547BB8244A; Wed, 19 Oct 2022 09:00:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5080C433C1; Wed, 19 Oct 2022 09:00:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170051; bh=rMbA6/oW/i/Lu6KasqXn0fbJlBZXxf0bUD+LrqGkdqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c/nm/tmaasT/m97T/0KYYeYynqqDQw/MIV+1ddTXBe6IXJfogRqwyzbjhAh7aeTrG q9xS4qT0zv05+zD/+VcxvShyv6E6ksOB25+NXakzeQwCtJMLjUFLDSAr3yVLXBQbJs b01Sb2NLwe2Ol5g9RTtOhL7Wl6r0gl80YL6DVN0c= 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 6.0 508/862] dmaengine: hisilicon: Disable channels when unregister hisi_dma Date: Wed, 19 Oct 2022 10:29:55 +0200 Message-Id: <20221019083312.433390135@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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?1747112600000396024?= X-GMAIL-MSGID: =?utf-8?q?1747112600000396024?= 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)