QSPI NOR power manager errrors when CONFIG_PM_DEVICE_RUNTIME is set

I recently enabled power management in my code base by adding these two oiptions to my prj.conf:

CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_RUNTIME=y
The code runs on an nRF5340 MCU with a LittleFS instance in an external MX25R64 QSPI flash. It all worked fine until I enabled the two options above in prj.conf, now I get this error each time the MCU starts:
<err> qspi_nor: pm_device_runtime_put failed: -16
It appears that things continue to work normally though, but I've yet to run extensive read/write tests on the external flash and the above error is a bit concerning. I also have 
CONFIG_NORDIC_QSPI_NOR_XIP=y in my prj.conf, which (among other things) is supposed to keep the external flash from sleeping if I understood correctly (I need this for various reasons). 
Does anybody know how concerned I should be about this error? Thank you.
EDIT: sorry, forgot to specify: I am using Nordic Connect SDK 2.7.0.
Parents
  • Hi

    Okay, so I think what's happening here is that this error is caused because you've set CONFIG_NORDIC_QSPI_NOR_XIP=y in your project, because it will keep the QSPI busy to avoid it from being affected by the power management. But something in your project does use power management, that is in turn rejected by the QSPI. Are you trying to put the nRF53 to sleep at all, because that will also call the pm_device_runtime_put I believe.

    Best regards,

    Simon

Reply
  • Hi

    Okay, so I think what's happening here is that this error is caused because you've set CONFIG_NORDIC_QSPI_NOR_XIP=y in your project, because it will keep the QSPI busy to avoid it from being affected by the power management. But something in your project does use power management, that is in turn rejected by the QSPI. Are you trying to put the nRF53 to sleep at all, because that will also call the pm_device_runtime_put I believe.

    Best regards,

    Simon

Children
  • Hi SImon,

    I am definitely not ttrying to put the MCU to sleep manually. When I enabled CONFIG_PM_DEVICE_RUNTIME, I added various calls to pm_device_runtime_get and pm_device_runtime_put in my code. With these changes in places, power management should be automatic: the PM subsystem should figure out which device(s) it can put to sleep and when (I am not considering device drivers here (which need to do more work), because my code doesn't implement any device drivers, it just uses the existing ones). However, none of the PM calls in my code touch the QSPI NOR device, I just use the existing driver. And the driver should do all the required PM work automatically. Looking at the driver, I don't think it's doing it correctly. I'm talking specifially about https://github.com/nrfconnect/sdk-zephyr/blob/v3.6.99-ncs2/drivers/flash/nrf_qspi_nor.c#L318-L323:

    if (!dev_data->xip_enabled) {
        qspi_clock_div_change();

        pm_device_busy_set(dev);
    }

    I would think that you want to call pm_device_busy_set when XIP is enabled, not disabled, like the code above does? There might be other places where this isn't used correctly, I just highlighted one that looks suspicious.

    Thanks,
    Bogdan

Related