Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3187967imw; Mon, 11 Jul 2022 03:53:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1swWHRsz4fF0Szve2G6e6J+F+Y5odDmRDsWDLRcp0ycEwD4qWTj3ypTaAp7w4iNtiNwo7ys X-Received: by 2002:a17:90b:388b:b0:1f0:47d8:67fb with SMTP id mu11-20020a17090b388b00b001f047d867fbmr2198379pjb.34.1657536831192; Mon, 11 Jul 2022 03:53:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657536831; cv=none; d=google.com; s=arc-20160816; b=I6VBkANJlC0zR3X9Wj6bhFtz713B+yTJrflVUY4hDGAJxvWo5t+IeqvOM/HZnOmeV/ AIyn8IKmlZ0x4M5bwnzjK+cDcVKyYOmQcpPLBfB9gwboWeHeQUX/OZW4EXjEQiZnP7wa J3ELEUjXg9CBUEnlLzy98bW+MnngzO5PNh42PvtxJADUIMMI5FFxX5dY2p8xWsF+0WD/ GffYrA5hs/I33yHxiHjZf079w1nH8Fp2phOcUjQPzeWot3Xyz08GBi3g9ehS9FSOU1kz uflLLa9JiGvNoSO0a0LF+uA0XGkVqUn5UUQDDYOyKlbpR0/jbBnlUDvOHVO+ChqYpS3E Qj3g== 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=+qagYeFSafl8Ylll62Oy7z0gh+mjDIcIlKqCGAy0Mog=; b=PDdjnoKSbFL9ckMh12iFc1OATojxrZ41j4j1YMnWS13z1SPqtMRr+a79hoV361bRvs 77EAN0NPpAsCkftzO6MOvINai7Aqz3WtX1qUSl+S3eVRkmibg38eYIbLs0WGK9xKEKDe tyWqCIsDdWIY6uY+5jaweTVluntDFAIBFigOZsCkjw80DcInN42OIe9dL2Q27Id6FDOL CiXvyvO1ZeYlIZjXgZ4AYWI3D9w6CgJLVvw8rXjCeTct7LEHDmvYd/h8rNCSGdM8sV1+ Vhhwrtq5pqrPtu7BhzrsMf//yhZYerSsK4aKFMyzT5IPZjkv1WyPN7BCRM8OypMRVKkq 8URw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sp8LOhS7; 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 w184-20020a6382c1000000b003fc573fa56dsi9495037pgd.6.2022.07.11.03.53.39; Mon, 11 Jul 2022 03:53:51 -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=sp8LOhS7; 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 S234260AbiGKKFH (ORCPT + 99 others); Mon, 11 Jul 2022 06:05:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234485AbiGKKDg (ORCPT ); Mon, 11 Jul 2022 06:03:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 128CF48EB0; Mon, 11 Jul 2022 02:29:40 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 9AAF361366; Mon, 11 Jul 2022 09:29:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB014C34115; Mon, 11 Jul 2022 09:29:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531779; bh=4P9xq6q8hGoQvb8Sigl3/Po/KZymH+V3vIWWDe8U1Uc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sp8LOhS7MXPRFIee/jhapWJ/JWVTzjy5/XOBtIkKeROUoxMLFG70rSnf4B3Q69pdp 4Ojvo1cUt3L36jzrbQoK3B+DeLtAbNyX0H+d2cOiwtL9zGJCeZBWW9ts82Uj6+W1ts qZ+FvEPrQ91QDW2oVuPT/F8c+Jb733gJoiTfnwBE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tony Zhu , Dave Jiang , Fenghua Yu , Vinod Koul Subject: [PATCH 5.15 229/230] dmaengine: idxd: force wq context cleanup on device disable path Date: Mon, 11 Jul 2022 11:08:05 +0200 Message-Id: <20220711090610.597250131@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090604.055883544@linuxfoundation.org> References: <20220711090604.055883544@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 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,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 From: Dave Jiang commit 44c4237cf3436bda2b185ff728123651ad133f69 upstream. Testing shown that when a wq mode is setup to be dedicated and then torn down and reconfigured to shared, the wq configured end up being dedicated anyays. The root cause is when idxd_device_wqs_clear_state() gets called during idxd_driver removal, idxd_wq_disable_cleanup() does not get called vs when the wq driver is removed first. The check of wq state being "enabled" causes the cleanup to be bypassed. However, idxd_driver->remove() releases all wq drivers. So the wqs goes to "disabled" state and will never be "enabled". By that point, the driver has no idea if the wq was previously configured or clean. So force call idxd_wq_disable_cleanup() on all wqs always to make sure everything gets cleaned up. Reported-by: Tony Zhu Tested-by: Tony Zhu Fixes: 0dcfe41e9a4c ("dmanegine: idxd: cleanup all device related bits after disabling device") Signed-off-by: Dave Jiang Co-developed-by: Fenghua Yu Signed-off-by: Fenghua Yu Link: https://lore.kernel.org/r/20220628230056.2527816-1-fenghua.yu@intel.com Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman --- drivers/dma/idxd/device.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) --- a/drivers/dma/idxd/device.c +++ b/drivers/dma/idxd/device.c @@ -720,10 +720,7 @@ static void idxd_device_wqs_clear_state( for (i = 0; i < idxd->max_wqs; i++) { struct idxd_wq *wq = idxd->wqs[i]; - if (wq->state == IDXD_WQ_ENABLED) { - idxd_wq_disable_cleanup(wq); - wq->state = IDXD_WQ_DISABLED; - } + idxd_wq_disable_cleanup(wq); idxd_wq_device_reset_cleanup(wq); } }