Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6920094rdb; Tue, 2 Jan 2024 20:10:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IGLCEvgj4yb4Odu8SF4JS+9HX70NPQG/Crf0qjxQ8MY4ohbPMROLRA8t5UPYkZrjwcY2SIH X-Received: by 2002:a17:90a:c918:b0:28c:8c58:e27d with SMTP id v24-20020a17090ac91800b0028c8c58e27dmr4232085pjt.51.1704255001306; Tue, 02 Jan 2024 20:10:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704255001; cv=none; d=google.com; s=arc-20160816; b=gKay9aL0k74nm+HQnDYRHhufOxlYnBeyGJWOggktLzIELBVXEIaCUKTwNlf0ZJ2CGB cg7FrhNUmIfk2iaEg5i7fVmzPuyI98oAX1FpJ5ObfETMMqzUtsH/c0XKmMkySJmG39iM vtc2BOwfJrx+LPZJGnT6pHlBS+BGsjRcp6EpxyR/qt7BmhOPJRRASXkPM2Ijx4Ds23Ny iBdd4q7QVkMJMQnlNkF0eWHiJ4/4iz1ik304qn6rYeLEOyyE+dw1kULZI2SHdX6vPTLC REvEF6zIxbdKbvbbtPCLkK5extgQoIxBzW0eVasAw8NWO0dtOnh/E0O64GI9FAUQBQwq n9SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=cMuPBHwdMOUe3h8fkTFVV+Zv0zsfLkpJFav/51QM2Jw=; fh=R/KnBtCXmGsBrHxx7fsHZQpEZsJfSLcYkK+1Y1M9Qnw=; b=IVeHLuLgTDmH/eoJp1xCe1Buc1H2k70VO3TXOzOzNZKWFRvE7Xh0+xB6KmDlrZUwjl ++ObYUvMV708K+y8qN4mWEDUZnH0kk9tJrtmcKDPSuoyLKkV8IPD062va5QGpZM6BgJi wVH2F4DAYAOC+S1xw/avEkbiHBqHbmhCmo2SqQjX6QZmuV3EdvCxhIvhcR1HIousvKiM kWI7pYIW3/YndzIYo6SSlDID+XJgOKTBiomX0b0EhWHyGCqFs3rGLJv4T/pJLLgxm2Fn ko6FZTGIxVCPktq90TYIF34wBeh4G+62gZ6YEKWg11AsV7fVipbVE1QojZOi5/erJXga EDEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dIvpHCuc; spf=pass (google.com: domain of linux-crypto+bounces-1206-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-1206-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id np18-20020a17090b4c5200b0028c1dd4d24asi520409pjb.174.2024.01.02.20.10.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 20:10:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-1206-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dIvpHCuc; spf=pass (google.com: domain of linux-crypto+bounces-1206-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-1206-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 610DA283534 for ; Wed, 3 Jan 2024 04:09:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E3A1F17980; Wed, 3 Jan 2024 04:09:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="dIvpHCuc" X-Original-To: linux-crypto@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CD8717988 for ; Wed, 3 Jan 2024 04:09:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1704254991; x=1735790991; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FFFFrrVArbQfvFtJfGYeSqY9oy58n895h3SxlpbFKJw=; b=dIvpHCucpcS/szFoXoto2kLuxOeu+Fq4umRethBABwYJzsrrq7E2i9nz AWrUxWUzayhgu6fbHZT8++rYcJqOq0pWWEM9F60Yp7qsnrkTLA2pC0LJi SIOi6RbYLsBxwr7iju0rNDq8qHBFJMdIHznkuSR0FS8mpXS5D7in7IslJ B+KQIo8LgzmlIda5MZGW0Il1/K/S/a5S5wUh6RhIoc3p7DAChDAJ6b9gI qJtPue1FoaBC58Iw9+KjvxKZlwn4z/zGwCDuQWrZH05lC9HI7862jw99c 2B7fo5CPoJd5mjL/WzqFy1bNqcpETYBWXnMAaIZ619kWhJf29rV9HolEr A==; X-IronPort-AV: E=McAfee;i="6600,9927,10941"; a="3725553" X-IronPort-AV: E=Sophos;i="6.04,326,1695711600"; d="scan'208";a="3725553" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2024 20:09:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10941"; a="1111241961" X-IronPort-AV: E=Sophos;i="6.04,326,1695711600"; d="scan'208";a="1111241961" Received: from myep-mobl1.png.intel.com ([10.107.5.97]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2024 20:09:48 -0800 From: Mun Chun Yep To: herbert@gondor.apana.org.au Cc: linux-crypto@vger.kernel.org, qat-linux@intel.com, Damian Muszynski , Ahsan Atta , Markas Rapoportas Subject: [PATCH 7/9] crypto: qat - add auto reset on error Date: Wed, 3 Jan 2024 12:07:20 +0800 Message-Id: <20240103040722.14467-8-mun.chun.yep@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240103040722.14467-1-mun.chun.yep@intel.com> References: <20240103040722.14467-1-mun.chun.yep@intel.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Damian Muszynski Expose the `auto_reset` sysfs attribute to configure the driver to reset the device when a fatal error is detected. When auto reset is enabled, the driver resets the device when it detects either an heartbeat failure or a fatal error through an interrupt. This patch is based on earlier work done by Shashank Gupta. Signed-off-by: Damian Muszynski Reviewed-by: Ahsan Atta Reviewed-by: Markas Rapoportas --- Documentation/ABI/testing/sysfs-driver-qat | 20 ++++++++++ .../intel/qat/qat_common/adf_accel_devices.h | 1 + drivers/crypto/intel/qat/qat_common/adf_aer.c | 11 +++++- .../intel/qat/qat_common/adf_common_drv.h | 1 + .../crypto/intel/qat/qat_common/adf_sysfs.c | 37 +++++++++++++++++++ 5 files changed, 69 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-driver-qat b/Documentation/ABI/testing/sysfs-driver-qat index bbf329cf0d67..6778f1fea874 100644 --- a/Documentation/ABI/testing/sysfs-driver-qat +++ b/Documentation/ABI/testing/sysfs-driver-qat @@ -141,3 +141,23 @@ Description: 64 This attribute is only available for qat_4xxx devices. + +What: /sys/bus/pci/devices//qat/auto_reset +Date: March 2024 +KernelVersion: 6.8 +Contact: qat-linux@intel.com +Description: (RW) Reports the current state of the autoreset feature + for a QAT device + + Write to the attribute to enable or disable device auto reset. + + Device auto reset is disabled by default. + + The values are:: + + * 1/Yy/on: auto reset enabled. If the device encounters an + unrecoverable error, it will be reset automatically. + * 0/Nn/off: auto reset disabled. If the device encounters an + unrecoverable error, it will not be reset. + + This attribute is only available for qat_4xxx devices. diff --git a/drivers/crypto/intel/qat/qat_common/adf_accel_devices.h b/drivers/crypto/intel/qat/qat_common/adf_accel_devices.h index 4a3c36aaa7ca..0f26aa976c8c 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_accel_devices.h +++ b/drivers/crypto/intel/qat/qat_common/adf_accel_devices.h @@ -402,6 +402,7 @@ struct adf_accel_dev { struct adf_error_counters ras_errors; struct mutex state_lock; /* protect state of the device */ bool is_vf; + bool autoreset_on_error; u32 accel_id; }; #endif diff --git a/drivers/crypto/intel/qat/qat_common/adf_aer.c b/drivers/crypto/intel/qat/qat_common/adf_aer.c index cd273b31db0e..b3d4b6b99c65 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_aer.c +++ b/drivers/crypto/intel/qat/qat_common/adf_aer.c @@ -204,6 +204,14 @@ const struct pci_error_handlers adf_err_handler = { }; EXPORT_SYMBOL_GPL(adf_err_handler); +int adf_dev_autoreset(struct adf_accel_dev *accel_dev) +{ + if (accel_dev->autoreset_on_error) + return adf_dev_aer_schedule_reset(accel_dev, ADF_DEV_RESET_ASYNC); + + return 0; +} + static void adf_notify_fatal_error_worker(struct work_struct *work) { struct adf_fatal_error_data *wq_data = @@ -215,10 +223,11 @@ static void adf_notify_fatal_error_worker(struct work_struct *work) if (!accel_dev->is_vf) { /* Disable arbitration to stop processing of new requests */ - if (hw_device->exit_arb) + if (accel_dev->autoreset_on_error && hw_device->exit_arb) hw_device->exit_arb(accel_dev); if (accel_dev->pf.vf_info) adf_pf2vf_notify_fatal_error(accel_dev); + adf_dev_autoreset(accel_dev); } kfree(wq_data); diff --git a/drivers/crypto/intel/qat/qat_common/adf_common_drv.h b/drivers/crypto/intel/qat/qat_common/adf_common_drv.h index 10891c9da6e7..57328249c89e 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_common_drv.h +++ b/drivers/crypto/intel/qat/qat_common/adf_common_drv.h @@ -87,6 +87,7 @@ int adf_ae_stop(struct adf_accel_dev *accel_dev); extern const struct pci_error_handlers adf_err_handler; void adf_reset_sbr(struct adf_accel_dev *accel_dev); void adf_reset_flr(struct adf_accel_dev *accel_dev); +int adf_dev_autoreset(struct adf_accel_dev *accel_dev); void adf_dev_restore(struct adf_accel_dev *accel_dev); int adf_init_aer(void); void adf_exit_aer(void); diff --git a/drivers/crypto/intel/qat/qat_common/adf_sysfs.c b/drivers/crypto/intel/qat/qat_common/adf_sysfs.c index d450dad32c9e..4e7f70d4049d 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_sysfs.c +++ b/drivers/crypto/intel/qat/qat_common/adf_sysfs.c @@ -204,6 +204,42 @@ static ssize_t pm_idle_enabled_store(struct device *dev, struct device_attribute } static DEVICE_ATTR_RW(pm_idle_enabled); +static ssize_t auto_reset_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + char *auto_reset; + struct adf_accel_dev *accel_dev; + + accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev)); + if (!accel_dev) + return -EINVAL; + + auto_reset = accel_dev->autoreset_on_error ? "on" : "off"; + + return sysfs_emit(buf, "%s\n", auto_reset); +} + +static ssize_t auto_reset_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct adf_accel_dev *accel_dev; + bool enabled = false; + int ret; + + ret = kstrtobool(buf, &enabled); + if (ret) + return ret; + + accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev)); + if (!accel_dev) + return -EINVAL; + + accel_dev->autoreset_on_error = enabled; + + return count; +} +static DEVICE_ATTR_RW(auto_reset); + static DEVICE_ATTR_RW(state); static DEVICE_ATTR_RW(cfg_services); @@ -291,6 +327,7 @@ static struct attribute *qat_attrs[] = { &dev_attr_pm_idle_enabled.attr, &dev_attr_rp2srv.attr, &dev_attr_num_rps.attr, + &dev_attr_auto_reset.attr, NULL, }; -- 2.34.1