mpt2sas: Target Reset will be issued from Interrupt context.
PATCH 5/9 mpt2sas: Target Reset will be issued from Interrupt context.
(1) Added three new functions to handle sending target resest and OP_REMOVE from interrupt time, they are _scsih_tm_tr_send, _scsih_tm_tr_complete, and _scsih_sas_control_complete. This code will create a link list of pending target resets if there is no more available request in the hipriority request queue. The list is stored in ioc->delayed_tr_list.
(2) All callback handler return type is changed from void to u8. Now _base_interrupt will check for return type of callback handlers to take decision of message frame is already freed or not.
In genral,
Return 1 meaning mf should be freed from _base_interrupt
0 means the mf is freed from function.
---
drivers/scsi/mpt2sas/mpt2sas_base.c +25 -10
@@ -575,9 +575,10 @@ _base_display_reply_info(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,* @msix_index: MSIX table index supplied by the OS * @reply: reply message frame(lower 32bit addr) * -* Return nothing. +* Return 1 meaning mf should be freed from _base_interrupt +* 0 means the mf is freed from this function. */ -void +u8 mpt2sas_base_done (struct MPT2SAS_ADAPTER *ioc,u16 smid,u8 msix_index,u32 reply) {
@@ -585,10 +586,10 @@ mpt2sas_base_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index, mpi_reply =mpt2sas_base_get_reply_virt_addr (ioc, reply);if (mpi_reply && mpi_reply->Function ==MPI2_FUNCTION_EVENT_ACK ) -return ; +return 1 ;if (ioc->base_cmds.status ==MPT2_CMD_NOT_USED ) -return ; +return 1 ; ioc->base_cmds.status |=MPT2_CMD_COMPLETE ;if (mpi_reply) {
@@ -597,6 +598,7 @@ mpt2sas_base_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index, } ioc->base_cmds.status &= ~MPT2_CMD_PENDING ;complete (&ioc->base_cmds.done); +return 1 ; }/**
@@ -605,9 +607,10 @@ mpt2sas_base_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,* @msix_index: MSIX table index supplied by the OS * @reply: reply message frame(lower 32bit addr) * -* Return nothing. +* Return 1 meaning mf should be freed from _base_interrupt +* 0 means the mf is freed from this function. */ -static void +static u8 _base_async_event (struct MPT2SAS_ADAPTER *ioc,u8 msix_index,u32 reply) {Mpi2EventNotificationReply_t *mpi_reply;
@@ -616,9 +619,9 @@ _base_async_event(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, u32 reply) mpi_reply =mpt2sas_base_get_reply_virt_addr (ioc, reply);if (!mpi_reply) -return ; +return 1 ;if (mpi_reply->Function !=MPI2_FUNCTION_EVENT_NOTIFICATION ) -return ; +return 1 ;#ifdef CONFIG_SCSI_MPT2SAS_LOGGING _base_display_event_data (ioc, mpi_reply);#endif
@@ -647,6 +650,8 @@ _base_async_event(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, u32 reply)/* ctl callback handler */ mpt2sas_ctl_event_callback (ioc, msix_index, reply); + +return 1 ; }/**
@@ -745,6 +750,7 @@ _base_interrupt(int irq, void *bus_id)u8 msix_index;struct MPT2SAS_ADAPTER *ioc = bus_id;Mpi2ReplyDescriptorsUnion_t *rpf; +u8 rc;if (ioc->mask_interrupts)return IRQ_NONE ;
@@ -777,12 +783,13 @@ _base_interrupt(int irq, void *bus_id)if (smid) cb_idx =_base_get_cb_idx (ioc, smid);if (smid && cb_idx !=0xFF ) { - mpt_callbacks[cb_idx](ioc, smid, msix_index, + rc = mpt_callbacks[cb_idx](ioc, smid, msix_index, reply);if (reply)_base_display_reply_info (ioc, smid, msix_index, reply); -mpt2sas_base_free_smid (ioc, smid); +if (rc) +mpt2sas_base_free_smid (ioc, smid); }if (!smid)_base_async_event (ioc, msix_index, reply);
@@ -3323,10 +3330,18 @@ _base_make_ioc_operational(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)unsigned long flags;u32 reply_address;u16 smid; +struct _tr_list *delayed_tr, *delayed_tr_next;dinitprintk (ioc,printk (MPT2SAS_DEBUG_FMT "%s\n" , ioc->name, __func__)); +/* clean the delayed target reset list */ +list_for_each_entry_safe (delayed_tr, delayed_tr_next, + &ioc->delayed_tr_list, list) { +list_del (&delayed_tr->list); +kfree (delayed_tr); + } +/* initialize the scsi lookup free list */ spin_lock_irqsave (&ioc->scsi_lookup_lock, flags);INIT_LIST_HEAD (&ioc->free_list);
drivers/scsi/mpt2sas/mpt2sas_base.h +30 -11
117 lines not on this page · raw message
drivers/scsi/mpt2sas/mpt2sas_config.c +6 -4
@@ -233,18 +233,19 @@ _config_free_config_dma_memory(struct MPT2SAS_ADAPTER *ioc,* * The callback handler when using _config_request. * -* Return nothing. +* Return 1 meaning mf should be freed from _base_interrupt +* 0 means the mf is freed from this function. */ -void +u8 mpt2sas_config_done (struct MPT2SAS_ADAPTER *ioc,u16 smid,u8 msix_index,u32 reply) {MPI2DefaultReply_t *mpi_reply;if (ioc->config_cmds.status ==MPT2_CMD_NOT_USED ) -return ; +return 1 ;if (ioc->config_cmds.smid != smid) -return ; +return 1 ; ioc->config_cmds.status |=MPT2_CMD_COMPLETE ; mpi_reply =mpt2sas_base_get_reply_virt_addr (ioc, reply);if (mpi_reply) {
@@ -258,6 +259,7 @@ mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,#endif ioc->config_cmds.smid =USHORT_MAX ;complete (&ioc->config_cmds.done); +return 1 ; }/**
drivers/scsi/mpt2sas/mpt2sas_ctl.c +10 -6
@@ -225,18 +225,19 @@ _ctl_display_some_debug(struct MPT2SAS_ADAPTER *ioc, u16 smid,* * The callback handler when using ioc->ctl_cb_idx. * -* Return nothing. +* Return 1 meaning mf should be freed from _base_interrupt +* 0 means the mf is freed from this function. */ -void +u8 mpt2sas_ctl_done (struct MPT2SAS_ADAPTER *ioc,u16 smid,u8 msix_index,u32 reply) {MPI2DefaultReply_t *mpi_reply;if (ioc->ctl_cmds.status ==MPT2_CMD_NOT_USED ) -return ; +return 1 ;if (ioc->ctl_cmds.smid != smid) -return ; +return 1 ; ioc->ctl_cmds.status |=MPT2_CMD_COMPLETE ; mpi_reply =mpt2sas_base_get_reply_virt_addr (ioc, reply);if (mpi_reply) {
@@ -248,6 +249,7 @@ mpt2sas_ctl_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,#endif ioc->ctl_cmds.status &= ~MPT2_CMD_PENDING ;complete (&ioc->ctl_cmds.done); +return 1 ; }/**
@@ -336,9 +338,10 @@ mpt2sas_ctl_add_to_event_log(struct MPT2SAS_ADAPTER *ioc,* This function merely adds a new work task into ioc->firmware_event_thread. * The tasks are worked from _firmware_event_work in user context. * -* Return nothing. +* Return 1 meaning mf should be freed from _base_interrupt +* 0 means the mf is freed from this function. */ -void +u8 mpt2sas_ctl_event_callback (struct MPT2SAS_ADAPTER *ioc,u8 msix_index,u32 reply) {
@@ -346,6 +349,7 @@ mpt2sas_ctl_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, mpi_reply =mpt2sas_base_get_reply_virt_addr (ioc, reply);mpt2sas_ctl_add_to_event_log (ioc, mpi_reply); +return 1 ; }/**
drivers/scsi/mpt2sas/mpt2sas_scsih.c +295 -19
477 lines not on this page · raw message
drivers/scsi/mpt2sas/mpt2sas_transport.c +6 -4
@@ -218,9 +218,10 @@ _transport_set_identify(struct MPT2SAS_ADAPTER *ioc, u16 handle,* Callback handler when sending internal generated transport cmds. * The callback index passed is `ioc->transport_cb_idx` * -* Return nothing. +* Return 1 meaning mf should be freed from _base_interrupt +* 0 means the mf is freed from this function. */ -void +u8 mpt2sas_transport_done (struct MPT2SAS_ADAPTER *ioc,u16 smid,u8 msix_index,u32 reply) {
@@ -228,9 +229,9 @@ mpt2sas_transport_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index, mpi_reply =mpt2sas_base_get_reply_virt_addr (ioc, reply);if (ioc->transport_cmds.status ==MPT2_CMD_NOT_USED ) -return ; +return 1 ;if (ioc->transport_cmds.smid != smid) -return ; +return 1 ; ioc->transport_cmds.status |=MPT2_CMD_COMPLETE ;if (mpi_reply) { memcpy(ioc->transport_cmds.reply, mpi_reply,
@@ -239,6 +240,7 @@ mpt2sas_transport_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index, } ioc->transport_cmds.status &= ~MPT2_CMD_PENDING ;complete (&ioc->transport_cmds.done); +return 1 ; }/* report manufacture request structure */