drm_mode_config_reset() has a dual role: it creates the initial KMS
state at probe time, and resets hardware and software state during
suspend/resume cycles.

Since the two roles need different behaviors (notably for objects like
drm_private_obj that must persist across suspend/resume),
drm_mode_config_create_initial_state() was introduced to handle only
the initial state creation at probe time.

Switch to drm_mode_config_create_initial_state().

Acked-by: Chen-Yu Tsai <[email protected]>
Signed-off-by: Maxime Ripard <[email protected]>
---
Cc: Chen-Yu Tsai <[email protected]>
Cc: Samuel Holland <[email protected]>
Cc: [email protected]
---
 drivers/gpu/drm/sun4i/sun4i_drv.c         | 4 +++-
 drivers/gpu/drm/sun4i/sun4i_framebuffer.c | 6 +++---
 drivers/gpu/drm/sun4i/sun4i_framebuffer.h | 2 +-
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c 
b/drivers/gpu/drm/sun4i/sun4i_drv.c
index f8bbca6eb49c..248be5ff4f36 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
@@ -102,11 +102,13 @@ static int sun4i_drv_bind(struct device *dev)
        /* Remove early framebuffers (ie. simplefb) */
        ret = aperture_remove_all_conflicting_devices(sun4i_drv_driver.name);
        if (ret)
                goto unbind_all;
 
-       sun4i_framebuffer_init(drm);
+       ret = sun4i_framebuffer_init(drm);
+       if (ret)
+               goto unbind_all;
 
        /* Enable connectors polling */
        drm_kms_helper_poll_init(drm);
 
        ret = drm_dev_register(drm, 0);
diff --git a/drivers/gpu/drm/sun4i/sun4i_framebuffer.c 
b/drivers/gpu/drm/sun4i/sun4i_framebuffer.c
index fc822bc2c62b..d7e5cdf76c16 100644
--- a/drivers/gpu/drm/sun4i/sun4i_framebuffer.c
+++ b/drivers/gpu/drm/sun4i/sun4i_framebuffer.c
@@ -22,16 +22,16 @@ static const struct drm_mode_config_funcs 
sun4i_de_mode_config_funcs = {
 
 static const struct drm_mode_config_helper_funcs sun4i_de_mode_config_helpers 
= {
        .atomic_commit_tail     = drm_atomic_helper_commit_tail_rpm,
 };
 
-void sun4i_framebuffer_init(struct drm_device *drm)
+int sun4i_framebuffer_init(struct drm_device *drm)
 {
-       drm_mode_config_reset(drm);
-
        drm->mode_config.max_width = 8192;
        drm->mode_config.max_height = 8192;
        drm->mode_config.normalize_zpos = true;
 
        drm->mode_config.funcs = &sun4i_de_mode_config_funcs;
        drm->mode_config.helper_private = &sun4i_de_mode_config_helpers;
+
+       return drm_mode_config_create_initial_state(drm);
 }
diff --git a/drivers/gpu/drm/sun4i/sun4i_framebuffer.h 
b/drivers/gpu/drm/sun4i/sun4i_framebuffer.h
index 06901fb3a186..378f0de343d7 100644
--- a/drivers/gpu/drm/sun4i/sun4i_framebuffer.h
+++ b/drivers/gpu/drm/sun4i/sun4i_framebuffer.h
@@ -7,8 +7,8 @@
  */
 
 #ifndef _SUN4I_FRAMEBUFFER_H_
 #define _SUN4I_FRAMEBUFFER_H_
 
-void sun4i_framebuffer_init(struct drm_device *drm);
+int sun4i_framebuffer_init(struct drm_device *drm);
 
 #endif /* _SUN4I_FRAMEBUFFER_H_ */

-- 
2.56.1

Reply via email to