linux/drivers/scsi/mpt2sas
Nagarajkumar Narayanan 6229b414b3 mpt2sas: setpci reset kernel oops fix
mpt2sas: setpci reset on nytro warpdrive card along with sysfs access and
cli ioctl access resulted in kernel oops

1. pci_access_mutex lock added to provide synchronization between IOCTL,
   sysfs, PCI resource handling path

2. gioc_lock spinlock to protect list operations over multiple
controllers

>From c53a1cff4c07528b8b9ec7f6716e94950283e8f9 Mon Sep 17 00:00:00 2001
From: Nagarajkumar Narayanan <nagarajkumar.narayanan@seagate.com>
Date: Tue, 18 Aug 2015 11:58:13 +0530
Subject: [PATCH] mpt2sas setpci reset oops fix

In mpt2sas driver due to lack of synchronization between ioctl,
BRM status access through sysfs, pci resource removal kernel oops
happen as ioctl path and BRM status sysfs access path still tries
to access the removed resources

Two locks added to provide syncrhonization

1. pci_access_mutex: Mutex to synchronize ioctl,sysfs show path and
pci resource handling. PCI resource freeing will lead to free
vital hardware/memory resource, which might be in use by cli/sysfs
path functions resulting in Null pointer reference followed by kernel
crash. To avoid the above race condition we use mutex syncrhonization
which ensures the syncrhonization between cli/sysfs_show path

Note: pci_access_mutex is used only if nytro warpdrive cards
(ioc->is_warpdrive based on device id) are used
as we could not test this case with other SAS2 HBA cards
We can remove this check if this behaviour confirmed from other
cards.

2. spinlock on list operations over IOCs

Case: when multiple warpdrive cards(IOCs) are in use
Each IOC will added to the ioc list stucture on initialization.
Watchdog threads run at regular intervals to check IOC for any
fault conditions which will trigger the dead_ioc thread to
deallocate pci resource, resulting deleting the IOC netry from list,
this deletion need to protected by spinlock to enusre that
ioc removal is syncrhonized, if not synchronized it might lead to
list_del corruption as the ioc list is traversed in cli path

Signed-off-by: Nagarajkumar Narayanan <nagarajkumar.narayanan@seagate.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Acked-by: Sreekanth Reddy <sreekanth.reddy@avagotech.com>
Signed-off-by: James Bottomley <JBottomley@Odin.com>
2015-09-06 11:57:25 -07:00
..
mpi mpt2sas: MPI2 Rev BB (2.00.20) specification and 2.00.35 header files 2015-01-13 16:27:25 +01:00
Kconfig mpt2sas: Copyright in driver sources is updated for year the 2014 2014-09-16 09:14:14 -07:00
Makefile
mpt2sas_base.c mpt2sas: setpci reset kernel oops fix 2015-09-06 11:57:25 -07:00
mpt2sas_base.h mpt2sas: setpci reset kernel oops fix 2015-09-06 11:57:25 -07:00
mpt2sas_config.c mpt2sas, mpt3sas: Update attribution language to Avago 2015-01-13 16:27:27 +01:00
mpt2sas_ctl.c mpt2sas: setpci reset kernel oops fix 2015-09-06 11:57:25 -07:00
mpt2sas_ctl.h mpt2sas, mpt3sas: Update attribution language to Avago 2015-01-13 16:27:27 +01:00
mpt2sas_debug.h mpt2sas, mpt3sas: Update attribution language to Avago 2015-01-13 16:27:27 +01:00
mpt2sas_scsih.c mpt2sas: setpci reset kernel oops fix 2015-09-06 11:57:25 -07:00
mpt2sas_transport.c mpt2sas: Refcount sas_device objects and fix unsafe list usage 2015-09-06 10:55:18 -07:00