> We get called twice on suspend, once with DVACT_SUSPEND and once with 
> DVACT_POWERDOWN. So, here is a patch that does it like in ahci.c an does 
> everything in the DVACT_POWERDOWN path and nothing in the DVACT_SUSPEND 
> path.

I suppose so.

> @@ -469,6 +512,11 @@ nvme_activate(struct nvme_softc *sc, int act)
>               rv = config_activate_children(&sc->sc_dev, act);
>               nvme_shutdown(sc);
>               break;
> +     case DVACT_RESUME:
> +             rv = nvme_resume(sc);
> +             if (rv == 0)
> +                     rv = config_activate_children(&sc->sc_dev, act);
> +             break;
>       default:
>               rv = config_activate_children(&sc->sc_dev, act);
>               break;

However, note that nvme_resume() cannot fail.  If it fails, and you
don't resume the children, all sorts of stuff goes wrong.

Also your nvme_resume() function performs diagnostic printf's.  During
a resume, those might not work, fact is they may make the situation worse.
Imagine a console screen.  Sure it is just printing characters.. unless
it has to scroll, now you are running a tremendous amount of code in another
driver during a resume function.

So the trend here should be to write code which silently just works.
Most of the resume code is written this way.  Try to get it right in a
minimal fashion, and create as few side effects as possible.  So
perhaps remove the diagnostics checking for failure later.  Such
diagnostics could make a failure to resume act very strange, leading someone
astray quite far.

Reply via email to