aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/mpt2sas/mpt2sas_base.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/mpt2sas/mpt2sas_base.h')
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_base.h41
1 files changed, 39 insertions, 2 deletions
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h b/drivers/scsi/mpt2sas/mpt2sas_base.h
index caff8d10cca4..97ea360c6920 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.h
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.h
@@ -238,6 +238,7 @@
238 * @flags: MPT_TARGET_FLAGS_XXX flags 238 * @flags: MPT_TARGET_FLAGS_XXX flags
239 * @deleted: target flaged for deletion 239 * @deleted: target flaged for deletion
240 * @tm_busy: target is busy with TM request. 240 * @tm_busy: target is busy with TM request.
241 * @sdev: The sas_device associated with this target
241 */ 242 */
242struct MPT2SAS_TARGET { 243struct MPT2SAS_TARGET {
243 struct scsi_target *starget; 244 struct scsi_target *starget;
@@ -248,6 +249,7 @@ struct MPT2SAS_TARGET {
248 u32 flags; 249 u32 flags;
249 u8 deleted; 250 u8 deleted;
250 u8 tm_busy; 251 u8 tm_busy;
252 struct _sas_device *sdev;
251}; 253};
252 254
253 255
@@ -376,8 +378,24 @@ struct _sas_device {
376 u8 phy; 378 u8 phy;
377 u8 responding; 379 u8 responding;
378 u8 pfa_led_on; 380 u8 pfa_led_on;
381 struct kref refcount;
379}; 382};
380 383
384static inline void sas_device_get(struct _sas_device *s)
385{
386 kref_get(&s->refcount);
387}
388
389static inline void sas_device_free(struct kref *r)
390{
391 kfree(container_of(r, struct _sas_device, refcount));
392}
393
394static inline void sas_device_put(struct _sas_device *s)
395{
396 kref_put(&s->refcount, sas_device_free);
397}
398
381/** 399/**
382 * struct _raid_device - raid volume link list 400 * struct _raid_device - raid volume link list
383 * @list: sas device list 401 * @list: sas device list
@@ -799,6 +817,12 @@ typedef void (*MPT2SAS_FLUSH_RUNNING_CMDS)(struct MPT2SAS_ADAPTER *ioc);
799 * @delayed_tr_list: target reset link list 817 * @delayed_tr_list: target reset link list
800 * @delayed_tr_volume_list: volume target reset link list 818 * @delayed_tr_volume_list: volume target reset link list
801 * @@temp_sensors_count: flag to carry the number of temperature sensors 819 * @@temp_sensors_count: flag to carry the number of temperature sensors
820 * @pci_access_mutex: Mutex to synchronize ioctl,sysfs show path and
821 * pci resource handling. PCI resource freeing will lead to free
822 * vital hardware/memory resource, which might be in use by cli/sysfs
823 * path functions resulting in Null pointer reference followed by kernel
824 * crash. To avoid the above race condition we use mutex syncrhonization
825 * which ensures the syncrhonization between cli/sysfs_show path
802 */ 826 */
803struct MPT2SAS_ADAPTER { 827struct MPT2SAS_ADAPTER {
804 struct list_head list; 828 struct list_head list;
@@ -1015,6 +1039,7 @@ struct MPT2SAS_ADAPTER {
1015 u8 mfg_pg10_hide_flag; 1039 u8 mfg_pg10_hide_flag;
1016 u8 hide_drives; 1040 u8 hide_drives;
1017 1041
1042 struct mutex pci_access_mutex;
1018}; 1043};
1019 1044
1020typedef u8 (*MPT_CALLBACK)(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index, 1045typedef u8 (*MPT_CALLBACK)(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
@@ -1023,6 +1048,17 @@ typedef u8 (*MPT_CALLBACK)(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
1023 1048
1024/* base shared API */ 1049/* base shared API */
1025extern struct list_head mpt2sas_ioc_list; 1050extern struct list_head mpt2sas_ioc_list;
1051/* spinlock on list operations over IOCs
1052 * Case: when multiple warpdrive cards(IOCs) are in use
1053 * Each IOC will added to the ioc list stucture on initialization.
1054 * Watchdog threads run at regular intervals to check IOC for any
1055 * fault conditions which will trigger the dead_ioc thread to
1056 * deallocate pci resource, resulting deleting the IOC netry from list,
1057 * this deletion need to protected by spinlock to enusre that
1058 * ioc removal is syncrhonized, if not synchronized it might lead to
1059 * list_del corruption as the ioc list is traversed in cli path
1060 */
1061extern spinlock_t gioc_lock;
1026void mpt2sas_base_start_watchdog(struct MPT2SAS_ADAPTER *ioc); 1062void mpt2sas_base_start_watchdog(struct MPT2SAS_ADAPTER *ioc);
1027void mpt2sas_base_stop_watchdog(struct MPT2SAS_ADAPTER *ioc); 1063void mpt2sas_base_stop_watchdog(struct MPT2SAS_ADAPTER *ioc);
1028 1064
@@ -1095,11 +1131,12 @@ struct _sas_node *mpt2sas_scsih_expander_find_by_handle(struct MPT2SAS_ADAPTER *
1095 u16 handle); 1131 u16 handle);
1096struct _sas_node *mpt2sas_scsih_expander_find_by_sas_address(struct MPT2SAS_ADAPTER 1132struct _sas_node *mpt2sas_scsih_expander_find_by_sas_address(struct MPT2SAS_ADAPTER
1097 *ioc, u64 sas_address); 1133 *ioc, u64 sas_address);
1098struct _sas_device *mpt2sas_scsih_sas_device_find_by_sas_address( 1134struct _sas_device *mpt2sas_get_sdev_by_addr(
1135 struct MPT2SAS_ADAPTER *ioc, u64 sas_address);
1136struct _sas_device *__mpt2sas_get_sdev_by_addr(
1099 struct MPT2SAS_ADAPTER *ioc, u64 sas_address); 1137 struct MPT2SAS_ADAPTER *ioc, u64 sas_address);
1100 1138
1101void mpt2sas_port_enable_complete(struct MPT2SAS_ADAPTER *ioc); 1139void mpt2sas_port_enable_complete(struct MPT2SAS_ADAPTER *ioc);
1102
1103void mpt2sas_scsih_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase); 1140void mpt2sas_scsih_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase);
1104 1141
1105/* config shared API */ 1142/* config shared API */