Skip to content

Commit 1bd2b28

Browse files
umakrishnmartinkpetersen
authored andcommitted
cxlflash: Verify problem state area is mapped before notifying shutdown
If an EEH or some other hard error occurs while the adapter instance was being initialized, on the subsequent shutdown of the device, the system could crash with: [c000000f1da03b60] c0000000005eccfc pci_device_shutdown+0x6c/0x100 [c000000f1da03ba0] c0000000006d67d4 device_shutdown+0x1b4/0x2c0 [c000000f1da03c40] c0000000000ea30c kernel_restart_prepare+0x5c/0x80 [c000000f1da03c70] c0000000000ea48c kernel_restart+0x2c/0xc0 [c000000f1da03ce0] c0000000000ea970 SyS_reboot+0x1c0/0x2d0 [c000000f1da03e30] c000000000009204 system_call+0x38/0xb4 This crash is due to the AFU not being mapped when the shutdown notification routine is called and is a regression that was inserted recently with Commit 704c4b0 ("cxlflash: Shutdown notify support for CXL Flash cards"). As a fix, shutdown notification should only occur when the AFU is mapped. Fixes: 704c4b0 ("cxlflash: Shutdown notify support for CXL Flash cards") Signed-off-by: Uma Krishnan <[email protected]> Reviewed-by: Andrew Donnellan <[email protected]> Acked-by: Matthew R. Ochs <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 05a0587 commit 1bd2b28

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

drivers/scsi/cxlflash/main.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ static void notify_shutdown(struct cxlflash_cfg *cfg, bool wait)
778778
{
779779
struct afu *afu = cfg->afu;
780780
struct device *dev = &cfg->dev->dev;
781-
struct sisl_global_map __iomem *global = &afu->afu_map->global;
781+
struct sisl_global_map __iomem *global;
782782
struct dev_dependent_vals *ddv;
783783
u64 reg, status;
784784
int i, retry_cnt = 0;
@@ -787,6 +787,14 @@ static void notify_shutdown(struct cxlflash_cfg *cfg, bool wait)
787787
if (!(ddv->flags & CXLFLASH_NOTIFY_SHUTDOWN))
788788
return;
789789

790+
if (!afu || !afu->afu_map) {
791+
dev_dbg(dev, "%s: The problem state area is not mapped\n",
792+
__func__);
793+
return;
794+
}
795+
796+
global = &afu->afu_map->global;
797+
790798
/* Notify AFU */
791799
for (i = 0; i < NUM_FC_PORTS; i++) {
792800
reg = readq_be(&global->fc_regs[i][FC_CONFIG2 / 8]);

0 commit comments

Comments
 (0)