scsi: qla2xxx: disabling pci error handler early
Subsystems (2)
PATCH 1/1 scsi: qla2xxx: disabling pci error handler early
qla2x00_disable_board_on_pci_error and pcie error handlers may run in parallel. Specifically, I observed qla2xxx_pci_slot_reset running at around the same moment as qla2x00_disable_board_on_pci_error. If scsi_qla_host_t or qla_hw_data structs are removed before an error handler completes, the handler crashes.
This patch disables pcie error handling early in qla2x00_disable_board_on_pci_error and in other paths that remove those structs.
--- drivers/scsi/qla2xxx/qla_os.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/scsi/qla2xxx/qla_os.c +9 -6
@@ -2775,9 +2775,6 @@ static void qla2x00_iocb_work_fn(struct work_struct *work)return ret; } -/* This may fail but that's ok */ -pci_enable_pcie_error_reporting (pdev); - ha =kzalloc (sizeof (struct qla_hw_data ),GFP_KERNEL );if (!ha) { ql_log_pci(ql_log_fatal, pdev, 0x0009,
@@ -3039,6 +3036,9 @@ static void qla2x00_iocb_work_fn(struct work_struct *work) goto probe_hw_failed; } +/* This may fail but that's ok */ +pci_enable_pcie_error_reporting (pdev); +pci_set_drvdata (pdev, base_vha);set_bit (PFLG_DRIVER_PROBING , &base_vha->pci_flags);
@@ -3400,6 +3400,8 @@ static void qla2x00_iocb_work_fn(struct work_struct *work)kthread_stop (t); } +pci_disable_pcie_error_reporting (); +qla2x00_free_device (base_vha);scsi_host_put (base_vha->host);/*
@@ -3625,6 +3627,8 @@ static void qla2x00_iocb_work_fn(struct work_struct *work) }qla2x00_wait_for_hba_ready (base_vha); +pci_disable_pcie_error_reporting (pdev); +qla2x00_wait_for_sess_deletion (base_vha);/*
@@ -3698,8 +3702,6 @@ static void qla2x00_iocb_work_fn(struct work_struct *work)pci_release_selected_regions (ha->pdev, ha->bars);kfree (ha); -pci_disable_pcie_error_reporting (pdev); -pci_disable_device (pdev); }
@@ -5826,6 +5828,8 @@ void qla2x00_relogin(struct scsi_qla_host *vha)return ; } +pci_disable_pcie_error_reporting (pdev); +qla2x00_wait_for_sess_deletion (base_vha);set_bit (UNLOADING , &base_vha->dpc_flags);
@@ -5866,7 +5870,6 @@ void qla2x00_relogin(struct scsi_qla_host *vha)qla2x00_unmap_iobases (ha);pci_release_selected_regions (ha->pdev, ha->bars); -pci_disable_pcie_error_reporting (pdev);pci_disable_device (pdev);/*
Signature · 1 line
1.9.1
Quoted 9 lines · Anatoliy Glagolev
qla2x00_disable_board_on_pci_errorand pcie error handlers may run in parallel. Specifically, I observedqla2xxx_pci_slot_resetrunning at around the same moment asqla2x00_disable_board_on_pci_error. Ifscsi_qla_host_torqla_hw_datastructs are removed before an error handler completes, the handler crashes.This patch disables pcie error handling early in
qla2x00_disable_board_on_pci_errorand in other paths that remove those structs.
While this may fix this issue for PCIe AER, I think you'll still have the exposure for EEH errors on a Power system, since we don't have the pci_enable_pcie_error_reporting API wired up to do anything, nor do we have much ability to do anything with it since its an attribute of the hardware.
Is there a way to fix this that doesn't break Power?
Thanks,
Brian
Quoted 75 lines
Signed-off-by Anatoliy Glagolev <[email protected]>--- drivers/scsi/qla2xxx/qla_os.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)drivers/scsi/qla2xxx/qla_os.c +9
-6@@ -2775,9 +2775,6 @@ static void qla2x00_iocb_work_fn(struct work_struct *work)return ret; } -/* This may fail but that's ok */ -pci_enable_pcie_error_reporting (pdev); - ha =kzalloc (sizeof (struct qla_hw_data ),GFP_KERNEL );if (!ha) { ql_log_pci(ql_log_fatal, pdev, 0x0009,@@ -3039,6 +3036,9 @@ static void qla2x00_iocb_work_fn(struct work_struct *work) goto probe_hw_failed; } +/* This may fail but that's ok */ +pci_enable_pcie_error_reporting (pdev); +pci_set_drvdata (pdev, base_vha);set_bit (PFLG_DRIVER_PROBING , &base_vha->pci_flags);@@ -3400,6 +3400,8 @@ static void qla2x00_iocb_work_fn(struct work_struct *work)kthread_stop (t); } +pci_disable_pcie_error_reporting (); +qla2x00_free_device (base_vha);scsi_host_put (base_vha->host);/* @@ -3625,6 +3627,8 @@ static void qla2x00_iocb_work_fn(struct work_struct *work) }qla2x00_wait_for_hba_ready (base_vha); +pci_disable_pcie_error_reporting (pdev); +qla2x00_wait_for_sess_deletion (base_vha);/* @@ -3698,8 +3702,6 @@ static void qla2x00_iocb_work_fn(struct work_struct *work)pci_release_selected_regions (ha->pdev, ha->bars);kfree (ha); -pci_disable_pcie_error_reporting (pdev); -pci_disable_device (pdev); }@@ -5826,6 +5828,8 @@ void qla2x00_relogin(struct scsi_qla_host *vha)return ; } +pci_disable_pcie_error_reporting (pdev); +qla2x00_wait_for_sess_deletion (base_vha);set_bit (UNLOADING , &base_vha->dpc_flags);@@ -5866,7 +5870,6 @@ void qla2x00_relogin(struct scsi_qla_host *vha)qla2x00_unmap_iobases (ha);pci_release_selected_regions (ha->pdev, ha->bars); -pci_disable_pcie_error_reporting (pdev);pci_disable_device (pdev);/*
Signature · 3 lines
Brian King Power Linux I/O IBM Linux Technology Center
Thanks, Brian. Great point. Even for AER, it looks like in-flight error handler completion is not guaranteed on pci_disable_pcie_error_reporting call, so the crash is still possible. It looks like we need to maintain per-pci_dev context and keep track of in-flight callbacks to make a clean fix. I will send a new patch.
Quoted 105 lines · Brian King
Quoted 9 lines · Anatoliy Glagolev
qla2x00_disable_board_on_pci_errorand pcie error handlers may run in parallel. Specifically, I observedqla2xxx_pci_slot_resetrunning at around the same moment asqla2x00_disable_board_on_pci_error. Ifscsi_qla_host_torqla_hw_datastructs are removed before an error handler completes, the handler crashes.This patch disables pcie error handling early in
qla2x00_disable_board_on_pci_errorand in other paths that remove those structs.While this may fix this issue for PCIe AER, I think you'll still have the exposure for EEH errors on a Power system, since we don't have the
pci_enable_pcie_error_reportingAPI wired up to do anything, nor do we have much ability to do anything with it since its an attribute of the hardware.Is there a way to fix this that doesn't break Power?
Thanks,
Brian
Quoted 75 lines
Signed-off-by Anatoliy Glagolev <[email protected]>--- drivers/scsi/qla2xxx/qla_os.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)drivers/scsi/qla2xxx/qla_os.c +9
-6@@ -2775,9 +2775,6 @@ static void qla2x00_iocb_work_fn(struct work_struct *work)return ret; } -/* This may fail but that's ok */ -pci_enable_pcie_error_reporting (pdev); - ha =kzalloc (sizeof (struct qla_hw_data ),GFP_KERNEL );if (!ha) { ql_log_pci(ql_log_fatal, pdev, 0x0009,@@ -3039,6 +3036,9 @@ static void qla2x00_iocb_work_fn(struct work_struct *work) goto probe_hw_failed; } +/* This may fail but that's ok */ +pci_enable_pcie_error_reporting (pdev); +pci_set_drvdata (pdev, base_vha);set_bit (PFLG_DRIVER_PROBING , &base_vha->pci_flags);@@ -3400,6 +3400,8 @@ static void qla2x00_iocb_work_fn(struct work_struct *work)kthread_stop (t); } +pci_disable_pcie_error_reporting (); +qla2x00_free_device (base_vha);scsi_host_put (base_vha->host);/* @@ -3625,6 +3627,8 @@ static void qla2x00_iocb_work_fn(struct work_struct *work) }qla2x00_wait_for_hba_ready (base_vha); +pci_disable_pcie_error_reporting (pdev); +qla2x00_wait_for_sess_deletion (base_vha);/* @@ -3698,8 +3702,6 @@ static void qla2x00_iocb_work_fn(struct work_struct *work)pci_release_selected_regions (ha->pdev, ha->bars);kfree (ha); -pci_disable_pcie_error_reporting (pdev); -pci_disable_device (pdev); }@@ -5826,6 +5828,8 @@ void qla2x00_relogin(struct scsi_qla_host *vha)return ; } +pci_disable_pcie_error_reporting (pdev); +qla2x00_wait_for_sess_deletion (base_vha);set_bit (UNLOADING , &base_vha->dpc_flags);@@ -5866,7 +5870,6 @@ void qla2x00_relogin(struct scsi_qla_host *vha)qla2x00_unmap_iobases (ha);pci_release_selected_regions (ha->pdev, ha->bars); -pci_disable_pcie_error_reporting (pdev);pci_disable_device (pdev);/* Signature · 3 lines
Brian King Power Linux I/O IBM Linux Technology Center
PATCH v2 1/1 scsi: qla2xxx: pci error handler sync
In reply to Anatoliy Glagolevqla2x00_disable_board_on_pci_error and PCI error handlers may run in parallel. Specifically, I observed qla2xxx_pci_slot_reset running at around the same moment as qla2x00_disable_board_on_pci_error. If scsi_qla_host_t or qla_hw_data structs are removed before an error handler completes, the handler crashes.
This patch provides syncronization of paths deleting PCI device specific structs and PCI error handlers, so that the handlers always run race-free.
Under the most generic assumptions about the PCI error handling the handlers may run at any moment between pci_register_driver and pci_unregister_driver. Then we have to maintain per-pci_dev context with the state of in-flight handlers and the driver structures associated with pci_dev. The contet outlives both the structs and the pci_dev.
--- drivers/scsi/qla2xxx/Makefile | 3 +- drivers/scsi/qla2xxx/qla_os.c | 117 +++++++++++---- drivers/scsi/qla2xxx/qla_pci_error_handler.c | 212 +++++++++++++++++++++++++++ drivers/scsi/qla2xxx/qla_pci_error_handler.h | 46 ++++++ 4 files changed, 352 insertions(+), 26 deletions(-) create mode 100644 drivers/scsi/qla2xxx/qla_pci_error_handler.c create mode 100644 drivers/scsi/qla2xxx/qla_pci_error_handler.h
drivers/scsi/qla2xxx/Makefile +2 -1
@@ -1,7 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 qla2xxx-y := qla_os.o qla_init.o qla_mbx.o qla_iocb.o qla_isr.o qla_gs.o \ qla_dbg.o qla_sup.o qla_attr.o qla_mid.o qla_dfs.o qla_bsg.o \ - qla_nx.o qla_mr.o qla_nx2.o qla_target.o qla_tmpl.o qla_nvme.o + qla_nx.o qla_mr.o qla_nx2.o qla_target.o qla_tmpl.o qla_nvme.o \ + qla_pci_error_handler.o obj-$(CONFIG_SCSI_QLA_FC) += qla2xxx.o obj-$(CONFIG_TCM_QLA2XXX) += tcm_qla2xxx.o
drivers/scsi/qla2xxx/qla_os.c +92 -25
252 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_pci_error_handler.c new file +212 -0
212 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_pci_error_handler.h new file +46 -0
46 lines not on this page · raw message
Signature · 1 line
1.9.1