Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5605432rdb; Sun, 17 Sep 2023 04:36:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHttp3froe+zYH+zJ+lGdVynfhO2W/MSIRUTUeraqZFDXl8TAIsvQRd7wpfYQ78c7z0PwC8 X-Received: by 2002:a17:902:d2c1:b0:1bb:d586:d29a with SMTP id n1-20020a170902d2c100b001bbd586d29amr14076739plc.34.1694950586947; Sun, 17 Sep 2023 04:36:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694950586; cv=none; d=google.com; s=arc-20160816; b=ngiwsnGZk8V4r7vrX397gqgqJPc/zma5Kbdnm4vUlqjZH04ofBN3hsPFuHCDu2rqgU eRZvev+KO5OJRY+Wywxy/KQ8R8VfkNsX5ytmLKcMTQnRA+vo37NS3Sm8ZREMZRvXApBv d1mQ/FS5CJjoNIdAH2tusEjITkpaN7SMh50A+DulS9QKejedhBAHiyzvsQ6bUPEMyGEw fuAY/XLCjZc0dO6Iiyt1HcWeroCZ3hAK1zuIZvrQjwLVAe9Zauuc6jBdlzX48/S3Tq33 OGjqeH2btuM1H3dD3C9F2v5Q5Hv3pLzCgupgKgNr6Xg7kHE4UNqCY/31jOLv5eQwpeZD e0tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iTB2sjpYcyR7N4awxrdT3Ud0Y/BuCJw7syKUcf7KhfQ=; fh=jcEcO8kvjVbjOnpJo+0CXMh8+lmy7ypg3mt+Q3PjQDE=; b=flV9xmfRyEzRSyNvIC5q6tm+7LmO/e4Cj3n9yAU9wiq3wbZoWLMo9fZuf/0CAW7FLI d1P8tLRTynsvPfzFXfeYLCyGTUKNPwxf+76Nqngw6zLvTPtZ4qcwjGg4dlt4wmofgi7p Sd8uqd1b5+8SZrp9SQRqTDYq5TwwQ8BVtD7etVP0LtQOEfUkDpF6/F0zs827Qr2TM+ov uukOKkzbWoAMSS08fA+s3x0C0RCjSJoQ4RHBmjHlTEjeF4tTa9Q7dfaXkqQaEkIjmPUO lqa1fjpPM54a42X9PtSyKXcjxJDE2Y2hHwa+h0YRXQAf7SmDnPqCwiOWv0vUJ1pBcm39 KhkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ihkl37EH; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id d4-20020a170902cec400b001b8a4954be1si6863524plg.595.2023.09.17.04.36.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 04:36:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ihkl37EH; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 9A3AE801CEB7; Thu, 14 Sep 2023 02:57:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237520AbjINJ5R (ORCPT + 99 others); Thu, 14 Sep 2023 05:57:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237518AbjINJ5Q (ORCPT ); Thu, 14 Sep 2023 05:57:16 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D6B483 for ; Thu, 14 Sep 2023 02:57:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694685432; x=1726221432; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ziVvr7l4KJrltF95aX1enLC5Yil0BRxSFwkmSuCyIL4=; b=Ihkl37EH13eyqBad5DhNXejN6IFLcqK75roAnKWkpLhxkNVXeCxcHCy8 MzsP5hyFOAY4YgfSjzVR8DsHIDNjvdIfUYgq8s0NHI8vsJ4G/mJflHap9 e+sBg+JoHfx6+N6VuD6S/vmVllJ6AH2EdK7unQiXJgfLu72pDjeiMej12 QELoQRZKVd0jRuf/8WqmAZJtezRlRdfUI9eJ+hVTY+1heSQ0WVRikGKK7 AGc2Jnx0k1H518Al3UbGvMW0/srh8b8nw0dtn+xccDnVgEY3Upet9K3KZ oWM5+YCpASMQURUV6gQAlCN/yNQA0hiVtiW16ekc+WolWkYio+Ib+Yi44 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="465279150" X-IronPort-AV: E=Sophos;i="6.02,145,1688454000"; d="scan'208";a="465279150" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2023 02:57:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="814619715" X-IronPort-AV: E=Sophos;i="6.02,145,1688454000"; d="scan'208";a="814619715" Received: from silpixa00400314.ir.intel.com (HELO silpixa00400314.ger.corp.intel.com) ([10.237.222.216]) by fmsmga004.fm.intel.com with ESMTP; 14 Sep 2023 02:57:10 -0700 From: Giovanni Cabiddu To: herbert@gondor.apana.org.au Cc: linux-crypto@vger.kernel.org, qat-linux@intel.com, Giovanni Cabiddu , Adam Guerin Subject: [PATCH 1/5] crypto: qat - fix state machines cleanup paths Date: Thu, 14 Sep 2023 10:55:45 +0100 Message-ID: <20230914095658.27166-2-giovanni.cabiddu@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230914095658.27166-1-giovanni.cabiddu@intel.com> References: <20230914095658.27166-1-giovanni.cabiddu@intel.com> MIME-Version: 1.0 Organization: Intel Research and Development Ireland Ltd - Co. Reg. #308263 - Collinstown Industrial Park, Leixlip, County Kildare - Ireland Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 14 Sep 2023 02:57:16 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Commit 1bdc85550a2b ("crypto: qat - fix concurrency issue when device state changes") introduced the function adf_dev_down() which wraps the functions adf_dev_stop() and adf_dev_shutdown(). In a subsequent change, the sequence adf_dev_stop() followed by adf_dev_shutdown() was then replaced across the driver with just a call to the function adf_dev_down(). The functions adf_dev_stop() and adf_dev_shutdown() are called in error paths to stop the accelerator and free up resources and can be called even if the counterparts adf_dev_init() and adf_dev_start() did not complete successfully. However, the implementation of adf_dev_down() prevents the stop/shutdown sequence if the device is found already down. For example, if adf_dev_init() fails, the device status is not set as started and therefore a call to adf_dev_down() won't be calling adf_dev_shutdown() to undo what adf_dev_init() did. Do not check if a device is started in adf_dev_down() but do the equivalent check in adf_sysfs.c when handling a DEV_DOWN command from the user. Fixes: 2b60f79c7b81 ("crypto: qat - replace state machine calls") Signed-off-by: Giovanni Cabiddu Reviewed-by: Adam Guerin --- drivers/crypto/intel/qat/qat_common/adf_init.c | 7 ------- drivers/crypto/intel/qat/qat_common/adf_sysfs.c | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/intel/qat/qat_common/adf_init.c b/drivers/crypto/intel/qat/qat_common/adf_init.c index 79a81e25de97..542318a5b771 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_init.c +++ b/drivers/crypto/intel/qat/qat_common/adf_init.c @@ -428,13 +428,6 @@ int adf_dev_down(struct adf_accel_dev *accel_dev, bool reconfig) mutex_lock(&accel_dev->state_lock); - if (!adf_dev_started(accel_dev)) { - dev_info(&GET_DEV(accel_dev), "Device qat_dev%d already down\n", - accel_dev->accel_id); - ret = -EINVAL; - goto out; - } - if (reconfig) { ret = adf_dev_shutdown_cache_cfg(accel_dev); goto out; diff --git a/drivers/crypto/intel/qat/qat_common/adf_sysfs.c b/drivers/crypto/intel/qat/qat_common/adf_sysfs.c index a74d2f930367..a8f33558d7cb 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_sysfs.c +++ b/drivers/crypto/intel/qat/qat_common/adf_sysfs.c @@ -52,6 +52,13 @@ static ssize_t state_store(struct device *dev, struct device_attribute *attr, case DEV_DOWN: dev_info(dev, "Stopping device qat_dev%d\n", accel_id); + if (!adf_dev_started(accel_dev)) { + dev_info(&GET_DEV(accel_dev), "Device qat_dev%d already down\n", + accel_id); + + break; + } + ret = adf_dev_down(accel_dev, true); if (ret < 0) return -EINVAL; -- 2.41.0