Re: [Intel-gfx] [PATCH 03/18] drm: Extract drm_atomic_state_helper.[hc]

2018-10-03 Thread Daniel Vetter
On Tue, Oct 02, 2018 at 06:40:52PM +0300, Ville Syrjälä wrote:
> On Tue, Oct 02, 2018 at 03:35:11PM +0200, Daniel Vetter wrote:
> > We already have a separate overview doc for this, makes sense to
> > untangle it from the overall atomic helpers.
> > 
> > v2: Rebase
> > 
> > v3: Rebase more.
> 
> Hopefully the rebases didn't leave any code changes behind...

I've redone the move on every rebase :-/

> Too lazy to read in full detail so
> Acked-by: Ville Syrjälä 

Thanks, I'll pick this one right up (just need to double-check CI).
-Daniel

> 
> > 
> > Signed-off-by: Daniel Vetter 
> > ---
> >  Documentation/gpu/drm-kms-helpers.rst |  19 +-
> >  drivers/gpu/drm/Makefile  |   3 +-
> >  drivers/gpu/drm/drm_atomic_helper.c   | 566 
> >  drivers/gpu/drm/drm_atomic_state_helper.c | 601 ++
> >  include/drm/drm_atomic_helper.h   |  44 +-
> >  include/drm/drm_atomic_state_helper.h |  80 +++
> >  6 files changed, 698 insertions(+), 615 deletions(-)
> >  create mode 100644 drivers/gpu/drm/drm_atomic_state_helper.c
> >  create mode 100644 include/drm/drm_atomic_state_helper.h
> > 
> > diff --git a/Documentation/gpu/drm-kms-helpers.rst 
> > b/Documentation/gpu/drm-kms-helpers.rst
> > index f9cfcdcdf024..4b4dc236ef6f 100644
> > --- a/Documentation/gpu/drm-kms-helpers.rst
> > +++ b/Documentation/gpu/drm-kms-helpers.rst
> > @@ -59,19 +59,28 @@ Implementing Asynchronous Atomic Commit
> >  .. kernel-doc:: drivers/gpu/drm/drm_atomic_helper.c
> > :doc: implementing nonblocking commit
> >  
> > +Helper Functions Reference
> > +--
> > +
> > +.. kernel-doc:: include/drm/drm_atomic_helper.h
> > +   :internal:
> > +
> > +.. kernel-doc:: drivers/gpu/drm/drm_atomic_helper.c
> > +   :export:
> > +
> >  Atomic State Reset and Initialization
> >  -
> >  
> > -.. kernel-doc:: drivers/gpu/drm/drm_atomic_helper.c
> > +.. kernel-doc:: drivers/gpu/drm/drm_atomic_state_helper.c
> > :doc: atomic state reset and initialization
> >  
> > -Helper Functions Reference
> > ---
> > +Atomic State Helper Reference
> > +-
> >  
> > -.. kernel-doc:: include/drm/drm_atomic_helper.h
> > +.. kernel-doc:: include/drm/drm_atomic_state_helper.h
> > :internal:
> >  
> > -.. kernel-doc:: drivers/gpu/drm/drm_atomic_helper.c
> > +.. kernel-doc:: drivers/gpu/drm/drm_atomic_state_helper.c
> > :export:
> >  
> >  Simple KMS Helper Reference
> > diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> > index bc6a16a3c36e..576ba985e138 100644
> > --- a/drivers/gpu/drm/Makefile
> > +++ b/drivers/gpu/drm/Makefile
> > @@ -36,7 +36,8 @@ drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o 
> > drm_probe_helper.o \
> > drm_plane_helper.o drm_dp_mst_topology.o drm_atomic_helper.o \
> > drm_kms_helper_common.o drm_dp_dual_mode_helper.o \
> > drm_simple_kms_helper.o drm_modeset_helper.o \
> > -   drm_scdc_helper.o drm_gem_framebuffer_helper.o
> > +   drm_scdc_helper.o drm_gem_framebuffer_helper.o \
> > +   drm_atomic_state_helper.o
> >  
> >  drm_kms_helper-$(CONFIG_DRM_PANEL_BRIDGE) += bridge/panel.o
> >  drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o
> > diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
> > b/drivers/gpu/drm/drm_atomic_helper.c
> > index 8c93f33fe92f..a5edc8757056 100644
> > --- a/drivers/gpu/drm/drm_atomic_helper.c
> > +++ b/drivers/gpu/drm/drm_atomic_helper.c
> > @@ -3382,569 +3382,3 @@ int drm_atomic_helper_page_flip_target(struct 
> > drm_crtc *crtc,
> > return ret;
> >  }
> >  EXPORT_SYMBOL(drm_atomic_helper_page_flip_target);
> > -
> > -/**
> > - * DOC: atomic state reset and initialization
> > - *
> > - * Both the drm core and the atomic helpers assume that there is always 
> > the full
> > - * and correct atomic software state for all connectors, CRTCs and planes
> > - * available. Which is a bit a problem on driver load and also after system
> > - * suspend. One way to solve this is to have a hardware state read-out
> > - * infrastructure which reconstructs the full software state (e.g. the i915
> > - * driver).
> > - *
> > - * The simpler solution is to just reset the software state to everything 
> > off,
> > - * which is easiest to do by calling drm_mode_config_reset(). To 
> > facilitate this
> > - * the atomic helpers provide default reset implementations for all hooks.
> > - *
> > - * On the upside the precise state tracking of atomic simplifies system 
> > suspend
> > - * and resume a lot. For drivers using drm_mode_config_reset() a complete 
> > recipe
> > - * is implemented in drm_atomic_helper_suspend() and 
> > drm_atomic_helper_resume().
> > - * For other drivers the building blocks are split out, see the 
> > documentation
> > - * for these functions.
> > - */
> > -
> > -/**
> > - * drm_atomic_helper_crtc_reset - default _crtc_funcs.reset hook 

Re: [Intel-gfx] [PATCH 03/18] drm: Extract drm_atomic_state_helper.[hc]

2018-10-02 Thread Ville Syrjälä
On Tue, Oct 02, 2018 at 03:35:11PM +0200, Daniel Vetter wrote:
> We already have a separate overview doc for this, makes sense to
> untangle it from the overall atomic helpers.
> 
> v2: Rebase
> 
> v3: Rebase more.

Hopefully the rebases didn't leave any code changes behind...

Too lazy to read in full detail so
Acked-by: Ville Syrjälä 

> 
> Signed-off-by: Daniel Vetter 
> ---
>  Documentation/gpu/drm-kms-helpers.rst |  19 +-
>  drivers/gpu/drm/Makefile  |   3 +-
>  drivers/gpu/drm/drm_atomic_helper.c   | 566 
>  drivers/gpu/drm/drm_atomic_state_helper.c | 601 ++
>  include/drm/drm_atomic_helper.h   |  44 +-
>  include/drm/drm_atomic_state_helper.h |  80 +++
>  6 files changed, 698 insertions(+), 615 deletions(-)
>  create mode 100644 drivers/gpu/drm/drm_atomic_state_helper.c
>  create mode 100644 include/drm/drm_atomic_state_helper.h
> 
> diff --git a/Documentation/gpu/drm-kms-helpers.rst 
> b/Documentation/gpu/drm-kms-helpers.rst
> index f9cfcdcdf024..4b4dc236ef6f 100644
> --- a/Documentation/gpu/drm-kms-helpers.rst
> +++ b/Documentation/gpu/drm-kms-helpers.rst
> @@ -59,19 +59,28 @@ Implementing Asynchronous Atomic Commit
>  .. kernel-doc:: drivers/gpu/drm/drm_atomic_helper.c
> :doc: implementing nonblocking commit
>  
> +Helper Functions Reference
> +--
> +
> +.. kernel-doc:: include/drm/drm_atomic_helper.h
> +   :internal:
> +
> +.. kernel-doc:: drivers/gpu/drm/drm_atomic_helper.c
> +   :export:
> +
>  Atomic State Reset and Initialization
>  -
>  
> -.. kernel-doc:: drivers/gpu/drm/drm_atomic_helper.c
> +.. kernel-doc:: drivers/gpu/drm/drm_atomic_state_helper.c
> :doc: atomic state reset and initialization
>  
> -Helper Functions Reference
> ---
> +Atomic State Helper Reference
> +-
>  
> -.. kernel-doc:: include/drm/drm_atomic_helper.h
> +.. kernel-doc:: include/drm/drm_atomic_state_helper.h
> :internal:
>  
> -.. kernel-doc:: drivers/gpu/drm/drm_atomic_helper.c
> +.. kernel-doc:: drivers/gpu/drm/drm_atomic_state_helper.c
> :export:
>  
>  Simple KMS Helper Reference
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index bc6a16a3c36e..576ba985e138 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -36,7 +36,8 @@ drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o 
> drm_probe_helper.o \
>   drm_plane_helper.o drm_dp_mst_topology.o drm_atomic_helper.o \
>   drm_kms_helper_common.o drm_dp_dual_mode_helper.o \
>   drm_simple_kms_helper.o drm_modeset_helper.o \
> - drm_scdc_helper.o drm_gem_framebuffer_helper.o
> + drm_scdc_helper.o drm_gem_framebuffer_helper.o \
> + drm_atomic_state_helper.o
>  
>  drm_kms_helper-$(CONFIG_DRM_PANEL_BRIDGE) += bridge/panel.o
>  drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
> b/drivers/gpu/drm/drm_atomic_helper.c
> index 8c93f33fe92f..a5edc8757056 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -3382,569 +3382,3 @@ int drm_atomic_helper_page_flip_target(struct 
> drm_crtc *crtc,
>   return ret;
>  }
>  EXPORT_SYMBOL(drm_atomic_helper_page_flip_target);
> -
> -/**
> - * DOC: atomic state reset and initialization
> - *
> - * Both the drm core and the atomic helpers assume that there is always the 
> full
> - * and correct atomic software state for all connectors, CRTCs and planes
> - * available. Which is a bit a problem on driver load and also after system
> - * suspend. One way to solve this is to have a hardware state read-out
> - * infrastructure which reconstructs the full software state (e.g. the i915
> - * driver).
> - *
> - * The simpler solution is to just reset the software state to everything 
> off,
> - * which is easiest to do by calling drm_mode_config_reset(). To facilitate 
> this
> - * the atomic helpers provide default reset implementations for all hooks.
> - *
> - * On the upside the precise state tracking of atomic simplifies system 
> suspend
> - * and resume a lot. For drivers using drm_mode_config_reset() a complete 
> recipe
> - * is implemented in drm_atomic_helper_suspend() and 
> drm_atomic_helper_resume().
> - * For other drivers the building blocks are split out, see the documentation
> - * for these functions.
> - */
> -
> -/**
> - * drm_atomic_helper_crtc_reset - default _crtc_funcs.reset hook for 
> CRTCs
> - * @crtc: drm CRTC
> - *
> - * Resets the atomic state for @crtc by freeing the state pointer (which 
> might
> - * be NULL, e.g. at driver load time) and allocating a new empty state 
> object.
> - */
> -void drm_atomic_helper_crtc_reset(struct drm_crtc *crtc)
> -{
> - if (crtc->state)
> - __drm_atomic_helper_crtc_destroy_state(crtc->state);
> -
> - kfree(crtc->state);
> -  

[Intel-gfx] [PATCH 03/18] drm: Extract drm_atomic_state_helper.[hc]

2018-10-02 Thread Daniel Vetter
We already have a separate overview doc for this, makes sense to
untangle it from the overall atomic helpers.

v2: Rebase

v3: Rebase more.

Signed-off-by: Daniel Vetter 
---
 Documentation/gpu/drm-kms-helpers.rst |  19 +-
 drivers/gpu/drm/Makefile  |   3 +-
 drivers/gpu/drm/drm_atomic_helper.c   | 566 
 drivers/gpu/drm/drm_atomic_state_helper.c | 601 ++
 include/drm/drm_atomic_helper.h   |  44 +-
 include/drm/drm_atomic_state_helper.h |  80 +++
 6 files changed, 698 insertions(+), 615 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_atomic_state_helper.c
 create mode 100644 include/drm/drm_atomic_state_helper.h

diff --git a/Documentation/gpu/drm-kms-helpers.rst 
b/Documentation/gpu/drm-kms-helpers.rst
index f9cfcdcdf024..4b4dc236ef6f 100644
--- a/Documentation/gpu/drm-kms-helpers.rst
+++ b/Documentation/gpu/drm-kms-helpers.rst
@@ -59,19 +59,28 @@ Implementing Asynchronous Atomic Commit
 .. kernel-doc:: drivers/gpu/drm/drm_atomic_helper.c
:doc: implementing nonblocking commit
 
+Helper Functions Reference
+--
+
+.. kernel-doc:: include/drm/drm_atomic_helper.h
+   :internal:
+
+.. kernel-doc:: drivers/gpu/drm/drm_atomic_helper.c
+   :export:
+
 Atomic State Reset and Initialization
 -
 
-.. kernel-doc:: drivers/gpu/drm/drm_atomic_helper.c
+.. kernel-doc:: drivers/gpu/drm/drm_atomic_state_helper.c
:doc: atomic state reset and initialization
 
-Helper Functions Reference
---
+Atomic State Helper Reference
+-
 
-.. kernel-doc:: include/drm/drm_atomic_helper.h
+.. kernel-doc:: include/drm/drm_atomic_state_helper.h
:internal:
 
-.. kernel-doc:: drivers/gpu/drm/drm_atomic_helper.c
+.. kernel-doc:: drivers/gpu/drm/drm_atomic_state_helper.c
:export:
 
 Simple KMS Helper Reference
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index bc6a16a3c36e..576ba985e138 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -36,7 +36,8 @@ drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o 
drm_probe_helper.o \
drm_plane_helper.o drm_dp_mst_topology.o drm_atomic_helper.o \
drm_kms_helper_common.o drm_dp_dual_mode_helper.o \
drm_simple_kms_helper.o drm_modeset_helper.o \
-   drm_scdc_helper.o drm_gem_framebuffer_helper.o
+   drm_scdc_helper.o drm_gem_framebuffer_helper.o \
+   drm_atomic_state_helper.o
 
 drm_kms_helper-$(CONFIG_DRM_PANEL_BRIDGE) += bridge/panel.o
 drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o
diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index 8c93f33fe92f..a5edc8757056 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -3382,569 +3382,3 @@ int drm_atomic_helper_page_flip_target(struct drm_crtc 
*crtc,
return ret;
 }
 EXPORT_SYMBOL(drm_atomic_helper_page_flip_target);
-
-/**
- * DOC: atomic state reset and initialization
- *
- * Both the drm core and the atomic helpers assume that there is always the 
full
- * and correct atomic software state for all connectors, CRTCs and planes
- * available. Which is a bit a problem on driver load and also after system
- * suspend. One way to solve this is to have a hardware state read-out
- * infrastructure which reconstructs the full software state (e.g. the i915
- * driver).
- *
- * The simpler solution is to just reset the software state to everything off,
- * which is easiest to do by calling drm_mode_config_reset(). To facilitate 
this
- * the atomic helpers provide default reset implementations for all hooks.
- *
- * On the upside the precise state tracking of atomic simplifies system suspend
- * and resume a lot. For drivers using drm_mode_config_reset() a complete 
recipe
- * is implemented in drm_atomic_helper_suspend() and 
drm_atomic_helper_resume().
- * For other drivers the building blocks are split out, see the documentation
- * for these functions.
- */
-
-/**
- * drm_atomic_helper_crtc_reset - default _crtc_funcs.reset hook for CRTCs
- * @crtc: drm CRTC
- *
- * Resets the atomic state for @crtc by freeing the state pointer (which might
- * be NULL, e.g. at driver load time) and allocating a new empty state object.
- */
-void drm_atomic_helper_crtc_reset(struct drm_crtc *crtc)
-{
-   if (crtc->state)
-   __drm_atomic_helper_crtc_destroy_state(crtc->state);
-
-   kfree(crtc->state);
-   crtc->state = kzalloc(sizeof(*crtc->state), GFP_KERNEL);
-
-   if (crtc->state)
-   crtc->state->crtc = crtc;
-}
-EXPORT_SYMBOL(drm_atomic_helper_crtc_reset);
-
-/**
- * __drm_atomic_helper_crtc_duplicate_state - copy atomic CRTC state
- * @crtc: CRTC object
- * @state: atomic CRTC state
- *
- * Copies atomic state from a CRTC's current state and resets inferred values.
- * This is useful for drivers