Hook up the default ->reset() and ->atomic_duplicate_state() helpers.
This ensures that state objects are properly created and framebuffer
reference counts correctly maintained.
Signed-off-by: Thierry Reding <treding@nvidia.com>
 #include "drm.h"
 #include "gem.h"
 
+#include <drm/drm_atomic.h>
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_plane_helper.h>
 
        .update_plane = drm_plane_helper_update,
        .disable_plane = drm_plane_helper_disable,
        .destroy = tegra_primary_plane_destroy,
+       .reset = drm_atomic_helper_plane_reset,
+       .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
        .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
 };
 
        .update_plane = drm_plane_helper_update,
        .disable_plane = drm_plane_helper_disable,
        .destroy = tegra_plane_destroy,
+       .reset = drm_atomic_helper_plane_reset,
+       .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
        .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
 };
 
        .update_plane = drm_plane_helper_update,
        .disable_plane = drm_plane_helper_disable,
        .destroy = tegra_overlay_plane_destroy,
+       .reset = drm_atomic_helper_plane_reset,
+       .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
        .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
 };
 
                drm_crtc_vblank_get(crtc);
        }
 
+       if (crtc->primary->state)
+               drm_atomic_set_fb_for_plane(crtc->primary->state, fb);
+
        tegra_dc_set_base(dc, 0, 0, fb);
        crtc->primary->fb = fb;
 
        .page_flip = tegra_dc_page_flip,
        .set_config = drm_crtc_helper_set_config,
        .destroy = tegra_dc_destroy,
+       .reset = drm_atomic_helper_crtc_reset,
+       .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
        .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
 };
 
 
        if (err < 0)
                goto fbdev;
 
+       drm_mode_config_reset(drm);
+
        /*
         * We don't use the drm_irq_install() helpers provided by the DRM
         * core, so we need to set this manually in order to allow the
 
 
 static const struct drm_connector_funcs tegra_dsi_connector_funcs = {
        .dpms = tegra_dsi_connector_dpms,
+       .reset = drm_atomic_helper_connector_reset,
        .detect = tegra_output_connector_detect,
        .fill_modes = drm_helper_probe_single_connector_modes,
        .destroy = tegra_output_connector_destroy,
+       .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
        .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };
 
 
 
 static const struct drm_connector_funcs tegra_hdmi_connector_funcs = {
        .dpms = tegra_hdmi_connector_dpms,
+       .reset = drm_atomic_helper_connector_reset,
        .detect = tegra_output_connector_detect,
        .fill_modes = drm_helper_probe_single_connector_modes,
        .destroy = tegra_output_connector_destroy,
+       .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
        .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };
 
 
 
 static const struct drm_connector_funcs tegra_rgb_connector_funcs = {
        .dpms = tegra_rgb_connector_dpms,
+       .reset = drm_atomic_helper_connector_reset,
        .detect = tegra_output_connector_detect,
        .fill_modes = drm_helper_probe_single_connector_modes,
        .destroy = tegra_output_connector_destroy,
+       .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
        .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };
 
 
 
 static const struct drm_connector_funcs tegra_sor_connector_funcs = {
        .dpms = tegra_sor_connector_dpms,
+       .reset = drm_atomic_helper_connector_reset,
        .detect = tegra_sor_connector_detect,
        .fill_modes = drm_helper_probe_single_connector_modes,
        .destroy = tegra_output_connector_destroy,
+       .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
        .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };