scsi: mpt3sas: Fix system going into read-only mode
authorSreekanth Reddy <sreekanth.reddy@broadcom.com>
Wed, 17 Nov 2021 10:50:58 +0000 (16:20 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Dec 2021 08:04:47 +0000 (09:04 +0100)
commit8f13c5eddf507e83a97080dd267e24a036c1906a
tree0a184343cd1027a436dab0e78f0231ba308c216a
parent8485649a7655e791a6e4e9f15b4d30fdae937184
scsi: mpt3sas: Fix system going into read-only mode

[ Upstream commit 91202a01a2fb2b78da3d03811b6d3d973ae426aa ]

While determining the SAS address of a drive, the driver checks whether the
handle number is less than the HBA phy count or not. If the handle number
is less than the HBA phy count then driver assumes that this handle belongs
to HBA and hence it assigns the HBA SAS address.

During IOC firmware downgrade operation, if the number of HBA phys is
reduced and the OS drive's device handle drops below the phy count while
determining the drive's SAS address, the driver ends up using the HBA's SAS
address. This leads to a mismatch of drive's SAS address and hence the
driver unregisters the OS drive and the system goes into read-only mode.

Update the IOC's num_phys to the HBA phy count provided by actual loaded
firmware.

Link: https://lore.kernel.org/r/20211117105058.3505-1-sreekanth.reddy@broadcom.com
Fixes: a5e99fda0172 ("scsi: mpt3sas: Update hba_port objects after host reset")
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/scsi/mpt3sas/mpt3sas_base.h
drivers/scsi/mpt3sas/mpt3sas_scsih.c