[PATCH v2] drm: Release driver references to handle before making it available again

2016-01-08 Thread Chris Wilson
When userspace closes a handle, we remove it from the file->object_idr
and then tell the driver to drop its references to that file/handle.
However, as the file/handle is already available again for reuse, it may
be reallocated back to userspace and active on a new object before the
driver has had a chance to drop the old file/handle references.

Whilst calling back into the driver, we have to drop the
file->table_lock spinlock and so to prevent reusing the closed handle we
mark that handle as stale in the idr, perform the callback and then
remove the handle. We set the stale handle to point to the NULL object,
then any idr_find() whilst the driver is removing the handle will return
NULL, just as if the handle is already removed from idr.

v2: Use NULL rather than an ERR_PTR to avoid having to adjust callers.
idr_alloc() tracks existing handles using an internal bitmap, so we are
free to use the NULL object as our stale identifier.

Signed-off-by: Chris Wilson 
Cc: dri-devel at lists.freedesktop.org
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Rob Clark 
Cc: Ville Syrjälä 
Cc: Thierry Reding 
---
 drivers/gpu/drm/drm_gem.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 2e8c77e71e1f..d1909d1a1eb4 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -294,18 +294,21 @@ drm_gem_handle_delete(struct drm_file *filp, u32 handle)
spin_lock(>table_lock);

/* Check if we currently have a reference on the object */
-   obj = idr_find(>object_idr, handle);
-   if (obj == NULL) {
+   obj = idr_replace(>object_idr, NULL, handle);
+   if (IS_ERR(obj)) {
spin_unlock(>table_lock);
return -EINVAL;
}
dev = obj->dev;
+   spin_unlock(>table_lock);

/* Release reference and decrement refcount. */
+   drm_gem_object_release_handle(handle, obj, filp);
+
+   spin_lock(>table_lock);
idr_remove(>object_idr, handle);
spin_unlock(>table_lock);

-   drm_gem_object_release_handle(handle, obj, filp);
return 0;
 }
 EXPORT_SYMBOL(drm_gem_handle_delete);
-- 
2.7.0.rc3



[PATCH] drm: Release driver references to handle before making it available again

2016-01-08 Thread Chris Wilson
On Fri, Jan 08, 2016 at 08:25:07PM +, Chris Wilson wrote:
> Whilst calling back into the driver, we have to drop the
> file->table_lock spinlock and so to prevent reusing the closed handle we
> mark that handle as stale in the idr, perform the callback and then
> remove the handle. It is then possible for a lookup on that handle to
> return an error object and so all callers of idr_find(file->object_idr)
> need to check against IS_ERR_OR_NULL() instead.
> 
> - obj = idr_find(>object_idr, handle);
> - if (obj == NULL) {
> + obj = idr_replace(>object_idr, ERR_PTR(-ENOENT), handle);
> + if (IS_ERR(obj)) {

Setting ERR_PTR(-ENOENT) is superfluous. We can just set the entry to
NULL as idr_alloc() uses a bitmap to find the new handle. This avoids
having to change the callers elsewhere, as idr_find() will then return
NULL for the stale handle and the invalid handle.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


[Bug 110211] [regression bisected] amdgpu Fury X Unplayable Slow Down on Dota 2

2016-01-08 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=110211

--- Comment #5 from Kevin McCormack  ---
Well, it seems that things are much better with 4.4rc8! I'm not sure why. It
could also be the new Mushkin RAM I installed. I was having a lot of other
random issues with my G.Skill Ares kit like lots of build errors and random
system freezes. I'll test this kernel out more this weekend.

-- 
You are receiving this mail because:
You are watching the assignee of the bug.


[PATCH v2 3/3] drm: adv7511: it's HPD, not HDP

2016-01-08 Thread Wolfram Sang
From: Wolfram Sang 

Fix this typo, consequently used over both files :)

Signed-off-by: Wolfram Sang 
Acked-by: Lars-Peter Clausen 
Reviewed-by: Laurent Pinchart 
Tested-by: Archit Taneja 
---
 drivers/gpu/drm/i2c/adv7511.c | 22 +++---
 drivers/gpu/drm/i2c/adv7511.h | 12 ++--
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/i2c/adv7511.c b/drivers/gpu/drm/i2c/adv7511.c
index e1756a452d6980..a02112ba1c3df6 100644
--- a/drivers/gpu/drm/i2c/adv7511.c
+++ b/drivers/gpu/drm/i2c/adv7511.c
@@ -378,16 +378,16 @@ static void adv7511_power_on(struct adv7511 *adv7511)
}

/*
-* Per spec it is allowed to pulse the HDP signal to indicate that the
+* Per spec it is allowed to pulse the HPD signal to indicate that the
 * EDID information has changed. Some monitors do this when they wakeup
-* from standby or are enabled. When the HDP goes low the adv7511 is
+* from standby or are enabled. When the HPD goes low the adv7511 is
 * reset and the outputs are disabled which might cause the monitor to
-* go to standby again. To avoid this we ignore the HDP pin for the
+* go to standby again. To avoid this we ignore the HPD pin for the
 * first few seconds after enabling the output.
 */
regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER2,
-  ADV7511_REG_POWER2_HDP_SRC_MASK,
-  ADV7511_REG_POWER2_HDP_SRC_NONE);
+  ADV7511_REG_POWER2_HPD_SRC_MASK,
+  ADV7511_REG_POWER2_HPD_SRC_NONE);

/*
 * Most of the registers are reset during power down or when HPD is low.
@@ -421,9 +421,9 @@ static bool adv7511_hpd(struct adv7511 *adv7511)
if (ret < 0)
return false;

-   if (irq0 & ADV7511_INT0_HDP) {
+   if (irq0 & ADV7511_INT0_HPD) {
regmap_write(adv7511->regmap, ADV7511_REG_INT(0),
-ADV7511_INT0_HDP);
+ADV7511_INT0_HPD);
return true;
}

@@ -446,7 +446,7 @@ static int adv7511_irq_process(struct adv7511 *adv7511)
regmap_write(adv7511->regmap, ADV7511_REG_INT(0), irq0);
regmap_write(adv7511->regmap, ADV7511_REG_INT(1), irq1);

-   if (irq0 & ADV7511_INT0_HDP && adv7511->encoder)
+   if (irq0 & ADV7511_INT0_HPD && adv7511->encoder)
drm_helper_hpd_irq_event(adv7511->encoder->dev);

if (irq0 & ADV7511_INT0_EDID_READY || irq1 & ADV7511_INT1_DDC_ERROR) {
@@ -648,10 +648,10 @@ adv7511_encoder_detect(struct drm_encoder *encoder,
if (adv7511->status == connector_status_connected)
status = connector_status_disconnected;
} else {
-   /* Renable HDP sensing */
+   /* Renable HPD sensing */
regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER2,
-  ADV7511_REG_POWER2_HDP_SRC_MASK,
-  ADV7511_REG_POWER2_HDP_SRC_BOTH);
+  ADV7511_REG_POWER2_HPD_SRC_MASK,
+  ADV7511_REG_POWER2_HPD_SRC_BOTH);
}

adv7511->status = status;
diff --git a/drivers/gpu/drm/i2c/adv7511.h b/drivers/gpu/drm/i2c/adv7511.h
index 6599ed538426d6..38515b30cedfc8 100644
--- a/drivers/gpu/drm/i2c/adv7511.h
+++ b/drivers/gpu/drm/i2c/adv7511.h
@@ -90,7 +90,7 @@
 #define ADV7511_CSC_ENABLE BIT(7)
 #define ADV7511_CSC_UPDATE_MODEBIT(5)

-#define ADV7511_INT0_HDP   BIT(7)
+#define ADV7511_INT0_HPD   BIT(7)
 #define ADV7511_INT0_VSYNC BIT(5)
 #define ADV7511_INT0_AUDIO_FIFO_FULL   BIT(4)
 #define ADV7511_INT0_EDID_READYBIT(2)
@@ -157,11 +157,11 @@
 #define ADV7511_PACKET_ENABLE_SPARE2   BIT(1)
 #define ADV7511_PACKET_ENABLE_SPARE1   BIT(0)

-#define ADV7511_REG_POWER2_HDP_SRC_MASK0xc0
-#define ADV7511_REG_POWER2_HDP_SRC_BOTH0x00
-#define ADV7511_REG_POWER2_HDP_SRC_HDP 0x40
-#define ADV7511_REG_POWER2_HDP_SRC_CEC 0x80
-#define ADV7511_REG_POWER2_HDP_SRC_NONE0xc0
+#define ADV7511_REG_POWER2_HPD_SRC_MASK0xc0
+#define ADV7511_REG_POWER2_HPD_SRC_BOTH0x00
+#define ADV7511_REG_POWER2_HPD_SRC_HPD 0x40
+#define ADV7511_REG_POWER2_HPD_SRC_CEC 0x80
+#define ADV7511_REG_POWER2_HPD_SRC_NONE0xc0
 #define ADV7511_REG_POWER2_TDMS_ENABLE BIT(4)
 #define ADV7511_REG_POWER2_GATE_INPUT_CLK  BIT(0)

-- 
2.1.4



[PATCH v2 2/3] drm: adv7511: mark ADV7511_REG_EDID_READ_CTRL volatile

2016-01-08 Thread Wolfram Sang
From: Wolfram Sang 

This register includes a counter which is decremented by the chip on I2C
failures. Also, it is reset when powering down.

Signed-off-by: Wolfram Sang 
Reviewed-by: Laurent Pinchart 
Tested-by: Archit Taneja 
---
 drivers/gpu/drm/i2c/adv7511.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/i2c/adv7511.c b/drivers/gpu/drm/i2c/adv7511.c
index db7435a4517fb4..e1756a452d6980 100644
--- a/drivers/gpu/drm/i2c/adv7511.c
+++ b/drivers/gpu/drm/i2c/adv7511.c
@@ -136,6 +136,7 @@ static bool adv7511_register_volatile(struct device *dev, 
unsigned int reg)
case ADV7511_REG_BKSV(3):
case ADV7511_REG_BKSV(4):
case ADV7511_REG_DDC_STATUS:
+   case ADV7511_REG_EDID_READ_CTRL:
case ADV7511_REG_BSTATUS(0):
case ADV7511_REG_BSTATUS(1):
case ADV7511_REG_CHIP_ID_HIGH:
-- 
2.1.4



[PATCH v2 1/3] drm: adv7511: really enable interrupts for EDID detection

2016-01-08 Thread Wolfram Sang
From: Wolfram Sang 

The interrupts for EDID_READY or DDC_ERROR were never enabled in this
driver, so reading EDID always timed out when chip was powered down and
interrupts were used. Fix this and also remove clearing the interrupt
flags, they are cleared in POWER_DOWN mode anyhow (unlike the interrupt
enable flags) according to docs and my tests.

Signed-off-by: Wolfram Sang 
Tested-by: Archit Taneja 
---
 drivers/gpu/drm/i2c/adv7511.c | 25 +
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i2c/adv7511.c b/drivers/gpu/drm/i2c/adv7511.c
index 533d1e3d4a999f..db7435a4517fb4 100644
--- a/drivers/gpu/drm/i2c/adv7511.c
+++ b/drivers/gpu/drm/i2c/adv7511.c
@@ -362,12 +362,19 @@ static void adv7511_power_on(struct adv7511 *adv7511)
 {
adv7511->current_edid_segment = -1;

-   regmap_write(adv7511->regmap, ADV7511_REG_INT(0),
-ADV7511_INT0_EDID_READY);
-   regmap_write(adv7511->regmap, ADV7511_REG_INT(1),
-ADV7511_INT1_DDC_ERROR);
regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER,
   ADV7511_POWER_POWER_DOWN, 0);
+   if (adv7511->i2c_main->irq) {
+   /*
+* Documentation says the INT_ENABLE registers are reset in
+* POWER_DOWN mode. My 7511w preserved the bits, however.
+* Still, let's be safe and stick to the documentation.
+*/
+   regmap_write(adv7511->regmap, ADV7511_REG_INT_ENABLE(0),
+ADV7511_INT0_EDID_READY);
+   regmap_write(adv7511->regmap, ADV7511_REG_INT_ENABLE(1),
+ADV7511_INT1_DDC_ERROR);
+   }

/*
 * Per spec it is allowed to pulse the HDP signal to indicate that the
@@ -567,12 +574,14 @@ static int adv7511_get_modes(struct drm_encoder *encoder,

/* Reading the EDID only works if the device is powered */
if (!adv7511->powered) {
-   regmap_write(adv7511->regmap, ADV7511_REG_INT(0),
-ADV7511_INT0_EDID_READY);
-   regmap_write(adv7511->regmap, ADV7511_REG_INT(1),
-ADV7511_INT1_DDC_ERROR);
regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER,
   ADV7511_POWER_POWER_DOWN, 0);
+   if (adv7511->i2c_main->irq) {
+   regmap_write(adv7511->regmap, ADV7511_REG_INT_ENABLE(0),
+ADV7511_INT0_EDID_READY);
+   regmap_write(adv7511->regmap, ADV7511_REG_INT_ENABLE(1),
+ADV7511_INT1_DDC_ERROR);
+   }
adv7511->current_edid_segment = -1;
}

-- 
2.1.4



[PATCH v2 0/3] drm: adv7511: edid read fixes

2016-01-08 Thread Wolfram Sang
So, here is my V2 of this series. Changes:

* Added tags. Thanks to Laurent and Lars-Peter for review and to Archit for
  testing. Much appreciated!
* rephrased the comment and commit message in patch 1 to be hopefully less
  confusing :)

No code changes!

Thanks,

   Wolfram


Wolfram Sang (3):
  drm: adv7511: really enable interrupts for EDID detection
  drm: adv7511: mark ADV7511_REG_EDID_READ_CTRL volatile
  drm: adv7511: it's HPD, not HDP

 drivers/gpu/drm/i2c/adv7511.c | 48 ++-
 drivers/gpu/drm/i2c/adv7511.h | 12 +--
 2 files changed, 35 insertions(+), 25 deletions(-)

-- 
2.1.4



[PATCH] x86: Add an explicit barrier() to clflushopt()

2016-01-08 Thread H. Peter Anvin
On 01/07/16 14:32, H. Peter Anvin wrote:
>
> Nevermind.  CLFLUSH is not ordered with regards to CLFLUSHOPT to the
> same cache line.
> 

*Except* to the same cache line, dammit.

-hpa




[PATCH 21/21] drm/vmwgfx: Nuke preclose hook

2016-01-08 Thread Thomas Hellstrom
On 01/08/2016 09:36 PM, Daniel Vetter wrote:
> Again since the drm core takes care of event unlinking/disarming this
> is now just needless code.
>
> Cc: Thomas Hellström 
> Signed-off-by: Daniel Vetter 
Hmm,

IIRC this is actually a list of events that core drm is not aware of
yet. They sit on this list waiting for a fence to pass and are then
transferred to core drm

/Thomas


> ---
>  drivers/gpu/drm/vc4/vc4_drv.h |  1 -
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c   | 10 -
>  drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 38 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_fence.h |  2 --
>  4 files changed, 51 deletions(-)
>
> diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
> index 080865ec2bae..4c734d087d7f 100644
> --- a/drivers/gpu/drm/vc4/vc4_drv.h
> +++ b/drivers/gpu/drm/vc4/vc4_drv.h
> @@ -376,7 +376,6 @@ int vc4_bo_stats_debugfs(struct seq_file *m, void *arg);
>  extern struct platform_driver vc4_crtc_driver;
>  int vc4_enable_vblank(struct drm_device *dev, unsigned int crtc_id);
>  void vc4_disable_vblank(struct drm_device *dev, unsigned int crtc_id);
> -void vc4_cancel_page_flip(struct drm_crtc *crtc, struct drm_file *file);
>  int vc4_crtc_debugfs_regs(struct seq_file *m, void *arg);
>  
>  /* vc4_debugfs.c */
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index c49812b80dd0..c04c4d1e2f3e 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -971,15 +971,6 @@ static int vmw_driver_unload(struct drm_device *dev)
>   return 0;
>  }
>  
> -static void vmw_preclose(struct drm_device *dev,
> -  struct drm_file *file_priv)
> -{
> - struct vmw_fpriv *vmw_fp = vmw_fpriv(file_priv);
> - struct vmw_private *dev_priv = vmw_priv(dev);
> -
> - vmw_event_fence_fpriv_gone(dev_priv->fman, _fp->fence_events);
> -}
> -
>  static void vmw_postclose(struct drm_device *dev,
>struct drm_file *file_priv)
>  {
> @@ -1500,7 +1491,6 @@ static struct drm_driver driver = {
>   .master_set = vmw_master_set,
>   .master_drop = vmw_master_drop,
>   .open = vmw_driver_open,
> - .preclose = vmw_preclose,
>   .postclose = vmw_postclose,
>   .set_busid = drm_pci_set_busid,
>  
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
> index e0edf149d9d5..55dc3e4754df 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
> @@ -808,44 +808,6 @@ int vmw_fence_obj_unref_ioctl(struct drm_device *dev, 
> void *data,
>  }
>  
>  /**
> - * vmw_event_fence_fpriv_gone - Remove references to struct drm_file objects
> - *
> - * @fman: Pointer to a struct vmw_fence_manager
> - * @event_list: Pointer to linked list of struct vmw_event_fence_action 
> objects
> - * with pointers to a struct drm_file object about to be closed.
> - *
> - * This function removes all pending fence events with references to a
> - * specific struct drm_file object about to be closed. The caller is required
> - * to pass a list of all struct vmw_event_fence_action objects with such
> - * events attached. This function is typically called before the
> - * struct drm_file object's event management is taken down.
> - */
> -void vmw_event_fence_fpriv_gone(struct vmw_fence_manager *fman,
> - struct list_head *event_list)
> -{
> - struct vmw_event_fence_action *eaction;
> - struct drm_pending_event *event;
> - unsigned long irq_flags;
> -
> - while (1) {
> - spin_lock_irqsave(>lock, irq_flags);
> - if (list_empty(event_list))
> - goto out_unlock;
> - eaction = list_first_entry(event_list,
> -struct vmw_event_fence_action,
> -fpriv_head);
> - list_del_init(>fpriv_head);
> - event = eaction->event;
> - eaction->event = NULL;
> - spin_unlock_irqrestore(>lock, irq_flags);
> - event->destroy(event);
> - }
> -out_unlock:
> - spin_unlock_irqrestore(>lock, irq_flags);
> -}
> -
> -
> -/**
>   * vmw_event_fence_action_seq_passed
>   *
>   * @action: The struct vmw_fence_action embedded in a struct
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.h 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.h
> index 8be6c29f5eb5..83ae301ee141 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.h
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.h
> @@ -116,8 +116,6 @@ extern int vmw_fence_obj_unref_ioctl(struct drm_device 
> *dev, void *data,
>struct drm_file *file_priv);
>  extern int vmw_fence_event_ioctl(struct drm_device *dev, void *data,
>struct drm_file *file_priv);
> -extern void vmw_event_fence_fpriv_gone(struct vmw_fence_manager *fman,
> - 

[PATCH 1/1] apple-gmux: Add initial documentation

2016-01-08 Thread Daniel Vetter
On Mon, Jan 04, 2016 at 12:21:40PM -0800, Darren Hart wrote:
> On Mon, Jan 04, 2016 at 05:52:06PM +0100, Lukas Wunner wrote:
> > Document what I've learned so far about the gmux so that we can
> > collaboratively reverse-engineer its remaining unknown bits
> > without everyone having to start from scratch.
> > 
> 
> +Jon Corbet
> +Daniel Vetter
> +linux-doc
> 
> Any concerns with this series? If not, I'll take it in via the pdx86 tree.

Acked-by: Daniel Vetter 

Like Jonathan clarified asciidoc is purely optional, at most it'll look a
bit funny with the upstream docbook system.
-Daniel

> 
> Thanks,
> 
> Darren
> 
> > The DOC sections are bound together in the gpu.tmpl DocBook
> > under a new vga_switcheroo "Handlers" chapter. Eventually
> > this should be amended with documentation about the four other
> > handlers that exist so far (nouveau v1 DSM, nouveau Optimus DSM,
> > radeon ATPX, amdgpu ATPX).
> > 
> > Requires kernel-doc with asciidoc support.
> > 
> > The EFI variable was reverse-engineered by Bruno Bierbaumer
> >  and Andreas Heider .
> > 
> > Some of the remaining open questions:
> > 
> > * How are vblank intervals synchronized on retinas to achieve seamless
> >   switching? Is the DP mux capable of this? It's not mentioned in the
> >   data sheets. Or is it done at the OS level, i.e. do we have to
> >   synchronize vblank intervals between DRM drivers? There's a signal
> >   coming from the panel connector and going into gmux, could this be
> >   the vblank signal as received by the panel to properly time the
> >   switch?
> > 
> > * On retinas there's an I2C bus between gmux and the connector of the
> >   right I/O board, apparently leading to the Parade PS8401A HDMI
> >   repeater. What is this for, is it controlled via gmux registers?
> >   Data sheet:
> >   http://www.paradetech.com/products/jitter-cleaning-repeaters/ps8401/
> > 
> > * On retinas there's an I2C bus between gmux and the LED driver.
> >   Pre-retinas connected the LED driver to SMBUS. Are there additional
> >   gmux registers on retinas to control it?
> > 
> > * The MacPro6,1 2013 also has a gmux, the same Renesas R4F2113 as the
> >   retina MacBook Pro. The Mac Pro doesn't have a built-in display,
> >   so what is its purpose? Power control of the dual FirePro GPUs?
> >   Switching of the external DP/Thunderbolt ports? The iFixit teardown
> >   clearly shows one TI HD3SS212 DisplayPort mux on the logic board next
> >   to one of the three Thunderbolt controllers. However six muxes would
> >   be necessary to switch all six ports between GPUs. The mux is probably
> >   necessary for one of the display configurations allowed by Apple,
> >   but which one?
> >   https://www.ifixit.com/Teardown/Mac+Pro+Late+2013+Teardown/20778
> >   https://d3nevzfk7ii3be.cloudfront.net/igi/fELBTnt31QhnDsqq.huge
> >   https://support.apple.com/en-us/HT202801
> > 
> > * Registers we haven't decoded yet:
> >   0x700 32 Bit configmap?
> >   0x708 32 Bit power sequence?
> >   0x712  8 Bit status of clock from panel on retinas?
> >   0x713  8 Bit dito?
> >   0x724 16 Bit backlight, raw value?
> >   0x760 32 Bit backlight
> >   0x764 32 Bit backlight
> >   0x768  8 Bit backlight
> >   0x76a 16 Bit backlight
> >   0x76c 16 Bit backlight
> >   0x76e 16 Bit backlight
> >   0x77fedp/dp/hdmi probe? retina only.
> > 
> > Signed-off-by: Lukas Wunner 
> > ---
> >  Documentation/DocBook/gpu.tmpl|  22 
> >  drivers/platform/x86/apple-gmux.c | 113 
> > ++
> >  2 files changed, 135 insertions(+)
> > 
> > diff --git a/Documentation/DocBook/gpu.tmpl b/Documentation/DocBook/gpu.tmpl
> > index 225a246..9e95aa1 100644
> > --- a/Documentation/DocBook/gpu.tmpl
> > +++ b/Documentation/DocBook/gpu.tmpl
> > @@ -3658,8 +3658,30 @@ int num_ioctls;
> >  
> >
> >  
> > +  
> > +Handlers
> > +
> > +  apple-gmux Handler
> > +!Pdrivers/platform/x86/apple-gmux.c Overview
> > +!Pdrivers/platform/x86/apple-gmux.c Interrupt
> > +  
> > +Graphics mux
> > +!Pdrivers/platform/x86/apple-gmux.c Graphics mux
> > +  
> > +  
> > +Power control
> > +!Pdrivers/platform/x86/apple-gmux.c Power control
> > +  
> > +  
> > +Backlight control
> > +!Pdrivers/platform/x86/apple-gmux.c Backlight control
> > +  
> > +
> > +  
> > +
> >  !Cdrivers/gpu/vga/vga_switcheroo.c
> >  !Cinclude/linux/vga_switcheroo.h
> > +!Cdrivers/platform/x86/apple-gmux.c
> >  
> >  
> >  
> > diff --git a/drivers/platform/x86/apple-gmux.c 
> > b/drivers/platform/x86/apple-gmux.c
> > index aa58d41..f236250 100644
> > --- a/drivers/platform/x86/apple-gmux.c
> > +++ b/drivers/platform/x86/apple-gmux.c
> > @@ -3,6 +3,7 @@
> >   *
> >   *  Copyright (C) Canonical Ltd. 
> >   *  Copyright (C) 2010-2012 Andreas Heider 
> > + *  Copyright (C) 2015 Lukas Wunner 
> >   *
> >   *  This program is free software; you can redistribute it and/or modify
> >   *  it under the terms of the GNU General Public 

[PATCH 21/21] drm/vmwgfx: Nuke preclose hook

2016-01-08 Thread Daniel Vetter
Again since the drm core takes care of event unlinking/disarming this
is now just needless code.

Cc: Thomas Hellström 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/vc4/vc4_drv.h |  1 -
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c   | 10 -
 drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 38 ---
 drivers/gpu/drm/vmwgfx/vmwgfx_fence.h |  2 --
 4 files changed, 51 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
index 080865ec2bae..4c734d087d7f 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.h
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
@@ -376,7 +376,6 @@ int vc4_bo_stats_debugfs(struct seq_file *m, void *arg);
 extern struct platform_driver vc4_crtc_driver;
 int vc4_enable_vblank(struct drm_device *dev, unsigned int crtc_id);
 void vc4_disable_vblank(struct drm_device *dev, unsigned int crtc_id);
-void vc4_cancel_page_flip(struct drm_crtc *crtc, struct drm_file *file);
 int vc4_crtc_debugfs_regs(struct seq_file *m, void *arg);

 /* vc4_debugfs.c */
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index c49812b80dd0..c04c4d1e2f3e 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -971,15 +971,6 @@ static int vmw_driver_unload(struct drm_device *dev)
return 0;
 }

-static void vmw_preclose(struct drm_device *dev,
-struct drm_file *file_priv)
-{
-   struct vmw_fpriv *vmw_fp = vmw_fpriv(file_priv);
-   struct vmw_private *dev_priv = vmw_priv(dev);
-
-   vmw_event_fence_fpriv_gone(dev_priv->fman, _fp->fence_events);
-}
-
 static void vmw_postclose(struct drm_device *dev,
 struct drm_file *file_priv)
 {
@@ -1500,7 +1491,6 @@ static struct drm_driver driver = {
.master_set = vmw_master_set,
.master_drop = vmw_master_drop,
.open = vmw_driver_open,
-   .preclose = vmw_preclose,
.postclose = vmw_postclose,
.set_busid = drm_pci_set_busid,

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
index e0edf149d9d5..55dc3e4754df 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
@@ -808,44 +808,6 @@ int vmw_fence_obj_unref_ioctl(struct drm_device *dev, void 
*data,
 }

 /**
- * vmw_event_fence_fpriv_gone - Remove references to struct drm_file objects
- *
- * @fman: Pointer to a struct vmw_fence_manager
- * @event_list: Pointer to linked list of struct vmw_event_fence_action objects
- * with pointers to a struct drm_file object about to be closed.
- *
- * This function removes all pending fence events with references to a
- * specific struct drm_file object about to be closed. The caller is required
- * to pass a list of all struct vmw_event_fence_action objects with such
- * events attached. This function is typically called before the
- * struct drm_file object's event management is taken down.
- */
-void vmw_event_fence_fpriv_gone(struct vmw_fence_manager *fman,
-   struct list_head *event_list)
-{
-   struct vmw_event_fence_action *eaction;
-   struct drm_pending_event *event;
-   unsigned long irq_flags;
-
-   while (1) {
-   spin_lock_irqsave(>lock, irq_flags);
-   if (list_empty(event_list))
-   goto out_unlock;
-   eaction = list_first_entry(event_list,
-  struct vmw_event_fence_action,
-  fpriv_head);
-   list_del_init(>fpriv_head);
-   event = eaction->event;
-   eaction->event = NULL;
-   spin_unlock_irqrestore(>lock, irq_flags);
-   event->destroy(event);
-   }
-out_unlock:
-   spin_unlock_irqrestore(>lock, irq_flags);
-}
-
-
-/**
  * vmw_event_fence_action_seq_passed
  *
  * @action: The struct vmw_fence_action embedded in a struct
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.h 
b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.h
index 8be6c29f5eb5..83ae301ee141 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.h
@@ -116,8 +116,6 @@ extern int vmw_fence_obj_unref_ioctl(struct drm_device 
*dev, void *data,
 struct drm_file *file_priv);
 extern int vmw_fence_event_ioctl(struct drm_device *dev, void *data,
 struct drm_file *file_priv);
-extern void vmw_event_fence_fpriv_gone(struct vmw_fence_manager *fman,
-  struct list_head *event_list);
 extern int vmw_event_fence_action_queue(struct drm_file *filee_priv,
struct vmw_fence_obj *fence,
struct drm_pending_event *event,
-- 
2.6.4



[PATCH 20/21] drm/vc4: Nuke preclose hook

2016-01-08 Thread Daniel Vetter
Again since the drm core takes care of event unlinking/disarming this
is now just needless code.

Cc: Eric Anholt 
Signed-off-by: Daniel Vetter enter the commit 
message for your changes. Lines starting
---
 drivers/gpu/drm/vc4/vc4_crtc.c | 20 
 drivers/gpu/drm/vc4/vc4_drv.c  | 10 --
 2 files changed, 30 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c
index 018145e0b87d..937409792b97 100644
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
@@ -593,26 +593,6 @@ static const struct drm_crtc_helper_funcs 
vc4_crtc_helper_funcs = {
.atomic_flush = vc4_crtc_atomic_flush,
 };

-/* Frees the page flip event when the DRM device is closed with the
- * event still outstanding.
- */
-void vc4_cancel_page_flip(struct drm_crtc *crtc, struct drm_file *file)
-{
-   struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
-   struct drm_device *dev = crtc->dev;
-   unsigned long flags;
-
-   spin_lock_irqsave(>event_lock, flags);
-
-   if (vc4_crtc->event && vc4_crtc->event->base.file_priv == file) {
-   vc4_crtc->event->base.destroy(_crtc->event->base);
-   drm_crtc_vblank_put(crtc);
-   vc4_crtc->event = NULL;
-   }
-
-   spin_unlock_irqrestore(>event_lock, flags);
-}
-
 static const struct vc4_crtc_data pv0_data = {
.hvs_channel = 0,
.encoder0_type = VC4_ENCODER_TYPE_DSI0,
diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
index f1655fff8425..b7d2ff0e6e1f 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.c
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
@@ -43,14 +43,6 @@ void __iomem *vc4_ioremap_regs(struct platform_device *dev, 
int index)
return map;
 }

-static void vc4_drm_preclose(struct drm_device *dev, struct drm_file *file)
-{
-   struct drm_crtc *crtc;
-
-   list_for_each_entry(crtc, >mode_config.crtc_list, head)
-   vc4_cancel_page_flip(crtc, file);
-}
-
 static void vc4_lastclose(struct drm_device *dev)
 {
struct vc4_dev *vc4 = to_vc4_dev(dev);
@@ -91,8 +83,6 @@ static struct drm_driver vc4_drm_driver = {
DRIVER_HAVE_IRQ |
DRIVER_PRIME),
.lastclose = vc4_lastclose,
-   .preclose = vc4_drm_preclose,
-
.irq_handler = vc4_irq,
.irq_preinstall = vc4_irq_preinstall,
.irq_postinstall = vc4_irq_postinstall,
-- 
2.6.4



[PATCH 19/21] drm/tilcdc: Nuke preclose hook

2016-01-08 Thread Daniel Vetter
Again since the drm core takes care of event unlinking/disarming this
is now just needless code.

Cc: Rob Clark 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/shmobile/shmob_drm_crtc.h |  2 --
 drivers/gpu/drm/tegra/drm.h   |  1 -
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c  | 20 
 drivers/gpu/drm/tilcdc/tilcdc_drv.c   |  8 
 drivers/gpu/drm/tilcdc/tilcdc_drv.h   |  1 -
 5 files changed, 32 deletions(-)

diff --git a/drivers/gpu/drm/shmobile/shmob_drm_crtc.h 
b/drivers/gpu/drm/shmobile/shmob_drm_crtc.h
index eddad6dcc88a..38ed4ff8aaf2 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_crtc.h
+++ b/drivers/gpu/drm/shmobile/shmob_drm_crtc.h
@@ -47,8 +47,6 @@ struct shmob_drm_connector {

 int shmob_drm_crtc_create(struct shmob_drm_device *sdev);
 void shmob_drm_crtc_enable_vblank(struct shmob_drm_device *sdev, bool enable);
-void shmob_drm_crtc_cancel_page_flip(struct shmob_drm_crtc *scrtc,
-struct drm_file *file);
 void shmob_drm_crtc_finish_page_flip(struct shmob_drm_crtc *scrtc);
 void shmob_drm_crtc_suspend(struct shmob_drm_crtc *scrtc);
 void shmob_drm_crtc_resume(struct shmob_drm_crtc *scrtc);
diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h
index c088f2f67eda..8a10f5b7d9dc 100644
--- a/drivers/gpu/drm/tegra/drm.h
+++ b/drivers/gpu/drm/tegra/drm.h
@@ -195,7 +195,6 @@ struct tegra_dc_window {
 u32 tegra_dc_get_vblank_counter(struct tegra_dc *dc);
 void tegra_dc_enable_vblank(struct tegra_dc *dc);
 void tegra_dc_disable_vblank(struct tegra_dc *dc);
-void tegra_dc_cancel_page_flip(struct drm_crtc *crtc, struct drm_file *file);
 void tegra_dc_commit(struct tegra_dc *dc);
 int tegra_dc_state_setup_clock(struct tegra_dc *dc,
   struct drm_crtc_state *crtc_state,
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c 
b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 7d07733bdc86..4802da8e6d6f 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -662,26 +662,6 @@ irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc)
return IRQ_HANDLED;
 }

-void tilcdc_crtc_cancel_page_flip(struct drm_crtc *crtc, struct drm_file *file)
-{
-   struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
-   struct drm_pending_vblank_event *event;
-   struct drm_device *dev = crtc->dev;
-   unsigned long flags;
-
-   /* Destroy the pending vertical blanking event associated with the
-* pending page flip, if any, and disable vertical blanking interrupts.
-*/
-   spin_lock_irqsave(>event_lock, flags);
-   event = tilcdc_crtc->event;
-   if (event && event->base.file_priv == file) {
-   tilcdc_crtc->event = NULL;
-   event->base.destroy(>base);
-   drm_vblank_put(dev, 0);
-   }
-   spin_unlock_irqrestore(>event_lock, flags);
-}
-
 struct drm_crtc *tilcdc_crtc_create(struct drm_device *dev)
 {
struct tilcdc_crtc *tilcdc_crtc;
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c 
b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 4ddb21e7f52f..b39ba213e303 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -349,13 +349,6 @@ fail_free_priv:
return ret;
 }

-static void tilcdc_preclose(struct drm_device *dev, struct drm_file *file)
-{
-   struct tilcdc_drm_private *priv = dev->dev_private;
-
-   tilcdc_crtc_cancel_page_flip(priv->crtc, file);
-}
-
 static void tilcdc_lastclose(struct drm_device *dev)
 {
struct tilcdc_drm_private *priv = dev->dev_private;
@@ -556,7 +549,6 @@ static struct drm_driver tilcdc_driver = {
.driver_features= DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET,
.load   = tilcdc_load,
.unload = tilcdc_unload,
-   .preclose   = tilcdc_preclose,
.lastclose  = tilcdc_lastclose,
.set_busid  = drm_platform_set_busid,
.irq_handler= tilcdc_irq,
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.h 
b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
index e863ad0d26fe..66105d8dc620 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.h
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
@@ -163,7 +163,6 @@ struct tilcdc_panel_info {
 #define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)

 struct drm_crtc *tilcdc_crtc_create(struct drm_device *dev);
-void tilcdc_crtc_cancel_page_flip(struct drm_crtc *crtc, struct drm_file 
*file);
 irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc);
 void tilcdc_crtc_update_clk(struct drm_crtc *crtc);
 void tilcdc_crtc_set_panel_info(struct drm_crtc *crtc,
-- 
2.6.4



[PATCH 18/21] drm/tegra: Stop cancelling page flip events

2016-01-08 Thread Daniel Vetter
The core takes care of that now.

Cc: Thierry Reding 
Cc: Terje Bergström 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/tegra/dc.c  | 17 -
 drivers/gpu/drm/tegra/drm.c |  3 ---
 2 files changed, 20 deletions(-)

diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index dde6f208c347..fb2b4b0271a2 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -988,23 +988,6 @@ static void tegra_dc_finish_page_flip(struct tegra_dc *dc)
spin_unlock_irqrestore(>event_lock, flags);
 }

-void tegra_dc_cancel_page_flip(struct drm_crtc *crtc, struct drm_file *file)
-{
-   struct tegra_dc *dc = to_tegra_dc(crtc);
-   struct drm_device *drm = crtc->dev;
-   unsigned long flags;
-
-   spin_lock_irqsave(>event_lock, flags);
-
-   if (dc->event && dc->event->base.file_priv == file) {
-   dc->event->base.destroy(>event->base);
-   drm_crtc_vblank_put(crtc);
-   dc->event = NULL;
-   }
-
-   spin_unlock_irqrestore(>event_lock, flags);
-}
-
 static void tegra_dc_destroy(struct drm_crtc *crtc)
 {
drm_crtc_cleanup(crtc);
diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index c5c856a0879d..021d0e1398fb 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -860,9 +860,6 @@ static void tegra_drm_preclose(struct drm_device *drm, 
struct drm_file *file)
struct tegra_drm_context *context, *tmp;
struct drm_crtc *crtc;

-   list_for_each_entry(crtc, >mode_config.crtc_list, head)
-   tegra_dc_cancel_page_flip(crtc, file);
-
list_for_each_entry_safe(context, tmp, >contexts, list)
tegra_drm_context_free(context);

-- 
2.6.4



[PATCH 17/21] drm/shmob: Nuke preclose hook

2016-01-08 Thread Daniel Vetter
Again since the drm core takes care of event unlinking/disarming this
is now just needless code.

Cc: Laurent Pinchart 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/shmobile/shmob_drm_crtc.c | 20 
 drivers/gpu/drm/shmobile/shmob_drm_drv.c  |  8 
 2 files changed, 28 deletions(-)

diff --git a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c 
b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c
index b80802f55143..de7959a60774 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_crtc.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_crtc.c
@@ -438,26 +438,6 @@ static const struct drm_crtc_helper_funcs 
crtc_helper_funcs = {
.mode_set_base = shmob_drm_crtc_mode_set_base,
 };

-void shmob_drm_crtc_cancel_page_flip(struct shmob_drm_crtc *scrtc,
-struct drm_file *file)
-{
-   struct drm_pending_vblank_event *event;
-   struct drm_device *dev = scrtc->crtc.dev;
-   unsigned long flags;
-
-   /* Destroy the pending vertical blanking event associated with the
-* pending page flip, if any, and disable vertical blanking interrupts.
-*/
-   spin_lock_irqsave(>event_lock, flags);
-   event = scrtc->event;
-   if (event && event->base.file_priv == file) {
-   scrtc->event = NULL;
-   event->base.destroy(>base);
-   drm_vblank_put(dev, 0);
-   }
-   spin_unlock_irqrestore(>event_lock, flags);
-}
-
 void shmob_drm_crtc_finish_page_flip(struct shmob_drm_crtc *scrtc)
 {
struct drm_pending_vblank_event *event;
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c 
b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
index 04e66e3751b4..7700ff172079 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
@@ -200,13 +200,6 @@ done:
return ret;
 }

-static void shmob_drm_preclose(struct drm_device *dev, struct drm_file *file)
-{
-   struct shmob_drm_device *sdev = dev->dev_private;
-
-   shmob_drm_crtc_cancel_page_flip(>crtc, file);
-}
-
 static irqreturn_t shmob_drm_irq(int irq, void *arg)
 {
struct drm_device *dev = arg;
@@ -266,7 +259,6 @@ static struct drm_driver shmob_drm_driver = {
| DRIVER_PRIME,
.load   = shmob_drm_load,
.unload = shmob_drm_unload,
-   .preclose   = shmob_drm_preclose,
.set_busid  = drm_platform_set_busid,
.irq_handler= shmob_drm_irq,
.get_vblank_counter = drm_vblank_no_hw_counter,
-- 
2.6.4



[PATCH 16/21] drm/rcar: Nuke preclose hook

2016-01-08 Thread Daniel Vetter
Again since the drm core takes care of event unlinking/disarming this
is now just needless code.

Cc: Laurent Pinchart 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 20 
 drivers/gpu/drm/rcar-du/rcar_du_crtc.h |  2 --
 drivers/gpu/drm/rcar-du/rcar_du_drv.c  | 10 --
 3 files changed, 32 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c 
b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index 88a4b706be16..4ec80ae1fa99 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -282,26 +282,6 @@ static void rcar_du_crtc_update_planes(struct rcar_du_crtc 
*rcrtc)
  * Page Flip
  */

-void rcar_du_crtc_cancel_page_flip(struct rcar_du_crtc *rcrtc,
-  struct drm_file *file)
-{
-   struct drm_pending_vblank_event *event;
-   struct drm_device *dev = rcrtc->crtc.dev;
-   unsigned long flags;
-
-   /* Destroy the pending vertical blanking event associated with the
-* pending page flip, if any, and disable vertical blanking interrupts.
-*/
-   spin_lock_irqsave(>event_lock, flags);
-   event = rcrtc->event;
-   if (event && event->base.file_priv == file) {
-   rcrtc->event = NULL;
-   event->base.destroy(>base);
-   drm_crtc_vblank_put(>crtc);
-   }
-   spin_unlock_irqrestore(>event_lock, flags);
-}
-
 static void rcar_du_crtc_finish_page_flip(struct rcar_du_crtc *rcrtc)
 {
struct drm_pending_vblank_event *event;
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h 
b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
index 4b95d9d08c49..2bbe3f5aab65 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
@@ -67,8 +67,6 @@ enum rcar_du_output {

 int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int index);
 void rcar_du_crtc_enable_vblank(struct rcar_du_crtc *rcrtc, bool enable);
-void rcar_du_crtc_cancel_page_flip(struct rcar_du_crtc *rcrtc,
-  struct drm_file *file);
 void rcar_du_crtc_suspend(struct rcar_du_crtc *rcrtc);
 void rcar_du_crtc_resume(struct rcar_du_crtc *rcrtc);

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index 40422f6b645e..0bb2b31555bf 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -220,15 +220,6 @@ done:
return ret;
 }

-static void rcar_du_preclose(struct drm_device *dev, struct drm_file *file)
-{
-   struct rcar_du_device *rcdu = dev->dev_private;
-   unsigned int i;
-
-   for (i = 0; i < rcdu->num_crtcs; ++i)
-   rcar_du_crtc_cancel_page_flip(>crtcs[i], file);
-}
-
 static void rcar_du_lastclose(struct drm_device *dev)
 {
struct rcar_du_device *rcdu = dev->dev_private;
@@ -271,7 +262,6 @@ static struct drm_driver rcar_du_driver = {
| DRIVER_ATOMIC,
.load   = rcar_du_load,
.unload = rcar_du_unload,
-   .preclose   = rcar_du_preclose,
.lastclose  = rcar_du_lastclose,
.set_busid  = drm_platform_set_busid,
.get_vblank_counter = drm_vblank_no_hw_counter,
-- 
2.6.4



[PATCH 15/21] drm/omap: Nuke close hooks

2016-01-08 Thread Daniel Vetter
Again since the core takes care of this we can remove them. While at
it also remove the postclose hook, it's empty.

Cc: Laurent Pinchart 
Cc: Tomi Valkeinen 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/omapdrm/omap_drv.c | 29 -
 1 file changed, 29 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index dfafdb602ad2..e8b5080f6e2d 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -787,33 +787,6 @@ static void dev_lastclose(struct drm_device *dev)
}
 }

-static void dev_preclose(struct drm_device *dev, struct drm_file *file)
-{
-   struct omap_drm_private *priv = dev->dev_private;
-   struct drm_pending_event *event;
-   unsigned long flags;
-
-   DBG("preclose: dev=%p", dev);
-
-   /*
-* Unlink all pending CRTC events to make sure they won't be queued up
-* by a pending asynchronous commit.
-*/
-   spin_lock_irqsave(>event_lock, flags);
-   list_for_each_entry(event, >commit.events, link) {
-   if (event->file_priv == file) {
-   file->event_space += event->event->length;
-   event->file_priv = NULL;
-   }
-   }
-   spin_unlock_irqrestore(>event_lock, flags);
-}
-
-static void dev_postclose(struct drm_device *dev, struct drm_file *file)
-{
-   DBG("postclose: dev=%p, file=%p", dev, file);
-}
-
 static const struct vm_operations_struct omap_gem_vm_ops = {
.fault = omap_gem_fault,
.open = drm_gem_vm_open,
@@ -838,8 +811,6 @@ static struct drm_driver omap_drm_driver = {
.unload = dev_unload,
.open = dev_open,
.lastclose = dev_lastclose,
-   .preclose = dev_preclose,
-   .postclose = dev_postclose,
.set_busid = drm_platform_set_busid,
.get_vblank_counter = drm_vblank_no_hw_counter,
.enable_vblank = omap_irq_enable_vblank,
-- 
2.6.4



[PATCH 14/21] drm/msm: Nuke preclose hooks

2016-01-08 Thread Daniel Vetter
They only complete the page flip events to avoid oops when the drm
file closes. The core takes care of that now and we can remove this
code.

Cc: Rob Clark 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c |  7 ---
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c  | 11 ---
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h  |  1 -
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c |  6 --
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c  | 11 ---
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h  |  1 -
 6 files changed, 37 deletions(-)

diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c 
b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
index 28df397c3b04..909d74250de7 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
@@ -575,13 +575,6 @@ uint32_t mdp4_crtc_vblank(struct drm_crtc *crtc)
return mdp4_crtc->vblank.irqmask;
 }

-void mdp4_crtc_cancel_pending_flip(struct drm_crtc *crtc, struct drm_file 
*file)
-{
-   struct mdp4_crtc *mdp4_crtc = to_mdp4_crtc(crtc);
-   DBG("%s: cancel: %p", mdp4_crtc->name, file);
-   complete_flip(crtc, file);
-}
-
 /* set dma config, ie. the format the encoder wants. */
 void mdp4_crtc_set_config(struct drm_crtc *crtc, uint32_t config)
 {
diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c 
b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
index 5a8e3d6bcbff..1c8e330f8d98 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
@@ -179,16 +179,6 @@ static long mdp4_round_pixclk(struct msm_kms *kms, 
unsigned long rate,
}
 }

-static void mdp4_preclose(struct msm_kms *kms, struct drm_file *file)
-{
-   struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(kms));
-   struct msm_drm_private *priv = mdp4_kms->dev->dev_private;
-   unsigned i;
-
-   for (i = 0; i < priv->num_crtcs; i++)
-   mdp4_crtc_cancel_pending_flip(priv->crtcs[i], file);
-}
-
 static void mdp4_destroy(struct msm_kms *kms)
 {
struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(kms));
@@ -213,7 +203,6 @@ static const struct mdp_kms_funcs kms_funcs = {
.wait_for_crtc_commit_done = mdp4_wait_for_crtc_commit_done,
.get_format  = mdp_get_format,
.round_pixclk= mdp4_round_pixclk,
-   .preclose= mdp4_preclose,
.destroy = mdp4_destroy,
},
.set_irqmask = mdp4_set_irqmask,
diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h 
b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h
index d2c96ef431f4..9ec53b464662 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h
@@ -199,7 +199,6 @@ struct drm_plane *mdp4_plane_init(struct drm_device *dev,
enum mdp4_pipe pipe_id, bool private_plane);

 uint32_t mdp4_crtc_vblank(struct drm_crtc *crtc);
-void mdp4_crtc_cancel_pending_flip(struct drm_crtc *crtc, struct drm_file 
*file);
 void mdp4_crtc_set_config(struct drm_crtc *crtc, uint32_t config);
 void mdp4_crtc_set_intf(struct drm_crtc *crtc, enum mdp4_intf intf, int mixer);
 void mdp4_crtc_wait_for_commit_done(struct drm_crtc *crtc);
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c 
b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
index 20cee5ce4071..46682aa8870c 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
@@ -721,12 +721,6 @@ uint32_t mdp5_crtc_vblank(struct drm_crtc *crtc)
return mdp5_crtc->vblank.irqmask;
 }

-void mdp5_crtc_cancel_pending_flip(struct drm_crtc *crtc, struct drm_file 
*file)
-{
-   DBG("cancel: %p", file);
-   complete_flip(crtc, file);
-}
-
 void mdp5_crtc_set_pipeline(struct drm_crtc *crtc,
struct mdp5_interface *intf, struct mdp5_ctl *ctl)
 {
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c 
b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
index e115318402bd..5e4d16b399c7 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
@@ -117,16 +117,6 @@ static int mdp5_set_split_display(struct msm_kms *kms,
return mdp5_encoder_set_split_display(encoder, slave_encoder);
 }

-static void mdp5_preclose(struct msm_kms *kms, struct drm_file *file)
-{
-   struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
-   struct msm_drm_private *priv = mdp5_kms->dev->dev_private;
-   unsigned i;
-
-   for (i = 0; i < priv->num_crtcs; i++)
-   mdp5_crtc_cancel_pending_flip(priv->crtcs[i], file);
-}
-
 static void mdp5_destroy(struct msm_kms *kms)
 {
struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
@@ -164,7 +154,6 @@ static const struct mdp_kms_funcs kms_funcs = {
.get_format  = mdp_get_format,
.round_pixclk= mdp5_round_pixclk,
.set_split_display = mdp5_set_split_display,
-   .preclose= mdp5_preclose,
.destroy = 

[PATCH 13/21] drm/imx: Unconfuse preclose logic

2016-01-08 Thread Daniel Vetter
So this one is special, since it tries to prevent races when userspace
crashes simply by disabling the vblank machinery. Well except that imx
always has vblanks enabled, and the disable_vblank hook actually just
tries to cancel a pending pageflip. Without any locking whatsoever. Of
course this is wrong, since it'll result in the hw not actually
displaying what drm thinks is the current frontbuffer.

Well since the core takes care of the disappearing DRM fd now. So we
can nuke all this confused code without ill side-effects.

Someone else needs to audit the locking for ->newfb and
->page_flip_event and fix it up. Common approach is to reuse
dev->event_lock for this.

Cc: Sascha Hauer 
Cc: Philipp Zabel 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/imx/imx-drm-core.c | 13 -
 drivers/gpu/drm/imx/ipuv3-crtc.c   |  4 
 2 files changed, 17 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-drm-core.c 
b/drivers/gpu/drm/imx/imx-drm-core.c
index 7be7ac808304..ff94ca4a2c1e 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -171,18 +171,6 @@ static void imx_drm_disable_vblank(struct drm_device *drm, 
unsigned int pipe)
imx_drm_crtc->imx_drm_helper_funcs.disable_vblank(imx_drm_crtc->crtc);
 }

-static void imx_drm_driver_preclose(struct drm_device *drm,
-   struct drm_file *file)
-{
-   int i;
-
-   if (!file->is_master)
-   return;
-
-   for (i = 0; i < MAX_CRTC; i++)
-   imx_drm_disable_vblank(drm, i);
-}
-
 static const struct file_operations imx_drm_driver_fops = {
.owner = THIS_MODULE,
.open = drm_open,
@@ -462,7 +450,6 @@ static struct drm_driver imx_drm_driver = {
.load   = imx_drm_driver_load,
.unload = imx_drm_driver_unload,
.lastclose  = imx_drm_driver_lastclose,
-   .preclose   = imx_drm_driver_preclose,
.set_busid  = drm_platform_set_busid,
.gem_free_object= drm_gem_cma_free_object,
.gem_vm_ops = _gem_cma_vm_ops,
diff --git a/drivers/gpu/drm/imx/ipuv3-crtc.c b/drivers/gpu/drm/imx/ipuv3-crtc.c
index 30a57185bdb4..846b5f558897 100644
--- a/drivers/gpu/drm/imx/ipuv3-crtc.c
+++ b/drivers/gpu/drm/imx/ipuv3-crtc.c
@@ -285,10 +285,6 @@ static int ipu_enable_vblank(struct drm_crtc *crtc)

 static void ipu_disable_vblank(struct drm_crtc *crtc)
 {
-   struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc);
-
-   ipu_crtc->page_flip_event = NULL;
-   ipu_crtc->newfb = NULL;
 }

 static int ipu_set_interface_pix_fmt(struct drm_crtc *crtc,
-- 
2.6.4



[PATCH 12/21] drm/exynos: Remove event cancelling from postclose

2016-01-08 Thread Daniel Vetter
The core takes care of this now. And since kfree(NULL) is ok we can
simplify the function even further now.

Cc: Inki Dae 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/exynos/exynos_drm_drv.c | 14 --
 1 file changed, 14 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c 
b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index 9756797a15a5..868ab9f54f17 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -335,20 +335,6 @@ static void exynos_drm_preclose(struct drm_device *dev,

 static void exynos_drm_postclose(struct drm_device *dev, struct drm_file *file)
 {
-   struct drm_pending_event *e, *et;
-   unsigned long flags;
-
-   if (!file->driver_priv)
-   return;
-
-   spin_lock_irqsave(>event_lock, flags);
-   /* Release all events handled by page flip handler but not freed. */
-   list_for_each_entry_safe(e, et, >event_list, link) {
-   list_del(>link);
-   e->destroy(e);
-   }
-   spin_unlock_irqrestore(>event_lock, flags);
-
kfree(file->driver_priv);
file->driver_priv = NULL;
 }
-- 
2.6.4



[PATCH 11/21] drm/atmel: Nuke preclose

2016-01-08 Thread Daniel Vetter
The only thing this did was cancle pending flip events, and the core
takes care of that now.

Cc: Boris Brezillon 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 18 --
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c   | 10 --
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h   |  3 ---
 3 files changed, 31 deletions(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
index 468a14f266a7..9863291a9a54 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
@@ -280,24 +280,6 @@ static void atmel_hlcdc_crtc_destroy(struct drm_crtc *c)
kfree(crtc);
 }

-void atmel_hlcdc_crtc_cancel_page_flip(struct drm_crtc *c,
-  struct drm_file *file)
-{
-   struct atmel_hlcdc_crtc *crtc = drm_crtc_to_atmel_hlcdc_crtc(c);
-   struct drm_pending_vblank_event *event;
-   struct drm_device *dev = c->dev;
-   unsigned long flags;
-
-   spin_lock_irqsave(>event_lock, flags);
-   event = crtc->event;
-   if (event && event->base.file_priv == file) {
-   event->base.destroy(>base);
-   drm_vblank_put(dev, crtc->id);
-   crtc->event = NULL;
-   }
-   spin_unlock_irqrestore(>event_lock, flags);
-}
-
 static void atmel_hlcdc_crtc_finish_page_flip(struct atmel_hlcdc_crtc *crtc)
 {
struct drm_device *dev = crtc->base.dev;
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
index a45b32ba029e..3d8d16402d07 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
@@ -619,15 +619,6 @@ static void atmel_hlcdc_dc_connector_unplug_all(struct 
drm_device *dev)
mutex_unlock(>mode_config.mutex);
 }

-static void atmel_hlcdc_dc_preclose(struct drm_device *dev,
-   struct drm_file *file)
-{
-   struct drm_crtc *crtc;
-
-   list_for_each_entry(crtc, >mode_config.crtc_list, head)
-   atmel_hlcdc_crtc_cancel_page_flip(crtc, file);
-}
-
 static void atmel_hlcdc_dc_lastclose(struct drm_device *dev)
 {
struct atmel_hlcdc_dc *dc = dev->dev_private;
@@ -698,7 +689,6 @@ static struct drm_driver atmel_hlcdc_dc_driver = {
.driver_features = DRIVER_HAVE_IRQ | DRIVER_GEM |
   DRIVER_MODESET | DRIVER_PRIME |
   DRIVER_ATOMIC,
-   .preclose = atmel_hlcdc_dc_preclose,
.lastclose = atmel_hlcdc_dc_lastclose,
.irq_handler = atmel_hlcdc_dc_irq_handler,
.irq_preinstall = atmel_hlcdc_dc_irq_uninstall,
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h
index cf6b375bc38d..fed517f297da 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h
@@ -152,9 +152,6 @@ int atmel_hlcdc_plane_prepare_disc_area(struct 
drm_crtc_state *c_state);

 void atmel_hlcdc_crtc_irq(struct drm_crtc *c);

-void atmel_hlcdc_crtc_cancel_page_flip(struct drm_crtc *crtc,
-  struct drm_file *file);
-
 void atmel_hlcdc_crtc_suspend(struct drm_crtc *crtc);
 void atmel_hlcdc_crtc_resume(struct drm_crtc *crtc);

-- 
2.6.4



[PATCH 10/21] drm/i915: Nuke intel_modeset_preclose

2016-01-08 Thread Daniel Vetter
Now that the drm core unlinks/disarms events there's no need to do so
ourselves anymore. Nuke the code.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/i915/i915_dma.c  |  2 --
 drivers/gpu/drm/i915/intel_display.c | 21 -
 drivers/gpu/drm/i915/intel_drv.h |  1 -
 3 files changed, 24 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index a0f5659032fc..4bfa72e5a217 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1262,8 +1262,6 @@ void i915_driver_preclose(struct drm_device *dev, struct 
drm_file *file)
i915_gem_context_close(dev, file);
i915_gem_release(dev, file);
mutex_unlock(>struct_mutex);
-
-   intel_modeset_preclose(dev, file);
 }

 void i915_driver_postclose(struct drm_device *dev, struct drm_file *file)
diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index b0928b1413e2..aa7e9c04a923 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -16355,24 +16355,3 @@ intel_display_print_error_state(struct 
drm_i915_error_state_buf *m,
err_printf(m, "  VSYNC: %08x\n", error->transcoder[i].vsync);
}
 }
-
-void intel_modeset_preclose(struct drm_device *dev, struct drm_file *file)
-{
-   struct intel_crtc *crtc;
-
-   for_each_intel_crtc(dev, crtc) {
-   struct intel_unpin_work *work;
-
-   spin_lock_irq(>event_lock);
-
-   work = crtc->unpin_work;
-
-   if (work && work->event &&
-   work->event->base.file_priv == file) {
-   kfree(work->event);
-   work->event = NULL;
-   }
-
-   spin_unlock_irq(>event_lock);
-   }
-}
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index e88050aee0c1..5e7422085162 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1235,7 +1235,6 @@ enum intel_display_power_domain
 intel_display_port_aux_power_domain(struct intel_encoder *intel_encoder);
 void intel_mode_from_pipe_config(struct drm_display_mode *mode,
 struct intel_crtc_state *pipe_config);
-void intel_modeset_preclose(struct drm_device *dev, struct drm_file *file);

 int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state);
 int skl_max_scale(struct intel_crtc *crtc, struct intel_crtc_state 
*crtc_state);
-- 
2.6.4



[PATCH 09/21] drm: Clean up pending events in the core

2016-01-08 Thread Daniel Vetter
There's really no reason to not do so, instead of replicating this
for every use-case and every driver. Now we can't just nuke the events,
since that would still mean that all drm_event users would need to know
when that has happened, since calling e.g. drm_send_event isn't allowed
any more. Instead just unlink them from the file, and detect this case
and handle it appropriately in all functions.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_fops.c | 27 ++-
 include/drm/drmP.h |  2 ++
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 3d338075113c..e831537dc931 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -264,6 +264,7 @@ static int drm_open_helper(struct file *filp, struct 
drm_minor *minor)
INIT_LIST_HEAD(>fbs);
mutex_init(>fbs_lock);
INIT_LIST_HEAD(>blobs);
+   INIT_LIST_HEAD(>pending_event_list);
INIT_LIST_HEAD(>event_list);
init_waitqueue_head(>event_wait);
priv->event_space = 4096; /* set aside 4k for event buffer */
@@ -353,18 +354,16 @@ static void drm_events_release(struct drm_file *file_priv)
 {
struct drm_device *dev = file_priv->minor->dev;
struct drm_pending_event *e, *et;
-   struct drm_pending_vblank_event *v, *vt;
unsigned long flags;

spin_lock_irqsave(>event_lock, flags);

-   /* Remove pending flips */
-   list_for_each_entry_safe(v, vt, >vblank_event_list, base.link)
-   if (v->base.file_priv == file_priv) {
-   list_del(>base.link);
-   drm_vblank_put(dev, v->pipe);
-   v->base.destroy(>base);
-   }
+   /* Unlink pending events */
+   list_for_each_entry_safe(e, et, _priv->pending_event_list,
+pending_link) {
+   list_del(>pending_link);
+   e->file_priv = NULL;
+   }

/* Remove unconsumed events */
list_for_each_entry_safe(e, et, _priv->event_list, link) {
@@ -710,6 +709,7 @@ int drm_event_reserve_init(struct drm_device *dev,
file_priv->event_space -= e->length;

p->event = e;
+   list_add(>pending_link, _priv->pending_event_list);
p->file_priv = file_priv;

/* we *could* pass this in as arg, but everyone uses kfree: */
@@ -734,7 +734,10 @@ void drm_event_cancel_free(struct drm_device *dev,
 {
unsigned long flags;
spin_lock_irqsave(>event_lock, flags);
-   p->file_priv->event_space += p->event->length;
+   if (p->file_priv) {
+   p->file_priv->event_space += p->event->length;
+   list_del(>pending_link);
+   }
spin_unlock_irqrestore(>event_lock, flags);
p->destroy(p);
 }
@@ -753,6 +756,12 @@ void drm_send_event_locked(struct drm_device *dev, struct 
drm_pending_event *e)
 {
assert_spin_locked(>event_lock);

+   if (!e->file_priv) {
+   e->destroy(e);
+   return;
+   }
+
+   list_del(>pending_link);
list_add_tail(>link,
  >file_priv->event_list);
wake_up_interruptible(>file_priv->event_wait);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index ae73abf5c2cf..3d78a7406d54 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -283,6 +283,7 @@ struct drm_ioctl_desc {
 struct drm_pending_event {
struct drm_event *event;
struct list_head link;
+   struct list_head pending_link;
struct drm_file *file_priv;
pid_t pid; /* pid of requester, no guarantee it's valid by the time
  we deliver the event, for tracing only */
@@ -346,6 +347,7 @@ struct drm_file {
struct list_head blobs;

wait_queue_head_t event_wait;
+   struct list_head pending_event_list;
struct list_head event_list;
int event_space;

-- 
2.6.4



[PATCH 08/21] drm/gma500: Remove empty preclose hook

2016-01-08 Thread Daniel Vetter
I'm auditing them all, empty ones just confuse ...

Cc: Patrik Jakobsson 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/gma500/psb_drv.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index 92e7e5795398..4e1c6850520e 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -442,14 +442,6 @@ static long psb_unlocked_ioctl(struct file *filp, unsigned 
int cmd,
/* FIXME: do we need to wrap the other side of this */
 }

-/*
- * When a client dies:
- *- Check for and clean up flipped page state
- */
-static void psb_driver_preclose(struct drm_device *dev, struct drm_file *priv)
-{
-}
-
 static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
return drm_get_pci_dev(pdev, ent, );
@@ -495,7 +487,6 @@ static struct drm_driver driver = {
.load = psb_driver_load,
.unload = psb_driver_unload,
.lastclose = psb_driver_lastclose,
-   .preclose = psb_driver_preclose,
.set_busid = drm_pci_set_busid,

.num_ioctls = ARRAY_SIZE(psb_ioctls),
-- 
2.6.4



[PATCH 07/21] drm/armada: Remove NULL open/pre/postclose hooks

2016-01-08 Thread Daniel Vetter
The compiler will do this, but the void hits when grepping all the
hooks for a subsystem wide audit are slightly annoying. So remove them
for next time around.

Cc: Russell King 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/armada/armada_drv.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_drv.c 
b/drivers/gpu/drm/armada/armada_drv.c
index 3bd7e1cde99e..82043c204b76 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -188,9 +188,6 @@ static const struct file_operations armada_drm_fops = {

 static struct drm_driver armada_drm_driver = {
.load   = armada_drm_load,
-   .open   = NULL,
-   .preclose   = NULL,
-   .postclose  = NULL,
.lastclose  = armada_drm_lastclose,
.unload = armada_drm_unload,
.set_busid  = drm_platform_set_busid,
-- 
2.6.4



[PATCH 06/21] drm/fsl: Remove preclose hook

2016-01-08 Thread Daniel Vetter
Doesn't do anything, but annoys when auditing them all.

Cc: Jianwei Wang 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c 
b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
index fca97d3fc846..9648b7f9a31c 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
@@ -112,10 +112,6 @@ static int fsl_dcu_unload(struct drm_device *dev)
return 0;
 }

-static void fsl_dcu_drm_preclose(struct drm_device *dev, struct drm_file *file)
-{
-}
-
 static irqreturn_t fsl_dcu_drm_irq(int irq, void *arg)
 {
struct drm_device *dev = arg;
@@ -191,7 +187,6 @@ static struct drm_driver fsl_dcu_drm_driver = {
| DRIVER_PRIME | DRIVER_ATOMIC,
.load   = fsl_dcu_load,
.unload = fsl_dcu_unload,
-   .preclose   = fsl_dcu_drm_preclose,
.irq_handler= fsl_dcu_drm_irq,
.get_vblank_counter = drm_vblank_no_hw_counter,
.enable_vblank  = fsl_dcu_drm_enable_vblank,
-- 
2.6.4



[PATCH 05/21] drm: Create drm_send_event helpers

2016-01-08 Thread Daniel Vetter
Use them in the core vblank code and exynos/vmwgfx drivers.

Note that the difference between wake_up_all and _interruptible in
vmwgfx doesn't matter since the only waiter is the core code in
drm_fops.c. And that is interruptible.

Cc: Thomas Hellstrom 
Cc: Inki Dae 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_fops.c  | 38 +
 drivers/gpu/drm/drm_irq.c   |  7 ++
 drivers/gpu/drm/exynos/exynos_drm_g2d.c |  5 +
 drivers/gpu/drm/exynos/exynos_drm_ipp.c |  5 +
 drivers/gpu/drm/vmwgfx/vmwgfx_fence.c   |  3 +--
 include/drm/drmP.h  |  2 ++
 6 files changed, 45 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index d6542864bd95..3d338075113c 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -739,3 +739,41 @@ void drm_event_cancel_free(struct drm_device *dev,
p->destroy(p);
 }
 EXPORT_SYMBOL(drm_event_cancel_free);
+
+/**
+ * drm_send_event_locked - send DRM event to file descriptor
+ * @dev: DRM device
+ * @e: DRM event to deliver
+ *
+ * This function sends the event @e, initialized with drm_event_reserve_init(),
+ * to its associated userspace DRM file. Callers must already hold
+ * dev->event_lock, see drm_send_event() for the unlocked version.
+ */
+void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e)
+{
+   assert_spin_locked(>event_lock);
+
+   list_add_tail(>link,
+ >file_priv->event_list);
+   wake_up_interruptible(>file_priv->event_wait);
+}
+EXPORT_SYMBOL(drm_send_event_locked);
+
+/**
+ * drm_send_event - send DRM event to file descriptor
+ * @dev: DRM device
+ * @e: DRM event to deliver
+ *
+ * This function sends the event @e, initialized with drm_event_reserve_init(),
+ * to its associated userspace DRM file. This function acquires 
dev->event_lock,
+ * see drm_send_event_locked() for callers which already hold this lock.
+ */
+void drm_send_event(struct drm_device *dev, struct drm_pending_event *e)
+{
+   unsigned long irqflags;
+
+   spin_lock_irqsave(>event_lock, irqflags);
+   drm_send_event_locked(dev, e);
+   spin_unlock_irqrestore(>event_lock, irqflags);
+}
+EXPORT_SYMBOL(drm_send_event);
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index a70b29909974..3fe8dbff6058 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -983,15 +983,12 @@ static void send_vblank_event(struct drm_device *dev,
struct drm_pending_vblank_event *e,
unsigned long seq, struct timeval *now)
 {
-   assert_spin_locked(>event_lock);
-
e->event.sequence = seq;
e->event.tv_sec = now->tv_sec;
e->event.tv_usec = now->tv_usec;

-   list_add_tail(>base.link,
- >base.file_priv->event_list);
-   wake_up_interruptible(>base.file_priv->event_wait);
+   drm_send_event_locked(dev, >base);
+
trace_drm_vblank_event_delivered(e->base.pid, e->pipe,
 e->event.sequence);
 }
diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c 
b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
index 82e7f95dfed9..db56c8259f18 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
@@ -893,10 +893,7 @@ static void g2d_finish_event(struct g2d_data *g2d, u32 
cmdlist_no)
e->event.tv_usec = now.tv_usec;
e->event.cmdlist_no = cmdlist_no;

-   spin_lock_irqsave(_dev->event_lock, flags);
-   list_move_tail(>base.link, >base.file_priv->event_list);
-   wake_up_interruptible(>base.file_priv->event_wait);
-   spin_unlock_irqrestore(_dev->event_lock, flags);
+   drm_send_event(dev, >base);
 }

 static irqreturn_t g2d_irq_handler(int irq, void *dev_id)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.c 
b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
index c8819c05e2dd..1f6a6c1881d6 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_ipp.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
@@ -1520,10 +1520,7 @@ static int ipp_send_event(struct exynos_drm_ippdrv 
*ippdrv,
for_each_ipp_ops(i)
e->event.buf_id[i] = tbuf_id[i];

-   spin_lock_irqsave(_dev->event_lock, flags);
-   list_move_tail(>base.link, >base.file_priv->event_list);
-   wake_up_interruptible(>base.file_priv->event_wait);
-   spin_unlock_irqrestore(_dev->event_lock, flags);
+   drm_send_event(dev, >base);
mutex_unlock(_node->event_lock);

DRM_DEBUG_KMS("done cmd[%d]prop_id[%d]buf_id[%d]\n",
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
index eda93bf52a6e..e0edf149d9d5 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
@@ -880,9 +880,8 @@ static void vmw_event_fence_action_seq_passed(struct 
vmw_fence_action *action)
}

list_del_init(>fpriv_head);
- 

[PATCH 04/21] drm/vmwgfx: Use the new event init/free functions

2016-01-08 Thread Daniel Vetter
Cc: Rob Clark 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 32 
 1 file changed, 8 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
index 8e689b439890..eda93bf52a6e 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
@@ -1025,38 +1025,26 @@ static int vmw_event_fence_action_create(struct 
drm_file *file_priv,
struct vmw_event_fence_pending *event;
struct vmw_fence_manager *fman = fman_from_fence(fence);
struct drm_device *dev = fman->dev_priv->dev;
-   unsigned long irq_flags;
int ret;

-   spin_lock_irqsave(>event_lock, irq_flags);
-
-   ret = (file_priv->event_space < sizeof(event->event)) ? -EBUSY : 0;
-   if (likely(ret == 0))
-   file_priv->event_space -= sizeof(event->event);
-
-   spin_unlock_irqrestore(>event_lock, irq_flags);
-
-   if (unlikely(ret != 0)) {
-   DRM_ERROR("Failed to allocate event space for this file.\n");
-   goto out_no_space;
-   }
-
-
event = kzalloc(sizeof(*event), GFP_KERNEL);
if (unlikely(event == NULL)) {
DRM_ERROR("Failed to allocate an event.\n");
ret = -ENOMEM;
-   goto out_no_event;
+   goto out_no_space;
}

event->event.base.type = DRM_VMW_EVENT_FENCE_SIGNALED;
event->event.base.length = sizeof(*event);
event->event.user_data = user_data;

-   event->base.event = >event.base;
-   event->base.file_priv = file_priv;
-   event->base.destroy = (void (*) (struct drm_pending_event *)) kfree;
+   ret = drm_event_reserve_init(dev, file_priv, >base, 
>event.base);

+   if (unlikely(ret != 0)) {
+   DRM_ERROR("Failed to allocate event space for this file.\n");
+   kfree(event);
+   goto out_no_space;
+   }

if (flags & DRM_VMW_FE_FLAG_REQ_TIME)
ret = vmw_event_fence_action_queue(file_priv, fence,
@@ -1076,11 +1064,7 @@ static int vmw_event_fence_action_create(struct drm_file 
*file_priv,
return 0;

 out_no_queue:
-   event->base.destroy(>base);
-out_no_event:
-   spin_lock_irqsave(>event_lock, irq_flags);
-   file_priv->event_space += sizeof(*event);
-   spin_unlock_irqrestore(>event_lock, irq_flags);
+   drm_event_cancel_free(dev, >base);
 out_no_space:
return ret;
 }
-- 
2.6.4



[PATCH 03/21] drm/exynos: Use the new event init/free functions

2016-01-08 Thread Daniel Vetter
Also fixes a bug in IPP with not correctly checking/allocating for
space in the event space. Not a too serious bug since it's not a
real ringbuffer, just a limit to avoid too much kernel allocations.

Cc: Rob Clark 
Cc: Inki Dae 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/exynos/exynos_drm_g2d.c | 31 ---
 drivers/gpu/drm/exynos/exynos_drm_ipp.c | 23 +--
 2 files changed, 17 insertions(+), 37 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c 
b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
index c17efdb238a6..82e7f95dfed9 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
@@ -1072,7 +1072,6 @@ int exynos_g2d_set_cmdlist_ioctl(struct drm_device 
*drm_dev, void *data,
struct drm_exynos_pending_g2d_event *e;
struct g2d_cmdlist_node *node;
struct g2d_cmdlist *cmdlist;
-   unsigned long flags;
int size;
int ret;

@@ -1094,21 +1093,8 @@ int exynos_g2d_set_cmdlist_ioctl(struct drm_device 
*drm_dev, void *data,
node->event = NULL;

if (req->event_type != G2D_EVENT_NOT) {
-   spin_lock_irqsave(_dev->event_lock, flags);
-   if (file->event_space < sizeof(e->event)) {
-   spin_unlock_irqrestore(_dev->event_lock, flags);
-   ret = -ENOMEM;
-   goto err;
-   }
-   file->event_space -= sizeof(e->event);
-   spin_unlock_irqrestore(_dev->event_lock, flags);
-
e = kzalloc(sizeof(*node->event), GFP_KERNEL);
if (!e) {
-   spin_lock_irqsave(_dev->event_lock, flags);
-   file->event_space += sizeof(e->event);
-   spin_unlock_irqrestore(_dev->event_lock, flags);
-
ret = -ENOMEM;
goto err;
}
@@ -1116,9 +1102,12 @@ int exynos_g2d_set_cmdlist_ioctl(struct drm_device 
*drm_dev, void *data,
e->event.base.type = DRM_EXYNOS_G2D_EVENT;
e->event.base.length = sizeof(e->event);
e->event.user_data = req->user_data;
-   e->base.event = >event.base;
-   e->base.file_priv = file;
-   e->base.destroy = (void (*) (struct drm_pending_event *)) kfree;
+
+   ret = drm_event_reserve_init(drm_dev, file, >base, 
>event.base);
+   if (ret) {
+   kfree(e);
+   goto err;
+   }

node->event = e;
}
@@ -1219,12 +1208,8 @@ int exynos_g2d_set_cmdlist_ioctl(struct drm_device 
*drm_dev, void *data,
 err_unmap:
g2d_unmap_cmdlist_gem(g2d, node, file);
 err_free_event:
-   if (node->event) {
-   spin_lock_irqsave(_dev->event_lock, flags);
-   file->event_space += sizeof(e->event);
-   spin_unlock_irqrestore(_dev->event_lock, flags);
-   kfree(node->event);
-   }
+   if (node->event)
+   drm_event_cancel_free(drm_dev, >event->base);
 err:
g2d_put_cmdlist(g2d, node);
return ret;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.c 
b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
index 67d24236e745..c8819c05e2dd 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_ipp.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
@@ -618,27 +618,18 @@ static void ipp_clean_mem_nodes(struct drm_device 
*drm_dev,
mutex_unlock(_node->mem_lock);
 }

-static void ipp_free_event(struct drm_pending_event *event)
-{
-   kfree(event);
-}
-
 static int ipp_get_event(struct drm_device *drm_dev,
struct drm_exynos_ipp_cmd_node *c_node,
struct drm_exynos_ipp_queue_buf *qbuf)
 {
struct drm_exynos_ipp_send_event *e;
-   unsigned long flags;
+   int ret;

DRM_DEBUG_KMS("ops_id[%d]buf_id[%d]\n", qbuf->ops_id, qbuf->buf_id);

e = kzalloc(sizeof(*e), GFP_KERNEL);
-   if (!e) {
-   spin_lock_irqsave(_dev->event_lock, flags);
-   c_node->filp->event_space += sizeof(e->event);
-   spin_unlock_irqrestore(_dev->event_lock, flags);
+   if (!e)
return -ENOMEM;
-   }

/* make event */
e->event.base.type = DRM_EXYNOS_IPP_EVENT;
@@ -646,9 +637,13 @@ static int ipp_get_event(struct drm_device *drm_dev,
e->event.user_data = qbuf->user_data;
e->event.prop_id = qbuf->prop_id;
e->event.buf_id[EXYNOS_DRM_OPS_DST] = qbuf->buf_id;
-   e->base.event = >event.base;
-   e->base.file_priv = c_node->filp;
-   e->base.destroy = ipp_free_event;
+
+   ret = drm_event_reserve_init(drm_dev, c_node->filp, >base, 
>event.base);
+   if (ret) {
+   kfree(e);
+   return ret;
+   }
+
mutex_lock(_node->event_lock);
list_add_tail(>base.link, _node->event_list);

[PATCH 02/21] drm: Add functions to setup/tear down drm_events.

2016-01-08 Thread Daniel Vetter
An attempt at not spreading out the file_priv->event_space stuff out
quite so far and wide.  And I think fixes something in ipp_get_event()
that is broken (or if they are doing something more weird/subtle, then
breaks it in a fun way).

Based upon a patch from Rob Clark, rebased and polished.

Cc: Rob Clark 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_atomic.c | 44 -
 drivers/gpu/drm/drm_crtc.c   | 36 +++-
 drivers/gpu/drm/drm_fops.c   | 67 
 include/drm/drmP.h   |  7 -
 4 files changed, 94 insertions(+), 60 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 3f74193885f1..8fb469c4e4b8 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -1347,44 +1347,23 @@ static struct drm_pending_vblank_event 
*create_vblank_event(
struct drm_device *dev, struct drm_file *file_priv, uint64_t 
user_data)
 {
struct drm_pending_vblank_event *e = NULL;
-   unsigned long flags;
-
-   spin_lock_irqsave(>event_lock, flags);
-   if (file_priv->event_space < sizeof e->event) {
-   spin_unlock_irqrestore(>event_lock, flags);
-   goto out;
-   }
-   file_priv->event_space -= sizeof e->event;
-   spin_unlock_irqrestore(>event_lock, flags);
+   int ret;

e = kzalloc(sizeof *e, GFP_KERNEL);
-   if (e == NULL) {
-   spin_lock_irqsave(>event_lock, flags);
-   file_priv->event_space += sizeof e->event;
-   spin_unlock_irqrestore(>event_lock, flags);
-   goto out;
-   }
+   if (!e)
+   return NULL;

e->event.base.type = DRM_EVENT_FLIP_COMPLETE;
-   e->event.base.length = sizeof e->event;
+   e->event.base.length = sizeof(e->event);
e->event.user_data = user_data;
-   e->base.event = >event.base;
-   e->base.file_priv = file_priv;
-   e->base.destroy = (void (*) (struct drm_pending_event *)) kfree;
-
-out:
-   return e;
-}

-static void destroy_vblank_event(struct drm_device *dev,
-   struct drm_file *file_priv, struct drm_pending_vblank_event *e)
-{
-   unsigned long flags;
+   ret = drm_event_reserve_init(dev, file_priv, >base, >event.base);
+   if (ret) {
+   kfree(e);
+   return NULL;
+   }

-   spin_lock_irqsave(>event_lock, flags);
-   file_priv->event_space += sizeof e->event;
-   spin_unlock_irqrestore(>event_lock, flags);
-   kfree(e);
+   return e;
 }

 static int atomic_set_prop(struct drm_atomic_state *state,
@@ -1646,8 +1625,7 @@ out:
if (!crtc_state->event)
continue;

-   destroy_vblank_event(dev, file_priv,
-crtc_state->event);
+   drm_event_cancel_free(dev, _state->event->base);
}
}

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 1e75a145834a..60a4184d41b7 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -5264,7 +5264,6 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
struct drm_crtc *crtc;
struct drm_framebuffer *fb = NULL;
struct drm_pending_vblank_event *e = NULL;
-   unsigned long flags;
int ret = -EINVAL;

if (page_flip->flags & ~DRM_MODE_PAGE_FLIP_FLAGS ||
@@ -5315,41 +5314,26 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
}

if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT) {
-   ret = -ENOMEM;
-   spin_lock_irqsave(>event_lock, flags);
-   if (file_priv->event_space < sizeof(e->event)) {
-   spin_unlock_irqrestore(>event_lock, flags);
-   goto out;
-   }
-   file_priv->event_space -= sizeof(e->event);
-   spin_unlock_irqrestore(>event_lock, flags);
-
-   e = kzalloc(sizeof(*e), GFP_KERNEL);
-   if (e == NULL) {
-   spin_lock_irqsave(>event_lock, flags);
-   file_priv->event_space += sizeof(e->event);
-   spin_unlock_irqrestore(>event_lock, flags);
+   e = kzalloc(sizeof *e, GFP_KERNEL);
+   if (!e) {
+   ret = -ENOMEM;
goto out;
}
-
e->event.base.type = DRM_EVENT_FLIP_COMPLETE;
e->event.base.length = sizeof(e->event);
e->event.user_data = page_flip->user_data;
-   e->base.event = >event.base;
-   e->base.file_priv = file_priv;
-   e->base.destroy =
-   (void (*) (struct drm_pending_event *)) kfree;
+   ret = drm_event_reserve_init(dev, file_priv, >base, 
>event.base);
+   if (ret) {

[PATCH 01/21] drm: kerneldoc for drm_fops.c

2016-01-08 Thread Daniel Vetter
Just prep work before I throw more drm_event refactorings on top.

Signed-off-by: Daniel Vetter 
---
 Documentation/DocBook/gpu.tmpl |  48 +--
 drivers/gpu/drm/drm_fops.c | 129 ++---
 include/drm/drmP.h |  17 +++---
 3 files changed, 117 insertions(+), 77 deletions(-)

diff --git a/Documentation/DocBook/gpu.tmpl b/Documentation/DocBook/gpu.tmpl
index 03535a7712eb..c434501c6868 100644
--- a/Documentation/DocBook/gpu.tmpl
+++ b/Documentation/DocBook/gpu.tmpl
@@ -2886,52 +2886,8 @@ void (*postclose) (struct drm_device *, struct drm_file 
*);
 
 
   File Operations
-  const struct file_operations *fops
-  File operations for the DRM device node.
-  
-Drivers must define the file operations structure that forms the DRM
-   userspace API entry point, even though most of those operations are
-   implemented in the DRM core. The open,
-   release and ioctl
-   operations are handled by
-   
-   .owner = THIS_MODULE,
-   .open = drm_open,
-   .release = drm_release,
-   .unlocked_ioctl = drm_ioctl,
-  #ifdef CONFIG_COMPAT
-   .compat_ioctl = drm_compat_ioctl,
-  #endif
-
-  
-  
-Drivers that implement private ioctls that requires 32/64bit
-   compatibility support must provide their own
-   compat_ioctl handler that processes private
-   ioctls and calls drm_compat_ioctl for core ioctls.
-  
-  
-The read and poll
-   operations provide support for reading DRM events and polling them. They
-   are implemented by
-   
-   .poll = drm_poll,
-   .read = drm_read,
-   .llseek = no_llseek,
-   
-  
-  
-The memory mapping implementation varies depending on how the driver
-   manages memory. Pre-GEM drivers will use drm_mmap,
-   while GEM-aware drivers will use drm_gem_mmap. See
-   .
-   
-   .mmap = drm_gem_mmap,
-   
-  
-  
-No other file operation is supported by the DRM API.
-  
+!Pdrivers/gpu/drm/drm_fops.c file operations
+!Edrivers/gpu/drm/drm_fops.c
 
 
   IOCTLs
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 359ec13cdf9d..73075a1fa380 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -1,4 +1,4 @@
-/**
+/*
  * \file drm_fops.c
  * File operations for DRM
  *
@@ -44,6 +44,46 @@
 /* from BKL pushdown */
 DEFINE_MUTEX(drm_global_mutex);

+/**
+ * DOC: file operations
+ *
+ * Drivers must define the file operations structure that forms the DRM
+ * userspace API entry point, even though most of those operations are
+ * implemented in the DRM core. The mandatory functions are drm_open(),
+ * drm_read(), drm_ioctl() and drm_compat_ioctl if CONFIG_COMPAT is enabled.
+ * Drivers which implement private ioctls that require 32/64 bit compatibility
+ * support must provided their onw .compat_ioctl() handler that processes
+ * private ioctls and calls drm_compat_ioctl() for core ioctls.
+ *
+ * In addition drm_read() and drm_poll() provide support for DRM events. DRM
+ * events are a generic and extensible means to send asynchronous events to
+ * userspace through the file descriptor. They are used to send vblank event 
and
+ * page flip completions by the KMS API. But drivers can also use it for their
+ * own needs, e.g. to signal completion of rendering.
+ *
+ * The memory mapping implementation will vary depending on how the driver
+ * manages memory. Legacy drivers will use the deprecated drm_legacy_mmap()
+ * function, modern drivers should use one of the provided memory-manager
+ * specific implementations. For GEM-based drivers this is drm_gem_mmap().
+ *
+ * No other file operations are supported by the DRM userspace API. Overall the
+ * following is an example #file_operations structure:
+ *
+ * static const example_drm_fops = {
+ * .owner = THIS_MODULE,
+ * .open = drm_open,
+ * .release = drm_release,
+ * .unlocked_ioctl = drm_ioctl,
+ * #ifdef CONFIG_COMPAT
+ * .compat_ioctl = drm_compat_ioctl,
+ * #endif
+ * .poll = drm_poll,
+ * .read = drm_read,
+ * .llseek = no_llseek,
+ * .mmap = drm_gem_mmap,
+ * };
+ */
+
 static int drm_open_helper(struct file *filp, struct drm_minor *minor);

 static int drm_setup(struct drm_device * dev)
@@ -67,15 +107,17 @@ static int drm_setup(struct drm_device * dev)
 }

 /**
- * Open file.
+ * drm_open - open method for DRM file
+ * @inode: device inode
+ * @filp: file pointer.
  *
- * \param inode device inode
- * \param filp file pointer.
- * \return zero on success or a negative number on failure.
+ * This function must be used by drivers as their .open() #file_operations
+ * method. It looks up the correct DRM device and instantiates all the per-file
+ * resources for it.
+ *
+ * RETURNS:
  *
- * Searches the DRM 

[PATCH 00/21] drm_event cleanup

2016-01-08 Thread Daniel Vetter
Hi all,

This patch series is inspired by a WIP patch from Rob Clark to consolidate the
drm_event handling a bit. I've went a bit further and also moved the pending
event handling and unlinking into the core, which allows us to nuke a bunch of
code from drivers who all copypasted this themselves. Plus fix up all the others
who failed to handle this correctly.

Net -500 lines of code, plus kerneldoc for drm_fops.c and all the new functions
as bonus.

Comments and review highly welcome as usual.

Cheers, Daniel

Daniel Vetter (21):
  drm: kerneldoc for drm_fops.c
  drm: Add functions to setup/tear down drm_events.
  drm/exynos: Use the new event init/free functions
  drm/vmwgfx: Use the new event init/free functions
  drm: Create drm_send_event helpers
  drm/fsl: Remove preclose hook
  drm/armada: Remove NULL open/pre/postclose hooks
  drm/gma500: Remove empty preclose hook
  drm: Clean up pending events in the core
  drm/i915: Nuke intel_modeset_preclose
  drm/atmel: Nuke preclose
  drm/exynos: Remove event cancelling from postclose
  drm/imx: Unconfuse preclose logic
  drm/msm: Nuke preclose hooks
  drm/omap: Nuke close hooks
  drm/rcar: Nuke preclose hook
  drm/shmob: Nuke preclose hook
  drm/tegra: Stop cancelling page flip events
  drm/tilcdc: Nuke preclose hook
  drm/vc4: Nuke preclose hook
  drm/vmwgfx: Nuke preclose hook

 Documentation/DocBook/gpu.tmpl |  48 +
 drivers/gpu/drm/armada/armada_drv.c|   3 -
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c |  18 --
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c   |  10 -
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h   |   3 -
 drivers/gpu/drm/drm_atomic.c   |  44 ++---
 drivers/gpu/drm/drm_crtc.c |  36 +---
 drivers/gpu/drm/drm_fops.c | 259 ++---
 drivers/gpu/drm/drm_irq.c  |   7 +-
 drivers/gpu/drm/exynos/exynos_drm_drv.c|  14 --
 drivers/gpu/drm/exynos/exynos_drm_g2d.c|  36 +---
 drivers/gpu/drm/exynos/exynos_drm_ipp.c|  28 +--
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c  |   5 -
 drivers/gpu/drm/gma500/psb_drv.c   |   9 -
 drivers/gpu/drm/i915/i915_dma.c|   2 -
 drivers/gpu/drm/i915/intel_display.c   |  21 --
 drivers/gpu/drm/i915/intel_drv.h   |   1 -
 drivers/gpu/drm/imx/imx-drm-core.c |  13 --
 drivers/gpu/drm/imx/ipuv3-crtc.c   |   4 -
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c   |   7 -
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c|  11 --
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h|   1 -
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c   |   6 -
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c|  11 --
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h|   1 -
 drivers/gpu/drm/omapdrm/omap_drv.c |  29 ---
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c |  20 --
 drivers/gpu/drm/rcar-du/rcar_du_crtc.h |   2 -
 drivers/gpu/drm/rcar-du/rcar_du_drv.c  |  10 -
 drivers/gpu/drm/shmobile/shmob_drm_crtc.c  |  20 --
 drivers/gpu/drm/shmobile/shmob_drm_crtc.h  |   2 -
 drivers/gpu/drm/shmobile/shmob_drm_drv.c   |   8 -
 drivers/gpu/drm/tegra/dc.c |  17 --
 drivers/gpu/drm/tegra/drm.c|   3 -
 drivers/gpu/drm/tegra/drm.h|   1 -
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c   |  20 --
 drivers/gpu/drm/tilcdc/tilcdc_drv.c|   8 -
 drivers/gpu/drm/tilcdc/tilcdc_drv.h|   1 -
 drivers/gpu/drm/vc4/vc4_crtc.c |  20 --
 drivers/gpu/drm/vc4/vc4_drv.c  |  10 -
 drivers/gpu/drm/vc4/vc4_drv.h  |   1 -
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c|  10 -
 drivers/gpu/drm/vmwgfx/vmwgfx_fence.c  |  73 +--
 drivers/gpu/drm/vmwgfx/vmwgfx_fence.h  |   2 -
 include/drm/drmP.h |  26 ++-
 45 files changed, 299 insertions(+), 582 deletions(-)

-- 
2.6.4



AMD: amdgpu/radeonsi support for mobile FirePro?

2016-01-08 Thread Felix Schwarz
Am 08.01.2016 um 21:00 schrieb Alex G.S.:
> What's the support status of the  AMD FirePro W5170M and AMD FirePro W5130M. 
> I'm confused as to whether these will support 'radeonsi' or 'amdgpu'. 

I think that is a false dichotomy. The (free) Linux driver consists of a
kernel part and a (or actual several) userspace components.

For the kernel part there is the "radeon" driver and the new "amdgpu" driver.
Mesa contains a "r600g" and a "radeonsi" part (+ other drivers for really old 
hw).

Even the newest GCN 1.2 cards are powered by radeonsi in userspace - just
using the amdgpu kernel driver.

According to [1] both the FirePro W5170M and the FirePro W5130M are GCN 1.0
cards which means - IIRC(!) - that they use the "radeon" kernel driver (and
the radeonsi mesa driver.

[1]
http://www.anandtech.com/show/9684/amd-announces-firepro-mobile-w7170m-w5170m-w5130m



amdgpu/radeonsi support for mobile FirePro?

2016-01-08 Thread Bridgman, John
I'm pretty sure that the 5170M and 5130M are both based on the Cape Verde GPU, 
so they would use the radeon stack rather than the amdgpu stack. Note that 
"radeonsi" refers to the Mesa GL driver, which is used with both radeon and 
amdgpu - it's primarily the kernel driver that is different between the stacks.

You can run lspci -nn to get the PCI IDs for the parts (if you have access to 
HW). If not, I believe the DID for 5170M was 0x6820 but it can vary from one 
OEM to the next. Couldn't find a reference ID for the 5130M but 6821 might be 
it.

Support for the parts should be pretty solid although if the IDs aren't yet in 
the driver source then the drivers won't recognize them until that is changed.

From: dri-devel [mailto:dri-devel-boun...@lists.freedesktop.org] On Behalf Of 
Alex G.S.
Sent: Friday, January 08, 2016 3:01 PM
To: dri-devel at lists.freedesktop.org
Subject: AMD: amdgpu/radeonsi support for mobile FirePro?

Dear Radeon Devs,

What's the support status of the  AMD FirePro W5170M and AMD FirePro W5130M.  
I'm confused as to whether these will support 'radeonsi' or 'amdgpu'.  After 
doing exhaustive research I've come across codenames like Tropo XT/LE and Mars 
XT/LE.  On some forums a pci-id was mentioned '6821' but I can't find this 
anywhere in the pcidb lists in either 'xf86-video-amdgpu' or 'xf86-video-ati'.

When I looked at the the Radeon feature matrix on [1] I'm unable to categorize 
these two GPU models into any of the categories S.Islands, C.Islands or 
V.Islands.  So are these GPU's supported by 'radeonsi' or by 'amdgpu'?  If 
they're 'radeonsi' what's the support like for those models, can I expect 
relatively good performance?

Thank you!

--- Alex G.S.

[1] http://xorg.freedesktop.org/wiki/RadeonFeature/
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20160108/1f09f919/attachment-0001.html>


[PATCH 2/2] drm/vmwgfx: Fix a width / pitch mismatch on framebuffer updates

2016-01-08 Thread Thomas Hellstrom
When the framebuffer is a vmwgfx dma buffer and a proxy surface is
created, the vmw_kms_update_proxy() function requires that the proxy
surface width and the framebuffer pitch are compatible, otherwise
display corruption occurs as seen in gnome-shell/native with software
3D. Since the framebuffer pitch is determined by user-space, allocate
a proxy surface the width of which is based on the framebuffer pitch
rather than on the framebuffer width.

Cc: 
Reported-by: Raphael Hertzog 
Tested-by:  Mati Aharoni 
Signed-off-by: Thomas Hellstrom 
Reviewed-by: Brian Paul 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 9b4bb9e..7c2e118 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -763,21 +763,25 @@ static int vmw_create_dmabuf_proxy(struct drm_device *dev,
uint32_t format;
struct drm_vmw_size content_base_size;
struct vmw_resource *res;
+   unsigned int bytes_pp;
int ret;

switch (mode_cmd->depth) {
case 32:
case 24:
format = SVGA3D_X8R8G8B8;
+   bytes_pp = 4;
break;

case 16:
case 15:
format = SVGA3D_R5G6B5;
+   bytes_pp = 2;
break;

case 8:
format = SVGA3D_P8;
+   bytes_pp = 1;
break;

default:
@@ -785,7 +789,7 @@ static int vmw_create_dmabuf_proxy(struct drm_device *dev,
return -EINVAL;
}

-   content_base_size.width  = mode_cmd->width;
+   content_base_size.width  = mode_cmd->pitch / bytes_pp;
content_base_size.height = mode_cmd->height;
content_base_size.depth  = 1;

-- 
2.4.3




[PATCH 1/2] drm/vmwgfx: Fix an incorrect lock check

2016-01-08 Thread Thomas Hellstrom
With CONFIG_SMP=n and CONFIG_DEBUG_SPINLOCK=y the vmwgfx kernel module
would unconditionally throw a bug when checking for a held spinlock
in the command buffer code. Fix this by using a lockdep check.

Cc: 
Reported-and-tested-by: Tetsuo Handa 
Signed-off-by: Thomas Hellstrom 
Reviewed-by: Sinclair Yeh 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
index 6377e81..67cebb2 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
@@ -247,7 +247,7 @@ static void __vmw_cmdbuf_header_free(struct 
vmw_cmdbuf_header *header)
 {
struct vmw_cmdbuf_man *man = header->man;

-   BUG_ON(!spin_is_locked(>lock));
+   lockdep_assert_held_once(>lock);

if (header->inline_space) {
vmw_cmdbuf_header_inline_free(header);
-- 
2.4.3




[PATCH 0/2] Last minute 4.4 fixes

2016-01-08 Thread Thomas Hellstrom
Dave,
A comple of small but important fixes for vmwgfx.
Not sure there will be time to get them in though.

/Thomas





[PATCH] drm: Release driver references to handle before making it available again

2016-01-08 Thread Chris Wilson
When userspace closes a handle, we remove it from the file->object_idr
and then tell the driver to drop its references to that file/handle.
However, as the file/handle is already available again for reuse, it may
be reallocated back to userspace and active on a new object before the
driver has had a chance to drop the old file/handle references.

Whilst calling back into the driver, we have to drop the
file->table_lock spinlock and so to prevent reusing the closed handle we
mark that handle as stale in the idr, perform the callback and then
remove the handle. It is then possible for a lookup on that handle to
return an error object and so all callers of idr_find(file->object_idr)
need to check against IS_ERR_OR_NULL() instead.

Signed-off-by: Chris Wilson 
Cc: dri-devel at lists.freedesktop.org
Cc: David Airlie 
Cc: Lucas Stach 
Cc: Russell King 
Cc: Christian Gmeiner 
Cc: Daniel Vetter 
Cc: Jani Nikula 
Cc: Rob Clark 
Cc: Eric Anholt 
Cc: Dan Carpenter 
Cc: Ville Syrjälä 
---
 drivers/gpu/drm/drm_gem.c| 11 +++
 drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c |  2 +-
 drivers/gpu/drm/i915/i915_gem_execbuffer.c   |  2 +-
 drivers/gpu/drm/msm/msm_gem_submit.c |  2 +-
 drivers/gpu/drm/vc4/vc4_gem.c|  2 +-
 5 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 2e8c77e71e1f..c56a0b49d829 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -294,18 +294,21 @@ drm_gem_handle_delete(struct drm_file *filp, u32 handle)
spin_lock(>table_lock);

/* Check if we currently have a reference on the object */
-   obj = idr_find(>object_idr, handle);
-   if (obj == NULL) {
+   obj = idr_replace(>object_idr, ERR_PTR(-ENOENT), handle);
+   if (IS_ERR(obj)) {
spin_unlock(>table_lock);
return -EINVAL;
}
dev = obj->dev;
+   spin_unlock(>table_lock);

/* Release reference and decrement refcount. */
+   drm_gem_object_release_handle(handle, obj, filp);
+
+   spin_lock(>table_lock);
idr_remove(>object_idr, handle);
spin_unlock(>table_lock);

-   drm_gem_object_release_handle(handle, obj, filp);
return 0;
 }
 EXPORT_SYMBOL(drm_gem_handle_delete);
@@ -597,7 +600,7 @@ drm_gem_object_lookup(struct drm_device *dev, struct 
drm_file *filp,

/* Check if we currently have a reference on the object */
obj = idr_find(>object_idr, handle);
-   if (obj == NULL) {
+   if (IS_ERR_OR_NULL(obj)) {
spin_unlock(>table_lock);
return NULL;
}
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c 
b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
index 1aba01a999df..77b549cb1301 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
@@ -78,7 +78,7 @@ static int submit_lookup_objects(struct etnaviv_gem_submit 
*submit,
 * all under single table_lock just hit object_idr directly:
 */
obj = idr_find(>object_idr, bo->handle);
-   if (!obj) {
+   if (IS_ERR_OR_NULL(obj)) {
DRM_ERROR("invalid handle %u at index %u\n",
  bo->handle, i);
ret = -EINVAL;
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c 
b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index dccb517361b3..500bcff9ad48 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -106,7 +106,7 @@ eb_lookup_vmas(struct eb_vmas *eb,
 * or create the VMA without using GFP_ATOMIC */
for (i = 0; i < args->buffer_count; i++) {
obj = to_intel_bo(idr_find(>object_idr, exec[i].handle));
-   if (obj == NULL) {
+   if (IS_ERR_OR_NULL(obj)) {
spin_unlock(>table_lock);
DRM_DEBUG("Invalid object handle %d at index %d\n",
   exec[i].handle, i);
diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c 
b/drivers/gpu/drm/msm/msm_gem_submit.c
index 6d7cd3fe21e7..c6d7abd53d20 100644
--- a/drivers/gpu/drm/msm/msm_gem_submit.c
+++ b/drivers/gpu/drm/msm/msm_gem_submit.c
@@ -90,7 +90,7 @@ static int submit_lookup_objects(struct msm_gem_submit 
*submit,
 * all under single table_lock just hit object_idr directly:
 */
obj = idr_find(>object_idr, submit_bo.handle);
-   if (!obj) {
+   if (IS_ERR_OR_NULL(obj)) {
DRM_ERROR("invalid handle %u at index %u\n", 
submit_bo.handle, i);
ret = -EINVAL;
goto out_unlock;
diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
index 48ce30a6f4b5..9138702a1c67 100644
--- 

[PATCH RFC 1/2] clk: sunxi: Add sun8i display support

2016-01-08 Thread Jean-Francois Moine
On Wed, 6 Jan 2016 10:39:51 +0800
Chen-Yu Tsai  wrote:

> First of all, please include the clk subsystem maintainers and the
> linux-clk mailing list for all clk related patches.

OK.

> On Wed, Jan 6, 2016 at 2:28 AM, Jean-Francois Moine  
> wrote:
> > Add the clock types which are used by the sun8i family for video.
> 
> These clocks first appeared in the A31.

Sorry, I have the documentation of only some sun8i SoCs.

> > Signed-off-by: Jean-Francois Moine 
> > ---
> >  drivers/clk/sunxi/Makefile|   1 +
> >  drivers/clk/sunxi/clk-sun8i-display.c | 247 
> > ++
> 
> Please split this into 2 patches, and 2 files: one for PLL3, named
> clk-sun6i-pll3.c, and one for the display mod clocks, named
> clk-sun6i-display.c

No problem.

[snip]
> > diff --git a/drivers/clk/sunxi/clk-sun8i-display.c 
> > b/drivers/clk/sunxi/clk-sun8i-display.c
> > new file mode 100644
> > index 000..eded572
> > --- /dev/null
> > +++ b/drivers/clk/sunxi/clk-sun8i-display.c
> > @@ -0,0 +1,247 @@
> > +/*
> > + * Copyright 2015 Jean-Francois Moine 
> > + *
> > + * 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 
> > +
> > +static DEFINE_SPINLOCK(sun8i_display_lock);
> > +
> > +/* PLL3 (video) and PLL10 (de) */
> > +struct clk_fact {
> > +   struct clk_hw hw;
> > +   void __iomem *reg;
> > +};
> > +#define to_clk_fact(_hw) container_of(_hw, struct clk_fact, hw)
> 
> What does fact stand for?

pre-divide plus factor. Have you a better name?

> > +
> > +#define SUN8I_PLL3_MSHIFT  0
> > +#define SUN8I_PLL3_MMASK   0x0f
> 
> You can use GENMASK for these. Note that GENMASK is inclusive on both ends.
> 
> > +#define SUN8I_PLL3_NSHIFT  8
> > +#define SUN8I_PLL3_NMASK   0x7f
> > +#define SUN8I_PLL3_MODE_SEL0x0100
> > +#define SUN8I_PLL3_FRAC_CLK0x0200
> 
> Please use the BIT() macros.

OK.

> > +
> > +static int sun8i_pll3_get_fact(unsigned long rate,
> > +   unsigned long parent_rate,
> > +   unsigned long *n, unsigned long *m)
> > +{
> > +   if (rate == 29700)
> > +   return 1;
> > +   if (rate == 27000)
> > +   return 0;
> > +   rational_best_approximation(rate, parent_rate,
> > +   SUN8I_PLL3_NMASK + 1, SUN8I_PLL3_MMASK + 1,
> > +   n, m);
> > +   return -1;
> > +}
> > +
> > +static unsigned long sun8i_pll3_recalc_rate(struct clk_hw *hw,
> > +   unsigned long parent_rate)
> > +{
> > +   struct clk_fact *fact = to_clk_fact(hw);
> > +   u32 reg;
> > +   u32 n, m;
> > +
> > +   reg = readl(fact->reg);
> > +   if (reg & SUN8I_PLL3_MODE_SEL) {
> > +   n = (reg >> SUN8I_PLL3_NSHIFT) & SUN8I_PLL3_NMASK;
> > +   m = (reg >> SUN8I_PLL3_MSHIFT) & SUN8I_PLL3_MMASK;
> > +   return parent_rate / (m + 1) * (n + 1);
> > +   }
> > +   if (reg & SUN8I_PLL3_FRAC_CLK)
> > +   return 29700;
> > +   return 27000;
> > +}
> > +
> > +static long sun8i_pll3_round_rate(struct clk_hw *hw, unsigned long rate,
> > +   unsigned long *parent_rate)
> > +{
> > +   int frac;
> > +   unsigned long n, m;
> > +
> > +   frac = sun8i_pll3_get_fact(rate, *parent_rate, , );
> > +   if (frac == 1)
> > +   return 29700;
> > +   if (frac == 0)
> > +   return 27000;
> > +   return (*parent_rate * n) / m;
> 
> The ordering is different from the one in recalc_rate. Considering
> integer rounding, would the results be different?

Maybe. But, you are right, 'm', as a pre-divider, should be before 'n'.

> > +}
> > +
> > +static int sun8i_pll3_set_rate(struct clk_hw *hw, unsigned long rate,
> > +   unsigned long parent_rate)
> > +{
> > +   struct clk_fact *fact = to_clk_fact(hw);
> > +   u32 reg;
> > +   int frac;
> > +   unsigned long n, m;
> > +
> > +   reg = readl(fact->reg) &
> > +   ~(SUN8I_PLL3_MODE_SEL |
> > + SUN8I_PLL3_FRAC_CLK |
> > + (SUN8I_PLL3_NMASK << SUN8I_PLL3_NSHIFT) |
> > + (SUN8I_PLL3_MMASK << SUN8I_PLL3_MSHIFT));
> > +
> > +   frac = sun8i_pll3_get_fact(rate, parent_rate, , );
> > +   if (frac == 1)
> > +

[PATCH 9/9] ASoC: AMD: Manage ACP 2.x SRAM banks power

2016-01-08 Thread Alex Deucher
From: Maruthi Srinivas Bayyavarapu 

ACP SRAM banks gets turned on when ACP is powered on.
Not all banks are used for playback/capture. So, power on
required banks during audio device open and power off during
audio device close.

Signed-off-by: Maruthi Bayyavarapu 
Reviewed-by: Alex Deucher 
Signed-off-by: Alex Deucher 
---

v2: Changes:
1. Clean up sram bank handling to clarify operation
2. Add timeout to loop

 sound/soc/amd/acp-pcm-dma.c | 94 +
 1 file changed, 87 insertions(+), 7 deletions(-)

diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c
index c0819b5..cc8b841 100644
--- a/sound/soc/amd/acp-pcm-dma.c
+++ b/sound/soc/amd/acp-pcm-dma.c
@@ -376,9 +376,57 @@ static int acp_dma_stop(void __iomem *acp_mmio, u8 ch_num)
return 0;
 }

+static void acp_set_sram_bank_state(void __iomem *acp_mmio, u16 bank,
+   bool power_on)
+{
+   u32 val, req_reg, sts_reg, sts_reg_mask;
+   u32 loops = 1000;
+
+   if (bank < 32) {
+   req_reg = mmACP_MEM_SHUT_DOWN_REQ_LO;
+   sts_reg = mmACP_MEM_SHUT_DOWN_STS_LO;
+   sts_reg_mask = 0x;
+
+   } else {
+   bank -= 32;
+   req_reg = mmACP_MEM_SHUT_DOWN_REQ_HI;
+   sts_reg = mmACP_MEM_SHUT_DOWN_STS_HI;
+   sts_reg_mask = 0x;
+   }
+
+   val = acp_reg_read(acp_mmio, req_reg);
+   if (val & (1 << bank)) {
+   /* bank is in off state */
+   if (power_on == true)
+   /* request to on */
+   val &= ~(1 << bank);
+   else
+   /* request to off */
+   return;
+   } else {
+   /* bank is in on state */
+   if (power_on == false)
+   /* request to off */
+   val |= 1 << bank;
+   else
+   /* request to on */
+   return;
+   }
+   acp_reg_write(val, acp_mmio, req_reg);
+
+   while (acp_reg_read(acp_mmio, sts_reg) != sts_reg_mask) {
+   if (!loops--) {
+   pr_err("ACP SRAM bank %d state change failed\n", bank);
+   break;
+   }
+   cpu_relax();
+   }
+}
+
 /* Initialize and bring ACP hardware to default state. */
 static int acp_init(void __iomem *acp_mmio)
 {
+   u16 bank;
u32 val, count, sram_pte_offset;

/* Assert Soft reset of ACP */
@@ -447,6 +495,13 @@ static int acp_init(void __iomem *acp_mmio)
acp_reg_write(ACP_EXTERNAL_INTR_CNTL__DMAIOCMask_MASK,
acp_mmio, mmACP_EXTERNAL_INTR_CNTL);

+   /* When ACP_TILE_P1 is turned on, all SRAM banks get turned on.
+   * Now, turn off all of them. This can't be done in 'poweron' of
+   * ACP pm domain, as this requires ACP to be initialized.
+   */
+   for (bank = 1; bank < 48; bank++)
+   acp_set_sram_bank_state(acp_mmio, bank, false);
+
return 0;
 }

@@ -559,6 +614,7 @@ static irqreturn_t dma_irq_handler(int irq, void *arg)

 static int acp_dma_open(struct snd_pcm_substream *substream)
 {
+   u16 bank;
int ret = 0;
struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_soc_pcm_runtime *prtd = substream->private_data;
@@ -592,10 +648,17 @@ static int acp_dma_open(struct snd_pcm_substream 
*substream)
if (!intr_data->play_stream && !intr_data->capture_stream)
acp_reg_write(1, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB);

-   if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+   if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
intr_data->play_stream = substream;
-   else
+   for (bank = 1; bank <= 4; bank++)
+   acp_set_sram_bank_state(intr_data->acp_mmio, bank,
+   true);
+   } else {
intr_data->capture_stream = substream;
+   for (bank = 5; bank <= 8; bank++)
+   acp_set_sram_bank_state(intr_data->acp_mmio, bank,
+   true);
+   }

return 0;
 }
@@ -627,6 +690,7 @@ static int acp_dma_hw_params(struct snd_pcm_substream 
*substream,
pg = virt_to_page(substream->dma_buffer.area);

if (pg != NULL) {
+   acp_set_sram_bank_state(rtd->acp_mmio, 0, true);
/* Save for runtime private data */
rtd->pg = pg;
rtd->order = get_order(size);
@@ -802,6 +866,7 @@ static int acp_dma_new(struct snd_soc_pcm_runtime *rtd)

 static int acp_dma_close(struct snd_pcm_substream *substream)
 {
+   u16 bank;
struct snd_pcm_runtime *runtime = substream->runtime;
struct audio_substream_data *rtd = runtime->private_data;

[PATCH 8/9] ASoC: AMD: add pm ops

2016-01-08 Thread Alex Deucher
From: Maruthi Srinivas Bayyavarapu 

genpd will power off/on ACP to manage runtime ACP PM. ACP runtime PM
hooks are added to get it deinitialized and initialized respectively,
after it is powered off/on.

When system goes to suspend when audio usecase is active, ACP will
be powered off through genpd. When it resumes, ACP needs to be
initialized and reconfigured.

Signed-off-by: Maruthi Bayyavarapu 
Reviewed-by: Alex Deucher 
Signed-off-by: Alex Deucher 
---

v2: replace ternery operator usage

 sound/soc/amd/acp-pcm-dma.c | 48 +
 1 file changed, 48 insertions(+)

diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c
index 0724d78..c0819b5 100644
--- a/sound/soc/amd/acp-pcm-dma.c
+++ b/sound/soc/amd/acp-pcm-dma.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 

@@ -885,6 +886,10 @@ static int acp_audio_probe(struct platform_device *pdev)
return status;
}

+   pm_runtime_set_autosuspend_delay(>dev, 1);
+   pm_runtime_use_autosuspend(>dev);
+   pm_runtime_enable(>dev);
+
return status;
 }

@@ -894,15 +899,58 @@ static int acp_audio_remove(struct platform_device *pdev)

acp_deinit(adata->acp_mmio);
snd_soc_unregister_platform(>dev);
+   pm_runtime_disable(>dev);

return 0;
 }

+static int acp_pcm_resume(struct device *dev)
+{
+   struct audio_drv_data *adata = dev_get_drvdata(dev);
+
+   acp_init(adata->acp_mmio);
+
+   if (adata->play_stream && adata->play_stream->runtime)
+   config_acp_dma(adata->acp_mmio,
+   adata->play_stream->runtime->private_data);
+   if (adata->capture_stream && adata->capture_stream->runtime)
+   config_acp_dma(adata->acp_mmio,
+   adata->capture_stream->runtime->private_data);
+
+   acp_reg_write(1, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB);
+   return 0;
+}
+
+static int acp_pcm_runtime_suspend(struct device *dev)
+{
+   struct audio_drv_data *adata = dev_get_drvdata(dev);
+
+   acp_deinit(adata->acp_mmio);
+   acp_reg_write(0, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB);
+   return 0;
+}
+
+static int acp_pcm_runtime_resume(struct device *dev)
+{
+   struct audio_drv_data *adata = dev_get_drvdata(dev);
+
+   acp_init(adata->acp_mmio);
+   acp_reg_write(1, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB);
+   return 0;
+}
+
+static const struct dev_pm_ops acp_pm_ops = {
+   .resume = acp_pcm_resume,
+   .runtime_suspend = acp_pcm_runtime_suspend,
+   .runtime_resume = acp_pcm_runtime_resume,
+};
+
 static struct platform_driver acp_dma_driver = {
.probe = acp_audio_probe,
.remove = acp_audio_remove,
.driver = {
.name = "acp_audio_dma",
+   .pm = _pm_ops,
},
 };

-- 
2.5.0



[PATCH 7/9] ASoC: AMD: add AMD ASoC ACP 2.x DMA driver

2016-01-08 Thread Alex Deucher
From: Maruthi Srinivas Bayyavarapu 

ACP IP has internal DMA controller with multiple channels which
can be programmed in cyclic/non cyclic manner. ACP can generate
interrupt upon completion of DMA transfer, if required.
The PCM driver provides the platform DMA component to ALSA core.

Signed-off-by: Maruthi Bayyavarapu 
Reviewed-by: Alex Deucher 
Reviewed-by: Murali Krishna Vemuri 
Signed-off-by: Alex Deucher 
---

v2: Changes
1. Squash ACP DMA abstraction and DMA patches together
2. Fix IRQ_NONE case in dma_irq_handler
3. Replace ternery operations
4. Add loop timeout
v3: Changes
1. replace COMP_PARAM_1 workaround with a dwc quirk
2. better namespaced some macros

 sound/soc/Kconfig   |   1 +
 sound/soc/Makefile  |   1 +
 sound/soc/amd/Kconfig   |   4 +
 sound/soc/amd/Makefile  |   3 +
 sound/soc/amd/acp-pcm-dma.c | 914 
 sound/soc/amd/acp.h | 118 ++
 6 files changed, 1041 insertions(+)
 create mode 100644 sound/soc/amd/Kconfig
 create mode 100644 sound/soc/amd/Makefile
 create mode 100644 sound/soc/amd/acp-pcm-dma.c
 create mode 100644 sound/soc/amd/acp.h

diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig
index 7ff7d88..a34e9e9 100644
--- a/sound/soc/Kconfig
+++ b/sound/soc/Kconfig
@@ -38,6 +38,7 @@ config SND_SOC_TOPOLOGY

 # All the supported SoCs
 source "sound/soc/adi/Kconfig"
+source "sound/soc/amd/Kconfig"
 source "sound/soc/atmel/Kconfig"
 source "sound/soc/au1x/Kconfig"
 source "sound/soc/bcm/Kconfig"
diff --git a/sound/soc/Makefile b/sound/soc/Makefile
index 8eb06db..a79a4c7 100644
--- a/sound/soc/Makefile
+++ b/sound/soc/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_SND_SOC) += snd-soc-core.o
 obj-$(CONFIG_SND_SOC)  += codecs/
 obj-$(CONFIG_SND_SOC)  += generic/
 obj-$(CONFIG_SND_SOC)  += adi/
+obj-$(CONFIG_SND_SOC)  += amd/
 obj-$(CONFIG_SND_SOC)  += atmel/
 obj-$(CONFIG_SND_SOC)  += au1x/
 obj-$(CONFIG_SND_SOC)  += bcm/
diff --git a/sound/soc/amd/Kconfig b/sound/soc/amd/Kconfig
new file mode 100644
index 000..78187eb
--- /dev/null
+++ b/sound/soc/amd/Kconfig
@@ -0,0 +1,4 @@
+config SND_SOC_AMD_ACP
+   tristate "AMD Audio Coprocessor support"
+   help
+This option enables ACP DMA support on AMD platform.
diff --git a/sound/soc/amd/Makefile b/sound/soc/amd/Makefile
new file mode 100644
index 000..1a66ec0
--- /dev/null
+++ b/sound/soc/amd/Makefile
@@ -0,0 +1,3 @@
+snd-soc-acp-pcm-objs   := acp-pcm-dma.o
+
+obj-$(CONFIG_SND_SOC_AMD_ACP) += snd-soc-acp-pcm.o
diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c
new file mode 100644
index 000..0724d78
--- /dev/null
+++ b/sound/soc/amd/acp-pcm-dma.c
@@ -0,0 +1,914 @@
+/*
+ * AMD ALSA SoC PCM Driver for ACP 2.x
+ *
+ * Copyright 2014-2015 Advanced Micro Devices, Inc.
+ *
+ * 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 "acp.h"
+
+#define PLAYBACK_MIN_NUM_PERIODS2
+#define PLAYBACK_MAX_NUM_PERIODS2
+#define PLAYBACK_MAX_PERIOD_SIZE16384
+#define PLAYBACK_MIN_PERIOD_SIZE1024
+#define CAPTURE_MIN_NUM_PERIODS 2
+#define CAPTURE_MAX_NUM_PERIODS 2
+#define CAPTURE_MAX_PERIOD_SIZE 16384
+#define CAPTURE_MIN_PERIOD_SIZE 1024
+
+#define MAX_BUFFER (PLAYBACK_MAX_PERIOD_SIZE * PLAYBACK_MAX_NUM_PERIODS)
+#define MIN_BUFFER MAX_BUFFER
+
+static const struct snd_pcm_hardware acp_pcm_hardware_playback = {
+   .info = SNDRV_PCM_INFO_INTERLEAVED |
+   SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP |
+   SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_BATCH |
+   SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME,
+   .formats = SNDRV_PCM_FMTBIT_S16_LE |
+   SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE,
+   .channels_min = 1,
+   .channels_max = 8,
+   .rates = SNDRV_PCM_RATE_8000_96000,
+   .rate_min = 8000,
+   .rate_max = 96000,
+   .buffer_bytes_max = PLAYBACK_MAX_NUM_PERIODS * PLAYBACK_MAX_PERIOD_SIZE,
+   .period_bytes_min = PLAYBACK_MIN_PERIOD_SIZE,
+   .period_bytes_max = PLAYBACK_MAX_PERIOD_SIZE,
+   .periods_min = PLAYBACK_MIN_NUM_PERIODS,
+   .periods_max = PLAYBACK_MAX_NUM_PERIODS,
+};
+
+static const struct snd_pcm_hardware acp_pcm_hardware_capture = {
+   .info = SNDRV_PCM_INFO_INTERLEAVED |
+   SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP |
+   SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_BATCH |
+   SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME,
+   

[PATCH 6/9] ASoC : AMD : add ACP 2.2 register headers

2016-01-08 Thread Alex Deucher
From: Maruthi Srinivas Bayyavarapu 

These are register headers for the ACP (Audio CoProcessor) v2.2

Signed-off-by: Maruthi Bayyavarapu 
Reviewed-by: Alex Deucher 
Signed-off-by: Alex Deucher 
---
 sound/soc/amd/include/acp_2_2_d.h   |  609 
 sound/soc/amd/include/acp_2_2_enum.h| 1068 ++
 sound/soc/amd/include/acp_2_2_sh_mask.h | 2292 +++
 3 files changed, 3969 insertions(+)
 create mode 100644 sound/soc/amd/include/acp_2_2_d.h
 create mode 100644 sound/soc/amd/include/acp_2_2_enum.h
 create mode 100644 sound/soc/amd/include/acp_2_2_sh_mask.h

diff --git a/sound/soc/amd/include/acp_2_2_d.h 
b/sound/soc/amd/include/acp_2_2_d.h
new file mode 100644
index 000..0118fe9
--- /dev/null
+++ b/sound/soc/amd/include/acp_2_2_d.h
@@ -0,0 +1,609 @@
+/*
+ * ACP_2_2 Register documentation
+ *
+ * Copyright (C) 2014  Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef ACP_2_2_D_H
+#define ACP_2_2_D_H
+
+#define mmACP_DMA_CNTL_0   
 0x5000
+#define mmACP_DMA_CNTL_1   
 0x5001
+#define mmACP_DMA_CNTL_2   
 0x5002
+#define mmACP_DMA_CNTL_3   
 0x5003
+#define mmACP_DMA_CNTL_4   
 0x5004
+#define mmACP_DMA_CNTL_5   
 0x5005
+#define mmACP_DMA_CNTL_6   
 0x5006
+#define mmACP_DMA_CNTL_7   
 0x5007
+#define mmACP_DMA_CNTL_8   
 0x5008
+#define mmACP_DMA_CNTL_9   
 0x5009
+#define mmACP_DMA_CNTL_10  
 0x500a
+#define mmACP_DMA_CNTL_11  
 0x500b
+#define mmACP_DMA_CNTL_12  
 0x500c
+#define mmACP_DMA_CNTL_13  
 0x500d
+#define mmACP_DMA_CNTL_14  
 0x500e
+#define mmACP_DMA_CNTL_15  
 0x500f
+#define mmACP_DMA_DSCR_STRT_IDX_0  
 0x5010
+#define mmACP_DMA_DSCR_STRT_IDX_1  
 0x5011
+#define mmACP_DMA_DSCR_STRT_IDX_2  
 0x5012
+#define mmACP_DMA_DSCR_STRT_IDX_3  
 0x5013
+#define mmACP_DMA_DSCR_STRT_IDX_4  
 0x5014
+#define mmACP_DMA_DSCR_STRT_IDX_5  
 0x5015
+#define mmACP_DMA_DSCR_STRT_IDX_6  
 0x5016
+#define mmACP_DMA_DSCR_STRT_IDX_7  
 0x5017
+#define mmACP_DMA_DSCR_STRT_IDX_8  
 0x5018
+#define mmACP_DMA_DSCR_STRT_IDX_9  
 0x5019
+#define mmACP_DMA_DSCR_STRT_IDX_10 
 0x501a
+#define mmACP_DMA_DSCR_STRT_IDX_11 
 0x501b
+#define mmACP_DMA_DSCR_STRT_IDX_12 
 0x501c
+#define mmACP_DMA_DSCR_STRT_IDX_13 
 0x501d
+#define mmACP_DMA_DSCR_STRT_IDX_14 
 0x501e
+#define mmACP_DMA_DSCR_STRT_IDX_15 
 0x501f
+#define mmACP_DMA_DSCR_CNT_0   
 

[PATCH 5/9] drm/amd: add pm domain for ACP IP sub blocks

2016-01-08 Thread Alex Deucher
From: Maruthi Srinivas Bayyavarapu 

ACP IP have internal DMA controller, DW I2S controller and DSPs
as separate power tiles. DMA and I2S devices are added to generic
pm domain, so that entire IP can be powered off/on at appropriate
times. Unused DSPs are made to be powered off though they are powered
on during ACP pm domain power on sequence.

Signed-off-by: Maruthi Bayyavarapu 
Reviewed-by: Alex Deucher 
Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/amd/acp/Kconfig |   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 206 +++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_acp.h |   1 +
 3 files changed, 207 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/acp/Kconfig b/drivers/gpu/drm/amd/acp/Kconfig
index 28b5e70..2b07813 100644
--- a/drivers/gpu/drm/amd/acp/Kconfig
+++ b/drivers/gpu/drm/amd/acp/Kconfig
@@ -4,6 +4,7 @@ config DRM_AMD_ACP
bool "Enable ACP IP support"
default y
select MFD_CORE
+   select PM_GENERIC_DOMAINS if PM
help
Choose this option to enable ACP IP support for AMD SOCs.

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
index 71f26e9..9f8cfaa 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
@@ -24,6 +24,7 @@
  */

 #include 
+#include 
 #include 
 #include 
 #include 
@@ -102,6 +103,155 @@ static int acp_sw_fini(void *handle)
return 0;
 }

+/* power off a tile/block within ACP */
+static int acp_suspend_tile(void *cgs_dev, int tile)
+{
+   u32 val = 0;
+   u32 count = 0;
+
+   if ((tile  < ACP_TILE_P1) || (tile > ACP_TILE_DSP2)) {
+   pr_err("Invalid ACP tile : %d to suspend\n", tile);
+   return -1;
+   }
+
+   val = cgs_read_register(cgs_dev, mmACP_PGFSM_READ_REG_0 + tile);
+   val &= ACP_TILE_ON_MASK;
+
+   if (val == 0x0) {
+   val = cgs_read_register(cgs_dev, mmACP_PGFSM_RETAIN_REG);
+   val = val | (1 << tile);
+   cgs_write_register(cgs_dev, mmACP_PGFSM_RETAIN_REG, val);
+   cgs_write_register(cgs_dev, mmACP_PGFSM_CONFIG_REG,
+   0x500 + tile);
+
+   count = ACP_TIMEOUT_LOOP;
+   while (true) {
+   val = cgs_read_register(cgs_dev, mmACP_PGFSM_READ_REG_0
+   + tile);
+   val = val & ACP_TILE_ON_MASK;
+   if (val == ACP_TILE_OFF_MASK)
+   break;
+   if (--count == 0) {
+   pr_err("Timeout reading ACP PGFSM status\n");
+   return -ETIMEDOUT;
+   }
+   udelay(100);
+   }
+
+   val = cgs_read_register(cgs_dev, mmACP_PGFSM_RETAIN_REG);
+
+   val |= ACP_TILE_OFF_RETAIN_REG_MASK;
+   cgs_write_register(cgs_dev, mmACP_PGFSM_RETAIN_REG, val);
+   }
+   return 0;
+}
+
+/* power on a tile/block within ACP */
+static int acp_resume_tile(void *cgs_dev, int tile)
+{
+   u32 val = 0;
+   u32 count = 0;
+
+   if ((tile  < ACP_TILE_P1) || (tile > ACP_TILE_DSP2)) {
+   pr_err("Invalid ACP tile to resume\n");
+   return -1;
+   }
+
+   val = cgs_read_register(cgs_dev, mmACP_PGFSM_READ_REG_0 + tile);
+   val = val & ACP_TILE_ON_MASK;
+
+   if (val != 0x0) {
+   cgs_write_register(cgs_dev, mmACP_PGFSM_CONFIG_REG,
+   0x600 + tile);
+   count = ACP_TIMEOUT_LOOP;
+   while (true) {
+   val = cgs_read_register(cgs_dev, mmACP_PGFSM_READ_REG_0
+   + tile);
+   val = val & ACP_TILE_ON_MASK;
+   if (val == 0x0)
+   break;
+   if (--count == 0) {
+   pr_err("Timeout reading ACP PGFSM status\n");
+   return -ETIMEDOUT;
+   }
+   udelay(100);
+   }
+   val = cgs_read_register(cgs_dev, mmACP_PGFSM_RETAIN_REG);
+   if (tile == ACP_TILE_P1)
+   val = val & (ACP_TILE_P1_MASK);
+   else if (tile == ACP_TILE_P2)
+   val = val & (ACP_TILE_P2_MASK);
+
+   cgs_write_register(cgs_dev, mmACP_PGFSM_RETAIN_REG, val);
+   }
+   return 0;
+}
+
+struct acp_pm_domain {
+   void *cgs_dev;
+   struct generic_pm_domain gpd;
+};
+
+static int acp_poweroff(struct generic_pm_domain *genpd)
+{
+   int i, ret;
+   struct acp_pm_domain *apd;
+
+   apd = container_of(genpd, struct acp_pm_domain, gpd);
+   if (apd != NULL) {
+   /* Donot 

[PATCH 4/9] drm/amd: add ACP driver support

2016-01-08 Thread Alex Deucher
From: Maruthi Bayyavarapu 

This adds the ACP (Audio CoProcessor) IP driver and wires
it up to the amdgpu driver.  The ACP block provides the DMA
engine for i2s based ALSA driver. This is required for audio
on APUs that utilize an i2s codec.

Reviewed-by: Jammy Zhou 
Reviewed-by: Maruthi Bayyavarapu 
Reviewed-by: Alex Deucher 
Reviewed-by: Murali Krishna Vemuri 
Signed-off-by: Maruthi Bayyavarapu 
Signed-off-by: Chunming Zhou 
Signed-off-by: Alex Deucher 
---

v2: integrate i2s/az check patch
v3: s/amd_acp/amdgpu_acp/
v4: update copyright notice
v5: squash multiple patches, convert to mfd
v6: major changes as below :
1. Pass ACP register base to DMA and dw i2s drivers
   as IORESOURCE_MEM resources.
2. add dw i2s as a new mfd cell.
v7: specify broken out dw quirks that apply to AMD hardware
v8: Changes:
1. Select MFD_CORE
2. use genirq for ACP interrupt
3. Add separate cells for dws capture and playback
v9: drop stale include path
v10: add DW_I2S_QUIRK_COMP_PARAM1 setting

 drivers/gpu/drm/Kconfig  |   2 +
 drivers/gpu/drm/amd/acp/Kconfig  |  10 +
 drivers/gpu/drm/amd/acp/Makefile |   8 +
 drivers/gpu/drm/amd/acp/acp_hw.c |  50 +
 drivers/gpu/drm/amd/acp/include/acp_gfx_if.h |  34 +++
 drivers/gpu/drm/amd/amdgpu/Makefile  |  13 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu.h  |  12 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c  | 298 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_acp.h  |  41 
 drivers/gpu/drm/amd/amdgpu/vi.c  |  12 ++
 drivers/gpu/drm/amd/include/amd_shared.h |   1 +
 11 files changed, 480 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/amd/acp/Kconfig
 create mode 100644 drivers/gpu/drm/amd/acp/Makefile
 create mode 100644 drivers/gpu/drm/amd/acp/acp_hw.c
 create mode 100644 drivers/gpu/drm/amd/acp/include/acp_gfx_if.h
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_acp.h

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 59babd5..01f5db6 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -162,6 +162,8 @@ config DRM_AMDGPU
 source "drivers/gpu/drm/amd/amdgpu/Kconfig"
 source "drivers/gpu/drm/amd/powerplay/Kconfig"

+source "drivers/gpu/drm/amd/acp/Kconfig"
+
 source "drivers/gpu/drm/nouveau/Kconfig"

 config DRM_I810
diff --git a/drivers/gpu/drm/amd/acp/Kconfig b/drivers/gpu/drm/amd/acp/Kconfig
new file mode 100644
index 000..28b5e70
--- /dev/null
+++ b/drivers/gpu/drm/amd/acp/Kconfig
@@ -0,0 +1,10 @@
+menu "ACP Configuration"
+
+config DRM_AMD_ACP
+   bool "Enable ACP IP support"
+   default y
+   select MFD_CORE
+   help
+   Choose this option to enable ACP IP support for AMD SOCs.
+
+endmenu
diff --git a/drivers/gpu/drm/amd/acp/Makefile b/drivers/gpu/drm/amd/acp/Makefile
new file mode 100644
index 000..8363cb5
--- /dev/null
+++ b/drivers/gpu/drm/amd/acp/Makefile
@@ -0,0 +1,8 @@
+#
+# Makefile for the ACP, which is a sub-component
+# of AMDSOC/AMDGPU drm driver.
+# It provides the HW control for ACP related functionalities.
+
+subdir-ccflags-y += -I$(AMDACPPATH)/ -I$(AMDACPPATH)/include
+
+AMD_ACP_FILES := $(AMDACPPATH)/acp_hw.o
diff --git a/drivers/gpu/drm/amd/acp/acp_hw.c b/drivers/gpu/drm/amd/acp/acp_hw.c
new file mode 100644
index 000..7af83f1
--- /dev/null
+++ b/drivers/gpu/drm/amd/acp/acp_hw.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2015 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "acp_gfx_if.h"
+
+#define ACP_MODE_I2S   0
+#define ACP_MODE_AZ1
+
+#define mmACP_AZALIA_I2S_SELECT 0x51d4
+
+int amd_acp_hw_init(void *cgs_device,
+   unsigned acp_version_major, unsigned acp_version_minor)
+{
+   unsigned int 

[PATCH 3/9] ASoC: dwc: add quirk to override COMP_PARAM_1 register

2016-01-08 Thread Alex Deucher
From: Maruthi Srinivas Bayyavarapu 

DWC for capture in ACP 2.x IP reports playback and capture capabilities
though it supports only capture. Added a quirk to override default value
to represent capture capability only.

Signed-off-by: Maruthi Bayyavarapu 
Signed-off-by: Alex Deucher 
---
 include/sound/designware_i2s.h | 1 +
 sound/soc/dwc/designware_i2s.c | 4 
 2 files changed, 5 insertions(+)

diff --git a/include/sound/designware_i2s.h b/include/sound/designware_i2s.h
index e0bb458..5681855 100644
--- a/include/sound/designware_i2s.h
+++ b/include/sound/designware_i2s.h
@@ -46,6 +46,7 @@ struct i2s_platform_data {
u32 snd_rates;

#define DW_I2S_QUIRK_COMP_REG_OFFSET(1 << 0)
+   #define DW_I2S_QUIRK_COMP_PARAM1(1 << 1)
unsigned int quirks;
unsigned int i2s_reg_comp1;
unsigned int i2s_reg_comp2;
diff --git a/sound/soc/dwc/designware_i2s.c b/sound/soc/dwc/designware_i2s.c
index 825a1f4..ce664c2 100644
--- a/sound/soc/dwc/designware_i2s.c
+++ b/sound/soc/dwc/designware_i2s.c
@@ -500,6 +500,10 @@ static int dw_configure_dai(struct dw_i2s_dev *dev,
u32 comp2 = i2s_read_reg(dev->i2s_base, dev->i2s_reg_comp2);
u32 idx;

+   if (dev->capability & DWC_I2S_RECORD &&
+   dev->quirks & DW_I2S_QUIRK_COMP_PARAM1)
+   comp1 = comp1 & ~BIT(5);
+
if (COMP1_TX_ENABLED(comp1)) {
dev_dbg(dev->dev, " designware: play supported\n");
idx = COMP1_TX_WORDSIZE_0(comp1);
-- 
2.5.0



[PATCH 2/9] drm/amdgpu: add irq domain support

2016-01-08 Thread Alex Deucher
Hardware blocks on the GPU like ACP generate interrupts in
the GPU interrupt controller, but are driven by a separate
driver.  Add an irq domain to the GPU driver so that
blocks like ACP can register a Linux interrupt.

Acked-by: Dave Airlie 
Acked-by: Christian König 
Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 108 +---
 drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h |   9 +++
 drivers/gpu/drm/amd/amdgpu/cik_ih.c |   6 ++
 drivers/gpu/drm/amd/amdgpu/cz_ih.c  |   7 +++
 drivers/gpu/drm/amd/amdgpu/iceland_ih.c |   7 +++
 drivers/gpu/drm/amd/amdgpu/tonga_ih.c   |   7 +++
 6 files changed, 136 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
index 7c42ff6..3006182 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
@@ -312,6 +312,7 @@ int amdgpu_irq_add_id(struct amdgpu_device *adev, unsigned 
src_id,
}

adev->irq.sources[src_id] = source;
+
return 0;
 }

@@ -335,15 +336,19 @@ void amdgpu_irq_dispatch(struct amdgpu_device *adev,
return;
}

-   src = adev->irq.sources[src_id];
-   if (!src) {
-   DRM_DEBUG("Unhandled interrupt src_id: %d\n", src_id);
-   return;
-   }
+   if (adev->irq.virq[src_id]) {
+   generic_handle_irq(irq_find_mapping(adev->irq.domain, src_id));
+   } else {
+   src = adev->irq.sources[src_id];
+   if (!src) {
+   DRM_DEBUG("Unhandled interrupt src_id: %d\n", src_id);
+   return;
+   }

-   r = src->funcs->process(adev, src, entry);
-   if (r)
-   DRM_ERROR("error processing interrupt (%d)\n", r);
+   r = src->funcs->process(adev, src, entry);
+   if (r)
+   DRM_ERROR("error processing interrupt (%d)\n", r);
+   }
 }

 /**
@@ -461,3 +466,90 @@ bool amdgpu_irq_enabled(struct amdgpu_device *adev, struct 
amdgpu_irq_src *src,

return !!atomic_read(>enabled_types[type]);
 }
+
+/* gen irq */
+static void amdgpu_irq_mask(struct irq_data *irqd)
+{
+   /* XXX */
+}
+
+static void amdgpu_irq_unmask(struct irq_data *irqd)
+{
+   /* XXX */
+}
+
+static struct irq_chip amdgpu_irq_chip = {
+   .name = "amdgpu-ih",
+   .irq_mask = amdgpu_irq_mask,
+   .irq_unmask = amdgpu_irq_unmask,
+};
+
+static int amdgpu_irqdomain_map(struct irq_domain *d,
+   unsigned int irq, irq_hw_number_t hwirq)
+{
+   if (hwirq >= AMDGPU_MAX_IRQ_SRC_ID)
+   return -EPERM;
+
+   irq_set_chip_and_handler(irq,
+_irq_chip, handle_simple_irq);
+   return 0;
+}
+
+static struct irq_domain_ops amdgpu_hw_irqdomain_ops = {
+   .map = amdgpu_irqdomain_map,
+};
+
+/**
+ * amdgpu_irq_add_domain - create a linear irq domain
+ *
+ * @adev: amdgpu device pointer
+ *
+ * Create an irq domain for GPU interrupt sources
+ * that may be driven by another driver (e.g., ACP).
+ */
+int amdgpu_irq_add_domain(struct amdgpu_device *adev)
+{
+   adev->irq.domain = irq_domain_add_linear(NULL, AMDGPU_MAX_IRQ_SRC_ID,
+_hw_irqdomain_ops, 
adev);
+   if (!adev->irq.domain) {
+   DRM_ERROR("GPU irq add domain failed\n");
+   return -ENODEV;
+   }
+
+   return 0;
+}
+
+/**
+ * amdgpu_irq_remove_domain - remove the irq domain
+ *
+ * @adev: amdgpu device pointer
+ *
+ * Remove the irq domain for GPU interrupt sources
+ * that may be driven by another driver (e.g., ACP).
+ */
+void amdgpu_irq_remove_domain(struct amdgpu_device *adev)
+{
+   if (adev->irq.domain) {
+   irq_domain_remove(adev->irq.domain);
+   adev->irq.domain = NULL;
+   }
+}
+
+/**
+ * amdgpu_irq_create_mapping - create a mapping between a domain irq and a
+ * Linux irq
+ *
+ * @adev: amdgpu device pointer
+ * @src_id: IH source id
+ *
+ * Create a mapping between a domain irq (GPU IH src id) and a Linux irq
+ * Use this for components that generate a GPU interrupt, but are driven
+ * by a different driver (e.g., ACP).
+ * Returns the Linux irq.
+ */
+unsigned amdgpu_irq_create_mapping(struct amdgpu_device *adev, unsigned src_id)
+{
+   adev->irq.virq[src_id] = irq_create_mapping(adev->irq.domain, src_id);
+
+   return adev->irq.virq[src_id];
+}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h
index 17b01aef..e124b59 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h
@@ -24,6 +24,7 @@
 #ifndef __AMDGPU_IRQ_H__
 #define __AMDGPU_IRQ_H__

+#include 
 #include "amdgpu_ih.h"

 #define AMDGPU_MAX_IRQ_SRC_ID  0x100
@@ -65,6 +66,10 @@ struct amdgpu_irq {
/* interrupt ring */
struct amdgpu_ih_ring 

[PATCH 1/9] drm/amdgpu/cgs: add an interface to access PCI resources

2016-01-08 Thread Alex Deucher
This provides an interface to get access to the base address
of PCI resources (MMIO, DOORBELL, etc.).  Only MMIO and
DOORBELL are implemented right now.  This is necessary to
properly utilize shared drivers on platform devices.  IP
modules can use this interface to get the base address
of the resource and add any additional offset and set the
size when setting up the platform driver(s).

Acked-by: Dave Airlie 
Acked-by: Christian König 
Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c  | 36 
 drivers/gpu/drm/amd/include/cgs_common.h | 34 ++
 2 files changed, 70 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
index 59485d0..a081dda 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
@@ -398,6 +398,41 @@ static void amdgpu_cgs_write_pci_config_dword(void 
*cgs_device, unsigned addr,
WARN(ret, "pci_write_config_dword error");
 }

+
+static int amdgpu_cgs_get_pci_resource(void *cgs_device,
+  enum cgs_resource_type resource_type,
+  uint64_t size,
+  uint64_t offset,
+  uint64_t *resource_base)
+{
+   CGS_FUNC_ADEV;
+
+   if (resource_base == NULL)
+   return -EINVAL;
+
+   switch (resource_type) {
+   case CGS_RESOURCE_TYPE_MMIO:
+   if (adev->rmmio_size == 0)
+   return -ENOENT;
+   if ((offset + size) > adev->rmmio_size)
+   return -EINVAL;
+   *resource_base = adev->rmmio_base;
+   return 0;
+   case CGS_RESOURCE_TYPE_DOORBELL:
+   if (adev->doorbell.size == 0)
+   return -ENOENT;
+   if ((offset + size) > adev->doorbell.size)
+   return -EINVAL;
+   *resource_base = adev->doorbell.base;
+   return 0;
+   case CGS_RESOURCE_TYPE_FB:
+   case CGS_RESOURCE_TYPE_IO:
+   case CGS_RESOURCE_TYPE_ROM:
+   default:
+   return -EINVAL;
+   }
+}
+
 static const void *amdgpu_cgs_atom_get_data_table(void *cgs_device,
  unsigned table, uint16_t 
*size,
  uint8_t *frev, uint8_t *crev)
@@ -1041,6 +1076,7 @@ static const struct cgs_ops amdgpu_cgs_ops = {
amdgpu_cgs_write_pci_config_byte,
amdgpu_cgs_write_pci_config_word,
amdgpu_cgs_write_pci_config_dword,
+   amdgpu_cgs_get_pci_resource,
amdgpu_cgs_atom_get_data_table,
amdgpu_cgs_atom_get_cmd_table_revs,
amdgpu_cgs_atom_exec_cmd_table,
diff --git a/drivers/gpu/drm/amd/include/cgs_common.h 
b/drivers/gpu/drm/amd/include/cgs_common.h
index 03affb3..713aec9 100644
--- a/drivers/gpu/drm/amd/include/cgs_common.h
+++ b/drivers/gpu/drm/amd/include/cgs_common.h
@@ -122,6 +122,17 @@ struct cgs_system_info {
uint64_t   padding[13];
 };

+/*
+ * enum cgs_resource_type - GPU resource type
+ */
+enum cgs_resource_type {
+   CGS_RESOURCE_TYPE_MMIO = 0,
+   CGS_RESOURCE_TYPE_FB,
+   CGS_RESOURCE_TYPE_IO,
+   CGS_RESOURCE_TYPE_DOORBELL,
+   CGS_RESOURCE_TYPE_ROM,
+};
+
 /**
  * struct cgs_clock_limits - Clock limits
  *
@@ -417,6 +428,23 @@ typedef void (*cgs_write_pci_config_word_t)(void 
*cgs_device, unsigned addr,
 typedef void (*cgs_write_pci_config_dword_t)(void *cgs_device, unsigned addr,
 uint32_t value);

+
+/**
+ * cgs_get_pci_resource() - provide access to a device resource (PCI BAR)
+ * @cgs_device:opaque device handle
+ * @resource_type: Type of Resource (MMIO, IO, ROM, FB, DOORBELL)
+ * @size:  size of the region
+ * @offset:offset from the start of the region
+ * @resource_base: base address (not including offset) returned
+ *
+ * Return: 0 on success, -errno otherwise
+ */
+typedef int (*cgs_get_pci_resource_t)(void *cgs_device,
+ enum cgs_resource_type resource_type,
+ uint64_t size,
+ uint64_t offset,
+ uint64_t *resource_base);
+
 /**
  * cgs_atom_get_data_table() - Get a pointer to an ATOM BIOS data table
  * @cgs_device:opaque device handle
@@ -593,6 +621,8 @@ struct cgs_ops {
cgs_write_pci_config_byte_t write_pci_config_byte;
cgs_write_pci_config_word_t write_pci_config_word;
cgs_write_pci_config_dword_t write_pci_config_dword;
+   /* PCI resources */
+   cgs_get_pci_resource_t get_pci_resource;
/* ATOM BIOS */
cgs_atom_get_data_table_t atom_get_data_table;
cgs_atom_get_cmd_table_revs_t atom_get_cmd_table_revs;
@@ -708,5 +738,9 @@ 

[PATCH 0/9] Add ASoC support for AMD APUs [v7]

2016-01-08 Thread Alex Deucher
This patch set implements support for i2s audio and new AMD GPUs.
The i2s codec is fed by a DMA engine on the GPU.  To handle this
we create mfd cells which we hang the i2s codec and DMA engine on.
Because of this, this patch set covers two subsystems: drm and alsa.
The drm patches add support for the ACP hw block which provides the
DMA engine for the i2s codec.  The alsa patches add the ASoC driver
for the i2s codec.  Since the alsa changes depend on the drm changes,
I'd like to take the alsa patches in via the drm tree.

This patch set depends on the following patch from the linux-pm tree:

PM / Domains: export symbols to add/remove devices from genpd

And the following patches from the audio tree:

ASoC: dwc: add runtime suspend/resume functionality
ASoC: dwc: add quirk for different register offset
ASoC: dwc: reconfigure dwc in 'resume' from 'suspend'

V2 changes:
- Use the MFD subsystem rather than adding our own bus
- Squash all sub-feature patches together
- fix comments mentioned in previous review

V3 changes:
- Update the designware driver to handle slave mode, amd specific
  features
- Use the designware driver directly for i2s
- Move the DMA handling from the GPU driver into the AMD ASoC
  driver
- Change the license on the ASoC driver to GPL

v4 changes:
- patch "ASoC : dwc : support dw i2s in slave mode" accepted
- Add a _dai_fmt() operation that checks to make sure that the mode
  we're setting corresponds to what we read back from the hardware.
- Split specific quirks into separate patches
- Set the specific quirks that apply to AMD chips in the acp driver

v5 changes:
- patch "ASoC : dwc : add check for master/slave format" accepted
- Fix MFD_CORE selection in ACP Kconfig
- Add irq domain support to amdgpu driver
- Use genirq in ACP DMA driver
- Export some genpd symbols to support ACP powergating (Acked by PM maintainer)
- Use genpd for ACP powergating
- add separate capture and playback instances of dws in ACP init
- add runtime suspend support for dws in master mode

v6 changes:
- Squash ACP DMA and abstraction layer patches into one
- Drop dependent patches from other trees
- Fix ACP DMA irq none case
- ACP DMA coding style cleanups
- Add timeouts to wait loops
- Clarify ACP powergating banks handling

v7 changes:
- Send out register header patch as well
- Add another dwc quirk for acp
- fix ternery operator usage

The entire patch set can be viewed here:
http://cgit.freedesktop.org/~agd5f/linux/log/?h=acp-upstream10

Thanks,

Alex

Alex Deucher (2):
  drm/amdgpu/cgs: add an interface to access PCI resources
  drm/amdgpu: add irq domain support

Maruthi Bayyavarapu (1):
  drm/amd: add ACP driver support

Maruthi Srinivas Bayyavarapu (6):
  ASoC: dwc: add quirk to override COMP_PARAM_1 register
  drm/amd: add pm domain for ACP IP sub blocks
  ASoC : AMD : add ACP 2.2 register headers
  ASoC: AMD: add AMD ASoC ACP 2.x DMA driver
  ASoC: AMD: add pm ops
  ASoC: AMD: Manage ACP 2.x SRAM banks power

 drivers/gpu/drm/Kconfig  |2 +
 drivers/gpu/drm/amd/acp/Kconfig  |   11 +
 drivers/gpu/drm/amd/acp/Makefile |8 +
 drivers/gpu/drm/amd/acp/acp_hw.c |   50 +
 drivers/gpu/drm/amd/acp/include/acp_gfx_if.h |   34 +
 drivers/gpu/drm/amd/amdgpu/Makefile  |   13 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu.h  |   12 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c  |  502 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_acp.h  |   42 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c  |   36 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c  |  108 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h  |9 +
 drivers/gpu/drm/amd/amdgpu/cik_ih.c  |6 +
 drivers/gpu/drm/amd/amdgpu/cz_ih.c   |7 +
 drivers/gpu/drm/amd/amdgpu/iceland_ih.c  |7 +
 drivers/gpu/drm/amd/amdgpu/tonga_ih.c|7 +
 drivers/gpu/drm/amd/amdgpu/vi.c  |   12 +
 drivers/gpu/drm/amd/include/amd_shared.h |1 +
 drivers/gpu/drm/amd/include/cgs_common.h |   34 +
 include/sound/designware_i2s.h   |1 +
 sound/soc/Kconfig|1 +
 sound/soc/Makefile   |1 +
 sound/soc/amd/Kconfig|4 +
 sound/soc/amd/Makefile   |3 +
 sound/soc/amd/acp-pcm-dma.c  | 1042 
 sound/soc/amd/acp.h  |  118 ++
 sound/soc/amd/include/acp_2_2_d.h|  609 +++
 sound/soc/amd/include/acp_2_2_enum.h | 1068 
 sound/soc/amd/include/acp_2_2_sh_mask.h  | 2292 ++
 sound/soc/dwc/designware_i2s.c   |4 +
 30 files changed, 6035 insertions(+), 9 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/acp/Kconfig
 create mode 100644 drivers/gpu/drm/amd/acp/Makefile
 create mode 100644 drivers/gpu/drm/amd/acp/acp_hw.c
 create mode 100644 drivers/gpu/drm/amd/acp/include/acp_gfx_if.h
 create mode 100644 

[PATCH RFC 0/2] Add a display driver to the Allwinner H3

2016-01-08 Thread Jean-Francois Moine
On Wed, 6 Jan 2016 22:20:46 +0100
Maxime Ripard  wrote:

> > As there is no documentation about the DE2 nor about the HDMI which
> > are found in the H3, this driver has been built from Allwiiner's
> > sources.
> 
> That's unfortunate :/
> 
> Have you checked in the A64 BSP if there was some useful information?

Same as the H3: no more information about the display system.

> > So, there may be license problems, especially for the file
> > de2_hdmi_h3.c which contains a lot of magic values.
> 
> I guess it's the biggest issue with your code right now. What licenses
> issues are we talking about here?

The documentation about the H3, as the other Allwinner documentations,
starts with:

This documentation is the original work and copyrighted
property of Allwinner Technology ("Allwinner"). Reproduction in
whole or in part must obtain the written approval of Allwinner
and give clear acknowledgement to the copyright owner.

Then, the DE2 sources contain only:

All Winner Tech, All Right Reserved. 2014-2015 Copyright (c)

Eventually, there is no copyright/author/history in the HDMI sources.

> Remember that having your Signed-off-by tag on a commit means that you
> certify that you have the right to submit the patch under the license
> you indicate in the files added and / or modified.
> 
> If you don't have such right, for example because you don't have the
> right and / or authorization from the initial author to re-license
> that code, you cannot put your SoB.

OK, sorry. So, please, ignore the whole patch series.

> > The associated DT and documentation will be submitted when the H3 DTs
> > will be in the kernel.
> 
> Having the DT binding documentation would really help in the review.

Here it is, as a sunxi specific documentation, but it could be generic.

--- /dev/null   1970-01-01 01:00:10.24002 +0100
+++ Documentation/devicetree/bindings/display/sunxi.txt 2016-01-08 
17:48:01.775903901 +0100
@@ -0,0 +1,107 @@
+Allwinner sunxi display subsystem
+=
+
+The sunxi display subsystems contain a display controller (DE),
+one or two LCD controllers (TCON) and their external interfaces.
+
+Display controller
+==
+
+Required properties:
+
+- compatible: value should be one of the following
+   "allwinner,sun8i-h3-display-engine"
+
+- clocks: must include clock specifiers corresponding to entries in the
+   clock-names property.
+
+- clock-names: must contain
+   gate: for DE activation
+   clock: DE clock
+
+- resets: phandle to the reset of the device
+
+- ports: phandle's to the LCD ports
+
+LCD controller
+==
+
+Required properties:
+
+- compatible: value should be one of the following
+   "allwinner,sun8i-h3-lcd"
+
+- clocks: must include clock specifiers corresponding to entries in the
+   clock-names property.
+
+- clock-names: must contain
+   gate: for LCD activation
+   clock: pixel clock
+
+- resets: phandle to the reset of the device
+
+- port: port node with endpoint definitions as defined in
+   Documentation/devicetree/bindings/media/video-interfaces.txt
+
+HDMI support
+
+
+Required properties:
+
+- compatible: value should be one of the following
+   "allwinner,sun8i-h3-hdmi"
+
+- clocks: must include clock specifiers corresponding to entries in the
+   clock-names property.
+
+- clock-names: must contain
+   gate: for HDMI activation
+   clock: pixel clock
+   ddc-clock: for the HDMI protocol
+
+- resets: one or two phandle's to the reset of the device
+
+- port: port node with endpoint definitions as defined in
+   Documentation/devicetree/bindings/media/video-interfaces.txt
+
+Example:
+
+   de: de-controller at 0100 {
+   compatible = "allwinner,sun8i-h3-display-engine";
+   ...
+   clocks = <_gates 44>, <_clk>;
+   clock-names = "gate", "clock";
+   resets = <_rst 44>;
+   ports = <_p>;
+   };
+
+   lcd0: lcd-controller at 01c0c000 {
+   compatible = "allwinner,sun8i-h3-lcd";
+   ...
+   clocks = <_gates 35>, <_clk>;
+   clock-names = "gate", "clock";
+   resets = <_rst 35>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+   lcd0_p: port {
+   lcd0_ep: endpoint {
+   remote-endpoint = <_ep>;
+   };
+   };
+   };
+
+   hdmi: hdmi at 01ee {
+   compatible = "allwinner,sun8i-h3-hdmi";
+   ...
+   clocks = <_gates 43>, <_clk>,
+<_slow_clk 31>;
+   clock-names = "gate", "clock", "ddc-clock";
+   resets = <_rst 42>, <_rst 43>;
+   #address-cells = <1>;
+

[PATCH 6/8] ASoC: AMD: add AMD ASoC ACP 2.x DMA driver

2016-01-08 Thread Alex Deucher
On Tue, Jan 5, 2016 at 1:43 PM, Mark Brown  wrote:
> On Wed, Dec 23, 2015 at 02:01:13PM -0500, Alex Deucher wrote:
>
>> --- /dev/null
>> +++ b/sound/soc/amd/Kconfig
>> @@ -0,0 +1,4 @@
>> +config SND_SOC_AMD_ACP
>> + tristate "AMD Audio Coprocessor support"
>> + help
>> +  This option enables ACP DMA support on AMD platform.
>
> This has no dependencies?

No dependencies.  The ACP device discovery is triggered from GPU
driver, but the ACP driver has no direct dependencies on it.
Theoretically it could act as a standalone driver.

Alex

>
>> +
>> + /* Designware I2S driver requries proper capabilities
>> +  * from mmACP_I2SMICSP_COMP_PARAM_1 register. The register
>> +  * reports playback and capture capabilities though the
>> +  * MIC instance of DW I2S controller supports capture only
>> +  * Provide a workaround by masking the capability into a
>> +  * scratch register and provide scratch register offset as
>> +  * though it is mmACP_I2SMICSP_COMP_PARAM_1
>> +  */
>> +
>> + val = acp_reg_read(acp_mmio, mmACP_I2SMICSP_COMP_PARAM_1);
>> + val = val & ~BIT(5);
>> + acp_reg_write(val, acp_mmio, mmACP_SCRATCH_REG_0);
>
> Ugh, right.  So the hardware doesn't actually have the register moved at
> all.  Why are we doing this, if the capabilities really are buggy the
> more idiomatic thing would be to provide an override for the
> capabilities via platform data?  Requiring some other driver to poke the
> hardware to set the capabilities is a very roundabout way to deal with
> things.
>
> We should probably revert that quirk unless I'm missing something here...
>
>> +++ b/sound/soc/amd/acp.h
>> @@ -0,0 +1,119 @@
>> +#ifndef __ACP_HW_H
>> +#define __ACP_HW_H
>> +
>> +#include "include/acp_2_2_d.h"
>> +#include "include/acp_2_2_sh_mask.h"
>
> I can't find these headers anywhere in the kernel tree or earlier in
> this patch series, this will break the build.  The fact that they've got
> include in the filename is also a bit interesting...
>
>> +#define PAGE_SIZE_4K 4096
>
> SZ_4K exists for this.
>
>> +#define PAGE_SIZE_4K_ENABLE  0x02
>> +
>> +#define PLAYBACK_PTE_OFFSET  10
>> +#define CAPTURE_PTE_OFFSET   0
>
> These defines could all use namespacing, as could some of the others
> later than don't mention ACP.


[PATCH 0/4] drm/exynos: introduce generic zpos property

2016-01-08 Thread Inki Dae
Hi Marek,


2016년 01월 05일 21:52에 Marek Szyprowski 이(가) 쓴 글:
> Hello all,
> 
> This patch series is a continuation of rework of blending support in
> Exynos DRM driver. Some background can be found here:
> http://www.spinics.net/lists/dri-devel/msg96969.html
> 
> Daniel Vetter suggested that zpos property should be made generic, with
> well-defined semantics. This patchset is my proposal for such generic
> zpos property:
> - added zpos properties to drm core and plane state structures,
> - added helpers for normalizing zpos properties of given set of planes,
> - well defined semantics: planes are sorted by zpos values and then plane
>   id value if zpos equals.
> 
> Patches 2/4 and 3/4 are fixes for Exynos DRM driver, which are required

Picked them up. Especially, 2/4 is a good patch.

Thanks,
Inki Dae

> to properly implement generic zpos handling. However they can be also
> merged regardless of the rest of the patches (if there is a need for
> further discussion on the generic zpos property feature).
> 
> Patches are based on top of latest exynos-drm-next branch.
> 
> Best regards
> Marek Szyprowski
> Samsung R Institute Poland
> 
> 
> Patch summary:
> 
> Marek Szyprowski (4):
>   drm: add generic zpos property
>   drm/exynos: crtc: rework atomic_{begin,flush}
>   drm/exynos: mixer: properly update all planes on the same vblank event
>   drm/exynos: use generic code for managing zpos plane property
> 
>  Documentation/DocBook/gpu.tmpl| 14 +-
>  drivers/gpu/drm/drm_atomic.c  |  4 ++
>  drivers/gpu/drm/drm_atomic_helper.c   | 52 
>  drivers/gpu/drm/drm_crtc.c| 13 +
>  drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 14 +++---
>  drivers/gpu/drm/exynos/exynos7_drm_decon.c| 14 +++---
>  drivers/gpu/drm/exynos/exynos_drm_crtc.c  | 20 ++--
>  drivers/gpu/drm/exynos/exynos_drm_drv.h   | 11 ++---
>  drivers/gpu/drm/exynos/exynos_drm_fimd.c  | 14 +++---
>  drivers/gpu/drm/exynos/exynos_drm_plane.c | 68 
> +++
>  drivers/gpu/drm/exynos/exynos_mixer.c | 53 -
>  include/drm/drm_atomic_helper.h   |  2 +
>  include/drm/drm_crtc.h| 13 +
>  13 files changed, 187 insertions(+), 105 deletions(-)
> 


[PATCH v3] drm/exynos: fix kernel panic issue at drm releasing

2016-01-08 Thread Inki Dae
This patch fixes a kernel panic issue which happened
when drm driver is closed while modetest.

This issue could be reproduced easily by launching modetest
with page flip repeatedly.

The reason is that invalid drm_file object could be accessed by
send_vblank_event function when finishing page flip if the drm_file
object was removed by drm_release and there was a pended page
flip event which was already committed to hardware.

So this patch makes the pended page flip event to be cancelled by
preclose callback which is called at front of drm_release function.

Changelog v2:
- free vblank event objects belonging to the request process,
  increment event space and decrease pending_update when cancelling
  the event

Changelog v3:
- initialize only device specific things. Each page flip event object
  is created by DRM core so DRM core should release the object including
  incrementing event space.

Signed-off-by: Inki Dae 
Reviewed-by: Daniel Stone 
---
 drivers/gpu/drm/exynos/exynos_drm_crtc.c | 15 +++
 drivers/gpu/drm/exynos/exynos_drm_crtc.h |  3 +++
 drivers/gpu/drm/exynos/exynos_drm_drv.c  |  5 +
 3 files changed, 23 insertions(+)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c 
b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
index cd94981..8b503a0 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
@@ -226,3 +226,18 @@ void exynos_drm_crtc_te_handler(struct drm_crtc *crtc)
if (exynos_crtc->ops->te_handler)
exynos_crtc->ops->te_handler(exynos_crtc);
 }
+
+void exynos_drm_crtc_cancel_page_flip(struct drm_crtc *crtc)
+{
+   struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
+   struct drm_pending_vblank_event *e;
+   unsigned long flags;
+
+   spin_lock_irqsave(>dev->event_lock, flags);
+   e = exynos_crtc->event;
+   if (e) {
+   exynos_crtc->event = NULL;
+   atomic_dec(_crtc->pending_update);
+   }
+   spin_unlock_irqrestore(>dev->event_lock, flags);
+}
diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.h 
b/drivers/gpu/drm/exynos/exynos_drm_crtc.h
index 6a581a8..b4def6e 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.h
@@ -40,4 +40,7 @@ int exynos_drm_crtc_get_pipe_from_type(struct drm_device 
*drm_dev,
  */
 void exynos_drm_crtc_te_handler(struct drm_crtc *crtc);

+/* This function cancels a page flip request. */
+void exynos_drm_crtc_cancel_page_flip(struct drm_crtc *crtc);
+
 #endif
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c 
b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index 9756797a..57c0e7d 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -330,7 +330,12 @@ err_file_priv_free:
 static void exynos_drm_preclose(struct drm_device *dev,
struct drm_file *file)
 {
+   struct drm_crtc *crtc;
+
exynos_drm_subdrv_close(dev, file);
+
+   list_for_each_entry(crtc, >mode_config.crtc_list, head)
+   exynos_drm_crtc_cancel_page_flip(crtc);
 }

 static void exynos_drm_postclose(struct drm_device *dev, struct drm_file *file)
-- 
1.9.1



[PATCH] drm/exynos: do not free pended event at postclose callback

2016-01-08 Thread Inki Dae
These events will be freed by drm_events_release of DRM core so
it doesn't need to free these events in SoC specific driver.
This patch removes relevant codes from Exynos DRM driver.

Signed-off-by: Inki Dae 
---
 drivers/gpu/drm/exynos/exynos_drm_drv.c | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c 
b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index 57c0e7d..59041d7 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -340,20 +340,9 @@ static void exynos_drm_preclose(struct drm_device *dev,

 static void exynos_drm_postclose(struct drm_device *dev, struct drm_file *file)
 {
-   struct drm_pending_event *e, *et;
-   unsigned long flags;
-
if (!file->driver_priv)
return;

-   spin_lock_irqsave(>event_lock, flags);
-   /* Release all events handled by page flip handler but not freed. */
-   list_for_each_entry_safe(e, et, >event_list, link) {
-   list_del(>link);
-   e->destroy(e);
-   }
-   spin_unlock_irqrestore(>event_lock, flags);
-
kfree(file->driver_priv);
file->driver_priv = NULL;
 }
-- 
1.9.1



[RFC PATCH v2 3/4] drm: rockchip: hdmi: add RK3229 HDMI support

2016-01-08 Thread Yakir Yang
Hi Philipp,

On 01/08/2016 12:50 AM, Philipp Zabel wrote:
> Hi Yakir,
>
> Am Donnerstag, den 07.01.2016, 18:15 +0800 schrieb Yakir Yang:
>> Hi Philipp,
>>
>> Thanks for your fast respond :)
>>
>> On 01/07/2016 06:04 PM, Philipp Zabel wrote:
>>> Am Donnerstag, den 07.01.2016, 17:02 +0800 schrieb Yakir Yang:
 RK3229 integrate an DesignedWare HDMI2.0 controller and an INNO HDMI2.0 
 phy,
 the max output resolution is 4K.

 Signed-off-by: Yakir Yang 
>>> It sounds like the INNO HDMI2.0 phy is not necessarily specific to
>>> RK3229 but might also appear in other SoCs? If so, I think this should
>>> be implemented in a separate phy driver and be used by dw_hdmi-rockchip.
>> Do you mean I should create a new phy driver that place in "driver/phy"
>> directly ?
> Possibly, yes. The exynos video phys are already there. I have kept the
> mediatek dsi/hdmi phys together with the DRM driver, but I suppose I
> could move them there, too.
>
>> I have think about this idea, and it would make things much clean. But
>> INNO PHY
>> driver need the target pixel clock in drm_display_mode, I didn't find a
>> good way
>> to pass this variable to separate phy driver. Do you have some idea ?
> We'd need to extend the PHY API for this. For the mediatek phys we have
> side-stepped the issue by wiring up the PLL output to the common clock
> framework.

Wow, I have look at your "drm/mediatek: Add HDMI support" patch, it's 
great to
registers a common clock framework.

> I expect besides the pixel clock frequency, it might also be necessary
> to inform the PHY about cycles per pixel for deep color modes.

INNO PHY didn't need the color depth directly, driver could get the 
input pixel
clock rate, and then hdmi core driver could set TMDS rate though common
clock framework.

Anyway it's great material, I would update the new version out.

Thanks a lot
- Yakir

> regards
> Philipp
>
>
>
>




[PATCH 00/21] drm_event cleanup

2016-01-08 Thread Alex Deucher
On Fri, Jan 8, 2016 at 3:36 PM, Daniel Vetter  wrote:
> Hi all,
>
> This patch series is inspired by a WIP patch from Rob Clark to consolidate the
> drm_event handling a bit. I've went a bit further and also moved the pending
> event handling and unlinking into the core, which allows us to nuke a bunch of
> code from drivers who all copypasted this themselves. Plus fix up all the 
> others
> who failed to handle this correctly.
>
> Net -500 lines of code, plus kerneldoc for drm_fops.c and all the new 
> functions
> as bonus.
>
> Comments and review highly welcome as usual.

Other than the typo in the comments in patch 2, this series looks good
to me.  With that fixed, the series is:

Reviewed-by: Alex Deucher 

>
> Cheers, Daniel
>
> Daniel Vetter (21):
>   drm: kerneldoc for drm_fops.c
>   drm: Add functions to setup/tear down drm_events.
>   drm/exynos: Use the new event init/free functions
>   drm/vmwgfx: Use the new event init/free functions
>   drm: Create drm_send_event helpers
>   drm/fsl: Remove preclose hook
>   drm/armada: Remove NULL open/pre/postclose hooks
>   drm/gma500: Remove empty preclose hook
>   drm: Clean up pending events in the core
>   drm/i915: Nuke intel_modeset_preclose
>   drm/atmel: Nuke preclose
>   drm/exynos: Remove event cancelling from postclose
>   drm/imx: Unconfuse preclose logic
>   drm/msm: Nuke preclose hooks
>   drm/omap: Nuke close hooks
>   drm/rcar: Nuke preclose hook
>   drm/shmob: Nuke preclose hook
>   drm/tegra: Stop cancelling page flip events
>   drm/tilcdc: Nuke preclose hook
>   drm/vc4: Nuke preclose hook
>   drm/vmwgfx: Nuke preclose hook
>
>  Documentation/DocBook/gpu.tmpl |  48 +
>  drivers/gpu/drm/armada/armada_drv.c|   3 -
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c |  18 --
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c   |  10 -
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h   |   3 -
>  drivers/gpu/drm/drm_atomic.c   |  44 ++---
>  drivers/gpu/drm/drm_crtc.c |  36 +---
>  drivers/gpu/drm/drm_fops.c | 259 
> ++---
>  drivers/gpu/drm/drm_irq.c  |   7 +-
>  drivers/gpu/drm/exynos/exynos_drm_drv.c|  14 --
>  drivers/gpu/drm/exynos/exynos_drm_g2d.c|  36 +---
>  drivers/gpu/drm/exynos/exynos_drm_ipp.c|  28 +--
>  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c  |   5 -
>  drivers/gpu/drm/gma500/psb_drv.c   |   9 -
>  drivers/gpu/drm/i915/i915_dma.c|   2 -
>  drivers/gpu/drm/i915/intel_display.c   |  21 --
>  drivers/gpu/drm/i915/intel_drv.h   |   1 -
>  drivers/gpu/drm/imx/imx-drm-core.c |  13 --
>  drivers/gpu/drm/imx/ipuv3-crtc.c   |   4 -
>  drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c   |   7 -
>  drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c|  11 --
>  drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h|   1 -
>  drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c   |   6 -
>  drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c|  11 --
>  drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h|   1 -
>  drivers/gpu/drm/omapdrm/omap_drv.c |  29 ---
>  drivers/gpu/drm/rcar-du/rcar_du_crtc.c |  20 --
>  drivers/gpu/drm/rcar-du/rcar_du_crtc.h |   2 -
>  drivers/gpu/drm/rcar-du/rcar_du_drv.c  |  10 -
>  drivers/gpu/drm/shmobile/shmob_drm_crtc.c  |  20 --
>  drivers/gpu/drm/shmobile/shmob_drm_crtc.h  |   2 -
>  drivers/gpu/drm/shmobile/shmob_drm_drv.c   |   8 -
>  drivers/gpu/drm/tegra/dc.c |  17 --
>  drivers/gpu/drm/tegra/drm.c|   3 -
>  drivers/gpu/drm/tegra/drm.h|   1 -
>  drivers/gpu/drm/tilcdc/tilcdc_crtc.c   |  20 --
>  drivers/gpu/drm/tilcdc/tilcdc_drv.c|   8 -
>  drivers/gpu/drm/tilcdc/tilcdc_drv.h|   1 -
>  drivers/gpu/drm/vc4/vc4_crtc.c |  20 --
>  drivers/gpu/drm/vc4/vc4_drv.c  |  10 -
>  drivers/gpu/drm/vc4/vc4_drv.h  |   1 -
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c|  10 -
>  drivers/gpu/drm/vmwgfx/vmwgfx_fence.c  |  73 +--
>  drivers/gpu/drm/vmwgfx/vmwgfx_fence.h  |   2 -
>  include/drm/drmP.h |  26 ++-
>  45 files changed, 299 insertions(+), 582 deletions(-)
>
> --
> 2.6.4
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel


[pull] radeon and amdgpu drm-next-4.5

2016-01-08 Thread Alex Deucher
Hi Dave,

Misc fixes for amdgpu and radeon for 4.5.  Pretty much the same as the
requst I sent yesterday minus the ttm and dependent CS ioctl fixes from
Christian until we sort out all the additional issues that uncovered.
The bulk of the changes are smatch fixes and cleanups.  This also includes
the DP MST fixes from Mykola.  Beyond that some suspend and resume fixes
and some powerplay fixes.

The following changes since commit c11b8989635166c5a1e6aac1853a847bd664f8db:

  Merge tag 'omapdrm-4.5-resolved' of 
git://git.kernel.org/pub/scm/linux/kernel/git/tomba/linux into drm-next 
(2016-01-01 07:41:52 +1000)

are available in the git repository at:

  git://people.freedesktop.org/~agd5f/linux 

for you to fetch changes up to 13c240ef95e6569956ba9c731a650cecb3603f0e:

  drm/radeon: fix trivial typo in warning message (2016-01-08 15:39:29 -0500)


Alexandre Demers (1):
  drm/radeon: fix trivial typo in warning message

Arnd Bergmann (1):
  drm: powerplay: use div64_s64 instead of do_div

Christian König (1):
  drm/amdgpu: add warning to amdgpu_bo_gpu_offset() v2

Chunming Zhou (1):
  drm/amdgpu: fix NULL in vm_grab_id while S3 back

Dan Carpenter (3):
  drm/amd/powerplay: fix a reversed condition
  drm/amdgpu/cgs: cleanup some indenting
  drm/amd/powerplay: precedence bug in init_non_clock_fields()

Mykola Lysenko (4):
  drm/dp/mst: process broadcast messages correctly
  drm/dp/mst: always send reply for UP request
  drm/dp/mst: fix in MSTB RAD initialization
  drm/dp/mst: fix in RAD element access

Rex Zhu (12):
  drm/amd/powerplay: fix bug that NULL checks are reversed.
  drm/amd/powerplay: fix Smatch static checker warnings with indenting (v2)
  drm/amd/powerplay: fix Smatch static checker warnings
  drm/amd/powerplay: add powerplay valid check to avoid null point. (v2)
  drm/amd/powerplay: Reload and initialize the smc firmware on powerplay 
resume.
  drm/amdgpu: Show gpu load when display gpu performance for Ci.
  drm/amdgpu: Show gpu load when display gpu performance for Fiji of VI.
  drm/amdgpu: fix hex/decimal bug when show gpu load.
  drm/amd/powerplay: add thermal control task when resume.
  drm/amd/powerplay: enable set boot state task
  drm/amd/powerplay: enable power down asic task. (v2)
  drm/amd/powerplay: implement power down asic task for CZ

Thierry Reding (1):
  drm/radeon: Drop unnecessary unsigned int < 0 check

Tim Gardner (1):
  radeon: r100: Silence 'may be used uninitialized' warnings

Tom St Denis (8):
  amdgpu/vce3: Cleanup harvest config function.
  amdgpu/vce3: Simplify idle and wait for idle code
  amdgpu/vce3: Simplify vce_v3_0_soft_reset()
  amdgpu/vce3: Simplify vce_v3_0_process_interrupt()
  amdgpu/vce3: Remove magic constants from harvest register masks.
  amdgpu/vce3: Simplify vce_v3_0_hw_init and ensure both rings default to 
not ready.
  amdgpu/dce11: Remove division from dce_v11_0_vblank_wait()
  amdgpu/dce11:  Add test for crtc < 0 to various DCEv11 functions

 drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c|  18 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.h |   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c |   2 +-
 drivers/gpu/drm/amd/amdgpu/ci_dpm.c|  14 +-
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c |  16 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c  |   1 -
 drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c  |   1 -
 drivers/gpu/drm/amd/amdgpu/vce_v3_0.c  |  89 +---
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c  |  32 +-
 .../drm/amd/powerplay/eventmgr/eventactionchains.c |   1 +
 .../gpu/drm/amd/powerplay/eventmgr/eventtasks.c|   9 +-
 drivers/gpu/drm/amd/powerplay/eventmgr/psm.c   |   3 +-
 drivers/gpu/drm/amd/powerplay/eventmgr/psm.h   |   2 +-
 drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c |  75 ++-
 drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c   |  64 ++-
 .../gpu/drm/amd/powerplay/hwmgr/fiji_powertune.c   |  12 +-
 .../gpu/drm/amd/powerplay/hwmgr/functiontables.c   |  13 +-
 .../gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c  |  18 +-
 drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c|   3 +
 drivers/gpu/drm/amd/powerplay/hwmgr/ppevvmath.h| 555 ++---
 .../gpu/drm/amd/powerplay/hwmgr/processpptables.c  |  15 +-
 drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c  |  40 +-
 .../amd/powerplay/hwmgr/tonga_processpptables.c|  20 +-
 .../gpu/drm/amd/powerplay/inc/hardwaremanager.h|   2 +
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h  |   6 +-
 drivers/gpu/drm/amd/powerplay/inc/pp_instance.h|   3 +
 drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c   |   2 +-
 drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c |  10 +-
 .../gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c|   2 +-
 drivers/gpu/drm/drm_dp_mst_topology.c  | 141 --
 

[PATCH 02/21] drm: Add functions to setup/tear down drm_events.

2016-01-08 Thread Alex Deucher
On Fri, Jan 8, 2016 at 3:36 PM, Daniel Vetter  wrote:
> An attempt at not spreading out the file_priv->event_space stuff out
> quite so far and wide.  And I think fixes something in ipp_get_event()
> that is broken (or if they are doing something more weird/subtle, then
> breaks it in a fun way).
>
> Based upon a patch from Rob Clark, rebased and polished.
>
> Cc: Rob Clark 
> Signed-off-by: Daniel Vetter 
> ---
>  drivers/gpu/drm/drm_atomic.c | 44 -
>  drivers/gpu/drm/drm_crtc.c   | 36 +++-
>  drivers/gpu/drm/drm_fops.c   | 67 
> 
>  include/drm/drmP.h   |  7 -
>  4 files changed, 94 insertions(+), 60 deletions(-)
>

> +
> +/**
> + * drm_event_reserve_init - init a DRM event and reserve space for it
> + * @dev: DRM device
> + * @file_priv: DRM file private data
> + * @p: tracking structure for the pending event
> + * @e: actual event data to deliver to userspace
> + *
> + * This function prepares the passed in even for eventual deliver. If the 
> event

Typo even -> event, deliver -> delivery

Alex


[patch] drm: move MODULE_PARM_DESC to other file

2016-01-08 Thread Daniel Vetter
On Fri, Jan 08, 2016 at 02:00:45PM +0300, Dan Carpenter wrote:
> We moved the module options from drm_drv.c to drm_irq.c in 18882995713d
> ('drm: Move vblank related module options into drm_irq.c').  Let's move
> the MODULE_PARM_DESC()s as well so they're together.
> 
> Signed-off-by: Dan Carpenter 

Yeah makes sense. Applied to drm-misc, thanks.
-Daniel

> 
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index bf934cde..167c8d3 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -44,10 +44,6 @@ MODULE_AUTHOR(CORE_AUTHOR);
>  MODULE_DESCRIPTION(CORE_DESC);
>  MODULE_LICENSE("GPL and additional rights");
>  MODULE_PARM_DESC(debug, "Enable debug output");
> -MODULE_PARM_DESC(vblankoffdelay, "Delay until vblank irq auto-disable 
> [msecs] (0: never disable, <0: disable immediately)");
> -MODULE_PARM_DESC(timestamp_precision_usec, "Max. error on timestamps 
> [usecs]");
> -MODULE_PARM_DESC(timestamp_monotonic, "Use monotonic timestamps");
> -
>  module_param_named(debug, drm_debug, int, 0600);
>  
>  static DEFINE_SPINLOCK(drm_minor_lock);
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index 607f493..d12a4ef 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -73,6 +73,9 @@ static int drm_vblank_offdelay = 5000;/* Default to 
> 5000 msecs. */
>  module_param_named(vblankoffdelay, drm_vblank_offdelay, int, 0600);
>  module_param_named(timestamp_precision_usec, drm_timestamp_precision, int, 
> 0600);
>  module_param_named(timestamp_monotonic, drm_timestamp_monotonic, int, 0600);
> +MODULE_PARM_DESC(vblankoffdelay, "Delay until vblank irq auto-disable 
> [msecs] (0: never disable, <0: disable immediately)");
> +MODULE_PARM_DESC(timestamp_precision_usec, "Max. error on timestamps 
> [usecs]");
> +MODULE_PARM_DESC(timestamp_monotonic, "Use monotonic timestamps");
>  
>  static void store_vblank(struct drm_device *dev, unsigned int pipe,
>u32 vblank_count_inc,

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


[PATCH v2] drm/edid: index CEA/HDMI mode tables using the VIC

2016-01-08 Thread Daniel Vetter
On Fri, Jan 08, 2016 at 01:30:29PM +0200, Ville Syrjälä wrote:
> On Fri, Jan 08, 2016 at 01:21:51PM +0200, Jani Nikula wrote:
> > Add a dummy entry to CEA/HDMI mode tables so they can be indexed
> > directly using the VIC, avoiding a +1/-1 dance here and there. This adds
> > clarity to the error checking for various functions that return the VIC
> > on success and zero on failure; we can now explicitly check for 0
> > instead of just subtracting one from an unsigned type.
> > 
> > Also add drm_valid_cea_vic() and drm_valid_hdmi_vic() helpers for
> > checking valid VICs.
> > 
> > v2: add drm_valid_cea_vic and drm_valid_hdmi_vic helpers (Ville)
> > use { } instead of { 0 } for initializing the dummy modes
> > 
> > Cc: Ville Syrjälä 
> > Cc: Alex Deucher 
> > Signed-off-by: Jani Nikula 
> 
> Reviewed-by: Ville Syrjälä 

Applied to drm-misc, thanks.
-Daniel

> 
> > ---
> >  drivers/gpu/drm/drm_edid.c | 94 
> > ++
> >  1 file changed, 53 insertions(+), 41 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > index c214f1246cb4..04cb4877fabd 100644
> > --- a/drivers/gpu/drm/drm_edid.c
> > +++ b/drivers/gpu/drm/drm_edid.c
> > @@ -637,8 +637,12 @@ static const struct minimode extra_modes[] = {
> >  /*
> >   * Probably taken from CEA-861 spec.
> >   * This table is converted from xorg's hw/xfree86/modes/xf86EdidModes.c.
> > + *
> > + * Index using the VIC.
> >   */
> >  static const struct drm_display_mode edid_cea_modes[] = {
> > +   /* 0 - dummy, VICs start at 1 */
> > +   { },
> > /* 1 - 640x480 at 60Hz */
> > { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25175, 640, 656,
> >752, 800, 0, 480, 490, 492, 525, 0,
> > @@ -987,9 +991,11 @@ static const struct drm_display_mode edid_cea_modes[] 
> > = {
> >  };
> >  
> >  /*
> > - * HDMI 1.4 4k modes.
> > + * HDMI 1.4 4k modes. Index using the VIC.
> >   */
> >  static const struct drm_display_mode edid_4k_modes[] = {
> > +   /* 0 - dummy, VICs start at 1 */
> > +   { },
> > /* 1 - 3840x2160 at 30Hz */
> > { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000,
> >3840, 4016, 4104, 4400, 0,
> > @@ -2548,13 +2554,13 @@ cea_mode_alternate_clock(const struct 
> > drm_display_mode *cea_mode)
> >  static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode 
> > *to_match,
> >  unsigned int clock_tolerance)
> >  {
> > -   u8 mode;
> > +   u8 vic;
> >  
> > if (!to_match->clock)
> > return 0;
> >  
> > -   for (mode = 0; mode < ARRAY_SIZE(edid_cea_modes); mode++) {
> > -   const struct drm_display_mode *cea_mode = _cea_modes[mode];
> > +   for (vic = 1; vic < ARRAY_SIZE(edid_cea_modes); vic++) {
> > +   const struct drm_display_mode *cea_mode = _cea_modes[vic];
> > unsigned int clock1, clock2;
> >  
> > /* Check both 60Hz and 59.94Hz */
> > @@ -2566,7 +2572,7 @@ static u8 drm_match_cea_mode_clock_tolerance(const 
> > struct drm_display_mode *to_m
> > continue;
> >  
> > if (drm_mode_equal_no_clocks(to_match, cea_mode))
> > -   return mode + 1;
> > +   return vic;
> > }
> >  
> > return 0;
> > @@ -2581,13 +2587,13 @@ static u8 drm_match_cea_mode_clock_tolerance(const 
> > struct drm_display_mode *to_m
> >   */
> >  u8 drm_match_cea_mode(const struct drm_display_mode *to_match)
> >  {
> > -   u8 mode;
> > +   u8 vic;
> >  
> > if (!to_match->clock)
> > return 0;
> >  
> > -   for (mode = 0; mode < ARRAY_SIZE(edid_cea_modes); mode++) {
> > -   const struct drm_display_mode *cea_mode = _cea_modes[mode];
> > +   for (vic = 1; vic < ARRAY_SIZE(edid_cea_modes); vic++) {
> > +   const struct drm_display_mode *cea_mode = _cea_modes[vic];
> > unsigned int clock1, clock2;
> >  
> > /* Check both 60Hz and 59.94Hz */
> > @@ -2597,12 +2603,17 @@ u8 drm_match_cea_mode(const struct drm_display_mode 
> > *to_match)
> > if ((KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock1) ||
> >  KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock2)) &&
> > drm_mode_equal_no_clocks_no_stereo(to_match, cea_mode))
> > -   return mode + 1;
> > +   return vic;
> > }
> > return 0;
> >  }
> >  EXPORT_SYMBOL(drm_match_cea_mode);
> >  
> > +static bool drm_valid_cea_vic(u8 vic)
> > +{
> > +   return vic > 0 && vic < ARRAY_SIZE(edid_cea_modes);
> > +}
> > +
> >  /**
> >   * drm_get_cea_aspect_ratio - get the picture aspect ratio corresponding to
> >   * the input VIC from the CEA mode list
> > @@ -2612,10 +2623,7 @@ EXPORT_SYMBOL(drm_match_cea_mode);
> >   */
> >  enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code)
> >  {
> > -   /* return picture aspect ratio for video_code - 1 to access the
> > -* right array element
> > -   */
> > -   return 

AMD: amdgpu/radeonsi support for mobile FirePro?

2016-01-08 Thread Alex Deucher
On Fri, Jan 8, 2016 at 3:00 PM, Alex G.S.  wrote:
> Dear Radeon Devs,
>
> What's the support status of the  AMD FirePro W5170M and AMD FirePro W5130M.
> I'm confused as to whether these will support 'radeonsi' or 'amdgpu'.  After
> doing exhaustive research I've come across codenames like Tropo XT/LE and
> Mars XT/LE.  On some forums a pci-id was mentioned '6821' but I can't find
> this anywhere in the pcidb lists in either 'xf86-video-amdgpu' or
> 'xf86-video-ati'.
>
> When I looked at the the Radeon feature matrix on [1] I'm unable to
> categorize these two GPU models into any of the categories S.Islands,
> C.Islands or V.Islands.  So are these GPU's supported by 'radeonsi' or by
> 'amdgpu'?  If they're 'radeonsi' what's the support like for those models,
> can I expect relatively good performance?

The are Cape Verde based asics (Southern Islands family).  They are
supported by the radeon kernel module and they use the radeonsi mesa
driver for 3D, etc.  amdgpu is a kernel driver for VI (Volcanic
Islands) and newer parts.  The radeonsi mesa driver supports SI and CI
parts supported by the radeon kernel driver and VI parts supported by
the amdgpu kernel driver.

Alex


>
> Thank you!
>
> --- Alex G.S.
>
> [1] http://xorg.freedesktop.org/wiki/RadeonFeature/
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>


[PATCH] MAINTAINERS: update for Freescale DCU DRM driver

2016-01-08 Thread Dave Airlie
On 7 January 2016 at 16:02, Stefan Agner  wrote:
> Promote myself as new maintainer of the Freescale DCU DRM driver.
>
> Signed-off-by: Stefan Agner 
> ---
> This has been previously discussed privately. The original driver
> author and maintainer Jianwei does not work for Freescale anymore
> and can not carve out spare time to maintain the driver.
>
> As I started to make use of the driver on the Freescale Vybrid SoC
> and already posted several fixes and improvements, I am willing to
> maintain the driver.
>
> Thanks Jianwei for your work on that driver!
>
> Dave, I hope you are OK with that?

Sounds good to me.

Dave.
>
> I plan to send a pull request with the patches which have been on the
> ml lately, specifically the "Fix no fb check bug" and my fixes and
> enhancements patchset, along with this maintainer change, does that
> sound reasonable?
>
> There is one more pending patchset for this drivers, the TCON and
> Vybrid support patchset, but this is probably not ready yet. I also
> plan to post another patchset which enables multiple overlay planes
> and a cursor plane.
>
> --
> Stefan
>
>  MAINTAINERS | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index e9caa4b..3f0aea3 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -3678,7 +3678,7 @@ F:include/drm/exynos*
>  F: include/uapi/drm/exynos*
>
>  DRM DRIVERS FOR FREESCALE DCU
> -M: Jianwei Wang 
> +M: Stefan Agner 
>  M: Alison Wang 
>  L: dri-devel at lists.freedesktop.org
>  S: Supported
> --
> 2.6.4
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel


AMD: amdgpu/radeonsi support for mobile FirePro?

2016-01-08 Thread Alex G.S.
Dear Radeon Devs,

What's the support status of the  AMD FirePro W5170M and AMD FirePro
W5130M.  I'm confused as to whether these will support 'radeonsi' or
'amdgpu'.  After doing exhaustive research I've come across codenames like
Tropo XT/LE and Mars XT/LE.  On some forums a pci-id was mentioned '6821'
but I can't find this anywhere in the pcidb lists in either
'xf86-video-amdgpu' or 'xf86-video-ati'.

When I looked at the the Radeon feature matrix on [1] I'm unable to
categorize these two GPU models into any of the categories
S.Islands, C.Islands or V.Islands.  So are these GPU's supported by
'radeonsi' or by 'amdgpu'?  If they're 'radeonsi' what's the support like
for those models, can I expect relatively good performance?

Thank you!

--- Alex G.S.

[1] http://xorg.freedesktop.org/wiki/RadeonFeature/
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20160108/05938670/attachment.html>


[pull] radeon and amdgpu drm-next-4.5

2016-01-08 Thread Alex Deucher
On Thu, Jan 7, 2016 at 5:34 PM, Alex Deucher  wrote:
> Hi Dave,
>
> Misc fixes for amdgpu and radeon for 4.5.  The bulk of the changes
> are smatch fixes and cleanups.  This also includes the DP MST fixes
> from Mykola.  Beyond that some fixes from Christian to avoid -ENOMEM
> errors in some corner cases in the CS ioctl, some suspend and resume
> fixes, and some powerplay fixes.

Hi Dave,

Please ignore this for now.  We dug up some ttm bugs so I'd like to
drop a few of these patches until we have those sorted out.  I'll send
and updated pull request shortly.

Thanks,

Alex

>
> The following changes since commit c11b8989635166c5a1e6aac1853a847bd664f8db:
>
>   Merge tag 'omapdrm-4.5-resolved' of 
> git://git.kernel.org/pub/scm/linux/kernel/git/tomba/linux into drm-next 
> (2016-01-01 07:41:52 +1000)
>
> are available in the git repository at:
>
>   git://people.freedesktop.org/~agd5f/linux drm-next-4.5
>
> for you to fetch changes up to 9cf452d68290c83862f2456e18c515aa63adb37d:
>
>   amdgpu/pm:  Change strncmp to strcmp to match the parameters precisely. 
> (2016-01-07 17:10:49 -0500)
>
> 
> Arnd Bergmann (1):
>   drm: powerplay: use div64_s64 instead of do_div
>
> Christian König (13):
>   drm/ttm: add ttm_bo_move_to_lru_tail function
>   drm/amdgpu: move VM page tables to the LRU end on CS
>   drm/amdgpu: validate duplicates first
>   drm/amdgpu: fix amdgpu_cs_get_threshold_for_moves handling
>   drm/amdgpu: cleanup amdgpu_cs_list_validate
>   drm/amdgpu: group VM mapping tree with it's lock (v2)
>   drm/amdgpu: cleanup amdgpu_cs_parser structure
>   drm/amdgpu: cleanup amdgpu_cs_parser_relocs
>   drm/amdgpu: cleanup bo list bucket handling
>   drm/amdgpu: keep the prefered/allowed domains in the BO
>   drm/amdgpu: search only the BO list for VM mappings
>   drm/amdgpu: try to find BO VAs only for the BOs in the list
>   drm/amdgpu: add warning to amdgpu_bo_gpu_offset() v2
>
> Chunming Zhou (1):
>   drm/amdgpu: fix NULL in vm_grab_id while S3 back
>
> Dan Carpenter (3):
>   drm/amd/powerplay: fix a reversed condition
>   drm/amdgpu/cgs: cleanup some indenting
>   drm/amd/powerplay: precedence bug in init_non_clock_fields()
>
> Mykola Lysenko (4):
>   drm/dp/mst: process broadcast messages correctly
>   drm/dp/mst: always send reply for UP request
>   drm/dp/mst: fix in MSTB RAD initialization
>   drm/dp/mst: fix in RAD element access
>
> Rex Zhu (12):
>   drm/amd/powerplay: fix bug that NULL checks are reversed.
>   drm/amd/powerplay: fix Smatch static checker warnings with indenting 
> (v2)
>   drm/amd/powerplay: fix Smatch static checker warnings
>   drm/amd/powerplay: add powerplay valid check to avoid null point. (v2)
>   drm/amd/powerplay: Reload and initialize the smc firmware on powerplay 
> resume.
>   drm/amdgpu: Show gpu load when display gpu performance for Ci.
>   drm/amdgpu: Show gpu load when display gpu performance for Fiji of VI.
>   drm/amdgpu: fix hex/decimal bug when show gpu load.
>   drm/amd/powerplay: add thermal control task when resume.
>   drm/amd/powerplay: enable set boot state task
>   drm/amd/powerplay: enable power down asic task. (v2)
>   drm/amd/powerplay: implement power down asic task for CZ
>
> Thierry Reding (1):
>   drm/radeon: Drop unnecessary unsigned int < 0 check
>
> Tom St Denis (9):
>   amdgpu/vce3: Cleanup harvest config function.
>   amdgpu/vce3: Simplify idle and wait for idle code
>   amdgpu/vce3: Simplify vce_v3_0_soft_reset()
>   amdgpu/vce3: Simplify vce_v3_0_process_interrupt()
>   amdgpu/vce3: Remove magic constants from harvest register masks.
>   amdgpu/vce3: Simplify vce_v3_0_hw_init and ensure both rings default to 
> not ready.
>   amdgpu/dce11: Remove division from dce_v11_0_vblank_wait()
>   amdgpu/dce11:  Add test for crtc < 0 to various DCEv11 functions
>   amdgpu/pm:  Change strncmp to strcmp to match the parameters precisely.
>
>  drivers/gpu/drm/amd/amdgpu/amdgpu.h|  33 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c|  51 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c|  18 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 186 +++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c|  16 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c |  15 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_object.h |   1 +
>  drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c |  14 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c |  14 +-
>  drivers/gpu/drm/amd/amdgpu/ci_dpm.c|  14 +-
>  drivers/gpu/drm/amd/amdgpu/dce_v11_0.c |  16 +-
>  drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c  |   1 -
>  drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c  |   1 -
>  drivers/gpu/drm/amd/amdgpu/vce_v3_0.c  |  89 +---
>  

[PATCH] drm/ttm: fix adding foreign BOs to the LRU during init

2016-01-08 Thread Christian König
From: Christian König 

If we import a BO with an eternal reservation object we don't
reserve/unreserve it. So we never add it to the LRU causing a possible
deny of service.

Signed-off-by: Christian König 
---
 drivers/gpu/drm/ttm/ttm_bo.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 745e996..a98a5d5 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1170,9 +1170,15 @@ int ttm_bo_init(struct ttm_bo_device *bdev,
if (likely(!ret))
ret = ttm_bo_validate(bo, placement, interruptible, false);

-   if (!resv)
+   if (!resv) {
ttm_bo_unreserve(bo);

+   } else if (!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) {
+   spin_lock(>glob->lru_lock);
+   ttm_bo_add_to_lru(bo);
+   spin_unlock(>glob->lru_lock);
+   }
+
if (unlikely(ret))
ttm_bo_unref();

-- 
2.5.0



[Bug 88263] Civilization Beyond Earth crashes on r600

2016-01-08 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=88263

--- Comment #8 from oleid at mescharet.de ---
I just tried it again with current git (Mesa 11.2.0-devel (git-040e314)). It
works for me with with low settings. I played a few turns - it seems to be
fine, albeit a bit slow. When using medium settings, the game hits the assert:

CivBE: ../nptl/pthread_mutex_lock.c:353: __pthread_mutex_lock_full: Assertion
`(-(e)) != 3 || !robust' failed.

and doesn't start. But there is no system crash.

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


[patch] drm: move MODULE_PARM_DESC to other file

2016-01-08 Thread Dan Carpenter
We moved the module options from drm_drv.c to drm_irq.c in 18882995713d
('drm: Move vblank related module options into drm_irq.c').  Let's move
the MODULE_PARM_DESC()s as well so they're together.

Signed-off-by: Dan Carpenter 

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index bf934cde..167c8d3 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -44,10 +44,6 @@ MODULE_AUTHOR(CORE_AUTHOR);
 MODULE_DESCRIPTION(CORE_DESC);
 MODULE_LICENSE("GPL and additional rights");
 MODULE_PARM_DESC(debug, "Enable debug output");
-MODULE_PARM_DESC(vblankoffdelay, "Delay until vblank irq auto-disable [msecs] 
(0: never disable, <0: disable immediately)");
-MODULE_PARM_DESC(timestamp_precision_usec, "Max. error on timestamps [usecs]");
-MODULE_PARM_DESC(timestamp_monotonic, "Use monotonic timestamps");
-
 module_param_named(debug, drm_debug, int, 0600);

 static DEFINE_SPINLOCK(drm_minor_lock);
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 607f493..d12a4ef 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -73,6 +73,9 @@ static int drm_vblank_offdelay = 5000;/* Default to 5000 
msecs. */
 module_param_named(vblankoffdelay, drm_vblank_offdelay, int, 0600);
 module_param_named(timestamp_precision_usec, drm_timestamp_precision, int, 
0600);
 module_param_named(timestamp_monotonic, drm_timestamp_monotonic, int, 0600);
+MODULE_PARM_DESC(vblankoffdelay, "Delay until vblank irq auto-disable [msecs] 
(0: never disable, <0: disable immediately)");
+MODULE_PARM_DESC(timestamp_precision_usec, "Max. error on timestamps [usecs]");
+MODULE_PARM_DESC(timestamp_monotonic, "Use monotonic timestamps");

 static void store_vblank(struct drm_device *dev, unsigned int pipe,
 u32 vblank_count_inc,


[PATCH v2 3/3] drm/bridge: add Silicon Image SiI8620 driver

2016-01-08 Thread Andrzej Hajda
SiI8620 transmitter converts eTMDS/HDMI signal to MHL 3.0.
It is controlled via I2C bus. Its interaction with other
devices in video pipeline is performed mainly on HW level.
The only interaction it does on device driver level is
filtering-out unsupported video modes, it exposes drm_bridge
interface to perform this operation.

Signed-off-by: Andrzej Hajda 
---
v2:
- changed specifier of INT pin from gpio to interrupt property
---
 drivers/gpu/drm/bridge/Kconfig   |7 +
 drivers/gpu/drm/bridge/Makefile  |1 +
 drivers/gpu/drm/bridge/sil-sii8620.c | 1560 ++
 drivers/gpu/drm/bridge/sil-sii8620.h | 1517 +
 4 files changed, 3085 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/sil-sii8620.c
 create mode 100644 drivers/gpu/drm/bridge/sil-sii8620.h

diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index 27e2022..c91735f 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -40,4 +40,11 @@ config DRM_PARADE_PS8622
---help---
  Parade eDP-LVDS bridge chip driver.

+config DRM_SIL_SII8620
+   tristate "Silicon Image SII8620 HDMI/MHL bridge"
+   depends on OF
+   select DRM_KMS_HELPER
+   help
+ Silicon Image SII8620 HDMI/MHL bridge chip driver.
+
 endmenu
diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
index f13c33d..50dd844 100644
--- a/drivers/gpu/drm/bridge/Makefile
+++ b/drivers/gpu/drm/bridge/Makefile
@@ -4,3 +4,4 @@ obj-$(CONFIG_DRM_DW_HDMI) += dw-hdmi.o
 obj-$(CONFIG_DRM_DW_HDMI_AHB_AUDIO) += dw-hdmi-ahb-audio.o
 obj-$(CONFIG_DRM_NXP_PTN3460) += nxp-ptn3460.o
 obj-$(CONFIG_DRM_PARADE_PS8622) += parade-ps8622.o
+obj-$(CONFIG_DRM_SIL_SII8620) += sil-sii8620.o
diff --git a/drivers/gpu/drm/bridge/sil-sii8620.c 
b/drivers/gpu/drm/bridge/sil-sii8620.c
new file mode 100644
index 000..0bd893f
--- /dev/null
+++ b/drivers/gpu/drm/bridge/sil-sii8620.c
@@ -0,0 +1,1560 @@
+/*
+ * Driver for Silicon Image SiI8620 Mobile HD Transmitter
+ *
+ * Copyright (C) 2015, Samsung Electronics Co., Ltd.
+ * Andrzej Hajda 
+ *
+ * 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.
+ */
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "sil-sii8620.h"
+
+#define VAL_RX_HDMI_CTRL2_DEFVAL   VAL_RX_HDMI_CTRL2_IDLE_CNT(3)
+
+enum sii8620_mode {
+   CM_DISCONNECTED,
+   CM_DISCOVERY,
+   CM_MHL1,
+   CM_MHL3,
+   CM_ECBUS_S
+};
+
+enum sii8620_sink_type {
+   SINK_NONE,
+   SINK_HDMI,
+   SINK_DVI
+};
+
+enum sii8620_mt_state {
+   MT_STATE_READY,
+   MT_STATE_BUSY,
+   MT_STATE_DONE
+};
+
+struct sii8620 {
+   struct drm_bridge bridge;
+   struct device *dev;
+   struct clk *clk_xtal;
+   struct gpio_desc *gpio_reset;
+   struct gpio_desc *gpio_int;
+   struct regulator_bulk_data supplies[2];
+   struct mutex lock; /* context lock, protects fields below */
+   int error;
+   enum sii8620_mode mode;
+   enum sii8620_sink_type sink_type;
+   u8 cbus_status;
+   u8 stat[MHL_DST_SIZE];
+   u8 xstat[MHL_XDS_SIZE];
+   u8 devcap[MHL_DCAP_SIZE];
+   u8 xdevcap[MHL_XDC_SIZE];
+   u8 avif[19];
+   struct edid *edid;
+   unsigned int gen2_write_burst:1;
+   enum sii8620_mt_state mt_state;
+   struct list_head mt_queue;
+};
+
+struct sii8620_mt_msg;
+
+typedef void (*sii8620_mt_msg_cb)(struct sii8620 *ctx,
+ struct sii8620_mt_msg *msg);
+
+struct sii8620_mt_msg {
+   struct list_head node;
+   u8 reg[4];
+   u8 ret;
+   sii8620_mt_msg_cb send;
+   sii8620_mt_msg_cb recv;
+};
+
+static const u8 sii8620_i2c_page[] = {
+   0x39, /* Main System */
+   0x3d, /* TDM and HSIC */
+   0x49, /* TMDS Receiver, MHL EDID */
+   0x4d, /* eMSC, HDCP, HSIC */
+   0x5d, /* MHL Spec */
+   0x64, /* MHL CBUS */
+   0x59, /* Hardware TPI (Transmitter Programming Interface) */
+   0x61, /* eCBUS-S, eCBUS-D */
+};
+
+static void sii8620_fetch_edid(struct sii8620 *ctx);
+static void sii8620_set_upstream_edid(struct sii8620 *ctx);
+static void sii8620_enable_hpd(struct sii8620 *ctx);
+static void sii8620_mhl_disconnected(struct sii8620 *ctx);
+
+static int sii8620_clear_error(struct sii8620 *ctx)
+{
+   int ret = ctx->error;
+
+   ctx->error = 0;
+   return ret;
+}
+
+static void sii8620_read_buf(struct sii8620 *ctx, u16 addr, u8 *buf, int len)
+{
+   struct device *dev = ctx->dev;
+   struct i2c_client *client = to_i2c_client(dev);
+   u8 data = addr;
+   struct i2c_msg msg[] = {
+   {
+   .addr = sii8620_i2c_page[addr >> 8],
+

[PATCH v2 2/3] dt-bindings: add Silicon Image SiI8620 bridge bindings

2016-01-08 Thread Andrzej Hajda
SiI8620 transmitter converts eTMDS/HDMI signal to MHL 3.0. It is controlled
via I2C bus.

Signed-off-by: Andrzej Hajda 
---
v2:
- changed specifier of INT pin from gpio to interrupt property,
- improved description.
---
 .../bindings/video/bridge/sil-sii8620.txt  | 33 ++
 1 file changed, 33 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/video/bridge/sil-sii8620.txt

diff --git a/Documentation/devicetree/bindings/video/bridge/sil-sii8620.txt 
b/Documentation/devicetree/bindings/video/bridge/sil-sii8620.txt
new file mode 100644
index 000..9409d9c
--- /dev/null
+++ b/Documentation/devicetree/bindings/video/bridge/sil-sii8620.txt
@@ -0,0 +1,33 @@
+Silicon Image SiI8620 HDMI/MHL bridge bindings
+
+Required properties:
+   - compatible: "sil,sii8620"
+   - reg: i2c address of the bridge
+   - cvcc10-supply: Digital Core Supply Voltage (1.0V)
+   - iovcc18-supply: I/O Supply Voltage (1.8V)
+   - interrupts, interrupt-parent: interrupt specifier of INT pin
+   - reset-gpios: gpio specifier of RESET pin
+   - clocks, clock-names: specification and name of "xtal" clock
+   - video interfaces: Device node can contain video interface port
+   node for HDMI encoder according to [1].
+
+[1]: Documentation/devicetree/bindings/media/video-interfaces.txt
+
+Example:
+   sii8620 at 39 {
+   reg = <0x39>;
+   compatible = "sil,sii8620";
+   cvcc10-supply = <_reg>;
+   iovcc18-supply = <_reg>;
+   interrupt-parent = <>;
+   interrupts = <2 0>;
+   reset-gpio = < 0 0>;
+   clocks = <_system_controller 0>;
+   clock-names = "xtal";
+
+   port {
+   mhl_to_hdmi: endpoint {
+   remote-endpoint = <_to_mhl>;
+   };
+   };
+   };
-- 
1.9.1



[PATCH v2 1/3] video: add header file for Mobile High-Definition Link (MHL) interface

2016-01-08 Thread Andrzej Hajda
This header adds definitions specific to MHL protocol.

Signed-off-by: Andrzej Hajda 
---
 include/linux/mhl.h | 292 
 1 file changed, 292 insertions(+)
 create mode 100644 include/linux/mhl.h

diff --git a/include/linux/mhl.h b/include/linux/mhl.h
new file mode 100644
index 000..6917508
--- /dev/null
+++ b/include/linux/mhl.h
@@ -0,0 +1,292 @@
+/*
+ * Defines for Mobile High-Definition Link (MHL) interface
+ *
+ * Copyright (C) 2015, Samsung Electronics, Co., Ltd.
+ * Andrzej Hajda 
+ *
+ * Based on MHL driver for Android devices.
+ * Copyright (C) 2013-2014 Silicon Image, Inc.
+ *
+ * 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.
+ */
+
+#ifndef LINUX_MHL_H
+#define LINUX_MHL_H
+
+/* Device Capabilities Registers */
+enum {
+   MHL_DCAP_DEV_STATE,
+   MHL_DCAP_MHL_VERSION,
+   MHL_DCAP_CAT,
+   MHL_DCAP_ADOPTER_ID_H,
+   MHL_DCAP_ADOPTER_ID_L,
+   MHL_DCAP_VID_LINK_MODE,
+   MHL_DCAP_AUD_LINK_MODE,
+   MHL_DCAP_VIDEO_TYPE,
+   MHL_DCAP_LOG_DEV_MAP,
+   MHL_DCAP_BANDWIDTH,
+   MHL_DCAP_FEATURE_FLAG,
+   MHL_DCAP_DEVICE_ID_H,
+   MHL_DCAP_DEVICE_ID_L,
+   MHL_DCAP_SCRATCHPAD_SIZE,
+   MHL_DCAP_INT_STAT_SIZE,
+   MHL_DCAP_RESERVED,
+   MHL_DCAP_SIZE
+};
+
+#define MHL_DCAP_CAT_SINK  0x01
+#define MHL_DCAP_CAT_SOURCE0x02
+#define MHL_DCAP_CAT_POWER 0x10
+#define MHL_DCAP_CAT_PLIM(x)   ((x) << 5)
+
+#define MHL_DCAP_VID_LINK_RGB444   0x01
+#define MHL_DCAP_VID_LINK_YCBCR444 0x02
+#define MHL_DCAP_VID_LINK_YCBCR422 0x04
+#define MHL_DCAP_VID_LINK_PPIXEL   0x08
+#define MHL_DCAP_VID_LINK_ISLANDS  0x10
+#define MHL_DCAP_VID_LINK_VGA  0x20
+#define MHL_DCAP_VID_LINK_16BPP0x40
+
+#define MHL_DCAP_AUD_LINK_2CH  0x01
+#define MHL_DCAP_AUD_LINK_8CH  0x02
+
+#define MHL_DCAP_VT_GRAPHICS   0x00
+#define MHL_DCAP_VT_PHOTO  0x02
+#define MHL_DCAP_VT_CINEMA 0x04
+#define MHL_DCAP_VT_GAMES  0x08
+#define MHL_DCAP_SUPP_VT   0x80
+
+#define MHL_DCAP_LD_DISPLAY0x01
+#define MHL_DCAP_LD_VIDEO  0x02
+#define MHL_DCAP_LD_AUDIO  0x04
+#define MHL_DCAP_LD_MEDIA  0x08
+#define MHL_DCAP_LD_TUNER  0x10
+#define MHL_DCAP_LD_RECORD 0x20
+#define MHL_DCAP_LD_SPEAKER0x40
+#define MHL_DCAP_LD_GUI0x80
+#define MHL_DCAP_LD_ALL0xFF
+
+#define MHL_DCAP_FEATURE_RCP_SUPPORT   0x01
+#define MHL_DCAP_FEATURE_RAP_SUPPORT   0x02
+#define MHL_DCAP_FEATURE_SP_SUPPORT0x04
+#define MHL_DCAP_FEATURE_UCP_SEND_SUPPOR   0x08
+#define MHL_DCAP_FEATURE_UCP_RECV_SUPPORT  0x10
+#define MHL_DCAP_FEATURE_RBP_SUPPORT   0x40
+
+/* Extended Device Capabilities Registers */
+enum {
+   MHL_XDC_ECBUS_SPEEDS,
+   MHL_XDC_TMDS_SPEEDS,
+   MHL_XDC_ECBUS_ROLES,
+   MHL_XDC_LOG_DEV_MAPX,
+   MHL_XDC_SIZE
+};
+
+#define MHL_XDC_ECBUS_S_0750x01
+#define MHL_XDC_ECBUS_S_8BIT   0x02
+#define MHL_XDC_ECBUS_S_12BIT  0x04
+#define MHL_XDC_ECBUS_D_1500x10
+#define MHL_XDC_ECBUS_D_8BIT   0x20
+
+#define MHL_XDC_TMDS_000   0x00
+#define MHL_XDC_TMDS_150   0x01
+#define MHL_XDC_TMDS_300   0x02
+#define MHL_XDC_TMDS_600   0x04
+
+/* MHL_XDC_ECBUS_ROLES flags */
+#define MHL_XDC_DEV_HOST   0x01
+#define MHL_XDC_DEV_DEVICE 0x02
+#define MHL_XDC_DEV_CHARGER0x04
+#define MHL_XDC_HID_HOST   0x08
+#define MHL_XDC_HID_DEVICE 0x10
+
+/* MHL_XDC_LOG_DEV_MAPX flags */
+#define MHL_XDC_LD_PHONE   0x01
+
+/* Device Status Registers */
+enum {
+   MHL_DST_CONNECTED_RDY,
+   MHL_DST_LINK_MODE,
+   MHL_DST_VERSION,
+   MHL_DST_SIZE
+};
+
+/* Offset of DEVSTAT registers */
+#define MHL_DST_OFFSET 0x30
+#define MHL_DST_REG(name) (MHL_DST_OFFSET + MHL_DST_##name)
+
+#define MHL_DST_CONN_DCAP_RDY  0x01
+#define MHL_DST_CONN_XDEVCAPP_SUPP 0x02
+#define MHL_DST_CONN_POW_STAT  0x04
+#define MHL_DST_CONN_PLIM_STAT_MASK0x38
+
+#define MHL_DST_LM_CLK_MODE_MASK   0x07
+#define MHL_DST_LM_CLK_MODE_PACKED_PIXEL   0x02
+#define MHL_DST_LM_CLK_MODE_NORMAL 0x03
+#define 

[PATCH v2 0/3] drm/bridge: add Silicon Image SiI8620 driver

2016-01-08 Thread Andrzej Hajda
Hi,

This version of patchset contains fixes of interrupt pin and binding description
according to Rob Herring comments.

This patchset adds MHL bridge driver for Silicon Image SiI8620 chip.
The chip is quite powerful, supports MHL versions up to 3.0. It is present
in multiple mobile devices.

I have put common MHL definitions into include/linux/mhl.h header file,
similarily to include/linux/hdmi.h.

The patchset is based on latest exynos-drm-next branch.

Regards
Andrzej


Andrzej Hajda (3):
  video: add header file for Mobile High-Definition Link (MHL) interface
  dt-bindings: add Silicon Image SiI8620 bridge bindings
  drm/bridge: add Silicon Image SiI8620 driver

 .../bindings/video/bridge/sil-sii8620.txt  |   33 +
 drivers/gpu/drm/bridge/Kconfig |7 +
 drivers/gpu/drm/bridge/Makefile|1 +
 drivers/gpu/drm/bridge/sil-sii8620.c   | 1560 
 drivers/gpu/drm/bridge/sil-sii8620.h   | 1517 +++
 include/linux/mhl.h|  292 
 6 files changed, 3410 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/video/bridge/sil-sii8620.txt
 create mode 100644 drivers/gpu/drm/bridge/sil-sii8620.c
 create mode 100644 drivers/gpu/drm/bridge/sil-sii8620.h
 create mode 100644 include/linux/mhl.h

-- 
1.9.1



[PATCH v2] drm/edid: index CEA/HDMI mode tables using the VIC

2016-01-08 Thread Ville Syrjälä
On Fri, Jan 08, 2016 at 01:21:51PM +0200, Jani Nikula wrote:
> Add a dummy entry to CEA/HDMI mode tables so they can be indexed
> directly using the VIC, avoiding a +1/-1 dance here and there. This adds
> clarity to the error checking for various functions that return the VIC
> on success and zero on failure; we can now explicitly check for 0
> instead of just subtracting one from an unsigned type.
> 
> Also add drm_valid_cea_vic() and drm_valid_hdmi_vic() helpers for
> checking valid VICs.
> 
> v2: add drm_valid_cea_vic and drm_valid_hdmi_vic helpers (Ville)
> use { } instead of { 0 } for initializing the dummy modes
> 
> Cc: Ville Syrjälä 
> Cc: Alex Deucher 
> Signed-off-by: Jani Nikula 

Reviewed-by: Ville Syrjälä 

> ---
>  drivers/gpu/drm/drm_edid.c | 94 
> ++
>  1 file changed, 53 insertions(+), 41 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index c214f1246cb4..04cb4877fabd 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -637,8 +637,12 @@ static const struct minimode extra_modes[] = {
>  /*
>   * Probably taken from CEA-861 spec.
>   * This table is converted from xorg's hw/xfree86/modes/xf86EdidModes.c.
> + *
> + * Index using the VIC.
>   */
>  static const struct drm_display_mode edid_cea_modes[] = {
> + /* 0 - dummy, VICs start at 1 */
> + { },
>   /* 1 - 640x480 at 60Hz */
>   { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25175, 640, 656,
>  752, 800, 0, 480, 490, 492, 525, 0,
> @@ -987,9 +991,11 @@ static const struct drm_display_mode edid_cea_modes[] = {
>  };
>  
>  /*
> - * HDMI 1.4 4k modes.
> + * HDMI 1.4 4k modes. Index using the VIC.
>   */
>  static const struct drm_display_mode edid_4k_modes[] = {
> + /* 0 - dummy, VICs start at 1 */
> + { },
>   /* 1 - 3840x2160 at 30Hz */
>   { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000,
>  3840, 4016, 4104, 4400, 0,
> @@ -2548,13 +2554,13 @@ cea_mode_alternate_clock(const struct 
> drm_display_mode *cea_mode)
>  static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode 
> *to_match,
>unsigned int clock_tolerance)
>  {
> - u8 mode;
> + u8 vic;
>  
>   if (!to_match->clock)
>   return 0;
>  
> - for (mode = 0; mode < ARRAY_SIZE(edid_cea_modes); mode++) {
> - const struct drm_display_mode *cea_mode = _cea_modes[mode];
> + for (vic = 1; vic < ARRAY_SIZE(edid_cea_modes); vic++) {
> + const struct drm_display_mode *cea_mode = _cea_modes[vic];
>   unsigned int clock1, clock2;
>  
>   /* Check both 60Hz and 59.94Hz */
> @@ -2566,7 +2572,7 @@ static u8 drm_match_cea_mode_clock_tolerance(const 
> struct drm_display_mode *to_m
>   continue;
>  
>   if (drm_mode_equal_no_clocks(to_match, cea_mode))
> - return mode + 1;
> + return vic;
>   }
>  
>   return 0;
> @@ -2581,13 +2587,13 @@ static u8 drm_match_cea_mode_clock_tolerance(const 
> struct drm_display_mode *to_m
>   */
>  u8 drm_match_cea_mode(const struct drm_display_mode *to_match)
>  {
> - u8 mode;
> + u8 vic;
>  
>   if (!to_match->clock)
>   return 0;
>  
> - for (mode = 0; mode < ARRAY_SIZE(edid_cea_modes); mode++) {
> - const struct drm_display_mode *cea_mode = _cea_modes[mode];
> + for (vic = 1; vic < ARRAY_SIZE(edid_cea_modes); vic++) {
> + const struct drm_display_mode *cea_mode = _cea_modes[vic];
>   unsigned int clock1, clock2;
>  
>   /* Check both 60Hz and 59.94Hz */
> @@ -2597,12 +2603,17 @@ u8 drm_match_cea_mode(const struct drm_display_mode 
> *to_match)
>   if ((KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock1) ||
>KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock2)) &&
>   drm_mode_equal_no_clocks_no_stereo(to_match, cea_mode))
> - return mode + 1;
> + return vic;
>   }
>   return 0;
>  }
>  EXPORT_SYMBOL(drm_match_cea_mode);
>  
> +static bool drm_valid_cea_vic(u8 vic)
> +{
> + return vic > 0 && vic < ARRAY_SIZE(edid_cea_modes);
> +}
> +
>  /**
>   * drm_get_cea_aspect_ratio - get the picture aspect ratio corresponding to
>   * the input VIC from the CEA mode list
> @@ -2612,10 +2623,7 @@ EXPORT_SYMBOL(drm_match_cea_mode);
>   */
>  enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code)
>  {
> - /* return picture aspect ratio for video_code - 1 to access the
> -  * right array element
> - */
> - return edid_cea_modes[video_code-1].picture_aspect_ratio;
> + return edid_cea_modes[video_code].picture_aspect_ratio;
>  }
>  EXPORT_SYMBOL(drm_get_cea_aspect_ratio);
>  
> @@ -2639,13 +2647,13 @@ hdmi_mode_alternate_clock(const struct 
> drm_display_mode *hdmi_mode)
>  

[PATCH v2] drm/edid: index CEA/HDMI mode tables using the VIC

2016-01-08 Thread Jani Nikula
Add a dummy entry to CEA/HDMI mode tables so they can be indexed
directly using the VIC, avoiding a +1/-1 dance here and there. This adds
clarity to the error checking for various functions that return the VIC
on success and zero on failure; we can now explicitly check for 0
instead of just subtracting one from an unsigned type.

Also add drm_valid_cea_vic() and drm_valid_hdmi_vic() helpers for
checking valid VICs.

v2: add drm_valid_cea_vic and drm_valid_hdmi_vic helpers (Ville)
use { } instead of { 0 } for initializing the dummy modes

Cc: Ville Syrjälä 
Cc: Alex Deucher 
Signed-off-by: Jani Nikula 
---
 drivers/gpu/drm/drm_edid.c | 94 ++
 1 file changed, 53 insertions(+), 41 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index c214f1246cb4..04cb4877fabd 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -637,8 +637,12 @@ static const struct minimode extra_modes[] = {
 /*
  * Probably taken from CEA-861 spec.
  * This table is converted from xorg's hw/xfree86/modes/xf86EdidModes.c.
+ *
+ * Index using the VIC.
  */
 static const struct drm_display_mode edid_cea_modes[] = {
+   /* 0 - dummy, VICs start at 1 */
+   { },
/* 1 - 640x480 at 60Hz */
{ DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25175, 640, 656,
   752, 800, 0, 480, 490, 492, 525, 0,
@@ -987,9 +991,11 @@ static const struct drm_display_mode edid_cea_modes[] = {
 };

 /*
- * HDMI 1.4 4k modes.
+ * HDMI 1.4 4k modes. Index using the VIC.
  */
 static const struct drm_display_mode edid_4k_modes[] = {
+   /* 0 - dummy, VICs start at 1 */
+   { },
/* 1 - 3840x2160 at 30Hz */
{ DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000,
   3840, 4016, 4104, 4400, 0,
@@ -2548,13 +2554,13 @@ cea_mode_alternate_clock(const struct drm_display_mode 
*cea_mode)
 static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode 
*to_match,
 unsigned int clock_tolerance)
 {
-   u8 mode;
+   u8 vic;

if (!to_match->clock)
return 0;

-   for (mode = 0; mode < ARRAY_SIZE(edid_cea_modes); mode++) {
-   const struct drm_display_mode *cea_mode = _cea_modes[mode];
+   for (vic = 1; vic < ARRAY_SIZE(edid_cea_modes); vic++) {
+   const struct drm_display_mode *cea_mode = _cea_modes[vic];
unsigned int clock1, clock2;

/* Check both 60Hz and 59.94Hz */
@@ -2566,7 +2572,7 @@ static u8 drm_match_cea_mode_clock_tolerance(const struct 
drm_display_mode *to_m
continue;

if (drm_mode_equal_no_clocks(to_match, cea_mode))
-   return mode + 1;
+   return vic;
}

return 0;
@@ -2581,13 +2587,13 @@ static u8 drm_match_cea_mode_clock_tolerance(const 
struct drm_display_mode *to_m
  */
 u8 drm_match_cea_mode(const struct drm_display_mode *to_match)
 {
-   u8 mode;
+   u8 vic;

if (!to_match->clock)
return 0;

-   for (mode = 0; mode < ARRAY_SIZE(edid_cea_modes); mode++) {
-   const struct drm_display_mode *cea_mode = _cea_modes[mode];
+   for (vic = 1; vic < ARRAY_SIZE(edid_cea_modes); vic++) {
+   const struct drm_display_mode *cea_mode = _cea_modes[vic];
unsigned int clock1, clock2;

/* Check both 60Hz and 59.94Hz */
@@ -2597,12 +2603,17 @@ u8 drm_match_cea_mode(const struct drm_display_mode 
*to_match)
if ((KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock1) ||
 KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock2)) &&
drm_mode_equal_no_clocks_no_stereo(to_match, cea_mode))
-   return mode + 1;
+   return vic;
}
return 0;
 }
 EXPORT_SYMBOL(drm_match_cea_mode);

+static bool drm_valid_cea_vic(u8 vic)
+{
+   return vic > 0 && vic < ARRAY_SIZE(edid_cea_modes);
+}
+
 /**
  * drm_get_cea_aspect_ratio - get the picture aspect ratio corresponding to
  * the input VIC from the CEA mode list
@@ -2612,10 +2623,7 @@ EXPORT_SYMBOL(drm_match_cea_mode);
  */
 enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code)
 {
-   /* return picture aspect ratio for video_code - 1 to access the
-* right array element
-   */
-   return edid_cea_modes[video_code-1].picture_aspect_ratio;
+   return edid_cea_modes[video_code].picture_aspect_ratio;
 }
 EXPORT_SYMBOL(drm_get_cea_aspect_ratio);

@@ -2639,13 +2647,13 @@ hdmi_mode_alternate_clock(const struct drm_display_mode 
*hdmi_mode)
 static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode 
*to_match,
  unsigned int clock_tolerance)
 {
-   u8 mode;
+   u8 vic;

if (!to_match->clock)
return 0;

-   for 

[PATCH v2 2/3] dt-bindings: add Silicon Image SiI8620 bridge bindings

2016-01-08 Thread Rob Herring
On Fri, Jan 08, 2016 at 01:48:56PM +0100, Andrzej Hajda wrote:
> SiI8620 transmitter converts eTMDS/HDMI signal to MHL 3.0. It is controlled
> via I2C bus.
> 
> Signed-off-by: Andrzej Hajda 
> ---
> v2:
> - changed specifier of INT pin from gpio to interrupt property,
> - improved description.
> ---
>  .../bindings/video/bridge/sil-sii8620.txt  | 33 
> ++
>  1 file changed, 33 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/video/bridge/sil-sii8620.txt

Acked-by: Rob Herring 



drm/amd/powerplay: show gpu load when print gpu performance for Cz. (v2)

2016-01-08 Thread Dan Carpenter
On Fri, Jan 08, 2016 at 03:44:51AM +, Zhu, Rex wrote:
> Hi Dan,
> 
> It is (result == 0).
> 
> From code,  smum_send_msg_to_smc() will return negative a error code or zero.
> 
> 0  mean success.
> 

Hm..  I have investigated more and the problem is typos in
tonga_send_msg_to_smc().


drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c
   183  /**
   184  * Send a message to the SMC, and wait for its response.
   185  *
   186  * @paramsmumgr  the address of the powerplay hardware manager.
   187  * @parammsg the message to send.
   188  * @return   The response that came from the SMC.
   189  */
   190  static int tonga_send_msg_to_smc(struct pp_smumgr *smumgr, uint16_t msg)
   191  {
   192  if (smumgr == NULL || smumgr->device == NULL)
   193  return -EINVAL;
   194  
   195  if (!tonga_is_smc_ram_running(smumgr))
   196  return -1;
   197  
   198  SMUM_WAIT_FIELD_UNEQUAL(smumgr, SMC_RESP_0, SMC_RESP, 0);
   199  PP_ASSERT_WITH_CODE(
   200  1 == SMUM_READ_FIELD(smumgr->device, SMC_RESP_0, 
SMC_RESP),
   201  "Failed to send Previous Message.",
   202  return 1);

We intended to return -EINVAL here.  (returning -1 means -EPERM but it's
sloppy to use -1 instead of -EPERM, -1 is never a valid error code).

   203  
   204  cgs_write_register(smumgr->device, mmSMC_MESSAGE_0, msg);
   205  
   206  SMUM_WAIT_FIELD_UNEQUAL(smumgr, SMC_RESP_0, SMC_RESP, 0);
   207  PP_ASSERT_WITH_CODE(
   208  1 == SMUM_READ_FIELD(smumgr->device, SMC_RESP_0, 
SMC_RESP),
   209  "Failed to send Message.",
   210  return 1);


return -EINVAL;

   211  
   212  return 0;
   213  }

regards,
dan carpenter




[PATCH 3/4] drm: bridge/dw-hdmi: detect initial connector state

2016-01-08 Thread Philipp Zabel
Am Freitag, den 08.01.2016, 11:24 + schrieb Russell King - ARM
Linux:
> On Fri, Jan 08, 2016 at 10:02:06AM +0100, Philipp Zabel wrote:
> > Allow userspace to read the initial connector state via sysfs without
> > having to issue a detect manually. There is no reason to keep the state
> > unknown during initialization.
> 
> Can you describe how it can be unknown?  I've always seen the state to be
> correctly initialised on iMX6 irrespective of whether a sink is connected
> or not.  However, I always have the FB helper and FB console enabled.

I have FB helper and console disabled. Since the kernel doesn't set a
mode automatically, in this case the modes are never requested, and
detect is not called by anyone.

Until userspace issues the detect, either via the DRM API or by writing
"detect" into /sys/class/drm/card0-HDMI-A-1/status, this sysfs file
reads "unknown".

regards
Philipp



[PATCH] drm/radeon: fix trivial typo in warning message

2016-01-08 Thread Alex Deucher
On Thu, Jan 7, 2016 at 7:22 PM, Alexandre Demers
 wrote:
> Signed-off-by: Alexandre Demers 

Applied.  thanks!

Alex

> ---
>  drivers/gpu/drm/radeon/radeon_device.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_device.c 
> b/drivers/gpu/drm/radeon/radeon_device.c
> index c566993..4197ca1 100644
> --- a/drivers/gpu/drm/radeon/radeon_device.c
> +++ b/drivers/gpu/drm/radeon/radeon_device.c
> @@ -1150,7 +1150,7 @@ static void radeon_check_arguments(struct radeon_device 
> *rdev)
> }
>
> if (radeon_vm_size < 1) {
> -   dev_warn(rdev->dev, "VM size (%d) to small, min is 1GB\n",
> +   dev_warn(rdev->dev, "VM size (%d) too small, min is 1GB\n",
>  radeon_vm_size);
> radeon_vm_size = 4;
> }
> --
> 2.6.4
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/3] drm/ttm: add ttm_bo_move_to_lru_tail function

2016-01-08 Thread Alex Deucher
On Fri, Jan 8, 2016 at 4:33 AM, Christian König  
wrote:
> Am 05.01.2016 um 22:34 schrieb Alex Deucher:
>>
>> On Tue, Jan 5, 2016 at 7:16 AM, Christian König 
>> wrote:
>>>
>>> From: Christian König 
>>>
>>> This allows the drivers to move a BO to the end of the LRU
>>> without removing and adding it again.
>>>
>>> Signed-off-by: Christian König 
>>> Reviewed-by: Chunming Zhou 
>>
>> This series is:
>> Reviewed-by: Alex Deucher 
>>
>> Unless there are any objections to the ttm patch, I'd like to pull
>> this series into my drm-next tree.
>
>
> I have objections!
>
> Ok seriously, David and I have found quite a bug around that in TTM. We need
> to fix that before we can push this patch.

I've already included this in my most recent fixes pull request to
Dave.  Should I ask him not to pull and drop this set or is the other
patch you just sent enough to fix it?

Thanks,

Alex


>
> Christian.
>
>
>>
>> Alex
>>
>>> ---
>>>   drivers/gpu/drm/ttm/ttm_bo.c | 20 
>>>   include/drm/ttm/ttm_bo_api.h | 10 ++
>>>   2 files changed, 30 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
>>> index 745e996..9e91cc3 100644
>>> --- a/drivers/gpu/drm/ttm/ttm_bo.c
>>> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
>>> @@ -228,6 +228,26 @@ void ttm_bo_del_sub_from_lru(struct
>>> ttm_buffer_object *bo)
>>>   }
>>>   EXPORT_SYMBOL(ttm_bo_del_sub_from_lru);
>>>
>>> +void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo)
>>> +{
>>> +   struct ttm_bo_device *bdev = bo->bdev;
>>> +   struct ttm_mem_type_manager *man;
>>> +
>>> +   lockdep_assert_held(>resv->lock.base);
>>> +
>>> +   if (!list_empty(>swap)) {
>>> +   list_del(>swap);
>>> +   list_add_tail(>swap, >glob->swap_lru);
>>> +   }
>>> +
>>> +   if (!list_empty(>lru)) {
>>> +   man = >man[bo->mem.mem_type];
>>> +   list_del(>lru);
>>> +   list_add_tail(>lru, >lru);
>>> +   }
>>> +}
>>> +EXPORT_SYMBOL(ttm_bo_move_to_lru_tail);
>>> +
>>>   /*
>>>* Call bo->mutex locked.
>>>*/
>>> diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
>>> index c768ddf..afae231 100644
>>> --- a/include/drm/ttm/ttm_bo_api.h
>>> +++ b/include/drm/ttm/ttm_bo_api.h
>>> @@ -383,6 +383,16 @@ extern void ttm_bo_add_to_lru(struct
>>> ttm_buffer_object *bo);
>>>*/
>>>   extern int ttm_bo_del_from_lru(struct ttm_buffer_object *bo);
>>>
>>> +/**
>>> + * ttm_bo_move_to_lru_tail
>>> + *
>>> + * @bo: The buffer object.
>>> + *
>>> + * Move this BO to the tail of all lru lists used to lookup and reserve
>>> an
>>> + * object. This function must be called with struct
>>> ttm_bo_global::lru_lock
>>> + * held, and is used to make a BO less likely to be considered for
>>> eviction.
>>> + */
>>> +extern void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo);
>>>
>>>   /**
>>>* ttm_bo_lock_delayed_workqueue
>>> --
>>> 2.5.0
>>>
>>> ___
>>> dri-devel mailing list
>>> dri-devel at lists.freedesktop.org
>>> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>
>


[PATCH v4.4-rc8] radeon: r100: Silence 'may be used uninitialized' warnings

2016-01-08 Thread Alex Deucher
On Thu, Jan 7, 2016 at 12:31 PM,   wrote:
> From: Tim Gardner 
>
>   CC [M]  drivers/gpu/drm/radeon/r100.o
> In file included from drivers/gpu/drm/radeon/radeon_mode.h:37:0,
>  from drivers/gpu/drm/radeon/radeon.h:80,
>  from drivers/gpu/drm/radeon/r100.c:33:
> drivers/gpu/drm/radeon/r100.c: In function 'r100_bandwidth_update':
> include/drm/drm_fixed.h:64:13: warning: 'crit_point_ff.full' may be used 
> uninitialized in this function [-Wmaybe-uninitialized]
>   u64 tmp = ((u64)A.full << 13);
>  ^
> drivers/gpu/drm/radeon/r100.c:3153:63: note: 'crit_point_ff.full' was 
> declared here
>   fixed20_12 peak_disp_bw, mem_bw, pix_clk, pix_clk2, temp_ff, crit_point_ff;
>^
> drivers/gpu/drm/radeon/r100.c:3583:42: warning: 'disp_drain_rate.full' may be 
> used uninitialized in this function [-Wmaybe-uninitialized]
>  temp_ff.full = read_return_rate.full - disp_drain_rate.full;
>
> gcc version 5.3.1 20151219 (Ubuntu 5.3.1-4ubuntu1)
>
> Cc: Alex Deucher 
> Cc: "Christian König" 
> Cc: David Airlie 
> Signed-off-by: Tim Gardner 
> ---
>
> I think this warning is bogus, but I don't know how else to make gcc shut up.

It's definitely bogus.  It just showed up in a new version of gcc.  Applied.

Thanks.

Alex

>
>  drivers/gpu/drm/radeon/r100.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
> index 9e7e2bf..5eae0a8 100644
> --- a/drivers/gpu/drm/radeon/r100.c
> +++ b/drivers/gpu/drm/radeon/r100.c
> @@ -3150,7 +3150,8 @@ void r100_bandwidth_update(struct radeon_device *rdev)
>  {
> fixed20_12 trcd_ff, trp_ff, tras_ff, trbs_ff, tcas_ff;
> fixed20_12 sclk_ff, mclk_ff, sclk_eff_ff, sclk_delay_ff;
> -   fixed20_12 peak_disp_bw, mem_bw, pix_clk, pix_clk2, temp_ff, 
> crit_point_ff;
> +   fixed20_12 peak_disp_bw, mem_bw, pix_clk, pix_clk2, temp_ff;
> +   fixed20_12 crit_point_ff = {0};
> uint32_t temp, data, mem_trcd, mem_trp, mem_tras;
> fixed20_12 memtcas_ff[8] = {
> dfixed_init(1),
> @@ -3204,7 +3205,7 @@ void r100_bandwidth_update(struct radeon_device *rdev)
> fixed20_12 min_mem_eff;
> fixed20_12 mc_latency_sclk, mc_latency_mclk, k1;
> fixed20_12 cur_latency_mclk, cur_latency_sclk;
> -   fixed20_12 disp_latency, disp_latency_overhead, disp_drain_rate,
> +   fixed20_12 disp_latency, disp_latency_overhead, disp_drain_rate = {0},
> disp_drain_rate2, read_return_rate;
> fixed20_12 time_disp1_drop_priority;
> int c;
> --
> 1.9.1
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/radeon: fix trivial typo in warning message

2016-01-08 Thread Eric Engestrom
Yes, a quick grep shows the same typo in several places:
> $ grep -Rwn 'to small' drivers/gpu/   
>   
> drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c:544:DRM_ERROR("BO to 
> small for addr 0x%010Lx %d %d\n",
> drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c:648:
> DRM_ERROR("buffer (%d) to small (%d / %d)!\n", cmd,
> drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c:656:
> DRM_ERROR("buffer (%d) to small (%d / %d)!\n", cmd,
> drivers/gpu/drm/radeon/radeon_device.c:1153:dev_warn(rdev->dev, 
> "VM size (%d) to small, min is 1GB\n",
> drivers/gpu/drm/radeon/radeon_vce.c:501:DRM_ERROR("buffer to 
> small (%d / %d)!\n",
> drivers/gpu/drm/radeon/radeon_uvd.c:563:
> DRM_ERROR("buffer (%d) to small (%d / %d)!\n", cmd,

BTW there's also a 'to large' one:
> drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c:342:/* clamp timeout if it's to 
> large */


On 08/01/16 09:35, Christian König wrote:
> Am 08.01.2016 um 01:22 schrieb Alexandre Demers:
>> Signed-off-by: Alexandre Demers 
> 
> Reviewed-by: Christian König .
> 
> We probably need to fix this in amdgpu as well.
> 
> Thanks for the help,
> Christian.
> 
>> ---
>>   drivers/gpu/drm/radeon/radeon_device.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/radeon/radeon_device.c 
>> b/drivers/gpu/drm/radeon/radeon_device.c
>> index c566993..4197ca1 100644
>> --- a/drivers/gpu/drm/radeon/radeon_device.c
>> +++ b/drivers/gpu/drm/radeon/radeon_device.c
>> @@ -1150,7 +1150,7 @@ static void radeon_check_arguments(struct 
>> radeon_device *rdev)
>>  }
>>   
>>  if (radeon_vm_size < 1) {
>> -dev_warn(rdev->dev, "VM size (%d) to small, min is 1GB\n",
>> +dev_warn(rdev->dev, "VM size (%d) too small, min is 1GB\n",
>>   radeon_vm_size);
>>  radeon_vm_size = 4;
>>  }
> 
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
> 


[PATCH] etnaviv: etnaviv_drv: Remove owner assignment from platform_driver

2016-01-08 Thread Fabio Estevam
This platform_driver does not need to set an owner as it will be
populated by the driver core.

Generated by scripts/coccinelle/api/platform_no_drv_owner.cocci.

Signed-off-by: Fabio Estevam 
---
 drivers/gpu/drm/etnaviv/etnaviv_drv.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c 
b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index 5c89ebb..e885898 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -668,7 +668,6 @@ static struct platform_driver etnaviv_platform_driver = {
.probe  = etnaviv_pdev_probe,
.remove = etnaviv_pdev_remove,
.driver = {
-   .owner  = THIS_MODULE,
.name   = "etnaviv",
.of_match_table = dt_match,
},
-- 
1.9.1



[PATCH 4/4] drm: bridge/dw-hdmi: use rx sense for plug detection if hpd is unreliable

2016-01-08 Thread Russell King - ARM Linux
On Fri, Jan 08, 2016 at 10:02:07AM +0100, Philipp Zabel wrote:
> Due to the voltage divider on the HPD line, the HDMI connector on
> imx6q-sabrelite doesn't reliably detect connected DVI monitors.
> This patch allows to use the RX_SENSE signals as a workaround when
> enabled by a boolean device tree property 'hpd-unreliable'.

There's a got-cha here.  On iMX6S, the RXSENSE interrupts bounce
around madly if the HDMI interface is not fully configured.  I've
seen this many times at boot time (I've been carrying a patch which
reports the HPD/RXSENSE state to the kernel log for a long time now,
it can be rather noisy.)

It's also out-of-spec for reading the EDID: the EDID is only valid
when HPD is asserted.  When HPD is deasserted, the EDID may not be
accessible.  Using RXSENSE opens a window where the EDID may be
unavailable, or may be mid-way through being updated depending on
how the sink hardware works.

With a Yamaha RX-V677 AV receiver and a Panasonic TV, I've observed
this:

initial(-rxsense,-hpd), AV standby, TV standby.
Connected to AV: +rxsense, +hpd
EDID reads from AV
TV standby->on: -hpd, 2s, +hpd
EDID reads from TV
AV standby->on: -hpd, 1.2s, +hpd
EDID reads combined TV/AV
AV on->standby: -hpd, 1.2s, +hpd
EDID reads from TV

Note that RXSENSE did not drop, but the EDID changed, and that change
was properly signalled via HPD according to the HDMI standard.

-- 
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.


[PATCH 3/4] drm: bridge/dw-hdmi: detect initial connector state

2016-01-08 Thread Russell King - ARM Linux
On Fri, Jan 08, 2016 at 10:02:06AM +0100, Philipp Zabel wrote:
> Allow userspace to read the initial connector state via sysfs without
> having to issue a detect manually. There is no reason to keep the state
> unknown during initialization.

Can you describe how it can be unknown?  I've always seen the state to be
correctly initialised on iMX6 irrespective of whether a sink is connected
or not.  However, I always have the FB helper and FB console enabled.

-- 
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.


[RESEND,V2] drm: fsl-dcu: Fix no fb check bug

2016-01-08 Thread Emil Velikov
Hi guys,

Am I loosing the plot here or something feels amiss here ?

On 6 January 2016 at 06:12, Meng Yi  wrote:
> For state->fb or state->crtc may be NULL in fsl_dcu_drm_plane_atomic_check
> function, if so, return 0.
>
> Signed-off-by: Meng Yi 
> Signed-off-by: Jianwei Wang 
>
> ---
>
> change in v2:
> -Add state->crtc check
> -return 0 when state->fb or state->crtc is NULL, instead of -EINVAL
> Adviced by Daniel Stone
>
>  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c 
> b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
> index 4b13cf9..8965580 100644
> --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
> +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
> @@ -41,6 +41,9 @@ static int fsl_dcu_drm_plane_atomic_check(struct drm_plane 
> *plane,
>  {
> struct drm_framebuffer *fb = state->fb;
>
> +   if (!state->fb || !state->crtc)
> +   return 0;
> +
Namely: if we return success here core drm will end up calling the
atomic_update...

> switch (fb->pixel_format) {
> case DRM_FORMAT_RGB565:
> case DRM_FORMAT_RGB888:
> @@ -85,9 +88,6 @@ static void fsl_dcu_drm_plane_atomic_update(struct 
> drm_plane *plane,
> unsigned int alpha, bpp;
> int index, ret;
>
> -   if (!fb)
> -   return;
> -
... which no longer has the !fb check, and we'll crash with null deref
a few lines below ?

-Emil


[PATCH] drm/radeon: fix trivial typo in warning message

2016-01-08 Thread Christian König
Am 08.01.2016 um 01:22 schrieb Alexandre Demers:
> Signed-off-by: Alexandre Demers 

Reviewed-by: Christian König .

We probably need to fix this in amdgpu as well.

Thanks for the help,
Christian.

> ---
>   drivers/gpu/drm/radeon/radeon_device.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_device.c 
> b/drivers/gpu/drm/radeon/radeon_device.c
> index c566993..4197ca1 100644
> --- a/drivers/gpu/drm/radeon/radeon_device.c
> +++ b/drivers/gpu/drm/radeon/radeon_device.c
> @@ -1150,7 +1150,7 @@ static void radeon_check_arguments(struct radeon_device 
> *rdev)
>   }
>   
>   if (radeon_vm_size < 1) {
> - dev_warn(rdev->dev, "VM size (%d) to small, min is 1GB\n",
> + dev_warn(rdev->dev, "VM size (%d) too small, min is 1GB\n",
>radeon_vm_size);
>   radeon_vm_size = 4;
>   }



[PATCH 1/3] drm/ttm: add ttm_bo_move_to_lru_tail function

2016-01-08 Thread Christian König
Am 05.01.2016 um 22:34 schrieb Alex Deucher:
> On Tue, Jan 5, 2016 at 7:16 AM, Christian König  
> wrote:
>> From: Christian König 
>>
>> This allows the drivers to move a BO to the end of the LRU
>> without removing and adding it again.
>>
>> Signed-off-by: Christian König 
>> Reviewed-by: Chunming Zhou 
> This series is:
> Reviewed-by: Alex Deucher 
>
> Unless there are any objections to the ttm patch, I'd like to pull
> this series into my drm-next tree.

I have objections!

Ok seriously, David and I have found quite a bug around that in TTM. We 
need to fix that before we can push this patch.

Christian.

>
> Alex
>
>> ---
>>   drivers/gpu/drm/ttm/ttm_bo.c | 20 
>>   include/drm/ttm/ttm_bo_api.h | 10 ++
>>   2 files changed, 30 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
>> index 745e996..9e91cc3 100644
>> --- a/drivers/gpu/drm/ttm/ttm_bo.c
>> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
>> @@ -228,6 +228,26 @@ void ttm_bo_del_sub_from_lru(struct ttm_buffer_object 
>> *bo)
>>   }
>>   EXPORT_SYMBOL(ttm_bo_del_sub_from_lru);
>>
>> +void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo)
>> +{
>> +   struct ttm_bo_device *bdev = bo->bdev;
>> +   struct ttm_mem_type_manager *man;
>> +
>> +   lockdep_assert_held(>resv->lock.base);
>> +
>> +   if (!list_empty(>swap)) {
>> +   list_del(>swap);
>> +   list_add_tail(>swap, >glob->swap_lru);
>> +   }
>> +
>> +   if (!list_empty(>lru)) {
>> +   man = >man[bo->mem.mem_type];
>> +   list_del(>lru);
>> +   list_add_tail(>lru, >lru);
>> +   }
>> +}
>> +EXPORT_SYMBOL(ttm_bo_move_to_lru_tail);
>> +
>>   /*
>>* Call bo->mutex locked.
>>*/
>> diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
>> index c768ddf..afae231 100644
>> --- a/include/drm/ttm/ttm_bo_api.h
>> +++ b/include/drm/ttm/ttm_bo_api.h
>> @@ -383,6 +383,16 @@ extern void ttm_bo_add_to_lru(struct ttm_buffer_object 
>> *bo);
>>*/
>>   extern int ttm_bo_del_from_lru(struct ttm_buffer_object *bo);
>>
>> +/**
>> + * ttm_bo_move_to_lru_tail
>> + *
>> + * @bo: The buffer object.
>> + *
>> + * Move this BO to the tail of all lru lists used to lookup and reserve an
>> + * object. This function must be called with struct ttm_bo_global::lru_lock
>> + * held, and is used to make a BO less likely to be considered for eviction.
>> + */
>> +extern void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo);
>>
>>   /**
>>* ttm_bo_lock_delayed_workqueue
>> --
>> 2.5.0
>>
>> ___
>> dri-devel mailing list
>> dri-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/dri-devel



[PATCH 4/4] drm: bridge/dw-hdmi: use rx sense for plug detection if hpd is unreliable

2016-01-08 Thread Philipp Zabel
Due to the voltage divider on the HPD line, the HDMI connector on
imx6q-sabrelite doesn't reliably detect connected DVI monitors.
This patch allows to use the RX_SENSE signals as a workaround when
enabled by a boolean device tree property 'hpd-unreliable'.

Signed-off-by: Philipp Zabel 
---
 drivers/gpu/drm/bridge/dw-hdmi.c | 30 --
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/bridge/dw-hdmi.c b/drivers/gpu/drm/bridge/dw-hdmi.c
index 2388a55..7ffaa44 100644
--- a/drivers/gpu/drm/bridge/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/dw-hdmi.c
@@ -111,6 +111,7 @@ struct dw_hdmi {
struct device *dev;
struct clk *isfr_clk;
struct clk *iahb_clk;
+   bool hpd_unreliable;

struct hdmi_data_info hdmi_data;
const struct dw_hdmi_plat_data *plat_data;
@@ -1413,6 +1414,8 @@ dw_hdmi_connector_detect(struct drm_connector *connector, 
bool force)
 {
struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi,
 connector);
+   /* If HPD is not reliable, use RX_SENSE as fallback */
+   u8 stat_mask = hdmi->hpd_unreliable ? HDMI_PHY_RX_SENSE : HDMI_PHY_HPD;

mutex_lock(>mutex);
hdmi->force = DRM_FORCE_UNSPECIFIED;
@@ -1420,7 +1423,7 @@ dw_hdmi_connector_detect(struct drm_connector *connector, 
bool force)
dw_hdmi_update_phy_mask(hdmi);
mutex_unlock(>mutex);

-   if (hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_HPD)
+   if ((hdmi_readb(hdmi, HDMI_PHY_STAT0) & stat_mask) == stat_mask)
return connector_status_connected;

/* free previous EDID block */
@@ -1556,7 +1559,7 @@ static irqreturn_t dw_hdmi_hardirq(int irq, void *dev_id)
 static irqreturn_t dw_hdmi_irq(int irq, void *dev_id)
 {
struct dw_hdmi *hdmi = dev_id;
-   u8 intr_stat, phy_int_pol, phy_pol_mask, phy_stat;
+   u8 intr_stat, intr_mask, phy_int_pol, phy_pol_mask, phy_stat;

intr_stat = hdmi_readb(hdmi, HDMI_IH_PHY_STAT0);
phy_int_pol = hdmi_readb(hdmi, HDMI_PHY_POL0);
@@ -1583,9 +1586,12 @@ static irqreturn_t dw_hdmi_irq(int irq, void *dev_id)
 * other end of the link.  Use this to decide whether we should
 * power on the phy as HPD may be toggled by the sink to merely
 * ask the source to re-read the EDID.
+* If HPD is known to be unreliable, ignore it completely.
 */
-   if (intr_stat &
-   (HDMI_IH_PHY_STAT0_RX_SENSE | HDMI_IH_PHY_STAT0_HPD)) {
+   intr_mask = hdmi->hpd_unreliable ?
+   HDMI_IH_PHY_STAT0_RX_SENSE :
+   HDMI_IH_PHY_STAT0_RX_SENSE | HDMI_IH_PHY_STAT0_HPD;
+   if (intr_stat & intr_mask) {
mutex_lock(>mutex);
if (!hdmi->disabled && !hdmi->force) {
/*
@@ -1594,14 +1600,14 @@ static irqreturn_t dw_hdmi_irq(int irq, void *dev_id)
 */
if (!(phy_stat & HDMI_PHY_RX_SENSE))
hdmi->rxsense = false;
-
/*
 * Only set the software rxsense status when both
 * rxsense and hpd indicates we're connected.
 * This avoids what seems to be bad behaviour in
 * at least iMX6S versions of the phy.
 */
-   if (phy_stat & HDMI_PHY_HPD)
+   else if ((phy_stat & HDMI_PHY_HPD) ||
+hdmi->hpd_unreliable)
hdmi->rxsense = true;

dw_hdmi_update_power(hdmi);
@@ -1617,8 +1623,7 @@ static irqreturn_t dw_hdmi_irq(int irq, void *dev_id)
}

hdmi_writeb(hdmi, intr_stat, HDMI_IH_PHY_STAT0);
-   hdmi_writeb(hdmi, ~(HDMI_IH_PHY_STAT0_HPD | HDMI_IH_PHY_STAT0_RX_SENSE),
-   HDMI_IH_MUTE_PHY_STAT0);
+   hdmi_writeb(hdmi, ~intr_mask, HDMI_IH_MUTE_PHY_STAT0);

return IRQ_HANDLED;
 }
@@ -1679,6 +1684,7 @@ int dw_hdmi_bind(struct device *dev, struct device 
*master,
struct device_node *ddc_node;
struct dw_hdmi_audio_data audio;
struct dw_hdmi *hdmi;
+   u8 intr_mask;
int ret;
u32 val = 1;

@@ -1770,6 +1776,8 @@ int dw_hdmi_bind(struct device *dev, struct device 
*master,

initialize_hdmi_ih_mutes(hdmi);

+   hdmi->hpd_unreliable = of_property_read_bool(np, "hpd-unreliable");
+
ret = devm_request_threaded_irq(dev, irq, dw_hdmi_hardirq,
dw_hdmi_irq, IRQF_SHARED,
dev_name(dev), hdmi);
@@ -1801,8 +1809,10 @@ int dw_hdmi_bind(struct device *dev, struct device 
*master,
goto err_iahb;

/* Unmute interrupts */
-   hdmi_writeb(hdmi, ~(HDMI_IH_PHY_STAT0_HPD | HDMI_IH_PHY_STAT0_RX_SENSE),
-   HDMI_IH_MUTE_PHY_STAT0);
+   

[PATCH 3/4] drm: bridge/dw-hdmi: detect initial connector state

2016-01-08 Thread Philipp Zabel
Allow userspace to read the initial connector state via sysfs without
having to issue a detect manually. There is no reason to keep the state
unknown during initialization.

Signed-off-by: Philipp Zabel 
---
 drivers/gpu/drm/bridge/dw-hdmi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/bridge/dw-hdmi.c b/drivers/gpu/drm/bridge/dw-hdmi.c
index e41ff4b..2388a55 100644
--- a/drivers/gpu/drm/bridge/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/dw-hdmi.c
@@ -1660,6 +1660,8 @@ static int dw_hdmi_register(struct drm_device *drm, 
struct dw_hdmi *hdmi)
   DRM_MODE_CONNECTOR_HDMIA);

hdmi->connector.encoder = encoder;
+   hdmi->connector.status = dw_hdmi_connector_detect(>connector,
+ false);

drm_mode_connector_attach_encoder(>connector, encoder);

-- 
2.6.4



[PATCH 2/4] drm: bridge/dw-hdmi: remove unused code

2016-01-08 Thread Philipp Zabel
From: Sascha Hauer 

The cable_plugin field in struct dw_hdmi is never set. Remove it and with
it all code that is only executed when the variable is true.

Signed-off-by: Sascha Hauer 
Signed-off-by: Philipp Zabel 
---
 drivers/gpu/drm/bridge/dw-hdmi.c | 17 -
 1 file changed, 17 deletions(-)

diff --git a/drivers/gpu/drm/bridge/dw-hdmi.c b/drivers/gpu/drm/bridge/dw-hdmi.c
index b0ebf92..e41ff4b 100644
--- a/drivers/gpu/drm/bridge/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/dw-hdmi.c
@@ -118,7 +118,6 @@ struct dw_hdmi {
int vic;

struct edid *edid;
-   bool cable_plugin;

bool phy_enabled;
struct drm_display_mode previous_mode;
@@ -1158,24 +1157,10 @@ static void dw_hdmi_clear_overflow(struct dw_hdmi *hdmi)
hdmi_writeb(hdmi, val, HDMI_FC_INVIDCONF);
 }

-static void hdmi_enable_overflow_interrupts(struct dw_hdmi *hdmi)
-{
-   hdmi_writeb(hdmi, 0, HDMI_FC_MASK2);
-   hdmi_writeb(hdmi, 0, HDMI_IH_MUTE_FC_STAT2);
-}
-
-static void hdmi_disable_overflow_interrupts(struct dw_hdmi *hdmi)
-{
-   hdmi_writeb(hdmi, HDMI_IH_MUTE_FC_STAT2_OVERFLOW_MASK,
-   HDMI_IH_MUTE_FC_STAT2);
-}
-
 static int dw_hdmi_setup(struct dw_hdmi *hdmi, struct drm_display_mode *mode)
 {
int ret;

-   hdmi_disable_overflow_interrupts(hdmi);
-
hdmi->vic = drm_match_cea_mode(mode);

if (!hdmi->vic) {
@@ -1240,8 +1225,6 @@ static int dw_hdmi_setup(struct dw_hdmi *hdmi, struct 
drm_display_mode *mode)
hdmi_tx_hdcp_config(hdmi);

dw_hdmi_clear_overflow(hdmi);
-   if (hdmi->cable_plugin && hdmi->sink_is_hdmi)
-   hdmi_enable_overflow_interrupts(hdmi);

return 0;
 }
-- 
2.6.4



[PATCH 1/4] drm: bridge/dw-hdmi: cache edid data

2016-01-08 Thread Philipp Zabel
From: Sascha Hauer 

Instead of rereading the edid data each time userspace asks for them,
read them once and cache them in the previously unused edid field in
struct dw_hdmi. When the connector is disconnected, drop the cached
edid data.

Signed-off-by: Sascha Hauer 
Signed-off-by: Philipp Zabel 
---
 drivers/gpu/drm/bridge/dw-hdmi.c | 43 
 1 file changed, 26 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/bridge/dw-hdmi.c b/drivers/gpu/drm/bridge/dw-hdmi.c
index 6fbec99..b0ebf92 100644
--- a/drivers/gpu/drm/bridge/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/dw-hdmi.c
@@ -117,7 +117,7 @@ struct dw_hdmi {

int vic;

-   u8 edid[HDMI_EDID_LEN];
+   struct edid *edid;
bool cable_plugin;

bool phy_enabled;
@@ -1437,32 +1437,41 @@ dw_hdmi_connector_detect(struct drm_connector 
*connector, bool force)
dw_hdmi_update_phy_mask(hdmi);
mutex_unlock(>mutex);

-   return hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_HPD ?
-   connector_status_connected : connector_status_disconnected;
+   if (hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_HPD)
+   return connector_status_connected;
+
+   /* free previous EDID block */
+   if (hdmi->edid) {
+   drm_mode_connector_update_edid_property(connector, NULL);
+   kfree(hdmi->edid);
+   hdmi->edid = NULL;
+   }
+
+   return connector_status_disconnected;
 }

 static int dw_hdmi_connector_get_modes(struct drm_connector *connector)
 {
struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi,
 connector);
-   struct edid *edid;
int ret = 0;

-   if (!hdmi->ddc)
-   return 0;
-
-   edid = drm_get_edid(connector, hdmi->ddc);
-   if (edid) {
-   dev_dbg(hdmi->dev, "got edid: width[%d] x height[%d]\n",
-   edid->width_cm, edid->height_cm);
+   if (hdmi->ddc && !hdmi->edid) {
+   hdmi->edid = drm_get_edid(connector, hdmi->ddc);
+   if (hdmi->edid) {
+   hdmi->sink_is_hdmi = 
drm_detect_hdmi_monitor(hdmi->edid);
+   hdmi->sink_has_audio = 
drm_detect_monitor_audio(hdmi->edid);
+   drm_mode_connector_update_edid_property(connector,
+   hdmi->edid);
+   dev_dbg(hdmi->dev, "got edid: width[%d] x height[%d]\n",
+   hdmi->edid->width_cm, hdmi->edid->height_cm);
+   }
+   }

-   hdmi->sink_is_hdmi = drm_detect_hdmi_monitor(edid);
-   hdmi->sink_has_audio = drm_detect_monitor_audio(edid);
-   drm_mode_connector_update_edid_property(connector, edid);
-   ret = drm_add_edid_modes(connector, edid);
+   if (hdmi->edid) {
+   ret = drm_add_edid_modes(connector, hdmi->edid);
/* Store the ELD */
-   drm_edid_to_eld(connector, edid);
-   kfree(edid);
+   drm_edid_to_eld(connector, hdmi->edid);
} else {
dev_dbg(hdmi->dev, "failed to get edid\n");
}
-- 
2.6.4



[PATCH 1/1] apple-gmux: Add initial documentation

2016-01-08 Thread Jonathan Corbet
On Mon, 4 Jan 2016 12:21:40 -0800
Darren Hart  wrote:

> Any concerns with this series? If not, I'll take it in via the pdx86 tree.
> 
Well, it's built around the asciidoc patch, which isn't in the mainline
at this point.  Should things go a different direction, that could force
some changes here; meanwhile, it won't build 100% as intended on most
systems.  It's intelligible anyway, though, and it's good to have the
information there, so I won't resist too hard.

I've not had a real chance to look seriously at the asciidoc stuff yet;
too much time dealing with sick people, foreign health systems, and such.
Very soon, I hope.

jon


drm/amd/powerplay: show gpu load when print gpu performance for Cz. (v2)

2016-01-08 Thread Zhu, Rex
Hi Dan,

It is (result == 0).


[PATCH v11 2/4] PM / Domains: add setter for dev.pm_domain

2016-01-08 Thread Rafael J. Wysocki
On Thursday, January 07, 2016 03:47:01 PM Tomeu Vizoso wrote:
> On 10 November 2015 at 10:33, Daniel Kurtz  wrote:
> [snip]
> >
> > The problem appears to be that:
> >   * On boot, platform_drv_probe() calls dev_pm_domain_attach() before
> > drv->probe(); thus, it calls dev_pm_domain_attach() while the device
> > is unbound.
> >
> >  * However, for a platform_device, the reboot path calls
> > device_shutdown(), but not __device_release_driver():
> > device_shutdown()
> >   dev->driver->shutdown => platform_drv_shutdown()
> > dev_pm_domain_detach()
> >dev->pm_domain->detach() => genpd_dev_pm_detach()
> >  pm_genpd_remove_device()
> > dev_pm_domain_set(dev, NULL);
> >
> > So, for a platform_device in a genpd power domain with .shutdown
> > installed, platform_drv_shutdown() calls dev_pm_domain_detach() while
> > the device is still bound, which triggers the WARN().
> 
> Hi Rafael, Alan and Ulf,
> 
> do you have any suggestion about this? I don't really understand why
> the device is detached from the domain on shutdown.

Well, this looks like a bug to me.

Thanks,
Rafael