Commit 64dfe495 authored by Yang Shen's avatar Yang Shen Committed by Herbert Xu

crypto: hisilicon/qm - register callback function to 'pci_driver.shutdown'

Since the drivers such as HPRE/SEC/ZIP do not implement
'pci_driver.shutdow', a RAS will be triggered at OS rebooting or shutting
down as the hardware device is processing request.
The log looks like this:
	NOTICE:  [NimbusSecNodeType1]:[2372L]This is sec, Base = 0x141800000
	NOTICE:  [NimbusSecHandle]:[2319L] SecIntSt = 0x3
	NOTICE:  [NimbusSecHandle]:[2320L] SecQmIntStatus = 0x2
	NOTICE:  [PrintSecurityType]:[344L] SecurityType is RECOVERABLE!

This patch offers a new API in qm to shutdown devices, and add shutdown
callbacks in ACC driver based on this new API.

So the running devices will be stopped when the OS reboot or shutdown.
Signed-off-by: default avatarYang Shen <shenyang39@huawei.com>
Reviewed-by: default avatarZhou Wang <wangzhou1@hisilicon.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 8d8f8d49
...@@ -939,6 +939,7 @@ static struct pci_driver hpre_pci_driver = { ...@@ -939,6 +939,7 @@ static struct pci_driver hpre_pci_driver = {
.sriov_configure = IS_ENABLED(CONFIG_PCI_IOV) ? .sriov_configure = IS_ENABLED(CONFIG_PCI_IOV) ?
hisi_qm_sriov_configure : NULL, hisi_qm_sriov_configure : NULL,
.err_handler = &hpre_err_handler, .err_handler = &hpre_err_handler,
.shutdown = hisi_qm_dev_shutdown,
}; };
static void hpre_register_debugfs(void) static void hpre_register_debugfs(void)
......
...@@ -3837,6 +3837,23 @@ static int qm_irq_register(struct hisi_qm *qm) ...@@ -3837,6 +3837,23 @@ static int qm_irq_register(struct hisi_qm *qm)
return ret; return ret;
} }
/**
* hisi_qm_dev_shutdown() - Shutdown device.
* @pdev: The device will be shutdown.
*
* This function will stop qm when OS shutdown or rebooting.
*/
void hisi_qm_dev_shutdown(struct pci_dev *pdev)
{
struct hisi_qm *qm = pci_get_drvdata(pdev);
int ret;
ret = hisi_qm_stop(qm, QM_NORMAL);
if (ret)
dev_err(&pdev->dev, "Fail to stop qm in shutdown!\n");
}
EXPORT_SYMBOL_GPL(hisi_qm_dev_shutdown);
static void hisi_qm_controller_reset(struct work_struct *rst_work) static void hisi_qm_controller_reset(struct work_struct *rst_work)
{ {
struct hisi_qm *qm = container_of(rst_work, struct hisi_qm, rst_work); struct hisi_qm *qm = container_of(rst_work, struct hisi_qm, rst_work);
......
...@@ -390,4 +390,5 @@ void hisi_acc_free_sgl_pool(struct device *dev, ...@@ -390,4 +390,5 @@ void hisi_acc_free_sgl_pool(struct device *dev,
int hisi_qm_alloc_qps_node(struct hisi_qm_list *qm_list, int qp_num, int hisi_qm_alloc_qps_node(struct hisi_qm_list *qm_list, int qp_num,
u8 alg_type, int node, struct hisi_qp **qps); u8 alg_type, int node, struct hisi_qp **qps);
void hisi_qm_free_qps(struct hisi_qp **qps, int qp_num); void hisi_qm_free_qps(struct hisi_qp **qps, int qp_num);
void hisi_qm_dev_shutdown(struct pci_dev *pdev);
#endif #endif
...@@ -950,6 +950,7 @@ static struct pci_driver sec_pci_driver = { ...@@ -950,6 +950,7 @@ static struct pci_driver sec_pci_driver = {
.remove = sec_remove, .remove = sec_remove,
.err_handler = &sec_err_handler, .err_handler = &sec_err_handler,
.sriov_configure = hisi_qm_sriov_configure, .sriov_configure = hisi_qm_sriov_configure,
.shutdown = hisi_qm_dev_shutdown,
}; };
static void sec_register_debugfs(void) static void sec_register_debugfs(void)
......
...@@ -866,6 +866,7 @@ static struct pci_driver hisi_zip_pci_driver = { ...@@ -866,6 +866,7 @@ static struct pci_driver hisi_zip_pci_driver = {
.sriov_configure = IS_ENABLED(CONFIG_PCI_IOV) ? .sriov_configure = IS_ENABLED(CONFIG_PCI_IOV) ?
hisi_qm_sriov_configure : NULL, hisi_qm_sriov_configure : NULL,
.err_handler = &hisi_zip_err_handler, .err_handler = &hisi_zip_err_handler,
.shutdown = hisi_qm_dev_shutdown,
}; };
static void hisi_zip_register_debugfs(void) static void hisi_zip_register_debugfs(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment