Skip to content

Commit 78b76a0

Browse files
sreekanthbrcmmartinkpetersen
authored andcommitted
scsi: mpi3mr: Support Prepare for Reset event
The IOC sends a Prepare for Reset Event to the host to prepare for a Soft Reset. This event data has two reason codes: 1. Start - The host is expected to gracefully quiesce all I/O within approximately 1 second. 2. Abort - The IOC is requesting to abort a previous Prepare for Reset Event request. Normal I/O may be resumed. Link: https://lore.kernel.org/r/20211220141159.16117-20-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 c1af985 commit 78b76a0

3 files changed

Lines changed: 96 additions & 33 deletions

File tree

drivers/scsi/mpi3mr/mpi3mr.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ extern int prot_mask;
114114
#define MPI3MR_TSUPDATE_INTERVAL 900
115115
#define MPI3MR_DEFAULT_SHUTDOWN_TIME 120
116116
#define MPI3MR_RAID_ERRREC_RESET_TIMEOUT 180
117+
#define MPI3MR_PREPARE_FOR_RESET_TIMEOUT 180
117118
#define MPI3MR_RESET_ACK_TIMEOUT 30
118119

119120
#define MPI3MR_WATCHDOG_INTERVAL 1000 /* in milli seconds */
@@ -693,6 +694,8 @@ struct scmd_priv {
693694
* @prev_reset_result: Result of previous reset
694695
* @reset_mutex: Controller reset mutex
695696
* @reset_waitq: Controller reset wait queue
697+
* @prepare_for_reset: Prepare for reset event received
698+
* @prepare_for_reset_timeout_counter: Prepare for reset timeout
696699
* @diagsave_timeout: Diagnostic information save timeout
697700
* @logging_level: Controller debug logging level
698701
* @flush_io_count: I/O count to flush after reset
@@ -825,6 +828,9 @@ struct mpi3mr_ioc {
825828
struct mutex reset_mutex;
826829
wait_queue_head_t reset_waitq;
827830

831+
u8 prepare_for_reset;
832+
u16 prepare_for_reset_timeout_counter;
833+
828834
u16 diagsave_timeout;
829835
int logging_level;
830836
u16 flush_io_count;

drivers/scsi/mpi3mr/mpi3mr_fw.c

Lines changed: 50 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2262,7 +2262,8 @@ static void mpi3mr_watchdog_work(struct work_struct *work)
22622262
container_of(work, struct mpi3mr_ioc, watchdog_work.work);
22632263
unsigned long flags;
22642264
enum mpi3mr_iocstate ioc_state;
2265-
u32 fault, host_diagnostic;
2265+
u32 fault, host_diagnostic, ioc_status;
2266+
u32 reset_reason = MPI3MR_RESET_FROM_FAULT_WATCH;
22662267

22672268
if (mrioc->reset_in_progress || mrioc->unrecoverable)
22682269
return;
@@ -2272,43 +2273,55 @@ static void mpi3mr_watchdog_work(struct work_struct *work)
22722273
mpi3mr_sync_timestamp(mrioc);
22732274
}
22742275

2276+
if ((mrioc->prepare_for_reset) &&
2277+
((mrioc->prepare_for_reset_timeout_counter++) >=
2278+
MPI3MR_PREPARE_FOR_RESET_TIMEOUT)) {
2279+
mpi3mr_soft_reset_handler(mrioc,
2280+
MPI3MR_RESET_FROM_CIACTVRST_TIMER, 1);
2281+
return;
2282+
}
2283+
2284+
ioc_status = readl(&mrioc->sysif_regs->ioc_status);
2285+
if (ioc_status & MPI3_SYSIF_IOC_STATUS_RESET_HISTORY) {
2286+
mpi3mr_soft_reset_handler(mrioc, MPI3MR_RESET_FROM_FIRMWARE, 0);
2287+
return;
2288+
}
2289+
22752290
/*Check for fault state every one second and issue Soft reset*/
22762291
ioc_state = mpi3mr_get_iocstate(mrioc);
2277-
if (ioc_state == MRIOC_STATE_FAULT) {
2278-
fault = readl(&mrioc->sysif_regs->fault) &
2279-
MPI3_SYSIF_FAULT_CODE_MASK;
2280-
host_diagnostic = readl(&mrioc->sysif_regs->host_diagnostic);
2281-
if (host_diagnostic & MPI3_SYSIF_HOST_DIAG_SAVE_IN_PROGRESS) {
2282-
if (!mrioc->diagsave_timeout) {
2283-
mpi3mr_print_fault_info(mrioc);
2284-
ioc_warn(mrioc, "Diag save in progress\n");
2285-
}
2286-
if ((mrioc->diagsave_timeout++) <=
2287-
MPI3_SYSIF_DIAG_SAVE_TIMEOUT)
2288-
goto schedule_work;
2289-
} else
2290-
mpi3mr_print_fault_info(mrioc);
2291-
mrioc->diagsave_timeout = 0;
2292+
if (ioc_state != MRIOC_STATE_FAULT)
2293+
goto schedule_work;
22922294

2293-
if (fault == MPI3_SYSIF_FAULT_CODE_POWER_CYCLE_REQUIRED) {
2294-
ioc_info(mrioc,
2295-
"Factory Reset fault occurred marking controller as unrecoverable"
2296-
);
2297-
mrioc->unrecoverable = 1;
2298-
goto out;
2295+
fault = readl(&mrioc->sysif_regs->fault) & MPI3_SYSIF_FAULT_CODE_MASK;
2296+
host_diagnostic = readl(&mrioc->sysif_regs->host_diagnostic);
2297+
if (host_diagnostic & MPI3_SYSIF_HOST_DIAG_SAVE_IN_PROGRESS) {
2298+
if (!mrioc->diagsave_timeout) {
2299+
mpi3mr_print_fault_info(mrioc);
2300+
ioc_warn(mrioc, "diag save in progress\n");
22992301
}
2302+
if ((mrioc->diagsave_timeout++) <= MPI3_SYSIF_DIAG_SAVE_TIMEOUT)
2303+
goto schedule_work;
2304+
}
23002305

2301-
if ((fault == MPI3_SYSIF_FAULT_CODE_DIAG_FAULT_RESET) ||
2302-
(fault == MPI3_SYSIF_FAULT_CODE_SOFT_RESET_IN_PROGRESS) ||
2303-
(mrioc->reset_in_progress))
2304-
goto out;
2305-
if (fault == MPI3_SYSIF_FAULT_CODE_CI_ACTIVATION_RESET)
2306-
mpi3mr_soft_reset_handler(mrioc,
2307-
MPI3MR_RESET_FROM_CIACTIV_FAULT, 0);
2308-
else
2309-
mpi3mr_soft_reset_handler(mrioc,
2310-
MPI3MR_RESET_FROM_FAULT_WATCH, 0);
2306+
mpi3mr_print_fault_info(mrioc);
2307+
mrioc->diagsave_timeout = 0;
2308+
2309+
switch (fault) {
2310+
case MPI3_SYSIF_FAULT_CODE_POWER_CYCLE_REQUIRED:
2311+
ioc_info(mrioc,
2312+
"controller requires system power cycle, marking controller as unrecoverable\n");
2313+
mrioc->unrecoverable = 1;
2314+
return;
2315+
case MPI3_SYSIF_FAULT_CODE_SOFT_RESET_IN_PROGRESS:
2316+
return;
2317+
case MPI3_SYSIF_FAULT_CODE_CI_ACTIVATION_RESET:
2318+
reset_reason = MPI3MR_RESET_FROM_CIACTIV_FAULT;
2319+
break;
2320+
default:
2321+
break;
23112322
}
2323+
mpi3mr_soft_reset_handler(mrioc, reset_reason, 0);
2324+
return;
23122325

23132326
schedule_work:
23142327
spin_lock_irqsave(&mrioc->watchdog_lock, flags);
@@ -2317,7 +2330,6 @@ static void mpi3mr_watchdog_work(struct work_struct *work)
23172330
&mrioc->watchdog_work,
23182331
msecs_to_jiffies(MPI3MR_WATCHDOG_INTERVAL));
23192332
spin_unlock_irqrestore(&mrioc->watchdog_lock, flags);
2320-
out:
23212333
return;
23222334
}
23232335

@@ -3488,6 +3500,7 @@ static int mpi3mr_enable_events(struct mpi3mr_ioc *mrioc)
34883500
mpi3mr_unmask_events(mrioc, MPI3_EVENT_SAS_BROADCAST_PRIMITIVE);
34893501
mpi3mr_unmask_events(mrioc, MPI3_EVENT_PCIE_TOPOLOGY_CHANGE_LIST);
34903502
mpi3mr_unmask_events(mrioc, MPI3_EVENT_PCIE_ENUMERATION);
3503+
mpi3mr_unmask_events(mrioc, MPI3_EVENT_PREPARE_FOR_RESET);
34913504
mpi3mr_unmask_events(mrioc, MPI3_EVENT_CABLE_MGMT);
34923505
mpi3mr_unmask_events(mrioc, MPI3_EVENT_ENERGY_PACK_CHANGE);
34933506

@@ -4223,6 +4236,10 @@ int mpi3mr_soft_reset_handler(struct mpi3mr_ioc *mrioc,
42234236
mpi3mr_cleanup_fwevt_list(mrioc);
42244237
mpi3mr_flush_host_io(mrioc);
42254238
mpi3mr_invalidate_devhandles(mrioc);
4239+
if (mrioc->prepare_for_reset) {
4240+
mrioc->prepare_for_reset = 0;
4241+
mrioc->prepare_for_reset_timeout_counter = 0;
4242+
}
42264243
mpi3mr_memset_buffers(mrioc);
42274244
retval = mpi3mr_reinit_ioc(mrioc, 0);
42284245
if (retval) {

drivers/scsi/mpi3mr/mpi3mr_os.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1988,6 +1988,40 @@ static void mpi3mr_devstatuschg_evt_th(struct mpi3mr_ioc *mrioc,
19881988
mpi3mr_tgtdev_put(tgtdev);
19891989
}
19901990

1991+
/**
1992+
* mpi3mr_preparereset_evt_th - Prepare for reset event tophalf
1993+
* @mrioc: Adapter instance reference
1994+
* @event_reply: event data
1995+
*
1996+
* Blocks and unblocks host level I/O based on the reason code
1997+
*
1998+
* Return: Nothing
1999+
*/
2000+
static void mpi3mr_preparereset_evt_th(struct mpi3mr_ioc *mrioc,
2001+
struct mpi3_event_notification_reply *event_reply)
2002+
{
2003+
struct mpi3_event_data_prepare_for_reset *evtdata =
2004+
(struct mpi3_event_data_prepare_for_reset *)event_reply->event_data;
2005+
2006+
if (evtdata->reason_code == MPI3_EVENT_PREPARE_RESET_RC_START) {
2007+
dprint_event_th(mrioc,
2008+
"prepare for reset event top half with rc=start\n");
2009+
if (mrioc->prepare_for_reset)
2010+
return;
2011+
mrioc->prepare_for_reset = 1;
2012+
mrioc->prepare_for_reset_timeout_counter = 0;
2013+
} else if (evtdata->reason_code == MPI3_EVENT_PREPARE_RESET_RC_ABORT) {
2014+
dprint_event_th(mrioc,
2015+
"prepare for reset top half with rc=abort\n");
2016+
mrioc->prepare_for_reset = 0;
2017+
mrioc->prepare_for_reset_timeout_counter = 0;
2018+
}
2019+
if ((event_reply->msg_flags & MPI3_EVENT_NOTIFY_MSGFLAGS_ACK_MASK)
2020+
== MPI3_EVENT_NOTIFY_MSGFLAGS_ACK_REQUIRED)
2021+
mpi3mr_send_event_ack(mrioc, event_reply->event, NULL,
2022+
le32_to_cpu(event_reply->event_context));
2023+
}
2024+
19912025
/**
19922026
* mpi3mr_energypackchg_evt_th - Energy pack change evt tophalf
19932027
* @mrioc: Adapter instance reference
@@ -2075,6 +2109,12 @@ void mpi3mr_os_handle_events(struct mpi3mr_ioc *mrioc,
20752109
mpi3mr_pcietopochg_evt_th(mrioc, event_reply);
20762110
break;
20772111
}
2112+
case MPI3_EVENT_PREPARE_FOR_RESET:
2113+
{
2114+
mpi3mr_preparereset_evt_th(mrioc, event_reply);
2115+
ack_req = 0;
2116+
break;
2117+
}
20782118
case MPI3_EVENT_DEVICE_INFO_CHANGED:
20792119
{
20802120
process_evt_bh = 1;

0 commit comments

Comments
 (0)