Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp802159rwe; Thu, 1 Sep 2022 07:52:20 -0700 (PDT) X-Google-Smtp-Source: AA6agR6ItigfsOsTr2gJiGU/GUXWshg0uJmdTVYAda2WZKtXBe6SpnqPqaDdKDzd2yu4OtFQO9xA X-Received: by 2002:a63:d745:0:b0:429:d263:615d with SMTP id w5-20020a63d745000000b00429d263615dmr26991696pgi.579.1662043940420; Thu, 01 Sep 2022 07:52:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662043940; cv=none; d=google.com; s=arc-20160816; b=sBhtiToOAsoWRyCS3Fys9yQjm1qGYf5DY8NZonMUZeP3HQDSQg/HGakOO/vVLyoQm8 4Nhnq6BbFKXG1NtqWOr2hqSjCxrooRqdp+xFrBeEteUNr0u6cUC+wnOzZfsSSz8r1MXy woFUQzPm70gApMvXO3oMEs+IPRFrZwfOwsms5bqb/8f86P04UwmUysTeFRYf5qlvUKJP Gvn/dA7WOT8UO1Tns7YqmgyzR4VQR3IG1/69Lxc3QsTM99xFtSxFI7N15fKPQnMXAS3Q hWkvZukeExMckmEDpW+Kwyj7ZzwWHRII4iPmGn+GnDmF1s0BHthnXFS9GG2Hv5zhMAYO Uvog== 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 :message-id:date:subject:to:from:dkim-signature; bh=QWY8to+d00rWq/rJi5teSMWyNnP44XxPpW2JtoKQAbY=; b=vjyUM1/BtymB4eb4wmInr+T2B9hbZrvOGERf26JeX50k8xUPmBsEMnZaHMx888e6SA t2zYMU1VtOe4TKTwu0ImRnG3/u6e/e+E3otXLL8L2MtJoHztUMs+sOa++HMqg93g5ubx zFdQWdq0to4sd3kar3r42onzdNFIV8uZv3J0g5vkmhDGRjkI3VcOpqU6oOR8nG3RMIlT JDnvtssGtH7RQihVMZvCIOZsA2sTXWmqVw/rqENQMfKTXKaGfXMZf7FoLrZPS7Wo0Gy3 ssQevEnyb5CAnkjda8L1MKVlTDZ/dirgMkp9S4WT48Z0x75rikNc7bx5qEv26YAKXvn3 zx3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=Wm15ImLz; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x189-20020a6331c6000000b0041d8ca10b57si8313491pgx.223.2022.09.01.07.51.52; Thu, 01 Sep 2022 07:52:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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=@canonical.com header.s=20210705 header.b=Wm15ImLz; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232430AbiIAOrX (ORCPT + 99 others); Thu, 1 Sep 2022 10:47:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231443AbiIAOrV (ORCPT ); Thu, 1 Sep 2022 10:47:21 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B82D72B43 for ; Thu, 1 Sep 2022 07:47:20 -0700 (PDT) Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id D0B0D3F495 for ; Thu, 1 Sep 2022 14:47:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1662043638; bh=QWY8to+d00rWq/rJi5teSMWyNnP44XxPpW2JtoKQAbY=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=Wm15ImLzGdsawfNoZL9U8ef2/THt7sViN5sWKlv/yjZR8ViGYcH7Y89a9oYlOyD3C LC69XOE8KHAsj4GoosFDiy8csyytCDmFGK+ziYqIKMaCPePKwevD/gue78GRqnj3CR Vq38mkLdIdW/3gBzeAgsqvkG1V03NyjTvQVgcGp9wSDSj31arwFPWApLZZlhWEcuY+ q/j7zbtTA+Uh5c09yEkrUCpQh07kQwOY1rcbfTqSCtm74SjZGWjvwmyX7fFcRrbirc JuI+e7JRXUuy9qEVVTQ78bZSYFaKDJDWeKDavPwJGtooNdkf+QSiUIaAiYpSQlou5l vRPdnRMaD5Dxg== Received: by mail-pl1-f199.google.com with SMTP id x6-20020a170902ec8600b001754410b6d0so3282291plg.10 for ; Thu, 01 Sep 2022 07:47:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date; bh=QWY8to+d00rWq/rJi5teSMWyNnP44XxPpW2JtoKQAbY=; b=JmUkQusTeFpZO4NREDApP/a27owdDzlrK9PACh2lKNOpoxcQHgBh907VwCzlQQTzTO qYo7Hs44TiLEB/6Qzubd+fXNFxIUGEFt8jwHTGsyRBdCBL0gfJGqVS6lve6OhVQumVPb Rx5x09mi4YTUPY7loJGHvRB+Z0qciRcmQMEdfNRD8jL8DORZK7gtvNR1kSrEmQ1OG8hk HfXph9KCVIrnqRMHbM2i+UrocjJ45p2fHvYH1iuNlzErFXE4sWaItD7pFuNtZIcSmO9j MyOnOVBR5jg/sB4s7Wy8ZrgVwgk/USo2+7ahqrhlCqFQofXbyiqrlism5yMspguCYoUe vXGQ== X-Gm-Message-State: ACgBeo2wbh13m7/lDflIs0Qewis+kn8wY4DHqEHjjopihjrOYCFvKeh2 dIME5CeYUrFfrFL9zu73WO74/zODp0EtBDHf/t/klcsziwRUQ7kFofOeUEdZAdQxzxLDtfi3gcM O6RcRQECyMZ/mw+BHwhTxLmyVPAjXEHvMq4XrEf0KTA== X-Received: by 2002:a17:902:dac1:b0:172:eae4:950c with SMTP id q1-20020a170902dac100b00172eae4950cmr30535501plx.70.1662043637046; Thu, 01 Sep 2022 07:47:17 -0700 (PDT) X-Received: by 2002:a17:902:dac1:b0:172:eae4:950c with SMTP id q1-20020a170902dac100b00172eae4950cmr30535477plx.70.1662043636582; Thu, 01 Sep 2022 07:47:16 -0700 (PDT) Received: from canonical.com (2001-b011-3815-31f6-fb99-d5df-1120-3f91.dynamic-ip6.hinet.net. [2001:b011:3815:31f6:fb99:d5df:1120:3f91]) by smtp.gmail.com with ESMTPSA id g16-20020aa796b0000000b005385555e647sm7717029pfk.155.2022.09.01.07.47.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 07:47:14 -0700 (PDT) From: Koba Ko To: Tom Lendacky , John Allen , Herbert Xu , "David S. Miller" , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V3] crypto: ccp - Release dma channels before dmaengine unrgister Date: Thu, 1 Sep 2022 22:47:12 +0800 Message-Id: <20220901144712.1192698-1-koba.ko@canonical.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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-crypto@vger.kernel.org A warning is shown during shutdown, __dma_async_device_channel_unregister called while 2 clients hold a reference WARNING: CPU: 15 PID: 1 at drivers/dma/dmaengine.c:1110 __dma_async_device_channel_unregister+0xb7/0xc0 Call dma_release_channel for occupied channles before dma_async_device_unregister. Fixes: 54cce8ecb925 ("crypto: ccp - ccp_dmaengine_unregister release dma channels") Reported-by: kernel test robot Signed-off-by: Koba Ko Acked-by: Tom Lendacky --- V2: Fix the unused warning V3: Fix the Fixes: tag. --- drivers/crypto/ccp/ccp-dmaengine.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/ccp/ccp-dmaengine.c b/drivers/crypto/ccp/ccp-dmaengine.c index 7d4b4ad1db1f3..9f753cb4f5f18 100644 --- a/drivers/crypto/ccp/ccp-dmaengine.c +++ b/drivers/crypto/ccp/ccp-dmaengine.c @@ -641,6 +641,10 @@ static void ccp_dma_release(struct ccp_device *ccp) for (i = 0; i < ccp->cmd_q_count; i++) { chan = ccp->ccp_dma_chan + i; dma_chan = &chan->dma_chan; + + if (dma_chan->client_count) + dma_release_channel(dma_chan); + tasklet_kill(&chan->cleanup_tasklet); list_del_rcu(&dma_chan->device_node); } @@ -766,8 +770,8 @@ void ccp_dmaengine_unregister(struct ccp_device *ccp) if (!dmaengine) return; - dma_async_device_unregister(dma_dev); ccp_dma_release(ccp); + dma_async_device_unregister(dma_dev); kmem_cache_destroy(ccp->dma_desc_cache); kmem_cache_destroy(ccp->dma_cmd_cache); -- 2.25.1