Commit 70a0c711 authored by Furong Zhou's avatar Furong Zhou Committed by Aichun Shi
Browse files

crypto: qat - add fatal error notify method

mainline inclusion
from mainline-v6.9-rc1
commit ae508d7afb753f7576c435226e32b9535b7f8b10
category: feature
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/I9A5BW
CVE: N/A
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ae508d7afb753f7576c435226e32b9535b7f8b10



-------------------------------------

Add error notify method to report a fatal error event to all the
subsystems registered. In addition expose an API,
adf_notify_fatal_error(), that allows to trigger a fatal error
notification asynchronously in the context of a workqueue.

This will be invoked when a fatal error is detected by the ISR or
through Heartbeat.

Intel-SIG: commit ae508d7afb75 crypto: qat - add fatal error notify method
Backport to support QAT in-tree driver

Signed-off-by: default avatarFurong Zhou <furong.zhou@intel.com>
Reviewed-by: default avatarAhsan Atta <ahsan.atta@intel.com>
Reviewed-by: default avatarMarkas Rapoportas <markas.rapoportas@intel.com>
Reviewed-by: default avatarGiovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: default avatarMun Chun Yep <mun.chun.yep@intel.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
[ Aichun Shi: amend commit log ]
Signed-off-by: default avatarAichun Shi <aichun.shi@intel.com>
parent f6e326b7
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -8,6 +8,11 @@
#include "adf_accel_devices.h"
#include "adf_common_drv.h"

struct adf_fatal_error_data {
	struct adf_accel_dev *accel_dev;
	struct work_struct work;
};

static struct workqueue_struct *device_reset_wq;

static pci_ers_result_t adf_error_detected(struct pci_dev *pdev,
@@ -171,6 +176,31 @@ const struct pci_error_handlers adf_err_handler = {
};
EXPORT_SYMBOL_GPL(adf_err_handler);

static void adf_notify_fatal_error_worker(struct work_struct *work)
{
	struct adf_fatal_error_data *wq_data =
			container_of(work, struct adf_fatal_error_data, work);
	struct adf_accel_dev *accel_dev = wq_data->accel_dev;

	adf_error_notifier(accel_dev);
	kfree(wq_data);
}

int adf_notify_fatal_error(struct adf_accel_dev *accel_dev)
{
	struct adf_fatal_error_data *wq_data;

	wq_data = kzalloc(sizeof(*wq_data), GFP_ATOMIC);
	if (!wq_data)
		return -ENOMEM;

	wq_data->accel_dev = accel_dev;
	INIT_WORK(&wq_data->work, adf_notify_fatal_error_worker);
	adf_misc_wq_queue_work(&wq_data->work);

	return 0;
}

int adf_init_aer(void)
{
	device_reset_wq = alloc_workqueue("qat_device_reset_wq",
+3 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ enum adf_event {
	ADF_EVENT_SHUTDOWN,
	ADF_EVENT_RESTARTING,
	ADF_EVENT_RESTARTED,
	ADF_EVENT_FATAL_ERROR,
};

struct service_hndl {
@@ -60,6 +61,8 @@ int adf_dev_restart(struct adf_accel_dev *accel_dev);

void adf_devmgr_update_class_index(struct adf_hw_device_data *hw_data);
void adf_clean_vf_map(bool);
int adf_notify_fatal_error(struct adf_accel_dev *accel_dev);
void adf_error_notifier(struct adf_accel_dev *accel_dev);
int adf_devmgr_add_dev(struct adf_accel_dev *accel_dev,
		       struct adf_accel_dev *pf);
void adf_devmgr_rm_dev(struct adf_accel_dev *accel_dev,
+12 −0
Original line number Diff line number Diff line
@@ -433,6 +433,18 @@ int adf_dev_restarted_notify(struct adf_accel_dev *accel_dev)
	return 0;
}

void adf_error_notifier(struct adf_accel_dev *accel_dev)
{
	struct service_hndl *service;

	list_for_each_entry(service, &service_table, list) {
		if (service->event_hld(accel_dev, ADF_EVENT_FATAL_ERROR))
			dev_err(&GET_DEV(accel_dev),
				"Failed to send error event to %s.\n",
				service->name);
	}
}

static int adf_dev_shutdown_cache_cfg(struct adf_accel_dev *accel_dev)
{
	char services[ADF_CFG_MAX_VAL_LEN_IN_BYTES] = {0};