• Suman Anna's avatar
    remoteproc/omap: Add support for runtime auto-suspend/resume · 5f31b232
    Suman Anna authored
    This patch enhances the PM support in the OMAP remoteproc driver to
    support the runtime auto-suspend. A remoteproc may not be required to
    be running all the time, and typically will need to be active only
    during certain usecases. As such, to save power, it should be turned
    off during potential long periods of inactivity between usecases.
    This suspend and resume of the device is a relatively heavy process
    in terms of latencies, so a remoteproc should be suspended only after
    a certain period of prolonged inactivity. The OMAP remoteproc driver
    leverages the runtime pm framework's auto_suspend feature to accomplish
    this functionality. This feature is automatically enabled when a remote
    processor has successfully booted. The 'autosuspend_delay_ms' for each
    device dictates the inactivity period/time to wait for before
    suspending the device.
    
    The runtime auto-suspend design relies on marking the last busy time
    on every communication (virtqueue kick) to and from the remote processor.
    When there has been no activity for 'autosuspend_delay_ms' time, the
    runtime PM framework invokes the driver's runtime pm suspend callback
    to suspend the device. The remote processor will be woken up on the
    initiation of the next communication message through the runtime pm
    resume callback. The current auto-suspend design also allows a remote
    processor to deny a auto-suspend attempt, if it wishes to, by sending a
    NACK response to the initial suspend request message sent to the remote
    processor as part of the suspend process. The auto-suspend request is
    also only attempted if the remote processor is idled and in standby at
    the time of inactivity timer expiry. This choice is made to avoid
    unnecessary messaging, and the auto-suspend is simply rescheduled to
    be attempted again after a further lapse of autosuspend_delay_ms.
    
    The runtime pm callbacks functionality in this patch reuses most of the
    core logic from the suspend/resume support code, and make use of an
    additional auto_suspend flag to differentiate the logic in common code
    from system suspend. The system suspend/resume sequences are also updated
    to reflect the proper pm_runtime statuses, and also to really perform a
    suspend/resume only if the remoteproc has not been auto-suspended at the
    time of request. The remote processor is left in suspended state on a
    system resume if it has been auto-suspended before, and will be woken up
    only when a usecase needs to run.
    
    The OMAP remoteproc driver currently uses a default value of 10 seconds
    for all OMAP remoteprocs, and a different value can be chosen either by
    choosing a positive value for the 'ti,autosuspend-delay-ms' under DT or
    by updating the 'autosuspend_delay_ms' field at runtime through the
    sysfs interface. A negative value is equivalent to disabling the runtime
    suspend.
        Eg: To use 25 seconds for IPU2 on DRA7xx,
          echo 25000 > /sys/bus/platform/devices/55020000.ipu/power/autosuspend_delay_ms
    
    The runtime suspend feature can also be similarly enabled or disabled by
    writing 'auto' or 'on' to the device's 'control' power field. The default
    is enabled.
        Eg: To disable auto-suspend for IPU2 on DRA7xx SoC,
          echo on > /sys/bus/platform/devices/55020000.ipu/power/control
    Signed-off-by: default avatarSuman Anna <s-anna@ti.com>
    [t-kristo@ti.com: converted to use ti-sysc instead of hwmod]
    Signed-off-by: default avatarTero Kristo <t-kristo@ti.com>
    Reviewed-by: default avatarAndrew F. Davis <afd@ti.com>
    Acked-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
    Link: https://lore.kernel.org/r/20200324110035.29907-13-t-kristo@ti.comSigned-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
    5f31b232
omap_remoteproc.c 32.4 KB