Skip to content

Commit c1af985

Browse files
sreekanthbrcmmartinkpetersen
authored andcommitted
scsi: mpi3mr: Add Event acknowledgment logic
Add Event acknowledgment logic. Link: https://lore.kernel.org/r/20211220141159.16117-19-sreekanth.reddy@broadcom.com Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent c5758fc commit c1af985

3 files changed

Lines changed: 224 additions & 12 deletions

File tree

drivers/scsi/mpi3mr/mpi3mr.h

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@ extern int prot_mask;
9696
#define MPI3MR_HOSTTAG_DEVRMCMD_MAX (MPI3MR_HOSTTAG_DEVRMCMD_MIN + \
9797
MPI3MR_NUM_DEVRMCMD - 1)
9898

99-
#define MPI3MR_INTERNAL_CMDS_RESVD MPI3MR_HOSTTAG_DEVRMCMD_MAX
99+
#define MPI3MR_INTERNAL_CMDS_RESVD MPI3MR_HOSTTAG_DEVRMCMD_MAX
100+
#define MPI3MR_NUM_EVTACKCMD 4
101+
#define MPI3MR_HOSTTAG_EVTACKCMD_MIN (MPI3MR_HOSTTAG_DEVRMCMD_MAX + 1)
102+
#define MPI3MR_HOSTTAG_EVTACKCMD_MAX (MPI3MR_HOSTTAG_EVTACKCMD_MIN + \
103+
MPI3MR_NUM_EVTACKCMD - 1)
100104

101105
/* Reduced resource count definition for crash kernel */
102106
#define MPI3MR_HOST_IOS_KDUMP 128
@@ -674,11 +678,15 @@ struct scmd_priv {
674678
* @chain_buf_lock: Chain buffer list lock
675679
* @host_tm_cmds: Command tracker for task management commands
676680
* @dev_rmhs_cmds: Command tracker for device removal commands
681+
* @evtack_cmds: Command tracker for event ack commands
677682
* @devrem_bitmap_sz: Device removal bitmap size
678683
* @devrem_bitmap: Device removal bitmap
679684
* @dev_handle_bitmap_sz: Device handle bitmap size
680685
* @removepend_bitmap: Remove pending bitmap
681686
* @delayed_rmhs_list: Delayed device removal list
687+
* @evtack_cmds_bitmap_sz: Event Ack bitmap size
688+
* @evtack_cmds_bitmap: Event Ack bitmap
689+
* @delayed_evtack_cmds_list: Delayed event acknowledgment list
682690
* @ts_update_counter: Timestamp update counter
683691
* @reset_in_progress: Reset in progress flag
684692
* @unrecoverable: Controller unrecoverable flag
@@ -800,11 +808,15 @@ struct mpi3mr_ioc {
800808

801809
struct mpi3mr_drv_cmd host_tm_cmds;
802810
struct mpi3mr_drv_cmd dev_rmhs_cmds[MPI3MR_NUM_DEVRMCMD];
811+
struct mpi3mr_drv_cmd evtack_cmds[MPI3MR_NUM_EVTACKCMD];
803812
u16 devrem_bitmap_sz;
804813
void *devrem_bitmap;
805814
u16 dev_handle_bitmap_sz;
806815
void *removepend_bitmap;
807816
struct list_head delayed_rmhs_list;
817+
u16 evtack_cmds_bitmap_sz;
818+
void *evtack_cmds_bitmap;
819+
struct list_head delayed_evtack_cmds_list;
808820

809821
u32 ts_update_counter;
810822
u8 reset_in_progress;
@@ -862,6 +874,18 @@ struct delayed_dev_rmhs_node {
862874
u8 iou_rc;
863875
};
864876

877+
/**
878+
* struct delayed_evt_ack_node - Delayed event ack node
879+
* @list: list head
880+
* @event: MPI3 event ID
881+
* @event_ctx: event context
882+
*/
883+
struct delayed_evt_ack_node {
884+
struct list_head list;
885+
u8 event;
886+
u32 event_ctx;
887+
};
888+
865889
int mpi3mr_setup_resources(struct mpi3mr_ioc *mrioc);
866890
void mpi3mr_cleanup_resources(struct mpi3mr_ioc *mrioc);
867891
int mpi3mr_init_ioc(struct mpi3mr_ioc *mrioc);
@@ -898,15 +922,15 @@ void mpi3mr_ioc_disable_intr(struct mpi3mr_ioc *mrioc);
898922
void mpi3mr_ioc_enable_intr(struct mpi3mr_ioc *mrioc);
899923

900924
enum mpi3mr_iocstate mpi3mr_get_iocstate(struct mpi3mr_ioc *mrioc);
901-
int mpi3mr_send_event_ack(struct mpi3mr_ioc *mrioc, u8 event,
925+
int mpi3mr_process_event_ack(struct mpi3mr_ioc *mrioc, u8 event,
902926
u32 event_ctx);
903927

904928
void mpi3mr_wait_for_host_io(struct mpi3mr_ioc *mrioc, u32 timeout);
905929
void mpi3mr_cleanup_fwevt_list(struct mpi3mr_ioc *mrioc);
906930
void mpi3mr_flush_host_io(struct mpi3mr_ioc *mrioc);
907931
void mpi3mr_invalidate_devhandles(struct mpi3mr_ioc *mrioc);
908932
void mpi3mr_rfresh_tgtdevs(struct mpi3mr_ioc *mrioc);
909-
void mpi3mr_flush_delayed_rmhs_list(struct mpi3mr_ioc *mrioc);
933+
void mpi3mr_flush_delayed_cmd_lists(struct mpi3mr_ioc *mrioc);
910934
void mpi3mr_check_rh_fault_ioc(struct mpi3mr_ioc *mrioc, u32 reason_code);
911935
void mpi3mr_print_fault_info(struct mpi3mr_ioc *mrioc);
912936
void mpi3mr_check_rh_fault_ioc(struct mpi3mr_ioc *mrioc, u32 reason_code);

drivers/scsi/mpi3mr/mpi3mr_fw.c

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,12 @@ mpi3mr_get_drv_cmd(struct mpi3mr_ioc *mrioc, u16 host_tag,
312312
return &mrioc->dev_rmhs_cmds[idx];
313313
}
314314

315+
if (host_tag >= MPI3MR_HOSTTAG_EVTACKCMD_MIN &&
316+
host_tag <= MPI3MR_HOSTTAG_EVTACKCMD_MAX) {
317+
idx = host_tag - MPI3MR_HOSTTAG_EVTACKCMD_MIN;
318+
return &mrioc->evtack_cmds[idx];
319+
}
320+
315321
return NULL;
316322
}
317323

@@ -2691,6 +2697,13 @@ static int mpi3mr_alloc_reply_sense_bufs(struct mpi3mr_ioc *mrioc)
26912697
goto out_failed;
26922698
}
26932699

2700+
for (i = 0; i < MPI3MR_NUM_EVTACKCMD; i++) {
2701+
mrioc->evtack_cmds[i].reply = kzalloc(mrioc->reply_sz,
2702+
GFP_KERNEL);
2703+
if (!mrioc->evtack_cmds[i].reply)
2704+
goto out_failed;
2705+
}
2706+
26942707
mrioc->host_tm_cmds.reply = kzalloc(mrioc->reply_sz, GFP_KERNEL);
26952708
if (!mrioc->host_tm_cmds.reply)
26962709
goto out_failed;
@@ -2711,6 +2724,14 @@ static int mpi3mr_alloc_reply_sense_bufs(struct mpi3mr_ioc *mrioc)
27112724
if (!mrioc->devrem_bitmap)
27122725
goto out_failed;
27132726

2727+
mrioc->evtack_cmds_bitmap_sz = MPI3MR_NUM_EVTACKCMD / 8;
2728+
if (MPI3MR_NUM_EVTACKCMD % 8)
2729+
mrioc->evtack_cmds_bitmap_sz++;
2730+
mrioc->evtack_cmds_bitmap = kzalloc(mrioc->evtack_cmds_bitmap_sz,
2731+
GFP_KERNEL);
2732+
if (!mrioc->evtack_cmds_bitmap)
2733+
goto out_failed;
2734+
27142735
mrioc->num_reply_bufs = mrioc->facts.max_reqs + MPI3MR_NUM_EVT_REPLIES;
27152736
mrioc->reply_free_qsz = mrioc->num_reply_bufs + 1;
27162737
mrioc->num_sense_bufs = mrioc->facts.max_reqs / MPI3MR_SENSEBUF_FACTOR;
@@ -3030,17 +3051,17 @@ static int mpi3mr_issue_event_notification(struct mpi3mr_ioc *mrioc)
30303051
}
30313052

30323053
/**
3033-
* mpi3mr_send_event_ack - Send event acknowledgment
3054+
* mpi3mr_process_event_ack - Process event acknowledgment
30343055
* @mrioc: Adapter instance reference
30353056
* @event: MPI3 event ID
3036-
* @event_ctx: Event context
3057+
* @event_ctx: event context
30373058
*
30383059
* Send event acknowledgment through admin queue and wait for
30393060
* it to complete.
30403061
*
30413062
* Return: 0 on success, non-zero on failures.
30423063
*/
3043-
int mpi3mr_send_event_ack(struct mpi3mr_ioc *mrioc, u8 event,
3064+
int mpi3mr_process_event_ack(struct mpi3mr_ioc *mrioc, u8 event,
30443065
u32 event_ctx)
30453066
{
30463067
struct mpi3_event_ack_request evtack_req;
@@ -3803,8 +3824,13 @@ void mpi3mr_memset_buffers(struct mpi3mr_ioc *mrioc)
38033824
for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++)
38043825
memset(mrioc->dev_rmhs_cmds[i].reply, 0,
38053826
sizeof(*mrioc->dev_rmhs_cmds[i].reply));
3827+
for (i = 0; i < MPI3MR_NUM_EVTACKCMD; i++)
3828+
memset(mrioc->evtack_cmds[i].reply, 0,
3829+
sizeof(*mrioc->evtack_cmds[i].reply));
38063830
memset(mrioc->removepend_bitmap, 0, mrioc->dev_handle_bitmap_sz);
38073831
memset(mrioc->devrem_bitmap, 0, mrioc->devrem_bitmap_sz);
3832+
memset(mrioc->evtack_cmds_bitmap, 0,
3833+
mrioc->evtack_cmds_bitmap_sz);
38083834
}
38093835

38103836
for (i = 0; i < mrioc->num_queues; i++) {
@@ -3898,12 +3924,20 @@ void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc)
38983924
kfree(mrioc->host_tm_cmds.reply);
38993925
mrioc->host_tm_cmds.reply = NULL;
39003926

3927+
for (i = 0; i < MPI3MR_NUM_EVTACKCMD; i++) {
3928+
kfree(mrioc->evtack_cmds[i].reply);
3929+
mrioc->evtack_cmds[i].reply = NULL;
3930+
}
3931+
39013932
kfree(mrioc->removepend_bitmap);
39023933
mrioc->removepend_bitmap = NULL;
39033934

39043935
kfree(mrioc->devrem_bitmap);
39053936
mrioc->devrem_bitmap = NULL;
39063937

3938+
kfree(mrioc->evtack_cmds_bitmap);
3939+
mrioc->evtack_cmds_bitmap = NULL;
3940+
39073941
kfree(mrioc->chain_bitmap);
39083942
mrioc->chain_bitmap = NULL;
39093943

@@ -4079,6 +4113,11 @@ static void mpi3mr_flush_drv_cmds(struct mpi3mr_ioc *mrioc)
40794113
cmdptr = &mrioc->dev_rmhs_cmds[i];
40804114
mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr);
40814115
}
4116+
4117+
for (i = 0; i < MPI3MR_NUM_EVTACKCMD; i++) {
4118+
cmdptr = &mrioc->evtack_cmds[i];
4119+
mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr);
4120+
}
40824121
}
40834122

40844123
/**
@@ -4176,10 +4215,11 @@ int mpi3mr_soft_reset_handler(struct mpi3mr_ioc *mrioc,
41764215
goto out;
41774216
}
41784217

4179-
mpi3mr_flush_delayed_rmhs_list(mrioc);
4218+
mpi3mr_flush_delayed_cmd_lists(mrioc);
41804219
mpi3mr_flush_drv_cmds(mrioc);
41814220
memset(mrioc->devrem_bitmap, 0, mrioc->devrem_bitmap_sz);
41824221
memset(mrioc->removepend_bitmap, 0, mrioc->dev_handle_bitmap_sz);
4222+
memset(mrioc->evtack_cmds_bitmap, 0, mrioc->evtack_cmds_bitmap_sz);
41834223
mpi3mr_cleanup_fwevt_list(mrioc);
41844224
mpi3mr_flush_host_io(mrioc);
41854225
mpi3mr_invalidate_devhandles(mrioc);

0 commit comments

Comments
 (0)