[Bug 95130] Derivatives of gl_Color wrong when helper pixels used

2016-06-07 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=95130

Nicolai Hähnle  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #5 from Nicolai Hähnle  ---
This is now fixed in Mesa Git b42bc90b6add0d0f81d915d49712761d32329afa with
LLVM r272063.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160607/c27e27e5/attachment-0001.html>


[PATCH v3] drm/dsi: Implement set tear scanline

2016-06-07 Thread Sumit Semwal
On 07-Jun-2016 2:32 PM, "Jani Nikula"  wrote:
>
> On Tue, 07 Jun 2016, Vinay Simha BN  wrote:
> > Provide a small convenience wrapper that transmits
> > a set_tear_scanline command.
> >
> > Cc: Archit Taneja 
> > Cc: John Stultz 
> > Cc: Thierry Reding 
> > Cc: Sumit Semwal 
> > Cc: Jani Nikula 
> > Signed-off-by: Vinay Simha BN 
>
> Reviewed-by: Jani Nikula 
>
>
Reviewed-by: Sumit Semwal 
> >
> > --
> > v1:
> >   * helper function suggested by Thierry
> > for set_tear_scanline
> >   * Also includes small build fixes from Sumit Semwal.
> >
> > v2:
> >   * one scanline parameter suggested by jani
> >
> > v3:
> >   * passing the payload properly as suggested by jani
> > --
> > ---
> >  drivers/gpu/drm/drm_mipi_dsi.c | 22 ++
> >  include/drm/drm_mipi_dsi.h |  1 +
> >  2 files changed, 23 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_mipi_dsi.c
b/drivers/gpu/drm/drm_mipi_dsi.c
> > index f5d8083..7938ce7 100644
> > --- a/drivers/gpu/drm/drm_mipi_dsi.c
> > +++ b/drivers/gpu/drm/drm_mipi_dsi.c
> > @@ -983,6 +983,28 @@ int mipi_dsi_dcs_set_tear_on(struct
mipi_dsi_device *dsi,
> >  EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_on);
> >
> >  /**
> > + * mipi_dsi_set_tear_scanline() - turn on the display module's Tearing
Effect
> > + * output signal on the TE signal line when display module reaches
line N
> > + * defined by STS[n:0].
> > + * @dsi: DSI peripheral device
> > + * @param: STS[10:0]
> > + * Return: 0 on success or a negative error code on failure
> > + */
> > +int mipi_dsi_set_tear_scanline(struct mipi_dsi_device *dsi, u16 param)
> > +{
> > + u8 payload[3] = { MIPI_DCS_SET_TEAR_SCANLINE, param >> 8,
> > +   param & 0xff };
> > + ssize_t err;
> > +
> > + err = mipi_dsi_generic_write(dsi, payload, sizeof(payload));
> > + if (err < 0)
> > + return err;
> > +
> > + return 0;
> > +}
> > +EXPORT_SYMBOL(mipi_dsi_set_tear_scanline);
> > +
> > +/**
> >   * mipi_dsi_dcs_set_pixel_format() - sets the pixel format for the RGB
image
> >   *data used by the interface
> >   * @dsi: DSI peripheral device
> > diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
> > index 7a9840f..ec55285 100644
> > --- a/include/drm/drm_mipi_dsi.h
> > +++ b/include/drm/drm_mipi_dsi.h
> > @@ -263,6 +263,7 @@ int mipi_dsi_dcs_set_column_address(struct
mipi_dsi_device *dsi, u16 start,
> >   u16 end);
> >  int mipi_dsi_dcs_set_page_address(struct mipi_dsi_device *dsi, u16
start,
> > u16 end);
> > +int mipi_dsi_set_tear_scanline(struct mipi_dsi_device *dsi, u16 param);
> >  int mipi_dsi_dcs_set_tear_off(struct mipi_dsi_device *dsi);
> >  int mipi_dsi_dcs_set_tear_on(struct mipi_dsi_device *dsi,
> >enum mipi_dsi_dcs_tear_mode mode);
>
> --
> Jani Nikula, Intel Open Source Technology Center
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160607/3575c177/attachment.html>


[PATCH] drm/ast: Remove useless drm_fb_get_bpp_depth() call

2016-06-07 Thread Laurent Pinchart
Hi Eric,

On Tuesday 07 Jun 2016 17:49:20 Eric Engestrom wrote:
> On Mon, Jun 06, 2016 at 09:14:12PM +0300, Laurent Pinchart wrote:
> > The function has no side effect and its returned values are ignored,
> > don't call it.
> > 
> > Signed-off-by: Laurent Pinchart 
> 
> Good catch!  Do you have a tool that detects this, or do you just have
> a really good eye?

I was reviewing the callers of drm_fb_get_bpp_depth() to see if I could get 
rid of the function, and realized that two of them didn't need it. A tool 
would be nice though :-)

> Reviewed-by: Eric Engestrom 
> 
> > ---
> > 
> >  drivers/gpu/drm/ast/ast_fb.c | 3 ---
> >  1 file changed, 3 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/ast/ast_fb.c b/drivers/gpu/drm/ast/ast_fb.c
> > index 5320f8c57884..c017a9330a18 100644
> > --- a/drivers/gpu/drm/ast/ast_fb.c
> > +++ b/drivers/gpu/drm/ast/ast_fb.c
> > @@ -167,12 +167,9 @@ static int astfb_create_object(struct ast_fbdev
> > *afbdev,> 
> >struct drm_gem_object **gobj_p)
> >  
> >  {
> >  
> > struct drm_device *dev = afbdev->helper.dev;
> > 
> > -   u32 bpp, depth;
> > 
> > u32 size;
> > struct drm_gem_object *gobj;
> > 
> > -
> > 
> > int ret = 0;
> > 
> > -   drm_fb_get_bpp_depth(mode_cmd->pixel_format, &depth, &bpp);
> > 
> > size = mode_cmd->pitches[0] * mode_cmd->height;
> > ret = ast_gem_create(dev, size, true, &gobj);

-- 
Regards,

Laurent Pinchart



[PULL] topic/drm-misc

2016-06-07 Thread Daniel Vetter
Hi Dave,

As promised, piles of prep work all around:
- drm_atomic_state rework, prep for nonblocking commit helpers
- fence patches from Gustavo and Christian to prep for atomic fences and
  some cool work in ttm/amdgpu from Christian
- drm event prep for both nonblocking commit and atomic fences
- Gustavo seems on a crusade against the non-kms-native version of the
  vblank functions.
- prep work from Boris to nuke all the silly ->best_encoder
  implementations we have (we really only need that for truly dynamic
  cases like dvi-i vs dvi-d or dp mst selecting the right transcoder on
  intel)
- prep work from Laurent to rework the format handling functions
- and few small things all over

btw since -rc2 has drm-fixes now you can also pull in the earlier pull req
from last week from me that you delayed.

Cheers, Daniel


The following changes since commit 66fd7a66e8b9e11e49f46ea77910f935c4dee5c3:

  Merge branch 'drm-intel-next' of git://anongit.freedesktop.org/drm-intel into 
drm-next (2016-06-02 07:58:36 +1000)

are available in the git repository at:

  git://anongit.freedesktop.org/drm-intel tags/topic/drm-misc-2016-06-07

for you to fetch changes up to e8395081636734da19778b0446d65588a06bc40d:

  drm/dsi: Implement set tear scanline (2016-06-07 21:44:29 +0200)


Boris Brezillon (2):
  drm/atomic: Handle funcs->best_encoder == NULL case
  drm/atomic: Fix remaining places where !funcs->best_encoder is valid

Chris Wilson (2):
  drm: Only create a cmdline mode if no probed modes match
  drm: Store the plane's index

Christian König (2):
  dma-buf/fence: make fence context 64 bit v2
  dma-buf/fence: add signal_on_any to the fence array v2

Daniel Vetter (20):
  drm/atomic-helper: use for_each_*_in_state more
  drm/hdlcd: Clean up crtc hooks
  drm/i915: Use drm_atomic_get_existing_plane_state
  drm/msm: Use for_each_*_in_state
  drm/rcar-du: Use for_each_*_in_state
  drm/vc4: Use for_each_plane_in_state
  drm/omap: Use for_each_plane_in_state
  drm/exynos: Use for_each_crtc_in_state
  drm/doc: Appease sphinx
  drm/atomic: Add drm_atomic_crtc_state_for_each_plane_state
  drm: Consolidate connector arrays in drm_atomic_state
  drm: Consolidate plane arrays in drm_atomic_state
  drm: Consolidate crtc arrays in drm_atomic_state
  drm/atomic-docs: Spelling fixups
  drm/doc: Update kerneldoc for drm_crtc.h
  drm/atomic-helper: Fixup kerneldoc for drm_atomic_helper_legacy_gamma_set
  drm/doc: Improve kernel-doc for drm_fb_cma_helper.c
  drm/gpu.tmpl: Don't forget to rename the include directives, too
  drm/doc: Drop kerneldoc for static functions in drm_irq.c
  drm/doc: Switch to sphinx/rst fixed-width quoting

Gustavo Padovan (15):
  dma-buf/fence: add fence_array fences v6
  drm/fence: add fence to drm_pending_event
  dma-buf/sync_file: fix build warning with context format type
  drm/armada: use drm_crtc_send_vblank_event()
  drm/atmel: use drm_crtc_send_vblank_event()
  drm/qxl: use drm_crtc_send_vblank_event()
  drm/udl: use drm_crtc_send_vblank_event()
  drm/virtio: use drm_crtc_send_vblank_event()
  drm/amdgpu: use drm_crtc_vblank_{get,put}()
  drm/armada: use drm_crtc_vblank_{get,put}()
  drm/atmel: use drm_crtc_vblank_{get,put}()
  drm/qxl: use drm_crtc_vblank_{get,put}()
  drm/radeon: use drm_crtc_vblank_{get,put}()
  drm/shmobile: use drm_crtc_vblank_{get,put}()
  Documentation: add fence-array to kernel DocBook

Laurent Pinchart (2):
  drm/ast: Remove useless drm_fb_get_bpp_depth() call
  drm/qxl: Remove useless drm_fb_get_bpp_depth() call

Liviu Dudau (1):
  drm: Update obsolete information from {enable/disable}_vblank hooks.

Maarten Lankhorst (1):
  drm/core: Change declaration for gamma_set.

Robin Murphy (1):
  drm/fb_cma_helper: Implement fb_mmap callback

Vinay Simha BN (1):
  drm/dsi: Implement set tear scanline

 Documentation/DocBook/device-drivers.tmpl  |   2 +
 Documentation/DocBook/gpu.tmpl |   2 +-
 drivers/dma-buf/Makefile   |   2 +-
 drivers/dma-buf/fence-array.c  | 144 ++
 drivers/dma-buf/fence.c|   8 +-
 drivers/dma-buf/sync_file.c|   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu.h|   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c|   4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c |   2 +-
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c |  12 +-
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c |  12 +-
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c  |  12 +-
 drivers/gpu/drm/arc/arcpgu_drv.c   |   2 +-
 drivers/gpu/drm/arm/hdlcd_crtc.c   |  19 ---
 drivers/gpu/drm/armada/armada_crtc.c   |  14 +--
 drivers/gpu/drm/ast/ast_fb.c   |   3 -
 drivers/gpu/drm/a

[PULL] drm-intel-next

2016-06-07 Thread Daniel Vetter
Hi Dave,

drm-intel-next-2016-06-06:
- some polish for the guc code (Dave Gordon)
- big refactoring of gen9 display clock handling code (Ville)
- refactoring work in the context code (Chris Wilson)
- give encoder/crtc/planes useful names for debug output (Ville)
- improvements to skl/kbl wm computation code (Mahesh Kumar)
- bunch of smaller improvements all over as usual

Cheers, Daniel


The following changes since commit 66fd7a66e8b9e11e49f46ea77910f935c4dee5c3:

  Merge branch 'drm-intel-next' of git://anongit.freedesktop.org/drm-intel into 
drm-next (2016-06-02 07:58:36 +1000)

are available in the git repository at:

  git://anongit.freedesktop.org/drm-intel tags/drm-intel-next-2016-06-06

for you to fetch changes up to 1750d59dfa3caf1fc5354a2217f0e83d717c9b22:

  drm/i915: Update DRIVER_DATE to 20160606 (2016-06-06 00:29:53 +0200)


- some polish for the guc code (Dave Gordon)
- big refactoring of gen9 display clock handling code (Ville)
- refactoring work in the context code (Chris Wilson)
- give encoder/crtc/planes useful names for debug output (Ville)
- improvements to skl/kbl wm computation code (Mahesh Kumar)
- bunch of smaller improvements all over as usual


Ander Conselvan de Oliveira (1):
  drm/i915: Fix NULL pointer deference when out of PLLs in IVB

Chris Wilson (14):
  drm/i915/opregion: Convert to using native drm_i915_private
  drm/i915/opregion: Rename init/fini functions to register/unregister
  drm/i915: Rename struct intel_context
  drm/i915: Apply lockdep annotations to i915_gem_context.c
  drm/i915: Rename and inline i915_gem_context_get()
  drm/i915: Name the inner most per-engine intel_context struct
  drm/i915: Move pinning of dev_priv->kernel_context into its creator
  drm/i915: Show i915_gem_context owner in debugfs
  drm/i915: Put the kernel_context in drm_i915_private next to its friends
  drm/i915: Merge legacy+execlists context structs
  drm/i915: Rearrange i915_gem_context
  drm/i915/debugfs: Show context objects in i915_gem_objects
  drm/i915: Only ignore eDP ports that are connected
  drm/i915: Silence "unexpected child device config size" for VBT on 845g

Clint Taylor (1):
  drm/i915/skl: SKL CDCLK change on modeset tracking VCO

Daniel Vetter (3):
  drm/i915: Revert async unpin and nonblocking atomic commit
  Merge remote-tracking branch 'airlied/drm-next' into drm-intel-next-queued
  drm/i915: Update DRIVER_DATE to 20160606

Dave Gordon (6):
  drm/i915/guc: rename loader entry points
  drm/i915/guc: distinguish HAS_GUC() from HAS_GUC_UCODE/HAS_GUC_SCHED
  drm/i915/guc: add enable_guc_loading parameter
  drm/i915/guc: pass request (not client) to i915_guc_{wq_check_space, 
submit}()
  drm/i915/guc: don't spinwait if the GuC's workqueue is full
  drm/i915/guc: rework guc_add_workqueue_item()

Imre Deak (2):
  drm/i915/gen9: Assume CDCLK PLL is off if it's not locked
  drm/i915/bxt: Sanitize CDCLK to fix breakage during S4 resume

Kumar, Mahesh (3):
  drm/i915/skl+: calculate ddb minimum allocation (v6)
  drm/i915/skl+: calculate plane pixel rate (v4)
  drm/i915/skl+: Use scaling amount for plane data rate calculation (v4)

Lyude (1):
  drm/i915/ilk: Don't disable SSC source if it's in use

Matt Roper (1):
  drm/i915: Don't try to calculate relative data rates during hw readout

Sagar Arun Kamble (1):
  drm/i915: Update GEN6_PMINTRMSK setup with GuC enabled

Tvrtko Ursulin (1):
  drm/i915/guc: Disable automatic GuC firmware loading

Ville Syrjälä (31):
  drm/i915: Enable GSE interrupt on BDW+
  drm/i915: Fix BXT min_pixclk after state readout
  drm/i915: Move the SKL DPLL0 VCO computation into 
intel_dp_compute_config()
  drm/i915: Extract skl_calc_cdclk()
  drm/i915: Actually read out DPLL0 vco on skl from hardware
  drm/i915: Report the current DPLL0 vco on SKL/KBL
  drm/i915: Allow enable/disable of DPLL0 around cdclk changes on SKL
  drm/i915: Keep track of preferred cdclk vco frequency on SKL
  drm/i915: Beef up skl_sanitize_cdclk() a bit
  drm/i915: Unify SKL cdclk init paths
  drm/i915: Move SKL+ DBUF enable/disable to display core init/uninit
  drm/i915: Make 308 and 671 MHz cdclks more accurate on SKL
  drm/i915: Rename skl_vco_freq to cdclk_pll.vco
  drm/i915: Store cdclk PLL reference clock under dev_priv
  drm/i915: Extract bxt DE PLL enable/disable from broxton_set_cdclk()
  drm/i915: Store BXT DE PLL vco and ref clocks in dev_priv
  drm/i915: Update cached cdclk state from broxton_init_cdclk()
  drm/i915: Rewrite broxton_get_display_clock_speed() in terms of the DE 
PLL vco/refclk
  drm/i915: Make bxt_set_cdclk() operate in terms of the current vs target 
DE PLL vco
  drm/i915: Replace bxt_verify_cdclk_state() with 

[PATCH v2 5/9] drm/fb-helper: Add top-level lock

2016-06-07 Thread Daniel Vetter
On Tue, Jun 07, 2016 at 05:26:21PM +0200, Thierry Reding wrote:
> From: Thierry Reding 
> 
> Introduce a new top-level lock for the FB helper code. This will allow
> better locking granularity and avoid the need to abuse modeset locking
> for this purpose instead.
> 
> Signed-off-by: Thierry Reding 

I think this is now too much locking, and ime too much locking only leads
to massive confusion. It'd be great if we can clean this up (maybe in a
follow-up patch, maybe in this one here) and restrict the core locks to
just where we need them: So all the places that look at probe state need
dev->mode_config.mutex, all the places that change modeset state need the
modeset locks. But e.g. add/remove_one_connector only need the new
fb_helper->lock I think. In the future we might grabbing the other locks
even down into the legacy/atomic fbdev implementations.

> ---
>  drivers/gpu/drm/drm_fb_helper.c | 27 ++-
>  include/drm/drm_fb_helper.h |  5 +
>  2 files changed, 31 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 252c7557bdb5..f7722bcb0064 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -105,6 +105,7 @@ static int __drm_fb_helper_add_one_connector(struct 
> drm_fb_helper *fb_helper,
>   if (!drm_fbdev_emulation)
>   return 0;
>  
> + WARN_ON(!mutex_is_locked(&fb_helper->lock));
>   WARN_ON(!mutex_is_locked(&fb_helper->dev->mode_config.mutex));
>  
>   count = fb_helper->connector_count + 1;
> @@ -127,6 +128,7 @@ static int __drm_fb_helper_add_one_connector(struct 
> drm_fb_helper *fb_helper,
>   drm_connector_reference(connector);
>   conn->connector = connector;
>   fb_helper->connector_info[fb_helper->connector_count++] = conn;
> +
>   return 0;
>  }
>  
> @@ -135,11 +137,13 @@ int drm_fb_helper_add_one_connector(struct 
> drm_fb_helper *fb_helper,
>  {
>   int err;
>  
> + mutex_lock(&fb_helper->lock);
>   mutex_lock(&fb_helper->dev->mode_config.mutex);
>  
>   err = __drm_fb_helper_add_one_connector(fb_helper, connector);
>  
>   mutex_unlock(&fb_helper->dev->mode_config.mutex);
> + mutex_unlock(&fb_helper->lock);
>  
>   return err;
>  }
> @@ -168,6 +172,7 @@ int drm_fb_helper_single_add_all_connectors(struct 
> drm_fb_helper *fb_helper)
>   if (!drm_fbdev_emulation)
>   return 0;
>  
> + mutex_lock(&fb_helper->lock);
>   mutex_lock(&dev->mode_config.mutex);
>  
>   drm_for_each_connector(connector, dev) {
> @@ -184,6 +189,7 @@ int drm_fb_helper_single_add_all_connectors(struct 
> drm_fb_helper *fb_helper)
>   }
>  
>   mutex_unlock(&dev->mode_config.mutex);
> + mutex_unlock(&fb_helper->lock);
>  
>   return ret;
>  }
> @@ -198,6 +204,7 @@ static int __drm_fb_helper_remove_one_connector(struct 
> drm_fb_helper *fb_helper,
>   if (!drm_fbdev_emulation)
>   return 0;
>  
> + WARN_ON(!mutex_is_locked(&fb_helper->lock));
>   WARN_ON(!mutex_is_locked(&fb_helper->dev->mode_config.mutex));
>  
>   for (i = 0; i < fb_helper->connector_count; i++) {
> @@ -225,11 +232,13 @@ int drm_fb_helper_remove_one_connector(struct 
> drm_fb_helper *fb_helper,
>  {
>   int err;
>  
> + mutex_lock(&fb_helper->lock);
>   mutex_lock(&fb_helper->dev->mode_config.mutex);
>  
>   err = __drm_fb_helper_remove_one_connector(fb_helper, connector);
>  
>   mutex_unlock(&fb_helper->dev->mode_config.mutex);
> + mutex_unlock(&fb_helper->lock);
>  
>   return err;
>  }
> @@ -478,16 +487,21 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct 
> drm_fb_helper *fb_helper)
>   if (!drm_fbdev_emulation)
>   return -ENODEV;
>  
> + mutex_lock(&fb_helper->lock);
>   drm_modeset_lock_all(dev);
> +
>   ret = restore_fbdev_mode(fb_helper);
>  
>   do_delayed = fb_helper->delayed_hotplug;
>   if (do_delayed)
>   fb_helper->delayed_hotplug = false;
> +
>   drm_modeset_unlock_all(dev);
> + mutex_unlock(&fb_helper->lock);
>  
>   if (do_delayed)
>   drm_fb_helper_hotplug_event(fb_helper);
> +
>   return ret;
>  }
>  EXPORT_SYMBOL(drm_fb_helper_restore_fbdev_mode_unlocked);
> @@ -688,6 +702,7 @@ void drm_fb_helper_prepare(struct drm_device *dev, struct 
> drm_fb_helper *helper,
>   spin_lock_init(&helper->dirty_lock);
>   INIT_WORK(&helper->dirty_work, drm_fb_helper_dirty_work);
>   helper->dirty_clip.x1 = helper->dirty_clip.y1 = ~0;
> + mutex_init(&helper->lock);
>   helper->funcs = funcs;
>   helper->dev = dev;
>  }
> @@ -853,6 +868,7 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper)
>   unregister_sysrq_key('v', 
> &sysrq_drm_fb_helper_restore_op);
>   }
>  
> + mutex_destroy(&fb_helper->lock);
>   drm_fb_helper_crtc_free(fb_helper);
>  
>  }
> @@ -2273,16 +2289,20 @@ int drm_fb_helper_hotplug_eve

[PATCH v2 8/9] drm/exynos: Remove custom FB helper deferred setup

2016-06-07 Thread Daniel Vetter
On Tue, Jun 07, 2016 at 05:26:24PM +0200, Thierry Reding wrote:
> From: Thierry Reding 
> 
> The FB helper core now supports deferred setup, so the driver's custom
> implementation can be removed.
> 
> Signed-off-by: Thierry Reding 
> ---
>  drivers/gpu/drm/exynos/exynos_drm_drv.c   | 8 ++--
>  drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 --
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c 
> b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> index 2dd820e23b0c..259c2585c703 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> @@ -215,11 +215,15 @@ static int exynos_drm_load(struct drm_device *dev, 
> unsigned long flags)
>   /* init kms poll for handling hpd */
>   drm_kms_helper_poll_init(dev);
>  
> - /* force connectors detection */
> - drm_helper_hpd_irq_event(dev);
> + ret = exynos_drm_fbdev_init(dev);
> + if (ret)
> + goto err_cleanup_poll;
>  
>   return 0;
>  
> +err_cleanup_poll:
> + drm_kms_helper_poll_fini(dev);
> + exynos_drm_device_subdrv_remove(dev);
>  err_cleanup_vblank:
>   drm_vblank_cleanup(dev);
>  err_unbind_all:
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c 
> b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> index 67dcd6831291..83a277946200 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> @@ -319,6 +319,4 @@ void exynos_drm_output_poll_changed(struct drm_device 
> *dev)
>  
>   if (fb_helper)
>   drm_fb_helper_hotplug_event(fb_helper);

I think you can drop that if now too, since we always init the structure
(just not register the fbdev instance itself).
-Daniel

> - else
> - exynos_drm_fbdev_init(dev);
>  }
> -- 
> 2.8.3
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[PATCH v3] drm/dsi: Implement set tear scanline

2016-06-07 Thread Daniel Vetter
On Tue, Jun 07, 2016 at 11:21:10PM +0530, Sumit Semwal wrote:
> On 07-Jun-2016 2:32 PM, "Jani Nikula"  wrote:
> >
> > On Tue, 07 Jun 2016, Vinay Simha BN  wrote:
> > > Provide a small convenience wrapper that transmits
> > > a set_tear_scanline command.
> > >
> > > Cc: Archit Taneja 
> > > Cc: John Stultz 
> > > Cc: Thierry Reding 
> > > Cc: Sumit Semwal 
> > > Cc: Jani Nikula 
> > > Signed-off-by: Vinay Simha BN 
> >
> > Reviewed-by: Jani Nikula 
> >
> >
> Reviewed-by: Sumit Semwal 

Applied to drm-misc, thanks.
-Daniel

> > >
> > > --
> > > v1:
> > >   * helper function suggested by Thierry
> > > for set_tear_scanline
> > >   * Also includes small build fixes from Sumit Semwal.
> > >
> > > v2:
> > >   * one scanline parameter suggested by jani
> > >
> > > v3:
> > >   * passing the payload properly as suggested by jani
> > > --
> > > ---
> > >  drivers/gpu/drm/drm_mipi_dsi.c | 22 ++
> > >  include/drm/drm_mipi_dsi.h |  1 +
> > >  2 files changed, 23 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/drm_mipi_dsi.c
> b/drivers/gpu/drm/drm_mipi_dsi.c
> > > index f5d8083..7938ce7 100644
> > > --- a/drivers/gpu/drm/drm_mipi_dsi.c
> > > +++ b/drivers/gpu/drm/drm_mipi_dsi.c
> > > @@ -983,6 +983,28 @@ int mipi_dsi_dcs_set_tear_on(struct
> mipi_dsi_device *dsi,
> > >  EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_on);
> > >
> > >  /**
> > > + * mipi_dsi_set_tear_scanline() - turn on the display module's Tearing
> Effect
> > > + * output signal on the TE signal line when display module reaches
> line N
> > > + * defined by STS[n:0].
> > > + * @dsi: DSI peripheral device
> > > + * @param: STS[10:0]
> > > + * Return: 0 on success or a negative error code on failure
> > > + */
> > > +int mipi_dsi_set_tear_scanline(struct mipi_dsi_device *dsi, u16 param)
> > > +{
> > > + u8 payload[3] = { MIPI_DCS_SET_TEAR_SCANLINE, param >> 8,
> > > +   param & 0xff };
> > > + ssize_t err;
> > > +
> > > + err = mipi_dsi_generic_write(dsi, payload, sizeof(payload));
> > > + if (err < 0)
> > > + return err;
> > > +
> > > + return 0;
> > > +}
> > > +EXPORT_SYMBOL(mipi_dsi_set_tear_scanline);
> > > +
> > > +/**
> > >   * mipi_dsi_dcs_set_pixel_format() - sets the pixel format for the RGB
> image
> > >   *data used by the interface
> > >   * @dsi: DSI peripheral device
> > > diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
> > > index 7a9840f..ec55285 100644
> > > --- a/include/drm/drm_mipi_dsi.h
> > > +++ b/include/drm/drm_mipi_dsi.h
> > > @@ -263,6 +263,7 @@ int mipi_dsi_dcs_set_column_address(struct
> mipi_dsi_device *dsi, u16 start,
> > >   u16 end);
> > >  int mipi_dsi_dcs_set_page_address(struct mipi_dsi_device *dsi, u16
> start,
> > > u16 end);
> > > +int mipi_dsi_set_tear_scanline(struct mipi_dsi_device *dsi, u16 param);
> > >  int mipi_dsi_dcs_set_tear_off(struct mipi_dsi_device *dsi);
> > >  int mipi_dsi_dcs_set_tear_on(struct mipi_dsi_device *dsi,
> > >enum mipi_dsi_dcs_tear_mode mode);
> >
> > --
> > Jani Nikula, Intel Open Source Technology Center

> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel


-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[PATCH] drm/fb_cma_helper: Implement fb_mmap callback

2016-06-07 Thread Daniel Vetter
On Tue, Jun 07, 2016 at 04:03:40PM +0100, Robin Murphy wrote:
> On 07/06/16 15:43, Daniel Vetter wrote:
> > On Tue, Jun 07, 2016 at 01:18:09PM +0100, Robin Murphy wrote:
> > > In the absence of an fb_mmap callback, the fbdev code falls back to a
> > > naive implementation which relies upon the DMA address being the same
> > > as the physical address, and the buffer being physically contiguous
> > > from there. Whilst this often holds for standard CMA allocations via
> > > the platform's regular DMA ops, if the allocation is provided by an
> > > IOMMU then such assumptions can fall apart spectacularly.
> > > 
> > > To resolve this, reroute the fb_mmap call to the appropriate DMA API
> > > implementation, as per the other cma_helper calls.
> > > 
> > > Acked-by: Daniel Vetter 
> > > Signed-off-by: Robin Murphy 
> > > ---
> > > 
> > > Resending rebased to 4.7-rc1 with Daniel's ack. I know Russell raised
> > > some concerns about the general way fb_cma_helper uses fb_info[1], but
> > > AFAICS that's a longstanding separate problem orthogonal to this patch.
> > 
> > Do you want me to pull this in through drm-misc, or will this land through
> > some driver tree? Note that I'll do -misc pulls about every week, so if
> > you don't send your pull this week I'd like to pull it in to avoid
> > hilarity^W needless conflicts.
> 
> Yeah, drm-misc sounds appropriate so if you're happy to pick it up, please
> feel free :)

Applied, thanks.
-Daniel

> 
> Robin.
> 
> > -Daniel
> > 
> > > 
> > > Robin.
> > > 
> > > [1]:http://thread.gmane.org/gmane.comp.video.dri.devel/149288
> > > 
> > >   drivers/gpu/drm/drm_fb_cma_helper.c | 8 
> > >   1 file changed, 8 insertions(+)
> > > 
> > > diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c 
> > > b/drivers/gpu/drm/drm_fb_cma_helper.c
> > > index 172cafe11c71..a25afc068d3f 100644
> > > --- a/drivers/gpu/drm/drm_fb_cma_helper.c
> > > +++ b/drivers/gpu/drm/drm_fb_cma_helper.c
> > > @@ -23,6 +23,7 @@
> > >   #include 
> > >   #include 
> > >   #include 
> > > +#include 
> > >   #include 
> > > 
> > >   #define DEFAULT_FBDEFIO_DELAY_MS 50
> > > @@ -297,6 +298,12 @@ int drm_fb_cma_debugfs_show(struct seq_file *m, void 
> > > *arg)
> > >   EXPORT_SYMBOL_GPL(drm_fb_cma_debugfs_show);
> > >   #endif
> > > 
> > > +static int drm_fb_cma_mmap(struct fb_info *info, struct vm_area_struct 
> > > *vma)
> > > +{
> > > + return dma_mmap_writecombine(info->device, vma, info->screen_base,
> > > +  info->fix.smem_start, info->fix.smem_len);
> > > +}
> > > +
> > >   static struct fb_ops drm_fbdev_cma_ops = {
> > >   .owner  = THIS_MODULE,
> > >   .fb_fillrect= drm_fb_helper_sys_fillrect,
> > > @@ -307,6 +314,7 @@ static struct fb_ops drm_fbdev_cma_ops = {
> > >   .fb_blank   = drm_fb_helper_blank,
> > >   .fb_pan_display = drm_fb_helper_pan_display,
> > >   .fb_setcmap = drm_fb_helper_setcmap,
> > > + .fb_mmap= drm_fb_cma_mmap,
> > >   };
> > > 
> > >   static int drm_fbdev_cma_deferred_io_mmap(struct fb_info *info,
> > > --
> > > 2.8.1.dirty
> > > 
> > 
> 
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[PATCH v6 1/4] drm: drm_helper_crtc_enable_color_mgmt() => drm_crtc_enable_color_mgmt()

2016-06-07 Thread Daniel Vetter
On Tue, Jun 07, 2016 at 07:54:35PM +0300, Tomi Valkeinen wrote:
> On 07/06/16 15:09, Jyri Sarha wrote:
> > Add drm_crtc_enable_color_mgmt(), remove drm_helper_crtc_enable_color_mgmt()
> > and update drm/i915-driver (the only user of the old function).
> > 
> > The new function is more flexible. It allows driver to enable only the
> > features it has without forcing to enable all three color management
> > properties: degamma lut, csc matrix (ctm), and gamma lut.
> > 
> > Suggested-by: Daniel Vetter 
> > Signed-off-by: Jyri Sarha 
> > ---
> >  drivers/gpu/drm/drm_crtc.c | 45 
> > ++
> >  drivers/gpu/drm/drm_crtc_helper.c  | 33 
> >  drivers/gpu/drm/i915/intel_color.c |  3 ++-
> >  include/drm/drm_crtc.h |  5 -
> >  include/drm/drm_crtc_helper.h  |  3 ---
> >  5 files changed, 51 insertions(+), 38 deletions(-)
> 
> Looks good to me. I can queue this up with the omapdrm patches in this
> series, if no one complains.

btw would be good if you send a pull for omapdrm in 1-2 weeks latest once
this is merged, to avoid unecessary conflicts and other hilarity.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[Intel-gfx] [PATCH v4] drm/i915/ilk: Don't disable SSC source if it's in use

2016-06-07 Thread Daniel Vetter
On Tue, Jun 07, 2016 at 10:02:35AM +0300, Jani Nikula wrote:
> On Mon, 06 Jun 2016, Lyude Paul  wrote:
> > On Mon, 2016-06-06 at 14:30 +0300, Ville Syrjälä wrote:
> >> On Thu, May 26, 2016 at 09:54:56AM +0200, Daniel Vetter wrote:
> >> > 
> >> > Queued for -next, thanks for the patch.
> >> Looks like this one broke one of the ILKs in CI.
> >> 
> >> [   13.100979] [drm:ironlake_init_pch_refclk] has_panel 1 has_lvds 1 
> >> has_ck505
> >> 0 using_ssc_source 1
> >> [   13.101413] [ cut here ]
> >> [   13.101429] kernel BUG at drivers/gpu/drm/i915/intel_display.c:8528!
> >> 
> >> which is the 'BUG_ON(val != final)' at the end of 
> >> ironlake_init_pch_refclk().
> >> 
> > Managed to find a machine at the office here that I could reproduce this on 
> > and
> > figured out the problem with the patch. Unfortunately, the Optiplex 990 
> > that I
> > was seeing this issue on already left the office and the person in charge 
> > of it
> > just went on PTO until the end of the week. For the time being don't merge 
> > this
> > patch until I can get access to that machine again and make sure the fixed
> > version of this patch still works on the 990. I'll send the new version 
> > once I'm
> > able to test it.
> 
> Daniel already merged it, should we revert?

Oops, can do. Or if I have a fixup right away we can merge that, too.
Waiting otoh isn't cool. Lyude?
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[Bug 95517] Constant GPU VM faults

2016-06-07 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=95517

--- Comment #7 from lumetili at gmail.com ---
Created attachment 124390
  --> https://bugs.freedesktop.org/attachment.cgi?id=124390&action=edit
GPU softreset

PCIe errors go away with pcie_aspm=off as well apparently.

Regardless, my computer keeps crashing so badly not even SysRq works. I don't
get any kernel error messages about anything except for the GPU faults. Usually
I get a whole bunch of them just before completely crashing.

Last night the computer was idle and screens were in powersaving mode and they
suddenly woke up and then turned off again - apparently it crashed.

This time there's a better error in the journal from before the crash:

GPU fault -> GPU lockup -> Couldn't update BO_VA -> GPU softreset -> dead

See attachment.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160607/08b31280/attachment.html>


[PATCH v6 1/4] drm: drm_helper_crtc_enable_color_mgmt() => drm_crtc_enable_color_mgmt()

2016-06-07 Thread Tomi Valkeinen
On 07/06/16 15:09, Jyri Sarha wrote:
> Add drm_crtc_enable_color_mgmt(), remove drm_helper_crtc_enable_color_mgmt()
> and update drm/i915-driver (the only user of the old function).
> 
> The new function is more flexible. It allows driver to enable only the
> features it has without forcing to enable all three color management
> properties: degamma lut, csc matrix (ctm), and gamma lut.
> 
> Suggested-by: Daniel Vetter 
> Signed-off-by: Jyri Sarha 
> ---
>  drivers/gpu/drm/drm_crtc.c | 45 
> ++
>  drivers/gpu/drm/drm_crtc_helper.c  | 33 
>  drivers/gpu/drm/i915/intel_color.c |  3 ++-
>  include/drm/drm_crtc.h |  5 -
>  include/drm/drm_crtc_helper.h  |  3 ---
>  5 files changed, 51 insertions(+), 38 deletions(-)

Looks good to me. I can queue this up with the omapdrm patches in this
series, if no one complains.

 Tomi

-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160607/0670ef8b/attachment.sig>


274ad65c9d02 ("drm/radeon: hard reset r600 and newer GPU when hibernating.")

2016-06-07 Thread Jerome Glisse
> On Mon, Jun 06, 2016 at 05:40:19PM -0400, Jerome Glisse wrote:
> > Brokens how ? Symptoms ?
> 
> Whoops, sorry, I meant to elaborate...
> 
> After doing:
> 
> echo "shutdown" > /sys/power/disk
> echo "disk" > /sys/power/state
> 
> screen goes blank but machine remains powered on and doesn't go off. No
> responses to keyboard presses, etc. The only thing left to do is the
> reset button.

Ok i don't have too much time to dig into r600 i assume that r700 breaks
the same way so could you verify that attached patch fix the issue for
you. Note that video decoding is likely broken for you after hibernation
but you might have never notice it.

Cheers,
Jérôme
-- next part --
A non-text attachment was scrubbed...
Name: 0001-drm-radeon-do-not-hard-reset-GPU-while-freezing-on-r.patch
Type: text/x-patch
Size: 1407 bytes
Desc: not available
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160607/4cf9d5dc/attachment.bin>


[PATCH] drm/qxl: Remove useless drm_fb_get_bpp_depth() call

2016-06-07 Thread Eric Engestrom
On Mon, Jun 06, 2016 at 09:14:51PM +0300, Laurent Pinchart wrote:
> The function has no side effect and its returned values are ignored,
> don't call it.
> 
> Signed-off-by: Laurent Pinchart 

Reviewed-by: Eric Engestrom 

> ---
>  drivers/gpu/drm/qxl/qxl_fb.c | 4 
>  1 file changed, 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/qxl/qxl_fb.c b/drivers/gpu/drm/qxl/qxl_fb.c
> index 5ea57f6320b8..df2657051afd 100644
> --- a/drivers/gpu/drm/qxl/qxl_fb.c
> +++ b/drivers/gpu/drm/qxl/qxl_fb.c
> @@ -131,10 +131,6 @@ static int qxlfb_create_pinned_object(struct qxl_fbdev 
> *qfbdev,
>   int ret;
>   int aligned_size, size;
>   int height = mode_cmd->height;
> - int bpp;
> - int depth;
> -
> - drm_fb_get_bpp_depth(mode_cmd->pixel_format, &bpp, &depth);
>  
>   size = mode_cmd->pitches[0] * height;
>   aligned_size = ALIGN(size, PAGE_SIZE);
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/ast: Remove useless drm_fb_get_bpp_depth() call

2016-06-07 Thread Eric Engestrom
On Mon, Jun 06, 2016 at 09:14:12PM +0300, Laurent Pinchart wrote:
> The function has no side effect and its returned values are ignored,
> don't call it.
> 
> Signed-off-by: Laurent Pinchart 

Good catch!  Do you have a tool that detects this, or do you just have
a really good eye?

Reviewed-by: Eric Engestrom 

> ---
>  drivers/gpu/drm/ast/ast_fb.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ast/ast_fb.c b/drivers/gpu/drm/ast/ast_fb.c
> index 5320f8c57884..c017a9330a18 100644
> --- a/drivers/gpu/drm/ast/ast_fb.c
> +++ b/drivers/gpu/drm/ast/ast_fb.c
> @@ -167,12 +167,9 @@ static int astfb_create_object(struct ast_fbdev *afbdev,
>  struct drm_gem_object **gobj_p)
>  {
>   struct drm_device *dev = afbdev->helper.dev;
> - u32 bpp, depth;
>   u32 size;
>   struct drm_gem_object *gobj;
> -
>   int ret = 0;
> - drm_fb_get_bpp_depth(mode_cmd->pixel_format, &depth, &bpp);
>  
>   size = mode_cmd->pitches[0] * mode_cmd->height;
>   ret = ast_gem_create(dev, size, true, &gobj);
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel


HDLCD crashes with 6d910bfa809e

2016-06-07 Thread Robin Murphy
On 07/06/16 15:40, Daniel Vetter wrote:
> On Tue, Jun 07, 2016 at 01:06:00PM +0100, Robin Murphy wrote:
>> Hi Daniel, Liviu,
>>
>> Having just inadvertently merged -next into my working branch, I find
>> dev6d910bfa809e ("drm/hlcd: Use lockless gem BO free callback") adversely
>> affecting my board's ability to boot ;)
>>
>> Since I (intentionally) don't have sufficient CMA to create a framebuffer,
>> drm_gem_cma_create() fails, unconditionally calls the now-NULL
>> drm->driver->gem_free_object() in its cleanup path, and fiery death
>> ensues...
>
> Please make sure you have the drm fixes from 4.7-rc2 included, this issue
> is fixed there.

Ah, right you are, thanks - the fact that that the newer branches I 
tried crashed or otherwise failed due to unrelated TDA998x problems 
threw me off. I see Chris' fix there now.

Robin.

> -Daniel
>



[PATCH v2 9/9] drm/hisilicon: Remove custom FB helper deferred setup

2016-06-07 Thread Thierry Reding
From: Thierry Reding 

The FB helper core now supports deferred setup, so the driver's custom
implementation can be removed.

Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c 
b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
index 3f94785fbcca..0e0bd77e4499 100644
--- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
+++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
@@ -54,15 +54,7 @@ static void kirin_fbdev_output_poll_changed(struct 
drm_device *dev)
 {
struct kirin_drm_private *priv = dev->dev_private;

-   if (priv->fbdev) {
-   drm_fbdev_cma_hotplug_event(priv->fbdev);
-   } else {
-   priv->fbdev = drm_fbdev_cma_init(dev, 32,
-   dev->mode_config.num_crtc,
-   dev->mode_config.num_connector);
-   if (IS_ERR(priv->fbdev))
-   priv->fbdev = NULL;
-   }
+   drm_fbdev_cma_hotplug_event(priv->fbdev);
 }
 #endif

@@ -129,11 +121,19 @@ static int kirin_drm_kms_init(struct drm_device *dev)
/* init kms poll for handling hpd */
drm_kms_helper_poll_init(dev);

-   /* force detection after connectors init */
-   (void)drm_helper_hpd_irq_event(dev);
+   priv->fbdev = drm_fbdev_cma_init(dev, 32, dev->mode_config.num_crtc,
+dev->mode_config.num_connector);
+   if (IS_ERR(priv->fbdev)) {
+   DRM_ERROR("failed to initialize fbdev.\n");
+   ret = PTR_ERR(priv->fbdev);
+   goto err_cleanup_poll;
+   }

return 0;

+err_cleanup_poll:
+   drm_kms_helper_poll_fini(dev);
+   drm_vblank_cleanup(dev);
 err_unbind_all:
component_unbind_all(dev->dev, dev);
 err_dc_cleanup:
-- 
2.8.3



[PATCH v2 8/9] drm/exynos: Remove custom FB helper deferred setup

2016-06-07 Thread Thierry Reding
From: Thierry Reding 

The FB helper core now supports deferred setup, so the driver's custom
implementation can be removed.

Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/exynos/exynos_drm_drv.c   | 8 ++--
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 2 --
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c 
b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index 2dd820e23b0c..259c2585c703 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -215,11 +215,15 @@ static int exynos_drm_load(struct drm_device *dev, 
unsigned long flags)
/* init kms poll for handling hpd */
drm_kms_helper_poll_init(dev);

-   /* force connectors detection */
-   drm_helper_hpd_irq_event(dev);
+   ret = exynos_drm_fbdev_init(dev);
+   if (ret)
+   goto err_cleanup_poll;

return 0;

+err_cleanup_poll:
+   drm_kms_helper_poll_fini(dev);
+   exynos_drm_device_subdrv_remove(dev);
 err_cleanup_vblank:
drm_vblank_cleanup(dev);
 err_unbind_all:
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c 
b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
index 67dcd6831291..83a277946200 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
@@ -319,6 +319,4 @@ void exynos_drm_output_poll_changed(struct drm_device *dev)

if (fb_helper)
drm_fb_helper_hotplug_event(fb_helper);
-   else
-   exynos_drm_fbdev_init(dev);
 }
-- 
2.8.3



[PATCH v2 7/9] drm/atmel-hlcdc: Remove custom FB helper deferred setup

2016-06-07 Thread Thierry Reding
From: Thierry Reding 

The FB helper core now supports deferred setup, so the driver's custom
implementation can be removed.

Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 26 +++---
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
index 8ded7645747e..a8a855910885 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
@@ -431,15 +431,7 @@ static void atmel_hlcdc_fb_output_poll_changed(struct 
drm_device *dev)
 {
struct atmel_hlcdc_dc *dc = dev->dev_private;

-   if (dc->fbdev) {
-   drm_fbdev_cma_hotplug_event(dc->fbdev);
-   } else {
-   dc->fbdev = drm_fbdev_cma_init(dev, 24,
-   dev->mode_config.num_crtc,
-   dev->mode_config.num_connector);
-   if (IS_ERR(dc->fbdev))
-   dc->fbdev = NULL;
-   }
+   drm_fbdev_cma_hotplug_event(dc->fbdev);
 }

 struct atmel_hlcdc_dc_commit {
@@ -654,11 +646,23 @@ static int atmel_hlcdc_dc_load(struct drm_device *dev)

drm_kms_helper_poll_init(dev);

-   /* force connectors detection */
-   drm_helper_hpd_irq_event(dev);
+   dc->fbdev = drm_fbdev_cma_init(dev, 24, dev->mode_config.num_crtc,
+  dev->mode_config.num_connector);
+   if (IS_ERR(dc->fbdev)) {
+   dev_err(dev->dev, "failed to setup fbdev\n");
+   ret = PTR_ERR(dc->fbdev);
+   goto err_cleanup_poll;
+   }

return 0;

+err_cleanup_poll:
+   drm_kms_helper_poll_fini(dev);
+
+   pm_runtime_get_sync(dev->dev);
+   drm_irq_uninstall(dev);
+   pm_runtime_put_sync(dev->dev);
+
 err_periph_clk_disable:
pm_runtime_disable(dev->dev);
clk_disable_unprepare(dc->hlcdc->periph_clk);
-- 
2.8.3



[PATCH v2 6/9] drm/fb-helper: Support deferred setup

2016-06-07 Thread Thierry Reding
From: Thierry Reding 

FB helper code falls back to a 1024x768 mode if no outputs are connected
or don't report back any modes upon initialization. This can be annoying
because outputs that are added to FB helper later on can't be used with
FB helper if they don't support a matching mode.

The fallback is in place because VGA connectors can happen to report an
unknown connection status even when they are in fact connected.

Some drivers have custom solutions in place to defer FB helper setup
until at least one output is connected. But the logic behind these
solutions is always the same and there is nothing driver-specific about
it, so a better alterative is to fix the FB helper core and add support
for all drivers automatically.

This patch adds support for deferred FB helper setup. It checks all the
connectors for their connection status, and if all of them report to be
disconnected marks the FB helper as needing deferred setup. Whet setup
is deferred, the FB helper core will automatically retry setup after a
hotplug event, and it will keep trying until it succeeds.

Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/drm_fb_helper.c | 36 
 include/drm/drm_fb_helper.h | 21 +
 2 files changed, 57 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index f7722bcb0064..0911b10c711c 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -487,6 +487,9 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct 
drm_fb_helper *fb_helper)
if (!drm_fbdev_emulation)
return -ENODEV;

+   if (fb_helper->deferred_setup)
+   return 0;
+
mutex_lock(&fb_helper->lock);
drm_modeset_lock_all(dev);

@@ -1452,6 +1455,23 @@ unlock:
 }
 EXPORT_SYMBOL(drm_fb_helper_pan_display);

+static bool drm_fb_helper_maybe_connected(struct drm_fb_helper *helper)
+{
+   bool connected = false;
+   unsigned int i;
+
+   for (i = 0; i < helper->connector_count; i++) {
+   struct drm_fb_helper_connector *fb = helper->connector_info[i];
+
+   if (fb->connector->status != connector_status_disconnected) {
+   connected = true;
+   break;
+   }
+   }
+
+   return connected;
+}
+
 /*
  * Allocates the backing storage and sets up the fbdev info structure through
  * the ->fb_probe callback and then registers the fbdev and sets up the panic
@@ -1554,6 +1574,17 @@ static int drm_fb_helper_single_fb_probe(struct 
drm_fb_helper *fb_helper,
sizes.fb_height = min_t(u32, desired_mode->vdisplay + 
y, sizes.fb_height);
}

+   /*
+* If everything's disconnected, there's no use in attempting to set
+* up fbdev.
+*/
+   if (!drm_fb_helper_maybe_connected(fb_helper)) {
+   DRM_INFO("No outputs connected, deferring setup\n");
+   fb_helper->preferred_bpp = preferred_bpp;
+   fb_helper->deferred_setup = true;
+   return 0;
+   }
+
if (crtc_count == 0 || sizes.fb_width == -1 || sizes.fb_height == -1) {
/* hmm everyone went away - assume VGA cable just fell out
   and will come back later. */
@@ -1593,6 +1624,7 @@ static int drm_fb_helper_single_fb_probe(struct 
drm_fb_helper *fb_helper,

list_add(&fb_helper->kernel_fb_list, &kernel_fb_helper_list);

+   fb_helper->deferred_setup = false;
return 0;
 }

@@ -2294,6 +2326,10 @@ int drm_fb_helper_hotplug_event(struct drm_fb_helper 
*fb_helper)
if (!drm_fbdev_emulation)
return 0;

+   if (fb_helper->deferred_setup)
+   return drm_fb_helper_initial_config(fb_helper,
+   fb_helper->preferred_bpp);
+
mutex_lock(&fb_helper->lock);
mutex_lock(&fb_helper->dev->mode_config.mutex);

diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 7739be08ebca..dac155ad33f6 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -219,6 +219,27 @@ struct drm_fb_helper {
bool delayed_hotplug;

/**
+* @deferred_setup:
+*
+* If no outputs are connected (disconnected or unknown) the FB helper
+* code will defer setup until at least one of the outputs shows up.
+* This field keeps track of the status so that setup can be retried
+* at every hotplug event until it succeeds eventually.
+*/
+   bool deferred_setup;
+
+   /**
+* @preferred_bpp:
+*
+* Temporary storage for the driver's preferred BPP setting passed to
+* FB helper initialization. This needs to be tracked so that deferred
+* FB helper setup can pass this on.
+*
+* See also: @deferred_setup
+*/
+   int preferred_bpp;
+
+   /**
 * @atom

[PATCH v2 5/9] drm/fb-helper: Add top-level lock

2016-06-07 Thread Thierry Reding
From: Thierry Reding 

Introduce a new top-level lock for the FB helper code. This will allow
better locking granularity and avoid the need to abuse modeset locking
for this purpose instead.

Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/drm_fb_helper.c | 27 ++-
 include/drm/drm_fb_helper.h |  5 +
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 252c7557bdb5..f7722bcb0064 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -105,6 +105,7 @@ static int __drm_fb_helper_add_one_connector(struct 
drm_fb_helper *fb_helper,
if (!drm_fbdev_emulation)
return 0;

+   WARN_ON(!mutex_is_locked(&fb_helper->lock));
WARN_ON(!mutex_is_locked(&fb_helper->dev->mode_config.mutex));

count = fb_helper->connector_count + 1;
@@ -127,6 +128,7 @@ static int __drm_fb_helper_add_one_connector(struct 
drm_fb_helper *fb_helper,
drm_connector_reference(connector);
conn->connector = connector;
fb_helper->connector_info[fb_helper->connector_count++] = conn;
+
return 0;
 }

@@ -135,11 +137,13 @@ int drm_fb_helper_add_one_connector(struct drm_fb_helper 
*fb_helper,
 {
int err;

+   mutex_lock(&fb_helper->lock);
mutex_lock(&fb_helper->dev->mode_config.mutex);

err = __drm_fb_helper_add_one_connector(fb_helper, connector);

mutex_unlock(&fb_helper->dev->mode_config.mutex);
+   mutex_unlock(&fb_helper->lock);

return err;
 }
@@ -168,6 +172,7 @@ int drm_fb_helper_single_add_all_connectors(struct 
drm_fb_helper *fb_helper)
if (!drm_fbdev_emulation)
return 0;

+   mutex_lock(&fb_helper->lock);
mutex_lock(&dev->mode_config.mutex);

drm_for_each_connector(connector, dev) {
@@ -184,6 +189,7 @@ int drm_fb_helper_single_add_all_connectors(struct 
drm_fb_helper *fb_helper)
}

mutex_unlock(&dev->mode_config.mutex);
+   mutex_unlock(&fb_helper->lock);

return ret;
 }
@@ -198,6 +204,7 @@ static int __drm_fb_helper_remove_one_connector(struct 
drm_fb_helper *fb_helper,
if (!drm_fbdev_emulation)
return 0;

+   WARN_ON(!mutex_is_locked(&fb_helper->lock));
WARN_ON(!mutex_is_locked(&fb_helper->dev->mode_config.mutex));

for (i = 0; i < fb_helper->connector_count; i++) {
@@ -225,11 +232,13 @@ int drm_fb_helper_remove_one_connector(struct 
drm_fb_helper *fb_helper,
 {
int err;

+   mutex_lock(&fb_helper->lock);
mutex_lock(&fb_helper->dev->mode_config.mutex);

err = __drm_fb_helper_remove_one_connector(fb_helper, connector);

mutex_unlock(&fb_helper->dev->mode_config.mutex);
+   mutex_unlock(&fb_helper->lock);

return err;
 }
@@ -478,16 +487,21 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct 
drm_fb_helper *fb_helper)
if (!drm_fbdev_emulation)
return -ENODEV;

+   mutex_lock(&fb_helper->lock);
drm_modeset_lock_all(dev);
+
ret = restore_fbdev_mode(fb_helper);

do_delayed = fb_helper->delayed_hotplug;
if (do_delayed)
fb_helper->delayed_hotplug = false;
+
drm_modeset_unlock_all(dev);
+   mutex_unlock(&fb_helper->lock);

if (do_delayed)
drm_fb_helper_hotplug_event(fb_helper);
+
return ret;
 }
 EXPORT_SYMBOL(drm_fb_helper_restore_fbdev_mode_unlocked);
@@ -688,6 +702,7 @@ void drm_fb_helper_prepare(struct drm_device *dev, struct 
drm_fb_helper *helper,
spin_lock_init(&helper->dirty_lock);
INIT_WORK(&helper->dirty_work, drm_fb_helper_dirty_work);
helper->dirty_clip.x1 = helper->dirty_clip.y1 = ~0;
+   mutex_init(&helper->lock);
helper->funcs = funcs;
helper->dev = dev;
 }
@@ -853,6 +868,7 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper)
unregister_sysrq_key('v', 
&sysrq_drm_fb_helper_restore_op);
}

+   mutex_destroy(&fb_helper->lock);
drm_fb_helper_crtc_free(fb_helper);

 }
@@ -2273,16 +2289,20 @@ int drm_fb_helper_hotplug_event(struct drm_fb_helper 
*fb_helper)
 {
struct drm_device *dev = fb_helper->dev;
u32 max_width, max_height;
+   int err = 0;

if (!drm_fbdev_emulation)
return 0;

+   mutex_lock(&fb_helper->lock);
mutex_lock(&fb_helper->dev->mode_config.mutex);
+
if (!fb_helper->fb || !drm_fb_helper_is_bound(fb_helper)) {
fb_helper->delayed_hotplug = true;
mutex_unlock(&fb_helper->dev->mode_config.mutex);
-   return 0;
+   goto unlock;
}
+
DRM_DEBUG_KMS("\n");

max_width = fb_helper->fb->width;
@@ -2290,6 +2310,7 @@ int drm_fb_helper_hotplug_event(struct drm_fb_helper 
*fb_helper)

drm_fb_helper_probe_connector_modes(fb_helper, max_width, max_height);

[PATCH v2 4/9] drm/fb-helper: Push down modeset lock into FB helpers

2016-06-07 Thread Thierry Reding
From: Thierry Reding 

Move the modeset locking from drivers into FB helpers.

Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/drm_fb_helper.c| 59 +-
 drivers/gpu/drm/i915/intel_dp_mst.c|  4 ---
 drivers/gpu/drm/radeon/radeon_dp_mst.c |  7 
 3 files changed, 44 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 9afd4208596f..252c7557bdb5 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -95,8 +95,8 @@ static LIST_HEAD(kernel_fb_helper_list);
  * mmap page writes.
  */

-int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper,
-   struct drm_connector *connector)
+static int __drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper,
+struct drm_connector *connector)
 {
struct drm_fb_helper_connector **temp;
struct drm_fb_helper_connector *conn;
@@ -129,6 +129,20 @@ int drm_fb_helper_add_one_connector(struct drm_fb_helper 
*fb_helper,
fb_helper->connector_info[fb_helper->connector_count++] = conn;
return 0;
 }
+
+int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper,
+   struct drm_connector *connector)
+{
+   int err;
+
+   mutex_lock(&fb_helper->dev->mode_config.mutex);
+
+   err = __drm_fb_helper_add_one_connector(fb_helper, connector);
+
+   mutex_unlock(&fb_helper->dev->mode_config.mutex);
+
+   return err;
+}
 EXPORT_SYMBOL(drm_fb_helper_add_one_connector);

 /**
@@ -155,28 +169,28 @@ int drm_fb_helper_single_add_all_connectors(struct 
drm_fb_helper *fb_helper)
return 0;

mutex_lock(&dev->mode_config.mutex);
+
drm_for_each_connector(connector, dev) {
-   ret = drm_fb_helper_add_one_connector(fb_helper, connector);
+   ret = __drm_fb_helper_add_one_connector(fb_helper, connector);
+   if (ret) {
+   for (i = 0; i < fb_helper->connector_count; i++) {
+   kfree(fb_helper->connector_info[i]);
+   fb_helper->connector_info[i] = NULL;
+   }

-   if (ret)
-   goto fail;
-   }
-   mutex_unlock(&dev->mode_config.mutex);
-   return 0;
-fail:
-   for (i = 0; i < fb_helper->connector_count; i++) {
-   kfree(fb_helper->connector_info[i]);
-   fb_helper->connector_info[i] = NULL;
+   fb_helper->connector_count = 0;
+   break;
+   }
}
-   fb_helper->connector_count = 0;
+
mutex_unlock(&dev->mode_config.mutex);

return ret;
 }
 EXPORT_SYMBOL(drm_fb_helper_single_add_all_connectors);

-int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper,
-  struct drm_connector *connector)
+static int __drm_fb_helper_remove_one_connector(struct drm_fb_helper 
*fb_helper,
+   struct drm_connector *connector)
 {
struct drm_fb_helper_connector *fb_helper_connector;
int i, j;
@@ -193,6 +207,7 @@ int drm_fb_helper_remove_one_connector(struct drm_fb_helper 
*fb_helper,

if (i == fb_helper->connector_count)
return -EINVAL;
+
fb_helper_connector = fb_helper->connector_info[i];
drm_connector_unreference(fb_helper_connector->connector);

@@ -204,6 +219,20 @@ int drm_fb_helper_remove_one_connector(struct 
drm_fb_helper *fb_helper,

return 0;
 }
+
+int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper,
+  struct drm_connector *connector)
+{
+   int err;
+
+   mutex_lock(&fb_helper->dev->mode_config.mutex);
+
+   err = __drm_fb_helper_remove_one_connector(fb_helper, connector);
+
+   mutex_unlock(&fb_helper->dev->mode_config.mutex);
+
+   return err;
+}
 EXPORT_SYMBOL(drm_fb_helper_remove_one_connector);

 static void drm_fb_helper_save_lut_atomic(struct drm_crtc *crtc, struct 
drm_fb_helper *helper)
diff --git a/drivers/gpu/drm/i915/intel_dp_mst.c 
b/drivers/gpu/drm/i915/intel_dp_mst.c
index 7a34090cef34..47c3980cb3b9 100644
--- a/drivers/gpu/drm/i915/intel_dp_mst.c
+++ b/drivers/gpu/drm/i915/intel_dp_mst.c
@@ -477,9 +477,7 @@ static void intel_dp_register_mst_connector(struct 
drm_connector *connector)
 {
struct intel_connector *intel_connector = to_intel_connector(connector);
struct drm_device *dev = connector->dev;
-   drm_modeset_lock_all(dev);
intel_connector_add_to_fbdev(intel_connector);
-   drm_modeset_unlock_all(dev);
drm_connector_register(&intel_connector->base);
 }

@@ -492,10 +490,8 @@ static void intel_dp_destroy_mst_connector(struct 
drm_dp_mst_topology_mgr *mgr,
intel_connector->unregister(intel_connec

[PATCH v2 3/9] drm/fb-helper: Improve code readability

2016-06-07 Thread Thierry Reding
From: Thierry Reding 

Add a couple of temporary variables and use shorter names for existing
variables in drm_fb_helper_add_one_connector() for better readability.

Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/drm_fb_helper.c | 26 --
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 301644d12013..9afd4208596f 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -95,32 +95,38 @@ static LIST_HEAD(kernel_fb_helper_list);
  * mmap page writes.
  */

-int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, struct 
drm_connector *connector)
+int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper,
+   struct drm_connector *connector)
 {
struct drm_fb_helper_connector **temp;
-   struct drm_fb_helper_connector *fb_helper_connector;
+   struct drm_fb_helper_connector *conn;
+   unsigned int count;

if (!drm_fbdev_emulation)
return 0;

WARN_ON(!mutex_is_locked(&fb_helper->dev->mode_config.mutex));
-   if (fb_helper->connector_count + 1 > 
fb_helper->connector_info_alloc_count) {
-   temp = krealloc(fb_helper->connector_info, sizeof(struct 
drm_fb_helper_connector *) * (fb_helper->connector_count + 1), GFP_KERNEL);
+
+   count = fb_helper->connector_count + 1;
+
+   if (count > fb_helper->connector_info_alloc_count) {
+   size_t size = count * sizeof(conn);
+
+   temp = krealloc(fb_helper->connector_info, size, GFP_KERNEL);
if (!temp)
return -ENOMEM;

-   fb_helper->connector_info_alloc_count = 
fb_helper->connector_count + 1;
+   fb_helper->connector_info_alloc_count = count;
fb_helper->connector_info = temp;
}

-
-   fb_helper_connector = kzalloc(sizeof(struct drm_fb_helper_connector), 
GFP_KERNEL);
-   if (!fb_helper_connector)
+   conn = kzalloc(sizeof(*conn), GFP_KERNEL);
+   if (!conn)
return -ENOMEM;

drm_connector_reference(connector);
-   fb_helper_connector->connector = connector;
-   fb_helper->connector_info[fb_helper->connector_count++] = 
fb_helper_connector;
+   conn->connector = connector;
+   fb_helper->connector_info[fb_helper->connector_count++] = conn;
return 0;
 }
 EXPORT_SYMBOL(drm_fb_helper_add_one_connector);
-- 
2.8.3



[PATCH v2 2/9] drm/fb-helper: Reshuffle code for subsequent patches

2016-06-07 Thread Thierry Reding
From: Thierry Reding 

An unlocked version of the drm_fb_helper_add_one_connector() function
will be added in a subsequent patch. Reshuffle the code separately to
make the diff more readable later on.

Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/drm_fb_helper.c | 60 -
 1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 7945620e7439..301644d12013 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -95,6 +95,36 @@ static LIST_HEAD(kernel_fb_helper_list);
  * mmap page writes.
  */

+int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, struct 
drm_connector *connector)
+{
+   struct drm_fb_helper_connector **temp;
+   struct drm_fb_helper_connector *fb_helper_connector;
+
+   if (!drm_fbdev_emulation)
+   return 0;
+
+   WARN_ON(!mutex_is_locked(&fb_helper->dev->mode_config.mutex));
+   if (fb_helper->connector_count + 1 > 
fb_helper->connector_info_alloc_count) {
+   temp = krealloc(fb_helper->connector_info, sizeof(struct 
drm_fb_helper_connector *) * (fb_helper->connector_count + 1), GFP_KERNEL);
+   if (!temp)
+   return -ENOMEM;
+
+   fb_helper->connector_info_alloc_count = 
fb_helper->connector_count + 1;
+   fb_helper->connector_info = temp;
+   }
+
+
+   fb_helper_connector = kzalloc(sizeof(struct drm_fb_helper_connector), 
GFP_KERNEL);
+   if (!fb_helper_connector)
+   return -ENOMEM;
+
+   drm_connector_reference(connector);
+   fb_helper_connector->connector = connector;
+   fb_helper->connector_info[fb_helper->connector_count++] = 
fb_helper_connector;
+   return 0;
+}
+EXPORT_SYMBOL(drm_fb_helper_add_one_connector);
+
 /**
  * drm_fb_helper_single_add_all_connectors() - add all connectors to fbdev
  *emulation helper
@@ -139,36 +169,6 @@ fail:
 }
 EXPORT_SYMBOL(drm_fb_helper_single_add_all_connectors);

-int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, struct 
drm_connector *connector)
-{
-   struct drm_fb_helper_connector **temp;
-   struct drm_fb_helper_connector *fb_helper_connector;
-
-   if (!drm_fbdev_emulation)
-   return 0;
-
-   WARN_ON(!mutex_is_locked(&fb_helper->dev->mode_config.mutex));
-   if (fb_helper->connector_count + 1 > 
fb_helper->connector_info_alloc_count) {
-   temp = krealloc(fb_helper->connector_info, sizeof(struct 
drm_fb_helper_connector *) * (fb_helper->connector_count + 1), GFP_KERNEL);
-   if (!temp)
-   return -ENOMEM;
-
-   fb_helper->connector_info_alloc_count = 
fb_helper->connector_count + 1;
-   fb_helper->connector_info = temp;
-   }
-
-
-   fb_helper_connector = kzalloc(sizeof(struct drm_fb_helper_connector), 
GFP_KERNEL);
-   if (!fb_helper_connector)
-   return -ENOMEM;
-
-   drm_connector_reference(connector);
-   fb_helper_connector->connector = connector;
-   fb_helper->connector_info[fb_helper->connector_count++] = 
fb_helper_connector;
-   return 0;
-}
-EXPORT_SYMBOL(drm_fb_helper_add_one_connector);
-
 int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper,
   struct drm_connector *connector)
 {
-- 
2.8.3



[PATCH v2 1/9] drm/fb-helper: Cleanup checkpatch warnings

2016-06-07 Thread Thierry Reding
From: Thierry Reding 

Fix up a couple of checkpatch warnings, such as whitespace or coding
style issues.

Signed-off-by: Thierry Reding 
---
 drivers/gpu/drm/drm_fb_helper.c | 33 +++--
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 7c2eb75db60f..7945620e7439 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -190,9 +190,9 @@ int drm_fb_helper_remove_one_connector(struct drm_fb_helper 
*fb_helper,
fb_helper_connector = fb_helper->connector_info[i];
drm_connector_unreference(fb_helper_connector->connector);

-   for (j = i + 1; j < fb_helper->connector_count; j++) {
+   for (j = i + 1; j < fb_helper->connector_count; j++)
fb_helper->connector_info[j - 1] = fb_helper->connector_info[j];
-   }
+
fb_helper->connector_count--;
kfree(fb_helper_connector);

@@ -290,6 +290,7 @@ int drm_fb_helper_debug_leave(struct fb_info *info)

for (i = 0; i < helper->crtc_count; i++) {
struct drm_mode_set *mode_set = &helper->crtc_info[i].mode_set;
+
crtc = mode_set->crtc;
funcs = crtc->helper_private;
fb = drm_mode_config_fb(crtc);
@@ -317,7 +318,7 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper 
*fb_helper)
struct drm_plane *plane;
struct drm_atomic_state *state;
int i, ret;
-   unsigned plane_mask;
+   unsigned int plane_mask;

state = drm_atomic_state_alloc(dev);
if (!state)
@@ -349,7 +350,7 @@ retry:
goto fail;
}

-   for(i = 0; i < fb_helper->crtc_count; i++) {
+   for (i = 0; i < fb_helper->crtc_count; i++) {
struct drm_mode_set *mode_set = 
&fb_helper->crtc_info[i].mode_set;

ret = __drm_atomic_helper_set_config(mode_set, state);
@@ -511,6 +512,7 @@ static bool drm_fb_helper_force_kernel_mode(void)
 static void drm_fb_helper_restore_work_fn(struct work_struct *ignored)
 {
bool ret;
+
ret = drm_fb_helper_force_kernel_mode();
if (ret == true)
DRM_ERROR("Failed to restore crtc configuration\n");
@@ -812,9 +814,8 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper)

if (!list_empty(&fb_helper->kernel_fb_list)) {
list_del(&fb_helper->kernel_fb_list);
-   if (list_empty(&kernel_fb_helper_list)) {
+   if (list_empty(&kernel_fb_helper_list))
unregister_sysrq_key('v', 
&sysrq_drm_fb_helper_restore_op);
-   }
}

drm_fb_helper_crtc_free(fb_helper);
@@ -1059,6 +1060,7 @@ static int setcolreg(struct drm_crtc *crtc, u16 red, u16 
green,
(blue << info->var.blue.offset);
if (info->var.transp.length > 0) {
u32 mask = (1 << info->var.transp.length) - 1;
+
mask <<= info->var.transp.offset;
value |= mask;
}
@@ -1087,6 +1089,7 @@ static int setcolreg(struct drm_crtc *crtc, u16 red, u16 
green,
if (fb->depth == 16) {
u16 r, g, b;
int i;
+
if (regno < 32) {
for (i = 0; i < 8; i++)
fb_helper->funcs->gamma_set(crtc, red,
@@ -1298,7 +1301,7 @@ static int pan_display_atomic(struct fb_var_screeninfo 
*var,
struct drm_atomic_state *state;
struct drm_plane *plane;
int i, ret;
-   unsigned plane_mask;
+   unsigned int plane_mask;

state = drm_atomic_state_alloc(dev);
if (!state)
@@ -1307,7 +1310,7 @@ static int pan_display_atomic(struct fb_var_screeninfo 
*var,
state->acquire_ctx = dev->mode_config.acquire_ctx;
 retry:
plane_mask = 0;
-   for(i = 0; i < fb_helper->crtc_count; i++) {
+   for (i = 0; i < fb_helper->crtc_count; i++) {
struct drm_mode_set *mode_set;

mode_set = &fb_helper->crtc_info[i].mode_set;
@@ -1416,8 +1419,8 @@ static int drm_fb_helper_single_fb_probe(struct 
drm_fb_helper *fb_helper,
memset(&sizes, 0, sizeof(struct drm_fb_helper_surface_size));
sizes.surface_depth = 24;
sizes.surface_bpp = 32;
-   sizes.fb_width = (unsigned)-1;
-   sizes.fb_height = (unsigned)-1;
+   sizes.fb_width = (u32)-1;
+   sizes.fb_height = (u32)-1;

/* if driver picks 8 or 16 by default use that
   for both depth/bpp */
@@ -1485,6 +1488,7 @@ static int drm_fb_helper_single_fb_probe(struct 
drm_fb_helper *fb_helper,

for (j = 0; j < mode_set->num_connectors; j++) {
struct drm_connector *connector = 
mode_set->connectors[j];
+
if (connector->has_tile) {
lasth = (connecto

[PATCH v2 0/9] drm/fb-helper: Deferred setup support

2016-06-07 Thread Thierry Reding
From: Thierry Reding 

This set of patches adds support for deferring FB helper setup, which is
useful to obtain a sane configuration even when no outputs are available
during probe.

One example is HDMI, where fbdev will currently fallback to a 1024x786
resolution if no monitor is connected, and will then forever stay that
way. With these patches, the FB helpers will take note that it doesn't
make sense to setup fbdev yet and will defer until a monitor is
connected, at which point the preferred mode will be selected.

Thierry

Changes in v2:
- now with locking

Thierry Reding (9):
  drm/fb-helper: Cleanup checkpatch warnings
  drm/fb-helper: Reshuffle code for subsequent patches
  drm/fb-helper: Improve code readability
  drm/fb-helper: Push down modeset lock into FB helpers
  drm/fb-helper: Add top-level lock
  drm/fb-helper: Support deferred setup
  drm/atmel-hlcdc: Remove custom FB helper deferred setup
  drm/exynos: Remove custom FB helper deferred setup
  drm/hisilicon: Remove custom FB helper deferred setup

 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c|  26 +--
 drivers/gpu/drm/drm_fb_helper.c | 217 +---
 drivers/gpu/drm/exynos/exynos_drm_drv.c |   8 +-
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c   |   2 -
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c |  22 +--
 drivers/gpu/drm/i915/intel_dp_mst.c |   4 -
 drivers/gpu/drm/radeon/radeon_dp_mst.c  |   7 -
 include/drm/drm_fb_helper.h |  26 +++
 8 files changed, 217 insertions(+), 95 deletions(-)

-- 
2.8.3



[PATCH] drm/fb_cma_helper: Implement fb_mmap callback

2016-06-07 Thread Daniel Vetter
On Tue, Jun 07, 2016 at 01:18:09PM +0100, Robin Murphy wrote:
> In the absence of an fb_mmap callback, the fbdev code falls back to a
> naive implementation which relies upon the DMA address being the same
> as the physical address, and the buffer being physically contiguous
> from there. Whilst this often holds for standard CMA allocations via
> the platform's regular DMA ops, if the allocation is provided by an
> IOMMU then such assumptions can fall apart spectacularly.
> 
> To resolve this, reroute the fb_mmap call to the appropriate DMA API
> implementation, as per the other cma_helper calls.
> 
> Acked-by: Daniel Vetter 
> Signed-off-by: Robin Murphy 
> ---
> 
> Resending rebased to 4.7-rc1 with Daniel's ack. I know Russell raised
> some concerns about the general way fb_cma_helper uses fb_info[1], but
> AFAICS that's a longstanding separate problem orthogonal to this patch.

Do you want me to pull this in through drm-misc, or will this land through
some driver tree? Note that I'll do -misc pulls about every week, so if
you don't send your pull this week I'd like to pull it in to avoid
hilarity^W needless conflicts.
-Daniel

> 
> Robin.
> 
> [1]:http://thread.gmane.org/gmane.comp.video.dri.devel/149288
> 
>  drivers/gpu/drm/drm_fb_cma_helper.c | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c 
> b/drivers/gpu/drm/drm_fb_cma_helper.c
> index 172cafe11c71..a25afc068d3f 100644
> --- a/drivers/gpu/drm/drm_fb_cma_helper.c
> +++ b/drivers/gpu/drm/drm_fb_cma_helper.c
> @@ -23,6 +23,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  #define DEFAULT_FBDEFIO_DELAY_MS 50
> @@ -297,6 +298,12 @@ int drm_fb_cma_debugfs_show(struct seq_file *m, void 
> *arg)
>  EXPORT_SYMBOL_GPL(drm_fb_cma_debugfs_show);
>  #endif
>  
> +static int drm_fb_cma_mmap(struct fb_info *info, struct vm_area_struct *vma)
> +{
> + return dma_mmap_writecombine(info->device, vma, info->screen_base,
> +  info->fix.smem_start, info->fix.smem_len);
> +}
> +
>  static struct fb_ops drm_fbdev_cma_ops = {
>   .owner  = THIS_MODULE,
>   .fb_fillrect= drm_fb_helper_sys_fillrect,
> @@ -307,6 +314,7 @@ static struct fb_ops drm_fbdev_cma_ops = {
>   .fb_blank   = drm_fb_helper_blank,
>   .fb_pan_display = drm_fb_helper_pan_display,
>   .fb_setcmap = drm_fb_helper_setcmap,
> + .fb_mmap= drm_fb_cma_mmap,
>  };
>  
>  static int drm_fbdev_cma_deferred_io_mmap(struct fb_info *info,
> -- 
> 2.8.1.dirty
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


HDLCD crashes with 6d910bfa809e

2016-06-07 Thread Daniel Vetter
On Tue, Jun 07, 2016 at 01:06:00PM +0100, Robin Murphy wrote:
> Hi Daniel, Liviu,
> 
> Having just inadvertently merged -next into my working branch, I find
> dev6d910bfa809e ("drm/hlcd: Use lockless gem BO free callback") adversely
> affecting my board's ability to boot ;)
> 
> Since I (intentionally) don't have sufficient CMA to create a framebuffer,
> drm_gem_cma_create() fails, unconditionally calls the now-NULL
> drm->driver->gem_free_object() in its cleanup path, and fiery death
> ensues...

Please make sure you have the drm fixes from 4.7-rc2 included, this issue
is fixed there.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[GIT PULL] foundation for omapdrm header clean-up series for 4.8

2016-06-07 Thread Peter Ujfalusi
Hi Tony, Tomi

as you have requested I have created the immutable branch containing the
mach-omap2 touching patches only from the omapdss header cleanup.

As I have mentioned in the v3 cover letter I have the other branch
containing the whole series:
https://www.mail-archive.com/linux-kernel at vger.kernel.org/msg1158006.html

-- 
Péter

The following changes since commit 1a695a905c18548062509178b98bc91e67510864:

  Linux 4.7-rc1 (2016-05-29 09:29:24 -0700)

are available in the git repository at:

  https://github.com/omap-audio/linux-audio.git peter/for-4.8_omapdss_part1

for you to fetch changes up to f8e0db9722e069f48f58e191948e85f6254879db:

  ARM: OMAP2: Use the platform_data header for omapdss (2016-06-03 16:01:01 
+0300)


Peter Ujfalusi (4):
  ARM: OMAP: rx51-video: Do not set TV connector_type
  ARM/video: omap2: Move omap_display_init declaration to 
mach-omap2/display.h
  video/platform_data: omapdss: Create new header file for platform data
  ARM: OMAP2: Use the platform_data header for omapdss

 arch/arm/mach-omap2/board-ldp.c|  3 ++-
 arch/arm/mach-omap2/board-rx51-video.c |  4 ++--
 arch/arm/mach-omap2/display.c  |  2 +-
 arch/arm/mach-omap2/display.h  |  5 
 arch/arm/mach-omap2/dss-common.c   |  2 +-
 include/linux/platform_data/omapdss.h  | 42 +
 include/video/omapdss.h| 31 +---
 7 files changed, 54 insertions(+), 35 deletions(-)
 create mode 100644 include/linux/platform_data/omapdss.h


[PATCH v2 01/20] drm/atomic: Fix remaining places where !funcs->best_encoder is valid

2016-06-07 Thread Daniel Vetter
On Tue, Jun 07, 2016 at 01:47:56PM +0200, Boris Brezillon wrote:
> Adapt drm_pick_crtcs() and update_connector_routing() to fallback to
> drm_atomic_helper_best_encoder() if funcs->best_encoder() is NULL so
> that DRM drivers can leave this hook unassigned if they know they want
> to use drm_atomic_helper_best_encoder().
> 
> Update the vtables documentation accordingly.
> 
> Signed-off-by: Boris Brezillon 

Applied to drm-misc, thanks. I think I'll wait with the driver patches
until next week or so.
-Daniel

> ---
>  drivers/gpu/drm/drm_atomic_helper.c  |  4 +++-
>  drivers/gpu/drm/drm_fb_helper.c  | 13 -
>  include/drm/drm_modeset_helper_vtables.h | 10 --
>  3 files changed, 23 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
> b/drivers/gpu/drm/drm_atomic_helper.c
> index f6a3350..849d029 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -300,8 +300,10 @@ update_connector_routing(struct drm_atomic_state *state,
>   if (funcs->atomic_best_encoder)
>   new_encoder = funcs->atomic_best_encoder(connector,
>connector_state);
> - else
> + else if (funcs->best_encoder)
>   new_encoder = funcs->best_encoder(connector);
> + else
> + new_encoder = drm_atomic_helper_best_encoder(connector);
>  
>   if (!new_encoder) {
>   DRM_DEBUG_ATOMIC("No suitable encoder found for 
> [CONNECTOR:%d:%s]\n",
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 7c2eb75..d44389a 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -2000,7 +2000,18 @@ static int drm_pick_crtcs(struct drm_fb_helper 
> *fb_helper,
>   my_score++;
>  
>   connector_funcs = connector->helper_private;
> - encoder = connector_funcs->best_encoder(connector);
> +
> + /*
> +  * If the DRM device implements atomic hooks and ->best_encoder() is
> +  * NULL we fallback to the default drm_atomic_helper_best_encoder()
> +  * helper.
> +  */
> + if (fb_helper->dev->mode_config.funcs->atomic_commit &&
> + !connector_funcs->best_encoder)
> + encoder = drm_atomic_helper_best_encoder(connector);
> + else
> + encoder = connector_funcs->best_encoder(connector);
> +
>   if (!encoder)
>   goto out;
>  
> diff --git a/include/drm/drm_modeset_helper_vtables.h 
> b/include/drm/drm_modeset_helper_vtables.h
> index d4619dc..4e7a53b 100644
> --- a/include/drm/drm_modeset_helper_vtables.h
> +++ b/include/drm/drm_modeset_helper_vtables.h
> @@ -736,6 +736,11 @@ struct drm_connector_helper_funcs {
>* inspect dynamic configuration state should instead use
>* @atomic_best_encoder.
>*
> +  * You can leave this function to NULL if the connector is only
> +  * attached to a single encoder and you are using the atomic helpers.
> +  * In this case, the core will call drm_atomic_helper_best_encoder()
> +  * for you.
> +  *
>* RETURNS:
>*
>* Encoder that should be used for the given connector and connector
> @@ -752,8 +757,9 @@ struct drm_connector_helper_funcs {
>* need to select the best encoder depending upon the desired
>* configuration and can't select it statically.
>*
> -  * This function is used by drm_atomic_helper_check_modeset() and either
> -  * this or @best_encoder is required.
> +  * This function is used by drm_atomic_helper_check_modeset().
> +  * If it is not implemented, the core will fallback to @best_encoder
> +  * (or drm_atomic_helper_best_encoder() if @best_encoder is NULL).
>*
>* NOTE:
>*
> -- 
> 2.7.4
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[PATCH 07/10] drm/gma500: use drm_crtc_vblank_{on,off}()

2016-06-07 Thread Patrik Jakobsson
On Tue, Jun 7, 2016 at 4:07 PM, Gustavo Padovan  wrote:
> From: Gustavo Padovan 
>
> Replace the legacy drm_vblank_{on,off}() with the new helper functions.
>
> Signed-off-by: Gustavo Padovan 

Acked-by: Patrik Jakobsson 

> ---
>  drivers/gpu/drm/gma500/gma_display.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/gma500/gma_display.c 
> b/drivers/gpu/drm/gma500/gma_display.c
> index c95406e..e3d9e35 100644
> --- a/drivers/gpu/drm/gma500/gma_display.c
> +++ b/drivers/gpu/drm/gma500/gma_display.c
> @@ -281,7 +281,7 @@ void gma_crtc_dpms(struct drm_crtc *crtc, int mode)
> REG_WRITE(VGACNTRL, VGA_DISP_DISABLE);
>
> /* Turn off vblank interrupts */
> -   drm_vblank_off(dev, pipe);
> +   drm_crtc_vblank_off(crtc);
>
> /* Wait for vblank for the disable to take effect */
> gma_wait_for_vblank(dev);
> --
> 2.5.5
>


[PATCH 1/4] drm/amdgpu: clear RB at ring init

2016-06-07 Thread Michel Dänzer
On 02.06.2016 07:27, Alex Deucher wrote:
> From: Monk Liu 
> 
> This help fix reloading driver hang issue of SDMA
> ring.
> 
> Signed-off-by: Monk Liu 
> Reviewed-by: Alex Deucher 
> Reviewed-by: Christian König 
> Signed-off-by: Alex Deucher 
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
> index 3b02272..a4b3f44 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
> @@ -310,6 +310,9 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct 
> amdgpu_ring *ring,
>   }
>   r = amdgpu_bo_kmap(ring->ring_obj,
>  (void **)&ring->ring);
> +
> + memset((void *)ring->ring, 0, ring->ring_size);
> +
>   amdgpu_bo_unreserve(ring->ring_obj);
>   if (r) {
>   dev_err(adev->dev, "(%d) ring map failed\n", r);
> 

We should only call memset if amdgpu_bo_kmap succeeded. Same issue in
patch 2.


There's something else about these two patches I'm a bit worried about:

The GPU should only read data from ring buffers and IBs that we
previously explicitly wrote there. I'm afraid these patches might just
paper over bugs elsewhere, which might still bite us under different
circumstances.


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast | Mesa and X developer


[PATCH 0/4] Centralize format information

2016-06-07 Thread Laurent Pinchart
Hi Daniel,

On Tuesday 07 Jun 2016 15:27:09 Daniel Vetter wrote:
> On Tue, Jun 07, 2016 at 02:33:10AM +0300, Laurent Pinchart wrote:
> > Hello,
> > 
> > Various pieces of information about DRM formats (number of planes, color
> > depth, chroma subsampling, ...) are scattered across different helper
> > functions in the DRM core. Callers of those functions often need to access
> > more than a single parameter of the format, leading to inefficiencies due
> > to multiple lookups.
> > 
> > This patch series addresses this issue by centralizing all format
> > information in a single data structure (1/4). It reimplements the
> > existing format helper functions based on that structure (3/4) and
> > converts the DRM core code to use the new structure (4/4). Two unused
> > format helper functions are removed in the process (2/4).
> > 
> > The new API is also useful for drivers. I will shortly post a patch series
> > for the omapdrm driver that makes use of it.
> 
> I'm still meh on this, but you could convince me if you'd extract all the
> format related stuff into drm_fourcc.c. drm_crtc is a mess, and the abi
> docs are confusing since everything is in one bag. Splitting parts out
> would be awesome.

I think we're on the same page, I had the exact same thought today. I'll work 
on that.

> Other stuff I think we could split out is all the framebuffer handling,
> basic property stuff, specialized properties (for zorder, blending,
> whatever) and maybe even a few more sub-topics. But let's start somewhere.

Deal, I'll start here :-)

-- 
Regards,

Laurent Pinchart



[PATCH v2 2/3] drm: convert DT component matching to component_match_add_release()

2016-06-07 Thread Vincent ABRIOU


On 06/03/2016 04:21 PM, Russell King wrote:
> Convert DT component matching to use component_match_add_release().
>
> Signed-off-by: Russell King 
> ---
>   drivers/gpu/drm/arm/hdlcd_drv.c |  9 +++--
>   drivers/gpu/drm/armada/armada_drv.c |  8 ++--
>   drivers/gpu/drm/drm_of.c|  6 --
>   drivers/gpu/drm/etnaviv/etnaviv_drv.c   | 11 ++-
>   drivers/gpu/drm/msm/msm_drv.c   |  8 ++--
>   drivers/gpu/drm/msm/msm_drv.h   |  1 +
>   drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 12 +++-
>   drivers/gpu/drm/sti/sti_drv.c   |  9 ++---
>   drivers/gpu/drm/tilcdc/tilcdc_external.c|  8 ++--
>   9 files changed, 21 insertions(+), 51 deletions(-)
>
>
> diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> index 872495e72294..aeb2787c9bd4 100644
> --- a/drivers/gpu/drm/sti/sti_drv.c
> +++ b/drivers/gpu/drm/sti/sti_drv.c
> @@ -10,6 +10,7 @@
>   #include 
>   #include 
>   #include 
> +#include 
>   #include 
>
>   #include 
> @@ -341,11 +342,6 @@ static struct drm_driver sti_driver = {
>   .minor = DRIVER_MINOR,
>   };
>
> -static int compare_of(struct device *dev, void *data)
> -{
> - return dev->of_node == data;
> -}
> -
>   static int sti_bind(struct device *dev)
>   {
>   return drm_platform_init(&sti_driver, to_platform_device(dev));
> @@ -375,8 +371,7 @@ static int sti_platform_probe(struct platform_device 
> *pdev)
>   child_np = of_get_next_available_child(node, NULL);
>
>   while (child_np) {
> - component_match_add(dev, &match, compare_of, child_np);
> - of_node_put(child_np);
> + component_match_add_of(dev, &match, child_np);
>   child_np = of_get_next_available_child(node, child_np);
>   }
>

Hi Russel,

Ok for the sti driver.

Acked-by: Vincent Abriou 


[PATCH 1/4] drm: Centralize format information

2016-06-07 Thread Laurent Pinchart
Hi Ville,

On Tuesday 07 Jun 2016 16:20:17 Ville Syrjälä wrote:
> On Tue, Jun 07, 2016 at 02:33:11AM +0300, Laurent Pinchart wrote:
> > Various pieces of information about DRM formats (number of planes, color
> > depth, chroma subsampling, ...) are scattered across different helper
> > functions in the DRM core. Callers of those functions often need to
> > access more than a single parameter of the format, leading to
> > inefficiencies due to multiple lookups.
> > 
> > Centralize all format information in a data structure and create a
> > function to look up information based on the format 4CC.
> > 
> > Signed-off-by: Laurent Pinchart 
> > ---
> > 
> >  drivers/gpu/drm/drm_crtc.c | 83 +
> >  include/drm/drm_crtc.h | 21 
> >  2 files changed, 104 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> > index 0e3cc66aa8b7..74b0c6dd80cd 100644
> > --- a/drivers/gpu/drm/drm_crtc.c
> > +++ b/drivers/gpu/drm/drm_crtc.c
> > @@ -5544,6 +5544,89 @@ int drm_mode_destroy_dumb_ioctl(struct drm_device
> > *dev,> 
> >  }
> >  
> >  /**
> > 
> > + * drm_format_info - information for a given format
> > + * @format: pixel format (DRM_FORMAT_*)
> > + *
> > + * Returns:
> > + * The instance of struct drm_format_info that describes the pixel
> > format, or + * NULL if the format is unsupported.
> > + */
> > +const struct drm_format_info *drm_format_info(u32 format)
> > +{
> > +   static const struct drm_format_info formats[] = {
> > +   { DRM_FORMAT_C8, 8, 8, 1, { 1 }, 1, 1 },
> 
> Named initializers please.

Do we really want to expand every entry to 7 lines ? I can do so, but it won't 
look pretty.

> > +   { DRM_FORMAT_RGB332, 8, 8, 1, { 1 }, 1, 1 },
> > +   { DRM_FORMAT_BGR233, 8, 8, 1, { 1 }, 1, 1 },
> > +   { DRM_FORMAT_XRGB, 12, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_XBGR, 12, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_RGBX, 12, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_BGRX, 12, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_ARGB, 12, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_ABGR, 12, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_RGBA, 12, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_BGRA, 12, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_XRGB1555, 15, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_XBGR1555, 15, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_RGBX5551, 15, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_BGRX5551, 15, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_ARGB1555, 15, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_ABGR1555, 15, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_RGBA5551, 15, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_BGRA5551, 15, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_RGB565, 16, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_BGR565, 16, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_RGB888, 24, 24, 1, { 3 }, 1, 1 },
> > +   { DRM_FORMAT_BGR888, 24, 24, 1, { 3 }, 1, 1 },
> > +   { DRM_FORMAT_XRGB, 24, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_XBGR, 24, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_RGBX, 24, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_BGRX, 24, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_XRGB2101010, 30, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_XBGR2101010, 30, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_RGBX1010102, 30, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_BGRX1010102, 30, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_ARGB2101010, 30, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_ABGR2101010, 30, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_RGBA1010102, 30, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_BGRA1010102, 30, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_ARGB, 32, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_ABGR, 32, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_RGBA, 32, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_BGRA, 32, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_YUV410, 0, 0, 3, { 1, 1, 1 }, 4, 4 },
> > +   { DRM_FORMAT_YVU410, 0, 0, 3, { 1, 1, 1 }, 4, 4 },
> > +   { DRM_FORMAT_YUV411, 0, 0, 3, { 1, 1, 1 }, 4, 1 },
> > +   { DRM_FORMAT_YVU411, 0, 0, 3, { 1, 1, 1 }, 4, 1 },
> > +   { DRM_FORMAT_YUV420, 0, 0, 3, { 1, 1, 1 }, 2, 2 },
> > +   { DRM_FORMAT_YVU420, 0, 0, 3, { 1, 1, 1 }, 2, 2 },
> > +   { DRM_FORMAT_YUV422, 0, 0, 3, { 1, 1, 1 }, 2, 1 },
> > +   { DRM_FORMAT_YVU422, 0, 0, 3, { 1, 1, 1 }, 2, 1 },
> > +   { DRM_FORMAT_YUV444, 0, 0, 3, { 1, 1, 1 }, 1, 1 },
> > +   { DRM_FORMAT_YVU444, 0, 0, 3, { 1, 1, 1 }, 1, 1 },
> > +   { DRM_FORMAT_NV12, 0, 0, 2, { 1, 2 }, 2, 2 },
> > +   { DRM_FORMAT_NV21, 0, 0, 2, { 1, 2 }, 2, 2 },
> > +

[PATCH 2/4] drm: Remove unused drm_format_plane_(width|height) helpers

2016-06-07 Thread Laurent Pinchart
Hi Ville,

On Tuesday 07 Jun 2016 16:19:01 Ville Syrjälä wrote:
> On Tue, Jun 07, 2016 at 02:33:12AM +0300, Laurent Pinchart wrote:
> > The drm_format_plane_width() and drm_format_plane_height() helper
> > functions are not used, remove them.
> 
> I have a user lined up, assuming I could get the dang thing reviewed.

OK, I'll keep the functions and convert them to use drm_format_info(). If your 
user needs to call more than one format helper then I'd suggest using 
drm_format_info() directly and perform the width/height computation yourself, 
it will be more efficient.

> > Signed-off-by: Laurent Pinchart 
> > ---
> > 
> >  drivers/gpu/drm/drm_crtc.c | 42 
> >  include/drm/drm_crtc.h |  2 --
> >  2 files changed, 44 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> > index 74b0c6dd80cd..b405d4379e47 100644
> > --- a/drivers/gpu/drm/drm_crtc.c
> > +++ b/drivers/gpu/drm/drm_crtc.c
> > @@ -5843,48 +5843,6 @@ int drm_format_vert_chroma_subsampling(uint32_t
> > format)> 
> >  EXPORT_SYMBOL(drm_format_vert_chroma_subsampling);
> >  
> >  /**
> > 
> > - * drm_format_plane_width - width of the plane given the first plane
> > - * @width: width of the first plane
> > - * @format: pixel format
> > - * @plane: plane index
> > - *
> > - * Returns:
> > - * The width of @plane, given that the width of the first plane is
> > @width.
> > - */
> > -int drm_format_plane_width(int width, uint32_t format, int plane)
> > -{
> > -   if (plane >= drm_format_num_planes(format))
> > -   return 0;
> > -
> > -   if (plane == 0)
> > -   return width;
> > -
> > -   return width / drm_format_horz_chroma_subsampling(format);
> > -}
> > -EXPORT_SYMBOL(drm_format_plane_width);
> > -
> > -/**
> > - * drm_format_plane_height - height of the plane given the first plane
> > - * @height: height of the first plane
> > - * @format: pixel format
> > - * @plane: plane index
> > - *
> > - * Returns:
> > - * The height of @plane, given that the height of the first plane is
> > @height. - */
> > -int drm_format_plane_height(int height, uint32_t format, int plane)
> > -{
> > -   if (plane >= drm_format_num_planes(format))
> > -   return 0;
> > -
> > -   if (plane == 0)
> > -   return height;
> > -
> > -   return height / drm_format_vert_chroma_subsampling(format);
> > -}
> > -EXPORT_SYMBOL(drm_format_plane_height);
> > -
> > -/**
> > 
> >   * drm_rotation_simplify() - Try to simplify the rotation
> >   * @rotation: Rotation to be simplified
> >   * @supported_rotations: Supported rotations
> > 
> > diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> > index 4199794cc317..a45f57f32dca 100644
> > --- a/include/drm/drm_crtc.h
> > +++ b/include/drm/drm_crtc.h
> > @@ -2567,8 +2567,6 @@ extern int drm_format_num_planes(uint32_t format);
> > 
> >  extern int drm_format_plane_cpp(uint32_t format, int plane);
> >  extern int drm_format_horz_chroma_subsampling(uint32_t format);
> >  extern int drm_format_vert_chroma_subsampling(uint32_t format);
> > 
> > -extern int drm_format_plane_width(int width, uint32_t format, int plane);
> > -extern int drm_format_plane_height(int height, uint32_t format, int
> > plane);> 
> >  extern const char *drm_get_format_name(uint32_t format);
> >  extern struct drm_property *drm_mode_create_rotation_property(struct
> >  drm_device *dev,>  
> >   unsigned int 
> > supported_rotations);

-- 
Regards,

Laurent Pinchart



[Bug 95528] BioShock Infinite graphical glitches on radeonsi

2016-06-07 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=95528

Vedran Miletić  changed:

   What|Removed |Added

Summary|BioShock Infinite issues on |BioShock Infinite graphical
   |Tonga/Hawaii|glitches on radeonsi
 CC||vedran at miletic.net

--- Comment #11 from Vedran Miletić  ---
I updated the bug summary. Thanks for providing the info.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160607/2a694157/attachment-0001.html>


[PATCH 1/4] drm: Centralize format information

2016-06-07 Thread Ville Syrjälä
On Tue, Jun 07, 2016 at 02:33:11AM +0300, Laurent Pinchart wrote:
> Various pieces of information about DRM formats (number of planes, color
> depth, chroma subsampling, ...) are scattered across different helper
> functions in the DRM core. Callers of those functions often need to
> access more than a single parameter of the format, leading to
> inefficiencies due to multiple lookups.
> 
> Centralize all format information in a data structure and create a
> function to look up information based on the format 4CC.
> 
> Signed-off-by: Laurent Pinchart 
> ---
>  drivers/gpu/drm/drm_crtc.c | 83 
> ++
>  include/drm/drm_crtc.h | 21 
>  2 files changed, 104 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 0e3cc66aa8b7..74b0c6dd80cd 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -5544,6 +5544,89 @@ int drm_mode_destroy_dumb_ioctl(struct drm_device *dev,
>  }
>  
>  /**
> + * drm_format_info - information for a given format
> + * @format: pixel format (DRM_FORMAT_*)
> + *
> + * Returns:
> + * The instance of struct drm_format_info that describes the pixel format, or
> + * NULL if the format is unsupported.
> + */
> +const struct drm_format_info *drm_format_info(u32 format)
> +{
> + static const struct drm_format_info formats[] = {
> + { DRM_FORMAT_C8, 8, 8, 1, { 1 }, 1, 1 },

Named initializers please.

> + { DRM_FORMAT_RGB332, 8, 8, 1, { 1 }, 1, 1 },
> + { DRM_FORMAT_BGR233, 8, 8, 1, { 1 }, 1, 1 },
> + { DRM_FORMAT_XRGB, 12, 16, 1, { 2 }, 1, 1 },
> + { DRM_FORMAT_XBGR, 12, 16, 1, { 2 }, 1, 1 },
> + { DRM_FORMAT_RGBX, 12, 16, 1, { 2 }, 1, 1 },
> + { DRM_FORMAT_BGRX, 12, 16, 1, { 2 }, 1, 1 },
> + { DRM_FORMAT_ARGB, 12, 16, 1, { 2 }, 1, 1 },
> + { DRM_FORMAT_ABGR, 12, 16, 1, { 2 }, 1, 1 },
> + { DRM_FORMAT_RGBA, 12, 16, 1, { 2 }, 1, 1 },
> + { DRM_FORMAT_BGRA, 12, 16, 1, { 2 }, 1, 1 },
> + { DRM_FORMAT_XRGB1555, 15, 16, 1, { 2 }, 1, 1 },
> + { DRM_FORMAT_XBGR1555, 15, 16, 1, { 2 }, 1, 1 },
> + { DRM_FORMAT_RGBX5551, 15, 16, 1, { 2 }, 1, 1 },
> + { DRM_FORMAT_BGRX5551, 15, 16, 1, { 2 }, 1, 1 },
> + { DRM_FORMAT_ARGB1555, 15, 16, 1, { 2 }, 1, 1 },
> + { DRM_FORMAT_ABGR1555, 15, 16, 1, { 2 }, 1, 1 },
> + { DRM_FORMAT_RGBA5551, 15, 16, 1, { 2 }, 1, 1 },
> + { DRM_FORMAT_BGRA5551, 15, 16, 1, { 2 }, 1, 1 },
> + { DRM_FORMAT_RGB565, 16, 16, 1, { 2 }, 1, 1 },
> + { DRM_FORMAT_BGR565, 16, 16, 1, { 2 }, 1, 1 },
> + { DRM_FORMAT_RGB888, 24, 24, 1, { 3 }, 1, 1 },
> + { DRM_FORMAT_BGR888, 24, 24, 1, { 3 }, 1, 1 },
> + { DRM_FORMAT_XRGB, 24, 32, 1, { 4 }, 1, 1 },
> + { DRM_FORMAT_XBGR, 24, 32, 1, { 4 }, 1, 1 },
> + { DRM_FORMAT_RGBX, 24, 32, 1, { 4 }, 1, 1 },
> + { DRM_FORMAT_BGRX, 24, 32, 1, { 4 }, 1, 1 },
> + { DRM_FORMAT_XRGB2101010, 30, 32, 1, { 4 }, 1, 1 },
> + { DRM_FORMAT_XBGR2101010, 30, 32, 1, { 4 }, 1, 1 },
> + { DRM_FORMAT_RGBX1010102, 30, 32, 1, { 4 }, 1, 1 },
> + { DRM_FORMAT_BGRX1010102, 30, 32, 1, { 4 }, 1, 1 },
> + { DRM_FORMAT_ARGB2101010, 30, 32, 1, { 4 }, 1, 1 },
> + { DRM_FORMAT_ABGR2101010, 30, 32, 1, { 4 }, 1, 1 },
> + { DRM_FORMAT_RGBA1010102, 30, 32, 1, { 4 }, 1, 1 },
> + { DRM_FORMAT_BGRA1010102, 30, 32, 1, { 4 }, 1, 1 },
> + { DRM_FORMAT_ARGB, 32, 32, 1, { 4 }, 1, 1 },
> + { DRM_FORMAT_ABGR, 32, 32, 1, { 4 }, 1, 1 },
> + { DRM_FORMAT_RGBA, 32, 32, 1, { 4 }, 1, 1 },
> + { DRM_FORMAT_BGRA, 32, 32, 1, { 4 }, 1, 1 },
> + { DRM_FORMAT_YUV410, 0, 0, 3, { 1, 1, 1 }, 4, 4 },
> + { DRM_FORMAT_YVU410, 0, 0, 3, { 1, 1, 1 }, 4, 4 },
> + { DRM_FORMAT_YUV411, 0, 0, 3, { 1, 1, 1 }, 4, 1 },
> + { DRM_FORMAT_YVU411, 0, 0, 3, { 1, 1, 1 }, 4, 1 },
> + { DRM_FORMAT_YUV420, 0, 0, 3, { 1, 1, 1 }, 2, 2 },
> + { DRM_FORMAT_YVU420, 0, 0, 3, { 1, 1, 1 }, 2, 2 },
> + { DRM_FORMAT_YUV422, 0, 0, 3, { 1, 1, 1 }, 2, 1 },
> + { DRM_FORMAT_YVU422, 0, 0, 3, { 1, 1, 1 }, 2, 1 },
> + { DRM_FORMAT_YUV444, 0, 0, 3, { 1, 1, 1 }, 1, 1 },
> + { DRM_FORMAT_YVU444, 0, 0, 3, { 1, 1, 1 }, 1, 1 },
> + { DRM_FORMAT_NV12, 0, 0, 2, { 1, 2 }, 2, 2 },
> + { DRM_FORMAT_NV21, 0, 0, 2, { 1, 2 }, 2, 2 },
> + { DRM_FORMAT_NV16, 0, 0, 2, { 1, 2 }, 2, 1 },
> + { DRM_FORMAT_NV61, 0, 0, 2, { 1, 2 }, 2, 1 },
> + { DRM_FORMAT_NV24, 0, 0, 2, { 1, 2 }, 1, 1 },
> + { DRM_FORMAT_NV42, 0, 0, 2, { 1, 2 }, 1, 1 },
> +

[PATCH 2/4] drm: Remove unused drm_format_plane_(width|height) helpers

2016-06-07 Thread Ville Syrjälä
On Tue, Jun 07, 2016 at 02:33:12AM +0300, Laurent Pinchart wrote:
> The drm_format_plane_width() and drm_format_plane_height() helper
> functions are not used, remove them.

I have a user lined up, assuming I could get the dang thing reviewed.

> 
> Signed-off-by: Laurent Pinchart 
> ---
>  drivers/gpu/drm/drm_crtc.c | 42 --
>  include/drm/drm_crtc.h |  2 --
>  2 files changed, 44 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 74b0c6dd80cd..b405d4379e47 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -5843,48 +5843,6 @@ int drm_format_vert_chroma_subsampling(uint32_t format)
>  EXPORT_SYMBOL(drm_format_vert_chroma_subsampling);
>  
>  /**
> - * drm_format_plane_width - width of the plane given the first plane
> - * @width: width of the first plane
> - * @format: pixel format
> - * @plane: plane index
> - *
> - * Returns:
> - * The width of @plane, given that the width of the first plane is @width.
> - */
> -int drm_format_plane_width(int width, uint32_t format, int plane)
> -{
> - if (plane >= drm_format_num_planes(format))
> - return 0;
> -
> - if (plane == 0)
> - return width;
> -
> - return width / drm_format_horz_chroma_subsampling(format);
> -}
> -EXPORT_SYMBOL(drm_format_plane_width);
> -
> -/**
> - * drm_format_plane_height - height of the plane given the first plane
> - * @height: height of the first plane
> - * @format: pixel format
> - * @plane: plane index
> - *
> - * Returns:
> - * The height of @plane, given that the height of the first plane is @height.
> - */
> -int drm_format_plane_height(int height, uint32_t format, int plane)
> -{
> - if (plane >= drm_format_num_planes(format))
> - return 0;
> -
> - if (plane == 0)
> - return height;
> -
> - return height / drm_format_vert_chroma_subsampling(format);
> -}
> -EXPORT_SYMBOL(drm_format_plane_height);
> -
> -/**
>   * drm_rotation_simplify() - Try to simplify the rotation
>   * @rotation: Rotation to be simplified
>   * @supported_rotations: Supported rotations
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index 4199794cc317..a45f57f32dca 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -2567,8 +2567,6 @@ extern int drm_format_num_planes(uint32_t format);
>  extern int drm_format_plane_cpp(uint32_t format, int plane);
>  extern int drm_format_horz_chroma_subsampling(uint32_t format);
>  extern int drm_format_vert_chroma_subsampling(uint32_t format);
> -extern int drm_format_plane_width(int width, uint32_t format, int plane);
> -extern int drm_format_plane_height(int height, uint32_t format, int plane);
>  extern const char *drm_get_format_name(uint32_t format);
>  extern struct drm_property *drm_mode_create_rotation_property(struct 
> drm_device *dev,
> unsigned int 
> supported_rotations);
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Ville Syrjälä
Intel OTC


[PATCH] drm/fb_cma_helper: Implement fb_mmap callback

2016-06-07 Thread Robin Murphy
On 07/06/16 15:43, Daniel Vetter wrote:
> On Tue, Jun 07, 2016 at 01:18:09PM +0100, Robin Murphy wrote:
>> In the absence of an fb_mmap callback, the fbdev code falls back to a
>> naive implementation which relies upon the DMA address being the same
>> as the physical address, and the buffer being physically contiguous
>> from there. Whilst this often holds for standard CMA allocations via
>> the platform's regular DMA ops, if the allocation is provided by an
>> IOMMU then such assumptions can fall apart spectacularly.
>>
>> To resolve this, reroute the fb_mmap call to the appropriate DMA API
>> implementation, as per the other cma_helper calls.
>>
>> Acked-by: Daniel Vetter 
>> Signed-off-by: Robin Murphy 
>> ---
>>
>> Resending rebased to 4.7-rc1 with Daniel's ack. I know Russell raised
>> some concerns about the general way fb_cma_helper uses fb_info[1], but
>> AFAICS that's a longstanding separate problem orthogonal to this patch.
>
> Do you want me to pull this in through drm-misc, or will this land through
> some driver tree? Note that I'll do -misc pulls about every week, so if
> you don't send your pull this week I'd like to pull it in to avoid
> hilarity^W needless conflicts.

Yeah, drm-misc sounds appropriate so if you're happy to pick it up, 
please feel free :)

Robin.

> -Daniel
>
>>
>> Robin.
>>
>> [1]:http://thread.gmane.org/gmane.comp.video.dri.devel/149288
>>
>>   drivers/gpu/drm/drm_fb_cma_helper.c | 8 
>>   1 file changed, 8 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c 
>> b/drivers/gpu/drm/drm_fb_cma_helper.c
>> index 172cafe11c71..a25afc068d3f 100644
>> --- a/drivers/gpu/drm/drm_fb_cma_helper.c
>> +++ b/drivers/gpu/drm/drm_fb_cma_helper.c
>> @@ -23,6 +23,7 @@
>>   #include 
>>   #include 
>>   #include 
>> +#include 
>>   #include 
>>
>>   #define DEFAULT_FBDEFIO_DELAY_MS 50
>> @@ -297,6 +298,12 @@ int drm_fb_cma_debugfs_show(struct seq_file *m, void 
>> *arg)
>>   EXPORT_SYMBOL_GPL(drm_fb_cma_debugfs_show);
>>   #endif
>>
>> +static int drm_fb_cma_mmap(struct fb_info *info, struct vm_area_struct *vma)
>> +{
>> +return dma_mmap_writecombine(info->device, vma, info->screen_base,
>> + info->fix.smem_start, info->fix.smem_len);
>> +}
>> +
>>   static struct fb_ops drm_fbdev_cma_ops = {
>>  .owner  = THIS_MODULE,
>>  .fb_fillrect= drm_fb_helper_sys_fillrect,
>> @@ -307,6 +314,7 @@ static struct fb_ops drm_fbdev_cma_ops = {
>>  .fb_blank   = drm_fb_helper_blank,
>>  .fb_pan_display = drm_fb_helper_pan_display,
>>  .fb_setcmap = drm_fb_helper_setcmap,
>> +.fb_mmap= drm_fb_cma_mmap,
>>   };
>>
>>   static int drm_fbdev_cma_deferred_io_mmap(struct fb_info *info,
>> --
>> 2.8.1.dirty
>>
>



[PATCH] drm/fb_cma_helper: Implement fb_mmap callback

2016-06-07 Thread liviu.du...@arm.com
On Tue, Jun 07, 2016 at 04:43:05PM +0200, Daniel Vetter wrote:
> On Tue, Jun 07, 2016 at 01:18:09PM +0100, Robin Murphy wrote:
> > In the absence of an fb_mmap callback, the fbdev code falls back to a
> > naive implementation which relies upon the DMA address being the same
> > as the physical address, and the buffer being physically contiguous
> > from there. Whilst this often holds for standard CMA allocations via
> > the platform's regular DMA ops, if the allocation is provided by an
> > IOMMU then such assumptions can fall apart spectacularly.
> > 
> > To resolve this, reroute the fb_mmap call to the appropriate DMA API
> > implementation, as per the other cma_helper calls.
> > 
> > Acked-by: Daniel Vetter 
> > Signed-off-by: Robin Murphy 
> > ---
> > 
> > Resending rebased to 4.7-rc1 with Daniel's ack. I know Russell raised
> > some concerns about the general way fb_cma_helper uses fb_info[1], but
> > AFAICS that's a longstanding separate problem orthogonal to this patch.
> 
> Do you want me to pull this in through drm-misc, or will this land through
> some driver tree? Note that I'll do -misc pulls about every week, so if
> you don't send your pull this week I'd like to pull it in to avoid
> hilarity^W needless conflicts.
> -Daniel

Hi Daniel,

This patch is for drm core, so no driver can carry it (?).

Please pull it into your drm-misc.

Best regards,
Liviu

> 
> > 
> > Robin.
> > 
> > [1]:http://thread.gmane.org/gmane.comp.video.dri.devel/149288
> > 
> >  drivers/gpu/drm/drm_fb_cma_helper.c | 8 
> >  1 file changed, 8 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c 
> > b/drivers/gpu/drm/drm_fb_cma_helper.c
> > index 172cafe11c71..a25afc068d3f 100644
> > --- a/drivers/gpu/drm/drm_fb_cma_helper.c
> > +++ b/drivers/gpu/drm/drm_fb_cma_helper.c
> > @@ -23,6 +23,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  
> >  #define DEFAULT_FBDEFIO_DELAY_MS 50
> > @@ -297,6 +298,12 @@ int drm_fb_cma_debugfs_show(struct seq_file *m, void 
> > *arg)
> >  EXPORT_SYMBOL_GPL(drm_fb_cma_debugfs_show);
> >  #endif
> >  
> > +static int drm_fb_cma_mmap(struct fb_info *info, struct vm_area_struct 
> > *vma)
> > +{
> > +   return dma_mmap_writecombine(info->device, vma, info->screen_base,
> > +info->fix.smem_start, info->fix.smem_len);
> > +}
> > +
> >  static struct fb_ops drm_fbdev_cma_ops = {
> > .owner  = THIS_MODULE,
> > .fb_fillrect= drm_fb_helper_sys_fillrect,
> > @@ -307,6 +314,7 @@ static struct fb_ops drm_fbdev_cma_ops = {
> > .fb_blank   = drm_fb_helper_blank,
> > .fb_pan_display = drm_fb_helper_pan_display,
> > .fb_setcmap = drm_fb_helper_setcmap,
> > +   .fb_mmap= drm_fb_cma_mmap,
> >  };
> >  
> >  static int drm_fbdev_cma_deferred_io_mmap(struct fb_info *info,
> > -- 
> > 2.8.1.dirty
> > 
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
> 

-- 

| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---
¯\_(ツ)_/¯


HDLCD crashes with 6d910bfa809e

2016-06-07 Thread liviu.du...@arm.com
On Tue, Jun 07, 2016 at 03:11:14PM +0100, Robin Murphy wrote:
> Hi Liviu,
> 
> On 07/06/16 14:35, liviu.dudau at arm.com wrote:
> >On Tue, Jun 07, 2016 at 01:06:00PM +0100, Robin Murphy wrote:
> >>Having just inadvertently merged -next into my working branch, I find
> >>dev6d910bfa809e ("drm/hlcd: Use lockless gem BO free callback") adversely
> >>affecting my board's ability to boot ;)
> >>
> >>Since I (intentionally) don't have sufficient CMA to create a framebuffer,
> >>drm_gem_cma_create() fails, unconditionally calls the now-NULL
> >>drm->driver->gem_free_object() in its cleanup path, and fiery death
> >>ensues...
> >
> >Thanks for reporting this. What other changes other than reducing the CMA
> >allocation size do you have that I might need in order to reproduce this?
> 
> I've just confirmed a plain checkout of next-20160602, using arm64 defconfig
> + DRM + HDLCD + TDA998X and CMA_SIZE_MBYTES=1, booted on a Juno, does the
> job:
> 
> [3.032402] hdlcd 7ff6.hdlcd: bound 0-0070 (ops tda998x_ops)
> [3.038388] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
> [3.044970] [drm] No driver support for vblank timestamp query.
> [3.076973] hdlcd 7ff6.hdlcd: failed to allocate buffer with size
> 768
> [3.084081] Bad mode in Synchronous Abort handler detected, code
> 0x8604 -- IABT (current EL)
> [3.092815] CPU: 3 PID: 6 Comm: kworker/u12:0 Not tainted
> 4.7.0-rc1-next-20160602 #686
> [3.100682] Hardware name: ARM Juno development board (r1) (DT)
> [3.106567] Workqueue: deferwq deferred_probe_work_func
> [3.111761] task: 8009768a3e80 ti: 8009768e8000 task.ti:
> 8009768e8000
> [3.119198] PC is at 0x0
> [3.121720] LR is at drm_gem_cma_create+0x128/0x130
> ...and so on.
> 
> Today's -next, on the other hand, dodges the bullet entirely:
> 
> [2.903645] [drm] found ARM HDLCD version r0p0
> [2.908122] hdlcd 7ff6.hdlcd: master bind failed: -22
> [2.913505] tda998x: probe of 0-0070 failed with error -22
> [2.919141] [drm] found ARM HDLCD version r0p0
> [2.923609] hdlcd 7ff5.hdlcd: master bind failed: -22
> [2.928991] tda998x: probe of 0-0071 failed with error -22

OK, the problem is that commit 59ce4039727ef40 has changed the behaviour from 
when
there is no "memory-region" phandle in the DT: before it used to return 
-ENODEV, now
it returns -EINVAL.

Marek, I quite liked the old behaviour to detect if the DT had the optional 
(from
my driver's point of view) "memory-region" phandle. Plus the check for dev is 
superfluous
when using of_reserved_mem_device_init() as that uses dev->of_node for np so it 
would
crash before the check anyway. Maybe move the check there?

Until then I suggest reverting the 59ce4039727ef40 commit.

Best regards,
Liviu

> 
> Oh well...
> 
> Robin.
> 

-- 

| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---
¯\_(ツ)_/¯


[PATCH] tree-wide: replace config_enabled() with IS_ENABLED()

2016-06-07 Thread Andrew Morton
On Mon,  6 Jun 2016 21:20:56 +0900 Masahiro Yamada  wrote:

> The use of config_enabled() against config options is ambiguous.
> In practical terms, config_enabled() is equivalent to IS_BUILTIN(),
> but the author might have used it for the meaning of IS_ENABLED().
> Using IS_ENABLED(), IS_BUILTIN(), IS_MODULE() etc. makes the
> intention clearer.
> 
> This commit replaces config_enabled() with IS_ENABLED() where
> possible.  This commit is only touching bool config options.
> 
> I noticed two cases where config_enabled() is used against a tristate
> option:
> 
>  - config_enabled(CONFIG_HWMON)
>   [ drivers/net/wireless/ath/ath10k/thermal.c ]
> 
>  - config_enabled(CONFIG_BACKLIGHT_CLASS_DEVICE)
>   [ drivers/gpu/drm/gma500/opregion.c ]
> 
> I did not touch them because they should be converted to IS_BUILTIN()
> in order to keep the logic, but I was not sure it was the authors'
> intention.

Well, we do want to be able to remove config_enabled() altogether if
we're going to do this.  So please later send along a patch which makes
a best-effort fix of the unclear usages and let's zap the thing.

If those fixes weren't quite correct then there will be a build error
(drivers/net/wireless/ath/ath10k/thermal.c) or no change in behaviour
(drivers/gpu/drm/gma500/opregion.c).



[PATCH 0/4] Centralize format information

2016-06-07 Thread Daniel Vetter
On Tue, Jun 07, 2016 at 02:33:10AM +0300, Laurent Pinchart wrote:
> Hello,
> 
> Various pieces of information about DRM formats (number of planes, color
> depth, chroma subsampling, ...) are scattered across different helper
> functions in the DRM core. Callers of those functions often need to access
> more than a single parameter of the format, leading to inefficiencies due to
> multiple lookups.
> 
> This patch series addresses this issue by centralizing all format information
> in a single data structure (1/4). It reimplements the existing format helper
> functions based on that structure (3/4) and converts the DRM core code to use
> the new structure (4/4). Two unused format helper functions are removed in the
> process (2/4).
> 
> The new API is also useful for drivers. I will shortly post a patch series for
> the omapdrm driver that makes use of it.

I'm still meh on this, but you could convince me if you'd extract all the
format related stuff into drm_fourcc.c. drm_crtc is a mess, and the abi
docs are confusing since everything is in one bag. Splitting parts out
would be awesome. Other stuff I think we could split out is all the
framebuffer handling, basic property stuff, specialized properties (for
zorder, blending, whatever) and maybe even a few more sub-topics. But
let's start somewhere.
-Daniel

> 
> Laurent Pinchart (4):
>   drm: Centralize format information
>   drm: Remove unused drm_format_plane_(width|height) helpers
>   drm: Implement the drm_format_*() helpers as drm_format_info()
> wrappers
>   drm: Use drm_format_info() in DRM core code
> 
>  drivers/gpu/drm/drm_crtc.c  | 391 
> +++-
>  drivers/gpu/drm/drm_fb_cma_helper.c |  23 ++-
>  include/drm/drm_crtc.h  |  23 ++-
>  3 files changed, 153 insertions(+), 284 deletions(-)
> 
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[PATCH v2] drm/core: Change declaration for gamma_set.

2016-06-07 Thread Sinclair Yeh
Acked-by: Sinclair Yeh 

On Tue, Jun 07, 2016 at 12:49:30PM +0200, Maarten Lankhorst wrote:
> Change return value to int to propagate errors from gamma_set,
> and remove start parameter. Updates always use the full size,
> and some drivers even ignore the start parameter altogether.
> 
> This is needed for atomic drivers, where an atomic commit can
> fail with -EINTR or -ENOMEM and should be restarted.
> 
> Changes since v1:
> - Fix compiler warning. (Emil)
> - Fix commit message (Daniel)
> 
> Cc: Alex Deucher 
> Acked-by: Alex Deucher 
> Cc: Christian König 
> Cc: David Airlie 
> Cc: Patrik Jakobsson 
> Cc: Ben Skeggs 
> Cc: Eric Anholt 
> Cc: VMware Graphics 
> Cc: Mathieu Larouche 
> Cc: Thierry Reding 
> Signed-off-by: Maarten Lankhorst 
> ---
>  drivers/gpu/drm/amd/amdgpu/dce_v10_0.c  | 10 ++
>  drivers/gpu/drm/amd/amdgpu/dce_v11_0.c  | 10 ++
>  drivers/gpu/drm/amd/amdgpu/dce_v8_0.c   | 10 ++
>  drivers/gpu/drm/ast/ast_mode.c  | 10 ++
>  drivers/gpu/drm/cirrus/cirrus_mode.c|  8 +---
>  drivers/gpu/drm/drm_atomic_helper.c | 13 ++---
>  drivers/gpu/drm/drm_crtc.c  |  2 +-
>  drivers/gpu/drm/drm_fb_helper.c |  2 +-
>  drivers/gpu/drm/gma500/gma_display.c|  9 +
>  drivers/gpu/drm/gma500/gma_display.h|  4 ++--
>  drivers/gpu/drm/mgag200/mgag200_mode.c  |  9 +
>  drivers/gpu/drm/nouveau/dispnv04/crtc.c | 12 +++-
>  drivers/gpu/drm/nouveau/nv50_display.c  |  9 +
>  drivers/gpu/drm/radeon/radeon_display.c | 11 +++
>  drivers/gpu/drm/vc4/vc4_crtc.c  |  8 +---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c |  8 +---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.h |  4 ++--
>  include/drm/drm_atomic_helper.h |  6 +++---
>  include/drm/drm_crtc.h  |  4 ++--
>  19 files changed, 85 insertions(+), 64 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c 
> b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
> index 7e57447bf5f4..112e358f0f9b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
> @@ -2667,19 +2667,21 @@ static void dce_v10_0_cursor_reset(struct drm_crtc 
> *crtc)
>   }
>  }
>  
> -static void dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
> *green,
> - u16 *blue, uint32_t start, uint32_t size)
> +static int dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
> *green,
> + u16 *blue, uint32_t size)
>  {
>   struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
> - int end = (start + size > 256) ? 256 : start + size, i;
> + int i;
>  
>   /* userspace palettes are always correct as is */
> - for (i = start; i < end; i++) {
> + for (i = 0; i < size; i++) {
>   amdgpu_crtc->lut_r[i] = red[i] >> 6;
>   amdgpu_crtc->lut_g[i] = green[i] >> 6;
>   amdgpu_crtc->lut_b[i] = blue[i] >> 6;
>   }
>   dce_v10_0_crtc_load_lut(crtc);
> +
> + return 0;
>  }
>  
>  static void dce_v10_0_crtc_destroy(struct drm_crtc *crtc)
> diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c 
> b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
> index da101551960b..b522fa2435a8 100644
> --- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
> @@ -2678,19 +2678,21 @@ static void dce_v11_0_cursor_reset(struct drm_crtc 
> *crtc)
>   }
>  }
>  
> -static void dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
> *green,
> - u16 *blue, uint32_t start, uint32_t size)
> +static int dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
> *green,
> + u16 *blue, uint32_t size)
>  {
>   struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
> - int end = (start + size > 256) ? 256 : start + size, i;
> + int i;
>  
>   /* userspace palettes are always correct as is */
> - for (i = start; i < end; i++) {
> + for (i = 0; i < size; i++) {
>   amdgpu_crtc->lut_r[i] = red[i] >> 6;
>   amdgpu_crtc->lut_g[i] = green[i] >> 6;
>   amdgpu_crtc->lut_b[i] = blue[i] >> 6;
>   }
>   dce_v11_0_crtc_load_lut(crtc);
> +
> + return 0;
>  }
>  
>  static void dce_v11_0_crtc_destroy(struct drm_crtc *crtc)
> diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c 
> b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
> index 41d9bc5f9c0e..b50ed72feedb 100644
> --- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
> @@ -2574,19 +2574,21 @@ static void dce_v8_0_cursor_reset(struct drm_crtc 
> *crtc)
>   }
>  }
>  
> -static void dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
> *green,
> - u16 *blue, uint32_t start, uint32_t size)
> +static int dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
> *green,
> +   

HDLCD crashes with 6d910bfa809e

2016-06-07 Thread liviu.du...@arm.com
On Tue, Jun 07, 2016 at 03:14:04PM +0100, liviu.dudau at arm.com wrote:
> On Tue, Jun 07, 2016 at 03:11:14PM +0100, Robin Murphy wrote:
> > Hi Liviu,
> > 
> > On 07/06/16 14:35, liviu.dudau at arm.com wrote:
> > >On Tue, Jun 07, 2016 at 01:06:00PM +0100, Robin Murphy wrote:
> > >>Having just inadvertently merged -next into my working branch, I find
> > >>dev6d910bfa809e ("drm/hlcd: Use lockless gem BO free callback") adversely
> > >>affecting my board's ability to boot ;)
> > >>
> > >>Since I (intentionally) don't have sufficient CMA to create a framebuffer,
> > >>drm_gem_cma_create() fails, unconditionally calls the now-NULL
> > >>drm->driver->gem_free_object() in its cleanup path, and fiery death
> > >>ensues...
> > >
> > >Thanks for reporting this. What other changes other than reducing the CMA
> > >allocation size do you have that I might need in order to reproduce this?
> > 
> > I've just confirmed a plain checkout of next-20160602, using arm64 defconfig
> > + DRM + HDLCD + TDA998X and CMA_SIZE_MBYTES=1, booted on a Juno, does the
> > job:
> > 
> > [3.032402] hdlcd 7ff6.hdlcd: bound 0-0070 (ops tda998x_ops)
> > [3.038388] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
> > [3.044970] [drm] No driver support for vblank timestamp query.
> > [3.076973] hdlcd 7ff6.hdlcd: failed to allocate buffer with size
> > 768
> > [3.084081] Bad mode in Synchronous Abort handler detected, code
> > 0x8604 -- IABT (current EL)
> > [3.092815] CPU: 3 PID: 6 Comm: kworker/u12:0 Not tainted
> > 4.7.0-rc1-next-20160602 #686
> > [3.100682] Hardware name: ARM Juno development board (r1) (DT)
> > [3.106567] Workqueue: deferwq deferred_probe_work_func
> > [3.111761] task: 8009768a3e80 ti: 8009768e8000 task.ti:
> > 8009768e8000
> > [3.119198] PC is at 0x0
> > [3.121720] LR is at drm_gem_cma_create+0x128/0x130
> > ...and so on.
> > 
> > Today's -next, on the other hand, dodges the bullet entirely:
> > 
> > [2.903645] [drm] found ARM HDLCD version r0p0
> > [2.908122] hdlcd 7ff6.hdlcd: master bind failed: -22
> > [2.913505] tda998x: probe of 0-0070 failed with error -22
> > [2.919141] [drm] found ARM HDLCD version r0p0
> > [2.923609] hdlcd 7ff5.hdlcd: master bind failed: -22
> > [2.928991] tda998x: probe of 0-0071 failed with error -22
> 
> Yes, if fails in of_reserved_mem_device_init(). Tracking now to see
> which of the conditions at line 311 are the culprits.

Bah, discard the line number, old cached version in my editor.

Liviu

> 
> Best regards,
> Liviu
> 
> > 
> > Oh well...
> > 
> > Robin.
> > 

-- 

| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---
¯\_(ツ)_/¯


HDLCD crashes with 6d910bfa809e

2016-06-07 Thread liviu.du...@arm.com
On Tue, Jun 07, 2016 at 03:11:14PM +0100, Robin Murphy wrote:
> Hi Liviu,
> 
> On 07/06/16 14:35, liviu.dudau at arm.com wrote:
> >On Tue, Jun 07, 2016 at 01:06:00PM +0100, Robin Murphy wrote:
> >>Having just inadvertently merged -next into my working branch, I find
> >>dev6d910bfa809e ("drm/hlcd: Use lockless gem BO free callback") adversely
> >>affecting my board's ability to boot ;)
> >>
> >>Since I (intentionally) don't have sufficient CMA to create a framebuffer,
> >>drm_gem_cma_create() fails, unconditionally calls the now-NULL
> >>drm->driver->gem_free_object() in its cleanup path, and fiery death
> >>ensues...
> >
> >Thanks for reporting this. What other changes other than reducing the CMA
> >allocation size do you have that I might need in order to reproduce this?
> 
> I've just confirmed a plain checkout of next-20160602, using arm64 defconfig
> + DRM + HDLCD + TDA998X and CMA_SIZE_MBYTES=1, booted on a Juno, does the
> job:
> 
> [3.032402] hdlcd 7ff6.hdlcd: bound 0-0070 (ops tda998x_ops)
> [3.038388] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
> [3.044970] [drm] No driver support for vblank timestamp query.
> [3.076973] hdlcd 7ff6.hdlcd: failed to allocate buffer with size
> 768
> [3.084081] Bad mode in Synchronous Abort handler detected, code
> 0x8604 -- IABT (current EL)
> [3.092815] CPU: 3 PID: 6 Comm: kworker/u12:0 Not tainted
> 4.7.0-rc1-next-20160602 #686
> [3.100682] Hardware name: ARM Juno development board (r1) (DT)
> [3.106567] Workqueue: deferwq deferred_probe_work_func
> [3.111761] task: 8009768a3e80 ti: 8009768e8000 task.ti:
> 8009768e8000
> [3.119198] PC is at 0x0
> [3.121720] LR is at drm_gem_cma_create+0x128/0x130
> ...and so on.
> 
> Today's -next, on the other hand, dodges the bullet entirely:
> 
> [2.903645] [drm] found ARM HDLCD version r0p0
> [2.908122] hdlcd 7ff6.hdlcd: master bind failed: -22
> [2.913505] tda998x: probe of 0-0070 failed with error -22
> [2.919141] [drm] found ARM HDLCD version r0p0
> [2.923609] hdlcd 7ff5.hdlcd: master bind failed: -22
> [2.928991] tda998x: probe of 0-0071 failed with error -22

Yes, if fails in of_reserved_mem_device_init(). Tracking now to see
which of the conditions at line 311 are the culprits.

Best regards,
Liviu

> 
> Oh well...
> 
> Robin.
> 

-- 

| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---
¯\_(ツ)_/¯


HDLCD crashes with 6d910bfa809e

2016-06-07 Thread Robin Murphy
Hi Liviu,

On 07/06/16 14:35, liviu.dudau at arm.com wrote:
> On Tue, Jun 07, 2016 at 01:06:00PM +0100, Robin Murphy wrote:
>> Having just inadvertently merged -next into my working branch, I find
>> dev6d910bfa809e ("drm/hlcd: Use lockless gem BO free callback") adversely
>> affecting my board's ability to boot ;)
>>
>> Since I (intentionally) don't have sufficient CMA to create a framebuffer,
>> drm_gem_cma_create() fails, unconditionally calls the now-NULL
>> drm->driver->gem_free_object() in its cleanup path, and fiery death
>> ensues...
>
> Thanks for reporting this. What other changes other than reducing the CMA
> allocation size do you have that I might need in order to reproduce this?

I've just confirmed a plain checkout of next-20160602, using arm64 
defconfig + DRM + HDLCD + TDA998X and CMA_SIZE_MBYTES=1, booted on a 
Juno, does the job:

[3.032402] hdlcd 7ff6.hdlcd: bound 0-0070 (ops tda998x_ops)
[3.038388] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[3.044970] [drm] No driver support for vblank timestamp query.
[3.076973] hdlcd 7ff6.hdlcd: failed to allocate buffer with size 
768
[3.084081] Bad mode in Synchronous Abort handler detected, code 
0x8604 -- IABT (current EL)
[3.092815] CPU: 3 PID: 6 Comm: kworker/u12:0 Not tainted 
4.7.0-rc1-next-20160602 #686
[3.100682] Hardware name: ARM Juno development board (r1) (DT)
[3.106567] Workqueue: deferwq deferred_probe_work_func
[3.111761] task: 8009768a3e80 ti: 8009768e8000 task.ti: 
8009768e8000
[3.119198] PC is at 0x0
[3.121720] LR is at drm_gem_cma_create+0x128/0x130
...and so on.

Today's -next, on the other hand, dodges the bullet entirely:

[2.903645] [drm] found ARM HDLCD version r0p0
[2.908122] hdlcd 7ff6.hdlcd: master bind failed: -22
[2.913505] tda998x: probe of 0-0070 failed with error -22
[2.919141] [drm] found ARM HDLCD version r0p0
[2.923609] hdlcd 7ff5.hdlcd: master bind failed: -22
[2.928991] tda998x: probe of 0-0071 failed with error -22

Oh well...

Robin.



[PATCH v6 4/4] drm/omapdrm: Implement gamma_lut atomic crtc properties

2016-06-07 Thread Jyri Sarha
Implement gamma_lut atomic crtc properties, set crtc gamma size to 256
for all crtcs and use drm_atomic_helper_legacy_gamma_set() as
gamma_set func. The tv-out crtc has 1024 element gamma table (with
10bit precision) in HW, but current Xorg server does not accept
anything else but 256 elements so that is used for all CRTCs. The dss
dispc API converts table of any length for HW and uses linear
interpolation in the process. The default gamma table is restored
if gamma_lut property is deleted.

Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/omapdrm/omap_crtc.c | 56 +
 1 file changed, 56 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 075f2bb..180f644 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -372,6 +372,20 @@ static void omap_crtc_mode_set_nofb(struct drm_crtc *crtc)
copy_timings_drm_to_omap(&omap_crtc->timings, mode);
 }

+static int omap_crtc_atomic_check(struct drm_crtc *crtc,
+   struct drm_crtc_state *state)
+{
+   if (state->color_mgmt_changed && state->gamma_lut) {
+   uint length = state->gamma_lut->length /
+   sizeof(struct drm_color_lut);
+
+   if (length < 2)
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
 static void omap_crtc_atomic_begin(struct drm_crtc *crtc,
   struct drm_crtc_state *old_crtc_state)
 {
@@ -384,6 +398,32 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,

WARN_ON(omap_crtc->vblank_irq.registered);

+   if (crtc->state->color_mgmt_changed) {
+   struct drm_color_lut *lut = NULL;
+   uint length = 0;
+
+   if (crtc->state->gamma_lut) {
+   lut = (struct drm_color_lut *)
+   crtc->state->gamma_lut->data;
+   length = crtc->state->gamma_lut->length /
+   sizeof(*lut);
+   }
+   dispc_mgr_set_gamma(omap_crtc->channel, lut, length);
+   }
+
+   if (crtc->state->color_mgmt_changed) {
+   struct drm_color_lut *lut = NULL;
+   uint length = 0;
+
+   if (crtc->state->gamma_lut) {
+   lut = (struct drm_color_lut *)
+   crtc->state->gamma_lut->data;
+   length = crtc->state->gamma_lut->length /
+   sizeof(*lut);
+   }
+   dispc_mgr_set_gamma(omap_crtc->channel, lut, length);
+   }
+
if (dispc_mgr_is_enabled(omap_crtc->channel)) {

DBG("%s: GO", omap_crtc->name);
@@ -460,6 +500,7 @@ static const struct drm_crtc_funcs omap_crtc_funcs = {
.set_config = drm_atomic_helper_set_config,
.destroy = omap_crtc_destroy,
.page_flip = drm_atomic_helper_page_flip,
+   .gamma_set = drm_atomic_helper_legacy_gamma_set,
.set_property = drm_atomic_helper_crtc_set_property,
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
@@ -471,6 +512,7 @@ static const struct drm_crtc_helper_funcs 
omap_crtc_helper_funcs = {
.mode_set_nofb = omap_crtc_mode_set_nofb,
.disable = omap_crtc_disable,
.enable = omap_crtc_enable,
+   .atomic_check = omap_crtc_atomic_check,
.atomic_begin = omap_crtc_atomic_begin,
.atomic_flush = omap_crtc_atomic_flush,
 };
@@ -534,6 +576,20 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,

drm_crtc_helper_add(crtc, &omap_crtc_helper_funcs);

+   /* The dispc API adapts to what ever size, but the HW supports
+* 256 element gamma table for LCDs and 1024 element table for
+* OMAP_DSS_CHANNEL_DIGIT. X server assumes 256 element gamma
+* tables so lets use that. Size of HW gamma table can be
+* extracted with dispc_mgr_gamma_size(). If it returns 0
+* gamma table is not supprted.
+*/
+   if (dispc_mgr_gamma_size(channel)) {
+   uint gamma_lut_size = 256;
+
+   drm_crtc_enable_color_mgmt(crtc, 0, false, gamma_lut_size);
+   drm_mode_crtc_set_gamma_size(crtc, gamma_lut_size);
+   }
+
omap_plane_install_properties(crtc->primary, &crtc->base);

omap_crtcs[channel] = omap_crtc;
-- 
1.9.1



[PATCH v6 3/4] drm/omapdrm: Workaround for errata i734 (LCD1 Gamma) in DSS dispc

2016-06-07 Thread Jyri Sarha
Workaround for errata i734 in DSS dispc
 - LCD1 Gamma Correction Is Not Working When GFX Pipe Is Disabled

For gamma tables to work on LCD1 the GFX plane has to be used at least
once after DSS HW has come out of reset. The workaround sets up a
minimal LCD setup with GFX plane and waits for one vertical sync irq
before disabling the setup and continuing with the context
restore. The physical outputs are gated during the operation.

For details see:
OMAP543x Multimedia Device Silicon Revision 2.0 Silicon Errata
Literature Number: SWPZ037E
Or some other relevant errata document for the DSS IP version.

Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/omapdrm/dss/dispc.c | 174 
 1 file changed, 174 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
b/drivers/gpu/drm/omapdrm/dss/dispc.c
index cdd227c..535240f 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -114,6 +114,8 @@ struct dispc_features {
bool reverse_ilace_field_order:1;

bool has_gamma_table:1;
+
+   bool has_gamma_i734_bug:1;
 };

 #define DISPC_MAX_NR_FIFOS 5
@@ -4074,6 +4076,7 @@ static const struct dispc_features omap44xx_dispc_feats = 
{
.supports_double_pixel  =   true,
.reverse_ilace_field_order =true,
.has_gamma_table=   true,
+   .has_gamma_i734_bug =   true,
 };

 static const struct dispc_features omap54xx_dispc_feats = {
@@ -4100,6 +4103,7 @@ static const struct dispc_features omap54xx_dispc_feats = 
{
.supports_double_pixel  =   true,
.reverse_ilace_field_order =true,
.has_gamma_table=   true,
+   .has_gamma_i734_bug =   true,
 };

 static int dispc_init_features(struct platform_device *pdev)
@@ -4191,6 +4195,168 @@ void dispc_free_irq(void *dev_id)
 }
 EXPORT_SYMBOL(dispc_free_irq);

+/*
+ * Workaround for errata i734 in DSS dispc
+ *  - LCD1 Gamma Correction Is Not Working When GFX Pipe Is Disabled
+ *
+ * For gamma tables to work on LCD1 the GFX plane has to be used at
+ * least once after DSS HW has come out of reset. The workaround
+ * sets up a minimal LCD setup with GFX plane and waits for one
+ * vertical sync irq before disabling the setup and continuing with
+ * the context restore. The physical outputs are gated during the
+ * operation. This workaround requires that gamma table's LOADMODE
+ * is set to 0x2 in DISPC_CONTROL1 register.
+ *
+ * For details see:
+ * OMAP543x Multimedia Device Silicon Revision 2.0 Silicon Errata
+ * Literature Number: SWPZ037E
+ * Or some other relevant errata document for the DSS IP version.
+ */
+
+static const struct dispc_errata_i734_data {
+   struct omap_video_timings timings;
+   struct omap_overlay_info ovli;
+   struct omap_overlay_manager_info mgri;
+   struct dss_lcd_mgr_config lcd_conf;
+} i734 = {
+   .timings = {
+   .x_res = 8, .y_res = 1,
+   .pixelclock = 1600,
+   .hsw = 8, .hfp = 4, .hbp = 4,
+   .vsw = 1, .vfp = 1, .vbp = 1,
+   .vsync_level = OMAPDSS_SIG_ACTIVE_LOW,
+   .hsync_level = OMAPDSS_SIG_ACTIVE_LOW,
+   .interlace = false,
+   .data_pclk_edge = OMAPDSS_DRIVE_SIG_RISING_EDGE,
+   .de_level = OMAPDSS_SIG_ACTIVE_HIGH,
+   .sync_pclk_edge = OMAPDSS_DRIVE_SIG_RISING_EDGE,
+   .double_pixel = false,
+   },
+   .ovli = {
+   .screen_width = 1,
+   .width = 1, .height = 1,
+   .color_mode = OMAP_DSS_COLOR_RGB24U,
+   .rotation = OMAP_DSS_ROT_0,
+   .rotation_type = OMAP_DSS_ROT_DMA,
+   .mirror = 0,
+   .pos_x = 0, .pos_y = 0,
+   .out_width = 0, .out_height = 0,
+   .global_alpha = 0xff,
+   .pre_mult_alpha = 0,
+   .zorder = 0,
+   },
+   .mgri = {
+   .default_color = 0,
+   .trans_enabled = false,
+   .partial_alpha_enabled = false,
+   .cpr_enable = false,
+   },
+   .lcd_conf = {
+   .io_pad_mode = DSS_IO_PAD_MODE_BYPASS,
+   .stallmode = false,
+   .fifohandcheck = false,
+   .clock_info = {
+   .lck_div = 1,
+   .pck_div = 2,
+   },
+   .video_port_width = 24,
+   .lcden_sig_polarity = 0,
+   },
+};
+
+static struct i734_buf {
+   size_t size;
+   dma_addr_t paddr;
+   void *vaddr;
+} i734_buf;
+
+static int dispc_errata_i734_wa_init(void)
+{
+   if (!dispc.feat->has_gamma_i734_bug)
+   return 0;
+
+   i734_buf.size = i734.ovli.width * i734.ovli.height *
+   color_mode_to_bpp(i734.ovli.color_mode) / 8;
+
+   i734_buf.vaddr = dma_alloc_writecombine(&dispc.pdev->dev, i734_buf.size,
+

[PATCH v6 2/4] drm/omapdrm: Add gamma table support to DSS dispc

2016-06-07 Thread Jyri Sarha
Add gamma table support to DSS dispc.

DSS driver initializes the default gamma table at component bind time
and holds a copy of all gamma tables in its internal data structure.

Each call to dispc_mgr_set_gamma() updates the internal table and
triggers write to the HW, if it is enabled. The tables are restored to
HW in PM resume callback. The drivers internal data structure match
the HW tables in size and in number of significant bits per color
component. The dispc_mgr_set_gamma() converts the size of any given
table for the internal data structure using linear interpolation.
Default gamma table is restored if NULL is given in place of gamma
lut.

dispc_mgr_gamma_size() gives HW gamma table size for the channel and
returns 0 if gamma table is not supported by the HW or the DSS driver.

Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/omapdrm/dss/dispc.c   | 203 +++---
 drivers/gpu/drm/omapdrm/dss/dispc.h   |   5 +
 drivers/gpu/drm/omapdrm/dss/hdmi4.c   |   3 -
 drivers/gpu/drm/omapdrm/dss/hdmi5.c   |   3 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h |   5 +
 5 files changed, 197 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 0aecce2..cdd227c 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -112,9 +112,12 @@ struct dispc_features {
 * never both, we can just use this flag for now.
 */
bool reverse_ilace_field_order:1;
+
+   bool has_gamma_table:1;
 };

 #define DISPC_MAX_NR_FIFOS 5
+#define DISPC_MAX_CHANNEL_GAMMA 4

 static struct {
struct platform_device *pdev;
@@ -134,6 +137,8 @@ static struct {
boolctx_valid;
u32 ctx[DISPC_SZ_REGS / sizeof(u32)];

+   u32 *gamma_table[DISPC_MAX_CHANNEL_GAMMA];
+
const struct dispc_features *feat;

bool is_enabled;
@@ -177,11 +182,19 @@ struct dispc_reg_field {
u8 low;
 };

+struct dispc_gamma_desc {
+   u32 len;
+   u32 bits;
+   u16 reg;
+   bool has_index;
+};
+
 static const struct {
const char *name;
u32 vsync_irq;
u32 framedone_irq;
u32 sync_lost_irq;
+   struct dispc_gamma_desc gamma;
struct dispc_reg_field reg_desc[DISPC_MGR_FLD_NUM];
 } mgr_desc[] = {
[OMAP_DSS_CHANNEL_LCD] = {
@@ -189,6 +202,12 @@ static const struct {
.vsync_irq  = DISPC_IRQ_VSYNC,
.framedone_irq  = DISPC_IRQ_FRAMEDONE,
.sync_lost_irq  = DISPC_IRQ_SYNC_LOST,
+   .gamma  = {
+   .len= 256,
+   .bits   = 8,
+   .reg= DISPC_GAMMA_TABLE0,
+   .has_index = true,
+   },
.reg_desc   = {
[DISPC_MGR_FLD_ENABLE]  = { DISPC_CONTROL,  0,  
0 },
[DISPC_MGR_FLD_STNTFT]  = { DISPC_CONTROL,  3,  
3 },
@@ -206,6 +225,12 @@ static const struct {
.vsync_irq  = DISPC_IRQ_EVSYNC_ODD | DISPC_IRQ_EVSYNC_EVEN,
.framedone_irq  = DISPC_IRQ_FRAMEDONETV,
.sync_lost_irq  = DISPC_IRQ_SYNC_LOST_DIGIT,
+   .gamma  = {
+   .len= 1024,
+   .bits   = 10,
+   .reg= DISPC_GAMMA_TABLE2,
+   .has_index = false,
+   },
.reg_desc   = {
[DISPC_MGR_FLD_ENABLE]  = { DISPC_CONTROL,  1,  
1 },
[DISPC_MGR_FLD_STNTFT]  = { },
@@ -223,6 +248,12 @@ static const struct {
.vsync_irq  = DISPC_IRQ_VSYNC2,
.framedone_irq  = DISPC_IRQ_FRAMEDONE2,
.sync_lost_irq  = DISPC_IRQ_SYNC_LOST2,
+   .gamma  = {
+   .len= 256,
+   .bits   = 8,
+   .reg= DISPC_GAMMA_TABLE1,
+   .has_index = true,
+   },
.reg_desc   = {
[DISPC_MGR_FLD_ENABLE]  = { DISPC_CONTROL2,  0, 
 0 },
[DISPC_MGR_FLD_STNTFT]  = { DISPC_CONTROL2,  3, 
 3 },
@@ -240,6 +271,12 @@ static const struct {
.vsync_irq  = DISPC_IRQ_VSYNC3,
.framedone_irq  = DISPC_IRQ_FRAMEDONE3,
.sync_lost_irq  = DISPC_IRQ_SYNC_LOST3,
+   .gamma  = {
+   .len= 256,
+   .bits   = 8,
+   .reg= DISPC_GAMMA_TABLE3,
+   .has_index = true,
+   },
.reg_desc   = {
[DISPC_MGR_FLD_ENABLE]  = { DISPC_CONTROL3,  0, 
 0 },
[DISPC_MGR_FLD_STNTFT]  = { DISPC_CONTROL3,  3, 
 3 },
@@ -1083,20 +1120,6 @@ static u32 d

[PATCH v6 1/4] drm: drm_helper_crtc_enable_color_mgmt() => drm_crtc_enable_color_mgmt()

2016-06-07 Thread Jyri Sarha
Add drm_crtc_enable_color_mgmt(), remove drm_helper_crtc_enable_color_mgmt()
and update drm/i915-driver (the only user of the old function).

The new function is more flexible. It allows driver to enable only the
features it has without forcing to enable all three color management
properties: degamma lut, csc matrix (ctm), and gamma lut.

Suggested-by: Daniel Vetter 
Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/drm_crtc.c | 45 ++
 drivers/gpu/drm/drm_crtc_helper.c  | 33 
 drivers/gpu/drm/i915/intel_color.c |  3 ++-
 include/drm/drm_crtc.h |  5 -
 include/drm/drm_crtc_helper.h  |  3 ---
 5 files changed, 51 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 0e3cc66..b25c759 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -6064,3 +6064,48 @@ struct drm_tile_group *drm_mode_create_tile_group(struct 
drm_device *dev,
return tg;
 }
 EXPORT_SYMBOL(drm_mode_create_tile_group);
+
+/**
+ * drm_crtc_enable_color_mgmt - enable color management properties
+ * @crtc: DRM CRTC
+ * @degamma_lut_size: the size of the degamma lut (before CSC)
+ * @has_ctm: whether to attach ctm_property for CSC matrix
+ * @gamma_lut_size: the size of the gamma lut (after CSC)
+ *
+ * This function lets the driver enable the color correction
+ * properties on a CRTC. This includes 3 degamma, csc and gamma
+ * properties that userspace can set and 2 size properties to inform
+ * the userspace of the lut sizes. Each of the properties are
+ * optional. The gamma and degamma properties are only attached if
+ * their size is not 0 and ctm_property is only attached if has_ctm is
+ * true.
+ */
+void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,
+   uint degamma_lut_size,
+   bool has_ctm,
+   uint gamma_lut_size)
+{
+   struct drm_device *dev = crtc->dev;
+   struct drm_mode_config *config = &dev->mode_config;
+
+   if (degamma_lut_size) {
+   drm_object_attach_property(&crtc->base,
+  config->degamma_lut_property, 0);
+   drm_object_attach_property(&crtc->base,
+  config->degamma_lut_size_property,
+  degamma_lut_size);
+   }
+
+   if (has_ctm)
+   drm_object_attach_property(&crtc->base,
+  config->ctm_property, 0);
+
+   if (gamma_lut_size) {
+   drm_object_attach_property(&crtc->base,
+  config->gamma_lut_property, 0);
+   drm_object_attach_property(&crtc->base,
+  config->gamma_lut_size_property,
+  gamma_lut_size);
+   }
+}
+EXPORT_SYMBOL(drm_crtc_enable_color_mgmt);
diff --git a/drivers/gpu/drm/drm_crtc_helper.c 
b/drivers/gpu/drm/drm_crtc_helper.c
index a6e4243..bf10d70 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -1121,36 +1121,3 @@ int drm_helper_crtc_mode_set_base(struct drm_crtc *crtc, 
int x, int y,
return drm_plane_helper_commit(plane, plane_state, old_fb);
 }
 EXPORT_SYMBOL(drm_helper_crtc_mode_set_base);
-
-/**
- * drm_helper_crtc_enable_color_mgmt - enable color management properties
- * @crtc: DRM CRTC
- * @degamma_lut_size: the size of the degamma lut (before CSC)
- * @gamma_lut_size: the size of the gamma lut (after CSC)
- *
- * This function lets the driver enable the color correction properties on a
- * CRTC. This includes 3 degamma, csc and gamma properties that userspace can
- * set and 2 size properties to inform the userspace of the lut sizes.
- */
-void drm_helper_crtc_enable_color_mgmt(struct drm_crtc *crtc,
-  int degamma_lut_size,
-  int gamma_lut_size)
-{
-   struct drm_device *dev = crtc->dev;
-   struct drm_mode_config *config = &dev->mode_config;
-
-   drm_object_attach_property(&crtc->base,
-  config->degamma_lut_property, 0);
-   drm_object_attach_property(&crtc->base,
-  config->ctm_property, 0);
-   drm_object_attach_property(&crtc->base,
-  config->gamma_lut_property, 0);
-
-   drm_object_attach_property(&crtc->base,
-  config->degamma_lut_size_property,
-  degamma_lut_size);
-   drm_object_attach_property(&crtc->base,
-  config->gamma_lut_size_property,
-  gamma_lut_size);
-}
-EXPORT_SYMBOL(drm_helper_crtc_enable_color_mgmt);
diff --git a/drivers/gpu/drm/i915/intel_color.c 
b/drivers/gpu/drm/i915/intel_color

[PATCH v6 0/4] drm/omapdrm: gamma table support + drm_crtc_enable_color_mgmt()

2016-06-07 Thread Jyri Sarha
Implements gamma tables for OMAP4, OMAP5, and dra7xx SoCs and adds a
workaround for errata that may break LCD1 channel if gamma tables
are in use.

Also adds new drm_crtc_enable_color_mgmt() as suggested[1] by Daniel
Vetter and get rid of the old drm_helper_crtc_enable_color_mgmt(). I
have not tested the change to i915 driver, only compiled it, but
functionally it should be exactly the same.

[1] http://www.spinics.net/lists/dri-devel/msg108092.html

Changes from v5 to v6
- Rebased on top of Tomi's 4.8/omapdrm branch
  (git://git.kernel.org/pub/scm/linux/kernel/git/tomba/linux.git 4.8/omapdrm)
- "drm: drm_helper_crtc_enable_color_mgmt() => drm_crtc_enable_color_mgmt()"
  - No change
- "drm/omapdrm: Add gamma table support to DSS dispc"
  - Don't crash to gamma table with lenght < 2
  - Deal with input table size > output table size, in interpolation code
- "drm/omapdrm: Workaround for errata i734 (LCD1 Gamma) in DSS dispc"
  - No change
- "drm/omapdrm: Implement gamma_lut atomic crtc properties"
  - Add "omap_crtc_atomic_check()"
  - Restore default gamma table if the gamma_lut property is removed

Changes from v4 to v5
- No code changes
- Reorder the patches so that color_mgmt-patch comes first
- Fix some typos from commit descriptions
- Squash:
"drm: Add drm_crtc_enable_color_mgmt()",
"drm/i915: Use drm_crtc_enable_color_mgmt()", and
"drm: Remove obsolete drm_helper_crtc_enable_color_mgmt()"
  to: "drm: drm_helper_crtc_enable_color_mgmt() => drm_crtc_enable_color_mgmt()"
- Squash:
"drm/omapdrm: Use drm_crtc_enable_color_mgmt() to enable gamma properties"
  into: "drm/omapdrm: Implement gamma_lut atomic crtc properties"

Changes from v3 to v4
- "drm/omapdrm: Add gamma table support to DSS dispc"
  - use interpolation code in dispc_mgr_set_gamma() to produce default lut
  - restore default lut table if NULL is given as gamma lut table
- "drm/omapdrm: Implement gamma_lut atomic crtc property"
  - attach gamma_lut_property and gamma_lut_size_property to crtc if
gamma tables are supported
  - restore default table if gamma lut property is deleted
- Adds:
  - drm: Add drm_crtc_enable_color_mgmt()
  - drm/omapdrm: Use drm_crtc_enable_color_mgmt() to enable gamma properties
  - drm/i915: Use drm_crtc_enable_color_mgmt()
  - drm: Remove obsolete drm_helper_crtc_enable_color_mgmt()

Changes from v2 to v3
- "drm/omapdrm: Add gamma table support to DSS dispc"
  - fix dispc_init_gamma_tables() to always return an int
  - omap54xx_dispc_feats initializes .has_gamma_table not .has_gamma_tables
- "drm/omapdrm: Work-a-round for errata i734 (LCD1 Gamma) in DSS dispc"
  - work-a-round -> workaround
  - Do not mention LOADMODE in description
  - dma_alloc_writecombine returns NULL on error
  - fix last wrong instrance of LCD output gating register
  - improve comment for framedone busy wait
  - add {} around busy loop's while statement

Changes from v1 to v2
- Drop "drm/omapdrm: omap_modeset_init: Separate crtc id and plane id indexing"
- "drm/omapdrm: Add gamma table support to DSS dispc"
 - Address Tomi's comments here: https://patchwork.kernel.org/patch/9128629/
- "drm/omapdrm: Work-a-round for errata i734 (LCD1 Gamma) in DSS dispc"
 - Address Tomi's comments here: https://patchwork.kernel.org/patch/9128633/

Jyri Sarha (4):
  drm: drm_helper_crtc_enable_color_mgmt() =>
drm_crtc_enable_color_mgmt()
  drm/omapdrm: Add gamma table support to DSS dispc
  drm/omapdrm: Workaround for errata i734 (LCD1 Gamma) in DSS dispc
  drm/omapdrm: Implement gamma_lut atomic crtc properties

 drivers/gpu/drm/drm_crtc.c|  45 
 drivers/gpu/drm/drm_crtc_helper.c |  33 ---
 drivers/gpu/drm/i915/intel_color.c|   3 +-
 drivers/gpu/drm/omapdrm/dss/dispc.c   | 377 --
 drivers/gpu/drm/omapdrm/dss/dispc.h   |   5 +
 drivers/gpu/drm/omapdrm/dss/hdmi4.c   |   3 -
 drivers/gpu/drm/omapdrm/dss/hdmi5.c   |   3 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h |   5 +
 drivers/gpu/drm/omapdrm/omap_crtc.c   |  56 +
 include/drm/drm_crtc.h|   5 +-
 include/drm/drm_crtc_helper.h |   3 -
 11 files changed, 478 insertions(+), 60 deletions(-)

-- 
1.9.1



[PATCH 1/4] drm: Centralize format information

2016-06-07 Thread Laurent Pinchart
Hi Tomi,

On Tuesday 07 Jun 2016 12:25:08 Tomi Valkeinen wrote:
> On 07/06/16 02:33, Laurent Pinchart wrote:
> > Various pieces of information about DRM formats (number of planes, color
> > depth, chroma subsampling, ...) are scattered across different helper
> > functions in the DRM core. Callers of those functions often need to
> > access more than a single parameter of the format, leading to
> > inefficiencies due to multiple lookups.
> > 
> > Centralize all format information in a data structure and create a
> > function to look up information based on the format 4CC.
> > 
> > Signed-off-by: Laurent Pinchart 
> > ---
> > 
> >  drivers/gpu/drm/drm_crtc.c | 83 +
> >  include/drm/drm_crtc.h | 21 
> >  2 files changed, 104 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> > index 0e3cc66aa8b7..74b0c6dd80cd 100644
> > --- a/drivers/gpu/drm/drm_crtc.c
> > +++ b/drivers/gpu/drm/drm_crtc.c
> > @@ -5544,6 +5544,89 @@ int drm_mode_destroy_dumb_ioctl(struct drm_device
> > *dev,> 
> >  }
> >  
> >  /**
> > 
> > + * drm_format_info - information for a given format
> > + * @format: pixel format (DRM_FORMAT_*)
> > + *
> > + * Returns:
> > + * The instance of struct drm_format_info that describes the pixel
> > format, or + * NULL if the format is unsupported.
> > + */
> > +const struct drm_format_info *drm_format_info(u32 format)
> > +{
> > +   static const struct drm_format_info formats[] = {
> > +   { DRM_FORMAT_C8, 8, 8, 1, { 1 }, 1, 1 },
> > +   { DRM_FORMAT_RGB332, 8, 8, 1, { 1 }, 1, 1 },
> > +   { DRM_FORMAT_BGR233, 8, 8, 1, { 1 }, 1, 1 },
> > +   { DRM_FORMAT_XRGB, 12, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_XBGR, 12, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_RGBX, 12, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_BGRX, 12, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_ARGB, 12, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_ABGR, 12, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_RGBA, 12, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_BGRA, 12, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_XRGB1555, 15, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_XBGR1555, 15, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_RGBX5551, 15, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_BGRX5551, 15, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_ARGB1555, 15, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_ABGR1555, 15, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_RGBA5551, 15, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_BGRA5551, 15, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_RGB565, 16, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_BGR565, 16, 16, 1, { 2 }, 1, 1 },
> > +   { DRM_FORMAT_RGB888, 24, 24, 1, { 3 }, 1, 1 },
> > +   { DRM_FORMAT_BGR888, 24, 24, 1, { 3 }, 1, 1 },
> > +   { DRM_FORMAT_XRGB, 24, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_XBGR, 24, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_RGBX, 24, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_BGRX, 24, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_XRGB2101010, 30, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_XBGR2101010, 30, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_RGBX1010102, 30, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_BGRX1010102, 30, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_ARGB2101010, 30, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_ABGR2101010, 30, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_RGBA1010102, 30, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_BGRA1010102, 30, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_ARGB, 32, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_ABGR, 32, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_RGBA, 32, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_BGRA, 32, 32, 1, { 4 }, 1, 1 },
> > +   { DRM_FORMAT_YUV410, 0, 0, 3, { 1, 1, 1 }, 4, 4 },
> > +   { DRM_FORMAT_YVU410, 0, 0, 3, { 1, 1, 1 }, 4, 4 },
> > +   { DRM_FORMAT_YUV411, 0, 0, 3, { 1, 1, 1 }, 4, 1 },
> > +   { DRM_FORMAT_YVU411, 0, 0, 3, { 1, 1, 1 }, 4, 1 },
> > +   { DRM_FORMAT_YUV420, 0, 0, 3, { 1, 1, 1 }, 2, 2 },
> > +   { DRM_FORMAT_YVU420, 0, 0, 3, { 1, 1, 1 }, 2, 2 },
> > +   { DRM_FORMAT_YUV422, 0, 0, 3, { 1, 1, 1 }, 2, 1 },
> > +   { DRM_FORMAT_YVU422, 0, 0, 3, { 1, 1, 1 }, 2, 1 },
> > +   { DRM_FORMAT_YUV444, 0, 0, 3, { 1, 1, 1 }, 1, 1 },
> > +   { DRM_FORMAT_YVU444, 0, 0, 3, { 1, 1, 1 }, 1, 1 },
> > +   { DRM_FORMAT_NV12, 0, 0, 2, { 1, 2 }, 2, 2 },
> > +   { DRM_FORMAT_NV21, 0, 0, 2, { 1, 2 }, 2, 2 },
> > +   { DRM_FORMAT_NV16, 0, 0, 2, { 1, 2 }, 2, 1 },
> > +   { DRM_FORMAT_NV61, 0, 0, 2, { 1, 2 }, 2, 1 },
> > +   { DRM_FORMAT_NV24, 0, 0, 

[Bug 96296] clpeak causes a GPU hang

2016-06-07 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=96296

--- Comment #5 from Jan Vesely  ---
One problem is that starting from R700 ADD_INT is VecALU only instruction
(should not be in Trans slot), but it was not enough to fix the hang on my
Turks.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160607/388beb4c/attachment.html>


[PATCH 1/4] drm: Centralize format information

2016-06-07 Thread Laurent Pinchart
Hi Tomi,

On Tuesday 07 Jun 2016 12:18:34 Tomi Valkeinen wrote:
> On 07/06/16 02:33, Laurent Pinchart wrote:
> > +/**
> > + * struct drm_format_info - information about a DRM format
> > + * @format: 4CC format identifier (DRM_FORMAT_*)
> > + * @depth: color depth (number of bits per pixel excluding padding bits)
> > + * @bpp: number of bits per pixel including padding
> > + * @num_planes: number of color planes (1 to 3)
> > + * @cpp: number of bytes per pixel (per plane)
> > + * @hsub: horizontal chroma subsampling factor
> > + * @vsub: vertical chroma subsampling factor
> > + */
> > +struct drm_format_info {
> > +   u32 format;
> > +   unsigned int depth;
> > +   unsigned int bpp;
> > +   unsigned int num_planes;
> > +   unsigned int cpp[3];
> > +   unsigned int hsub;
> > +   unsigned int vsub;
> > +};
> 
> Any reason not to pack this a bit? All those unsigned ints would fit
> easily into u8.

Good point, I'll do that.

-- 
Regards,

Laurent Pinchart



[PATCH v2 2/3] drm: convert DT component matching to component_match_add_release()

2016-06-07 Thread Liviu Dudau
On Fri, Jun 03, 2016 at 03:21:25PM +0100, Russell King wrote:
> Convert DT component matching to use component_match_add_release().
> 
> Signed-off-by: Russell King 
> ---
>  drivers/gpu/drm/arm/hdlcd_drv.c |  9 +++--
>  drivers/gpu/drm/armada/armada_drv.c |  8 ++--
>  drivers/gpu/drm/drm_of.c|  6 --
>  drivers/gpu/drm/etnaviv/etnaviv_drv.c   | 11 ++-
>  drivers/gpu/drm/msm/msm_drv.c   |  8 ++--
>  drivers/gpu/drm/msm/msm_drv.h   |  1 +
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 12 +++-
>  drivers/gpu/drm/sti/sti_drv.c   |  9 ++---
>  drivers/gpu/drm/tilcdc/tilcdc_external.c|  8 ++--
>  9 files changed, 21 insertions(+), 51 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> index b987c63ba8d6..f00845c25795 100644
> --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> @@ -14,6 +14,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -443,11 +444,6 @@ static const struct component_master_ops 
> hdlcd_master_ops = {
>   .unbind = hdlcd_drm_unbind,
>  };
>  
> -static int compare_dev(struct device *dev, void *data)
> -{
> - return dev->of_node == data;
> -}
> -
>  static int hdlcd_probe(struct platform_device *pdev)
>  {
>   struct device_node *port, *ep;
> @@ -474,7 +470,8 @@ static int hdlcd_probe(struct platform_device *pdev)
>   return -EAGAIN;
>   }
>  
> - component_match_add(&pdev->dev, &match, compare_dev, port);
> + component_match_add_of(&pdev->dev, &match, port);
> + of_node_put(port);
>  
>   return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
>  match);

For the HDLCD part of v2:

Acked-by: Liviu Dudau 


> diff --git a/drivers/gpu/drm/armada/armada_drv.c 
> b/drivers/gpu/drm/armada/armada_drv.c
> index 439824a61aa5..f2716d20c257 100644
> --- a/drivers/gpu/drm/armada/armada_drv.c
> +++ b/drivers/gpu/drm/armada/armada_drv.c
> @@ -9,6 +9,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -227,11 +228,6 @@ static void armada_drm_unbind(struct device *dev)
>   drm_put_dev(dev_get_drvdata(dev));
>  }
>  
> -static int compare_of(struct device *dev, void *data)
> -{
> - return dev->of_node == data;
> -}
> -
>  static int compare_dev_name(struct device *dev, void *data)
>  {
>   const char *name = data;
> @@ -255,7 +251,7 @@ static void armada_add_endpoints(struct device *dev,
>   continue;
>   }
>  
> - component_match_add(dev, match, compare_of, remote);
> + component_match_add_of(dev, match, remote);
>   of_node_put(remote);
>   }
>  }
> diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> index bc98bb94264d..d13fc633aeea 100644
> --- a/drivers/gpu/drm/drm_of.c
> +++ b/drivers/gpu/drm/drm_of.c
> @@ -1,6 +1,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -101,7 +102,7 @@ int drm_of_component_probe(struct device *dev,
>   continue;
>   }
>  
> - component_match_add(dev, &match, compare_of, port);
> + component_match_add_of(dev, &match, compare_of, port);
>   of_node_put(port);
>   }
>  
> @@ -140,7 +141,8 @@ int drm_of_component_probe(struct device *dev,
>   continue;
>   }
>  
> - component_match_add(dev, &match, compare_of, remote);
> + component_match_add_of_compare(dev, &match, compare_of,
> +remote);
>   of_node_put(remote);
>   }
>   of_node_put(port);
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c 
> b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> index 3d4f56df8359..a0e0764a6269 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> @@ -15,6 +15,7 @@
>   */
>  
>  #include 
> +#include 
>  #include 
>  
>  #include "etnaviv_drv.h"
> @@ -606,13 +607,6 @@ static const struct component_master_ops 
> etnaviv_master_ops = {
>   .unbind = etnaviv_unbind,
>  };
>  
> -static int compare_of(struct device *dev, void *data)
> -{
> - struct device_node *np = data;
> -
> - return dev->of_node == np;
> -}
> -
>  static int compare_str(struct device *dev, void *data)
>  {
>   return !strcmp(dev_name(dev), data);
> @@ -635,8 +629,7 @@ static int etnaviv_pdev_probe(struct platform_device 
> *pdev)
>   if (!core_node)
>   break;
>  
> - component_match_add(&pdev->dev, &match, compare_of,
> - core_node);
> + component_

HDLCD crashes with 6d910bfa809e

2016-06-07 Thread liviu.du...@arm.com
On Tue, Jun 07, 2016 at 01:06:00PM +0100, Robin Murphy wrote:
> Hi Daniel, Liviu,

Hi Robin,

> 
> Having just inadvertently merged -next into my working branch, I find
> dev6d910bfa809e ("drm/hlcd: Use lockless gem BO free callback") adversely
> affecting my board's ability to boot ;)
> 
> Since I (intentionally) don't have sufficient CMA to create a framebuffer,
> drm_gem_cma_create() fails, unconditionally calls the now-NULL
> drm->driver->gem_free_object() in its cleanup path, and fiery death
> ensues...

Thanks for reporting this. What other changes other than reducing the CMA
allocation size do you have that I might need in order to reproduce this?

Best regards,
Liviu

> 
> Regards,
> Robin.
> 

-- 

| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---
¯\_(ツ)_/¯


[PATCH] drm/imx: check the value returned by regulator_set_voltage()

2016-06-07 Thread Fabio Estevam
regulator_set_voltage() may fail, so we better check its return value
and propagate it in the case of error.

Signed-off-by: Fabio Estevam 
---
 drivers/gpu/drm/imx/imx-tve.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/imx/imx-tve.c b/drivers/gpu/drm/imx/imx-tve.c
index baf7881..c93301c 100644
--- a/drivers/gpu/drm/imx/imx-tve.c
+++ b/drivers/gpu/drm/imx/imx-tve.c
@@ -633,7 +633,9 @@ static int imx_tve_bind(struct device *dev, struct device 
*master, void *data)

tve->dac_reg = devm_regulator_get(dev, "dac");
if (!IS_ERR(tve->dac_reg)) {
-   regulator_set_voltage(tve->dac_reg, 275, 275);
+   ret = regulator_set_voltage(tve->dac_reg, 275, 275);
+   if (ret)
+   return ret;
ret = regulator_enable(tve->dac_reg);
if (ret)
return ret;
-- 
1.9.1



[Mesa-dev] radeonfb: BAR 0: can't reserve [mem 0x98000000-0x9fffffff pref]

2016-06-07 Thread Christian König
Am 07.06.2016 um 14:19 schrieb Mathieu Malaterre:
> On Tue, Jun 7, 2016 at 8:05 AM, Mathieu Malaterre  wrote:
>> Hi Alex,
>>
>> On Mon, Jun 6, 2016 at 7:20 PM, Alex Deucher  
>> wrote:
>>> On Mon, Jun 6, 2016 at 1:16 PM, Marek Olšák  wrote:
 [+ dri-devel]

 On Mon, Jun 6, 2016 at 8:42 AM, Mathieu Malaterre  
 wrote:
> Hi,
>
> Before reporting a possible invalid bug report. Does anyone knows why
> radeaonfb is not configured the same way radeon is ? For instance on a
> PowerPC machine, when Open Firmware Frame Buffer is used (OFfb), I
> cannot `modprobe radeonfb` (but I can load `radeon`). It fails with:
>
> [   96.551486] radeonfb :00:10.0: enabling device (0006 -> 0007)
> [   96.551526] radeonfb :00:10.0: BAR 0: can't reserve [mem
> 0x9800-0x9fff pref]
> [   96.551531] radeonfb (:00:10.0): cannot request region 0.
> [   96.551545] radeonfb: probe of :00:10.0 failed with error -16
>
> It seems (to me) that it should be possible to add something like this
> to `radeonfb`:
>
> https://github.com/torvalds/linux/blob/master/drivers/gpu/drm/radeon/radeon_drv.c#L353
>
> Is the above correct ?
>>> Yes, probably.  But is there any reason why you'd want to use radeonfb
>>> rather than radeon?
>> I'll check with the debian-installer team if this is possible. Right
>> now the debian-installer is setup to use `radeonfb` (at least on
>> PowerPC) during the text-based installation.
>>
>> ref: https://bugs.debian.org/825840#77
> [between a rock and a hard place]
>
> So it seems there would be a risk moving from radeonfb to radeon, esp.
> since Debian does not distribute (at least by default) the firmware
> during installation: https://bugs.debian.org/826629#12.
>
> I'll report the bug against radeonfb and see if I can provide a patch.

radeon should be able to offer the same functionality as radeonfb even 
without firmware.

But saying so that functionality is usually rarely tested.

Regards,
Christian.

>
> -M
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel



[Mesa-dev] radeonfb: BAR 0: can't reserve [mem 0x98000000-0x9fffffff pref]

2016-06-07 Thread Mathieu Malaterre
On Tue, Jun 7, 2016 at 8:05 AM, Mathieu Malaterre  wrote:
> Hi Alex,
>
> On Mon, Jun 6, 2016 at 7:20 PM, Alex Deucher  wrote:
>> On Mon, Jun 6, 2016 at 1:16 PM, Marek Olšák  wrote:
>>> [+ dri-devel]
>>>
>>> On Mon, Jun 6, 2016 at 8:42 AM, Mathieu Malaterre  
>>> wrote:
 Hi,

 Before reporting a possible invalid bug report. Does anyone knows why
 radeaonfb is not configured the same way radeon is ? For instance on a
 PowerPC machine, when Open Firmware Frame Buffer is used (OFfb), I
 cannot `modprobe radeonfb` (but I can load `radeon`). It fails with:

 [   96.551486] radeonfb :00:10.0: enabling device (0006 -> 0007)
 [   96.551526] radeonfb :00:10.0: BAR 0: can't reserve [mem
 0x9800-0x9fff pref]
 [   96.551531] radeonfb (:00:10.0): cannot request region 0.
 [   96.551545] radeonfb: probe of :00:10.0 failed with error -16

 It seems (to me) that it should be possible to add something like this
 to `radeonfb`:

 https://github.com/torvalds/linux/blob/master/drivers/gpu/drm/radeon/radeon_drv.c#L353

 Is the above correct ?
>>
>> Yes, probably.  But is there any reason why you'd want to use radeonfb
>> rather than radeon?
>
> I'll check with the debian-installer team if this is possible. Right
> now the debian-installer is setup to use `radeonfb` (at least on
> PowerPC) during the text-based installation.
>
> ref: https://bugs.debian.org/825840#77

[between a rock and a hard place]

So it seems there would be a risk moving from radeonfb to radeon, esp.
since Debian does not distribute (at least by default) the firmware
during installation: https://bugs.debian.org/826629#12.

I'll report the bug against radeonfb and see if I can provide a patch.

-M


[PATCH v6 2/2] drm/bridge: Add sii902x DT bindings doc

2016-06-07 Thread Boris Brezillon
Add Sii9022 DT bindings description.

Signed-off-by: Boris Brezillon 
Acked-by: Rob Herring 
---
Changes since v1:
- rename doc file
- s/sil902/sii902/
---
 .../devicetree/bindings/display/bridge/sii902x.txt | 35 ++
 1 file changed, 35 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/bridge/sii902x.txt

diff --git a/Documentation/devicetree/bindings/display/bridge/sii902x.txt 
b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
new file mode 100644
index 000..e8d0ffa
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
@@ -0,0 +1,35 @@
+sii902x HDMI bridge bindings
+
+Required properties:
+   - compatible: "sil,sii9022"
+   - reg: i2c address of the bridge
+   - reset-gpios: OF device-tree gpio specification for RST_N pin.
+
+Optional properties:
+   - interrupts-extended or interrupt-parent + interrupts: describe
+ the interrupt line used to inform the host about hotplug events.
+
+Optional subnodes:
+   - video input: this subnode can contain a video input port node
+ to connect the bridge to a display controller output (See this
+ documentation [1]).
+
+[1]: Documentation/devicetree/bindings/media/video-interfaces.txt
+
+Example:
+   hdmi-bridge at 39 {
+   compatible = "sil,sii9022";
+   reg = <0x39>;
+   reset-gpios = <&pioA 1 0>;
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port at 0 {
+   reg = <0>;
+   bridge_in: endpoint {
+   remote-endpoint = <&dc_out>;
+   };
+   };
+   };
+   };
-- 
2.7.4



[PATCH v6 1/2] drm/bridge: Add sii902x driver

2016-06-07 Thread Boris Brezillon
Add basic support for the sii902x RGB -> HDMI bridge.
This driver does not support audio output yet.

Signed-off-by: Boris Brezillon 
Tested-by: Nicolas Ferre 
---
Hello,

This patch is only adding basic support for the sii9022 chip.
As stated in the commit log, there's no audio support, but the
driver also hardcodes a lot of things (like the RGB input format to
use).

Best Regards,

Boris

Changes in v6:
- use HDMI_INFOFRAME_SIZE(AVI)
- fix reset_gpio initialization
- reduce the reset time based on Ming feedback

Changes in v5:
- drop the best_encoder() implementation

Changes in v4:
- make reset GPIO optional
- only support attaching to DRM devices supporting atomic updates

Changes in v3:
- fix get_modes() implementation to avoid turning the screen in power
  save mode
- rename the driver (sil902x -> sii902x)

Changes in v2:
- fix errors reported by the kbuild robot

fixup! drm: bridge: Add sii902x driver
---
 drivers/gpu/drm/bridge/Kconfig   |   8 +
 drivers/gpu/drm/bridge/Makefile  |   1 +
 drivers/gpu/drm/bridge/sii902x.c | 459 +++
 3 files changed, 468 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/sii902x.c

diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index 8f7423f..a1419214 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -50,6 +50,14 @@ config DRM_PARADE_PS8622
---help---
  Parade eDP-LVDS bridge chip driver.

+config DRM_SII902X
+   tristate "Silicon Image sii902x RGB/HDMI bridge"
+   depends on OF
+   select DRM_KMS_HELPER
+   select REGMAP_I2C
+   ---help---
+ Silicon Image sii902x bridge chip driver.
+
 source "drivers/gpu/drm/bridge/analogix/Kconfig"

 endmenu
diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
index 96b13b3..bfec9f8 100644
--- a/drivers/gpu/drm/bridge/Makefile
+++ b/drivers/gpu/drm/bridge/Makefile
@@ -5,4 +5,5 @@ obj-$(CONFIG_DRM_DW_HDMI) += dw-hdmi.o
 obj-$(CONFIG_DRM_DW_HDMI_AHB_AUDIO) += dw-hdmi-ahb-audio.o
 obj-$(CONFIG_DRM_NXP_PTN3460) += nxp-ptn3460.o
 obj-$(CONFIG_DRM_PARADE_PS8622) += parade-ps8622.o
+obj-$(CONFIG_DRM_SII902X) += sii902x.o
 obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix/
diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
new file mode 100644
index 000..d46bf98
--- /dev/null
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -0,0 +1,459 @@
+/*
+ * Copyright (C) 2014 Atmel
+ *   Bo Shen 
+ *
+ * Authors:  Bo Shen 
+ *   Boris Brezillon 
+ *   Wu, Songjun 
+ *
+ *
+ * Copyright (C) 2010-2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define SIL902X_TPI_VIDEO_DATA 0x0
+
+#define SIL902X_TPI_PIXEL_REPETITION   0x8
+#define SIL902X_TPI_AVI_PIXEL_REP_BUS_24BIT BIT(5)
+#define SIL902X_TPI_AVI_PIXEL_REP_RISING_EDGE   BIT(4)
+#define SIL902X_TPI_AVI_PIXEL_REP_4X   3
+#define SIL902X_TPI_AVI_PIXEL_REP_2X   1
+#define SIL902X_TPI_AVI_PIXEL_REP_NONE 0
+#define SIL902X_TPI_CLK_RATIO_HALF (0 << 6)
+#define SIL902X_TPI_CLK_RATIO_1X   (1 << 6)
+#define SIL902X_TPI_CLK_RATIO_2X   (2 << 6)
+#define SIL902X_TPI_CLK_RATIO_4X   (3 << 6)
+
+#define SIL902X_TPI_AVI_IN_FORMAT  0x9
+#define SIL902X_TPI_AVI_INPUT_BITMODE_12BITBIT(7)
+#define SIL902X_TPI_AVI_INPUT_DITHER   BIT(6)
+#define SIL902X_TPI_AVI_INPUT_RANGE_LIMITED(2 << 2)
+#define SIL902X_TPI_AVI_INPUT_RANGE_FULL   (1 << 2)
+#define SIL902X_TPI_AVI_INPUT_RANGE_AUTO   (0 << 2)
+#define SIL902X_TPI_AVI_INPUT_COLORSPACE_BLACK (3 << 0)
+#define SIL902X_TPI_AVI_INPUT_COLORSPACE_YUV422(2 << 0)
+#define SIL902X_TPI_AVI_INPUT_COLORSPACE_YUV444(1 << 0)
+#define SIL902X_TPI_AVI_INPUT_COLORSPACE_RGB   (0 << 0)
+
+#define SIL902X_TPI_AVI_INFOFRAME  0x0c
+
+#define SIL902X_SYS_CTRL_DATA  0x1a
+#define SIL902X_SYS_CTRL_PWR_DWN   BIT(4)
+#define SIL902X_SYS_CTRL_AV_MUTE   BIT(3)
+#define SIL902X_SYS_CTRL_DDC_BUS_REQ   BIT(2)
+#define SIL902X_SYS_CTRL_DDC_BUS_GRTD  BIT(1)
+#define SIL902X_SYS_CTRL_OUTPUT_MODE   BIT(0)
+#define SIL902X_SYS_CTRL_OUTPUT_HDMI   1
+#define SIL902X_SYS_

[PATCH v2 20/20] drm/bridge: dw-hdmi: Use drm_atomic_helper_best_encoder()

2016-06-07 Thread Boris Brezillon
We have a 1:1 relationship between connectors and encoders, which means
we can rely on the drm_atomic_helper_best_encoder() behavior.

We still have to explicitly assign ->best_encoder() to
drm_atomic_helper_best_encoder(), because the automated fallback to
drm_atomic_helper_best_encoder() when ->best_encoder() is NULL is only
available when the DRM device is using the atomic helpers, and this bridge
is compatible with non-atomic and atomic devices.

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/bridge/dw-hdmi.c | 11 +--
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/bridge/dw-hdmi.c b/drivers/gpu/drm/bridge/dw-hdmi.c
index c9d9412..70b1f7d 100644
--- a/drivers/gpu/drm/bridge/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/dw-hdmi.c
@@ -1476,15 +1476,6 @@ dw_hdmi_connector_mode_valid(struct drm_connector 
*connector,
return mode_status;
 }

-static struct drm_encoder *dw_hdmi_connector_best_encoder(struct drm_connector
-  *connector)
-{
-   struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi,
-connector);
-
-   return hdmi->encoder;
-}
-
 static void dw_hdmi_connector_destroy(struct drm_connector *connector)
 {
drm_connector_unregister(connector);
@@ -1525,7 +1516,7 @@ static const struct drm_connector_funcs 
dw_hdmi_atomic_connector_funcs = {
 static const struct drm_connector_helper_funcs dw_hdmi_connector_helper_funcs 
= {
.get_modes = dw_hdmi_connector_get_modes,
.mode_valid = dw_hdmi_connector_mode_valid,
-   .best_encoder = dw_hdmi_connector_best_encoder,
+   .best_encoder = drm_atomic_helper_best_encoder,
 };

 static const struct drm_bridge_funcs dw_hdmi_bridge_funcs = {
-- 
2.7.4



[PATCH v2 19/20] drm/bridge: ps8622: Rely on the default ->best_encoder() behavior

2016-06-07 Thread Boris Brezillon
We have a 1:1 relationship between connectors and encoders, and the driver
is relying on the atomic helpers: we can drop the custom ->best_encoder(),
and let the core call drm_atomic_helper_best_encoder() for us.

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/bridge/parade-ps8622.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/drivers/gpu/drm/bridge/parade-ps8622.c 
b/drivers/gpu/drm/bridge/parade-ps8622.c
index be881e9..5cd8dd7 100644
--- a/drivers/gpu/drm/bridge/parade-ps8622.c
+++ b/drivers/gpu/drm/bridge/parade-ps8622.c
@@ -474,18 +474,8 @@ static int ps8622_get_modes(struct drm_connector 
*connector)
return drm_panel_get_modes(ps8622->panel);
 }

-static struct drm_encoder *ps8622_best_encoder(struct drm_connector *connector)
-{
-   struct ps8622_bridge *ps8622;
-
-   ps8622 = connector_to_ps8622(connector);
-
-   return ps8622->bridge.encoder;
-}
-
 static const struct drm_connector_helper_funcs ps8622_connector_helper_funcs = 
{
.get_modes = ps8622_get_modes,
-   .best_encoder = ps8622_best_encoder,
 };

 static enum drm_connector_status ps8622_detect(struct drm_connector *connector,
-- 
2.7.4



[PATCH v2 18/20] drm/bridge: ptn3460: Rely on the default ->best_encoder() behavior

2016-06-07 Thread Boris Brezillon
We have a 1:1 relationship between connectors and encoders, and the driver
is relying on the atomic helpers: we can drop the custom ->best_encoder(),
and let the core call drm_atomic_helper_best_encoder() for us.

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/bridge/nxp-ptn3460.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/gpu/drm/bridge/nxp-ptn3460.c 
b/drivers/gpu/drm/bridge/nxp-ptn3460.c
index 7ecd59f..93f3dac 100644
--- a/drivers/gpu/drm/bridge/nxp-ptn3460.c
+++ b/drivers/gpu/drm/bridge/nxp-ptn3460.c
@@ -235,16 +235,8 @@ out:
return num_modes;
 }

-static struct drm_encoder *ptn3460_best_encoder(struct drm_connector 
*connector)
-{
-   struct ptn3460_bridge *ptn_bridge = connector_to_ptn3460(connector);
-
-   return ptn_bridge->bridge.encoder;
-}
-
 static const struct drm_connector_helper_funcs ptn3460_connector_helper_funcs 
= {
.get_modes = ptn3460_get_modes,
-   .best_encoder = ptn3460_best_encoder,
 };

 static enum drm_connector_status ptn3460_detect(struct drm_connector 
*connector,
-- 
2.7.4



[PATCH v2 17/20] drm/bridge: anx78xx: Rely on the default ->best_encoder() behavior

2016-06-07 Thread Boris Brezillon
We have a 1:1 relationship between connectors and encoders, and the driver
is relying on the atomic helpers: we can drop the custom ->best_encoder(),
and let the core call drm_atomic_helper_best_encoder() for us.

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/bridge/analogix-anx78xx.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix-anx78xx.c 
b/drivers/gpu/drm/bridge/analogix-anx78xx.c
index d087b05..f9f03bc 100644
--- a/drivers/gpu/drm/bridge/analogix-anx78xx.c
+++ b/drivers/gpu/drm/bridge/analogix-anx78xx.c
@@ -986,16 +986,8 @@ unlock:
return num_modes;
 }

-static struct drm_encoder *anx78xx_best_encoder(struct drm_connector 
*connector)
-{
-   struct anx78xx *anx78xx = connector_to_anx78xx(connector);
-
-   return anx78xx->bridge.encoder;
-}
-
 static const struct drm_connector_helper_funcs anx78xx_connector_helper_funcs 
= {
.get_modes = anx78xx_get_modes,
-   .best_encoder = anx78xx_best_encoder,
 };

 static enum drm_connector_status anx78xx_detect(struct drm_connector 
*connector,
-- 
2.7.4



[PATCH v2 16/20] drm: omap: Rely on the default ->best_encoder() behavior

2016-06-07 Thread Boris Brezillon
We have a 1:1 relationship between connectors and encoders and the
driver is relying on the atomic helpers: we can drop the custom
->best_encoder() implementation and let the core call
drm_atomic_helper_best_encoder() for us.

Signed-off-by: Boris Brezillon 
Reviewed-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/omap_connector.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_connector.c 
b/drivers/gpu/drm/omapdrm/omap_connector.c
index ce2d67b..137fe69 100644
--- a/drivers/gpu/drm/omapdrm/omap_connector.c
+++ b/drivers/gpu/drm/omapdrm/omap_connector.c
@@ -32,7 +32,6 @@
 struct omap_connector {
struct drm_connector base;
struct omap_dss_device *dssdev;
-   struct drm_encoder *encoder;
bool hdmi_mode;
 };

@@ -256,13 +255,6 @@ static int omap_connector_mode_valid(struct drm_connector 
*connector,
return ret;
 }

-struct drm_encoder *omap_connector_attached_encoder(
-   struct drm_connector *connector)
-{
-   struct omap_connector *omap_connector = to_omap_connector(connector);
-   return omap_connector->encoder;
-}
-
 static const struct drm_connector_funcs omap_connector_funcs = {
.dpms = drm_atomic_helper_connector_dpms,
.reset = drm_atomic_helper_connector_reset,
@@ -276,7 +268,6 @@ static const struct drm_connector_funcs 
omap_connector_funcs = {
 static const struct drm_connector_helper_funcs omap_connector_helper_funcs = {
.get_modes = omap_connector_get_modes,
.mode_valid = omap_connector_mode_valid,
-   .best_encoder = omap_connector_attached_encoder,
 };

 /* initialize connector */
@@ -296,7 +287,6 @@ struct drm_connector *omap_connector_init(struct drm_device 
*dev,
goto fail;

omap_connector->dssdev = dssdev;
-   omap_connector->encoder = encoder;

connector = &omap_connector->base;

-- 
2.7.4



[PATCH v2 15/20] drm: virtgpu: Rely on the default ->best_encoder() behavior

2016-06-07 Thread Boris Brezillon
The virtgpu output exposes a 1:1 relationship between connectors and
encoders and the driver is relying on the atomic helpers: we can drop
the custom ->best_encoder() implementation and let the core call
drm_atomic_helper_best_encoder() for us.

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/virtio/virtgpu_display.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c 
b/drivers/gpu/drm/virtio/virtgpu_display.c
index d4305da..4d41dcb 100644
--- a/drivers/gpu/drm/virtio/virtgpu_display.c
+++ b/drivers/gpu/drm/virtio/virtgpu_display.c
@@ -341,15 +341,6 @@ static int virtio_gpu_conn_mode_valid(struct drm_connector 
*connector,
return MODE_BAD;
 }

-static struct drm_encoder*
-virtio_gpu_best_encoder(struct drm_connector *connector)
-{
-   struct virtio_gpu_output *virtio_gpu_output =
-   drm_connector_to_virtio_gpu_output(connector);
-
-   return &virtio_gpu_output->enc;
-}
-
 static const struct drm_encoder_helper_funcs virtio_gpu_enc_helper_funcs = {
.mode_set   = virtio_gpu_enc_mode_set,
.enable = virtio_gpu_enc_enable,
@@ -359,7 +350,6 @@ static const struct drm_encoder_helper_funcs 
virtio_gpu_enc_helper_funcs = {
 static const struct drm_connector_helper_funcs virtio_gpu_conn_helper_funcs = {
.get_modes= virtio_gpu_conn_get_modes,
.mode_valid   = virtio_gpu_conn_mode_valid,
-   .best_encoder = virtio_gpu_best_encoder,
 };

 static enum drm_connector_status virtio_gpu_conn_detect(
-- 
2.7.4



[PATCH v2 14/20] drm: vc4: Rely on the default ->best_encoder() behavior

2016-06-07 Thread Boris Brezillon
All outputs have a 1:1 relationship between connectors and encoders and
the driver is relying on the atomic helpers: we can drop the custom
->best_encoder() implementations and let the core call
drm_atomic_helper_best_encoder() for us.

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/vc4/vc4_dpi.c  | 9 -
 drivers/gpu/drm/vc4/vc4_hdmi.c | 9 -
 2 files changed, 18 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_dpi.c b/drivers/gpu/drm/vc4/vc4_dpi.c
index 9817dbf..dba1114 100644
--- a/drivers/gpu/drm/vc4/vc4_dpi.c
+++ b/drivers/gpu/drm/vc4/vc4_dpi.c
@@ -208,14 +208,6 @@ static int vc4_dpi_connector_get_modes(struct 
drm_connector *connector)
return 0;
 }

-static struct drm_encoder *
-vc4_dpi_connector_best_encoder(struct drm_connector *connector)
-{
-   struct vc4_dpi_connector *dpi_connector =
-   to_vc4_dpi_connector(connector);
-   return dpi_connector->encoder;
-}
-
 static const struct drm_connector_funcs vc4_dpi_connector_funcs = {
.dpms = drm_atomic_helper_connector_dpms,
.detect = vc4_dpi_connector_detect,
@@ -228,7 +220,6 @@ static const struct drm_connector_funcs 
vc4_dpi_connector_funcs = {

 static const struct drm_connector_helper_funcs vc4_dpi_connector_helper_funcs 
= {
.get_modes = vc4_dpi_connector_get_modes,
-   .best_encoder = vc4_dpi_connector_best_encoder,
 };

 static struct drm_connector *vc4_dpi_connector_init(struct drm_device *dev,
diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index fd2644d..68df91c 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -208,14 +208,6 @@ static int vc4_hdmi_connector_get_modes(struct 
drm_connector *connector)
return ret;
 }

-static struct drm_encoder *
-vc4_hdmi_connector_best_encoder(struct drm_connector *connector)
-{
-   struct vc4_hdmi_connector *hdmi_connector =
-   to_vc4_hdmi_connector(connector);
-   return hdmi_connector->encoder;
-}
-
 static const struct drm_connector_funcs vc4_hdmi_connector_funcs = {
.dpms = drm_atomic_helper_connector_dpms,
.detect = vc4_hdmi_connector_detect,
@@ -228,7 +220,6 @@ static const struct drm_connector_funcs 
vc4_hdmi_connector_funcs = {

 static const struct drm_connector_helper_funcs vc4_hdmi_connector_helper_funcs 
= {
.get_modes = vc4_hdmi_connector_get_modes,
-   .best_encoder = vc4_hdmi_connector_best_encoder,
 };

 static struct drm_connector *vc4_hdmi_connector_init(struct drm_device *dev,
-- 
2.7.4



[PATCH v2 13/20] drm: tegra: Rely on the default ->best_encoder() behavior

2016-06-07 Thread Boris Brezillon
All outputs have a 1:1 relationship between connectors and encoders
and the driver is relying on the atomic helpers: we can drop the custom
->best_encoder() implementation and let the core call
drm_atomic_helper_best_encoder() for us.

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/tegra/drm.h| 2 --
 drivers/gpu/drm/tegra/dsi.c| 1 -
 drivers/gpu/drm/tegra/hdmi.c   | 1 -
 drivers/gpu/drm/tegra/output.c | 8 
 drivers/gpu/drm/tegra/rgb.c| 1 -
 drivers/gpu/drm/tegra/sor.c| 1 -
 6 files changed, 14 deletions(-)

diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h
index f52d6cb2..0ddcce1 100644
--- a/drivers/gpu/drm/tegra/drm.h
+++ b/drivers/gpu/drm/tegra/drm.h
@@ -239,8 +239,6 @@ int tegra_output_init(struct drm_device *drm, struct 
tegra_output *output);
 void tegra_output_exit(struct tegra_output *output);

 int tegra_output_connector_get_modes(struct drm_connector *connector);
-struct drm_encoder *
-tegra_output_connector_best_encoder(struct drm_connector *connector);
 enum drm_connector_status
 tegra_output_connector_detect(struct drm_connector *connector, bool force);
 void tegra_output_connector_destroy(struct drm_connector *connector);
diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c
index d1239eb..099cccb 100644
--- a/drivers/gpu/drm/tegra/dsi.c
+++ b/drivers/gpu/drm/tegra/dsi.c
@@ -794,7 +794,6 @@ tegra_dsi_connector_mode_valid(struct drm_connector 
*connector,
 static const struct drm_connector_helper_funcs 
tegra_dsi_connector_helper_funcs = {
.get_modes = tegra_output_connector_get_modes,
.mode_valid = tegra_dsi_connector_mode_valid,
-   .best_encoder = tegra_output_connector_best_encoder,
 };

 static const struct drm_encoder_funcs tegra_dsi_encoder_funcs = {
diff --git a/drivers/gpu/drm/tegra/hdmi.c b/drivers/gpu/drm/tegra/hdmi.c
index b7ef492..2fdb879 100644
--- a/drivers/gpu/drm/tegra/hdmi.c
+++ b/drivers/gpu/drm/tegra/hdmi.c
@@ -806,7 +806,6 @@ static const struct drm_connector_helper_funcs
 tegra_hdmi_connector_helper_funcs = {
.get_modes = tegra_output_connector_get_modes,
.mode_valid = tegra_hdmi_connector_mode_valid,
-   .best_encoder = tegra_output_connector_best_encoder,
 };

 static const struct drm_encoder_funcs tegra_hdmi_encoder_funcs = {
diff --git a/drivers/gpu/drm/tegra/output.c b/drivers/gpu/drm/tegra/output.c
index 46664b6..1480f6a 100644
--- a/drivers/gpu/drm/tegra/output.c
+++ b/drivers/gpu/drm/tegra/output.c
@@ -42,14 +42,6 @@ int tegra_output_connector_get_modes(struct drm_connector 
*connector)
return err;
 }

-struct drm_encoder *
-tegra_output_connector_best_encoder(struct drm_connector *connector)
-{
-   struct tegra_output *output = connector_to_output(connector);
-
-   return &output->encoder;
-}
-
 enum drm_connector_status
 tegra_output_connector_detect(struct drm_connector *connector, bool force)
 {
diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c
index e246334..a131b44 100644
--- a/drivers/gpu/drm/tegra/rgb.c
+++ b/drivers/gpu/drm/tegra/rgb.c
@@ -112,7 +112,6 @@ tegra_rgb_connector_mode_valid(struct drm_connector 
*connector,
 static const struct drm_connector_helper_funcs 
tegra_rgb_connector_helper_funcs = {
.get_modes = tegra_output_connector_get_modes,
.mode_valid = tegra_rgb_connector_mode_valid,
-   .best_encoder = tegra_output_connector_best_encoder,
 };

 static const struct drm_encoder_funcs tegra_rgb_encoder_funcs = {
diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c
index 757c6e8..34958d7 100644
--- a/drivers/gpu/drm/tegra/sor.c
+++ b/drivers/gpu/drm/tegra/sor.c
@@ -1087,7 +1087,6 @@ tegra_sor_connector_mode_valid(struct drm_connector 
*connector,
 static const struct drm_connector_helper_funcs 
tegra_sor_connector_helper_funcs = {
.get_modes = tegra_sor_connector_get_modes,
.mode_valid = tegra_sor_connector_mode_valid,
-   .best_encoder = tegra_output_connector_best_encoder,
 };

 static const struct drm_encoder_funcs tegra_sor_encoder_funcs = {
-- 
2.7.4



[PATCH v2 12/20] drm: sun4i: Rely on the default ->best_encoder() behavior

2016-06-07 Thread Boris Brezillon
All outputs have a 1:1 relationship between connectors and encoders
and the driver is relying on the atomic helpers: we can drop the custom
->best_encoder() implementations and let the core call
drm_atomic_helper_best_encoder() for us.

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/sun4i/sun4i_rgb.c | 10 --
 drivers/gpu/drm/sun4i/sun4i_tv.c  |  9 -
 2 files changed, 19 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_rgb.c 
b/drivers/gpu/drm/sun4i/sun4i_rgb.c
index ab64948..442cfe2 100644
--- a/drivers/gpu/drm/sun4i/sun4i_rgb.c
+++ b/drivers/gpu/drm/sun4i/sun4i_rgb.c
@@ -90,19 +90,9 @@ static int sun4i_rgb_mode_valid(struct drm_connector 
*connector,
return MODE_OK;
 }

-static struct drm_encoder *
-sun4i_rgb_best_encoder(struct drm_connector *connector)
-{
-   struct sun4i_rgb *rgb =
-   drm_connector_to_sun4i_rgb(connector);
-
-   return &rgb->encoder;
-}
-
 static struct drm_connector_helper_funcs sun4i_rgb_con_helper_funcs = {
.get_modes  = sun4i_rgb_get_modes,
.mode_valid = sun4i_rgb_mode_valid,
-   .best_encoder   = sun4i_rgb_best_encoder,
 };

 static enum drm_connector_status
diff --git a/drivers/gpu/drm/sun4i/sun4i_tv.c b/drivers/gpu/drm/sun4i/sun4i_tv.c
index bc047f9..b841478 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_tv.c
@@ -526,18 +526,9 @@ static int sun4i_tv_comp_mode_valid(struct drm_connector 
*connector,
return MODE_OK;
 }

-static struct drm_encoder *
-sun4i_tv_comp_best_encoder(struct drm_connector *connector)
-{
-   struct sun4i_tv *tv = drm_connector_to_sun4i_tv(connector);
-
-   return &tv->encoder;
-}
-
 static struct drm_connector_helper_funcs sun4i_tv_comp_connector_helper_funcs 
= {
.get_modes  = sun4i_tv_comp_get_modes,
.mode_valid = sun4i_tv_comp_mode_valid,
-   .best_encoder   = sun4i_tv_comp_best_encoder,
 };

 static enum drm_connector_status
-- 
2.7.4



[PATCH v2 11/20] drm: sti: Rely on the default ->best_encoder() behavior

2016-06-07 Thread Boris Brezillon
All outputs have a 1:1 relationship between connectors and encoders
and the driver is relying on the atomic helpers: we can drop the custom
->best_encoder() implementations and let the core call
drm_atomic_helper_best_encoder() for us.

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/sti/sti_dvo.c  | 10 --
 drivers/gpu/drm/sti/sti_hda.c  | 10 --
 drivers/gpu/drm/sti/sti_hdmi.c | 10 --
 3 files changed, 30 deletions(-)

diff --git a/drivers/gpu/drm/sti/sti_dvo.c b/drivers/gpu/drm/sti/sti_dvo.c
index 25f7663..d5627d1 100644
--- a/drivers/gpu/drm/sti/sti_dvo.c
+++ b/drivers/gpu/drm/sti/sti_dvo.c
@@ -384,20 +384,10 @@ static int sti_dvo_connector_mode_valid(struct 
drm_connector *connector,
return MODE_OK;
 }

-struct drm_encoder *sti_dvo_best_encoder(struct drm_connector *connector)
-{
-   struct sti_dvo_connector *dvo_connector
-   = to_sti_dvo_connector(connector);
-
-   /* Best encoder is the one associated during connector creation */
-   return dvo_connector->encoder;
-}
-
 static const
 struct drm_connector_helper_funcs sti_dvo_connector_helper_funcs = {
.get_modes = sti_dvo_connector_get_modes,
.mode_valid = sti_dvo_connector_mode_valid,
-   .best_encoder = sti_dvo_best_encoder,
 };

 static enum drm_connector_status
diff --git a/drivers/gpu/drm/sti/sti_hda.c b/drivers/gpu/drm/sti/sti_hda.c
index f7d3464..c4649f5 100644
--- a/drivers/gpu/drm/sti/sti_hda.c
+++ b/drivers/gpu/drm/sti/sti_hda.c
@@ -676,20 +676,10 @@ static int sti_hda_connector_mode_valid(struct 
drm_connector *connector,
return MODE_OK;
 }

-struct drm_encoder *sti_hda_best_encoder(struct drm_connector *connector)
-{
-   struct sti_hda_connector *hda_connector
-   = to_sti_hda_connector(connector);
-
-   /* Best encoder is the one associated during connector creation */
-   return hda_connector->encoder;
-}
-
 static const
 struct drm_connector_helper_funcs sti_hda_connector_helper_funcs = {
.get_modes = sti_hda_connector_get_modes,
.mode_valid = sti_hda_connector_mode_valid,
-   .best_encoder = sti_hda_best_encoder,
 };

 static enum drm_connector_status
diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c
index 6ef0715..dc9ab6e 100644
--- a/drivers/gpu/drm/sti/sti_hdmi.c
+++ b/drivers/gpu/drm/sti/sti_hdmi.c
@@ -897,20 +897,10 @@ static int sti_hdmi_connector_mode_valid(struct 
drm_connector *connector,
return MODE_OK;
 }

-struct drm_encoder *sti_hdmi_best_encoder(struct drm_connector *connector)
-{
-   struct sti_hdmi_connector *hdmi_connector
-   = to_sti_hdmi_connector(connector);
-
-   /* Best encoder is the one associated during connector creation */
-   return hdmi_connector->encoder;
-}
-
 static const
 struct drm_connector_helper_funcs sti_hdmi_connector_helper_funcs = {
.get_modes = sti_hdmi_connector_get_modes,
.mode_valid = sti_hdmi_connector_mode_valid,
-   .best_encoder = sti_hdmi_best_encoder,
 };

 /* get detection status of display device */
-- 
2.7.4



[PATCH v2 10/20] drm: rockchip: Rely on the default ->best_encoder() behavior

2016-06-07 Thread Boris Brezillon
All outputs have a 1:1 relationship between connectors and encoders
and the driver is relying on the atomic helpers: we can drop the custom
->best_encoder() implementations  and let the core call
drm_atomic_helper_best_encoder() for us.

Signed-off-by: Boris Brezillon 
Acked-by: Mark Yao 
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 9 -
 drivers/gpu/drm/rockchip/inno_hdmi.c   | 9 -
 2 files changed, 18 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c 
b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index dedc65b..ca22e5e 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -964,18 +964,9 @@ static enum drm_mode_status dw_mipi_dsi_mode_valid(
return mode_status;
 }

-static struct drm_encoder *dw_mipi_dsi_connector_best_encoder(
-   struct drm_connector *connector)
-{
-   struct dw_mipi_dsi *dsi = con_to_dsi(connector);
-
-   return &dsi->encoder;
-}
-
 static struct drm_connector_helper_funcs dw_mipi_dsi_connector_helper_funcs = {
.get_modes = dw_mipi_dsi_connector_get_modes,
.mode_valid = dw_mipi_dsi_mode_valid,
-   .best_encoder = dw_mipi_dsi_connector_best_encoder,
 };

 static enum drm_connector_status
diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c 
b/drivers/gpu/drm/rockchip/inno_hdmi.c
index f8b4feb..006260d 100644
--- a/drivers/gpu/drm/rockchip/inno_hdmi.c
+++ b/drivers/gpu/drm/rockchip/inno_hdmi.c
@@ -579,14 +579,6 @@ inno_hdmi_connector_mode_valid(struct drm_connector 
*connector,
return MODE_OK;
 }

-static struct drm_encoder *
-inno_hdmi_connector_best_encoder(struct drm_connector *connector)
-{
-   struct inno_hdmi *hdmi = to_inno_hdmi(connector);
-
-   return &hdmi->encoder;
-}
-
 static int
 inno_hdmi_probe_single_connector_modes(struct drm_connector *connector,
   uint32_t maxX, uint32_t maxY)
@@ -613,7 +605,6 @@ static struct drm_connector_funcs inno_hdmi_connector_funcs 
= {
 static struct drm_connector_helper_funcs inno_hdmi_connector_helper_funcs = {
.get_modes = inno_hdmi_connector_get_modes,
.mode_valid = inno_hdmi_connector_mode_valid,
-   .best_encoder = inno_hdmi_connector_best_encoder,
 };

 static int inno_hdmi_register(struct drm_device *drm, struct inno_hdmi *hdmi)
-- 
2.7.4



[PATCH v2 09/20] drm: rcar-du: Rely on the default ->best_encoder() behavior

2016-06-07 Thread Boris Brezillon
All outputs have a 1:1 relationship between connectors and encoders,
and the driver is relying on the atomic helpers: we can drop the custom
->best_encoder() implementations and let the core call
drm_atomic_helper_best_encoder() for us.

Signed-off-by: Boris Brezillon 
Reviewed-by: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 12 
 drivers/gpu/drm/rcar-du/rcar_du_encoder.h |  3 ---
 drivers/gpu/drm/rcar-du/rcar_du_hdmicon.c |  1 -
 drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c |  1 -
 drivers/gpu/drm/rcar-du/rcar_du_vgacon.c  |  3 ---
 5 files changed, 20 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c 
b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
index 4e939e4..55149e9 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
@@ -27,18 +27,6 @@
 #include "rcar_du_vgacon.h"

 /* 
-
- * Common connector functions
- */
-
-struct drm_encoder *
-rcar_du_connector_best_encoder(struct drm_connector *connector)
-{
-   struct rcar_du_connector *rcon = to_rcar_connector(connector);
-
-   return rcar_encoder_to_drm_encoder(rcon->encoder);
-}
-
-/* 
-
  * Encoder
  */

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.h 
b/drivers/gpu/drm/rcar-du/rcar_du_encoder.h
index 719b6f2a..a8669c3 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_encoder.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.h
@@ -49,9 +49,6 @@ struct rcar_du_connector {
 #define to_rcar_connector(c) \
container_of(c, struct rcar_du_connector, connector)

-struct drm_encoder *
-rcar_du_connector_best_encoder(struct drm_connector *connector);
-
 int rcar_du_encoder_init(struct rcar_du_device *rcdu,
 enum rcar_du_encoder_type type,
 enum rcar_du_output output,
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_hdmicon.c 
b/drivers/gpu/drm/rcar-du/rcar_du_hdmicon.c
index 6c92714..612b4d5 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_hdmicon.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_hdmicon.c
@@ -52,7 +52,6 @@ static int rcar_du_hdmi_connector_mode_valid(struct 
drm_connector *connector,
 static const struct drm_connector_helper_funcs connector_helper_funcs = {
.get_modes = rcar_du_hdmi_connector_get_modes,
.mode_valid = rcar_du_hdmi_connector_mode_valid,
-   .best_encoder = rcar_du_connector_best_encoder,
 };

 static enum drm_connector_status
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c 
b/drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c
index e905f5d..6afd0af 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c
@@ -59,7 +59,6 @@ static int rcar_du_lvds_connector_get_modes(struct 
drm_connector *connector)

 static const struct drm_connector_helper_funcs connector_helper_funcs = {
.get_modes = rcar_du_lvds_connector_get_modes,
-   .best_encoder = rcar_du_connector_best_encoder,
 };

 static enum drm_connector_status
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vgacon.c 
b/drivers/gpu/drm/rcar-du/rcar_du_vgacon.c
index 9d7e5c9..8d6125c 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_vgacon.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vgacon.c
@@ -28,7 +28,6 @@ static int rcar_du_vga_connector_get_modes(struct 
drm_connector *connector)

 static const struct drm_connector_helper_funcs connector_helper_funcs = {
.get_modes = rcar_du_vga_connector_get_modes,
-   .best_encoder = rcar_du_connector_best_encoder,
 };

 static enum drm_connector_status
@@ -79,7 +78,5 @@ int rcar_du_vga_connector_init(struct rcar_du_device *rcdu,
if (ret < 0)
return ret;

-   rcon->encoder = renc;
-
return 0;
 }
-- 
2.7.4



[PATCH v2 08/20] drm: msm: Rely on the default ->best_encoder() behavior where appropriate

2016-06-07 Thread Boris Brezillon
For all outputs except DSI we have a 1:1 relationship between connectors
and encoders and the driver is relying on the atomic helpers: we can
drop the custom ->best_encoder() and let the core call
drm_atomic_helper_best_encoder() for us.

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/msm/edp/edp_connector.c| 10 --
 drivers/gpu/drm/msm/hdmi/hdmi_connector.c  |  8 
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_lvds_connector.c |  9 -
 3 files changed, 27 deletions(-)

diff --git a/drivers/gpu/drm/msm/edp/edp_connector.c 
b/drivers/gpu/drm/msm/edp/edp_connector.c
index 72360cd..5960628 100644
--- a/drivers/gpu/drm/msm/edp/edp_connector.c
+++ b/drivers/gpu/drm/msm/edp/edp_connector.c
@@ -91,15 +91,6 @@ static int edp_connector_mode_valid(struct drm_connector 
*connector,
return MODE_OK;
 }

-static struct drm_encoder *
-edp_connector_best_encoder(struct drm_connector *connector)
-{
-   struct edp_connector *edp_connector = to_edp_connector(connector);
-
-   DBG("");
-   return edp_connector->edp->encoder;
-}
-
 static const struct drm_connector_funcs edp_connector_funcs = {
.dpms = drm_atomic_helper_connector_dpms,
.detect = edp_connector_detect,
@@ -113,7 +104,6 @@ static const struct drm_connector_funcs edp_connector_funcs 
= {
 static const struct drm_connector_helper_funcs edp_connector_helper_funcs = {
.get_modes = edp_connector_get_modes,
.mode_valid = edp_connector_mode_valid,
-   .best_encoder = edp_connector_best_encoder,
 };

 /* initialize connector */
diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_connector.c 
b/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
index b15d726..a2515b4 100644
--- a/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
+++ b/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
@@ -406,13 +406,6 @@ static int msm_hdmi_connector_mode_valid(struct 
drm_connector *connector,
return 0;
 }

-static struct drm_encoder *
-msm_hdmi_connector_best_encoder(struct drm_connector *connector)
-{
-   struct hdmi_connector *hdmi_connector = to_hdmi_connector(connector);
-   return hdmi_connector->hdmi->encoder;
-}
-
 static const struct drm_connector_funcs hdmi_connector_funcs = {
.dpms = drm_atomic_helper_connector_dpms,
.detect = hdmi_connector_detect,
@@ -426,7 +419,6 @@ static const struct drm_connector_funcs 
hdmi_connector_funcs = {
 static const struct drm_connector_helper_funcs msm_hdmi_connector_helper_funcs 
= {
.get_modes = msm_hdmi_connector_get_modes,
.mode_valid = msm_hdmi_connector_mode_valid,
-   .best_encoder = msm_hdmi_connector_best_encoder,
 };

 /* initialize connector */
diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_lvds_connector.c 
b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_lvds_connector.c
index 2648cd7..353429b 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_lvds_connector.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_lvds_connector.c
@@ -90,14 +90,6 @@ static int mdp4_lvds_connector_mode_valid(struct 
drm_connector *connector,
return MODE_OK;
 }

-static struct drm_encoder *
-mdp4_lvds_connector_best_encoder(struct drm_connector *connector)
-{
-   struct mdp4_lvds_connector *mdp4_lvds_connector =
-   to_mdp4_lvds_connector(connector);
-   return mdp4_lvds_connector->encoder;
-}
-
 static const struct drm_connector_funcs mdp4_lvds_connector_funcs = {
.dpms = drm_atomic_helper_connector_dpms,
.detect = mdp4_lvds_connector_detect,
@@ -111,7 +103,6 @@ static const struct drm_connector_funcs 
mdp4_lvds_connector_funcs = {
 static const struct drm_connector_helper_funcs 
mdp4_lvds_connector_helper_funcs = {
.get_modes = mdp4_lvds_connector_get_modes,
.mode_valid = mdp4_lvds_connector_mode_valid,
-   .best_encoder = mdp4_lvds_connector_best_encoder,
 };

 /* initialize connector */
-- 
2.7.4



[PATCH v2 07/20] drm: mediatek: Rely on the default ->best_encoder() behavior

2016-06-07 Thread Boris Brezillon
We have a 1:1 relationship between connectors and encoders and the
driver is relying on the atomic helpers: we can drop the custom
->best_encoder() implementation and let the core call
drm_atomic_helper_best_encoder() for us.

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/mediatek/mtk_dsi.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c 
b/drivers/gpu/drm/mediatek/mtk_dsi.c
index 2d808e5..7343ffc 100644
--- a/drivers/gpu/drm/mediatek/mtk_dsi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
@@ -575,14 +575,6 @@ static int mtk_dsi_connector_get_modes(struct 
drm_connector *connector)
return drm_panel_get_modes(dsi->panel);
 }

-static struct drm_encoder *mtk_dsi_connector_best_encoder(
-   struct drm_connector *connector)
-{
-   struct mtk_dsi *dsi = connector_to_dsi(connector);
-
-   return &dsi->encoder;
-}
-
 static const struct drm_encoder_helper_funcs mtk_dsi_encoder_helper_funcs = {
.mode_fixup = mtk_dsi_encoder_mode_fixup,
.mode_set = mtk_dsi_encoder_mode_set,
@@ -603,7 +595,6 @@ static const struct drm_connector_funcs 
mtk_dsi_connector_funcs = {
 static const struct drm_connector_helper_funcs
mtk_dsi_connector_helper_funcs = {
.get_modes = mtk_dsi_connector_get_modes,
-   .best_encoder = mtk_dsi_connector_best_encoder,
 };

 static int mtk_drm_attach_bridge(struct drm_bridge *bridge,
-- 
2.7.4



[PATCH v2 06/20] drm: i915: Rely on the default ->best_encoder() behavior where appropriate

2016-06-07 Thread Boris Brezillon
For all outputs except dp_mst, we have a 1:1 relationship between
connectors and encoders and the driver is relying on the atomic helpers:
we can drop the custom ->best_encoder() implementation and let the core
call drm_atomic_helper_best_encoder() for us.

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/i915/intel_crt.c | 1 -
 drivers/gpu/drm/i915/intel_display.c | 8 
 drivers/gpu/drm/i915/intel_dp.c  | 1 -
 drivers/gpu/drm/i915/intel_drv.h | 1 -
 drivers/gpu/drm/i915/intel_dsi.c | 1 -
 drivers/gpu/drm/i915/intel_dvo.c | 1 -
 drivers/gpu/drm/i915/intel_hdmi.c| 1 -
 drivers/gpu/drm/i915/intel_lvds.c| 1 -
 drivers/gpu/drm/i915/intel_sdvo.c| 1 -
 drivers/gpu/drm/i915/intel_tv.c  | 1 -
 10 files changed, 17 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
index 3fbb6fc..bd0cd68 100644
--- a/drivers/gpu/drm/i915/intel_crt.c
+++ b/drivers/gpu/drm/i915/intel_crt.c
@@ -753,7 +753,6 @@ static const struct drm_connector_funcs 
intel_crt_connector_funcs = {
 static const struct drm_connector_helper_funcs 
intel_crt_connector_helper_funcs = {
.mode_valid = intel_crt_mode_valid,
.get_modes = intel_crt_get_modes,
-   .best_encoder = intel_best_encoder,
 };

 static const struct drm_encoder_funcs intel_crt_enc_funcs = {
diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index 2113f40..77026ce 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -16113,14 +16113,6 @@ void intel_modeset_cleanup(struct drm_device *dev)
intel_teardown_gmbus(dev);
 }

-/*
- * Return which encoder is currently attached for connector.
- */
-struct drm_encoder *intel_best_encoder(struct drm_connector *connector)
-{
-   return &intel_attached_encoder(connector)->base;
-}
-
 void intel_connector_attach_encoder(struct intel_connector *connector,
struct intel_encoder *encoder)
 {
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index f192f58..21b2833 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -4935,7 +4935,6 @@ static const struct drm_connector_funcs 
intel_dp_connector_funcs = {
 static const struct drm_connector_helper_funcs intel_dp_connector_helper_funcs 
= {
.get_modes = intel_dp_get_modes,
.mode_valid = intel_dp_mode_valid,
-   .best_encoder = intel_best_encoder,
 };

 static const struct drm_encoder_funcs intel_dp_enc_funcs = {
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index a28b4aa..79a4d6b 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1128,7 +1128,6 @@ struct intel_connector *intel_connector_alloc(void);
 bool intel_connector_get_hw_state(struct intel_connector *connector);
 void intel_connector_attach_encoder(struct intel_connector *connector,
struct intel_encoder *encoder);
-struct drm_encoder *intel_best_encoder(struct drm_connector *connector);
 struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
 struct drm_crtc *crtc);
 enum pipe intel_get_pipe_from_connector(struct intel_connector *connector);
diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c
index 366ad6c..ec51952 100644
--- a/drivers/gpu/drm/i915/intel_dsi.c
+++ b/drivers/gpu/drm/i915/intel_dsi.c
@@ -1378,7 +1378,6 @@ static const struct drm_encoder_funcs intel_dsi_funcs = {
 static const struct drm_connector_helper_funcs 
intel_dsi_connector_helper_funcs = {
.get_modes = intel_dsi_get_modes,
.mode_valid = intel_dsi_mode_valid,
-   .best_encoder = intel_best_encoder,
 };

 static const struct drm_connector_funcs intel_dsi_connector_funcs = {
diff --git a/drivers/gpu/drm/i915/intel_dvo.c b/drivers/gpu/drm/i915/intel_dvo.c
index 286baec..34b7e3f 100644
--- a/drivers/gpu/drm/i915/intel_dvo.c
+++ b/drivers/gpu/drm/i915/intel_dvo.c
@@ -351,7 +351,6 @@ static const struct drm_connector_funcs 
intel_dvo_connector_funcs = {
 static const struct drm_connector_helper_funcs 
intel_dvo_connector_helper_funcs = {
.mode_valid = intel_dvo_mode_valid,
.get_modes = intel_dvo_get_modes,
-   .best_encoder = intel_best_encoder,
 };

 static void intel_dvo_enc_destroy(struct drm_encoder *encoder)
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c 
b/drivers/gpu/drm/i915/intel_hdmi.c
index 2c3bd9c..aef4bc8 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -2114,7 +2114,6 @@ static const struct drm_connector_funcs 
intel_hdmi_connector_funcs = {
 static const struct drm_connector_helper_funcs 
intel_hdmi_connector_helper_funcs = {
.get_modes = intel_hdmi_get_modes,
.mode_valid = intel_hdmi_mode_valid,
-   .best_encoder = intel_best_encoder,
 };

 static const struct drm_e

[PATCH v2 05/20] drm: fsl-dcu: Rely on the default ->best_encoder() behavior

2016-06-07 Thread Boris Brezillon
We have a 1:1 relationship between connectors and encoders and the
driver is relying on the atomic helpers: we can drop the custom
->best_encoder() and let the core call drm_atomic_helper_best_encoder()
for us.

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c 
b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
index 98c998d..0b0989e 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
@@ -102,14 +102,6 @@ static const struct drm_connector_funcs 
fsl_dcu_drm_connector_funcs = {
.reset = drm_atomic_helper_connector_reset,
 };

-static struct drm_encoder *
-fsl_dcu_drm_connector_best_encoder(struct drm_connector *connector)
-{
-   struct fsl_dcu_drm_connector *fsl_con = to_fsl_dcu_connector(connector);
-
-   return fsl_con->encoder;
-}
-
 static int fsl_dcu_drm_connector_get_modes(struct drm_connector *connector)
 {
struct fsl_dcu_drm_connector *fsl_connector;
@@ -136,7 +128,6 @@ static int fsl_dcu_drm_connector_mode_valid(struct 
drm_connector *connector,
 }

 static const struct drm_connector_helper_funcs connector_helper_funcs = {
-   .best_encoder = fsl_dcu_drm_connector_best_encoder,
.get_modes = fsl_dcu_drm_connector_get_modes,
.mode_valid = fsl_dcu_drm_connector_mode_valid,
 };
-- 
2.7.4



[PATCH v2 04/20] drm: exynos: Rely on the default ->best_encoder() behavior

2016-06-07 Thread Boris Brezillon
We have 1:1 relationship between connectors and encoders and the driver
is relying on the atomic helpers: we can drop the custom ->best_encoder()
implementations and let the core call drm_atomic_helper_best_encoder()
for us.

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/exynos/exynos_drm_dpi.c  | 9 -
 drivers/gpu/drm/exynos/exynos_drm_dsi.c  | 9 -
 drivers/gpu/drm/exynos/exynos_drm_vidi.c | 8 
 drivers/gpu/drm/exynos/exynos_hdmi.c | 8 
 4 files changed, 34 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_dpi.c 
b/drivers/gpu/drm/exynos/exynos_drm_dpi.c
index 5e38e74..ad6b73c 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dpi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dpi.c
@@ -93,17 +93,8 @@ static int exynos_dpi_get_modes(struct drm_connector 
*connector)
return 0;
 }

-static struct drm_encoder *
-exynos_dpi_best_encoder(struct drm_connector *connector)
-{
-   struct exynos_dpi *ctx = connector_to_dpi(connector);
-
-   return &ctx->encoder;
-}
-
 static const struct drm_connector_helper_funcs 
exynos_dpi_connector_helper_funcs = {
.get_modes = exynos_dpi_get_modes,
-   .best_encoder = exynos_dpi_best_encoder,
 };

 static int exynos_dpi_create_connector(struct drm_encoder *encoder)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c 
b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
index 601ecf8..e07cb1f 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
@@ -1566,17 +1566,8 @@ static int exynos_dsi_get_modes(struct drm_connector 
*connector)
return 0;
 }

-static struct drm_encoder *
-exynos_dsi_best_encoder(struct drm_connector *connector)
-{
-   struct exynos_dsi *dsi = connector_to_dsi(connector);
-
-   return &dsi->encoder;
-}
-
 static const struct drm_connector_helper_funcs 
exynos_dsi_connector_helper_funcs = {
.get_modes = exynos_dsi_get_modes,
-   .best_encoder = exynos_dsi_best_encoder,
 };

 static int exynos_dsi_create_connector(struct drm_encoder *encoder)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c 
b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
index 608b0af..e8f6c92 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
@@ -378,16 +378,8 @@ static int vidi_get_modes(struct drm_connector *connector)
return drm_add_edid_modes(connector, edid);
 }

-static struct drm_encoder *vidi_best_encoder(struct drm_connector *connector)
-{
-   struct vidi_context *ctx = ctx_from_connector(connector);
-
-   return &ctx->encoder;
-}
-
 static const struct drm_connector_helper_funcs vidi_connector_helper_funcs = {
.get_modes = vidi_get_modes,
-   .best_encoder = vidi_best_encoder,
 };

 static int vidi_create_connector(struct drm_encoder *encoder)
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c 
b/drivers/gpu/drm/exynos/exynos_hdmi.c
index 58de5a4..1625d7c 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -937,17 +937,9 @@ static int hdmi_mode_valid(struct drm_connector *connector,
return MODE_OK;
 }

-static struct drm_encoder *hdmi_best_encoder(struct drm_connector *connector)
-{
-   struct hdmi_context *hdata = connector_to_hdmi(connector);
-
-   return &hdata->encoder;
-}
-
 static const struct drm_connector_helper_funcs hdmi_connector_helper_funcs = {
.get_modes = hdmi_get_modes,
.mode_valid = hdmi_mode_valid,
-   .best_encoder = hdmi_best_encoder,
 };

 static int hdmi_create_connector(struct drm_encoder *encoder)
-- 
2.7.4



[PATCH v2 03/20] drm: atmel-hlcdc: Rely on the default ->best_encoder() behavior

2016-06-07 Thread Boris Brezillon
We have a 1:1 relationship between connectors and encoders and the
driver is relying on the atomic helpers: we can drop the custom
->best_encoder() and let the core call drm_atomic_helper_best_encoder()
for us.

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c | 12 
 1 file changed, 12 deletions(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
index 3d34fc4..6119b50 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
@@ -113,21 +113,9 @@ static int atmel_hlcdc_rgb_mode_valid(struct drm_connector 
*connector,
return atmel_hlcdc_dc_mode_valid(rgb->dc, mode);
 }

-
-
-static struct drm_encoder *
-atmel_hlcdc_rgb_best_encoder(struct drm_connector *connector)
-{
-   struct atmel_hlcdc_rgb_output *rgb =
-   drm_connector_to_atmel_hlcdc_rgb_output(connector);
-
-   return &rgb->encoder;
-}
-
 static const struct drm_connector_helper_funcs 
atmel_hlcdc_panel_connector_helper_funcs = {
.get_modes = atmel_hlcdc_panel_get_modes,
.mode_valid = atmel_hlcdc_rgb_mode_valid,
-   .best_encoder = atmel_hlcdc_rgb_best_encoder,
 };

 static enum drm_connector_status
-- 
2.7.4



[PATCH v2 02/20] drm: arc: Rely on the default ->best_encoder() behavior

2016-06-07 Thread Boris Brezillon
We have a 1:1 relationship between connectors and encoders and the
driver is relying on the atomic helpers: we can drop the custom
->best_encoder(), and let the core call drm_atomic_helper_best_encoder()
for us.

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/arc/arcpgu_hdmi.c | 18 --
 1 file changed, 18 deletions(-)

diff --git a/drivers/gpu/drm/arc/arcpgu_hdmi.c 
b/drivers/gpu/drm/arc/arcpgu_hdmi.c
index 08b6bae..b7a8b2a 100644
--- a/drivers/gpu/drm/arc/arcpgu_hdmi.c
+++ b/drivers/gpu/drm/arc/arcpgu_hdmi.c
@@ -46,23 +46,6 @@ static int arcpgu_drm_connector_get_modes(struct 
drm_connector *connector)
return sfuncs->get_modes(&slave->base, connector);
 }

-struct drm_encoder *
-arcpgu_drm_connector_best_encoder(struct drm_connector *connector)
-{
-   struct drm_encoder_slave *slave;
-   struct arcpgu_drm_connector *con =
-   container_of(connector, struct arcpgu_drm_connector, connector);
-
-   slave = con->encoder_slave;
-   if (slave == NULL) {
-   dev_err(connector->dev->dev,
-   "connector_best_encoder: cannot find slave encoder for 
connector\n");
-   return NULL;
-   }
-
-   return &slave->base;
-}
-
 static enum drm_connector_status
 arcpgu_drm_connector_detect(struct drm_connector *connector, bool force)
 {
@@ -97,7 +80,6 @@ static void arcpgu_drm_connector_destroy(struct drm_connector 
*connector)
 static const struct drm_connector_helper_funcs
 arcpgu_drm_connector_helper_funcs = {
.get_modes = arcpgu_drm_connector_get_modes,
-   .best_encoder = arcpgu_drm_connector_best_encoder,
 };

 static const struct drm_connector_funcs arcpgu_drm_connector_funcs = {
-- 
2.7.4



[PATCH v2 01/20] drm/atomic: Fix remaining places where !funcs->best_encoder is valid

2016-06-07 Thread Boris Brezillon
Adapt drm_pick_crtcs() and update_connector_routing() to fallback to
drm_atomic_helper_best_encoder() if funcs->best_encoder() is NULL so
that DRM drivers can leave this hook unassigned if they know they want
to use drm_atomic_helper_best_encoder().

Update the vtables documentation accordingly.

Signed-off-by: Boris Brezillon 
---
 drivers/gpu/drm/drm_atomic_helper.c  |  4 +++-
 drivers/gpu/drm/drm_fb_helper.c  | 13 -
 include/drm/drm_modeset_helper_vtables.h | 10 --
 3 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index f6a3350..849d029 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -300,8 +300,10 @@ update_connector_routing(struct drm_atomic_state *state,
if (funcs->atomic_best_encoder)
new_encoder = funcs->atomic_best_encoder(connector,
 connector_state);
-   else
+   else if (funcs->best_encoder)
new_encoder = funcs->best_encoder(connector);
+   else
+   new_encoder = drm_atomic_helper_best_encoder(connector);

if (!new_encoder) {
DRM_DEBUG_ATOMIC("No suitable encoder found for 
[CONNECTOR:%d:%s]\n",
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 7c2eb75..d44389a 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -2000,7 +2000,18 @@ static int drm_pick_crtcs(struct drm_fb_helper 
*fb_helper,
my_score++;

connector_funcs = connector->helper_private;
-   encoder = connector_funcs->best_encoder(connector);
+
+   /*
+* If the DRM device implements atomic hooks and ->best_encoder() is
+* NULL we fallback to the default drm_atomic_helper_best_encoder()
+* helper.
+*/
+   if (fb_helper->dev->mode_config.funcs->atomic_commit &&
+   !connector_funcs->best_encoder)
+   encoder = drm_atomic_helper_best_encoder(connector);
+   else
+   encoder = connector_funcs->best_encoder(connector);
+
if (!encoder)
goto out;

diff --git a/include/drm/drm_modeset_helper_vtables.h 
b/include/drm/drm_modeset_helper_vtables.h
index d4619dc..4e7a53b 100644
--- a/include/drm/drm_modeset_helper_vtables.h
+++ b/include/drm/drm_modeset_helper_vtables.h
@@ -736,6 +736,11 @@ struct drm_connector_helper_funcs {
 * inspect dynamic configuration state should instead use
 * @atomic_best_encoder.
 *
+* You can leave this function to NULL if the connector is only
+* attached to a single encoder and you are using the atomic helpers.
+* In this case, the core will call drm_atomic_helper_best_encoder()
+* for you.
+*
 * RETURNS:
 *
 * Encoder that should be used for the given connector and connector
@@ -752,8 +757,9 @@ struct drm_connector_helper_funcs {
 * need to select the best encoder depending upon the desired
 * configuration and can't select it statically.
 *
-* This function is used by drm_atomic_helper_check_modeset() and either
-* this or @best_encoder is required.
+* This function is used by drm_atomic_helper_check_modeset().
+* If it is not implemented, the core will fallback to @best_encoder
+* (or drm_atomic_helper_best_encoder() if @best_encoder is NULL).
 *
 * NOTE:
 *
-- 
2.7.4



[PATCH v2 00/20] drm/atomic: Provide default ->best_encoder() behavior

2016-06-07 Thread Boris Brezillon
Hello,

This patch series aims at replacing all dummy ->best_encoder()
implementations where we have a 1:1 relationship between encoders
and connectors.
The core already provides the drm_atomic_helper_best_encoder()
function which is taking the first encoder attached to the
connector (after making sure only one encoder was attached to the
connector), but it's not automatically used, and drivers wanting
to rely on this default behavior have to explicitly assign their
->best_encoder() hook to drm_atomic_helper_best_encoder().

The first patch fixes remaining places where
drm_atomic_helper_best_encoder() should be called when ->best_encoder()
is NULL, so that drivers using the atomic helpers can get rid of the
explicit ->best_encoder assignment if they need to rely on the default
drm_atomic_helper_best_encoder() implementation.

The following patches are killing all open coded ->best_encoder()
implementations that could be replaced by
drm_atomic_helper_best_encoder().

All modifications have been compile tested except for the changed on
the intel driver.
I've also tested on an atmel board, but I recommend waiting for DRM
driver maintainers feedback before applying the associated changes.

Note that once patch 1 is applied, the other patches can be applied
independently.

Best Regards,

Boris

Changes since v1:
- remove useless ->encoder backpointers in some implementations
- documented the default behavior in the vtable doc
- added R-b/A-b tags

Boris Brezillon (20):
  drm/atomic: Fix remaining places where !funcs->best_encoder is valid
  drm: arc: Rely on the default ->best_encoder() behavior
  drm: atmel-hlcdc: Rely on the default ->best_encoder() behavior
  drm: exynos: Rely on the default ->best_encoder() behavior
  drm: fsl-dcu: Rely on the default ->best_encoder() behavior
  drm: i915: Rely on the default ->best_encoder() behavior where
appropriate
  drm: mediatek: Rely on the default ->best_encoder() behavior
  drm: msm: Rely on the default ->best_encoder() behavior where
appropriate
  drm: rcar-du: Rely on the default ->best_encoder() behavior
  drm: rockchip: Rely on the default ->best_encoder() behavior
  drm: sti: Rely on the default ->best_encoder() behavior
  drm: sun4i: Rely on the default ->best_encoder() behavior
  drm: tegra: Rely on the default ->best_encoder() behavior
  drm: vc4: Rely on the default ->best_encoder() behavior
  drm: virtgpu: Rely on the default ->best_encoder() behavior
  drm: omap: Rely on the default ->best_encoder() behavior
  drm/bridge: anx78xx: Rely on the default ->best_encoder() behavior
  drm/bridge: ptn3460: Rely on the default ->best_encoder() behavior
  drm/bridge: ps8622: Rely on the default ->best_encoder() behavior
  drm/bridge: dw-hdmi: Use drm_atomic_helper_best_encoder()

 drivers/gpu/drm/arc/arcpgu_hdmi.c  | 18 --
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c   | 12 
 drivers/gpu/drm/bridge/analogix-anx78xx.c  |  8 
 drivers/gpu/drm/bridge/dw-hdmi.c   | 11 +--
 drivers/gpu/drm/bridge/nxp-ptn3460.c   |  8 
 drivers/gpu/drm/bridge/parade-ps8622.c | 10 --
 drivers/gpu/drm/drm_atomic_helper.c|  4 +++-
 drivers/gpu/drm/drm_fb_helper.c| 13 -
 drivers/gpu/drm/exynos/exynos_drm_dpi.c|  9 -
 drivers/gpu/drm/exynos/exynos_drm_dsi.c|  9 -
 drivers/gpu/drm/exynos/exynos_drm_vidi.c   |  8 
 drivers/gpu/drm/exynos/exynos_hdmi.c   |  8 
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c  |  9 -
 drivers/gpu/drm/i915/intel_crt.c   |  1 -
 drivers/gpu/drm/i915/intel_display.c   |  8 
 drivers/gpu/drm/i915/intel_dp.c|  1 -
 drivers/gpu/drm/i915/intel_drv.h   |  1 -
 drivers/gpu/drm/i915/intel_dsi.c   |  1 -
 drivers/gpu/drm/i915/intel_dvo.c   |  1 -
 drivers/gpu/drm/i915/intel_hdmi.c  |  1 -
 drivers/gpu/drm/i915/intel_lvds.c  |  1 -
 drivers/gpu/drm/i915/intel_sdvo.c  |  1 -
 drivers/gpu/drm/i915/intel_tv.c|  1 -
 drivers/gpu/drm/mediatek/mtk_dsi.c |  9 -
 drivers/gpu/drm/msm/edp/edp_connector.c| 10 --
 drivers/gpu/drm/msm/hdmi/hdmi_connector.c  |  8 
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_lvds_connector.c |  9 -
 drivers/gpu/drm/omapdrm/omap_connector.c   | 10 --
 drivers/gpu/drm/rcar-du/rcar_du_encoder.c  | 12 
 drivers/gpu/drm/rcar-du/rcar_du_encoder.h  |  3 ---
 drivers/gpu/drm/rcar-du/rcar_du_hdmicon.c  |  1 -
 drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c  |  1 -
 drivers/gpu/drm/rcar-du/rcar_du_vgacon.c   |  3 ---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c |  9 -
 drivers/gpu/drm/rockchip/in

[Bug 96423] radeonfb: BAR 0: can't reserve [mem 0x98000000-0x9fffffff pref]

2016-06-07 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=96423

Alex Deucher  changed:

   What|Removed |Added

 Resolution|--- |NOTOURBUG
 Status|NEW |RESOLVED

--- Comment #1 from Alex Deucher  ---
radeonfb is a different driver than radeon.  Please file a bug at
https://bugzilla.kernel.org/ against
Product: Drivers
Component: Video(Other)

If radeon works, why not use it?

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160607/48b6c19c/attachment-0001.html>


[Bug 96350] vaGetSurfaceBufferWl() is not implemented at VAAPI Gallium state tracker

2016-06-07 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=96350

--- Comment #1 from leoxsliu at gmail.com ---
First, the change is nothing to do with DRI3.
Second, the change removing "NOT_IMPLEMENTED" is wayland display should be
opened with DRM code path, and it's already implemented. the code here is not
general switch to turn on the wayland support on vaapi, it's just one of the
steps to complete that support and which has been implemented. Sorry for the
confusion.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160607/0e0828f9/attachment.html>


[PATCH 03/27] drm/atmel: Use lockless gem BO free callback

2016-06-07 Thread Boris Brezillon
On Mon, 30 May 2016 19:52:55 +0200
Daniel Vetter  wrote:

> No dev->struct_mutex anywhere to be seen.
> 
> Cc: Boris Brezillon 
> Signed-off-by: Daniel Vetter 

Acked-by: Boris Brezillon 

> ---
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c 
> b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> index 8ded7645747e..6485fa5bee8b 100644
> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
> @@ -776,7 +776,7 @@ static struct drm_driver atmel_hlcdc_dc_driver = {
>   .get_vblank_counter = drm_vblank_no_hw_counter,
>   .enable_vblank = atmel_hlcdc_dc_enable_vblank,
>   .disable_vblank = atmel_hlcdc_dc_disable_vblank,
> - .gem_free_object = drm_gem_cma_free_object,
> + .gem_free_object_unlocked = drm_gem_cma_free_object,
>   .gem_vm_ops = &drm_gem_cma_vm_ops,
>   .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
>   .prime_fd_to_handle = drm_gem_prime_fd_to_handle,



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[PATCH] drm/fb_cma_helper: Implement fb_mmap callback

2016-06-07 Thread Robin Murphy
In the absence of an fb_mmap callback, the fbdev code falls back to a
naive implementation which relies upon the DMA address being the same
as the physical address, and the buffer being physically contiguous
from there. Whilst this often holds for standard CMA allocations via
the platform's regular DMA ops, if the allocation is provided by an
IOMMU then such assumptions can fall apart spectacularly.

To resolve this, reroute the fb_mmap call to the appropriate DMA API
implementation, as per the other cma_helper calls.

Acked-by: Daniel Vetter 
Signed-off-by: Robin Murphy 
---

Resending rebased to 4.7-rc1 with Daniel's ack. I know Russell raised
some concerns about the general way fb_cma_helper uses fb_info[1], but
AFAICS that's a longstanding separate problem orthogonal to this patch.

Robin.

[1]:http://thread.gmane.org/gmane.comp.video.dri.devel/149288

 drivers/gpu/drm/drm_fb_cma_helper.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c 
b/drivers/gpu/drm/drm_fb_cma_helper.c
index 172cafe11c71..a25afc068d3f 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 

 #define DEFAULT_FBDEFIO_DELAY_MS 50
@@ -297,6 +298,12 @@ int drm_fb_cma_debugfs_show(struct seq_file *m, void *arg)
 EXPORT_SYMBOL_GPL(drm_fb_cma_debugfs_show);
 #endif

+static int drm_fb_cma_mmap(struct fb_info *info, struct vm_area_struct *vma)
+{
+   return dma_mmap_writecombine(info->device, vma, info->screen_base,
+info->fix.smem_start, info->fix.smem_len);
+}
+
 static struct fb_ops drm_fbdev_cma_ops = {
.owner  = THIS_MODULE,
.fb_fillrect= drm_fb_helper_sys_fillrect,
@@ -307,6 +314,7 @@ static struct fb_ops drm_fbdev_cma_ops = {
.fb_blank   = drm_fb_helper_blank,
.fb_pan_display = drm_fb_helper_pan_display,
.fb_setcmap = drm_fb_helper_setcmap,
+   .fb_mmap= drm_fb_cma_mmap,
 };

 static int drm_fbdev_cma_deferred_io_mmap(struct fb_info *info,
-- 
2.8.1.dirty



[PATCH v3] drm/dsi: Implement set tear scanline

2016-06-07 Thread Vinay Simha BN
Provide a small convenience wrapper that transmits
a set_tear_scanline command.

Cc: Archit Taneja 
Cc: John Stultz 
Cc: Thierry Reding 
Cc: Sumit Semwal 
Cc: Jani Nikula 
Signed-off-by: Vinay Simha BN 

--
v1:
  * helper function suggested by Thierry
for set_tear_scanline
  * Also includes small build fixes from Sumit Semwal.

v2:
  * one scanline parameter suggested by jani

v3:
  * passing the payload properly as suggested by jani
--
---
 drivers/gpu/drm/drm_mipi_dsi.c | 22 ++
 include/drm/drm_mipi_dsi.h |  1 +
 2 files changed, 23 insertions(+)

diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
index f5d8083..7938ce7 100644
--- a/drivers/gpu/drm/drm_mipi_dsi.c
+++ b/drivers/gpu/drm/drm_mipi_dsi.c
@@ -983,6 +983,28 @@ int mipi_dsi_dcs_set_tear_on(struct mipi_dsi_device *dsi,
 EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_on);

 /**
+ * mipi_dsi_set_tear_scanline() - turn on the display module's Tearing Effect
+ * output signal on the TE signal line when display module reaches line N
+ * defined by STS[n:0].
+ * @dsi: DSI peripheral device
+ * @param: STS[10:0]
+ * Return: 0 on success or a negative error code on failure
+ */
+int mipi_dsi_set_tear_scanline(struct mipi_dsi_device *dsi, u16 param)
+{
+   u8 payload[3] = { MIPI_DCS_SET_TEAR_SCANLINE, param >> 8,
+ param & 0xff };
+   ssize_t err;
+
+   err = mipi_dsi_generic_write(dsi, payload, sizeof(payload));
+   if (err < 0)
+   return err;
+
+   return 0;
+}
+EXPORT_SYMBOL(mipi_dsi_set_tear_scanline);
+
+/**
  * mipi_dsi_dcs_set_pixel_format() - sets the pixel format for the RGB image
  *data used by the interface
  * @dsi: DSI peripheral device
diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
index 7a9840f..ec55285 100644
--- a/include/drm/drm_mipi_dsi.h
+++ b/include/drm/drm_mipi_dsi.h
@@ -263,6 +263,7 @@ int mipi_dsi_dcs_set_column_address(struct mipi_dsi_device 
*dsi, u16 start,
u16 end);
 int mipi_dsi_dcs_set_page_address(struct mipi_dsi_device *dsi, u16 start,
  u16 end);
+int mipi_dsi_set_tear_scanline(struct mipi_dsi_device *dsi, u16 param);
 int mipi_dsi_dcs_set_tear_off(struct mipi_dsi_device *dsi);
 int mipi_dsi_dcs_set_tear_on(struct mipi_dsi_device *dsi,
 enum mipi_dsi_dcs_tear_mode mode);
-- 
2.1.2



[PATCH RESEND 03/14] drm/atmel: use drm_crtc_send_vblank_event()

2016-06-07 Thread Boris Brezillon
On Mon,  6 Jun 2016 11:41:34 -0300
Gustavo Padovan  wrote:

> From: Gustavo Padovan 
> 
> Replace the legacy drm_send_vblank_event() with the new helper function.
> 
> Signed-off-by: Gustavo Padovan 

Acked-by: Boris Brezillon 

> ---
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c 
> b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
> index cf23a75..6fca9c4 100644
> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
> @@ -374,7 +374,7 @@ static void atmel_hlcdc_crtc_finish_page_flip(struct 
> atmel_hlcdc_crtc *crtc)
>  
>   spin_lock_irqsave(&dev->event_lock, flags);
>   if (crtc->event) {
> - drm_send_vblank_event(dev, crtc->id, crtc->event);
> + drm_crtc_send_vblank_event(&crtc->base, crtc->event);
>   drm_vblank_put(dev, crtc->id);
>   crtc->event = NULL;
>   }



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[PATCH 10/14] drm/atmel: use drm_crtc_vblank_{get,put}()

2016-06-07 Thread Boris Brezillon
On Mon,  6 Jun 2016 11:41:41 -0300
Gustavo Padovan  wrote:

> From: Gustavo Padovan 
> 
> Replace the legacy drm_vblank_{get,put}() with the new helper functions.
> 
> Signed-off-by: Gustavo Padovan 

Acked-by: Boris Brezillon 

> ---
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c 
> b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
> index 6fca9c4..461b39c 100644
> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
> @@ -375,7 +375,7 @@ static void atmel_hlcdc_crtc_finish_page_flip(struct 
> atmel_hlcdc_crtc *crtc)
>   spin_lock_irqsave(&dev->event_lock, flags);
>   if (crtc->event) {
>   drm_crtc_send_vblank_event(&crtc->base, crtc->event);
> - drm_vblank_put(dev, crtc->id);
> + drm_crtc_vblank_put(&crtc->base);
>   crtc->event = NULL;
>   }
>   spin_unlock_irqrestore(&dev->event_lock, flags);



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[PATCH v14.1 01/17] drm: bridge: analogix/dp: split exynos dp driver to bridge directory

2016-06-07 Thread Javier Martinez Canillas
Hello Yakir,

On 03/17/2016 05:47 PM, Heiko Stübner wrote:
> Split the dp core driver from exynos directory to bridge directory,
> and rename the core driver to analogix_dp_*, rename the platform
> code to exynos_dp.
> 
> Beside the new analogix_dp driver would export six hooks.
> "analogix_dp_bind()" and "analogix_dp_unbind()"
> "analogix_dp_suspned()" and "analogix_dp_resume()"
> "analogix_dp_detect()" and "analogix_dp_get_modes()"
> 
> The bind/unbind symbols is used for analogix platform driver to connect
> with analogix_dp core driver. And the detect/get_modes is used for analogix
> platform driver to init the connector.
> 
> They reason why connector need register in helper driver is rockchip drm
> haven't implement the atomic API, but Exynos drm have implement it, so
> there would need two different connector helper functions, that's why we
> leave the connector register in helper driver.
> 
> Signed-off-by: Yakir Yang 
> ---

Marc reported that his Exynos5250 Snow Chromebook fails to boot with v4.7-rc.

I've done a git bisect and tracked down to this commit. The problem is a NULL
pointer dereference to connector->dev in drm_mode_create(connector->dev) when
called from exynos_dp_get_modes(). The error log is at [1]. 

I'm trying to figure out the issue but wanted to mention in case you have any
hints about what could be the cause. AFAICT the problem is related to the fact
that drm_connector_init() is called in analogix_dp_bridge_attach() and the
connector passed as argument is the one in struct analogix_dp_device *dp, but
later exynos_dp_get_modes() calls drm_mode_create() passing the connector in
struct exynos_dp_device *dp, which has not been previously initialized.

[1]
[4.175676] Unable to handle kernel NULL pointer dereference at virtual 
address 0210
[4.182793] pgd = c0004000
[4.185171] [0210] *pgd=
[4.188657] Internal error: Oops: 5 [#1] PREEMPT SMP ARM
[4.194164] Modules linked in:
[4.196964] CPU: 1 PID: 68 Comm: kworker/1:1 Not tainted 
4.7.0-rc2-next-20160606-6-g876c3150327a #97
[4.206565] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
[4.212582] Workqueue: events hdmi_hotplug_work_func
[4.217383] task: ed758000 ti: ed75c000 task.ti: ed75c000
[4.222887] PC is at __mutex_lock_slowpath+0x6c/0x404
[4.227913] LR is at preempt_count_add+0xa4/0x140
[4.232592] pc : []lr : []psr: 6093
[4.232592] sp : ed75dd80  ip :   fp : ee8c1180
[4.244193] r10: 0300  r9 : ed758000  r8 : 0001
[4.249262] r7 : 6013  r6 : c0b473a8  r5 : 0210  r4 : 020c
[4.261955] r3 :   r2 : 0001  r1 : ee8c2808  r0 : 
[4.273270] Flags: nZCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment 
none
[4.285336] Control: 10c5387d  Table: 4000406a  DAC: 0051
[4.295885] Process kworker/1:1 (pid: 68, stack limit = 0xed75c210)
[4.306979] Stack: (0xed75dd80 to 0xed75e000)
[4.316102] dd80: ee8c1180 c03dd21c ee8f0820 0001 020c 020c 
 
[4.329201] dda0: 0001 dededede 0300 c06d2578 ee8c2808 c03d00f4 
ee801d80 c0b0261c
[4.342362] ddc0: 0041 ee8c2800  0001 ee8f0810 ee8f0b65 
c074d2b4 c03d35b0
[4.353140] dde0:  0300 ee8c1180 c03d81d0 c387cf74 ee8f0820 
0001 c03eaffc
[4.361811] de00:  ee8f0820 0001 c03f28bc ee8f0b65 c06d400c 
ee8c1180 006d40a4
[4.370483] de20:  01820a11 81010300 0100 0064 ee8f085c 
ee8f0820 c0b1f894
[4.379150] de40: c3872800 c0b82fac c074d2b4 c03b7550 c0b13274 c0327974 
0001 eefb8530
[4.387805] de60: 0556  c38729b0 c3872800 ee8c1180 0001 
ee8c7000 
[4.396467] de80: 0556 0300 c38729b0 0002 ee8c1180 c03c107c 
ee8c7000 c3872800
[4.405121] dea0: ee8c7240 c3872800 c0b82fac c03c3268 c3872ad4 0001 
c3872ae0 c03b7af0
[4.413776] dec0: eefb8000 c0139804  c0136484 ee8a ee8c1180 
c3870b4c eefb7b00
[4.422415] dee0: eefbb000   eefb7b00 ee8c1180 c012ff2c 
0008 eefb7b24
[4.431045] df00: eefb7b00 ee8c1198 0008 eefb7b24 c0b02100 ed75c000 
eefb7b00 c0130178
[4.439664] df20: ed75c000 ee863040 ee8c1180  ee863040 ee8c1180 
c0130140 
[4.448274] df40:    c0135454   
 ee8c1180
[4.456879] df60:   dead4ead   ed75df74 
ed75df74 
[4.465462] df80:  dead4ead   ed75df90 ed75df90 
ed75dfac ee863040
[4.474028] dfa0: c0135378   c0107978   
 
[4.482597] dfc0:       
 
[4.491133] dfe0:     0013  
 
[4.499643] [] (__mutex_lock_slowpath) from [] 
(mutex_lock+0xc/0x24)
[4.507102] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[4.514264] [] (mute

HDLCD crashes with 6d910bfa809e

2016-06-07 Thread Robin Murphy
Hi Daniel, Liviu,

Having just inadvertently merged -next into my working branch, I find 
dev6d910bfa809e ("drm/hlcd: Use lockless gem BO free callback") 
adversely affecting my board's ability to boot ;)

Since I (intentionally) don't have sufficient CMA to create a 
framebuffer, drm_gem_cma_create() fails, unconditionally calls the 
now-NULL drm->driver->gem_free_object() in its cleanup path, and fiery 
death ensues...

Regards,
Robin.


[PATCH v2] drm/core: Change declaration for gamma_set.

2016-06-07 Thread Patrik Jakobsson
On Tue, Jun 7, 2016 at 12:49 PM, Maarten Lankhorst
 wrote:
> Change return value to int to propagate errors from gamma_set,
> and remove start parameter. Updates always use the full size,
> and some drivers even ignore the start parameter altogether.
>
> This is needed for atomic drivers, where an atomic commit can
> fail with -EINTR or -ENOMEM and should be restarted.
>
> Changes since v1:
> - Fix compiler warning. (Emil)
> - Fix commit message (Daniel)
>
> Cc: Alex Deucher 
> Acked-by: Alex Deucher 
> Cc: Christian König 
> Cc: David Airlie 
> Cc: Patrik Jakobsson 
> Cc: Ben Skeggs 
> Cc: Eric Anholt 
> Cc: VMware Graphics 
> Cc: Mathieu Larouche 
> Cc: Thierry Reding 
> Signed-off-by: Maarten Lankhorst 
> ---
>  drivers/gpu/drm/amd/amdgpu/dce_v10_0.c  | 10 ++
>  drivers/gpu/drm/amd/amdgpu/dce_v11_0.c  | 10 ++
>  drivers/gpu/drm/amd/amdgpu/dce_v8_0.c   | 10 ++
>  drivers/gpu/drm/ast/ast_mode.c  | 10 ++
>  drivers/gpu/drm/cirrus/cirrus_mode.c|  8 +---
>  drivers/gpu/drm/drm_atomic_helper.c | 13 ++---
>  drivers/gpu/drm/drm_crtc.c  |  2 +-
>  drivers/gpu/drm/drm_fb_helper.c |  2 +-
>  drivers/gpu/drm/gma500/gma_display.c|  9 +
>  drivers/gpu/drm/gma500/gma_display.h|  4 ++--
>  drivers/gpu/drm/mgag200/mgag200_mode.c  |  9 +
>  drivers/gpu/drm/nouveau/dispnv04/crtc.c | 12 +++-
>  drivers/gpu/drm/nouveau/nv50_display.c  |  9 +
>  drivers/gpu/drm/radeon/radeon_display.c | 11 +++
>  drivers/gpu/drm/vc4/vc4_crtc.c  |  8 +---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c |  8 +---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.h |  4 ++--
>  include/drm/drm_atomic_helper.h |  6 +++---
>  include/drm/drm_crtc.h  |  4 ++--
>  19 files changed, 85 insertions(+), 64 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c 
> b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
> index 7e57447bf5f4..112e358f0f9b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
> @@ -2667,19 +2667,21 @@ static void dce_v10_0_cursor_reset(struct drm_crtc 
> *crtc)
> }
>  }
>
> -static void dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
> *green,
> -   u16 *blue, uint32_t start, uint32_t size)
> +static int dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
> *green,
> +   u16 *blue, uint32_t size)
>  {
> struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
> -   int end = (start + size > 256) ? 256 : start + size, i;
> +   int i;
>
> /* userspace palettes are always correct as is */
> -   for (i = start; i < end; i++) {
> +   for (i = 0; i < size; i++) {
> amdgpu_crtc->lut_r[i] = red[i] >> 6;
> amdgpu_crtc->lut_g[i] = green[i] >> 6;
> amdgpu_crtc->lut_b[i] = blue[i] >> 6;
> }
> dce_v10_0_crtc_load_lut(crtc);
> +
> +   return 0;
>  }
>
>  static void dce_v10_0_crtc_destroy(struct drm_crtc *crtc)
> diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c 
> b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
> index da101551960b..b522fa2435a8 100644
> --- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
> @@ -2678,19 +2678,21 @@ static void dce_v11_0_cursor_reset(struct drm_crtc 
> *crtc)
> }
>  }
>
> -static void dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
> *green,
> -   u16 *blue, uint32_t start, uint32_t size)
> +static int dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
> *green,
> +   u16 *blue, uint32_t size)
>  {
> struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
> -   int end = (start + size > 256) ? 256 : start + size, i;
> +   int i;
>
> /* userspace palettes are always correct as is */
> -   for (i = start; i < end; i++) {
> +   for (i = 0; i < size; i++) {
> amdgpu_crtc->lut_r[i] = red[i] >> 6;
> amdgpu_crtc->lut_g[i] = green[i] >> 6;
> amdgpu_crtc->lut_b[i] = blue[i] >> 6;
> }
> dce_v11_0_crtc_load_lut(crtc);
> +
> +   return 0;
>  }
>
>  static void dce_v11_0_crtc_destroy(struct drm_crtc *crtc)
> diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c 
> b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
> index 41d9bc5f9c0e..b50ed72feedb 100644
> --- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
> @@ -2574,19 +2574,21 @@ static void dce_v8_0_cursor_reset(struct drm_crtc 
> *crtc)
> }
>  }
>
> -static void dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
> *green,
> -   u16 *blue, uint32_t start, uint32_t size)
> +static int dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
> *green,
> +  

[PATCH v2] drm/core: Change declaration for gamma_set.

2016-06-07 Thread Maarten Lankhorst
Change return value to int to propagate errors from gamma_set,
and remove start parameter. Updates always use the full size,
and some drivers even ignore the start parameter altogether.

This is needed for atomic drivers, where an atomic commit can
fail with -EINTR or -ENOMEM and should be restarted.

Changes since v1:
- Fix compiler warning. (Emil)
- Fix commit message (Daniel)

Cc: Alex Deucher 
Acked-by: Alex Deucher 
Cc: Christian König 
Cc: David Airlie 
Cc: Patrik Jakobsson 
Cc: Ben Skeggs 
Cc: Eric Anholt 
Cc: VMware Graphics 
Cc: Mathieu Larouche 
Cc: Thierry Reding 
Signed-off-by: Maarten Lankhorst 
---
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c  | 10 ++
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c  | 10 ++
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c   | 10 ++
 drivers/gpu/drm/ast/ast_mode.c  | 10 ++
 drivers/gpu/drm/cirrus/cirrus_mode.c|  8 +---
 drivers/gpu/drm/drm_atomic_helper.c | 13 ++---
 drivers/gpu/drm/drm_crtc.c  |  2 +-
 drivers/gpu/drm/drm_fb_helper.c |  2 +-
 drivers/gpu/drm/gma500/gma_display.c|  9 +
 drivers/gpu/drm/gma500/gma_display.h|  4 ++--
 drivers/gpu/drm/mgag200/mgag200_mode.c  |  9 +
 drivers/gpu/drm/nouveau/dispnv04/crtc.c | 12 +++-
 drivers/gpu/drm/nouveau/nv50_display.c  |  9 +
 drivers/gpu/drm/radeon/radeon_display.c | 11 +++
 drivers/gpu/drm/vc4/vc4_crtc.c  |  8 +---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c |  8 +---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.h |  4 ++--
 include/drm/drm_atomic_helper.h |  6 +++---
 include/drm/drm_crtc.h  |  4 ++--
 19 files changed, 85 insertions(+), 64 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
index 7e57447bf5f4..112e358f0f9b 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
@@ -2667,19 +2667,21 @@ static void dce_v10_0_cursor_reset(struct drm_crtc 
*crtc)
}
 }

-static void dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
*green,
-   u16 *blue, uint32_t start, uint32_t size)
+static int dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
*green,
+   u16 *blue, uint32_t size)
 {
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-   int end = (start + size > 256) ? 256 : start + size, i;
+   int i;

/* userspace palettes are always correct as is */
-   for (i = start; i < end; i++) {
+   for (i = 0; i < size; i++) {
amdgpu_crtc->lut_r[i] = red[i] >> 6;
amdgpu_crtc->lut_g[i] = green[i] >> 6;
amdgpu_crtc->lut_b[i] = blue[i] >> 6;
}
dce_v10_0_crtc_load_lut(crtc);
+
+   return 0;
 }

 static void dce_v10_0_crtc_destroy(struct drm_crtc *crtc)
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
index da101551960b..b522fa2435a8 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
@@ -2678,19 +2678,21 @@ static void dce_v11_0_cursor_reset(struct drm_crtc 
*crtc)
}
 }

-static void dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
*green,
-   u16 *blue, uint32_t start, uint32_t size)
+static int dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
*green,
+   u16 *blue, uint32_t size)
 {
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-   int end = (start + size > 256) ? 256 : start + size, i;
+   int i;

/* userspace palettes are always correct as is */
-   for (i = start; i < end; i++) {
+   for (i = 0; i < size; i++) {
amdgpu_crtc->lut_r[i] = red[i] >> 6;
amdgpu_crtc->lut_g[i] = green[i] >> 6;
amdgpu_crtc->lut_b[i] = blue[i] >> 6;
}
dce_v11_0_crtc_load_lut(crtc);
+
+   return 0;
 }

 static void dce_v11_0_crtc_destroy(struct drm_crtc *crtc)
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
index 41d9bc5f9c0e..b50ed72feedb 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
@@ -2574,19 +2574,21 @@ static void dce_v8_0_cursor_reset(struct drm_crtc *crtc)
}
 }

-static void dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
*green,
-   u16 *blue, uint32_t start, uint32_t size)
+static int dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+  u16 *blue, uint32_t size)
 {
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-   int end = (start + size > 256) ? 256 : start + size, i;
+   int i;

/* userspace palettes are always correct as is */
-   for (i = start; i < end; i++) {
+   for

[PATCH 08/14] drm/amdgpu: use drm_crtc_vblank_{get,put}()

2016-06-07 Thread Michel Dänzer
On 06.06.2016 23:41, Gustavo Padovan wrote:
> From: Gustavo Padovan 
> 
> Replace the legacy drm_vblank_{get,put}() with the new helper functions.
> 
> Signed-off-by: Gustavo Padovan 

[...]

> @@ -268,7 +268,7 @@ int amdgpu_crtc_page_flip(struct drm_crtc *crtc,
>   return 0;
>  
>  vblank_cleanup:
> - drm_vblank_put(crtc->dev, amdgpu_crtc->crtc_id);
> + drm_crtc_vblank_put(&amdgpu_crtc->base);

Can just use crtc here instead of &amdgpu_crtc->base. Same for the
radeon patch.


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast | Mesa and X developer


[Bug 96423] radeonfb: BAR 0: can't reserve [mem 0x98000000-0x9fffffff pref]

2016-06-07 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=96423

Bug ID: 96423
   Summary: radeonfb: BAR 0: can't reserve [mem
0x9800-0x9fff pref]
   Product: DRI
   Version: XOrg git
  Hardware: PowerPC
OS: All
Status: NEW
  Severity: normal
  Priority: medium
 Component: DRM/Radeon
  Assignee: dri-devel at lists.freedesktop.org
  Reporter: mathieu.malaterre at gmail.com

On a PowerPC machine, when Open Firmware Frame Buffer is used (OFfb), I
cannot `modprobe radeonfb` (but I can load `radeon`). It currently fails with:

[   96.551486] radeonfb :00:10.0: enabling device (0006 -> 0007)
[   96.551526] radeonfb :00:10.0: BAR 0: can't reserve [mem
0x9800-0x9fff pref]
[   96.551531] radeonfb (:00:10.0): cannot request region 0.
[   96.551545] radeonfb: probe of :00:10.0 failed with error -16

It seems (to me) that it should be possible to add something like this
to `radeonfb`:

https://github.com/torvalds/linux/blob/master/drivers/gpu/drm/radeon/radeon_drv.c#L353

[...]
/* Get rid of things like offb */
ret = radeon_kick_out_firmware_fb(pdev);
if (ret)
[...]

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160607/6d33be59/attachment-0001.html>


[PATCH 1/4] drm: Centralize format information

2016-06-07 Thread Tomi Valkeinen
, { 1, 2 }, 2, 1 },
> + { DRM_FORMAT_NV61, 0, 0, 2, { 1, 2 }, 2, 1 },
> + { DRM_FORMAT_NV24, 0, 0, 2, { 1, 2 }, 1, 1 },
> + { DRM_FORMAT_NV42, 0, 0, 2, { 1, 2 }, 1, 1 },
> + { DRM_FORMAT_YUYV, 0, 0, 1, { 2 }, 2, 1 },
> + { DRM_FORMAT_YVYU, 0, 0, 1, { 2 }, 2, 1 },
> + { DRM_FORMAT_UYVY, 0, 0, 1, { 2 }, 2, 1 },
> + { DRM_FORMAT_VYUY, 0, 0, 1, { 2 }, 2, 1 },
> + { DRM_FORMAT_AYUV, 0, 0, 1, { 4 }, 1, 1 },
> + };
> +
> + unsigned int i;
> +
> + for (i = 0; i < ARRAY_SIZE(formats); ++i) {
> + if (formats[i].format == format)
> + return &formats[i];
> + }
> +
> + return NULL;

After looking at the third patch, I wonder if it would make sense to
give a warning here if the format was not found. In the third patch many
of the helpers will quietly return a valid value for unknown modes.
Which is what they do at the moment too, but is there ever a valid
reason to do that without something being wrong?

 Tomi

-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160607/efa883a2/attachment-0001.sig>


[PATCH 1/4] drm: Centralize format information

2016-06-07 Thread Tomi Valkeinen
On 07/06/16 02:33, Laurent Pinchart wrote:

> +/**
> + * struct drm_format_info - information about a DRM format
> + * @format: 4CC format identifier (DRM_FORMAT_*)
> + * @depth: color depth (number of bits per pixel excluding padding bits)
> + * @bpp: number of bits per pixel including padding
> + * @num_planes: number of color planes (1 to 3)
> + * @cpp: number of bytes per pixel (per plane)
> + * @hsub: horizontal chroma subsampling factor
> + * @vsub: vertical chroma subsampling factor
> + */
> +struct drm_format_info {
> + u32 format;
> + unsigned int depth;
> + unsigned int bpp;
> + unsigned int num_planes;
> + unsigned int cpp[3];
> + unsigned int hsub;
> + unsigned int vsub;
> +};

Any reason not to pack this a bit? All those unsigned ints would fit
easily into u8.

 Tomi

-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160607/c78c65dc/attachment.sig>


  1   2   >