diff options
Diffstat (limited to 'drivers/scsi/esas2r/esas2r.h')
-rw-r--r-- | drivers/scsi/esas2r/esas2r.h | 132 |
1 files changed, 61 insertions, 71 deletions
diff --git a/drivers/scsi/esas2r/esas2r.h b/drivers/scsi/esas2r/esas2r.h index 0838e265e0b9..3fd305d6b67d 100644 --- a/drivers/scsi/esas2r/esas2r.h +++ b/drivers/scsi/esas2r/esas2r.h | |||
@@ -799,47 +799,47 @@ struct esas2r_adapter { | |||
799 | struct esas2r_target *targetdb_end; | 799 | struct esas2r_target *targetdb_end; |
800 | unsigned char *regs; | 800 | unsigned char *regs; |
801 | unsigned char *data_window; | 801 | unsigned char *data_window; |
802 | u32 volatile flags; | 802 | long flags; |
803 | #define AF_PORT_CHANGE (u32)(0x00000001) | 803 | #define AF_PORT_CHANGE 0 |
804 | #define AF_CHPRST_NEEDED (u32)(0x00000004) | 804 | #define AF_CHPRST_NEEDED 1 |
805 | #define AF_CHPRST_PENDING (u32)(0x00000008) | 805 | #define AF_CHPRST_PENDING 2 |
806 | #define AF_CHPRST_DETECTED (u32)(0x00000010) | 806 | #define AF_CHPRST_DETECTED 3 |
807 | #define AF_BUSRST_NEEDED (u32)(0x00000020) | 807 | #define AF_BUSRST_NEEDED 4 |
808 | #define AF_BUSRST_PENDING (u32)(0x00000040) | 808 | #define AF_BUSRST_PENDING 5 |
809 | #define AF_BUSRST_DETECTED (u32)(0x00000080) | 809 | #define AF_BUSRST_DETECTED 6 |
810 | #define AF_DISABLED (u32)(0x00000100) | 810 | #define AF_DISABLED 7 |
811 | #define AF_FLASH_LOCK (u32)(0x00000200) | 811 | #define AF_FLASH_LOCK 8 |
812 | #define AF_OS_RESET (u32)(0x00002000) | 812 | #define AF_OS_RESET 9 |
813 | #define AF_FLASHING (u32)(0x00004000) | 813 | #define AF_FLASHING 10 |
814 | #define AF_POWER_MGT (u32)(0x00008000) | 814 | #define AF_POWER_MGT 11 |
815 | #define AF_NVR_VALID (u32)(0x00010000) | 815 | #define AF_NVR_VALID 12 |
816 | #define AF_DEGRADED_MODE (u32)(0x00020000) | 816 | #define AF_DEGRADED_MODE 13 |
817 | #define AF_DISC_PENDING (u32)(0x00040000) | 817 | #define AF_DISC_PENDING 14 |
818 | #define AF_TASKLET_SCHEDULED (u32)(0x00080000) | 818 | #define AF_TASKLET_SCHEDULED 15 |
819 | #define AF_HEARTBEAT (u32)(0x00200000) | 819 | #define AF_HEARTBEAT 16 |
820 | #define AF_HEARTBEAT_ENB (u32)(0x00400000) | 820 | #define AF_HEARTBEAT_ENB 17 |
821 | #define AF_NOT_PRESENT (u32)(0x00800000) | 821 | #define AF_NOT_PRESENT 18 |
822 | #define AF_CHPRST_STARTED (u32)(0x01000000) | 822 | #define AF_CHPRST_STARTED 19 |
823 | #define AF_FIRST_INIT (u32)(0x02000000) | 823 | #define AF_FIRST_INIT 20 |
824 | #define AF_POWER_DOWN (u32)(0x04000000) | 824 | #define AF_POWER_DOWN 21 |
825 | #define AF_DISC_IN_PROG (u32)(0x08000000) | 825 | #define AF_DISC_IN_PROG 22 |
826 | #define AF_COMM_LIST_TOGGLE (u32)(0x10000000) | 826 | #define AF_COMM_LIST_TOGGLE 23 |
827 | #define AF_LEGACY_SGE_MODE (u32)(0x20000000) | 827 | #define AF_LEGACY_SGE_MODE 24 |
828 | #define AF_DISC_POLLED (u32)(0x40000000) | 828 | #define AF_DISC_POLLED 25 |
829 | u32 volatile flags2; | 829 | long flags2; |
830 | #define AF2_SERIAL_FLASH (u32)(0x00000001) | 830 | #define AF2_SERIAL_FLASH 0 |
831 | #define AF2_DEV_SCAN (u32)(0x00000002) | 831 | #define AF2_DEV_SCAN 1 |
832 | #define AF2_DEV_CNT_OK (u32)(0x00000004) | 832 | #define AF2_DEV_CNT_OK 2 |
833 | #define AF2_COREDUMP_AVAIL (u32)(0x00000008) | 833 | #define AF2_COREDUMP_AVAIL 3 |
834 | #define AF2_COREDUMP_SAVED (u32)(0x00000010) | 834 | #define AF2_COREDUMP_SAVED 4 |
835 | #define AF2_VDA_POWER_DOWN (u32)(0x00000100) | 835 | #define AF2_VDA_POWER_DOWN 5 |
836 | #define AF2_THUNDERLINK (u32)(0x00000200) | 836 | #define AF2_THUNDERLINK 6 |
837 | #define AF2_THUNDERBOLT (u32)(0x00000400) | 837 | #define AF2_THUNDERBOLT 7 |
838 | #define AF2_INIT_DONE (u32)(0x00000800) | 838 | #define AF2_INIT_DONE 8 |
839 | #define AF2_INT_PENDING (u32)(0x00001000) | 839 | #define AF2_INT_PENDING 9 |
840 | #define AF2_TIMER_TICK (u32)(0x00002000) | 840 | #define AF2_TIMER_TICK 10 |
841 | #define AF2_IRQ_CLAIMED (u32)(0x00004000) | 841 | #define AF2_IRQ_CLAIMED 11 |
842 | #define AF2_MSI_ENABLED (u32)(0x00008000) | 842 | #define AF2_MSI_ENABLED 12 |
843 | atomic_t disable_cnt; | 843 | atomic_t disable_cnt; |
844 | atomic_t dis_ints_cnt; | 844 | atomic_t dis_ints_cnt; |
845 | u32 int_stat; | 845 | u32 int_stat; |
@@ -1150,16 +1150,6 @@ void esas2r_queue_fw_event(struct esas2r_adapter *a, | |||
1150 | int data_sz); | 1150 | int data_sz); |
1151 | 1151 | ||
1152 | /* Inline functions */ | 1152 | /* Inline functions */ |
1153 | static inline u32 esas2r_lock_set_flags(volatile u32 *flags, u32 bits) | ||
1154 | { | ||
1155 | return test_and_set_bit(ilog2(bits), (volatile unsigned long *)flags); | ||
1156 | } | ||
1157 | |||
1158 | static inline u32 esas2r_lock_clear_flags(volatile u32 *flags, u32 bits) | ||
1159 | { | ||
1160 | return test_and_clear_bit(ilog2(bits), | ||
1161 | (volatile unsigned long *)flags); | ||
1162 | } | ||
1163 | 1153 | ||
1164 | /* Allocate a chip scatter/gather list entry */ | 1154 | /* Allocate a chip scatter/gather list entry */ |
1165 | static inline struct esas2r_mem_desc *esas2r_alloc_sgl(struct esas2r_adapter *a) | 1155 | static inline struct esas2r_mem_desc *esas2r_alloc_sgl(struct esas2r_adapter *a) |
@@ -1217,7 +1207,6 @@ static inline void esas2r_rq_init_request(struct esas2r_request *rq, | |||
1217 | struct esas2r_adapter *a) | 1207 | struct esas2r_adapter *a) |
1218 | { | 1208 | { |
1219 | union atto_vda_req *vrq = rq->vrq; | 1209 | union atto_vda_req *vrq = rq->vrq; |
1220 | u32 handle; | ||
1221 | 1210 | ||
1222 | INIT_LIST_HEAD(&rq->sg_table_head); | 1211 | INIT_LIST_HEAD(&rq->sg_table_head); |
1223 | rq->data_buf = (void *)(vrq + 1); | 1212 | rq->data_buf = (void *)(vrq + 1); |
@@ -1253,11 +1242,9 @@ static inline void esas2r_rq_init_request(struct esas2r_request *rq, | |||
1253 | 1242 | ||
1254 | /* | 1243 | /* |
1255 | * add a reference number to the handle to make it unique (until it | 1244 | * add a reference number to the handle to make it unique (until it |
1256 | * wraps of course) while preserving the upper word | 1245 | * wraps of course) while preserving the least significant word |
1257 | */ | 1246 | */ |
1258 | 1247 | vrq->scsi.handle = (a->cmd_ref_no++ << 16) | (u16)vrq->scsi.handle; | |
1259 | handle = be32_to_cpu(vrq->scsi.handle) & 0xFFFF0000; | ||
1260 | vrq->scsi.handle = cpu_to_be32(handle + a->cmd_ref_no++); | ||
1261 | 1248 | ||
1262 | /* | 1249 | /* |
1263 | * the following formats a SCSI request. the caller can override as | 1250 | * the following formats a SCSI request. the caller can override as |
@@ -1303,10 +1290,13 @@ static inline void esas2r_rq_destroy_request(struct esas2r_request *rq, | |||
1303 | 1290 | ||
1304 | static inline bool esas2r_is_tasklet_pending(struct esas2r_adapter *a) | 1291 | static inline bool esas2r_is_tasklet_pending(struct esas2r_adapter *a) |
1305 | { | 1292 | { |
1306 | return (a->flags & (AF_BUSRST_NEEDED | AF_BUSRST_DETECTED | 1293 | |
1307 | | AF_CHPRST_NEEDED | AF_CHPRST_DETECTED | 1294 | return test_bit(AF_BUSRST_NEEDED, &a->flags) || |
1308 | | AF_PORT_CHANGE)) | 1295 | test_bit(AF_BUSRST_DETECTED, &a->flags) || |
1309 | ? true : false; | 1296 | test_bit(AF_CHPRST_NEEDED, &a->flags) || |
1297 | test_bit(AF_CHPRST_DETECTED, &a->flags) || | ||
1298 | test_bit(AF_PORT_CHANGE, &a->flags); | ||
1299 | |||
1310 | } | 1300 | } |
1311 | 1301 | ||
1312 | /* | 1302 | /* |
@@ -1345,24 +1335,24 @@ static inline void esas2r_enable_chip_interrupts(struct esas2r_adapter *a) | |||
1345 | static inline void esas2r_schedule_tasklet(struct esas2r_adapter *a) | 1335 | static inline void esas2r_schedule_tasklet(struct esas2r_adapter *a) |
1346 | { | 1336 | { |
1347 | /* make sure we don't schedule twice */ | 1337 | /* make sure we don't schedule twice */ |
1348 | if (!(esas2r_lock_set_flags(&a->flags, AF_TASKLET_SCHEDULED) & | 1338 | if (!test_and_set_bit(AF_TASKLET_SCHEDULED, &a->flags)) |
1349 | ilog2(AF_TASKLET_SCHEDULED))) | ||
1350 | tasklet_hi_schedule(&a->tasklet); | 1339 | tasklet_hi_schedule(&a->tasklet); |
1351 | } | 1340 | } |
1352 | 1341 | ||
1353 | static inline void esas2r_enable_heartbeat(struct esas2r_adapter *a) | 1342 | static inline void esas2r_enable_heartbeat(struct esas2r_adapter *a) |
1354 | { | 1343 | { |
1355 | if (!(a->flags & (AF_DEGRADED_MODE | AF_CHPRST_PENDING)) | 1344 | if (!test_bit(AF_DEGRADED_MODE, &a->flags) && |
1356 | && (a->nvram->options2 & SASNVR2_HEARTBEAT)) | 1345 | !test_bit(AF_CHPRST_PENDING, &a->flags) && |
1357 | esas2r_lock_set_flags(&a->flags, AF_HEARTBEAT_ENB); | 1346 | (a->nvram->options2 & SASNVR2_HEARTBEAT)) |
1347 | set_bit(AF_HEARTBEAT_ENB, &a->flags); | ||
1358 | else | 1348 | else |
1359 | esas2r_lock_clear_flags(&a->flags, AF_HEARTBEAT_ENB); | 1349 | clear_bit(AF_HEARTBEAT_ENB, &a->flags); |
1360 | } | 1350 | } |
1361 | 1351 | ||
1362 | static inline void esas2r_disable_heartbeat(struct esas2r_adapter *a) | 1352 | static inline void esas2r_disable_heartbeat(struct esas2r_adapter *a) |
1363 | { | 1353 | { |
1364 | esas2r_lock_clear_flags(&a->flags, AF_HEARTBEAT_ENB); | 1354 | clear_bit(AF_HEARTBEAT_ENB, &a->flags); |
1365 | esas2r_lock_clear_flags(&a->flags, AF_HEARTBEAT); | 1355 | clear_bit(AF_HEARTBEAT, &a->flags); |
1366 | } | 1356 | } |
1367 | 1357 | ||
1368 | /* Set the initial state for resetting the adapter on the next pass through | 1358 | /* Set the initial state for resetting the adapter on the next pass through |
@@ -1372,9 +1362,9 @@ static inline void esas2r_local_reset_adapter(struct esas2r_adapter *a) | |||
1372 | { | 1362 | { |
1373 | esas2r_disable_heartbeat(a); | 1363 | esas2r_disable_heartbeat(a); |
1374 | 1364 | ||
1375 | esas2r_lock_set_flags(&a->flags, AF_CHPRST_NEEDED); | 1365 | set_bit(AF_CHPRST_NEEDED, &a->flags); |
1376 | esas2r_lock_set_flags(&a->flags, AF_CHPRST_PENDING); | 1366 | set_bit(AF_CHPRST_PENDING, &a->flags); |
1377 | esas2r_lock_set_flags(&a->flags, AF_DISC_PENDING); | 1367 | set_bit(AF_DISC_PENDING, &a->flags); |
1378 | } | 1368 | } |
1379 | 1369 | ||
1380 | /* See if an interrupt is pending on the adapter. */ | 1370 | /* See if an interrupt is pending on the adapter. */ |