[PATCH v3 1/7] firmware: rockchip: sip: Add rockchip SIP runtime service

2016-07-22 Thread Heiko Stübner
Hi again,

one bigger thing I noticed only now.

Am Freitag, 22. Juli 2016, 17:07:14 schrieben Sie:
> diff --git a/drivers/firmware/rockchip_sip.c
> b/drivers/firmware/rockchip_sip.c new file mode 100644
> index 000..7756af9
> --- /dev/null
> +++ b/drivers/firmware/rockchip_sip.c
> @@ -0,0 +1,64 @@
> +/*
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * 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.
> + *
> + * Copyright (C) 2016 ARM Limited
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include "rockchip_sip.h"
> +
> +typedef unsigned long (psci_fn)(unsigned long, unsigned long,
> + unsigned long, unsigned long);
> +asmlinkage psci_fn __invoke_psci_fn_smc;
> +
> +#define CONFIG_DRAM_INIT 0x00
> +#define CONFIG_DRAM_SET_RATE 0x01
> +#define CONFIG_DRAM_ROUND_RATE   0x02
> +#define CONFIG_DRAM_SET_AT_SR0x03
> +#define CONFIG_DRAM_GET_BW   0x04
> +#define CONFIG_DRAM_GET_RATE 0x05
> +#define CONFIG_DRAM_CLR_IRQ  0x06
> +#define CONFIG_DRAM_SET_PARAM   0x07
> +
> +uint64_t sip_smc_ddr_init(void)
> +{
> + return __invoke_psci_fn_smc(SIP_DDR_FREQ, 0,
> + 0, CONFIG_DRAM_INIT);

I don't think that is legal to use. For one this function itself is declared 
static in the psci code - most likely for a specific reason.

And also if anything invoke_psci_fn would hold the correct pointer depending 
on the calling method.

But as said above, accessing psci static stuff is most likely wrong. Maybe the 
two psci people I've included can tell us how this is to be accessed.


Heiko

> +}
> +
> +uint64_t sip_smc_set_ddr_param(uint64_t param)
> +{
> + return __invoke_psci_fn_smc(SIP_DDR_FREQ, param,
> + 0, CONFIG_DRAM_SET_PARAM);
> +}
> +
> +uint64_t sip_smc_set_ddr_rate(uint64_t rate)
> +{
> + return __invoke_psci_fn_smc(SIP_DDR_FREQ, rate, 0,
> + CONFIG_DRAM_SET_RATE);
> +}
> +
> +uint64_t sip_smc_get_ddr_rate(void)
> +{
> + return __invoke_psci_fn_smc(SIP_DDR_FREQ, 0, 0, CONFIG_DRAM_GET_RATE);
> +}
> +
> +uint64_t sip_smc_clr_ddr_irq(void)
> +{
> + return __invoke_psci_fn_smc(SIP_DDR_FREQ, 0, 0, CONFIG_DRAM_CLR_IRQ);
> +}
> +
> +uint64_t sip_smc_get_call_count(void)
> +{
> + return __invoke_psci_fn_smc(SIP_SVC_CALL_COUNT, 0, 0, 0);
> +}



[Bug 87682] Horizontal lines in radeon driver on kernel 3.15 and upwards

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

--- Comment #21 from Thom  ---
Gilbert, same with me, also ubuntu 14.04 -> 16.04.

The patch is already in the 4.7+ kernel tree so it should be in the first 4.7
kernel (pre) release.

I'm not familiar with ubuntu's kernel policy and I also don't know anyone who
does but I guess that the 4.7 kernel will land in  16.10 or 17.04.
Best to ask the Ubuntu Kernelteam.

-- 
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/20160722/65eacd59/attachment.html>


[PATCH v4 2/4] drm/rockchip: add an common abstracted PSR driver

2016-07-22 Thread Doug Anderson
Yakir,

On Wed, Jul 13, 2016 at 9:15 PM, Yakir Yang  wrote:
> +static void psr_set_state(struct psr_drv *psr, enum psr_state state)
> +{
> +   mutex_lock(>state_mutex);
> +
> +   if (psr->state == state) {
> +   mutex_unlock(>state_mutex);
> +   return;
> +   }
> +
> +   psr->state = state;
> +   switch (state) {
> +   case PSR_ENABLE:
> +   psr->set(psr->encoder, true);
> +   break;
> +
> +   case PSR_DISABLE:
> +   case PSR_FLUSH:
> +   psr->set(psr->encoder, false);
> +   break;
> +   };
> +
> +   mutex_unlock(>state_mutex);
> +}
> +
> +static void psr_flush_handler(unsigned long data)
> +{
> +   struct psr_drv *psr = (struct psr_drv *)data;
> +
> +   if (!psr || psr->state != PSR_FLUSH)
> +   return;
> +
> +   psr_set_state(psr, PSR_ENABLE);

As mentioned in a separate thread, this is probably not OK.
psr_set_state() grabs a mutex and that might sleep.  ...but
psr_flush_handler() is a timer.  I'm nearly certain that timers can't
sleep.

I believe this is the source of "sleeping function called from invalid
context" that I've seen at times.

-Doug


[Bug 87682] Horizontal lines in radeon driver on kernel 3.15 and upwards

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

--- Comment #20 from Gilbert Smith  ---
I have this same problem with an upgrade from 14.04 LTS to 16.04 LTS Ubuntu -

Linux DV7 4.6.4-040604-generic #201607111332 SMP Mon Jul 11 17:34:50 UTC 2016
x86_64 x86_64 x86_64 GNU/Linux

01:05.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc.
[AMD/ATI] RS780M [Mobility Radeon HD 3200] [1002:9612] (prog-if 00 [VGA
controller])


I noticed that a patch was submitted. Can I expect to see this in a future
kernel or perhaps a RC version after my 4.6.4 kernel?

---

-- 
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/20160722/f044fea2/attachment.html>


[Bug 97022] Garbage in windows while running a game windowed

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

--- Comment #8 from Peter Mulholland  ---
Created attachment 125261
  --> https://bugs.freedesktop.org/attachment.cgi?id=125261=edit
Part of kern.log written during forcing a GPU reset

I've found that force resetting the GPU clears the corruption - using cat
/sys/kernel/debug/dri/0/radeon_gpu_reset

This does not take effect straight away however, I often have to kill Xorg
before it'll happen. There are some errors written to the kernel log - i have
attached those.

Here is lspci output for the card in case it's relevant:

01:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc.
[AMD/ATI] Cape Verde PRO [Radeon HD 7750/8740 / R7 250E] [1002:683f] (prog-if
00 [VGA controller])
Subsystem: ASUSTeK Computer Inc. Cape Verde PRO [Radeon HD 7750/8740 /
R7 250E] [1043:0427]
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr-
Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- SERR- 
Kernel driver in use: radeon
Kernel modules: radeon

-- 
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/20160722/4866d746/attachment.html>


[Bug 97040] NAEV menu gradient render bug

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

--- Comment #5 from Ilia Mirkin  ---
Tested on i965/SKL and llvmpipe - neither display the reported issue. Most
likely an issue somewhere in r600.

-- 
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/20160722/1ef25214/attachment.html>


[Bug 97040] NAEV menu gradient render bug

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

--- Comment #4 from Bug  ---
https://www.sendspace.com/file/ptig9u

-- 
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/20160722/55fdd126/attachment.html>


[Bug 97029] cik_sdma_copy_texture broken on Carrizo (mesa 12)

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

--- Comment #3 from Franklin Titus  ---
I have similar issue since upgrading to Mesa 12 on the same AMD hardware (A10
Carrizo). 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/20160722/9fa4c3e8/attachment.html>


[Bug 97029] cik_sdma_copy_texture broken on Carrizo (mesa 12)

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

--- Comment #2 from Franklin Titus  ---
Created attachment 125260
  --> https://bugs.freedesktop.org/attachment.cgi?id=125260=edit
distorted screenshot image

-- 
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/20160722/8a54e196/attachment.html>


[PATCH 1/2] drm/atomic-helper: Add atomic_mode_set version to extend encoder mode_set

2016-07-22 Thread Daniel Vetter
On Fri, Jul 22, 2016 at 06:53:41PM +0200, Daniel Vetter wrote:
> On Fri, Jul 22, 2016 at 02:09:12PM +0200, Philipp Zabel wrote:
> > Some encoders need more information from crtc and connector state
> > than just the mode. Add an atomic encoder mode setting variant
> > that passes the crtc state (which contains the modes) and the
> > connector state.
> > 
> > Signed-off-by: Philipp Zabel 
> > ---
> >  drivers/gpu/drm/drm_atomic_helper.c  |  6 +-
> >  include/drm/drm_modeset_helper_vtables.h | 20 
> >  2 files changed, 25 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
> > b/drivers/gpu/drm/drm_atomic_helper.c
> > index de7fddc..a3c033f 100644
> > --- a/drivers/gpu/drm/drm_atomic_helper.c
> > +++ b/drivers/gpu/drm/drm_atomic_helper.c
> > @@ -880,8 +880,12 @@ crtc_set_mode(struct drm_device *dev, struct 
> > drm_atomic_state *old_state)
> >  * Each encoder has at most one connector (since we always steal
> >  * it away), so we won't call mode_set hooks twice.
> >  */
> > -   if (funcs && funcs->mode_set)
> > +   if (funcs && funcs->atomic_mode_set) {
> > +   funcs->atomic_mode_set(encoder, new_crtc_state,
> > +  connector->state);
> > +   } else if (funcs && funcs->mode_set) {
> > funcs->mode_set(encoder, mode, adjusted_mode);
> > +   }
> >  
> > drm_bridge_mode_set(encoder->bridge, mode, adjusted_mode);
> > }
> > diff --git a/include/drm/drm_modeset_helper_vtables.h 
> > b/include/drm/drm_modeset_helper_vtables.h
> > index b55f218..1b15c1f 100644
> > --- a/include/drm/drm_modeset_helper_vtables.h
> > +++ b/include/drm/drm_modeset_helper_vtables.h
> > @@ -529,6 +529,26 @@ struct drm_encoder_helper_funcs {
> >  struct drm_display_mode *adjusted_mode);
> >  
> > /**
> > +* @atomic_mode_set:
> > +*
> > +* This callback is used to update the display mode of an encoder.
> > +*
> > +* Note that the display pipe is completely off when this function is
> > +* called. Drivers which need hardware to be running before they program
> > +* the new display mode (because they implement runtime PM) should not
> > +* use this hook, because the helper library calls it only once and not
> > +* every time the display pipeline is suspended using either DPMS or the
> > +* new "ACTIVE" property. Such drivers should instead move all their
> > +* encoder setup into the ->enable() callback.
> > +*
> > +* This callback is used by the atomic modeset helpers instead of the
> > +* mode_set callback. It is optional in the atomic helpers.
> 
> s/mode_set/@mode_set/ Also pls a bit of text when this should be used (any
> time you need to inspect connector state, since there's no direct way to
> go from the encoder to the current connector). And pls add a note to
> @mode_set that drivers should use @atomic_mode_set in such a case, for
> cross linking.
> 
> Great docs matter ;-)
> 
> While at it I noticed that the kernel-doc for @mode_set is wrong, it says
> it's only used by CRTC helpers. Can you pls fix that too?

Strike that part, I accidentally read the kerneldoc for crtc->mode_fixup.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


Why drm-mipi-dsi is built-in only?

2016-07-22 Thread Daniel Vetter
On Fri, Jul 22, 2016 at 04:30:24PM +0200, Takashi Iwai wrote:
> Hi,
> 
> is there any reason drm-mipi-dsi can't be a module?  It's fixed as a
> built-in since its Kconfig is bool.

Probably none except embedded folks eshew modules ;-) Submit patch, I'll
apply.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[PATCH 1/2] drm/atomic-helper: Add atomic_mode_set version to extend encoder mode_set

2016-07-22 Thread Daniel Vetter
On Fri, Jul 22, 2016 at 02:09:12PM +0200, Philipp Zabel wrote:
> Some encoders need more information from crtc and connector state
> than just the mode. Add an atomic encoder mode setting variant
> that passes the crtc state (which contains the modes) and the
> connector state.
> 
> Signed-off-by: Philipp Zabel 
> ---
>  drivers/gpu/drm/drm_atomic_helper.c  |  6 +-
>  include/drm/drm_modeset_helper_vtables.h | 20 
>  2 files changed, 25 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
> b/drivers/gpu/drm/drm_atomic_helper.c
> index de7fddc..a3c033f 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -880,8 +880,12 @@ crtc_set_mode(struct drm_device *dev, struct 
> drm_atomic_state *old_state)
>* Each encoder has at most one connector (since we always steal
>* it away), so we won't call mode_set hooks twice.
>*/
> - if (funcs && funcs->mode_set)
> + if (funcs && funcs->atomic_mode_set) {
> + funcs->atomic_mode_set(encoder, new_crtc_state,
> +connector->state);
> + } else if (funcs && funcs->mode_set) {
>   funcs->mode_set(encoder, mode, adjusted_mode);
> + }
>  
>   drm_bridge_mode_set(encoder->bridge, mode, adjusted_mode);
>   }
> diff --git a/include/drm/drm_modeset_helper_vtables.h 
> b/include/drm/drm_modeset_helper_vtables.h
> index b55f218..1b15c1f 100644
> --- a/include/drm/drm_modeset_helper_vtables.h
> +++ b/include/drm/drm_modeset_helper_vtables.h
> @@ -529,6 +529,26 @@ struct drm_encoder_helper_funcs {
>struct drm_display_mode *adjusted_mode);
>  
>   /**
> +  * @atomic_mode_set:
> +  *
> +  * This callback is used to update the display mode of an encoder.
> +  *
> +  * Note that the display pipe is completely off when this function is
> +  * called. Drivers which need hardware to be running before they program
> +  * the new display mode (because they implement runtime PM) should not
> +  * use this hook, because the helper library calls it only once and not
> +  * every time the display pipeline is suspended using either DPMS or the
> +  * new "ACTIVE" property. Such drivers should instead move all their
> +  * encoder setup into the ->enable() callback.
> +  *
> +  * This callback is used by the atomic modeset helpers instead of the
> +  * mode_set callback. It is optional in the atomic helpers.

s/mode_set/@mode_set/ Also pls a bit of text when this should be used (any
time you need to inspect connector state, since there's no direct way to
go from the encoder to the current connector). And pls add a note to
@mode_set that drivers should use @atomic_mode_set in such a case, for
cross linking.

Great docs matter ;-)

While at it I noticed that the kernel-doc for @mode_set is wrong, it says
it's only used by CRTC helpers. Can you pls fix that too?

Thanks, Daniel
> +  */
> + void (*atomic_mode_set)(struct drm_encoder *encoder,
> + struct drm_crtc_state *crtc_state,
> + struct drm_connector_state *conn_state);
> +
> + /**
>* @get_crtc:
>*
>* This callback is used by the legacy CRTC helpers to work around
> -- 
> 2.8.1
> 

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


[PATCH] drm/imx: imx-ldb: do not try to dereference crtc->state->state in encoder mode_set

2016-07-22 Thread Daniel Vetter
On Fri, Jul 22, 2016 at 12:57:15PM +0200, Philipp Zabel wrote:
> Am Freitag, den 22.07.2016, 11:35 +0200 schrieb Daniel Vetter:
> [...]
> > Proper fix would be to roll out atomic_ versions of all teh encoder
> > callbacks where we additionally pass both the crtc state and the connector
> > state. Then there's no need for walking connector lists like that. And in
> > the atomic helpers those two states are always readily available, and
> > passing them down to callbacks is also what we will do in i915. I'd be
> > happy to merge such a patch.
> 
> Thanks, that is a good idea. Which encoder callbacks besides mode_set ->
> atomic_mode_set are you thinking of, though? enable/disable?

Yes. The only other one is mode_fixup, and we already have atomic_check as
the fancy replacement for that. Please align the parameter ordering with
encoder->atomic_check for consistency.

Also when you do that patch, pls don't forget the vtable kerneldoc
comments, and make sure there's no warnings/issues and it renders nicely
using

$ make htmldocs

Since 4.8 will feature a new sphinx-based toolchain, pls run that command
on top of linux-next (for the latest sphinx fixes from docs-next).
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[PATCH v2 05/15] drm/atmel-hlcdc: Use per-plane rotation property

2016-07-22 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

The global mode_config.rotation_property is going away, switch over to
per-plane rotation_property.

v2: Propagate error upwards (Boris)

Cc: Boris Brezillon 
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 37 +
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
index f3350c80704d..ee9bd7a938c3 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
@@ -883,9 +883,9 @@ static int atmel_hlcdc_plane_atomic_get_property(struct 
drm_plane *p,
return 0;
 }

-static void atmel_hlcdc_plane_init_properties(struct atmel_hlcdc_plane *plane,
-   const struct atmel_hlcdc_layer_desc *desc,
-   struct atmel_hlcdc_plane_properties *props)
+static int atmel_hlcdc_plane_init_properties(struct atmel_hlcdc_plane *plane,
+const struct 
atmel_hlcdc_layer_desc *desc,
+struct 
atmel_hlcdc_plane_properties *props)
 {
struct regmap *regmap = plane->layer.hlcdc->regmap;

@@ -902,10 +902,18 @@ static void atmel_hlcdc_plane_init_properties(struct 
atmel_hlcdc_plane *plane,
ATMEL_HLCDC_LAYER_GA_MASK);
}

-   if (desc->layout.xstride && desc->layout.pstride)
-   drm_object_attach_property(>base.base,
-   plane->base.dev->mode_config.rotation_property,
-   BIT(DRM_ROTATE_0));
+   if (desc->layout.xstride && desc->layout.pstride) {
+   int ret;
+
+   ret = drm_plane_create_rotation_property(>base,
+BIT(DRM_ROTATE_0),
+BIT(DRM_ROTATE_0) |
+BIT(DRM_ROTATE_90) |
+BIT(DRM_ROTATE_180) |
+BIT(DRM_ROTATE_270));
+   if (ret)
+   return ret;
+   }

if (desc->layout.csc) {
/*
@@ -925,6 +933,8 @@ static void atmel_hlcdc_plane_init_properties(struct 
atmel_hlcdc_plane *plane,
 ATMEL_HLCDC_LAYER_CSC_CFG(>layer, 2),
 0x40040890);
}
+
+   return 0;
 }

 static struct drm_plane_helper_funcs atmel_hlcdc_layer_plane_helper_funcs = {
@@ -1036,7 +1046,9 @@ atmel_hlcdc_plane_create(struct drm_device *dev,
 _hlcdc_layer_plane_helper_funcs);

/* Set default property values*/
-   atmel_hlcdc_plane_init_properties(plane, desc, props);
+   ret = atmel_hlcdc_plane_init_properties(plane, desc, props);
+   if (ret)
+   return ERR_PTR(ret);

return plane;
 }
@@ -1054,15 +1066,6 @@ atmel_hlcdc_plane_create_properties(struct drm_device 
*dev)
if (!props->alpha)
return ERR_PTR(-ENOMEM);

-   dev->mode_config.rotation_property =
-   drm_mode_create_rotation_property(dev,
- BIT(DRM_ROTATE_0) |
- BIT(DRM_ROTATE_90) |
- BIT(DRM_ROTATE_180) |
- BIT(DRM_ROTATE_270));
-   if (!dev->mode_config.rotation_property)
-   return ERR_PTR(-ENOMEM);
-
return props;
 }

-- 
2.7.4



[PATCH 2/4] GPU-DRM-Etnaviv: Delete unnecessary if statement in __etnaviv_gem_new()

2016-07-22 Thread walter harms


Am 22.07.2016 17:48, schrieb SF Markus Elfring:
> From: Markus Elfring 
> Date: Fri, 22 Jul 2016 16:45:22 +0200
> 
> Move a return statement into a block for successful function execution.
> Omit a duplicate check for the local variable "ret" then at the end.
> 
> Signed-off-by: Markus Elfring 
> ---
>  drivers/gpu/drm/etnaviv/etnaviv_gem.c | 6 +-
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c 
> b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
> index 8eee742..851a8ba 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
> @@ -661,13 +661,9 @@ static struct drm_gem_object *__etnaviv_gem_new(struct 
> drm_device *dev,
>*/
>   mapping = obj->filp->f_mapping;
>   mapping_set_gfp_mask(mapping, GFP_HIGHUSER);
> + return obj;
>   }
>  
> - if (ret)
> - goto fail;
> -
> - return obj;
> -
>  fail:
>   drm_gem_object_unreference_unlocked(obj);
>   return ERR_PTR(ret);


>From the program flow an readability it would be more nice the branch on error

 ret = drm_gem_object_init(dev, obj, size);
 if (ret)
goto fail;


just m 2 cents

re,
 wh


[PATCH 4/4] GPU-DRM-Etnaviv: Optimize error handling in etnaviv_gem_new_userptr()

2016-07-22 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 22 Jul 2016 17:17:48 +0200

Refactor this function implementation so that the
drm_gem_object_unreference_unlocked() function will only be called once
in case of a failure according to the Linux coding style recommendation
for centralized exiting of functions.

Signed-off-by: Markus Elfring 
---
 drivers/gpu/drm/etnaviv/etnaviv_gem.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c 
b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
index 0a5c00c..007577c 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
@@ -909,15 +909,12 @@ int etnaviv_gem_new_userptr(struct drm_device *dev, 
struct drm_file *file,
get_task_struct(current);

ret = etnaviv_gem_obj_add(dev, _obj->base);
-   if (ret) {
-   drm_gem_object_unreference_unlocked(_obj->base);
-   return ret;
-   }
+   if (ret)
+   goto unreference;

ret = drm_gem_handle_create(file, _obj->base, handle);
-
+unreference:
/* drop reference from allocate - handle holds it now */
drm_gem_object_unreference_unlocked(_obj->base);
-
return ret;
 }
-- 
2.9.2



[PATCH 3/4] GPU-DRM-Etnaviv: Rename jump labels

2016-07-22 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 22 Jul 2016 16:51:00 +0200

Adjust jump targets according to the Linux coding style convention.

Signed-off-by: Markus Elfring 
---
 drivers/gpu/drm/etnaviv/etnaviv_gem.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c 
b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
index 851a8ba..0a5c00c 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
@@ -308,17 +308,17 @@ struct etnaviv_vram_mapping *etnaviv_gem_mapping_get(
mapping = NULL;
mutex_unlock(>mmu->lock);
if (mapping)
-   goto out;
+   goto unlock;
} else {
mapping->use += 1;
-   goto out;
+   goto unlock;
}
}

pages = etnaviv_gem_get_pages(etnaviv_obj);
if (IS_ERR(pages)) {
ret = PTR_ERR(pages);
-   goto out;
+   goto unlock;
}

/*
@@ -330,7 +330,7 @@ struct etnaviv_vram_mapping *etnaviv_gem_mapping_get(
mapping = kzalloc(sizeof(*mapping), GFP_KERNEL);
if (!mapping) {
ret = -ENOMEM;
-   goto out;
+   goto unlock;
}

INIT_LIST_HEAD(>scan_node);
@@ -349,7 +349,7 @@ struct etnaviv_vram_mapping *etnaviv_gem_mapping_get(
else
list_add_tail(>obj_node, _obj->vram_list);

-out:
+unlock:
mutex_unlock(_obj->lock);

if (ret)
@@ -646,7 +646,7 @@ static struct drm_gem_object *__etnaviv_gem_new(struct 
drm_device *dev,
ret = etnaviv_gem_new_impl(dev, size, flags, NULL,
   _gem_shmem_ops, );
if (ret)
-   goto fail;
+   goto unreference;

ret = drm_gem_object_init(dev, obj, size);
if (ret == 0) {
@@ -664,7 +664,7 @@ static struct drm_gem_object *__etnaviv_gem_new(struct 
drm_device *dev,
return obj;
}

-fail:
+unreference:
drm_gem_object_unreference_unlocked(obj);
return ERR_PTR(ret);
 }
-- 
2.9.2



[PATCH 2/4] GPU-DRM-Etnaviv: Delete unnecessary if statement in __etnaviv_gem_new()

2016-07-22 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 22 Jul 2016 16:45:22 +0200

Move a return statement into a block for successful function execution.
Omit a duplicate check for the local variable "ret" then at the end.

Signed-off-by: Markus Elfring 
---
 drivers/gpu/drm/etnaviv/etnaviv_gem.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c 
b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
index 8eee742..851a8ba 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
@@ -661,13 +661,9 @@ static struct drm_gem_object *__etnaviv_gem_new(struct 
drm_device *dev,
 */
mapping = obj->filp->f_mapping;
mapping_set_gfp_mask(mapping, GFP_HIGHUSER);
+   return obj;
}

-   if (ret)
-   goto fail;
-
-   return obj;
-
 fail:
drm_gem_object_unreference_unlocked(obj);
return ERR_PTR(ret);
-- 
2.9.2



[PATCH 1/4] GPU-DRM-Etnaviv: Delete unnecessary checks before two function calls

2016-07-22 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 22 Jul 2016 15:56:15 +0200

The functions drm_gem_object_unreference_unlocked() and vunmap() perform
also input parameter validation.
Thus the tests around their calls are not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/gpu/drm/etnaviv/etnaviv_gem.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c 
b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
index 8c6f750..8eee742 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
@@ -535,8 +535,7 @@ void etnaviv_gem_describe_objects(struct 
etnaviv_drm_private *priv,

 static void etnaviv_gem_shmem_release(struct etnaviv_gem_object *etnaviv_obj)
 {
-   if (etnaviv_obj->vaddr)
-   vunmap(etnaviv_obj->vaddr);
+   vunmap(etnaviv_obj->vaddr);
put_pages(etnaviv_obj);
 }

@@ -670,9 +669,7 @@ static struct drm_gem_object *__etnaviv_gem_new(struct 
drm_device *dev,
return obj;

 fail:
-   if (obj)
-   drm_gem_object_unreference_unlocked(obj);
-
+   drm_gem_object_unreference_unlocked(obj);
return ERR_PTR(ret);
 }

-- 
2.9.2



[PATCH 0/4] GPU-DRM-Etnaviv: Fine-tuning for a few functions

2016-07-22 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 22 Jul 2016 17:34:32 +0200

Further update suggestions were taken into account
after a patch was applied from static source code analysis.

Markus Elfring (4):
  Delete unnecessary checks before two function calls
  Delete unnecessary if statement in __etnaviv_gem_new()
  Rename jump labels
  Optimize error handling in etnaviv_gem_new_userptr()

 drivers/gpu/drm/etnaviv/etnaviv_gem.c | 36 +--
 1 file changed, 13 insertions(+), 23 deletions(-)

-- 
2.9.2



[PATCH] drm/imx: imx-ldb: store LVDS bus configuration in ldb channel

2016-07-22 Thread Ying Liu
Hi Philipp,

On Fri, Jul 22, 2016 at 4:59 PM, Philipp Zabel  
wrote:
> Hi Liu,
>
> thank you for your comments.
>
> Am Freitag, den 22.07.2016, 12:01 +0800 schrieb Ying Liu:
>> Hi Philipp,
>>
>> This patch's headline doesn't exactly reflect what the patch actually
>> does - retrieve lvds bus format from imx_crtc_state during encoder
>> mode_set.
>
> Yes. I initially stored ldb_bus_format in imx_ldb_ch, then fixed that,
> and forgot to change the subject.
>
>> On Thu, Jul 21, 2016 at 9:25 PM, Philipp Zabel  
>> wrote:
>> > The code in imx_ldb_encoder_mode_set crashes trying to access the
>> > crtc->state->state drm_atomic_state pointer if that was previously
>> > cleared by drm_atomic_helper_swap_state.
>>
>> Nit: Providing a crash log might be good.
>
> Will do.
>
>> > Instead of trying to walk all connectors during encoder mode_set to
>> > determine the LVDS bus format from panel or external bridge connector
>> > display info, store it in imx_crtc_state during encoder atomic_check,
>> > where it is already known, and just retrieve it from imx_crtc_state
>> > during encoder mode_set.
>> >
>> > Fixes: 49f98bc4d44a4 ("drm/imx: store internal bus configuration in crtc 
>> > state")
>> > Signed-off-by: Philipp Zabel 
>> > ---
>> >  drivers/gpu/drm/imx/imx-drm.h |  1 +
>> >  drivers/gpu/drm/imx/imx-ldb.c | 22 +-
>> >  2 files changed, 6 insertions(+), 17 deletions(-)
>> >
>> > diff --git a/drivers/gpu/drm/imx/imx-drm.h b/drivers/gpu/drm/imx/imx-drm.h
>> > index bdaa381..5e2f68a 100644
>> > --- a/drivers/gpu/drm/imx/imx-drm.h
>> > +++ b/drivers/gpu/drm/imx/imx-drm.h
>> > @@ -19,6 +19,7 @@ struct imx_crtc_state {
>> > u32 bus_flags;
>> > int di_hsync_pin;
>> > int di_vsync_pin;
>> > +   u32 ldb_bus_format;
>>
>> Pretty much a hack here, I think.
>> Comparing to the other members of imx_crtc_state,
>> ldb_bus_format is less likely to be a member, since
>> crtc just doesn't like to know the LVDS bus format...
>
> I suppose I should keep the connector walk then. I'll send a new
> version.
>
> [...]
>> Instead of introducing imx_crtc_state->ldb_bus_format to get the
>> lvds bus format, you may get the connector via
>> crtc_state->connector_mask(verify connector->encoder to be
>> the encoder we are talking about). connector_mask is maintained
>> well by the atomic core I assume.
>
> I could also use drm_for_each_connector and just keep the
> (connector->state->crtc == encoder->crtc) check in the loop.

It looks (connector->encoder == encoder) is simpler.

Regards,
Liu Ying

>
> regards
> Philipp
>


[PATCH 1/1] drm/sti: use new Reset API

2016-07-22 Thread Lee Jones
On Fri, 22 Jul 2016, Sean Paul wrote:

> On Fri, Jul 22, 2016 at 3:22 AM, Lee Jones  wrote:
> > Since 0b52297f228 ("reset: Add support for shared reset controls") the
> > new Reset API now demands consumers choose either an *_exclusive or
> > a *_shared line when requesting reset lines.
> >
> > Signed-off-by: Lee Jones 
> > ---
> >  drivers/gpu/drm/sti/sti_compositor.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/sti/sti_compositor.c 
> > b/drivers/gpu/drm/sti/sti_compositor.c
> > index 3d2fa3a..c2ace02 100644
> > --- a/drivers/gpu/drm/sti/sti_compositor.c
> > +++ b/drivers/gpu/drm/sti/sti_compositor.c
> > @@ -234,12 +234,12 @@ static int sti_compositor_probe(struct 
> > platform_device *pdev)
> > }
> >
> > /* Get reset resources */
> > -   compo->rst_main = devm_reset_control_get(dev, "compo-main");
> > +   compo->rst_main = devm_reset_control_get_shared(dev, "compo-main");
> 
> Seems like this patch also changes the behavior from being exclusively
> managed to shared. Is this intentional? If so, it's probably worth
> changing you commit message to be a little less innocuous.

Interesting turn of phrase.  You would like the commit message to be
more "harmful or offensive".  I'm sure I can rustle something up to
suit!

... or I could just mention why I'm changing the behaviour? ;)

v2 to follow.

> > /* Take compo main out of reset */
> > if (!IS_ERR(compo->rst_main))
> > reset_control_deassert(compo->rst_main);
> >
> > -   compo->rst_aux = devm_reset_control_get(dev, "compo-aux");
> > +   compo->rst_aux = devm_reset_control_get_shared(dev, "compo-aux");
> > /* Take compo aux out of reset */
> > if (!IS_ERR(compo->rst_aux))
> > reset_control_deassert(compo->rst_aux);
> >
> > ___
> > dri-devel mailing list
> > dri-devel at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


[PATCH v3 7/7] drm/rockchip: Add dmc notifier in vop driver

2016-07-22 Thread Lin Huang
when in ddr frequency scaling process, vop can not do
enable or disable operate, since dcf will base on vop vblank
time to do frequency scaling and need to get vop irq if there
have vop enabled. So need register to dmc notifier, and we can
get the dmc status.

Signed-off-by: Lin Huang 
---
Changes in v3:
- when do vop eanble/disable, dmc will wait until it finish

Changes in v2:
- None

Changes in v1:
- use wait_event instead usleep

 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 75 ++---
 1 file changed, 69 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index 6255e5b..4220629 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -31,6 +31,8 @@
 #include 
 #include 

+#include 
+
 #include "rockchip_drm_drv.h"
 #include "rockchip_drm_gem.h"
 #include "rockchip_drm_fb.h"
@@ -120,6 +122,11 @@ struct vop {

const struct vop_data *data;

+   struct notifier_block dmc_nb;
+   int dmc_in_process;
+   int vop_switch_status;
+   wait_queue_head_t   wait_dmc_queue;
+   wait_queue_head_t   wait_vop_switch_queue;
uint32_t *regsbak;
void __iomem *regs;

@@ -430,21 +437,56 @@ static void vop_dsp_hold_valid_irq_disable(struct vop 
*vop)
spin_unlock_irqrestore(>irq_lock, flags);
 }

+static int dmc_notify(struct notifier_block *nb, unsigned long event,
+ void *data)
+{
+   struct vop *vop = container_of(nb, struct vop, dmc_nb);
+
+   if (event == DMCFREQ_ADJUST) {
+
+   /*
+* check if vop in enable or disable process,
+* if yes, wait until it finish, use 200ms as
+* timeout.
+*/
+   wait_event_timeout(vop->wait_vop_switch_queue,
+  !vop->vop_switch_status, HZ / 5);
+   vop->dmc_in_process = 1;
+   } else if (event == DMCFREQ_FINISH) {
+   vop->dmc_in_process = 0;
+   wake_up(>wait_dmc_queue);
+   }
+
+   return NOTIFY_OK;
+}
+
 static void vop_enable(struct drm_crtc *crtc)
 {
struct vop *vop = to_vop(crtc);
int ret;

+   if (vop->is_enabled)
+   return;
+
+   /*
+* if in dmc scaling frequency process, wait until it finish
+* use 100ms as timeout time.
+*/
+   wait_event_timeout(vop->wait_dmc_queue,
+  !vop->dmc_in_process, HZ / 5);
+
+   vop->vop_switch_status = 1;
+
ret = pm_runtime_get_sync(vop->dev);
if (ret < 0) {
dev_err(vop->dev, "failed to get pm runtime: %d\n", ret);
-   return;
+   goto err;
}

ret = clk_enable(vop->hclk);
if (ret < 0) {
dev_err(vop->dev, "failed to enable hclk - %d\n", ret);
-   return;
+   goto err;
}

ret = clk_enable(vop->dclk);
@@ -458,7 +500,6 @@ static void vop_enable(struct drm_crtc *crtc)
dev_err(vop->dev, "failed to enable aclk - %d\n", ret);
goto err_disable_dclk;
}
-
/*
 * Slave iommu shares power, irq and clock with vop.  It was associated
 * automatically with this master device via common driver code.
@@ -486,7 +527,9 @@ static void vop_enable(struct drm_crtc *crtc)
enable_irq(vop->irq);

drm_crtc_vblank_on(crtc);
-
+   vop->vop_switch_status = 0;
+   wake_up(>wait_vop_switch_queue);
+   rockchip_dmc_get(>dmc_nb);
return;

 err_disable_aclk:
@@ -495,6 +538,10 @@ err_disable_dclk:
clk_disable(vop->dclk);
 err_disable_hclk:
clk_disable(vop->hclk);
+err:
+   vop->vop_switch_status = 0;
+   wake_up(>wait_vop_switch_queue);
+   return;
 }

 static void vop_crtc_disable(struct drm_crtc *crtc)
@@ -505,6 +552,15 @@ static void vop_crtc_disable(struct drm_crtc *crtc)
WARN_ON(vop->event);

/*
+* if in dmc scaling frequency process, wait until it finish
+* use 100ms as timeout time.
+*/
+   wait_event_timeout(vop->wait_dmc_queue,
+  !vop->dmc_in_process, HZ / 5);
+
+   vop->vop_switch_status = 1;
+
+   /*
 * We need to make sure that all windows are disabled before we
 * disable that crtc. Otherwise we might try to scan from a destroyed
 * buffer later.
@@ -517,7 +573,6 @@ static void vop_crtc_disable(struct drm_crtc *crtc)
VOP_WIN_SET(vop, win, enable, 0);
spin_unlock(>reg_lock);
}
-
drm_crtc_vblank_off(crtc);

/*
@@ -548,7 +603,6 @@ static void vop_crtc_disable(struct drm_crtc *crtc)
 * vop standby complete, so iommu detach is safe.
 */
rockchip_drm_dma_detach_device(vop->drm_dev, vop->dev);
-
clk_disable(vop->dclk);

[PATCH v3 6/7] PM / devfreq: rockchip: add devfreq driver for rk3399 dmc

2016-07-22 Thread Lin Huang
base on dfi result, we do ddr frequency scaling, register
dmc driver to devfreq framework, and use simple-ondemand
policy.

Signed-off-by: Lin Huang 
---
Changes in v3:
- operate dram setting through sip call
- imporve set rate flow

Changes in v2:
- None

Changes in v1:
- move dfi controller to event
- fix set voltage sequence when set rate fail
- change Kconfig type from tristate to bool
- move unuse EXPORT_SYMBOL_GPL()

 drivers/devfreq/Kconfig |   1 +
 drivers/devfreq/Makefile|   1 +
 drivers/devfreq/rockchip/Kconfig|  15 +
 drivers/devfreq/rockchip/Makefile   |   2 +
 drivers/devfreq/rockchip/rk3399_dmc.c   | 482 
 drivers/devfreq/rockchip/rockchip_dmc.c | 143 ++
 include/soc/rockchip/rockchip_dmc.h |  45 +++
 7 files changed, 689 insertions(+)
 create mode 100644 drivers/devfreq/rockchip/Kconfig
 create mode 100644 drivers/devfreq/rockchip/Makefile
 create mode 100644 drivers/devfreq/rockchip/rk3399_dmc.c
 create mode 100644 drivers/devfreq/rockchip/rockchip_dmc.c
 create mode 100644 include/soc/rockchip/rockchip_dmc.h

diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig
index a5be56e..cb67246 100644
--- a/drivers/devfreq/Kconfig
+++ b/drivers/devfreq/Kconfig
@@ -101,5 +101,6 @@ config ARM_TEGRA_DEVFREQ
  operating frequencies and voltages with OPP support.

 source "drivers/devfreq/event/Kconfig"
+source "drivers/devfreq/rockchip/Kconfig"

 endif # PM_DEVFREQ
diff --git a/drivers/devfreq/Makefile b/drivers/devfreq/Makefile
index 09f11d9..48e2ae6 100644
--- a/drivers/devfreq/Makefile
+++ b/drivers/devfreq/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_DEVFREQ_GOV_PASSIVE)   += governor_passive.o
 # DEVFREQ Drivers
 obj-$(CONFIG_ARM_EXYNOS_BUS_DEVFREQ)   += exynos-bus.o
 obj-$(CONFIG_ARM_TEGRA_DEVFREQ)+= tegra-devfreq.o
+obj-$(CONFIG_ARCH_ROCKCHIP)+= rockchip/

 # DEVFREQ Event Drivers
 obj-$(CONFIG_PM_DEVFREQ_EVENT) += event/
diff --git a/drivers/devfreq/rockchip/Kconfig b/drivers/devfreq/rockchip/Kconfig
new file mode 100644
index 000..7fb1cff
--- /dev/null
+++ b/drivers/devfreq/rockchip/Kconfig
@@ -0,0 +1,15 @@
+config ARM_ROCKCHIP_DMC_DEVFREQ
+   bool "ARM ROCKCHIP DMC DEVFREQ Driver"
+   depends on ARCH_ROCKCHIP
+   help
+ This adds the DEVFREQ driver framework for the rockchip dmc.
+
+config ARM_RK3399_DMC_DEVFREQ
+   bool "ARM RK3399 DMC DEVFREQ Driver"
+   depends on ARM_ROCKCHIP_DMC_DEVFREQ
+   select PM_OPP
+   select DEVFREQ_GOV_SIMPLE_ONDEMAND
+   help
+  This adds the DEVFREQ driver for the RK3399 dmc. It sets the 
frequency
+  for the memory controller and reads the usage counts from hardware.
+
diff --git a/drivers/devfreq/rockchip/Makefile 
b/drivers/devfreq/rockchip/Makefile
new file mode 100644
index 000..caca525
--- /dev/null
+++ b/drivers/devfreq/rockchip/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_ARM_ROCKCHIP_DMC_DEVFREQ) += rockchip_dmc.o
+obj-$(CONFIG_ARM_RK3399_DMC_DEVFREQ)   += rk3399_dmc.o
diff --git a/drivers/devfreq/rockchip/rk3399_dmc.c 
b/drivers/devfreq/rockchip/rk3399_dmc.c
new file mode 100644
index 000..f1d6120
--- /dev/null
+++ b/drivers/devfreq/rockchip/rk3399_dmc.c
@@ -0,0 +1,482 @@
+/*
+ * Copyright (c) 2016, Fuzhou Rockchip Electronics Co., Ltd
+ * Author: Lin Huang 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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 
+#include 
+
+#include 
+#include "../../firmware/rockchip_sip.h"
+
+struct dram_timing {
+   unsigned int ddr3_speed_bin;
+   unsigned int pd_idle;
+   unsigned int sr_idle;
+   unsigned int sr_mc_gate_idle;
+   unsigned int srpd_lite_idle;
+   unsigned int standby_idle;
+   unsigned int dram_dll_dis_freq;
+   unsigned int phy_dll_dis_freq;
+   unsigned int ddr3_odt_dis_freq;
+   unsigned int ddr3_drv;
+   unsigned int ddr3_odt;
+   unsigned int phy_ddr3_ca_drv;
+   unsigned int phy_ddr3_dq_drv;
+   unsigned int phy_ddr3_odt;
+   unsigned int lpddr3_odt_dis_freq;
+   unsigned int lpddr3_drv;
+   unsigned int lpddr3_odt;
+   unsigned int phy_lpddr3_ca_drv;
+   unsigned int phy_lpddr3_dq_drv;
+   unsigned int phy_lpddr3_odt;
+   unsigned int lpddr4_odt_dis_freq;
+   unsigned int lpddr4_drv;
+   unsigned int lpddr4_dq_odt;
+   unsigned int lpddr4_ca_odt;
+   unsigned int phy_lpddr4_ca_drv;
+   unsigned 

[PATCH v3 5/7] PM / devfreq: event: support rockchip dfi controller

2016-07-22 Thread Lin Huang
on rk3399 platform, there is dfi conroller can monitor
ddr load, base on this result, we can do ddr freqency
scaling.

Signed-off-by: Lin Huang 
Acked-by: Chanwoo Choi 
---
Changes in v3:
- None

Changes in v2:
- use clk_disable_unprepare and clk_enable_prepare
- remove clk_enable_prepare in probe
- remove rockchip_dfi_remove function

Changes in v1:
- None

 drivers/devfreq/event/Kconfig|   7 +
 drivers/devfreq/event/Makefile   |   1 +
 drivers/devfreq/event/rockchip-dfi.c | 253 +++
 3 files changed, 261 insertions(+)
 create mode 100644 drivers/devfreq/event/rockchip-dfi.c

diff --git a/drivers/devfreq/event/Kconfig b/drivers/devfreq/event/Kconfig
index eb6f74a..0d32d68 100644
--- a/drivers/devfreq/event/Kconfig
+++ b/drivers/devfreq/event/Kconfig
@@ -30,4 +30,11 @@ config DEVFREQ_EVENT_EXYNOS_PPMU
  (Platform Performance Monitoring Unit) counters to estimate the
  utilization of each module.

+config DEVFREQ_EVENT_ROCKCHIP_DFI
+   bool "ROCKCHIP DFI DEVFREQ event Driver"
+   depends on ARCH_ROCKCHIP
+   help
+ This add the devfreq-event driver for Rockchip SoC. It provides DFI
+ (DDR Monitor Module) driver to count ddr load.
+
 endif # PM_DEVFREQ_EVENT
diff --git a/drivers/devfreq/event/Makefile b/drivers/devfreq/event/Makefile
index 3d6afd3..dda7090 100644
--- a/drivers/devfreq/event/Makefile
+++ b/drivers/devfreq/event/Makefile
@@ -2,3 +2,4 @@

 obj-$(CONFIG_DEVFREQ_EVENT_EXYNOS_NOCP) += exynos-nocp.o
 obj-$(CONFIG_DEVFREQ_EVENT_EXYNOS_PPMU) += exynos-ppmu.o
+obj-$(CONFIG_DEVFREQ_EVENT_ROCKCHIP_DFI) += rockchip-dfi.o
diff --git a/drivers/devfreq/event/rockchip-dfi.c 
b/drivers/devfreq/event/rockchip-dfi.c
new file mode 100644
index 000..96a0307
--- /dev/null
+++ b/drivers/devfreq/event/rockchip-dfi.c
@@ -0,0 +1,253 @@
+/*
+ * Copyright (c) 2016, Fuzhou Rockchip Electronics Co., Ltd
+ * Author: Lin Huang 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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 RK3399_DMC_NUM_CH  2
+
+/* DDRMON_CTRL */
+#define DDRMON_CTRL0x04
+#define CLR_DDRMON_CTRL(0x1f << 0)
+#define LPDDR4_EN  (0x10001 << 4)
+#define HARDWARE_EN(0x10001 << 3)
+#define LPDDR3_EN  (0x10001 << 2)
+#define SOFTWARE_EN(0x10001 << 1)
+#define TIME_CNT_EN(0x10001 << 0)
+
+#define DDRMON_CH0_COUNT_NUM   0x28
+#define DDRMON_CH0_DFI_ACCESS_NUM  0x2c
+#define DDRMON_CH1_COUNT_NUM   0x3c
+#define DDRMON_CH1_DFI_ACCESS_NUM  0x40
+
+/* pmu grf */
+#define PMUGRF_OS_REG2 0x308
+#define DDRTYPE_SHIFT  13
+#define DDRTYPE_MASK   7
+
+enum {
+   DDR3 = 3,
+   LPDDR3 = 6,
+   LPDDR4 = 7,
+   UNUSED = 0xFF
+};
+
+struct dmc_usage {
+   u32 access;
+   u32 total;
+};
+
+struct rockchip_dfi {
+   struct devfreq_event_dev *edev;
+   struct devfreq_event_desc *desc;
+   struct dmc_usage ch_usage[RK3399_DMC_NUM_CH];
+   struct device *dev;
+   void __iomem *regs;
+   struct regmap *regmap_pmu;
+   struct clk *clk;
+};
+
+static void rockchip_dfi_start_hardware_counter(struct devfreq_event_dev *edev)
+{
+   struct rockchip_dfi *info = devfreq_event_get_drvdata(edev);
+   void __iomem *dfi_regs = info->regs;
+   u32 val;
+   u32 ddr_type;
+
+   /* get ddr type */
+   regmap_read(info->regmap_pmu, PMUGRF_OS_REG2, );
+   ddr_type = (val >> DDRTYPE_SHIFT) & DDRTYPE_MASK;
+
+   /* clear DDRMON_CTRL setting */
+   writel_relaxed(CLR_DDRMON_CTRL, dfi_regs + DDRMON_CTRL);
+
+   /* set ddr type to dfi */
+   if (ddr_type == LPDDR3)
+   writel_relaxed(LPDDR3_EN, dfi_regs + DDRMON_CTRL);
+   else if (ddr_type == LPDDR4)
+   writel_relaxed(LPDDR4_EN, dfi_regs + DDRMON_CTRL);
+
+   /* enable count, use software mode */
+   writel_relaxed(SOFTWARE_EN, dfi_regs + DDRMON_CTRL);
+}
+
+static void rockchip_dfi_stop_hardware_counter(struct devfreq_event_dev *edev)
+{
+   struct rockchip_dfi *info = devfreq_event_get_drvdata(edev);
+   void __iomem *dfi_regs = info->regs;
+   u32 val;
+
+   val = readl_relaxed(dfi_regs + DDRMON_CTRL);
+   val &= ~SOFTWARE_EN;
+   writel_relaxed(val, dfi_regs + DDRMON_CTRL);
+}
+
+static int rockchip_dfi_get_busier_ch(struct devfreq_event_dev *edev)
+{
+   struct rockchip_dfi *info = devfreq_event_get_drvdata(edev);
+   u32 tmp, max = 0;
+   u32 i, busier_ch = 0;
+   

[PATCH v3 4/7] clk: rockchip: rk3399: add ddrc clock support

2016-07-22 Thread Lin Huang
add ddrc clock setting, so we can do ddr frequency
scaling on rk3399 platform in future.

Signed-off-by: Lin Huang 
---
Changes in v3:
- None

Changes in v2:
- remove clk_ddrc_dpll_src from critical clock list

Changes in v1:
- remove ddrc source CLK_IGNORE_UNUSED flag
- move clk_ddrc and clk_ddrc_dpll_src to critical

 drivers/clk/rockchip/clk-rk3399.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/drivers/clk/rockchip/clk-rk3399.c 
b/drivers/clk/rockchip/clk-rk3399.c
index c109d80..7ef9d82 100644
--- a/drivers/clk/rockchip/clk-rk3399.c
+++ b/drivers/clk/rockchip/clk-rk3399.c
@@ -118,6 +118,10 @@ PNAME(mux_armclkb_p)   = { 
"clk_core_b_lpll_src",
"clk_core_b_bpll_src",
"clk_core_b_dpll_src",
"clk_core_b_gpll_src" };
+PNAME(mux_ddrclk_p)= { "clk_ddrc_lpll_src",
+   "clk_ddrc_bpll_src",
+   "clk_ddrc_dpll_src",
+   "clk_ddrc_gpll_src" };
 PNAME(mux_aclk_cci_p)  = { "cpll_aclk_cci_src",
"gpll_aclk_cci_src",
"npll_aclk_cci_src",
@@ -1377,6 +1381,18 @@ static struct rockchip_clk_branch rk3399_clk_branches[] 
__initdata = {
COMPOSITE_NOMUX(0, "clk_test", "clk_test_pre", CLK_IGNORE_UNUSED,
RK3368_CLKSEL_CON(58), 0, 5, DFLAGS,
RK3368_CLKGATE_CON(13), 11, GFLAGS),
+
+   /* ddrc */
+   GATE(0, "clk_ddrc_lpll_src", "lpll", 0, RK3399_CLKGATE_CON(3),
+0, GFLAGS),
+   GATE(0, "clk_ddrc_bpll_src", "bpll", 0, RK3399_CLKGATE_CON(3),
+1, GFLAGS),
+   GATE(0, "clk_ddrc_dpll_src", "dpll", 0, RK3399_CLKGATE_CON(3),
+2, GFLAGS),
+   GATE(0, "clk_ddrc_gpll_src", "gpll", 0, RK3399_CLKGATE_CON(3),
+3, GFLAGS),
+   COMPOSITE_DDRC(SCLK_DDRCLK, "clk_ddrc", mux_ddrclk_p, 0,
+  RK3399_CLKSEL_CON(6), 4, 2, MFLAGS, 0, 3, DFLAGS),
 };

 static struct rockchip_clk_branch rk3399_clk_pmu_branches[] __initdata = {
@@ -1487,6 +1503,9 @@ static const char *const rk3399_cru_critical_clocks[] 
__initconst = {
"gpll_hclk_perilp1_src",
"gpll_aclk_perilp0_src",
"gpll_aclk_perihp_src",
+
+   /* ddrc */
+   "clk_ddrc"
 };

 static const char *const rk3399_pmucru_critical_clocks[] __initconst = {
-- 
2.6.6



[PATCH v3 3/7] clk: rockchip: rk3399: add SCLK_DDRCLK ID for ddrc

2016-07-22 Thread Lin Huang
Signed-off-by: Lin Huang 
---
Changes in v3:
-None

Changes in v2:
- None 
Changes in v1:
- None

 include/dt-bindings/clock/rk3399-cru.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/dt-bindings/clock/rk3399-cru.h 
b/include/dt-bindings/clock/rk3399-cru.h
index 50a44cf..8a0f0442 100644
--- a/include/dt-bindings/clock/rk3399-cru.h
+++ b/include/dt-bindings/clock/rk3399-cru.h
@@ -131,6 +131,7 @@
 #define SCLK_DPHY_RX0_CFG  165
 #define SCLK_RMII_SRC  166
 #define SCLK_PCIEPHY_REF100M   167
+#define SCLK_DDRCLK168

 #define DCLK_VOP0  180
 #define DCLK_VOP1  181
-- 
2.6.6



[PATCH v3 2/7] clk: rockchip: add new clock-type for the ddrclk

2016-07-22 Thread Lin Huang
On new rockchip platform(rk3399 etc), there have dcf controller to
do ddr frequency scaling, and this controller will implement in
arm-trust-firmware. We add a special clock-type to handle that.

Signed-off-by: Lin Huang 
---
Changes in v3:
- use sip call to set/read ddr rate

Changes in v2:
- use GENMASK instead val_mask
- use divider_recalc_rate() instead DIV_ROUND_UP_ULL
- cleanup code

Changes in v1:
- None

 drivers/clk/rockchip/Makefile  |   1 +
 drivers/clk/rockchip/clk-ddr.c | 139 +
 drivers/clk/rockchip/clk.c |   9 +++
 drivers/clk/rockchip/clk.h |  27 
 4 files changed, 176 insertions(+)
 create mode 100644 drivers/clk/rockchip/clk-ddr.c

diff --git a/drivers/clk/rockchip/Makefile b/drivers/clk/rockchip/Makefile
index f47a2fa..b5f2c8e 100644
--- a/drivers/clk/rockchip/Makefile
+++ b/drivers/clk/rockchip/Makefile
@@ -8,6 +8,7 @@ obj-y   += clk-pll.o
 obj-y  += clk-cpu.o
 obj-y  += clk-inverter.o
 obj-y  += clk-mmc-phase.o
+obj-y  += clk-ddr.o
 obj-$(CONFIG_RESET_CONTROLLER) += softrst.o

 obj-y  += clk-rk3036.o
diff --git a/drivers/clk/rockchip/clk-ddr.c b/drivers/clk/rockchip/clk-ddr.c
new file mode 100644
index 000..6f5f05e
--- /dev/null
+++ b/drivers/clk/rockchip/clk-ddr.c
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2016 Rockchip Electronics Co. Ltd.
+ * Author: Lin Huang 
+ *
+ * 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 "../../firmware/rockchip_sip.h"
+#include "clk.h"
+
+struct rockchip_ddrclk {
+   struct clk_hw   hw;
+   void __iomem*reg_base;
+   int mux_offset;
+   int mux_shift;
+   int mux_width;
+   int mux_flag;
+   int div_shift;
+   int div_width;
+   int div_flag;
+   spinlock_t  *lock;
+};
+
+#define to_rockchip_ddrclk_hw(hw) container_of(hw, struct rockchip_ddrclk, hw)
+
+static int rockchip_ddrclk_set_rate(struct clk_hw *hw, unsigned long drate,
+   unsigned long prate)
+{
+   u64 value;
+   struct rockchip_ddrclk *ddrclk = to_rockchip_ddrclk_hw(hw);
+   unsigned long flags;
+
+   spin_lock_irqsave(ddrclk->lock, flags);
+   value = sip_smc_set_ddr_rate(drate);
+   spin_unlock_irqrestore(ddrclk->lock, flags);
+
+   return 0;
+}
+
+static unsigned long
+rockchip_ddrclk_recalc_rate(struct clk_hw *hw,
+   unsigned long parent_rate)
+{
+   return sip_smc_get_ddr_rate();
+}
+
+static long clk_ddrclk_round_rate(struct clk_hw *hw, unsigned long rate,
+ unsigned long *prate)
+{
+   return rate;
+}
+
+static u8 rockchip_ddrclk_get_parent(struct clk_hw *hw)
+{
+   struct rockchip_ddrclk *ddrclk = to_rockchip_ddrclk_hw(hw);
+   int num_parents = clk_hw_get_num_parents(hw);
+   u32 val;
+
+   val = clk_readl(ddrclk->reg_base +
+   ddrclk->mux_offset) >> ddrclk->mux_shift;
+   val &= GENMASK(ddrclk->mux_width - 1, 0);
+
+   if (val >= num_parents)
+   return -EINVAL;
+
+   return val;
+}
+
+static const struct clk_ops rockchip_ddrclk_ops = {
+   .recalc_rate = rockchip_ddrclk_recalc_rate,
+   .set_rate = rockchip_ddrclk_set_rate,
+   .round_rate = clk_ddrclk_round_rate,
+   .get_parent = rockchip_ddrclk_get_parent,
+};
+
+struct clk *rockchip_clk_register_ddrclk(const char *name, int flags,
+const char *const *parent_names,
+u8 num_parents, int mux_offset,
+int mux_shift, int mux_width,
+int mux_flag, int div_shift,
+int div_width, int div_flag,
+void __iomem *reg_base,
+spinlock_t *lock)
+{
+   struct rockchip_ddrclk *ddrclk;
+   struct clk_init_data init;
+   struct clk *clk;
+
+   ddrclk = kzalloc(sizeof(*ddrclk), GFP_KERNEL);
+   if (!ddrclk)
+   return ERR_PTR(-ENOMEM);
+
+   init.name = name;
+   init.parent_names = parent_names;
+   init.num_parents = num_parents;
+   init.ops = _ddrclk_ops;
+
+   init.flags = flags;
+   init.flags |= CLK_SET_RATE_NO_REPARENT;
+   init.flags |= CLK_GET_RATE_NOCACHE;
+
+   ddrclk->reg_base = reg_base;
+

[PATCH v3 1/7] firmware: rockchip: sip: Add rockchip SIP runtime service

2016-07-22 Thread Lin Huang
From: Shengfei xu 

This patch adds support for the SiP interface, we can pass dram
paramtert to bl31, and control ddr frequency scaling in bl31.

Signed-off-by: Shengfei xu 
Signed-off-by: Lin Huang 
---
Changes in v3:
- None

Changes in v2:
- None

Changes in v1:
- None

 drivers/firmware/Kconfig|  7 +
 drivers/firmware/Makefile   |  1 +
 drivers/firmware/rockchip_sip.c | 64 +
 drivers/firmware/rockchip_sip.h | 59 +
 4 files changed, 131 insertions(+)
 create mode 100644 drivers/firmware/rockchip_sip.c
 create mode 100644 drivers/firmware/rockchip_sip.h

diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig
index 0e22f24..6f585c5 100644
--- a/drivers/firmware/Kconfig
+++ b/drivers/firmware/Kconfig
@@ -206,6 +206,13 @@ config QCOM_SCM_64
 config HAVE_ARM_SMCCC
bool

+config ROCKCHIP_SIP
+   bool "Rockchip SIP interface"
+   depends on ARM64 && ARM_PSCI_FW
+   help
+ Say Y here if you want to enable SIP callbacks for Rockchip platforms
+ This option enables support for communicating with the ATF.
+
 source "drivers/firmware/broadcom/Kconfig"
 source "drivers/firmware/google/Kconfig"
 source "drivers/firmware/efi/Kconfig"
diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile
index 44a59dc..e9eab5b 100644
--- a/drivers/firmware/Makefile
+++ b/drivers/firmware/Makefile
@@ -25,3 +25,4 @@ obj-y += broadcom/
 obj-$(CONFIG_GOOGLE_FIRMWARE)  += google/
 obj-$(CONFIG_EFI)  += efi/
 obj-$(CONFIG_UEFI_CPER)+= efi/
+obj-$(CONFIG_ROCKCHIP_SIP) += rockchip_sip.o
diff --git a/drivers/firmware/rockchip_sip.c b/drivers/firmware/rockchip_sip.c
new file mode 100644
index 000..7756af9
--- /dev/null
+++ b/drivers/firmware/rockchip_sip.c
@@ -0,0 +1,64 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ *
+ * Copyright (C) 2016 ARM Limited
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "rockchip_sip.h"
+
+typedef unsigned long (psci_fn)(unsigned long, unsigned long,
+   unsigned long, unsigned long);
+asmlinkage psci_fn __invoke_psci_fn_smc;
+
+#define CONFIG_DRAM_INIT   0x00
+#define CONFIG_DRAM_SET_RATE   0x01
+#define CONFIG_DRAM_ROUND_RATE 0x02
+#define CONFIG_DRAM_SET_AT_SR  0x03
+#define CONFIG_DRAM_GET_BW 0x04
+#define CONFIG_DRAM_GET_RATE   0x05
+#define CONFIG_DRAM_CLR_IRQ0x06
+#define CONFIG_DRAM_SET_PARAM   0x07
+
+uint64_t sip_smc_ddr_init(void)
+{
+   return __invoke_psci_fn_smc(SIP_DDR_FREQ, 0,
+   0, CONFIG_DRAM_INIT);
+}
+
+uint64_t sip_smc_set_ddr_param(uint64_t param)
+{
+   return __invoke_psci_fn_smc(SIP_DDR_FREQ, param,
+   0, CONFIG_DRAM_SET_PARAM);
+}
+
+uint64_t sip_smc_set_ddr_rate(uint64_t rate)
+{
+   return __invoke_psci_fn_smc(SIP_DDR_FREQ, rate, 0,
+   CONFIG_DRAM_SET_RATE);
+}
+
+uint64_t sip_smc_get_ddr_rate(void)
+{
+   return __invoke_psci_fn_smc(SIP_DDR_FREQ, 0, 0, CONFIG_DRAM_GET_RATE);
+}
+
+uint64_t sip_smc_clr_ddr_irq(void)
+{
+   return __invoke_psci_fn_smc(SIP_DDR_FREQ, 0, 0, CONFIG_DRAM_CLR_IRQ);
+}
+
+uint64_t sip_smc_get_call_count(void)
+{
+   return __invoke_psci_fn_smc(SIP_SVC_CALL_COUNT, 0, 0, 0);
+}
diff --git a/drivers/firmware/rockchip_sip.h b/drivers/firmware/rockchip_sip.h
new file mode 100644
index 000..6487734
--- /dev/null
+++ b/drivers/firmware/rockchip_sip.h
@@ -0,0 +1,59 @@
+/* Copyright (c) 2010-2015, The Linux Foundation. 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 version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+#ifndef __SIP_INT_H
+#define __SIP_INT_H
+
+/* SMC function IDs for SiP Service queries */
+#define SIP_SVC_CALL_COUNT 0x8200ff00
+#define SIP_SVC_UID0x8200ff01
+#define SIP_SVC_VERSION0x8200ff03
+#define SIP_DDR_FREQ   0xC208
+
+#if IS_ENABLED(CONFIG_ROCKCHIP_SIP)
+uint64_t sip_smc_set_ddr_rate(uint64_t rate);
+uint64_t sip_smc_get_ddr_rate(void);
+uint64_t sip_smc_clr_ddr_irq(void);

[PATCH v3 0/7] rk3399 support ddr frequency scaling

2016-07-22 Thread Lin Huang
rk3399 platform have dfi controller can monitor ddr load,
and dcf controller to handle ddr register so we can get the
right ddr frequency and make ddr controller happy work(which
will implement in bl31). So we do ddr frequency scaling with
following flow:

 kernelbl31

monitor ddr load
|
|
get_target_rate
|
|   pass rate to bl31
clk_set_rate(ddr) ->run dcf flow
|   |
|   |
wait dcf interrupt<---trigger dcf interrupt  
|
|
  return

Lin Huang (6):
  clk: rockchip: add new clock-type for the ddrclk
  clk: rockchip: rk3399: add SCLK_DDRCLK ID for ddrc
  clk: rockchip: rk3399: add ddrc clock support
  PM / devfreq: event: support rockchip dfi controller
  PM / devfreq: rockchip: add devfreq driver for rk3399 dmc
  drm/rockchip: Add dmc notifier in vop driver

Shengfei xu (1):
  firmware: rockchip: sip: Add rockchip SIP runtime service

 drivers/clk/rockchip/Makefile   |   1 +
 drivers/clk/rockchip/clk-ddr.c  | 139 
 drivers/clk/rockchip/clk-rk3399.c   |  19 ++
 drivers/clk/rockchip/clk.c  |   9 +
 drivers/clk/rockchip/clk.h  |  27 ++
 drivers/devfreq/Kconfig |   1 +
 drivers/devfreq/Makefile|   1 +
 drivers/devfreq/event/Kconfig   |   7 +
 drivers/devfreq/event/Makefile  |   1 +
 drivers/devfreq/event/rockchip-dfi.c| 253 +++
 drivers/devfreq/rockchip/Kconfig|  15 +
 drivers/devfreq/rockchip/Makefile   |   2 +
 drivers/devfreq/rockchip/rk3399_dmc.c   | 482 
 drivers/devfreq/rockchip/rockchip_dmc.c | 143 +
 drivers/firmware/Kconfig|   7 +
 drivers/firmware/Makefile   |   1 +
 drivers/firmware/rockchip_sip.c |  64 
 drivers/firmware/rockchip_sip.h |  59 
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c |  75 -
 include/dt-bindings/clock/rk3399-cru.h  |   1 +
 include/soc/rockchip/rockchip_dmc.h |  45 +++
 21 files changed, 1346 insertions(+), 6 deletions(-)
 create mode 100644 drivers/clk/rockchip/clk-ddr.c
 create mode 100644 drivers/devfreq/event/rockchip-dfi.c
 create mode 100644 drivers/devfreq/rockchip/Kconfig
 create mode 100644 drivers/devfreq/rockchip/Makefile
 create mode 100644 drivers/devfreq/rockchip/rk3399_dmc.c
 create mode 100644 drivers/devfreq/rockchip/rockchip_dmc.c
 create mode 100644 drivers/firmware/rockchip_sip.c
 create mode 100644 drivers/firmware/rockchip_sip.h
 create mode 100644 include/soc/rockchip/rockchip_dmc.h

-- 
2.6.6



[PATCH 15/15] drm/i915: Add horizontal mirroring support for CHV pipe B planes

2016-07-22 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

The primary and sprite planes on CHV pipe B support horizontal
mirroring. Expose it to the world.

Sadly the hardware ignores the mirror bit when the rotate bit is
set, so we'll have to reject the 180+X case.

Signed-off-by: Ville Syrjälä 
Reviewed-by: Joonas Lahtinen 
---
 drivers/gpu/drm/i915/intel_atomic_plane.c |  8 
 drivers/gpu/drm/i915/intel_display.c  | 10 ++
 drivers/gpu/drm/i915/intel_sprite.c   | 10 ++
 3 files changed, 28 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_atomic_plane.c 
b/drivers/gpu/drm/i915/intel_atomic_plane.c
index c19eb9a0cd4a..0a019eacfede 100644
--- a/drivers/gpu/drm/i915/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/intel_atomic_plane.c
@@ -180,6 +180,14 @@ static int intel_plane_atomic_check(struct drm_plane 
*plane,
}
}

+   /* CHV ignores the mirror bit when the rotate bit is set :( */
+   if (IS_CHERRYVIEW(plane->dev) &&
+   state->rotation & BIT(DRM_ROTATE_180) &&
+   state->rotation & BIT(DRM_REFLECT_X)) {
+   DRM_DEBUG_KMS("Cannot rotate and reflect at the same time\n");
+   return -EINVAL;
+   }
+
intel_state->visible = false;
ret = intel_plane->check_plane(plane, crtc_state, intel_state);
if (ret)
diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index 5c612a0dffb3..9d803982554b 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2677,6 +2677,9 @@ static void i9xx_update_primary_plane(struct drm_plane 
*primary,
if (rotation & BIT(DRM_ROTATE_180))
dspcntr |= DISPPLANE_ROTATE_180;

+   if (rotation & BIT(DRM_REFLECT_X))
+   dspcntr |= DISPPLANE_MIRROR;
+
if (IS_G4X(dev))
dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE;

@@ -2700,6 +2703,9 @@ static void i9xx_update_primary_plane(struct drm_plane 
*primary,
linear_offset +=
(crtc_state->pipe_src_h - 1) * fb->pitches[0] +
(crtc_state->pipe_src_w - 1) * cpp;
+   } else if (rotation & BIT(DRM_REFLECT_X)) {
+   x += (crtc_state->pipe_src_w - 1);
+   linear_offset += (crtc_state->pipe_src_w - 1) * cpp;
}

intel_crtc->adjusted_x = x;
@@ -14293,6 +14299,10 @@ static struct drm_plane 
*intel_primary_plane_create(struct drm_device *dev,
supported_rotations =
BIT(DRM_ROTATE_0) | BIT(DRM_ROTATE_90) |
BIT(DRM_ROTATE_180) | BIT(DRM_ROTATE_270);
+   } else if (IS_CHERRYVIEW(dev) && pipe == PIPE_B) {
+   supported_rotations =
+   BIT(DRM_ROTATE_0) | BIT(DRM_ROTATE_180) |
+   BIT(DRM_REFLECT_X);
} else if (INTEL_INFO(dev)->gen >= 4) {
supported_rotations =
BIT(DRM_ROTATE_0) | BIT(DRM_ROTATE_180);
diff --git a/drivers/gpu/drm/i915/intel_sprite.c 
b/drivers/gpu/drm/i915/intel_sprite.c
index f26594e2e851..2e2063633ca9 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -436,6 +436,9 @@ vlv_update_plane(struct drm_plane *dplane,
if (rotation & BIT(DRM_ROTATE_180))
sprctl |= SP_ROTATE_180;

+   if (rotation & BIT(DRM_REFLECT_X))
+   sprctl |= SP_MIRROR;
+
/* Sizes are 0 based */
src_w--;
src_h--;
@@ -451,6 +454,9 @@ vlv_update_plane(struct drm_plane *dplane,
x += src_w;
y += src_h;
linear_offset += src_h * fb->pitches[0] + src_w * cpp;
+   } else if (rotation & BIT(DRM_REFLECT_X)) {
+   x += src_w;
+   linear_offset += src_w * cpp;
}

if (key->flags) {
@@ -1128,6 +1134,10 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, 
int plane)
supported_rotations =
BIT(DRM_ROTATE_0) | BIT(DRM_ROTATE_90) |
BIT(DRM_ROTATE_180) | BIT(DRM_ROTATE_270);
+   } else if (IS_CHERRYVIEW(dev) && pipe == PIPE_B) {
+   supported_rotations =
+   BIT(DRM_ROTATE_0) | BIT(DRM_ROTATE_180) |
+   BIT(DRM_REFLECT_X);
} else {
supported_rotations =
BIT(DRM_ROTATE_0) | BIT(DRM_ROTATE_180);
-- 
2.7.4



[PATCH 14/15] drm/i915: Clean up rotation DSPCNTR/DVSCNTR/etc. setup

2016-07-22 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

Move the plane control register rotation setup away from the
coordinate munging code. This will result in neater looking
code once we add reflection support for CHV.

Signed-off-by: Ville Syrjälä 
Reviewed-by: Chris Wilson 
Reviewed-by: Joonas Lahtinen 
---
 drivers/gpu/drm/i915/intel_display.c | 28 ++--
 drivers/gpu/drm/i915/intel_sprite.c  | 28 +++-
 2 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index 5f36040eb96b..5c612a0dffb3 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2674,6 +2674,9 @@ static void i9xx_update_primary_plane(struct drm_plane 
*primary,
obj->tiling_mode != I915_TILING_NONE)
dspcntr |= DISPPLANE_TILED;

+   if (rotation & BIT(DRM_ROTATE_180))
+   dspcntr |= DISPPLANE_ROTATE_180;
+
if (IS_G4X(dev))
dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE;

@@ -2689,8 +2692,6 @@ static void i9xx_update_primary_plane(struct drm_plane 
*primary,
}

if (rotation & BIT(DRM_ROTATE_180)) {
-   dspcntr |= DISPPLANE_ROTATE_180;
-
x += (crtc_state->pipe_src_w - 1);
y += (crtc_state->pipe_src_h - 1);

@@ -2783,6 +2784,9 @@ static void ironlake_update_primary_plane(struct 
drm_plane *primary,
if (obj->tiling_mode != I915_TILING_NONE)
dspcntr |= DISPPLANE_TILED;

+   if (rotation & BIT(DRM_ROTATE_180))
+   dspcntr |= DISPPLANE_ROTATE_180;
+
if (!IS_HASWELL(dev) && !IS_BROADWELL(dev))
dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE;

@@ -2792,19 +2796,15 @@ static void ironlake_update_primary_plane(struct 
drm_plane *primary,
  fb->pitches[0], rotation);
linear_offset -= intel_crtc->dspaddr_offset;

-   if (rotation & BIT(DRM_ROTATE_180)) {
-   dspcntr |= DISPPLANE_ROTATE_180;
-
-   if (!IS_HASWELL(dev) && !IS_BROADWELL(dev)) {
-   x += (crtc_state->pipe_src_w - 1);
-   y += (crtc_state->pipe_src_h - 1);
+   /* HSW and BDW does this automagically in hardware */
+   if (!IS_HASWELL(dev) && !IS_BROADWELL(dev) &&
+   rotation & BIT(DRM_ROTATE_180)) {
+   x += (crtc_state->pipe_src_w - 1);
+   y += (crtc_state->pipe_src_h - 1);

-   /* Finding the last pixel of the last line of the 
display
-   data and adding to linear_offset*/
-   linear_offset +=
-   (crtc_state->pipe_src_h - 1) * fb->pitches[0] +
-   (crtc_state->pipe_src_w - 1) * cpp;
-   }
+   linear_offset +=
+   (crtc_state->pipe_src_h - 1) * fb->pitches[0] +
+   (crtc_state->pipe_src_w - 1) * cpp;
}

intel_crtc->adjusted_x = x;
diff --git a/drivers/gpu/drm/i915/intel_sprite.c 
b/drivers/gpu/drm/i915/intel_sprite.c
index ccb894f39425..f26594e2e851 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -433,6 +433,9 @@ vlv_update_plane(struct drm_plane *dplane,
if (obj->tiling_mode != I915_TILING_NONE)
sprctl |= SP_TILED;

+   if (rotation & BIT(DRM_ROTATE_180))
+   sprctl |= SP_ROTATE_180;
+
/* Sizes are 0 based */
src_w--;
src_h--;
@@ -445,8 +448,6 @@ vlv_update_plane(struct drm_plane *dplane,
linear_offset -= sprsurf_offset;

if (rotation & BIT(DRM_ROTATE_180)) {
-   sprctl |= SP_ROTATE_180;
-
x += src_w;
y += src_h;
linear_offset += src_h * fb->pitches[0] + src_w * cpp;
@@ -555,6 +556,9 @@ ivb_update_plane(struct drm_plane *plane,
if (obj->tiling_mode != I915_TILING_NONE)
sprctl |= SPRITE_TILED;

+   if (rotation & BIT(DRM_ROTATE_180))
+   sprctl |= SPRITE_ROTATE_180;
+
if (IS_HASWELL(dev) || IS_BROADWELL(dev))
sprctl &= ~SPRITE_TRICKLE_FEED_DISABLE;
else
@@ -577,15 +581,12 @@ ivb_update_plane(struct drm_plane *plane,
   fb->pitches[0], rotation);
linear_offset -= sprsurf_offset;

-   if (rotation & BIT(DRM_ROTATE_180)) {
-   sprctl |= SPRITE_ROTATE_180;
-
-   /* HSW and BDW does this automagically in hardware */
-   if (!IS_HASWELL(dev) && !IS_BROADWELL(dev)) {
-   x += src_w;
-   y += src_h;
-   linear_offset += src_h * fb->pitches[0] + src_w * cpp;
-   }
+   /* HSW and BDW does this automagically in hardware */
+   if (!IS_HASWELL(dev) && !IS_BROADWELL(dev) &&
+ 

[PATCH 13/15] drm/i915: Use & instead if == to check for rotations

2016-07-22 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

Using == to check for 180 degree rotation only works as long as the
reflection bits aren't set. That will change soon enough for CHV, so
let's stop doing things the wrong way.

Signed-off-by: Ville Syrjälä 
Reviewed-by: Chris Wilson 
Reviewed-by: Joonas Lahtinen 
---
 drivers/gpu/drm/i915/intel_display.c | 9 +
 drivers/gpu/drm/i915/intel_sprite.c  | 6 +++---
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index a6d5c4d434a4..5f36040eb96b 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2688,7 +2688,7 @@ static void i9xx_update_primary_plane(struct drm_plane 
*primary,
intel_crtc->dspaddr_offset = linear_offset;
}

-   if (rotation == BIT(DRM_ROTATE_180)) {
+   if (rotation & BIT(DRM_ROTATE_180)) {
dspcntr |= DISPPLANE_ROTATE_180;

x += (crtc_state->pipe_src_w - 1);
@@ -2791,7 +2791,8 @@ static void ironlake_update_primary_plane(struct 
drm_plane *primary,
intel_compute_tile_offset(, , fb, 0,
  fb->pitches[0], rotation);
linear_offset -= intel_crtc->dspaddr_offset;
-   if (rotation == BIT(DRM_ROTATE_180)) {
+
+   if (rotation & BIT(DRM_ROTATE_180)) {
dspcntr |= DISPPLANE_ROTATE_180;

if (!IS_HASWELL(dev) && !IS_BROADWELL(dev)) {
@@ -10263,7 +10264,7 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, 
u32 base,
if (HAS_DDI(dev))
cntl |= CURSOR_PIPE_CSC_ENABLE;

-   if (plane_state->base.rotation == BIT(DRM_ROTATE_180))
+   if (plane_state->base.rotation & BIT(DRM_ROTATE_180))
cntl |= CURSOR_ROTATE_180;
}

@@ -10309,7 +10310,7 @@ static void intel_crtc_update_cursor(struct drm_crtc 
*crtc,

/* ILK+ do this automagically */
if (HAS_GMCH_DISPLAY(dev) &&
-   plane_state->base.rotation == BIT(DRM_ROTATE_180)) {
+   plane_state->base.rotation & BIT(DRM_ROTATE_180)) {
base += (plane_state->base.crtc_h *
 plane_state->base.crtc_w - 1) * 4;
}
diff --git a/drivers/gpu/drm/i915/intel_sprite.c 
b/drivers/gpu/drm/i915/intel_sprite.c
index a0395f8f3723..ccb894f39425 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -444,7 +444,7 @@ vlv_update_plane(struct drm_plane *dplane,
   fb->pitches[0], rotation);
linear_offset -= sprsurf_offset;

-   if (rotation == BIT(DRM_ROTATE_180)) {
+   if (rotation & BIT(DRM_ROTATE_180)) {
sprctl |= SP_ROTATE_180;

x += src_w;
@@ -577,7 +577,7 @@ ivb_update_plane(struct drm_plane *plane,
   fb->pitches[0], rotation);
linear_offset -= sprsurf_offset;

-   if (rotation == BIT(DRM_ROTATE_180)) {
+   if (rotation & BIT(DRM_ROTATE_180)) {
sprctl |= SPRITE_ROTATE_180;

/* HSW and BDW does this automagically in hardware */
@@ -714,7 +714,7 @@ ilk_update_plane(struct drm_plane *plane,
   fb->pitches[0], rotation);
linear_offset -= dvssurf_offset;

-   if (rotation == BIT(DRM_ROTATE_180)) {
+   if (rotation & BIT(DRM_ROTATE_180)) {
dvscntr |= DVS_ROTATE_180;

x += src_w;
-- 
2.7.4



[PATCH 12/15] drm: RIP mode_config->rotation_property

2016-07-22 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

Now that all drivers have been converted over to the per-plane rotation
property, we can just nuke the global rotation property.

Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/drm_atomic.c|  6 ++
 drivers/gpu/drm/drm_crtc.c  | 18 --
 drivers/gpu/drm/drm_fb_helper.c |  7 +--
 include/drm/drm_crtc.h  |  7 ---
 4 files changed, 3 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 116f940a9267..81061fcdb984 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -709,8 +709,7 @@ int drm_atomic_plane_set_property(struct drm_plane *plane,
state->src_w = val;
} else if (property == config->prop_src_h) {
state->src_h = val;
-   } else if (property == config->rotation_property ||
-  property == plane->rotation_property) {
+   } else if (property == plane->rotation_property) {
if (!is_power_of_2(val & DRM_ROTATE_MASK))
return -EINVAL;
state->rotation = val;
@@ -768,8 +767,7 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
*val = state->src_w;
} else if (property == config->prop_src_h) {
*val = state->src_h;
-   } else if (property == config->rotation_property ||
-  property == plane->rotation_property) {
+   } else if (property == plane->rotation_property) {
*val = state->rotation;
} else if (plane->funcs->atomic_get_property) {
return plane->funcs->atomic_get_property(plane, state, 
property, val);
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 9e20a52ece7c..c1df75caf72f 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -5783,24 +5783,6 @@ void drm_mode_config_cleanup(struct drm_device *dev)
 }
 EXPORT_SYMBOL(drm_mode_config_cleanup);

-struct drm_property *drm_mode_create_rotation_property(struct drm_device *dev,
-  unsigned int 
supported_rotations)
-{
-   static const struct drm_prop_enum_list props[] = {
-   { DRM_ROTATE_0,   "rotate-0" },
-   { DRM_ROTATE_90,  "rotate-90" },
-   { DRM_ROTATE_180, "rotate-180" },
-   { DRM_ROTATE_270, "rotate-270" },
-   { DRM_REFLECT_X,  "reflect-x" },
-   { DRM_REFLECT_Y,  "reflect-y" },
-   };
-
-   return drm_property_create_bitmask(dev, 0, "rotation",
-  props, ARRAY_SIZE(props),
-  supported_rotations);
-}
-EXPORT_SYMBOL(drm_mode_create_rotation_property);
-
 int drm_plane_create_rotation_property(struct drm_plane *plane,
   unsigned int rotation,
   unsigned int supported_rotations)
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index ce536c0553e5..cf5f071ffae1 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -392,15 +392,10 @@ static int restore_fbdev_mode(struct drm_fb_helper 
*fb_helper)
if (plane->type != DRM_PLANE_TYPE_PRIMARY)
drm_plane_force_disable(plane);

-   if (plane->rotation_property) {
+   if (plane->rotation_property)
drm_mode_plane_set_obj_prop(plane,
plane->rotation_property,
BIT(DRM_ROTATE_0));
-   } else if (dev->mode_config.rotation_property) {
-   drm_mode_plane_set_obj_prop(plane,
-   
dev->mode_config.rotation_property,
-   BIT(DRM_ROTATE_0));
-   }
}

for (i = 0; i < fb_helper->crtc_count; i++) {
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 01cf0673f6c8..00a93e44f854 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -2480,11 +2480,6 @@ struct drm_mode_config {
 */
struct drm_property *plane_type_property;
/**
-* @rotation_property: Optional property for planes or CRTCs to specify
-* rotation.
-*/
-   struct drm_property *rotation_property;
-   /**
 * @prop_src_x: Default atomic plane property for the plane source
 * position in the connected _framebuffer.
 */
@@ -2960,8 +2955,6 @@ extern int drm_mode_plane_set_obj_prop(struct drm_plane 
*plane,
   struct drm_property *property,
   uint64_t value);

-extern struct drm_property *drm_mode_create_rotation_property(struct 
drm_device *dev,
- 

[PATCH v2 11/15] drm/i915: Use the per-plane rotation property

2016-07-22 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

On certain platforms not all planes support the same set of
rotations/reflections, so let's use the per-plane property
for this.

This is already a problem on SKL when we use the legay cursor plane
as it only supports 0|180 whereas the universal planes support
0|90|180|270, and it will be a problem on CHV soon.

v2: Use drm_plane_create_rotation_property() helper

Signed-off-by: Ville Syrjälä 
Reviewed-by: Chris Wilson  (v1)
---
 drivers/gpu/drm/i915/intel_display.c | 50 +++-
 drivers/gpu/drm/i915/intel_drv.h |  3 ---
 drivers/gpu/drm/i915/intel_sprite.c  | 14 +-
 3 files changed, 33 insertions(+), 34 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index 51357986cf4a..a6d5c4d434a4 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -14215,6 +14215,7 @@ static struct drm_plane 
*intel_primary_plane_create(struct drm_device *dev,
struct intel_plane *primary = NULL;
struct intel_plane_state *state = NULL;
const uint32_t *intel_primary_formats;
+   unsigned int supported_rotations;
unsigned int num_formats;
int ret;

@@ -14287,8 +14288,21 @@ static struct drm_plane 
*intel_primary_plane_create(struct drm_device *dev,
if (ret)
goto fail;

+   if (INTEL_INFO(dev)->gen >= 9) {
+   supported_rotations =
+   BIT(DRM_ROTATE_0) | BIT(DRM_ROTATE_90) |
+   BIT(DRM_ROTATE_180) | BIT(DRM_ROTATE_270);
+   } else if (INTEL_INFO(dev)->gen >= 4) {
+   supported_rotations =
+   BIT(DRM_ROTATE_0) | BIT(DRM_ROTATE_180);
+   } else {
+   supported_rotations = BIT(DRM_ROTATE_0);
+   }
+
if (INTEL_INFO(dev)->gen >= 4)
-   intel_create_rotation_property(dev, primary);
+   drm_plane_create_rotation_property(>base,
+  BIT(DRM_ROTATE_0),
+  supported_rotations);

drm_plane_helper_add(>base, _plane_helper_funcs);

@@ -14301,24 +14315,6 @@ fail:
return NULL;
 }

-void intel_create_rotation_property(struct drm_device *dev, struct intel_plane 
*plane)
-{
-   if (!dev->mode_config.rotation_property) {
-   unsigned long flags = BIT(DRM_ROTATE_0) |
-   BIT(DRM_ROTATE_180);
-
-   if (INTEL_INFO(dev)->gen >= 9)
-   flags |= BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_270);
-
-   dev->mode_config.rotation_property =
-   drm_mode_create_rotation_property(dev, flags);
-   }
-   if (dev->mode_config.rotation_property)
-   drm_object_attach_property(>base.base,
-   dev->mode_config.rotation_property,
-   plane->base.state->rotation);
-}
-
 static int
 intel_check_cursor_plane(struct drm_plane *plane,
 struct intel_crtc_state *crtc_state,
@@ -14447,17 +14443,11 @@ static struct drm_plane 
*intel_cursor_plane_create(struct drm_device *dev,
if (ret)
goto fail;

-   if (INTEL_INFO(dev)->gen >= 4) {
-   if (!dev->mode_config.rotation_property)
-   dev->mode_config.rotation_property =
-   drm_mode_create_rotation_property(dev,
-   BIT(DRM_ROTATE_0) |
-   BIT(DRM_ROTATE_180));
-   if (dev->mode_config.rotation_property)
-   drm_object_attach_property(>base.base,
-   dev->mode_config.rotation_property,
-   state->base.rotation);
-   }
+   if (INTEL_INFO(dev)->gen >= 4)
+   drm_plane_create_rotation_property(>base,
+  BIT(DRM_ROTATE_0),
+  BIT(DRM_ROTATE_0) |
+  BIT(DRM_ROTATE_180));

if (INTEL_INFO(dev)->gen >=9)
state->scaler_id = -1;
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 907a72cfdad3..9c085a3377a6 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1255,9 +1255,6 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state 
*crtc_state,
 unsigned int intel_tile_height(const struct drm_i915_private *dev_priv,
   uint64_t fb_modifier, unsigned int cpp);

-void intel_create_rotation_property(struct drm_device *dev,
-   struct intel_plane *plane);
-
 void assert_pch_transcoder_disabled(struct drm_i915_private *dev_priv,
 

[PATCH 10/15] drm/msm/mdp5: Advertize 180 degree rotation

2016-07-22 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

Since the hardware can apparently do both X and Y reflection, we
can advertize also 180 degree rotation as thats just X+Y reflection.

Cc: Rob Clark 
Cc: Jilai Wang 
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | 20 
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c 
b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
index 2aefb0db1874..586963016c89 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
@@ -78,6 +78,7 @@ static void mdp5_plane_install_rotation_property(struct 
drm_device *dev,
drm_plane_create_rotation_property(plane,
   BIT(DRM_ROTATE_0),
   BIT(DRM_ROTATE_0) |
+  BIT(DRM_ROTATE_180) |
   BIT(DRM_REFLECT_X) |
   BIT(DRM_REFLECT_Y));
 }
@@ -285,6 +286,8 @@ static int mdp5_plane_atomic_check(struct drm_plane *plane,
plane_enabled(old_state), plane_enabled(state));

if (plane_enabled(state)) {
+   unsigned int rotation;
+
format = to_mdp_format(msm_framebuffer_format(state->fb));
if (MDP_FORMAT_IS_YUV(format) &&
!pipe_supports_yuv(mdp5_plane->caps)) {
@@ -305,8 +308,12 @@ static int mdp5_plane_atomic_check(struct drm_plane *plane,
return -EINVAL;
}

-   hflip = !!(state->rotation & BIT(DRM_REFLECT_X));
-   vflip = !!(state->rotation & BIT(DRM_REFLECT_Y));
+   rotation = drm_rotation_simplify(state->rotation,
+BIT(DRM_ROTATE_0) |
+BIT(DRM_REFLECT_X) |
+BIT(DRM_REFLECT_Y));
+   hflip = !!(rotation & BIT(DRM_REFLECT_X));
+   vflip = !!(rotation & BIT(DRM_REFLECT_Y));
if ((vflip && !(mdp5_plane->caps & MDP_PIPE_CAP_VFLIP)) ||
(hflip && !(mdp5_plane->caps & MDP_PIPE_CAP_HFLIP))) {
dev_err(plane->dev->dev,
@@ -677,6 +684,7 @@ static int mdp5_plane_mode_set(struct drm_plane *plane,
int pe_top[COMP_MAX], pe_bottom[COMP_MAX];
uint32_t hdecm = 0, vdecm = 0;
uint32_t pix_format;
+   unsigned int rotation;
bool vflip, hflip;
unsigned long flags;
int ret;
@@ -739,8 +747,12 @@ static int mdp5_plane_mode_set(struct drm_plane *plane,
config |= get_scale_config(format, src_h, crtc_h, false);
DBG("scale config = %x", config);

-   hflip = !!(pstate->rotation & BIT(DRM_REFLECT_X));
-   vflip = !!(pstate->rotation & BIT(DRM_REFLECT_Y));
+   rotation = drm_rotation_simplify(pstate->rotation,
+BIT(DRM_ROTATE_0) |
+BIT(DRM_REFLECT_X) |
+BIT(DRM_REFLECT_Y));
+   hflip = !!(rotation & BIT(DRM_REFLECT_X));
+   vflip = !!(rotation & BIT(DRM_REFLECT_Y));

spin_lock_irqsave(_plane->pipe_lock, flags);

-- 
2.7.4



[PATCH 09/15] drm/msm/mdp5: Use per-plane rotation property

2016-07-22 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

The global mode_config.rotation_property is going away, switch over to
per-plane rotation_property.

Cc: Rob Clark 
Cc: Jilai Wang 
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | 15 +--
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c 
b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
index cf30911f3267..2aefb0db1874 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
@@ -75,16 +75,11 @@ static void mdp5_plane_install_rotation_property(struct 
drm_device *dev,
!(mdp5_plane->caps & MDP_PIPE_CAP_VFLIP))
return;

-   if (!dev->mode_config.rotation_property)
-   dev->mode_config.rotation_property =
-   drm_mode_create_rotation_property(dev,
-   BIT(DRM_ROTATE_0) |
-   BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y));
-
-   if (dev->mode_config.rotation_property)
-   drm_object_attach_property(>base,
-   dev->mode_config.rotation_property,
-   BIT(DRM_ROTATE_0));
+   drm_plane_create_rotation_property(plane,
+  BIT(DRM_ROTATE_0),
+  BIT(DRM_ROTATE_0) |
+  BIT(DRM_REFLECT_X) |
+  BIT(DRM_REFLECT_Y));
 }

 /* helper to install properties which are common to planes and crtcs */
-- 
2.7.4



[PATCH 08/15] drm/msm/mdp5: Set rotation property initial value to BIT(DRM_ROTATE_0) insted of 0

2016-07-22 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

0 isn't a valid rotation property value, so let's set the initial value
of the property to BIT(DRM_ROTATE_0) instead.

In the same vein, we must always have at leat one angle as part of
set of supported rotation bits, so let's include BIT(DRM_ROTATE_0)
in there.

Cc: Rob Clark 
Cc: Jilai Wang 
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c 
b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
index 432c09836b0e..cf30911f3267 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
@@ -78,12 +78,13 @@ static void mdp5_plane_install_rotation_property(struct 
drm_device *dev,
if (!dev->mode_config.rotation_property)
dev->mode_config.rotation_property =
drm_mode_create_rotation_property(dev,
+   BIT(DRM_ROTATE_0) |
BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y));

if (dev->mode_config.rotation_property)
drm_object_attach_property(>base,
dev->mode_config.rotation_property,
-   0);
+   BIT(DRM_ROTATE_0));
 }

 /* helper to install properties which are common to planes and crtcs */
-- 
2.7.4



[PATCH 07/15] drm/omap: Use per-plane rotation property

2016-07-22 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

The global mode_config.rotation_property is going away, switch over to
per-plane rotation_property.

Not sure I got the annoying crtc rotation_property handling right.
Might work, or migth not.

Cc: Tomi Valkeinen 
Cc: Rob Clark 
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/omapdrm/omap_crtc.c  | 13 -
 drivers/gpu/drm/omapdrm/omap_drv.c   | 52 +---
 drivers/gpu/drm/omapdrm/omap_plane.c | 12 ++---
 3 files changed, 39 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 180f644e861e..16c691dbc372 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -438,13 +438,14 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
}
 }

-static bool omap_crtc_is_plane_prop(struct drm_device *dev,
+static bool omap_crtc_is_plane_prop(struct drm_crtc *crtc,
struct drm_property *property)
 {
+   struct drm_device *dev = crtc->dev;
struct omap_drm_private *priv = dev->dev_private;

return property == priv->zorder_prop ||
-   property == dev->mode_config.rotation_property;
+   property == crtc->primary->rotation_property;
 }

 static int omap_crtc_atomic_set_property(struct drm_crtc *crtc,
@@ -452,9 +453,7 @@ static int omap_crtc_atomic_set_property(struct drm_crtc 
*crtc,
 struct drm_property *property,
 uint64_t val)
 {
-   struct drm_device *dev = crtc->dev;
-
-   if (omap_crtc_is_plane_prop(dev, property)) {
+   if (omap_crtc_is_plane_prop(crtc, property)) {
struct drm_plane_state *plane_state;
struct drm_plane *plane = crtc->primary;

@@ -479,9 +478,7 @@ static int omap_crtc_atomic_get_property(struct drm_crtc 
*crtc,
 struct drm_property *property,
 uint64_t *val)
 {
-   struct drm_device *dev = crtc->dev;
-
-   if (omap_crtc_is_plane_prop(dev, property)) {
+   if (omap_crtc_is_plane_prop(crtc, property)) {
/*
 * Delegate property get to the primary plane. The
 * drm_atomic_plane_get_property() function isn't exported, but
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index f57a6910ac01..98040ec836f1 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -292,16 +292,6 @@ static int omap_modeset_init_properties(struct drm_device 
*dev)
 {
struct omap_drm_private *priv = dev->dev_private;

-   if (priv->has_dmm) {
-   dev->mode_config.rotation_property =
-   drm_mode_create_rotation_property(dev,
-   BIT(DRM_ROTATE_0) | BIT(DRM_ROTATE_90) |
-   BIT(DRM_ROTATE_180) | BIT(DRM_ROTATE_270) |
-   BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y));
-   if (!dev->mode_config.rotation_property)
-   return -ENOMEM;
-   }
-
priv->zorder_prop = drm_property_create_range(dev, 0, "zorder", 0, 3);
if (!priv->zorder_prop)
return -ENOMEM;
@@ -752,24 +742,32 @@ static void dev_lastclose(struct drm_device *dev)

DBG("lastclose: dev=%p", dev);

-   if (dev->mode_config.rotation_property) {
-   /* need to restore default rotation state.. not sure
-* if there is a cleaner way to restore properties to
-* default state?  Maybe a flag that properties should
-* automatically be restored to default state on
-* lastclose?
-*/
-   for (i = 0; i < priv->num_crtcs; i++) {
-   drm_object_property_set_value(>crtcs[i]->base,
-   dev->mode_config.rotation_property,
-   BIT(DRM_ROTATE_0));
-   }
+   /* need to restore default rotation state.. not sure
+* if there is a cleaner way to restore properties to
+* default state?  Maybe a flag that properties should
+* automatically be restored to default state on
+* lastclose?
+*/
+   for (i = 0; i < priv->num_crtcs; i++) {
+   struct drm_crtc *crtc = priv->crtcs[i];

-   for (i = 0; i < priv->num_planes; i++) {
-   drm_object_property_set_value(>planes[i]->base,
-   dev->mode_config.rotation_property,
-   BIT(DRM_ROTATE_0));
-   }
+   if (!crtc->primary->rotation_property)
+   continue;
+
+   drm_object_property_set_value(>base,
+ 

[PATCH 06/15] drm/omap: Set rotation property initial value to BIT(DRM_ROTATE_0) insted of 0

2016-07-22 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

0 isn't a valid rotation property value, so let's set the initial value
of the property to BIT(DRM_ROTATE_0) instead.

Cc: Tomi Valkeinen 
Cc: Rob Clark 
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/omapdrm/omap_drv.c   | 6 --
 drivers/gpu/drm/omapdrm/omap_plane.c | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index 26c6134eb744..f57a6910ac01 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -761,12 +761,14 @@ static void dev_lastclose(struct drm_device *dev)
 */
for (i = 0; i < priv->num_crtcs; i++) {
drm_object_property_set_value(>crtcs[i]->base,
-   dev->mode_config.rotation_property, 0);
+   dev->mode_config.rotation_property,
+   BIT(DRM_ROTATE_0));
}

for (i = 0; i < priv->num_planes; i++) {
drm_object_property_set_value(>planes[i]->base,
-   dev->mode_config.rotation_property, 0);
+   dev->mode_config.rotation_property,
+   BIT(DRM_ROTATE_0));
}
}

diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c 
b/drivers/gpu/drm/omapdrm/omap_plane.c
index 7f0d567b8d67..08e911469a2f 100644
--- a/drivers/gpu/drm/omapdrm/omap_plane.c
+++ b/drivers/gpu/drm/omapdrm/omap_plane.c
@@ -213,7 +213,7 @@ void omap_plane_install_properties(struct drm_plane *plane,
if (priv->has_dmm) {
struct drm_property *prop = dev->mode_config.rotation_property;

-   drm_object_attach_property(obj, prop, 0);
+   drm_object_attach_property(obj, prop, BIT(DRM_ROTATE_0));
}

drm_object_attach_property(obj, priv->zorder_prop, 0);
-- 
2.7.4



[PATCH 05/15] drm/atmel-hlcdc: Use per-plane rotation property

2016-07-22 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

The global mode_config.rotation_property is going away, switch over to
per-plane rotation_property.

Cc: Boris Brezillon 
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 18 ++
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
index f3350c80704d..be3d4310ea97 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
@@ -903,9 +903,12 @@ static void atmel_hlcdc_plane_init_properties(struct 
atmel_hlcdc_plane *plane,
}

if (desc->layout.xstride && desc->layout.pstride)
-   drm_object_attach_property(>base.base,
-   plane->base.dev->mode_config.rotation_property,
-   BIT(DRM_ROTATE_0));
+   drm_plane_create_rotation_property(>base,
+  BIT(DRM_ROTATE_0),
+  BIT(DRM_ROTATE_0) |
+  BIT(DRM_ROTATE_90) |
+  BIT(DRM_ROTATE_180) |
+  BIT(DRM_ROTATE_270));

if (desc->layout.csc) {
/*
@@ -1054,15 +1057,6 @@ atmel_hlcdc_plane_create_properties(struct drm_device 
*dev)
if (!props->alpha)
return ERR_PTR(-ENOMEM);

-   dev->mode_config.rotation_property =
-   drm_mode_create_rotation_property(dev,
- BIT(DRM_ROTATE_0) |
- BIT(DRM_ROTATE_90) |
- BIT(DRM_ROTATE_180) |
- BIT(DRM_ROTATE_270));
-   if (!dev->mode_config.rotation_property)
-   return ERR_PTR(-ENOMEM);
-
return props;
 }

-- 
2.7.4



[PATCH 04/15] drm/arm: Use per-plane rotation property

2016-07-22 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

The global mode_config.rotation_property is going away, switch over to
per-plane rotation_property.

Cc: Liviu Dudau 
Cc: Brian Starkey 
Cc: Mali DP Maintainers 
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/arm/malidp_planes.c | 13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/arm/malidp_planes.c 
b/drivers/gpu/drm/arm/malidp_planes.c
index 725098d6179a..7fbe1feec861 100644
--- a/drivers/gpu/drm/arm/malidp_planes.c
+++ b/drivers/gpu/drm/arm/malidp_planes.c
@@ -254,21 +254,18 @@ int malidp_de_planes_init(struct drm_device *drm)
if (ret < 0)
goto cleanup;

-   if (!drm->mode_config.rotation_property) {
+   /* SMART layer can't be rotated */
+   if (id != DE_SMART) {
unsigned long flags = BIT(DRM_ROTATE_0) |
  BIT(DRM_ROTATE_90) |
  BIT(DRM_ROTATE_180) |
  BIT(DRM_ROTATE_270) |
  BIT(DRM_REFLECT_X) |
  BIT(DRM_REFLECT_Y);
-   drm->mode_config.rotation_property =
-   drm_mode_create_rotation_property(drm, flags);
+   drm_plane_create_rotation_property(>base,
+  BIT(DRM_ROTATE_0),
+  flags);
}
-   /* SMART layer can't be rotated */
-   if (drm->mode_config.rotation_property && (id != DE_SMART))
-   drm_object_attach_property(>base.base,
-  
drm->mode_config.rotation_property,
-  BIT(DRM_ROTATE_0));

drm_plane_helper_add(>base,
 _de_plane_helper_funcs);
-- 
2.7.4



[PATCH v2 03/15] drm: Add support for optional per-plane rotation property

2016-07-22 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

Not all planes on the ssytem may support the same rotations/reflections,
so make it possible to create a separate property for each plane.
This way userspace gets told exactly which rotations/reflections are
possible for each plane.

v2: Add drm_plane_create_rotation_property() helper

Signed-off-by: Ville Syrjälä 
Reviewed-by: Chris Wilson  (v1)
---
 drivers/gpu/drm/drm_atomic.c|  6 --
 drivers/gpu/drm/drm_crtc.c  | 33 +
 drivers/gpu/drm/drm_fb_helper.c |  6 +-
 include/drm/drm_crtc.h  | 10 +-
 4 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index c425bd39a210..116f940a9267 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -709,7 +709,8 @@ int drm_atomic_plane_set_property(struct drm_plane *plane,
state->src_w = val;
} else if (property == config->prop_src_h) {
state->src_h = val;
-   } else if (property == config->rotation_property) {
+   } else if (property == config->rotation_property ||
+  property == plane->rotation_property) {
if (!is_power_of_2(val & DRM_ROTATE_MASK))
return -EINVAL;
state->rotation = val;
@@ -767,7 +768,8 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
*val = state->src_w;
} else if (property == config->prop_src_h) {
*val = state->src_h;
-   } else if (property == config->rotation_property) {
+   } else if (property == config->rotation_property ||
+  property == plane->rotation_property) {
*val = state->rotation;
} else if (plane->funcs->atomic_get_property) {
return plane->funcs->atomic_get_property(plane, state, 
property, val);
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 986de180e6c2..9e20a52ece7c 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -5801,6 +5801,39 @@ struct drm_property 
*drm_mode_create_rotation_property(struct drm_device *dev,
 }
 EXPORT_SYMBOL(drm_mode_create_rotation_property);

+int drm_plane_create_rotation_property(struct drm_plane *plane,
+  unsigned int rotation,
+  unsigned int supported_rotations)
+{
+   static const struct drm_prop_enum_list props[] = {
+   { DRM_ROTATE_0,   "rotate-0" },
+   { DRM_ROTATE_90,  "rotate-90" },
+   { DRM_ROTATE_180, "rotate-180" },
+   { DRM_ROTATE_270, "rotate-270" },
+   { DRM_REFLECT_X,  "reflect-x" },
+   { DRM_REFLECT_Y,  "reflect-y" },
+   };
+   struct drm_property *prop;
+
+   WARN_ON((supported_rotations & rotation) == 0);
+
+   prop = drm_property_create_bitmask(plane->dev, 0, "rotation",
+  props, ARRAY_SIZE(props),
+  supported_rotations);
+   if (!prop)
+   return -ENOMEM;
+
+   drm_object_attach_property(>base, prop, rotation);
+
+   if (plane->state)
+   plane->state->rotation = rotation;
+
+   plane->rotation_property = prop;
+
+   return 0;
+}
+EXPORT_SYMBOL(drm_plane_create_rotation_property);
+
 /**
  * DOC: Tile group
  *
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index ce54e985d91b..ce536c0553e5 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -392,7 +392,11 @@ static int restore_fbdev_mode(struct drm_fb_helper 
*fb_helper)
if (plane->type != DRM_PLANE_TYPE_PRIMARY)
drm_plane_force_disable(plane);

-   if (dev->mode_config.rotation_property) {
+   if (plane->rotation_property) {
+   drm_mode_plane_set_obj_prop(plane,
+   plane->rotation_property,
+   BIT(DRM_ROTATE_0));
+   } else if (dev->mode_config.rotation_property) {
drm_mode_plane_set_obj_prop(plane,

dev->mode_config.rotation_property,
BIT(DRM_ROTATE_0));
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index b7ac7dcf52db..01cf0673f6c8 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -1737,6 +1737,11 @@ struct drm_plane {
const struct drm_plane_helper_funcs *helper_private;

struct drm_plane_state *state;
+
+   /**
+* @rotation_property: Optional property for planes to specify rotation.
+*/
+   struct drm_property *rotation_property;
 };

 /**
@@ -2475,7 +2480,7 @@ struct drm_mode_config {
   

[PATCH 02/15] drm/atomic: Reject attempts to use multiple rotation angles at once

2016-07-22 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

The rotation property should only accept exactly one rotation angle
at once. Let's reject attempts to set none or multiple angles.

Testcase: igt/kms_rotation_crc/bad-rotation
Signed-off-by: Ville Syrjälä 
Reviewed-by: Joonas Lahtinen 
Reviewed-by: Chris Wilson 
---
 drivers/gpu/drm/drm_atomic.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 8d2f111fa113..c425bd39a210 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -710,6 +710,8 @@ int drm_atomic_plane_set_property(struct drm_plane *plane,
} else if (property == config->prop_src_h) {
state->src_h = val;
} else if (property == config->rotation_property) {
+   if (!is_power_of_2(val & DRM_ROTATE_MASK))
+   return -EINVAL;
state->rotation = val;
} else if (plane->funcs->atomic_set_property) {
return plane->funcs->atomic_set_property(plane, state,
-- 
2.7.4



[PATCH 01/15] drm: Add drm_rotation_90_or_270()

2016-07-22 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

We have intel_rotation_90_or_270() in i915 to check if the rotation is
90 or 270 degrees. Similar checks are elsewhere in drm, so let's move
the helper into a central place and use it everwhere.

Signed-off-by: Ville Syrjälä 
Reviewed-by: Joonas Lahtinen 
Reviewed-by: Chris Wilson 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c |  4 ++--
 drivers/gpu/drm/drm_atomic_helper.c |  2 +-
 drivers/gpu/drm/drm_crtc.c  |  3 +--
 drivers/gpu/drm/i915/intel_atomic_plane.c   |  2 +-
 drivers/gpu/drm/i915/intel_display.c| 10 +-
 drivers/gpu/drm/i915/intel_drv.h|  6 --
 drivers/gpu/drm/i915/intel_fbc.c|  2 +-
 drivers/gpu/drm/i915/intel_pm.c | 12 ++--
 drivers/gpu/drm/i915/intel_sprite.c |  2 +-
 drivers/gpu/drm/omapdrm/omap_plane.c|  8 ++--
 include/drm/drm_crtc.h  |  5 +
 11 files changed, 25 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
index 016c191221f3..f3350c80704d 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
@@ -393,7 +393,7 @@ static void atmel_hlcdc_plane_update_format(struct 
atmel_hlcdc_plane *plane,

if ((state->base.fb->pixel_format == DRM_FORMAT_YUV422 ||
 state->base.fb->pixel_format == DRM_FORMAT_NV61) &&
-   (state->base.rotation & (BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_270
+   drm_rotation_90_or_270(state->base.rotation))
cfg |= ATMEL_HLCDC_YUV422ROT;

atmel_hlcdc_layer_update_cfg(>layer,
@@ -628,7 +628,7 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane 
*p,
/*
 * Swap width and size in case of 90 or 270 degrees rotation
 */
-   if (state->base.rotation & (BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_270))) {
+   if (drm_rotation_90_or_270(state->base.rotation)) {
tmp = state->crtc_w;
state->crtc_w = state->crtc_h;
state->crtc_h = tmp;
diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index de7fddce3cef..3e12e6e646ad 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -2348,7 +2348,7 @@ int __drm_atomic_helper_set_config(struct drm_mode_set 
*set,
primary_state->crtc_h = vdisplay;
primary_state->src_x = set->x << 16;
primary_state->src_y = set->y << 16;
-   if (primary_state->rotation & (BIT(DRM_ROTATE_90) | 
BIT(DRM_ROTATE_270))) {
+   if (drm_rotation_90_or_270(primary_state->rotation)) {
primary_state->src_w = vdisplay << 16;
primary_state->src_h = hdisplay << 16;
} else {
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index f1d9f0569d7f..986de180e6c2 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -2804,8 +2804,7 @@ int drm_crtc_check_viewport(const struct drm_crtc *crtc,
drm_crtc_get_hv_timing(mode, , );

if (crtc->state &&
-   crtc->primary->state->rotation & (BIT(DRM_ROTATE_90) |
- BIT(DRM_ROTATE_270)))
+   drm_rotation_90_or_270(crtc->primary->state->rotation))
swap(hdisplay, vdisplay);

return check_src_coords(x << 16, y << 16,
diff --git a/drivers/gpu/drm/i915/intel_atomic_plane.c 
b/drivers/gpu/drm/i915/intel_atomic_plane.c
index 7de7721f65bc..c19eb9a0cd4a 100644
--- a/drivers/gpu/drm/i915/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/intel_atomic_plane.c
@@ -156,7 +156,7 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
intel_state->clip.y2 =
crtc_state->base.enable ? crtc_state->pipe_src_h : 0;

-   if (state->fb && intel_rotation_90_or_270(state->rotation)) {
+   if (state->fb && drm_rotation_90_or_270(state->rotation)) {
if (!(state->fb->modifier[0] == I915_FORMAT_MOD_Y_TILED ||
state->fb->modifier[0] == I915_FORMAT_MOD_Yf_TILED)) {
DRM_DEBUG_KMS("Y/Yf tiling required for 90/270!\n");
diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index 78beb7e9d384..51357986cf4a 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2138,7 +2138,7 @@ intel_fill_fb_ggtt_view(struct i915_ggtt_view *view,
const struct drm_framebuffer *fb,
unsigned int rotation)
 {
-   if (intel_rotation_90_or_270(rotation)) {
+   if (drm_rotation_90_or_270(rotation)) {
*view = i915_ggtt_view_rotated;
view->params.rotated = to_intel_framebuffer(fb)->rot_info;
} else {
@@ -2352,7 +2352,7 @@ u32 

[PATCH 00/15] drm: Per-plane rotation etc.

2016-07-22 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

Here's an expaned version of my earlier series [1]. This time I went as
far as nuking the mode_config.rotation_property in favor of the per-plane
property. Also tried to fix a few buglets in omap/msm rotation property
setup.

Entire series is available here:
git://github.com/vsyrjala/linux.git chv_mirror_2

[1] https://lists.freedesktop.org/archives/dri-devel/2016-July/113636.html

Ville Syrjälä (15):
  drm: Add drm_rotation_90_or_270()
  drm/atomic: Reject attempts to use multiple rotation angles at once
  drm: Add support for optional per-plane rotation property
  drm/arm: Use per-plane rotation property
  drm/atmel-hlcdc: Use per-plane rotation property
  drm/omap: Set rotation property initial value to BIT(DRM_ROTATE_0)
insted of 0
  drm/omap: Use per-plane rotation property
  drm/msm/mdp5: Set rotation property initial value to BIT(DRM_ROTATE_0)
insted of 0
  drm/msm/mdp5: Use per-plane rotation property
  drm/msm/mdp5: Advertize 180 degree rotation
  drm/i915: Use the per-plane rotation property
  drm: RIP mode_config->rotation_property
  drm/i915: Use & instead if == to check for rotations
  drm/i915: Clean up rotation DSPCNTR/DVSCNTR/etc. setup
  drm/i915: Add horizontal mirroring support for CHV pipe B planes

 drivers/gpu/drm/arm/malidp_planes.c |  13 ++-
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c |  22 ++---
 drivers/gpu/drm/drm_atomic.c|   6 +-
 drivers/gpu/drm/drm_atomic_helper.c |   2 +-
 drivers/gpu/drm/drm_crtc.c  |  26 --
 drivers/gpu/drm/drm_fb_helper.c |   5 +-
 drivers/gpu/drm/i915/intel_atomic_plane.c   |  10 ++-
 drivers/gpu/drm/i915/intel_display.c| 103 
 drivers/gpu/drm/i915/intel_drv.h|   9 ---
 drivers/gpu/drm/i915/intel_fbc.c|   2 +-
 drivers/gpu/drm/i915/intel_pm.c |  12 +--
 drivers/gpu/drm/i915/intel_sprite.c |  58 +
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c   |  34 +---
 drivers/gpu/drm/omapdrm/omap_crtc.c |  13 ++-
 drivers/gpu/drm/omapdrm/omap_drv.c  |  50 ++--
 drivers/gpu/drm/omapdrm/omap_plane.c|  20 ++---
 include/drm/drm_crtc.h  |  20 +++--
 17 files changed, 224 insertions(+), 181 deletions(-)

-- 
2.7.4



[PATCH v4 6/7] drm/nouveau/fifo/gk104: make use of new strcpytoupper() function

2016-07-22 Thread Markus Mayer
Call strcpytoupper() rather than copying the string explicitly and then
walking it to convert it to uppercase.

Signed-off-by: Markus Mayer 
---
 drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c 
b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
index 743f3a1..8d01032 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
@@ -332,10 +332,7 @@ gk104_fifo_intr_fault(struct gk104_fifo *fifo, int unit)
enum nvkm_devidx engidx = nvkm_top_fault(device->top, unit);
if (engidx < NVKM_SUBDEV_NR) {
const char *src = nvkm_subdev_name[engidx];
-   char *dst = en;
-   do {
-   *dst++ = toupper(*src++);
-   } while(*src);
+   strcpytoupper(en, src);
engine = nvkm_device_engine(device, engidx);
}
} else {
-- 
2.7.4



[PATCH v4 2/7] drm/nouveau/core: make use of new strlcpytolower() function

2016-07-22 Thread Markus Mayer
Call strlcpytolower() rather than copying the string explicitly and
then walking it to convert it to lowercase.

Signed-off-by: Markus Mayer 
---

The semantics of the new function has changed, so this patch has been
updated since v2 to match the new strlcpy() semantics (no explicit NULL
terminating is required).

See https://patchwork.kernel.org/patch/9215207/ for the previous version.

 drivers/gpu/drm/nouveau/nvkm/core/firmware.c | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/core/firmware.c 
b/drivers/gpu/drm/nouveau/nvkm/core/firmware.c
index 34ecd4a..982601e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/firmware.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/firmware.c
@@ -36,16 +36,9 @@ nvkm_firmware_get(struct nvkm_device *device, const char 
*fwname,
 {
char f[64];
char cname[16];
-   int i;

/* Convert device name to lowercase */
-   strncpy(cname, device->chip->name, sizeof(cname));
-   cname[sizeof(cname) - 1] = '\0';
-   i = strlen(cname);
-   while (i) {
-   --i;
-   cname[i] = tolower(cname[i]);
-   }
+   strlcpytolower(cname, device->chip->name, sizeof(cname));

snprintf(f, sizeof(f), "nvidia/%s/%s.bin", cname, fwname);
return request_firmware(fw, f, device->dev);
-- 
2.7.4



[PATCH v4 1/7] lib: string: add functions to case-convert strings

2016-07-22 Thread Markus Mayer
Add a collection of generic functions to convert strings to lowercase
or uppercase.

Changing the case of a string (with or without copying it first) seems
to be a recurring requirement in the kernel that is currently being
solved by several duplicated implementations doing the same thing. This
change aims at reducing this code duplication.

The new functions are
int strlcpytoupper(char *dst, const char *src, size_t len);
int strlcpytolower(char *dst, const char *src, size_t len);
void strcpytoupper(char *dst, const char *src);
void strcpytolower(char *dst, const char *src);
void strtoupper(char *s);
void strtolower(char *s);

The "str[l]cpyto*" versions of the function take a destination string
and a source string as arguments. The "strlcpyto*" versions additionally
take a length argument like strlcpy() itself. Lastly, the strto*
functions take a single string argument and modify the passed-in string.

strlcpytoupper() and strlcpytolower() return the number of characters
copied or -E2BIG if the destination string was truncated.

Like strlcpy(), and unlike strncpy(), the functions guarantee NULL
termination of the destination string.

Signed-off-by: Markus Mayer 
---
 include/linux/string.h | 40 
 lib/string.c   | 46 ++
 2 files changed, 86 insertions(+)

diff --git a/include/linux/string.h b/include/linux/string.h
index 26b6f6a..257d797 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -116,6 +116,8 @@ extern void * memchr(const void *,int,__kernel_size_t);
 #endif
 void *memchr_inv(const void *s, int c, size_t n);
 char *strreplace(char *s, char old, char new);
+extern int strlcpytoupper(char *dst, const char *src, size_t len);
+extern int strlcpytolower(char *dst, const char *src, size_t len);

 extern void kfree_const(const void *x);

@@ -169,4 +171,42 @@ static inline const char *kbasename(const char *path)
return tail ? tail + 1 : path;
 }

+/**
+ * strcpytoupper - Copy string and convert to uppercase.
+ * @dst: The buffer to store the result.
+ * @src: The string to convert to uppercase.
+ */
+static inline void strcpytoupper(char *dst, const char *src)
+{
+   strlcpytoupper(dst, src, ~(size_t)0);
+}
+
+/**
+ * strcpytolower - Copy string and convert to lowercase.
+ * @dst: The buffer to store the result.
+ * @src: The string to convert to lowercase.
+ */
+static inline void strcpytolower(char *dst, const char *src)
+{
+   strlcpytolower(dst, src, ~(size_t)0);
+}
+
+/**
+ * strtoupper - Convert string to uppercase.
+ * @s: The string to operate on.
+ */
+static inline void strtoupper(char *s)
+{
+   strlcpytoupper(s, s, ~(size_t)0);
+}
+
+/**
+ * strtolower - Convert string to lowercase.
+ * @s: The string to operate on.
+ */
+static inline void strtolower(char *s)
+{
+   strlcpytolower(s, s, ~(size_t)0);
+}
+
 #endif /* _LINUX_STRING_H_ */
diff --git a/lib/string.c b/lib/string.c
index ed83562..d36d5fb2 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -952,3 +952,49 @@ char *strreplace(char *s, char old, char new)
return s;
 }
 EXPORT_SYMBOL(strreplace);
+
+/**
+ * strlcpytoupper - Copy a length-limited string and convert to uppercase.
+ * @dst: The buffer to store the result.
+ * @src: The string to convert to uppercase.
+ * @len: Maximum string length. May be SIZE_MAX to set no limit.
+ *
+ * Returns the number of characters copied or -E2BIG if @dst wasn't big enough.
+ */
+int strlcpytoupper(char *dst, const char *src, size_t len)
+{
+   size_t i;
+
+   if (!len)
+   return -E2BIG;
+
+   for (i = 0; i < len && src[i]; ++i)
+   dst[i] = toupper(src[i]);
+   dst[i < len ? i : i - 1] = '\0';
+
+   return (i < len) ? i : -E2BIG;
+}
+EXPORT_SYMBOL(strlcpytoupper);
+
+/**
+ * strlcpytolower - Copy a length-limited string and convert to lowercase.
+ * @dst: The buffer to store the result.
+ * @src: The string to convert to lowercase.
+ * @len: Maximum string length. May be SIZE_MAX to set no limit.
+ *
+ * Returns the number of characters copied or -E2BIG if @dst wasn't big enough.
+ */
+int strlcpytolower(char *dst, const char *src, size_t len)
+{
+   size_t i;
+
+   if (!len)
+   return -E2BIG;
+
+   for (i = 0; i < len && src[i]; ++i)
+   dst[i] = tolower(src[i]);
+   dst[i < len ? i : i - 1] = '\0';
+
+   return (i < len) ? i : -E2BIG;
+}
+EXPORT_SYMBOL(strlcpytolower);
-- 
2.7.4



[PATCH v4 0/7] lib: string: add functions to case-convert strings

2016-07-22 Thread Markus Mayer
This series introduces a family of generic string case conversion
functions. This kind of functionality is needed in several places in
the kernel. Right now, everybody seems to be implementing their own
copy of this functionality.

Based on the discussion of the previous version of this series[1] and
the use cases found in the kernel, it does look like having several
flavours of case conversion functions is beneficial. The use cases fall
into three categories:
- copying a string and converting the case while specifying a
  maximum length to mimic strlcpy()
- copying a string and converting the case without specifying a
  length to mimic strcpy()
- converting the case of a string in-place (i.e. modifying the
  string that was passed in)

Consequently, I am proposing these new functions:
int strlcpytoupper(char *dst, const char *src, size_t len);
int strlcpytolower(char *dst, const char *src, size_t len);
void strcpytoupper(char *dst, const char *src);
void strcpytolower(char *dst, const char *src);
void strtoupper(char *s);
void strtolower(char *s);

Several drivers are being modified to make use of the functions above.
Another driver that also makes use of this functionality will be
submitted upstream shortly, which prompted this whole exercise.

The changes made here have been compile-tested, but not tried out, due
to lack of required hardware.

Changes since v3:
  - strlcpytoupper() and strlcpytolower() return length of destination
or -E2BIG (see [2])
  - we use ~(size_t)0 instead of -1 to copy strings of arbitrary length
in strcpyto*() and strto*()
  - A few ACKs added

Changes since v2:
  - use strlcpy() semantics not strncpy() semantics, i.e. guarantee
NULL termination
  - as a result strncpyto are now called
strlcpyto
  - make functions void
  - use len == -1 (SIZE_MAX) as no-limit indicator rather then len == 0
  - change PATCH 2/7 to match strlcpy() semantics
  - change PATCH 4/7 to match strlcpy() semantics

Changes since v1:
  - expanded strtolower() into a family of functions that cover use
cases when a length argument is or isn't required and that support
copying the string into a new buffer or changing it in-place 
  - changed the function semantics to return a pointer to the
terminating '\0' character of the modified string
  - added strtoupper() functionality mirroring the above
  - dropped the ACPICA patch, since that code is OS independent and
can't rely on a Linux library function (see [3])
  - Added two new patches replacing strtoupper() implementations

[1] https://lkml.org/lkml/2016/6/30/727
[2] https://lkml.org/lkml/2016/7/10/4
[3] https://lkml.org/lkml/2016/7/1/9

Markus Mayer (7):
  lib: string: add functions to case-convert strings
  drm/nouveau/core: make use of new strlcpytolower() function
  ACPI / device_sysfs: make use of new strtolower() function
  staging: speakup: replace spk_strlwr() with strlcpytolower()
  iscsi-target: replace iscsi_initiatorname_tolower() with strtolower()
  drm/nouveau/fifo/gk104: make use of new strcpytoupper() function
  power_supply: make use of new strcpytoupper() function

 drivers/acpi/device_sysfs.c  |  4 +--
 drivers/gpu/drm/nouveau/nvkm/core/firmware.c |  9 +
 drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c |  5 +--
 drivers/power/power_supply_sysfs.c   | 13 +++
 drivers/staging/speakup/kobjects.c   |  3 +-
 drivers/staging/speakup/main.c   |  3 +-
 drivers/staging/speakup/speakup.h|  1 -
 drivers/staging/speakup/varhandlers.c| 12 ---
 drivers/target/iscsi/iscsi_target_nego.c | 17 +
 include/linux/string.h   | 40 +
 lib/string.c | 46 
 11 files changed, 98 insertions(+), 55 deletions(-)

-- 
2.7.4



Why drm-mipi-dsi is built-in only?

2016-07-22 Thread Takashi Iwai
Hi,

is there any reason drm-mipi-dsi can't be a module?  It's fixed as a
built-in since its Kconfig is bool.


thanks,

Takashi


[PATCH v3 5/7] PM / devfreq: event: support rockchip dfi controller

2016-07-22 Thread Paul Gortmaker
On Fri, Jul 22, 2016 at 5:07 AM, Lin Huang  wrote:
> on rk3399 platform, there is dfi conroller can monitor
> ddr load, base on this result, we can do ddr freqency
> scaling.
>
> Signed-off-by: Lin Huang 
> Acked-by: Chanwoo Choi 
> ---
> Changes in v3:
> - None
>
> Changes in v2:
> - use clk_disable_unprepare and clk_enable_prepare
> - remove clk_enable_prepare in probe
> - remove rockchip_dfi_remove function
>
> Changes in v1:
> - None
>
>  drivers/devfreq/event/Kconfig|   7 +
>  drivers/devfreq/event/Makefile   |   1 +
>  drivers/devfreq/event/rockchip-dfi.c | 253 
> +++
>  3 files changed, 261 insertions(+)
>  create mode 100644 drivers/devfreq/event/rockchip-dfi.c
>
> diff --git a/drivers/devfreq/event/Kconfig b/drivers/devfreq/event/Kconfig
> index eb6f74a..0d32d68 100644
> --- a/drivers/devfreq/event/Kconfig
> +++ b/drivers/devfreq/event/Kconfig
> @@ -30,4 +30,11 @@ config DEVFREQ_EVENT_EXYNOS_PPMU
>   (Platform Performance Monitoring Unit) counters to estimate the
>   utilization of each module.
>
> +config DEVFREQ_EVENT_ROCKCHIP_DFI
> +   bool "ROCKCHIP DFI DEVFREQ event Driver"
> +   depends on ARCH_ROCKCHIP
> +   help
> + This add the devfreq-event driver for Rockchip SoC. It provides DFI
> + (DDR Monitor Module) driver to count ddr load.
> +
>  endif # PM_DEVFREQ_EVENT
> diff --git a/drivers/devfreq/event/Makefile b/drivers/devfreq/event/Makefile
> index 3d6afd3..dda7090 100644
> --- a/drivers/devfreq/event/Makefile
> +++ b/drivers/devfreq/event/Makefile
> @@ -2,3 +2,4 @@
>
>  obj-$(CONFIG_DEVFREQ_EVENT_EXYNOS_NOCP) += exynos-nocp.o
>  obj-$(CONFIG_DEVFREQ_EVENT_EXYNOS_PPMU) += exynos-ppmu.o
> +obj-$(CONFIG_DEVFREQ_EVENT_ROCKCHIP_DFI) += rockchip-dfi.o
> diff --git a/drivers/devfreq/event/rockchip-dfi.c 
> b/drivers/devfreq/event/rockchip-dfi.c
> new file mode 100644
> index 000..96a0307
> --- /dev/null
> +++ b/drivers/devfreq/event/rockchip-dfi.c
> @@ -0,0 +1,253 @@
> +/*
> + * Copyright (c) 2016, Fuzhou Rockchip Electronics Co., Ltd
> + * Author: Lin Huang 
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope 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 

Same comment applies here.   Also might want to check any instances
of "IS_ENABLED" being used on bool items, as that is overkill too.

Thanks,
Paul.


[PATCH v3 6/7] PM / devfreq: rockchip: add devfreq driver for rk3399 dmc

2016-07-22 Thread Paul Gortmaker
On Fri, Jul 22, 2016 at 5:07 AM, Lin Huang  wrote:
> base on dfi result, we do ddr frequency scaling, register
> dmc driver to devfreq framework, and use simple-ondemand
> policy.
>
> Signed-off-by: Lin Huang 
> ---
> Changes in v3:
> - operate dram setting through sip call
> - imporve set rate flow
>
> Changes in v2:
> - None
>
> Changes in v1:
> - move dfi controller to event
> - fix set voltage sequence when set rate fail
> - change Kconfig type from tristate to bool
> - move unuse EXPORT_SYMBOL_GPL()
>
>  drivers/devfreq/Kconfig |   1 +
>  drivers/devfreq/Makefile|   1 +
>  drivers/devfreq/rockchip/Kconfig|  15 +
>  drivers/devfreq/rockchip/Makefile   |   2 +
>  drivers/devfreq/rockchip/rk3399_dmc.c   | 482 
> 
>  drivers/devfreq/rockchip/rockchip_dmc.c | 143 ++
>  include/soc/rockchip/rockchip_dmc.h |  45 +++
>  7 files changed, 689 insertions(+)
>  create mode 100644 drivers/devfreq/rockchip/Kconfig
>  create mode 100644 drivers/devfreq/rockchip/Makefile
>  create mode 100644 drivers/devfreq/rockchip/rk3399_dmc.c
>  create mode 100644 drivers/devfreq/rockchip/rockchip_dmc.c
>  create mode 100644 include/soc/rockchip/rockchip_dmc.h
>
> diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig
> index a5be56e..cb67246 100644
> --- a/drivers/devfreq/Kconfig
> +++ b/drivers/devfreq/Kconfig
> @@ -101,5 +101,6 @@ config ARM_TEGRA_DEVFREQ
>   operating frequencies and voltages with OPP support.
>
>  source "drivers/devfreq/event/Kconfig"
> +source "drivers/devfreq/rockchip/Kconfig"
>
>  endif # PM_DEVFREQ
> diff --git a/drivers/devfreq/Makefile b/drivers/devfreq/Makefile
> index 09f11d9..48e2ae6 100644
> --- a/drivers/devfreq/Makefile
> +++ b/drivers/devfreq/Makefile
> @@ -9,6 +9,7 @@ obj-$(CONFIG_DEVFREQ_GOV_PASSIVE)   += governor_passive.o
>  # DEVFREQ Drivers
>  obj-$(CONFIG_ARM_EXYNOS_BUS_DEVFREQ)   += exynos-bus.o
>  obj-$(CONFIG_ARM_TEGRA_DEVFREQ)+= tegra-devfreq.o
> +obj-$(CONFIG_ARCH_ROCKCHIP)+= rockchip/
>
>  # DEVFREQ Event Drivers
>  obj-$(CONFIG_PM_DEVFREQ_EVENT) += event/
> diff --git a/drivers/devfreq/rockchip/Kconfig 
> b/drivers/devfreq/rockchip/Kconfig
> new file mode 100644
> index 000..7fb1cff
> --- /dev/null
> +++ b/drivers/devfreq/rockchip/Kconfig
> @@ -0,0 +1,15 @@
> +config ARM_ROCKCHIP_DMC_DEVFREQ
> +   bool "ARM ROCKCHIP DMC DEVFREQ Driver"
> +   depends on ARCH_ROCKCHIP
> +   help
> + This adds the DEVFREQ driver framework for the rockchip dmc.
> +
> +config ARM_RK3399_DMC_DEVFREQ
> +   bool "ARM RK3399 DMC DEVFREQ Driver"

Since you are using bool Kconfigs for your driver, please do not use
module.h or MODULE_ tags in your driver, and use the builtin
register function.

Alternatively if there really is  a use case for it to be a modular driver
then use a tristate Kconfig.

THanks,
Paul.
--

> +   depends on ARM_ROCKCHIP_DMC_DEVFREQ
> +   select PM_OPP
> +   select DEVFREQ_GOV_SIMPLE_ONDEMAND
> +   help
> +  This adds the DEVFREQ driver for the RK3399 dmc. It sets the 
> frequency
> +  for the memory controller and reads the usage counts from hardware.
> +


[Intel-gfx] [PATCH i-g-t] tests/kms_rotation_crc: Add bad-rotation subtest

2016-07-22 Thread Ville Syrjälä
On Fri, Jul 22, 2016 at 01:52:32PM +0100, Matthew Auld wrote:
> I believe you're thinking of:
> https://patchwork.freedesktop.org/patch/77191/
> https://patchwork.freedesktop.org/patch/77192/
> 
> Although they don't test for multiple rotation values...

I guess you could just

for (rotation = 0; rotation < 0x40; rotation++)
if (!is_power_of_2(rotation & 0xf) ||
(rotation & ~supported) != 0)
// expect failure
}

if you want to be really sure invalid crap won't get through.

-- 
Ville Syrjälä
Intel OTC


[Bug 97040] NAEV menu gradient render bug

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

--- Comment #3 from Ilia Mirkin  ---
Please make an apitrace of the issue to facilitate developer
verification/debugging. See https://github.com/apitrace/apitrace .

-- 
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/20160722/0d149776/attachment.html>


[PATCH v3 3/3] drm/i915: Use new CRC debugfs API

2016-07-22 Thread Tomeu Vizoso
The core provides now an ABI to userspace for generation of frame CRCs,
so implement the ->set_crc_source() callback and reuse as much code as
possible with the previous ABI implementation.

v2:
- Leave the legacy implementation in place as the ABI implementation
  in the core is incompatible with it.
v3:
- Use the "cooked" vblank counter so we have a whole 32 bits.
- Make sure we don't mess with the state of the legacy CRC capture
  ABI implementation.

Signed-off-by: Tomeu Vizoso 
---

 drivers/gpu/drm/i915/i915_irq.c   |  69 ---
 drivers/gpu/drm/i915/intel_display.c  |   1 +
 drivers/gpu/drm/i915/intel_drv.h  |   2 +
 drivers/gpu/drm/i915/intel_pipe_crc.c | 124 --
 4 files changed, 133 insertions(+), 63 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index b77d808b71cd..f2726171f7c8 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1492,41 +1492,58 @@ static void display_pipe_crc_irq_handler(struct 
drm_i915_private *dev_priv,
 {
struct intel_pipe_crc *pipe_crc = _priv->pipe_crc[pipe];
struct intel_pipe_crc_entry *entry;
-   int head, tail;
+   struct drm_crtc *crtc = intel_get_crtc_for_pipe(_priv->drm, pipe);
+   struct drm_driver *driver = dev_priv->drm.driver;
+   uint32_t crcs[5];
+   int head, tail, ret;

spin_lock(_crc->lock);
+   if (pipe_crc->source) {
+   if (!pipe_crc->entries) {
+   spin_unlock(_crc->lock);
+   DRM_DEBUG_KMS("spurious interrupt\n");
+   return;
+   }

-   if (!pipe_crc->entries) {
-   spin_unlock(_crc->lock);
-   DRM_DEBUG_KMS("spurious interrupt\n");
-   return;
-   }
-
-   head = pipe_crc->head;
-   tail = pipe_crc->tail;
+   head = pipe_crc->head;
+   tail = pipe_crc->tail;

-   if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
-   spin_unlock(_crc->lock);
-   DRM_ERROR("CRC buffer overflowing\n");
-   return;
-   }
+   if (CIRC_SPACE(head, tail, INTEL_PIPE_CRC_ENTRIES_NR) < 1) {
+   spin_unlock(_crc->lock);
+   DRM_ERROR("CRC buffer overflowing\n");
+   return;
+   }

-   entry = _crc->entries[head];
+   entry = _crc->entries[head];

-   entry->frame = dev_priv->drm.driver->get_vblank_counter(_priv->drm,
-pipe);
-   entry->crc[0] = crc0;
-   entry->crc[1] = crc1;
-   entry->crc[2] = crc2;
-   entry->crc[3] = crc3;
-   entry->crc[4] = crc4;
+   entry->frame = driver->get_vblank_counter(_priv->drm, pipe);
+   entry->crc[0] = crc0;
+   entry->crc[1] = crc1;
+   entry->crc[2] = crc2;
+   entry->crc[3] = crc3;
+   entry->crc[4] = crc4;

-   head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
-   pipe_crc->head = head;
+   head = (head + 1) & (INTEL_PIPE_CRC_ENTRIES_NR - 1);
+   pipe_crc->head = head;

-   spin_unlock(_crc->lock);
+   spin_unlock(_crc->lock);

-   wake_up_interruptible(_crc->wq);
+   wake_up_interruptible(_crc->wq);
+   } else {
+   spin_unlock(_crc->lock);
+   spin_lock(>crc.lock);
+   crcs[0] = crc0;
+   crcs[1] = crc1;
+   crcs[2] = crc2;
+   crcs[3] = crc3;
+   crcs[4] = crc4;
+   ret = drm_crtc_add_crc_entry(crtc, true,
+drm_accurate_vblank_count(crtc),
+crcs);
+   spin_unlock(>crc.lock);
+   if (!ret)
+   wake_up_interruptible(>crc.wq);
+   }
 }
 #else
 static inline void
diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index 111b350d1d7e..d91a2f779fb1 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -14019,6 +14019,7 @@ static const struct drm_crtc_funcs intel_crtc_funcs = {
.page_flip = intel_crtc_page_flip,
.atomic_duplicate_state = intel_crtc_duplicate_state,
.atomic_destroy_state = intel_crtc_destroy_state,
+   .set_crc_source = intel_crtc_set_crc_source,
 };

 /**
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 5d06cb2425a1..4302cf2cfb04 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1782,6 +1782,8 @@ void intel_color_load_luts(struct drm_crtc_state 
*crtc_state);
 /* intel_pipe_crc.c */
 int intel_pipe_crc_create(struct drm_minor *minor);
 void intel_pipe_crc_cleanup(struct drm_minor 

[PATCH v3 2/3] drm: Add API for capturing frame CRCs

2016-07-22 Thread Tomeu Vizoso
Adds files and directories to debugfs for controlling and reading frame
CRCs, per CRTC:

dri/0/crtc-0/crc
dri/0/crtc-0/crc/control
dri/0/crtc-0/crc/data

Drivers can implement the set_crc_source callback() in drm_crtc_funcs to
start and stop generating frame CRCs and can add entries to the output
by calling drm_crtc_add_crc_entry.

v2:
- Lots of good fixes suggested by Thierry.
- Added documentation.
- Changed the debugfs layout.
- Moved to allocate the entries circular queue once when frame
  generation gets enabled for the first time.
v3:
- Use the control file just to select the source, and start and stop
  capture when the data file is opened and closed, respectively.
- Make variable the number of CRC values per entry, per source.
- Allocate entries queue each time we start capturing as now there
  isn't a fixed number of CRC values per entry.
- Store the frame counter in the data file as a 8-digit hex number.
- For sources that cannot provide useful frame numbers, place
   in the frame field.

Signed-off-by: Tomeu Vizoso 
---

 Documentation/gpu/drm-uapi.rst|   6 +
 drivers/gpu/drm/Makefile  |   3 +-
 drivers/gpu/drm/drm_crtc.c|  12 ++
 drivers/gpu/drm/drm_debugfs.c |  36 +++-
 drivers/gpu/drm/drm_debugfs_crc.c | 370 ++
 drivers/gpu/drm/drm_drv.c |   9 +
 drivers/gpu/drm/drm_internal.h|  10 ++
 include/drm/drmP.h|   5 +
 include/drm/drm_crtc.h|  41 +
 include/drm/drm_debugfs_crc.h |  74 
 10 files changed, 564 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_debugfs_crc.c
 create mode 100644 include/drm/drm_debugfs_crc.h

diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm-uapi.rst
index 536bf3eaadd4..33f778696ccd 100644
--- a/Documentation/gpu/drm-uapi.rst
+++ b/Documentation/gpu/drm-uapi.rst
@@ -109,3 +109,9 @@ interfaces. Especially since all hardware-acceleration 
interfaces to
 userspace are driver specific for efficiency and other reasons these
 interfaces can be rather substantial. Hence every driver has its own
 chapter.
+
+Testing and validation
+==
+
+.. kernel-doc:: drivers/gpu/drm/drm_debugfs_crc.c
+   :doc: CRC ABI
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index e3dba6f44a79..b53b5aaaeb4d 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -12,7 +12,8 @@ drm-y   :=drm_auth.o drm_bufs.o drm_cache.o \
drm_info.o drm_debugfs.o drm_encoder_slave.o \
drm_trace_points.o drm_global.o drm_prime.o \
drm_rect.o drm_vma_manager.o drm_flip_work.o \
-   drm_modeset_lock.o drm_atomic.o drm_bridge.o
+   drm_modeset_lock.o drm_atomic.o drm_bridge.o \
+   drm_debugfs_crc.o

 drm-$(CONFIG_COMPAT) += drm_ioc32.o
 drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 10b73f68c023..087345af96e7 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "drm_crtc_internal.h"
 #include "drm_internal.h"
@@ -738,6 +739,12 @@ int drm_crtc_init_with_planes(struct drm_device *dev, 
struct drm_crtc *crtc,
if (cursor)
cursor->possible_crtcs = 1 << drm_crtc_index(crtc);

+#ifdef CONFIG_DEBUG_FS
+   spin_lock_init(>crc.lock);
+   init_waitqueue_head(>crc.wq);
+   crtc->crc.source = kstrdup("auto", GFP_KERNEL);
+#endif
+
if (drm_core_check_feature(dev, DRIVER_ATOMIC)) {
drm_object_attach_property(>base, config->prop_active, 0);
drm_object_attach_property(>base, config->prop_mode_id, 
0);
@@ -764,6 +771,11 @@ void drm_crtc_cleanup(struct drm_crtc *crtc)
 * the indices on the drm_crtc after us in the crtc_list.
 */

+#ifdef CONFIG_DEBUG_FS
+   drm_debugfs_crtc_remove(crtc);
+   kfree(crtc->crc.source);
+#endif
+
kfree(crtc->gamma_store);
crtc->gamma_store = NULL;

diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index fa10cef2ba37..73530cbf1316 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -415,5 +415,39 @@ void drm_debugfs_connector_remove(struct drm_connector 
*connector)
connector->debugfs_entry = NULL;
 }

-#endif /* CONFIG_DEBUG_FS */
+int drm_debugfs_crtc_add(struct drm_crtc *crtc)
+{
+   struct drm_minor *minor = crtc->dev->primary;
+   struct dentry *root;
+   char *name;
+
+   name = kasprintf(GFP_KERNEL, "crtc-%d", crtc->index);
+   if (!name)
+   return -ENOMEM;

+   root = debugfs_create_dir(name, minor->debugfs_root);
+   kfree(name);
+   if (!root)
+   return -ENOMEM;
+
+   crtc->debugfs_entry = root;
+
+   if 

[PATCH v3 1/3] drm/i915/debugfs: Move out pipe CRC code

2016-07-22 Thread Tomeu Vizoso
In preparation to using a generic API in the DRM core for continuous CRC
generation, move the related code out of i915_debugfs.c into a new file.

Eventually, only the Intel-specific code will remain in this new file.

v2: Rebased.

Signed-off-by: Tomeu Vizoso 
---

 drivers/gpu/drm/i915/Makefile |   2 +-
 drivers/gpu/drm/i915/i915_debugfs.c   | 892 +--
 drivers/gpu/drm/i915/intel_drv.h  |   5 +
 drivers/gpu/drm/i915/intel_pipe_crc.c | 951 ++
 4 files changed, 961 insertions(+), 889 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_pipe_crc.c

diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 684fc1cd08fa..9419e0c2e2c0 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -19,7 +19,7 @@ i915-y := i915_drv.o \
  intel_runtime_pm.o

 i915-$(CONFIG_COMPAT)   += i915_ioc32.o
-i915-$(CONFIG_DEBUG_FS) += i915_debugfs.o
+i915-$(CONFIG_DEBUG_FS) += i915_debugfs.o intel_pipe_crc.o

 # GEM code
 i915-y += i915_cmd_parser.o \
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
b/drivers/gpu/drm/i915/i915_debugfs.c
index a59e0caeda64..c37bfda32e53 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -26,19 +26,9 @@
  *
  */

-#include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include "intel_drv.h"
-#include "intel_ringbuffer.h"
-#include 
-#include "i915_drv.h"

 enum {
ACTIVE_LIST,
@@ -3490,12 +3480,6 @@ static int i915_drrs_status(struct seq_file *m, void 
*unused)
return 0;
 }

-struct pipe_crc_info {
-   const char *name;
-   struct drm_device *dev;
-   enum pipe pipe;
-};
-
 static int i915_dp_mst_info(struct seq_file *m, void *unused)
 {
struct drm_info_node *node = (struct drm_info_node *) m->private;
@@ -3525,853 +3509,6 @@ static int i915_dp_mst_info(struct seq_file *m, void 
*unused)
return 0;
 }

-static int i915_pipe_crc_open(struct inode *inode, struct file *filep)
-{
-   struct pipe_crc_info *info = inode->i_private;
-   struct drm_i915_private *dev_priv = to_i915(info->dev);
-   struct intel_pipe_crc *pipe_crc = _priv->pipe_crc[info->pipe];
-
-   if (info->pipe >= INTEL_INFO(info->dev)->num_pipes)
-   return -ENODEV;
-
-   spin_lock_irq(_crc->lock);
-
-   if (pipe_crc->opened) {
-   spin_unlock_irq(_crc->lock);
-   return -EBUSY; /* already open */
-   }
-
-   pipe_crc->opened = true;
-   filep->private_data = inode->i_private;
-
-   spin_unlock_irq(_crc->lock);
-
-   return 0;
-}
-
-static int i915_pipe_crc_release(struct inode *inode, struct file *filep)
-{
-   struct pipe_crc_info *info = inode->i_private;
-   struct drm_i915_private *dev_priv = to_i915(info->dev);
-   struct intel_pipe_crc *pipe_crc = _priv->pipe_crc[info->pipe];
-
-   spin_lock_irq(_crc->lock);
-   pipe_crc->opened = false;
-   spin_unlock_irq(_crc->lock);
-
-   return 0;
-}
-
-/* (6 fields, 8 chars each, space separated (5) + '\n') */
-#define PIPE_CRC_LINE_LEN  (6 * 8 + 5 + 1)
-/* account for \'0' */
-#define PIPE_CRC_BUFFER_LEN(PIPE_CRC_LINE_LEN + 1)
-
-static int pipe_crc_data_count(struct intel_pipe_crc *pipe_crc)
-{
-   assert_spin_locked(_crc->lock);
-   return CIRC_CNT(pipe_crc->head, pipe_crc->tail,
-   INTEL_PIPE_CRC_ENTRIES_NR);
-}
-
-static ssize_t
-i915_pipe_crc_read(struct file *filep, char __user *user_buf, size_t count,
-  loff_t *pos)
-{
-   struct pipe_crc_info *info = filep->private_data;
-   struct drm_device *dev = info->dev;
-   struct drm_i915_private *dev_priv = to_i915(dev);
-   struct intel_pipe_crc *pipe_crc = _priv->pipe_crc[info->pipe];
-   char buf[PIPE_CRC_BUFFER_LEN];
-   int n_entries;
-   ssize_t bytes_read;
-
-   /*
-* Don't allow user space to provide buffers not big enough to hold
-* a line of data.
-*/
-   if (count < PIPE_CRC_LINE_LEN)
-   return -EINVAL;
-
-   if (pipe_crc->source == INTEL_PIPE_CRC_SOURCE_NONE)
-   return 0;
-
-   /* nothing to read */
-   spin_lock_irq(_crc->lock);
-   while (pipe_crc_data_count(pipe_crc) == 0) {
-   int ret;
-
-   if (filep->f_flags & O_NONBLOCK) {
-   spin_unlock_irq(_crc->lock);
-   return -EAGAIN;
-   }
-
-   ret = wait_event_interruptible_lock_irq(pipe_crc->wq,
-   pipe_crc_data_count(pipe_crc), pipe_crc->lock);
-   if (ret) {
-   spin_unlock_irq(_crc->lock);
-   return ret;
-   }
-   }
-
-   /* We now have one or more entries to read */
-   n_entries = count / PIPE_CRC_LINE_LEN;
-
-   bytes_read = 0;
-   while (n_entries > 

[PATCH v3 0/3] New debugfs API for capturing CRC of frames

2016-07-22 Thread Tomeu Vizoso
Hi,

this series basically takes the facility for continuously capturing CRCs
of frames from the i915 driver and into the DRM core.

The idea is that test suites such as IGT use this information to check
that frames that are exected to be identical, also have identical CRC
values.

Other drivers for hardware that can provide frame CRCs (including eDP
panels that support self-refresh) can easily implement the new callback
and provide userspace with the CRC values.

Thanks,

Tomeu


Tomeu Vizoso (3):
  drm/i915/debugfs: Move out pipe CRC code
  drm: Add API for capturing frame CRCs
  drm/i915: Use new CRC debugfs API

 Documentation/gpu/drm-uapi.rst|6 +
 drivers/gpu/drm/Makefile  |3 +-
 drivers/gpu/drm/drm_crtc.c|   12 +
 drivers/gpu/drm/drm_debugfs.c |   36 +-
 drivers/gpu/drm/drm_debugfs_crc.c |  370 
 drivers/gpu/drm/drm_drv.c |9 +
 drivers/gpu/drm/drm_internal.h|   10 +
 drivers/gpu/drm/i915/Makefile |2 +-
 drivers/gpu/drm/i915/i915_debugfs.c   |  892 +
 drivers/gpu/drm/i915/i915_irq.c   |   69 ++-
 drivers/gpu/drm/i915/intel_display.c  |1 +
 drivers/gpu/drm/i915/intel_drv.h  |7 +
 drivers/gpu/drm/i915/intel_pipe_crc.c | 1001 +
 include/drm/drmP.h|5 +
 include/drm/drm_crtc.h|   41 ++
 include/drm/drm_debugfs_crc.h |   74 +++
 16 files changed, 1621 insertions(+), 917 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_debugfs_crc.c
 create mode 100644 drivers/gpu/drm/i915/intel_pipe_crc.c
 create mode 100644 include/drm/drm_debugfs_crc.h

-- 
2.5.5



[PATCH 05/15] drm/atmel-hlcdc: Use per-plane rotation property

2016-07-22 Thread Boris Brezillon
Hi Ville,

On Fri, 22 Jul 2016 16:43:06 +0300
ville.syrjala at linux.intel.com wrote:

> From: Ville Syrjälä 
> 
> The global mode_config.rotation_property is going away, switch over to
> per-plane rotation_property.
> 
> Cc: Boris Brezillon 
> Signed-off-by: Ville Syrjälä 
> ---
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 18 ++
>  1 file changed, 6 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c 
> b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
> index f3350c80704d..be3d4310ea97 100644
> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
> @@ -903,9 +903,12 @@ static void atmel_hlcdc_plane_init_properties(struct 
> atmel_hlcdc_plane *plane,
>   }
>  
>   if (desc->layout.xstride && desc->layout.pstride)
> - drm_object_attach_property(>base.base,
> - plane->base.dev->mode_config.rotation_property,
> - BIT(DRM_ROTATE_0));
> + drm_plane_create_rotation_property(>base,
> +BIT(DRM_ROTATE_0),
> +BIT(DRM_ROTATE_0) |
> +BIT(DRM_ROTATE_90) |
> +BIT(DRM_ROTATE_180) |
> +BIT(DRM_ROTATE_270));

Can you update the atmel_hlcdc_plane_init_properties() prototype to
return an int so that we can catch errors returned by
drm_plane_create_rotation_property().

Thanks,

Boris

>  
>   if (desc->layout.csc) {
>   /*
> @@ -1054,15 +1057,6 @@ atmel_hlcdc_plane_create_properties(struct drm_device 
> *dev)
>   if (!props->alpha)
>   return ERR_PTR(-ENOMEM);
>  
> - dev->mode_config.rotation_property =
> - drm_mode_create_rotation_property(dev,
> -   BIT(DRM_ROTATE_0) |
> -   BIT(DRM_ROTATE_90) |
> -   BIT(DRM_ROTATE_180) |
> -   BIT(DRM_ROTATE_270));
> - if (!dev->mode_config.rotation_property)
> - return ERR_PTR(-ENOMEM);
> -
>   return props;
>  }
>  



[Bug 97022] Garbage in windows while running a game windowed

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

--- Comment #7 from Peter Mulholland  ---
Created attachment 125258
  --> https://bugs.freedesktop.org/attachment.cgi?id=125258=edit
Xorg log from same crash

-- 
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/20160722/e5f2aa41/attachment.html>


[Bug 97022] Garbage in windows while running a game windowed

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

--- Comment #6 from Peter Mulholland  ---
Created attachment 125257
  --> https://bugs.freedesktop.org/attachment.cgi?id=125257=edit
Latest kern.log from crash described

-- 
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/20160722/5f789669/attachment.html>


[Bug 97022] Garbage in windows while running a game windowed

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

--- Comment #5 from Peter Mulholland  ---
Today I gave the latest Padoka (git1600721124400.4f89cf4) a try during
debugging Overlord. I got a screen corruption followed by a hang.

Just as I was about to reach for the SysRq keys, Xorg restarted, and seemed to
operate as normal - except I was now on llvmpipe instead. Quite an amount of
kernel log was generated, and some relevant looking info in Xorg.log too. They
are attached here.

-- 
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/20160722/23378732/attachment-0001.html>


[PATCH 04/15] drm/arm: Use per-plane rotation property

2016-07-22 Thread Brian Starkey
On Fri, Jul 22, 2016 at 04:43:05PM +0300, Ville Syrjälä wrote:
>From: Ville Syrjälä 
>
>The global mode_config.rotation_property is going away, switch over to
>per-plane rotation_property.
>
>Cc: Liviu Dudau 
>Cc: Brian Starkey 
>Cc: Mali DP Maintainers 
>Signed-off-by: Ville Syrjälä 

Acked-by: Brian Starkey 

Thanks!

-Brian
>---
> drivers/gpu/drm/arm/malidp_planes.c | 13 +
> 1 file changed, 5 insertions(+), 8 deletions(-)
>
>diff --git a/drivers/gpu/drm/arm/malidp_planes.c 
>b/drivers/gpu/drm/arm/malidp_planes.c
>index 725098d6179a..7fbe1feec861 100644
>--- a/drivers/gpu/drm/arm/malidp_planes.c
>+++ b/drivers/gpu/drm/arm/malidp_planes.c
>@@ -254,21 +254,18 @@ int malidp_de_planes_init(struct drm_device *drm)
>   if (ret < 0)
>   goto cleanup;
>
>-  if (!drm->mode_config.rotation_property) {
>+  /* SMART layer can't be rotated */
>+  if (id != DE_SMART) {
>   unsigned long flags = BIT(DRM_ROTATE_0) |
> BIT(DRM_ROTATE_90) |
> BIT(DRM_ROTATE_180) |
> BIT(DRM_ROTATE_270) |
> BIT(DRM_REFLECT_X) |
> BIT(DRM_REFLECT_Y);
>-  drm->mode_config.rotation_property =
>-  drm_mode_create_rotation_property(drm, flags);
>+  drm_plane_create_rotation_property(>base,
>+ BIT(DRM_ROTATE_0),
>+ flags);
>   }
>-  /* SMART layer can't be rotated */
>-  if (drm->mode_config.rotation_property && (id != DE_SMART))
>-  drm_object_attach_property(>base.base,
>- 
>drm->mode_config.rotation_property,
>- BIT(DRM_ROTATE_0));
>
>   drm_plane_helper_add(>base,
>_de_plane_helper_funcs);
>-- 
>2.7.4
>


[PATCH] drm/ttm: partial revert "cleanup ttm_tt_(unbind|destroy)" v2

2016-07-22 Thread Christian König
From: Christian König 

We still need to unbind explicitely during a move.

This partial reverts commit ff20caa0bcbfef9f7686f8d1868a3b990921afd6.

v2: remove unnecessary check and unused variable

Signed-off-by: Christian König 
---
 drivers/gpu/drm/ttm/ttm_bo_util.c |  1 +
 drivers/gpu/drm/ttm/ttm_tt.c  | 19 ---
 include/drm/ttm/ttm_bo_driver.h   |  9 +
 3 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c 
b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 0c389a5..6c412c3 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -53,6 +53,7 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
int ret;

if (old_mem->mem_type != TTM_PL_SYSTEM) {
+   ttm_tt_unbind(ttm);
ttm_bo_free_old_node(bo);
ttm_flag_masked(_mem->placement, TTM_PL_FLAG_SYSTEM,
TTM_PL_MASK_MEM);
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index d28d4333..526e5a7 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -166,16 +166,10 @@ EXPORT_SYMBOL(ttm_tt_set_placement_caching);

 void ttm_tt_destroy(struct ttm_tt *ttm)
 {
-   int ret;
-
if (ttm == NULL)
return;

-   if (ttm->state == tt_bound) {
-   ret = ttm->func->unbind(ttm);
-   BUG_ON(ret);
-   ttm->state = tt_unbound;
-   }
+   ttm_tt_unbind(ttm);

if (ttm->state == tt_unbound)
ttm_tt_unpopulate(ttm);
@@ -255,6 +249,17 @@ void ttm_dma_tt_fini(struct ttm_dma_tt *ttm_dma)
 }
 EXPORT_SYMBOL(ttm_dma_tt_fini);

+void ttm_tt_unbind(struct ttm_tt *ttm)
+{
+   int ret;
+
+   if (ttm->state == tt_bound) {
+   ret = ttm->func->unbind(ttm);
+   BUG_ON(ret);
+   ttm->state = tt_unbound;
+   }
+}
+
 int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem)
 {
int ret = 0;
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 141cefb..e7d81a8 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -628,6 +628,15 @@ extern int ttm_tt_bind(struct ttm_tt *ttm, struct 
ttm_mem_reg *bo_mem);
 extern void ttm_tt_destroy(struct ttm_tt *ttm);

 /**
+ * ttm_ttm_unbind:
+ *
+ * @ttm: The struct ttm_tt.
+ *
+ * Unbind a struct ttm_tt.
+ */
+extern void ttm_tt_unbind(struct ttm_tt *ttm);
+
+/**
  * ttm_tt_swapin:
  *
  * @ttm: The struct ttm_tt.
-- 
2.5.0



[PATCH] drm/bridge: ps8622: Delete an unnecessary check before backlight_device_unregister()

2016-07-22 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 22 Jul 2016 14:45:51 +0200

The backlight_device_unregister() function tests whether its argument
is NULL and then returns immediately.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/gpu/drm/bridge/parade-ps8622.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/bridge/parade-ps8622.c 
b/drivers/gpu/drm/bridge/parade-ps8622.c
index 5cd8dd7..583b8ce 100644
--- a/drivers/gpu/drm/bridge/parade-ps8622.c
+++ b/drivers/gpu/drm/bridge/parade-ps8622.c
@@ -636,9 +636,7 @@ static int ps8622_remove(struct i2c_client *client)
 {
struct ps8622_bridge *ps8622 = i2c_get_clientdata(client);

-   if (ps8622->bl)
-   backlight_device_unregister(ps8622->bl);
-
+   backlight_device_unregister(ps8622->bl);
drm_bridge_remove(>bridge);

return 0;
-- 
2.9.2



[PATCH v6 4/4] drm: rcar: use generic code for managing zpos plane property

2016-07-22 Thread Benjamin Gaignard
version 6:
rebased patch on top rcar-du changes for zpos

version 4:
fix null pointer issue while setting zpos in plane reset function

This patch replaces zpos property handling custom code in rcar DRM
driver with calls to generic DRM code.

Signed-off-by: Benjamin Gaignard 
Reviewed-by: Laurent Pinchart 
Tested-by: Laurent Pinchart 

Cc: Daniel Vetter 
Cc: Ville Syrjala 
Cc: Marek Szyprowski 
---
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c  | 2 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.h   | 1 -
 drivers/gpu/drm/rcar-du/rcar_du_kms.c   | 5 -
 drivers/gpu/drm/rcar-du/rcar_du_plane.c | 9 ++---
 drivers/gpu/drm/rcar-du/rcar_du_plane.h | 2 --
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c   | 5 -
 6 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c 
b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index e39fcef..7316fc7 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -196,7 +196,7 @@ void rcar_du_crtc_route_output(struct drm_crtc *crtc,

 static unsigned int plane_zpos(struct rcar_du_plane *plane)
 {
-   return to_rcar_plane_state(plane->plane.state)->zpos;
+   return plane->plane.state->normalized_zpos;
 }

 static const struct rcar_du_format_info *
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.h 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
index ed35467..c843c31 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
@@ -92,7 +92,6 @@ struct rcar_du_device {
struct {
struct drm_property *alpha;
struct drm_property *colorkey;
-   struct drm_property *zpos;
} props;

unsigned int dpad0_source;
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c 
b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index 6bb032d..f03eb55 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -527,11 +527,6 @@ static int rcar_du_properties_init(struct rcar_du_device 
*rcdu)
if (rcdu->props.colorkey == NULL)
return -ENOMEM;

-   rcdu->props.zpos =
-   drm_property_create_range(rcdu->ddev, 0, "zpos", 1, 7);
-   if (rcdu->props.zpos == NULL)
-   return -ENOMEM;
-
return 0;
 }

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c 
b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
index bfe31ca..a74f8ed 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
@@ -652,7 +652,7 @@ static void rcar_du_plane_reset(struct drm_plane *plane)
state->source = RCAR_DU_PLANE_MEMORY;
state->alpha = 255;
state->colorkey = RCAR_DU_COLORKEY_NONE;
-   state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;
+   state->state.zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;

plane->state = >state;
plane->state->plane = plane;
@@ -670,8 +670,6 @@ static int rcar_du_plane_atomic_set_property(struct 
drm_plane *plane,
rstate->alpha = val;
else if (property == rcdu->props.colorkey)
rstate->colorkey = val;
-   else if (property == rcdu->props.zpos)
-   rstate->zpos = val;
else
return -EINVAL;

@@ -690,8 +688,6 @@ static int rcar_du_plane_atomic_get_property(struct 
drm_plane *plane,
*val = rstate->alpha;
else if (property == rcdu->props.colorkey)
*val = rstate->colorkey;
-   else if (property == rcdu->props.zpos)
-   *val = rstate->zpos;
else
return -EINVAL;

@@ -763,8 +759,7 @@ int rcar_du_planes_init(struct rcar_du_group *rgrp)
drm_object_attach_property(>plane.base,
   rcdu->props.colorkey,
   RCAR_DU_COLORKEY_NONE);
-   drm_object_attach_property(>plane.base,
-  rcdu->props.zpos, 1);
+   drm_plane_create_zpos_property(>plane, 1, 1, 7);
}

return 0;
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.h 
b/drivers/gpu/drm/rcar-du/rcar_du_plane.h
index b18b7b2..8b91dd3 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_plane.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.h
@@ -51,7 +51,6 @@ static inline struct rcar_du_plane *to_rcar_plane(struct 
drm_plane *plane)
  * @hwindex: 0-based hardware plane index, -1 means unused
  * @alpha: value of the plane alpha property
  * @colorkey: value of the plane colorkey property
- * @zpos: value of the plane zpos property
  */
 struct rcar_du_plane_state {
struct drm_plane_state state;
@@ -62,7 +61,6 @@ struct rcar_du_plane_state {

unsigned int alpha;
unsigned int colorkey;
-   unsigned int zpos;
 };

 static inline struct rcar_du_plane_state *
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c 
b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
index e671a7c..7e51afc 100644
--- 

[PATCH] drm/qxl: Delete an unnecessary check before drm_gem_object_unreference_unlocked()

2016-07-22 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 22 Jul 2016 14:14:54 +0200

The drm_gem_object_unreference_unlocked() function tests whether
its argument is NULL and then returns immediately.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/gpu/drm/qxl/qxl_display.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_display.c 
b/drivers/gpu/drm/qxl/qxl_display.c
index ad42968..3aef127 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -468,8 +468,7 @@ void qxl_user_framebuffer_destroy(struct drm_framebuffer 
*fb)
 {
struct qxl_framebuffer *qxl_fb = to_qxl_framebuffer(fb);

-   if (qxl_fb->obj)
-   drm_gem_object_unreference_unlocked(qxl_fb->obj);
+   drm_gem_object_unreference_unlocked(qxl_fb->obj);
drm_framebuffer_cleanup(fb);
kfree(qxl_fb);
 }
-- 
2.9.2



[PATCH 2/2] drm/imx: imx-ldb: use encoder atomic_mode_set callback

2016-07-22 Thread Philipp Zabel
Using atomic_mode_set instead of mode_set allows to access crtc
and connector states in addition to the modes. This allows to
remove the connector list walk.

Signed-off-by: Philipp Zabel 
---
 drivers/gpu/drm/imx/imx-ldb.c | 24 ++--
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c
index 3ed2d50..7b588b4 100644
--- a/drivers/gpu/drm/imx/imx-ldb.c
+++ b/drivers/gpu/drm/imx/imx-ldb.c
@@ -252,11 +252,13 @@ static void imx_ldb_encoder_enable(struct drm_encoder 
*encoder)
drm_panel_enable(imx_ldb_ch->panel);
 }

-static void imx_ldb_encoder_mode_set(struct drm_encoder *encoder,
-struct drm_display_mode *orig_mode,
-struct drm_display_mode *mode)
+static void
+imx_ldb_encoder_atomic_mode_set(struct drm_encoder *encoder,
+   struct drm_crtc_state *crtc_state,
+   struct drm_connector_state *connector_state)
 {
struct imx_ldb_channel *imx_ldb_ch = enc_to_imx_ldb_ch(encoder);
+   struct drm_display_mode *mode = _state->adjusted_mode;
struct imx_ldb *ldb = imx_ldb_ch->ldb;
int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN;
unsigned long serial_clk;
@@ -298,17 +300,11 @@ static void imx_ldb_encoder_mode_set(struct drm_encoder 
*encoder,
}

if (!bus_format) {
-   struct drm_connector *connector;
+   struct drm_connector *connector = connector_state->connector;
+   struct drm_display_info *di = >display_info;

-   drm_for_each_connector(connector, encoder->dev) {
-   struct drm_display_info *di = >display_info;
-
-   if (connector->encoder == encoder &&
-   di->num_bus_formats) {
-   bus_format = di->bus_formats[0];
-   break;
-   }
-   }
+   if (di->num_bus_formats)
+   bus_format = di->bus_formats[0];
}
imx_ldb_ch_set_bus_format(imx_ldb_ch, bus_format);
 }
@@ -426,7 +422,7 @@ static const struct drm_encoder_funcs imx_ldb_encoder_funcs 
= {
 };

 static const struct drm_encoder_helper_funcs imx_ldb_encoder_helper_funcs = {
-   .mode_set = imx_ldb_encoder_mode_set,
+   .atomic_mode_set = imx_ldb_encoder_atomic_mode_set,
.enable = imx_ldb_encoder_enable,
.disable = imx_ldb_encoder_disable,
.atomic_check = imx_ldb_encoder_atomic_check,
-- 
2.8.1



[PATCH 1/2] drm/atomic-helper: Add atomic_mode_set version to extend encoder mode_set

2016-07-22 Thread Philipp Zabel
Some encoders need more information from crtc and connector state
than just the mode. Add an atomic encoder mode setting variant
that passes the crtc state (which contains the modes) and the
connector state.

Signed-off-by: Philipp Zabel 
---
 drivers/gpu/drm/drm_atomic_helper.c  |  6 +-
 include/drm/drm_modeset_helper_vtables.h | 20 
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index de7fddc..a3c033f 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -880,8 +880,12 @@ crtc_set_mode(struct drm_device *dev, struct 
drm_atomic_state *old_state)
 * Each encoder has at most one connector (since we always steal
 * it away), so we won't call mode_set hooks twice.
 */
-   if (funcs && funcs->mode_set)
+   if (funcs && funcs->atomic_mode_set) {
+   funcs->atomic_mode_set(encoder, new_crtc_state,
+  connector->state);
+   } else if (funcs && funcs->mode_set) {
funcs->mode_set(encoder, mode, adjusted_mode);
+   }

drm_bridge_mode_set(encoder->bridge, mode, adjusted_mode);
}
diff --git a/include/drm/drm_modeset_helper_vtables.h 
b/include/drm/drm_modeset_helper_vtables.h
index b55f218..1b15c1f 100644
--- a/include/drm/drm_modeset_helper_vtables.h
+++ b/include/drm/drm_modeset_helper_vtables.h
@@ -529,6 +529,26 @@ struct drm_encoder_helper_funcs {
 struct drm_display_mode *adjusted_mode);

/**
+* @atomic_mode_set:
+*
+* This callback is used to update the display mode of an encoder.
+*
+* Note that the display pipe is completely off when this function is
+* called. Drivers which need hardware to be running before they program
+* the new display mode (because they implement runtime PM) should not
+* use this hook, because the helper library calls it only once and not
+* every time the display pipeline is suspended using either DPMS or the
+* new "ACTIVE" property. Such drivers should instead move all their
+* encoder setup into the ->enable() callback.
+*
+* This callback is used by the atomic modeset helpers instead of the
+* mode_set callback. It is optional in the atomic helpers.
+*/
+   void (*atomic_mode_set)(struct drm_encoder *encoder,
+   struct drm_crtc_state *crtc_state,
+   struct drm_connector_state *conn_state);
+
+   /**
 * @get_crtc:
 *
 * This callback is used by the legacy CRTC helpers to work around
-- 
2.8.1



[PATCH v2] drm/imx: imx-ldb: do not try to dereference crtc->state->state in encoder mode_set

2016-07-22 Thread Philipp Zabel
The code in imx_ldb_encoder_mode_set crashes with a NULL pointer
dereference trying to access crtc->state->state, which was previously
cleared by drm_atomic_helper_swap_state:

Unable to handle kernel NULL pointer dereference at virtual address 0010
pgd = ae08c000
[0010] *pgd=3e00e831, *pte=, *ppte=
Internal error: Oops: 17 [#1] PREEMPT SMP ARM
Modules linked in:
CPU: 1 PID: 102 Comm: kmsfb-manage Not tainted 4.7.0-rc5+ #232
Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
task: ae058c40 ti: ae04e000 task.ti: ae04e000
PC is at imx_ldb_encoder_mode_set+0x138/0x2f8
LR is at 0xae881818
pc : [<8051a8c8>]lr : []psr: 600f0013
sp : ae04fc70  ip : ae04fbb0  fp : ae04fcbc
r10: ae8ea018  r9 :   r8 : ae246418
r7 : ae8ea010  r6 : ae8ea308  r5 :   r4 : 
r3 :   r2 :   r1 : 0110  r0 : 
Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
Control: 10c5387d  Table: 3e08c04a  DAC: 0051
Process kmsfb-manage (pid: 102, stack limit = 0xae04e210)
Stack: (0xae04fc70 to 0xae05)
fc60: 043ce660 0001 009e 
043ce660
fc80: 0002   af75cf50 1009 ae23f440 0001 
ae246418
fca0: 8155a210 ae8ea308 8093c364 ae2464e0 ae04fcec ae04fcc0 804ef350 
8051a79c
fcc0: 0004 0004 ae23f440 af3f9000 ae881818 8155a210 af1af200 
ae8ea020
fce0: ae04fd1c ae04fcf0 80519124 804ef060 ae04fd34   

fd00: ae881818 ae23f440 80d4ec8c  ae04fd34 ae04fd20 804f00b4 
80518fac
fd20: ae23f440  ae04fd54 ae04fd38 804f2190 804f0074 ae23f440 
af3f9000
fd40: ae04fdd4 ae881818 ae04fd6c ae04fd58 80516390 804f20f4 ae23f440 

fd60: ae04fd8c ae04fd70 804f26f4 80516348 ae23a000 ae881818 0001 
af3f9000
fd80: ae04fdac ae04fd90 80502c58 804f2678 ae04fe50 ae23f400 0001 
af3f9000
fda0: ae04fe1c ae04fdb0 80507a1c 80502bf8 ae23a000 ae058c40 af1af200 
ae23f400
fdc0: ae23a000 af3f9000 ae881818 ae23a00c 80176c7c ae23a000 ae881818 
af1af200
fde0:   ae23f400 0001 ae04fe1c 0051 ae04fe50 
8155a210
fe00: 80932060 c06864a2 af3f9000 ae246200 ae04fefc ae04fe20 804f9718 
805074e8
fe20: ae04feac ae04fe30 80177360 8017631c 805074dc 0068 0068 
0062
fe40: 0068 00a2 ae04fe50 7ef29688 7ef29c40  0001 
0018
fe60: 0026    0001 000115bc 05010500 
05a0059f
fe80: 0320 03360321 0337 003c  0040 30383231 
30303878
fea0:       4000 
aea6a140
fec0:  80d77b71  80283110 600f0013 7ef29688 af342bb0 
ae250b40
fee0: 80275440 0003 ae04e000  ae04ff7c ae04ff00 80274ac8 
804f957c
ff00: 80283128 80179030   80282fd8 ae1e 003d 
aea6a1d0
ff20: 0002 0003 4000 007f8c60 c06864a2 7ef29688 ae04e000 

ff40: ae04ff6c ae04ff50 80283260 80282fe4 00017050 ae250b41 0003 
ae250b40
ff60: c06864a2 7ef29688 ae04e000  ae04ffa4 ae04ff80 80275440 
80274a20
ff80: 00017050 0001 007f8c60 0036 801088a4 ae04e000  
ae04ffa8
ffa0: 80108700 80275408 00017050 0001 0003 c06864a2 7ef29688 
000115bc
ffc0: 00017050 0001 007f8c60 0036 0003  0026 
0018
ffe0: 00016f28 7ef29684 b7d9 76e4a1e6 400f0030 0003 3ff7e861 
3ff7ec61
Backtrace:
[<8051a790>] (imx_ldb_encoder_mode_set) from [<804ef350>] 
(drm_atomic_helper_commit_modeset_disables+0x2fc/0x3f0)
 r10:ae2464e0 r9:8093c364 r8:ae8ea308 r7:8155a210 r6:ae246418 r5:0001
 r4:ae23f440
[<804ef054>] (drm_atomic_helper_commit_modeset_disables) from [<80519124>] 
(imx_drm_atomic_commit_tail+0x184/0x1e0)
 r10:ae8ea020 r9:af1af200 r8:8155a210 r7:ae881818 r6:af3f9000 r5:ae23f440
 r4:0004 r3:0004
[<80518fa0>] (imx_drm_atomic_commit_tail) from [<804f00b4>] 
(commit_tail+0x4c/0x68)
 r6: r5:80d4ec8c r4:ae23f440
[<804f0068>] (commit_tail) from [<804f2190>] 
(drm_atomic_helper_commit+0xa8/0xd4)
 r5: r4:ae23f440
[<804f20e8>] (drm_atomic_helper_commit) from [<80516390>] 
(drm_atomic_commit+0x54/0x74)
 r7:ae881818 r6:ae04fdd4 r5:af3f9000 r4:ae23f440
[<8051633c>] (drm_atomic_commit) from [<804f26f4>] 
(drm_atomic_helper_set_config+0x88/0xac)
 r5: r4:ae23f440
[<804f266c>] (drm_atomic_helper_set_config) from [<80502c58>] 
(drm_mode_set_config_internal+0x6c/0xf4)
 r7:af3f9000 r6:0001 r5:ae881818 r4:ae23a000
[<80502bec>] (drm_mode_set_config_internal) from [<80507a1c>] 
(drm_mode_setcrtc+0x540/0x5b8)
 r7:af3f9000 r6:0001 r5:ae23f400 r4:ae04fe50
[<805074dc>] (drm_mode_setcrtc) from [<804f9718>] (drm_ioctl+0x1a8/0x46c)
 r10:ae246200 r9:af3f9000 r8:c06864a2 r7:80932060 r6:8155a210 

[PATCH 4/4] GPU-DRM-Etnaviv: Optimize error handling in etnaviv_gem_new_userptr()

2016-07-22 Thread Sean Paul
On Fri, Jul 22, 2016 at 11:51 AM, SF Markus Elfring
 wrote:
> From: Markus Elfring 
> Date: Fri, 22 Jul 2016 17:17:48 +0200
>
> Refactor this function implementation so that the
> drm_gem_object_unreference_unlocked() function will only be called once
> in case of a failure according to the Linux coding style recommendation
> for centralized exiting of functions.
>
> Signed-off-by: Markus Elfring 

Applied to drm-misc. In the future, could you please format your
subjects starting with "drm/"? I've fixed this one and the
first, but it'd be nice not to have to do that going forward.

Sean

> ---
>  drivers/gpu/drm/etnaviv/etnaviv_gem.c | 9 +++--
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c 
> b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
> index 0a5c00c..007577c 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
> @@ -909,15 +909,12 @@ int etnaviv_gem_new_userptr(struct drm_device *dev, 
> struct drm_file *file,
> get_task_struct(current);
>
> ret = etnaviv_gem_obj_add(dev, _obj->base);
> -   if (ret) {
> -   drm_gem_object_unreference_unlocked(_obj->base);
> -   return ret;
> -   }
> +   if (ret)
> +   goto unreference;
>
> ret = drm_gem_handle_create(file, _obj->base, handle);
> -
> +unreference:
> /* drop reference from allocate - handle holds it now */
> drm_gem_object_unreference_unlocked(_obj->base);
> -
> return ret;
>  }
> --
> 2.9.2
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/4] GPU-DRM-Etnaviv: Delete unnecessary checks before two function calls

2016-07-22 Thread Sean Paul
On Fri, Jul 22, 2016 at 11:47 AM, SF Markus Elfring
 wrote:
> From: Markus Elfring 
> Date: Fri, 22 Jul 2016 15:56:15 +0200
>
> The functions drm_gem_object_unreference_unlocked() and vunmap() perform
> also input parameter validation.
> Thus the tests around their calls are not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring 

Applied to drm-misc. In the future, could you please format your
subjects starting with "drm/"? I've fixed this one and the
next, but it'd be nice not to have to do that going forward.

> ---
>  drivers/gpu/drm/etnaviv/etnaviv_gem.c | 7 ++-
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c 
> b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
> index 8c6f750..8eee742 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
> @@ -535,8 +535,7 @@ void etnaviv_gem_describe_objects(struct 
> etnaviv_drm_private *priv,
>
>  static void etnaviv_gem_shmem_release(struct etnaviv_gem_object *etnaviv_obj)
>  {
> -   if (etnaviv_obj->vaddr)
> -   vunmap(etnaviv_obj->vaddr);
> +   vunmap(etnaviv_obj->vaddr);
> put_pages(etnaviv_obj);
>  }
>
> @@ -670,9 +669,7 @@ static struct drm_gem_object *__etnaviv_gem_new(struct 
> drm_device *dev,
> return obj;
>
>  fail:
> -   if (obj)
> -   drm_gem_object_unreference_unlocked(obj);
> -
> +   drm_gem_object_unreference_unlocked(obj);
> return ERR_PTR(ret);
>  }
>
> --
> 2.9.2
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Intel-gfx] [PATCH i-g-t] tests/kms_rotation_crc: Add bad-rotation subtest

2016-07-22 Thread Matthew Auld
I believe you're thinking of:
https://patchwork.freedesktop.org/patch/77191/
https://patchwork.freedesktop.org/patch/77192/

Although they don't test for multiple rotation values...


[PATCH 3/4] GPU-DRM-Etnaviv: Rename jump labels

2016-07-22 Thread Sean Paul
On Fri, Jul 22, 2016 at 11:50 AM, SF Markus Elfring
 wrote:
> From: Markus Elfring 
> Date: Fri, 22 Jul 2016 16:51:00 +0200
>
> Adjust jump targets according to the Linux coding style convention.
>

I'm not convinced the old labels are really that bad, tbh.

Sean

> Signed-off-by: Markus Elfring 
> ---
>  drivers/gpu/drm/etnaviv/etnaviv_gem.c | 14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c 
> b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
> index 851a8ba..0a5c00c 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
> @@ -308,17 +308,17 @@ struct etnaviv_vram_mapping *etnaviv_gem_mapping_get(
> mapping = NULL;
> mutex_unlock(>mmu->lock);
> if (mapping)
> -   goto out;
> +   goto unlock;
> } else {
> mapping->use += 1;
> -   goto out;
> +   goto unlock;
> }
> }
>
> pages = etnaviv_gem_get_pages(etnaviv_obj);
> if (IS_ERR(pages)) {
> ret = PTR_ERR(pages);
> -   goto out;
> +   goto unlock;
> }
>
> /*
> @@ -330,7 +330,7 @@ struct etnaviv_vram_mapping *etnaviv_gem_mapping_get(
> mapping = kzalloc(sizeof(*mapping), GFP_KERNEL);
> if (!mapping) {
> ret = -ENOMEM;
> -   goto out;
> +   goto unlock;
> }
>
> INIT_LIST_HEAD(>scan_node);
> @@ -349,7 +349,7 @@ struct etnaviv_vram_mapping *etnaviv_gem_mapping_get(
> else
> list_add_tail(>obj_node, _obj->vram_list);
>
> -out:
> +unlock:
> mutex_unlock(_obj->lock);
>
> if (ret)
> @@ -646,7 +646,7 @@ static struct drm_gem_object *__etnaviv_gem_new(struct 
> drm_device *dev,
> ret = etnaviv_gem_new_impl(dev, size, flags, NULL,
>_gem_shmem_ops, );
> if (ret)
> -   goto fail;
> +   goto unreference;
>
> ret = drm_gem_object_init(dev, obj, size);
> if (ret == 0) {
> @@ -664,7 +664,7 @@ static struct drm_gem_object *__etnaviv_gem_new(struct 
> drm_device *dev,
> return obj;
> }
>
> -fail:
> +unreference:
> drm_gem_object_unreference_unlocked(obj);
> return ERR_PTR(ret);
>  }
> --
> 2.9.2
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/vmwgfx: Delete an unnecessary check before the function call "vfree"

2016-07-22 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 22 Jul 2016 13:31:00 +0200

The vfree() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index 1a1a87c..dc5beff 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -3625,9 +3625,7 @@ static int vmw_resize_cmd_bounce(struct vmw_sw_context 
*sw_context,
   (sw_context->cmd_bounce_size >> 1));
}

-   if (sw_context->cmd_bounce != NULL)
-   vfree(sw_context->cmd_bounce);
-
+   vfree(sw_context->cmd_bounce);
sw_context->cmd_bounce = vmalloc(sw_context->cmd_bounce_size);

if (sw_context->cmd_bounce == NULL) {
-- 
2.9.2



[PATCH] drm/etnaviv: Improve readability in __etnaviv_gem_new

2016-07-22 Thread Sean Paul
Move things around a little in __etnaviv_gem_new() to make it
more readable.

Reported-by: Markus Elfring 
Reported-by: walter harms 
Signed-off-by: Sean Paul 
---
 drivers/gpu/drm/etnaviv/etnaviv_gem.c | 25 +++--
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c 
b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
index df9bcba..7d13628 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
@@ -640,6 +640,7 @@ static struct drm_gem_object *__etnaviv_gem_new(struct 
drm_device *dev,
u32 size, u32 flags)
 {
struct drm_gem_object *obj = NULL;
+   struct address_space *mapping;
int ret;

size = PAGE_ALIGN(size);
@@ -650,23 +651,19 @@ static struct drm_gem_object *__etnaviv_gem_new(struct 
drm_device *dev,
goto fail;

ret = drm_gem_object_init(dev, obj, size);
-   if (ret == 0) {
-   struct address_space *mapping;
-
-   /*
-* Our buffers are kept pinned, so allocating them
-* from the MOVABLE zone is a really bad idea, and
-* conflicts with CMA.  See coments above new_inode()
-* why this is required _and_ expected if you're
-* going to pin these pages.
-*/
-   mapping = file_inode(obj->filp)->i_mapping;
-   mapping_set_gfp_mask(mapping, GFP_HIGHUSER);
-   }
-
if (ret)
goto fail;

+   /*
+* Our buffers are kept pinned, so allocating them
+* from the MOVABLE zone is a really bad idea, and
+* conflicts with CMA.  See coments above new_inode()
+* why this is required _and_ expected if you're
+* going to pin these pages.
+*/
+   mapping = file_inode(obj->filp)->i_mapping;
+   mapping_set_gfp_mask(mapping, GFP_HIGHUSER);
+
return obj;

 fail:
-- 
2.8.0.rc3.226.g39d4020



[PATCH libdrm 3/6] libdrm: Fix drm.h include path in virtgpu drm header file

2016-07-22 Thread Andreas Boll
2016-07-21 18:10 GMT+02:00 Emil Velikov :
> On 21 July 2016 at 14:12, Andreas Boll  wrote:
>> A similar change was made to mesa's copy of virtgpu_drm.h by the
>> following commit:
>>
> Please sync this using the approach shown in commit
> c745e541a9d8dfd3fb5e1ac57297e58d34d9328f.
>
> Namely:
>  - Use make header_install and copy the resulting file over.
>  - Mention the tree/branch and sha where it is based on.
>
> Adding details about the kernel changes are a bonus, but not necessary
> unless they remove/change existing code.
>
> Thanks
> Emil

I've replaced this patch with a new one that syncs from the kernel header.

Thanks,
Andreas


[PATCH libdrm 2/6] automake: Pick up all Android files for distribution

2016-07-22 Thread Andreas Boll
2016-07-21 18:14 GMT+02:00 Emil Velikov :
> On 21 July 2016 at 14:12, Andreas Boll  wrote:
>> Currently only some Android Makefiles are included in the release tarball.
>> Add all remaining files to be more consistent.
>>
> Since Android folk never fully bought the idea of using actual
> releases/release tarballs, one could just drop all the existing
> Android.mk instances from the Makefiles.

Ok I've just sent a new patch to drop all Android files from the
release tarball.

>
> If the Debian build system warnings about files not included in the
> tarball go ahead with this patch.
>

No problem, I'll just extend the ignore rule like I did for mesa.

Thanks,
Andreas


[PATCH libdrm] virtgpu: Update kernel header

2016-07-22 Thread Andreas Boll
Generated using make headers_install.

This brings the C++ guard, proper include path for drm.h and the
switching to kernel types for fixed-with integers.

Generated from drm-next commit c11dea5b0290984fa48111957ba3fdc5b3bdae5a

Suggested-by: Emil Velikov 
Signed-off-by: Andreas Boll 
---
 include/drm/virtgpu_drm.h | 109 --
 1 file changed, 58 insertions(+), 51 deletions(-)

diff --git a/include/drm/virtgpu_drm.h b/include/drm/virtgpu_drm.h
index abf11c5..91a31ff 100644
--- a/include/drm/virtgpu_drm.h
+++ b/include/drm/virtgpu_drm.h
@@ -24,13 +24,16 @@
 #ifndef VIRTGPU_DRM_H
 #define VIRTGPU_DRM_H

-#include 
-#include "drm/drm.h"
+#include "drm.h"
+
+#if defined(__cplusplus)
+extern "C" {
+#endif

 /* Please note that modifications to all structs defined here are
  * subject to backwards-compatibility constraints.
  *
- * Do not use pointers, use uint64_t instead for 32 bit / 64 bit user/kernel
+ * Do not use pointers, use __u64 instead for 32 bit / 64 bit user/kernel
  * compatibility Keep fields aligned to their size
  */

@@ -45,88 +48,88 @@
 #define DRM_VIRTGPU_GET_CAPS  0x09

 struct drm_virtgpu_map {
-   uint64_t offset; /* use for mmap system call */
-   uint32_t handle;
-   uint32_t pad;
+   __u64 offset; /* use for mmap system call */
+   __u32 handle;
+   __u32 pad;
 };

 struct drm_virtgpu_execbuffer {
-   uint32_t flags; /* for future use */
-   uint32_t size;
-   uint64_t command; /* void* */
-   uint64_t bo_handles;
-   uint32_t num_bo_handles;
-   uint32_t pad;
+   __u32   flags;  /* for future use */
+   __u32 size;
+   __u64 command; /* void* */
+   __u64 bo_handles;
+   __u32 num_bo_handles;
+   __u32 pad;
 };

 #define VIRTGPU_PARAM_3D_FEATURES 1 /* do we have 3D features in the hw */

 struct drm_virtgpu_getparam {
-   uint64_t param;
-   uint64_t value;
+   __u64 param;
+   __u64 value;
 };

 /* NO_BO flags? NO resource flag? */
 /* resource flag for y_0_top */
 struct drm_virtgpu_resource_create {
-   uint32_t target;
-   uint32_t format;
-   uint32_t bind;
-   uint32_t width;
-   uint32_t height;
-   uint32_t depth;
-   uint32_t array_size;
-   uint32_t last_level;
-   uint32_t nr_samples;
-   uint32_t flags;
-   uint32_t bo_handle; /* if this is set - recreate a new resource 
attached to this bo ? */
-   uint32_t res_handle;  /* returned by kernel */
-   uint32_t size;/* validate transfer in the host */
-   uint32_t stride;  /* validate transfer in the host */
+   __u32 target;
+   __u32 format;
+   __u32 bind;
+   __u32 width;
+   __u32 height;
+   __u32 depth;
+   __u32 array_size;
+   __u32 last_level;
+   __u32 nr_samples;
+   __u32 flags;
+   __u32 bo_handle; /* if this is set - recreate a new resource attached 
to this bo ? */
+   __u32 res_handle;  /* returned by kernel */
+   __u32 size;/* validate transfer in the host */
+   __u32 stride;  /* validate transfer in the host */
 };

 struct drm_virtgpu_resource_info {
-   uint32_t bo_handle;
-   uint32_t res_handle;
-   uint32_t size;
-   uint32_t stride;
+   __u32 bo_handle;
+   __u32 res_handle;
+   __u32 size;
+   __u32 stride;
 };

 struct drm_virtgpu_3d_box {
-   uint32_t x;
-   uint32_t y;
-   uint32_t z;
-   uint32_t w;
-   uint32_t h;
-   uint32_t d;
+   __u32 x;
+   __u32 y;
+   __u32 z;
+   __u32 w;
+   __u32 h;
+   __u32 d;
 };

 struct drm_virtgpu_3d_transfer_to_host {
-   uint32_t bo_handle;
+   __u32 bo_handle;
struct drm_virtgpu_3d_box box;
-   uint32_t level;
-   uint32_t offset;
+   __u32 level;
+   __u32 offset;
 };

 struct drm_virtgpu_3d_transfer_from_host {
-   uint32_t bo_handle;
+   __u32 bo_handle;
struct drm_virtgpu_3d_box box;
-   uint32_t level;
-   uint32_t offset;
+   __u32 level;
+   __u32 offset;
 };

 #define VIRTGPU_WAIT_NOWAIT 1 /* like it */
 struct drm_virtgpu_3d_wait {
-   uint32_t handle; /* 0 is an invalid handle */
-   uint32_t flags;
+   __u32 handle; /* 0 is an invalid handle */
+   __u32 flags;
 };

 struct drm_virtgpu_get_caps {
-   uint32_t cap_set_id;
-   uint32_t cap_set_ver;
-   uint64_t addr;
-   uint32_t size;
-   uint32_t pad;
+   __u32 cap_set_id;
+   __u32 cap_set_ver;
+   __u64 addr;
+   __u32 size;
+   __u32 pad;
 };

 #define DRM_IOCTL_VIRTGPU_MAP \
@@ -164,4 +167,8 @@ struct drm_virtgpu_get_caps {
DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_GET_CAPS, \
struct drm_virtgpu_get_caps)

+#if defined(__cplusplus)
+}
+#endif
+
 #endif
-- 
2.8.1



[PATCH libdrm] automake: Don't include Android Makefiles in the release tarball

2016-07-22 Thread Andreas Boll
Currently only some Android Makefiles are included in the release tarball.
To be more consistent one could either add the remaining files or don't
ship Android Makefiles altogether.

According to Emil the Android folk doesn't use our release tarballs.
Thus it makes sense to remove those files from distribution which also
means less work for maintenance in the future.

Suggested-by: Emil Velikov 
Signed-off-by: Andreas Boll 
---
 Makefile.am| 2 --
 freedreno/Makefile.am  | 2 +-
 intel/Makefile.am  | 1 -
 libkms/Makefile.am | 2 +-
 nouveau/Makefile.am| 2 +-
 radeon/Makefile.am | 2 +-
 tests/modetest/Makefile.am | 2 --
 7 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index feecba7..2ceb352 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -120,8 +120,6 @@ libdrm_la_SOURCES = $(LIBDRM_FILES)
 libdrmincludedir = ${includedir}
 libdrminclude_HEADERS = $(LIBDRM_H_FILES)

-EXTRA_DIST = Android.mk
-
 klibdrmincludedir = ${includedir}/libdrm
 klibdrminclude_HEADERS = $(LIBDRM_INCLUDE_H_FILES)

diff --git a/freedreno/Makefile.am b/freedreno/Makefile.am
index 9b7ec7d..0771d14 100644
--- a/freedreno/Makefile.am
+++ b/freedreno/Makefile.am
@@ -27,4 +27,4 @@ pkgconfigdir = @pkgconfigdir@
 pkgconfig_DATA = libdrm_freedreno.pc

 TESTS = freedreno-symbol-check
-EXTRA_DIST = Android.mk $(TESTS)
+EXTRA_DIST = $(TESTS)
diff --git a/intel/Makefile.am b/intel/Makefile.am
index d004568..c52e8c0 100644
--- a/intel/Makefile.am
+++ b/intel/Makefile.am
@@ -66,7 +66,6 @@ EXTRA_DIST = \
$(BATCHES:.batch=.batch-ref.txt) \
$(BATCHES:.batch=.batch-ref.txt) \
tests/test-batch.sh \
-   Android.mk \
$(TESTS)

 test_decode_LDADD = libdrm_intel.la ../libdrm.la
diff --git a/libkms/Makefile.am b/libkms/Makefile.am
index 6c0ab7a..7c1debe 100644
--- a/libkms/Makefile.am
+++ b/libkms/Makefile.am
@@ -44,4 +44,4 @@ pkgconfigdir = @pkgconfigdir@
 pkgconfig_DATA = libkms.pc

 TESTS = kms-symbol-check
-EXTRA_DIST = Android.mk $(TESTS)
+EXTRA_DIST = $(TESTS)
diff --git a/nouveau/Makefile.am b/nouveau/Makefile.am
index 76cdeca..344a844 100644
--- a/nouveau/Makefile.am
+++ b/nouveau/Makefile.am
@@ -30,4 +30,4 @@ pkgconfigdir = @pkgconfigdir@
 pkgconfig_DATA = libdrm_nouveau.pc

 TESTS = nouveau-symbol-check
-EXTRA_DIST = Android.mk $(TESTS)
+EXTRA_DIST = $(TESTS)
diff --git a/radeon/Makefile.am b/radeon/Makefile.am
index 31f19e5..e241531 100644
--- a/radeon/Makefile.am
+++ b/radeon/Makefile.am
@@ -44,4 +44,4 @@ pkgconfigdir = @pkgconfigdir@
 pkgconfig_DATA = libdrm_radeon.pc

 TESTS = radeon-symbol-check
-EXTRA_DIST = Android.mk $(LIBDRM_RADEON_BOF_FILES) $(TESTS)
+EXTRA_DIST = $(LIBDRM_RADEON_BOF_FILES) $(TESTS)
diff --git a/tests/modetest/Makefile.am b/tests/modetest/Makefile.am
index 25ce372..9686ccb 100644
--- a/tests/modetest/Makefile.am
+++ b/tests/modetest/Makefile.am
@@ -22,5 +22,3 @@ modetest_LDADD = \
$(top_builddir)/tests/util/libutil.la \
$(CAIRO_LIBS) \
-lpthread
-
-EXTRA_DIST = Android.mk
-- 
2.8.1



[PATCH] apple-gmux: Sphinxify docs

2016-07-22 Thread Darren Hart
On Tue, Jul 12, 2016 at 03:11:45PM +0200, Daniel Vetter wrote:
> On Fri, Jul 08, 2016 at 07:49:32AM +0200, Lukas Wunner wrote:
> > On Wed, Jul 06, 2016 at 01:40:25PM -0700, Darren Hart wrote:
> > > On Mon, Jul 04, 2016 at 12:40:35PM +0200, Lukas Wunner wrote:
> > > > Convert asciidoc-formatted docs to rst in accordance with Jonathan's and
> > > > Jani's effort to use sphinx for kernel-doc rendering in 4.8.
> > > 
> > > Somebody help me out here. How do I verify this works and using sphinx?
> > > to build the docs?
> > 
> > (1) git remote add l1k https://github.com/l1k/linux.git
> > git fetch l1k
> > git checkout l1k/sphinx-docs
> > (Alternatively: git cherry-pick v4.7-rc6..l1k/sphinx-docs )
> > 
> > (2) sudo apt-get install python-sphinx python-sphinx-rtd-theme
> > 
> > (3) make xmldocs
> > make htmldocs
> > 
> > (4) open Documentation/output/html/index.html
> > click on "VGA Switcheroo", then click on "Handlers" in the
> > navigation pane on the left
> > 
> > The apple-gmux docs are currently asciidoc-formatted. Support for
> > markdown/asciidoc in kerneldoc was an Intel-sponsored effort last year
> > led by Daniel, but never got upstreamed.
> > 
> > After some deliberation the decision was made to use rst instead.
> > Support for it is in docs-next, i.e. will be in 4.8.
> > 
> > Jani has converted the gpu docs to rst and deleted the gpu.tmpl,
> > this is on the drm-intel/for-linux-next branch but not yet in drm-next.
> > Jani and Daniel are both on vacation. Daniel has indicated that he
> > considers sending another drm-intel-next pull when he returns next week,
> > then the rst-formatted gpu docs would land in drm-next:
> > https://lists.freedesktop.org/archives/intel-gfx/2016-June/099114.html
> > 
> > 
> > > Should I be merging this directly, or is it dependent on something Jon
> > > is working on and therefore to be merged by him?
> > 
> > It is not dependent on someone else. You can either merge it directly
> > through your tree or alternatively ack it and have it merged through
> > drm-intel trees by Daniel (+ cc:) next week.
> > 
> > 
> > Unfortunately there is currently no branch which contains all the rst
> > patches in docs-next *and* the rst-formatted gpu docs in drm-intel.
> > (Some patches in docs-next are missing from drm-intel/for-linux-next.)
> > That's why I pushed the above-mentioned branch to my GitHub repo,
> > it contains everything needed:
> > https://github.com/l1k/linux/commits/sphinx-docs
> 
> Probably best to pull this in through drm-misc, which contains docs-next
> plus the skeleton conversion of the drm docs over to sphinx/rst. Darren,
> ack on that?

Acked-by: Darren Hart 

I've dropped this from my testing branch (I never pushed it to my next branch)
and will leave it to you to pull in.

> 
> Oh and if you want to take a peek at the pretty docs this gives us:
> 
> https://01.org/linuxgraphics/gfx-docs/drm/

Very nice.

> 
> This is just the drm part, but if you pull in docs-next there should be
> even more. Media/tv might also be ready for 4.8.
> -Daniel
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
> 

-- 
Darren Hart
Intel Open Source Technology Center


[PATCH] drm/imx: imx-ldb: do not try to dereference crtc->state->state in encoder mode_set

2016-07-22 Thread Philipp Zabel
Am Freitag, den 22.07.2016, 11:35 +0200 schrieb Daniel Vetter:
[...]
> Proper fix would be to roll out atomic_ versions of all teh encoder
> callbacks where we additionally pass both the crtc state and the connector
> state. Then there's no need for walking connector lists like that. And in
> the atomic helpers those two states are always readily available, and
> passing them down to callbacks is also what we will do in i915. I'd be
> happy to merge such a patch.

Thanks, that is a good idea. Which encoder callbacks besides mode_set ->
atomic_mode_set are you thinking of, though? enable/disable?

regards
Philipp



[PATCH] GPU-DRM: Delete an unnecessary check before drm_property_unreference_blob()

2016-07-22 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 22 Jul 2016 12:48:12 +0200

The drm_property_unreference_blob() function tests whether its argument
is NULL and then returns immediately.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c 
b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index 24aa3ba..07541d0 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -112,9 +112,7 @@ static void mtk_drm_crtc_reset(struct drm_crtc *crtc)
struct mtk_crtc_state *state;

if (crtc->state) {
-   if (crtc->state->mode_blob)
-   drm_property_unreference_blob(crtc->state->mode_blob);
-
+   drm_property_unreference_blob(crtc->state->mode_blob);
state = to_mtk_crtc_state(crtc->state);
memset(state, 0, sizeof(*state));
} else {
-- 
2.9.2



[PATCH v3 3/7] clk: rockchip: rk3399: add SCLK_DDRCLK ID for ddrc

2016-07-22 Thread Heiko Stübner
Am Freitag, 22. Juli 2016, 17:07:16 schrieb Lin Huang:
> Signed-off-by: Lin Huang 
> ---
> Changes in v3:
> -None
> 
> Changes in v2:
> - None
> Changes in v1:
> - None
> 
>  include/dt-bindings/clock/rk3399-cru.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/dt-bindings/clock/rk3399-cru.h
> b/include/dt-bindings/clock/rk3399-cru.h index 50a44cf..8a0f0442 100644
> --- a/include/dt-bindings/clock/rk3399-cru.h
> +++ b/include/dt-bindings/clock/rk3399-cru.h
> @@ -131,6 +131,7 @@
>  #define SCLK_DPHY_RX0_CFG165
>  #define SCLK_RMII_SRC166
>  #define SCLK_PCIEPHY_REF100M 167
> +#define SCLK_DDRCLK  168

nit: SCLK_DDR (i.e. without the CLK at the end)?

>  #define DCLK_VOP0180
>  #define DCLK_VOP1181



[PATCH 2/2] drm/doc: Fix more kerneldoc/sphinx warnings

2016-07-22 Thread Mauro Carvalho Chehab
Em Wed, 20 Jul 2016 20:35:09 +0200
Markus Heiser  escreveu:

> Am 20.07.2016 um 14:20 schrieb Mauro Carvalho Chehab  s-opensource.com>:
> 
> > Em Tue, 19 Jul 2016 14:36:50 +0200
> > Daniel Vetter  escreveu:
> >   
> >> On Tue, Jul 19, 2016 at 01:42:55PM +0200, Daniel Vetter wrote:  
> >>> These are the leftovers I could only track down using keep_warnings =
> >>> True. For some of them we might want to update our style guide on how
> >>> to reference structures and constants, not sure ...
> >>> 
> >>> Cc: Markus Heiser 
> >>> Cc: Jonathan Corbet 
> >>> Cc: linux-doc at vger.kernel.org
> >>> Signed-off-by: Daniel Vetter 
> >> 
> >> Aside: With this and the latest docs-next branch from Jon it's possible to
> >> compile test doc changes (e.g. with git rebase -x) using:
> >> 
> >> $ make IGNORE_DOCBOOKS=1 SPHINXOPTS=-W htmldocs  
> > 
> > Unfortunately, we'll not get rid of Sphinx warnings any time soon.
> > 
> > The Sphinx function parser is really broken, even on version 1.4.5.
> > 
> > Every time Sphinx finds a typedef argument or return value, like here:
> > 
> > ssize_t dvb_ringbuffer_pkt_read_user (struct dvb_ringbuffer * rbuf, 
> > size_t idx, int offset, u8 __user * buf, size_t len);
> > 
> > It produces a very ugly noisy warning:
> > 
> > ./drivers/media/dvb-core/dvb_ringbuffer.h:149: WARNING: Error when parsing 
> > function declaration.
> > If the function has no return type:
> >  Error in declarator or parameters and qualifiers
> >  Invalid definition: Expecting "(" in parameters_and_qualifiers. [error at 
> > 8]
> >ssize_t dvb_ringbuffer_pkt_read_user (struct dvb_ringbuffer * rbuf, 
> > size_t idx, int offset, u8 __user * buf, size_t len)
> >^
> > If the function has a return type:
> >  Error in declarator or parameters and qualifiers
> >  If pointer to member declarator:
> >Invalid definition: Expected '::' in pointer to member (function). 
> > [error at 37]
> >  ssize_t dvb_ringbuffer_pkt_read_user (struct dvb_ringbuffer * rbuf, 
> > size_t idx, int offset, u8 __user * buf, size_t len)
> >  -^
> >  If declarator-id:
> >Invalid definition: Expecting "," or ")" in parameters_and_qualifiers, 
> > got "*". [error at 102]
> >  ssize_t dvb_ringbuffer_pkt_read_user (struct dvb_ringbuffer * rbuf, 
> > size_t idx, int offset, u8 __user * buf, size_t len)
> >  
> > --^
> >   
> 
> Aaargh ... it seems you are right. 

Just sent a fix for the above:

https://git.linuxtv.org/mchehab/experimental.git/commit/?h=docs-next=263bbae9c1bf6ea7c14dad8c29f9b3148b2b5de7

I was able to fix the other two typedef warnings with:

https://git.linuxtv.org/mchehab/experimental.git/commit/?h=docs-next=b32909983ab03e03504bb44d5c66f44b9d57adc3

Basically, I had to:

1) Make kernel-doc ignore __user;
2) typedef the function argument for v4l2_ctrl_add_handler();
3) not let kernel-doc generate :cpp:function: for function typedefs.

With DocBook, we used kernel-doc to produce a page for typedef
functions. Now, such capability got lost. Not sure if/how
Sphinx would support it.

Thanks,
Mauro


[PATCH] drm/imx: imx-ldb: store LVDS bus configuration in ldb channel

2016-07-22 Thread Ying Liu
Hi Philipp,

This patch's headline doesn't exactly reflect what the patch actually
does - retrieve lvds bus format from imx_crtc_state during encoder
mode_set.

On Thu, Jul 21, 2016 at 9:25 PM, Philipp Zabel  
wrote:
> The code in imx_ldb_encoder_mode_set crashes trying to access the
> crtc->state->state drm_atomic_state pointer if that was previously
> cleared by drm_atomic_helper_swap_state.

Nit: Providing a crash log might be good.

> Instead of trying to walk all connectors during encoder mode_set to
> determine the LVDS bus format from panel or external bridge connector
> display info, store it in imx_crtc_state during encoder atomic_check,
> where it is already known, and just retrieve it from imx_crtc_state
> during encoder mode_set.
>
> Fixes: 49f98bc4d44a4 ("drm/imx: store internal bus configuration in crtc 
> state")
> Signed-off-by: Philipp Zabel 
> ---
>  drivers/gpu/drm/imx/imx-drm.h |  1 +
>  drivers/gpu/drm/imx/imx-ldb.c | 22 +-
>  2 files changed, 6 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/gpu/drm/imx/imx-drm.h b/drivers/gpu/drm/imx/imx-drm.h
> index bdaa381..5e2f68a 100644
> --- a/drivers/gpu/drm/imx/imx-drm.h
> +++ b/drivers/gpu/drm/imx/imx-drm.h
> @@ -19,6 +19,7 @@ struct imx_crtc_state {
> u32 bus_flags;
> int di_hsync_pin;
> int di_vsync_pin;
> +   u32 ldb_bus_format;

Pretty much a hack here, I think.
Comparing to the other members of imx_crtc_state,
ldb_bus_format is less likely to be a member, since
crtc just doesn't like to know the LVDS bus format...

>  };
>
>  static inline struct imx_crtc_state *to_imx_crtc_state(struct drm_crtc_state 
> *s)
> diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c
> index dc2b420..871dff9 100644
> --- a/drivers/gpu/drm/imx/imx-ldb.c
> +++ b/drivers/gpu/drm/imx/imx-ldb.c
> @@ -262,7 +262,10 @@ static void imx_ldb_encoder_mode_set(struct drm_encoder 
> *encoder,
> unsigned long serial_clk;
> unsigned long di_clk = mode->clock * 1000;
> int mux = drm_of_encoder_active_port_id(imx_ldb_ch->child, encoder);
> -   u32 bus_format = imx_ldb_ch->bus_format;
> +   struct drm_crtc_state *crtc_state = encoder->crtc->state;
> +   struct imx_crtc_state *imx_crtc_state = to_imx_crtc_state(crtc_state);
> +   u32 bus_format = imx_ldb_ch->bus_format ?:
> +imx_crtc_state->ldb_bus_format;

Instead of introducing imx_crtc_state->ldb_bus_format to get the
lvds bus format, you may get the connector via
crtc_state->connector_mask(verify connector->encoder to be
the encoder we are talking about). connector_mask is maintained
well by the atomic core I assume.

Regards,
Liu Ying

>
> if (mode->clock > 17) {
> dev_warn(ldb->dev,
> @@ -297,22 +300,6 @@ static void imx_ldb_encoder_mode_set(struct drm_encoder 
> *encoder,
> ldb->ldb_ctrl &= ~LDB_DI1_VS_POL_ACT_LOW;
> }
>
> -   if (!bus_format) {
> -   struct drm_connector_state *conn_state;
> -   struct drm_connector *connector;
> -   int i;
> -
> -   for_each_connector_in_state(encoder->crtc->state->state,
> -   connector, conn_state, i) {
> -   struct drm_display_info *di = 
> >display_info;
> -
> -   if (conn_state->crtc == encoder->crtc &&
> -   di->num_bus_formats) {
> -   bus_format = di->bus_formats[0];
> -   break;
> -   }
> -   }
> -   }
> imx_ldb_ch_set_bus_format(imx_ldb_ch, bus_format);
>  }
>
> @@ -404,6 +391,7 @@ static int imx_ldb_encoder_atomic_check(struct 
> drm_encoder *encoder,
>
> imx_crtc_state->di_hsync_pin = 2;
> imx_crtc_state->di_vsync_pin = 3;
> +   imx_crtc_state->ldb_bus_format = bus_format;
>
> return 0;
>  }
> --
> 2.8.1
>


[PATCH v3 1/7] firmware: rockchip: sip: Add rockchip SIP runtime service

2016-07-22 Thread Heiko Stübner
Hi,

Am Freitag, 22. Juli 2016, 17:07:14 schrieb Lin Huang:
> From: Shengfei xu 
> 
> This patch adds support for the SiP interface, we can pass dram
> paramtert to bl31, and control ddr frequency scaling in bl31.
> 
> Signed-off-by: Shengfei xu 
> Signed-off-by: Lin Huang 

[...]

> +++ b/drivers/firmware/rockchip_sip.c
> @@ -0,0 +1,64 @@
> +/*
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * 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.
> + *
> + * Copyright (C) 2016 ARM Limited
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include "rockchip_sip.h"
> +
> +typedef unsigned long (psci_fn)(unsigned long, unsigned long,
> + unsigned long, unsigned long);
> +asmlinkage psci_fn __invoke_psci_fn_smc;
> +
> +#define CONFIG_DRAM_INIT 0x00
> +#define CONFIG_DRAM_SET_RATE 0x01
> +#define CONFIG_DRAM_ROUND_RATE   0x02
> +#define CONFIG_DRAM_SET_AT_SR0x03
> +#define CONFIG_DRAM_GET_BW   0x04
> +#define CONFIG_DRAM_GET_RATE 0x05
> +#define CONFIG_DRAM_CLR_IRQ  0x06
> +#define CONFIG_DRAM_SET_PARAM   0x07
> +
> +uint64_t sip_smc_ddr_init(void)

if I'm reading the ATF writers guide [0] correctly, the SiP calls are soc-
specific things:
"For example, two SoC providers can use the same Function ID within the SiP
Service calls OEN range to mean different things - as these calls should be
specific to the SoC. "

So I guess the function calls, as well as the constants should have a prefix.
ROCKCHIP_SIP_DDR_FREQ, rockchip_sip_smc_set_ddr_param(), etc.

Looking at Zynq in the ATF [1] seems to strengthen that theory with the 
similar constants having the ZYNQMP_ prefix.

I guess it doesn't matter to much on the ATF side, as you build a soc-specific 
image, but on the kernel-side I think it should unambiguos, especially as 
functions and constants are part of a public header.

I think the code itself looks fine though :-)


Heiko

[0] 
https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/rt-svc-writers-guide.md
[1] 
https://github.com/ARM-software/arm-trusted-firmware/blob/master/plat/xilinx/zynqmp/sip_svc_setup.c



> +{
> + return __invoke_psci_fn_smc(SIP_DDR_FREQ, 0,
> + 0, CONFIG_DRAM_INIT);
> +}
> +
> +uint64_t sip_smc_set_ddr_param(uint64_t param)
> +{
> + return __invoke_psci_fn_smc(SIP_DDR_FREQ, param,
> + 0, CONFIG_DRAM_SET_PARAM);
> +}
> +
> +uint64_t sip_smc_set_ddr_rate(uint64_t rate)
> +{
> + return __invoke_psci_fn_smc(SIP_DDR_FREQ, rate, 0,
> + CONFIG_DRAM_SET_RATE);
> +}
> +
> +uint64_t sip_smc_get_ddr_rate(void)
> +{
> + return __invoke_psci_fn_smc(SIP_DDR_FREQ, 0, 0, CONFIG_DRAM_GET_RATE);
> +}
> +
> +uint64_t sip_smc_clr_ddr_irq(void)
> +{
> + return __invoke_psci_fn_smc(SIP_DDR_FREQ, 0, 0, CONFIG_DRAM_CLR_IRQ);
> +}
> +
> +uint64_t sip_smc_get_call_count(void)
> +{
> + return __invoke_psci_fn_smc(SIP_SVC_CALL_COUNT, 0, 0, 0);
> +}
> diff --git a/drivers/firmware/rockchip_sip.h
> b/drivers/firmware/rockchip_sip.h new file mode 100644
> index 000..6487734
> --- /dev/null
> +++ b/drivers/firmware/rockchip_sip.h
> @@ -0,0 +1,59 @@
> +/* Copyright (c) 2010-2015, The Linux Foundation. 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 version 2 and
> + * only version 2 as published by the Free Software Foundation.
> + *
> + * 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.
> + */
> +#ifndef __SIP_INT_H
> +#define __SIP_INT_H
> +
> +/* SMC function IDs for SiP Service queries */
> +#define SIP_SVC_CALL_COUNT   0x8200ff00
> +#define SIP_SVC_UID  0x8200ff01
> +#define SIP_SVC_VERSION  0x8200ff03
> +#define SIP_DDR_FREQ 0xC208
> +
> +#if IS_ENABLED(CONFIG_ROCKCHIP_SIP)
> +uint64_t sip_smc_set_ddr_rate(uint64_t rate);
> +uint64_t sip_smc_get_ddr_rate(void);
> +uint64_t sip_smc_clr_ddr_irq(void);
> +uint64_t sip_smc_get_call_count(void);
> +uint64_t sip_smc_ddr_init(void);
> +uint64_t sip_smc_set_ddr_param(uint64_t param);
> +#else
> +static inline uint64_t sip_smc_set_ddr_rate(uint64_t rate)
> +{
> + return 0;
> +}
> +
> +static inline uint64_t sip_smc_get_ddr_rate(void)
> +{
> + return 0;
> +}
> +
> +static inline uint64_t sip_smc_clr_ddr_irq(void)
> +{
> + return 0;

[PATCH] drm/imx: imx-ldb: do not try to dereference crtc->state->state in encoder mode_set

2016-07-22 Thread Daniel Vetter
On Fri, Jul 22, 2016 at 10:59:51AM +0200, Philipp Zabel wrote:
> The code in imx_ldb_encoder_mode_set crashes with a NULL pointer
> dereference trying to access crtc->state->state, which was previously
> cleared by drm_atomic_helper_swap_state:
> 
> Unable to handle kernel NULL pointer dereference at virtual address 
> 0010
> pgd = ae08c000
> [0010] *pgd=3e00e831, *pte=, *ppte=
> Internal error: Oops: 17 [#1] PREEMPT SMP ARM
> Modules linked in:
> CPU: 1 PID: 102 Comm: kmsfb-manage Not tainted 4.7.0-rc5+ #232
> Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
> task: ae058c40 ti: ae04e000 task.ti: ae04e000
> PC is at imx_ldb_encoder_mode_set+0x138/0x2f8
> LR is at 0xae881818
> pc : [<8051a8c8>]lr : []psr: 600f0013
> sp : ae04fc70  ip : ae04fbb0  fp : ae04fcbc
> r10: ae8ea018  r9 :   r8 : ae246418
> r7 : ae8ea010  r6 : ae8ea308  r5 :   r4 : 
> r3 :   r2 :   r1 : 0110  r0 : 
> Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
> Control: 10c5387d  Table: 3e08c04a  DAC: 0051
> Process kmsfb-manage (pid: 102, stack limit = 0xae04e210)
> Stack: (0xae04fc70 to 0xae05)
> fc60: 043ce660 0001 009e 
> 043ce660
> fc80: 0002   af75cf50 1009 ae23f440 0001 
> ae246418
> fca0: 8155a210 ae8ea308 8093c364 ae2464e0 ae04fcec ae04fcc0 804ef350 
> 8051a79c
> fcc0: 0004 0004 ae23f440 af3f9000 ae881818 8155a210 af1af200 
> ae8ea020
> fce0: ae04fd1c ae04fcf0 80519124 804ef060 ae04fd34   
> 
> fd00: ae881818 ae23f440 80d4ec8c  ae04fd34 ae04fd20 804f00b4 
> 80518fac
> fd20: ae23f440  ae04fd54 ae04fd38 804f2190 804f0074 ae23f440 
> af3f9000
> fd40: ae04fdd4 ae881818 ae04fd6c ae04fd58 80516390 804f20f4 ae23f440 
> 
> fd60: ae04fd8c ae04fd70 804f26f4 80516348 ae23a000 ae881818 0001 
> af3f9000
> fd80: ae04fdac ae04fd90 80502c58 804f2678 ae04fe50 ae23f400 0001 
> af3f9000
> fda0: ae04fe1c ae04fdb0 80507a1c 80502bf8 ae23a000 ae058c40 af1af200 
> ae23f400
> fdc0: ae23a000 af3f9000 ae881818 ae23a00c 80176c7c ae23a000 ae881818 
> af1af200
> fde0:   ae23f400 0001 ae04fe1c 0051 ae04fe50 
> 8155a210
> fe00: 80932060 c06864a2 af3f9000 ae246200 ae04fefc ae04fe20 804f9718 
> 805074e8
> fe20: ae04feac ae04fe30 80177360 8017631c 805074dc 0068 0068 
> 0062
> fe40: 0068 00a2 ae04fe50 7ef29688 7ef29c40  0001 
> 0018
> fe60: 0026    0001 000115bc 05010500 
> 05a0059f
> fe80: 0320 03360321 0337 003c  0040 30383231 
> 30303878
> fea0:       4000 
> aea6a140
> fec0:  80d77b71  80283110 600f0013 7ef29688 af342bb0 
> ae250b40
> fee0: 80275440 0003 ae04e000  ae04ff7c ae04ff00 80274ac8 
> 804f957c
> ff00: 80283128 80179030   80282fd8 ae1e 003d 
> aea6a1d0
> ff20: 0002 0003 4000 007f8c60 c06864a2 7ef29688 ae04e000 
> 
> ff40: ae04ff6c ae04ff50 80283260 80282fe4 00017050 ae250b41 0003 
> ae250b40
> ff60: c06864a2 7ef29688 ae04e000  ae04ffa4 ae04ff80 80275440 
> 80274a20
> ff80: 00017050 0001 007f8c60 0036 801088a4 ae04e000  
> ae04ffa8
> ffa0: 80108700 80275408 00017050 0001 0003 c06864a2 7ef29688 
> 000115bc
> ffc0: 00017050 0001 007f8c60 0036 0003  0026 
> 0018
> ffe0: 00016f28 7ef29684 b7d9 76e4a1e6 400f0030 0003 3ff7e861 
> 3ff7ec61
> Backtrace:
> [<8051a790>] (imx_ldb_encoder_mode_set) from [<804ef350>] 
> (drm_atomic_helper_commit_modeset_disables+0x2fc/0x3f0)
>  r10:ae2464e0 r9:8093c364 r8:ae8ea308 r7:8155a210 r6:ae246418 r5:0001
>  r4:ae23f440
> [<804ef054>] (drm_atomic_helper_commit_modeset_disables) from 
> [<80519124>] (imx_drm_atomic_commit_tail+0x184/0x1e0)
>  r10:ae8ea020 r9:af1af200 r8:8155a210 r7:ae881818 r6:af3f9000 r5:ae23f440
>  r4:0004 r3:0004
> [<80518fa0>] (imx_drm_atomic_commit_tail) from [<804f00b4>] 
> (commit_tail+0x4c/0x68)
>  r6: r5:80d4ec8c r4:ae23f440
> [<804f0068>] (commit_tail) from [<804f2190>] 
> (drm_atomic_helper_commit+0xa8/0xd4)
>  r5: r4:ae23f440
> [<804f20e8>] (drm_atomic_helper_commit) from [<80516390>] 
> (drm_atomic_commit+0x54/0x74)
>  r7:ae881818 r6:ae04fdd4 r5:af3f9000 r4:ae23f440
> [<8051633c>] (drm_atomic_commit) from [<804f26f4>] 
> (drm_atomic_helper_set_config+0x88/0xac)
>  r5: r4:ae23f440
> [<804f266c>] (drm_atomic_helper_set_config) from [<80502c58>] 
> (drm_mode_set_config_internal+0x6c/0xf4)
>  r7:af3f9000 r6:0001 r5:ae881818 r4:ae23a000
> [<80502bec>] 

[PATCH] GPU-DRM-GMA500: Delete unnecessary checks before two function calls

2016-07-22 Thread Daniel Vetter
On Fri, Jul 22, 2016 at 10:45:30AM +0200, SF Markus Elfring wrote:
> From: Markus Elfring 
> Date: Fri, 22 Jul 2016 10:30:30 +0200
> 
> The functions pci_dev_put() and psb_intel_i2c_destroy() test whether
> their argument is NULL and then return immediately.
> Thus the tests around their calls are not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring 

Two more applied. And your threading still looks funny, all the patches
are in-reply to one I don't even have.
-Daniel

> ---
>  drivers/gpu/drm/gma500/cdv_intel_hdmi.c | 3 +--
>  drivers/gpu/drm/gma500/cdv_intel_lvds.c | 9 +++--
>  drivers/gpu/drm/gma500/psb_drv.c| 6 ++
>  drivers/gpu/drm/gma500/psb_intel_lvds.c | 9 +++--
>  4 files changed, 9 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/gpu/drm/gma500/cdv_intel_hdmi.c 
> b/drivers/gpu/drm/gma500/cdv_intel_hdmi.c
> index 28f9d90..563f193 100644
> --- a/drivers/gpu/drm/gma500/cdv_intel_hdmi.c
> +++ b/drivers/gpu/drm/gma500/cdv_intel_hdmi.c
> @@ -246,8 +246,7 @@ static void cdv_hdmi_destroy(struct drm_connector 
> *connector)
>  {
>   struct gma_encoder *gma_encoder = gma_attached_encoder(connector);
>  
> - if (gma_encoder->i2c_bus)
> - psb_intel_i2c_destroy(gma_encoder->i2c_bus);
> + psb_intel_i2c_destroy(gma_encoder->i2c_bus);
>   drm_connector_unregister(connector);
>   drm_connector_cleanup(connector);
>   kfree(connector);
> diff --git a/drivers/gpu/drm/gma500/cdv_intel_lvds.c 
> b/drivers/gpu/drm/gma500/cdv_intel_lvds.c
> index 813ef23..38dc890 100644
> --- a/drivers/gpu/drm/gma500/cdv_intel_lvds.c
> +++ b/drivers/gpu/drm/gma500/cdv_intel_lvds.c
> @@ -444,8 +444,7 @@ static void cdv_intel_lvds_destroy(struct drm_connector 
> *connector)
>  {
>   struct gma_encoder *gma_encoder = gma_attached_encoder(connector);
>  
> - if (gma_encoder->i2c_bus)
> - psb_intel_i2c_destroy(gma_encoder->i2c_bus);
> + psb_intel_i2c_destroy(gma_encoder->i2c_bus);
>   drm_connector_unregister(connector);
>   drm_connector_cleanup(connector);
>   kfree(connector);
> @@ -780,12 +779,10 @@ out:
>  failed_find:
>   mutex_unlock(>mode_config.mutex);
>   printk(KERN_ERR "Failed find\n");
> - if (gma_encoder->ddc_bus)
> - psb_intel_i2c_destroy(gma_encoder->ddc_bus);
> + psb_intel_i2c_destroy(gma_encoder->ddc_bus);
>  failed_ddc:
>   printk(KERN_ERR "Failed DDC\n");
> - if (gma_encoder->i2c_bus)
> - psb_intel_i2c_destroy(gma_encoder->i2c_bus);
> + psb_intel_i2c_destroy(gma_encoder->i2c_bus);
>  failed_blc_i2c:
>   printk(KERN_ERR "Failed BLC\n");
>   drm_encoder_cleanup(encoder);
> diff --git a/drivers/gpu/drm/gma500/psb_drv.c 
> b/drivers/gpu/drm/gma500/psb_drv.c
> index 82b8ce4..50eb944f 100644
> --- a/drivers/gpu/drm/gma500/psb_drv.c
> +++ b/drivers/gpu/drm/gma500/psb_drv.c
> @@ -210,10 +210,8 @@ static int psb_driver_unload(struct drm_device *dev)
>   iounmap(dev_priv->aux_reg);
>   dev_priv->aux_reg = NULL;
>   }
> - if (dev_priv->aux_pdev)
> - pci_dev_put(dev_priv->aux_pdev);
> - if (dev_priv->lpc_pdev)
> - pci_dev_put(dev_priv->lpc_pdev);
> + pci_dev_put(dev_priv->aux_pdev);
> + pci_dev_put(dev_priv->lpc_pdev);
>  
>   /* Destroy VBT data */
>   psb_intel_destroy_bios(dev);
> diff --git a/drivers/gpu/drm/gma500/psb_intel_lvds.c 
> b/drivers/gpu/drm/gma500/psb_intel_lvds.c
> index b1b9331..e55733c 100644
> --- a/drivers/gpu/drm/gma500/psb_intel_lvds.c
> +++ b/drivers/gpu/drm/gma500/psb_intel_lvds.c
> @@ -561,8 +561,7 @@ void psb_intel_lvds_destroy(struct drm_connector 
> *connector)
>   struct gma_encoder *gma_encoder = gma_attached_encoder(connector);
>   struct psb_intel_lvds_priv *lvds_priv = gma_encoder->dev_priv;
>  
> - if (lvds_priv->ddc_bus)
> - psb_intel_i2c_destroy(lvds_priv->ddc_bus);
> + psb_intel_i2c_destroy(lvds_priv->ddc_bus);
>   drm_connector_unregister(connector);
>   drm_connector_cleanup(connector);
>   kfree(connector);
> @@ -835,11 +834,9 @@ out:
>  
>  failed_find:
>   mutex_unlock(>mode_config.mutex);
> - if (lvds_priv->ddc_bus)
> - psb_intel_i2c_destroy(lvds_priv->ddc_bus);
> + psb_intel_i2c_destroy(lvds_priv->ddc_bus);
>  failed_ddc:
> - if (lvds_priv->i2c_bus)
> - psb_intel_i2c_destroy(lvds_priv->i2c_bus);
> + psb_intel_i2c_destroy(lvds_priv->i2c_bus);
>  failed_blc_i2c:
>   drm_encoder_cleanup(encoder);
>   drm_connector_cleanup(connector);
> -- 
> 2.9.2
> 

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


[PATCH] drm/mgag200: Delete an unnecessary check before drm_gem_object_unreference_unlocked()

2016-07-22 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 22 Jul 2016 11:20:27 +0200

The drm_gem_object_unreference_unlocked() function tests whether
its argument is NULL and then returns immediately.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/gpu/drm/mgag200/mgag200_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c 
b/drivers/gpu/drm/mgag200/mgag200_main.c
index 615cbb0..13798b3 100644
--- a/drivers/gpu/drm/mgag200/mgag200_main.c
+++ b/drivers/gpu/drm/mgag200/mgag200_main.c
@@ -17,8 +17,8 @@
 static void mga_user_framebuffer_destroy(struct drm_framebuffer *fb)
 {
struct mga_framebuffer *mga_fb = to_mga_framebuffer(fb);
-   if (mga_fb->obj)
-   drm_gem_object_unreference_unlocked(mga_fb->obj);
+
+   drm_gem_object_unreference_unlocked(mga_fb->obj);
drm_framebuffer_cleanup(fb);
kfree(fb);
 }
-- 
2.9.2



[PATCH] drm/bridge: ps8622: Delete an unnecessary check before backlight_device_unregister()

2016-07-22 Thread Sean Paul
On Fri, Jul 22, 2016 at 8:54 AM, SF Markus Elfring
 wrote:
> From: Markus Elfring 
> Date: Fri, 22 Jul 2016 14:45:51 +0200
>
> The backlight_device_unregister() function tests whether its argument
> is NULL and then returns immediately.
> Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring 

Applied to drm-misc

> ---
>  drivers/gpu/drm/bridge/parade-ps8622.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/parade-ps8622.c 
> b/drivers/gpu/drm/bridge/parade-ps8622.c
> index 5cd8dd7..583b8ce 100644
> --- a/drivers/gpu/drm/bridge/parade-ps8622.c
> +++ b/drivers/gpu/drm/bridge/parade-ps8622.c
> @@ -636,9 +636,7 @@ static int ps8622_remove(struct i2c_client *client)
>  {
> struct ps8622_bridge *ps8622 = i2c_get_clientdata(client);
>
> -   if (ps8622->bl)
> -   backlight_device_unregister(ps8622->bl);
> -
> +   backlight_device_unregister(ps8622->bl);
> drm_bridge_remove(>bridge);
>
> return 0;
> --
> 2.9.2
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/qxl: Delete an unnecessary check before drm_gem_object_unreference_unlocked()

2016-07-22 Thread Sean Paul
On Fri, Jul 22, 2016 at 8:22 AM, SF Markus Elfring
 wrote:
> From: Markus Elfring 
> Date: Fri, 22 Jul 2016 14:14:54 +0200
>
> The drm_gem_object_unreference_unlocked() function tests whether
> its argument is NULL and then returns immediately.
> Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring 

Applied to drm-misc

> ---
>  drivers/gpu/drm/qxl/qxl_display.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/qxl/qxl_display.c 
> b/drivers/gpu/drm/qxl/qxl_display.c
> index ad42968..3aef127 100644
> --- a/drivers/gpu/drm/qxl/qxl_display.c
> +++ b/drivers/gpu/drm/qxl/qxl_display.c
> @@ -468,8 +468,7 @@ void qxl_user_framebuffer_destroy(struct drm_framebuffer 
> *fb)
>  {
> struct qxl_framebuffer *qxl_fb = to_qxl_framebuffer(fb);
>
> -   if (qxl_fb->obj)
> -   drm_gem_object_unreference_unlocked(qxl_fb->obj);
> +   drm_gem_object_unreference_unlocked(qxl_fb->obj);
> drm_framebuffer_cleanup(fb);
> kfree(qxl_fb);
>  }
> --
> 2.9.2
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/vmwgfx: Delete an unnecessary check before the function call "vfree"

2016-07-22 Thread Sean Paul
On Fri, Jul 22, 2016 at 7:45 AM, SF Markus Elfring
 wrote:
> From: Markus Elfring 
> Date: Fri, 22 Jul 2016 13:31:00 +0200
>
> The vfree() function performs also input parameter validation.
> Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring 

Applied to drm-misc

> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> index 1a1a87c..dc5beff 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> @@ -3625,9 +3625,7 @@ static int vmw_resize_cmd_bounce(struct vmw_sw_context 
> *sw_context,
>(sw_context->cmd_bounce_size >> 1));
> }
>
> -   if (sw_context->cmd_bounce != NULL)
> -   vfree(sw_context->cmd_bounce);
> -
> +   vfree(sw_context->cmd_bounce);
> sw_context->cmd_bounce = vmalloc(sw_context->cmd_bounce_size);
>
> if (sw_context->cmd_bounce == NULL) {
> --
> 2.9.2
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/mgag200: Delete an unnecessary check before drm_gem_object_unreference_unlocked()

2016-07-22 Thread Sean Paul
On Fri, Jul 22, 2016 at 5:32 AM, SF Markus Elfring
 wrote:
> From: Markus Elfring 
> Date: Fri, 22 Jul 2016 11:20:27 +0200
>
> The drm_gem_object_unreference_unlocked() function tests whether
> its argument is NULL and then returns immediately.
> Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring 

Applied to drm-misc

> ---
>  drivers/gpu/drm/mgag200/mgag200_main.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c 
> b/drivers/gpu/drm/mgag200/mgag200_main.c
> index 615cbb0..13798b3 100644
> --- a/drivers/gpu/drm/mgag200/mgag200_main.c
> +++ b/drivers/gpu/drm/mgag200/mgag200_main.c
> @@ -17,8 +17,8 @@
>  static void mga_user_framebuffer_destroy(struct drm_framebuffer *fb)
>  {
> struct mga_framebuffer *mga_fb = to_mga_framebuffer(fb);
> -   if (mga_fb->obj)
> -   drm_gem_object_unreference_unlocked(mga_fb->obj);
> +
> +   drm_gem_object_unreference_unlocked(mga_fb->obj);
> drm_framebuffer_cleanup(fb);
> kfree(fb);
>  }
> --
> 2.9.2
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/1] drm/sti: use new Reset API

2016-07-22 Thread Sean Paul
On Fri, Jul 22, 2016 at 3:22 AM, Lee Jones  wrote:
> Since 0b52297f228 ("reset: Add support for shared reset controls") the
> new Reset API now demands consumers choose either an *_exclusive or
> a *_shared line when requesting reset lines.
>
> Signed-off-by: Lee Jones 
> ---
>  drivers/gpu/drm/sti/sti_compositor.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/sti/sti_compositor.c 
> b/drivers/gpu/drm/sti/sti_compositor.c
> index 3d2fa3a..c2ace02 100644
> --- a/drivers/gpu/drm/sti/sti_compositor.c
> +++ b/drivers/gpu/drm/sti/sti_compositor.c
> @@ -234,12 +234,12 @@ static int sti_compositor_probe(struct platform_device 
> *pdev)
> }
>
> /* Get reset resources */
> -   compo->rst_main = devm_reset_control_get(dev, "compo-main");
> +   compo->rst_main = devm_reset_control_get_shared(dev, "compo-main");

Seems like this patch also changes the behavior from being exclusively
managed to shared. Is this intentional? If so, it's probably worth
changing you commit message to be a little less innocuous.

> /* Take compo main out of reset */
> if (!IS_ERR(compo->rst_main))
> reset_control_deassert(compo->rst_main);
>
> -   compo->rst_aux = devm_reset_control_get(dev, "compo-aux");
> +   compo->rst_aux = devm_reset_control_get_shared(dev, "compo-aux");
> /* Take compo aux out of reset */
> if (!IS_ERR(compo->rst_aux))
> reset_control_deassert(compo->rst_aux);
> --
> 2.9.0
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/imx: imx-ldb: do not try to dereference crtc->state->state in encoder mode_set

2016-07-22 Thread Philipp Zabel
Am Freitag, den 22.07.2016, 10:59 +0200 schrieb Philipp Zabel:
> +   struct drm_crtc_state *crtc_state = encoder->crtc->state;

Sorry, this is superfluous. I'll drop it.



[PATCH] drm/ttm: partial revert "cleanup ttm_tt_(unbind|destroy)" v2

2016-07-22 Thread Sean Paul
On Fri, Jul 22, 2016 at 9:10 AM, Christian König
 wrote:
> From: Christian König 
>
> We still need to unbind explicitely during a move.

Sorry for the drive-by nit, but:

s/explicitely/explicitly/


>
> This partial reverts commit ff20caa0bcbfef9f7686f8d1868a3b990921afd6.
>
> v2: remove unnecessary check and unused variable
>
> Signed-off-by: Christian König 
> ---
>  drivers/gpu/drm/ttm/ttm_bo_util.c |  1 +
>  drivers/gpu/drm/ttm/ttm_tt.c  | 19 ---
>  include/drm/ttm/ttm_bo_driver.h   |  9 +
>  3 files changed, 22 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c 
> b/drivers/gpu/drm/ttm/ttm_bo_util.c
> index 0c389a5..6c412c3 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_util.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
> @@ -53,6 +53,7 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
> int ret;
>
> if (old_mem->mem_type != TTM_PL_SYSTEM) {
> +   ttm_tt_unbind(ttm);
> ttm_bo_free_old_node(bo);
> ttm_flag_masked(_mem->placement, TTM_PL_FLAG_SYSTEM,
> TTM_PL_MASK_MEM);
> diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
> index d28d4333..526e5a7 100644
> --- a/drivers/gpu/drm/ttm/ttm_tt.c
> +++ b/drivers/gpu/drm/ttm/ttm_tt.c
> @@ -166,16 +166,10 @@ EXPORT_SYMBOL(ttm_tt_set_placement_caching);
>
>  void ttm_tt_destroy(struct ttm_tt *ttm)
>  {
> -   int ret;
> -
> if (ttm == NULL)
> return;
>
> -   if (ttm->state == tt_bound) {
> -   ret = ttm->func->unbind(ttm);
> -   BUG_ON(ret);
> -   ttm->state = tt_unbound;
> -   }
> +   ttm_tt_unbind(ttm);
>
> if (ttm->state == tt_unbound)
> ttm_tt_unpopulate(ttm);
> @@ -255,6 +249,17 @@ void ttm_dma_tt_fini(struct ttm_dma_tt *ttm_dma)
>  }
>  EXPORT_SYMBOL(ttm_dma_tt_fini);
>
> +void ttm_tt_unbind(struct ttm_tt *ttm)
> +{
> +   int ret;
> +
> +   if (ttm->state == tt_bound) {
> +   ret = ttm->func->unbind(ttm);
> +   BUG_ON(ret);
> +   ttm->state = tt_unbound;
> +   }
> +}
> +
>  int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem)
>  {
> int ret = 0;
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index 141cefb..e7d81a8 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -628,6 +628,15 @@ extern int ttm_tt_bind(struct ttm_tt *ttm, struct 
> ttm_mem_reg *bo_mem);
>  extern void ttm_tt_destroy(struct ttm_tt *ttm);
>
>  /**
> + * ttm_ttm_unbind:
> + *
> + * @ttm: The struct ttm_tt.
> + *
> + * Unbind a struct ttm_tt.
> + */
> +extern void ttm_tt_unbind(struct ttm_tt *ttm);
> +
> +/**
>   * ttm_tt_swapin:
>   *
>   * @ttm: The struct ttm_tt.
> --
> 2.5.0
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v1 2/2] drm/bridge: analogix_dp: turn off the panel when eDP need to disable

2016-07-22 Thread Sean Paul
On Thu, Jul 21, 2016 at 9:00 PM, Yakir Yang  wrote:
> Sean,
>
> Thanks for your fast respond :-)
>
> But this patch is not the latest one, I have upgraded this to "v1.1" version
> to fix the eDP can't be disabled problem:
> [PATCH v1.1 2/2] drm/bridge: analogix_dp: turn off the panel when eDP
> need to disable
> Changes in v1.1: - unprepare the panel at the end of
> bridge->disable() function
>
> In spite of this, I would take your comments with my "v1.1" patch.
>
> On 07/21/2016 10:28 PM, Sean Paul wrote:
>
> On Thu, Jul 21, 2016 at 9:14 AM, Yakir Yang  wrote:
>
> Some panels (like Sharp LQ123P1JX31) need to be turn off when eDP
> controller stop to send valid video signal, otherwhise panel would
> go burn in, and keep flicker and flicker.
>
> So it's better to turn off the panel when eDP need to disable, and
> we need to turn on the panel in connector->detect() callback, so
> that driver would detect panel status rightly.
>
> Signed-off-by: Yakir Yang 
> ---
>  drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 18 ++
>  1 file changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> index 32715da..ea059b3 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> @@ -961,6 +961,14 @@ analogix_dp_detect(struct drm_connector *connector,
> bool force)
>  {
> struct analogix_dp_device *dp = to_dp(connector);
>
> +   /*
> +* Panle would prepare for several times here, but don't worry it
>
> s/Panle/Panel/
>
>
> Done
>
> +* would only enable the hardware at the first prepare time.
>
> Errr, this shouldn't go in detect. How about putting this in
> bridge_enable instead?
>
>
> Nope, if we put this in bridge_enable, then eDP would never be enabled.
> Here're the calling flow.
>
> --> analogix_dp_probe
>   --> analogix_dp_bind  # we still haven't prepared the panel here, that
> means panel have been powered up
> --> analogix_dp_detect  # Oops, losing panel valid hotplug signal, cause
> panel have been powered up
> --> ** Keep detecting **


Yeah, after playing around with the patch yesterday I discovered this
for myself. I still don't think detect() should be changing hardware
state. Perhaps you could add a matching unprepare() after you attempt
to detect the panel?

Sean

>
> +*/
> +   if (dp->plat_data->panel)
> +   if (drm_panel_prepare(dp->plat_data->panel))
>
> Personally, I don't like doing work in a conditional since you're
> throwing the return code away. Could you break this out into:
>
> ret = drm_panel_prepare(dp->plat_data->panel);
> if (ret)
>   DRM_ERROR("failed to setup the panel ret=%d\n", ret);
>
>
> Okay
>
>
> +   DRM_ERROR("failed to setup the panel\n");
> +
> if (analogix_dp_detect_hpd(dp))
> return connector_status_disconnected;
>
> @@ -1063,7 +1071,8 @@ static void analogix_dp_bridge_disable(struct
> drm_bridge *bridge)
> return;
>
> if (dp->plat_data->panel) {
> -   if (drm_panel_disable(dp->plat_data->panel)) {
> +   if (drm_panel_disable(dp->plat_data->panel) ||
> +   drm_panel_unprepare(dp->plat_data->panel)) {
>
> Same comment here, please break this out into separate statements for
> better readability/logging.
>
>
> Okay,
>
>
> Thanks,
> - Yakir
>
>
> DRM_ERROR("failed to disable the panel\n");
> return;
> }
> @@ -1333,13 +1342,6 @@ int analogix_dp_bind(struct device *dev, struct
> drm_device *drm_dev,
>
> phy_power_on(dp->phy);
>
> -   if (dp->plat_data->panel) {
> -   if (drm_panel_prepare(dp->plat_data->panel)) {
> -   DRM_ERROR("failed to setup the panel\n");
> -   return -EBUSY;
> -   }
> -   }
> -
> analogix_dp_init_dp(dp);
>
> ret = devm_request_threaded_irq(>dev, dp->irq,
> --
> 1.9.1
>
>
>
>
>


[PATCH] drm/imx: imx-ldb: do not try to dereference crtc->state->state in encoder mode_set

2016-07-22 Thread Philipp Zabel
The code in imx_ldb_encoder_mode_set crashes with a NULL pointer
dereference trying to access crtc->state->state, which was previously
cleared by drm_atomic_helper_swap_state:

Unable to handle kernel NULL pointer dereference at virtual address 0010
pgd = ae08c000
[0010] *pgd=3e00e831, *pte=, *ppte=
Internal error: Oops: 17 [#1] PREEMPT SMP ARM
Modules linked in:
CPU: 1 PID: 102 Comm: kmsfb-manage Not tainted 4.7.0-rc5+ #232
Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
task: ae058c40 ti: ae04e000 task.ti: ae04e000
PC is at imx_ldb_encoder_mode_set+0x138/0x2f8
LR is at 0xae881818
pc : [<8051a8c8>]lr : []psr: 600f0013
sp : ae04fc70  ip : ae04fbb0  fp : ae04fcbc
r10: ae8ea018  r9 :   r8 : ae246418
r7 : ae8ea010  r6 : ae8ea308  r5 :   r4 : 
r3 :   r2 :   r1 : 0110  r0 : 
Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
Control: 10c5387d  Table: 3e08c04a  DAC: 0051
Process kmsfb-manage (pid: 102, stack limit = 0xae04e210)
Stack: (0xae04fc70 to 0xae05)
fc60: 043ce660 0001 009e 
043ce660
fc80: 0002   af75cf50 1009 ae23f440 0001 
ae246418
fca0: 8155a210 ae8ea308 8093c364 ae2464e0 ae04fcec ae04fcc0 804ef350 
8051a79c
fcc0: 0004 0004 ae23f440 af3f9000 ae881818 8155a210 af1af200 
ae8ea020
fce0: ae04fd1c ae04fcf0 80519124 804ef060 ae04fd34   

fd00: ae881818 ae23f440 80d4ec8c  ae04fd34 ae04fd20 804f00b4 
80518fac
fd20: ae23f440  ae04fd54 ae04fd38 804f2190 804f0074 ae23f440 
af3f9000
fd40: ae04fdd4 ae881818 ae04fd6c ae04fd58 80516390 804f20f4 ae23f440 

fd60: ae04fd8c ae04fd70 804f26f4 80516348 ae23a000 ae881818 0001 
af3f9000
fd80: ae04fdac ae04fd90 80502c58 804f2678 ae04fe50 ae23f400 0001 
af3f9000
fda0: ae04fe1c ae04fdb0 80507a1c 80502bf8 ae23a000 ae058c40 af1af200 
ae23f400
fdc0: ae23a000 af3f9000 ae881818 ae23a00c 80176c7c ae23a000 ae881818 
af1af200
fde0:   ae23f400 0001 ae04fe1c 0051 ae04fe50 
8155a210
fe00: 80932060 c06864a2 af3f9000 ae246200 ae04fefc ae04fe20 804f9718 
805074e8
fe20: ae04feac ae04fe30 80177360 8017631c 805074dc 0068 0068 
0062
fe40: 0068 00a2 ae04fe50 7ef29688 7ef29c40  0001 
0018
fe60: 0026    0001 000115bc 05010500 
05a0059f
fe80: 0320 03360321 0337 003c  0040 30383231 
30303878
fea0:       4000 
aea6a140
fec0:  80d77b71  80283110 600f0013 7ef29688 af342bb0 
ae250b40
fee0: 80275440 0003 ae04e000  ae04ff7c ae04ff00 80274ac8 
804f957c
ff00: 80283128 80179030   80282fd8 ae1e 003d 
aea6a1d0
ff20: 0002 0003 4000 007f8c60 c06864a2 7ef29688 ae04e000 

ff40: ae04ff6c ae04ff50 80283260 80282fe4 00017050 ae250b41 0003 
ae250b40
ff60: c06864a2 7ef29688 ae04e000  ae04ffa4 ae04ff80 80275440 
80274a20
ff80: 00017050 0001 007f8c60 0036 801088a4 ae04e000  
ae04ffa8
ffa0: 80108700 80275408 00017050 0001 0003 c06864a2 7ef29688 
000115bc
ffc0: 00017050 0001 007f8c60 0036 0003  0026 
0018
ffe0: 00016f28 7ef29684 b7d9 76e4a1e6 400f0030 0003 3ff7e861 
3ff7ec61
Backtrace:
[<8051a790>] (imx_ldb_encoder_mode_set) from [<804ef350>] 
(drm_atomic_helper_commit_modeset_disables+0x2fc/0x3f0)
 r10:ae2464e0 r9:8093c364 r8:ae8ea308 r7:8155a210 r6:ae246418 r5:0001
 r4:ae23f440
[<804ef054>] (drm_atomic_helper_commit_modeset_disables) from [<80519124>] 
(imx_drm_atomic_commit_tail+0x184/0x1e0)
 r10:ae8ea020 r9:af1af200 r8:8155a210 r7:ae881818 r6:af3f9000 r5:ae23f440
 r4:0004 r3:0004
[<80518fa0>] (imx_drm_atomic_commit_tail) from [<804f00b4>] 
(commit_tail+0x4c/0x68)
 r6: r5:80d4ec8c r4:ae23f440
[<804f0068>] (commit_tail) from [<804f2190>] 
(drm_atomic_helper_commit+0xa8/0xd4)
 r5: r4:ae23f440
[<804f20e8>] (drm_atomic_helper_commit) from [<80516390>] 
(drm_atomic_commit+0x54/0x74)
 r7:ae881818 r6:ae04fdd4 r5:af3f9000 r4:ae23f440
[<8051633c>] (drm_atomic_commit) from [<804f26f4>] 
(drm_atomic_helper_set_config+0x88/0xac)
 r5: r4:ae23f440
[<804f266c>] (drm_atomic_helper_set_config) from [<80502c58>] 
(drm_mode_set_config_internal+0x6c/0xf4)
 r7:af3f9000 r6:0001 r5:ae881818 r4:ae23a000
[<80502bec>] (drm_mode_set_config_internal) from [<80507a1c>] 
(drm_mode_setcrtc+0x540/0x5b8)
 r7:af3f9000 r6:0001 r5:ae23f400 r4:ae04fe50
[<805074dc>] (drm_mode_setcrtc) from [<804f9718>] (drm_ioctl+0x1a8/0x46c)
 r10:ae246200 r9:af3f9000 r8:c06864a2 r7:80932060 r6:8155a210 

  1   2   >