• Laurent Pinchart's avatar
    drm: omapdrm: dss: Move initialization code from component bind to probe · 215003b4
    Laurent Pinchart authored
    There's no reason to delay initialization of most of the driver (such as
    mapping memory I/O, getting clocks or enabling runtime PM) to the
    component master bind handler.
    
    This additionally fixes a real PM issue caused enabling runtime PM in
    the bind handler.
    
    The bind handler performs the following sequence of PM operations:
    
    	pm_runtime_enable(dev);
    	pm_runtime_get_sync(dev);
    
    	... (access the hardware to read the device revision) ...
    
    	pm_runtime_put_sync(dev);
    
    If a failure occurs at this point, the error path calls
    pm_runtime_disable() to balance the pm_runtime_enable() call.
    
    To understand the problem, it should be noted that the bind handler is
    called when one of the component registers itself, which happens in the
    component's probe handler. Furthermore, as the components are children
    of the DSS, the device core calls pm_runtime_get_sync() on the DSS
    platform device before calling the component's probe handler. This
    increases the DSS power usage count but doesn't runtime resume the
    device, as runtime PM is disabled at that point.
    
    The bind handler is thus called with runtime PM disabled, with the
    device runtime suspended, but with the power usage count larger than 0.
    The pm_runtime_get_sync() call will thus further increase the power
    usage count and runtime resume the device. The pm_runtime_put_sync()
    handler will decrease the power usage count to a non-zero value and will
    thus not suspend the device. Finally, the pm_runtime_disable() call will
    disable runtime PM, preventing the pm_runtime_put() call in the device
    core from runtime suspending the device. The DSS device is thus left
    powered on.
    
    To fix this, move the initialization code from the bind handler to the
    probe handler.
    Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
    Reviewed-by: default avatarSebastian Reichel <sebastian.reichel@collabora.co.uk>
    Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
    215003b4
dss.c 33.4 KB