Re: [PATCHv2 5/6] nvme: Prevent resets during paused states

Keith Busch
2019-09-20T18:09:01Z

On Fri, Sep 20, 2019 at 11:05:22AM -0700, Sagi Grimberg wrote:
>
> > drivers/nvme/host/core.c | 10 +++++-----
> > 1 file changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> > index 95b74d020506..33b5729763c2 100644
> > --- a/drivers/nvme/host/core.c
> > +++ b/drivers/nvme/host/core.c
> > @@ -3742,15 +3742,14 @@ static void nvme_fw_act_work(struct work_struct *work)
> > if (time_after(jiffies, fw_act_timeout)) {
> > dev_warn(ctrl->device,
> > "Fw activation timeout, reset controller\n");
> > - nvme_reset_ctrl(ctrl);
> > - break;
> > + nvme_reset_continue(ctrl);
> > + return;
> > }
> > msleep(100);
> > }
> > - if (ctrl->state != NVME_CTRL_LIVE)
> > + if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_LIVE))
> > return;
> > -
> > nvme_start_queues(ctrl);
> > /* read FW slot information to clear the AER */
> > nvme_get_fw_slot_info(ctrl);
> > @@ -3768,7 +3767,8 @@ static void nvme_handle_aen_notice(struct nvme_ctrl *ctrl, u32 result)
> > nvme_queue_scan(ctrl);
> > break;
> > case NVME_AER_NOTICE_FW_ACT_STARTING:
> > - queue_work(nvme_wq, &ctrl->fw_act_work);
> > + if (nvme_change_ctrl_state(ctrl, NVME_CTRL_RESETTING))
> > + queue_work(nvme_wq, &ctrl->fw_act_work);
>
> btw, what happens if someone just initiated a reset here when the event
> is handled? just ignore the fw activation?

Yep, if someone reset the controller before the driver got to handle the
activation notice event, there's nothing for fw_act_work to do anymore
since CSTS.PP is not valid after toggling CC.EN.