aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/mfi/mfivar.h
diff options
context:
space:
mode:
authorSteven Hartland <smh@FreeBSD.org>2013-02-27 02:21:10 +0000
committerSteven Hartland <smh@FreeBSD.org>2013-02-27 02:21:10 +0000
commit08c89430bd9b1871c26eac1a01e87d6b0cb4cbad (patch)
treea555daeab5c76d1d4bfacf0594a40bbce5110489 /sys/dev/mfi/mfivar.h
parent1a3a560767329f041ac725ab95462c02d7978fb4 (diff)
downloadsrc-08c89430bd9b1871c26eac1a01e87d6b0cb4cbad.tar.gz
src-08c89430bd9b1871c26eac1a01e87d6b0cb4cbad.zip
Fixes queuing issues where mfi_release_command blindly sets the cm_flags = 0
without first removing the command from the relavent queue. This was causing panics in the queue functions which check to ensure a command is not on another queue. Fixed some cases where the error from mfi_mapcmd was lost and where the command was never released / dequeued in error cases. Ensure that all failures to mfi_mapcmd are logged. Fixed possible null pointer exception in mfi_aen_setup if mfi_get_log_state failed. Fixed mfi_parse_entries & mfi_aen_setup not returning possible errors. Corrected MFI_DUMP_CMDS calls with invalid vars SC vs sc. Commands which have timed out now set cm_error to ETIMEDOUT and call mfi_complete which prevents them getting stuck in the busy queue forever. Fixed possible use of NULL pointer in mfi_tbolt_get_cmd. Changed output formats to be more easily recognisable when debugging. Optimised mfi_cmd_pool_tbolt cleanup. Made information about driver limiting commands always display as for modern cards this can be severe. Fixed mfi_tbolt_alloc_cmd out of memory case which previously didnt return an error. Added malloc checks for request_desc_pool including free when subsiquent errors are detected. Fixed overflow error in SIMD reply descriptor check. Fixed tbolt_cmd leak in mfi_build_and_issue_cmd if there's an error during IO build. Elimintated double checks on sc->mfi_aen_cm & sc->mfi_map_sync_cm in mfi_shutdown. Move local hdr calculation after error check in mfi_aen_complete. Fixed wakeup on NULL in mfi_aen_complete. Fixed mfi_aen_cm cleanup in mfi_process_fw_state_chg_isr not checking if it was NULL. Changed mfi_alloc_commands to error if bus_dmamap_create fails. Previously we would try to continue with the number of allocated commands but lots of places in the driver assume sc->mfi_max_fw_cmds is whats available so its unsafe to do this without lots of changes. Removed mfi_total_cmds as its no longer used due the above change. Corrected mfi_tbolt_alloc_cmd to return ENOMEM where appropriate. Fixed timeouts actually firing at double what they should. Setting hw.mfi.max_cmds=-1 now configures to use the controller max. A few style (9) fixes e.g. braced single line conditions and double blank lines Cleaned up queuing macros Removed invalid queuing tests for multiple queues Trap and deal with errors when doing sends in mfi_data_cb Refactored frame sending into one method with error checking of the return code so we can ensure commands aren't left on the queue after error. This ensures that mfi_mapcmd & mfi_data_cb leave the queue in a valid state. Refactored how commands are cleaned up, mfi_release_command now ensures that all queues and command state is maintained in a consistent state. Prevent NULL pointer use in mfi_tbolt_complete_cmd Fixed use of NULL sc->mfi_map_sync_cm in wakeup Added defines to help with output of mfi_cmd and header flags. Fixed mfi_tbolt_init_MFI_queue invalidating cm_index of the acquired mfi_cmd. Reset now reinitialises sync map as well as AEN. Fixed possible use of NULL pointer in mfi_build_and_issue_cmd Fixed mfi_tbolt_init_MFI_queue call to mfi_process_fw_state_chg_isr causing panic on failure. Ensure that tbolt cards always initialise next_host_reply_index and free_host_reply_index (based off mfi_max_fw_cmds) on both startup and reset as per the linux driver. Fixed mfi_tbolt_complete_cmd not acknowledging unknown commands so it didn't clear the controller. Prevent locks from being dropped and re-acquired in the following functions which was allowing multiple threads to enter critical methods such as mfi_tbolt_complete_cmd & mfi_process_fw_state_chg_isr:- * mfi_tbolt_init_MFI_queue * mfi_aen_complete / mfi_aen_register * mfi_tbolt_sync_map_info * mfi_get_log_state * mfi_parse_entries The locking for these functions was promoting to higher level methods. This also fixed MFI_LINUX_SET_AEN_2 which was already acquiring the lock, so would have paniced for recursive lock. This also required changing malloc of ld_sync in mfi_tbolt_sync_map_info to M_NOWAIT which can hence now fail but this was already expected as its return was being tested. Removed the assignment of cm_index in mfi_tbolt_init_MFI_queue which breaks the world if the cmd returned by mfi_dequeue_free isn't the first cmd. Fixed locking in mfi_data_cb, this is an async callback from bus_dmamap_load which could hence be called after the caller has dropped the lock. If we don't have the lock we aquire it and ensure we unlock before returning. Fixed locking mfi_comms_init when mfi_dequeue_free fails. Fixed mfi_build_and_issue_cmd not returning tbolt cmds aquired to the pool on error. Fixed mfi_abort not dropping the io lock when mfi_dequeue_free fails. Added hw.mfi.polled_cmd_timeout sysctl that enables tuning of polled timeouts. This shouldn't be reduced below 50 seconds as its used for firmware patching which can take quite some time. Added hw.mfi.fw_reset_test sysctl which is avaliable when compiled with MFI_DEBUG and allows the testing of controller reset that was provoking a large number of the issues encountered here. Reviewed by: Doug Ambrisko Approved by: pjd (mentor) MFC after: 1 month
Notes
Notes: svn path=/head/; revision=247369
Diffstat (limited to 'sys/dev/mfi/mfivar.h')
-rw-r--r--sys/dev/mfi/mfivar.h48
1 files changed, 28 insertions, 20 deletions
diff --git a/sys/dev/mfi/mfivar.h b/sys/dev/mfi/mfivar.h
index bb2a324b5143..664ede96ad78 100644
--- a/sys/dev/mfi/mfivar.h
+++ b/sys/dev/mfi/mfivar.h
@@ -102,12 +102,25 @@ struct mfi_command {
#define MFI_CMD_DATAOUT (1<<2)
#define MFI_CMD_COMPLETED (1<<3)
#define MFI_CMD_POLLED (1<<4)
-#define MFI_ON_MFIQ_FREE (1<<5)
-#define MFI_ON_MFIQ_READY (1<<6)
-#define MFI_ON_MFIQ_BUSY (1<<7)
-#define MFI_ON_MFIQ_MASK ((1<<5)|(1<<6)|(1<<7))
-#define MFI_CMD_SCSI (1<<8)
-#define MFI_CMD_CCB (1<<9)
+#define MFI_CMD_SCSI (1<<5)
+#define MFI_CMD_CCB (1<<6)
+#define MFI_CMD_TBOLT (1<<7)
+#define MFI_ON_MFIQ_FREE (1<<8)
+#define MFI_ON_MFIQ_READY (1<<9)
+#define MFI_ON_MFIQ_BUSY (1<<10)
+#define MFI_ON_MFIQ_MASK (MFI_ON_MFIQ_FREE | MFI_ON_MFIQ_READY| \
+ MFI_ON_MFIQ_BUSY)
+#define MFI_CMD_FLAGS_FMT "\20" \
+ "\1MAPPED" \
+ "\2DATAIN" \
+ "\3DATAOUT" \
+ "\4COMPLETED" \
+ "\5POLLED" \
+ "\6SCSI" \
+ "\7TBOLT" \
+ "\10Q_FREE" \
+ "\11Q_READY" \
+ "\12Q_BUSY"
uint8_t retry_for_fw_reset;
void (* cm_complete)(struct mfi_command *cm);
void *cm_private;
@@ -268,10 +281,6 @@ struct mfi_softc {
*/
struct mfi_command *mfi_commands;
/*
- * How many commands were actually allocated
- */
- int mfi_total_cmds;
- /*
* How many commands the firmware can handle. Also how big the reply
* queue is, minus 1.
*/
@@ -470,9 +479,8 @@ extern int mfi_build_cdb(int, uint8_t, u_int64_t, u_int32_t, uint8_t *);
mfi_enqueue_ ## name (struct mfi_command *cm) \
{ \
if ((cm->cm_flags & MFI_ON_MFIQ_MASK) != 0) { \
- printf("command %p is on another queue, " \
+ panic("command %p is on another queue, " \
"flags = %#x\n", cm, cm->cm_flags); \
- panic("command is on another queue"); \
} \
TAILQ_INSERT_TAIL(&cm->cm_sc->mfi_ ## name, cm, cm_link); \
cm->cm_flags |= MFI_ON_ ## index; \
@@ -482,9 +490,8 @@ extern int mfi_build_cdb(int, uint8_t, u_int64_t, u_int32_t, uint8_t *);
mfi_requeue_ ## name (struct mfi_command *cm) \
{ \
if ((cm->cm_flags & MFI_ON_MFIQ_MASK) != 0) { \
- printf("command %p is on another queue, " \
+ panic("command %p is on another queue, " \
"flags = %#x\n", cm, cm->cm_flags); \
- panic("command is on another queue"); \
} \
TAILQ_INSERT_HEAD(&cm->cm_sc->mfi_ ## name, cm, cm_link); \
cm->cm_flags |= MFI_ON_ ## index; \
@@ -497,10 +504,9 @@ extern int mfi_build_cdb(int, uint8_t, u_int64_t, u_int32_t, uint8_t *);
\
if ((cm = TAILQ_FIRST(&sc->mfi_ ## name)) != NULL) { \
if ((cm->cm_flags & MFI_ON_ ## index) == 0) { \
- printf("command %p not in queue, " \
+ panic("command %p not in queue, " \
"flags = %#x, bit = %#x\n", cm, \
cm->cm_flags, MFI_ON_ ## index); \
- panic("command not in queue"); \
} \
TAILQ_REMOVE(&sc->mfi_ ## name, cm, cm_link); \
cm->cm_flags &= ~MFI_ON_ ## index; \
@@ -512,10 +518,9 @@ extern int mfi_build_cdb(int, uint8_t, u_int64_t, u_int32_t, uint8_t *);
mfi_remove_ ## name (struct mfi_command *cm) \
{ \
if ((cm->cm_flags & MFI_ON_ ## index) == 0) { \
- printf("command %p not in queue, flags = %#x, " \
+ panic("command %p not in queue, flags = %#x, " \
"bit = %#x\n", cm, cm->cm_flags, \
MFI_ON_ ## index); \
- panic("command not in queue"); \
} \
TAILQ_REMOVE(&cm->cm_sc->mfi_ ## name, cm, cm_link); \
cm->cm_flags &= ~MFI_ON_ ## index; \
@@ -608,7 +613,8 @@ SYSCTL_DECL(_hw_mfi);
#ifdef MFI_DEBUG
extern void mfi_print_cmd(struct mfi_command *cm);
extern void mfi_dump_cmds(struct mfi_softc *sc);
-extern void mfi_validate_sg(struct mfi_softc *, struct mfi_command *, const char *, int );
+extern void mfi_validate_sg(struct mfi_softc *, struct mfi_command *,
+ const char *, int);
#define MFI_PRINT_CMD(cm) mfi_print_cmd(cm)
#define MFI_DUMP_CMDS(sc) mfi_dump_cmds(sc)
#define MFI_VALIDATE_CMD(sc, cm) mfi_validate_sg(sc, cm, __FUNCTION__, __LINE__)
@@ -618,6 +624,8 @@ extern void mfi_validate_sg(struct mfi_softc *, struct mfi_command *, const char
#define MFI_VALIDATE_CMD(sc, cm)
#endif
-extern void mfi_release_command(struct mfi_command *cm);
+extern void mfi_release_command(struct mfi_command *);
+extern void mfi_tbolt_return_cmd(struct mfi_softc *,
+ struct mfi_cmd_tbolt *, struct mfi_command *);
#endif /* _MFIVAR_H */